diff --git a/api/src/main/java/javax/jdo/AttributeConverter.java b/api/src/main/java/javax/jdo/AttributeConverter.java index ea94c3a1c..61e3dcfe2 100644 --- a/api/src/main/java/javax/jdo/AttributeConverter.java +++ b/api/src/main/java/javax/jdo/AttributeConverter.java @@ -17,50 +17,44 @@ package javax.jdo; /** - * Converts persistent attribute values (fields or properties) to different values stored in the - * underlying datastore and vice versa. [TBD: - * + * Converts persistent attribute values (fields or properties) to different + * values stored in the underlying datastore and vice versa. + * [TBD: * - * - * ] - * + *
  • should we require that converters need access to any other information, e.g metadata? passed into the constructor
  • + *
  • otherwise we assume there is a default constructor, and is instantiable using the current JDO class loader(s)
  • + * ] + * * @param The type of persistent attribute (field or property). * @param The type to be used in the datastore. */ public interface AttributeConverter { - /** - * Converts the given persistent attribute value to its representation in the datastore. - * - * @param attributeValue Value of attribute - * @return Value in datastore - */ - D convertToDatastore(A attributeValue); + /** + * Converts the given persistent attribute value to its representation in the datastore. + * @param attributeValue Value of attribute + * @return Value in datastore + */ + D convertToDatastore(A attributeValue); - /** - * Converts the given datastore value to its representation as a persistent attribute. - * - * @param datastoreValue Value in datastore - * @return Value in attribute - */ - A convertToAttribute(D datastoreValue); + /** + * Converts the given datastore value to its representation as a persistent attribute. + * @param datastoreValue Value in datastore + * @return Value in attribute + */ + A convertToAttribute(D datastoreValue); - /** - * Dummy converter to represent "use the implementation default for this type" when using - * annotations. - */ - public static class UseDefault implements AttributeConverter { - public Object convertToDatastore(Object attributeValue) { - throw new JDOUserException("This converter is not usable."); - } + /** + * Dummy converter to represent "use the implementation default for this type" when using annotations. + */ + public static class UseDefault implements AttributeConverter + { + public Object convertToDatastore(Object attributeValue) { + throw new JDOUserException("This converter is not usable."); + } - public Object convertToAttribute(Object datastoreValue) { - throw new JDOUserException("This converter is not usable."); - } - } + public Object convertToAttribute(Object datastoreValue) { + throw new JDOUserException("This converter is not usable."); + } + } } diff --git a/api/src/main/java/javax/jdo/Constants.java b/api/src/main/java/javax/jdo/Constants.java index 8f4a69cef..18169f3b2 100644 --- a/api/src/main/java/javax/jdo/Constants.java +++ b/api/src/main/java/javax/jdo/Constants.java @@ -25,941 +25,1072 @@ */ public interface Constants { - /** - * The JDO standard package name. - * - * @since 3.1 - */ - static String JAVAX_JDO = "javax.jdo"; - - /** The JDO standard property string and option string prefix. */ - static String JAVAX_JDO_PREFIX = JAVAX_JDO + "."; - - /** - * The name of the standard service configuration resource text file containing the name of an - * implementation of {@link PersistenceManagerFactory}. Constant value is - * META-INF/services/javax.jdo.PersistenceManagerFactory. - * - * @since 2.1 - */ - static String SERVICE_LOOKUP_PMF_RESOURCE_NAME = - "META-INF/services/javax.jdo.PersistenceManagerFactory"; - - /** - * The name of the standard service configuration resource text file containing the name of an - * enhancer of {@link JDOEnhancer}. Constant value is - * META-INF/services/javax.jdo.JDOEnhancer. - * - * @since 3.0 - */ - static String SERVICE_LOOKUP_ENHANCER_RESOURCE_NAME = "META-INF/services/javax.jdo.JDOEnhancer"; - - /** - * The name of the standard JDO configuration resource file(s). Constant value is - * META-INF/jdoconfig.xml. - * - * @since 2.1 - */ - static String JDOCONFIG_RESOURCE_NAME = "META-INF/jdoconfig.xml"; - - /** - * The standard JDO configuration schema namespace. Constant value is - * https://db.apache.org/jdo/xmlns/jdoconfig. - * - * @since 2.1 - */ - static String JDOCONFIG_XSD_NS = "https://db.apache.org/jdo/xmlns/jdoconfig"; - - /** - * The standard JDO metadata schema namespace. Constant value is - * https://db.apache.org/jdo/xmlns/jdo. - * - * @since 2.1 - */ - static String JDO_XSD_NS = "https://db.apache.org/jdo/xmlns/jdo"; - - /** - * The standard JDO object-repository mapping schema namespace. Constant value is - * https://db.apache.org/jdo/xmlns/orm. - * - * @since 2.1 - */ - static String ORM_XSD_NS = "https://db.apache.org/jdo/xmlns/orm"; - - /** - * The standard JDO query schema namespace. Constant value is - * https://db.apache.org/jdo/xmlns/jdoquery. - * - * @since 2.1 - */ - static String JDOQUERY_XSD_NS = "https://db.apache.org/jdo/xmlns/jdoquery"; - - /** - * The name of the persistence manager factory element in the JDO configuration file. Constant - * value is persistence-manager-factory. - * - * @since 2.1 - */ - static String ELEMENT_PERSISTENCE_MANAGER_FACTORY = "persistence-manager-factory"; - - /** - * The name of the persistence manager factory element's "class" attribute. - * - * @since 2.1 - */ - static String PMF_ATTRIBUTE_CLASS = "class"; - /** - * The name of the persistence manager factory element's "name" attribute. - * - * @since 2.1 - */ - static String PMF_ATTRIBUTE_NAME = "name"; - /** - * The name of the persistence manager factory element's "persistence-unit-name" attribute. - * - * @since 2.1 - */ - static String PMF_ATTRIBUTE_PERSISTENCE_UNIT_NAME = "persistence-unit-name"; - /** - * The name of the persistence manager factory element's "optimistic" attribute. - * - * @since 2.1 - */ - static String PMF_ATTRIBUTE_OPTIMISTIC = "optimistic"; - /** - * The name of the persistence manager factory element's "readonly" attribute. - * - * @since 2.2 - */ - static String PMF_ATTRIBUTE_READONLY = "readonly"; - /** - * The name of the persistence manager factory element's "retain-values" attribute. - * - * @since 2.1 - */ - static String PMF_ATTRIBUTE_RETAIN_VALUES = "retain-values"; - /** - * The name of the persistence manager factory element's "restore-values" attribute. - * - * @since 2.1 - */ - static String PMF_ATTRIBUTE_RESTORE_VALUES = "restore-values"; - /** - * The name of the persistence manager factory element's "ignore-cache" attribute. - * - * @since 2.1 - */ - static String PMF_ATTRIBUTE_IGNORE_CACHE = "ignore-cache"; - /** - * The name of the persistence manager factory element's "nontransactional-read" attribute. - * - * @since 2.1 - */ - static String PMF_ATTRIBUTE_NONTRANSACTIONAL_READ = "nontransactional-read"; - /** - * The name of the persistence manager factory element's "nontransactional-write" attribute. - * - * @since 2.1 - */ - static String PMF_ATTRIBUTE_NONTRANSACTIONAL_WRITE = "nontransactional-write"; - /** - * The name of the persistence manager factory element's "multithreaded" attribute. - * - * @since 2.1 - */ - static String PMF_ATTRIBUTE_MULTITHREADED = "multithreaded"; - /** - * The name of the persistence manager factory element's "connection-driver-name" attribute. - * - * @since 2.1 - */ - static String PMF_ATTRIBUTE_CONNECTION_DRIVER_NAME = "connection-driver-name"; - /** - * The name of the persistence manager factory element's "connection-user-name" attribute. - * - * @since 2.1 - */ - static String PMF_ATTRIBUTE_CONNECTION_USER_NAME = "connection-user-name"; - /** - * The name of the persistence manager factory element's "connection-password" attribute. - * - * @since 2.1 - */ - static String PMF_ATTRIBUTE_CONNECTION_PASSWORD = "connection-password"; - /** - * The name of the persistence manager factory element's "connection-url" attribute. - * - * @since 2.1 - */ - static String PMF_ATTRIBUTE_CONNECTION_URL = "connection-url"; - /** - * The name of the persistence manager factory element's "connection-factory-name" attribute. - * - * @since 2.1 - */ - static String PMF_ATTRIBUTE_CONNECTION_FACTORY_NAME = "connection-factory-name"; - /** - * The name of the persistence manager factory element's "connection-factory2-name" attribute. - * - * @since 2.1 - */ - static String PMF_ATTRIBUTE_CONNECTION_FACTORY2_NAME = "connection-factory2-name"; - /** - * The name of the persistence manager factory element's "detach-all-on-commit" attribute. - * - * @since 2.1 - */ - static String PMF_ATTRIBUTE_DETACH_ALL_ON_COMMIT = "detach-all-on-commit"; - /** - * The name of the persistence manager factory element's "copy-on-attach" attribute. - * - * @since 2.1 - */ - static String PMF_ATTRIBUTE_COPY_ON_ATTACH = "copy-on-attach"; - /** - * The name of the persistence manager factory element's "mapping" attribute. - * - * @since 2.1 - */ - static String PMF_ATTRIBUTE_MAPPING = "mapping"; - /** - * The name of the persistence manager factory element's "server-time-zone-id" attribute. - * - * @since 2.1 - */ - static String PMF_ATTRIBUTE_SERVER_TIME_ZONE_ID = "server-time-zone-id"; - /** - * The name of the persistence manager factory element's "datastore-read-timeout-millis" - * attribute. - * - * @since 3.0 - */ - static String PMF_ATTRIBUTE_DATASTORE_READ_TIMEOUT_MILLIS = "datastore-read-timeout-millis"; - /** - * The name of the persistence manager factory element's "datastore-write-timeout-millis" - * attribute. - * - * @since 3.0 - */ - static String PMF_ATTRIBUTE_DATASTORE_WRITE_TIMEOUT_MILLIS = "datastore-write-timeout-millis"; - /** - * The name of the persistence manager factory property elements in the JDO configuration file. - */ - static String ELEMENT_PROPERTY = "property"; - /** The name of the persistence manager factory property element's "name" attribute. */ - static String PROPERTY_ATTRIBUTE_NAME = "name"; - /** The name of the persistence manager factory property element's "value" attribute. */ - static String PROPERTY_ATTRIBUTE_VALUE = "value"; - - /** The name of the instance lifecycle listener element in the JDO configuration file. */ - static String ELEMENT_INSTANCE_LIFECYCLE_LISTENER = "instance-lifecycle-listener"; - - /** The name of the instance lifecycle listener element's "listener" attribute. */ - static String INSTANCE_LIFECYCLE_LISTENER_ATTRIBUTE_LISTENER = "listener"; - /** The name of the instance lifecycle listener element's "classes" attribute. */ - static String INSTANCE_LIFECYCLE_LISTENER_ATTRIBUTE_CLASSES = "classes"; - - /** - * "javax.jdo.option.TransientTransactional" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_TRANSACTIONAL_TRANSIENT = "javax.jdo.option.TransientTransactional"; - /** - * "javax.jdo.option.NontransactionalRead" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_NONTRANSACTIONAL_READ = "javax.jdo.option.NontransactionalRead"; - /** - * "javax.jdo.option.NontransactionalWrite" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_NONTRANSACTIONAL_WRITE = "javax.jdo.option.NontransactionalWrite"; - /** - * "javax.jdo.option.RetainValues" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_RETAIN_VALUES = "javax.jdo.option.RetainValues"; - /** - * "javax.jdo.option.Optimistic" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_OPTIMISTIC = "javax.jdo.option.Optimistic"; - /** - * "javax.jdo.option.ApplicationIdentity" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_APPLICATION_IDENTITY = "javax.jdo.option.ApplicationIdentity"; - /** - * "javax.jdo.option.DatastoreIdentity" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_DATASTORE_IDENTITY = "javax.jdo.option.DatastoreIdentity"; - /** - * "javax.jdo.option.NonDurableIdentity" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_NONDURABLE_IDENTITY = "javax.jdo.option.NonDurableIdentity"; - /** - * "javax.jdo.option.ArrayList" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_ARRAYLIST = "javax.jdo.option.ArrayList"; - /** - * "javax.jdo.option.LinkedList" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_LINKEDLIST = "javax.jdo.option.LinkedList"; - /** - * "javax.jdo.option.TreeMap" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_TREEMAP = "javax.jdo.option.TreeMap"; - /** - * "javax.jdo.option.TreeSet" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_TREESET = "javax.jdo.option.TreeSet"; - /** - * "javax.jdo.option.Vector" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_VECTOR = "javax.jdo.option.Vector"; - /** - * "javax.jdo.option.Array" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_ARRAY = "javax.jdo.option.Array"; - /** - * "javax.jdo.option.NullCollection" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_NULL_COLLECTION = "javax.jdo.option.NullCollection"; - /** - * "javax.jdo.option.ChangeApplicationIdentity" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_CHANGE_APPLICATION_IDENTITY = "javax.jdo.option.ChangeApplicationIdentity"; - /** - * "javax.jdo.option.BinaryCompatibility" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_BINARY_COMPATIBILITY = "javax.jdo.option.BinaryCompatibility"; - /** - * "javax.jdo.option.GetDataStoreConnection" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_GET_DATASTORE_CONNECTION = "javax.jdo.option.GetDataStoreConnection"; - /** - * "javax.jdo.option.GetJDBCConnection" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_GET_JDBC_CONNECTION = "javax.jdo.option.GetJDBCConnection"; - /** - * "javax.jdo.query.SQL" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_QUERY_SQL = "javax.jdo.query.SQL"; - - /** - * "javax.jdo.option.QueryCancel" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 3.0 - */ - static String OPTION_QUERY_CANCEL = "javax.jdo.option.QueryCancel"; - - /** - * "javax.jdo.query.JDOQL.BitwiseOperations" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 3.2 - */ - static String OPTION_QUERY_JDOQL_BITWISE_OPERATIONS = "javax.jdo.query.JDOQL.BitwiseOperations"; - - /** - * "javax.jdo.query.JDOQL.UnconstrainedQueryVariables" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_UNCONSTRAINED_QUERY_VARIABLES = - "javax.jdo.query.JDOQL.UnconstrainedQueryVariables"; - - /** - * "javax.jdo.option.DatastoreTimeout" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 3.0 - */ - static String OPTION_DATASTORE_TIMEOUT = "javax.jdo.option.DatastoreTimeout"; - /** - * "javax.jdo.option.version.DateTime" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_VERSION_DATETIME = "javax.jdo.option.version.DateTime"; - /** - * "javax.jdo.option.version.StateImage" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_VERSION_STATE_IMAGE = "javax.jdo.option.version.StateImage"; - /** - * "javax.jdo.option.PreDirtyEvent" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_PREDIRTY_EVENT = "javax.jdo.option.PreDirtyEvent"; - /** - * "javax.jdo.option.mapping.HeterogeneousObjectType" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_MAPPING_HETEROGENEOUS_OBJECT_TYPE = - "javax.jdo.option.mapping.HeterogeneousObjectType"; - /** - * "javax.jdo.option.mapping.HeterogeneousInterfaceType" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_MAPPING_HETEROGENEOUS_INTERFACE_TYPE = - "javax.jdo.option.mapping.HeterogeneousInterfaceType"; - /** - * "javax.jdo.option.mapping.JoinedTablePerClass" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_MAPPING_JOINED_TABLE_PER_CLASS = - "javax.jdo.option.mapping.JoinedTablePerClass"; - /** - * "javax.jdo.option.mapping.JoinedTablePerConcreteClass" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_MAPPING_JOINED_TABLE_PER_CONCRETE_CLASS = - "javax.jdo.option.mapping.JoinedTablePerConcreteClass"; - /** - * "javax.jdo.option.mapping.NonJoinedTablePerConcreteClass" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_MAPPING_NON_JOINED_TABLE_PER_CONCRETE_CLASS = - "javax.jdo.option.mapping.NonJoinedTablePerConcreteClass"; - /** - * "javax.jdo.option.mapping.RelationSubclassTable" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.1 - */ - static String OPTION_MAPPING_RELATION_SUBCLASS_TABLE = - "javax.jdo.option.mapping.RelationSubclassTable"; - - /** - * "javax.jdo.PersistenceManagerFactoryClass" - * - * @see JDOHelper#getPersistenceManagerFactory(java.util.Map) - * @since 2.1 - */ - static String PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS = - "javax.jdo.PersistenceManagerFactoryClass"; - - /** - * "VendorName" - * - * @see JDOEnhancer#getProperties() - * @since 3.0 - */ - public static final String PROPERTY_ENHANCER_VENDOR_NAME = "VendorName"; - - /** - * "VersionNumber" - * - * @see JDOEnhancer#getProperties() - * @since 3.0 - */ - public static final String PROPERTY_ENHANCER_VERSION_NUMBER = "VersionNumber"; - - /** - * Exit value for no enhancer found - * - * @since 3.0 - */ - public static final int ENHANCER_NO_JDO_ENHANCER_FOUND = 2; - - /** - * Exit value for usage error - * - * @since 3.0 - */ - public static final int ENHANCER_USAGE_ERROR = 3; - - /** - * Exit value for an exception from the JDOEnhancer - * - * @since 3.0 - */ - public static final int ENHANCER_EXCEPTION = 1; - - /** - * "javax.jdo.option.Optimistic" - * - * @see PersistenceManagerFactory#getOptimistic() - * @since 2.1 - */ - static String PROPERTY_OPTIMISTIC = "javax.jdo.option.Optimistic"; - /** - * "javax.jdo.option.ReadOnly" - * - * @see PersistenceManagerFactory#getReadOnly() - * @since 2.2 - */ - static String PROPERTY_READONLY = "javax.jdo.option.ReadOnly"; - /** - * "javax.jdo.option.RetainValues" - * - * @see PersistenceManagerFactory#getRetainValues() - * @since 2.1 - */ - static String PROPERTY_RETAIN_VALUES = "javax.jdo.option.RetainValues"; - /** - * "javax.jdo.option.RestoreValues" - * - * @see PersistenceManagerFactory#getRestoreValues() - * @since 2.1 - */ - static String PROPERTY_RESTORE_VALUES = "javax.jdo.option.RestoreValues"; - /** - * "javax.jdo.option.IgnoreCache" - * - * @see PersistenceManagerFactory#getIgnoreCache() - * @since 2.1 - */ - static String PROPERTY_IGNORE_CACHE = "javax.jdo.option.IgnoreCache"; - /** - * "javax.jdo.option.NontransactionalRead" - * - * @see PersistenceManagerFactory#getNontransactionalRead() - * @since 2.1 - */ - static String PROPERTY_NONTRANSACTIONAL_READ = "javax.jdo.option.NontransactionalRead"; - /** - * "javax.jdo.option.NontransactionalWrite" - * - * @see PersistenceManagerFactory#getNontransactionalWrite() - * @since 2.1 - */ - static String PROPERTY_NONTRANSACTIONAL_WRITE = "javax.jdo.option.NontransactionalWrite"; - /** - * "javax.jdo.option.Multithreaded" - * - * @see PersistenceManagerFactory#getMultithreaded() - * @since 2.1 - */ - static String PROPERTY_MULTITHREADED = "javax.jdo.option.Multithreaded"; - /** - * "javax.jdo.option.TransactionIsolationLevel" - * - * @since 2.2 - */ - static String PROPERTY_TRANSACTION_ISOLATION_LEVEL = "javax.jdo.option.TransactionIsolationLevel"; - /** - * "javax.jdo.option.TransactionIsolationLevel.read-uncommitted" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.2 - */ - static String PROPERTY_TRANSACTION_ISOLATION_LEVEL_READ_UNCOMMITTED = - "javax.jdo.option.TransactionIsolationLevel.read-uncommitted"; - /** - * "javax.jdo.option.TransactionIsolationLevel.read-committed" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.2 - */ - static String PROPERTY_TRANSACTION_ISOLATION_LEVEL_READ_COMMITTED = - "javax.jdo.option.TransactionIsolationLevel.read-committed"; - /** - * "javax.jdo.option.TransactionIsolationLevel.repeatable-read" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.2 - */ - static String PROPERTY_TRANSACTION_ISOLATION_LEVEL_REPEATABLE_READ = - "javax.jdo.option.TransactionIsolationLevel.repeatable-read"; - /** - * "javax.jdo.option.TransactionIsolationLevel.snapshot" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.2 - */ - static String PROPERTY_TRANSACTION_ISOLATION_LEVEL_SNAPSHOT = - "javax.jdo.option.TransactionIsolationLevel.snapshot"; - /** - * "javax.jdo.option.TransactionIsolationLevel.serializable" - * - * @see PersistenceManagerFactory#supportedOptions() - * @since 2.2 - */ - static String PROPERTY_TRANSACTION_ISOLATION_LEVEL_SERIALIZABLE = - "javax.jdo.option.TransactionIsolationLevel.serializable"; - /** - * "javax.jdo.option.DetachAllOnCommit" - * - * @see PersistenceManagerFactory#getDetachAllOnCommit() - * @since 2.1 - */ - static String PROPERTY_DETACH_ALL_ON_COMMIT = "javax.jdo.option.DetachAllOnCommit"; - /** - * "javax.jdo.option.CopyOnAttach" - * - * @see PersistenceManagerFactory#getCopyOnAttach() - * @since 2.1 - */ - static String PROPERTY_COPY_ON_ATTACH = "javax.jdo.option.CopyOnAttach"; - /** - * "javax.jdo.option.ConnectionDriverName" This property might be ignored by the JDO - * implementation because the JDBC DriverManager handles the driver name. - * - * @see PersistenceManagerFactory#getConnectionDriverName() - * @since 2.1 - */ - static String PROPERTY_CONNECTION_DRIVER_NAME = "javax.jdo.option.ConnectionDriverName"; - /** - * "javax.jdo.option.ConnectionUserName" - * - * @see PersistenceManagerFactory#getConnectionUserName() - * @since 2.1 - */ - static String PROPERTY_CONNECTION_USER_NAME = "javax.jdo.option.ConnectionUserName"; - /** - * "javax.jdo.option.Password" - * - * @since 2.1 - */ - static String PROPERTY_CONNECTION_PASSWORD = "javax.jdo.option.ConnectionPassword"; - /** - * "javax.jdo.option.ConnectionURL" - * - * @see PersistenceManagerFactory#getConnectionURL() - * @since 2.1 - */ - static String PROPERTY_CONNECTION_URL = "javax.jdo.option.ConnectionURL"; - /** - * "javax.jdo.option.ConnectionFactoryName" - * - * @see PersistenceManagerFactory#getConnectionFactoryName() - * @since 2.1 - */ - static String PROPERTY_CONNECTION_FACTORY_NAME = "javax.jdo.option.ConnectionFactoryName"; - /** - * "javax.jdo.option.ConnectionFactory2Name" - * - * @see PersistenceManagerFactory#getConnectionFactory2Name() - * @since 2.1 - */ - static String PROPERTY_CONNECTION_FACTORY2_NAME = "javax.jdo.option.ConnectionFactory2Name"; - /** - * "javax.jdo.option.Mapping" - * - * @see PersistenceManagerFactory#getMapping() - * @since 2.1 - */ - static String PROPERTY_MAPPING = "javax.jdo.option.Mapping"; - /** - * "javax.jdo.option.PersistenceUnitName" - * - * @see PersistenceManagerFactory#getPersistenceUnitName() - * @since 2.1 - */ - static String PROPERTY_PERSISTENCE_UNIT_NAME = "javax.jdo.option.PersistenceUnitName"; - /** - * "javax.jdo.option.Name" - * - * @see PersistenceManagerFactory#getName() - * @since 2.1 - */ - static String PROPERTY_NAME = "javax.jdo.option.Name"; - - /** - * "javax.jdo.spi.PropertiesFileName" - * - * @since 3.2 - */ - static String PROPERTY_SPI_PROPERTIES_FILE_NAME = "javax.jdo.spi.PropertiesFileName"; - - /** - * "javax.jdo.option.spi.ResourceName" - * - * @since 2.1 - */ - static String PROPERTY_SPI_RESOURCE_NAME = "javax.jdo.option.spi.ResourceName"; - - /** - * "javax.jdo.listener.InstanceLifecycleListener" - * - * @see - * PersistenceManagerFactory#addInstanceLifecycleListener(javax.jdo.listener.InstanceLifecycleListener,Class[]) - * @see - * PersistenceManagerFactory#removeInstanceLifecycleListener(javax.jdo.listener.InstanceLifecycleListener) - */ - static String PROPERTY_INSTANCE_LIFECYCLE_LISTENER = - "javax.jdo.listener.InstanceLifecycleListener"; - - /** - * Prefix used to configure {@link javax.jdo.listener.InstanceLifecycleListener} instances - * externally. To configure an InstanceLifecycleListener via properties, create a - * property name with the prefix of this constant and append the fully qualified listener class - * name, then set its value to the comma- or whitespace-delimited list of persistence-capable - * classes whose instances are to be observed. Use no value to indicate that instances of all - * persistence-capable classes are to be observed.
    - * For example,
    - * - * javax.jdo.option.InstanceLifecycleListener.com.example.MyListener=com.example.Foo,com.example.Bar - *
    - * is equivalent to calling
    - * - * pmf.addInstanceLifecycleListener(new com.example.MyListener(), new Class[] {com.example.Foo.class, com.example.Bar.class}); - *
    - * where pmf is an instance of type PersistenceManagerFactory. - * - * @see - * javax.jdo.PersistenceManagerFactory#addInstanceLifecycleListener(javax.jdo.listener.InstanceLifecycleListener,Class[]) - * @since 2.1 - */ - static String PROPERTY_PREFIX_INSTANCE_LIFECYCLE_LISTENER = - PROPERTY_INSTANCE_LIFECYCLE_LISTENER + "."; - - /** - * Mapping "javax.jdo.mapping.Catalog" - * - * @since 2.1 - */ - static String PROPERTY_MAPPING_CATALOG = "javax.jdo.mapping.Catalog"; - /** - * Mapping "javax.jdo.mapping.Schema" - * - * @since 2.1 - */ - static String PROPERTY_MAPPING_SCHEMA = "javax.jdo.mapping.Schema"; - - /** - * Specified value "javax.jdo.option.ServerTimeZoneID" - * - * @since 2.1 - */ - static String PROPERTY_SERVER_TIME_ZONE_ID = "javax.jdo.option.ServerTimeZoneID"; - - /** - * Specified value "javax.jdo.option.DatastoreReadTimeoutMillis" - * - * @since 3.0 - */ - static String PROPERTY_DATASTORE_READ_TIMEOUT_MILLIS = - "javax.jdo.option.DatastoreReadTimeoutMillis"; - - /** - * Specified value "javax.jdo.option.DatastoreWriteTimeoutMillis" - * - * @since 3.0 - */ - static String PROPERTY_DATASTORE_WRITE_TIMEOUT_MILLIS = - "javax.jdo.option.DatastoreWriteTimeoutMillis"; - - /** - * Nonconfigurable property constant "VendorName" - * - * @see PersistenceManagerFactory#getProperties() - * @since 2.1 - */ - static String NONCONFIGURABLE_PROPERTY_VENDOR_NAME = "VendorName"; - - /** - * Nonconfigurable property constant "VersionNumber" - * - * @see PersistenceManagerFactory#getProperties() - * @since 2.1 - */ - static String NONCONFIGURABLE_PROPERTY_VERSION_NUMBER = "VersionNumber"; - - /** - * Specified value "javax.jdo.option.TransactionType" - * - * @since 2.1 - */ - static String PROPERTY_TRANSACTION_TYPE = "javax.jdo.option.TransactionType"; - - /** - * The value for TransactionType to specify that transactions are managed by the Java Transactions - * API, as documented in JSR-220. - * - * @since 2.1 - */ - static String JTA = "JTA"; - - /** - * The value for TransactionType to specify that transactions are managed by the - * javax.jdo.Transaction instance, similar to the usage as documented in JSR-220. - * - * @since 2.1 - */ - static String RESOURCE_LOCAL = "RESOURCE_LOCAL"; - - /** - * The name of the resource for the DTD of the standard JDO configuration file. - * - * @since 2.1 - */ - static String JDOCONFIG_DTD_RESOURCE = "javax/jdo/jdoconfig_3_0.dtd"; - - /** - * The name of the resource for the XML schema of the standard JDO configuration file. - * - * @since 2.1 - */ - static String JDOCONFIG_XSD_RESOURCE = "javax/jdo/jdoconfig_3_0.xsd"; - - /** - * The name of the resource for the DTD of the standard JDO metadata file. - * - * @since 2.1 - */ - static String JDO_DTD_RESOURCE = "javax/jdo/jdo_3_0.dtd"; - - /** - * The name of the resource for the XML schema of the standard JDO metadata file. - * - * @since 2.1 - */ - static String JDO_XSD_RESOURCE = "javax/jdo/jdo_3_0.xsd"; - - /** - * The name of the resource for the DTD of the standard JDO object-relational mapping metadata - * file. - * - * @since 2.1 - */ - static String ORM_DTD_RESOURCE = "javax/jdo/orm_3_0.dtd"; - - /** - * The name of the resource for the XML schema of the standard JDO object-relational mapping - * metadata file. - * - * @since 2.1 - */ - static String ORM_XSD_RESOURCE = "javax/jdo/orm_3_0.xsd"; - - /** - * The name of the resource for the DTD of the standard JDO query metadata file. - * - * @since 2.1 - */ - static String JDOQUERY_DTD_RESOURCE = "javax/jdo/jdoquery_3_0.dtd"; - - /** - * The name of the resource for the XML schema of the standard JDO query metadata file. - * - * @since 2.1 - */ - static String JDOQUERY_XSD_RESOURCE = "javax/jdo/jdoquery_3_0.xsd"; - - /** - * The name of the anonymous PersistenceManagerFactory, which is the empty string. - * - * @since 2.1 - */ - static String ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME = ""; - - /** - * Transaction isolation level representing the ability to read uncommitted data. - * - * @see PersistenceManagerFactory#getTransactionIsolationLevel() - * @see Transaction#getIsolationLevel() - * @since 2.2 - */ - public static final String TX_READ_UNCOMMITTED = "read-uncommitted"; - - /** - * Transaction isolation level representing the requirement to read committed data only. - * - * @see PersistenceManagerFactory#getTransactionIsolationLevel() - * @see Transaction#getIsolationLevel() - * @since 2.2 - */ - public static final String TX_READ_COMMITTED = "read-committed"; - - /** - * Transaction isolation level representing the requirement to read the same data in the same - * transaction. - * - * @see PersistenceManagerFactory#getTransactionIsolationLevel() - * @see Transaction#getIsolationLevel() - * @since 2.2 - */ - public static final String TX_REPEATABLE_READ = "repeatable-read"; - - /** - * Transaction isolation level representing the requirement to keep a snapshot for reading data. - * - * @see PersistenceManagerFactory#getTransactionIsolationLevel() - * @see Transaction#getIsolationLevel() - * @since 2.2 - */ - public static final String TX_SNAPSHOT = "snapshot"; - - /** - * Transaction isolation level representing the requirement to serialize transactions. - * - * @see PersistenceManagerFactory#getTransactionIsolationLevel() - * @see Transaction#getIsolationLevel() - * @since 2.2 - */ - public static final String TX_SERIALIZABLE = "serializable"; + /** + * The JDO standard package name. + * @since 3.1 + */ + static String JAVAX_JDO = "javax.jdo"; + + /** + * The JDO standard property string and option string prefix. + */ + static String JAVAX_JDO_PREFIX = JAVAX_JDO + "."; + + /** + * The name of the standard service configuration resource text file containing + * the name of an implementation of {@link PersistenceManagerFactory}. + * Constant value is META-INF/services/javax.jdo.PersistenceManagerFactory. + * + * @since 2.1 + */ + static String SERVICE_LOOKUP_PMF_RESOURCE_NAME + = "META-INF/services/javax.jdo.PersistenceManagerFactory"; + + /** + * The name of the standard service configuration resource text file containing + * the name of an enhancer of {@link JDOEnhancer}. + * Constant value is META-INF/services/javax.jdo.JDOEnhancer. + * @since 3.0 + */ + static String SERVICE_LOOKUP_ENHANCER_RESOURCE_NAME + = "META-INF/services/javax.jdo.JDOEnhancer"; + + /** + * The name of the standard JDO configuration resource file(s). + * Constant value is META-INF/jdoconfig.xml. + * + * @since 2.1 + */ + static String JDOCONFIG_RESOURCE_NAME + = "META-INF/jdoconfig.xml"; + + /** + * The standard JDO configuration schema namespace. + * Constant value is https://db.apache.org/jdo/xmlns/jdoconfig. + * + * @since 2.1 + */ + static String JDOCONFIG_XSD_NS + = "https://db.apache.org/jdo/xmlns/jdoconfig"; + + /** + * The standard JDO metadata schema namespace. + * Constant value is https://db.apache.org/jdo/xmlns/jdo. + * + * @since 2.1 + */ + static String JDO_XSD_NS + = "https://db.apache.org/jdo/xmlns/jdo"; + + /** + * The standard JDO object-repository mapping schema namespace. + * Constant value is https://db.apache.org/jdo/xmlns/orm. + * + * @since 2.1 + */ + static String ORM_XSD_NS + = "https://db.apache.org/jdo/xmlns/orm"; + + /** + * The standard JDO query schema namespace. + * Constant value is https://db.apache.org/jdo/xmlns/jdoquery. + * + * @since 2.1 + */ + static String JDOQUERY_XSD_NS + = "https://db.apache.org/jdo/xmlns/jdoquery"; + + /** + * The name of the persistence manager factory element in the JDO + * configuration file. + * Constant value is persistence-manager-factory. + * + * @since 2.1 + */ + static String ELEMENT_PERSISTENCE_MANAGER_FACTORY + = "persistence-manager-factory"; + + /** + * The name of the persistence manager factory element's "class" attribute. + * + * @since 2.1 + */ + static String PMF_ATTRIBUTE_CLASS + = "class"; + /** + * The name of the persistence manager factory element's + * "name" attribute. + * + * @since 2.1 + */ + static String PMF_ATTRIBUTE_NAME + = "name"; + /** + * The name of the persistence manager factory element's + * "persistence-unit-name" attribute. + * + * @since 2.1 + */ + static String PMF_ATTRIBUTE_PERSISTENCE_UNIT_NAME + = "persistence-unit-name"; + /** + * The name of the persistence manager factory element's "optimistic" + * attribute. + * + * @since 2.1 + */ + static String PMF_ATTRIBUTE_OPTIMISTIC + = "optimistic"; + /** + * The name of the persistence manager factory element's "readonly" + * attribute. + * + * @since 2.2 + */ + static String PMF_ATTRIBUTE_READONLY + = "readonly"; + /** + * The name of the persistence manager factory element's "retain-values" + * attribute. + * + * @since 2.1 + */ + static String PMF_ATTRIBUTE_RETAIN_VALUES + = "retain-values"; + /** + * The name of the persistence manager factory element's "restore-values" + * attribute. + * + * @since 2.1 + */ + static String PMF_ATTRIBUTE_RESTORE_VALUES + = "restore-values"; + /** + * The name of the persistence manager factory element's "ignore-cache" + * attribute. + * + * @since 2.1 + */ + static String PMF_ATTRIBUTE_IGNORE_CACHE + = "ignore-cache"; + /** + * The name of the persistence manager factory element's + * "nontransactional-read" attribute. + * + * @since 2.1 + */ + static String PMF_ATTRIBUTE_NONTRANSACTIONAL_READ + = "nontransactional-read"; + /** + * The name of the persistence manager factory element's + * "nontransactional-write" attribute. + * + * @since 2.1 + */ + static String PMF_ATTRIBUTE_NONTRANSACTIONAL_WRITE + = "nontransactional-write"; + /** + * The name of the persistence manager factory element's "multithreaded" + * attribute. + * + * @since 2.1 + */ + static String PMF_ATTRIBUTE_MULTITHREADED + = "multithreaded"; + /** + * The name of the persistence manager factory element's + * "connection-driver-name" attribute. + * + * @since 2.1 + */ + static String PMF_ATTRIBUTE_CONNECTION_DRIVER_NAME + = "connection-driver-name"; + /** + * The name of the persistence manager factory element's + * "connection-user-name" attribute. + * + * @since 2.1 + */ + static String PMF_ATTRIBUTE_CONNECTION_USER_NAME + = "connection-user-name"; + /** + * The name of the persistence manager factory element's + * "connection-password" attribute. + * + * @since 2.1 + */ + static String PMF_ATTRIBUTE_CONNECTION_PASSWORD + = "connection-password"; + /** + * The name of the persistence manager factory element's "connection-url" + * attribute. + * + * @since 2.1 + */ + static String PMF_ATTRIBUTE_CONNECTION_URL + = "connection-url"; + /** + * The name of the persistence manager factory element's + * "connection-factory-name" attribute. + * + * @since 2.1 + */ + static String PMF_ATTRIBUTE_CONNECTION_FACTORY_NAME + = "connection-factory-name"; + /** + * The name of the persistence manager factory element's + * "connection-factory2-name" attribute. + * + * @since 2.1 + */ + static String PMF_ATTRIBUTE_CONNECTION_FACTORY2_NAME + = "connection-factory2-name"; + /** + * The name of the persistence manager factory element's + * "detach-all-on-commit" attribute. + * + * @since 2.1 + */ + static String PMF_ATTRIBUTE_DETACH_ALL_ON_COMMIT + = "detach-all-on-commit"; + /** + * The name of the persistence manager factory element's + * "copy-on-attach" attribute. + * + * @since 2.1 + */ + static String PMF_ATTRIBUTE_COPY_ON_ATTACH + = "copy-on-attach"; + /** + * The name of the persistence manager factory element's "mapping" + * attribute. + * + * @since 2.1 + */ + static String PMF_ATTRIBUTE_MAPPING + = "mapping"; + /** + * The name of the persistence manager factory element's + * "server-time-zone-id" attribute. + * + * @since 2.1 + */ + static String PMF_ATTRIBUTE_SERVER_TIME_ZONE_ID + = "server-time-zone-id"; + /** + * The name of the persistence manager factory element's + * "datastore-read-timeout-millis" attribute. + * + * @since 3.0 + */ + static String PMF_ATTRIBUTE_DATASTORE_READ_TIMEOUT_MILLIS + = "datastore-read-timeout-millis"; + /** + * The name of the persistence manager factory element's + * "datastore-write-timeout-millis" attribute. + * + * @since 3.0 + */ + static String PMF_ATTRIBUTE_DATASTORE_WRITE_TIMEOUT_MILLIS + = "datastore-write-timeout-millis"; + /** + * The name of the persistence manager factory property elements in the JDO + * configuration file. + */ + static String ELEMENT_PROPERTY + = "property"; + /** + * The name of the persistence manager factory property element's "name" + * attribute. + */ + static String PROPERTY_ATTRIBUTE_NAME + = "name"; + /** + * The name of the persistence manager factory property element's "value" + * attribute. + */ + static String PROPERTY_ATTRIBUTE_VALUE + = "value"; + + /** + * The name of the instance lifecycle listener element in the JDO + * configuration file. + */ + static String ELEMENT_INSTANCE_LIFECYCLE_LISTENER + = "instance-lifecycle-listener"; + + /** + * The name of the instance lifecycle listener element's "listener" + * attribute. + */ + static String INSTANCE_LIFECYCLE_LISTENER_ATTRIBUTE_LISTENER + = "listener"; + /** + * The name of the instance lifecycle listener element's "classes" + * attribute. + */ + static String INSTANCE_LIFECYCLE_LISTENER_ATTRIBUTE_CLASSES + = "classes"; + + /** + * "javax.jdo.option.TransientTransactional" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_TRANSACTIONAL_TRANSIENT + = "javax.jdo.option.TransientTransactional"; + /** + * "javax.jdo.option.NontransactionalRead" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_NONTRANSACTIONAL_READ + = "javax.jdo.option.NontransactionalRead"; + /** + * "javax.jdo.option.NontransactionalWrite" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_NONTRANSACTIONAL_WRITE + = "javax.jdo.option.NontransactionalWrite"; + /** + * "javax.jdo.option.RetainValues" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_RETAIN_VALUES + = "javax.jdo.option.RetainValues"; + /** + * "javax.jdo.option.Optimistic" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_OPTIMISTIC + = "javax.jdo.option.Optimistic"; + /** + * "javax.jdo.option.ApplicationIdentity" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_APPLICATION_IDENTITY + = "javax.jdo.option.ApplicationIdentity"; + /** + * "javax.jdo.option.DatastoreIdentity" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_DATASTORE_IDENTITY + = "javax.jdo.option.DatastoreIdentity"; + /** + * "javax.jdo.option.NonDurableIdentity" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_NONDURABLE_IDENTITY + = "javax.jdo.option.NonDurableIdentity"; + /** + * "javax.jdo.option.ArrayList" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_ARRAYLIST + = "javax.jdo.option.ArrayList"; + /** + * "javax.jdo.option.LinkedList" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_LINKEDLIST + = "javax.jdo.option.LinkedList"; + /** + * "javax.jdo.option.TreeMap" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_TREEMAP + = "javax.jdo.option.TreeMap"; + /** + * "javax.jdo.option.TreeSet" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_TREESET + = "javax.jdo.option.TreeSet"; + /** + * "javax.jdo.option.Vector" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_VECTOR + = "javax.jdo.option.Vector"; + /** + * "javax.jdo.option.Array" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_ARRAY + = "javax.jdo.option.Array"; + /** + * "javax.jdo.option.NullCollection" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_NULL_COLLECTION + = "javax.jdo.option.NullCollection"; + /** + * "javax.jdo.option.ChangeApplicationIdentity" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_CHANGE_APPLICATION_IDENTITY + = "javax.jdo.option.ChangeApplicationIdentity"; + /** + * "javax.jdo.option.BinaryCompatibility" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_BINARY_COMPATIBILITY + = "javax.jdo.option.BinaryCompatibility"; + /** + * "javax.jdo.option.GetDataStoreConnection" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_GET_DATASTORE_CONNECTION + = "javax.jdo.option.GetDataStoreConnection"; + /** + * "javax.jdo.option.GetJDBCConnection" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_GET_JDBC_CONNECTION + = "javax.jdo.option.GetJDBCConnection"; + /** + * "javax.jdo.query.SQL" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_QUERY_SQL = "javax.jdo.query.SQL"; + + /** + * "javax.jdo.option.QueryCancel" + * @see PersistenceManagerFactory#supportedOptions() + * @since 3.0 + */ + static String OPTION_QUERY_CANCEL = "javax.jdo.option.QueryCancel"; + + /** + * "javax.jdo.query.JDOQL.BitwiseOperations" + * @see PersistenceManagerFactory#supportedOptions() + * @since 3.2 + */ + static String OPTION_QUERY_JDOQL_BITWISE_OPERATIONS = "javax.jdo.query.JDOQL.BitwiseOperations"; + + /** + * "javax.jdo.query.JDOQL.UnconstrainedQueryVariables" + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_UNCONSTRAINED_QUERY_VARIABLES = "javax.jdo.query.JDOQL.UnconstrainedQueryVariables"; + + /** + * "javax.jdo.option.DatastoreTimeout" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 3.0 + */ + static String OPTION_DATASTORE_TIMEOUT + = "javax.jdo.option.DatastoreTimeout"; + /** + * "javax.jdo.option.version.DateTime" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_VERSION_DATETIME + = "javax.jdo.option.version.DateTime"; + /** + * "javax.jdo.option.version.StateImage" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_VERSION_STATE_IMAGE + = "javax.jdo.option.version.StateImage"; + /** + * "javax.jdo.option.PreDirtyEvent" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_PREDIRTY_EVENT + = "javax.jdo.option.PreDirtyEvent"; + /** + * "javax.jdo.option.mapping.HeterogeneousObjectType" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_MAPPING_HETEROGENEOUS_OBJECT_TYPE + = "javax.jdo.option.mapping.HeterogeneousObjectType"; + /** + * "javax.jdo.option.mapping.HeterogeneousInterfaceType" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_MAPPING_HETEROGENEOUS_INTERFACE_TYPE + = "javax.jdo.option.mapping.HeterogeneousInterfaceType"; + /** + * "javax.jdo.option.mapping.JoinedTablePerClass" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_MAPPING_JOINED_TABLE_PER_CLASS + = "javax.jdo.option.mapping.JoinedTablePerClass"; + /** + * "javax.jdo.option.mapping.JoinedTablePerConcreteClass" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_MAPPING_JOINED_TABLE_PER_CONCRETE_CLASS + = "javax.jdo.option.mapping.JoinedTablePerConcreteClass"; + /** + * "javax.jdo.option.mapping.NonJoinedTablePerConcreteClass" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_MAPPING_NON_JOINED_TABLE_PER_CONCRETE_CLASS + = "javax.jdo.option.mapping.NonJoinedTablePerConcreteClass"; + /** + * "javax.jdo.option.mapping.RelationSubclassTable" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.1 + */ + static String OPTION_MAPPING_RELATION_SUBCLASS_TABLE + = "javax.jdo.option.mapping.RelationSubclassTable"; + + /** + * "javax.jdo.PersistenceManagerFactoryClass" + * + * @see JDOHelper#getPersistenceManagerFactory(java.util.Map) + * @since 2.1 + */ + static String PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS + = "javax.jdo.PersistenceManagerFactoryClass"; + + /** + * "VendorName" + * + * @see JDOEnhancer#getProperties() + * @since 3.0 + */ + public final static String PROPERTY_ENHANCER_VENDOR_NAME + = "VendorName"; + + /** + * "VersionNumber" + * + * @see JDOEnhancer#getProperties() + * @since 3.0 + */ + public final static String PROPERTY_ENHANCER_VERSION_NUMBER + = "VersionNumber"; + + /** Exit value for no enhancer found + * @since 3.0 + * */ + public final static int ENHANCER_NO_JDO_ENHANCER_FOUND = 2; + + /** Exit value for usage error + * @since 3.0 + * */ + public final static int ENHANCER_USAGE_ERROR = 3; + + /** Exit value for an exception from the JDOEnhancer + * @since 3.0 + * */ + public final static int ENHANCER_EXCEPTION = 1; + + /** + * "javax.jdo.option.Optimistic" + * + * @see PersistenceManagerFactory#getOptimistic() + * @since 2.1 + */ + static String PROPERTY_OPTIMISTIC + = "javax.jdo.option.Optimistic"; + /** + * "javax.jdo.option.ReadOnly" + * + * @see PersistenceManagerFactory#getReadOnly() + * @since 2.2 + */ + static String PROPERTY_READONLY + = "javax.jdo.option.ReadOnly"; + /** + * "javax.jdo.option.RetainValues" + * + * @see PersistenceManagerFactory#getRetainValues() + * @since 2.1 + */ + static String PROPERTY_RETAIN_VALUES + = "javax.jdo.option.RetainValues"; + /** + * "javax.jdo.option.RestoreValues" + * + * @see PersistenceManagerFactory#getRestoreValues() + * @since 2.1 + */ + static String PROPERTY_RESTORE_VALUES + = "javax.jdo.option.RestoreValues"; + /** + * "javax.jdo.option.IgnoreCache" + * + * @see PersistenceManagerFactory#getIgnoreCache() + * @since 2.1 + */ + static String PROPERTY_IGNORE_CACHE + = "javax.jdo.option.IgnoreCache"; + /** + * "javax.jdo.option.NontransactionalRead" + * + * @see PersistenceManagerFactory#getNontransactionalRead() + * @since 2.1 + */ + static String PROPERTY_NONTRANSACTIONAL_READ + = "javax.jdo.option.NontransactionalRead"; + /** + * "javax.jdo.option.NontransactionalWrite" + * + * @see PersistenceManagerFactory#getNontransactionalWrite() + * @since 2.1 + */ + static String PROPERTY_NONTRANSACTIONAL_WRITE + = "javax.jdo.option.NontransactionalWrite"; + /** + * "javax.jdo.option.Multithreaded" + * + * @see PersistenceManagerFactory#getMultithreaded() + * @since 2.1 + */ + static String PROPERTY_MULTITHREADED + = "javax.jdo.option.Multithreaded"; + /** + * "javax.jdo.option.TransactionIsolationLevel" + * + * @since 2.2 + */ + static String PROPERTY_TRANSACTION_ISOLATION_LEVEL + = "javax.jdo.option.TransactionIsolationLevel"; + /** + * "javax.jdo.option.TransactionIsolationLevel.read-uncommitted" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.2 + */ + static String PROPERTY_TRANSACTION_ISOLATION_LEVEL_READ_UNCOMMITTED + = "javax.jdo.option.TransactionIsolationLevel.read-uncommitted"; + /** + * "javax.jdo.option.TransactionIsolationLevel.read-committed" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.2 + */ + static String PROPERTY_TRANSACTION_ISOLATION_LEVEL_READ_COMMITTED + = "javax.jdo.option.TransactionIsolationLevel.read-committed"; + /** + * "javax.jdo.option.TransactionIsolationLevel.repeatable-read" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.2 + */ + static String PROPERTY_TRANSACTION_ISOLATION_LEVEL_REPEATABLE_READ + = "javax.jdo.option.TransactionIsolationLevel.repeatable-read"; + /** + * "javax.jdo.option.TransactionIsolationLevel.snapshot" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.2 + */ + static String PROPERTY_TRANSACTION_ISOLATION_LEVEL_SNAPSHOT + = "javax.jdo.option.TransactionIsolationLevel.snapshot"; + /** + * "javax.jdo.option.TransactionIsolationLevel.serializable" + * + * @see PersistenceManagerFactory#supportedOptions() + * @since 2.2 + */ + static String PROPERTY_TRANSACTION_ISOLATION_LEVEL_SERIALIZABLE + = "javax.jdo.option.TransactionIsolationLevel.serializable"; + /** + * "javax.jdo.option.DetachAllOnCommit" + * + * @see PersistenceManagerFactory#getDetachAllOnCommit() + * @since 2.1 + */ + static String PROPERTY_DETACH_ALL_ON_COMMIT + = "javax.jdo.option.DetachAllOnCommit"; + /** + * "javax.jdo.option.CopyOnAttach" + * + * @see PersistenceManagerFactory#getCopyOnAttach() + * @since 2.1 + */ + static String PROPERTY_COPY_ON_ATTACH + = "javax.jdo.option.CopyOnAttach"; + /** + * "javax.jdo.option.ConnectionDriverName" + * This property might be ignored by the JDO implementation + * because the JDBC DriverManager handles the driver name. + * @see PersistenceManagerFactory#getConnectionDriverName() + * @since 2.1 + */ + static String PROPERTY_CONNECTION_DRIVER_NAME + = "javax.jdo.option.ConnectionDriverName"; + /** + * "javax.jdo.option.ConnectionUserName" + * + * @see PersistenceManagerFactory#getConnectionUserName() + * @since 2.1 + */ + static String PROPERTY_CONNECTION_USER_NAME + = "javax.jdo.option.ConnectionUserName"; + /** + * "javax.jdo.option.Password" + * + * @since 2.1 + */ + static String PROPERTY_CONNECTION_PASSWORD + = "javax.jdo.option.ConnectionPassword"; + /** + * "javax.jdo.option.ConnectionURL" + * + * @see PersistenceManagerFactory#getConnectionURL() + * @since 2.1 + */ + static String PROPERTY_CONNECTION_URL + = "javax.jdo.option.ConnectionURL"; + /** + * "javax.jdo.option.ConnectionFactoryName" + * + * @see PersistenceManagerFactory#getConnectionFactoryName() + * @since 2.1 + */ + static String PROPERTY_CONNECTION_FACTORY_NAME + = "javax.jdo.option.ConnectionFactoryName"; + /** + * "javax.jdo.option.ConnectionFactory2Name" + * + * @see PersistenceManagerFactory#getConnectionFactory2Name() + * @since 2.1 + */ + static String PROPERTY_CONNECTION_FACTORY2_NAME + = "javax.jdo.option.ConnectionFactory2Name"; + /** + * "javax.jdo.option.Mapping" + * + * @see PersistenceManagerFactory#getMapping() + * @since 2.1 + */ + static String PROPERTY_MAPPING + = "javax.jdo.option.Mapping"; + /** + * "javax.jdo.option.PersistenceUnitName" + * + * @see PersistenceManagerFactory#getPersistenceUnitName() + * @since 2.1 + */ + static String PROPERTY_PERSISTENCE_UNIT_NAME + = "javax.jdo.option.PersistenceUnitName"; + /** + * "javax.jdo.option.Name" + * + * @see PersistenceManagerFactory#getName() + * @since 2.1 + */ + static String PROPERTY_NAME + = "javax.jdo.option.Name"; + + /** + * "javax.jdo.spi.PropertiesFileName" + * + * @since 3.2 + */ + static String PROPERTY_SPI_PROPERTIES_FILE_NAME + = "javax.jdo.spi.PropertiesFileName"; + + /** + * "javax.jdo.option.spi.ResourceName" + * @since 2.1 + */ + static String PROPERTY_SPI_RESOURCE_NAME + = "javax.jdo.option.spi.ResourceName"; + + /** + * "javax.jdo.listener.InstanceLifecycleListener" + * + * @see PersistenceManagerFactory#addInstanceLifecycleListener(javax.jdo.listener.InstanceLifecycleListener,Class[]) + * @see PersistenceManagerFactory#removeInstanceLifecycleListener(javax.jdo.listener.InstanceLifecycleListener) + */ + static String PROPERTY_INSTANCE_LIFECYCLE_LISTENER + = "javax.jdo.listener.InstanceLifecycleListener"; + + /** + * Prefix used to configure + * {@link javax.jdo.listener.InstanceLifecycleListener} instances + * externally. + * To configure an InstanceLifecycleListener via properties, + * create a property name with the prefix of + * this constant and append the fully qualified listener class name, then + * set its value to the comma- or whitespace-delimited list + * of persistence-capable classes whose instances are to be observed. + * Use no value to indicate that instances of + * all persistence-capable classes are to be observed.
    + * For example,
    + * javax.jdo.option.InstanceLifecycleListener.com.example.MyListener=com.example.Foo,com.example.Bar
    + * is equivalent to calling
    + * pmf.addInstanceLifecycleListener(new com.example.MyListener(), new Class[] {com.example.Foo.class, com.example.Bar.class});
    + * where pmf is an instance of type + * PersistenceManagerFactory. + * + * @see javax.jdo.PersistenceManagerFactory#addInstanceLifecycleListener(javax.jdo.listener.InstanceLifecycleListener,Class[]) + * @since 2.1 + */ + static String PROPERTY_PREFIX_INSTANCE_LIFECYCLE_LISTENER + = PROPERTY_INSTANCE_LIFECYCLE_LISTENER + "."; + + /** + * Mapping "javax.jdo.mapping.Catalog" + * + * @since 2.1 + */ + static String PROPERTY_MAPPING_CATALOG + = "javax.jdo.mapping.Catalog"; + /** + * Mapping "javax.jdo.mapping.Schema" + * + * @since 2.1 + */ + static String PROPERTY_MAPPING_SCHEMA + = "javax.jdo.mapping.Schema"; + + /** + * Specified value "javax.jdo.option.ServerTimeZoneID" + * + * @since 2.1 + */ + static String PROPERTY_SERVER_TIME_ZONE_ID + = "javax.jdo.option.ServerTimeZoneID"; + + /** + * Specified value "javax.jdo.option.DatastoreReadTimeoutMillis" + * + * @since 3.0 + */ + static String PROPERTY_DATASTORE_READ_TIMEOUT_MILLIS + = "javax.jdo.option.DatastoreReadTimeoutMillis"; + + /** + * Specified value "javax.jdo.option.DatastoreWriteTimeoutMillis" + * + * @since 3.0 + */ + static String PROPERTY_DATASTORE_WRITE_TIMEOUT_MILLIS + = "javax.jdo.option.DatastoreWriteTimeoutMillis"; + + /** + * Nonconfigurable property constant "VendorName" + * + * @see PersistenceManagerFactory#getProperties() + * @since 2.1 + */ + static String NONCONFIGURABLE_PROPERTY_VENDOR_NAME + = "VendorName"; + + /** + * Nonconfigurable property constant "VersionNumber" + * + * @see PersistenceManagerFactory#getProperties() + * @since 2.1 + */ + static String NONCONFIGURABLE_PROPERTY_VERSION_NUMBER + = "VersionNumber"; + + /** + * Specified value "javax.jdo.option.TransactionType" + * + * @since 2.1 + */ + static String PROPERTY_TRANSACTION_TYPE + = "javax.jdo.option.TransactionType"; + + /** + * The value for TransactionType to specify that transactions + * are managed by the Java Transactions API, as documented in + * JSR-220. + * + * @since 2.1 + */ + static String JTA + = "JTA"; + + /** + * The value for TransactionType to specify that transactions + * are managed by the javax.jdo.Transaction instance, similar + * to the usage as documented in JSR-220. + * + * @since 2.1 + */ + static String RESOURCE_LOCAL + = "RESOURCE_LOCAL"; + + /** + * The name of the resource for the DTD of the standard JDO configuration + * file. + * + * @since 2.1 + */ + static String JDOCONFIG_DTD_RESOURCE + = "javax/jdo/jdoconfig_3_0.dtd"; + + /** + * The name of the resource for the XML schema of the standard JDO + * configuration file. + * + * @since 2.1 + */ + static String JDOCONFIG_XSD_RESOURCE + = "javax/jdo/jdoconfig_3_0.xsd"; + + /** + * The name of the resource for the DTD of the standard JDO metadata file. + * + * @since 2.1 + */ + static String JDO_DTD_RESOURCE + = "javax/jdo/jdo_3_0.dtd"; + + /** + * The name of the resource for the XML schema of the standard JDO + * metadata file. + * + * @since 2.1 + */ + static String JDO_XSD_RESOURCE + = "javax/jdo/jdo_3_0.xsd"; + + /** + * The name of the resource for the DTD of the standard JDO + * object-relational mapping metadata file. + * + * @since 2.1 + */ + static String ORM_DTD_RESOURCE + = "javax/jdo/orm_3_0.dtd"; + + /** + * The name of the resource for the XML schema of the standard JDO + * object-relational mapping metadata file. + * + * @since 2.1 + */ + static String ORM_XSD_RESOURCE + = "javax/jdo/orm_3_0.xsd"; + + /** + * The name of the resource for the DTD of the standard JDO query + * metadata file. + * + * @since 2.1 + */ + static String JDOQUERY_DTD_RESOURCE + = "javax/jdo/jdoquery_3_0.dtd"; + + /** + * The name of the resource for the XML schema of the standard JDO query + * metadata file. + * + * @since 2.1 + */ + static String JDOQUERY_XSD_RESOURCE + = "javax/jdo/jdoquery_3_0.xsd"; + + /** + * The name of the anonymous PersistenceManagerFactory, which + * is the empty string. + * + * @since 2.1 + */ + static String ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME + = ""; + + /** + * Transaction isolation level representing the ability to read + * uncommitted data. + * @see PersistenceManagerFactory#getTransactionIsolationLevel() + * @see Transaction#getIsolationLevel() + * @since 2.2 + */ + public static final String TX_READ_UNCOMMITTED = "read-uncommitted"; + + /** + * Transaction isolation level representing the requirement to read + * committed data only. + * @see PersistenceManagerFactory#getTransactionIsolationLevel() + * @see Transaction#getIsolationLevel() + * @since 2.2 + */ + public static final String TX_READ_COMMITTED = "read-committed"; + + /** + * Transaction isolation level representing the requirement to read + * the same data in the same transaction. + * @see PersistenceManagerFactory#getTransactionIsolationLevel() + * @see Transaction#getIsolationLevel() + * @since 2.2 + */ + public static final String TX_REPEATABLE_READ = "repeatable-read"; + + /** + * Transaction isolation level representing the requirement to keep + * a snapshot for reading data. + * @see PersistenceManagerFactory#getTransactionIsolationLevel() + * @see Transaction#getIsolationLevel() + * @since 2.2 + */ + public static final String TX_SNAPSHOT = "snapshot"; + + /** + * Transaction isolation level representing the requirement to serialize + * transactions. + * @see PersistenceManagerFactory#getTransactionIsolationLevel() + * @see Transaction#getIsolationLevel() + * @since 2.2 + */ + public static final String TX_SERIALIZABLE = "serializable"; } diff --git a/api/src/main/java/javax/jdo/Enhancer.java b/api/src/main/java/javax/jdo/Enhancer.java index 3634e03a5..19d14ec26 100644 --- a/api/src/main/java/javax/jdo/Enhancer.java +++ b/api/src/main/java/javax/jdo/Enhancer.java @@ -16,460 +16,441 @@ */ package javax.jdo; -import static javax.jdo.Constants.ENHANCER_EXCEPTION; -import static javax.jdo.Constants.ENHANCER_NO_JDO_ENHANCER_FOUND; -import static javax.jdo.Constants.ENHANCER_USAGE_ERROR; -import static javax.jdo.Constants.PROPERTY_ENHANCER_VENDOR_NAME; -import static javax.jdo.Constants.PROPERTY_ENHANCER_VERSION_NUMBER; - import java.io.File; import java.net.MalformedURLException; import java.net.URI; import java.net.URL; import java.net.URLClassLoader; + import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.Map.Entry; import java.util.Properties; import java.util.Set; +import java.util.Map.Entry; + +import static javax.jdo.Constants.ENHANCER_EXCEPTION; +import static javax.jdo.Constants.ENHANCER_NO_JDO_ENHANCER_FOUND; +import static javax.jdo.Constants.ENHANCER_USAGE_ERROR; +import static javax.jdo.Constants.PROPERTY_ENHANCER_VENDOR_NAME; +import static javax.jdo.Constants.PROPERTY_ENHANCER_VERSION_NUMBER; + import javax.jdo.spi.I18NHelper; /** - * Main class to invoke a JDO Enhancer. The enhancer is invoked with the following command line: - * + * Main class to invoke a JDO Enhancer. + * The enhancer is invoked with the following command line: *
      * java -cp {classpath} javax.jdo.Enhancer {options} {directory, file, or resource names}
      * 
    - * - * <classpath> must contain the jdo specification jar, the implementation jar and any - * implementation dependencies, the statically-compiled classes, and the jdo metadata files loadable - * as resources. - * - *

    <options> include: - * - *

      - *
    • ? : print usage to stderr and exit - *
    • -h : print usage to stderr and exit - *
    • -help : print usage to stderr and exit - *
    • -pu <persistence-unit-name> : the name of a persistence unit - *
    • -d <target directory> : write the enhanced classes to the specified directory - *
    • -checkonly : just check the classes for enhancement status - *
    • -v : verbose output - *
    • -r : recurse through directories to find all classes and metadata files to enhance - *
    • -cp <enhancer class loader path> : if not already included in the java class loader, - * this parameter must contain the statically-compiled classes, and the jdo metadata files - * loadable as resources - *
    - * - * <directory, file, or resource names> - * - *
      - *
    • Directory names must not end in ".jdo", ".jar", or ".class" - *
    • Directories will be searched for files with suffixes ".jdo", ".jar", and ".class" - *
    • Directories will be searched recursively if the -r option is set - *
    - * + * <classpath> must contain the jdo specification jar, the implementation jar and any + * implementation dependencies, the statically-compiled classes, and the jdo + * metadata files loadable as resources. + * + * <options> include: + *
    • ? : print usage to stderr and exit + *
    • -h : print usage to stderr and exit + *
    • -help : print usage to stderr and exit + *
    • -pu <persistence-unit-name> : the name of a persistence unit + *
    • -d <target directory> : write the enhanced classes to the specified directory + *
    • -checkonly : just check the classes for enhancement status + *
    • -v : verbose output + *
    • -r : recurse through directories to find all classes and metadata files to enhance + *
    • -cp <enhancer class loader path> : if not already included in the java class loader, + * this parameter must contain the statically-compiled classes, and the jdo metadata + * files loadable as resources + *
    <directory, file, or resource names> + *
    • Directory names must not end in ".jdo", ".jar", or ".class" + *
    • Directories will be searched for files with suffixes ".jdo", ".jar", and ".class" + *
    • Directories will be searched recursively if the -r option is set + *
    + * * @since 3.0 */ public class Enhancer { - /** The Internationalization message helper. */ - private static final I18NHelper msg = I18NHelper.getInstance("javax.jdo.Bundle"); // NOI18N + /** The Internationalization message helper. */ + private final static I18NHelper msg = + I18NHelper.getInstance ("javax.jdo.Bundle"); //NOI18N - /** New Line */ - private char NL = '\n'; // NOI18N - /** Jar file suffix */ - private String JAR_FILE_SUFFIX = ".jar"; // NOI18N - /** JDO Metadata file suffix */ - private String JDO_FILE_SUFFIX = ".jdo"; // NOI18N - /** Class file suffix */ - private String CLASS_FILE_SUFFIX = ".class"; // NOI18N + /** New Line */ + private char NL = '\n'; //NOI18N + /** Jar file suffix */ + private String JAR_FILE_SUFFIX = ".jar"; //NOI18N + /** JDO Metadata file suffix */ + private String JDO_FILE_SUFFIX = ".jdo"; //NOI18N + /** Class file suffix */ + private String CLASS_FILE_SUFFIX = ".class"; //NOI18N - /** Error indicator */ - private boolean error = false; - /** If set, process parameters, print usage, and exit. */ - private boolean printAndExit = false; + /** Error indicator */ + private boolean error = false; + /** If set, process parameters, print usage, and exit. */ + private boolean printAndExit = false; - /** Persistence Units */ - private List persistenceUnitNames = new ArrayList(); - /** Target Directory Parameter */ - private String directoryName = null; - /** ClassLoader for JDOEnhancer */ - private ClassLoader loader = null; - /** Classpath (-cp) parameter */ - private String classPath = null; - /** Check Only flag */ - private boolean checkOnly = false; - /** Verbose flag */ - private boolean verbose = false; - /** Recurse flag */ - private boolean recurse = false; - /** Error messages should be empty unless there is an error */ - private StringBuilder errorBuffer = new StringBuilder(); - /** Verbose messages are always collected but only output if verbose flag is set */ - private StringBuilder verboseBuffer = new StringBuilder(); - /** File Names */ - private List fileNames = new ArrayList(); - /** Class File Names */ - private List classFileNames = new ArrayList(); - /** JDO File Names */ - private List jdoFileNames = new ArrayList(); - /** Jar File Names */ - private List jarFileNames = new ArrayList(); - /** The number of classes validated by the JDOEnhancer */ - private int numberOfValidatedClasses = 0; - /** The number of classes enhanced by the JDOEnhancer */ - private int numberOfEnhancedClasses = 0; + /** Persistence Units */ + private List persistenceUnitNames = new ArrayList(); + /** Target Directory Parameter */ + private String directoryName = null; + /** ClassLoader for JDOEnhancer */ + private ClassLoader loader = null; + /** Classpath (-cp) parameter */ + private String classPath = null; + /** Check Only flag */ + private boolean checkOnly = false; + /** Verbose flag */ + private boolean verbose = false; + /** Recurse flag */ + private boolean recurse = false; + /** Error messages should be empty unless there is an error */ + private StringBuilder errorBuffer = new StringBuilder(); + /** Verbose messages are always collected but only output if verbose flag is set */ + private StringBuilder verboseBuffer = new StringBuilder(); + /** File Names */ + private List fileNames = new ArrayList(); + /** Class File Names */ + private List classFileNames = new ArrayList(); + /** JDO File Names */ + private List jdoFileNames = new ArrayList(); + /** Jar File Names */ + private List jarFileNames = new ArrayList(); + /** The number of classes validated by the JDOEnhancer */ + private int numberOfValidatedClasses = 0; + /** The number of classes enhanced by the JDOEnhancer */ + private int numberOfEnhancedClasses = 0; - /** The properties from the JDOEnhancer */ - private Properties properties; + /** The properties from the JDOEnhancer */ + private Properties properties; - /** - * Run the enhancer from the command line. - * - * @param args command line arguments - */ - public static void main(String[] args) { - Enhancer enhancerMain = new Enhancer(); - enhancerMain.run(args); - } - - /** - * Execute the enhancer. - * - * @param args the command line arguments - */ - private void run(String[] args) { - // processArgs will exit if errors or help - processArgs(args); - JDOEnhancer enhancer = null; - try { - enhancer = JDOHelper.getEnhancer(); - } catch (JDOException jdoex) { - jdoex.printStackTrace(); // outputs to stderr - exit(ENHANCER_NO_JDO_ENHANCER_FOUND); + /** Run the enhancer from the command line. + * + * @param args command line arguments + */ + public static void main (String[] args) { + Enhancer enhancerMain = new Enhancer(); + enhancerMain.run(args); } - try { - // provide verbose property settings of the JDOEnhancer we just loaded - properties = enhancer.getProperties(); - addVerboseMessage("MSG_EnhancerClass", enhancer.getClass().getName()); // NOI18N - addVerboseMessage( - "MSG_EnhancerProperty", - PROPERTY_ENHANCER_VENDOR_NAME, // NOI18N - properties.getProperty(PROPERTY_ENHANCER_VENDOR_NAME)); - addVerboseMessage( - "MSG_EnhancerProperty", - PROPERTY_ENHANCER_VERSION_NUMBER, // NOI18N - properties.getProperty(PROPERTY_ENHANCER_VERSION_NUMBER)); - Set> props = properties.entrySet(); - Iterator> entries = props.iterator(); - while (entries.hasNext()) { - Entry entry = entries.next(); - if (!(PROPERTY_ENHANCER_VENDOR_NAME.equals(entry.getKey()) - || PROPERTY_ENHANCER_VERSION_NUMBER.equals(entry.getKey()))) { - addVerboseMessage( - "MSG_EnhancerProperty", - (String) entry.getKey(), // NOI18N - (String) entry.getValue()); + /** Execute the enhancer. + * + * @param args the command line arguments + */ + private void run(String[] args) { + // processArgs will exit if errors or help + processArgs(args); + JDOEnhancer enhancer = null; + try { + enhancer = JDOHelper.getEnhancer(); + } catch (JDOException jdoex) { + jdoex.printStackTrace(); // outputs to stderr + exit(ENHANCER_NO_JDO_ENHANCER_FOUND); } - } - enhancer.setVerbose(verbose); - if (loader != null) { - enhancer.setClassLoader(loader); - } - int numberOfClasses = classFileNames.size(); - if (numberOfClasses != 0) { - enhancer.addClasses(classFileNames.toArray(new String[numberOfClasses])); - } - int numberOfFiles = jdoFileNames.size(); - if (numberOfFiles != 0) { - enhancer.addFiles(jdoFileNames.toArray(new String[numberOfFiles])); - } - if (0 < jarFileNames.size()) { - for (String jarFileName : jarFileNames) { - enhancer.addJar(jarFileName); - } - } - if (persistenceUnitNames != null) { - for (String persistenceUnitName : persistenceUnitNames) { - enhancer.addPersistenceUnit(persistenceUnitName); + try { + // provide verbose property settings of the JDOEnhancer we just loaded + properties = enhancer.getProperties(); + addVerboseMessage("MSG_EnhancerClass", enhancer.getClass().getName()); //NOI18N + addVerboseMessage("MSG_EnhancerProperty", PROPERTY_ENHANCER_VENDOR_NAME, //NOI18N + properties.getProperty(PROPERTY_ENHANCER_VENDOR_NAME)); + addVerboseMessage("MSG_EnhancerProperty", PROPERTY_ENHANCER_VERSION_NUMBER, //NOI18N + properties.getProperty(PROPERTY_ENHANCER_VERSION_NUMBER)); + Set> props = properties.entrySet(); + Iterator> entries = props.iterator(); + while (entries.hasNext()) { + Entry entry = entries.next(); + if (!(PROPERTY_ENHANCER_VENDOR_NAME.equals(entry.getKey()) || + PROPERTY_ENHANCER_VERSION_NUMBER.equals(entry.getKey()))) { + addVerboseMessage("MSG_EnhancerProperty", (String)entry.getKey(), //NOI18N + (String)entry.getValue()); + } + } + enhancer.setVerbose(verbose); + if (loader != null) { + enhancer.setClassLoader(loader); + } + + int numberOfClasses = classFileNames.size(); + if (numberOfClasses != 0) { + enhancer.addClasses(classFileNames.toArray(new String[numberOfClasses])); + } + int numberOfFiles = jdoFileNames.size(); + if (numberOfFiles != 0) { + enhancer.addFiles(jdoFileNames.toArray(new String[numberOfFiles])); + } + if (0 < jarFileNames.size()) { + for (String jarFileName : jarFileNames) { + enhancer.addJar(jarFileName); + } + } + if (persistenceUnitNames != null) { + for (String persistenceUnitName: persistenceUnitNames) { + enhancer.addPersistenceUnit(persistenceUnitName); + } + } + if (directoryName != null) { + enhancer.setOutputDirectory(directoryName); + } + if (checkOnly) { + numberOfValidatedClasses = enhancer.validate(); + addVerboseMessage("MSG_EnhancerValidatedClasses", numberOfValidatedClasses); //NOI18N + } else { + numberOfEnhancedClasses = enhancer.enhance(); + addVerboseMessage("MSG_EnhancerEnhancedClasses", numberOfEnhancedClasses); //NOI18N + } + exit(0); // good exit + } catch (Exception ex) { + ex.printStackTrace(); // outputs to stderr + exit(ENHANCER_EXCEPTION); // error exit } - } - if (directoryName != null) { - enhancer.setOutputDirectory(directoryName); - } - if (checkOnly) { - numberOfValidatedClasses = enhancer.validate(); - addVerboseMessage("MSG_EnhancerValidatedClasses", numberOfValidatedClasses); // NOI18N - } else { - numberOfEnhancedClasses = enhancer.enhance(); - addVerboseMessage("MSG_EnhancerEnhancedClasses", numberOfEnhancedClasses); // NOI18N - } - exit(0); // good exit - } catch (Exception ex) { - ex.printStackTrace(); // outputs to stderr - exit(ENHANCER_EXCEPTION); // error exit } - } - /** - * Process the command line arguments and exit if there is a usage request or an error. - * - * @param args the command line arguments - */ - private void processArgs(String[] args) { - parseArgs(args); - parseFiles(fileNames.toArray(new String[fileNames.size()]), true, recurse); - loader = prepareClassLoader(classPath); - if (error) { - addErrorMessage(msg.msg("MSG_EnhancerUsage")); // NOI18N - exit(ENHANCER_USAGE_ERROR); // error exit - } - if (printAndExit) { - addVerboseMessage("MSG_EnhancerUsage"); // NOI18N - exit(0); // good exit + /** Process the command line arguments and exit if there is a usage request or an error. + * + * @param args the command line arguments + */ + private void processArgs(String[] args) { + parseArgs(args); + parseFiles(fileNames.toArray(new String[fileNames.size()]), true, recurse); + loader = prepareClassLoader(classPath); + if (error) { + addErrorMessage(msg.msg("MSG_EnhancerUsage")); //NOI18N + exit(ENHANCER_USAGE_ERROR); // error exit + } + if (printAndExit) { + addVerboseMessage("MSG_EnhancerUsage"); //NOI18N + exit(0); // good exit + } } - } - /** - * Parse the command line arguments. Put the results into fields. - * - * @param args the command line arguments - */ - private void parseArgs(String[] args) { - boolean doneWithOptions = false; - fileNames = new ArrayList(); - for (int i = 0; i < args.length; ++i) { - String arg = args[i]; - // if first argument is ? then simply print usage and return. - if ("?".equals(arg)) { - printAndExit = true; - return; - } - if (!doneWithOptions) { - if (arg.startsWith("-")) { // NOI18N - String option = arg.substring(1); - if ("help".equals(option)) { // NOI18N - addVerboseMessage("MSG_EnhancerProcessing", "-help"); // NOI18N - setPrintAndExit(); - } else if ("h".equals(option)) { // NOI18N - addVerboseMessage("MSG_EnhancerProcessing", "-h"); // NOI18N - setPrintAndExit(); - } else if ("v".equals(option)) { // NOI18N - addVerboseMessage("MSG_EnhancerProcessing", "-v"); // NOI18N - verbose = true; - } else if ("verbose".equals(option)) { // NOI18N - addVerboseMessage("MSG_EnhancerProcessing", "-verbose"); // NOI18N - verbose = true; - } else if ("pu".equals(option)) { // NOI18N - if (hasNextArgument("MSG_EnhancerProcessing", "-pu", i, args.length)) { // NOI18N - String puName = args[++i]; - addVerboseMessage("MSG_EnhancerPersistenceUnitName", puName); // NOI18N - persistenceUnitNames.add(puName); - } else { - setError(); - } - } else if ("cp".equals(option)) { // NOI18N - if (hasNextArgument("MSG_EnhancerProcessing", "-cp", i, args.length)) { // NOI18N - classPath = args[++i]; - addVerboseMessage("MSG_EnhancerClassPath", classPath); // NOI18N - } else { - setError(); + /** Parse the command line arguments. Put the results into fields. + * + * @param args the command line arguments + */ + private void parseArgs(String[] args) { + boolean doneWithOptions = false; + fileNames = new ArrayList(); + for (int i = 0; i < args.length; ++i) { + String arg = args[i]; + // if first argument is ? then simply print usage and return. + if ("?".equals(arg)) { + printAndExit = true; + return; } - } else if ("d".equals(option)) { // NOI18N - if (hasNextArgument("MSG_EnhancerProcessing", "-d", i, args.length)) { // NOI18N - directoryName = args[++i]; - addVerboseMessage("MSG_EnhancerOutputDirectory", directoryName); // NOI18N + if (!doneWithOptions) { + if (arg.startsWith("-")) { //NOI18N + String option = arg.substring(1); + if ("help".equals(option)) { //NOI18N + addVerboseMessage("MSG_EnhancerProcessing", "-help"); //NOI18N + setPrintAndExit(); + } else if ("h".equals(option)) { //NOI18N + addVerboseMessage("MSG_EnhancerProcessing", "-h"); //NOI18N + setPrintAndExit(); + } else if ("v".equals(option)) { //NOI18N + addVerboseMessage("MSG_EnhancerProcessing", "-v"); //NOI18N + verbose = true; + } else if ("verbose".equals(option)) { //NOI18N + addVerboseMessage("MSG_EnhancerProcessing", "-verbose"); //NOI18N + verbose = true; + } else if ("pu".equals(option)) { //NOI18N + if (hasNextArgument("MSG_EnhancerProcessing", "-pu", i, args.length)) { //NOI18N + String puName = args[++i]; + addVerboseMessage("MSG_EnhancerPersistenceUnitName", puName); //NOI18N + persistenceUnitNames.add(puName); + } else { + setError(); + } + } else if ("cp".equals(option)) { //NOI18N + if (hasNextArgument("MSG_EnhancerProcessing", "-cp", i, args.length)) { //NOI18N + classPath = args[++i]; + addVerboseMessage("MSG_EnhancerClassPath", classPath); //NOI18N + } else { + setError(); + } + } else if ("d".equals(option)) { //NOI18N + if (hasNextArgument("MSG_EnhancerProcessing", "-d", i, args.length)) { //NOI18N + directoryName = args[++i]; + addVerboseMessage("MSG_EnhancerOutputDirectory", directoryName); //NOI18N + } else { + setError(); + } + } else if ("checkonly".equals(option)) { //NOI18N + addVerboseMessage("MSG_EnhancerProcessing", "-checkonly"); //NOI18N + checkOnly = true; + } else if ("r".equals(option)) { //NOI18N + addVerboseMessage("MSG_EnhancerProcessing", "-r"); //NOI18N + recurse = true; + } else { + setError(); + addErrorMessage(msg.msg("ERR_EnhancerUnrecognizedOption", option)); //NOI18N + } + } else { + doneWithOptions = true; + fileNames.add(arg); + } } else { - setError(); + fileNames.add(arg); } - } else if ("checkonly".equals(option)) { // NOI18N - addVerboseMessage("MSG_EnhancerProcessing", "-checkonly"); // NOI18N - checkOnly = true; - } else if ("r".equals(option)) { // NOI18N - addVerboseMessage("MSG_EnhancerProcessing", "-r"); // NOI18N - recurse = true; - } else { + } + } + + /** Check whether there is another parameter (the argument for an option + * that requires an argument). + * @param msgId the message id for an error message + * @param where the parameter for the message + * @param i the index into the parameter array + * @param length the length of the parameter array + * @return + */ + private boolean hasNextArgument(String msgId, String where, int i, int length) { + if (i + 1 >= length) { setError(); - addErrorMessage(msg.msg("ERR_EnhancerUnrecognizedOption", option)); // NOI18N - } - } else { - doneWithOptions = true; - fileNames.add(arg); + addErrorMessage(msg.msg(msgId, where)); + addErrorMessage(msg.msg("ERR_EnhancerRequiredArgumentMissing")); //NOI18N + return false; } - } else { - fileNames.add(arg); - } + return true; } - } - /** - * Check whether there is another parameter (the argument for an option that requires an - * argument). - * - * @param msgId the message id for an error message - * @param where the parameter for the message - * @param i the index into the parameter array - * @param length the length of the parameter array - * @return - */ - private boolean hasNextArgument(String msgId, String where, int i, int length) { - if (i + 1 >= length) { - setError(); - addErrorMessage(msg.msg(msgId, where)); - addErrorMessage(msg.msg("ERR_EnhancerRequiredArgumentMissing")); // NOI18N - return false; + /** + * Files can be one of four types: + *
    1. directory: the directory is examined for files of the following types + *
    2. .class: this is a java class file + *
    3. .jdo: this is a jdo metadata file + *
    4. .jar: this is a jar file + *
    + * If the recursion flag is set, directories contained in directories are examined, + * recursively. + */ + private void parseFiles(String[] fileNames, boolean search, boolean recurse) { + for (String fileName: fileNames) { + if (fileName.endsWith(JAR_FILE_SUFFIX)) { + // add to jar file names + jarFileNames.add(fileName); + addVerboseMessage("MSG_EnhancerJarFileName", fileName); //NOI18N + } else if (fileName.endsWith(JDO_FILE_SUFFIX)) { + // add to jdo file names + jdoFileNames.add(fileName); + addVerboseMessage("MSG_EnhancerJDOFileName", fileName); //NOI18N + } else if (fileName.endsWith(CLASS_FILE_SUFFIX)) { + // add to class file names + classFileNames.add(fileName); + addVerboseMessage("MSG_EnhancerClassFileName", fileName); //NOI18N + } else { + // assume a directory if no recognized suffix + File directoryFile = new File(fileName); + if (directoryFile.isDirectory() && search) { + String directoryPath = directoryFile.getAbsolutePath(); + String[] files = directoryFile.list(); + String[] pathName = new String[1]; + if (files != null) { + for (String file: files) { + pathName[0] = directoryPath + '/' + file; + parseFiles(pathName, recurse, recurse); + } + } + } + } + } } - return true; - } - /** - * Files can be one of four types: - * - *
      - *
    1. directory: the directory is examined for files of the following types - *
    2. .class: this is a java class file - *
    3. .jdo: this is a jdo metadata file - *
    4. .jar: this is a jar file - *
    - * - * If the recursion flag is set, directories contained in directories are examined, recursively. - */ - private void parseFiles(String[] fileNames, boolean search, boolean recurse) { - for (String fileName : fileNames) { - if (fileName.endsWith(JAR_FILE_SUFFIX)) { - // add to jar file names - jarFileNames.add(fileName); - addVerboseMessage("MSG_EnhancerJarFileName", fileName); // NOI18N - } else if (fileName.endsWith(JDO_FILE_SUFFIX)) { - // add to jdo file names - jdoFileNames.add(fileName); - addVerboseMessage("MSG_EnhancerJDOFileName", fileName); // NOI18N - } else if (fileName.endsWith(CLASS_FILE_SUFFIX)) { - // add to class file names - classFileNames.add(fileName); - addVerboseMessage("MSG_EnhancerClassFileName", fileName); // NOI18N - } else { - // assume a directory if no recognized suffix - File directoryFile = new File(fileName); - if (directoryFile.isDirectory() && search) { - String directoryPath = directoryFile.getAbsolutePath(); - String[] files = directoryFile.list(); - String[] pathName = new String[1]; - if (files != null) { - for (String file : files) { - pathName[0] = directoryPath + '/' + file; - parseFiles(pathName, recurse, recurse); + /** Prepare the class loader from the classPath specified + * + * @param classPath the classPath string from the "-cp classPath" option + * @return the class loader + */ + private ClassLoader prepareClassLoader(String classPath) { + if (classPath == null) + return null; + ClassLoader result = null; + // separate classPath using system class path separator + String separator = System.getProperty("path.separator"); + String[] paths = classPath.split(separator); + List urls = new ArrayList(); + for (String path: paths) { + // for each path construct a URL from the File + File file = new File(path); + URI uri = file.toURI(); + try { + URL url = uri.toURL(); + addVerboseMessage("MSG_EnhancerClassPath", url.toString()); + urls.add(url); + } catch (MalformedURLException e) { + setError(); + addErrorMessage(msg.msg("ERR_EnhancerBadClassPath", file)); } - } } - } + result = new URLClassLoader(urls.toArray(new URL[urls.size()]), null); + return result; } - } - /** - * Prepare the class loader from the classPath specified - * - * @param classPath the classPath string from the "-cp classPath" option - * @return the class loader - */ - private ClassLoader prepareClassLoader(String classPath) { - if (classPath == null) return null; - ClassLoader result = null; - // separate classPath using system class path separator - String separator = System.getProperty("path.separator"); - String[] paths = classPath.split(separator); - List urls = new ArrayList(); - for (String path : paths) { - // for each path construct a URL from the File - File file = new File(path); - URI uri = file.toURI(); - try { - URL url = uri.toURL(); - addVerboseMessage("MSG_EnhancerClassPath", url.toString()); - urls.add(url); - } catch (MalformedURLException e) { - setError(); - addErrorMessage(msg.msg("ERR_EnhancerBadClassPath", file)); - } + /** Add a message to stderr. + * + * @param message the internationalized message to add + */ + private void addErrorMessage(String message) { + errorBuffer.append(message); + errorBuffer.append(NL); } - result = new URLClassLoader(urls.toArray(new URL[urls.size()]), null); - return result; - } - /** - * Add a message to stderr. - * - * @param message the internationalized message to add - */ - private void addErrorMessage(String message) { - errorBuffer.append(message); - errorBuffer.append(NL); - } + /** Set the error flag. + * + */ + private void setError() { + error = true; + } - /** Set the error flag. */ - private void setError() { - error = true; - } + /** Set the print-and-exit flag. + * + */ + private void setPrintAndExit() { + printAndExit = true; + } - /** Set the print-and-exit flag. */ - private void setPrintAndExit() { - printAndExit = true; - } + /** Exit this process. + * + * @param exitValue the process exit value + */ + private void exit(int exitValue) { + System.out.print(verboseBuffer.toString()); + System.err.print(errorBuffer.toString()); + System.exit(exitValue); + } - /** - * Exit this process. - * - * @param exitValue the process exit value - */ - private void exit(int exitValue) { - System.out.print(verboseBuffer.toString()); - System.err.print(errorBuffer.toString()); - System.exit(exitValue); - } + /** Add a message to the verbose message buffer. + * + * @param msgId the message id + * @param where the parameter + */ + private void addVerboseMessage(String msgId, String... where) { + verboseBuffer.append(msg.msg(msgId, where)); + verboseBuffer.append(NL); + } - /** - * Add a message to the verbose message buffer. - * - * @param msgId the message id - * @param where the parameter - */ - private void addVerboseMessage(String msgId, String... where) { - verboseBuffer.append(msg.msg(msgId, where)); - verboseBuffer.append(NL); - } + /** Add a message to the verbose message buffer. + * + * @param msgId the message id + * @param where the parameter + */ + private void addVerboseMessage(String msgId, String where) { + verboseBuffer.append(msg.msg(msgId, where)); + verboseBuffer.append(NL); + } - /** - * Add a message to the verbose message buffer. - * - * @param msgId the message id - * @param where the parameter - */ - private void addVerboseMessage(String msgId, String where) { - verboseBuffer.append(msg.msg(msgId, where)); - verboseBuffer.append(NL); - } + /** Add a message to the verbose message buffer. + * + * @param msgId the message id + */ + private void addVerboseMessage(String msgId) { + verboseBuffer.append(msg.msg(msgId)); + verboseBuffer.append(NL); + } - /** - * Add a message to the verbose message buffer. - * - * @param msgId the message id - */ - private void addVerboseMessage(String msgId) { - verboseBuffer.append(msg.msg(msgId)); - verboseBuffer.append(NL); - } + /** Add a message to the verbose message buffer. + * + * @param msgId the message id + * @param where the parameter + */ + private void addVerboseMessage(String msgId, int where) { + addVerboseMessage(msgId, String.valueOf(where)); + } - /** - * Add a message to the verbose message buffer. - * - * @param msgId the message id - * @param where the parameter - */ - private void addVerboseMessage(String msgId, int where) { - addVerboseMessage(msgId, String.valueOf(where)); - } } diff --git a/api/src/main/java/javax/jdo/Extent.java b/api/src/main/java/javax/jdo/Extent.java index 264e07ab8..120200f30 100644 --- a/api/src/main/java/javax/jdo/Extent.java +++ b/api/src/main/java/javax/jdo/Extent.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -22,92 +22,78 @@ package javax.jdo; +import java.lang.Iterable; import java.util.Iterator; -/** - * Instances of the Extent class represent the entire collection of instances in the - * data store of the candidate class or interface possibly including its subclasses or - * subinterfaces. - * - *

    The Extent instance has two possible uses: - * +/** Instances of the Extent class represent the entire collection + * of instances in the data store of the candidate class or interface + * possibly including its subclasses or subinterfaces. + *

    The Extent instance has two possible uses: *

      - *
    1. to iterate all instances of a particular class or interface - *
    2. to execute a Query in the data store over all instances of a particular class - * or interface + *
    3. to iterate all instances of a particular class or interface + *
    4. to execute a Query in the data store over all instances + * of a particular class or interface *
    - * * @version 2.1 */ public interface Extent extends Iterable, AutoCloseable { + + /** Returns an iterator over all the instances in the Extent. + * The behavior of the returned iterator might depend on the setting of the + * ignoreCache flag in the owning PersistenceManager. + * @return an iterator over all instances in the Extent + */ + Iterator iterator(); - /** - * Returns an iterator over all the instances in the Extent. The behavior of the - * returned iterator might depend on the setting of the ignoreCache flag in the - * owning PersistenceManager. - * - * @return an iterator over all instances in the Extent - */ - Iterator iterator(); + /** Returns whether this Extent was defined to contain subclasses. + * @return true if this Extent was defined to contain instances + * that are of a subclass type. + */ + boolean hasSubclasses(); - /** - * Returns whether this Extent was defined to contain subclasses. - * - * @return true if this Extent was defined to contain instances that are of a - * subclass type. - */ - boolean hasSubclasses(); + /** An Extent contains all instances of a particular class + * or interface in the data + * store; this method returns the Class of the instances + * represented by this Extent. + * @return the Class of instances of this Extent. + */ + Class getCandidateClass(); - /** - * An Extent contains all instances of a particular class or interface in the data - * store; this method returns the Class of the instances represented by this Extent. - * - * @return the Class of instances of this Extent. - */ - Class getCandidateClass(); + /** An Extent is managed by a PersistenceManager; + * this method gives access to the owning PersistenceManager. + * @return the owning PersistenceManager + */ + PersistenceManager getPersistenceManager(); + + /** Close all Iterators associated with this Extent instance. + * Iterators closed by this method will return false + * to hasNext() and will throw + * NoSuchElementException on next(). + * The Extent instance can still be used + * as a parameter of Query.setExtent, and to get an Iterator. + */ + void closeAll (); + + /** Close an Iterator associated with this Extent instance. + * Iterators closed by this method will return false + * to hasNext() and will throw NoSuchElementException + * on next(). The Extent instance can still be used + * as a parameter of Query.setExtent, and to get an Iterator. + * @param it an Iterator obtained by the method + * iterator() on this Extent instance. + */ + void close (Iterator it); - /** - * An Extent is managed by a PersistenceManager; this method gives - * access to the owning PersistenceManager. - * - * @return the owning PersistenceManager - */ - PersistenceManager getPersistenceManager(); + /** + * Don't use this method directly; use closeAll() instead. It is intended for use with try-with-resources. + * @throws Exception if this resource cannot be closed + */ + void close() throws Exception; - /** - * Close all Iterators associated with this Extent instance. - * Iterators closed by this method will return false to hasNext() - * and will throw NoSuchElementException on next(). The Extent - * instance can still be used as a parameter of Query.setExtent, and to get - * an Iterator. - */ - void closeAll(); - - /** - * Close an Iterator associated with this Extent instance. - * Iterators closed by this method will return false to hasNext() - * and will throw NoSuchElementException on next(). The Extent - * instance can still be used as a parameter of Query.setExtent, and to get - * an Iterator. - * - * @param it an Iterator obtained by the method iterator() on this - * Extent instance. - */ - void close(Iterator it); - - /** - * Don't use this method directly; use closeAll() instead. It is intended for use - * with try-with-resources. - * - * @throws Exception if this resource cannot be closed - */ - void close() throws Exception; - - /** - * Get the fetch plan associated with this Extent. - * - * @return the fetch plan - * @since 2.0 - */ - FetchPlan getFetchPlan(); + /** Get the fetch plan associated with this Extent. + * @return the fetch plan + * @since 2.0 + */ + FetchPlan getFetchPlan(); } + diff --git a/api/src/main/java/javax/jdo/FetchGroup.java b/api/src/main/java/javax/jdo/FetchGroup.java index 2e7827bce..ca4d2acec 100644 --- a/api/src/main/java/javax/jdo/FetchGroup.java +++ b/api/src/main/java/javax/jdo/FetchGroup.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,269 +19,265 @@ * FetchGroup.java * */ - + package javax.jdo; import java.util.Set; /** - * FetchGroup represents a named fetch group for a specific class or interface. A fetch group - * instance identifies the name of the class or interface, the list of members (fields or - * properties) to be fetched when the fetch group is active, and the recursion depth for each - * member. - * - *

    Fetch groups are updated using methods on this interface. An instance of a class implementing - * this interface can be obtained from {@link PersistenceManager#getFetchGroup} or {@link - * PersistenceManagerFactory#getFetchGroup}. - * - *

    A FetchGroup can be unscoped or can be in one of two scopes (the {@link PersistenceManager} or - * the {@link PersistenceManagerFactory} scope). Unscoped FetchGroups do not affect any behavior. A - * FetchGroup in PersistenceManager scope hides the corresponding FetchGroup in the - * PersistenceManagerFactory scope. - * - *

      - *
    • When a FetchGroup is obtained via {@link PersistenceManager#getFetchGroup}, it is - * immediately in scope of its PersistenceManager. Subsequent modifications of - * the FetchGroup immediately affect FetchPlans that contain the FetchGroup - * . - *
    • When a FetchGroup is obtained via {@link PersistenceManagerFactory#getFetchGroup}, it is - * unscoped. - *
    • When a FetchGroup is added to the set of active FetchGroups via {@link - * PersistenceManagerFactory#addFetchGroups}, it is put in scope of the - * PersistenceManagerFactory. - *
    • When a FetchGroup is removed from the set of active FetchGroups via {@link - * PersistenceManagerFactory#removeFetchGroups}, {@link - * PersistenceManagerFactory#removeAllFetchGroups}, or replaced via {@link - * PersistenceManagerFactory#addFetchGroups}, it is unscoped. - *
    - * + * FetchGroup represents a named fetch group for a specific class or + * interface. A fetch group instance identifies the name of the class or + * interface, the list of members (fields or properties) to be fetched when + * the fetch group is active, and the recursion depth for each member. + *

    + * Fetch groups are updated using methods on this interface. An instance of + * a class implementing this interface can be obtained from + * {@link PersistenceManager#getFetchGroup} or + * {@link PersistenceManagerFactory#getFetchGroup}. + *

    + * A FetchGroup can be unscoped or can be in one of two scopes (the + * {@link PersistenceManager} or the {@link PersistenceManagerFactory} scope). + * Unscoped FetchGroups do not affect any behavior. + * A FetchGroup in PersistenceManager scope hides the corresponding + * FetchGroup in the PersistenceManagerFactory scope. + *

    • When a FetchGroup is obtained via + * {@link PersistenceManager#getFetchGroup}, + * it is immediately in scope of its PersistenceManager. + * Subsequent modifications of the FetchGroup + * immediately affect FetchPlans that contain the + * FetchGroup. + *
    • When a FetchGroup is obtained via + * {@link PersistenceManagerFactory#getFetchGroup}, it is unscoped. + *
    • When a FetchGroup is added to the set of active FetchGroups via + * {@link PersistenceManagerFactory#addFetchGroups}, it is put in scope of the + * PersistenceManagerFactory. + *
    • When a FetchGroup is removed from the set of active FetchGroups via + * {@link PersistenceManagerFactory#removeFetchGroups}, + * {@link PersistenceManagerFactory#removeAllFetchGroups}, or replaced via + * {@link PersistenceManagerFactory#addFetchGroups}, it is unscoped. + *
    * @version 2.2 * @since 2.2 */ public interface FetchGroup { - /** - * For use with {@link #addCategory} and {@link #removeCategory} calls. This category includes - * members defined in the default fetch group in xml or annotations. Redefining the default fetch - * group via the API does not affect the members defined by this category. - * - *

    Using this category also sets the fetch-depth for the members in the default fetch group. - * - * @since 2.2 - */ - public static final String DEFAULT = "default"; + /** + * For use with {@link #addCategory} and {@link #removeCategory} calls. + * This category includes members defined in the default fetch group + * in xml or annotations. Redefining the default fetch group via the API + * does not affect the members defined by this category. + *

    + * Using this category also sets the fetch-depth for the members in the + * default fetch group.

    + * @since 2.2 + */ + public static final String DEFAULT = "default"; - /** - * For use with {@link #addCategory} and {@link #removeCategory} calls. This category includes - * members of all relationship types. - * - * @since 2.2 - */ - public static final String RELATIONSHIP = "relationship"; + /** + * For use with {@link #addCategory} and {@link #removeCategory} calls. + * This category includes members of all relationship types. + * @since 2.2 + */ + public static final String RELATIONSHIP = "relationship"; - /** - * For use with {@link #addCategory} and {@link #removeCategory} calls. This category includes - * members of all multi-valued types, including Collection, array, and Map types of basic and - * relationship types. - * - * @since 2.2 - */ - public static final String MULTIVALUED = "multivalued"; + /** + * For use with {@link #addCategory} and {@link #removeCategory} calls. + * This category includes members of all multi-valued types, including + * Collection, array, and Map types of basic and relationship types. + * @since 2.2 + */ + public static final String MULTIVALUED = "multivalued"; - /** - * For use with {@link #addCategory} and {@link #removeCategory} calls. This category includes - * members of all primitive and immutable object class types as defined in section 6.4 of the - * specification, including String, Locale, Currency, BigDecimal, and BigInteger; as well as Date - * and its jdbc subtypes and Enum types. - * - * @since 2.2 - */ - public static final String BASIC = "basic"; + /** + * For use with {@link #addCategory} and {@link #removeCategory} calls. + * This category includes members of all primitive and immutable + * object class types as defined in section 6.4 of the specification, + * including String, Locale, Currency, BigDecimal, and BigInteger; + * as well as Date and its jdbc subtypes and Enum types. + * @since 2.2 + */ + public static final String BASIC = "basic"; - /** - * For use with {@link #addCategory} and {@link #removeCategory} calls. This category includes all - * members in the persistent type. - * - *

    Using this category also sets the fetch-depth for the members in the default fetch group. - * - * @since 2.2 - */ - public static final String ALL = "all"; + /** + * For use with {@link #addCategory} and {@link #removeCategory} calls. + * This category includes all members in the persistent type. + *

    + * Using this category also sets the fetch-depth for the members in the + * default fetch group.

    + * @since 2.2 + */ + public static final String ALL = "all"; - /** - * Return the hashCode for this instance. The hash code should combine both the class and fetch - * group name. The hash codes for two equal instances must be identical. - * - * @return the hash code - * @since 2.2 - */ - int hashCode(); + /** + * Return the hashCode for this instance. The hash code should combine both + * the class and fetch group name. The hash codes for two equal instances + * must be identical. + * @return the hash code + * @since 2.2 + */ + int hashCode(); - /** - * Return whether this instance is equal to the other. The equals method must compare the class - * for identity and the fetch group name for equality. - * - * @return whether this instance is equal to the other - * @since 2.2 - */ - boolean equals(Object other); + /** + * Return whether this instance is equal to the other. The equals method + * must compare the class for identity and the fetch group name for + * equality. + * @return whether this instance is equal to the other + * @since 2.2 + */ + boolean equals(Object other); - /** - * Get the name of this FetchGroup. The name is set only in the factory method. - * - * @return the name - * @since 2.2 - */ - String getName(); + /** + * Get the name of this FetchGroup. The name is set only in the + * factory method. + * @return the name + * @since 2.2 + */ + String getName(); - /** - * Get the persistent type (class or interface) of this FetchGroup. The persistent type is set - * only in the factory method(s). - * - * @return the persistent type - * @since 2.2 - */ - Class getType(); + /** + * Get the persistent type (class or interface) of this FetchGroup. + * The persistent type is set only in the factory method(s). + * @return the persistent type + * @since 2.2 + */ + Class getType(); - /** - * Get the post-load property of this FetchGroup. - * - * @return the post-load property - * @since 2.2 - */ - boolean getPostLoad(); + /** + * Get the post-load property of this FetchGroup. + * @return the post-load property + * @since 2.2 + */ + boolean getPostLoad(); - /** - * Set the post-load property of this FetchGroup. - * - * @param postLoad Whether to post load this fetch group - * @return the FetchGroup - * @throws JDOUserException if the FetchGroup is unmodifiable - * @since 2.2 - */ - FetchGroup setPostLoad(boolean postLoad); + /** + * Set the post-load property of this FetchGroup. + * @param postLoad Whether to post load this fetch group + * @return the FetchGroup + * @throws JDOUserException if the FetchGroup is unmodifiable + * @since 2.2 + */ + FetchGroup setPostLoad(boolean postLoad); - /** - * Add the member (field or property) to the set of members in this FetchGroup. - * - * @param memberName the name of a member to add to the FetchGroup - * @return the FetchGroup - * @throws JDOUserException if the parameter is not a member of the persistent type - * @throws JDOUserException if the FetchGroup is unmodifiable - * @since 2.2 - */ - FetchGroup addMember(String memberName); + /** + * Add the member (field or property) to the set of members in this + * FetchGroup. + * @param memberName the name of a member to add to the FetchGroup + * @return the FetchGroup + * @throws JDOUserException if the parameter is not a member of the + * persistent type + * @throws JDOUserException if the FetchGroup is unmodifiable + * @since 2.2 + */ + FetchGroup addMember(String memberName); - /** - * Add the member (field or property) to the set of members in this FetchGroup. Duplicates are - * ignored. - * - * @param memberNames the names of members to add to the FetchGroup - * @return the FetchGroup - * @throws JDOUserException if any parameter is not a member of the persistent type - * @throws JDOUserException if the FetchGroup is unmodifiable - * @since 2.2 - */ - FetchGroup addMembers(String... memberNames); + /** + * Add the member (field or property) to the set of members in this + * FetchGroup. Duplicates are ignored. + * @param memberNames the names of members to add to the FetchGroup + * @return the FetchGroup + * @throws JDOUserException if any parameter is not a member of the + * persistent type + * @throws JDOUserException if the FetchGroup is unmodifiable + * @since 2.2 + */ + FetchGroup addMembers(String... memberNames); - /** - * Remove the member (field or property) from the set of members in this FetchGroup. - * - * @param memberName Name of the member of the class to remove from the FetchGroup. - * @return the FetchGroup - * @throws JDOUserException if the parameter is not a member of the persistent type - * @throws JDOUserException if the FetchGroup is unmodifiable - * @since 2.2 - */ - FetchGroup removeMember(String memberName); + /** + * Remove the member (field or property) from the set of members in this FetchGroup. + * @param memberName Name of the member of the class to remove from the FetchGroup. + * @return the FetchGroup + * @throws JDOUserException if the parameter is not a member of the persistent type + * @throws JDOUserException if the FetchGroup is unmodifiable + * @since 2.2 + */ + FetchGroup removeMember(String memberName); - /** - * Remove the member (field or property) from the set of members in this FetchGroup. Duplicates in - * the parameter list are eliminated before removing them from the membership. - * - * @param memberNames Member names of the class to remove from this FetchGroup. - * @return the FetchGroup - * @throws JDOUserException if any parameter is not a member of the persistent type - * @throws JDOUserException if the FetchGroup is unmodifiable - * @since 2.2 - */ - FetchGroup removeMembers(String... memberNames); + /** + * Remove the member (field or property) from the set of members in this + * FetchGroup. Duplicates in the parameter list are eliminated before + * removing them from the membership. + * @param memberNames Member names of the class to remove from this FetchGroup. + * @return the FetchGroup + * @throws JDOUserException if any parameter is not a member of the persistent type + * @throws JDOUserException if the FetchGroup is unmodifiable + * @since 2.2 + */ + FetchGroup removeMembers(String... memberNames); - /** - * Add the members (fields or properties) of the named category to the set of members in this - * FetchGroup. This method first resolves the category name to a set of members and then adds the - * members as if {@link #addMembers} was called. After this method executes, the category is not - * remembered. - * - * @param categoryName Category to add to this FetchGroup. - * @return the FetchGroup - * @throws JDOUserException if the FetchGroup is unmodifiable - * @since 2.2 - */ - FetchGroup addCategory(String categoryName); + /** + * Add the members (fields or properties) of the named category + * to the set of members in this FetchGroup. This method first + * resolves the category name to a set of members and then adds + * the members as if {@link #addMembers} was called. After this + * method executes, the category is not remembered. + * @param categoryName Category to add to this FetchGroup. + * @return the FetchGroup + * @throws JDOUserException if the FetchGroup is unmodifiable + * @since 2.2 + */ + FetchGroup addCategory(String categoryName); - /** - * Remove the members (fields or properties) of the named category from the set of members in this - * FetchGroup. This method first resolves the category name to a set of members and then removes - * the members as if {@link #removeMembers} was called. After this method executes, the category - * is not remembered. - * - * @param categoryName Category to remove from this FetchGroup. - * @return the FetchGroup - * @throws JDOUserException if the FetchGroup is unmodifiable - * @since 2.2 - */ - FetchGroup removeCategory(String categoryName); + /** + * Remove the members (fields or properties) of the named category + * from the set of members in this FetchGroup. This method first + * resolves the category name to a set of members and then removes + * the members as if {@link #removeMembers} was called. After this + * method executes, the category is not remembered. + * @param categoryName Category to remove from this FetchGroup. + * @return the FetchGroup + * @throws JDOUserException if the FetchGroup is unmodifiable + * @since 2.2 + */ + FetchGroup removeCategory(String categoryName); - /** - * Set the recursion-depth for this member. The default is 1. A value of 0 means don't fetch the - * member (as if the member were omitted entirely). A value of -1 means fetch all instances - * reachable via this member. - * - * @return the FetchGroup - * @param memberName the name of the field or property - * @param recursionDepth the value for the recursion-depth property - * @throws JDOUserException if the member does not exist - * @throws JDOUserException if the FetchGroup is unmodifiable - * @since 2.2 - */ - FetchGroup setRecursionDepth(String memberName, int recursionDepth); + /** + * Set the recursion-depth for this member. The default is 1. A value of 0 + * means don't fetch the member (as if the member were omitted entirely). + * A value of -1 means fetch all instances reachable via this member. + * @return the FetchGroup + * @param memberName the name of the field or property + * @param recursionDepth the value for the recursion-depth property + * @throws JDOUserException if the member does not exist + * @throws JDOUserException if the FetchGroup is unmodifiable + * @since 2.2 + */ + FetchGroup setRecursionDepth(String memberName, int recursionDepth); - /** - * Get the recursion-depth for this member. - * - * @param memberName the name of the field or property - * @return the recursion-depth for this member - * @throws JDOUserException if the member is not in the FetchGroup - * @since 2.2 - */ - int getRecursionDepth(String memberName); + /** + * Get the recursion-depth for this member. + * @param memberName the name of the field or property + * @return the recursion-depth for this member + * @throws JDOUserException if the member is not in the FetchGroup + * @since 2.2 + */ + int getRecursionDepth(String memberName); - /** - * Return an immutable Set of String containing the names of all members. The Set is a copy of the - * currently defined members and will not change based on subsequent changes to the membership in - * the FetchGroup. - * - * @return an immutable Set containing the names of all members in the FetchGroup - * @since 2.2 - */ - Set getMembers(); + /** + * Return an immutable Set of String containing the names of all members. + * The Set is a copy of the currently defined members and will not change + * based on subsequent changes to the membership in the FetchGroup. + * @return an immutable Set containing the names of all members + * in the FetchGroup + * @since 2.2 + */ + Set getMembers(); - /** - * Make this FetchGroup unmodifiable. If already unmodifiable, this method has no effect. - * - * @return the FetchGroup - * @since 2.2 - */ - FetchGroup setUnmodifiable(); + /** + * Make this FetchGroup unmodifiable. If already unmodifiable, this method + * has no effect. + * @return the FetchGroup + * @since 2.2 + */ + FetchGroup setUnmodifiable(); - /** - * Return whether this FetchGroup is unmodifiable. If so, methods {@link #setPostLoad}, {@link - * #addMember}, {@link #removeMember}, {@link #addMembers}, {@link #removeMembers}, {@link - * #addCategory}, and {@link #removeCategory} will throw {@link JDOUserException}. - * - * @return whether the FetchGroup is unmodifiable - * @since 2.2 - */ - boolean isUnmodifiable(); + /** + * Return whether this FetchGroup is unmodifiable. If so, methods + * {@link #setPostLoad}, {@link #addMember}, {@link #removeMember}, + * {@link #addMembers}, {@link #removeMembers}, + * {@link #addCategory}, and {@link #removeCategory} + * will throw {@link JDOUserException}. + * @return whether the FetchGroup is unmodifiable + * @since 2.2 + */ + boolean isUnmodifiable(); } diff --git a/api/src/main/java/javax/jdo/FetchPlan.java b/api/src/main/java/javax/jdo/FetchPlan.java index 0548b5cd2..85ea6722e 100644 --- a/api/src/main/java/javax/jdo/FetchPlan.java +++ b/api/src/main/java/javax/jdo/FetchPlan.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,221 +19,211 @@ * FetchPlan.java * */ - + package javax.jdo; import java.util.Collection; import java.util.Set; /** - * Fetch groups are activated using methods on this interface. An instance of this interface can be - * obtained from {@link PersistenceManager#getFetchPlan}, {@link Extent#getFetchPlan}, and {@link - * Query#getFetchPlan}. When a Query or Extent is retrieved from a - * PersistenceManager, its FetchPlan is initialized to the same settings as that - * of the PersistenceManager. Subsequent modifications of the Query or - * Extent's FetchPlan are not reflected in the FetchPlan of - * the PersistenceManager. - * + * Fetch groups are activated using methods on this interface. An + * instance of this interface can be obtained from {@link + * PersistenceManager#getFetchPlan}, {@link Extent#getFetchPlan}, and + * {@link Query#getFetchPlan}. When a Query or + * Extent is retrieved from a + * PersistenceManager, its FetchPlan is + * initialized to the same settings as that of the + * PersistenceManager. Subsequent modifications of the + * Query or Extent's FetchPlan + * are not reflected in the FetchPlan of the + * PersistenceManager. * @version 2.0 * @since 2.0 */ public interface FetchPlan { - /** - * For use with {@link #addGroup}, {@link #removeGroup}, and the various {@link #setGroups} calls. - * Value: default. - * - * @since 2.0 - */ - public static final String DEFAULT = "default"; - - /** - * For use with {@link #addGroup}, {@link #removeGroup}, and the various {@link #setGroups} calls. - * Value: all. - * - * @since 2.0 - */ - public static final String ALL = "all"; - - /** - * For use with {@link PersistenceManager#detachCopy} and {@link #setDetachmentOptions}. Specifies - * that fields that are loaded but not in the current fetch plan should be unloaded prior to - * detachment. - * - * @since 2.0 - */ - public static final int DETACH_UNLOAD_FIELDS = 2; - - /** - * For use with {@link PersistenceManager#detachCopy} and {@link #setDetachmentOptions}. Specifies - * that fields that are not loaded but are in the current fetch plan should be loaded prior to - * detachment. - * - * @since 2.0 - */ - public static final int DETACH_LOAD_FIELDS = 1; - - /** - * For use with {@link #setFetchSize}. Value: -1. - * - * @since 2.0 - */ - public static final int FETCH_SIZE_GREEDY = -1; - - /** - * For use with {@link #setFetchSize}. Value: 0. - * - * @since 2.0 - */ - public static final int FETCH_SIZE_OPTIMAL = 0; - - /** - * Add the fetch group to the set of active fetch groups. - * - * @param fetchGroupName Name of the FetchGroup to add - * @return the FetchPlan - * @since 2.0 - */ - FetchPlan addGroup(String fetchGroupName); - - /** - * Remove the fetch group from the set active fetch groups. - * - * @param fetchGroupName Name of the FetchGroup to remove - * @return the FetchPlan - * @since 2.0 - */ - FetchPlan removeGroup(String fetchGroupName); - - /** - * Remove all active groups leaving no active fetch group. - * - * @return the FetchPlan - * @since 2.0 - */ - FetchPlan clearGroups(); - - /** - * Return an immutable Set containing the names of all active fetch groups. The Set is a copy of - * the currently active groups and will not change based on subsequent changes to the groups. - * - * @return an immutable Set containing the names of all currently active fetch groups - * @since 2.0 - */ - Set getGroups(); - - /** - * Set a collection of groups. - * - * @param fetchGroupNames a collection of names of fetch groups - * @return the FetchPlan - * @since 2.0 - */ - FetchPlan setGroups(Collection fetchGroupNames); - - /** - * Set a collection of groups. - * - * @param fetchGroupNames a String array of names of fetch groups - * @return the FetchPlan - * @since 2.0 - */ - FetchPlan setGroups(String... fetchGroupNames); - - /** - * Set the active fetch groups to the single named fetch group. - * - * @param fetchGroupName the single fetch group - * @return the FetchPlan - * @since 2.0 - */ - FetchPlan setGroup(String fetchGroupName); - - /** - * Set the maximum fetch depth when fetching. A value of 0 has no meaning and will throw a - * JDOUserException. A value of -1 means that no limit is placed on fetching. A positive integer - * will result in that number of references from the initial object to be fetched. - * - * @param fetchDepth the depth - * @return the FetchPlan - * @since 2.0 - */ - FetchPlan setMaxFetchDepth(int fetchDepth); - - /** - * Return the maximum fetch depth used when fetching instances. - * - * @return the maximum fetch depth - * @since 2.0 - */ - int getMaxFetchDepth(); - - /** - * Set the roots for DetachAllOnCommit. - * - * @param roots Collection of the detachment roots. - * @return This FetchPlan - * @since 2.0 - */ - FetchPlan setDetachmentRoots(Collection roots); - - /** - * Get the roots for DetachAllOnCommit. - * - * @return Collection of detachment roots. - * @since 2.0 - */ - Collection getDetachmentRoots(); - - /** - * Set the root classes for DetachAllOnCommit. - * - * @param rootClasses The root classes. - * @return This FetchPlan - * @since 2.0 - */ - FetchPlan setDetachmentRootClasses(Class... rootClasses); - - /** - * Get the root classes for DetachAllOnCommit. - * - * @return The detachment root classes - * @since 2.0 - */ - Class[] getDetachmentRootClasses(); - - /** - * Set the fetch size for large result set support. Use {@link #FETCH_SIZE_OPTIMAL} to unset, and - * {@link #FETCH_SIZE_GREEDY} to force loading of everything. - * - * @param fetchSize the fetch size - * @return the FetchPlan - * @since 2.0 - */ - FetchPlan setFetchSize(int fetchSize); - - /** - * Return the fetch size, or {@link #FETCH_SIZE_OPTIMAL} if not set, or {@link #FETCH_SIZE_GREEDY} - * to fetch all. - * - * @return the fetch size - * @since 2.0 - */ - int getFetchSize(); - - /** - * Set options to be used during detachment. Options are {@link #DETACH_LOAD_FIELDS} and {@link - * #DETACH_UNLOAD_FIELDS}. - * - * @param options Options for use during detachment. - * @return This FetchPlan - */ - FetchPlan setDetachmentOptions(int options); - - /** - * Get options used during detachment. - * - * @return Options to use during detachment. - */ - int getDetachmentOptions(); + /** + * For use with {@link #addGroup}, {@link #removeGroup}, and the + * various {@link #setGroups} calls. Value: default. + * @since 2.0 + */ + public static final String DEFAULT = "default"; + + /** + * For use with {@link #addGroup}, {@link #removeGroup}, and the + * various {@link #setGroups} calls. Value: all. + * @since 2.0 + */ + public static final String ALL = "all"; + + /** + * For use with {@link PersistenceManager#detachCopy} and + * {@link #setDetachmentOptions}. Specifies that + * fields that are loaded but not in the current fetch plan should + * be unloaded prior to detachment. + * @since 2.0 + */ + public static final int DETACH_UNLOAD_FIELDS = 2; + + /** + * For use with {@link PersistenceManager#detachCopy} and + * {@link #setDetachmentOptions}. Specifies that + * fields that are not loaded but are in the current fetch plan should + * be loaded prior to detachment. + * @since 2.0 + */ + public static final int DETACH_LOAD_FIELDS = 1; + + /** + * For use with {@link #setFetchSize}. Value: -1. + * @since 2.0 + */ + public static final int FETCH_SIZE_GREEDY = -1; + + /** + * For use with {@link #setFetchSize}. Value: 0. + * @since 2.0 + */ + public static final int FETCH_SIZE_OPTIMAL = 0; + + /** + * Add the fetch group to the set of active fetch groups. + * @param fetchGroupName Name of the FetchGroup to add + * @return the FetchPlan + * @since 2.0 + */ + FetchPlan addGroup(String fetchGroupName); + + /** + * Remove the fetch group from the set active fetch groups. + * @param fetchGroupName Name of the FetchGroup to remove + * @return the FetchPlan + * @since 2.0 + */ + FetchPlan removeGroup(String fetchGroupName); + + /** + * Remove all active groups leaving no active fetch group. + * @return the FetchPlan + * @since 2.0 + */ + FetchPlan clearGroups(); + + /** + * Return an immutable Set containing the names + * of all active fetch groups. The Set is a copy of + * the currently active groups and will not change + * based on subsequent changes to the groups. + * @return an immutable Set containing the names + * of all currently active fetch groups + * @since 2.0 + */ + Set getGroups(); + + /** + * Set a collection of groups. + * @param fetchGroupNames a collection of names of fetch groups + * @return the FetchPlan + * @since 2.0 + */ + FetchPlan setGroups(Collection fetchGroupNames); + + /** + * Set a collection of groups. + * @param fetchGroupNames a String array of names of fetch groups + * @return the FetchPlan + * @since 2.0 + */ + FetchPlan setGroups(String... fetchGroupNames); + + /** + * Set the active fetch groups to the single named fetch group. + * @param fetchGroupName the single fetch group + * @return the FetchPlan + * @since 2.0 + */ + FetchPlan setGroup(String fetchGroupName); + + /** + * Set the maximum fetch depth when fetching. + * A value of 0 has no meaning and will throw a JDOUserException. + * A value of -1 means that no limit is placed on fetching. + * A positive integer will result in that number of references from the + * initial object to be fetched. + * @param fetchDepth the depth + * @return the FetchPlan + * @since 2.0 + */ + FetchPlan setMaxFetchDepth(int fetchDepth); + + /** + * Return the maximum fetch depth used when fetching instances. + * @return the maximum fetch depth + * @since 2.0 + */ + int getMaxFetchDepth(); + + /** + * Set the roots for DetachAllOnCommit. + * @param roots Collection of the detachment roots. + * @return This FetchPlan + * @since 2.0 + */ + FetchPlan setDetachmentRoots(Collection roots); + + /** + * Get the roots for DetachAllOnCommit. + * @return Collection of detachment roots. + * @since 2.0 + */ + Collection getDetachmentRoots(); + + /** + * Set the root classes for DetachAllOnCommit. + * @param rootClasses The root classes. + * @return This FetchPlan + * @since 2.0 + */ + FetchPlan setDetachmentRootClasses(Class... rootClasses); + + /** + * Get the root classes for DetachAllOnCommit. + * @return The detachment root classes + * @since 2.0 + */ + Class[] getDetachmentRootClasses(); + + /** + * Set the fetch size for large result set support. Use + * {@link #FETCH_SIZE_OPTIMAL} to unset, and {@link #FETCH_SIZE_GREEDY} + * to force loading of everything. + * @param fetchSize the fetch size + * @return the FetchPlan + * @since 2.0 + */ + FetchPlan setFetchSize(int fetchSize); + + /** + * Return the fetch size, or {@link #FETCH_SIZE_OPTIMAL} if not set, + * or {@link #FETCH_SIZE_GREEDY} to fetch all. + * @return the fetch size + * @since 2.0 + */ + int getFetchSize(); + + /** + * Set options to be used during detachment. Options are {@link + * #DETACH_LOAD_FIELDS} and {@link #DETACH_UNLOAD_FIELDS}. + * @param options Options for use during detachment. + * @return This FetchPlan + */ + FetchPlan setDetachmentOptions(int options); + + /** + * Get options used during detachment. + * @return Options to use during detachment. + */ + int getDetachmentOptions(); + } + diff --git a/api/src/main/java/javax/jdo/InstanceCallbacks.java b/api/src/main/java/javax/jdo/InstanceCallbacks.java index 2aad32ab8..640e963ee 100644 --- a/api/src/main/java/javax/jdo/InstanceCallbacks.java +++ b/api/src/main/java/javax/jdo/InstanceCallbacks.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,44 +19,53 @@ * InstanceCallbacks.java * */ - + package javax.jdo; -/** - * A PersistenceCapable class that provides callback methods for life cycle events - * implements this interface. +/** A PersistenceCapable class that provides callback methods for life + * cycle events implements this interface. * - *

    For JDO 2.0, InstanceCallbacks has been refactored to extend four other - * interfaces, without changing any of the methods or semantics. This allows fine-grained control - * over callbacks, for example to allow a class to implement the load callback without implementing - * any of the other callbacks. For backward compatibility with JDO 1.0, the InstanceCallbacks - * interface is preserved. + *

    For JDO 2.0, InstanceCallbacks has been refactored to extend + * four other interfaces, without changing any of the methods or semantics. + * This allows fine-grained control over callbacks, for + * example to allow a class to implement the load callback without + * implementing any of the other callbacks. For backward compatibility + * with JDO 1.0, the InstanceCallbacks interface is preserved. * - *

    Classes which include non-persistent fields whose values depend on the values of persistent - * fields require callbacks on specific JDO instance life cycle events in order to correctly - * populate the values in these fields. + *

    Classes which include non-persistent fields whose values depend + * on the values of persistent fields require callbacks on specific + * JDO instance life cycle events in order to correctly populate the + * values in these fields. * - *

    The callbacks might also be used if the persistent instances need to be put into the runtime - * infrastructure of the application. For example, a persistent instance might notify other - * instances on changes to state. The persistent instance might be in a list of managed instances. - * When the persistent instance is made hollow, it can no longer generate change events, and the - * persistent instance should be removed from the list of managed instances. + *

    The callbacks might also be used if the persistent instances + * need to be put into the runtime infrastructure of the application. + * For example, a persistent instance might notify other instances + * on changes to state. The persistent instance might be in a list of + * managed instances. When the persistent instance is made hollow, + * it can no longer generate change events, and the persistent + * instance should be removed from the list of managed instances. * - *

    To implement this, the application programmer would implement jdoPostLoad to put - * itself into the list of managed instances, and implement jdoPreClear to remove - * itself from the list. With JDO 1.0, the domain class would be declared to implement - * InstanceCallbacks. With JDO 2.0, the domain class would be declared to implement - * javax.jdo.listener.LoadCallback and javax.jdo.listener.ClearCallback. + *

    To implement this, the application programmer would implement + * jdoPostLoad to put itself into the list of managed + * instances, and implement jdoPreClear to remove itself from + * the list. With JDO 1.0, the domain class would be declared to implement + * InstanceCallbacks. With JDO 2.0, the domain class + * would be declared to implement + * javax.jdo.listener.LoadCallback and + * javax.jdo.listener.ClearCallback. * - *

    Note that JDO does not manage the state of non-persistent fields, and when a JDO instance - * transitions to hollow, JDO clears the persistent fields. It is the programmer's responsibility to - * clear non-persistent fields so that garbage collection of referred instances can occur. + *

    Note that JDO does not manage the state of non-persistent + * fields, and when a JDO instance transitions to hollow, JDO clears + * the persistent fields. It is the programmer's responsibility to + * clear non-persistent fields so that garbage collection of + * referred instances can occur. * * @since 1.0 * @version 2.0 */ -public interface InstanceCallbacks - extends javax.jdo.listener.ClearCallback, +public interface InstanceCallbacks + extends javax.jdo.listener.ClearCallback, javax.jdo.listener.DeleteCallback, javax.jdo.listener.LoadCallback, - javax.jdo.listener.StoreCallback {} + javax.jdo.listener.StoreCallback { +} diff --git a/api/src/main/java/javax/jdo/JDOCanRetryException.java b/api/src/main/java/javax/jdo/JDOCanRetryException.java index 59d10e5aa..8296fc394 100644 --- a/api/src/main/java/javax/jdo/JDOCanRetryException.java +++ b/api/src/main/java/javax/jdo/JDOCanRetryException.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -22,81 +22,74 @@ package javax.jdo; -/** - * This is the base class for exceptions that can be retried. +/** This is the base class for exceptions that can be retried. * * @version 1.0 */ public class JDOCanRetryException extends JDOException { - private static final long serialVersionUID = 3046202905626157173L; - - /** Constructs a new JDOCanRetryException without a detail message. */ - public JDOCanRetryException() {} - - /** - * Constructs a new JDOCanRetryException with the specified detail message. - * - * @param msg the detail message. - */ - public JDOCanRetryException(String msg) { - super(msg); - } - - /** - * Constructs a new JDOCanRetryException with the specified detail message and nested - * Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - */ - public JDOCanRetryException(String msg, Throwable[] nested) { - super(msg, nested); - } + private static final long serialVersionUID = 3046202905626157173L; - /** - * Constructs a new JDOCanRetryException with the specified detail message and nested - * Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable. - */ - public JDOCanRetryException(String msg, Throwable nested) { - super(msg, nested); - } + /** + * Constructs a new JDOCanRetryException without a detail message. + */ + public JDOCanRetryException() { + } - /** - * Constructs a new JDOCanRetryException with the specified detail message and failed - * object. - * - * @param msg the detail message. - * @param failed the failed object. - */ - public JDOCanRetryException(String msg, Object failed) { - super(msg, failed); - } + /** + * Constructs a new JDOCanRetryException with the specified detail message. + * @param msg the detail message. + */ + public JDOCanRetryException(String msg) { + super(msg); + } - /** - * Constructs a new JDOCanRetryException with the specified detail message, nested - * Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - * @param failed the failed object. - */ - public JDOCanRetryException(String msg, Throwable[] nested, Object failed) { - super(msg, nested, failed); - } + /** + * Constructs a new JDOCanRetryException with the specified detail + * message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable[]. + */ + public JDOCanRetryException(String msg, Throwable[] nested) { + super(msg, nested); + } + + /** + * Constructs a new JDOCanRetryException with the specified detail + * message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable. + */ + public JDOCanRetryException(String msg, Throwable nested) { + super(msg, nested); + } + + /** Constructs a new JDOCanRetryException with the specified detail message + * and failed object. + * @param msg the detail message. + * @param failed the failed object. + */ + public JDOCanRetryException(String msg, Object failed) { + super(msg, failed); + } + + /** Constructs a new JDOCanRetryException with the specified detail message, + * nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable[]. + * @param failed the failed object. + */ + public JDOCanRetryException(String msg, Throwable[] nested, Object failed) { + super(msg, nested, failed); + } - /** - * Constructs a new JDOCanRetryException with the specified detail message, nested - * Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable. - * @param failed the failed object. - */ - public JDOCanRetryException(String msg, Throwable nested, Object failed) { - super(msg, nested, failed); - } + /** Constructs a new JDOCanRetryException with the specified detail message, + * nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable. + * @param failed the failed object. + */ + public JDOCanRetryException(String msg, Throwable nested, Object failed) { + super(msg, nested, failed); + } } diff --git a/api/src/main/java/javax/jdo/JDODataStoreException.java b/api/src/main/java/javax/jdo/JDODataStoreException.java index b08c47036..4437d10a8 100644 --- a/api/src/main/java/javax/jdo/JDODataStoreException.java +++ b/api/src/main/java/javax/jdo/JDODataStoreException.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -22,81 +22,78 @@ package javax.jdo; -/** - * This class represents data store exceptions that can be retried. +/** This class represents data store exceptions that can be retried. * * @version 1.0 */ public class JDODataStoreException extends JDOCanRetryException { - private static final long serialVersionUID = -8728485891077403354L; + private static final long serialVersionUID = -8728485891077403354L; - /** Constructs a new JDODataStoreException without a detail message. */ - public JDODataStoreException() {} + /** + * Constructs a new JDODataStoreException without a detail message. + */ + public JDODataStoreException() { + } - /** - * Constructs a new JDODataStoreException with the specified detail message. - * - * @param msg the detail message. - */ - public JDODataStoreException(String msg) { - super(msg); - } + /** + * Constructs a new JDODataStoreException with the specified detail message. + * @param msg the detail message. + */ + public JDODataStoreException(String msg) { + super(msg); + } - /** - * Constructs a new JDODataStoreException with the specified detail message and - * nested Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - */ - public JDODataStoreException(String msg, Throwable[] nested) { - super(msg, nested); - } + /** + * Constructs a new JDODataStoreException with the specified + * detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable[]. + */ + public JDODataStoreException(String msg, Throwable[] nested) { + super(msg, nested); + } - /** - * Constructs a new JDODataStoreException with the specified detail message and - * nested Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable. - */ - public JDODataStoreException(String msg, Throwable nested) { - super(msg, nested); - } + /** + * Constructs a new JDODataStoreException with the specified + * detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable. + */ + public JDODataStoreException(String msg, Throwable nested) { + super(msg, nested); + } - /** - * Constructs a new JDODataStoreException with the specified detail message and - * failed object. - * - * @param msg the detail message. - * @param failed the failed object. - */ - public JDODataStoreException(String msg, Object failed) { - super(msg, failed); - } + /** + * Constructs a new JDODataStoreException with the specified detail message + * and failed object. + * @param msg the detail message. + * @param failed the failed object. + */ + public JDODataStoreException(String msg, Object failed) { + super(msg, failed); + } + + /** + * Constructs a new JDODataStoreException with the specified detail message, + * nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable[]. + * @param failed the failed object. + */ + public JDODataStoreException(String msg, Throwable[] nested, Object failed) { + super(msg, nested, failed); + } - /** - * Constructs a new JDODataStoreException with the specified detail message, nested - * Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - * @param failed the failed object. - */ - public JDODataStoreException(String msg, Throwable[] nested, Object failed) { - super(msg, nested, failed); - } - - /** - * Constructs a new JDODataStoreException with the specified detail message, nested - * Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable. - * @param failed the failed object. - */ - public JDODataStoreException(String msg, Throwable nested, Object failed) { - super(msg, nested, failed); - } + /** + * Constructs a new JDODataStoreException with the specified detail message, + * nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable. + * @param failed the failed object. + */ + public JDODataStoreException(String msg, Throwable nested, Object failed) { + super(msg, nested, failed); + } } + diff --git a/api/src/main/java/javax/jdo/JDODetachedFieldAccessException.java b/api/src/main/java/javax/jdo/JDODetachedFieldAccessException.java index 72fd5b2ec..011f6cda3 100644 --- a/api/src/main/java/javax/jdo/JDODetachedFieldAccessException.java +++ b/api/src/main/java/javax/jdo/JDODetachedFieldAccessException.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -22,67 +22,61 @@ package javax.jdo; -/** - * This class represents exceptions caused by access of an unloaded field while the instance is - * detached. +/** This class represents exceptions caused by access of an unloaded field while + * the instance is detached. * * @version 2.0 * @since 2.0 */ public class JDODetachedFieldAccessException extends JDOUserException { - private static final long serialVersionUID = 5035418119865472625L; - - /** - * Constructs a new JDODetachedFieldAccessException without a detail message. - * - * @since 2.0 - */ - public JDODetachedFieldAccessException() {} + private static final long serialVersionUID = 5035418119865472625L; - /** - * Constructs a new JDODetachedFieldAccessException with the specified detail - * message. - * - * @param msg the detail message. - * @since 2.0 - */ - public JDODetachedFieldAccessException(String msg) { - super(msg); - } + /** + * Constructs a new JDODetachedFieldAccessException without a detail message. + * @since 2.0 + */ + public JDODetachedFieldAccessException() { + } - /** - * Constructs a new JDODetachedFieldAccessException with the specified detail message - * and failed object. - * - * @param msg the detail message. - * @param failed the failed object. - */ - public JDODetachedFieldAccessException(String msg, Object failed) { - super(msg, failed); - } + /** + * Constructs a new JDODetachedFieldAccessException with the + * specified detail message. + * @param msg the detail message. + * @since 2.0 + */ + public JDODetachedFieldAccessException(String msg) { + super(msg); + } - /** - * Constructs a new JDODetachedFieldAccessException with the specified detail message - * and nested Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - * @since 2.0 - */ - public JDODetachedFieldAccessException(String msg, Throwable[] nested) { - super(msg, nested); - } + /** Constructs a new JDODetachedFieldAccessException + * with the specified detail message and failed object. + * @param msg the detail message. + * @param failed the failed object. + */ + public JDODetachedFieldAccessException(String msg, Object failed) { + super(msg, failed); + } + + /** + * Constructs a new JDODetachedFieldAccessException with the + * specified detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable[]. + * @since 2.0 + */ + public JDODetachedFieldAccessException(String msg, Throwable[] nested) { + super(msg, nested); + } - /** - * Constructs a new JDODetachedFieldAccessException with the specified detail message - * and nested Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable. - * @since 2.0 - */ - public JDODetachedFieldAccessException(String msg, Throwable nested) { - super(msg, nested); - } + /** + * Constructs a new JDODetachedFieldAccessException with the + * specified detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable. + * @since 2.0 + */ + public JDODetachedFieldAccessException(String msg, Throwable nested) { + super(msg, nested); + } } diff --git a/api/src/main/java/javax/jdo/JDOEnhanceException.java b/api/src/main/java/javax/jdo/JDOEnhanceException.java index 56afd05c2..dc8ed5353 100644 --- a/api/src/main/java/javax/jdo/JDOEnhanceException.java +++ b/api/src/main/java/javax/jdo/JDOEnhanceException.java @@ -18,43 +18,49 @@ /** * Exception thrown when an error occurs during enhancement. - * * @since 3.0 */ -public class JDOEnhanceException extends JDOException { - private static final long serialVersionUID = 7953336394264555958L; +public class JDOEnhanceException extends JDOException +{ + private static final long serialVersionUID = 7953336394264555958L; - /** Constructs a new JDOEnhanceException without a detail message. */ - public JDOEnhanceException() {} + /** + * Constructs a new JDOEnhanceException without a + * detail message. + */ + public JDOEnhanceException() + { + } - /** - * Constructs a new JDOEnhanceException with the specified detail message. - * - * @param msg the detail message. - */ - public JDOEnhanceException(String msg) { - super(msg); - } + /** + * Constructs a new JDOEnhanceException with the + * specified detail message. + * @param msg the detail message. + */ + public JDOEnhanceException(String msg) + { + super(msg); + } - /** - * Constructs a new JDOEnhanceException with the specified detail message and nested - * Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - */ - public JDOEnhanceException(String msg, Throwable[] nested) { - super(msg, nested); - } + /** + * Constructs a new JDOEnhanceException with the + * specified detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable[]. + */ + public JDOEnhanceException(String msg, Throwable[] nested) + { + super(msg, nested); + } - /** - * Constructs a new JDOEnhanceException with the specified detail message and nested - * Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable. - */ - public JDOEnhanceException(String msg, Throwable nested) { - super(msg, nested); - } + /** + * Constructs a new JDOEnhanceException with the + * specified detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable. + */ + public JDOEnhanceException(String msg, Throwable nested) + { + super(msg, nested); + } } diff --git a/api/src/main/java/javax/jdo/JDOEnhancer.java b/api/src/main/java/javax/jdo/JDOEnhancer.java index 1c6306f17..08deb8091 100644 --- a/api/src/main/java/javax/jdo/JDOEnhancer.java +++ b/api/src/main/java/javax/jdo/JDOEnhancer.java @@ -18,144 +18,135 @@ import java.lang.instrument.ClassFileTransformer; import java.util.Properties; + import javax.jdo.metadata.JDOMetadata; /** * Interface for a JDO Enhancer. - * * @since 3.0 */ -public interface JDOEnhancer extends ClassFileTransformer { - /** - * Return non-configurable properties of this JDOEnhancer. Properties with keys "VendorName" and - * "VersionNumber" are required. Other keys are optional. - * - * @return the non-configurable properties of this JDOEnhancer. - */ - Properties getProperties(); - - /** - * Whether to provide verbose output - * - * @param flag Verbose? - * @return The enhancer - */ - JDOEnhancer setVerbose(boolean flag); - - /** - * Mutator to set the location where enhanced classes are written. Mutator to set the location - * where enhanced classes are written. If this method is not called, classes will be enhanced in - * place, overwriting the existing classes. If overwriting classes in a jar file, the existing - * files in the jar file will be written unchanged except for the enhanced classes. The directory - * name can be absolute or relative. - * - * @param dirName Name of the directory - * @return The enhancer - */ - JDOEnhancer setOutputDirectory(String dirName); - - /** - * Mutator to set the class loader to use for loading classes. - * - * @param loader ClassLoader to use - * @return The enhancer - */ - JDOEnhancer setClassLoader(ClassLoader loader); - - /** - * Add a persistence-unit to the items to be enhanced. - * - * @param persistenceUnit Name of the persistence unit - * @return The enhancer - */ - JDOEnhancer addPersistenceUnit(String persistenceUnit); - - /** - * Add an in-memory class to the items to be enhanced. The class name should be of the form - * "mydomain.MyClass". - * - * @param className Name of the class - * @param bytes The bytes of the class - * @return The enhancer - */ - JDOEnhancer addClass(String className, byte[] bytes); - - /** - * Add class(es) to the items to be enhanced. The class names can be absolute file names, relative - * file names, or names of CLASSPATH resources. - * - * @param classNames Names of the classes - * @return The enhancer - */ - JDOEnhancer addClasses(String... classNames); - - /** - * Add metadata file(s) to the items to be enhanced. The metadata file names can be absolute file - * names, relative file names, or names of CLASSPATH resources. They should be JDO XML metadata - * files. - * - * @param metadataFiles Names of the files - * @return The enhancer - */ - JDOEnhancer addFiles(String... metadataFiles); - - /** - * Add a jar file to the items to be enhanced. The jar file name can be absolute, or relative or a - * CLASSPATH resource. - * - * @param jarFileName Name of the jar file - * @return The enhancer - */ - JDOEnhancer addJar(String jarFileName); - - /** - * Method to enhance the items specified using addJar, addFiles, addClasses, addClass, - * addPersistenceUnit. - * - * @return Number of classes enhanced - * @throws JDOEnhanceException if an error occurs during enhancement. If multiple errors occur - * then the nested exceptions provides this detail. - */ - int enhance(); - - /** - * Method to validate the items specified using addJar, addFiles, addClasses, addClass, - * addPersistenceUnit. - * - * @return Number of classes validated - * @throws JDOEnhanceException if an error occurs during validation. If multiple errors occur then - * the nested exceptions provides this detail. - */ - int validate(); - - /** - * Method to retrieve the (enhanced) bytes of the specified class. Only applies to the classes - * enhanced in the most recent enhance() call. If no enhance has yet been performed will throw a - * JDOEnhanceException. If the specified class hasn't been enhanced then will throw a - * JDOEnhanceException. - * - * @param className Name of the class (of the form "mydomain.MyClass") - * @return Enhanced bytes - */ - byte[] getEnhancedBytes(String className); - - /** - * Method to register metadata with the enhancement process managed by this JDOEnhancer - * . Metadata can be created using the method {@link #newMetadata}. If there is already - * metadata registered for a class contained in this metadata object then a JDOUserException will - * be thrown. - * - * @param metadata The Metadata to register. - * @since 3.0 - */ - void registerMetadata(JDOMetadata metadata); - - /** - * Method to return a new metadata object that can be subsequently modified and registered with - * the enhancement process using the method {@link #registerMetadata}. - * - * @return The metadata - * @since 3.0 - */ - JDOMetadata newMetadata(); +public interface JDOEnhancer extends ClassFileTransformer +{ + /** + * Return non-configurable properties of this JDOEnhancer. + * Properties with keys "VendorName" and "VersionNumber" are required. + * Other keys are optional. + * @return the non-configurable properties of this JDOEnhancer. + */ + Properties getProperties(); + + /** + * Whether to provide verbose output + * @param flag Verbose? + * @return The enhancer + */ + JDOEnhancer setVerbose(boolean flag); + + /** + * Mutator to set the location where enhanced classes are written. + * Mutator to set the location where enhanced classes are written. + * If this method is not called, classes will be enhanced in place, + * overwriting the existing classes. If overwriting classes in a jar file, + * the existing files in the jar file will be written unchanged except + * for the enhanced classes. The directory name can be absolute or relative. + * @param dirName Name of the directory + * @return The enhancer + */ + JDOEnhancer setOutputDirectory(String dirName); + + /** + * Mutator to set the class loader to use for loading classes. + * @param loader ClassLoader to use + * @return The enhancer + */ + JDOEnhancer setClassLoader(ClassLoader loader); + + /** + * Add a persistence-unit to the items to be enhanced. + * @param persistenceUnit Name of the persistence unit + * @return The enhancer + */ + JDOEnhancer addPersistenceUnit(String persistenceUnit); + + /** + * Add an in-memory class to the items to be enhanced. + * The class name should be of the form "mydomain.MyClass". + * @param className Name of the class + * @param bytes The bytes of the class + * @return The enhancer + */ + JDOEnhancer addClass(String className, byte[] bytes); + + /** + * Add class(es) to the items to be enhanced. + * The class names can be absolute file names, relative file names, or + * names of CLASSPATH resources. + * @param classNames Names of the classes + * @return The enhancer + */ + JDOEnhancer addClasses(String... classNames); + + /** + * Add metadata file(s) to the items to be enhanced. + * The metadata file names can be absolute file names, relative file names, or + * names of CLASSPATH resources. They should be JDO XML metadata files. + * @param metadataFiles Names of the files + * @return The enhancer + */ + JDOEnhancer addFiles(String... metadataFiles); + + /** + * Add a jar file to the items to be enhanced. + * The jar file name can be absolute, or relative or a CLASSPATH resource. + * @param jarFileName Name of the jar file + * @return The enhancer + */ + JDOEnhancer addJar(String jarFileName); + + /** + * Method to enhance the items specified using addJar, addFiles, addClasses, addClass, + * addPersistenceUnit. + * @return Number of classes enhanced + * @throws JDOEnhanceException if an error occurs during enhancement. If multiple + * errors occur then the nested exceptions provides this detail. + */ + int enhance(); + + /** + * Method to validate the items specified using addJar, addFiles, addClasses, addClass, + * addPersistenceUnit. + * @return Number of classes validated + * @throws JDOEnhanceException if an error occurs during validation. If multiple + * errors occur then the nested exceptions provides this detail. + */ + int validate(); + + /** + * Method to retrieve the (enhanced) bytes of the specified class. + * Only applies to the classes enhanced in the most recent enhance() call. + * If no enhance has yet been performed will throw a JDOEnhanceException. + * If the specified class hasn't been enhanced then will throw a JDOEnhanceException. + * @param className Name of the class (of the form "mydomain.MyClass") + * @return Enhanced bytes + */ + byte[] getEnhancedBytes(String className); + + /** + * Method to register metadata with the enhancement process managed by this + * JDOEnhancer. + * Metadata can be created using the method {@link #newMetadata}. + * If there is already metadata registered for a class contained in this metadata + * object then a JDOUserException will be thrown. + * @param metadata The Metadata to register. + * @since 3.0 + */ + void registerMetadata(JDOMetadata metadata); + + /** + * Method to return a new metadata object that can be subsequently modified + * and registered with the enhancement process using the method {@link #registerMetadata}. + * @return The metadata + * @since 3.0 + */ + JDOMetadata newMetadata(); } diff --git a/api/src/main/java/javax/jdo/JDOException.java b/api/src/main/java/javax/jdo/JDOException.java index 3ea68ec9c..18007f6cb 100644 --- a/api/src/main/java/javax/jdo/JDOException.java +++ b/api/src/main/java/javax/jdo/JDOException.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -24,291 +24,275 @@ import javax.jdo.spi.I18NHelper; -/** - * This is the root of all JDO Exceptions. It contains an optional detail message, an optional - * nested Throwable array and an optional failed object. - * +/** This is the root of all JDO Exceptions. It contains an optional detail + * message, an optional nested Throwable array and an optional failed object. * @author Craig Russell * @version 1.0.2 */ public class JDOException extends java.lang.RuntimeException { - private static final long serialVersionUID = 1950979275859696534L; - - /** - * This exception was generated because of an exception in the runtime library. - * - * @serial the nested Throwable array - */ - Throwable[] nested; - - /** - * This exception may be the result of incorrect parameters supplied to an API. This is the object - * from which the user can determine the cause of the problem. - * - * @serial the failed Object - */ - Object failed; - - /** The Internationalization message helper. */ - private static I18NHelper msg = I18NHelper.getInstance("javax.jdo.Bundle"); // NOI18N - - /** Flag indicating whether printStackTrace is being executed. */ - private boolean inPrintStackTrace = false; - - /** Constructs a new JDOException without a detail message. */ - public JDOException() {} - - /** - * Constructs a new JDOException with the specified detail message. - * - * @param msg the detail message. - */ - public JDOException(String msg) { - super(msg); - } - - /** - * Constructs a new JDOException with the specified detail message and nested - * Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - */ - public JDOException(String msg, Throwable[] nested) { - super(msg); - this.nested = nested; - } - - /** - * Constructs a new JDOException with the specified detail message and nested - * Throwable. - * - * @param msg the detail message. - * @param nested the nested Throwable. - */ - public JDOException(String msg, Throwable nested) { - super(msg); - this.nested = new Throwable[] {nested}; - } - - /** - * Constructs a new JDOException with the specified detail message and failed object. - * - * @param msg the detail message. - * @param failed the failed object. - */ - public JDOException(String msg, Object failed) { - super(msg); - this.failed = failed; - } - - /** - * Constructs a new JDOException with the specified detail message, nested - * Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - * @param failed the failed object. - */ - public JDOException(String msg, Throwable[] nested, Object failed) { - super(msg); - this.nested = nested; - this.failed = failed; - } - - /** - * Constructs a new JDOException with the specified detail message, nested - * Throwable, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable. - * @param failed the failed object. - */ - public JDOException(String msg, Throwable nested, Object failed) { - super(msg); - this.nested = new Throwable[] {nested}; - this.failed = failed; - } + private static final long serialVersionUID = 1950979275859696534L; - /** - * The exception may include a failed object. - * - * @return the failed object. - */ - public Object getFailedObject() { - return failed; - } + /** This exception was generated because of an exception in the runtime library. + * @serial the nested Throwable array + */ + Throwable[] nested; + + /** This exception may be the result of incorrect parameters supplied to an API. + * This is the object from which the user can determine the cause of the problem. + * @serial the failed Object + */ + Object failed; - /** - * The exception may have been caused by multiple exceptions in the runtime. If multiple objects - * caused the problem, each failed object will have its own Exception. - * - * @return the nested Throwable array. - */ - public Throwable[] getNestedExceptions() { - return nested; - } + /** + * The Internationalization message helper. + */ + private static I18NHelper msg = I18NHelper.getInstance ("javax.jdo.Bundle"); //NOI18N - /** - * Often there is only one nested exception, and this method returns it. If there are more than - * one, then this method returns the first nested exception. If there is no nested exception, then - * null is returned. - * - * @return the first or only nested Throwable. - * @since 1.0.1 - */ - public synchronized Throwable getCause() { - // super.printStackTrace calls getCause to handle the cause. - // Returning null prevents the superclass from handling the cause; - // instead the local implementation of printStackTrace should - // handle the cause. Otherwise, the cause is printed twice. - if (nested == null || nested.length == 0 || inPrintStackTrace) { - return null; - } else { - return nested[0]; + /** + * Flag indicating whether printStackTrace is being executed. + */ + private boolean inPrintStackTrace = false; + + /** + * Constructs a new JDOException without a detail message. + */ + public JDOException() { } - } - /** - * JDK 1.4 includes a new chaining mechanism for Throwable, but since JDO has its own "legacy" - * chaining mechanism, the "standard" mechanism cannot be used. This method always throws a - * JDOFatalInternalException. - * - * @param cause ignored. - * @return never. - */ - public Throwable initCause(Throwable cause) { - throw new JDOFatalInternalException(msg.msg("ERR_CannotInitCause")); - } + /** + * Constructs a new JDOException with the specified detail message. + * @param msg the detail message. + */ + public JDOException(String msg) { + super(msg); + } - /** - * The String representation includes the name of the class, the descriptive comment - * (if any), the String representation of the failed Object (if any), - * and the String representation of the nested Throwables (if any). - * - * @return the String. - */ - public synchronized String toString() { - int len = nested == null ? 0 : nested.length; - // calculate approximate size of the String to return - StringBuffer sb = new StringBuffer(10 + 100 * len); - sb.append(super.toString()); - // include failed object information - if (failed != null) { - sb.append("\n").append(msg.msg("MSG_FailedObject")); - String failedToString = null; - try { - failedToString = failed.toString(); - } catch (Exception ex) { - // include the information from the exception thrown by failed.toString - Object objectId = JDOHelper.getObjectId(failed); - if (objectId == null) { - failedToString = - msg.msg( - "MSG_ExceptionGettingFailedToString", // NOI18N - exceptionToString(ex)); + /** Constructs a new JDOException with the specified detail message + * and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable[]. + */ + public JDOException(String msg, Throwable[] nested) { + super(msg); + this.nested = nested; + } + + /** Constructs a new JDOException with the specified detail message + * and nested Throwable. + * @param msg the detail message. + * @param nested the nested Throwable. + */ + public JDOException(String msg, Throwable nested) { + super(msg); + this.nested = new Throwable[] {nested}; + } + + /** Constructs a new JDOException with the specified detail message + * and failed object. + * @param msg the detail message. + * @param failed the failed object. + */ + public JDOException(String msg, Object failed) { + super(msg); + this.failed = failed; + } + + /** Constructs a new JDOException with the specified detail message, + * nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable[]. + * @param failed the failed object. + */ + public JDOException(String msg, Throwable[] nested, Object failed) { + super(msg); + this.nested = nested; + this.failed = failed; + } + + /** Constructs a new JDOException with the specified detail message, + * nested Throwable, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable. + * @param failed the failed object. + */ + public JDOException(String msg, Throwable nested, Object failed) { + super(msg); + this.nested = new Throwable[] {nested}; + this.failed = failed; + } + + /** + * The exception may include a failed object. + * @return the failed object. + */ + public Object getFailedObject() { + return failed; + } + + /** The exception may have been caused by multiple exceptions in the runtime. + * If multiple objects caused the problem, each failed object will have + * its own Exception. + * @return the nested Throwable array. + */ + public Throwable[] getNestedExceptions() { + return nested; + } + + /** Often there is only one nested exception, and this method returns it. + * If there are more than one, then this method returns the first nested + * exception. If there is no nested exception, then null is returned. + * @return the first or only nested Throwable. + * @since 1.0.1 + */ + public synchronized Throwable getCause() { + // super.printStackTrace calls getCause to handle the cause. + // Returning null prevents the superclass from handling the cause; + // instead the local implementation of printStackTrace should + // handle the cause. Otherwise, the cause is printed twice. + if (nested == null || nested.length == 0 || inPrintStackTrace) { + return null; } else { - // include the ObjectId information - String objectIdToString = null; - try { - objectIdToString = objectId.toString(); - } catch (Exception ex2) { - objectIdToString = exceptionToString(ex2); - } - failedToString = - msg.msg( - "MSG_ExceptionGettingFailedToStringObjectId", // NOI18N - exceptionToString(ex), - objectIdToString); + return nested[0]; } - } - sb.append(failedToString); } - // include nested Throwable information, but only if not called by - // printStackTrace; the stacktrace will include the cause anyway. - if (len > 0 && !inPrintStackTrace) { - sb.append("\n").append(msg.msg("MSG_NestedThrowables")).append("\n"); - Throwable exception = nested[0]; - sb.append(exception == null ? "null" : exception.toString()); // NOI18N - for (int i = 1; i < len; ++i) { - sb.append("\n"); // NOI18N - exception = nested[i]; - sb.append(exception == null ? "null" : exception.toString()); // NOI18N - } + + /** JDK 1.4 includes a new chaining mechanism for Throwable, but since + * JDO has its own "legacy" chaining mechanism, the "standard" mechanism + * cannot be used. This method always throws a JDOFatalInternalException. + * @param cause ignored. + * @return never. + */ + public Throwable initCause(Throwable cause) { + throw new JDOFatalInternalException(msg.msg("ERR_CannotInitCause")); + } + + /** The String representation includes the name of the class, + * the descriptive comment (if any), + * the String representation of the failed Object (if any), + * and the String representation of the nested Throwables (if any). + * @return the String. + */ + public synchronized String toString() { + int len = nested==null?0:nested.length; + // calculate approximate size of the String to return + StringBuffer sb = new StringBuffer (10 + 100 * len); + sb.append (super.toString()); + // include failed object information + if (failed != null) { + sb.append ("\n").append (msg.msg ("MSG_FailedObject")); + String failedToString = null; + try { + failedToString = failed.toString(); + } catch (Exception ex) { + // include the information from the exception thrown by failed.toString + Object objectId = JDOHelper.getObjectId(failed); + if (objectId == null) { + failedToString = msg.msg("MSG_ExceptionGettingFailedToString", //NOI18N + exceptionToString(ex)); + } + else { + // include the ObjectId information + String objectIdToString = null; + try { + objectIdToString = objectId.toString(); + } + catch (Exception ex2) { + objectIdToString = exceptionToString(ex2); + } + failedToString = msg.msg("MSG_ExceptionGettingFailedToStringObjectId", //NOI18N + exceptionToString(ex), objectIdToString); + } + } + sb.append (failedToString); + } + // include nested Throwable information, but only if not called by + // printStackTrace; the stacktrace will include the cause anyway. + if (len > 0 && !inPrintStackTrace) { + sb.append ("\n").append (msg.msg ("MSG_NestedThrowables")).append ("\n"); + Throwable exception = nested[0]; + sb.append (exception==null?"null":exception.toString()); //NOI18N + for (int i=1; iJDOException and its backtrace to the + * standard error output. + * Print nested Throwables' stack trace as well. + */ + public void printStackTrace() { + printStackTrace (System.err); } - return sb.toString(); - } - - /** - * Prints this JDOException and its backtrace to the standard error output. Print - * nested Throwables' stack trace as well. - */ - public void printStackTrace() { - printStackTrace(System.err); - } - /** - * Prints this JDOException and its backtrace to the specified print stream. Print - * nested Throwables' stack trace as well. - * - * @param s PrintStream to use for output - */ - public synchronized void printStackTrace(java.io.PrintStream s) { - int len = nested == null ? 0 : nested.length; - synchronized (s) { - inPrintStackTrace = true; - super.printStackTrace(s); - if (len > 0) { - s.println(msg.msg("MSG_NestedThrowablesStackTrace")); - for (int i = 0; i < len; ++i) { - Throwable exception = nested[i]; - if (exception != null) { - exception.printStackTrace(s); - } + /** + * Prints this JDOException and its backtrace to the + * specified print stream. + * Print nested Throwables' stack trace as well. + * @param s PrintStream to use for output + */ + public synchronized void printStackTrace(java.io.PrintStream s) { + int len = nested==null?0:nested.length; + synchronized (s) { + inPrintStackTrace = true; + super.printStackTrace(s); + if (len > 0) { + s.println (msg.msg ("MSG_NestedThrowablesStackTrace")); + for (int i=0; iJDOException and its backtrace to the specified print writer. Print - * nested Throwables' stack trace as well. - * - * @param s PrintWriter to use for output - */ - public synchronized void printStackTrace(java.io.PrintWriter s) { - int len = nested == null ? 0 : nested.length; - synchronized (s) { - inPrintStackTrace = true; - super.printStackTrace(s); - if (len > 0) { - s.println(msg.msg("MSG_NestedThrowablesStackTrace")); - for (int i = 0; i < len; ++i) { - Throwable exception = nested[i]; - if (exception != null) { - exception.printStackTrace(s); - } + /** + * Prints this JDOException and its backtrace to the specified + * print writer. + * Print nested Throwables' stack trace as well. + * @param s PrintWriter to use for output + */ + public synchronized void printStackTrace(java.io.PrintWriter s) { + int len = nested==null?0:nested.length; + synchronized (s) { + inPrintStackTrace = true; + super.printStackTrace(s); + if (len > 0) { + s.println (msg.msg ("MSG_NestedThrowablesStackTrace")); + for (int i=0; iJDOFatalDataStoreException without a detail message. */ - public JDOFatalDataStoreException() {} + private static final long serialVersionUID = 8953679366316248154L; - /** - * Constructs a new JDOFatalDataStoreException with the specified detail message. - * - * @param msg the detail message. - */ - public JDOFatalDataStoreException(String msg) { - super(msg); - } + /** + * Constructs a new JDOFatalDataStoreException without a detail message. + */ + public JDOFatalDataStoreException() { + } - /** - * Constructs a new JDOFatalDataStoreException with the specified detail message and - * failed object. - * - * @param msg the detail message. - * @param failed the failed object. - */ - public JDOFatalDataStoreException(String msg, Object failed) { - super(msg, failed); - } + /** + * Constructs a new JDOFatalDataStoreException with the specified detail message. + * @param msg the detail message. + */ + public JDOFatalDataStoreException(String msg) { + super(msg); + } - /** - * Constructs a new JDOFatalDataStoreException with the specified detail message and - * nested Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - */ - public JDOFatalDataStoreException(String msg, Throwable[] nested) { - super(msg, nested); - } + /** Constructs a new JDOFatalDataStoreException with the specified detail message + * and failed object. + * @param msg the detail message. + * @param failed the failed object. + */ + public JDOFatalDataStoreException(String msg, Object failed) { + super(msg, failed); + } + + /** + * Constructs a new JDOFatalDataStoreException with the specified + * detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable[]. + */ + public JDOFatalDataStoreException(String msg, Throwable[] nested) { + super(msg, nested); + } - /** - * Constructs a new JDOFatalDataStoreException with the specified detail message and - * nested Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable. - */ - public JDOFatalDataStoreException(String msg, Throwable nested) { - super(msg, nested); - } + /** + * Constructs a new JDOFatalDataStoreException with the specified + * detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable. + */ + public JDOFatalDataStoreException(String msg, Throwable nested) { + super(msg, nested); + } + + /** + * Constructs a new JDOFatalDataStoreException with the specified + * detail message, nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable[]. + * @param failed the failed object. + */ + public JDOFatalDataStoreException(String msg, Throwable[] nested, Object failed) { + super(msg, nested, failed); + } - /** - * Constructs a new JDOFatalDataStoreException with the specified detail message, - * nested Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - * @param failed the failed object. - */ - public JDOFatalDataStoreException(String msg, Throwable[] nested, Object failed) { - super(msg, nested, failed); - } - - /** - * Constructs a new JDOFatalDataStoreException with the specified detail message, - * nested Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable. - * @param failed the failed object. - */ - public JDOFatalDataStoreException(String msg, Throwable nested, Object failed) { - super(msg, nested, failed); - } + /** + * Constructs a new JDOFatalDataStoreException with the specified + * detail message, nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable. + * @param failed the failed object. + */ + public JDOFatalDataStoreException(String msg, Throwable nested, Object failed) { + super(msg, nested, failed); + } } + diff --git a/api/src/main/java/javax/jdo/JDOFatalException.java b/api/src/main/java/javax/jdo/JDOFatalException.java index eb39889ed..6247306c5 100644 --- a/api/src/main/java/javax/jdo/JDOFatalException.java +++ b/api/src/main/java/javax/jdo/JDOFatalException.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -22,82 +22,75 @@ package javax.jdo; -/** - * This class represents exceptions that are fatal; that is, the condition that caused it cannot be - * bypassed even if the operation is retried. +/** This class represents exceptions that are fatal; that is, the condition + * that caused it cannot be bypassed even if the operation is retried. * * @version 1.0 */ public class JDOFatalException extends JDOException { - private static final long serialVersionUID = -414371106009364006L; - - /** Constructs a new JDOFatalException without a detail message. */ - public JDOFatalException() {} - - /** - * Constructs a new JDOFatalException with the specified detail message. - * - * @param msg the detail message. - */ - public JDOFatalException(String msg) { - super(msg); - } - - /** - * Constructs a new JDOFatalException with the specified detail message and nested - * Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - */ - public JDOFatalException(String msg, Throwable[] nested) { - super(msg, nested); - } + private static final long serialVersionUID = -414371106009364006L; - /** - * Constructs a new JDOFatalException with the specified detail message and nested - * Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable. - */ - public JDOFatalException(String msg, Throwable nested) { - super(msg, nested); - } + /** + * Constructs a new JDOFatalException without a detail message. + */ + public JDOFatalException() { + } - /** - * Constructs a new JDOFatalException with the specified detail message and failed - * object. - * - * @param msg the detail message. - * @param failed the failed object. - */ - public JDOFatalException(String msg, Object failed) { - super(msg, failed); - } + /** + * Constructs a new JDOFatalException with the specified detail message. + * @param msg the detail message. + */ + public JDOFatalException(String msg) { + super(msg); + } - /** - * Constructs a new JDOFatalException with the specified detail message, nested - * Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - * @param failed the failed object. - */ - public JDOFatalException(String msg, Throwable[] nested, Object failed) { - super(msg, nested, failed); - } + /** + * Constructs a new JDOFatalException with the specified detail + * message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable[]. + */ + public JDOFatalException(String msg, Throwable[] nested) { + super(msg, nested); + } + + /** + * Constructs a new JDOFatalException with the specified detail + * message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable. + */ + public JDOFatalException(String msg, Throwable nested) { + super(msg, nested); + } + + /** Constructs a new JDOFatalException with the specified detail message + * and failed object. + * @param msg the detail message. + * @param failed the failed object. + */ + public JDOFatalException(String msg, Object failed) { + super(msg, failed); + } + + /** Constructs a new JDOFatalException with the specified detail message, + * nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable[]. + * @param failed the failed object. + */ + public JDOFatalException(String msg, Throwable[] nested, Object failed) { + super(msg, nested, failed); + } - /** - * Constructs a new JDOFatalException with the specified detail message, nested - * Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable. - * @param failed the failed object. - */ - public JDOFatalException(String msg, Throwable nested, Object failed) { - super(msg, nested, failed); - } + /** Constructs a new JDOFatalException with the specified detail message, + * nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable. + * @param failed the failed object. + */ + public JDOFatalException(String msg, Throwable nested, Object failed) { + super(msg, nested, failed); + } } diff --git a/api/src/main/java/javax/jdo/JDOFatalInternalException.java b/api/src/main/java/javax/jdo/JDOFatalInternalException.java index b239d6387..5ba042e5b 100644 --- a/api/src/main/java/javax/jdo/JDOFatalInternalException.java +++ b/api/src/main/java/javax/jdo/JDOFatalInternalException.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -22,82 +22,79 @@ package javax.jdo; -/** - * This class represents errors in the implementation for which no user error handling is possible. - * The error should be reported to the JDO vendor for corrective action. +/** This class represents errors in the implementation for which no user + * error handling is possible. The error should be reported to the JDO + * vendor for corrective action. * * @version 1.0 */ public class JDOFatalInternalException extends JDOFatalException { - private static final long serialVersionUID = -2315924677228266735L; + private static final long serialVersionUID = -2315924677228266735L; - /** Constructs a new JDOFatalInternalException without a detail message. */ - public JDOFatalInternalException() {} + /** + * Constructs a new JDOFatalInternalException without a detail message. + */ + public JDOFatalInternalException() { + } - /** - * Constructs a new JDOFatalInternalException with the specified detail message. - * - * @param msg the detail message. - */ - public JDOFatalInternalException(String msg) { - super(msg); - } + /** + * Constructs a new JDOFatalInternalException with the specified detail message. + * @param msg the detail message. + */ + public JDOFatalInternalException(String msg) { + super(msg); + } - /** - * Constructs a new JDOFatalInternalException with the specified detail message and - * nested Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - */ - public JDOFatalInternalException(String msg, Throwable[] nested) { - super(msg, nested); - } + /** + * Constructs a new JDOFatalInternalException with the specified + * detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable[]. + */ + public JDOFatalInternalException(String msg, Throwable[] nested) { + super(msg, nested); + } - /** - * Constructs a new JDOFatalInternalException with the specified detail message and - * nested Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable. - */ - public JDOFatalInternalException(String msg, Throwable nested) { - super(msg, nested); - } + /** + * Constructs a new JDOFatalInternalException with the specified + * detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable. + */ + public JDOFatalInternalException(String msg, Throwable nested) { + super(msg, nested); + } - /** - * Constructs a new JDOFatalInternalException with the specified detail message and - * failed object. - * - * @param msg the detail message. - * @param failed the failed object. - */ - public JDOFatalInternalException(String msg, Object failed) { - super(msg, failed); - } + /** + * Constructs a new JDOFatalInternalException + * with the specified detail message and failed object. + * @param msg the detail message. + * @param failed the failed object. + */ + public JDOFatalInternalException(String msg, Object failed) { + super(msg, failed); + } - /** - * Constructs a new JDOFatalInternalException with the specified detail message, - * nested Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - * @param failed the failed object. - */ - public JDOFatalInternalException(String msg, Throwable[] nested, Object failed) { - super(msg, nested, failed); - } + /** + * Constructs a new JDOFatalInternalException with the specified + * detail message, nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable[]. + * @param failed the failed object. + */ + public JDOFatalInternalException(String msg, Throwable[] nested, Object failed) { + super(msg, nested, failed); + } - /** - * Constructs a new JDOFatalInternalException with the specified detail message, - * nested Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable. - * @param failed the failed object. - */ - public JDOFatalInternalException(String msg, Throwable nested, Object failed) { - super(msg, nested, failed); - } + /** + * Constructs a new JDOFatalInternalException with the specified + * detail message, nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable. + * @param failed the failed object. + */ + public JDOFatalInternalException(String msg, Throwable nested, Object failed) { + super(msg, nested, failed); + } } diff --git a/api/src/main/java/javax/jdo/JDOFatalUserException.java b/api/src/main/java/javax/jdo/JDOFatalUserException.java index f43cfd2cf..8dc1434d7 100644 --- a/api/src/main/java/javax/jdo/JDOFatalUserException.java +++ b/api/src/main/java/javax/jdo/JDOFatalUserException.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -22,81 +22,75 @@ package javax.jdo; -/** - * This class represents user errors that cannot be retried. +/** This class represents user errors that cannot be retried. * * @version 1.0 */ public class JDOFatalUserException extends JDOFatalException { - private static final long serialVersionUID = -7451285498620809419L; - - /** Constructs a new JDOFatalUserException without a detail message. */ - public JDOFatalUserException() {} - - /** - * Constructs a new JDOFatalUserException with the specified detail message. - * - * @param msg the detail message. - */ - public JDOFatalUserException(String msg) { - super(msg); - } + private static final long serialVersionUID = -7451285498620809419L; - /** - * Constructs a new JDOFatalUserException with the specified detail message and - * nested Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - */ - public JDOFatalUserException(String msg, Throwable[] nested) { - super(msg, nested); - } + /** + * Constructs a new JDOFatalUserException without a detail message. + */ + public JDOFatalUserException() { + } - /** - * Constructs a new JDOFatalUserException with the specified detail message and - * nested Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable. - */ - public JDOFatalUserException(String msg, Throwable nested) { - super(msg, nested); - } + /** + * Constructs a new JDOFatalUserException with the specified detail message. + * @param msg the detail message. + */ + public JDOFatalUserException(String msg) { + super(msg); + } - /** - * Constructs a new JDOFatalUserException with the specified detail message and - * failed object. - * - * @param msg the detail message. - * @param failed the failed object. - */ - public JDOFatalUserException(String msg, Object failed) { - super(msg, failed); - } - - /** - * Constructs a new JDOFatalUserException with the specified detail message, nested - * Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - * @param failed the failed object. - */ - public JDOFatalUserException(String msg, Throwable[] nested, Object failed) { - super(msg, nested, failed); - } - - /** - * Constructs a new JDOFatalUserException with the specified detail message, nested - * Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable. - * @param failed the failed object. - */ - public JDOFatalUserException(String msg, Throwable nested, Object failed) { - super(msg, nested, failed); - } + /** + * Constructs a new JDOFatalUserException with the specified + * detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable[]. + */ + public JDOFatalUserException(String msg, Throwable[] nested) { + super(msg, nested); + } + + /** + * Constructs a new JDOFatalUserException with the specified + * detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable. + */ + public JDOFatalUserException(String msg, Throwable nested) { + super(msg, nested); + } + + /** Constructs a new JDOFatalUserException with the specified + * detail message and failed object. + * @param msg the detail message. + * @param failed the failed object. + */ + public JDOFatalUserException(String msg, Object failed) { + super(msg, failed); + } + + /** Constructs a new JDOFatalUserException with the specified + * detail message, nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable[]. + * @param failed the failed object. + */ + public JDOFatalUserException(String msg, Throwable[] nested, Object failed) { + super(msg, nested, failed); + } + + /** Constructs a new JDOFatalUserException with the specified + * detail message, nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable. + * @param failed the failed object. + */ + public JDOFatalUserException(String msg, Throwable nested, Object failed) { + super(msg, nested, failed); + } } + diff --git a/api/src/main/java/javax/jdo/JDOHelper.java b/api/src/main/java/javax/jdo/JDOHelper.java index 0b68680b4..892d46834 100644 --- a/api/src/main/java/javax/jdo/JDOHelper.java +++ b/api/src/main/java/javax/jdo/JDOHelper.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,7 +19,7 @@ * JDOHelper.java * */ - + package javax.jdo; import java.io.BufferedReader; @@ -44,6 +44,7 @@ import java.util.List; import java.util.Map; import java.util.Properties; + import javax.jdo.spi.I18NHelper; import javax.jdo.spi.JDOImplHelper; import javax.jdo.spi.JDOImplHelper.StateInterrogationBooleanReturn; @@ -58,6 +59,7 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; + import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; @@ -67,1614 +69,1806 @@ import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; + /** - * This class can be used by a JDO-aware application to call the JDO behavior of - * PersistenceCapable instances without declaring them to be PersistenceCapable. - * - *

    It is also used to acquire a PersistenceManagerFactory via various methods. - * - *

    This helper class defines static methods that allow a JDO-aware application to examine the - * runtime state of instances. For example, an application can discover whether the instance is - * persistent, transactional, dirty, new, deleted, or detached; and to get its associated - * PersistenceManager if it has one. - * + * This class can be used by a JDO-aware application to call the JDO behavior + * of PersistenceCapable instances without declaring them to be + * PersistenceCapable. + *

    It is also used to acquire a PersistenceManagerFactory via + * various methods. + *

    This helper class defines static methods that allow a JDO-aware + * application to examine the runtime state of instances. For example, + * an application can discover whether the instance is persistent, + * transactional, dirty, new, deleted, or detached; and to get its associated + * PersistenceManager if it has one. + * * @version 2.1 */ public class JDOHelper implements Constants { - /** A mapping from jdoconfig.xsd element attributes to PMF properties. */ - static final Map ATTRIBUTE_PROPERTY_XREF = createAttributePropertyXref(); - - /** The Internationalization message helper. */ - private static final I18NHelper msg = I18NHelper.getInstance("javax.jdo.Bundle"); // NOI18N - - /** - * Creates a map from jdoconfig.xsd element attributes to PMF properties. - * - * @return An unmodifiable Map of jdoconfig.xsd element attributes to PMF properties. - */ - static Map createAttributePropertyXref() { - Map xref = new HashMap(); - - xref.put(PMF_ATTRIBUTE_CLASS, PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS); - xref.put(PMF_ATTRIBUTE_CONNECTION_DRIVER_NAME, PROPERTY_CONNECTION_DRIVER_NAME); - xref.put(PMF_ATTRIBUTE_CONNECTION_FACTORY_NAME, PROPERTY_CONNECTION_FACTORY_NAME); - xref.put(PMF_ATTRIBUTE_CONNECTION_FACTORY2_NAME, PROPERTY_CONNECTION_FACTORY2_NAME); - xref.put(PMF_ATTRIBUTE_CONNECTION_PASSWORD, PROPERTY_CONNECTION_PASSWORD); - xref.put(PMF_ATTRIBUTE_CONNECTION_URL, PROPERTY_CONNECTION_URL); - xref.put(PMF_ATTRIBUTE_CONNECTION_USER_NAME, PROPERTY_CONNECTION_USER_NAME); - xref.put(PMF_ATTRIBUTE_IGNORE_CACHE, PROPERTY_IGNORE_CACHE); - xref.put(PMF_ATTRIBUTE_MAPPING, PROPERTY_MAPPING); - xref.put(PMF_ATTRIBUTE_MULTITHREADED, PROPERTY_MULTITHREADED); - xref.put(PMF_ATTRIBUTE_NONTRANSACTIONAL_READ, PROPERTY_NONTRANSACTIONAL_READ); - xref.put(PMF_ATTRIBUTE_NONTRANSACTIONAL_WRITE, PROPERTY_NONTRANSACTIONAL_WRITE); - xref.put(PMF_ATTRIBUTE_OPTIMISTIC, PROPERTY_OPTIMISTIC); - xref.put(PMF_ATTRIBUTE_PERSISTENCE_UNIT_NAME, PROPERTY_PERSISTENCE_UNIT_NAME); - xref.put(PMF_ATTRIBUTE_NAME, PROPERTY_NAME); - xref.put(PMF_ATTRIBUTE_RESTORE_VALUES, PROPERTY_RESTORE_VALUES); - xref.put(PMF_ATTRIBUTE_RETAIN_VALUES, PROPERTY_RETAIN_VALUES); - xref.put(PMF_ATTRIBUTE_DETACH_ALL_ON_COMMIT, PROPERTY_DETACH_ALL_ON_COMMIT); - xref.put(PMF_ATTRIBUTE_SERVER_TIME_ZONE_ID, PROPERTY_SERVER_TIME_ZONE_ID); - xref.put(PMF_ATTRIBUTE_DATASTORE_READ_TIMEOUT_MILLIS, PROPERTY_DATASTORE_READ_TIMEOUT_MILLIS); - xref.put(PMF_ATTRIBUTE_DATASTORE_WRITE_TIMEOUT_MILLIS, PROPERTY_DATASTORE_WRITE_TIMEOUT_MILLIS); - - return Collections.unmodifiableMap(xref); - } - - /** The JDOImplHelper instance used for handling non-binary-compatible implementations. */ - private static JDOImplHelper implHelper = - (JDOImplHelper) - doPrivileged( - new PrivilegedAction() { - public JDOImplHelper run() { - return JDOImplHelper.getInstance(); + /** + * A mapping from jdoconfig.xsd element attributes to PMF properties. + */ + static final Map ATTRIBUTE_PROPERTY_XREF + = createAttributePropertyXref(); + + /** The Internationalization message helper. + */ + private final static I18NHelper msg = + I18NHelper.getInstance ("javax.jdo.Bundle"); //NOI18N + + /** + * Creates a map from jdoconfig.xsd element attributes to PMF properties. + * @return An unmodifiable Map of jdoconfig.xsd element attributes to PMF + * properties. + */ + static Map createAttributePropertyXref() { + Map xref = new HashMap(); + + xref.put( + PMF_ATTRIBUTE_CLASS, + PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS); + xref.put( + PMF_ATTRIBUTE_CONNECTION_DRIVER_NAME, + PROPERTY_CONNECTION_DRIVER_NAME); + xref.put( + PMF_ATTRIBUTE_CONNECTION_FACTORY_NAME, + PROPERTY_CONNECTION_FACTORY_NAME); + xref.put( + PMF_ATTRIBUTE_CONNECTION_FACTORY2_NAME, + PROPERTY_CONNECTION_FACTORY2_NAME); + xref.put( + PMF_ATTRIBUTE_CONNECTION_PASSWORD, + PROPERTY_CONNECTION_PASSWORD); + xref.put( + PMF_ATTRIBUTE_CONNECTION_URL, + PROPERTY_CONNECTION_URL); + xref.put( + PMF_ATTRIBUTE_CONNECTION_USER_NAME, + PROPERTY_CONNECTION_USER_NAME); + xref.put( + PMF_ATTRIBUTE_IGNORE_CACHE, + PROPERTY_IGNORE_CACHE); + xref.put( + PMF_ATTRIBUTE_MAPPING, + PROPERTY_MAPPING); + xref.put( + PMF_ATTRIBUTE_MULTITHREADED, + PROPERTY_MULTITHREADED); + xref.put( + PMF_ATTRIBUTE_NONTRANSACTIONAL_READ, + PROPERTY_NONTRANSACTIONAL_READ); + xref.put( + PMF_ATTRIBUTE_NONTRANSACTIONAL_WRITE, + PROPERTY_NONTRANSACTIONAL_WRITE); + xref.put( + PMF_ATTRIBUTE_OPTIMISTIC, + PROPERTY_OPTIMISTIC); + xref.put( + PMF_ATTRIBUTE_PERSISTENCE_UNIT_NAME, + PROPERTY_PERSISTENCE_UNIT_NAME); + xref.put( + PMF_ATTRIBUTE_NAME, + PROPERTY_NAME); + xref.put( + PMF_ATTRIBUTE_RESTORE_VALUES, + PROPERTY_RESTORE_VALUES); + xref.put( + PMF_ATTRIBUTE_RETAIN_VALUES, + PROPERTY_RETAIN_VALUES); + xref.put( + PMF_ATTRIBUTE_DETACH_ALL_ON_COMMIT, + PROPERTY_DETACH_ALL_ON_COMMIT); + xref.put( + PMF_ATTRIBUTE_SERVER_TIME_ZONE_ID, + PROPERTY_SERVER_TIME_ZONE_ID); + xref.put( + PMF_ATTRIBUTE_DATASTORE_READ_TIMEOUT_MILLIS, + PROPERTY_DATASTORE_READ_TIMEOUT_MILLIS); + xref.put( + PMF_ATTRIBUTE_DATASTORE_WRITE_TIMEOUT_MILLIS, + PROPERTY_DATASTORE_WRITE_TIMEOUT_MILLIS); + + return Collections.unmodifiableMap(xref); + } + + /** The JDOImplHelper instance used for handling non-binary-compatible + * implementations. + */ + private static JDOImplHelper implHelper = (JDOImplHelper) + doPrivileged( + new PrivilegedAction () { + public JDOImplHelper run () { + return JDOImplHelper.getInstance(); } - }); - - /** - * The singleton instance of JDOHelper. - * - * @since 2.1 - */ - private static JDOHelper instance = new JDOHelper(); - - /** - * Return the singleton instance of JDOHelper. This instance is thread-safe. - * - * @since 2.1 - * @return the thread-safe singleton JDOHelper - */ - public static JDOHelper getInstance() { - return instance; - } - - /** - * Some applications might prefer to use instance methods instead of static methods. - * - * @since 2.1 - */ - public JDOHelper() {} - - /** - * The stateless instance used for handling non-binary-compatible implementations of - * getPersistenceManager. - */ - static StateInterrogationObjectReturn getPersistenceManager = - new StateInterrogationObjectReturn() { - public Object get(Object pc, StateInterrogation si) { - return si.getPersistenceManager(pc); - } - }; - - /** - * The stateless instance used for handling non-binary-compatible implementations of getObjectId. - */ - static StateInterrogationObjectReturn getObjectId = - new StateInterrogationObjectReturn() { - public Object get(Object pc, StateInterrogation si) { - return si.getObjectId(pc); - } - }; - - /** - * The stateless instance used for handling non-binary-compatible implementations of - * getTransactionalObjectId. - */ - static StateInterrogationObjectReturn getTransactionalObjectId = - new StateInterrogationObjectReturn() { - public Object get(Object pc, StateInterrogation si) { - return si.getTransactionalObjectId(pc); - } - }; - - /** - * The stateless instance used for handling non-binary-compatible implementations of getVersion. - */ - static StateInterrogationObjectReturn getVersion = - new StateInterrogationObjectReturn() { - public Object get(Object pc, StateInterrogation si) { - return si.getVersion(pc); + } + ); + + /** The singleton instance of JDOHelper. + * @since 2.1 + */ + private static JDOHelper instance = new JDOHelper(); + + /** + * Return the singleton instance of JDOHelper. This instance is + * thread-safe. + * @since 2.1 + * @return the thread-safe singleton JDOHelper + */ + public static JDOHelper getInstance() { + return instance; + } + + /** Some applications might prefer to use instance + * methods instead of static methods. + * @since 2.1 + */ + public JDOHelper() {} + + /** The stateless instance used for handling non-binary-compatible + * implementations of getPersistenceManager. + */ + static StateInterrogationObjectReturn getPersistenceManager = + new StateInterrogationObjectReturn() { + public Object get(Object pc, StateInterrogation si) { + return si.getPersistenceManager(pc); + } + }; + + /** The stateless instance used for handling non-binary-compatible + * implementations of getObjectId. + */ + static StateInterrogationObjectReturn getObjectId = + new StateInterrogationObjectReturn() { + public Object get(Object pc, StateInterrogation si) { + return si.getObjectId(pc); + } + }; + + /** The stateless instance used for handling non-binary-compatible + * implementations of getTransactionalObjectId. + */ + static StateInterrogationObjectReturn getTransactionalObjectId = + new StateInterrogationObjectReturn() { + public Object get(Object pc, StateInterrogation si) { + return si.getTransactionalObjectId(pc); + } + }; + + /** The stateless instance used for handling non-binary-compatible + * implementations of getVersion. + */ + static StateInterrogationObjectReturn getVersion = + new StateInterrogationObjectReturn() { + public Object get(Object pc, StateInterrogation si) { + return si.getVersion(pc); + } + }; + + /** The stateless instance used for handling non-binary-compatible + * implementations of isPersistent. + */ + static StateInterrogationBooleanReturn isPersistent = + new StateInterrogationBooleanReturn() { + public Boolean is(Object pc, StateInterrogation si) { + return si.isPersistent(pc); + } + }; + + /** The stateless instance used for handling non-binary-compatible + * implementations of isTransactional. + */ + static StateInterrogationBooleanReturn isTransactional = + new StateInterrogationBooleanReturn() { + public Boolean is(Object pc, StateInterrogation si) { + return si.isTransactional(pc); + } + }; + + /** The stateless instance used for handling non-binary-compatible + * implementations of isDirty. + */ + static StateInterrogationBooleanReturn isDirty = + new StateInterrogationBooleanReturn() { + public Boolean is(Object pc, StateInterrogation si) { + return si.isDirty(pc); + } + }; + + /** The stateless instance used for handling non-binary-compatible + * implementations of isNew. + */ + static StateInterrogationBooleanReturn isNew = + new StateInterrogationBooleanReturn() { + public Boolean is(Object pc, StateInterrogation si) { + return si.isNew(pc); + } + }; + + /** The stateless instance used for handling non-binary-compatible + * implementations of isDeleted. + */ + static StateInterrogationBooleanReturn isDeleted = + new StateInterrogationBooleanReturn() { + public Boolean is(Object pc, StateInterrogation si) { + return si.isDeleted(pc); + } + }; + + /** The stateless instance used for handling non-binary-compatible + * implementations of isDetached. + */ + static StateInterrogationBooleanReturn isDetached = + new StateInterrogationBooleanReturn() { + public Boolean is(Object pc, StateInterrogation si) { + return si.isDetached(pc); + } + }; + + /** Return the associated PersistenceManager if there is one. + * Transactional and persistent instances return the associated + * PersistenceManager. + * + *

    Transient non-transactional instances and instances of classes + * that do not implement PersistenceCapable return + * null. + * @see PersistenceCapable#jdoGetPersistenceManager() + * @param pc the PersistenceCapable instance. + * @return the PersistenceManager associated with the parameter + * instance. + */ + public static PersistenceManager getPersistenceManager(Object pc) { + if (pc instanceof PersistenceCapable) { + return ((PersistenceCapable)pc).jdoGetPersistenceManager(); + } else { + return (PersistenceManager) + implHelper.nonBinaryCompatibleGet(pc, getPersistenceManager); } - }; - - /** - * The stateless instance used for handling non-binary-compatible implementations of isPersistent. - */ - static StateInterrogationBooleanReturn isPersistent = - new StateInterrogationBooleanReturn() { - public Boolean is(Object pc, StateInterrogation si) { - return si.isPersistent(pc); + } + + /** Explicitly mark the parameter instance and field dirty. + * Normally, PersistenceCapable classes are able to detect + * changes made to their fields. However, if a reference to an array is + * given to a method outside the class, and the array is modified, then the + * persistent instance is not aware of the change. This API allows the + * application to notify the instance that a change was made to a field. + * + *

    Transient instances and instances of classes + * that do not implement PersistenceCapable ignore this method. + * @see PersistenceCapable#jdoMakeDirty(String fieldName) + * @param pc the PersistenceCapable instance. + * @param fieldName the name of the field to be marked dirty. + */ + public static void makeDirty(Object pc, String fieldName) { + if (pc instanceof PersistenceCapable) { + ((PersistenceCapable)pc).jdoMakeDirty(fieldName); + } else { + implHelper.nonBinaryCompatibleMakeDirty(pc, fieldName); } - }; - - /** - * The stateless instance used for handling non-binary-compatible implementations of - * isTransactional. - */ - static StateInterrogationBooleanReturn isTransactional = - new StateInterrogationBooleanReturn() { - public Boolean is(Object pc, StateInterrogation si) { - return si.isTransactional(pc); + } + + /** Return a copy of the JDO identity associated with the parameter + * instance. + * + *

    Persistent instances of PersistenceCapable classes have a + * JDO identity managed by the PersistenceManager. This method + * returns a copy of the ObjectId that represents the JDO identity. + * + *

    Transient instances and instances of classes that do not implement + * PersistenceCapable return null. + * + *

    The ObjectId may be serialized + * and later restored, and used with a PersistenceManager from + * the same JDO implementation to locate a persistent instance with the same + * data store identity. + * + *

    If the JDO identity is managed by the application, then the ObjectId + * may be used with a PersistenceManager from any JDO + * implementation that supports the PersistenceCapable class. + * + *

    If the JDO identity is not managed by the application or the data + * store, then the ObjectId returned is only valid within the current + * transaction. + *

    + * @see PersistenceManager#getObjectId(Object pc) + * @see PersistenceCapable#jdoGetObjectId() + * @see PersistenceManager#getObjectById(Object oid, boolean validate) + * @param pc the PersistenceCapable instance. + * @return a copy of the ObjectId of the parameter instance as of the + * beginning of the transaction. + */ + public static Object getObjectId(Object pc) { + if (pc instanceof PersistenceCapable) { + return ((PersistenceCapable)pc).jdoGetObjectId(); + } else { + return implHelper.nonBinaryCompatibleGet(pc, getObjectId); } - }; + } - /** The stateless instance used for handling non-binary-compatible implementations of isDirty. */ - static StateInterrogationBooleanReturn isDirty = - new StateInterrogationBooleanReturn() { - public Boolean is(Object pc, StateInterrogation si) { - return si.isDirty(pc); + /** Get object ids for a collection of instances. For each instance + * in the parameter, the getObjectId method is called. This method + * returns one identity instance for each element + * in the parameter. The order of iteration of the returned + * Collection exactly matches the order of iteration of the + * parameter Collection. + * @param pcs the persistence-capable instances + * @return the object ids of the parameters + * @see #getObjectId(Object pc) + * @see #getObjectIds(Object[] pcs) + * @since 2.0 + */ + public static Collection getObjectIds(Collection pcs) { + ArrayList result = new ArrayList(); + for (Iterator it = pcs.iterator(); it.hasNext();) { + result.add(getObjectId(it.next())); } - }; + return result; + } - /** The stateless instance used for handling non-binary-compatible implementations of isNew. */ - static StateInterrogationBooleanReturn isNew = - new StateInterrogationBooleanReturn() { - public Boolean is(Object pc, StateInterrogation si) { - return si.isNew(pc); - } - }; - - /** - * The stateless instance used for handling non-binary-compatible implementations of isDeleted. - */ - static StateInterrogationBooleanReturn isDeleted = - new StateInterrogationBooleanReturn() { - public Boolean is(Object pc, StateInterrogation si) { - return si.isDeleted(pc); - } - }; - - /** - * The stateless instance used for handling non-binary-compatible implementations of isDetached. - */ - static StateInterrogationBooleanReturn isDetached = - new StateInterrogationBooleanReturn() { - public Boolean is(Object pc, StateInterrogation si) { - return si.isDetached(pc); + /** Get object ids for an array of instances. For each instance + * in the parameter, the getObjectId method is called. This method + * returns one identity instance for each element + * in the parameter. The order of instances of the returned + * array exactly matches the order of instances of the + * parameter array. + * @param pcs the persistence-capable instances + * @return the object ids of the parameters + * @see #getObjectId(Object pc) + * @see #getObjectIds(Collection pcs) + * @since 2.0 + */ + public static Object[] getObjectIds(Object[] pcs) { + Object[] result = new Object[pcs.length]; + for (int i = 0; i < pcs.length; ++i) { + result[i] = getObjectId(pcs[i]); } - }; - - /** - * Return the associated PersistenceManager if there is one. Transactional and - * persistent instances return the associated PersistenceManager. - * - *

    Transient non-transactional instances and instances of classes that do not implement - * PersistenceCapable return null. - * - * @see PersistenceCapable#jdoGetPersistenceManager() - * @param pc the PersistenceCapable instance. - * @return the PersistenceManager associated with the parameter instance. - */ - public static PersistenceManager getPersistenceManager(Object pc) { - if (pc instanceof PersistenceCapable) { - return ((PersistenceCapable) pc).jdoGetPersistenceManager(); - } else { - return (PersistenceManager) implHelper.nonBinaryCompatibleGet(pc, getPersistenceManager); + return result; } - } - - /** - * Explicitly mark the parameter instance and field dirty. Normally, PersistenceCapable - * classes are able to detect changes made to their fields. However, if a reference to an - * array is given to a method outside the class, and the array is modified, then the persistent - * instance is not aware of the change. This API allows the application to notify the instance - * that a change was made to a field. - * - *

    Transient instances and instances of classes that do not implement PersistenceCapable - * ignore this method. - * - * @see PersistenceCapable#jdoMakeDirty(String fieldName) - * @param pc the PersistenceCapable instance. - * @param fieldName the name of the field to be marked dirty. - */ - public static void makeDirty(Object pc, String fieldName) { - if (pc instanceof PersistenceCapable) { - ((PersistenceCapable) pc).jdoMakeDirty(fieldName); - } else { - implHelper.nonBinaryCompatibleMakeDirty(pc, fieldName); + + /** Return a copy of the JDO identity associated with the parameter + * instance. + * + * @see PersistenceCapable#jdoGetTransactionalObjectId() + * @see PersistenceManager#getObjectById(Object oid, boolean validate) + * @param pc the PersistenceCapable instance. + * @return a copy of the ObjectId of the parameter instance as modified in + * this transaction. + */ + public static Object getTransactionalObjectId(Object pc) { + if (pc instanceof PersistenceCapable) { + return ((PersistenceCapable)pc).jdoGetTransactionalObjectId(); + } else { + return implHelper.nonBinaryCompatibleGet( + pc, getTransactionalObjectId); + } } - } - - /** - * Return a copy of the JDO identity associated with the parameter instance. - * - *

    Persistent instances of PersistenceCapable classes have a JDO identity managed - * by the PersistenceManager. This method returns a copy of the ObjectId that - * represents the JDO identity. - * - *

    Transient instances and instances of classes that do not implement PersistenceCapable - * return null. - * - *

    The ObjectId may be serialized and later restored, and used with a PersistenceManager - * from the same JDO implementation to locate a persistent instance with the same data - * store identity. - * - *

    If the JDO identity is managed by the application, then the ObjectId may be used with a - * PersistenceManager from any JDO implementation that supports the - * PersistenceCapable class. - * - *

    If the JDO identity is not managed by the application or the data store, then the ObjectId - * returned is only valid within the current transaction. - * - *

    - * - * @see PersistenceManager#getObjectId(Object pc) - * @see PersistenceCapable#jdoGetObjectId() - * @see PersistenceManager#getObjectById(Object oid, boolean validate) - * @param pc the PersistenceCapable instance. - * @return a copy of the ObjectId of the parameter instance as of the beginning of the - * transaction. - */ - public static Object getObjectId(Object pc) { - if (pc instanceof PersistenceCapable) { - return ((PersistenceCapable) pc).jdoGetObjectId(); - } else { - return implHelper.nonBinaryCompatibleGet(pc, getObjectId); + + /** + * Return the version of the instance. + * @since 2.0 + * @param pc the instance + * @return the version of the instance + */ + public static Object getVersion (Object pc) { + if (pc instanceof PersistenceCapable) { + return ((PersistenceCapable)pc).jdoGetVersion(); + } else { + return implHelper.nonBinaryCompatibleGet(pc, getVersion); + } } - } - - /** - * Get object ids for a collection of instances. For each instance in the parameter, the - * getObjectId method is called. This method returns one identity instance for each element in the - * parameter. The order of iteration of the returned Collection exactly matches the order of - * iteration of the parameter Collection. - * - * @param pcs the persistence-capable instances - * @return the object ids of the parameters - * @see #getObjectId(Object pc) - * @see #getObjectIds(Object[] pcs) - * @since 2.0 - */ - public static Collection getObjectIds(Collection pcs) { - ArrayList result = new ArrayList(); - for (Iterator it = pcs.iterator(); it.hasNext(); ) { - result.add(getObjectId(it.next())); + /** Tests whether the parameter instance is dirty. + * + * Instances that have been modified, deleted, or newly + * made persistent in the current transaction return true. + * + *

    Transient instances and instances of classes that do not implement + * PersistenceCapable return false. + *

    + * @see javax.jdo.spi.StateManager#makeDirty(PersistenceCapable pc, + * String fieldName) + * @see PersistenceCapable#jdoIsDirty() + * @param pc the PersistenceCapable instance. + * @return true if the parameter instance has been modified in + * the current transaction. + */ + public static boolean isDirty(Object pc) { + if (pc instanceof PersistenceCapable) { + return ((PersistenceCapable)pc).jdoIsDirty(); + } else { + return implHelper.nonBinaryCompatibleIs(pc, isDirty); + } } - return result; - } - - /** - * Get object ids for an array of instances. For each instance in the parameter, the getObjectId - * method is called. This method returns one identity instance for each element in the parameter. - * The order of instances of the returned array exactly matches the order of instances of the - * parameter array. - * - * @param pcs the persistence-capable instances - * @return the object ids of the parameters - * @see #getObjectId(Object pc) - * @see #getObjectIds(Collection pcs) - * @since 2.0 - */ - public static Object[] getObjectIds(Object[] pcs) { - Object[] result = new Object[pcs.length]; - for (int i = 0; i < pcs.length; ++i) { - result[i] = getObjectId(pcs[i]); + + /** Tests whether the parameter instance is transactional. + * + * Instances whose state is associated with the current transaction + * return true. + * + *

    Transient instances and instances of classes that do not implement + * PersistenceCapable return false. + * @see PersistenceCapable#jdoIsTransactional() + * @param pc the PersistenceCapable instance. + * @return true if the parameter instance is transactional. + */ + public static boolean isTransactional(Object pc) { + if (pc instanceof PersistenceCapable) { + return ((PersistenceCapable)pc).jdoIsTransactional(); + } else { + return implHelper.nonBinaryCompatibleIs(pc, isTransactional); + } } - return result; - } - - /** - * Return a copy of the JDO identity associated with the parameter instance. - * - * @see PersistenceCapable#jdoGetTransactionalObjectId() - * @see PersistenceManager#getObjectById(Object oid, boolean validate) - * @param pc the PersistenceCapable instance. - * @return a copy of the ObjectId of the parameter instance as modified in this transaction. - */ - public static Object getTransactionalObjectId(Object pc) { - if (pc instanceof PersistenceCapable) { - return ((PersistenceCapable) pc).jdoGetTransactionalObjectId(); - } else { - return implHelper.nonBinaryCompatibleGet(pc, getTransactionalObjectId); + + /** Tests whether the parameter instance is persistent. + * + * Instances that represent persistent objects in the data store + * return true. + * + *

    Transient instances and instances of classes that do not implement + * PersistenceCapable return false. + *

    + * @see PersistenceManager#makePersistent(Object pc) + * @see PersistenceCapable#jdoIsPersistent() + * @param pc the PersistenceCapable instance. + * @return true if the parameter instance is persistent. + */ + public static boolean isPersistent(Object pc) { + if (pc instanceof PersistenceCapable) { + return ((PersistenceCapable)pc).jdoIsPersistent(); + } else { + return implHelper.nonBinaryCompatibleIs(pc, isPersistent); + } } - } - - /** - * Return the version of the instance. - * - * @since 2.0 - * @param pc the instance - * @return the version of the instance - */ - public static Object getVersion(Object pc) { - if (pc instanceof PersistenceCapable) { - return ((PersistenceCapable) pc).jdoGetVersion(); - } else { - return implHelper.nonBinaryCompatibleGet(pc, getVersion); + + /** Tests whether the parameter instance has been newly made persistent. + * + * Instances that have been made persistent in the current transaction + * return true. + * + *

    Transient instances and instances of classes that do not implement + * PersistenceCapable return false. + *

    + * @see PersistenceManager#makePersistent(Object pc) + * @see PersistenceCapable#jdoIsNew() + * @param pc the PersistenceCapable instance. + * @return true if the parameter instance was made persistent + * in the current transaction. + */ + public static boolean isNew(Object pc) { + if (pc instanceof PersistenceCapable) { + return ((PersistenceCapable)pc).jdoIsNew(); + } else { + return implHelper.nonBinaryCompatibleIs(pc, isNew); + } } - } - /** - * Tests whether the parameter instance is dirty. - * - *

    Instances that have been modified, deleted, or newly made persistent in the current - * transaction return true. - * - *

    Transient instances and instances of classes that do not implement PersistenceCapable - * return false. - * - *

    - * - * @see javax.jdo.spi.StateManager#makeDirty(PersistenceCapable pc, String fieldName) - * @see PersistenceCapable#jdoIsDirty() - * @param pc the PersistenceCapable instance. - * @return true if the parameter instance has been modified in the current - * transaction. - */ - public static boolean isDirty(Object pc) { - if (pc instanceof PersistenceCapable) { - return ((PersistenceCapable) pc).jdoIsDirty(); - } else { - return implHelper.nonBinaryCompatibleIs(pc, isDirty); + + /** Tests whether the parameter instance has been deleted. + * + * Instances that have been deleted in the current transaction return + * true. + * + *

    Transient instances and instances of classes that do not implement + * PersistenceCapable return false. + *

    + * @see PersistenceManager#deletePersistent(Object pc) + * @see PersistenceCapable#jdoIsDeleted() + * @param pc the PersistenceCapable instance. + * @return true if the parameter instance was deleted + * in the current transaction. + */ + public static boolean isDeleted(Object pc) { + if (pc instanceof PersistenceCapable) { + return ((PersistenceCapable)pc).jdoIsDeleted(); + } else { + return implHelper.nonBinaryCompatibleIs(pc, isDeleted); + } } - } - - /** - * Tests whether the parameter instance is transactional. - * - *

    Instances whose state is associated with the current transaction return true. - * - *

    Transient instances and instances of classes that do not implement PersistenceCapable - * return false. - * - * @see PersistenceCapable#jdoIsTransactional() - * @param pc the PersistenceCapable instance. - * @return true if the parameter instance is transactional. - */ - public static boolean isTransactional(Object pc) { - if (pc instanceof PersistenceCapable) { - return ((PersistenceCapable) pc).jdoIsTransactional(); - } else { - return implHelper.nonBinaryCompatibleIs(pc, isTransactional); + + /** + * Tests whether the parameter instance has been detached. + * + * Instances that have been detached return true. + * + *

    Transient instances return false. + *

    + * @see PersistenceCapable#jdoIsDetached() + * @return true if this instance is detached. + * @since 2.0 + * @param pc the instance + */ + public static boolean isDetached(Object pc) { + if (pc instanceof PersistenceCapable) { + return ((PersistenceCapable)pc).jdoIsDetached(); + } else { + return implHelper.nonBinaryCompatibleIs(pc, isDetached); + } } - } - - /** - * Tests whether the parameter instance is persistent. - * - *

    Instances that represent persistent objects in the data store return true. - * - *

    Transient instances and instances of classes that do not implement PersistenceCapable - * return false. - * - *

    - * - * @see PersistenceManager#makePersistent(Object pc) - * @see PersistenceCapable#jdoIsPersistent() - * @param pc the PersistenceCapable instance. - * @return true if the parameter instance is persistent. - */ - public static boolean isPersistent(Object pc) { - if (pc instanceof PersistenceCapable) { - return ((PersistenceCapable) pc).jdoIsPersistent(); - } else { - return implHelper.nonBinaryCompatibleIs(pc, isPersistent); + + /** Accessor for the state of the passed object. + * @param pc The object + * @return The object state + * @since 2.1 + */ + public static ObjectState getObjectState(Object pc) { + if (pc == null) { + return null; + } + + if (isDetached(pc)) { + if (isDirty(pc)) { + // Detached Dirty + return ObjectState.DETACHED_DIRTY; + } + else { + // Detached Not Dirty + return ObjectState.DETACHED_CLEAN; + } + } + else { + if (isPersistent(pc)) { + if (isTransactional(pc)) { + if (isDirty(pc)) { + if (isNew(pc)) { + if (isDeleted(pc)) { + // Persistent Transactional Dirty New Deleted + return ObjectState.PERSISTENT_NEW_DELETED; + } else { + // Persistent Transactional Dirty New Not Deleted + return ObjectState.PERSISTENT_NEW; + } + } else { + if (isDeleted(pc)) { + // Persistent Transactional Dirty Not New Deleted + return ObjectState.PERSISTENT_DELETED; + } else { + // Persistent Transactional Dirty Not New Not Deleted + return ObjectState.PERSISTENT_DIRTY; + } + } + } else { + // Persistent Transactional Not Dirty + return ObjectState.PERSISTENT_CLEAN; + } + } + else { + if (isDirty(pc)) { + // Persistent Nontransactional Dirty + return ObjectState.PERSISTENT_NONTRANSACTIONAL_DIRTY; + } + else { + // Persistent Nontransactional Not Dirty + return ObjectState.HOLLOW_PERSISTENT_NONTRANSACTIONAL; + } + } + } + else { + if (isTransactional(pc)) { + if (isDirty(pc)) { + // Not Persistent Transactional Dirty + return ObjectState.TRANSIENT_DIRTY; + } else { + // Not Persistent Transactional Not Dirty + return ObjectState.TRANSIENT_CLEAN; + } + } + else { + // Not Persistent Not Transactional + return ObjectState.TRANSIENT; + } + } + } } - } - - /** - * Tests whether the parameter instance has been newly made persistent. - * - *

    Instances that have been made persistent in the current transaction return true - * . - * - *

    Transient instances and instances of classes that do not implement PersistenceCapable - * return false. - * - *

    - * - * @see PersistenceManager#makePersistent(Object pc) - * @see PersistenceCapable#jdoIsNew() - * @param pc the PersistenceCapable instance. - * @return true if the parameter instance was made persistent in the current - * transaction. - */ - public static boolean isNew(Object pc) { - if (pc instanceof PersistenceCapable) { - return ((PersistenceCapable) pc).jdoIsNew(); - } else { - return implHelper.nonBinaryCompatibleIs(pc, isNew); + + /** Get the anonymous PersistenceManagerFactory configured via + * the standard configuration file resource "META-INF/jdoconfig.xml", using + * the current thread's context class loader + * to locate the configuration file resource(s). + * @return the anonymous PersistenceManagerFactory. + * @since 2.1 + * @see #getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader) + */ + public static PersistenceManagerFactory getPersistenceManagerFactory() { + ClassLoader cl = getContextClassLoader(); + return getPersistenceManagerFactory( + null, ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, cl, cl); } - } - - /** - * Tests whether the parameter instance has been deleted. - * - *

    Instances that have been deleted in the current transaction return true. - * - *

    Transient instances and instances of classes that do not implement PersistenceCapable - * return false. - * - *

    - * - * @see PersistenceManager#deletePersistent(Object pc) - * @see PersistenceCapable#jdoIsDeleted() - * @param pc the PersistenceCapable instance. - * @return true if the parameter instance was deleted in the current transaction. - */ - public static boolean isDeleted(Object pc) { - if (pc instanceof PersistenceCapable) { - return ((PersistenceCapable) pc).jdoIsDeleted(); - } else { - return implHelper.nonBinaryCompatibleIs(pc, isDeleted); + + /** Get the anonymous PersistenceManagerFactory configured via + * the standard configuration file resource "META-INF/jdoconfig.xml", using + * the given class loader. + * @return the anonymous PersistenceManagerFactory. + * @param pmfClassLoader the ClassLoader used to load resources and classes + * @since 2.1 + * @see #getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader) + */ + public static PersistenceManagerFactory getPersistenceManagerFactory( + ClassLoader pmfClassLoader) { + return getPersistenceManagerFactory( + null, + ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, + pmfClassLoader, pmfClassLoader); } - } - - /** - * Tests whether the parameter instance has been detached. - * - *

    Instances that have been detached return true. - * - *

    Transient instances return false. - * - *

    - * - * @see PersistenceCapable#jdoIsDetached() - * @return true if this instance is detached. - * @since 2.0 - * @param pc the instance - */ - public static boolean isDetached(Object pc) { - if (pc instanceof PersistenceCapable) { - return ((PersistenceCapable) pc).jdoIsDetached(); - } else { - return implHelper.nonBinaryCompatibleIs(pc, isDetached); + + /** Get a PersistenceManagerFactory based on a Properties + * instance, using the current thread's context class loader to locate the + * PersistenceManagerFactory class. + * @return the PersistenceManagerFactory. + * @param props a Properties instance with properties of the + * PersistenceManagerFactory. + * @see #getPersistenceManagerFactory(java.util.Map,ClassLoader) + */ + public static PersistenceManagerFactory getPersistenceManagerFactory + (Map props) { + return getPersistenceManagerFactory( + null, props, getContextClassLoader()); } - } - - /** - * Accessor for the state of the passed object. - * - * @param pc The object - * @return The object state - * @since 2.1 - */ - public static ObjectState getObjectState(Object pc) { - if (pc == null) { - return null; + + + /** Get a PersistenceManagerFactory based on a + * Map and a class loader. + * This method delegates to the getPersistenceManagerFactory + * method that takes a Map of overrides and a Map of properties, + * passing null as the overrides parameter. + * @see #getPersistenceManagerFactory(java.util.Map, java.util.Map, ClassLoader) + * @return the PersistenceManagerFactory. + * @param props a Map with properties of the + * PersistenceManagerFactory. + * @param pmfClassLoader the class loader used to load the + * PersistenceManagerFactory class + * @since 1.0 + */ + public static PersistenceManagerFactory getPersistenceManagerFactory + (Map props, ClassLoader pmfClassLoader) { + return getPersistenceManagerFactory( + null, props, pmfClassLoader); } - if (isDetached(pc)) { - if (isDirty(pc)) { - // Detached Dirty - return ObjectState.DETACHED_DIRTY; - } else { - // Detached Not Dirty - return ObjectState.DETACHED_CLEAN; - } - } else { - if (isPersistent(pc)) { - if (isTransactional(pc)) { - if (isDirty(pc)) { - if (isNew(pc)) { - if (isDeleted(pc)) { - // Persistent Transactional Dirty New Deleted - return ObjectState.PERSISTENT_NEW_DELETED; - } else { - // Persistent Transactional Dirty New Not Deleted - return ObjectState.PERSISTENT_NEW; - } - } else { - if (isDeleted(pc)) { - // Persistent Transactional Dirty Not New Deleted - return ObjectState.PERSISTENT_DELETED; - } else { - // Persistent Transactional Dirty Not New Not Deleted - return ObjectState.PERSISTENT_DIRTY; - } - } - } else { - // Persistent Transactional Not Dirty - return ObjectState.PERSISTENT_CLEAN; - } - } else { - if (isDirty(pc)) { - // Persistent Nontransactional Dirty - return ObjectState.PERSISTENT_NONTRANSACTIONAL_DIRTY; - } else { - // Persistent Nontransactional Not Dirty - return ObjectState.HOLLOW_PERSISTENT_NONTRANSACTIONAL; - } - } - } else { - if (isTransactional(pc)) { - if (isDirty(pc)) { - // Not Persistent Transactional Dirty - return ObjectState.TRANSIENT_DIRTY; - } else { - // Not Persistent Transactional Not Dirty - return ObjectState.TRANSIENT_CLEAN; - } + /** + * Get a PersistenceManagerFactory based on a + * Map of overrides, a Map of + * properties, and a class loader. + * The following are standard key names: + *
    "javax.jdo.PersistenceManagerFactoryClass" + *
    "javax.jdo.option.Optimistic", + *
    "javax.jdo.option.RetainValues", + *
    "javax.jdo.option.RestoreValues", + *
    "javax.jdo.option.IgnoreCache", + *
    "javax.jdo.option.NontransactionalRead", + *
    "javax.jdo.option.NontransactionalWrite", + *
    "javax.jdo.option.Multithreaded", + *
    "javax.jdo.option.ConnectionUserName", + *
    "javax.jdo.option.ConnectionPassword", + *
    "javax.jdo.option.ConnectionURL", + *
    "javax.jdo.option.ConnectionFactoryName", + *
    "javax.jdo.option.ConnectionFactory2Name", + *
    "javax.jdo.option.Mapping", + *
    "javax.jdo.mapping.Catalog", + *
    "javax.jdo.mapping.Schema", + *
    "javax.jdo.option.PersistenceUnitName", + *
    "javax.jdo.option.DetachAllOnCommit", + *
    "javax.jdo.option.CopyOnAttach", + *
    "javax.jdo.option.ReadOnly", + *
    "javax.jdo.option.TransactionIsolationLevel", + *
    "javax.jdo.option.TransactionType", + *
    "javax.jdo.option.ServerTimeZoneID", + *
    "javax.jdo.option.DatastoreReadTimeoutMillis", + *
    "javax.jdo.option.DatastoreWriteTimeoutMillis", + *
    "javax.jdo.option.Name". + *
    + * and properties of the form + *
    javax.jdo.option.InstanceLifecycleListener.{listenerClass}[=[{pcClasses}]] + * where {listenerClass} is the fully qualified name of a + * class that implements + * {@link javax.jdo.listener.InstanceLifecycleListener}, and + * {pcClasses} is an optional comma- or whitespace-delimited + * list of persistence-capable classes to be observed; the absence of a + * value for a property of this form means that instances of all + * persistence-capable classes will be observed by an instance of the given + * listener class. + *

    JDO implementations + * are permitted to define key values of their own. Any key values not + * recognized by the implementation must be ignored. Key values that are + * recognized but not supported by an implementation must result in a + * JDOFatalUserException thrown by the method. + *

    The returned PersistenceManagerFactory is not + * configurable (the setXXX methods will throw an + * exception). + *

    JDO implementations might manage a map of instantiated + * PersistenceManagerFactory instances based on specified + * property key values, and return a previously instantiated + * PersistenceManagerFactory instance. In this case, the + * properties of the returned instance must exactly match the requested + * properties. + * @param overrides Overrides of properties + * @param props a Properties instance with properties of the + * PersistenceManagerFactory. + * @param pmfClassLoader the class loader to use to load the + * PersistenceManagerFactory class + * @return the PersistenceManagerFactory. + * @throws JDOFatalUserException if + *

    • the pmfClassLoader passed is invalid; or + *
    • a valid class name cannot be obtained from + * either props or system resources + * (an entry in META-INF/services/javax.jdo.PersistenceManagerFactory); or + *
    • all implementations throw an exception. + *
    + * @since 2.1 + */ + protected static PersistenceManagerFactory getPersistenceManagerFactory + (Map overrides, Map props, ClassLoader pmfClassLoader) { + + List exceptions = new ArrayList(); + if (pmfClassLoader == null) + throw new JDOFatalUserException (msg.msg ( + "EXC_GetPMFNullLoader")); //NOI18N + + JDOImplHelper.assertOnlyKnownStandardProperties(overrides); + JDOImplHelper.assertOnlyKnownStandardProperties(props); + + // first try to get the class name from the properties object. + String pmfClassName = (String) props.get ( + PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS); + + if (!isNullOrBlank(pmfClassName)) { + // a valid name was returned from the properties. + return invokeGetPersistenceManagerFactoryOnImplementation( + pmfClassName, overrides, props, pmfClassLoader); + } else { - // Not Persistent Not Transactional - return ObjectState.TRANSIENT; - } - } - } - } - - /** - * Get the anonymous PersistenceManagerFactory configured via the standard - * configuration file resource "META-INF/jdoconfig.xml", using the current thread's context class - * loader to locate the configuration file resource(s). - * - * @return the anonymous PersistenceManagerFactory. - * @since 2.1 - * @see #getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader) - */ - public static PersistenceManagerFactory getPersistenceManagerFactory() { - ClassLoader cl = getContextClassLoader(); - return getPersistenceManagerFactory(null, ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, cl, cl); - } - - /** - * Get the anonymous PersistenceManagerFactory configured via the standard - * configuration file resource "META-INF/jdoconfig.xml", using the given class loader. - * - * @return the anonymous PersistenceManagerFactory. - * @param pmfClassLoader the ClassLoader used to load resources and classes - * @since 2.1 - * @see #getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader) - */ - public static PersistenceManagerFactory getPersistenceManagerFactory(ClassLoader pmfClassLoader) { - return getPersistenceManagerFactory( - null, ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, pmfClassLoader, pmfClassLoader); - } - - /** - * Get a PersistenceManagerFactory based on a Properties instance, using - * the current thread's context class loader to locate the PersistenceManagerFactory - * class. - * - * @return the PersistenceManagerFactory. - * @param props a Properties instance with properties of the - * PersistenceManagerFactory. - * @see #getPersistenceManagerFactory(java.util.Map,ClassLoader) - */ - public static PersistenceManagerFactory getPersistenceManagerFactory(Map props) { - return getPersistenceManagerFactory(null, props, getContextClassLoader()); - } - - /** - * Get a PersistenceManagerFactory based on a Map and a class loader. - * This method delegates to the getPersistenceManagerFactory method that takes a Map of overrides - * and a Map of properties, passing null as the overrides parameter. - * - * @see #getPersistenceManagerFactory(java.util.Map, java.util.Map, ClassLoader) - * @return the PersistenceManagerFactory. - * @param props a Map with properties of the PersistenceManagerFactory. - * @param pmfClassLoader the class loader used to load the PersistenceManagerFactory - * class - * @since 1.0 - */ - public static PersistenceManagerFactory getPersistenceManagerFactory( - Map props, ClassLoader pmfClassLoader) { - return getPersistenceManagerFactory(null, props, pmfClassLoader); - } - - /** - * Get a PersistenceManagerFactory based on a Map of overrides, a - * Map of properties, and a class loader. The following are standard key names:
    - * "javax.jdo.PersistenceManagerFactoryClass" - *
    "javax.jdo.option.Optimistic", - *
    "javax.jdo.option.RetainValues", - *
    "javax.jdo.option.RestoreValues", - *
    "javax.jdo.option.IgnoreCache", - *
    "javax.jdo.option.NontransactionalRead", - *
    "javax.jdo.option.NontransactionalWrite", - *
    "javax.jdo.option.Multithreaded", - *
    "javax.jdo.option.ConnectionUserName", - *
    "javax.jdo.option.ConnectionPassword", - *
    "javax.jdo.option.ConnectionURL", - *
    "javax.jdo.option.ConnectionFactoryName", - *
    "javax.jdo.option.ConnectionFactory2Name", - *
    "javax.jdo.option.Mapping", - *
    "javax.jdo.mapping.Catalog", - *
    "javax.jdo.mapping.Schema", - *
    "javax.jdo.option.PersistenceUnitName", - *
    "javax.jdo.option.DetachAllOnCommit", - *
    "javax.jdo.option.CopyOnAttach", - *
    "javax.jdo.option.ReadOnly", - *
    "javax.jdo.option.TransactionIsolationLevel", - *
    "javax.jdo.option.TransactionType", - *
    "javax.jdo.option.ServerTimeZoneID", - *
    "javax.jdo.option.DatastoreReadTimeoutMillis", - *
    "javax.jdo.option.DatastoreWriteTimeoutMillis", - *
    "javax.jdo.option.Name". - *
    and properties of the form
    - * javax.jdo.option.InstanceLifecycleListener.{listenerClass}[=[{pcClasses}]] where - * {listenerClass} is the fully qualified name of a class that implements {@link - * javax.jdo.listener.InstanceLifecycleListener}, and {pcClasses} is an optional - * comma- or whitespace-delimited list of persistence-capable classes to be observed; the absence - * of a value for a property of this form means that instances of all persistence-capable classes - * will be observed by an instance of the given listener class. - * - *

    JDO implementations are permitted to define key values of their own. Any key values not - * recognized by the implementation must be ignored. Key values that are recognized but not - * supported by an implementation must result in a JDOFatalUserException thrown by - * the method. - * - *

    The returned PersistenceManagerFactory is not configurable (the - * setXXX methods will throw an exception). - * - *

    JDO implementations might manage a map of instantiated PersistenceManagerFactory - * instances based on specified property key values, and return a previously instantiated - * PersistenceManagerFactory instance. In this case, the properties of the returned - * instance must exactly match the requested properties. - * - * @param overrides Overrides of properties - * @param props a Properties instance with properties of the - * PersistenceManagerFactory. - * @param pmfClassLoader the class loader to use to load the PersistenceManagerFactory - * class - * @return the PersistenceManagerFactory. - * @throws JDOFatalUserException if - *

      - *
    • the pmfClassLoader passed is invalid; or - *
    • a valid class name cannot be obtained from either props or system - * resources (an entry in META-INF/services/javax.jdo.PersistenceManagerFactory); or - *
    • all implementations throw an exception. - *
    - * - * @since 2.1 - */ - protected static PersistenceManagerFactory getPersistenceManagerFactory( - Map overrides, Map props, ClassLoader pmfClassLoader) { - - List exceptions = new ArrayList(); - if (pmfClassLoader == null) - throw new JDOFatalUserException(msg.msg("EXC_GetPMFNullLoader")); // NOI18N - - JDOImplHelper.assertOnlyKnownStandardProperties(overrides); - JDOImplHelper.assertOnlyKnownStandardProperties(props); - - // first try to get the class name from the properties object. - String pmfClassName = (String) props.get(PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS); - - if (!isNullOrBlank(pmfClassName)) { - // a valid name was returned from the properties. - return invokeGetPersistenceManagerFactoryOnImplementation( - pmfClassName, overrides, props, pmfClassLoader); - - } else { - /* - * If you have a jar file that provides the jdo implementation, - * a file naming the implementation goes into the file - * packaged into the jar file, called - * META-INF/services/javax.jdo.PersistenceManagerFactory. - * The contents of the file is a string that is the PMF class name, - * null or blank. - * For each file in pmfClassLoader named - * META-INF/services/javax.jdo.PersistenceManagerFactory, - * this method will try to invoke the getPersistenceManagerFactory - * method of the implementation class. - * Return the factory if a valid class name is extracted from - * resources and the invocation returns an instance. - * Otherwise add the exception thrown to - * an exception list. - */ - Enumeration urls = null; - try { - urls = getResources(pmfClassLoader, SERVICE_LOOKUP_PMF_RESOURCE_NAME); - } catch (Throwable ex) { - exceptions.add(ex); - } + /* + * If you have a jar file that provides the jdo implementation, + * a file naming the implementation goes into the file + * packaged into the jar file, called + * META-INF/services/javax.jdo.PersistenceManagerFactory. + * The contents of the file is a string that is the PMF class name, + * null or blank. + * For each file in pmfClassLoader named + * META-INF/services/javax.jdo.PersistenceManagerFactory, + * this method will try to invoke the getPersistenceManagerFactory + * method of the implementation class. + * Return the factory if a valid class name is extracted from + * resources and the invocation returns an instance. + * Otherwise add the exception thrown to + * an exception list. + */ + Enumeration urls = null; + try { + urls = getResources(pmfClassLoader, + SERVICE_LOOKUP_PMF_RESOURCE_NAME); + } catch (Throwable ex) { + exceptions.add(ex); + } - if (urls != null) { - while (urls.hasMoreElements()) { + if (urls != null){ + while (urls.hasMoreElements()) { - try { - pmfClassName = getClassNameFromURL((URL) urls.nextElement()); + try { + pmfClassName = getClassNameFromURL( + (URL) urls.nextElement()); - // return the implementation that is valid. - PersistenceManagerFactory pmf = - invokeGetPersistenceManagerFactoryOnImplementation( - pmfClassName, overrides, props, pmfClassLoader); - return pmf; + // return the implementation that is valid. + PersistenceManagerFactory pmf = + invokeGetPersistenceManagerFactoryOnImplementation( + pmfClassName, overrides, props, pmfClassLoader); + return pmf; - } catch (Throwable ex) { + } catch (Throwable ex) { - // remember exceptions from failed pmf invocations - exceptions.add(ex); - } + // remember exceptions from failed pmf invocations + exceptions.add(ex); + + } + } + } } - } + + // no PMF class name in props and no services. + + throw new JDOFatalUserException(msg.msg( + "EXC_GetPMFNoPMFClassNamePropertyOrPUNameProperty"), + (Throwable[]) + exceptions.toArray(new Throwable[exceptions.size()])); } - // no PMF class name in props and no services. - - throw new JDOFatalUserException( - msg.msg("EXC_GetPMFNoPMFClassNamePropertyOrPUNameProperty"), - (Throwable[]) exceptions.toArray(new Throwable[exceptions.size()])); - } - - /** - * Get a class name from a URL. The URL is from getResources with e.g. - * META-INF/services/javax.jdo.PersistenceManagerFactory as the parameter. Parse the file, - * removing blank lines, comment lines, and comments. - * - * @param url the URL of the services file - * @return the name of the class contained in the file - * @throws java.io.IOException Throw if an error occurs on accessing this URL - * @since 2.1 - */ - protected static String getClassNameFromURL(URL url) throws IOException { - InputStream is = openStream(url); - BufferedReader reader = new BufferedReader(new InputStreamReader(is)); - String line = null; - try { - while ((line = reader.readLine()) != null) { - line = line.trim(); - if (line.length() == 0 || line.startsWith("#")) { - continue; - } - // else assume first line of text is the PMF class name - String[] tokens = line.split("\\s"); - String pmfClassName = tokens[0]; - int indexOfComment = pmfClassName.indexOf("#"); - if (indexOfComment == -1) { - return pmfClassName; + /** Get a class name from a URL. The URL is from getResources with + * e.g. META-INF/services/javax.jdo.PersistenceManagerFactory as the + * parameter. Parse the file, removing blank lines, comment lines, + * and comments. + * @param url the URL of the services file + * @return the name of the class contained in the file + * @throws java.io.IOException Throw if an error occurs on accessing this URL + * @since 2.1 + */ + protected static String getClassNameFromURL (URL url) + throws IOException { + InputStream is = openStream(url); + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + String line = null; + try { + while ((line = reader.readLine()) != null) { + line = line.trim(); + if (line.length() == 0 || line.startsWith("#")) { + continue; + } + // else assume first line of text is the PMF class name + String[] tokens = line.split("\\s"); + String pmfClassName = tokens[0]; + int indexOfComment = pmfClassName.indexOf("#"); + if (indexOfComment == -1) { + return pmfClassName; + } + // else pmfClassName has a comment at the end of it -- remove + return pmfClassName.substring(0, indexOfComment); + } + return null; + } finally { + try { + reader.close(); + } + catch (IOException x) { + // gulp + } } - // else pmfClassName has a comment at the end of it -- remove - return pmfClassName.substring(0, indexOfComment); - } - return null; - } finally { - try { - reader.close(); - } catch (IOException x) { - // gulp - } } - } - - /** - * Returns a named {@link PersistenceManagerFactory} or persistence unit. - * - * @since 2.1 - * @see #getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader) - * @param name Name of the PMF - * @return PersistenceManagerFactory - */ - public static PersistenceManagerFactory getPersistenceManagerFactory(String name) { - ClassLoader cl = getContextClassLoader(); - return getPersistenceManagerFactory(null, name, cl, cl); - } - - /** - * Returns a named {@link PersistenceManagerFactory} or persistence unit. - * - * @since 1.0 - * @see #getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader) - * @param name Name of the PMF - * @param loader ClassLoader to use - * @return PersistenceManagerFactory - */ - public static PersistenceManagerFactory getPersistenceManagerFactory( - String name, ClassLoader loader) { - - return getPersistenceManagerFactory(null, name, loader, loader); - } - - /** - * Returns a named {@link PersistenceManagerFactory} or persistence unit. - * - * @since 2.0 - * @see #getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader) - * @param name Name of the PMF - * @param resourceLoader ClassLoader to use for loading resources - * @param pmfLoader ClassLoader to use for loading the PMF - * @return PersistenceManagerFactory - */ - public static PersistenceManagerFactory getPersistenceManagerFactory( - String name, ClassLoader resourceLoader, ClassLoader pmfLoader) { - - return getPersistenceManagerFactory(null, name, resourceLoader, pmfLoader); - } - - /** - * Returns a named {@link PersistenceManagerFactory} or persistence unit. - * - * @since 2.1 - * @see #getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader) - * @param name Name of the PMF - * @param overrides Property overrides - * @return PersistenceManagerFactory - */ - public static PersistenceManagerFactory getPersistenceManagerFactory( - Map overrides, String name) { - - ClassLoader cl = getContextClassLoader(); - return getPersistenceManagerFactory(overrides, name, cl, cl); - } - - /** - * Returns a named {@link PersistenceManagerFactory} or persistence unit. - * - * @since 2.1 - * @see #getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader) - * @param overrides Property overrides - * @param name Name of the PMF - * @param resourceLoader ClassLoader to use for loading resources - * @return The PMF - */ - public static PersistenceManagerFactory getPersistenceManagerFactory( - Map overrides, String name, ClassLoader resourceLoader) { - - return getPersistenceManagerFactory(overrides, name, resourceLoader, resourceLoader); - } - - /** - * Returns a {@link PersistenceManagerFactory} configured based on the properties stored in the - * resource at name, or, if not found, returns a {@link PersistenceManagerFactory} - * with the given name or, if not found, returns a javax.persistence.EntityManagerFactory - * cast to a {@link PersistenceManagerFactory}. If the name given is null or consists only - * of whitespace, it is interpreted as {@link - * Constants#ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME}. The following are standard key names: - *
    - * "javax.jdo.PersistenceManagerFactoryClass" - *
    "javax.jdo.option.Optimistic", - *
    "javax.jdo.option.RetainValues", - *
    "javax.jdo.option.RestoreValues", - *
    "javax.jdo.option.IgnoreCache", - *
    "javax.jdo.option.NontransactionalRead", - *
    "javax.jdo.option.NontransactionalWrite", - *
    "javax.jdo.option.Multithreaded", - *
    "javax.jdo.option.ConnectionUserName", - *
    "javax.jdo.option.ConnectionPassword", - *
    "javax.jdo.option.ConnectionURL", - *
    "javax.jdo.option.ConnectionFactoryName", - *
    "javax.jdo.option.ConnectionFactory2Name", - *
    "javax.jdo.option.Mapping", - *
    "javax.jdo.mapping.Catalog", - *
    "javax.jdo.mapping.Schema", - *
    "javax.jdo.option.PersistenceUnitName". - *
    "javax.jdo.option.DetachAllOnCommit". - *
    "javax.jdo.option.CopyOnAttach". - *
    "javax.jdo.option.TransactionType". - *
    "javax.jdo.option.ServerTimeZoneID". - *
    "javax.jdo.option.DatastoreReadTimeoutMillis", - *
    "javax.jdo.option.DatastoreWriteTimeoutMillis", - *
    "javax.jdo.option.Name". - *
    and properties of the form
    - * javax.jdo.option.InstanceLifecycleListener.{listenerClass}[=[{pcClasses}]] where - * {listenerClass} is the fully qualified name of a class that implements {@link - * javax.jdo.listener.InstanceLifecycleListener}, and {pcClasses} is an optional - * comma- or whitespace-delimited list of persistence-capable classes to be observed; the absence - * of a value for a property of this form means that instances of all persistence-capable classes - * will be observed by an instance of the given listener class. - * - *

    JDO implementations are permitted to define key values of their own. Any key values not - * recognized by the implementation must be ignored. Key values that are recognized but not - * supported by an implementation must result in a JDOFatalUserException thrown by - * the method. - * - *

    The returned PersistenceManagerFactory is not configurable (the - * setXXX methods will throw an exception). - * - *

    This method loads the properties found at name, if any, via - * resourceLoader, and creates a {@link PersistenceManagerFactory} with pmfLoader - * . Any exceptions thrown during resource loading will be wrapped in a {@link - * JDOFatalUserException}. If multiple PMFs with the requested name are found, a {@link - * JDOFatalUserException} is thrown. - * - * @since 2.1 - * @param overrides a Map containing properties that override properties defined in any resources - * loaded according to the "name" parameter - * @param name interpreted as the name of the resource containing the PMF properties, the name of - * the PMF, or the persistence unit name, in that order; if name is null, blank or whitespace, - * it is interpreted as indicating the anonymous {@link PersistenceManagerFactory}. - * @param resourceLoader the class loader to use to load properties file resources; must be - * non-null if name is non-null or blank - * @param pmfLoader the class loader to use to load the {@link PersistenceManagerFactory} or - * javax.persistence.EntityManagerFactory classes - * @return the {@link PersistenceManagerFactory} with properties in the given resource, with the - * given name, or with the given persitence unit name - * @see Constants#ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME - */ - public static PersistenceManagerFactory getPersistenceManagerFactory( - Map overrides, String name, ClassLoader resourceLoader, ClassLoader pmfLoader) { - if (pmfLoader == null) - throw new JDOFatalUserException(msg.msg("EXC_GetPMFNullPMFLoader")); // NOI18N - if (resourceLoader == null) { - throw new JDOFatalUserException(msg.msg("EXC_GetPMFNullPropsLoader")); // NOI18N + + /** + * Returns a named {@link PersistenceManagerFactory} or persistence unit. + * @since 2.1 + * @see #getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader) + * @param name Name of the PMF + * @return PersistenceManagerFactory + */ + public static PersistenceManagerFactory getPersistenceManagerFactory + (String name) { + ClassLoader cl = getContextClassLoader(); + return getPersistenceManagerFactory(null, name, cl, cl); } - Map props = null; - // trim spaces from name and ensure non-null - name = (name == null ? ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME : name.trim()); - if (!ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME.equals(name)) { - props = loadPropertiesFromResource(resourceLoader, name); + /** + * Returns a named {@link PersistenceManagerFactory} or persistence unit. + * @since 1.0 + * @see #getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader) + * @param name Name of the PMF + * @param loader ClassLoader to use + * @return PersistenceManagerFactory + */ + public static PersistenceManagerFactory getPersistenceManagerFactory + (String name, ClassLoader loader) { + + return getPersistenceManagerFactory(null, name, loader, loader); } - if (props != null) { - // add the SPI property to inform the implementation that - // the PMF was configured by the given resource name - // and not via named PMF for proper deserialization - props.put(PROPERTY_SPI_RESOURCE_NAME, name); - props.remove(PROPERTY_NAME); - return getPersistenceManagerFactory(overrides, props, pmfLoader); + /** + * Returns a named {@link PersistenceManagerFactory} or persistence unit. + * @since 2.0 + * @see #getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader) + * @param name Name of the PMF + * @param resourceLoader ClassLoader to use for loading resources + * @param pmfLoader ClassLoader to use for loading the PMF + * @return PersistenceManagerFactory + */ + public static PersistenceManagerFactory getPersistenceManagerFactory + (String name, ClassLoader resourceLoader, ClassLoader pmfLoader) { + + return getPersistenceManagerFactory( + null, name, resourceLoader, pmfLoader); } - // props were null; try getting from jdoconfig.xml - props = getPropertiesFromJdoconfig(name, resourceLoader); - if (props != null) { - // inform the impl that the config came from a jdoconfig.xml - // element with the given name - props.put(PROPERTY_NAME, name); - props.remove(PROPERTY_SPI_RESOURCE_NAME); - // we have loaded a Properties, delegate to implementation - return getPersistenceManagerFactory(overrides, props, pmfLoader); + + /** + * Returns a named {@link PersistenceManagerFactory} or persistence unit. + * @since 2.1 + * @see #getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader) + * @param name Name of the PMF + * @param overrides Property overrides + * @return PersistenceManagerFactory + */ + public static PersistenceManagerFactory getPersistenceManagerFactory + (Map overrides, String name) { + + ClassLoader cl = getContextClassLoader(); + return getPersistenceManagerFactory(overrides, name, cl, cl); } - // no properties found; last try to see if name is a JPA PU name - if (!ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME.equals(name)) { - props = new Properties(); - props.put(PROPERTY_PERSISTENCE_UNIT_NAME, name); - return getPersistenceManagerFactory(overrides, props, pmfLoader); + + /** + * Returns a named {@link PersistenceManagerFactory} or persistence unit. + * @since 2.1 + * @see #getPersistenceManagerFactory(Map,String,ClassLoader,ClassLoader) + * @param overrides Property overrides + * @param name Name of the PMF + * @param resourceLoader ClassLoader to use for loading resources + * @return The PMF + */ + public static PersistenceManagerFactory getPersistenceManagerFactory + (Map overrides, String name, ClassLoader resourceLoader) { + + return getPersistenceManagerFactory( + overrides, name, resourceLoader, resourceLoader); } + + + /** + * Returns a {@link PersistenceManagerFactory} configured based + * on the properties stored in the resource at + * name, or, if not found, returns a + * {@link PersistenceManagerFactory} with the given + * name or, if not found, returns a + * javax.persistence.EntityManagerFactory cast to a + * {@link PersistenceManagerFactory}. If the name given is null or consists + * only of whitespace, it is interpreted as + * {@link Constants#ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME}. + * The following are standard key names: + *
    "javax.jdo.PersistenceManagerFactoryClass" + *
    "javax.jdo.option.Optimistic", + *
    "javax.jdo.option.RetainValues", + *
    "javax.jdo.option.RestoreValues", + *
    "javax.jdo.option.IgnoreCache", + *
    "javax.jdo.option.NontransactionalRead", + *
    "javax.jdo.option.NontransactionalWrite", + *
    "javax.jdo.option.Multithreaded", + *
    "javax.jdo.option.ConnectionUserName", + *
    "javax.jdo.option.ConnectionPassword", + *
    "javax.jdo.option.ConnectionURL", + *
    "javax.jdo.option.ConnectionFactoryName", + *
    "javax.jdo.option.ConnectionFactory2Name", + *
    "javax.jdo.option.Mapping", + *
    "javax.jdo.mapping.Catalog", + *
    "javax.jdo.mapping.Schema", + *
    "javax.jdo.option.PersistenceUnitName". + *
    "javax.jdo.option.DetachAllOnCommit". + *
    "javax.jdo.option.CopyOnAttach". + *
    "javax.jdo.option.TransactionType". + *
    "javax.jdo.option.ServerTimeZoneID". + *
    "javax.jdo.option.DatastoreReadTimeoutMillis", + *
    "javax.jdo.option.DatastoreWriteTimeoutMillis", + *
    "javax.jdo.option.Name". + *
    + * and properties of the form + *
    javax.jdo.option.InstanceLifecycleListener.{listenerClass}[=[{pcClasses}]] + * where {listenerClass} is the fully qualified name of a + * class that implements + * {@link javax.jdo.listener.InstanceLifecycleListener}, and + * {pcClasses} is an optional comma- or whitespace-delimited + * list of persistence-capable classes to be observed; the absence of a + * value for a property of this form means that instances of all + * persistence-capable classes will be observed by an instance of the given + * listener class. + *

    JDO implementations + * are permitted to define key values of their own. Any key values not + * recognized by the implementation must be ignored. Key values that are + * recognized but not supported by an implementation must result in a + * JDOFatalUserException thrown by the method. + *

    The returned PersistenceManagerFactory is not + * configurable (the setXXX methods will throw an + * exception). + * + * This method loads the properties found at name, if any, via + * resourceLoader, and creates a {@link + * PersistenceManagerFactory} with pmfLoader. Any + * exceptions thrown during resource loading will + * be wrapped in a {@link JDOFatalUserException}. + * If multiple PMFs with the requested name are found, a + * {@link JDOFatalUserException} is thrown. + * @since 2.1 + * @param overrides a Map containing properties that override properties + * defined in any resources loaded according to the "name" parameter + * @param name interpreted as the name of the resource containing the PMF + * properties, the name of the PMF, or the persistence unit name, in that + * order; if name is null, blank or whitespace, it is interpreted as + * indicating the anonymous {@link PersistenceManagerFactory}. + * @param resourceLoader the class loader to use to load properties file + * resources; must be non-null if name is non-null or blank + * @param pmfLoader the class loader to use to load the + * {@link PersistenceManagerFactory} or + * javax.persistence.EntityManagerFactory classes + * @return the {@link PersistenceManagerFactory} with properties in the + * given resource, with the given name, or with the given persitence unit name + * @see Constants#ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME + */ + public static PersistenceManagerFactory getPersistenceManagerFactory( + Map overrides, + String name, + ClassLoader resourceLoader, + ClassLoader pmfLoader) { + if (pmfLoader == null) + throw new JDOFatalUserException (msg.msg ( + "EXC_GetPMFNullPMFLoader")); //NOI18N + if (resourceLoader == null) { + throw new JDOFatalUserException(msg.msg( + "EXC_GetPMFNullPropsLoader")); //NOI18N + } - // no PMF found; give up - throw new JDOFatalUserException( - msg.msg("EXC_NoPMFConfigurableViaPropertiesOrXML", name)); // NOI18N - } - - /** - * Invoke the getPersistenceManagerFactory method on the implementation. If the overrides - * parameter to this method is not null, the static method with Map overrides, Map properties - * parameters will be invoked. If the overrides parameter to this method is null, the static - * method with Map properties parameter will be invoked. - * - * @param pmfClassName the name of the implementation factory class - * @param overrides a Map of overrides - * @param properties a Map of properties - * @param cl the class loader to use to load the implementation class - * @return the PersistenceManagerFactory - */ - protected static PersistenceManagerFactory invokeGetPersistenceManagerFactoryOnImplementation( - String pmfClassName, Map overrides, Map properties, ClassLoader cl) { - if (overrides != null) { - // overrides is not null; use getPersistenceManagerFactory(Map overrides, Map props) - try { - Class implClass = forName(pmfClassName, true, cl); - Method m = - getMethod( - implClass, - "getPersistenceManagerFactory", // NOI18N - new Class[] {Map.class, Map.class}); - PersistenceManagerFactory pmf = - (PersistenceManagerFactory) invoke(m, null, new Object[] {overrides, properties}); - if (pmf == null) { - throw new JDOFatalInternalException(msg.msg("EXC_GetPMFNullPMF", pmfClassName)); // NOI18N + Map props = null; + // trim spaces from name and ensure non-null + name = (name == null?ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME:name.trim()); + if (!ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME.equals(name)) { + props = loadPropertiesFromResource(resourceLoader, name); } - return pmf; - - } catch (ClassNotFoundException e) { - throw new JDOFatalUserException( - msg.msg("EXC_GetPMFClassNotFound", pmfClassName), e); // NOI18N - } catch (NoSuchMethodException e) { - throw new JDOFatalInternalException( - msg.msg("EXC_GetPMFNoSuchMethod2", pmfClassName), e); // NOI18N - } catch (NullPointerException e) { - throw new JDOFatalInternalException( - msg.msg("EXC_GetPMFNullPointerException", pmfClassName), e); // NOI18N - } catch (IllegalAccessException e) { - throw new JDOFatalUserException( - msg.msg("EXC_GetPMFIllegalAccess", pmfClassName), e); // NOI18N - } catch (ClassCastException e) { - throw new JDOFatalInternalException( - msg.msg("EXC_GetPMFClassCastException", pmfClassName), e); // NOI18N - } catch (InvocationTargetException ite) { - Throwable nested = ite.getTargetException(); - if (nested instanceof JDOException) { - throw (JDOException) nested; - } else - throw new JDOFatalInternalException( - msg.msg("EXC_GetPMFUnexpectedException"), ite); // NOI18N - } - } else { - // overrides is null; use getPersistenceManagerFactory(Map props) - try { - Class implClass = forName(pmfClassName, true, cl); - Method m = - getMethod( - implClass, - "getPersistenceManagerFactory", // NOI18N - new Class[] {Map.class}); - PersistenceManagerFactory pmf = - (PersistenceManagerFactory) invoke(m, null, new Object[] {properties}); - if (pmf == null) { - throw new JDOFatalInternalException(msg.msg("EXC_GetPMFNullPMF", pmfClassName)); // NOI18N + + if (props != null) { + // add the SPI property to inform the implementation that + // the PMF was configured by the given resource name + // and not via named PMF for proper deserialization + props.put(PROPERTY_SPI_RESOURCE_NAME, name); + props.remove(PROPERTY_NAME); + return getPersistenceManagerFactory(overrides, props, pmfLoader); } - return pmf; - } catch (ClassNotFoundException e) { - throw new JDOFatalUserException( - msg.msg("EXC_GetPMFClassNotFound", pmfClassName), e); // NOI18N - } catch (NoSuchMethodException e) { - throw new JDOFatalInternalException( - msg.msg("EXC_GetPMFNoSuchMethod", pmfClassName), e); // NOI18N - } catch (NullPointerException e) { - throw new JDOFatalInternalException( - msg.msg("EXC_GetPMFNullPointerException", pmfClassName), e); // NOI18N - } catch (IllegalAccessException e) { - throw new JDOFatalUserException( - msg.msg("EXC_GetPMFIllegalAccess", pmfClassName), e); // NOI18N - } catch (ClassCastException e) { - throw new JDOFatalInternalException( - msg.msg("EXC_GetPMFClassCastException", pmfClassName), e); // NOI18N - } catch (InvocationTargetException ite) { - Throwable nested = ite.getTargetException(); - if (nested instanceof JDOException) { - throw (JDOException) nested; - } else - throw new JDOFatalInternalException( - msg.msg("EXC_GetPMFUnexpectedException"), ite); // NOI18N - } + // props were null; try getting from jdoconfig.xml + props = getPropertiesFromJdoconfig(name, resourceLoader); + if (props != null) { + // inform the impl that the config came from a jdoconfig.xml + // element with the given name + props.put(PROPERTY_NAME, name); + props.remove(PROPERTY_SPI_RESOURCE_NAME); + // we have loaded a Properties, delegate to implementation + return getPersistenceManagerFactory(overrides, props, pmfLoader); + } + // no properties found; last try to see if name is a JPA PU name + if (!ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME.equals(name)) { + props = new Properties(); + props.put(PROPERTY_PERSISTENCE_UNIT_NAME, name); + return getPersistenceManagerFactory(overrides, props, pmfLoader); + } + + // no PMF found; give up + throw new JDOFatalUserException (msg.msg ( + "EXC_NoPMFConfigurableViaPropertiesOrXML", name)); //NOI18N } - } - - /** - * Load a Properties instance by name from the class loader. - * - * @param resourceLoader the class loader from which to load the properties - * @param name the name of the resource - * @return a Properties instance or null if no resource is found - */ - protected static Map loadPropertiesFromResource( - ClassLoader resourceLoader, String name) { - InputStream in = null; - Properties props = null; - // try to load resources from properties file - try { - in = getResourceAsStream(resourceLoader, name); - if (in != null) { - // then some kind of resource was found by the given name; - // assume that it's a properties file - props = new Properties(); - ((Properties) props).load(in); - } - } catch (IOException ioe) { - throw new JDOFatalUserException(msg.msg("EXC_GetPMFIOExceptionRsrc", name), ioe); // NOI18N - } finally { - if (in != null) { + + /** Invoke the getPersistenceManagerFactory method on the implementation. + * If the overrides parameter to this method is not null, the static method + * with Map overrides, Map properties parameters will be invoked. + * If the overrides parameter to this method is null, the static method + * with Map properties parameter will be invoked. + * @param pmfClassName the name of the implementation factory class + * @param overrides a Map of overrides + * @param properties a Map of properties + * @param cl the class loader to use to load the implementation class + * @return the PersistenceManagerFactory + */ + protected static PersistenceManagerFactory + invokeGetPersistenceManagerFactoryOnImplementation( + String pmfClassName, Map overrides, Map properties, ClassLoader cl) { + if (overrides != null) { + // overrides is not null; use getPersistenceManagerFactory(Map overrides, Map props) + try { + Class implClass = forName(pmfClassName, true, cl); + Method m = getMethod(implClass, + "getPersistenceManagerFactory", //NOI18N + new Class[]{Map.class, Map.class}); + PersistenceManagerFactory pmf = + (PersistenceManagerFactory) invoke(m, + null, new Object[]{overrides, properties}); + if (pmf == null) { + throw new JDOFatalInternalException(msg.msg ( + "EXC_GetPMFNullPMF", pmfClassName)); //NOI18N + } + return pmf; + + } catch (ClassNotFoundException e) { + throw new JDOFatalUserException(msg.msg( + "EXC_GetPMFClassNotFound", pmfClassName), e); //NOI18N + } catch (NoSuchMethodException e) { + throw new JDOFatalInternalException(msg.msg( + "EXC_GetPMFNoSuchMethod2", pmfClassName), e); //NOI18N + } catch (NullPointerException e) { + throw new JDOFatalInternalException (msg.msg( + "EXC_GetPMFNullPointerException", pmfClassName), e); //NOI18N + } catch (IllegalAccessException e) { + throw new JDOFatalUserException(msg.msg( + "EXC_GetPMFIllegalAccess", pmfClassName), e); //NOI18N + } catch (ClassCastException e) { + throw new JDOFatalInternalException (msg.msg( + "EXC_GetPMFClassCastException", pmfClassName), e); //NOI18N + } catch (InvocationTargetException ite) { + Throwable nested = ite.getTargetException(); + if (nested instanceof JDOException) { + throw (JDOException)nested; + } else throw new JDOFatalInternalException (msg.msg( + "EXC_GetPMFUnexpectedException"), ite); //NOI18N + } + } else { + // overrides is null; use getPersistenceManagerFactory(Map props) + try { + Class implClass = forName(pmfClassName, true, cl); + Method m = getMethod(implClass, + "getPersistenceManagerFactory", //NOI18N + new Class[]{Map.class}); + PersistenceManagerFactory pmf = + (PersistenceManagerFactory) invoke(m, + null, new Object[]{properties}); + if (pmf == null) { + throw new JDOFatalInternalException(msg.msg ( + "EXC_GetPMFNullPMF", pmfClassName)); //NOI18N + } + return pmf; + } catch (ClassNotFoundException e) { + throw new JDOFatalUserException(msg.msg( + "EXC_GetPMFClassNotFound", pmfClassName), e); //NOI18N + } catch (NoSuchMethodException e) { + throw new JDOFatalInternalException(msg.msg( + "EXC_GetPMFNoSuchMethod", pmfClassName), e); //NOI18N + } catch (NullPointerException e) { + throw new JDOFatalInternalException (msg.msg( + "EXC_GetPMFNullPointerException", pmfClassName), e); //NOI18N + } catch (IllegalAccessException e) { + throw new JDOFatalUserException(msg.msg( + "EXC_GetPMFIllegalAccess", pmfClassName), e); //NOI18N + } catch (ClassCastException e) { + throw new JDOFatalInternalException (msg.msg( + "EXC_GetPMFClassCastException", pmfClassName), e); //NOI18N + } catch (InvocationTargetException ite) { + Throwable nested = ite.getTargetException(); + if (nested instanceof JDOException) { + throw (JDOException)nested; + } else throw new JDOFatalInternalException (msg.msg( + "EXC_GetPMFUnexpectedException"), ite); //NOI18N + } + } + } + + /** Load a Properties instance by name from the class loader. + * + * @param resourceLoader the class loader from which to load the properties + * @param name the name of the resource + * @return a Properties instance or null if no resource is found + */ + protected static Map loadPropertiesFromResource( + ClassLoader resourceLoader, String name) { + InputStream in = null; + Properties props = null; + // try to load resources from properties file try { - in.close(); + in = getResourceAsStream(resourceLoader, name); + if (in != null) { + // then some kind of resource was found by the given name; + // assume that it's a properties file + props = new Properties(); + ((Properties) props).load(in); + } } catch (IOException ioe) { + throw new JDOFatalUserException(msg.msg( + "EXC_GetPMFIOExceptionRsrc", name), ioe); //NOI18N + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException ioe) { + } + } } - } + return props; } - return props; - } - - /** - * @see #getNamedPMFProperties(String,ClassLoader,String) - * @since 2.1 - * @param name Name of the PMF - * @param resourceLoader ClassLoader to use for loading resources - * @return The properties for this PMF - */ - protected static Map getPropertiesFromJdoconfig( - String name, ClassLoader resourceLoader) { - return getNamedPMFProperties(name, resourceLoader, JDOCONFIG_RESOURCE_NAME); - } - - /** - * Find and return the named {@link PersistenceManagerFactory}'s properties, or null if not found. - * If multiple named PMF property sets with the given name are found (including anonymous ones), - * throw {@link JDOFatalUserException}. This method is here only to facilitate testing; the - * parameter "jdoconfigResourceName" in public usage should always have the value given in the - * constant {@link Constants#JDOCONFIG_RESOURCE_NAME}. - * - * @param name The persistence unit name; null is disallowed. - * @param resourceLoader The ClassLoader used to load the standard JDO configuration file. - * @param jdoconfigResourceName The name of the configuration file to read. In public usage, this - * should always be the value of {@link Constants#JDOCONFIG_RESOURCE_NAME}. - * @return The named PersistenceManagerFactory properties if found, null if not. - * @since 2.1 - * @throws JDOFatalUserException if multiple named PMF property sets are found with the given - * name, or any other exception is encountered. - */ - protected static Map getNamedPMFProperties( - String name, ClassLoader resourceLoader, String jdoconfigResourceName) { - // key is PU name, value is Map of PU properties - Map> propertiesByNameInAllConfigs = - new HashMap>(); - try { - URL firstFoundConfigURL = null; - - // get all JDO configurations - Enumeration resources = getResources(resourceLoader, jdoconfigResourceName); - - if (resources.hasMoreElements()) { - ArrayList processedResources = new ArrayList(); - - // get ready to parse XML - DocumentBuilderFactory factory = getDocumentBuilderFactory(); - do { - URL currentConfigURL = resources.nextElement(); - if (processedResources.contains(currentConfigURL)) { - continue; - } else { - processedResources.add(currentConfigURL); - } - - Map> propertiesByNameInCurrentConfig = - readNamedPMFProperties(currentConfigURL, name, factory); - - // try to detect duplicate requested PU - if (propertiesByNameInCurrentConfig.containsKey(name)) { - // possible dup -- check for it - if (firstFoundConfigURL == null) { - firstFoundConfigURL = currentConfigURL; + + /** + * @see #getNamedPMFProperties(String,ClassLoader,String) + * @since 2.1 + * @param name Name of the PMF + * @param resourceLoader ClassLoader to use for loading resources + * @return The properties for this PMF + */ + protected static Map getPropertiesFromJdoconfig( + String name, + ClassLoader resourceLoader) { + return getNamedPMFProperties(name, resourceLoader, JDOCONFIG_RESOURCE_NAME); + } + + /** + * Find and return the named {@link PersistenceManagerFactory}'s properties, + * or null if not found. + * If multiple named PMF property sets with + * the given name are found (including anonymous ones), throw + * {@link JDOFatalUserException}. + * This method is here only to facilitate testing; the parameter + * "jdoconfigResourceName" in public usage should always have the value + * given in the constant {@link Constants#JDOCONFIG_RESOURCE_NAME}. + * + * @param name The persistence unit name; null is disallowed. + * @param resourceLoader The ClassLoader used to load the standard JDO + * configuration file. + * @param jdoconfigResourceName The name of the configuration file to read. + * In public usage, this should always be the value of + * {@link Constants#JDOCONFIG_RESOURCE_NAME}. + * @return The named PersistenceManagerFactory properties if + * found, null if not. + * @since 2.1 + * @throws JDOFatalUserException if multiple named PMF property sets are + * found with the given name, or any other exception is encountered. + */ + protected static Map getNamedPMFProperties( + String name, + ClassLoader resourceLoader, + String jdoconfigResourceName) { + // key is PU name, value is Map of PU properties + Map> propertiesByNameInAllConfigs + = new HashMap>(); + try { + URL firstFoundConfigURL = null; + + // get all JDO configurations + Enumeration resources = + getResources(resourceLoader, jdoconfigResourceName); + + if (resources.hasMoreElements()) { + ArrayList processedResources = new ArrayList(); + + // get ready to parse XML + DocumentBuilderFactory factory = getDocumentBuilderFactory(); + do { + URL currentConfigURL = resources.nextElement(); + if (processedResources.contains(currentConfigURL)) { + continue; + } + else { + processedResources.add(currentConfigURL); + } + + Map> propertiesByNameInCurrentConfig = + readNamedPMFProperties( + currentConfigURL, + name, + factory); + + // try to detect duplicate requested PU + if (propertiesByNameInCurrentConfig.containsKey(name)) { + // possible dup -- check for it + if (firstFoundConfigURL == null) { + firstFoundConfigURL = currentConfigURL; + } + + if (propertiesByNameInAllConfigs.containsKey(name)) + throw new JDOFatalUserException (msg.msg( + "EXC_DuplicateRequestedNamedPMFFoundInDifferentConfigs", + "".equals(name) + ? "(anonymous)" + : name, + firstFoundConfigURL.toExternalForm(), + currentConfigURL.toExternalForm())); //NOI18N + } + // no dups -- add found PUs to all PUs and keep going + propertiesByNameInAllConfigs + .putAll(propertiesByNameInCurrentConfig); + } while (resources.hasMoreElements()); } + } + catch (FactoryConfigurationError e) { + throw new JDOFatalUserException( + msg.msg("ERR_NoDocumentBuilderFactory"), e); + } + catch (IOException ioe) { + throw new JDOFatalUserException (msg.msg ( + "EXC_GetPMFIOExceptionRsrc", name), ioe); //NOI18N + } - if (propertiesByNameInAllConfigs.containsKey(name)) - throw new JDOFatalUserException( - msg.msg( - "EXC_DuplicateRequestedNamedPMFFoundInDifferentConfigs", - "".equals(name) ? "(anonymous)" : name, - firstFoundConfigURL.toExternalForm(), - currentConfigURL.toExternalForm())); // NOI18N - } - // no dups -- add found PUs to all PUs and keep going - propertiesByNameInAllConfigs.putAll(propertiesByNameInCurrentConfig); - } while (resources.hasMoreElements()); - } - } catch (FactoryConfigurationError e) { - throw new JDOFatalUserException(msg.msg("ERR_NoDocumentBuilderFactory"), e); - } catch (IOException ioe) { - throw new JDOFatalUserException(msg.msg("EXC_GetPMFIOExceptionRsrc", name), ioe); // NOI18N + // done with reading all config resources; + // return what we found, which may very well be null + return (Map) propertiesByNameInAllConfigs.get(name); } - // done with reading all config resources; - // return what we found, which may very well be null - return (Map) propertiesByNameInAllConfigs.get(name); - } - protected static DocumentBuilderFactory getDocumentBuilderFactory() { - @SuppressWarnings("static-access") - DocumentBuilderFactory factory = implHelper.getRegisteredDocumentBuilderFactory(); - if (factory == null) { - factory = getDefaultDocumentBuilderFactory(); + protected static DocumentBuilderFactory getDocumentBuilderFactory() { + @SuppressWarnings("static-access") + DocumentBuilderFactory factory = + implHelper.getRegisteredDocumentBuilderFactory(); + if (factory == null) { + factory = getDefaultDocumentBuilderFactory(); + } + return factory; } - return factory; - } - - protected static DocumentBuilderFactory getDefaultDocumentBuilderFactory() { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setIgnoringComments(true); - factory.setNamespaceAware(true); - factory.setValidating(false); - factory.setIgnoringElementContentWhitespace(true); - factory.setExpandEntityReferences(true); - - return factory; - } - - protected static ErrorHandler getErrorHandler() { - @SuppressWarnings("static-access") - ErrorHandler handler = implHelper.getRegisteredErrorHandler(); - if (handler == null) { - handler = getDefaultErrorHandler(); + + protected static DocumentBuilderFactory getDefaultDocumentBuilderFactory() { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setIgnoringComments(true); + factory.setNamespaceAware(true); + factory.setValidating(false); + factory.setIgnoringElementContentWhitespace(true); + factory.setExpandEntityReferences(true); + + return factory; } - return handler; - } - - protected static ErrorHandler getDefaultErrorHandler() { - return new ErrorHandler() { - public void error(SAXParseException exception) throws SAXException { - throw exception; - } - public void fatalError(SAXParseException exception) throws SAXException { - throw exception; - } + protected static ErrorHandler getErrorHandler() { + @SuppressWarnings("static-access") + ErrorHandler handler = implHelper.getRegisteredErrorHandler(); + if (handler == null) { + handler = getDefaultErrorHandler(); + } + return handler; + } + + protected static ErrorHandler getDefaultErrorHandler() { + return new ErrorHandler() { + public void error(SAXParseException exception) + throws SAXException { + throw exception; + } - public void warning(SAXParseException exception) throws SAXException { - // gulp: ignore warnings - } - }; - } - - /** - * Reads JDO configuration file, creates a Map for each persistence-manager-factory, then returns - * the map. - * - * @param url URL of a JDO configuration file compliant with javax/jdo/jdoconfig.xsd. - * @param requestedPMFName The name of the requested persistence unit (allows for fail-fast). - * @param factory The DocumentBuilderFactory to use for XML parsing. - * @return a Map<String,Map> holding persistence unit configurations; for the anonymous - * persistence unit, the value of the String key is the empty string, "". - */ - protected static Map> readNamedPMFProperties( - URL url, String requestedPMFName, DocumentBuilderFactory factory) { - requestedPMFName = requestedPMFName == null ? "" : requestedPMFName.trim(); - - Map> propertiesByName = new HashMap>(); - InputStream in = null; - try { - DocumentBuilder builder = factory.newDocumentBuilder(); - builder.setErrorHandler(getErrorHandler()); - - in = openStream(url); - Document doc = builder.parse(in); - - Element root = doc.getDocumentElement(); - if (root == null) { - throw new JDOFatalUserException( - msg.msg("EXC_InvalidJDOConfigNoRoot", url.toExternalForm())); - } + public void fatalError(SAXParseException exception) + throws SAXException { + throw exception; + } - NodeList pmfs = root.getElementsByTagName(ELEMENT_PERSISTENCE_MANAGER_FACTORY); + public void warning(SAXParseException exception) + throws SAXException { + // gulp: ignore warnings + } + }; + } - for (int i = 0; i < pmfs.getLength(); i++) { - Node pmfElement = pmfs.item(i); - Properties pmfPropertiesFromAttributes = readPropertiesFromPMFElementAttributes(pmfElement); + /** + * Reads JDO configuration file, creates a Map for each + * persistence-manager-factory, then returns the map. + * @param url URL of a JDO configuration file compliant with javax/jdo/jdoconfig.xsd. + * @param requestedPMFName The name of the requested + * persistence unit (allows for fail-fast). + * @param factory The DocumentBuilderFactory to use for XML parsing. + * @return a Map<String,Map> holding persistence unit configurations; for the + * anonymous persistence unit, the value of the String key is the empty string, "". + */ + protected static Map> readNamedPMFProperties( + URL url, + String requestedPMFName, + DocumentBuilderFactory factory) { + requestedPMFName = requestedPMFName == null + ? "" + : requestedPMFName.trim(); + + Map> + propertiesByName = new HashMap>(); + InputStream in = null; + try { + DocumentBuilder builder = factory.newDocumentBuilder(); + builder.setErrorHandler(getErrorHandler()); - Properties pmfPropertiesFromElements = readPropertiesFromPMFSubelements(pmfElement, url); + in = openStream(url); + Document doc = builder.parse(in); - // for informative error handling, get name (or names) now - String pmfNameFromAtts = pmfPropertiesFromAttributes.getProperty(PROPERTY_NAME); - String pmfNameFromElem = pmfPropertiesFromElements.getProperty(PROPERTY_NAME); + Element root = doc.getDocumentElement(); + if (root == null) { + throw new JDOFatalUserException( + msg.msg("EXC_InvalidJDOConfigNoRoot", url.toExternalForm()) + ); + } - String pmfName = null; - if (isNullOrBlank(pmfNameFromAtts)) { - // no PMF name attribute given - if (!isNullOrBlank(pmfNameFromElem)) { - // PMF name element was given - pmfName = pmfNameFromElem; - } else { - // PMF name not given at all, means the "anonymous" PMF - pmfName = ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME; - } - } else { - // PMF name given in an attribute - if (!isNullOrBlank(pmfNameFromElem)) { - // exception -- PMF name given as both att & elem + NodeList pmfs = root.getElementsByTagName( + ELEMENT_PERSISTENCE_MANAGER_FACTORY); + + for(int i = 0; i < pmfs.getLength(); i++) { + Node pmfElement = pmfs.item(i); + + Properties pmfPropertiesFromAttributes + = readPropertiesFromPMFElementAttributes(pmfElement); + + Properties pmfPropertiesFromElements + = readPropertiesFromPMFSubelements(pmfElement, url); + + // for informative error handling, get name (or names) now + String pmfNameFromAtts = + pmfPropertiesFromAttributes.getProperty(PROPERTY_NAME); + String pmfNameFromElem = + pmfPropertiesFromElements.getProperty(PROPERTY_NAME); + + String pmfName = null; + if (isNullOrBlank(pmfNameFromAtts)) { + // no PMF name attribute given + if (!isNullOrBlank(pmfNameFromElem)) { + // PMF name element was given + pmfName = pmfNameFromElem; + } + else { + // PMF name not given at all, means the "anonymous" PMF + pmfName = ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME; + } + } + else { + // PMF name given in an attribute + if (!isNullOrBlank(pmfNameFromElem)) { + // exception -- PMF name given as both att & elem + throw new JDOFatalUserException( + msg.msg( + "EXC_DuplicatePMFNamePropertyFoundWithinConfig", + pmfNameFromAtts, + pmfNameFromElem, + url.toExternalForm())); + } + pmfName = pmfNameFromAtts; + } + pmfName = pmfName == null ? "" : pmfName.trim(); + + // check for duplicate properties among atts & elems + if (requestedPMFName.equals(pmfName)) { + Iterator it = + pmfPropertiesFromAttributes.keySet().iterator(); + while (it.hasNext()) { + String property = (String) it.next(); + if (pmfPropertiesFromElements.contains(property)) { + throw new JDOFatalUserException( + msg.msg( + "EXC_DuplicatePropertyFound", + property, + pmfName, + url.toExternalForm())); + } + } + } + + // at this point, we're guaranteed not to have duplicate + // properties -- merge them + Properties pmfProps = new Properties(); + pmfProps.putAll(pmfPropertiesFromAttributes); + pmfProps.putAll(pmfPropertiesFromElements); + + // check for duplicate requested PMF name + if (pmfName.equals(requestedPMFName) + && propertiesByName.containsKey(pmfName)) { + + throw new JDOFatalUserException(msg.msg( + "EXC_DuplicateRequestedNamedPMFFoundInSameConfig", + pmfName, + url.toExternalForm())); + } + propertiesByName.put(pmfName, pmfProps); + } + return propertiesByName; + } + catch (IOException ioe) { + throw new JDOFatalUserException( + msg.msg("EXC_GetPMFIOExceptionRsrc", url.toString()), + ioe); //NOI18N + } + catch (ParserConfigurationException e) { + throw new JDOFatalInternalException( + msg.msg("EXC_ParserConfigException"), + e); + } + catch (SAXParseException e) { throw new JDOFatalUserException( msg.msg( - "EXC_DuplicatePMFNamePropertyFoundWithinConfig", - pmfNameFromAtts, - pmfNameFromElem, - url.toExternalForm())); - } - pmfName = pmfNameFromAtts; + "EXC_SAXParseException", + url.toExternalForm(), + e.getLineNumber(), + e.getColumnNumber()), + e); } - pmfName = pmfName == null ? "" : pmfName.trim(); - - // check for duplicate properties among atts & elems - if (requestedPMFName.equals(pmfName)) { - Iterator it = pmfPropertiesFromAttributes.keySet().iterator(); - while (it.hasNext()) { - String property = (String) it.next(); - if (pmfPropertiesFromElements.contains(property)) { - throw new JDOFatalUserException( - msg.msg("EXC_DuplicatePropertyFound", property, pmfName, url.toExternalForm())); - } - } + catch (SAXException e) { + throw new JDOFatalUserException( + msg.msg("EXC_SAXException", url.toExternalForm()), + e); } - - // at this point, we're guaranteed not to have duplicate - // properties -- merge them - Properties pmfProps = new Properties(); - pmfProps.putAll(pmfPropertiesFromAttributes); - pmfProps.putAll(pmfPropertiesFromElements); - - // check for duplicate requested PMF name - if (pmfName.equals(requestedPMFName) && propertiesByName.containsKey(pmfName)) { - - throw new JDOFatalUserException( - msg.msg( - "EXC_DuplicateRequestedNamedPMFFoundInSameConfig", - pmfName, - url.toExternalForm())); + catch (JDOException e) { + throw e; } - propertiesByName.put(pmfName, pmfProps); - } - return propertiesByName; - } catch (IOException ioe) { - throw new JDOFatalUserException( - msg.msg("EXC_GetPMFIOExceptionRsrc", url.toString()), ioe); // NOI18N - } catch (ParserConfigurationException e) { - throw new JDOFatalInternalException(msg.msg("EXC_ParserConfigException"), e); - } catch (SAXParseException e) { - throw new JDOFatalUserException( - msg.msg( - "EXC_SAXParseException", - url.toExternalForm(), - e.getLineNumber(), - e.getColumnNumber()), - e); - } catch (SAXException e) { - throw new JDOFatalUserException(msg.msg("EXC_SAXException", url.toExternalForm()), e); - } catch (JDOException e) { - throw e; - } catch (RuntimeException e) { - throw new JDOFatalUserException(msg.msg("EXC_SAXException", url.toExternalForm()), e); - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException ioe) { - /* gulp */ + catch (RuntimeException e) { + throw new JDOFatalUserException( + msg.msg("EXC_SAXException", url.toExternalForm()), + e); + } + finally { + if (in != null) { + try { + in.close(); + } + catch (IOException ioe) { /* gulp */ } + } } - } } - } - protected static Properties readPropertiesFromPMFElementAttributes(Node pmfElement) { - Properties p = new Properties(); - NamedNodeMap attributes = pmfElement.getAttributes(); - if (attributes == null) { - return p; - } + protected static Properties readPropertiesFromPMFElementAttributes( + Node pmfElement) { + Properties p = new Properties(); + NamedNodeMap attributes = pmfElement.getAttributes(); + if (attributes == null) { + return p; + } + + for(int i = 0; i < attributes.getLength(); i++) { + Node att = attributes.item(i); + String attName = att.getNodeName(); + String attValue = att.getNodeValue().trim(); - for (int i = 0; i < attributes.getLength(); i++) { - Node att = attributes.item(i); - String attName = att.getNodeName(); - String attValue = att.getNodeValue().trim(); + String jdoPropertyName = + (String) ATTRIBUTE_PROPERTY_XREF.get(attName); - String jdoPropertyName = (String) ATTRIBUTE_PROPERTY_XREF.get(attName); + p.put( + jdoPropertyName != null + ? jdoPropertyName + : attName, + attValue); + } - p.put(jdoPropertyName != null ? jdoPropertyName : attName, attValue); + return p; } - return p; - } + protected static Properties readPropertiesFromPMFSubelements( + Node pmfElement, URL url) { + Properties p = new Properties(); + NodeList elements = pmfElement.getChildNodes(); + if (elements == null) { + return p; + } + for(int i = 0; i < elements.getLength(); i++) { + Node element = elements.item(i); + if (element.getNodeType() != Node.ELEMENT_NODE) { + continue; + } + + String elementName = element.getNodeName(); + NamedNodeMap attributes = element.getAttributes(); + if (ELEMENT_PROPERTY.equalsIgnoreCase(elementName)) { + // + + // get the "name" attribute's value (required) + Node nameAtt = attributes.getNamedItem(PROPERTY_ATTRIBUTE_NAME); + if (nameAtt == null) { + throw new JDOFatalUserException( + msg.msg("EXC_PropertyElementHasNoNameAttribute", url)); + } + String name = nameAtt.getNodeValue().trim(); + if ("".equals(name)) { + throw new JDOFatalUserException( + msg.msg( + "EXC_PropertyElementNameAttributeHasNoValue", + name, + url)); + } + // The next call allows users to use either the + // attribute names or the + // "javax.jdo" property names in element "name" + // attributes. Handy-dandy. + String jdoPropertyName = + (String) ATTRIBUTE_PROPERTY_XREF.get(name); + + String propertyName = jdoPropertyName != null + ? jdoPropertyName + : name; + + if (p.containsKey(propertyName)) { + throw new JDOFatalUserException( + msg.msg( + "EXC_DuplicatePropertyNameGivenInPropertyElement", + propertyName, + url)); + } - protected static Properties readPropertiesFromPMFSubelements(Node pmfElement, URL url) { - Properties p = new Properties(); - NodeList elements = pmfElement.getChildNodes(); - if (elements == null) { - return p; - } - for (int i = 0; i < elements.getLength(); i++) { - Node element = elements.item(i); - if (element.getNodeType() != Node.ELEMENT_NODE) { - continue; - } + // get the "value" attribute's value (optional) + Node valueAtt = attributes.getNamedItem( + PROPERTY_ATTRIBUTE_VALUE); + String value = valueAtt == null + ? null + : valueAtt.getNodeValue().trim(); - String elementName = element.getNodeName(); - NamedNodeMap attributes = element.getAttributes(); - if (ELEMENT_PROPERTY.equalsIgnoreCase(elementName)) { - // + p.put(propertyName, value); + } + else if (ELEMENT_INSTANCE_LIFECYCLE_LISTENER.equals(elementName)) { + // + + // get the "listener" attribute's value + Node listenerAtt = attributes.getNamedItem( + INSTANCE_LIFECYCLE_LISTENER_ATTRIBUTE_LISTENER); + if (listenerAtt == null) { + throw new JDOFatalUserException( + msg.msg( + "EXC_MissingListenerAttribute", + url)); + } + String listener = listenerAtt.getNodeValue().trim(); + if ("".equals(listener)) { + throw new JDOFatalUserException( + msg.msg( + "EXC_MissingListenerAttributeValue", + url)); + } - // get the "name" attribute's value (required) - Node nameAtt = attributes.getNamedItem(PROPERTY_ATTRIBUTE_NAME); - if (nameAtt == null) { - throw new JDOFatalUserException(msg.msg("EXC_PropertyElementHasNoNameAttribute", url)); - } - String name = nameAtt.getNodeValue().trim(); - if ("".equals(name)) { - throw new JDOFatalUserException( - msg.msg("EXC_PropertyElementNameAttributeHasNoValue", name, url)); - } - // The next call allows users to use either the - // attribute names or the - // "javax.jdo" property names in element "name" - // attributes. Handy-dandy. - String jdoPropertyName = (String) ATTRIBUTE_PROPERTY_XREF.get(name); + // listener properties are of the form + // "javax.jdo.option.InstanceLifecycleListener." + listener + listener = + PROPERTY_PREFIX_INSTANCE_LIFECYCLE_LISTENER + listener; - String propertyName = jdoPropertyName != null ? jdoPropertyName : name; + // get the "classes" attribute's value (optional) + Node classesAtt = attributes.getNamedItem( + INSTANCE_LIFECYCLE_LISTENER_ATTRIBUTE_CLASSES); + String value = classesAtt == null + ? "" + : classesAtt.getNodeValue().trim(); - if (p.containsKey(propertyName)) { - throw new JDOFatalUserException( - msg.msg("EXC_DuplicatePropertyNameGivenInPropertyElement", propertyName, url)); + p.put(listener, value); + } } + return p; + } - // get the "value" attribute's value (optional) - Node valueAtt = attributes.getNamedItem(PROPERTY_ATTRIBUTE_VALUE); - String value = valueAtt == null ? null : valueAtt.getNodeValue().trim(); + protected static boolean isNullOrBlank(String s) { + return s == null || "".equals(s.trim()); + } + + /** + * Returns a {@link PersistenceManagerFactory} configured based + * on the properties stored in the file at + * propsFile. This method is equivalent to + * invoking {@link + * #getPersistenceManagerFactory(File,ClassLoader)} with + * Thread.currentThread().getContextClassLoader() as + * the loader argument. + * @since 2.0 + * @param propsFile the file containing the Properties + * @return the PersistenceManagerFactory + */ + public static PersistenceManagerFactory getPersistenceManagerFactory + (File propsFile) { + return getPersistenceManagerFactory( + propsFile, getContextClassLoader()); + } - p.put(propertyName, value); - } else if (ELEMENT_INSTANCE_LIFECYCLE_LISTENER.equals(elementName)) { - // + /** + * Returns a {@link PersistenceManagerFactory} configured based + * on the properties stored in the file at + * propsFile. Creates a {@link + * PersistenceManagerFactory} with loader. Any + * IOExceptions or + * FileNotFoundExceptions thrown during resource + * loading will be wrapped in a {@link JDOFatalUserException}. + * @since 2.0 + * @param propsFile the file containing the Properties + * @param loader the class loader to use to load the + * PersistenceManagerFactory class + * @return the PersistenceManagerFactory + */ + public static PersistenceManagerFactory getPersistenceManagerFactory + (File propsFile, ClassLoader loader) { + if (propsFile == null) + throw new JDOFatalUserException (msg.msg ( + "EXC_GetPMFNullFile")); //NOI18N - // get the "listener" attribute's value - Node listenerAtt = attributes.getNamedItem(INSTANCE_LIFECYCLE_LISTENER_ATTRIBUTE_LISTENER); - if (listenerAtt == null) { - throw new JDOFatalUserException(msg.msg("EXC_MissingListenerAttribute", url)); - } - String listener = listenerAtt.getNodeValue().trim(); - if ("".equals(listener)) { - throw new JDOFatalUserException(msg.msg("EXC_MissingListenerAttributeValue", url)); + InputStream in = null; + try { + in = new FileInputStream(propsFile); + return getPersistenceManagerFactory(in, loader); + } catch (FileNotFoundException fnfe) { + throw new JDOFatalUserException (msg.msg ( + "EXC_GetPMFNoFile", propsFile), fnfe); //NOI18N + } finally { + if (in != null) + try { + in.close (); + } catch (IOException ioe) { } } + } - // listener properties are of the form - // "javax.jdo.option.InstanceLifecycleListener." + listener - listener = PROPERTY_PREFIX_INSTANCE_LIFECYCLE_LISTENER + listener; + /** + * Returns a {@link PersistenceManagerFactory} at the JNDI + * location specified by jndiLocation in the context + * context. If context is + * null, new InitialContext() will be + * used. This method is equivalent to invoking {@link + * #getPersistenceManagerFactory(String,Context,ClassLoader)} + * with Thread.currentThread().getContextClassLoader() as + * the loader argument. + * @since 2.0 + * @param jndiLocation the JNDI location containing the + * PersistenceManagerFactory + * @param context the context in which to find the named + * PersistenceManagerFactory + * @return the PersistenceManagerFactory + */ + public static PersistenceManagerFactory getPersistenceManagerFactory + (String jndiLocation, Context context) { + return getPersistenceManagerFactory (jndiLocation, context, + getContextClassLoader()); + } - // get the "classes" attribute's value (optional) - Node classesAtt = attributes.getNamedItem(INSTANCE_LIFECYCLE_LISTENER_ATTRIBUTE_CLASSES); - String value = classesAtt == null ? "" : classesAtt.getNodeValue().trim(); - p.put(listener, value); - } - } - return p; - } - - protected static boolean isNullOrBlank(String s) { - return s == null || "".equals(s.trim()); - } - - /** - * Returns a {@link PersistenceManagerFactory} configured based on the properties stored in the - * file at propsFile. This method is equivalent to invoking {@link - * #getPersistenceManagerFactory(File,ClassLoader)} with - * Thread.currentThread().getContextClassLoader() as the loader argument. - * - * @since 2.0 - * @param propsFile the file containing the Properties - * @return the PersistenceManagerFactory - */ - public static PersistenceManagerFactory getPersistenceManagerFactory(File propsFile) { - return getPersistenceManagerFactory(propsFile, getContextClassLoader()); - } - - /** - * Returns a {@link PersistenceManagerFactory} configured based on the properties stored in the - * file at propsFile. Creates a {@link PersistenceManagerFactory} with loader - * . Any IOExceptions or FileNotFoundExceptions thrown during - * resource loading will be wrapped in a {@link JDOFatalUserException}. - * - * @since 2.0 - * @param propsFile the file containing the Properties - * @param loader the class loader to use to load the PersistenceManagerFactory class - * @return the PersistenceManagerFactory - */ - public static PersistenceManagerFactory getPersistenceManagerFactory( - File propsFile, ClassLoader loader) { - if (propsFile == null) throw new JDOFatalUserException(msg.msg("EXC_GetPMFNullFile")); // NOI18N - - InputStream in = null; - try { - in = new FileInputStream(propsFile); - return getPersistenceManagerFactory(in, loader); - } catch (FileNotFoundException fnfe) { - throw new JDOFatalUserException(msg.msg("EXC_GetPMFNoFile", propsFile), fnfe); // NOI18N - } finally { - if (in != null) + /** + * Returns a {@link PersistenceManagerFactory} at the JNDI + * location specified by jndiLocation in the context + * context. If context is + * null, new InitialContext() will be + * used. Creates a {@link PersistenceManagerFactory} with + * loader. Any NamingExceptions thrown + * will be wrapped in a {@link JDOFatalUserException}. + * @since 2.0 + * @param jndiLocation the JNDI location containing the + * PersistenceManagerFactory + * @param context the context in which to find the named + * PersistenceManagerFactory + * @param loader the class loader to use to load the + * PersistenceManagerFactory class + * @return the PersistenceManagerFactory + */ + public static PersistenceManagerFactory getPersistenceManagerFactory + (String jndiLocation, Context context, ClassLoader loader) { + if (jndiLocation == null) + throw new JDOFatalUserException (msg.msg ( + "EXC_GetPMFNullJndiLoc")); //NOI18N + if (loader == null) + throw new JDOFatalUserException (msg.msg ( + "EXC_GetPMFNullLoader")); //NOI18N try { - in.close(); - } catch (IOException ioe) { + if (context == null) + context = new InitialContext (); + + Object o = context.lookup (jndiLocation); + return (PersistenceManagerFactory) PortableRemoteObject.narrow + (o, PersistenceManagerFactory.class); + } catch (NamingException ne) { + throw new JDOFatalUserException (msg.msg ( + "EXC_GetPMFNamingException", jndiLocation, loader), ne); //NOI18N } } - } - - /** - * Returns a {@link PersistenceManagerFactory} at the JNDI location specified by - * jndiLocation in the context context. If context is null - * , new InitialContext() will be used. This method is equivalent to invoking - * {@link #getPersistenceManagerFactory(String,Context,ClassLoader)} with - * Thread.currentThread().getContextClassLoader() as the loader argument. - * - * @since 2.0 - * @param jndiLocation the JNDI location containing the PersistenceManagerFactory - * @param context the context in which to find the named PersistenceManagerFactory - * @return the PersistenceManagerFactory - */ - public static PersistenceManagerFactory getPersistenceManagerFactory( - String jndiLocation, Context context) { - return getPersistenceManagerFactory(jndiLocation, context, getContextClassLoader()); - } - - /** - * Returns a {@link PersistenceManagerFactory} at the JNDI location specified by - * jndiLocation in the context context. If context is null - * , new InitialContext() will be used. Creates a {@link - * PersistenceManagerFactory} with loader. Any NamingExceptions thrown - * will be wrapped in a {@link JDOFatalUserException}. - * - * @since 2.0 - * @param jndiLocation the JNDI location containing the PersistenceManagerFactory - * @param context the context in which to find the named PersistenceManagerFactory - * @param loader the class loader to use to load the PersistenceManagerFactory class - * @return the PersistenceManagerFactory - */ - public static PersistenceManagerFactory getPersistenceManagerFactory( - String jndiLocation, Context context, ClassLoader loader) { - if (jndiLocation == null) - throw new JDOFatalUserException(msg.msg("EXC_GetPMFNullJndiLoc")); // NOI18N - if (loader == null) throw new JDOFatalUserException(msg.msg("EXC_GetPMFNullLoader")); // NOI18N - try { - if (context == null) context = new InitialContext(); - - Object o = context.lookup(jndiLocation); - return (PersistenceManagerFactory) - PortableRemoteObject.narrow(o, PersistenceManagerFactory.class); - } catch (NamingException ne) { - throw new JDOFatalUserException( - msg.msg("EXC_GetPMFNamingException", jndiLocation, loader), ne); // NOI18N + + /** + * Returns a {@link PersistenceManagerFactory} configured based + * on the Properties stored in the input stream at + * stream. This method is equivalent to + * invoking {@link + * #getPersistenceManagerFactory(InputStream,ClassLoader)} with + * Thread.currentThread().getContextClassLoader() as + * the loader argument. + * @since 2.0 + * @param stream the stream containing the Properties + * @return the PersistenceManagerFactory + */ + public static PersistenceManagerFactory getPersistenceManagerFactory + (InputStream stream) { + return getPersistenceManagerFactory( + stream, getContextClassLoader()); } - } - - /** - * Returns a {@link PersistenceManagerFactory} configured based on the Properties stored in the - * input stream at stream. This method is equivalent to invoking {@link - * #getPersistenceManagerFactory(InputStream,ClassLoader)} with - * Thread.currentThread().getContextClassLoader() as the loader argument. - * - * @since 2.0 - * @param stream the stream containing the Properties - * @return the PersistenceManagerFactory - */ - public static PersistenceManagerFactory getPersistenceManagerFactory(InputStream stream) { - return getPersistenceManagerFactory(stream, getContextClassLoader()); - } - - /** - * Returns a {@link PersistenceManagerFactory} configured based on the Properties stored in the - * input stream at stream. Creates a {@link PersistenceManagerFactory} with - * loader. Any IOExceptions thrown during resource loading will be wrapped in - * a {@link JDOFatalUserException}. - * - * @since 2.0 - * @param stream the stream containing the Properties - * @param loader the class loader to use to load the PersistenceManagerFactory class - * @return the PersistenceManagerFactory - */ - public static PersistenceManagerFactory getPersistenceManagerFactory( - InputStream stream, ClassLoader loader) { - if (stream == null) throw new JDOFatalUserException(msg.msg("EXC_GetPMFNullStream")); // NOI18N - - Properties props = new Properties(); - try { - props.load(stream); - } catch (IOException ioe) { - throw new JDOFatalUserException(msg.msg("EXC_GetPMFIOExceptionStream"), ioe); // NOI18N + + /** + * Returns a {@link PersistenceManagerFactory} configured based + * on the Properties stored in the input stream at + * stream. Creates a {@link + * PersistenceManagerFactory} with loader. Any + * IOExceptions thrown during resource + * loading will be wrapped in a {@link JDOFatalUserException}. + * @since 2.0 + * @param stream the stream containing the Properties + * @param loader the class loader to use to load the + * PersistenceManagerFactory class + * @return the PersistenceManagerFactory + */ + public static PersistenceManagerFactory getPersistenceManagerFactory + (InputStream stream, ClassLoader loader) { + if (stream == null) + throw new JDOFatalUserException (msg.msg ( + "EXC_GetPMFNullStream")); //NOI18N + + Properties props = new Properties (); + try { + props.load (stream); + } catch (IOException ioe) { + throw new JDOFatalUserException + (msg.msg ("EXC_GetPMFIOExceptionStream"), ioe); //NOI18N + } + return getPersistenceManagerFactory (props, loader); } - return getPersistenceManagerFactory(props, loader); - } - - /** - * Get a JDOEnhancer using the available enhancer(s) specified in - * "META-INF/services/JDOEnhancer" using the context class loader. - * - * @return the JDOEnhancer. - * @throws JDOFatalUserException if no available enhancer - * @since 3.0 - */ - public static JDOEnhancer getEnhancer() { - return getEnhancer(getContextClassLoader()); - } - - /** - * Get a JDOEnhancer using the available enhancer(s) specified in - * "META-INF/services/JDOEnhancer" - * - * @param loader the loader to use for loading the JDOEnhancer class (if any) - * @return the JDOEnhancer. - * @throws JDOFatalUserException if no available enhancer - * @since 3.0 - */ - public static JDOEnhancer getEnhancer(ClassLoader loader) { - ClassLoader ctrLoader = loader; - if (ctrLoader == null) { - ctrLoader = Thread.currentThread().getContextClassLoader(); + + /** + * Get a JDOEnhancer using the available enhancer(s) specified in + * "META-INF/services/JDOEnhancer" using the context class loader. + * @return the JDOEnhancer. + * @throws JDOFatalUserException if no available enhancer + * @since 3.0 + */ + public static JDOEnhancer getEnhancer() { + return getEnhancer(getContextClassLoader()); } + /** + * Get a JDOEnhancer using the available enhancer(s) specified in + * "META-INF/services/JDOEnhancer" + * @param loader the loader to use for loading the JDOEnhancer class (if any) + * @return the JDOEnhancer. + * @throws JDOFatalUserException if no available enhancer + * @since 3.0 + */ + public static JDOEnhancer getEnhancer(ClassLoader loader) { + ClassLoader ctrLoader = loader; + if (ctrLoader == null) { + ctrLoader = Thread.currentThread().getContextClassLoader(); + } + /* * If you have a jar file that provides the jdo enhancer implementation, - * a file naming the implementation goes into the file + * a file naming the implementation goes into the file * packaged into the jar file, called "META-INF/services/javax.jdo.JDOEnhancer". * The contents of the file is a string that is the enhancer class name. * For each file in the class loader named "META-INF/services/javax.jdo.JDOEnhancer", @@ -1683,191 +1877,207 @@ public static JDOEnhancer getEnhancer(ClassLoader loader) { * the invocation returns an instance. * Otherwise add the exception thrown to an exception list. */ - ArrayList exceptions = new ArrayList(); - int numberOfJDOEnhancers = 0; - try { - Enumeration urls = getResources(loader, SERVICE_LOOKUP_ENHANCER_RESOURCE_NAME); - if (urls != null) { - while (urls.hasMoreElements()) { - numberOfJDOEnhancers++; - try { - String enhancerClassName = getClassNameFromURL((URL) urls.nextElement()); - Class enhancerClass = forName(enhancerClassName, true, ctrLoader); - JDOEnhancer enhancer = (JDOEnhancer) enhancerClass.newInstance(); - return enhancer; - } catch (Throwable ex) { - // remember exceptions from failed enhancer invocations + ArrayList exceptions = new ArrayList(); + int numberOfJDOEnhancers = 0; + try { + Enumeration urls = getResources(loader, SERVICE_LOOKUP_ENHANCER_RESOURCE_NAME); + if (urls != null) { + while (urls.hasMoreElements()) { + numberOfJDOEnhancers++; + try { + String enhancerClassName = getClassNameFromURL((URL)urls.nextElement()); + Class enhancerClass = forName(enhancerClassName, true, ctrLoader); + JDOEnhancer enhancer = (JDOEnhancer)enhancerClass.newInstance(); + return enhancer; + } catch (Throwable ex) { + // remember exceptions from failed enhancer invocations + exceptions.add(ex); + } + } + } + } catch (Throwable ex) { exceptions.add(ex); - } } - } - } catch (Throwable ex) { - exceptions.add(ex); + + throw new JDOFatalUserException(msg.msg("EXC_GetEnhancerNoValidEnhancerAvailable", numberOfJDOEnhancers), + (Throwable[])exceptions.toArray(new Throwable[exceptions.size()])); } - throw new JDOFatalUserException( - msg.msg("EXC_GetEnhancerNoValidEnhancerAvailable", numberOfJDOEnhancers), - (Throwable[]) exceptions.toArray(new Throwable[exceptions.size()])); - } - - /** - * Get the context class loader associated with the current thread. This is done in a doPrivileged - * block because it is a secure method. - * - * @return the current thread's context class loader. - * @since 2.0 - */ - private static ClassLoader getContextClassLoader() { - return doPrivileged( - new PrivilegedAction() { - public ClassLoader run() { - return Thread.currentThread().getContextClassLoader(); - } - }); - } - - /** - * Get the named resource as a stream from the resource loader. Perform this operation in a - * doPrivileged block. - */ - private static InputStream getResourceAsStream( - final ClassLoader resourceLoader, final String name) { - return doPrivileged( - new PrivilegedAction() { - public InputStream run() { - return resourceLoader.getResourceAsStream(name); - } - }); - } - - /** - * Get the named Method from the named class. Perform this operation in a doPrivileged block. - * - * @param implClass the class - * @param methodName the name of the method - * @param parameterTypes the parameter types of the method - * @return the Method instance - */ - private static Method getMethod( - final Class implClass, final String methodName, final Class[] parameterTypes) - throws NoSuchMethodException { - try { - return doPrivileged( - new PrivilegedExceptionAction() { - public Method run() throws NoSuchMethodException { - return implClass.getMethod(methodName, parameterTypes); + /** Get the context class loader associated with the current thread. + * This is done in a doPrivileged block because it is a secure method. + * @return the current thread's context class loader. + * @since 2.0 + */ + private static ClassLoader getContextClassLoader() { + return doPrivileged( + new PrivilegedAction () { + public ClassLoader run () { + return Thread.currentThread().getContextClassLoader(); + } } - }); - } catch (PrivilegedActionException ex) { - throw (NoSuchMethodException) ex.getException(); + ); } - } - - /** Invoke the method. Perform this operation in a doPrivileged block. */ - private static Object invoke( - final Method method, final Object instance, final Object[] parameters) - throws IllegalAccessException, InvocationTargetException { - try { - return (Object) - doPrivileged( - new PrivilegedExceptionAction() { - public Object run() throws IllegalAccessException, InvocationTargetException { - return method.invoke(instance, parameters); + + /** Get the named resource as a stream from the resource loader. + * Perform this operation in a doPrivileged block. + */ + private static InputStream getResourceAsStream( + final ClassLoader resourceLoader, final String name) { + return doPrivileged( + new PrivilegedAction() { + public InputStream run() { + return resourceLoader.getResourceAsStream(name); } - }); - } catch (PrivilegedActionException ex) { - Exception cause = (Exception) ex.getException(); - if (cause instanceof IllegalAccessException) throw (IllegalAccessException) cause; - else // if (cause instanceof InvocationTargetException) - throw (InvocationTargetException) cause; - } - } - - /** - * Get resources of the resource loader. Perform this operation in a doPrivileged block. - * - * @param resourceLoader ClassLoader to use for loading resources - * @param resourceName Name of the resource - * @return the resources - * @throws IOException if an error occurs accessing the resources - */ - protected static Enumeration getResources( - final ClassLoader resourceLoader, final String resourceName) throws IOException { - try { - return doPrivileged( - new PrivilegedExceptionAction>() { - public Enumeration run() throws IOException { - return resourceLoader.getResources(resourceName); } - }); - } catch (PrivilegedActionException ex) { - throw (IOException) ex.getException(); + ); } - } - - /** - * Get the named class. Perform this operation in a doPrivileged block. - * - * @param name the name of the class - * @param init whether to initialize the class - * @param loader which class loader to use - * @return the class - */ - private static Class forName(final String name, final boolean init, final ClassLoader loader) - throws ClassNotFoundException { - try { - return doPrivileged( - new PrivilegedExceptionAction>() { - public Class run() throws ClassNotFoundException { - return Class.forName(name, init, loader); - } - }); - } catch (PrivilegedActionException ex) { - throw (ClassNotFoundException) ex.getException(); + + + /** Get the named Method from the named class. + * Perform this operation in a doPrivileged block. + * + * @param implClass the class + * @param methodName the name of the method + * @param parameterTypes the parameter types of the method + * @return the Method instance + */ + private static Method getMethod( + final Class implClass, + final String methodName, + final Class[] parameterTypes) + throws NoSuchMethodException { + try { + return doPrivileged( + new PrivilegedExceptionAction() { + public Method run() throws NoSuchMethodException { + return implClass.getMethod(methodName, parameterTypes); + } + } + ); + } catch (PrivilegedActionException ex) { + throw (NoSuchMethodException)ex.getException(); + } } - } - - /** - * Open an input stream on the url. Perform this operation in a doPrivileged block. - * - * @param url - * @return the input stream - */ - private static InputStream openStream(final URL url) throws IOException { - try { - return doPrivileged( - new PrivilegedExceptionAction() { - public InputStream run() throws IOException { - return url.openStream(); - } - }); - } catch (PrivilegedActionException ex) { - throw (IOException) ex.getException(); + + /** Invoke the method. + * Perform this operation in a doPrivileged block. + */ + private static Object invoke(final Method method, + final Object instance, final Object[] parameters) + throws IllegalAccessException, InvocationTargetException { + try { + return (Object) doPrivileged( + new PrivilegedExceptionAction() { + public Object run() + throws IllegalAccessException, + InvocationTargetException { + return method.invoke (instance, parameters); + } + } + ); + } catch (PrivilegedActionException ex) { + Exception cause = (Exception)ex.getException(); + if (cause instanceof IllegalAccessException) + throw (IllegalAccessException)cause; + else //if (cause instanceof InvocationTargetException) + throw (InvocationTargetException)cause; + } } - } - - @SuppressWarnings("unchecked") - private static T doPrivileged(PrivilegedAction privilegedAction) { - try { - return (T) LegacyJava.doPrivilegedAction.invoke(null, privilegedAction); - } catch (IllegalAccessException | InvocationTargetException e) { - if (e.getCause() instanceof RuntimeException) { - throw (RuntimeException) e.getCause(); - } - throw new JDOFatalInternalException(e.getMessage()); + + /** + * Get resources of the resource loader. + * Perform this operation in a doPrivileged block. + * @param resourceLoader ClassLoader to use for loading resources + * @param resourceName Name of the resource + * @return the resources + * @throws IOException if an error occurs accessing the resources + */ + protected static Enumeration getResources( + final ClassLoader resourceLoader, + final String resourceName) + throws IOException { + try { + return doPrivileged( + new PrivilegedExceptionAction>() { + public Enumeration run() throws IOException { + return resourceLoader.getResources(resourceName); + } + } + ); + } catch (PrivilegedActionException ex) { + throw (IOException)ex.getException(); + } } - } - - @SuppressWarnings("unchecked") - private static T doPrivileged(PrivilegedExceptionAction privilegedAction) - throws PrivilegedActionException { - try { - return (T) LegacyJava.doPrivilegedExceptionAction.invoke(null, privilegedAction); - } catch (IllegalAccessException | InvocationTargetException e) { - if (e.getCause() instanceof PrivilegedActionException) { - throw (PrivilegedActionException) e.getCause(); - } - throw new PrivilegedActionException(e); + + /** + * Get the named class. + * Perform this operation in a doPrivileged block. + * @param name the name of the class + * @param init whether to initialize the class + * @param loader which class loader to use + * @return the class + */ + private static Class forName( + final String name, + final boolean init, + final ClassLoader loader) + throws ClassNotFoundException { + try { + return doPrivileged( + new PrivilegedExceptionAction>() { + public Class run() throws ClassNotFoundException { + return Class.forName(name, init, loader); + } + } + ); + } catch (PrivilegedActionException ex) { + throw (ClassNotFoundException)ex.getException(); + } + } + + /** Open an input stream on the url. + * Perform this operation in a doPrivileged block. + * + * @param url + * @return the input stream + */ + private static InputStream openStream(final URL url) + throws IOException { + try { + return doPrivileged( + new PrivilegedExceptionAction() { + public InputStream run() throws IOException { + return url.openStream(); + } + } + ); + } catch (PrivilegedActionException ex) { + throw (IOException)ex.getException(); + } + } + + @SuppressWarnings("unchecked") + private static T doPrivileged(PrivilegedAction privilegedAction) { + try { + return (T) LegacyJava.doPrivilegedAction.invoke(null, privilegedAction); + } catch (IllegalAccessException | InvocationTargetException e) { + if (e.getCause() instanceof RuntimeException) { + throw (RuntimeException) e.getCause(); + } + throw new JDOFatalInternalException(e.getMessage()); + } + } + + @SuppressWarnings("unchecked") + private static T doPrivileged(PrivilegedExceptionAction privilegedAction) + throws PrivilegedActionException { + try { + return (T) LegacyJava.doPrivilegedExceptionAction.invoke(null, privilegedAction); + } catch (IllegalAccessException | InvocationTargetException e) { + if (e.getCause() instanceof PrivilegedActionException) { + throw (PrivilegedActionException) e.getCause(); + } + throw new PrivilegedActionException(e); + } } - } } diff --git a/api/src/main/java/javax/jdo/JDONullIdentityException.java b/api/src/main/java/javax/jdo/JDONullIdentityException.java index 5add98f5a..4086470ec 100644 --- a/api/src/main/java/javax/jdo/JDONullIdentityException.java +++ b/api/src/main/java/javax/jdo/JDONullIdentityException.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -22,60 +22,59 @@ package javax.jdo; -/** - * An instance of this class is thrown when attempting to create an object id when the object id - * constructor parameter is null. This might occur when creating an object id instance from a - * transient instance where an identity field is null. +/** An instance of this class is thrown when attempting to create an object id + * when the object id constructor parameter is null. This might occur when + * creating an object id instance from a transient instance where an identity + * field is null. * * @since 2.0 * @version 2.0 */ public class JDONullIdentityException extends JDOUserException { - private static final long serialVersionUID = 8912096213726707815L; + private static final long serialVersionUID = 8912096213726707815L; - /** Constructs a new JDONullIdentityException without a detail message. */ - public JDONullIdentityException() {} + /** + * Constructs a new JDONullIdentityException without a detail message. + */ + public JDONullIdentityException() { + } - /** - * Constructs a new JDONullIdentityException with the specified detail message. - * - * @param msg the detail message. - */ - public JDONullIdentityException(String msg) { - super(msg); - } + /** + * Constructs a new JDONullIdentityException with the specified detail message. + * @param msg the detail message. + */ + public JDONullIdentityException(String msg) { + super(msg); + } - /** - * Constructs a new JDONullIdentityException with the specified detail message and - * failed object. - * - * @param msg the detail message. - * @param failed the failed object. - */ - public JDONullIdentityException(String msg, Object failed) { - super(msg, failed); - } + /** + * Constructs a new JDONullIdentityException with the specified detail message + * and failed object. + * @param msg the detail message. + * @param failed the failed object. + */ + public JDONullIdentityException(String msg, Object failed) { + super(msg, failed); + } - /** - * Constructs a new JDONullIdentityException with the specified detail message and - * nested Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - */ - public JDONullIdentityException(String msg, Throwable[] nested) { - super(msg, nested); - } + /** + * Constructs a new JDONullIdentityException with the specified + * detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable[]. + */ + public JDONullIdentityException(String msg, Throwable[] nested) { + super(msg, nested); + } - /** - * Constructs a new JDONullIdentityException with the specified detail message and - * nested Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable. - */ - public JDONullIdentityException(String msg, Throwable nested) { - super(msg, nested); - } + /** + * Constructs a new JDONullIdentityException with the specified detail message + * and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable. + */ + public JDONullIdentityException(String msg, Throwable nested) { + super(msg, nested); + } } diff --git a/api/src/main/java/javax/jdo/JDOObjectNotFoundException.java b/api/src/main/java/javax/jdo/JDOObjectNotFoundException.java index 0ef7ef245..e6f5ec20c 100644 --- a/api/src/main/java/javax/jdo/JDOObjectNotFoundException.java +++ b/api/src/main/java/javax/jdo/JDOObjectNotFoundException.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -22,83 +22,80 @@ package javax.jdo; -/** - * This class represents exceptions caused by the user accessing an object that does not exist in - * the datastore. +/** This class represents exceptions caused by the user accessing + * an object that does not exist in the datastore. * * @since 1.0.1 * @version 1.0.1 */ public class JDOObjectNotFoundException extends JDODataStoreException { - private static final long serialVersionUID = 1367920495587689648L; + private static final long serialVersionUID = 1367920495587689648L; - /** Constructs a new JDOObjectNotFoundException without a detail message. */ - public JDOObjectNotFoundException() {} + /** + * Constructs a new JDOObjectNotFoundException without a detail message. + */ + public JDOObjectNotFoundException() { + } - /** - * Constructs a new JDOObjectNotFoundException with the specified detail message. - * - * @param msg the detail message. - */ - public JDOObjectNotFoundException(String msg) { - super(msg); - } + /** + * Constructs a new JDOObjectNotFoundException + * with the specified detail message. + * @param msg the detail message. + */ + public JDOObjectNotFoundException(String msg) { + super(msg); + } - /** - * Constructs a new JDOObjectNotFoundException with the specified detail message and - * failed object. - * - * @param msg the detail message. - * @param failed the failed object. - */ - public JDOObjectNotFoundException(String msg, Object failed) { - super(msg, failed); - } + /** Constructs a new JDOObjectNotFoundException with the specified detail message + * and failed object. + * @param msg the detail message. + * @param failed the failed object. + */ + public JDOObjectNotFoundException(String msg, Object failed) { + super(msg, failed); + } - /** - * Constructs a new JDOObjectNotFoundException with the specified detail message and - * nested Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable. - */ - public JDOObjectNotFoundException(String msg, Throwable nested) { - super(msg, nested); - } + /** + * Constructs a new JDOObjectNotFoundException with the + * specified detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable. + */ + public JDOObjectNotFoundException(String msg, Throwable nested) { + super(msg, nested); + } - /** - * Constructs a new JDOObjectNotFoundException with the specified detail message and - * nested Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - */ - public JDOObjectNotFoundException(String msg, Throwable[] nested) { - super(msg, nested); - } + /** + * Constructs a new JDOObjectNotFoundException with the + * specified detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable[]. + */ + public JDOObjectNotFoundException(String msg, Throwable[] nested) { + super(msg, nested); + } - /** - * Constructs a new JDOObjectNotFoundException with the specified detail message, - * nested Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - * @param failed the failed object. - */ - public JDOObjectNotFoundException(String msg, Throwable[] nested, Object failed) { - super(msg, nested, failed); - } + /** + * Constructs a new JDOObjectNotFoundException with the specified + * detail message, nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable[]. + * @param failed the failed object. + */ + public JDOObjectNotFoundException(String msg, Throwable[] nested, Object failed) { + super(msg, nested, failed); + } - /** - * Constructs a new JDOFatalInternalException with the specified detail message, - * nested Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable. - * @param failed the failed object. - */ - public JDOObjectNotFoundException(String msg, Throwable nested, Object failed) { - super(msg, nested, failed); - } + /** + * Constructs a new JDOFatalInternalException with the specified + * detail message, nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable. + * @param failed the failed object. + */ + public JDOObjectNotFoundException(String msg, Throwable nested, Object failed) { + super(msg, nested, failed); + } } + diff --git a/api/src/main/java/javax/jdo/JDOOptimisticVerificationException.java b/api/src/main/java/javax/jdo/JDOOptimisticVerificationException.java index 69d8dd99b..11208d28f 100644 --- a/api/src/main/java/javax/jdo/JDOOptimisticVerificationException.java +++ b/api/src/main/java/javax/jdo/JDOOptimisticVerificationException.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -22,73 +22,71 @@ package javax.jdo; -/** - * This class represents optimistic verification failures. The nested exception array contains an - * exception for each instance that failed the optimistic verification. +/** This class represents optimistic verification failures. The nested + * exception array contains an exception for each instance that failed + * the optimistic verification. * * @since 1.0.1 * @version 1.0.1 */ public class JDOOptimisticVerificationException extends JDOFatalDataStoreException { - private static final long serialVersionUID = 7434635765817151133L; - - /** Constructs a new JDOOptimisticVerificationException without a detail message. */ - public JDOOptimisticVerificationException() {} + private static final long serialVersionUID = 7434635765817151133L; - /** - * Constructs a new JDOOptimisticVerificationException with the specified detail - * message. - * - * @param msg the detail message. - */ - public JDOOptimisticVerificationException(String msg) { - super(msg); - } + /** + * Constructs a new JDOOptimisticVerificationException without a detail message. + */ + public JDOOptimisticVerificationException() { + } - /** - * Constructs a new JDOOptimisticVerificationException with the specified detail - * message and failed object. - * - * @param msg the detail message. - * @param failed the failed object. - */ - public JDOOptimisticVerificationException(String msg, Object failed) { - super(msg, failed); - } + /** + * Constructs a new JDOOptimisticVerificationException with the + * specified detail message. + * @param msg the detail message. + */ + public JDOOptimisticVerificationException(String msg) { + super(msg); + } - /** - * Constructs a new JDOOptimisticVerificationException with the specified detail - * message and nested Throwable[]s. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - */ - public JDOOptimisticVerificationException(String msg, Throwable[] nested) { - super(msg, nested); - } + /** Constructs a new JDOOptimisticVerificationException with the + * specified detail message and failed object. + * @param msg the detail message. + * @param failed the failed object. + */ + public JDOOptimisticVerificationException(String msg, Object failed) { + super(msg, failed); + } + + /** + * Constructs a new JDOOptimisticVerificationException with the + * specified detail message and nested Throwable[]s. + * @param msg the detail message. + * @param nested the nested Throwable[]. + */ + public JDOOptimisticVerificationException(String msg, Throwable[] nested) { + super(msg, nested); + } + + /** + * Constructs a new JDOOptimisticVerificationException with the specified + * detail message, nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable[]. + * @param failed the failed object. + */ + public JDOOptimisticVerificationException(String msg, Throwable[] nested, Object failed) { + super(msg, nested, failed); + } - /** - * Constructs a new JDOOptimisticVerificationException with the specified detail - * message, nested Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - * @param failed the failed object. - */ - public JDOOptimisticVerificationException(String msg, Throwable[] nested, Object failed) { - super(msg, nested, failed); - } - - /** - * Constructs a new JDOOptimisticVerificationException with the specified detail - * message, nested Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable. - * @param failed the failed object. - */ - public JDOOptimisticVerificationException(String msg, Throwable nested, Object failed) { - super(msg, nested, failed); - } + /** + * Constructs a new JDOOptimisticVerificationException with the specified + * detail message, nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable. + * @param failed the failed object. + */ + public JDOOptimisticVerificationException(String msg, Throwable nested, Object failed) { + super(msg, nested, failed); + } } + diff --git a/api/src/main/java/javax/jdo/JDOQLTypedQuery.java b/api/src/main/java/javax/jdo/JDOQLTypedQuery.java index edf9ae3af..2fd1accdd 100644 --- a/api/src/main/java/javax/jdo/JDOQLTypedQuery.java +++ b/api/src/main/java/javax/jdo/JDOQLTypedQuery.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo; @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; + import javax.jdo.query.BooleanExpression; import javax.jdo.query.CharacterExpression; import javax.jdo.query.CollectionExpression; @@ -39,645 +40,550 @@ /** * Interface for a type-safe refactorable JDOQL query, using a fluent API, based around expressions. * Note that a JDOQLTypedQuery only supports named parameters, and the values of these parameters - * should be set using the relevant setter methods prior to execution, and that the values for the + * should be set using the relevant setter methods prior to execution, and that the values for the * parameters will only be retained until the subsequent query execution. - * + * * @param candidate type for this query */ public interface JDOQLTypedQuery extends Serializable, Closeable { - public static final String QUERY_CLASS_PREFIX = "Q"; - - /** - * Method to return an expression for the candidate of the query. Cast the returned expression to - * the candidate "Q" type to be able to call methods on it. This calls the method - * "Q{type}.candidate(null)" The preference is to use the "Q{type}.candidate()" method for real - * type-safe handling. - * - * @return Expression for the candidate - */ - PersistableExpression candidate(); - - /** - * Method to return a parameter for the query. Cast the returned parameter to the right type to be - * able to call methods on it. The preference is to use the "xxxParameter(String)" methods for - * real type-safe handling. - * - * @param name Name of the parameter - * @param type Java type of the parameter - * @return Expression for the parameter - * @param

    type for the parameter - */ -

    Expression

    parameter(String name, Class

    type); - - /** - * Method to return a string parameter for the query. - * - * @param name Name of the parameter - * @return StringExpression for the parameter - */ - StringExpression stringParameter(String name); - - /** - * Method to return a character parameter for the query. - * - * @param name Name of the parameter - * @return Expression for the parameter - */ - CharacterExpression characterParameter(String name); - - /** - * Method to return a numeric parameter for the query. - * - * @param name Name of the parameter - * @return NumericExpression for the parameter - */ - NumericExpression numericParameter(String name); - - /** - * Method to return a numeric parameter for the query. - * - * @param name Name of the parameter - * @param type Type of the numeric parameter - * @param Type for the numeric parameter - * @return NumericExpression for the parameter - */ - @SuppressWarnings("unchecked") - default NumericExpression numericParameter(String name, Class type) { - return (NumericExpression) numericParameter(name); - } - - /** - * Method to return a date parameter for the query. - * - * @param name Name of the parameter - * @return Expression for the parameter - */ - DateExpression dateParameter(String name); - - /** - * Method to return a time parameter for the query. - * - * @param name Name of the parameter - * @return Expression for the parameter - */ - TimeExpression timeParameter(String name); - - /** - * Method to return a datetime parameter for the query. - * - * @param name Name of the parameter - * @return Expression for the parameter - */ - DateTimeExpression datetimeParameter(String name); - - /** - * Method to return a collection parameter for the query. - * - * @param name Name of the parameter - * @return Expression for the parameter - */ - CollectionExpression collectionParameter(String name); - - /** - * Method to return a collection parameter for the query. - * - * @param name Name of the parameter - * @param elementType Element type of the collection parameter - * @param Element type for the collection parameter - * @return Expression for the parameter - */ - @SuppressWarnings("unchecked") - default CollectionExpression, E> collectionParameter( - String name, Class elementType) { - return (CollectionExpression, E>) collectionParameter(name); - } - - /** - * Method to return a map parameter for the query. - * - * @param name Name of the parameter - * @return Expression for the parameter - */ - MapExpression mapParameter(String name); - - /** - * Method to return a map parameter for the query. - * - * @param name Name of the parameter - * @param keyType Key type of the map parameter - * @param valueType Value type of the map parameter - * @param Key type for the map parameter - * @param Value type for the map parameter - * @return Expression for the parameter - */ - @SuppressWarnings("unchecked") - default MapExpression, K, V> mapParameter( - String name, Class keyType, Class valueType) { - return (MapExpression, K, V>) mapParameter(name); - } - - /** - * Method to return a list parameter for the query. - * - * @param name Name of the parameter - * @return Expression for the parameter - */ - ListExpression listParameter(String name); - - /** - * Method to return a list parameter for the query. - * - * @param name Name of the parameter - * @param elementType Element type of the list parameter - * @param Element type for the list parameter - * @return Expression for the parameter - */ - @SuppressWarnings("unchecked") - default ListExpression, E> listParameter(String name, Class elementType) { - return (ListExpression, E>) listParameter(name); - } - - /** - * Method to return a variable for this query. Cast the returned variable to the right type to be - * able to call methods on it. - * - * @param name Name of the variable - * @param type Type of the variable - * @return Expression for the variable - * @param type for the variable - */ - Expression variable(String name, Class type); - - /** - * Method to set the candidates to use over which we are querying. If no candidates are set then - * the query is performed on the datastore. - * - * @param candidates The candidates - * @return The query - */ - JDOQLTypedQuery setCandidates(Collection candidates); - - /** - * Method to remove subclasses (of the candidate) from the query - * - * @return The query - */ - JDOQLTypedQuery excludeSubclasses(); - - /** - * Method to include subclasses (of the candidate) to the query - * - * @return The query - */ - JDOQLTypedQuery includeSubclasses(); - - /** - * Method to set the filter of the query. - * - * @param expr Filter expression - * @return The query - */ - JDOQLTypedQuery filter(BooleanExpression expr); - - /** - * Method to return an "IF (...) ... ELSE ..." expression for use in this query. - * - * @param type The type returned by the IfElse. - * @param cond The if condition - * @param thenValueExpr Expression for value to return when the if expression is met - * @param elseValueExpr Expression for value to return when the if expression is not met - * @param type for the IfThenElseExpression - * @return The IfThenElse expression - */ - IfThenElseExpression ifThenElse( - Class type, - BooleanExpression cond, - Expression thenValueExpr, - Expression elseValueExpr); - - /** - * Method to return an "IF (...) ... ELSE ..." expression for use in this query. - * - * @param cond The if condition - * @param thenValue Value to return when the if expression is met - * @param elseValueExpr Expression to return when the if expression is not met - * @param type for the IfThenElseExpression - * @return The IfThenElse expression - */ - IfThenElseExpression ifThenElse( - BooleanExpression cond, V thenValue, Expression elseValueExpr); - - /** - * Method to return an "IF (...) ... ELSE ..." expression for use in this query. - * - * @param cond The if condition - * @param thenValueExpr Expression to return when the if expression is met - * @param elseValue Value to return when the if expression is not met - * @param type for the IfThenElseExpression - * @return The IfThenElse expression - */ - IfThenElseExpression ifThenElse( - BooleanExpression cond, Expression thenValueExpr, V elseValue); - - /** - * Method to return an "IF (...) ... ELSE ..." expression for use in this query. - * - * @param cond The if condition - * @param thenValue Value to return when the if expression is met - * @param elseValue Value to return when the if expression is not met - * @param type for the IfThenElseExpression - * @return The IfThenElse expression - */ - IfThenElseExpression ifThenElse(BooleanExpression cond, V thenValue, V elseValue); - - /** - * Method to return an "IF (...) ... ELSE ..." expression for use in this query. - * - * @param type The type returned by the IfElse. - * @param cond The if condition - * @param thenValueExpr Expression for value to return when the if expression is met - * @param type for the IfThenElseExpression - * @return The IfThenElse expression - */ - IfThenElseExpression ifThen( - Class type, BooleanExpression cond, Expression thenValueExpr); - - /** - * Method to return an "IF (...) ... ELSE ..." expression for use in this query. - * - * @param cond The if condition - * @param thenValue Value to return when the if expression is met - * @param type for the IfThenElseExpression - * @return The IfThenElse expression - */ - IfThenElseExpression ifThen(BooleanExpression cond, V thenValue); - - /** - * Method to set the grouping(s) for the query. - * - * @param exprs Grouping expression(s) - * @return The query - */ - JDOQLTypedQuery groupBy(Expression... exprs); - - /** - * Method to set the having clause of the query. - * - * @param expr Having expression - * @return The query - */ - JDOQLTypedQuery having(Expression expr); - - /** - * Method to set the ordering of the query. - * - * @param orderExprs Ordering expression(s) - * @return The query - */ - JDOQLTypedQuery orderBy(OrderExpression... orderExprs); - - /** - * Method to set the result of the query. - * - * @param distinct Whether results are distinct - * @param exprs The result expressions - * @return The query - */ - JDOQLTypedQuery result(boolean distinct, Expression... exprs); - - /** - * Method to set the range of any required results, using expressions. - * - * @param lowerInclExpr The position of the first result (inclusive) - * @param upperExclExpr The position of the last result (exclusive) - * @return The query - */ - JDOQLTypedQuery range(NumericExpression lowerInclExpr, NumericExpression upperExclExpr); - - /** - * Method to set the range of any required results, using long values. - * - * @param lowerIncl The position of the first result (inclusive) - * @param upperExcl The position of the last result (exclusive) - * @return The query - */ - JDOQLTypedQuery range(long lowerIncl, long upperExcl); - - /** - * Method to set the range of any required results, using parameters (expressions). - * - * @param paramLowerInclExpr Expression for a parameter defining the position of the first result - * (inclusive) - * @param paramUpperExclExpr Expression for a parameter defining the position of the last result - * (exclusive) - * @return The query - */ - JDOQLTypedQuery range(Expression paramLowerInclExpr, Expression paramUpperExclExpr); - - /** - * Method to return a subquery for use in this query using the same candidate class as this query. - * To obtain the expression for the subquery to link it back to this query, call "result(...)" on - * the subquery. - * - * @param candidateAlias Alias for the candidate - * @return The subquery - */ - JDOQLTypedSubquery subquery(String candidateAlias); - - /** - * Method to return a subquery for use in this query. To obtain the expression for the subquery to - * link it back to this query, call "result(...)" on the subquery. - * - * @param candidate Candidate for the subquery - * @param candidateAlias Alias for the candidate - * @return The subquery - * @param Candidate type for subquery - */ - JDOQLTypedSubquery subquery(Class candidate, String candidateAlias); - - /** - * Method to return a correlated subquery for use in this query. The candidate collection of the - * subquery is defined using a collection relationship of the outer query. To obtain the - * expression for the subquery to link it back to this query, call "result(...)" on the subquery. - * - * @param candidateCollection Expression defining the candidate collection for the subquery - * @param candidate Candidate for the subquery - * @param candidateAlias Alias for the candidate - * @return The subquery - * @param Candidate type for subquery - */ - JDOQLTypedSubquery subquery( - CollectionExpression, E> candidateCollection, - Class candidate, - String candidateAlias); - - /** - * Method to set the named parameters on this query prior to execution. All parameter values - * specified in this method will only be retained until the subsequent query execution. - * - * @param namedParamMap The map of parameter values keyed by their names. - * @return This query - */ - JDOQLTypedQuery setParameters(Map namedParamMap); - - /** - * Method to set a parameter value for the specified (parameter) expression when executing the - * query. All parameter values specified in this method will only be retained until the subsequent - * query execution. - * - * @param paramExpr Expression defining the parameter - * @param value The value - * @return The query - */ - JDOQLTypedQuery setParameter(Expression paramExpr, Object value); - - /** - * Method to set the value for a named parameter for use when executing the query. All parameter - * values specified in this method will only be retained until the subsequent query execution. - * - * @param paramName Parameter name - * @param value The value - * @return The query - */ - JDOQLTypedQuery setParameter(String paramName, Object value); - - /** - * Method to execute the query where there are (potentially) multiple rows and we are returning - * the candidate type. Any parameters required should be set prior to calling this method, using - * one of the setParameter methods. - * - *

    Calling this method with a result being specified will result in JDOUserException being - * thrown. - * - * @return The results - */ - List executeList(); - - /** - * Method to execute the query where there is a single row and we are returning the candidate - * type. Any parameters required should be set prior to calling this method, using one of the - * setParameter methods. - * - *

    Calling this method with a result being specified will result in JDOUserException being - * thrown. - * - * @return The result - */ - T executeUnique(); - - /** - * Method to execute the query where there are (potentially) multiple rows and we are returning - * either the result type. Any parameters required should be set prior to calling this method, - * using one of the setParameters methods. - * - *

    Calling this method with no result being specified will result in JDOUserException being - * thrown. - * - * @param resultCls Result class - * @return The results - * @param result type - */ - List executeResultList(Class resultCls); - - /** - * Method to execute the query where there is a single row and we are returning either the result - * type. Any parameters required should be set prior to calling this method, using one of the - * setParameter methods. - * - *

    Calling this method with no result being specified will result in JDOUserException being - * thrown. - * - * @param resultCls Result class - * @return The result - * @param result type - */ - R executeResultUnique(Class resultCls); - - /** - * Method to execute the query where there are (potentially) multiple rows and we have a result - * defined but no result class. Any parameters required should be set prior to calling this - * method, using one of the setParameter methods. - * - *

    Calling this method with no result being specified will result in JDOUserException being - * thrown. - * - * @return The results - */ - List executeResultList(); - - /** - * Method to execute the query where there is a single row and we have a result defined but no - * result class. Any parameters required should be set prior to calling this method, using one of - * the setParameters methods. - * - *

    Calling this method with no result being specified will result in JDOUserException being - * thrown. - * - * @return The results - */ - Object executeResultUnique(); - - /** - * Method to execute the query deleting the affected instances. Any parameters required should be - * set prior to calling this method, using one of the setParameter methods. - * - * @return The number of objects deleted - */ - long deletePersistentAll(); - - /** - * Get the effective timeout setting for read operations. If the timeout has not been set on this - * query explicitly, the effective datastore read timeout value from the persistence manager is - * returned. - * - * @see PersistenceManager#setDatastoreReadTimeoutMillis(Integer) - * @return the effective timeout setting (milliseconds). - */ - Integer getDatastoreReadTimeoutMillis(); - - /** - * Set the datastore read timeout (millis). - * - * @param interval The interval - * @return This query - */ - JDOQLTypedQuery datastoreReadTimeoutMillis(Integer interval); - - /** - * Get the effective timeout setting for write operations. If the timeout has not been set on this - * query explicitly, the effective datastore write timeout value from the persistence manager is - * returned. - * - * @see PersistenceManager#setDatastoreWriteTimeoutMillis(Integer) - * @return the effective timeout setting (milliseconds). - */ - Integer getDatastoreWriteTimeoutMillis(); - - /** - * Set the datastore write timeout (millis). - * - * @param interval The interval - * @return This query - */ - JDOQLTypedQuery datastoreWriteTimeoutMillis(Integer interval); - - /** - * Return the current value of the serializeRead property. - * - * @return the value of the serializeRead property - */ - Boolean getSerializeRead(); - - /** - * Set whether we to lock all objects read by this query. - * - * @param serialize Whether to lock - * @return This query - */ - JDOQLTypedQuery serializeRead(Boolean serialize); - - /** - * The unmodifiable flag, when set, disallows further modification of the query, except for - * specifying the range, result class, and ignoreCache option. - * - * @return the current setting of the flag - */ - boolean isUnmodifiable(); - - /** - * Set to make this query unmodifiable hereafter. - * - * @return This query - */ - JDOQLTypedQuery unmodifiable(); - - /** - * Get the ignoreCache option setting. - * - * @return the ignoreCache option setting. - */ - boolean getIgnoreCache(); - - /** - * Set whether we to ignore the cache with this query. - * - * @param flag Whether to ignore the cache - * @return This query - */ - JDOQLTypedQuery ignoreCache(boolean flag); - - /** - * Specify an extension for this query. - * - * @param key The extension key - * @param value The extension value - * @return This query - */ - JDOQLTypedQuery extension(String key, Object value); - - /** - * Specify a map of extensions for this query. - * - * @param values The extension map of keys and values - * @return This query - */ - JDOQLTypedQuery extensions(Map values); - - /** - * Save the query, as it is currently defined, as a named query under the specified name. If a - * named query already exists under this name (either defined in metadata, or previously saved) - * then it will be overwritten. - * - * @param name Name to save it under. - * @return This query - */ - JDOQLTypedQuery saveAsNamedQuery(String name); - - /** - * Accessor for the PersistenceManager for this query - * - * @return The PersistenceManager - */ - PersistenceManager getPersistenceManager(); - - /** - * Accessor for the FetchPlan for this query - * - * @return The FetchPlan - */ - FetchPlan getFetchPlan(); - - /** - * Method to cancel any executing queries. If the underlying datastore doesn't support - * cancellation of queries this will throw JDOUnsupportedOptionException. If the cancellation - * fails (e.g in the underlying datastore) then this will throw a JDOException. - */ - void cancelAll(); - - /** - * Method to cancel an executing query in the specified thread. If the underlying datastore - * doesn't support cancellation of queries this will throw JDOUnsupportedOptionException. If the - * cancellation fails (e.g in the underlying datastore) then this will throw a JDOException. - * - * @param thread The thread to cancel - */ - void cancel(Thread thread); - - /** - * Method to close the specified query result. - * - * @param result The result - */ - void close(Object result); - - /** Method to close all query results from this query. */ - void closeAll(); - - /** - * Method to return the equivalent String form of this query (if applicable for the query - * language). - * - * @return The single-string form of this query - */ - String toString(); + public static final String QUERY_CLASS_PREFIX = "Q"; + + /** + * Method to return an expression for the candidate of the query. + * Cast the returned expression to the candidate "Q" type to be able to call methods on it. + * This calls the method "Q{type}.candidate(null)" + * The preference is to use the "Q{type}.candidate()" method for real type-safe handling. + * @return Expression for the candidate + */ + PersistableExpression candidate(); + + /** + * Method to return a parameter for the query. + * Cast the returned parameter to the right type to be able to call methods on it. + * The preference is to use the "xxxParameter(String)" methods for real type-safe handling. + * @param name Name of the parameter + * @param type Java type of the parameter + * @return Expression for the parameter + * @param

    type for the parameter + */ +

    Expression

    parameter(String name, Class

    type); + + /** + * Method to return a string parameter for the query. + * @param name Name of the parameter + * @return StringExpression for the parameter + */ + StringExpression stringParameter(String name); + + /** + * Method to return a character parameter for the query. + * @param name Name of the parameter + * @return Expression for the parameter + */ + CharacterExpression characterParameter(String name); + + /** + * Method to return a numeric parameter for the query. + * @param name Name of the parameter + * @return NumericExpression for the parameter + */ + NumericExpression numericParameter(String name); + + /** + * Method to return a numeric parameter for the query. + * @param name Name of the parameter + * @param type Type of the numeric parameter + * @param Type for the numeric parameter + * @return NumericExpression for the parameter + */ + @SuppressWarnings("unchecked") + default NumericExpression numericParameter(String name, Class type) { + return (NumericExpression)numericParameter(name); + } + + /** + * Method to return a date parameter for the query. + * @param name Name of the parameter + * @return Expression for the parameter + */ + DateExpression dateParameter(String name); + + /** + * Method to return a time parameter for the query. + * @param name Name of the parameter + * @return Expression for the parameter + */ + TimeExpression timeParameter(String name); + + /** + * Method to return a datetime parameter for the query. + * @param name Name of the parameter + * @return Expression for the parameter + */ + DateTimeExpression datetimeParameter(String name); + + /** + * Method to return a collection parameter for the query. + * @param name Name of the parameter + * @return Expression for the parameter + */ + CollectionExpression collectionParameter(String name); + + /** + * Method to return a collection parameter for the query. + * + * @param name Name of the parameter + * @param elementType Element type of the collection parameter + * @param Element type for the collection parameter + * @return Expression for the parameter + */ + @SuppressWarnings("unchecked") + default CollectionExpression, E> collectionParameter(String name, Class elementType) { + return (CollectionExpression, E>)collectionParameter(name); + } + + /** + * Method to return a map parameter for the query. + * @param name Name of the parameter + * @return Expression for the parameter + */ + MapExpression mapParameter(String name); + + /** + * Method to return a map parameter for the query. + * @param name Name of the parameter + * @param keyType Key type of the map parameter + * @param valueType Value type of the map parameter + * @param Key type for the map parameter + * @param Value type for the map parameter + * @return Expression for the parameter + */ + @SuppressWarnings("unchecked") + default MapExpression, K, V> mapParameter(String name, Class keyType, Class valueType) { + return (MapExpression, K, V>)mapParameter(name); + } + + /** + * Method to return a list parameter for the query. + * @param name Name of the parameter + * @return Expression for the parameter + */ + ListExpression listParameter(String name); + + /** + * Method to return a list parameter for the query. + * @param name Name of the parameter + * @param elementType Element type of the list parameter + * @param Element type for the list parameter + * @return Expression for the parameter + */ + @SuppressWarnings("unchecked") + default ListExpression, E> listParameter(String name, Class elementType) { + return (ListExpression, E>)listParameter(name); + } + + /** + * Method to return a variable for this query. + * Cast the returned variable to the right type to be able to call methods on it. + * @param name Name of the variable + * @param type Type of the variable + * @return Expression for the variable + * @param type for the variable + */ + Expression variable(String name, Class type); + + /** + * Method to set the candidates to use over which we are querying. + * If no candidates are set then the query is performed on the datastore. + * @param candidates The candidates + * @return The query + */ + JDOQLTypedQuery setCandidates(Collection candidates); + + /** + * Method to remove subclasses (of the candidate) from the query + * @return The query + */ + JDOQLTypedQuery excludeSubclasses(); + + /** + * Method to include subclasses (of the candidate) to the query + * @return The query + */ + JDOQLTypedQuery includeSubclasses(); + + /** + * Method to set the filter of the query. + * @param expr Filter expression + * @return The query + */ + JDOQLTypedQuery filter(BooleanExpression expr); + + /** + * Method to return an "IF (...) ... ELSE ..." expression for use in this query. + * @param type The type returned by the IfElse. + * @param cond The if condition + * @param thenValueExpr Expression for value to return when the if expression is met + * @param elseValueExpr Expression for value to return when the if expression is not met + * @param type for the IfThenElseExpression + * @return The IfThenElse expression + */ + IfThenElseExpression ifThenElse(Class type, BooleanExpression cond, + Expression thenValueExpr, Expression elseValueExpr); + + /** + * Method to return an "IF (...) ... ELSE ..." expression for use in this query. + * @param cond The if condition + * @param thenValue Value to return when the if expression is met + * @param elseValueExpr Expression to return when the if expression is not met + * @param type for the IfThenElseExpression + * @return The IfThenElse expression + */ + IfThenElseExpression ifThenElse(BooleanExpression cond, V thenValue, Expression elseValueExpr); + + /** + * Method to return an "IF (...) ... ELSE ..." expression for use in this query. + * @param cond The if condition + * @param thenValueExpr Expression to return when the if expression is met + * @param elseValue Value to return when the if expression is not met + * @param type for the IfThenElseExpression + * @return The IfThenElse expression + */ + IfThenElseExpression ifThenElse(BooleanExpression cond, Expression thenValueExpr, V elseValue); + + /** + * Method to return an "IF (...) ... ELSE ..." expression for use in this query. + * @param cond The if condition + * @param thenValue Value to return when the if expression is met + * @param elseValue Value to return when the if expression is not met + * @param type for the IfThenElseExpression + * @return The IfThenElse expression + */ + IfThenElseExpression ifThenElse(BooleanExpression cond, V thenValue, V elseValue); + + /** + * Method to return an "IF (...) ... ELSE ..." expression for use in this query. + * @param type The type returned by the IfElse. + * @param cond The if condition + * @param thenValueExpr Expression for value to return when the if expression is met + * @param type for the IfThenElseExpression + * @return The IfThenElse expression + */ + IfThenElseExpression ifThen(Class type, BooleanExpression cond, Expression thenValueExpr); + + /** + * Method to return an "IF (...) ... ELSE ..." expression for use in this query. + * @param cond The if condition + * @param thenValue Value to return when the if expression is met + * @param type for the IfThenElseExpression + * @return The IfThenElse expression + */ + IfThenElseExpression ifThen(BooleanExpression cond, V thenValue); + + /** + * Method to set the grouping(s) for the query. + * @param exprs Grouping expression(s) + * @return The query + */ + JDOQLTypedQuery groupBy(Expression... exprs); + + /** + * Method to set the having clause of the query. + * @param expr Having expression + * @return The query + */ + JDOQLTypedQuery having(Expression expr); + + /** + * Method to set the ordering of the query. + * @param orderExprs Ordering expression(s) + * @return The query + */ + JDOQLTypedQuery orderBy(OrderExpression... orderExprs); + + /** + * Method to set the result of the query. + * @param distinct Whether results are distinct + * @param exprs The result expressions + * @return The query + */ + JDOQLTypedQuery result(boolean distinct, Expression... exprs); + + /** + * Method to set the range of any required results, using expressions. + * @param lowerInclExpr The position of the first result (inclusive) + * @param upperExclExpr The position of the last result (exclusive) + * @return The query + */ + JDOQLTypedQuery range(NumericExpression lowerInclExpr, NumericExpression upperExclExpr); + + /** + * Method to set the range of any required results, using long values. + * @param lowerIncl The position of the first result (inclusive) + * @param upperExcl The position of the last result (exclusive) + * @return The query + */ + JDOQLTypedQuery range(long lowerIncl, long upperExcl); + + /** + * Method to set the range of any required results, using parameters (expressions). + * @param paramLowerInclExpr Expression for a parameter defining the position of the first result (inclusive) + * @param paramUpperExclExpr Expression for a parameter defining the position of the last result (exclusive) + * @return The query + */ + JDOQLTypedQuery range(Expression paramLowerInclExpr, Expression paramUpperExclExpr); + + /** + * Method to return a subquery for use in this query using the same candidate class as this query. + * To obtain the expression for the subquery to link it back to this query, call "result(...)" on the subquery. + * @param candidateAlias Alias for the candidate + * @return The subquery + */ + JDOQLTypedSubquery subquery(String candidateAlias); + + /** + * Method to return a subquery for use in this query. + * To obtain the expression for the subquery to link it back to this query, call "result(...)" on the subquery. + * @param candidate Candidate for the subquery + * @param candidateAlias Alias for the candidate + * @return The subquery + * @param Candidate type for subquery + */ + JDOQLTypedSubquery subquery(Class candidate, String candidateAlias); + + /** + * Method to return a correlated subquery for use in this query. + * The candidate collection of the subquery is defined using a collection relationship of the outer query. + * To obtain the expression for the subquery to link it back to this query, call "result(...)" on the subquery. + * @param candidateCollection Expression defining the candidate collection for the subquery + * @param candidate Candidate for the subquery + * @param candidateAlias Alias for the candidate + * @return The subquery + * @param Candidate type for subquery + */ + JDOQLTypedSubquery subquery(CollectionExpression, E> candidateCollection, Class candidate, String candidateAlias); + + /** + * Method to set the named parameters on this query prior to execution. + * All parameter values specified in this method will only be retained until the subsequent query execution. + * @param namedParamMap The map of parameter values keyed by their names. + * @return This query + */ + JDOQLTypedQuery setParameters(Map namedParamMap); + + /** + * Method to set a parameter value for the specified (parameter) expression when executing the query. + * All parameter values specified in this method will only be retained until the subsequent query execution. + * @param paramExpr Expression defining the parameter + * @param value The value + * @return The query + */ + JDOQLTypedQuery setParameter(Expression paramExpr, Object value); + + /** + * Method to set the value for a named parameter for use when executing the query. + * All parameter values specified in this method will only be retained until the subsequent query execution. + * @param paramName Parameter name + * @param value The value + * @return The query + */ + JDOQLTypedQuery setParameter(String paramName, Object value); + + /** + * Method to execute the query where there are (potentially) multiple rows and we are returning the candidate type. + * Any parameters required should be set prior to calling this method, using one of the setParameter methods. + *

    Calling this method with a result being specified will result in JDOUserException being thrown. + * @return The results + */ + List executeList(); + + /** + * Method to execute the query where there is a single row and we are returning the candidate type. + * Any parameters required should be set prior to calling this method, using one of the setParameter methods. + *

    Calling this method with a result being specified will result in JDOUserException being thrown. + * @return The result + */ + T executeUnique(); + + /** + * Method to execute the query where there are (potentially) multiple rows and we are returning either the result type. + * Any parameters required should be set prior to calling this method, using one of the setParameters methods. + *

    Calling this method with no result being specified will result in JDOUserException being thrown. + * @param resultCls Result class + * @return The results + * @param result type + */ + List executeResultList(Class resultCls); + + /** + * Method to execute the query where there is a single row and we are returning either the result type. + * Any parameters required should be set prior to calling this method, using one of the setParameter methods. + *

    Calling this method with no result being specified will result in JDOUserException being thrown. + * @param resultCls Result class + * @return The result + * @param result type + */ + R executeResultUnique(Class resultCls); + + /** + * Method to execute the query where there are (potentially) multiple rows and we have a result defined but no result class. + * Any parameters required should be set prior to calling this method, using one of the setParameter methods. + *

    Calling this method with no result being specified will result in JDOUserException being thrown. + * @return The results + */ + List executeResultList(); + + /** + * Method to execute the query where there is a single row and we have a result defined but no result class. + * Any parameters required should be set prior to calling this method, using one of the setParameters methods. + *

    Calling this method with no result being specified will result in JDOUserException being thrown. + * @return The results + */ + Object executeResultUnique(); + + /** + * Method to execute the query deleting the affected instances. + * Any parameters required should be set prior to calling this method, using one of the setParameter methods. + * @return The number of objects deleted + */ + long deletePersistentAll(); + + /** + * Get the effective timeout setting for read operations. + * If the timeout has not been set on this query explicitly, the effective + * datastore read timeout value from the persistence manager is returned. + * @see PersistenceManager#setDatastoreReadTimeoutMillis(Integer) + * @return the effective timeout setting (milliseconds). + */ + Integer getDatastoreReadTimeoutMillis(); + + /** + * Set the datastore read timeout (millis). + * @param interval The interval + * @return This query + */ + JDOQLTypedQuery datastoreReadTimeoutMillis(Integer interval); + + /** + * Get the effective timeout setting for write operations. + * If the timeout has not been set on this query explicitly, the effective + * datastore write timeout value from the persistence manager is returned. + * @see PersistenceManager#setDatastoreWriteTimeoutMillis(Integer) + * @return the effective timeout setting (milliseconds). + */ + Integer getDatastoreWriteTimeoutMillis(); + + /** + * Set the datastore write timeout (millis). + * @param interval The interval + * @return This query + */ + JDOQLTypedQuery datastoreWriteTimeoutMillis(Integer interval); + + /** + * Return the current value of the serializeRead property. + * @return the value of the serializeRead property + */ + Boolean getSerializeRead(); + + /** + * Set whether we to lock all objects read by this query. + * @param serialize Whether to lock + * @return This query + */ + JDOQLTypedQuery serializeRead(Boolean serialize); + + /** + * The unmodifiable flag, when set, disallows further modification of the query, + * except for specifying the range, result class, and ignoreCache option. + * @return the current setting of the flag + */ + boolean isUnmodifiable(); + + /** + * Set to make this query unmodifiable hereafter. + * @return This query + */ + JDOQLTypedQuery unmodifiable(); + + /** + * Get the ignoreCache option setting. + * @return the ignoreCache option setting. + */ + boolean getIgnoreCache(); + + /** + * Set whether we to ignore the cache with this query. + * @param flag Whether to ignore the cache + * @return This query + */ + JDOQLTypedQuery ignoreCache(boolean flag); + + /** + * Specify an extension for this query. + * @param key The extension key + * @param value The extension value + * @return This query + */ + JDOQLTypedQuery extension(String key, Object value); + + /** + * Specify a map of extensions for this query. + * @param values The extension map of keys and values + * @return This query + */ + JDOQLTypedQuery extensions(Map values); + + /** + * Save the query, as it is currently defined, as a named query under the specified name. + * If a named query already exists under this name (either defined in metadata, or previously saved) + * then it will be overwritten. + * @param name Name to save it under. + * @return This query + */ + JDOQLTypedQuery saveAsNamedQuery(String name); + + /** + * Accessor for the PersistenceManager for this query + * @return The PersistenceManager + */ + PersistenceManager getPersistenceManager(); + + /** + * Accessor for the FetchPlan for this query + * @return The FetchPlan + */ + FetchPlan getFetchPlan(); + + /** + * Method to cancel any executing queries. + * If the underlying datastore doesn't support cancellation of queries this will throw JDOUnsupportedOptionException. + * If the cancellation fails (e.g in the underlying datastore) then this will throw a JDOException. + */ + void cancelAll(); + + /** + * Method to cancel an executing query in the specified thread. + * If the underlying datastore doesn't support cancellation of queries this will throw JDOUnsupportedOptionException. + * If the cancellation fails (e.g in the underlying datastore) then this will throw a JDOException. + * @param thread The thread to cancel + */ + void cancel(Thread thread); + + /** + * Method to close the specified query result. + * @param result The result + */ + void close(Object result); + + /** + * Method to close all query results from this query. + */ + void closeAll(); + + /** + * Method to return the equivalent String form of this query (if applicable for the query language). + * @return The single-string form of this query + */ + String toString(); } diff --git a/api/src/main/java/javax/jdo/JDOQLTypedSubquery.java b/api/src/main/java/javax/jdo/JDOQLTypedSubquery.java index dff6381a4..208b1ce70 100644 --- a/api/src/main/java/javax/jdo/JDOQLTypedSubquery.java +++ b/api/src/main/java/javax/jdo/JDOQLTypedSubquery.java @@ -5,18 +5,19 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo; import java.io.Serializable; + import javax.jdo.query.BooleanExpression; import javax.jdo.query.CharacterExpression; import javax.jdo.query.CollectionExpression; @@ -29,105 +30,88 @@ import javax.jdo.query.TimeExpression; /** - * Interface for a type-safe subquery, using a fluent API. Users should call methods on the subquery - * instance and end with a select of what the subquery returns; this returns the expression that - * they use to link it with the owning query. - * + * Interface for a type-safe subquery, using a fluent API. + * Users should call methods on the subquery instance and end with a select of what the subquery returns; this + * returns the expression that they use to link it with the owning query. + * * @param (Candidate) type being represented */ public interface JDOQLTypedSubquery extends Serializable { - /** - * Method to return an expression for the candidate of the subquery. Cast the returned expression - * to the candidate "Q" type to be able to call methods on it. - * - * @return Expression for the candidate - */ - PersistableExpression candidate(); + /** + * Method to return an expression for the candidate of the subquery. + * Cast the returned expression to the candidate "Q" type to be able to call methods on it. + * @return Expression for the candidate + */ + PersistableExpression candidate(); - /** - * Method to set the filter of the query. - * - * @param expr Filter expression - * @return The query - */ - JDOQLTypedSubquery filter(BooleanExpression expr); + /** + * Method to set the filter of the query. + * @param expr Filter expression + * @return The query + */ + JDOQLTypedSubquery filter(BooleanExpression expr); - /** - * Method to set the grouping(s) for the query. - * - * @param exprs Grouping expression(s) - * @return The query - */ - JDOQLTypedSubquery groupBy(Expression... exprs); + /** + * Method to set the grouping(s) for the query. + * @param exprs Grouping expression(s) + * @return The query + */ + JDOQLTypedSubquery groupBy(Expression... exprs); - /** - * Method to set the having clause of the query. - * - * @param expr Having expression - * @return The query - */ - JDOQLTypedSubquery having(Expression expr); + /** + * Method to set the having clause of the query. + * @param expr Having expression + * @return The query + */ + JDOQLTypedSubquery having(Expression expr); - /** - * Accessor for the subquery (numeric) expression from the subquery when the subquery returns a - * single value. - * - * @param expr The expression - * @return Expression for the typesafe query - * @param numeric type - */ - NumericExpression selectUnique(NumericExpression expr); + /** + * Accessor for the subquery (numeric) expression from the subquery when the subquery returns a single value. + * @param expr The expression + * @return Expression for the typesafe query + * @param numeric type + */ + NumericExpression selectUnique(NumericExpression expr); - /** - * Accessor for the subquery (string) expression from the subquery when the subquery returns a - * single value. - * - * @param expr The expression - * @return Expression for the typesafe query - */ - StringExpression selectUnique(StringExpression expr); + /** + * Accessor for the subquery (string) expression from the subquery when the subquery returns a single value. + * @param expr The expression + * @return Expression for the typesafe query + */ + StringExpression selectUnique(StringExpression expr); - /** - * Accessor for the subquery (date) expression from the subquery when the subquery returns a - * single value. - * - * @param expr The expression - * @return Expression for the typesafe query - */ - DateExpression selectUnique(DateExpression expr); + /** + * Accessor for the subquery (date) expression from the subquery when the subquery returns a single value. + * @param expr The expression + * @return Expression for the typesafe query + */ + DateExpression selectUnique(DateExpression expr); - /** - * Accessor for the subquery (datetime) expression from the subquery when the subquery returns a - * single value. - * - * @param expr The expression - * @return Expression for the typesafe query - */ - DateTimeExpression selectUnique(DateTimeExpression expr); + /** + * Accessor for the subquery (datetime) expression from the subquery when the subquery returns a single value. + * @param expr The expression + * @return Expression for the typesafe query + */ + DateTimeExpression selectUnique(DateTimeExpression expr); - /** - * Accessor for the subquery (time) expression from the subquery when the subquery returns a - * single value. - * - * @param expr The expression - * @return Expression for the typesafe query - */ - TimeExpression selectUnique(TimeExpression expr); + /** + * Accessor for the subquery (time) expression from the subquery when the subquery returns a single value. + * @param expr The expression + * @return Expression for the typesafe query + */ + TimeExpression selectUnique(TimeExpression expr); - /** - * Accessor for the subquery (character) expression from the subquery when the subquery returns a - * single value. - * - * @param expr The expression - * @return Expression for the typesafe query - */ - CharacterExpression selectUnique(CharacterExpression expr); + /** + * Accessor for the subquery (character) expression from the subquery when the subquery returns a single value. + * @param expr The expression + * @return Expression for the typesafe query + */ + CharacterExpression selectUnique(CharacterExpression expr); - /** - * Accessor for the subquery (collection) expression from the subquery. - * - * @param expr The expression - * @return Expression for the typesafe query - */ - CollectionExpression select(CollectionExpression expr); -} + /** + * Accessor for the subquery (collection) expression from the subquery. + * @param expr The expression + * @return Expression for the typesafe query + */ + CollectionExpression select(CollectionExpression expr); +} \ No newline at end of file diff --git a/api/src/main/java/javax/jdo/JDOQueryInterruptedException.java b/api/src/main/java/javax/jdo/JDOQueryInterruptedException.java index 3dc3ed8f3..7c7d7ea40 100644 --- a/api/src/main/java/javax/jdo/JDOQueryInterruptedException.java +++ b/api/src/main/java/javax/jdo/JDOQueryInterruptedException.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -21,24 +21,26 @@ */ package javax.jdo; -/** +/** * This class represents exceptions caused when a query is cancelled by a user calling * Query.cancel(). - * + * * @since 3.0 */ public class JDOQueryInterruptedException extends JDOUserException { - private static final long serialVersionUID = -5832046548440677226L; + private static final long serialVersionUID = -5832046548440677226L; - /** Constructs a new JDOQueryInterruptedException without a detail message. */ - public JDOQueryInterruptedException() {} + /** + * Constructs a new JDOQueryInterruptedException without a detail message. + */ + public JDOQueryInterruptedException() { + } - /** - * Constructs a new JDOQueryInterruptedException with the specified detail message. - * - * @param msg the detail message. - */ - public JDOQueryInterruptedException(String msg) { - super(msg); - } + /** + * Constructs a new JDOQueryInterruptedException with the specified detail message. + * @param msg the detail message. + */ + public JDOQueryInterruptedException(String msg) { + super(msg); + } } diff --git a/api/src/main/java/javax/jdo/JDOReadOnlyException.java b/api/src/main/java/javax/jdo/JDOReadOnlyException.java index 0e5c5a485..3b178b872 100644 --- a/api/src/main/java/javax/jdo/JDOReadOnlyException.java +++ b/api/src/main/java/javax/jdo/JDOReadOnlyException.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -21,55 +21,52 @@ package javax.jdo; -/** - * This class represents exceptions caused by an attempt to update a datastore when the PMF was - * created as "read-only". +/** This class represents exceptions caused by an attempt to update a datastore + * when the PMF was created as "read-only". * * @version 2.2 * @since 2.2 */ public class JDOReadOnlyException extends JDOUserException { - private static final long serialVersionUID = -6612305192571046806L; + private static final long serialVersionUID = -6612305192571046806L; - /** - * Constructs a new JDOReadOnlyException without a detail message. - * - * @since 2.2 - */ - public JDOReadOnlyException() {} + /** + * Constructs a new JDOReadOnlyException without a detail message. + * @since 2.2 + */ + public JDOReadOnlyException() { + } - /** - * Constructs a new JDOReadOnlyException with the specified detail message. - * - * @param msg the detail message. - * @since 2.2 - */ - public JDOReadOnlyException(String msg) { - super(msg); - } + /** + * Constructs a new JDOReadOnlyException with the + * specified detail message. + * @param msg the detail message. + * @since 2.2 + */ + public JDOReadOnlyException(String msg) { + super(msg); + } - /** - * Constructs a new JDOReadOnlyException with the specified detail message and nested - * Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - * @since 2.2 - */ - public JDOReadOnlyException(String msg, Throwable[] nested) { - super(msg, nested); - } + /** + * Constructs a new JDOReadOnlyException with the + * specified detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable[]. + * @since 2.2 + */ + public JDOReadOnlyException(String msg, Throwable[] nested) { + super(msg, nested); + } - /** - * Constructs a new JDOReadOnlyException with the specified detail message and nested - * Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable. - * @since 2.2 - */ - public JDOReadOnlyException(String msg, Throwable nested) { - super(msg, nested); - } -} + /** + * Constructs a new JDOReadOnlyException with the + * specified detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable. + * @since 2.2 + */ + public JDOReadOnlyException(String msg, Throwable nested) { + super(msg, nested); + } +} \ No newline at end of file diff --git a/api/src/main/java/javax/jdo/JDOUnsupportedOptionException.java b/api/src/main/java/javax/jdo/JDOUnsupportedOptionException.java index 6e5391dc6..13ad0ec75 100644 --- a/api/src/main/java/javax/jdo/JDOUnsupportedOptionException.java +++ b/api/src/main/java/javax/jdo/JDOUnsupportedOptionException.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -22,47 +22,46 @@ package javax.jdo; -/** - * This class represents exceptions caused by the use of optional features not supported by the JDO - * implementation. +/** This class represents exceptions caused by the use of optional features + * not supported by the JDO implementation. * * @version 1.0 */ public class JDOUnsupportedOptionException extends JDOUserException { - private static final long serialVersionUID = -8357333650749157892L; + private static final long serialVersionUID = -8357333650749157892L; - /** Constructs a new JDOUnsupportedOptionException without a detail message. */ - public JDOUnsupportedOptionException() {} + /** + * Constructs a new JDOUnsupportedOptionException without a detail message. + */ + public JDOUnsupportedOptionException() { + } - /** - * Constructs a new JDOUnsupportedOptionException with the specified detail message. - * - * @param msg the detail message. - */ - public JDOUnsupportedOptionException(String msg) { - super(msg); - } + /** + * Constructs a new JDOUnsupportedOptionException with the specified detail message. + * @param msg the detail message. + */ + public JDOUnsupportedOptionException(String msg) { + super(msg); + } - /** - * Constructs a new JDOUnsupportedOptionException with the specified detail message - * and nested Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - */ - public JDOUnsupportedOptionException(String msg, Throwable[] nested) { - super(msg, nested); - } + /** + * Constructs a new JDOUnsupportedOptionException with the + * specified detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable[]. + */ + public JDOUnsupportedOptionException(String msg, Throwable[] nested) { + super(msg, nested); + } - /** - * Constructs a new JDOUnsupportedOptionException with the specified detail message - * and nested Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable. - */ - public JDOUnsupportedOptionException(String msg, Throwable nested) { - super(msg, nested); - } + /** + * Constructs a new JDOUnsupportedOptionException with the + * specified detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable. + */ + public JDOUnsupportedOptionException(String msg, Throwable nested) { + super(msg, nested); + } } diff --git a/api/src/main/java/javax/jdo/JDOUserCallbackException.java b/api/src/main/java/javax/jdo/JDOUserCallbackException.java index 352ada117..afb873b18 100644 --- a/api/src/main/java/javax/jdo/JDOUserCallbackException.java +++ b/api/src/main/java/javax/jdo/JDOUserCallbackException.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -22,82 +22,78 @@ package javax.jdo; -/** - * This class represents exceptions caused by exceptions thrown during execution of callbacks or - * listeners. +/** This class represents exceptions caused by exceptions thrown + * during execution of callbacks or listeners. * * @version 2.0 */ public class JDOUserCallbackException extends JDOUserException { - private static final long serialVersionUID = -3317062335034038699L; + private static final long serialVersionUID = -3317062335034038699L; - /** Constructs a new JDOUserCallbackException without a detail message. */ - public JDOUserCallbackException() {} + /** + * Constructs a new JDOUserCallbackException + * without a detail message. + */ + public JDOUserCallbackException() { + } - /** - * Constructs a new JDOUserCallbackException with the specified detail message. - * - * @param msg the detail message. - */ - public JDOUserCallbackException(String msg) { - super(msg); - } + /** + * Constructs a new JDOUserCallbackException + * with the specified detail message. + * @param msg the detail message. + */ + public JDOUserCallbackException(String msg) { + super(msg); + } - /** - * Constructs a new JDOUserCallbackException with the specified detail message and - * nested Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - */ - public JDOUserCallbackException(String msg, Throwable[] nested) { - super(msg, nested); - } + /** + * Constructs a new JDOUserCallbackException with the + * specified detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable[]. + */ + public JDOUserCallbackException(String msg, Throwable[] nested) { + super(msg, nested); + } - /** - * Constructs a new JDOUserCallbackException with the specified detail message and - * nested Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable. - */ - public JDOUserCallbackException(String msg, Throwable nested) { - super(msg, nested); - } + /** + * Constructs a new JDOUserCallbackException with the + * specified detail message and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable. + */ + public JDOUserCallbackException(String msg, Throwable nested) { + super(msg, nested); + } + + /** Constructs a new JDOUserCallbackException with the specified detail message + * and failed object. + * @param msg the detail message. + * @param failed the failed object. + */ + public JDOUserCallbackException(String msg, Object failed) { + super(msg, failed); + } - /** - * Constructs a new JDOUserCallbackException with the specified detail message and - * failed object. - * - * @param msg the detail message. - * @param failed the failed object. - */ - public JDOUserCallbackException(String msg, Object failed) { - super(msg, failed); - } + /** Constructs a new JDOUserCallbackException with the specified detail message, + * nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable[]. + * @param failed the failed object. + */ + public JDOUserCallbackException(String msg, Throwable[] nested, Object failed) { + super(msg, nested, failed); + } - /** - * Constructs a new JDOUserCallbackException with the specified detail message, - * nested Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - * @param failed the failed object. - */ - public JDOUserCallbackException(String msg, Throwable[] nested, Object failed) { - super(msg, nested, failed); - } - - /** - * Constructs a new JDOUserException with the specified detail message, nested - * Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable. - * @param failed the failed object. - */ - public JDOUserCallbackException(String msg, Throwable nested, Object failed) { - super(msg, nested, failed); - } + /** Constructs a new JDOUserException with the specified detail message, + * nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable. + * @param failed the failed object. + */ + public JDOUserCallbackException(String msg, Throwable nested, Object failed) { + super(msg, nested, failed); + } } + diff --git a/api/src/main/java/javax/jdo/JDOUserException.java b/api/src/main/java/javax/jdo/JDOUserException.java index 70da645ed..c95b64547 100644 --- a/api/src/main/java/javax/jdo/JDOUserException.java +++ b/api/src/main/java/javax/jdo/JDOUserException.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -22,81 +22,75 @@ package javax.jdo; -/** - * This class represents user errors that can possibly be retried. +/** This class represents user errors that can possibly be retried. * * @version 1.0 */ public class JDOUserException extends JDOCanRetryException { - private static final long serialVersionUID = 2552001511762583039L; - - /** Constructs a new JDOUserException without a detail message. */ - public JDOUserException() {} + private static final long serialVersionUID = 2552001511762583039L; - /** - * Constructs a new JDOUserException with the specified detail message. - * - * @param msg the detail message. - */ - public JDOUserException(String msg) { - super(msg); - } + /** + * Constructs a new JDOUserException without a detail message. + */ + public JDOUserException() { + } - /** - * Constructs a new JDOUserException with the specified detail message and nested - * Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - */ - public JDOUserException(String msg, Throwable[] nested) { - super(msg, nested); - } + /** + * Constructs a new JDOUserException with the specified detail message. + * @param msg the detail message. + */ + public JDOUserException(String msg) { + super(msg); + } - /** - * Constructs a new JDOUserException with the specified detail message and nested - * Throwables. - * - * @param msg the detail message. - * @param nested the nested Throwable. - */ - public JDOUserException(String msg, Throwable nested) { - super(msg, nested); - } + /** + * Constructs a new JDOUserException with the specified detail message + * and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable[]. + */ + public JDOUserException(String msg, Throwable[] nested) { + super(msg, nested); + } - /** - * Constructs a new JDOUserException with the specified detail message and failed - * object. - * - * @param msg the detail message. - * @param failed the failed object. - */ - public JDOUserException(String msg, Object failed) { - super(msg, failed); - } - - /** - * Constructs a new JDOUserException with the specified detail message, nested - * Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable[]. - * @param failed the failed object. - */ - public JDOUserException(String msg, Throwable[] nested, Object failed) { - super(msg, nested, failed); - } - - /** - * Constructs a new JDOUserException with the specified detail message, nested - * Throwables, and failed object. - * - * @param msg the detail message. - * @param nested the nested Throwable. - * @param failed the failed object. - */ - public JDOUserException(String msg, Throwable nested, Object failed) { - super(msg, nested, failed); - } + /** + * Constructs a new JDOUserException with the specified detail message + * and nested Throwables. + * @param msg the detail message. + * @param nested the nested Throwable. + */ + public JDOUserException(String msg, Throwable nested) { + super(msg, nested); + } + + /** Constructs a new JDOUserException with the specified detail message + * and failed object. + * @param msg the detail message. + * @param failed the failed object. + */ + public JDOUserException(String msg, Object failed) { + super(msg, failed); + } + + /** Constructs a new JDOUserException with the specified detail message, + * nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable[]. + * @param failed the failed object. + */ + public JDOUserException(String msg, Throwable[] nested, Object failed) { + super(msg, nested, failed); + } + + /** Constructs a new JDOUserException with the specified detail message, + * nested Throwables, and failed object. + * @param msg the detail message. + * @param nested the nested Throwable. + * @param failed the failed object. + */ + public JDOUserException(String msg, Throwable nested, Object failed) { + super(msg, nested, failed); + } } + diff --git a/api/src/main/java/javax/jdo/LegacyJava.java b/api/src/main/java/javax/jdo/LegacyJava.java index d8206c654..70cc2e74c 100644 --- a/api/src/main/java/javax/jdo/LegacyJava.java +++ b/api/src/main/java/javax/jdo/LegacyJava.java @@ -16,183 +16,171 @@ */ package javax.jdo; +import javax.jdo.spi.JDOPermission; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.security.Permission; -import java.security.PrivilegedAction; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; -import javax.jdo.spi.JDOPermission; +import java.security.*; /** - * This class provides wrapper implementations for the Java SecurityManager and AccessController - * classes that were deprecated in Java 17/18. - * - *

    For pre-17 this class provides access to the expected SecurityManager and AccessController. - * For 17+ the getSecurityManager() will always return 'null' and the doPrivileged() methods will - * simply execute the lambda argument without any security checks. - * - *

    Solution for AccessControl: This class uses reflection to detect whether AccessControl is - * deprecated. If it is deprecated we provide dummy implementation of 'doPrivileged'. If it is not - * deprecated we use the original implementation. Implementations are used by finding the desired - * methods and store them in a static field in LegacyJava. Whenever we need to call a method we can - * use reflection again to call the stored method in LegacyJava. - * - *

    Please note that the call to the stored method needs to happen from the original calling - * class. We cannot provide such a generic doPrivileged() in LegacyJava because it would be - * accessible from other classes and thus allow *any* caller to execute *any* code with - * doPrivileged() with the security context of LegacyJava. For the same reason the doPrivileged() - * implementations in the calling classes must be *private*. + * This class provides wrapper implementations for the Java SecurityManager and AccessController classes + * that were deprecated in Java 17/18. + *

    + * For pre-17 this class provides access to the expected SecurityManager and AccessController. + * For 17+ the getSecurityManager() will always return 'null' and the doPrivileged() methods will simply execute + * the lambda argument without any security checks. + *

    + * Solution for AccessControl: This class uses reflection to detect whether AccessControl is deprecated. + * If it is deprecated we provide dummy implementation of 'doPrivileged'. If it is not deprecated we use the + * original implementation. + * Implementations are used by finding the desired methods and store them in a static field in LegacyJava. + * Whenever we need to call a method we can use reflection again to call the stored method in LegacyJava. + *

    + * Please note that the call to the stored method needs to happen from the original calling class. We cannot provide + * such a generic doPrivileged() in LegacyJava because it would be accessible from other classes and thus + * allow *any* caller to execute *any* code with doPrivileged() with the security context of LegacyJava. For the same + * reason the doPrivileged() implementations in the calling classes must be *private*. */ public class LegacyJava { - private static final boolean isSecurityDeprecated = initIsSecurityDeprecated(); - private static final Method getSecurityManager = - isSecurityDeprecated ? null : findMethod("java.lang.System", "getSecurityManager"); - private static final SecurityManager securityManager = - getSecurityManager == null ? null : new SecurityManager(); - public static final Method doPrivilegedAction = - findMethod( - "java.security.AccessController", - "doPrivileged", - LegacyJava.class.getName(), - PrivilegedAction.class); - public static final Method doPrivilegedExceptionAction = - findMethod( - "java.security.AccessController", - "doPrivileged", - LegacyJava.class.getName(), - PrivilegedExceptionAction.class); + private static final boolean isSecurityDeprecated = initIsSecurityDeprecated(); + private static final Method getSecurityManager = isSecurityDeprecated ? null : + findMethod("java.lang.System", "getSecurityManager"); + private static final SecurityManager securityManager = getSecurityManager == null ? null : new SecurityManager(); + public static final Method doPrivilegedAction = + findMethod("java.security.AccessController", "doPrivileged", LegacyJava.class.getName(), PrivilegedAction.class); + public static final Method doPrivilegedExceptionAction = + findMethod("java.security.AccessController", "doPrivileged", LegacyJava.class.getName(), PrivilegedExceptionAction.class); - /** - * @return A wrapper around the java SecurityManager or 'null' if no SecurityManager is available - * or if it is deprecated (Java 17 and later). - */ - public static SecurityManager getSecurityManager() { - if (getSecurityManager == null) { - return null; - } - Object sm; - try { - sm = getSecurityManager.invoke(null); - } catch (IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); - throw new JDOFatalInternalException(e.getMessage()); - } - if (sm == null) { - return null; + /** + * @return A wrapper around the java SecurityManager or 'null' if no SecurityManager is available or if it + * is deprecated (Java 17 and later). + */ + public static SecurityManager getSecurityManager() { + if (getSecurityManager == null) { + return null; + } + Object sm; + try { + sm = getSecurityManager.invoke(null); + } catch (IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + throw new JDOFatalInternalException(e.getMessage()); + } + if (sm == null) { + return null; + } + + securityManager.updateSecurityManager(sm); + return securityManager; } - securityManager.updateSecurityManager(sm); - return securityManager; - } + /** + * @return 'true' if the security manager is deprecated or does not exist. + */ + public static boolean isSecurityManagerDeprecated() { + return isSecurityDeprecated; + } - /** - * @return 'true' if the security manager is deprecated or does not exist. - */ - public static boolean isSecurityManagerDeprecated() { - return isSecurityDeprecated; - } + /** + * The SecurityManager is only instantiated if it is not deprecated/removed in the Java API. + * It wraps the java SecurityManager and will forward any calls to it. + * It is updated in every call to getSecurityManager() to ensure that it uses the latest Java SecurityManager + * instance. + */ + public static class SecurityManager { + Object sm = null; + Method checkPermissionMethod = null; - /** - * The SecurityManager is only instantiated if it is not deprecated/removed in the Java API. It - * wraps the java SecurityManager and will forward any calls to it. It is updated in every call to - * getSecurityManager() to ensure that it uses the latest Java SecurityManager instance. - */ - public static class SecurityManager { - Object sm = null; - Method checkPermissionMethod = null; + public void checkPermission(JDOPermission permission) { + try { + checkPermissionMethod.invoke(null, permission); + } catch (IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + throw new JDOFatalInternalException(e.getMessage()); + } + } - public void checkPermission(JDOPermission permission) { - try { - checkPermissionMethod.invoke(null, permission); - } catch (IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); - throw new JDOFatalInternalException(e.getMessage()); - } + public void updateSecurityManager(Object sm) { + if (this.sm != sm) { + // We have a new security manager! + this.sm = sm; + if (sm != null) { + checkPermissionMethod = + findMethod("java.lang.SecurityManager", "checkPermission", Permission.class); + } else { + checkPermissionMethod = null; + } + } + } } - public void updateSecurityManager(Object sm) { - if (this.sm != sm) { - // We have a new security manager! - this.sm = sm; - if (sm != null) { - checkPermissionMethod = - findMethod("java.lang.SecurityManager", "checkPermission", Permission.class); - } else { - checkPermissionMethod = null; + /** + * @return 'true' if the security manager is deprecated or does not exist. + */ + private static boolean initIsSecurityDeprecated() { + try { + Method getSecurityManager = System.class.getMethod("getSecurityManager"); + return getSecurityManager.isAnnotationPresent(Deprecated.class); + } catch (NoSuchMethodException e) { + return true; } - } } - } - /** - * @return 'true' if the security manager is deprecated or does not exist. - */ - private static boolean initIsSecurityDeprecated() { - try { - Method getSecurityManager = System.class.getMethod("getSecurityManager"); - return getSecurityManager.isAnnotationPresent(Deprecated.class); - } catch (NoSuchMethodException e) { - return true; + private static Method findMethod(String cName, String mName, Class... args) { + if (isSecurityDeprecated) { + return null; + } + try { + Class accessController = Class.forName(cName); + return accessController.getMethod(mName, args); + } catch (NoSuchMethodException | ClassNotFoundException e) { + throw new JDOFatalInternalException(e.getMessage()); + } } - } - private static Method findMethod(String cName, String mName, Class... args) { - if (isSecurityDeprecated) { - return null; - } - try { - Class accessController = Class.forName(cName); - return accessController.getMethod(mName, args); - } catch (NoSuchMethodException | ClassNotFoundException e) { - throw new JDOFatalInternalException(e.getMessage()); + private static Method findMethod(String cName, String mName, String cNameAlt, Class... args) { + if (isSecurityDeprecated) { + cName = cNameAlt; + } + try { + Class accessController = Class.forName(cName); + return accessController.getMethod(mName, args); + } catch (NoSuchMethodException | ClassNotFoundException e) { + throw new JDOFatalInternalException(e.getMessage()); + } } - } - private static Method findMethod(String cName, String mName, String cNameAlt, Class... args) { - if (isSecurityDeprecated) { - cName = cNameAlt; - } - try { - Class accessController = Class.forName(cName); - return accessController.getMethod(mName, args); - } catch (NoSuchMethodException | ClassNotFoundException e) { - throw new JDOFatalInternalException(e.getMessage()); + /** + * This is a replacement for the old Java AccessControl.doPrivileged(). This replacement is used when the + * old doPrivileged() is deprecated or not available. + * This replacement simply execute the action without any further checks. + * + * @param privilegedAction The action to execute. + * @param Return type. + * @return Return value of the action. + */ + public static T doPrivileged(PrivilegedAction privilegedAction) { + return privilegedAction.run(); } - } - /** - * This is a replacement for the old Java AccessControl.doPrivileged(). This replacement is used - * when the old doPrivileged() is deprecated or not available. This replacement simply execute the - * action without any further checks. - * - * @param privilegedAction The action to execute. - * @param Return type. - * @return Return value of the action. - */ - public static T doPrivileged(PrivilegedAction privilegedAction) { - return privilegedAction.run(); - } - - /** - * This is a replacement for the old Java AccessControl.doPrivileged(). This replacement is used - * when the old doPrivileged() is deprecated or not available. This replacement simply execute the - * action without any further checks. - * - * @param privilegedAction The action to execute. - * @param Return type. - * @return Return value of the action. - * @throws PrivilegedActionException Never thrown. - */ - public static T doPrivileged(PrivilegedExceptionAction privilegedAction) - throws PrivilegedActionException { - try { - return privilegedAction.run(); - } catch (RuntimeException e) { - throw e; - } catch (Exception e) { - throw new PrivilegedActionException(e); + /** + * This is a replacement for the old Java AccessControl.doPrivileged(). This replacement is used when the + * old doPrivileged() is deprecated or not available. + * This replacement simply execute the action without any further checks. + * + * @param privilegedAction The action to execute. + * @param Return type. + * @return Return value of the action. + * @throws PrivilegedActionException Never thrown. + */ + public static T doPrivileged(PrivilegedExceptionAction privilegedAction) + throws PrivilegedActionException { + try { + return privilegedAction.run(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new PrivilegedActionException(e); + } } - } } diff --git a/api/src/main/java/javax/jdo/ObjectState.java b/api/src/main/java/javax/jdo/ObjectState.java index 7b407e360..72709dc4f 100644 --- a/api/src/main/java/javax/jdo/ObjectState.java +++ b/api/src/main/java/javax/jdo/ObjectState.java @@ -27,26 +27,29 @@ * @version 2.1 */ public enum ObjectState { - TRANSIENT("transient"), - TRANSIENT_CLEAN("transient-clean"), - TRANSIENT_DIRTY("transient-dirty"), - PERSISTENT_NEW("persistent-new"), - HOLLOW_PERSISTENT_NONTRANSACTIONAL("hollow/persistent-nontransactional"), - PERSISTENT_NONTRANSACTIONAL_DIRTY("persistent-nontransactional-dirty"), - PERSISTENT_CLEAN("persistent-clean"), - PERSISTENT_DIRTY("persistent-dirty"), - PERSISTENT_DELETED("persistent-deleted"), - PERSISTENT_NEW_DELETED("persistent-new-deleted"), - DETACHED_CLEAN("detached-clean"), - DETACHED_DIRTY("detached-dirty"); - - private final String value; - - private ObjectState(String value) { - this.value = value; - } - - public String toString() { - return value; - } + + TRANSIENT("transient"), + TRANSIENT_CLEAN("transient-clean"), + TRANSIENT_DIRTY("transient-dirty"), + PERSISTENT_NEW("persistent-new"), + HOLLOW_PERSISTENT_NONTRANSACTIONAL("hollow/persistent-nontransactional"), + PERSISTENT_NONTRANSACTIONAL_DIRTY("persistent-nontransactional-dirty"), + PERSISTENT_CLEAN("persistent-clean"), + PERSISTENT_DIRTY("persistent-dirty"), + PERSISTENT_DELETED("persistent-deleted"), + PERSISTENT_NEW_DELETED("persistent-new-deleted"), + DETACHED_CLEAN("detached-clean"), + DETACHED_DIRTY("detached-dirty"); + + private final String value; + + private ObjectState(String value) { + this.value = value; + } + + public String toString() { + return value; + } } + + diff --git a/api/src/main/java/javax/jdo/PersistenceManager.java b/api/src/main/java/javax/jdo/PersistenceManager.java index 9a7f8606b..c67c2079c 100644 --- a/api/src/main/java/javax/jdo/PersistenceManager.java +++ b/api/src/main/java/javax/jdo/PersistenceManager.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -26,1320 +26,1299 @@ import java.util.EnumSet; import java.util.Map; import java.util.Set; + import javax.jdo.datastore.JDOConnection; import javax.jdo.datastore.Sequence; + import javax.jdo.listener.InstanceLifecycleListener; -/** - * PersistenceManager is the primary interface for JDO-aware application components. It - * is the factory for Query and Transaction instances, and contains - * methods to manage the life cycle of PersistenceCapable instances. +/** PersistenceManager is the primary interface for JDO-aware + * application components. It is the factory for Query and + * Transaction instances, and contains methods to manage the + * life cycle of PersistenceCapable instances. * - *

    A PersistenceManager is obtained from the {@link PersistenceManagerFactory} + *

    A PersistenceManager is obtained from the + * {@link PersistenceManagerFactory} * (recommended) or by construction. - * * @version 2.1 */ + public interface PersistenceManager extends AutoCloseable { - /** - * A PersistenceManager instance can be used until it is closed. - * - * @return true if this PersistenceManager has been closed. - * @see #close() - */ - boolean isClosed(); - - /** - * Close this PersistenceManager so that no further requests may be made on it. A - * PersistenceManager instance can be used only until it is closed. - * - *

    Closing a PersistenceManager might release it to the pool of available - * PersistenceManagers, or might be garbage collected, at the option of the JDO - * implementation. Before being used again to satisfy a getPersistenceManager() - * request, the default values for options will be restored to their values as specified in the - * PersistenceManagerFactory. - * - *

    This method closes the PersistenceManager. - */ - void close(); - - /** - * Return the Transaction instance associated with a PersistenceManager. - * There is one Transaction instance associated with each PersistenceManager - * instance. The Transaction instance supports options as well as transaction - * completion requests. - * - * @return the Transaction associated with this PersistenceManager. - */ - Transaction currentTransaction(); - - /** - * Mark an instance as no longer needed in the cache. Eviction is normally done automatically by - * the PersistenceManager at transaction completion. This method allows the - * application to explicitly provide a hint to the PersistenceManager that the - * instance is no longer needed in the cache. - * - * @param pc the instance to evict from the cache. - */ - void evict(Object pc); - - /** - * Mark an array of instances as no longer needed in the cache. - * - * @see #evict(Object pc) - * @param pcs the array of instances to evict from the cache. - */ - void evictAll(Object... pcs); - - /** - * Mark a Collection of instances as no longer needed in the cache. - * - * @see #evict(Object pc) - * @param pcs the Collection of instances to evict from the cache. - */ - void evictAll(Collection pcs); - - /** - * Mark the parameter instances as no longer needed in the cache. - * - * @param pcClass the class of instances to evict - * @param subclasses if true, mark instances of subclasses also - * @since 2.1 - */ - void evictAll(boolean subclasses, Class pcClass); - - /** - * Mark all persistent-nontransactional instances as no longer needed in the cache. It transitions - * all persistent-nontransactional instances to hollow. Transactional instances are subject to - * eviction based on the RetainValues setting. - * - * @see #evict(Object pc) - */ - void evictAll(); - - /** - * Refresh the state of the instance from the data store. - * - *

    In an optimistic transaction, the state of instances in the cache might not match the state - * in the data store. This method is used to reload the state of the instance from the data store - * so that a subsequent commit is more likely to succeed. - * - *

    Outside a transaction, this method will refresh nontransactional state. - * - * @param pc the instance to refresh. - */ - void refresh(Object pc); - - /** - * Refresh the state of an array of instances from the data store. - * - * @see #refresh(Object pc) - * @param pcs the array of instances to refresh. - */ - void refreshAll(Object... pcs); - - /** - * Refresh the state of a Collection of instances from the data store. - * - * @see #refresh(Object pc) - * @param pcs the Collection of instances to refresh. - */ - void refreshAll(Collection pcs); - - /** - * Refresh the state of all applicable instances from the data store. - * - *

    If called with an active transaction, all transactional instances will be refreshed. If - * called outside an active transaction, all nontransactional instances will be refreshed. - * - * @see #refresh(Object pc) - */ - void refreshAll(); - - /** - * Refreshes all instances in the exception that failed verification. - * - * @param jdoe The exception defining object(s) to be refreshed - * @since 2.0 - */ - void refreshAll(JDOException jdoe); - - /** - * Create a new Query with no elements. - * - * @return the new Query. - */ - Query newQuery(); - - /** - * Create a new Query using elements from another Query. The other - * Query must have been created by the same JDO implementation. It might be active in - * a different PersistenceManager or might have been serialized and restored. - * - *

    All of the settings of the other Query are copied to this Query, - * except for the candidate Collection or Extent. - * - * @return the new Query - * @param compiled another Query from the same JDO implementation - */ - Query newQuery(Object compiled); - - /** - * Create a Construct a new query instance using the specified String as the single-string - * representation of the query. - * - * @param query the single-string query - * @return the new Query - * @since 2.0 - */ - Query newQuery(String query); - - /** - * Create a new Query using the specified language. - * - * @param language the language of the query parameter - * @param query the query, which is of a form determined by the language - * @return the new Query - */ - Query newQuery(String language, Object query); - - /** - * Create a new Query specifying the Class of the candidate instances. - * - * @param cls the Class of the candidate instances - * @return the new Query - * @param Candidate type for the query - */ - Query newQuery(Class cls); - - /** - * Create a new Query with the Class of the candidate instances and - * candidate Extent. - * - * @param cln the Extent of candidate instances - * @return the new Query - * @param Candidate type for the query - */ - Query newQuery(Extent cln); - - /** - * Create a new Query with the candidate Class and Collection - * . - * - * @param cls the Class of results - * @param cln the Collection of candidate instances - * @return the new Query - * @param Candidate type for the query - */ - Query newQuery(Class cls, Collection cln); - - /** - * Create a new Query with the Class of the candidate instances and - * filter. - * - * @param cls the Class of results - * @param filter the filter for candidate instances - * @return the new Query - * @param Candidate type for the query - */ - Query newQuery(Class cls, String filter); - - /** - * Create a new Query with the Class of the candidate instances, - * candidate Collection, and filter. - * - * @param cls the Class of candidate instances - * @param cln the Collection of candidate instances - * @param filter the filter for candidate instances - * @return the new Query - * @param Candidate type for the query - */ - Query newQuery(Class cls, Collection cln, String filter); - - /** - * Create a new Query with the candidate Extent and filter; the class is - * taken from the Extent. - * - * @param cln the Extent of candidate instances - * @param filter the filter for candidate instances - * @return the new Query - * @param Candidate type for the query - */ - Query newQuery(Extent cln, String filter); - - /** - * Create a new JDOQLTypedQuery with the specified candidate class. - * - * @param cls Candidate class for the query - * @return The JDOQLTypedQuery - * @param Candidate type for the query - * @since 3.2 - */ - JDOQLTypedQuery newJDOQLTypedQuery(Class cls); - - /** - * Create a new Query with the given candidate class from a named query. The query - * name given must be the name of a query defined in metadata. - * - * @param cls the Class of candidate instances - * @param queryName the name of the query to look up in metadata - * @return the new Query - * @param Candidate type for the query - */ - Query newNamedQuery(Class cls, String queryName); - - /** - * The PersistenceManager manages a collection of instances in the data store based - * on the class of the instances. This method returns an Extent of instances in the - * data store that might be iterated or given to a Query. The Extent - * itself might not reference any instances, but only hold the class name and an indicator as to - * whether subclasses are included in the Extent. - * - *

    Note that the Extent might be very large. - * - * @param persistenceCapableClass Class of instances - * @param subclasses whether to include instances of subclasses - * @return an Extent of the specified Class - * @see Query - * @param Type for the candidate of the Extent - */ - Extent getExtent(Class persistenceCapableClass, boolean subclasses); - - /** - * Equivalent to getExtent (persistenceCapableClass, true). - * - * @see #getExtent(Class,boolean) - * @since 2.0 - * @param persistenceCapableClass Candidate class for the extent - * @return an Extent of the specified Class - * @param Type for the candidate of the Extent - */ - Extent getExtent(Class persistenceCapableClass); - - /** - * This method locates a persistent instance in the cache of instances managed by this - * PersistenceManager. The getObjectById method attempts to find an instance - * in the cache with the specified JDO identity. The oid parameter object might have - * been returned by an earlier call to getObjectId or getTransactionalObjectId - * , or might have been constructed by the application. - * - *

    If the PersistenceManager is unable to resolve the oid parameter - * to an ObjectId instance, then it throws a JDOUserException. - * - *

    If the validate flag is false, and there is already an instance in - * the cache with the same JDO identity as the oid parameter, then this method - * returns it. There is no change made to the state of the returned instance. - * - *

    If there is not an instance already in the cache with the same JDO identity as the oid - * parameter, then this method creates an instance with the specified JDO identity and - * returns it. If there is no transaction in progress, the returned instance will be hollow or - * persistent-nontransactional, at the choice of the implementation. - * - *

    If there is a transaction in progress, the returned instance will be hollow, - * persistent-nontransactional, or persistent-clean, at the choice of the implementation. - * - *

    It is an implementation decision whether to access the data store, if required to determine - * the exact class. This will be the case of inheritance, where multiple PersistenceCapable - * classes share the same ObjectId class. - * - *

    If the validate flag is false, and the instance does not exist in the data - * store, then this method might not fail. It is an implementation choice whether to fail - * immediately with a JDOObjectNotFoundException. But a subsequent access of the - * fields of the instance will throw a JDOObjectNotFoundException if the instance - * does not exist at that time. Further, if a relationship is established to this instance, then - * the transaction in which the association was made will fail. - * - *

    If the validate flag is true, and there is already a transactional - * instance in the cache with the same JDO identity as the oid parameter, then this - * method returns it. There is no change made to the state of the returned instance. - * - *

    If there is an instance already in the cache with the same JDO identity as the oid - * parameter, but the instance is not transactional, then it must be verified in the data - * store. If the instance does not exist in the datastore, then a JDOObjectNotFoundException - * is thrown. - * - *

    If there is not an instance already in the cache with the same JDO identity as the oid - * parameter, then this method creates an instance with the specified JDO identity, - * verifies that it exists in the data store, and returns it. If there is no transaction in - * progress, the returned instance will be hollow or persistent-nontransactional, at the choice of - * the implementation. - * - *

    If there is a data store transaction in progress, the returned instance will be - * persistent-clean. If there is an optimistic transaction in progress, the returned instance will - * be persistent-nontransactional. - * - * @see #getObjectId(Object pc) - * @see #getTransactionalObjectId(Object pc) - * @return the PersistenceCapable instance with the specified ObjectId - * @param oid an ObjectId - * @param validate if the existence of the instance is to be validated - */ - Object getObjectById(Object oid, boolean validate); - - /** - * Looks up the instance of the given type with the given key. - * - * @param cls The type of object to load - * @param key either the string representation of the object id, or an object representation of a - * single field identity key - * @return the corresponding persistent instance - * @since 2.0 - * @param Type of the persistable object being retrieved - */ - T getObjectById(Class cls, Object key); - - /** - * Looks up the instance corresponding to the specified oid. This is equivalent to - * getObjectById(oid, true); - * - * @param oid The object id of the object to load - * @return the corresponding persistent instance - */ - Object getObjectById(Object oid); - - /** - * The ObjectId returned by this method represents the JDO identity of the instance. The ObjectId - * is a copy (clone) of the internal state of the instance, and changing it does not affect the - * JDO identity of the instance. - * - *

    The getObjectId method returns an ObjectId instance that represents the object - * identity of the specified JDO instance. The identity is guaranteed to be unique only in the - * context of the JDO PersistenceManager that created the identity, and only for two - * types of JDO Identity: those that are managed by the application, and those that are managed by - * the data store. - * - *

    If the object identity is being changed in the transaction, by the application modifying one - * or more of the application key fields, then this method returns the identity as of the - * beginning of the transaction. The value returned by getObjectId will be different - * following afterCompletion processing for successful transactions. - * - *

    Within a transaction, the ObjectId returned will compare equal to the ObjectId returned by - * only one among all JDO instances associated with the PersistenceManager regardless - * of the type of ObjectId. - * - *

    The ObjectId does not necessarily contain any internal state of the instance, nor is it - * necessarily an instance of the class used to manage identity internally. Therefore, if the - * application makes a change to the ObjectId instance returned by this method, there is no effect - * on the instance from which the ObjectId was obtained. - * - *

    The getObjectById method can be used between instances of - * PersistenceManager of different JDO vendors only for instances of persistence capable - * classes using application-managed (primary key) JDO identity. If it is used for instances of - * classes using datastore identity, the method might succeed, but there are no guarantees that - * the parameter and return instances are related in any way. - * - * @see #getTransactionalObjectId(Object pc) - * @see #getObjectById(Object oid, boolean validate) - * @param pc the PersistenceCapable instance - * @return the ObjectId of the instance - */ - Object getObjectId(Object pc); - - /** - * The ObjectId returned by this method represents the JDO identity of the instance. The ObjectId - * is a copy (clone) of the internal state of the instance, and changing it does not affect the - * JDO identity of the instance. - * - *

    If the object identity is being changed in the transaction, by the application modifying one - * or more of the application key fields, then this method returns the current identity in the - * transaction. - * - *

    If there is no transaction in progress, or if none of the key fields is being modified, then - * this method will return the same value as getObjectId. - * - * @see #getObjectId(Object pc) - * @see #getObjectById(Object oid, boolean validate) - * @param pc a PersistenceCapable instance - * @return the ObjectId of the instance - */ - Object getTransactionalObjectId(Object pc); - - /** - * This method returns an object id instance corresponding to the pcClass and key arguments. - * - * @param pcClass the Class of the persistence-capable instance - * @param key for single-field identity, the parameter for the constructor; for non-single-field - * application identity, the result of toString() on the object id instance. - * @return an instance of the object identity class - */ - Object newObjectIdInstance(Class pcClass, Object key); - - /** - * Return the objects with the given oids. - * - * @param oids the oids of the objects to return - * @param validate if true, the existance of the objects in the datastore will be validated. - * @return the objects that were looked up, in the same order as the oids parameter. - * @see #getObjectById(Object,boolean) - * @since 2.0 - */ - Collection getObjectsById(Collection oids, boolean validate); - - /** - * Return the objects with the given oids. This method is equivalent to calling {@link - * #getObjectsById(Collection, boolean)} with the validate flag true. - * - * @param oids the oids of the objects to return - * @return the objects that were looked up, in the same order as the oids parameter. - * @see #getObjectsById(Collection,boolean) - * @since 2.0 - */ - Collection getObjectsById(Collection oids); - - /** - * Return the objects with the given oids. - * - * @param oids the oids of the objects to return - * @param validate if true, the existance of the objects in the datastore will be validated. - * @return the objects that were looked up, in the same order as the oids parameter. - * @see #getObjectById(Object,boolean) - * @since 2.1 - */ - Object[] getObjectsById(boolean validate, Object... oids); - - /** - * Return the objects with the given oids. This method is equivalent to calling {@link - * #getObjectsById(boolean,Object...)} with the validate flag true. - * - * @param oids the oids of the objects to return - * @return the objects that were looked up, in the same order as the oids parameter. - * @see #getObjectsById(boolean,Object...) - * @since 2.0 - */ - Object[] getObjectsById(Object... oids); - - /** - * Make the parameter instance persistent in this PersistenceManager. This method - * makes transient instances persistent and applies detached instance changes to the cache. It - * must be called in the context of an active transaction, or a JDOUserException is thrown. For a - * transient instance, it assigns an object identity to the instance and transitions it to - * persistent-new. Any transient instances reachable from this instance via persistent fields of - * this instance become provisionally persistent, transitively. That is, they behave as - * persistent-new instances (return true to isPersistent, isNew, and isDirty). But at commit time, - * the reachability algorithm is run again, and instances made provisionally persistent that are - * not then reachable from persistent instances will revert to transient. - * - *

    During makePersistent of transient instances, the create life cycle listener is called. - * - *

    For detached instances, it locates or instantiates a persistent instance with the same JDO - * identity as the detached instance, and merges the persistent state of the detached instance - * into the persistent instance. Only the state of persistent fields is merged. If non-persistent - * state needs to be copied, the application should use the jdoPostAttach callback or the - * postAttach lifecycle event listener. Any references to the detached instances from instances in - * the closure of the parameter instances are modified to refer to the corresponding persistent - * instance instead of to the detached instance. - * - *

    During attachment of detached instances, the attach callbacks and attach life cycle - * listeners are called. - * - *

    During application of changes of the detached state, if the JDO implementation can determine - * that there were no changes made during detachment, then the implementation is not required to - * mark the corresponding instance dirty. If it cannot determine if changes were made, then it - * must mark the instance dirty. No consistency checking is done during makePersistent of detached - * instances. If consistency checking is required by the application, then flush or - * checkConsistency should be called after attaching the instances. - * - *

    These methods have no effect on parameter persistent instances already managed by this - * PersistenceManager. They will throw a JDOUserException if the parameter instance is managed by - * a different PersistenceManager. If an instance is of a class whose identity type (application, - * datastore, or none) is not supported by the JDO implementation, then a JDOUserException will be - * thrown for that instance. The return value for parameter instances in the transient or - * persistent states is the same as the parameter value. The return value for parameter instances - * in the detached state is the persistent instance corresponding to the detached instance. The - * return values for makePersistentAll methods correspond by position to the parameter instances. - * - * @param pc an instance of a Class that is persistent capable. - * @return the parameter instance for parameters in the transient or persistent state, or the - * corresponding persistent instance for detached parameter instances - * @param Type of the persistable object - */ - T makePersistent(T pc); - - /** - * Make an array of instances persistent. - * - * @param pcs an array of instances - * @return the parameter instances for parameters in the transient or persistent state, or the - * corresponding persistent instance for detached parameter instances, in the same order as in - * the parameter array - * @see #makePersistent(Object pc) - * @param Type of the persistable object - */ - @SuppressWarnings({"unchecked", "varargs"}) - T[] makePersistentAll(T... pcs); - - /** - * Make a Collection of instances persistent. - * - * @param pcs a Collection of instances - * @return the parameter instance for parameters in the transient or persistent state, or the - * corresponding persistent instance for detached parameter instances, with an iteration in - * the same order as in the parameter Collection - * @see #makePersistent(Object pc) - * @param Type of the persistable object - */ - Collection makePersistentAll(Collection pcs); - - /** - * Delete the persistent instance from the data store. This method must be called in an active - * transaction. The data store object will be removed at commit. Unlike makePersistent - * , which makes the closure of the instance persistent, the closure of the instance is not - * deleted from the data store. This method has no effect if the instance is already deleted in - * the current transaction. This method throws JDOUserException if the instance is - * transient or is managed by another PersistenceManager. - * - * @param pc a persistent instance - */ - void deletePersistent(Object pc); - - /** - * Delete an array of instances from the data store. - * - * @param pcs a Collection of persistent instances - * @see #deletePersistent(Object pc) - */ - void deletePersistentAll(Object... pcs); - - /** - * Delete a Collection of instances from the data store. - * - * @param pcs a Collection of persistent instances - * @see #deletePersistent(Object pc) - */ - void deletePersistentAll(Collection pcs); - - /** - * Make an instance transient, removing it from management by this PersistenceManager - * . - * - *

    The instance loses its JDO identity and it is no longer associated with any - * PersistenceManager. The state of fields is preserved unchanged. - * - * @param pc the instance to make transient. - */ - void makeTransient(Object pc); - - /** - * Make an array of instances transient, removing them from management by this - * PersistenceManager. - * - *

    The instances lose their JDO identity and they are no longer associated with any - * PersistenceManager. The state of fields is preserved unchanged. - * - * @param pcs the instances to make transient. - */ - void makeTransientAll(Object... pcs); - - /** - * Make a Collection of instances transient, removing them from management by this - * PersistenceManager. - * - *

    The instances lose their JDO identity and they are no longer associated with any - * PersistenceManager. The state of fields is preserved unchanged. - * - * @param pcs the instances to make transient. - */ - void makeTransientAll(Collection pcs); - - /** - * Make an instance transient, removing it from management by this PersistenceManager - * . If the useFetchPlan parameter is false, this method behaves exactly as makeTransient(Object - * pc). - * - *

    The affected instance(s) lose their JDO identity and are no longer associated with any - * PersistenceManager. The state of fields is unchanged. - * - *

    If the useFetchPlan parameter is true, then the current FetchPlan is applied to the pc - * parameter, as if detachCopy(Object) had been called. After the graph of instances is loaded, - * the instances reachable via loaded fields is made transient. The state of fields in the - * affected instances is as specified by the FetchPlan. - * - *

    Unlike detachCopy, the instances are not detached; there is no detachment information in the - * instances. - * - *

    The instances to be made transient do not need to implement the javax.jdo.spi.Detachable - * interface. - * - * @param pc the root instance to make transient. - * @param useFetchPlan whether to use the current fetch plan to determine which fields to load and - * which instances to make transient - * @since 2.0 - */ - void makeTransient(Object pc, boolean useFetchPlan); - - /** - * Make instances transient, removing them from management by this PersistenceManager - * . If the useFetchPlan parameter is false, this method behaves exactly as - * makeTransientAll(Object[] pcs). - * - *

    The affected instance(s) lose their JDO identity and are no longer associated with any - * PersistenceManager. The state of fields is unchanged. - * - *

    If the useFetchPlan parameter is true, then the current FetchPlan is applied to the pcs - * parameters and the entire graph of instances reachable via loaded fields is made transient. The - * state of fields in the affected instances is as specified by the FetchPlan. - * - *

    Unlike detachCopy, the instances are not detached; there is no detachment information in the - * instances. - * - *

    The instances to be made transient do not need to implement the javax.jdo.spi.Detachable - * interface. - * - * @param pcs the root instances to make transient. - * @param useFetchPlan whether to use the current fetch plan to determine which fields to load and - * which instances to make transient - * @since 2.1 - */ - void makeTransientAll(boolean useFetchPlan, Object... pcs); - - /** - * Make instances transient, removing them from management by this PersistenceManager - * . If the useFetchPlan parameter is false, this method behaves exactly as - * makeTransientAll(Collection pcs). - * - *

    The affected instance(s) lose their JDO identity and are no longer associated with any - * PersistenceManager. The state of fields is unchanged. - * - *

    If the useFetchPlan parameter is true, then the current FetchPlan is applied to the pcs - * parameters and the entire graph of instances reachable via loaded fields is made transient. The - * state of fields in the affected instances is as specified by the FetchPlan. - * - *

    Unlike detachCopy, the instances are not detached; there is no detachment information in the - * instances. - * - *

    The instances to be made transient do not need to implement the javax.jdo.spi.Detachable - * interface. - * - * @param pcs the root instances to make transient. - * @param useFetchPlan whether to use the current fetch plan to determine which fields to load and - * which instances to make transient - * @since 2.0 - */ - void makeTransientAll(Collection pcs, boolean useFetchPlan); - - /** - * Make an instance subject to transactional boundaries. - * - *

    Transient instances normally do not observe transaction boundaries. This method makes - * transient instances sensitive to transaction completion. If an instance is modified in a - * transaction, and the transaction rolls back, the state of the instance is restored to the state - * before the first change in the transaction. - * - *

    For persistent instances read in optimistic transactions, this method allows the application - * to make the state of the instance part of the transactional state. At transaction commit, the - * state of the instance in the cache is compared to the state of the instance in the data store. - * If they are not the same, then an exception is thrown. - * - * @param pc the instance to make transactional. - */ - void makeTransactional(Object pc); - - /** - * Make an array of instances subject to transactional boundaries. - * - * @param pcs the array of instances to make transactional. - * @see #makeTransactional(Object pc) - */ - void makeTransactionalAll(Object... pcs); - - /** - * Make a Collection of instances subject to transactional boundaries. - * - * @param pcs the Collection of instances to make transactional. - * @see #makeTransactional(Object pc) - */ - void makeTransactionalAll(Collection pcs); - - /** - * Make an instance non-transactional after commit. - * - *

    Normally, at transaction completion, instances are evicted from the cache. This method - * allows an application to identify an instance as not being evicted from the cache at - * transaction completion. Instead, the instance remains in the cache with nontransactional state. - * - * @param pc the instance to make nontransactional. - */ - void makeNontransactional(Object pc); - - /** - * Make an array of instances non-transactional after commit. - * - * @param pcs the array of instances to make nontransactional. - * @see #makeNontransactional(Object pc) - */ - void makeNontransactionalAll(Object... pcs); - - /** - * Make a Collection of instances non-transactional after commit. - * - * @param pcs the Collection of instances to make nontransactional. - * @see #makeNontransactional(Object pc) - */ - void makeNontransactionalAll(Collection pcs); - - /** - * Retrieve field values of an instance from the store. This tells the PersistenceManager - * that the application intends to use the instance, and its field values must be - * retrieved. - * - *

    The PersistenceManager might use policy information about the class to retrieve - * associated instances. - * - * @param pc the instance - */ - void retrieve(Object pc); - - /** - * Retrieve field values of an instance from the store. This tells the PersistenceManager - * that the application intends to use the instance, and its field values must be - * retrieved. - * - *

    If the useFetchPlan parameter is false, this method behaves exactly as the corresponding - * method without the useFetchPlan parameter. If the useFetchPlan parameter is true, and the fetch - * plan has not been modified from its default setting, all fields in the current fetch plan are - * fetched, and other fields might be fetched lazily by the implementation. If the useFetchPlan - * parameter is true, and the fetch plan has been changed from its default setting, then the - * fields specified by the fetch plan are loaded, along with related instances specified by the - * fetch plan. - * - * @param pc the instance - * @param useFetchPlan whether to use the current fetch plan to determine which fields to load and - * which instances to retrieve. - * @since 2.0 - */ - void retrieve(Object pc, boolean useFetchPlan); - - /** - * Retrieve field values of instances from the store. This tells the PersistenceManager - * that the application intends to use the instances, and all field values must be - * retrieved. - * - *

    The PersistenceManager might use policy information about the class to retrieve - * associated instances. - * - * @param pcs the instances - */ - void retrieveAll(Collection pcs); - - /** - * Retrieve field values of instances from the store. This tells the PersistenceManager - * that the application intends to use the instances, and their field values should be - * retrieved. The fields in the current fetch group must be retrieved, and the implementation - * might retrieve more fields than the current fetch group. - * - *

    If the useFetchPlan parameter is false, this method behaves exactly as the corresponding - * method without the useFetchPlan parameter. If the useFetchPlan parameter is true, and the fetch - * plan has not been modified from its default setting, all fields in the current fetch plan are - * fetched, and other fields might be fetched lazily by the implementation. If the useFetchPlan - * parameter is true, and the fetch plan has been changed from its default setting, then the - * fields specified by the fetch plan are loaded, along with related instances specified by the - * fetch plan. - * - * @param pcs the instances - * @param useFetchPlan whether to use the current fetch plan to determine which fields to load and - * which instances to retrieve. - * @since 1.0.1 - */ - void retrieveAll(Collection pcs, boolean useFetchPlan); - - /** - * Retrieve field values of instances from the store. This tells the PersistenceManager - * that the application intends to use the instances, and all field values must be - * retrieved. - * - *

    The PersistenceManager might use policy information about the class to retrieve - * associated instances. - * - * @param pcs the instances - */ - void retrieveAll(Object... pcs); - - /** - * Retrieve field values of instances from the store. This tells the PersistenceManager - * that the application intends to use the instances, and their field values should be - * retrieved. The fields in the current fetch group must be retrieved, and the implementation - * might retrieve more fields than the current fetch group. - * - *

    If the useFetchPlan parameter is false, this method behaves exactly as the corresponding - * method without the useFetchPlan parameter. If the useFetchPlan parameter is true, and the fetch - * plan has not been modified from its default setting, all fields in the current fetch plan are - * fetched, and other fields might be fetched lazily by the implementation. If the useFetchPlan - * parameter is true, and the fetch plan has been changed from its default setting, then the - * fields specified by the fetch plan are loaded, along with related instances specified by the - * fetch plan. - * - * @param pcs the instances - * @param useFetchPlan whether to use the current fetch plan to determine which fields to load and - * which instances to retrieve. - * @since 2.1 - */ - void retrieveAll(boolean useFetchPlan, Object... pcs); - - /** - * The application can manage the PersistenceManager instances more easily by having - * an application object associated with each PersistenceManager instance. - * - * @param o the user instance to be remembered by the PersistenceManager - * @see #getUserObject - */ - void setUserObject(Object o); - - /** - * The application can manage the PersistenceManager instances more easily by having - * an application object associated with each PersistenceManager instance. - * - * @return the user object associated with this PersistenceManager - * @see #setUserObject - */ - Object getUserObject(); - - /** - * This method returns the PersistenceManagerFactory used to create this - * PersistenceManager. - * - * @return the PersistenceManagerFactory that created this PersistenceManager - * - */ - PersistenceManagerFactory getPersistenceManagerFactory(); - - /** - * Return the Class that implements the JDO Identity for the specified - * PersistenceCapable class. The application can use the returned Class to - * construct a JDO Identity instance for application identity PersistenceCapable - * classes. This JDO Identity instance can then be used to get an instance of the - * PersistenceCapable class for use in the application. - * - *

    In order for the application to construct an instance of the ObjectId class it needs to know - * the class being used by the JDO implementation. - * - * @param cls the PersistenceCapable Class - * @return the Class of the ObjectId of the parameter - * @see #getObjectById - */ - Class getObjectIdClass(Class cls); - - /** - * Set the Multithreaded flag for this PersistenceManager. Applications that use - * multiple threads to invoke methods or access fields from instances managed by this - * PersistenceManager must set this flag to true. Instances managed by this - * PersistenceManager include persistent or transactional instances of - * PersistenceCapable classes, as well as helper instances such as Query, - * Transaction, or Extent. - * - * @param flag the Multithreaded setting. - */ - void setMultithreaded(boolean flag); - - /** - * Get the current Multithreaded flag for this PersistenceManager. - * - * @see #setMultithreaded - * @return the Multithreaded setting. - */ - boolean getMultithreaded(); - - /** - * Set the ignoreCache parameter for queries. - * - *

    IgnoreCache set to true specifies that for all Query instances - * created by this PersistenceManager, the default is the cache should be ignored for - * queries. - * - * @param flag the ignoreCache setting. - */ - void setIgnoreCache(boolean flag); - - /** - * Get the ignoreCache setting for queries. - * - *

    IgnoreCache set to true specifies that for all Query instances - * created by this PersistenceManager, the default is the cache should be ignored for - * queries. - * - * @return the ignoreCache setting. - */ - boolean getIgnoreCache(); - - /** - * Specify a timeout interval (milliseconds) for any datastore read operations associated with - * this persistence manager. To unset the explicit timeout, specify null. For no timeout, specify - * 0. Read operations include, for example, those associated with query, getObjectById, refresh, - * retrieve, and extent iteration operations. If the datastore granularity is larger than - * milliseconds, the timeout value will be rounded up to the nearest supported datastore value. If - * a read operation hasn't completed within this interval, the operation will throw a - * JDODatastoreException. If multiple datastore operations are required to complete the query, the - * timeout value applies to each of them individually. If the datastore and JDO implementation - * support timeouts, then javax.jdo.option.DatastoreTimeout is returned by - * PersistenceManagerFactory.supportedOptions(). If timeouts are not supported,this method will - * throw JDOUnsupportedOptionException. - * - * @since 3.0 - * @param interval the timeout interval (milliseconds) - */ - void setDatastoreReadTimeoutMillis(Integer interval); - - /** - * Get the effective timeout setting for datastore read operations associated with this - * persistence manager. If the timeout has not been set on this persistence manager explicitly, - * the default read timeout value from the persistence manager factory is returned. - * - * @see #setDatastoreReadTimeoutMillis(Integer) - * @see PersistenceManagerFactory#setDatastoreReadTimeoutMillis(Integer) - * @return the effective timeout setting (milliseconds). - * @since 3.0 - */ - Integer getDatastoreReadTimeoutMillis(); - - /** - * Specify a timeout interval (milliseconds) for any write operations associated with this - * persistence manager. To unset the explicit timeout, specify null. For no timeout, specify 0. - * Datastore write operations include, for example, operations associated with flush, commit, and - * delete by query. If the datastore granularity is larger than milliseconds, the timeout value - * will be rounded up to the nearest supported datastore value. If a write operation hasn't - * completed within this interval, methods will throw a JDODatastoreException. If multiple - * datastore operations are required to complete the method, the timeout value applies to each of - * them individually. If the datastore and JDO implementation support timeouts, then - * javax.jdo.option.DatastoreTimeout is returned by PersistenceManagerFactory.supportedOptions(). - * If timeouts are not supported,this method will throw JDOUnsupportedOptionException. - * - * @since 3.0 - * @param interval the timeout interval (milliseconds) - */ - void setDatastoreWriteTimeoutMillis(Integer interval); - - /** - * Get the effective timeout setting for write operations. If the timeout has not been set on this - * persistence manager explicitly, the default datastore write timeout value from the persistence - * manager factory is returned. - * - * @see #setDatastoreWriteTimeoutMillis(Integer) - * @see PersistenceManagerFactory#setDatastoreWriteTimeoutMillis(Integer) - * @return the effective timeout setting (milliseconds). - * @since 3.0 - */ - Integer getDatastoreWriteTimeoutMillis(); - - /** - * Gets the detachAllOnCommit setting. - * - * @see #setDetachAllOnCommit(boolean) - * @since 2.0 - * @return the detachAllOnCommit setting. - */ - boolean getDetachAllOnCommit(); - - /** - * Sets the detachAllOnCommit setting. - * - *

    DetachAllOnCommit set to false specifies that the state of persistent instances - * in the cache after commit is defined by the retainValues flag. With this flag set - * to true, during beforeCompletion all cached instances are prepared for detachment according to - * the fetch plan in effect at commit. Loading fields and unloading fields required by the fetch - * plan is done after calling the user's beforeCompletion callback. During - * afterCompletion, before calling the user's afterCompletion callback, all - * detachable persistent instances in the cache transition to detached; non-detachable persistent - * instances transition to transient; and detachable instances can be serialized as detached - * instances. Transient transactional instances are unaffected by this flag. - * - * @param flag Flag for whether to detach all on commit - * @see #getDetachAllOnCommit() - * @since 2.0 - */ - void setDetachAllOnCommit(boolean flag); - - /** - * Gets the copyOnAttach setting. - * - * @see #setCopyOnAttach(boolean) - * @since 2.1 - * @return the copyOnAttach setting. - */ - boolean getCopyOnAttach(); - - /** - * Sets the copyOnAttach setting. - * - *

    CopyOnAttach set to true specifies that during makePersistent, copies are made - * of detached parameter instances. With this flag set to false, detached parameter - * instances are attached directly and change their state from detached-clean to persistent-clean - * or from detached-dirty to persistent-dirty. - * - * @param flag Flag for whether to copy on attach - * @see #getCopyOnAttach() - * @since 2.1 - */ - void setCopyOnAttach(boolean flag); - - /** - * Detach the specified instance from the PersistenceManager. The flags for - * detachment (DETACH_LOAD_FIELDS and DETACH_UNLOAD_FIELDS) and the active fetch groups determine - * the scope of fetching for the graph of instances reachable from the pc parameter. The state of - * fields in the affected instances is as specified by the FetchPlan. - * - * @param pc the instance to detach - * @return the detached instance - * @see #detachCopyAll(Object[]) - * @since 2.0 - * @param Type of the persistable object - */ - T detachCopy(T pc); - - /** - * Detach the specified instances from the PersistenceManager. The flags for - * detachment (DETACH_LOAD_FIELDS and DETACH_UNLOAD_FIELDS) and the active fetch groups determine - * the scope of fetching for the graph of instances reachable from the pcs parameter. The state of - * fields in the affected instances is as specified by the FetchPlan. - * - * @param pcs the instances to detach - * @return the detached instances - * @see #detachCopyAll(Object[]) - * @since 2.0 - * @param Type of the persistable objects - */ - Collection detachCopyAll(Collection pcs); - - /** - * Detach the specified instances from the PersistenceManager. The flags for - * detachment (DETACH_LOAD_FIELDS and DETACH_UNLOAD_FIELDS) and the active fetch groups determine - * the scope of fetching for the graph of instances reachable from the pcs parameter. The state of - * fields in the affected instances is as specified by the FetchPlan. The objects returned can be - * manipulated and re-attached with {@link #makePersistentAll(Object[])}. The detached instances - * will be unmanaged copies of the specified parameters, and are suitable for serialization and - * manipulation outside of a JDO environment. When detaching instances, only fields in the current - * {@link FetchPlan} will be traversed. Thus, to detach a graph of objects, relations to other - * persistent instances must either be in the default-fetch-group, or in the current - * custom {@link FetchPlan}. - * - * @param pcs the instances to detach - * @return the detached instances - * @throws JDOUserException if any of the instances to be detached do not implement the - * javax.jdo.spi.Detachable interface. - * @see #makePersistentAll(Object[]) - * @see #getFetchPlan - * @since 2.0 - * @param Type of the persistable object - */ - @SuppressWarnings({"unchecked", "varargs"}) - T[] detachCopyAll(T... pcs); - - /** - * Put the specified key-value pair into the map of user objects. - * - * @since 2.0 - * @param key Key to store the user object under - * @param val User object to store - * @return The previous object under this key - */ - Object putUserObject(Object key, Object val); - - /** - * Get the value for the specified key from the map of user objects. - * - * @param key the key of the object to be returned - * @return the object - * @since 2.0 - */ - Object getUserObject(Object key); - - /** - * Remove the specified key and its value from the map of user objects. - * - * @param key the key of the object to be removed - * @return The user object that was removed - * @since 2.0 - */ - Object removeUserObject(Object key); - - /** - * Flushes all dirty, new, and deleted instances to the data store. It has no effect if a - * transaction is not active. - * - *

    If a datastore transaction is active, this method synchronizes the cache with the datastore - * and reports any exceptions. - * - *

    If an optimistic transaction is active, this method obtains a datastore connection, - * synchronizes the cache with the datastore using this connection and reports any exceptions. The - * connection obtained by this method is held until the end of the transaction. - * - *

    If exceptions occur during flush, the implementation will set the current transaction's - * RollbackOnly flag (see {@link Transaction#setRollbackOnly}). - * - * @since 2.0 - */ - void flush(); - - /** - * Validates the PersistenceManager cache with the datastore. This method has no - * effect if a transaction is not active. - * - *

    If a datastore transaction is active, this method verifies the consistency of instances in - * the cache against the datastore. An implementation might flush instances as if {@link #flush} - * were called, but it is not required to do so. - * - *

    If an optimistic transaction is active, this method obtains a datastore connection and - * verifies the consistency of the instances in the cache against the datastore. If any - * inconsistencies are detected, a {@link JDOOptimisticVerificationException} is thrown. This - * exception contains a nested {@link JDOOptimisticVerificationException} for each object that - * failed the consistency check. No datastore resources acquired during the execution of this - * method are held beyond the scope of this method. - * - * @since 2.0 - */ - void checkConsistency(); - - /** - * Returns the FetchPlan used by this PersistenceManager. - * - * @return the FetchPlan - * @since 2.0 - */ - FetchPlan getFetchPlan(); - - /** - * Creates an instance of a persistence-capable interface, or of a concrete or abstract class. The - * returned instance is transient. - * - * @param pcClass Must be a persistence-capable interface, or a concrete or abstract class that is - * declared in the metadata. - * @return the created instance - * @since 2.0 - * @param Type of the persistable object - */ - T newInstance(Class pcClass); - - /** - * Returns the sequence identified by name. - * - * @param name the name of the Sequence - * @return the Sequence - * @since 2.0 - */ - Sequence getSequence(String name); - - /** - * If this method is called while a datastore transaction is active, the object returned will be - * enlisted in the current transaction. If called in an optimistic transaction or outside an - * active transaction, the object returned will not be enlisted in any transaction. - * - * @return the JDOConnection instance - * @since 2.0 - */ - JDOConnection getDataStoreConnection(); - - /** - * Adds the listener instance to the list of lifecycle event listeners. The classes - * parameter identifies all of the classes of interest. If the classes parameter is - * specified as null, events for all persistent classes and interfaces will be sent - * to listenerInstance. - * - *

    The listenerInstance will be called for each event for which it implements the corresponding - * listenerInstance interface. - * - * @param listener the lifecycle listener - * @param classes the classes of interest to the listener - * @since 2.0 - */ - void addInstanceLifecycleListener(InstanceLifecycleListener listener, Class... classes); - - /** - * Removes the listener instance from the list of lifecycle event listeners. - * - * @param listener the listener instance to be removed - * @since 2.0 - */ - void removeInstanceLifecycleListener(InstanceLifecycleListener listener); - - /** - * Get the Date as seen by the server. Clients using this method can order their operations - * according to a single time source. Implementations use the setting of the server time zone to - * prepare a Date instance that represents UTC time on the server. - * - * @return a Date instance corresponding to the UTC Date as seen by the server - * @since 2.1 - */ - Date getServerDate(); - - /** - * Get the objects managed by this persistence manager. - * - * @return the objects - * @since 2.1 - */ - Set getManagedObjects(); - - /** - * Get the objects managed by this persistence manager having the specified object states. - * - * @param states The states of objects that we are interested in - * @return the objects - * @since 2.1 - */ - Set getManagedObjects(EnumSet states); - - /** - * Get the objects managed by this persistence manager being instances of the specified classes. - * - * @param classes The classes of objects that we are interested in - * @return the objects - * @since 2.1 - */ - Set getManagedObjects(Class... classes); - - /** - * Get the objects managed by this persistence manager having the specified object states and - * being instances of the specified classes. - * - * @param states The states of objects that we are interested in - * @param classes The classes of objects that we are interested in - * @return the objects - * @since 2.1 - */ - Set getManagedObjects(EnumSet states, Class... classes); - - /** - * Get a modifiable FetchGroup for the Class and name. If a modifiable - * FetchGroup already exists in the PersistenceManager scope, return it. If - * not, create and populate a new FetchGroup from the existing definition in the - * {@link PersistenceManager} or {@link PersistenceManagerFactory}. If the definition for the - * FetchGroup is not in scope in either the PersistenceManager or - * PersistenceManagerFactory, create it with no members. The FetchGroup - * immediately becomes active and in scope of the PersistenceManager, and hides the corresponding - * fetch group in the PersistenceManagerFactory. - * - * @param cls the class or interface for the FetchGroup - * @param name the name of the fetch group - * @return the FetchGroup - * @throws JDOUserException if the class is not a persistence-capable class or interface - * @since 2.2 - */ - FetchGroup getFetchGroup(Class cls, String name); - - /** - * Set a persistence manager property. This can be a standard property or a vendor-extension - * property. If a vendor-extension property is not recognized, it is silently ignored. - * - * @param propertyName name of property - * @param value The value - * @throws JDOUserException if the value is not supported for the property - * @since 3.1 - */ - public void setProperty(String propertyName, Object value); - - /** - * Get the properties and associated values currently in effect for the persistence manager. - * Changing entries in the map will not have affect the configuration of the persistence manager. - * - * @return map of properties in effect - * @since 3.1 - */ - public Map getProperties(); - - /** - * Get the names of the properties that are supported for use with the persistence manager. These - * can be standard JDO properties, or can be vendor-extension properties. - * - * @return property names Names of the properties accepted - * @since 3.1 - */ - public Set getSupportedProperties(); + /** + * A PersistenceManager instance can be used until it is + * closed. + * @return true if this PersistenceManager has + * been closed. + * @see #close() + */ + boolean isClosed (); + + /** Close this PersistenceManager so that no further requests + * may be made on it. A PersistenceManager instance can be + * used only until it is closed. + * + *

    Closing a PersistenceManager might release it to the pool + * of available PersistenceManagers, or might be garbage + * collected, at the option of the JDO implementation. Before being used + * again to satisfy a getPersistenceManager() request, the + * default values for options will be restored to their values as specified + * in the PersistenceManagerFactory. + * + *

    This method closes the PersistenceManager. + */ + void close (); + + /** Return the Transaction instance associated with a + * PersistenceManager. There is one Transaction + * instance associated with each PersistenceManager instance. + * The Transaction instance supports options as well as + * transaction completion requests. + * @return the Transaction associated with this + * PersistenceManager. + */ + Transaction currentTransaction(); + + /** Mark an instance as no longer needed in the cache. Eviction is normally + * done automatically by the PersistenceManager at transaction + * completion. This method allows the application to explicitly provide a + * hint to the PersistenceManager that the instance is no + * longer needed in the cache. + * @param pc the instance to evict from the cache. + */ + void evict (Object pc); + + /** Mark an array of instances as no longer needed in the cache. + * @see #evict(Object pc) + * @param pcs the array of instances to evict from the cache. + */ + void evictAll (Object... pcs); + + /** Mark a Collection of instances as no longer needed in the + * cache. + * @see #evict(Object pc) + * @param pcs the Collection of instances to evict from the + * cache. + */ + void evictAll (Collection pcs); + + /** Mark the parameter instances as no longer needed in the cache. + * @param pcClass the class of instances to evict + * @param subclasses if true, mark instances of subclasses also + * @since 2.1 + */ + void evictAll (boolean subclasses, Class pcClass); + + /** Mark all persistent-nontransactional instances as no longer needed + * in the cache. It transitions + * all persistent-nontransactional instances to hollow. Transactional + * instances are subject to eviction based on the RetainValues setting. + * @see #evict(Object pc) + */ + void evictAll (); + + /** Refresh the state of the instance from the data store. + * + *

    In an optimistic transaction, the state of instances in the cache + * might not match the state in the data store. This method is used to + * reload the state of the instance from the data store so that a subsequent + * commit is more likely to succeed. + *

    Outside a transaction, this method will refresh nontransactional + * state. + * @param pc the instance to refresh. + */ + void refresh (Object pc); + + /** Refresh the state of an array of instances from the data store. + * + * @see #refresh(Object pc) + * @param pcs the array of instances to refresh. + */ + void refreshAll (Object... pcs); + + /** Refresh the state of a Collection of instances from the + * data store. + * + * @see #refresh(Object pc) + * @param pcs the Collection of instances to refresh. + */ + void refreshAll (Collection pcs); + + /** Refresh the state of all applicable instances from the data store. + *

    If called with an active transaction, all transactional instances + * will be refreshed. If called outside an active transaction, all + * nontransactional instances will be refreshed. + * @see #refresh(Object pc) + */ + void refreshAll (); + + /** + * Refreshes all instances in the exception that failed verification. + * @param jdoe The exception defining object(s) to be refreshed + * @since 2.0 + */ + void refreshAll (JDOException jdoe); + + /** + * Create a new Query with no elements. + * @return the new Query. + */ + Query newQuery (); + + /** + * Create a new Query using elements from another + * Query. The other Query must have been created + * by the same JDO implementation. It might be active in a different + * PersistenceManager or might have been serialized and + * restored. + *

    All of the settings of the other Query are copied to this + * Query, except for the candidate Collection or + * Extent. + * @return the new Query + * @param compiled another Query from the same JDO implementation + */ + Query newQuery (Object compiled); + + /** + * Create a Construct a new query instance using the specified String + * as the single-string representation of the query. + * @param query the single-string query + * @return the new Query + * @since 2.0 + */ + Query newQuery (String query); + + /** Create a new Query using the specified language. + * @param language the language of the query parameter + * @param query the query, which is of a form determined by the language + * @return the new Query + */ + Query newQuery (String language, Object query); + + /** + * Create a new Query specifying the Class of the + * candidate instances. + * @param cls the Class of the candidate instances + * @return the new Query + * @param Candidate type for the query + */ + Query newQuery (Class cls); + + /** + * Create a new Query with the Class of the + * candidate instances and candidate Extent. + * @param cln the Extent of candidate instances + * @return the new Query + * @param Candidate type for the query + */ + Query newQuery (Extent cln); + + /** + * Create a new Query with the candidate Class + * and Collection. + * @param cls the Class of results + * @param cln the Collection of candidate instances + * @return the new Query + * @param Candidate type for the query + */ + Query newQuery (Class cls, Collection cln); + + /** + * Create a new Query with the Class of the + * candidate instances and filter. + * @param cls the Class of results + * @param filter the filter for candidate instances + * @return the new Query + * @param Candidate type for the query + */ + Query newQuery (Class cls, String filter); + + /** + * Create a new Query with the Class of the candidate instances, + * candidate Collection, and filter. + * @param cls the Class of candidate instances + * @param cln the Collection of candidate instances + * @param filter the filter for candidate instances + * @return the new Query + * @param Candidate type for the query + */ + Query newQuery (Class cls, Collection cln, String filter); + + /** Create a new Query with the + * candidate Extent and filter; the class + * is taken from the Extent. + * @param cln the Extent of candidate instances + * @param filter the filter for candidate instances + * @return the new Query + * @param Candidate type for the query + */ + Query newQuery (Extent cln, String filter); + + /** + * Create a new JDOQLTypedQuery with the specified candidate class. + * @param cls Candidate class for the query + * @return The JDOQLTypedQuery + * @param Candidate type for the query + * @since 3.2 + */ + JDOQLTypedQuery newJDOQLTypedQuery(Class cls); + + /** + * Create a new Query with the given candidate class + * from a named query. The query name given must be the name of a + * query defined in metadata. + * @param cls the Class of candidate instances + * @param queryName the name of the query to look up in metadata + * @return the new Query + * @param Candidate type for the query + */ + Query newNamedQuery (Class cls, String queryName); + + /** The PersistenceManager manages a collection of instances in + * the data store based on the class of the instances. This method returns + * an Extent of instances in the data store that might be + * iterated or given to a Query. The Extent + * itself might not reference any instances, but only hold the class name + * and an indicator as to whether subclasses are included in the + * Extent. + *

    Note that the Extent might be very large. + * @param persistenceCapableClass Class of instances + * @param subclasses whether to include instances of subclasses + * @return an Extent of the specified Class + * @see Query + * @param Type for the candidate of the Extent + */ + Extent getExtent (Class persistenceCapableClass, boolean subclasses); + + /** + * Equivalent to getExtent (persistenceCapableClass, true). + * @see #getExtent(Class,boolean) + * @since 2.0 + * @param persistenceCapableClass Candidate class for the extent + * @return an Extent of the specified Class + * @param Type for the candidate of the Extent + */ + Extent getExtent (Class persistenceCapableClass); + + /** This method locates a persistent instance in the cache of instances + * managed by this PersistenceManager. + * The getObjectById method attempts + * to find an instance in the cache with the specified JDO identity. + * The oid parameter object might have been returned by an + * earlier call to getObjectId or + * getTransactionalObjectId, or might have been constructed by + * the application. + *

    If the PersistenceManager is unable to resolve the + * oid parameter to an ObjectId instance, then it throws a + * JDOUserException. + *

    If the validate flag is false, and there is + * already an instance in the cache with the same JDO identity as the + * oid parameter, then this method returns it. There is no + * change made to the state of the returned instance. + *

    If there is not an instance already in the cache with the same JDO + * identity as the oid parameter, then this method creates an + * instance with the specified JDO identity and returns it. If there is no + * transaction in progress, the returned instance will be hollow or + * persistent-nontransactional, at the choice of the implementation. + *

    If there is a transaction in progress, the returned instance will + * be hollow, persistent-nontransactional, or persistent-clean, at the + * choice of the implementation. + *

    It is an implementation decision whether to access the data store, + * if required to determine the exact class. This will be the case of + * inheritance, where multiple PersistenceCapable classes share + * the same ObjectId class. + *

    If the validate flag is false, and the instance does not + * exist in the data store, then this method might not fail. It is an + * implementation choice whether to fail immediately with a + * JDOObjectNotFoundException. But a subsequent access + * of the fields of the + * instance will throw a JDOObjectNotFoundException + * if the instance does not + * exist at that time. Further, if a relationship is established to this + * instance, then the transaction in which the association was made will + * fail. + *

    If the validate flag is true, and there is + * already a transactional instance in the cache with the same JDO identity + * as the oid parameter, then this method returns it. There is + * no change made to the state of the returned instance. + *

    If there is an instance already in the cache with the same JDO + * identity as the oid parameter, but the instance is not + * transactional, then it must be verified in the data store. If the + * instance does not exist in the datastore, then a + * JDOObjectNotFoundException is thrown. + *

    If there is not an instance already in the cache with the same JDO + * identity as the oid parameter, then this method creates an + * instance with the specified JDO identity, verifies that it exists in the + * data store, and returns it. If there is no transaction in progress, the + * returned instance will be hollow or persistent-nontransactional, + * at the choice of the implementation. + *

    If there is a data store transaction in progress, the returned + * instance will be persistent-clean. + * If there is an optimistic transaction in progress, the returned + * instance will be persistent-nontransactional. + * @see #getObjectId(Object pc) + * @see #getTransactionalObjectId(Object pc) + * @return the PersistenceCapable instance with the specified + * ObjectId + * @param oid an ObjectId + * @param validate if the existence of the instance is to be validated + */ + Object getObjectById (Object oid, boolean validate); + + /** + * Looks up the instance of the given type with the given key. + * @param cls The type of object to load + * @param key either the string representation of the object id, or + * an object representation of a single field identity key + * @return the corresponding persistent instance + * @since 2.0 + * @param Type of the persistable object being retrieved + */ + T getObjectById (Class cls, Object key); + + /** + * Looks up the instance corresponding to the specified oid. This is + * equivalent to getObjectById(oid, true); + * @param oid The object id of the object to load + * @return the corresponding persistent instance + */ + Object getObjectById (Object oid); + + /** The ObjectId returned by this method represents the JDO identity of + * the instance. The ObjectId is a copy (clone) of the internal state + * of the instance, and changing it does not affect the JDO identity of + * the instance. + *

    The getObjectId method returns an ObjectId instance that + * represents the object identity of the specified JDO instance. The + * identity is guaranteed to be unique only in the context of the JDO + * PersistenceManager that created the identity, and only for + * two types of JDO Identity: those that are managed by the application, and + * those that are managed by the data store. + *

    If the object identity is being changed in the transaction, by the + * application modifying one or more of the application key fields, + * then this method returns the identity as of the beginning of the + * transaction. The value returned by getObjectId will be + * different following afterCompletion processing for + * successful transactions.

    Within a transaction, the ObjectId returned + * will compare equal to the ObjectId returned by only one among all JDO + * instances associated with the PersistenceManager regardless + * of the type of ObjectId. + *

    The ObjectId does not necessarily contain any internal state of the + * instance, nor is it necessarily an instance of the class used to + * manage identity internally. Therefore, if the application makes a + * change to the ObjectId instance returned by this method, there is + * no effect on the instance from which the ObjectId was obtained. + *

    The getObjectById method can be used between instances of + * PersistenceManager of different JDO vendors only for + * instances of persistence capable classes using application-managed + * (primary key) JDO identity. If it is used for instances of classes using + * datastore identity, the method might succeed, but there are no guarantees + * that the parameter and return instances are related in any way. + * @see #getTransactionalObjectId(Object pc) + * @see #getObjectById(Object oid, boolean validate) + * @param pc the PersistenceCapable instance + * @return the ObjectId of the instance + */ + Object getObjectId (Object pc); + + /** The ObjectId returned by this method represents the JDO identity of + * the instance. The ObjectId is a copy (clone) of the internal state + * of the instance, and changing it does not affect the JDO identity of + * the instance. + *

    If the object identity is being changed in the transaction, by the + * application modifying one or more of the application key fields, + * then this method returns the current identity in the transaction. + *

    If there is no transaction in progress, or if none of the key fields + * is being modified, then this method will return the same value as + * getObjectId. + * @see #getObjectId(Object pc) + * @see #getObjectById(Object oid, boolean validate) + * @param pc a PersistenceCapable instance + * @return the ObjectId of the instance + */ + Object getTransactionalObjectId (Object pc); + + /** + * This method returns an object id instance corresponding to the pcClass + * and key arguments. + * @param pcClass the Class of the persistence-capable instance + * @param key for single-field identity, the parameter for the + * constructor; for non-single-field application identity, the result + * of toString() on the object id instance. + * @return an instance of the object identity class + */ + Object newObjectIdInstance (Class pcClass, Object key); + + /** + * Return the objects with the given oids. + * @param oids the oids of the objects to return + * @param validate if true, the existance of the objects in + * the datastore will be validated. + * @return the objects that were looked up, in the + * same order as the oids parameter. + * @see #getObjectById(Object,boolean) + * @since 2.0 + */ + Collection getObjectsById (Collection oids, boolean validate); + + /** + * Return the objects with the given oids. This method is equivalent + * to calling {@link #getObjectsById(Collection, boolean)} + * with the validate flag true. + * @param oids the oids of the objects to return + * @return the objects that were looked up, in the + * same order as the oids parameter. + * @see #getObjectsById(Collection,boolean) + * @since 2.0 + */ + Collection getObjectsById (Collection oids); + + /** + * Return the objects with the given oids. + * @param oids the oids of the objects to return + * @param validate if true, the existance of the objects in + * the datastore will be validated. + * @return the objects that were looked up, in the + * same order as the oids parameter. + * @see #getObjectById(Object,boolean) + * @since 2.1 + */ + Object[] getObjectsById (boolean validate, Object... oids); + + /** + * Return the objects with the given oids. This method is equivalent + * to calling {@link #getObjectsById(boolean,Object...)} + * with the validate flag true. + * @param oids the oids of the objects to return + * @return the objects that were looked up, in the + * same order as the oids parameter. + * @see #getObjectsById(boolean,Object...) + * @since 2.0 + */ + Object[] getObjectsById (Object... oids); + + /** Make the parameter instance persistent in this + * PersistenceManager. + * This method makes transient instances persistent and applies detached + * instance changes to the cache. It must be called in the context of + * an active transaction, or a JDOUserException is thrown. For a transient + * instance, it assigns an object identity to the instance and transitions + * it to persistent-new. Any transient instances reachable from this + * instance via persistent fields of this instance become provisionally + * persistent, transitively. That is, they behave as persistent-new + * instances (return true to isPersistent, isNew, and isDirty). + * But at commit time, the reachability algorithm is run again, + * and instances made provisionally persistent that are not then + * reachable from persistent instances will revert to transient. + *

    During makePersistent of transient instances, the create life cycle + * listener is called. + *

    For detached instances, it locates or instantiates a persistent + * instance with the same JDO identity as the detached instance, + * and merges the persistent state of the detached instance into the + * persistent instance. Only the state of persistent fields is merged. + * If non-persistent state needs to be copied, the application should + * use the jdoPostAttach callback or the postAttach lifecycle event + * listener. Any references to the detached instances from instances + * in the closure of the parameter instances are modified to refer to + * the corresponding persistent instance instead of to the + * detached instance. + *

    During attachment of detached instances, the attach callbacks + * and attach life cycle listeners are called. + *

    During application of changes of the detached state, if the JDO + * implementation can determine that there were no changes made during + * detachment, then the implementation is not required to mark the + * corresponding instance dirty. If it cannot determine if changes + * were made, then it must mark the instance dirty. + * No consistency checking is done during makePersistent of detached + * instances. If consistency checking is required by the application, + * then flush or checkConsistency should be called after attaching the + * instances. + *

    These methods have no effect on parameter persistent instances + * already managed by this PersistenceManager. They will throw a + * JDOUserException if the parameter instance is managed by a + * different PersistenceManager. + * If an instance is of a class whose identity type (application, + * datastore, or none) is not supported by the JDO implementation, + * then a JDOUserException will be thrown for that instance. + * The return value for parameter instances in the transient or persistent + * states is the same as the parameter value. The return value for + * parameter instances in the detached state is the persistent instance + * corresponding to the detached instance. + * The return values for makePersistentAll methods correspond by position + * to the parameter instances. + * @param pc an instance of a Class that is persistent + * capable. + * @return the parameter instance for parameters in the transient or + * persistent state, or the corresponding persistent instance + * for detached parameter instances + * @param Type of the persistable object + */ + T makePersistent (T pc); + + /** Make an array of instances persistent. + * @param pcs an array of instances + * @return the parameter instances for parameters in the transient or + * persistent state, or the corresponding persistent instance + * for detached parameter instances, in the same order as in the + * parameter array + * @see #makePersistent(Object pc) + * @param Type of the persistable object + */ + @SuppressWarnings({"unchecked", "varargs"}) + T[] makePersistentAll (T... pcs); + + /** Make a Collection of instances persistent. + * @param pcs a Collection of instances + * @return the parameter instance for parameters in the transient or + * persistent state, or the corresponding persistent instance + * for detached parameter instances, with an iteration in the same order + * as in the parameter Collection + * @see #makePersistent(Object pc) + * @param Type of the persistable object + */ + Collection makePersistentAll (Collection pcs); + + /** Delete the persistent instance from the data store. + * This method must be called in an active transaction. + * The data store object will be removed at commit. + * Unlike makePersistent, which makes the closure of the + * instance persistent, the closure of the instance is not deleted from the + * data store. This method has no effect if the instance is already deleted + * in the current transaction. + * This method throws JDOUserException if the instance is + * transient or is managed by another PersistenceManager. + * + * @param pc a persistent instance + */ + void deletePersistent (Object pc); + + /** Delete an array of instances from the data store. + * @param pcs a Collection of persistent instances + * @see #deletePersistent(Object pc) + */ + void deletePersistentAll (Object... pcs); + + /** Delete a Collection of instances from the data store. + * @param pcs a Collection of persistent instances + * @see #deletePersistent(Object pc) + */ + void deletePersistentAll (Collection pcs); + + /** Make an instance transient, removing it from management by this + * PersistenceManager. + * + *

    The instance loses its JDO identity and it is no longer associated + * with any PersistenceManager. The state of fields is + * preserved unchanged. + * @param pc the instance to make transient. + */ + void makeTransient (Object pc); + + /** Make an array of instances transient, removing them from management by + * this PersistenceManager. + * + *

    The instances lose their JDO identity and they are no longer + * associated with any PersistenceManager. The state of fields + * is preserved unchanged. + * @param pcs the instances to make transient. + */ + void makeTransientAll (Object... pcs); + + /** Make a Collection of instances transient, removing them + * from management by this PersistenceManager. + * + *

    The instances lose their JDO identity and they are no longer + * associated with any PersistenceManager. The state of fields + * is preserved unchanged. + * @param pcs the instances to make transient. + */ + void makeTransientAll (Collection pcs); + + /** Make an instance transient, removing it from management by this + * PersistenceManager. If the useFetchPlan parameter is + * false, this method behaves exactly as makeTransient(Object pc). + *

    The affected instance(s) lose their JDO identity and are no longer + * associated with any PersistenceManager. The state + * of fields is unchanged. + *

    If the useFetchPlan parameter is true, then the current FetchPlan + * is applied to the pc parameter, as if detachCopy(Object) had been + * called. After the graph of instances is loaded, the instances + * reachable via loaded fields is made transient. The state of fields + * in the affected instances is as specified by the FetchPlan. + *

    Unlike detachCopy, the instances are not detached; there is no + * detachment information in the instances. + *

    The instances to be made transient do not need to + * implement the javax.jdo.spi.Detachable interface. + * @param pc the root instance to make transient. + * @param useFetchPlan whether to use the current fetch plan to determine + * which fields to load and which instances to make transient + * @since 2.0 + */ + void makeTransient (Object pc, boolean useFetchPlan); + + /** Make instances transient, removing them from management + * by this PersistenceManager. If the useFetchPlan parameter + * is false, this method behaves exactly as makeTransientAll(Object[] pcs). + *

    The affected instance(s) lose their JDO identity and are no longer + * associated with any PersistenceManager. The state + * of fields is unchanged. + *

    If the useFetchPlan parameter is true, then the current FetchPlan + * is applied to the pcs parameters and the entire graph of instances + * reachable via loaded fields is made transient. The state of fields + * in the affected instances is as specified by the FetchPlan. + *

    Unlike detachCopy, the instances are not detached; there is no + * detachment information in the instances. + *

    The instances to be made transient do not need to + * implement the javax.jdo.spi.Detachable interface. + * @param pcs the root instances to make transient. + * @param useFetchPlan whether to use the current fetch plan to determine + * which fields to load and which instances to make transient + * @since 2.1 + */ + void makeTransientAll (boolean useFetchPlan, Object... pcs); + + /** Make instances transient, removing them from management + * by this PersistenceManager. If the useFetchPlan parameter + * is false, this method behaves exactly as + * makeTransientAll(Collection pcs). + *

    The affected instance(s) lose their JDO identity and are no longer + * associated with any PersistenceManager. The state + * of fields is unchanged. + *

    If the useFetchPlan parameter is true, then the current FetchPlan + * is applied to the pcs parameters and the entire graph of instances + * reachable via loaded fields is made transient. The state of fields + * in the affected instances is as specified by the FetchPlan. + *

    Unlike detachCopy, the instances are not detached; there is no + * detachment information in the instances. + *

    The instances to be made transient do not need to + * implement the javax.jdo.spi.Detachable interface. + * @param pcs the root instances to make transient. + * @param useFetchPlan whether to use the current fetch plan to determine + * which fields to load and which instances to make transient + * @since 2.0 + */ + void makeTransientAll (Collection pcs, boolean useFetchPlan); + + /** Make an instance subject to transactional boundaries. + * + *

    Transient instances normally do not observe transaction boundaries. + * This method makes transient instances sensitive to transaction + * completion. If an instance is modified in a transaction, and the + * transaction rolls back, the state of the instance is restored to the + * state before the first change in the transaction. + * + *

    For persistent instances read in optimistic transactions, this method + * allows the application to make the state of the instance part of the + * transactional state. At transaction commit, the state of the instance in + * the cache is compared to the state of the instance in the data store. If + * they are not the same, then an exception is thrown. + * @param pc the instance to make transactional. + */ + void makeTransactional (Object pc); + + /** Make an array of instances subject to transactional boundaries. + * @param pcs the array of instances to make transactional. + * @see #makeTransactional(Object pc) + */ + void makeTransactionalAll (Object... pcs); + + /** Make a Collection of instances subject to transactional + * boundaries. + * @param pcs the Collection of instances to make + * transactional. + * @see #makeTransactional(Object pc) + */ + void makeTransactionalAll (Collection pcs); + + /** Make an instance non-transactional after commit. + * + *

    Normally, at transaction completion, instances are evicted from the + * cache. This method allows an application to identify an instance as + * not being evicted from the cache at transaction completion. Instead, + * the instance remains in the cache with nontransactional state. + * + * @param pc the instance to make nontransactional. + */ + void makeNontransactional (Object pc); + + /** Make an array of instances non-transactional after commit. + * + * @param pcs the array of instances to make nontransactional. + * @see #makeNontransactional(Object pc) + */ + void makeNontransactionalAll (Object... pcs); + + /** Make a Collection of instances non-transactional after + * commit. + * + * @param pcs the Collection of instances to make + * nontransactional. + * @see #makeNontransactional(Object pc) + */ + void makeNontransactionalAll (Collection pcs); + + /** Retrieve field values of an instance from the store. This tells + * the PersistenceManager that the application intends to use + * the instance, and its field values must be retrieved. + *

    The PersistenceManager might use policy information about + * the class to retrieve associated instances. + * @param pc the instance + */ + void retrieve (Object pc); + + /** Retrieve field values of an instance from the store. This tells + * the PersistenceManager that the application intends to use + * the instance, and its field values must be retrieved. + *

    If the useFetchPlan parameter is false, this method behaves exactly + * as the corresponding method without the useFetchPlan parameter. + * If the useFetchPlan parameter is true, and the fetch plan has not been + * modified from its default setting, all fields in the current fetch plan + * are fetched, and other fields might be fetched lazily by the + * implementation. If the useFetchPlan parameter is true, and the fetch + * plan has been changed from its default setting, then the fields + * specified by the fetch plan are loaded, along with related instances + * specified by the fetch plan. + * @param pc the instance + * @param useFetchPlan whether to use the current fetch plan to determine + * which fields to load and which instances to retrieve. + * @since 2.0 + */ + void retrieve (Object pc, boolean useFetchPlan); + + /** Retrieve field values of instances from the store. This tells + * the PersistenceManager that the application intends to use + * the instances, and all field values must be retrieved. + *

    The PersistenceManager might use policy information about + * the class to retrieve associated instances. + * @param pcs the instances + */ + void retrieveAll (Collection pcs); + + /** Retrieve field values of instances from the store. This tells + * the PersistenceManager that the application intends to use + * the instances, and their field values should be retrieved. The fields + * in the current fetch group must be retrieved, and the implementation + * might retrieve more fields than the current fetch group. + *

    If the useFetchPlan parameter is false, this method behaves exactly + * as the corresponding method without the useFetchPlan parameter. + * If the useFetchPlan parameter is true, and the fetch plan has not been + * modified from its default setting, all fields in the current fetch plan + * are fetched, and other fields might be fetched lazily by the + * implementation. If the useFetchPlan parameter is true, and the fetch + * plan has been changed from its default setting, then the fields + * specified by the fetch plan are loaded, along with related instances + * specified by the fetch plan. + * @param pcs the instances + * @param useFetchPlan whether to use the current fetch plan to determine + * which fields to load and which instances to retrieve. + * @since 1.0.1 + */ + void retrieveAll (Collection pcs, boolean useFetchPlan); + + /** Retrieve field values of instances from the store. This tells + * the PersistenceManager that the application intends to use + * the instances, and all field values must be retrieved. + *

    The PersistenceManager might use policy information about + * the class to retrieve associated instances. + * @param pcs the instances + */ + void retrieveAll (Object... pcs); + + /** Retrieve field values of instances from the store. This tells + * the PersistenceManager that the application intends to use + * the instances, and their field values should be retrieved. The fields + * in the current fetch group must be retrieved, and the implementation + * might retrieve more fields than the current fetch group. + *

    If the useFetchPlan parameter is false, this method behaves exactly + * as the corresponding method without the useFetchPlan parameter. + * If the useFetchPlan parameter is true, and the fetch plan has not been + * modified from its default setting, all fields in the current fetch plan + * are fetched, and other fields might be fetched lazily by the + * implementation. If the useFetchPlan parameter is true, and the fetch + * plan has been changed from its default setting, then the fields + * specified by the fetch plan are loaded, along with related instances + * specified by the fetch plan. + * @param pcs the instances + * @param useFetchPlan whether to use the current fetch plan to determine + * which fields to load and which instances to retrieve. + * @since 2.1 + */ + void retrieveAll (boolean useFetchPlan, Object... pcs); + + /** The application can manage the PersistenceManager instances + * more easily by having an application object associated with each + * PersistenceManager instance. + * @param o the user instance to be remembered by the + * PersistenceManager + * @see #getUserObject + */ + void setUserObject (Object o); + + /** The application can manage the PersistenceManager instances + * more easily by having an application object associated with each + * PersistenceManager instance. + * @return the user object associated with this + * PersistenceManager + * @see #setUserObject + */ + Object getUserObject (); + + /** This method returns the PersistenceManagerFactory used to + * create this PersistenceManager. + * @return the PersistenceManagerFactory that created + * this PersistenceManager + */ + PersistenceManagerFactory getPersistenceManagerFactory(); + + /** Return the Class that implements the JDO Identity for the + * specified PersistenceCapable class. The application can use + * the returned Class to construct a JDO Identity instance for + * application identity PersistenceCapable classes. This JDO + * Identity instance can then be used to get an instance of the + * PersistenceCapable class for use in the application. + * + *

    In order for the application to construct an instance of the ObjectId + * class it needs to know the class being used by the JDO implementation. + * @param cls the PersistenceCapable Class + * @return the Class of the ObjectId of the parameter + * @see #getObjectById + */ + Class getObjectIdClass(Class cls); + + /** Set the Multithreaded flag for this PersistenceManager. + * Applications that use multiple threads to invoke methods or access fields + * from instances managed by this PersistenceManager must set + * this flag to true. + * Instances managed by this PersistenceManager include + * persistent or transactional instances of PersistenceCapable + * classes, as well as helper instances such as Query, + * Transaction, or Extent. + * @param flag the Multithreaded setting. + */ + void setMultithreaded (boolean flag); + + /** Get the current Multithreaded flag for this + * PersistenceManager. + * @see #setMultithreaded + * @return the Multithreaded setting. + */ + boolean getMultithreaded(); + + /** Set the ignoreCache parameter for queries. + * + *

    IgnoreCache set to true specifies that for all + * Query instances created by this + * PersistenceManager, the default is the cache should be + * ignored for queries. + * @param flag the ignoreCache setting. + */ + void setIgnoreCache(boolean flag); + + /** Get the ignoreCache setting for queries. + * + *

    IgnoreCache set to true specifies that for all + * Query instances created by this + * PersistenceManager, the default is the cache should be + * ignored for queries. + * @return the ignoreCache setting. + */ + boolean getIgnoreCache(); + + /** + * Specify a timeout interval (milliseconds) for any datastore read + * operations associated with this persistence manager. To unset + * the explicit timeout, specify null. For no timeout, specify 0. + * Read operations include, for example, those associated with query, + * getObjectById, refresh, retrieve, and extent iteration operations. + * If the datastore granularity is larger than milliseconds, the + * timeout value will be rounded up to the nearest supported datastore + * value. + * If a read operation hasn't completed within this interval, the operation + * will throw a JDODatastoreException. + * If multiple datastore operations are required to complete the query, + * the timeout value applies to each of them individually. + * If the datastore and JDO implementation support timeouts, then + * javax.jdo.option.DatastoreTimeout is returned by + * PersistenceManagerFactory.supportedOptions(). + * If timeouts are not supported,this method will throw + * JDOUnsupportedOptionException. + * @since 3.0 + * @param interval the timeout interval (milliseconds) + */ + void setDatastoreReadTimeoutMillis(Integer interval); + + /** Get the effective timeout setting for datastore read operations + * associated with this persistence manager. + * If the timeout has not been set on this persistence manager explicitly, + * the default read timeout value from the persistence manager factory + * is returned. + * @see #setDatastoreReadTimeoutMillis(Integer) + * @see PersistenceManagerFactory#setDatastoreReadTimeoutMillis(Integer) + * @return the effective timeout setting (milliseconds). + * @since 3.0 + */ + Integer getDatastoreReadTimeoutMillis(); + + /** + * Specify a timeout interval (milliseconds) for any write operations + * associated with this persistence manager. To unset the explicit timeout, + * specify null. For no timeout, specify 0. + * Datastore write operations include, for example, operations associated + * with flush, commit, and delete by query. + * If the datastore granularity is larger than milliseconds, the + * timeout value will be rounded up to the nearest supported datastore + * value. + * If a write operation hasn't completed within this interval, methods + * will throw a JDODatastoreException. + * If multiple datastore operations are required to complete the method, + * the timeout value applies to each of them individually. + * If the datastore and JDO implementation support timeouts, then + * javax.jdo.option.DatastoreTimeout is returned by + * PersistenceManagerFactory.supportedOptions(). + * If timeouts are not supported,this method will throw + * JDOUnsupportedOptionException. + * @since 3.0 + * @param interval the timeout interval (milliseconds) + */ + void setDatastoreWriteTimeoutMillis(Integer interval); + + /** Get the effective timeout setting for write operations. + * If the timeout has not been set on this persistence manager explicitly, + * the default datastore write timeout value from the persistence manager + * factory is returned. + * @see #setDatastoreWriteTimeoutMillis(Integer) + * @see PersistenceManagerFactory#setDatastoreWriteTimeoutMillis(Integer) + * @return the effective timeout setting (milliseconds). + * @since 3.0 + */ + Integer getDatastoreWriteTimeoutMillis(); + + /** Gets the detachAllOnCommit setting. + * @see #setDetachAllOnCommit(boolean) + * @since 2.0 + * @return the detachAllOnCommit setting. + */ + boolean getDetachAllOnCommit(); + + /** Sets the detachAllOnCommit setting. + * + *

    DetachAllOnCommit set to false specifies that the + * state of persistent instances in the cache after commit is defined + * by the retainValues flag. With this flag set to true, + * during beforeCompletion all cached instances are prepared for + * detachment according to the fetch plan in effect at commit. Loading + * fields and unloading fields required by the fetch plan is done after + * calling the user's beforeCompletion callback. During + * afterCompletion, before calling the user's + * afterCompletion callback, all detachable persistent + * instances in the cache transition to detached; non-detachable + * persistent instances transition to transient; and detachable + * instances can be serialized as detached instances. Transient + * transactional instances are unaffected by this flag. + * @param flag Flag for whether to detach all on commit + * @see #getDetachAllOnCommit() + * @since 2.0 + */ + void setDetachAllOnCommit(boolean flag); + + /** Gets the copyOnAttach setting. + * @see #setCopyOnAttach(boolean) + * @since 2.1 + * @return the copyOnAttach setting. + */ + boolean getCopyOnAttach(); + + /** Sets the copyOnAttach setting. + * + *

    CopyOnAttach set to true specifies that during + * makePersistent, copies are made of detached parameter instances. + * With this flag set to false, detached parameter + * instances are attached directly and change their state from + * detached-clean to persistent-clean or from detached-dirty to + * persistent-dirty. + * @param flag Flag for whether to copy on attach + * @see #getCopyOnAttach() + * @since 2.1 + */ + void setCopyOnAttach(boolean flag); + + /** + * Detach the specified instance from the PersistenceManager. + * The flags for detachment (DETACH_LOAD_FIELDS and DETACH_UNLOAD_FIELDS) + * and the active fetch groups determine the scope of fetching for the + * graph of instances reachable from the pc parameter. The state of fields + * in the affected instances is as specified by the FetchPlan. + * @param pc the instance to detach + * @return the detached instance + * @see #detachCopyAll(Object[]) + * @since 2.0 + * @param Type of the persistable object + */ + T detachCopy (T pc); + + /** + * Detach the specified instances from the PersistenceManager. + * The flags for detachment (DETACH_LOAD_FIELDS and DETACH_UNLOAD_FIELDS) + * and the active fetch groups determine the scope of fetching for the + * graph of instances reachable from the pcs parameter. The state of fields + * in the affected instances is as specified by the FetchPlan. + * @param pcs the instances to detach + * @return the detached instances + * @see #detachCopyAll(Object[]) + * @since 2.0 + * @param Type of the persistable objects + */ + Collection detachCopyAll (Collection pcs); + + /** + * Detach the specified instances from the PersistenceManager. + * The flags for detachment (DETACH_LOAD_FIELDS and DETACH_UNLOAD_FIELDS) + * and the active fetch groups determine the scope of fetching for the + * graph of instances reachable from the pcs parameter. The state of fields + * in the affected instances is as specified by the FetchPlan. + * The objects returned can be manipulated and re-attached with + * {@link #makePersistentAll(Object[])}. + * The detached instances will be + * unmanaged copies of the specified parameters, and are suitable + * for serialization and manipulation outside of a JDO + * environment. When detaching instances, only fields in the + * current {@link FetchPlan} will be traversed. Thus, to detach a + * graph of objects, relations to other persistent instances must + * either be in the default-fetch-group, or in the + * current custom {@link FetchPlan}. + * @param pcs the instances to detach + * @return the detached instances + * @throws JDOUserException if any of the instances to be detached do not + * implement the javax.jdo.spi.Detachable interface. + * @see #makePersistentAll(Object[]) + * @see #getFetchPlan + * @since 2.0 + * @param Type of the persistable object + */ + @SuppressWarnings({"unchecked", "varargs"}) + T[] detachCopyAll (T... pcs); + + /** + * Put the specified key-value pair into the map of user objects. + * @since 2.0 + * @param key Key to store the user object under + * @param val User object to store + * @return The previous object under this key + */ + Object putUserObject (Object key, Object val); + + /** + * Get the value for the specified key from the map of user objects. + * @param key the key of the object to be returned + * @return the object + * @since 2.0 + */ + Object getUserObject (Object key); + + /** + * Remove the specified key and its value from the map of user objects. + * @param key the key of the object to be removed + * @return The user object that was removed + * @since 2.0 + */ + Object removeUserObject (Object key); + + /** + * Flushes all dirty, new, and deleted instances to the data + * store. It has no effect if a transaction is not active. + *

    If a datastore transaction is active, this method + * synchronizes the cache with the datastore and reports any + * exceptions.

    + *

    If an optimistic transaction is active, this method obtains + * a datastore connection, synchronizes the cache with the + * datastore using this connection and reports any + * exceptions. The connection obtained by this method is held + * until the end of the transaction.

    + *

    If exceptions occur during flush, the implementation will + * set the current transaction's RollbackOnly flag + * (see {@link Transaction#setRollbackOnly}).

    + * @since 2.0 + */ + void flush (); + + /** + * Validates the PersistenceManager cache with the + * datastore. This method has no effect if a transaction is not + * active. + *

    If a datastore transaction is active, this method verifies + * the consistency of instances in the cache against the + * datastore. An implementation might flush instances as if + * {@link #flush} were called, but it is not required to do + * so.

    + *

    If an optimistic transaction is active, this method obtains + * a datastore connection and verifies the consistency of the + * instances in the cache against the datastore. If any + * inconsistencies are detected, a {@link + * JDOOptimisticVerificationException} is thrown. This exception + * contains a nested {@link JDOOptimisticVerificationException} + * for each object that failed the consistency check. No + * datastore resources acquired during the execution of this + * method are held beyond the scope of this method.

    + * @since 2.0 + */ + void checkConsistency (); + + /** + * Returns the FetchPlan used by this + * PersistenceManager. + * @return the FetchPlan + * @since 2.0 + */ + FetchPlan getFetchPlan (); + + /** + * Creates an instance of a persistence-capable interface, + * or of a concrete or abstract class. + * The returned instance is transient. + * @param pcClass Must be a persistence-capable interface, + * or a concrete or abstract class that is declared in the metadata. + * @return the created instance + * @since 2.0 + * @param Type of the persistable object + */ + T newInstance (Class pcClass); + + /** + * Returns the sequence identified by name. + * @param name the name of the Sequence + * @return the Sequence + * @since 2.0 + */ + Sequence getSequence (String name); + + /** + * If this method is called while a datastore transaction is + * active, the object returned will be enlisted in the current + * transaction. If called in an optimistic transaction or outside + * an active transaction, the object returned will not be + * enlisted in any transaction. + * @return the JDOConnection instance + * @since 2.0 + */ + JDOConnection getDataStoreConnection (); + + /** + * Adds the listener instance to the list of lifecycle event + * listeners. The classes parameter identifies all + * of the classes of interest. If the classes + * parameter is specified as null, events for all + * persistent classes and interfaces will be sent to + * listenerInstance. + *

    The listenerInstance will be called for each event for which it + * implements the corresponding listenerInstance interface.

    + * @param listener the lifecycle listener + * @param classes the classes of interest to the listener + * @since 2.0 + */ + void addInstanceLifecycleListener (InstanceLifecycleListener listener, + Class... classes); + + /** + * Removes the listener instance from the list of lifecycle event listeners. + * @param listener the listener instance to be removed + * @since 2.0 + */ + void removeInstanceLifecycleListener (InstanceLifecycleListener listener); + + /** + * Get the Date as seen by the server. + * Clients using this method can order their operations according to + * a single time source. Implementations use the setting of the + * server time zone to prepare a Date instance that represents + * UTC time on the server. + * @return a Date instance corresponding to the UTC Date + * as seen by the server + * @since 2.1 + */ + Date getServerDate(); + + /** + * Get the objects managed by this persistence manager. + * @return the objects + * @since 2.1 + */ + Set getManagedObjects(); + + /** + * Get the objects managed by this persistence manager having the + * specified object states. + * @param states The states of objects that we are interested in + * @return the objects + * @since 2.1 + */ + Set getManagedObjects(EnumSet states); + + /** + * Get the objects managed by this persistence manager being instances of + * the specified classes. + * @param classes The classes of objects that we are interested in + * @return the objects + * @since 2.1 + */ + Set getManagedObjects(Class... classes); + + /** + * Get the objects managed by this persistence manager having the + * specified object states and being instances of the specified classes. + * @param states The states of objects that we are interested in + * @param classes The classes of objects that we are interested in + * @return the objects + * @since 2.1 + */ + Set getManagedObjects(EnumSet states, Class... classes); + + /** + * Get a modifiable FetchGroup for the Class and name. + * If a modifiable FetchGroup already exists in the + * PersistenceManager scope, return it. + * If not, create and populate a new FetchGroup from the + * existing definition in the {@link PersistenceManager} or + * {@link PersistenceManagerFactory}. If the definition for the + * FetchGroup is not in scope in either the + * PersistenceManager or + * PersistenceManagerFactory, create it with no members. + * The FetchGroup immediately + * becomes active and in scope of the PersistenceManager, and hides + * the corresponding fetch group in the PersistenceManagerFactory. + * @param cls the class or interface for the FetchGroup + * @param name the name of the fetch group + * @return the FetchGroup + * @throws JDOUserException if the class is not a persistence-capable + * class or interface + * @since 2.2 + */ + FetchGroup getFetchGroup(Class cls, String name); + + /** + * Set a persistence manager property. This can be a standard property + * or a vendor-extension property. If a vendor-extension property is + * not recognized, it is silently ignored. + * @param propertyName name of property + * @param value The value + * @throws JDOUserException if the value is not supported for the property + * @since 3.1 + */ + public void setProperty(String propertyName, Object value); + + /** + * Get the properties and associated values currently in effect for the + * persistence manager. Changing entries in the map will not have affect + * the configuration of the persistence manager. + * @return map of properties in effect + * @since 3.1 + */ + public Map getProperties(); + + /** + * Get the names of the properties that are supported for use with the + * persistence manager. These can be standard JDO properties, or can be + * vendor-extension properties. + * @return property names Names of the properties accepted + * @since 3.1 + */ + public Set getSupportedProperties(); } diff --git a/api/src/main/java/javax/jdo/PersistenceManagerFactory.java b/api/src/main/java/javax/jdo/PersistenceManagerFactory.java index 5886ed997..7daa7e244 100644 --- a/api/src/main/java/javax/jdo/PersistenceManagerFactory.java +++ b/api/src/main/java/javax/jdo/PersistenceManagerFactory.java @@ -22,797 +22,771 @@ package javax.jdo; +import javax.jdo.datastore.DataStoreCache; +import javax.jdo.listener.InstanceLifecycleListener; +import javax.jdo.metadata.TypeMetadata; +import javax.jdo.metadata.JDOMetadata; +import javax.jdo.spi.JDOPermission; // for getFetchGroups javadoc import java.io.Serializable; import java.util.Collection; import java.util.Properties; import java.util.Set; -import javax.jdo.datastore.DataStoreCache; -import javax.jdo.listener.InstanceLifecycleListener; -import javax.jdo.metadata.JDOMetadata; -import javax.jdo.metadata.TypeMetadata; -import javax.jdo.spi.JDOPermission; -/** - * The PersistenceManagerFactory is the interface to use to obtain - * PersistenceManager instances. All PersistenceManager instances obtained from - * the same PersistenceManagerFactory will have the same default properties. - * - *

    PersistenceManagerFactory instances may be configured and serialized for later - * use. They may be stored via JNDI and looked up and used later. Any properties configured will be - * saved and restored. +/** The PersistenceManagerFactory is the interface to use to obtain + * PersistenceManager instances. + * All PersistenceManager instances obtained from the same + * PersistenceManagerFactory will have the same default properties. * - *

    Once the first PersistenceManager is obtained from the - * PersistenceManagerFactory, the factory can no longer be configured. + *

    PersistenceManagerFactory instances may be configured and + * serialized for later use. They may be stored via JNDI and looked up + * and used later. Any properties configured will be saved and restored. * - *

    If the ConnectionFactory property is set (non-null) then all other - * Connection properties including ConnectionFactoryName are ignored; otherwise, if - * ConnectionFactoryName is set (non-null) then all other Connection - * properties are ignored. Similarly, if the ConnectionFactory2 property is set (non- - * null) then ConnectionFactory2Name is ignored. - * - *

    Operational state (PersistenceManager pooling, connection pooling, operational - * parameters) must not be serialized. + *

    Once the first PersistenceManager is obtained from the + * PersistenceManagerFactory, the factory can no longer be + * configured. + *

    If the ConnectionFactory property is set + * (non-null) then all other Connection properties including + * ConnectionFactoryName are ignored; + * otherwise, if ConnectionFactoryName is set + * (non-null) then all other Connection properties are ignored. + * Similarly, if the ConnectionFactory2 property is set + * (non-null) then ConnectionFactory2Name is ignored. + *

    Operational state (PersistenceManager pooling, connection + * pooling, operational parameters) must not be serialized. * * @version 2.2 */ + public interface PersistenceManagerFactory extends Serializable { - /** - * Close this PersistenceManagerFactory. Check for JDOPermission("closePersistenceManagerFactory") - * and if not authorized, throw SecurityException. - * - *

    If the authorization check succeeds, check to see that all PersistenceManager instances - * obtained from this PersistenceManagerFactory have no active transactions. If any - * PersistenceManager instances have an active transaction, throw a JDOUserException, with one - * nested JDOUserException for each PersistenceManager with an active Transaction. - * - *

    If there are no active transactions, then close all PersistenceManager instances obtained - * from this PersistenceManagerFactory, mark this PersistenceManagerFactory as closed, disallow - * getPersistenceManager methods, and allow all other get methods. If a set method or - * getPersistenceManager method is called after close, then JDOUserException is thrown. - * - * @since 1.0.1 - */ - void close(); - - /** - * A PersistenceManagerFactory instance can be used until it is closed. - * - * @return true if this PersistenceManagerFactory has been closed. - * @see #close() - * @since 2.0 - */ - boolean isClosed(); - - /** - * Get an instance of PersistenceManager from this factory. The instance has default - * values for options. - * - *

    After the first use of getPersistenceManager, no "set" methods will succeed. - * - * @return a PersistenceManager instance with default options. - */ - PersistenceManager getPersistenceManager(); - - /** - * Get a thread-safe instance of a proxy that dynamically binds on each method call to an instance - * of PersistenceManager. - * - *

    When used with a PersistenceManagerFactory that uses TransactionType JTA, the - * proxy can be used in a server to dynamically bind to an instance from this factory associated - * with the thread's current transaction. In this case, the close method is ignored, as the - * PersistenceManager is automatically closed when the transaction completes. - * - *

    When used with a PersistenceManagerFactory that uses TransactionType - * RESOURCE_LOCAL, the proxy uses an inheritable ThreadLocal to bind to an instance of - * PersistenceManager associated with the thread. In this case, the close method executed - * on the proxy closes the PersistenceManager and then clears the ThreadLocal. Use of - * this method does not affect the configurability of the PersistenceManagerFactory. - * - * @since 2.1 - * @return a PersistenceManager proxy. - */ - PersistenceManager getPersistenceManagerProxy(); - - /** - * Get an instance of PersistenceManager from this factory. The instance has default - * values for options. The parameters userid and password are used when - * obtaining datastore connections from the connection pool. - * - *

    After the first use of getPersistenceManager, no "set" methods will succeed. - * - * @return a PersistenceManager instance with default options. - * @param userid the userid for the connection - * @param password the password for the connection - */ - PersistenceManager getPersistenceManager(String userid, String password); - - /** - * Set the user name for the data store connection. - * - * @param userName the user name for the data store connection. - */ - void setConnectionUserName(String userName); - - /** - * Get the user name for the data store connection. - * - * @return the user name for the data store connection. - */ - String getConnectionUserName(); - - /** - * Set the password for the data store connection. - * - * @param password the password for the data store connection. - */ - void setConnectionPassword(String password); - - /** - * Set the URL for the data store connection. - * - * @param url the URL for the data store connection. - */ - void setConnectionURL(String url); - - /** - * Get the URL for the data store connection. - * - * @return the URL for the data store connection. - */ - String getConnectionURL(); - - /** - * Set the driver name for the data store connection. This property might be ignored by the JDO - * implementation because the JDBC DriverManager handles the driver name. - * - * @param driverName the driver name for the data store connection. - */ - void setConnectionDriverName(String driverName); - - /** - * Get the driver name for the data store connection. This property might be ignored by the JDO - * implementation because the JDBC DriverManager handles the driver name. - * - * @return the driver name for the data store connection. - */ - String getConnectionDriverName(); - - /** - * Set the name for the data store connection factory. - * - * @param connectionFactoryName the name of the data store connection factory. - */ - void setConnectionFactoryName(String connectionFactoryName); - - /** - * Get the name for the data store connection factory. - * - * @return the name of the data store connection factory. - */ - String getConnectionFactoryName(); - - /** - * Set the data store connection factory. JDO implementations will support specific connection - * factories. The connection factory interfaces are not part of the JDO specification. - * - * @param connectionFactory the data store connection factory. - */ - void setConnectionFactory(Object connectionFactory); - - /** - * Get the data store connection factory. - * - * @return the data store connection factory. - */ - Object getConnectionFactory(); - - /** - * Set the name for the second data store connection factory. This is needed for managed - * environments to get nontransactional connections for optimistic transactions. - * - * @param connectionFactoryName the name of the data store connection factory. - */ - void setConnectionFactory2Name(String connectionFactoryName); - - /** - * Get the name for the second data store connection factory. This is needed for managed - * environments to get nontransactional connections for optimistic transactions. - * - * @return the name of the data store connection factory. - */ - String getConnectionFactory2Name(); - - /** - * Set the second data store connection factory. This is needed for managed environments to get - * nontransactional connections for optimistic transactions. JDO implementations will support - * specific connection factories. The connection factory interfaces are not part of the JDO - * specification. - * - * @param connectionFactory the data store connection factory. - */ - void setConnectionFactory2(Object connectionFactory); - - /** - * Get the second data store connection factory. This is needed for managed environments to get - * nontransactional connections for optimistic transactions. - * - * @return the data store connection factory. - */ - Object getConnectionFactory2(); - - /** - * Set the default Multithreaded setting for all PersistenceManager instances - * obtained from this factory. - * - * @param flag the default Multithreaded setting. - */ - void setMultithreaded(boolean flag); - - /** - * Get the default Multithreaded setting for all PersistenceManager instances - * obtained from this factory. - * - * @return the default Multithreaded setting. - */ - boolean getMultithreaded(); - - /** - * Set the Mapping setting for this factory. This is used to find the object-datastore mapping - * file(s). - * - * @param mapping the Mapping setting. - */ - void setMapping(String mapping); - - /** - * Get the Mapping setting for this factory. This is used to find the object-datastore mapping - * file(s). - * - * @return the Mapping setting. - */ - String getMapping(); - - /** - * Set the default Optimistic setting for all PersistenceManager instances obtained - * from this factory. - * - * @param flag the default Optimistic setting. - */ - void setOptimistic(boolean flag); - - /** - * Get the default Optimistic setting for all PersistenceManager instances obtained - * from this factory. - * - * @return the default Optimistic setting. - */ - boolean getOptimistic(); - - /** - * Set the default RetainValues setting for all PersistenceManager instances obtained - * from this factory. - * - * @param flag the default RetainValues setting. - */ - void setRetainValues(boolean flag); - - /** - * Get the default RetainValues setting for all PersistenceManager instances obtained - * from this factory. - * - * @return the default RetainValues setting. - */ - boolean getRetainValues(); - - /** - * Set the default value for the RestoreValues property. If true, at rollback, fields - * of newly persistent instances are restored to their values as of the beginning of the - * transaction, and the instances revert to transient. Additionally, fields of modified instances - * of primitive types and immutable reference types are restored to their values as of the - * beginning of the transaction. - * - *

    If false, at rollback, the values of fields of newly persistent instances are - * unchanged and the instances revert to transient. Additionally, dirty instances transition to - * hollow. If an implementation does not support this option, a - * JDOUnsupportedOptionException is thrown. - * - * @param restoreValues the value of the restoreValues property - */ - void setRestoreValues(boolean restoreValues); - - /** - * Get the default value for the RestoreValues property. - * - * @return the value of the restoreValues property - */ - boolean getRestoreValues(); - - /** - * Set the default NontransactionalRead setting for all PersistenceManager instances - * obtained from this factory. - * - * @param flag the default NontransactionalRead setting. - */ - void setNontransactionalRead(boolean flag); - - /** - * Get the default NontransactionalRead setting for all PersistenceManager instances - * obtained from this factory. - * - * @return the default NontransactionalRead setting. - */ - boolean getNontransactionalRead(); - - /** - * Set the default NontransactionalWrite setting for all PersistenceManager instances - * obtained from this factory. - * - * @param flag the default NontransactionalWrite setting. - */ - void setNontransactionalWrite(boolean flag); - - /** - * Get the default NontransactionalWrite setting for all PersistenceManager instances - * obtained from this factory. - * - * @return the default NontransactionalWrite setting. - */ - boolean getNontransactionalWrite(); - - /** - * Set the default IgnoreCache setting for all PersistenceManager instances obtained - * from this factory. - * - * @param flag the default IgnoreCache setting. - */ - void setIgnoreCache(boolean flag); - - /** - * Get the default IgnoreCache setting for all PersistenceManager instances obtained - * from this factory. - * - * @return the default IngoreCache setting. - */ - boolean getIgnoreCache(); - - /** - * Gets the detachAllOnCommit setting. - * - * @see #setDetachAllOnCommit(boolean) - * @since 2.0 - * @return the default detachAllOnCommit setting. - */ - boolean getDetachAllOnCommit(); - - /** - * Sets the default detachAllOnCommit setting for all PersistenceManager instances - * obtained from this factory. - * - * @see #getDetachAllOnCommit() - * @since 2.0 - * @param flag the default DetachAllOnCommit setting - */ - void setDetachAllOnCommit(boolean flag); - - /** - * Gets the default copyOnAttach setting for all PersistenceManager instances - * obtained from this factory. - * - * @see #setCopyOnAttach(boolean) - * @since 2.1 - * @return the copyOnAttach setting. - */ - boolean getCopyOnAttach(); - - /** - * Sets the default copyOnAttach setting for all PersistenceManager instances - * obtained from this factory. - * - *

    CopyOnAttach set to true specifies that during makePersistent, copies are made - * of detached parameter instances. With this flag set to false, detached parameter - * instances are attached directly and change their state from detached-clean to persistent-clean - * or from detached-dirty to persistent-dirty. - * - * @param flag Whether we should copy on attach - * @see #getCopyOnAttach() - * @since 2.1 - */ - void setCopyOnAttach(boolean flag); - - /** - * Sets the name of this PersistenceManagerFactory. - * - * @since 2.1 - * @param name the name of this PMF - */ - void setName(String name); - - /** - * Gets the name of this PersistenceManagerFactory. - * - * @since 2.1 - * @return the name of this PMF - */ - String getName(); - - /** - * Sets the PersistenceUnitName for this PersistenceManagerFactory. This has the same semantics as - * the same-named property in JSR-220 PersistenceUnitInfo. - * - * @see #getPersistenceUnitName() - * @since 2.1 - * @param name the PersistenceUnitName - */ - void setPersistenceUnitName(String name); - - /** - * Gets the PersistenceUnitName for this PersistenceManagerFactory. - * - * @see #setPersistenceUnitName(String) - * @since 2.1 - * @return the PersistenceUnitName - */ - String getPersistenceUnitName(); - - /** - * Sets the TimeZone ID of the server associated with this PersistenceManagerFactory. The - * parameter is a String suitable for use with TimeZone.getTimeZone(). The String must match an ID - * returned by TimeZone.getAvailableIDs(). If the ServerTimeZoneID is not set, or set to the null - * String, assume that the server has the same TimeZone ID as the client. If incorrectly set, the - * result of PersistenceManager.getServerDate() might be incorrect. - * - * @see #getServerTimeZoneID() - * @see java.util.TimeZone#getTimeZone(String) - * @see java.util.TimeZone#getAvailableIDs() - * @see PersistenceManager#getServerDate() - * @since 2.1 - * @param timezoneid the TimeZone ID of the server - * @throws JDOUserException if the parameter does not match an ID from TimeZone.getAvailableIDs() - */ - void setServerTimeZoneID(String timezoneid); - - /** - * Gets the TimeZone ID of the server associated with this PersistenceManagerFactory. If not set, - * assume that the server has the same TimeZone ID as the client. - * - * @see #setServerTimeZoneID(String) - * @since 2.1 - * @return the TimeZone of the server - */ - String getServerTimeZoneID(); - - /** - * Sets the TransactionType for this PersistenceManagerFactory. Permitted values are "JTA" and - * "RESOURCE_LOCAL". This has the same semantics as the same-named property in JSR-220 - * EntityManagerFactory. - * - * @see #getTransactionType() - * @see Constants#JTA - * @see Constants#RESOURCE_LOCAL - * @since 2.1 - * @param name the TransactionType - * @throws JDOUserException if the parameter is not a permitted value - */ - void setTransactionType(String name); - - /** - * Gets the TransactionType for this PersistenceManagerFactory. - * - * @see #setTransactionType(String) - * @since 2.1 - * @return the TransactionType - */ - String getTransactionType(); - - /** - * Gets the value for read-only for this PMF. Indicates whether the datastore is read-only or - * writable. - * - * @see #setReadOnly(boolean) - * @since 2.2 - * @return the readOnly setting. - */ - boolean getReadOnly(); - - /** - * Sets the value for whether the datastore is to be considered read-only. - * - *

    ReadOnly set to false specifies that no updates can be performed to the - * datastore, and if updates are attempted a JDOReadOnlyException is thrown. - * - * @param flag whether we should consider this datastore read-only - * @see #getReadOnly() - * @since 2.2 - */ - void setReadOnly(boolean flag); - - /** - * Get the value for transaction isolation level for this PMF. - * - * @return the transaction isolation level - * @see #setTransactionIsolationLevel(String) - * @since 2.2 - */ - String getTransactionIsolationLevel(); - - /** - * Set the value for transaction isolation level for this PMF. Transaction isolation levels are - * defined in javax.jdo.Constants. If the requested level is not available, but a higher level is - * available, the higher level is silently used. If the requested level is not available, and no - * higher level is available, then JDOUnsupportedOptionException is thrown. Standard values in - * order from low to high are: - * - *

      - *
    • read-uncommitted - *
    • read-committed - *
    • repeatable-read - *
    • snapshot - *
    • serializable - *
    - * - * @param level the transaction isolation level - * @see #getTransactionIsolationLevel() - * @see Constants#TX_READ_UNCOMMITTED - * @see Constants#TX_READ_COMMITTED - * @see Constants#TX_REPEATABLE_READ - * @see Constants#TX_SNAPSHOT - * @see Constants#TX_SERIALIZABLE - * @since 2.2 - */ - void setTransactionIsolationLevel(String level); - - /** - * Specify a default timeout interval (milliseconds) for any read operations for persistence - * managers obtained from this persistence manager factory. To unset the explicit timeout, specify - * null. For no timeout, specify 0. If the datastore and JDO implementation support timeouts, then - * javax.jdo.option.DatastoreTimeout is returned by supportedOptions(). If timeouts are not - * supported,this method will throw JDOUnsupportedOptionException. - * - * @since 3.0 - * @param interval the timeout interval (milliseconds) - */ - void setDatastoreReadTimeoutMillis(Integer interval); - - /** - * Get the default timeout setting for read operations. If timeouts are not supported,this method - * will return null. - * - * @see #setDatastoreReadTimeoutMillis(Integer) - * @return the default timeout setting (milliseconds). - * @since 3.0 - */ - Integer getDatastoreReadTimeoutMillis(); - - /** - * Specify a default timeout interval (milliseconds) for any write operations for persistence - * managers obtained from this persistence manager factory. To unset the explicit timeout, specify - * null. For no timeout, specify 0. If the datastore and JDO implementation support timeouts, then - * javax.jdo.option.DatastoreTimeout is returned by supportedOptions(). If timeouts are not - * supported,this method will throw JDOUnsupportedOptionException. - * - * @since 3.0 - * @param interval the timeout interval (milliseconds) - */ - void setDatastoreWriteTimeoutMillis(Integer interval); - - /** - * Get the default timeout setting for write operations. If timeouts are not supported,this method - * will return null. - * - * @see #setDatastoreWriteTimeoutMillis(Integer) - * @return the default timeout setting (milliseconds). - * @since 3.0 - */ - Integer getDatastoreWriteTimeoutMillis(); - - /** - * Return non-configurable properties of this PersistenceManagerFactory. Properties - * with keys VendorName and VersionNumber are required. Other keys are - * optional. - * - * @return the non-configurable properties of this PersistenceManagerFactory. - */ - Properties getProperties(); - - /** - * The application can determine from the results of this method which optional features, and - * which query languages are supported by the JDO implementation. - * - *

    Each supported JDO feature is represented by a String with one of the following - * values: - * - *

    javax.jdo.option.TransientTransactional - *
    javax.jdo.option.NontransactionalRead - *
    javax.jdo.option.NontransactionalWrite - *
    javax.jdo.option.RetainValues - *
    javax.jdo.option.Optimistic - *
    javax.jdo.option.ApplicationIdentity - *
    javax.jdo.option.DatastoreIdentity - *
    javax.jdo.option.NonDurableIdentity - *
    javax.jdo.option.ArrayList - *
    javax.jdo.option.HashMap - *
    javax.jdo.option.Hashtable - *
    javax.jdo.option.LinkedList - *
    javax.jdo.option.TreeMap - *
    javax.jdo.option.TreeSet - *
    javax.jdo.option.Vector - *
    javax.jdo.option.Map - *
    javax.jdo.option.List - *
    javax.jdo.option.Array - *
    javax.jdo.option.NullCollection - *
    javax.jdo.option.ChangeApplicationIdentity - *
    javax.jdo.option.BinaryCompatibility - *
    javax.jdo.option.GetDataStoreConnection - *
    javax.jdo.option.UnconstrainedQueryVariables - *
    javax.jdo.option.TransactionIsolationLevel.read-uncommitted - *
    javax.jdo.option.TransactionIsolationLevel.read-committed - *
    javax.jdo.option.TransactionIsolationLevel.repeatable-read - *
    javax.jdo.option.TransactionIsolationLevel.snapshot - *
    javax.jdo.option.TransactionIsolationLevel.serializable - *
    javax.jdo.option.QueryCancel - *
    javax.jdo.option.DatastoreTimeout - *
    javax.jdo.query.SQL - *
    javax.jdo.query.JDOQL - *
    - * - *

    The standard JDO query language is represented by a String: - * - *

    javax.jdo.query.JDOQL - * - * @return the Collection of Strings representing the supported options. - */ - Collection supportedOptions(); - - /** - * Return the {@link DataStoreCache} that this factory uses for controlling a second-level cache. - * If this factory does not use a second-level cache, the returned instance does nothing. This - * method never returns null. - * - * @since 2.0 - * @return the DataStoreCache - */ - DataStoreCache getDataStoreCache(); - - /** - * Add the parameter listener to the list of instance lifecycle event listeners set as the initial - * listeners for each PersistenceManager created by this PersistenceManagerFactory. The - * addInstanceLifecycleListener and removeInstanceLifecycleListener methods - * are considered to be configuration methods and can only be called when the - * PersistenceManagerFactory is configurable (before the first time {@link #getPersistenceManager} - * is called). - * - *

    The classes parameter identifies all of the classes of interest. If the - * classes parameter is specified as null, events for all persistent classes - * and interfaces will be sent to the listener. - * - *

    The listener will be called for each event for which it implements the corresponding {@link - * InstanceLifecycleListener} interface. - * - * @param listener the lifecycle listener - * @param classes the classes of interest to the listener - * @since 2.0 - */ - void addInstanceLifecycleListener(InstanceLifecycleListener listener, Class[] classes); - - /** - * Remove the parameter listener instance from the list of instance lifecycle event listeners set - * as the initial listeners for each PersistenceManager created by this PersistenceManagerFactory. - * The addInstanceLifecycleListener and removeInstanceLifecycleListener - * methods are considered to be configuration methods and can only be called when the - * PersistenceManagerFactory is configurable (before the first time {@link #getPersistenceManager} - * is called). - * - * @param listener the listener instance to be removed - * @since 2.0 - */ - void removeInstanceLifecycleListener(InstanceLifecycleListener listener); - - /** - * Add the FetchGroups to the set of active fetch groups. FetchGroups - * are made unmodifiable before being added. FetchGroups that match existing - * FetchGroups replace the corresponding FetchGroups. The replaced - * FetchGroups become unscoped. Match is based on identical class and equal name. The - * methods {@link #addFetchGroups}, {@link #removeFetchGroups}, {@link #getFetchGroups}, and - * {@link #removeAllFetchGroups} are internally serialized. - * - * @param groups an array of FetchGroups - * @throws SecurityException if the caller is not authorized for {@link JDOPermission} - * ("manageMetadata") - * @since 2.2 - */ - void addFetchGroups(FetchGroup... groups); - - /** - * Remove the FetchGroups from the set of active FetchGroups. Existing - * FetchGroups that match parameter FetchGroups are removed. Parameter - * FetchGroups that do not match any existing FetchGroup are ignored. - * Removed FetchGroups become unscoped. Match is based on identical class and equal - * name. The methods {@link #addFetchGroups}, {@link #removeFetchGroups}, {@link #getFetchGroups}, - * and {@link #removeAllFetchGroups} are internally serialized. - * - * @param groups an array of FetchGroups - * @throws SecurityException if the caller is not authorized for {@link JDOPermission} - * ("manageMetadata") - * @since 2.2 - */ - void removeFetchGroups(FetchGroup... groups); - - /** - * Remove all FetchGroups from the set of active FetchGroups. All - * removed FetchGroups become unscoped. The methods {@link #addFetchGroups}, {@link - * #removeFetchGroups}, {@link #getFetchGroups}, and {@link #removeAllFetchGroups} are internally - * serialized. - * - * @throws SecurityException if the caller is not authorized for {@link JDOPermission} - * ("manageMetadata") - * @since 2.2 - */ - void removeAllFetchGroups(); - - /** - * Create an unscoped, modifiable FetchGroup for the Class and name. If a - * corresponding FetchGroup already exists in PersistenceManagerFactory - * scope, copy its definition to a new FetchGroup. If the FetchGroup - * does not already exist, create it with no members. The FetchGroup does not become - * in scope until it is added to the current set via {@link #addFetchGroups}. - * - * @param cls the class or interface for the FetchGroup - * @param name the name of the fetch group - * @return the FetchGroup - * @throws JDOUserException if the class is not a persistence-capable class or interface - * @since 2.2 - */ - FetchGroup getFetchGroup(Class cls, String name); - - /** - * Get a modifiable Set containing a mutable copy of all currently active (in scope) fetch groups. - * The methods {@link #addFetchGroups}, {@link #removeFetchGroups}, {@link #getFetchGroups}, and - * {@link #removeAllFetchGroups} are internally serialized. - * - * @return a copy of all currently active fetch groups - * @throws SecurityException if the caller is not authorized for {@link JDOPermission} - * ("getMetadata") - * @since 2.2 - */ - Set getFetchGroups(); - - /** - * Method to register metadata with the persistence process managed by this - * PersistenceManagerFactory. Metadata can be created using the method {@link - * #newMetadata}. If there is already metadata registered for a class contained in this metadata - * object then a JDOUserException will be thrown. - * - * @param metadata The Metadata to register. - * @since 3.0 - */ - void registerMetadata(JDOMetadata metadata); - - /** - * Method to return a new metadata object that can be subsequently modified and registered with - * the persistence process using the method {@link #registerMetadata}. - * - * @return The metadata - * @since 3.0 - */ - JDOMetadata newMetadata(); - - /** - * Method to return the metadata object for the specified class/interface, if there is metadata - * defined for that class/interface. If there is no metadata for the specified class/interface, or - * the parameter is null, then null will be returned. - * - * @param className Name of the class to get metadata for - * @return The metadata - * @since 3.0 - */ - TypeMetadata getMetadata(String className); - - /** - * Method to return the currently managed classes for this factory. - * - * @return Collection of persistable classes that are managed by this factory - * @since 3.1 - */ - Collection getManagedClasses(); + + /** Close this PersistenceManagerFactory. Check for + * JDOPermission("closePersistenceManagerFactory") and if not authorized, + * throw SecurityException. + *

    If the authorization check succeeds, check to see that all + * PersistenceManager instances obtained from this PersistenceManagerFactory + * have no active transactions. If any PersistenceManager instances have + * an active transaction, throw a JDOUserException, with one nested + * JDOUserException for each PersistenceManager with an active Transaction. + *

    If there are no active transactions, then close all PersistenceManager + * instances obtained from this PersistenceManagerFactory, mark this + * PersistenceManagerFactory as closed, disallow getPersistenceManager + * methods, and allow all other get methods. If a set method or + * getPersistenceManager method is called after close, then + * JDOUserException is thrown. + * @since 1.0.1 + */ + void close(); + + /** + * A PersistenceManagerFactory instance can be used + * until it is closed. + * @return true if this PersistenceManagerFactory + * has been closed. + * @see #close() + * @since 2.0 + */ + boolean isClosed(); + + /** Get an instance of PersistenceManager from this factory. + * The instance has default values for options. + * + *

    After the first use of getPersistenceManager, no "set" + * methods will succeed. + * + * @return a PersistenceManager instance with default options. + */ + PersistenceManager getPersistenceManager(); + + /** Get a thread-safe instance of a proxy that dynamically binds + * on each method call to an instance of PersistenceManager. + *

    When used with a PersistenceManagerFactory + * that uses TransactionType JTA, + * the proxy can be used in a server to dynamically bind to an instance + * from this factory associated with the thread's current transaction. + * In this case, the close method is ignored, as the + * PersistenceManager is automatically closed when the + * transaction completes. + *

    When used with a PersistenceManagerFactory + * that uses TransactionType RESOURCE_LOCAL, the proxy uses an inheritable + * ThreadLocal to bind to an instance of PersistenceManager + * associated with the thread. In this case, the close method executed + * on the proxy closes the PersistenceManager and then + * clears the ThreadLocal. + * Use of this method does not affect the configurability of the + * PersistenceManagerFactory. + * + * @since 2.1 + * @return a PersistenceManager proxy. + */ + PersistenceManager getPersistenceManagerProxy(); + + /** Get an instance of PersistenceManager from this factory. + * The instance has default values for options. + * The parameters userid and password are used + * when obtaining datastore connections from the connection pool. + * + *

    After the first use of getPersistenceManager, no "set" + * methods will succeed. + * + * @return a PersistenceManager instance with default options. + * @param userid the userid for the connection + * @param password the password for the connection + */ + PersistenceManager getPersistenceManager(String userid, String password); + + /** Set the user name for the data store connection. + * @param userName the user name for the data store connection. + */ + void setConnectionUserName(String userName); + + /** Get the user name for the data store connection. + * @return the user name for the data store connection. + */ + String getConnectionUserName (); + + /** Set the password for the data store connection. + * @param password the password for the data store connection. + */ + void setConnectionPassword (String password); + + /** Set the URL for the data store connection. + * @param url the URL for the data store connection. + */ + void setConnectionURL (String url); + + /** Get the URL for the data store connection. + * @return the URL for the data store connection. + */ + String getConnectionURL (); + + /** Set the driver name for the data store connection. + * This property might be ignored by the JDO implementation + * because the JDBC DriverManager handles the driver name. + * @param driverName the driver name for the data store connection. + */ + void setConnectionDriverName (String driverName); + + /** Get the driver name for the data store connection. + * This property might be ignored by the JDO implementation + * because the JDBC DriverManager handles the driver name. + * @return the driver name for the data store connection. + */ + String getConnectionDriverName (); + + /** Set the name for the data store connection factory. + * @param connectionFactoryName the name of the data store connection + * factory. + */ + void setConnectionFactoryName (String connectionFactoryName); + + /** Get the name for the data store connection factory. + * @return the name of the data store connection factory. + */ + String getConnectionFactoryName (); + + /** Set the data store connection factory. JDO implementations + * will support specific connection factories. The connection + * factory interfaces are not part of the JDO specification. + * @param connectionFactory the data store connection factory. + */ + void setConnectionFactory (Object connectionFactory); + + /** Get the data store connection factory. + * @return the data store connection factory. + */ + Object getConnectionFactory (); + + /** Set the name for the second data store connection factory. This is + * needed for managed environments to get nontransactional connections for + * optimistic transactions. + * @param connectionFactoryName the name of the data store connection + * factory. + */ + void setConnectionFactory2Name (String connectionFactoryName); + + /** Get the name for the second data store connection factory. This is + * needed for managed environments to get nontransactional connections for + * optimistic transactions. + * @return the name of the data store connection factory. + */ + String getConnectionFactory2Name (); + + /** Set the second data store connection factory. This is + * needed for managed environments to get nontransactional connections for + * optimistic transactions. JDO implementations + * will support specific connection factories. The connection + * factory interfaces are not part of the JDO specification. + * @param connectionFactory the data store connection factory. + */ + void setConnectionFactory2 (Object connectionFactory); + + /** Get the second data store connection factory. This is + * needed for managed environments to get nontransactional connections for + * optimistic transactions. + * @return the data store connection factory. + */ + Object getConnectionFactory2 (); + + /** Set the default Multithreaded setting for all + * PersistenceManager instances obtained from this factory. + * + * @param flag the default Multithreaded setting. + */ + void setMultithreaded (boolean flag); + + /** Get the default Multithreaded setting for all + * PersistenceManager instances obtained from this factory. + * + * @return the default Multithreaded setting. + */ + boolean getMultithreaded(); + + /** Set the Mapping setting for this factory. This is used to find the + * object-datastore mapping file(s). + * + * @param mapping the Mapping setting. + */ + void setMapping (String mapping); + + /** Get the Mapping setting for this factory. This is used to find the + * object-datastore mapping file(s). + * + * @return the Mapping setting. + */ + String getMapping (); + + /** Set the default Optimistic setting for all + * PersistenceManager instances obtained from this factory. + * + * @param flag the default Optimistic setting. + */ + void setOptimistic (boolean flag); + + /** Get the default Optimistic setting for all + * PersistenceManager instances obtained from this factory. + * + * @return the default Optimistic setting. + */ + boolean getOptimistic(); + + /** Set the default RetainValues setting for all + * PersistenceManager instances obtained from this factory. + * + * @param flag the default RetainValues setting. + */ + void setRetainValues (boolean flag); + + /** Get the default RetainValues setting for all + * PersistenceManager instances obtained from this factory. + * + * @return the default RetainValues setting. + */ + boolean getRetainValues (); + + /** Set the default value for the RestoreValues property. + * If true, at rollback, fields of newly persistent instances + * are restored to + * their values as of the beginning of the transaction, and the instances + * revert to transient. Additionally, fields of modified + * instances of primitive types and immutable reference types + * are restored to their values as of the beginning of the + * transaction. + *

    If false, at rollback, the values of fields of + * newly persistent instances are unchanged and the instances revert to + * transient. Additionally, dirty instances transition to hollow. + * If an implementation does not support this option, a + * JDOUnsupportedOptionException is thrown. + * @param restoreValues the value of the restoreValues property + */ + void setRestoreValues(boolean restoreValues); + + /** Get the default value for the RestoreValues property. + * @return the value of the restoreValues property + */ + boolean getRestoreValues(); + + /** Set the default NontransactionalRead setting for all + * PersistenceManager instances obtained from this factory. + * + * @param flag the default NontransactionalRead setting. + */ + void setNontransactionalRead (boolean flag); + + /** Get the default NontransactionalRead setting for all + * PersistenceManager instances obtained from this factory. + * + * @return the default NontransactionalRead setting. + */ + boolean getNontransactionalRead (); + + /** Set the default NontransactionalWrite setting for all + * PersistenceManager instances obtained from this factory. + * + * @param flag the default NontransactionalWrite setting. + */ + void setNontransactionalWrite (boolean flag); + + /** Get the default NontransactionalWrite setting for all + * PersistenceManager instances obtained from this factory. + * + * @return the default NontransactionalWrite setting. + */ + boolean getNontransactionalWrite (); + + /** Set the default IgnoreCache setting for all + * PersistenceManager instances obtained from this factory. + * + * @param flag the default IgnoreCache setting. + */ + void setIgnoreCache (boolean flag); + + /** Get the default IgnoreCache setting for all + * PersistenceManager instances obtained from this factory. + * + * @return the default IngoreCache setting. + */ + boolean getIgnoreCache (); + + /** Gets the detachAllOnCommit setting. + * @see #setDetachAllOnCommit(boolean) + * @since 2.0 + * @return the default detachAllOnCommit setting. + */ + boolean getDetachAllOnCommit(); + + /** Sets the default detachAllOnCommit setting for all + * PersistenceManager instances obtained from this + * factory. + * @see #getDetachAllOnCommit() + * @since 2.0 + * @param flag the default DetachAllOnCommit setting + */ + void setDetachAllOnCommit(boolean flag); + + /** Gets the default copyOnAttach setting for all + * PersistenceManager instances obtained from this + * factory. + * @see #setCopyOnAttach(boolean) + * @since 2.1 + * @return the copyOnAttach setting. + */ + boolean getCopyOnAttach(); + + /** Sets the default copyOnAttach setting for all + * PersistenceManager instances obtained from this + * factory. + * + *

    CopyOnAttach set to true specifies that during + * makePersistent, copies are made of detached parameter instances. + * With this flag set to false, detached parameter + * instances are attached directly and change their state from + * detached-clean to persistent-clean or from detached-dirty to + * persistent-dirty. + * @param flag Whether we should copy on attach + * @see #getCopyOnAttach() + * @since 2.1 + */ + void setCopyOnAttach(boolean flag); + + /** + * Sets the name of this PersistenceManagerFactory. + * @since 2.1 + * @param name the name of this PMF + */ + void setName(String name); + + /** + * Gets the name of this PersistenceManagerFactory. + * @since 2.1 + * @return the name of this PMF + */ + String getName(); + + /** + * Sets the PersistenceUnitName for this PersistenceManagerFactory. + * This has the same semantics as the same-named property in + * JSR-220 PersistenceUnitInfo. + * @see #getPersistenceUnitName() + * @since 2.1 + * @param name the PersistenceUnitName + */ + void setPersistenceUnitName(String name); + + /** + * Gets the PersistenceUnitName for this PersistenceManagerFactory. + * @see #setPersistenceUnitName(String) + * @since 2.1 + * @return the PersistenceUnitName + */ + String getPersistenceUnitName(); + + /** + * Sets the TimeZone ID of the server associated with this + * PersistenceManagerFactory. The parameter is a String + * suitable for use with TimeZone.getTimeZone(). The String + * must match an ID returned by TimeZone.getAvailableIDs(). + * If the ServerTimeZoneID is not set, or set to the null String, + * assume that the server has the same TimeZone ID as the client. + * If incorrectly set, the result of PersistenceManager.getServerDate() + * might be incorrect. + * @see #getServerTimeZoneID() + * @see java.util.TimeZone#getTimeZone(String) + * @see java.util.TimeZone#getAvailableIDs() + * @see PersistenceManager#getServerDate() + * @since 2.1 + * @param timezoneid the TimeZone ID of the server + * @throws JDOUserException if the parameter does not match + * an ID from TimeZone.getAvailableIDs() + */ + void setServerTimeZoneID(String timezoneid); + + /** + * Gets the TimeZone ID of the server associated with this + * PersistenceManagerFactory. If not set, assume that + * the server has the same TimeZone ID as the client. + * @see #setServerTimeZoneID(String) + * @since 2.1 + * @return the TimeZone of the server + */ + String getServerTimeZoneID(); + + /** + * Sets the TransactionType for this PersistenceManagerFactory. + * Permitted values are "JTA" and "RESOURCE_LOCAL". + * This has the same semantics as the same-named property in + * JSR-220 EntityManagerFactory. + * @see #getTransactionType() + * @see Constants#JTA + * @see Constants#RESOURCE_LOCAL + * @since 2.1 + * @param name the TransactionType + * @throws JDOUserException if the parameter is not a permitted value + */ + void setTransactionType(String name); + + /** + * Gets the TransactionType for this PersistenceManagerFactory. + * @see #setTransactionType(String) + * @since 2.1 + * @return the TransactionType + */ + String getTransactionType(); + + /** Gets the value for read-only for this PMF. + * Indicates whether the datastore is read-only or writable. + * @see #setReadOnly(boolean) + * @since 2.2 + * @return the readOnly setting. + */ + boolean getReadOnly(); + + /** Sets the value for whether the datastore is to be considered + * read-only. + * + *

    ReadOnly set to false specifies that no updates + * can be performed to the datastore, and if updates are attempted + * a JDOReadOnlyException is thrown. + * @param flag whether we should consider this datastore read-only + * @see #getReadOnly() + * @since 2.2 + */ + void setReadOnly(boolean flag); + + /** Get the value for transaction isolation level for this PMF. + * @return the transaction isolation level + * @see #setTransactionIsolationLevel(String) + * @since 2.2 + */ + String getTransactionIsolationLevel(); + + /** Set the value for transaction isolation level for this PMF. + * Transaction isolation levels are defined in javax.jdo.Constants. + * If the requested level is not available, but a higher level is + * available, the higher level is silently used. + * If the requested level is not available, and no higher level is + * available, then JDOUnsupportedOptionException is thrown. + * Standard values in order from low to high are: + *

    • read-uncommitted + *
    • read-committed + *
    • repeatable-read + *
    • snapshot + *
    • serializable + *
    + * @param level the transaction isolation level + * @see #getTransactionIsolationLevel() + * @see Constants#TX_READ_UNCOMMITTED + * @see Constants#TX_READ_COMMITTED + * @see Constants#TX_REPEATABLE_READ + * @see Constants#TX_SNAPSHOT + * @see Constants#TX_SERIALIZABLE + * @since 2.2 + */ + void setTransactionIsolationLevel(String level); + + /** + * Specify a default timeout interval (milliseconds) for any read + * operations for persistence managers obtained from this persistence + * manager factory. To unset the explicit timeout, specify null. + * For no timeout, specify 0. + * If the datastore and JDO implementation support timeouts, then + * javax.jdo.option.DatastoreTimeout is returned by supportedOptions(). + * If timeouts are not supported,this method will throw + * JDOUnsupportedOptionException. + * @since 3.0 + * @param interval the timeout interval (milliseconds) + */ + void setDatastoreReadTimeoutMillis(Integer interval); + + /** Get the default timeout setting for read operations. + * If timeouts are not supported,this method will return null. + * @see #setDatastoreReadTimeoutMillis(Integer) + * @return the default timeout setting (milliseconds). + * @since 3.0 + */ + Integer getDatastoreReadTimeoutMillis(); + + /** + * Specify a default timeout interval (milliseconds) for any write + * operations for persistence managers obtained from this persistence + * manager factory. To unset the explicit timeout, specify null. + * For no timeout, specify 0. + * If the datastore and JDO implementation support timeouts, then + * javax.jdo.option.DatastoreTimeout is returned by supportedOptions(). + * If timeouts are not supported,this method will throw + * JDOUnsupportedOptionException. + * @since 3.0 + * @param interval the timeout interval (milliseconds) + */ + void setDatastoreWriteTimeoutMillis(Integer interval); + + /** Get the default timeout setting for write operations. + * If timeouts are not supported,this method will return null. + * @see #setDatastoreWriteTimeoutMillis(Integer) + * @return the default timeout setting (milliseconds). + * @since 3.0 + */ + Integer getDatastoreWriteTimeoutMillis(); + + /** Return non-configurable properties of this + * PersistenceManagerFactory. + * Properties with keys VendorName and + * VersionNumber are required. Other keys are optional. + * @return the non-configurable properties of this + * PersistenceManagerFactory. + */ + Properties getProperties(); + + /** The application can determine from the results of this + * method which optional features, and which query languages + * are supported by the JDO implementation. + *

    Each supported JDO feature is represented by a + * String with one of the following values: + * + *

    javax.jdo.option.TransientTransactional + *
    javax.jdo.option.NontransactionalRead + *
    javax.jdo.option.NontransactionalWrite + *
    javax.jdo.option.RetainValues + *
    javax.jdo.option.Optimistic + *
    javax.jdo.option.ApplicationIdentity + *
    javax.jdo.option.DatastoreIdentity + *
    javax.jdo.option.NonDurableIdentity + *
    javax.jdo.option.ArrayList + *
    javax.jdo.option.HashMap + *
    javax.jdo.option.Hashtable + *
    javax.jdo.option.LinkedList + *
    javax.jdo.option.TreeMap + *
    javax.jdo.option.TreeSet + *
    javax.jdo.option.Vector + *
    javax.jdo.option.Map + *
    javax.jdo.option.List + *
    javax.jdo.option.Array + *
    javax.jdo.option.NullCollection + *
    javax.jdo.option.ChangeApplicationIdentity + *
    javax.jdo.option.BinaryCompatibility + *
    javax.jdo.option.GetDataStoreConnection + *
    javax.jdo.option.UnconstrainedQueryVariables + *
    javax.jdo.option.TransactionIsolationLevel.read-uncommitted + *
    javax.jdo.option.TransactionIsolationLevel.read-committed + *
    javax.jdo.option.TransactionIsolationLevel.repeatable-read + *
    javax.jdo.option.TransactionIsolationLevel.snapshot + *
    javax.jdo.option.TransactionIsolationLevel.serializable + *
    javax.jdo.option.QueryCancel + *
    javax.jdo.option.DatastoreTimeout + *
    javax.jdo.query.SQL + *
    javax.jdo.query.JDOQL + *
    + * + *

    The standard JDO query language is represented by a + * String: + *

    javax.jdo.query.JDOQL + * @return the Collection of Strings representing + * the supported options. + */ + Collection supportedOptions(); + + /** + * Return the {@link DataStoreCache} that this factory uses for + * controlling a second-level cache. If this factory does not use + * a second-level cache, the returned instance does nothing. This + * method never returns null. + * @since 2.0 + * @return the DataStoreCache + */ + DataStoreCache getDataStoreCache (); + + /** + * Add the parameter listener to the list of + * instance lifecycle event listeners set as the initial listeners + * for each PersistenceManager created by this PersistenceManagerFactory. + * The addInstanceLifecycleListener and + * removeInstanceLifecycleListener + * methods are considered to be configuration methods and + * can only be called when the PersistenceManagerFactory + * is configurable (before the first time {@link #getPersistenceManager} + * is called). + *

    The classes parameter identifies all + * of the classes of interest. If the classes + * parameter is specified as null, events for all + * persistent classes and interfaces will be sent to the listener.

    + *

    The listener will be called for each event for which it + * implements the corresponding {@link InstanceLifecycleListener} + * interface.

    + * @param listener the lifecycle listener + * @param classes the classes of interest to the listener + * @since 2.0 + */ + void addInstanceLifecycleListener (InstanceLifecycleListener listener, + Class[] classes); + + /** + * Remove the parameter listener instance from the list of + * instance lifecycle event listeners set as the initial listeners + * for each PersistenceManager created by this PersistenceManagerFactory. + * The addInstanceLifecycleListener and + * removeInstanceLifecycleListener + * methods are considered to be configuration methods and + * can only be called when the PersistenceManagerFactory + * is configurable (before the first time {@link #getPersistenceManager} + * is called). + * @param listener the listener instance to be removed + * @since 2.0 + */ + void removeInstanceLifecycleListener (InstanceLifecycleListener listener); + + /** + * Add the FetchGroups to the set of active fetch groups. + * FetchGroups are made unmodifiable before being added. + * FetchGroups that match existing FetchGroups + * replace the corresponding FetchGroups. + * The replaced FetchGroups become unscoped. + * Match is based on identical class and equal name. + * The methods {@link #addFetchGroups}, {@link #removeFetchGroups}, + * {@link #getFetchGroups}, and {@link #removeAllFetchGroups} + * are internally serialized. + * @param groups an array of FetchGroups + * @throws SecurityException if the caller is not authorized for + * {@link JDOPermission} ("manageMetadata") + * @since 2.2 + */ + void addFetchGroups(FetchGroup... groups); + + /** + * Remove the FetchGroups from the set of active + * FetchGroups. Existing FetchGroups that match + * parameter FetchGroups are removed. Parameter + * FetchGroups that do not match any existing + * FetchGroup are ignored. + * Removed FetchGroups become unscoped. + * Match is based on identical class and equal name. + * The methods {@link #addFetchGroups}, {@link #removeFetchGroups}, + * {@link #getFetchGroups}, and {@link #removeAllFetchGroups} + * are internally serialized. + * @param groups an array of FetchGroups + * @throws SecurityException if the caller is not authorized for + * {@link JDOPermission} ("manageMetadata") + * @since 2.2 + */ + void removeFetchGroups(FetchGroup... groups); + + /** + * Remove all FetchGroups from the set of active + * FetchGroups. + * All removed FetchGroups become unscoped. + * The methods {@link #addFetchGroups}, {@link #removeFetchGroups}, + * {@link #getFetchGroups}, and {@link #removeAllFetchGroups} + * are internally serialized. + * @throws SecurityException if the caller is not authorized for + * {@link JDOPermission} ("manageMetadata") + * @since 2.2 + */ + void removeAllFetchGroups(); + + /** + * Create an unscoped, modifiable FetchGroup for the Class and + * name. If a corresponding FetchGroup already exists in + * PersistenceManagerFactory scope, copy its definition + * to a new FetchGroup. + * If the FetchGroup does not already exist, create it + * with no members. The FetchGroup does not become + * in scope until it is added to the current set via + * {@link #addFetchGroups}. + * @param cls the class or interface for the FetchGroup + * @param name the name of the fetch group + * @return the FetchGroup + * @throws JDOUserException if the class is not a persistence-capable + * class or interface + * @since 2.2 + */ + FetchGroup getFetchGroup(Class cls, String name); + + /** + * Get a modifiable Set containing a mutable copy of all currently active + * (in scope) fetch groups. + * The methods {@link #addFetchGroups}, {@link #removeFetchGroups}, + * {@link #getFetchGroups}, and {@link #removeAllFetchGroups} + * are internally serialized. + * @return a copy of all currently active fetch groups + * @throws SecurityException if the caller is not authorized for + * {@link JDOPermission} ("getMetadata") + * @since 2.2 + */ + Set getFetchGroups(); + + /** + * Method to register metadata with the persistence process managed by this + * PersistenceManagerFactory. + * Metadata can be created using the method {@link #newMetadata}. + * If there is already metadata registered for a class contained in this metadata + * object then a JDOUserException will be thrown. + * @param metadata The Metadata to register. + * @since 3.0 + */ + void registerMetadata(JDOMetadata metadata); + + /** + * Method to return a new metadata object that can be subsequently modified + * and registered with the persistence process using the method {@link #registerMetadata}. + * @return The metadata + * @since 3.0 + */ + JDOMetadata newMetadata(); + + /** + * Method to return the metadata object for the specified class/interface, if there is + * metadata defined for that class/interface. + * If there is no metadata for the specified class/interface, or the parameter is null, + * then null will be returned. + * @param className Name of the class to get metadata for + * @return The metadata + * @since 3.0 + */ + TypeMetadata getMetadata(String className); + + /** + * Method to return the currently managed classes for this factory. + * @return Collection of persistable classes that are managed by this factory + * @since 3.1 + */ + Collection getManagedClasses(); } diff --git a/api/src/main/java/javax/jdo/Query.java b/api/src/main/java/javax/jdo/Query.java index 13a3f81d5..2d3750e66 100644 --- a/api/src/main/java/javax/jdo/Query.java +++ b/api/src/main/java/javax/jdo/Query.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -27,1076 +27,1021 @@ import java.util.Map; /** - * The Query interface allows applications to obtain persistent instances, values, and - * aggregate data from the data store. - * - *

    The {@link PersistenceManager} is the factory for Query instances. There may be - * many Query instances associated with a PersistenceManager. Multiple - * queries might be executed simultaneously by different threads, but the implementation might - * choose to execute them serially. In either case, the implementation must be thread-safe. + * The Query interface allows applications to obtain persistent + * instances, values, and aggregate data from the data store. * - *

    There are three required elements in a Query: the class of the results, the - * candidate collection of instances, and the filter. + * The {@link PersistenceManager} is the factory for Query + * instances. There may be many Query instances associated with a + * PersistenceManager. Multiple queries might be executed + * simultaneously by different threads, but the implementation might choose to + * execute them serially. In either case, the implementation must be thread-safe. * - *

    There are optional elements: parameter declarations, variable declarations, import statements, - * ordering and grouping specifications, result and result class, the range of results, and flags - * indicating whether the query result is unique and whether the query can be modified. - * - *

    The query namespace is modeled after methods in Java: + *

    There are three required elements in a Query: the class of + * the results, the candidate collection of instances, and the filter. * + *

    There are optional elements: parameter declarations, variable + * declarations, import statements, ordering and grouping specifications, + * result and result class, the range of results, + * and flags indicating whether the query result + * is unique and whether the query can be modified. + *

    The query namespace is modeled after methods in Java: *

      - *
    • setClass corresponds to the class definition - *
    • declareParameters corresponds to formal parameters of a method - *
    • declareVariables corresponds to local variables of a method - *
    • setFilter and setOrdering correspond to the method body + *
    • setClass corresponds to the class definition + *
    • declareParameters corresponds to formal parameters of a method + *
    • declareVariables corresponds to local variables of a method + *
    • setFilter and setOrdering correspond to the method body *
    - * - *

    There are two namespaces in queries. Type names have their own namespace that is separate from - * the namespace for fields, variables and parameters. - * - *

    The method setClass introduces the name of the candidate class in the type - * namespace. The method declareImports introduces the names of the imported class or - * interface types in the type namespace. Imported type names must be unique. When used (e.g. in a - * parameter declaration, cast expression, etc.) a type name must be the name of the candidate - * class, the name of a class or interface imported by method declareImports, or denote - * a class or interface from the same package as the candidate class. - * - *

    The method setClass introduces the names of the candidate class fields. - * - *

    The method declareParameters introduces the names of the parameters. A name - * introduced by declareParameters hides the name of a candidate class field of the - * same name. Parameter names must be unique. - * - *

    The method declareVariables introduces the names of the variables. A name - * introduced by declareVariables hides the name of a candidate class field if equal. - * Variable names must be unique and must not conflict with parameter names. - * - *

    The result of the query by default is a list of result class instances, but might be specified - * via setResult. The class of the result by default is the candidate class, but might - * be specified via setResultClass. - * - *

    A hidden field may be accessed using the 'this' qualifier: this.fieldName. - * - *

    The Query interface provides methods which execute the query based on the - * parameters given. They return a single instance or a List of result class instances - * which the user can iterate to get results. The signature of the execute methods - * specifies that they return an Object which must be cast to the appropriate result by - * the user. - * - *

    Any parameters passed to the execute methods are used only for this execution, - * and are not remembered for future execution. - * + *

    There are two namespaces in queries. Type names have their own namespace + * that is separate from the namespace for fields, variables and parameters. + *

    The method setClass introduces the name of the candidate + * class in the type namespace. The method declareImports + * introduces the names of the imported class or interface types in the type + * namespace. Imported type names must be unique. When used (e.g. in a parameter + * declaration, cast expression, etc.) a type name must be the name of the + * candidate class, the name of a class or interface imported by method + * declareImports, or denote a class or interface from the same + * package as the candidate class. + *

    The method setClass introduces the names of the candidate + * class fields. + *

    The method declareParameters introduces the names of the + * parameters. A name introduced by declareParameters hides the + * name of a candidate class field of the same name. Parameter names must be + * unique. + *

    The method declareVariables introduces the names of the + * variables. A name introduced by declareVariables hides the name + * of a candidate class field if equal. Variable names must be unique and must + * not conflict with parameter names. + *

    The result of the query by default is a list of result class instances, + * but might be specified via setResult. The class of the result + * by default is the candidate class, but might be specified via setResultClass. + *

    A hidden field may be accessed using the 'this' qualifier: this.fieldName. + *

    The Query interface provides methods which execute the query + * based on the parameters given. They return a single instance or a + * List of result class instances which the + * user can iterate to get results. The signature + * of the execute methods specifies that they return an + * Object which must be cast to the appropriate result by the user. + *

    Any parameters passed to the execute methods are used only + * for this execution, and are not remembered for future execution. * @version 2.1 + * * @param T Candidate class for the query */ public interface Query extends AutoCloseable, Serializable { - /** - * The string constant used as the first argument to {@link - * PersistenceManager#newQuery(String,Object)} to identify that the created query should obey the - * JDOQL syntax and semantic rules. - * - *

    This is the default query language used when creating a query with any of the other {@link - * PersistenceManager#newQuery} methods, except {@link PersistenceManager#newQuery(Object)}, which - * uses the query language of the compiled query template object passed to that method. - * - * @since 2.0 - */ - String JDOQL = "javax.jdo.query.JDOQL"; - - /** - * The string constant used as the first argument to {@link - * PersistenceManager#newQuery(String,Object)} to identify that the created query should use SQL - * semantics. This is only meaningful for relational JDO implementations. - * - *

    If this is used, the Object argument to the {@link - * PersistenceManager#newQuery(String,Object)} method should be a String containing a - * SQL SELECT statement. - * - * @since 2.0 - */ - String SQL = "javax.jdo.query.SQL"; - - /** - * Set the class of the candidate instances of the query. - * - *

    The class specifies the class of the candidates of the query. Elements of the candidate - * collection that are of the specified class are filtered before being put into the result - * Collection. - * - * @param cls the Class of the candidate instances. - */ - void setClass(Class cls); - - /** - * Set the candidate Extent to query. - * - * @param pcs the candidate Extent. - */ - void setCandidates(Extent pcs); - - /** - * Set the candidate Collection to query. - * - * @param pcs the candidate Collection. - */ - void setCandidates(Collection pcs); - - /** - * Set the filter for the query. - * - *

    The filter specification is a String containing a Boolean expression that is to - * be evaluated for each of the instances in the candidate collection. If the filter is not - * specified, then it defaults to "true", which has the effect of filtering the input - * Collection only for class type. - * - *

    An element of the candidate collection is returned in the result if: - * - *

      - *
    • it is assignment compatible to the candidate Class of the Query - * ; and - *
    • for all variables there exists a value for which the filter expression evaluates to - * true. - *
    - * - *

    The user may denote uniqueness in the filter expression by explicitly declaring an - * expression (for example, e1 != e2). - * - *

    Rules for constructing valid expressions follow the Java language, except for these - * differences: - * - *

      - *
    • Equality and ordering comparisons between primitives and instances of wrapper classes are - * valid. - *
    • Equality and ordering comparisons of Date fields and Date - * parameters are valid. - *
    • White space (non-printing characters space, tab, carriage return, and line feed) is a - * separator and is otherwise ignored. - *
    • The assignment operators =, +=, etc. and pre- and - * post-increment and -decrement are not supported. Therefore, there are no side effects - * from evaluation of any expressions. - *
    • Methods, including object construction, are not supported, except for - * Collection.contains(Object o), Collection.isEmpty(), - * String.startsWith(String s), and String.endsWith(String e). - * Implementations might choose to support non-mutating method calls as non-standard - * extensions. - *
    • Navigation through a null-valued field, which would throw - * NullPointerException, is treated as if the filter expression returned false - * for the evaluation of the current set of variable values. Other values for - * variables might still qualify the candidate instance for inclusion in the result set. - *
    • Navigation through multi-valued fields (Collection types) is specified using - * a variable declaration and the Collection.contains(Object o) method. - *
    - * - *

    Identifiers in the expression are considered to be in the name space of the specified class, - * with the addition of declared imports, parameters and variables. As in the Java language, - * this is a reserved word which means the element of the collection being evaluated. - * - *

    Navigation through single-valued fields is specified by the Java language syntax of - * field_name.field_name....field_name. - * - *

    A JDO implementation is allowed to reorder the filter expression for optimization purposes. - * - * @param filter the query filter. - */ - void setFilter(String filter); - - /** - * Set the import statements to be used to identify the fully qualified name of variables or - * parameters. Parameters and unbound variables might come from a different class from the - * candidate class, and the names need to be declared in an import statement to eliminate - * ambiguity. Import statements are specified as a String with semicolon-separated - * statements. - * - *

    The String parameter to this method follows the syntax of the import statement - * of the Java language. - * - * @param imports import statements separated by semicolons. - */ - void declareImports(String imports); - - /** - * Declare the list of parameters query execution. - * - *

    The parameter declaration is a String containing one or more query parameter - * declarations separated with commas. Each parameter named in the parameter declaration must be - * bound to a value when the query is executed. - * - *

    The String parameter to this method follows the syntax for formal parameters in - * the Java language. - * - * @param parameters the list of parameters separated by commas. - */ - void declareParameters(String parameters); - - /** - * Declare the unbound variables to be used in the query. Variables might be used in the filter, - * and these variables must be declared with their type. The unbound variable declaration is a - * String containing one or more unbound variable declarations separated with - * semicolons. It follows the syntax for local variables in the Java language. - * - * @param variables the variables separated by semicolons. - */ - void declareVariables(String variables); - - /** - * Set the ordering specification for the result Collection. The ordering - * specification is a String containing one or more ordering declarations separated - * by commas. - * - *

    Each ordering declaration is the name of the field on which to order the results followed by - * one of the following words: "ascending" or "descending". - * - *

    The field must be declared in the candidate class or must be a navigation expression - * starting with a field in the candidate class. - * - *

    Valid field types are primitive types except boolean; wrapper types except - * Boolean; BigDecimal; BigInteger; String; - * and Date. - * - * @param ordering the ordering specification. - */ - void setOrdering(String ordering); - - /** - * Set the ignoreCache option. The default value for this option was set by the - * PersistenceManagerFactory or the PersistenceManager used to create this - * Query. - * - *

    The ignoreCache option setting specifies whether the query should execute entirely in the - * back end, instead of in the cache. If this flag is set to true, an implementation - * might be able to optimize the query execution by ignoring changed values in the cache. For - * optimistic transactions, this can dramatically improve query response times. - * - * @param ignoreCache the setting of the ignoreCache option. - */ - void setIgnoreCache(boolean ignoreCache); - - /** - * Get the ignoreCache option setting. - * - * @return the ignoreCache option setting. - * @see #setIgnoreCache - */ - boolean getIgnoreCache(); - - /** - * Verify the elements of the query and provide a hint to the query to prepare and optimize an - * execution plan. - */ - void compile(); - - /** - * Execute the query and return the filtered Collection. - * - *

    Cancellation of the query using cancel() will result in JDOQueryInterruptedException being - * thrown here - * - * @return the filtered Collection. - * @see #executeWithArray(Object[] parameters) - */ - Object execute(); - - /** - * Execute the query and return the filtered Collection. - * - *

    Cancellation of the query using cancel() will result in JDOQueryInterruptedException being - * thrown here - * - * @return the filtered Collection. - * @see #executeWithArray(Object[] parameters) - * @param p1 the value of the first parameter declared. - */ - Object execute(Object p1); - - /** - * Execute the query and return the filtered Collection. - * - *

    Cancellation of the query using cancel() will result in JDOQueryInterruptedException being - * thrown here - * - * @return the filtered Collection. - * @see #executeWithArray(Object[] parameters) - * @param p1 the value of the first parameter declared. - * @param p2 the value of the second parameter declared. - */ - Object execute(Object p1, Object p2); - - /** - * Execute the query and return the filtered Collection. - * - *

    Cancellation of the query using cancel() will result in JDOQueryInterruptedException being - * thrown here - * - * @return the filtered Collection. - * @see #executeWithArray(Object[] parameters) - * @param p1 the value of the first parameter declared. - * @param p2 the value of the second parameter declared. - * @param p3 the value of the third parameter declared. - */ - Object execute(Object p1, Object p2, Object p3); - - /** - * Execute the query and return the filtered Collection. The query is executed with - * the parameters set by the Map values. Each Map entry consists of a - * key which is the name of the parameter in the declareParameters method, and a - * value which is the value used in the execute method. The keys in the Map - * and the declared parameters must exactly match or a JDOUserException is - * thrown. - * - *

    Cancellation of the query using cancel() will result in JDOQueryInterruptedException being - * thrown here - * - * @return the filtered Collection. - * @see #executeWithArray(Object[] parameters) - * @param parameters the Map containing all of the parameters. - */ - Object executeWithMap(Map parameters); - - /** - * Execute the query and return the filtered Collection. - * - *

    The execution of the query obtains the values of the parameters and matches them against the - * declared parameters in order. The names of the declared parameters are ignored. The type of the - * declared parameters must match the type of the passed parameters, except that the passed - * parameters might need to be unwrapped to get their primitive values. - * - *

    The filter, import, declared parameters, declared variables, and ordering statements are - * verified for consistency. - * - *

    Each element in the candidate Collection is examined to see that it is - * assignment compatible to the Class of the query. It is then evaluated by the - * Boolean expression of the filter. The element passes the filter if there exist unique values - * for all variables for which the filter expression evaluates to true. - * - *

    Cancellation of the query using cancel() will result in JDOQueryInterruptedException being - * thrown here - * - * @return the filtered Collection. - * @param parameters the Object array with all of the parameters. - */ - Object executeWithArray(Object... parameters); - - /** - * Get the PersistenceManager associated with this Query. - * - *

    If this Query was restored from a serialized form, it has no - * PersistenceManager, and this method returns null. - * - * @return the PersistenceManager associated with this Query. - */ - PersistenceManager getPersistenceManager(); - - /** - * Close a query result and release any resources associated with it. The parameter is the return - * from execute(...) and might have iterators open on it. Iterators associated with - * the query result are invalidated: they return false to hasNext() and - * throw NoSuchElementException to next(). - * - * @param queryResult the result of execute(...) on this Query instance. - */ - void close(Object queryResult); - - /** - * Close all query results associated with this Query instance, and release all - * resources associated with them. The query results might have iterators open on them. Iterators - * associated with the query results are invalidated: they return false to - * hasNext() and throw NoSuchElementException to next(). - */ - void closeAll(); - - /** - * Don't use this method directly; use closeAll() instead. It is intended for use - * with try-with-resources. - * - * @throws Exception if this resource cannot be closed - */ - void close() throws Exception; - - /** - * Set the grouping expressions, optionally including a "having" clause. When grouping is - * specified, each result expression must either be an expression contained in the grouping, or an - * aggregate evaluated once per group. - * - * @param group a comma-delimited list of expressions, optionally followed by the "having" keyword - * and a boolean expression - * @since 2.0 - */ - void setGrouping(String group); - - /** - * Specify that only the first result of the query should be returned, rather than a collection. - * The execute method will return null if the query result size is 0. - * - * @since 2.0 - * @param unique if true, only one element is returned - */ - void setUnique(boolean unique); - - /** - * Specifies what type of data this query should return. If this is unset or set to null - * , this query returns instances of the query's candidate class. If set, this query will - * return expressions, including field values (projections) and aggregate function results. - * - * @param data a comma-delimited list of expressions (fields, functions on fields, or aggregate - * functions) to return from this query - * @since 2.0 - */ - void setResult(String data); - - /** - * Specify the type of object in which to return each element of the result of invoking {@link - * #execute} or one of its siblings. If the result is not set or set to null, the result class - * defaults to the candidate class of the query. If the result consists of one expression, the - * result class defaults to the type of that expression. If the result consists of more than one - * expression, the result class defaults to Object[]. The result class may be specified to be one - * of the java.lang classes Character, Boolean, Byte, Short, Integer, Long, Float, Double, String, - * or Object[]; or one of the java.math classes BigInteger or BigDecimal; or the java.util class - * Date; or one of the java.sql classes Date, Time, or Timestamp; or a user-defined class. - * - *

    If there are multiple result expressions, the result class must be able to hold all elements - * of the result specification or a JDOUserException is thrown. - * - *

    If there is only one result expression, the result class must be assignable from the type of - * the result expression or must be able to hold all elements of the result specification. A - * single value must be able to be coerced into the specified result class (treating wrapper - * classes as equivalent to their unwrapped primitive types) or by matching. If the result class - * does not satisfy these conditions, a JDOUserException is thrown. - * - *

    A constructor of a result class specified in the setResult method will be used if the - * results specification matches the parameters of the constructor by position and type. If more - * than one constructor satisfies the requirements, the JDO implementation chooses one of them. If - * no constructor satisfies the results requirements, or if the result class is specified via the - * setResultClass method, the following requirements apply: - * - *

      - *
    • A user-defined result class must have a no-args constructor and one or more public - * set or put methods or fields. - *
    • Each result expression must match one of: - *
        - *
      • a public field that matches the name of the result expression and is of the type - * (treating wrapper types equivalent to primitive types) of the result expression; - *
      • or if no public field matches the name and type, a public set method - * that returns void and matches the name of the result expression and takes a single - * parameter which is the exact type of the result expression; - *
      • or if neither of the above applies,a public method must be found with the signature - * void put(Object, Object). During processing of the results, the first - * argument is the name of the result expression and the second argument is the value - * from the query result. - *
      - *
    - * - * Portable result classes do not invoke any persistence behavior during their no-args constructor - * or set methods. - * - * @param cls the result class - * @since 2.0 - */ - void setResultClass(Class cls); - - /** - * Set the range of results to return. The execution of the query is modified to return only a - * subset of results. If the filter would normally return 100 instances, and fromIncl is set to - * 50, and toExcl is set to 70, then the first 50 results that would have been returned are - * skipped, the next 20 results are returned and the remaining 30 results are ignored. An - * implementation should execute the query such that the range algorithm is done at the data - * store. - * - * @param fromIncl 0-based inclusive start index - * @param toExcl 0-based exclusive end index, or {@link Long#MAX_VALUE} for no limit. - * @since 2.0 - */ - void setRange(long fromIncl, long toExcl); - - /** - * Set the range of results to return. The parameter is a String containing a comma-separated - * fromIncl and toExcl. The fromIncl and toExcl can be either String representations of long - * values, or can be parameters identified with a leading ":". For example, - * setRange("50, 70"); or setRange(":from, :to"); or - * setRange("50, :to");. The execution of the query is modified to return only a subset of - * results. If the filter would normally return 100 instances, and fromIncl is set to 50, and - * toExcl is set to 70, then the first 50 results that would have been returned are skipped, the - * next 20 results are returned and the remaining 30 results are ignored. An implementation should - * execute the query such that the range algorithm is done at the data store. - * - * @param fromInclToExcl comma-separated fromIncl and toExcl values - * @see #setRange(long, long) - * @since 2.0 - */ - void setRange(String fromInclToExcl); - - /** - * Add a vendor-specific extension to this query. The key and value are not standard. An - * implementation must ignore keys that are not recognized. - * - * @param key the key of the extension - * @param value the value of the extension - * @since 2.0 - */ - void addExtension(String key, Object value); - - /** - * Set multiple extensions, or use null to clear all extensions. Map keys and values are not - * standard. An implementation must ignore entries that are not recognized. - * - * @param extensions the map of extensions - * @see #addExtension - * @since 2.0 - */ - void setExtensions(Map extensions); - - /** - * Returns the FetchPlan used by this Query. Modifications of the - * returned fetch plan will not cause this query's owning PersistenceManager's - * FetchPlan to be modified. - * - * @since 2.0 - * @return the fetch plan used by this query - */ - FetchPlan getFetchPlan(); - - /** - * Deletes all the instances of the candidate class that pass the filter. - * - * @see #deletePersistentAll() - * @param parameters for the query - * @return the number of instances of the candidate class that were deleted - * @since 2.0 - */ - long deletePersistentAll(Object... parameters); - - /** - * Deletes all the instances of the candidate class that pass the filter. - * - * @see #deletePersistentAll() - * @param parameters for the query - * @return the number of instances of the candidate class that were deleted - * @since 2.0 - */ - long deletePersistentAll(Map parameters); - - /** - * Deletes all the instances of the candidate class that pass the filter. Returns the number of - * instances of the candidate class that were deleted, specifically not including the number of - * dependent and embedded instances. - * - *

    Dirty instances of affected classes in the cache are first flushed to the datastore. - * Instances in the cache or brought into the cache as a result of executing one of the - * deletePersistentAll methods undergo life cycle changes as if deletePersistent - * were called on them. - * - *

    Specifically, if the class of deleted instances implements the delete callback interface, - * the corresponding callback methods are called on the deleted instances. Similarly, if there are - * lifecycle listeners registered for delete events on affected classes, the listener is called - * for each appropriate deleted instance. - * - *

    Before returning control to the application, instances of affected classes in the cache are - * refreshed to reflect whether they were deleted from the datastore. - * - * @return the number of instances of the candidate class that were deleted - * @since 2.0 - */ - long deletePersistentAll(); - - /** - * The unmodifiable flag, when set, disallows further modification of the query, except for - * specifying the range, result class, and ignoreCache option. The unmodifiable flag can also be - * set in metadata. - * - * @since 2.0 - */ - void setUnmodifiable(); - - /** - * The unmodifiable flag, when set, disallows further modification of the query, except for - * specifying the range, result class, and ignoreCache option. - * - * @return the current setting of the flag - * @since 2.0 - */ - boolean isUnmodifiable(); - - /** - * Add a subquery to this query. - * - * @param sub the subquery to add to this Query - * @param variableDeclaration the name of the variable in the outer query to bind the results of - * the subquery - * @param candidateCollectionExpression the candidate collection of the subquery as an expression - * using terms of the outer query - * @see #addSubquery(Query sub, String variableDeclaration, String candidateCollectionExpression, - * String... parameters) - * @since 2.1 - */ - void addSubquery(Query sub, String variableDeclaration, String candidateCollectionExpression); - - /** - * Add a subquery to this query. The String version of the method binds the named expression to - * the parameter implictly or explicitly declared in the subquery. - * - * @param sub the subquery to add to this Query - * @param variableDeclaration the name of the variable to be used in this Query - * @param candidateCollectionExpression the candidate collection to apply to the subquery - * @param parameter the expression from the outer query to bind the parameter in the subquery - * @see #addSubquery(Query sub, String variableDeclaration, String candidateCollectionExpression, - * String... parameters) - * @since 2.1 - */ - void addSubquery( - Query sub, - String variableDeclaration, - String candidateCollectionExpression, - String parameter); - - /** - * Add a subquery to this query. A subquery is composed as a Query and subsequently attached to a - * different query (the outer query) by calling this method. The query parameter instance is - * unmodified as a result of the addSubquery or subsequent execution of the outer query. Only some - * of the query parts are copied for use as the subquery. The parts copied include the candidate - * class, filter, parameter declarations, variable declarations, imports, ordering specification, - * uniqueness, result specification, and grouping specification. The association with a - * PersistenceManager, the candidate collection or extent, result class, and range limits are not - * used. The String parameters are trimmed of white space. The variableDeclaration parameter is - * the name of the variable containing the results of the subquery execution. If the same value of - * variableDeclaration is used to add multiple subqueries, the subquery replaces the previous - * subquery for the same named variable. If the subquery parameter is null, the variable is unset, - * effectively making the variable named in the variableDeclaration unbound. If the trimmed value - * is the empty String, or the parameter is null, then JDOUserException is thrown. The - * candidateCollectionExpression is the expression from the outer query that represents the - * candidates over which the subquery is evaluated. If the trimmed value is the empty String, or - * the parameter is null, then the candidate collection is the extent of the candidate class. The - * String... version of the method binds the named expressions in turn to parameters in the order - * in which they are declared in the subquery, or in the order they are found in the filter if not - * explicitly declared in the subquery. - * - * @param sub the subquery to add to this Query - * @param variableDeclaration the name of the variable in the outer query to bind the results of - * the subquery - * @param candidateCollectionExpression the candidate collection of the subquery as an expression - * using terms of the outer query - * @param parameters the expressions from the outer query to bind the parameters in the subquery - * @since 2.1 - */ - void addSubquery( - Query sub, - String variableDeclaration, - String candidateCollectionExpression, - String... parameters); - - /** - * Add a subquery to this query. The Map version of the method treats the key of each map entry as - * the name of the parameter in the subquery, with or without the leading ":", and the value as - * the name of the expression in the outer query. If the trimmed expression is the empty String - * for either the parameter or the value of the String[], or for any map key or value, that - * expression is ignored. - * - * @param sub the subquery to add to this Query - * @param variableDeclaration the name of the variable to be used in this Query - * @param candidateCollectionExpression the candidate collection to apply to the subquery - * @param parameters the expressions from the outer query to bind the parameter in the subquery - * @see #addSubquery(Query sub, String variableDeclaration, String candidateCollectionExpression, - * String... parameters) - * @since 2.1 - */ - void addSubquery( - Query sub, String variableDeclaration, String candidateCollectionExpression, Map parameters); - - /** - * Specify a timeout interval (milliseconds) for any read operations associated with this query. - * To unset the explicit timeout for this query, specify null. For no timeout, specify 0. If the - * datastore granularity is larger than milliseconds, the timeout value will be rounded up to the - * nearest supported datastore value. If a read operation hasn't completed within this interval, - * executeXXX will throw a JDODatastoreException. If multiple datastore operations are required to - * complete the query, the timeout value applies to each of them individually. If the datastore - * and JDO implementation support timeouts, then javax.jdo.option.DatastoreTimeout is returned by - * PersistenceManagerFactory.supportedOptions(). If timeouts are not supported,this method will - * throw JDOUnsupportedOptionException. - * - * @since 3.0 - * @param interval the timeout interval (milliseconds) - */ - void setDatastoreReadTimeoutMillis(Integer interval); - - /** - * Get the effective timeout setting for read operations. If the timeout has not been set on this - * query explicitly, the effective datastore read timeout value from the persistence manager is - * returned. - * - * @see #setDatastoreReadTimeoutMillis(Integer) - * @see PersistenceManager#setDatastoreReadTimeoutMillis(Integer) - * @return the effective timeout setting (milliseconds). - * @since 3.0 - */ - Integer getDatastoreReadTimeoutMillis(); - - /** - * Specify a timeout interval (milliseconds) for any write operations associated with this query. - * To unset the explicit timeout for this query, specify null. For no timeout, specify 0. If the - * datastore granularity is larger than milliseconds, the timeout value will be rounded up to the - * nearest supported datastore value. If a write operation hasn't completed within this interval, - * deleteXXX will throw a JDODatastoreException. If multiple datastore operations are required to - * complete the query, the timeout value applies to each of them individually. If the datastore - * and JDO implementation support timeouts, then javax.jdo.option.DatastoreTimeout is returned by - * PersistenceManagerFactory.supportedOptions(). If timeouts are not supported,this method will - * throw JDOUnsupportedOptionException. - * - * @since 3.0 - * @param interval the timeout interval (milliseconds) - */ - void setDatastoreWriteTimeoutMillis(Integer interval); - - /** - * Get the effective timeout setting for write operations. If the timeout has not been set on this - * query explicitly, the effective datastore write timeout value from the persistence manager is - * returned. - * - * @see #setDatastoreWriteTimeoutMillis(Integer) - * @see PersistenceManager#setDatastoreWriteTimeoutMillis(Integer) - * @return the effective timeout setting (milliseconds). - * @since 3.0 - */ - Integer getDatastoreWriteTimeoutMillis(); - - /** - * Method to cancel any executing queries. If the underlying datastore doesn't support - * cancellation of queries this will throw JDOUnsupportedOptionException. If the cancellation - * fails (e.g in the underlying datastore) then this will throw a JDOException. - * - * @since 3.0 - */ - void cancelAll(); - - /** - * Method to cancel an executing query in the specified thread. If the underlying datastore - * doesn't support cancellation of queries this will throw JDOUnsupportedOptionException. If the - * cancellation fails (e.g in the underlying datastore) then this will throw a JDOException. - * - * @param thread The thread to cancel - * @since 3.0 - */ - void cancel(Thread thread); - - /** - * If true, a lock will be applied to all objects read in this query. - * - *

    If false then retrieved objects will not be locked. If null will fallback to - * the value for metadata for the class in question. - * - * @param serialize the value of the serializeRead property - * @since 3.0 - */ - void setSerializeRead(Boolean serialize); - - /** - * Return the current value of the serializeRead property. - * - * @return the value of the serializeRead property - * @since 3.0 - */ - Boolean getSerializeRead(); - - /** - * Save the query, as it is currently defined, as a named query under the specified name. If a - * named query already exists under this name (either defined in metadata, or previously saved) - * then it will be overwritten. - * - * @param name Name to save it under. - * @return This query - */ - Query saveAsNamedQuery(String name); - - /** - * Set the filter for the query. Shortcut for the {@link #setFilter(String)} method - * - * @param filter the query filter. - * @return This query - */ - Query filter(String filter); - - /** - * Set the ordering specification for the result Collection. Shortcut for the {@link - * #setOrdering(String)} method - * - * @param ordering the ordering specification. - * @return This query - */ - Query orderBy(String ordering); - - /** - * Set the grouping expressions, optionally including a "having" clause. Shortcut for the {@link - * #setGrouping(String)} method - * - * @param group a comma-delimited list of expressions, optionally followed by the "having" keyword - * and a boolean expression - * @return This query - */ - Query groupBy(String group); - - /** - * Set the result clause for the query. Shortcut for the {@link #setResult(String)} method - * - * @param result The result clause - * @return This query - */ - Query result(String result); - - /** - * Set the range of results to return. Shortcut for the {@link #setRange(long, long)} method - * - * @param fromIncl 0-based inclusive start index - * @param toExcl 0-based exclusive end index, or {@link Long#MAX_VALUE} for no limit. - * @return This query - */ - Query range(long fromIncl, long toExcl); - - /** - * Set the range of results to return. Shortcut for the {@link #setRange(String)} method - * - * @param fromInclToExcl comma-separated fromIncl and toExcl values - * @return This query - */ - Query range(String fromInclToExcl); - - /** - * Add a subquery to this query. Shortcut for the {@link #subquery(Query, String, String)} method - * - * @param sub the subquery to add to this Query - * @param variableDeclaration the name of the variable in the outer query to bind the results of - * the subquery - * @param candidateCollectionExpression the candidate collection of the subquery as an expression - * using terms of the outer query - * @return This query - */ - Query subquery(Query sub, String variableDeclaration, String candidateCollectionExpression); - - /** - * Add a subquery to this query. Shortcut for the {@link #subquery(Query, String, String, String)} - * method - * - * @param sub the subquery to add to this Query - * @param variableDeclaration the name of the variable to be used in this Query - * @param candidateCollectionExpression the candidate collection to apply to the subquery - * @param parameter the expression from the outer query to bind the parameter in the subquery - * @return This query - */ - Query subquery( - Query sub, - String variableDeclaration, - String candidateCollectionExpression, - String parameter); - - /** - * Add a subquery to this query. Shortcut for the {@link #subquery(Query, String, String, - * String...)} method - * - * @param sub the subquery to add to this Query - * @param variableDeclaration the name of the variable in the outer query to bind the results of - * the subquery - * @param candidateCollectionExpression the candidate collection of the subquery as an expression - * using terms of the outer query - * @param parameters the expressions from the outer query to bind the parameters in the subquery - * @return This query - */ - Query subquery( - Query sub, - String variableDeclaration, - String candidateCollectionExpression, - String... parameters); - - /** - * Add a subquery to this query. Shortcut for the {@link #subquery(Query, String, String, Map)} - * method - * - * @param sub the subquery to add to this Query - * @param variableDeclaration the name of the variable to be used in this Query - * @param candidateCollectionExpression the candidate collection to apply to the subquery - * @param parameters the expressions from the outer query to bind the parameter in the subquery - * @return This query - */ - Query subquery( - Query sub, String variableDeclaration, String candidateCollectionExpression, Map parameters); - - /** - * Set the import statements to be used to identify the fully qualified name of variables or - * parameters. Shortcut for {@link #declareImports(String)} method. - * - * @param imports the imports declaration - * @return This query - */ - Query imports(String imports); - - /** - * Declare the list of parameters for query execution. Shortcut for {@link - * #declareParameters(String)} method. - * - * @param parameters the list of parameters separated by commas. - * @return This query - */ - Query parameters(String parameters); - - /** - * Declare the unbound variables to be used in the query. Shortcut for {@link - * #declareVariables(String)} method. - * - * @param variables the variables separated by semicolons. - * @return This query - */ - Query variables(String variables); - - /** - * Set the datastore read timeout (millis). Shortcut for {@link - * #setDatastoreReadTimeoutMillis(Integer)} method. - * - * @param interval The interval - * @return This query - */ - Query datastoreReadTimeoutMillis(Integer interval); - - /** - * Set the datastore write timeout (millis). Shortcut for {@link - * #setDatastoreWriteTimeoutMillis(Integer)} method. - * - * @param interval The interval - * @return This query - */ - Query datastoreWriteTimeoutMillis(Integer interval); - - /** - * Set whether we to lock all objects read by this query. Shortcut for {@link - * #setSerializeRead(Boolean)} method. - * - * @param serialize Whether to lock - * @return This query - */ - Query serializeRead(Boolean serialize); - - /** - * Set whether to make this query unmodifiable. Shortcut for {@link #setUnmodifiable()} method. - * - * @return This query - */ - Query unmodifiable(); - - /** - * Set whether we to ignore the cache with this query. Shortcut for {@link - * #setIgnoreCache(boolean)} method. - * - * @param flag Whether to ignore the cache - * @return This query - */ - Query ignoreCache(boolean flag); - - /** - * Specify an extension for this query. Shortcut for {@link #addExtension(String, Object)} method. - * - * @param key The extension key - * @param value The extension value - * @return This query - */ - Query extension(String key, Object value); - - /** - * Specify a map of extensions for this query. Shortcut for {@link #setExtensions(Map)} method. - * - * @param values The extension map of keys and values - * @return This query - */ - Query extensions(Map values); - - /** - * Method to set the named parameters on this query prior to execution. If using the execute - * methods taking parameters then those parameter values will override these values. All parameter - * values specified in this method will only be retained until the subsequent query execution. - * - * @param namedParamMap The map of parameter values keyed by their names. - * @return This query - */ - Query setNamedParameters(Map namedParamMap); - - /** - * Method to set the values of the numbered parameters on this query prior to execution. If using - * the execute methods taking parameters then those parameter values will override these values. - * All parameter values specified in this method will only be retained until the subsequent query - * execution. - * - * @param paramValues Values of the numbered parameters, in order. - * @return This query - */ - Query setParameters(Object... paramValues); - - /** - * Method to execute the query where there are (potentially) multiple rows and we are returning - * the candidate type. Any parameters required should be set prior to calling this method, using - * one of the setParameters methods. - * - *

    Calling this method with a result being specified will result in JDOUserException being - * thrown. - * - * @return The List of candidate objects - */ - List executeList(); - - /** - * Method to execute the query where there is a single row and we are returning the candidate - * type. Any parameters required should be set prior to calling this method, using one of the - * setParameters methods. - * - *

    Calling this method with a result being specified will result in JDOUserException being - * thrown. - * - * @return The candidate object returned by the query (or null) - */ - T executeUnique(); - - /** - * Method to execute the query where there are (potentially) multiple rows and we are returning a - * result type for the specified result. Any parameters required should be set prior to calling - * this method, using one of the setParameters methods. - * - *

    Calling this method with no result being specified will result in JDOUserException being - * thrown. - * - * @param resultCls The result class - * @return List of result objects - * @param The result type - */ - List executeResultList(Class resultCls); - - /** - * Method to execute the query where there is a single row and we are returning a result type for - * the specified result. Any parameters required should be set prior to calling this method, using - * one of the setParameters methods. - * - *

    Calling this method with no result being specified will result in JDOUserException being - * thrown. - * - * @param resultCls The result class - * @return The result object (or null) - * @param The result type - */ - R executeResultUnique(Class resultCls); - - /** - * Method to execute the query where there are (potentially) multiple rows and we have a result - * defined but no result class. Any parameters required should be set prior to calling this - * method, using one of the setParameters methods. - * - *

    Calling this method with no result being specified will result in JDOUserException being - * thrown. - * - * @return The list of query results - */ - List executeResultList(); - - /** - * Method to execute the query where there is a single row and we have a result defined but no - * result class. Any parameters required should be set prior to calling this method, using one of - * the setParameters methods. - * - *

    Calling this method with no result being specified will result in JDOUserException being - * thrown. - * - * @return The query result (or null) - */ - Object executeResultUnique(); + /** + * The string constant used as the first argument to + * {@link PersistenceManager#newQuery(String,Object)} to identify that the + * created query should obey the JDOQL syntax and semantic rules. + *

    This is the default query language used when creating a query with any + * of the other {@link PersistenceManager#newQuery} methods, except + * {@link PersistenceManager#newQuery(Object)}, which uses the query + * language of the compiled query template object passed to that method.

    + * @since 2.0 + */ + String JDOQL = "javax.jdo.query.JDOQL"; + + /** + * The string constant used as the first argument to {@link + * PersistenceManager#newQuery(String,Object)} to identify that + * the created query should use SQL semantics. This is only + * meaningful for relational JDO implementations. + *

    If this is used, the Object argument to the + * {@link PersistenceManager#newQuery(String,Object)} method + * should be a String containing a SQL + * SELECT statement.

    + * @since 2.0 + */ + String SQL = "javax.jdo.query.SQL"; + + /** + * Set the class of the candidate instances of the query. + *

    The class specifies the class + * of the candidates of the query. Elements of the candidate collection + * that are of the specified class are filtered before being + * put into the result Collection. + * + * @param cls the Class of the candidate instances. + */ + void setClass(Class cls); + + /** + * Set the candidate Extent to query. + * @param pcs the candidate Extent. + */ + void setCandidates(Extent pcs); + + /** + * Set the candidate Collection to query. + * @param pcs the candidate Collection. + */ + void setCandidates(Collection pcs); + + /** + * Set the filter for the query. + *

    The filter specification is a String containing a Boolean + * expression that is to be evaluated for each of the instances + * in the candidate collection. If the filter is not specified, + * then it defaults to "true", which has the effect of filtering + * the input Collection only for class type. + *

    An element of the candidate collection is returned in the result if: + *

    • it is assignment compatible to the candidate Class + * of the Query; and + *
    • for all variables there exists a value for which the filter + * expression evaluates to true. + *
    + *

    The user may denote uniqueness in the filter expression by + * explicitly declaring an expression (for example, e1 != e2). + *

    Rules for constructing valid expressions follow the Java + * language, except for these differences: + *

      + *
    • Equality and ordering comparisons between primitives and instances + * of wrapper classes are valid. + *
    • Equality and ordering comparisons of Date fields and + * Date parameters are valid. + *
    • White space (non-printing characters space, tab, carriage + * return, and line feed) is a separator and is otherwise ignored. + *
    • The assignment operators =, +=, etc. and + * pre- and post-increment and -decrement are not supported. Therefore, + * there are no side effects from evaluation of any expressions. + *
    • Methods, including object construction, are not supported, except + * for Collection.contains(Object o), + * Collection.isEmpty(), + * String.startsWith(String s), and + * String.endsWith(String e). Implementations might choose to + * support non-mutating method calls as non-standard extensions. + *
    • Navigation through a null-valued field, which would + * throw NullPointerException, is treated as if the filter + * expression returned false for the evaluation of the current + * set of variable values. Other values for variables might still qualify + * the candidate instance for inclusion in the result set. + *
    • Navigation through multi-valued fields (Collection + * types) is specified using a variable declaration and the + * Collection.contains(Object o) method. + *
    + *

    Identifiers in the expression are considered to be in the name + * space of the specified class, with the addition of declared imports, + * parameters and variables. As in the Java language, this is a + * reserved word which means the element of the collection being evaluated. + *

    Navigation through single-valued fields is specified by the Java + * language syntax of field_name.field_name....field_name. + *

    A JDO implementation is allowed to reorder the filter expression + * for optimization purposes. + * @param filter the query filter. + */ + void setFilter(String filter); + + /** Set the import statements to be used to identify the fully qualified + * name of variables or parameters. Parameters and unbound variables might + * come from a different class from the candidate class, and the names + * need to be declared in an import statement to eliminate ambiguity. + * Import statements are specified as a String with + * semicolon-separated statements. + *

    The String parameter to this method follows the syntax of + * the import statement of the Java language. + * @param imports import statements separated by semicolons. + */ + void declareImports(String imports); + + /** Declare the list of parameters query execution. + * + * The parameter declaration is a String containing one or more + * query parameter declarations separated with commas. Each parameter named + * in the parameter declaration must be bound to a value when + * the query is executed. + *

    The String parameter to this method follows the syntax + * for formal parameters in the Java language. + * @param parameters the list of parameters separated by commas. + */ + void declareParameters(String parameters); + + /** Declare the unbound variables to be used in the query. Variables + * might be used in the filter, and these variables must be declared + * with their type. The unbound variable declaration is a + * String containing one or more unbound variable declarations + * separated with semicolons. It follows the syntax for local variables in + * the Java language. + * @param variables the variables separated by semicolons. + */ + void declareVariables(String variables); + + /** Set the ordering specification for the result Collection. + * The ordering specification is a String containing one or + * more ordering declarations separated by commas. + * + *

    Each ordering declaration is the name of the field on which + * to order the results followed by one of the following words: + * "ascending" or "descending". + * + *

    The field must be declared in the candidate class or must be + * a navigation expression starting with a field in the candidate class. + * + *

    Valid field types are primitive types except boolean; + * wrapper types except Boolean; BigDecimal; + * BigInteger; String; and Date. + * @param ordering the ordering specification. + */ + void setOrdering(String ordering); + + /** Set the ignoreCache option. The default value for this option was + * set by the PersistenceManagerFactory or the + * PersistenceManager used to create this Query. + * + * The ignoreCache option setting specifies whether the query should execute + * entirely in the back end, instead of in the cache. If this flag is set + * to true, an implementation might be able to optimize the + * query execution by ignoring changed values in the cache. For optimistic + * transactions, this can dramatically improve query response times. + * @param ignoreCache the setting of the ignoreCache option. + */ + void setIgnoreCache(boolean ignoreCache); + + /** Get the ignoreCache option setting. + * @return the ignoreCache option setting. + * @see #setIgnoreCache + */ + boolean getIgnoreCache(); + + /** Verify the elements of the query and provide a hint to the query to + * prepare and optimize an execution plan. + */ + void compile(); + + /** Execute the query and return the filtered Collection. + *

    Cancellation of the query using cancel() will result in JDOQueryInterruptedException + * being thrown here + * @return the filtered Collection. + * @see #executeWithArray(Object[] parameters) + */ + Object execute(); + + /** Execute the query and return the filtered Collection. + *

    Cancellation of the query using cancel() will result in JDOQueryInterruptedException + * being thrown here + * @return the filtered Collection. + * @see #executeWithArray(Object[] parameters) + * @param p1 the value of the first parameter declared. + */ + Object execute(Object p1); + + /** Execute the query and return the filtered Collection. + *

    Cancellation of the query using cancel() will result in JDOQueryInterruptedException + * being thrown here + * @return the filtered Collection. + * @see #executeWithArray(Object[] parameters) + * @param p1 the value of the first parameter declared. + * @param p2 the value of the second parameter declared. + */ + Object execute(Object p1, Object p2); + + /** Execute the query and return the filtered Collection. + *

    Cancellation of the query using cancel() will result in JDOQueryInterruptedException + * being thrown here + * @return the filtered Collection. + * @see #executeWithArray(Object[] parameters) + * @param p1 the value of the first parameter declared. + * @param p2 the value of the second parameter declared. + * @param p3 the value of the third parameter declared. + */ + Object execute(Object p1, Object p2, Object p3); + + /** Execute the query and return the filtered Collection. The + * query is executed with the parameters set by the Map values. + * Each Map entry consists of a key which is the name of the + * parameter in the declareParameters method, and a value which + * is the value used in the execute method. The keys in the + * Map and the declared parameters must exactly match or a + * JDOUserException is thrown. + *

    Cancellation of the query using cancel() will result in JDOQueryInterruptedException + * being thrown here + * @return the filtered Collection. + * @see #executeWithArray(Object[] parameters) + * @param parameters the Map containing all of the parameters. + */ + Object executeWithMap (Map parameters); + + /** Execute the query and return the filtered Collection. + * + *

    The execution of the query obtains the values of the parameters and + * matches them against the declared parameters in order. The names + * of the declared parameters are ignored. The type of + * the declared parameters must match the type of the passed parameters, + * except that the passed parameters might need to be unwrapped to get + * their primitive values. + * + *

    The filter, import, declared parameters, declared variables, and + * ordering statements are verified for consistency. + * + *

    Each element in the candidate Collection is examined to + * see that it is assignment compatible to the Class of the + * query. It is then evaluated by the Boolean expression of the filter. + * The element passes the filter if there exist unique values for all + * variables for which the filter expression evaluates to true. + *

    Cancellation of the query using cancel() will result in JDOQueryInterruptedException being thrown here + * @return the filtered Collection. + * @param parameters the Object array with all of the parameters. + */ + Object executeWithArray (Object... parameters); + + /** Get the PersistenceManager associated with this + * Query. + * + *

    If this Query was restored from a serialized form, it has + * no PersistenceManager, and this method returns + * null. + * @return the PersistenceManager associated with this + * Query. + */ + PersistenceManager getPersistenceManager(); + + /** Close a query result and release any resources associated with it. The + * parameter is the return from execute(...) and might have + * iterators open on it. Iterators associated with the query result are + * invalidated: they return false to hasNext() + * and throw NoSuchElementException to next(). + * @param queryResult the result of execute(...) on this + * Query instance. + */ + void close(Object queryResult); + + /** Close all query results associated with this Query + * instance, and release all resources associated with them. The query + * results might have iterators open on them. Iterators associated with the + * query results are invalidated: + * they return false to hasNext() and throw + * NoSuchElementException to next(). + */ + void closeAll(); + + /** + * Don't use this method directly; use closeAll() instead. It is intended for use with try-with-resources. + * @throws Exception if this resource cannot be closed + */ + void close() throws Exception; + + /** + * Set the grouping expressions, optionally including a "having" + * clause. When grouping is specified, each result expression + * must either be an expression contained in the grouping, or an + * aggregate evaluated once per group. + * + * @param group a comma-delimited list of expressions, optionally + * followed by the "having" keyword and a boolean expression + * @since 2.0 + */ + void setGrouping(String group); + + /** + * Specify that only the first result of the query should be + * returned, rather than a collection. The execute method will + * return null if the query result size is 0. + * @since 2.0 + * @param unique if true, only one element is returned + */ + void setUnique(boolean unique); + + /** + * Specifies what type of data this query should return. If this + * is unset or set to null, this query returns + * instances of the query's candidate class. If set, this query + * will return expressions, including field values (projections) and + * aggregate function results. + * @param data a comma-delimited list of expressions + * (fields, functions on fields, or aggregate functions) + * to return from this query + * @since 2.0 + */ + void setResult(String data); + + /** + * Specify the type of object in which to return each element of + * the result of invoking {@link #execute} or one of its siblings. + * If the result is not set or set to null, the result class defaults + * to the candidate class of the query. If the result consists of one + * expression, the result class defaults to the type of that expression. + * If the result consists of more than one expression, the result class + * defaults to Object[]. + * The result class may be specified to be one of the java.lang classes + * Character, Boolean, Byte, Short, Integer, Long, Float, Double, String, + * or Object[]; or one of the java.math classes BigInteger or BigDecimal; + * or the java.util class Date; or one of the java.sql classes Date, + * Time, or Timestamp; or a user-defined class. + *

    If there are multiple result expressions, the result class + * must be able to hold all elements of the result specification + * or a JDOUserException is thrown. + *

    If there is only one result expression, the result class must be + * assignable from the type of the result expression or must be able + * to hold all elements of the result specification. A single value + * must be able to be coerced into the specified result class + * (treating wrapper classes as equivalent to their unwrapped + * primitive types) or by matching. If the result class does not satisfy + * these conditions, a JDOUserException is thrown. + *

    A constructor of a result class specified in the setResult method + * will be used if the results specification matches the parameters + * of the constructor by position and type. If more than one constructor + * satisfies the requirements, the JDO implementation chooses one of them. + * If no constructor satisfies the results requirements, or if the result + * class is specified via the setResultClass method, the following + * requirements apply: + *

      + *
    • A user-defined result class must have a no-args constructor and + * one or more public set or put methods or + * fields. + *
    • Each result expression must match one of: + *
        + *
      • a public field that matches the name of the result expression + * and is of the type (treating wrapper types equivalent to primitive + * types) of the result expression; + *
      • or if no public field matches the name and type, a public + * set method that returns void and matches the name of the + * result expression and takes a single parameter which is the + * exact type of the result expression; + *
      • or if neither of the above applies,a public method must be found + * with the signature void put(Object, Object). + * During processing of the results, + * the first argument is the name of the result expression and + * the second argument is the value from the query result. + *
      + *
    + * Portable result classes do not invoke any persistence behavior + * during their no-args constructor or set methods. + * @param cls the result class + * @since 2.0 + */ + void setResultClass(Class cls); + + /** + * Set the range of results to return. The execution of the query is + * modified to return only a subset of results. If the filter would + * normally return 100 instances, and fromIncl is set to 50, and + * toExcl is set to 70, then the first 50 results that would have + * been returned are skipped, the next 20 results are returned and the + * remaining 30 results are ignored. An implementation should execute + * the query such that the range algorithm is done at the data store. + * @param fromIncl 0-based inclusive start index + * @param toExcl 0-based exclusive end index, or + * {@link Long#MAX_VALUE} for no limit. + * @since 2.0 + */ + void setRange(long fromIncl, long toExcl); + + /** + * Set the range of results to return. The parameter is a String + * containing a comma-separated fromIncl and toExcl. The fromIncl and + * toExcl can be either String representations of long values, or can + * be parameters identified with a leading ":". For example, + * setRange("50, 70"); or + * setRange(":from, :to"); or + * setRange("50, :to");. + * The execution of the query is + * modified to return only a subset of results. If the filter would + * normally return 100 instances, and fromIncl is set to 50, and + * toExcl is set to 70, then the first 50 results that would have + * been returned are skipped, the next 20 results are returned and the + * remaining 30 results are ignored. An implementation should execute + * the query such that the range algorithm is done at the data store. + * @param fromInclToExcl comma-separated fromIncl and toExcl values + * @see #setRange(long, long) + * @since 2.0 + */ + void setRange(String fromInclToExcl); + + /** + * Add a vendor-specific extension to this query. The key and value + * are not standard. + * An implementation must ignore keys that are not recognized. + * @param key the key of the extension + * @param value the value of the extension + * @since 2.0 + */ + void addExtension(String key, Object value); + + /** + * Set multiple extensions, or use null to clear all extensions. + * Map keys and values are not standard. + * An implementation must ignore entries that are not recognized. + * @param extensions the map of extensions + * @see #addExtension + * @since 2.0 + */ + void setExtensions(Map extensions); + + /** + * Returns the FetchPlan used by this + * Query. Modifications of the returned fetch plan will not + * cause this query's owning PersistenceManager's + * FetchPlan to be modified. + * @since 2.0 + * @return the fetch plan used by this query + */ + FetchPlan getFetchPlan(); + + /** + * Deletes all the instances of the candidate class that pass the + * filter. + * @see #deletePersistentAll() + * @param parameters for the query + * @return the number of instances of the candidate class that were deleted + * @since 2.0 + */ + long deletePersistentAll(Object... parameters); + + /** + * Deletes all the instances of the candidate class that pass the + * filter. + * @see #deletePersistentAll() + * @param parameters for the query + * @return the number of instances of the candidate class that were deleted + * @since 2.0 + */ + long deletePersistentAll(Map parameters); + + /** + * Deletes all the instances of the candidate class that pass the + * filter. Returns the number of instances of the candidate + * class that were deleted, specifically not including the number + * of dependent and embedded instances. + *

    Dirty instances of affected classes in the cache are first + * flushed to the datastore. Instances in the cache or brought into + * the cache as a result of executing one of the + * deletePersistentAll + * methods undergo life cycle changes as if deletePersistent + * were called on them. + *

    Specifically, if the class of deleted instances implements the + * delete callback interface, the corresponding callback methods + * are called on the deleted instances. Similarly, if there are + * lifecycle listeners registered for delete events on affected + * classes, the listener is called for each appropriate deleted instance. + *

    Before returning control to the application, instances of affected + * classes in the cache are refreshed to reflect whether they were + * deleted from the datastore. + * + * @return the number of instances of the candidate class that were deleted + * @since 2.0 + */ + long deletePersistentAll(); + + /** + * The unmodifiable flag, when set, disallows further + * modification of the query, except for specifying the range, + * result class, and ignoreCache option. + * The unmodifiable flag can also be set in metadata. + * @since 2.0 + */ + void setUnmodifiable(); + + /** + * The unmodifiable flag, when set, disallows further + * modification of the query, except for specifying the range, + * result class, and ignoreCache option. + * @return the current setting of the flag + * @since 2.0 + */ + boolean isUnmodifiable(); + + /** + * Add a subquery to this query. + * @param sub the subquery to add to this Query + * @param variableDeclaration the name of the variable in the outer query + * to bind the results of the subquery + * @param candidateCollectionExpression the candidate collection + * of the subquery as an expression using terms of the outer query + * @see #addSubquery(Query sub, String variableDeclaration, + * String candidateCollectionExpression, String... parameters) + * @since 2.1 + */ + void addSubquery(Query sub, String variableDeclaration, String candidateCollectionExpression); + + /** + * Add a subquery to this query. + * The String version of the method binds the named expression + * to the parameter implictly or explicitly declared in the + * subquery. + * @param sub the subquery to add to this Query + * @param variableDeclaration the name of the variable + * to be used in this Query + * @param candidateCollectionExpression the candidate collection + * to apply to the subquery + * @param parameter the expression from the outer query to bind + * the parameter in the subquery + * @see #addSubquery(Query sub, String variableDeclaration, + * String candidateCollectionExpression, String... parameters) + * @since 2.1 + */ + void addSubquery(Query sub, String variableDeclaration, String candidateCollectionExpression, String parameter); + + /** + * Add a subquery to this query. + * A subquery is composed as a Query and subsequently attached + * to a different query (the outer query) by calling this method. + * The query parameter instance is unmodified as a result of the + * addSubquery or subsequent execution of the outer query. + * Only some of the query parts are copied for use as the subquery. + * The parts copied include the candidate class, filter, parameter + * declarations, variable declarations, imports, ordering specification, + * uniqueness, result specification, and grouping specification. + * The association with a PersistenceManager, the candidate collection + * or extent, result class, and range limits are not used. + * The String parameters are trimmed of white space. + * The variableDeclaration parameter is the name of the variable + * containing the results of the subquery execution. If the same value + * of variableDeclaration is used to add multiple subqueries, the + * subquery replaces the previous subquery for the same named variable. + * If the subquery parameter is null, the variable is unset, + * effectively making the variable named in the variableDeclaration + * unbound. If the trimmed value is the empty String, or the parameter + * is null, then JDOUserException is thrown. + * The candidateCollectionExpression is the expression from the + * outer query that represents the candidates over which the subquery + * is evaluated. If the trimmed value is the empty String, or the + * parameter is null, then the candidate collection is the extent + * of the candidate class. + * The String... version of the method binds the named expressions in + * turn to parameters in the order in which they are declared in the + * subquery, or in the order they are found in the filter if not + * explicitly declared in the subquery. + * @param sub the subquery to add to this Query + * @param variableDeclaration the name of the variable in the outer query + * to bind the results of the subquery + * @param candidateCollectionExpression the candidate collection + * of the subquery as an expression using terms of the outer query + * @param parameters the expressions from the outer query to bind + * the parameters in the subquery + * @since 2.1 + */ + void addSubquery(Query sub, String variableDeclaration, + String candidateCollectionExpression, String... parameters); + + /** + * Add a subquery to this query. + * The Map version of the method treats the key of each map entry as + * the name of the parameter in the subquery, with or without the + * leading ":", and the value as the name of the expression in the + * outer query. If the trimmed expression is the empty String for + * either the parameter or the value of the String[], or for any + * map key or value, that expression is ignored. + * @param sub the subquery to add to this Query + * @param variableDeclaration the name of the variable + * to be used in this Query + * @param candidateCollectionExpression the candidate collection + * to apply to the subquery + * @param parameters the expressions from the outer query to bind + * the parameter in the subquery + * @see #addSubquery(Query sub, String variableDeclaration, + * String candidateCollectionExpression, String... parameters) + * @since 2.1 + */ + void addSubquery(Query sub, String variableDeclaration, + String candidateCollectionExpression, Map parameters); + + /** + * Specify a timeout interval (milliseconds) for any read operations + * associated with this query. To unset the explicit timeout for this + * query, specify null. For no timeout, specify 0. + * If the datastore granularity is larger than milliseconds, the + * timeout value will be rounded up to the nearest supported datastore + * value. + * If a read operation hasn't completed within this interval, executeXXX + * will throw a JDODatastoreException. + * If multiple datastore operations are required to complete the query, + * the timeout value applies to each of them individually. + * If the datastore and JDO implementation support timeouts, then + * javax.jdo.option.DatastoreTimeout is returned by + * PersistenceManagerFactory.supportedOptions(). + * If timeouts are not supported,this method will throw + * JDOUnsupportedOptionException. + * @since 3.0 + * @param interval the timeout interval (milliseconds) + */ + void setDatastoreReadTimeoutMillis(Integer interval); + + /** Get the effective timeout setting for read operations. + * If the timeout has not been set on this query explicitly, the effective + * datastore read timeout value from the persistence manager is returned. + * @see #setDatastoreReadTimeoutMillis(Integer) + * @see PersistenceManager#setDatastoreReadTimeoutMillis(Integer) + * @return the effective timeout setting (milliseconds). + * @since 3.0 + */ + Integer getDatastoreReadTimeoutMillis(); + + /** + * Specify a timeout interval (milliseconds) for any write operations + * associated with this query. To unset the explicit timeout for this + * query, specify null. For no timeout, specify 0. + * If the datastore granularity is larger than milliseconds, the + * timeout value will be rounded up to the nearest supported datastore + * value. + * If a write operation hasn't completed within this interval, deleteXXX + * will throw a JDODatastoreException. + * If multiple datastore operations are required to complete the query, + * the timeout value applies to each of them individually. + * If the datastore and JDO implementation support timeouts, then + * javax.jdo.option.DatastoreTimeout is returned by + * PersistenceManagerFactory.supportedOptions(). + * If timeouts are not supported,this method will throw + * JDOUnsupportedOptionException. + * @since 3.0 + * @param interval the timeout interval (milliseconds) + */ + void setDatastoreWriteTimeoutMillis(Integer interval); + + /** Get the effective timeout setting for write operations. + * If the timeout has not been set on this query explicitly, the effective + * datastore write timeout value from the persistence manager is returned. + * @see #setDatastoreWriteTimeoutMillis(Integer) + * @see PersistenceManager#setDatastoreWriteTimeoutMillis(Integer) + * @return the effective timeout setting (milliseconds). + * @since 3.0 + */ + Integer getDatastoreWriteTimeoutMillis(); + + /** + * Method to cancel any executing queries. + * If the underlying datastore doesn't support cancellation of queries this will + * throw JDOUnsupportedOptionException. + * If the cancellation fails (e.g in the underlying datastore) then this will throw + * a JDOException. + * @since 3.0 + */ + void cancelAll(); + + /** + * Method to cancel an executing query in the specified thread. + * If the underlying datastore doesn't support cancellation of queries this will + * throw JDOUnsupportedOptionException. + * If the cancellation fails (e.g in the underlying datastore) then this will throw + * a JDOException. + * @param thread The thread to cancel + * @since 3.0 + */ + void cancel(Thread thread); + + /** + * If true, a lock will be applied to all objects read in this + * query. + *

    If false then retrieved objects will not be locked. + * If null will fallback to the value for metadata for the class in question. + * @param serialize the value of the serializeRead property + * @since 3.0 + */ + void setSerializeRead(Boolean serialize); + + /** + * Return the current value of the serializeRead property. + * @return the value of the serializeRead property + * @since 3.0 + */ + Boolean getSerializeRead(); + + /** + * Save the query, as it is currently defined, as a named query under the specified name. + * If a named query already exists under this name (either defined in metadata, or previously saved) + * then it will be overwritten. + * @param name Name to save it under. + * @return This query + */ + Query saveAsNamedQuery(String name); + + /** + * Set the filter for the query. + * Shortcut for the {@link #setFilter(String)} method + * @param filter the query filter. + * @return This query + */ + Query filter(String filter); + + /** + * Set the ordering specification for the result Collection. + * Shortcut for the {@link #setOrdering(String)} method + * @param ordering the ordering specification. + * @return This query + */ + Query orderBy(String ordering); + + /** + * Set the grouping expressions, optionally including a "having" clause. + * Shortcut for the {@link #setGrouping(String)} method + * @param group a comma-delimited list of expressions, optionally followed by the "having" keyword and a boolean expression + * @return This query + */ + Query groupBy(String group); + + /** + * Set the result clause for the query. + * Shortcut for the {@link #setResult(String)} method + * @param result The result clause + * @return This query + */ + Query result(String result); + + /** + * Set the range of results to return. + * Shortcut for the {@link #setRange(long, long)} method + * @param fromIncl 0-based inclusive start index + * @param toExcl 0-based exclusive end index, or {@link Long#MAX_VALUE} for no limit. + * @return This query + */ + Query range(long fromIncl, long toExcl); + + /** + * Set the range of results to return. + * Shortcut for the {@link #setRange(String)} method + * @param fromInclToExcl comma-separated fromIncl and toExcl values + * @return This query + */ + Query range(String fromInclToExcl); + + /** + * Add a subquery to this query. + * Shortcut for the {@link #subquery(Query, String, String)} method + * @param sub the subquery to add to this Query + * @param variableDeclaration the name of the variable in the outer query to bind the results of the subquery + * @param candidateCollectionExpression the candidate collection of the subquery as an expression using terms of the outer query + * @return This query + */ + Query subquery(Query sub, String variableDeclaration, String candidateCollectionExpression); + + /** + * Add a subquery to this query. + * Shortcut for the {@link #subquery(Query, String, String, String)} method + * @param sub the subquery to add to this Query + * @param variableDeclaration the name of the variable to be used in this Query + * @param candidateCollectionExpression the candidate collection to apply to the subquery + * @param parameter the expression from the outer query to bind the parameter in the subquery + * @return This query + */ + Query subquery(Query sub, String variableDeclaration, String candidateCollectionExpression, String parameter); + + /** + * Add a subquery to this query. + * Shortcut for the {@link #subquery(Query, String, String, String...)} method + * @param sub the subquery to add to this Query + * @param variableDeclaration the name of the variable in the outer query to bind the results of the subquery + * @param candidateCollectionExpression the candidate collection of the subquery as an expression using terms of the outer query + * @param parameters the expressions from the outer query to bind the parameters in the subquery + * @return This query + */ + Query subquery(Query sub, String variableDeclaration, String candidateCollectionExpression, String... parameters); + + /** + * Add a subquery to this query. + * Shortcut for the {@link #subquery(Query, String, String, Map)} method + * @param sub the subquery to add to this Query + * @param variableDeclaration the name of the variable to be used in this Query + * @param candidateCollectionExpression the candidate collection to apply to the subquery + * @param parameters the expressions from the outer query to bind the parameter in the subquery + * @return This query + */ + Query subquery(Query sub, String variableDeclaration, String candidateCollectionExpression, Map parameters); + + /** + * Set the import statements to be used to identify the fully qualified name of variables or parameters. + * Shortcut for {@link #declareImports(String)} method. + * @param imports the imports declaration + * @return This query + */ + Query imports(String imports); + + /** + * Declare the list of parameters for query execution. + * Shortcut for {@link #declareParameters(String)} method. + * @param parameters the list of parameters separated by commas. + * @return This query + */ + Query parameters(String parameters); + + /** + * Declare the unbound variables to be used in the query. + * Shortcut for {@link #declareVariables(String)} method. + * @param variables the variables separated by semicolons. + * @return This query + */ + Query variables(String variables); + + /** + * Set the datastore read timeout (millis). + * Shortcut for {@link #setDatastoreReadTimeoutMillis(Integer)} method. + * @param interval The interval + * @return This query + */ + Query datastoreReadTimeoutMillis(Integer interval); + + /** + * Set the datastore write timeout (millis). + * Shortcut for {@link #setDatastoreWriteTimeoutMillis(Integer)} method. + * @param interval The interval + * @return This query + */ + Query datastoreWriteTimeoutMillis(Integer interval); + + /** + * Set whether we to lock all objects read by this query. + * Shortcut for {@link #setSerializeRead(Boolean)} method. + * @param serialize Whether to lock + * @return This query + */ + Query serializeRead(Boolean serialize); + + /** + * Set whether to make this query unmodifiable. + * Shortcut for {@link #setUnmodifiable()} method. + * @return This query + */ + Query unmodifiable(); + + /** + * Set whether we to ignore the cache with this query. + * Shortcut for {@link #setIgnoreCache(boolean)} method. + * @param flag Whether to ignore the cache + * @return This query + */ + Query ignoreCache(boolean flag); + + /** + * Specify an extension for this query. + * Shortcut for {@link #addExtension(String, Object)} method. + * @param key The extension key + * @param value The extension value + * @return This query + */ + Query extension(String key, Object value); + + /** + * Specify a map of extensions for this query. + * Shortcut for {@link #setExtensions(Map)} method. + * @param values The extension map of keys and values + * @return This query + */ + Query extensions(Map values); + + /** + * Method to set the named parameters on this query prior to execution. + * If using the execute methods taking parameters then those parameter values will override these values. + * All parameter values specified in this method will only be retained until the subsequent query execution. + * @param namedParamMap The map of parameter values keyed by their names. + * @return This query + */ + Query setNamedParameters(Map namedParamMap); + + /** + * Method to set the values of the numbered parameters on this query prior to execution. + * If using the execute methods taking parameters then those parameter values will override these values. + * All parameter values specified in this method will only be retained until the subsequent query execution. + * @param paramValues Values of the numbered parameters, in order. + * @return This query + */ + Query setParameters(Object... paramValues); + + /** + * Method to execute the query where there are (potentially) multiple rows and we are returning the candidate type. + * Any parameters required should be set prior to calling this method, using one of the setParameters methods. + *

    Calling this method with a result being specified will result in JDOUserException being thrown. + * @return The List of candidate objects + */ + List executeList(); + + /** + * Method to execute the query where there is a single row and we are returning the candidate type. + * Any parameters required should be set prior to calling this method, using one of the setParameters methods. + *

    Calling this method with a result being specified will result in JDOUserException being thrown. + * @return The candidate object returned by the query (or null) + */ + T executeUnique(); + + /** + * Method to execute the query where there are (potentially) multiple rows and we are returning a result type for the specified result. + * Any parameters required should be set prior to calling this method, using one of the setParameters methods. + *

    Calling this method with no result being specified will result in JDOUserException being thrown. + * @param resultCls The result class + * @return List of result objects + * @param The result type + */ + List executeResultList(Class resultCls); + + /** + * Method to execute the query where there is a single row and we are returning a result type for the specified result. + * Any parameters required should be set prior to calling this method, using one of the setParameters methods. + *

    Calling this method with no result being specified will result in JDOUserException being thrown. + * @param resultCls The result class + * @return The result object (or null) + * @param The result type + */ + R executeResultUnique(Class resultCls); + + /** + * Method to execute the query where there are (potentially) multiple rows and we have a result defined but no result class. + * Any parameters required should be set prior to calling this method, using one of the setParameters methods. + *

    Calling this method with no result being specified will result in JDOUserException being thrown. + * @return The list of query results + */ + List executeResultList(); + + /** + * Method to execute the query where there is a single row and we have a result defined but no result class. + * Any parameters required should be set prior to calling this method, using one of the setParameters methods. + *

    Calling this method with no result being specified will result in JDOUserException being thrown. + * @return The query result (or null) + */ + Object executeResultUnique(); } diff --git a/api/src/main/java/javax/jdo/Transaction.java b/api/src/main/java/javax/jdo/Transaction.java index 0482ce779..656633b0f 100644 --- a/api/src/main/java/javax/jdo/Transaction.java +++ b/api/src/main/java/javax/jdo/Transaction.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,255 +19,230 @@ * Transaction.java * */ - + package javax.jdo; - import javax.transaction.Synchronization; -/** - * The JDO Transaction interface provides for initiation and completion of transactions - * under user control. It is a sub-interface of the {@link PersistenceManager} that deals with - * options and transaction demarcation. - * - *

    Transaction options include whether optimistic concurrency control should be used for the - * current transaction, whether instances may hold values in the cache outside transactions, and - * whether values should be retained in the cache after transaction completion. These options are - * valid for both managed and non-managed transactions. - * - *

    Transaction initiation and completion methods have similar semantics to - * javax.transaction.UserTransaction when used outside a managed environment. When used in a - * managed environment, transaction initiation and completion methods may only be used with - * bean-managed transaction semantics. +/** The JDO Transaction interface provides for initiation and + * completion of transactions under user control. + * It is a sub-interface of the {@link PersistenceManager} + * that deals with options and transaction demarcation. + *

    Transaction options include whether optimistic concurrency + * control should be used for the current transaction, whether instances + * may hold values in the cache outside transactions, and whether + * values should be retained in the cache after transaction completion. These + * options are valid for both managed and non-managed transactions. * + *

    Transaction initiation and completion methods have similar semantics to + * javax.transaction.UserTransaction when used outside a managed + * environment. When used in a managed environment, transaction initiation + * and completion methods may only be used with bean-managed transaction + * semantics. * @version 3.0 */ -public interface Transaction { - /** - * Begin a transaction. The type of transaction is determined by the setting of the Optimistic - * flag. - * - * @see #setOptimistic - * @see #getOptimistic - * @throws JDOUserException if transactions are managed by a container in the managed environment, - * or if the transaction is already active. - */ - void begin(); - - /** - * Commit the current transaction. - * - * @throws JDOUserException if transactions are managed by a container in the managed environment, - * or if the transaction is not active. - */ - void commit(); - - /** - * Roll back the current transaction. - * - * @throws JDOUserException if transactions are managed by a container in the managed environment, - * or if the transaction is not active. - */ - void rollback(); - - /** - * Returns whether there is a transaction currently active. - * - * @return true if the transaction is active. - */ - boolean isActive(); - - /** - * Returns the rollback-only status of the transaction. When begun, the rollback-only status is - * false. Either the application or the JDO implementation may set this flag using - * setRollbackOnly. - * - * @return true if the transaction has been marked for rollback. - * @since 2.0 - */ - boolean getRollbackOnly(); - - /** - * Sets the rollback-only status of the transaction to true. After this flag is set - * to true, the transaction can no longer be committed, and any attempt to commit the - * transaction will throw JDOFatalDataStoreException. - * - * @since 2.0 - */ - void setRollbackOnly(); - - /** - * If true, allow persistent instances to be read without a transaction active. If an - * implementation does not support this option, a JDOUnsupportedOptionException is - * thrown. - * - * @param nontransactionalRead the value of the nontransactionalRead property - */ - void setNontransactionalRead(boolean nontransactionalRead); - - /** - * If true, allows persistent instances to be read without a transaction active. - * - * @return the value of the nontransactionalRead property - */ - boolean getNontransactionalRead(); - - /** - * If true, allow persistent instances to be written without a transaction active. If - * an implementation does not support this option, a JDOUnsupportedOptionException is - * thrown. - * - * @param nontransactionalWrite the value of the nontransactionalRead property - */ - void setNontransactionalWrite(boolean nontransactionalWrite); - - /** - * If true, allows persistent instances to be written without a transaction active. - * - * @return the value of the nontransactionalWrite property - */ - boolean getNontransactionalWrite(); - - /** - * If true, at commit instances retain their values and the instances transition to - * persistent-nontransactional. If an implementation does not support this option, a - * JDOUnsupportedOptionException is thrown. - * - * @param retainValues the value of the retainValues property - */ - void setRetainValues(boolean retainValues); - - /** - * If true, at commit time instances retain their field values. - * - * @return the value of the retainValues property - */ - boolean getRetainValues(); - - /** - * If true, at rollback, fields of newly persistent instances are restored to their - * values as of the beginning of the transaction, and the instances revert to transient. - * Additionally, fields of modified instances of primitive types and immutable reference types are - * restored to their values as of the beginning of the transaction. - * - *

    If false, at rollback, the values of fields of newly persistent instances are - * unchanged and the instances revert to transient. Additionally, dirty instances transition to - * hollow. If an implementation does not support this option, a - * JDOUnsupportedOptionException is thrown. - * - * @param restoreValues the value of the restoreValues property - */ - void setRestoreValues(boolean restoreValues); - - /** - * Return the current value of the restoreValues property. - * - * @return the value of the restoreValues property - */ - boolean getRestoreValues(); - - /** - * Optimistic transactions do not hold data store locks until commit time. If an implementation - * does not support this option, a JDOUnsupportedOptionException is thrown. - * - * @param optimistic the value of the Optimistic flag. - */ - void setOptimistic(boolean optimistic); - - /** - * Optimistic transactions do not hold data store locks until commit time. - * - * @return the value of the Optimistic property. - */ - boolean getOptimistic(); - - /** - * Get the value for transaction isolation level for this transaction. - * - * @return the transaction isolation level - * @see #setIsolationLevel(String) - * @since 2.2 - */ - String getIsolationLevel(); - - /** - * Set the value for transaction isolation level for this transaction. Transaction isolation - * levels are defined in javax.jdo.Constants. If the requested level is not available, but a - * higher level is available, the higher level is silently used. If the requested level is not - * available, and no higher level is available, then JDOUnsupportedOptionException is thrown. Five - * standard isolation levels are defined. Other isolation levels might be supported by an - * implementation but are not standard. - * - *

    Standard values in order of low to high are: - * - *

      - *
    • read-uncommitted - *
    • read-committed - *
    • repeatable-read - *
    • snapshot - *
    • serializable - *
    - * - * @param level the transaction isolation level - * @see #getIsolationLevel() - * @see Constants#TX_READ_UNCOMMITTED - * @see Constants#TX_READ_COMMITTED - * @see Constants#TX_REPEATABLE_READ - * @see Constants#TX_SNAPSHOT - * @see Constants#TX_SERIALIZABLE - * @since 2.2 - */ - void setIsolationLevel(String level); - - /** - * The user can specify a Synchronization instance to be notified on transaction - * completions. The beforeCompletion method is called prior to flushing instances to - * the data store. - * - *

    The afterCompletion method is called after performing state transitions of - * persistent and transactional instances, following the data store commit or rollback operation. - * - *

    Only one Synchronization instance can be registered with the Transaction - * . If the application requires more than one instance to receive synchronization - * callbacks, then the single application instance is responsible for managing them, and - * forwarding callbacks to them. - * - * @param sync the Synchronization instance to be notified; null for - * none - */ - void setSynchronization(Synchronization sync); - - /** - * The user-specified Synchronization instance for this Transaction - * instance. - * - * @return the user-specified Synchronization instance. - */ - Synchronization getSynchronization(); - - /** - * The Transaction instance is always associated with exactly one - * PersistenceManager. - * - * @return the PersistenceManager for this Transaction instance - */ - PersistenceManager getPersistenceManager(); - - /** - * If true, a lock will be applied to all objects read in this transaction. - * - *

    If false then retrieved objects will not be locked. If null will fallback to - * the value for metadata for the class in question. - * - * @param serialize the value of the serializeRead property - * @since 3.0 - */ - void setSerializeRead(Boolean serialize); - - /** - * Return the current value of the serializeRead property. - * - * @return the value of the serializeRead property - * @since 3.0 - */ - Boolean getSerializeRead(); +public interface Transaction +{ + /** Begin a transaction. The type of transaction is determined by the + * setting of the Optimistic flag. + * @see #setOptimistic + * @see #getOptimistic + * @throws JDOUserException if transactions are managed by a container + * in the managed environment, or if the transaction is already active. + */ + void begin(); + + /** Commit the current transaction. + * @throws JDOUserException if transactions are managed by a container + * in the managed environment, or if the transaction is not active. + */ + void commit(); + + /** Roll back the current transaction. + * @throws JDOUserException if transactions are managed by a container + * in the managed environment, or if the transaction is not active. + */ + void rollback(); + + /** Returns whether there is a transaction currently active. + * @return true if the transaction is active. + */ + boolean isActive(); + + /** + * Returns the rollback-only status of the transaction. When + * begun, the rollback-only status is false. Either the + * application or the JDO implementation may set this flag + * using setRollbackOnly. + * @return true if the transaction has been + * marked for rollback. + * @since 2.0 + */ + boolean getRollbackOnly(); + + /** + * Sets the rollback-only status of the transaction to true. + * After this flag is set to true, the transaction + * can no longer be committed, and any attempt to commit the + * transaction will throw JDOFatalDataStoreException. + * @since 2.0 + */ + void setRollbackOnly(); + + /** If true, allow persistent instances to be read without + * a transaction active. + * If an implementation does not support this option, a + * JDOUnsupportedOptionException is thrown. + * @param nontransactionalRead the value of the nontransactionalRead + * property + */ + void setNontransactionalRead (boolean nontransactionalRead); + + /** If true, allows persistent instances to be read without + * a transaction active. + * @return the value of the nontransactionalRead property + */ + boolean getNontransactionalRead (); + + /** If true, allow persistent instances to be written without + * a transaction active. + * If an implementation does not support this option, a + * JDOUnsupportedOptionException is thrown. + * @param nontransactionalWrite the value of the nontransactionalRead + * property + */ + void setNontransactionalWrite (boolean nontransactionalWrite); + + /** If true, allows persistent instances to be written without + * a transaction active. + * @return the value of the nontransactionalWrite property + */ + boolean getNontransactionalWrite (); + + /** If true, at commit instances retain their values and the + * instances transition to persistent-nontransactional. + * If an implementation does not support this option, a + * JDOUnsupportedOptionException is thrown. + * @param retainValues the value of the retainValues property + */ + void setRetainValues(boolean retainValues); + + /** If true, at commit time instances retain their field + * values. + * @return the value of the retainValues property + */ + boolean getRetainValues(); + + /** If true, at rollback, fields of newly persistent instances + * are restored to + * their values as of the beginning of the transaction, and the instances + * revert to transient. Additionally, fields of modified + * instances of primitive types and immutable reference types + * are restored to their values as of the beginning of the + * transaction. + *

    If false, at rollback, the values of fields of + * newly persistent instances are unchanged and the instances revert to + * transient. Additionally, dirty instances transition to hollow. + * If an implementation does not support this option, a + * JDOUnsupportedOptionException is thrown. + * @param restoreValues the value of the restoreValues property + */ + void setRestoreValues(boolean restoreValues); + + /** Return the current value of the restoreValues property. + * @return the value of the restoreValues property + */ + boolean getRestoreValues(); + + /** Optimistic transactions do not hold data store locks until commit time. + * If an implementation does not support this option, a + * JDOUnsupportedOptionException is thrown. + * @param optimistic the value of the Optimistic flag. + */ + void setOptimistic(boolean optimistic); + + /** Optimistic transactions do not hold data store locks until commit time. + * @return the value of the Optimistic property. + */ + boolean getOptimistic(); + + /** Get the value for transaction isolation level for this transaction. + * @return the transaction isolation level + * @see #setIsolationLevel(String) + * @since 2.2 + */ + String getIsolationLevel(); + + /** Set the value for transaction isolation level for this transaction. + * Transaction isolation levels are defined in javax.jdo.Constants. + * If the requested level is not available, but a higher level is + * available, the higher level is silently used. + * If the requested level is not available, and no higher level is + * available, then JDOUnsupportedOptionException is thrown. + * Five standard isolation levels are defined. Other isolation levels + * might be supported by an implementation but are not standard. + *

    Standard values in order of low to high are: + *

    • read-uncommitted + *
    • read-committed + *
    • repeatable-read + *
    • snapshot + *
    • serializable + *
    + * @param level the transaction isolation level + * @see #getIsolationLevel() + * @see Constants#TX_READ_UNCOMMITTED + * @see Constants#TX_READ_COMMITTED + * @see Constants#TX_REPEATABLE_READ + * @see Constants#TX_SNAPSHOT + * @see Constants#TX_SERIALIZABLE + * @since 2.2 + */ + void setIsolationLevel(String level); + + /** The user can specify a Synchronization instance to be + * notified on transaction completions. The beforeCompletion + * method is called prior to flushing instances to the data store. + * + *

    The afterCompletion method is called after performing + * state transitions of persistent and transactional instances, following + * the data store commit or rollback operation. + *

    Only one Synchronization instance can be registered with + * the Transaction. If the application requires more than one + * instance to receive synchronization callbacks, then the single + * application instance is responsible for managing them, and forwarding + * callbacks to them. + * @param sync the Synchronization instance to be notified; + * null for none + */ + void setSynchronization(Synchronization sync); + + /** The user-specified Synchronization instance for this + * Transaction instance. + * @return the user-specified Synchronization instance. + */ + Synchronization getSynchronization(); + + /** The Transaction instance is always associated with exactly + * one PersistenceManager. + * + * @return the PersistenceManager for this + * Transaction instance + */ + PersistenceManager getPersistenceManager(); + + /** + * If true, a lock will be applied to all objects read in this + * transaction. + *

    If false then retrieved objects will not be locked. + * If null will fallback to the value for metadata for the class in question. + * @param serialize the value of the serializeRead property + * @since 3.0 + */ + void setSerializeRead(Boolean serialize); + + /** + * Return the current value of the serializeRead property. + * @return the value of the serializeRead property + * @since 3.0 + */ + Boolean getSerializeRead(); } diff --git a/api/src/main/java/javax/jdo/annotations/Cacheable.java b/api/src/main/java/javax/jdo/annotations/Cacheable.java index 203aab219..14128ae2a 100644 --- a/api/src/main/java/javax/jdo/annotations/Cacheable.java +++ b/api/src/main/java/javax/jdo/annotations/Cacheable.java @@ -22,14 +22,16 @@ import java.lang.annotation.Target; /** - * Annotation to specify that this class/field/property is cacheable in a Level 2 cache. This - * corresponds to the xml attribute "cacheable" of the "class", "field" and "property" elements. - * + * Annotation to specify that this class/field/property is cacheable + * in a Level 2 cache. + * This corresponds to the xml attribute "cacheable" of the "class", "field" + * and "property" elements. * @version 2.2 * @since 2.2 */ -@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) -public @interface Cacheable { - String value() default "true"; -} +public @interface Cacheable +{ + String value() default "true"; +} \ No newline at end of file diff --git a/api/src/main/java/javax/jdo/annotations/Column.java b/api/src/main/java/javax/jdo/annotations/Column.java index 0e3f4c1ea..35b093d32 100644 --- a/api/src/main/java/javax/jdo/annotations/Column.java +++ b/api/src/main/java/javax/jdo/annotations/Column.java @@ -23,99 +23,90 @@ import java.lang.annotation.Target; /** - * Annotation for a column in the database. Corresponds to the xml element "column". - * + * Annotation for a column in the database. + * Corresponds to the xml element "column". + * * @version 3.2 * @since 2.1 */ -@Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE}) +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Repeatable(Columns.class) -public @interface Column { - /** - * Name of the column. - * - * @return the name of the column - */ - String name() default ""; +public @interface Column +{ + /** + * Name of the column. + * @return the name of the column + */ + String name() default ""; - /** - * Target column for this column in the other table when part of a foreign key relation. - * - * @return the target column in the other table for this column when part of a foreign key - * relation. - */ - String target() default ""; + /** + * Target column for this column in the other table when part of a + * foreign key relation. + * @return the target column in the other table for this column + * when part of a foreign key relation. + */ + String target() default ""; - /** - * Target member in the other class or interface for this column when part of a bidirectional - * relation. - * - * @return the target member for this column when part of a bidirectional relation. - */ - String targetMember() default ""; + /** + * Target member in the other class or interface for this column + * when part of a bidirectional relation. + * @return the target member for this column when part of + * a bidirectional relation. + */ + String targetMember() default ""; - /** - * JDBC Type for this column. - * - * @return JDBC type for this column - */ - String jdbcType() default ""; + /** + * JDBC Type for this column. + * @return JDBC type for this column + */ + String jdbcType() default ""; - /** - * SQL Type for this column. - * - * @return SQL type for this column - */ - String sqlType() default ""; + /** + * SQL Type for this column. + * @return SQL type for this column + */ + String sqlType() default ""; - /** - * Maximum length of data stored in this column. - * - * @return the maximum length of data stored in this column - */ - int length() default -1; + /** + * Maximum length of data stored in this column. + * @return the maximum length of data stored in this column + */ + int length() default -1; - /** - * Scale for the column when handling floating point values. - * - * @return the scale for the column when handling floating point values - */ - int scale() default -1; + /** + * Scale for the column when handling floating point values. + * @return the scale for the column when handling floating point values + */ + int scale() default -1; - /** - * Whether the column allows null values to be inserted. - * - * @return whether the column allows null values to be inserted - */ - String allowsNull() default ""; + /** + * Whether the column allows null values to be inserted. + * @return whether the column allows null values to be inserted + */ + String allowsNull() default ""; - /** - * Default value for this column. - * - * @return the default value for this column - */ - String defaultValue() default ""; + /** + * Default value for this column. + * @return the default value for this column + */ + String defaultValue() default ""; - /** - * Value to be inserted when this is an "unmapped" column - * - * @return the value to be inserted when this is an "unmapped" column - */ - String insertValue() default ""; + /** + * Value to be inserted when this is an "unmapped" column + * @return the value to be inserted when this is an "unmapped" column + */ + String insertValue() default ""; - /** - * Vendor extensions. - * - * @return the vendor extensions - */ - Extension[] extensions() default {}; + /** Vendor extensions. + * @return the vendor extensions + */ + Extension[] extensions() default {}; - /** - * Position of this column in the table for this class (0=first, -1=unset). - * - * @return (relative) position of this column - * @since 3.1 - */ - int position() default -1; + /** + * Position of this column in the table for this class (0=first, -1=unset). + * @return (relative) position of this column + * @since 3.1 + */ + int position() default -1; } diff --git a/api/src/main/java/javax/jdo/annotations/Columns.java b/api/src/main/java/javax/jdo/annotations/Columns.java index e198b0c74..83ca0c334 100644 --- a/api/src/main/java/javax/jdo/annotations/Columns.java +++ b/api/src/main/java/javax/jdo/annotations/Columns.java @@ -23,17 +23,16 @@ /** * Annotation for a group of columns. - * + * * @version 2.1 * @since 2.1 */ -@Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE}) +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) -public @interface Columns { - /** - * The columns annotation information. - * - * @return the columns - */ - Column[] value(); +public @interface Columns +{ + /** The columns annotation information. + * @return the columns + */ + Column[] value(); } diff --git a/api/src/main/java/javax/jdo/annotations/Convert.java b/api/src/main/java/javax/jdo/annotations/Convert.java index 72ae3f98b..4aefa001d 100644 --- a/api/src/main/java/javax/jdo/annotations/Convert.java +++ b/api/src/main/java/javax/jdo/annotations/Convert.java @@ -20,19 +20,20 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; + import javax.jdo.AttributeConverter; /** - * Specifies that a given type should be converted before being stored to, and after being retrieved - * from the datastore using the given {@link AttributeConverter}. - * - *

    If this annotation is placed on a type, then the conversion applies to all fields or - * properties whose types match the entity type of the given {@link AttributeConverter}. Any {@link - * Convert} annotations placed on members overrides any type-level conversion specifications. + * Specifies that a given type should be converted before being stored to, and after being retrieved from + * the datastore using the given {@link AttributeConverter}. * - *

    If this annotation is placed on a field or property, the annotated attribute's type must be + * If this annotation is placed on a type, then the conversion applies to all fields or properties whose types + * match the entity type of the given {@link AttributeConverter}. + * Any {@link Convert} annotations placed on members overrides any type-level conversion specifications. + * + * If this annotation is placed on a field or property, the annotated attribute's type must be * assignment-compatible with the {@link AttributeConverter}'s entity type argument. - * + * * @version 3.2 * @since 3.2 */ @@ -40,19 +41,17 @@ @Target({ElementType.METHOD, ElementType.FIELD}) public @interface Convert { - /** - * The {@link AttributeConverter} to use for conversion. - * - * @return Converter class to use - */ - @SuppressWarnings("rawtypes") - Class value(); + /** + * The {@link AttributeConverter} to use for conversion. + * @return Converter class to use + */ + @SuppressWarnings("rawtypes") + Class value(); - /** - * Whether this conversion is enabled. True by default. Setting this to false allows disabling - * conversion that was specified at PMF level. - * - * @return Whether the PMF default converter is enabled - */ - boolean enabled() default true; + /** + * Whether this conversion is enabled. True by default. + * Setting this to false allows disabling conversion that was specified at PMF level. + * @return Whether the PMF default converter is enabled + */ + boolean enabled() default true; } diff --git a/api/src/main/java/javax/jdo/annotations/DatastoreIdentity.java b/api/src/main/java/javax/jdo/annotations/DatastoreIdentity.java index 4f38716bf..ce07a0dd3 100644 --- a/api/src/main/java/javax/jdo/annotations/DatastoreIdentity.java +++ b/api/src/main/java/javax/jdo/annotations/DatastoreIdentity.java @@ -22,55 +22,48 @@ import java.lang.annotation.Target; /** - * Annotation for the datastore identity of the class. Corresponds to the xml element - * "datastore-identity" of the "class" element. - * + * Annotation for the datastore identity of the class. + * Corresponds to the xml element "datastore-identity" of the "class" element. + * * @version 2.1 * @since 2.1 */ -@Target(ElementType.TYPE) +@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -public @interface DatastoreIdentity { - /** - * Strategy to use when generating datastore identities - * - * @return Strategy to use when generating datastore identities - */ - IdGeneratorStrategy strategy() default IdGeneratorStrategy.UNSPECIFIED; +public @interface DatastoreIdentity +{ + /** + * Strategy to use when generating datastore identities + * @return Strategy to use when generating datastore identities + */ + IdGeneratorStrategy strategy() default IdGeneratorStrategy.UNSPECIFIED; - /** - * Custom strategy to use to generate the value for the identity. If customStrategy is non-empty, - * then strategy must be UNSPECIFIED. - * - * @return the custom strategy - */ - String customStrategy() default ""; + /** Custom strategy to use to generate the value for the identity. + * If customStrategy is non-empty, then strategy must be UNSPECIFIED. + * @return the custom strategy + */ + String customStrategy() default ""; - /** - * Name of sequence to use when the strategy involves sequences - * - * @return Name of sequence to use when the strategy involves sequences - */ - String sequence() default ""; + /** + * Name of sequence to use when the strategy involves sequences + * @return Name of sequence to use when the strategy involves sequences + */ + String sequence() default ""; - /** - * Name of the column for the datastore identity - * - * @return Name of the column for the datastore identity - */ - String column() default ""; + /** + * Name of the column for the datastore identity + * @return Name of the column for the datastore identity + */ + String column() default ""; - /** - * The column(s) making up the datastore identity. - * - * @return The column(s) making up the datastore identity. - */ - Column[] columns() default {}; + /** + * The column(s) making up the datastore identity. + * @return The column(s) making up the datastore identity. + */ + Column[] columns() default {}; - /** - * Vendor extensions. - * - * @return the vendor extensions - */ - Extension[] extensions() default {}; + /** Vendor extensions. + * @return the vendor extensions + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/javax/jdo/annotations/Discriminator.java b/api/src/main/java/javax/jdo/annotations/Discriminator.java index 20a3f1040..b2a825df8 100644 --- a/api/src/main/java/javax/jdo/annotations/Discriminator.java +++ b/api/src/main/java/javax/jdo/annotations/Discriminator.java @@ -22,57 +22,53 @@ import java.lang.annotation.Target; /** - * Annotation for the discriminator of the class. Corresponds to the xml element "discriminator" of - * the "inheritance" element. - * + * Annotation for the discriminator of the class. + * Corresponds to the xml element "discriminator" of the "inheritance" element. + * * @version 2.1 * @since 2.1 */ -@Target(ElementType.TYPE) +@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -public @interface Discriminator { - /** - * Strategy to use for the discriminator. The discriminator determines the class associated with a - * row in the datastore. - * - * @return the strategy to use for the discriminator - */ - DiscriminatorStrategy strategy() default DiscriminatorStrategy.UNSPECIFIED; +public @interface Discriminator +{ + /** + * Strategy to use for the discriminator. The discriminator determines + * the class associated with a row in the datastore. + * @return the strategy to use for the discriminator + */ + DiscriminatorStrategy strategy() + default DiscriminatorStrategy.UNSPECIFIED; - /** - * Custom strategy to use for the discriminator. If customStrategy is non-empty, then strategy - * must be UNSPECIFIED. - * - * @return the custom strategy - */ - String customStrategy() default ""; + /** Custom strategy to use for the discriminator. + * If customStrategy is non-empty, then strategy must be UNSPECIFIED. + * @return the custom strategy + */ + String customStrategy() default ""; - /** - * Whether the discriminator is indexed. - * - * @return whether the discriminator is indexed - */ - String indexed() default ""; + /** + * Whether the discriminator is indexed. + * @return whether the discriminator is indexed + */ + String indexed() default ""; - /** - * Name of the column for the discriminator - * - * @return the name of the column for the discriminator - */ - String column() default ""; + /** + * Name of the column for the discriminator + * @return the name of the column for the discriminator + */ + String column() default ""; - /** - * The value for the discriminator for objects of this class when using "value-map" strategy. - * - * @return The value for the discriminator for objects of this class when using "value-map" - * strategy - */ - String value() default ""; + /** + * The value for the discriminator for objects of this class + * when using "value-map" strategy. + * @return The value for the discriminator for objects of this class + * when using "value-map" strategy + */ + String value() default ""; - /** - * The column(s) making up the discriminator. - * - * @return the column(s) making up the discriminator - */ - Column[] columns() default {}; + /** + * The column(s) making up the discriminator. + * @return the column(s) making up the discriminator + */ + Column[] columns() default {}; } diff --git a/api/src/main/java/javax/jdo/annotations/DiscriminatorStrategy.java b/api/src/main/java/javax/jdo/annotations/DiscriminatorStrategy.java index be8eb78ea..8f725fc18 100644 --- a/api/src/main/java/javax/jdo/annotations/DiscriminatorStrategy.java +++ b/api/src/main/java/javax/jdo/annotations/DiscriminatorStrategy.java @@ -18,13 +18,14 @@ /** * Enumeration of the discriminator strategy values. - * + * * @version 2.1 * @since 2.1 */ -public enum DiscriminatorStrategy { - UNSPECIFIED, - NONE, - VALUE_MAP, - CLASS_NAME +public enum DiscriminatorStrategy +{ + UNSPECIFIED, + NONE, + VALUE_MAP, + CLASS_NAME } diff --git a/api/src/main/java/javax/jdo/annotations/Element.java b/api/src/main/java/javax/jdo/annotations/Element.java index 9fe0348de..358ad6e5a 100644 --- a/api/src/main/java/javax/jdo/annotations/Element.java +++ b/api/src/main/java/javax/jdo/annotations/Element.java @@ -20,166 +20,144 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; + import javax.jdo.AttributeConverter; import javax.jdo.AttributeConverter.UseDefault; /** - * Annotation for the element of a collection/array relation. Corresponds to the xml element - * "element". - * + * Annotation for the element of a collection/array relation. + * Corresponds to the xml element "element". + * * @version 2.1 * @since 2.1 */ -@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) +@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) -public @interface Element { - /** - * Types of the elements. This can be determined if using JDK1.5 generics but is required - * otherwise. Multiple types can be specified if the implementation supports multiple types. - * - * @return the types of elements - */ - Class[] types() default {}; - - /** - * Whether the element is to be stored serialized (into a join table) - * - * @return whether the element is to be stored serialized (into a join table) - */ - String serialized() default ""; - - /** - * Whether this element is embedded. - * - * @return whether this element is embedded - */ - String embedded() default ""; - - /** - * The embedded mapping for the element. - * - * @return the embedded mapping for the element - */ - Embedded[] embeddedMapping() default {}; - - /** - * Whether the element is dependent on the owner, and will be deleted when the owner is deleted. - * - * @return whether the element is dependent on the owner, and will be deleted when the owner is - * deleted - */ - String dependent() default ""; - - /** - * Name of the table for the element. - * - * @return name of the table for the element - */ - String table() default ""; - - /** - * Name of the column to store the element in. - * - * @return name of the column to store the element in - */ - String column() default ""; - - /** - * Delete action to apply to any foreign key for the element. - * - * @return delete action to apply to any foreign key for the element - */ - ForeignKeyAction deleteAction() default ForeignKeyAction.UNSPECIFIED; - - /** - * Update action to apply to any foreign key for the element - * - * @return update action to apply to any foreign key for the element - */ - ForeignKeyAction updateAction() default ForeignKeyAction.UNSPECIFIED; - - /** - * Whether the value column(s) should be indexed. - * - * @return whether the value column(s) should be indexed. - */ - String indexed() default ""; - - /** - * The name of the index to generate. - * - * @return the name of the index - */ - String index() default ""; - - /** - * Whether a unique constraint should be generated or assumed. - * - * @return whether a unique constraint should be generated or assumed - */ - String unique() default ""; - - /** - * The name of the unique key constraint to generate. - * - * @return the name of the unique key constraint - */ - String uniqueKey() default ""; - - /** - * Name of the member in the target class that forms a bidirectional relationship with this - * member. - * - * @return name of the member in the target class that forms a bidirectional relationship with - * this member - */ - String mappedBy() default ""; - - /** - * The column(s) for the element. - * - * @return the column(s) for the element - */ - Column[] columns() default {}; - - /** - * Generate or assume a foreign key constraint exists on the column or columns associated with - * this join. Specify "true" or "false". - * - * @return whether to generate or assume a primary key constraint - */ - String generateForeignKey() default ""; - - /** - * Name for a generated foreign key constraint. - * - * @return the name of the generated foreign key constraint - */ - String foreignKey() default ""; - - /** - * Optional {@link AttributeConverter} to use for converting this element. - * - * @return The converter class (or NullAttributeConverter if not specified). - */ - @SuppressWarnings("rawtypes") - Class converter() default - UseDefault.class; // TODO Current JDK doesn't allow "default null" - - /** - * Whether we should disable any converter that was specified as default for this type on the PMF. - * Only has any effect when this is explicitly set to true, when any AttributeConverter specified - * for this type either here or for the class or at the PMF will be ignored and will use the JDO - * implementation default handling. - * - * @return Whether PMF attribute conversion is to be disabled. - */ - boolean useDefaultConversion() default false; // TODO Current JDK doesn't allow "default null" - - /** - * Vendor extensions. - * - * @return the vendor extensions - */ - Extension[] extensions() default {}; +public @interface Element +{ + /** + * Types of the elements. This can be determined if using JDK1.5 generics + * but is required otherwise. Multiple types can be specified if the + * implementation supports multiple types. + * @return the types of elements + */ + Class[] types() default {}; + + /** + * Whether the element is to be stored serialized (into a join table) + * @return whether the element is to be stored serialized + * (into a join table) + */ + String serialized() default ""; + + /** Whether this element is embedded. + * @return whether this element is embedded + */ + String embedded() default ""; + + /** + * The embedded mapping for the element. + * @return the embedded mapping for the element + */ + Embedded[] embeddedMapping() default {}; + + /** + * Whether the element is dependent on the owner, and will be deleted + * when the owner is deleted. + * @return whether the element is dependent on the owner, and will be + * deleted when the owner is deleted + */ + String dependent() default ""; + + /** + * Name of the table for the element. + * @return name of the table for the element + */ + String table() default ""; + + /** + * Name of the column to store the element in. + * @return name of the column to store the element in + */ + String column() default ""; + + /** + * Delete action to apply to any foreign key for the element. + * @return delete action to apply to any foreign key for the element + */ + ForeignKeyAction deleteAction() default ForeignKeyAction.UNSPECIFIED; + + /** + * Update action to apply to any foreign key for the element + * @return update action to apply to any foreign key for the element + */ + ForeignKeyAction updateAction() default ForeignKeyAction.UNSPECIFIED; + + /** + * Whether the value column(s) should be indexed. + * @return whether the value column(s) should be indexed. + */ + String indexed() default ""; + + /** The name of the index to generate. + * @return the name of the index + */ + String index() default ""; + + /** + * Whether a unique constraint should be generated or assumed. + * @return whether a unique constraint should be generated or assumed + */ + String unique() default ""; + + /** + * The name of the unique key constraint to generate. + * @return the name of the unique key constraint + */ + String uniqueKey() default ""; + + /** + * Name of the member in the target class that forms a bidirectional + * relationship with this member. + * @return name of the member in the target class that forms a bidirectional + * relationship with this member + */ + String mappedBy() default ""; + + /** + * The column(s) for the element. + * @return the column(s) for the element + */ + Column[] columns() default {}; + + /** Generate or assume a foreign key constraint exists on the column + * or columns associated with this join. Specify "true" or "false". + * @return whether to generate or assume a primary key constraint + */ + String generateForeignKey() default ""; + + /** Name for a generated foreign key constraint. + * @return the name of the generated foreign key constraint + */ + String foreignKey() default ""; + + /** + * Optional {@link AttributeConverter} to use for converting this element. + * @return The converter class (or NullAttributeConverter if not specified). + */ + @SuppressWarnings("rawtypes") + Class converter() default UseDefault.class; // TODO Current JDK doesn't allow "default null" + + /** + * Whether we should disable any converter that was specified as default for this type on the PMF. + * Only has any effect when this is explicitly set to true, when any AttributeConverter specified for this type + * either here or for the class or at the PMF will be ignored and will use the JDO implementation default handling. + * @return Whether PMF attribute conversion is to be disabled. + */ + boolean useDefaultConversion() default false; // TODO Current JDK doesn't allow "default null" + + /** Vendor extensions. + * @return the vendor extensions + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/javax/jdo/annotations/Embedded.java b/api/src/main/java/javax/jdo/annotations/Embedded.java index 9763839a2..ca44db1f3 100644 --- a/api/src/main/java/javax/jdo/annotations/Embedded.java +++ b/api/src/main/java/javax/jdo/annotations/Embedded.java @@ -22,48 +22,42 @@ import java.lang.annotation.Target; /** - * Annotation to define that the object is embedded into the table of the owning object. Corresponds - * to the xml element "embedded". - * + * Annotation to define that the object is embedded into the table of the + * owning object. + * Corresponds to the xml element "embedded". + * * @version 2.1 * @since 2.1 */ -@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) +@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) -public @interface Embedded { - /** - * The member in the embedded object that links back to the owning object where it has a - * bidirectional relationship. - * - * @return the member that refers to the owner - */ - String ownerMember() default ""; +public @interface Embedded +{ + /** The member in the embedded object that links back to the owning object + * where it has a bidirectional relationship. + * @return the member that refers to the owner + */ + String ownerMember() default ""; - /** - * The column in the embedded object used to judge if the embedded object is null. - * - * @return the null indicator column - */ - String nullIndicatorColumn() default ""; + /** The column in the embedded object used to judge if the embedded object + * is null. + * @return the null indicator column + */ + String nullIndicatorColumn() default ""; - /** - * The value in the null column to interpret the object as being null. - * - * @return the null indicator value - */ - String nullIndicatorValue() default ""; + /** The value in the null column to interpret the object as being null. + * @return the null indicator value + */ + String nullIndicatorValue() default ""; - /** - * Members for this embedding. - * - * @return the members embedded in the field or property being annotated - */ - Persistent[] members() default {}; + /** Members for this embedding. + * @return the members embedded in the field or property being annotated + */ + Persistent[] members() default {}; - /** - * Discriminator for cases where the embedded object has inheritance. - * - * @return the discriminator for inheritance determination - */ - Discriminator discriminatorColumnName() default @Discriminator; + /** + * Discriminator for cases where the embedded object has inheritance. + * @return the discriminator for inheritance determination + */ + Discriminator discriminatorColumnName() default @Discriminator; } diff --git a/api/src/main/java/javax/jdo/annotations/EmbeddedOnly.java b/api/src/main/java/javax/jdo/annotations/EmbeddedOnly.java index 5a4e49817..fd07d2a81 100644 --- a/api/src/main/java/javax/jdo/annotations/EmbeddedOnly.java +++ b/api/src/main/java/javax/jdo/annotations/EmbeddedOnly.java @@ -22,12 +22,15 @@ import java.lang.annotation.Target; /** - * Annotation for whether the class is only for persisting embedded into another object. Same as - * specifying @PersistenceCapable(embeddedOnly="true"). - * + * Annotation for whether the class is only for persisting embedded into + * another object. + * Same as specifying @PersistenceCapable(embeddedOnly="true"). + * * @version 2.1 * @since 2.1 */ -@Target(ElementType.TYPE) +@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -public @interface EmbeddedOnly {} +public @interface EmbeddedOnly +{ +} diff --git a/api/src/main/java/javax/jdo/annotations/Extension.java b/api/src/main/java/javax/jdo/annotations/Extension.java index cf54bd826..9511cf167 100644 --- a/api/src/main/java/javax/jdo/annotations/Extension.java +++ b/api/src/main/java/javax/jdo/annotations/Extension.java @@ -23,33 +23,29 @@ import java.lang.annotation.Target; /** - * Annotation for a JDO vendor extension. Corresponds to the xml element "extension". - * + * Annotation for a JDO vendor extension. + * Corresponds to the xml element "extension". + * * @version 3.2 * @since 2.1 */ -@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @Repeatable(Extensions.class) -public @interface Extension { - /** - * Vendor that the extension applies to (required). - * - * @return the vendor - */ - String vendorName(); +public @interface Extension +{ + /** Vendor that the extension applies to (required). + * @return the vendor + */ + String vendorName(); - /** - * The key for the extension (required). - * - * @return the key - */ - String key(); + /** The key for the extension (required). + * @return the key + */ + String key(); - /** - * The value for the extension (required). - * - * @return the value - */ - String value(); + /** The value for the extension (required). + * @return the value + */ + String value(); } diff --git a/api/src/main/java/javax/jdo/annotations/Extensions.java b/api/src/main/java/javax/jdo/annotations/Extensions.java index d62624a29..6ba6bfc46 100644 --- a/api/src/main/java/javax/jdo/annotations/Extensions.java +++ b/api/src/main/java/javax/jdo/annotations/Extensions.java @@ -23,17 +23,17 @@ /** * Annotation for a group of extensions - * + * * @version 2.1 * @since 2.1 */ -@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) -public @interface Extensions { - /** - * The extensions. - * - * @return the extensions - */ - Extension[] value(); +public @interface Extensions +{ + /** + * The extensions. + * @return the extensions + */ + Extension[] value(); } diff --git a/api/src/main/java/javax/jdo/annotations/FetchGroup.java b/api/src/main/java/javax/jdo/annotations/FetchGroup.java index f1ffa15e1..f7ae432f1 100644 --- a/api/src/main/java/javax/jdo/annotations/FetchGroup.java +++ b/api/src/main/java/javax/jdo/annotations/FetchGroup.java @@ -23,41 +23,40 @@ import java.lang.annotation.Target; /** - * Annotation for the fetch group of a class. Corresponds to the xml element "fetch-group". - * + * Annotation for the fetch group of a class. + * Corresponds to the xml element "fetch-group". + * * @version 3.2 * @since 2.1 */ -@Target(ElementType.TYPE) +@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Repeatable(FetchGroups.class) -public @interface FetchGroup { - /** - * Name of the fetch group. - * - * @return the name of the fetch group - */ - String name() default ""; +public @interface FetchGroup +{ + /** + * Name of the fetch group. + * @return the name of the fetch group + */ + String name() default ""; - /** - * Whether we should load this group as part of the post load process. - * - * @return whether we should load this group as part of the post load process. - */ - String postLoad() default ""; + /** + * Whether we should load this group as part of the post load process. + * @return whether we should load this group as part of the post load + * process. + */ + String postLoad() default ""; - /** - * Members (fields and properties) of the fetch group. The members should contain only name and - * recursionDepth. - * - * @return members for the fetch group - */ - Persistent[] members(); + /** + * Members (fields and properties) of the fetch group. The members + * should contain only name and recursionDepth. + * @return members for the fetch group + */ + Persistent[] members(); - /** - * Fetch groups to be nested (included) in this fetch group. - * - * @return The nested fetch groups in this fetch group - */ - String[] fetchGroups() default {}; + /** + * Fetch groups to be nested (included) in this fetch group. + * @return The nested fetch groups in this fetch group + */ + String[] fetchGroups() default {}; } diff --git a/api/src/main/java/javax/jdo/annotations/FetchGroups.java b/api/src/main/java/javax/jdo/annotations/FetchGroups.java index 602a272a2..cd55704be 100644 --- a/api/src/main/java/javax/jdo/annotations/FetchGroups.java +++ b/api/src/main/java/javax/jdo/annotations/FetchGroups.java @@ -23,17 +23,17 @@ /** * Annotation for a group of fetch-group objects - * + * * @version 2.1 * @since 2.1 */ -@Target(ElementType.TYPE) +@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -public @interface FetchGroups { - /** - * The Fetch Groups - * - * @return The Fetch Groups - */ - FetchGroup[] value(); +public @interface FetchGroups +{ + /** + * The Fetch Groups + * @return The Fetch Groups + */ + FetchGroup[] value(); } diff --git a/api/src/main/java/javax/jdo/annotations/FetchPlan.java b/api/src/main/java/javax/jdo/annotations/FetchPlan.java index d572e52b2..8e46e55a0 100644 --- a/api/src/main/java/javax/jdo/annotations/FetchPlan.java +++ b/api/src/main/java/javax/jdo/annotations/FetchPlan.java @@ -23,41 +23,38 @@ import java.lang.annotation.Target; /** - * Annotation for the fetch plan of a persistence manager, query, or extent. Corresponds to the xml - * element "fetch-plan". - * + * Annotation for the fetch plan of a persistence manager, query, or extent. + * Corresponds to the xml element "fetch-plan". + * * @version 3.2 * @since 2.1 */ -@Target(ElementType.TYPE) +@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Repeatable(FetchPlans.class) -public @interface FetchPlan { - /** - * Name of the fetch plan. - * - * @return the name of the fetch plan - */ - String name() default ""; +public @interface FetchPlan +{ + /** + * Name of the fetch plan. + * @return the name of the fetch plan + */ + String name() default ""; - /** - * The fetch groups in this fetch plan. - * - * @return the fetch groups - */ - String[] fetchGroups() default {}; + /** + * The fetch groups in this fetch plan. + * @return the fetch groups + */ + String[] fetchGroups() default {}; - /** - * The depth of references to instantiate, starting with the root object. - * - * @return the maxium fetch depth - */ - int maxFetchDepth() default 1; + /** + * The depth of references to instantiate, starting with the root object. + * @return the maxium fetch depth + */ + int maxFetchDepth() default 1; - /** - * The number of instances of multi-valued fields retrieved by queries. - * - * @return the fetch size - */ - int fetchSize() default 0; + /** + * The number of instances of multi-valued fields retrieved by queries. + * @return the fetch size + */ + int fetchSize() default 0; } diff --git a/api/src/main/java/javax/jdo/annotations/FetchPlans.java b/api/src/main/java/javax/jdo/annotations/FetchPlans.java index a14d51ee2..196a156c9 100644 --- a/api/src/main/java/javax/jdo/annotations/FetchPlans.java +++ b/api/src/main/java/javax/jdo/annotations/FetchPlans.java @@ -23,17 +23,17 @@ /** * Annotation for a group of FetchPlan objects - * + * * @version 2.1 * @since 2.1 */ -@Target(ElementType.TYPE) +@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -public @interface FetchPlans { - /** - * The Fetch Plans - * - * @return The Fetch Plans - */ - FetchPlan[] value(); +public @interface FetchPlans +{ + /** + * The Fetch Plans + * @return The Fetch Plans + */ + FetchPlan[] value(); } diff --git a/api/src/main/java/javax/jdo/annotations/ForeignKey.java b/api/src/main/java/javax/jdo/annotations/ForeignKey.java index 3d0a33dce..62419ec43 100644 --- a/api/src/main/java/javax/jdo/annotations/ForeignKey.java +++ b/api/src/main/java/javax/jdo/annotations/ForeignKey.java @@ -23,76 +23,61 @@ import java.lang.annotation.Target; /** - * Annotation for a database foreign-key. Corresponds to the xml element "foreign-key". + * Annotation for a database foreign-key. + * Corresponds to the xml element "foreign-key". * * @version 3.2 * @since 2.1 */ -@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @Repeatable(ForeignKeys.class) -public @interface ForeignKey { - /** - * Name of the foreign key. - * - * @return the name of the foreign key - */ - String name() default ""; +public @interface ForeignKey +{ + /** Name of the foreign key. + * @return the name of the foreign key + */ + String name() default ""; - /** - * Table for the foreign key. This is needed iff annotating a type where the foreign key is not - * defined on the primary table for the type. - * - * @return the table on which the foreign key is defined - */ - String table() default ""; + /** Table for the foreign key. This is needed iff annotating a type where + * the foreign key is not defined on the primary table for the type. + * @return the table on which the foreign key is defined + */ + String table() default ""; - /** - * Whether this foreign key is deferred (constraint is checked only at commit). - * - * @return whether this foreign key is deferred - */ - String deferred() default ""; + /** Whether this foreign key is deferred + * (constraint is checked only at commit). + * @return whether this foreign key is deferred + */ + String deferred() default ""; - /** - * Whether this foreign key is unique. - * - * @return whether this foreign key is unique - */ - String unique() default ""; + /** Whether this foreign key is unique. + * @return whether this foreign key is unique + */ + String unique() default ""; - /** - * The delete action of this foreign key. - * - * @return the delete action of this foreign key - */ - ForeignKeyAction deleteAction() default ForeignKeyAction.RESTRICT; + /** The delete action of this foreign key. + * @return the delete action of this foreign key + */ + ForeignKeyAction deleteAction() default ForeignKeyAction.RESTRICT; - /** - * The update action of this foreign key. - * - * @return the update action of this foreign key - */ - ForeignKeyAction updateAction() default ForeignKeyAction.RESTRICT; + /** The update action of this foreign key. + * @return the update action of this foreign key + */ + ForeignKeyAction updateAction() default ForeignKeyAction.RESTRICT; - /** - * Member (field and property) names that compose this foreign key. - * - * @return the member names that compose this foreign key - */ - String[] members() default {}; + /** Member (field and property) names that compose this foreign key. + * @return the member names that compose this foreign key + */ + String[] members() default {}; - /** - * Columns that compose this foreign key. - * - * @return the columns that compose this foreign key - */ - Column[] columns() default {}; + /** Columns that compose this foreign key. + * @return the columns that compose this foreign key + */ + Column[] columns() default {}; - /** - * Vendor extensions. - * - * @return the vendor extensions - */ - Extension[] extensions() default {}; + /** Vendor extensions. + * @return the vendor extensions + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/javax/jdo/annotations/ForeignKeyAction.java b/api/src/main/java/javax/jdo/annotations/ForeignKeyAction.java index 4af387562..d84daa15b 100644 --- a/api/src/main/java/javax/jdo/annotations/ForeignKeyAction.java +++ b/api/src/main/java/javax/jdo/annotations/ForeignKeyAction.java @@ -18,15 +18,16 @@ /** * Enumeration of the foreign-key delete/update action values. - * + * * @version 2.1 * @since 2.1 */ -public enum ForeignKeyAction { - UNSPECIFIED, - RESTRICT, - CASCADE, - NULL, - DEFAULT, - NONE +public enum ForeignKeyAction +{ + UNSPECIFIED, + RESTRICT, + CASCADE, + NULL, + DEFAULT, + NONE } diff --git a/api/src/main/java/javax/jdo/annotations/ForeignKeys.java b/api/src/main/java/javax/jdo/annotations/ForeignKeys.java index 07e7e89ce..e0cd58b10 100644 --- a/api/src/main/java/javax/jdo/annotations/ForeignKeys.java +++ b/api/src/main/java/javax/jdo/annotations/ForeignKeys.java @@ -23,17 +23,17 @@ /** * Annotation for a group of foreign-key constraints. - * + * * @version 2.1 * @since 2.1 */ -@Target(ElementType.TYPE) +@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -public @interface ForeignKeys { - /** - * The foreign keys. - * - * @return The foreign keys - */ - ForeignKey[] value(); +public @interface ForeignKeys +{ + /** + * The foreign keys. + * @return The foreign keys + */ + ForeignKey[] value(); } diff --git a/api/src/main/java/javax/jdo/annotations/IdGeneratorStrategy.java b/api/src/main/java/javax/jdo/annotations/IdGeneratorStrategy.java index 0cd3ef04d..f00f9f4f9 100644 --- a/api/src/main/java/javax/jdo/annotations/IdGeneratorStrategy.java +++ b/api/src/main/java/javax/jdo/annotations/IdGeneratorStrategy.java @@ -18,16 +18,17 @@ /** * Enumeration of the id generator strategy values. - * + * * @version 2.1 * @since 2.1 */ -public enum IdGeneratorStrategy { - UNSPECIFIED, - NATIVE, - SEQUENCE, - IDENTITY, - INCREMENT, - UUIDSTRING, - UUIDHEX +public enum IdGeneratorStrategy +{ + UNSPECIFIED, + NATIVE, + SEQUENCE, + IDENTITY, + INCREMENT, + UUIDSTRING, + UUIDHEX } diff --git a/api/src/main/java/javax/jdo/annotations/IdentityType.java b/api/src/main/java/javax/jdo/annotations/IdentityType.java index 0a3bef4b4..3d391ddac 100644 --- a/api/src/main/java/javax/jdo/annotations/IdentityType.java +++ b/api/src/main/java/javax/jdo/annotations/IdentityType.java @@ -18,13 +18,14 @@ /** * Enumeration of the identity type values. - * + * * @version 2.1 * @since 2.1 */ -public enum IdentityType { - UNSPECIFIED, - APPLICATION, - DATASTORE, - NONDURABLE +public enum IdentityType +{ + UNSPECIFIED, + APPLICATION, + DATASTORE, + NONDURABLE } diff --git a/api/src/main/java/javax/jdo/annotations/Index.java b/api/src/main/java/javax/jdo/annotations/Index.java index 8a62a7626..43ce1af60 100644 --- a/api/src/main/java/javax/jdo/annotations/Index.java +++ b/api/src/main/java/javax/jdo/annotations/Index.java @@ -23,56 +23,46 @@ import java.lang.annotation.Target; /** - * Annotation for a database index. Used for database schema generation to create indexes. + * Annotation for a database index. Used for database schema + * generation to create indexes. * Corresponds to the xml element "index". * * @version 3.2 * @since 2.1 */ -@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @Repeatable(Indices.class) -public @interface Index { - /** - * Name of the index - * - * @return the name of the index - */ - String name() default ""; +public @interface Index +{ + /** Name of the index + * @return the name of the index + */ + String name() default ""; - /** - * Table for the index. This is needed iff annotating a type where the index is not defined on the - * primary table for the type. - * - * @return the table on which the index is defined - */ - String table() default ""; + /** Table for the index. This is needed iff annotating a type where + * the index is not defined on the primary table for the type. + * @return the table on which the index is defined + */ + String table() default ""; - /** - * Whether this index is unique - * - * @return whether this index is unique - */ - String unique() default ""; + /** Whether this index is unique + * @return whether this index is unique + */ + String unique() default ""; - /** - * Member (field and property) names that compose this index. - * - * @return member names that compose this index - */ - String[] members() default {}; + /** Member (field and property) names that compose this index. + * @return member names that compose this index + */ + String[] members() default {}; - /** - * Columns that compose this index. - * - * @return columns that compose this index - */ - Column[] columns() default {}; + /** Columns that compose this index. + * @return columns that compose this index + */ + Column[] columns() default {}; - /** - * Vendor extensions. - * - * @return the vendor extensions - */ - Extension[] extensions() default {}; + /** Vendor extensions. + * @return the vendor extensions + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/javax/jdo/annotations/Indices.java b/api/src/main/java/javax/jdo/annotations/Indices.java index 02cb3b503..bd229037c 100644 --- a/api/src/main/java/javax/jdo/annotations/Indices.java +++ b/api/src/main/java/javax/jdo/annotations/Indices.java @@ -23,17 +23,17 @@ /** * Annotation for a group of index constraints. - * + * * @version 2.1 * @since 2.1 */ -@Target(ElementType.TYPE) +@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -public @interface Indices { - /** - * The indices - * - * @return The indices - */ - Index[] value(); +public @interface Indices +{ + /** + * The indices + * @return The indices + */ + Index[] value(); } diff --git a/api/src/main/java/javax/jdo/annotations/Inheritance.java b/api/src/main/java/javax/jdo/annotations/Inheritance.java index ff8ba0527..03e07ca16 100644 --- a/api/src/main/java/javax/jdo/annotations/Inheritance.java +++ b/api/src/main/java/javax/jdo/annotations/Inheritance.java @@ -22,27 +22,26 @@ import java.lang.annotation.Target; /** - * Annotation for the inheritance of the class. Corresponds to the xml element "inheritance" of the - * "class" and "interface" elements. - * + * Annotation for the inheritance of the class. + * Corresponds to the xml element "inheritance" of the "class" + * and "interface" elements. + * * @version 2.1 * @since 2.1 */ -@Target(ElementType.TYPE) +@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -public @interface Inheritance { - /** - * Strategy to use for inheritance. Specifies in which table(s) the members for the class are - * stored. - * - * @return the inheritance strategy - */ - InheritanceStrategy strategy() default InheritanceStrategy.UNSPECIFIED; +public @interface Inheritance +{ + /** Strategy to use for inheritance. Specifies in which table(s) + * the members for the class are stored. + * @return the inheritance strategy + */ + InheritanceStrategy strategy() default InheritanceStrategy.UNSPECIFIED; - /** - * Custom inheritance strategy. If customStrategy is non-empty, then strategy must be UNSPECIFIED. - * - * @return the custom inheritance strategy - */ - String customStrategy() default ""; + /** Custom inheritance strategy. If customStrategy is non-empty, then + * strategy must be UNSPECIFIED. + * @return the custom inheritance strategy + */ + String customStrategy() default ""; } diff --git a/api/src/main/java/javax/jdo/annotations/InheritanceStrategy.java b/api/src/main/java/javax/jdo/annotations/InheritanceStrategy.java index 24c9f5c87..f9b028a62 100644 --- a/api/src/main/java/javax/jdo/annotations/InheritanceStrategy.java +++ b/api/src/main/java/javax/jdo/annotations/InheritanceStrategy.java @@ -18,14 +18,15 @@ /** * Enumeration of the inheritance strategy values. - * + * * @version 3.1 * @since 2.1 */ -public enum InheritanceStrategy { - UNSPECIFIED, - NEW_TABLE, - SUBCLASS_TABLE, - SUPERCLASS_TABLE, - COMPLETE_TABLE +public enum InheritanceStrategy +{ + UNSPECIFIED, + NEW_TABLE, + SUBCLASS_TABLE, + SUPERCLASS_TABLE, + COMPLETE_TABLE } diff --git a/api/src/main/java/javax/jdo/annotations/Join.java b/api/src/main/java/javax/jdo/annotations/Join.java index bcf637828..e1267521b 100644 --- a/api/src/main/java/javax/jdo/annotations/Join.java +++ b/api/src/main/java/javax/jdo/annotations/Join.java @@ -23,112 +23,88 @@ import java.lang.annotation.Target; /** - * Annotation for the join of a relation. Corresponds to the xml element "join". - * + * Annotation for the join of a relation. + * Corresponds to the xml element "join". + * * @version 3.2 * @since 2.1 */ -@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @Repeatable(Joins.class) -public @interface Join { - /** - * Table to join to (used when joining to secondary tables). - * - * @return the table - */ - String table() default ""; +public @interface Join +{ + /** Table to join to (used when joining to secondary tables). + * @return the table + */ + String table() default ""; - /** - * Name of the column in the join table. - * - * @return the name of the column in the join table - */ - String column() default ""; + /** Name of the column in the join table. + * @return the name of the column in the join table + */ + String column() default ""; - /** - * Whether the join column is indexed. - * - * @return whether the join column(s) is(are) indexed - */ - String indexed() default ""; + /** Whether the join column is indexed. + * @return whether the join column(s) is(are) indexed + */ + String indexed() default ""; - /** - * The name of the index to generate. - * - * @return the name of the index - */ - String index() default ""; + /** The name of the index to generate. + * @return the name of the index + */ + String index() default ""; - /** - * Whether the join column is unique. - * - * @return whether the join column(s) is(are) is unique - */ - String unique() default ""; + /** Whether the join column is unique. + * @return whether the join column(s) is(are) is unique + */ + String unique() default ""; - /** - * The name of the unique key constraint to generate. - * - * @return the name of the unique key constraint - */ - String uniqueKey() default ""; + /** + * The name of the unique key constraint to generate. + * @return the name of the unique key constraint + */ + String uniqueKey() default ""; - /** - * Whether to use an outer join. - * - * @return whether to use an outer join - */ - String outer() default ""; + /** Whether to use an outer join. + * @return whether to use an outer join + */ + String outer() default ""; - /** - * Delete action to be applied to any ForeignKey on this join. - * - * @return the delete action - */ - ForeignKeyAction deleteAction() default ForeignKeyAction.UNSPECIFIED; + /** Delete action to be applied to any ForeignKey on this join. + * @return the delete action + */ + ForeignKeyAction deleteAction() default ForeignKeyAction.UNSPECIFIED; - /** - * Detail definition of the join column(s). This is needed for more than one join column. - * - * @return the join columns - */ - Column[] columns() default {}; + /** Detail definition of the join column(s). This is needed for + * more than one join column. + * @return the join columns + */ + Column[] columns() default {}; - /** - * Generate or assume a primary key constraint exists on the column or columns associated with - * this join. Specify "true" or "false". - * - * @return whether to generate or assume a primary key constraint - */ - String generatePrimaryKey() default ""; + /** Generate or assume a primary key constraint exists on the column + * or columns associated with this join. Specify "true" or "false". + * @return whether to generate or assume a primary key constraint + */ + String generatePrimaryKey() default ""; - /** - * Name for a generated primary key constraint. - * - * @return the name of the generated primary key constraint - */ - String primaryKey() default ""; + /** Name for a generated primary key constraint. + * @return the name of the generated primary key constraint + */ + String primaryKey() default ""; - /** - * Generate or assume a foreign key constraint exists on the column or columns associated with - * this join. Specify "true" or "false". - * - * @return whether to generate or assume a foreign key constraint - */ - String generateForeignKey() default ""; + /** Generate or assume a foreign key constraint exists on the column + * or columns associated with this join. Specify "true" or "false". + * @return whether to generate or assume a foreign key constraint + */ + String generateForeignKey() default ""; - /** - * Name for a generated foreign key constraint. - * - * @return the name of the generated foreign key constraint - */ - String foreignKey() default ""; + /** Name for a generated foreign key constraint. + * @return the name of the generated foreign key constraint + */ + String foreignKey() default ""; - /** - * Vendor extensions. - * - * @return the vendor extensions - */ - Extension[] extensions() default {}; + /** Vendor extensions. + * @return the vendor extensions + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/javax/jdo/annotations/Joins.java b/api/src/main/java/javax/jdo/annotations/Joins.java index 43bd4489f..41eb039ae 100644 --- a/api/src/main/java/javax/jdo/annotations/Joins.java +++ b/api/src/main/java/javax/jdo/annotations/Joins.java @@ -23,19 +23,20 @@ /** * Annotation for a group of joins. - * + * * @version 2.1 * @since 2.1 */ -@Target(ElementType.TYPE) +@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -public @interface Joins { - /** - * The join definitions used for the mapping of this type. Joins for secondary tables are usually - * defined at the type level and not the field or property level. This allows multiple fields and - * properties to share the same join definition and avoid redundancies. - * - * @return the join definitions - */ - Join[] value(); +public @interface Joins +{ + /** + * The join definitions used for the mapping of this type. Joins for + * secondary tables are usually defined at the type level and not the + * field or property level. This allows multiple fields and properties + * to share the same join definition and avoid redundancies. + * @return the join definitions + */ + Join[] value(); } diff --git a/api/src/main/java/javax/jdo/annotations/Key.java b/api/src/main/java/javax/jdo/annotations/Key.java index e6702d6e2..e9c76e6f3 100644 --- a/api/src/main/java/javax/jdo/annotations/Key.java +++ b/api/src/main/java/javax/jdo/annotations/Key.java @@ -20,162 +20,142 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; + import javax.jdo.AttributeConverter; import javax.jdo.AttributeConverter.UseDefault; /** - * Annotation for the key of a map relation. Corresponds to the xml element "key". - * + * Annotation for the key of a map relation. + * Corresponds to the xml element "key". + * * @version 2.1 * @since 2.1 */ -@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) +@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) -public @interface Key { - /** - * Types of the keys. This can be determined if using JDK1.5 generics but is required otherwise. - * Multiple types can be specified if the implementation supports multiple types. - * - * @return the types of keys - */ - Class[] types() default {}; - - /** - * Whether the key is to be stored serialized (into a single column of a join table). - * - * @return whether the key is to be stored serialized - */ - String serialized() default ""; - - /** - * Whether this key is embedded. - * - * @return whether this key is embedded - */ - String embedded() default ""; - - /** - * The embedded mapping for the key. - * - * @return the embedded mapping for the key - */ - Embedded[] embeddedMapping() default {}; - - /** - * Whether the key is dependent on the owner (and will be deleted when the owner is deleted). - * - * @return whether the key is dependent on the owner - */ - String dependent() default ""; - - /** - * Name of the table for the key. - * - * @return name of the table for the key - */ - String table() default ""; - - /** - * Name of the column to store the key in. - * - * @return name of the column to store the key in - */ - String column() default ""; - - /** - * Delete action to apply to the foreign key for the key. - * - * @return delete action to apply to the foreign key for the key - */ - ForeignKeyAction deleteAction() default ForeignKeyAction.UNSPECIFIED; - - /** - * Update action to apply to the foreign key for the key. - * - * @return update action to apply to the foreign key for the key - */ - ForeignKeyAction updateAction() default ForeignKeyAction.UNSPECIFIED; - - /** - * Whether the value column(s) should be indexed. - * - * @return whether the value column(s) should be indexed. - */ - String indexed() default ""; - - /** - * The name of the index to generate. - * - * @return the name of the index - */ - String index() default ""; - - /** - * Whether the element column(s) contents should be considered unique - * - * @return whether the element column(s) contents should be considered unique - */ - String unique() default ""; - - /** - * The name of the unique key constraint to generate. - * - * @return the name of the unique key constraint - */ - String uniqueKey() default ""; - - /** - * Name of a member in the value class where this key is stored. - * - * @return the name of a member in the value class where this key is stored - */ - String mappedBy() default ""; - - /** - * The column(s) for the key - * - * @return the column(s) for the key - */ - Column[] columns() default {}; - - /** - * Generate or assume a foreign key constraint exists on the column or columns associated with - * this join. Specify "true" or "false". - * - * @return whether to generate or assume a foreign key constraint - */ - String generateForeignKey() default ""; - - /** - * Name for a generated foreign key constraint. - * - * @return the name of the generated foreign key constraint - */ - String foreignKey() default ""; - - /** - * Optional {@link AttributeConverter} to use for converting this key. - * - * @return Optional converter class for converting this key (when non-PersistenceCapable) - */ - @SuppressWarnings("rawtypes") - Class converter() default - UseDefault.class; // TODO Current JDK doesn't allow "default null" - - /** - * Whether we should disable any converter that was specified as default for this type on the PMF. - * Only has any effect when this is explicitly set to true, when any AttributeConverter specified - * for this type either here or for the class or at the PMF will be ignored and will use the JDO - * implementation default handling. - * - * @return Whether PMF attribute conversion is to be disabled. - */ - boolean useDefaultConversion() default false; // TODO Current JDK doesn't allow "default null" - - /** - * Vendor extensions. - * - * @return the vendor extensions - */ - Extension[] extensions() default {}; +public @interface Key +{ + /** + * Types of the keys. This can be determined if using JDK1.5 generics + * but is required otherwise. Multiple types can be specified if the + * implementation supports multiple types. + * @return the types of keys + */ + Class[] types() default {}; + + /** + * Whether the key is to be stored serialized (into a single column of a + * join table). + * @return whether the key is to be stored serialized + */ + String serialized() default ""; + + /** Whether this key is embedded. + * @return whether this key is embedded + */ + String embedded() default ""; + + /** + * The embedded mapping for the key. + * @return the embedded mapping for the key + */ + Embedded[] embeddedMapping() default {}; + + /** + * Whether the key is dependent on the owner (and will be deleted + * when the owner is deleted). + * @return whether the key is dependent on the owner + */ + String dependent() default ""; + + /** + * Name of the table for the key. + * @return name of the table for the key + */ + String table() default ""; + + /** + * Name of the column to store the key in. + * @return name of the column to store the key in + */ + String column() default ""; + + /** + * Delete action to apply to the foreign key for the key. + * @return delete action to apply to the foreign key for the key + */ + ForeignKeyAction deleteAction() default ForeignKeyAction.UNSPECIFIED; + + /** + * Update action to apply to the foreign key for the key. + * @return update action to apply to the foreign key for the key + */ + ForeignKeyAction updateAction() default ForeignKeyAction.UNSPECIFIED; + + /** + * Whether the value column(s) should be indexed. + * @return whether the value column(s) should be indexed. + */ + String indexed() default ""; + + /** The name of the index to generate. + * @return the name of the index + */ + String index() default ""; + + /** + * Whether the element column(s) contents should be considered unique + * @return whether the element column(s) contents should be considered unique + */ + String unique() default ""; + + /** + * The name of the unique key constraint to generate. + * @return the name of the unique key constraint + */ + String uniqueKey() default ""; + + /** + * Name of a member in the value class where this key is stored. + * @return the name of a member in the value class where this key is stored + */ + String mappedBy() default ""; + + /** + * The column(s) for the key + * @return the column(s) for the key + */ + Column[] columns() default {}; + + /** Generate or assume a foreign key constraint exists on the column + * or columns associated with this join. Specify "true" or "false". + * @return whether to generate or assume a foreign key constraint + */ + String generateForeignKey() default ""; + + /** Name for a generated foreign key constraint. + * @return the name of the generated foreign key constraint + */ + String foreignKey() default ""; + + /** + * Optional {@link AttributeConverter} to use for converting this key. + * @return Optional converter class for converting this key (when non-PersistenceCapable) + */ + @SuppressWarnings("rawtypes") + Class converter() default UseDefault.class; // TODO Current JDK doesn't allow "default null" + + /** + * Whether we should disable any converter that was specified as default for this type on the PMF. + * Only has any effect when this is explicitly set to true, when any AttributeConverter specified for this type + * either here or for the class or at the PMF will be ignored and will use the JDO implementation default handling. + * @return Whether PMF attribute conversion is to be disabled. + */ + boolean useDefaultConversion() default false; // TODO Current JDK doesn't allow "default null" + + /** + * Vendor extensions. + * @return the vendor extensions + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/javax/jdo/annotations/NotPersistent.java b/api/src/main/java/javax/jdo/annotations/NotPersistent.java index bccc77933..299148d7e 100644 --- a/api/src/main/java/javax/jdo/annotations/NotPersistent.java +++ b/api/src/main/java/javax/jdo/annotations/NotPersistent.java @@ -22,13 +22,15 @@ import java.lang.annotation.Target; /** - * Annotation to specify that the member is not persistent. If used, this is the only JDO annotation - * allowed on a member. This corresponds to the xml attribute persistence-modifier="none" of the + * Annotation to specify that the member is not persistent. If used, this is + * the only JDO annotation allowed on a member. + * This corresponds to the xml attribute persistence-modifier="none" of the * "field" and "property" elements. - * * @version 2.1 * @since 2.1 */ -@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) +@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) -public @interface NotPersistent {} +public @interface NotPersistent +{ +} diff --git a/api/src/main/java/javax/jdo/annotations/NullValue.java b/api/src/main/java/javax/jdo/annotations/NullValue.java index f06d481f0..896520ce9 100644 --- a/api/src/main/java/javax/jdo/annotations/NullValue.java +++ b/api/src/main/java/javax/jdo/annotations/NullValue.java @@ -17,14 +17,16 @@ package javax.jdo.annotations; /** - * Enumeration of the "null-value" behavior values. This corresponds to the "null-value" attribute - * of the "field" and "property" elements. + * Enumeration of the "null-value" behavior values. + * This corresponds to the "null-value" attribute of the "field" + * and "property" elements. * * @version 2.1 * @since 2.1 */ -public enum NullValue { - NONE, - EXCEPTION, - DEFAULT +public enum NullValue +{ + NONE, + EXCEPTION, + DEFAULT } diff --git a/api/src/main/java/javax/jdo/annotations/Order.java b/api/src/main/java/javax/jdo/annotations/Order.java index 8e53e81a4..3d76e451c 100644 --- a/api/src/main/java/javax/jdo/annotations/Order.java +++ b/api/src/main/java/javax/jdo/annotations/Order.java @@ -22,42 +22,40 @@ import java.lang.annotation.Target; /** - * Annotation for the ordering component of an ordered container member, such as Java Collections - * Framework Array and List types and Java native array types. Corresponds to the xml element - * "order". - * + * Annotation for the ordering component of an ordered container member, + * such as Java Collections Framework Array and List types and Java native + * array types. + * Corresponds to the xml element "order". + * * @version 2.1 * @since 2.1 */ -@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) +@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) -public @interface Order { - /** - * The name of the column to use for ordering the elements of the member. - * - * @return the name of the ordering column - */ - String column() default ""; +public @interface Order +{ + /** + * The name of the column to use for ordering the elements of the member. + * @return the name of the ordering column + */ + String column() default ""; - /** - * Name of a field or property in the target class that acts as the ordering field or property for - * this member. - * - * @return the name of the field or property in the target class - */ - String mappedBy() default ""; + /** + * Name of a field or property in the target class that acts as the + * ordering field or property for this member. + * @return the name of the field or property in the target class + */ + String mappedBy() default ""; - /** - * The definition of the column(s) to use for ordering. - * - * @return the columns to use for ordering - */ - Column[] columns() default {}; + /** + * The definition of the column(s) to use for ordering. + * @return the columns to use for ordering + */ + Column[] columns() default {}; - /** - * Vendor extensions. - * - * @return the vendor extensions - */ - Extension[] extensions() default {}; + /** + * Vendor extensions. + * @return the vendor extensions + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/javax/jdo/annotations/PersistenceAware.java b/api/src/main/java/javax/jdo/annotations/PersistenceAware.java index d8ad3f9cb..1692dceec 100644 --- a/api/src/main/java/javax/jdo/annotations/PersistenceAware.java +++ b/api/src/main/java/javax/jdo/annotations/PersistenceAware.java @@ -22,13 +22,15 @@ import java.lang.annotation.Target; /** - * Annotation to specify that the class is persistence-aware. If used, this is the only JDO - * annotation allowed on the class. This corresponds to the xml attribute + * Annotation to specify that the class is persistence-aware. If used, this is + * the only JDO annotation allowed on the class. + * This corresponds to the xml attribute * persistence-modifier="persistence-aware" of the "class" element. - * * @version 2.1 * @since 2.1 */ -@Target(ElementType.TYPE) +@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -public @interface PersistenceAware {} +public @interface PersistenceAware +{ +} diff --git a/api/src/main/java/javax/jdo/annotations/PersistenceCapable.java b/api/src/main/java/javax/jdo/annotations/PersistenceCapable.java index 887f33376..f7c438edb 100644 --- a/api/src/main/java/javax/jdo/annotations/PersistenceCapable.java +++ b/api/src/main/java/javax/jdo/annotations/PersistenceCapable.java @@ -23,98 +23,86 @@ /** * Annotation for whether the class or interface is persistence-capable. - * + * * @version 2.1 * @since 2.1 */ -@Target(ElementType.TYPE) +@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -public @interface PersistenceCapable { - /** - * Member declarations. Annotations for persistent members of this class or interface can be - * specifed either here or on each member. Annotations for inherited members can only be specified - * here. - * - * @return member declarations - */ - Persistent[] members() default {}; +public @interface PersistenceCapable +{ + /** Member declarations. Annotations for persistent members of this + * class or interface can be specifed either here or on each member. + * Annotations for inherited members can only be specified here. + * @return member declarations + */ + Persistent[] members() default {}; - /** - * Table to use for persisting this class or interface. - * - * @return The table - */ - String table() default ""; + /** + * Table to use for persisting this class or interface. + * @return The table + */ + String table() default ""; - /** - * Catalog to use for persisting this class or interface. - * - * @return The catalog - */ - String catalog() default ""; + /** + * Catalog to use for persisting this class or interface. + * @return The catalog + */ + String catalog() default ""; - /** - * Schema to use for persisting this class or interface. - * - * @return The schema - */ - String schema() default ""; + /** + * Schema to use for persisting this class or interface. + * @return The schema + */ + String schema() default ""; - /** - * Whether this class or interface manages an extent. - * - * @return Whether an extent is required - */ - String requiresExtent() default ""; + /** + * Whether this class or interface manages an extent. + * @return Whether an extent is required + */ + String requiresExtent() default ""; - /** - * Whether objects of this class or interface can only be embedded. - * - * @return Whether this is embedded only - */ - String embeddedOnly() default ""; + /** + * Whether objects of this class or interface can only be embedded. + * @return Whether this is embedded only + */ + String embeddedOnly() default ""; - /** - * Whether this class or interface is detachable. - * - * @return Whether this is detachable - */ - String detachable() default ""; + /** + * Whether this class or interface is detachable. + * @return Whether this is detachable + */ + String detachable() default ""; - /** - * Type of identity for this class or interface. - * - * @return The identity type for this class - */ - IdentityType identityType() default IdentityType.UNSPECIFIED; + /** + * Type of identity for this class or interface. + * @return The identity type for this class + */ + IdentityType identityType() default IdentityType.UNSPECIFIED; - /** - * Primary key class when using application identity and using own PK. - * - * @return Object-id class (if specified) - */ - Class objectIdClass() default void.class; + /** + * Primary key class when using application identity and using own PK. + * @return Object-id class (if specified) + */ + Class objectIdClass() default void.class; - /** - * Whether this class is cacheable in a Level2 cache. - * - * @return Whether the class is L2 cacheable - * @since 2.2 - */ - String cacheable() default "true"; + /** + * Whether this class is cacheable in a Level2 cache. + * @return Whether the class is L2 cacheable + * @since 2.2 + */ + String cacheable() default "true"; - /** - * Whether objects of this type should, by default, be locked when read. - * - * @return Whether we should lock this type of object by default - * @since 3.0 - */ - String serializeRead() default "false"; + /** + * Whether objects of this type should, by default, be locked when read. + * @return Whether we should lock this type of object by default + * @since 3.0 + */ + String serializeRead() default "false"; - /** - * Any vendor extensions. - * - * @return The extensions defined for this class - */ - Extension[] extensions() default {}; + /** + * Any vendor extensions. + * @return The extensions defined for this class + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/javax/jdo/annotations/PersistenceModifier.java b/api/src/main/java/javax/jdo/annotations/PersistenceModifier.java index f133f76f7..04616e93b 100644 --- a/api/src/main/java/javax/jdo/annotations/PersistenceModifier.java +++ b/api/src/main/java/javax/jdo/annotations/PersistenceModifier.java @@ -17,15 +17,17 @@ package javax.jdo.annotations; /** - * Enumeration of the persistence-modifier values for a field or property. This corresponds to the - * "persistence-modifier" attribute of the "field" and "property" elements. - * + * Enumeration of the persistence-modifier values for a field or property. + * This corresponds to the "persistence-modifier" attribute of the + * "field" and "property" elements. + * * @version 2.1 * @since 2.1 */ -public enum PersistenceModifier { - UNSPECIFIED, - PERSISTENT, - TRANSACTIONAL, - NONE +public enum PersistenceModifier +{ + UNSPECIFIED, + PERSISTENT, + TRANSACTIONAL, + NONE } diff --git a/api/src/main/java/javax/jdo/annotations/Persistent.java b/api/src/main/java/javax/jdo/annotations/Persistent.java index 7b2cca444..46e24690d 100644 --- a/api/src/main/java/javax/jdo/annotations/Persistent.java +++ b/api/src/main/java/javax/jdo/annotations/Persistent.java @@ -20,264 +20,218 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; + import javax.jdo.AttributeConverter; import javax.jdo.AttributeConverter.UseDefault; /** - * Annotation for defining the persistence of a member. This corresponds to the xml elements "field" - * and "property". - * + * Annotation for defining the persistence of a member. + * This corresponds to the xml elements "field" and "property". + * * @version 2.1 * @since 2.1 */ -@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) +@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) -public @interface Persistent { - /** - * Modifier for this field. This is normally not specified, and the defaults are used, or - * the @Transactional or @NotPersistent annotation is specified directly on the member. One - * possible use for specifying persistenceModifier is for embedded instances in which a member is - * not persistent but in the non-embedded instances the member is persistent. Note that it is not - * portable to specify a member to be not persistent in the non-embedded case and persistent in - * the embedded usage. - * - * @return the persistence modifier - */ - PersistenceModifier persistenceModifier() default PersistenceModifier.UNSPECIFIED; - - /** - * Table to use for persisting this member. - * - * @return the table to use for persisting this member - */ - String table() default ""; - - /** - * Whether this member is in the default fetch group. - * - * @return whether this member is in the default fetch group - */ - String defaultFetchGroup() default ""; - - /** - * Behavior when this member contains a null value. - * - * @return the behavior when this member contains a null value - */ - NullValue nullValue() default NullValue.NONE; - - /** - * Whether this member is embedded. - * - * @return whether this member is embedded - */ - String embedded() default ""; - - /** - * Whether the elements of this member are embedded. - * - * @return whether the elements of this member are embedded - */ - String embeddedElement() default ""; - - /** - * Whether the keys of this member are embedded. - * - * @return whether the keys of this member are embedded - */ - String embeddedKey() default ""; - - /** - * Whether the values of this member are embedded. - * - * @return whether the values of this member are embedded - */ - String embeddedValue() default ""; - - /** - * Whether this member is serialized into a single column. - * - * @return whether this member is serialized into a single column - */ - String serialized() default ""; - - /** - * Whether the elements of this member are serialized. - * - * @return whether the elements of this member are serialized - */ - String serializedElement() default ""; - - /** - * Whether the keys of this member are serialized. - * - * @return whether the keys of this member are serialized - */ - String serializedKey() default ""; - - /** - * Whether the values of this member are serialized. - * - * @return whether the values of this member are serialized - */ - String serializedValue() default ""; - - /** - * Whether related object(s) of this member are dependent and so deleted when this object is - * deleted. - * - * @return whether the related object(s) of this member are dependent - */ - String dependent() default ""; - - /** - * Whether the elements of this member are dependent. - * - * @return whether the elements of this member are dependent - */ - String dependentElement() default ""; - - /** - * Whether the keys of this member are dependent. - * - * @return whether the keys of this member are dependent - */ - String dependentKey() default ""; - - /** - * Whether the values of this member are dependent. - * - * @return whether the values of this member are dependent - */ - String dependentValue() default ""; - - /** - * Whether this member is part of the primary key for application identity. This is equivalent to - * specifying @PrimaryKey as a separate annotation on the member. - * - * @return whether this member is part of the primary key - */ - String primaryKey() default ""; - - /** - * Value strategy to use to generate the value for this field or property (if any). - * - * @return the generated value strategy - */ - IdGeneratorStrategy valueStrategy() default IdGeneratorStrategy.UNSPECIFIED; - - /** - * Custom value strategy to use to generate the value for this field or property (if any). If - * customValueStrategy is non-empty, then valueStrategy must be UNSPECIFIED. - * - * @return the custom value strategy - */ - String customValueStrategy() default ""; - - /** - * Name of the sequence to use with particular value strategies. - * - * @return the name of the sequence - */ - String sequence() default ""; - - /** - * Name of the fetch-group to use when this member is loaded due to being referenced when not - * already loaded. - * - * @return the name of the load fetch group - */ - String loadFetchGroup() default ""; - - /** - * Types of the member. Used when the declared member type is a supertype of the actual type that - * is stored in the member. For example, the declared member type might be an interface type that - * must contain an object of a concrete type when used for persistence. - * - * @return the types - */ - Class[] types() default {}; - - /** - * Name of the related member in the other class where this value is mapped (bidirectional - * relationship). - * - * @return the related member in the other class - */ - String mappedBy() default ""; - - /** - * Column definition(s) for this member. Used for mapping multiple columns to the same member, for - * example relationships with multiple column foreign keys. - * - * @return the columns for this member - */ - Column[] columns() default {}; - - /** - * Column name where the values are stored for this member. - * - * @return the name of the column - */ - String column() default ""; - - /** - * Null indicator column for this member. Used for nested embedded fields or properties to - * indicate whether the embedded instance should have a null value. - * - * @return the null indicator column - */ - String nullIndicatorColumn() default ""; - - /** - * Name of the member when this is embedded in another object. The fully-qualified member name is - * used. For example, "line.point1.x" refers to the member x in class Point that is embedded as - * member point1 in class Line that is embedded in a member called line. - * - * @return the name of the member - */ - String name() default ""; - - /** - * Recursion depth for this member. Used only when the annotation is used within the definition of - * a FetchGroup. - * - * @return the recursion depth - */ - int recursionDepth() default 1; - - /** - * Whether this field/property is cacheable in a Level2 cache. - * - * @return Whether the field is L2 cacheable - * @since 2.2 - */ - String cacheable() default "true"; - - /** - * Optional {@link AttributeConverter} to use for converting this member. - * - * @return Converter class for converting this member when not PersistenceCapable (or - * NullAttributeConverter when not specified). - */ - @SuppressWarnings("rawtypes") - Class converter() default - UseDefault.class; // TODO Current JDK doesn't allow "default null" - - /** - * Whether we should disable any converter that was specified as default for this type on the PMF. - * Only has any effect when this is explicitly set to true, when any AttributeConverter specified - * for this type either here or for the class or at the PMF will be ignored and will use the JDO - * implementation default handling. - * - * @return Whether PMF attribute conversion is to be disabled. - */ - boolean useDefaultConversion() default false; // TODO Current JDK doesn't allow "default null" - - /** - * Vendor extensions for this member. - * - * @return the vendor extensions - */ - Extension[] extensions() default {}; +public @interface Persistent +{ + /** Modifier for this field. This is normally not specified, and the + * defaults are used, or the @Transactional or @NotPersistent + * annotation is specified directly on the member. One possible use + * for specifying persistenceModifier is for embedded instances in which + * a member is not persistent but in the non-embedded instances the + * member is persistent. Note that it is not portable to specify a + * member to be not persistent in the non-embedded case and persistent + * in the embedded usage. + * @return the persistence modifier + */ + PersistenceModifier persistenceModifier() + default PersistenceModifier.UNSPECIFIED; + + /** Table to use for persisting this member. + * @return the table to use for persisting this member + */ + String table() default ""; + + /** Whether this member is in the default fetch group. + * @return whether this member is in the default fetch group + */ + String defaultFetchGroup() default ""; + + /** Behavior when this member contains a null value. + * @return the behavior when this member contains a null value + */ + NullValue nullValue() default NullValue.NONE; + + /** Whether this member is embedded. + * @return whether this member is embedded + */ + String embedded() default ""; + + /** Whether the elements of this member are embedded. + * @return whether the elements of this member are embedded + */ + String embeddedElement() default ""; + + /** Whether the keys of this member are embedded. + * @return whether the keys of this member are embedded + */ + String embeddedKey() default ""; + + /** Whether the values of this member are embedded. + * @return whether the values of this member are embedded + */ + String embeddedValue() default ""; + + /** Whether this member is serialized into a single column. + * @return whether this member is serialized into a single column + */ + String serialized() default ""; + + /** Whether the elements of this member are serialized. + * @return whether the elements of this member are serialized + */ + String serializedElement() default ""; + + /** Whether the keys of this member are serialized. + * @return whether the keys of this member are serialized + */ + String serializedKey() default ""; + + /** Whether the values of this member are serialized. + * @return whether the values of this member are serialized + */ + String serializedValue() default ""; + + /** Whether related object(s) of this member are dependent + * and so deleted when this object is deleted. + * @return whether the related object(s) of this member + * are dependent + */ + String dependent() default ""; + + /** Whether the elements of this member are dependent. + * @return whether the elements of this member are dependent + */ + String dependentElement() default ""; + + /** Whether the keys of this member are dependent. + * @return whether the keys of this member are dependent + */ + String dependentKey() default ""; + + /** Whether the values of this member are dependent. + * @return whether the values of this member are dependent + */ + String dependentValue() default ""; + + /** Whether this member is part of the primary key for application + * identity. This is equivalent to specifying @PrimaryKey as + * a separate annotation on the member. + * @return whether this member is part of the primary key + */ + String primaryKey() default ""; + + /** Value strategy to use to generate the value for this field + * or property (if any). + * @return the generated value strategy + */ + IdGeneratorStrategy valueStrategy() default IdGeneratorStrategy.UNSPECIFIED; + + /** Custom value strategy to use to generate the value for this field + * or property (if any). If customValueStrategy is non-empty, then + * valueStrategy must be UNSPECIFIED. + * @return the custom value strategy + */ + String customValueStrategy() default ""; + + /** Name of the sequence to use with particular value strategies. + * @return the name of the sequence + */ + String sequence() default ""; + + /** Name of the fetch-group to use when this member is loaded + * due to being referenced when not already loaded. + * @return the name of the load fetch group + */ + String loadFetchGroup() default ""; + + /** Types of the member. Used when the declared + * member type is a supertype of the actual type that is stored in the + * member. For example, the declared member type might be an interface type + * that must contain an object of a concrete type when used + * for persistence. + * @return the types + */ + Class[] types() default {}; + + /** Name of the related member in the other class + * where this value is mapped (bidirectional relationship). + * @return the related member in the other class + */ + String mappedBy() default ""; + + /** Column definition(s) for this member. Used for mapping + * multiple columns + * to the same member, for example relationships with + * multiple column foreign keys. + * @return the columns for this member + */ + Column[] columns() default {}; + + /** Column name where the values are stored for this member. + * @return the name of the column + */ + String column() default ""; + + /** Null indicator column for this member. Used for nested + * embedded fields or properties to indicate whether the embedded + * instance should have a null value. + * @return the null indicator column + */ + String nullIndicatorColumn() default ""; + + /** Name of the member when this is embedded in another object. + * The fully-qualified member name is used. For example, + * "line.point1.x" refers to the member x in class Point + * that is embedded as member point1 in class Line that is embedded + * in a member called line. + * @return the name of the member + */ + String name() default ""; + + /** + * Recursion depth for this member. Used only when + * the annotation is used within the definition of a FetchGroup. + * @return the recursion depth + */ + int recursionDepth() default 1; + + /** + * Whether this field/property is cacheable in a Level2 cache. + * @return Whether the field is L2 cacheable + * @since 2.2 + */ + String cacheable() default "true"; + + /** + * Optional {@link AttributeConverter} to use for converting this member. + * @return Converter class for converting this member when not PersistenceCapable + * (or NullAttributeConverter when not specified). + */ + @SuppressWarnings("rawtypes") + Class converter() default UseDefault.class; // TODO Current JDK doesn't allow "default null" + + /** + * Whether we should disable any converter that was specified as default for this type on the PMF. + * Only has any effect when this is explicitly set to true, when any AttributeConverter specified for this type + * either here or for the class or at the PMF will be ignored and will use the JDO implementation default handling. + * @return Whether PMF attribute conversion is to be disabled. + */ + boolean useDefaultConversion() default false; // TODO Current JDK doesn't allow "default null" + + /** Vendor extensions for this member. + * @return the vendor extensions + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/javax/jdo/annotations/PrimaryKey.java b/api/src/main/java/javax/jdo/annotations/PrimaryKey.java index dfae70d75..d866ef0b2 100644 --- a/api/src/main/java/javax/jdo/annotations/PrimaryKey.java +++ b/api/src/main/java/javax/jdo/annotations/PrimaryKey.java @@ -22,41 +22,38 @@ import java.lang.annotation.Target; /** - * Annotation on a member to define it as a primary key member of a class or persistent interface - * using application identity. Also used to define the primary key columns of a secondary table. + * Annotation on a member to define it as a primary key member of a class or + * persistent interface using application identity. + * Also used to define the primary key columns of a secondary table. * Corresponds to the xml element "primary-key". - * + * * @version 2.1 * @since 2.1 */ -@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) -public @interface PrimaryKey { - /** - * Name of the primary key constraint - * - * @return the name of the primary key constraint - */ - String name() default ""; +public @interface PrimaryKey +{ + /** + * Name of the primary key constraint + * @return the name of the primary key constraint + */ + String name() default ""; - /** - * Name of the column to use for the primary key - * - * @return the name of the column to use for the primary key - */ - String column() default ""; + /** + * Name of the column to use for the primary key + * @return the name of the column to use for the primary key + */ + String column() default ""; - /** - * The column(s) for the primary key - * - * @return the column(s) for the primary key - */ - Column[] columns() default {}; + /** + * The column(s) for the primary key + * @return the column(s) for the primary key + */ + Column[] columns() default {}; - /** - * Vendor extensions. - * - * @return the vendor extensions - */ - Extension[] extensions() default {}; + /** Vendor extensions. + * @return the vendor extensions + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/javax/jdo/annotations/Queries.java b/api/src/main/java/javax/jdo/annotations/Queries.java index 1ae897e83..b96efddea 100644 --- a/api/src/main/java/javax/jdo/annotations/Queries.java +++ b/api/src/main/java/javax/jdo/annotations/Queries.java @@ -23,17 +23,17 @@ /** * Annotation for a group of named queries. - * + * * @version 2.1 * @since 2.1 */ -@Target(ElementType.TYPE) +@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -public @interface Queries { - /** - * The named queries - * - * @return The named queries - */ - Query[] value(); +public @interface Queries +{ + /** + * The named queries + * @return The named queries + */ + Query[] value(); } diff --git a/api/src/main/java/javax/jdo/annotations/Query.java b/api/src/main/java/javax/jdo/annotations/Query.java index 29a3db2d6..c5c652c9b 100644 --- a/api/src/main/java/javax/jdo/annotations/Query.java +++ b/api/src/main/java/javax/jdo/annotations/Query.java @@ -23,68 +23,54 @@ import java.lang.annotation.Target; /** - * Annotation for a named query. Corresponds to the xml element "query". - * + * Annotation for a named query. + * Corresponds to the xml element "query". + * * @version 3.2 * @since 2.1 */ -@Target(ElementType.TYPE) +@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Repeatable(Queries.class) -public @interface Query { - /** - * Name of the query (mandatory) - * - * @return the name of the query - */ - String name(); +public @interface Query +{ + /** Name of the query (mandatory) + * @return the name of the query + */ + String name(); - /** - * The query string (mandatory) - * - * @return the query string - */ - String value(); + /** The query string (mandatory) + * @return the query string + */ + String value(); - /** - * The query language - * - * @return the query language - */ - String language() default "JDOQL"; + /** The query language + * @return the query language + */ + String language() default "JDOQL"; - /** - * Whether the query is unmodifiable. - * - * @return whether the query is unmodifiable - */ - String unmodifiable() default ""; + /** Whether the query is unmodifiable. + * @return whether the query is unmodifiable + */ + String unmodifiable() default ""; - /** - * Whether the query returns a single unique result. - * - * @return whether the query returns a single unique result - */ - String unique() default ""; + /** Whether the query returns a single unique result. + * @return whether the query returns a single unique result + */ + String unique() default ""; - /** - * Result class into which to put the results. - * - * @return the class of the result - */ - Class resultClass() default void.class; + /** Result class into which to put the results. + * @return the class of the result + */ + Class resultClass() default void.class; - /** - * The name of the fetch plan used by this query - * - * @return the fetch plan - */ - String fetchPlan() default ""; + /** The name of the fetch plan used by this query + * @return the fetch plan + */ + String fetchPlan() default ""; - /** - * Vendor extensions. - * - * @return the vendor extensions - */ - Extension[] extensions() default {}; + /** Vendor extensions. + * @return the vendor extensions + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/javax/jdo/annotations/Sequence.java b/api/src/main/java/javax/jdo/annotations/Sequence.java index e767a2da0..945443484 100644 --- a/api/src/main/java/javax/jdo/annotations/Sequence.java +++ b/api/src/main/java/javax/jdo/annotations/Sequence.java @@ -22,62 +22,52 @@ import java.lang.annotation.Target; /** - * Annotation for a datastore sequence. Maps across to the JDO2 element "sequence". - * + * Annotation for a datastore sequence. + * Maps across to the JDO2 element "sequence". + * * @version 2.1 * @since 2.1 */ -@Target(ElementType.TYPE) +@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -public @interface Sequence { - /** - * The symbolic name of the datastore sequence. - * - * @return the name of the sequence - */ - String name(); +public @interface Sequence +{ + /** The symbolic name of the datastore sequence. + * @return the name of the sequence + */ + String name(); - /** - * Strategy for the sequence. - * - * @return the strategy for the sequence - */ - SequenceStrategy strategy(); + /** Strategy for the sequence. + * @return the strategy for the sequence + */ + SequenceStrategy strategy(); - /** - * Name of the sequence in the datastore. - * - * @return the name of the datastore sequence - */ - String datastoreSequence() default ""; + /** Name of the sequence in the datastore. + * @return the name of the datastore sequence + */ + String datastoreSequence() default ""; - /** - * Name of a factory class for generating the sequence values. - * - * @return the name of the factory class for the sequence - */ - Class factoryClass() default void.class; + /** Name of a factory class for generating the sequence values. + * @return the name of the factory class for the sequence + */ + Class factoryClass() default void.class; - /** - * Vendor extensions for this sequence. - * - * @return vendor extensions - */ - Extension[] extensions() default {}; + /** Vendor extensions for this sequence. + * @return vendor extensions + */ + Extension[] extensions() default {}; - /** - * Initial value for the sequence. - * - * @return Initial value for the sequence - * @since 3.1 - */ - int initialValue() default 1; + /** + * Initial value for the sequence. + * @return Initial value for the sequence + * @since 3.1 + */ + int initialValue() default 1; - /** - * Allocation size for the sequence. - * - * @return Allocation size for the sequence - * @since 3.1 - */ - int allocationSize() default 50; + /** + * Allocation size for the sequence. + * @return Allocation size for the sequence + * @since 3.1 + */ + int allocationSize() default 50; } diff --git a/api/src/main/java/javax/jdo/annotations/SequenceStrategy.java b/api/src/main/java/javax/jdo/annotations/SequenceStrategy.java index c27aff983..a5b9ae138 100644 --- a/api/src/main/java/javax/jdo/annotations/SequenceStrategy.java +++ b/api/src/main/java/javax/jdo/annotations/SequenceStrategy.java @@ -18,12 +18,13 @@ /** * Enumeration of the sequence strategy values. - * + * * @version 2.1 * @since 2.1 */ -public enum SequenceStrategy { - NONTRANSACTIONAL, - CONTIGUOUS, - NONCONTIGUOUS +public enum SequenceStrategy +{ + NONTRANSACTIONAL, + CONTIGUOUS, + NONCONTIGUOUS } diff --git a/api/src/main/java/javax/jdo/annotations/Serialized.java b/api/src/main/java/javax/jdo/annotations/Serialized.java index cf792788f..912519cb4 100644 --- a/api/src/main/java/javax/jdo/annotations/Serialized.java +++ b/api/src/main/java/javax/jdo/annotations/Serialized.java @@ -22,13 +22,18 @@ import java.lang.annotation.Target; /** - * Annotation on a member (field or property) to indicate that the member is stored serialized. Such - * a member cannot be queried using JDOQL. Corresponds to xml attribute "serialized" in "field" and - * "property" elements. This is the same as specifying @Persistent(serialized="true"). - * + * Annotation on a member (field or property) to indicate that + * the member is stored serialized. Such a member cannot be queried using + * JDOQL. + * Corresponds to xml attribute "serialized" in "field" and "property" + * elements. + * This is the same as specifying @Persistent(serialized="true"). + * * @version 2.1 * @since 2.1 */ -@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) +@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) -public @interface Serialized {} +public @interface Serialized +{ +} diff --git a/api/src/main/java/javax/jdo/annotations/Transactional.java b/api/src/main/java/javax/jdo/annotations/Transactional.java index 558a809bd..f045937f4 100644 --- a/api/src/main/java/javax/jdo/annotations/Transactional.java +++ b/api/src/main/java/javax/jdo/annotations/Transactional.java @@ -22,13 +22,15 @@ import java.lang.annotation.Target; /** - * Annotation to indicate that a member (field or property) is transactional but not persistent. - * This corresponds to xml attribute persistence-modifier="transactional" of "field" and "property" - * elements. - * + * Annotation to indicate that a member (field or property) + * is transactional but not persistent. + * This corresponds to xml attribute persistence-modifier="transactional" of + * "field" and "property" elements. * @version 2.1 * @since 2.1 */ -@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) +@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) -public @interface Transactional {} +public @interface Transactional +{ +} diff --git a/api/src/main/java/javax/jdo/annotations/Unique.java b/api/src/main/java/javax/jdo/annotations/Unique.java index 23c452a40..2dbbf84fd 100644 --- a/api/src/main/java/javax/jdo/annotations/Unique.java +++ b/api/src/main/java/javax/jdo/annotations/Unique.java @@ -23,57 +23,48 @@ import java.lang.annotation.Target; /** - * Annotation for a database unique constraint. Used for database schema generation to create unique - * constraints. Also used to reorder database operations when flushing changes to avoid unique - * constraint violations. Corresponds to the xml element "unique". + * Annotation for a database unique constraint. Used for database schema + * generation to create unique constraints. Also used to reorder database + * operations when flushing changes to avoid unique constraint violations. + * Corresponds to the xml element "unique". * * @version 3.2 * @since 2.1 */ -@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @Repeatable(Uniques.class) -public @interface Unique { - /** - * Name of the unique constraint. - * - * @return the name of the unique constraint - */ - String name() default ""; +public @interface Unique +{ + /** Name of the unique constraint. + * @return the name of the unique constraint + */ + String name() default ""; - /** - * Table for the unique constraint. This is needed iff annotating a type where this unique - * constraint is not for the primary table for the persistent class or interface. - * - * @return the table on which the unique constraint is defined - */ - String table() default ""; + /** Table for the unique constraint. This is needed iff annotating a type + * where this unique constraint is not for the primary table for + * the persistent class or interface. + * @return the table on which the unique constraint is defined + */ + String table() default ""; - /** - * Whether this unique constraint is deferred until commit. - * - * @return whether this unique constraint is deferred until commit - */ - String deferred() default ""; + /** Whether this unique constraint is deferred until commit. + * @return whether this unique constraint is deferred until commit + */ + String deferred() default ""; - /** - * Member (field and property) names that compose this unique constraint. - * - * @return member names that compose this unique constraint - */ - String[] members() default {}; + /** Member (field and property) names that compose this unique constraint. + * @return member names that compose this unique constraint + */ + String[] members() default {}; - /** - * Columns that compose this unique constraint. - * - * @return columns that compose this unique constraint - */ - Column[] columns() default {}; + /** Columns that compose this unique constraint. + * @return columns that compose this unique constraint + */ + Column[] columns() default {}; - /** - * Vendor extensions. - * - * @return the vendor extensions - */ - Extension[] extensions() default {}; + /** Vendor extensions. + * @return the vendor extensions + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/javax/jdo/annotations/Uniques.java b/api/src/main/java/javax/jdo/annotations/Uniques.java index da901058d..36ba2a28e 100644 --- a/api/src/main/java/javax/jdo/annotations/Uniques.java +++ b/api/src/main/java/javax/jdo/annotations/Uniques.java @@ -23,17 +23,17 @@ /** * Annotation for a group of unique constraints. - * + * * @version 2.1 * @since 2.1 */ -@Target(ElementType.TYPE) +@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -public @interface Uniques { - /** - * The unique constraints. - * - * @return The unique constraints - */ - Unique[] value(); +public @interface Uniques +{ + /** + * The unique constraints. + * @return The unique constraints + */ + Unique[] value(); } diff --git a/api/src/main/java/javax/jdo/annotations/Value.java b/api/src/main/java/javax/jdo/annotations/Value.java index 912c8d9be..f62884b5a 100644 --- a/api/src/main/java/javax/jdo/annotations/Value.java +++ b/api/src/main/java/javax/jdo/annotations/Value.java @@ -20,163 +20,142 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; + import javax.jdo.AttributeConverter; import javax.jdo.AttributeConverter.UseDefault; /** - * Annotation for the value of a map relation. Corresponds to the xml element "value". - * + * Annotation for the value of a map relation. + * Corresponds to the xml element "value". + * * @version 2.1 * @since 2.1 */ -@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) +@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) -public @interface Value { - /** - * Types of the values. This can be determined if using JDK1.5 generics but is required otherwise. - * Multiple types can be specified if the implementation supports multiple types. - * - * @return the types of values - */ - Class[] types() default {}; - - /** - * Whether the value is to be stored serialized (into a single column of a join table). - * - * @return Whether the value is to be stored serialized (into a join table) - */ - String serialized() default ""; - - /** - * Whether this value is embedded. - * - * @return whether this value is embedded - */ - String embedded() default ""; - - /** - * The embedded mapping for the value. - * - * @return the embedded mapping for the value - */ - Embedded[] embeddedMapping() default {}; - - /** - * Whether the value is dependent on the owner (and will be deleted when the owner is deleted). - * - * @return whether the value is dependent on the owner - */ - String dependent() default ""; - - /** - * Name of the table for the value. - * - * @return the name of the table for the value - */ - String table() default ""; - - /** - * Name of the column to store the value in. - * - * @return the name of the column to store the value in - */ - String column() default ""; - - /** - * Delete action to apply to any foreign key for the value. - * - * @return delete action to apply to any foreign key for the value - */ - ForeignKeyAction deleteAction() default ForeignKeyAction.UNSPECIFIED; - - /** - * Update action to apply to any foreign key for the value. - * - * @return update action to apply to any foreign key for the value - */ - ForeignKeyAction updateAction() default ForeignKeyAction.UNSPECIFIED; - - /** - * Whether the value column(s) should be indexed. - * - * @return whether the value column(s) should be indexed. - */ - String indexed() default ""; - - /** - * The name of the index to generate. - * - * @return the name of the index - */ - String index() default ""; - - /** - * Whether the element column(s) contents should be considered unique - * - * @return whether the element column(s) contents should be considered unique - */ - String unique() default ""; - - /** - * The name of the unique key constraint to generate. - * - * @return the name of the unique key constraint - */ - String uniqueKey() default ""; - - /** - * Name of a member in the key class where this value is stored. - * - * @return the name of a member in the key class where this value is stored - */ - String mappedBy() default ""; - - /** - * The column(s) for the value. - * - * @return the column(s) for the value - */ - Column[] columns() default {}; - - /** - * Generate or assume a foreign key constraint exists on the column or columns associated with - * this join. Specify "true" or "false". - * - * @return whether to generate or assume a foreign key constraint - */ - String generateForeignKey() default ""; - - /** - * Name for a generated foreign key constraint. - * - * @return the name of the generated foreign key constraint - */ - String foreignKey() default ""; - - /** - * Optional {@link AttributeConverter} to use for converting this value. - * - * @return Converter class for converting this value when not PersistenceCapable (or - * NullAttributeConverter when not specified). - */ - @SuppressWarnings("rawtypes") - Class converter() default - UseDefault.class; // TODO Current JDK doesn't allow "default null" - - /** - * Whether we should disable any converter that was specified as default for this type on the PMF. - * Only has any effect when this is explicitly set to true, when any AttributeConverter specified - * for this type either here or for the class or at the PMF will be ignored and will use the JDO - * implementation default handling. - * - * @return Whether PMF attribute conversion is to be disabled. - */ - boolean useDefaultConversion() default false; // TODO Current JDK doesn't allow "default null" - - /** - * Vendor extensions. - * - * @return the vendor extensions - */ - Extension[] extensions() default {}; +public @interface Value +{ + /** + * Types of the values. This can be determined if using JDK1.5 generics + * but is required otherwise. Multiple types can be specified if the + * implementation supports multiple types. + * @return the types of values + */ + Class[] types() default {}; + + /** + * Whether the value is to be stored serialized (into a single column of a + * join table). + * @return Whether the value is to be stored serialized (into a join table) + */ + String serialized() default ""; + + /** Whether this value is embedded. + * @return whether this value is embedded + */ + String embedded() default ""; + + /** + * The embedded mapping for the value. + * @return the embedded mapping for the value + */ + Embedded[] embeddedMapping() default {}; + + /** + * Whether the value is dependent on the owner (and will be deleted + * when the owner is deleted). + * @return whether the value is dependent on the owner + */ + String dependent() default ""; + + /** + * Name of the table for the value. + * @return the name of the table for the value + */ + String table() default ""; + + /** + * Name of the column to store the value in. + * @return the name of the column to store the value in + */ + String column() default ""; + + /** + * Delete action to apply to any foreign key for the value. + * @return delete action to apply to any foreign key for the value + */ + ForeignKeyAction deleteAction() default ForeignKeyAction.UNSPECIFIED; + + /** + * Update action to apply to any foreign key for the value. + * @return update action to apply to any foreign key for the value + */ + ForeignKeyAction updateAction() default ForeignKeyAction.UNSPECIFIED; + + /** + * Whether the value column(s) should be indexed. + * @return whether the value column(s) should be indexed. + */ + String indexed() default ""; + + /** The name of the index to generate. + * @return the name of the index + */ + String index() default ""; + + /** + * Whether the element column(s) contents should be considered unique + * @return whether the element column(s) contents should be considered unique + */ + String unique() default ""; + + /** + * The name of the unique key constraint to generate. + * @return the name of the unique key constraint + */ + String uniqueKey() default ""; + + /** + * Name of a member in the key class where this value is stored. + * @return the name of a member in the key class where this value is stored + */ + String mappedBy() default ""; + + /** + * The column(s) for the value. + * @return the column(s) for the value + */ + Column[] columns() default {}; + + /** Generate or assume a foreign key constraint exists on the column + * or columns associated with this join. Specify "true" or "false". + * @return whether to generate or assume a foreign key constraint + */ + String generateForeignKey() default ""; + + /** Name for a generated foreign key constraint. + * @return the name of the generated foreign key constraint + */ + String foreignKey() default ""; + + /** + * Optional {@link AttributeConverter} to use for converting this value. + * @return Converter class for converting this value when not PersistenceCapable + * (or NullAttributeConverter when not specified). + */ + @SuppressWarnings("rawtypes") + Class converter() default UseDefault.class; // TODO Current JDK doesn't allow "default null" + + /** + * Whether we should disable any converter that was specified as default for this type on the PMF. + * Only has any effect when this is explicitly set to true, when any AttributeConverter specified for this type + * either here or for the class or at the PMF will be ignored and will use the JDO implementation default handling. + * @return Whether PMF attribute conversion is to be disabled. + */ + boolean useDefaultConversion() default false; // TODO Current JDK doesn't allow "default null" + + /** Vendor extensions. + * @return the vendor extensions + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/javax/jdo/annotations/Version.java b/api/src/main/java/javax/jdo/annotations/Version.java index fbd3e5dad..894b4c13e 100644 --- a/api/src/main/java/javax/jdo/annotations/Version.java +++ b/api/src/main/java/javax/jdo/annotations/Version.java @@ -22,55 +22,50 @@ import java.lang.annotation.Target; /** - * Annotation for the versioning of the class. Corresponds to the xml element "version" of the - * "class" and "property" elements. - * + * Annotation for the versioning of the class. + * Corresponds to the xml element "version" of the "class" and "property" + * elements. + * * @version 2.1 * @since 2.1 */ -@Target(ElementType.TYPE) +@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -public @interface Version { - /** - * Strategy for versioning of objects of this class. - * - * @return the strategy for versioning objects of this class - */ - VersionStrategy strategy() default VersionStrategy.UNSPECIFIED; +public @interface Version +{ + /** + * Strategy for versioning of objects of this class. + * @return the strategy for versioning objects of this class + */ + VersionStrategy strategy() default VersionStrategy.UNSPECIFIED; - /** - * Custom strategy for versioning of objects of this class. If customStrategy is non-empty, - * strategy must be UNSPECIFIED. - * - * @return the custom strategy for versioning objects of this class - */ - String customStrategy() default ""; + /** + * Custom strategy for versioning of objects of this class. + * If customStrategy is non-empty, strategy must be UNSPECIFIED. + * @return the custom strategy for versioning objects of this class + */ + String customStrategy() default ""; - /** - * Name of the column for the version. - * - * @return the name of the column for the version - */ - String column() default ""; + /** + * Name of the column for the version. + * @return the name of the column for the version + */ + String column() default ""; - /** - * Whether the version column(s) is(are) indexed. - * - * @return whether the version column(s) is(are) indexed - */ - String indexed() default ""; + /** + * Whether the version column(s) is(are) indexed. + * @return whether the version column(s) is(are) indexed + */ + String indexed() default ""; - /** - * The column(s) making up the version. - * - * @return the column(s) making up the version - */ - Column[] columns() default {}; + /** + * The column(s) making up the version. + * @return the column(s) making up the version + */ + Column[] columns() default {}; - /** - * Vendor extensions. - * - * @return the vendor extensions - */ - Extension[] extensions() default {}; + /** Vendor extensions. + * @return the vendor extensions + */ + Extension[] extensions() default {}; } diff --git a/api/src/main/java/javax/jdo/annotations/VersionStrategy.java b/api/src/main/java/javax/jdo/annotations/VersionStrategy.java index bcbd9709a..41f1dc395 100644 --- a/api/src/main/java/javax/jdo/annotations/VersionStrategy.java +++ b/api/src/main/java/javax/jdo/annotations/VersionStrategy.java @@ -18,14 +18,15 @@ /** * Enumeration of the version strategy values. - * + * * @version 2.1 * @since 2.1 */ -public enum VersionStrategy { - UNSPECIFIED, - NONE, - STATE_IMAGE, - DATE_TIME, - VERSION_NUMBER +public enum VersionStrategy +{ + UNSPECIFIED, + NONE, + STATE_IMAGE, + DATE_TIME, + VERSION_NUMBER } diff --git a/api/src/main/java/javax/jdo/datastore/DataStoreCache.java b/api/src/main/java/javax/jdo/datastore/DataStoreCache.java index 7097a77b0..e2a2fc000 100644 --- a/api/src/main/java/javax/jdo/datastore/DataStoreCache.java +++ b/api/src/main/java/javax/jdo/datastore/DataStoreCache.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -23,156 +23,145 @@ import java.util.Collection; -/** - * Many JDO implementations allow instances to be cached in a second-level cache, and allow direct - * management of the cache by knowledgeable applications. This interface standardizes this behavior. - * +/** + * Many JDO implementations allow instances to be cached in a + * second-level cache, and allow direct management of the cache by + * knowledgeable applications. This interface standardizes this behavior. * @since 2.0 * @version 2.0 */ public interface DataStoreCache { - /** - * Evict the parameter instance from the second-level cache. - * - * @param oid the object id of the instance to evict. - * @since 2.0 - */ - void evict(Object oid); - - /** - * Evict the parameter instances from the second-level cache. All instances in the - * PersistenceManager's cache are evicted from the second-level cache. - * - * @since 2.0 - */ - void evictAll(); - - /** - * Evict the parameter instances from the second-level cache. - * - * @param oids the object ids of the instance to evict. - * @since 2.0 - */ - void evictAll(Object... oids); - - /** - * Evict the parameter instances from the second-level cache. - * - * @param oids the object ids of the instance to evict. - * @since 2.0 - */ - void evictAll(Collection oids); - - /** - * Evict the parameter instances from the second-level cache. - * - * @param pcClass the class of instances to evict - * @param subclasses if true, evict instances of subclasses also - * @since 2.1 - */ - void evictAll(boolean subclasses, Class pcClass); - - /** - * Pin the parameter instance in the second-level cache. - * - * @param oid the object id of the instance to pin. - * @since 2.0 - */ - void pin(Object oid); - - /** - * Pin the parameter instances in the second-level cache. - * - * @param oids the object ids of the instances to pin. - * @since 2.0 - */ - void pinAll(Collection oids); - - /** - * Pin the parameter instances in the second-level cache. - * - * @param oids the object ids of the instances to pin. - * @since 2.0 - */ - void pinAll(Object... oids); - - /** - * Pin instances in the second-level cache. - * - * @param pcClass the class of instances to pin - * @param subclasses if true, pin instances of subclasses also - * @since 2.1 - */ - void pinAll(boolean subclasses, Class pcClass); - - /** - * Unpin the parameter instance from the second-level cache. - * - * @param oid the object id of the instance to unpin. - * @since 2.0 - */ - void unpin(Object oid); - - /** - * Unpin the parameter instances from the second-level cache. - * - * @param oids the object ids of the instance to evict. - * @since 2.0 - */ - void unpinAll(Collection oids); - - /** - * Unpin the parameter instance from the second-level cache. - * - * @param oids the object id of the instance to evict. - * @since 2.0 - */ - void unpinAll(Object... oids); - - /** - * Unpin instances from the second-level cache. - * - * @param pcClass the class of instances to unpin - * @param subclasses if true, unpin instances of subclasses also - * @since 2.1 - */ - void unpinAll(boolean subclasses, Class pcClass); - - /** - * This class is an empty implementation of the DataStoreCache interface. It can be used by an - * implementation that does not support a second-level cache. - * - * @since 2.0 - */ - public class EmptyDataStoreCache implements DataStoreCache { - - public EmptyDataStoreCache() {} - - public void evict(Object oid) {} - - public void evictAll() {} - - public void evictAll(Object... oids) {} - - public void evictAll(Collection oids) {} - - public void evictAll(boolean subclasses, Class pcClass) {} - - public void pin(Object oid) {} - - public void pinAll(Object... oids) {} - - public void pinAll(Collection oids) {} - - public void pinAll(boolean subclasses, Class pcClass) {} - - public void unpin(Object oid) {} - - public void unpinAll(Object... oids) {} - - public void unpinAll(Collection oids) {} - - public void unpinAll(boolean subclasses, Class pcClass) {} - } + /** Evict the parameter instance from the second-level cache. + * @param oid the object id of the instance to evict. + * @since 2.0 + */ + void evict (Object oid); + + /** Evict the parameter instances from the second-level cache. + * All instances in the PersistenceManager's cache are evicted + * from the second-level cache. + * @since 2.0 + */ + void evictAll (); + + /** Evict the parameter instances from the second-level cache. + * @param oids the object ids of the instance to evict. + * @since 2.0 + */ + void evictAll (Object... oids); + + /** Evict the parameter instances from the second-level cache. + * @param oids the object ids of the instance to evict. + * @since 2.0 + */ + void evictAll (Collection oids); + + /** Evict the parameter instances from the second-level cache. + * @param pcClass the class of instances to evict + * @param subclasses if true, evict instances of subclasses also + * @since 2.1 + */ + void evictAll (boolean subclasses, Class pcClass); + + /** Pin the parameter instance in the second-level cache. + * @param oid the object id of the instance to pin. + * @since 2.0 + */ + void pin (Object oid); + + /** Pin the parameter instances in the second-level cache. + * @param oids the object ids of the instances to pin. + * @since 2.0 + */ + void pinAll (Collection oids); + + /** Pin the parameter instances in the second-level cache. + * @param oids the object ids of the instances to pin. + * @since 2.0 + */ + void pinAll (Object... oids); + + /** Pin instances in the second-level cache. + * @param pcClass the class of instances to pin + * @param subclasses if true, pin instances of subclasses also + * @since 2.1 + */ + void pinAll (boolean subclasses, Class pcClass); + + /** Unpin the parameter instance from the second-level cache. + * @param oid the object id of the instance to unpin. + * @since 2.0 + */ + void unpin(Object oid); + + /** Unpin the parameter instances from the second-level cache. + * @param oids the object ids of the instance to evict. + * @since 2.0 + */ + void unpinAll(Collection oids); + + /** Unpin the parameter instance from the second-level cache. + * @param oids the object id of the instance to evict. + * @since 2.0 + */ + void unpinAll(Object... oids); + + /** Unpin instances from the second-level cache. + * @param pcClass the class of instances to unpin + * @param subclasses if true, unpin instances of subclasses also + * @since 2.1 + */ + void unpinAll(boolean subclasses, Class pcClass); + + /** + * This class is an empty implementation of the DataStoreCache + * interface. It can be used by an implementation that does not + * support a second-level cache. + * @since 2.0 + */ + public class EmptyDataStoreCache implements DataStoreCache { + + public EmptyDataStoreCache() { + } + + public void evict(Object oid) { + } + + public void evictAll() { + } + + public void evictAll(Object... oids) { + } + + public void evictAll(Collection oids) { + } + + public void evictAll(boolean subclasses, Class pcClass) { + } + + public void pin(Object oid) { + } + + public void pinAll(Object... oids) { + } + + public void pinAll(Collection oids) { + } + + public void pinAll(boolean subclasses, Class pcClass) { + } + + public void unpin(Object oid) { + } + + public void unpinAll(Object... oids) { + } + + public void unpinAll(Collection oids) { + } + + public void unpinAll(boolean subclasses, Class pcClass) { + } + } } diff --git a/api/src/main/java/javax/jdo/datastore/JDOConnection.java b/api/src/main/java/javax/jdo/datastore/JDOConnection.java index 19918b100..d1b01671e 100644 --- a/api/src/main/java/javax/jdo/datastore/JDOConnection.java +++ b/api/src/main/java/javax/jdo/datastore/JDOConnection.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,36 +19,38 @@ * JDOConnection.java * */ - + package javax.jdo.datastore; /** - * The underlying connection that is being used by a {@link javax.jdo.PersistenceManager}. - * + * The underlying connection that is being used by a + * {@link javax.jdo.PersistenceManager}. * @version 2.0 * @since 2.0 */ public interface JDOConnection { - /** - * Returns the native, datastore-specific connection that this connection wraps. In general, it is - * not recommended that this native connection be used directly, since the JDO implementation has - * no way to intercept calls to it, so it is quite possible to put the PersistenceManager - * 's connection into an invalid state. - * - * @return the native connection - * @since 2.0 - */ - Object getNativeConnection(); - - /** - * Returns this connection to the JDO implementation. The object must be returned to the JDO - * implementation prior to calling any JDO method or performing any action on any persistent - * instance that might require the JDO implementation to use a connection. If the object has not - * been returned and the JDO implementation needs a connection, a JDOUserException is - * thrown. - * - * @since 2.0 - */ - void close(); + /** + * Returns the native, datastore-specific connection that this + * connection wraps. In general, it is not recommended that this + * native connection be used directly, since the JDO + * implementation has no way to intercept calls to it, so it is + * quite possible to put the PersistenceManager's + * connection into an invalid state. + * @return the native connection + * @since 2.0 + */ + Object getNativeConnection (); + + /** + * Returns this connection to the JDO implementation. + * The object must be returned to the JDO implementation prior to + * calling any JDO method or performing any action on any persistent + * instance that might require the JDO implementation to use a + * connection. If the object has not been returned and the JDO + * implementation needs a connection, a JDOUserException + * is thrown. + * @since 2.0 + */ + void close(); } diff --git a/api/src/main/java/javax/jdo/datastore/Sequence.java b/api/src/main/java/javax/jdo/datastore/Sequence.java index 44eb7675f..c1ecd2322 100644 --- a/api/src/main/java/javax/jdo/datastore/Sequence.java +++ b/api/src/main/java/javax/jdo/datastore/Sequence.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,65 +19,65 @@ * Sequence.java * */ - + package javax.jdo.datastore; + /** - * Implementations of this interface can be used to obtain sequences. The behavior with regard to - * the transaction and rollover behavior are defined in the metadata. + * Implementations of this interface can be used to obtain + * sequences. The behavior with regard to the transaction and + * rollover behavior are defined in the metadata. * - * @version 2.0 - * @since 2.0 + * @version 2.0 + * @since 2.0 */ public interface Sequence { - /** - * Returns the fully qualified name of the Sequence. - * - * @return the name of the sequence - */ - String getName(); - - /** - * Returns the next sequence value as an Object. If the next sequence value is not available, - * throw JDODataStoreException. - * - * @return the next value - */ - Object next(); - - /** - * Provides a hint to the implementation that the application will need additional - * sequence value objects in short order. There is no externally visible behavior of this method. - * It is used to potentially improve the efficiency of the algorithm of obtaining additional - * sequence value objects. - * - * @param additional the number of additional values to allocate - */ - void allocate(int additional); + /** + * Returns the fully qualified name of the Sequence. + * @return the name of the sequence + */ + String getName (); - /** - * Returns the current sequence value object if it is available. It is intended to return a - * sequence value object previously used. If the current sequence value is not available, throw - * JDODataStoreException. - * - * @return the current value - */ - Object current(); + /** + * Returns the next sequence value as an Object. If the next + * sequence value is not available, throw JDODataStoreException. + * @return the next value + */ + Object next (); - /** - * Returns the next sequence value as a long. If the next sequence value is not available or is - * not numeric, throw JDODataStoreException. - * - * @return the next value - */ - long nextValue(); + /** + * Provides a hint to the implementation that the application + * will need additional sequence value objects in + * short order. There is no externally visible behavior of this + * method. It is used to potentially improve the efficiency of + * the algorithm of obtaining additional sequence value objects. + * @param additional the number of additional values to allocate + */ + void allocate (int additional); - /** - * Returns the current sequence value as a long. If the current sequence value is not available or - * is not numeric, throw JDODataStoreException. - * - * @return the current value - */ - long currentValue(); + /** + * Returns the current sequence value object if it is + * available. It is intended to return a sequence value object + * previously used. If the current sequence value is not available, + * throw JDODataStoreException. + * @return the current value + */ + Object current (); + + /** + * Returns the next sequence value as a long. If the next + * sequence value is not available or is not numeric, throw + * JDODataStoreException. + * @return the next value + */ + long nextValue(); + + /** + * Returns the current sequence value as a long. If the current + * sequence value is not available or is not numeric, throw + * JDODataStoreException. + * @return the current value + */ + long currentValue(); } diff --git a/api/src/main/java/javax/jdo/identity/ByteIdentity.java b/api/src/main/java/javax/jdo/identity/ByteIdentity.java index 39febf806..d56a09268 100644 --- a/api/src/main/java/javax/jdo/identity/ByteIdentity.java +++ b/api/src/main/java/javax/jdo/identity/ByteIdentity.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,151 +19,135 @@ * ByteIdentity.java * */ - + package javax.jdo.identity; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; -/** - * This class is for identity with a single byte field. - * +/** This class is for identity with a single byte field. * @version 2.0 */ public class ByteIdentity extends SingleFieldIdentity { + + /** The key. + */ + private byte key; + + /** Construct this instance with the key value. + */ + private void construct(byte key) { + this.key = key; + hashCode = super.hashClassName() ^ key; + } + + /** Constructor with class and key. + * @param pcClass the target class + * @param key the key + */ + public ByteIdentity(Class pcClass, byte key) { + super(pcClass); + construct(key); + } + + /** Constructor with class and key. + * @param pcClass the target class + * @param key the key + */ + public ByteIdentity(Class pcClass, Byte key) { + super(pcClass); + setKeyAsObject(key); + construct(key.byteValue()); + } - /** The key. */ - private byte key; - - /** Construct this instance with the key value. */ - private void construct(byte key) { - this.key = key; - hashCode = super.hashClassName() ^ key; - } - - /** - * Constructor with class and key. - * - * @param pcClass the target class - * @param key the key - */ - public ByteIdentity(Class pcClass, byte key) { - super(pcClass); - construct(key); - } - - /** - * Constructor with class and key. - * - * @param pcClass the target class - * @param key the key - */ - public ByteIdentity(Class pcClass, Byte key) { - super(pcClass); - setKeyAsObject(key); - construct(key.byteValue()); - } - - /** - * Constructor with class and key. - * - * @param pcClass the target class - * @param str the key - */ - public ByteIdentity(Class pcClass, String str) { - super(pcClass); - assertKeyNotNull(str); - construct(Byte.parseByte(str)); - } + /** Constructor with class and key. + * @param pcClass the target class + * @param str the key + */ + public ByteIdentity(Class pcClass, String str) { + super(pcClass); + assertKeyNotNull(str); + construct(Byte.parseByte(str)); + } - /** Constructor only for Externalizable. */ - public ByteIdentity() {} + /** Constructor only for Externalizable. + */ + public ByteIdentity() { + } - /** - * Return the key. - * - * @return the key - */ - public byte getKey() { - return key; - } + /** Return the key. + * @return the key + */ + public byte getKey() { + return key; + } - /** - * Return the String version of the key. - * - * @return the key. - */ - public String toString() { - return Byte.toString(key); - } + /** Return the String version of the key. + * @return the key. + */ + public String toString() { + return Byte.toString(key); + } - /** - * Determine if the other object represents the same object id. - * - * @param obj the other object - * @return true if both objects represent the same object id - */ - public boolean equals(Object obj) { - if (this == obj) { - return true; - } else if (!super.equals(obj)) { - return false; - } else { - ByteIdentity other = (ByteIdentity) obj; - return key == other.key; + /** Determine if the other object represents the same object id. + * @param obj the other object + * @return true if both objects represent the same object id + */ + public boolean equals(Object obj) { + if (this == obj) { + return true; + } else if (!super.equals (obj)) { + return false; + } else { + ByteIdentity other = (ByteIdentity)obj; + return key == other.key; + } } - } - /** - * Determine the ordering of identity objects. - * - * @param o Other identity - * @return The relative ordering between the objects - * @since 2.2 - */ - public int compareTo(Object o) { - if (o instanceof ByteIdentity) { - ByteIdentity other = (ByteIdentity) o; - int result = super.compare(other); - if (result == 0) { - return (key - other.key); - } else { - return result; - } - } else if (o == null) { - throw new ClassCastException("object is null"); + /** Determine the ordering of identity objects. + * @param o Other identity + * @return The relative ordering between the objects + * @since 2.2 + */ + public int compareTo(Object o) { + if (o instanceof ByteIdentity) { + ByteIdentity other = (ByteIdentity)o; + int result = super.compare(other); + if (result == 0) { + return (key - other.key); + } else { + return result; + } + } + else if (o == null) { + throw new ClassCastException("object is null"); + } + throw new ClassCastException(this.getClass().getName() + " != " + o.getClass().getName()); } - throw new ClassCastException(this.getClass().getName() + " != " + o.getClass().getName()); - } - /** - * Create the key as an Object. - * - * @return the key as an Object - * @since 2.0 - */ - protected Object createKeyAsObject() { - return Byte.valueOf(key); - } + /** Create the key as an Object. + * @return the key as an Object + * @since 2.0 + */ + protected Object createKeyAsObject() { + return Byte.valueOf(key); + } - /** - * Write this object. Write the superclass first. - * - * @param out the output - */ - public void writeExternal(ObjectOutput out) throws IOException { - super.writeExternal(out); - out.writeByte(key); - } + /** Write this object. Write the superclass first. + * @param out the output + */ + public void writeExternal(ObjectOutput out) throws IOException { + super.writeExternal (out); + out.writeByte (key); + } - /** - * Read this object. Read the superclass first. - * - * @param in the input - */ - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - super.readExternal(in); - key = in.readByte(); - } + /** Read this object. Read the superclass first. + * @param in the input + */ + public void readExternal(ObjectInput in) + throws IOException, ClassNotFoundException { + super.readExternal (in); + key = in.readByte (); + } } diff --git a/api/src/main/java/javax/jdo/identity/CharIdentity.java b/api/src/main/java/javax/jdo/identity/CharIdentity.java index 0a82e46e7..7cf03bb6e 100644 --- a/api/src/main/java/javax/jdo/identity/CharIdentity.java +++ b/api/src/main/java/javax/jdo/identity/CharIdentity.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -25,150 +25,137 @@ import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; + import javax.jdo.spi.I18NHelper; -/** - * This class is for identity with a single character field. - * +/** This class is for identity with a single character field. * @version 2.0 */ public class CharIdentity extends SingleFieldIdentity { - /** The Internationalization message helper. */ - private static I18NHelper msg = I18NHelper.getInstance("javax.jdo.Bundle"); // NOI18N - - /** The key. */ - private char key; - - private void construct(char key) { - this.key = key; - hashCode = hashClassName() ^ key; - } - - /** - * Constructor with class and key. - * - * @param pcClass the target class - * @param key the key - */ - public CharIdentity(Class pcClass, char key) { - super(pcClass); - construct(key); - } - - /** - * Constructor with class and key. - * - * @param pcClass the target class - * @param key the key - */ - public CharIdentity(Class pcClass, Character key) { - super(pcClass); - setKeyAsObject(key); - construct(key.charValue()); - } - - /** - * Constructor with class and key. The String must have exactly one character. - * - * @param pcClass the target class - * @param str the key - */ - public CharIdentity(Class pcClass, String str) { - super(pcClass); - assertKeyNotNull(str); - if (str.length() != 1) - throw new IllegalArgumentException(msg.msg("EXC_StringWrongLength")); // NOI18N - construct(str.charAt(0)); - } - - /** Constructor only for Externalizable. */ - public CharIdentity() {} - - /** - * Return the key. - * - * @return the key - */ - public char getKey() { - return key; - } - - /** - * Return the String form of the key. - * - * @return the String form of the key - */ - public String toString() { - return String.valueOf(key); - } - - /** - * Determine if the other object represents the same object id. - * - * @param obj the other object - * @return true if both objects represent the same object id - */ - public boolean equals(Object obj) { - if (this == obj) { - return true; - } else if (!super.equals(obj)) { - return false; - } else { - CharIdentity other = (CharIdentity) obj; - return key == other.key; + /** The Internationalization message helper. + */ + private static I18NHelper msg = I18NHelper.getInstance ("javax.jdo.Bundle"); //NOI18N + + /** The key. + */ + private char key; + + private void construct(char key) { + this.key = key; + hashCode = hashClassName() ^ key; + } + + /** Constructor with class and key. + * @param pcClass the target class + * @param key the key + */ + public CharIdentity (Class pcClass, char key) { + super (pcClass); + construct(key); + } + + /** Constructor with class and key. + * @param pcClass the target class + * @param key the key + */ + public CharIdentity (Class pcClass, Character key) { + super (pcClass); + setKeyAsObject(key); + construct(key.charValue()); + } + + /** Constructor with class and key. The String must have exactly one + * character. + * @param pcClass the target class + * @param str the key + */ + public CharIdentity (Class pcClass, String str) { + super(pcClass); + assertKeyNotNull(str); + if (str.length() != 1) + throw new IllegalArgumentException( + msg.msg("EXC_StringWrongLength")); //NOI18N + construct(str.charAt(0)); + } + + /** Constructor only for Externalizable. + */ + public CharIdentity () { } - } - - /** - * Determine the ordering of identity objects. - * - * @param o Other identity - * @return The relative ordering between the objects - * @since 2.2 - */ - public int compareTo(Object o) { - if (o instanceof CharIdentity) { - CharIdentity other = (CharIdentity) o; - int result = super.compare(other); - if (result == 0) { - return (key - other.key); - } else { - return result; - } - } else if (o == null) { - throw new ClassCastException("object is null"); + + /** Return the key. + * @return the key + */ + public char getKey () { + return key; + } + + /** Return the String form of the key. + * @return the String form of the key + */ + public String toString () { + return String.valueOf(key); + } + + /** Determine if the other object represents the same object id. + * @param obj the other object + * @return true if both objects represent the same object id + */ + public boolean equals (Object obj) { + if (this == obj) { + return true; + } else if (!super.equals (obj)) { + return false; + } else { + CharIdentity other = (CharIdentity) obj; + return key == other.key; + } + } + + /** Determine the ordering of identity objects. + * @param o Other identity + * @return The relative ordering between the objects + * @since 2.2 + */ + public int compareTo(Object o) { + if (o instanceof CharIdentity) { + CharIdentity other = (CharIdentity)o; + int result = super.compare(other); + if (result == 0) { + return (key - other.key); + } else { + return result; + } + } + else if (o == null) { + throw new ClassCastException("object is null"); + } + throw new ClassCastException(this.getClass().getName() + " != " + o.getClass().getName()); + } + + /** Create the key as an Object. + * @return the key as an Object + * @since 2.0 + */ + protected Object createKeyAsObject() { + return Character.valueOf(key); + } + + /** Write this object. Write the superclass first. + * @param out the output + */ + public void writeExternal(ObjectOutput out) throws IOException { + super.writeExternal (out); + out.writeChar(key); + } + + /** Read this object. Read the superclass first. + * @param in the input + */ + public void readExternal(ObjectInput in) + throws IOException, ClassNotFoundException { + super.readExternal (in); + key = in.readChar(); } - throw new ClassCastException(this.getClass().getName() + " != " + o.getClass().getName()); - } - - /** - * Create the key as an Object. - * - * @return the key as an Object - * @since 2.0 - */ - protected Object createKeyAsObject() { - return Character.valueOf(key); - } - - /** - * Write this object. Write the superclass first. - * - * @param out the output - */ - public void writeExternal(ObjectOutput out) throws IOException { - super.writeExternal(out); - out.writeChar(key); - } - - /** - * Read this object. Read the superclass first. - * - * @param in the input - */ - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - super.readExternal(in); - key = in.readChar(); - } } diff --git a/api/src/main/java/javax/jdo/identity/IntIdentity.java b/api/src/main/java/javax/jdo/identity/IntIdentity.java index 79149b6cc..e2159409d 100644 --- a/api/src/main/java/javax/jdo/identity/IntIdentity.java +++ b/api/src/main/java/javax/jdo/identity/IntIdentity.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,149 +19,132 @@ * IntIdentity.java * */ - + package javax.jdo.identity; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; -/** - * This class is for identity with a single int field. - * +/** This class is for identity with a single int field. * @version 2.0 */ public class IntIdentity extends SingleFieldIdentity { - private int key; - - private void construct(int key) { - this.key = key; - hashCode = hashClassName() ^ key; - } - - /** - * Constructor with class and key. - * - * @param pcClass the class - * @param key the key - */ - public IntIdentity(Class pcClass, int key) { - super(pcClass); - construct(key); - } - - /** - * Constructor with class and key. - * - * @param pcClass the class - * @param key the key - */ - public IntIdentity(Class pcClass, Integer key) { - super(pcClass); - setKeyAsObject(key); - construct(key.intValue()); - } - - /** - * Constructor with class and key. - * - * @param pcClass the class - * @param str the key - */ - public IntIdentity(Class pcClass, String str) { - super(pcClass); - assertKeyNotNull(str); - construct(Integer.parseInt(str)); - } - - /** Constructor only for Externalizable. */ - public IntIdentity() {} - - /** - * Return the key. - * - * @return the key - */ - public int getKey() { - return key; - } - - /** - * Return the String form of the key. - * - * @return the String form of the key - */ - public String toString() { - return Integer.toString(key); - } - - /** - * Determine if the other object represents the same object id. - * - * @param obj the other object - * @return true if both objects represent the same object id - */ - public boolean equals(Object obj) { - if (this == obj) { - return true; - } else if (!super.equals(obj)) { - return false; - } else { - IntIdentity other = (IntIdentity) obj; - return key == other.key; + private int key; + + private void construct(int key) { + this.key = key; + hashCode = hashClassName() ^ key; + } + + /** Constructor with class and key. + * @param pcClass the class + * @param key the key + */ + public IntIdentity (Class pcClass, int key) { + super(pcClass); + construct(key); + } + + /** Constructor with class and key. + * @param pcClass the class + * @param key the key + */ + public IntIdentity (Class pcClass, Integer key) { + super(pcClass); + setKeyAsObject(key); + construct(key.intValue ()); } - } - - /** - * Determine the ordering of identity objects. - * - * @param o Other identity - * @return The relative ordering between the objects - * @since 2.2 - */ - public int compareTo(Object o) { - if (o instanceof IntIdentity) { - IntIdentity other = (IntIdentity) o; - int result = super.compare(other); - if (result == 0) { - return (key - other.key); - } else { - return result; - } - } else if (o == null) { - throw new ClassCastException("object is null"); + + + /** Constructor with class and key. + * @param pcClass the class + * @param str the key + */ + public IntIdentity (Class pcClass, String str) { + super(pcClass); + assertKeyNotNull(str); + construct(Integer.parseInt(str)); + } + + /** Constructor only for Externalizable. + */ + public IntIdentity () { + } + + /** Return the key. + * @return the key + */ + public int getKey () { + return key; + } + + /** Return the String form of the key. + * @return the String form of the key + */ + public String toString () { + return Integer.toString(key); + } + + /** Determine if the other object represents the same object id. + * @param obj the other object + * @return true if both objects represent the same object id + */ + public boolean equals (Object obj) { + if (this == obj) { + return true; + } else if (!super.equals (obj)) { + return false; + } else { + IntIdentity other = (IntIdentity) obj; + return key == other.key; + } + } + + /** Determine the ordering of identity objects. + * @param o Other identity + * @return The relative ordering between the objects + * @since 2.2 + */ + public int compareTo(Object o) { + if (o instanceof IntIdentity) { + IntIdentity other = (IntIdentity)o; + int result = super.compare(other); + if (result == 0) { + return (key - other.key); + } else { + return result; + } + } + else if (o == null) { + throw new ClassCastException("object is null"); + } + throw new ClassCastException(this.getClass().getName() + " != " + o.getClass().getName()); + } + + /** Create the key as an Object. + * @return the key as an Object + * @since 2.0 + */ + protected Object createKeyAsObject() { + return Integer.valueOf(key); + } + + /** Write this object. Write the superclass first. + * @param out the output + */ + public void writeExternal(ObjectOutput out) throws IOException { + super.writeExternal (out); + out.writeInt(key); + } + + /** Read this object. Read the superclass first. + * @param in the input + */ + public void readExternal(ObjectInput in) + throws IOException, ClassNotFoundException { + super.readExternal (in); + key = in.readInt(); } - throw new ClassCastException(this.getClass().getName() + " != " + o.getClass().getName()); - } - - /** - * Create the key as an Object. - * - * @return the key as an Object - * @since 2.0 - */ - protected Object createKeyAsObject() { - return Integer.valueOf(key); - } - - /** - * Write this object. Write the superclass first. - * - * @param out the output - */ - public void writeExternal(ObjectOutput out) throws IOException { - super.writeExternal(out); - out.writeInt(key); - } - - /** - * Read this object. Read the superclass first. - * - * @param in the input - */ - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - super.readExternal(in); - key = in.readInt(); - } } diff --git a/api/src/main/java/javax/jdo/identity/LongIdentity.java b/api/src/main/java/javax/jdo/identity/LongIdentity.java index fc222fbfb..b522751b6 100644 --- a/api/src/main/java/javax/jdo/identity/LongIdentity.java +++ b/api/src/main/java/javax/jdo/identity/LongIdentity.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,159 +19,143 @@ * LongIdentity.java * */ - + package javax.jdo.identity; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; -/** - * This class is for identity with a single long field. - * +/** This class is for identity with a single long field. * @version 2.0 */ public class LongIdentity extends SingleFieldIdentity { + + /** The key. + */ + private long key; + + private void construct(long key) { + this.key = key; + hashCode = hashClassName() ^ (int)key; + } + + /** Constructor with class and key. + * @param pcClass the class + * @param key the key + */ + public LongIdentity (Class pcClass, long key) { + super (pcClass); + construct(key); + } - /** The key. */ - private long key; - - private void construct(long key) { - this.key = key; - hashCode = hashClassName() ^ (int) key; - } - - /** - * Constructor with class and key. - * - * @param pcClass the class - * @param key the key - */ - public LongIdentity(Class pcClass, long key) { - super(pcClass); - construct(key); - } - - /** - * Constructor with class and key. - * - * @param pcClass the class - * @param key the key - */ - public LongIdentity(Class pcClass, Long key) { - super(pcClass); - setKeyAsObject(key); - construct(key.longValue()); - } - - /** - * Constructor with class and key. - * - * @param pcClass the class - * @param str the key - */ - public LongIdentity(Class pcClass, String str) { - super(pcClass); - assertKeyNotNull(str); - construct(Long.parseLong(str)); - } - - /** Constructor only for Externalizable. */ - public LongIdentity() {} - - /** - * Return the key. - * - * @return the key - */ - public long getKey() { - return key; - } - - /** - * Return the String form of the key. - * - * @return the String form of the key - */ - public String toString() { - return Long.toString(key); - } - - /** - * Determine if the other object represents the same object id. - * - * @param obj the other object - * @return true if both objects represent the same object id - */ - public boolean equals(Object obj) { - if (this == obj) { - return true; - } else if (!super.equals(obj)) { - return false; - } else { - LongIdentity other = (LongIdentity) obj; - return key == other.key; + /** Constructor with class and key. + * @param pcClass the class + * @param key the key + */ + public LongIdentity (Class pcClass, Long key) { + super(pcClass); + setKeyAsObject(key); + construct(key.longValue()); } - } - - /** - * Determine the ordering of identity objects. - * - * @param o Other identity - * @return The relative ordering between the objects - * @since 2.2 - */ - public int compareTo(Object o) { - if (o instanceof LongIdentity) { - LongIdentity other = (LongIdentity) o; - int result = super.compare(other); - if (result == 0) { - long diff = key - other.key; - if (diff == 0) { - return 0; + + /** Constructor with class and key. + * @param pcClass the class + * @param str the key + */ + public LongIdentity (Class pcClass, String str) { + super(pcClass); + assertKeyNotNull(str); + construct(Long.parseLong(str)); + } + + /** Constructor only for Externalizable. + */ + public LongIdentity () { + } + + /** Return the key. + * @return the key + */ + public long getKey () { + return key; + } + + /** Return the String form of the key. + * @return the String form of the key + */ + public String toString () { + return Long.toString(key); + } + + /** Determine if the other object represents the same object id. + * @param obj the other object + * @return true if both objects represent the same object id + */ + public boolean equals (Object obj) { + if (this == obj) { + return true; + } else if (!super.equals (obj)) { + return false; } else { - if (diff < 0) { - return -1; - } else { - return 1; - } + LongIdentity other = (LongIdentity) obj; + return key == other.key; } - } else { - return result; - } - } else if (o == null) { - throw new ClassCastException("object is null"); } - throw new ClassCastException(this.getClass().getName() + " != " + o.getClass().getName()); - } - - /** - * Create the key as an Object. - * - * @return the key as an Object - * @since 2.0 - */ - protected Object createKeyAsObject() { - return Long.valueOf(key); - } - - /** - * Write this object. Write the superclass first. - * - * @param out the output - */ - public void writeExternal(ObjectOutput out) throws IOException { - super.writeExternal(out); - out.writeLong(key); - } - - /** - * Read this object. Read the superclass first. - * - * @param in the input - */ - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - super.readExternal(in); - key = in.readLong(); - } + + /** Determine the ordering of identity objects. + * @param o Other identity + * @return The relative ordering between the objects + * @since 2.2 + */ + public int compareTo(Object o) { + if (o instanceof LongIdentity) { + LongIdentity other = (LongIdentity)o; + int result = super.compare(other); + if (result == 0) { + long diff = key - other.key; + if (diff == 0) { + return 0; + } else { + if (diff < 0) { + return -1; + } else { + return 1; + } + } + } else { + return result; + } + } + else if (o == null) { + throw new ClassCastException("object is null"); + } + throw new ClassCastException(this.getClass().getName() + " != " + o.getClass().getName()); + } + + /** Create the key as an Object. + * @return the key as an Object + * @since 2.0 + */ + protected Object createKeyAsObject() { + return Long.valueOf(key); + } + + /** Write this object. Write the superclass first. + * @param out the output + */ + public void writeExternal(ObjectOutput out) throws IOException { + super.writeExternal (out); + out.writeLong(key); + } + + /** Read this object. Read the superclass first. + * @param in the input + */ + public void readExternal(ObjectInput in) + throws IOException, ClassNotFoundException { + super.readExternal (in); + key = in.readLong(); + } + } diff --git a/api/src/main/java/javax/jdo/identity/ObjectIdentity.java b/api/src/main/java/javax/jdo/identity/ObjectIdentity.java index 2b73efaec..6cace865f 100644 --- a/api/src/main/java/javax/jdo/identity/ObjectIdentity.java +++ b/api/src/main/java/javax/jdo/identity/ObjectIdentity.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,198 +19,196 @@ * ObjectIdentity.java * */ - + package javax.jdo.identity; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; + +import javax.jdo.JDOFatalInternalException; +import javax.jdo.LegacyJava; import java.lang.reflect.InvocationTargetException; import java.security.PrivilegedAction; -import javax.jdo.JDOFatalInternalException; + import javax.jdo.JDOUserException; -import javax.jdo.LegacyJava; + import javax.jdo.spi.JDOImplHelper; -/** - * This class is for identity with a single Object type field. - * +/** This class is for identity with a single Object type field. * @version 2.0 */ public class ObjectIdentity extends SingleFieldIdentity { + + /** The key is stored in the superclass field keyAsObject. + */ + + /** The JDOImplHelper instance used for parsing the String to an Object. + */ + private static JDOImplHelper helper = (JDOImplHelper) + doPrivileged( + new PrivilegedAction () { + public JDOImplHelper run () { + return JDOImplHelper.getInstance(); + } + } + ); + + @SuppressWarnings("unchecked") + private static T doPrivileged(PrivilegedAction privilegedAction) { + try { + return (T) LegacyJava.doPrivilegedAction.invoke(null, privilegedAction); + } catch (IllegalAccessException | InvocationTargetException e) { + if (e.getCause() instanceof RuntimeException) { + throw (RuntimeException) e.getCause(); + } + throw new JDOFatalInternalException(e.getMessage()); + } + } - /** The key is stored in the superclass field keyAsObject. */ + /** The delimiter for String constructor. + */ + private static final String STRING_DELIMITER = ":"; //NOI18N + + /** Constructor with class and key. + * @param pcClass the class + * @param param the key + */ + @SuppressWarnings("static-access") + public ObjectIdentity (Class pcClass, Object param) { + super (pcClass); + assertKeyNotNull(param); + String paramString = null; + String keyString = null; + String className = null; + if (param instanceof String) { + /* The paramString is of the form ":" */ + paramString = (String)param; + if (paramString.length() < 3) { + throw new JDOUserException( + msg.msg("EXC_ObjectIdentityStringConstructionTooShort") + //NOI18N + msg.msg("EXC_ObjectIdentityStringConstructionUsage", //NOI18N + paramString)); + } + int indexOfDelimiter = paramString.indexOf(STRING_DELIMITER); + if (indexOfDelimiter < 0) { + throw new JDOUserException( + msg.msg("EXC_ObjectIdentityStringConstructionNoDelimiter") + //NOI18N + msg.msg("EXC_ObjectIdentityStringConstructionUsage", //NOI18N + paramString)); + } + keyString = paramString.substring(indexOfDelimiter+1); + className = paramString.substring(0, indexOfDelimiter); + keyAsObject = helper.construct(className, keyString); + } else { + keyAsObject = param; + } + hashCode = hashClassName() ^ keyAsObject.hashCode(); + } - /** The JDOImplHelper instance used for parsing the String to an Object. */ - private static JDOImplHelper helper = - (JDOImplHelper) - doPrivileged( - new PrivilegedAction() { - public JDOImplHelper run() { - return JDOImplHelper.getInstance(); - } - }); - - @SuppressWarnings("unchecked") - private static T doPrivileged(PrivilegedAction privilegedAction) { - try { - return (T) LegacyJava.doPrivilegedAction.invoke(null, privilegedAction); - } catch (IllegalAccessException | InvocationTargetException e) { - if (e.getCause() instanceof RuntimeException) { - throw (RuntimeException) e.getCause(); - } - throw new JDOFatalInternalException(e.getMessage()); + /** Constructor only for Externalizable. + */ + public ObjectIdentity () { } - } - - /** The delimiter for String constructor. */ - private static final String STRING_DELIMITER = ":"; // NOI18N - - /** - * Constructor with class and key. - * - * @param pcClass the class - * @param param the key - */ - @SuppressWarnings("static-access") - public ObjectIdentity(Class pcClass, Object param) { - super(pcClass); - assertKeyNotNull(param); - String paramString = null; - String keyString = null; - String className = null; - if (param instanceof String) { - /* The paramString is of the form ":" */ - paramString = (String) param; - if (paramString.length() < 3) { - throw new JDOUserException( - msg.msg("EXC_ObjectIdentityStringConstructionTooShort") - + // NOI18N - msg.msg( - "EXC_ObjectIdentityStringConstructionUsage", // NOI18N - paramString)); - } - int indexOfDelimiter = paramString.indexOf(STRING_DELIMITER); - if (indexOfDelimiter < 0) { - throw new JDOUserException( - msg.msg("EXC_ObjectIdentityStringConstructionNoDelimiter") - + // NOI18N - msg.msg( - "EXC_ObjectIdentityStringConstructionUsage", // NOI18N - paramString)); - } - keyString = paramString.substring(indexOfDelimiter + 1); - className = paramString.substring(0, indexOfDelimiter); - keyAsObject = helper.construct(className, keyString); - } else { - keyAsObject = param; + + /** Return the key. + * @return the key + */ + public Object getKey () { + return keyAsObject; } - hashCode = hashClassName() ^ keyAsObject.hashCode(); - } - - /** Constructor only for Externalizable. */ - public ObjectIdentity() {} - - /** - * Return the key. - * - * @return the key - */ - public Object getKey() { - return keyAsObject; - } - - /** - * Return the String form of the object id. The class of the object id is written as the first - * part of the result so that the class can be reconstructed later. Then the toString of the key - * instance is appended. During construction, this process is reversed. The class is extracted - * from the first part of the String, and the String constructor of the key is used to construct - * the key itself. - * - * @return the String form of the key - */ - @Override - public String toString() { - return keyAsObject.getClass().getName() + STRING_DELIMITER + keyAsObject.toString(); - } - - /** - * Determine if the other object represents the same object id. - * - * @param obj the other object - * @return true if both objects represent the same object id - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } else if (!super.equals(obj)) { - return false; - } else { - ObjectIdentity other = (ObjectIdentity) obj; - return keyAsObject.equals(other.keyAsObject); + + /** Return the String form of the object id. The class of the + * object id is written as the first part of the result so that + * the class can be reconstructed later. Then the toString + * of the key instance is appended. During construction, + * this process is reversed. The class is extracted from + * the first part of the String, and the String constructor + * of the key is used to construct the key itself. + * @return the String form of the key + */ + @Override + public String toString () { + return keyAsObject.getClass().getName() + + STRING_DELIMITER + + keyAsObject.toString(); } - } - - /** - * Provide the hash code for this instance. The hash code is the hash code of the contained key. - * - * @return the hash code - */ - @Override - public int hashCode() { - return keyAsObject.hashCode(); - } - - /** - * Determine the ordering of identity objects. - * - * @param o Other identity - * @return The relative ordering between the objects - * @since 2.2 - */ - @SuppressWarnings("unchecked") - public int compareTo(Object o) { - if (o instanceof ObjectIdentity) { - ObjectIdentity other = (ObjectIdentity) o; - int result = super.compare(other); - if (result == 0) { - if (other.keyAsObject instanceof Comparable && keyAsObject instanceof Comparable) { - return ((Comparable) keyAsObject).compareTo((Comparable) other.keyAsObject); + + /** Determine if the other object represents the same object id. + * @param obj the other object + * @return true if both objects represent the same object id + */ + @Override + public boolean equals (Object obj) { + if (this == obj) { + return true; + } else if (!super.equals (obj)) { + return false; } else { - throw new ClassCastException( - "The key class (" - + keyAsObject.getClass().getName() - + ") does not implement Comparable"); + ObjectIdentity other = (ObjectIdentity) obj; + return keyAsObject.equals(other.keyAsObject); + } + } + + /** Provide the hash code for this instance. The hash code is the + * hash code of the contained key. + * @return the hash code + */ + @Override + public int hashCode() { + return keyAsObject.hashCode(); + } + + /** Determine the ordering of identity objects. + * @param o Other identity + * @return The relative ordering between the objects + * @since 2.2 + */ + @SuppressWarnings("unchecked") + public int compareTo(Object o) { + if (o instanceof ObjectIdentity) { + ObjectIdentity other = (ObjectIdentity)o; + int result = super.compare(other); + if (result == 0) { + if (other.keyAsObject instanceof Comparable && + keyAsObject instanceof Comparable) { + return ((Comparable)keyAsObject).compareTo( + (Comparable)other.keyAsObject); + } + else + { + throw new ClassCastException("The key class (" + + keyAsObject.getClass().getName() + + ") does not implement Comparable"); + } + } else { + return result; + } + } + else if (o == null) { + throw new ClassCastException("object is null"); } - } else { - return result; - } - } else if (o == null) { - throw new ClassCastException("object is null"); + throw new ClassCastException(this.getClass().getName() + + " != " + o.getClass().getName()); + } + + /** Write this object. Write the superclass first. + * @param out the output + */ + @Override + public void writeExternal(ObjectOutput out) throws IOException { + super.writeExternal (out); + out.writeObject(keyAsObject); + } + + /** Read this object. Read the superclass first. + * @param in the input + */ + @Override + public void readExternal(ObjectInput in) + throws IOException, ClassNotFoundException { + super.readExternal (in); + keyAsObject = in.readObject(); } - throw new ClassCastException(this.getClass().getName() + " != " + o.getClass().getName()); - } - - /** - * Write this object. Write the superclass first. - * - * @param out the output - */ - @Override - public void writeExternal(ObjectOutput out) throws IOException { - super.writeExternal(out); - out.writeObject(keyAsObject); - } - - /** - * Read this object. Read the superclass first. - * - * @param in the input - */ - @Override - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - super.readExternal(in); - keyAsObject = in.readObject(); - } + } diff --git a/api/src/main/java/javax/jdo/identity/ShortIdentity.java b/api/src/main/java/javax/jdo/identity/ShortIdentity.java index 4430b27d1..c7dee68eb 100644 --- a/api/src/main/java/javax/jdo/identity/ShortIdentity.java +++ b/api/src/main/java/javax/jdo/identity/ShortIdentity.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,148 +19,132 @@ * ShortIdentity.java * */ - + package javax.jdo.identity; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; -/** - * This class is for identity with a single short field. - * +/** This class is for identity with a single short field. * @version 2.0 */ -public class ShortIdentity extends SingleFieldIdentity { - private short key; - - private void construct(short key) { - this.key = key; - hashCode = hashClassName() ^ key; - } +public class ShortIdentity + extends SingleFieldIdentity +{ + private short key; + + private void construct(short key) { + this.key = key; + hashCode = hashClassName() ^ key; + } - /** - * Constructor with class and key. - * - * @param pcClass the class - * @param key the key - */ - public ShortIdentity(Class pcClass, short key) { - super(pcClass); - construct(key); - } + /** Constructor with class and key. + * @param pcClass the class + * @param key the key + */ + public ShortIdentity (Class pcClass, short key) { + super(pcClass); + construct(key); + } - /** - * Constructor with class and key. - * - * @param pcClass the class - * @param key the key - */ - public ShortIdentity(Class pcClass, Short key) { - super(pcClass); - setKeyAsObject(key); - construct(key.shortValue()); - } + /** Constructor with class and key. + * @param pcClass the class + * @param key the key + */ + public ShortIdentity (Class pcClass, Short key) { + super(pcClass); + setKeyAsObject(key); + construct(key.shortValue()); + } - /** - * Constructor with class and key. - * - * @param pcClass the class - * @param str the key - */ - public ShortIdentity(Class pcClass, String str) { - super(pcClass); - assertKeyNotNull(str); - construct(Short.parseShort(str)); - } + /** Constructor with class and key. + * @param pcClass the class + * @param str the key + */ + public ShortIdentity (Class pcClass, String str) { + super(pcClass); + assertKeyNotNull(str); + construct(Short.parseShort (str)); + } - /** Constructor only for Externalizable. */ - public ShortIdentity() {} + /** Constructor only for Externalizable. + */ + public ShortIdentity () { + } - /** - * Return the key. - * - * @return the key - */ - public short getKey() { - return key; - } + /** Return the key. + * @return the key + */ + public short getKey () { + return key; + } - /** - * Return the String form of the key. - * - * @return the String form of the key - */ - public String toString() { - return Short.toString(key); - } + /** Return the String form of the key. + * @return the String form of the key + */ + public String toString () { + return Short.toString(key); + } - /** - * Determine if the other object represents the same object id. - * - * @param obj the other object - * @return true if both objects represent the same object id - */ - public boolean equals(Object obj) { - if (this == obj) { - return true; - } else if (!super.equals(obj)) { - return false; - } else { - ShortIdentity other = (ShortIdentity) obj; - return key == other.key; + /** Determine if the other object represents the same object id. + * @param obj the other object + * @return true if both objects represent the same object id + */ + public boolean equals (Object obj) { + if (this == obj) { + return true; + } else if (!super.equals (obj)) { + return false; + } else { + ShortIdentity other = (ShortIdentity) obj; + return key == other.key; + } } - } - /** - * Determine the ordering of identity objects. - * - * @param o Other identity - * @return The relative ordering between the objects - * @since 2.2 - */ - public int compareTo(Object o) { - if (o instanceof ShortIdentity) { - ShortIdentity other = (ShortIdentity) o; - int result = super.compare(other); - if (result == 0) { - return (key - other.key); - } else { - return result; - } - } else if (o == null) { - throw new ClassCastException("object is null"); + /** Determine the ordering of identity objects. + * @param o Other identity + * @return The relative ordering between the objects + * @since 2.2 + */ + public int compareTo(Object o) { + if (o instanceof ShortIdentity) { + ShortIdentity other = (ShortIdentity)o; + int result = super.compare(other); + if (result == 0) { + return (key - other.key); + } else { + return result; + } + } + else if (o == null) { + throw new ClassCastException("object is null"); + } + throw new ClassCastException(this.getClass().getName() + " != " + o.getClass().getName()); } - throw new ClassCastException(this.getClass().getName() + " != " + o.getClass().getName()); - } - /** - * Create the key as an Object. - * - * @return the key as an Object - * @since 2.0 - */ - protected Object createKeyAsObject() { - return Short.valueOf(key); - } + /** Create the key as an Object. + * @return the key as an Object + * @since 2.0 + */ + protected Object createKeyAsObject() { + return Short.valueOf(key); + } - /** - * Write this object. Write the superclass first. - * - * @param out the output - */ - public void writeExternal(ObjectOutput out) throws IOException { - super.writeExternal(out); - out.writeShort(key); - } + /** Write this object. Write the superclass first. + * @param out the output + */ + public void writeExternal(ObjectOutput out) throws IOException { + super.writeExternal (out); + out.writeShort(key); + } - /** - * Read this object. Read the superclass first. - * - * @param in the input - */ - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - super.readExternal(in); - key = in.readShort(); - } + /** Read this object. Read the superclass first. + * @param in the input + */ + public void readExternal(ObjectInput in) + throws IOException, ClassNotFoundException { + super.readExternal (in); + key = in.readShort(); + } } diff --git a/api/src/main/java/javax/jdo/identity/SingleFieldIdentity.java b/api/src/main/java/javax/jdo/identity/SingleFieldIdentity.java index 4d53b7ab6..4a1dda648 100644 --- a/api/src/main/java/javax/jdo/identity/SingleFieldIdentity.java +++ b/api/src/main/java/javax/jdo/identity/SingleFieldIdentity.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,192 +19,184 @@ * SingleFieldIdentity.java * */ - + package javax.jdo.identity; import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; + import javax.jdo.JDOFatalInternalException; import javax.jdo.JDONullIdentityException; + import javax.jdo.spi.I18NHelper; -/** - * This class is the abstract base class for all single field identity classes. A common case of - * application identity uses exactly one persistent field in the class to represent identity. In - * this case, the application can use a standard JDO class instead of creating a new user-defined - * class for the purpose. - * +/** This class is the abstract base class for all single field identity + * classes. A common case of application identity uses exactly one + * persistent field in the class to represent identity. In this case, + * the application can use a standard JDO class instead of creating + * a new user-defined class for the purpose. * @version 2.0 */ -public abstract class SingleFieldIdentity implements Externalizable, Comparable { - - /** The Internationalization message helper. */ - protected static I18NHelper msg = I18NHelper.getInstance("javax.jdo.Bundle"); // NOI18N - - /** The class of the target object. */ - private transient Class targetClass; - - /** The name of the class of the target object. */ - private String targetClassName; - - /** The hashCode. */ - protected int hashCode; - - /** The key as an Object. */ - protected Object keyAsObject; - - /** - * Constructor with target class. - * - * @param pcClass the class of the target - * @since 2.0 - */ - protected SingleFieldIdentity(Class pcClass) { - if (pcClass == null) throw new NullPointerException(); - targetClass = pcClass; - targetClassName = pcClass.getName(); - } - - /** - * Constructor only for Externalizable. - * - * @since 2.0 - */ - public SingleFieldIdentity() {} - - /** - * Set the given key as the key for this instance. Compute the hash code for the instance. - * - * @param key The key to use - * @since 2.0 - */ - protected void setKeyAsObject(Object key) { - assertKeyNotNull(key); - keyAsObject = key; - } - - /** - * Assert that the key is not null. Throw a JDONullIdentityException if the given key is null. - * - * @param key The key to check - * @since 2.0 - */ - protected void assertKeyNotNull(Object key) { - if (key == null) { - throw new JDONullIdentityException(msg.msg("EXC_SingleFieldIdentityNullParameter")); // NOI18N +public abstract class SingleFieldIdentity + implements Externalizable, Comparable { + + /** The Internationalization message helper. + */ + protected static I18NHelper msg = I18NHelper.getInstance ("javax.jdo.Bundle"); //NOI18N + + /** The class of the target object. + */ + transient private Class targetClass; + + /** The name of the class of the target object. + */ + private String targetClassName; + + /** The hashCode. + */ + protected int hashCode; + + /** The key as an Object. + */ + protected Object keyAsObject; + + /** Constructor with target class. + * @param pcClass the class of the target + * @since 2.0 + */ + protected SingleFieldIdentity(Class pcClass) { + if (pcClass == null) + throw new NullPointerException(); + targetClass = pcClass; + targetClassName = pcClass.getName(); + } + + /** Constructor only for Externalizable. + * @since 2.0 + */ + public SingleFieldIdentity () { + } + + /** Set the given key as the key for this instance. + * Compute the hash code for the instance. + * @param key The key to use + * @since 2.0 + */ + protected void setKeyAsObject(Object key) { + assertKeyNotNull(key); + keyAsObject = key; + } + + /** Assert that the key is not null. Throw a JDONullIdentityException + * if the given key is null. + * @param key The key to check + * @since 2.0 + */ + protected void assertKeyNotNull(Object key) { + if (key == null) { + throw new JDONullIdentityException( + msg.msg("EXC_SingleFieldIdentityNullParameter")); //NOI18N + } } - } - - /** - * Return the target class. - * - * @return the target class. - * @since 2.0 - */ - public Class getTargetClass() { - return targetClass; - } - - /** - * Return the target class name. - * - * @return the target class name. - * @since 2.0 - */ - public String getTargetClassName() { - return targetClassName; - } - - /** - * Return the key as an Object. The method is synchronized to avoid race conditions in - * multi-threaded environments. - * - * @return the key as an Object. - * @since 2.0 - */ - public synchronized Object getKeyAsObject() { - if (keyAsObject == null) { - keyAsObject = createKeyAsObject(); + + /** Return the target class. + * @return the target class. + * @since 2.0 + */ + public Class getTargetClass() { + return targetClass; } - return keyAsObject; - } - - /** - * Create the key as an Object. - * - * @return the key as an Object; - * @since 2.0 - */ - protected Object createKeyAsObject() { - throw new JDOFatalInternalException(msg.msg("EXC_CreateKeyAsObjectMustNotBeCalled")); - } - - /** - * Check the class and class name and object type. If restored from serialization, class will be - * null so compare class name. - * - * @param obj the other object - * @return true if the class or class name is the same - */ - public boolean equals(Object obj) { - if (this == obj) { - return true; - } else if (obj == null || this.getClass() != obj.getClass()) { - return false; - } else { - SingleFieldIdentity other = (SingleFieldIdentity) obj; - if (targetClass != null && targetClass == other.targetClass) return true; - return targetClassName.equals(other.targetClassName); + + /** Return the target class name. + * @return the target class name. + * @since 2.0 + */ + public String getTargetClassName() { + return targetClassName; + } + + /** Return the key as an Object. The method is synchronized to avoid + * race conditions in multi-threaded environments. + * @return the key as an Object. + * @since 2.0 + */ + public synchronized Object getKeyAsObject() { + if (keyAsObject == null) { + keyAsObject = createKeyAsObject(); + } + return keyAsObject; + } + + /** Create the key as an Object. + * @return the key as an Object; + * @since 2.0 + */ + protected Object createKeyAsObject() { + throw new JDOFatalInternalException + (msg.msg("EXC_CreateKeyAsObjectMustNotBeCalled")); + } + + /** Check the class and class name and object type. If restored + * from serialization, class will be null so compare class name. + * @param obj the other object + * @return true if the class or class name is the same + */ + public boolean equals(Object obj) { + if (this == obj) { + return true; + } else if (obj == null || this.getClass() != obj.getClass()) { + return false; + } else { + SingleFieldIdentity other = (SingleFieldIdentity) obj; + if (targetClass != null && targetClass == other.targetClass) + return true; + return targetClassName.equals (other.targetClassName); + } + } + + /** Return the hash code of the class name. + * @return the hash code of the class name + * @since 2.0 + */ + protected int hashClassName() { + return targetClassName.hashCode(); + } + + /** Return the cached hash code. + * @return the cached hash code. + */ + public int hashCode() { + return hashCode; + } + + /** Write to the output stream. + * @param out the stream + */ + public void writeExternal(ObjectOutput out) throws IOException { + out.writeObject(targetClassName); + out.writeInt(hashCode); } - } - - /** - * Return the hash code of the class name. - * - * @return the hash code of the class name - * @since 2.0 - */ - protected int hashClassName() { - return targetClassName.hashCode(); - } - - /** - * Return the cached hash code. - * - * @return the cached hash code. - */ - public int hashCode() { - return hashCode; - } - - /** - * Write to the output stream. - * - * @param out the stream - */ - public void writeExternal(ObjectOutput out) throws IOException { - out.writeObject(targetClassName); - out.writeInt(hashCode); - } - - /** Read from the input stream. Creates a new instance with the target class name set */ - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - targetClass = null; - targetClassName = (String) in.readObject(); - hashCode = in.readInt(); - } - - /** - * Determine the ordering of identity objects. Only the class name is compared. This method is - * only used by subclasses. - * - * @param o Other identity - * @return The relative ordering between the objects - * @since 2.2 - */ - protected int compare(SingleFieldIdentity o) { - return targetClassName.compareTo(o.targetClassName); - } + + /** Read from the input stream. + * Creates a new instance with the target class name set + */ + public void readExternal(ObjectInput in) + throws IOException, ClassNotFoundException { + targetClass = null; + targetClassName = (String)in.readObject(); + hashCode = in.readInt(); + } + + /** Determine the ordering of identity objects. Only the class name + * is compared. This method is only used by subclasses. + * @param o Other identity + * @return The relative ordering between the objects + * @since 2.2 + */ + protected int compare(SingleFieldIdentity o) { + return targetClassName.compareTo(o.targetClassName); + } + } diff --git a/api/src/main/java/javax/jdo/identity/StringIdentity.java b/api/src/main/java/javax/jdo/identity/StringIdentity.java index 5a63cd40f..80f0ac20c 100644 --- a/api/src/main/java/javax/jdo/identity/StringIdentity.java +++ b/api/src/main/java/javax/jdo/identity/StringIdentity.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,111 +19,100 @@ * StringIdentity.java * */ - + package javax.jdo.identity; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; -/** - * This class is for identity with a single String field. - * +/** This class is for identity with a single String field. * @version 2.0 */ public class StringIdentity extends SingleFieldIdentity { + + /** The key is stored in the superclass field keyAsObject. + */ + + /** Constructor with class and key. + * @param pcClass the class + * @param key the key + */ + public StringIdentity (Class pcClass, String key) { + super (pcClass); + setKeyAsObject(key); + hashCode = hashClassName() ^ key.hashCode(); + } - /** The key is stored in the superclass field keyAsObject. */ - - /** - * Constructor with class and key. - * - * @param pcClass the class - * @param key the key - */ - public StringIdentity(Class pcClass, String key) { - super(pcClass); - setKeyAsObject(key); - hashCode = hashClassName() ^ key.hashCode(); - } - - /** Constructor only for Externalizable. */ - public StringIdentity() {} + /** Constructor only for Externalizable. + */ + public StringIdentity () { + } - /** - * Return the key. - * - * @return the key - */ - public String getKey() { - return (String) keyAsObject; - } + /** Return the key. + * @return the key + */ + public String getKey () { + return (String)keyAsObject; + } - /** - * Return the String form of the key. - * - * @return the String form of the key - */ - public String toString() { - return (String) keyAsObject; - } + /** Return the String form of the key. + * @return the String form of the key + */ + public String toString () { + return (String)keyAsObject; + } - /** - * Determine if the other object represents the same object id. - * - * @param obj the other object - * @return true if both objects represent the same object id - */ - public boolean equals(Object obj) { - if (this == obj) { - return true; - } else if (!super.equals(obj)) { - return false; - } else { - StringIdentity other = (StringIdentity) obj; - return keyAsObject.equals(other.keyAsObject); + /** Determine if the other object represents the same object id. + * @param obj the other object + * @return true if both objects represent the same object id + */ + public boolean equals (Object obj) { + if (this == obj) { + return true; + } else if (!super.equals (obj)) { + return false; + } else { + StringIdentity other = (StringIdentity) obj; + return keyAsObject.equals(other.keyAsObject); + } } - } - /** - * Determine the ordering of identity objects. - * - * @param o Other identity - * @return The relative ordering between the objects - * @since 2.2 - */ - public int compareTo(Object o) { - if (o instanceof StringIdentity) { - StringIdentity other = (StringIdentity) o; - int result = super.compare(other); - if (result == 0) { - return ((String) keyAsObject).compareTo((String) other.keyAsObject); - } else { - return result; - } - } else if (o == null) { - throw new ClassCastException("object is null"); + /** Determine the ordering of identity objects. + * @param o Other identity + * @return The relative ordering between the objects + * @since 2.2 + */ + public int compareTo(Object o) { + if (o instanceof StringIdentity) { + StringIdentity other = (StringIdentity)o; + int result = super.compare(other); + if (result == 0) { + return ((String)keyAsObject).compareTo((String)other.keyAsObject); + } else { + return result; + } + } + else if (o == null) { + throw new ClassCastException("object is null"); + } + throw new ClassCastException(this.getClass().getName() + " != " + o.getClass().getName()); } - throw new ClassCastException(this.getClass().getName() + " != " + o.getClass().getName()); - } - /** - * Write this object. Write the superclass first. - * - * @param out the output - */ - public void writeExternal(ObjectOutput out) throws IOException { - super.writeExternal(out); - out.writeObject(keyAsObject); - } + /** Write this object. Write the superclass first. + * @param out the output + */ + public void writeExternal(ObjectOutput out) throws IOException { + super.writeExternal (out); + out.writeObject(keyAsObject); + } - /** - * Read this object. Read the superclass first. - * - * @param in the input - */ - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - super.readExternal(in); - keyAsObject = (String) in.readObject(); - } + /** Read this object. Read the superclass first. + * @param in the input + */ + public void readExternal(ObjectInput in) + throws IOException, ClassNotFoundException { + super.readExternal (in); + keyAsObject = (String)in.readObject(); + } } diff --git a/api/src/main/java/javax/jdo/listener/AttachCallback.java b/api/src/main/java/javax/jdo/listener/AttachCallback.java index a43bee3a6..140d2af02 100644 --- a/api/src/main/java/javax/jdo/listener/AttachCallback.java +++ b/api/src/main/java/javax/jdo/listener/AttachCallback.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,32 +19,32 @@ * AttachCallback.java * */ - + package javax.jdo.listener; /** * This interface is used to notify instances of attach events. - * * @version 2.0 * @since 2.0 */ public interface AttachCallback { + + /** + * This method is called during the execution of + * {@link javax.jdo.PersistenceManager#makePersistent} on the detached + * instance before the copy is made. + * @since 2.0 + */ + public void jdoPreAttach(); - /** - * This method is called during the execution of {@link - * javax.jdo.PersistenceManager#makePersistent} on the detached instance before the copy is made. - * - * @since 2.0 - */ - public void jdoPreAttach(); - - /** - * This method is called during the execution of {@link - * javax.jdo.PersistenceManager#makePersistent} on the persistent instance after the copy is made. - * - * @param attached The corresponding (non-attached) instance that was attached in the call to - * {@link javax.jdo.PersistenceManager#makePersistent}. - * @since 2.0 - */ - public void jdoPostAttach(Object attached); + /** + * This method is called during the execution of + * {@link javax.jdo.PersistenceManager#makePersistent} on the persistent + * instance after the copy is made. + * @param attached The corresponding (non-attached) instance that was + * attached in the call to + * {@link javax.jdo.PersistenceManager#makePersistent}. + * @since 2.0 + */ + public void jdoPostAttach(Object attached); } diff --git a/api/src/main/java/javax/jdo/listener/AttachLifecycleListener.java b/api/src/main/java/javax/jdo/listener/AttachLifecycleListener.java index c0423e1cd..15ba883a6 100644 --- a/api/src/main/java/javax/jdo/listener/AttachLifecycleListener.java +++ b/api/src/main/java/javax/jdo/listener/AttachLifecycleListener.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,36 +19,38 @@ * AttachLifecycleListener.java * */ - + package javax.jdo.listener; /** - * This interface is implemented by listeners to be notified of attach events. - * + * This interface is implemented by listeners to be notified of + * attach events. * @version 2.0 * @since 2.0 */ -public interface AttachLifecycleListener extends InstanceLifecycleListener { - - /** - * This method is called before a detached instance is attached, via the {@link - * javax.jdo.PersistenceManager#makePersistent} method. The source instance is the detached - * instance. This method is called before the corresponding {@link AttachCallback#jdoPreAttach} on - * the detached instance. - * - * @param event the attach event. - * @since 2.0 - */ - void preAttach(InstanceLifecycleEvent event); - - /** - * This method is called after a detached instance is attached, via the {@link - * javax.jdo.PersistenceManager#makePersistent} method. The source instance is the corresponding - * persistent instance in the cache; the target instance is the detached instance. This method is - * called after the corresponding {@link AttachCallback#jdoPostAttach} on the persistent instance. - * - * @param event the attach event. - * @since 2.0 - */ - void postAttach(InstanceLifecycleEvent event); +public interface AttachLifecycleListener + extends InstanceLifecycleListener { + + /** + * This method is called before a detached instance is attached, via the + * {@link javax.jdo.PersistenceManager#makePersistent} method. The source + * instance is the detached instance. This method is called before the + * corresponding {@link AttachCallback#jdoPreAttach} on the detached + * instance. + * @param event the attach event. + * @since 2.0 + */ + void preAttach (InstanceLifecycleEvent event); + + /** + * This method is called after a detached instance is attached, via the + * {@link javax.jdo.PersistenceManager#makePersistent} method. The source + * instance is the corresponding persistent instance in the cache; the + * target instance is the detached instance. This method is called after + * the corresponding {@link AttachCallback#jdoPostAttach} on the + * persistent instance. + * @param event the attach event. + * @since 2.0 + */ + void postAttach (InstanceLifecycleEvent event); } diff --git a/api/src/main/java/javax/jdo/listener/ClearCallback.java b/api/src/main/java/javax/jdo/listener/ClearCallback.java index 11a72d495..f9a2956e9 100644 --- a/api/src/main/java/javax/jdo/listener/ClearCallback.java +++ b/api/src/main/java/javax/jdo/listener/ClearCallback.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,24 +19,25 @@ * ClearCallback.java * */ - + package javax.jdo.listener; + /** * This interface is used to notify instances of clear events. - * * @version 2.0 * @since 2.0 */ public interface ClearCallback { - - /** - * Called before the values in the instance are cleared. - * - *

    Transient fields should be cleared in this method. Associations between this instance and - * others in the runtime environment should be cleared. - * - *

    This method is not modified by the enhancer. - */ - void jdoPreClear(); + + /** + * Called before the values in the instance are cleared. + * + *

    Transient fields should be cleared in this method. + * Associations between this + * instance and others in the runtime environment should be cleared. + * + *

    This method is not modified by the enhancer. + */ + void jdoPreClear(); } diff --git a/api/src/main/java/javax/jdo/listener/ClearLifecycleListener.java b/api/src/main/java/javax/jdo/listener/ClearLifecycleListener.java index 6c360c21a..174d4f4bd 100644 --- a/api/src/main/java/javax/jdo/listener/ClearLifecycleListener.java +++ b/api/src/main/java/javax/jdo/listener/ClearLifecycleListener.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -23,36 +23,37 @@ package javax.jdo.listener; /** - * This interface is implemented by listeners to be notified of clear events. - * + * This interface is implemented by listeners to be notified of + * clear events. * @version 2.0 * @since 2.0 */ -public interface ClearLifecycleListener extends InstanceLifecycleListener { - - /** - * This method is called before the implementation calls the instance method {@link - * ClearCallback#jdoPreClear} and before it clears the values in the instance to their Java - * default values. This happens during an application call to evict, and in afterCompletion for - * commit with RetainValues false and rollback with RestoreValues false. - * - *

    The method is called during any state transition to hollow. Non-persistent, - * non-transactional fields should be cleared in this method. Associations between this instance - * and others in the runtime environment should be cleared. - * - *

    This method is not modified by the enhancer, so access to fields is not mediated. - * - * @param event the clear event. - * @since 2.0 - */ - void preClear(InstanceLifecycleEvent event); +public interface ClearLifecycleListener + extends InstanceLifecycleListener { - /** - * This method is called after the {@link ClearCallback#jdoPreClear} method is invoked on the - * instance and the fields have been cleared by the JDO implementation. - * - * @param event the clear event. - * @since 2.0 - */ - void postClear(InstanceLifecycleEvent event); + /** + * This method is called before the implementation calls the instance + * method {@link ClearCallback#jdoPreClear} and before it clears the values + * in the instance to their Java default values. This happens during + * an application call to evict, and in afterCompletion for commit + * with RetainValues false and rollback with RestoreValues false. + *

    The method is called during any state transition to hollow. + * Non-persistent, non-transactional fields should be cleared + * in this method. Associations between this instance and others + * in the runtime environment should be cleared. + *

    This method is not modified by the enhancer, so access to fields + * is not mediated. + * @param event the clear event. + * @since 2.0 + */ + void preClear (InstanceLifecycleEvent event); + + /** + * This method is called after the {@link ClearCallback#jdoPreClear} + * method is invoked on the instance and the fields have been cleared + * by the JDO implementation. + * @param event the clear event. + * @since 2.0 + */ + void postClear (InstanceLifecycleEvent event); } diff --git a/api/src/main/java/javax/jdo/listener/CreateLifecycleListener.java b/api/src/main/java/javax/jdo/listener/CreateLifecycleListener.java index ebd1ed0db..2480cc4dd 100644 --- a/api/src/main/java/javax/jdo/listener/CreateLifecycleListener.java +++ b/api/src/main/java/javax/jdo/listener/CreateLifecycleListener.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -23,19 +23,20 @@ package javax.jdo.listener; /** - * This interface is implemented by listeners to be notified of create events. - * + * This interface is implemented by listeners to be notified of + * create events. * @version 2.0 * @since 2.0 */ -public interface CreateLifecycleListener extends InstanceLifecycleListener { +public interface CreateLifecycleListener + extends InstanceLifecycleListener { - /** - * Invoked whenever an instance is made persistent via a call to {@link - * javax.jdo.PersistenceManager#makePersistent} or during persistence by reachability. - * - * @param event the create event. - * @since 2.0 - */ - void postCreate(InstanceLifecycleEvent event); + /** + * Invoked whenever an instance is made persistent via a + * call to {@link javax.jdo.PersistenceManager#makePersistent} or during + * persistence by reachability. + * @param event the create event. + * @since 2.0 + */ + void postCreate (InstanceLifecycleEvent event); } diff --git a/api/src/main/java/javax/jdo/listener/DeleteCallback.java b/api/src/main/java/javax/jdo/listener/DeleteCallback.java index 6283ca2de..7d78064f9 100644 --- a/api/src/main/java/javax/jdo/listener/DeleteCallback.java +++ b/api/src/main/java/javax/jdo/listener/DeleteCallback.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,23 +19,24 @@ * DeleteCallback.java * */ - + package javax.jdo.listener; -/** + +/** * This interface is used to notify instances of delete events. - * * @version 2.0 * @since 2.0 */ -public interface DeleteCallback { - /** - * Called before the instance is deleted. This method is called before the state transition to - * persistent-deleted or persistent-new-deleted. Access to field values within this call are - * valid. Access to field values after this call are disallowed. - * - *

    This method is modified by the enhancer so that fields referenced can be used in the - * business logic of the method. - */ - void jdoPreDelete(); +public interface DeleteCallback +{ + /** + * Called before the instance is deleted. + * This method is called before the state transition to persistent-deleted + * or persistent-new-deleted. Access to field values within this call + * are valid. Access to field values after this call are disallowed. + *

    This method is modified by the enhancer so that fields referenced + * can be used in the business logic of the method. + */ + void jdoPreDelete(); } diff --git a/api/src/main/java/javax/jdo/listener/DeleteLifecycleListener.java b/api/src/main/java/javax/jdo/listener/DeleteLifecycleListener.java index d90eb595e..444ce3eed 100644 --- a/api/src/main/java/javax/jdo/listener/DeleteLifecycleListener.java +++ b/api/src/main/java/javax/jdo/listener/DeleteLifecycleListener.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -23,34 +23,32 @@ package javax.jdo.listener; /** - * This interface is implemented by listeners to be notified of delete events. - * + * This interface is implemented by listeners to be notified of + * delete events. * @version 2.0 * @since 2.0 */ -public interface DeleteLifecycleListener extends InstanceLifecycleListener { +public interface DeleteLifecycleListener + extends InstanceLifecycleListener { - /** - * Invoked whenever a persistent instance is deleted, for example during {@link - * javax.jdo.PersistenceManager#deletePersistent}. Access to field values within this call are - * permitted. - * - *

    This method is called before the instance callback {@link DeleteCallback#jdoPreDelete}. - * - * @param event the delete event. - * @since 2.0 - */ - void preDelete(InstanceLifecycleEvent event); + /** + * Invoked whenever a persistent instance is deleted, for example + * during {@link javax.jdo.PersistenceManager#deletePersistent}. + * Access to field values within this call are permitted. + *

    This method is called before the instance callback + * {@link DeleteCallback#jdoPreDelete}. + * @param event the delete event. + * @since 2.0 + */ + void preDelete (InstanceLifecycleEvent event); - /** - * Invoked whenever a persistent instance is deleted, for example during {@link - * javax.jdo.PersistenceManager#deletePersistent}. - * - *

    This method is called after the instance transitions to persistent-deleted. Access to field - * values is not permitted. - * - * @param event the delete event. - * @since 2.0 - */ - void postDelete(InstanceLifecycleEvent event); + /** + * Invoked whenever a persistent instance is deleted, for example + * during {@link javax.jdo.PersistenceManager#deletePersistent}. + *

    This method is called after the instance transitions + * to persistent-deleted. Access to field values is not permitted. + * @param event the delete event. + * @since 2.0 + */ + void postDelete (InstanceLifecycleEvent event); } diff --git a/api/src/main/java/javax/jdo/listener/DetachCallback.java b/api/src/main/java/javax/jdo/listener/DetachCallback.java index 8beccf095..0c7404693 100644 --- a/api/src/main/java/javax/jdo/listener/DetachCallback.java +++ b/api/src/main/java/javax/jdo/listener/DetachCallback.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,31 +19,30 @@ * DetachCallback.java * */ - + package javax.jdo.listener; /** * This interface is used to notify instances of detach events. - * * @version 2.0 * @since 2.0 */ public interface DetachCallback { + + /** + * This method is called during the execution of + * {@link javax.jdo.PersistenceManager#detachCopy} on the + * persistent instance before the copy is made. + * @since 2.0 + */ + public void jdoPreDetach(); - /** - * This method is called during the execution of {@link javax.jdo.PersistenceManager#detachCopy} - * on the persistent instance before the copy is made. - * - * @since 2.0 - */ - public void jdoPreDetach(); - - /** - * This method is called during the execution of {@link javax.jdo.PersistenceManager#detachCopy} - * on the detached instance after the copy is made. - * - * @param detached The corresponding (attached) persistent instance. - * @since 2.0 - */ - public void jdoPostDetach(Object detached); + /** + * This method is called during the execution of + * {@link javax.jdo.PersistenceManager#detachCopy} on the + * detached instance after the copy is made. + * @param detached The corresponding (attached) persistent instance. + * @since 2.0 + */ + public void jdoPostDetach(Object detached); } diff --git a/api/src/main/java/javax/jdo/listener/DetachLifecycleListener.java b/api/src/main/java/javax/jdo/listener/DetachLifecycleListener.java index f239efbe6..90645edef 100644 --- a/api/src/main/java/javax/jdo/listener/DetachLifecycleListener.java +++ b/api/src/main/java/javax/jdo/listener/DetachLifecycleListener.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,34 +19,37 @@ * DetachLifecycleListener.java * */ - + package javax.jdo.listener; /** - * This interface is implemented by listeners to be notified of detach events. - * + * This interface is implemented by listeners to be notified of + * detach events. * @version 2.0 * @since 2.0 */ -public interface DetachLifecycleListener extends InstanceLifecycleListener { - - /** - * This method is called during the execution of {@link javax.jdo.PersistenceManager#detachCopy} - * before the detached copy is made. It is called before the method {@link - * DetachCallback#jdoPreDetach} is called on the instance to be detached. - * - * @param event the detach event. - * @since 2.0 - */ - void preDetach(InstanceLifecycleEvent event); - - /** - * This method is called during the execution of {@link javax.jdo.PersistenceManager#detachCopy} - * after the detached copy is made. It is called after the method {@link - * DetachCallback#jdoPreDetach} is called on the detached instance. - * - * @param event the detach event. - * @since 2.0 - */ - void postDetach(InstanceLifecycleEvent event); +public interface DetachLifecycleListener + extends InstanceLifecycleListener { + + /** + * This method is called during the execution of + * {@link javax.jdo.PersistenceManager#detachCopy} before the + * detached copy is made. It is called before the method + * {@link DetachCallback#jdoPreDetach} is called on the + * instance to be detached. + * @param event the detach event. + * @since 2.0 + */ + void preDetach (InstanceLifecycleEvent event); + + /** + * This method is called during the execution of + * {@link javax.jdo.PersistenceManager#detachCopy} after the + * detached copy is made. It is called after the method + * {@link DetachCallback#jdoPreDetach} is called on + * the detached instance. + * @param event the detach event. + * @since 2.0 + */ + void postDetach (InstanceLifecycleEvent event); } diff --git a/api/src/main/java/javax/jdo/listener/DirtyLifecycleListener.java b/api/src/main/java/javax/jdo/listener/DirtyLifecycleListener.java index 39c9ce583..240d28e14 100644 --- a/api/src/main/java/javax/jdo/listener/DirtyLifecycleListener.java +++ b/api/src/main/java/javax/jdo/listener/DirtyLifecycleListener.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -23,28 +23,28 @@ package javax.jdo.listener; /** - * This interface is implemented by listeners to be notified of dirty events. - * + * This interface is implemented by listeners to be notified of + * dirty events. * @version 2.0 * @since 2.0 */ public interface DirtyLifecycleListener extends InstanceLifecycleListener { - /** - * Invoked whenever a persistent instance is first made dirty, during an operation that modifies - * the value of a persistent or transactional field. Called before the value is changed. - * - * @param event The lifecycle event - * @since 2.0 - */ - void preDirty(InstanceLifecycleEvent event); + /** + * Invoked whenever a persistent instance is first made dirty, + * during an operation that modifies the value of a persistent or + * transactional field. Called before the value is changed. + * @param event The lifecycle event + * @since 2.0 + */ + void preDirty (InstanceLifecycleEvent event); - /** - * Invoked whenever a persistent instance is first made dirty, during an operation that modifies - * the value of a persistent or transactional field. Called after the value is changed. - * - * @param event The lifecycle event - * @since 2.0 - */ - void postDirty(InstanceLifecycleEvent event); + /** + * Invoked whenever a persistent instance is first made dirty, + * during an operation that modifies the value of a persistent or + * transactional field. Called after the value is changed. + * @param event The lifecycle event + * @since 2.0 + */ + void postDirty (InstanceLifecycleEvent event); } diff --git a/api/src/main/java/javax/jdo/listener/InstanceLifecycleEvent.java b/api/src/main/java/javax/jdo/listener/InstanceLifecycleEvent.java index 3348a84bc..fabfdbee6 100644 --- a/api/src/main/java/javax/jdo/listener/InstanceLifecycleEvent.java +++ b/api/src/main/java/javax/jdo/listener/InstanceLifecycleEvent.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -26,157 +26,163 @@ /** * This is the event class used in life cycle event notifications. - * - *

    Note that although InstanceLifecycleEvent inherits Serializable interface from EventObject, it - * is not intended to be Serializable. Appropriate serialization methods are implemented to throw - * NotSerializableException. - * + *

    Note that although InstanceLifecycleEvent inherits Serializable interface + * from EventObject, it is not intended to be Serializable. Appropriate + * serialization methods are implemented to throw NotSerializableException. * @version 2.0 * @since 2.0 */ public class InstanceLifecycleEvent extends java.util.EventObject { - private static final long serialVersionUID = -1338786292441991812L; - - private static final int FIRST_EVENT_TYPE = 0; - public static final int CREATE = 0; - public static final int LOAD = 1; - public static final int STORE = 2; - public static final int CLEAR = 3; - public static final int DELETE = 4; - public static final int DIRTY = 5; - public static final int DETACH = 6; - public static final int ATTACH = 7; - private static final int LAST_EVENT_TYPE = 7; - - /** The Internationalization message helper. */ - private static final I18NHelper msg = I18NHelper.getInstance("javax.jdo.Bundle"); // NOI18N - - /** The event type that triggered the construction of this event object. */ - private final int eventType; - - /** The "other" object associated with the event. */ - private final Object target; - - /** - * Creates a new event object with the specified source and type. - * - * @param source the instance that triggered the event - * @param type the event type - * @since 2.0 - */ - public InstanceLifecycleEvent(Object source, int type) { - this(source, type, null); - } - - /** - * Creates a new event object with the specified source, type, and - * target. - * - * @param source the instance that triggered the event - * @param type the event type - * @param target the "other" instance - * @since 2.0 - */ - public InstanceLifecycleEvent(Object source, int type, Object target) { - super(source); - if (type < FIRST_EVENT_TYPE || type > LAST_EVENT_TYPE) { - throw new IllegalArgumentException(msg.msg("EXC_IllegalEventType")); + private static final long serialVersionUID = -1338786292441991812L; + + private static final int FIRST_EVENT_TYPE = 0; + public static final int CREATE = 0; + public static final int LOAD = 1; + public static final int STORE = 2; + public static final int CLEAR = 3; + public static final int DELETE = 4; + public static final int DIRTY = 5; + public static final int DETACH = 6; + public static final int ATTACH = 7; + private static final int LAST_EVENT_TYPE = 7; + + /** The Internationalization message helper. */ + private final static I18NHelper msg = I18NHelper.getInstance ("javax.jdo.Bundle"); //NOI18N + + /** The event type that triggered the construction of this event object. */ + private final int eventType; + + /** The "other" object associated with the event. */ + private final Object target; + + /** + * Creates a new event object with the specified + * source and type. + * @param source the instance that triggered the event + * @param type the event type + * @since 2.0 + */ + public InstanceLifecycleEvent (Object source, int type) { + this(source, type, null); + } + + /** + * Creates a new event object with the specified + * source, type, and target. + * @param source the instance that triggered the event + * @param type the event type + * @param target the "other" instance + * @since 2.0 + */ + public InstanceLifecycleEvent (Object source, int type, Object target) { + super (source); + if (type < FIRST_EVENT_TYPE || type > LAST_EVENT_TYPE) { + throw new IllegalArgumentException(msg.msg("EXC_IllegalEventType")); + } + eventType = type; + this.target = target; + } + + /** + * Returns the event type that triggered this event. + * @return the event type + * @since 2.0 + */ + public int getEventType () { + return eventType; + } + + /** + * The source object of the Event. Although not deprecated, + * it is recommended that the the methods + * getPersistentInstance() and + * getDetachedInstance() be used instead. + * + * @return The persistent instance on any pre- callback except preAttach, + * or the detached instance for a postDetach or preAttach callback. + * + * @see #getPersistentInstance() + * @see #getDetachedInstance() + * @see "Section 12.15, Java Data Objects 2.0 Specification" + */ + public Object getSource() { + return super.getSource(); } - eventType = type; - this.target = target; - } - - /** - * Returns the event type that triggered this event. - * - * @return the event type - * @since 2.0 - */ - public int getEventType() { - return eventType; - } - - /** - * The source object of the Event. Although not deprecated, it is recommended that the the methods - * getPersistentInstance() and getDetachedInstance() be used instead. - * - * @return The persistent instance on any pre- callback except preAttach, or the detached instance - * for a postDetach or preAttach callback. - * @see #getPersistentInstance() - * @see #getDetachedInstance() - * @see "Section 12.15, Java Data Objects 2.0 Specification" - */ - public Object getSource() { - return super.getSource(); - } - - /** - * The target object of the Event. Although not deprecated, it is recommended that the the methods - * getPersistentInstance() and getDetachedInstance() be used instead. - * - * @return The detached instance for preDetach and postAttach, the persistent instance otherwise. - * @since 2.0 - * @see #getPersistentInstance() - * @see #getDetachedInstance() - * @see "Section 12.15, Java Data Objects 2.0 Specification" - */ - public Object getTarget() { - return target; - } - - /** - * Returns the persistent instance involved in the event. - * - * @return The persistent instance involved in the event, or null if there was none. - * @see "Section 12.15, Java Data Objects 2.0 Specification" - */ - public Object getPersistentInstance() { - switch (getEventType()) { - case DETACH: - return target == null - ? getSource() // preDetach: source is persistent instance - : getTarget(); // postDetach: target is persistent instance - case ATTACH: - return target == null - ? null // preAttach: no persistent instance yet - : getSource(); // postAttach: source is persistent instance + + /** + * The target object of the Event. Although not deprecated, + * it is recommended that the the methods + * getPersistentInstance() and + * getDetachedInstance() be used instead. + * + * @return The detached instance for preDetach and postAttach, + * the persistent instance otherwise. + * + * @since 2.0 + * @see #getPersistentInstance() + * @see #getDetachedInstance() + * @see "Section 12.15, Java Data Objects 2.0 Specification" + */ + public Object getTarget () { + return target; } - // for all other events, source is persistent instance - return getSource(); - } - - /** - * Returns the detached instance involved in the event. - * - * @return The detached instance involved in the event, or null if there was none. - * @see "Section 12.15, Java Data Objects 2.0 Specification" - */ - public Object getDetachedInstance() { - switch (getEventType()) { - case DETACH: - return target == null - ? null // preDetach: no detached instance yet - : getSource(); // postDetach: source is detached instance - case ATTACH: - return target == null - ? getSource() // preAttach: source is detached instance - : getTarget(); // postAttach: target is detached instance + /** + * Returns the persistent instance involved in the event. + * + * @return The persistent instance involved in the event, or null if there + * was none. + * + * @see "Section 12.15, Java Data Objects 2.0 Specification" + */ + public Object getPersistentInstance() { + switch (getEventType()) { + case DETACH: + return target == null + ? getSource() // preDetach: source is persistent instance + : getTarget(); // postDetach: target is persistent instance + case ATTACH: + return target == null + ? null // preAttach: no persistent instance yet + : getSource(); // postAttach: source is persistent instance + } + + // for all other events, source is persistent instance + return getSource(); } - // for all other events, there is no detached instance - return null; - } - - /** - * Serialization is not supported for InstanceLifecycleEvents. - * - * @param out the output stream - * @throws java.io.IOException Thrown when an error occurs - * @since 2.0 - */ - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - throw new java.io.NotSerializableException(); - } + /** + * Returns the detached instance involved in the event. + * + * @return The detached instance involved in the event, or null if there was none. + * + * @see "Section 12.15, Java Data Objects 2.0 Specification" + */ + public Object getDetachedInstance() { + switch (getEventType()) { + case DETACH: + return target == null + ? null // preDetach: no detached instance yet + : getSource(); // postDetach: source is detached instance + case ATTACH: + return target == null + ? getSource() // preAttach: source is detached instance + : getTarget(); // postAttach: target is detached instance + } + + // for all other events, there is no detached instance + return null; + } + + /** + * Serialization is not supported for InstanceLifecycleEvents. + * @param out the output stream + * @throws java.io.IOException Thrown when an error occurs + * @since 2.0 + */ + private void writeObject(java.io.ObjectOutputStream out) + throws java.io.IOException { + throw new java.io.NotSerializableException(); + } } diff --git a/api/src/main/java/javax/jdo/listener/InstanceLifecycleListener.java b/api/src/main/java/javax/jdo/listener/InstanceLifecycleListener.java index 58aeb97ba..20c9a2b9a 100644 --- a/api/src/main/java/javax/jdo/listener/InstanceLifecycleListener.java +++ b/api/src/main/java/javax/jdo/listener/InstanceLifecycleListener.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -23,11 +23,13 @@ package javax.jdo.listener; /** - * All lifecycle listeners extend from this base interface. In order to minimize the impact on - * domain classes, instance callbacks can be defined to use a life-cycle listener pattern instead of + * All lifecycle listeners extend from this base interface. + * In order to minimize the impact on domain classes, instance callbacks + * can be defined to use a life-cycle listener pattern instead of * having the domain class implement the callback interface(s). * * @version 2.0 * @since 2.0 */ -public interface InstanceLifecycleListener {} +public interface InstanceLifecycleListener { +} diff --git a/api/src/main/java/javax/jdo/listener/LoadCallback.java b/api/src/main/java/javax/jdo/listener/LoadCallback.java index cbe630d04..3526c0608 100644 --- a/api/src/main/java/javax/jdo/listener/LoadCallback.java +++ b/api/src/main/java/javax/jdo/listener/LoadCallback.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,24 +19,24 @@ * LoadCallback.java * */ - + package javax.jdo.listener; /** * This interface is used to notify instances of load events. - * * @version 2.0 * @since 2.0 */ public interface LoadCallback { - - /** - * Called after the values are loaded from the data store into this instance. - * - *

    This method is not modified by the enhancer. - * - *

    Derived fields should be initialized in this method. The context in which this call is made - * does not allow access to other persistent JDO instances. - */ - void jdoPostLoad(); + + /** + * Called after the values are loaded from the data store into + * this instance. + * + *

    This method is not modified by the enhancer. + *

    Derived fields should be initialized in this method. + * The context in which this call is made does not allow access to + * other persistent JDO instances. + */ + void jdoPostLoad(); } diff --git a/api/src/main/java/javax/jdo/listener/LoadLifecycleListener.java b/api/src/main/java/javax/jdo/listener/LoadLifecycleListener.java index 2bd8d9cec..790992e97 100644 --- a/api/src/main/java/javax/jdo/listener/LoadLifecycleListener.java +++ b/api/src/main/java/javax/jdo/listener/LoadLifecycleListener.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -23,19 +23,20 @@ package javax.jdo.listener; /** - * This interface is implemented by listeners to be notified of load events. - * + * This interface is implemented by listeners to be notified of + * load events. * @version 2.0 * @since 2.0 */ -public interface LoadLifecycleListener extends InstanceLifecycleListener { +public interface LoadLifecycleListener + extends InstanceLifecycleListener { - /** - * Invoked whenever a persistent instance is loaded from the data store. It is called after the - * method {@link LoadCallback#jdoPostLoad} is invoked on the persistent instance. - * - * @param event the load event. - * @since 2.0 - */ - void postLoad(InstanceLifecycleEvent event); + /** + * Invoked whenever a persistent instance is loaded from the data + * store. It is called after the method {@link LoadCallback#jdoPostLoad} + * is invoked on the persistent instance. + * @param event the load event. + * @since 2.0 + */ + void postLoad (InstanceLifecycleEvent event); } diff --git a/api/src/main/java/javax/jdo/listener/StoreCallback.java b/api/src/main/java/javax/jdo/listener/StoreCallback.java index 31153bd41..e977257cf 100644 --- a/api/src/main/java/javax/jdo/listener/StoreCallback.java +++ b/api/src/main/java/javax/jdo/listener/StoreCallback.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,26 +19,27 @@ * StoreCallback.java * */ - + package javax.jdo.listener; /** * This interface is used to notify instances of store events. - * * @version 2.0 * @since 2.0 */ public interface StoreCallback { - - /** - * Called before the values are stored from this instance to the data store. - * - *

    Data store fields that might have been affected by modified non-persistent fields should be - * updated in this method. - * - *

    This method is modified by the enhancer so that changes to persistent fields will be - * reflected in the data store. The context in which this call is made allows access to the - * PersistenceManager and other persistent JDO instances. - */ - void jdoPreStore(); + + /** + * Called before the values are stored from this instance to the + * data store. + * + *

    Data store fields that might have been affected by modified + * non-persistent fields should be updated in this method. + * + *

    This method is modified by the enhancer so that changes to + * persistent fields will be reflected in the data store. + * The context in which this call is made allows access to the + * PersistenceManager and other persistent JDO instances. + */ + void jdoPreStore(); } diff --git a/api/src/main/java/javax/jdo/listener/StoreLifecycleListener.java b/api/src/main/java/javax/jdo/listener/StoreLifecycleListener.java index ac9232f87..01f28f897 100644 --- a/api/src/main/java/javax/jdo/listener/StoreLifecycleListener.java +++ b/api/src/main/java/javax/jdo/listener/StoreLifecycleListener.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -23,30 +23,31 @@ package javax.jdo.listener; /** - * This interface is implemented by listeners to be notified of store events. - * + * This interface is implemented by listeners to be notified of + * store events. * @version 2.0 * @since 2.0 */ -public interface StoreLifecycleListener extends InstanceLifecycleListener { - - /** - * Invoked whenever a persistent instance is stored, for example during {@link - * javax.jdo.PersistenceManager#flush} or {@link javax.jdo.Transaction#commit}. It is called - * before the method {@link StoreCallback#jdoPreStore} is invoked. - * - * @param event the store event. - * @since 2.0 - */ - void preStore(InstanceLifecycleEvent event); +public interface StoreLifecycleListener + extends InstanceLifecycleListener { - /** - * Invoked whenever a persistent instance is stored, for example during {@link - * javax.jdo.PersistenceManager#flush} or {@link javax.jdo.Transaction#commit}. It is called after - * the field values have been stored. - * - * @param event the store event. - * @since 2.0 - */ - void postStore(InstanceLifecycleEvent event); + /** + * Invoked whenever a persistent instance is stored, for example during + * {@link javax.jdo.PersistenceManager#flush} or + * {@link javax.jdo.Transaction#commit}. It is called before the + * method {@link StoreCallback#jdoPreStore} is invoked. + * @param event the store event. + * @since 2.0 + */ + void preStore (InstanceLifecycleEvent event); + + /** + * Invoked whenever a persistent instance is stored, for example during + * {@link javax.jdo.PersistenceManager#flush} or + * {@link javax.jdo.Transaction#commit}. It is called after the + * field values have been stored. + * @param event the store event. + * @since 2.0 + */ + void postStore (InstanceLifecycleEvent event); } diff --git a/api/src/main/java/javax/jdo/metadata/ArrayMetadata.java b/api/src/main/java/javax/jdo/metadata/ArrayMetadata.java index 25d9f063a..de81897ba 100644 --- a/api/src/main/java/javax/jdo/metadata/ArrayMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/ArrayMetadata.java @@ -18,67 +18,58 @@ /** * Represents details of an array in a field/property in a class. - * * @since 3.0 */ public interface ArrayMetadata extends Metadata { - /** - * Method to set the name of the element type. - * - * @param type Name of the element type - * @return This metadata object - */ - ArrayMetadata setElementType(String type); + /** + * Method to set the name of the element type. + * @param type Name of the element type + * @return This metadata object + */ + ArrayMetadata setElementType(String type); - /** - * Accessor for the element type. - * - * @return The element type - */ - String getElementType(); + /** + * Accessor for the element type. + * @return The element type + */ + String getElementType(); - /** - * Method to set whether the element is embedded. - * - * @param val Whether it is embedded - * @return This metadata object - */ - ArrayMetadata setEmbeddedElement(boolean val); + /** + * Method to set whether the element is embedded. + * @param val Whether it is embedded + * @return This metadata object + */ + ArrayMetadata setEmbeddedElement(boolean val); - /** - * Accessor for whether the element is embedded. - * - * @return whether the element is embedded - */ - Boolean getEmbeddedElement(); + /** + * Accessor for whether the element is embedded. + * @return whether the element is embedded + */ + Boolean getEmbeddedElement(); - /** - * Method to set whether the element is serialised. - * - * @param val Whether it is serialised - * @return This metadata object - */ - ArrayMetadata setSerializedElement(boolean val); + /** + * Method to set whether the element is serialised. + * @param val Whether it is serialised + * @return This metadata object + */ + ArrayMetadata setSerializedElement(boolean val); - /** - * Accessor for whether the element is serialised. - * - * @return whether the element is serialised - */ - Boolean getSerializedElement(); + /** + * Accessor for whether the element is serialised. + * @return whether the element is serialised + */ + Boolean getSerializedElement(); - /** - * Method to set whether the element is dependent. - * - * @param val Whether it is dependent - * @return This metadata object - */ - ArrayMetadata setDependentElement(boolean val); + /** + * Method to set whether the element is dependent. + * @param val Whether it is dependent + * @return This metadata object + */ + ArrayMetadata setDependentElement(boolean val); - /** - * Accessor for whether the element is dependent. - * - * @return whether the element is dependent - */ - Boolean getDependentElement(); + /** + * Accessor for whether the element is dependent. + * @return whether the element is dependent + */ + Boolean getDependentElement(); } diff --git a/api/src/main/java/javax/jdo/metadata/ClassMetadata.java b/api/src/main/java/javax/jdo/metadata/ClassMetadata.java index 8acc1b1c9..dfe59f5c7 100644 --- a/api/src/main/java/javax/jdo/metadata/ClassMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/ClassMetadata.java @@ -20,38 +20,33 @@ /** * Represents a class. - * * @since 3.0 */ public interface ClassMetadata extends TypeMetadata { - /** - * Method to define the persistence modifier. - * - * @param mod persistence modifier - * @return This metadata object - */ - ClassMetadata setPersistenceModifier(ClassPersistenceModifier mod); + /** + * Method to define the persistence modifier. + * @param mod persistence modifier + * @return This metadata object + */ + ClassMetadata setPersistenceModifier(ClassPersistenceModifier mod); - /** - * Accessor for the persistence modifier. - * - * @return persistence modifier - */ - ClassPersistenceModifier getPersistenceModifier(); + /** + * Accessor for the persistence modifier. + * @return persistence modifier + */ + ClassPersistenceModifier getPersistenceModifier(); - /** - * Add a new field to this class. - * - * @param name Name of the field - * @return The FieldMetadata - */ - FieldMetadata newFieldMetadata(String name); + /** + * Add a new field to this class. + * @param name Name of the field + * @return The FieldMetadata + */ + FieldMetadata newFieldMetadata(String name); - /** - * Add a new field to this class. - * - * @param fld The field - * @return The FieldMetadata - */ - FieldMetadata newFieldMetadata(Field fld); + /** + * Add a new field to this class. + * @param fld The field + * @return The FieldMetadata + */ + FieldMetadata newFieldMetadata(Field fld); } diff --git a/api/src/main/java/javax/jdo/metadata/ClassPersistenceModifier.java b/api/src/main/java/javax/jdo/metadata/ClassPersistenceModifier.java index 84f52a513..e8af23c81 100644 --- a/api/src/main/java/javax/jdo/metadata/ClassPersistenceModifier.java +++ b/api/src/main/java/javax/jdo/metadata/ClassPersistenceModifier.java @@ -18,11 +18,11 @@ /** * Enumeration of the persistence-modifier values for a class. - * * @since 3.0 */ -public enum ClassPersistenceModifier { - PERSISTENCE_CAPABLE, - PERSISTENCE_AWARE, - NON_PERSISTENT +public enum ClassPersistenceModifier +{ + PERSISTENCE_CAPABLE, + PERSISTENCE_AWARE, + NON_PERSISTENT } diff --git a/api/src/main/java/javax/jdo/metadata/CollectionMetadata.java b/api/src/main/java/javax/jdo/metadata/CollectionMetadata.java index fbae459af..f854f090e 100644 --- a/api/src/main/java/javax/jdo/metadata/CollectionMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/CollectionMetadata.java @@ -18,67 +18,58 @@ /** * Represents details of a collection in a field/property in a class. - * * @since 3.0 */ public interface CollectionMetadata extends Metadata { - /** - * Method to set the name of the element type. - * - * @param type Name of the element type - * @return This metadata object - */ - CollectionMetadata setElementType(String type); + /** + * Method to set the name of the element type. + * @param type Name of the element type + * @return This metadata object + */ + CollectionMetadata setElementType(String type); - /** - * Accessor for the element type. - * - * @return The element type - */ - String getElementType(); + /** + * Accessor for the element type. + * @return The element type + */ + String getElementType(); - /** - * Method to set whether the element is embedded. - * - * @param val Whether it is embedded - * @return This metadata object - */ - CollectionMetadata setEmbeddedElement(boolean val); + /** + * Method to set whether the element is embedded. + * @param val Whether it is embedded + * @return This metadata object + */ + CollectionMetadata setEmbeddedElement(boolean val); - /** - * Accessor for whether the element is embedded. - * - * @return whether the element is embedded - */ - Boolean getEmbeddedElement(); + /** + * Accessor for whether the element is embedded. + * @return whether the element is embedded + */ + Boolean getEmbeddedElement(); - /** - * Method to set whether the element is serialised. - * - * @param val Whether it is serialised - * @return This metadata object - */ - CollectionMetadata setSerializedElement(boolean val); + /** + * Method to set whether the element is serialised. + * @param val Whether it is serialised + * @return This metadata object + */ + CollectionMetadata setSerializedElement(boolean val); - /** - * Accessor for whether the element is serialised. - * - * @return whether the element is serialised - */ - Boolean getSerializedElement(); + /** + * Accessor for whether the element is serialised. + * @return whether the element is serialised + */ + Boolean getSerializedElement(); - /** - * Method to set whether the element is dependent. - * - * @param val Whether it is dependent - * @return This metadata object - */ - CollectionMetadata setDependentElement(boolean val); + /** + * Method to set whether the element is dependent. + * @param val Whether it is dependent + * @return This metadata object + */ + CollectionMetadata setDependentElement(boolean val); - /** - * Accessor for whether the element is dependent - * - * @return whether the element is dependent - */ - Boolean getDependentElement(); + /** + * Accessor for whether the element is dependent + * @return whether the element is dependent + */ + Boolean getDependentElement(); } diff --git a/api/src/main/java/javax/jdo/metadata/ColumnMetadata.java b/api/src/main/java/javax/jdo/metadata/ColumnMetadata.java index 248e9bcc2..a10919346 100644 --- a/api/src/main/java/javax/jdo/metadata/ColumnMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/ColumnMetadata.java @@ -18,172 +18,151 @@ /** * Represents an element in a collection/array. - * * @since 3.0 */ public interface ColumnMetadata extends Metadata { - /** - * Method to set the column name. - * - * @param name Column name - * @return This metadata object - */ - ColumnMetadata setName(String name); - - /** - * Accessor for the name of the column. - * - * @return The name - */ - String getName(); - - /** - * Method to set the target column (at the other side of the relation). - * - * @param target Target column - * @return This metadata object - */ - ColumnMetadata setTarget(String target); - - /** - * Accessor for the name of the target column. - * - * @return Target column name - */ - String getTarget(); - - /** - * Method to set the target field (at the other side of the relation). - * - * @param target Target field - * @return This metadata object - */ - ColumnMetadata setTargetField(String target); - - /** - * Accessor for the name of the target field. - * - * @return Target field name - */ - String getTargetField(); - - /** - * Method to set the JDBC type. - * - * @param type JDBC Type - * @return This metadata object - */ - ColumnMetadata setJDBCType(String type); - - /** - * Accessor for the JDBC Type. - * - * @return JDBC Type - */ - String getJDBCType(); - - /** - * Method to set the SQL type. - * - * @param type SQL Type - * @return This metadata object - */ - ColumnMetadata setSQLType(String type); - - /** - * Accessor for the SQL Type. - * - * @return SQL Type - */ - String getSQLType(); - - /** - * Method to set the length. - * - * @param len Length - * @return This metadata object - */ - ColumnMetadata setLength(int len); - - /** - * Accessor for the length. - * - * @return length - */ - Integer getLength(); - - /** - * Method to set the scale. - * - * @param scale scale - * @return This metadata object - */ - ColumnMetadata setScale(int scale); - - /** - * Accessor for the scale. - * - * @return scale - */ - Integer getScale(); - - /** - * Method to set whether it allows null. - * - * @param nulls Allows null? - * @return This metadata object - */ - ColumnMetadata setAllowsNull(boolean nulls); - - /** - * Accessor for whether the column allows null. - * - * @return Allows null? - */ - Boolean getAllowsNull(); - - /** - * Method to set the default value. - * - * @param val Default value - * @return This metadata object - */ - ColumnMetadata setDefaultValue(String val); - - /** - * Accessor for the default value. - * - * @return Default value - */ - String getDefaultValue(); - - /** - * Method to set the insert value (for columns with no field/property). - * - * @param val Insert value - * @return This metadata object - */ - ColumnMetadata setInsertValue(String val); - - /** - * Accessor for the insert value (for columns with no field/property) - * - * @return Insert value - */ - String getInsertValue(); - - /** - * Method to set the position. - * - * @param pos Position - * @return This metadata object - */ - ColumnMetadata setPosition(int pos); - - /** - * Accessor for the position. - * - * @return position - */ - Integer getPosition(); + /** + * Method to set the column name. + * @param name Column name + * @return This metadata object + */ + ColumnMetadata setName(String name); + + /** + * Accessor for the name of the column. + * @return The name + */ + String getName(); + + /** + * Method to set the target column (at the other side of the relation). + * @param target Target column + * @return This metadata object + */ + ColumnMetadata setTarget(String target); + + /** + * Accessor for the name of the target column. + * @return Target column name + */ + String getTarget(); + + /** + * Method to set the target field (at the other side of the relation). + * @param target Target field + * @return This metadata object + */ + ColumnMetadata setTargetField(String target); + + /** + * Accessor for the name of the target field. + * @return Target field name + */ + String getTargetField(); + + /** + * Method to set the JDBC type. + * @param type JDBC Type + * @return This metadata object + */ + ColumnMetadata setJDBCType(String type); + + /** + * Accessor for the JDBC Type. + * @return JDBC Type + */ + String getJDBCType(); + + /** + * Method to set the SQL type. + * @param type SQL Type + * @return This metadata object + */ + ColumnMetadata setSQLType(String type); + + /** + * Accessor for the SQL Type. + * @return SQL Type + */ + String getSQLType(); + + /** + * Method to set the length. + * @param len Length + * @return This metadata object + */ + ColumnMetadata setLength(int len); + + /** + * Accessor for the length. + * @return length + */ + Integer getLength(); + + /** + * Method to set the scale. + * @param scale scale + * @return This metadata object + */ + ColumnMetadata setScale(int scale); + + /** + * Accessor for the scale. + * @return scale + */ + Integer getScale(); + + /** + * Method to set whether it allows null. + * @param nulls Allows null? + * @return This metadata object + */ + ColumnMetadata setAllowsNull(boolean nulls); + + /** + * Accessor for whether the column allows null. + * + * @return Allows null? + */ + Boolean getAllowsNull(); + + /** + * Method to set the default value. + * @param val Default value + * @return This metadata object + */ + ColumnMetadata setDefaultValue(String val); + + /** + * Accessor for the default value. + * @return Default value + */ + String getDefaultValue(); + + /** + * Method to set the insert value (for columns with no field/property). + * @param val Insert value + * @return This metadata object + */ + ColumnMetadata setInsertValue(String val); + + /** + * Accessor for the insert value (for columns with no field/property) + * + * @return Insert value + */ + String getInsertValue(); + + /** + * Method to set the position. + * @param pos Position + * @return This metadata object + */ + ColumnMetadata setPosition(int pos); + + /** + * Accessor for the position. + * @return position + */ + Integer getPosition(); } diff --git a/api/src/main/java/javax/jdo/metadata/DatastoreIdentityMetadata.java b/api/src/main/java/javax/jdo/metadata/DatastoreIdentityMetadata.java index 3a09fb14a..f2d33165e 100644 --- a/api/src/main/java/javax/jdo/metadata/DatastoreIdentityMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/DatastoreIdentityMetadata.java @@ -20,88 +20,76 @@ /** * Represents the datastore identity of a class. - * * @since 3.0 */ public interface DatastoreIdentityMetadata extends Metadata { - /** - * Method to set the datastore identity column name. - * - * @param column Name of the datastore identity column - * @return This metadata object - */ - DatastoreIdentityMetadata setColumn(String column); + /** + * Method to set the datastore identity column name. + * @param column Name of the datastore identity column + * @return This metadata object + */ + DatastoreIdentityMetadata setColumn(String column); - /** - * Accessor for the datastore identity column name. - * - * @return The column name - */ - String getColumn(); + /** + * Accessor for the datastore identity column name. + * @return The column name + */ + String getColumn(); - /** - * Method to set the identity generation strategy. - * - * @param strategy The strategy - * @return This metadata object - */ - DatastoreIdentityMetadata setStrategy(IdGeneratorStrategy strategy); + /** + * Method to set the identity generation strategy. + * @param strategy The strategy + * @return This metadata object + */ + DatastoreIdentityMetadata setStrategy(IdGeneratorStrategy strategy); - /** - * Accessor for the identity generation strategy. - * - * @return The strategy - */ - IdGeneratorStrategy getStrategy(); + /** + * Accessor for the identity generation strategy. + * @return The strategy + */ + IdGeneratorStrategy getStrategy(); - /** - * Method to set the custom identity generation strategy. - * - * @param strategy The strategy - * @return This metadata object - */ - DatastoreIdentityMetadata setCustomStrategy(String strategy); + /** + * Method to set the custom identity generation strategy. + * @param strategy The strategy + * @return This metadata object + */ + DatastoreIdentityMetadata setCustomStrategy(String strategy); - /** - * Accessor for the custom strategy (overriding "strategy"). - * - * @return The strategy - */ - String getCustomStrategy(); + /** + * Accessor for the custom strategy (overriding "strategy"). + * @return The strategy + */ + String getCustomStrategy(); - /** - * Method to set the sequence key (when using "sequence" strategy). - * - * @param seq Sequence key - * @return This metadata object - */ - DatastoreIdentityMetadata setSequence(String seq); + /** + * Method to set the sequence key (when using "sequence" strategy). + * @param seq Sequence key + * @return This metadata object + */ + DatastoreIdentityMetadata setSequence(String seq); - /** - * Accessor for the sequence key (when using "sequence" strategy) - * - * @return The sequence - */ - String getSequence(); + /** + * Accessor for the sequence key (when using "sequence" strategy) + * @return The sequence + */ + String getSequence(); - /** - * Accessor for all column(s) defined on the datastore identity. - * - * @return The column(s) - */ - ColumnMetadata[] getColumns(); + /** + * Accessor for all column(s) defined on the datastore identity. + * @return The column(s) + */ + ColumnMetadata[] getColumns(); - /** - * Add a new column for this datastore identity. - * - * @return The ColumnMetadata - */ - ColumnMetadata newColumnMetadata(); + /** + * Add a new column for this datastore identity. + * @return The ColumnMetadata + */ + ColumnMetadata newColumnMetadata(); - /** - * Accessor for the number of columns defined for this datastore identity. - * - * @return The number of columns - */ - int getNumberOfColumns(); + /** + * Accessor for the number of columns defined for this datastore identity. + * @return The number of columns + */ + int getNumberOfColumns(); } diff --git a/api/src/main/java/javax/jdo/metadata/DiscriminatorMetadata.java b/api/src/main/java/javax/jdo/metadata/DiscriminatorMetadata.java index 67ac82931..88d57fd0d 100644 --- a/api/src/main/java/javax/jdo/metadata/DiscriminatorMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/DiscriminatorMetadata.java @@ -20,102 +20,88 @@ /** * Represents the discriminator for inheritance purposes for this class. - * * @since 3.0 */ public interface DiscriminatorMetadata extends Metadata { - /** - * Method to set the discriminator column. - * - * @param column Name of the discriminator column - * @return This metadata object - */ - DiscriminatorMetadata setColumn(String column); + /** + * Method to set the discriminator column. + * @param column Name of the discriminator column + * @return This metadata object + */ + DiscriminatorMetadata setColumn(String column); - /** - * Accessor for the discriminator column name - * - * @return The column name - */ - String getColumn(); + /** + * Accessor for the discriminator column name + * @return The column name + */ + String getColumn(); - /** - * Method to set the discriminator value (when using "value-map" strategy). - * - * @param val Value for the discriminator for this class - * @return This metadata object - */ - DiscriminatorMetadata setValue(String val); + /** + * Method to set the discriminator value (when using "value-map" strategy). + * @param val Value for the discriminator for this class + * @return This metadata object + */ + DiscriminatorMetadata setValue(String val); - /** - * Accessor for the discriminator value (when using "value-map" strategy). - * - * @return The value - */ - String getValue(); + /** + * Accessor for the discriminator value (when using "value-map" strategy). + * @return The value + */ + String getValue(); - /** - * Method to set the discriminator strategy. - * - * @param strategy The strategy - * @return This metadata object - */ - DiscriminatorMetadata setStrategy(DiscriminatorStrategy strategy); + /** + * Method to set the discriminator strategy. + * @param strategy The strategy + * @return This metadata object + */ + DiscriminatorMetadata setStrategy(DiscriminatorStrategy strategy); - /** - * Accessor for the discriminator strategy. - * - * @return The strategy - */ - DiscriminatorStrategy getStrategy(); + /** + * Accessor for the discriminator strategy. + * @return The strategy + */ + DiscriminatorStrategy getStrategy(); - /** - * Method to set whether indexed. - * - * @param indexed Whether indexed (true | false | unique) - * @return This metadata object - */ - DiscriminatorMetadata setIndexed(Indexed indexed); + /** + * Method to set whether indexed. + * @param indexed Whether indexed (true | false | unique) + * @return This metadata object + */ + DiscriminatorMetadata setIndexed(Indexed indexed); - /** - * Accessor for whether indexed (true|false|unique) - * - * @return Indexed? - */ - Indexed getIndexed(); + /** + * Accessor for whether indexed (true|false|unique) + * @return Indexed? + */ + Indexed getIndexed(); - /** - * Accessor for all column(s) defined on the discriminator. - * - * @return The column(s) - */ - ColumnMetadata[] getColumns(); + /** + * Accessor for all column(s) defined on the discriminator. + * @return The column(s) + */ + ColumnMetadata[] getColumns(); - /** - * Add a new column for this discriminator. - * - * @return The ColumnMetadata - */ - ColumnMetadata newColumnMetadata(); + /** + * Add a new column for this discriminator. + * @return The ColumnMetadata + */ + ColumnMetadata newColumnMetadata(); - /** - * Accessor for the number of columns defined for this discriminator. - * - * @return The number of columns - */ - int getNumberOfColumns(); + /** + * Accessor for the number of columns defined for this discriminator. + * @return The number of columns + */ + int getNumberOfColumns(); - /** - * Method to set the index metadata for the discriminator. - * - * @return The IndexMetadata - */ - IndexMetadata newIndexMetadata(); + /** + * Method to set the index metadata for the discriminator. + * @return The IndexMetadata + */ + IndexMetadata newIndexMetadata(); - /** - * Accessor for any index metadata for the discriminator. - * - * @return Index metadata - */ - IndexMetadata getIndexMetadata(); + /** + * Accessor for any index metadata for the discriminator. + * @return Index metadata + */ + IndexMetadata getIndexMetadata(); } diff --git a/api/src/main/java/javax/jdo/metadata/ElementMetadata.java b/api/src/main/java/javax/jdo/metadata/ElementMetadata.java index 55741b2ae..b7772969a 100644 --- a/api/src/main/java/javax/jdo/metadata/ElementMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/ElementMetadata.java @@ -21,176 +21,150 @@ /** * Represents an element in a collection/array. - * * @since 3.0 */ public interface ElementMetadata extends Metadata { - /** - * Method to set the column name. - * - * @param column Column name - * @return This metadata object - */ - ElementMetadata setColumn(String column); - - /** - * Accessor for the name of the column. - * - * @return The name - */ - String getColumn(); - - /** - * Method to set the table name. - * - * @param table Table name - * @return This metadata object - */ - ElementMetadata setTable(String table); - - /** - * Accessor for the name of the table. - * - * @return The name - */ - String getTable(); - - /** - * Method to set the delete action of the FK - * - * @param action Delete action of the FK - * @return This metadata object - */ - ElementMetadata setDeleteAction(ForeignKeyAction action); - - /** - * Accessor for the delete action of the FK - * - * @return The FK delete-action - */ - ForeignKeyAction getDeleteAction(); - - /** - * Method to set the update action of the FK - * - * @param action Update action of the FK - * @return This metadata object - */ - ElementMetadata setUpdateAction(ForeignKeyAction action); - - /** - * Accessor for the update action of the FK. - * - * @return The FK update-action - */ - ForeignKeyAction getUpdateAction(); - - /** - * Accessor for all column(s) defined on the element. - * - * @return The column(s) - */ - ColumnMetadata[] getColumns(); - - /** - * Add a new column for this element. - * - * @return The ColumnMetadata - */ - ColumnMetadata newColumnMetadata(); - - /** - * Accessor for the number of columns defined for this element. - * - * @return The number of columns - */ - int getNumberOfColumns(); - - /** - * Method to set new embedded metadata for the element. - * - * @return The EmbeddedMetadata - */ - EmbeddedMetadata newEmbeddedMetadata(); - - /** - * Accessor for any embedded metadata on this element. - * - * @return The EmbeddedMetadata - */ - EmbeddedMetadata getEmbeddedMetadata(); - - /** - * Method to set new index metadata for the element. - * - * @return The IndexMetadata - */ - IndexMetadata newIndexMetadata(); - - /** - * Accessor for any index metadata on this element - * - * @return Index metadata - */ - IndexMetadata getIndexMetadata(); - - /** - * Method to set new unique constraint metadata for the element. - * - * @return The UniqueMetadata - */ - UniqueMetadata newUniqueMetadata(); - - /** - * Accessor for any unique constraint metadata on this element. - * - * @return The UniqueMetadata - */ - UniqueMetadata getUniqueMetadata(); - - /** - * Method to set new foreign key metadata for the element. - * - * @return The ForeignKeyMetadata - */ - ForeignKeyMetadata newForeignKeyMetadata(); - - /** - * Accessor for any foreign key metadata on this element. - * - * @return The ForeignKeyMetadata - */ - ForeignKeyMetadata getForeignKeyMetadata(); - - /** - * Accessor for the attribute converter for this element (if any). - * - * @return The converter - */ - AttributeConverter getConverter(); - - /** - * Method to set the attribute converter to use for this element. - * - * @param conv Converter - * @return This metadata - */ - ElementMetadata setConverter(AttributeConverter conv); - - /** - * Accessor for whether any AttributeConverter for this element type is explicitly disabled and - * should use the implementation default. - * - * @return Whether it is disabled - */ - Boolean getUseDefaultConversion(); - - /** - * Method to explicitly set whether to disable use of AttributeConverter for this type (either - * here, class-level or PMF level). - * - * @param flag Whether to disable - * @return This metadata - */ - ElementMetadata setUseDefaultConversion(Boolean flag); + /** + * Method to set the column name. + * @param column Column name + * @return This metadata object + */ + ElementMetadata setColumn(String column); + + /** + * Accessor for the name of the column. + * @return The name + */ + String getColumn(); + + /** + * Method to set the table name. + * @param table Table name + * @return This metadata object + */ + ElementMetadata setTable(String table); + + /** + * Accessor for the name of the table. + * @return The name + */ + String getTable(); + + /** + * Method to set the delete action of the FK + * @param action Delete action of the FK + * @return This metadata object + */ + ElementMetadata setDeleteAction(ForeignKeyAction action); + + /** + * Accessor for the delete action of the FK + * @return The FK delete-action + */ + ForeignKeyAction getDeleteAction(); + + /** + * Method to set the update action of the FK + * @param action Update action of the FK + * @return This metadata object + */ + ElementMetadata setUpdateAction(ForeignKeyAction action); + + /** + * Accessor for the update action of the FK. + * @return The FK update-action + */ + ForeignKeyAction getUpdateAction(); + + /** + * Accessor for all column(s) defined on the element. + * @return The column(s) + */ + ColumnMetadata[] getColumns(); + + /** + * Add a new column for this element. + * @return The ColumnMetadata + */ + ColumnMetadata newColumnMetadata(); + + /** + * Accessor for the number of columns defined for this element. + * @return The number of columns + */ + int getNumberOfColumns(); + + /** + * Method to set new embedded metadata for the element. + * @return The EmbeddedMetadata + */ + EmbeddedMetadata newEmbeddedMetadata(); + + /** + * Accessor for any embedded metadata on this element. + * @return The EmbeddedMetadata + */ + EmbeddedMetadata getEmbeddedMetadata(); + + /** + * Method to set new index metadata for the element. + * @return The IndexMetadata + */ + IndexMetadata newIndexMetadata(); + + /** + * Accessor for any index metadata on this element + * @return Index metadata + */ + IndexMetadata getIndexMetadata(); + + /** + * Method to set new unique constraint metadata for the element. + * @return The UniqueMetadata + */ + UniqueMetadata newUniqueMetadata(); + + /** + * Accessor for any unique constraint metadata on this element. + * @return The UniqueMetadata + */ + UniqueMetadata getUniqueMetadata(); + + /** + * Method to set new foreign key metadata for the element. + * @return The ForeignKeyMetadata + */ + ForeignKeyMetadata newForeignKeyMetadata(); + + /** + * Accessor for any foreign key metadata on this element. + * @return The ForeignKeyMetadata + */ + ForeignKeyMetadata getForeignKeyMetadata(); + + /** + * Accessor for the attribute converter for this element (if any). + * @return The converter + */ + AttributeConverter getConverter(); + + /** + * Method to set the attribute converter to use for this element. + * @param conv Converter + * @return This metadata + */ + ElementMetadata setConverter(AttributeConverter conv); + + /** + * Accessor for whether any AttributeConverter for this element type is explicitly disabled and should use the implementation default. + * @return Whether it is disabled + */ + Boolean getUseDefaultConversion(); + + /** + * Method to explicitly set whether to disable use of AttributeConverter for this type (either here, class-level or PMF level). + * @param flag Whether to disable + * @return This metadata + */ + ElementMetadata setUseDefaultConversion(Boolean flag); } diff --git a/api/src/main/java/javax/jdo/metadata/EmbeddedMetadata.java b/api/src/main/java/javax/jdo/metadata/EmbeddedMetadata.java index 6c83374bf..6315b9675 100644 --- a/api/src/main/java/javax/jdo/metadata/EmbeddedMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/EmbeddedMetadata.java @@ -18,96 +18,83 @@ /** * Represents embedding details of a field/property in a class. - * * @since 3.0 */ public interface EmbeddedMetadata extends Metadata { - /** - * Method to set the name of the owner field/property. - * - * @param member Name of the owner member - * @return This metadata object - */ - EmbeddedMetadata setOwnerMember(String member); + /** + * Method to set the name of the owner field/property. + * @param member Name of the owner member + * @return This metadata object + */ + EmbeddedMetadata setOwnerMember(String member); - /** - * Accessor for the owner field/property name. - * - * @return The owner member name - */ - String getOwnerMember(); + /** + * Accessor for the owner field/property name. + * @return The owner member name + */ + String getOwnerMember(); - /** - * Method to set any column that indicates a null embedded object. - * - * @param col Null indicator column - * @return This metadata object - */ - EmbeddedMetadata setNullIndicatorColumn(String col); + /** + * Method to set any column that indicates a null embedded object. + * @param col Null indicator column + * @return This metadata object + */ + EmbeddedMetadata setNullIndicatorColumn(String col); - /** - * Accessor for any column indicating a null embedded object. - * - * @return Whether to call post-load - */ - String getNullIndicatorColumn(); + /** + * Accessor for any column indicating a null embedded object. + * @return Whether to call post-load + */ + String getNullIndicatorColumn(); - /** - * Method to set the value of a null indicator column to signify null object. - * - * @param val Null indicator value - * @return This metadata object - */ - EmbeddedMetadata setNullIndicatorValue(String val); + /** + * Method to set the value of a null indicator column to signify null object. + * @param val Null indicator value + * @return This metadata object + */ + EmbeddedMetadata setNullIndicatorValue(String val); - /** - * Accessor for a null indicator value. - * - * @return Null indicator value - */ - String getNullIndicatorValue(); + /** + * Accessor for a null indicator value. + * @return Null indicator value + */ + String getNullIndicatorValue(); - /** - * Accessor for all fields/properties defined on the fetch group. - * - * @return The members - */ - MemberMetadata[] getMembers(); + /** + * Accessor for all fields/properties defined on the fetch group. + * @return The members + */ + MemberMetadata[] getMembers(); - /** - * Accessor for the number of fields/properties defined for embedding. - * - * @return The number of members - */ - int getNumberOfMembers(); + /** + * Accessor for the number of fields/properties defined for embedding. + * @return The number of members + */ + int getNumberOfMembers(); - /** - * Add a new field to be embedded. - * - * @param name Name of the field - * @return The FieldMetadata - */ - FieldMetadata newFieldMetadata(String name); + /** + * Add a new field to be embedded. + * @param name Name of the field + * @return The FieldMetadata + */ + FieldMetadata newFieldMetadata(String name); - /** - * Add a new property for embedding. - * - * @param name Name of the property - * @return The PropertyMetadata - */ - PropertyMetadata newPropertyMetadata(String name); + /** + * Add a new property for embedding. + * @param name Name of the property + * @return The PropertyMetadata + */ + PropertyMetadata newPropertyMetadata(String name); - /** - * Accessor for the discriminator metadata when handling inherited objects. - * - * @return Discriminator details - */ - DiscriminatorMetadata getDiscriminatorMetadata(); + /** + * Accessor for the discriminator metadata when handling inherited objects. + * @return Discriminator details + */ + DiscriminatorMetadata getDiscriminatorMetadata(); - /** - * Method to define the new discriminator metadata for handling inherited embedded objects. - * - * @return Discriminator metadata - */ - DiscriminatorMetadata newDiscriminatorMetadata(); + /** + * Method to define the new discriminator metadata for handling inherited embedded objects. + * @return Discriminator metadata + */ + DiscriminatorMetadata newDiscriminatorMetadata(); } diff --git a/api/src/main/java/javax/jdo/metadata/ExtensionMetadata.java b/api/src/main/java/javax/jdo/metadata/ExtensionMetadata.java index b4855cc0f..1c5d5726d 100644 --- a/api/src/main/java/javax/jdo/metadata/ExtensionMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/ExtensionMetadata.java @@ -22,24 +22,21 @@ * @version 3.0 */ public interface ExtensionMetadata { - /** - * Accessor for the vendor name (set at construction). - * - * @return The vendor - */ - String getVendorName(); + /** + * Accessor for the vendor name (set at construction). + * @return The vendor + */ + String getVendorName(); - /** - * Accessor for the key (set at construction). - * - * @return The key - */ - String getKey(); + /** + * Accessor for the key (set at construction). + * @return The key + */ + String getKey(); - /** - * Accessor for the value (set at construction). - * - * @return The value - */ - String getValue(); + /** + * Accessor for the value (set at construction). + * @return The value + */ + String getValue(); } diff --git a/api/src/main/java/javax/jdo/metadata/FetchGroupMetadata.java b/api/src/main/java/javax/jdo/metadata/FetchGroupMetadata.java index b3716fd4d..82907bc10 100644 --- a/api/src/main/java/javax/jdo/metadata/FetchGroupMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/FetchGroupMetadata.java @@ -18,59 +18,51 @@ /** * Represents a fetch group for a class. - * * @since 3.0 */ public interface FetchGroupMetadata extends Metadata { - /** - * Accessor for the fetch group name (set on construction). - * - * @return The fetch group name - */ - String getName(); + /** + * Accessor for the fetch group name (set on construction). + * @return The fetch group name + */ + String getName(); - /** - * Method to set whether to call post load with this fetch group - * - * @param load Call post load - * @return This metadata object - */ - FetchGroupMetadata setPostLoad(boolean load); + /** + * Method to set whether to call post load with this fetch group + * @param load Call post load + * @return This metadata object + */ + FetchGroupMetadata setPostLoad(boolean load); - /** - * Accessor for whether to call post load for this fetch group. - * - * @return Whether to call post-load - */ - Boolean getPostLoad(); + /** + * Accessor for whether to call post load for this fetch group. + * @return Whether to call post-load + */ + Boolean getPostLoad(); - /** - * Accessor for all fields/properties defined on the fetch group. - * - * @return The members - */ - MemberMetadata[] getMembers(); + /** + * Accessor for all fields/properties defined on the fetch group. + * @return The members + */ + MemberMetadata[] getMembers(); - /** - * Accessor for the number of fields/properties defined for this fetch group. - * - * @return The number of members - */ - int getNumberOfMembers(); + /** + * Accessor for the number of fields/properties defined for this fetch group. + * @return The number of members + */ + int getNumberOfMembers(); - /** - * Add a new field for this fetch group. - * - * @param name Name of field - * @return The FieldMetadata - */ - FieldMetadata newFieldMetadata(String name); + /** + * Add a new field for this fetch group. + * @param name Name of field + * @return The FieldMetadata + */ + FieldMetadata newFieldMetadata(String name); - /** - * Add a new property for this fetch group. - * - * @param name Name of property - * @return The PropertyMetadata - */ - PropertyMetadata newPropertyMetadata(String name); + /** + * Add a new property for this fetch group. + * @param name Name of property + * @return The PropertyMetadata + */ + PropertyMetadata newPropertyMetadata(String name); } diff --git a/api/src/main/java/javax/jdo/metadata/FetchPlanMetadata.java b/api/src/main/java/javax/jdo/metadata/FetchPlanMetadata.java index 29bca1ed4..bcfc9d751 100644 --- a/api/src/main/java/javax/jdo/metadata/FetchPlanMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/FetchPlanMetadata.java @@ -18,66 +18,57 @@ /** * Represents a fetch plan for a class. - * * @since 3.0 */ public interface FetchPlanMetadata extends Metadata { - /** - * Accessor for the fetch plan name (set on construction). - * - * @return The fetch plan name - */ - String getName(); + /** + * Accessor for the fetch plan name (set on construction). + * @return The fetch plan name + */ + String getName(); - /** - * Method to set the max fetch depth for this plan. - * - * @param depth The max fetch depth - * @return This metadata object - */ - FetchPlanMetadata setMaxFetchDepth(int depth); + /** + * Method to set the max fetch depth for this plan. + * @param depth The max fetch depth + * @return This metadata object + */ + FetchPlanMetadata setMaxFetchDepth(int depth); - /** - * Accessor for the max fetch depth. - * - * @return The max fetch depth - */ - int getMaxFetchDepth(); + /** + * Accessor for the max fetch depth. + * @return The max fetch depth + */ + int getMaxFetchDepth(); - /** - * Method to set the fetch size. - * - * @param size The fetch size - * @return This metadata object - */ - FetchPlanMetadata setFetchSize(int size); + /** + * Method to set the fetch size. + * @param size The fetch size + * @return This metadata object + */ + FetchPlanMetadata setFetchSize(int size); - /** - * Accessor for the max fetch depth. - * - * @return The max fetch depth - */ - int getFetchSize(); + /** + * Accessor for the max fetch depth. + * @return The max fetch depth + */ + int getFetchSize(); - /** - * Accessor for all fetch groups defined for this fetch plan. - * - * @return The fetch groups - */ - FetchGroupMetadata[] getFetchGroups(); + /** + * Accessor for all fetch groups defined for this fetch plan. + * @return The fetch groups + */ + FetchGroupMetadata[] getFetchGroups(); - /** - * Add a new fetch group for this fetch plan. - * - * @param name Name of fetch group. - * @return The FetchGroupMetadata - */ - FetchGroupMetadata newFetchGroupMetadata(String name); + /** + * Add a new fetch group for this fetch plan. + * @param name Name of fetch group. + * @return The FetchGroupMetadata + */ + FetchGroupMetadata newFetchGroupMetadata(String name); - /** - * Accessor for the number of fetch groups defined for this fetch plan. - * - * @return The number of fetch groups - */ - int getNumberOfFetchGroups(); + /** + * Accessor for the number of fetch groups defined for this fetch plan. + * @return The number of fetch groups + */ + int getNumberOfFetchGroups(); } diff --git a/api/src/main/java/javax/jdo/metadata/FieldMetadata.java b/api/src/main/java/javax/jdo/metadata/FieldMetadata.java index 432f729f7..40220fce2 100644 --- a/api/src/main/java/javax/jdo/metadata/FieldMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/FieldMetadata.java @@ -18,7 +18,8 @@ /** * Represents a field in a class. - * * @since 3.0 */ -public interface FieldMetadata extends MemberMetadata {} +public interface FieldMetadata extends MemberMetadata { + +} diff --git a/api/src/main/java/javax/jdo/metadata/ForeignKeyMetadata.java b/api/src/main/java/javax/jdo/metadata/ForeignKeyMetadata.java index 33e286b22..f142950a4 100644 --- a/api/src/main/java/javax/jdo/metadata/ForeignKeyMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/ForeignKeyMetadata.java @@ -20,148 +20,130 @@ /** * Represents a FK constraint in an ORM context. - * * @since 3.0 */ public interface ForeignKeyMetadata extends Metadata { - /** - * Method to set the name of the constraint - * - * @param name Name of the constraint - * @return This metadata object - */ - ForeignKeyMetadata setName(String name); - - /** - * Accessor for the constraint name. - * - * @return The constraint name - */ - String getName(); - - /** - * Method to set the table name. - * - * @param table Table name - * @return This metadata object - */ - ForeignKeyMetadata setTable(String table); - - /** - * Accessor for the name of the table. - * - * @return The name - */ - String getTable(); - - /** - * Method to set whether it is unique. - * - * @param unique Unique? - * @return This metadata object - */ - ForeignKeyMetadata setUnique(boolean unique); - - /** - * Accessor for whether unique. - * - * @return Unique? - */ - Boolean getUnique(); - - /** - * Method to set whether it is deferred. - * - * @param def Deferred? - * @return This metadata object - */ - ForeignKeyMetadata setDeferred(boolean def); - - /** - * Accessor for whether the constraint can be deferred. - * - * @return Deferred? - */ - Boolean getDeferred(); - - /** - * Method to set the delete action of the FK - * - * @param action Delete action of the FK - * @return This metadata object - */ - ForeignKeyMetadata setDeleteAction(ForeignKeyAction action); - - /** - * Accessor for the delete action of the FK. - * - * @return The FK delete-action - */ - ForeignKeyAction getDeleteAction(); - - /** - * Method to set the update action of the FK. - * - * @param action Update action of the FK - * @return This metadata object - */ - ForeignKeyMetadata setUpdateAction(ForeignKeyAction action); - - /** - * Accessor for the update action of the FK. - * - * @return The FK update-action - */ - ForeignKeyAction getUpdateAction(); - - /** - * Accessor for all column(s) defined on the FK. - * - * @return The column(s) - */ - ColumnMetadata[] getColumns(); - - /** - * Add a new column for this FK. - * - * @return The ColumnMetadata - */ - ColumnMetadata newColumnMetadata(); - - /** - * Accessor for the number of columns defined for this FK. - * - * @return The number of columns - */ - int getNumberOfColumns(); - - /** - * Accessor for all fields/properties defined on the FK. - * - * @return The members - */ - MemberMetadata[] getMembers(); - - /** - * Accessor for the number of fields/properties defined for this FK. - * - * @return The number of members - */ - int getNumberOfMembers(); - - /** - * Add a new field for this FK. - * - * @param name Name of the field - * @return The FieldMetadata - */ - FieldMetadata newFieldMetadata(String name); - - /** - * Add a new property for this FK. - * - * @param name Name of the property - * @return The PropertyMetadata - */ - PropertyMetadata newPropertyMetadata(String name); + /** + * Method to set the name of the constraint + * @param name Name of the constraint + * @return This metadata object + */ + ForeignKeyMetadata setName(String name); + + /** + * Accessor for the constraint name. + * @return The constraint name + */ + String getName(); + + /** + * Method to set the table name. + * @param table Table name + * @return This metadata object + */ + ForeignKeyMetadata setTable(String table); + + /** + * Accessor for the name of the table. + * @return The name + */ + String getTable(); + + /** + * Method to set whether it is unique. + * @param unique Unique? + * @return This metadata object + */ + ForeignKeyMetadata setUnique(boolean unique); + + /** + * Accessor for whether unique. + * @return Unique? + */ + Boolean getUnique(); + + /** + * Method to set whether it is deferred. + * @param def Deferred? + * @return This metadata object + */ + ForeignKeyMetadata setDeferred(boolean def); + + /** + * Accessor for whether the constraint can be deferred. + * @return Deferred? + */ + Boolean getDeferred(); + + /** + * Method to set the delete action of the FK + * @param action Delete action of the FK + * @return This metadata object + */ + ForeignKeyMetadata setDeleteAction(ForeignKeyAction action); + + /** + * Accessor for the delete action of the FK. + * @return The FK delete-action + */ + ForeignKeyAction getDeleteAction(); + + /** + * Method to set the update action of the FK. + * @param action Update action of the FK + * @return This metadata object + */ + ForeignKeyMetadata setUpdateAction(ForeignKeyAction action); + + /** + * Accessor for the update action of the FK. + * @return The FK update-action + */ + ForeignKeyAction getUpdateAction(); + + /** + * Accessor for all column(s) defined on the FK. + * @return The column(s) + */ + ColumnMetadata[] getColumns(); + + /** + * Add a new column for this FK. + * @return The ColumnMetadata + */ + ColumnMetadata newColumnMetadata(); + + /** + * Accessor for the number of columns defined for this FK. + * @return The number of columns + */ + int getNumberOfColumns(); + + /** + * Accessor for all fields/properties defined on the FK. + * @return The members + */ + MemberMetadata[] getMembers(); + + /** + * Accessor for the number of fields/properties defined for this FK. + * @return The number of members + */ + int getNumberOfMembers(); + + /** + * Add a new field for this FK. + * + * @param name Name of the field + * @return The FieldMetadata + */ + FieldMetadata newFieldMetadata(String name); + + /** + * Add a new property for this FK. + * + * @param name Name of the property + * @return The PropertyMetadata + */ + PropertyMetadata newPropertyMetadata(String name); } diff --git a/api/src/main/java/javax/jdo/metadata/IndexMetadata.java b/api/src/main/java/javax/jdo/metadata/IndexMetadata.java index 0692cebf8..a8578bac4 100644 --- a/api/src/main/java/javax/jdo/metadata/IndexMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/IndexMetadata.java @@ -18,103 +18,90 @@ /** * Represents an index. - * * @since 3.0 */ public interface IndexMetadata extends Metadata { - /** - * Method to set the name of the index. - * - * @param name Name of the index - * @return This metadata object - */ - IndexMetadata setName(String name); + /** + * Method to set the name of the index. + * @param name Name of the index + * @return This metadata object + */ + IndexMetadata setName(String name); - /** - * Accessor for the index name. - * - * @return The index name - */ - String getName(); + /** + * Accessor for the index name. + * @return The index name + */ + String getName(); - /** - * Method to set the table name. - * - * @param table Table name - * @return This metadata object - */ - IndexMetadata setTable(String table); + /** + * Method to set the table name. + * @param table Table name + * @return This metadata object + */ + IndexMetadata setTable(String table); - /** - * Accessor for the name of the table. - * - * @return The name - */ - String getTable(); + /** + * Accessor for the name of the table. + * @return The name + */ + String getTable(); - /** - * Method to set whether it is unique. - * - * @param unique Unique? - * @return This metadata object - */ - IndexMetadata setUnique(boolean unique); + /** + * Method to set whether it is unique. + * + * @param unique Unique? + * @return This metadata object + */ + IndexMetadata setUnique(boolean unique); - /** - * Accessor for whether unique. - * - * @return Unique? - */ - boolean getUnique(); + /** + * Accessor for whether unique. + * @return Unique? + */ + boolean getUnique(); - /** - * Accessor for all column(s) defined on the index. - * - * @return The column(s) - */ - ColumnMetadata[] getColumns(); + /** + * Accessor for all column(s) defined on the index. + * @return The column(s) + */ + ColumnMetadata[] getColumns(); - /** - * Add a new column for this index. - * - * @return The ColumnMetadata - */ - ColumnMetadata newColumn(); + /** + * Add a new column for this index. + * @return The ColumnMetadata + */ + ColumnMetadata newColumn(); - /** - * Accessor for the number of columns defined for this index. - * - * @return The number of columns - */ - int getNumberOfColumns(); + /** + * Accessor for the number of columns defined for this index. + * @return The number of columns + */ + int getNumberOfColumns(); - /** - * Accessor for all member(s) defined on the index. - * - * @return The fields/properties - */ - MemberMetadata[] getMembers(); + /** + * Accessor for all member(s) defined on the index. + * @return The fields/properties + */ + MemberMetadata[] getMembers(); - /** - * Accessor for the number of fields/properties defined for this index. - * - * @return The number of members - */ - int getNumberOfMembers(); + /** + * Accessor for the number of fields/properties defined for this index. + * @return The number of members + */ + int getNumberOfMembers(); - /** - * Add a new field for this index. - * - * @param name Name of the field - * @return The FieldMetadata - */ - FieldMetadata newFieldMetadata(String name); + /** + * Add a new field for this index. + * @param name Name of the field + * @return The FieldMetadata + */ + FieldMetadata newFieldMetadata(String name); - /** - * Add a new property for this index. - * - * @param name Name of the property - * @return The PropertyMetadata - */ - PropertyMetadata newPropertyMetadata(String name); + /** + * Add a new property for this index. + * @param name Name of the property + * @return The PropertyMetadata + */ + PropertyMetadata newPropertyMetadata(String name); } diff --git a/api/src/main/java/javax/jdo/metadata/Indexed.java b/api/src/main/java/javax/jdo/metadata/Indexed.java index 01a0aba0c..f7b2b9973 100644 --- a/api/src/main/java/javax/jdo/metadata/Indexed.java +++ b/api/src/main/java/javax/jdo/metadata/Indexed.java @@ -18,13 +18,14 @@ /** * Enumeration of the indexed values. - * + * * @version 3.0 * @since 3.0 */ -public enum Indexed { - UNSPECIFIED, - TRUE, - FALSE, - UNIQUE +public enum Indexed +{ + UNSPECIFIED, + TRUE, + FALSE, + UNIQUE } diff --git a/api/src/main/java/javax/jdo/metadata/InheritanceMetadata.java b/api/src/main/java/javax/jdo/metadata/InheritanceMetadata.java index 15baa40e6..1d888baef 100644 --- a/api/src/main/java/javax/jdo/metadata/InheritanceMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/InheritanceMetadata.java @@ -20,65 +20,56 @@ /** * Represents the inheritance of a class. - * * @since 3.0 */ public interface InheritanceMetadata extends Metadata { - /** - * Method to set the inheritance strategy. - * - * @param strategy The strategy - * @return This metadata object - */ - InheritanceMetadata setStrategy(InheritanceStrategy strategy); + /** + * Method to set the inheritance strategy. + * @param strategy The strategy + * @return This metadata object + */ + InheritanceMetadata setStrategy(InheritanceStrategy strategy); - /** - * Accessor for the inheritance strategy. - * - * @return The strategy - */ - InheritanceStrategy getStrategy(); + /** + * Accessor for the inheritance strategy. + * @return The strategy + */ + InheritanceStrategy getStrategy(); - /** - * Method to set the custom inheritance strategy. - * - * @param strategy The strategy - * @return This metadata object - */ - InheritanceMetadata setCustomStrategy(String strategy); + /** + * Method to set the custom inheritance strategy. + * @param strategy The strategy + * @return This metadata object + */ + InheritanceMetadata setCustomStrategy(String strategy); - /** - * Accessor for the custom inheritance (overriding "strategy"). - * - * @return The strategy - */ - String getCustomStrategy(); + /** + * Accessor for the custom inheritance (overriding "strategy"). + * @return The strategy + */ + String getCustomStrategy(); - /** - * Method to define the new discriminator metadata. - * - * @return The DiscriminatorMetadata - */ - DiscriminatorMetadata newDiscriminatorMetadata(); + /** + * Method to define the new discriminator metadata. + * @return The DiscriminatorMetadata + */ + DiscriminatorMetadata newDiscriminatorMetadata(); - /** - * Accessor for the discriminator (if any). - * - * @return Discriminator - */ - DiscriminatorMetadata getDiscriminatorMetadata(); + /** + * Accessor for the discriminator (if any). + * @return Discriminator + */ + DiscriminatorMetadata getDiscriminatorMetadata(); - /** - * Method to define the new join information. - * - * @return The JoinMetadata - */ - JoinMetadata newJoinMetadata(); + /** + * Method to define the new join information. + * @return The JoinMetadata + */ + JoinMetadata newJoinMetadata(); - /** - * Accessor for the join (if any). - * - * @return Join information - */ - JoinMetadata getJoinMetadata(); + /** + * Accessor for the join (if any). + * @return Join information + */ + JoinMetadata getJoinMetadata(); } diff --git a/api/src/main/java/javax/jdo/metadata/InterfaceMetadata.java b/api/src/main/java/javax/jdo/metadata/InterfaceMetadata.java index 405472b63..b7ab60e8c 100644 --- a/api/src/main/java/javax/jdo/metadata/InterfaceMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/InterfaceMetadata.java @@ -18,7 +18,8 @@ /** * Represents a persistent-interface. - * * @since 3.0 */ -public interface InterfaceMetadata extends TypeMetadata {} +public interface InterfaceMetadata extends TypeMetadata { + +} diff --git a/api/src/main/java/javax/jdo/metadata/JDOMetadata.java b/api/src/main/java/javax/jdo/metadata/JDOMetadata.java index 3f6d72df8..5c2a2a444 100644 --- a/api/src/main/java/javax/jdo/metadata/JDOMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/JDOMetadata.java @@ -18,127 +18,117 @@ /** * Represents the top-level JDO metadata. - * * @since 3.0 */ public interface JDOMetadata extends Metadata { - /** - * Method to set the catalog (ORM) to apply to all classes in this JDO Metadata. - * - * @param catalog Catalog name - * @return This metadata object - */ - JDOMetadata setCatalog(String catalog); - - /** - * Accessor for the catalog (ORM) that all classes in this JDO Metadata default to. - * - * @return The catalog - */ - String getCatalog(); - - /** - * Method to set the schema (ORM) to apply to all classes in this JDO Metadata. - * - * @param schema Schema name - * @return This metadata object - */ - JDOMetadata setSchema(String schema); - - /** - * Accessor for the schema (ORM) that all classes in this JDO Metadata default to. - * - * @return The schema - */ - String getSchema(); - - /** - * Accessor for all packages defined on the JDO Metadata. - * - * @return The packages - */ - PackageMetadata[] getPackages(); - - /** - * Add a new package to this JDO Metadata. - * - * @param pkgName Name of the package - * @return The PackageMetadata - */ - PackageMetadata newPackageMetadata(String pkgName); - - /** - * Add a new package to this JDO Metadata. - * - * @param pkg The package - * @return The PackageMetadata - */ - PackageMetadata newPackageMetadata(Package pkg); - - /** - * Accessor for the number of packages defined in this JDO Metadata. - * - * @return The number of packages. - */ - int getNumberOfPackages(); - - /** - * Add a new class to this JDO Metadata. Adds its package also if not yet existing. - * - * @param cls Class to add - * @return The ClassMetadata - */ - ClassMetadata newClassMetadata(Class cls); - - /** - * Add a new interface to this JDO Metadata. Adds its package also if not yet existing. - * - * @param cls Class to add - * @return The InterfaceMetadata - */ - InterfaceMetadata newInterfaceMetadata(Class cls); - - /** - * Accessor for any named queries defined on the JDO Metadata. - * - * @return The queries - */ - QueryMetadata[] getQueries(); - - /** - * Add a new named query to this JDO Metadata. - * - * @param name Name of the query - * @return The QueryMetadata - */ - QueryMetadata newQueryMetadata(String name); - - /** - * Accessor for the number of named queries defined in this JDO Metadata. - * - * @return The number of queries. - */ - int getNumberOfQueries(); - - /** - * Accessor for any fetch plans defined on the JDO Metadata. - * - * @return The fetch plans - */ - FetchPlanMetadata[] getFetchPlans(); - - /** - * Add a new fetch plan to this JDO Metadata. - * - * @param name Name of the query - * @return The FetchPlanMetadata - */ - FetchPlanMetadata newFetchPlanMetadata(String name); - - /** - * Accessor for the number of fetch plans defined in this JDO Metadata. - * - * @return The number of fetch plans. - */ - int getNumberOfFetchPlans(); + /** + * Method to set the catalog (ORM) to apply to all classes in this + * JDO Metadata. + * @param catalog Catalog name + * @return This metadata object + */ + JDOMetadata setCatalog(String catalog); + + /** + * Accessor for the catalog (ORM) that all classes in this JDO Metadata + * default to. + * @return The catalog + */ + String getCatalog(); + + /** + * Method to set the schema (ORM) to apply to all classes in this JDO + * Metadata. + * @param schema Schema name + * @return This metadata object + */ + JDOMetadata setSchema(String schema); + + /** + * Accessor for the schema (ORM) that all classes in this JDO Metadata + * default to. + * @return The schema + */ + String getSchema(); + + /** + * Accessor for all packages defined on the JDO Metadata. + * @return The packages + */ + PackageMetadata[] getPackages(); + + /** + * Add a new package to this JDO Metadata. + * @param pkgName Name of the package + * @return The PackageMetadata + */ + PackageMetadata newPackageMetadata(String pkgName); + + /** + * Add a new package to this JDO Metadata. + * @param pkg The package + * @return The PackageMetadata + */ + PackageMetadata newPackageMetadata(Package pkg); + + /** + * Accessor for the number of packages defined in this JDO Metadata. + * @return The number of packages. + */ + int getNumberOfPackages(); + + /** + * Add a new class to this JDO Metadata. + * Adds its package also if not yet existing. + * @param cls Class to add + * @return The ClassMetadata + */ + ClassMetadata newClassMetadata(Class cls); + + /** + * Add a new interface to this JDO Metadata. + * Adds its package also if not yet existing. + * @param cls Class to add + * @return The InterfaceMetadata + */ + InterfaceMetadata newInterfaceMetadata(Class cls); + + /** + * Accessor for any named queries defined on the JDO Metadata. + * @return The queries + */ + QueryMetadata[] getQueries(); + + /** + * Add a new named query to this JDO Metadata. + * @param name Name of the query + * @return The QueryMetadata + */ + QueryMetadata newQueryMetadata(String name); + + /** + * Accessor for the number of named queries defined in this JDO Metadata. + * @return The number of queries. + */ + int getNumberOfQueries(); + + /** + * Accessor for any fetch plans defined on the JDO Metadata. + * @return The fetch plans + */ + FetchPlanMetadata[] getFetchPlans(); + + /** + * Add a new fetch plan to this JDO Metadata. + * + * @param name Name of the query + * @return The FetchPlanMetadata + */ + FetchPlanMetadata newFetchPlanMetadata(String name); + + /** + * Accessor for the number of fetch plans defined in this JDO Metadata. + * @return The number of fetch plans. + */ + int getNumberOfFetchPlans(); } diff --git a/api/src/main/java/javax/jdo/metadata/JoinMetadata.java b/api/src/main/java/javax/jdo/metadata/JoinMetadata.java index b7492afb3..a2fe16262 100644 --- a/api/src/main/java/javax/jdo/metadata/JoinMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/JoinMetadata.java @@ -20,174 +20,151 @@ /** * Represents join information. - * * @since 3.0 */ public interface JoinMetadata extends Metadata { - /** - * Method to set the join column. - * - * @param column Name of the join column - * @return This metadata object - */ - JoinMetadata setColumn(String column); - - /** - * Accessor for the join column name. - * - * @return The column name - */ - String getColumn(); - - /** - * Method to set the table name. - * - * @param table Table name - * @return This metadata object - */ - JoinMetadata setTable(String table); - - /** - * Accessor for the name of the table. - * - * @return The name - */ - String getTable(); - - /** - * Method to set whether to use an outer join. - * - * @param outer Outer join? - * @return This metadata object - */ - JoinMetadata setOuter(boolean outer); - - /** - * Accessor for whether to use an outer join. - * - * @return Outer join? - */ - boolean getOuter(); - - /** - * Method to set the delete action of the FK - * - * @param action Delete action of the FK - * @return This metadata object - */ - JoinMetadata setDeleteAction(ForeignKeyAction action); - - /** - * Accessor for the delete action of the FK. - * - * @return The FK delete-action - */ - ForeignKeyAction getDeleteAction(); - - /** - * Method to set whether indexed. - * - * @param indexed Whether indexed (true | false | unique) - * @return This metadata object - */ - JoinMetadata setIndexed(Indexed indexed); - - /** - * Accessor for whether indexed (true|false|unique). - * - * @return Indexed? - */ - Indexed getIndexed(); - - /** - * Method to set whether it is unique. - * - * @param unique Unique? - * @return This metadata object - */ - JoinMetadata setUnique(boolean unique); - - /** - * Accessor for whether unique. - * - * @return Unique? - */ - Boolean getUnique(); - - /** - * Method to set new index metadata for the join. - * - * @return The IndexMetadata - */ - IndexMetadata newIndexMetadata(); - - /** - * Accessor for any index metadata on this join. - * - * @return Index metadata - */ - IndexMetadata getIndexMetadata(); - - /** - * Method to set new unique constraint metadata for the join. - * - * @return The UniqueMetadata - */ - UniqueMetadata newUniqueMetadata(); - - /** - * Accessor for any unique constraint metadata on this join. - * - * @return The UniqueMetadata - */ - UniqueMetadata getUniqueMetadata(); - - /** - * Method to set new foreign key metadata for the join. - * - * @return The ForeignKeyMetadata - */ - ForeignKeyMetadata newForeignKeyMetadata(); - - /** - * Accessor for any foreign key metadata on this join. - * - * @return The ForeignKeyMetadata - */ - ForeignKeyMetadata getForeignKeyMetadata(); - - /** - * Method to set new primary key metadata for the join. - * - * @return The PrimaryKeyMetadata - */ - PrimaryKeyMetadata newPrimaryKeyMetadata(); - - /** - * Accessor for any primary key metadata on this join. - * - * @return The PrimaryKeyMetadata - */ - PrimaryKeyMetadata getPrimaryKeyMetadata(); - - /** - * Accessor for all column(s) defined on the join. - * - * @return The column(s) - */ - ColumnMetadata[] getColumns(); - - /** - * Add a new column for this join. - * - * @return The ColumnMetadata - */ - ColumnMetadata newColumnMetadata(); - - /** - * Accessor for the number of columns defined for this join. - * - * @return The number of columns - */ - int getNumberOfColumns(); + /** + * Method to set the join column. + * @param column Name of the join column + * @return This metadata object + */ + JoinMetadata setColumn(String column); + + /** + * Accessor for the join column name. + * @return The column name + */ + String getColumn(); + + /** + * Method to set the table name. + * @param table Table name + * @return This metadata object + */ + JoinMetadata setTable(String table); + + /** + * Accessor for the name of the table. + * @return The name + */ + String getTable(); + + /** + * Method to set whether to use an outer join. + * @param outer Outer join? + * @return This metadata object + */ + JoinMetadata setOuter(boolean outer); + + /** + * Accessor for whether to use an outer join. + * @return Outer join? + */ + boolean getOuter(); + + /** + * Method to set the delete action of the FK + * @param action Delete action of the FK + * @return This metadata object + */ + JoinMetadata setDeleteAction(ForeignKeyAction action); + + /** + * Accessor for the delete action of the FK. + * @return The FK delete-action + */ + ForeignKeyAction getDeleteAction(); + + /** + * Method to set whether indexed. + * @param indexed Whether indexed (true | false | unique) + * @return This metadata object + */ + JoinMetadata setIndexed(Indexed indexed); + + /** + * Accessor for whether indexed (true|false|unique). + * @return Indexed? + */ + Indexed getIndexed(); + + /** + * Method to set whether it is unique. + * @param unique Unique? + * @return This metadata object + */ + JoinMetadata setUnique(boolean unique); + + /** + * Accessor for whether unique. + * @return Unique? + */ + Boolean getUnique(); + + /** + * Method to set new index metadata for the join. + * @return The IndexMetadata + */ + IndexMetadata newIndexMetadata(); + + /** + * Accessor for any index metadata on this join. + * @return Index metadata + */ + IndexMetadata getIndexMetadata(); + + /** + * Method to set new unique constraint metadata for the join. + * @return The UniqueMetadata + */ + UniqueMetadata newUniqueMetadata(); + + /** + * Accessor for any unique constraint metadata on this join. + * @return The UniqueMetadata + */ + UniqueMetadata getUniqueMetadata(); + + /** + * Method to set new foreign key metadata for the join. + * @return The ForeignKeyMetadata + */ + ForeignKeyMetadata newForeignKeyMetadata(); + + /** + * Accessor for any foreign key metadata on this join. + * + * @return The ForeignKeyMetadata + */ + ForeignKeyMetadata getForeignKeyMetadata(); + + /** + * Method to set new primary key metadata for the join. + * @return The PrimaryKeyMetadata + */ + PrimaryKeyMetadata newPrimaryKeyMetadata(); + + /** + * Accessor for any primary key metadata on this join. + * @return The PrimaryKeyMetadata + */ + PrimaryKeyMetadata getPrimaryKeyMetadata(); + + /** + * Accessor for all column(s) defined on the join. + * @return The column(s) + */ + ColumnMetadata[] getColumns(); + + /** + * Add a new column for this join. + * @return The ColumnMetadata + */ + ColumnMetadata newColumnMetadata(); + + /** + * Accessor for the number of columns defined for this join. + * @return The number of columns + */ + int getNumberOfColumns(); } diff --git a/api/src/main/java/javax/jdo/metadata/KeyMetadata.java b/api/src/main/java/javax/jdo/metadata/KeyMetadata.java index 8b29a9c6c..25ad2f9be 100644 --- a/api/src/main/java/javax/jdo/metadata/KeyMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/KeyMetadata.java @@ -19,174 +19,153 @@ import javax.jdo.AttributeConverter; import javax.jdo.annotations.ForeignKeyAction; -/** Represents a key in a map. */ +/** + * Represents a key in a map. + */ public interface KeyMetadata extends Metadata { - /** - * Method to set the column name. - * - * @param column Column name - * @return This metadata object - */ - KeyMetadata setColumn(String column); - - /** - * Accessor for the name of the column. - * - * @return The name - */ - String getColumn(); - - /** - * Method to set the table name. - * - * @param table Table name - * @return This metadata object - */ - KeyMetadata setTable(String table); - - /** - * Accessor for the name of the table. - * - * @return The name - */ - String getTable(); - - /** - * Method to set the delete action of the FK - * - * @param action Delete action of the FK - * @return This metadata object - */ - KeyMetadata setDeleteAction(ForeignKeyAction action); - - /** - * Accessor for the delete action of the FK. - * - * @return The FK delete-action - */ - ForeignKeyAction getDeleteAction(); - - /** - * Method to set the update action of the FK. - * - * @param action Update action of the FK - * @return This metadata object - */ - KeyMetadata setUpdateAction(ForeignKeyAction action); - - /** - * Accessor for the update action of the FK. - * - * @return The FK update-action - */ - ForeignKeyAction getUpdateAction(); - - /** - * Accessor for all column(s) defined on the key. - * - * @return The column(s) - */ - ColumnMetadata[] getColumns(); - - /** - * Add a new column for this key. - * - * @return The ColumnMetadata - */ - ColumnMetadata newColumnMetadata(); - - /** - * Accessor for the number of columns defined for this key. - * - * @return The number of columns - */ - int getNumberOfColumns(); - - /** - * Method to set new embedded metadata for the key. - * - * @return The EmbeddedMetadata - */ - EmbeddedMetadata newEmbeddedMetadata(); - - /** - * Accessor for any embedded metadata on this key - * - * @return The EmbeddedMetadata - */ - EmbeddedMetadata getEmbeddedMetadata(); - - /** - * Method to set new index metadata for the key. - * - * @return The IndexMetadata - */ - IndexMetadata newIndexMetadata(); - - /** - * Accessor for any index metadata on this key - * - * @return Index metadata - */ - IndexMetadata getIndexMetadata(); - - /** - * Method to set new unique constraint metadata for the key - * - * @return The UniqueMetadata - */ - UniqueMetadata newUniqueMetadata(); - - /** - * Accessor for any unique constraint metadata on this key. - * - * @return The UniqueMetadata - */ - UniqueMetadata getUniqueMetadata(); - - /** - * Method to set new foreign key metadata for the key - * - * @return The ForeignKeyMetadata - */ - ForeignKeyMetadata newForeignKeyMetadata(); - - /** - * Accessor for any foreign key metadata on this key. - * - * @return The ForeignKeyMetadata - */ - ForeignKeyMetadata getForeignKeyMetadata(); - - /** - * Accessor for the attribute converter for this key (if any). - * - * @return The converter - */ - AttributeConverter getConverter(); - - /** - * Method to set the attribute converter to use for this key. - * - * @param conv Converter - * @return This metadata - */ - KeyMetadata setConverter(AttributeConverter conv); - - /** - * Accessor for whether any AttributeConverter for this key type is explicitly disabled and should - * use the implementation default. - * - * @return Whether it is disabled - */ - Boolean getUseDefaultConversion(); - - /** - * Method to explicitly set whether to disable use of AttributeConverter for this type (either - * here, class-level or PMF level). - * - * @param flag Whether to disable - * @return This metadata - */ - KeyMetadata setUseDefaultConversion(Boolean flag); -} + /** + * Method to set the column name. + * @param column Column name + * @return This metadata object + */ + KeyMetadata setColumn(String column); + + /** + * Accessor for the name of the column. + * @return The name + */ + String getColumn(); + + /** + * Method to set the table name. + * @param table Table name + * @return This metadata object + */ + KeyMetadata setTable(String table); + + /** + * Accessor for the name of the table. + * @return The name + */ + String getTable(); + + /** + * Method to set the delete action of the FK + * @param action Delete action of the FK + * @return This metadata object + */ + KeyMetadata setDeleteAction(ForeignKeyAction action); + + /** + * Accessor for the delete action of the FK. + * @return The FK delete-action + */ + ForeignKeyAction getDeleteAction(); + + /** + * Method to set the update action of the FK. + * @param action Update action of the FK + * @return This metadata object + */ + KeyMetadata setUpdateAction(ForeignKeyAction action); + + /** + * Accessor for the update action of the FK. + * @return The FK update-action + */ + ForeignKeyAction getUpdateAction(); + + /** + * Accessor for all column(s) defined on the key. + * @return The column(s) + */ + ColumnMetadata[] getColumns(); + + /** + * Add a new column for this key. + * @return The ColumnMetadata + */ + ColumnMetadata newColumnMetadata(); + + /** + * Accessor for the number of columns defined for this key. + * @return The number of columns + */ + int getNumberOfColumns(); + + /** + * Method to set new embedded metadata for the key. + * @return The EmbeddedMetadata + */ + EmbeddedMetadata newEmbeddedMetadata(); + + /** + * Accessor for any embedded metadata on this key + * + * @return The EmbeddedMetadata + */ + EmbeddedMetadata getEmbeddedMetadata(); + + /** + * Method to set new index metadata for the key. + * + * @return The IndexMetadata + */ + IndexMetadata newIndexMetadata(); + + /** + * Accessor for any index metadata on this key + * @return Index metadata + */ + IndexMetadata getIndexMetadata(); + + /** + * Method to set new unique constraint metadata for the key + * @return The UniqueMetadata + */ + UniqueMetadata newUniqueMetadata(); + + /** + * Accessor for any unique constraint metadata on this key. + * @return The UniqueMetadata + */ + UniqueMetadata getUniqueMetadata(); + + /** + * Method to set new foreign key metadata for the key + * @return The ForeignKeyMetadata + */ + ForeignKeyMetadata newForeignKeyMetadata(); + + /** + * Accessor for any foreign key metadata on this key. + * @return The ForeignKeyMetadata + */ + ForeignKeyMetadata getForeignKeyMetadata(); + + /** + * Accessor for the attribute converter for this key (if any). + * @return The converter + */ + AttributeConverter getConverter(); + + /** + * Method to set the attribute converter to use for this key. + * @param conv Converter + * @return This metadata + */ + KeyMetadata setConverter(AttributeConverter conv); + + /** + * Accessor for whether any AttributeConverter for this key type is explicitly disabled and should use the implementation default. + * @return Whether it is disabled + */ + Boolean getUseDefaultConversion(); + + /** + * Method to explicitly set whether to disable use of AttributeConverter for this type (either here, class-level or PMF level). + * @param flag Whether to disable + * @return This metadata + */ + KeyMetadata setUseDefaultConversion(Boolean flag); +} \ No newline at end of file diff --git a/api/src/main/java/javax/jdo/metadata/MapMetadata.java b/api/src/main/java/javax/jdo/metadata/MapMetadata.java index edc90e0fd..e1dcbd513 100644 --- a/api/src/main/java/javax/jdo/metadata/MapMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/MapMetadata.java @@ -18,127 +18,110 @@ /** * Represents details of a map in a field/property in a class. - * * @since 3.0 */ public interface MapMetadata extends Metadata { - /** - * Method to set the name of the key type. - * - * @param type Name of the key type - * @return This metadata object - */ - MapMetadata setKeyType(String type); - - /** - * Accessor for the key type. - * - * @return The key type - */ - String getKeyType(); - - /** - * Method to set whether the key is embedded. - * - * @param val Whether it is embedded - * @return This metadata object - */ - MapMetadata setEmbeddedKey(boolean val); - - /** - * Accessor for whether the key is embedded. - * - * @return whether the key is embedded - */ - Boolean getEmbeddedKey(); - - /** - * Method to set whether the key is serialised. - * - * @param val Whether it is serialised - * @return This metadata object - */ - MapMetadata setSerializedKey(boolean val); - - /** - * Accessor for whether the key is serialised. - * - * @return whether the key is serialised - */ - Boolean getSerializedKey(); - - /** - * Method to set whether the key is dependent. - * - * @param val Whether it is dependent - * @return This metadata object - */ - MapMetadata setDependentKey(boolean val); - - /** - * Accessor for whether the key is dependent. - * - * @return whether the key is dependent - */ - Boolean getDependentKey(); - - /** - * Method to set the name of the value type. - * - * @param type Name of the value type - * @return This metadata object - */ - MapMetadata setValueType(String type); - - /** - * Accessor for the value type. - * - * @return The value type - */ - String getValueType(); - - /** - * Method to set whether the value is embedded. - * - * @param val Whether it is embedded - * @return This metadata object - */ - MapMetadata setEmbeddedValue(boolean val); - - /** - * Accessor for whether the value is embedded. - * - * @return whether the value is embedded - */ - Boolean getEmbeddedValue(); - - /** - * Method to set whether the value is serialised. - * - * @param val Whether it is serialised - * @return This metadata object - */ - MapMetadata setSerializedValue(boolean val); - - /** - * Accessor for whether the value is serialised. - * - * @return whether the value is serialised - */ - Boolean getSerializedValue(); - - /** - * Method to set whether the value is dependent. - * - * @param val Whether it is dependent - * @return This metadata object - */ - MapMetadata setDependentValue(boolean val); - - /** - * Accessor for whether the value is dependent. - * - * @return whether the value is dependent - */ - Boolean getDependentValue(); + /** + * Method to set the name of the key type. + * @param type Name of the key type + * @return This metadata object + */ + MapMetadata setKeyType(String type); + + /** + * Accessor for the key type. + * @return The key type + */ + String getKeyType(); + + /** + * Method to set whether the key is embedded. + * @param val Whether it is embedded + * @return This metadata object + */ + MapMetadata setEmbeddedKey(boolean val); + + /** + * Accessor for whether the key is embedded. + * @return whether the key is embedded + */ + Boolean getEmbeddedKey(); + + /** + * Method to set whether the key is serialised. + * @param val Whether it is serialised + * @return This metadata object + */ + MapMetadata setSerializedKey(boolean val); + + /** + * Accessor for whether the key is serialised. + * @return whether the key is serialised + */ + Boolean getSerializedKey(); + + /** + * Method to set whether the key is dependent. + * @param val Whether it is dependent + * @return This metadata object + */ + MapMetadata setDependentKey(boolean val); + + /** + * Accessor for whether the key is dependent. + * @return whether the key is dependent + */ + Boolean getDependentKey(); + + /** + * Method to set the name of the value type. + * @param type Name of the value type + * @return This metadata object + */ + MapMetadata setValueType(String type); + + /** + * Accessor for the value type. + * @return The value type + */ + String getValueType(); + + /** + * Method to set whether the value is embedded. + * @param val Whether it is embedded + * @return This metadata object + */ + MapMetadata setEmbeddedValue(boolean val); + + /** + * Accessor for whether the value is embedded. + * @return whether the value is embedded + */ + Boolean getEmbeddedValue(); + + /** + * Method to set whether the value is serialised. + * @param val Whether it is serialised + * @return This metadata object + */ + MapMetadata setSerializedValue(boolean val); + + /** + * Accessor for whether the value is serialised. + * @return whether the value is serialised + */ + Boolean getSerializedValue(); + + /** + * Method to set whether the value is dependent. + * @param val Whether it is dependent + * @return This metadata object + */ + MapMetadata setDependentValue(boolean val); + + /** + * Accessor for whether the value is dependent. + * @return whether the value is dependent + */ + Boolean getDependentValue(); } diff --git a/api/src/main/java/javax/jdo/metadata/MemberMetadata.java b/api/src/main/java/javax/jdo/metadata/MemberMetadata.java index f2bc360e3..3a90feb7c 100644 --- a/api/src/main/java/javax/jdo/metadata/MemberMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/MemberMetadata.java @@ -24,544 +24,469 @@ /** * Represents a field/property in a class/persistent-interface. - * * @since 3.0 */ public interface MemberMetadata extends Metadata { - /** - * Method to set the name. - * - * @param name name - * @return This metadata object - */ - MemberMetadata setName(String name); - - /** - * Accessor for the name of the field/property. - * - * @return The name - */ - String getName(); - - /** - * Method to set the table name. - * - * @param table Table name - * @return This metadata object - */ - MemberMetadata setTable(String table); - - /** - * Accessor for the name of the table. - * - * @return The name - */ - String getTable(); - - /** - * Method to set the column name. - * - * @param col Column name - * @return This metadata object - */ - MemberMetadata setColumn(String col); - - /** - * Accessor for the name of the column. - * - * @return The column name - */ - String getColumn(); - - /** - * Method to set the field type(s). For defining where we want to restrict what type is stored in - * a field - * - * @param type Type of field - * @return This metadata object - */ - MemberMetadata setFieldType(String type); - - /** - * Accessor for the type storable in the field. - * - * @return The field type - */ - String getFieldType(); - - /** - * Method to set the delete action of the FK - * - * @param action Delete action of the FK - * @return This metadata object - */ - MemberMetadata setDeleteAction(ForeignKeyAction action); - - /** - * Accessor for the delete action of the FK. - * - * @return The FK delete-action - */ - ForeignKeyAction getDeleteAction(); - - /** - * Method to set the persistence-modifier of the field/property. - * - * @param mod persistence modifier - * @return This metadata object - */ - MemberMetadata setPersistenceModifier(PersistenceModifier mod); - - /** - * Accessor for the persistence modifier of the field/property. - * - * @return The persistence modifier - */ - PersistenceModifier getPersistenceModifier(); - - /** - * Method to set the behaviour of a null value - * - * @param val Null value behaviour - * @return This metadata object - */ - MemberMetadata setNullValue(NullValue val); - - /** - * Accessor for the behaviour of a null value - * - * @return The null value behaviour - */ - NullValue getNullValue(); - - /** - * Method to set whether it is in the DFG. - * - * @param dfg DFG? - * @return This metadata object - */ - MemberMetadata setDefaultFetchGroup(boolean dfg); - - /** - * Accessor for whether part of the DFG. - * - * @return dfg? - */ - Boolean getDefaultFetchGroup(); - - /** - * Method to set whether it is unique. - * - * @param unique Unique? - * @return This metadata object - */ - MemberMetadata setDependent(boolean unique); - - /** - * Accessor for whether unique. - * - * @return Unique? - */ - Boolean getDependent(); - - /** - * Method to set whether it is embedded. - * - * @param emb Embedded? - * @return This metadata object - */ - MemberMetadata setEmbedded(boolean emb); - - /** - * Accessor for whether it is embedded. - * - * @return embedded? - */ - Boolean getEmbedded(); - - /** - * Method to set whether it is serialized. - * - * @param ser serialized? - * @return This metadata object - */ - MemberMetadata setSerialized(boolean ser); - - /** - * Accessor for whether it is serialized. - * - * @return serialized? - */ - Boolean getSerialized(); - - /** - * Method to set whether it is part of the pk - * - * @param pk PK? - * @return This metadata object - */ - MemberMetadata setPrimaryKey(boolean pk); - - /** - * Accessor for whether it is part of the pk. - * - * @return pk? - */ - boolean getPrimaryKey(); - - /** - * Method to set whether it is indexed. - * - * @param index Indexed? - * @return This metadata object - */ - MemberMetadata setIndexed(boolean index); - - /** - * Accessor for whether it is indexed. - * - * @return Indexed? - */ - Boolean getIndexed(); - - /** - * Method to set whether it is unique. - * - * @param unique Unique? - * @return This metadata object - */ - MemberMetadata setUnique(boolean unique); - - /** - * Accessor for whether unique. - * - * @return Unique? - */ - Boolean getUnique(); - - /** - * Method to set whether this is cacheable - * - * @param cacheable Cacheable? - * @return This metadata object - */ - MemberMetadata setCacheable(boolean cacheable); - - /** - * Accessor for whether this is cacheable. - * - * @return Detachable? - */ - boolean getCacheable(); - - /** - * Method to set the recursion depth (when used in a fetch group). - * - * @param depth Recursion depth - * @return This metadata object - */ - MemberMetadata setRecursionDepth(int depth); - - /** - * Accessor for the recursion depth (when part of a fetch group). - * - * @return Recursion depth? - */ - int getRecursionDepth(); - - /** - * Method to set the load fetch group. - * - * @param grp Load fetch group - * @return This metadata object - */ - MemberMetadata setLoadFetchGroup(String grp); - - /** - * Accessor for the name of the load fetch group - * - * @return The load fetch group - */ - String getLoadFetchGroup(); - - /** - * Method to set the value strategy - * - * @param str Value strategy - * @return This metadata object - */ - MemberMetadata setValueStrategy(IdGeneratorStrategy str); - - /** - * Accessor for the value strategy - * - * @return Value strategy - */ - IdGeneratorStrategy getValueStrategy(); - - /** - * Method to set the custom identity generation strategy. - * - * @param strategy The strategy - * @return This metadata object - */ - MemberMetadata setCustomStrategy(String strategy); - - /** - * Accessor for the custom strategy (overriding "strategy"). - * - * @return The strategy - */ - String getCustomStrategy(); - - /** - * Method to set the sequence (when using value-strategy of "sequence") - * - * @param seq Sequence key - * @return This metadata object - */ - MemberMetadata setSequence(String seq); - - /** - * Accessor for the sequence (when using value-strategy of "sequence") - * - * @return Sequence key - */ - String getSequence(); - - /** - * Method to set the field on the other side of a bidirectional relation (this side is owner). - * - * @param map mapped-by field/property - * @return This metadata object - */ - MemberMetadata setMappedBy(String map); - - /** - * Accessor for the mapped-by field/property - * - * @return mapped-by field/property - */ - String getMappedBy(); - - /** - * Method to define the array details (if the field/property is an array) - * - * @return The ArrayMetadata - */ - ArrayMetadata newArrayMetadata(); - - /** - * Accessor for the array details. - * - * @return array details - */ - ArrayMetadata getArrayMetadata(); - - /** - * Method to define the array details (if the field/property is an array). - * - * @return The ArrayMetadata - */ - CollectionMetadata newCollectionMetadata(); - - /** - * Accessor for the array details. - * - * @return array details - */ - CollectionMetadata getCollectionMetadata(); - - /** - * Method to define the map details (if the field/property is an map). - * - * @return The MapMetadata - */ - MapMetadata newMapMetadata(); - - /** - * Accessor for the map details. - * - * @return map details - */ - MapMetadata getMapMetadata(); - - /** - * Method to define the join details. - * - * @return The JoinMetadata - */ - JoinMetadata newJoinMetadata(); - - /** - * Accessor for the join details. - * - * @return join details - */ - JoinMetadata getJoinMetadata(); - - /** - * Method to define the embedded details. - * - * @return The EmbeddedMetadata - */ - EmbeddedMetadata newEmbeddedMetadata(); - - /** - * Accessor for the embedded metadata. - * - * @return embedded metadata - */ - EmbeddedMetadata getEmbeddedMetadata(); - - /** - * Method to define the new element details. - * - * @return The ElementMetadata - */ - ElementMetadata newElementMetadata(); - - /** - * Accessor for the element details. - * - * @return element details - */ - ElementMetadata getElementMetadata(); - - /** - * Method to define the key details. - * - * @return The KeyMetadata - */ - KeyMetadata newKeyMetadata(); - - /** - * Accessor for the key details. - * - * @return key details - */ - KeyMetadata getKeyMetadata(); - - /** - * Method to define the value details. - * - * @return The ValueMetadata - */ - ValueMetadata newValueMetadata(); - - /** - * Accessor for the value details. - * - * @return value details - */ - ValueMetadata getValueMetadata(); - - /** - * Method to set index metadata for the field/property. - * - * @return The metadata for any index - */ - IndexMetadata newIndexMetadata(); - - /** - * Accessor for any index metadata for the field/property. - * - * @return Index metadata - */ - IndexMetadata getIndexMetadata(); - - /** - * Method to set new unique constraint metadata for the field/property. - * - * @return The UniqueMetadata - */ - UniqueMetadata newUniqueMetadata(); - - /** - * Accessor for any unique constraint metadata on this field/property. - * - * @return The UniqueMetadata - */ - UniqueMetadata getUniqueMetadata(); - - /** - * Method to set new foreign key metadata for the field/property. - * - * @return The ForeignKeyMetadata - */ - ForeignKeyMetadata newForeignKeyMetadata(); - - /** - * Accessor for any foreign key metadata on this field/property. - * - * @return The ForeignKeyMetadata - */ - ForeignKeyMetadata getForeignKeyMetadata(); - - /** - * Method to define the order details. - * - * @return The OrdeMetadata - */ - OrderMetadata newOrderMetadata(); - - /** - * Accessor for the order metadata. - * - * @return order metadata - */ - OrderMetadata getOrderMetadata(); - - /** - * Accessor for all column(s) defined on the join. - * - * @return The column(s) - */ - ColumnMetadata[] getColumns(); - - /** - * Add a new column for this join. - * - * @return The ColumnMetadata - */ - ColumnMetadata newColumnMetadata(); - - /** - * Accessor for the number of columns defined for this join. - * - * @return The number of columns - */ - int getNumberOfColumns(); - - /** - * Accessor for the attribute converter for this member (if any). - * - * @return The converter - */ - AttributeConverter getConverter(); - - /** - * Method to set the attribute converter to use for this member. - * - * @param conv Converter - * @return This metadata - */ - MemberMetadata setConverter(AttributeConverter conv); - - /** - * Accessor for whether any AttributeConverter for this member type is explicitly disabled and - * should use the implementation default. - * - * @return Whether it is explicitly disabled - */ - Boolean getUseDefaultConversion(); - - /** - * Method to explicitly set whether to disable use of AttributeConverter for this type (either - * here, class-level or PMF level). - * - * @param flag Whether to disable - * @return This metadata - */ - MemberMetadata setUseDefaultConversion(Boolean flag); + /** + * Method to set the name. + * @param name name + * @return This metadata object + */ + MemberMetadata setName(String name); + + /** + * Accessor for the name of the field/property. + * @return The name + */ + String getName(); + + /** + * Method to set the table name. + * @param table Table name + * @return This metadata object + */ + MemberMetadata setTable(String table); + + /** + * Accessor for the name of the table. + * @return The name + */ + String getTable(); + + /** + * Method to set the column name. + * @param col Column name + * @return This metadata object + */ + MemberMetadata setColumn(String col); + + /** + * Accessor for the name of the column. + * @return The column name + */ + String getColumn(); + + /** + * Method to set the field type(s). For defining where we want to restrict + * what type is stored in a field + * @param type Type of field + * @return This metadata object + */ + MemberMetadata setFieldType(String type); + + /** + * Accessor for the type storable in the field. + * @return The field type + */ + String getFieldType(); + + /** + * Method to set the delete action of the FK + * @param action Delete action of the FK + * @return This metadata object + */ + MemberMetadata setDeleteAction(ForeignKeyAction action); + + /** + * Accessor for the delete action of the FK. + * @return The FK delete-action + */ + ForeignKeyAction getDeleteAction(); + + /** + * Method to set the persistence-modifier of the field/property. + * @param mod persistence modifier + * @return This metadata object + */ + MemberMetadata setPersistenceModifier(PersistenceModifier mod); + + /** + * Accessor for the persistence modifier of the field/property. + * @return The persistence modifier + */ + PersistenceModifier getPersistenceModifier(); + + /** + * Method to set the behaviour of a null value + * @param val Null value behaviour + * @return This metadata object + */ + MemberMetadata setNullValue(NullValue val); + + /** + * Accessor for the behaviour of a null value + * @return The null value behaviour + */ + NullValue getNullValue(); + + /** + * Method to set whether it is in the DFG. + * @param dfg DFG? + * @return This metadata object + */ + MemberMetadata setDefaultFetchGroup(boolean dfg); + + /** + * Accessor for whether part of the DFG. + * @return dfg? + */ + Boolean getDefaultFetchGroup(); + + /** + * Method to set whether it is unique. + * @param unique Unique? + * @return This metadata object + */ + MemberMetadata setDependent(boolean unique); + + /** + * Accessor for whether unique. + * @return Unique? + */ + Boolean getDependent(); + + /** + * Method to set whether it is embedded. + * @param emb Embedded? + * @return This metadata object + */ + MemberMetadata setEmbedded(boolean emb); + + /** + * Accessor for whether it is embedded. + * @return embedded? + */ + Boolean getEmbedded(); + + /** + * Method to set whether it is serialized. + * @param ser serialized? + * @return This metadata object + */ + MemberMetadata setSerialized(boolean ser); + + /** + * Accessor for whether it is serialized. + * @return serialized? + */ + Boolean getSerialized(); + + /** + * Method to set whether it is part of the pk + * @param pk PK? + * @return This metadata object + */ + MemberMetadata setPrimaryKey(boolean pk); + + /** + * Accessor for whether it is part of the pk. + * @return pk? + */ + boolean getPrimaryKey(); + + /** + * Method to set whether it is indexed. + * @param index Indexed? + * @return This metadata object + */ + MemberMetadata setIndexed(boolean index); + + /** + * Accessor for whether it is indexed. + * @return Indexed? + */ + Boolean getIndexed(); + + /** + * Method to set whether it is unique. + * @param unique Unique? + * @return This metadata object + */ + MemberMetadata setUnique(boolean unique); + + /** + * Accessor for whether unique. + * @return Unique? + */ + Boolean getUnique(); + + /** + * Method to set whether this is cacheable + * @param cacheable Cacheable? + * @return This metadata object + */ + MemberMetadata setCacheable(boolean cacheable); + + /** + * Accessor for whether this is cacheable. + * @return Detachable? + */ + boolean getCacheable(); + + /** + * Method to set the recursion depth (when used in a fetch group). + * @param depth Recursion depth + * @return This metadata object + */ + MemberMetadata setRecursionDepth(int depth); + + /** + * Accessor for the recursion depth (when part of a fetch group). + * @return Recursion depth? + */ + int getRecursionDepth(); + + /** + * Method to set the load fetch group. + * @param grp Load fetch group + * @return This metadata object + */ + MemberMetadata setLoadFetchGroup(String grp); + + /** + * Accessor for the name of the load fetch group + * @return The load fetch group + */ + String getLoadFetchGroup(); + + /** + * Method to set the value strategy + * @param str Value strategy + * @return This metadata object + */ + MemberMetadata setValueStrategy(IdGeneratorStrategy str); + + /** + * Accessor for the value strategy + * @return Value strategy + */ + IdGeneratorStrategy getValueStrategy(); + + /** + * Method to set the custom identity generation strategy. + * @param strategy The strategy + * @return This metadata object + */ + MemberMetadata setCustomStrategy(String strategy); + + /** + * Accessor for the custom strategy (overriding "strategy"). + * @return The strategy + */ + String getCustomStrategy(); + + /** + * Method to set the sequence (when using value-strategy of "sequence") + * @param seq Sequence key + * @return This metadata object + */ + MemberMetadata setSequence(String seq); + + /** + * Accessor for the sequence (when using value-strategy of "sequence") + * @return Sequence key + */ + String getSequence(); + + /** + * Method to set the field on the other side of a bidirectional relation + * (this side is owner). + * @param map mapped-by field/property + * @return This metadata object + */ + MemberMetadata setMappedBy(String map); + + /** + * Accessor for the mapped-by field/property + * @return mapped-by field/property + */ + String getMappedBy(); + + /** + * Method to define the array details (if the field/property is an array) + * @return The ArrayMetadata + */ + ArrayMetadata newArrayMetadata(); + + /** + * Accessor for the array details. + * @return array details + */ + ArrayMetadata getArrayMetadata(); + + /** + * Method to define the array details (if the field/property is an array). + * @return The ArrayMetadata + */ + CollectionMetadata newCollectionMetadata(); + + /** + * Accessor for the array details. + * @return array details + */ + CollectionMetadata getCollectionMetadata(); + + /** + * Method to define the map details (if the field/property is an map). + * @return The MapMetadata + */ + MapMetadata newMapMetadata(); + + /** + * Accessor for the map details. + * @return map details + */ + MapMetadata getMapMetadata(); + + /** + * Method to define the join details. + * @return The JoinMetadata + */ + JoinMetadata newJoinMetadata(); + + /** + * Accessor for the join details. + * @return join details + */ + JoinMetadata getJoinMetadata(); + + /** + * Method to define the embedded details. + * @return The EmbeddedMetadata + */ + EmbeddedMetadata newEmbeddedMetadata(); + + /** + * Accessor for the embedded metadata. + * @return embedded metadata + */ + EmbeddedMetadata getEmbeddedMetadata(); + + /** + * Method to define the new element details. + * @return The ElementMetadata + */ + ElementMetadata newElementMetadata(); + + /** + * Accessor for the element details. + * @return element details + */ + ElementMetadata getElementMetadata(); + + /** + * Method to define the key details. + * @return The KeyMetadata + */ + KeyMetadata newKeyMetadata(); + + /** + * Accessor for the key details. + * @return key details + */ + KeyMetadata getKeyMetadata(); + + /** + * Method to define the value details. + * @return The ValueMetadata + */ + ValueMetadata newValueMetadata(); + + /** + * Accessor for the value details. + * @return value details + */ + ValueMetadata getValueMetadata(); + + /** + * Method to set index metadata for the field/property. + * @return The metadata for any index + */ + IndexMetadata newIndexMetadata(); + + /** + * Accessor for any index metadata for the field/property. + * @return Index metadata + */ + IndexMetadata getIndexMetadata(); + + /** + * Method to set new unique constraint metadata for the field/property. + * @return The UniqueMetadata + */ + UniqueMetadata newUniqueMetadata(); + + /** + * Accessor for any unique constraint metadata on this field/property. + * @return The UniqueMetadata + */ + UniqueMetadata getUniqueMetadata(); + + /** + * Method to set new foreign key metadata for the field/property. + * @return The ForeignKeyMetadata + */ + ForeignKeyMetadata newForeignKeyMetadata(); + + /** + * Accessor for any foreign key metadata on this field/property. + * @return The ForeignKeyMetadata + */ + ForeignKeyMetadata getForeignKeyMetadata(); + + /** + * Method to define the order details. + * @return The OrdeMetadata + */ + OrderMetadata newOrderMetadata(); + + /** + * Accessor for the order metadata. + * @return order metadata + */ + OrderMetadata getOrderMetadata(); + + /** + * Accessor for all column(s) defined on the join. + * @return The column(s) + */ + ColumnMetadata[] getColumns(); + + /** + * Add a new column for this join. + * @return The ColumnMetadata + */ + ColumnMetadata newColumnMetadata(); + + /** + * Accessor for the number of columns defined for this join. + * @return The number of columns + */ + int getNumberOfColumns(); + + /** + * Accessor for the attribute converter for this member (if any). + * @return The converter + */ + AttributeConverter getConverter(); + + /** + * Method to set the attribute converter to use for this member. + * @param conv Converter + * @return This metadata + */ + MemberMetadata setConverter(AttributeConverter conv); + + /** + * Accessor for whether any AttributeConverter for this member type is explicitly disabled and should use the implementation default. + * @return Whether it is explicitly disabled + */ + Boolean getUseDefaultConversion(); + + /** + * Method to explicitly set whether to disable use of AttributeConverter for this type (either here, class-level or PMF level). + * @param flag Whether to disable + * @return This metadata + */ + MemberMetadata setUseDefaultConversion(Boolean flag); } diff --git a/api/src/main/java/javax/jdo/metadata/Metadata.java b/api/src/main/java/javax/jdo/metadata/Metadata.java index e125828c9..d91e984f6 100644 --- a/api/src/main/java/javax/jdo/metadata/Metadata.java +++ b/api/src/main/java/javax/jdo/metadata/Metadata.java @@ -22,34 +22,34 @@ * @version 3.0 */ public interface Metadata { - /** - * Add a vendor extension to this metadata component. - * - * @param vendor Identifier for the vendor - * @param key The extension key - * @param value Value for the extension - * @return The ExtensionMetadata - */ - ExtensionMetadata newExtensionMetadata(String vendor, String key, String value); + /** + * Add a vendor extension to this metadata component. + * + * @param vendor Identifier for the vendor + * @param key The extension key + * @param value Value for the extension + * @return The ExtensionMetadata + */ + ExtensionMetadata newExtensionMetadata(String vendor, String key, String value); - /** - * Number of extensions on this component. - * - * @return Number of extensions - */ - int getNumberOfExtensions(); + /** + * Number of extensions on this component. + * + * @return Number of extensions + */ + int getNumberOfExtensions(); - /** - * Accessor for the defined extensions for this component - * - * @return The extensions - */ - ExtensionMetadata[] getExtensions(); + /** + * Accessor for the defined extensions for this component + * + * @return The extensions + */ + ExtensionMetadata[] getExtensions(); - /** - * Accessor for the parent metadata component. - * - * @return The parent - */ - Metadata getParent(); + /** + * Accessor for the parent metadata component. + * + * @return The parent + */ + Metadata getParent(); } diff --git a/api/src/main/java/javax/jdo/metadata/OrderMetadata.java b/api/src/main/java/javax/jdo/metadata/OrderMetadata.java index 01f6a6b4e..005232d38 100644 --- a/api/src/main/java/javax/jdo/metadata/OrderMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/OrderMetadata.java @@ -18,72 +18,62 @@ /** * Represents ordering of a collection field/property. - * * @since 3.0 */ public interface OrderMetadata extends Metadata { - /** - * Method to set the version column name. - * - * @param column Name of the version column - * @return This metadata object - */ - OrderMetadata setColumn(String column); + /** + * Method to set the version column name. + * @param column Name of the version column + * @return This metadata object + */ + OrderMetadata setColumn(String column); - /** - * Accessor for the version column name. - * - * @return The version column name - */ - String getColumn(); + /** + * Accessor for the version column name. + * @return The version column name + */ + String getColumn(); - /** - * Method to set mapped-by information whether the order is present in the element class. - * - * @param mappedBy Field/property name in which to store the ordering in the element - * @return This metadata object - */ - OrderMetadata setMappedBy(String mappedBy); + /** + * Method to set mapped-by information whether the order is present in the element class. + * @param mappedBy Field/property name in which to store the ordering in the element + * @return This metadata object + */ + OrderMetadata setMappedBy(String mappedBy); - /** - * Accessor for the mapped-by field/property name in the element class. - * - * @return Name of field/property in element class - */ - String getMappedBy(); + /** + * Accessor for the mapped-by field/property name in the element class. + * @return Name of field/property in element class + */ + String getMappedBy(); - /** - * Accessor for all column(s) defined on the ordering. - * - * @return The column(s) - */ - ColumnMetadata[] getColumns(); + /** + * Accessor for all column(s) defined on the ordering. + * @return The column(s) + */ + ColumnMetadata[] getColumns(); - /** - * Add a column for this ordering. - * - * @return The ColumnMetadata - */ - ColumnMetadata newColumnMetadata(); + /** + * Add a column for this ordering. + * @return The ColumnMetadata + */ + ColumnMetadata newColumnMetadata(); - /** - * Accessor for the number of columns defined for this ordering. - * - * @return The number of columns - */ - int getNumberOfColumns(); + /** + * Accessor for the number of columns defined for this ordering. + * @return The number of columns + */ + int getNumberOfColumns(); - /** - * Method to set index metadata for the ordering. - * - * @return The metadata for any index - */ - IndexMetadata newIndexMetadata(); + /** + * Method to set index metadata for the ordering. + * @return The metadata for any index + */ + IndexMetadata newIndexMetadata(); - /** - * Accessor for any index metadata for the ordering. - * - * @return Index metadata - */ - IndexMetadata getIndexMetadata(); + /** + * Accessor for any index metadata for the ordering. + * @return Index metadata + */ + IndexMetadata getIndexMetadata(); } diff --git a/api/src/main/java/javax/jdo/metadata/PackageMetadata.java b/api/src/main/java/javax/jdo/metadata/PackageMetadata.java index 8b19368a4..67aff3131 100644 --- a/api/src/main/java/javax/jdo/metadata/PackageMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/PackageMetadata.java @@ -20,127 +20,110 @@ /** * Represents a package within a JDOMetadata. - * * @since 3.0 */ public interface PackageMetadata extends Metadata { - /** - * Accessor for the name of this package (set on construction). - * - * @return The name - */ - String getName(); - - /** - * Method to set the catalog (ORM) to apply to all classes in this package. - * - * @param catalog Catalog name - * @return This metadata object - */ - PackageMetadata setCatalog(String catalog); - - /** - * Accessor for the catalog (ORM) that all classes in this package default to. - * - * @return The catalog - */ - String getCatalog(); - - /** - * Method to set the schema (ORM) to apply to all classes in this package. - * - * @param schema Schema name - * @return This metadata object - */ - PackageMetadata setSchema(String schema); - - /** - * Accessor for the schema (ORM) that all classes in this package default to. - * - * @return The schema - */ - String getSchema(); - - /** - * Accessor for all classes defined in this package. - * - * @return The classes - */ - ClassMetadata[] getClasses(); - - /** - * Add a new class to this package. - * - * @param name Name of the class - * @return The ClassMetadata - */ - ClassMetadata newClassMetadata(String name); - - /** - * Add a new class to this package. - * - * @param cls The class - * @return The ClassMetadata - */ - ClassMetadata newClassMetadata(Class cls); - - /** - * Accessor for the number of classes defined in this package. - * - * @return The number of classes. - */ - int getNumberOfClasses(); - - /** - * Accessor for all interfaces defined in this package. - * - * @return The interfaces - */ - InterfaceMetadata[] getInterfaces(); - - /** - * Add a new interface to this package. - * - * @param name The interface name - * @return The InterfaceMetadata - */ - InterfaceMetadata newInterfaceMetadata(String name); - - /** - * Add a new interface to this package. - * - * @param cls The class - * @return The ClassMetadata - */ - InterfaceMetadata newInterfaceMetadata(Class cls); - - /** - * Accessor for the number of interfaces defined in this package. - * - * @return The number of interfaces. - */ - int getNumberOfInterfaces(); - - /** - * Accessor for any sequences defined on the package. - * - * @return The sequences - */ - SequenceMetadata[] getSequences(); - - /** - * Add a new sequence to this package. - * - * @param name Name of the sequence - * @param strategy Strategy for the sequence - * @return The SequenceMetadata - */ - SequenceMetadata newSequenceMetadata(String name, SequenceStrategy strategy); - - /** - * Accessor for the number of sequences defined for this package. - * - * @return The number of sequences. - */ - int getNumberOfSequences(); + /** + * Accessor for the name of this package (set on construction). + * @return The name + */ + String getName(); + + /** + * Method to set the catalog (ORM) to apply to all classes in this package. + * @param catalog Catalog name + * @return This metadata object + */ + PackageMetadata setCatalog(String catalog); + + /** + * Accessor for the catalog (ORM) that all classes in this package default to. + * @return The catalog + */ + String getCatalog(); + + /** + * Method to set the schema (ORM) to apply to all classes in this package. + * @param schema Schema name + * @return This metadata object + */ + PackageMetadata setSchema(String schema); + + /** + * Accessor for the schema (ORM) that all classes in this package default to. + * @return The schema + */ + String getSchema(); + + /** + * Accessor for all classes defined in this package. + * @return The classes + */ + ClassMetadata[] getClasses(); + + /** + * Add a new class to this package. + * @param name Name of the class + * @return The ClassMetadata + */ + ClassMetadata newClassMetadata(String name); + + /** + * Add a new class to this package. + * @param cls The class + * @return The ClassMetadata + */ + ClassMetadata newClassMetadata(Class cls); + + /** + * Accessor for the number of classes defined in this package. + * @return The number of classes. + */ + int getNumberOfClasses(); + + /** + * Accessor for all interfaces defined in this package. + * @return The interfaces + */ + InterfaceMetadata[] getInterfaces(); + + /** + * Add a new interface to this package. + * @param name The interface name + * @return The InterfaceMetadata + */ + InterfaceMetadata newInterfaceMetadata(String name); + + /** + * Add a new interface to this package. + * @param cls The class + * @return The ClassMetadata + */ + InterfaceMetadata newInterfaceMetadata(Class cls); + + /** + * Accessor for the number of interfaces defined in this package. + * @return The number of interfaces. + */ + int getNumberOfInterfaces(); + + /** + * Accessor for any sequences defined on the package. + * @return The sequences + */ + SequenceMetadata[] getSequences(); + + /** + * Add a new sequence to this package. + * @param name Name of the sequence + * @param strategy Strategy for the sequence + * @return The SequenceMetadata + */ + SequenceMetadata newSequenceMetadata(String name, SequenceStrategy strategy); + + /** + * Accessor for the number of sequences defined for this package. + * @return The number of sequences. + */ + int getNumberOfSequences(); } diff --git a/api/src/main/java/javax/jdo/metadata/PrimaryKeyMetadata.java b/api/src/main/java/javax/jdo/metadata/PrimaryKeyMetadata.java index c56dc6d57..c592a3875 100644 --- a/api/src/main/java/javax/jdo/metadata/PrimaryKeyMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/PrimaryKeyMetadata.java @@ -18,58 +18,50 @@ /** * Represents the primary key definition of a class. - * * @since 3.0 */ public interface PrimaryKeyMetadata extends Metadata { - /** - * Method to set the name of the PK constraint. - * - * @param name Name of the PK constraint - * @return The PK metadata - */ - PrimaryKeyMetadata setName(String name); + /** + * Method to set the name of the PK constraint. + * @param name Name of the PK constraint + * @return The PK metadata + */ + PrimaryKeyMetadata setName(String name); - /** - * Accessor for the name of the PK constraint. - * - * @return The PK constraint name - */ - String getName(); + /** + * Accessor for the name of the PK constraint. + * @return The PK constraint name + */ + String getName(); - /** - * Method to set the PK column name. - * - * @param column Name of the PK column - * @return The PK metadata - */ - PrimaryKeyMetadata setColumn(String column); + /** + * Method to set the PK column name. + * @param column Name of the PK column + * @return The PK metadata + */ + PrimaryKeyMetadata setColumn(String column); - /** - * Accessor for the PK column name. - * - * @return The column name - */ - String getColumn(); + /** + * Accessor for the PK column name. + * @return The column name + */ + String getColumn(); - /** - * Accessor for all column(s) defined on the PK. - * - * @return The column(s) - */ - ColumnMetadata[] getColumns(); + /** + * Accessor for all column(s) defined on the PK. + * @return The column(s) + */ + ColumnMetadata[] getColumns(); - /** - * Add a new column for this PK. - * - * @return The ColumnMetadata - */ - ColumnMetadata newColumnMetadata(); + /** + * Add a new column for this PK. + * @return The ColumnMetadata + */ + ColumnMetadata newColumnMetadata(); - /** - * Accessor for the number of columns defined for this PK. - * - * @return The number of columns - */ - int getNumberOfColumns(); + /** + * Accessor for the number of columns defined for this PK. + * @return The number of columns + */ + int getNumberOfColumns(); } diff --git a/api/src/main/java/javax/jdo/metadata/PropertyMetadata.java b/api/src/main/java/javax/jdo/metadata/PropertyMetadata.java index b21fb209c..faae8bc93 100644 --- a/api/src/main/java/javax/jdo/metadata/PropertyMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/PropertyMetadata.java @@ -18,22 +18,19 @@ /** * Represents a property in a class/persistent-interface. - * * @since 3.0 */ public interface PropertyMetadata extends MemberMetadata { - /** - * Method to set the field name (persistent interfaces). - * - * @param name field name - * @return This metadata object - */ - PropertyMetadata setFieldName(String name); + /** + * Method to set the field name (persistent interfaces). + * @param name field name + * @return This metadata object + */ + PropertyMetadata setFieldName(String name); - /** - * Accessor for the field name. - * - * @return Field name - */ - String getFieldName(); + /** + * Accessor for the field name. + * @return Field name + */ + String getFieldName(); } diff --git a/api/src/main/java/javax/jdo/metadata/QueryMetadata.java b/api/src/main/java/javax/jdo/metadata/QueryMetadata.java index 2439ca70f..58f5d1adf 100644 --- a/api/src/main/java/javax/jdo/metadata/QueryMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/QueryMetadata.java @@ -18,103 +18,89 @@ /** * Represents a named query. - * * @since 3.0 */ public interface QueryMetadata extends Metadata { - /** - * Accessor for the name of the query (set on construction). - * - * @return The name - */ - String getName(); + /** + * Accessor for the name of the query (set on construction). + * @return The name + */ + String getName(); - /** - * Method to set the language of the query. - * - * @param lang Query language - * @return This metadata object - */ - QueryMetadata setLanguage(String lang); + /** + * Method to set the language of the query. + * @param lang Query language + * @return This metadata object + */ + QueryMetadata setLanguage(String lang); - /** - * Accessor for the query language. - * - * @return The language - */ - String getLanguage(); + /** + * Accessor for the query language. + * @return The language + */ + String getLanguage(); - /** - * Method to set the single-string query. - * - * @param query The query - * @return This metadata object - */ - QueryMetadata setQuery(String query); + /** + * Method to set the single-string query. + * @param query The query + * @return This metadata object + */ + QueryMetadata setQuery(String query); - /** - * Accessor for the single-string query. - * - * @return The query - */ - String getQuery(); + /** + * Accessor for the single-string query. + * @return The query + */ + String getQuery(); - /** - * Method to set the result class name for the query. - * - * @param clsName Result class name - * @return This metadata object - */ - QueryMetadata setResultClass(String clsName); + /** + * Method to set the result class name for the query. + * @param clsName Result class name + * @return This metadata object + */ + QueryMetadata setResultClass(String clsName); - /** - * Accessor for the result class name for the query. - * - * @return The result class name - */ - String getResultClass(); + /** + * Accessor for the result class name for the query. + * @return The result class name + */ + String getResultClass(); - /** - * Method to set if the query results are unique. - * - * @param unique Whether they are unique - * @return This metadata object - */ - QueryMetadata setUnique(boolean unique); + /** + * Method to set if the query results are unique. + * @param unique Whether they are unique + * @return This metadata object + */ + QueryMetadata setUnique(boolean unique); - /** - * Accessor for whether results from the query are unique. - * - * @return Results are unique? - */ - Boolean getUnique(); + /** + * Accessor for whether results from the query are unique. + * @return Results are unique? + */ + Boolean getUnique(); - /** - * Method to set the query as not being modifiable from now. - * - * @return This metadata object - */ - QueryMetadata setUnmodifiable(); + /** + * Method to set the query as not being modifiable from now. + * @return This metadata object + */ + QueryMetadata setUnmodifiable(); - /** - * Accessor for whether the query is unmodifiable. - * - * @return Can't be changed? - */ - boolean getUnmodifiable(); + /** + * Accessor for whether the query is unmodifiable. + * @return Can't be changed? + */ + boolean getUnmodifiable(); - /** - * Method to set the FetchPlan to use for this named query. - * - * @param fetchPlanName name of the FetchPlan - * @return This metadata object - */ - QueryMetadata setFetchPlan(String fetchPlanName); + /** + * Method to set the FetchPlan to use for this named query. + * @param fetchPlanName name of the FetchPlan + * @return This metadata object + */ + QueryMetadata setFetchPlan(String fetchPlanName); - /** - * Accessor for the name of a fetch plan to use (if any). - * - * @return The fetch plan name - */ - String getFetchPlan(); + /** + * Accessor for the name of a fetch plan to use (if any). + * @return The fetch plan name + */ + String getFetchPlan(); } diff --git a/api/src/main/java/javax/jdo/metadata/SequenceMetadata.java b/api/src/main/java/javax/jdo/metadata/SequenceMetadata.java index 7623e2406..97be9c4f9 100644 --- a/api/src/main/java/javax/jdo/metadata/SequenceMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/SequenceMetadata.java @@ -20,85 +20,74 @@ /** * Represents a sequence. - * * @since 3.0 */ public interface SequenceMetadata extends Metadata { - /** - * Accessor for the name of the sequence (set on construction). - * - * @return The name - */ - String getName(); + /** + * Accessor for the name of the sequence (set on construction). + * @return The name + */ + String getName(); - /** - * Accessor for the sequence strategy (set on construction). - * - * @return Sequence strategy - */ - SequenceStrategy getSequenceStrategy(); + /** + * Accessor for the sequence strategy (set on construction). + * @return Sequence strategy + */ + SequenceStrategy getSequenceStrategy(); - /** - * Method to set the name of the datastore sequence that this maps to. - * - * @param seq Datastore sequence name - * @return This metadata object - */ - SequenceMetadata setDatastoreSequence(String seq); + /** + * Method to set the name of the datastore sequence that this maps to. + * @param seq Datastore sequence name + * @return This metadata object + */ + SequenceMetadata setDatastoreSequence(String seq); - /** - * Accessor for the name of the datastore sequence that this maps to - * - * @return The datastore sequence name - */ - String getDatastoreSequence(); + /** + * Accessor for the name of the datastore sequence that this maps to + * @return The datastore sequence name + */ + String getDatastoreSequence(); - /** - * Method to set the result class name for the query. - * - * @param clsName Result class name - * @return This metadata object - */ - SequenceMetadata setFactoryClass(String clsName); + /** + * Method to set the result class name for the query. + * @param clsName Result class name + * @return This metadata object + */ + SequenceMetadata setFactoryClass(String clsName); - /** - * Accessor for the factory class for this sequence. - * - * @return The factory class - */ - String getFactoryClass(); + /** + * Accessor for the factory class for this sequence. + * @return The factory class + */ + String getFactoryClass(); - /** - * Method to set the initial value for the sequence. - * - * @param val Initial value to use - * @return This metadata object - * @since 3.1 - */ - SequenceMetadata setInitialValue(int val); + /** + * Method to set the initial value for the sequence. + * @param val Initial value to use + * @return This metadata object + * @since 3.1 + */ + SequenceMetadata setInitialValue(int val); - /** - * Accessor for the initial value of the sequence (if any). - * - * @return initial value - * @since 3.1 - */ - Integer getInitialValue(); + /** + * Accessor for the initial value of the sequence (if any). + * @return initial value + * @since 3.1 + */ + Integer getInitialValue(); - /** - * Method to set the allocation size for the sequence. - * - * @param size Allocation size to use - * @return This metadata object - * @since 3.1 - */ - SequenceMetadata setAllocationSize(int size); + /** + * Method to set the allocation size for the sequence. + * @param size Allocation size to use + * @return This metadata object + * @since 3.1 + */ + SequenceMetadata setAllocationSize(int size); - /** - * Accessor for the allocation size of the sequence (if any). - * - * @return allocation size - * @since 3.1 - */ - Integer getAllocationSize(); + /** + * Accessor for the allocation size of the sequence (if any). + * @return allocation size + * @since 3.1 + */ + Integer getAllocationSize(); } diff --git a/api/src/main/java/javax/jdo/metadata/TypeMetadata.java b/api/src/main/java/javax/jdo/metadata/TypeMetadata.java index 1cf456746..1ed1d7910 100644 --- a/api/src/main/java/javax/jdo/metadata/TypeMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/TypeMetadata.java @@ -17,403 +17,350 @@ package javax.jdo.metadata; import java.lang.reflect.Method; + import javax.jdo.annotations.IdentityType; /** * Represents a class or interface. Extended for the specifics of those cases. - * * @since 3.0 */ public interface TypeMetadata extends Metadata { - /** - * Accessor for the name of this component (set on construction). - * - * @return The name - */ - String getName(); - - /** - * Method to define the identity type to use. - * - * @param id identity type - * @return This metadata object - */ - TypeMetadata setIdentityType(IdentityType id); - - /** - * Accessor for the identity type to use. - * - * @return identity type - */ - IdentityType getIdentityType(); - - /** - * Method to set the object-id (PK) class. - * - * @param idclass Object-id class - * @return This metadata object - */ - TypeMetadata setObjectIdClass(String idclass); - - /** - * Accessor for the object-id class (if defined). - * - * @return The object-id class - */ - String getObjectIdClass(); - - /** - * Method to set whether the component requires an extent. - * - * @param extent Requires extent? - * @return This metadata object - */ - TypeMetadata setRequiresExtent(boolean extent); - - /** - * Accessor for whether the component requires an extent. - * - * @return Requires extent? - */ - boolean getRequiresExtent(); - - /** - * Method to set whether this is detachable. - * - * @param detachable Detachable? - * @return This metadata object - */ - TypeMetadata setDetachable(boolean detachable); - - /** - * Accessor for whether this is detachable. - * - * @return Detachable? - */ - boolean getDetachable(); - - /** - * Method to set whether this is cacheable. - * - * @param cacheable Cacheable? - * @return This metadata object - */ - TypeMetadata setCacheable(boolean cacheable); - - /** - * Accessor for whether this is cacheable. - * - * @return Detachable? - */ - boolean getCacheable(); - - /** - * Method to set the default value of serializeRead for objects of this type. - * - * @param flag serializeRead - * @return This metadata object - */ - TypeMetadata setSerializeRead(boolean flag); - - /** - * Accessor for the value of serializeRead for objects of this type. - * - * @return SerializeRead? - */ - boolean getSerializeRead(); - - /** - * Method to set whether it is stored only as embedded in other objects. - * - * @param embedded Whether it is only stored embedded - * @return This metadata object - */ - TypeMetadata setEmbeddedOnly(boolean embedded); - - /** - * Accessor for whether this is embedded only. - * - * @return Only stored as embedded - */ - Boolean getEmbeddedOnly(); - - /** - * Method to set the catalog (ORM) for this component. - * - * @param catalog Catalog name - * @return This metadata object - */ - TypeMetadata setCatalog(String catalog); - - /** - * Accessor for the catalog (ORM) for this component. - * - * @return The catalog - */ - String getCatalog(); - - /** - * Method to set the schema (ORM) for this component. - * - * @param schema Schema name - * @return This metadata object - */ - TypeMetadata setSchema(String schema); - - /** - * Accessor for the schema (ORM) for this component. - * - * @return The schema - */ - String getSchema(); - - /** - * Method to set the table name. - * - * @param table Table name - * @return This metadata object - */ - TypeMetadata setTable(String table); - - /** - * Accessor for the name of the table. - * - * @return The name - */ - String getTable(); - - /** - * Method to define the inheritance metadata. - * - * @return The InheritanceMetadata - */ - InheritanceMetadata newInheritanceMetadata(); - - /** - * Accessor for the inheritance (if any). - * - * @return inheritance - */ - InheritanceMetadata getInheritanceMetadata(); - - /** - * Method to define the version metadata. - * - * @return The VersionMetadata - */ - VersionMetadata newVersionMetadata(); - - /** - * Accessor for the version (if any). - * - * @return version - */ - VersionMetadata getVersionMetadata(); - - /** - * Method to define the datastore identity metadata details. - * - * @return The DatastoreIdentityMetadata - */ - DatastoreIdentityMetadata newDatastoreIdentityMetadata(); - - /** - * Accessor for the datastore identity details. - * - * @return datastore identity details - */ - DatastoreIdentityMetadata getDatastoreIdentityMetadata(); - - /** - * Method to define the primary key details. - * - * @return The PrimaryKeyMetadata - */ - PrimaryKeyMetadata newPrimaryKeyMetadata(); - - /** - * Accessor for the primary key (if any). - * - * @return primary key details - */ - PrimaryKeyMetadata getPrimaryKeyMetadata(); - - /** - * Accessor for all joins(s) defined on the component. - * - * @return The join(s) - */ - JoinMetadata[] getJoins(); - - /** - * Add a join for this component. - * - * @return The JoinMetadata - */ - JoinMetadata newJoinMetadata(); - - /** - * Accessor for the number of join(s) defined for this component. - * - * @return The number of join(s) - */ - int getNumberOfJoins(); - - /** - * Accessor for all fk(s) defined on the component. - * - * @return The fk(s) - */ - ForeignKeyMetadata[] getForeignKeys(); - - /** - * Add a new FK for this component. - * - * @return The ForeignKeyMetadata - */ - ForeignKeyMetadata newForeignKeyMetadata(); - - /** - * Accessor for the number of FKs defined for this component. - * - * @return The number of FKs - */ - int getNumberOfForeignKeys(); - - /** - * Accessor for all index(s) defined on the component. - * - * @return The index(s) - */ - IndexMetadata[] getIndices(); - - /** - * Add a new index for this component. - * - * @return The IndexMetadata - */ - IndexMetadata newIndexMetadata(); - - /** - * Accessor for the number of indices defined for this component. - * - * @return The number of indices - */ - int getNumberOfIndices(); - - /** - * Accessor for all unique constraints defined on the component. - * - * @return The unique constraints - */ - UniqueMetadata[] getUniques(); - - /** - * Add a new unique constraint for this component. - * - * @return The UniqueMetadata - */ - UniqueMetadata newUniqueMetadata(); - - /** - * Accessor for the number of unique constraints defined for this component. - * - * @return The number of unique constraints - */ - int getNumberOfUniques(); - - /** - * Accessor for all fields/properties defined on the component. - * - * @return The members - */ - MemberMetadata[] getMembers(); - - /** - * Accessor for the number of fields/properties defined for this component. - * - * @return The number of members - */ - int getNumberOfMembers(); - - /** - * Add a new property for this component. - * - * @param name Name of the property - * @return The PropertyMetadata - */ - PropertyMetadata newPropertyMetadata(String name); - - /** - * Add a new property for this component. - * - * @param method Java bean getter/setter method - * @return The PropertyMetadata - */ - PropertyMetadata newPropertyMetadata(Method method); - - /** - * Accessor for all named queries defined on the component. - * - * @return The queries - */ - QueryMetadata[] getQueries(); - - /** - * Add a new query for this component. - * - * @param name Name of the query to add - * @return The QueryMetadata - */ - QueryMetadata newQueryMetadata(String name); - - /** - * Accessor for the number of named queries defined for this component. - * - * @return The number of named queries - */ - int getNumberOfQueries(); - - /** - * Accessor for all FetchGroup defined on the component. - * - * @return The FetchGroups - */ - FetchGroupMetadata[] getFetchGroups(); - - /** - * Add a new FetchGroup for this component. - * - * @param name Name of the FetchGroup - * @return The FetchGroupMetadata - */ - FetchGroupMetadata newFetchGroupMetadata(String name); - - /** - * Accessor for the number of fetchGroups defined for this component. - * - * @return The number of fetch groups - */ - int getNumberOfFetchGroups(); - - /** - * Accessor for all column(s) defined on the join. - * - * @return The column(s) - */ - ColumnMetadata[] getColumns(); - - /** - * Add a new column for this join. - * - * @return The ColumnMetadata - */ - ColumnMetadata newColumnMetadata(); - - /** - * Accessor for the number of columns defined for this join. - * - * @return The number of columns - */ - int getNumberOfColumns(); + /** + * Accessor for the name of this component (set on construction). + * @return The name + */ + String getName(); + + /** + * Method to define the identity type to use. + * @param id identity type + * @return This metadata object + */ + TypeMetadata setIdentityType(IdentityType id); + + /** + * Accessor for the identity type to use. + * @return identity type + */ + IdentityType getIdentityType(); + + /** + * Method to set the object-id (PK) class. + * @param idclass Object-id class + * @return This metadata object + */ + TypeMetadata setObjectIdClass(String idclass); + + /** + * Accessor for the object-id class (if defined). + * @return The object-id class + */ + String getObjectIdClass(); + + /** + * Method to set whether the component requires an extent. + * @param extent Requires extent? + * @return This metadata object + */ + TypeMetadata setRequiresExtent(boolean extent); + + /** + * Accessor for whether the component requires an extent. + * @return Requires extent? + */ + boolean getRequiresExtent(); + + /** + * Method to set whether this is detachable. + * @param detachable Detachable? + * @return This metadata object + */ + TypeMetadata setDetachable(boolean detachable); + + /** + * Accessor for whether this is detachable. + * @return Detachable? + */ + boolean getDetachable(); + + /** + * Method to set whether this is cacheable. + * @param cacheable Cacheable? + * @return This metadata object + */ + TypeMetadata setCacheable(boolean cacheable); + + /** + * Accessor for whether this is cacheable. + * @return Detachable? + */ + boolean getCacheable(); + + /** + * Method to set the default value of serializeRead for objects of this type. + * @param flag serializeRead + * @return This metadata object + */ + TypeMetadata setSerializeRead(boolean flag); + + /** + * Accessor for the value of serializeRead for objects of this type. + * @return SerializeRead? + */ + boolean getSerializeRead(); + + /** + * Method to set whether it is stored only as embedded in other objects. + * @param embedded Whether it is only stored embedded + * @return This metadata object + */ + TypeMetadata setEmbeddedOnly(boolean embedded); + + /** + * Accessor for whether this is embedded only. + * @return Only stored as embedded + */ + Boolean getEmbeddedOnly(); + + /** + * Method to set the catalog (ORM) for this component. + * @param catalog Catalog name + * @return This metadata object + */ + TypeMetadata setCatalog(String catalog); + + /** + * Accessor for the catalog (ORM) for this component. + * @return The catalog + */ + String getCatalog(); + + /** + * Method to set the schema (ORM) for this component. + * @param schema Schema name + * @return This metadata object + */ + TypeMetadata setSchema(String schema); + + /** + * Accessor for the schema (ORM) for this component. + * @return The schema + */ + String getSchema(); + + /** + * Method to set the table name. + * @param table Table name + * @return This metadata object + */ + TypeMetadata setTable(String table); + + /** + * Accessor for the name of the table. + * @return The name + */ + String getTable(); + + /** + * Method to define the inheritance metadata. + * @return The InheritanceMetadata + */ + InheritanceMetadata newInheritanceMetadata(); + + /** + * Accessor for the inheritance (if any). + * @return inheritance + */ + InheritanceMetadata getInheritanceMetadata(); + + /** + * Method to define the version metadata. + * @return The VersionMetadata + */ + VersionMetadata newVersionMetadata(); + + /** + * Accessor for the version (if any). + * @return version + */ + VersionMetadata getVersionMetadata(); + + /** + * Method to define the datastore identity metadata details. + * @return The DatastoreIdentityMetadata + */ + DatastoreIdentityMetadata newDatastoreIdentityMetadata(); + + /** + * Accessor for the datastore identity details. + * @return datastore identity details + */ + DatastoreIdentityMetadata getDatastoreIdentityMetadata(); + + /** + * Method to define the primary key details. + * @return The PrimaryKeyMetadata + */ + PrimaryKeyMetadata newPrimaryKeyMetadata(); + + /** + * Accessor for the primary key (if any). + * @return primary key details + */ + PrimaryKeyMetadata getPrimaryKeyMetadata(); + + /** + * Accessor for all joins(s) defined on the component. + * @return The join(s) + */ + JoinMetadata[] getJoins(); + + /** + * Add a join for this component. + * @return The JoinMetadata + */ + JoinMetadata newJoinMetadata(); + + /** + * Accessor for the number of join(s) defined for this component. + * @return The number of join(s) + */ + int getNumberOfJoins(); + + /** + * Accessor for all fk(s) defined on the component. + * @return The fk(s) + */ + ForeignKeyMetadata[] getForeignKeys(); + + /** + * Add a new FK for this component. + * @return The ForeignKeyMetadata + */ + ForeignKeyMetadata newForeignKeyMetadata(); + + /** + * Accessor for the number of FKs defined for this component. + * @return The number of FKs + */ + int getNumberOfForeignKeys(); + + /** + * Accessor for all index(s) defined on the component. + * @return The index(s) + */ + IndexMetadata[] getIndices(); + + /** + * Add a new index for this component. + * @return The IndexMetadata + */ + IndexMetadata newIndexMetadata(); + + /** + * Accessor for the number of indices defined for this component. + * @return The number of indices + */ + int getNumberOfIndices(); + + /** + * Accessor for all unique constraints defined on the component. + * @return The unique constraints + */ + UniqueMetadata[] getUniques(); + + /** + * Add a new unique constraint for this component. + * @return The UniqueMetadata + */ + UniqueMetadata newUniqueMetadata(); + + /** + * Accessor for the number of unique constraints defined for this component. + * @return The number of unique constraints + */ + int getNumberOfUniques(); + + /** + * Accessor for all fields/properties defined on the component. + * @return The members + */ + MemberMetadata[] getMembers(); + + /** + * Accessor for the number of fields/properties defined for this component. + * @return The number of members + */ + int getNumberOfMembers(); + + /** + * Add a new property for this component. + * + * @param name Name of the property + * @return The PropertyMetadata + */ + PropertyMetadata newPropertyMetadata(String name); + + /** + * Add a new property for this component. + * @param method Java bean getter/setter method + * @return The PropertyMetadata + */ + PropertyMetadata newPropertyMetadata(Method method); + + /** + * Accessor for all named queries defined on the component. + * @return The queries + */ + QueryMetadata[] getQueries(); + + /** + * Add a new query for this component. + * @param name Name of the query to add + * @return The QueryMetadata + */ + QueryMetadata newQueryMetadata(String name); + + /** + * Accessor for the number of named queries defined for this component. + * @return The number of named queries + */ + int getNumberOfQueries(); + + /** + * Accessor for all FetchGroup defined on the component. + * @return The FetchGroups + */ + FetchGroupMetadata[] getFetchGroups(); + + /** + * Add a new FetchGroup for this component. + * @param name Name of the FetchGroup + * @return The FetchGroupMetadata + */ + FetchGroupMetadata newFetchGroupMetadata(String name); + + /** + * Accessor for the number of fetchGroups defined for this component. + * @return The number of fetch groups + */ + int getNumberOfFetchGroups(); + + /** + * Accessor for all column(s) defined on the join. + * @return The column(s) + */ + ColumnMetadata[] getColumns(); + + /** + * Add a new column for this join. + * @return The ColumnMetadata + */ + ColumnMetadata newColumnMetadata(); + + /** + * Accessor for the number of columns defined for this join. + * @return The number of columns + */ + int getNumberOfColumns(); } diff --git a/api/src/main/java/javax/jdo/metadata/UniqueMetadata.java b/api/src/main/java/javax/jdo/metadata/UniqueMetadata.java index 4b8f3aaea..f82f32d47 100644 --- a/api/src/main/java/javax/jdo/metadata/UniqueMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/UniqueMetadata.java @@ -18,103 +18,91 @@ /** * Represents a unique constraint. - * * @since 3.0 */ public interface UniqueMetadata extends Metadata { - /** - * Method to set the name of the constraint. - * - * @param name Name of the constraint - * @return This metadata object - */ - UniqueMetadata setName(String name); + /** + * Method to set the name of the constraint. + * @param name Name of the constraint + * @return This metadata object + */ + UniqueMetadata setName(String name); - /** - * Accessor for the constraint name. - * - * @return The constraint name - */ - String getName(); + /** + * Accessor for the constraint name. + * @return The constraint name + */ + String getName(); - /** - * Method to set the table name. - * - * @param table Table name - * @return This metadata object - */ - UniqueMetadata setTable(String table); + /** + * Method to set the table name. + * @param table Table name + * @return This metadata object + */ + UniqueMetadata setTable(String table); - /** - * Accessor for the name of the table. - * - * @return The name - */ - String getTable(); + /** + * Accessor for the name of the table. + * @return The name + */ + String getTable(); - /** - * Method to set whether the constraint is deferred. - * - * @param def Deferred? - * @return This metadata object - */ - UniqueMetadata setDeferred(boolean def); + /** + * Method to set whether the constraint is deferred. + * @param def Deferred? + * @return This metadata object + */ + UniqueMetadata setDeferred(boolean def); - /** - * Accessor for whether deferred. - * - * @return Deferred? - */ - Boolean getDeferred(); + /** + * Accessor for whether deferred. + * @return Deferred? + */ + Boolean getDeferred(); - /** - * Accessor for all column(s) defined on the unique constraint. - * - * @return The column(s) - */ - ColumnMetadata[] getColumns(); + /** + * Accessor for all column(s) defined on the unique constraint. + * @return The column(s) + */ + ColumnMetadata[] getColumns(); - /** - * Add a new column for this unique constraint. - * - * @return The ColumnMetadata - */ - ColumnMetadata newColumnMetadata(); + /** + * Add a new column for this unique constraint. + * @return The ColumnMetadata + */ + ColumnMetadata newColumnMetadata(); - /** - * Accessor for the number of columns defined for this unique constraint. - * - * @return The number of columns - */ - int getNumberOfColumns(); + /** + * Accessor for the number of columns defined for this unique constraint. + * @return The number of columns + */ + int getNumberOfColumns(); - /** - * Accessor for all fields/properties defined on the unique constraint. - * - * @return The members - */ - MemberMetadata[] getMembers(); + /** + * Accessor for all fields/properties defined on the unique constraint. + * @return The members + */ + MemberMetadata[] getMembers(); - /** - * Accessor for the number of fields/properties defined for this unique constraint. - * - * @return The number of members - */ - int getNumberOfMembers(); + /** + * Accessor for the number of fields/properties defined for this unique constraint. + * @return The number of members + */ + int getNumberOfMembers(); - /** - * Add a new field for this unique constraint. - * - * @param name Name of the field - * @return The FieldMetadata - */ - FieldMetadata newFieldMetadata(String name); + /** + * Add a new field for this unique constraint. + * + * @param name Name of the field + * @return The FieldMetadata + */ + FieldMetadata newFieldMetadata(String name); - /** - * Add a new property for this unique constraint. - * - * @param name Name of the property - * @return The PropertyMetadata - */ - PropertyMetadata newPropertyMetadata(String name); + /** + * Add a new property for this unique constraint. + * + * @param name Name of the property + * @return The PropertyMetadata + */ + PropertyMetadata newPropertyMetadata(String name); } diff --git a/api/src/main/java/javax/jdo/metadata/ValueMetadata.java b/api/src/main/java/javax/jdo/metadata/ValueMetadata.java index 296b0fe75..51bcdee1f 100644 --- a/api/src/main/java/javax/jdo/metadata/ValueMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/ValueMetadata.java @@ -21,169 +21,144 @@ /** * Represents a value in a map. - * * @since 3.0 */ public interface ValueMetadata extends Metadata { - /** - * Method to set the column name. - * - * @param column Column name - * @return This metadata object - */ - ValueMetadata setColumn(String column); - - /** - * Accessor for the name of the column. - * - * @return The name - */ - String getColumn(); - - /** - * Method to set the table name. - * - * @param table Table name - * @return This metadata object - */ - ValueMetadata setTable(String table); - - /** - * Accessor for the name of the table. - * - * @return The name - */ - String getTable(); - - /** - * Method to set the delete action of the FK. - * - * @param action Delete action of the FK - * @return This metadata object - */ - ValueMetadata setDeleteAction(ForeignKeyAction action); - - /** - * Accessor for the delete action of the FK. - * - * @return The FK delete-action - */ - ForeignKeyAction getDeleteAction(); - - /** - * Method to set the update action of the FK. - * - * @param action Update action of the FK - * @return This metadata object - */ - ValueMetadata setUpdateAction(ForeignKeyAction action); - - /** - * Accessor for the update action of the FK. - * - * @return The FK update-action - */ - ForeignKeyAction getUpdateAction(); - - /** - * Accessor for all column(s) defined on the value. - * - * @return The column(s) - */ - ColumnMetadata[] getColumns(); - - /** - * Add a new column for this value. - * - * @return The ColumnMetadata - */ - ColumnMetadata newColumnMetadata(); - - /** - * Method to set new embedded metadata for the value. - * - * @return The EmbeddedMetadata - */ - EmbeddedMetadata newEmbeddedMetadata(); - - /** - * Accessor for any embedded metadata on this value. - * - * @return The EmbeddedMetadata - */ - EmbeddedMetadata getEmbeddedMetadata(); - - /** - * Method to set new index metadata for the value. - * - * @return The IndexMetadata - */ - IndexMetadata newIndexMetadata(); - - /** - * Accessor for any index metadata on this value. - * - * @return Index metadata - */ - IndexMetadata getIndexMetadata(); - - /** - * Method to set new unique constraint metadata for the value. - * - * @return The UniqueMetadata - */ - UniqueMetadata newUniqueMetadata(); - - /** - * Accessor for any unique constraint metadata on this value. - * - * @return The UniqueMetadata - */ - UniqueMetadata getUniqueMetadata(); - - /** - * Method to set new foreign key metadata for the value. - * - * @return The ForeignKeyMetadata - */ - ForeignKeyMetadata newForeignKeyMetadata(); - - /** - * Accessor for any foreign key metadata on this value. - * - * @return The ForeignKeyMetadata - */ - ForeignKeyMetadata getForeignKeyMetadata(); - - /** - * Accessor for the attribute converter for this value (if any). - * - * @return The converter - */ - AttributeConverter getConverter(); - - /** - * Method to set the attribute converter to use for this value. - * - * @param conv Converter - * @return This value metadata - */ - ValueMetadata setConverter(AttributeConverter conv); - - /** - * Accessor for whether any AttributeConverter for this value type is explicitly disabled and - * should use the implementation default. - * - * @return Whether it is disabled - */ - Boolean getUseDefaultConversion(); - - /** - * Method to explicitly set whether to disable use of AttributeConverter for this type (either - * here, class-level or PMF level). - * - * @param flag Whether to disable - * @return This metadata - */ - ValueMetadata setUseDefaultConversion(Boolean flag); + /** + * Method to set the column name. + * @param column Column name + * @return This metadata object + */ + ValueMetadata setColumn(String column); + + /** + * Accessor for the name of the column. + * @return The name + */ + String getColumn(); + + /** + * Method to set the table name. + * @param table Table name + * @return This metadata object + */ + ValueMetadata setTable(String table); + + /** + * Accessor for the name of the table. + * @return The name + */ + String getTable(); + + /** + * Method to set the delete action of the FK. + * @param action Delete action of the FK + * @return This metadata object + */ + ValueMetadata setDeleteAction(ForeignKeyAction action); + + /** + * Accessor for the delete action of the FK. + * @return The FK delete-action + */ + ForeignKeyAction getDeleteAction(); + + /** + * Method to set the update action of the FK. + * @param action Update action of the FK + * @return This metadata object + */ + ValueMetadata setUpdateAction(ForeignKeyAction action); + + /** + * Accessor for the update action of the FK. + * @return The FK update-action + */ + ForeignKeyAction getUpdateAction(); + + /** + * Accessor for all column(s) defined on the value. + * @return The column(s) + */ + ColumnMetadata[] getColumns(); + + /** + * Add a new column for this value. + * @return The ColumnMetadata + */ + ColumnMetadata newColumnMetadata(); + + /** + * Method to set new embedded metadata for the value. + * @return The EmbeddedMetadata + */ + EmbeddedMetadata newEmbeddedMetadata(); + + /** + * Accessor for any embedded metadata on this value. + * @return The EmbeddedMetadata + */ + EmbeddedMetadata getEmbeddedMetadata(); + + /** + * Method to set new index metadata for the value. + * @return The IndexMetadata + */ + IndexMetadata newIndexMetadata(); + + /** + * Accessor for any index metadata on this value. + * @return Index metadata + */ + IndexMetadata getIndexMetadata(); + + /** + * Method to set new unique constraint metadata for the value. + * @return The UniqueMetadata + */ + UniqueMetadata newUniqueMetadata(); + + /** + * Accessor for any unique constraint metadata on this value. + * @return The UniqueMetadata + */ + UniqueMetadata getUniqueMetadata(); + + /** + * Method to set new foreign key metadata for the value. + * @return The ForeignKeyMetadata + */ + ForeignKeyMetadata newForeignKeyMetadata(); + + /** + * Accessor for any foreign key metadata on this value. + * @return The ForeignKeyMetadata + */ + ForeignKeyMetadata getForeignKeyMetadata(); + + /** + * Accessor for the attribute converter for this value (if any). + * @return The converter + */ + AttributeConverter getConverter(); + + /** + * Method to set the attribute converter to use for this value. + * @param conv Converter + * @return This value metadata + */ + ValueMetadata setConverter(AttributeConverter conv); + + /** + * Accessor for whether any AttributeConverter for this value type is explicitly disabled and should use the implementation default. + * @return Whether it is disabled + */ + Boolean getUseDefaultConversion(); + + /** + * Method to explicitly set whether to disable use of AttributeConverter for this type (either here, class-level or PMF level). + * @param flag Whether to disable + * @return This metadata + */ + ValueMetadata setUseDefaultConversion(Boolean flag); } diff --git a/api/src/main/java/javax/jdo/metadata/VersionMetadata.java b/api/src/main/java/javax/jdo/metadata/VersionMetadata.java index 8e642d09e..38ae453fd 100644 --- a/api/src/main/java/javax/jdo/metadata/VersionMetadata.java +++ b/api/src/main/java/javax/jdo/metadata/VersionMetadata.java @@ -20,87 +20,75 @@ /** * Represents versioning of a class. - * * @since 3.0 */ public interface VersionMetadata extends Metadata { - /** - * Method to set the version strategy. - * - * @param strategy The strategy - * @return This metadata object - */ - VersionMetadata setStrategy(VersionStrategy strategy); + /** + * Method to set the version strategy. + * @param strategy The strategy + * @return This metadata object + */ + VersionMetadata setStrategy(VersionStrategy strategy); - /** - * Accessor for the version strategy. - * - * @return The strategy - */ - VersionStrategy getStrategy(); + /** + * Accessor for the version strategy. + * @return The strategy + */ + VersionStrategy getStrategy(); - /** - * Method to set the version column name. - * - * @param column Name of the version column - * @return This metadata object - */ - VersionMetadata setColumn(String column); + /** + * Method to set the version column name. + * @param column Name of the version column + * @return This metadata object + */ + VersionMetadata setColumn(String column); - /** - * Accessor for the version column name - * - * @return The version column name - */ - String getColumn(); + /** + * Accessor for the version column name + * @return The version column name + */ + String getColumn(); - /** - * Method to set whether indexed. - * - * @param indexed Whether indexed (true | false | unique) - * @return This metadata object - */ - VersionMetadata setIndexed(Indexed indexed); + /** + * Method to set whether indexed. + * @param indexed Whether indexed (true | false | unique) + * @return This metadata object + */ + VersionMetadata setIndexed(Indexed indexed); - /** - * Accessor for whether indexed (true|false|unique). - * - * @return Indexed? - */ - Indexed getIndexed(); + /** + * Accessor for whether indexed (true|false|unique). + * @return Indexed? + */ + Indexed getIndexed(); - /** - * Accessor for all column(s) defined on the version. - * - * @return The column(s) - */ - ColumnMetadata[] getColumns(); + /** + * Accessor for all column(s) defined on the version. + * @return The column(s) + */ + ColumnMetadata[] getColumns(); - /** - * Add a new column for this version. - * - * @return The ColumnMetadata - */ - ColumnMetadata newColumnMetadata(); + /** + * Add a new column for this version. + * @return The ColumnMetadata + */ + ColumnMetadata newColumnMetadata(); - /** - * Accessor for the number of columns defined for this version. - * - * @return The number of columns - */ - int getNumberOfColumns(); + /** + * Accessor for the number of columns defined for this version. + * @return The number of columns + */ + int getNumberOfColumns(); - /** - * Method to set index metadata for the version. - * - * @return The IndexMetadata - */ - IndexMetadata newIndexMetadata(); + /** + * Method to set index metadata for the version. + * @return The IndexMetadata + */ + IndexMetadata newIndexMetadata(); - /** - * Accessor for any index metadata on this version. - * - * @return Index metadata - */ - IndexMetadata getIndexMetadata(); + /** + * Accessor for any index metadata on this version. + * @return Index metadata + */ + IndexMetadata getIndexMetadata(); } diff --git a/api/src/main/java/javax/jdo/query/BooleanExpression.java b/api/src/main/java/javax/jdo/query/BooleanExpression.java index d49f43061..400b4b81d 100644 --- a/api/src/main/java/javax/jdo/query/BooleanExpression.java +++ b/api/src/main/java/javax/jdo/query/BooleanExpression.java @@ -5,46 +5,45 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; -/** Representation of a boolean expression. */ -public interface BooleanExpression extends ComparableExpression { - /** - * Method to return the AND of this expression and the other expression. - * - * @param expr The other expression - * @return The resultant (boolean) expression - */ - BooleanExpression and(BooleanExpression expr); +/** + * Representation of a boolean expression. + */ +public interface BooleanExpression extends ComparableExpression +{ + /** + * Method to return the AND of this expression and the other expression. + * @param expr The other expression + * @return The resultant (boolean) expression + */ + BooleanExpression and(BooleanExpression expr); - /** - * Method to return the OR of this expression and the other expression. - * - * @param expr The other expression - * @return The resultant (boolean) expression - */ - BooleanExpression or(BooleanExpression expr); + /** + * Method to return the OR of this expression and the other expression. + * @param expr The other expression + * @return The resultant (boolean) expression + */ + BooleanExpression or(BooleanExpression expr); - /** - * Method to negate this expression. - * - * @return The negated expression - */ - BooleanExpression not(); + /** + * Method to negate this expression. + * @return The negated expression + */ + BooleanExpression not(); - /** - * Method to return an expression that is the current expression negated. - * - * @return The negated expression - */ - BooleanExpression neg(); -} + /** + * Method to return an expression that is the current expression negated. + * @return The negated expression + */ + BooleanExpression neg(); +} \ No newline at end of file diff --git a/api/src/main/java/javax/jdo/query/ByteExpression.java b/api/src/main/java/javax/jdo/query/ByteExpression.java index 1a99f21fe..84a9b5366 100644 --- a/api/src/main/java/javax/jdo/query/ByteExpression.java +++ b/api/src/main/java/javax/jdo/query/ByteExpression.java @@ -5,16 +5,20 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; -/** Representation of a byte expression. */ -public interface ByteExpression extends ComparableExpression {} +/** + * Representation of a byte expression. + */ +public interface ByteExpression extends ComparableExpression +{ +} \ No newline at end of file diff --git a/api/src/main/java/javax/jdo/query/CharacterExpression.java b/api/src/main/java/javax/jdo/query/CharacterExpression.java index 33b7c1552..080b9a772 100644 --- a/api/src/main/java/javax/jdo/query/CharacterExpression.java +++ b/api/src/main/java/javax/jdo/query/CharacterExpression.java @@ -5,44 +5,43 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; -/** Representation of a character expression. */ -public interface CharacterExpression extends ComparableExpression { - /** - * Method to return a CharacterExpression representing this CharacterExpression in lower case. - * - * @return The lower case expression - */ - CharacterExpression toLowerCase(); +/** + * Representation of a character expression. + */ +public interface CharacterExpression extends ComparableExpression +{ + /** + * Method to return a CharacterExpression representing this CharacterExpression in lower case. + * @return The lower case expression + */ + CharacterExpression toLowerCase(); - /** - * Method to return a CharacterExpression representing this CharacterExpression in upper case. - * - * @return The upper case expression - */ - CharacterExpression toUpperCase(); + /** + * Method to return a CharacterExpression representing this CharacterExpression in upper case. + * @return The upper case expression + */ + CharacterExpression toUpperCase(); - /** - * Method to return an expression that is the current expression negated. - * - * @return The negated expression - */ - CharacterExpression neg(); + /** + * Method to return an expression that is the current expression negated. + * @return The negated expression + */ + CharacterExpression neg(); - /** - * Method to return an expression that is the complement of the current expression. - * - * @return The complement expression - */ - CharacterExpression com(); -} + /** + * Method to return an expression that is the complement of the current expression. + * @return The complement expression + */ + CharacterExpression com(); +} \ No newline at end of file diff --git a/api/src/main/java/javax/jdo/query/CollectionExpression.java b/api/src/main/java/javax/jdo/query/CollectionExpression.java index b3bc194f2..af10d2fcd 100644 --- a/api/src/main/java/javax/jdo/query/CollectionExpression.java +++ b/api/src/main/java/javax/jdo/query/CollectionExpression.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; @@ -20,38 +20,35 @@ /** * Representation of a collection in a query. - * + * * @param Java type being represented here * @param Element type of the collection being represented here */ -public interface CollectionExpression, E> extends Expression { - /** - * Method returning whether the specified element expression is contained in this collection. - * - * @param expr The element expression - * @return Whether it is contained here - */ - BooleanExpression contains(Expression expr); +public interface CollectionExpression, E> extends Expression +{ + /** + * Method returning whether the specified element expression is contained in this collection. + * @param expr The element expression + * @return Whether it is contained here + */ + BooleanExpression contains(Expression expr); - /** - * Method returning whether the specified element is contained in this collection. - * - * @param elem The element - * @return Whether it is contained here - */ - BooleanExpression contains(E elem); + /** + * Method returning whether the specified element is contained in this collection. + * @param elem The element + * @return Whether it is contained here + */ + BooleanExpression contains(E elem); - /** - * Method returning whether the collection is empty. - * - * @return Whether it is empty - */ - BooleanExpression isEmpty(); + /** + * Method returning whether the collection is empty. + * @return Whether it is empty + */ + BooleanExpression isEmpty(); - /** - * Method returning an expression for the size of the collection - * - * @return The size - */ - NumericExpression size(); -} + /** + * Method returning an expression for the size of the collection + * @return The size + */ + NumericExpression size(); +} \ No newline at end of file diff --git a/api/src/main/java/javax/jdo/query/ComparableExpression.java b/api/src/main/java/javax/jdo/query/ComparableExpression.java index b51479b41..7ac4a33bc 100644 --- a/api/src/main/java/javax/jdo/query/ComparableExpression.java +++ b/api/src/main/java/javax/jdo/query/ComparableExpression.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; @@ -21,96 +21,86 @@ * * @param Java type being represented here */ -public interface ComparableExpression extends Expression { - /** - * Method returning whether this expression is less than the other expression. - * - * @param expr Other expression - * @return Whether this is less than the other - */ - BooleanExpression lt(ComparableExpression expr); +public interface ComparableExpression extends Expression +{ + /** + * Method returning whether this expression is less than the other expression. + * @param expr Other expression + * @return Whether this is less than the other + */ + BooleanExpression lt(ComparableExpression expr); - /** - * Method returning whether this expression is less than the literal. - * - * @param t literal - * @return Whether this is less than the other - */ - BooleanExpression lt(T t); + /** + * Method returning whether this expression is less than the literal. + * @param t literal + * @return Whether this is less than the other + */ + BooleanExpression lt(T t); - /** - * Method returning whether this expression is less than or equal the other expression. - * - * @param expr Other expression - * @return Whether this is less than or equal the other - */ - BooleanExpression lteq(ComparableExpression expr); + /** + * Method returning whether this expression is less than or equal the other expression. + * @param expr Other expression + * @return Whether this is less than or equal the other + */ + BooleanExpression lteq(ComparableExpression expr); - /** - * Method returning whether this expression is less than or equal the literal. - * - * @param t literal - * @return Whether this is less than or equal the other - */ - BooleanExpression lteq(T t); + /** + * Method returning whether this expression is less than or equal the literal. + * @param t literal + * @return Whether this is less than or equal the other + */ + BooleanExpression lteq(T t); - /** - * Method returning whether this expression is greater than the other expression. - * - * @param expr Other expression - * @return Whether this is greater than the other - */ - BooleanExpression gt(ComparableExpression expr); + /** + * Method returning whether this expression is greater than the other expression. + * @param expr Other expression + * @return Whether this is greater than the other + */ + BooleanExpression gt(ComparableExpression expr); - /** - * Method returning whether this expression is greater than the literal. - * - * @param t literal - * @return Whether this is greater than the other - */ - BooleanExpression gt(T t); + /** + * Method returning whether this expression is greater than the literal. + * @param t literal + * @return Whether this is greater than the other + */ + BooleanExpression gt(T t); - /** - * Method returning whether this expression is greater than or equal the other expression. - * - * @param expr Other expression - * @return Whether this is greater than or equal to the other - */ - BooleanExpression gteq(ComparableExpression expr); + /** + * Method returning whether this expression is greater than or equal the other expression. + * @param expr Other expression + * @return Whether this is greater than or equal to the other + */ + BooleanExpression gteq(ComparableExpression expr); - /** - * Method returning whether this expression is greater than or equal the literal. - * - * @param t literal - * @return Whether this is greater than or equal to the other - */ - BooleanExpression gteq(T t); + /** + * Method returning whether this expression is greater than or equal the literal. + * @param t literal + * @return Whether this is greater than or equal to the other + */ + BooleanExpression gteq(T t); - /** - * Method to return a numeric expression representing the aggregated minimum of this expression. - * - * @return expression for the minimum - */ - ComparableExpression min(); + /** + * Method to return a numeric expression representing the aggregated minimum of this expression. + * @return expression for the minimum + */ + ComparableExpression min(); - /** - * Method to return a numeric expression representing the aggregated maximum of this expression. - * - * @return expression for the maximum - */ - ComparableExpression max(); + /** + * Method to return a numeric expression representing the aggregated maximum of this expression. + * @return expression for the maximum + */ + ComparableExpression max(); - /** - * Method to return an order expression for this expression in ascending order. - * - * @return The order expression - */ - OrderExpression asc(); + /** + * Method to return an order expression for this expression in ascending order. + * @return The order expression + */ + OrderExpression asc(); - /** - * Method to return an order expression for this expression in descending order. - * - * @return The order expression - */ - OrderExpression desc(); + /** + * Method to return an order expression for this expression in descending order. + * @return The order expression + */ + OrderExpression desc(); } + diff --git a/api/src/main/java/javax/jdo/query/DateExpression.java b/api/src/main/java/javax/jdo/query/DateExpression.java index 00a08ac19..dfb0be004 100644 --- a/api/src/main/java/javax/jdo/query/DateExpression.java +++ b/api/src/main/java/javax/jdo/query/DateExpression.java @@ -5,37 +5,37 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; -/** Representation of a date in a query. */ -public interface DateExpression extends ComparableExpression { - /** - * Accessor for the year of this date. - * - * @return Expression for the year - */ - NumericExpression getYear(); +/** + * Representation of a date in a query. + */ +public interface DateExpression extends ComparableExpression +{ + /** + * Accessor for the year of this date. + * @return Expression for the year + */ + NumericExpression getYear(); - /** - * Accessor for the month of this date. - * - * @return Expression for the month - */ - NumericExpression getMonth(); + /** + * Accessor for the month of this date. + * @return Expression for the month + */ + NumericExpression getMonth(); - /** - * Accessor for the day (of the month) of this date. - * - * @return Expression for the day of the month - */ - NumericExpression getDay(); -} + /** + * Accessor for the day (of the month) of this date. + * @return Expression for the day of the month + */ + NumericExpression getDay(); +} \ No newline at end of file diff --git a/api/src/main/java/javax/jdo/query/DateTimeExpression.java b/api/src/main/java/javax/jdo/query/DateTimeExpression.java index 23cbcfd1d..fd0b273d8 100644 --- a/api/src/main/java/javax/jdo/query/DateTimeExpression.java +++ b/api/src/main/java/javax/jdo/query/DateTimeExpression.java @@ -5,58 +5,55 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; -/** Representation of a date-time type in a query. */ -public interface DateTimeExpression extends ComparableExpression { - /** - * Accessor for the year of this date-time. - * - * @return Expression for the year - */ - NumericExpression getYear(); +/** + * Representation of a date-time type in a query. + */ +public interface DateTimeExpression extends ComparableExpression +{ + /** + * Accessor for the year of this date-time. + * @return Expression for the year + */ + NumericExpression getYear(); - /** - * Accessor for the month of this date-time. - * - * @return Expression for the month - */ - NumericExpression getMonth(); + /** + * Accessor for the month of this date-time. + * @return Expression for the month + */ + NumericExpression getMonth(); - /** - * Accessor for the day (of the month) of this date-time. - * - * @return Expression for the day of the month - */ - NumericExpression getDay(); + /** + * Accessor for the day (of the month) of this date-time. + * @return Expression for the day of the month + */ + NumericExpression getDay(); - /** - * Accessor for the hour of this date-time. - * - * @return Expression for the hour - */ - NumericExpression getHour(); + /** + * Accessor for the hour of this date-time. + * @return Expression for the hour + */ + NumericExpression getHour(); - /** - * Accessor for the minute of this date-time. - * - * @return Expression for the minute - */ - NumericExpression getMinute(); + /** + * Accessor for the minute of this date-time. + * @return Expression for the minute + */ + NumericExpression getMinute(); - /** - * Accessor for the second of this date-time. - * - * @return Expression for the second - */ - NumericExpression getSecond(); -} + /** + * Accessor for the second of this date-time. + * @return Expression for the second + */ + NumericExpression getSecond(); +} \ No newline at end of file diff --git a/api/src/main/java/javax/jdo/query/EnumExpression.java b/api/src/main/java/javax/jdo/query/EnumExpression.java index 1a7323b74..68e48b884 100644 --- a/api/src/main/java/javax/jdo/query/EnumExpression.java +++ b/api/src/main/java/javax/jdo/query/EnumExpression.java @@ -5,27 +5,27 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; /** * Representation of an Enum in a query. - * + * * @param Enum type */ -public interface EnumExpression extends ComparableExpression { - /** - * Method to return an expression for the ordinal of this enum. - * - * @return Expression for the ordinal of the passed enum - */ - NumericExpression ordinal(); +public interface EnumExpression extends ComparableExpression +{ + /** + * Method to return an expression for the ordinal of this enum. + * @return Expression for the ordinal of the passed enum + */ + NumericExpression ordinal(); } diff --git a/api/src/main/java/javax/jdo/query/Expression.java b/api/src/main/java/javax/jdo/query/Expression.java index 89b1bbac6..b304c8f50 100644 --- a/api/src/main/java/javax/jdo/query/Expression.java +++ b/api/src/main/java/javax/jdo/query/Expression.java @@ -5,91 +5,82 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; /** * Representation of an expression in a query. - * + * * @param Java type being represented here */ -public interface Expression { - /** - * Method returning whether this expression equals the other expression. - * - * @param expr Other expression - * @return Whether they are equal - */ - BooleanExpression eq(Expression expr); +public interface Expression +{ + /** + * Method returning whether this expression equals the other expression. + * @param expr Other expression + * @return Whether they are equal + */ + BooleanExpression eq(Expression expr); - /** - * Method returning whether this expression equals the literal. - * - * @param t Literal - * @return Whether they are equal - */ - BooleanExpression eq(T t); + /** + * Method returning whether this expression equals the literal. + * @param t Literal + * @return Whether they are equal + */ + BooleanExpression eq(T t); - /** - * Method returning whether this expression doesn't equal the other expression. - * - * @param expr Other expression - * @return Whether they are not equal - */ - BooleanExpression ne(Expression expr); + /** + * Method returning whether this expression doesn't equal the other expression. + * @param expr Other expression + * @return Whether they are not equal + */ + BooleanExpression ne(Expression expr); - /** - * Method returning whether this expression doesn't equal the literal. - * - * @param t literal - * @return Whether they are not equal - */ - BooleanExpression ne(T t); + /** + * Method returning whether this expression doesn't equal the literal. + * @param t literal + * @return Whether they are not equal + */ + BooleanExpression ne(T t); - /** - * Method to return a numeric expression representing the aggregated count of this expression. - * - * @return Numeric expression for the count - */ - NumericExpression count(); + /** + * Method to return a numeric expression representing the aggregated count of this expression. + * @return Numeric expression for the count + */ + NumericExpression count(); - /** - * Method to return a numeric expression representing the aggregated (distinct) count of this - * expression. - * - * @return Numeric expression for the distinct count - */ - NumericExpression countDistinct(); + /** + * Method to return a numeric expression representing the aggregated (distinct) count of this expression. + * @return Numeric expression for the distinct count + */ + NumericExpression countDistinct(); - /** - * Return an expression for whether this expression is an instanceof the supplied class. - * - * @param cls Class to check against - * @return Whether it is an instanceof - */ - BooleanExpression instanceOf(Class cls); + /** + * Return an expression for whether this expression is an instanceof the supplied class. + * @param cls Class to check against + * @return Whether it is an instanceof + */ + BooleanExpression instanceOf(Class cls); - /** - * Return an expression where this expression is cast to the specified type. - * - * @param cls Class to cast to - * @return The cast expression - */ - Expression cast(Class cls); + /** + * Return an expression where this expression is cast to the specified type. + * @param cls Class to cast to + * @return The cast expression + */ + Expression cast(Class cls); - /** - * Method to return an expression with the specified alias assigned to this expression. - * - * @param alias the alias for this expression - * @return the expression with an alias - */ - Expression as(String alias); -} + /** + * Method to return an expression with the specified alias assigned to this expression. + * @param alias the alias for this expression + * @return the expression with an alias + */ + Expression as(String alias); +} \ No newline at end of file diff --git a/api/src/main/java/javax/jdo/query/IfThenElseExpression.java b/api/src/main/java/javax/jdo/query/IfThenElseExpression.java index 5dd02736f..c014b6cc1 100644 --- a/api/src/main/java/javax/jdo/query/IfThenElseExpression.java +++ b/api/src/main/java/javax/jdo/query/IfThenElseExpression.java @@ -23,41 +23,38 @@ */ public interface IfThenElseExpression extends ComparableExpression { - /** - * Method to add an "IF (...) ..." clause. If called multiple times, will add extra "IF (...) ..." - * or "ELSE IF (...) ..." - * - * @param cond The if expression - * @param thenValueExpr Expression to return when the if expression is met - * @return This expression - */ - IfThenElseExpression ifThen(BooleanExpression cond, Expression thenValueExpr); + /** + * Method to add an "IF (...) ..." clause. + * If called multiple times, will add extra "IF (...) ..." or "ELSE IF (...) ..." + * @param cond The if expression + * @param thenValueExpr Expression to return when the if expression is met + * @return This expression + */ + IfThenElseExpression ifThen(BooleanExpression cond, Expression thenValueExpr); - /** - * Method to add an "IF (...) ..." clause. If called multiple times, will add extra "IF (...) ..." - * or "ELSE IF (...) ..." - * - * @param cond The if condition - * @param thenValue Value to return when the if expression is met - * @return This expression - */ - IfThenElseExpression ifThen(BooleanExpression cond, T thenValue); + /** + * Method to add an "IF (...) ..." clause. + * If called multiple times, will add extra "IF (...) ..." or "ELSE IF (...) ..." + * @param cond The if condition + * @param thenValue Value to return when the if expression is met + * @return This expression + */ + IfThenElseExpression ifThen(BooleanExpression cond, T thenValue); - /** - * Method to add the "ELSE ..." clause. If called multiple times will replace the previous else - * clause - * - * @param elseValueExpr Expression for value to return when the if expression is not met - * @return This expression - */ - IfThenElseExpression elseEnd(Expression elseValueExpr); + /** + * Method to add the "ELSE ..." clause. + * If called multiple times will replace the previous else clause + * @param elseValueExpr Expression for value to return when the if expression is not met + * @return This expression + */ + IfThenElseExpression elseEnd(Expression elseValueExpr); - /** - * Method to add the "ELSE ..." clause. If called multiple times will replace the previous else - * clause - * - * @param elseValue Value to return when the if expression is not met - * @return This expression - */ - IfThenElseExpression elseEnd(T elseValue); + /** + * Method to add the "ELSE ..." clause. + * If called multiple times will replace the previous else clause + * @param elseValue Value to return when the if expression is not met + * @return This expression + */ + IfThenElseExpression elseEnd(T elseValue); + } diff --git a/api/src/main/java/javax/jdo/query/ListExpression.java b/api/src/main/java/javax/jdo/query/ListExpression.java index 09fc173ca..d6b422fc4 100644 --- a/api/src/main/java/javax/jdo/query/ListExpression.java +++ b/api/src/main/java/javax/jdo/query/ListExpression.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; @@ -20,24 +20,23 @@ /** * Representation of a List in a query. - * + * * @param Java type being represented here * @param Element type of the List being represented here */ -public interface ListExpression, E> extends CollectionExpression { - /** - * Method returning the element at this position in the List. - * - * @param posExpr The position expression - * @return The element at this position in the List - */ - Expression get(NumericExpression posExpr); +public interface ListExpression, E> extends CollectionExpression +{ + /** + * Method returning the element at this position in the List. + * @param posExpr The position expression + * @return The element at this position in the List + */ + Expression get(NumericExpression posExpr); - /** - * Method returning the element at this position in the List. - * - * @param pos The position - * @return The element at this position in the List - */ - Expression get(int pos); -} + /** + * Method returning the element at this position in the List. + * @param pos The position + * @return The element at this position in the List + */ + Expression get(int pos); +} \ No newline at end of file diff --git a/api/src/main/java/javax/jdo/query/LocalDateExpression.java b/api/src/main/java/javax/jdo/query/LocalDateExpression.java index 7be4b83ea..6df74164b 100644 --- a/api/src/main/java/javax/jdo/query/LocalDateExpression.java +++ b/api/src/main/java/javax/jdo/query/LocalDateExpression.java @@ -5,37 +5,40 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; -/** Representation of a java.time.LocalDate in a query. */ -public interface LocalDateExpression extends ComparableExpression { - /** - * Accessor for the year of this date. - * - * @return Expression for the year - */ - NumericExpression getYear(); +import javax.jdo.query.ComparableExpression; +import javax.jdo.query.NumericExpression; - /** - * Accessor for the month of this date. - * - * @return Expression for the month - */ - NumericExpression getMonthValue(); +/** + * Representation of a java.time.LocalDate in a query. + */ +public interface LocalDateExpression extends ComparableExpression +{ + /** + * Accessor for the year of this date. + * @return Expression for the year + */ + NumericExpression getYear(); + + /** + * Accessor for the month of this date. + * @return Expression for the month + */ + NumericExpression getMonthValue(); - /** - * Accessor for the day (of the month) of this date. - * - * @return Expression for the day of the month - */ - NumericExpression getDayOfMonth(); + /** + * Accessor for the day (of the month) of this date. + * @return Expression for the day of the month + */ + NumericExpression getDayOfMonth(); } diff --git a/api/src/main/java/javax/jdo/query/LocalDateTimeExpression.java b/api/src/main/java/javax/jdo/query/LocalDateTimeExpression.java index 2c40184fb..ea553cf2f 100644 --- a/api/src/main/java/javax/jdo/query/LocalDateTimeExpression.java +++ b/api/src/main/java/javax/jdo/query/LocalDateTimeExpression.java @@ -5,58 +5,58 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; -/** Representation of a java.time.LocalDateTime type in a query. */ -public interface LocalDateTimeExpression extends ComparableExpression { - /** - * Accessor for the year of this date-time. - * - * @return Expression for the year - */ - NumericExpression getYear(); +import javax.jdo.query.ComparableExpression; +import javax.jdo.query.NumericExpression; - /** - * Accessor for the month of this date-time. - * - * @return Expression for the month - */ - NumericExpression getMonthValue(); +/** + * Representation of a java.time.LocalDateTime type in a query. + */ +public interface LocalDateTimeExpression extends ComparableExpression +{ + /** + * Accessor for the year of this date-time. + * @return Expression for the year + */ + NumericExpression getYear(); + + /** + * Accessor for the month of this date-time. + * @return Expression for the month + */ + NumericExpression getMonthValue(); - /** - * Accessor for the day (of the month) of this date-time. - * - * @return Expression for the day of the month - */ - NumericExpression getDayOfMonth(); + /** + * Accessor for the day (of the month) of this date-time. + * @return Expression for the day of the month + */ + NumericExpression getDayOfMonth(); - /** - * Accessor for the hour of this date-time. - * - * @return Expression for the hour - */ - NumericExpression getHour(); + /** + * Accessor for the hour of this date-time. + * @return Expression for the hour + */ + NumericExpression getHour(); - /** - * Accessor for the minute of this date-time. - * - * @return Expression for the minute - */ - NumericExpression getMinute(); + /** + * Accessor for the minute of this date-time. + * @return Expression for the minute + */ + NumericExpression getMinute(); - /** - * Accessor for the second of this date-time. - * - * @return Expression for the second - */ - NumericExpression getSecond(); + /** + * Accessor for the second of this date-time. + * @return Expression for the second + */ + NumericExpression getSecond(); } diff --git a/api/src/main/java/javax/jdo/query/LocalTimeExpression.java b/api/src/main/java/javax/jdo/query/LocalTimeExpression.java index 994fd9ed1..8ce93e20e 100644 --- a/api/src/main/java/javax/jdo/query/LocalTimeExpression.java +++ b/api/src/main/java/javax/jdo/query/LocalTimeExpression.java @@ -5,37 +5,40 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; -/** Representation of a java.time.LocalTime in a query. */ -public interface LocalTimeExpression extends ComparableExpression { - /** - * Accessor for the hour of this time. - * - * @return Expression for the hour - */ - NumericExpression getHour(); +import javax.jdo.query.ComparableExpression; +import javax.jdo.query.NumericExpression; - /** - * Accessor for the minute of this time. - * - * @return Expression for the minute - */ - NumericExpression getMinute(); +/** + * Representation of a java.time.LocalTime in a query. + */ +public interface LocalTimeExpression extends ComparableExpression +{ + /** + * Accessor for the hour of this time. + * @return Expression for the hour + */ + NumericExpression getHour(); + + /** + * Accessor for the minute of this time. + * @return Expression for the minute + */ + NumericExpression getMinute(); - /** - * Accessor for the second of this time. - * - * @return Expression for the second - */ - NumericExpression getSecond(); + /** + * Accessor for the second of this time. + * @return Expression for the second + */ + NumericExpression getSecond(); } diff --git a/api/src/main/java/javax/jdo/query/MapExpression.java b/api/src/main/java/javax/jdo/query/MapExpression.java index 964ba3900..13b48668b 100644 --- a/api/src/main/java/javax/jdo/query/MapExpression.java +++ b/api/src/main/java/javax/jdo/query/MapExpression.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; @@ -20,87 +20,78 @@ /** * Representation of a map in a query. - * + * * @param Java type being represented here * @param Key type of the map being represented here * @param Value type of the map being represented here */ -public interface MapExpression, K, V> extends Expression { - /** - * Method returning an expression for the value of the specified key in the map. - * - * @param key The key expression - * @return the value for the specified key - */ - Expression get(Expression key); +public interface MapExpression, K, V> extends Expression +{ + /** + * Method returning an expression for the value of the specified key in the map. + * @param key The key expression + * @return the value for the specified key + */ + Expression get(Expression key); - /** - * Method returning an expression for the value of the specified key in the map. - * - * @param key The key expression - * @return the value for the specified key - */ - Expression get(K key); + /** + * Method returning an expression for the value of the specified key in the map. + * @param key The key expression + * @return the value for the specified key + */ + Expression get(K key); - /** - * Method returning whether the specified key expression is contained in this map. - * - * @param expr The key expression - * @return Whether it is contained here - */ - BooleanExpression containsKey(Expression expr); + /** + * Method returning whether the specified key expression is contained in this map. + * @param expr The key expression + * @return Whether it is contained here + */ + BooleanExpression containsKey(Expression expr); - /** - * Method returning whether the specified key is contained in this map. - * - * @param key The key - * @return Whether it is contained here - */ - BooleanExpression containsKey(K key); + /** + * Method returning whether the specified key is contained in this map. + * @param key The key + * @return Whether it is contained here + */ + BooleanExpression containsKey(K key); - /** - * Method returning whether the specified value expression is contained in this map. - * - * @param expr The value expression - * @return Whether it is contained here - */ - BooleanExpression containsValue(Expression expr); + /** + * Method returning whether the specified value expression is contained in this map. + * @param expr The value expression + * @return Whether it is contained here + */ + BooleanExpression containsValue(Expression expr); - /** - * Method returning whether the specified value is contained in this map. - * - * @param value The value - * @return Whether it is contained here - */ - BooleanExpression containsValue(V value); + /** + * Method returning whether the specified value is contained in this map. + * @param value The value + * @return Whether it is contained here + */ + BooleanExpression containsValue(V value); - /** - * Method returning whether the specified entry expression is contained in this map. - * - * @param expr The entry expression - * @return Whether it is contained here - */ - BooleanExpression containsEntry(Expression> expr); + /** + * Method returning whether the specified entry expression is contained in this map. + * @param expr The entry expression + * @return Whether it is contained here + */ + BooleanExpression containsEntry(Expression> expr); - /** - * Method returning whether the specified entry is contained in this map. - * - * @param entry The entry expression - * @return Whether it is contained here - */ - BooleanExpression containsEntry(Map.Entry entry); + /** + * Method returning whether the specified entry is contained in this map. + * @param entry The entry expression + * @return Whether it is contained here + */ + BooleanExpression containsEntry(Map.Entry entry); - /** - * Method returning whether the map is empty. - * - * @return Whether it is empty - */ - BooleanExpression isEmpty(); + /** + * Method returning whether the map is empty. + * @return Whether it is empty + */ + BooleanExpression isEmpty(); - /** - * Method returning an expression for the size of the map - * - * @return The size - */ - NumericExpression size(); -} + /** + * Method returning an expression for the size of the map + * @return The size + */ + NumericExpression size(); +} \ No newline at end of file diff --git a/api/src/main/java/javax/jdo/query/NumericExpression.java b/api/src/main/java/javax/jdo/query/NumericExpression.java index f3270593b..c509f0858 100644 --- a/api/src/main/java/javax/jdo/query/NumericExpression.java +++ b/api/src/main/java/javax/jdo/query/NumericExpression.java @@ -5,256 +5,220 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; /** * Representation of a numeric expression. - * + * * @param Number type */ -public interface NumericExpression extends ComparableExpression { - /** - * Method to return an expression for this expression added to the passed expression. - * - * @param expr The other expression - * @return The summation - */ - NumericExpression add(Expression expr); - - /** - * Method to return an expression for this expression added to the passed number. - * - * @param num Number to add - * @return The summation - */ - NumericExpression add(Number num); - - /** - * Method to return an expression for this expression subtracting the passed expression. - * - * @param expr The other expression - * @return The difference - */ - NumericExpression sub(Expression expr); - - /** - * Method to return an expression for this expression subtracting the passed number. - * - * @param num Number to subtract - * @return The difference - */ - NumericExpression sub(Number num); - - /** - * Method to return an expression for this expression multiplied by the passed expression. - * - * @param expr The other expression - * @return The multiplication - */ - NumericExpression mul(Expression expr); - - /** - * Method to return an expression for this expression multiplied by the passed number. - * - * @param num Number - * @return The multiplication - */ - NumericExpression mul(Number num); - - /** - * Method to return an expression for this expression divided by the passed expression. - * - * @param expr The other expression - * @return The division - */ - NumericExpression div(Expression expr); - - /** - * Method to return an expression for this expression divided by the passed number. - * - * @param num Number to divide by - * @return The division - */ - NumericExpression div(Number num); - - /** - * Method to return an expression for this expression modulus the passed expression ( - * - *

    a % b
    - * - * ). - * - * @param expr The other expression - * @return The modulus - */ - NumericExpression mod(Expression expr); - - /** - * Method to return an expression for this expression modulus the passed number. - * - * @param num Number - * @return The modulus - */ - NumericExpression mod(Number num); - - /** - * Method to return an expression that is the current expression negated. - * - * @return The negated expression - */ - NumericExpression neg(); - - /** - * Method to return an expression that is the complement of the current expression. - * - * @return The complement expression - */ - NumericExpression com(); - - /** - * Method to return a numeric expression representing the aggregated average of this expression. - * - * @return Numeric expression for the average - */ - NumericExpression avg(); - - /** - * Method to return a numeric expression representing the aggregated (distinct) average of this - * expression. - * - * @return Numeric expression for the average - */ - NumericExpression avgDistinct(); - - /** - * Method to return a numeric expression representing the aggregated sum of this expression. - * - * @return Numeric expression for the sum - */ - NumericExpression sum(); - - /** - * Method to return a numeric expression representing the aggregated (distinct) sum of this - * expression. - * - * @return Numeric expression for the sum - */ - NumericExpression sumDistinct(); - - /** - * Method to return the absolute value expression of this expression. - * - * @return The absolute value expression - */ - NumericExpression abs(); - - /** - * Method to return the square-root value expression of this expression. - * - * @return The square-root value expression - */ - NumericExpression sqrt(); - - /** - * Method to return the arc cosine value expression of this expression. - * - * @return The arc cosine value expression - */ - NumericExpression acos(); - - /** - * Method to return the arc sine value expression of this expression. - * - * @return The arc sine value expression - */ - NumericExpression asin(); - - /** - * Method to return the arc tangent value expression of this expression. - * - * @return The arc tangent value expression - */ - NumericExpression atan(); - - /** - * Method to return the sine value expression of this expression. - * - * @return The sine value expression - */ - NumericExpression sin(); - - /** - * Method to return the cosine value expression of this expression. - * - * @return The cosine value expression - */ - NumericExpression cos(); - - /** - * Method to return the tangent value expression of this expression. - * - * @return The tangent value expression - */ - NumericExpression tan(); - - /** - * Method to return the exponential value expression of this expression. - * - * @return The exponential value expression - */ - NumericExpression exp(); - - /** - * Method to return the logarithm value expression of this expression. - * - * @return The logarithm value expression - */ - NumericExpression log(); - - /** - * Method to return the ceiling value expression of this expression. - * - * @return The ceiling value expression - */ - NumericExpression ceil(); - - /** - * Method to return the floor value expression of this expression. - * - * @return The floor value expression - */ - NumericExpression floor(); - - /** - * Method to return a bitwise AND expression for this expression with the supplied bit path. - * - * @param bitExpr Bit expression - * @return Bitwise AND expression - */ - NumericExpression bAnd(NumericExpression bitExpr); - - /** - * Method to return a bitwise OR expression for this expression with the supplied bit path. - * - * @param bitExpr Bit expression - * @return Bitwise OR expression - */ - NumericExpression bOr(NumericExpression bitExpr); - - /** - * Method to return a bitwise XOR expression for this expression with the supplied bit path. - * - * @param bitExpr Bit expression - * @return Bitwise XOR expression - */ - NumericExpression bXor(NumericExpression bitExpr); +public interface NumericExpression extends ComparableExpression +{ + /** + * Method to return an expression for this expression added to the passed expression. + * @param expr The other expression + * @return The summation + */ + NumericExpression add(Expression expr); + + /** + * Method to return an expression for this expression added to the passed number. + * @param num Number to add + * @return The summation + */ + NumericExpression add(Number num); + + /** + * Method to return an expression for this expression subtracting the passed expression. + * @param expr The other expression + * @return The difference + */ + NumericExpression sub(Expression expr); + + /** + * Method to return an expression for this expression subtracting the passed number. + * @param num Number to subtract + * @return The difference + */ + NumericExpression sub(Number num); + + /** + * Method to return an expression for this expression multiplied by the passed expression. + * @param expr The other expression + * @return The multiplication + */ + NumericExpression mul(Expression expr); + + /** + * Method to return an expression for this expression multiplied by the passed number. + * @param num Number + * @return The multiplication + */ + NumericExpression mul(Number num); + + /** + * Method to return an expression for this expression divided by the passed expression. + * @param expr The other expression + * @return The division + */ + NumericExpression div(Expression expr); + + /** + * Method to return an expression for this expression divided by the passed number. + * @param num Number to divide by + * @return The division + */ + NumericExpression div(Number num); + + /** + * Method to return an expression for this expression modulus the passed expression (
    a % b
    ). + * @param expr The other expression + * @return The modulus + */ + NumericExpression mod(Expression expr); + + /** + * Method to return an expression for this expression modulus the passed number. + * @param num Number + * @return The modulus + */ + NumericExpression mod(Number num); + + /** + * Method to return an expression that is the current expression negated. + * @return The negated expression + */ + NumericExpression neg(); + + /** + * Method to return an expression that is the complement of the current expression. + * @return The complement expression + */ + NumericExpression com(); + + /** + * Method to return a numeric expression representing the aggregated average of this expression. + * @return Numeric expression for the average + */ + NumericExpression avg(); + + /** + * Method to return a numeric expression representing the aggregated (distinct) average of this expression. + * @return Numeric expression for the average + */ + NumericExpression avgDistinct(); + + /** + * Method to return a numeric expression representing the aggregated sum of this expression. + * @return Numeric expression for the sum + */ + NumericExpression sum(); + + /** + * Method to return a numeric expression representing the aggregated (distinct) sum of this expression. + * @return Numeric expression for the sum + */ + NumericExpression sumDistinct(); + + /** + * Method to return the absolute value expression of this expression. + * @return The absolute value expression + */ + NumericExpression abs(); + + /** + * Method to return the square-root value expression of this expression. + * @return The square-root value expression + */ + NumericExpression sqrt(); + + /** + * Method to return the arc cosine value expression of this expression. + * @return The arc cosine value expression + */ + NumericExpression acos(); + + /** + * Method to return the arc sine value expression of this expression. + * @return The arc sine value expression + */ + NumericExpression asin(); + + /** + * Method to return the arc tangent value expression of this expression. + * @return The arc tangent value expression + */ + NumericExpression atan(); + + /** + * Method to return the sine value expression of this expression. + * @return The sine value expression + */ + NumericExpression sin(); + + /** + * Method to return the cosine value expression of this expression. + * @return The cosine value expression + */ + NumericExpression cos(); + + /** + * Method to return the tangent value expression of this expression. + * @return The tangent value expression + */ + NumericExpression tan(); + + /** + * Method to return the exponential value expression of this expression. + * @return The exponential value expression + */ + NumericExpression exp(); + + /** + * Method to return the logarithm value expression of this expression. + * @return The logarithm value expression + */ + NumericExpression log(); + + /** + * Method to return the ceiling value expression of this expression. + * @return The ceiling value expression + */ + NumericExpression ceil(); + + /** + * Method to return the floor value expression of this expression. + * @return The floor value expression + */ + NumericExpression floor(); + + /** + * Method to return a bitwise AND expression for this expression with the supplied bit path. + * @param bitExpr Bit expression + * @return Bitwise AND expression + */ + NumericExpression bAnd(NumericExpression bitExpr); + + /** + * Method to return a bitwise OR expression for this expression with the supplied bit path. + * @param bitExpr Bit expression + * @return Bitwise OR expression + */ + NumericExpression bOr(NumericExpression bitExpr); + + /** + * Method to return a bitwise XOR expression for this expression with the supplied bit path. + * @param bitExpr Bit expression + * @return Bitwise XOR expression + */ + NumericExpression bXor(NumericExpression bitExpr); } diff --git a/api/src/main/java/javax/jdo/query/ObjectExpression.java b/api/src/main/java/javax/jdo/query/ObjectExpression.java index 414118876..2b0260545 100644 --- a/api/src/main/java/javax/jdo/query/ObjectExpression.java +++ b/api/src/main/java/javax/jdo/query/ObjectExpression.java @@ -5,21 +5,24 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; /** - * Representation of an Object as an expression. This handles all remaining Java types not handled - * by String, Numeric, Enum, Boolean, Collection, Map, etc. - * + * Representation of an Object as an expression. + * This handles all remaining Java types not handled by String, Numeric, Enum, Boolean, Collection, Map, etc. + * * @param Java type */ -public interface ObjectExpression extends Expression {} +public interface ObjectExpression extends Expression +{ + +} \ No newline at end of file diff --git a/api/src/main/java/javax/jdo/query/OptionalExpression.java b/api/src/main/java/javax/jdo/query/OptionalExpression.java index aa0f64f7f..b38b95027 100644 --- a/api/src/main/java/javax/jdo/query/OptionalExpression.java +++ b/api/src/main/java/javax/jdo/query/OptionalExpression.java @@ -5,30 +5,31 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; -/** Representation of an Optional type in a query. */ -public interface OptionalExpression extends ComparableExpression> { - /** - * Accessor for the object within the Optional. - * - * @return Expression for the object - */ - Expression get(); +/** + * Representation of an Optional type in a query. + */ +public interface OptionalExpression extends ComparableExpression> +{ + /** + * Accessor for the object within the Optional. + * @return Expression for the object + */ + Expression get(); - /** - * Accessor for whether there is an object within the Optional. - * - * @return Whether there is an expression - */ - BooleanExpression isPresent(); -} + /** + * Accessor for whether there is an object within the Optional. + * @return Whether there is an expression + */ + BooleanExpression isPresent(); +} \ No newline at end of file diff --git a/api/src/main/java/javax/jdo/query/OrderExpression.java b/api/src/main/java/javax/jdo/query/OrderExpression.java index 62a25a318..0ff15e8a7 100644 --- a/api/src/main/java/javax/jdo/query/OrderExpression.java +++ b/api/src/main/java/javax/jdo/query/OrderExpression.java @@ -5,65 +5,63 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; /** * Expression representing the ordering using an expression and a direction. - * + * * @param Java type of the expression being represented here */ -public interface OrderExpression { - public enum OrderDirection { - ASC, - DESC - } +public interface OrderExpression +{ + public enum OrderDirection + { + ASC, + DESC + } - public enum OrderNullsPosition { - FIRST, - LAST - } + public enum OrderNullsPosition + { + FIRST, + LAST + } - /** - * Accessor for the direction of the ordering with this expression. - * - * @return The direction - */ - OrderDirection getDirection(); + /** + * Accessor for the direction of the ordering with this expression. + * @return The direction + */ + OrderDirection getDirection(); - /** - * Accessor for the expression being used for ordering. - * - * @return Ordering expression - */ - Expression getExpression(); + /** + * Accessor for the expression being used for ordering. + * @return Ordering expression + */ + Expression getExpression(); - /** - * Accessor for the position of nulls with this expression. - * - * @return The nulls position (or null if not defined) - */ - OrderNullsPosition getNullsPosition(); + /** + * Accessor for the position of nulls with this expression. + * @return The nulls position (or null if not defined) + */ + OrderNullsPosition getNullsPosition(); - /** - * Method to set nulls to be ordered BEFORE non-nulls. - * - * @return The order expression - */ - OrderExpression nullsFirst(); + /** + * Method to set nulls to be ordered BEFORE non-nulls. + * @return The order expression + */ + OrderExpression nullsFirst(); - /** - * Method to set nulls to be ordered AFTER non-nulls. - * - * @return The order expression - */ - OrderExpression nullsLast(); + /** + * Method to set nulls to be ordered AFTER non-nulls. + * @return The order expression + */ + OrderExpression nullsLast(); } diff --git a/api/src/main/java/javax/jdo/query/PersistableExpression.java b/api/src/main/java/javax/jdo/query/PersistableExpression.java index 93fbfec92..6b355e3b8 100644 --- a/api/src/main/java/javax/jdo/query/PersistableExpression.java +++ b/api/src/main/java/javax/jdo/query/PersistableExpression.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; @@ -21,18 +21,17 @@ * * @param (Persistable) Java type being represented here */ -public interface PersistableExpression extends Expression { - /** - * Method to return an expression for the (JDO) identity of this persistable object. - * - * @return The identity expression - */ - Expression jdoObjectId(); +public interface PersistableExpression extends Expression +{ + /** + * Method to return an expression for the (JDO) identity of this persistable object. + * @return The identity expression + */ + Expression jdoObjectId(); - /** - * Method to return an expression for the (JDO) version of this persistable object. - * - * @return The version expression - */ - Expression jdoVersion(); -} + /** + * Method to return an expression for the (JDO) version of this persistable object. + * @return The version expression + */ + Expression jdoVersion(); +} \ No newline at end of file diff --git a/api/src/main/java/javax/jdo/query/StringExpression.java b/api/src/main/java/javax/jdo/query/StringExpression.java index 4c518740f..3ceacd212 100644 --- a/api/src/main/java/javax/jdo/query/StringExpression.java +++ b/api/src/main/java/javax/jdo/query/StringExpression.java @@ -5,260 +5,223 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; -/** Representation of a string in a query. */ -public interface StringExpression extends ComparableExpression { - /** - * Method to return an expression for this expression added to the passed expression (String - * concatenation). - * - * @param expr The other expression - * @return The summation - */ - StringExpression add(Expression expr); - - /** - * Method to return an expression for this expression added to the passed string (String - * concatenation). - * - * @param str The other string - * @return The summation - */ - StringExpression add(String str); - - /** - * Method to return an expression for the character at a position of this string expression. - * - * @param pos The position - * @return Expression for the character - */ - CharacterExpression charAt(int pos); - - /** - * Method to return an expression for the character at a position of this string expression. - * - * @param pos The position - * @return Expression for the character - */ - CharacterExpression charAt(NumericExpression pos); - - /** - * Method returning an expression for whether this string expression ends with the passed string - * expression. - * - * @param expr The expression that it ends with. - * @return Whether it ends with the other string - */ - BooleanExpression endsWith(StringExpression expr); - - /** - * Method returning an expression for whether this string expression ends with the passed string - * expression. - * - * @param str The string that it ends with. - * @return Whether it ends with the other string - */ - BooleanExpression endsWith(String str); - - /** - * Method returning an expression for whether this string expression is equal to (ignoring case) - * the passed string expression. - * - * @param expr The expression - * @return Whether they are equal - */ - BooleanExpression equalsIgnoreCase(StringExpression expr); - - /** - * Method returning an expression for whether this string expression is equal to (ignoring case) - * the passed string. - * - * @param str The string - * @return Whether they are equal - */ - BooleanExpression equalsIgnoreCase(String str); - - /** - * Method to return an expression for the position of the passed string in this string. - * - * @param expr The other string - * @return Expression for the position of the passed string - */ - NumericExpression indexOf(StringExpression expr); - - /** - * Method to return an expression for the position of the passed string in this string. - * - * @param str The other string - * @return Expression for the position of the passed string - */ - NumericExpression indexOf(String str); - - /** - * Method to return an expression for the position of the passed string in this string after a - * position. - * - * @param expr The other string - * @param pos Start point of the search - * @return Expression for the position of the passed string - */ - NumericExpression indexOf(StringExpression expr, NumericExpression pos); - - /** - * Method to return an expression for the position of the passed string in this string after a - * position. - * - * @param str The other string - * @param pos Start point of the search - * @return Expression for the position of the passed string - */ - NumericExpression indexOf(String str, NumericExpression pos); - - /** - * Method to return an expression for the position of the passed string in this string after a - * position. - * - * @param str The other string - * @param pos Start point of the search - * @return Expression for the position of the passed string - */ - NumericExpression indexOf(String str, int pos); - - /** - * Method to return an expression for the position of the passed string in this string after a - * position. - * - * @param expr The other string - * @param pos Start point of the search - * @return Expression for the position of the passed string - */ - NumericExpression indexOf(StringExpression expr, int pos); - - /** - * Method returning a expression for the length of this string. - * - * @return Expression for the length - */ - NumericExpression length(); - - /** - * Method to return an expression for whether this string expression matches the provided - * expression. - * - * @param expr The expression to match against - * @return Whether this expression matches the provided expression - */ - BooleanExpression matches(StringExpression expr); - - /** - * Method to return an expression for whether this string expression matches the provided string. - * - * @param str String literal to match against - * @return Whether this expression matches the provided string - */ - BooleanExpression matches(String str); - - /** - * Method returning an expression for whether this string expression starts with the passed string - * expression. - * - * @param expr The expression that it starts with. - * @return Whether it starts with the other string - */ - BooleanExpression startsWith(StringExpression expr); - - /** - * Method returning an expression for whether this string expression starts with the passed - * string. - * - * @param str The string that it starts with. - * @return Whether it starts with the other string - */ - BooleanExpression startsWith(String str); - - /** - * Method returning an expression for whether the substring of this string beginning at the - * specified index starts with the passed string expression. - * - * @param expr The expression that it starts with. - * @param index where to begin looking in this string - * @return Whether it starts with the other string - */ - BooleanExpression startsWith(StringExpression expr, int index); - - /** - * Method returning an expression for whether the substring of this string beginning at the - * specified index starts with the passed string. - * - * @param str The string that it starts with. - * @param index where to begin looking in this string - * @return Whether it starts with the other string - */ - BooleanExpression startsWith(String str, int index); - - /** - * Method to return an expression for the substring of this string expression. - * - * @param pos The position of the start point of the substring - * @return Expression for the substring - */ - StringExpression substring(NumericExpression pos); - - /** - * Method to return an expression for the substring of this string expression. - * - * @param pos The position of the start point of the substring - * @return Expression for the substring - */ - StringExpression substring(int pos); - - /** - * Method to return an expression for the substring of this string expression. - * - * @param startPos The position of the start point of the substring (inclusive, origin 0) - * @param endPos The position of the end point of the substring (exclusive, origin 0) - * @return Expression for the substring - */ - StringExpression substring( - NumericExpression startPos, NumericExpression endPos); - - /** - * Method to return an expression for the substring of this string expression. - * - * @param startPos The position of the start point of the substring (inclusive, origin 0) - * @param endPos The position of the end point of the substring (exclusive, origin 0) - * @return Expression for the substring - */ - StringExpression substring(int startPos, int endPos); - - /** - * Method to return a StringExpression representing this string expression in lower case. - * - * @return The lower case expression - */ - StringExpression toLowerCase(); - - /** - * Method to return a StringExpression representing this string expression in upper case. - * - * @return The upper case expression - */ - StringExpression toUpperCase(); - - /** - * Method returning a string expression with whitespace trimmed from start and end. - * - * @return String expression with whitespace trimmed - */ - StringExpression trim(); -} +/** + * Representation of a string in a query. + */ +public interface StringExpression extends ComparableExpression +{ + /** + * Method to return an expression for this expression added to the passed expression (String concatenation). + * @param expr The other expression + * @return The summation + */ + StringExpression add(Expression expr); + + /** + * Method to return an expression for this expression added to the passed string (String concatenation). + * @param str The other string + * @return The summation + */ + StringExpression add(String str); + + /** + * Method to return an expression for the character at a position of this string expression. + * @param pos The position + * @return Expression for the character + */ + CharacterExpression charAt(int pos); + + /** + * Method to return an expression for the character at a position of this string expression. + * @param pos The position + * @return Expression for the character + */ + CharacterExpression charAt(NumericExpression pos); + + /** + * Method returning an expression for whether this string expression ends with the passed string expression. + * @param expr The expression that it ends with. + * @return Whether it ends with the other string + */ + BooleanExpression endsWith(StringExpression expr); + + /** + * Method returning an expression for whether this string expression ends with the passed string expression. + * @param str The string that it ends with. + * @return Whether it ends with the other string + */ + BooleanExpression endsWith(String str); + + /** + * Method returning an expression for whether this string expression is equal to (ignoring case) the + * passed string expression. + * @param expr The expression + * @return Whether they are equal + */ + BooleanExpression equalsIgnoreCase(StringExpression expr); + + /** + * Method returning an expression for whether this string expression is equal to (ignoring case) the + * passed string. + * @param str The string + * @return Whether they are equal + */ + BooleanExpression equalsIgnoreCase(String str); + + /** + * Method to return an expression for the position of the passed string in this string. + * @param expr The other string + * @return Expression for the position of the passed string + */ + NumericExpression indexOf(StringExpression expr); + + /** + * Method to return an expression for the position of the passed string in this string. + * @param str The other string + * @return Expression for the position of the passed string + */ + NumericExpression indexOf(String str); + + /** + * Method to return an expression for the position of the passed string in this string after a position. + * @param expr The other string + * @param pos Start point of the search + * @return Expression for the position of the passed string + */ + NumericExpression indexOf(StringExpression expr, NumericExpression pos); + + /** + * Method to return an expression for the position of the passed string in this string after a position. + * @param str The other string + * @param pos Start point of the search + * @return Expression for the position of the passed string + */ + NumericExpression indexOf(String str, NumericExpression pos); + + /** + * Method to return an expression for the position of the passed string in this string after a position. + * @param str The other string + * @param pos Start point of the search + * @return Expression for the position of the passed string + */ + NumericExpression indexOf(String str, int pos); + + /** + * Method to return an expression for the position of the passed string in this string after a position. + * @param expr The other string + * @param pos Start point of the search + * @return Expression for the position of the passed string + */ + NumericExpression indexOf(StringExpression expr, int pos); + + /** + * Method returning a expression for the length of this string. + * @return Expression for the length + */ + NumericExpression length(); + + /** + * Method to return an expression for whether this string expression matches the provided expression. + * @param expr The expression to match against + * @return Whether this expression matches the provided expression + */ + BooleanExpression matches(StringExpression expr); + + /** + * Method to return an expression for whether this string expression matches the provided string. + * @param str String literal to match against + * @return Whether this expression matches the provided string + */ + BooleanExpression matches(String str); + + /** + * Method returning an expression for whether this string expression starts with the passed string expression. + * @param expr The expression that it starts with. + * @return Whether it starts with the other string + */ + BooleanExpression startsWith(StringExpression expr); + + /** + * Method returning an expression for whether this string expression starts with the passed string. + * @param str The string that it starts with. + * @return Whether it starts with the other string + */ + BooleanExpression startsWith(String str); + + /** + * Method returning an expression for whether the substring of this string beginning at the specified + * index starts with the passed string expression. + * @param expr The expression that it starts with. + * @param index where to begin looking in this string + * @return Whether it starts with the other string + */ + BooleanExpression startsWith(StringExpression expr, int index); + + /** + * Method returning an expression for whether the substring of this string beginning at the specified + * index starts with the passed string. + * @param str The string that it starts with. + * @param index where to begin looking in this string + * @return Whether it starts with the other string + */ + BooleanExpression startsWith(String str, int index); + + /** + * Method to return an expression for the substring of this string expression. + * @param pos The position of the start point of the substring + * @return Expression for the substring + */ + StringExpression substring(NumericExpression pos); + + /** + * Method to return an expression for the substring of this string expression. + * @param pos The position of the start point of the substring + * @return Expression for the substring + */ + StringExpression substring(int pos); + + /** + * Method to return an expression for the substring of this string expression. + * @param startPos The position of the start point of the substring (inclusive, origin 0) + * @param endPos The position of the end point of the substring (exclusive, origin 0) + * @return Expression for the substring + */ + StringExpression substring(NumericExpression startPos, NumericExpression endPos); + + /** + * Method to return an expression for the substring of this string expression. + * @param startPos The position of the start point of the substring (inclusive, origin 0) + * @param endPos The position of the end point of the substring (exclusive, origin 0) + * @return Expression for the substring + */ + StringExpression substring(int startPos, int endPos); + + /** + * Method to return a StringExpression representing this string expression in lower case. + * @return The lower case expression + */ + StringExpression toLowerCase(); + + /** + * Method to return a StringExpression representing this string expression in upper case. + * @return The upper case expression + */ + StringExpression toUpperCase(); + + /** + * Method returning a string expression with whitespace trimmed from start and end. + * @return String expression with whitespace trimmed + */ + StringExpression trim(); +} \ No newline at end of file diff --git a/api/src/main/java/javax/jdo/query/SubqueryExpression.java b/api/src/main/java/javax/jdo/query/SubqueryExpression.java index e707bd417..11ba6df05 100644 --- a/api/src/main/java/javax/jdo/query/SubqueryExpression.java +++ b/api/src/main/java/javax/jdo/query/SubqueryExpression.java @@ -5,16 +5,21 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; -/** Representation of a subquery in a query. */ -public interface SubqueryExpression {} +/** + * Representation of a subquery in a query. + */ +public interface SubqueryExpression +{ + +} \ No newline at end of file diff --git a/api/src/main/java/javax/jdo/query/TimeExpression.java b/api/src/main/java/javax/jdo/query/TimeExpression.java index 297214b77..283b44544 100644 --- a/api/src/main/java/javax/jdo/query/TimeExpression.java +++ b/api/src/main/java/javax/jdo/query/TimeExpression.java @@ -5,37 +5,37 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.query; -/** Representation of a time in a query. */ -public interface TimeExpression extends ComparableExpression { - /** - * Accessor for the hour of this time. - * - * @return Expression for the hour - */ - NumericExpression getHour(); +/** + * Representation of a time in a query. + */ +public interface TimeExpression extends ComparableExpression +{ + /** + * Accessor for the hour of this time. + * @return Expression for the hour + */ + NumericExpression getHour(); - /** - * Accessor for the minute of this time. - * - * @return Expression for the minute - */ - NumericExpression getMinute(); + /** + * Accessor for the minute of this time. + * @return Expression for the minute + */ + NumericExpression getMinute(); - /** - * Accessor for the second of this time. - * - * @return Expression for the second - */ - NumericExpression getSecond(); -} + /** + * Accessor for the second of this time. + * @return Expression for the second + */ + NumericExpression getSecond(); +} \ No newline at end of file diff --git a/api/src/main/java/javax/jdo/spi/Detachable.java b/api/src/main/java/javax/jdo/spi/Detachable.java index 749838c9e..e320473dc 100644 --- a/api/src/main/java/javax/jdo/spi/Detachable.java +++ b/api/src/main/java/javax/jdo/spi/Detachable.java @@ -5,45 +5,43 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.spi; /** - * This interface is implemented by classes that can be detached from the persistence context and - * later attached. The interface includes the contract by which the StateManager can set the object - * id, version, BitSet of loaded fields, and BitSet of modified fields so they are preserved while - * outside the persistence environment. - * - *

    The detached state is stored as a field in each instance of Detachable. The field is - * serialized so as to maintain the state of the instance while detached. While detached, only the - * BitSet of modified fields will be modified. The structure of the Object[] jdoDetachedState is as - * follows: - * - *

      - *
    • jdoDetachedState[0]: the Object Id of the instance - *
    • jdoDetachedState[1]: the Version of the instance - *
    • jdoDetachedState[2]: a BitSet of loaded fields - *
    • jdoDetachedState[3]: a BitSet of modified fields - *
    - * + * This interface is implemented by classes that can be detached from the + * persistence context and later attached. The interface includes the + * contract by which the StateManager can set the object id, version, + * BitSet of loaded fields, and BitSet of modified fields + * so they are preserved while outside the persistence environment. + *

    The detached state is stored as a field in each instance of Detachable. + * The field is serialized so as to maintain the state of the instance + * while detached. While detached, only the BitSet of modified fields + * will be modified. The structure of the Object[] jdoDetachedState + * is as follows: + *

    • jdoDetachedState[0]: the Object Id of the instance + *
    • jdoDetachedState[1]: the Version of the instance + *
    • jdoDetachedState[2]: a BitSet of loaded fields + *
    • jdoDetachedState[3]: a BitSet of modified fields + *
    * @version 2.0 */ + public interface Detachable { - /** - * This method calls the StateManager with the current detached state instance as a parameter and - * replaces the current detached state instance with the value provided by the StateManager. - * - * @since 2.0 - */ - public void jdoReplaceDetachedState(); + /** This method calls the StateManager with the current detached + * state instance as a parameter and replaces the current detached + * state instance with the value provided by the StateManager. + * @since 2.0 + */ + public void jdoReplaceDetachedState(); } diff --git a/api/src/main/java/javax/jdo/spi/I18NHelper.java b/api/src/main/java/javax/jdo/spi/I18NHelper.java index 26d29534f..331a7b120 100644 --- a/api/src/main/java/javax/jdo/spi/I18NHelper.java +++ b/api/src/main/java/javax/jdo/spi/I18NHelper.java @@ -5,413 +5,409 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.spi; import java.lang.reflect.InvocationTargetException; -import java.security.PrivilegedAction; +import java.util.*; import java.text.MessageFormat; -import java.util.Hashtable; -import java.util.Locale; -import java.util.ResourceBundle; -import javax.jdo.JDOFatalInternalException; import javax.jdo.LegacyJava; +import java.security.PrivilegedAction; -/** - * Helper class for constructing messages from bundles. The intended usage of this class is to - * construct a new instance bound to a bundle, as in - * - *

    I18NHelper msg = I18NHelper.getInstance("javax.jdo.Bundle"); - * - *

    This call uses the class loader that loaded the I18NHelper class to find the specified Bundle. - * The class provides two overloaded getInstance methods allowing to specify a different class - * loader: {@link #getInstance(Class cls)} looks for a bundle called "Bundle.properties" located in - * the package of the specified class object and {@link #getInstance(String bundleName,ClassLoader - * loader)} uses the specified class loader to find the bundle. - * - *

    Subsequently, instance methods can be used to format message strings using the text from the - * bundle, as in - * - *

    throw new JDOFatalInternalException (msg.msg("ERR_NoMetadata", +import javax.jdo.JDOFatalInternalException; + +/** Helper class for constructing messages from bundles. The intended usage + * of this class is to construct a new instance bound to a bundle, as in + *

    + * I18NHelper msg = I18NHelper.getInstance("javax.jdo.Bundle"); + *

    + * This call uses the class loader that loaded the I18NHelper class to find + * the specified Bundle. The class provides two overloaded getInstance + * methods allowing to specify a different class loader: + * {@link #getInstance(Class cls)} looks for a bundle + * called "Bundle.properties" located in the package of the specified class + * object and {@link #getInstance(String bundleName,ClassLoader loader)} + * uses the specified class loader to find the bundle. + *

    + * Subsequently, instance methods can be used to format message strings + * using the text from the bundle, as in + *

    + * throw new JDOFatalInternalException (msg.msg("ERR_NoMetadata", * cls.getName())); - * * @since 1.0.1 * @version 1.1 - */ + */ public class I18NHelper { - /** Bundles that have already been loaded */ - private static Hashtable bundles = - new Hashtable(); - - /** Helper instances that have already been created */ - private static Hashtable helpers = new Hashtable(); - - /** The default locale for this VM. */ - private static Locale locale = Locale.getDefault(); - - /** The bundle used by this instance of the helper. */ - private ResourceBundle bundle = null; - - /** Throwable if ResourceBundle couldn't be loaded */ - private Throwable failure = null; - - /** The unqualified standard name of a bundle. */ - private static final String bundleSuffix = ".Bundle"; // NOI18N - - /** Constructor */ - private I18NHelper() {} - - /** - * Constructor for an instance bound to a bundle. - * - * @param bundleName the name of the resource bundle - * @param loader the class loader from which to load the resource bundle - */ - private I18NHelper(String bundleName, ClassLoader loader) { - try { - bundle = loadBundle(bundleName, loader); - } catch (Throwable e) { - failure = e; + /** Bundles that have already been loaded + */ + private static Hashtable + bundles = new Hashtable(); + + /** Helper instances that have already been created + */ + private static Hashtable + helpers = new Hashtable(); + + /** The default locale for this VM. + */ + private static Locale locale = Locale.getDefault(); + + /** The bundle used by this instance of the helper. + */ + private ResourceBundle bundle = null; + + /** Throwable if ResourceBundle couldn't be loaded + */ + private Throwable failure = null; + + /** The unqualified standard name of a bundle. */ + private static final String bundleSuffix = ".Bundle"; // NOI18N + + /** Constructor */ + private I18NHelper() { } - } - /** - * An instance bound to a bundle. This method uses the current class loader to find the bundle. - * - * @param bundleName the name of the bundle - * @return the helper instance bound to the bundle - */ - public static I18NHelper getInstance(String bundleName) { - return getInstance(bundleName, I18NHelper.class.getClassLoader()); - } - - /** - * An instance bound to a bundle. This method figures out the bundle name for the class object's - * package and uses the class' class loader to find the bundle. Note, the specified class object - * must not be null. - * - * @param cls the class object from which to load the resource bundle - * @return the helper instance bound to the bundle - */ - public static I18NHelper getInstance(final Class cls) { - ClassLoader classLoader = - doPrivileged( - new PrivilegedAction() { - public ClassLoader run() { - return cls.getClassLoader(); - } - }); - String bundle = getPackageName(cls.getName()) + bundleSuffix; - return getInstance(bundle, classLoader); - } - - /** - * An instance bound to a bundle. This method uses the specified class loader to find the bundle. - * Note, the specified class loader must not be null. - * - * @param bundleName the name of the bundle - * @param loader the class loader from which to load the resource bundle - * @return the helper instance bound to the bundle - */ - public static I18NHelper getInstance(String bundleName, ClassLoader loader) { - I18NHelper helper = (I18NHelper) helpers.get(bundleName); - if (helper != null) { - return helper; + /** Constructor for an instance bound to a bundle. + * @param bundleName the name of the resource bundle + * @param loader the class loader from which to load the resource + * bundle + */ + private I18NHelper (String bundleName, ClassLoader loader) { + try { + bundle = loadBundle (bundleName, loader); + } + catch (Throwable e) { + failure = e; + } + } + + /** An instance bound to a bundle. This method uses the current class + * loader to find the bundle. + * @param bundleName the name of the bundle + * @return the helper instance bound to the bundle + */ + public static I18NHelper getInstance (String bundleName) { + return getInstance (bundleName, I18NHelper.class.getClassLoader()); } - helper = new I18NHelper(bundleName, loader); - helpers.put(bundleName, helper); - // if two threads simultaneously create the same helper, return the first - // one to be put into the Hashtable. The other will be garbage collected. - return (I18NHelper) helpers.get(bundleName); - } - - /** - * Message formatter - * - * @param messageKey the message key - * @return the resolved message text - */ - public String msg(String messageKey) { - assertBundle(messageKey); - return getMessage(bundle, messageKey); - } - /** - * Message formatter - * - * @param messageKey the message key - * @param arg1 the first argument - * @return the resolved message text - */ - public String msg(String messageKey, Object arg1) { - assertBundle(messageKey); - return getMessage(bundle, messageKey, arg1); - } + /** An instance bound to a bundle. This method figures out the bundle name + * for the class object's package and uses the class' class loader to + * find the bundle. Note, the specified class object must not be + * null. + * @param cls the class object from which to load the resource bundle + * @return the helper instance bound to the bundle + */ + public static I18NHelper getInstance (final Class cls) { + ClassLoader classLoader = doPrivileged ( + new PrivilegedAction () { + public ClassLoader run () { + return cls.getClassLoader(); + } + } + ); + String bundle = getPackageName (cls.getName()) + bundleSuffix; + return getInstance (bundle, classLoader); + } - /** - * Message formatter - * - * @param messageKey the message key - * @param arg1 the first argument - * @param arg2 the second argument - * @return the resolved message text - */ - public String msg(String messageKey, Object arg1, Object arg2) { - assertBundle(messageKey); - return getMessage(bundle, messageKey, arg1, arg2); - } + /** An instance bound to a bundle. This method uses the specified class + * loader to find the bundle. Note, the specified class loader must not + * be null. + * @param bundleName the name of the bundle + * @param loader the class loader from which to load the resource + * bundle + * @return the helper instance bound to the bundle + */ + public static I18NHelper getInstance (String bundleName, + ClassLoader loader) { + I18NHelper helper = (I18NHelper) helpers.get (bundleName); + if (helper != null) { + return helper; + } + helper = new I18NHelper(bundleName, loader); + helpers.put (bundleName, helper); + // if two threads simultaneously create the same helper, return the first + // one to be put into the Hashtable. The other will be garbage collected. + return (I18NHelper) helpers.get (bundleName); + } - /** - * Message formatter - * - * @param messageKey the message key - * @param arg1 the first argument - * @param arg2 the second argument - * @param arg3 the third argument - * @return the resolved message text - */ - public String msg(String messageKey, Object arg1, Object arg2, Object arg3) { - assertBundle(messageKey); - return getMessage(bundle, messageKey, arg1, arg2, arg3); - } + /** Message formatter + * @param messageKey the message key + * @return the resolved message text + */ + public String msg (String messageKey) { + assertBundle (messageKey); + return getMessage (bundle, messageKey); + } - /** - * Message formatter - * - * @param messageKey the message key - * @param args the array of arguments - * @return the resolved message text - */ - public String msg(String messageKey, Object[] args) { - assertBundle(messageKey); - return getMessage(bundle, messageKey, args); - } + /** Message formatter + * @param messageKey the message key + * @param arg1 the first argument + * @return the resolved message text + */ + public String msg (String messageKey, Object arg1) { + assertBundle (messageKey); + return getMessage (bundle, messageKey, arg1); + } - /** - * Message formatter - * - * @param messageKey the message key - * @param arg the argument - * @return the resolved message text - */ - public String msg(String messageKey, int arg) { - assertBundle(messageKey); - return getMessage(bundle, messageKey, arg); - } + /** Message formatter + * @param messageKey the message key + * @param arg1 the first argument + * @param arg2 the second argument + * @return the resolved message text + */ + public String msg (String messageKey, Object arg1, Object arg2) { + assertBundle (messageKey); + return getMessage (bundle, messageKey, arg1, arg2); + } - /** - * Message formatter - * - * @param messageKey the message key - * @param arg the argument - * @return the resolved message text - */ - public String msg(String messageKey, boolean arg) { - assertBundle(messageKey); - return getMessage(bundle, messageKey, arg); - } + /** Message formatter + * @param messageKey the message key + * @param arg1 the first argument + * @param arg2 the second argument + * @param arg3 the third argument + * @return the resolved message text + */ + public String msg (String messageKey, Object arg1, Object arg2, Object arg3) { + assertBundle (messageKey); + return getMessage (bundle, messageKey, arg1, arg2, arg3); + } - /** - * Returns the resource bundle used by this I18NHelper. - * - * @return the associated resource bundle - * @since 1.1 - */ - public ResourceBundle getResourceBundle() { - assertBundle(); - return bundle; - } + /** Message formatter + * @param messageKey the message key + * @param args the array of arguments + * @return the resolved message text + */ + public String msg (String messageKey, Object[] args) { + assertBundle (messageKey); + return getMessage (bundle, messageKey, args); + } - // ========= Internal helper methods ========== + /** Message formatter + * @param messageKey the message key + * @param arg the argument + * @return the resolved message text + */ + public String msg (String messageKey, int arg) { + assertBundle (messageKey); + return getMessage(bundle, messageKey, arg); + } + + /** Message formatter + * @param messageKey the message key + * @param arg the argument + * @return the resolved message text + */ + public String msg (String messageKey, boolean arg) { + assertBundle (messageKey); + return getMessage(bundle, messageKey, arg); + } + + /** Returns the resource bundle used by this I18NHelper. + * @return the associated resource bundle + * @since 1.1 + */ + public ResourceBundle getResourceBundle () { + assertBundle (); + return bundle; + } + + //========= Internal helper methods ========== + + /** + * Load ResourceBundle by bundle name + * @param bundleName the name of the bundle + * @param loader the class loader from which to load the resource bundle + * @return the ResourceBundle + */ + final private static ResourceBundle loadBundle( + String bundleName, ClassLoader loader) { + ResourceBundle messages = (ResourceBundle)bundles.get(bundleName); + + if (messages == null) //not found as loaded - add + { + if (loader != null) { + messages = ResourceBundle.getBundle(bundleName, locale, loader); + } else { + // the JDO library is loaded by the boostrap class loader + messages = ResourceBundle.getBundle(bundleName, locale, + getSystemClassLoaderPrivileged()); + } + bundles.put(bundleName, messages); + } + return messages; + } - /** - * Load ResourceBundle by bundle name - * - * @param bundleName the name of the bundle - * @param loader the class loader from which to load the resource bundle - * @return the ResourceBundle - */ - private static final ResourceBundle loadBundle(String bundleName, ClassLoader loader) { - ResourceBundle messages = (ResourceBundle) bundles.get(bundleName); + /** Assert resources available + * @since 1.1 + * @throws JDOFatalInternalException if the resource bundle could not + * be loaded during construction. + */ + private void assertBundle () { + if (failure != null) + throw new JDOFatalInternalException ( + "No resources could be found for bundle:\"" + + bundle + "\" ", failure); + } + + /** Assert resources available + * @param key the message key + * @since 1.0.2 + * @throws JDOFatalInternalException if the resource bundle could not + * be loaded during construction. + */ + private void assertBundle (String key) { + if (failure != null) + throw new JDOFatalInternalException ( + "No resources could be found to annotate error message key:\"" + + key + "\"", failure); + } - if (messages == null) // not found as loaded - add + /** + * Returns message as String + * @param messages the resource bundle + * @param messageKey the message key + * @return the resolved message text + */ + final private static String getMessage(ResourceBundle messages, String messageKey) { - if (loader != null) { - messages = ResourceBundle.getBundle(bundleName, locale, loader); - } else { - // the JDO library is loaded by the boostrap class loader - messages = ResourceBundle.getBundle(bundleName, locale, getSystemClassLoaderPrivileged()); - } - bundles.put(bundleName, messages); + return messages.getString(messageKey); } - return messages; - } - - /** - * Assert resources available - * - * @since 1.1 - * @throws JDOFatalInternalException if the resource bundle could not be loaded during - * construction. - */ - private void assertBundle() { - if (failure != null) - throw new JDOFatalInternalException( - "No resources could be found for bundle:\"" + bundle + "\" ", failure); - } - - /** - * Assert resources available - * - * @param key the message key - * @since 1.0.2 - * @throws JDOFatalInternalException if the resource bundle could not be loaded during - * construction. - */ - private void assertBundle(String key) { - if (failure != null) - throw new JDOFatalInternalException( - "No resources could be found to annotate error message key:\"" + key + "\"", failure); - } - /** - * Returns message as String - * - * @param messages the resource bundle - * @param messageKey the message key - * @return the resolved message text - */ - private static final String getMessage(ResourceBundle messages, String messageKey) { - return messages.getString(messageKey); - } - - /** - * Formats message by adding array of arguments - * - * @param messages the resource bundle - * @param messageKey the message key - * @param msgArgs an array of arguments to substitute into the message - * @return the resolved message text - */ - private static final String getMessage( - ResourceBundle messages, String messageKey, Object[] msgArgs) { - for (int i = 0; i < msgArgs.length; i++) { - if (msgArgs[i] == null) msgArgs[i] = ""; // NOI18N + /** + * Formats message by adding array of arguments + * @param messages the resource bundle + * @param messageKey the message key + * @param msgArgs an array of arguments to substitute into the message + * @return the resolved message text + */ + final private static String getMessage(ResourceBundle messages, + String messageKey, Object[] msgArgs) + { + for (int i=0; iObject argument. + * @param messages the resource bundle + * @param messageKey the message key + * @param arg the argument + * @return the resolved message text + */ + final private static String getMessage(ResourceBundle messages, + String messageKey, Object arg) + { + Object []args = {arg}; + return getMessage(messages, messageKey, args); + } + + /** + * Formats message by adding two Object arguments. + * @param messages the resource bundle + * @param messageKey the message key + * @param arg1 the first argument + * @param arg2 the second argument + * @return the resolved message text + */ + final private static String getMessage(ResourceBundle messages, + String messageKey, Object arg1, Object arg2) + { + Object []args = {arg1, arg2}; + return getMessage(messages, messageKey, args); + } + + /** + * Formats message by adding three Object arguments. + * @param messages the resource bundle + * @param messageKey the message key + * @param arg1 the first argument + * @param arg2 the second argument + * @param arg3 the third argument + * @return the resolved message text + */ + final private static String getMessage(ResourceBundle messages, + String messageKey, Object arg1, Object arg2, Object arg3) + { + Object []args = {arg1, arg2, arg3}; + return getMessage(messages, messageKey, args); } - MessageFormat formatter = new MessageFormat(messages.getString(messageKey)); - return formatter.format(msgArgs); - } - - /** - * Formats message by adding an Object argument. - * - * @param messages the resource bundle - * @param messageKey the message key - * @param arg the argument - * @return the resolved message text - */ - private static final String getMessage(ResourceBundle messages, String messageKey, Object arg) { - Object[] args = {arg}; - return getMessage(messages, messageKey, args); - } - - /** - * Formats message by adding two Object arguments. - * - * @param messages the resource bundle - * @param messageKey the message key - * @param arg1 the first argument - * @param arg2 the second argument - * @return the resolved message text - */ - private static final String getMessage( - ResourceBundle messages, String messageKey, Object arg1, Object arg2) { - Object[] args = {arg1, arg2}; - return getMessage(messages, messageKey, args); - } - - /** - * Formats message by adding three Object arguments. - * - * @param messages the resource bundle - * @param messageKey the message key - * @param arg1 the first argument - * @param arg2 the second argument - * @param arg3 the third argument - * @return the resolved message text - */ - private static final String getMessage( - ResourceBundle messages, String messageKey, Object arg1, Object arg2, Object arg3) { - Object[] args = {arg1, arg2, arg3}; - return getMessage(messages, messageKey, args); - } - - /** - * Formats message by adding an int as an argument. - * - * @param messages the resource bundle - * @param messageKey the message key - * @param arg the argument - * @return the resolved message text - */ - private static final String getMessage(ResourceBundle messages, String messageKey, int arg) { - Object[] args = {Integer.valueOf(arg)}; - return getMessage(messages, messageKey, args); - } - /** - * Formats message by adding a boolean as an argument. - * - * @param messages the resource bundle - * @param messageKey the message key - * @param arg the argument - * @return the resolved message text - */ - private static final String getMessage(ResourceBundle messages, String messageKey, boolean arg) { - Object[] args = {String.valueOf(arg)}; - return getMessage(messages, messageKey, args); - } + /** + * Formats message by adding an int as an argument. + * @param messages the resource bundle + * @param messageKey the message key + * @param arg the argument + * @return the resolved message text + */ + final private static String getMessage(ResourceBundle messages, + String messageKey, int arg) + { + Object []args = {Integer.valueOf(arg)}; + return getMessage(messages, messageKey, args); + } + + /** + * Formats message by adding a boolean as an argument. + * @param messages the resource bundle + * @param messageKey the message key + * @param arg the argument + * @return the resolved message text + */ + final private static String getMessage(ResourceBundle messages, + String messageKey, boolean arg) + { + Object []args = {String.valueOf(arg)}; + return getMessage(messages, messageKey, args); + } - /** - * Returns the package portion of the specified class. - * - * @param className the name of the class from which to extract the package - * @return package portion of the specified class - */ - private static final String getPackageName(final String className) { - final int index = className.lastIndexOf('.'); - return ((index != -1) ? className.substring(0, index) : ""); // NOI18N - } + /** + * Returns the package portion of the specified class. + * @param className the name of the class from which to extract the + * package + * @return package portion of the specified class + */ + final private static String getPackageName(final String className) + { + final int index = className.lastIndexOf('.'); + return ((index != -1) ? className.substring(0, index) : ""); // NOI18N + } - /** Get the system class loader. This must be done in a doPrivileged block because of security. */ - private static ClassLoader getSystemClassLoaderPrivileged() { - return doPrivileged( - new PrivilegedAction() { - public ClassLoader run() { - return ClassLoader.getSystemClassLoader(); - } - }); - } + /** + * Get the system class loader. This must be done in a doPrivileged + * block because of security. + */ + private static ClassLoader getSystemClassLoaderPrivileged() { + return doPrivileged ( + new PrivilegedAction () { + public ClassLoader run () { + return ClassLoader.getSystemClassLoader(); + } + } + ); + } - @SuppressWarnings("unchecked") - private static T doPrivileged(PrivilegedAction privilegedAction) { - try { - return (T) LegacyJava.doPrivilegedAction.invoke(null, privilegedAction); - } catch (IllegalAccessException | InvocationTargetException e) { - if (e.getCause() instanceof RuntimeException) { - throw (RuntimeException) e.getCause(); - } - throw new JDOFatalInternalException(e.getMessage()); + @SuppressWarnings("unchecked") + private static T doPrivileged(PrivilegedAction privilegedAction) { + try { + return (T) LegacyJava.doPrivilegedAction.invoke(null, privilegedAction); + } catch (IllegalAccessException | InvocationTargetException e) { + if (e.getCause() instanceof RuntimeException) { + throw (RuntimeException) e.getCause(); + } + throw new JDOFatalInternalException(e.getMessage()); + } } - } } diff --git a/api/src/main/java/javax/jdo/spi/JDOImplHelper.java b/api/src/main/java/javax/jdo/spi/JDOImplHelper.java index e2cf5bde6..99bc1644d 100644 --- a/api/src/main/java/javax/jdo/spi/JDOImplHelper.java +++ b/api/src/main/java/javax/jdo/spi/JDOImplHelper.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -22,12 +22,20 @@ package javax.jdo.spi; +import org.xml.sax.ErrorHandler; + +import javax.jdo.LegacyJava; +import javax.jdo.LegacyJava.SecurityManager; + import java.lang.reflect.Constructor; + import java.lang.reflect.InvocationTargetException; import java.security.PrivilegedAction; + import java.text.DateFormat; import java.text.ParsePosition; import java.text.SimpleDateFormat; + import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -41,1173 +49,1159 @@ import java.util.Map; import java.util.Set; import java.util.WeakHashMap; -import javax.jdo.Constants; -import javax.jdo.JDOException; -import javax.jdo.JDOFatalInternalException; -import javax.jdo.JDOFatalUserException; -import javax.jdo.JDOUserException; -import javax.jdo.LegacyJava; -import javax.jdo.LegacyJava.SecurityManager; + +import javax.jdo.*; import javax.xml.parsers.DocumentBuilderFactory; -import org.xml.sax.ErrorHandler; -/** - * This class is a helper class for JDO implementations. It contains methods to register metadata - * for persistence-capable classes and to perform common operations needed by implementations, not - * by end users. - * - *

    JDOImplHelper allows construction of instances of persistence-capable classes - * without using reflection. - * - *

    Persistence-capable classes register themselves via a static method at class load time. There - * is no security restriction on this access. JDO implementations get access to the functions - * provided by this class only if they are authorized by the security manager. To avoid having every - * call go through the security manager, only the call to get an instance is checked. Once an - * implementation has an instance, any of the methods can be invoked without security checks. - * +/** This class is a helper class for JDO implementations. It contains methods + * to register metadata for persistence-capable classes and to perform common + * operations needed by implementations, not by end users. + *

    JDOImplHelper allows construction of instances of + * persistence-capable classes without using reflection. + *

    Persistence-capable classes register themselves via a static method + * at class load time. + * There is no security restriction on this access. JDO implementations + * get access to the functions provided by this class only if they are + * authorized by the security manager. To avoid having every call go through + * the security manager, only the call to get an instance is checked. Once an + * implementation + * has an instance, any of the methods can be invoked without security checks. * @version 2.1 + * */ public class JDOImplHelper extends java.lang.Object { + + /** This synchronized HashMap contains a static mapping of + * PersistenceCapable class to + * metadata for the class used for constructing new instances. New entries + * are added by the static method in each PersistenceCapable + * class. Entries are never removed. + */ + private static Map registeredClasses = + Collections.synchronizedMap(new HashMap ()); + + /** This Set contains all classes that have registered for setStateManager + * permissions via authorizeStateManagerClass. + * Only the key is used in order to maintain a weak set of classes. + */ + private static final Map + authorizedStateManagerClasses = new WeakHashMap(); - /** - * This synchronized HashMap contains a static mapping of PersistenceCapable - * class to metadata for the class used for constructing new instances. New entries are - * added by the static method in each PersistenceCapable class. Entries are never - * removed. - */ - private static Map registeredClasses = - Collections.synchronizedMap(new HashMap()); - - /** - * This Set contains all classes that have registered for setStateManager permissions via - * authorizeStateManagerClass. Only the key is used in order to maintain a weak set of classes. - */ - private static final Map authorizedStateManagerClasses = - new WeakHashMap(); - - /** This list contains the registered listeners for RegisterClassEvents. */ - private static final List listeners = - new ArrayList(); - - /** The list of registered StateInterrogation instances */ - private static List stateInterrogations = new ArrayList(); - - /** The singleton JDOImplHelper instance. */ - private static JDOImplHelper jdoImplHelper = new JDOImplHelper(); - - /** The Internationalization message helper. */ - private static final I18NHelper msg = I18NHelper.getInstance("javax.jdo.Bundle"); // NOI18N - - /** The DateFormat pattern. */ - private static String dateFormatPattern; - - /** The default DateFormat instance. */ - private static DateFormat dateFormat; - - /** The DocumentBuilderFactory used during jdoconfig.xml parsing. */ - private static DocumentBuilderFactory documentBuilderFactory; - - /** The ErrorHandler used during jdoconfig.xml parsing. */ - private static ErrorHandler errorHandler; - - /** JDO standard properties that the user can configure. */ - public static final Set USER_CONFIGURABLE_STANDARD_PROPERTIES = - createUserConfigurableStandardProperties(); - - private static Set createUserConfigurableStandardProperties() { - Set props = new HashSet(); - - props.add(Constants.PROPERTY_CONNECTION_DRIVER_NAME); - props.add(Constants.PROPERTY_CONNECTION_FACTORY2_NAME); - props.add(Constants.PROPERTY_CONNECTION_FACTORY_NAME); - props.add(Constants.PROPERTY_CONNECTION_PASSWORD); - props.add(Constants.PROPERTY_CONNECTION_URL); - props.add(Constants.PROPERTY_CONNECTION_USER_NAME); - props.add(Constants.PROPERTY_COPY_ON_ATTACH); - props.add(Constants.PROPERTY_DATASTORE_READ_TIMEOUT_MILLIS); - props.add(Constants.PROPERTY_DATASTORE_WRITE_TIMEOUT_MILLIS); - props.add(Constants.PROPERTY_DETACH_ALL_ON_COMMIT); - props.add(Constants.PROPERTY_IGNORE_CACHE); - props.add(Constants.PROPERTY_INSTANCE_LIFECYCLE_LISTENER); - props.add(Constants.PROPERTY_MAPPING); - props.add(Constants.PROPERTY_MAPPING_CATALOG); - props.add(Constants.PROPERTY_MAPPING_SCHEMA); - props.add(Constants.PROPERTY_MULTITHREADED); - props.add(Constants.PROPERTY_NAME); - props.add(Constants.PROPERTY_NONTRANSACTIONAL_READ); - props.add(Constants.PROPERTY_NONTRANSACTIONAL_WRITE); - props.add(Constants.PROPERTY_OPTIMISTIC); - props.add(Constants.PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS); - props.add(Constants.PROPERTY_PERSISTENCE_UNIT_NAME); - props.add(Constants.PROPERTY_READONLY); - props.add(Constants.PROPERTY_RESTORE_VALUES); - props.add(Constants.PROPERTY_RETAIN_VALUES); - props.add(Constants.PROPERTY_SERVER_TIME_ZONE_ID); - props.add(Constants.PROPERTY_SPI_RESOURCE_NAME); - props.add(Constants.PROPERTY_TRANSACTION_ISOLATION_LEVEL); - props.add(Constants.PROPERTY_TRANSACTION_TYPE); - - return Collections.unmodifiableSet(props); - } - - static final String JAVAX_JDO_PREFIX_LOWER_CASED = Constants.JAVAX_JDO_PREFIX.toLowerCase(); + /** This list contains the registered listeners for + * RegisterClassEvents. + */ + private static final List + listeners = new ArrayList(); + + /** The list of registered StateInterrogation instances + */ + private static List + stateInterrogations = new ArrayList(); + + /** The singleton JDOImplHelper instance. + */ + private static JDOImplHelper jdoImplHelper = new JDOImplHelper(); + + /** The Internationalization message helper. + */ + private final static I18NHelper msg = + I18NHelper.getInstance ("javax.jdo.Bundle"); //NOI18N + + /** The DateFormat pattern. + */ + private static String dateFormatPattern; - static final String PROPERTY_PREFIX_INSTANCE_LIFECYCLE_LISTENER_LOWER_CASED = - Constants.PROPERTY_PREFIX_INSTANCE_LIFECYCLE_LISTENER.toLowerCase(); + /** The default DateFormat instance. + */ + private static DateFormat dateFormat; - static final Set USER_CONFIGURABLE_STANDARD_PROPERTIES_LOWER_CASED = - createUserConfigurableStandardPropertiesLowerCased(); + /** + * The DocumentBuilderFactory used during jdoconfig.xml parsing. + */ + private static DocumentBuilderFactory documentBuilderFactory; - static Set createUserConfigurableStandardPropertiesLowerCased() { - Set mixedCased = createUserConfigurableStandardProperties(); - Set lowerCased = new HashSet(mixedCased.size()); + /** + * The ErrorHandler used during jdoconfig.xml parsing. + */ + private static ErrorHandler errorHandler; - for (String propertyName : mixedCased) { - lowerCased.add(propertyName.toLowerCase()); + /** + * JDO standard properties that the user can configure. + */ + public static final Set USER_CONFIGURABLE_STANDARD_PROPERTIES = createUserConfigurableStandardProperties(); + + private static Set createUserConfigurableStandardProperties() { + Set props = new HashSet(); + + props.add(Constants.PROPERTY_CONNECTION_DRIVER_NAME); + props.add(Constants.PROPERTY_CONNECTION_FACTORY2_NAME); + props.add(Constants.PROPERTY_CONNECTION_FACTORY_NAME); + props.add(Constants.PROPERTY_CONNECTION_PASSWORD); + props.add(Constants.PROPERTY_CONNECTION_URL); + props.add(Constants.PROPERTY_CONNECTION_USER_NAME); + props.add(Constants.PROPERTY_COPY_ON_ATTACH); + props.add(Constants.PROPERTY_DATASTORE_READ_TIMEOUT_MILLIS); + props.add(Constants.PROPERTY_DATASTORE_WRITE_TIMEOUT_MILLIS); + props.add(Constants.PROPERTY_DETACH_ALL_ON_COMMIT); + props.add(Constants.PROPERTY_IGNORE_CACHE); + props.add(Constants.PROPERTY_INSTANCE_LIFECYCLE_LISTENER); + props.add(Constants.PROPERTY_MAPPING); + props.add(Constants.PROPERTY_MAPPING_CATALOG); + props.add(Constants.PROPERTY_MAPPING_SCHEMA); + props.add(Constants.PROPERTY_MULTITHREADED); + props.add(Constants.PROPERTY_NAME); + props.add(Constants.PROPERTY_NONTRANSACTIONAL_READ); + props.add(Constants.PROPERTY_NONTRANSACTIONAL_WRITE); + props.add(Constants.PROPERTY_OPTIMISTIC); + props.add(Constants.PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS); + props.add(Constants.PROPERTY_PERSISTENCE_UNIT_NAME); + props.add(Constants.PROPERTY_READONLY); + props.add(Constants.PROPERTY_RESTORE_VALUES); + props.add(Constants.PROPERTY_RETAIN_VALUES); + props.add(Constants.PROPERTY_SERVER_TIME_ZONE_ID); + props.add(Constants.PROPERTY_SPI_RESOURCE_NAME); + props.add(Constants.PROPERTY_TRANSACTION_ISOLATION_LEVEL); + props.add(Constants.PROPERTY_TRANSACTION_TYPE); + + return Collections.unmodifiableSet(props); } - return Collections.unmodifiableSet(lowerCased); - } - /** Register the default DateFormat instance. */ - static { - jdoImplHelper.registerDateFormat(getDateTimeInstance()); - } - - /** Creates new JDOImplHelper */ - private JDOImplHelper() {} - - /** - * Get an instance of JDOImplHelper. This method checks that the caller is authorized - * for JDOPermission("getMetadata"), and if not, throws SecurityException - * . - * - * @return an instance of JDOImplHelper. - * @throws SecurityException if the caller is not authorized for JDOPermission("getMetadata"). - */ - public static JDOImplHelper getInstance() throws SecurityException { - SecurityManager sec = LegacyJava.getSecurityManager(); - if (sec != null) { - // throws exception if caller is not authorized - sec.checkPermission(JDOPermission.GET_METADATA); + static final String JAVAX_JDO_PREFIX_LOWER_CASED = + Constants.JAVAX_JDO_PREFIX.toLowerCase(); + + static final String PROPERTY_PREFIX_INSTANCE_LIFECYCLE_LISTENER_LOWER_CASED = + Constants.PROPERTY_PREFIX_INSTANCE_LIFECYCLE_LISTENER.toLowerCase(); + + static final Set USER_CONFIGURABLE_STANDARD_PROPERTIES_LOWER_CASED = + createUserConfigurableStandardPropertiesLowerCased(); + + static Set createUserConfigurableStandardPropertiesLowerCased() { + Set mixedCased = createUserConfigurableStandardProperties(); + Set lowerCased = + new HashSet(mixedCased.size()); + + for (String propertyName : mixedCased) { + lowerCased.add(propertyName.toLowerCase()); + } + return Collections.unmodifiableSet(lowerCased); } - return jdoImplHelper; - } - - /** - * Get the field names for a PersistenceCapable class. The order of fields is the - * natural ordering of the String class (without considering localization). - * - * @param pcClass the PersistenceCapable class. - * @return the field names for the class. - */ - public String[] getFieldNames(Class pcClass) { - Meta meta = getMeta(pcClass); - return meta.getFieldNames(); - } - - /** - * Get the field types for a PersistenceCapable class. The order of fields is the - * same as for field names. - * - * @param pcClass the PersistenceCapable class. - * @return the field types for the class. - */ - public Class[] getFieldTypes(Class pcClass) { - Meta meta = getMeta(pcClass); - return meta.getFieldTypes(); - } - - /** - * Get the field flags for a PersistenceCapable class. The order of fields is the - * same as for field names. - * - * @param pcClass the PersistenceCapable class. - * @return the field types for the class. - */ - public byte[] getFieldFlags(Class pcClass) { - Meta meta = getMeta(pcClass); - return meta.getFieldFlags(); - } - - /** - * Get the persistence-capable superclass for a PersistenceCapable class. - * - * @param pcClass the PersistenceCapable class. - * @return The PersistenceCapable superclass for this class, or null if - * there isn't one. - */ - public Class getPersistenceCapableSuperclass(Class pcClass) { - Meta meta = getMeta(pcClass); - return meta.getPersistenceCapableSuperclass(); - } - - /** - * Create a new instance of the class and assign its jdoStateManager. The new - * instance has its jdoFlags set to LOAD_REQUIRED. - * - * @see PersistenceCapable#jdoNewInstance(StateManager sm) - * @param pcClass the PersistenceCapable class. - * @param sm the StateManager which will own the new instance. - * @return the new instance, or null if the class is not registered. - */ - public PersistenceCapable newInstance(Class pcClass, StateManager sm) { - Meta meta = getMeta(pcClass); - PersistenceCapable pcInstance = meta.getPC(); - return pcInstance == null ? null : pcInstance.jdoNewInstance(sm); - } - - /** - * Create a new instance of the class and assign its jdoStateManager and key values - * from the ObjectId. If the oid parameter is null, no key values are copied. The new - * instance has its jdoFlags set to LOAD_REQUIRED. - * - * @see PersistenceCapable#jdoNewInstance(StateManager sm, Object oid) - * @param pcClass the PersistenceCapable class. - * @param sm the StateManager which will own the new instance. - * @return the new instance, or null if the class is not registered. - * @param oid the ObjectId instance from which to copy key field values. - */ - public PersistenceCapable newInstance(Class pcClass, StateManager sm, Object oid) { - Meta meta = getMeta(pcClass); - PersistenceCapable pcInstance = meta.getPC(); - return pcInstance == null ? null : pcInstance.jdoNewInstance(sm, oid); - } - - /** - * Create a new instance of the ObjectId class of this PersistenceCapable class. It - * is intended only for application identity. This method should not be called for classes that - * use single field identity; newObjectIdInstance(Class, Object) should be used instead. If the - * class has been enhanced for datastore identity, or if the class is abstract, null is returned. - * - * @param pcClass the PersistenceCapable class. - * @return the new ObjectId instance, or null if the class is not registered. - */ - public Object newObjectIdInstance(Class pcClass) { - Meta meta = getMeta(pcClass); - PersistenceCapable pcInstance = meta.getPC(); - return pcInstance == null ? null : pcInstance.jdoNewObjectIdInstance(); - } - /** - * Create a new instance of the class used by the parameter Class for JDO identity, using the key - * constructor of the object id class. It is intended for single field identity. The identity - * instance returned has no relationship with the values of the primary key fields of the - * persistence-capable instance on which the method is called. If the key is the wrong class for - * the object id class, null is returned. - * - *

    For classes that use single field identity, if the parameter is of one of the following - * types, the behavior must be as specified: - * - *

      - *
    • Number or Character: the parameter must be the single field - * type or the wrapper class of the primitive field type; the parameter is passed to the - * single field identity constructor - *
    • ObjectIdFieldSupplier: the field value is fetched from the - * ObjectIdFieldSupplier and passed to the single field identity constructor - *
    • String: the String is passed to the single field identity constructor - *
    - * - * @return the new ObjectId instance, or null if the class is not registered. - * @param obj the Object form of the object id - * @param pcClass the PersistenceCapable class. - * @since 2.0 - */ - public Object newObjectIdInstance(Class pcClass, Object obj) { - Meta meta = getMeta(pcClass); - PersistenceCapable pcInstance = meta.getPC(); - return (pcInstance == null) ? null : pcInstance.jdoNewObjectIdInstance(obj); - } - - /** - * Copy fields from an outside source to the key fields in the ObjectId. This method is generated - * in the PersistenceCapable class to generate a call to the field manager for each - * key field in the ObjectId. - * - *

    For example, an ObjectId class that has three key fields (int id, - * String name, and Float salary) would have the method generated: - * - *

    - * void jdoCopyKeyFieldsToObjectId (Object oid, ObjectIdFieldSupplier fm) { - *
    oid.id = fm.fetchIntField (0); - *
    oid.name = fm.fetchStringField (1); - *
    oid.salary = fm.fetchObjectField (2); - *
    }
    - * - *

    The implementation is responsible for implementing the ObjectIdFieldSupplier to - * provide the values for the key fields. - * - * @param pcClass the PersistenceCapable Class. - * @param oid the ObjectId target of the copy. - * @param fm the field manager that supplies the field values. - */ - public void copyKeyFieldsToObjectId( - Class pcClass, PersistenceCapable.ObjectIdFieldSupplier fm, Object oid) { - Meta meta = getMeta(pcClass); - PersistenceCapable pcInstance = meta.getPC(); - if (pcInstance == null) { - throw new JDOFatalInternalException( - msg.msg("ERR_AbstractClassNoIdentity", pcClass.getName())); // NOI18N + /** Register the default DateFormat instance. + */ + static { + jdoImplHelper.registerDateFormat(getDateTimeInstance()); } - pcInstance.jdoCopyKeyFieldsToObjectId(fm, oid); - } - - /** - * Copy fields to an outside source from the key fields in the ObjectId. This method is generated - * in the PersistenceCapable class to generate a call to the field manager for each - * key field in the ObjectId. For example, an ObjectId class that has three key fields ( - * int id, String name, and Float salary) would have the method - * generated: - * - *

    void jdoCopyKeyFieldsFromObjectId - *
    (PersistenceCapable oid, ObjectIdFieldConsumer fm) { - *
    fm.storeIntField (0, oid.id); - *
    fm.storeStringField (1, oid.name); - *
    fm.storeObjectField (2, oid.salary); - *
    }
    - * - *

    The implementation is responsible for implementing the ObjectIdFieldConsumer to - * store the values for the key fields. - * - * @param pcClass the PersistenceCapable class - * @param oid the ObjectId source of the copy. - * @param fm the field manager that receives the field values. - */ - public void copyKeyFieldsFromObjectId( - Class pcClass, PersistenceCapable.ObjectIdFieldConsumer fm, Object oid) { - Meta meta = getMeta(pcClass); - PersistenceCapable pcInstance = meta.getPC(); - if (pcInstance == null) { - throw new JDOFatalInternalException( - msg.msg("ERR_AbstractClassNoIdentity", pcClass.getName())); // NOI18N + + /** Creates new JDOImplHelper */ + private JDOImplHelper() { } - pcInstance.jdoCopyKeyFieldsFromObjectId(fm, oid); - } - - /** - * Register metadata by class. The registration will be done in the class named - * JDOImplHelper loaded by the same or an ancestor class loader as the - * PersistenceCapable class performing the registration. - * - * @param pcClass the PersistenceCapable class used as the key for lookup. - * @param fieldNames an array of String field names for persistent and transactional - * fields - * @param fieldTypes an array of Class field types - * @param fieldFlags the Field Flags for persistent and transactional fields - * @param pc an instance of the PersistenceCapable class - * @param persistenceCapableSuperclass the most immediate superclass that is - * PersistenceCapable - */ - public static void registerClass( - Class pcClass, - String[] fieldNames, - Class[] fieldTypes, - byte[] fieldFlags, - Class persistenceCapableSuperclass, - PersistenceCapable pc) { - if (pcClass == null) throw new NullPointerException(msg.msg("ERR_NullClass")); // NOI18N - Meta meta = new Meta(fieldNames, fieldTypes, fieldFlags, persistenceCapableSuperclass, pc); - registeredClasses.put(pcClass, meta); - // handle class registration listeners - synchronized (listeners) { - if (!listeners.isEmpty()) { - RegisterClassEvent event = - new RegisterClassEvent( - jdoImplHelper, - pcClass, - fieldNames, - fieldTypes, - fieldFlags, - persistenceCapableSuperclass); - for (Iterator i = listeners.iterator(); i.hasNext(); ) { - RegisterClassListener crl = (RegisterClassListener) i.next(); - if (crl != null) { - crl.registerClass(event); - } + /** Get an instance of JDOImplHelper. This method + * checks that the caller is authorized for + * JDOPermission("getMetadata"), and if not, throws + * SecurityException. + * @return an instance of JDOImplHelper. + * @throws SecurityException if the caller is not authorized for + * JDOPermission("getMetadata"). + */ + public static JDOImplHelper getInstance() + throws SecurityException { + SecurityManager sec = LegacyJava.getSecurityManager(); + if (sec != null) { + // throws exception if caller is not authorized + sec.checkPermission (JDOPermission.GET_METADATA); } - } + return jdoImplHelper; } - } - - /** - * Unregister metadata by class loader. This method unregisters all registered - * PersistenceCapable classes loaded by the specified class loader. Any attempt to get - * metadata for unregistered classes will result in a JDOFatalUserException. - * - * @param cl the class loader. - * @since 1.0.2 - */ - public void unregisterClasses(ClassLoader cl) { - SecurityManager sec = LegacyJava.getSecurityManager(); - if (sec != null) { - // throws exception if caller is not authorized - sec.checkPermission(JDOPermission.MANAGE_METADATA); - } - synchronized (registeredClasses) { - for (Iterator i = registeredClasses.keySet().iterator(); i.hasNext(); ) { - Class pcClass = (Class) i.next(); - // Note, the pc class was registered by calling the static - // method JDOImplHelper.registerClass. This means the - // JDOImplHelper class loader is the same as or an ancestor - // of the class loader of the pc class. In this case method - // getClassLoader does not perform a security check for - // RuntimePermission("getClassLoader") and thus we do not - // need a privileged block for the getClassLoader call. - if ((pcClass != null) && (pcClass.getClassLoader() == cl)) { - // unregister pc class, if its class loader is the - // specified one. - i.remove(); - } - } + + /** Get the field names for a PersistenceCapable class. The + * order of fields is the natural ordering of the String class + * (without considering localization). + * @param pcClass the PersistenceCapable class. + * @return the field names for the class. + */ + public String[] getFieldNames (Class pcClass) { + Meta meta = getMeta (pcClass); + return meta.getFieldNames(); } - } - /** - * Unregister metadata by class. This method unregisters the specified class. Any further attempt - * to get metadata for the specified class will result in a JDOFatalUserException. - * - * @param pcClass the PersistenceCapable class to be unregistered. - * @since 1.0.2 - */ - public void unregisterClass(Class pcClass) { - if (pcClass == null) throw new NullPointerException(msg.msg("ERR_NullClass")); // NOI18N - SecurityManager sec = LegacyJava.getSecurityManager(); - if (sec != null) { - // throws exception if caller is not authorized - sec.checkPermission(JDOPermission.MANAGE_METADATA); + /** Get the field types for a PersistenceCapable class. The + * order of fields is the same as for field names. + * @param pcClass the PersistenceCapable class. + * @return the field types for the class. + */ + public Class[] getFieldTypes (Class pcClass) { + Meta meta = getMeta (pcClass); + return meta.getFieldTypes(); } - registeredClasses.remove(pcClass); - } - - /** - * Add the specified RegisterClassListener to the listener list. - * - * @param crl the listener to be added - */ - public void addRegisterClassListener(RegisterClassListener crl) { - HashSet alreadyRegisteredClasses = null; - synchronized (listeners) { - listeners.add(crl); - // Make a copy of the existing set of registered classes. - // Between these two lines of code, any number of new class - // registrations might occur, and will then all wait until this - // synchronized block completes. Some of the class registrations - // might be delivered twice to the newly registered listener. - alreadyRegisteredClasses = new HashSet(registeredClasses.keySet()); + + /** Get the field flags for a PersistenceCapable class. The + * order of fields is the same as for field names. + * @param pcClass the PersistenceCapable class. + * @return the field types for the class. + */ + public byte[] getFieldFlags (Class pcClass) { + Meta meta = getMeta (pcClass); + return meta.getFieldFlags(); } - // new registrations will call the new listener while the following - // occurs notify the new listener about already-registered classes - for (Iterator it = alreadyRegisteredClasses.iterator(); it.hasNext(); ) { - Class pcClass = (Class) it.next(); - Meta meta = getMeta(pcClass); - RegisterClassEvent event = - new RegisterClassEvent( - this, - pcClass, - meta.getFieldNames(), - meta.getFieldTypes(), - meta.getFieldFlags(), - meta.getPersistenceCapableSuperclass()); - crl.registerClass(event); + + /** Get the persistence-capable superclass for a + * PersistenceCapable class. + * @param pcClass the PersistenceCapable class. + * @return The PersistenceCapable superclass for this class, + * or null if there isn't one. + */ + public Class getPersistenceCapableSuperclass (Class pcClass) { + Meta meta = getMeta (pcClass); + return meta.getPersistenceCapableSuperclass(); } - } - - /** - * Remove the specified RegisterClassListener from the listener list. - * - * @param crl the listener to be removed - */ - public void removeRegisterClassListener(RegisterClassListener crl) { - synchronized (listeners) { - listeners.remove(crl); + + + /** Create a new instance of the class and assign its + * jdoStateManager. The new instance has its + * jdoFlags set to LOAD_REQUIRED. + * @see PersistenceCapable#jdoNewInstance(StateManager sm) + * @param pcClass the PersistenceCapable class. + * @param sm the StateManager which will own the new instance. + * @return the new instance, or null if the class is not + * registered. + */ + public PersistenceCapable newInstance (Class pcClass, StateManager sm) { + Meta meta = getMeta (pcClass); + PersistenceCapable pcInstance = meta.getPC(); + return pcInstance == null?null:pcInstance.jdoNewInstance(sm); } - } - - /** - * Returns a collection of class objects of the registered persistence-capable classes. - * - * @return registered persistence-capable classes - */ - public Collection getRegisteredClasses() { - return Collections.unmodifiableCollection(registeredClasses.keySet()); - } - - /** - * Look up the metadata for a PersistenceCapable class. - * - * @param pcClass the Class. - * @return the Meta for the Class. - */ - private static Meta getMeta(Class pcClass) { - Meta ret = (Meta) registeredClasses.get(pcClass); - if (ret == null) { - throw new JDOFatalUserException(msg.msg("ERR_NoMetadata", pcClass.getName())); // NOI18N + + /** Create a new instance of the class and assign its + * jdoStateManager and key values from the ObjectId. If the + * oid parameter is null, no key values are copied. + * The new instance has its jdoFlags set to + * LOAD_REQUIRED. + * @see PersistenceCapable#jdoNewInstance(StateManager sm, Object oid) + * @param pcClass the PersistenceCapable class. + * @param sm the StateManager which will own the new instance. + * @return the new instance, or null if the class is not + * registered. + * @param oid the ObjectId instance from which to copy key field values. + */ + public PersistenceCapable newInstance + (Class pcClass, StateManager sm, Object oid) { + Meta meta = getMeta (pcClass); + PersistenceCapable pcInstance = meta.getPC(); + return pcInstance == null?null:pcInstance.jdoNewInstance(sm, oid); } - return ret; - } - - /** - * Register a class authorized to replaceStateManager. The caller of this method must be - * authorized for JDOPermission("setStateManager"). During replaceStateManager, a - * persistence-capable class will call the corresponding checkAuthorizedStateManager and the class - * of the instance of the parameter must have been registered. - * - * @param smClass a Class that is authorized for JDOPermission("setStateManager"). - * @throws SecurityException if the caller is not authorized for JDOPermission("setStateManager"). - * @since 1.0.1 - */ - public static void registerAuthorizedStateManagerClass(Class smClass) throws SecurityException { - if (smClass == null) throw new NullPointerException(msg.msg("ERR_NullClass")); // NOI18N - SecurityManager sm = LegacyJava.getSecurityManager(); - if (sm != null) { - sm.checkPermission(JDOPermission.SET_STATE_MANAGER); + + /** Create a new instance of the ObjectId class of this + * PersistenceCapable class. + * It is intended only for application identity. This method should + * not be called for classes that use single field identity; + * newObjectIdInstance(Class, Object) should be used instead. + * If the class has been + * enhanced for datastore identity, or if the class is abstract, + * null is returned. + * @param pcClass the PersistenceCapable class. + * @return the new ObjectId instance, or null if the class + * is not registered. + */ + public Object newObjectIdInstance (Class pcClass) { + Meta meta = getMeta (pcClass); + PersistenceCapable pcInstance = meta.getPC(); + return pcInstance == null?null:pcInstance.jdoNewObjectIdInstance(); } - synchronized (authorizedStateManagerClasses) { - authorizedStateManagerClasses.put(smClass, null); + + /** Create a new instance of the class used by the parameter Class + * for JDO identity, using the + * key constructor of the object id class. It is intended for single + * field identity. The identity + * instance returned has no relationship with the values of the primary key + * fields of the persistence-capable instance on which the method is called. + * If the key is the wrong class for the object id class, null is returned. + *

    For classes that use single field identity, if the parameter is + * of one of the following types, the behavior must be as specified: + *

    • Number or Character: the + * parameter must be the single field + * type or the wrapper class of the primitive field type; the parameter + * is passed to the single field identity constructor + *
    • ObjectIdFieldSupplier: the field value + * is fetched from the ObjectIdFieldSupplier and passed to the + * single field identity constructor + *
    • String: the String is passed to the + * single field identity constructor + *
    + * @return the new ObjectId instance, or null + * if the class is not registered. + * @param obj the Object form of the object id + * @param pcClass the PersistenceCapable class. + * @since 2.0 + */ + public Object newObjectIdInstance (Class pcClass, Object obj) { + Meta meta = getMeta (pcClass); + PersistenceCapable pcInstance = meta.getPC(); + return (pcInstance == null)?null:pcInstance.jdoNewObjectIdInstance(obj); } - } - - /** - * Register classes authorized to replaceStateManager. The caller of this method must be - * authorized for JDOPermission("setStateManager"). During replaceStateManager, a - * persistence-capable class will call the corresponding checkAuthorizedStateManager and the class - * of the instance of the parameter must have been registered. - * - * @param smClasses a Collection of Classes that are authorized for - * JDOPermission("setStateManager"). - * @throws SecurityException if the caller is not authorized for JDOPermission("setStateManager"). - * @since 1.0.1 - */ - public static void registerAuthorizedStateManagerClasses(Collection smClasses) - throws SecurityException { - SecurityManager sm = LegacyJava.getSecurityManager(); - if (sm != null) { - sm.checkPermission(JDOPermission.SET_STATE_MANAGER); - synchronized (authorizedStateManagerClasses) { - for (Iterator it = smClasses.iterator(); it.hasNext(); ) { - Object smClass = it.next(); - if (!(smClass instanceof Class)) { - throw new ClassCastException( - msg.msg( - "ERR_StateManagerClassCast", // NOI18N - smClass.getClass().getName())); - } - registerAuthorizedStateManagerClass((Class) it.next()); + + /** Copy fields from an outside source to the key fields in the ObjectId. + * This method is generated in the PersistenceCapable class to + * generate a call to the field manager for each key field in the ObjectId. + *

    For example, an ObjectId class that has three key fields + * (int id, String name, and + * Float salary) would have the method generated: + *

    + * void jdoCopyKeyFieldsToObjectId (Object oid, ObjectIdFieldSupplier fm) { + *
    oid.id = fm.fetchIntField (0); + *
    oid.name = fm.fetchStringField (1); + *
    oid.salary = fm.fetchObjectField (2); + *
    }
    + *

    The implementation is responsible for implementing the + * ObjectIdFieldSupplier to provide the values for the key + * fields. + * @param pcClass the PersistenceCapable Class. + * @param oid the ObjectId target of the copy. + * @param fm the field manager that supplies the field values. + */ + public void copyKeyFieldsToObjectId + (Class pcClass, PersistenceCapable.ObjectIdFieldSupplier fm, Object oid) { + Meta meta = getMeta (pcClass); + PersistenceCapable pcInstance = meta.getPC(); + if (pcInstance == null) { + throw new JDOFatalInternalException (msg.msg( + "ERR_AbstractClassNoIdentity", pcClass.getName())); //NOI18N } - } + pcInstance.jdoCopyKeyFieldsToObjectId(fm, oid); } - } - /** - * Register a DocumentBuilderFactory instance for use in parsing the resource(s) - * META-INF/jdoconfig.xml. The default is governed by the semantics of - * DocumentBuilderFactory.newInstance(). - * - * @param factory the DocumentBuilderFactory instance to use - * @since 2.1 - */ - public synchronized void registerDocumentBuilderFactory(DocumentBuilderFactory factory) { - documentBuilderFactory = factory; - } - - /** - * Return the registered instance of DocumentBuilderFactory. - * - * @return the DocumentBuilderFactory if registered; null otherwise - * @since 2.1 - */ - public static DocumentBuilderFactory getRegisteredDocumentBuilderFactory() { - return documentBuilderFactory; - } - - /** - * Register an ErrorHandler instance for use in parsing the resource(s) META-INF/jdoconfig.xml. - * The default is an ErrorHandler that throws on error or fatalError and ignores warnings. - * - * @param handler the ErrorHandler instance to use - * @since 2.1 - */ - public synchronized void registerErrorHandler(ErrorHandler handler) { - errorHandler = handler; - } - - /** - * Return the registered instance of ErrorHandler. - * - * @return the registered ErrorHandler if registered; null otherwise - * @since 2.1 - */ - public static ErrorHandler getRegisteredErrorHandler() { - return errorHandler; - } - - /** - * Check that the parameter instance is of a class that is authorized for - * JDOPermission("setStateManager"). This method is called by the replaceStateManager method in - * persistence-capable classes. A class that is passed as the parameter to replaceStateManager - * must be authorized for JDOPermission("setStateManager"). To improve performance, first the set - * of authorized classes is checked, and if not present, a regular permission check is made. The - * regular permission check requires that all callers on the stack, including the - * persistence-capable class itself, must be authorized for JDOPermission("setStateManager"). - * - * @param sm an instance of StateManager whose class is to be checked. - * @since 1.0.1 - */ - public static void checkAuthorizedStateManager(StateManager sm) { - checkAuthorizedStateManagerClass(sm.getClass()); - } - - /** - * Check that the parameter instance is a class that is authorized for - * JDOPermission("setStateManager"). This method is called by the constructors of JDO Reference - * Implementation classes. - * - * @param smClass a Class to be checked for JDOPermission("setStateManager") - * @since 1.0.1 - */ - public static void checkAuthorizedStateManagerClass(Class smClass) { - final SecurityManager scm = LegacyJava.getSecurityManager(); - if (scm == null) { - // if no security manager, no checking. - return; + /** Copy fields to an outside source from the key fields in the ObjectId. + * This method is generated in the PersistenceCapable class to + * generate a call to the field manager for each key field in the ObjectId. + * For example, an ObjectId class that has three key fields + * (int id, String name, and + * Float salary) would have the method generated: + *

    void jdoCopyKeyFieldsFromObjectId + *
    (PersistenceCapable oid, ObjectIdFieldConsumer fm) { + *
    fm.storeIntField (0, oid.id); + *
    fm.storeStringField (1, oid.name); + *
    fm.storeObjectField (2, oid.salary); + *
    }
    + *

    The implementation is responsible for implementing the + * ObjectIdFieldConsumer to store the values for the key + * fields. + * @param pcClass the PersistenceCapable class + * @param oid the ObjectId source of the copy. + * @param fm the field manager that receives the field values. + */ + public void copyKeyFieldsFromObjectId + (Class pcClass, PersistenceCapable.ObjectIdFieldConsumer fm, Object oid) { + Meta meta = getMeta (pcClass); + PersistenceCapable pcInstance = meta.getPC(); + if (pcInstance == null) { + throw new JDOFatalInternalException (msg.msg( + "ERR_AbstractClassNoIdentity", pcClass.getName())); //NOI18N + } + pcInstance.jdoCopyKeyFieldsFromObjectId(fm, oid); } - synchronized (authorizedStateManagerClasses) { - if (authorizedStateManagerClasses.containsKey(smClass)) { - return; - } + + /** Register metadata by class. The registration will be done in the + * class named JDOImplHelper loaded by the same or an + * ancestor class loader as the PersistenceCapable class + * performing the registration. + * + * @param pcClass the PersistenceCapable class + * used as the key for lookup. + * @param fieldNames an array of String field names for + * persistent and transactional fields + * @param fieldTypes an array of Class field types + * @param fieldFlags the Field Flags for persistent and transactional fields + * @param pc an instance of the PersistenceCapable class + * @param persistenceCapableSuperclass the most immediate superclass that is + * PersistenceCapable + */ + public static void registerClass (Class pcClass, + String[] fieldNames, Class[] fieldTypes, + byte[] fieldFlags, Class persistenceCapableSuperclass, + PersistenceCapable pc) { + if (pcClass == null) + throw new NullPointerException(msg.msg("ERR_NullClass")); //NOI18N + Meta meta = new Meta (fieldNames, fieldTypes, + fieldFlags, persistenceCapableSuperclass, pc); + registeredClasses.put (pcClass, meta); + + // handle class registration listeners + synchronized (listeners) { + if (!listeners.isEmpty()) { + RegisterClassEvent event = new RegisterClassEvent( + jdoImplHelper, pcClass, fieldNames, fieldTypes, + fieldFlags, persistenceCapableSuperclass); + for (Iterator i = listeners.iterator(); i.hasNext();) { + RegisterClassListener crl = + (RegisterClassListener)i.next(); + if (crl != null) { + crl.registerClass(event); + } + } + } + } } - // if not already authorized, perform "long" security checking. - scm.checkPermission(JDOPermission.SET_STATE_MANAGER); - } - - /** - * Construct an instance of a key class using a String as input. This is a helper interface for - * use with ObjectIdentity. Classes without a String constructor (such as those in java.lang and - * java.util) will use this interface for constructing new instances. The result might be a - * singleton or use some other strategy. - */ - public interface StringConstructor { + /** - * Construct an instance of the class for which this instance is registered. - * - * @param s the parameter for construction - * @return the constructed object + * Unregister metadata by class loader. This method unregisters all + * registered PersistenceCapable classes loaded by the + * specified class loader. Any attempt to get metadata for unregistered + * classes will result in a JDOFatalUserException. + * @param cl the class loader. + * @since 1.0.2 */ - public Object construct(String s); - } - - /** - * Special StringConstructor instances for use with specific classes that have no public String - * constructor. The Map is keyed on class instance and the value is an instance of - * StringConstructor. - */ - static final Map stringConstructorMap = - new HashMap(); - - /** - * Register special StringConstructor instances. These instances are for constructing instances - * from String parameters where there is no String constructor for them. - * - * @param cls the class to register a StringConstructor for - * @param sc the StringConstructor instance - * @return the previous StringConstructor registered for this class - */ - public Object registerStringConstructor(Class cls, StringConstructor sc) { - synchronized (stringConstructorMap) { - return stringConstructorMap.put(cls, sc); - } - } - - /** Register the default special StringConstructor instances. */ - static { - if (isClassLoadable("java.util.Currency")) { - jdoImplHelper.registerStringConstructor( - Currency.class, - new StringConstructor() { - public Object construct(String s) { - try { - return Currency.getInstance(s); - } catch (IllegalArgumentException ex) { - throw new javax.jdo.JDOUserException( - msg.msg( - "EXC_CurrencyStringConstructorIllegalArgument", // NOI18N - s), - ex); - } catch (Exception ex) { - throw new JDOUserException( - msg.msg("EXC_CurrencyStringConstructorException"), // NOI18N - ex); - } + public void unregisterClasses (ClassLoader cl) + { + SecurityManager sec = LegacyJava.getSecurityManager(); + if (sec != null) { + // throws exception if caller is not authorized + sec.checkPermission (JDOPermission.MANAGE_METADATA); + } + synchronized(registeredClasses) { + for (Iterator i = registeredClasses.keySet().iterator(); + i.hasNext();) { + Class pcClass = (Class)i.next(); + // Note, the pc class was registered by calling the static + // method JDOImplHelper.registerClass. This means the + // JDOImplHelper class loader is the same as or an ancestor + // of the class loader of the pc class. In this case method + // getClassLoader does not perform a security check for + // RuntimePermission("getClassLoader") and thus we do not + // need a privileged block for the getClassLoader call. + if ((pcClass != null) && (pcClass.getClassLoader() == cl)) { + // unregister pc class, if its class loader is the + // specified one. + i.remove(); + } } - }); + } } - jdoImplHelper.registerStringConstructor( - Locale.class, - new StringConstructor() { - public Object construct(String s) { - try { - return getLocale(s); - } catch (Exception ex) { - throw new JDOUserException( - msg.msg("EXC_LocaleStringConstructorException"), ex); // NOI18N - } - } - }); - jdoImplHelper.registerStringConstructor( - Date.class, - new StringConstructor() { - public synchronized Object construct(String s) { - try { - // first, try the String as a Long - return new Date(Long.parseLong(s)); - } catch (NumberFormatException ex) { - // not a Long; try the formatted date - ParsePosition pp = new ParsePosition(0); - Date result = dateFormat.parse(s, pp); - if (result == null) { - throw new JDOUserException( - msg.msg( - "EXC_DateStringConstructor", - new Object[] // NOI18N - {s, pp.getErrorIndex(), dateFormatPattern})); - } - return result; - } - } - }); - } - /** - * Parse the String to a Locale. - * - * @param s the name of the Locale - * @return the Locale corresponding to the name - */ - private static Locale getLocale(String s) { - String lang = s; - int firstUnderbar = s.indexOf('_'); - if (firstUnderbar == -1) { - // nothing but language - return new Locale(lang); - } - lang = s.substring(0, firstUnderbar); - String country; - int secondUnderbar = s.indexOf('_', firstUnderbar + 1); - if (secondUnderbar == -1) { - // nothing but language, country - country = s.substring(firstUnderbar + 1); - return new Locale(lang, country); - } - country = s.substring(firstUnderbar + 1, secondUnderbar); - String variant = s.substring(secondUnderbar + 1); - return new Locale(lang, country, variant); - } - /** - * Determine if a class is loadable in the current environment. - * - * @param className the fully-qualified name of the class - * @return true if the class can be loaded; false otherwise - */ - private static boolean isClassLoadable(String className) { - try { - Class.forName(className); - return true; - } catch (ClassNotFoundException ex) { - return false; + /** + * Unregister metadata by class. This method unregisters the specified + * class. Any further attempt to get metadata for the specified class will + * result in a JDOFatalUserException. + * @param pcClass the PersistenceCapable class to be + * unregistered. + * @since 1.0.2 + */ + public void unregisterClass (Class pcClass) + { + if (pcClass == null) + throw new NullPointerException(msg.msg("ERR_NullClass")); //NOI18N + SecurityManager sec = LegacyJava.getSecurityManager(); + if (sec != null) { + // throws exception if caller is not authorized + sec.checkPermission (JDOPermission.MANAGE_METADATA); + } + registeredClasses.remove(pcClass); } - } - /** - * Construct an instance of the parameter class, using the keyString as an argument to the - * constructor. If the class has a StringConstructor instance registered, use it. If not, try to - * find a constructor for the class with a single String argument. Otherwise, throw a - * JDOUserException. - * - * @param className the name of the class - * @param keyString the String parameter for the constructor - * @return the result of construction - */ - public static Object construct(String className, String keyString) { - StringConstructor stringConstructor; - try { - Class keyClass = Class.forName(className); - synchronized (stringConstructorMap) { - stringConstructor = (StringConstructor) stringConstructorMap.get(keyClass); - } - if (stringConstructor != null) { - return stringConstructor.construct(keyString); - } else { - Constructor keyConstructor = keyClass.getConstructor(new Class[] {String.class}); - return keyConstructor.newInstance(new Object[] {keyString}); - } - } catch (JDOException ex) { - throw ex; - } catch (Exception ex) { - /* ClassNotFoundException, - NoSuchMethodException, - InstantiationException, - IllegalAccessException, - InvocationTargetException */ - throw new JDOUserException( - msg.msg( - "EXC_ObjectIdentityStringConstruction", // NOI18N - new Object[] {ex.toString(), className, keyString}), - ex); + /** + * Add the specified RegisterClassListener to the listener + * list. + * @param crl the listener to be added + */ + public void addRegisterClassListener (RegisterClassListener crl) { + HashSet alreadyRegisteredClasses = null; + synchronized (listeners) { + listeners.add(crl); + // Make a copy of the existing set of registered classes. + // Between these two lines of code, any number of new class + // registrations might occur, and will then all wait until this + // synchronized block completes. Some of the class registrations + // might be delivered twice to the newly registered listener. + alreadyRegisteredClasses = new HashSet (registeredClasses.keySet()); + } + // new registrations will call the new listener while the following + // occurs notify the new listener about already-registered classes + for (Iterator it = alreadyRegisteredClasses.iterator(); it.hasNext();) { + Class pcClass = (Class)it.next(); + Meta meta = getMeta (pcClass); + RegisterClassEvent event = new RegisterClassEvent( + this, pcClass, meta.getFieldNames(), meta.getFieldTypes(), + meta.getFieldFlags(), meta.getPersistenceCapableSuperclass()); + crl.registerClass (event); + } } - } - /** - * Get the DateFormat instance for the default locale from the VM. This requires the following - * privileges for JDOImplHelper in the security permissions file: permission - * java.util.PropertyPermission "user.country", "read"; permission java.util.PropertyPermission - * "user.timezone", "read,write"; permission java.util.PropertyPermission "java.home", "read"; If - * these permissions are not present, or there is some other problem getting the default date - * format, a simple formatter is returned. - * - * @since 2.1 - * @return the default date-time formatter - */ - static DateFormat getDateTimeInstance() { - DateFormat result = null; - try { - result = - doPrivileged( - new PrivilegedAction() { - public DateFormat run() { - return DateFormat.getDateTimeInstance(); - } - }); - } catch (Exception ex) { - result = DateFormat.getInstance(); + /** + * Remove the specified RegisterClassListener from the listener + * list. + * @param crl the listener to be removed + */ + public void removeRegisterClassListener (RegisterClassListener crl) { + synchronized (listeners) { + listeners.remove(crl); + } } - return result; - } - @SuppressWarnings("unchecked") - private static T doPrivileged(PrivilegedAction privilegedAction) { - try { - return (T) LegacyJava.doPrivilegedAction.invoke(null, privilegedAction); - } catch (IllegalAccessException | InvocationTargetException e) { - if (e.getCause() instanceof RuntimeException) { - throw (RuntimeException) e.getCause(); - } - throw new JDOFatalInternalException(e.getMessage()); + /** + * Returns a collection of class objects of the registered + * persistence-capable classes. + * @return registered persistence-capable classes + */ + public Collection getRegisteredClasses() { + return Collections.unmodifiableCollection(registeredClasses.keySet()); } - } - /** - * Register a DateFormat instance for use with constructing Date instances. The default is the - * default DateFormat instance. If the new instance implements SimpleDateFormat, get its pattern - * for error messages. - * - * @since 2.0 - * @param df the DateFormat instance to use - */ - public synchronized void registerDateFormat(DateFormat df) { - dateFormat = df; - if (df instanceof SimpleDateFormat) { - dateFormatPattern = ((SimpleDateFormat) df).toPattern(); - } else { - dateFormatPattern = msg.msg("MSG_unknown"); // NOI18N + /** Look up the metadata for a PersistenceCapable class. + * @param pcClass the Class. + * @return the Meta for the Class. + */ + private static Meta getMeta (Class pcClass) { + Meta ret = (Meta) registeredClasses.get (pcClass); + if (ret == null) { + throw new JDOFatalUserException( + msg.msg ("ERR_NoMetadata", pcClass.getName())); //NOI18N + } + return ret; } - } - - /** - * This is a helper class to manage metadata per persistence-capable class. The information is - * used at runtime to provide field names and field types to the JDO Model. - * - *

    This is the value of the HashMap which relates the - * PersistenceCapable Class as a key to the metadata. - */ - static class Meta { - + + /** Register a class authorized to replaceStateManager. The caller of + * this method must be authorized for JDOPermission("setStateManager"). + * During replaceStateManager, a persistence-capable class will call + * the corresponding checkAuthorizedStateManager and the class of the + * instance of the parameter must have been registered. + * @param smClass a Class that is authorized for + * JDOPermission("setStateManager"). + * @throws SecurityException if the caller is not authorized for + * JDOPermission("setStateManager"). + * @since 1.0.1 + */ + public static void registerAuthorizedStateManagerClass (Class smClass) + throws SecurityException { + if (smClass == null) + throw new NullPointerException(msg.msg("ERR_NullClass")); //NOI18N + SecurityManager sm = LegacyJava.getSecurityManager(); + if (sm != null) { + sm.checkPermission(JDOPermission.SET_STATE_MANAGER); + } + synchronized (authorizedStateManagerClasses) { + authorizedStateManagerClasses.put(smClass, null); + } + } + + /** Register classes authorized to replaceStateManager. The caller of + * this method must be authorized for JDOPermission("setStateManager"). + * During replaceStateManager, a persistence-capable class will call + * the corresponding checkAuthorizedStateManager and the class of the + * instance of the parameter must have been registered. + * @param smClasses a Collection of Classes that are authorized for + * JDOPermission("setStateManager"). + * @throws SecurityException if the caller is not authorized for + * JDOPermission("setStateManager"). + * @since 1.0.1 + */ + public static void registerAuthorizedStateManagerClasses ( + Collection smClasses) throws SecurityException { + SecurityManager sm = LegacyJava.getSecurityManager(); + if (sm != null) { + sm.checkPermission(JDOPermission.SET_STATE_MANAGER); + synchronized (authorizedStateManagerClasses) { + for (Iterator it = smClasses.iterator(); it.hasNext();) { + Object smClass = it.next(); + if (!(smClass instanceof Class)) { + throw new ClassCastException( + msg.msg("ERR_StateManagerClassCast", //NOI18N + smClass.getClass().getName())); + } + registerAuthorizedStateManagerClass((Class)it.next()); + } + } + } + } + /** - * Construct an instance of Meta. + * Register a DocumentBuilderFactory instance for use in parsing the + * resource(s) META-INF/jdoconfig.xml. The default is governed by the + * semantics of DocumentBuilderFactory.newInstance(). * - * @param fieldNames An array of String - * @param fieldTypes An array of Class - * @param fieldFlags an array of int - * @param persistenceCapableSuperclass the most immediate PersistenceCapable - * superclass - * @param pc An instance of the PersistenceCapable class + * @param factory the DocumentBuilderFactory instance to use + * @since 2.1 */ - Meta( - String[] fieldNames, - Class[] fieldTypes, - byte[] fieldFlags, - Class persistenceCapableSuperclass, - PersistenceCapable pc) { - this.fieldNames = fieldNames; - this.fieldTypes = fieldTypes; - this.fieldFlags = fieldFlags; - this.persistenceCapableSuperclass = persistenceCapableSuperclass; - this.pc = pc; + public synchronized void registerDocumentBuilderFactory( + DocumentBuilderFactory factory) { + documentBuilderFactory = factory; } /** - * This is an array of field names used for the Model at runtime. The field is passed by the - * static class initialization. + * Return the registered instance of DocumentBuilderFactory. + * @return the DocumentBuilderFactory if registered; null otherwise + * @since 2.1 */ - String[] fieldNames; + public static DocumentBuilderFactory getRegisteredDocumentBuilderFactory() { + return documentBuilderFactory; + } /** - * Get the field names from the metadata. + * Register an ErrorHandler instance for use in parsing the + * resource(s) META-INF/jdoconfig.xml. The default is an ErrorHandler + * that throws on error or fatalError and ignores warnings. * - * @return the array of field names. + * @param handler the ErrorHandler instance to use + * @since 2.1 */ - String[] getFieldNames() { - return fieldNames; + public synchronized void registerErrorHandler(ErrorHandler handler) { + errorHandler = handler; } /** - * This is an array of field types used for the Model at runtime. The field is passed by the - * static class initialization. + * Return the registered instance of ErrorHandler. + * @return the registered ErrorHandler if registered; null otherwise + * @since 2.1 */ - Class[] fieldTypes; + public static ErrorHandler getRegisteredErrorHandler() { + return errorHandler; + } - /** - * Get the field types from the metadata. - * - * @return the array of field types. + /** Check that the parameter instance is of a class that is authorized for + * JDOPermission("setStateManager"). This method is called by the + * replaceStateManager method in persistence-capable classes. + * A class that is passed as the parameter to replaceStateManager must be + * authorized for JDOPermission("setStateManager"). To improve performance, + * first the set of authorized classes is checked, and if not present, a + * regular permission check is made. The regular permission check requires + * that all callers on the stack, including the persistence-capable class + * itself, must be authorized for JDOPermission("setStateManager"). + * @param sm an instance of StateManager whose class is to be checked. + * @since 1.0.1 */ - Class[] getFieldTypes() { - return fieldTypes; + public static void checkAuthorizedStateManager (StateManager sm) { + checkAuthorizedStateManagerClass(sm.getClass()); } - /** - * This is an array of field flags used for the Model at runtime. The field is passed by the - * static class initialization. + /** Check that the parameter instance is a class that is authorized for + * JDOPermission("setStateManager"). This method is called by the + * constructors of JDO Reference Implementation classes. + * @param smClass a Class to be checked for JDOPermission("setStateManager") + * @since 1.0.1 */ - byte[] fieldFlags; + public static void checkAuthorizedStateManagerClass (Class smClass) { + final SecurityManager scm = LegacyJava.getSecurityManager(); + if (scm == null) { + // if no security manager, no checking. + return; + } + synchronized(authorizedStateManagerClasses) { + if (authorizedStateManagerClasses.containsKey(smClass)) { + return; + } + } + // if not already authorized, perform "long" security checking. + scm.checkPermission(JDOPermission.SET_STATE_MANAGER); + } - /** - * Get the field types from the metadata. - * - * @return the array of field types. + /** + * Construct an instance of a key class using a String as input. + * This is a helper interface for use with ObjectIdentity. + * Classes without a String constructor (such as those in java.lang + * and java.util) will use this interface for constructing new instances. + * The result might be a singleton or use some other strategy. */ - byte[] getFieldFlags() { - return fieldFlags; + public interface StringConstructor { + /** + * Construct an instance of the class for which this instance + * is registered. + * @param s the parameter for construction + * @return the constructed object + */ + public Object construct(String s); } + + /** + * Special StringConstructor instances for use with specific + * classes that have no public String constructor. The Map is + * keyed on class instance and the value is an instance of + * StringConstructor. + */ + static final Map stringConstructorMap = + new HashMap(); /** - * This is the Class instance of the PersistenceCapable superclass. + * + * Register special StringConstructor instances. These instances + * are for constructing instances from String parameters where there + * is no String constructor for them. + * @param cls the class to register a StringConstructor for + * @param sc the StringConstructor instance + * @return the previous StringConstructor registered for this class */ - Class persistenceCapableSuperclass; + public Object registerStringConstructor(Class cls, StringConstructor sc) { + synchronized(stringConstructorMap) { + return stringConstructorMap.put(cls, sc); + } + } + /** Register the default special StringConstructor instances. + */ + static { + if (isClassLoadable("java.util.Currency")) { + jdoImplHelper.registerStringConstructor( + Currency.class, new StringConstructor() { + public Object construct(String s) { + try { + return Currency.getInstance(s); + } catch (IllegalArgumentException ex) { + throw new javax.jdo.JDOUserException(msg.msg( + "EXC_CurrencyStringConstructorIllegalArgument", //NOI18N + s), ex); + } catch (Exception ex) { + throw new JDOUserException(msg.msg( + "EXC_CurrencyStringConstructorException"), //NOI18N + ex); + } + } + }); + } + jdoImplHelper.registerStringConstructor(Locale.class, new StringConstructor() { + public Object construct(String s) { + try { + return getLocale(s); + } catch (Exception ex) { + throw new JDOUserException(msg.msg( + "EXC_LocaleStringConstructorException"), ex); //NOI18N + } + } + }); + jdoImplHelper.registerStringConstructor(Date.class, new StringConstructor() { + public synchronized Object construct(String s) { + try { + // first, try the String as a Long + return new Date(Long.parseLong(s)); + } catch (NumberFormatException ex) { + // not a Long; try the formatted date + ParsePosition pp = new ParsePosition(0); + Date result = dateFormat.parse(s, pp); + if (result == null) { + throw new JDOUserException (msg.msg( + "EXC_DateStringConstructor", new Object[] //NOI18N + {s, pp.getErrorIndex(), + dateFormatPattern})); + } + return result; + } + } + }); + } + /** - * Return the PersistenceCapable superclass. - * - * @return the PersistenceCapable superclass + * Parse the String to a Locale. + * @param s the name of the Locale + * @return the Locale corresponding to the name */ - Class getPersistenceCapableSuperclass() { - return persistenceCapableSuperclass; + private static Locale getLocale(String s) { + String lang = s; + int firstUnderbar = s.indexOf('_'); + if (firstUnderbar == -1) { + // nothing but language + return new Locale(lang); + } + lang = s.substring(0, firstUnderbar); + String country; + int secondUnderbar = s.indexOf('_', firstUnderbar + 1); + if (secondUnderbar == -1) { + // nothing but language, country + country = s.substring(firstUnderbar + 1); + return new Locale(lang, country); + } + country = s.substring(firstUnderbar + 1, secondUnderbar); + String variant = s.substring(secondUnderbar + 1); + return new Locale(lang, country, variant); } /** - * This is an instance of PersistenceCapable, used at runtime to create new - * instances. + * Determine if a class is loadable in the current environment. + * @param className the fully-qualified name of the class + * @return true if the class can be loaded; false otherwise */ - PersistenceCapable pc; - + private static boolean isClassLoadable(String className) { + try { + Class.forName(className); + return true; + } catch (ClassNotFoundException ex) { + return false; + } + } + /** - * Get an instance of the PersistenceCapable class. - * - * @return an instance of the PersistenceCapable Class. + * Construct an instance of the parameter class, using the keyString + * as an argument to the constructor. If the class has a StringConstructor + * instance registered, use it. If not, try to find a constructor for + * the class with a single String argument. Otherwise, throw a + * JDOUserException. + * @param className the name of the class + * @param keyString the String parameter for the constructor + * @return the result of construction */ - PersistenceCapable getPC() { - return pc; + public static Object construct(String className, String keyString) { + StringConstructor stringConstructor; + try { + Class keyClass = Class.forName(className); + synchronized(stringConstructorMap) { + stringConstructor = + (StringConstructor) stringConstructorMap.get(keyClass); + } + if (stringConstructor != null) { + return stringConstructor.construct(keyString); + } else { + Constructor keyConstructor = + keyClass.getConstructor(new Class[]{String.class}); + return keyConstructor.newInstance(new Object[]{keyString}); + } + } catch (JDOException ex) { + throw ex; + } catch (Exception ex) { + /* ClassNotFoundException, + NoSuchMethodException, + InstantiationException, + IllegalAccessException, + InvocationTargetException */ + throw new JDOUserException( + msg.msg("EXC_ObjectIdentityStringConstruction", //NOI18N + new Object[] {ex.toString(), className, keyString}), ex); + } } /** - * Return the string form of the metadata. - * - * @return the string form + * Get the DateFormat instance for the default locale from the VM. + * This requires the following privileges for JDOImplHelper in the + * security permissions file: + * permission java.util.PropertyPermission "user.country", "read"; + * permission java.util.PropertyPermission "user.timezone", "read,write"; + * permission java.util.PropertyPermission "java.home", "read"; + * If these permissions are not present, or there is some other + * problem getting the default date format, a simple formatter is returned. + * @since 2.1 + * @return the default date-time formatter */ - public String toString() { - return "Meta-" + pc.getClass().getName(); // NOI18N + static DateFormat getDateTimeInstance() { + DateFormat result = null; + try { + result = doPrivileged ( + new PrivilegedAction () { + public DateFormat run () { + return DateFormat.getDateTimeInstance(); + } + } + ); + } catch (Exception ex) { + result = DateFormat.getInstance(); + } + return result; } - } - /** - * Add a StateInterrogation to the list. Create a new list in case there is an iterator open on - * the original list. - * - * @param si the StateInterrogation to add - */ - public synchronized void addStateInterrogation(StateInterrogation si) { - List newList = new ArrayList(stateInterrogations); - newList.add(si); - stateInterrogations = newList; - } + @SuppressWarnings("unchecked") + private static T doPrivileged(PrivilegedAction privilegedAction) { + try { + return (T) LegacyJava.doPrivilegedAction.invoke(null, privilegedAction); + } catch (IllegalAccessException | InvocationTargetException e) { + if (e.getCause() instanceof RuntimeException) { + throw (RuntimeException) e.getCause(); + } + throw new JDOFatalInternalException(e.getMessage()); + } + } - /** - * Remove a StateInterrogation from the list. Create a new list in case there is an iterator open - * on the original list. - * - * @param si the StateInterrogation to remove - */ - public synchronized void removeStateInterrogation(StateInterrogation si) { - List newList = new ArrayList(stateInterrogations); - newList.remove(si); - stateInterrogations = newList; - } + /** + * Register a DateFormat instance for use with constructing Date + * instances. The default is the default DateFormat instance. + * If the new instance implements SimpleDateFormat, get its pattern + * for error messages. + * @since 2.0 + * @param df the DateFormat instance to use + */ + public synchronized void registerDateFormat(DateFormat df) { + dateFormat = df; + if (df instanceof SimpleDateFormat) { + dateFormatPattern = ((SimpleDateFormat)df).toPattern(); + } else { + dateFormatPattern = msg.msg("MSG_unknown"); //NOI18N + } + } - /** - * Return an Iterator over all StateInterrogation instances. Synchronize to avoid - * add/remove/iterate conflicts. - * - * @return an Iterator over all StateInterrogation instances. - */ - private synchronized Iterator getStateInterrogationIterator() { - return stateInterrogations.iterator(); - } + /** This is a helper class to manage metadata per persistence-capable + * class. The information is used at runtime to provide field names and + * field types to the JDO Model. + * + * This is the value of the HashMap which + * relates the PersistenceCapable Class + * as a key to the metadata. + */ + static class Meta { + + /** Construct an instance of Meta. + * @param fieldNames An array of String + * @param fieldTypes An array of Class + * @param fieldFlags an array of int + * @param persistenceCapableSuperclass the most immediate + * PersistenceCapable superclass + * @param pc An instance of the PersistenceCapable class + */ + Meta (String[] fieldNames, Class[] fieldTypes, byte[] fieldFlags, + Class persistenceCapableSuperclass, PersistenceCapable pc) { + this.fieldNames = fieldNames; + this.fieldTypes = fieldTypes; + this.fieldFlags = fieldFlags; + this.persistenceCapableSuperclass = persistenceCapableSuperclass; + this.pc = pc; + } + + /** This is an array of field names used + * for the Model at runtime. The field + * is passed by the static class initialization. + */ + String[] fieldNames; + + /** Get the field names from the metadata. + * @return the array of field names. + */ + String[] getFieldNames() { + return fieldNames; + } + + /** This is an array of field types used + * for the Model at runtime. The field + * is passed by the static class initialization. + */ + Class[] fieldTypes; + + /** Get the field types from the metadata. + * @return the array of field types. + */ + Class[] getFieldTypes() { + return fieldTypes; + } + + /** This is an array of field flags used + * for the Model at runtime. The field + * is passed by the static class initialization. + */ + byte[] fieldFlags; + + /** Get the field types from the metadata. + * @return the array of field types. + */ + byte[] getFieldFlags() { + return fieldFlags; + } - /** - * Mark a non-binary-compatible instance dirty. Delegate to all registered StateInterrogation - * instances until one of them handles the call. - * - * @param pc the instance to mark dirty - * @param fieldName the field to mark dirty - */ - public void nonBinaryCompatibleMakeDirty(Object pc, String fieldName) { - Iterator sit = getStateInterrogationIterator(); - while (sit.hasNext()) { - StateInterrogation si = (StateInterrogation) sit.next(); - try { - if (si.makeDirty(pc, fieldName)) return; - } catch (Throwable t) { - continue; // ignore exceptions from errant StateInterrogations - } + /** This is the Class instance of the + * PersistenceCapable superclass. + */ + Class persistenceCapableSuperclass; + + /** Return the PersistenceCapable superclass. + * @return the PersistenceCapable superclass + */ + Class getPersistenceCapableSuperclass() { + return persistenceCapableSuperclass; + } + /** This is an instance of PersistenceCapable, + * used at runtime to create new instances. + */ + PersistenceCapable pc; + + /** Get an instance of the PersistenceCapable class. + * @return an instance of the PersistenceCapable Class. + */ + PersistenceCapable getPC() { + return pc; + } + + /** Return the string form of the metadata. + * @return the string form + */ + public String toString() { + return "Meta-" + pc.getClass().getName(); //NOI18N + } } - } - - /** - * Determine the state of a non-binary-compatible instance. Delegate to all registered - * StateInterrogation instances until one of them handles the call (returns a non-null Boolean - * with the answer). The caller provides the stateless "method object" that does the actual call - * to the StateInterrogation instance. - * - * @param pc the instance to be checked - * @param sibr the method object that delegates to the non-binary-compatible implementation - * @return Boolean.TRUE if the instance satisfies the state interrogation; Boolean.FALSE if the - * instance does not satisfy the interrogation; or null if the implementation does not manage - * the class of the instance - */ - public boolean nonBinaryCompatibleIs(Object pc, StateInterrogationBooleanReturn sibr) { - Iterator sit = getStateInterrogationIterator(); - while (sit.hasNext()) { - StateInterrogation si = (StateInterrogation) sit.next(); - Boolean result; - try { - result = sibr.is(pc, si); - } catch (Throwable t) { - continue; // ignore exceptions from errant StateInterrogations - } - if (result != null) return result.booleanValue(); + + /** + * Add a StateInterrogation to the list. Create a new list + * in case there is an iterator open on the original list. + * @param si the StateInterrogation to add + */ + public synchronized void addStateInterrogation(StateInterrogation si) { + List newList = + new ArrayList(stateInterrogations); + newList.add(si); + stateInterrogations = newList; } - return false; - } - - /** - * Return an object associated with a non-binary-compatible instance. Delegate to all registered - * StateInterrogation instances until one of them handles the call (returns a non-null answer). - * The caller provides the stateless "method object" that does the actual call to the - * StateInterrogation instance. - * - * @param pc the instance whose associated object is needed - * @param sibr the method object that delegates to the non-binary-compatible implementation - * @return the associated object or null if the implementation does not manage the class of the - * instance - */ - public Object nonBinaryCompatibleGet(Object pc, StateInterrogationObjectReturn sibr) { - Iterator sit = getStateInterrogationIterator(); - while (sit.hasNext()) { - StateInterrogation si = (StateInterrogation) sit.next(); - Object result; - try { - result = sibr.get(pc, si); - } catch (Throwable t) { - continue; // ignore exceptions from errant StateInterrogations - } - if (result != null) return result; + + /** + * Remove a StateInterrogation from the list. Create a new list + * in case there is an iterator open on the original list. + * @param si the StateInterrogation to remove + */ + public synchronized void removeStateInterrogation(StateInterrogation si) { + List newList = + new ArrayList(stateInterrogations); + newList.remove(si); + stateInterrogations = newList; } - return null; - } - - /** - * This is an interface used to interrogate the state of an instance that does not implement - * PersistenceCapable. It is used for the methods that return a boolean value. - */ - public static interface StateInterrogationBooleanReturn { + /** - * Interrogate the state of the instance - * - * @param pc the instance - * @param si the method object - * @return the state of the instance or null + * Return an Iterator over all StateInterrogation instances. + * Synchronize to avoid add/remove/iterate conflicts. + * @return an Iterator over all StateInterrogation instances. */ - public Boolean is(Object pc, StateInterrogation si); - } - - /** - * This is an interface used to interrogate the state of an instance that does not implement - * PersistenceCapable. It is used for the methods that return an Object value. - */ - public static interface StateInterrogationObjectReturn { + private synchronized Iterator getStateInterrogationIterator() { + return stateInterrogations.iterator(); + } + /** - * Return the associated instance. - * - * @param pc the instance - * @param si the method object - * @return the associated object or null + * Mark a non-binary-compatible instance dirty. Delegate to all + * registered StateInterrogation instances until one of them + * handles the call. + * @param pc the instance to mark dirty + * @param fieldName the field to mark dirty */ - public Object get(Object pc, StateInterrogation si); - } + public void nonBinaryCompatibleMakeDirty(Object pc, String fieldName) { + Iterator sit = getStateInterrogationIterator(); + while (sit.hasNext()) { + StateInterrogation si = (StateInterrogation)sit.next(); + try { + if (si.makeDirty(pc, fieldName)) return; + } catch (Throwable t) { + continue; // ignore exceptions from errant StateInterrogations + } + } + } + + /** + * Determine the state of a non-binary-compatible instance. + * Delegate to all registered StateInterrogation instances until + * one of them handles the call (returns a non-null Boolean + * with the answer). + * The caller provides the stateless "method object" that does + * the actual call to the StateInterrogation instance. + * @param pc the instance to be checked + * @param sibr the method object that delegates to the + * non-binary-compatible implementation + * @return Boolean.TRUE if the instance satisfies the state interrogation; + * Boolean.FALSE if the instance does not satisfy the interrogation; + * or null if the implementation does not manage the class of the instance + */ + public boolean nonBinaryCompatibleIs(Object pc, + StateInterrogationBooleanReturn sibr) { + Iterator sit = getStateInterrogationIterator(); + while (sit.hasNext()) { + StateInterrogation si = (StateInterrogation)sit.next(); + Boolean result; + try { + result = sibr.is(pc, si); + } catch (Throwable t) { + continue; // ignore exceptions from errant StateInterrogations + } + if (result != null) return result.booleanValue(); + } + return false; + } + + /** + * Return an object associated with a non-binary-compatible instance. + * Delegate to all registered StateInterrogation instances until + * one of them handles the call (returns a non-null answer). + * The caller provides the stateless "method object" that does + * the actual call to the StateInterrogation instance. + * @param pc the instance whose associated object is needed + * @param sibr the method object that delegates to the + * non-binary-compatible implementation + * @return the associated object or null if the implementation does not + * manage the class of the instance + */ + public Object nonBinaryCompatibleGet(Object pc, + StateInterrogationObjectReturn sibr) { + Iterator sit = getStateInterrogationIterator(); + while (sit.hasNext()) { + StateInterrogation si = (StateInterrogation)sit.next(); + Object result; + try { + result = sibr.get(pc, si); + } catch (Throwable t) { + continue; // ignore exceptions from errant StateInterrogations + } + if (result != null) return result; + } + return null; + } + + /** This is an interface used to interrogate the state of an instance + * that does not implement PersistenceCapable. It is used for the + * methods that return a boolean value. + */ + public static interface StateInterrogationBooleanReturn { + /** + * Interrogate the state of the instance + * @param pc the instance + * @param si the method object + * @return the state of the instance or null + */ + public Boolean is(Object pc, StateInterrogation si); + } + + /** This is an interface used to interrogate the state of an instance + * that does not implement PersistenceCapable. It is used for the + * methods that return an Object value. + */ + public static interface StateInterrogationObjectReturn { + /** + * Return the associated instance. + * @param pc the instance + * @param si the method object + * @return the associated object or null + */ + public Object get(Object pc, StateInterrogation si); + } - /** - * Examines the given map for keys beginning with the JDO standard prefix, {@link - * Constants#JAVAX_JDO_PREFIX}. If any property keys are found with that prefix but are unknown to - * this version of the JDO standard, a JDOUserException is thrown with a message indicating the - * unknown property. Keys that are not strings are ignored, as are string keys beginning with - * {@link Constants#PROPERTY_PREFIX_INSTANCE_LIFECYCLE_LISTENER} or not beginning with {@link - * Constants#JAVAX_JDO_PREFIX}. - * - * @param properties The properties to examine. - * @see Constants#JAVAX_JDO_PREFIX - * @since 3.1 - */ - public static void assertOnlyKnownStandardProperties(Map properties) { - if (properties == null || properties.isEmpty()) return; + /** + * Examines the given map for keys beginning with the JDO standard prefix, + * {@link Constants#JAVAX_JDO_PREFIX}. If any property keys are found with + * that prefix but are unknown to this version of the JDO standard, a + * JDOUserException is thrown with a message indicating the unknown + * property. Keys that are not strings are ignored, as are string keys + * beginning with + * {@link Constants#PROPERTY_PREFIX_INSTANCE_LIFECYCLE_LISTENER} or not + * beginning with {@link Constants#JAVAX_JDO_PREFIX}. + * @param properties The properties to examine. + * @see Constants#JAVAX_JDO_PREFIX + * @since 3.1 + */ + public static void assertOnlyKnownStandardProperties(Map properties) { + if (properties == null || properties.isEmpty()) + return; - List exceptions = new ArrayList(); - StringBuilder unknowns = new StringBuilder(); + List exceptions = new ArrayList(); + StringBuilder unknowns = new StringBuilder(); - for (Object key : properties.keySet()) { - if (!(key instanceof String)) { - continue; // ignore keys not of type string - } - String s = ((String) key).toLowerCase(); // compare case-insensitively - if (!s.startsWith(JAVAX_JDO_PREFIX_LOWER_CASED)) { - continue; // ignore vendor-specific keys - } - if (s.startsWith(PROPERTY_PREFIX_INSTANCE_LIFECYCLE_LISTENER_LOWER_CASED)) { - continue; // ignore listener class names - } - if (!USER_CONFIGURABLE_STANDARD_PROPERTIES_LOWER_CASED.contains(s)) { - exceptions.add(new JDOUserException(msg.msg("EXC_UnknownStandardProperty", s))); + for (Object key : properties.keySet()) { + if (!(key instanceof String)) { + continue; // ignore keys not of type string + } + String s = ((String) key).toLowerCase(); // compare case-insensitively + if (!s.startsWith(JAVAX_JDO_PREFIX_LOWER_CASED)) { + continue; // ignore vendor-specific keys + } + if (s.startsWith(PROPERTY_PREFIX_INSTANCE_LIFECYCLE_LISTENER_LOWER_CASED)) { + continue; // ignore listener class names + } + if (!USER_CONFIGURABLE_STANDARD_PROPERTIES_LOWER_CASED.contains(s)) { + exceptions.add(new JDOUserException(msg.msg( + "EXC_UnknownStandardProperty", s))); - if (exceptions.size() > 1) { - unknowns.append(","); + if (exceptions.size() > 1) { + unknowns.append(","); + } + unknowns.append(s); + } } - unknowns.append(s); - } - } - if (exceptions.size() == 1) { - throw exceptions.get(0); - } else if (exceptions.size() > 1) { - throw new JDOUserException( - msg.msg("EXC_UnknownStandardProperties", unknowns.toString()), - exceptions.toArray(new JDOUserException[] {})); + if (exceptions.size() == 1) { + throw exceptions.get(0); + } else if (exceptions.size() > 1) { + throw new JDOUserException(msg.msg("EXC_UnknownStandardProperties", + unknowns.toString()), + exceptions.toArray(new JDOUserException[] {})); + } } - } } diff --git a/api/src/main/java/javax/jdo/spi/JDOPermission.java b/api/src/main/java/javax/jdo/spi/JDOPermission.java index 469bf65e9..c1e60a094 100644 --- a/api/src/main/java/javax/jdo/spi/JDOPermission.java +++ b/api/src/main/java/javax/jdo/spi/JDOPermission.java @@ -5,26 +5,29 @@ * 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 - * + * * https://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 + * + * 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 javax.jdo.spi; /** - * The JDOPermission class is for operations that are reserved for JDO implementations - * and should not be called by other code. A JDOPermission is a named - * permission and has no actions. There are two names currently defined. Each named permission - * has a corresponding public static final field which contains an instance of the named permission. - * - *

    The following table provides a summary description of what each named permission allows, and - * discusses the risks of granting code the permission. + * The JDOPermission class is for operations that are reserved for + * JDO implementations and should not be called by other code. A + * JDOPermission is a named permission and has no + * actions. There are two names currently defined. Each named permission + * has a corresponding public static final field which contains an instance + * of the named permission. + *

    + * The following table + * provides a summary description of what each named permission allows, + * and discusses the risks of granting code the permission. * * * @@ -34,35 +37,35 @@ * * * - * - * * * * - * - * * * * - * - * * * * * + * thereby releasing resources. * + * malicious code. * *
    setStateManagerThis allows setting the StateManager for an instance of + * This allows setting the StateManager for an instance of * PersistenceCapable. The StateManager * has unlimited access to get and set persistent and transactional fields of * the PersistenceCapable instance.This is dangerous in that information (possibly confidential) + * This is dangerous in that information (possibly confidential) * normally unavailable would be accessible to malicious code.
    getMetadataThis allows getting metadata for any PersistenceCapable + * This allows getting metadata for any PersistenceCapable * class that has registered with JDOImplHelper.This is dangerous in that metadata information (possibly confidential) + * This is dangerous in that metadata information (possibly confidential) * normally unavailable would be accessible to malicious code.
    manageMetadataThis allows managing metadata for any PersistenceCapable + * This allows managing metadata for any PersistenceCapable * class that has registered with JDOImplHelper.This is dangerous in that metadata information (possibly confidential) + * This is dangerous in that metadata information (possibly confidential) * normally unavailable would be manageable (modifiable) by malicious code. *
    closePersistenceManagerFactoryThis allows closing a PersistenceManagerFactory, - * thereby releasing resources.This is dangerous in that resources bound to the * PersistenceManagerFactory would be releaseable by - * malicious code.
    * @@ -74,56 +77,54 @@ */ public final class JDOPermission extends java.security.BasicPermission { - private static final long serialVersionUID = 3087132628681636890L; - - /** - * Constructs a JDOPermission with the specified name. - * - * @param name the name of the JDOPermission - */ - public JDOPermission(String name) { - super(name); - } - - /** - * Constructs a JDOPermission with the specified name and actions. The actions should - * be null; they are ignored. This constructor exists for use by the Policy - * object to instantiate new Permission objects. - * - * @param name the name of the JDOPermission - * @param actions should be null. - */ - public JDOPermission(String name, String actions) { - super(name, actions); - } - - /** - * An instance of JDOPermission to be used for getMetadata permission - * checking. - */ - public static final JDOPermission GET_METADATA = new JDOPermission("getMetadata"); // NOI18N + private static final long serialVersionUID = 3087132628681636890L; - /** - * An instance of JDOPermission to be used for manageMetadata permission - * checking. - * - * @since 1.0.2 - */ - public static final JDOPermission MANAGE_METADATA = new JDOPermission("manageMetadata"); // NOI18N + /** + * Constructs a JDOPermission with the specified name. + * + * @param name the name of the JDOPermission + */ + public JDOPermission(String name) { + super(name); + } - /** - * An instance of JDOPermission to be used for setStateManager - * permission checking. - */ - public static final JDOPermission SET_STATE_MANAGER = - new JDOPermission("setStateManager"); // NOI18N + /** + * Constructs a JDOPermission with the specified name and + * actions. The actions should be null; they are ignored. + * This constructor exists for use by the Policy object + * to instantiate new Permission objects. + * + * @param name the name of the JDOPermission + * @param actions should be null. + */ + public JDOPermission(String name, String actions) { + super(name, actions); + } - /** - * An instance of JDOPermission to be used for closePersistenceManagerFactory - * permission checking. - * - * @since 1.0.1 - */ - public static final JDOPermission CLOSE_PERSISTENCE_MANAGER_FACTORY = - new JDOPermission("closePersistenceManagerFactory"); // NOI18N + /** An instance of JDOPermission to be used for + * getMetadata permission checking. + */ + public final static JDOPermission GET_METADATA = + new JDOPermission("getMetadata"); // NOI18N + + /** An instance of JDOPermission to be used for + * manageMetadata permission checking. + * @since 1.0.2 + */ + public final static JDOPermission MANAGE_METADATA = + new JDOPermission("manageMetadata"); // NOI18N + + /** An instance of JDOPermission to be used for + * setStateManager permission checking. + */ + public final static JDOPermission SET_STATE_MANAGER = + new JDOPermission("setStateManager"); // NOI18N + + /** An instance of JDOPermission to be used for + * closePersistenceManagerFactory permission checking. + * @since 1.0.1 + */ + public final static JDOPermission CLOSE_PERSISTENCE_MANAGER_FACTORY = + new JDOPermission("closePersistenceManagerFactory"); // NOI18N + } diff --git a/api/src/main/java/javax/jdo/spi/PersistenceCapable.java b/api/src/main/java/javax/jdo/spi/PersistenceCapable.java index f27458e85..dd03a9c90 100644 --- a/api/src/main/java/javax/jdo/spi/PersistenceCapable.java +++ b/api/src/main/java/javax/jdo/spi/PersistenceCapable.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -20,641 +20,572 @@ import javax.jdo.PersistenceManager; /** - * A class that can be managed by a binary-compatible JDO implementation must implement this - * interface. - * - *

    This interface defines methods that allow the implementation to manage the instances. It also - * defines methods that allow a JDO aware application to examine the runtime state of instances. For - * example, an application can discover whether the instance is persistent, transactional, dirty, - * new, deleted, or detached; and to get its associated PersistenceManager, object identity, and - * version if it has one. + * A class that can be managed by a binary-compatible JDO implementation + * must implement this interface. * - *

    In the Reference Implementation, the JDO Enhancer modifies the class to implement - * PersistenceCapable prior to loading the class into the runtime environment. The Reference - * Enhancer also adds code to implement the methods defined by PersistenceCapable. + *

    This interface defines methods that allow the implementation to manage + * the instances. It also defines methods that allow a JDO aware + * application to examine the runtime state of instances. For example, + * an application can discover whether the instance is persistent, transactional, + * dirty, new, deleted, or detached; and to get its associated + * PersistenceManager, object identity, and version if it has one. * - *

    The extra methods in the PersistenceCapable interface might be generated by pre-processing a - * .java file, or might be generated from a tool directly. The exact technique for generating the - * extra methods is not specified by JDO. + *

    In the Reference Implementation, the JDO Enhancer modifies the class + * to implement PersistenceCapable prior to loading the class into the runtime + * environment. The Reference Enhancer also adds code to implement the + * methods defined by PersistenceCapable. * - *

    The PersistenceCapable interface is designed to avoid name conflicts in the scope of - * user-defined classes. All of its declared method names are prefixed with 'jdo'. + *

    The extra methods in the PersistenceCapable interface might be generated + * by pre-processing a .java file, or might be generated from a tool directly. + * The exact technique for generating the extra methods is not specified by + * JDO. * + *

    The PersistenceCapable interface is designed to avoid name conflicts + * in the scope of user-defined classes. All of its declared method + * names are prefixed with 'jdo'. * @version 2.0 */ public interface PersistenceCapable { - /** - * If jdoFlags is set to READ_WRITE_OK, then the fields in the default fetch group can be accessed - * for read or write without notifying the StateManager. - */ - static final byte READ_WRITE_OK = 0; - - /** - * If jdoFlags is set to LOAD_REQUIRED, then the fields in the default fetch group cannot be - * accessed for read or write without notifying the StateManager. - */ - static final byte LOAD_REQUIRED = 1; - - /** - * If jdoFlags is set to READ_OK, then the fields in the default fetch group can be accessed for - * read without notifying the StateManager. - */ - static final byte READ_OK = -1; - - /** - * If jdoFieldFlags for a field includes CHECK_READ, then the field has been enhanced to call the - * jdoStateManager on read if the jdoFlags setting is not READ_OK or READ_WRITE_OK. - */ - static final byte CHECK_READ = 1; - - /** - * If jdoFieldFlags for a field includes MEDIATE_READ, then the field has been enhanced to always - * call the jdoStateManager on all reads. - */ - static final byte MEDIATE_READ = 2; - - /** - * If jdoFieldFlags for a field includes CHECK_WRITE, then the field has been enhanced to call the - * jdoStateManager on write if the jdoFlags setting is not READ_WRITE_OK;. - */ - static final byte CHECK_WRITE = 4; - - /** - * If jdoFieldFlags for a field includes MEDIATE_WRITE, then the field has been enhanced to always - * call the jdoStateManager on all writes. - */ - static final byte MEDIATE_WRITE = 8; - - /** - * If jdoFieldFlags for a field includes SERIALIZABLE, then the field is not declared as - * TRANSIENT. - */ - static final byte SERIALIZABLE = 16; - - /** - * Return the associated PersistenceManager if there is one. Transactional and persistent - * instances return the associated PersistenceManager. - * - *

    Transient non-transactional instances return null. - * - *

    This method always delegates to the StateManager if it is non-null. - * - * @return the PersistenceManager associated with this instance. - */ - PersistenceManager jdoGetPersistenceManager(); - - /** - * This method sets the StateManager instance that manages the state of this instance. This method - * is normally used by the StateManager during the process of making an instance persistent, - * transient, or transactional. - * - *

    The caller of this method must have JDOPermission for the instance, if the instance is not - * already owned by a StateManager. If the parameter is null, and the StateManager approves the - * change, then the jdoFlags field will be reset to READ_WRITE_OK. If the parameter is not null, - * and the security manager approves the change, then the jdoFlags field will be reset to - * LOAD_REQUIRED. - * - * @param sm The StateManager which will own this instance, or null to reset the instance to - * transient state - * @throws SecurityException if the caller does not have JDOPermission - * @see JDOPermission - */ - void jdoReplaceStateManager(StateManager sm) throws SecurityException; - - /** - * The owning StateManager uses this method to ask the instance to provide the value of the single - * field identified by fieldNumber. - * - * @param fieldNumber the field whose value is to be provided by a callback to the StateManager's - * providedXXXField method - */ - void jdoProvideField(int fieldNumber); - - /** - * The owning StateManager uses this method to ask the instance to provide the values of the - * multiple fields identified by fieldNumbers. - * - * @param fieldNumbers the fields whose values are to be provided by multiple callbacks to the - * StateManager's providedXXXField method - */ - void jdoProvideFields(int[] fieldNumbers); - - /** - * The owning StateManager uses this method to ask the instance to replace the value of the single - * field identified by number. - * - * @param fieldNumber the field whose value is to be replaced by a callback to the StateManager's - * replacingXXXField method - */ - void jdoReplaceField(int fieldNumber); - - /** - * The owning StateManager uses this method to ask the instance to replace the values of the - * multiple fields identified by number. - * - * @param fieldNumbers the fields whose values are to be replaced by multiple callbacks to the - * StateManager's replacingXXXField method - */ - void jdoReplaceFields(int[] fieldNumbers); - - /** - * The owning StateManager uses this method to ask the instance to replace the value of the flags - * by calling back the StateManager replacingFlags method. - */ - void jdoReplaceFlags(); - - /** - * Copy field values from another instance of the same class to this instance. - * - *

    This method will throw an exception if the other instance is not managed by the same - * StateManager as this instance. - * - * @param other the PC instance from which field values are to be copied - * @param fieldNumbers the field numbers to be copied into this instance - */ - void jdoCopyFields(Object other, int[] fieldNumbers); - - /** - * Explicitly mark this instance and this field dirty. Normally, PersistenceCapable classes are - * able to detect changes made to their fields. However, if a reference to an array is given to a - * method outside the class, and the array is modified, then the persistent instance is not aware - * of the change. This API allows the application to notify the instance that a change was made to - * a field. - * - *

    The field name should be the fully qualified name, including package name and class name of - * the class declaring the field. This allows unambiguous identification of the field to be marked - * dirty. If multiple classes declare the same field, and if the package and class name are not - * provided by the parameter in this API, then the field marked dirty is the field declared by the - * most derived class. - * - *

    Transient instances ignore this method. - * - *

    - * - * @param fieldName the name of the field to be marked dirty. - */ - void jdoMakeDirty(String fieldName); - - /** - * Return a copy of the JDO identity associated with this instance. - * - *

    Persistent instances of PersistenceCapable classes have a JDO identity managed by the - * PersistenceManager. This method returns a copy of the ObjectId that represents the JDO - * identity. - * - *

    Transient instances return null. - * - *

    The ObjectId may be serialized and later restored, and used with a PersistenceManager from - * the same JDO implementation to locate a persistent instance with the same data store identity. - * - *

    If the JDO identity is managed by the application, then the ObjectId may be used with a - * PersistenceManager from any JDO implementation that supports the PersistenceCapable class. - * - *

    If the JDO identity is not managed by the application or the data store, then the ObjectId - * returned is only valid within the current transaction. - * - *

    If the JDO identity is being changed in the transaction, this method returns the object id - * as of the beginning of the current transaction. - * - * @see PersistenceManager#getObjectId(Object pc) - * @see PersistenceManager#getObjectById(Object oid, boolean validate) - * @return a copy of the ObjectId of this instance as of the beginning of the transaction. - */ - Object jdoGetObjectId(); - - /** - * Return a copy of the JDO identity associated with this instance. This method is the same as - * jdoGetObjectId if the identity of the instance has not changed in the current transaction. - * - *

    If the JDO identity is being changed in the transaction, this method returns the current - * object id as modified in the current transaction. - * - * @see #jdoGetObjectId() - * @see PersistenceManager#getObjectId(Object pc) - * @see PersistenceManager#getObjectById(Object oid, boolean validate) - * @return a copy of the ObjectId of this instance as modified in the transaction. - */ - Object jdoGetTransactionalObjectId(); - - /** - * Return the version of this instance. - * - * @return the version - * @since 2.0 - */ - Object jdoGetVersion(); - - /** - * Tests whether this object is dirty. - * - *

    Instances that have been modified, deleted, or newly made persistent in the current - * transaction return true. - * - *

    Transient instances return false. - * - *

    - * - * @see javax.jdo.JDOHelper#isDirty(Object pc) - * @see javax.jdo.JDOHelper#makeDirty(Object pc, String fieldName) - * @see #jdoMakeDirty(String fieldName) - * @return true if this instance has been modified in the current transaction. - */ - boolean jdoIsDirty(); - - /** - * Tests whether this object is transactional. - * - *

    Instances whose state is associated with the current transaction return true. - * - *

    Transient instances return false. - * - *

    - * - * @see javax.jdo.JDOHelper#isTransactional(Object pc) - * @see PersistenceManager#makeTransactional(Object pc) - * @return true if this instance is transactional. - */ - boolean jdoIsTransactional(); - - /** - * Tests whether this object is persistent. Instances that represent persistent objects in the - * data store return true. - * - * @see javax.jdo.JDOHelper#isPersistent(Object pc) - * @see PersistenceManager#makePersistent(Object pc) - * @return true if this instance is persistent. - */ - boolean jdoIsPersistent(); - - /** - * Tests whether this object has been newly made persistent. - * - *

    Instances that have been made persistent in the current transaction return true. - * - *

    Transient instances return false. - * - *

    - * - * @see javax.jdo.JDOHelper#isNew(Object pc) - * @see PersistenceManager#makePersistent(Object pc) - * @return true if this instance was made persistent in the current transaction. - */ - boolean jdoIsNew(); - - /** - * Tests whether this object has been deleted. - * - *

    Instances that have been deleted in the current transaction return true. - * - *

    Transient instances return false. - * - *

    - * - * @see javax.jdo.JDOHelper#isDeleted(Object pc) - * @see PersistenceManager#deletePersistent(Object pc) - * @return true if this instance was deleted in the current transaction. - */ - boolean jdoIsDeleted(); - - /** - * Tests whether this object has been detached. - * - *

    Instances that have been detached return true. - * - *

    Transient instances return false. - * - *

    - * - * @see javax.jdo.JDOHelper#isDetached(Object pc) - * @return true if this instance is detached. - * @since 2.0 - */ - boolean jdoIsDetached(); - - /** - * Return a new instance of this class, with the jdoStateManager set to the parameter, and - * jdoFlags set to LOAD_REQUIRED. - * - *

    This method is used as a performance optimization as an alternative to using reflection to - * construct a new instance. It is used by the JDOImplHelper class method newInstance. - * - * @return a new instance of this class. - * @see JDOImplHelper#newInstance(Class pcClass, StateManager sm) - * @param sm the StateManager that will own the new instance. - */ - PersistenceCapable jdoNewInstance(StateManager sm); - - /** - * Return a new instance of this class, with the jdoStateManager set to the parameter, key fields - * initialized to the values in the oid, and jdoFlags set to LOAD_REQUIRED. - * - *

    This method is used as a performance optimization as an alternative to using reflection to - * construct a new instance of a class that uses application identity. It is used by the - * JDOImplHelper class method newInstance. - * - * @return a new instance of this class. - * @see JDOImplHelper#newInstance(Class pcClass, StateManager sm) - * @param sm the StateManager that will own the new instance. - * @param oid an instance of the object id class (application identity). - */ - PersistenceCapable jdoNewInstance(StateManager sm, Object oid); - - /** - * Create a new instance of the ObjectId class for this PersistenceCapable class and initialize - * the key fields from the instance on which this method is called. This method creates a new - * instance of the class used for JDO identity. It is intended only for application identity. If - * the class has been enhanced for datastore identity, or if the class is abstract, null is - * returned. - * - *

    For classes using single field identity, this method must be called on an instance of a - * persistence-capable class with its primary key field initialized (not null), or a - * JDONullIdentityException is thrown. - * - *

    The instance returned is initialized with the value(s) of the primary key field(s) of the - * instance on which the method is called. - * - * @return the new instance created. - */ - Object jdoNewObjectIdInstance(); - - /** - * Create a new instance of the class used for JDO identity, using the key constructor of the - * object id class. It is intended for single field identity. The identity instance returned has - * no relationship with the values of the primary key fields of the persistence-capable instance - * on which the method is called. If the key is the wrong class for the object id class, null is - * returned. - * - *

    For classes that use single field identity, if the parameter is of one of the following - * types, the behavior must be as specified: - * - *

      - *
    • Number or Character: the parameter must be the single field - * type or the wrapper class of the primitive field type; the parameter is passed to the - * single field identity constructor - *
    • ObjectIdFieldSupplier: the field value is fetched from the - * ObjectIdFieldSupplier and passed to the single field identity constructor - *
    • String: the String is passed to the single field identity constructor - *
    - * - * @return the new instance created. - * @param o the object identity constructor parameter - * @since 2.0 - */ - Object jdoNewObjectIdInstance(Object o); - - /** - * Copy fields from this PersistenceCapable instance to the Object Id instance. For classes using - * single field identity, this method always throws JDOUserException. - * - * @param oid the ObjectId target of the key fields - */ - void jdoCopyKeyFieldsToObjectId(Object oid); - - /** - * Copy fields from an outside source to the key fields in the ObjectId. This method is generated - * in the PersistenceCapable class to generate a call to the field manager for each - * key field in the ObjectId. For example, an ObjectId class that has three key fields - * (int id, - * String name, and Float salary) would have the method generated: - * void jdoCopyKeyFieldsToObjectId - * (ObjectIdFieldSupplier fm, Object objectId) { - * EmployeeKey oid = (EmployeeKey)objectId; - * oid.id = fm.fetchIntField (0); - * oid.name = fm.fetchStringField (1); - * oid.salary = fm.fetchObjectField (2); - * } - * - *

    The implementation is responsible for implementing the ObjectIdFieldSupplier to - * produce the values for the key fields. - * - *

    For classes using single field identity, this method always throws JDOUserException - * . - * - * @param oid the ObjectId target of the copy. - * @param fm the field supplier that supplies the field values. - */ - void jdoCopyKeyFieldsToObjectId(ObjectIdFieldSupplier fm, Object oid); - - /** - * Copy fields to an outside consumer from the key fields in the ObjectId. This method is - * generated in the PersistenceCapable class to generate a call to the field manager - * for each key field in the ObjectId. For example, an ObjectId class that has three key fields - * (int id, - * String name, and Float salary) would have the method generated: - * void copyKeyFieldsFromObjectId(ObjectIdFieldConsumer fm, Object objectId) { - * EmployeeKey oid = (EmployeeKey)objectId; - * fm.storeIntField (0, oid.id); - * fm.storeStringField (1, oid.name); - * fm.storeObjectField (2, oid.salary); - * } - * - *

    The implementation is responsible for implementing the ObjectIdFieldConsumer to - * store the values for the key fields. - * - * @param oid the ObjectId source of the copy. - * @param fm the field manager that receives the field values. - */ - void jdoCopyKeyFieldsFromObjectId(ObjectIdFieldConsumer fm, Object oid); - - /** - * This interface is a convenience interface that allows an instance to implement both - * ObjectIdFieldSupplier and ObjectIdFieldConsumer. - */ - static interface ObjectIdFieldManager extends ObjectIdFieldConsumer, ObjectIdFieldSupplier {} - - /** - * This interface is used to provide fields to the Object id instance. It is used by the method - * copyKeyFieldsToObjectId. When the method is called, the generated code calls the instance of - * ObjectIdFieldManager for each field in the object id. - */ - static interface ObjectIdFieldSupplier { - - /** - * Fetch one field from the field manager. This field will be stored in the proper field of the - * ObjectId. - * - * @param fieldNumber the field number of the key field. - * @return the value of the field to be stored into the ObjectId. + /** If jdoFlags is set to READ_WRITE_OK, then the fields in the default fetch group + * can be accessed for read or write without notifying the StateManager. */ - boolean fetchBooleanField(int fieldNumber); - - /** - * Fetch one field from the field manager. This field will be stored in the proper field of the - * ObjectId. - * - * @param fieldNumber the field number of the key field. - * @return the value of the field to be stored into the ObjectId. + static final byte READ_WRITE_OK = 0; + + /** If jdoFlags is set to LOAD_REQUIRED, then the fields in the default fetch group + * cannot be accessed for read or write without notifying the StateManager. */ - char fetchCharField(int fieldNumber); - - /** - * Fetch one field from the field manager. This field will be stored in the proper field of the - * ObjectId. - * - * @param fieldNumber the field number of the key field. - * @return the value of the field to be stored into the ObjectId. + static final byte LOAD_REQUIRED = 1; + + /** If jdoFlags is set to READ_OK, then the fields in the default fetch group + * can be accessed for read without notifying the StateManager. */ - byte fetchByteField(int fieldNumber); - - /** - * Fetch one field from the field manager. This field will be stored in the proper field of the - * ObjectId. - * - * @param fieldNumber the field number of the key field. - * @return the value of the field to be stored into the ObjectId. + static final byte READ_OK = -1; + + /** If jdoFieldFlags for a field includes CHECK_READ, then + * the field has been enhanced to call the jdoStateManager on read + * if the jdoFlags setting is not READ_OK or READ_WRITE_OK. */ - short fetchShortField(int fieldNumber); - - /** - * Fetch one field from the field manager. This field will be stored in the proper field of the - * ObjectId. - * - * @param fieldNumber the field number of the key field. - * @return the value of the field to be stored into the ObjectId. + static final byte CHECK_READ = 1; + + /** If jdoFieldFlags for a field includes MEDIATE_READ, then + * the field has been enhanced to always call the jdoStateManager + * on all reads. */ - int fetchIntField(int fieldNumber); - - /** - * Fetch one field from the field manager. This field will be stored in the proper field of the - * ObjectId. - * - * @param fieldNumber the field number of the key field. - * @return the value of the field to be stored into the ObjectId. + static final byte MEDIATE_READ = 2; + + /** If jdoFieldFlags for a field includes CHECK_WRITE, + * then the field has been enhanced to call the + * jdoStateManager on write if the jdoFlags setting is not + * READ_WRITE_OK;. */ - long fetchLongField(int fieldNumber); - - /** - * Fetch one field from the field manager. This field will be stored in the proper field of the - * ObjectId. - * - * @param fieldNumber the field number of the key field. - * @return the value of the field to be stored into the ObjectId. + static final byte CHECK_WRITE = 4; + + /** If jdoFieldFlags for a field includes MEDIATE_WRITE, then + * the field has been enhanced to always call the jdoStateManager + * on all writes. */ - float fetchFloatField(int fieldNumber); - - /** - * Fetch one field from the field manager. This field will be stored in the proper field of the - * ObjectId. - * - * @param fieldNumber the field number of the key field. - * @return the value of the field to be stored into the ObjectId. + static final byte MEDIATE_WRITE = 8; + + /** If jdoFieldFlags for a field includes SERIALIZABLE, + * then the field is not declared as TRANSIENT. */ - double fetchDoubleField(int fieldNumber); - - /** - * Fetch one field from the field manager. This field will be stored in the proper field of the - * ObjectId. + static final byte SERIALIZABLE = 16; + + /** Return the associated PersistenceManager if there is one. + * Transactional and persistent instances return the associated + * PersistenceManager. * - * @param fieldNumber the field number of the key field. - * @return the value of the field to be stored into the ObjectId. + *

    Transient non-transactional instances return null. + *

    This method always delegates to the StateManager if it is non-null. + * @return the PersistenceManager associated with this instance. */ - String fetchStringField(int fieldNumber); - - /** - * Fetch one field from the field manager. This field will be stored in the proper field of the - * ObjectId. + PersistenceManager jdoGetPersistenceManager(); + + /** This method sets the StateManager instance that manages the state + * of this instance. This method is normally used by the StateManager + * during the process of making an instance persistent, transient, + * or transactional. * - * @param fieldNumber the field number of the key field. - * @return the value of the field to be stored into the ObjectId. + * The caller of this method must have JDOPermission for the instance, + * if the instance is not already owned by a StateManager. + * If the parameter is null, and the StateManager approves the change, + * then the jdoFlags field will be reset to READ_WRITE_OK. + * If the parameter is not null, and the security manager approves + * the change, then the jdoFlags field will be reset to LOAD_REQUIRED. + * @param sm The StateManager which will own this instance, or null + * to reset the instance to transient state + * @throws SecurityException if the caller does not have JDOPermission + * @see JDOPermission */ - Object fetchObjectField(int fieldNumber); - } - - /** - * This interface is used to store fields from the Object id instance. It is used by the method - * copyKeyFieldsFromObjectId. When the method is called, the generated code calls the instance of - * ObjectIdFieldManager for each field in the object id. - */ - static interface ObjectIdFieldConsumer { - - /** - * Store one field into the field manager. This field was retrieved from the field of the - * ObjectId. - * - * @param fieldNumber the field number of the key field. - * @param value the value of the field from the ObjectId. + void jdoReplaceStateManager(StateManager sm) + throws SecurityException; + + /** The owning StateManager uses this method to ask the instance to + * provide the value of the single field identified by fieldNumber. + * @param fieldNumber the field whose value is to be provided by + * a callback to the StateManager's + * providedXXXField method */ - void storeBooleanField(int fieldNumber, boolean value); - - /** - * Store one field into the field manager. This field was retrieved from the field of the - * ObjectId. - * - * @param fieldNumber the field number of the key field. - * @param value the value of the field from the ObjectId. + void jdoProvideField(int fieldNumber); + + /** The owning StateManager uses this method to ask the instance to + * provide the values of the multiple fields identified by fieldNumbers. + * @param fieldNumbers the fields whose values are to be provided by + * multiple callbacks to the StateManager's + * providedXXXField method */ - void storeCharField(int fieldNumber, char value); - - /** - * Store one field into the field manager. This field was retrieved from the field of the - * ObjectId. + void jdoProvideFields(int[] fieldNumbers); + + /** The owning StateManager uses this method to ask the instance to + * replace the value of the single field identified by number. + * @param fieldNumber the field whose value is to be replaced by + * a callback to the StateManager's + * replacingXXXField method + */ + void jdoReplaceField(int fieldNumber); + + /** The owning StateManager uses this method to ask the instance to + * replace the values of the multiple fields identified by number. + * @param fieldNumbers the fields whose values are to be replaced by + * multiple callbacks to the StateManager's + * replacingXXXField method + */ + void jdoReplaceFields(int[] fieldNumbers); + + /** The owning StateManager uses this method to ask the instance to + * replace the value of the flags by calling back the StateManager + * replacingFlags method. + */ + void jdoReplaceFlags(); + + /** Copy field values from another instance of the same class + * to this instance. + *

    This method will throw an exception if the other instance is + * not managed by the same StateManager as this instance. + * @param other the PC instance from which field values are to be copied + * @param fieldNumbers the field numbers to be copied into this instance + */ + void jdoCopyFields(Object other, int[] fieldNumbers); + + /** Explicitly mark this instance and this field dirty. + * Normally, PersistenceCapable classes are able to detect changes made + * to their fields. However, if a reference to an array is given to a + * method outside the class, and the array is modified, then the + * persistent instance is not aware of the change. This API allows the + * application to notify the instance that a change was made to a field. * - * @param fieldNumber the field number of the key field. - * @param value the value of the field from the ObjectId. + *

    The field name should be the fully qualified name, including package + * name and class name of the class declaring the field. This allows + * unambiguous identification of the field to be marked dirty. + * If multiple classes declare the same field, and + * if the package and class name are not provided by the parameter in + * this API, then the field marked + * dirty is the field declared by the most derived class. + *

    Transient instances ignore this method. + *

    + * @param fieldName the name of the field to be marked dirty. */ - void storeByteField(int fieldNumber, byte value); - - /** - * Store one field into the field manager. This field was retrieved from the field of the - * ObjectId. + void jdoMakeDirty(String fieldName); + + /** Return a copy of the JDO identity associated with this instance. + * + *

    Persistent instances of PersistenceCapable classes have a JDO identity + * managed by the PersistenceManager. This method returns a copy of the + * ObjectId that represents the JDO identity. + * + *

    Transient instances return null. + * + *

    The ObjectId may be serialized + * and later restored, and used with a PersistenceManager from the same JDO + * implementation to locate a persistent instance with the same data store + * identity. + * + *

    If the JDO identity is managed by the application, then the ObjectId may + * be used with a PersistenceManager from any JDO implementation that supports + * the PersistenceCapable class. + * + *

    If the JDO identity is not managed by the application or the data store, + * then the ObjectId returned is only valid within the current transaction. + *

    If the JDO identity is being changed in the transaction, this method + * returns the object id as of the beginning of the current transaction. * - * @param fieldNumber the field number of the key field. - * @param value the value of the field from the ObjectId. + * @see PersistenceManager#getObjectId(Object pc) + * @see PersistenceManager#getObjectById(Object oid, boolean validate) + * @return a copy of the ObjectId of this instance as of the beginning of the transaction. */ - void storeShortField(int fieldNumber, short value); - - /** - * Store one field into the field manager. This field was retrieved from the field of the - * ObjectId. + Object jdoGetObjectId(); + + /** Return a copy of the JDO identity associated with this instance. + * This method is the same as jdoGetObjectId if the identity of the + * instance has not changed in the current transaction. + *

    If the JDO identity is being changed in the transaction, this method + * returns the current object id as modified in the current transaction. * - * @param fieldNumber the field number of the key field. - * @param value the value of the field from the ObjectId. + * @see #jdoGetObjectId() + * @see PersistenceManager#getObjectId(Object pc) + * @see PersistenceManager#getObjectById(Object oid, boolean validate) + * @return a copy of the ObjectId of this instance as modified in the transaction. */ - void storeIntField(int fieldNumber, int value); - - /** - * Store one field into the field manager. This field was retrieved from the field of the - * ObjectId. + Object jdoGetTransactionalObjectId(); + + /** Return the version of this instance. + * @return the version + * @since 2.0 + */ + Object jdoGetVersion(); + + /** Tests whether this object is dirty. * - * @param fieldNumber the field number of the key field. - * @param value the value of the field from the ObjectId. + * Instances that have been modified, deleted, or newly + * made persistent in the current transaction return true. + * + *

    Transient instances return false. + *

    + * @see javax.jdo.JDOHelper#isDirty(Object pc) + * @see javax.jdo.JDOHelper#makeDirty(Object pc, String fieldName) + * @see #jdoMakeDirty(String fieldName) + * @return true if this instance has been modified in the current transaction. */ - void storeLongField(int fieldNumber, long value); - - /** - * Store one field into the field manager. This field was retrieved from the field of the - * ObjectId. + boolean jdoIsDirty(); + + /** Tests whether this object is transactional. + * + * Instances whose state is associated with the current transaction + * return true. * - * @param fieldNumber the field number of the key field. - * @param value the value of the field from the ObjectId. + *

    Transient instances return false. + *

    + * @see javax.jdo.JDOHelper#isTransactional(Object pc) + * @see PersistenceManager#makeTransactional(Object pc) + * @return true if this instance is transactional. */ - void storeFloatField(int fieldNumber, float value); - - /** - * Store one field into the field manager. This field was retrieved from the field of the - * ObjectId. + boolean jdoIsTransactional(); + + /** Tests whether this object is persistent. + * Instances that represent persistent objects in the data store + * return true. + * @see javax.jdo.JDOHelper#isPersistent(Object pc) + * @see PersistenceManager#makePersistent(Object pc) + * @return true if this instance is persistent. + */ + boolean jdoIsPersistent(); + + /** Tests whether this object has been newly made persistent. + * + * Instances that have been made persistent in the current transaction + * return true. * - * @param fieldNumber the field number of the key field. - * @param value the value of the field from the ObjectId. + *

    Transient instances return false. + *

    + * @see javax.jdo.JDOHelper#isNew(Object pc) + * @see PersistenceManager#makePersistent(Object pc) + * @return true if this instance was made persistent + * in the current transaction. */ - void storeDoubleField(int fieldNumber, double value); - - /** - * Store one field into the field manager. This field was retrieved from the field of the - * ObjectId. + boolean jdoIsNew(); + + /** Tests whether this object has been deleted. + * + * Instances that have been deleted in the current transaction return true. * - * @param fieldNumber the field number of the key field. - * @param value the value of the field from the ObjectId. + *

    Transient instances return false. + *

    + * @see javax.jdo.JDOHelper#isDeleted(Object pc) + * @see PersistenceManager#deletePersistent(Object pc) + * @return true if this instance was deleted + * in the current transaction. */ - void storeStringField(int fieldNumber, String value); - - /** - * Store one field into the field manager. This field was retrieved from the field of the - * ObjectId. + boolean jdoIsDeleted(); + + /** Tests whether this object has been detached. * - * @param fieldNumber the field number of the key field. - * @param value the value of the field from the ObjectId. + * Instances that have been detached return true. + * + *

    Transient instances return false. + *

    + * @see javax.jdo.JDOHelper#isDetached(Object pc) + * @return true if this instance is detached. + * @since 2.0 + */ + boolean jdoIsDetached(); + + /** Return a new instance of this class, with the jdoStateManager set to the + * parameter, and jdoFlags set to LOAD_REQUIRED. + *

    This method is used as a performance optimization as an alternative to + * using reflection to construct a new instance. It is used by the + * JDOImplHelper class method newInstance. + * @return a new instance of this class. + * @see JDOImplHelper#newInstance(Class pcClass, StateManager sm) + * @param sm the StateManager that will own the new instance. + */ + PersistenceCapable jdoNewInstance(StateManager sm); + + /** Return a new instance of this class, with the jdoStateManager set to the + * parameter, key fields initialized to the values in the oid, and jdoFlags + * set to LOAD_REQUIRED. + *

    This method is used as a performance optimization as an alternative to + * using reflection to construct a new instance of a class that uses + * application identity. It is used by the + * JDOImplHelper class method newInstance. + * @return a new instance of this class. + * @see JDOImplHelper#newInstance(Class pcClass, StateManager sm) + * @param sm the StateManager that will own the new instance. + * @param oid an instance of the object id class (application identity). + */ + PersistenceCapable jdoNewInstance(StateManager sm, Object oid); + + /** Create a new instance of the + * ObjectId class for this PersistenceCapable class and initialize + * the key fields from the instance on which this method is called. + * This method creates a new instance of the class used for JDO identity. + * It is intended only for application identity. If the class has been + * enhanced for datastore identity, or if the class is abstract, + * null is returned. + *

    For classes using single field identity, this method must be called + * on an instance of a persistence-capable class with its primary key + * field initialized (not null), or a + * JDONullIdentityException is thrown. + *

    The instance returned is initialized with the value(s) of the + * primary key field(s) of the instance on which the method is called. + * @return the new instance created. + */ + Object jdoNewObjectIdInstance(); + + /** Create a new instance of the class used for JDO identity, using the + * key constructor of the object id class. It is intended for single + * field identity. The identity + * instance returned has no relationship with the values of the primary key + * fields of the persistence-capable instance on which the method is called. + * If the key is the wrong class for the object id class, null is returned. + *

    For classes that use single field identity, if the parameter is + * of one of the following types, the behavior must be as specified: + *

    • Number or Character: the + * parameter must be the single field + * type or the wrapper class of the primitive field type; the parameter + * is passed to the single field identity constructor + *
    • ObjectIdFieldSupplier: the field value + * is fetched from the ObjectIdFieldSupplier and passed to the + * single field identity constructor + *
    • String: the String is passed to the + * single field identity constructor + *
    + * @return the new instance created. + * @param o the object identity constructor parameter + * @since 2.0 + */ + Object jdoNewObjectIdInstance(Object o); + + /** Copy fields from this PersistenceCapable instance to the Object Id + * instance. For classes using single field identity, this method always + * throws JDOUserException. + * @param oid the ObjectId target of the key fields + */ + void jdoCopyKeyFieldsToObjectId(Object oid); + + /** Copy fields from an outside source to the key fields in the ObjectId. + * This method is generated in the PersistenceCapable + * class to generate + * a call to the field manager for each key field in the ObjectId. For + * example, an ObjectId class that has three key fields (int id, + * String name, and Float salary) would have the method generated: + * + * void jdoCopyKeyFieldsToObjectId + * (ObjectIdFieldSupplier fm, Object objectId) { + * EmployeeKey oid = (EmployeeKey)objectId; + * oid.id = fm.fetchIntField (0); + * oid.name = fm.fetchStringField (1); + * oid.salary = fm.fetchObjectField (2); + * } + *

    The implementation is responsible for implementing the + * ObjectIdFieldSupplier to produce the values + * for the key fields. + *

    For classes using single field identity, this method always + * throws JDOUserException. + * @param oid the ObjectId target of the copy. + * @param fm the field supplier that supplies the field values. + */ + void jdoCopyKeyFieldsToObjectId(ObjectIdFieldSupplier fm, Object oid); + + /** Copy fields to an outside consumer from the key fields in the ObjectId. + * This method is generated in the PersistenceCapable + * class to generate + * a call to the field manager for each key field in the ObjectId. For + * example, an ObjectId class that has three key fields (int id, + * String name, and Float salary) would have the method generated: + * + * void copyKeyFieldsFromObjectId(ObjectIdFieldConsumer fm, Object objectId) { + * EmployeeKey oid = (EmployeeKey)objectId; + * fm.storeIntField (0, oid.id); + * fm.storeStringField (1, oid.name); + * fm.storeObjectField (2, oid.salary); + * } + *

    The implementation is responsible for implementing the + * ObjectIdFieldConsumer to store the values for the + * key fields. + * @param oid the ObjectId source of the copy. + * @param fm the field manager that receives the field values. + */ + void jdoCopyKeyFieldsFromObjectId(ObjectIdFieldConsumer fm, Object oid); + + /** This interface is a convenience interface that allows an instance to + * implement both ObjectIdFieldSupplier and + * ObjectIdFieldConsumer. + */ + static interface ObjectIdFieldManager extends ObjectIdFieldConsumer, ObjectIdFieldSupplier {} + + /** This interface is used to provide fields to the Object id instance. It is used + * by the method copyKeyFieldsToObjectId. When the method is called, the + * generated code calls the instance of ObjectIdFieldManager for each field in + * the object id. + */ + static interface ObjectIdFieldSupplier { + + /** Fetch one field from the field manager. This field will be stored in the + * proper field of the ObjectId. + * @param fieldNumber the field number of the key field. + * @return the value of the field to be stored into the ObjectId. + */ + boolean fetchBooleanField(int fieldNumber); + + /** Fetch one field from the field manager. This field will be stored in the + * proper field of the ObjectId. + * @param fieldNumber the field number of the key field. + * @return the value of the field to be stored into the ObjectId. + */ + char fetchCharField(int fieldNumber); + + /** Fetch one field from the field manager. This field will be stored in the + * proper field of the ObjectId. + * @param fieldNumber the field number of the key field. + * @return the value of the field to be stored into the ObjectId. + */ + byte fetchByteField(int fieldNumber); + + /** Fetch one field from the field manager. This field will be stored in the + * proper field of the ObjectId. + * @param fieldNumber the field number of the key field. + * @return the value of the field to be stored into the ObjectId. + */ + short fetchShortField(int fieldNumber); + + /** Fetch one field from the field manager. This field will be stored in the + * proper field of the ObjectId. + * @param fieldNumber the field number of the key field. + * @return the value of the field to be stored into the ObjectId. + */ + int fetchIntField(int fieldNumber); + + /** Fetch one field from the field manager. This field will be stored in the + * proper field of the ObjectId. + * @param fieldNumber the field number of the key field. + * @return the value of the field to be stored into the ObjectId. + */ + long fetchLongField(int fieldNumber); + + /** Fetch one field from the field manager. This field will be stored in the + * proper field of the ObjectId. + * @param fieldNumber the field number of the key field. + * @return the value of the field to be stored into the ObjectId. + */ + float fetchFloatField(int fieldNumber); + + /** Fetch one field from the field manager. This field will be stored in the + * proper field of the ObjectId. + * @param fieldNumber the field number of the key field. + * @return the value of the field to be stored into the ObjectId. + */ + double fetchDoubleField(int fieldNumber); + + /** Fetch one field from the field manager. This field will be stored in the + * proper field of the ObjectId. + * @param fieldNumber the field number of the key field. + * @return the value of the field to be stored into the ObjectId. + */ + String fetchStringField(int fieldNumber); + + /** Fetch one field from the field manager. This field will be stored in the + * proper field of the ObjectId. + * @param fieldNumber the field number of the key field. + * @return the value of the field to be stored into the ObjectId. + */ + Object fetchObjectField(int fieldNumber); + } + + /** This interface is used to store fields from the Object id instance. It is used + * by the method copyKeyFieldsFromObjectId. When the method is called, the + * generated code calls the instance of ObjectIdFieldManager for each field in + * the object id. */ - void storeObjectField(int fieldNumber, Object value); - } + static interface ObjectIdFieldConsumer { + + /** Store one field into the field manager. This field was retrieved from + * the field of the ObjectId. + * @param fieldNumber the field number of the key field. + * @param value the value of the field from the ObjectId. + */ + void storeBooleanField(int fieldNumber, boolean value); + + /** Store one field into the field manager. This field was retrieved from + * the field of the ObjectId. + * @param fieldNumber the field number of the key field. + * @param value the value of the field from the ObjectId. + */ + void storeCharField(int fieldNumber, char value); + + /** Store one field into the field manager. This field was retrieved from + * the field of the ObjectId. + * @param fieldNumber the field number of the key field. + * @param value the value of the field from the ObjectId. + */ + void storeByteField(int fieldNumber, byte value); + + /** Store one field into the field manager. This field was retrieved from + * the field of the ObjectId. + * @param fieldNumber the field number of the key field. + * @param value the value of the field from the ObjectId. + */ + void storeShortField(int fieldNumber, short value); + + /** Store one field into the field manager. This field was retrieved from + * the field of the ObjectId. + * @param fieldNumber the field number of the key field. + * @param value the value of the field from the ObjectId. + */ + void storeIntField(int fieldNumber, int value); + + /** Store one field into the field manager. This field was retrieved from + * the field of the ObjectId. + * @param fieldNumber the field number of the key field. + * @param value the value of the field from the ObjectId. + */ + void storeLongField(int fieldNumber, long value); + + /** Store one field into the field manager. This field was retrieved from + * the field of the ObjectId. + * @param fieldNumber the field number of the key field. + * @param value the value of the field from the ObjectId. + */ + void storeFloatField(int fieldNumber, float value); + + /** Store one field into the field manager. This field was retrieved from + * the field of the ObjectId. + * @param fieldNumber the field number of the key field. + * @param value the value of the field from the ObjectId. + */ + void storeDoubleField(int fieldNumber, double value); + + /** Store one field into the field manager. This field was retrieved from + * the field of the ObjectId. + * @param fieldNumber the field number of the key field. + * @param value the value of the field from the ObjectId. + */ + void storeStringField(int fieldNumber, String value); + + /** Store one field into the field manager. This field was retrieved from + * the field of the ObjectId. + * @param fieldNumber the field number of the key field. + * @param value the value of the field from the ObjectId. + */ + void storeObjectField(int fieldNumber, Object value); + } } diff --git a/api/src/main/java/javax/jdo/spi/RegisterClassEvent.java b/api/src/main/java/javax/jdo/spi/RegisterClassEvent.java index c6d3a84fb..3f477798a 100644 --- a/api/src/main/java/javax/jdo/spi/RegisterClassEvent.java +++ b/api/src/main/java/javax/jdo/spi/RegisterClassEvent.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -25,96 +25,96 @@ import java.util.EventObject; /** - * A RegisterClassEvent event gets delivered whenever a persistence-capable class - * registers itself with the JDOImplHelper. + * A RegisterClassEvent event gets delivered whenever a persistence-capable + * class registers itself with the JDOImplHelper. * * @version 1.0 */ -public class RegisterClassEvent extends EventObject { - private static final long serialVersionUID = 945917130591776973L; - - /** The class object of the registered persistence-capable class */ - protected Class pcClass; +public class RegisterClassEvent extends EventObject +{ + private static final long serialVersionUID = 945917130591776973L; - /** The names of managed fields of the persistence-capable class */ - protected String[] fieldNames; + /** The class object of the registered persistence-capable class */ + protected Class pcClass; - /** The types of managed fields of the persistence-capable class */ - protected Class[] fieldTypes; + /** The names of managed fields of the persistence-capable class */ + protected String[] fieldNames; - /** The flags of managed fields of the persistence-capable class */ - protected byte[] fieldFlags; + /** The types of managed fields of the persistence-capable class */ + protected Class[] fieldTypes; - /** */ - protected Class persistenceCapableSuperclass; + /** The flags of managed fields of the persistence-capable class */ + protected byte[] fieldFlags; - /** - * Constructs a new RegisterClassEvent. - * - * @param helper the JDOImplHelper instance - * @param registeredClass the persistence-capable class - * @param fieldNames the names of the managed fields - * @param fieldTypes the types of the managed fields - * @param fieldFlags the flags of the managed fields - * @param persistenceCapableSuperclass the persistence-capable superclass - */ - public RegisterClassEvent( - JDOImplHelper helper, - Class registeredClass, - String[] fieldNames, - Class[] fieldTypes, - byte[] fieldFlags, - Class persistenceCapableSuperclass) { - super(helper); - this.pcClass = registeredClass; - this.fieldNames = fieldNames; - this.fieldTypes = fieldTypes; - this.fieldFlags = fieldFlags; - this.persistenceCapableSuperclass = persistenceCapableSuperclass; - } + /** */ + protected Class persistenceCapableSuperclass; - /** - * Returns the class object of the registered persistence-capable class. - * - * @return the persistence-capable class. - */ - public Class getRegisteredClass() { - return pcClass; - } + /** + * Constructs a new RegisterClassEvent. + * @param helper the JDOImplHelper instance + * @param registeredClass the persistence-capable class + * @param fieldNames the names of the managed fields + * @param fieldTypes the types of the managed fields + * @param fieldFlags the flags of the managed fields + * @param persistenceCapableSuperclass the persistence-capable superclass + **/ + public RegisterClassEvent(JDOImplHelper helper, + Class registeredClass, + String[] fieldNames, + Class[] fieldTypes, + byte[] fieldFlags, + Class persistenceCapableSuperclass) + { + super(helper); + this.pcClass = registeredClass; + this.fieldNames = fieldNames; + this.fieldTypes = fieldTypes; + this.fieldFlags = fieldFlags; + this.persistenceCapableSuperclass = persistenceCapableSuperclass; + } - /** - * Returns the names of the managed field of the persistence-capable class. - * - * @return the names of the managed fields - */ - public String[] getFieldNames() { - return fieldNames; - } + /** + * Returns the class object of the registered persistence-capable class. + * @return the persistence-capable class. + */ + public Class getRegisteredClass() + { + return pcClass; + } + + /** + * Returns the names of the managed field of the persistence-capable class. + * @return the names of the managed fields + */ + public String[] getFieldNames() + { + return fieldNames; + } - /** - * Returns the types of the managed field of the persistence-capable class. - * - * @return the types of the managed fields - */ - public Class[] getFieldTypes() { - return fieldTypes; - } + /** + * Returns the types of the managed field of the persistence-capable class. + * @return the types of the managed fields + */ + public Class[] getFieldTypes() + { + return fieldTypes; + } - /** - * Returns the flags of the managed field of the persistence-capable class. - * - * @return the flags of the managed fields - */ - public byte[] getFieldFlags() { - return fieldFlags; - } + /** + * Returns the flags of the managed field of the persistence-capable class. + * @return the flags of the managed fields + */ + public byte[] getFieldFlags() + { + return fieldFlags; + } - /** - * Returns the class object of the persistence-capable superclass. - * - * @return the persistence-capable superclass. - */ - public Class getPersistenceCapableSuperclass() { - return persistenceCapableSuperclass; - } -} + /** + * Returns the class object of the persistence-capable superclass. + * @return the persistence-capable superclass. + */ + public Class getPersistenceCapableSuperclass() + { + return persistenceCapableSuperclass; + } +} \ No newline at end of file diff --git a/api/src/main/java/javax/jdo/spi/RegisterClassListener.java b/api/src/main/java/javax/jdo/spi/RegisterClassListener.java index dc0b0fdfe..0fdc61b59 100644 --- a/api/src/main/java/javax/jdo/spi/RegisterClassListener.java +++ b/api/src/main/java/javax/jdo/spi/RegisterClassListener.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -25,18 +25,20 @@ import java.util.EventListener; /** - * A "RegisterClassEvent" event gets fired whenever a persistence-capable class is loaded and gets - * registered with the JDOImplHelper. You can register a RegisterClassListener - * so as to be notified of any registration of a persistence-capable class. + * A "RegisterClassEvent" event gets fired whenever a persistence-capable class + * is loaded and gets registered with the JDOImplHelper. You can register a + * RegisterClassListener so as to be notified of any registration of a + * persistence-capable class. * * @version 1.0 */ -public interface RegisterClassListener extends EventListener { - /** - * This method gets called when a persistence-capable class is registered. - * - * @param event a RegisterClassEvent instance describing the registered class plus - * metadata. - */ - public void registerClass(RegisterClassEvent event); +public interface RegisterClassListener + extends EventListener +{ + /** + * This method gets called when a persistence-capable class is registered. + * @param event a RegisterClassEvent instance describing the registered + * class plus metadata. + */ + public void registerClass(RegisterClassEvent event); } diff --git a/api/src/main/java/javax/jdo/spi/StateInterrogation.java b/api/src/main/java/javax/jdo/spi/StateInterrogation.java index dc492c6af..8e3bdfd4e 100644 --- a/api/src/main/java/javax/jdo/spi/StateInterrogation.java +++ b/api/src/main/java/javax/jdo/spi/StateInterrogation.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,224 +19,234 @@ * StateInterrogation.java * */ - + package javax.jdo.spi; import javax.jdo.PersistenceManager; /** - * This interface is implemented by a non-binary-compatible JDO implementation to provide state - * interrogation for non-enhanced persistent classes. + * This interface is implemented by a non-binary-compatible JDO implementation + * to provide state interrogation for non-enhanced persistent classes. * - *

    A call to JDOHelper to get the status of an instance is handled internally if the parameter - * instance implements PersistenceCapable. For non-binary-compatible implementations, there is no - * requirement that persistent instances implement PersistenceCapable. Therefore, if the parameter - * does not implement PersistenceCapable, JDOHelper delegates to all registered instances of - * StateInterrogation until an instance can handle the request. - * - *

    For JDOHelper isXXX methods, which return boolean, the corresponding method in - * StateInterrogation returns Boolean. If the return value is null then the - * StateInterrogation does not recognize the parameter as being handled by it. A non-null return + *

    A call to JDOHelper to get the status of an instance is handled + * internally if the parameter instance implements PersistenceCapable. + * For non-binary-compatible implementations, there is no requirement + * that persistent instances implement PersistenceCapable. Therefore, + * if the parameter does not implement PersistenceCapable, JDOHelper + * delegates to all registered instances of StateInterrogation until + * an instance can handle the request. + *

    For JDOHelper isXXX methods, which return boolean, the + * corresponding method in StateInterrogation returns Boolean. If the + * return value is null then the StateInterrogation does + * not recognize the parameter as being handled by it. A non-null return * value indicates that the implementation has determined the answer. - * - *

    For JDOHelper getXXX methods, which return an Object, each registered StateInterrogation is - * given the parameter until one of them returns a non-null value, which is passed to the caller. - * - *

    For JDOHelper makeDirty, each registered StateInterrogation is given the parameter until one - * of them returns true, indicating that it has handled the call. An instance that implements this - * interface must be registered with the {@link JDOImplHelper}. - * + *

    For JDOHelper getXXX methods, which return an Object, each + * registered StateInterrogation is given the parameter until one of + * them returns a non-null value, which is passed to the caller. + *

    For JDOHelper makeDirty, each + * registered StateInterrogation is given the parameter until one of + * them returns true, indicating that it has handled the call. + * An instance that implements this interface must be registered with the + * {@link JDOImplHelper}. * @version 2.0 * @since 2.0 */ public interface StateInterrogation { - /** - * Tests whether the parameter instance is persistent. - * - *

    Instances that represent persistent objects in the data store return Boolean.TRUE - * . - * - *

    Instances known by the implementation to be non-persistent return Boolean.FALSE - * . - * - *

    Instances not recognized by the implementation return null. - * - * @see PersistenceManager#makePersistent(Object pc) - * @see PersistenceCapable#jdoIsPersistent() - * @param pc the instance. - * @return Boolean.TRUE if the parameter instance is persistent. - */ - Boolean isPersistent(Object pc); - - /** - * Tests whether the parameter instance is transactional. - * - *

    Instances whose state is associated with the current transaction return Boolean.TRUE - * . - * - *

    Instances known by the implementation to be non-transactional return Boolean.FALSE - * . - * - *

    Instances not recognized by the implementation return null. - * - * @see PersistenceCapable#jdoIsTransactional() - * @param pc the instance. - * @return Boolean.TRUE if the parameter instance is transactional. - */ - Boolean isTransactional(Object pc); - - /** - * Tests whether the parameter instance is dirty. - * - *

    Instances that have been modified, deleted, newly made persistent in the current - * transaction, or modified while detached return Boolean.TRUE. - * - *

    Instances known by the implementation to be non-dirty return Boolean.FALSE. - * - *

    Instances not recognized by the implementation return null. - * - * @see StateManager#makeDirty(PersistenceCapable pc, String fieldName) - * @see PersistenceCapable#jdoIsDirty() - * @param pc the instance. - * @return Boolean.TRUE if the parameter instance has been modified in the current - * transaction, or while detached. - */ - Boolean isDirty(Object pc); - /** - * Tests whether the parameter instance has been newly made persistent. - * - *

    Instances that have been made persistent in the current transaction return - * Boolean.TRUE. - * - *

    Instances known by the implementation to be non-new return Boolean.FALSE. - * - *

    Instances not recognized by the implementation return null. - * - * @see PersistenceManager#makePersistent(Object pc) - * @see PersistenceCapable#jdoIsNew() - * @param pc the instance. - * @return Boolean.TRUE if the parameter instance was made persistent in the current - * transaction. - */ - Boolean isNew(Object pc); + /** Tests whether the parameter instance is persistent. + * + * Instances that represent persistent objects in the data store + * return Boolean.TRUE. + * + *

    Instances known by the implementation to be non-persistent + * return Boolean.FALSE. + * + *

    Instances not recognized by the implementation return + * null. + * + * @see PersistenceManager#makePersistent(Object pc) + * @see PersistenceCapable#jdoIsPersistent() + * @param pc the instance. + * @return Boolean.TRUE if the parameter instance is persistent. + */ + Boolean isPersistent (Object pc); - /** - * Tests whether the parameter instance has been deleted. - * - *

    Instances that have been deleted in the current transaction return Boolean.TRUE - * . - * - *

    Instances known by the implementation to be non-deleted return Boolean.FALSE. - * - *

    Instances not recognized by the implementation return null. - * - * @see PersistenceManager#deletePersistent(Object pc) - * @see PersistenceCapable#jdoIsDeleted() - * @param pc the instance. - * @return Boolean.TRUE if the parameter instance was deleted in the current - * transaction. - */ - Boolean isDeleted(Object pc); + /** Tests whether the parameter instance is transactional. + * + * Instances whose state is associated with the current transaction + * return Boolean.TRUE. + * + *

    Instances known by the implementation to be non-transactional + * return Boolean.FALSE. + * + *

    Instances not recognized by the implementation return + * null. + * + * @see PersistenceCapable#jdoIsTransactional() + * @param pc the instance. + * @return Boolean.TRUE if the parameter instance is transactional. + */ + Boolean isTransactional (Object pc); + + /** Tests whether the parameter instance is dirty. + * + * Instances that have been modified, deleted, newly + * made persistent in the current transaction, + * or modified while detached return Boolean.TRUE. + * + *

    Instances known by the implementation to be non-dirty + * return Boolean.FALSE. + * + *

    Instances not recognized by the implementation return + * null. + * + * @see StateManager#makeDirty(PersistenceCapable pc, String fieldName) + * @see PersistenceCapable#jdoIsDirty() + * @param pc the instance. + * @return Boolean.TRUE if the parameter instance has been modified + * in the current transaction, or while detached. + */ + Boolean isDirty (Object pc); - /** - * Tests whether the parameter instance is detached. - * - *

    Instances that are detached return Boolean.TRUE. - * - *

    Instances known by the implementation to be non-detached return Boolean.FALSE. - * - *

    Instances not recognized by the implementation return null. - * - * @see PersistenceManager#detachCopy(Object pc) - * @see PersistenceCapable#jdoIsDeleted() - * @param pc the instance. - * @return Boolean.TRUE if the parameter instance is detached. - */ - Boolean isDetached(Object pc); + /** Tests whether the parameter instance has been newly made persistent. + * + * Instances that have been made persistent in the current transaction + * return Boolean.TRUE. + * + *

    Instances known by the implementation to be non-new + * return Boolean.FALSE. + * + *

    Instances not recognized by the implementation return + * null. + * + * @see PersistenceManager#makePersistent(Object pc) + * @see PersistenceCapable#jdoIsNew() + * @param pc the instance. + * @return Boolean.TRUE if the parameter instance was made persistent + * in the current transaction. + */ + Boolean isNew (Object pc); - /** - * Return the associated PersistenceManager if there is one. Transactional and - * persistent instances return the associated PersistenceManager. - * - *

    Transient non-transactional instances return null. - * - *

    Instances unknown by the implementation return null. - * - * @see PersistenceCapable#jdoGetPersistenceManager() - * @param pc the instance. - * @return the PersistenceManager associated with the parameter instance. - */ - PersistenceManager getPersistenceManager(Object pc); + /** Tests whether the parameter instance has been deleted. + * + * Instances that have been deleted in the current transaction + * return Boolean.TRUE. + * + *

    Instances known by the implementation to be non-deleted + * return Boolean.FALSE. + * + *

    Instances not recognized by the implementation return + * null. + * + * @see PersistenceManager#deletePersistent(Object pc) + * @see PersistenceCapable#jdoIsDeleted() + * @param pc the instance. + * @return Boolean.TRUE if the parameter instance was deleted + * in the current transaction. + */ + Boolean isDeleted (Object pc); - /** - * Return a copy of the JDO identity associated with the parameter instance. - * - *

    Persistent instances of PersistenceCapable classes have a JDO identity managed - * by the PersistenceManager. This method returns a copy of the ObjectId that - * represents the JDO identity. - * - *

    Instances unknown by the implementation return null. - * - *

    The ObjectId may be serialized and later restored, and used with a PersistenceManager - * from the same JDO implementation to locate a persistent instance with the same data - * store identity. - * - *

    If the JDO identity is managed by the application, then the ObjectId may be used with a - * PersistenceManager from any JDO implementation that supports the - * PersistenceCapable class. - * - *

    If the JDO identity is not managed by the application or the data store, then the ObjectId - * returned is only valid within the current transaction. - * - *

    - * - * @see PersistenceManager#getObjectId(Object pc) - * @see PersistenceCapable#jdoGetObjectId() - * @see PersistenceManager#getObjectById(Object oid, boolean validate) - * @param pc the instance. - * @return a copy of the ObjectId of the parameter instance as of the beginning of the - * transaction. - */ - Object getObjectId(Object pc); + /** Tests whether the parameter instance is detached. + * + * Instances that are detached return Boolean.TRUE. + * + *

    Instances known by the implementation to be non-detached + * return Boolean.FALSE. + * + *

    Instances not recognized by the implementation return + * null. + * + * @see PersistenceManager#detachCopy(Object pc) + * @see PersistenceCapable#jdoIsDeleted() + * @param pc the instance. + * @return Boolean.TRUE if the parameter instance is detached. + */ + Boolean isDetached (Object pc); - /** - * Return a copy of the JDO identity associated with the parameter instance. - * - *

    Instances unknown by the implementation return null. - * - * @see PersistenceCapable#jdoGetTransactionalObjectId() - * @see PersistenceManager#getObjectById(Object oid, boolean validate) - * @param pc the instance. - * @return a copy of the ObjectId of the parameter instance as modified in this transaction. - */ - Object getTransactionalObjectId(Object pc); + /** Return the associated PersistenceManager if there is one. + * Transactional and persistent instances return the associated + * PersistenceManager. + * + *

    Transient non-transactional instances return null. + *

    Instances unknown by the implementation return null. + * @see PersistenceCapable#jdoGetPersistenceManager() + * @param pc the instance. + * @return the PersistenceManager associated with the + * parameter instance. + */ + PersistenceManager getPersistenceManager (Object pc); + + /** Return a copy of the JDO identity associated with the parameter + * instance. + * + *

    Persistent instances of PersistenceCapable classes + * have a JDO identity + * managed by the PersistenceManager. This method returns + * a copy of the + * ObjectId that represents the JDO identity. + * + *

    Instances unknown by the implementation return null. + *

    The ObjectId may be serialized + * and later restored, and used with a PersistenceManager + * from the same JDO + * implementation to locate a persistent instance with the same data store + * identity. + * + *

    If the JDO identity is managed by the application, then the ObjectId + * may be used with a PersistenceManager from any JDO + * implementation that supports + * the PersistenceCapable class. + * + *

    If the JDO identity is not managed by the application or the data + * store, then the ObjectId returned is only valid within the current + * transaction. + *

    + * @see PersistenceManager#getObjectId(Object pc) + * @see PersistenceCapable#jdoGetObjectId() + * @see PersistenceManager#getObjectById(Object oid, boolean validate) + * @param pc the instance. + * @return a copy of the ObjectId of the parameter instance as of the + * beginning of the transaction. + */ + Object getObjectId (Object pc); - /** - * Return the version of the parameter instance. - * - *

    Instances unknown by the implementation return null. - * - * @see PersistenceCapable#jdoGetVersion() - * @param pc the instance. - * @return a copy of the ObjectId of the parameter instance as modified in this transaction. - */ - Object getVersion(Object pc); + /** Return a copy of the JDO identity associated with the parameter + * instance. + * + *

    Instances unknown by the implementation return null. + * @see PersistenceCapable#jdoGetTransactionalObjectId() + * @see PersistenceManager#getObjectById(Object oid, boolean validate) + * @param pc the instance. + * @return a copy of the ObjectId of the parameter instance as modified + * in this transaction. + */ + Object getTransactionalObjectId (Object pc); + + /** Return the version of the parameter instance. + * + *

    Instances unknown by the implementation return null. + * @see PersistenceCapable#jdoGetVersion() + * @param pc the instance. + * @return a copy of the ObjectId of the parameter instance as modified + * in this transaction. + */ + Object getVersion (Object pc); + + /** Explicitly mark the parameter instance and field dirty. + * Normally, PersistenceCapable classes are able to detect + * changes made + * to their fields. However, if a reference to an array is given to a + * method outside the class, and the array is modified, then the + * persistent instance is not aware of the change. This API allows the + * application to notify the instance that a change was made to a field. + * + *

    Instances unknown by the implementation are unaffected. + * @see PersistenceCapable#jdoMakeDirty(String fieldName) + * @param pc the instance. + * @param fieldName the name of the field to be marked dirty. + * @return Whether it was made dirty + */ + boolean makeDirty (Object pc, String fieldName); - /** - * Explicitly mark the parameter instance and field dirty. Normally, PersistenceCapable - * classes are able to detect changes made to their fields. However, if a reference to an - * array is given to a method outside the class, and the array is modified, then the persistent - * instance is not aware of the change. This API allows the application to notify the instance - * that a change was made to a field. - * - *

    Instances unknown by the implementation are unaffected. - * - * @see PersistenceCapable#jdoMakeDirty(String fieldName) - * @param pc the instance. - * @param fieldName the name of the field to be marked dirty. - * @return Whether it was made dirty - */ - boolean makeDirty(Object pc, String fieldName); } diff --git a/api/src/main/java/javax/jdo/spi/StateManager.java b/api/src/main/java/javax/jdo/spi/StateManager.java index 6ce711e31..209a14eea 100644 --- a/api/src/main/java/javax/jdo/spi/StateManager.java +++ b/api/src/main/java/javax/jdo/spi/StateManager.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,576 +19,498 @@ import javax.jdo.PersistenceManager; -/** - * This interface is the point of contact between managed instances of PersistenceCapable - * classes and the JDO implementation. It contains the methods used by - * PersistenceCapable instances to delegate behavior to the JDO implementation. - * - *

    Each managed PersistenceCapable instance contains a reference to a - * StateManager. A StateManager might manage one or multiple instances of - * PersistenceCapable instances, at the choice of the implementation. +/** This interface is the point of contact between managed instances of + * PersistenceCapable classes and the JDO implementation. It + * contains the methods used by PersistenceCapable instances to + * delegate behavior to the JDO implementation. + *

    Each managed PersistenceCapable instance contains a reference + * to a StateManager. A StateManager might manage one + * or multiple instances of PersistenceCapable instances, at the + * choice of the implementation. * * @version 2.0 + * */ public interface StateManager { - - /** - * The owning StateManager uses this method to supply the value of the flags to the - * PersistenceCapable instance. - * - * @param pc the calling PersistenceCapable instance - * @return the value of jdoFlags to be stored in the PersistenceCapable - * instance - */ - byte replacingFlags(PersistenceCapable pc); - - /** - * Replace the current value of jdoStateManager. - * - *

    This method is called by the PersistenceCapable whenever - * jdoReplaceStateManager is called and there is already an owning StateManager - * . This is a security precaution to ensure that the owning StateManager is - * the only source of any change to its reference in the PersistenceCapable. - * - * @return the new value for the jdoStateManager - * @param pc the calling PersistenceCapable instance - * @param sm the proposed new value for the jdoStateManager - */ - StateManager replacingStateManager(PersistenceCapable pc, StateManager sm); - - /** - * Tests whether this object is dirty. - * - *

    Instances that have been modified, deleted, or newly made persistent in the current - * transaction return true. - * - *

    Transient nontransactional instances return false. - * - *

    - * - * @see PersistenceCapable#jdoMakeDirty(String fieldName) - * @param pc the calling PersistenceCapable instance - * @return true if this instance has been modified in the current transaction. - */ - boolean isDirty(PersistenceCapable pc); - - /** - * Tests whether this object is transactional. - * - *

    Instances that respect transaction boundaries return true. These instances - * include transient instances made transactional as a result of being the target of a - * makeTransactional method call; newly made persistent or deleted persistent instances; - * persistent instances read in data store transactions; and persistent instances modified in - * optimistic transactions. - * - *

    Transient nontransactional instances return false. - * - *

    - * - * @param pc the calling PersistenceCapable instance - * @return true if this instance is transactional. - */ - boolean isTransactional(PersistenceCapable pc); - - /** - * Tests whether this object is persistent. - * - *

    Instances whose state is stored in the data store return true. - * - *

    Transient instances return false. - * - *

    - * - * @see PersistenceManager#makePersistent(Object pc) - * @param pc the calling PersistenceCapable instance - * @return true if this instance is persistent. - */ - boolean isPersistent(PersistenceCapable pc); - - /** - * Tests whether this object has been newly made persistent. - * - *

    Instances that have been made persistent in the current transaction return true - * . - * - *

    Transient instances return false. - * - *

    - * - * @see PersistenceManager#makePersistent(Object pc) - * @param pc the calling PersistenceCapable instance - * @return true if this instance was made persistent in the current transaction. - */ - boolean isNew(PersistenceCapable pc); - - /** - * Tests whether this object has been deleted. - * - *

    Instances that have been deleted in the current transaction return true. - * - *

    Transient instances return false. - * - *

    - * - * @see PersistenceManager#deletePersistent(Object pc) - * @param pc the calling PersistenceCapable instance - * @return true if this instance was deleted in the current transaction. - */ - boolean isDeleted(PersistenceCapable pc); - - /** - * Return the PersistenceManager that owns this instance. - * - * @param pc the calling PersistenceCapable instance - * @return the PersistenceManager that owns this instance - */ - PersistenceManager getPersistenceManager(PersistenceCapable pc); - - /** - * Mark the associated PersistenceCapable field dirty. - * - *

    The StateManager will make a copy of the field so it can be restored if needed - * later, and then mark the field as modified in the current transaction. - * - * @param pc the calling PersistenceCapable instance - * @param fieldName the name of the field - */ - void makeDirty(PersistenceCapable pc, String fieldName); - - /** - * Return the object representing the JDO identity of the calling instance. If the JDO identity is - * being changed in the current transaction, this method returns the identity as of the beginning - * of the transaction. - * - * @param pc the calling PersistenceCapable instance - * @return the object representing the JDO identity of the calling instance - */ - Object getObjectId(PersistenceCapable pc); - - /** - * Return the object representing the JDO identity of the calling instance. If the JDO identity is - * being changed in the current transaction, this method returns the current identity as changed - * in the transaction. - * - * @param pc the calling PersistenceCapable instance - * @return the object representing the JDO identity of the calling instance - */ - Object getTransactionalObjectId(PersistenceCapable pc); - - /** - * Return the object representing the version of the calling instance. - * - * @param pc the calling PersistenceCapable instance - * @return the object representing the version of the calling instance - * @since 2.0 - */ - Object getVersion(PersistenceCapable pc); - - /** - * Return true if the field is cached in the calling instance. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @return whether the field is cached in the calling instance - */ - boolean isLoaded(PersistenceCapable pc, int field); - - /** - * Guarantee that the serializable transactional and persistent fields are loaded into the - * instance. This method is called by the generated jdoPreSerialize method prior to - * serialization of the instance. - * - * @param pc the calling PersistenceCapable instance - */ - void preSerialize(PersistenceCapable pc); - - /** - * Return the value for the field. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - * @return the new value for the field - */ - boolean getBooleanField(PersistenceCapable pc, int field, boolean currentValue); - - /** - * Return the value for the field. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - * @return the new value for the field - */ - char getCharField(PersistenceCapable pc, int field, char currentValue); - - /** - * Return the value for the field. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - * @return the new value for the field - */ - byte getByteField(PersistenceCapable pc, int field, byte currentValue); - - /** - * Return the value for the field. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - * @return the new value for the field - */ - short getShortField(PersistenceCapable pc, int field, short currentValue); - - /** - * Return the value for the field. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - * @return the new value for the field - */ - int getIntField(PersistenceCapable pc, int field, int currentValue); - - /** - * Return the value for the field. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - * @return the new value for the field - */ - long getLongField(PersistenceCapable pc, int field, long currentValue); - - /** - * Return the value for the field. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - * @return the new value for the field - */ - float getFloatField(PersistenceCapable pc, int field, float currentValue); - - /** - * Return the value for the field. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - * @return the new value for the field - */ - double getDoubleField(PersistenceCapable pc, int field, double currentValue); - - /** - * Return the value for the field. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - * @return the new value for the field - */ - String getStringField(PersistenceCapable pc, int field, String currentValue); - - /** - * Return the value for the field. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - * @return the new value for the field - */ - Object getObjectField(PersistenceCapable pc, int field, Object currentValue); - - /** - * Mark the field as modified by the user. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - * @param newValue the proposed new value of the field - */ - void setBooleanField(PersistenceCapable pc, int field, boolean currentValue, boolean newValue); - - /** - * Mark the field as modified by the user. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - * @param newValue the proposed new value of the field - */ - void setCharField(PersistenceCapable pc, int field, char currentValue, char newValue); - - /** - * Mark the field as modified by the user. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - * @param newValue the proposed new value of the field - */ - void setByteField(PersistenceCapable pc, int field, byte currentValue, byte newValue); - - /** - * Mark the field as modified by the user. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - * @param newValue the proposed new value of the field - */ - void setShortField(PersistenceCapable pc, int field, short currentValue, short newValue); - - /** - * Mark the field as modified by the user. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - * @param newValue the proposed new value of the field - */ - void setIntField(PersistenceCapable pc, int field, int currentValue, int newValue); - - /** - * Mark the field as modified by the user. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - * @param newValue the proposed new value of the field - */ - void setLongField(PersistenceCapable pc, int field, long currentValue, long newValue); - - /** - * Mark the field as modified by the user. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - * @param newValue the proposed new value of the field - */ - void setFloatField(PersistenceCapable pc, int field, float currentValue, float newValue); - - /** - * Mark the field as modified by the user. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - * @param newValue the proposed new value of the field - */ - void setDoubleField(PersistenceCapable pc, int field, double currentValue, double newValue); - - /** - * Mark the field as modified by the user. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - * @param newValue the proposed new value of the field - */ - void setStringField(PersistenceCapable pc, int field, String currentValue, String newValue); - - /** - * Mark the field as modified by the user. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - * @param newValue the proposed new value of the field - */ - void setObjectField(PersistenceCapable pc, int field, Object currentValue, Object newValue); - - /** - * The value of the field requested to be provided to the StateManager. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - */ - void providedBooleanField(PersistenceCapable pc, int field, boolean currentValue); - - /** - * The value of the field requested to be provided to the StateManager. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - */ - void providedCharField(PersistenceCapable pc, int field, char currentValue); - - /** - * The value of the field requested to be provided to the StateManager. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - */ - void providedByteField(PersistenceCapable pc, int field, byte currentValue); - - /** - * The value of the field requested to be provided to the StateManager. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - */ - void providedShortField(PersistenceCapable pc, int field, short currentValue); - - /** - * The value of the field requested to be provided to the StateManager. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - */ - void providedIntField(PersistenceCapable pc, int field, int currentValue); - - /** - * The value of the field requested to be provided to the StateManager. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - */ - void providedLongField(PersistenceCapable pc, int field, long currentValue); - - /** - * The value of the field requested to be provided to the StateManager. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - */ - void providedFloatField(PersistenceCapable pc, int field, float currentValue); - - /** - * The value of the field requested to be provided to the StateManager. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - */ - void providedDoubleField(PersistenceCapable pc, int field, double currentValue); - - /** - * The value of the field requested to be provided to the StateManager. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - */ - void providedStringField(PersistenceCapable pc, int field, String currentValue); - - /** - * The value of the field requested to be provided to the StateManager. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @param currentValue the current value of the field - */ - void providedObjectField(PersistenceCapable pc, int field, Object currentValue); - - /** - * The replacement value of the field in the calling instance. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @return the new value for the field - */ - boolean replacingBooleanField(PersistenceCapable pc, int field); - - /** - * The replacement value of the field in the calling instance. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @return the new value for the field - */ - char replacingCharField(PersistenceCapable pc, int field); - - /** - * The replacement value of the field in the calling instance. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @return the new value for the field - */ - byte replacingByteField(PersistenceCapable pc, int field); - - /** - * The replacement value of the field in the calling instance. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @return the new value for the field - */ - short replacingShortField(PersistenceCapable pc, int field); - - /** - * The replacement value of the field in the calling instance. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @return the new value for the field - */ - int replacingIntField(PersistenceCapable pc, int field); - - /** - * The replacement value of the field in the calling instance. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @return the new value for the field - */ - long replacingLongField(PersistenceCapable pc, int field); - - /** - * The replacement value of the field in the calling instance. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @return the new value for the field - */ - float replacingFloatField(PersistenceCapable pc, int field); - - /** - * The replacement value of the field in the calling instance. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @return the new value for the field - */ - double replacingDoubleField(PersistenceCapable pc, int field); - - /** - * The replacement value of the field in the calling instance. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @return the new value for the field - */ - String replacingStringField(PersistenceCapable pc, int field); - - /** - * The replacement value of the field in the calling instance. - * - * @param pc the calling PersistenceCapable instance - * @param field the field number - * @return the new value for the field - */ - Object replacingObjectField(PersistenceCapable pc, int field); - - /** - * The replacement value of the detached state in the calling instance. - * - * @param pc the calling Detachable instance - * @param state the current value of the detached state - * @return the replacement value for the detached state - * @since 2.0 - */ - Object[] replacingDetachedState(Detachable pc, Object[] state); + + /** The owning StateManager uses this method to supply the + * value of the flags to the PersistenceCapable instance. + * @param pc the calling PersistenceCapable instance + * @return the value of jdoFlags to be stored in the + * PersistenceCapable instance + */ + byte replacingFlags(PersistenceCapable pc); + + /** Replace the current value of jdoStateManager. + *

    + * This method is called by the PersistenceCapable whenever + * jdoReplaceStateManager is called and there is already + * an owning StateManager. This is a security precaution + * to ensure that the owning StateManager is the only + * source of any change to its reference in the + * PersistenceCapable. + * @return the new value for the jdoStateManager + * @param pc the calling PersistenceCapable instance + * @param sm the proposed new value for the jdoStateManager + */ + StateManager replacingStateManager (PersistenceCapable pc, StateManager sm); + + /** Tests whether this object is dirty. + * + * Instances that have been modified, deleted, or newly + * made persistent in the current transaction return true. + * + *

    Transient nontransactional instances return false. + *

    + * @see PersistenceCapable#jdoMakeDirty(String fieldName) + * @param pc the calling PersistenceCapable instance + * @return true if this instance has been modified in the + * current transaction. + */ + boolean isDirty(PersistenceCapable pc); + + /** Tests whether this object is transactional. + * + * Instances that respect transaction boundaries return true. + * These instances include transient instances made transactional as a + * result of being the target of a makeTransactional method + * call; newly made persistent or deleted persistent instances; persistent + * instances read in data store transactions; and persistent instances + * modified in optimistic transactions. + * + *

    Transient nontransactional instances return false. + *

    + * @param pc the calling PersistenceCapable instance + * @return true if this instance is transactional. + */ + boolean isTransactional(PersistenceCapable pc); + + /** Tests whether this object is persistent. + * + * Instances whose state is stored in the data store return + * true. + * + *

    Transient instances return false. + *

    + * @see PersistenceManager#makePersistent(Object pc) + * @param pc the calling PersistenceCapable instance + * @return true if this instance is persistent. + */ + boolean isPersistent(PersistenceCapable pc); + + /** Tests whether this object has been newly made persistent. + * + * Instances that have been made persistent in the current transaction + * return true. + * + *

    Transient instances return false. + *

    + * @see PersistenceManager#makePersistent(Object pc) + * @param pc the calling PersistenceCapable instance + * @return true if this instance was made persistent + * in the current transaction. + */ + boolean isNew(PersistenceCapable pc); + + /** Tests whether this object has been deleted. + * + * Instances that have been deleted in the current transaction return + * true. + * + *

    Transient instances return false. + *

    + * @see PersistenceManager#deletePersistent(Object pc) + * @param pc the calling PersistenceCapable instance + * @return true if this instance was deleted + * in the current transaction. + */ + boolean isDeleted(PersistenceCapable pc); + + /** Return the PersistenceManager that owns this instance. + * @param pc the calling PersistenceCapable instance + * @return the PersistenceManager that owns this instance + */ + PersistenceManager getPersistenceManager (PersistenceCapable pc); + + /** Mark the associated PersistenceCapable field dirty. + *

    The StateManager will make a copy of the field + * so it can be restored if needed later, and then mark + * the field as modified in the current transaction. + * @param pc the calling PersistenceCapable instance + * @param fieldName the name of the field + */ + void makeDirty (PersistenceCapable pc, String fieldName); + + /** Return the object representing the JDO identity + * of the calling instance. If the JDO identity is being changed in + * the current transaction, this method returns the identity as of + * the beginning of the transaction. + * @param pc the calling PersistenceCapable instance + * @return the object representing the JDO identity of the calling instance + */ + Object getObjectId (PersistenceCapable pc); + + /** Return the object representing the JDO identity + * of the calling instance. If the JDO identity is being changed in + * the current transaction, this method returns the current identity as + * changed in the transaction. + * @param pc the calling PersistenceCapable instance + * @return the object representing the JDO identity of the calling instance + */ + Object getTransactionalObjectId (PersistenceCapable pc); + + /** Return the object representing the version + * of the calling instance. + * @param pc the calling PersistenceCapable instance + * @return the object representing the version of the calling instance + * @since 2.0 + */ + Object getVersion (PersistenceCapable pc); + + /** Return true if the field is cached in the calling + * instance. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @return whether the field is cached in the calling instance + */ + boolean isLoaded (PersistenceCapable pc, int field); + + /** Guarantee that the serializable transactional and persistent fields + * are loaded into the instance. This method is called by the generated + * jdoPreSerialize method prior to serialization of the + * instance. + * @param pc the calling PersistenceCapable instance + */ + void preSerialize (PersistenceCapable pc); + + /** Return the value for the field. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + * @return the new value for the field + */ + boolean getBooleanField ( + PersistenceCapable pc, int field, boolean currentValue); + + /** Return the value for the field. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + * @return the new value for the field + */ + char getCharField (PersistenceCapable pc, int field, char currentValue); + + /** Return the value for the field. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + * @return the new value for the field + */ + byte getByteField (PersistenceCapable pc, int field, byte currentValue); + + /** Return the value for the field. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + * @return the new value for the field + */ + short getShortField (PersistenceCapable pc, int field, short currentValue); + + /** Return the value for the field. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + * @return the new value for the field + */ + int getIntField (PersistenceCapable pc, int field, int currentValue); + + /** Return the value for the field. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + * @return the new value for the field + */ + long getLongField (PersistenceCapable pc, int field, long currentValue); + + /** Return the value for the field. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + * @return the new value for the field + */ + float getFloatField (PersistenceCapable pc, int field, float currentValue); + + /** Return the value for the field. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + * @return the new value for the field + */ + double getDoubleField (PersistenceCapable pc, int field, + double currentValue); + + /** Return the value for the field. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + * @return the new value for the field + */ + String getStringField (PersistenceCapable pc, int field, + String currentValue); + + /** Return the value for the field. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + * @return the new value for the field + */ + Object getObjectField (PersistenceCapable pc, int field, + Object currentValue); + + /** Mark the field as modified by the user. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + * @param newValue the proposed new value of the field */ + void setBooleanField (PersistenceCapable pc, int field, + boolean currentValue, boolean newValue); + + /** Mark the field as modified by the user. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + * @param newValue the proposed new value of the field */ + void setCharField (PersistenceCapable pc, int field, + char currentValue, char newValue); + + /** Mark the field as modified by the user. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + * @param newValue the proposed new value of the field */ + void setByteField (PersistenceCapable pc, int field, + byte currentValue, byte newValue); + + /** Mark the field as modified by the user. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + * @param newValue the proposed new value of the field */ + void setShortField (PersistenceCapable pc, int field, + short currentValue, short newValue); + + /** Mark the field as modified by the user. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + * @param newValue the proposed new value of the field */ + void setIntField (PersistenceCapable pc, int field, + int currentValue, int newValue); + + /** Mark the field as modified by the user. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + * @param newValue the proposed new value of the field */ + void setLongField (PersistenceCapable pc, int field, + long currentValue, long newValue); + + /** Mark the field as modified by the user. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + * @param newValue the proposed new value of the field */ + void setFloatField (PersistenceCapable pc, int field, + float currentValue, float newValue); + + /** Mark the field as modified by the user. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + * @param newValue the proposed new value of the field */ + void setDoubleField (PersistenceCapable pc, int field, + double currentValue, double newValue); + + /** Mark the field as modified by the user. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + * @param newValue the proposed new value of the field */ + void setStringField (PersistenceCapable pc, int field, + String currentValue, String newValue); + + /** Mark the field as modified by the user. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + * @param newValue the proposed new value of the field */ + void setObjectField (PersistenceCapable pc, int field, + Object currentValue, Object newValue); + + /** The value of the field requested to be provided to the + * StateManager. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + */ + void providedBooleanField (PersistenceCapable pc, int field, + boolean currentValue); + + /** The value of the field requested to be provided to the + * StateManager. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + */ + void providedCharField (PersistenceCapable pc, int field, + char currentValue); + + /** The value of the field requested to be provided to the + * StateManager. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + */ + void providedByteField (PersistenceCapable pc, int field, + byte currentValue); + + /** The value of the field requested to be provided to the + * StateManager. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + */ + void providedShortField (PersistenceCapable pc, int field, + short currentValue); + + /** The value of the field requested to be provided to the + * StateManager. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + */ + void providedIntField (PersistenceCapable pc, int field, int currentValue); + + /** The value of the field requested to be provided to the + * StateManager. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + */ + void providedLongField (PersistenceCapable pc, int field, + long currentValue); + + /** The value of the field requested to be provided to the + * StateManager. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + */ + void providedFloatField (PersistenceCapable pc, int field, + float currentValue); + + /** The value of the field requested to be provided to the + * StateManager. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + */ + void providedDoubleField (PersistenceCapable pc, int field, + double currentValue); + + /** The value of the field requested to be provided to the + * StateManager. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + */ + void providedStringField (PersistenceCapable pc, int field, + String currentValue); + + /** The value of the field requested to be provided to the + * StateManager. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @param currentValue the current value of the field + */ + void providedObjectField (PersistenceCapable pc, int field, + Object currentValue); + + /** The replacement value of the field in the calling instance. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @return the new value for the field + */ + boolean replacingBooleanField (PersistenceCapable pc, int field); + + /** The replacement value of the field in the calling instance. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @return the new value for the field + */ + char replacingCharField (PersistenceCapable pc, int field); + + /** The replacement value of the field in the calling instance. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @return the new value for the field + */ + byte replacingByteField (PersistenceCapable pc, int field); + + /** The replacement value of the field in the calling instance. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @return the new value for the field + */ + short replacingShortField (PersistenceCapable pc, int field); + + /** The replacement value of the field in the calling instance. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @return the new value for the field + */ + int replacingIntField (PersistenceCapable pc, int field); + + /** The replacement value of the field in the calling instance. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @return the new value for the field + */ + long replacingLongField (PersistenceCapable pc, int field); + + /** The replacement value of the field in the calling instance. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @return the new value for the field + */ + float replacingFloatField (PersistenceCapable pc, int field); + + /** The replacement value of the field in the calling instance. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @return the new value for the field + */ + double replacingDoubleField (PersistenceCapable pc, int field); + + /** The replacement value of the field in the calling instance. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @return the new value for the field + */ + String replacingStringField (PersistenceCapable pc, int field); + + /** The replacement value of the field in the calling instance. + * @param pc the calling PersistenceCapable instance + * @param field the field number + * @return the new value for the field + */ + Object replacingObjectField (PersistenceCapable pc, int field); + + /** The replacement value of the detached state in the calling instance. + * @param pc the calling Detachable instance + * @param state the current value of the detached state + * @return the replacement value for the detached state + * @since 2.0 + */ + Object[] replacingDetachedState (Detachable pc, Object[] state); } diff --git a/api/src/test/java/javax/jdo/AbstractJDOConfigTest.java b/api/src/test/java/javax/jdo/AbstractJDOConfigTest.java index 94745b18e..2ee1378db 100644 --- a/api/src/test/java/javax/jdo/AbstractJDOConfigTest.java +++ b/api/src/test/java/javax/jdo/AbstractJDOConfigTest.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -22,113 +22,119 @@ import java.util.Iterator; import java.util.Map; import java.util.Random; + import javax.jdo.util.AbstractTest; public abstract class AbstractJDOConfigTest extends AbstractTest { - /** A class path prefix used in the various tests where the class path needs to be set. */ - protected static String JDOCONFIG_CLASSPATH_PREFIX = initJDOConfigClasspathPrefix(); - - /** - * Returns the JDO configuration class path prefix's default value, which is the project base - * directory suffixed by the path to the configuration directory - * (src/test/resources/jdoconfig). - * - * @return the default class path prefix used by this test suite. - */ - protected static String initJDOConfigClasspathPrefix() { - return initBasedir() + "src/test/resources/jdoconfig"; - } + /** + * A class path prefix used in the various tests where the class path + * needs to be set. + */ + protected static String JDOCONFIG_CLASSPATH_PREFIX + = initJDOConfigClasspathPrefix(); - /** - * The class path used to specify the location of test class files. - * - * @return the class path where test class files can be found. - */ - protected static String TEST_CLASSPATH = initTestClasspath(); + /** + * Returns the JDO configuration class path prefix's default value, which is + * the project base directory suffixed by the path to the configuration + * directory (src/test/resources/jdoconfig). + * + * @return the default class path prefix used by this test suite. + * + */ + protected static String initJDOConfigClasspathPrefix() { + return initBasedir() + "src/test/resources/jdoconfig"; + } - /** - * Returns the default class path for JDO test class files (target/test-classes/). - * - * @return the default class path for JDO test class files. - */ - protected static String initTestClasspath() { - return initBasedir() + "target/test-classes/"; - } + /** + * The class path used to specify the location of test class files. + * @return the class path where test class files can be found. + */ + protected static String TEST_CLASSPATH = initTestClasspath(); - /** The class path used to locate the JDO API class files. */ - protected static String API_CLASSPATH = initAPIClasspath(); + /** + * Returns the default class path for JDO test class files + * (target/test-classes/). + * @return the default class path for JDO test class files. + */ + protected static String initTestClasspath() { + return initBasedir() + "target/test-classes/"; + } - /** - * Returns the default class path for JDO API class files (target/classes/). - * - * @return the default class path for JDO API class files. - */ - protected static String initAPIClasspath() { - return initBasedir() + "target/classes/"; - } + /** + * The class path used to locate the JDO API class files. + */ + protected static String API_CLASSPATH = initAPIClasspath(); - /** - * Returns the base directory for this project. This base directory is used to build up the other - * class paths defined in this test suite. The value returned is the value returned by - * System.getProperty("basedir"). A trailing slash is appended to the path if it doesn't - * exist. - * - * @return the default base directory of the project. - */ - protected static String initBasedir() { - String basedir = System.getProperty("basedir"); - if (basedir != null) { - if (!basedir.endsWith("/")) { - basedir += "/"; - } - } else { - basedir = ""; + /** + * Returns the default class path for JDO API class files + * (target/classes/). + * @return the default class path for JDO API class files. + */ + protected static String initAPIClasspath() { + return initBasedir() + "target/classes/"; } - return basedir; - } - /** A randomizer seeded with the system clock's current time. */ - protected static Random RANDOM = new Random(System.currentTimeMillis()); + /** + * Returns the base directory for this project. This base directory + * is used to build up the other class paths defined in this test suite. + * The value returned is the value returned by + * System.getProperty("basedir"). + * A trailing slash is appended to the path if it doesn't exist. + * + * @return the default base directory of the project. + */ + protected static String initBasedir() { + String basedir = System.getProperty("basedir"); + if (basedir != null) { + if (!basedir.endsWith("/")) { + basedir += "/"; + } + } else { + basedir = ""; + } + return basedir; + } + + /** + * A randomizer seeded with the system clock's current time. + */ + protected static Random RANDOM = new Random(System.currentTimeMillis()); - /** - * Fails the test if the number of properties in the two specified {@link java.util.Map Map} - * objects are not identical or their values do not match. - * - * @param expected the first {@link java.util.Map Map} object to test. - * @param actual the second {@link java.util.Map Map} object to test. - */ - static void assertEqualProperties(Map expected, Map actual) { - Iterator i = expected.entrySet().iterator(); - while (i.hasNext()) { - Map.Entry entry = (Map.Entry) i.next(); - String key = (String) entry.getKey(); - String expectedValue = (String) entry.getValue(); - String actualValue = (String) actual.get(key); + /** + * Fails the test if the number of properties in the two specified + * {@link java.util.Map Map} objects are not identical or their values + * do not match. + * @param expected the first {@link java.util.Map Map} object to test. + * @param actual the second {@link java.util.Map Map} object to test. + */ + static void assertEqualProperties(Map expected, Map actual) { + Iterator i = expected.entrySet().iterator(); + while (i.hasNext()) { + Map.Entry entry = (Map.Entry) i.next(); + String key = (String) entry.getKey(); + String expectedValue = (String) entry.getValue(); + String actualValue = (String) actual.get(key); - assertEquals( - "Actual property at key [" - + key - + "] with value [" - + actualValue - + "] not equal to expected value [" - + expectedValue - + "]", - expectedValue, - actualValue); + assertEquals("Actual property at key [" + key + "] with value [" + + actualValue + "] not equal to expected value [" + + expectedValue + "]", + expectedValue, + actualValue); + } } - } - - protected String getPMFClassNameViaServiceLookup(ClassLoader loader) { - try { - Enumeration urls = JDOHelper.getResources(loader, SERVICE_LOOKUP_PMF_RESOURCE_NAME); - while (urls.hasMoreElements()) { - // return the first one found - return JDOHelper.getClassNameFromURL((URL) urls.nextElement()); - } - } catch (Exception ex) { - // ignore exceptions from i/o errors + + protected String getPMFClassNameViaServiceLookup(ClassLoader loader) { + try { + Enumeration urls = JDOHelper.getResources(loader, + SERVICE_LOOKUP_PMF_RESOURCE_NAME); + while (urls.hasMoreElements()) { + // return the first one found + return JDOHelper.getClassNameFromURL((URL)urls.nextElement()); + } + } catch (Exception ex) { + // ignore exceptions from i/o errors + } + return null; } - return null; - } } diff --git a/api/src/test/java/javax/jdo/EnhancerTest.java b/api/src/test/java/javax/jdo/EnhancerTest.java index 7a9b4ecb7..4adf13879 100644 --- a/api/src/test/java/javax/jdo/EnhancerTest.java +++ b/api/src/test/java/javax/jdo/EnhancerTest.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -26,531 +26,352 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; + import javax.jdo.util.AbstractTest; import javax.jdo.util.BatchTestRunner; + /** * Tests class javax.jdo.Enhancer (Enhancer main class). - * *

    */ public class EnhancerTest extends AbstractTest { - /** The path delimiter for constructing classpaths. */ - private static String pathDelimiter = System.getProperty("path.separator"); - - /** The maven basedir identifying the directory of the execution environment. */ - private static String basedir = System.getProperty("basedir"); - - /** - * Main - * - * @param args command line arguments - */ - public static void main(String args[]) { - BatchTestRunner.run(EnhancerTest.class); - } - - public void testUsageOption() { - // invoke enhancer with a usage option - InvocationResult result = invokeEnhancer("?"); - String outputString = result.getOutputString(); - String errorString = result.getErrorString(); - assertEquals( - "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); - assertTrue( - "Expected Usage message from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("javax.jdo.Enhancer")); - } - - public void testHelpOption() { - // invoke enhancer with a usage option - InvocationResult result = invokeEnhancer("-help"); - String outputString = result.getOutputString(); - String errorString = result.getErrorString(); - assertEquals( - "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); - assertTrue( - "Expected Usage message from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("javax.jdo.Enhancer")); - } - - public void testHOption() { - // invoke enhancer with a usage option - InvocationResult result = invokeEnhancer("-h"); - String outputString = result.getOutputString(); - String errorString = result.getErrorString(); - assertEquals( - "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); - assertTrue( - "Expected Usage message from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("javax.jdo.Enhancer")); - } - - public void testInvalidOption() { - // invoke enhancer with an invalid option - InvocationResult result = invokeEnhancer("-poo"); - assertEquals("Wrong return value ", ENHANCER_USAGE_ERROR, result.getExitValue()); - String errorString = result.getErrorString(); - assertTrue( - "Expected Usage message from err:\n" + errorString, - errorString.contains("javax.jdo.Enhancer")); - } - - public void testProperties() { - // invoke enhancer with verbose option - InvocationResult result = invokeEnhancer("-v"); - String outputString = result.getOutputString(); - String errorString = result.getErrorString(); - assertEquals( - "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); - assertTrue( - "Expected MockEnhancer vendor message from out:\n" - + outputString - + " with err:\n" - + errorString, - outputString.contains(PROPERTY_ENHANCER_VENDOR_NAME)); - assertTrue( - "Expected MockEnhancer version message from out:\n" - + outputString - + " with err:\n" - + errorString, - outputString.contains(PROPERTY_ENHANCER_VERSION_NUMBER)); - assertTrue( - "Expected MockEnhancer vendor message from out:\n" - + outputString - + " with err:\n" - + errorString, - outputString.contains("Mock Enhancer")); - assertTrue( - "Expected MockEnhancer vendor message from out:\n" - + outputString - + " with err:\n" - + errorString, - outputString.contains("2.3.0")); - assertTrue( - "Expected MockEnhancer properties message from out:\n" - + outputString - + " with err:\n" - + errorString, - outputString.contains("MockKey")); - } - - public void testVOption() { - // invoke enhancer with verbose option - InvocationResult result = invokeEnhancer("-v"); - String outputString = result.getOutputString(); - String errorString = result.getErrorString(); - assertEquals( - "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); - assertTrue( - "Expected Enhancer class message from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("javax.jdo.MockEnhancer")); - } - - public void testVerboseOption() { - // invoke enhancer with verbose option - InvocationResult result = invokeEnhancer("-verbose"); - String outputString = result.getOutputString(); - String errorString = result.getErrorString(); - assertEquals( - "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); - assertTrue( - "Expected Enhancer class message from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("javax.jdo.MockEnhancer")); - } - - public void testVerboseClasses() { - // invoke enhancer with .class parameter - InvocationResult result = invokeEnhancer("-v some.class"); - String outputString = result.getOutputString(); - String errorString = result.getErrorString(); - assertEquals( - "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); - assertTrue( - "Expected class message from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("some.class")); - assertTrue( - "Expected number of classes from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("1")); - } - - public void testVerboseJars() { - // invoke enhancer with a .jar parameter - InvocationResult result = invokeEnhancer("-v some.jar"); - String outputString = result.getOutputString(); - String errorString = result.getErrorString(); - assertEquals( - "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); - assertTrue( - "Expected jar message from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("some.jar")); - assertTrue( - "Expected number of jars from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("1")); - } - - public void testVerboseJDOs() { - // invoke enhancer with a .jdo parameter - InvocationResult result = invokeEnhancer("-v some.jdo"); - String outputString = result.getOutputString(); - String errorString = result.getErrorString(); - assertEquals( - "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); - assertTrue( - "Expected jdo message from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("some.jdo")); - assertTrue( - "Expected number of jdos from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("1")); - } - - public void testVerboseAll() { - // invoke enhancer with multiple parameters - InvocationResult result = invokeEnhancer("-v some.class some.jar some.jdo"); - String outputString = result.getOutputString(); - String errorString = result.getErrorString(); - assertEquals( - "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); - assertTrue( - "Expected jdo message from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("some.jdo")); - assertTrue( - "Expected jar message from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("some.jar")); - assertTrue( - "Expected class message from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("some.class")); - assertTrue( - "Expected number of elements from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("3")); - } - - public void testVerboseCheckonlyAll() { - // invoke enhancer with a checkonly option - InvocationResult result = invokeEnhancer("-v -checkonly some.class some.jar some.jdo"); - String outputString = result.getOutputString(); - String errorString = result.getErrorString(); - assertEquals( - "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); - assertTrue( - "Expected jdo message from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("some.jdo")); - assertTrue( - "Expected jar message from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("some.jar")); - assertTrue( - "Expected class message from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("some.class")); - assertTrue( - "Expected number of elements from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("3")); - } - - public void testMissingPU() { - // invoke enhancer with missing parameter - InvocationResult result = invokeEnhancer("-v -pu"); - assertEquals("Wrong return value ", 3, result.getExitValue()); - } - - public void testVerbosePU() { - // invoke enhancer with a pu parameter - InvocationResult result = invokeEnhancer("-v -pu myPU -pu yourPU"); - String outputString = result.getOutputString(); - String errorString = result.getErrorString(); - assertEquals( - "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); - assertTrue( - "Expected pu message from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("myPU")); - assertTrue( - "Expected pu message from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("yourPU")); - assertTrue( - "Expected number of elements from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("2")); - } - - public void testClasspath() { - // invoke enhancer with a classpath parameter - // JDOHelper must be loadable from this path - // the File.toURI should append "/" to the path, so only "target/classes" is needed - InvocationResult result = invokeEnhancer("-v -cp " + basedir + "/target/classes"); - String outputString = result.getOutputString(); - String errorString = result.getErrorString(); - assertEquals( - "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); - assertTrue( - "Expected classpath message from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("target/classes")); - } - - public void testBadClasspath() { - // invoke enhancer with a bad classpath parameter - // JDOHelper is not loadable from this path - InvocationResult result = invokeEnhancer("-v -cp target"); - String outputString = result.getOutputString(); - String errorString = result.getErrorString(); - assertEquals( - "Wrong exit code from Enhancer with stderr:\n" + errorString, 1, result.getExitValue()); - assertTrue( - "Expected classpath error message from out:\n" - + outputString - + " with err:\n" - + errorString, - errorString.contains("JDOHelper")); - } - - public void testClasspathJar() throws IOException, InterruptedException { - // invoke enhancer with a classpath parameter - // JDOHelper must be loadable from this path - // create the jar file from the target/classes directory - String uuid = UUID.randomUUID().toString(); - File uuidDir = new File(basedir + "/target/" + uuid); - uuidDir.mkdirs(); - String enhancerJar = "target/" + uuid + "/enhancer-test.jar"; - String enhancerJarPathname = basedir + "/" + enhancerJar; - Process create = - Runtime.getRuntime() - .exec("jar -cf " + enhancerJarPathname + " -C " + basedir + "/target/classes ."); - int returnCode = create.waitFor(); - assertEquals("jar command returned wrong return code.", 0, returnCode); - // find the jdo.jar in target - InvocationResult result = invokeEnhancer("-v -cp " + enhancerJar); - String outputString = result.getOutputString(); - String errorString = result.getErrorString(); - assertEquals( - "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); - assertTrue( - "Expected classpath message from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains(enhancerJar)); - } - - public void testOutputDirectory() { - // invoke enhancer with an output directory parameter - InvocationResult result = invokeEnhancer("-v -d some/output/directory"); - String outputString = result.getOutputString(); - String errorString = result.getErrorString(); - assertEquals( - "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); - assertTrue( - "Expected directory message from out:\n" + outputString + " with err:\n" + errorString, - outputString.contains("some/output/directory")); - } - - public void testMissingOutputDirectory() { - // invoke enhancer with missing parameter - InvocationResult result = invokeEnhancer("-v -d"); - assertEquals("Wrong return value ", 3, result.getExitValue()); - } - - public void testDir() { - // invoke enhancer with directory and not recurse - InvocationResult result = - invokeEnhancer("-v " + basedir + "/target/test-classes/enhancer-test-dir"); - String outputString = result.getOutputString(); - String errorString = result.getErrorString(); - assertEquals( - "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); - assertTrue( - "Expected directory enhancer-test-dir in message from out:\n" - + outputString - + " with err:\n" - + errorString, - outputString.contains("enhancer-test-dir")); - assertTrue( - "Expected file file1.jdo in message from out:\n" - + outputString - + " with err:\n" - + errorString, - outputString.contains("file1.jdo")); - assertTrue( - "Expected file file2.class in message from out:\n" - + outputString - + " with err:\n" - + errorString, - outputString.contains("file2.class")); - assertTrue( - "Expected file file3.jar in message from out:\n" - + outputString - + " with err:\n" - + errorString, - outputString.contains("file3.jar")); - assertFalse( - "Expected no directory enhancer-test-subdir in message from out:\n" - + outputString - + " with err:\n" - + errorString, - outputString.contains("enhancer-test-subdir")); - assertTrue( - "Expected 3 files to be enhanced in message from out:\n" - + outputString - + " with err:\n" - + errorString, - outputString.contains("3")); - } - - public void testDirRecurse() { - // invoke enhancer with directory and recurse - InvocationResult result = - invokeEnhancer("-v -r " + basedir + "/target/test-classes/enhancer-test-dir"); - String outputString = result.getOutputString(); - String errorString = result.getErrorString(); - assertEquals( - "Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); - assertTrue( - "Expected directory enhancer-test-dir in message from out:\n" - + outputString - + " with err:\n" - + errorString, - outputString.contains("enhancer-test-dir")); - assertTrue( - "Expected directory enhancer-test-subdir in message from out:\n" - + outputString - + " with err:\n" - + errorString, - outputString.contains("enhancer-test-subdir")); - assertTrue( - "Expected file file1.jdo in message from out:\n" - + outputString - + " with err:\n" - + errorString, - outputString.contains("file1.jdo")); - assertTrue( - "Expected file file2.class in message from out:\n" - + outputString - + " with err:\n" - + errorString, - outputString.contains("file2.class")); - assertTrue( - "Expected file file3.jar in message from out:\n" - + outputString - + " with err:\n" - + errorString, - outputString.contains("file3.jar")); - assertTrue( - "Expected file file4.jdo in message from out:\n" - + outputString - + " with err:\n" - + errorString, - outputString.contains("file4.jdo")); - assertTrue( - "Expected file file5.class in message from out:\n" - + outputString - + " with err:\n" - + errorString, - outputString.contains("file5.class")); - assertTrue( - "Expected file file6.jar in message from out:\n" - + outputString - + " with err:\n" - + errorString, - outputString.contains("file6.jar")); - assertTrue( - "Expected 6 files to be enhanced in message from out:\n" - + outputString - + " with err:\n" - + errorString, - outputString.contains("6")); - } - - private InvocationResult invokeEnhancer(String string) { - InvocationResult result = new InvocationResult(); - try { - // create the java command to invoke the Enhancer - List commands = new ArrayList(); - // find the java command in the user's path - commands.add("java"); - commands.add("-cp"); - commands.add( - "" + basedir + "/target/classes" + pathDelimiter + "" + basedir + "/target/test-classes"); - commands.add("javax.jdo.Enhancer"); - // add the test options (from the method parameter) to the java command - String[] optionArray = string.split(" "); - for (String option : optionArray) { - commands.add(option); - } - String[] cmdarray = commands.toArray(new String[commands.size()]); - ProcessBuilder builder = new ProcessBuilder(cmdarray); - Process proc = builder.start(); - InputStream stdout = proc.getInputStream(); - InputStream stderr = proc.getErrorStream(); - CharBuffer outBuffer = CharBuffer.allocate(1000000); - CharBuffer errBuffer = CharBuffer.allocate(1000000); - Thread outputThread = createReaderThread(stdout, outBuffer); - Thread errorThread = createReaderThread(stderr, errBuffer); - int exitValue = proc.waitFor(); - result.setExitValue(exitValue); - errorThread.join(10000); // wait ten seconds to get stderr after process terminates - outputThread.join(10000); // wait ten seconds to get stdout after process terminates - result.setErrorString(errBuffer.toString()); - result.setOutputString(outBuffer.toString()); - // wait until the Enhancer command finishes - } catch (InterruptedException ex) { - throw new RuntimeException("InterruptedException", ex); - } catch (IOException ex) { - throw new RuntimeException("IOException", ex); - } catch (JDOException jdoex) { - jdoex.printStackTrace(); - Throwable[] throwables = jdoex.getNestedExceptions(); - System.out.println("Exception throwables of size: " + throwables.length); - for (Throwable throwable : throwables) { - throwable.printStackTrace(); - } + /** The path delimiter for constructing classpaths. */ + private static String pathDelimiter = System.getProperty("path.separator"); + + /** The maven basedir identifying the directory of the execution environment. */ + private static String basedir = System.getProperty("basedir"); + + /** + * Main + * @param args command line arguments + */ + public static void main(String args[]) { + BatchTestRunner.run(EnhancerTest.class); } - return result; - } - - private Thread createReaderThread(final InputStream input, final CharBuffer output) { - final Reader reader = new InputStreamReader(input); - Thread thread = - new Thread( - new Runnable() { - public void run() { - int count = 0; - int outputBytesRead = 0; - try { - while (-1 != (outputBytesRead = reader.read(output))) { - count += outputBytesRead; - } - } catch (IOException e) { - e.printStackTrace(); - } finally { - output.flip(); - } - } - }); - thread.start(); - return thread; - } - - class InvocationResult { - private int exitValue; - private String errorString; - private String outputString; - - int getExitValue() { - return exitValue; + + public void testUsageOption() { + // invoke enhancer with a usage option + InvocationResult result = invokeEnhancer("?"); + String outputString = result.getOutputString(); + String errorString = result.getErrorString(); + assertEquals("Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); + assertTrue("Expected Usage message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("javax.jdo.Enhancer")); + } + + public void testHelpOption() { + // invoke enhancer with a usage option + InvocationResult result = invokeEnhancer("-help"); + String outputString = result.getOutputString(); + String errorString = result.getErrorString(); + assertEquals("Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); + assertTrue("Expected Usage message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("javax.jdo.Enhancer")); + } + + public void testHOption() { + // invoke enhancer with a usage option + InvocationResult result = invokeEnhancer("-h"); + String outputString = result.getOutputString(); + String errorString = result.getErrorString(); + assertEquals("Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); + assertTrue("Expected Usage message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("javax.jdo.Enhancer")); + } + + public void testInvalidOption() { + // invoke enhancer with an invalid option + InvocationResult result = invokeEnhancer("-poo"); + assertEquals("Wrong return value ", ENHANCER_USAGE_ERROR, result.getExitValue()); + String errorString = result.getErrorString(); + assertTrue("Expected Usage message from err:\n" + errorString, errorString.contains("javax.jdo.Enhancer")); + } + + public void testProperties() { + // invoke enhancer with verbose option + InvocationResult result = invokeEnhancer("-v"); + String outputString = result.getOutputString(); + String errorString = result.getErrorString(); + assertEquals("Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); + assertTrue("Expected MockEnhancer vendor message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains(PROPERTY_ENHANCER_VENDOR_NAME)); + assertTrue("Expected MockEnhancer version message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains(PROPERTY_ENHANCER_VERSION_NUMBER)); + assertTrue("Expected MockEnhancer vendor message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("Mock Enhancer")); + assertTrue("Expected MockEnhancer vendor message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("2.3.0")); + assertTrue("Expected MockEnhancer properties message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("MockKey")); + } + + public void testVOption() { + // invoke enhancer with verbose option + InvocationResult result = invokeEnhancer("-v"); + String outputString = result.getOutputString(); + String errorString = result.getErrorString(); + assertEquals("Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); + assertTrue("Expected Enhancer class message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("javax.jdo.MockEnhancer")); + } + + public void testVerboseOption() { + // invoke enhancer with verbose option + InvocationResult result = invokeEnhancer("-verbose"); + String outputString = result.getOutputString(); + String errorString = result.getErrorString(); + assertEquals("Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); + assertTrue("Expected Enhancer class message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("javax.jdo.MockEnhancer")); + } + + public void testVerboseClasses() { + // invoke enhancer with .class parameter + InvocationResult result = invokeEnhancer("-v some.class"); + String outputString = result.getOutputString(); + String errorString = result.getErrorString(); + assertEquals("Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); + assertTrue("Expected class message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("some.class")); + assertTrue("Expected number of classes from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("1")); + } + + public void testVerboseJars() { + // invoke enhancer with a .jar parameter + InvocationResult result = invokeEnhancer("-v some.jar"); + String outputString = result.getOutputString(); + String errorString = result.getErrorString(); + assertEquals("Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); + assertTrue("Expected jar message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("some.jar")); + assertTrue("Expected number of jars from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("1")); + } + + public void testVerboseJDOs() { + // invoke enhancer with a .jdo parameter + InvocationResult result = invokeEnhancer("-v some.jdo"); + String outputString = result.getOutputString(); + String errorString = result.getErrorString(); + assertEquals("Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); + assertTrue("Expected jdo message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("some.jdo")); + assertTrue("Expected number of jdos from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("1")); + } + + public void testVerboseAll() { + // invoke enhancer with multiple parameters + InvocationResult result = invokeEnhancer("-v some.class some.jar some.jdo"); + String outputString = result.getOutputString(); + String errorString = result.getErrorString(); + assertEquals("Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); + assertTrue("Expected jdo message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("some.jdo")); + assertTrue("Expected jar message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("some.jar")); + assertTrue("Expected class message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("some.class")); + assertTrue("Expected number of elements from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("3")); } - private void setExitValue(int exitValue) { - this.exitValue = exitValue; + public void testVerboseCheckonlyAll() { + // invoke enhancer with a checkonly option + InvocationResult result = invokeEnhancer("-v -checkonly some.class some.jar some.jdo"); + String outputString = result.getOutputString(); + String errorString = result.getErrorString(); + assertEquals("Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); + assertTrue("Expected jdo message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("some.jdo")); + assertTrue("Expected jar message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("some.jar")); + assertTrue("Expected class message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("some.class")); + assertTrue("Expected number of elements from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("3")); } - private void setErrorString(String errorString) { - this.errorString = errorString; + public void testMissingPU() { + // invoke enhancer with missing parameter + InvocationResult result = invokeEnhancer("-v -pu"); + assertEquals("Wrong return value ", 3, result.getExitValue()); } - String getErrorString() { - return errorString; + public void testVerbosePU() { + // invoke enhancer with a pu parameter + InvocationResult result = invokeEnhancer("-v -pu myPU -pu yourPU"); + String outputString = result.getOutputString(); + String errorString = result.getErrorString(); + assertEquals("Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); + assertTrue("Expected pu message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("myPU")); + assertTrue("Expected pu message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("yourPU")); + assertTrue("Expected number of elements from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("2")); } - private void setOutputString(String outputString) { - this.outputString = outputString; + public void testClasspath() { + // invoke enhancer with a classpath parameter + // JDOHelper must be loadable from this path + // the File.toURI should append "/" to the path, so only "target/classes" is needed + InvocationResult result = invokeEnhancer("-v -cp " + basedir + "/target/classes"); + String outputString = result.getOutputString(); + String errorString = result.getErrorString(); + assertEquals("Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); + assertTrue("Expected classpath message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("target/classes")); } - String getOutputString() { - return outputString; + public void testBadClasspath() { + // invoke enhancer with a bad classpath parameter + // JDOHelper is not loadable from this path + InvocationResult result = invokeEnhancer("-v -cp target"); + String outputString = result.getOutputString(); + String errorString = result.getErrorString(); + assertEquals("Wrong exit code from Enhancer with stderr:\n" + errorString, 1, result.getExitValue()); + assertTrue("Expected classpath error message from out:\n" + outputString + " with err:\n" + errorString, errorString.contains("JDOHelper")); } - } + + public void testClasspathJar() throws IOException, InterruptedException { + // invoke enhancer with a classpath parameter + // JDOHelper must be loadable from this path + // create the jar file from the target/classes directory + String uuid = UUID.randomUUID().toString(); + File uuidDir = new File(basedir + "/target/" + uuid); + uuidDir.mkdirs(); + String enhancerJar = "target/" + uuid + "/enhancer-test.jar"; + String enhancerJarPathname = basedir + "/" + enhancerJar; + Process create = Runtime.getRuntime().exec("jar -cf " + enhancerJarPathname + " -C " + basedir + "/target/classes ."); + int returnCode = create.waitFor(); + assertEquals("jar command returned wrong return code.", 0, returnCode); + // find the jdo.jar in target + InvocationResult result = invokeEnhancer("-v -cp " + enhancerJar); + String outputString = result.getOutputString(); + String errorString = result.getErrorString(); + assertEquals("Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); + assertTrue("Expected classpath message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains(enhancerJar)); + } + + public void testOutputDirectory() { + // invoke enhancer with an output directory parameter + InvocationResult result = invokeEnhancer("-v -d some/output/directory"); + String outputString = result.getOutputString(); + String errorString = result.getErrorString(); + assertEquals("Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); + assertTrue("Expected directory message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("some/output/directory")); + } + + public void testMissingOutputDirectory() { + // invoke enhancer with missing parameter + InvocationResult result = invokeEnhancer("-v -d"); + assertEquals("Wrong return value ", 3, result.getExitValue()); + } + + public void testDir() { + // invoke enhancer with directory and not recurse + InvocationResult result = invokeEnhancer("-v " + basedir + "/target/test-classes/enhancer-test-dir"); + String outputString = result.getOutputString(); + String errorString = result.getErrorString(); + assertEquals("Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); + assertTrue("Expected directory enhancer-test-dir in message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("enhancer-test-dir")); + assertTrue("Expected file file1.jdo in message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("file1.jdo")); + assertTrue("Expected file file2.class in message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("file2.class")); + assertTrue("Expected file file3.jar in message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("file3.jar")); + assertFalse("Expected no directory enhancer-test-subdir in message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("enhancer-test-subdir")); + assertTrue("Expected 3 files to be enhanced in message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("3")); + } + + public void testDirRecurse() { + // invoke enhancer with directory and recurse + InvocationResult result = invokeEnhancer("-v -r " + basedir + "/target/test-classes/enhancer-test-dir"); + String outputString = result.getOutputString(); + String errorString = result.getErrorString(); + assertEquals("Wrong exit code from Enhancer with stderr:\n" + errorString, 0, result.getExitValue()); + assertTrue("Expected directory enhancer-test-dir in message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("enhancer-test-dir")); + assertTrue("Expected directory enhancer-test-subdir in message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("enhancer-test-subdir")); + assertTrue("Expected file file1.jdo in message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("file1.jdo")); + assertTrue("Expected file file2.class in message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("file2.class")); + assertTrue("Expected file file3.jar in message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("file3.jar")); + assertTrue("Expected file file4.jdo in message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("file4.jdo")); + assertTrue("Expected file file5.class in message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("file5.class")); + assertTrue("Expected file file6.jar in message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("file6.jar")); + assertTrue("Expected 6 files to be enhanced in message from out:\n" + outputString + " with err:\n" + errorString, outputString.contains("6")); + } + + private InvocationResult invokeEnhancer(String string) { + InvocationResult result = new InvocationResult(); + try { + // create the java command to invoke the Enhancer + List commands = new ArrayList(); + // find the java command in the user's path + commands.add("java"); + commands.add("-cp"); + commands.add("" + basedir + "/target/classes" + pathDelimiter + "" + basedir + "/target/test-classes"); + commands.add("javax.jdo.Enhancer"); + // add the test options (from the method parameter) to the java command + String[] optionArray = string.split(" "); + for (String option: optionArray) { + commands.add(option); + } + String[] cmdarray = commands.toArray(new String[commands.size()]); + ProcessBuilder builder = new ProcessBuilder(cmdarray); + Process proc = builder.start(); + InputStream stdout = proc.getInputStream(); + InputStream stderr = proc.getErrorStream(); + CharBuffer outBuffer = CharBuffer.allocate(1000000); + CharBuffer errBuffer = CharBuffer.allocate(1000000); + Thread outputThread = createReaderThread(stdout, outBuffer); + Thread errorThread = createReaderThread(stderr, errBuffer); + int exitValue = proc.waitFor(); + result.setExitValue(exitValue); + errorThread.join(10000); // wait ten seconds to get stderr after process terminates + outputThread.join(10000); // wait ten seconds to get stdout after process terminates + result.setErrorString(errBuffer.toString()); + result.setOutputString(outBuffer.toString()); + // wait until the Enhancer command finishes + } catch (InterruptedException ex) { + throw new RuntimeException("InterruptedException", ex); + } catch (IOException ex) { + throw new RuntimeException("IOException", ex); + } catch (JDOException jdoex) { + jdoex.printStackTrace(); + Throwable[] throwables = jdoex.getNestedExceptions(); + System.out.println("Exception throwables of size: " + throwables.length); + for (Throwable throwable: throwables) { + throwable.printStackTrace(); + } + } + return result; + } + + private Thread createReaderThread(final InputStream input, final CharBuffer output) { + final Reader reader = new InputStreamReader(input); + Thread thread = new Thread( + new Runnable() { + public void run() { + int count = 0; + int outputBytesRead = 0; + try { + while (-1 != (outputBytesRead = reader.read(output))) { + count += outputBytesRead; + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + output.flip(); + } + } + }); + thread.start(); + return thread; + } + + class InvocationResult { + private int exitValue; + private String errorString; + private String outputString; + + int getExitValue() { + return exitValue; + } + + private void setExitValue(int exitValue) { + this.exitValue = exitValue; + } + + private void setErrorString(String errorString) { + this.errorString = errorString; + } + + String getErrorString() { + return errorString; + } + + private void setOutputString(String outputString) { + this.outputString = outputString; + } + + String getOutputString() { + return outputString; + } + + } + } diff --git a/api/src/test/java/javax/jdo/JDOConfigTestClassLoader.java b/api/src/test/java/javax/jdo/JDOConfigTestClassLoader.java index 513175b18..0646407e1 100644 --- a/api/src/test/java/javax/jdo/JDOConfigTestClassLoader.java +++ b/api/src/test/java/javax/jdo/JDOConfigTestClassLoader.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -22,34 +22,39 @@ import java.net.URL; import java.net.URLClassLoader; -/** A class loader that allows the user to add classpath entries. */ +/** + * A class loader that allows the user to add classpath entries. + */ public class JDOConfigTestClassLoader extends URLClassLoader { - /** Uses the CTCCL as the parent and adds the given path to this loader's classpath. */ - public JDOConfigTestClassLoader(String... additionalPath) throws IOException { - this(Thread.currentThread().getContextClassLoader(), additionalPath); - } - - /** Uses the given ClassLoader as the parent & adds the given paths to this loader's classpath. */ - public JDOConfigTestClassLoader(ClassLoader parent, String... additionalPaths) - throws IOException { - super(new URL[] {}, parent); - - for (String path : additionalPaths) { - addFile(path); + /** + * Uses the CTCCL as the parent and adds the given path to this loader's classpath. + */ + public JDOConfigTestClassLoader(String... additionalPath) throws IOException { + this(Thread.currentThread().getContextClassLoader(), additionalPath); + } + + /** + * Uses the given ClassLoader as the parent & adds the given paths to this loader's classpath. + */ + public JDOConfigTestClassLoader(ClassLoader parent, String... additionalPaths) throws IOException { + super(new URL[] {}, parent); + + for (String path : additionalPaths) { + addFile(path); + } } - } - public void addFile(String s) throws IOException { - addFile(new File(s)); - } + public void addFile(String s) throws IOException { + addFile(new File(s)); + } - public void addFile(File f) throws IOException { - addURL(f.toURI().toURL()); - } + public void addFile(File f) throws IOException { + addURL(f.toURI().toURL()); + } - @Override - public void addURL(URL url) { - super.addURL(url); - } + @Override + public void addURL(URL url) { + super.addURL(url); + } } diff --git a/api/src/test/java/javax/jdo/JDOHelperConfigTest.java b/api/src/test/java/javax/jdo/JDOHelperConfigTest.java index fd74a15e2..1825a0abd 100644 --- a/api/src/test/java/javax/jdo/JDOHelperConfigTest.java +++ b/api/src/test/java/javax/jdo/JDOHelperConfigTest.java @@ -21,463 +21,460 @@ import java.net.URLClassLoader; import java.util.HashMap; import java.util.Map; + import javax.jdo.util.BatchTestRunner; + import junit.framework.TestSuite; -/** Tests class javax.jdo.JDOHelper for META-INF/jdoconfig.xml compliance. */ +/** + * Tests class javax.jdo.JDOHelper for META-INF/jdoconfig.xml compliance. + */ public class JDOHelperConfigTest extends AbstractJDOConfigTest implements Constants { - public static void main(String args[]) { - BatchTestRunner.run(JDOHelperConfigTest.class); - } - - /** - * {@inheritDoc} - * - * @return {@inheritDoc} - */ - public static TestSuite suite() { - return new TestSuite(JDOHelperConfigTest.class); - } - - /** - * Builds up a {@link java.util.Map Map} object that contains key parameter values specific to a - * named test. All of the properties needed to run a particular test are loaded into this object. - * - * @param testVariant the name of the test to include in the {@link java.util.Map Map} values. - * @param listenerCount the number of life cycle listener class names to add to this map. The - * listener names will begin with the value stored in {@link - * javax.jdo.Constants.PROPERTY_INSTANCE_LIFECYCLE_LISTENER - * PROPERTY_INSTANCE_LIFECYCLE_LISTENER}. - * @param vendorSpecificPropertyCount the number of properties named of the form - *

    -   * "property." + testVariant + ".name"
    -   * 
    - * that are added to the map. - * @param excludeName if true the property specified by {@link javax.jdo.Constants.PROPERTY_NAME - * PROPERTY_NAME} is not added to the map. - * @param excludePUName if true the property specified by {@link - * javax.jdo.Constants.PROPERTY_PERSISTENCE_UNIT_NAME PROPERTY_PERSISTENCE_UNIT_NAME} is not - * added to the map. - * @return a new {@link java.util.Map Map} object populated with properties that can be used in - * this test suite. - */ - protected Map prepareInitialExpectedMap( - String testVariant, - int listenerCount, - int vendorSpecificPropertyCount, - boolean excludeName, - boolean excludePUName) { - Map expected = new HashMap(); - - if (!excludeName) { - expected.put(PROPERTY_NAME, PMF_ATTRIBUTE_NAME + "." + testVariant); + public static void main(String args[]) { + BatchTestRunner.run(JDOHelperConfigTest.class); + } + + /** + * {@inheritDoc} + * + * @return {@inheritDoc} + */ + public static TestSuite suite() { + return new TestSuite(JDOHelperConfigTest.class); + } + + /** + * Builds up a {@link java.util.Map Map} object that contains key parameter + * values specific to a named test. All of the properties needed to run a + * particular test are loaded into this object. + * + * @param testVariant + * the name of the test to include in the {@link java.util.Map + * Map} values. + * @param listenerCount + * the number of life cycle listener class names to add to this + * map. The listener names will begin with the value stored in + * {@link javax.jdo.Constants.PROPERTY_INSTANCE_LIFECYCLE_LISTENER + * PROPERTY_INSTANCE_LIFECYCLE_LISTENER}. + * @param vendorSpecificPropertyCount + * the number of properties named of the form + * + *
    +     * "property." + testVariant + ".name"
    +     * 
    + * + * that are added to the map. + * @param excludeName + * if true the property specified by + * {@link javax.jdo.Constants.PROPERTY_NAME PROPERTY_NAME} is not + * added to the map. + * @param excludePUName + * if true the property specified by + * {@link javax.jdo.Constants.PROPERTY_PERSISTENCE_UNIT_NAME + * PROPERTY_PERSISTENCE_UNIT_NAME} is not added to the map. + * @return a new {@link java.util.Map Map} object populated with properties + * that can be used in this test suite. + */ + protected Map prepareInitialExpectedMap(String testVariant, + int listenerCount, int vendorSpecificPropertyCount, + boolean excludeName, boolean excludePUName) { + Map expected = new HashMap(); + + if (!excludeName) { + expected.put(PROPERTY_NAME, PMF_ATTRIBUTE_NAME + "." + testVariant); + } + if (!excludePUName) { + expected.put(PROPERTY_PERSISTENCE_UNIT_NAME, + PMF_ATTRIBUTE_PERSISTENCE_UNIT_NAME + "." + testVariant); + } + + expected.put(PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS, + PMF_ATTRIBUTE_CLASS + "." + testVariant); + expected.put(PROPERTY_CONNECTION_DRIVER_NAME, + PMF_ATTRIBUTE_CONNECTION_DRIVER_NAME + "." + testVariant); + expected.put(PROPERTY_CONNECTION_FACTORY_NAME, + PMF_ATTRIBUTE_CONNECTION_FACTORY_NAME + "." + testVariant); + expected.put(PROPERTY_CONNECTION_FACTORY2_NAME, + PMF_ATTRIBUTE_CONNECTION_FACTORY2_NAME + "." + testVariant); + expected.put(PROPERTY_CONNECTION_PASSWORD, + PMF_ATTRIBUTE_CONNECTION_PASSWORD + "." + testVariant); + expected.put(PROPERTY_CONNECTION_URL, PMF_ATTRIBUTE_CONNECTION_URL + + "." + testVariant); + expected.put(PROPERTY_CONNECTION_USER_NAME, + PMF_ATTRIBUTE_CONNECTION_USER_NAME + "." + testVariant); + expected.put(PROPERTY_IGNORE_CACHE, PMF_ATTRIBUTE_IGNORE_CACHE + "." + + testVariant); + expected.put(PROPERTY_MAPPING, PMF_ATTRIBUTE_MAPPING + "." + + testVariant); + expected.put(PROPERTY_MULTITHREADED, PMF_ATTRIBUTE_MULTITHREADED + "." + + testVariant); + expected.put(PROPERTY_NONTRANSACTIONAL_READ, + PMF_ATTRIBUTE_NONTRANSACTIONAL_READ + "." + testVariant); + expected.put(PROPERTY_NONTRANSACTIONAL_WRITE, + PMF_ATTRIBUTE_NONTRANSACTIONAL_WRITE + "." + testVariant); + expected.put(PROPERTY_OPTIMISTIC, PMF_ATTRIBUTE_OPTIMISTIC + "." + + testVariant); + expected.put(PROPERTY_RESTORE_VALUES, PMF_ATTRIBUTE_RESTORE_VALUES + + "." + testVariant); + expected.put(PROPERTY_RETAIN_VALUES, PMF_ATTRIBUTE_RETAIN_VALUES + "." + + testVariant); + expected.put(PROPERTY_DETACH_ALL_ON_COMMIT, + PMF_ATTRIBUTE_DETACH_ALL_ON_COMMIT + "." + testVariant); + expected.put(PROPERTY_SERVER_TIME_ZONE_ID, + PMF_ATTRIBUTE_SERVER_TIME_ZONE_ID + "." + testVariant); + + // listeners + for (int i = 0; i < listenerCount; i++) { + expected.put(PROPERTY_PREFIX_INSTANCE_LIFECYCLE_LISTENER + + "listener." + testVariant + ".listener" + i, "classes." + + testVariant + ".classes" + i); + } + + // vendor-specific properties + for (int i = 0; i < vendorSpecificPropertyCount; i++) { + expected.put("property." + testVariant + ".name" + i, "property." + testVariant + ".value" + i); + } + + return expected; } - if (!excludePUName) { - expected.put( - PROPERTY_PERSISTENCE_UNIT_NAME, PMF_ATTRIBUTE_PERSISTENCE_UNIT_NAME + "." + testVariant); + + /** + * Performs a test specified by testVariantName, by building up a + * property map and executing the test according to the property values. + * With this version of doPositiveTest the property name ( + * {@link javax.jdo.Constants.PROPERTY_NAME PROPERTY_NAME}) and the + * {@link javax.jdo.Constants.PERSISTENCE_UNIT_NAME PERSISTENCE_UNIT_NAME}) + * are included in the property map that is used to run the test. + * + * @param classpaths + * class paths to add to the class loader that runs the test that + * specify where jdoconfig.xml can be found. + * @param testVariantName + * the name of the test. + * @param listenerCount + * number of listeners utilized in the test. + * @param vendorSpecificPropertyCount + * number of vendor properties used in the test. + * @param checkEqualProperties + * if true the test's properties are tested. + * @throws java.io.IOException + * if an {@java.io.IOException + * IOException} occurs during class loading or any part of the + * test. + */ + protected void doPositiveTest(String[] classpaths, String testVariantName, + int listenerCount, int vendorSpecificPropertyCount, + boolean checkEqualProperties) throws IOException { + + doPositiveTest(classpaths, testVariantName, listenerCount, + vendorSpecificPropertyCount, checkEqualProperties, false, false); + } + + /** + * Performs a test specified by testVariantName, by building up a + * property map and executing the test according to the property values. An + * assertion exeception is thrown if the test being run has a negative + * (non-true) result. With this version of doPositiveTest the + * property name ({@link javax.jdo.Constants.PROPERTY_NAME PROPERTY_NAME}) + * and the {@link javax.jdo.Constants.PERSISTENCE_UNIT_NAME + * PERSISTENCE_UNIT_NAME}) are included in the property map that is used to + * run the test. + * + * @param classpaths + * class paths to add to the class loader that runs the test that + * specify where jdoconfig.xml can be found. + * @param testVariantName + * the name of the test. + * @param listenerCount + * number of listeners utilized in the test. + * @param vendorSpecificPropertyCount + * number of vendor properties used in the test. + * @param checkEqualProperties + * if true the test's properties are tested. + * @param excludeName + * if true the property specified by + * {@link javax.jdo.Constants.PROPERTY_NAME PROPERTY_NAME} is not + * added to the map. + * @param excludePUName + * if true the property specified by + * {@link javax.jdo.Constants.PROPERTY_PERSISTENCE_UNIT_NAME + * PROPERTY_PERSISTENCE_UNIT_NAME} is not added to the map. + * @throws java.io.IOException + * if an {@java.io.IOException + * IOException} occurs during class loading or any part of the + * test. + */ + protected void doPositiveTest(String[] classpaths, String testVariantName, + int listenerCount, int vendorSpecificPropertyCount, + boolean checkEqualProperties, boolean excludeName, + boolean excludePUName) throws IOException { + + URLClassLoader loader = new JDOConfigTestClassLoader( + getClass().getClassLoader(), classpaths); + Map expected = prepareInitialExpectedMap(testVariantName, + listenerCount, vendorSpecificPropertyCount, excludeName, excludePUName); + String name = testVariantName == null ? null : (String) expected.get(PROPERTY_NAME); + Map actual = JDOHelper.getPropertiesFromJdoconfig(name, loader); + + assertNotNull("No properties found", actual); + if (checkEqualProperties) { + assertEqualProperties(expected, actual); + } + } + + public void testPositive00_PMF0_BasicPMFConfigUsingOnlyStandardAttributesAndListeners() + throws IOException { + doPositiveTest(new String[] { JDOCONFIG_CLASSPATH_PREFIX + "/Positive00" }, "positive00.pmf0", 2, 0, true); + } + + public void testPositive00_PMF1_BasicPMFConfigUsingOnlyPropertyElementsWithStandardJavaxDotJDOProperties() + throws IOException { + doPositiveTest(new String[] { JDOCONFIG_CLASSPATH_PREFIX + "/Positive00" }, "positive00.pmf1", 2, 0, true); + } + + public void testPositive00_PMF2_NestedPropertyElementsWithOnlyStandardAttributeNames() + throws IOException { + doPositiveTest(new String[] { JDOCONFIG_CLASSPATH_PREFIX+ "/Positive00" }, "positive00.pmf2", 2, 0, true); + } + + public void testPositive00_PMF3_StandardAttributesPlusNonstandardPropertiesInPropertyElements() + throws IOException { + doPositiveTest(new String[] { JDOCONFIG_CLASSPATH_PREFIX + "/Positive00" }, "positive00.pmf3", 2, 2, true); + } + + public void testPositive00_PMF4_StandardAttributesPlusNonstandardAttributes() + throws IOException { + doPositiveTest(new String[] { JDOCONFIG_CLASSPATH_PREFIX + "/Positive00" }, "positive00.pmf4", 0, 2, true); } - expected.put( - PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS, PMF_ATTRIBUTE_CLASS + "." + testVariant); - expected.put( - PROPERTY_CONNECTION_DRIVER_NAME, PMF_ATTRIBUTE_CONNECTION_DRIVER_NAME + "." + testVariant); - expected.put( - PROPERTY_CONNECTION_FACTORY_NAME, - PMF_ATTRIBUTE_CONNECTION_FACTORY_NAME + "." + testVariant); - expected.put( - PROPERTY_CONNECTION_FACTORY2_NAME, - PMF_ATTRIBUTE_CONNECTION_FACTORY2_NAME + "." + testVariant); - expected.put( - PROPERTY_CONNECTION_PASSWORD, PMF_ATTRIBUTE_CONNECTION_PASSWORD + "." + testVariant); - expected.put(PROPERTY_CONNECTION_URL, PMF_ATTRIBUTE_CONNECTION_URL + "." + testVariant); - expected.put( - PROPERTY_CONNECTION_USER_NAME, PMF_ATTRIBUTE_CONNECTION_USER_NAME + "." + testVariant); - expected.put(PROPERTY_IGNORE_CACHE, PMF_ATTRIBUTE_IGNORE_CACHE + "." + testVariant); - expected.put(PROPERTY_MAPPING, PMF_ATTRIBUTE_MAPPING + "." + testVariant); - expected.put(PROPERTY_MULTITHREADED, PMF_ATTRIBUTE_MULTITHREADED + "." + testVariant); - expected.put( - PROPERTY_NONTRANSACTIONAL_READ, PMF_ATTRIBUTE_NONTRANSACTIONAL_READ + "." + testVariant); - expected.put( - PROPERTY_NONTRANSACTIONAL_WRITE, PMF_ATTRIBUTE_NONTRANSACTIONAL_WRITE + "." + testVariant); - expected.put(PROPERTY_OPTIMISTIC, PMF_ATTRIBUTE_OPTIMISTIC + "." + testVariant); - expected.put(PROPERTY_RESTORE_VALUES, PMF_ATTRIBUTE_RESTORE_VALUES + "." + testVariant); - expected.put(PROPERTY_RETAIN_VALUES, PMF_ATTRIBUTE_RETAIN_VALUES + "." + testVariant); - expected.put( - PROPERTY_DETACH_ALL_ON_COMMIT, PMF_ATTRIBUTE_DETACH_ALL_ON_COMMIT + "." + testVariant); - expected.put( - PROPERTY_SERVER_TIME_ZONE_ID, PMF_ATTRIBUTE_SERVER_TIME_ZONE_ID + "." + testVariant); - - // listeners - for (int i = 0; i < listenerCount; i++) { - expected.put( - PROPERTY_PREFIX_INSTANCE_LIFECYCLE_LISTENER + "listener." + testVariant + ".listener" + i, - "classes." + testVariant + ".classes" + i); + public void testPositive01_DuplicatePUsInDifferentConfigFilesButNotRequested() + throws IOException { + String[] classpaths = new String[] { + JDOCONFIG_CLASSPATH_PREFIX + "/Positive01/1a", + JDOCONFIG_CLASSPATH_PREFIX + "/Positive01/1b" }; + URLClassLoader loader = new JDOConfigTestClassLoader(getClass().getClassLoader(), classpaths); + Map actual = JDOHelper.getPropertiesFromJdoconfig( + ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader); } - // vendor-specific properties - for (int i = 0; i < vendorSpecificPropertyCount; i++) { - expected.put( - "property." + testVariant + ".name" + i, "property." + testVariant + ".value" + i); + public void testPositive02_GetAnonymousPMFWithNoProperties() + throws IOException { + + URLClassLoader loader = new JDOConfigTestClassLoader( + getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Positive02/"); + + Map properties = JDOHelper.getPropertiesFromJdoconfig( + ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader); + assertNotNull("Anonymous PMF with no properties returned null", properties); + assertTrue("Anonymous PMF with no properties had properties", properties.size() == 0); } - return expected; - } - - /** - * Performs a test specified by testVariantName, by building up a property map and - * executing the test according to the property values. With this version of - * doPositiveTest the property name ( {@link javax.jdo.Constants.PROPERTY_NAME - * PROPERTY_NAME}) and the {@link javax.jdo.Constants.PERSISTENCE_UNIT_NAME - * PERSISTENCE_UNIT_NAME}) are included in the property map that is used to run the test. - * - * @param classpaths class paths to add to the class loader that runs the test that specify where - * jdoconfig.xml can be found. - * @param testVariantName the name of the test. - * @param listenerCount number of listeners utilized in the test. - * @param vendorSpecificPropertyCount number of vendor properties used in the test. - * @param checkEqualProperties if true the test's properties are tested. - * @throws java.io.IOException if an {@java.io.IOException IOException} occurs during class - * loading or any part of the test. - */ - protected void doPositiveTest( - String[] classpaths, - String testVariantName, - int listenerCount, - int vendorSpecificPropertyCount, - boolean checkEqualProperties) - throws IOException { - - doPositiveTest( - classpaths, - testVariantName, - listenerCount, - vendorSpecificPropertyCount, - checkEqualProperties, - false, - false); - } - - /** - * Performs a test specified by testVariantName, by building up a property map and - * executing the test according to the property values. An assertion exeception is thrown if the - * test being run has a negative (non-true) result. With this version of doPositiveTest - * the property name ({@link javax.jdo.Constants.PROPERTY_NAME PROPERTY_NAME}) and the {@link - * javax.jdo.Constants.PERSISTENCE_UNIT_NAME PERSISTENCE_UNIT_NAME}) are included in the property - * map that is used to run the test. - * - * @param classpaths class paths to add to the class loader that runs the test that specify where - * jdoconfig.xml can be found. - * @param testVariantName the name of the test. - * @param listenerCount number of listeners utilized in the test. - * @param vendorSpecificPropertyCount number of vendor properties used in the test. - * @param checkEqualProperties if true the test's properties are tested. - * @param excludeName if true the property specified by {@link javax.jdo.Constants.PROPERTY_NAME - * PROPERTY_NAME} is not added to the map. - * @param excludePUName if true the property specified by {@link - * javax.jdo.Constants.PROPERTY_PERSISTENCE_UNIT_NAME PROPERTY_PERSISTENCE_UNIT_NAME} is not - * added to the map. - * @throws java.io.IOException if an {@java.io.IOException IOException} occurs during class - * loading or any part of the test. - */ - protected void doPositiveTest( - String[] classpaths, - String testVariantName, - int listenerCount, - int vendorSpecificPropertyCount, - boolean checkEqualProperties, - boolean excludeName, - boolean excludePUName) - throws IOException { - - URLClassLoader loader = new JDOConfigTestClassLoader(getClass().getClassLoader(), classpaths); - Map expected = - prepareInitialExpectedMap( - testVariantName, - listenerCount, - vendorSpecificPropertyCount, - excludeName, - excludePUName); - String name = testVariantName == null ? null : (String) expected.get(PROPERTY_NAME); - Map actual = JDOHelper.getPropertiesFromJdoconfig(name, loader); - - assertNotNull("No properties found", actual); - if (checkEqualProperties) { - assertEqualProperties(expected, actual); + public void testPositive03_PMF0_PMFClassNameViaServicesLookup() + throws IOException { + URLClassLoader loader = new JDOConfigTestClassLoader( + getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Positive03/"); + + String expected = "class.positive03.pmf0"; + String actual = getPMFClassNameViaServiceLookup(loader); + + assertNotNull("No PMF name found via services lookup", actual); + assertEquals(expected, actual); } - } - - public void testPositive00_PMF0_BasicPMFConfigUsingOnlyStandardAttributesAndListeners() - throws IOException { - doPositiveTest( - new String[] {JDOCONFIG_CLASSPATH_PREFIX + "/Positive00"}, "positive00.pmf0", 2, 0, true); - } - - public void - testPositive00_PMF1_BasicPMFConfigUsingOnlyPropertyElementsWithStandardJavaxDotJDOProperties() - throws IOException { - doPositiveTest( - new String[] {JDOCONFIG_CLASSPATH_PREFIX + "/Positive00"}, "positive00.pmf1", 2, 0, true); - } - - public void testPositive00_PMF2_NestedPropertyElementsWithOnlyStandardAttributeNames() - throws IOException { - doPositiveTest( - new String[] {JDOCONFIG_CLASSPATH_PREFIX + "/Positive00"}, "positive00.pmf2", 2, 0, true); - } - - public void testPositive00_PMF3_StandardAttributesPlusNonstandardPropertiesInPropertyElements() - throws IOException { - doPositiveTest( - new String[] {JDOCONFIG_CLASSPATH_PREFIX + "/Positive00"}, "positive00.pmf3", 2, 2, true); - } - - public void testPositive00_PMF4_StandardAttributesPlusNonstandardAttributes() throws IOException { - doPositiveTest( - new String[] {JDOCONFIG_CLASSPATH_PREFIX + "/Positive00"}, "positive00.pmf4", 0, 2, true); - } - - public void testPositive01_DuplicatePUsInDifferentConfigFilesButNotRequested() - throws IOException { - String[] classpaths = - new String[] { - JDOCONFIG_CLASSPATH_PREFIX + "/Positive01/1a", - JDOCONFIG_CLASSPATH_PREFIX + "/Positive01/1b" - }; - URLClassLoader loader = new JDOConfigTestClassLoader(getClass().getClassLoader(), classpaths); - Map actual = - JDOHelper.getPropertiesFromJdoconfig(ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader); - } - - public void testPositive02_GetAnonymousPMFWithNoProperties() throws IOException { - - URLClassLoader loader = - new JDOConfigTestClassLoader( - getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Positive02/"); - - Map properties = - JDOHelper.getPropertiesFromJdoconfig(ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader); - assertNotNull("Anonymous PMF with no properties returned null", properties); - assertTrue("Anonymous PMF with no properties had properties", properties.size() == 0); - } - - public void testPositive03_PMF0_PMFClassNameViaServicesLookup() throws IOException { - URLClassLoader loader = - new JDOConfigTestClassLoader( - getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Positive03/"); - - String expected = "class.positive03.pmf0"; - String actual = getPMFClassNameViaServiceLookup(loader); - - assertNotNull("No PMF name found via services lookup", actual); - assertEquals(expected, actual); - } - - public void testPositive04_PMF0_PMFClassNameViaServicesLookup() throws IOException { - - URLClassLoader loader = - new JDOConfigTestClassLoader( + + public void testPositive04_PMF0_PMFClassNameViaServicesLookup() + throws IOException { + + URLClassLoader loader = new JDOConfigTestClassLoader( getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Positive04/"); - String expected = "class.positive04.pmf0"; - String actual = getPMFClassNameViaServiceLookup(loader); + String expected = "class.positive04.pmf0"; + String actual = getPMFClassNameViaServiceLookup(loader); - assertNotNull("No PMF name found via services lookup", actual); - assertEquals(expected, actual); - } + assertNotNull("No PMF name found via services lookup", actual); + assertEquals(expected, actual); + } - public void testPositive05_PMF0_PMFClassNameViaServicesLookup() throws IOException { + public void testPositive05_PMF0_PMFClassNameViaServicesLookup() + throws IOException { - URLClassLoader loader = - new JDOConfigTestClassLoader( + URLClassLoader loader = new JDOConfigTestClassLoader( getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Positive05/"); - String expected = "class.positive05.pmf0"; - String actual = getPMFClassNameViaServiceLookup(loader); + String expected = "class.positive05.pmf0"; + String actual = getPMFClassNameViaServiceLookup(loader); - assertNotNull("No PMF name found via services lookup", actual); - assertEquals(expected, actual); - } + assertNotNull("No PMF name found via services lookup", actual); + assertEquals(expected, actual); + } - public void testPositive06_PMF0_GetAnonymousPMFProperties() throws IOException { + public void testPositive06_PMF0_GetAnonymousPMFProperties() + throws IOException { - URLClassLoader loader = - new JDOConfigTestClassLoader( - getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Positive06/"); + URLClassLoader loader = new JDOConfigTestClassLoader( + getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Positive06/"); - Map expected = prepareInitialExpectedMap("positive06.pmf0", 2, 0, true, true); - Map actual = - JDOHelper.getPropertiesFromJdoconfig(ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader); + Map expected = prepareInitialExpectedMap("positive06.pmf0", 2, 0, true, true); + Map actual = JDOHelper.getPropertiesFromJdoconfig( + ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader); - assertNotNull("No properties found", actual); - assertEqualProperties(expected, actual); - } + assertNotNull("No properties found", actual); + assertEqualProperties(expected, actual); + } - public void testPositive07_PMF0_GetAnonymousPMFPropertiesWithPUName() throws IOException { + public void testPositive07_PMF0_GetAnonymousPMFPropertiesWithPUName() + throws IOException { - URLClassLoader loader = - new JDOConfigTestClassLoader( - getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Positive07/"); + URLClassLoader loader = new JDOConfigTestClassLoader( + getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Positive07/"); - Map expected = prepareInitialExpectedMap("positive07.pmf0", 2, 0, true, false); - Map actual = - JDOHelper.getPropertiesFromJdoconfig(ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader); + Map expected = prepareInitialExpectedMap("positive07.pmf0", 2, 0, true, false); + Map actual = JDOHelper.getPropertiesFromJdoconfig( + ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, loader); - assertNotNull("No properties found", actual); - assertEqualProperties(expected, actual); - } + assertNotNull("No properties found", actual); + assertEqualProperties(expected, actual); + } - public void testNegative00_EmptyJDOConfigXML() throws IOException { - try { - URLClassLoader loader = - new JDOConfigTestClassLoader( - getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative0/"); - JDOHelper.getPersistenceManagerFactory(loader); - fail("JDOHelper failed to throw JDOFatalUserException"); - } catch (JDOFatalUserException x) { - // sunny day + public void testNegative00_EmptyJDOConfigXML() throws IOException { + try { + URLClassLoader loader = new JDOConfigTestClassLoader( + getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative0/"); + JDOHelper.getPersistenceManagerFactory(loader); + fail("JDOHelper failed to throw JDOFatalUserException"); + } catch (JDOFatalUserException x) { + // sunny day + } } - } - - public void testNegative01_NoPersistenceUnitsDefined() throws IOException { - try { - URLClassLoader loader = - new JDOConfigTestClassLoader( - getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative01/"); - JDOHelper.getPersistenceManagerFactory(loader); - fail("JDOHelper failed to throw JDOFatalUserException"); - } catch (JDOFatalUserException x) { - // joy, sweet joy + + public void testNegative01_NoPersistenceUnitsDefined() throws IOException { + try { + URLClassLoader loader = new JDOConfigTestClassLoader( + getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative01/"); + JDOHelper.getPersistenceManagerFactory(loader); + fail("JDOHelper failed to throw JDOFatalUserException"); + } catch (JDOFatalUserException x) { + // joy, sweet joy + } } - } - - public void testNegative02_DuplicateAnonymousPersistenceUnitsInSameConfig() throws IOException { - try { - URLClassLoader loader = - new JDOConfigTestClassLoader( - getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative02/"); - JDOHelper.getPersistenceManagerFactory(loader); - fail("JDOHelper failed to throw JDOFatalUserException"); - } catch (JDOFatalUserException x) { - // the cockles of my heart warmeth + + public void testNegative02_DuplicateAnonymousPersistenceUnitsInSameConfig() + throws IOException { + try { + URLClassLoader loader = new JDOConfigTestClassLoader( + getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative02/"); + JDOHelper.getPersistenceManagerFactory(loader); + fail("JDOHelper failed to throw JDOFatalUserException"); + } catch (JDOFatalUserException x) { + // the cockles of my heart warmeth + } } - } - - public void testNegative03_DuplicateNamedPersistenceUnitsInSameConfig() throws IOException { - try { - URLClassLoader loader = - new JDOConfigTestClassLoader( - getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative03/"); - JDOHelper.getPersistenceManagerFactory("name.negative03", loader); - fail("JDOHelper failed to throw JDOFatalUserException"); - } catch (JDOFatalUserException x) { - // warm fuzzies + + public void testNegative03_DuplicateNamedPersistenceUnitsInSameConfig() + throws IOException { + try { + URLClassLoader loader = new JDOConfigTestClassLoader( + getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative03/"); + JDOHelper.getPersistenceManagerFactory("name.negative03", loader); + fail("JDOHelper failed to throw JDOFatalUserException"); + } catch (JDOFatalUserException x) { + // warm fuzzies + } } - } - - public void testNegative04_DuplicatePUNamePropertyInAttributeAndElement() throws IOException { - try { - URLClassLoader loader = - new JDOConfigTestClassLoader( - getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative04/"); - JDOHelper.getPersistenceManagerFactory("name.negative04.value0", loader); - fail("JDOHelper failed to throw JDOFatalUserException"); - } catch (JDOFatalUserException x) { - // no cold pricklies + + public void testNegative04_DuplicatePUNamePropertyInAttributeAndElement() + throws IOException { + try { + URLClassLoader loader = new JDOConfigTestClassLoader( + getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative04/"); + JDOHelper.getPersistenceManagerFactory("name.negative04.value0", loader); + fail("JDOHelper failed to throw JDOFatalUserException"); + } catch (JDOFatalUserException x) { + // no cold pricklies + } } - } - - public void testNegative05_DuplicatePropertyInAttributeAndElement() throws IOException { - try { - URLClassLoader loader = - new JDOConfigTestClassLoader( - getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative05/"); - JDOHelper.getPersistenceManagerFactory(loader); - fail("JDOHelper failed to throw JDOFatalUserException"); - } catch (JDOFatalUserException x) { - // party! + + public void testNegative05_DuplicatePropertyInAttributeAndElement() + throws IOException { + try { + URLClassLoader loader = new JDOConfigTestClassLoader( + getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative05/"); + JDOHelper.getPersistenceManagerFactory(loader); + fail("JDOHelper failed to throw JDOFatalUserException"); + } catch (JDOFatalUserException x) { + // party! + } } - } - - public void testNegative06_DuplicatePUInDifferentConfigFiles() throws IOException { - try { - URLClassLoader loader = - new JDOConfigTestClassLoader( - getClass().getClassLoader(), - JDOCONFIG_CLASSPATH_PREFIX + "/Negative06/6a/", - JDOCONFIG_CLASSPATH_PREFIX + "/Negative06/6b/"); - JDOHelper.getPersistenceManagerFactory("name.negative06", loader); - fail("JDOHelper failed to throw JDOFatalUserException"); - } catch (JDOFatalUserException x) { - // clear blue sky + + public void testNegative06_DuplicatePUInDifferentConfigFiles() + throws IOException { + try { + URLClassLoader loader = new JDOConfigTestClassLoader( + getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative06/6a/", + JDOCONFIG_CLASSPATH_PREFIX + "/Negative06/6b/"); + JDOHelper.getPersistenceManagerFactory("name.negative06", loader); + fail("JDOHelper failed to throw JDOFatalUserException"); + } catch (JDOFatalUserException x) { + // clear blue sky + } } - } - public void testNegative07_EmptyServicesFile() throws IOException { - JDOConfigTestClassLoader testLoader = - new JDOConfigTestClassLoader( + public void testNegative07_EmptyServicesFile() throws IOException { + JDOConfigTestClassLoader testLoader = new JDOConfigTestClassLoader( getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative07/"); - String shouldBeNull = getPMFClassNameViaServiceLookup(testLoader); - assertNull(shouldBeNull); - } - - public void testNegative08_NoResourcesFound() { - String resource = "" + RANDOM.nextLong(); - InputStream in = getClass().getClassLoader().getResourceAsStream(resource); - assertNull(in); - - // resource pretty much guaranteed not to exist - try { - JDOHelper.getPersistenceManagerFactory(resource); - fail("JDOHelper failed to throw JDOFatalUserException"); - } catch (JDOFatalUserException x) { - // happy path + String shouldBeNull = getPMFClassNameViaServiceLookup(testLoader); + assertNull(shouldBeNull); } - } - public void testNegative08_ServicesFileWithOnlyComments() throws IOException { - JDOConfigTestClassLoader testLoader = - new JDOConfigTestClassLoader( + public void testNegative08_NoResourcesFound() { + String resource = "" + RANDOM.nextLong(); + InputStream in = getClass().getClassLoader().getResourceAsStream(resource); + assertNull(in); + + // resource pretty much guaranteed not to exist + try { + JDOHelper.getPersistenceManagerFactory(resource); + fail("JDOHelper failed to throw JDOFatalUserException"); + } catch (JDOFatalUserException x) { + // happy path + } + } + + public void testNegative08_ServicesFileWithOnlyComments() + throws IOException { + JDOConfigTestClassLoader testLoader = new JDOConfigTestClassLoader( getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative08/"); - String shouldBeNull = getPMFClassNameViaServiceLookup(testLoader); - assertNull(shouldBeNull); - } - - public void testNegative09_MultipleInvalidClassesInDifferentServicesFiles() throws IOException { - - // no class name in Negative09/jdoconfig.xml - // 9a and 9b include services/javax.jdo.PersistenceManagerFactory - // with bad implementations - try { - URLClassLoader loader = - new JDOConfigTestClassLoader( - getClass().getClassLoader(), - JDOCONFIG_CLASSPATH_PREFIX + "/Negative09/9a/", - JDOCONFIG_CLASSPATH_PREFIX + "/Negative09/9b/", - TEST_CLASSPATH, - API_CLASSPATH); - JDOHelper.getPersistenceManagerFactory("name.negative09", loader); - fail("JDOHelper failed to throw JDOFatalUserException"); - } catch (JDOFatalException x) { - Throwable[] nestedExceptions = x.getNestedExceptions(); - if (nestedExceptions.length != 2) { - appendMessage( - "JDOHelper.getPersistenceManagerFactory wrong number of " - + "nested exceptions. Expected 2, got " - + nestedExceptions.length - + "\n" - + x); - } - for (int i = 0; i < nestedExceptions.length; ++i) { - Throwable exception = nestedExceptions[i]; - if (!(exception instanceof JDOFatalException)) { - appendMessage( - "Nested exception " - + exception.getClass().getName() - + " is not a JDOFatalException."); + String shouldBeNull = getPMFClassNameViaServiceLookup(testLoader); + assertNull(shouldBeNull); + } + + public void testNegative09_MultipleInvalidClassesInDifferentServicesFiles() + throws IOException { + + // no class name in Negative09/jdoconfig.xml + // 9a and 9b include services/javax.jdo.PersistenceManagerFactory + // with bad implementations + try { + URLClassLoader loader = new JDOConfigTestClassLoader( + getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + "/Negative09/9a/", + JDOCONFIG_CLASSPATH_PREFIX + "/Negative09/9b/", TEST_CLASSPATH, API_CLASSPATH); + JDOHelper.getPersistenceManagerFactory("name.negative09", loader); + fail("JDOHelper failed to throw JDOFatalUserException"); + } catch (JDOFatalException x) { + Throwable[] nestedExceptions = x.getNestedExceptions(); + if (nestedExceptions.length != 2) { + appendMessage("JDOHelper.getPersistenceManagerFactory wrong number of " + + "nested exceptions. Expected 2, got " + + nestedExceptions.length + "\n" + x); + } + for (int i = 0; i < nestedExceptions.length; ++i) { + Throwable exception = nestedExceptions[i]; + if (!(exception instanceof JDOFatalException)) { + appendMessage("Nested exception " + exception.getClass().getName() + + " is not a JDOFatalException."); + } + } } - } + failOnError(); } - failOnError(); - } } diff --git a/api/src/test/java/javax/jdo/JDOHelperTest.java b/api/src/test/java/javax/jdo/JDOHelperTest.java index 8181a3942..727bf1a9e 100644 --- a/api/src/test/java/javax/jdo/JDOHelperTest.java +++ b/api/src/test/java/javax/jdo/JDOHelperTest.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,533 +19,619 @@ import java.io.File; import java.io.InputStream; + import java.util.HashMap; import java.util.Map; import java.util.Properties; + import javax.jdo.pc.PCPoint; import javax.jdo.util.AbstractTest; import javax.jdo.util.BatchTestRunner; + import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; /** * Tests class javax.jdo.JDOHelper. - * - *

    TBD: implementation of testMakeDirty, TBD: testing interrogative methods for persistent - * instances TBD: getPMF for valid PMF class + *

    + * TBD: implementation of testMakeDirty, + * TBD: testing interrogative methods for persistent instances + * TBD: getPMF for valid PMF class */ public class JDOHelperTest extends AbstractTest { - - /** */ - public static void main(String args[]) { - BatchTestRunner.run(JDOHelperTest.class); - } - - /** - * The purpose of this test is simply to call some of the methods on a constructed instance of - * JDOHelper and verify that they do not throw exceptions. It is not a functional test. - * - * @since 2.1 - */ - public void testConstructor() { - assertNull("getObjectId(null) returned non-null", JDOHelper.getObjectId(null)); - assertNull( - "getPersistenceManager(null) returned non-null", JDOHelper.getPersistenceManager(null)); - assertNull( - "getTransactionalObjectId(null) returned non-null", - JDOHelper.getTransactionalObjectId(null)); - assertNull("getVersion(null) returned non-null", JDOHelper.getVersion(null)); - assertFalse("isDeleted(null) returned non-null", JDOHelper.isDeleted(null)); - assertFalse("isDetached(null) returned non-null", JDOHelper.isDetached(null)); - assertFalse("isDirty(null) returned non-null", JDOHelper.isDirty(null)); - assertFalse("isNew(null) returned non-null", JDOHelper.isNew(null)); - assertFalse("isPersistent(null) returned non-null", JDOHelper.isPersistent(null)); - assertFalse("isTransactional(null) returned non-null", JDOHelper.isTransactional(null)); - } - - /** - * The purpose of this test is simply to call some of the methods on the static instance of - * JDOHelper and verify that they do not throw exceptions. It is not a functional test. - * - * @since 2.1 - */ - public void testGetInstance() { - assertNull("getObjectId(null) returned non-null", JDOHelper.getObjectId(null)); - assertNull( - "getPersistenceManager(null) returned non-null", JDOHelper.getPersistenceManager(null)); - assertNull( - "getTransactionalObjectId(null) returned non-null", - JDOHelper.getTransactionalObjectId(null)); - assertNull("getVersion(null) returned non-null", JDOHelper.getVersion(null)); - assertFalse("isDeleted(null) returned non-null", JDOHelper.isDeleted(null)); - assertFalse("isDetached(null) returned non-null", JDOHelper.isDetached(null)); - assertFalse("isDirty(null) returned non-null", JDOHelper.isDirty(null)); - assertFalse("isNew(null) returned non-null", JDOHelper.isNew(null)); - assertFalse("isPersistent(null) returned non-null", JDOHelper.isPersistent(null)); - assertFalse("isTransactional(null) returned non-null", JDOHelper.isTransactional(null)); - } - - /** */ - public void testGetPM() { - PCPoint p = new PCPoint(1, Integer.valueOf(1)); - if (JDOHelper.getPersistenceManager(p) != null) { - fail("JDOHelper.getPersistenceManager should return null pm for non-persistent instance"); - } - - // TBD: test for persistent instance - } - - /** */ - public void testMakeDirty() { - // TBD: test JDOHelper.makeDirty(pc, fieldName); - } - - /** */ - public void testGetObjectId() { - PCPoint p = new PCPoint(1, Integer.valueOf(1)); - if (JDOHelper.getObjectId(p) != null) { - fail("JDOHelper.getObjectId should return null ObjectId for non-persistent instance"); - } - - // TBD test JDOHelper.getObjectId(pc) for persistent instance - } - - /** */ - public void testGetTransactionObjectId() { - PCPoint p = new PCPoint(1, Integer.valueOf(1)); - if (JDOHelper.getObjectId(p) != null) { - fail( - "JDOHelper.getTransactionalObjectId should return null ObjectId for non-persistent instance"); - } - - // TBD test JDOHelper.getTransactionalObjectId(pc) for persistent instance - } - - /** */ - public void testIsDirty() { - PCPoint p = new PCPoint(1, Integer.valueOf(1)); - if (JDOHelper.isDirty(p)) { - fail("JDOHelper.isDirty should return false for non-persistent instance"); - } - - // TBD test JDOHelper.isDirty(pc) for persistent instance - } - - /** */ - public void testIsTransactional() { - PCPoint p = new PCPoint(1, Integer.valueOf(1)); - if (JDOHelper.isTransactional(p)) { - fail("JDOHelper.isTransactional should return false for non-persistent instance"); - } - - // TBD test JDOHelper.isTransactional(pc) for persistent instance - } - - /** */ - public void testIsPersistent() { - PCPoint p = new PCPoint(1, Integer.valueOf(1)); - if (JDOHelper.isPersistent(p)) { - fail("JDOHelper.isPersistent should return false for non-persistent instance"); - } - - // TBD test JDOHelper.isPersistent(pc) for persistent instance - } - - /** */ - public void testIsNew() { - PCPoint p = new PCPoint(1, Integer.valueOf(1)); - if (JDOHelper.isNew(p)) { - fail("JDOHelper.isNew should return false for non-persistent instance"); - } - - // TBD test JDOHelper.isNew(pc) for persistent instance - } - - /** */ - public void testIsDeleted() { - PCPoint p = new PCPoint(1, Integer.valueOf(1)); - if (JDOHelper.isDeleted(p)) { - fail("JDOHelper.isDeleted should return false for non-persistent instance"); - } - - // TBD test JDOHelper.isDeleted(pc) for persistent instance - } - - /** Test null String resource with no class loader. */ - public void testGetPMFNullResource() { - try { - JDOHelper.getPersistenceManagerFactory((String) null); - fail("Null resource name should result in JDOFatalUserException"); - } catch (JDOFatalUserException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test null String resource with good class loader. */ - public void testGetPMFNullResourceGoodClassLoader() { - try { - JDOHelper.getPersistenceManagerFactory((String) null, this.getClass().getClassLoader()); - fail("Null resource name should result in JDOFatalUserException"); - } catch (JDOFatalUserException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test bad String resource with no class loader. */ - public void testGetPMFBadResource() { - try { - JDOHelper.getPersistenceManagerFactory("Whatever"); - fail("Null resource name should result in JDOFatalUserException"); - } catch (JDOFatalUserException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test null String resource with good class loader. */ - public void testGetPMFBadResourceGoodClassLoader() { - try { - JDOHelper.getPersistenceManagerFactory("Whatever", this.getClass().getClassLoader()); - fail("Null resource name should result in JDOFatalUserException"); - } catch (JDOFatalUserException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test null File resource with no class loader. */ - public void testGetPMFNullFile() { - try { - JDOHelper.getPersistenceManagerFactory((File) null); - fail("Null file should result in JDOFatalUserException"); - } catch (JDOFatalUserException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test null File resource with good class loader. */ - public void testGetPMFNullFileGoodClassLoader() { - try { - JDOHelper.getPersistenceManagerFactory((File) null, this.getClass().getClassLoader()); - fail("Null file should result in JDOFatalUserException"); - } catch (JDOFatalUserException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test bad File resource with no class loader. */ - public void testGetPMFBadFile() { - try { - JDOHelper.getPersistenceManagerFactory(new File("Whatever")); - fail("Null file should result in JDOFatalUserException"); - } catch (JDOFatalUserException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test bad File resource with good class loader. */ - public void testGetPMFBadFileGoodClassLoader() { - try { - JDOHelper.getPersistenceManagerFactory( - new File("Whatever"), this.getClass().getClassLoader()); - fail("Null file should result in JDOFatalUserException"); - } catch (JDOFatalUserException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test null JNDI resource name with no class loader. */ - public void testGetPMFNullJNDI() { - try { - JDOHelper.getPersistenceManagerFactory((String) null, getInitialContext()); - fail("Null JNDI resource name should result in JDOFatalUserException"); - } catch (JDOFatalUserException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test null JNDI resource name with good class loader. */ - public void testGetPMFNullJNDIGoodClassLoader() { - try { - JDOHelper.getPersistenceManagerFactory( - (String) null, getInitialContext(), this.getClass().getClassLoader()); - fail("Null JNDI resource name should result in JDOFatalUserException"); - } catch (JDOFatalUserException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test bad JNDI resource name with no class loader. */ - public void testGetPMFBadJNDI() { - try { - JDOHelper.getPersistenceManagerFactory("Whatever", getInitialContext()); - fail("Bad JNDI resource name should result in JDOFatalUserException"); - } catch (JDOFatalUserException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test bad JNDI resource name with good class loader. */ - public void testGetPMFBadJNDIGoodClassLoader() { - try { - JDOHelper.getPersistenceManagerFactory( - "Whatever", getInitialContext(), this.getClass().getClassLoader()); - fail("Bad JNDI resource name should result in JDOFatalUserException"); - } catch (JDOFatalUserException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test null stream with no class loader. */ - public void testGetPMFNullStream() { - try { - JDOHelper.getPersistenceManagerFactory((InputStream) null); - fail("Null JNDI resource name should result in JDOFatalUserException"); - } catch (JDOFatalUserException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test null stream with good class loader. */ - public void testGetPMFNullStreamGoodClassLoader() { - try { - JDOHelper.getPersistenceManagerFactory((InputStream) null, this.getClass().getClassLoader()); - fail("Null JNDI resource name should result in JDOFatalUserException"); - } catch (JDOFatalUserException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test null ClassLoader. */ - public void testGetPMFNullClassLoader() { - try { - JDOHelper.getPersistenceManagerFactory("Whatever", (ClassLoader) null); - fail("Null ClassLoader should result in JDOFatalUserException"); - } catch (JDOFatalUserException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test both null ClassLoaders. */ - public void testGetPMFBothNullClassLoader() { - try { - JDOHelper.getPersistenceManagerFactory("Whatever", (ClassLoader) null, (ClassLoader) null); - fail("Null ClassLoader should result in JDOFatalUserException"); - } catch (JDOFatalUserException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test missing property javax.jdo.PersistenceManagerFactoryClass. */ - public void testGetPMFNoClassNameProperty() { - try { - JDOHelper.getPersistenceManagerFactory(new Properties()); - fail( - "Missing property PersistenceManagerFactoryClass should result in JDOFatalUserException "); - } catch (JDOFatalUserException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test bad PMF class does not exist. */ - public void testBadPMFClassNotFound() { - Properties props = new Properties(); - props.put("javax.jdo.PersistenceManagerFactoryClass", "ThisClassDoesNotExist"); - try { - JDOHelper.getPersistenceManagerFactory(props); - fail("Bad PersistenceManagerFactoryClass should result in JDOFatalUserException "); - } catch (JDOFatalUserException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test bad PMF class no method getPersistenceManagerFactory(Properties). */ - public void testBadPMFNoGetPMFPropertiesMethod() { - Properties props = new Properties(); - props.put( - "javax.jdo.PersistenceManagerFactoryClass", "javax.jdo.JDOHelperTest$BadPMFNoGetPMFMethod"); - try { - JDOHelper.getPersistenceManagerFactory(props); - fail("Bad PersistenceManagerFactory should result in JDOFatalInternalException "); - } catch (JDOFatalInternalException ex) { - if (ex.getCause() instanceof NoSuchMethodException) { - if (verbose) println("Caught expected exception " + ex); - } else { - fail( - "Bad PersistenceManagerFactory should result in " - + "JDOFatalInternalException with nested " - + "NoSuchMethodException. " - + "Actual nested exception was " - + ex); - } - } - } - - /** Test bad PMF class no method getPersistenceManagerFactory(Map). */ - public void testBadPMFNoGetPMFMapMethod() { - Map props = new HashMap(); - props.put( - "javax.jdo.PersistenceManagerFactoryClass", "javax.jdo.JDOHelperTest$BadPMFNoGetPMFMethod"); - try { - JDOHelper.getPersistenceManagerFactory(props); - fail("Bad PersistenceManagerFactory should result in JDOFatalInternalException "); - } catch (JDOFatalInternalException ex) { - if (ex.getCause() instanceof NoSuchMethodException) { - if (verbose) println("Caught expected exception " + ex); - } else { - fail( - "Bad PersistenceManagerFactory should result in " - + "JDOFatalInternalException with nested " - + "NoSuchMethodException. " - + "Actual nested exception was " - + ex); - } - } - } - - /** Test bad PMF class non-static getPMF method. */ - public void testBadPMFNonStaticGetPMFMethod() { - Properties props = new Properties(); - props.put( - "javax.jdo.PersistenceManagerFactoryClass", - "javax.jdo.JDOHelperTest$BadPMFNonStaticGetPMFMethod"); - try { - JDOHelper.getPersistenceManagerFactory(props); - fail("Bad PersistenceManagerFactoryClass should result in JDOFatalInternalException "); - } catch (JDOFatalInternalException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test bad PMF class doesn't implement PMF. */ - public void testBadPMFWrongReturnType() { - Properties props = new Properties(); - props.put( - "javax.jdo.PersistenceManagerFactoryClass", - "javax.jdo.JDOHelperTest$BadPMFWrongReturnType"); - try { - JDOHelper.getPersistenceManagerFactory(props); - fail("Bad PersistenceManagerFactoryClass should result in JDOFatalInternalException "); - } catch (JDOFatalInternalException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test bad PMF class getPersistenceManagerFactory throws Exception. */ - public void testBadPMFGetPMFMethodThrowsJDOException() { - Properties props = new Properties(); - props.put( - "javax.jdo.PersistenceManagerFactoryClass", - "javax.jdo.JDOHelperTest$BadPMFGetPMFMethodThrowsJDOException"); - try { - JDOHelper.getPersistenceManagerFactory(props); - fail( - "BadPMFGetPMFMethodThrowsJDOException.GetPersistenceManagerFactory " - + "should result in JDOUnsupportedOptionException. " - + "No exception was thrown."); - } catch (JDOUnsupportedOptionException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test bad PMF class getPersistenceManagerFactory returns null. */ - public void testBadPMFGetPMFMethodReturnsNull() { - Properties props = new Properties(); - props.put( - "javax.jdo.PersistenceManagerFactoryClass", - "javax.jdo.JDOHelperTest$BadPMFGetPMFMethodReturnsNull"); - try { - JDOHelper.getPersistenceManagerFactory(props); - fail( - "BadPMFGetPMFMethodReturnsNull.GetPersistenceManagerFactory " - + "should result in JDOFatalInternalException. " - + "No exception was thrown."); - } catch (JDOFatalInternalException ex) { - if (verbose) println("Caught expected exception " + ex); - } - } - - /** Test that an unknown standard property cause JDOUserException. */ - public void testUnknownStandardProperty() { - Properties p = new Properties(); - p.setProperty("javax.jdo.unknown.standard.property", "value"); - try { - JDOHelper.getPersistenceManagerFactory(p); - fail( - "testUnknownStandardProperties should result in JDOUserException. " - + "No exception was thrown."); - } catch (JDOUserException x) { - if (verbose) println("Caught expected exception " + x); - } - } - - /** Test that unknown standard properties cause JDOUserException w/nested exceptions. */ - public void testUnknownStandardProperties() { - Properties p = new Properties(); - p.setProperty("javax.jdo.unknown.standard.property.1", "value"); - p.setProperty("javax.jdo.unknown.standard.property.2", "value"); - - JDOUserException x = null; - - try { - JDOHelper.getPersistenceManagerFactory(p); - fail( - "testUnknownStandardProperties should result in JDOUserException. " - + "No exception was thrown."); - } catch (JDOUserException thrown) { - if (verbose) println("Caught expected exception " + thrown); - x = thrown; - } - - Throwable[] nesteds = x.getNestedExceptions(); - - assertNotNull(nesteds); - assertEquals("should have been 2 nested exceptions", 2, nesteds.length); - for (int i = 0; i < nesteds.length; i++) { - Throwable t = nesteds[i]; - assertTrue( - "nested exception " + i + " should have been JDOUserException", - t instanceof JDOUserException); - } - } - - private Context getInitialContext() { - try { - return new InitialContext(); - } catch (NamingException ne) { - fail("Could not get Initial Context"); - return null; - } - } - - public static class BadPMFNoGetPMFMethod {} - - public static class BadPMFNonStaticGetPMFMethod { - public PersistenceManagerFactory getPersistenceManagerFactory(Map props) { - return null; - } - } - - public static class BadPMFWrongReturnType { - public static BadPMFWrongReturnType getPersistenceManagerFactory(Map props) { - return new BadPMFWrongReturnType(); - } - } - - public static class BadPMFGetPMFMethodThrowsJDOException { - public static PersistenceManagerFactory getPersistenceManagerFactory(Map props) { - throw new JDOUnsupportedOptionException("GetPMF method throws JDOUnsupportedOptionException"); - } - } - - public static class BadPMFGetPMFMethodThrowsJDOFatalInternalException { - public static PersistenceManagerFactory getPersistenceManagerFactory(Map props) { - throw new JDOFatalInternalException("GetPMF method throws JDOFatalInternalException"); - } - } - - public static class BadPMFGetPMFMethodReturnsNull { - public static PersistenceManagerFactory getPersistenceManagerFactory(Map props) { - return null; - } - } + + /** */ + public static void main(String args[]) { + BatchTestRunner.run(JDOHelperTest.class); + } + + /** The purpose of this test is simply to call some of the + * methods on a constructed instance of JDOHelper and verify that + * they do not throw exceptions. It is not a functional test. + * @since 2.1 + */ + public void testConstructor() { + assertNull("getObjectId(null) returned non-null", + JDOHelper.getObjectId(null)); + assertNull("getPersistenceManager(null) returned non-null", + JDOHelper.getPersistenceManager(null)); + assertNull("getTransactionalObjectId(null) returned non-null", + JDOHelper.getTransactionalObjectId(null)); + assertNull("getVersion(null) returned non-null", + JDOHelper.getVersion(null)); + assertFalse("isDeleted(null) returned non-null", + JDOHelper.isDeleted(null)); + assertFalse("isDetached(null) returned non-null", + JDOHelper.isDetached(null)); + assertFalse("isDirty(null) returned non-null", + JDOHelper.isDirty(null)); + assertFalse("isNew(null) returned non-null", + JDOHelper.isNew(null)); + assertFalse("isPersistent(null) returned non-null", + JDOHelper.isPersistent(null)); + assertFalse("isTransactional(null) returned non-null", + JDOHelper.isTransactional(null)); + } + + /** The purpose of this test is simply to call some of the + * methods on the static instance of JDOHelper and verify that + * they do not throw exceptions. It is not a functional test. + * @since 2.1 + */ + public void testGetInstance() { + assertNull("getObjectId(null) returned non-null", + JDOHelper.getObjectId(null)); + assertNull("getPersistenceManager(null) returned non-null", + JDOHelper.getPersistenceManager(null)); + assertNull("getTransactionalObjectId(null) returned non-null", + JDOHelper.getTransactionalObjectId(null)); + assertNull("getVersion(null) returned non-null", + JDOHelper.getVersion(null)); + assertFalse("isDeleted(null) returned non-null", + JDOHelper.isDeleted(null)); + assertFalse("isDetached(null) returned non-null", + JDOHelper.isDetached(null)); + assertFalse("isDirty(null) returned non-null", + JDOHelper.isDirty(null)); + assertFalse("isNew(null) returned non-null", + JDOHelper.isNew(null)); + assertFalse("isPersistent(null) returned non-null", + JDOHelper.isPersistent(null)); + assertFalse("isTransactional(null) returned non-null", + JDOHelper.isTransactional(null)); + } + + /** */ + public void testGetPM() { + PCPoint p = new PCPoint(1, Integer.valueOf(1)); + if (JDOHelper.getPersistenceManager(p) != null) { + fail("JDOHelper.getPersistenceManager should return null pm for non-persistent instance"); + } + + // TBD: test for persistent instance + } + + /** */ + public void testMakeDirty() { + // TBD: test JDOHelper.makeDirty(pc, fieldName); + } + + /** */ + public void testGetObjectId() { + PCPoint p = new PCPoint(1, Integer.valueOf(1)); + if (JDOHelper.getObjectId(p) != null) { + fail("JDOHelper.getObjectId should return null ObjectId for non-persistent instance"); + } + + // TBD test JDOHelper.getObjectId(pc) for persistent instance + } + + /** */ + public void testGetTransactionObjectId() { + PCPoint p = new PCPoint(1, Integer.valueOf(1)); + if (JDOHelper.getObjectId(p) != null) { + fail("JDOHelper.getTransactionalObjectId should return null ObjectId for non-persistent instance"); + } + + // TBD test JDOHelper.getTransactionalObjectId(pc) for persistent instance + } + + /** */ + public void testIsDirty() { + PCPoint p = new PCPoint(1, Integer.valueOf(1)); + if (JDOHelper.isDirty(p)) { + fail("JDOHelper.isDirty should return false for non-persistent instance"); + } + + // TBD test JDOHelper.isDirty(pc) for persistent instance + } + + /** */ + public void testIsTransactional() { + PCPoint p = new PCPoint(1, Integer.valueOf(1)); + if (JDOHelper.isTransactional(p)) { + fail("JDOHelper.isTransactional should return false for non-persistent instance"); + } + + // TBD test JDOHelper.isTransactional(pc) for persistent instance + } + + /** */ + public void testIsPersistent() { + PCPoint p = new PCPoint(1, Integer.valueOf(1)); + if (JDOHelper.isPersistent(p)) { + fail("JDOHelper.isPersistent should return false for non-persistent instance"); + } + + // TBD test JDOHelper.isPersistent(pc) for persistent instance + } + + /** */ + public void testIsNew() { + PCPoint p = new PCPoint(1, Integer.valueOf(1)); + if (JDOHelper.isNew(p)) { + fail("JDOHelper.isNew should return false for non-persistent instance"); + } + + // TBD test JDOHelper.isNew(pc) for persistent instance + } + + + /** */ + public void testIsDeleted() { + PCPoint p = new PCPoint(1, Integer.valueOf(1)); + if (JDOHelper.isDeleted(p)) { + fail("JDOHelper.isDeleted should return false for non-persistent instance"); + } + + // TBD test JDOHelper.isDeleted(pc) for persistent instance + } + + /** Test null String resource with no class loader. + */ + public void testGetPMFNullResource() { + try { + JDOHelper.getPersistenceManagerFactory((String)null); + fail("Null resource name should result in JDOFatalUserException"); + } + catch (JDOFatalUserException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test null String resource with good class loader. + */ + public void testGetPMFNullResourceGoodClassLoader() { + try { + JDOHelper.getPersistenceManagerFactory((String)null, this.getClass().getClassLoader()); + fail("Null resource name should result in JDOFatalUserException"); + } + catch (JDOFatalUserException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test bad String resource with no class loader. + */ + public void testGetPMFBadResource() { + try { + JDOHelper.getPersistenceManagerFactory("Whatever"); + fail("Null resource name should result in JDOFatalUserException"); + } + catch (JDOFatalUserException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test null String resource with good class loader. + */ + public void testGetPMFBadResourceGoodClassLoader() { + try { + JDOHelper.getPersistenceManagerFactory("Whatever", this.getClass().getClassLoader()); + fail("Null resource name should result in JDOFatalUserException"); + } + catch (JDOFatalUserException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test null File resource with no class loader. + */ + public void testGetPMFNullFile() { + try { + JDOHelper.getPersistenceManagerFactory((File)null); + fail("Null file should result in JDOFatalUserException"); + } + catch (JDOFatalUserException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test null File resource with good class loader. + */ + public void testGetPMFNullFileGoodClassLoader() { + try { + JDOHelper.getPersistenceManagerFactory((File)null, this.getClass().getClassLoader()); + fail("Null file should result in JDOFatalUserException"); + } + catch (JDOFatalUserException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test bad File resource with no class loader. + */ + public void testGetPMFBadFile() { + try { + JDOHelper.getPersistenceManagerFactory(new File("Whatever")); + fail("Null file should result in JDOFatalUserException"); + } + catch (JDOFatalUserException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test bad File resource with good class loader. + */ + public void testGetPMFBadFileGoodClassLoader() { + try { + JDOHelper.getPersistenceManagerFactory(new File("Whatever"), this.getClass().getClassLoader()); + fail("Null file should result in JDOFatalUserException"); + } + catch (JDOFatalUserException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test null JNDI resource name with no class loader. + */ + public void testGetPMFNullJNDI() { + try { + JDOHelper.getPersistenceManagerFactory((String)null, getInitialContext()); + fail("Null JNDI resource name should result in JDOFatalUserException"); + } + catch (JDOFatalUserException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test null JNDI resource name with good class loader. + */ + public void testGetPMFNullJNDIGoodClassLoader() { + try { + JDOHelper.getPersistenceManagerFactory((String)null, getInitialContext(), this.getClass().getClassLoader()); + fail("Null JNDI resource name should result in JDOFatalUserException"); + } + catch (JDOFatalUserException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test bad JNDI resource name with no class loader. + */ + public void testGetPMFBadJNDI() { + try { + JDOHelper.getPersistenceManagerFactory("Whatever", getInitialContext()); + fail("Bad JNDI resource name should result in JDOFatalUserException"); + } + catch (JDOFatalUserException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test bad JNDI resource name with good class loader. + */ + public void testGetPMFBadJNDIGoodClassLoader() { + try { + JDOHelper.getPersistenceManagerFactory("Whatever", getInitialContext(), this.getClass().getClassLoader()); + fail("Bad JNDI resource name should result in JDOFatalUserException"); + } + catch (JDOFatalUserException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test null stream with no class loader. + */ + public void testGetPMFNullStream() { + try { + JDOHelper.getPersistenceManagerFactory((InputStream)null); + fail("Null JNDI resource name should result in JDOFatalUserException"); + } + catch (JDOFatalUserException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test null stream with good class loader. + */ + public void testGetPMFNullStreamGoodClassLoader() { + try { + JDOHelper.getPersistenceManagerFactory((InputStream)null, this.getClass().getClassLoader()); + fail("Null JNDI resource name should result in JDOFatalUserException"); + } + catch (JDOFatalUserException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test null ClassLoader. + */ + public void testGetPMFNullClassLoader() { + try { + JDOHelper.getPersistenceManagerFactory("Whatever", (ClassLoader)null); + fail("Null ClassLoader should result in JDOFatalUserException"); + } + catch (JDOFatalUserException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test both null ClassLoaders. + */ + public void testGetPMFBothNullClassLoader() { + try { + JDOHelper.getPersistenceManagerFactory("Whatever", (ClassLoader)null, (ClassLoader)null); + fail("Null ClassLoader should result in JDOFatalUserException"); + } + catch (JDOFatalUserException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test missing property javax.jdo.PersistenceManagerFactoryClass. + */ + public void testGetPMFNoClassNameProperty() { + try { + JDOHelper.getPersistenceManagerFactory(new Properties()); + fail("Missing property PersistenceManagerFactoryClass should result in JDOFatalUserException "); + } + catch (JDOFatalUserException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test bad PMF class does not exist. + */ + public void testBadPMFClassNotFound() { + Properties props = new Properties(); + props.put("javax.jdo.PersistenceManagerFactoryClass", "ThisClassDoesNotExist"); + try { + JDOHelper.getPersistenceManagerFactory(props); + fail("Bad PersistenceManagerFactoryClass should result in JDOFatalUserException "); + } + catch (JDOFatalUserException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test bad PMF class no method getPersistenceManagerFactory(Properties). + */ + public void testBadPMFNoGetPMFPropertiesMethod() { + Properties props = new Properties(); + props.put("javax.jdo.PersistenceManagerFactoryClass", + "javax.jdo.JDOHelperTest$BadPMFNoGetPMFMethod"); + try { + JDOHelper.getPersistenceManagerFactory(props); + fail("Bad PersistenceManagerFactory should result in JDOFatalInternalException "); + } + catch (JDOFatalInternalException ex) { + if (ex.getCause() instanceof NoSuchMethodException) { + if (verbose) + println("Caught expected exception " + ex); + } else { + fail("Bad PersistenceManagerFactory should result in " + + "JDOFatalInternalException with nested " + + "NoSuchMethodException. " + + "Actual nested exception was " + ex); + } + } + } + + /** Test bad PMF class no method getPersistenceManagerFactory(Map). + */ + public void testBadPMFNoGetPMFMapMethod() { + Map props = new HashMap(); + props.put("javax.jdo.PersistenceManagerFactoryClass", + "javax.jdo.JDOHelperTest$BadPMFNoGetPMFMethod"); + try { + JDOHelper.getPersistenceManagerFactory(props); + fail("Bad PersistenceManagerFactory should result in JDOFatalInternalException "); + } + catch (JDOFatalInternalException ex) { + if (ex.getCause() instanceof NoSuchMethodException) { + if (verbose) + println("Caught expected exception " + ex); + } else { + fail("Bad PersistenceManagerFactory should result in " + + "JDOFatalInternalException with nested " + + "NoSuchMethodException. " + + "Actual nested exception was " + ex); + } + } + } + + /** Test bad PMF class non-static getPMF method. + */ + public void testBadPMFNonStaticGetPMFMethod() { + Properties props = new Properties(); + props.put("javax.jdo.PersistenceManagerFactoryClass", + "javax.jdo.JDOHelperTest$BadPMFNonStaticGetPMFMethod"); + try { + JDOHelper.getPersistenceManagerFactory(props); + fail("Bad PersistenceManagerFactoryClass should result in JDOFatalInternalException "); + } + catch (JDOFatalInternalException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test bad PMF class doesn't implement PMF. + */ + public void testBadPMFWrongReturnType() { + Properties props = new Properties(); + props.put("javax.jdo.PersistenceManagerFactoryClass", + "javax.jdo.JDOHelperTest$BadPMFWrongReturnType"); + try { + JDOHelper.getPersistenceManagerFactory(props); + fail("Bad PersistenceManagerFactoryClass should result in JDOFatalInternalException "); + } + catch (JDOFatalInternalException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test bad PMF class getPersistenceManagerFactory throws Exception. + */ + public void testBadPMFGetPMFMethodThrowsJDOException() { + Properties props = new Properties(); + props.put("javax.jdo.PersistenceManagerFactoryClass", + "javax.jdo.JDOHelperTest$BadPMFGetPMFMethodThrowsJDOException"); + try { + JDOHelper.getPersistenceManagerFactory(props); + fail("BadPMFGetPMFMethodThrowsJDOException.GetPersistenceManagerFactory " + + "should result in JDOUnsupportedOptionException. " + + "No exception was thrown."); + } + catch (JDOUnsupportedOptionException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test bad PMF class getPersistenceManagerFactory returns null. + */ + public void testBadPMFGetPMFMethodReturnsNull() { + Properties props = new Properties(); + props.put("javax.jdo.PersistenceManagerFactoryClass", + "javax.jdo.JDOHelperTest$BadPMFGetPMFMethodReturnsNull"); + try { + JDOHelper.getPersistenceManagerFactory(props); + fail("BadPMFGetPMFMethodReturnsNull.GetPersistenceManagerFactory " + + "should result in JDOFatalInternalException. " + + "No exception was thrown."); + } + catch (JDOFatalInternalException ex) { + if (verbose) + println("Caught expected exception " + ex); + } + } + + /** Test that an unknown standard property cause JDOUserException. + */ + public void testUnknownStandardProperty() { + Properties p = new Properties(); + p.setProperty("javax.jdo.unknown.standard.property", "value"); + try { + JDOHelper.getPersistenceManagerFactory(p); + fail("testUnknownStandardProperties should result in JDOUserException. " + + "No exception was thrown."); + } catch (JDOUserException x) { + if (verbose) + println("Caught expected exception " + x); + } + } + + /** + * Test that unknown standard properties cause JDOUserException w/nested + * exceptions. + */ + public void testUnknownStandardProperties() { + Properties p = new Properties(); + p.setProperty("javax.jdo.unknown.standard.property.1", "value"); + p.setProperty("javax.jdo.unknown.standard.property.2", "value"); + + JDOUserException x = null; + + try { + JDOHelper.getPersistenceManagerFactory(p); + fail("testUnknownStandardProperties should result in JDOUserException. " + + "No exception was thrown."); + } catch (JDOUserException thrown) { + if (verbose) + println("Caught expected exception " + thrown); + x = thrown; + } + + Throwable[] nesteds = x.getNestedExceptions(); + + assertNotNull(nesteds); + assertEquals("should have been 2 nested exceptions", 2, nesteds.length); + for (int i = 0; i < nesteds.length; i++) { + Throwable t = nesteds[i]; + assertTrue("nested exception " + i + + " should have been JDOUserException", + t instanceof JDOUserException); + } + } + + private Context getInitialContext() { + try { + return new InitialContext(); + } catch (NamingException ne) { + fail("Could not get Initial Context"); + return null; + } + } + + public static class BadPMFNoGetPMFMethod { + } + + public static class BadPMFNonStaticGetPMFMethod { + public PersistenceManagerFactory + getPersistenceManagerFactory(Map props) { + return null; + } + } + + public static class BadPMFWrongReturnType { + public static BadPMFWrongReturnType + getPersistenceManagerFactory(Map props) { + return new BadPMFWrongReturnType(); + } + } + + public static class BadPMFGetPMFMethodThrowsJDOException { + public static PersistenceManagerFactory + getPersistenceManagerFactory(Map props) { + throw new JDOUnsupportedOptionException( + "GetPMF method throws JDOUnsupportedOptionException"); + } + } + + public static class BadPMFGetPMFMethodThrowsJDOFatalInternalException { + public static PersistenceManagerFactory + getPersistenceManagerFactory(Map props) { + throw new JDOFatalInternalException( + "GetPMF method throws JDOFatalInternalException"); + } + } + + public static class BadPMFGetPMFMethodReturnsNull { + public static PersistenceManagerFactory + getPersistenceManagerFactory(Map props) { + return null; + } + } } diff --git a/api/src/test/java/javax/jdo/MockEnhancer.java b/api/src/test/java/javax/jdo/MockEnhancer.java index 2877de860..a5208a402 100644 --- a/api/src/test/java/javax/jdo/MockEnhancer.java +++ b/api/src/test/java/javax/jdo/MockEnhancer.java @@ -5,20 +5,18 @@ * 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 + * + * 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 javax.jdo; -import static javax.jdo.Constants.PROPERTY_ENHANCER_VENDOR_NAME; -import static javax.jdo.Constants.PROPERTY_ENHANCER_VERSION_NUMBER; import java.lang.instrument.IllegalClassFormatException; import java.security.ProtectionDomain; @@ -26,117 +24,113 @@ import java.util.Arrays; import java.util.List; import java.util.Properties; + +import static javax.jdo.Constants.PROPERTY_ENHANCER_VENDOR_NAME; +import static javax.jdo.Constants.PROPERTY_ENHANCER_VERSION_NUMBER; + import javax.jdo.metadata.JDOMetadata; + /** * Tests class javax.jdo.Enhancer (main class). - * *

    */ public class MockEnhancer implements JDOEnhancer { - static Properties props = new Properties(); - - static { - props.put(PROPERTY_ENHANCER_VENDOR_NAME, "Mock Enhancer"); - props.put(PROPERTY_ENHANCER_VERSION_NUMBER, "2.3.0"); - props.put("MockKey", "MockValue"); - } - - @SuppressWarnings("unused") - private boolean verbose; - - private int numberOfElements; - private List classNames = new ArrayList(); - private List jarNames = new ArrayList(); - private List jdoNames = new ArrayList(); - private List puNames = new ArrayList(); - - @SuppressWarnings("unused") - private String outputDirectory = null; - - public MockEnhancer() {} - - public Properties getProperties() { - return props; - } - - public JDOEnhancer setVerbose(boolean flag) { - this.verbose = flag; - return this; - } - - public JDOEnhancer setOutputDirectory(String dirName) { - outputDirectory = dirName; - return this; - } - - public JDOEnhancer setClassLoader(ClassLoader loader) { - // check to see if JDOHelper is loadable from the loader - try { - loader.loadClass("javax.jdo.JDOHelper"); - } catch (ClassNotFoundException ex) { - // bad - throw new JDOFatalInternalException("Should be able to load JDOHelper from the class loader"); - } - return this; - } - - public JDOEnhancer addPersistenceUnit(String persistenceUnit) { - numberOfElements++; - this.puNames.add(persistenceUnit); - return this; - } - - public JDOEnhancer addClass(String className, byte[] bytes) { - throw new UnsupportedOperationException("Not supported yet."); - } - - public JDOEnhancer addClasses(String... classNames) { - numberOfElements += classNames.length; - this.classNames.addAll(Arrays.asList(classNames)); - return this; - } - - public JDOEnhancer addFiles(String... metadataFiles) { - numberOfElements += metadataFiles.length; - this.jdoNames.addAll(Arrays.asList(metadataFiles)); - return this; - } - - public JDOEnhancer addJar(String jarFileName) { - numberOfElements++; - this.jarNames.add(jarFileName); - return this; - } - - public int enhance() { - return numberOfElements; - } - - public int validate() { - return numberOfElements; - } - - public byte[] getEnhancedBytes(String className) { - throw new UnsupportedOperationException("Not supported yet."); - } - - public void registerMetadata(JDOMetadata metadata) { - throw new UnsupportedOperationException("Not supported yet."); - } - - public JDOMetadata newMetadata() { - throw new UnsupportedOperationException("Not supported yet."); - } - - public byte[] transform( - ClassLoader loader, - String className, - Class classBeingRedefined, - ProtectionDomain protectionDomain, - byte[] classfileBuffer) - throws IllegalClassFormatException { - throw new UnsupportedOperationException("Not supported yet."); - } + static Properties props = new Properties(); + static { + props.put(PROPERTY_ENHANCER_VENDOR_NAME, "Mock Enhancer"); + props.put(PROPERTY_ENHANCER_VERSION_NUMBER, "2.3.0"); + props.put("MockKey", "MockValue"); + } + @SuppressWarnings("unused") + private boolean verbose; + private int numberOfElements; + private List classNames = new ArrayList(); + private List jarNames = new ArrayList(); + private List jdoNames = new ArrayList(); + private List puNames = new ArrayList(); + @SuppressWarnings("unused") + private String outputDirectory = null; + + public MockEnhancer(){ + } + + public Properties getProperties() { + return props; + } + + public JDOEnhancer setVerbose(boolean flag) { + this.verbose = flag; + return this; + } + + public JDOEnhancer setOutputDirectory(String dirName) { + outputDirectory = dirName; + return this; + } + + public JDOEnhancer setClassLoader(ClassLoader loader) { + // check to see if JDOHelper is loadable from the loader + try { + loader.loadClass("javax.jdo.JDOHelper"); + } catch (ClassNotFoundException ex) { + // bad + throw new JDOFatalInternalException("Should be able to load JDOHelper from the class loader"); + } + return this; + } + + public JDOEnhancer addPersistenceUnit(String persistenceUnit) { + numberOfElements++; + this.puNames.add(persistenceUnit); + return this; + } + + public JDOEnhancer addClass(String className, byte[] bytes) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public JDOEnhancer addClasses(String... classNames) { + numberOfElements += classNames.length; + this.classNames.addAll(Arrays.asList(classNames)); + return this; + } + + public JDOEnhancer addFiles(String... metadataFiles) { + numberOfElements += metadataFiles.length; + this.jdoNames.addAll(Arrays.asList(metadataFiles)); + return this; + } + + public JDOEnhancer addJar(String jarFileName) { + numberOfElements++; + this.jarNames.add(jarFileName); + return this; + } + + public int enhance() { + return numberOfElements; + } + + public int validate() { + return numberOfElements; + } + + public byte[] getEnhancedBytes(String className) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void registerMetadata(JDOMetadata metadata) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public JDOMetadata newMetadata() { + throw new UnsupportedOperationException("Not supported yet."); + } + + public byte[] transform(ClassLoader loader, String className, Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { + throw new UnsupportedOperationException("Not supported yet."); + } } + diff --git a/api/src/test/java/javax/jdo/ObjectStateTest.java b/api/src/test/java/javax/jdo/ObjectStateTest.java index 8e9b306ab..35cdc3859 100644 --- a/api/src/test/java/javax/jdo/ObjectStateTest.java +++ b/api/src/test/java/javax/jdo/ObjectStateTest.java @@ -20,7 +20,9 @@ import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; + import javax.jdo.spi.PersistenceCapable; + import javax.jdo.util.AbstractTest; import javax.jdo.util.BatchTestRunner; @@ -33,184 +35,204 @@ */ public class ObjectStateTest extends AbstractTest { - static final int PERSISTENT = 1; - static final int TRANSACTIONAL = 2; - static final int DIRTY = 4; - static final int NEW = 8; - static final int DELETED = 16; - static final int DETACHED = 32; - - private static final Method jdoIsPersistent = - getDeclaredMethod(PersistenceCapable.class, "jdoIsPersistent", null); - private static final Method jdoIsTransactional = - getDeclaredMethod(PersistenceCapable.class, "jdoIsTransactional", null); - private static final Method jdoIsDirty = - getDeclaredMethod(PersistenceCapable.class, "jdoIsDirty", null); - private static final Method jdoIsNew = - getDeclaredMethod(PersistenceCapable.class, "jdoIsNew", null); - private static final Method jdoIsDeleted = - getDeclaredMethod(PersistenceCapable.class, "jdoIsDeleted", null); - private static final Method jdoIsDetached = - getDeclaredMethod(PersistenceCapable.class, "jdoIsDetached", null); - - /** */ - public static void main(String args[]) { - BatchTestRunner.run(ObjectStateTest.class); - } - - public void testNull() { - PersistenceCapable mock = null; - assertObjectState("null", null, mock); - } - - public void testTransient() { - PersistenceCapable mock = newMock(0); - assertObjectState("transient", ObjectState.TRANSIENT, mock); - } - - public void testTransientClean() { - PersistenceCapable mock = newMock(TRANSACTIONAL); - assertObjectState("transient-clean", ObjectState.TRANSIENT_CLEAN, mock); - } - - public void testTransientDirty() { - PersistenceCapable mock = newMock(TRANSACTIONAL + DIRTY); - assertObjectState("transient-dirty", ObjectState.TRANSIENT_DIRTY, mock); - } - - public void testPersistentNew() { - PersistenceCapable mock = newMock(PERSISTENT + TRANSACTIONAL + NEW + DIRTY); - assertObjectState("persistent-new", ObjectState.PERSISTENT_NEW, mock); - } - - public void testPersistentNontransactional() { - PersistenceCapable mock = newMock(PERSISTENT); - assertObjectState( - "persistent-nontransactional", ObjectState.HOLLOW_PERSISTENT_NONTRANSACTIONAL, mock); - } - - public void testPersistentNontransactionalDirty() { - PersistenceCapable mock = newMock(PERSISTENT + DIRTY); - assertObjectState( - "persistent-nontransactional-dirty", ObjectState.PERSISTENT_NONTRANSACTIONAL_DIRTY, mock); - } - - public void testPersistentClean() { - PersistenceCapable mock = newMock(PERSISTENT + TRANSACTIONAL); - assertObjectState("persistent-clean", ObjectState.PERSISTENT_CLEAN, mock); - } - - public void testPersistentDirty() { - PersistenceCapable mock = newMock(PERSISTENT + TRANSACTIONAL + DIRTY); - assertObjectState("persistent-dirty", ObjectState.PERSISTENT_DIRTY, mock); - } - - public void testPersistentDeleted() { - PersistenceCapable mock = newMock(PERSISTENT + TRANSACTIONAL + DIRTY + DELETED); - assertObjectState("persistent-deleted", ObjectState.PERSISTENT_DELETED, mock); - } - - public void testPersistentNewDeleted() { - PersistenceCapable mock = newMock(PERSISTENT + TRANSACTIONAL + NEW + DIRTY + DELETED); - assertObjectState("persistent-new-deleted", ObjectState.PERSISTENT_NEW_DELETED, mock); - } - - public void testDetachedClean() { - PersistenceCapable mock = newMock(DETACHED); - assertObjectState("detached-clean", ObjectState.DETACHED_CLEAN, mock); - } - - public void testDetachedDirty() { - PersistenceCapable mock = newMock(DETACHED + DIRTY); - assertObjectState("detached-dirty", ObjectState.DETACHED_DIRTY, mock); - } - - private void assertObjectState(String string, ObjectState expected, PersistenceCapable pc) { - ObjectState actual = JDOHelper.getObjectState(pc); - // test for == here because enums should be singleton - if (actual == expected) return; - fail( - "ObjectState failure for " + string + NL + "expected: " + expected + ", actual: " + actual); - } - - /** - * Construct a new mock instance of PersistenceCapable that responds to methods jdoIsXXX by - * returning the bit value of its constructor masked with the value of XXX. - * - * @param i the sum of bit masks representing the life cycle state - * @return a mock instance of PersistenceCapable - */ - private PersistenceCapable newMock(final int i) { - return (PersistenceCapable) - Proxy.newProxyInstance( - PersistenceCapable.class.getClassLoader(), - new Class[] {PersistenceCapable.class}, - new MockInvocationHandler(i)); - } - - private class MockInvocationHandler implements InvocationHandler { - /** States is the sum of all life cycle interrogatives. */ - private int states; + static final int PERSISTENT = 1; + static final int TRANSACTIONAL = 2; + static final int DIRTY = 4; + static final int NEW = 8; + static final int DELETED = 16; + static final int DETACHED = 32; + + private static final Method jdoIsPersistent = getDeclaredMethod( + PersistenceCapable.class, + "jdoIsPersistent", + null); + private static final Method jdoIsTransactional = getDeclaredMethod( + PersistenceCapable.class, + "jdoIsTransactional", + null); + private static final Method jdoIsDirty = getDeclaredMethod( + PersistenceCapable.class, + "jdoIsDirty", + null); + private static final Method jdoIsNew = getDeclaredMethod( + PersistenceCapable.class, + "jdoIsNew", + null); + private static final Method jdoIsDeleted = getDeclaredMethod( + PersistenceCapable.class, + "jdoIsDeleted", + null); + private static final Method jdoIsDetached = getDeclaredMethod( + PersistenceCapable.class, + "jdoIsDetached", + null); + + /** */ + public static void main(String args[]) { + BatchTestRunner.run(ObjectStateTest.class); + } - /** - * Constructs an invocation handler with the specified bit fields set according to the sum of - * values of PERSISTENT, TRANSACTIONAL, DIRTY, NEW, DELETED, and DETACHED. - * - * @param i the bit field values for the life cycle interrogatives - */ - private MockInvocationHandler(int i) { - states = i; + public void testNull() { + PersistenceCapable mock = null; + assertObjectState("null", null, mock); + } + + public void testTransient() { + PersistenceCapable mock = newMock(0); + assertObjectState("transient", ObjectState.TRANSIENT, mock); + } + + public void testTransientClean() { + PersistenceCapable mock = newMock(TRANSACTIONAL); + assertObjectState("transient-clean", ObjectState.TRANSIENT_CLEAN, mock); + } + + public void testTransientDirty() { + PersistenceCapable mock = newMock(TRANSACTIONAL+DIRTY); + assertObjectState("transient-dirty", ObjectState.TRANSIENT_DIRTY, mock); + } + + public void testPersistentNew() { + PersistenceCapable mock = newMock(PERSISTENT+TRANSACTIONAL+NEW+DIRTY); + assertObjectState("persistent-new", ObjectState.PERSISTENT_NEW, mock); + } + + public void testPersistentNontransactional() { + PersistenceCapable mock = newMock(PERSISTENT); + assertObjectState("persistent-nontransactional", ObjectState.HOLLOW_PERSISTENT_NONTRANSACTIONAL, mock); + } + + public void testPersistentNontransactionalDirty() { + PersistenceCapable mock = newMock(PERSISTENT+DIRTY); + assertObjectState("persistent-nontransactional-dirty", ObjectState.PERSISTENT_NONTRANSACTIONAL_DIRTY, mock); + } + + public void testPersistentClean() { + PersistenceCapable mock = newMock(PERSISTENT+TRANSACTIONAL); + assertObjectState("persistent-clean", ObjectState.PERSISTENT_CLEAN, mock); + } + + public void testPersistentDirty() { + PersistenceCapable mock = newMock(PERSISTENT+TRANSACTIONAL+DIRTY); + assertObjectState("persistent-dirty", ObjectState.PERSISTENT_DIRTY, mock); + } + + public void testPersistentDeleted() { + PersistenceCapable mock = newMock(PERSISTENT+TRANSACTIONAL+DIRTY+DELETED); + assertObjectState("persistent-deleted", ObjectState.PERSISTENT_DELETED, mock); + } + + public void testPersistentNewDeleted() { + PersistenceCapable mock = newMock(PERSISTENT+TRANSACTIONAL+NEW+DIRTY+DELETED); + assertObjectState("persistent-new-deleted", ObjectState.PERSISTENT_NEW_DELETED, mock); + } + + public void testDetachedClean() { + PersistenceCapable mock = newMock(DETACHED); + assertObjectState("detached-clean", ObjectState.DETACHED_CLEAN, mock); + } + + public void testDetachedDirty() { + PersistenceCapable mock = newMock(DETACHED+DIRTY); + assertObjectState("detached-dirty", ObjectState.DETACHED_DIRTY, mock); + } + + private void assertObjectState(String string, + ObjectState expected, + PersistenceCapable pc) { + ObjectState actual = JDOHelper.getObjectState(pc); + // test for == here because enums should be singleton + if (actual == expected) + return; + fail("ObjectState failure for " + string + NL + + "expected: " + expected + + ", actual: " + actual); } /** - * @param object the PersistenceCapable instance - * @param method the method being invoked - * @param parameters parameters (should be null) - * @throws java.lang.Throwable unused - * @return for jdoIsXXX methods only, returns whether the bit field selected by the method is - * set in the mock handler + * Construct a new mock instance of PersistenceCapable that responds + * to methods jdoIsXXX by returning the bit value of its constructor + * masked with the value of XXX. + * @param i the sum of bit masks representing the life cycle state + * @return a mock instance of PersistenceCapable */ - public Object invoke(Object object, Method method, Object[] parameters) throws Throwable { - if (method.equals(jdoIsPersistent)) { - return (0 != (states & PERSISTENT)); - } - if (method.equals(jdoIsTransactional)) { - return (0 != (states & TRANSACTIONAL)); - } - if (method.equals(jdoIsDirty)) { - return (0 != (states & DIRTY)); - } - if (method.equals(jdoIsNew)) { - return (0 != (states & NEW)); - } - if (method.equals(jdoIsDeleted)) { - return (0 != (states & DELETED)); - } - if (method.equals(jdoIsDetached)) { - return (0 != (states & DETACHED)); - } - fail("Unexpected method called: " + method.getName()); - return Boolean.FALSE; // not reached - } - } - - private static Method getDeclaredMethod(Class clazz, String methodName, Class[] parameters) { - try { - @SuppressWarnings("unchecked") - Method result = clazz.getDeclaredMethod(methodName, parameters); - return result; - } catch (Exception ex) { - // human-readable class.methodName(parameter[,parameter]) - StringBuffer sb = new StringBuffer(methodName); - String delimiter = "("; - for (Class parameter : parameters) { - sb.append(delimiter); - sb.append(parameter.getName()); - delimiter = ","; - } - sb.append(")"); - throw new RuntimeException( - "getDeclaredMethod for " + clazz.getName() + "." + sb + " threw..." + ex); - } - } + private PersistenceCapable newMock(final int i) { + return (PersistenceCapable) + Proxy.newProxyInstance( + PersistenceCapable.class.getClassLoader(), + new Class[] {PersistenceCapable.class}, + new MockInvocationHandler(i)); + } + + private class MockInvocationHandler implements InvocationHandler { + /** States is the sum of all life cycle interrogatives. + */ + private int states; + + /** + * Constructs an invocation handler with the specified bit fields set + * according to the sum of values of PERSISTENT, TRANSACTIONAL, DIRTY, + * NEW, DELETED, and DETACHED. + * @param i the bit field values for the life cycle interrogatives + */ + private MockInvocationHandler(int i) { + states = i; + } + + /** + * + * @param object the PersistenceCapable instance + * @param method the method being invoked + * @param parameters parameters (should be null) + * @throws java.lang.Throwable unused + * @return for jdoIsXXX methods only, returns whether the + * bit field selected by the method is set in the + * mock handler + */ + public Object invoke(Object object, Method method, Object[] parameters) + throws Throwable { + if (method.equals(jdoIsPersistent)) { + return (0 != (states & PERSISTENT)); + } + if (method.equals(jdoIsTransactional)) { + return (0 != (states & TRANSACTIONAL)); + } + if (method.equals(jdoIsDirty)) { + return (0 != (states & DIRTY)); + } + if (method.equals(jdoIsNew)) { + return (0 != (states & NEW)); + } + if (method.equals(jdoIsDeleted)) { + return (0 != (states & DELETED)); + } + if (method.equals(jdoIsDetached)) { + return (0 != (states & DETACHED)); + } + fail("Unexpected method called: " + method.getName()); + return Boolean.FALSE; // not reached + } + } + + private static Method getDeclaredMethod + (Class clazz, String methodName, Class[] parameters) { + try { + @SuppressWarnings("unchecked") + Method result = clazz.getDeclaredMethod(methodName, parameters); + return result; + } catch (Exception ex) { + // human-readable class.methodName(parameter[,parameter]) + StringBuffer sb = new StringBuffer(methodName); + String delimiter = "("; + for (Class parameter: parameters) { + sb.append(delimiter); + sb.append(parameter.getName()); + delimiter = ","; + } + sb.append(")"); + throw new RuntimeException + ("getDeclaredMethod for " + clazz.getName() + "." + + sb + " threw..." + ex); + } + } } diff --git a/api/src/test/java/javax/jdo/PMFMapMapTest.java b/api/src/test/java/javax/jdo/PMFMapMapTest.java index e6fd96745..1c4dcd21b 100644 --- a/api/src/test/java/javax/jdo/PMFMapMapTest.java +++ b/api/src/test/java/javax/jdo/PMFMapMapTest.java @@ -19,385 +19,386 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; + import java.io.IOException; import java.io.InputStream; import java.util.Properties; -import javax.jdo.util.BatchTestRunner; import junit.framework.TestSuite; +import javax.jdo.util.BatchTestRunner; + /** * Tests class javax.jdo.JDOHelper for calls to the impl's static method * getPersistenceManagerFactory(Map overrides, Map props). */ public class PMFMapMapTest extends AbstractJDOConfigTest { - private static final String EXPECTED_FACTORY2_NAME = "Jane Doe"; - private static final String EXPECTED_FACTORY2_NAME_4_NAMED_PMF = "Larry"; - private static final String EXPECTED_FACTORY2_NAME_WITH_OVERRIDE = "Gerard Manley Hopkins"; - private static final String PMF_NAME = "BookSearch"; - private static final String RESOURCE_DIR = "/Pmfmapmap01/"; - private static final String PROPS_DIR = "/Pmfmapmap02/"; - private static final String PMF_SERVICE_CLASS = "javax.jdo.stub.StubPMF"; - private static final String PROPERTIES_FILE = "propsfile.props"; - - public static void main(String args[]) { - BatchTestRunner.run(PMFMapMapTest.class); - } - - /** - * {@inheritDoc} - * - * @return {@inheritDoc} - */ - public static TestSuite suite() { - return new TestSuite(PMFMapMapTest.class); - } - - /* - * static PersistenceManagerFactory getPersistenceManagerFactory() Get the - * anonymous PersistenceManagerFactory configured via the standard - * configuration file resource "META-INF/jdoconfig.xml", using the current - * thread's context class loader to locate the configuration file - * resource(s). - */ - public void testJDOConfigXML() throws IOException { - - ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); - ClassLoader saveContextClassLoader = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(resourceClassLoader); - - try { - PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(); - checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); - } finally { - Thread.currentThread().setContextClassLoader(saveContextClassLoader); + private static final String EXPECTED_FACTORY2_NAME = "Jane Doe"; + private static final String EXPECTED_FACTORY2_NAME_4_NAMED_PMF = "Larry"; + private static final String EXPECTED_FACTORY2_NAME_WITH_OVERRIDE = "Gerard Manley Hopkins"; + private static final String PMF_NAME = "BookSearch"; + private static final String RESOURCE_DIR = "/Pmfmapmap01/"; + private static final String PROPS_DIR = "/Pmfmapmap02/"; + private static final String PMF_SERVICE_CLASS = "javax.jdo.stub.StubPMF"; + private static final String PROPERTIES_FILE = "propsfile.props"; + + public static void main(String args[]) { + BatchTestRunner.run(PMFMapMapTest.class); } - } - - /* - * static PersistenceManagerFactory getPersistenceManagerFactory - * (java.lang.ClassLoader pmfClassLoader) Get the anonymous - * PersistenceManagerFactory configured via the standard configuration file - * resource "META-INF/jdoconfig.xml", using the given class loader. - */ - public void testJDOConfigXMLWithLoader() throws IOException { - - ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); - - try { - PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(resourceClassLoader); - checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); + + /** + * {@inheritDoc} + * + * @return {@inheritDoc} + */ + public static TestSuite suite() { + return new TestSuite(PMFMapMapTest.class); } - } - - /* - * static PersistenceManagerFactory getPersistenceManagerFactory( - * java.io.File propsFile) Returns a PersistenceManagerFactory configured - * based on the properties stored in the file at propsFile. - */ - public void testPropsFile() throws IOException { - - ClassLoader resourceClassLoader = createResourceClassLoader(PROPS_DIR); - ClassLoader saveContextClassLoader = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(resourceClassLoader); - - try { - PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(PROPERTIES_FILE); - checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); - } finally { - Thread.currentThread().setContextClassLoader(saveContextClassLoader); + + /* + * static PersistenceManagerFactory getPersistenceManagerFactory() Get the + * anonymous PersistenceManagerFactory configured via the standard + * configuration file resource "META-INF/jdoconfig.xml", using the current + * thread's context class loader to locate the configuration file + * resource(s). + */ + public void testJDOConfigXML() throws IOException { + + ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); + ClassLoader saveContextClassLoader = Thread.currentThread().getContextClassLoader(); + Thread.currentThread().setContextClassLoader(resourceClassLoader); + + try { + PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(); + checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME); + } catch (JDOFatalUserException ex) { + fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); + } finally { + Thread.currentThread().setContextClassLoader(saveContextClassLoader); + } } - } - - /* - * static PersistenceManagerFactory getPersistenceManagerFactory( - * java.io.File propsFile, java.lang.ClassLoader loader) Returns a - * PersistenceManagerFactory configured based on the properties stored in - * the file at propsFile. - */ - public void testPropsFileAndLoader() throws IOException { - - ClassLoader resourceClassLoader = createResourceClassLoader(PROPS_DIR); - - try { - PersistenceManagerFactory pmf = - JDOHelper.getPersistenceManagerFactory(PROPERTIES_FILE, resourceClassLoader); - checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); + + /* + * static PersistenceManagerFactory getPersistenceManagerFactory + * (java.lang.ClassLoader pmfClassLoader) Get the anonymous + * PersistenceManagerFactory configured via the standard configuration file + * resource "META-INF/jdoconfig.xml", using the given class loader. + */ + public void testJDOConfigXMLWithLoader() throws IOException { + + ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); + + try { + PersistenceManagerFactory pmf = + JDOHelper.getPersistenceManagerFactory(resourceClassLoader); + checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME); + } catch (JDOFatalUserException ex) { + fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); + } } - } - - /* - * static PersistenceManagerFactory getPersistenceManagerFactory( - * java.io.InputStream stream) Returns a PersistenceManagerFactory - * configured based on the Properties stored in the input stream at stream. - */ - public void testInputStream() throws IOException { - Properties props = new Properties(); - props.setProperty(Constants.PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS, PMF_SERVICE_CLASS); - props.setProperty(Constants.PROPERTY_CONNECTION_FACTORY2_NAME, EXPECTED_FACTORY2_NAME); - - ByteArrayOutputStream outstream = new ByteArrayOutputStream(); - try { - props.store(outstream, ""); - } catch (IOException ex) { - fail(ex.getMessage()); + + /* + * static PersistenceManagerFactory getPersistenceManagerFactory( + * java.io.File propsFile) Returns a PersistenceManagerFactory configured + * based on the properties stored in the file at propsFile. + */ + public void testPropsFile() throws IOException { + + ClassLoader resourceClassLoader = createResourceClassLoader(PROPS_DIR); + ClassLoader saveContextClassLoader = Thread.currentThread().getContextClassLoader(); + Thread.currentThread().setContextClassLoader(resourceClassLoader); + + try { + PersistenceManagerFactory pmf = + JDOHelper.getPersistenceManagerFactory(PROPERTIES_FILE); + checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME); + } catch (JDOFatalUserException ex) { + fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); + } finally { + Thread.currentThread().setContextClassLoader(saveContextClassLoader); + } } - InputStream byteArrayInputStream = new ByteArrayInputStream(outstream.toByteArray()); - - ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); - ClassLoader saveContextClassLoader = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(resourceClassLoader); - - try { - PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(byteArrayInputStream); - checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); - } finally { - Thread.currentThread().setContextClassLoader(saveContextClassLoader); + + /* + * static PersistenceManagerFactory getPersistenceManagerFactory( + * java.io.File propsFile, java.lang.ClassLoader loader) Returns a + * PersistenceManagerFactory configured based on the properties stored in + * the file at propsFile. + */ + public void testPropsFileAndLoader() throws IOException { + + ClassLoader resourceClassLoader = createResourceClassLoader(PROPS_DIR); + + try { + PersistenceManagerFactory pmf = + JDOHelper.getPersistenceManagerFactory(PROPERTIES_FILE, resourceClassLoader); + checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME); + } catch (JDOFatalUserException ex) { + fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); + } } - } - - /* - * static PersistenceManagerFactory getPersistenceManagerFactory( - * java.io.InputStream stream, java.lang.ClassLoader loader) Returns a - * PersistenceManagerFactory configured based on the Properties stored in - * the input stream at stream. - */ - public void testInputStreamWithLoader() throws IOException { - Properties props = new Properties(); - props.setProperty(Constants.PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS, PMF_SERVICE_CLASS); - props.setProperty(Constants.PROPERTY_CONNECTION_FACTORY2_NAME, EXPECTED_FACTORY2_NAME); - - ByteArrayOutputStream outstream = new ByteArrayOutputStream(); - try { - props.store(outstream, ""); - } catch (IOException ex) { - fail(ex.getMessage()); + + /* + * static PersistenceManagerFactory getPersistenceManagerFactory( + * java.io.InputStream stream) Returns a PersistenceManagerFactory + * configured based on the Properties stored in the input stream at stream. + */ + public void testInputStream() throws IOException { + Properties props = new Properties(); + props.setProperty(Constants.PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS, PMF_SERVICE_CLASS); + props.setProperty(Constants.PROPERTY_CONNECTION_FACTORY2_NAME, EXPECTED_FACTORY2_NAME); + + ByteArrayOutputStream outstream = new ByteArrayOutputStream(); + try { + props.store(outstream, ""); + } catch (IOException ex) { + fail(ex.getMessage()); + } + InputStream byteArrayInputStream = new ByteArrayInputStream(outstream.toByteArray()); + + ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); + ClassLoader saveContextClassLoader = Thread.currentThread().getContextClassLoader(); + Thread.currentThread().setContextClassLoader(resourceClassLoader); + + try { + PersistenceManagerFactory pmf = + JDOHelper.getPersistenceManagerFactory(byteArrayInputStream); + checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME); + } catch (JDOFatalUserException ex) { + fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); + } finally { + Thread.currentThread().setContextClassLoader(saveContextClassLoader); + } } - InputStream byteArrayInputStream = new ByteArrayInputStream(outstream.toByteArray()); - ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); + /* + * static PersistenceManagerFactory getPersistenceManagerFactory( + * java.io.InputStream stream, java.lang.ClassLoader loader) Returns a + * PersistenceManagerFactory configured based on the Properties stored in + * the input stream at stream. + */ + public void testInputStreamWithLoader() throws IOException { + Properties props = new Properties(); + props.setProperty(Constants.PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS, PMF_SERVICE_CLASS); + props.setProperty(Constants.PROPERTY_CONNECTION_FACTORY2_NAME, EXPECTED_FACTORY2_NAME); + + ByteArrayOutputStream outstream = new ByteArrayOutputStream(); + try { + props.store(outstream, ""); + } catch (IOException ex) { + fail(ex.getMessage()); + } + InputStream byteArrayInputStream = new ByteArrayInputStream(outstream.toByteArray()); + + ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); - try { - PersistenceManagerFactory pmf = - JDOHelper.getPersistenceManagerFactory(byteArrayInputStream, resourceClassLoader); - checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); + try { + PersistenceManagerFactory pmf = + JDOHelper.getPersistenceManagerFactory(byteArrayInputStream, resourceClassLoader); + checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME); + } catch (JDOFatalUserException ex) { + fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); + } } - } - - /* - * static PersistenceManagerFactory getPersistenceManagerFactory( - * java.util.Map props) Get a PersistenceManagerFactory based on a - * Properties instance, using the current thread's context class loader to - * locate the PersistenceManagerFactory class. - */ - public void testProperties() throws IOException { - Properties props = new Properties(); - props.setProperty(Constants.PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS, PMF_SERVICE_CLASS); - props.setProperty(Constants.PROPERTY_CONNECTION_FACTORY2_NAME, EXPECTED_FACTORY2_NAME); - - ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); - ClassLoader saveContextClassLoader = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(resourceClassLoader); - try { - PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(props); - checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); - } finally { - Thread.currentThread().setContextClassLoader(saveContextClassLoader); + + /* + * static PersistenceManagerFactory getPersistenceManagerFactory( + * java.util.Map props) Get a PersistenceManagerFactory based on a + * Properties instance, using the current thread's context class loader to + * locate the PersistenceManagerFactory class. + */ + public void testProperties() throws IOException { + Properties props = new Properties(); + props.setProperty(Constants.PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS, PMF_SERVICE_CLASS); + props.setProperty(Constants.PROPERTY_CONNECTION_FACTORY2_NAME, EXPECTED_FACTORY2_NAME); + + ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); + ClassLoader saveContextClassLoader = Thread.currentThread().getContextClassLoader(); + Thread.currentThread().setContextClassLoader(resourceClassLoader); + try { + PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(props); + checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME); + } catch (JDOFatalUserException ex) { + fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); + } finally { + Thread.currentThread().setContextClassLoader(saveContextClassLoader); + } } - } - - /* - * static PersistenceManagerFactory getPersistenceManagerFactory( - * java.util.Map props, java.lang.ClassLoader pmfClassLoader) Get a - * PersistenceManagerFactory based on a Map and a class loader. - */ - public void testPropertiesAndLoader() throws IOException { - Properties props = new Properties(); - props.setProperty(Constants.PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS, PMF_SERVICE_CLASS); - props.setProperty(Constants.PROPERTY_CONNECTION_FACTORY2_NAME, EXPECTED_FACTORY2_NAME); - - ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); - try { - PersistenceManagerFactory pmf = - JDOHelper.getPersistenceManagerFactory(props, resourceClassLoader); - checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); + + /* + * static PersistenceManagerFactory getPersistenceManagerFactory( + * java.util.Map props, java.lang.ClassLoader pmfClassLoader) Get a + * PersistenceManagerFactory based on a Map and a class loader. + */ + public void testPropertiesAndLoader() throws IOException { + Properties props = new Properties(); + props.setProperty(Constants.PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS, PMF_SERVICE_CLASS); + props.setProperty(Constants.PROPERTY_CONNECTION_FACTORY2_NAME, EXPECTED_FACTORY2_NAME); + + ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); + try { + PersistenceManagerFactory pmf = + JDOHelper.getPersistenceManagerFactory(props, resourceClassLoader); + checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME); + } catch (JDOFatalUserException ex) { + fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); + } } - } - - /* - * static PersistenceManagerFactory getPersistenceManagerFactory - * (java.util.Map overrides, java.lang.String name) Returns a named - * PersistenceManagerFactory or persistence unit. - */ - public void testNamedPMFWithOverrides() throws IOException { - Properties overrides = new Properties(); - overrides.setProperty( - Constants.PROPERTY_CONNECTION_FACTORY2_NAME, EXPECTED_FACTORY2_NAME_WITH_OVERRIDE); - - ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); - ClassLoader saveContextClassLoader = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(resourceClassLoader); - - try { - PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(overrides, PMF_NAME); - checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME_WITH_OVERRIDE); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); - } finally { - Thread.currentThread().setContextClassLoader(saveContextClassLoader); + + /* + * static PersistenceManagerFactory getPersistenceManagerFactory + * (java.util.Map overrides, java.lang.String name) Returns a named + * PersistenceManagerFactory or persistence unit. + */ + public void testNamedPMFWithOverrides() throws IOException { + Properties overrides = new Properties(); + overrides.setProperty(Constants.PROPERTY_CONNECTION_FACTORY2_NAME, + EXPECTED_FACTORY2_NAME_WITH_OVERRIDE); + + ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); + ClassLoader saveContextClassLoader = Thread.currentThread().getContextClassLoader(); + Thread.currentThread().setContextClassLoader(resourceClassLoader); + + try { + PersistenceManagerFactory pmf = + JDOHelper.getPersistenceManagerFactory(overrides, PMF_NAME); + checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME_WITH_OVERRIDE); + } catch (JDOFatalUserException ex) { + fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); + } finally { + Thread.currentThread().setContextClassLoader(saveContextClassLoader); + } } - } - - /* - * static PersistenceManagerFactory getPersistenceManagerFactory( - * java.util.Map overrides, java.lang.String name, - * java.lang.ClassLoader resourceLoader) Returns a named - * PersistenceManagerFactory or persistence unit. - */ - public void testNamedPMFWithOverridesAndLoader() throws IOException { - Properties overrides = new Properties(); - overrides.setProperty( - Constants.PROPERTY_CONNECTION_FACTORY2_NAME, EXPECTED_FACTORY2_NAME_WITH_OVERRIDE); - - ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); - - try { - PersistenceManagerFactory pmf = - JDOHelper.getPersistenceManagerFactory(overrides, PMF_NAME, resourceClassLoader); - checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME_WITH_OVERRIDE); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); + + /* + * static PersistenceManagerFactory getPersistenceManagerFactory( + * java.util.Map overrides, java.lang.String name, + * java.lang.ClassLoader resourceLoader) Returns a named + * PersistenceManagerFactory or persistence unit. + */ + public void testNamedPMFWithOverridesAndLoader() throws IOException { + Properties overrides = new Properties(); + overrides.setProperty(Constants.PROPERTY_CONNECTION_FACTORY2_NAME, + EXPECTED_FACTORY2_NAME_WITH_OVERRIDE); + + ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); + + try { + PersistenceManagerFactory pmf = + JDOHelper.getPersistenceManagerFactory(overrides, PMF_NAME, resourceClassLoader); + checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME_WITH_OVERRIDE); + } catch (JDOFatalUserException ex) { + fail("Failed to find PersistenceManagerFactoryClass." + ex.getMessage()); + } } - } - - /* - * static PersistenceManagerFactory getPersistenceManagerFactory( - * java.util.Map overrides, java.lang.String name, - * java.lang.ClassLoader resourceLoader, java.lang.ClassLoader pmfLoader) - * Returns a PersistenceManagerFactory configured based on the properties - * stored in the resource at name, or, if not found, returns a - * PersistenceManagerFactory with the given name or, if not found, returns a - * javax.persistence.EntityManagerFactory cast to a - * PersistenceManagerFactory. - */ - public void testNamedPMFWithOverridesAndTwoLoaders() throws IOException { - Properties overrides = new Properties(); - overrides.setProperty( - Constants.PROPERTY_CONNECTION_FACTORY2_NAME, EXPECTED_FACTORY2_NAME_WITH_OVERRIDE); - - ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); - ClassLoader pmfLoader = getClass().getClassLoader(); - - try { - PersistenceManagerFactory pmf = - JDOHelper.getPersistenceManagerFactory( - overrides, PMF_NAME, resourceClassLoader, pmfLoader); - checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME_WITH_OVERRIDE); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass. " + ex.getMessage()); + + /* + * static PersistenceManagerFactory getPersistenceManagerFactory( + * java.util.Map overrides, java.lang.String name, + * java.lang.ClassLoader resourceLoader, java.lang.ClassLoader pmfLoader) + * Returns a PersistenceManagerFactory configured based on the properties + * stored in the resource at name, or, if not found, returns a + * PersistenceManagerFactory with the given name or, if not found, returns a + * javax.persistence.EntityManagerFactory cast to a + * PersistenceManagerFactory. + */ + public void testNamedPMFWithOverridesAndTwoLoaders() throws IOException { + Properties overrides = new Properties(); + overrides.setProperty(Constants.PROPERTY_CONNECTION_FACTORY2_NAME, + EXPECTED_FACTORY2_NAME_WITH_OVERRIDE); + + ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); + ClassLoader pmfLoader = getClass().getClassLoader(); + + try { + PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory( + overrides, PMF_NAME, resourceClassLoader, pmfLoader); + checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME_WITH_OVERRIDE); + } catch (JDOFatalUserException ex) { + fail("Failed to find PersistenceManagerFactoryClass. " + ex.getMessage()); + } } - } - - /* - * static PersistenceManagerFactory getPersistenceManagerFactory( - * java.lang.String name) Returns a named PersistenceManagerFactory or - * persistence unit. - */ - public void testNamedPMF() throws IOException { - - ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); - ClassLoader saveContextClassLoader = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(resourceClassLoader); - - try { - PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(PMF_NAME); - checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME_4_NAMED_PMF); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass. " + ex.getMessage()); - } finally { - Thread.currentThread().setContextClassLoader(saveContextClassLoader); + + /* + * static PersistenceManagerFactory getPersistenceManagerFactory( + * java.lang.String name) Returns a named PersistenceManagerFactory or + * persistence unit. + */ + public void testNamedPMF() throws IOException { + + ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); + ClassLoader saveContextClassLoader = Thread.currentThread().getContextClassLoader(); + Thread.currentThread().setContextClassLoader(resourceClassLoader); + + try { + PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(PMF_NAME); + checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME_4_NAMED_PMF); + } catch (JDOFatalUserException ex) { + fail("Failed to find PersistenceManagerFactoryClass. " + ex.getMessage()); + } finally { + Thread.currentThread().setContextClassLoader(saveContextClassLoader); + } } - } - - /* - * static PersistenceManagerFactory getPersistenceManagerFactory - * (java.lang.String name, java.lang.ClassLoader loader) Returns a named - * PersistenceManagerFactory or persistence unit. - */ - public void testNamedPMFWithLoader() throws IOException { - - ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); - - try { - PersistenceManagerFactory pmf = - JDOHelper.getPersistenceManagerFactory(PMF_NAME, resourceClassLoader); - checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME_4_NAMED_PMF); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass. " + ex.getMessage()); + + /* + * static PersistenceManagerFactory getPersistenceManagerFactory + * (java.lang.String name, java.lang.ClassLoader loader) Returns a named + * PersistenceManagerFactory or persistence unit. + */ + public void testNamedPMFWithLoader() throws IOException { + + ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); + + try { + PersistenceManagerFactory pmf = + JDOHelper.getPersistenceManagerFactory(PMF_NAME, resourceClassLoader); + checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME_4_NAMED_PMF); + } catch (JDOFatalUserException ex) { + fail("Failed to find PersistenceManagerFactoryClass. " + ex.getMessage()); + } } - } - - /* - * static PersistenceManagerFactory getPersistenceManagerFactory( - * java.lang.String name, java.lang.ClassLoader resourceLoader, - * java.lang.ClassLoader pmfLoader) Returns a named - * PersistenceManagerFactory or persistence unit. - */ - public void testNamedPMFWithTwoLoaders() throws IOException { - - ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); - ClassLoader pmfLoader = getClass().getClassLoader(); - - try { - PersistenceManagerFactory pmf = - JDOHelper.getPersistenceManagerFactory(PMF_NAME, resourceClassLoader, pmfLoader); - checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME_4_NAMED_PMF); - } catch (JDOFatalUserException ex) { - fail("Failed to find PersistenceManagerFactoryClass. " + ex.getMessage()); + + /* + * static PersistenceManagerFactory getPersistenceManagerFactory( + * java.lang.String name, java.lang.ClassLoader resourceLoader, + * java.lang.ClassLoader pmfLoader) Returns a named + * PersistenceManagerFactory or persistence unit. + */ + public void testNamedPMFWithTwoLoaders() throws IOException { + + ClassLoader resourceClassLoader = createResourceClassLoader(RESOURCE_DIR); + ClassLoader pmfLoader = getClass().getClassLoader(); + + try { + PersistenceManagerFactory pmf = + JDOHelper.getPersistenceManagerFactory(PMF_NAME, resourceClassLoader, pmfLoader); + checkConnectionFactory2Name(pmf, EXPECTED_FACTORY2_NAME_4_NAMED_PMF); + } catch (JDOFatalUserException ex) { + fail("Failed to find PersistenceManagerFactoryClass. " + ex.getMessage()); + } } - } - - private ClassLoader createResourceClassLoader(String dir) throws IOException { - switch (dir.charAt(dir.length() - 1)) { - case '\\': - dir = dir.substring(0, dir.length() - 1) + '/'; - break; - case '/': - break; - default: - if (new File(dir).isDirectory()) { - dir += '/'; + + private ClassLoader createResourceClassLoader(String dir) throws IOException { + switch (dir.charAt(dir.length() - 1)) { + case '\\': + dir = dir.substring(0, dir.length() - 1) + '/'; + break; + case '/': + break; + default: + if (new File(dir).isDirectory()) { + dir += '/'; + } } + return new JDOConfigTestClassLoader(getClass().getClassLoader(), + JDOCONFIG_CLASSPATH_PREFIX + dir); } - return new JDOConfigTestClassLoader( - getClass().getClassLoader(), JDOCONFIG_CLASSPATH_PREFIX + dir); - } - - private void checkConnectionFactory2Name(PersistenceManagerFactory pmf, String expectedName) { - String factory2Name = pmf.getConnectionFactory2Name(); - if (!expectedName.equals(factory2Name)) { - fail( - "Bad ConnectionFactory2Name(): " - + factory2Name - + ". Expected: \"" - + expectedName - + "\""); + + private void checkConnectionFactory2Name(PersistenceManagerFactory pmf, String expectedName) { + String factory2Name = pmf.getConnectionFactory2Name(); + if (!expectedName.equals(factory2Name)) { + fail("Bad ConnectionFactory2Name(): " + factory2Name + ". Expected: \"" + expectedName + "\""); + } } - } + } diff --git a/api/src/test/java/javax/jdo/PMFProxy.java b/api/src/test/java/javax/jdo/PMFProxy.java index 007b5898b..51df676ec 100644 --- a/api/src/test/java/javax/jdo/PMFProxy.java +++ b/api/src/test/java/javax/jdo/PMFProxy.java @@ -5,13 +5,13 @@ * 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 + * + * 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 javax.jdo; @@ -20,34 +20,39 @@ import java.lang.reflect.Method; import java.lang.reflect.Proxy; -/** */ +/** + * + *

    + */ public class PMFProxy implements InvocationHandler { - private String connectionDriverName; + private String connectionDriverName; - public static PersistenceManagerFactory newInstance() { - PersistenceManagerFactory pmf = - (PersistenceManagerFactory) - Proxy.newProxyInstance( + public static PersistenceManagerFactory newInstance() { + PersistenceManagerFactory pmf = + (PersistenceManagerFactory) Proxy.newProxyInstance( PMFProxy.class.getClassLoader(), - new Class[] {PersistenceManagerFactory.class}, + new Class[]{PersistenceManagerFactory.class}, new PMFProxy()); - return pmf; - } + return pmf; + } - /* - * - */ - public Object invoke(Object proxy, Method m, Object[] args) throws Exception { - Object result = null; + /* + * + */ + public Object invoke(Object proxy, Method m, Object[] args) + throws Exception { + Object result = null; - if (m.getName().equals("getConnectionDriverName")) { - result = connectionDriverName; - } else if (m.getName().equals("setConnectionDriverName")) { - connectionDriverName = (String) args[0]; - } else { - throw new Exception("Unexpected invocation of method: " + m); + if (m.getName().equals("getConnectionDriverName")) { + result = connectionDriverName; + } else if (m.getName().equals("setConnectionDriverName")) { + connectionDriverName = (String) args[0]; + } else { + throw new Exception( + "Unexpected invocation of method: " + m); + } + return result; } - return result; - } } + diff --git a/api/src/test/java/javax/jdo/PMFService.java b/api/src/test/java/javax/jdo/PMFService.java index 91e9da1fa..7d1a8e361 100644 --- a/api/src/test/java/javax/jdo/PMFService.java +++ b/api/src/test/java/javax/jdo/PMFService.java @@ -5,44 +5,54 @@ * 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 + * + * 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 javax.jdo; import java.util.Map; -/** */ -public class PMFService implements Constants { +/** + * + *

    + */ +public class PMFService implements Constants{ - public PMFService() {} + public PMFService() { + } - public static PersistenceManagerFactory getPersistenceManagerFactory(Map overrides, Map props) { - PersistenceManagerFactory pmf = (PersistenceManagerFactory) PMFProxy.newInstance(); - setPMFProperties(pmf, props, overrides); + public static PersistenceManagerFactory getPersistenceManagerFactory( + Map overrides, Map props) { + PersistenceManagerFactory pmf = + (PersistenceManagerFactory) PMFProxy.newInstance(); + setPMFProperties(pmf, props, overrides); - return pmf; - } + return pmf; + } - public static PersistenceManagerFactory getPersistenceManagerFactory(Map props) { - PersistenceManagerFactory pmf = (PersistenceManagerFactory) PMFProxy.newInstance(); - setPMFProperties(pmf, props, null); + public static PersistenceManagerFactory getPersistenceManagerFactory( + Map props) { + PersistenceManagerFactory pmf = + (PersistenceManagerFactory) PMFProxy.newInstance(); + setPMFProperties(pmf, props, null); - return pmf; - } + return pmf; + } - private static void setPMFProperties(PersistenceManagerFactory pmf, Map props, Map overrides) { + private static void setPMFProperties(PersistenceManagerFactory pmf, + Map props, Map overrides) { - pmf.setConnectionDriverName((String) props.get(PROPERTY_CONNECTION_DRIVER_NAME)); + pmf.setConnectionDriverName((String)props.get(PROPERTY_CONNECTION_DRIVER_NAME)); - if (overrides != null) { - pmf.setConnectionDriverName((String) overrides.get(PROPERTY_CONNECTION_DRIVER_NAME)); + if (overrides != null) { + pmf.setConnectionDriverName((String)overrides.get(PROPERTY_CONNECTION_DRIVER_NAME)); + } } - } } + diff --git a/api/src/test/java/javax/jdo/annotations/Line.java b/api/src/test/java/javax/jdo/annotations/Line.java index c72a8e1ab..d07eaf004 100644 --- a/api/src/test/java/javax/jdo/annotations/Line.java +++ b/api/src/test/java/javax/jdo/annotations/Line.java @@ -24,10 +24,11 @@ * */ public class Line { + + /** Creates a new instance of Line */ + public Line() { + } - /** Creates a new instance of Line */ - public Line() {} - - Point point1; - Point point2; + Point point1; + Point point2; } diff --git a/api/src/test/java/javax/jdo/annotations/Point.java b/api/src/test/java/javax/jdo/annotations/Point.java index 3ee21dd77..245a975b4 100644 --- a/api/src/test/java/javax/jdo/annotations/Point.java +++ b/api/src/test/java/javax/jdo/annotations/Point.java @@ -24,10 +24,11 @@ * */ public class Point { + + /** Creates a new instance of Point */ + public Point() { + } - /** Creates a new instance of Point */ - public Point() {} - - int x; - Integer y; + int x; + Integer y; } diff --git a/api/src/test/java/javax/jdo/annotations/TestEmbeddedMap.java b/api/src/test/java/javax/jdo/annotations/TestEmbeddedMap.java index e09032f3b..b8faf78a8 100644 --- a/api/src/test/java/javax/jdo/annotations/TestEmbeddedMap.java +++ b/api/src/test/java/javax/jdo/annotations/TestEmbeddedMap.java @@ -26,35 +26,35 @@ * */ public abstract class TestEmbeddedMap { + + /** Creates a new instance of TestEmbeddedMap */ + public TestEmbeddedMap() { + } - /** Creates a new instance of TestEmbeddedMap */ - public TestEmbeddedMap() {} + @Persistent(table="INTEGER_LINES", embeddedKey="true", embeddedValue="true") + @Join(column="OWNER_FK") + @Key(column="INTEGER") + @Value( + embeddedMapping=@Embedded( + members={ + @Persistent(name="point1.x", column="POINT1_X"), + @Persistent(name="point1.y", column="POINT2_Y"), + @Persistent(name="point2.x", column="POINT2_X"), + @Persistent(name="point2.y", column="POINT2_Y") + })) + Map integerLines; - @Persistent(table = "INTEGER_LINES", embeddedKey = "true", embeddedValue = "true") - @Join(column = "OWNER_FK") - @Key(column = "INTEGER") - @Value( - embeddedMapping = - @Embedded( - members = { - @Persistent(name = "point1.x", column = "POINT1_X"), - @Persistent(name = "point1.y", column = "POINT2_Y"), - @Persistent(name = "point2.x", column = "POINT2_X"), - @Persistent(name = "point2.y", column = "POINT2_Y") - })) - Map integerLines; + @Persistent(table="INTEGER_LINES", embeddedKey="true", embeddedValue="true") + @Join(column="OWNER_FK") + @Key(column="INTEGER") + @Value( + embeddedMapping=@Embedded( + members={ + @Persistent(name="point1.x", column="POINT1_X"), + @Persistent(name="point1.y", column="POINT2_Y"), + @Persistent(name="point2.x", column="POINT2_X"), + @Persistent(name="point2.y", column="POINT2_Y") + })) + abstract Map getIntegerLines(); - @Persistent(table = "INTEGER_LINES", embeddedKey = "true", embeddedValue = "true") - @Join(column = "OWNER_FK") - @Key(column = "INTEGER") - @Value( - embeddedMapping = - @Embedded( - members = { - @Persistent(name = "point1.x", column = "POINT1_X"), - @Persistent(name = "point1.y", column = "POINT2_Y"), - @Persistent(name = "point2.x", column = "POINT2_X"), - @Persistent(name = "point2.y", column = "POINT2_Y") - })) - abstract Map getIntegerLines(); } diff --git a/api/src/test/java/javax/jdo/annotations/TestEmbeddedSet.java b/api/src/test/java/javax/jdo/annotations/TestEmbeddedSet.java index 790909d15..d11bb2502 100644 --- a/api/src/test/java/javax/jdo/annotations/TestEmbeddedSet.java +++ b/api/src/test/java/javax/jdo/annotations/TestEmbeddedSet.java @@ -27,33 +27,35 @@ */ @PersistenceCapable public abstract class TestEmbeddedSet { + + /** Creates a new instance of TestEmbeddedSet */ - /** Creates a new instance of TestEmbeddedSet */ - public TestEmbeddedSet() {} + public TestEmbeddedSet() { + } - @Persistent(table = "LINES", embeddedElement = "true") - @Join(column = "OWNER_FK") - @Element( - embeddedMapping = - @Embedded( - members = { - @Persistent(name = "point1.x", column = "POINT1_X"), - @Persistent(name = "point1.y", column = "POINT2_Y"), - @Persistent(name = "point2.x", column = "POINT2_X"), - @Persistent(name = "point2.y", column = "POINT2_Y") - })) - Set lines; + @Persistent (table="LINES", embeddedElement="true") + @Join(column="OWNER_FK") + @Element ( + embeddedMapping=@Embedded( + members={ + @Persistent(name="point1.x", column="POINT1_X"), + @Persistent(name="point1.y", column="POINT2_Y"), + @Persistent(name="point2.x", column="POINT2_X"), + @Persistent(name="point2.y", column="POINT2_Y") + })) + Set lines; - @Persistent(embeddedElement = "true") - @Join(column = "OWNER_FK") - @Element( - embeddedMapping = - @Embedded( - members = { - @Persistent(name = "point1.x", column = "POINT1_X"), - @Persistent(name = "point1.y", column = "POINT2_Y"), - @Persistent(name = "point2.x", column = "POINT2_X"), - @Persistent(name = "point2.y", column = "POINT2_Y") - })) - abstract Set getLines(); + @Persistent (embeddedElement="true") + @Join(column="OWNER_FK") + @Element ( + embeddedMapping=@Embedded( + members={ + @Persistent(name="point1.x", column="POINT1_X"), + @Persistent(name="point1.y", column="POINT2_Y"), + @Persistent(name="point2.x", column="POINT2_X"), + @Persistent(name="point2.y", column="POINT2_Y") + })) + abstract Set getLines(); + + } diff --git a/api/src/test/java/javax/jdo/annotations/TestExtensions.java b/api/src/test/java/javax/jdo/annotations/TestExtensions.java index 410dd5b97..567b45de9 100644 --- a/api/src/test/java/javax/jdo/annotations/TestExtensions.java +++ b/api/src/test/java/javax/jdo/annotations/TestExtensions.java @@ -24,31 +24,28 @@ * Add extensions element to @Index, @ForeignKey, @Unique, @PrimaryKey annotations. */ public abstract class TestExtensions { + + /** Creates a new instance of TestExtensions */ + public TestExtensions() { + } - /** Creates a new instance of TestExtensions */ - public TestExtensions() {} + @PrimaryKey(extensions= { + @Extension(vendorName = "vendor 1", key = "key 1", value = "value 1"), + @Extension(vendorName = "vendor 2", key = "key 2", value = "value 2")} + ) + long pk; - @PrimaryKey( - extensions = { - @Extension(vendorName = "vendor 1", key = "key 1", value = "value 1"), - @Extension(vendorName = "vendor 2", key = "key 2", value = "value 2") - }) - long pk; - - @Index( - extensions = { - @Extension(vendorName = "vendor 1", key = "key 1", value = "value 1"), - @Extension(vendorName = "vendor 2", key = "key 2", value = "value 2") - }) - @Unique( - extensions = { - @Extension(vendorName = "vendor 1", key = "key 1", value = "value 1"), - @Extension(vendorName = "vendor 2", key = "key 2", value = "value 2") - }) - @ForeignKey( - extensions = { - @Extension(vendorName = "vendor 1", key = "key 1", value = "value 1"), - @Extension(vendorName = "vendor 2", key = "key 2", value = "value 2") - }) - long fk; + @Index(extensions= { + @Extension(vendorName = "vendor 1", key = "key 1", value = "value 1"), + @Extension(vendorName = "vendor 2", key = "key 2", value = "value 2")} + ) + @Unique(extensions= { + @Extension(vendorName = "vendor 1", key = "key 1", value = "value 1"), + @Extension(vendorName = "vendor 2", key = "key 2", value = "value 2")} + ) + @ForeignKey(extensions= { + @Extension(vendorName = "vendor 1", key = "key 1", value = "value 1"), + @Extension(vendorName = "vendor 2", key = "key 2", value = "value 2")} + ) + long fk; } diff --git a/api/src/test/java/javax/jdo/identity/ByteIdentityTest.java b/api/src/test/java/javax/jdo/identity/ByteIdentityTest.java index a4cbd7770..3093fb00f 100644 --- a/api/src/test/java/javax/jdo/identity/ByteIdentityTest.java +++ b/api/src/test/java/javax/jdo/identity/ByteIdentityTest.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -23,117 +23,118 @@ package javax.jdo.identity; import javax.jdo.JDONullIdentityException; + import javax.jdo.util.BatchTestRunner; -/** */ +/** + * + */ public class ByteIdentityTest extends SingleFieldIdentityTest { + + /** Creates a new instance of ByteIdentityTest */ + public ByteIdentityTest() { + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + BatchTestRunner.run(ByteIdentityTest.class); + } + + public void testConstructor() { + ByteIdentity c1 = new ByteIdentity(Object.class, (byte)1); + ByteIdentity c2 = new ByteIdentity(Object.class, (byte)1); + ByteIdentity c3 = new ByteIdentity(Object.class, (byte)2); + assertEquals("Equal ByteIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal ByteIdentity instances compare equal", c1.equals(c3)); + } - /** Creates a new instance of ByteIdentityTest */ - public ByteIdentityTest() {} - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - BatchTestRunner.run(ByteIdentityTest.class); - } - - public void testConstructor() { - ByteIdentity c1 = new ByteIdentity(Object.class, (byte) 1); - ByteIdentity c2 = new ByteIdentity(Object.class, (byte) 1); - ByteIdentity c3 = new ByteIdentity(Object.class, (byte) 2); - assertEquals("Equal ByteIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal ByteIdentity instances compare equal", c1.equals(c3)); - } - - public void testByteConstructor() { - ByteIdentity c1 = new ByteIdentity(Object.class, (byte) 1); - ByteIdentity c2 = new ByteIdentity(Object.class, Byte.valueOf((byte) 1)); - ByteIdentity c3 = new ByteIdentity(Object.class, Byte.valueOf((byte) 2)); - assertEquals("Equal ByteIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal ByteIdentity instances compare equal", c1.equals(c3)); - } - - public void testToStringConstructor() { - ByteIdentity c1 = new ByteIdentity(Object.class, (byte) 1); - ByteIdentity c2 = new ByteIdentity(Object.class, c1.toString()); - assertEquals("Equal ByteIdentity instances compare not equal.", c1, c2); - } - - public void testStringConstructor() { - ByteIdentity c1 = new ByteIdentity(Object.class, (byte) 1); - ByteIdentity c2 = new ByteIdentity(Object.class, "1"); - ByteIdentity c3 = new ByteIdentity(Object.class, "2"); - assertEquals("Equal ByteIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal ByteIdentity instances compare equal", c1.equals(c3)); - } - - public void testIllegalStringConstructor() { - try { - new ByteIdentity(Object.class, "b"); - } catch (IllegalArgumentException iae) { - return; // good + public void testByteConstructor() { + ByteIdentity c1 = new ByteIdentity(Object.class, (byte)1); + ByteIdentity c2 = new ByteIdentity(Object.class, Byte.valueOf((byte)1)); + ByteIdentity c3 = new ByteIdentity(Object.class, Byte.valueOf((byte)2)); + assertEquals ("Equal ByteIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal ByteIdentity instances compare equal", c1.equals(c3)); } - fail("No exception caught for illegal String."); - } - public void testSerialized() { - ByteIdentity c1 = new ByteIdentity(Object.class, (byte) 1); - ByteIdentity c2 = new ByteIdentity(Object.class, "1"); - ByteIdentity c3 = new ByteIdentity(Object.class, "2"); - Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); - Object sc1 = scis[0]; - Object sc2 = scis[1]; - Object sc3 = scis[2]; - assertEquals("Equal ByteIdentity instances compare not equal.", c1, sc1); - assertEquals("Equal ByteIdentity instances compare not equal.", c2, sc2); - assertEquals("Equal ByteIdentity instances compare not equal.", sc1, c2); - assertEquals("Equal ByteIdentity instances compare not equal.", sc2, c1); - assertFalse("Not equal ByteIdentity instances compare equal.", c1.equals(sc3)); - assertFalse("Not equal ByteIdentity instances compare equal.", sc1.equals(c3)); - assertFalse("Not equal ByteIdentity instances compare equal.", sc1.equals(sc3)); - assertFalse("Not equal ByteIdentity instances compare equal.", sc3.equals(sc1)); - } + public void testToStringConstructor() { + ByteIdentity c1 = new ByteIdentity(Object.class, (byte)1); + ByteIdentity c2 = new ByteIdentity(Object.class, c1.toString()); + assertEquals ("Equal ByteIdentity instances compare not equal.", c1, c2); + } - public void testGetKeyAsObjectPrimitive() { - ByteIdentity c1 = new ByteIdentity(Object.class, (byte) 1); - assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Byte.valueOf((byte) 1)); - } + public void testStringConstructor() { + ByteIdentity c1 = new ByteIdentity(Object.class, (byte)1); + ByteIdentity c2 = new ByteIdentity(Object.class, "1"); + ByteIdentity c3 = new ByteIdentity(Object.class, "2"); + assertEquals ("Equal ByteIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal ByteIdentity instances compare equal", c1.equals(c3)); + } + + public void testIllegalStringConstructor() { + try { + new ByteIdentity(Object.class, "b"); + } catch (IllegalArgumentException iae) { + return; // good + } + fail ("No exception caught for illegal String."); + } + + public void testSerialized() { + ByteIdentity c1 = new ByteIdentity(Object.class, (byte)1); + ByteIdentity c2 = new ByteIdentity(Object.class, "1"); + ByteIdentity c3 = new ByteIdentity(Object.class, "2"); + Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); + Object sc1 = scis[0]; + Object sc2 = scis[1]; + Object sc3 = scis[2]; + assertEquals ("Equal ByteIdentity instances compare not equal.", c1, sc1); + assertEquals ("Equal ByteIdentity instances compare not equal.", c2, sc2); + assertEquals ("Equal ByteIdentity instances compare not equal.", sc1, c2); + assertEquals ("Equal ByteIdentity instances compare not equal.", sc2, c1); + assertFalse ("Not equal ByteIdentity instances compare equal.", c1.equals(sc3)); + assertFalse ("Not equal ByteIdentity instances compare equal.", sc1.equals(c3)); + assertFalse ("Not equal ByteIdentity instances compare equal.", sc1.equals(sc3)); + assertFalse ("Not equal ByteIdentity instances compare equal.", sc3.equals(sc1)); + } + + public void testGetKeyAsObjectPrimitive() { + ByteIdentity c1 = new ByteIdentity(Object.class, (byte)1); + assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Byte.valueOf((byte)1)); + } - public void testGetKeyAsObject() { - ByteIdentity c1 = new ByteIdentity(Object.class, Byte.valueOf((byte) 1)); - assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Byte.valueOf((byte) 1)); - } + public void testGetKeyAsObject() { + ByteIdentity c1 = new ByteIdentity(Object.class, Byte.valueOf((byte)1)); + assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Byte.valueOf((byte)1)); + } - public void testBadConstructorNullByteParam() { - try { - new ByteIdentity(Object.class, (Byte) null); - } catch (JDONullIdentityException ex) { - return; + public void testBadConstructorNullByteParam() { + try { + new ByteIdentity(Object.class, (Byte)null); + } catch (JDONullIdentityException ex) { + return; + } + fail ("Failed to catch expected exception."); } - fail("Failed to catch expected exception."); - } - public void testBadConstructorNullStringParam() { - try { - new ByteIdentity(Object.class, (String) null); - } catch (JDONullIdentityException ex) { - return; + public void testBadConstructorNullStringParam() { + try { + new ByteIdentity(Object.class, (String)null); + } catch (JDONullIdentityException ex) { + return; + } + fail ("Failed to catch expected exception."); } - fail("Failed to catch expected exception."); - } - public void testCompareTo() { - ByteIdentity c1 = new ByteIdentity(Object.class, (byte) 1); - ByteIdentity c2 = new ByteIdentity(Object.class, (byte) 1); - ByteIdentity c3 = new ByteIdentity(Object.class, (byte) 2); - ByteIdentity c4 = new ByteIdentity(Class.class, (byte) 1); - assertEquals("Equal ByteIdentity instances compare not equal.", 0, c1.compareTo(c2)); - assertTrue( - "Not equal ByteIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0); - assertTrue( - "Not equal ByteIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0); - assertTrue( - "Not equal ByteIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0); - } + public void testCompareTo() { + ByteIdentity c1 = new ByteIdentity(Object.class, (byte)1); + ByteIdentity c2 = new ByteIdentity(Object.class, (byte)1); + ByteIdentity c3 = new ByteIdentity(Object.class, (byte)2); + ByteIdentity c4 = new ByteIdentity(Class.class, (byte)1); + assertEquals("Equal ByteIdentity instances compare not equal.", 0, c1.compareTo(c2)); + assertTrue("Not equal ByteIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0); + assertTrue("Not equal ByteIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0); + assertTrue("Not equal ByteIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0); + } } diff --git a/api/src/test/java/javax/jdo/identity/CharIdentityTest.java b/api/src/test/java/javax/jdo/identity/CharIdentityTest.java index f4b543cd8..6995d151f 100644 --- a/api/src/test/java/javax/jdo/identity/CharIdentityTest.java +++ b/api/src/test/java/javax/jdo/identity/CharIdentityTest.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -23,128 +23,127 @@ package javax.jdo.identity; import javax.jdo.JDONullIdentityException; + import javax.jdo.util.BatchTestRunner; /** + * * @author clr */ public class CharIdentityTest extends SingleFieldIdentityTest { - - /** Creates a new instance of CharIdentityTest */ - public CharIdentityTest() {} - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - BatchTestRunner.run(CharIdentityTest.class); - } - - public void testConstructor() { - CharIdentity c1 = new CharIdentity(Object.class, 'a'); - CharIdentity c2 = new CharIdentity(Object.class, 'a'); - CharIdentity c3 = new CharIdentity(Object.class, 'b'); - assertEquals("Equal CharIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal CharIdentity instances compare equal", c1.equals(c3)); - } - - public void testCharacterConstructor() { - CharIdentity c1 = new CharIdentity(Object.class, 'a'); - CharIdentity c2 = new CharIdentity(Object.class, Character.valueOf('a')); - CharIdentity c3 = new CharIdentity(Object.class, Character.valueOf('b')); - assertEquals("Equal CharIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal CharIdentity instances compare equal", c1.equals(c3)); - } - - public void testToStringConstructor() { - CharIdentity c1 = new CharIdentity(Object.class, 'a'); - CharIdentity c2 = new CharIdentity(Object.class, c1.toString()); - assertEquals("Equal CharIdentity instances compare not equal.", c1, c2); - } - - public void testStringConstructor() { - CharIdentity c1 = new CharIdentity(Object.class, 'a'); - CharIdentity c2 = new CharIdentity(Object.class, "a"); - CharIdentity c3 = new CharIdentity(Object.class, "b"); - assertEquals("Equal CharIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal CharIdentity instances compare equal", c1.equals(c3)); - } - - public void testStringConstructorTooLong() { - try { - new CharIdentity(Object.class, "ab"); - } catch (IllegalArgumentException iae) { - return; // good + + /** Creates a new instance of CharIdentityTest */ + public CharIdentityTest() { } - fail("No exception caught for String too long."); - } - - public void testStringConstructorTooShort() { - try { - new CharIdentity(Object.class, ""); - } catch (IllegalArgumentException iae) { - return; // good + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + BatchTestRunner.run(CharIdentityTest.class); + } + + public void testConstructor() { + CharIdentity c1 = new CharIdentity(Object.class, 'a'); + CharIdentity c2 = new CharIdentity(Object.class, 'a'); + CharIdentity c3 = new CharIdentity(Object.class, 'b'); + assertEquals("Equal CharIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal CharIdentity instances compare equal", c1.equals(c3)); + } + + public void testCharacterConstructor() { + CharIdentity c1 = new CharIdentity(Object.class, 'a'); + CharIdentity c2 = new CharIdentity(Object.class, Character.valueOf('a')); + CharIdentity c3 = new CharIdentity(Object.class, Character.valueOf('b')); + assertEquals("Equal CharIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal CharIdentity instances compare equal", c1.equals(c3)); + } + + public void testToStringConstructor() { + CharIdentity c1 = new CharIdentity(Object.class, 'a'); + CharIdentity c2 = new CharIdentity(Object.class, c1.toString()); + assertEquals ("Equal CharIdentity instances compare not equal.", c1, c2); + } + + public void testStringConstructor() { + CharIdentity c1 = new CharIdentity(Object.class, 'a'); + CharIdentity c2 = new CharIdentity(Object.class, "a"); + CharIdentity c3 = new CharIdentity(Object.class, "b"); + assertEquals ("Equal CharIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal CharIdentity instances compare equal", c1.equals(c3)); + } + + public void testStringConstructorTooLong() { + try { + new CharIdentity(Object.class, "ab"); + } catch (IllegalArgumentException iae) { + return; // good + } + fail ("No exception caught for String too long."); + } + + public void testStringConstructorTooShort() { + try { + new CharIdentity(Object.class, ""); + } catch (IllegalArgumentException iae) { + return; // good + } + fail ("No exception caught for String too short."); + } + + public void testSerialized() { + CharIdentity c1 = new CharIdentity(Object.class, 'a'); + CharIdentity c2 = new CharIdentity(Object.class, "a"); + CharIdentity c3 = new CharIdentity(Object.class, "b"); + Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); + Object sc1 = scis[0]; + Object sc2 = scis[1]; + Object sc3 = scis[2]; + assertEquals ("Equal CharIdentity instances compare not equal.", c1, sc1); + assertEquals ("Equal CharIdentity instances compare not equal.", c2, sc2); + assertEquals ("Equal CharIdentity instances compare not equal.", sc1, c2); + assertEquals ("Equal CharIdentity instances compare not equal.", sc2, c1); + assertFalse ("Not equal CharIdentity instances compare equal.", c1.equals(sc3)); + assertFalse ("Not equal CharIdentity instances compare equal.", sc1.equals(c3)); + assertFalse ("Not equal CharIdentity instances compare equal.", sc1.equals(sc3)); + assertFalse ("Not equal CharIdentity instances compare equal.", sc3.equals(sc1)); + } + public void testGetKeyAsObjectPrimitive() { + CharIdentity c1 = new CharIdentity(Object.class, '1'); + assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Character.valueOf('1')); } - fail("No exception caught for String too short."); - } - - public void testSerialized() { - CharIdentity c1 = new CharIdentity(Object.class, 'a'); - CharIdentity c2 = new CharIdentity(Object.class, "a"); - CharIdentity c3 = new CharIdentity(Object.class, "b"); - Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); - Object sc1 = scis[0]; - Object sc2 = scis[1]; - Object sc3 = scis[2]; - assertEquals("Equal CharIdentity instances compare not equal.", c1, sc1); - assertEquals("Equal CharIdentity instances compare not equal.", c2, sc2); - assertEquals("Equal CharIdentity instances compare not equal.", sc1, c2); - assertEquals("Equal CharIdentity instances compare not equal.", sc2, c1); - assertFalse("Not equal CharIdentity instances compare equal.", c1.equals(sc3)); - assertFalse("Not equal CharIdentity instances compare equal.", sc1.equals(c3)); - assertFalse("Not equal CharIdentity instances compare equal.", sc1.equals(sc3)); - assertFalse("Not equal CharIdentity instances compare equal.", sc3.equals(sc1)); - } - - public void testGetKeyAsObjectPrimitive() { - CharIdentity c1 = new CharIdentity(Object.class, '1'); - assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Character.valueOf('1')); - } - public void testGetKeyAsObject() { - CharIdentity c1 = new CharIdentity(Object.class, Character.valueOf('1')); - assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Character.valueOf('1')); - } + public void testGetKeyAsObject() { + CharIdentity c1 = new CharIdentity(Object.class, Character.valueOf('1')); + assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Character.valueOf('1')); + } - public void testBadConstructorNullCharacterParam() { - try { - new CharIdentity(Object.class, (Character) null); - } catch (JDONullIdentityException ex) { - return; + public void testBadConstructorNullCharacterParam() { + try { + new CharIdentity(Object.class, (Character)null); + } catch (JDONullIdentityException ex) { + return; + } + fail ("Failed to catch expected exception."); } - fail("Failed to catch expected exception."); - } - public void testBadConstructorNullStringParam() { - try { - new CharIdentity(Object.class, (String) null); - } catch (JDONullIdentityException ex) { - return; + public void testBadConstructorNullStringParam() { + try { + new CharIdentity(Object.class, (String)null); + } catch (JDONullIdentityException ex) { + return; + } + fail ("Failed to catch expected exception."); } - fail("Failed to catch expected exception."); - } - public void testCompareTo() { - CharIdentity c1 = new CharIdentity(Object.class, '1'); - CharIdentity c2 = new CharIdentity(Object.class, '1'); - CharIdentity c3 = new CharIdentity(Object.class, '2'); - CharIdentity c4 = new CharIdentity(Class.class, '1'); - assertEquals("Equal CharIdentity instances compare not equal.", 0, c1.compareTo(c2)); - assertTrue( - "Not equal CharIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0); - assertTrue( - "Not equal CharIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0); - assertTrue( - "Not equal CharIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0); - } + public void testCompareTo() { + CharIdentity c1 = new CharIdentity(Object.class, '1'); + CharIdentity c2 = new CharIdentity(Object.class, '1'); + CharIdentity c3 = new CharIdentity(Object.class, '2'); + CharIdentity c4 = new CharIdentity(Class.class, '1'); + assertEquals("Equal CharIdentity instances compare not equal.", 0, c1.compareTo(c2)); + assertTrue("Not equal CharIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0); + assertTrue("Not equal CharIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0); + assertTrue("Not equal CharIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0); + } } diff --git a/api/src/test/java/javax/jdo/identity/ConcreteTestIdentity.java b/api/src/test/java/javax/jdo/identity/ConcreteTestIdentity.java index 44657b386..02de1ee75 100644 --- a/api/src/test/java/javax/jdo/identity/ConcreteTestIdentity.java +++ b/api/src/test/java/javax/jdo/identity/ConcreteTestIdentity.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -27,35 +27,36 @@ import java.io.ObjectOutput; /** + * * @author clr */ -public class ConcreteTestIdentity extends SingleFieldIdentity { - - ConcreteTestIdentity(Class cls) { - super(cls); - } - - /** This constructor is only for Serialization */ - public ConcreteTestIdentity() { - super(); - } - - /** - * Determine the ordering of identity objects. - * - * @param o Other identity - * @return The relative ordering between the objects - * @since 2.2 - */ - public int compareTo(Object o) { - throw new ClassCastException("Not implemented"); - } - - public void writeExternal(ObjectOutput out) throws IOException { - super.writeExternal(out); - } - - public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - super.readExternal(in); - } -} + public class ConcreteTestIdentity extends SingleFieldIdentity { + + ConcreteTestIdentity(Class cls) { + super(cls); + } + + /** This constructor is only for Serialization + */ + public ConcreteTestIdentity() { + super(); + } + + /** Determine the ordering of identity objects. + * @param o Other identity + * @return The relative ordering between the objects + * @since 2.2 + */ + public int compareTo(Object o) { + throw new ClassCastException("Not implemented"); + } + + public void writeExternal(ObjectOutput out) throws IOException { + super.writeExternal(out); + } + + public void readExternal(ObjectInput in) + throws IOException, ClassNotFoundException { + super.readExternal(in); + } + } diff --git a/api/src/test/java/javax/jdo/identity/IntIdentityTest.java b/api/src/test/java/javax/jdo/identity/IntIdentityTest.java index 5d9d6a1d8..271531e21 100644 --- a/api/src/test/java/javax/jdo/identity/IntIdentityTest.java +++ b/api/src/test/java/javax/jdo/identity/IntIdentityTest.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -23,114 +23,117 @@ package javax.jdo.identity; import javax.jdo.JDONullIdentityException; + import javax.jdo.util.BatchTestRunner; -/** */ +/** + * + */ public class IntIdentityTest extends SingleFieldIdentityTest { + + /** Creates a new instance of IntIdentityTest */ + public IntIdentityTest() { + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + BatchTestRunner.run(IntIdentityTest.class); + } + + public void testConstructor() { + IntIdentity c1 = new IntIdentity(Object.class, (int)1); + IntIdentity c2 = new IntIdentity(Object.class, (int)1); + IntIdentity c3 = new IntIdentity(Object.class, (int)2); + assertEquals("Equal IntIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal IntIdentity instances compare equal", c1.equals(c3)); + } - /** Creates a new instance of IntIdentityTest */ - public IntIdentityTest() {} - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - BatchTestRunner.run(IntIdentityTest.class); - } - - public void testConstructor() { - IntIdentity c1 = new IntIdentity(Object.class, (int) 1); - IntIdentity c2 = new IntIdentity(Object.class, (int) 1); - IntIdentity c3 = new IntIdentity(Object.class, (int) 2); - assertEquals("Equal IntIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal IntIdentity instances compare equal", c1.equals(c3)); - } - - public void testIntegerConstructor() { - IntIdentity c1 = new IntIdentity(Object.class, (int) 1); - IntIdentity c2 = new IntIdentity(Object.class, Integer.valueOf((int) 1)); - IntIdentity c3 = new IntIdentity(Object.class, Integer.valueOf((int) 2)); - assertEquals("Equal intIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal IntIdentity instances compare equal", c1.equals(c3)); - } - - public void testToStringConstructor() { - IntIdentity c1 = new IntIdentity(Object.class, (int) 1); - IntIdentity c2 = new IntIdentity(Object.class, c1.toString()); - assertEquals("Equal IntIdentity instances compare not equal.", c1, c2); - } - - public void testStringConstructor() { - IntIdentity c1 = new IntIdentity(Object.class, (int) 1); - IntIdentity c2 = new IntIdentity(Object.class, "1"); - IntIdentity c3 = new IntIdentity(Object.class, "2"); - assertEquals("Equal IntIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal IntIdentity instances compare equal", c1.equals(c3)); - } - - public void testIllegalStringConstructor() { - try { - new IntIdentity(Object.class, "b"); - } catch (IllegalArgumentException iae) { - return; // good + public void testIntegerConstructor() { + IntIdentity c1 = new IntIdentity(Object.class, (int)1); + IntIdentity c2 = new IntIdentity(Object.class, Integer.valueOf((int)1)); + IntIdentity c3 = new IntIdentity(Object.class, Integer.valueOf((int)2)); + assertEquals ("Equal intIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal IntIdentity instances compare equal", c1.equals(c3)); } - fail("No exception caught for illegal String."); - } - public void testSerialized() { - IntIdentity c1 = new IntIdentity(Object.class, (int) 1); - IntIdentity c2 = new IntIdentity(Object.class, "1"); - IntIdentity c3 = new IntIdentity(Object.class, "2"); - Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); - Object sc1 = scis[0]; - Object sc2 = scis[1]; - Object sc3 = scis[2]; - assertEquals("Equal IntIdentity instances compare not equal.", c1, sc1); - assertEquals("Equal IntIdentity instances compare not equal.", c2, sc2); - assertEquals("Equal IntIdentity instances compare not equal.", sc1, c2); - assertEquals("Equal IntIdentity instances compare not equal.", sc2, c1); - assertFalse("Not equal InrIdentity instances compare equal.", c1.equals(sc3)); - assertFalse("Not equal IntIdentity instances compare equal.", sc1.equals(c3)); - assertFalse("Not equal IntIdentity instances compare equal.", sc1.equals(sc3)); - assertFalse("Not equal IntIdentity instances compare equal.", sc3.equals(sc1)); - } + public void testToStringConstructor() { + IntIdentity c1 = new IntIdentity(Object.class, (int)1); + IntIdentity c2 = new IntIdentity(Object.class, c1.toString()); + assertEquals ("Equal IntIdentity instances compare not equal.", c1, c2); + } - public void testGetKeyAsObjectPrimitive() { - IntIdentity c1 = new IntIdentity(Object.class, 1); - assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Integer.valueOf(1)); - } + public void testStringConstructor() { + IntIdentity c1 = new IntIdentity(Object.class, (int)1); + IntIdentity c2 = new IntIdentity(Object.class, "1"); + IntIdentity c3 = new IntIdentity(Object.class, "2"); + assertEquals ("Equal IntIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal IntIdentity instances compare equal", c1.equals(c3)); + } + + public void testIllegalStringConstructor() { + try { + new IntIdentity(Object.class, "b"); + } catch (IllegalArgumentException iae) { + return; // good + } + fail ("No exception caught for illegal String."); + } + + public void testSerialized() { + IntIdentity c1 = new IntIdentity(Object.class, (int)1); + IntIdentity c2 = new IntIdentity(Object.class, "1"); + IntIdentity c3 = new IntIdentity(Object.class, "2"); + Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); + Object sc1 = scis[0]; + Object sc2 = scis[1]; + Object sc3 = scis[2]; + assertEquals ("Equal IntIdentity instances compare not equal.", c1, sc1); + assertEquals ("Equal IntIdentity instances compare not equal.", c2, sc2); + assertEquals ("Equal IntIdentity instances compare not equal.", sc1, c2); + assertEquals ("Equal IntIdentity instances compare not equal.", sc2, c1); + assertFalse ("Not equal InrIdentity instances compare equal.", c1.equals(sc3)); + assertFalse ("Not equal IntIdentity instances compare equal.", sc1.equals(c3)); + assertFalse ("Not equal IntIdentity instances compare equal.", sc1.equals(sc3)); + assertFalse ("Not equal IntIdentity instances compare equal.", sc3.equals(sc1)); + } + public void testGetKeyAsObjectPrimitive() { + IntIdentity c1 = new IntIdentity(Object.class, 1); + assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Integer.valueOf(1)); + } - public void testGetKeyAsObject() { - IntIdentity c1 = new IntIdentity(Object.class, Integer.valueOf(1)); - assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Integer.valueOf(1)); - } + public void testGetKeyAsObject() { + IntIdentity c1 = new IntIdentity(Object.class, Integer.valueOf(1)); + assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Integer.valueOf(1)); + } - public void testBadConstructorNullIntegerParam() { - try { - new IntIdentity(Object.class, (Integer) null); - } catch (JDONullIdentityException ex) { - return; + public void testBadConstructorNullIntegerParam() { + try { + new IntIdentity(Object.class, (Integer)null); + } catch (JDONullIdentityException ex) { + return; + } + fail ("Failed to catch expected exception."); } - fail("Failed to catch expected exception."); - } - public void testBadConstructorNullStringParam() { - try { - new IntIdentity(Object.class, (String) null); - } catch (JDONullIdentityException ex) { - return; + public void testBadConstructorNullStringParam() { + try { + new IntIdentity(Object.class, (String)null); + } catch (JDONullIdentityException ex) { + return; + } + fail ("Failed to catch expected exception."); } - fail("Failed to catch expected exception."); - } - public void testCompareTo() { - IntIdentity c1 = new IntIdentity(Object.class, 1); - IntIdentity c2 = new IntIdentity(Object.class, 1); - IntIdentity c3 = new IntIdentity(Object.class, 2); - IntIdentity c4 = new IntIdentity(Class.class, 1); - assertEquals("Equal IntIdentity instances compare not equal.", 0, c1.compareTo(c2)); - assertTrue("Not equal IntIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0); - assertTrue("Not equal IntIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0); - assertTrue("Not equal IntIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0); - } + public void testCompareTo() { + IntIdentity c1 = new IntIdentity(Object.class, 1); + IntIdentity c2 = new IntIdentity(Object.class, 1); + IntIdentity c3 = new IntIdentity(Object.class, 2); + IntIdentity c4 = new IntIdentity(Class.class, 1); + assertEquals("Equal IntIdentity instances compare not equal.", 0, c1.compareTo(c2)); + assertTrue("Not equal IntIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0); + assertTrue("Not equal IntIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0); + assertTrue("Not equal IntIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0); + } } diff --git a/api/src/test/java/javax/jdo/identity/LongIdentityTest.java b/api/src/test/java/javax/jdo/identity/LongIdentityTest.java index 53f54f0e6..9f65b27d4 100644 --- a/api/src/test/java/javax/jdo/identity/LongIdentityTest.java +++ b/api/src/test/java/javax/jdo/identity/LongIdentityTest.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -23,122 +23,122 @@ package javax.jdo.identity; import javax.jdo.JDONullIdentityException; + import javax.jdo.util.BatchTestRunner; -/** */ +/** + * + */ public class LongIdentityTest extends SingleFieldIdentityTest { + + /** Creates a new instance of LongIdentityTest */ + public LongIdentityTest() { + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + BatchTestRunner.run(LongIdentityTest.class); + } + + public void testConstructor() { + LongIdentity c1 = new LongIdentity(Object.class, 1); + LongIdentity c2 = new LongIdentity(Object.class, 1); + LongIdentity c3 = new LongIdentity(Object.class, 2); + LongIdentity c4 = new LongIdentity(Object.class, 0x100000001L); + assertEquals("Equal LongIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal LongIdentity instances compare equal", c1.equals(c3)); + assertFalse ("Not equal LongIdentity instances compare equal", c4.equals(c1)); + } - /** Creates a new instance of LongIdentityTest */ - public LongIdentityTest() {} - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - BatchTestRunner.run(LongIdentityTest.class); - } - - public void testConstructor() { - LongIdentity c1 = new LongIdentity(Object.class, 1); - LongIdentity c2 = new LongIdentity(Object.class, 1); - LongIdentity c3 = new LongIdentity(Object.class, 2); - LongIdentity c4 = new LongIdentity(Object.class, 0x100000001L); - assertEquals("Equal LongIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal LongIdentity instances compare equal", c1.equals(c3)); - assertFalse("Not equal LongIdentity instances compare equal", c4.equals(c1)); - } - - public void testLongConstructor() { - LongIdentity c1 = new LongIdentity(Object.class, 1); - LongIdentity c2 = new LongIdentity(Object.class, Long.valueOf(1)); - LongIdentity c3 = new LongIdentity(Object.class, Long.valueOf(2)); - assertEquals("Equal LongIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal LongIdentity instances compare equal", c1.equals(c3)); - } - - public void testToStringConstructor() { - LongIdentity c1 = new LongIdentity(Object.class, Long.MAX_VALUE); - LongIdentity c2 = new LongIdentity(Object.class, c1.toString()); - assertEquals("Equal LongIdentity instances compare not equal.", c1, c2); - } - - public void testStringConstructor() { - LongIdentity c1 = new LongIdentity(Object.class, 1); - LongIdentity c2 = new LongIdentity(Object.class, "1"); - LongIdentity c3 = new LongIdentity(Object.class, "2"); - assertEquals("Equal LongIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal LongIdentity instances compare equal", c1.equals(c3)); - } - - public void testIllegalStringConstructor() { - try { - new LongIdentity(Object.class, "b"); - } catch (IllegalArgumentException iae) { - return; // good + public void testLongConstructor() { + LongIdentity c1 = new LongIdentity(Object.class, 1); + LongIdentity c2 = new LongIdentity(Object.class, Long.valueOf(1)); + LongIdentity c3 = new LongIdentity(Object.class, Long.valueOf(2)); + assertEquals ("Equal LongIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal LongIdentity instances compare equal", c1.equals(c3)); } - fail("No exception caught for illegal String."); - } - public void testSerialized() { - LongIdentity c1 = new LongIdentity(Object.class, 1); - LongIdentity c2 = new LongIdentity(Object.class, "1"); - LongIdentity c3 = new LongIdentity(Object.class, "2"); - Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); - Object sc1 = scis[0]; - Object sc2 = scis[1]; - Object sc3 = scis[2]; - assertEquals("Equal LongIdentity instances compare not equal.", c1, sc1); - assertEquals("Equal LongIdentity instances compare not equal.", c2, sc2); - assertEquals("Equal LongIdentity instances compare not equal.", sc1, c2); - assertEquals("Equal LongIdentity instances compare not equal.", sc2, c1); - assertFalse("Not equal LongIdentity instances compare equal.", c1.equals(sc3)); - assertFalse("Not equal LongIdentity instances compare equal.", sc1.equals(c3)); - assertFalse("Not equal LongIdentity instances compare equal.", sc1.equals(sc3)); - assertFalse("Not equal LongIdentity instances compare equal.", sc3.equals(sc1)); - } + public void testToStringConstructor() { + LongIdentity c1 = new LongIdentity(Object.class, Long.MAX_VALUE); + LongIdentity c2 = new LongIdentity(Object.class, c1.toString()); + assertEquals ("Equal LongIdentity instances compare not equal.", c1, c2); + } - public void testGetKeyAsObjectPrimitive() { - LongIdentity c1 = new LongIdentity(Object.class, 1L); - assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Long.valueOf(1L)); - } + public void testStringConstructor() { + LongIdentity c1 = new LongIdentity(Object.class, 1); + LongIdentity c2 = new LongIdentity(Object.class, "1"); + LongIdentity c3 = new LongIdentity(Object.class, "2"); + assertEquals ("Equal LongIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal LongIdentity instances compare equal", c1.equals(c3)); + } + + public void testIllegalStringConstructor() { + try { + new LongIdentity(Object.class, "b"); + } catch (IllegalArgumentException iae) { + return; // good + } + fail ("No exception caught for illegal String."); + } + + public void testSerialized() { + LongIdentity c1 = new LongIdentity(Object.class, 1); + LongIdentity c2 = new LongIdentity(Object.class, "1"); + LongIdentity c3 = new LongIdentity(Object.class, "2"); + Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); + Object sc1 = scis[0]; + Object sc2 = scis[1]; + Object sc3 = scis[2]; + assertEquals ("Equal LongIdentity instances compare not equal.", c1, sc1); + assertEquals ("Equal LongIdentity instances compare not equal.", c2, sc2); + assertEquals ("Equal LongIdentity instances compare not equal.", sc1, c2); + assertEquals ("Equal LongIdentity instances compare not equal.", sc2, c1); + assertFalse ("Not equal LongIdentity instances compare equal.", c1.equals(sc3)); + assertFalse ("Not equal LongIdentity instances compare equal.", sc1.equals(c3)); + assertFalse ("Not equal LongIdentity instances compare equal.", sc1.equals(sc3)); + assertFalse ("Not equal LongIdentity instances compare equal.", sc3.equals(sc1)); + } + + public void testGetKeyAsObjectPrimitive() { + LongIdentity c1 = new LongIdentity(Object.class, 1L); + assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Long.valueOf(1L)); + } - public void testGetKeyAsObject() { - LongIdentity c1 = new LongIdentity(Object.class, Long.valueOf(1L)); - assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Long.valueOf(1L)); - } + public void testGetKeyAsObject() { + LongIdentity c1 = new LongIdentity(Object.class, Long.valueOf(1L)); + assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Long.valueOf(1L)); + } - public void testBadConstructorNullShortParam() { - try { - new LongIdentity(Object.class, (Long) null); - } catch (JDONullIdentityException ex) { - return; + public void testBadConstructorNullShortParam() { + try { + new LongIdentity(Object.class, (Long)null); + } catch (JDONullIdentityException ex) { + return; + } + fail ("Failed to catch expected exception."); } - fail("Failed to catch expected exception."); - } - public void testBadConstructorNullStringParam() { - try { - new LongIdentity(Object.class, (String) null); - } catch (JDONullIdentityException ex) { - return; + public void testBadConstructorNullStringParam() { + try { + new LongIdentity(Object.class, (String)null); + } catch (JDONullIdentityException ex) { + return; + } + fail ("Failed to catch expected exception."); } - fail("Failed to catch expected exception."); - } - public void testCompareTo() { - LongIdentity c1 = new LongIdentity(Object.class, 1); - LongIdentity c2 = new LongIdentity(Object.class, 1); - LongIdentity c3 = new LongIdentity(Object.class, 2); - LongIdentity c4 = new LongIdentity(Class.class, 1); - LongIdentity c5 = new LongIdentity(Object.class, 0x100000001L); - assertEquals("Equal LongIdentity instances compare not equal.", 0, c1.compareTo(c2)); - assertTrue( - "Not equal LongIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0); - assertTrue( - "Not equal LongIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0); - assertTrue( - "Not equal LongIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0); - assertTrue( - "Not equal LongIdentity instances have wrong compareTo result", c5.compareTo(c1) > 0); - } + public void testCompareTo() { + LongIdentity c1 = new LongIdentity(Object.class, 1); + LongIdentity c2 = new LongIdentity(Object.class, 1); + LongIdentity c3 = new LongIdentity(Object.class, 2); + LongIdentity c4 = new LongIdentity(Class.class, 1); + LongIdentity c5 = new LongIdentity(Object.class, 0x100000001L); + assertEquals("Equal LongIdentity instances compare not equal.", 0, c1.compareTo(c2)); + assertTrue("Not equal LongIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0); + assertTrue("Not equal LongIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0); + assertTrue("Not equal LongIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0); + assertTrue("Not equal LongIdentity instances have wrong compareTo result", c5.compareTo(c1) > 0); + } } diff --git a/api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java b/api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java index bafa58000..af957726a 100644 --- a/api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java +++ b/api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -21,424 +21,430 @@ */ package javax.jdo.identity; -import java.io.Serializable; import java.lang.reflect.InvocationTargetException; + +import java.io.Serializable; + import java.math.BigDecimal; + +import javax.jdo.JDOFatalInternalException; +import javax.jdo.LegacyJava; import java.security.PrivilegedAction; -import java.text.DateFormat; + import java.text.SimpleDateFormat; +import java.text.DateFormat; + import java.util.Currency; import java.util.Date; import java.util.Locale; -import javax.jdo.JDOFatalInternalException; -import javax.jdo.JDONullIdentityException; + import javax.jdo.JDOUserException; -import javax.jdo.LegacyJava; +import javax.jdo.JDONullIdentityException; + import javax.jdo.spi.JDOImplHelper; + import javax.jdo.util.BatchTestRunner; -/** */ +/** + * + */ public class ObjectIdentityTest extends SingleFieldIdentityTest { - - /** The JDOImplHelper instance used for Date formatting. */ - private static JDOImplHelper helper = - (JDOImplHelper) - doPrivileged( - new PrivilegedAction() { - public JDOImplHelper run() { - return JDOImplHelper.getInstance(); + + /** The JDOImplHelper instance used for Date formatting. + */ + private static JDOImplHelper helper = (JDOImplHelper) + doPrivileged( + new PrivilegedAction () { + public JDOImplHelper run () { + return JDOImplHelper.getInstance(); } - }); - - @SuppressWarnings("unchecked") - private static T doPrivileged(PrivilegedAction privilegedAction) { - try { - return (T) LegacyJava.doPrivilegedAction.invoke(null, privilegedAction); - } catch (IllegalAccessException | InvocationTargetException e) { - if (e.getCause() instanceof RuntimeException) { - throw (RuntimeException) e.getCause(); - } - throw new JDOFatalInternalException(e.getMessage()); - } - } - - /** Creates a new instance of ObjectIdentityTest */ - public ObjectIdentityTest() {} - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - BatchTestRunner.run(ObjectIdentityTest.class); - } - - public void testConstructor() { - ObjectIdentity c1 = new ObjectIdentity(Object.class, new IdClass(1)); - ObjectIdentity c2 = new ObjectIdentity(Object.class, new IdClass(1)); - ObjectIdentity c3 = new ObjectIdentity(Object.class, new IdClass(2)); - assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal ObjectIdentity instances compare equal", c1.equals(c3)); - } - - public void testIntegerConstructor() { - ObjectIdentity c1 = new ObjectIdentity(Object.class, Integer.valueOf(1)); - ObjectIdentity c2 = new ObjectIdentity(Object.class, Integer.valueOf(1)); - ObjectIdentity c3 = new ObjectIdentity(Object.class, Integer.valueOf(2)); - assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal ObjectIdentity instances compare equal", c1.equals(c3)); - } - - public void testLongConstructor() { - ObjectIdentity c1 = new ObjectIdentity(Object.class, Long.valueOf(1)); - ObjectIdentity c2 = new ObjectIdentity(Object.class, Long.valueOf(1)); - ObjectIdentity c3 = new ObjectIdentity(Object.class, Long.valueOf(2)); - assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal ObjectIdentity instances compare equal", c1.equals(c3)); - } - - public void testDateConstructor() { - ObjectIdentity c1 = new ObjectIdentity(Object.class, new Date(1)); - ObjectIdentity c2 = new ObjectIdentity(Object.class, new Date(1)); - ObjectIdentity c3 = new ObjectIdentity(Object.class, new Date(2)); - assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal ObjectIdentity instances compare equal", c1.equals(c3)); - } - - public void testLocaleConstructor() { - ObjectIdentity c1 = new ObjectIdentity(Object.class, Locale.US); - ObjectIdentity c2 = new ObjectIdentity(Object.class, Locale.US); - ObjectIdentity c3 = new ObjectIdentity(Object.class, Locale.GERMANY); - assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal ObjectIdentity instances compare equal", c1.equals(c3)); - } - - public void testCurrencyConstructor() { - if (!isClassLoadable("java.util.Currency")) return; - ObjectIdentity c1 = new ObjectIdentity(Object.class, Currency.getInstance(Locale.US)); - ObjectIdentity c2 = new ObjectIdentity(Object.class, Currency.getInstance(Locale.US)); - ObjectIdentity c3 = new ObjectIdentity(Object.class, Currency.getInstance(Locale.GERMANY)); - assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal ObjectIdentity instances compare equal", c1.equals(c3)); - } - - public void testStringConstructor() { - ObjectIdentity c1 = - new ObjectIdentity(Object.class, "javax.jdo.identity.ObjectIdentityTest$IdClass:1"); - ObjectIdentity c2 = - new ObjectIdentity(Object.class, "javax.jdo.identity.ObjectIdentityTest$IdClass:1"); - ObjectIdentity c3 = - new ObjectIdentity(Object.class, "javax.jdo.identity.ObjectIdentityTest$IdClass:2"); - assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal ObjectIdentity instances compare equal", c1.equals(c3)); - } - - public void testToStringConstructor() { - ObjectIdentity c1 = new ObjectIdentity(Object.class, new IdClass(1)); - ObjectIdentity c2 = new ObjectIdentity(Object.class, c1.toString()); - assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2); - } - - public void testDateCompareTo() { - ObjectIdentity c1 = new ObjectIdentity(Object.class, new Date(1)); - ObjectIdentity c2 = new ObjectIdentity(Object.class, new Date(1)); - ObjectIdentity c3 = new ObjectIdentity(Object.class, new Date(2)); - ObjectIdentity c4 = new ObjectIdentity(Class.class, new Date(1)); - assertEquals("Equal ObjectIdentity instances compare not equal.", 0, c1.compareTo(c2)); - assertTrue( - "Not equal ObjectIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0); - assertTrue( - "Not equal ObjectIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0); - assertTrue( - "Not equal ObjectIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0); - } - - public void testBadStringConstructorNullClass() { - try { - new ObjectIdentity(null, "1"); - } catch (NullPointerException ex) { - return; - } - fail("Failed to catch expected exception."); - } - - public void testBadStringConstructorNullParam() { - try { - new ObjectIdentity(Object.class, null); - } catch (JDONullIdentityException ex) { - return; - } - fail("Failed to catch expected exception."); - } - - public void testBadStringConstructorTooShort() { - try { - new ObjectIdentity(Object.class, "xx"); - } catch (JDOUserException ex) { - return; - } - fail("Failed to catch expected exception."); - } - - public void testBadStringConstructorNoDelimiter() { - try { - new ObjectIdentity(Object.class, "xxxxxxxxx"); - } catch (JDOUserException ex) { - return; - } - fail("Failed to catch expected exception."); - } - - public void testBadStringConstructorBadClassName() { - try { - new ObjectIdentity(Object.class, "xx:yy"); - } catch (JDOUserException ex) { - validateNestedException(ex, ClassNotFoundException.class); - return; - } - fail("Failed to catch expected ClassNotFoundException."); - } - - public void testBadStringConstructorNoStringConstructor() { - try { - new ObjectIdentity( - Object.class, "javax.jdo.identity.ObjectIdentityTest$BadIdClassNoStringConstructor:yy"); - } catch (JDOUserException ex) { - validateNestedException(ex, NoSuchMethodException.class); - return; - } - fail("Failed to catch expected NoSuchMethodException."); - } - - public void testBadStringConstructorNoPublicStringConstructor() { - try { - new ObjectIdentity( - Object.class, - "javax.jdo.identity.ObjectIdentityTest$BadIdClassNoPublicStringConstructor:yy"); - } catch (JDOUserException ex) { - validateNestedException(ex, NoSuchMethodException.class); - return; - } - fail("Failed to catch expected NoSuchMethodException."); - } - - public void testBadStringConstructorIllegalArgument() { - try { - new ObjectIdentity(Object.class, "javax.jdo.identity.ObjectIdentityTest$IdClass:yy"); - } catch (JDOUserException ex) { - validateNestedException(ex, InvocationTargetException.class); - return; - } - fail("Failed to catch expected InvocationTargetException."); - } - - public void testStringDateConstructor() { - SimpleDateFormat usDateFormat = new SimpleDateFormat("MMM dd, yyyy hh:mm:ss a", Locale.US); - helper.registerDateFormat(usDateFormat); - new ObjectIdentity(Object.class, "java.util.Date:Jan 01, 1970 00:00:00 AM"); - helper.registerDateFormat(DateFormat.getDateTimeInstance()); - } - - public void testStringDefaultDateConstructor() { - DateFormat dateFormat = DateFormat.getDateTimeInstance(); - String rightNow = dateFormat.format(new Date()); - new ObjectIdentity(Object.class, "java.util.Date:" + rightNow); - } - - public void testBadStringDateConstructor() { - try { - new ObjectIdentity(Object.class, "java.util.Date:Jop 1, 1970 00:00:00"); - } catch (JDOUserException ex) { - return; - } - fail("Failed to catch expected Exception."); - } + } + ); + + @SuppressWarnings("unchecked") + private static T doPrivileged(PrivilegedAction privilegedAction) { + try { + return (T) LegacyJava.doPrivilegedAction.invoke(null, privilegedAction); + } catch (IllegalAccessException | InvocationTargetException e) { + if (e.getCause() instanceof RuntimeException) { + throw (RuntimeException) e.getCause(); + } + throw new JDOFatalInternalException(e.getMessage()); + } + } - public void testStringLocaleConstructorLanguage() { - if (!isClassLoadable("java.util.Currency")) return; - SingleFieldIdentity c1 = new ObjectIdentity(Object.class, "java.util.Locale:en"); - assertEquals(new Locale("en"), c1.getKeyAsObject()); - } + /** Creates a new instance of ObjectIdentityTest */ + public ObjectIdentityTest() { + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + BatchTestRunner.run(ObjectIdentityTest.class); + } + + public void testConstructor() { + ObjectIdentity c1 = new ObjectIdentity(Object.class, new IdClass(1)); + ObjectIdentity c2 = new ObjectIdentity(Object.class, new IdClass(1)); + ObjectIdentity c3 = new ObjectIdentity(Object.class, new IdClass(2)); + assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal ObjectIdentity instances compare equal", c1.equals(c3)); + } + + public void testIntegerConstructor() { + ObjectIdentity c1 = new ObjectIdentity(Object.class, Integer.valueOf(1)); + ObjectIdentity c2 = new ObjectIdentity(Object.class, Integer.valueOf(1)); + ObjectIdentity c3 = new ObjectIdentity(Object.class, Integer.valueOf(2)); + assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal ObjectIdentity instances compare equal", c1.equals(c3)); + } + + public void testLongConstructor() { + ObjectIdentity c1 = new ObjectIdentity(Object.class, Long.valueOf(1)); + ObjectIdentity c2 = new ObjectIdentity(Object.class, Long.valueOf(1)); + ObjectIdentity c3 = new ObjectIdentity(Object.class, Long.valueOf(2)); + assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal ObjectIdentity instances compare equal", c1.equals(c3)); + } + + public void testDateConstructor() { + ObjectIdentity c1 = new ObjectIdentity(Object.class, new Date(1)); + ObjectIdentity c2 = new ObjectIdentity(Object.class, new Date(1)); + ObjectIdentity c3 = new ObjectIdentity(Object.class, new Date(2)); + assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal ObjectIdentity instances compare equal", c1.equals(c3)); + } + + public void testLocaleConstructor() { + ObjectIdentity c1 = new ObjectIdentity(Object.class, Locale.US); + ObjectIdentity c2 = new ObjectIdentity(Object.class, Locale.US); + ObjectIdentity c3 = new ObjectIdentity(Object.class, Locale.GERMANY); + assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal ObjectIdentity instances compare equal", c1.equals(c3)); + } + + public void testCurrencyConstructor() { + if (!isClassLoadable("java.util.Currency")) return; + ObjectIdentity c1 = new ObjectIdentity(Object.class, + Currency.getInstance(Locale.US)); + ObjectIdentity c2 = new ObjectIdentity(Object.class, + Currency.getInstance(Locale.US)); + ObjectIdentity c3 = new ObjectIdentity(Object.class, + Currency.getInstance(Locale.GERMANY)); + assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal ObjectIdentity instances compare equal", c1.equals(c3)); + } + + public void testStringConstructor() { + ObjectIdentity c1 = new ObjectIdentity(Object.class, + "javax.jdo.identity.ObjectIdentityTest$IdClass:1"); + ObjectIdentity c2 = new ObjectIdentity(Object.class, + "javax.jdo.identity.ObjectIdentityTest$IdClass:1"); + ObjectIdentity c3 = new ObjectIdentity(Object.class, + "javax.jdo.identity.ObjectIdentityTest$IdClass:2"); + assertEquals("Equal ObjectIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal ObjectIdentity instances compare equal", c1.equals(c3)); + } + + public void testToStringConstructor() { + ObjectIdentity c1 = new ObjectIdentity(Object.class, new IdClass(1)); + ObjectIdentity c2 = new ObjectIdentity(Object.class, c1.toString()); + assertEquals ("Equal ObjectIdentity instances compare not equal.", c1, c2); + } - public void testStringLocaleConstructorCountry() { - SingleFieldIdentity c1 = new ObjectIdentity(Object.class, "java.util.Locale:_US"); - assertEquals(new Locale("", "US"), c1.getKeyAsObject()); - } + public void testDateCompareTo() { + ObjectIdentity c1 = new ObjectIdentity(Object.class, new Date(1)); + ObjectIdentity c2 = new ObjectIdentity(Object.class, new Date(1)); + ObjectIdentity c3 = new ObjectIdentity(Object.class, new Date(2)); + ObjectIdentity c4 = new ObjectIdentity(Class.class, new Date(1)); + assertEquals("Equal ObjectIdentity instances compare not equal.", 0, c1.compareTo(c2)); + assertTrue("Not equal ObjectIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0); + assertTrue("Not equal ObjectIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0); + assertTrue("Not equal ObjectIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0); + } - public void testStringLocaleConstructorLanguageCountry() { - SingleFieldIdentity c1 = new ObjectIdentity(Object.class, "java.util.Locale:en_US"); - assertEquals(new Locale("en", "US"), c1.getKeyAsObject()); - } + public void testBadStringConstructorNullClass() { + try { + new ObjectIdentity(null, "1"); + } catch (NullPointerException ex) { + return; + } + fail ("Failed to catch expected exception."); + } + + public void testBadStringConstructorNullParam() { + try { + new ObjectIdentity(Object.class, null); + } catch (JDONullIdentityException ex) { + return; + } + fail ("Failed to catch expected exception."); + } + + public void testBadStringConstructorTooShort() { + try { + new ObjectIdentity(Object.class, "xx"); + } catch (JDOUserException ex) { + return; + } + fail ("Failed to catch expected exception."); + } + + public void testBadStringConstructorNoDelimiter() { + try { + new ObjectIdentity(Object.class, "xxxxxxxxx"); + } catch (JDOUserException ex) { + return; + } + fail ("Failed to catch expected exception."); + } + + public void testBadStringConstructorBadClassName() { + try { + new ObjectIdentity(Object.class, "xx:yy"); + } catch (JDOUserException ex) { + validateNestedException(ex, ClassNotFoundException.class); + return; + } + fail ("Failed to catch expected ClassNotFoundException."); + } + + public void testBadStringConstructorNoStringConstructor() { + try { + new ObjectIdentity(Object.class, + "javax.jdo.identity.ObjectIdentityTest$BadIdClassNoStringConstructor:yy"); + } catch (JDOUserException ex) { + validateNestedException(ex, NoSuchMethodException.class); + return; + } + fail ("Failed to catch expected NoSuchMethodException."); + } + + public void testBadStringConstructorNoPublicStringConstructor() { + try { + new ObjectIdentity(Object.class, + "javax.jdo.identity.ObjectIdentityTest$BadIdClassNoPublicStringConstructor:yy"); + } catch (JDOUserException ex) { + validateNestedException(ex, NoSuchMethodException.class); + return; + } + fail ("Failed to catch expected NoSuchMethodException."); + } + + public void testBadStringConstructorIllegalArgument() { + try { + new ObjectIdentity(Object.class, + "javax.jdo.identity.ObjectIdentityTest$IdClass:yy"); + } catch (JDOUserException ex) { + validateNestedException(ex, InvocationTargetException.class); + return; + } + fail ("Failed to catch expected InvocationTargetException."); + } - public void testStringLocaleConstructorLanguageCountryVariant() { - SingleFieldIdentity c1 = new ObjectIdentity(Object.class, "java.util.Locale:en_US_MAC"); - assertEquals(new Locale("en", "US", "MAC"), c1.getKeyAsObject()); - } + public void testStringDateConstructor() { + SimpleDateFormat usDateFormat = new SimpleDateFormat + ("MMM dd, yyyy hh:mm:ss a", Locale.US); + helper.registerDateFormat(usDateFormat); + new ObjectIdentity(Object.class, "java.util.Date:Jan 01, 1970 00:00:00 AM"); + helper.registerDateFormat(DateFormat.getDateTimeInstance()); + } - public void testStringCurrencyConstructor() { - if (!isClassLoadable("java.util.Currency")) return; - new ObjectIdentity(Object.class, "java.util.Currency:USD"); - } + public void testStringDefaultDateConstructor() { + DateFormat dateFormat = DateFormat.getDateTimeInstance(); + String rightNow = dateFormat.format(new Date()); + new ObjectIdentity(Object.class, "java.util.Date:" + rightNow); + } - public void testBadStringCurrencyConstructor() { - if (!isClassLoadable("java.util.Currency")) return; - try { - new ObjectIdentity(Object.class, "java.util.Currency:NowhereInTheWorld"); - } catch (JDOUserException ex) { - validateNestedException(ex, IllegalArgumentException.class); - return; - } - fail("Failed to catch expected IllegalArgumentException."); - } + public void testBadStringDateConstructor() { + try { + new ObjectIdentity(Object.class, "java.util.Date:Jop 1, 1970 00:00:00"); + } catch (JDOUserException ex) { + return; + } + fail ("Failed to catch expected Exception."); + } - public void testSerializedIdClass() { - ObjectIdentity c1 = new ObjectIdentity(Object.class, new IdClass(1)); - ObjectIdentity c2 = new ObjectIdentity(Object.class, new IdClass(1)); - ObjectIdentity c3 = new ObjectIdentity(Object.class, new IdClass(2)); - Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); - Object sc1 = scis[0]; - Object sc2 = scis[1]; - Object sc3 = scis[2]; - assertEquals("Equal ObjectIdentity instances compare not equal.", c1, sc1); - assertEquals("Equal ObjectIdentity instances compare not equal.", c2, sc2); - assertEquals("Equal ObjectIdentity instances compare not equal.", sc1, c2); - assertEquals("Equal ObjectIdentity instances compare not equal.", sc2, c1); - assertFalse("Not equal ObjectIdentity instances compare equal.", c1.equals(sc3)); - assertFalse("Not equal ObjectIdentity instances compare equal.", sc1.equals(c3)); - assertFalse("Not equal ObjectIdentity instances compare equal.", sc1.equals(sc3)); - assertFalse("Not equal ObjectIdentity instances compare equal.", sc3.equals(sc1)); - } + public void testStringLocaleConstructorLanguage() { + if (!isClassLoadable("java.util.Currency")) return; + SingleFieldIdentity c1 = new ObjectIdentity(Object.class, + "java.util.Locale:en"); + assertEquals(new Locale("en"), c1.getKeyAsObject()); + } - public void testSerializedBigDecimal() { - ObjectIdentity c1 = new ObjectIdentity(Object.class, new BigDecimal("123456789.012")); - ObjectIdentity c2 = new ObjectIdentity(Object.class, new BigDecimal("123456789.012")); - ObjectIdentity c3 = new ObjectIdentity(Object.class, new BigDecimal("123456789.01")); - Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); - Object sc1 = scis[0]; - Object sc2 = scis[1]; - Object sc3 = scis[2]; - assertEquals("Equal ObjectIdentity instances compare not equal.", c1, sc1); - assertEquals("Equal ObjectIdentity instances compare not equal.", c2, sc2); - assertEquals("Equal ObjectIdentity instances compare not equal.", sc1, c2); - assertEquals("Equal ObjectIdentity instances compare not equal.", sc2, c1); - assertFalse("Not equal ObjectIdentity instances compare equal.", c1.equals(sc3)); - assertFalse("Not equal ObjectIdentity instances compare equal.", sc1.equals(c3)); - assertFalse("Not equal ObjectIdentity instances compare equal.", sc1.equals(sc3)); - assertFalse("Not equal ObjectIdentity instances compare equal.", sc3.equals(sc1)); - } + public void testStringLocaleConstructorCountry() { + SingleFieldIdentity c1 = new ObjectIdentity(Object.class, + "java.util.Locale:_US"); + assertEquals(new Locale("","US"), c1.getKeyAsObject()); + } - public void testSerializedCurrency() { - if (!isClassLoadable("java.util.Currency")) return; - ObjectIdentity c1 = new ObjectIdentity(Object.class, Currency.getInstance(Locale.US)); - ObjectIdentity c2 = new ObjectIdentity(Object.class, Currency.getInstance(Locale.US)); - ObjectIdentity c3 = new ObjectIdentity(Object.class, Currency.getInstance(Locale.GERMANY)); - Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); - Object sc1 = scis[0]; - Object sc2 = scis[1]; - Object sc3 = scis[2]; - assertEquals("Equal ObjectIdentity instances compare not equal.", c1, sc1); - assertEquals("Equal ObjectIdentity instances compare not equal.", c2, sc2); - assertEquals("Equal ObjectIdentity instances compare not equal.", sc1, c2); - assertEquals("Equal ObjectIdentity instances compare not equal.", sc2, c1); - assertFalse("Not equal ObjectIdentity instances compare equal.", c1.equals(sc3)); - assertFalse("Not equal ObjectIdentity instances compare equal.", sc1.equals(c3)); - assertFalse("Not equal ObjectIdentity instances compare equal.", sc1.equals(sc3)); - assertFalse("Not equal ObjectIdentity instances compare equal.", sc3.equals(sc1)); - } + public void testStringLocaleConstructorLanguageCountry() { + SingleFieldIdentity c1 = new ObjectIdentity(Object.class, + "java.util.Locale:en_US"); + assertEquals(new Locale("en","US"), c1.getKeyAsObject()); + } - public void testSerializedDate() { - ObjectIdentity c1 = new ObjectIdentity(Object.class, new Date(1)); - ObjectIdentity c2 = new ObjectIdentity(Object.class, "java.util.Date:1"); - ObjectIdentity c3 = new ObjectIdentity(Object.class, new Date(2)); - Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); - Object sc1 = scis[0]; - Object sc2 = scis[1]; - Object sc3 = scis[2]; - assertEquals("Equal ObjectIdentity instances compare not equal.", c1, sc1); - assertEquals("Equal ObjectIdentity instances compare not equal.", c2, sc2); - assertEquals("Equal ObjectIdentity instances compare not equal.", sc1, c2); - assertEquals("Equal ObjectIdentity instances compare not equal.", sc2, c1); - assertFalse("Not equal ObjectIdentity instances compare equal.", c1.equals(sc3)); - assertFalse("Not equal ObjectIdentity instances compare equal.", sc1.equals(c3)); - assertFalse("Not equal ObjectIdentity instances compare equal.", sc1.equals(sc3)); - assertFalse("Not equal ObjectIdentity instances compare equal.", sc3.equals(sc1)); - } + public void testStringLocaleConstructorLanguageCountryVariant() { + SingleFieldIdentity c1 = new ObjectIdentity(Object.class, + "java.util.Locale:en_US_MAC"); + assertEquals(new Locale("en","US","MAC"), c1.getKeyAsObject()); + } - public void testSerializedLocale() { - ObjectIdentity c1 = new ObjectIdentity(Object.class, Locale.US); - ObjectIdentity c2 = new ObjectIdentity(Object.class, Locale.US); - ObjectIdentity c3 = new ObjectIdentity(Object.class, Locale.GERMANY); - Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); - Object sc1 = scis[0]; - Object sc2 = scis[1]; - Object sc3 = scis[2]; - assertEquals("Equal ObjectIdentity instances compare not equal.", c1, sc1); - assertEquals("Equal ObjectIdentity instances compare not equal.", c2, sc2); - assertEquals("Equal ObjectIdentity instances compare not equal.", sc1, c2); - assertEquals("Equal ObjectIdentity instances compare not equal.", sc2, c1); - assertFalse("Not equal ObjectIdentity instances compare equal.", c1.equals(sc3)); - assertFalse("Not equal ObjectIdentity instances compare equal.", sc1.equals(c3)); - assertFalse("Not equal ObjectIdentity instances compare equal.", sc1.equals(sc3)); - assertFalse("Not equal ObjectIdentity instances compare equal.", sc3.equals(sc1)); - } + public void testStringCurrencyConstructor() { + if (!isClassLoadable("java.util.Currency")) return; + new ObjectIdentity(Object.class, "java.util.Currency:USD"); + } - public void testGetKeyAsObject() { - ObjectIdentity c1 = new ObjectIdentity(Object.class, new IdClass(1)); - assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), new IdClass(1)); - } + public void testBadStringCurrencyConstructor() { + if (!isClassLoadable("java.util.Currency")) return; + try { + new ObjectIdentity(Object.class, "java.util.Currency:NowhereInTheWorld"); + } catch (JDOUserException ex) { + validateNestedException(ex, IllegalArgumentException.class); + return; + } + fail ("Failed to catch expected IllegalArgumentException."); + } - private void validateNestedException(JDOUserException ex, Class expected) { - Throwable[] nesteds = ex.getNestedExceptions(); - if (nesteds == null || nesteds.length != 1) { - fail("Nested exception is null or length 0"); + public void testSerializedIdClass() { + ObjectIdentity c1 = new ObjectIdentity(Object.class, new IdClass(1)); + ObjectIdentity c2 = new ObjectIdentity(Object.class, new IdClass(1)); + ObjectIdentity c3 = new ObjectIdentity(Object.class, new IdClass(2)); + Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); + Object sc1 = scis[0]; + Object sc2 = scis[1]; + Object sc3 = scis[2]; + assertEquals ("Equal ObjectIdentity instances compare not equal.", c1, sc1); + assertEquals ("Equal ObjectIdentity instances compare not equal.", c2, sc2); + assertEquals ("Equal ObjectIdentity instances compare not equal.", sc1, c2); + assertEquals ("Equal ObjectIdentity instances compare not equal.", sc2, c1); + assertFalse ("Not equal ObjectIdentity instances compare equal.", c1.equals(sc3)); + assertFalse ("Not equal ObjectIdentity instances compare equal.", sc1.equals(c3)); + assertFalse ("Not equal ObjectIdentity instances compare equal.", sc1.equals(sc3)); + assertFalse ("Not equal ObjectIdentity instances compare equal.", sc3.equals(sc1)); } - Throwable nested = nesteds[0]; - if (nested != ex.getCause()) { - fail("Nested exception is not == getCause()"); + + public void testSerializedBigDecimal() { + ObjectIdentity c1 = new ObjectIdentity(Object.class, new BigDecimal("123456789.012")); + ObjectIdentity c2 = new ObjectIdentity(Object.class, new BigDecimal("123456789.012")); + ObjectIdentity c3 = new ObjectIdentity(Object.class, new BigDecimal("123456789.01")); + Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); + Object sc1 = scis[0]; + Object sc2 = scis[1]; + Object sc3 = scis[2]; + assertEquals ("Equal ObjectIdentity instances compare not equal.", c1, sc1); + assertEquals ("Equal ObjectIdentity instances compare not equal.", c2, sc2); + assertEquals ("Equal ObjectIdentity instances compare not equal.", sc1, c2); + assertEquals ("Equal ObjectIdentity instances compare not equal.", sc2, c1); + assertFalse ("Not equal ObjectIdentity instances compare equal.", c1.equals(sc3)); + assertFalse ("Not equal ObjectIdentity instances compare equal.", sc1.equals(c3)); + assertFalse ("Not equal ObjectIdentity instances compare equal.", sc1.equals(sc3)); + assertFalse ("Not equal ObjectIdentity instances compare equal.", sc3.equals(sc1)); } - if (!(expected.isAssignableFrom(nested.getClass()))) { - fail("Wrong nested exception. Expected " + expected.getName() + ", got " + nested.toString()); + + public void testSerializedCurrency() { + if (!isClassLoadable("java.util.Currency")) return; + ObjectIdentity c1 = new ObjectIdentity(Object.class, Currency.getInstance(Locale.US)); + ObjectIdentity c2 = new ObjectIdentity(Object.class, Currency.getInstance(Locale.US)); + ObjectIdentity c3 = new ObjectIdentity(Object.class, Currency.getInstance(Locale.GERMANY)); + Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); + Object sc1 = scis[0]; + Object sc2 = scis[1]; + Object sc3 = scis[2]; + assertEquals ("Equal ObjectIdentity instances compare not equal.", c1, sc1); + assertEquals ("Equal ObjectIdentity instances compare not equal.", c2, sc2); + assertEquals ("Equal ObjectIdentity instances compare not equal.", sc1, c2); + assertEquals ("Equal ObjectIdentity instances compare not equal.", sc2, c1); + assertFalse ("Not equal ObjectIdentity instances compare equal.", c1.equals(sc3)); + assertFalse ("Not equal ObjectIdentity instances compare equal.", sc1.equals(c3)); + assertFalse ("Not equal ObjectIdentity instances compare equal.", sc1.equals(sc3)); + assertFalse ("Not equal ObjectIdentity instances compare equal.", sc3.equals(sc1)); } - return; - } - - public static class IdClass implements Serializable { - private static final long serialVersionUID = 5718122068872969580L; - - public int value; - - public IdClass() { - value = 0; + + public void testSerializedDate() { + ObjectIdentity c1 = new ObjectIdentity(Object.class, new Date(1)); + ObjectIdentity c2 = new ObjectIdentity(Object.class, "java.util.Date:1"); + ObjectIdentity c3 = new ObjectIdentity(Object.class, new Date(2)); + Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); + Object sc1 = scis[0]; + Object sc2 = scis[1]; + Object sc3 = scis[2]; + assertEquals ("Equal ObjectIdentity instances compare not equal.", c1, sc1); + assertEquals ("Equal ObjectIdentity instances compare not equal.", c2, sc2); + assertEquals ("Equal ObjectIdentity instances compare not equal.", sc1, c2); + assertEquals ("Equal ObjectIdentity instances compare not equal.", sc2, c1); + assertFalse ("Not equal ObjectIdentity instances compare equal.", c1.equals(sc3)); + assertFalse ("Not equal ObjectIdentity instances compare equal.", sc1.equals(c3)); + assertFalse ("Not equal ObjectIdentity instances compare equal.", sc1.equals(sc3)); + assertFalse ("Not equal ObjectIdentity instances compare equal.", sc3.equals(sc1)); } - - public IdClass(int value) { - this.value = value; + + public void testSerializedLocale() { + ObjectIdentity c1 = new ObjectIdentity(Object.class, Locale.US); + ObjectIdentity c2 = new ObjectIdentity(Object.class, Locale.US); + ObjectIdentity c3 = new ObjectIdentity(Object.class, Locale.GERMANY); + Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); + Object sc1 = scis[0]; + Object sc2 = scis[1]; + Object sc3 = scis[2]; + assertEquals ("Equal ObjectIdentity instances compare not equal.", c1, sc1); + assertEquals ("Equal ObjectIdentity instances compare not equal.", c2, sc2); + assertEquals ("Equal ObjectIdentity instances compare not equal.", sc1, c2); + assertEquals ("Equal ObjectIdentity instances compare not equal.", sc2, c1); + assertFalse ("Not equal ObjectIdentity instances compare equal.", c1.equals(sc3)); + assertFalse ("Not equal ObjectIdentity instances compare equal.", sc1.equals(c3)); + assertFalse ("Not equal ObjectIdentity instances compare equal.", sc1.equals(sc3)); + assertFalse ("Not equal ObjectIdentity instances compare equal.", sc3.equals(sc1)); } - - public IdClass(String str) { - this.value = Integer.parseInt(str); + + public void testGetKeyAsObject() { + ObjectIdentity c1 = new ObjectIdentity(Object.class, new IdClass(1)); + assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), new IdClass(1)); } - public String toString() { - return Integer.toString(value); + private void validateNestedException(JDOUserException ex, Class expected) { + Throwable[] nesteds = ex.getNestedExceptions(); + if (nesteds == null || nesteds.length != 1) { + fail ("Nested exception is null or length 0"); + } + Throwable nested = nesteds[0]; + if (nested != ex.getCause()) { + fail ("Nested exception is not == getCause()"); + } + if (!(expected.isAssignableFrom(nested.getClass()))) { + fail ("Wrong nested exception. Expected " + + expected.getName() + ", got " + + nested.toString()); + } + return; } - public int hashCode() { - return value; + public static class IdClass implements Serializable { + private static final long serialVersionUID = 5718122068872969580L; + + public int value; + public IdClass() {value = 0;} + public IdClass(int value) {this.value = value;} + public IdClass(String str) {this.value = Integer.parseInt(str);} + public String toString() {return Integer.toString(value);} + public int hashCode() { + return value; + } + public boolean equals (Object obj) { + if (this == obj) { + return true; + } else { + IdClass other = (IdClass) obj; + return value == other.value; + } + } + } + + public static class BadIdClassNoStringConstructor { + } + + public static class BadIdClassNoPublicStringConstructor { + private BadIdClassNoPublicStringConstructor(String str) {} } - - public boolean equals(Object obj) { - if (this == obj) { - return true; - } else { - IdClass other = (IdClass) obj; - return value == other.value; - } - } - } - - public static class BadIdClassNoStringConstructor {} - - public static class BadIdClassNoPublicStringConstructor { - private BadIdClassNoPublicStringConstructor(String str) {} - } } diff --git a/api/src/test/java/javax/jdo/identity/ShortIdentityTest.java b/api/src/test/java/javax/jdo/identity/ShortIdentityTest.java index 2fac39e25..65761074c 100644 --- a/api/src/test/java/javax/jdo/identity/ShortIdentityTest.java +++ b/api/src/test/java/javax/jdo/identity/ShortIdentityTest.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -23,117 +23,117 @@ package javax.jdo.identity; import javax.jdo.JDONullIdentityException; + import javax.jdo.util.BatchTestRunner; -/** */ +/** + * + */ public class ShortIdentityTest extends SingleFieldIdentityTest { + + /** Creates a new instance of ShortIdentityTest */ + public ShortIdentityTest() { + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + BatchTestRunner.run(ShortIdentityTest.class); + } + + public void testConstructor() { + ShortIdentity c1 = new ShortIdentity(Object.class, (short)1); + ShortIdentity c2 = new ShortIdentity(Object.class, (short)1); + ShortIdentity c3 = new ShortIdentity(Object.class, (short)2); + assertEquals("Equal ShortIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal ShortIdentity instances compare equal", c1.equals(c3)); + } - /** Creates a new instance of ShortIdentityTest */ - public ShortIdentityTest() {} - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - BatchTestRunner.run(ShortIdentityTest.class); - } - - public void testConstructor() { - ShortIdentity c1 = new ShortIdentity(Object.class, (short) 1); - ShortIdentity c2 = new ShortIdentity(Object.class, (short) 1); - ShortIdentity c3 = new ShortIdentity(Object.class, (short) 2); - assertEquals("Equal ShortIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal ShortIdentity instances compare equal", c1.equals(c3)); - } - - public void testShortConstructor() { - ShortIdentity c1 = new ShortIdentity(Object.class, (short) 1); - ShortIdentity c2 = new ShortIdentity(Object.class, Short.valueOf((short) 1)); - ShortIdentity c3 = new ShortIdentity(Object.class, Short.valueOf((short) 2)); - assertEquals("Equal ShortIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal ShortIdentity instances compare equal", c1.equals(c3)); - } - - public void testToStringConstructor() { - ShortIdentity c1 = new ShortIdentity(Object.class, Short.MAX_VALUE); - ShortIdentity c2 = new ShortIdentity(Object.class, c1.toString()); - assertEquals("Equal ShortIdentity instances compare not equal.", c1, c2); - } - - public void testStringConstructor() { - ShortIdentity c1 = new ShortIdentity(Object.class, (short) 1); - ShortIdentity c2 = new ShortIdentity(Object.class, "1"); - ShortIdentity c3 = new ShortIdentity(Object.class, "2"); - assertEquals("Equal ShortIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal ShortIdentity instances compare equal", c1.equals(c3)); - } - - public void testIllegalStringConstructor() { - try { - new ShortIdentity(Object.class, "b"); - } catch (IllegalArgumentException iae) { - return; // good + public void testShortConstructor() { + ShortIdentity c1 = new ShortIdentity(Object.class, (short)1); + ShortIdentity c2 = new ShortIdentity(Object.class, Short.valueOf((short)1)); + ShortIdentity c3 = new ShortIdentity(Object.class, Short.valueOf((short)2)); + assertEquals ("Equal ShortIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal ShortIdentity instances compare equal", c1.equals(c3)); } - fail("No exception caught for illegal String."); - } - public void testSerialized() { - ShortIdentity c1 = new ShortIdentity(Object.class, (short) 1); - ShortIdentity c2 = new ShortIdentity(Object.class, "1"); - ShortIdentity c3 = new ShortIdentity(Object.class, "2"); - Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); - Object sc1 = scis[0]; - Object sc2 = scis[1]; - Object sc3 = scis[2]; - assertEquals("Equal ShortIdentity instances compare not equal.", c1, sc1); - assertEquals("Equal ShortIdentity instances compare not equal.", c2, sc2); - assertEquals("Equal ShortIdentity instances compare not equal.", sc1, c2); - assertEquals("Equal ShortIdentity instances compare not equal.", sc2, c1); - assertFalse("Not equal ShortIdentity instances compare equal.", c1.equals(sc3)); - assertFalse("Not equal ShortIdentity instances compare equal.", sc1.equals(c3)); - assertFalse("Not equal ShortIdentity instances compare equal.", sc1.equals(sc3)); - assertFalse("Not equal ShortIdentity instances compare equal.", sc3.equals(sc1)); - } + public void testToStringConstructor() { + ShortIdentity c1 = new ShortIdentity(Object.class, Short.MAX_VALUE); + ShortIdentity c2 = new ShortIdentity(Object.class, c1.toString()); + assertEquals ("Equal ShortIdentity instances compare not equal.", c1, c2); + } - public void testGetKeyAsObjectPrimitive() { - ShortIdentity c1 = new ShortIdentity(Object.class, (short) 1); - assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Short.valueOf((short) 1)); - } + public void testStringConstructor() { + ShortIdentity c1 = new ShortIdentity(Object.class, (short)1); + ShortIdentity c2 = new ShortIdentity(Object.class, "1"); + ShortIdentity c3 = new ShortIdentity(Object.class, "2"); + assertEquals ("Equal ShortIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal ShortIdentity instances compare equal", c1.equals(c3)); + } + + public void testIllegalStringConstructor() { + try { + new ShortIdentity(Object.class, "b"); + } catch (IllegalArgumentException iae) { + return; // good + } + fail ("No exception caught for illegal String."); + } + + public void testSerialized() { + ShortIdentity c1 = new ShortIdentity(Object.class, (short)1); + ShortIdentity c2 = new ShortIdentity(Object.class, "1"); + ShortIdentity c3 = new ShortIdentity(Object.class, "2"); + Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); + Object sc1 = scis[0]; + Object sc2 = scis[1]; + Object sc3 = scis[2]; + assertEquals ("Equal ShortIdentity instances compare not equal.", c1, sc1); + assertEquals ("Equal ShortIdentity instances compare not equal.", c2, sc2); + assertEquals ("Equal ShortIdentity instances compare not equal.", sc1, c2); + assertEquals ("Equal ShortIdentity instances compare not equal.", sc2, c1); + assertFalse ("Not equal ShortIdentity instances compare equal.", c1.equals(sc3)); + assertFalse ("Not equal ShortIdentity instances compare equal.", sc1.equals(c3)); + assertFalse ("Not equal ShortIdentity instances compare equal.", sc1.equals(sc3)); + assertFalse ("Not equal ShortIdentity instances compare equal.", sc3.equals(sc1)); + } + public void testGetKeyAsObjectPrimitive() { + ShortIdentity c1 = new ShortIdentity(Object.class, (short)1); + assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Short.valueOf((short)1)); + } - public void testGetKeyAsObject() { - ShortIdentity c1 = new ShortIdentity(Object.class, Short.valueOf((short) 1)); - assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Short.valueOf((short) 1)); - } + public void testGetKeyAsObject() { + ShortIdentity c1 = new ShortIdentity(Object.class, Short.valueOf((short)1)); + assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), Short.valueOf((short)1)); + } - public void testBadConstructorNullShortParam() { - try { - new ShortIdentity(Object.class, (Short) null); - } catch (JDONullIdentityException ex) { - return; + public void testBadConstructorNullShortParam() { + try { + new ShortIdentity(Object.class, (Short)null); + } catch (JDONullIdentityException ex) { + return; + } + fail ("Failed to catch expected exception."); } - fail("Failed to catch expected exception."); - } - public void testBadConstructorNullStringParam() { - try { - new ShortIdentity(Object.class, (String) null); - } catch (JDONullIdentityException ex) { - return; + public void testBadConstructorNullStringParam() { + try { + new ShortIdentity(Object.class, (String)null); + } catch (JDONullIdentityException ex) { + return; + } + fail ("Failed to catch expected exception."); } - fail("Failed to catch expected exception."); - } - public void testCompareTo() { - ShortIdentity c1 = new ShortIdentity(Object.class, (short) 1); - ShortIdentity c2 = new ShortIdentity(Object.class, (short) 1); - ShortIdentity c3 = new ShortIdentity(Object.class, (short) 2); - ShortIdentity c4 = new ShortIdentity(Class.class, (short) 1); - assertEquals("Equal ShortIdentity instances compare not equal.", 0, c1.compareTo(c2)); - assertTrue( - "Not equal ShortIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0); - assertTrue( - "Not equal ShortIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0); - assertTrue( - "Not equal ShortIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0); - } + public void testCompareTo() { + ShortIdentity c1 = new ShortIdentity(Object.class, (short)1); + ShortIdentity c2 = new ShortIdentity(Object.class, (short)1); + ShortIdentity c3 = new ShortIdentity(Object.class, (short)2); + ShortIdentity c4 = new ShortIdentity(Class.class, (short)1); + assertEquals("Equal ShortIdentity instances compare not equal.", 0, c1.compareTo(c2)); + assertTrue("Not equal ShortIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0); + assertTrue("Not equal ShortIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0); + assertTrue("Not equal ShortIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0); + } } diff --git a/api/src/test/java/javax/jdo/identity/SingleFieldIdentityTest.java b/api/src/test/java/javax/jdo/identity/SingleFieldIdentityTest.java index cc2f6e853..1dc3a1e42 100644 --- a/api/src/test/java/javax/jdo/identity/SingleFieldIdentityTest.java +++ b/api/src/test/java/javax/jdo/identity/SingleFieldIdentityTest.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -26,74 +26,82 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; + import javax.jdo.util.AbstractTest; import javax.jdo.util.BatchTestRunner; -/** */ +/** + * + */ public class SingleFieldIdentityTest extends AbstractTest { + + ConcreteTestIdentity cti1; + ConcreteTestIdentity cti2; + ConcreteTestIdentity cti3; + + Object scti1; + Object scti2; + Object scti3; - ConcreteTestIdentity cti1; - ConcreteTestIdentity cti2; - ConcreteTestIdentity cti3; - - Object scti1; - Object scti2; - Object scti3; - - /** Creates a new instance of SingleFieldIdentityTest */ - public SingleFieldIdentityTest() {} - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - BatchTestRunner.run(SingleFieldIdentityTest.class); - } - - public void testConstructor() { - cti1 = new ConcreteTestIdentity(Object.class); - cti2 = new ConcreteTestIdentity(Object.class); - cti3 = new ConcreteTestIdentity(Class.class); - - assertEquals("Equal identity instances compare not equal.", cti1, cti2); - if (cti1.equals(cti3)) fail("Not equal identity instances compare equal."); - } - - public void testSerialized() { + /** Creates a new instance of SingleFieldIdentityTest */ + public SingleFieldIdentityTest() { + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + BatchTestRunner.run(SingleFieldIdentityTest.class); + } + + public void testConstructor() { cti1 = new ConcreteTestIdentity(Object.class); cti2 = new ConcreteTestIdentity(Object.class); cti3 = new ConcreteTestIdentity(Class.class); - Object[] sctis = writeReadSerialized(new Object[] {cti1, cti2, cti3}); - scti1 = sctis[0]; - scti2 = sctis[1]; - scti3 = sctis[2]; - assertEquals("Deserialized instance compare not equal.", cti1, scti1); - assertEquals("Deserialized instance compare not equal.", cti2, scti2); - assertEquals("Deserialized instance compare not equal.", cti3, scti3); - assertEquals("Deserialized instance compare not equal.", scti1, cti1); - assertEquals("Deserialized instance compare not equal.", scti2, cti2); - assertEquals("Deserialized instance compare not equal.", scti3, cti3); - if (scti1.equals(scti3)) fail("Not equal identity instances compare equal."); - } - - protected Object[] writeReadSerialized(Object[] in) { - int length = in.length; - Object[] result = new Object[length]; - try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(baos); - for (int i = 0; i < length; ++i) { - oos.writeObject(in[i]); - } - byte[] ba = baos.toByteArray(); - ByteArrayInputStream bais = new ByteArrayInputStream(ba); - ObjectInputStream ois = new ObjectInputStream(bais); - for (int i = 0; i < length; ++i) { - result[i] = ois.readObject(); - } - } catch (Exception e) { - fail(e.toString()); + + assertEquals ("Equal identity instances compare not equal.", cti1, cti2); + if (cti1.equals(cti3)) + fail ("Not equal identity instances compare equal."); + } + + public void testSerialized() { + cti1 = new ConcreteTestIdentity(Object.class); + cti2 = new ConcreteTestIdentity(Object.class); + cti3 = new ConcreteTestIdentity(Class.class); + Object[] sctis = writeReadSerialized(new Object[]{cti1, cti2, cti3}); + scti1 = sctis[0]; + scti2 = sctis[1]; + scti3 = sctis[2]; + assertEquals ("Deserialized instance compare not equal.", cti1, scti1); + assertEquals ("Deserialized instance compare not equal.", cti2, scti2); + assertEquals ("Deserialized instance compare not equal.", cti3, scti3); + assertEquals ("Deserialized instance compare not equal.", scti1, cti1); + assertEquals ("Deserialized instance compare not equal.", scti2, cti2); + assertEquals ("Deserialized instance compare not equal.", scti3, cti3); + if (scti1.equals(scti3)) + fail ("Not equal identity instances compare equal."); + + } + + protected Object[] writeReadSerialized(Object[] in) { + int length = in.length; + Object[] result = new Object[length]; + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + for (int i = 0; i < length; ++i) { + oos.writeObject(in[i]); + } + byte[] ba = baos.toByteArray(); + ByteArrayInputStream bais = new ByteArrayInputStream(ba); + ObjectInputStream ois = new ObjectInputStream(bais); + for (int i = 0; i < length; ++i) { + result[i] = ois.readObject(); + } + } catch (Exception e) { + fail(e.toString()); + } + return result; } - return result; - } + } diff --git a/api/src/test/java/javax/jdo/identity/StringIdentityTest.java b/api/src/test/java/javax/jdo/identity/StringIdentityTest.java index cac6051b6..3670d83f9 100644 --- a/api/src/test/java/javax/jdo/identity/StringIdentityTest.java +++ b/api/src/test/java/javax/jdo/identity/StringIdentityTest.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -23,78 +23,79 @@ package javax.jdo.identity; import javax.jdo.JDONullIdentityException; + import javax.jdo.util.BatchTestRunner; -/** */ +/** + * + */ public class StringIdentityTest extends SingleFieldIdentityTest { + + /** Creates a new instance of StringIdentityTest */ + public StringIdentityTest() { + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + BatchTestRunner.run(StringIdentityTest.class); + } + + public void testConstructor() { + StringIdentity c1 = new StringIdentity(Object.class, "1"); + StringIdentity c2 = new StringIdentity(Object.class, "1"); + StringIdentity c3 = new StringIdentity(Object.class, "2"); + assertEquals("Equal StringIdentity instances compare not equal.", c1, c2); + assertFalse ("Not equal StringIdentity instances compare equal", c1.equals(c3)); + } + + public void testToStringConstructor() { + StringIdentity c1 = new StringIdentity(Object.class, "Now who's talking!"); + StringIdentity c2 = new StringIdentity(Object.class, c1.toString()); + assertEquals ("Equal StringIdentity instances compare not equal.", c1, c2); + } - /** Creates a new instance of StringIdentityTest */ - public StringIdentityTest() {} - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - BatchTestRunner.run(StringIdentityTest.class); - } - - public void testConstructor() { - StringIdentity c1 = new StringIdentity(Object.class, "1"); - StringIdentity c2 = new StringIdentity(Object.class, "1"); - StringIdentity c3 = new StringIdentity(Object.class, "2"); - assertEquals("Equal StringIdentity instances compare not equal.", c1, c2); - assertFalse("Not equal StringIdentity instances compare equal", c1.equals(c3)); - } - - public void testToStringConstructor() { - StringIdentity c1 = new StringIdentity(Object.class, "Now who's talking!"); - StringIdentity c2 = new StringIdentity(Object.class, c1.toString()); - assertEquals("Equal StringIdentity instances compare not equal.", c1, c2); - } - - public void testSerialized() { - StringIdentity c1 = new StringIdentity(Object.class, "1"); - StringIdentity c2 = new StringIdentity(Object.class, "1"); - StringIdentity c3 = new StringIdentity(Object.class, "2"); - Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); - Object sc1 = scis[0]; - Object sc2 = scis[1]; - Object sc3 = scis[2]; - assertEquals("Equal StringIdentity instances compare not equal.", c1, sc1); - assertEquals("Equal StringIdentity instances compare not equal.", c2, sc2); - assertEquals("Equal StringIdentity instances compare not equal.", sc1, c2); - assertEquals("Equal StringIdentity instances compare not equal.", sc2, c1); - assertFalse("Not equal StringIdentity instances compare equal.", c1.equals(sc3)); - assertFalse("Not equal StringIdentity instances compare equal.", sc1.equals(c3)); - assertFalse("Not equal StringIdentity instances compare equal.", sc1.equals(sc3)); - assertFalse("Not equal StringIdentity instances compare equal.", sc3.equals(sc1)); - } + public void testSerialized() { + StringIdentity c1 = new StringIdentity(Object.class, "1"); + StringIdentity c2 = new StringIdentity(Object.class, "1"); + StringIdentity c3 = new StringIdentity(Object.class, "2"); + Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3}); + Object sc1 = scis[0]; + Object sc2 = scis[1]; + Object sc3 = scis[2]; + assertEquals ("Equal StringIdentity instances compare not equal.", c1, sc1); + assertEquals ("Equal StringIdentity instances compare not equal.", c2, sc2); + assertEquals ("Equal StringIdentity instances compare not equal.", sc1, c2); + assertEquals ("Equal StringIdentity instances compare not equal.", sc2, c1); + assertFalse ("Not equal StringIdentity instances compare equal.", c1.equals(sc3)); + assertFalse ("Not equal StringIdentity instances compare equal.", sc1.equals(c3)); + assertFalse ("Not equal StringIdentity instances compare equal.", sc1.equals(sc3)); + assertFalse ("Not equal StringIdentity instances compare equal.", sc3.equals(sc1)); + } - public void testGetKeyAsObject() { - StringIdentity c1 = new StringIdentity(Object.class, "1"); - assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), "1"); - } + public void testGetKeyAsObject() { + StringIdentity c1 = new StringIdentity(Object.class, "1"); + assertEquals("keyAsObject doesn't match.", c1.getKeyAsObject(), "1"); + } - public void testBadConstructorNullParam() { - try { - new StringIdentity(Object.class, null); - } catch (JDONullIdentityException ex) { - return; + public void testBadConstructorNullParam() { + try { + new StringIdentity(Object.class, null); + } catch (JDONullIdentityException ex) { + return; + } + fail ("Failed to catch expected exception."); } - fail("Failed to catch expected exception."); - } - public void testCompareTo() { - StringIdentity c1 = new StringIdentity(Object.class, "1"); - StringIdentity c2 = new StringIdentity(Object.class, "1"); - StringIdentity c3 = new StringIdentity(Object.class, "2"); - StringIdentity c4 = new StringIdentity(Class.class, "1"); - assertEquals("Equal StringIdentity instances compare not equal.", 0, c1.compareTo(c2)); - assertTrue( - "Not equal StringIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0); - assertTrue( - "Not equal StringIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0); - assertTrue( - "Not equal StringIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0); - } + public void testCompareTo() { + StringIdentity c1 = new StringIdentity(Object.class, "1"); + StringIdentity c2 = new StringIdentity(Object.class, "1"); + StringIdentity c3 = new StringIdentity(Object.class, "2"); + StringIdentity c4 = new StringIdentity(Class.class, "1"); + assertEquals("Equal StringIdentity instances compare not equal.", 0, c1.compareTo(c2)); + assertTrue("Not equal StringIdentity instances have wrong compareTo result", c1.compareTo(c3) < 0); + assertTrue("Not equal StringIdentity instances have wrong compareTo result", c3.compareTo(c1) > 0); + assertTrue("Not equal StringIdentity instances have wrong compareTo result", c1.compareTo(c4) > 0); + } } diff --git a/api/src/test/java/javax/jdo/listener/InstanceLifecycleEventTest.java b/api/src/test/java/javax/jdo/listener/InstanceLifecycleEventTest.java index dfe6b6b01..81f43f572 100644 --- a/api/src/test/java/javax/jdo/listener/InstanceLifecycleEventTest.java +++ b/api/src/test/java/javax/jdo/listener/InstanceLifecycleEventTest.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -26,99 +26,106 @@ import javax.jdo.util.BatchTestRunner; /** - * Tests that instances of InstanceLifecycleEvent can be created and that the source, type, and - * target instances are correct. + * Tests that instances of InstanceLifecycleEvent can be created and + * that the source, type, and target instances are correct. */ public class InstanceLifecycleEventTest extends AbstractTest { - - Object created = new Object(); - Object loaded = new Object(); - Object stored = new Object(); - Object cleared = new Object(); - Object deleted = new Object(); - Object dirtied = new Object(); - Object attached = new Object(); - Object attachTarget = new Object(); - Object detached = new Object(); - Object detachTarget = new Object(); - - /** Creates a new instance of SingleFieldIdentityTest */ - public InstanceLifecycleEventTest() {} - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - BatchTestRunner.run(InstanceLifecycleEventTest.class); - } - - public void testConstructorCreateEvent() { - InstanceLifecycleEvent e = new InstanceLifecycleEvent(created, InstanceLifecycleEvent.CREATE); - assertSame("Create source differs.", created, e.getSource()); - assertEquals("Create type differs.", InstanceLifecycleEvent.CREATE, e.getEventType()); - } - - public void testConstructorLoadEvent() { - InstanceLifecycleEvent e = new InstanceLifecycleEvent(loaded, InstanceLifecycleEvent.LOAD); - assertSame("Load source differs.", loaded, e.getSource()); - assertEquals("Load type differs.", InstanceLifecycleEvent.LOAD, e.getEventType()); - } - - public void testConstructorStoreEvent() { - InstanceLifecycleEvent e = new InstanceLifecycleEvent(stored, InstanceLifecycleEvent.STORE); - assertSame("Store source differs.", stored, e.getSource()); - assertEquals("Store type differs.", InstanceLifecycleEvent.STORE, e.getEventType()); - } - - public void testConstructorClearEvent() { - InstanceLifecycleEvent e = new InstanceLifecycleEvent(cleared, InstanceLifecycleEvent.CLEAR); - assertSame("Clear source differs.", cleared, e.getSource()); - assertEquals("Clear type differs.", InstanceLifecycleEvent.CLEAR, e.getEventType()); - } - - public void testConstructorDeleteEvent() { - InstanceLifecycleEvent e = new InstanceLifecycleEvent(deleted, InstanceLifecycleEvent.DELETE); - assertSame("Delete source differs.", deleted, e.getSource()); - assertEquals("Delete type differs.", InstanceLifecycleEvent.DELETE, e.getEventType()); - } - - public void testConstructorDirtyEvent() { - InstanceLifecycleEvent e = new InstanceLifecycleEvent(dirtied, InstanceLifecycleEvent.DIRTY); - assertSame("Dirty source differs.", dirtied, e.getSource()); - assertEquals("Dirty type differs.", InstanceLifecycleEvent.DIRTY, e.getEventType()); - } - - public void testConstructorDetachEvent() { - InstanceLifecycleEvent e = - new InstanceLifecycleEvent(detached, InstanceLifecycleEvent.DETACH, detachTarget); - assertSame("Detach source differs.", detached, e.getSource()); - assertEquals("Detach type differs.", InstanceLifecycleEvent.DETACH, e.getEventType()); - assertSame("Detach target differs.", detachTarget, e.getTarget()); - } - - public void testConstructorAttachEvent() { - InstanceLifecycleEvent e = - new InstanceLifecycleEvent(attached, InstanceLifecycleEvent.ATTACH, attachTarget); - assertSame("Attach source differs.", attached, e.getSource()); - assertEquals("Attach type differs.", InstanceLifecycleEvent.ATTACH, e.getEventType()); - assertSame("Attach target differs.", attachTarget, e.getTarget()); - } - - public void testIllegalConstructorTooSmall() { - try { - new InstanceLifecycleEvent(new Object(), -1); - } catch (IllegalArgumentException e) { - return; // good catch + + Object created = new Object(); + Object loaded = new Object(); + Object stored = new Object(); + Object cleared = new Object(); + Object deleted = new Object(); + Object dirtied = new Object(); + Object attached = new Object(); + Object attachTarget = new Object(); + Object detached = new Object(); + Object detachTarget = new Object(); + + /** Creates a new instance of SingleFieldIdentityTest */ + public InstanceLifecycleEventTest() { } - fail("Invalid event did not throw IllegalArgumentException."); - } - - public void testIllegalConstructorTooBig() { - try { - new InstanceLifecycleEvent(new Object(), 8); - } catch (IllegalArgumentException e) { - return; // good catch + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + BatchTestRunner.run(InstanceLifecycleEventTest.class); + } + + public void testConstructorCreateEvent() { + InstanceLifecycleEvent e = new InstanceLifecycleEvent + (created, InstanceLifecycleEvent.CREATE); + assertSame ("Create source differs.", created, e.getSource()); + assertEquals ("Create type differs.", InstanceLifecycleEvent.CREATE, e.getEventType()); + } + + public void testConstructorLoadEvent() { + InstanceLifecycleEvent e = new InstanceLifecycleEvent + (loaded, InstanceLifecycleEvent.LOAD); + assertSame ("Load source differs.", loaded, e.getSource()); + assertEquals ("Load type differs.", InstanceLifecycleEvent.LOAD, e.getEventType()); + } + + public void testConstructorStoreEvent() { + InstanceLifecycleEvent e = new InstanceLifecycleEvent + (stored, InstanceLifecycleEvent.STORE); + assertSame ("Store source differs.", stored, e.getSource()); + assertEquals ("Store type differs.", InstanceLifecycleEvent.STORE, e.getEventType()); + } + + public void testConstructorClearEvent() { + InstanceLifecycleEvent e = new InstanceLifecycleEvent + (cleared, InstanceLifecycleEvent.CLEAR); + assertSame ("Clear source differs.", cleared, e.getSource()); + assertEquals ("Clear type differs.", InstanceLifecycleEvent.CLEAR, e.getEventType()); + } + + public void testConstructorDeleteEvent() { + InstanceLifecycleEvent e = new InstanceLifecycleEvent + (deleted, InstanceLifecycleEvent.DELETE); + assertSame ("Delete source differs.", deleted, e.getSource()); + assertEquals ("Delete type differs.", InstanceLifecycleEvent.DELETE, e.getEventType()); + } + + public void testConstructorDirtyEvent() { + InstanceLifecycleEvent e = new InstanceLifecycleEvent + (dirtied, InstanceLifecycleEvent.DIRTY); + assertSame ("Dirty source differs.", dirtied, e.getSource()); + assertEquals ("Dirty type differs.", InstanceLifecycleEvent.DIRTY, e.getEventType()); + } + + public void testConstructorDetachEvent() { + InstanceLifecycleEvent e = new InstanceLifecycleEvent + (detached, InstanceLifecycleEvent.DETACH, detachTarget); + assertSame ("Detach source differs.", detached, e.getSource()); + assertEquals ("Detach type differs.", InstanceLifecycleEvent.DETACH, e.getEventType()); + assertSame ("Detach target differs.", detachTarget, e.getTarget()); + } + + public void testConstructorAttachEvent() { + InstanceLifecycleEvent e = new InstanceLifecycleEvent + (attached, InstanceLifecycleEvent.ATTACH, attachTarget); + assertSame ("Attach source differs.", attached, e.getSource()); + assertEquals ("Attach type differs.", InstanceLifecycleEvent.ATTACH, e.getEventType()); + assertSame ("Attach target differs.", attachTarget, e.getTarget()); + } + + public void testIllegalConstructorTooSmall() { + try { + new InstanceLifecycleEvent (new Object(), -1); + } catch (IllegalArgumentException e) { + return; // good catch + } + fail ("Invalid event did not throw IllegalArgumentException."); + } + + public void testIllegalConstructorTooBig() { + try { + new InstanceLifecycleEvent (new Object(), 8); + } catch (IllegalArgumentException e) { + return; // good catch + } + fail ("Invalid event did not throw IllegalArgumentException."); } - fail("Invalid event did not throw IllegalArgumentException."); - } } diff --git a/api/src/test/java/javax/jdo/pc/PCPoint.java b/api/src/test/java/javax/jdo/pc/PCPoint.java index 7ab7df1f8..2a80d4268 100644 --- a/api/src/test/java/javax/jdo/pc/PCPoint.java +++ b/api/src/test/java/javax/jdo/pc/PCPoint.java @@ -5,388 +5,455 @@ * 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 + * + * 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 javax.jdo.pc; import javax.jdo.PersistenceManager; -import javax.jdo.spi.JDOImplHelper; +import javax.jdo.spi.*; + import javax.jdo.spi.PersistenceCapable; -import javax.jdo.spi.StateManager; /** - * This is a hand-enhanced version of a simple class with two fields. The enhanced code assumes - * datastore identity. + * This is a hand-enhanced version of a simple class with two fields. The + * enhanced code assumes datastore identity. * * @version 2.0 */ -public class PCPoint implements PersistenceCapable { - public int x; - public Integer y; - - // JDO generated fields - protected transient StateManager jdoStateManager; - protected transient byte jdoFlags; - private static final int jdoInheritedFieldCount = 0; - private static final String jdoFieldNames[] = {"x", "y"}; - private static final Class jdoFieldTypes[]; - private static final byte jdoFieldFlags[] = { - (byte) - (PersistenceCapable.CHECK_READ - + PersistenceCapable.CHECK_WRITE - + PersistenceCapable.SERIALIZABLE), - (byte) - (PersistenceCapable.CHECK_READ - + PersistenceCapable.CHECK_WRITE - + PersistenceCapable.SERIALIZABLE), - }; - private static final Class jdoPersistenceCapableSuperclass; - - static { - jdoFieldTypes = (new Class[] {Integer.TYPE, sunjdo$classForName$("java.lang.Integer")}); - jdoPersistenceCapableSuperclass = null; - JDOImplHelper.registerClass( - sunjdo$classForName$("javax.jdo.pc.PCPoint"), - jdoFieldNames, - jdoFieldTypes, - jdoFieldFlags, - jdoPersistenceCapableSuperclass, - new PCPoint()); - } - - /** JDO required no-args constructor. */ - public PCPoint() {} - - /** Constructor. */ - public PCPoint(int x, Integer y) { - jdoSetx(this, x); - jdoSety(this, y); - } - - /** */ - public void setX(int x) { - jdoSetx(this, x); - } - - /** */ - public int getX() { - return jdoGetx(this); - } - - /** */ - public void setY(Integer y) { - jdoSety(this, y); - } - - /** */ - public Integer getY() { - return jdoGety(this); - } - - /** */ - public boolean equals(Object o) { - if (o == null || !(o instanceof PCPoint)) return false; - PCPoint other = (PCPoint) o; - if (jdoGetx(this) != jdoGetx(other)) return false; - if (jdoGety(this) == null) return jdoGety(other) == null; - if (jdoGety(other) == null) return jdoGety(this) == null; - else return jdoGety(this).intValue() == jdoGety(other).intValue(); - } - - /** */ - public int hashCode() { - int code = getX(); - if (getY() != null) { - code += getY().intValue(); - } - return code; - } - - /** */ - public String toString() { - return "PCPoint(x: " + getX() + ", y: " + getY() + ")"; - } - - // Generated methods in least-derived PersistenceCapable class - - public final boolean jdoIsPersistent() { - StateManager statemanager = jdoStateManager; - if (statemanager != null) return statemanager.isPersistent(this); - else return false; - } - - public final boolean jdoIsTransactional() { - StateManager statemanager = jdoStateManager; - if (statemanager != null) return statemanager.isTransactional(this); - else return false; - } - - public final boolean jdoIsNew() { - StateManager statemanager = jdoStateManager; - if (statemanager != null) return statemanager.isNew(this); - else return false; - } - - public final boolean jdoIsDirty() { - StateManager statemanager = jdoStateManager; - if (statemanager != null) return statemanager.isDirty(this); - else return false; - } - - public final boolean jdoIsDeleted() { - StateManager statemanager = jdoStateManager; - if (statemanager != null) return statemanager.isDeleted(this); - else return false; - } - - public final boolean jdoIsDetached() { - return false; - } - - public final void jdoMakeDirty(String s) { - StateManager statemanager = jdoStateManager; - if (statemanager != null) statemanager.makeDirty(this, s); - } - - public final PersistenceManager jdoGetPersistenceManager() { - StateManager statemanager = jdoStateManager; - if (statemanager != null) return statemanager.getPersistenceManager(this); - else return null; - } - - public final Object jdoGetObjectId() { - StateManager statemanager = jdoStateManager; - if (statemanager != null) return statemanager.getObjectId(this); - else return null; - } - - public final Object jdoGetTransactionalObjectId() { - StateManager statemanager = jdoStateManager; - if (statemanager != null) return statemanager.getTransactionalObjectId(this); - else return null; - } - - public final Object jdoGetVersion() { - StateManager statemanager = jdoStateManager; - if (statemanager != null) return statemanager.getVersion(this); - else return null; - } - - public final synchronized void jdoReplaceStateManager(StateManager statemanager) { - StateManager statemanager1 = jdoStateManager; - if (statemanager1 != null) { - jdoStateManager = statemanager1.replacingStateManager(this, statemanager); - return; - } else { - JDOImplHelper.checkAuthorizedStateManager(statemanager); - jdoStateManager = statemanager; - jdoFlags = PersistenceCapable.LOAD_REQUIRED; - return; - } - } - - public final void jdoReplaceFlags() { - StateManager statemanager = jdoStateManager; - if (statemanager != null) jdoFlags = statemanager.replacingFlags(this); - } - - public final void jdoReplaceFields(int fields[]) { - if (fields == null) throw new IllegalArgumentException("fields is null"); - int i = fields.length; - for (int j = 0; j < i; j++) jdoReplaceField(fields[j]); - } - - public final void jdoProvideFields(int fields[]) { - if (fields == null) throw new IllegalArgumentException("fields is null"); - int i = fields.length; - for (int j = 0; j < i; j++) jdoProvideField(fields[j]); - } - - protected final void jdoPreSerialize() { - StateManager statemanager = jdoStateManager; - if (statemanager != null) statemanager.preSerialize(this); - } - - // Generated methods in PersistenceCapable root classes and all classes - // that declare objectid-class in xml metadata: - - public void jdoCopyKeyFieldsToObjectId( - PersistenceCapable.ObjectIdFieldSupplier objectidfieldsupplier, Object obj) {} - - public void jdoCopyKeyFieldsToObjectId(Object obj) {} - - public void jdoCopyKeyFieldsFromObjectId( - PersistenceCapable.ObjectIdFieldConsumer objectidfieldconsumer, Object obj) {} - - protected void jdoCopyKeyFieldsFromObjectId(Object obj) {} - - public Object jdoNewObjectIdInstance() { - return null; - } - - public Object jdoNewObjectIdInstance(Object o) { - return null; - } - - // Generated methods in all PersistenceCapable classes - - public PersistenceCapable jdoNewInstance(StateManager statemanager) { - PCPoint pcpoint = new PCPoint(); - pcpoint.jdoFlags = PersistenceCapable.LOAD_REQUIRED; - pcpoint.jdoStateManager = statemanager; - return pcpoint; - } - - public PersistenceCapable jdoNewInstance(StateManager statemanager, Object obj) { - PCPoint pcpoint = new PCPoint(); - pcpoint.jdoCopyKeyFieldsFromObjectId(obj); - pcpoint.jdoFlags = PersistenceCapable.LOAD_REQUIRED; - pcpoint.jdoStateManager = statemanager; - return pcpoint; - } - - protected static int jdoGetManagedFieldCount() { - return 2; - } - - public static final int jdoGetx(PCPoint pcpoint) { - if (pcpoint.jdoFlags <= PersistenceCapable.READ_WRITE_OK) return pcpoint.x; - StateManager statemanager = pcpoint.jdoStateManager; - if (statemanager == null) return pcpoint.x; - if (statemanager.isLoaded(pcpoint, jdoInheritedFieldCount + 0)) return pcpoint.x; - else return statemanager.getIntField(pcpoint, jdoInheritedFieldCount + 0, pcpoint.x); - } - - public static final Integer jdoGety(PCPoint pcpoint) { - if (pcpoint.jdoFlags <= PersistenceCapable.READ_WRITE_OK) return pcpoint.y; - StateManager statemanager = pcpoint.jdoStateManager; - if (statemanager == null) return pcpoint.y; - if (statemanager.isLoaded(pcpoint, jdoInheritedFieldCount + 1)) return pcpoint.y; - else - return (Integer) statemanager.getObjectField(pcpoint, jdoInheritedFieldCount + 1, pcpoint.y); - } - - public static final void jdoSetx(PCPoint pcpoint, int i) { - if (pcpoint.jdoFlags == PersistenceCapable.READ_WRITE_OK) { - pcpoint.x = i; - return; - } - StateManager statemanager = pcpoint.jdoStateManager; - if (statemanager == null) { - pcpoint.x = i; - return; - } else { - statemanager.setIntField(pcpoint, jdoInheritedFieldCount + 0, pcpoint.x, i); - return; - } - } - - public static final void jdoSety(PCPoint pcpoint, Integer integer) { - if (pcpoint.jdoFlags == PersistenceCapable.READ_WRITE_OK) { - pcpoint.y = integer; - return; - } - StateManager statemanager = pcpoint.jdoStateManager; - if (statemanager == null) { - pcpoint.y = integer; - return; - } else { - statemanager.setObjectField(pcpoint, jdoInheritedFieldCount + 1, pcpoint.y, integer); - return; - } - } - - public void jdoReplaceField(int field) { - StateManager statemanager = jdoStateManager; - switch (field - jdoInheritedFieldCount) { - case 0: - if (statemanager == null) { - throw new IllegalStateException("jdoStateManager is null"); - } else { - x = statemanager.replacingIntField(this, field); - return; +public class PCPoint + implements PersistenceCapable +{ + public int x; + public Integer y; + + // JDO generated fields + protected transient StateManager jdoStateManager; + protected transient byte jdoFlags; + private static final int jdoInheritedFieldCount = 0; + private static final String jdoFieldNames[] = { "x", "y" }; + private static final Class jdoFieldTypes[]; + private static final byte jdoFieldFlags[] = { + (byte)(PersistenceCapable.CHECK_READ + PersistenceCapable.CHECK_WRITE + + PersistenceCapable.SERIALIZABLE), + (byte)(PersistenceCapable.CHECK_READ + PersistenceCapable.CHECK_WRITE + + PersistenceCapable.SERIALIZABLE), + }; + private static final Class jdoPersistenceCapableSuperclass; + + static + { + jdoFieldTypes = (new Class[] { + Integer.TYPE, sunjdo$classForName$("java.lang.Integer") + }); + jdoPersistenceCapableSuperclass = null; + JDOImplHelper.registerClass( + sunjdo$classForName$("javax.jdo.pc.PCPoint"), + jdoFieldNames, jdoFieldTypes, jdoFieldFlags, + jdoPersistenceCapableSuperclass, new PCPoint()); + } + + /** JDO required no-args constructor. */ + public PCPoint() { } + + /** Constructor. */ + public PCPoint(int x, Integer y) { + jdoSetx(this, x); + jdoSety(this, y); + } + + /** */ + public void setX(int x) { + jdoSetx(this, x); + } + + /** */ + public int getX() { + return jdoGetx(this); + } + + /** */ + public void setY(Integer y) { + jdoSety(this, y); + } + + /** */ + public Integer getY() { + return jdoGety(this); + } + + /** */ + public boolean equals(Object o) { + if (o == null || !(o instanceof PCPoint)) + return false; + PCPoint other = (PCPoint)o; + if (jdoGetx(this) != jdoGetx(other)) + return false; + if (jdoGety(this) == null) + return jdoGety(other) == null; + if (jdoGety(other) == null) + return jdoGety(this) == null; + else + return jdoGety(this).intValue() == jdoGety(other).intValue(); + } + + /** */ + public int hashCode() { + int code = getX(); + if (getY() != null) { + code += getY().intValue(); } - case 1: - if (statemanager == null) { - throw new IllegalStateException("jdoStateManager is null"); - } else { - y = (Integer) statemanager.replacingObjectField(this, field); - return; + return code; + } + + /** */ + public String toString() { + return "PCPoint(x: " + getX() + ", y: " + getY() + ")"; + } + + + // Generated methods in least-derived PersistenceCapable class + + public final boolean jdoIsPersistent() { + StateManager statemanager = jdoStateManager; + if (statemanager != null) + return statemanager.isPersistent(this); + else + return false; + } + + public final boolean jdoIsTransactional() { + StateManager statemanager = jdoStateManager; + if (statemanager != null) + return statemanager.isTransactional(this); + else + return false; + } + + public final boolean jdoIsNew() { + StateManager statemanager = jdoStateManager; + if (statemanager != null) + return statemanager.isNew(this); + else + return false; + } + + public final boolean jdoIsDirty() { + StateManager statemanager = jdoStateManager; + if (statemanager != null) + return statemanager.isDirty(this); + else + return false; + } + + public final boolean jdoIsDeleted() { + StateManager statemanager = jdoStateManager; + if (statemanager != null) + return statemanager.isDeleted(this); + else + return false; + } + + public final boolean jdoIsDetached() { + return false; + } + + public final void jdoMakeDirty(String s) { + StateManager statemanager = jdoStateManager; + if (statemanager != null) + statemanager.makeDirty(this, s); + } + + public final PersistenceManager jdoGetPersistenceManager() { + StateManager statemanager = jdoStateManager; + if (statemanager != null) + return statemanager.getPersistenceManager(this); + else + return null; + } + + public final Object jdoGetObjectId() { + StateManager statemanager = jdoStateManager; + if (statemanager != null) + return statemanager.getObjectId(this); + else + return null; + } + + public final Object jdoGetTransactionalObjectId() { + StateManager statemanager = jdoStateManager; + if (statemanager != null) + return statemanager.getTransactionalObjectId(this); + else + return null; + } + + public final Object jdoGetVersion() { + StateManager statemanager = jdoStateManager; + if (statemanager != null) + return statemanager.getVersion(this); + else + return null; + } + + public final synchronized void jdoReplaceStateManager( + StateManager statemanager) { + StateManager statemanager1 = jdoStateManager; + if (statemanager1 != null) { + jdoStateManager = statemanager1.replacingStateManager( + this, statemanager); + return; + } + else { + JDOImplHelper.checkAuthorizedStateManager(statemanager); + jdoStateManager = statemanager; + jdoFlags = PersistenceCapable.LOAD_REQUIRED; + return; } } - throw new IllegalArgumentException("field number out of range"); - } + + public final void jdoReplaceFlags() { + StateManager statemanager = jdoStateManager; + if (statemanager != null) + jdoFlags = statemanager.replacingFlags(this); + } + + public final void jdoReplaceFields(int fields[]) { + if (fields == null) + throw new IllegalArgumentException("fields is null"); + int i = fields.length; + for(int j = 0; j < i; j++) + jdoReplaceField(fields[j]); + + } + + public final void jdoProvideFields(int fields[]) { + if (fields == null) + throw new IllegalArgumentException("fields is null"); + int i = fields.length; + for(int j = 0; j < i; j++) + jdoProvideField(fields[j]); + + } + + protected final void jdoPreSerialize() { + StateManager statemanager = jdoStateManager; + if (statemanager != null) + statemanager.preSerialize(this); + } + + // Generated methods in PersistenceCapable root classes and all classes + // that declare objectid-class in xml metadata: + + public void jdoCopyKeyFieldsToObjectId( + PersistenceCapable.ObjectIdFieldSupplier objectidfieldsupplier, + Object obj) { } + + public void jdoCopyKeyFieldsToObjectId(Object obj) { + } + + public void jdoCopyKeyFieldsFromObjectId( + PersistenceCapable.ObjectIdFieldConsumer objectidfieldconsumer, + Object obj) { } + + protected void jdoCopyKeyFieldsFromObjectId(Object obj) { + } + + public Object jdoNewObjectIdInstance() { + return null; + } + + public Object jdoNewObjectIdInstance(Object o) { + return null; + } + + // Generated methods in all PersistenceCapable classes + + public PersistenceCapable jdoNewInstance(StateManager statemanager) { + PCPoint pcpoint = new PCPoint(); + pcpoint.jdoFlags = PersistenceCapable.LOAD_REQUIRED; + pcpoint.jdoStateManager = statemanager; + return pcpoint; + } + + public PersistenceCapable jdoNewInstance( + StateManager statemanager, Object obj) { + PCPoint pcpoint = new PCPoint(); + pcpoint.jdoCopyKeyFieldsFromObjectId(obj); + pcpoint.jdoFlags = PersistenceCapable.LOAD_REQUIRED; + pcpoint.jdoStateManager = statemanager; + return pcpoint; + } + + protected static int jdoGetManagedFieldCount() { + return 2; + } - public void jdoProvideField(int field) { - StateManager statemanager = jdoStateManager; - switch (field - jdoInheritedFieldCount) { - case 0: + public static final int jdoGetx(PCPoint pcpoint) { + if (pcpoint.jdoFlags <= PersistenceCapable.READ_WRITE_OK) + return pcpoint.x; + StateManager statemanager = pcpoint.jdoStateManager; + if (statemanager == null) + return pcpoint.x; + if (statemanager.isLoaded(pcpoint, jdoInheritedFieldCount + 0)) + return pcpoint.x; + else + return statemanager.getIntField( + pcpoint, jdoInheritedFieldCount + 0, pcpoint.x); + } + + public static final Integer jdoGety(PCPoint pcpoint) { + if (pcpoint.jdoFlags <= PersistenceCapable.READ_WRITE_OK) + return pcpoint.y; + StateManager statemanager = pcpoint.jdoStateManager; + if (statemanager == null) + return pcpoint.y; + if (statemanager.isLoaded(pcpoint, jdoInheritedFieldCount + 1)) + return pcpoint.y; + else + return (Integer)statemanager.getObjectField( + pcpoint, jdoInheritedFieldCount + 1, pcpoint.y); + } + + public static final void jdoSetx(PCPoint pcpoint, int i) { + if (pcpoint.jdoFlags == PersistenceCapable.READ_WRITE_OK) { + pcpoint.x = i; + return; + } + StateManager statemanager = pcpoint.jdoStateManager; if (statemanager == null) { - throw new IllegalStateException("jdoStateManager is null"); - } else { - statemanager.providedIntField(this, field, x); - return; + pcpoint.x = i; + return; + } + else { + statemanager.setIntField( + pcpoint, jdoInheritedFieldCount + 0, pcpoint.x, i); + return; + } + } + + public static final void jdoSety(PCPoint pcpoint, Integer integer) { + if (pcpoint.jdoFlags == PersistenceCapable.READ_WRITE_OK) { + pcpoint.y = integer; + return; } - case 1: + StateManager statemanager = pcpoint.jdoStateManager; if (statemanager == null) { - throw new IllegalStateException("jdoStateManager is null"); - } else { - statemanager.providedObjectField(this, field, y); - return; + pcpoint.y = integer; + return; + } + else { + statemanager.setObjectField(pcpoint, jdoInheritedFieldCount + 1, pcpoint.y, integer); + return; } } - throw new IllegalArgumentException("field number out of range"); - } - - public void jdoCopyFields(Object obj, int fieldNumbers[]) { - if (jdoStateManager == null) throw new IllegalStateException("jdoStateManager is null"); - if (!(obj instanceof PCPoint)) throw new ClassCastException(obj.getClass().getName()); - if (fieldNumbers == null) throw new IllegalArgumentException("fieldNumber is null"); - PCPoint pcpoint = (PCPoint) obj; - if (pcpoint.jdoStateManager != jdoStateManager) - throw new IllegalArgumentException("wrong jdoStateManager"); - int i = fieldNumbers.length; - for (int j = 0; j < i; j++) jdoCopyField(pcpoint, fieldNumbers[j]); - } - - protected final void jdoCopyField(PCPoint pcpoint, int fieldNumber) { - switch (fieldNumber - jdoInheritedFieldCount) { - case 0: - if (pcpoint == null) { - throw new IllegalArgumentException("pcpoint is null"); - } else { - x = pcpoint.x; - return; + + public void jdoReplaceField(int field) { + StateManager statemanager = jdoStateManager; + switch(field - jdoInheritedFieldCount) { + case 0: + if (statemanager == null) { + throw new IllegalStateException("jdoStateManager is null"); + } + else { + x = statemanager.replacingIntField(this, field); + return; + } + case 1: + if (statemanager == null) { + throw new IllegalStateException("jdoStateManager is null"); + } + else { + y = (Integer)statemanager.replacingObjectField(this, field); + return; + } } - case 1: - if (pcpoint == null) { - throw new IllegalArgumentException("pcpoint is null"); - } else { - y = pcpoint.y; - return; + throw new IllegalArgumentException("field number out of range"); + } + + public void jdoProvideField(int field) { + StateManager statemanager = jdoStateManager; + switch(field - jdoInheritedFieldCount) { + case 0: + if (statemanager == null) { + throw new IllegalStateException("jdoStateManager is null"); + } + else { + statemanager.providedIntField(this, field, x); + return; + } + case 1: + if (statemanager == null) { + throw new IllegalStateException("jdoStateManager is null"); + } + else { + statemanager.providedObjectField(this, field, y); + return; + } } + throw new IllegalArgumentException("field number out of range"); } - throw new IllegalArgumentException("field number out of range"); - } - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - jdoPreSerialize(); - out.defaultWriteObject(); - } + public void jdoCopyFields(Object obj, int fieldNumbers[]) { + if (jdoStateManager == null) + throw new IllegalStateException("jdoStateManager is null"); + if (!(obj instanceof PCPoint)) + throw new ClassCastException(obj.getClass().getName()); + if (fieldNumbers == null) + throw new IllegalArgumentException("fieldNumber is null"); + PCPoint pcpoint = (PCPoint)obj; + if (pcpoint.jdoStateManager != jdoStateManager) + throw new IllegalArgumentException("wrong jdoStateManager"); + int i = fieldNumbers.length; + for(int j = 0; j < i; j++) + jdoCopyField(pcpoint, fieldNumbers[j]); + } - protected static final Class sunjdo$classForName$(String s) { - try { - return Class.forName(s); - } catch (ClassNotFoundException ex) { - throw new NoClassDefFoundError(ex.getMessage()); + protected final void jdoCopyField(PCPoint pcpoint, int fieldNumber) + { + switch(fieldNumber - jdoInheritedFieldCount) { + case 0: + if (pcpoint == null) { + throw new IllegalArgumentException("pcpoint is null"); + } + else { + x = pcpoint.x; + return; + } + case 1: + if (pcpoint == null) { + throw new IllegalArgumentException("pcpoint is null"); + } + else { + y = pcpoint.y; + return; + } + } + throw new IllegalArgumentException("field number out of range"); } - } + + private void writeObject(java.io.ObjectOutputStream out) + throws java.io.IOException { + jdoPreSerialize(); + out.defaultWriteObject(); + } + + protected static final Class sunjdo$classForName$(String s) { + try { + return Class.forName(s); + } + catch(ClassNotFoundException ex) { + throw new NoClassDefFoundError(ex.getMessage()); + } + } + + + } diff --git a/api/src/test/java/javax/jdo/schema/XMLTest.java b/api/src/test/java/javax/jdo/schema/XMLTest.java index 0c1534436..ceb03e474 100644 --- a/api/src/test/java/javax/jdo/schema/XMLTest.java +++ b/api/src/test/java/javax/jdo/schema/XMLTest.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,102 +19,101 @@ import java.io.File; import java.io.FilenameFilter; + import javax.jdo.util.AbstractTest; import javax.jdo.util.BatchTestRunner; import javax.jdo.util.XMLTestUtil; /** * Tests schema files. - * *

    */ public class XMLTest extends AbstractTest { - /** */ - protected static String BASEDIR = System.getProperty("basedir", "."); - - /** File prefix */ - protected static final String FILE_PREFIX = BASEDIR + "/src/test/resources/"; - - /** */ - protected static final File JDO_XSD_FILE = - new File(BASEDIR + "/target/classes/javax/jdo/jdo_2_2.xsd"); - - /** */ - protected static final File ORM_XSD_FILE = - new File(BASEDIR + "/target/classes/javax/jdo/orm_2_2.xsd"); - - /** */ - protected static final File JDOQUERY_XSD_FILE = - new File(BASEDIR + "/target/classes/javax/jdo/jdoquery_2_2.xsd"); - - /** .xsd files */ - protected static final File[] XSD_FILES = - new File[] {JDO_XSD_FILE, ORM_XSD_FILE, JDOQUERY_XSD_FILE}; - - /** XSD metadata files. */ - protected static File[] positiveXSDJDO = getFiles("Positive", "-xsd.jdo"); - - protected static File[] negativeXSDJDO = getFiles("Negative", "-xsd.jdo"); - protected static File[] positiveXSDORM = getFiles("Positive", "-xsd.orm"); - protected static File[] negativeXSDORM = getFiles("Negative", "-xsd.orm"); - protected static File[] positiveXSDJDOQUERY = getFiles("Positive", "-xsd.jdoquery"); - protected static File[] negativeXSDJDOQUERY = getFiles("Negative", "-xsd.jdoquery"); - - /** DTD metadata files. */ - protected static File[] positiveDTDJDO = getFiles("Positive", "-dtd.jdo"); - - protected static File[] negativeDTDJDO = getFiles("Negative", "-dtd.jdo"); - protected static File[] positiveDTDORM = getFiles("Positive", "-dtd.orm"); - protected static File[] negativeDTDORM = getFiles("Negative", "-dtd.orm"); - protected static File[] positiveDTDJDOQUERY = getFiles("Positive", "-dtd.jdoquery"); - protected static File[] negativeDTDJDOQUERY = getFiles("Negative", "-dtd.jdoquery"); - - /** Returns array of files of matching file names. */ - protected static File[] getFiles(final String prefix, final String suffix) { - FilenameFilter filter = - new FilenameFilter() { - public boolean accept(File file, String name) { - return (name.startsWith(prefix) && name.endsWith(suffix)); - } + /** */ + protected static String BASEDIR = System.getProperty("basedir", "."); + + /** File prefix */ + protected static final String FILE_PREFIX = BASEDIR + "/src/test/resources/"; + + /** */ + protected static final File JDO_XSD_FILE = + new File(BASEDIR + "/target/classes/javax/jdo/jdo_2_2.xsd"); + + /** */ + protected static final File ORM_XSD_FILE = + new File(BASEDIR + "/target/classes/javax/jdo/orm_2_2.xsd"); + + /** */ + protected static final File JDOQUERY_XSD_FILE = + new File(BASEDIR + "/target/classes/javax/jdo/jdoquery_2_2.xsd"); + + /** .xsd files */ + protected static final File[] XSD_FILES = + new File[] {JDO_XSD_FILE, ORM_XSD_FILE, JDOQUERY_XSD_FILE}; + + /** XSD metadata files. */ + protected static File[] positiveXSDJDO = getFiles("Positive", "-xsd.jdo"); + protected static File[] negativeXSDJDO = getFiles("Negative", "-xsd.jdo"); + protected static File[] positiveXSDORM = getFiles("Positive", "-xsd.orm"); + protected static File[] negativeXSDORM = getFiles("Negative", "-xsd.orm"); + protected static File[] positiveXSDJDOQUERY = getFiles("Positive", "-xsd.jdoquery"); + protected static File[] negativeXSDJDOQUERY = getFiles("Negative", "-xsd.jdoquery"); + + /** DTD metadata files. */ + protected static File[] positiveDTDJDO = getFiles("Positive", "-dtd.jdo"); + protected static File[] negativeDTDJDO = getFiles("Negative", "-dtd.jdo"); + protected static File[] positiveDTDORM = getFiles("Positive", "-dtd.orm"); + protected static File[] negativeDTDORM = getFiles("Negative", "-dtd.orm"); + protected static File[] positiveDTDJDOQUERY = getFiles("Positive", "-dtd.jdoquery"); + protected static File[] negativeDTDJDOQUERY = getFiles("Negative", "-dtd.jdoquery"); + + /** Returns array of files of matching file names. */ + protected static File[] getFiles(final String prefix, final String suffix) { + FilenameFilter filter = new FilenameFilter () { + public boolean accept(File file, String name) { + return (name.startsWith(prefix) && name.endsWith(suffix)); + } }; - File dir = new File(FILE_PREFIX); - return dir.listFiles(filter); - } - - /** */ - public static void main(String args[]) { - BatchTestRunner.run(XMLTest.class); - } - - /** Test XSD files jdo.xsd, orm.xsd, and jdoquery.xsd. */ - public void testXSD() { - XMLTestUtil util = new XMLTestUtil(); - appendMessage(util.checkXMLNonValidating(XSD_FILES)); - failOnError(); - } - - /** Test XSD based .jdo, .orm and .jdoquery files. */ - public void testXSDBased() { - XMLTestUtil util = new XMLTestUtil(); - appendMessage(util.checkXML(positiveXSDJDO, true)); - appendMessage(util.checkXML(negativeXSDJDO, false)); - appendMessage(util.checkXML(positiveXSDORM, true)); - appendMessage(util.checkXML(negativeXSDORM, false)); - appendMessage(util.checkXML(positiveXSDJDOQUERY, true)); - appendMessage(util.checkXML(negativeXSDJDOQUERY, false)); - failOnError(); - } - - /** Test DTD based .jdo, .orm and .jdoquery files. */ - public void testDTDBased() { - XMLTestUtil util = new XMLTestUtil(); - appendMessage(util.checkXML(positiveDTDJDO, true)); - appendMessage(util.checkXML(negativeDTDJDO, false)); - appendMessage(util.checkXML(positiveDTDORM, true)); - appendMessage(util.checkXML(negativeDTDORM, false)); - appendMessage(util.checkXML(positiveDTDJDOQUERY, true)); - appendMessage(util.checkXML(negativeDTDJDOQUERY, false)); - failOnError(); - } + File dir = new File(FILE_PREFIX); + return dir.listFiles(filter); + } + + /** */ + public static void main(String args[]) { + BatchTestRunner.run(XMLTest.class); + } + + /** Test XSD files jdo.xsd, orm.xsd, and jdoquery.xsd. */ + public void testXSD() { + XMLTestUtil util = new XMLTestUtil(); + appendMessage(util.checkXMLNonValidating(XSD_FILES)); + failOnError(); + } + + /** Test XSD based .jdo, .orm and .jdoquery files. */ + public void testXSDBased() { + XMLTestUtil util = new XMLTestUtil(); + appendMessage(util.checkXML(positiveXSDJDO, true)); + appendMessage(util.checkXML(negativeXSDJDO, false)); + appendMessage(util.checkXML(positiveXSDORM, true)); + appendMessage(util.checkXML(negativeXSDORM, false)); + appendMessage(util.checkXML(positiveXSDJDOQUERY, true)); + appendMessage(util.checkXML(negativeXSDJDOQUERY, false)); + failOnError(); + } + + /** Test DTD based .jdo, .orm and .jdoquery files. */ + public void testDTDBased() { + XMLTestUtil util = new XMLTestUtil(); + appendMessage(util.checkXML(positiveDTDJDO, true)); + appendMessage(util.checkXML(negativeDTDJDO, false)); + appendMessage(util.checkXML(positiveDTDORM, true)); + appendMessage(util.checkXML(negativeDTDORM, false)); + appendMessage(util.checkXML(positiveDTDJDOQUERY, true)); + appendMessage(util.checkXML(negativeDTDJDOQUERY, false)); + failOnError(); + } + } + diff --git a/api/src/test/java/javax/jdo/spi/JDOImplHelperTest.java b/api/src/test/java/javax/jdo/spi/JDOImplHelperTest.java index 547262455..3e4b7c906 100644 --- a/api/src/test/java/javax/jdo/spi/JDOImplHelperTest.java +++ b/api/src/test/java/javax/jdo/spi/JDOImplHelperTest.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,258 +19,281 @@ import java.util.Collection; import java.util.Properties; + import javax.jdo.Constants; import javax.jdo.JDOUserException; import javax.jdo.pc.PCPoint; import javax.jdo.util.AbstractTest; import javax.jdo.util.BatchTestRunner; -/** +/** * Tests class javax.jdo.spi.JDOImplHelper. - * - *

    Missing: testNewInstance + testNewObjectIdInstance Missing: tests for JDOImplHelper methods: - * copyKeyFieldsToObjectId and copyKeyFieldsFromObjectId. + *

    + * Missing: testNewInstance + testNewObjectIdInstance + * Missing: tests for JDOImplHelper methods: copyKeyFieldsToObjectId and + * copyKeyFieldsFromObjectId. */ public class JDOImplHelperTest extends AbstractTest { + + /** */ + private RegisterClassEvent event; - /** */ - private RegisterClassEvent event; - - /** */ - public static void main(String args[]) { - BatchTestRunner.run(JDOImplHelperTest.class); - } - - /** */ - public void setUp() { - // make sure PCClass is loaded before any tests are run - new PCPoint(1, Integer.valueOf(1)); - } - - /** */ - public void testGetFieldNames() { - JDOImplHelper implHelper = JDOImplHelper.getInstance(); - String[] fieldNames = implHelper.getFieldNames(PCPoint.class); - if (fieldNames == null) { - fail("array of field names is null"); - } - if (fieldNames.length != 2) { - fail("Unexpected length of fieldNames; expected 2, got " + fieldNames.length); - } - if (!fieldNames[0].equals("x")) { - fail("Unexpected field; expected x, got " + fieldNames[0]); - } - if (!fieldNames[1].equals("y")) { - fail("Unexpected field; expected y, got " + fieldNames[1]); + /** */ + public static void main(String args[]) { + BatchTestRunner.run(JDOImplHelperTest.class); } - } - /** */ - public void testGetFieldTypes() { - JDOImplHelper implHelper = JDOImplHelper.getInstance(); - Class[] fieldTypes = implHelper.getFieldTypes(PCPoint.class); - if (fieldTypes == null) { - fail("array of field types is null"); - } - if (fieldTypes.length != 2) { - fail("Unexpected length of fieldTypes; expected 2, got " + fieldTypes.length); - } - if (fieldTypes[0] != int.class) { - fail("Unexpected field type; expected int, got " + fieldTypes[0]); - } - if (fieldTypes[1] != Integer.class) { - fail("Unexpected field type; expected Integer, got " + fieldTypes[1]); + /** */ + public void setUp() { + // make sure PCClass is loaded before any tests are run + new PCPoint(1, Integer.valueOf(1)); } - } - - /** */ - public void testGetFieldFlags() { - byte expected = - (byte) - (PersistenceCapable.CHECK_READ - + PersistenceCapable.CHECK_WRITE - + PersistenceCapable.SERIALIZABLE); - JDOImplHelper implHelper = JDOImplHelper.getInstance(); - byte[] fieldFlags = implHelper.getFieldFlags(PCPoint.class); - if (fieldFlags == null) { - fail("array of field flags is null"); - } - if (fieldFlags.length != 2) { - fail("Unexpected length of fieldFlags; expected 2, got " + fieldFlags.length); + /** */ + public void testGetFieldNames() { + JDOImplHelper implHelper = JDOImplHelper.getInstance(); + String[] fieldNames = implHelper.getFieldNames(PCPoint.class); + if (fieldNames == null) { + fail("array of field names is null"); + } + if (fieldNames.length != 2) { + fail("Unexpected length of fieldNames; expected 2, got " + + fieldNames.length); + } + if (!fieldNames[0].equals("x")) { + fail("Unexpected field; expected x, got " + fieldNames[0]); + } + if (!fieldNames[1].equals("y")) { + fail("Unexpected field; expected y, got " + fieldNames[1]); + } } - if (fieldFlags[0] != expected) { - fail("Unexpected field flag; expected " + expected + ", got " + fieldFlags[0]); + + /** */ + public void testGetFieldTypes() { + JDOImplHelper implHelper = JDOImplHelper.getInstance(); + Class[] fieldTypes = implHelper.getFieldTypes(PCPoint.class); + if (fieldTypes == null) { + fail("array of field types is null"); + } + if (fieldTypes.length != 2) { + fail("Unexpected length of fieldTypes; expected 2, got " + + fieldTypes.length); + } + if (fieldTypes[0] != int.class) { + fail("Unexpected field type; expected int, got " + + fieldTypes[0]); + } + if (fieldTypes[1] != Integer.class) { + fail("Unexpected field type; expected Integer, got " + + fieldTypes[1]); + } } - if (fieldFlags[1] != expected) { - fail("Unexpected field flag; expected " + expected + ", got " + fieldFlags[1]); + + /** */ + public void testGetFieldFlags() { + byte expected = (byte) (PersistenceCapable.CHECK_READ + + PersistenceCapable.CHECK_WRITE + PersistenceCapable.SERIALIZABLE); + + JDOImplHelper implHelper = JDOImplHelper.getInstance(); + byte[] fieldFlags = implHelper.getFieldFlags(PCPoint.class); + if (fieldFlags == null) { + fail("array of field flags is null"); + } + if (fieldFlags.length != 2) { + fail("Unexpected length of fieldFlags; expected 2, got " + + fieldFlags.length); + } + if (fieldFlags[0] != expected) { + fail("Unexpected field flag; expected " + expected + + ", got " + fieldFlags[0]); + } + if (fieldFlags[1] != expected) { + fail("Unexpected field flag; expected " + expected + + ", got " + fieldFlags[1]); + } } - } - /** */ - public void testGetPCSuperclass() { - JDOImplHelper implHelper = JDOImplHelper.getInstance(); - Class pcSuper = implHelper.getPersistenceCapableSuperclass(PCPoint.class); - if (pcSuper != null) { - fail("Wrong pc superclass of PCPoint; expected null, got " + pcSuper); + /** */ + public void testGetPCSuperclass() { + JDOImplHelper implHelper = JDOImplHelper.getInstance(); + Class pcSuper = + implHelper.getPersistenceCapableSuperclass(PCPoint.class); + if (pcSuper != null) { + fail("Wrong pc superclass of PCPoint; expected null, got " + + pcSuper); + } } - } - - /** */ - public void testNewInstance() { - // TBD: test JDOImplHelper.newInstance(pcClass, sm) and - // JDOImplHelper.newInstance(pcClass, sm, oid) - } - /** */ - public void testNewObjectIdInstance() { - // TBD: test JDOImplHelper.newObjectIdInstance(pcClass) - } - - /** */ - public void testClassRegistration() { - JDOImplHelper implHelper = JDOImplHelper.getInstance(); - - Collection registeredClasses = implHelper.getRegisteredClasses(); - // test whether PCPoint is registered - if (!registeredClasses.contains(PCPoint.class)) { - fail("Missing registration of pc class PCPoint"); + /** */ + public void testNewInstance() { + // TBD: test JDOImplHelper.newInstance(pcClass, sm) and + // JDOImplHelper.newInstance(pcClass, sm, oid) } - // Save registered meta data for restoring - String[] fieldNames = implHelper.getFieldNames(PCPoint.class); - Class[] fieldTypes = implHelper.getFieldTypes(PCPoint.class); - byte[] fieldFlags = implHelper.getFieldFlags(PCPoint.class); - Class pcSuperclass = implHelper.getPersistenceCapableSuperclass(PCPoint.class); - - // test unregisterClass with null parameter - try { - implHelper.unregisterClass(null); - fail("Missing exception when calling unregisterClass(null)"); - } catch (NullPointerException ex) { - // expected exception => OK + /** */ + public void testNewObjectIdInstance() { + // TBD: test JDOImplHelper.newObjectIdInstance(pcClass) } - - // test unregister PCPoint class - implHelper.unregisterClass(PCPoint.class); - registeredClasses = implHelper.getRegisteredClasses(); - if (registeredClasses.contains(PCPoint.class)) { - fail("PCPoint still registered"); + + /** */ + public void testClassRegistration() { + JDOImplHelper implHelper = JDOImplHelper.getInstance(); + + Collection registeredClasses = implHelper.getRegisteredClasses(); + // test whether PCPoint is registered + if (!registeredClasses.contains(PCPoint.class)) { + fail("Missing registration of pc class PCPoint"); + } + + // Save registered meta data for restoring + String[] fieldNames = implHelper.getFieldNames(PCPoint.class); + Class[] fieldTypes = implHelper.getFieldTypes(PCPoint.class); + byte[] fieldFlags = implHelper.getFieldFlags(PCPoint.class); + Class pcSuperclass = implHelper.getPersistenceCapableSuperclass(PCPoint.class); + + // test unregisterClass with null parameter + try { + implHelper.unregisterClass(null); + fail("Missing exception when calling unregisterClass(null)"); + } + catch (NullPointerException ex) { + // expected exception => OK + } + + // test unregister PCPoint class + implHelper.unregisterClass(PCPoint.class); + registeredClasses = implHelper.getRegisteredClasses(); + if (registeredClasses.contains(PCPoint.class)) { + fail("PCPoint still registered"); + } + + // register PCPoint again + JDOImplHelper.registerClass(PCPoint.class, fieldNames, fieldTypes, + fieldFlags, pcSuperclass, new PCPoint()); } - // register PCPoint again - JDOImplHelper.registerClass( - PCPoint.class, fieldNames, fieldTypes, fieldFlags, pcSuperclass, new PCPoint()); - } - - /** */ - public void testClassListenerRegistration() { - JDOImplHelper implHelper = JDOImplHelper.getInstance(); - - // add listener and check event - event = null; - RegisterClassListener listener = new SimpleListener(); - implHelper.addRegisterClassListener(listener); - JDOImplHelper.registerClass( - JDOImplHelperTest.class, new String[0], new Class[0], new byte[0], null, null); - if (event == null) { - fail("Missing event "); + /** */ + public void testClassListenerRegistration() { + JDOImplHelper implHelper = JDOImplHelper.getInstance(); + + // add listener and check event + event = null; + RegisterClassListener listener = new SimpleListener(); + implHelper.addRegisterClassListener(listener); + JDOImplHelper.registerClass(JDOImplHelperTest.class, new String[0], + new Class[0], new byte[0], null, null); + if (event == null) { + fail("Missing event "); + } + + // remove listener and check event + event = null; + implHelper.removeRegisterClassListener(listener); + JDOImplHelper.registerClass(JDOImplHelperTest.class, new String[0], + new Class[0], new byte[0], null, null); + if (event != null) { + fail("Unexpected event " + event); + } } - // remove listener and check event - event = null; - implHelper.removeRegisterClassListener(listener); - JDOImplHelper.registerClass( - JDOImplHelperTest.class, new String[0], new Class[0], new byte[0], null, null); - if (event != null) { - fail("Unexpected event " + event); + /** + * Test that an unknown standard property causes JDOUserException. + */ + public void testUnknownStandardProperty() { + Properties p = new Properties(); + p.setProperty("javax.jdo.unknown.standard.property", "value"); + + JDOUserException x = null; + + try { + JDOImplHelper.assertOnlyKnownStandardProperties(p); + fail("testUnknownStandardProperty should result in JDOUserException. " + + "No exception was thrown."); + } catch (JDOUserException thrown) { + if (verbose) + println("Caught expected exception " + thrown); + x = thrown; + } + assertNull("should have had no nested exceptions", + x.getNestedExceptions()); } - } - - /** Test that an unknown standard property causes JDOUserException. */ - public void testUnknownStandardProperty() { - Properties p = new Properties(); - p.setProperty("javax.jdo.unknown.standard.property", "value"); - JDOUserException x = null; - - try { - JDOImplHelper.assertOnlyKnownStandardProperties(p); - fail( - "testUnknownStandardProperty should result in JDOUserException. " - + "No exception was thrown."); - } catch (JDOUserException thrown) { - if (verbose) println("Caught expected exception " + thrown); - x = thrown; + /** + * Test that unknown standard properties cause JDOUserException w/nested + * exceptions. + */ + public void testUnknownStandardProperties() { + Properties p = new Properties(); + p.setProperty("javax.jdo.unknown.standard.property.1", "value"); + p.setProperty("javax.jdo.unknown.standard.property.2", "value"); + + JDOUserException x = null; + + try { + JDOImplHelper.assertOnlyKnownStandardProperties(p); + fail("testUnknownStandardProperties should result in JDOUserException. " + + "No exception was thrown."); + } catch (JDOUserException thrown) { + if (verbose) + println("Caught expected exception " + thrown); + x = thrown; + } + + Throwable[] nesteds = x.getNestedExceptions(); + + assertNotNull(nesteds); + assertEquals("should have been 2 nested exceptions", 2, nesteds.length); + for (int i = 0; i < nesteds.length; i++) { + Throwable t = nesteds[i]; + assertTrue("nested exception " + i + + " should have been JDOUserException", + t instanceof JDOUserException); + } } - assertNull("should have had no nested exceptions", x.getNestedExceptions()); - } - - /** Test that unknown standard properties cause JDOUserException w/nested exceptions. */ - public void testUnknownStandardProperties() { - Properties p = new Properties(); - p.setProperty("javax.jdo.unknown.standard.property.1", "value"); - p.setProperty("javax.jdo.unknown.standard.property.2", "value"); - - JDOUserException x = null; - try { - JDOImplHelper.assertOnlyKnownStandardProperties(p); - fail( - "testUnknownStandardProperties should result in JDOUserException. " - + "No exception was thrown."); - } catch (JDOUserException thrown) { - if (verbose) println("Caught expected exception " + thrown); - x = thrown; + /** + * Test that unknown non-standard properties & well-formed listener + * properties don't cause JDOUserException. + */ + public void testUnknownNonStandardPropertiesAndListeners() { + Properties p = new Properties(); + p.put("unknown.property", "value"); + p.put(new Object(), "value"); + p.put(Constants.PROPERTY_PREFIX_INSTANCE_LIFECYCLE_LISTENER + + "unknown.listener", "value"); + JDOImplHelper.assertOnlyKnownStandardProperties(p); } - Throwable[] nesteds = x.getNestedExceptions(); - - assertNotNull(nesteds); - assertEquals("should have been 2 nested exceptions", 2, nesteds.length); - for (int i = 0; i < nesteds.length; i++) { - Throwable t = nesteds[i]; - assertTrue( - "nested exception " + i + " should have been JDOUserException", - t instanceof JDOUserException); + /** + * Test that all JDO standard properties don't cause JDOUserException. + */ + public void testOnlyStandardProperties() { + Properties props = new Properties(); + for (String p : JDOImplHelper.USER_CONFIGURABLE_STANDARD_PROPERTIES) { + props.setProperty(p, p); + } + JDOImplHelper.assertOnlyKnownStandardProperties(props); } - } - - /** - * Test that unknown non-standard properties & well-formed listener properties don't cause - * JDOUserException. - */ - public void testUnknownNonStandardPropertiesAndListeners() { - Properties p = new Properties(); - p.put("unknown.property", "value"); - p.put(new Object(), "value"); - p.put(Constants.PROPERTY_PREFIX_INSTANCE_LIFECYCLE_LISTENER + "unknown.listener", "value"); - JDOImplHelper.assertOnlyKnownStandardProperties(p); - } - - /** Test that all JDO standard properties don't cause JDOUserException. */ - public void testOnlyStandardProperties() { - Properties props = new Properties(); - for (String p : JDOImplHelper.USER_CONFIGURABLE_STANDARD_PROPERTIES) { - props.setProperty(p, p); + + /** + * Test that an known standard property in mixed case succeeds. + */ + public void testKnownStandardPropertyThatDiffersInCaseOnly() { + Properties p = new Properties(); + p.setProperty("JaVaX.jDo.oPtIoN.CoNNectionDRiVerNamE", "value"); + p.setProperty("jAvAx.JdO.lIsTeNeR.InstaNceLifeCycleLisTener.foo.Bar", ""); + JDOImplHelper.assertOnlyKnownStandardProperties(p); } - JDOImplHelper.assertOnlyKnownStandardProperties(props); - } - - /** Test that an known standard property in mixed case succeeds. */ - public void testKnownStandardPropertyThatDiffersInCaseOnly() { - Properties p = new Properties(); - p.setProperty("JaVaX.jDo.oPtIoN.CoNNectionDRiVerNamE", "value"); - p.setProperty("jAvAx.JdO.lIsTeNeR.InstaNceLifeCycleLisTener.foo.Bar", ""); - JDOImplHelper.assertOnlyKnownStandardProperties(p); - } - - /** */ - class SimpleListener implements RegisterClassListener { /** */ - public void registerClass(RegisterClassEvent event) { - JDOImplHelperTest.this.event = event; + class SimpleListener implements RegisterClassListener { + + /** */ + public void registerClass(RegisterClassEvent event) { + JDOImplHelperTest.this.event = event; + } + } - } + } + diff --git a/api/src/test/java/javax/jdo/spi/StateInterrogationTest.java b/api/src/test/java/javax/jdo/spi/StateInterrogationTest.java index b06414938..bfbee55dc 100644 --- a/api/src/test/java/javax/jdo/spi/StateInterrogationTest.java +++ b/api/src/test/java/javax/jdo/spi/StateInterrogationTest.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,473 +19,520 @@ import java.lang.reflect.InvocationHandler; import java.lang.reflect.Proxy; + import javax.jdo.JDOHelper; import javax.jdo.PersistenceManager; + import javax.jdo.util.AbstractTest; import javax.jdo.util.BatchTestRunner; /** - * This class tests the StateInterrogation interface. The test is in several parts: - * - *

      - *
    • Add and remove the StateInterrogation instance - *
    • test interrogatives to return the correct answer - *
    • test getters to return the correct answer - *
    • test makeDirty to return. - *
    - * - * We use an mock implementation of StateInterrogation interface to log when calls are received and - * to return the correct replies. We use a java.lang.reflect.Proxy for the getPersistenceManager - * call because it's too much work to mock it. + * This class tests the StateInterrogation interface. The test is in + * several parts: + *
    • Add and remove the StateInterrogation instance + *
    • test interrogatives to return the correct answer + *
    • test getters to return the correct answer + *
    • test makeDirty to return. + *
    + * We use an mock implementation of StateInterrogation interface to + * log when calls are received and to return the correct replies. + * We use a java.lang.reflect.Proxy for the getPersistenceManager call + * because it's too much work to mock it. */ public class StateInterrogationTest extends AbstractTest { + + private JDOImplHelper implHelper = JDOImplHelper.getInstance(); - private JDOImplHelper implHelper = JDOImplHelper.getInstance(); - - /** Creates a new instance of StateInterrogationTest */ - public StateInterrogationTest() {} - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - BatchTestRunner.run(StateInterrogationTest.class); - } - - public void testGetObjectIdNull() { - Object id2 = JDOHelper.getObjectId(nbcpc2); - assertNull("ObjectId should be null before addStateInterrogations", id2); - addStateInterrogations(); - Object id = JDOHelper.getObjectId(Boolean.TRUE); - assertNull("ObjectId should be null for non-pc instances", id); - } - - public void testGetObjectId() { - addStateInterrogations(); - Object id2 = JDOHelper.getObjectId(nbcpc2); - assertNotNull("ObjectId should not be null", id2); - assertEquals("ObjectId should be 2", 2, id2.hashCode()); - Object id20 = JDOHelper.getObjectId(nbcpc2); - assertEquals("ObjectIds from same object should be equal", id2, id20); - } - - public void testRemoveStateInterrogation() { - addStateInterrogations(); - Object id2 = JDOHelper.getObjectId(nbcpc2); - assertNotNull("ObjectId should not be null", id2); - assertEquals("ObjectId should be 2", 2, id2.hashCode()); - implHelper.removeStateInterrogation(si2); - implHelper.removeStateInterrogation(si0); - Object id21 = JDOHelper.getObjectId(nbcpc2); - assertNull("ObjectId should be null after RemoveStateInterrogation", id21); - Object id1 = JDOHelper.getObjectId(nbcpc1); - assertNotNull("ObjectId should not be null", id1); - assertEquals("ObjectId should be 1", 1, id1.hashCode()); - } - - public void testGetTransactionalObjectIdNull() { - Object id2 = JDOHelper.getTransactionalObjectId(nbcpc2); - assertNull("TransactionalObjectId should be null before addStateInterrogations", id2); - addStateInterrogations(); - Object id = JDOHelper.getTransactionalObjectId(Boolean.TRUE); - assertNull("TransactionalObjectId should be null for non-pc instances", id); - } - - public void testGetTransactionalObjectId() { - addStateInterrogations(); - Object id2 = JDOHelper.getTransactionalObjectId(nbcpc2); - assertNotNull("TransactionalObjectId should not be null", id2); - assertEquals("TransactionalObjectId should be 2", 2, id2.hashCode()); - Object id20 = JDOHelper.getTransactionalObjectId(nbcpc2); - assertEquals("TransactionalObjectIds from same object should be equal", id2, id20); - } - - public void testGetPersistenceManagerNull() { - Object pm2 = JDOHelper.getPersistenceManager(nbcpc2); - assertNull("PersistenceManager should be null before addStateInterrogations", pm2); - addStateInterrogations(); - Object pm = JDOHelper.getPersistenceManager(Boolean.TRUE); - assertNull("PersistenceManager should be null for non-pc instances", pm); - } - - public void testGetPersistenceManager() { - addStateInterrogations(); - Object pm2 = JDOHelper.getPersistenceManager(nbcpc2); - assertNotNull("PersistenceManager should not be null", pm2); - assertEquals("PersistenceManager should be 2", 2, pm2.hashCode()); - Object pm20 = JDOHelper.getPersistenceManager(nbcpc2); - assertEquals("PersistenceManagers from same object should be equal", pm2, pm20); - } - - public void testGetVersionNull() { - Object id2 = JDOHelper.getVersion(nbcpc2); - assertNull("Version should be null before addStateInterrogations", id2); - addStateInterrogations(); - Object id = JDOHelper.getVersion(Boolean.TRUE); - assertNull("Version should be null for non-pc instances", id); - } - - public void testGetVersion() { - addStateInterrogations(); - Object id2 = JDOHelper.getVersion(nbcpc2); - assertNotNull("Version should not be null", id2); - assertEquals("Version should be 2", 2, id2.hashCode()); - Object id20 = JDOHelper.getVersion(nbcpc2); - assertEquals("Versions from same object should be equal", id2, id20); - } - - public void testIsDeletedFalse() { - assertFalse( - "IsDeleted should be false before addStateInterrogations", JDOHelper.isDeleted(nbcpc2)); - addStateInterrogations(); - assertFalse( - "IsDeleted should be false for non-pc instances", JDOHelper.isDeleted(Boolean.TRUE)); - implHelper.removeStateInterrogation(si2); - assertFalse( - "IsDeleted should be false after removeStateInterrogations", JDOHelper.isDeleted(nbcpc2)); - } - - public void testIsDeletedMine() { - addStateInterrogations(); - assertTrue("IsDeleted should be true for nbcpc1", JDOHelper.isDeleted(nbcpc1)); - assertFalse("IsDeleted should be false for nbcpc2", JDOHelper.isDeleted(nbcpc2)); - } - - public void testIsDetachedFalse() { - assertFalse( - "IsDetached should be false before addStateInterrogations", JDOHelper.isDetached(nbcpc2)); - addStateInterrogations(); - assertFalse( - "IsDetached should be false for non-pc instances", JDOHelper.isDetached(Boolean.TRUE)); - implHelper.removeStateInterrogation(si2); - assertFalse( - "IsDetached should be false after removeStateInterrogations", JDOHelper.isDetached(nbcpc2)); - } - - public void testIsDetachedMine() { - addStateInterrogations(); - assertTrue("IsDetached should be true for nbcpc1", JDOHelper.isDetached(nbcpc1)); - assertFalse("IsDetached should be false for nbcpc2", JDOHelper.isDetached(nbcpc2)); - } - - public void testIsDirtyFalse() { - assertFalse("IsDirty should be false before addStateInterrogations", JDOHelper.isDirty(nbcpc2)); - addStateInterrogations(); - assertFalse("IsDirty should be false for non-pc instances", JDOHelper.isDirty(Boolean.TRUE)); - implHelper.removeStateInterrogation(si2); - nbcpc2.setDirty(true); - assertFalse( - "IsDirty should be false after removeStateInterrogations", JDOHelper.isDirty(nbcpc2)); - nbcpc2.setDirty(false); - } - - public void testIsDirtyMine() { - addStateInterrogations(); - nbcpc1.setDirty(true); - assertTrue("IsDirty should be true for nbcpc1 after setDirty(true)", JDOHelper.isDirty(nbcpc1)); - nbcpc1.setDirty(false); - assertFalse( - "IsDirty should be false for nbcpc1 after setDirty(false)", JDOHelper.isDirty(nbcpc1)); - assertFalse("IsDirty should be false for nbcpc2", JDOHelper.isDirty(nbcpc2)); - } - - public void testIsNewFalse() { - assertFalse("IsNew should be false before addStateInterrogations", JDOHelper.isNew(nbcpc2)); - addStateInterrogations(); - assertFalse("IsNew should be false for non-pc instances", JDOHelper.isNew(Boolean.TRUE)); - implHelper.removeStateInterrogation(si2); - assertFalse("IsNew should be false after removeStateInterrogations", JDOHelper.isNew(nbcpc2)); - } - - public void testIsNewMine() { - addStateInterrogations(); - assertTrue("IsNew should be true for nbcpc1", JDOHelper.isNew(nbcpc1)); - assertFalse("IsNew should be false for nbcpc2", JDOHelper.isNew(nbcpc2)); - } - - public void testIsPersistentFalse() { - assertFalse( - "IsPersistent should be false before addStateInterrogations", - JDOHelper.isPersistent(nbcpc2)); - addStateInterrogations(); - assertFalse( - "IsPersistent should be false for non-pc instances", JDOHelper.isPersistent(Boolean.TRUE)); - implHelper.removeStateInterrogation(si2); - assertFalse( - "IsPersistent should be false after removeStateInterrogations", - JDOHelper.isPersistent(nbcpc2)); - } - - public void testIsPersistentMine() { - addStateInterrogations(); - assertTrue("IsPersistent should be true for nbcpc1", JDOHelper.isPersistent(nbcpc1)); - assertFalse("IsPersistent should be false for nbcpc2", JDOHelper.isPersistent(nbcpc2)); - } - - public void testIsTransactionalFalse() { - assertFalse( - "IsTransactional should be false before addStateInterrogations", - JDOHelper.isTransactional(nbcpc2)); - addStateInterrogations(); - assertFalse( - "IsTransactional should be false for non-pc instances", - JDOHelper.isTransactional(Boolean.TRUE)); - implHelper.removeStateInterrogation(si2); - assertFalse( - "IsTransactional should be false after removeStateInterrogations", - JDOHelper.isTransactional(nbcpc2)); - } - - public void testIsTransactionalMine() { - addStateInterrogations(); - assertTrue("IsTransactional should be true for nbcpc1", JDOHelper.isTransactional(nbcpc1)); - assertFalse("IsTransactional should be false for nbcpc2", JDOHelper.isTransactional(nbcpc2)); - } - - public void testMakeDirtyFalse() { - JDOHelper.makeDirty(nbcpc2, ""); - nbcpc2.setDirty(true); - assertFalse("IsDirty should be false before addStateInterrogations", JDOHelper.isDirty(nbcpc2)); - addStateInterrogations(); - implHelper.removeStateInterrogation(si2); - nbcpc2.setDirty(false); - JDOHelper.makeDirty(nbcpc2, ""); - assertFalse( - "IsDirty should be false after removeStateInterrogations", JDOHelper.isDirty(nbcpc2)); - } - - public void testMakeDirtyMine() { - addStateInterrogations(); - JDOHelper.makeDirty(nbcpc1, ""); - assertTrue("IsDirty should be true for nbcpc1", JDOHelper.isDirty(nbcpc1)); - nbcpc1.setDirty(false); - assertFalse("IsDirty should be false after setDirty(false)", JDOHelper.isDirty(nbcpc1)); - } - - public void tearDown() { - removeStateInterrogations(); - } - - public void addStateInterrogations() { - implHelper.addStateInterrogation(si0); - implHelper.addStateInterrogation(si1); - implHelper.addStateInterrogation(si2); - } - - public void removeStateInterrogations() { - implHelper.removeStateInterrogation(si0); - implHelper.removeStateInterrogation(si1); - implHelper.removeStateInterrogation(si2); - } - - /** The non-binary-compatible PersistenceManager class instances. */ - private static PersistenceManager pmProxy0 = - (PersistenceManager) - Proxy.newProxyInstance( - PersistenceManager.class.getClassLoader(), - new Class[] {PersistenceManager.class}, - new InvocationHandlerImpl(0)); - - /** The non-binary-compatible PersistenceManager class instances. */ - private static PersistenceManager pmProxy1 = - (PersistenceManager) - Proxy.newProxyInstance( - PersistenceManager.class.getClassLoader(), - new Class[] {PersistenceManager.class}, - new InvocationHandlerImpl(1)); - - /** The non-binary-compatible PersistenceManager class instances. */ - private static PersistenceManager pmProxy2 = - (PersistenceManager) - Proxy.newProxyInstance( - PersistenceManager.class.getClassLoader(), - new Class[] {PersistenceManager.class}, - new InvocationHandlerImpl(2)); - - /** The array of PersistenceManager proxies */ - static PersistenceManager[] pmProxies = {pmProxy0, pmProxy1, pmProxy2}; - - /** The array of NonBinaryCompatiblePersistenceCapable instances. */ - NonBinaryCompatiblePersistenceCapable nbcpc0 = new NonBinaryCompatiblePersistenceCapable(0); - - NonBinaryCompatiblePersistenceCapable nbcpc1 = new NonBinaryCompatiblePersistenceCapable(1); - NonBinaryCompatiblePersistenceCapable nbcpc2 = new NonBinaryCompatiblePersistenceCapable(2); - - NonBinaryCompatiblePersistenceCapable[] nbcpcs = {nbcpc0, nbcpc1, nbcpc2}; - - /** The array of StateInterrogations */ - static StateInterrogation si0 = new StateInterrogationImpl(0); - - static StateInterrogation si1 = new StateInterrogationImpl(1); - static StateInterrogation si2 = new StateInterrogationImpl(2); - static StateInterrogation[] sis = {si0, si1, si2}; - - /** - * The StateInterrogation implementation manages NonBinaryCompatiblePersistenceCapable instances - * that have a hashCode equal to their own. - * - *

    For the methods returning Object, return null if the object is not managed by this - * StateInterrogation. - * - *

    For the methods returning Boolean, return null if the object is not managed by this - * StateInterrogation. - * - *

    For the makeDirty method, return false if the object is not managed by this - * StateInterrogation. - */ - private static class StateInterrogationImpl implements StateInterrogation { - - private int id; - - public int hashCode() { - return id; + /** Creates a new instance of StateInterrogationTest */ + public StateInterrogationTest() { } - - private StateInterrogationImpl(int id) { - this.id = id; + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + BatchTestRunner.run(StateInterrogationTest.class); } - - public boolean equals(Object other) { - if (other.getClass() != StateInterrogationImpl.class) return false; - return (other.hashCode() == id); + + public void testGetObjectIdNull() { + Object id2 = JDOHelper.getObjectId(nbcpc2); + assertNull("ObjectId should be null before addStateInterrogations", + id2); + addStateInterrogations(); + Object id = JDOHelper.getObjectId(Boolean.TRUE); + assertNull("ObjectId should be null for non-pc instances", + id); } - private boolean isMine(Object pc) { - return pc.hashCode() == id; + public void testGetObjectId() { + addStateInterrogations(); + Object id2 = JDOHelper.getObjectId(nbcpc2); + assertNotNull("ObjectId should not be null", + id2); + assertEquals("ObjectId should be 2", + 2, id2.hashCode()); + Object id20 = JDOHelper.getObjectId(nbcpc2); + assertEquals("ObjectIds from same object should be equal", + id2, id20); } - public javax.jdo.PersistenceManager getPersistenceManager(Object pc) { - return isMine(pc) ? pmProxies[id] : null; + public void testRemoveStateInterrogation() { + addStateInterrogations(); + Object id2 = JDOHelper.getObjectId(nbcpc2); + assertNotNull("ObjectId should not be null", + id2); + assertEquals("ObjectId should be 2", + 2, id2.hashCode()); + implHelper.removeStateInterrogation(si2); + implHelper.removeStateInterrogation(si0); + Object id21 = JDOHelper.getObjectId(nbcpc2); + assertNull("ObjectId should be null after RemoveStateInterrogation", + id21); + Object id1 = JDOHelper.getObjectId(nbcpc1); + assertNotNull("ObjectId should not be null", + id1); + assertEquals("ObjectId should be 1", + 1, id1.hashCode()); } - public Object getObjectId(Object pc) { - return isMine(pc) ? new ObjectIdImpl(id) : null; + public void testGetTransactionalObjectIdNull() { + Object id2 = JDOHelper.getTransactionalObjectId(nbcpc2); + assertNull("TransactionalObjectId should be null before addStateInterrogations", + id2); + addStateInterrogations(); + Object id = JDOHelper.getTransactionalObjectId(Boolean.TRUE); + assertNull("TransactionalObjectId should be null for non-pc instances", + id); } - public Object getTransactionalObjectId(Object pc) { - return isMine(pc) ? new ObjectIdImpl(id) : null; + public void testGetTransactionalObjectId() { + addStateInterrogations(); + Object id2 = JDOHelper.getTransactionalObjectId(nbcpc2); + assertNotNull("TransactionalObjectId should not be null", + id2); + assertEquals("TransactionalObjectId should be 2", + 2, id2.hashCode()); + Object id20 = JDOHelper.getTransactionalObjectId(nbcpc2); + assertEquals("TransactionalObjectIds from same object should be equal", + id2, id20); } - public Object getVersion(Object pc) { - return isMine(pc) ? new ObjectIdImpl(id) : null; + public void testGetPersistenceManagerNull() { + Object pm2 = JDOHelper.getPersistenceManager(nbcpc2); + assertNull("PersistenceManager should be null before addStateInterrogations", + pm2); + addStateInterrogations(); + Object pm = JDOHelper.getPersistenceManager(Boolean.TRUE); + assertNull("PersistenceManager should be null for non-pc instances", + pm); } - public Boolean isDeleted(Object pc) { - if (isMine(pc)) { - return (pc.hashCode() == 1) ? Boolean.TRUE : Boolean.FALSE; - } else return null; + public void testGetPersistenceManager() { + addStateInterrogations(); + Object pm2 = JDOHelper.getPersistenceManager(nbcpc2); + assertNotNull("PersistenceManager should not be null", + pm2); + assertEquals("PersistenceManager should be 2", + 2, pm2.hashCode()); + Object pm20 = JDOHelper.getPersistenceManager(nbcpc2); + assertEquals("PersistenceManagers from same object should be equal", + pm2, pm20); } - public Boolean isDetached(Object pc) { - if (isMine(pc)) { - return (pc.hashCode() == 1) ? Boolean.TRUE : Boolean.FALSE; - } else return null; + public void testGetVersionNull() { + Object id2 = JDOHelper.getVersion(nbcpc2); + assertNull("Version should be null before addStateInterrogations", + id2); + addStateInterrogations(); + Object id = JDOHelper.getVersion(Boolean.TRUE); + assertNull("Version should be null for non-pc instances", + id); } - public Boolean isDirty(Object pc) { - if (isMine(pc)) { - return ((NonBinaryCompatiblePersistenceCapable) pc).isDirty() - ? Boolean.TRUE - : Boolean.FALSE; - } else return null; + public void testGetVersion() { + addStateInterrogations(); + Object id2 = JDOHelper.getVersion(nbcpc2); + assertNotNull("Version should not be null", + id2); + assertEquals("Version should be 2", + 2, id2.hashCode()); + Object id20 = JDOHelper.getVersion(nbcpc2); + assertEquals("Versions from same object should be equal", + id2, id20); } - public Boolean isNew(Object pc) { - if (isMine(pc)) { - return (pc.hashCode() == 1) ? Boolean.TRUE : Boolean.FALSE; - } else return null; + public void testIsDeletedFalse() { + assertFalse("IsDeleted should be false before addStateInterrogations", + JDOHelper.isDeleted(nbcpc2)); + addStateInterrogations(); + assertFalse("IsDeleted should be false for non-pc instances", + JDOHelper.isDeleted(Boolean.TRUE)); + implHelper.removeStateInterrogation(si2); + assertFalse("IsDeleted should be false after removeStateInterrogations", + JDOHelper.isDeleted(nbcpc2)); } - public Boolean isPersistent(Object pc) { - if (isMine(pc)) { - return (pc.hashCode() == 1) ? Boolean.TRUE : Boolean.FALSE; - } else return null; + public void testIsDeletedMine() { + addStateInterrogations(); + assertTrue("IsDeleted should be true for nbcpc1", + JDOHelper.isDeleted(nbcpc1)); + assertFalse("IsDeleted should be false for nbcpc2", + JDOHelper.isDeleted(nbcpc2)); } - public Boolean isTransactional(Object pc) { - if (isMine(pc)) { - return (pc.hashCode() == 1) ? Boolean.TRUE : Boolean.FALSE; - } else return null; + public void testIsDetachedFalse() { + assertFalse("IsDetached should be false before addStateInterrogations", + JDOHelper.isDetached(nbcpc2)); + addStateInterrogations(); + assertFalse("IsDetached should be false for non-pc instances", + JDOHelper.isDetached(Boolean.TRUE)); + implHelper.removeStateInterrogation(si2); + assertFalse("IsDetached should be false after removeStateInterrogations", + JDOHelper.isDetached(nbcpc2)); } - public boolean makeDirty(Object pc, String fieldName) { - if (isMine(pc)) { - ((NonBinaryCompatiblePersistenceCapable) pc).setDirty(true); - return true; - } else return false; + public void testIsDetachedMine() { + addStateInterrogations(); + assertTrue("IsDetached should be true for nbcpc1", + JDOHelper.isDetached(nbcpc1)); + assertFalse("IsDetached should be false for nbcpc2", + JDOHelper.isDetached(nbcpc2)); } - } - - /** The non-binary-compatible PersistenceCapable class. */ - public static class NonBinaryCompatiblePersistenceCapable { - private int id; - private boolean dirty = false; - private NonBinaryCompatiblePersistenceCapable(int id) { - this.id = id; + public void testIsDirtyFalse() { + assertFalse("IsDirty should be false before addStateInterrogations", + JDOHelper.isDirty(nbcpc2)); + addStateInterrogations(); + assertFalse("IsDirty should be false for non-pc instances", + JDOHelper.isDirty(Boolean.TRUE)); + implHelper.removeStateInterrogation(si2); + nbcpc2.setDirty(true); + assertFalse("IsDirty should be false after removeStateInterrogations", + JDOHelper.isDirty(nbcpc2)); + nbcpc2.setDirty(false); } - public int hashCode() { - return id; + public void testIsDirtyMine() { + addStateInterrogations(); + nbcpc1.setDirty(true); + assertTrue("IsDirty should be true for nbcpc1 after setDirty(true)", + JDOHelper.isDirty(nbcpc1)); + nbcpc1.setDirty(false); + assertFalse("IsDirty should be false for nbcpc1 after setDirty(false)", + JDOHelper.isDirty(nbcpc1)); + assertFalse("IsDirty should be false for nbcpc2", + JDOHelper.isDirty(nbcpc2)); } - public void setDirty(boolean dirty) { - this.dirty = dirty; + public void testIsNewFalse() { + assertFalse("IsNew should be false before addStateInterrogations", + JDOHelper.isNew(nbcpc2)); + addStateInterrogations(); + assertFalse("IsNew should be false for non-pc instances", + JDOHelper.isNew(Boolean.TRUE)); + implHelper.removeStateInterrogation(si2); + assertFalse("IsNew should be false after removeStateInterrogations", + JDOHelper.isNew(nbcpc2)); } - public boolean isDirty() { - return dirty; + public void testIsNewMine() { + addStateInterrogations(); + assertTrue("IsNew should be true for nbcpc1", + JDOHelper.isNew(nbcpc1)); + assertFalse("IsNew should be false for nbcpc2", + JDOHelper.isNew(nbcpc2)); } - } - /** The non-binary-compatible object id class. */ - public static class ObjectIdImpl { - private int id; - - private ObjectIdImpl(int id) { - this.id = id; + public void testIsPersistentFalse() { + assertFalse("IsPersistent should be false before addStateInterrogations", + JDOHelper.isPersistent(nbcpc2)); + addStateInterrogations(); + assertFalse("IsPersistent should be false for non-pc instances", + JDOHelper.isPersistent(Boolean.TRUE)); + implHelper.removeStateInterrogation(si2); + assertFalse("IsPersistent should be false after removeStateInterrogations", + JDOHelper.isPersistent(nbcpc2)); } - public int hashCode() { - return id; + public void testIsPersistentMine() { + addStateInterrogations(); + assertTrue("IsPersistent should be true for nbcpc1", + JDOHelper.isPersistent(nbcpc1)); + assertFalse("IsPersistent should be false for nbcpc2", + JDOHelper.isPersistent(nbcpc2)); } - public boolean equals(Object other) { - if (other.getClass() != ObjectIdImpl.class) return false; - return (other.hashCode() == id); + public void testIsTransactionalFalse() { + assertFalse("IsTransactional should be false before addStateInterrogations", + JDOHelper.isTransactional(nbcpc2)); + addStateInterrogations(); + assertFalse("IsTransactional should be false for non-pc instances", + JDOHelper.isTransactional(Boolean.TRUE)); + implHelper.removeStateInterrogation(si2); + assertFalse("IsTransactional should be false after removeStateInterrogations", + JDOHelper.isTransactional(nbcpc2)); } - } - - /** The non-binary-compatible InvocationHandler class for PersistenceManager proxy. */ - private static class InvocationHandlerImpl implements InvocationHandler { - private int id; - private InvocationHandlerImpl(int id) { - this.id = id; + public void testIsTransactionalMine() { + addStateInterrogations(); + assertTrue("IsTransactional should be true for nbcpc1", + JDOHelper.isTransactional(nbcpc1)); + assertFalse("IsTransactional should be false for nbcpc2", + JDOHelper.isTransactional(nbcpc2)); } - public int hashCode() { - return id; + public void testMakeDirtyFalse() { + JDOHelper.makeDirty(nbcpc2, ""); + nbcpc2.setDirty(true); + assertFalse("IsDirty should be false before addStateInterrogations", + JDOHelper.isDirty(nbcpc2)); + addStateInterrogations(); + implHelper.removeStateInterrogation(si2); + nbcpc2.setDirty(false); + JDOHelper.makeDirty(nbcpc2, ""); + assertFalse("IsDirty should be false after removeStateInterrogations", + JDOHelper.isDirty(nbcpc2)); } - public boolean equals(Object other) { - if (other.getClass() != ObjectIdImpl.class) return false; - return (other.hashCode() == id); + public void testMakeDirtyMine() { + addStateInterrogations(); + JDOHelper.makeDirty(nbcpc1, ""); + assertTrue("IsDirty should be true for nbcpc1", JDOHelper.isDirty(nbcpc1)); + nbcpc1.setDirty(false); + assertFalse("IsDirty should be false after setDirty(false)", + JDOHelper.isDirty(nbcpc1)); } - public Object invoke(Object obj, java.lang.reflect.Method method, Object[] params) - throws Throwable { - String name = method.getName(); - if (name == "hashCode") { - return Integer.valueOf(id); - } else if (name == "equals") { - Object other = params[0]; - if (!(other instanceof PersistenceManager)) return Boolean.FALSE; - int otherid = Proxy.getInvocationHandler(other).hashCode(); - if (otherid == id) return Boolean.TRUE; - return Boolean.FALSE; - } - return null; + public void tearDown() { + removeStateInterrogations(); + } + + public void addStateInterrogations() { + implHelper.addStateInterrogation(si0); + implHelper.addStateInterrogation(si1); + implHelper.addStateInterrogation(si2); + } + + public void removeStateInterrogations() { + implHelper.removeStateInterrogation(si0); + implHelper.removeStateInterrogation(si1); + implHelper.removeStateInterrogation(si2); + } + + /** + * The non-binary-compatible PersistenceManager class instances. + */ + static private PersistenceManager pmProxy0 = (PersistenceManager) + Proxy.newProxyInstance( + PersistenceManager.class.getClassLoader(), + new Class[] {PersistenceManager.class}, + new InvocationHandlerImpl(0)); + + /** + * The non-binary-compatible PersistenceManager class instances. + */ + static private PersistenceManager pmProxy1 = (PersistenceManager) + Proxy.newProxyInstance( + PersistenceManager.class.getClassLoader(), + new Class[] {PersistenceManager.class}, + new InvocationHandlerImpl(1)); + + /** + * The non-binary-compatible PersistenceManager class instances. + */ + static private PersistenceManager pmProxy2 = (PersistenceManager) + Proxy.newProxyInstance( + PersistenceManager.class.getClassLoader(), + new Class[] {PersistenceManager.class}, + new InvocationHandlerImpl(2)); + + /** + * The array of PersistenceManager proxies + */ + static PersistenceManager[] pmProxies = {pmProxy0, pmProxy1, pmProxy2}; + + /** + * The array of NonBinaryCompatiblePersistenceCapable instances. + */ + NonBinaryCompatiblePersistenceCapable nbcpc0 = + new NonBinaryCompatiblePersistenceCapable(0); + NonBinaryCompatiblePersistenceCapable nbcpc1 = + new NonBinaryCompatiblePersistenceCapable(1); + NonBinaryCompatiblePersistenceCapable nbcpc2 = + new NonBinaryCompatiblePersistenceCapable(2); + + NonBinaryCompatiblePersistenceCapable[] nbcpcs = {nbcpc0, nbcpc1, nbcpc2}; + + /** + * The array of StateInterrogations + */ + static StateInterrogation si0 = new StateInterrogationImpl(0); + static StateInterrogation si1 = new StateInterrogationImpl(1); + static StateInterrogation si2 = new StateInterrogationImpl(2); + static StateInterrogation[] sis = {si0, si1, si2}; + + /** + * The StateInterrogation implementation manages + * NonBinaryCompatiblePersistenceCapable instances that have a + * hashCode equal to their own. + * + *

    For the methods returning Object, return null if the object + * is not managed by this StateInterrogation. + * + *

    For the methods returning Boolean, return null if the object + * is not managed by this StateInterrogation. + * + *

    For the makeDirty method, return false if the object + * is not managed by this StateInterrogation. + */ + private static class StateInterrogationImpl implements StateInterrogation { + + private int id; + + public int hashCode() { + return id; + } + + private StateInterrogationImpl(int id) { + this.id = id; + } + + public boolean equals(Object other) { + if (other.getClass() != StateInterrogationImpl.class) return false; + return (other.hashCode() == id); + } + + private boolean isMine(Object pc) { + return pc.hashCode() == id; + } + + public javax.jdo.PersistenceManager getPersistenceManager(Object pc) { + return isMine(pc)?pmProxies[id]:null; + } + + public Object getObjectId(Object pc) { + return isMine(pc)?new ObjectIdImpl(id):null; + } + + public Object getTransactionalObjectId(Object pc) { + return isMine(pc)?new ObjectIdImpl(id):null; + } + + public Object getVersion(Object pc) { + return isMine(pc)?new ObjectIdImpl(id):null; + } + + public Boolean isDeleted(Object pc) { + if (isMine(pc)) { + return (pc.hashCode()==1)?Boolean.TRUE:Boolean.FALSE; + } else return null; + } + + public Boolean isDetached(Object pc) { + if (isMine(pc)) { + return (pc.hashCode()==1)?Boolean.TRUE:Boolean.FALSE; + } else return null; + } + + public Boolean isDirty(Object pc) { + if (isMine(pc)) { + return ((NonBinaryCompatiblePersistenceCapable)pc).isDirty() + ?Boolean.TRUE:Boolean.FALSE; + } else return null; + } + + public Boolean isNew(Object pc) { + if (isMine(pc)) { + return (pc.hashCode()==1)?Boolean.TRUE:Boolean.FALSE; + } else return null; + } + + public Boolean isPersistent(Object pc) { + if (isMine(pc)) { + return (pc.hashCode()==1)?Boolean.TRUE:Boolean.FALSE; + } else return null; + } + + public Boolean isTransactional(Object pc) { + if (isMine(pc)) { + return (pc.hashCode()==1)?Boolean.TRUE:Boolean.FALSE; + } else return null; + } + + public boolean makeDirty(Object pc, String fieldName) { + if (isMine(pc)) { + ((NonBinaryCompatiblePersistenceCapable)pc).setDirty(true); + return true; + } else return false; + } + } + + /** + * The non-binary-compatible PersistenceCapable class. + */ + public static class NonBinaryCompatiblePersistenceCapable { + private int id; + private boolean dirty = false; + private NonBinaryCompatiblePersistenceCapable(int id) { + this.id = id; + } + public int hashCode() { + return id; + } + public void setDirty(boolean dirty) { + this.dirty = dirty; + } + public boolean isDirty() { + return dirty; + } + } + + /** + * The non-binary-compatible object id class. + */ + public static class ObjectIdImpl { + private int id; + private ObjectIdImpl(int id) { + this.id = id; + } + public int hashCode() { + return id; + } + public boolean equals(Object other) { + if (other.getClass() != ObjectIdImpl.class) return false; + return (other.hashCode() == id); + } + } + + /** + * The non-binary-compatible InvocationHandler class + * for PersistenceManager proxy. + */ + private static class InvocationHandlerImpl implements InvocationHandler { + private int id; + private InvocationHandlerImpl(int id) { + this.id = id; + } + public int hashCode() { + return id; + } + public boolean equals(Object other) { + if (other.getClass() != ObjectIdImpl.class) return false; + return (other.hashCode() == id); + } + public Object invoke(Object obj, java.lang.reflect.Method method, + Object[] params) throws Throwable { + String name = method.getName(); + if (name == "hashCode") { + return Integer.valueOf(id); + } else if (name == "equals") { + Object other = params[0]; + if (!(other instanceof PersistenceManager)) return Boolean.FALSE; + int otherid = Proxy.getInvocationHandler(other).hashCode(); + if (otherid == id) return Boolean.TRUE; + return Boolean.FALSE; + } + return null; + } } - } -} +} \ No newline at end of file diff --git a/api/src/test/java/javax/jdo/stub/StubPMF.java b/api/src/test/java/javax/jdo/stub/StubPMF.java index bba259f8a..b903fafd5 100644 --- a/api/src/test/java/javax/jdo/stub/StubPMF.java +++ b/api/src/test/java/javax/jdo/stub/StubPMF.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -21,6 +21,7 @@ import java.util.Map; import java.util.Properties; import java.util.Set; + import javax.jdo.Constants; import javax.jdo.FetchGroup; import javax.jdo.PersistenceManager; @@ -32,513 +33,533 @@ public class StubPMF implements PersistenceManagerFactory, Constants { - private static final long serialVersionUID = 488698916248368422L; - - public static PersistenceManagerFactory getPersistenceManagerFactory(Map props) { - - StubPMF pmf = new StubPMF(); - - pmf.setProperties(props); - - for (Object key : props.keySet()) { - if (!(key instanceof String)) { - continue; - } - String prop = (String) key; - if (!prop.startsWith("javax.jdo.")) { - continue; - } - pmf.setProperty(prop, props.get(prop)); - } - - return pmf; - } - - public static PersistenceManagerFactory getPersistenceManagerFactory(Map overrides, Map props) { - - StubPMF pmf = new StubPMF(); - - pmf.setProperties(props); - pmf.setProperties(overrides); - - return pmf; - } - - String name; - String persistenceManagerFactoryClassName; - String spiResourceName; - String optionConnectionUserName; - String optionConnectionPassword; - String optionConnectionURL; - String optionConnectionDriverName; - String optionConnectionFactoryName; - Object optionConnectionFactory; - String optionConnectionFactory2Name; - Object optionConnectionFactory2; - boolean optionMultithreaded; - String optionMapping; - boolean optionOptimistic; - boolean optionRetainValues; - boolean optionRestoreValues; - boolean optionNontransactionalRead; - boolean optionNontransactionalWrite; - boolean optionIgnoreCache; - boolean optionDetachAllOnCommit; - boolean optionCopyOnAttach; - String optionName; - String optionPersistenceUnitName; - String optionServerTimeZoneID; - String optionTransactionType; - boolean optionReadOnly; - String optionTransactionIsolationLevel; - Integer optionDatastoreReadTimeoutMillis; - Integer optionDatastoreWriteTimeoutMillis; - - Properties properties = new Properties(); - - public String getConnectionUserName() { - return optionConnectionUserName; - } - - public void setConnectionUserName(String connectionUserName) { - this.optionConnectionUserName = connectionUserName; - } - - public void setConnectionPassword(String connectionPassword) { - this.optionConnectionPassword = connectionPassword; - } - - public String getConnectionURL() { - return optionConnectionURL; - } - - public void setConnectionURL(String connectionURL) { - this.optionConnectionURL = connectionURL; - } - - public String getConnectionDriverName() { - return optionConnectionDriverName; - } - - public void setConnectionDriverName(String connectionDriverName) { - this.optionConnectionDriverName = connectionDriverName; - } - - public String getConnectionFactoryName() { - return optionConnectionFactoryName; - } - - public void setConnectionFactoryName(String connectionFactoryName) { - this.optionConnectionFactoryName = connectionFactoryName; - } - - public Object getConnectionFactory() { - return optionConnectionFactory; - } - - public void setConnectionFactory(Object connectionFactory) { - this.optionConnectionFactory = connectionFactory; - } - - public String getConnectionFactory2Name() { - return optionConnectionFactory2Name; - } - - public void setConnectionFactory2Name(String connectionFactory2Name) { - this.optionConnectionFactory2Name = connectionFactory2Name; - } - - public Object getConnectionFactory2() { - return optionConnectionFactory2; - } - - public void setConnectionFactory2(Object connectionFactory2) { - this.optionConnectionFactory2 = connectionFactory2; - } - - public boolean getMultithreaded() { - return optionMultithreaded; - } - - public void setMultithreaded(boolean multithreaded) { - this.optionMultithreaded = multithreaded; - } - - public String getMapping() { - return optionMapping; - } - - public void setMapping(String mapping) { - this.optionMapping = mapping; - } - - public boolean getOptimistic() { - return optionOptimistic; - } - - public void setOptimistic(boolean optimistic) { - this.optionOptimistic = optimistic; - } - - public boolean getRetainValues() { - return optionRetainValues; - } - - public void setRetainValues(boolean retainValues) { - this.optionRetainValues = retainValues; - } - - public boolean getRestoreValues() { - return optionRestoreValues; - } - - public void setRestoreValues(boolean restoreValues) { - this.optionRestoreValues = restoreValues; - } - - public boolean getNontransactionalRead() { - return optionNontransactionalRead; - } - - public void setNontransactionalRead(boolean nontransactionalRead) { - this.optionNontransactionalRead = nontransactionalRead; - } - - public boolean getNontransactionalWrite() { - return optionNontransactionalWrite; - } - - public void setNontransactionalWrite(boolean nontransactionalWrite) { - this.optionNontransactionalWrite = nontransactionalWrite; - } - - public boolean getIgnoreCache() { - return optionIgnoreCache; - } + private static final long serialVersionUID = 488698916248368422L; - public void setIgnoreCache(boolean ignoreCache) { - this.optionIgnoreCache = ignoreCache; - } + public static PersistenceManagerFactory getPersistenceManagerFactory( + Map props) { - public boolean getDetachAllOnCommit() { - return optionDetachAllOnCommit; - } + StubPMF pmf = new StubPMF(); - public void setDetachAllOnCommit(boolean detachAllOnCommit) { - this.optionDetachAllOnCommit = detachAllOnCommit; - } + pmf.setProperties(props); - public boolean getCopyOnAttach() { - return optionCopyOnAttach; - } + for (Object key : props.keySet()) { + if (!(key instanceof String)) { + continue; + } + String prop = (String) key; + if (!prop.startsWith("javax.jdo.")) { + continue; + } + pmf.setProperty(prop, props.get(prop)); + } - public void setCopyOnAttach(boolean copyOnAttach) { - this.optionCopyOnAttach = copyOnAttach; - } - - public String getName() { - return optionName; - } + return pmf; + } - public void setName(String name) { - this.optionName = name; - } + public static PersistenceManagerFactory getPersistenceManagerFactory( + Map overrides, Map props) { - public String getPersistenceUnitName() { - return optionPersistenceUnitName; - } + StubPMF pmf = new StubPMF(); - public void setPersistenceUnitName(String persistenceUnitName) { - this.optionPersistenceUnitName = persistenceUnitName; - } + pmf.setProperties(props); + pmf.setProperties(overrides); - public String getServerTimeZoneID() { - return optionServerTimeZoneID; - } + return pmf; + } - public void setServerTimeZoneID(String serverTimeZoneID) { - this.optionServerTimeZoneID = serverTimeZoneID; - } + String name; + String persistenceManagerFactoryClassName; + String spiResourceName; + String optionConnectionUserName; + String optionConnectionPassword; + String optionConnectionURL; + String optionConnectionDriverName; + String optionConnectionFactoryName; + Object optionConnectionFactory; + String optionConnectionFactory2Name; + Object optionConnectionFactory2; + boolean optionMultithreaded; + String optionMapping; + boolean optionOptimistic; + boolean optionRetainValues; + boolean optionRestoreValues; + boolean optionNontransactionalRead; + boolean optionNontransactionalWrite; + boolean optionIgnoreCache; + boolean optionDetachAllOnCommit; + boolean optionCopyOnAttach; + String optionName; + String optionPersistenceUnitName; + String optionServerTimeZoneID; + String optionTransactionType; + boolean optionReadOnly; + String optionTransactionIsolationLevel; + Integer optionDatastoreReadTimeoutMillis; + Integer optionDatastoreWriteTimeoutMillis; + + Properties properties = new Properties(); + + public String getConnectionUserName() { + return optionConnectionUserName; + } - public String getTransactionType() { - return optionTransactionType; - } + public void setConnectionUserName(String connectionUserName) { + this.optionConnectionUserName = connectionUserName; + } - public void setTransactionType(String transactionType) { - this.optionTransactionType = transactionType; - } + public void setConnectionPassword(String connectionPassword) { + this.optionConnectionPassword = connectionPassword; + } - public boolean getReadOnly() { - return optionReadOnly; - } + public String getConnectionURL() { + return optionConnectionURL; + } - public void setReadOnly(boolean readOnly) { - this.optionReadOnly = readOnly; - } + public void setConnectionURL(String connectionURL) { + this.optionConnectionURL = connectionURL; + } - public String getTransactionIsolationLevel() { - return optionTransactionIsolationLevel; - } + public String getConnectionDriverName() { + return optionConnectionDriverName; + } - public void setTransactionIsolationLevel(String transactionIsolationLevel) { - this.optionTransactionIsolationLevel = transactionIsolationLevel; - } + public void setConnectionDriverName(String connectionDriverName) { + this.optionConnectionDriverName = connectionDriverName; + } - public Integer getDatastoreReadTimeoutMillis() { - return optionDatastoreReadTimeoutMillis; - } + public String getConnectionFactoryName() { + return optionConnectionFactoryName; + } - public void setDatastoreReadTimeoutMillis(Integer datastoreReadTimeoutMillis) { - this.optionDatastoreReadTimeoutMillis = datastoreReadTimeoutMillis; - } + public void setConnectionFactoryName(String connectionFactoryName) { + this.optionConnectionFactoryName = connectionFactoryName; + } - public Integer getDatastoreWriteTimeoutMillis() { - return optionDatastoreWriteTimeoutMillis; - } + public Object getConnectionFactory() { + return optionConnectionFactory; + } - public void setDatastoreWriteTimeoutMillis(Integer datastoreWriteTimeoutMillis) { - this.optionDatastoreWriteTimeoutMillis = datastoreWriteTimeoutMillis; - } + public void setConnectionFactory(Object connectionFactory) { + this.optionConnectionFactory = connectionFactory; + } - public void close() { - throw new UnsupportedOperationException("not implemented"); - } + public String getConnectionFactory2Name() { + return optionConnectionFactory2Name; + } - public boolean isClosed() { - return true; - } + public void setConnectionFactory2Name(String connectionFactory2Name) { + this.optionConnectionFactory2Name = connectionFactory2Name; + } - public PersistenceManager getPersistenceManager() { - throw new UnsupportedOperationException("not implemented"); - } + public Object getConnectionFactory2() { + return optionConnectionFactory2; + } - public PersistenceManager getPersistenceManagerProxy() { - throw new UnsupportedOperationException("not implemented"); - } + public void setConnectionFactory2(Object connectionFactory2) { + this.optionConnectionFactory2 = connectionFactory2; + } - public PersistenceManager getPersistenceManager(String userid, String password) { - throw new UnsupportedOperationException("not implemented"); - } + public boolean getMultithreaded() { + return optionMultithreaded; + } - public Properties getProperties() { - return properties; - } + public void setMultithreaded(boolean multithreaded) { + this.optionMultithreaded = multithreaded; + } - public Collection supportedOptions() { - throw new UnsupportedOperationException("not implemented"); - } + public String getMapping() { + return optionMapping; + } - public DataStoreCache getDataStoreCache() { - return new DataStoreCache() { + public void setMapping(String mapping) { + this.optionMapping = mapping; + } - public void evict(Object oid) {} + public boolean getOptimistic() { + return optionOptimistic; + } - public void evictAll() {} + public void setOptimistic(boolean optimistic) { + this.optionOptimistic = optimistic; + } - public void evictAll(Object... oids) {} + public boolean getRetainValues() { + return optionRetainValues; + } - public void evictAll(Collection oids) {} + public void setRetainValues(boolean retainValues) { + this.optionRetainValues = retainValues; + } - public void evictAll(boolean subclasses, Class pcClass) {} + public boolean getRestoreValues() { + return optionRestoreValues; + } - public void pin(Object oid) {} + public void setRestoreValues(boolean restoreValues) { + this.optionRestoreValues = restoreValues; + } - public void pinAll(Collection oids) {} + public boolean getNontransactionalRead() { + return optionNontransactionalRead; + } - public void pinAll(Object... oids) {} + public void setNontransactionalRead(boolean nontransactionalRead) { + this.optionNontransactionalRead = nontransactionalRead; + } - public void pinAll(boolean subclasses, Class pcClass) {} + public boolean getNontransactionalWrite() { + return optionNontransactionalWrite; + } - public void unpin(Object oid) {} + public void setNontransactionalWrite(boolean nontransactionalWrite) { + this.optionNontransactionalWrite = nontransactionalWrite; + } - public void unpinAll(Collection oids) {} + public boolean getIgnoreCache() { + return optionIgnoreCache; + } - public void unpinAll(Object... oids) {} + public void setIgnoreCache(boolean ignoreCache) { + this.optionIgnoreCache = ignoreCache; + } - public void unpinAll(boolean subclasses, Class pcClass) {} - }; - } + public boolean getDetachAllOnCommit() { + return optionDetachAllOnCommit; + } - public void addInstanceLifecycleListener(InstanceLifecycleListener listener, Class[] classes) { - throw new UnsupportedOperationException("not implemented"); - } + public void setDetachAllOnCommit(boolean detachAllOnCommit) { + this.optionDetachAllOnCommit = detachAllOnCommit; + } - public void removeInstanceLifecycleListener(InstanceLifecycleListener listener) { - throw new UnsupportedOperationException("not implemented"); - } + public boolean getCopyOnAttach() { + return optionCopyOnAttach; + } - public void addFetchGroups(FetchGroup... groups) { - throw new UnsupportedOperationException("not implemented"); - } + public void setCopyOnAttach(boolean copyOnAttach) { + this.optionCopyOnAttach = copyOnAttach; + } - public void removeFetchGroups(FetchGroup... groups) { - throw new UnsupportedOperationException("not implemented"); - } + public String getName() { + return optionName; + } - public void removeAllFetchGroups() { - throw new UnsupportedOperationException("not implemented"); - } + public void setName(String name) { + this.optionName = name; + } - @SuppressWarnings("rawtypes") - public FetchGroup getFetchGroup(Class cls, String name) { - throw new UnsupportedOperationException("not implemented"); - } + public String getPersistenceUnitName() { + return optionPersistenceUnitName; + } - @SuppressWarnings("rawtypes") - public Set getFetchGroups() { - throw new UnsupportedOperationException("not implemented"); - } + public void setPersistenceUnitName(String persistenceUnitName) { + this.optionPersistenceUnitName = persistenceUnitName; + } - public void registerMetadata(JDOMetadata metadata) { - throw new UnsupportedOperationException("not implemented"); - } + public String getServerTimeZoneID() { + return optionServerTimeZoneID; + } - public JDOMetadata newMetadata() { - throw new UnsupportedOperationException("not implemented"); - } + public void setServerTimeZoneID(String serverTimeZoneID) { + this.optionServerTimeZoneID = serverTimeZoneID; + } - public TypeMetadata getMetadata(String className) { - throw new UnsupportedOperationException("not implemented"); - } + public String getTransactionType() { + return optionTransactionType; + } - void setSpiResourceName(String spiPropertiesResourceName) { - this.spiResourceName = spiPropertiesResourceName; - } + public void setTransactionType(String transactionType) { + this.optionTransactionType = transactionType; + } - public String getSpiPropertiesResourceName() { - return spiResourceName; - } + public boolean getReadOnly() { + return optionReadOnly; + } - void setPersistenceManagerFactoryClass(String className) { - this.persistenceManagerFactoryClassName = className; - } + public void setReadOnly(boolean readOnly) { + this.optionReadOnly = readOnly; + } - public String getPersistenceManagerFactoryClass() { - return this.persistenceManagerFactoryClassName; - } + public String getTransactionIsolationLevel() { + return optionTransactionIsolationLevel; + } - void setProperty(String name, Object value) { - String val = value.toString(); + public void setTransactionIsolationLevel(String transactionIsolationLevel) { + this.optionTransactionIsolationLevel = transactionIsolationLevel; + } - if (name.equals(PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS)) { - setPersistenceManagerFactoryClass(val); - return; + public Integer getDatastoreReadTimeoutMillis() { + return optionDatastoreReadTimeoutMillis; } - if (name.equals(PROPERTY_CONNECTION_DRIVER_NAME)) { - setConnectionDriverName(val); - return; + + public void setDatastoreReadTimeoutMillis(Integer datastoreReadTimeoutMillis) { + this.optionDatastoreReadTimeoutMillis = datastoreReadTimeoutMillis; } - if (name.equals(PROPERTY_CONNECTION_FACTORY_NAME)) { - setConnectionFactoryName(val); - return; + + public Integer getDatastoreWriteTimeoutMillis() { + return optionDatastoreWriteTimeoutMillis; } - if (name.equals(PROPERTY_CONNECTION_FACTORY2_NAME)) { - setConnectionFactory2Name(val); - return; + + public void setDatastoreWriteTimeoutMillis( + Integer datastoreWriteTimeoutMillis) { + this.optionDatastoreWriteTimeoutMillis = datastoreWriteTimeoutMillis; } - if (name.equals(PROPERTY_CONNECTION_PASSWORD)) { - setConnectionPassword(val); - return; + + public void close() { + throw new UnsupportedOperationException("not implemented"); } - if (name.equals(PROPERTY_CONNECTION_URL)) { - setConnectionURL(val); - return; + + public boolean isClosed() { + return true; } - if (name.equals(PROPERTY_CONNECTION_USER_NAME)) { - setConnectionUserName(val); - return; + + public PersistenceManager getPersistenceManager() { + throw new UnsupportedOperationException("not implemented"); } - if (name.equals(PROPERTY_IGNORE_CACHE)) { - setCopyOnAttach(Boolean.parseBoolean(val)); - return; + + public PersistenceManager getPersistenceManagerProxy() { + throw new UnsupportedOperationException("not implemented"); } - if (name.equals(PROPERTY_DATASTORE_READ_TIMEOUT_MILLIS)) { - setDatastoreReadTimeoutMillis(Integer.parseInt(val)); - return; + + public PersistenceManager getPersistenceManager(String userid, + String password) { + throw new UnsupportedOperationException("not implemented"); } - if (name.equals(PROPERTY_DATASTORE_WRITE_TIMEOUT_MILLIS)) { - setDatastoreWriteTimeoutMillis(Integer.parseInt(val)); - return; + + public Properties getProperties() { + return properties; } - if (name.equals(PROPERTY_DETACH_ALL_ON_COMMIT)) { - setDetachAllOnCommit(Boolean.parseBoolean(val)); - return; + + public Collection supportedOptions() { + throw new UnsupportedOperationException("not implemented"); } - if (name.equals(PROPERTY_IGNORE_CACHE)) { - setIgnoreCache(Boolean.parseBoolean(val)); - return; + + public DataStoreCache getDataStoreCache() { + return new DataStoreCache() { + + public void evict(Object oid) { + } + + public void evictAll() { + } + + public void evictAll(Object... oids) { + } + + public void evictAll(Collection oids) { + } + + public void evictAll(boolean subclasses, Class pcClass) { + } + + public void pin(Object oid) { + } + + public void pinAll(Collection oids) { + } + + public void pinAll(Object... oids) { + } + + public void pinAll(boolean subclasses, Class pcClass) { + } + + public void unpin(Object oid) { + } + + public void unpinAll(Collection oids) { + } + + public void unpinAll(Object... oids) { + } + + public void unpinAll(boolean subclasses, Class pcClass) { + } + }; } - if (name.equals(PROPERTY_MAPPING)) { - setMapping(val); - return; + + public void addInstanceLifecycleListener( + InstanceLifecycleListener listener, Class[] classes) { + throw new UnsupportedOperationException("not implemented"); } - if (name.equals(PROPERTY_MULTITHREADED)) { - setMultithreaded(Boolean.parseBoolean(val)); - return; + + public void removeInstanceLifecycleListener( + InstanceLifecycleListener listener) { + throw new UnsupportedOperationException("not implemented"); } - if (name.equals(PROPERTY_NAME)) { - setName(val); - return; + + public void addFetchGroups(FetchGroup... groups) { + throw new UnsupportedOperationException("not implemented"); } - if (name.equals(PROPERTY_NONTRANSACTIONAL_READ)) { - setNontransactionalRead(Boolean.parseBoolean(val)); - return; + + public void removeFetchGroups(FetchGroup... groups) { + throw new UnsupportedOperationException("not implemented"); } - if (name.equals(PROPERTY_NONTRANSACTIONAL_WRITE)) { - setNontransactionalWrite(Boolean.parseBoolean(val)); - return; + + public void removeAllFetchGroups() { + throw new UnsupportedOperationException("not implemented"); } - if (name.equals(PROPERTY_OPTIMISTIC)) { - setOptimistic(Boolean.parseBoolean(val)); - return; + + @SuppressWarnings("rawtypes") + public FetchGroup getFetchGroup(Class cls, String name) { + throw new UnsupportedOperationException("not implemented"); } - if (name.equals(PROPERTY_PERSISTENCE_UNIT_NAME)) { - setPersistenceUnitName(val); - return; + + @SuppressWarnings("rawtypes") + public Set getFetchGroups() { + throw new UnsupportedOperationException("not implemented"); } - if (name.equals(PROPERTY_READONLY)) { - setReadOnly(Boolean.parseBoolean(val)); - return; + + public void registerMetadata(JDOMetadata metadata) { + throw new UnsupportedOperationException("not implemented"); } - if (name.equals(PROPERTY_RESTORE_VALUES)) { - setRestoreValues(Boolean.parseBoolean(val)); - return; + + public JDOMetadata newMetadata() { + throw new UnsupportedOperationException("not implemented"); } - if (name.equals(PROPERTY_RETAIN_VALUES)) { - setRetainValues(Boolean.parseBoolean(val)); - return; + + public TypeMetadata getMetadata(String className) { + throw new UnsupportedOperationException("not implemented"); } - if (name.equals(PROPERTY_SERVER_TIME_ZONE_ID)) { - setServerTimeZoneID(val); - return; + + void setSpiResourceName(String spiPropertiesResourceName) { + this.spiResourceName = spiPropertiesResourceName; } - if (name.equals(PROPERTY_TRANSACTION_ISOLATION_LEVEL)) { - setTransactionIsolationLevel(val); - return; + + public String getSpiPropertiesResourceName() { + return spiResourceName; } - if (name.equals(PROPERTY_TRANSACTION_TYPE)) { - setTransactionType(val); - return; + + void setPersistenceManagerFactoryClass(String className) { + this.persistenceManagerFactoryClassName = className; } - if (name.equals(PROPERTY_SPI_RESOURCE_NAME)) { - setSpiResourceName(val); - return; + + public String getPersistenceManagerFactoryClass() { + return this.persistenceManagerFactoryClassName; } - throw new IllegalArgumentException("unhandled stub PMF property " + name); - } + void setProperty(String name, Object value) { + String val = value.toString(); + + if (name.equals(PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS)) { + setPersistenceManagerFactoryClass(val); + return; + } + if (name.equals(PROPERTY_CONNECTION_DRIVER_NAME)) { + setConnectionDriverName(val); + return; + } + if (name.equals(PROPERTY_CONNECTION_FACTORY_NAME)) { + setConnectionFactoryName(val); + return; + } + if (name.equals(PROPERTY_CONNECTION_FACTORY2_NAME)) { + setConnectionFactory2Name(val); + return; + } + if (name.equals(PROPERTY_CONNECTION_PASSWORD)) { + setConnectionPassword(val); + return; + } + if (name.equals(PROPERTY_CONNECTION_URL)) { + setConnectionURL(val); + return; + } + if (name.equals(PROPERTY_CONNECTION_USER_NAME)) { + setConnectionUserName(val); + return; + } + if (name.equals(PROPERTY_IGNORE_CACHE)) { + setCopyOnAttach(Boolean.parseBoolean(val)); + return; + } + if (name.equals(PROPERTY_DATASTORE_READ_TIMEOUT_MILLIS)) { + setDatastoreReadTimeoutMillis(Integer.parseInt(val)); + return; + } + if (name.equals(PROPERTY_DATASTORE_WRITE_TIMEOUT_MILLIS)) { + setDatastoreWriteTimeoutMillis(Integer.parseInt(val)); + return; + } + if (name.equals(PROPERTY_DETACH_ALL_ON_COMMIT)) { + setDetachAllOnCommit(Boolean.parseBoolean(val)); + return; + } + if (name.equals(PROPERTY_IGNORE_CACHE)) { + setIgnoreCache(Boolean.parseBoolean(val)); + return; + } + if (name.equals(PROPERTY_MAPPING)) { + setMapping(val); + return; + } + if (name.equals(PROPERTY_MULTITHREADED)) { + setMultithreaded(Boolean.parseBoolean(val)); + return; + } + if (name.equals(PROPERTY_NAME)) { + setName(val); + return; + } + if (name.equals(PROPERTY_NONTRANSACTIONAL_READ)) { + setNontransactionalRead(Boolean.parseBoolean(val)); + return; + } + if (name.equals(PROPERTY_NONTRANSACTIONAL_WRITE)) { + setNontransactionalWrite(Boolean.parseBoolean(val)); + return; + } + if (name.equals(PROPERTY_OPTIMISTIC)) { + setOptimistic(Boolean.parseBoolean(val)); + return; + } + if (name.equals(PROPERTY_PERSISTENCE_UNIT_NAME)) { + setPersistenceUnitName(val); + return; + } + if (name.equals(PROPERTY_READONLY)) { + setReadOnly(Boolean.parseBoolean(val)); + return; + } + if (name.equals(PROPERTY_RESTORE_VALUES)) { + setRestoreValues(Boolean.parseBoolean(val)); + return; + } + if (name.equals(PROPERTY_RETAIN_VALUES)) { + setRetainValues(Boolean.parseBoolean(val)); + return; + } + if (name.equals(PROPERTY_SERVER_TIME_ZONE_ID)) { + setServerTimeZoneID(val); + return; + } + if (name.equals(PROPERTY_TRANSACTION_ISOLATION_LEVEL)) { + setTransactionIsolationLevel(val); + return; + } + if (name.equals(PROPERTY_TRANSACTION_TYPE)) { + setTransactionType(val); + return; + } + if (name.equals(PROPERTY_SPI_RESOURCE_NAME)) { + setSpiResourceName(val); + return; + } + + throw new IllegalArgumentException("unhandled stub PMF property " + + name); + } - void setProperties(Map properties) { - for (Object key : properties.keySet()) { - String k = key.toString(); - Object v = properties.get(key); + void setProperties(Map properties) { + for (Object key : properties.keySet()) { + String k = key.toString(); + Object v = properties.get(key); - this.properties.put(k, v); - setProperty(k, v); + this.properties.put(k, v); + setProperty(k, v); + } } - } - public Collection getManagedClasses() { - throw new UnsupportedOperationException("not implemented"); - } + public Collection getManagedClasses() { + throw new UnsupportedOperationException("not implemented"); + } } diff --git a/api/src/test/java/javax/jdo/util/AbstractTest.java b/api/src/test/java/javax/jdo/util/AbstractTest.java index c7d6bbb2a..393d278d5 100644 --- a/api/src/test/java/javax/jdo/util/AbstractTest.java +++ b/api/src/test/java/javax/jdo/util/AbstractTest.java @@ -5,87 +5,101 @@ * 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 + * + * 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 javax.jdo.util; import java.io.PrintStream; + import javax.jdo.Constants; + import junit.framework.TestCase; /** */ public abstract class AbstractTest extends TestCase implements Constants { - /** */ - protected static PrintStream out = System.out; - - /** If true, print extra messages. */ - protected boolean verbose; - - /** Construct and initialize from properties. */ - protected AbstractTest() { - super(null); - verbose = Boolean.getBoolean("verbose"); - } + /** */ + protected static PrintStream out = System.out; + + /** If true, print extra messages. */ + protected boolean verbose; - /** Determine if a class is loadable in the current environment. */ - protected static boolean isClassLoadable(String className) { - try { - Class.forName(className); - return true; - } catch (ClassNotFoundException ex) { - return false; + /** + * Construct and initialize from properties. + */ + protected AbstractTest() { + super(null); + verbose = Boolean.getBoolean("verbose"); } - } - - /** */ - protected void println(String s) { - if (verbose) out.println(s); - } - - /** New line. */ - public static final String NL = System.getProperty("line.separator"); - - /** A buffer of of error messages. */ - protected static StringBuffer messages; - - /** Appends to error messages. */ - protected static synchronized void appendMessage(String message) { - if (message != null) { - if (messages == null) { - messages = new StringBuffer(); - } - messages.append(message); - messages.append(NL); + + /** + * Determine if a class is loadable in the current environment. + */ + protected static boolean isClassLoadable(String className) { + try { + Class.forName(className); + return true; + } catch (ClassNotFoundException ex) { + return false; + } } - } - - /** - * Returns collected error messages, or null if there are none, and clears the - * buffer. - */ - protected static synchronized String retrieveMessages() { - if (messages == null) { - return null; + + /** + */ + protected void println(String s) { + if (verbose) + out.println(s); } - final String msg = messages.toString(); - messages = null; - return msg; - } - - /** Fail the test if there are any error messages. */ - protected void failOnError() { - String errors = retrieveMessages(); - if (errors != null) { - fail(errors); + + /** New line. + */ + public static final String NL = System.getProperty("line.separator"); + + /** A buffer of of error messages. + */ + protected static StringBuffer messages; + + /** Appends to error messages. + */ + protected static synchronized void appendMessage(String message) { + if (message != null) { + if (messages == null) { + messages = new StringBuffer(); + } + messages.append(message); + messages.append(NL); + } + } + + /** + * Returns collected error messages, or null if there + * are none, and clears the buffer. + */ + protected static synchronized String retrieveMessages() { + if (messages == null) { + return null; + } + final String msg = messages.toString(); + messages = null; + return msg; + } + + /** + * Fail the test if there are any error messages. + */ + protected void failOnError() { + String errors = retrieveMessages(); + if (errors != null) { + fail (errors); + } } - } } + diff --git a/api/src/test/java/javax/jdo/util/BatchResultPrinter.java b/api/src/test/java/javax/jdo/util/BatchResultPrinter.java index 6cd0bf414..91002aaa6 100644 --- a/api/src/test/java/javax/jdo/util/BatchResultPrinter.java +++ b/api/src/test/java/javax/jdo/util/BatchResultPrinter.java @@ -5,19 +5,20 @@ * 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 + * + * 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 javax.jdo.util; import java.io.PrintStream; + import junit.framework.AssertionFailedError; import junit.framework.Test; import junit.framework.TestCase; @@ -26,86 +27,87 @@ /** * Default result printer implementation for running tests in batch mode. - * + * * @author Michael Bouschen */ -public class BatchResultPrinter extends ResultPrinter { - /** */ - public BatchResultPrinter(PrintStream writer) { - super(writer); - } - - /** Called in case of a test error. */ - public void addError(Test test, Throwable t) { - getWriter().print(" ERROR"); - } - - /** Called in case of a test failure. */ - public void addFailure(Test test, AssertionFailedError t) { - getWriter().print(" FAILURE"); - } - - /** Called when a test case is finished. */ - public void endTest(Test test) { - getWriter().println(); - } - - /** - * Called when a test case is started. - * - * @param test test case - */ - public void startTest(Test test) { - String testName; - if (test instanceof TestCase) { - testName = getClassBaseName(test) + "." + ((TestCase) test).getName(); - } else { - testName = test.toString(); +public class BatchResultPrinter + extends ResultPrinter +{ + /** */ + public BatchResultPrinter(PrintStream writer) { + super(writer); } - getWriter().print("RUN " + testName); - } - - /** - * @param runTime time - */ - protected void printHeader(long runTime) { - getWriter().println("Time: " + elapsedTimeAsString(runTime)); - } - - /** - * @param result the result - */ - protected void printFooter(TestResult result) { - if (result.wasSuccessful()) { - getWriter().print("OK"); - getWriter() - .println(" (" + result.runCount() + " test" + (result.runCount() == 1 ? "" : "s") + ")"); - - } else { - getWriter().println("FAILURES!!!"); - getWriter() - .println( - "Tests run: " - + result.runCount() - + ", Failures: " - + result.failureCount() - + ", Errors: " - + result.errorCount()); + + /** Called in case of a test error. */ + public void addError(Test test, Throwable t) { + getWriter().print(" ERROR"); + } + + /** Called in case of a test failure. */ + public void addFailure(Test test, AssertionFailedError t) { + getWriter().print(" FAILURE"); + } + + /** Called when a test case is finished. */ + public void endTest(Test test) { + getWriter().println(); + } + + /** + * Called when a test case is started. + * @param test test case + */ + public void startTest(Test test) { + String testName; + if (test instanceof TestCase) { + testName = getClassBaseName(test) + "." + ((TestCase)test).getName(); + } + else { + testName = test.toString(); + } + getWriter().print("RUN " + testName); + } + + /** + * + * @param runTime time + */ + protected void printHeader(long runTime) { + getWriter().println("Time: "+elapsedTimeAsString(runTime)); } - } - - // helper method - /** - * @return Name of the class of the given object without package prefix - */ - private String getClassBaseName(Object obj) { - if (obj == null) return null; - String className = obj.getClass().getName(); - int index = className.lastIndexOf('.'); - if (index != -1) { - className = className.substring(index + 1); + /** + * + * @param result the result + */ + protected void printFooter(TestResult result) { + if (result.wasSuccessful()) { + getWriter().print("OK"); + getWriter().println (" (" + result.runCount() + " test" + (result.runCount() == 1 ? "": "s") + ")"); + + } else { + getWriter().println("FAILURES!!!"); + getWriter().println("Tests run: "+result.runCount()+ + ", Failures: "+result.failureCount()+ + ", Errors: "+result.errorCount()); + } + } + + // helper method + + /** + * @return Name of the class of the given object without package prefix + */ + private String getClassBaseName(Object obj) { + if (obj == null) return null; + String className = obj.getClass().getName(); + int index = className.lastIndexOf('.'); + if (index != -1) { + className = className.substring(index + 1); + } + return className; } - return className; - } + } + + diff --git a/api/src/test/java/javax/jdo/util/BatchTestRunner.java b/api/src/test/java/javax/jdo/util/BatchTestRunner.java index 0d0cbb2cf..30c758f0d 100644 --- a/api/src/test/java/javax/jdo/util/BatchTestRunner.java +++ b/api/src/test/java/javax/jdo/util/BatchTestRunner.java @@ -5,21 +5,22 @@ * 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 + * + * 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 javax.jdo.util; -import java.io.PrintStream; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; +import java.io.PrintStream; + import junit.framework.Test; import junit.framework.TestResult; import junit.framework.TestSuite; @@ -27,114 +28,137 @@ import junit.textui.TestRunner; /** - * TestRunner class for running a single test or a test suite in batch mode. The format of the test - * output is specified by the result printer class. The main method sets an exit code according to - * the test result: - * + * TestRunner class for running a single test or a test suite in batch + * mode. The format of the test output is specified by the result printer + * class. The main method sets an exit code according to the test result: *

      - *
    • 0: success - *
    • 1: failure, the test shows an unexpected behavior - *
    • 2: exception, the test throws an unhandled excption + *
    • 0: success + *
    • 1: failure, the test shows an unexpected behavior + *
    • 2: exception, the test throws an unhandled excption *
    - * + * * @author Michael Bouschen */ -public class BatchTestRunner extends TestRunner { - /** Name of the system property to specify the result printer class. */ - public static final String RESULTPRINTER_PROPERTY = "ResultPrinterClass"; - - /** Default of the system property ResultPrinterClass. */ - public static final String RESULTPRINTER_DEFAULT = BatchResultPrinter.class.getName(); - - /** - * Constructor. It creates a result printer instance based on the system property and delegates to - * the constructor taking a result printer argument. - */ - public BatchTestRunner() { - super(); - setPrinter(getResultPrinter()); - } - - /** Constructor. USes teh specified resultPrinter to format the test result. */ - public BatchTestRunner(ResultPrinter resultPrinter) { - super(resultPrinter); - } - - /** Runs all test methods from the specified class. */ - public static void run(Class clazz) { - run(new TestSuite(clazz)); - } +public class BatchTestRunner + extends TestRunner +{ + /** Name of the system property to specify the result printer class. */ + public static final String RESULTPRINTER_PROPERTY = "ResultPrinterClass"; + + /** Default of the system property ResultPrinterClass. */ + public static final String RESULTPRINTER_DEFAULT = BatchResultPrinter.class.getName(); + + /** + * Constructor. + * It creates a result printer instance based on the system property + * and delegates to the constructor taking a result printer argument. + */ + public BatchTestRunner() { + super(); + setPrinter(getResultPrinter()); + } + + /** + * Constructor. USes teh specified resultPrinter to format the test result. + */ + public BatchTestRunner(ResultPrinter resultPrinter) { + super(resultPrinter); + } - /** Runs the specified test. */ - public static TestResult run(Test test) { - return new BatchTestRunner().doRun(test); - } + /** Runs all test methods from the specified class. */ + public static void run(Class clazz) { + run(new TestSuite(clazz)); + } + + /** Runs the specified test. */ + public static TestResult run(Test test) { + return new BatchTestRunner().doRun(test); + } - /** Runs the specified test and waits until the user types RETURN. */ - public static void runAndWait(Test suite) { - new BatchTestRunner().doRun(suite, true); - } + /** Runs the specified test and waits until the user types RETURN. */ + public static void runAndWait(Test suite) { + new BatchTestRunner().doRun(suite, true); + } - /** - * Runs in batch mode and sets an exit code. If the specified String array includes a single fully - * qualified class name, this test class is executed. If it is empty it runs the TestListSuite. - */ - public static void main(String args[]) { - BatchTestRunner aTestRunner = new BatchTestRunner(); - try { - /* - if ((args == null) || args.length == 0) - args = new String[] { TestListSuite.class.getName() }; - */ - TestResult r = aTestRunner.start(args); - if (!r.wasSuccessful()) System.exit(FAILURE_EXIT); - System.exit(SUCCESS_EXIT); - } catch (Exception e) { - System.err.println(e.getMessage()); - System.exit(EXCEPTION_EXIT); - } - } + /** + * Runs in batch mode and sets an exit code. If the specified String + * array includes a single fully qualified class name, this test class + * is executed. If it is empty it runs the TestListSuite. + */ + public static void main(String args[]) { + BatchTestRunner aTestRunner= new BatchTestRunner(); + try { + /* + if ((args == null) || args.length == 0) + args = new String[] { TestListSuite.class.getName() }; + */ + TestResult r = aTestRunner.start(args); + if (!r.wasSuccessful()) + System.exit(FAILURE_EXIT); + System.exit(SUCCESS_EXIT); + } catch(Exception e) { + System.err.println(e.getMessage()); + System.exit(EXCEPTION_EXIT); + } + } + + /** Returns a result printer instance. n instance of tCheck the system property */ + protected ResultPrinter getResultPrinter() { + String className = System.getProperty(RESULTPRINTER_PROPERTY); + if (className != null) { + className = className.trim(); + if (className.length() != 0) { + String msg = null; + try { + // get class instance + Class clazz = Class.forName(className); + // constructor taking PrintStream arg + Constructor ctor = clazz.getConstructor( + new Class[] { PrintStream.class } ); + // create instance + return (ResultPrinter)ctor.newInstance( + new Object[] { System.out }); + } + catch (ClassNotFoundException ex) { + // specified ResultPrinter class not + msg = "Cannot find specified result printer class " + + className + "."; + } + catch (NoSuchMethodException ex) { + msg = "Class " + className + + " does not provide constructor taking a PrintStream."; + } + catch (InstantiationException ex) { + msg = "Class " + className + " is abstract."; + } + catch (IllegalAccessException ex) { + msg = "Constructor taking a PrintStream of class " + + className + " is not accessible."; + } + catch (InvocationTargetException ex) { + msg = "Constructor call results in exception " + ex + "."; + } - /** Returns a result printer instance. n instance of tCheck the system property */ - protected ResultPrinter getResultPrinter() { - String className = System.getProperty(RESULTPRINTER_PROPERTY); - if (className != null) { - className = className.trim(); - if (className.length() != 0) { - String msg = null; - try { - // get class instance - Class clazz = Class.forName(className); - // constructor taking PrintStream arg - Constructor ctor = clazz.getConstructor(new Class[] {PrintStream.class}); - // create instance - return (ResultPrinter) ctor.newInstance(new Object[] {System.out}); - } catch (ClassNotFoundException ex) { - // specified ResultPrinter class not - msg = "Cannot find specified result printer class " + className + "."; - } catch (NoSuchMethodException ex) { - msg = "Class " + className + " does not provide constructor taking a PrintStream."; - } catch (InstantiationException ex) { - msg = "Class " + className + " is abstract."; - } catch (IllegalAccessException ex) { - msg = "Constructor taking a PrintStream of class " + className + " is not accessible."; - } catch (InvocationTargetException ex) { - msg = "Constructor call results in exception " + ex + "."; + // ResultPrinter class specified, but not avaiable + System.out.println(msg); + ResultPrinter printer = getDefaultResultPrinter(); + System.out.println("Using default result printer of class " + + printer.getClass().getName()); + } } - - // ResultPrinter class specified, but not avaiable - System.out.println(msg); - ResultPrinter printer = getDefaultResultPrinter(); - System.out.println("Using default result printer of class " + printer.getClass().getName()); - } + + // ResultPrinter class not specified => use default + return getDefaultResultPrinter(); } - // ResultPrinter class not specified => use default - return getDefaultResultPrinter(); - } + /** + * Returns an instance of the default result printer class + * BatchResultPrinter. + */ + protected ResultPrinter getDefaultResultPrinter() { + return new BatchResultPrinter(System.out); + } + - /** Returns an instance of the default result printer class BatchResultPrinter. */ - protected ResultPrinter getDefaultResultPrinter() { - return new BatchResultPrinter(System.out); - } } + diff --git a/api/src/test/java/javax/jdo/util/XMLTestUtil.java b/api/src/test/java/javax/jdo/util/XMLTestUtil.java index 88a897294..10681a7ac 100644 --- a/api/src/test/java/javax/jdo/util/XMLTestUtil.java +++ b/api/src/test/java/javax/jdo/util/XMLTestUtil.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,26 +19,29 @@ import java.io.BufferedReader; import java.io.File; -import java.io.FileFilter; import java.io.FileReader; -import java.io.FilenameFilter; -import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.IOException; +import java.io.FileFilter; +import java.io.FilenameFilter; + +import javax.jdo.JDOFatalInternalException; +import javax.jdo.LegacyJava; import java.lang.reflect.InvocationTargetException; import java.security.PrivilegedAction; -import java.util.ArrayList; import java.util.Arrays; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.StringTokenizer; + import javax.jdo.JDOFatalException; -import javax.jdo.JDOFatalInternalException; -import javax.jdo.LegacyJava; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; + import org.w3c.dom.Document; import org.xml.sax.EntityResolver; import org.xml.sax.ErrorHandler; @@ -48,523 +51,534 @@ /** * Tests schema files. - * *

    */ public class XMLTestUtil { - /** */ - protected static String BASEDIR = System.getProperty("basedir", "."); - - /** "http://www.w3.org/2001/XMLSchema" */ - protected static final String XSD_TYPE = "http://www.w3.org/2001/XMLSchema"; - - /** */ - protected static final String SCHEMA_LANGUAGE_PROP = - "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; - - /** */ - protected static final String SCHEMA_LOCATION_PROP = - "http://apache.org/xml/properties/schema/external-schemaLocation"; - - /** jdo namespace */ - protected static final String JDO_XSD_NS = "https://db.apache.org/jdo/xmlns/jdo"; - - /** orm namespace */ - protected static final String ORM_XSD_NS = "https://db.apache.org/jdo/xmlns/orm"; - - /** jdoquery namespace */ - protected static final String JDOQUERY_XSD_NS = "https://db.apache.org/jdo/xmlns/jdoquery"; - - /** jdo xsd file */ - protected static final File JDO_XSD_FILE = - new File(BASEDIR + "/target/classes/javax/jdo/jdo_3_2.xsd"); - - /** orm xsd file */ - protected static final File ORM_XSD_FILE = - new File(BASEDIR + "/target/classes/javax/jdo/orm_3_2.xsd"); - - /** jdoquery xsd file */ - protected static final File JDOQUERY_XSD_FILE = - new File(BASEDIR + "/target/classes/javax/jdo/jdoquery_3_2.xsd"); - - /** Entity resolver */ - protected static final EntityResolver resolver = new JDOEntityResolver(); - - /** Error handler */ - protected static final Handler handler = new Handler(); - - /** - * Name of the metadata property, a comma separated list of JDO metadata file or directories - * containing such files. - */ - protected static String METADATA_PROP = "javax.jdo.metadata"; - - /** Name of the recursive property, allowing recursive search of metadata files. */ - protected static String RECURSIVE_PROP = "javax.jdo.recursive"; - - /** Separator character for the metadata property. */ - protected static final String DELIM = ",;"; - - /** Newline. */ - protected static final String NL = System.getProperty("line.separator"); - - /** XSD builder for jdo namespace. */ - private final DocumentBuilder jdoXsdBuilder = - createBuilder(JDO_XSD_NS + " " + JDO_XSD_FILE.toURI().toString()); - - /** XSD builder for orm namespace. */ - private final DocumentBuilder ormXsdBuilder = - createBuilder(ORM_XSD_NS + " " + ORM_XSD_FILE.toURI().toString()); - - /** XSD builder for jdoquery namespace. */ - private final DocumentBuilder jdoqueryXsdBuilder = - createBuilder(JDOQUERY_XSD_NS + " " + JDOQUERY_XSD_FILE.toURI().toString()); - - /** DTD builder. */ - private final DocumentBuilder dtdBuilder = createBuilder(true); - - /** Non validating builder. */ - private final DocumentBuilder nonValidatingBuilder = createBuilder(false); - - /** Create XSD builder. */ - private DocumentBuilder createBuilder(String location) { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setValidating(true); - factory.setNamespaceAware(true); - factory.setAttribute(SCHEMA_LANGUAGE_PROP, XSD_TYPE); - factory.setAttribute(SCHEMA_LOCATION_PROP, location); - return getParser(factory); - } - - /** Create builder. */ - private DocumentBuilder createBuilder(boolean validating) { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setValidating(validating); - factory.setNamespaceAware(true); - return getParser(factory); - } - - /** Returns a parser obtained from specified factroy. */ - private DocumentBuilder getParser(DocumentBuilderFactory factory) { - try { - DocumentBuilder builder = factory.newDocumentBuilder(); - builder.setEntityResolver(resolver); - builder.setErrorHandler(handler); - return builder; - } catch (ParserConfigurationException ex) { - throw new JDOFatalException("Cannot create XML parser", ex); - } - } - - /** - * Parse the specified files. The valid parameter determines whether the specified files are valid - * JDO metadata files. The method does not throw an exception on an error, instead it instead it - * returns the error message(s) as string. - */ - public String checkXML(File[] files, boolean valid) { - StringBuffer messages = new StringBuffer(); - for (int i = 0; i < files.length; i++) { - String msg = checkXML(files[i], valid); - if (msg != null) { - messages.append(msg); - } - } - return (messages.length() == 0) ? null : messages.toString(); - } - - /** - * Parse the specified files using a non validating parser. The method does not throw an exception - * on an error, instead it instead it returns the error message(s) as string. - */ - public String checkXMLNonValidating(File[] files) { - StringBuffer messages = new StringBuffer(); - for (int i = 0; i < files.length; i++) { - String msg = checkXML(nonValidatingBuilder, files[i], true); - if (msg != null) { - messages.append(msg); - } - } - return (messages.length() == 0) ? null : messages.toString(); - } - - /** - * Parse the specified file. The method checks whether it is a XSD or DTD base file and parses the - * file using a builder according to the file name suffix. The valid parameter determines whether - * the specified files are valid JDO metadata files. The method does not throw an exception on an - * error, instead it returns the error message(s) as string. - */ - private String checkXML(File file, boolean valid) { - String messages = null; - String fileName = file.getName(); - try { - if (isDTDBased(file)) { - messages = checkXML(dtdBuilder, file, valid); - } else if (fileName.endsWith(".jdo")) { - messages = checkXML(jdoXsdBuilder, file, valid); - } else if (fileName.endsWith(".orm")) { - messages = checkXML(ormXsdBuilder, file, valid); - } else if (fileName.endsWith(".jdoquery")) { - messages = checkXML(jdoqueryXsdBuilder, file, valid); - } - } catch (SAXException ex) { - messages = ex.getMessage(); - } - return messages; - } - - /** - * Parse the specified file using the specified builder. The valid parameter determines whether - * the specified files are valid JDO metadata files. The method does not throw an exception on an - * error, instead it returns the error message(s) as string. - */ - private String checkXML(DocumentBuilder builder, File file, boolean valid) { - String messages = null; - handler.init(file); - try { - builder.parse(file); - } catch (SAXParseException ex) { - handler.error(ex); - } catch (Exception ex) { - messages = "Fatal error processing " + file.getName() + ": " + ex + NL; - } - if (messages == null) { - messages = handler.getMessages(); - } - if (!valid) { - if (messages != null) { - // expected error for negative test - messages = null; - } else { - messages = file.getName() + " is not valid, " + "but the parser did not catch the error."; - } - } - return messages; - } - - /** - * Checks whether the specifeid file is DTD or XSD based. The method throws a SAXException if the - * file has syntax errors. - */ - private boolean isDTDBased(File file) throws SAXException { - handler.init(file); - try { - Document document = nonValidatingBuilder.parse(file); - return document.getDoctype() != null; - } catch (SAXParseException ex) { - handler.error(ex); - throw new SAXException(handler.getMessages()); - } catch (Exception ex) { - throw new SAXException("Fatal error processing " + file.getName() + ": " + ex); - } - } + /** */ + protected static String BASEDIR = System.getProperty("basedir", "."); - /** ErrorHandler implementation. */ - private static class Handler implements ErrorHandler { + /** "http://www.w3.org/2001/XMLSchema" */ + protected static final String XSD_TYPE = + "http://www.w3.org/2001/XMLSchema"; - private File fileUnderTest; - private String[] lines; - private StringBuffer messages; + /** */ + protected static final String SCHEMA_LANGUAGE_PROP = + "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; - public void error(SAXParseException ex) { - append("Handler.error: ", ex); + /** */ + protected static final String SCHEMA_LOCATION_PROP = + "http://apache.org/xml/properties/schema/external-schemaLocation"; + + /** jdo namespace */ + protected static final String JDO_XSD_NS = + "https://db.apache.org/jdo/xmlns/jdo"; + + /** orm namespace */ + protected static final String ORM_XSD_NS = + "https://db.apache.org/jdo/xmlns/orm"; + + /** jdoquery namespace */ + protected static final String JDOQUERY_XSD_NS = + "https://db.apache.org/jdo/xmlns/jdoquery"; + + /** jdo xsd file */ + protected static final File JDO_XSD_FILE = + new File(BASEDIR + "/target/classes/javax/jdo/jdo_3_2.xsd"); + + /** orm xsd file */ + protected static final File ORM_XSD_FILE = + new File(BASEDIR + "/target/classes/javax/jdo/orm_3_2.xsd"); + + /** jdoquery xsd file */ + protected static final File JDOQUERY_XSD_FILE = + new File(BASEDIR + "/target/classes/javax/jdo/jdoquery_3_2.xsd"); + + /** Entity resolver */ + protected static final EntityResolver resolver = new JDOEntityResolver(); + + /** Error handler */ + protected static final Handler handler = new Handler(); + + /** Name of the metadata property, a comma separated list of JDO metadata + * file or directories containing such files. */ + protected static String METADATA_PROP = "javax.jdo.metadata"; + + /** Name of the recursive property, allowing recursive search of metadata + * files. */ + protected static String RECURSIVE_PROP = "javax.jdo.recursive"; + + /** Separator character for the metadata property. */ + protected static final String DELIM = ",;"; + + /** Newline. */ + protected static final String NL = System.getProperty("line.separator"); + + /** XSD builder for jdo namespace. */ + private final DocumentBuilder jdoXsdBuilder = + createBuilder(JDO_XSD_NS + " " + JDO_XSD_FILE.toURI().toString()); + + /** XSD builder for orm namespace. */ + private final DocumentBuilder ormXsdBuilder = + createBuilder(ORM_XSD_NS + " " + ORM_XSD_FILE.toURI().toString()); + + /** XSD builder for jdoquery namespace. */ + private final DocumentBuilder jdoqueryXsdBuilder = + createBuilder(JDOQUERY_XSD_NS + " " + JDOQUERY_XSD_FILE.toURI().toString()); + + /** DTD builder. */ + private final DocumentBuilder dtdBuilder = createBuilder(true); + + /** Non validating builder. */ + private final DocumentBuilder nonValidatingBuilder = createBuilder(false); + + /** Create XSD builder. */ + private DocumentBuilder createBuilder(String location) { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setValidating(true); + factory.setNamespaceAware(true); + factory.setAttribute(SCHEMA_LANGUAGE_PROP, XSD_TYPE); + factory.setAttribute(SCHEMA_LOCATION_PROP, location); + return getParser(factory); } - public void fatalError(SAXParseException ex) { - append("Handler.fatalError: ", ex); + /** Create builder. */ + private DocumentBuilder createBuilder(boolean validating) { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setValidating(validating); + factory.setNamespaceAware(true); + return getParser(factory); } - public void warning(SAXParseException ex) { - append("Handler.warning: ", ex); + /** Returns a parser obtained from specified factroy. */ + private DocumentBuilder getParser(DocumentBuilderFactory factory) { + try { + DocumentBuilder builder = factory.newDocumentBuilder(); + builder.setEntityResolver(resolver); + builder.setErrorHandler(handler); + return builder; + } catch (ParserConfigurationException ex) { + throw new JDOFatalException("Cannot create XML parser", ex); + } } - public void init(File file) { - this.fileUnderTest = file; - this.messages = new StringBuffer(); - this.lines = null; + /** Parse the specified files. The valid parameter determines whether the + * specified files are valid JDO metadata files. The method does not throw + * an exception on an error, instead it instead it returns the error + * message(s) as string. + */ + public String checkXML(File[] files, boolean valid) { + StringBuffer messages = new StringBuffer(); + for (int i = 0; i < files.length; i++) { + String msg = checkXML(files[i], valid); + if (msg != null) { + messages.append(msg); + } + } + return (messages.length() == 0) ? null : messages.toString(); } - - public String getMessages() { - return (messages.length() == 0) ? null : messages.toString(); + + /** Parse the specified files using a non validating parser. The method + * does not throw an exception on an error, instead it instead it returns + * the error message(s) as string. + */ + public String checkXMLNonValidating(File[] files) { + StringBuffer messages = new StringBuffer(); + for (int i = 0; i < files.length; i++) { + String msg = checkXML(nonValidatingBuilder, files[i], true); + if (msg != null) { + messages.append(msg); + } + } + return (messages.length() == 0) ? null : messages.toString(); } - - private void append(String prefix, SAXParseException ex) { - int lineNumber = ex.getLineNumber(); - int columnNumber = ex.getColumnNumber(); - messages.append("------------------------").append(NL); - messages.append(prefix).append(fileUnderTest.getName()); - messages.append(" [line=").append(lineNumber); - messages.append(", col=").append(columnNumber).append("]: "); - messages.append(ex.getMessage()).append(NL); - messages.append(getErrorLocation(lineNumber, columnNumber)); + + /** Parse the specified file. The method checks whether it is a XSD or + * DTD base file and parses the file using a builder according to the file + * name suffix. The valid parameter determines whether the specified files + * are valid JDO metadata files. The method does not throw an exception on + * an error, instead it returns the error message(s) as string. + */ + private String checkXML(File file, boolean valid) { + String messages = null; + String fileName = file.getName(); + try { + if (isDTDBased(file)) { + messages = checkXML(dtdBuilder, file, valid); + } else if (fileName.endsWith(".jdo")) { + messages = checkXML(jdoXsdBuilder, file, valid); + } else if (fileName.endsWith(".orm")) { + messages = checkXML(ormXsdBuilder, file, valid); + } else if (fileName.endsWith(".jdoquery")) { + messages = checkXML(jdoqueryXsdBuilder, file, valid); + } + } catch (SAXException ex) { + messages = ex.getMessage(); + } + return messages; } - private String[] getLines() { - if (lines == null) { + /** Parse the specified file using the specified builder. The valid + * parameter determines whether the specified files are valid JDO metadata + * files. The method does not throw an exception on an error, instead it + * returns the error message(s) as string. + */ + private String checkXML(DocumentBuilder builder, File file, boolean valid) { + String messages = null; + handler.init(file); try { - BufferedReader bufferedReader = new BufferedReader(new FileReader(fileUnderTest)); - ArrayList tmp = new ArrayList(); - while (bufferedReader.ready()) { - tmp.add(bufferedReader.readLine()); - } - lines = (String[]) tmp.toArray(new String[tmp.size()]); - } catch (IOException ex) { - throw new JDOFatalException("getLines: caught IOException", ex); + builder.parse(file); + } catch (SAXParseException ex) { + handler.error(ex); + } catch (Exception ex) { + messages = "Fatal error processing " + file.getName() + ": " + ex + NL; + } + if (messages == null) { + messages = handler.getMessages(); + } + if (!valid) { + if (messages != null) { + // expected error for negative test + messages = null; + } else { + messages = file.getName() + " is not valid, " + + "but the parser did not catch the error."; + } } - } - return lines; + return messages; } - /** Return the error location for the file under test. */ - private String getErrorLocation(int lineNumber, int columnNumber) { - String[] lines = getLines(); - int length = lines.length; - if (lineNumber > length) { - return "Line number " - + lineNumber - + " exceeds the number of lines in the file (" - + lines.length - + ")"; - } else if (lineNumber < 1) { - return "Line number " + lineNumber + " does not allow retriving the error location."; - } - StringBuffer buf = new StringBuffer(); - if (lineNumber > 2) { - buf.append(lines[lineNumber - 3]); - buf.append(NL); - buf.append(lines[lineNumber - 2]); - buf.append(NL); - } - buf.append(lines[lineNumber - 1]); - buf.append(NL); - for (int i = 1; i < columnNumber; ++i) { - buf.append(' '); - } - buf.append("^\n"); - if (lineNumber + 1 < length) { - buf.append(lines[lineNumber]); - buf.append(NL); - buf.append(lines[lineNumber + 1]); - buf.append(NL); - } - return buf.toString(); - } - } - - /** - * Implementation of EntityResolver interface to check the jdo.dtd location. TODO Somebody should - * update these 2.2 to 3.1 or later at some point. - */ - private static class JDOEntityResolver implements EntityResolver { - - private static final String RECOGNIZED_JDO_PUBLIC_ID = - "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 3.2//EN"; - private static final String RECOGNIZED_JDO_SYSTEM_ID = "file:/javax/jdo/jdo_3_2.dtd"; - private static final String RECOGNIZED_JDO_SYSTEM_ID2 = "http://xmlns.jcp.org/dtd/jdo_3_2.dtd"; - private static final String RECOGNIZED_ORM_PUBLIC_ID = - "-//Sun Microsystems, Inc.//DTD Java Data Objects Mapping Metadata 3.2//EN"; - private static final String RECOGNIZED_ORM_SYSTEM_ID = "file:/javax/jdo/orm_3_2.dtd"; - private static final String RECOGNIZED_ORM_SYSTEM_ID2 = "http://xmlns.jcp.org/dtd/orm_3_2.dtd"; - private static final String RECOGNIZED_JDOQUERY_PUBLIC_ID = - "-//Sun Microsystems, Inc.//DTD Java Data Objects Query Metadata 3.2//EN"; - private static final String RECOGNIZED_JDOQUERY_SYSTEM_ID = "file:/javax/jdo/jdoquery_3_2.dtd"; - private static final String RECOGNIZED_JDOQUERY_SYSTEM_ID2 = - "http://xmlns.jcp.org/dtd/jdoquery_3_2.dtd"; - private static final String JDO_DTD_FILENAME = "javax/jdo/jdo_3_2.dtd"; - private static final String ORM_DTD_FILENAME = "javax/jdo/orm_3_2.dtd"; - private static final String JDOQUERY_DTD_FILENAME = "javax/jdo/jdoquery_3_2.dtd"; - - static Map publicIds = new HashMap(); - static Map systemIds = new HashMap(); - - static { - publicIds.put(RECOGNIZED_JDO_PUBLIC_ID, JDO_DTD_FILENAME); - publicIds.put(RECOGNIZED_ORM_PUBLIC_ID, ORM_DTD_FILENAME); - publicIds.put(RECOGNIZED_JDOQUERY_PUBLIC_ID, JDOQUERY_DTD_FILENAME); - systemIds.put(RECOGNIZED_JDO_SYSTEM_ID, JDO_DTD_FILENAME); - systemIds.put(RECOGNIZED_ORM_SYSTEM_ID, ORM_DTD_FILENAME); - systemIds.put(RECOGNIZED_JDOQUERY_SYSTEM_ID, JDOQUERY_DTD_FILENAME); - systemIds.put(RECOGNIZED_JDO_SYSTEM_ID2, JDO_DTD_FILENAME); - systemIds.put(RECOGNIZED_ORM_SYSTEM_ID2, ORM_DTD_FILENAME); - systemIds.put(RECOGNIZED_JDOQUERY_SYSTEM_ID2, JDOQUERY_DTD_FILENAME); + /** Checks whether the specifeid file is DTD or XSD based. The method + * throws a SAXException if the file has syntax errors. */ + private boolean isDTDBased(File file) throws SAXException { + handler.init(file); + try { + Document document = nonValidatingBuilder.parse(file); + return document.getDoctype() != null; + } catch (SAXParseException ex) { + handler.error(ex); + throw new SAXException(handler.getMessages()); + } catch (Exception ex) { + throw new SAXException( + "Fatal error processing " + file.getName() + ": " + ex); + } } + + /** ErrorHandler implementation. */ + private static class Handler implements ErrorHandler { - public InputSource resolveEntity(String publicId, final String systemId) - throws SAXException, IOException { - // check for recognized ids - String filename = (String) publicIds.get(publicId); - if (filename == null) { - filename = (String) systemIds.get(systemId); - } - final String finalName = filename; - if (finalName == null) { - return null; - } else { - // Substitute the dtd with the one from javax.jdo.jdo.dtd, - // but only if the publicId is equal to RECOGNIZED_PUBLIC_ID - // or there is no publicID and the systemID is equal to - // RECOGNIZED_SYSTEM_ID. - InputStream stream = - doPrivileged( - new PrivilegedAction() { - public InputStream run() { - return getClass().getClassLoader().getResourceAsStream(finalName); - } - }); - if (stream == null) { - throw new JDOFatalException( - "Cannot load " - + finalName - + ", because the file does not exist in the jdo.jar file, " - + "or the JDOParser class is not granted permission to read this file. " - + "The metadata .xml file contained PUBLIC=" - + publicId - + " SYSTEM=" - + systemId - + "."); + private File fileUnderTest; + private String[] lines; + private StringBuffer messages; + + public void error(SAXParseException ex) { + append("Handler.error: ", ex); + } + + public void fatalError(SAXParseException ex) { + append("Handler.fatalError: ", ex); + } + + public void warning(SAXParseException ex) { + append("Handler.warning: ", ex); + } + + public void init(File file) { + this.fileUnderTest = file; + this.messages = new StringBuffer(); + this.lines = null; } - return new InputSource(new InputStreamReader(stream)); - } - } - } - /** Helper class to find all test JDO metadata files. */ - public static class XMLFinder { + public String getMessages() { + return (messages.length() == 0) ? null : messages.toString(); + } - private List metadataFiles = new ArrayList(); - private final boolean recursive; + private void append(String prefix, SAXParseException ex) { + int lineNumber = ex.getLineNumber(); + int columnNumber = ex.getColumnNumber(); + messages.append("------------------------").append(NL); + messages.append(prefix).append(fileUnderTest.getName()); + messages.append(" [line=").append(lineNumber); + messages.append(", col=").append(columnNumber).append("]: "); + messages.append(ex.getMessage()).append(NL); + messages.append(getErrorLocation(lineNumber, columnNumber)); + } - /** Constructor. */ - public XMLFinder(String[] fileNames, boolean recursive) { - this.recursive = recursive; - if (fileNames == null) return; - for (int i = 0; i < fileNames.length; i++) { - appendTestFiles(fileNames[i]); - } + private String[] getLines() { + if (lines == null) { + try { + BufferedReader bufferedReader = + new BufferedReader(new FileReader(fileUnderTest)); + ArrayList tmp = new ArrayList(); + while (bufferedReader.ready()) { + tmp.add(bufferedReader.readLine()); + } + lines = (String[])tmp.toArray(new String[tmp.size()]); + } catch (IOException ex) { + throw new JDOFatalException("getLines: caught IOException", ex); + } + } + return lines; + } + + /** Return the error location for the file under test. + */ + private String getErrorLocation(int lineNumber, int columnNumber) { + String[] lines = getLines(); + int length = lines.length; + if (lineNumber > length) { + return "Line number " + lineNumber + + " exceeds the number of lines in the file (" + + lines.length + ")"; + } else if (lineNumber < 1) { + return "Line number " + lineNumber + + " does not allow retriving the error location."; + } + StringBuffer buf = new StringBuffer(); + if (lineNumber > 2) { + buf.append(lines[lineNumber-3]); + buf.append(NL); + buf.append(lines[lineNumber-2]); + buf.append(NL); + } + buf.append(lines[lineNumber-1]); + buf.append(NL); + for (int i = 1; i < columnNumber; ++i) { + buf.append(' '); + } + buf.append("^\n"); + if (lineNumber + 1 < length) { + buf.append(lines[lineNumber]); + buf.append(NL); + buf.append(lines[lineNumber+1]); + buf.append(NL); + } + return buf.toString(); + } } - /** Returns array of files of matching file names. */ - private File[] getFiles(File dir, final String suffix) { - FilenameFilter filter = - new FilenameFilter() { - public boolean accept(File file, String name) { - return name.endsWith(suffix); + /** + * Implementation of EntityResolver interface to check the jdo.dtd location. + * TODO Somebody should update these 2.2 to 3.1 or later at some point. + */ + private static class JDOEntityResolver + implements EntityResolver { + + private static final String RECOGNIZED_JDO_PUBLIC_ID = + "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 3.2//EN"; + private static final String RECOGNIZED_JDO_SYSTEM_ID = + "file:/javax/jdo/jdo_3_2.dtd"; + private static final String RECOGNIZED_JDO_SYSTEM_ID2 = + "http://xmlns.jcp.org/dtd/jdo_3_2.dtd"; + private static final String RECOGNIZED_ORM_PUBLIC_ID = + "-//Sun Microsystems, Inc.//DTD Java Data Objects Mapping Metadata 3.2//EN"; + private static final String RECOGNIZED_ORM_SYSTEM_ID = + "file:/javax/jdo/orm_3_2.dtd"; + private static final String RECOGNIZED_ORM_SYSTEM_ID2 = + "http://xmlns.jcp.org/dtd/orm_3_2.dtd"; + private static final String RECOGNIZED_JDOQUERY_PUBLIC_ID = + "-//Sun Microsystems, Inc.//DTD Java Data Objects Query Metadata 3.2//EN"; + private static final String RECOGNIZED_JDOQUERY_SYSTEM_ID = + "file:/javax/jdo/jdoquery_3_2.dtd"; + private static final String RECOGNIZED_JDOQUERY_SYSTEM_ID2 = + "http://xmlns.jcp.org/dtd/jdoquery_3_2.dtd"; + private static final String JDO_DTD_FILENAME = + "javax/jdo/jdo_3_2.dtd"; + private static final String ORM_DTD_FILENAME = + "javax/jdo/orm_3_2.dtd"; + private static final String JDOQUERY_DTD_FILENAME = + "javax/jdo/jdoquery_3_2.dtd"; + + static Map publicIds = new HashMap(); + static Map systemIds = new HashMap(); + static { + publicIds.put(RECOGNIZED_JDO_PUBLIC_ID, JDO_DTD_FILENAME); + publicIds.put(RECOGNIZED_ORM_PUBLIC_ID, ORM_DTD_FILENAME); + publicIds.put(RECOGNIZED_JDOQUERY_PUBLIC_ID, JDOQUERY_DTD_FILENAME); + systemIds.put(RECOGNIZED_JDO_SYSTEM_ID, JDO_DTD_FILENAME); + systemIds.put(RECOGNIZED_ORM_SYSTEM_ID, ORM_DTD_FILENAME); + systemIds.put(RECOGNIZED_JDOQUERY_SYSTEM_ID, JDOQUERY_DTD_FILENAME); + systemIds.put(RECOGNIZED_JDO_SYSTEM_ID2, JDO_DTD_FILENAME); + systemIds.put(RECOGNIZED_ORM_SYSTEM_ID2, ORM_DTD_FILENAME); + systemIds.put(RECOGNIZED_JDOQUERY_SYSTEM_ID2, JDOQUERY_DTD_FILENAME); + } + public InputSource resolveEntity(String publicId, final String systemId) + throws SAXException, IOException + { + // check for recognized ids + String filename = (String)publicIds.get(publicId); + if (filename == null) { + filename = (String)systemIds.get(systemId); } - }; - return dir.listFiles(filter); + final String finalName = filename; + if (finalName == null) { + return null; + } else { + // Substitute the dtd with the one from javax.jdo.jdo.dtd, + // but only if the publicId is equal to RECOGNIZED_PUBLIC_ID + // or there is no publicID and the systemID is equal to + // RECOGNIZED_SYSTEM_ID. + InputStream stream = doPrivileged ( + new PrivilegedAction () { + public InputStream run () { + return getClass().getClassLoader(). + getResourceAsStream(finalName); + } + } + ); + if (stream == null) { + throw new JDOFatalException("Cannot load " + finalName + + ", because the file does not exist in the jdo.jar file, " + + "or the JDOParser class is not granted permission to read this file. " + + "The metadata .xml file contained PUBLIC=" + publicId + + " SYSTEM=" + systemId + "."); + } + return new InputSource(new InputStreamReader(stream)); + } + } } - /** */ - private File[] getDirectories(File dir) { - FileFilter filter = - new FileFilter() { - public boolean accept(File pathname) { - return pathname.isDirectory(); + + /** Helper class to find all test JDO metadata files. */ + public static class XMLFinder { + + private List metadataFiles = new ArrayList(); + private final boolean recursive; + + /** Constructor. */ + public XMLFinder(String[] fileNames, boolean recursive) { + this.recursive = recursive; + if (fileNames == null) return; + for (int i = 0; i < fileNames.length; i++) { + appendTestFiles(fileNames[i]); + } + } + + /** Returns array of files of matching file names. */ + private File[] getFiles(File dir, final String suffix) { + FilenameFilter filter = new FilenameFilter() { + public boolean accept(File file, String name) { + return name.endsWith(suffix); + } + }; + return dir.listFiles(filter); + } + + /** */ + private File[] getDirectories(File dir) { + FileFilter filter = new FileFilter() { + public boolean accept(File pathname) { + return pathname.isDirectory(); + } + }; + return dir.listFiles(filter); + } + + /** */ + private void appendTestFiles(String fileName) { + File file = new File(fileName); + if (file.isDirectory()) { + processDirectory(file); + } else if (fileName.endsWith(".jdo") || + fileName.endsWith(".orm") || + fileName.endsWith(".jdoquery")) { + metadataFiles.add(new File(fileName)); + } + } + + /** Adds all files with suffix .jdo, .orm and .jdoquery to the list of + * metadata files. Recursively process subdirectories if recursive + * flag is set. */ + private void processDirectory(File dir) { + metadataFiles.addAll(Arrays.asList(getFiles(dir, ".jdo"))); + metadataFiles.addAll(Arrays.asList(getFiles(dir, ".orm"))); + metadataFiles.addAll(Arrays.asList(getFiles(dir, ".jdoquery"))); + if (recursive) { + File[] subdirs = getDirectories(dir); + for (int i = 0; i < subdirs.length; i++) { + processDirectory(subdirs[i]); + } } - }; - return dir.listFiles(filter); + } + + /** Returns an array of test files with suffix .jdo, .orm or .jdoquery. */ + public File[] getMetadataFiles() { + return (File[])metadataFiles.toArray(new File[metadataFiles.size()]); + } + } /** */ - private void appendTestFiles(String fileName) { - File file = new File(fileName); - if (file.isDirectory()) { - processDirectory(file); - } else if (fileName.endsWith(".jdo") - || fileName.endsWith(".orm") - || fileName.endsWith(".jdoquery")) { - metadataFiles.add(new File(fileName)); - } + private static String[] checkMetadataSystemProperty() { + String[] ret = null; + String metadata = System.getProperty(METADATA_PROP); + if ((metadata != null) && (metadata.length() > 0)) { + List entries = new ArrayList(); + StringTokenizer st = new StringTokenizer(metadata, DELIM); + while (st.hasMoreTokens()) { + entries.add(st.nextToken()); + } + ret = (String[])entries.toArray(new String[entries.size()]); + } + return ret; } /** - * Adds all files with suffix .jdo, .orm and .jdoquery to the list of metadata files. - * Recursively process subdirectories if recursive flag is set. + * Command line tool to test JDO metadata files. + * Usage: XMLTestUtil [-r] + */ - private void processDirectory(File dir) { - metadataFiles.addAll(Arrays.asList(getFiles(dir, ".jdo"))); - metadataFiles.addAll(Arrays.asList(getFiles(dir, ".orm"))); - metadataFiles.addAll(Arrays.asList(getFiles(dir, ".jdoquery"))); - if (recursive) { - File[] subdirs = getDirectories(dir); - for (int i = 0; i < subdirs.length; i++) { - processDirectory(subdirs[i]); + public static void main(String args[]) { + String[] fromProp = checkMetadataSystemProperty(); + boolean recursive = Boolean.getBoolean(RECURSIVE_PROP); + + // handle command line args + String[] fileNames = null; + if ((args.length > 0) && ("-r".equals(args[0]))) { + recursive = true; + fileNames = new String[args.length - 1]; + System.arraycopy(args, 1, fileNames, 0, args.length - 1); + } else { + fileNames = args; + } + + // check args + if ((fileNames.length == 0) && (fromProp == null)) { + System.err.println( + "No commandline arguments and system property metadata not defined; " + + "nothing to be tested.\nUsage: XMLTestUtil [-r] \n" + + "\tAll .jdo, .orm, and .jdoquery files in the directory (recursively) will be tested."); + } else if ((fileNames.length == 0) && (fromProp != null)) { + // use metadata system property + fileNames = fromProp; + } else if ((fileNames.length != 0) && (fromProp != null)) { + System.err.println( + "Commandline arguments specified and system property metadata defined; " + + "ignoring system property metadata."); } - } - } - /** Returns an array of test files with suffix .jdo, .orm or .jdoquery. */ - public File[] getMetadataFiles() { - return (File[]) metadataFiles.toArray(new File[metadataFiles.size()]); - } - } - - /** */ - private static String[] checkMetadataSystemProperty() { - String[] ret = null; - String metadata = System.getProperty(METADATA_PROP); - if ((metadata != null) && (metadata.length() > 0)) { - List entries = new ArrayList(); - StringTokenizer st = new StringTokenizer(metadata, DELIM); - while (st.hasMoreTokens()) { - entries.add(st.nextToken()); - } - ret = (String[]) entries.toArray(new String[entries.size()]); - } - return ret; - } - - /** Command line tool to test JDO metadata files. Usage: XMLTestUtil [-r] + */ - public static void main(String args[]) { - String[] fromProp = checkMetadataSystemProperty(); - boolean recursive = Boolean.getBoolean(RECURSIVE_PROP); - - // handle command line args - String[] fileNames = null; - if ((args.length > 0) && ("-r".equals(args[0]))) { - recursive = true; - fileNames = new String[args.length - 1]; - System.arraycopy(args, 1, fileNames, 0, args.length - 1); - } else { - fileNames = args; + // run the test + XMLTestUtil xmlTest = new XMLTestUtil(); + File[] files = new XMLFinder(fileNames, recursive).getMetadataFiles(); + for (int i = 0; i < files.length; i++) { + File file = files[i]; + System.out.print("Checking " + file.getPath() + ": "); + String messages = xmlTest.checkXML(file, true); + messages = (messages == null) ? "OK" : NL + messages; + System.out.println(messages); + } } - // check args - if ((fileNames.length == 0) && (fromProp == null)) { - System.err.println( - "No commandline arguments and system property metadata not defined; " - + "nothing to be tested.\nUsage: XMLTestUtil [-r] \n" - + "\tAll .jdo, .orm, and .jdoquery files in the directory (recursively) will be tested."); - } else if ((fileNames.length == 0) && (fromProp != null)) { - // use metadata system property - fileNames = fromProp; - } else if ((fileNames.length != 0) && (fromProp != null)) { - System.err.println( - "Commandline arguments specified and system property metadata defined; " - + "ignoring system property metadata."); - } - // run the test - XMLTestUtil xmlTest = new XMLTestUtil(); - File[] files = new XMLFinder(fileNames, recursive).getMetadataFiles(); - for (int i = 0; i < files.length; i++) { - File file = files[i]; - System.out.print("Checking " + file.getPath() + ": "); - String messages = xmlTest.checkXML(file, true); - messages = (messages == null) ? "OK" : NL + messages; - System.out.println(messages); - } - } - - @SuppressWarnings("unchecked") - private static T doPrivileged(PrivilegedAction privilegedAction) { - try { - return (T) LegacyJava.doPrivilegedAction.invoke(null, privilegedAction); - } catch (IllegalAccessException | InvocationTargetException e) { - if (e.getCause() instanceof RuntimeException) { - throw (RuntimeException) e.getCause(); - } - throw new JDOFatalInternalException(e.getMessage()); + @SuppressWarnings("unchecked") + private static T doPrivileged(PrivilegedAction privilegedAction) { + try { + return (T) LegacyJava.doPrivilegedAction.invoke(null, privilegedAction); + } catch (IllegalAccessException | InvocationTargetException e) { + if (e.getCause() instanceof RuntimeException) { + throw (RuntimeException) e.getCause(); + } + throw new JDOFatalInternalException(e.getMessage()); + } } - } } + diff --git a/exectck/src/main/java/org/apache/jdo/exectck/AbstractTCKMojo.java b/exectck/src/main/java/org/apache/jdo/exectck/AbstractTCKMojo.java index 39db770c1..bd266f0a6 100644 --- a/exectck/src/main/java/org/apache/jdo/exectck/AbstractTCKMojo.java +++ b/exectck/src/main/java/org/apache/jdo/exectck/AbstractTCKMojo.java @@ -22,129 +22,132 @@ import java.util.Collection; import java.util.HashSet; import java.util.Properties; + import org.apache.commons.io.FileUtils; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.Parameter; -/** Abstract Mojo to be extended for the actual goals of this maven plugin. */ +/** + * Abstract Mojo to be extended for the actual goals of this maven plugin. + */ public abstract class AbstractTCKMojo extends AbstractMojo { - /** Filename of log4j2 configuration file. */ - protected final String LOG4J2_CONFIGURATION = "log4j2.xml"; - - /** Location of TCK generated output. */ - @Parameter( - property = "project.build.directory", - defaultValue = "${basedir}/target", - required = true) - protected String buildDirectory; - - /** Location of the logs directory. */ - @Parameter( - property = "project.log.directory", - defaultValue = "${project.build.directory}/logs", - required = true) - protected File logsDirectory; - - /** Location of the configuration directory. */ - @Parameter( - property = "project.conf.directory", - defaultValue = "${basedir}/src/main/resources/conf", - required = true) - protected String confDirectory; - - /** Location of the configuration directory. */ - @Parameter( - property = "project.sql.directory", - defaultValue = "${basedir}/src/main/resources/sql", - required = true) - protected String sqlDirectory; - - /** - * List of configuration files, each describing a test configuration. Note: Collection can only be - * configured in pom.xml. Using multi-valued type because long String cannot be broken across - * lines in pom.xml. - */ - @Parameter protected Collection cfgs; - - /** - * List of configuration files, each describing a test configuration. Allows command line override - * of configured cfgs value. - */ - @Parameter(property = "jdo.tck.cfglist") - protected String cfgList; - - /** List of databases to run tests under. Currently only derby is supported. */ - @Parameter(property = "jdo.tck.dblist", defaultValue = "derby", required = true) - protected String dblist; - - /** - * Implementation to be tested (jdori or iut). Any value other than "jdori" will test an - * appropriately configured IUT - */ - @Parameter(property = "jdo.tck.impl", defaultValue = "jdori", required = true) - protected String impl; - - /** Location of implementation log file. */ - @Parameter( - property = "jdo.tck.impl.logfile", - defaultValue = "${user.dir}/datanucleus.txt", - required = true) - protected String implLogFile; - - /** Classpath including the dependencies using : as separator between entries. */ - @Parameter(property = "jdo.tck.dependencyClasspath", defaultValue = "", required = true) - protected String dependencyClasspath; - - protected Collection dbs = new HashSet(); - - /** List of identity types to be tested. */ - @Parameter( - property = "jdo.tck.identitytypes", - defaultValue = "applicationidentity datastoreidentity", - required = true) - protected String identitytypes; - - protected Collection idtypes = new HashSet(); - - /** - * Convenience method to set the cfgList from the file - * "src/main/resources/conf/configurations.list". - * - * @throws MojoExecutionException If the file could not be found/opened - */ - protected void setCfgListFromFile() throws MojoExecutionException { - try { - Properties defaultProps = new Properties(); - FileInputStream in = - new FileInputStream(confDirectory + File.separator + "configurations.list"); - defaultProps.load(in); - in.close(); - cfgList = defaultProps.getProperty("jdo.tck.cfglist"); - } catch (Exception e) { - // Error finding configurations.list - throw new MojoExecutionException( - "No configuration specified and could not " - + "find 'src/main/resources/conf/configurations.list'"); + /** + * Filename of log4j2 configuration file. + */ + protected final String LOG4J2_CONFIGURATION = "log4j2.xml"; + + /** + * Location of TCK generated output. + */ + @Parameter( property = "project.build.directory", defaultValue = "${basedir}/target", required = true) + protected String buildDirectory; + + /** + * Location of the logs directory. + */ + @Parameter( property = "project.log.directory", defaultValue = "${project.build.directory}/logs", required = true) + protected File logsDirectory; + + /** + * Location of the configuration directory. + */ + @Parameter( property = "project.conf.directory", defaultValue = "${basedir}/src/main/resources/conf", required = true) + protected String confDirectory; + + /** + * Location of the configuration directory. + */ + @Parameter( property = "project.sql.directory", defaultValue = "${basedir}/src/main/resources/sql", required = true) + protected String sqlDirectory; + + /** + * List of configuration files, each describing a test configuration. + * Note: Collection can only be configured in pom.xml. Using multi-valued + * type because long String cannot be broken across lines in pom.xml. + */ + @Parameter + protected Collection cfgs; + + /** + * List of configuration files, each describing a test configuration. + * Allows command line override of configured cfgs value. + */ + @Parameter( property = "jdo.tck.cfglist") + protected String cfgList; + + /** + * List of databases to run tests under. + * Currently only derby is supported. + */ + @Parameter( property = "jdo.tck.dblist", defaultValue = "derby", required = true) + protected String dblist; + + /** + * Implementation to be tested (jdori or iut). + * Any value other than "jdori" will test an appropriately configured IUT + */ + @Parameter( property = "jdo.tck.impl", defaultValue = "jdori", required = true) + protected String impl; + + /** + * Location of implementation log file. + */ + @Parameter( property = "jdo.tck.impl.logfile", defaultValue = "${user.dir}/datanucleus.txt", required = true) + protected String implLogFile; + + /** + * Classpath including the dependencies using : as separator between entries. + */ + @Parameter( property = "jdo.tck.dependencyClasspath", defaultValue = "", required = true) + protected String dependencyClasspath; + + protected Collection dbs = new HashSet(); + + /** + * List of identity types to be tested. + */ + @Parameter( property = "jdo.tck.identitytypes", defaultValue = "applicationidentity datastoreidentity", required = true) + protected String identitytypes; + + protected Collection idtypes = new HashSet(); + + /** + * Convenience method to set the cfgList from the file + * "src/main/resources/conf/configurations.list". + * @throws MojoExecutionException If the file could not be found/opened + */ + protected void setCfgListFromFile() throws MojoExecutionException { + try { + Properties defaultProps = new Properties(); + FileInputStream in = new FileInputStream(confDirectory + File.separator + + "configurations.list"); + defaultProps.load(in); + in.close(); + cfgList = defaultProps.getProperty("jdo.tck.cfglist"); + } + catch (Exception e) { + // Error finding configurations.list + throw new MojoExecutionException("No configuration specified and could not " + + "find 'src/main/resources/conf/configurations.list'"); + } } - } - - protected void copyLog4j2ConfigurationFile() throws IOException { - File fromFile = new File(confDirectory + File.separator + impl + "-" + LOG4J2_CONFIGURATION); - File toFile = - new File( - buildDirectory + File.separator + "classes" + File.separator + LOG4J2_CONFIGURATION); - FileUtils.copyFile(fromFile, toFile); - } - - protected void resetFileContent(String fileName) throws MojoExecutionException { - File file = new File(fileName); - // reset file content - try { - FileUtils.write(file, "", Charset.defaultCharset()); - } catch (IOException e) { - throw new MojoExecutionException("Failed to reset file content: " + file.toURI()); + + protected void copyLog4j2ConfigurationFile() throws IOException { + File fromFile = new File(confDirectory + File.separator + impl + "-" + LOG4J2_CONFIGURATION); + File toFile = new File(buildDirectory + File.separator + "classes" + + File.separator + LOG4J2_CONFIGURATION); + FileUtils.copyFile(fromFile, toFile); + } + + protected void resetFileContent(String fileName) throws MojoExecutionException { + File file = new File(fileName); + // reset file content + try { + FileUtils.write(file, "", Charset.defaultCharset()); + } catch (IOException e) { + throw new MojoExecutionException("Failed to reset file content: " + file.toURI()); + } } - } } diff --git a/exectck/src/main/java/org/apache/jdo/exectck/Enhance.java b/exectck/src/main/java/org/apache/jdo/exectck/Enhance.java index 11ee87c98..2f4e7260a 100644 --- a/exectck/src/main/java/org/apache/jdo/exectck/Enhance.java +++ b/exectck/src/main/java/org/apache/jdo/exectck/Enhance.java @@ -5,290 +5,256 @@ * 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 + * + * 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.jdo.exectck; +import java.net.MalformedURLException; +import java.nio.charset.Charset; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.apache.commons.io.FileUtils; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; + import java.io.File; import java.io.IOException; -import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; -import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.jdo.JDOEnhancer; import javax.jdo.JDOHelper; -import org.apache.commons.io.FileUtils; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -/** Goal that enhances test classes for testing a JDO implementation. */ -@Mojo(name = "enhance") +/** + * Goal that enhances test classes for testing a JDO implementation. + */ +@Mojo( name = "enhance" ) public class Enhance extends AbstractTCKMojo { - private static final String[] PC_PKG_DIRS = { - "org" - + File.separator - + "apache" - + File.separator - + "jdo" - + File.separator - + "tck" - + File.separator - + "api" - + File.separator, - "org" - + File.separator - + "apache" - + File.separator - + "jdo" - + File.separator - + "tck" - + File.separator - + "pc" - + File.separator, - "org" - + File.separator - + "apache" - + File.separator - + "jdo" - + File.separator - + "tck" - + File.separator - + "models" - + File.separator - + "inheritance" - + File.separator - }; - /** Location of TCK generated output. */ - @Parameter(property = "jdo.tck.doEnhance", defaultValue = "true", required = true) - private boolean doEnhance; + private static final String[] PC_PKG_DIRS = { + "org" + File.separator + "apache" + File.separator + "jdo" + File.separator + "tck" + File.separator + "api" + File.separator, + "org" + File.separator + "apache" + File.separator + "jdo" + File.separator + "tck" + File.separator + "pc" + File.separator, + "org" + File.separator + "apache" + File.separator + "jdo" + File.separator + "tck" + File.separator + "models" + File.separator + "inheritance" + File.separator + }; + /** + * Location of TCK generated output. + */ + @Parameter( property = "jdo.tck.doEnhance", defaultValue = "true", required = true) + private boolean doEnhance; - /** Root of the TCK source installation. */ - @Parameter( - property = "project.src.directory", - defaultValue = "${basedir}/src/main/resources", - required = true) - private String srcDirectory; + /** + * Root of the TCK source installation. + */ + @Parameter( property = "project.src.directory", defaultValue = "${basedir}/src/main/resources", required = true) + private String srcDirectory; - /** List of identity types to be tested. */ - @Parameter( - property = "jdo.tck.identitytypes", - defaultValue = "applicationidentity datastoreidentity", - required = true) - private String identitytypes; + /** + * List of identity types to be tested. + */ + @Parameter( property = "jdo.tck.identitytypes", defaultValue = "applicationidentity datastoreidentity", required = true) + private String identitytypes; - private Collection idtypes; + private Collection idtypes; - @Override - public void execute() throws MojoExecutionException, MojoFailureException { + @Override + public void execute() throws MojoExecutionException, MojoFailureException { - if (!doEnhance) { - System.out.println("Skipping Enhance goal!"); - return; - } + if (!doEnhance) { + System.out.println("Skipping Enhance goal!"); + return; + } - idtypes = new HashSet(); - PropertyUtils.string2Set(identitytypes, idtypes); + idtypes = new HashSet(); + PropertyUtils.string2Set(identitytypes, idtypes); - // Reset logfile content (may not be empty if previous run crashed) - resetFileContent(implLogFile); + // Reset logfile content (may not be empty if previous run crashed) + resetFileContent(implLogFile); - // Create directory for enhancer logs - String enhanceLogsDirName = logsDirectory + File.separator + "enhanced"; - File enhancerLogsDir = new File(enhanceLogsDirName); - if (!(enhancerLogsDir.exists()) && !(enhancerLogsDir.mkdirs())) { - throw new MojoExecutionException("Failed to create directory " + enhancerLogsDir); - } + // Create directory for enhancer logs + String enhanceLogsDirName = logsDirectory + File.separator + "enhanced"; + File enhancerLogsDir = new File(enhanceLogsDirName); + if (!(enhancerLogsDir.exists()) && !(enhancerLogsDir.mkdirs())) { + throw new MojoExecutionException("Failed to create directory " + + enhancerLogsDir); + } - try { - copyLog4j2ConfigurationFile(); - } catch (IOException ex) { - Logger.getLogger(Enhance.class.getName()).log(Level.SEVERE, null, ex); - } + try { + copyLog4j2ConfigurationFile(); + } catch (IOException ex) { + Logger.getLogger(Enhance.class.getName()).log(Level.SEVERE, null, ex); + } - // Create directory for enhanced classes - String enhancedDirName = - buildDirectory + File.separator + "enhanced" + File.separator + impl + File.separator; - File enhancedDir = new File(enhancedDirName); - if (!(enhancedDir.exists()) && !(enhancedDir.mkdirs())) { - throw new MojoExecutionException("Failed to create directory " + enhancedDir); - } + // Create directory for enhanced classes + String enhancedDirName = buildDirectory + File.separator + "enhanced" + + File.separator + impl + File.separator; + File enhancedDir = new File(enhancedDirName); + if (!(enhancedDir.exists()) && !(enhancedDir.mkdirs())) { + throw new MojoExecutionException("Failed to create directory " + + enhancedDir); + } - String[] metadataExtensions = {"jdo", "jdoquery", "orm", "xml", "properties"}; - String[] srcDirs = {"jdo", "orm", "testdata"}; - File toFile = null; - File fromFile = null; - String fromFileName = null; - String pkgName = null; - int startIdx = -1; - Iterator fi = null; - String[] classArray = new String[10]; - String enhancedIdDirName = null; - String classesDirName = buildDirectory + File.separator + "classes" + File.separator; - ArrayList classes = null; + String[] metadataExtensions = {"jdo", "jdoquery", "orm", "xml", "properties"}; + String[] srcDirs = {"jdo", "orm", "testdata"}; + File toFile = null; + File fromFile = null; + String fromFileName = null; + String pkgName = null; + int startIdx = -1; + Iterator fi = null; + String[] classArray = new String[10]; + String enhancedIdDirName = null; + String classesDirName = buildDirectory + File.separator + + "classes" + File.separator; + ArrayList classes = null; - // Copy metadata from src to enhanced - for (String idtype : idtypes) { - for (String srcDir : srcDirs) { - String srcDirName = srcDirectory + File.separator + srcDir; - // iterator over list of abs name of metadata files in src - fi = FileUtils.iterateFiles(new File(srcDirName), metadataExtensions, true); + // Copy metadata from src to enhanced + for (String idtype : idtypes) { + for (String srcDir : srcDirs) { + String srcDirName = srcDirectory + File.separator + srcDir; + // iterator over list of abs name of metadata files in src + fi = FileUtils.iterateFiles( + new File(srcDirName), metadataExtensions, true); - while (fi.hasNext()) { - try { - fromFile = fi.next(); - fromFileName = fromFile.toString(); - if ((startIdx = fromFileName.indexOf(idtype + File.separator)) > -1) { - // fully specified name of file (idtype + package + filename) - pkgName = fromFileName.substring(startIdx); - toFile = new File(enhancedDirName + File.separator + pkgName); - FileUtils.copyFile(fromFile, toFile); - } else if (srcDir.equals("testdata")) { - startIdx = fromFileName.indexOf("org" + File.separator); - pkgName = fromFileName.substring(startIdx); - toFile = - new File(enhancedDirName + File.separator + idtype + File.separator + pkgName); - FileUtils.copyFile(fromFile, toFile); - } else { - continue; // idtype not in pathname, do not copy + while (fi.hasNext()) { + try { + fromFile = fi.next(); + fromFileName = fromFile.toString(); + if ((startIdx = fromFileName.indexOf(idtype + File.separator)) > -1) { + // fully specified name of file (idtype + package + filename) + pkgName = fromFileName.substring(startIdx); + toFile = new File(enhancedDirName + File.separator + + pkgName); + FileUtils.copyFile(fromFile, toFile); + } else if (srcDir.equals("testdata")) { + startIdx = fromFileName.indexOf("org" + File.separator); + pkgName = fromFileName.substring(startIdx); + toFile = new File(enhancedDirName + File.separator + + idtype + File.separator + pkgName); + FileUtils.copyFile(fromFile, toFile); + } else { + continue; // idtype not in pathname, do not copy + } + } catch (IOException ex) { + throw new MojoExecutionException("Failed to copy files from " + + fromFileName + " to " + toFile.toString() + + ": " + ex.getLocalizedMessage()); + } + } + + // Copy pc and pa classes from target/classes to enhanced + String[] extensions = {"class"}; + enhancedIdDirName = enhancedDirName + idtype + File.separator; + classes = new ArrayList(); + for (String pcPkgName : PC_PKG_DIRS) { + // iterator over list of abs name of class files in target/classes + fi = FileUtils.iterateFiles( + new File(classesDirName + pcPkgName), extensions, true); + while (fi.hasNext()) { + try { + fromFile = fi.next(); + fromFileName = fromFile.toString(); + // fully specified name of file (package + filename) + int index = fromFileName.indexOf(pcPkgName); + if (index == -1) { + throw new MojoExecutionException( + "Cannot get index of package path " + pcPkgName + + " in file name" + fromFileName); + } + toFile = new File(enhancedIdDirName + fromFileName.substring(index)); + FileUtils.copyFile(fromFile, toFile); + classes.add(toFile.toString()); + } catch (IOException ex) { + throw new MojoExecutionException("Failed to copy files from " + + fromFileName + " to " + toFile.toString() + + ": " + ex.getLocalizedMessage()); + } + } + } } - } catch (IOException ex) { - throw new MojoExecutionException( - "Failed to copy files from " - + fromFileName - + " to " - + toFile.toString() - + ": " - + ex.getLocalizedMessage()); - } - } - // Copy pc and pa classes from target/classes to enhanced - String[] extensions = {"class"}; - enhancedIdDirName = enhancedDirName + idtype + File.separator; - classes = new ArrayList(); - for (String pcPkgName : PC_PKG_DIRS) { - // iterator over list of abs name of class files in target/classes - fi = FileUtils.iterateFiles(new File(classesDirName + pcPkgName), extensions, true); - while (fi.hasNext()) { + // Enhance classes + + // Build ClassLoader for finding enhancer + URL[] classPathURLs1 = new URL[2]; + ArrayList cpList1 = new ArrayList(); + ClassLoader enhancerLoader = null; try { - fromFile = fi.next(); - fromFileName = fromFile.toString(); - // fully specified name of file (package + filename) - int index = fromFileName.indexOf(pcPkgName); - if (index == -1) { - throw new MojoExecutionException( - "Cannot get index of package path " - + pcPkgName - + " in file name" - + fromFileName); - } - toFile = new File(enhancedIdDirName + fromFileName.substring(index)); - FileUtils.copyFile(fromFile, toFile); - classes.add(toFile.toString()); - } catch (IOException ex) { - throw new MojoExecutionException( - "Failed to copy files from " - + fromFileName - + " to " - + toFile.toString() - + ": " - + ex.getLocalizedMessage()); + // Must add enhancedIdDirName first!! + cpList1.add((new File(enhancedIdDirName)).toURI().toURL()); + cpList1.add((new File(classesDirName)).toURI().toURL()); + for (String dependency : this.dependencyClasspath.split(File.pathSeparator)) { + cpList1.add(new File(dependency).toURI().toURL()); + } + enhancerLoader = new URLClassLoader(cpList1.toArray(classPathURLs1), + getClass().getClassLoader()); + System.out.println("ClassLoader enhancerLoader:"); + Utilities.printClasspath(enhancerLoader); + } catch (MalformedURLException ex) { + Logger.getLogger(Enhance.class.getName()).log(Level.SEVERE, null, ex); } - } - } - } - - // Enhance classes + + // Context classloader for finding log4j2 configuration + ClassLoader prevCl = Thread.currentThread().getContextClassLoader(); + try { + URL enhancedClassesUrl = (new File(enhancedIdDirName)).toURI().toURL(); + // Classes dir needed for org.apache.jdo.tck.util.TCKFileAppender + URL classesUrl = (new File(classesDirName)).toURI().toURL(); + ClassLoader loggingPropsCl = + URLClassLoader.newInstance(new URL[]{ + enhancedClassesUrl, classesUrl}, prevCl); + Thread.currentThread().setContextClassLoader(loggingPropsCl); + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("ClassLoader ContextClassLoader:"); + Utilities.printClasspath(Thread.currentThread().getContextClassLoader()); + System.out.println("Get enhancer"); + JDOEnhancer enhancer = JDOHelper.getEnhancer(enhancerLoader); + System.out.println("enhancer.setVerbose()"); + enhancer.setVerbose(true); + System.out.println("enhancer.setClassLoader()"); + enhancer.setClassLoader(enhancerLoader); + String[] classArr = classes.toArray(classArray); + enhancer.addClasses(classArr); + System.out.println("Enhancing classes for identity type " + idtype); + // enhancer needs org/apache/jdo/tck/util/DeepEquality + enhancer.enhance(); + Thread.currentThread().setContextClassLoader(prevCl); - // Build ClassLoader for finding enhancer - URL[] classPathURLs1 = new URL[2]; - ArrayList cpList1 = new ArrayList(); - ClassLoader enhancerLoader = null; - try { - // Must add enhancedIdDirName first!! - cpList1.add((new File(enhancedIdDirName)).toURI().toURL()); - cpList1.add((new File(classesDirName)).toURI().toURL()); - for (String dependency : this.dependencyClasspath.split(File.pathSeparator)) { - cpList1.add(new File(dependency).toURI().toURL()); + // Move log to per-test location + String idname = "dsid"; + if (idtype.trim().equals("applicationidentity")) { + idname = "app"; + } + String testLogFilename = logsDirectory + File.separator + + "enhanced" + File.separator + idname + + "-" + impl + ".txt"; + System.out.println("testLogFilename is " + testLogFilename); + try { + File logFile = new File(implLogFile); + File testLogFile = new File(testLogFilename); + FileUtils.copyFile(logFile, testLogFile); + // reset file content + FileUtils.write(logFile, "", Charset.defaultCharset()); + FileUtils.forceDeleteOnExit(logFile); + } catch (Exception e) { + System.out.println(">> Error moving implementation log file: " + + e.getMessage()); + } } - enhancerLoader = - new URLClassLoader(cpList1.toArray(classPathURLs1), getClass().getClassLoader()); - System.out.println("ClassLoader enhancerLoader:"); - Utilities.printClasspath(enhancerLoader); - } catch (MalformedURLException ex) { - Logger.getLogger(Enhance.class.getName()).log(Level.SEVERE, null, ex); - } - - // Context classloader for finding log4j2 configuration - ClassLoader prevCl = Thread.currentThread().getContextClassLoader(); - try { - URL enhancedClassesUrl = (new File(enhancedIdDirName)).toURI().toURL(); - // Classes dir needed for org.apache.jdo.tck.util.TCKFileAppender - URL classesUrl = (new File(classesDirName)).toURI().toURL(); - ClassLoader loggingPropsCl = - URLClassLoader.newInstance(new URL[] {enhancedClassesUrl, classesUrl}, prevCl); - Thread.currentThread().setContextClassLoader(loggingPropsCl); - } catch (Exception e) { - e.printStackTrace(); - } - System.out.println("ClassLoader ContextClassLoader:"); - Utilities.printClasspath(Thread.currentThread().getContextClassLoader()); - System.out.println("Get enhancer"); - JDOEnhancer enhancer = JDOHelper.getEnhancer(enhancerLoader); - System.out.println("enhancer.setVerbose()"); - enhancer.setVerbose(true); - System.out.println("enhancer.setClassLoader()"); - enhancer.setClassLoader(enhancerLoader); - String[] classArr = classes.toArray(classArray); - enhancer.addClasses(classArr); - System.out.println("Enhancing classes for identity type " + idtype); - // enhancer needs org/apache/jdo/tck/util/DeepEquality - enhancer.enhance(); - Thread.currentThread().setContextClassLoader(prevCl); - - // Move log to per-test location - String idname = "dsid"; - if (idtype.trim().equals("applicationidentity")) { - idname = "app"; - } - String testLogFilename = - logsDirectory - + File.separator - + "enhanced" - + File.separator - + idname - + "-" - + impl - + ".txt"; - System.out.println("testLogFilename is " + testLogFilename); - try { - File logFile = new File(implLogFile); - File testLogFile = new File(testLogFilename); - FileUtils.copyFile(logFile, testLogFile); - // reset file content - FileUtils.write(logFile, "", Charset.defaultCharset()); - FileUtils.forceDeleteOnExit(logFile); - } catch (Exception e) { - System.out.println(">> Error moving implementation log file: " + e.getMessage()); - } + System.out.println(""); } - System.out.println(""); - } } diff --git a/exectck/src/main/java/org/apache/jdo/exectck/Help.java b/exectck/src/main/java/org/apache/jdo/exectck/Help.java index aabe19331..10828a8e0 100644 --- a/exectck/src/main/java/org/apache/jdo/exectck/Help.java +++ b/exectck/src/main/java/org/apache/jdo/exectck/Help.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -22,72 +22,69 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Mojo; -/** Goal that displays help text for the exectck Maven plugin. */ -@Mojo(name = "help") -public class Help extends AbstractMojo { +/** + * Goal that displays help text for the exectck Maven plugin. + */ +@Mojo( name = "help" ) +public class Help extends AbstractMojo{ - @Override - public void execute() throws MojoExecutionException, MojoFailureException { + @Override + public void execute() throws MojoExecutionException, MojoFailureException { + + StringBuffer msg = new StringBuffer(); - StringBuffer msg = new StringBuffer(); + msg.append("\n\n*** jdo-exectck Maven plugin ***\n\n"); + msg.append("This plugin executes the JDO Technology Compatibility Kit (TCK)\n"); + msg.append("against the Reference Implementation (RI) or an implementation under test (IUT).\n\n"); + msg.append("- To display this help text, type \"mvn jdo-exectck:help\"\n"); + msg.append("- To run the entire TCK type \"mvn integration-test\" or \"mvn install\"\n"); + msg.append("- To run individual goals type \"mvn jdo-exectck:\"\n"); + msg.append(" Specify command line parameters, described below, to configure the test.\n"); + msg.append("\nGOALS\n"); + msg.append("* installSchema\n"); + msg.append(" Installs all of the database schemas required to execute tests\n"); + msg.append(" in the current test configurations.\n"); + msg.append("* enhance\n"); + msg.append(" Enhances classes. Classes must first be compiled (mvn compile).\n"); + msg.append("* runtck\n"); + msg.append(" Runs the JDO Technology Compatibility Kit. Schema must first be installed and classes enhanced.\n"); + msg.append("\nPARAMETERS\n"); + msg.append("To set parameters from the command line, \n use the -D option and the parameter name.\n"); + msg.append(" For example, \"mvn -Djdo.tck.identitytype=applicationidentity\"\n"); + msg.append("* jdo.tck.impl\n"); + msg.append(" jdori (reference implementation) or iut (mplementation under test\n"); + msg.append("* jdo.tck.cfglist\n"); + msg.append(" List of configuration files, each describing a test configuration.\n"); + msg.append(" Default is all configurations.\n"); + msg.append("* jdo.tck.dblist\n"); + msg.append(" List of databases to run tests under.\n"); + msg.append(" Currently only derby is supported\n"); + msg.append("* jdo.tck.identitytypes\n"); + msg.append(" List of identity types to be tested\n"); + msg.append(" Default value is \"applicationidentity datastoreidentity\"\n"); + msg.append("* jdo.tck.impl.logfile\n"); + msg.append(" Location of implementation log file. Default: ${user.dir}/datanucleus.txt\n"); + msg.append("* jdo.tck.doInstallSchema\n"); + msg.append(" Setting this parameter to false will bypass schema installation.\n"); + msg.append("* jdo.tck.doEnhance\n"); + msg.append(" Setting this parameter to false will bypass enhancement.\n"); + msg.append("* jdo.tck.doRunTCK\n"); + msg.append(" Setting this parameter to false will bypass running the TCK.\n"); + msg.append("* jdo.tck.runTCKVerbose\n"); + msg.append(" Setting this parameter to true will display test progress and" + + "error output while the TCK is running.\n"); + msg.append("* jdo.tck.onFailure\n"); + msg.append(" Specifies how test failures are treated. \"failFast\" will immediately abort the test run. " + + "\"failGoal\" (default) will execute the whole TCK (maven goal) before failing. " + + "\"logOnly\" will report failures to console and logs only but return 'SUCCESS' to the " + + "Maven execution environment.\n"); + msg.append("\n To run the TCK on an implementation under test, \n" + + " edit the pom.xml in tck and add the iut dependencies to the iut profile\n" + + " and set jdo.tck.impl to iut:\n"); + msg.append(" mvn integration-test -D jdo.tck.impl=\"iut\"\n\n"); + msg.append("\n END EXECTCK HELP INFORMATION\n"); - msg.append("\n\n*** jdo-exectck Maven plugin ***\n\n"); - msg.append("This plugin executes the JDO Technology Compatibility Kit (TCK)\n"); - msg.append( - "against the Reference Implementation (RI) or an implementation under test (IUT).\n\n"); - msg.append("- To display this help text, type \"mvn jdo-exectck:help\"\n"); - msg.append("- To run the entire TCK type \"mvn integration-test\" or \"mvn install\"\n"); - msg.append("- To run individual goals type \"mvn jdo-exectck:\"\n"); - msg.append(" Specify command line parameters, described below, to configure the test.\n"); - msg.append("\nGOALS\n"); - msg.append("* installSchema\n"); - msg.append(" Installs all of the database schemas required to execute tests\n"); - msg.append(" in the current test configurations.\n"); - msg.append("* enhance\n"); - msg.append(" Enhances classes. Classes must first be compiled (mvn compile).\n"); - msg.append("* runtck\n"); - msg.append( - " Runs the JDO Technology Compatibility Kit. Schema must first be installed and classes enhanced.\n"); - msg.append("\nPARAMETERS\n"); - msg.append( - "To set parameters from the command line, \n use the -D option and the parameter name.\n"); - msg.append(" For example, \"mvn -Djdo.tck.identitytype=applicationidentity\"\n"); - msg.append("* jdo.tck.impl\n"); - msg.append(" jdori (reference implementation) or iut (mplementation under test\n"); - msg.append("* jdo.tck.cfglist\n"); - msg.append(" List of configuration files, each describing a test configuration.\n"); - msg.append(" Default is all configurations.\n"); - msg.append("* jdo.tck.dblist\n"); - msg.append(" List of databases to run tests under.\n"); - msg.append(" Currently only derby is supported\n"); - msg.append("* jdo.tck.identitytypes\n"); - msg.append(" List of identity types to be tested\n"); - msg.append(" Default value is \"applicationidentity datastoreidentity\"\n"); - msg.append("* jdo.tck.impl.logfile\n"); - msg.append(" Location of implementation log file. Default: ${user.dir}/datanucleus.txt\n"); - msg.append("* jdo.tck.doInstallSchema\n"); - msg.append(" Setting this parameter to false will bypass schema installation.\n"); - msg.append("* jdo.tck.doEnhance\n"); - msg.append(" Setting this parameter to false will bypass enhancement.\n"); - msg.append("* jdo.tck.doRunTCK\n"); - msg.append(" Setting this parameter to false will bypass running the TCK.\n"); - msg.append("* jdo.tck.runTCKVerbose\n"); - msg.append( - " Setting this parameter to true will display test progress and" - + "error output while the TCK is running.\n"); - msg.append("* jdo.tck.onFailure\n"); - msg.append( - " Specifies how test failures are treated. \"failFast\" will immediately abort the test run. " - + "\"failGoal\" (default) will execute the whole TCK (maven goal) before failing. " - + "\"logOnly\" will report failures to console and logs only but return 'SUCCESS' to the " - + "Maven execution environment.\n"); - msg.append( - "\n To run the TCK on an implementation under test, \n" - + " edit the pom.xml in tck and add the iut dependencies to the iut profile\n" - + " and set jdo.tck.impl to iut:\n"); - msg.append(" mvn integration-test -D jdo.tck.impl=\"iut\"\n\n"); - msg.append("\n END EXECTCK HELP INFORMATION\n"); + System.out.println(msg.toString()); + } - System.out.println(msg.toString()); - } } diff --git a/exectck/src/main/java/org/apache/jdo/exectck/InstallSchema.java b/exectck/src/main/java/org/apache/jdo/exectck/InstallSchema.java index 3fa9ab5b7..eeb01d0ac 100644 --- a/exectck/src/main/java/org/apache/jdo/exectck/InstallSchema.java +++ b/exectck/src/main/java/org/apache/jdo/exectck/InstallSchema.java @@ -15,6 +15,11 @@ */ package org.apache.jdo.exectck; +import org.apache.commons.io.FileUtils; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; + import java.io.File; import java.io.IOException; import java.io.PrintWriter; @@ -25,263 +30,242 @@ import java.util.Collection; import java.util.HashSet; import java.util.List; -import org.apache.commons.io.FileUtils; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -/** Goal that installs a database schema for testing a JDO implementation. */ -@Mojo(name = "installSchema") +/** + * Goal that installs a database schema for testing a JDO implementation. + */ +@Mojo( name = "installSchema" ) public class InstallSchema extends AbstractTCKMojo { - /** Location of TCK generated output. */ - @Parameter(property = "jdo.tck.doInstallSchema", defaultValue = "true", required = true) - private boolean doInstallSchema; - - /** List of mappings required by the current configuration */ - protected Collection mappings = new HashSet(); + /** + * Location of TCK generated output. + */ + @Parameter( property = "jdo.tck.doInstallSchema", defaultValue = "true", required = true) + private boolean doInstallSchema; - @Override - public void execute() throws MojoExecutionException { + /** + * List of mappings required by the current configuration + */ + protected Collection mappings = new HashSet(); - if (!doInstallSchema) { - System.out.println("Skipping InstallSchema goal!"); - return; - } + @Override + public void execute() throws MojoExecutionException { - if (cfgs == null) { - if (cfgList != null) { - System.out.println("cfgList is " + cfgList); - cfgs = new HashSet(); - PropertyUtils.string2Set(cfgList, cfgs); - } else { - // Fallback to "src/conf/main/resources/configurations.list" - setCfgListFromFile(); - if (cfgList != null) { - cfgs = new HashSet(); - PropertyUtils.string2Set(cfgList, cfgs); + if (!doInstallSchema) { + System.out.println("Skipping InstallSchema goal!"); + return; } - if (cfgList == null) { - throw new MojoExecutionException( - "Could not find configurations to run TCK. " - + "Set cfgList parameter on command line or cfgs in pom.xml."); + if (cfgs == null) { + if (cfgList != null) { + System.out.println("cfgList is " + cfgList); + cfgs = new HashSet(); + PropertyUtils.string2Set(cfgList, cfgs); + } + else { + // Fallback to "src/conf/main/resources/configurations.list" + setCfgListFromFile(); + if (cfgList != null) { + cfgs = new HashSet(); + PropertyUtils.string2Set(cfgList, cfgs); + } + + if (cfgList == null) { + throw new MojoExecutionException( + "Could not find configurations to run TCK. " + + "Set cfgList parameter on command line or cfgs in pom.xml."); + } + } } - } - } - PropertyUtils.string2Set(dblist, dbs); - PropertyUtils.string2Set(identitytypes, idtypes); - PropertyUtils.mappingsSet(cfgs, confDirectory, mappings); - System.out.println( - "*>Schemas to be installed for \n configurations: " - + cfgs.toString() - + "\n databases: " - + dbs.toString() - + "\n identity types: " - + identitytypes.toString()); + PropertyUtils.string2Set(dblist, dbs); + PropertyUtils.string2Set(identitytypes, idtypes); + PropertyUtils.mappingsSet(cfgs, confDirectory, mappings); + System.out.println("*>Schemas to be installed for \n configurations: " + + cfgs.toString() + "\n databases: " + dbs.toString() + + "\n identity types: " + identitytypes.toString()); - System.setProperty("java.security.manager", "default"); - System.setProperty("java.security.policy", confDirectory + File.separator + "security.policy"); + System.setProperty("java.security.manager", "default"); + System.setProperty("java.security.policy", confDirectory + + File.separator + "security.policy"); - for (String db : dbs) { - // Create directory for db logs - String dbLogsDirName = logsDirectory + File.separator + "database"; - File dbLogsDir = new File(dbLogsDirName); - if (!(dbLogsDir.exists()) && !(dbLogsDir.mkdirs())) { - throw new MojoExecutionException("Failed to create directory " + dbLogsDir); - } + for (String db : dbs) { + // Create directory for db logs + String dbLogsDirName = logsDirectory + File.separator + "database"; + File dbLogsDir = new File(dbLogsDirName); + if (!(dbLogsDir.exists()) && !(dbLogsDir.mkdirs())) { + throw new MojoExecutionException("Failed to create directory " + dbLogsDir); + } - // Create database directory - String dbDirName = buildDirectory + File.separator + "database" + File.separator + db; - File dbDir = new File(dbDirName); - if (!(dbDir.exists()) && !(dbDir.mkdirs())) { - throw new MojoExecutionException("Failed to create directory " + dbDir); - } + // Create database directory + String dbDirName = buildDirectory + File.separator + "database" + + File.separator + db; + File dbDir = new File(dbDirName); + if (!(dbDir.exists()) && !(dbDir.mkdirs())) { + throw new MojoExecutionException("Failed to create directory " + dbDir); + } - // Copy db.properties to db dir - File dbConf = new File(confDirectory + File.separator + db + ".properties"); - try { - FileUtils.copyFileToDirectory(dbConf, dbDir, false); - } catch (IOException ex) { - throw new MojoExecutionException( - "Failed to copy file " + dbConf + " to " + dbDir + ": " + ex.getLocalizedMessage()); - } + // Copy db.properties to db dir + File dbConf = new File(confDirectory + File.separator + db + + ".properties"); + try { + FileUtils.copyFileToDirectory(dbConf, dbDir, false); + } catch (IOException ex) { + throw new MojoExecutionException("Failed to copy file " + dbConf + + " to " + dbDir + ": " + ex.getLocalizedMessage()); + } - if (mappings.contains("0")) { - // If schema was explicitly specified as "0" change to "" since - // the schema file in that case is "schema.sql". Note that this - // removes a duplicate entry too - mappings.remove("0"); - mappings.add(""); - } + if (mappings.contains("0")) { + // If schema was explicitly specified as "0" change to "" since + // the schema file in that case is "schema.sql". Note that this + // removes a duplicate entry too + mappings.remove("0"); + mappings.add(""); + } - initializeDB(db, dbDirName); + initializeDB(db, dbDirName); - // Create database - for (String idtype : idtypes) { - for (String mapping : mappings) { - System.out.print( - "*> Installing schema" + mapping + ".sql for " + db + " " + idtype + " ... "); + // Create database + for (String idtype : idtypes) { + for (String mapping : mappings) { + System.out.print("*> Installing schema" + mapping + + ".sql for " + db + " " + idtype + " ... "); - String outFileName = - logsDirectory - + File.separator - + "database" - + File.separator - + db - + "_" - + idtype - + "_" - + mapping - + ".txt"; - String sqlFileName = - sqlDirectory - + File.separator - + db - + File.separator - + idtype - + File.separator - + "schema" - + mapping - + ".sql"; + String outFileName = logsDirectory + File.separator + "database" + + File.separator + db + "_" + idtype + "_" + mapping + ".txt"; + String sqlFileName = sqlDirectory + File.separator + db + + File.separator + idtype + File.separator + + "schema" + mapping + ".sql"; - boolean success = true; - try { - loadSQLFileUsingJDBC(db, dbDirName, sqlFileName, outFileName); - } catch (Exception ex) { - success = false; - System.out.println("FAILED!"); - ex.printStackTrace(); - System.out.println("*> Classpath is "); - new Utilities().printClasspath(); - System.out.println( - "*> jdo.tck.basedir is \n " + System.getProperty("jdo.tck.basedir")); - System.out.println( - "*> java.security.manager is \n " + System.getProperty("java.security.manager")); - System.out.println( - "*> java.security.policy is \n " + System.getProperty("java.security.policy")); - System.out.println("*> dbDirName is \n " + dbDirName); - System.out.println("*> outFileName is \n " + outFileName); - } finally { - if (success) { - System.out.println("done"); + boolean success = true; + try { + loadSQLFileUsingJDBC(db, dbDirName, sqlFileName, outFileName); + } catch (Exception ex) { + success = false; + System.out.println("FAILED!"); + ex.printStackTrace(); + System.out.println("*> Classpath is "); + new Utilities().printClasspath(); + System.out.println("*> jdo.tck.basedir is \n " + + System.getProperty("jdo.tck.basedir")); + System.out.println("*> java.security.manager is \n " + + System.getProperty("java.security.manager")); + System.out.println("*> java.security.policy is \n " + + System.getProperty("java.security.policy")); + System.out.println("*> dbDirName is \n " + dbDirName); + System.out.println("*> outFileName is \n " + outFileName); + } finally { + if (success) { + System.out.println("done"); + } + } + } } - } - } - } - finalizeDB(db, dbDirName); + finalizeDB(db, dbDirName); - System.out.println("*> See diagnostic output in " + dbLogsDir + "."); - System.out.println(""); + System.out.println("*> See diagnostic output in " + dbLogsDir + "."); + System.out.println(""); + } } - } - /** - * @param db database name - * @param dbDirName database home directory - */ - protected void initializeDB(String db, String dbDirName) { - if ("derby".equalsIgnoreCase(db)) { - System.setProperty("derby.system.home", dbDirName); + /** + * + * @param db database name + * @param dbDirName database home directory + */ + protected void initializeDB(String db, String dbDirName) { + if ("derby".equalsIgnoreCase(db)) { + System.setProperty("derby.system.home", dbDirName); + } } - } - /** - * @param db database name - * @param dbDirName database home directory - */ - protected void finalizeDB(String db, String dbDirName) { - if ("derby".equalsIgnoreCase(db)) { - try { - DriverManager.getConnection("jdbc:derby:;shutdown=true"); - } catch (SQLException ex) { - // ignore - } + /** + * + * @param db database name + * @param dbDirName database home directory + */ + protected void finalizeDB(String db, String dbDirName) { + if ("derby".equalsIgnoreCase(db)) { + try { + DriverManager.getConnection("jdbc:derby:;shutdown=true"); + } catch (SQLException ex) { + // ignore + } + } } - } - /** - * @param db database name - * @param dbDirName database home directory - * @param sqlFileName name of the sql file - * @param outFileName name of the output file - * @throws MojoExecutionException exception indicating error case - */ - protected void loadSQLFileUsingIJ( - String db, String dbDirName, String sqlFileName, String outFileName) - throws MojoExecutionException { - String[] args = {sqlFileName}; - try { - System.setProperty("ij.outfile", outFileName); - org.apache.derby.tools.ij.main(args); - } catch (IOException ioex) { - System.out.println("FAILED!"); - throw new MojoExecutionException("*> Failed to execute ij: " + ioex.getLocalizedMessage()); + /** + * + * @param db database name + * @param dbDirName database home directory + * @param sqlFileName name of the sql file + * @param outFileName name of the output file + * @throws MojoExecutionException exception indicating error case + */ + protected void loadSQLFileUsingIJ(String db, String dbDirName, String sqlFileName, String outFileName) + throws MojoExecutionException { + String[] args = {sqlFileName}; + try { + System.setProperty("ij.outfile", outFileName); + org.apache.derby.tools.ij.main(args); + } catch (IOException ioex) { + System.out.println("FAILED!"); + throw new MojoExecutionException( + "*> Failed to execute ij: " + ioex.getLocalizedMessage()); + } } - } - /** - * @param db database name - * @param dbDirName database home directory - * @param sqlFileName name of the sql file - * @param outFileName name of the output file - * @throws MojoExecutionException exception indicating error case - */ - protected void loadSQLFileUsingJDBC( - String db, String dbDirName, String sqlFileName, String outFileName) - throws MojoExecutionException { - try { - SQLFileLoader loader = new SQLFileLoader(sqlFileName); - String url = loader.getConnect(); - if (url == null || "".equals(url.trim())) { - throw new MojoExecutionException( - "*> connection url needs to be specified, see file " + sqlFileName); - } - String user = loader.getUser(); - if (user == null || "".equals(user.trim())) { - throw new MojoExecutionException( - "*> connection user needs to be specified, see file " + sqlFileName); - } - String passwd = loader.getPassword(); - if (passwd == null || "".equals(passwd.trim())) { - throw new MojoExecutionException( - "*> connection passwd needs to be specified, see file " + sqlFileName); - } - List stmts = loader.getStatements(); + /** + * + * @param db database name + * @param dbDirName database home directory + * @param sqlFileName name of the sql file + * @param outFileName name of the output file + * @throws MojoExecutionException exception indicating error case + */ + protected void loadSQLFileUsingJDBC(String db, String dbDirName, + String sqlFileName, String outFileName) + throws MojoExecutionException { + try { + SQLFileLoader loader = new SQLFileLoader(sqlFileName); + String url = loader.getConnect(); + if (url == null || "".equals(url.trim())) { + throw new MojoExecutionException("*> connection url needs to be specified, see file " + sqlFileName); + } + String user = loader.getUser(); + if (user == null || "".equals(user.trim())) { + throw new MojoExecutionException("*> connection user needs to be specified, see file " + sqlFileName); + } + String passwd = loader.getPassword(); + if (passwd == null || "".equals(passwd.trim())) { + throw new MojoExecutionException("*> connection passwd needs to be specified, see file " + sqlFileName); + } + List stmts = loader.getStatements(); - try (Connection conn = DriverManager.getConnection(url, user, passwd); - Statement stmt = conn.createStatement(); - PrintWriter outfile = new PrintWriter(outFileName)) { - outfile.println("url=" + url + " user=" + user + " password=" + passwd); - for (String s : stmts) { - try { - outfile.print("loading: " + s); - stmt.execute(s); - outfile.println(" success"); - } catch (SQLException ex) { - outfile.println(" failure " + ex); - } + try (Connection conn = DriverManager.getConnection(url, user, passwd); + Statement stmt = conn.createStatement(); + PrintWriter outfile = new PrintWriter(outFileName)) { + outfile.println("url=" + url + " user=" + user + " password=" + passwd); + for (String s : stmts) { + try { + outfile.print("loading: " + s); + stmt.execute(s); + outfile.println(" success"); + } catch (SQLException ex) { + outfile.println(" failure " + ex); + } + } + } catch (SQLException ex) { + throw new MojoExecutionException("*> Failed to initialize JDBC connection, " + + "url=" + url + " user=" + user + " password=" + passwd + ": " + ex.getLocalizedMessage()); + } catch (IOException ex) { + throw new MojoExecutionException("*> Failed to write to the outfile " + outFileName + ": " + + ex.getLocalizedMessage()); + } + } catch (IOException ex) { + throw new MojoExecutionException("*> Failed to load file " + sqlFileName + " " + ex.getLocalizedMessage()); } - } catch (SQLException ex) { - throw new MojoExecutionException( - "*> Failed to initialize JDBC connection, " - + "url=" - + url - + " user=" - + user - + " password=" - + passwd - + ": " - + ex.getLocalizedMessage()); - } catch (IOException ex) { - throw new MojoExecutionException( - "*> Failed to write to the outfile " + outFileName + ": " + ex.getLocalizedMessage()); - } - } catch (IOException ex) { - throw new MojoExecutionException( - "*> Failed to load file " + sqlFileName + " " + ex.getLocalizedMessage()); } - } + } diff --git a/exectck/src/main/java/org/apache/jdo/exectck/PropertyUtils.java b/exectck/src/main/java/org/apache/jdo/exectck/PropertyUtils.java index 676828dc3..9ca7d9585 100644 --- a/exectck/src/main/java/org/apache/jdo/exectck/PropertyUtils.java +++ b/exectck/src/main/java/org/apache/jdo/exectck/PropertyUtils.java @@ -24,111 +24,113 @@ import java.util.logging.Level; import java.util.logging.Logger; -/** Helper class that sets properties required for running the JDO TCK. */ +/** + * Helper class that sets properties required for running the JDO TCK. + * + */ public class PropertyUtils { - /** - * Separates white space separated items from a String into Collection entries Used to collect - * command line argument lists into a Collection - * - * @param names String of white space separated items - * @param list HashSet to contain String items - */ - public static void string2Set(String names, Collection list) { - String[] items = names.split("[ \t\n]"); - for (String s : items) { - list.add(s); + /** + * Separates white space separated items from a String into Collection entries + * Used to collect command line argument lists into a Collection + * + * @param names String of white space separated items + * @param list HashSet to contain String items + */ + public static void string2Set(String names, Collection list) { + String[] items = names.split("[ \t\n]"); + for (String s : items) { + list.add(s); + } } - } - /** - * Separates white space separated items from a String into HashSet entries Used to collect - * command line argument lists into a Collection - * - * @param names String of white space separated items - * @param list HashSet to contain String items - */ - public static void string2List(String names, List list) { - // System.out.println("names are " + names); - String[] items = names.split("[ \t\n]"); - for (String s : items) { - list.add(s); + /** + * Separates white space separated items from a String into HashSet entries + * Used to collect command line argument lists into a Collection + * + * @param names String of white space separated items + * @param list HashSet to contain String items + */ + public static void string2List(String names, List list) { +// System.out.println("names are " + names); + String[] items = names.split("[ \t\n]"); + for (String s : items) { + list.add(s); + } +// System.out.println("List names are " + list.toString()); } - // System.out.println("List names are " + list.toString()); - } - /** - * Parses a set of config files for the mapping entry and provides the mapping values in a - * Collection. - * - * @param cfglist config file names - * @param confDir directory where config files are found - * @param mappings object to containg mapping values - */ - public static void mappingsSet( - Collection cfglist, String confDir, Collection mappings) { + /** + * Parses a set of config files for the mapping entry and + * provides the mapping values in a Collection. + * @param cfglist config file names + * @param confDir directory where config files are found + * @param mappings object to containg mapping values + */ + public static void mappingsSet(Collection cfglist, String confDir, + Collection mappings) { - for (String cfg : cfglist) { - String mapping = ""; - String confName = confDir + File.separator + cfg; + for (String cfg : cfglist) { + String mapping = ""; + String confName = confDir + File.separator + cfg; - Properties props = new Properties(); - FileInputStream fis = null; - // System.out.println("confName is " + confName); - try { - fis = new FileInputStream(confName); - props.load(fis); - mapping = props.getProperty("jdo.tck.mapping"); - // System.out.println("Next mapping is " + mapping); - } catch (IOException e) { - e.printStackTrace(); - try { - if (fis != null) { - fis.close(); - } - } catch (IOException ex) { - Logger.getLogger(PropertyUtils.class.getName()).log(Level.SEVERE, null, ex); + Properties props = new Properties(); + FileInputStream fis = null; +// System.out.println("confName is " + confName); + try { + fis = new FileInputStream(confName); + props.load(fis); + mapping = props.getProperty("jdo.tck.mapping"); +// System.out.println("Next mapping is " + mapping); + } catch (IOException e) { + e.printStackTrace(); + try { + if (fis != null) { + fis.close(); + } + } catch (IOException ex) { + Logger.getLogger(PropertyUtils.class.getName()).log(Level.SEVERE, null, ex); + } + return; + } + + mappings.add(mapping); } - return; - } + } - mappings.add(mapping); + /* + * Open a properties file and return a Properties object + */ + public static Properties getProperties(String fname){ + Properties props = new Properties(); + FileInputStream fis = null; + try { + fis = new FileInputStream(new File(fname)); + props.load(fis); + } catch (IOException e) { + e.printStackTrace(); + try { + if (fis != null) { + fis.close(); + } + } catch (IOException ex) { + Logger.getLogger(PropertyUtils.class.getName()).log(Level.SEVERE, null, ex); + } + } + return props; } - } - /* - * Open a properties file and return a Properties object - */ - public static Properties getProperties(String fname) { - Properties props = new Properties(); - FileInputStream fis = null; - try { - fis = new FileInputStream(new File(fname)); - props.load(fis); - } catch (IOException e) { - e.printStackTrace(); - try { - if (fis != null) { - fis.close(); + /* + * Set the value of key if found in properties. + */ + public static void setSysProperty(Properties properties, String key, String newkey) { + String value = properties.getProperty("key"); + if (value != null) { + System.setProperty(newkey, value); } - } catch (IOException ex) { - Logger.getLogger(PropertyUtils.class.getName()).log(Level.SEVERE, null, ex); - } } - return props; - } - /* - * Set the value of key if found in properties. - */ - public static void setSysProperty(Properties properties, String key, String newkey) { - String value = properties.getProperty("key"); - if (value != null) { - System.setProperty(newkey, value); + public static void setSysProperty(Properties properties, String key) { + setSysProperty(properties, key, key); } - } - - public static void setSysProperty(Properties properties, String key) { - setSysProperty(properties, key, key); - } } diff --git a/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java b/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java index cfda5f7fd..1ec1c6439 100644 --- a/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java +++ b/exectck/src/main/java/org/apache/jdo/exectck/RunTCK.java @@ -15,10 +15,7 @@ */ package org.apache.jdo.exectck; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; +import java.io.*; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; @@ -37,541 +34,508 @@ import org.apache.maven.plugins.annotations.Parameter; /** - * Goal that runs the JDO TCK against the Reference Implementation (RI) or an implementation under - * test (IUT). + * Goal that runs the JDO TCK against the Reference Implementation (RI) + * or an implementation under test (IUT). */ -@Mojo(name = "runtck") +@Mojo( name = "runtck" ) public class RunTCK extends AbstractTCKMojo { - private static final String TCK_PARAM_ON_FAILURE_FAIL_FAST = "failFast"; - private static final String TCK_PARAM_ON_FAILURE_FAIL_EVENTUALLY = "failGoal"; - private static final String TCK_PARAM_ON_FAILURE_LOG_ONLY = "logOnly"; - - private static final String TCK_LOG_FILE = "tck.txt"; - - /** To skip running of TCK, set to false. */ - @Parameter(property = "jdo.tck.doRunTCK", defaultValue = "true", required = true) - private boolean doRunTCK; - - /** To run the RunTCK plugin goal in verbose mode. */ - @Parameter(property = "jdo.tck.runTCKVerbose", defaultValue = "false", required = true) - private boolean runtckVerbose; - - /** Define handling of TCK failures. */ - @Parameter(property = "jdo.tck.onFailure", defaultValue = "failGoal", required = true) - private String onFailure; - - /** Run the TCK in a debugger. */ - @Parameter(property = "jdo.tck.debugTCK", defaultValue = "false", required = true) - private boolean debugTCK; - - /** Location of third party libraries such as JNDI. */ - @Parameter( - property = "project.lib.ext.directory", - defaultValue = "${basedir}/../lib/ext", - required = true) - private String extLibsDirectory; - - /** To skip jndi PMF Tests set to true. */ - @Parameter(property = "jdo.tck.skipJndi", defaultValue = "false", required = true) - private boolean skipJndi; - - /** Location of implementation log file. */ - @Parameter( - property = "jdo.tck.impl.logfile", - defaultValue = "${user.dir}/datanucleus.txt", - required = true) - private String implLogFile; - - /** Name of file in src/conf containing pmf properties. */ - @Parameter(property = "jdo.tck.pmfproperties", defaultValue = "jdori-pmf.properties") - private String pmfProperties; - - /** - * Name of file in src/conf containing property jdo.tck.exclude, whose value is a list of files to - * be excluded from testing. - */ - @Parameter(property = "jdo.tck.excludefile", defaultValue = "exclude.list", required = true) - private String exclude; - - /** Run the TCK tests in verbose mode. */ - @Parameter(property = "jdo.tck.verbose", defaultValue = "false") - private String verbose; - - /** To retain test output for debugging, set to false. */ - @Parameter(property = "jdo.tck.cleanupaftertest", defaultValue = "true") - private String cleanupaftertest; - - /** Properties to use in accessing database. */ - @Parameter( - property = "database.runtck.sysproperties", - defaultValue = "-Dderby.system.home=${basedir}/target/database/derby") - private String dbproperties; // NOTE: only allows for one db - - /** Properties to use in accessing database. */ - @Parameter( - property = "jdo.tck.signaturefile", - defaultValue = "${basedir}/src/main/resources/conf/jdo-signatures.txt") - private String signaturefile; - - /** JVM properties. */ - @Parameter(property = "jdo.tck.jvmproperties", defaultValue = "-Xmx512m") - private String jvmproperties; - - /** User-supplied arguments for debug directives. */ - @Parameter( - property = "jdo.tck.debug.jvmargs", - defaultValue = - "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${jdo.tck.debug.port}") - private String debugDirectives; - - /** Class used to run a batch of tests. */ - @Parameter( - property = "jdo.tck.testrunnerclass", - defaultValue = "org.apache.jdo.tck.util.BatchTestRunner", - required = true) - private String testRunnerClass; - - /** Class used to output test result and configuration information. */ - @Parameter( - property = "jdo.tck.resultprinterclass", - defaultValue = "org.apache.jdo.tck.util.BatchResultPrinter", - required = true) - private String resultPrinterClass; - - /** - * Helper method returning the trimmed value of the specified property. - * - * @param props the Properties object - * @param key the key of the property to be returned - * @return the trimmed property value or the empty string if the property is not defined. + - */ - private String getTrimmedPropertyValue(Properties props, String key) { - String value = props.getProperty(key); - return value == null ? "" : value.trim(); - } - - @Override - public void execute() throws MojoExecutionException, MojoFailureException { - if (!doRunTCK) { - System.out.println("Skipping RunTCK goal!"); - return; + private static final String TCK_PARAM_ON_FAILURE_FAIL_FAST = "failFast"; + private static final String TCK_PARAM_ON_FAILURE_FAIL_EVENTUALLY = "failGoal"; + private static final String TCK_PARAM_ON_FAILURE_LOG_ONLY = "logOnly"; + + private static final String TCK_LOG_FILE = "tck.txt"; + + /** + * To skip running of TCK, set to false. + */ + @Parameter( property = "jdo.tck.doRunTCK", defaultValue = "true", required = true) + private boolean doRunTCK; + + /** + * To run the RunTCK plugin goal in verbose mode. + */ + @Parameter( property = "jdo.tck.runTCKVerbose", defaultValue = "false", required = true) + private boolean runtckVerbose; + + /** + * Define handling of TCK failures. + */ + @Parameter( property = "jdo.tck.onFailure", defaultValue = "failGoal", required = true) + private String onFailure; + + /** + * Run the TCK in a debugger. + */ + @Parameter( property = "jdo.tck.debugTCK", defaultValue = "false", required = true) + private boolean debugTCK; + + /** + * Location of third party libraries such as JNDI. + */ + @Parameter( property = "project.lib.ext.directory", defaultValue = "${basedir}/../lib/ext", required = true) + private String extLibsDirectory; + + /** + * To skip jndi PMF Tests set to true. + */ + @Parameter( property = "jdo.tck.skipJndi", defaultValue = "false", required = true) + private boolean skipJndi; + + /** + * Location of implementation log file. + */ + @Parameter( property = "jdo.tck.impl.logfile", defaultValue = "${user.dir}/datanucleus.txt", required = true) + private String implLogFile; + + /** + * Name of file in src/conf containing pmf properties. + */ + @Parameter( property = "jdo.tck.pmfproperties", defaultValue = "jdori-pmf.properties") + private String pmfProperties; + + /** + * Name of file in src/conf containing property jdo.tck.exclude, + * whose value is a list of files to be excluded from testing. + */ + @Parameter( property = "jdo.tck.excludefile", defaultValue = "exclude.list", required = true) + private String exclude; + + /** + * Run the TCK tests in verbose mode. + */ + @Parameter( property = "jdo.tck.verbose", defaultValue = "false") + private String verbose; + + /** + * To retain test output for debugging, set to false. + */ + @Parameter( property = "jdo.tck.cleanupaftertest", defaultValue = "true") + private String cleanupaftertest; + + /** + * Properties to use in accessing database. + */ + @Parameter( property = "database.runtck.sysproperties", + defaultValue = "-Dderby.system.home=${basedir}/target/database/derby") + private String dbproperties; // NOTE: only allows for one db + + /** + * Properties to use in accessing database. + */ + @Parameter( property = "jdo.tck.signaturefile", + defaultValue = "${basedir}/src/main/resources/conf/jdo-signatures.txt") + private String signaturefile; + + /** + * JVM properties. + */ + @Parameter( property = "jdo.tck.jvmproperties", defaultValue = "-Xmx512m") + private String jvmproperties; + + /** + * User-supplied arguments for debug directives. + */ + @Parameter( property = "jdo.tck.debug.jvmargs", + defaultValue = "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${jdo.tck.debug.port}") + private String debugDirectives; + + /** + * Class used to run a batch of tests. + */ + @Parameter( property = "jdo.tck.testrunnerclass", defaultValue = "org.apache.jdo.tck.util.BatchTestRunner", + required = true) + private String testRunnerClass; + + /** + * Class used to output test result and configuration information. + */ + @Parameter( property = "jdo.tck.resultprinterclass", defaultValue = "org.apache.jdo.tck.util.BatchResultPrinter", + required = true) + private String resultPrinterClass; + + /** + * Helper method returning the trimmed value of the specified property. + * @param props the Properties object + * @param key the key of the property to be returned + * @return the trimmed property value or the empty string if the property is not defined. + */ + private String getTrimmedPropertyValue (Properties props, String key) { + String value = props.getProperty(key); + return value == null ? "" : value.trim(); } - Properties props = null; - boolean alreadyran = false; - String runonce = "false"; - List propsString = new ArrayList(); - List command; - String cpString = null; - InvocationResult result; - File fromFile = null; - File toFile = null; - - if (impl.equals("iut")) { - pmfProperties = "iut-pmf.properties"; - } + @Override + public void execute() throws MojoExecutionException, MojoFailureException { + if (!doRunTCK) { + System.out.println("Skipping RunTCK goal!"); + return; + } - if (cfgs == null) { - if (cfgList != null) { - cfgs = new ArrayList(); - PropertyUtils.string2List(cfgList, (List) cfgs); - } else { - // Fallback to "src/conf/configurations.list" - setCfgListFromFile(); - if (cfgList != null) { - cfgs = new ArrayList(); - PropertyUtils.string2List(cfgList, (List) cfgs); + Properties props = null; + boolean alreadyran = false; + String runonce = "false"; + List propsString = new ArrayList(); + List command; + String cpString = null; + InvocationResult result; + File fromFile = null; + File toFile = null; + + if (impl.equals("iut")) { + pmfProperties="iut-pmf.properties"; } - if (cfgList == null) { - throw new MojoExecutionException( - "Could not find configurations to run TCK. " - + "Set cfgList parameter on command line or cfgs in pom.xml"); + if (cfgs == null) { + if (cfgList != null) { + cfgs = new ArrayList(); + PropertyUtils.string2List(cfgList, (List)cfgs); + } else { + // Fallback to "src/conf/configurations.list" + setCfgListFromFile(); + if (cfgList != null) { + cfgs = new ArrayList(); + PropertyUtils.string2List(cfgList, (List)cfgs); + } + + if (cfgList == null) { + throw new MojoExecutionException( + "Could not find configurations to run TCK. " + + "Set cfgList parameter on command line or cfgs in pom.xml"); + } + } } - } - } - PropertyUtils.string2Set(dblist, dbs); - PropertyUtils.string2Set(identitytypes, idtypes); - System.out.println( - "*>TCK to be run for implementation '" - + impl - + "' on \n" - + " configurations: " - + cfgs.toString() - + "\n" - + " databases: " - + dbs.toString() - + "\n" - + " identitytypes: " - + identitytypes.toString()); - - // Properties required for test execution - System.out.println("cleanupaftertest is " + cleanupaftertest); - propsString.add("-DResultPrinterClass=" + resultPrinterClass); - propsString.add("-Dverbose=" + verbose); - propsString.add("-Djdo.tck.cleanupaftertest=" + cleanupaftertest); - propsString.add("-Djdo.tck.skipJndi=" + skipJndi); - propsString.add( - "-DPMFProperties=" - + buildDirectory - + File.separator - + "classes" - + File.separator - + pmfProperties); - propsString.add( - "-DPMF2Properties=" - + buildDirectory - + File.separator - + "classes" - + File.separator - + pmfProperties); - String excludeFile = confDirectory + File.separator + exclude; - propsString.add( - "-Djdo.tck.exclude=" - + getTrimmedPropertyValue(PropertyUtils.getProperties(excludeFile), "jdo.tck.exclude")); - - // Create configuration log directory - String timestamp = Utilities.now(); - String thisLogDir = logsDirectory + File.separator + timestamp + File.separator; - String cfgDirName = thisLogDir + "configuration"; - File cfgDir = new File(cfgDirName); - if (!(cfgDir.exists()) && !(cfgDir.mkdirs())) { - throw new MojoExecutionException("Failed to create directory " + cfgDirName); - } - propsString.add("-Djdo.tck.log.directory=" + thisLogDir); + PropertyUtils.string2Set(dblist, dbs); + PropertyUtils.string2Set(identitytypes, idtypes); + System.out.println("*>TCK to be run for implementation '" + impl + + "' on \n" + + " configurations: " + cfgs.toString() + "\n" + + " databases: " + dbs.toString() + "\n" + + " identitytypes: " + identitytypes.toString()); + + // Properties required for test execution + System.out.println("cleanupaftertest is " + cleanupaftertest); + propsString.add("-DResultPrinterClass=" + resultPrinterClass); + propsString.add("-Dverbose=" + verbose); + propsString.add("-Djdo.tck.cleanupaftertest=" + cleanupaftertest); + propsString.add("-Djdo.tck.skipJndi=" + skipJndi); + propsString.add("-DPMFProperties=" + buildDirectory + File.separator + + "classes" + File.separator + pmfProperties); + propsString.add("-DPMF2Properties=" + buildDirectory + File.separator + + "classes" + File.separator + pmfProperties); + String excludeFile = confDirectory + File.separator + exclude; + propsString.add("-Djdo.tck.exclude=" + + getTrimmedPropertyValue(PropertyUtils.getProperties(excludeFile), "jdo.tck.exclude")); + + // Create configuration log directory + String timestamp = Utilities.now(); + String thisLogDir = logsDirectory + File.separator + timestamp + + File.separator; + String cfgDirName = thisLogDir + "configuration"; + File cfgDir = new File(cfgDirName); + if (!(cfgDir.exists()) && !(cfgDir.mkdirs())) { + throw new MojoExecutionException("Failed to create directory " + + cfgDirName); + } + propsString.add("-Djdo.tck.log.directory=" + thisLogDir); - try { - copyLog4j2ConfigurationFile(); - } catch (IOException ex) { - Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null, ex); - } + try { + copyLog4j2ConfigurationFile(); + } catch (IOException ex) { + Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null, ex); + } - // Copy JDO config files to classes dir - try { - fromFile = new File(confDirectory + File.separator + impl + "-jdoconfig.xml"); - toFile = - new File( - buildDirectory - + File.separator - + "classes" - + File.separator - + "META-INF" - + File.separator - + "jdoconfig.xml"); - FileUtils.copyFile(fromFile, toFile); - fromFile = new File(confDirectory + File.separator + impl + "-persistence.xml"); - toFile = - new File( - buildDirectory - + File.separator - + "classes" - + File.separator - + "META-INF" - + File.separator - + "persistence.xml"); - FileUtils.copyFile(fromFile, toFile); - } catch (IOException ex) { - Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null, ex); - } + // Copy JDO config files to classes dir + try { + fromFile = new File(confDirectory + File.separator + impl + "-jdoconfig.xml"); + toFile = new File(buildDirectory + File.separator + "classes" + + File.separator + "META-INF" + File.separator + "jdoconfig.xml"); + FileUtils.copyFile(fromFile, toFile); + fromFile = new File(confDirectory + File.separator + impl + "-persistence.xml"); + toFile = new File(buildDirectory + File.separator + "classes" + + File.separator + "META-INF" + File.separator + "persistence.xml"); + FileUtils.copyFile(fromFile, toFile); + } catch (IOException ex) { + Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null, ex); + } - // Get ClassLoader URLs to build classpath below - URL[] cpURLs = ((URLClassLoader) Thread.currentThread().getContextClassLoader()).getURLs(); - ArrayList urlList = new ArrayList(Arrays.asList(cpURLs)); - - // Get contents of pmf properties file to build new file below - String pmfPropsReadFileName = confDirectory + File.separator + pmfProperties; - String defaultPropsContents = ""; - try { - defaultPropsContents = Utilities.readFile(pmfPropsReadFileName); - } catch (IOException ex) { - Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null, ex); - } + // Get ClassLoader URLs to build classpath below + URL[] cpURLs = ((URLClassLoader) Thread.currentThread().getContextClassLoader()).getURLs(); + ArrayList urlList = new ArrayList(Arrays.asList(cpURLs)); - // Reset logfile content (may not be empty if previous run crashed) - resetFileContent(implLogFile); - resetFileContent(TCK_LOG_FILE); - - int failureCount = 0; - for (String db : dbs) { - System.setProperty("jdo.tck.database", db); - alreadyran = false; - - for (String idtype : idtypes) { - List idPropsString = new ArrayList(); - idPropsString.addAll(propsString); - idPropsString.add("-Djdo.tck.identitytype=" + idtype); - String enhancedDirName = - buildDirectory - + File.separator - + "enhanced" - + File.separator - + impl - + File.separator - + idtype - + File.separator; - File enhancedDir = new File(enhancedDirName); - if (!(enhancedDir.exists())) { - throw new MojoExecutionException( - "Could not find enhanced directory " - + enhancedDirName - + ". Execute Enhance goal before RunTCK."); + // Get contents of pmf properties file to build new file below + String pmfPropsReadFileName = confDirectory + File.separator + pmfProperties; + String defaultPropsContents = ""; + try { + defaultPropsContents = Utilities.readFile(pmfPropsReadFileName); + } catch (IOException ex) { + Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null, ex); } - // Set classpath string: add new entries to URLS from loader - ArrayList cpList = new ArrayList(); - cpList.addAll(urlList); + // Reset logfile content (may not be empty if previous run crashed) + resetFileContent(implLogFile); + resetFileContent(TCK_LOG_FILE); + + int failureCount = 0; + for (String db : dbs) { + System.setProperty("jdo.tck.database", db); + alreadyran = false; + + for (String idtype : idtypes) { + List idPropsString = new ArrayList(); + idPropsString.addAll(propsString); + idPropsString.add("-Djdo.tck.identitytype=" + idtype); + String enhancedDirName = buildDirectory + File.separator + "enhanced" + + File.separator + impl + File.separator + idtype + File.separator; + File enhancedDir = new File(enhancedDirName); + if (!(enhancedDir.exists())) { + throw new MojoExecutionException("Could not find enhanced directory " + + enhancedDirName + ". Execute Enhance goal before RunTCK."); + } + + // Set classpath string: add new entries to URLS from loader + ArrayList cpList = new ArrayList(); + cpList.addAll(urlList); + try { + URL url1 = enhancedDir.toURI().toURL(); + URL url2 = new File(buildDirectory + File.separator + + "classes" + File.separator).toURI().toURL(); + if (runtckVerbose) { + System.out.println("url2 is " + url2.toString()); + } + cpList.add(url1); + cpList.add(url2); + String[] jars = {"jar"}; + Iterator fi = FileUtils.iterateFiles( + new File(extLibsDirectory), jars, true); + while (fi.hasNext()) { + cpList.add(fi.next().toURI().toURL()); + } + for (String dependency : this.dependencyClasspath.split(File.pathSeparator)) { + cpList.add(new File(dependency).toURI().toURL()); + } + } catch (MalformedURLException ex) { + ex.printStackTrace(); + Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null, ex); + } + cpString = Utilities.urls2ClasspathString(cpList); + if (runtckVerbose) { + System.out.println("\nClasspath is " + cpString); + } + + for (String cfg : cfgs) { + List cfgPropsString = new ArrayList(); + cfgPropsString.addAll(idPropsString); + // Parse conf file and set properties String + props = PropertyUtils.getProperties(confDirectory + + File.separator + cfg); + cfgPropsString.add("-Djdo.tck.testdata=" + + getTrimmedPropertyValue(props, "jdo.tck.testdata")); + cfgPropsString.add("-Djdo.tck.standarddata=" + + getTrimmedPropertyValue(props, "jdo.tck.standarddata")); + cfgPropsString.add("-Djdo.tck.mapping.companyfactory=" + + getTrimmedPropertyValue(props, "jdo.tck.mapping.companyfactory")); +// innerPropsString.append("-Djdo.tck.description=\"" + +// props.getProperty("jdo.tck.description") + "\""); + cfgPropsString.add("-Djdo.tck.requiredOptions=" + + getTrimmedPropertyValue(props, "jdo.tck.requiredOptions")); + cfgPropsString.add("-Djdo.tck.signaturefile=" + + signaturefile); + String mapping = getTrimmedPropertyValue(props, "jdo.tck.mapping"); + if (mapping == null) { + throw new MojoExecutionException( + "Could not find mapping value in conf file: " + cfg); + } + String classes = getTrimmedPropertyValue(props, "jdo.tck.classes"); + String excludeList = getTrimmedPropertyValue( + PropertyUtils.getProperties(excludeFile), "jdo.tck.exclude"); + if (classes == null) { + throw new MojoExecutionException( + "Could not find classes value in conf file: " + cfg); + } + classes = Utilities.removeSubstrs(classes, excludeList); + if (classes.equals("")) { + System.out.println("Skipping configuration " + cfg + + ": classes excluded"); + continue; + } + List classesList = Arrays.asList(classes.split(" ")); + + cfgPropsString.add("-Djdo.tck.schemaname=" + idtype + mapping); + cfgPropsString.add("-Djdo.tck.cfg=" + cfg); + + runonce = getTrimmedPropertyValue(props, "runOnce"); + runonce = (runonce == null) ? "false" : runonce; + + // Add Mapping and schemaname to properties file + StringBuffer propsFileData = new StringBuffer(); + propsFileData.append("\n### Properties below added by maven 2 goal RunTCK.jdori"); + propsFileData.append("\njavax.jdo.mapping.Schema=" + idtype + mapping); + mapping = (mapping.equals("0")) ? "" : mapping; + propsFileData.append("\njavax.jdo.option.Mapping=standard" + mapping); + propsFileData.append("\n"); + String pmfPropsWriteFileName = buildDirectory + File.separator + + "classes" + File.separator + pmfProperties; + try { + BufferedWriter out = new BufferedWriter(new FileWriter(pmfPropsWriteFileName, false)); + out.write(defaultPropsContents + propsFileData.toString()); + out.close(); + } catch (IOException ex) { + Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null, ex); + } + + // build command line string + command = new ArrayList(); + command.add("java"); + command.add("-cp"); + command.add(cpString); + command.addAll(cfgPropsString); + command.add(dbproperties); + command.add(jvmproperties); + if (debugTCK) { + command.add(debugDirectives); + } + command.add(testRunnerClass); + command.addAll(classesList); + + if (runonce.equals("true") && alreadyran) { + continue; + } + + if (debugTCK) { + System.out.println("Using debug arguments: \n" + + debugDirectives); + } + + // invoke class runner + System.out.print("*> Running tests for " + cfg + + " with " + idtype + + " on '" + db + "'" + + " mapping=" + mapping + " ... "); + try { + result = (new Utilities()).invokeTest(command); + if (result.getExitValue() == 0) { + System.out.println("success"); + } else { + System.out.println("FAIL"); + failureCount++; + } + if (runtckVerbose) { + System.out.println("\nCommand line is: \n" + command.toString()); + System.out.println("Test exit value is " + result.getExitValue()); + System.out.println("Test result output:\n" + result.getOutputString()); + System.out.println("Test result error:\n" + result.getErrorString()); + } + } catch (java.lang.RuntimeException re) { + System.out.println("Exception on command " + command); + } + + // Move log to per-test location + String idname = "dsid"; + if (idtype.trim().equals("applicationidentity")) { + idname = "app"; + } + String configName = cfg; + if (cfg.indexOf('.') > 0) { + configName = configName.substring(0, cfg.indexOf('.')); + } + String testLogFilename = thisLogDir + + idname + "-" + configName + "-" + impl + ".txt"; + try { + File logFile = new File(implLogFile); + FileUtils.copyFile(logFile, new File(testLogFilename)); + resetFileContent(implLogFile); + } catch (Exception e) { + System.out.println(">> Error copying implementation log file: " + + e.getMessage()); + } + String tckLogFilename = thisLogDir + idname + "-" + configName + "-" + TCK_LOG_FILE; + try { + File logFile = new File(TCK_LOG_FILE); + FileUtils.copyFile(logFile, new File(tckLogFilename)); + resetFileContent(TCK_LOG_FILE); + } catch (Exception e) { + System.out.println(">> Error copying tck log file: " + + e.getMessage()); + } + + if (runonce.equals("true")) { + alreadyran = true; + } + + if (TCK_PARAM_ON_FAILURE_FAIL_FAST.equals(onFailure) && failureCount > 0) { + break; + } + } + if (TCK_PARAM_ON_FAILURE_FAIL_FAST.equals(onFailure) && failureCount > 0) { + break; + } + } + if (TCK_PARAM_ON_FAILURE_FAIL_FAST.equals(onFailure) && failureCount > 0) { + break; + } + } + // Remove log file try { - URL url1 = enhancedDir.toURI().toURL(); - URL url2 = - new File(buildDirectory + File.separator + "classes" + File.separator) - .toURI() - .toURL(); - if (runtckVerbose) { - System.out.println("url2 is " + url2.toString()); - } - cpList.add(url1); - cpList.add(url2); - String[] jars = {"jar"}; - Iterator fi = FileUtils.iterateFiles(new File(extLibsDirectory), jars, true); - while (fi.hasNext()) { - cpList.add(fi.next().toURI().toURL()); - } - for (String dependency : this.dependencyClasspath.split(File.pathSeparator)) { - cpList.add(new File(dependency).toURI().toURL()); - } - } catch (MalformedURLException ex) { - ex.printStackTrace(); - Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null, ex); + FileUtils.forceDeleteOnExit(new File(implLogFile)); + } catch (Exception e) { + System.out.println(">> Error deleting log file: " + e.getMessage()); } - cpString = Utilities.urls2ClasspathString(cpList); - if (runtckVerbose) { - System.out.println("\nClasspath is " + cpString); + try { + FileUtils.forceDeleteOnExit(new File(TCK_LOG_FILE)); + } catch (Exception e) { + System.out.println(">> Error deleting log file: " + e.getMessage()); } - for (String cfg : cfgs) { - List cfgPropsString = new ArrayList(); - cfgPropsString.addAll(idPropsString); - // Parse conf file and set properties String - props = PropertyUtils.getProperties(confDirectory + File.separator + cfg); - cfgPropsString.add( - "-Djdo.tck.testdata=" + getTrimmedPropertyValue(props, "jdo.tck.testdata")); - cfgPropsString.add( - "-Djdo.tck.standarddata=" + getTrimmedPropertyValue(props, "jdo.tck.standarddata")); - cfgPropsString.add( - "-Djdo.tck.mapping.companyfactory=" - + getTrimmedPropertyValue(props, "jdo.tck.mapping.companyfactory")); - // innerPropsString.append("-Djdo.tck.description=\"" + - // props.getProperty("jdo.tck.description") + "\""); - cfgPropsString.add( - "-Djdo.tck.requiredOptions=" - + getTrimmedPropertyValue(props, "jdo.tck.requiredOptions")); - cfgPropsString.add("-Djdo.tck.signaturefile=" + signaturefile); - String mapping = getTrimmedPropertyValue(props, "jdo.tck.mapping"); - if (mapping == null) { - throw new MojoExecutionException("Could not find mapping value in conf file: " + cfg); - } - String classes = getTrimmedPropertyValue(props, "jdo.tck.classes"); - String excludeList = - getTrimmedPropertyValue(PropertyUtils.getProperties(excludeFile), "jdo.tck.exclude"); - if (classes == null) { - throw new MojoExecutionException("Could not find classes value in conf file: " + cfg); - } - classes = Utilities.removeSubstrs(classes, excludeList); - if (classes.equals("")) { - System.out.println("Skipping configuration " + cfg + ": classes excluded"); - continue; - } - List classesList = Arrays.asList(classes.split(" ")); - - cfgPropsString.add("-Djdo.tck.schemaname=" + idtype + mapping); - cfgPropsString.add("-Djdo.tck.cfg=" + cfg); - - runonce = getTrimmedPropertyValue(props, "runOnce"); - runonce = (runonce == null) ? "false" : runonce; - - // Add Mapping and schemaname to properties file - StringBuffer propsFileData = new StringBuffer(); - propsFileData.append("\n### Properties below added by maven 2 goal RunTCK.jdori"); - propsFileData.append("\njavax.jdo.mapping.Schema=" + idtype + mapping); - mapping = (mapping.equals("0")) ? "" : mapping; - propsFileData.append("\njavax.jdo.option.Mapping=standard" + mapping); - propsFileData.append("\n"); - String pmfPropsWriteFileName = - buildDirectory + File.separator + "classes" + File.separator + pmfProperties; - try { - BufferedWriter out = new BufferedWriter(new FileWriter(pmfPropsWriteFileName, false)); - out.write(defaultPropsContents + propsFileData.toString()); - out.close(); - } catch (IOException ex) { - Logger.getLogger(RunTCK.class.getName()).log(Level.SEVERE, null, ex); - } - - // build command line string - command = new ArrayList(); - command.add("java"); - command.add("-cp"); - command.add(cpString); - command.addAll(cfgPropsString); - command.add(dbproperties); - command.add(jvmproperties); - if (debugTCK) { - command.add(debugDirectives); - } - command.add(testRunnerClass); - command.addAll(classesList); - - if (runonce.equals("true") && alreadyran) { - continue; - } - - if (debugTCK) { - System.out.println("Using debug arguments: \n" + debugDirectives); - } - - // invoke class runner - System.out.print( - "*> Running tests for " - + cfg - + " with " - + idtype - + " on '" - + db - + "'" - + " mapping=" - + mapping - + " ... "); - try { - result = (new Utilities()).invokeTest(command); - if (result.getExitValue() == 0) { - System.out.println("success"); - } else { - System.out.println("FAIL"); - failureCount++; + // Output results + command = new ArrayList(); + command.add("java"); + command.add("-cp"); + command.add(cpString); + command.add("org.apache.jdo.tck.util.ResultSummary"); + command.add(thisLogDir); + result = (new Utilities()).invokeTest(command, new File(buildDirectory)); + + // Create system configuration description file + command.set(3, "org.apache.jdo.tck.util.SystemCfgSummary"); + command.set(4, cfgDirName); + command.add("system_config.txt"); + result = (new Utilities()).invokeTest(command, new File(buildDirectory)); + + // Copy metadata from enhanced to configuration logs directory + for (String idtype : idtypes) { + String fromDirName = buildDirectory + File.separator + "enhanced" + + File.separator + impl + File.separator + idtype + File.separator; + String[] metadataExtensions = {"jdo", "jdoquery", "orm", "xml", "properties"}; + String fromFileName = null; + String pkgName = null; + int startIdx = -1; + // iterator over list of abs name of metadata files in src + Iterator fi = FileUtils.iterateFiles( + new File(fromDirName), metadataExtensions, true); + while (fi.hasNext()) { + try { + fromFile = fi.next(); + fromFileName = fromFile.toString(); + if ((startIdx = fromFileName.indexOf(idtype + File.separator)) > -1) { + // fully specified name of file (idtype + package + filename) + pkgName = fromFileName.substring(startIdx); + toFile = new File(cfgDirName + File.separator + + pkgName); + FileUtils.copyFile(fromFile, toFile); + } + } catch (IOException ex) { + throw new MojoExecutionException("Failed to copy files from " + + fromFileName + " to " + toFile.toString() + + ": " + ex.getLocalizedMessage()); + } } - if (runtckVerbose) { - System.out.println("\nCommand line is: \n" + command.toString()); - System.out.println("Test exit value is " + result.getExitValue()); - System.out.println("Test result output:\n" + result.getOutputString()); - System.out.println("Test result error:\n" + result.getErrorString()); - } - } catch (java.lang.RuntimeException re) { - System.out.println("Exception on command " + command); - } - - // Move log to per-test location - String idname = "dsid"; - if (idtype.trim().equals("applicationidentity")) { - idname = "app"; - } - String configName = cfg; - if (cfg.indexOf('.') > 0) { - configName = configName.substring(0, cfg.indexOf('.')); - } - String testLogFilename = thisLogDir + idname + "-" + configName + "-" + impl + ".txt"; - try { - File logFile = new File(implLogFile); - FileUtils.copyFile(logFile, new File(testLogFilename)); - resetFileContent(implLogFile); - } catch (Exception e) { - System.out.println(">> Error copying implementation log file: " + e.getMessage()); - } - String tckLogFilename = thisLogDir + idname + "-" + configName + "-" + TCK_LOG_FILE; - try { - File logFile = new File(TCK_LOG_FILE); - FileUtils.copyFile(logFile, new File(tckLogFilename)); - resetFileContent(TCK_LOG_FILE); - } catch (Exception e) { - System.out.println(">> Error copying tck log file: " + e.getMessage()); - } - - if (runonce.equals("true")) { - alreadyran = true; - } - - if (TCK_PARAM_ON_FAILURE_FAIL_FAST.equals(onFailure) && failureCount > 0) { - break; - } } if (TCK_PARAM_ON_FAILURE_FAIL_FAST.equals(onFailure) && failureCount > 0) { - break; + throw new MojoExecutionException("Aborted TCK test run after 1 failure."); } - } - if (TCK_PARAM_ON_FAILURE_FAIL_FAST.equals(onFailure) && failureCount > 0) { - break; - } - } - // Remove log file - try { - FileUtils.forceDeleteOnExit(new File(implLogFile)); - } catch (Exception e) { - System.out.println(">> Error deleting log file: " + e.getMessage()); - } - try { - FileUtils.forceDeleteOnExit(new File(TCK_LOG_FILE)); - } catch (Exception e) { - System.out.println(">> Error deleting log file: " + e.getMessage()); - } - - // Output results - command = new ArrayList(); - command.add("java"); - command.add("-cp"); - command.add(cpString); - command.add("org.apache.jdo.tck.util.ResultSummary"); - command.add(thisLogDir); - result = (new Utilities()).invokeTest(command, new File(buildDirectory)); - - // Create system configuration description file - command.set(3, "org.apache.jdo.tck.util.SystemCfgSummary"); - command.set(4, cfgDirName); - command.add("system_config.txt"); - result = (new Utilities()).invokeTest(command, new File(buildDirectory)); - - // Copy metadata from enhanced to configuration logs directory - for (String idtype : idtypes) { - String fromDirName = - buildDirectory - + File.separator - + "enhanced" - + File.separator - + impl - + File.separator - + idtype - + File.separator; - String[] metadataExtensions = {"jdo", "jdoquery", "orm", "xml", "properties"}; - String fromFileName = null; - String pkgName = null; - int startIdx = -1; - // iterator over list of abs name of metadata files in src - Iterator fi = FileUtils.iterateFiles(new File(fromDirName), metadataExtensions, true); - while (fi.hasNext()) { - try { - fromFile = fi.next(); - fromFileName = fromFile.toString(); - if ((startIdx = fromFileName.indexOf(idtype + File.separator)) > -1) { - // fully specified name of file (idtype + package + filename) - pkgName = fromFileName.substring(startIdx); - toFile = new File(cfgDirName + File.separator + pkgName); - FileUtils.copyFile(fromFile, toFile); - } - } catch (IOException ex) { - throw new MojoExecutionException( - "Failed to copy files from " - + fromFileName - + " to " - + toFile.toString() - + ": " - + ex.getLocalizedMessage()); + if (TCK_PARAM_ON_FAILURE_FAIL_EVENTUALLY.equals(onFailure) && failureCount > 0) { + throw new MojoExecutionException("There were " + failureCount + " TCK test failures."); } - } - } - if (TCK_PARAM_ON_FAILURE_FAIL_FAST.equals(onFailure) && failureCount > 0) { - throw new MojoExecutionException("Aborted TCK test run after 1 failure."); - } - if (TCK_PARAM_ON_FAILURE_FAIL_EVENTUALLY.equals(onFailure) && failureCount > 0) { - throw new MojoExecutionException("There were " + failureCount + " TCK test failures."); } - } } diff --git a/exectck/src/main/java/org/apache/jdo/exectck/SQLFileLoader.java b/exectck/src/main/java/org/apache/jdo/exectck/SQLFileLoader.java index bb4d4bb40..7bd42c6f4 100644 --- a/exectck/src/main/java/org/apache/jdo/exectck/SQLFileLoader.java +++ b/exectck/src/main/java/org/apache/jdo/exectck/SQLFileLoader.java @@ -25,337 +25,327 @@ /** * Utility class to load SQL files via JDBC. - * - *

    The class expects a comment on a single line having a connect statement defining url, user and - * password to connect to the database e.g. -- connect 'jdbc:derby:jdotckdb;create=true' user - * 'tckuser' password 'tckuser'; + * + * The class expects a comment on a single line having a connect statement + * defining url, user and password to connect to the database e.g. + * -- connect 'jdbc:derby:jdotckdb;create=true' user 'tckuser' password 'tckuser'; */ public class SQLFileLoader { - // the reader for the sql file - private Reader reader; - // holds the next character that is just read from the reader - private int nextChar; - // holds the current SQL statement - private StringBuilder currentStmt = new StringBuilder(); - // flag indicating whether a SQL string literal is processed - private boolean scanStringLiteral = false; - // the list of SQL statements - private List statements = new ArrayList<>(); - // the JDBC connection url - private String connect; - // the JDBC connection user - private String user; - // the JDBC connection password - private String password; + // the reader for the sql file + private Reader reader; + // holds the next character that is just read from the reader + private int nextChar; + // holds the current SQL statement + private StringBuilder currentStmt = new StringBuilder(); + // flag indicating whether a SQL string literal is processed + private boolean scanStringLiteral = false; + // the list of SQL statements + private List statements = new ArrayList<>(); + // the JDBC connection url + private String connect; + // the JDBC connection user + private String user; + // the JDBC connection password + private String password; - /** - * Constructor. Reads the SQL statements from the specified file. The internal state of the class - * is updated with the contents of the file and may be accessed using the getter methods (see - * below). - * - * @param filename the name of the sql to be loaded - * @throws IOException If an I/O error occurs - */ - public SQLFileLoader(String filename) throws IOException { - try (Reader r = new BufferedReader(new FileReader(filename))) { - // init reader instance variable - this.reader = r; - // initialize nextChar with the first character from the stream - this.nextChar = this.reader.read(); + /** + * Constructor. + * Reads the SQL statements from the specified file. + * The internal state of the class is updated with the contents of the file + * and may be accessed using the getter methods (see below). + * @param filename the name of the sql to be loaded + * @throws IOException If an I/O error occurs + */ + public SQLFileLoader(String filename) throws IOException { + try (Reader r = new BufferedReader(new FileReader(filename))) { + // init reader instance variable + this.reader = r; + // initialize nextChar with the first character from the stream + this.nextChar = this.reader.read(); - int currentChar = next(); - // read characters from the stream - while (currentChar != -1) { - accept(currentChar); - currentChar = next(); - } - this.reader = null; + int currentChar = next(); + // read characters from the stream + while(currentChar != -1) { + accept(currentChar); + currentChar = next(); + } + this.reader = null; + } } - } - - /** - * Returns the list of SQL statements processed by this SQLFileLoader. - * - * @return list of SQL statements - */ - public List getStatements() { - return this.statements; - } - /** - * Returns the JDBC connection URL. - * - * @return the JDBC connection URL - */ - public String getConnect() { - return this.connect; - } + /** + * Returns the list of SQL statements processed by this SQLFileLoader. + * @return list of SQL statements + */ + public List getStatements() { + return this.statements; + } - /** - * Returns the JDBC connection user. - * - * @return the JDBC connection user. - */ - public String getUser() { - return this.user; - } + /** + * Returns the JDBC connection URL. + * @return the JDBC connection URL + */ + public String getConnect() { + return this.connect; + } - /** - * Returns the JDBC connection password. - * - * @return the JDBC connection password - */ - public String getPassword() { - return this.password; - } + /** + * Returns the JDBC connection user. + * @return the JDBC connection user. + */ + public String getUser() { + return this.user; + } - /** - * Checks the specified character whether it terminates a SQL Statement. If so the current SQL - * statement is added to the list of processed SQL statements and a new SQL statement is - * initialized. Otherwise the method appends the specified character to the current SQL statement. - * - * @param value character to be checked - */ - private void accept(int value) { - if (value == ';' && !this.scanStringLiteral) { - // found statement end - statements.add(currentStmt.toString()); - currentStmt = new StringBuilder(); - } else { - currentStmt.append((char) value); + /** + * Returns the JDBC connection password. + * @return the JDBC connection password + */ + public String getPassword() { + return this.password; } - } - /** - * Returns the next character from the input that is not part of a comment. That means single line - * comments and multi line comments are skipped. The method is able to handle SQL String literals. - * - * @return the next non comment character - * @throws IOException If an I/O error occurs - */ - private int next() throws IOException { - int result = this.nextChar; - switch (this.nextChar) { - case '\'': - this.scanStringLiteral = !this.scanStringLiteral; - this.nextChar = this.reader.read(); - break; - case '/': - if (!this.scanStringLiteral) { - int next = this.reader.read(); - if (next == '*') { - this.nextChar = this.reader.read(); - skipToEndOfMLComment(); - skipWhitespace(); - return next(); - } else { - this.nextChar = next; - } - } else { - this.nextChar = this.reader.read(); - } - break; - case '-': - if (!this.scanStringLiteral) { - int next = this.reader.read(); - if (next == '-') { - this.nextChar = reader.read(); - handleSingleLineComment(); - skipWhitespace(); - return next(); - } else { - this.nextChar = next; - } + /** + * Checks the specified character whether it terminates a SQL Statement. + * If so the current SQL statement is added to the list of processed SQL statements + * and a new SQL statement is initialized. Otherwise the method appends the specified + * character to the current SQL statement. + * @param value character to be checked + */ + private void accept(int value) { + if (value == ';' && !this.scanStringLiteral) { + // found statement end + statements.add(currentStmt.toString()); + currentStmt = new StringBuilder(); } else { - this.nextChar = this.reader.read(); + currentStmt.append((char) value); } - break; - case ' ': - case '\t': - case '\n': - case '\r': - if (!this.scanStringLiteral) { - skipWhitespace(); - result = ' '; - } else { - this.nextChar = this.reader.read(); + } + + /** + * Returns the next character from the input that is not part of a comment. + * That means single line comments and multi line comments are skipped. + * The method is able to handle SQL String literals. + * @return the next non comment character + * @throws IOException If an I/O error occurs + */ + private int next() throws IOException { + int result = this.nextChar; + switch (this.nextChar) { + case '\'' : + this.scanStringLiteral = !this.scanStringLiteral; + this.nextChar = this.reader.read(); + break; + case '/' : + if (!this.scanStringLiteral) { + int next = this.reader.read(); + if (next == '*') { + this.nextChar = this.reader.read(); + skipToEndOfMLComment(); + skipWhitespace(); + return next(); + } else { + this.nextChar = next; + } + } else { + this.nextChar = this.reader.read(); + } + break; + case '-': + if (!this.scanStringLiteral) { + int next = this.reader.read(); + if (next == '-') { + this.nextChar = reader.read(); + handleSingleLineComment(); + skipWhitespace(); + return next(); + } else { + this.nextChar = next; + } + } else { + this.nextChar = this.reader.read(); + } + break; + case ' ' : + case '\t' : + case '\n' : + case '\r' : + if (!this.scanStringLiteral) { + skipWhitespace(); + result = ' '; + } else { + this.nextChar = this.reader.read(); + } + break; + default : + this.nextChar = this.reader.read(); + break; } - break; - default: - this.nextChar = this.reader.read(); - break; + return result; } - return result; - } - /** - * Skips a single line comment. That means any character from -- to the end of the line are - * akipped. - * - * @throws IOException If an I/O error occurs - */ - private void handleSingleLineComment() throws IOException { - Optional optConnect = readIdentFollowedByLiteral("connect"); - optConnect.ifPresent(x -> this.connect = x); - Optional optUser = readIdentFollowedByLiteral("user"); - optUser.ifPresent(x -> this.user = x); - Optional optPassword = readIdentFollowedByLiteral("password"); - optPassword.ifPresent(x -> this.password = x); - skipToEOL(); - } + /** + * Skips a single line comment. + * That means any character from -- to the end of the line are akipped. + * @throws IOException If an I/O error occurs + */ + private void handleSingleLineComment() throws IOException { + Optional optConnect = readIdentFollowedByLiteral("connect"); + optConnect.ifPresent(x -> this.connect = x); + Optional optUser = readIdentFollowedByLiteral("user"); + optUser.ifPresent(x -> this.user = x); + Optional optPassword = readIdentFollowedByLiteral("password"); + optPassword.ifPresent(x -> this.password = x); + skipToEOL(); + } - /** - * Tries to read an Java identifier with the expected name followed by a SQL string literal. - * - * @param expected the expected Java identifier - * @return an Optional with the text of SQL String literal if present; otherwise an empty Optional - * @throws IOException If an I/O error occurs - */ - private Optional readIdentFollowedByLiteral(String expected) throws IOException { - Optional optIdent = readIdentifier(); - if (optIdent.isPresent()) { - String ident = optIdent.get(); - if (ident.equalsIgnoreCase(expected)) { - Optional optLiteral = readSQLStringLiteral(); - if (optLiteral.isPresent()) { - return optLiteral; + /** + * Tries to read an Java identifier with the expected name followed by a SQL string literal. + * @param expected the expected Java identifier + * @return an Optional with the text of SQL String literal if present; otherwise an empty Optional + * @throws IOException If an I/O error occurs + */ + private Optional readIdentFollowedByLiteral(String expected) throws IOException { + Optional optIdent = readIdentifier(); + if (optIdent.isPresent()) { + String ident = optIdent.get(); + if (ident.equalsIgnoreCase(expected)) { + Optional optLiteral = readSQLStringLiteral(); + if (optLiteral.isPresent()) { + return optLiteral; + } + } } - } + return Optional.empty(); } - return Optional.empty(); - } - /** - * Tries to read a Java identifier. - * - * @return an Optional with the text of the identifier if present; otherwise an empty Optional - * @throws IOException If an I/O error occurs - */ - private Optional readIdentifier() throws IOException { - skipBlanksAndTabs(); - if (Character.isJavaIdentifierStart(this.nextChar)) { - StringBuilder ident = new StringBuilder(); - ident.append((char) this.nextChar); - this.nextChar = this.reader.read(); - while (Character.isJavaIdentifierPart(this.nextChar)) { - ident.append((char) this.nextChar); - this.nextChar = reader.read(); - } - return Optional.of(ident.toString()); + /** + * Tries to read a Java identifier. + * @return an Optional with the text of the identifier if present; otherwise an empty Optional + * @throws IOException If an I/O error occurs + */ + private Optional readIdentifier() throws IOException { + skipBlanksAndTabs(); + if (Character.isJavaIdentifierStart(this.nextChar)) { + StringBuilder ident = new StringBuilder(); + ident.append((char)this.nextChar); + this.nextChar = this.reader.read(); + while (Character.isJavaIdentifierPart(this.nextChar)) { + ident.append((char)this.nextChar); + this.nextChar = reader.read(); + } + return Optional.of(ident.toString()); + } + return Optional.empty(); } - return Optional.empty(); - } - /** - * Tries to read a SQL String literal. - * - * @return an Optional with the text of the SQL String literal if present; otherwise an empty - * Optional - * @throws IOException If an I/O error occurs - */ - private Optional readSQLStringLiteral() throws IOException { - skipBlanksAndTabs(); - if (this.nextChar == '\'') { - StringBuilder literal = new StringBuilder(); - this.nextChar = this.reader.read(); - while (this.nextChar != -1) { - // possible end of SQL String literal + /** + * Tries to read a SQL String literal. + * @return an Optional with the text of the SQL String literal if present; otherwise an empty Optional + * @throws IOException If an I/O error occurs + */ + private Optional readSQLStringLiteral() throws IOException { + skipBlanksAndTabs(); if (this.nextChar == '\'') { - this.nextChar = this.reader.read(); - // are there two single quotes? - if (this.nextChar == '\'') { - // yes -> append one ' and continue - literal.append('\''); - } else { - // found end of literal - break; - } - } else { - literal.append((char) this.nextChar); - this.nextChar = this.reader.read(); + StringBuilder literal = new StringBuilder(); + this.nextChar = this.reader.read(); + while (this.nextChar != -1) { + // possible end of SQL String literal + if (this.nextChar == '\'') { + this.nextChar = this.reader.read(); + // are there two single quotes? + if (this.nextChar == '\'') { + // yes -> append one ' and continue + literal.append('\''); + } else { + // found end of literal + break; + } + } else { + literal.append((char)this.nextChar); + this.nextChar = this.reader.read(); + } + } + return Optional.of(literal.toString()); } - } - return Optional.of(literal.toString()); + return Optional.empty(); } - return Optional.empty(); - } - /** - * Skip any whitespace characters. The variable nextChar holds the first non whitespace char. - * - * @throws IOException If an I/O error occurs - */ - private void skipWhitespace() throws IOException { - while (Character.isWhitespace(this.nextChar)) { - this.nextChar = this.reader.read(); + /** + * Skip any whitespace characters. + * The variable nextChar holds the first non whitespace char. + * @throws IOException If an I/O error occurs + */ + private void skipWhitespace() throws IOException { + while (Character.isWhitespace(this.nextChar)) { + this.nextChar = this.reader.read(); + } } - } - /** - * Skips any blank and tab characters. The variable nextChar holds the first non blank or non tab - * char. - * - * @throws IOException If an I/O error occurs - */ - private void skipBlanksAndTabs() throws IOException { - while (this.nextChar == ' ' || this.nextChar == '\t') { - this.nextChar = this.reader.read(); + /** + * Skips any blank and tab characters. + * The variable nextChar holds the first non blank or non tab char. + * @throws IOException If an I/O error occurs + */ + private void skipBlanksAndTabs() throws IOException { + while (this.nextChar == ' ' || this.nextChar == '\t') { + this.nextChar = this.reader.read(); + } } - } - /** - * Skips to the end of the current line. The newline char is consumed. The variable nextChar holds - * the first char of the next line. - * - * @throws IOException If an I/O error occurs - */ - private void skipToEOL() throws IOException { - while (this.nextChar != -1) { - if (this.nextChar == '\n') { - break; - } - this.nextChar = this.reader.read(); + /** + * Skips to the end of the current line. + * The newline char is consumed. + * The variable nextChar holds the first char of the next line. + * @throws IOException If an I/O error occurs + */ + private void skipToEOL() throws IOException { + while (this.nextChar != -1) { + if (this.nextChar == '\n') { + break; + } + this.nextChar = this.reader.read(); + } + this.nextChar = this.reader.read(); } - this.nextChar = this.reader.read(); - } - /** - * Skips to the end of a multi line comment. Any characters up to * followed by / are consumed. - * The variable nextChar holds the first char after the comment. - * - * @throws IOException If an I/O error occurs - */ - private void skipToEndOfMLComment() throws IOException { - while (this.nextChar != -1) { - if (this.nextChar == '*') { - this.nextChar = this.reader.read(); - if (this.nextChar == '/') { - break; + /** + * Skips to the end of a multi line comment. + * Any characters up to * followed by / are consumed. + * The variable nextChar holds the first char after the comment. + * @throws IOException If an I/O error occurs + */ + private void skipToEndOfMLComment() throws IOException { + while (this.nextChar != -1) { + if (this.nextChar == '*') { + this.nextChar = this.reader.read(); + if (this.nextChar == '/') { + break; + } + } + this.nextChar = this.reader.read(); } - } - this.nextChar = this.reader.read(); + this.nextChar = this.reader.read(); } - this.nextChar = this.reader.read(); - } - /** - * main method For testing; prints the internal state to System.out. - * - * @param args command line arguments - */ - public static void main(String[] args) { - for (String arg : args) { - try { - SQLFileLoader loader = new SQLFileLoader(arg); - List stmts = loader.getStatements(); - System.out.println(loader.getConnect()); - System.out.println(loader.getUser()); - System.out.println(loader.getPassword()); - stmts.forEach(System.out::println); - } catch (IOException ex) { - System.err.println(ex); - } + /** + * main method For testing; prints the internal state to System.out. + * @param args command line arguments + */ + public static void main(String[] args) { + for (String arg : args) { + try { + SQLFileLoader loader = new SQLFileLoader(arg); + List stmts = loader.getStatements(); + System.out.println(loader.getConnect()); + System.out.println(loader.getUser()); + System.out.println(loader.getPassword()); + stmts.forEach(System.out::println); + } catch (IOException ex) { + System.err.println(ex); + } + } } - } + } diff --git a/exectck/src/main/java/org/apache/jdo/exectck/Utilities.java b/exectck/src/main/java/org/apache/jdo/exectck/Utilities.java index 0d334d3f6..8c5a452b1 100644 --- a/exectck/src/main/java/org/apache/jdo/exectck/Utilities.java +++ b/exectck/src/main/java/org/apache/jdo/exectck/Utilities.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -34,168 +34,171 @@ public class Utilities { - Utilities() {} - - private static final String DATE_FORMAT_NOW = "yyyyMMdd-HHmmss"; - - /* - * Return the current date/time as a String. - */ - public static String now() { - Calendar cal = Calendar.getInstance(); - SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW); - return sdf.format(cal.getTime()); - } - - /* - * From an array of URLs, create a classpath String suitable for use - * as a command line argument - */ - public static String urls2ClasspathString(List urls) { - StringBuilder cp = new StringBuilder(); - - for (URL url : urls) { - cp.append(url.getPath()); - cp.append(File.pathSeparator); + Utilities() { } - return cp.toString(); - } - - public static String removeSubstrs(String original, String exclude) { - String[] deleteThese = exclude.split(" "); - String filtered = original; - for (String sub : deleteThese) { - filtered = filtered.replaceAll(sub.trim(), ""); + + private static final String DATE_FORMAT_NOW = "yyyyMMdd-HHmmss"; + + /* + * Return the current date/time as a String. + */ + public static String now() { + Calendar cal = Calendar.getInstance(); + SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW); + return sdf.format(cal.getTime()); } - return filtered.trim(); - } - - public static void printClasspath(ClassLoader loader) { - if (loader instanceof URLClassLoader) { - // Get the URLs - URL[] urls = ((URLClassLoader) loader).getURLs(); - System.out.println(urls.length + " URL(s) for loader: "); - for (URL url : urls) { - if (url != null) { - System.out.println(" " + url.getFile()); + + /* + * From an array of URLs, create a classpath String suitable for use + * as a command line argument + */ + public static String urls2ClasspathString(List urls) { + StringBuilder cp = new StringBuilder(); + + for (URL url : urls) { + cp.append(url.getPath()); + cp.append(File.pathSeparator); + } + return cp.toString(); + } + + public static String removeSubstrs(String original, String exclude) { + String[] deleteThese = exclude.split(" "); + String filtered = original; + for (String sub: deleteThese) { + filtered = filtered.replaceAll(sub.trim(), ""); + } + return filtered.trim(); + } + + public static void printClasspath(ClassLoader loader) { + if (loader instanceof URLClassLoader) { + // Get the URLs + URL[] urls = ((URLClassLoader) loader).getURLs(); + System.out.println(urls.length + " URL(s) for loader: "); + for (URL url : urls) { + if (url != null) { + System.out.println(" " + url.getFile()); + } + } } - } } - } - public void printClasspath() { + public void printClasspath() { - // Get the System Classloader - printClasspath(ClassLoader.getSystemClassLoader()); + // Get the System Classloader + printClasspath(ClassLoader.getSystemClassLoader()); - // Get the System Classloader - printClasspath(Thread.currentThread().getContextClassLoader()); - } + // Get the System Classloader + printClasspath(Thread.currentThread().getContextClassLoader()); - static String readFile(String fileName) throws IOException { - BufferedReader reader = new BufferedReader(new FileReader(fileName)); - String line = null; - StringBuffer stringBuf = new StringBuffer(); - String ls = System.getProperty("line.separator"); - while ((line = reader.readLine()) != null) { - stringBuf.append(line); - stringBuf.append(ls); } - return stringBuf.toString(); - } - - InvocationResult invokeTest(List command) { - return invokeTest(new ProcessBuilder(command)); - } - - InvocationResult invokeTest(List command, File directory) { - ProcessBuilder builder = new ProcessBuilder(command); - builder.directory(directory); - return invokeTest(builder); - } - - private InvocationResult invokeTest(ProcessBuilder builder) { - InvocationResult result = new InvocationResult(); - try { - Process proc = builder.start(); - InputStream stdout = proc.getInputStream(); - InputStream stderr = proc.getErrorStream(); - CharBuffer outBuffer = CharBuffer.allocate(1000000); - CharBuffer errBuffer = CharBuffer.allocate(1000000); - Thread outputThread = createReaderThread(stdout, outBuffer); - Thread errorThread = createReaderThread(stderr, errBuffer); - int exitValue = proc.waitFor(); - result.setExitValue(exitValue); - errorThread.join(10000); // wait ten seconds to get stderr after process terminates - outputThread.join(10000); // wait ten seconds to get stdout after process terminates - result.setErrorString(errBuffer.toString()); - result.setOutputString(outBuffer.toString()); - // wait until the Enhancer command finishes - } catch (InterruptedException ex) { - throw new RuntimeException("InterruptedException", ex); - } catch (IOException ex) { - throw new RuntimeException("IOException", ex); - } catch (JDOException jdoex) { - jdoex.printStackTrace(); - Throwable[] throwables = jdoex.getNestedExceptions(); - System.out.println("Exception throwables of size: " + throwables.length); - for (Throwable throwable : throwables) { - throwable.printStackTrace(); - } - } - return result; - } - - private Thread createReaderThread(final InputStream input, final CharBuffer output) { - final Reader reader = new InputStreamReader(input); - Thread thread = - new Thread( - new Runnable() { - public void run() { - int count = 0; - int outputBytesRead = 0; - try { - while (-1 != (outputBytesRead = reader.read(output))) { - count += outputBytesRead; - } - } catch (IOException e) { - e.printStackTrace(); - } finally { - output.flip(); - } - } - }); - thread.start(); - return thread; - } - - class InvocationResult { - private int exitValue; - private String errorString; - private String outputString; - - int getExitValue() { - return exitValue; + + static String readFile( String fileName ) throws IOException { + BufferedReader reader = new BufferedReader( new FileReader (fileName)); + String line = null; + StringBuffer stringBuf = new StringBuffer(); + String ls = System.getProperty("line.separator"); + while ((line = reader.readLine()) != null) { + stringBuf.append( line ); + stringBuf.append( ls ); + } + return stringBuf.toString(); } - private void setExitValue(int exitValue) { - this.exitValue = exitValue; + InvocationResult invokeTest(List command) { + return invokeTest(new ProcessBuilder(command)); } - private void setErrorString(String errorString) { - this.errorString = errorString; + InvocationResult invokeTest(List command, File directory) { + ProcessBuilder builder = new ProcessBuilder(command); + builder.directory(directory); + return invokeTest(builder); } - String getErrorString() { - return errorString; + private InvocationResult invokeTest(ProcessBuilder builder) { + InvocationResult result = new InvocationResult(); + try { + Process proc = builder.start(); + InputStream stdout = proc.getInputStream(); + InputStream stderr = proc.getErrorStream(); + CharBuffer outBuffer = CharBuffer.allocate(1000000); + CharBuffer errBuffer = CharBuffer.allocate(1000000); + Thread outputThread = createReaderThread(stdout, outBuffer); + Thread errorThread = createReaderThread(stderr, errBuffer); + int exitValue = proc.waitFor(); + result.setExitValue(exitValue); + errorThread.join(10000); // wait ten seconds to get stderr after process terminates + outputThread.join(10000); // wait ten seconds to get stdout after process terminates + result.setErrorString(errBuffer.toString()); + result.setOutputString(outBuffer.toString()); + // wait until the Enhancer command finishes + } catch (InterruptedException ex) { + throw new RuntimeException("InterruptedException", ex); + } catch (IOException ex) { + throw new RuntimeException("IOException", ex); + } catch (JDOException jdoex) { + jdoex.printStackTrace(); + Throwable[] throwables = jdoex.getNestedExceptions(); + System.out.println("Exception throwables of size: " + throwables.length); + for (Throwable throwable: throwables) { + throwable.printStackTrace(); + } + } + return result; } - private void setOutputString(String outputString) { - this.outputString = outputString; + private Thread createReaderThread(final InputStream input, final CharBuffer output) { + final Reader reader = new InputStreamReader(input); + Thread thread = new Thread( + new Runnable() { + public void run() { + int count = 0; + int outputBytesRead = 0; + try { + while (-1 != (outputBytesRead = reader.read(output))) { + count += outputBytesRead; + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + output.flip(); + } + } + }); + thread.start(); + return thread; } - String getOutputString() { - return outputString; + + class InvocationResult { + private int exitValue; + private String errorString; + private String outputString; + + int getExitValue() { + return exitValue; + } + + private void setExitValue(int exitValue) { + this.exitValue = exitValue; + } + + private void setErrorString(String errorString) { + this.errorString = errorString; + } + + String getErrorString() { + return errorString; + } + + private void setOutputString(String outputString) { + this.outputString = outputString; + } + + String getOutputString() { + return outputString; + } + } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/AbstractReaderTest.java b/tck/src/main/java/org/apache/jdo/tck/AbstractReaderTest.java index c8ccbe543..17b371e9a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/AbstractReaderTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/AbstractReaderTest.java @@ -17,13 +17,15 @@ package org.apache.jdo.tck; +import javax.jdo.JDOFatalInternalException; +import javax.jdo.LegacyJava; import java.lang.reflect.InvocationTargetException; import java.security.PrivilegedAction; + import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.jdo.JDOFatalInternalException; -import javax.jdo.LegacyJava; + import org.springframework.beans.factory.support.DefaultListableBeanFactory; /* @@ -31,63 +33,62 @@ */ public class AbstractReaderTest extends JDO_Test { - /** The list of all objects in the bean collection. */ - protected List rootOids; + /** The list of all objects in the bean collection. */ + protected List rootOids; - /** The name of the root object in the bean collection. */ - protected static final String rootName = "root"; + /** The name of the root object in the bean collection. */ + protected static final String rootName = "root"; - /** The name of the file containing the bean collection (test data). */ - protected final String inputFilename = System.getProperty("jdo.tck.testdata"); + /** The name of the file containing the bean collection (test data). */ + protected final String inputFilename = System.getProperty("jdo.tck.testdata"); - /** The map of String (bean name) to Object (bean). */ - protected Map oidMap = new HashMap(); + /** The map of String (bean name) to Object (bean). */ + protected Map oidMap = new HashMap(); - /** - * Get the named bean from the bean factory. - * - * @param factory the bean factory - * @param name the name of the bean - * @return the named object - */ - protected Object getBean(final DefaultListableBeanFactory factory, final String name) { - return doPrivileged( - new PrivilegedAction() { - public Object run() { - return factory.getBean(name); - } - }); - } + /** Get the named bean from the bean factory. + * + * @param factory the bean factory + * @param name the name of the bean + * @return the named object + */ + protected Object getBean(final DefaultListableBeanFactory factory, final String name) { + return doPrivileged( + new PrivilegedAction() { + public Object run() { + return factory.getBean(name); + } + } + ); + } - @SuppressWarnings("unchecked") - private static T doPrivileged(PrivilegedAction privilegedAction) { - try { - return (T) LegacyJava.doPrivilegedAction.invoke(null, privilegedAction); - } catch (IllegalAccessException | InvocationTargetException e) { - if (e.getCause() instanceof RuntimeException) { - throw (RuntimeException) e.getCause(); - } - throw new JDOFatalInternalException(e.getMessage()); + @SuppressWarnings("unchecked") + private static T doPrivileged(PrivilegedAction privilegedAction) { + try { + return (T) LegacyJava.doPrivilegedAction.invoke(null, privilegedAction); + } catch (IllegalAccessException | InvocationTargetException e) { + if (e.getCause() instanceof RuntimeException) { + throw (RuntimeException) e.getCause(); + } + throw new JDOFatalInternalException(e.getMessage()); + } } - } - /** - * Get the root object from the bean factory. - * - * @param factory the bean factory - * @return the List of objects - */ - protected List getRootList(DefaultListableBeanFactory factory) { - return (List) getBean(factory, rootName); - } + /** Get the root object from the bean factory. + * + * @param factory the bean factory + * @return the List of objects + */ + protected List getRootList(DefaultListableBeanFactory factory) { + return (List) getBean(factory, rootName); + } + + /** Get the named object from the Map of objects. + * + * @param name the bean name + * @return the named object + */ + protected Object getOidByName(String name) { + return oidMap.get((Object)name); + } - /** - * Get the named object from the Map of objects. - * - * @param name the bean name - * @return the named object - */ - protected Object getOidByName(String name) { - return oidMap.get((Object) name); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/JDO_Test.java b/tck/src/main/java/org/apache/jdo/tck/JDO_Test.java index da4451262..5278c7300 100644 --- a/tck/src/main/java/org/apache/jdo/tck/JDO_Test.java +++ b/tck/src/main/java/org/apache/jdo/tck/JDO_Test.java @@ -5,29 +5,34 @@ * 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 + * + * 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.jdo.tck; import java.io.File; -import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; + import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Modifier; + +import javax.jdo.*; import java.security.PrivilegedAction; + import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -38,1318 +43,1346 @@ import java.util.Properties; import java.util.StringTokenizer; import java.util.Vector; -import javax.jdo.Constants; -import javax.jdo.Extent; -import javax.jdo.JDOException; -import javax.jdo.JDOFatalException; -import javax.jdo.JDOFatalInternalException; -import javax.jdo.JDOHelper; -import javax.jdo.JDOObjectNotFoundException; -import javax.jdo.LegacyJava; -import javax.jdo.PersistenceManager; -import javax.jdo.PersistenceManagerFactory; -import javax.jdo.Query; + import junit.framework.AssertionFailedError; import junit.framework.TestCase; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; public abstract class JDO_Test extends TestCase { - public static final int TRANSIENT = 0; - public static final int PERSISTENT_NEW = 1; - public static final int PERSISTENT_CLEAN = 2; - public static final int PERSISTENT_DIRTY = 3; - public static final int HOLLOW = 4; - public static final int TRANSIENT_CLEAN = 5; - public static final int TRANSIENT_DIRTY = 6; - public static final int PERSISTENT_NEW_DELETED = 7; - public static final int PERSISTENT_DELETED = 8; - public static final int PERSISTENT_NONTRANSACTIONAL = 9; - public static final int PERSISTENT_NONTRANSACTIONAL_DIRTY = 10; - public static final int DETACHED_CLEAN = 11; - public static final int DETACHED_DIRTY = 12; - public static final int NUM_STATES = 13; - public static final int ILLEGAL_STATE = 13; - - public static final String[] states = { - "transient", - "persistent-new", - "persistent-clean", - "persistent-dirty", - "hollow", - "transient-clean", - "transient-dirty", - "persistent-new-deleted", - "persistent-deleted", - "persistent-nontransactional", - "persistent-nontransactional-dirty", - "detached-clean", - "detached-dirty", - "illegal" - }; - private static final int IS_PERSISTENT = 0; - private static final int IS_TRANSACTIONAL = 1; - private static final int IS_DIRTY = 2; - private static final int IS_NEW = 3; - private static final int IS_DELETED = 4; - private static final int IS_DETACHED = 5; - private static final int NUM_STATUSES = 6; - - /* - * This table indicates the values returned by the status interrogation - * methods for each state. This is used to determine the current lifecycle - * state of an object. - */ - private static final boolean state_statuses[][] = { - // IS_PERSISTENT IS_TRANSACTIONAL IS_DIRTY IS_NEW IS_DELETED IS_DETACHED - // transient - {false, false, false, false, false, false}, - - // persistent-new - {true, true, true, true, false, false}, - - // persistent-clean - {true, true, false, false, false, false}, - - // persistent-dirty - {true, true, true, false, false, false}, - - // hollow - {true, false, false, false, false, false}, - - // transient-clean - {false, true, false, false, false, false}, - - // transient-dirty - {false, true, true, false, false, false}, - - // persistent-new-deleted - {true, true, true, true, true, false}, - - // persistent-deleted - {true, true, true, false, true, false}, - - // persistent-nontransactional - {true, false, false, false, false, false}, - - // persistent-nontransactional-dirty - {true, false, true, false, false, false}, - - // detached_clean - {false, false, false, false, false, true}, - - // detached_dirty - {false, false, true, false, false, true} - }; - - /** Name of the PersistenceManagerFactoryClass PMF property. */ - public static final String PMF_CLASS_PROP = "javax.jdo.PersistenceManagerFactoryClass"; - - /** Name of the ConnectionURL PMF property. */ - public static final String CONNECTION_URL_PROP = "javax.jdo.option.ConnectionURL"; - - /** Name of the ConnectionUserName PMF property. */ - public static final String CONNECTION_USERNAME_PROP = "javax.jdo.option.ConnectionUserName"; - - /** Name of the ConnectionPassword PMF property. */ - public static final String CONNECTION_PASSWORD_PROP = "javax.jdo.option.ConnectionPassword"; - - /** identitytype value for applicationidentity. */ - public static final String APPLICATION_IDENTITY = "applicationidentity"; - - /** identitytype value for datastoreidentity. */ - public static final String DATASTORE_IDENTITY = "datastoreidentity"; - - /** Map of transaction isolation String values to Integer */ - protected static final Map levelValues = new HashMap(); - - static { - levelValues.put(Constants.TX_READ_UNCOMMITTED, 0); - levelValues.put(Constants.TX_READ_COMMITTED, 1); - levelValues.put(Constants.TX_REPEATABLE_READ, 2); - levelValues.put(Constants.TX_SNAPSHOT, 3); - levelValues.put(Constants.TX_SERIALIZABLE, 4); - } - - /** - * String indicating the type of identity used for the current test case. The value is either - * "applicationidentity" or "datastoreidentity". - */ - protected static final String IDENTITYTYPE = System.getProperty("jdo.tck.identitytype"); - - /** String indicating the name of the schema for the current test. */ - protected static final String SCHEMANAME = System.getProperty("jdo.tck.schemaname"); - - /** Name of the file containing the properties for the PMF. */ - protected static String PMFProperties = System.getProperty("PMFProperties"); - - /** - * Flag indicating whether to clean up data after tests or not. If false then test will not clean - * up data from database. The default value is true. - */ - protected static final boolean CLEANUP_DATA = - System.getProperty("jdo.tck.cleanupaftertest", "true").equalsIgnoreCase("true"); - - /** Flag indicating whether to close the PMF after each test or not. It defaults to false. */ - protected static final boolean CLOSE_PMF_AFTER_EACH_TEST = - System.getProperty("jdo.tck.closePMFAfterEachTest", "false").equalsIgnoreCase("true"); - - /** Flag indicating whether to skip JNDI related tests. */ - protected static final boolean SKIP_JNDI = - System.getProperty("jdo.tck.skipJndi", "false").equalsIgnoreCase("true"); - - /** The Properties object for the PersistenceManagerFactory. */ - protected static Properties PMFPropertiesObject; - - /** The PersistenceManagerFactory. */ - protected static PersistenceManagerFactory pmf; - - /** The collection of supported options of the pmf. */ - protected static Collection supportedOptions; - - /** The name of the pmf supported options summary file. */ - private static final String PMF_SUPPORTED_OPTIONS_FILE_NAME = "pmf_supported_options.txt"; - - /** The PersistenceManager. */ - protected PersistenceManager pm; - - // Flag indicating successful test run - protected boolean testSucceeded; - - /** Logger */ - protected Log logger = LogFactory.getFactory().getInstance("org.apache.jdo.tck"); - - /** true if debug logging in enabled. */ - protected boolean debug = logger.isDebugEnabled(); - - /** - * Indicates an exception thrown in method tearDown. At the end of method - * tearDown this field is nullified. - */ - private Throwable tearDownThrowable; - - /** - * A list of registered oid instances. Corresponding pc instances are deleted in - * localTearDown. - */ - private Collection tearDownInstances = new LinkedList(); - - /** - * A list of registered pc classes. The extents of these classes are deleted in - * localTearDown. - */ - private Collection tearDownClasses = new LinkedList(); - - /** - * Intended for subclasses so that they may skip this class's normal set up procedure. - * - * @return true to run normal set up, false to skip normal set up - */ - protected boolean preSetUp() { - return true; - } - - protected final void setUp() throws Exception { - if (!preSetUp()) { - return; - } - - pmf = getPMF(); - localSetUp(); - } - - /** - * Subclasses may override this method to allocate any data and resources that they need in order - * to successfully execute this testcase. - */ - protected void localSetUp() {} - - /** - * Runs the bare test sequence. - * - * @exception Throwable if any exception is thrown - */ - public final void runBare() throws Throwable { - try { - testSucceeded = false; - setUp(); - runTest(); - testSucceeded = true; - } catch (AssertionFailedError e) { - if (logger.isInfoEnabled()) logger.info("Exception during setUp or runtest: ", e); - throw e; - } catch (Throwable t) { - if (logger.isInfoEnabled()) logger.info("Exception during setUp or runtest: ", t); - throw t; - } finally { - tearDown(); - if (debug) { - logger.debug("Free memory: " + Runtime.getRuntime().freeMemory()); - } - } - } - - /** - * Sets field tearDownThrowable if it is null. Else, the given throwable - * is logged using fatal log level. - * - * @param throwable the throwable - */ - private void setTearDownThrowable(String context, Throwable throwable) { - if (logger.isInfoEnabled()) logger.info("Exception during " + context + ": ", throwable); - if (this.tearDownThrowable == null) { - this.tearDownThrowable = throwable; - } - } - - /** - * Intended for subclasses so that they may skip this class's normal tear down procedure. - * - * @return true to run normal tear down, false to skip normal tear down - */ - protected boolean preTearDown() { - return true; - } - - /** - * This method clears data and resources allocated by testcases. It first closes the persistence - * manager of this testcase. Then it calls method localTearDown. Subclasses may - * override that method to clear any data and resources that they have allocated in method - * localSetUp. Finally, this method closes the persistence manager factory. - * - *

    Note:These methods are called always, regardless of any exceptions. The first caught - * exception is kept in field tearDownThrowable. That exception is thrown as a nested - * exception of JDOFatalException if and only if the testcase executed successful. - * Otherwise that exception is logged using fatal log level. All other exceptions are logged using - * fatal log level, always. - * - *

    Note:By default, the method tearDown does not close the pmf. This is done at the end - * of each configuration, unless the property jdo.tck.closePMFAfterEachTest is set to true. - */ - protected final void tearDown() { - if (!preTearDown()) { - return; - } - - try { - cleanupPM(); - } catch (Throwable t) { - setTearDownThrowable("cleanupPM", t); - } - - if ((pmf == null || pmf.isClosed()) - && (this.tearDownInstances.size() > 0 || this.tearDownClasses.size() > 0)) - throw new JDOFatalException( - "PMF must not be nullified or closed when tear down instances and /or classes have been added."); - - if (pmf != null && pmf.isClosed()) pmf = null; - - try { - if (CLEANUP_DATA) { - localTearDown(); - } - } catch (Throwable t) { - setTearDownThrowable("localTearDown", t); - } - - if (CLOSE_PMF_AFTER_EACH_TEST) { - try { - closePMF(); - } catch (Throwable t) { - setTearDownThrowable("closePMF", t); - } - } - - if (this.tearDownThrowable != null) { - Throwable t = this.tearDownThrowable; - this.tearDownThrowable = null; - if (testSucceeded) { - // runTest succeeded, but this method threw exception => error - throw new JDOFatalException("Exception during tearDown", t); - } - } - } - - /** - * Deletes all registered pc instances and extents of all registered pc classes. Subclasses may - * override this method to clear any data and resources that they have allocated in method - * localSetUp. - */ - protected void localTearDown() { - deleteTearDownInstances(); - deleteTearDownClasses(); - } - - protected void addTearDownObjectId(Object oid) { - // ensure that oid is not a PC instance - if (JDOHelper.getObjectId(oid) != null || JDOHelper.isTransactional(oid)) - throw new IllegalArgumentException("oid"); - this.tearDownInstances.add(oid); - } - - protected void addTearDownInstance(Object pc) { - Object oid = JDOHelper.getObjectId(pc); - addTearDownObjectId(oid); - } - - protected void addTearDownClass(Class pcClass) { - this.tearDownClasses.add(pcClass); - } - - protected void addTearDownClass(Class[] pcClasses) { - if (pcClasses == null) return; - for (int i = 0; i < pcClasses.length; ++i) { - addTearDownClass(pcClasses[i]); - } - } - - /** - * Deletes and removes tear down instances. If there are no tear down instances, the this method - * is a noop. Otherwise, tear down instances are deleted exactly in the order they have been - * added. Tear down instances are deleted in a separate transaction. - */ - protected void deleteTearDownInstances() { - if (this.tearDownInstances.size() > 0) { - getPM(); - try { - this.pm.currentTransaction().begin(); - for (Iterator i = this.tearDownInstances.iterator(); i.hasNext(); ) { - Object pc; - try { - pc = this.pm.getObjectById(i.next(), true); - } catch (JDOObjectNotFoundException e) { - pc = null; - } - // we only delete those persistent instances - // which have not been deleted by tests already. - if (pc != null) { - this.pm.deletePersistent(pc); - } + public static final int TRANSIENT = 0; + public static final int PERSISTENT_NEW = 1; + public static final int PERSISTENT_CLEAN = 2; + public static final int PERSISTENT_DIRTY = 3; + public static final int HOLLOW = 4; + public static final int TRANSIENT_CLEAN = 5; + public static final int TRANSIENT_DIRTY = 6; + public static final int PERSISTENT_NEW_DELETED = 7; + public static final int PERSISTENT_DELETED = 8; + public static final int PERSISTENT_NONTRANSACTIONAL = 9; + public static final int PERSISTENT_NONTRANSACTIONAL_DIRTY = 10; + public static final int DETACHED_CLEAN = 11; + public static final int DETACHED_DIRTY = 12; + public static final int NUM_STATES = 13; + public static final int ILLEGAL_STATE = 13; + + public static final String[] states = { + "transient", + "persistent-new", + "persistent-clean", + "persistent-dirty", + "hollow", + "transient-clean", + "transient-dirty", + "persistent-new-deleted", + "persistent-deleted", + "persistent-nontransactional", + "persistent-nontransactional-dirty", + "detached-clean", + "detached-dirty", + "illegal" + }; + private static final int IS_PERSISTENT = 0; + private static final int IS_TRANSACTIONAL = 1; + private static final int IS_DIRTY = 2; + private static final int IS_NEW = 3; + private static final int IS_DELETED = 4; + private static final int IS_DETACHED = 5; + private static final int NUM_STATUSES = 6; + + /* + * This table indicates the values returned by the status interrogation + * methods for each state. This is used to determine the current lifecycle + * state of an object. + */ + private static final boolean state_statuses[][] = { + // IS_PERSISTENT IS_TRANSACTIONAL IS_DIRTY IS_NEW IS_DELETED IS_DETACHED + // transient + { false, false, false, false, false, false}, + + // persistent-new + { true, true, true, true, false, false}, + + // persistent-clean + { true, true, false, false, false, false}, + + // persistent-dirty + { true, true, true, false, false, false}, + + // hollow + { true, false, false, false, false, false}, + + // transient-clean + { false, true, false, false, false, false}, + + // transient-dirty + { false, true, true, false, false, false}, + + // persistent-new-deleted + { true, true, true, true, true, false}, + + // persistent-deleted + { true, true, true, false, true, false}, + + // persistent-nontransactional + { true, false, false, false, false, false}, + + // persistent-nontransactional-dirty + { true, false, true, false, false, false}, + + // detached_clean + { false, false, false, false, false, true}, + + // detached_dirty + { false, false, true, false, false, true} + }; + + /** Name of the PersistenceManagerFactoryClass PMF property. */ + public static final String PMF_CLASS_PROP = + "javax.jdo.PersistenceManagerFactoryClass"; + + /** Name of the ConnectionURL PMF property. */ + public static final String CONNECTION_URL_PROP = + "javax.jdo.option.ConnectionURL"; + + /** Name of the ConnectionUserName PMF property. */ + public static final String CONNECTION_USERNAME_PROP = + "javax.jdo.option.ConnectionUserName"; + + /** Name of the ConnectionPassword PMF property. */ + public static final String CONNECTION_PASSWORD_PROP = + "javax.jdo.option.ConnectionPassword"; + + /** identitytype value for applicationidentity. */ + public static final String APPLICATION_IDENTITY = "applicationidentity"; + + /** identitytype value for datastoreidentity. */ + public static final String DATASTORE_IDENTITY = "datastoreidentity"; + + /** Map of transaction isolation String values to Integer */ + protected final static Map levelValues = new HashMap(); + static { + levelValues.put(Constants.TX_READ_UNCOMMITTED, 0); + levelValues.put(Constants.TX_READ_COMMITTED, 1); + levelValues.put(Constants.TX_REPEATABLE_READ, 2); + levelValues.put(Constants.TX_SNAPSHOT, 3); + levelValues.put(Constants.TX_SERIALIZABLE, 4); + } + + /** + * String indicating the type of identity used for the current test case. + * The value is either "applicationidentity" or "datastoreidentity". + */ + protected static final String IDENTITYTYPE = System.getProperty("jdo.tck.identitytype"); + + /** + * String indicating the name of the schema for the current test. + */ + protected static final String SCHEMANAME = System.getProperty("jdo.tck.schemaname"); + + /** Name of the file containing the properties for the PMF. */ + protected static String PMFProperties = System.getProperty("PMFProperties"); + + /** Flag indicating whether to clean up data after tests or not. + * If false then test will not clean up data from database. + * The default value is true. + */ + protected static final boolean CLEANUP_DATA = + System.getProperty("jdo.tck.cleanupaftertest", "true").equalsIgnoreCase("true"); + + /** Flag indicating whether to close the PMF after each test or not. + * It defaults to false. + */ + protected static final boolean CLOSE_PMF_AFTER_EACH_TEST = + System.getProperty("jdo.tck.closePMFAfterEachTest", "false").equalsIgnoreCase("true"); + + /** Flag indicating whether to skip JNDI related tests. */ + protected static final boolean SKIP_JNDI = + System.getProperty("jdo.tck.skipJndi", "false").equalsIgnoreCase("true"); + + /** The Properties object for the PersistenceManagerFactory. */ + protected static Properties PMFPropertiesObject; + + /** The PersistenceManagerFactory. */ + protected static PersistenceManagerFactory pmf; + + /** The collection of supported options of the pmf. */ + protected static Collection supportedOptions; + + /** The name of the pmf supported options summary file. */ + private static final String PMF_SUPPORTED_OPTIONS_FILE_NAME = "pmf_supported_options.txt"; + + /** The PersistenceManager. */ + protected PersistenceManager pm; + + // Flag indicating successful test run + protected boolean testSucceeded; + + /** Logger */ + protected Log logger = + LogFactory.getFactory().getInstance("org.apache.jdo.tck"); + + /** true if debug logging in enabled. */ + protected boolean debug = logger.isDebugEnabled(); + + /** + * Indicates an exception thrown in method tearDown. + * At the end of method tearDown this field is nullified. + */ + private Throwable tearDownThrowable; + + /** + * A list of registered oid instances. + * Corresponding pc instances are deleted in localTearDown. + */ + private Collection tearDownInstances = new LinkedList(); + + /** + * A list of registered pc classes. + * The extents of these classes are deleted in localTearDown. + */ + private Collection tearDownClasses = new LinkedList(); + + /** + * Intended for subclasses so that they may skip this class's normal set up procedure. + * @return true to run normal set up, false to skip normal set up + */ + protected boolean preSetUp() { + return true; + } + + protected final void setUp() throws Exception { + if (!preSetUp()) { + return; + } + + pmf = getPMF(); + localSetUp(); + } + + /** + * Subclasses may override this method to allocate any data and resources + * that they need in order to successfully execute this testcase. + */ + protected void localSetUp() {} + + /** + * Runs the bare test sequence. + * @exception Throwable if any exception is thrown + */ + public final void runBare() throws Throwable { + try { + testSucceeded = false; + setUp(); + runTest(); + testSucceeded = true; + } + catch (AssertionFailedError e) { + if (logger.isInfoEnabled()) + logger.info("Exception during setUp or runtest: ", e); + throw e; + } + catch (Throwable t) { + if (logger.isInfoEnabled()) + logger.info("Exception during setUp or runtest: ", t); + throw t; + } + finally { + tearDown(); + if (debug) { + logger.debug("Free memory: " + Runtime.getRuntime().freeMemory()); + } + } + } + + /** + * Sets field tearDownThrowable if it is null. + * Else, the given throwable is logged using fatal log level. + * @param throwable the throwable + */ + private void setTearDownThrowable(String context, Throwable throwable) + { + if (logger.isInfoEnabled()) + logger.info("Exception during "+context+": ", throwable); + if (this.tearDownThrowable == null) { + this.tearDownThrowable = throwable; + } + } + + /** + * Intended for subclasses so that they may skip this class's normal tear down procedure. + * @return true to run normal tear down, false to skip normal tear down + */ + protected boolean preTearDown() { + return true; + } + + /** + * This method clears data and resources allocated by testcases. + * It first closes the persistence manager of this testcase. + * Then it calls method localTearDown. + * Subclasses may override that method to clear any data and resources + * that they have allocated in method localSetUp. + * Finally, this method closes the persistence manager factory.

    + * + * Note:These methods are called always, regardless of any exceptions. + * The first caught exception is kept in field tearDownThrowable. + * That exception is thrown as a nested exception of JDOFatalException + * if and only if the testcase executed successful. + * Otherwise that exception is logged using fatal log level. + * All other exceptions are logged using fatal log level, always.

    + * + * Note:By default, the method tearDown does not close the pmf. + * This is done at the end of each configuration, unless the property + * jdo.tck.closePMFAfterEachTest is set to true. + */ + protected final void tearDown() { + if (!preTearDown()) { + return; + } + + try { + cleanupPM(); + } + catch (Throwable t) { + setTearDownThrowable("cleanupPM", t); + } + + if ((pmf == null || pmf.isClosed()) && + (this.tearDownInstances.size() > 0 || this.tearDownClasses.size() > 0)) + throw new JDOFatalException ("PMF must not be nullified or closed when tear down instances and /or classes have been added."); + + if (pmf != null && pmf.isClosed()) + pmf = null; + + try { + if (CLEANUP_DATA) { + localTearDown(); + } + } + catch (Throwable t) { + setTearDownThrowable("localTearDown", t); + } + + if (CLOSE_PMF_AFTER_EACH_TEST) { + try { + closePMF(); + } + catch (Throwable t) { + setTearDownThrowable("closePMF", t); + } + } + + if (this.tearDownThrowable != null) { + Throwable t = this.tearDownThrowable; + this.tearDownThrowable = null; + if (testSucceeded) { + // runTest succeeded, but this method threw exception => error + throw new JDOFatalException("Exception during tearDown", t); + } + } + } + + /** + * Deletes all registered pc instances and extents of all registered pc classes. + * Subclasses may override this method to clear any data and resources + * that they have allocated in method localSetUp. + */ + protected void localTearDown() { + deleteTearDownInstances(); + deleteTearDownClasses(); + } + + protected void addTearDownObjectId(Object oid) { + // ensure that oid is not a PC instance + if (JDOHelper.getObjectId(oid) != null || + JDOHelper.isTransactional(oid)) + throw new IllegalArgumentException("oid"); + this.tearDownInstances.add(oid); + } + + protected void addTearDownInstance(Object pc) { + Object oid = JDOHelper.getObjectId(pc); + addTearDownObjectId(oid); + } + + protected void addTearDownClass(Class pcClass) { + this.tearDownClasses.add(pcClass); + } + + protected void addTearDownClass(Class[] pcClasses) { + if (pcClasses == null) return; + for (int i = 0; i < pcClasses.length; ++i) { + addTearDownClass(pcClasses[i]); + } + } + + /** + * Deletes and removes tear down instances. + * If there are no tear down instances, + * the this method is a noop. + * Otherwise, tear down instances are deleted + * exactly in the order they have been added. + * Tear down instances are deleted in a separate transaction. + */ + protected void deleteTearDownInstances() { + if (this.tearDownInstances.size() > 0) { + getPM(); + try { + this.pm.currentTransaction().begin(); + for (Iterator i = this.tearDownInstances.iterator(); i.hasNext(); ) { + Object pc; + try { + pc = this.pm.getObjectById(i.next(), true); + } + catch (JDOObjectNotFoundException e) { + pc = null; + } + // we only delete those persistent instances + // which have not been deleted by tests already. + if (pc != null) { + this.pm.deletePersistent(pc); + } + } + this.pm.currentTransaction().commit(); + } + finally { + this.tearDownInstances.clear(); + cleanupPM(); + } + } + } + + /** + * Deletes and removes tear down classes. + * If there are no tear down classes, + * the this method is a noop. + * Otherwise, tear down classes are deleted + * exactly in the order they have been added. + * Tear down classes are deleted in a separate transaction. + * Deleting a tear down class means to delete the extent. + */ + protected void deleteTearDownClasses() { + if (this.tearDownClasses.size() > 0) { + getPM(); + try { + this.pm.currentTransaction().begin(); + for (Iterator i = this.tearDownClasses.iterator(); i.hasNext(); ) { + this.pm.deletePersistentAll(getAllObjects(this.pm, (Class)i.next())); + } + this.pm.currentTransaction().commit(); + } + finally { + this.tearDownClasses.clear(); + cleanupPM(); + } + } + } + + /** + * Returns a collection of persistence instances of the specified class. + * @param pm the PersistenceManager + * @param pcClass the class object of the PersistenceCapabale class + * @return a Collection of persistence objects + */ + protected Collection getAllObjects(PersistenceManager pm, Class pcClass) { + Collection col = new Vector() ; + Query query = pm.newQuery(); + query.setClass(pcClass); + Extent candidates = null; + try { + candidates = pm.getExtent(pcClass, false); + } catch (JDOException ex) { + if (debug) logger.debug("Exception thrown for getExtent of class " + + pcClass.getName()); + return col; + } + query.setCandidates(candidates); + Object result = query.execute(); + return (Collection)result; + } + + /** + * Get the PersistenceManagerFactory instance + * for the implementation under test. + * @return field pmf if it is not null, + * else sets field pmf to a new instance and returns that instance. + */ + protected PersistenceManagerFactory getPMF() { + if (pmf == null) { + PMFPropertiesObject = loadProperties(PMFProperties); // will exit here if no properties + pmf = JDOHelper.getPersistenceManagerFactory(PMFPropertiesObject); + if (supportedOptions == null) { + supportedOptions = pmf.supportedOptions(); + } + } + return pmf; + } + + protected Class getPMFClass() { + if (pmf != null) { + return pmf.getClass(); + } + + PMFPropertiesObject = loadProperties(PMFProperties); + String name = PMFPropertiesObject.getProperty(PMF_CLASS_PROP); + try { + return Class.forName(name); + } catch (ClassNotFoundException ex) { + throw new JDOException("Cannot find PMF class '" + name + "'.", + ex); + } + } + + /** + * Get the PersistenceManagerFactory instance + * for the implementation under test. This method does NOT use the + * JDOHelper method to retrieve the PMF, instead it creates an instance of + * the class specified as javax.jdo.PersistenceManagerFactoryClass + * property. The returned PMF is not configured. + * @return field pmf if it is not null, + * else sets field pmf to a new instance and returns that instance. + */ + protected PersistenceManagerFactory getUnconfiguredPMF() { + if (pmf == null) { + String name = null; + try { + Class pmfClass = getPMFClass(); + name = pmfClass.getName(); + pmf = (PersistenceManagerFactory) pmfClass.newInstance(); + if (supportedOptions == null) { + supportedOptions = pmf.supportedOptions(); + } + } catch (InstantiationException ex) { + throw new JDOException("Cannot instantiate PMF class '" + + name + "'.", ex); + } catch (IllegalAccessException ex) { + throw new JDOException("Cannot access PMF class '" + name + + "' or its no-arg constructor.", ex); + } + } + return pmf; + } + + /** + * Get the PersistenceManager instance + * for the implementation under test. + * @return the PersistenceManager + */ + protected PersistenceManager getPM() { + if (pm == null) { + pm = getPMF().getPersistenceManager(); + } + return pm; + } + + + /** + * This method cleans up the environment: closes the + * PersistenceManager. This should avoid leaving + * multiple PersistenceManager instances around, in case the + * PersistenceManagerFactory performs PersistenceManager pooling. + */ + protected void cleanupPM() { + cleanupPM(pm); + pm = null; + } + + /** + * This method cleans up the specified + * PersistenceManager. If the pm still has an open + * transaction, it will be rolled back, before closing the pm. + * @param pm the PersistenceManager + */ + protected static void cleanupPM(PersistenceManager pm) { + if ((pm != null) && !pm.isClosed()) { + if (pm.currentTransaction().isActive()) { + pm.currentTransaction().rollback(); + } + pm.close(); + } + } + + /** Closes the pmf stored in this instance. */ + public static void closePMF() { + JDOException failure = null; + while (pmf != null) { + try { + if (!pmf.isClosed()) { + closePMF(pmf); + } + pmf = null; + } + catch (JDOException ex) { + // store failure of first call pmf.close + if (failure == null) + failure = ex; + PersistenceManager[] pms = getFailedPersistenceManagers( + "closePMF", ex); + for (int i = 0; i < pms.length; i++) { + cleanupPM(pms[i]); + } + } + catch (RuntimeException ex) { + pmf = null; + ex.printStackTrace(System.out); + throw ex; + } + } + + // rethrow JDOException thrown by pmf.close + if (failure != null) + throw failure; + } + + /** + * Closes the pmf passed as a parameter. + * This must be done in a doPrivileged block. + * @param PMF the PersistenceManagerFactory + */ + public static void closePMF(final PersistenceManagerFactory PMF) { + if (PMF != null) { + if (!PMF.isClosed()) { + doPrivileged( + new PrivilegedAction () { + public Object run () { + PMF.close(); + return null; + } + } + ); + } + } + } + + @SuppressWarnings("unchecked") + private static T doPrivileged(PrivilegedAction privilegedAction) { + try { + return (T) LegacyJava.doPrivilegedAction.invoke(null, privilegedAction); + } catch (IllegalAccessException | InvocationTargetException e) { + if (e.getCause() instanceof RuntimeException) { + throw (RuntimeException) e.getCause(); + } + throw new JDOFatalInternalException(e.getMessage()); + } + } + + /** + * Returns failed PersistenceManagers + * @param assertionFailure failure + * @param ex exception + * @return failed PersistenceManagers + */ + protected static PersistenceManager[] getFailedPersistenceManagers( + String assertionFailure, JDOException ex) { + Throwable[] nesteds = ex.getNestedExceptions(); + int numberOfExceptions = nesteds==null ? 0 : nesteds.length; + PersistenceManager[] result = new PersistenceManager[numberOfExceptions]; + for (int i = 0; i < numberOfExceptions; ++i) { + JDOException exc = (JDOException)nesteds[i]; + Object failedObject = exc.getFailedObject(); + if (exc.getFailedObject() instanceof PersistenceManager) { + result[i] = (PersistenceManager)failedObject; + } else { + throw new JDOFatalException(assertionFailure, + "Unexpected failed object of type: " + + failedObject.getClass().getName()); + } + } + return result; + } + + /** + * This method load Properties from a given file. + * @param fileName the name of the properties file + * @return a Properties instance with the loaded properties + */ + protected Properties loadProperties(String fileName) { + if (fileName == null) { + fileName = System.getProperty("user.home") + "/.jdo/PMFProperties.properties"; + } + Properties props = new Properties(); + InputStream propStream = null; + try { + propStream = new FileInputStream(fileName); + } + catch (IOException ex) { + System.out.println("Could not open properties file \"" + fileName + "\""); + System.out.println("Please specify a system property PMFProperties " + + "with the PMF properties file name as value " + + "(defaults to {user.home}/.jdo/PMFProperties.properties)"); + System.exit(1); + } + try { + props.load(propStream); + } + catch (IOException ex) { + System.out.println("Error loading properties file \"" + fileName + "\""); + ex.printStackTrace(); + System.exit(1); + } + return props; + } + + /** + * Prints the specified msg (if debug is true), before it aborts the + * test case. + * @param assertionFailure the assertion failure + * @param msg the message text + */ + public void fail(String assertionFailure, String msg) { + if (debug) logger.debug(msg); + fail(assertionFailure + NL + msg); + } + + // Helper methods to check for supported options + + /** + * Dump the supportedOptions to the a file in the specified directory. + * @param directory the directory the options are dumped to + */ + public static void dumpSupportedOptions(String directory) { + if (supportedOptions == null) + return; + File file = new File(directory, PMF_SUPPORTED_OPTIONS_FILE_NAME); + if (file.exists()) + // PMF supported options have been dumped before => return + return; + PrintStream resultStream = null; + try { + resultStream = new PrintStream(new FileOutputStream(file)); + for (Iterator it = supportedOptions.iterator(); it.hasNext();) { + resultStream.println((String)it.next()); + } + } catch (FileNotFoundException e) { + throw new JDOFatalException( + "dumpSupportedOptions: cannot create file " + file.getName(), e); + } finally { + if (resultStream != null) + resultStream.close(); + } + } + + /** + * Prints a message (if debug is true) saying the test with the + * specified name is not executed, because the JDO implementation under + * test does not support the specified optional feature. + * @param testName the name of the test method that is skipped. + * @param optionalFeature the name of the option not supported by the + * JDO implementation under tets. + */ + protected void printUnsupportedOptionalFeatureNotTested( + String testName, String optionalFeature) { + if (debug) { + logger.debug( + "Test " + testName + + " was not run, because optional feature " + optionalFeature + + " is not supported by the JDO implementation under test"); + } + } + + /** + * Reports whether TransientTransactional is supported. + * @return true if TransientTransactional is supported. + */ + public boolean isTransientTransactionalSupported() { + return supportedOptions.contains( + "javax.jdo.option.TransientTransactional"); + } + + /** + * Reports whether NontransactionalRead is supported. + * @return true if NontransactionalRead is supported. + */ + public boolean isNontransactionalReadSupported(){ + return supportedOptions.contains( + "javax.jdo.option.NontransactionalRead"); + } + + /** + * Reports whether NontransactionalWrite is supported. + * @return true if NontransactionalWrite is supported. + */ + public boolean isNontransactionalWriteSupported() { + return supportedOptions.contains( + "javax.jdo.option.NontransactionalWrite"); + } + + /** + * Reports whether RetainValues is supported. + * @return true if RetainValues is supported. + */ + public boolean isRetainValuesSupported() { + return supportedOptions.contains( + "javax.jdo.option.RetainValues"); + } + + /** + * Reports whether Optimistic is supported. + * @return true if Optimistic is supported. + */ + public boolean isOptimisticSupported() { + return supportedOptions.contains( + "javax.jdo.option.Optimistic"); + } + + /** + * Reports whether Application Identity is supported. + * @return true if Application Identity is supported. + */ + public boolean isApplicationIdentitySupported() { + return supportedOptions.contains( + "javax.jdo.option.ApplicationIdentity"); + } + + /** + * Reports whether Datastore Identity is supported. + * @return true if Datastore Identity is supported. + */ + public boolean isDatastoreIdentitySupported() { + return supportedOptions.contains( + "javax.jdo.option.DatastoreIdentity"); + } + + /** + * Reports whether Non-Durable Identity is supported. + * @return true if Non-Durable Identity is supported. + */ + public boolean isNonDurableIdentitySupported() { + return supportedOptions.contains( + "javax.jdo.option.NonDurableIdentity"); + } + + /** + * Reports whether an ArrayList collection is supported. + * @return true if an ArrayList collection is supported. + */ + public boolean isArrayListSupported() { + return supportedOptions.contains( + "javax.jdo.option.ArrayList"); + } + + /** + * Reports whether a HashMap collection is supported. + * @return true if a HashMap collection is supported. + */ + public boolean isHashMapSupported() { + return supportedOptions.contains( + "javax.jdo.option.HashMap"); + } + + /** + * Reports whether a Hashtable collection is supported. + * @return true if a Hashtable collection is supported. + */ + public boolean isHashtableSupported() { + return supportedOptions.contains( + "javax.jdo.option.Hashtable"); + } + + /** + * Reports whether a LinkedList collection is supported. + * @return true if a LinkedList collection is supported. + */ + public boolean isLinkedListSupported() { + return supportedOptions.contains( + "javax.jdo.option.LinkedList"); + } + + /** + * Reports whether a TreeMap collection is supported. + * @return true if a TreeMap collection is supported. + */ + public boolean isTreeMapSupported() { + return supportedOptions.contains( + "javax.jdo.option.TreeMap"); + } + + /** + * Reports whether a TreeSet collection is supported. + * @return true if a TreeSet collection is supported. + */ + public boolean isTreeSetSupported() { + return supportedOptions.contains( + "javax.jdo.option.TreeSet"); + } + + /** + * Reports whether a Vector collection is supported. + * @return true if a Vector collection is supported. + */ + public boolean isVectorSupported() { + return supportedOptions.contains( + "javax.jdo.option.Vector"); + } + + /** + * Reports whether a Map collection is supported. + * @return true if a Map collection is supported. + */ + public boolean isMapSupported() { + return supportedOptions.contains( + "javax.jdo.option.Map"); + } + + /** + * Reports whether a List collection is supported. + * @return true if a List collection is supported. + */ + public boolean isListSupported() { + return supportedOptions.contains( + "javax.jdo.option.List"); + } + + /** + * Reports whether arrays are supported. + * @return true if arrays are supported. + */ + public boolean isArraySupported() { + return supportedOptions.contains( + "javax.jdo.option.Array"); + } + + /** + * Reports whether a null collection is supported. + * @return true if a null collection is supported. + */ + public boolean isNullCollectionSupported() { + return supportedOptions.contains( + "javax.jdo.option.NullCollection"); + } + + /** + * Reports whether Changing Application Identity is supported. + * @return true if Changing Application Identity is supported. + */ + public boolean isChangeApplicationIdentitySupported() { + return supportedOptions.contains( + "javax.jdo.option.ChangeApplicationIdentity"); + } + + /** + * Reports whether Binary Compatibility is supported. + * @return true if Binary Compatibility is supported. + */ + public boolean isBinaryCompatibilitySupported() { + return supportedOptions.contains( + "javax.jdo.option.BinaryCompatibility"); + } + + /** + * Reports whether UnconstrainedVariables is supported. + * @return true if UnconstrainedVariables is supported. + */ + public boolean isUnconstrainedVariablesSupported() { + return supportedOptions.contains( + "javax.jdo.query.JDOQL.UnconstraintedQueryVariables"); + } + + /** + * Reports whether BitwiseOperations is supported. + * @return true if BitwiseOperations is supported. + */ + public boolean isBitwiseOperationsSupported() { + return supportedOptions.contains( + "javax.jdo.query.JDOQL.bitwiseOperations"); + } + + /** + * Reports whether SQL queries are supported. + * @return true if SQL queries are supported. + */ + public boolean isSQLSupported() { + return supportedOptions.contains( + "javax.jdo.query.SQL"); + } + + /** + * Reports whether getting the DataStoreConnection is supported. + * @return true if getting the DataStoreConnection is supported. + */ + public boolean isDataStoreConnectionSupported() { + return supportedOptions.contains( + "javax.jdo.option.GetDataStoreConnection"); + } + + /** + * Reports whether canceling a running query is supported. + * @return true if canceling a running query is supported. + */ + public boolean isQueryCancelSupported() { + return supportedOptions.contains( + "javax.jdo.option.QueryCancel"); + } + + /** + * Reports whether setting a Datastore timout is supported. + * @return true if setting a Datastore timout is supported. + */ + public boolean isDatastoreTimeoutSupported() { + return supportedOptions.contains( + Constants.OPTION_DATASTORE_TIMEOUT); + } + + /** + * Reports whether a feature is supported + * @param option the option + * @return true if the specified option is supported + */ + public boolean isSupported(String option) { + return supportedOptions.contains(option); + } + + /** + * Determine if a class is loadable in the current environment. + * @param className the name of the class + * @return true if the class is loadable in the current environment. + */ + public static boolean isClassLoadable(String className) { + try { + Class.forName(className); + return true; + } catch (ClassNotFoundException ex) { + return false; + } + } + + /** + * Determine if the environment is 1.4 version of JRE or better. + * @return true if 1.4 version of JRE or better. + */ + public static boolean isJRE14orBetter() { + return isClassLoadable("java.util.Currency"); + } + + /** + * This utility method returns a String that indicates the + * current state of an instance. + * @param o The object. + * @return The current state of the instance, by using the + * JDOHelper state interrogation methods. + */ + public static String getStateOfInstance(Object o) { + boolean existingEntries = false; + StringBuffer buff = new StringBuffer("{"); + if( JDOHelper.isPersistent(o) ){ + buff.append("persistent"); + existingEntries = true; + } + if( JDOHelper.isTransactional(o) ){ + if( existingEntries ) buff.append(", "); + buff.append("transactional"); + existingEntries = true; } - this.pm.currentTransaction().commit(); - } finally { - this.tearDownInstances.clear(); - cleanupPM(); - } - } - } - - /** - * Deletes and removes tear down classes. If there are no tear down classes, the this method is a - * noop. Otherwise, tear down classes are deleted exactly in the order they have been added. Tear - * down classes are deleted in a separate transaction. Deleting a tear down class means to delete - * the extent. - */ - protected void deleteTearDownClasses() { - if (this.tearDownClasses.size() > 0) { - getPM(); - try { - this.pm.currentTransaction().begin(); - for (Iterator i = this.tearDownClasses.iterator(); i.hasNext(); ) { - this.pm.deletePersistentAll(getAllObjects(this.pm, (Class) i.next())); + if( JDOHelper.isDirty(o) ){ + if( existingEntries ) buff.append(", "); + buff.append("dirty"); + existingEntries = true; } - this.pm.currentTransaction().commit(); - } finally { - this.tearDownClasses.clear(); - cleanupPM(); - } - } - } - - /** - * Returns a collection of persistence instances of the specified class. - * - * @param pm the PersistenceManager - * @param pcClass the class object of the PersistenceCapabale class - * @return a Collection of persistence objects - */ - protected Collection getAllObjects(PersistenceManager pm, Class pcClass) { - Collection col = new Vector(); - Query query = pm.newQuery(); - query.setClass(pcClass); - Extent candidates = null; - try { - candidates = pm.getExtent(pcClass, false); - } catch (JDOException ex) { - if (debug) logger.debug("Exception thrown for getExtent of class " + pcClass.getName()); - return col; - } - query.setCandidates(candidates); - Object result = query.execute(); - return (Collection) result; - } - - /** - * Get the PersistenceManagerFactory instance for the implementation under test. - * - * @return field pmf if it is not null, else sets field pmf - * to a new instance and returns that instance. - */ - protected PersistenceManagerFactory getPMF() { - if (pmf == null) { - PMFPropertiesObject = loadProperties(PMFProperties); // will exit here if no properties - pmf = JDOHelper.getPersistenceManagerFactory(PMFPropertiesObject); - if (supportedOptions == null) { - supportedOptions = pmf.supportedOptions(); - } - } - return pmf; - } - - protected Class getPMFClass() { - if (pmf != null) { - return pmf.getClass(); - } - - PMFPropertiesObject = loadProperties(PMFProperties); - String name = PMFPropertiesObject.getProperty(PMF_CLASS_PROP); - try { - return Class.forName(name); - } catch (ClassNotFoundException ex) { - throw new JDOException("Cannot find PMF class '" + name + "'.", ex); - } - } - - /** - * Get the PersistenceManagerFactory instance for the implementation under test. This - * method does NOT use the JDOHelper method to retrieve the PMF, instead it creates an instance of - * the class specified as javax.jdo.PersistenceManagerFactoryClass property. The returned PMF is - * not configured. - * - * @return field pmf if it is not null, else sets field pmf - * to a new instance and returns that instance. - */ - protected PersistenceManagerFactory getUnconfiguredPMF() { - if (pmf == null) { - String name = null; - try { - Class pmfClass = getPMFClass(); - name = pmfClass.getName(); - pmf = (PersistenceManagerFactory) pmfClass.newInstance(); - if (supportedOptions == null) { - supportedOptions = pmf.supportedOptions(); + if( JDOHelper.isNew(o) ){ + if( existingEntries ) buff.append(", "); + buff.append("new"); + existingEntries = true; } - } catch (InstantiationException ex) { - throw new JDOException("Cannot instantiate PMF class '" + name + "'.", ex); - } catch (IllegalAccessException ex) { - throw new JDOException( - "Cannot access PMF class '" + name + "' or its no-arg constructor.", ex); - } - } - return pmf; - } - - /** - * Get the PersistenceManager instance for the implementation under test. - * - * @return the PersistenceManager - */ - protected PersistenceManager getPM() { - if (pm == null) { - pm = getPMF().getPersistenceManager(); - } - return pm; - } - - /** - * This method cleans up the environment: closes the PersistenceManager. This should - * avoid leaving multiple PersistenceManager instances around, in case the - * PersistenceManagerFactory performs PersistenceManager pooling. - */ - protected void cleanupPM() { - cleanupPM(pm); - pm = null; - } - - /** - * This method cleans up the specified PersistenceManager. If the pm still has an - * open transaction, it will be rolled back, before closing the pm. - * - * @param pm the PersistenceManager - */ - protected static void cleanupPM(PersistenceManager pm) { - if ((pm != null) && !pm.isClosed()) { - if (pm.currentTransaction().isActive()) { - pm.currentTransaction().rollback(); - } - pm.close(); - } - } - - /** Closes the pmf stored in this instance. */ - public static void closePMF() { - JDOException failure = null; - while (pmf != null) { - try { - if (!pmf.isClosed()) { - closePMF(pmf); + if( JDOHelper.isDeleted(o) ){ + if( existingEntries ) buff.append(", "); + buff.append("deleted"); } - pmf = null; - } catch (JDOException ex) { - // store failure of first call pmf.close - if (failure == null) failure = ex; - PersistenceManager[] pms = getFailedPersistenceManagers("closePMF", ex); - for (int i = 0; i < pms.length; i++) { - cleanupPM(pms[i]); + if( JDOHelper.isDetached(o) ){ + if( existingEntries ) buff.append(", "); + buff.append("detached"); } - } catch (RuntimeException ex) { - pmf = null; - ex.printStackTrace(System.out); - throw ex; - } - } - - // rethrow JDOException thrown by pmf.close - if (failure != null) throw failure; - } - - /** - * Closes the pmf passed as a parameter. This must be done in a doPrivileged block. - * - * @param PMF the PersistenceManagerFactory - */ - public static void closePMF(final PersistenceManagerFactory PMF) { - if (PMF != null) { - if (!PMF.isClosed()) { - doPrivileged( - new PrivilegedAction() { - public Object run() { - PMF.close(); - return null; - } - }); - } - } - } - - @SuppressWarnings("unchecked") - private static T doPrivileged(PrivilegedAction privilegedAction) { - try { - return (T) LegacyJava.doPrivilegedAction.invoke(null, privilegedAction); - } catch (IllegalAccessException | InvocationTargetException e) { - if (e.getCause() instanceof RuntimeException) { - throw (RuntimeException) e.getCause(); - } - throw new JDOFatalInternalException(e.getMessage()); - } - } - - /** - * Returns failed PersistenceManagers - * - * @param assertionFailure failure - * @param ex exception - * @return failed PersistenceManagers - */ - protected static PersistenceManager[] getFailedPersistenceManagers( - String assertionFailure, JDOException ex) { - Throwable[] nesteds = ex.getNestedExceptions(); - int numberOfExceptions = nesteds == null ? 0 : nesteds.length; - PersistenceManager[] result = new PersistenceManager[numberOfExceptions]; - for (int i = 0; i < numberOfExceptions; ++i) { - JDOException exc = (JDOException) nesteds[i]; - Object failedObject = exc.getFailedObject(); - if (exc.getFailedObject() instanceof PersistenceManager) { - result[i] = (PersistenceManager) failedObject; - } else { - throw new JDOFatalException( - assertionFailure, - "Unexpected failed object of type: " + failedObject.getClass().getName()); - } - } - return result; - } - - /** - * This method load Properties from a given file. - * - * @param fileName the name of the properties file - * @return a Properties instance with the loaded properties - */ - protected Properties loadProperties(String fileName) { - if (fileName == null) { - fileName = System.getProperty("user.home") + "/.jdo/PMFProperties.properties"; - } - Properties props = new Properties(); - InputStream propStream = null; - try { - propStream = new FileInputStream(fileName); - } catch (IOException ex) { - System.out.println("Could not open properties file \"" + fileName + "\""); - System.out.println( - "Please specify a system property PMFProperties " - + "with the PMF properties file name as value " - + "(defaults to {user.home}/.jdo/PMFProperties.properties)"); - System.exit(1); - } - try { - props.load(propStream); - } catch (IOException ex) { - System.out.println("Error loading properties file \"" + fileName + "\""); - ex.printStackTrace(); - System.exit(1); - } - return props; - } - - /** - * Prints the specified msg (if debug is true), before it aborts the test case. - * - * @param assertionFailure the assertion failure - * @param msg the message text - */ - public void fail(String assertionFailure, String msg) { - if (debug) logger.debug(msg); - fail(assertionFailure + NL + msg); - } - - // Helper methods to check for supported options - - /** - * Dump the supportedOptions to the a file in the specified directory. - * - * @param directory the directory the options are dumped to - */ - public static void dumpSupportedOptions(String directory) { - if (supportedOptions == null) return; - File file = new File(directory, PMF_SUPPORTED_OPTIONS_FILE_NAME); - if (file.exists()) - // PMF supported options have been dumped before => return - return; - PrintStream resultStream = null; - try { - resultStream = new PrintStream(new FileOutputStream(file)); - for (Iterator it = supportedOptions.iterator(); it.hasNext(); ) { - resultStream.println((String) it.next()); - } - } catch (FileNotFoundException e) { - throw new JDOFatalException("dumpSupportedOptions: cannot create file " + file.getName(), e); - } finally { - if (resultStream != null) resultStream.close(); - } - } - - /** - * Prints a message (if debug is true) saying the test with the specified name is not executed, - * because the JDO implementation under test does not support the specified optional feature. - * - * @param testName the name of the test method that is skipped. - * @param optionalFeature the name of the option not supported by the JDO implementation under - * tets. - */ - protected void printUnsupportedOptionalFeatureNotTested(String testName, String optionalFeature) { - if (debug) { - logger.debug( - "Test " - + testName - + " was not run, because optional feature " - + optionalFeature - + " is not supported by the JDO implementation under test"); - } - } - - /** - * Reports whether TransientTransactional is supported. - * - * @return true if TransientTransactional is supported. - */ - public boolean isTransientTransactionalSupported() { - return supportedOptions.contains("javax.jdo.option.TransientTransactional"); - } - - /** - * Reports whether NontransactionalRead is supported. - * - * @return true if NontransactionalRead is supported. - */ - public boolean isNontransactionalReadSupported() { - return supportedOptions.contains("javax.jdo.option.NontransactionalRead"); - } - - /** - * Reports whether NontransactionalWrite is supported. - * - * @return true if NontransactionalWrite is supported. - */ - public boolean isNontransactionalWriteSupported() { - return supportedOptions.contains("javax.jdo.option.NontransactionalWrite"); - } - - /** - * Reports whether RetainValues is supported. - * - * @return true if RetainValues is supported. - */ - public boolean isRetainValuesSupported() { - return supportedOptions.contains("javax.jdo.option.RetainValues"); - } - - /** - * Reports whether Optimistic is supported. - * - * @return true if Optimistic is supported. - */ - public boolean isOptimisticSupported() { - return supportedOptions.contains("javax.jdo.option.Optimistic"); - } - - /** - * Reports whether Application Identity is supported. - * - * @return true if Application Identity is supported. - */ - public boolean isApplicationIdentitySupported() { - return supportedOptions.contains("javax.jdo.option.ApplicationIdentity"); - } - - /** - * Reports whether Datastore Identity is supported. - * - * @return true if Datastore Identity is supported. - */ - public boolean isDatastoreIdentitySupported() { - return supportedOptions.contains("javax.jdo.option.DatastoreIdentity"); - } - - /** - * Reports whether Non-Durable Identity is supported. - * - * @return true if Non-Durable Identity is supported. - */ - public boolean isNonDurableIdentitySupported() { - return supportedOptions.contains("javax.jdo.option.NonDurableIdentity"); - } - - /** - * Reports whether an ArrayList collection is supported. - * - * @return true if an ArrayList collection is supported. - */ - public boolean isArrayListSupported() { - return supportedOptions.contains("javax.jdo.option.ArrayList"); - } - - /** - * Reports whether a HashMap collection is supported. - * - * @return true if a HashMap collection is supported. - */ - public boolean isHashMapSupported() { - return supportedOptions.contains("javax.jdo.option.HashMap"); - } - - /** - * Reports whether a Hashtable collection is supported. - * - * @return true if a Hashtable collection is supported. - */ - public boolean isHashtableSupported() { - return supportedOptions.contains("javax.jdo.option.Hashtable"); - } - - /** - * Reports whether a LinkedList collection is supported. - * - * @return true if a LinkedList collection is supported. - */ - public boolean isLinkedListSupported() { - return supportedOptions.contains("javax.jdo.option.LinkedList"); - } - - /** - * Reports whether a TreeMap collection is supported. - * - * @return true if a TreeMap collection is supported. - */ - public boolean isTreeMapSupported() { - return supportedOptions.contains("javax.jdo.option.TreeMap"); - } - - /** - * Reports whether a TreeSet collection is supported. - * - * @return true if a TreeSet collection is supported. - */ - public boolean isTreeSetSupported() { - return supportedOptions.contains("javax.jdo.option.TreeSet"); - } - - /** - * Reports whether a Vector collection is supported. - * - * @return true if a Vector collection is supported. - */ - public boolean isVectorSupported() { - return supportedOptions.contains("javax.jdo.option.Vector"); - } - - /** - * Reports whether a Map collection is supported. - * - * @return true if a Map collection is supported. - */ - public boolean isMapSupported() { - return supportedOptions.contains("javax.jdo.option.Map"); - } - - /** - * Reports whether a List collection is supported. - * - * @return true if a List collection is supported. - */ - public boolean isListSupported() { - return supportedOptions.contains("javax.jdo.option.List"); - } - - /** - * Reports whether arrays are supported. - * - * @return true if arrays are supported. - */ - public boolean isArraySupported() { - return supportedOptions.contains("javax.jdo.option.Array"); - } - - /** - * Reports whether a null collection is supported. - * - * @return true if a null collection is supported. - */ - public boolean isNullCollectionSupported() { - return supportedOptions.contains("javax.jdo.option.NullCollection"); - } - - /** - * Reports whether Changing Application Identity is supported. - * - * @return true if Changing Application Identity is supported. - */ - public boolean isChangeApplicationIdentitySupported() { - return supportedOptions.contains("javax.jdo.option.ChangeApplicationIdentity"); - } - - /** - * Reports whether Binary Compatibility is supported. - * - * @return true if Binary Compatibility is supported. - */ - public boolean isBinaryCompatibilitySupported() { - return supportedOptions.contains("javax.jdo.option.BinaryCompatibility"); - } - - /** - * Reports whether UnconstrainedVariables is supported. - * - * @return true if UnconstrainedVariables is supported. - */ - public boolean isUnconstrainedVariablesSupported() { - return supportedOptions.contains("javax.jdo.query.JDOQL.UnconstraintedQueryVariables"); - } - - /** - * Reports whether BitwiseOperations is supported. - * - * @return true if BitwiseOperations is supported. - */ - public boolean isBitwiseOperationsSupported() { - return supportedOptions.contains("javax.jdo.query.JDOQL.bitwiseOperations"); - } - - /** - * Reports whether SQL queries are supported. - * - * @return true if SQL queries are supported. - */ - public boolean isSQLSupported() { - return supportedOptions.contains("javax.jdo.query.SQL"); - } - - /** - * Reports whether getting the DataStoreConnection is supported. - * - * @return true if getting the DataStoreConnection is supported. - */ - public boolean isDataStoreConnectionSupported() { - return supportedOptions.contains("javax.jdo.option.GetDataStoreConnection"); - } - - /** - * Reports whether canceling a running query is supported. - * - * @return true if canceling a running query is supported. - */ - public boolean isQueryCancelSupported() { - return supportedOptions.contains("javax.jdo.option.QueryCancel"); - } - - /** - * Reports whether setting a Datastore timout is supported. - * - * @return true if setting a Datastore timout is supported. - */ - public boolean isDatastoreTimeoutSupported() { - return supportedOptions.contains(Constants.OPTION_DATASTORE_TIMEOUT); - } - - /** - * Reports whether a feature is supported - * - * @param option the option - * @return true if the specified option is supported - */ - public boolean isSupported(String option) { - return supportedOptions.contains(option); - } - - /** - * Determine if a class is loadable in the current environment. - * - * @param className the name of the class - * @return true if the class is loadable in the current environment. - */ - public static boolean isClassLoadable(String className) { - try { - Class.forName(className); - return true; - } catch (ClassNotFoundException ex) { - return false; - } - } - - /** - * Determine if the environment is 1.4 version of JRE or better. - * - * @return true if 1.4 version of JRE or better. - */ - public static boolean isJRE14orBetter() { - return isClassLoadable("java.util.Currency"); - } - - /** - * This utility method returns a String that indicates the current state of an - * instance. - * - * @param o The object. - * @return The current state of the instance, by using the JDOHelper state - * interrogation methods. - */ - public static String getStateOfInstance(Object o) { - boolean existingEntries = false; - StringBuffer buff = new StringBuffer("{"); - if (JDOHelper.isPersistent(o)) { - buff.append("persistent"); - existingEntries = true; - } - if (JDOHelper.isTransactional(o)) { - if (existingEntries) buff.append(", "); - buff.append("transactional"); - existingEntries = true; - } - if (JDOHelper.isDirty(o)) { - if (existingEntries) buff.append(", "); - buff.append("dirty"); - existingEntries = true; - } - if (JDOHelper.isNew(o)) { - if (existingEntries) buff.append(", "); - buff.append("new"); - existingEntries = true; - } - if (JDOHelper.isDeleted(o)) { - if (existingEntries) buff.append(", "); - buff.append("deleted"); - } - if (JDOHelper.isDetached(o)) { - if (existingEntries) buff.append(", "); - buff.append("detached"); - } - buff.append("}"); - return buff.toString(); - } - - /** - * This method will return the current lifecycle state of an instance. - * - * @param o the object - * @return the current lifecycle state - */ - public static int currentState(Object o) { - boolean[] status = new boolean[NUM_STATUSES]; - status[IS_PERSISTENT] = JDOHelper.isPersistent(o); - status[IS_TRANSACTIONAL] = JDOHelper.isTransactional(o); - status[IS_DIRTY] = JDOHelper.isDirty(o); - status[IS_NEW] = JDOHelper.isNew(o); - status[IS_DELETED] = JDOHelper.isDeleted(o); - status[IS_DETACHED] = JDOHelper.isDetached(o); - int i, j; + buff.append("}"); + return buff.toString(); + } + + /** + * This method will return the current lifecycle state of an instance. + * @param o the object + * @return the current lifecycle state + */ + public static int currentState(Object o) { + boolean[] status = new boolean[NUM_STATUSES]; + status[IS_PERSISTENT] = JDOHelper.isPersistent(o); + status[IS_TRANSACTIONAL] = JDOHelper.isTransactional(o); + status[IS_DIRTY] = JDOHelper.isDirty(o); + status[IS_NEW] = JDOHelper.isNew(o); + status[IS_DELETED] = JDOHelper.isDeleted(o); + status[IS_DETACHED] = JDOHelper.isDetached(o); + int i, j; outerloop: - for (i = 0; i < NUM_STATES; ++i) { - for (j = 0; j < NUM_STATUSES; ++j) { - if (status[j] != state_statuses[i][j]) continue outerloop; - } - return i; - } - return NUM_STATES; - } - - /** - * Tests if a found state matches an expected state. - * - * @param found_state the found state - * @param expected_state the expected state - * @return true if the found state matches the expected state - */ - public static boolean compareStates(int found_state, int expected_state) { - // status interrogation gives same values for PERSISTENT_NONTRANSACTIONAL and HOLLOW - return (expected_state < 0 - || found_state == expected_state - || (found_state == HOLLOW && expected_state == PERSISTENT_NONTRANSACTIONAL) - || (found_state == PERSISTENT_NONTRANSACTIONAL && expected_state == HOLLOW)); - } - - /** - * This method mangles an object by changing all its non-static, non-final fields. It returns true - * if the object was mangled, and false if there are no fields to mangle. - * - * @param oid the oid of the object - * @return a mangled object - * @throws Exception exception - */ - protected boolean mangleObject(Object oid) throws Exception { - Field[] fields = getModifiableFields(oid); - if (fields.length == 0) return false; - for (int i = 0; i < fields.length; ++i) { - Field field = fields[i]; - Class fieldType = field.getType(); - if (fieldType == long.class) { - field.setLong(oid, 10000L + field.getLong(oid)); - } else if (fieldType == int.class) { - field.setInt(oid, 10000 + field.getInt(oid)); - } else if (fieldType == short.class) { - field.setShort(oid, (short) (10000 + field.getShort(oid))); - } else if (fieldType == byte.class) { - field.setByte(oid, (byte) (100 + field.getByte(oid))); - } else if (fieldType == char.class) { - field.setChar(oid, (char) (10 + field.getChar(oid))); - } else if (fieldType == String.class) { - field.set(oid, "This is certainly a challenge" + (String) field.get(oid)); - } else if (fieldType == Integer.class) { - field.set(oid, Integer.valueOf(10000 + ((Integer) field.get(oid)).intValue())); - } else if (fieldType == Long.class) { - field.set(oid, Long.valueOf(10000L + ((Long) field.get(oid)).longValue())); - } else if (fieldType == Short.class) { - field.set(oid, Short.valueOf((short) (10000 + ((Short) field.get(oid)).shortValue()))); - } else if (fieldType == Byte.class) { - field.set(oid, Byte.valueOf((byte) (100 + ((Byte) field.get(oid)).byteValue()))); - } else if (fieldType == Character.class) { - field.set(oid, Character.valueOf((char) (10 + ((Character) (field.get(oid))).charValue()))); - } - } - return true; - } - - /** - * Returns modifiable Fields of the class of the parameter. Fields are considered modifiable if - * they are not static or final. This method requires several permissions in order to run with a - * SecurityManager, hence the doPrivileged block: - * - *

      - *
    • ReflectPermission("suppressAccessChecks") - *
    • RuntimePermission("accessDeclaredMembers") - *
    - * - * @param obj the object - * @return an array of fields - */ - protected Field[] getModifiableFields(final Object obj) { - return (Field[]) - doPrivileged( - new PrivilegedAction() { - public Object run() { - Class cls = obj.getClass(); - List result = new ArrayList(); - Field[] fields = cls.getFields(); - for (int i = 0; i < fields.length; ++i) { - Field field = fields[i]; - int modifiers = field.getModifiers(); - if (Modifier.isFinal(modifiers) || Modifier.isStatic(modifiers)) continue; - field.setAccessible(true); - result.add(field); + for( i = 0; i < NUM_STATES; ++i ){ + for( j = 0; j < NUM_STATUSES; ++j ){ + if( status[j] != state_statuses[i][j] ) + continue outerloop; + } + return i; + } + return NUM_STATES; + } + + /** + * Tests if a found state matches an expected state. + * @param found_state the found state + * @param expected_state the expected state + * @return true if the found state matches the expected state + */ + public static boolean compareStates(int found_state, int expected_state) { + // status interrogation gives same values for PERSISTENT_NONTRANSACTIONAL and HOLLOW + return (expected_state < 0 + || found_state == expected_state + || (found_state == HOLLOW && expected_state == PERSISTENT_NONTRANSACTIONAL) + || (found_state == PERSISTENT_NONTRANSACTIONAL && expected_state == HOLLOW)); + } + + /** This method mangles an object by changing all its non-static, + * non-final fields. + * It returns true if the object was mangled, and false if there + * are no fields to mangle. + * @param oid the oid of the object + * @return a mangled object + * @throws Exception exception + */ + protected boolean mangleObject (Object oid) + throws Exception { + Field[] fields = getModifiableFields(oid); + if (fields.length == 0) return false; + for (int i = 0; i < fields.length; ++i) { + Field field = fields[i]; + Class fieldType = field.getType(); + if (fieldType == long.class) { + field.setLong(oid, 10000L + field.getLong(oid)); + } else if (fieldType == int.class) { + field.setInt(oid, 10000 + field.getInt(oid)); + } else if (fieldType == short.class) { + field.setShort(oid, (short)(10000 + field.getShort(oid))); + } else if (fieldType == byte.class) { + field.setByte(oid, (byte)(100 + field.getByte(oid))); + } else if (fieldType == char.class) { + field.setChar(oid, (char)(10 + field.getChar(oid))); + } else if (fieldType == String.class) { + field.set(oid, "This is certainly a challenge" + (String)field.get(oid)); + } else if (fieldType == Integer.class) { + field.set(oid, Integer.valueOf(10000 + ((Integer)field.get(oid)).intValue())); + } else if (fieldType == Long.class) { + field.set(oid, Long.valueOf(10000L + ((Long)field.get(oid)).longValue())); + } else if (fieldType == Short.class) { + field.set(oid, Short.valueOf((short)(10000 + ((Short)field.get(oid)).shortValue()))); + } else if (fieldType == Byte.class) { + field.set(oid, Byte.valueOf((byte)(100 + ((Byte)field.get(oid)).byteValue()))); + } else if (fieldType == Character.class) { + field.set(oid, Character.valueOf((char)(10 + ((Character)(field.get(oid))).charValue()))); + } + } + return true; + } + + /** + Returns modifiable Fields of the class of the parameter. + * Fields are considered modifiable if they are not static or final. + * This method requires several permissions in order to run with + * a SecurityManager, hence the doPrivileged block: + *
      + *
    • ReflectPermission("suppressAccessChecks")
    • + *
    • RuntimePermission("accessDeclaredMembers")
    • + *
    + * @param obj the object + * @return an array of fields + */ + protected Field[] getModifiableFields(final Object obj) { + return (Field[])doPrivileged( + new PrivilegedAction () { + public Object run () { + Class cls = obj.getClass(); + List result = new ArrayList(); + Field[] fields = cls.getFields(); + for (int i = 0; i < fields.length; ++i) { + Field field = fields[i]; + int modifiers = field.getModifiers(); + if (Modifier.isFinal(modifiers) || + Modifier.isStatic(modifiers)) + continue; + field.setAccessible(true); + result.add(field); + } + return result.toArray(new Field[result.size()]); } - return result.toArray(new Field[result.size()]); - } - }); - } - - /** - * Returns true if the current test runs with application identity. This means the - * system property jdo.tck.identitytype has the value applicationidentity. - * - * @return true if current test runs with application identity; false - * otherwise: - */ - public boolean runsWithApplicationIdentity() { - return APPLICATION_IDENTITY.equals(IDENTITYTYPE); - } - - /** - * Prints a message (if debug is true) saying the test with the specified name is not executed, - * because the JDO implementation under test is run for an inapplicable identity type. - * - * @param testName the name of the test method that is skipped. - * @param requiredIdentityType the name of the required identity type. - */ - protected void printNonApplicableIdentityType(String testName, String requiredIdentityType) { - if (debug) { - logger.debug( - "Test " - + testName - + " was not run, because it is only applicable for identity type " - + requiredIdentityType - + ". The identity type of the current configuration is " - + IDENTITYTYPE); - } - } - - /** - * Returns the value of the PMF property given by argument key. - * - * @param key the key - * @return the value - */ - protected String getPMFProperty(String key) { - return PMFPropertiesObject.getProperty(key); - } - - /** - * Returns true if the implementation under test supports all JDO options contained - * in system property jdo.tck.requiredOptions. - * - * @return true if the implementation under test supports all JDO options contained - * in system property jdo.tck.requiredOptions - */ - protected boolean isTestToBePerformed() { - boolean isTestToBePerformed = true; - String requiredOptions = System.getProperty("jdo.tck.requiredOptions"); - // Collection supportedOptions = supportedOptions; - StringTokenizer tokenizer = new StringTokenizer(requiredOptions, " ,;\n\r\t"); - while (tokenizer.hasMoreTokens()) { - String requiredOption = tokenizer.nextToken(); - logger.debug("Required option: " + requiredOption); - if (!requiredOption.equals("") && !supportedOptions.contains(requiredOption)) { - isTestToBePerformed = false; - printUnsupportedOptionalFeatureNotTested(getClass().getName(), requiredOption); - } - } - return isTestToBePerformed; - } - - /** New line. */ - public static final String NL = System.getProperty("line.separator"); - - /** A buffer of of error messages. */ - protected static StringBuffer messages; - - /** - * Appends to error messages. - * - * @param message the message - */ - protected static synchronized void appendMessage(String message) { - if (messages == null) { - messages = new StringBuffer(NL); - } - messages.append(message); - messages.append(NL); - } - - /** - * Appends to error messages. - * - * @param test test option - * @param context context - * @param message message - */ - protected static synchronized void deferredAssertTrue( - boolean test, String context, String message) { - if (!test) { - appendMessage(context + ": " + message); - } - } - - /** - * Appends an error if the actual value does not equal the expected value. Primitive values are - * autoboxed. Null values are ok for both expected and actual. - * - * @param message the message - * @param expected the expected value - * @param actual the actual value - */ - protected void errorIfNotEqual(String message, Object expected, Object actual) { - if (expected == null) { - if (actual != null) { - appendMessage(message + " failed. expected: null; actual: " + actual); - } - } else { - if (!expected.equals(actual)) { - appendMessage(message + " failed. expected: " + expected + "; actual: " + actual); - } - } - } - - /** - * Appends an error if the actual value equals the unexpected value. Primitive values are - * autoboxed. Null values are ok for both unexpected and actual. - * - * @param message the message - * @param unexpected the unexpected value - * @param actual the actual value - */ - protected void errorIfEqual(String message, Object unexpected, Object actual) { - if (unexpected == null) { - if (actual == null) { - appendMessage(message + " failed. unexpected: null"); - } - } else { - if (unexpected.equals(actual)) { - appendMessage(message + " failed. unexpected: " + unexpected); - } - } - } - - /** - * Returns collected error messages, or null if there are none, and clears the - * buffer. - * - * @return collected error messages - */ - protected static synchronized String retrieveMessages() { - if (messages == null) { - return null; - } - final String msg = messages.toString(); - messages = null; - return msg; - } - - /** Fail the test if there are any error messages. */ - protected void failOnError() { - String errors = retrieveMessages(); - if (errors != null) { - fail(errors); - } - } - - /** - * Validate an actual isolation level against the requested level. - * - * @param requested requested level - * @param actual actual level - * @return true if the actual level is greater or equal the requsted level - */ - protected boolean validLevelSubstitution(String requested, String actual) { - int requestedLevel = ((Integer) levelValues.get(requested)).intValue(); - int actualLevel = ((Integer) levelValues.get(actual)).intValue(); - return actualLevel >= requestedLevel; - } + } + ); + } + + /** + * Returns true if the current test runs with application + * identity. This means the system property jdo.tck.identitytype has the + * value applicationidentity. + * @return true if current test runs with application + * identity; false otherwise: + */ + public boolean runsWithApplicationIdentity() { + return APPLICATION_IDENTITY.equals(IDENTITYTYPE); + } + + /** + * Prints a message (if debug is true) saying the test with the + * specified name is not executed, because the JDO implementation under + * test is run for an inapplicable identity type. + * @param testName the name of the test method that is skipped. + * @param requiredIdentityType the name of the required identity type. + */ + protected void printNonApplicableIdentityType( + String testName, String requiredIdentityType) { + if (debug) { + logger.debug( + "Test " + testName + + " was not run, because it is only applicable for identity type " + + requiredIdentityType + + ". The identity type of the current configuration is " + IDENTITYTYPE); + } + } + + /** + * Returns the value of the PMF property + * given by argument key. + * @param key the key + * @return the value + */ + protected String getPMFProperty(String key) { + return PMFPropertiesObject.getProperty(key); + } + + /** + * Returns true if the implementation under test + * supports all JDO options contained in system property + * jdo.tck.requiredOptions. + * @return true if the implementation under test + * supports all JDO options contained in system property + * jdo.tck.requiredOptions + */ + protected boolean isTestToBePerformed() { + boolean isTestToBePerformed = true; + String requiredOptions = System.getProperty("jdo.tck.requiredOptions"); +// Collection supportedOptions = supportedOptions; + StringTokenizer tokenizer = new StringTokenizer( + requiredOptions, " ,;\n\r\t"); + while (tokenizer.hasMoreTokens()) { + String requiredOption = tokenizer.nextToken(); + logger.debug("Required option: " + requiredOption); + if (!requiredOption.equals("") && + !supportedOptions.contains(requiredOption)) { + isTestToBePerformed = false; + printUnsupportedOptionalFeatureNotTested( + getClass().getName(), requiredOption); + } + } + return isTestToBePerformed; + } + + /** New line. + */ + public static final String NL = System.getProperty("line.separator"); + + /** A buffer of of error messages. + */ + protected static StringBuffer messages; + + /** + * Appends to error messages. + * @param message the message + */ + protected static synchronized void appendMessage(String message) { + if (messages == null) { + messages = new StringBuffer(NL); + } + messages.append(message); + messages.append(NL); + } + + /** + * Appends to error messages. + * @param test test option + * @param context context + * @param message message + */ + protected static synchronized void deferredAssertTrue(boolean test, + String context, String message) { + if (!test) { + appendMessage(context + ": " +message); + } + } + + /** + * Appends an error if the actual value does not equal the expected value. + * Primitive values are autoboxed. Null values are ok for both expected and actual. + * @param message the message + * @param expected the expected value + * @param actual the actual value + */ + protected void errorIfNotEqual(String message, Object expected, Object actual) { + if (expected == null) { + if (actual != null) { + appendMessage(message + " failed. expected: null; actual: " + actual); + } + } else { + if (!expected.equals(actual)) { + appendMessage(message + " failed. expected: " + expected + "; actual: " + actual); + } + } + } + + /** + * Appends an error if the actual value equals the unexpected value. + * Primitive values are autoboxed. Null values are ok for both unexpected and actual. + * @param message the message + * @param unexpected the unexpected value + * @param actual the actual value + */ + protected void errorIfEqual(String message, Object unexpected, Object actual) { + if (unexpected == null) { + if (actual == null) { + appendMessage(message + " failed. unexpected: null"); + } + } else { + if (unexpected.equals(actual)) { + appendMessage(message + " failed. unexpected: " + unexpected); + } + } + } + + /** + * Returns collected error messages, or null if there + * are none, and clears the buffer. + * @return collected error messages + */ + protected static synchronized String retrieveMessages() { + if (messages == null) { + return null; + } + final String msg = messages.toString(); + messages = null; + return msg; + } + + /** + * Fail the test if there are any error messages. + */ + protected void failOnError() { + String errors = retrieveMessages(); + if (errors != null) { + fail (errors); + } + } + + /** + * Validate an actual isolation level against the requested level. + * @param requested requested level + * @param actual actual level + * @return true if the actual level is greater or equal the requsted level + */ + protected boolean validLevelSubstitution(String requested, String actual) { + int requestedLevel = ((Integer)levelValues.get(requested)).intValue(); + int actualLevel = ((Integer)levelValues.get(actual)).intValue(); + return actualLevel >= requestedLevel; + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/SignatureTest.java b/tck/src/main/java/org/apache/jdo/tck/api/SignatureTest.java index 0b366318d..4ce5ae12f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/SignatureTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/SignatureTest.java @@ -5,107 +5,116 @@ * 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 + * + * 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.jdo.tck.api; +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.util.signature.SignatureVerifier; + import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; -import java.text.ParseException; -import java.util.ArrayList; + import java.util.List; -import org.apache.jdo.tck.JDO_Test; -import org.apache.jdo.tck.util.BatchTestRunner; -import org.apache.jdo.tck.util.signature.SignatureVerifier; +import java.util.ArrayList; + +import java.text.ParseException; /** - * Title: SignatureTest
    - * Keywords: API
    - * Assertion IDs:
    - * Assertion Description: This test verifies that a set of JDO API classes and interfaces is - * compliant with a "signature" description, which has been verified against the JDO specification - * document. Any discrepancies between the feature declarations in the API classes and the signature - * descriptor are reported, including any public non-standard features found only in the API - * classes. + *Title: SignatureTest + *
    + *Keywords: API + *
    + *Assertion IDs: + *
    + *Assertion Description: + * This test verifies that a set of JDO API classes and interfaces + * is compliant with a "signature" description, which has been verified + * against the JDO specification document. Any discrepancies between + * the feature declarations in the API classes and the signature descriptor + * are reported, including any public non-standard features found only in + * the API classes. */ public class SignatureTest extends JDO_Test { - private static String newLine = System.getProperty("line.separator"); - - /** */ - private static final String ASSERTION_FAILED = "API Signature Test failed: "; + private static String newLine = System.getProperty("line.separator"); - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SignatureTest.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() {} - - /** Runs the API Signature Test. */ - public void testSignatures() { - // create a SignatureVerifier instance - final StringWriter sw = new StringWriter(); - final PrintWriter pw = new PrintWriter(sw); // auto-flushes on println - final boolean quiet = false; - final boolean verbose = debug; - final SignatureVerifier verifier = new SignatureVerifier(pw, quiet, verbose); - - // run the signature test - try { - // fetch name of signature file - final String signatureFileName = System.getProperty("jdo.tck.signaturefile"); - if (signatureFileName == null) { - fail(ASSERTION_FAILED, "No system property defined: jdo.tck.signaturefile"); - return; - } + /** */ + private static final String ASSERTION_FAILED = + "API Signature Test failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SignatureTest.class); + } - // run the test - final List signatureFileNames = new ArrayList(); - signatureFileNames.add(signatureFileName); - int status = verifier.test(signatureFileNames); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + } + + /** Runs the API Signature Test. */ + public void testSignatures() { + // create a SignatureVerifier instance + final StringWriter sw = new StringWriter(); + final PrintWriter pw = new PrintWriter(sw); //auto-flushes on println + final boolean quiet = false; + final boolean verbose = debug; + final SignatureVerifier verifier + = new SignatureVerifier(pw, quiet, verbose); - // print test's output in case of problems or debugging - if (status != 0) { - fail( - ASSERTION_FAILED, - ("Found problems or signature descrepancies." - + newLine - + "Test Output: " - + newLine - + sw.toString())); - logger.debug(sw.toString()); - } + // run the signature test + try { + // fetch name of signature file + final String signatureFileName + = System.getProperty("jdo.tck.signaturefile"); + if (signatureFileName == null) { + fail(ASSERTION_FAILED, + "No system property defined: jdo.tck.signaturefile"); + return; + } - // print test's output in case of problems or debugging - if (debug) { - logger.debug(sw.toString()); - } - } catch (IOException ex) { - fail( - ASSERTION_FAILED, - ("Exception caught: " + ex + newLine + "Test Output: " + newLine + sw.toString())); - } catch (ParseException ex) { - fail( - ASSERTION_FAILED, - ("Exception caught: " + ex + newLine + "Test Output: " + newLine + sw.toString())); + // run the test + final List signatureFileNames = new ArrayList(); + signatureFileNames.add(signatureFileName); + int status = verifier.test(signatureFileNames); + + // print test's output in case of problems or debugging + if (status != 0) { + fail(ASSERTION_FAILED, + ("Found problems or signature descrepancies." + newLine + + "Test Output: " + newLine + sw.toString())); + logger.debug(sw.toString()); + } + + // print test's output in case of problems or debugging + if (debug) { + logger.debug(sw.toString()); + } + } catch (IOException ex) { + fail(ASSERTION_FAILED, + ("Exception caught: " + ex + newLine + + "Test Output: " + newLine + sw.toString())); + } catch (ParseException ex) { + fail(ASSERTION_FAILED, + ("Exception caught: " + ex + newLine + + "Test Output: " + newLine + sw.toString())); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/converter/IntAttributeConverterTest.java b/tck/src/main/java/org/apache/jdo/tck/api/converter/IntAttributeConverterTest.java index fa600828a..d14a23e80 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/converter/IntAttributeConverterTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/converter/IntAttributeConverterTest.java @@ -16,11 +16,6 @@ */ package org.apache.jdo.tck.api.converter; -import java.lang.reflect.InvocationTargetException; -import java.util.List; -import javax.jdo.JDOHelper; -import javax.jdo.Query; -import javax.jdo.Transaction; import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.converter.IPCPoint; import org.apache.jdo.tck.pc.converter.PCPoint; @@ -30,378 +25,418 @@ import org.apache.jdo.tck.util.BatchTestRunner; import org.apache.jdo.tck.util.IntegerToStringConverter; +import javax.jdo.JDOHelper; +import javax.jdo.Query; +import javax.jdo.Transaction; +import java.lang.reflect.InvocationTargetException; +import java.util.List; + /** - * Title:IntAttributeConverterTest
    - * Keywords: mapping
    - * Assertion ID: [not identified]
    - * Assertion Description: A IPCPoint instance has an int and an Integer field, that are - * stored as strings in the datastore. The int / Integer fields are converted using an - * AttributeConverter. + *Title:IntAttributeConverterTest + *
    + *Keywords: mapping + *
    + *Assertion ID: [not identified] + *
    + *Assertion Description: + * A IPCPoint instance has an int and an Integer field, that are stored as strings in the datastore. + * The int / Integer fields are converted using an AttributeConverter. */ public class IntAttributeConverterTest extends JDO_Test { - private static final int MIN_X = 1; - private static final int MIN_Y = 5; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IntAttributeConverterTest.class); - } - - /** - * @see JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - addTearDownClass(PCPointAnnotated.class); - addTearDownClass(PCPointProp.class); - addTearDownClass(PCPointPropAnnotated.class); - } - - /** Test method creating and storing a PCPoint instance. */ - public void testStorePCPointInstance() { - runStoreIPCPointInstance(PCPoint.class); - } - - /** Test method reading a PCPoint instance from the datastore. */ - public void testReadPCPointInstance() { - runReadIPCPointInstance(PCPoint.class); - } - - /** Test method modifying a PCPoint instance and storing in the datastore. */ - public void testModifyPCPointInstance() { - runModifyIPCPointInstance(PCPoint.class); - } - - /** Test method running a PCPoint query with a query parameter of type Point. */ - public void testPCPointQueryWithPointParam() throws Exception { - runQueryWithIntParameter(PCPoint.class); - } - - /** Test method running a PCPoint query with a query parameter of type String. */ - public void testPCPointQueryWithStringParam() throws Exception { - runQueryWithStringParameter(PCPoint.class); - } - - /** Test method creating and storing a PCPointAnnotated instance. */ - public void testStorePCPointAnnotatedInstance() { - runStoreIPCPointInstance(PCPointAnnotated.class); - } - - /** Test method reading a PCPointAnnotated instance from the datastore. */ - public void testReadPCPointAnnotatedInstance() { - runReadIPCPointInstance(PCPointAnnotated.class); - } - - /** Test method modifying a PCPointAnnotated instance and storing in the datastore. */ - public void testModifyPCPointAnnotatedInstance() { - runModifyIPCPointInstance(PCPointAnnotated.class); - } - - /** Test method running a PCPointAnnotated query with a query parameter of type String. */ - public void testPCPointAnnotatedQueryWithPointParam() throws Exception { - runQueryWithIntParameter(PCPointAnnotated.class); - } - - /** Test method running a PCPointAnnotated query with a query parameter of type Point. */ - public void testPCPointAnnotatedQueryWithStringParam() throws Exception { - runQueryWithStringParameter(PCPointAnnotated.class); - } - - /** Test method creating and storing a PCPoint instance. */ - public void testStorePCPointPropInstance() { - runStoreIPCPointInstance(PCPointProp.class); - } - - /** Test method reading a PCPoint instance from the datastore. */ - public void testReadPCPointPropInstance() { - runReadIPCPointInstance(PCPointProp.class); - } - - /** Test method modifying a PCPoint instance and storing in the datastore. */ - public void testModifyPCPointPropInstance() { - runModifyIPCPointInstance(PCPointProp.class); - } - - /** Test method running a PCPoint query with a query parameter of type Point. */ - public void testPCPointPropQueryWithPointParam() throws Exception { - runQueryWithIntParameter(PCPointProp.class); - } - - /** Test method running a PCPoint query with a query parameter of type String. */ - public void testPCPointPropQueryWithStringParam() throws Exception { - runQueryWithStringParameter(PCPointProp.class); - } - - /** Test method creating and storing a PCPointAnnotated instance. */ - public void testStorePCPointPropAnnotatedInstance() { - runStoreIPCPointInstance(PCPointPropAnnotated.class); - } - - /** Test method reading a PCPointAnnotated instance from the datastore. */ - public void testReadPCPointPropAnnotatedInstance() { - runReadIPCPointInstance(PCPointPropAnnotated.class); - } - - /** Test method modifying a PCPointAnnotated instance and storing in the datastore. */ - public void testModifyPCPointPropAnnotatedInstance() { - runModifyIPCPointInstance(PCPointPropAnnotated.class); - } - - /** Test method running a PCPointAnnotated query with a query parameter of type String. */ - public void testPCPointPropAnnotatedQueryWithPointParam() throws Exception { - runQueryWithIntParameter(PCPointPropAnnotated.class); - } - - /** Test method running a PCPointAnnotated query with a query parameter of type Point. */ - public void testPCPointPropAnnotatedQueryWithStringParam() throws Exception { - runQueryWithStringParameter(PCPointPropAnnotated.class); - } - - // Helper methods - - /** - * Helper method creating a IPCPoint instance. It should call AttributeConverter method - * convertToDatastore. - */ - private void runStoreIPCPointInstance(Class pcPointClass) { - int nrOfDbCalls = IntegerToStringConverter.getNrOfConvertToDatastoreCalls(); - int nrOfAttrCalls = IntegerToStringConverter.getNrOfConvertToAttributeCalls(); - - // Create a persistent IPCPoint instance and store its oid - // AttributeConverter method convertToDatastore is called when persisting instance - createIPCPointInstances(pcPointClass, 1); - - // convertToDatastore should be called twice - assertEquals(2, IntegerToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); - // convertToAttribute should not be called - assertEquals(0, IntegerToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); - } - - /** - * Helper method reading a IPCPoint instance from the datastore. It should call AttributeConverter - * method convertToAttribute. - */ - private void runReadIPCPointInstance(Class pcPointClass) { - IPCPoint point; - Object oid; - int nrOfDbCalls; - int nrOfAttrCalls; - - // Create a persistent IPCPoint instance and store its oid - oid = createIPCPointInstances(pcPointClass, 1); - - // Cleanup the 2nd-level cache and close the pm to make sure PCPoint instances are not cached - pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcPointClass); - pm.close(); - pm = null; - - nrOfDbCalls = IntegerToStringConverter.getNrOfConvertToDatastoreCalls(); - nrOfAttrCalls = IntegerToStringConverter.getNrOfConvertToAttributeCalls(); - pm = getPM(); - pm.currentTransaction().begin(); - // Read the IPCPoint instance from the datastore, this should call convertToAttribute - point = (IPCPoint) pm.getObjectById(oid); - int x = point.getX(); - Integer y = point.getY(); - pm.currentTransaction().commit(); - - // convertToDatastore should not be called - assertEquals(0, IntegerToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); - // convertToAttribute should be called twice - assertEquals(2, IntegerToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); - // Check the values of the associated Point instances - assertEquals(MIN_X, x); - assertEquals(MIN_Y, y == null ? 0 : y.intValue()); - } - - /** - * Helper method modifying a IPCPoint instance. It should call AttributeConverter method - * convertToDatastore. - */ - private void runModifyIPCPointInstance(Class pcPointClass) { - Transaction tx; - IPCPoint point; - Object oid; - int nrOfDbCalls; - int nrOfAttrCalls; - - // Create a persistent IPCPoint instance and store its oid - oid = createIPCPointInstances(pcPointClass, 1); - - // Cleanup the 2nd-level cache and close the pm to make sure PCPoint instances are not cached - pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcPointClass); - pm.close(); - pm = null; - - nrOfDbCalls = IntegerToStringConverter.getNrOfConvertToDatastoreCalls(); - nrOfAttrCalls = IntegerToStringConverter.getNrOfConvertToAttributeCalls(); - pm = getPM(); - tx = pm.currentTransaction(); - tx.begin(); - // Load the PCPoint instance, this should call convertToAttribute - point = (IPCPoint) pm.getObjectById(oid); - // Update IPCPoint instance, this should call convertToDatastore - point.setX(MIN_X + 1); - point.setY(Integer.valueOf(MIN_Y + 1)); - // IPCPoint instance should be dirty - assertTrue(JDOHelper.isDirty(point)); - tx.commit(); - - // convertToDatastore should be called twice - assertEquals(2, IntegerToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); - // convertToAttribute should be called twice - assertEquals(2, IntegerToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); - } - - /** - * Helper method running a query with an int parameter. The parameter value is converted using the - * AttributeConverter. - * - * @throws Exception - */ - private void runQueryWithIntParameter(Class pcPointClass) - throws Exception { - int nrOfDbCalls; - int nrOfAttrCalls; - - nrOfDbCalls = IntegerToStringConverter.getNrOfConvertToDatastoreCalls(); - nrOfAttrCalls = IntegerToStringConverter.getNrOfConvertToAttributeCalls(); - createIPCPointInstances(pcPointClass, 5); - // convertToDatastore should be called twice per instance = 10 times - assertEquals(10, IntegerToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); - // convertToAttribute should not be called - assertEquals(0, IntegerToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); - - // Cleanup the 2nd-level cache and close the pm to make sure PCPoint instances are not cached - pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcPointClass); - pm.close(); - pm = null; - - nrOfDbCalls = IntegerToStringConverter.getNrOfConvertToDatastoreCalls(); - nrOfAttrCalls = IntegerToStringConverter.getNrOfConvertToAttributeCalls(); - pm = getPM(); - pm.currentTransaction().begin(); - try (Query q = pm.newQuery(pcPointClass, "this.x == :param")) { - q.setParameters(MIN_X + 1); - // AttributeConverter method convertToAttribute is called when loading instance from the - // datastore - List res = q.executeList(); - assertEquals(1, res.size()); - IPCPoint point = res.get(0); - - // Check the coordinates of the associated Point instances - assertEquals(MIN_X + 1, point.getX()); - assertEquals(MIN_Y + 1, point.getY() == null ? 0 : point.getY().intValue()); - } catch (Exception e) { - fail(e.getMessage()); - } finally { - pm.currentTransaction().commit(); + private static final int MIN_X = 1; + private static final int MIN_Y = 5; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IntAttributeConverterTest.class); + } + + /** + * @see JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + addTearDownClass(PCPointAnnotated.class); + addTearDownClass(PCPointProp.class); + addTearDownClass(PCPointPropAnnotated.class); + } + + /** + * Test method creating and storing a PCPoint instance. + */ + public void testStorePCPointInstance() { + runStoreIPCPointInstance(PCPoint.class); + } + + /** + * Test method reading a PCPoint instance from the datastore. + */ + public void testReadPCPointInstance() { + runReadIPCPointInstance(PCPoint.class); + } + + /** + * Test method modifying a PCPoint instance and storing in the datastore. + */ + public void testModifyPCPointInstance() { + runModifyIPCPointInstance(PCPoint.class); + } + + /** + * Test method running a PCPoint query with a query parameter of type Point. + */ + public void testPCPointQueryWithPointParam() throws Exception { + runQueryWithIntParameter(PCPoint.class); + } + + /** + * Test method running a PCPoint query with a query parameter of type String. + */ + public void testPCPointQueryWithStringParam() throws Exception { + runQueryWithStringParameter(PCPoint.class); + } + + /** + * Test method creating and storing a PCPointAnnotated instance. + */ + public void testStorePCPointAnnotatedInstance() { + runStoreIPCPointInstance(PCPointAnnotated.class); + } + + /** + * Test method reading a PCPointAnnotated instance from the datastore. + */ + public void testReadPCPointAnnotatedInstance() { + runReadIPCPointInstance(PCPointAnnotated.class); + } + + /** + * Test method modifying a PCPointAnnotated instance and storing in the datastore. + */ + public void testModifyPCPointAnnotatedInstance() { + runModifyIPCPointInstance(PCPointAnnotated.class); + } + + /** + * Test method running a PCPointAnnotated query with a query parameter of type String. + */ + public void testPCPointAnnotatedQueryWithPointParam() throws Exception { + runQueryWithIntParameter(PCPointAnnotated.class); + } + + /** + * Test method running a PCPointAnnotated query with a query parameter of type Point. + */ + public void testPCPointAnnotatedQueryWithStringParam() throws Exception { + runQueryWithStringParameter(PCPointAnnotated.class); + } + + /** + * Test method creating and storing a PCPoint instance. + */ + public void testStorePCPointPropInstance() { + runStoreIPCPointInstance(PCPointProp.class); + } + + /** + * Test method reading a PCPoint instance from the datastore. + */ + public void testReadPCPointPropInstance() { + runReadIPCPointInstance(PCPointProp.class); + } + + /** + * Test method modifying a PCPoint instance and storing in the datastore. + */ + public void testModifyPCPointPropInstance() { + runModifyIPCPointInstance(PCPointProp.class); + } + + /** + * Test method running a PCPoint query with a query parameter of type Point. + */ + public void testPCPointPropQueryWithPointParam() throws Exception { + runQueryWithIntParameter(PCPointProp.class); } - // convertToDatastore should be called to handle the query parameter - assertTrue(IntegerToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls >= 1); - // convertToAttribute should be called at least twice - assertTrue(IntegerToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls >= 2); - } - - /** - * Helper method running a query with a Point parameter. The string parameter is compared to the - * converted int field. - * - * @throws Exception - */ - private void runQueryWithStringParameter(Class pcPointClass) - throws Exception { - int nrOfDbCalls; - int nrOfAttrCalls; - - nrOfDbCalls = IntegerToStringConverter.getNrOfConvertToDatastoreCalls(); - nrOfAttrCalls = IntegerToStringConverter.getNrOfConvertToAttributeCalls(); - createIPCPointInstances(pcPointClass, 5); - // convertToDatastore should be called twice per instance = 10 times - assertEquals(10, IntegerToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); - // convertToAttribute should not be called - assertEquals(0, IntegerToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); - - // Cleanup the 2nd-level cache and close the pm to make sure PCPoint instances are not cached - pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcPointClass); - pm.close(); - pm = null; - - nrOfDbCalls = IntegerToStringConverter.getNrOfConvertToDatastoreCalls(); - nrOfAttrCalls = IntegerToStringConverter.getNrOfConvertToAttributeCalls(); - pm = getPM(); - pm.currentTransaction().begin(); - try (Query q = pm.newQuery(pcPointClass, "this.x == param")) { - q.declareParameters("String param"); - q.setParameters("3"); - // AttributeConverter method convertToAttribute is called when loading instance from the - // datastore - List res = q.executeList(); - assertEquals(1, res.size()); - IPCPoint point = res.get(0); - - assertEquals(MIN_X + 2, point.getX()); - assertEquals(MIN_Y + 2, point.getY() == null ? 0 : point.getY().intValue()); - } finally { - pm.currentTransaction().commit(); + /** + * Test method running a PCPoint query with a query parameter of type String. + */ + public void testPCPointPropQueryWithStringParam() throws Exception { + runQueryWithStringParameter(PCPointProp.class); } - // convertToDatastore should not be called - assertTrue(IntegerToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls == 0); - // convertToAttribute should be called at least twice - assertTrue(IntegerToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls >= 2); - } - - /** - * Helper method to create IPCPoint instances. - * - * @param pcPointClass class instance of the IPCPoint implementation class to be created - * @param nrOfObjects number of IPCPoint instances to be created - * @return ObjectId of the first IPCPoint instance - */ - private Object createIPCPointInstances( - Class pcPointClass, int nrOfObjects) { - IPCPoint point; - Object oid = null; - - if (nrOfObjects < 1) { - return null; + /** + * Test method creating and storing a PCPointAnnotated instance. + */ + public void testStorePCPointPropAnnotatedInstance() { + runStoreIPCPointInstance(PCPointPropAnnotated.class); } - pm = getPM(); - try { - pm.currentTransaction().begin(); - point = pcPointClass.getConstructor().newInstance(); - point.setX(MIN_X); - point.setY(Integer.valueOf(MIN_Y)); - pm.makePersistent(point); - oid = pm.getObjectId(point); - for (int i = 1; i < nrOfObjects; i++) { - point = pcPointClass.getConstructor().newInstance(); - point.setX(MIN_X + i); - point.setY(Integer.valueOf(MIN_Y + i)); - pm.makePersistent(point); - } - pm.currentTransaction().commit(); - } catch (NoSuchMethodException - | SecurityException - | InstantiationException - | IllegalAccessException - | IllegalArgumentException - | InvocationTargetException ex) { - fail("Error creating IPCPoint instance: " + ex.getMessage()); - } finally { - if (pm.currentTransaction().isActive()) { - pm.currentTransaction().rollback(); - } + /** + * Test method reading a PCPointAnnotated instance from the datastore. + */ + public void testReadPCPointPropAnnotatedInstance() { + runReadIPCPointInstance(PCPointPropAnnotated.class); } - return oid; - } + + /** + * Test method modifying a PCPointAnnotated instance and storing in the datastore. + */ + public void testModifyPCPointPropAnnotatedInstance() { + runModifyIPCPointInstance(PCPointPropAnnotated.class); + } + + /** + * Test method running a PCPointAnnotated query with a query parameter of type String. + */ + public void testPCPointPropAnnotatedQueryWithPointParam() throws Exception { + runQueryWithIntParameter(PCPointPropAnnotated.class); + } + + /** + * Test method running a PCPointAnnotated query with a query parameter of type Point. + */ + public void testPCPointPropAnnotatedQueryWithStringParam() throws Exception { + runQueryWithStringParameter(PCPointPropAnnotated.class); + } + + + // Helper methods + + /** + * Helper method creating a IPCPoint instance. + * It should call AttributeConverter method convertToDatastore. + */ + private void runStoreIPCPointInstance(Class pcPointClass) { + int nrOfDbCalls = IntegerToStringConverter.getNrOfConvertToDatastoreCalls(); + int nrOfAttrCalls = IntegerToStringConverter.getNrOfConvertToAttributeCalls(); + + // Create a persistent IPCPoint instance and store its oid + // AttributeConverter method convertToDatastore is called when persisting instance + createIPCPointInstances(pcPointClass, 1); + + // convertToDatastore should be called twice + assertEquals(2, IntegerToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); + // convertToAttribute should not be called + assertEquals(0, IntegerToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); + } + + /** + * Helper method reading a IPCPoint instance from the datastore. + * It should call AttributeConverter method convertToAttribute. + */ + private void runReadIPCPointInstance(Class pcPointClass) { + IPCPoint point; + Object oid; + int nrOfDbCalls; + int nrOfAttrCalls; + + // Create a persistent IPCPoint instance and store its oid + oid = createIPCPointInstances(pcPointClass, 1); + + // Cleanup the 2nd-level cache and close the pm to make sure PCPoint instances are not cached + pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcPointClass); + pm.close(); + pm = null; + + nrOfDbCalls = IntegerToStringConverter.getNrOfConvertToDatastoreCalls(); + nrOfAttrCalls = IntegerToStringConverter.getNrOfConvertToAttributeCalls(); + pm = getPM(); + pm.currentTransaction().begin(); + // Read the IPCPoint instance from the datastore, this should call convertToAttribute + point = (IPCPoint)pm.getObjectById(oid); + int x = point.getX(); + Integer y = point.getY(); + pm.currentTransaction().commit(); + + // convertToDatastore should not be called + assertEquals(0, IntegerToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); + // convertToAttribute should be called twice + assertEquals(2, IntegerToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); + // Check the values of the associated Point instances + assertEquals(MIN_X, x); + assertEquals(MIN_Y, y == null ? 0 : y.intValue()); + } + + /** + * Helper method modifying a IPCPoint instance. + * It should call AttributeConverter method convertToDatastore. + */ + private void runModifyIPCPointInstance(Class pcPointClass) { + Transaction tx; + IPCPoint point; + Object oid; + int nrOfDbCalls; + int nrOfAttrCalls; + + // Create a persistent IPCPoint instance and store its oid + oid = createIPCPointInstances(pcPointClass, 1); + + // Cleanup the 2nd-level cache and close the pm to make sure PCPoint instances are not cached + pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcPointClass); + pm.close(); + pm = null; + + nrOfDbCalls = IntegerToStringConverter.getNrOfConvertToDatastoreCalls(); + nrOfAttrCalls = IntegerToStringConverter.getNrOfConvertToAttributeCalls(); + pm = getPM(); + tx = pm.currentTransaction(); + tx.begin(); + // Load the PCPoint instance, this should call convertToAttribute + point = (IPCPoint)pm.getObjectById(oid); + // Update IPCPoint instance, this should call convertToDatastore + point.setX(MIN_X + 1); + point.setY(Integer.valueOf(MIN_Y + 1)); + // IPCPoint instance should be dirty + assertTrue(JDOHelper.isDirty(point)); + tx.commit(); + + // convertToDatastore should be called twice + assertEquals(2, IntegerToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); + // convertToAttribute should be called twice + assertEquals(2, IntegerToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); + } + + /** + * Helper method running a query with an int parameter. + * The parameter value is converted using the AttributeConverter. + * @throws Exception + */ + private void runQueryWithIntParameter(Class pcPointClass) throws Exception { + int nrOfDbCalls; + int nrOfAttrCalls; + + nrOfDbCalls = IntegerToStringConverter.getNrOfConvertToDatastoreCalls(); + nrOfAttrCalls = IntegerToStringConverter.getNrOfConvertToAttributeCalls(); + createIPCPointInstances(pcPointClass, 5); + // convertToDatastore should be called twice per instance = 10 times + assertEquals(10, IntegerToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); + // convertToAttribute should not be called + assertEquals(0, IntegerToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); + + // Cleanup the 2nd-level cache and close the pm to make sure PCPoint instances are not cached + pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcPointClass); + pm.close(); + pm = null; + + nrOfDbCalls = IntegerToStringConverter.getNrOfConvertToDatastoreCalls(); + nrOfAttrCalls = IntegerToStringConverter.getNrOfConvertToAttributeCalls(); + pm = getPM(); + pm.currentTransaction().begin(); + try (Query q = pm.newQuery(pcPointClass, "this.x == :param")) { + q.setParameters(MIN_X + 1); + // AttributeConverter method convertToAttribute is called when loading instance from the datastore + List res = q.executeList(); + assertEquals(1, res.size()); + IPCPoint point = res.get(0); + + // Check the coordinates of the associated Point instances + assertEquals(MIN_X + 1, point.getX()); + assertEquals(MIN_Y + 1, point.getY() == null ? 0 : point.getY().intValue()); + } catch (Exception e) { + fail(e.getMessage()); + } finally { + pm.currentTransaction().commit(); + } + + // convertToDatastore should be called to handle the query parameter + assertTrue(IntegerToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls >= 1); + // convertToAttribute should be called at least twice + assertTrue(IntegerToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls >= 2); + } + + /** + * Helper method running a query with a Point parameter. + * The string parameter is compared to the converted int field. + * @throws Exception + */ + private void runQueryWithStringParameter(Class pcPointClass) throws Exception { + int nrOfDbCalls; + int nrOfAttrCalls; + + nrOfDbCalls = IntegerToStringConverter.getNrOfConvertToDatastoreCalls(); + nrOfAttrCalls = IntegerToStringConverter.getNrOfConvertToAttributeCalls(); + createIPCPointInstances(pcPointClass,5); + // convertToDatastore should be called twice per instance = 10 times + assertEquals(10, IntegerToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); + // convertToAttribute should not be called + assertEquals(0, IntegerToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); + + // Cleanup the 2nd-level cache and close the pm to make sure PCPoint instances are not cached + pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcPointClass); + pm.close(); + pm = null; + + nrOfDbCalls = IntegerToStringConverter.getNrOfConvertToDatastoreCalls(); + nrOfAttrCalls = IntegerToStringConverter.getNrOfConvertToAttributeCalls(); + pm = getPM(); + pm.currentTransaction().begin(); + try (Query q = pm.newQuery(pcPointClass, "this.x == param")) { + q.declareParameters("String param"); + q.setParameters("3"); + // AttributeConverter method convertToAttribute is called when loading instance from the datastore + List res = q.executeList(); + assertEquals(1, res.size()); + IPCPoint point = res.get(0); + + assertEquals(MIN_X+2, point.getX()); + assertEquals(MIN_Y+2, point.getY() == null ? 0 : point.getY().intValue()); + } finally { + pm.currentTransaction().commit(); + } + + // convertToDatastore should not be called + assertTrue(IntegerToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls == 0); + // convertToAttribute should be called at least twice + assertTrue(IntegerToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls >= 2); + + } + + /** + * Helper method to create IPCPoint instances. + * @param pcPointClass class instance of the IPCPoint implementation class to be created + * @param nrOfObjects number of IPCPoint instances to be created + * @return ObjectId of the first IPCPoint instance + */ + private Object createIPCPointInstances(Class pcPointClass, int nrOfObjects) { + IPCPoint point; + Object oid = null; + + if (nrOfObjects < 1) { + return null; + } + + pm = getPM(); + try { + pm.currentTransaction().begin(); + point = pcPointClass.getConstructor().newInstance(); + point.setX(MIN_X); + point.setY(Integer.valueOf(MIN_Y)); + pm.makePersistent(point); + oid = pm.getObjectId(point); + for (int i = 1; i < nrOfObjects; i++) { + point = pcPointClass.getConstructor().newInstance(); + point.setX(MIN_X + i); + point.setY(Integer.valueOf(MIN_Y + i)); + pm.makePersistent(point); + } + pm.currentTransaction().commit(); + } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | + IllegalArgumentException | InvocationTargetException ex) { + fail("Error creating IPCPoint instance: " + ex.getMessage()); + } finally { + if (pm.currentTransaction().isActive()) { + pm.currentTransaction().rollback(); + } + } + return oid; + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/converter/PointAttributeConverterTest.java b/tck/src/main/java/org/apache/jdo/tck/api/converter/PointAttributeConverterTest.java index a52bde06e..019ebf371 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/converter/PointAttributeConverterTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/converter/PointAttributeConverterTest.java @@ -16,11 +16,6 @@ */ package org.apache.jdo.tck.api.converter; -import java.lang.reflect.InvocationTargetException; -import java.util.List; -import javax.jdo.JDOHelper; -import javax.jdo.Query; -import javax.jdo.Transaction; import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.converter.IPCRect; import org.apache.jdo.tck.pc.converter.PCRect; @@ -29,339 +24,360 @@ import org.apache.jdo.tck.util.BatchTestRunner; import org.apache.jdo.tck.util.PointToStringConverter; +import javax.jdo.JDOHelper; +import javax.jdo.Query; +import javax.jdo.Transaction; +import java.lang.reflect.InvocationTargetException; +import java.util.List; + /** - * Title:PointAttributeConverterTest
    - * Keywords: mapping
    - * Assertion ID: [not identified]
    - * Assertion Description: A IPCRect instance refers two Point instances, that are stored as - * strings in the datastore. A Point instance is converted using an AttributeConverter. + *Title:PointAttributeConverterTest + *
    + *Keywords: mapping + *
    + *Assertion ID: [not identified] + *
    + *Assertion Description: + * A IPCRect instance refers two Point instances, that are stored as strings in the datastore. + * A Point instance is converted using an AttributeConverter. */ public class PointAttributeConverterTest extends JDO_Test { - private static final int UL_X = 1; - private static final int UL_Y = 10; - private static final int LR_X = 10; - private static final int LR_Y = 1; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(PointAttributeConverterTest.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCRect.class); - addTearDownClass(PCRectAnnotated.class); - } - - /** Test method creating and storing a PCRectString instance. */ - public void testStorePCRectStringInstance() { - runStoreIPCRectInstance(PCRect.class); - } - - /** Test method reading a PCRectString instance from the datastore. */ - public void testReadPCRectStringInstance() { - runReadIPCRectInstance(PCRect.class); - } - - /** Test method modifying a PCRectString instance and storing in the datastore. */ - public void testModifyPCRectStringInstance() { - runModifyIPCRectInstance(PCRect.class); - } - - /** Test method running a PCRectString query with a query parameter of type Point. */ - public void testPCRectStringQueryWithPointParam() throws Exception { - runQueryWithPointParameter(PCRect.class); - } - - /** Test method running a PCRectString query with a query parameter of type String. */ - public void testPCRectStringQueryWithStringParam() throws Exception { - runQueryWithStringParameter(PCRect.class); - } - - /** Test method creating and storing a PCRectStringAnnotated instance. */ - public void testStorePCRectStringAnnotatedInstance() { - runStoreIPCRectInstance(PCRectAnnotated.class); - } - - /** Test method reading a PCRectStringAnnotated instance from the datastore. */ - public void testReadPCRectStringAnnotatedInstance() { - runReadIPCRectInstance(PCRectAnnotated.class); - } - - /** Test method modifying a PCRectStringAnnotated instance and storing in the datastore. */ - public void testModifyPCRectStringAnnotatedInstance() { - runModifyIPCRectInstance(PCRectAnnotated.class); - } - - /** Test method running a PCRectStringAnnotated query with a query parameter of type String. */ - public void testPCRectStringAnnotatedQueryWithPointParam() throws Exception { - runQueryWithPointParameter(PCRectAnnotated.class); - } - - /** Test method running a PCRectStringAnnotated query with a query parameter of type Point. */ - public void testPCRectStringAnnotatedQueryWithStringParam() throws Exception { - runQueryWithStringParameter(PCRectAnnotated.class); - } - - // Helper methods - - /** - * Helper method creating a IPCRect instance. It should call AttributeConverter method - * convertToDatastore. - */ - private void runStoreIPCRectInstance(Class pcrectClass) { - int nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); - int nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); - - // Create a persistent IPCRect instance and store its oid - // AttributeConverter method convertToDatastore is called when persisting instance - createIPCRectInstances(pcrectClass, 1); - - // convertToDatastore should be called twice - assertEquals(2, PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); - // convertToAttribute should not be called - assertEquals(0, PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); - } - - /** - * Helper method reading a IPCRect instance from the datastore. It should call AttributeConverter - * method convertToAttribute. - */ - private void runReadIPCRectInstance(Class pcrectClass) { - IPCRect rect; - Object oid; - int nrOfDbCalls; - int nrOfAttrCalls; - - // Create a persistent IPCRect instance and store its oid - oid = createIPCRectInstances(pcrectClass, 1); - - // Cleanup the 2nd-level cache and close the pm to make sure PCRect instances are not cached - pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcrectClass); - pm.close(); - pm = null; - - nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); - nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); - pm = getPM(); - pm.currentTransaction().begin(); - // Read the IPCRect instance from the datastore, this should call convertToAttribute - rect = (IPCRect) pm.getObjectById(oid); - Point ul = rect.getUpperLeft(); - Point lr = rect.getLowerRight(); - pm.currentTransaction().commit(); - - // convertToDatastore should not be called - assertEquals(0, PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); - // convertToAttribute should be called twice - assertEquals(2, PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); - // Check the values of the associated Point instances - assertEquals(UL_X, ul.getX()); - assertEquals(UL_Y, ul.getY() == null ? 0 : ul.getY().intValue()); - assertEquals(LR_X, lr.getX()); - assertEquals(LR_Y, lr.getY() == null ? 0 : lr.getY().intValue()); - } - - /** - * Helper method modifying a IPCRect instance. It should call AttributeConverter method - * convertToDatastore. - */ - private void runModifyIPCRectInstance(Class pcrectClass) { - Transaction tx; - IPCRect rect; - Object oid; - int nrOfDbCalls; - int nrOfAttrCalls; - - // Create a persistent IPCRect instance and store its oid - oid = createIPCRectInstances(pcrectClass, 1); - - // Cleanup the 2nd-level cache and close the pm to make sure PCRect instances are not cached - pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcrectClass); - pm.close(); - pm = null; - - nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); - nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); - pm = getPM(); - tx = pm.currentTransaction(); - tx.begin(); - rect = (IPCRect) pm.getObjectById(oid); - // should trigger convertToAttribute - rect.getLowerRight(); - rect.getUpperLeft(); - // Update IPCRect instance, this should call convertToDatastore - rect.setUpperLeft(new Point(UL_X + 1, UL_Y + 1)); - rect.setLowerRight(new Point(LR_X + 1, LR_Y + 1)); - // IPCRect instance should be dirty - assertTrue(JDOHelper.isDirty(rect)); - tx.commit(); - - // convertToDatastore should be called twice - assertEquals(2, PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); - // convertToAttribute should be called twice - assertEquals(2, PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); - } - - /** - * Helper method running a query with a Point parameter. The parameter value is converted using - * the AttributeConverter. - * - * @throws Exception - */ - private void runQueryWithPointParameter(Class pcrectClass) - throws Exception { - int nrOfDbCalls; - int nrOfAttrCalls; - - nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); - nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); - createIPCRectInstances(pcrectClass, 5); - // convertToDatastore should be called twice per instance = 10 times - assertEquals(10, PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); - // convertToAttribute should not be called - assertEquals(0, PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); - - // Cleanup the 2nd-level cache and close the pm to make sure PCRect instances are not cached - pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcrectClass); - pm.close(); - pm = null; - - nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); - nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); - pm = getPM(); - pm.currentTransaction().begin(); - try (Query q = pm.newQuery(pcrectClass, "this.upperLeft == :point")) { - q.setParameters(new Point(UL_X + 1, UL_Y + 1)); - // AttributeConverter method convertToAttribute is called when loading instance from the - // datastore - List res = q.executeList(); - assertEquals(1, res.size()); - IPCRect rect = res.get(0); - Point ul = rect.getUpperLeft(); - Point lr = rect.getLowerRight(); - - // Check the coordinates of the associated Point instances - assertEquals(UL_X + 1, ul.getX()); - assertEquals(UL_Y + 1, ul.getY() == null ? 0 : ul.getY().intValue()); - assertEquals(LR_X + 1, lr.getX()); - assertEquals(LR_Y + 1, lr.getY() == null ? 0 : lr.getY().intValue()); - } catch (Exception e) { - fail(e.getMessage()); - } finally { - pm.currentTransaction().commit(); + private static final int UL_X = 1; + private static final int UL_Y = 10; + private static final int LR_X = 10; + private static final int LR_Y = 1; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(PointAttributeConverterTest.class); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCRect.class); + addTearDownClass(PCRectAnnotated.class); + } + + /** + * Test method creating and storing a PCRectString instance. + */ + public void testStorePCRectStringInstance() { + runStoreIPCRectInstance(PCRect.class); + } + + /** + * Test method reading a PCRectString instance from the datastore. + */ + public void testReadPCRectStringInstance() { + runReadIPCRectInstance(PCRect.class); + } + + /** + * Test method modifying a PCRectString instance and storing in the datastore. + */ + public void testModifyPCRectStringInstance() { + runModifyIPCRectInstance(PCRect.class); + } + + /** + * Test method running a PCRectString query with a query parameter of type Point. + */ + public void testPCRectStringQueryWithPointParam() throws Exception { + runQueryWithPointParameter(PCRect.class); + } + + /** + * Test method running a PCRectString query with a query parameter of type String. + */ + public void testPCRectStringQueryWithStringParam() throws Exception { + runQueryWithStringParameter(PCRect.class); + } + + /** + * Test method creating and storing a PCRectStringAnnotated instance. + */ + public void testStorePCRectStringAnnotatedInstance() { + runStoreIPCRectInstance(PCRectAnnotated.class); + } + + /** + * Test method reading a PCRectStringAnnotated instance from the datastore. + */ + public void testReadPCRectStringAnnotatedInstance() { + runReadIPCRectInstance(PCRectAnnotated.class); + } + + /** + * Test method modifying a PCRectStringAnnotated instance and storing in the datastore. + */ + public void testModifyPCRectStringAnnotatedInstance() { + runModifyIPCRectInstance(PCRectAnnotated.class); + } + + /** + * Test method running a PCRectStringAnnotated query with a query parameter of type String. + */ + public void testPCRectStringAnnotatedQueryWithPointParam() throws Exception { + runQueryWithPointParameter(PCRectAnnotated.class); + } + + /** + * Test method running a PCRectStringAnnotated query with a query parameter of type Point. + */ + public void testPCRectStringAnnotatedQueryWithStringParam() throws Exception { + runQueryWithStringParameter(PCRectAnnotated.class); } - // convertToDatastore should be called to handle the query parameter - assertTrue(PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls >= 1); - // convertToAttribute should be called at least twice - assertTrue(PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls >= 2); - } - - /** - * Helper method running a query with a Point parameter. The string parameter is compared to the - * converted Point field. - * - * @throws Exception - */ - private void runQueryWithStringParameter(Class pcrectClass) - throws Exception { - int nrOfDbCalls; - int nrOfAttrCalls; - - nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); - nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); - createIPCRectInstances(pcrectClass, 5); - // convertToDatastore should be called twice per instance = 10 times - assertEquals(10, PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); - // convertToAttribute should not be called - assertEquals(0, PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); - - // Cleanup the 2nd-level cache and close the pm to make sure PCRect instances are not cached - pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcrectClass); - pm.close(); - pm = null; - - nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); - nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); - pm = getPM(); - pm.currentTransaction().begin(); - try (Query q = pm.newQuery(pcrectClass, "this.upperLeft == str")) { - q.declareParameters("String str"); - q.setParameters("3:12"); - // AttributeConverter method convertToAttribute is called when loading instance from the - // datastore - List res = q.executeList(); - assertEquals(1, res.size()); - IPCRect rect = res.get(0); - Point ul = rect.getUpperLeft(); - Point lr = rect.getLowerRight(); - - // Check the coordinates of the associated Point instances - assertEquals(UL_X + 2, ul.getX()); - assertEquals(UL_Y + 2, ul.getY() == null ? 0 : ul.getY().intValue()); - assertEquals(LR_X + 2, lr.getX()); - assertEquals(LR_Y + 2, lr.getY() == null ? 0 : lr.getY().intValue()); - } finally { - pm.currentTransaction().commit(); + // Helper methods + + /** + * Helper method creating a IPCRect instance. + * It should call AttributeConverter method convertToDatastore. + */ + private void runStoreIPCRectInstance(Class pcrectClass) { + int nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); + int nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); + + // Create a persistent IPCRect instance and store its oid + // AttributeConverter method convertToDatastore is called when persisting instance + createIPCRectInstances(pcrectClass, 1); + + // convertToDatastore should be called twice + assertEquals(2, PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); + // convertToAttribute should not be called + assertEquals(0, PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); } - // convertToDatastore should not be called - assertTrue(PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls == 0); - // convertToAttribute should be called at least twice - assertTrue(PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls >= 2); - } - - /** - * Helper method to create IPCRect instances. - * - * @param pcrectClass class instance of the IPCRect implementation class to be created - * @param nrOfObjects number of IPCRect instances to be created - * @return ObjectId of the first IPCRect instance - */ - private Object createIPCRectInstances(Class pcrectClass, int nrOfObjects) { - IPCRect rect; - Object oid = null; - - if (nrOfObjects < 1) { - return null; + /** + * Helper method reading a IPCRect instance from the datastore. + * It should call AttributeConverter method convertToAttribute. + */ + private void runReadIPCRectInstance(Class pcrectClass) { + IPCRect rect; + Object oid; + int nrOfDbCalls; + int nrOfAttrCalls; + + // Create a persistent IPCRect instance and store its oid + oid = createIPCRectInstances(pcrectClass, 1); + + // Cleanup the 2nd-level cache and close the pm to make sure PCRect instances are not cached + pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcrectClass); + pm.close(); + pm = null; + + nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); + nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); + pm = getPM(); + pm.currentTransaction().begin(); + // Read the IPCRect instance from the datastore, this should call convertToAttribute + rect = (IPCRect)pm.getObjectById(oid); + Point ul = rect.getUpperLeft(); + Point lr = rect.getLowerRight(); + pm.currentTransaction().commit(); + + // convertToDatastore should not be called + assertEquals(0, PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); + // convertToAttribute should be called twice + assertEquals(2, PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); + // Check the values of the associated Point instances + assertEquals(UL_X, ul.getX()); + assertEquals(UL_Y, ul.getY() == null ? 0 : ul.getY().intValue()); + assertEquals(LR_X, lr.getX()); + assertEquals(LR_Y, lr.getY() == null ? 0 : lr.getY().intValue()); } - pm = getPM(); - try { - pm.currentTransaction().begin(); - rect = pcrectClass.getConstructor().newInstance(); - rect.setUpperLeft(new Point(UL_X, UL_Y)); - rect.setLowerRight(new Point(LR_X, LR_Y)); - pm.makePersistent(rect); - oid = pm.getObjectId(rect); - for (int i = 1; i < nrOfObjects; i++) { - rect = pcrectClass.getConstructor().newInstance(); - rect.setUpperLeft(new Point(UL_X + i, UL_Y + i)); - rect.setLowerRight(new Point(LR_X + i, LR_Y + i)); - pm.makePersistent(rect); - } - pm.currentTransaction().commit(); - } catch (NoSuchMethodException - | SecurityException - | InstantiationException - | IllegalAccessException - | IllegalArgumentException - | InvocationTargetException ex) { - fail("Error creating IPCRect instance: " + ex.getMessage()); - } finally { - if (pm.currentTransaction().isActive()) { - pm.currentTransaction().rollback(); - } + /** + * Helper method modifying a IPCRect instance. + * It should call AttributeConverter method convertToDatastore. + */ + private void runModifyIPCRectInstance(Class pcrectClass) { + Transaction tx; + IPCRect rect; + Object oid; + int nrOfDbCalls; + int nrOfAttrCalls; + + // Create a persistent IPCRect instance and store its oid + oid = createIPCRectInstances(pcrectClass, 1); + + // Cleanup the 2nd-level cache and close the pm to make sure PCRect instances are not cached + pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcrectClass); + pm.close(); + pm = null; + + nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); + nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); + pm = getPM(); + tx = pm.currentTransaction(); + tx.begin(); + rect = (IPCRect)pm.getObjectById(oid); + // should trigger convertToAttribute + rect.getLowerRight(); + rect.getUpperLeft(); + // Update IPCRect instance, this should call convertToDatastore + rect.setUpperLeft(new Point(UL_X + 1, UL_Y + 1)); + rect.setLowerRight(new Point(LR_X + 1, LR_Y + 1)); + // IPCRect instance should be dirty + assertTrue(JDOHelper.isDirty(rect)); + tx.commit(); + + // convertToDatastore should be called twice + assertEquals(2, PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); + // convertToAttribute should be called twice + assertEquals(2, PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); } - return oid; - } + + /** + * Helper method running a query with a Point parameter. + * The parameter value is converted using the AttributeConverter. + * @throws Exception + */ + private void runQueryWithPointParameter(Class pcrectClass) throws Exception { + int nrOfDbCalls; + int nrOfAttrCalls; + + nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); + nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); + createIPCRectInstances(pcrectClass, 5); + // convertToDatastore should be called twice per instance = 10 times + assertEquals(10, PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); + // convertToAttribute should not be called + assertEquals(0, PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); + + // Cleanup the 2nd-level cache and close the pm to make sure PCRect instances are not cached + pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcrectClass); + pm.close(); + pm = null; + + nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); + nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); + pm = getPM(); + pm.currentTransaction().begin(); + try (Query q = pm.newQuery(pcrectClass, "this.upperLeft == :point")) { + q.setParameters(new Point(UL_X + 1, UL_Y + 1)); + // AttributeConverter method convertToAttribute is called when loading instance from the datastore + List res = q.executeList(); + assertEquals(1, res.size()); + IPCRect rect = res.get(0); + Point ul = rect.getUpperLeft(); + Point lr = rect.getLowerRight(); + + // Check the coordinates of the associated Point instances + assertEquals(UL_X+1, ul.getX()); + assertEquals(UL_Y+1, ul.getY() == null ? 0 : ul.getY().intValue()); + assertEquals(LR_X+1, lr.getX()); + assertEquals(LR_Y+1, lr.getY() == null ? 0 : lr.getY().intValue()); + } catch (Exception e) { + fail(e.getMessage()); + } finally { + pm.currentTransaction().commit(); + } + + // convertToDatastore should be called to handle the query parameter + assertTrue(PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls >= 1); + // convertToAttribute should be called at least twice + assertTrue(PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls >= 2); + } + + /** + * Helper method running a query with a Point parameter. + * The string parameter is compared to the converted Point field. + * @throws Exception + */ + private void runQueryWithStringParameter(Class pcrectClass) throws Exception { + int nrOfDbCalls; + int nrOfAttrCalls; + + nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); + nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); + createIPCRectInstances(pcrectClass,5); + // convertToDatastore should be called twice per instance = 10 times + assertEquals(10, PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls); + // convertToAttribute should not be called + assertEquals(0, PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls); + + // Cleanup the 2nd-level cache and close the pm to make sure PCRect instances are not cached + pm.getPersistenceManagerFactory().getDataStoreCache().evictAll(false, pcrectClass); + pm.close(); + pm = null; + + nrOfDbCalls = PointToStringConverter.getNrOfConvertToDatastoreCalls(); + nrOfAttrCalls = PointToStringConverter.getNrOfConvertToAttributeCalls(); + pm = getPM(); + pm.currentTransaction().begin(); + try (Query q = pm.newQuery(pcrectClass, "this.upperLeft == str")) { + q.declareParameters("String str"); + q.setParameters("3:12"); + // AttributeConverter method convertToAttribute is called when loading instance from the datastore + List res = q.executeList(); + assertEquals(1, res.size()); + IPCRect rect = res.get(0); + Point ul = rect.getUpperLeft(); + Point lr = rect.getLowerRight(); + + // Check the coordinates of the associated Point instances + assertEquals(UL_X+2, ul.getX()); + assertEquals(UL_Y+2, ul.getY() == null ? 0 : ul.getY().intValue()); + assertEquals(LR_X+2, lr.getX()); + assertEquals(LR_Y+2, lr.getY() == null ? 0 : lr.getY().intValue()); + } finally { + pm.currentTransaction().commit(); + } + + // convertToDatastore should not be called + assertTrue(PointToStringConverter.getNrOfConvertToDatastoreCalls() - nrOfDbCalls == 0); + // convertToAttribute should be called at least twice + assertTrue(PointToStringConverter.getNrOfConvertToAttributeCalls() - nrOfAttrCalls >= 2); + + } + + /** + * Helper method to create IPCRect instances. + * @param pcrectClass class instance of the IPCRect implementation class to be created + * @param nrOfObjects number of IPCRect instances to be created + * @return ObjectId of the first IPCRect instance + */ + private Object createIPCRectInstances(Class pcrectClass, int nrOfObjects) { + IPCRect rect; + Object oid = null; + + if (nrOfObjects < 1) { + return null; + } + + pm = getPM(); + try { + pm.currentTransaction().begin(); + rect = pcrectClass.getConstructor().newInstance(); + rect.setUpperLeft(new Point(UL_X, UL_Y)); + rect.setLowerRight(new Point(LR_X, LR_Y)); + pm.makePersistent(rect); + oid = pm.getObjectId(rect); + for (int i = 1; i < nrOfObjects; i++) { + rect = pcrectClass.getConstructor().newInstance(); + rect.setUpperLeft(new Point(UL_X + i, UL_Y + i)); + rect.setLowerRight(new Point(LR_X + i, LR_Y + i)); + pm.makePersistent(rect); + } + pm.currentTransaction().commit(); + } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | + IllegalArgumentException | InvocationTargetException ex) { + fail("Error creating IPCRect instance: " + ex.getMessage()); + } finally { + if (pm.currentTransaction().isActive()) { + pm.currentTransaction().rollback(); + } + } + return oid; + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/exceptions/ExceptionConstructor.java b/tck/src/main/java/org/apache/jdo/tck/api/exceptions/ExceptionConstructor.java index 6b9346544..a0ecabab2 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/exceptions/ExceptionConstructor.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/exceptions/ExceptionConstructor.java @@ -5,315 +5,296 @@ * 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 + * + * 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.jdo.tck.api.exceptions; import java.lang.reflect.Constructor; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Exception Constructor
    - * Keywords: exception
    - * Assertion ID:
    - * Assertion Description: + *Title: Exception Constructor + *
    + *Keywords: exception + *
    + *Assertion ID: + *
    + *Assertion Description: */ -public class ExceptionConstructor extends JDO_Test { - protected static final Class[] classArrayEmpty = new Class[] {}; - protected static final Class[] classArrayString = new Class[] {String.class}; - protected static final Class[] classArrayStringObject = new Class[] {String.class, Object.class}; - protected static final Class[] classArrayStringThrowable = - new Class[] {String.class, Throwable.class}; - protected static final Class[] classArrayStringThrowableArray = - new Class[] {String.class, Throwable[].class}; - protected static final Class[] classArrayStringThrowableObject = - new Class[] {String.class, Throwable.class, Object.class}; - protected static final Class[] classArrayStringThrowableArrayObject = - new Class[] {String.class, Throwable[].class, Object.class}; - protected static final String message = "Message"; - protected static final Object object = "Failed Object"; - protected static final Throwable throwable = new Throwable("Throwable"); - protected static final Object[] objectArrayEmpty = new Object[] {}; - protected static final Object[] objectArrayString = new Object[] {message}; - protected static final Object[] objectArrayStringObject = new Object[] {message, object}; - protected static final Object[] objectArrayStringThrowableArray = - new Object[] {message, new Throwable[] {throwable}}; - protected static final Object[] objectArrayStringThrowable = new Object[] {message, throwable}; - protected static final Object[] objectArrayStringThrowableArrayObject = - new Object[] {message, new Throwable[] {throwable}, object}; - protected static final Object[] objectArrayStringThrowableObject = - new Object[] {message, throwable, object}; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ExceptionConstructor.class); - } +public class ExceptionConstructor extends JDO_Test { - /* test all constructors - * - */ - public void testConstructors() { - constructJDOCanRetryException(); - constructJDODataStoreException(); - constructJDODetachedFieldAccessException(); - constructJDOException(); - constructJDOFatalDataStoreException(); - constructJDOFatalException(); - constructJDOFatalInternalException(); - constructJDOFatalUserException(); - constructJDONullIdentityException(); - constructJDOObjectNotFoundException(); - constructJDOOptimisticVerificationException(); - constructJDOUnsupportedOptionException(); - constructJDOUserCallbackException(); - failOnError(); - } + protected static final Class[] classArrayEmpty = + new Class[] {}; + protected static final Class[] classArrayString = + new Class[] {String.class}; + protected static final Class[] classArrayStringObject = + new Class[] {String.class, Object.class}; + protected static final Class[] classArrayStringThrowable = + new Class[] {String.class, Throwable.class}; + protected static final Class[] classArrayStringThrowableArray = + new Class[] {String.class, Throwable[].class}; + protected static final Class[] classArrayStringThrowableObject = + new Class[] {String.class, Throwable.class, Object.class}; + protected static final Class[] classArrayStringThrowableArrayObject = + new Class[] {String.class, Throwable[].class, Object.class}; + protected static final String message = "Message"; + protected static final Object object = "Failed Object"; + protected static final Throwable throwable = new Throwable("Throwable"); + protected static final Object[] objectArrayEmpty = + new Object[]{}; + protected static final Object[] objectArrayString = + new Object[]{message}; + protected static final Object[] objectArrayStringObject = + new Object[]{message, object}; + protected static final Object[] objectArrayStringThrowableArray = + new Object[] {message, new Throwable[] {throwable}}; + protected static final Object[] objectArrayStringThrowable = + new Object[] {message, throwable}; + protected static final Object[] objectArrayStringThrowableArrayObject = + new Object[] {message, new Throwable[] {throwable}, object}; + protected static final Object[] objectArrayStringThrowableObject = + new Object[] {message, throwable, object}; + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ExceptionConstructor.class); + } - protected void constructJDOCanRetryException() { - constructEmpty(javax.jdo.JDOCanRetryException.class); - constructString(javax.jdo.JDOCanRetryException.class); - constructStringThrowableArray(javax.jdo.JDOCanRetryException.class); - constructStringThrowable(javax.jdo.JDOCanRetryException.class); - constructStringObject(javax.jdo.JDOCanRetryException.class); - constructStringThrowableArrayObject(javax.jdo.JDOCanRetryException.class); - constructStringThrowableObject(javax.jdo.JDOCanRetryException.class); - } + /* test all constructors + * + */ + public void testConstructors() { + constructJDOCanRetryException(); + constructJDODataStoreException(); + constructJDODetachedFieldAccessException(); + constructJDOException(); + constructJDOFatalDataStoreException(); + constructJDOFatalException(); + constructJDOFatalInternalException(); + constructJDOFatalUserException(); + constructJDONullIdentityException(); + constructJDOObjectNotFoundException(); + constructJDOOptimisticVerificationException(); + constructJDOUnsupportedOptionException(); + constructJDOUserCallbackException(); + failOnError(); + } - protected void constructJDODataStoreException() { - constructEmpty(javax.jdo.JDODataStoreException.class); - constructString(javax.jdo.JDODataStoreException.class); - constructStringThrowableArray(javax.jdo.JDODataStoreException.class); - constructStringThrowable(javax.jdo.JDODataStoreException.class); - constructStringObject(javax.jdo.JDODataStoreException.class); - constructStringThrowableArrayObject(javax.jdo.JDODataStoreException.class); - constructStringThrowableObject(javax.jdo.JDODataStoreException.class); - } + protected void constructJDOCanRetryException() { + constructEmpty(javax.jdo.JDOCanRetryException.class); + constructString(javax.jdo.JDOCanRetryException.class); + constructStringThrowableArray(javax.jdo.JDOCanRetryException.class); + constructStringThrowable(javax.jdo.JDOCanRetryException.class); + constructStringObject(javax.jdo.JDOCanRetryException.class); + constructStringThrowableArrayObject(javax.jdo.JDOCanRetryException.class); + constructStringThrowableObject(javax.jdo.JDOCanRetryException.class); + } - protected void constructJDODetachedFieldAccessException() { - constructEmpty(javax.jdo.JDODetachedFieldAccessException.class); - constructString(javax.jdo.JDODetachedFieldAccessException.class); - constructStringThrowableArray(javax.jdo.JDODetachedFieldAccessException.class); - constructStringThrowable(javax.jdo.JDODetachedFieldAccessException.class); - constructStringObject(javax.jdo.JDODetachedFieldAccessException.class); - } + protected void constructJDODataStoreException() { + constructEmpty(javax.jdo.JDODataStoreException.class); + constructString(javax.jdo.JDODataStoreException.class); + constructStringThrowableArray(javax.jdo.JDODataStoreException.class); + constructStringThrowable(javax.jdo.JDODataStoreException.class); + constructStringObject(javax.jdo.JDODataStoreException.class); + constructStringThrowableArrayObject(javax.jdo.JDODataStoreException.class); + constructStringThrowableObject(javax.jdo.JDODataStoreException.class); + } - protected void constructJDOException() { - constructEmpty(javax.jdo.JDOException.class); - constructString(javax.jdo.JDOException.class); - constructStringThrowableArray(javax.jdo.JDOException.class); - constructStringThrowable(javax.jdo.JDOException.class); - constructStringObject(javax.jdo.JDOException.class); - constructStringThrowableArrayObject(javax.jdo.JDOException.class); - constructStringThrowableObject(javax.jdo.JDOException.class); - } + protected void constructJDODetachedFieldAccessException() { + constructEmpty(javax.jdo.JDODetachedFieldAccessException.class); + constructString(javax.jdo.JDODetachedFieldAccessException.class); + constructStringThrowableArray(javax.jdo.JDODetachedFieldAccessException.class); + constructStringThrowable(javax.jdo.JDODetachedFieldAccessException.class); + constructStringObject(javax.jdo.JDODetachedFieldAccessException.class); + } - protected void constructJDOFatalDataStoreException() { - constructEmpty(javax.jdo.JDOFatalDataStoreException.class); - constructString(javax.jdo.JDOFatalDataStoreException.class); - constructStringThrowableArray(javax.jdo.JDOFatalDataStoreException.class); - constructStringThrowable(javax.jdo.JDOFatalDataStoreException.class); - constructStringObject(javax.jdo.JDOFatalDataStoreException.class); - } + protected void constructJDOException() { + constructEmpty(javax.jdo.JDOException.class); + constructString(javax.jdo.JDOException.class); + constructStringThrowableArray(javax.jdo.JDOException.class); + constructStringThrowable(javax.jdo.JDOException.class); + constructStringObject(javax.jdo.JDOException.class); + constructStringThrowableArrayObject(javax.jdo.JDOException.class); + constructStringThrowableObject(javax.jdo.JDOException.class); + } - protected void constructJDOFatalException() { - constructEmpty(javax.jdo.JDOFatalException.class); - constructString(javax.jdo.JDOFatalException.class); - constructStringThrowableArray(javax.jdo.JDOFatalException.class); - constructStringThrowable(javax.jdo.JDOFatalException.class); - constructStringObject(javax.jdo.JDOFatalException.class); - constructStringThrowableArrayObject(javax.jdo.JDOFatalException.class); - constructStringThrowableObject(javax.jdo.JDOFatalException.class); - } + protected void constructJDOFatalDataStoreException() { + constructEmpty(javax.jdo.JDOFatalDataStoreException.class); + constructString(javax.jdo.JDOFatalDataStoreException.class); + constructStringThrowableArray(javax.jdo.JDOFatalDataStoreException.class); + constructStringThrowable(javax.jdo.JDOFatalDataStoreException.class); + constructStringObject(javax.jdo.JDOFatalDataStoreException.class); + } - protected void constructJDOFatalInternalException() { - constructEmpty(javax.jdo.JDOFatalInternalException.class); - constructString(javax.jdo.JDOFatalInternalException.class); - constructStringThrowableArray(javax.jdo.JDOFatalInternalException.class); - constructStringThrowable(javax.jdo.JDOFatalInternalException.class); - constructStringObject(javax.jdo.JDOFatalInternalException.class); - constructStringThrowableArrayObject(javax.jdo.JDOFatalInternalException.class); - constructStringThrowableObject(javax.jdo.JDOFatalInternalException.class); - } + protected void constructJDOFatalException() { + constructEmpty(javax.jdo.JDOFatalException.class); + constructString(javax.jdo.JDOFatalException.class); + constructStringThrowableArray(javax.jdo.JDOFatalException.class); + constructStringThrowable(javax.jdo.JDOFatalException.class); + constructStringObject(javax.jdo.JDOFatalException.class); + constructStringThrowableArrayObject(javax.jdo.JDOFatalException.class); + constructStringThrowableObject(javax.jdo.JDOFatalException.class); + } - protected void constructJDOFatalUserException() { - constructEmpty(javax.jdo.JDOFatalUserException.class); - constructString(javax.jdo.JDOFatalUserException.class); - constructStringThrowableArray(javax.jdo.JDOFatalUserException.class); - constructStringThrowable(javax.jdo.JDOFatalUserException.class); - constructStringObject(javax.jdo.JDOFatalUserException.class); - constructStringThrowableArrayObject(javax.jdo.JDOFatalUserException.class); - constructStringThrowableObject(javax.jdo.JDOFatalUserException.class); - } + protected void constructJDOFatalInternalException() { + constructEmpty(javax.jdo.JDOFatalInternalException.class); + constructString(javax.jdo.JDOFatalInternalException.class); + constructStringThrowableArray(javax.jdo.JDOFatalInternalException.class); + constructStringThrowable(javax.jdo.JDOFatalInternalException.class); + constructStringObject(javax.jdo.JDOFatalInternalException.class); + constructStringThrowableArrayObject(javax.jdo.JDOFatalInternalException.class); + constructStringThrowableObject(javax.jdo.JDOFatalInternalException.class); + } - protected void constructJDONullIdentityException() { - constructEmpty(javax.jdo.JDONullIdentityException.class); - constructString(javax.jdo.JDONullIdentityException.class); - constructStringThrowableArray(javax.jdo.JDONullIdentityException.class); - constructStringThrowable(javax.jdo.JDONullIdentityException.class); - constructStringObject(javax.jdo.JDONullIdentityException.class); - } + protected void constructJDOFatalUserException() { + constructEmpty(javax.jdo.JDOFatalUserException.class); + constructString(javax.jdo.JDOFatalUserException.class); + constructStringThrowableArray(javax.jdo.JDOFatalUserException.class); + constructStringThrowable(javax.jdo.JDOFatalUserException.class); + constructStringObject(javax.jdo.JDOFatalUserException.class); + constructStringThrowableArrayObject(javax.jdo.JDOFatalUserException.class); + constructStringThrowableObject(javax.jdo.JDOFatalUserException.class); + } - protected void constructJDOObjectNotFoundException() { - constructEmpty(javax.jdo.JDOObjectNotFoundException.class); - constructString(javax.jdo.JDOObjectNotFoundException.class); - constructStringThrowableArray(javax.jdo.JDOObjectNotFoundException.class); - constructStringObject(javax.jdo.JDOObjectNotFoundException.class); - constructStringThrowableArrayObject(javax.jdo.JDOObjectNotFoundException.class); - constructStringThrowableObject(javax.jdo.JDOObjectNotFoundException.class); - } + protected void constructJDONullIdentityException() { + constructEmpty(javax.jdo.JDONullIdentityException.class); + constructString(javax.jdo.JDONullIdentityException.class); + constructStringThrowableArray(javax.jdo.JDONullIdentityException.class); + constructStringThrowable(javax.jdo.JDONullIdentityException.class); + constructStringObject(javax.jdo.JDONullIdentityException.class); + } - protected void constructJDOOptimisticVerificationException() { - constructEmpty(javax.jdo.JDOOptimisticVerificationException.class); - constructString(javax.jdo.JDOOptimisticVerificationException.class); - constructStringThrowableArray(javax.jdo.JDOOptimisticVerificationException.class); - constructStringObject(javax.jdo.JDOOptimisticVerificationException.class); - constructStringThrowableArrayObject(javax.jdo.JDOOptimisticVerificationException.class); - constructStringThrowableObject(javax.jdo.JDOOptimisticVerificationException.class); - } + protected void constructJDOObjectNotFoundException() { + constructEmpty(javax.jdo.JDOObjectNotFoundException.class); + constructString(javax.jdo.JDOObjectNotFoundException.class); + constructStringThrowableArray(javax.jdo.JDOObjectNotFoundException.class); + constructStringObject(javax.jdo.JDOObjectNotFoundException.class); + constructStringThrowableArrayObject(javax.jdo.JDOObjectNotFoundException.class); + constructStringThrowableObject(javax.jdo.JDOObjectNotFoundException.class); + } - protected void constructJDOUnsupportedOptionException() { - constructEmpty(javax.jdo.JDOUnsupportedOptionException.class); - constructString(javax.jdo.JDOUnsupportedOptionException.class); - constructStringThrowableArray(javax.jdo.JDOUnsupportedOptionException.class); - constructStringThrowable(javax.jdo.JDOUnsupportedOptionException.class); - } + protected void constructJDOOptimisticVerificationException() { + constructEmpty(javax.jdo.JDOOptimisticVerificationException.class); + constructString(javax.jdo.JDOOptimisticVerificationException.class); + constructStringThrowableArray(javax.jdo.JDOOptimisticVerificationException.class); + constructStringObject(javax.jdo.JDOOptimisticVerificationException.class); + constructStringThrowableArrayObject(javax.jdo.JDOOptimisticVerificationException.class); + constructStringThrowableObject(javax.jdo.JDOOptimisticVerificationException.class); + } - protected void constructJDOUserCallbackException() { - constructEmpty(javax.jdo.JDOUserCallbackException.class); - constructString(javax.jdo.JDOUserCallbackException.class); - constructStringThrowableArray(javax.jdo.JDOUserCallbackException.class); - constructStringThrowable(javax.jdo.JDOUserCallbackException.class); - constructStringObject(javax.jdo.JDOUserCallbackException.class); - constructStringThrowableArrayObject(javax.jdo.JDOUserCallbackException.class); - constructStringThrowableObject(javax.jdo.JDOUserCallbackException.class); - } + protected void constructJDOUnsupportedOptionException() { + constructEmpty(javax.jdo.JDOUnsupportedOptionException.class); + constructString(javax.jdo.JDOUnsupportedOptionException.class); + constructStringThrowableArray(javax.jdo.JDOUnsupportedOptionException.class); + constructStringThrowable(javax.jdo.JDOUnsupportedOptionException.class); + } - protected void constructEmpty(Class clazz) { - construct(clazz, classArrayEmpty, objectArrayEmpty, null, null, null); - } + protected void constructJDOUserCallbackException() { + constructEmpty(javax.jdo.JDOUserCallbackException.class); + constructString(javax.jdo.JDOUserCallbackException.class); + constructStringThrowableArray(javax.jdo.JDOUserCallbackException.class); + constructStringThrowable(javax.jdo.JDOUserCallbackException.class); + constructStringObject(javax.jdo.JDOUserCallbackException.class); + constructStringThrowableArrayObject(javax.jdo.JDOUserCallbackException.class); + constructStringThrowableObject(javax.jdo.JDOUserCallbackException.class); + } - protected void constructString(Class clazz) { - construct(clazz, classArrayString, objectArrayString, message, null, null); - } + protected void constructEmpty(Class clazz) { + construct(clazz, classArrayEmpty, objectArrayEmpty, + null, null, null); + } - protected void constructStringObject(Class clazz) { - construct(clazz, classArrayStringObject, objectArrayStringObject, message, object, null); - } + protected void constructString(Class clazz) { + construct(clazz, classArrayString, objectArrayString, + message, null, null); + } - protected void constructStringThrowableArray(Class clazz) { - construct( - clazz, - classArrayStringThrowableArray, - objectArrayStringThrowableArray, - message, - null, - throwable); - } + protected void constructStringObject(Class clazz) { + construct(clazz, classArrayStringObject, objectArrayStringObject, + message, object, null); + } - protected void constructStringThrowable(Class clazz) { - construct( - clazz, classArrayStringThrowable, objectArrayStringThrowable, message, null, throwable); - } + protected void constructStringThrowableArray(Class clazz) { + construct(clazz, classArrayStringThrowableArray, objectArrayStringThrowableArray, + message, null, throwable); + } - protected void constructStringThrowableArrayObject(Class clazz) { - construct( - clazz, - classArrayStringThrowableArrayObject, - objectArrayStringThrowableArrayObject, - message, - object, - throwable); - } + protected void constructStringThrowable(Class clazz) { + construct(clazz, classArrayStringThrowable, objectArrayStringThrowable, + message, null, throwable); + } - protected void constructStringThrowableObject(Class clazz) { - construct( - clazz, - classArrayStringThrowableObject, - objectArrayStringThrowableObject, - message, - object, - throwable); - } + protected void constructStringThrowableArrayObject(Class clazz) { + construct(clazz, classArrayStringThrowableArrayObject, objectArrayStringThrowableArrayObject, + message, object, throwable); + } - protected void construct( - Class clazz, - Class[] formal, - Object[] params, - String expectedMessage, - Object expectedObject, - Throwable expectedCause) { - Constructor ctor = null; - try { - ctor = clazz.getConstructor(formal); - } catch (Throwable ex) { - appendMessage("Throwable caught during getConstructor. " + ex); - return; + protected void constructStringThrowableObject(Class clazz) { + construct(clazz, classArrayStringThrowableObject, objectArrayStringThrowableObject, + message, object, throwable); } - try { - throw (Throwable) ctor.newInstance(params); - } catch (javax.jdo.JDOException ex) { - // good catch - if (clazz.isInstance(ex)) { - Object actualObject = ex.getFailedObject(); - if (expectedObject != null && !expectedObject.equals(actualObject)) { - appendMessage( - "Wrong failed object for exception of " - + clazz - + "; Expected: " - + expectedObject - + " Actual: " - + actualObject); - } - String actualMessage = ex.getMessage(); - if (expectedMessage != null && !expectedMessage.equals(actualMessage)) { - appendMessage( - "Wrong message for exception of " - + clazz - + "; Expected: " - + expectedMessage - + " Actual: " - + actualMessage); + + protected void construct(Class clazz, Class[] formal, Object[] params, + String expectedMessage, Object expectedObject, Throwable expectedCause) { + Constructor ctor = null; + try { + ctor = clazz.getConstructor(formal); + } catch (Throwable ex) { + appendMessage ("Throwable caught during getConstructor. " + ex); + return; } - Throwable actualCause = ex.getCause(); - if (expectedCause != null && !expectedCause.equals(actualCause)) { - appendMessage( - "Wrong cause for exception of " - + clazz - + "; Expected: " - + expectedCause - + " Actual: " - + actualCause); + try { + throw (Throwable)ctor.newInstance(params); + } catch (javax.jdo.JDOException ex) { + // good catch + if (clazz.isInstance(ex)) { + Object actualObject = ex.getFailedObject(); + if (expectedObject != null && !expectedObject.equals(actualObject)) { + appendMessage("Wrong failed object for exception of " + + clazz + + "; Expected: " + expectedObject + + " Actual: " + actualObject); + } + String actualMessage = ex.getMessage(); + if (expectedMessage != null && !expectedMessage.equals(actualMessage)) { + appendMessage("Wrong message for exception of " + + clazz + + "; Expected: " + expectedMessage + + " Actual: " + actualMessage); + } + Throwable actualCause = ex.getCause(); + if (expectedCause != null && !expectedCause.equals(actualCause)) { + appendMessage("Wrong cause for exception of " + + clazz + + "; Expected: " + expectedCause + + " Actual: " + actualCause); + } + return; + } else { + appendMessage ("Wrong Throwable type caught for " + + clazz + + "; Expected:" + clazz + + " Actual: " + ex.getClass()); + } + } catch (Throwable t) { + appendMessage ("Wrong Throwable type caught for " + + clazz + + "; Expected:" + clazz + + " Actual: " + t.getClass()); } - return; - } else { - appendMessage( - "Wrong Throwable type caught for " - + clazz - + "; Expected:" - + clazz - + " Actual: " - + ex.getClass()); - } - } catch (Throwable t) { - appendMessage( - "Wrong Throwable type caught for " - + clazz - + "; Expected:" - + clazz - + " Actual: " - + t.getClass()); } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/fetchgroup/FetchGroupTest.java b/tck/src/main/java/org/apache/jdo/tck/api/fetchgroup/FetchGroupTest.java index da91a456d..d00ae2c10 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/fetchgroup/FetchGroupTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/fetchgroup/FetchGroupTest.java @@ -5,27 +5,30 @@ * 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 + * + * 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.jdo.tck.api.fetchgroup; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; + import java.util.Iterator; import java.util.Map; import java.util.Set; import javax.jdo.FetchGroup; + import javax.jdo.JDOException; import org.apache.jdo.tck.JDO_Test; + import org.apache.jdo.tck.pc.company.Address; import org.apache.jdo.tck.pc.company.Company; import org.apache.jdo.tck.pc.company.DentalInsurance; @@ -39,590 +42,535 @@ import org.apache.jdo.tck.pc.company.PartTimeEmployee; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.pc.company.Project; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * This class is an abstract superclass for the fetch plan tests. It contains methods useful for - * testing the behavior of the fetch plan. + * This class is an abstract superclass for the fetch plan tests. + * It contains methods useful for testing the behavior of the + * fetch plan. */ + public class FetchGroupTest extends JDO_Test { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(FetchGroupTest.class); - } - - /** All fetch groups in this PMF. */ - protected Set allPMFFetchGroups; - - /** - * Employee.java: private Date hiredate; private double weeklyhours; private DentalInsurance - * dentalInsurance; private MedicalInsurance medicalInsurance; private Department department; - * private Department fundingDept; private Employee manager; private Employee mentor; private - * Employee protege; private Employee hradvisor; private transient Set reviewedProjects = new - * HashSet(); // element-type is Project private transient Set projects = new HashSet(); // - * element-type is Project private transient Set team = new HashSet(); // element-type is Employee - * private transient Set hradvisees = new HashSet(); // element-type is Employee Person.java: - * private long personid; private String firstname; private String lastname; private String - * middlename; private Date birthdate; private Address address; private Map phoneNumbers = new - * HashMap(); - */ - protected String[] basicMembers = - new String[] { - "hiredate", "weeklyhours", "personid", "firstname", "lastname", "middlename", "birthdate" - }; - /** In org/apache/jdo/tck/pc/package.jdo, middlename is not in DFG */ - protected String[] defaultMembers = - new String[] {"hiredate", "weeklyhours", "personid", "firstname", "lastname", "birthdate"}; - - protected String[] allMembers = - new String[] { - "hiredate", - "weeklyhours", - "dentalInsurance", - "medicalInsurance", - "department", - "fundingDept", - "manager", - "mentor", - "protege", - "hradvisor", - "reviewedProjects", - "projects", - "team", - "hradvisees", - "personid", - "firstname", - "lastname", - "middlename", - "birthdate", - "address", - "phoneNumbers" - }; - /** Address address is of type Address and is a relationship */ - protected String[] relationshipMembers = - new String[] { - "dentalInsurance", - "medicalInsurance", - "department", - "fundingDept", - "manager", - "mentor", - "protege", - "hradvisor", - "reviewedProjects", - "projects", - "team", - "hradvisees", - "address" - }; - /** Map phoneNumbers is not a relationship but is multivalued */ - protected String[] multivaluedMembers = - new String[] {"reviewedProjects", "projects", "team", "hradvisees", "phoneNumbers"}; - - protected String[] allButMultivaluedMembers = - new String[] { - "hiredate", - "weeklyhours", - "dentalInsurance", - "medicalInsurance", - "department", - "fundingDept", - "manager", - "mentor", - "protege", - "hradvisor", - "personid", - "firstname", - "lastname", - "middlename", - "birthdate", - "address" - }; - - /** SetUp for test. */ - public void localSetUp() { - getPM(); // initialize pmf and pm fields - } - - public void testPMFGetFetchGroup() { - allPMFFetchGroups = pmf.getFetchGroups(); - Map unscopedFetchGroupMap = new HashMap(); - unscopedFetchGroupMap.put("Address+default", pmf.getFetchGroup(Address.class, "default")); - unscopedFetchGroupMap.put("Company+default", pmf.getFetchGroup(Company.class, "default")); - unscopedFetchGroupMap.put( - "DentalInsurance+default", pmf.getFetchGroup(DentalInsurance.class, "default")); - unscopedFetchGroupMap.put("Department+default", pmf.getFetchGroup(Department.class, "default")); - unscopedFetchGroupMap.put("Employee+default", pmf.getFetchGroup(Employee.class, "default")); - unscopedFetchGroupMap.put( - "FullTimeEmployee+default", pmf.getFetchGroup(FullTimeEmployee.class, "default")); - unscopedFetchGroupMap.put("Insurance+default", pmf.getFetchGroup(Insurance.class, "default")); - unscopedFetchGroupMap.put( - "MedicalInsurance+default", pmf.getFetchGroup(MedicalInsurance.class, "default")); - unscopedFetchGroupMap.put( - "PartTimeEmployee+default", pmf.getFetchGroup(PartTimeEmployee.class, "default")); - unscopedFetchGroupMap.put("Person+default", pmf.getFetchGroup(Person.class, "default")); - unscopedFetchGroupMap.put("Project+default", pmf.getFetchGroup(Project.class, "default")); - } - - public void testPMFGetFetchGroupHashCode() { - FetchGroup scoped = pm.getFetchGroup(Address.class, "default"); - FetchGroup unscoped = pmf.getFetchGroup(Address.class, "default"); - int actual = scoped.hashCode(); - int expected = unscoped.hashCode(); - assertEquals( - "Scoped hash code does not equal unscoped hash code;" - + "Expected: " - + expected - + " actual: " - + actual, - actual, - expected); - } - - public void testPMGetFetchGroupIdentical() { - FetchGroup scoped = pm.getFetchGroup(Address.class, "default"); - FetchGroup identical = pm.getFetchGroup(Address.class, "default"); - assertSame( - "Modifiable FetchGroup is not identical to modifiable FetchGroup;" - + "FetchGroup: " - + printFetchGroup(scoped) - + " identical: " - + printFetchGroup(identical), - scoped, - identical); - } - - public void testPMGetFetchGroupUnmodifiableNotIdentical() { - FetchGroup scoped = pm.getFetchGroup(Address.class, "default"); - scoped.setUnmodifiable(); - FetchGroup modifiable = pm.getFetchGroup(Address.class, "default"); - assertNotSame( - "Unmodifiable FetchGroup is identical to modifiable FetchGroup;" - + "\nunmodifiable: " - + printFetchGroup(scoped) - + "\n modifiable: " - + printFetchGroup(modifiable), - scoped, - modifiable); - } - - public void testPMFGetFetchGroupNotIdentical() { - FetchGroup first = pmf.getFetchGroup(Address.class, "default"); - FetchGroup second = pmf.getFetchGroup(Address.class, "default"); - assertNotSame( - "First FetchGroup is identical to second FetchGroup;" - + "\n first: " - + printFetchGroup(first) - + "\nsecond: " - + printFetchGroup(second), - first, - second); - } - - public void testPMGetFetchGroupEquals() { - FetchGroup unmodifiable = pm.getFetchGroup(Address.class, "default"); - unmodifiable.setUnmodifiable(); - FetchGroup modifiable = pm.getFetchGroup(Address.class, "default"); - assertEquals( - "Unmodifiable FetchGroup is not equal to modifiable FetchGroup;" - + "\nunmodifiable: " - + printFetchGroup(unmodifiable) - + "\n modifiable: " - + printFetchGroup(modifiable), - unmodifiable, - modifiable); - } - - public void testPMModifiable() { - FetchGroup scoped = pm.getFetchGroup(Address.class, "default"); - assertFalse( - "Scoped FetchGroup should be modifiable initially, but is unmodifiable.", - scoped.isUnmodifiable()); - scoped.setUnmodifiable(); - assertTrue( - "Scoped FetchGroup should be unmodifiable after setUnmodifiable, but is modifiable.", - scoped.isUnmodifiable()); - } - - public void testPMFModifiable() { - FetchGroup scoped = pmf.getFetchGroup(Address.class, "default"); - assertFalse( - "Unscoped FetchGroup should be modifiable initially, but is unmodifiable.", - scoped.isUnmodifiable()); - scoped.setUnmodifiable(); - assertTrue( - "Unscoped FetchGroup should be unmodifiable after setUnmodifiable, but is modifiable.", - scoped.isUnmodifiable()); - } - - public void testCategoriesClass() { - checkAddCategory(Employee.class, FetchGroup.ALL, allMembers); - checkAddCategory(Employee.class, FetchGroup.BASIC, basicMembers); - checkAddCategory(Employee.class, FetchGroup.DEFAULT, defaultMembers); - checkAddCategory(Employee.class, FetchGroup.RELATIONSHIP, relationshipMembers); - checkAddCategory(Employee.class, FetchGroup.MULTIVALUED, multivaluedMembers); - failOnError(); - } - - public void testCategoriesInterface() { - checkAddCategory(PIEmployee.class, FetchGroup.ALL, allMembers); - checkAddCategory(PIEmployee.class, FetchGroup.BASIC, basicMembers); - checkAddCategory(PIEmployee.class, FetchGroup.DEFAULT, defaultMembers); - checkAddCategory(PIEmployee.class, FetchGroup.RELATIONSHIP, relationshipMembers); - checkAddCategory(PIEmployee.class, FetchGroup.MULTIVALUED, multivaluedMembers); - failOnError(); - } - - public void testRemoveCategory() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testRemoveCategory"); - Set expectedSet = new HashSet(); - expectedSet.addAll(Arrays.asList(allButMultivaluedMembers)); - Set members = fg.getMembers(); - fg.addCategory(FetchGroup.ALL); - fg.removeCategory(FetchGroup.MULTIVALUED); - members = fg.getMembers(); - assertEquals( - "FetchGroup.addCategory(all).removeCategory(multivalued)" - + " should contain all but multivalued members.\n", - expectedSet, - members); - } - - public void testAddMember() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testAddMember"); - for (int i = 0; i < allMembers.length; ++i) { - String member = allMembers[i]; - fg.addMember(member); - Set members = fg.getMembers(); - assertTrue( - "FetchGroup should contain " + member + " but does not.\n" + printFetchGroup(fg), - members.contains(member)); - assertEquals( - "FetchGroup should contain " + i + 1 + "members, but does not; ", i + 1, members.size()); - } - } - - public void testAddMembers() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testAddMembers"); - fg.addMembers(multivaluedMembers); - fg.addMembers(allButMultivaluedMembers); - Set members = fg.getMembers(); - Set expectedSet = new HashSet(); - expectedSet.addAll(Arrays.asList(allMembers)); - assertEquals("FetchGroup should contain all members.\n", expectedSet, members); - } - - public void testRemoveMembers() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testRemoveMembers"); - fg.addMembers(allMembers); - fg.removeMembers(relationshipMembers); - Set members = fg.getMembers(); - Set expectedSet = new HashSet(); - expectedSet.addAll(Arrays.asList(basicMembers)); - expectedSet.add("phoneNumbers"); - assertEquals( - "FetchGroup should contain basic members " + "plus address plus phoneNumbers.\n", - expectedSet, - members); - fg.removeMembers(basicMembers); - members = fg.getMembers(); - expectedSet = new HashSet(); - expectedSet.add("phoneNumbers"); - assertEquals("FetchGroup should contain address plus phoneNumbers.\n", expectedSet, members); - } - - public void testRemoveMember() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testRemoveMember"); - fg.addCategory(FetchGroup.ALL); - for (int i = allMembers.length - 1; i >= 0; --i) { - String member = allMembers[i]; - fg.removeMember(member); - Set members = fg.getMembers(); - assertFalse( - "FetchGroup should not contain " + member + " but does.\n" + printFetchGroup(fg), - members.contains(member)); - assertEquals("FetchGroup should contain " + i + "members, but does not; ", i, members.size()); - } - } - - public void testRecursionDepth() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testRecursionDepth"); - fg.addMember("manager"); - int depth = fg.getRecursionDepth("manager"); - assertEquals( - "Initial recursion depth for manager should be 1." + printFetchGroup(fg), 1, depth); - fg.setRecursionDepth("manager", 64); - assertEquals( - "Recursion depth for manager should be 64." + printFetchGroup(fg), - 64, - fg.getRecursionDepth("manager")); - } - - public void testPostLoad() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testPostLoad"); - assertFalse( - "New FetchGroup should have post-load false; " + printFetchGroup(fg), fg.getPostLoad()); - fg.setPostLoad(true); - assertTrue( - "After setPostLoad(true) FetchGroup should have post-load true; " + printFetchGroup(fg), - fg.getPostLoad()); - fg.setPostLoad(false); - assertFalse( - "After setPostLoad, FetchGroup should have post-load false; " + printFetchGroup(fg), - fg.getPostLoad()); - } - - public void testUnmodifiableSetPostLoad() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testUnmodifiableSetPostLoad"); - fg.setUnmodifiable(); - try { - fg.setPostLoad(true); - fail("Unmodifiable FetchGroup should throw on setPostLoad."); - } catch (JDOException ex) { - // good catch! - } - } - - public void testUnmodifiableAddMember() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testUnmodifiableAddMember"); - fg.setUnmodifiable(); - try { - fg.addMember("hiredate"); - fail("Unmodifiable FetchGroup should throw on addMember."); - } catch (JDOException ex) { - // good catch! - } - } - - public void testUnmodifiableAddMembers() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testUnmodifiableAddMembers"); - fg.setUnmodifiable(); - try { - fg.addMembers(allMembers); - fail("Unmodifiable FetchGroup should throw on addMembers."); - } catch (JDOException ex) { - // good catch! - } - } - - public void testUnmodifiableRemoveMember() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testUnmodifiableRemoveMember"); - fg.addMembers(allMembers); - fg.setUnmodifiable(); - try { - fg.removeMember("hiredate"); - fail("Unmodifiable FetchGroup should throw on removeMember."); - } catch (JDOException ex) { - // good catch! - } - } - - public void testUnmodifiableRemoveMembers() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testUnmodifiableRemoveMembers"); - fg.addMembers(allMembers); - fg.setUnmodifiable(); - try { - fg.removeMembers(allMembers); - fail("Unmodifiable FetchGroup should throw on removeMembers."); - } catch (JDOException ex) { - // good catch! - } - } - - public void testUnmodifiableAddCategory() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testUnmodifiableAddCategory"); - fg.setUnmodifiable(); - try { - fg.addCategory(FetchGroup.ALL); - fail("Unmodifiable FetchGroup should throw on addCategory."); - } catch (JDOException ex) { - // good catch! - } - } - - public void testUnmodifiableRemoveCategory() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testUnmodifiableRemoveCategory"); - fg.addCategory(FetchGroup.ALL); - fg.setUnmodifiable(); - try { - fg.removeCategory(FetchGroup.ALL); - fail("Unmodifiable FetchGroup should throw on removeCategory."); - } catch (JDOException ex) { - // good catch! - } - } - - public void testUnmodifiableSetRecursionDepth() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testUnmodifiableSetRecursionDepth"); - fg.setUnmodifiable(); - try { - fg.setRecursionDepth("hiredate", 64); - fail("Unmodifiable FetchGroup should throw on setRecursionDepth."); - } catch (JDOException ex) { - // good catch! - } - } - - public void testUnmodifiableSetUnmodifiable() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testUnmodifiableSetUnmodifiable"); - fg.setUnmodifiable(); - fg.setUnmodifiable(); // should be ok - } - - public void testPMGetFetchGroupClassNotPersistenceCapable() { - try { - FetchGroup fg = - pm.getFetchGroup(Integer.class, "testPMGetFetchGroupClassNotPersistenceCapable"); - fail("getFetchGroup should throw on nonPersistenceCapable class."); - } catch (JDOException ex) { - // good catch! - } - } - - public void testPMGetFetchGroupInterfaceNotPersistenceCapable() { - try { - FetchGroup fg = - pm.getFetchGroup(IEmployee.class, "testPMGetFetchGroupInterfaceNotPersistenceCapable"); - fail("getFetchGroup should throw on nonPersistenceCapable interface."); - } catch (JDOException ex) { - // good catch! - } - } - - public void testPMFGetFetchGroupClassNotPersistenceCapable() { - try { - FetchGroup fg = - pmf.getFetchGroup( - Integer.class, - "testtestPMFGetFetchGroupClassNotPersistenceCapableGetFetchGroupClassNotPersistenceCapable"); - fail("getFetchGroup should throw on nonPersistenceCapable class."); - } catch (JDOException ex) { - // good catch! - } - } - - public void testPMFGetFetchGroupInterfaceNotPersistenceCapable() { - try { - FetchGroup fg = - pmf.getFetchGroup(IEmployee.class, "testPMFGetFetchGroupInterfaceNotPersistenceCapable"); - fail("getFetchGroup should throw on nonPersistenceCapable interface."); - } catch (JDOException ex) { - // good catch! - } - } - - public void testAddMemberNotAMember() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testAddMemberNotAMember"); - try { - fg.addMember("NotAMember"); - fail("FetchGroup should throw on addMember(NotAMember)."); - } catch (JDOException ex) { - // good catch! - } - } - - public void testAddMembersNotAMember() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testAddMembersNotAMember"); - try { - fg.addMembers(new String[] {"NotAMember"}); - fail("FetchGroup should throw on addMembers(NotAMember)."); - } catch (JDOException ex) { - // good catch! - } - } - - public void testRemoveMemberNotAMember() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testRemoveMemberNotAMember"); - fg.addCategory(FetchGroup.ALL); - try { - fg.removeMember("NotAMember"); - fail("FetchGroup should throw on removeMember(NotAMember)."); - } catch (JDOException ex) { - // good catch! - } - } - - public void testRemoveMembersNotAMember() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testRemoveMembersNotAMember"); - fg.addCategory(FetchGroup.ALL); - try { - fg.removeMembers(new String[] {"NotAMember"}); - fail("FetchGroup should throw on removeMembers(NotAMember)."); - } catch (JDOException ex) { - // good catch! - } - } - - public void testSetRecursionDepthNotAMember() { - FetchGroup fg = pm.getFetchGroup(Employee.class, "testSetRecursionDepthNotAMember"); - try { - fg.setRecursionDepth("NotAMember", 64); - fail("FetchGroup should throw on setRecursionDepth(NotAMember)."); - } catch (JDOException ex) { - // good catch! - } - } - - private void checkAddCategory(Class cls, String category, String[] expected) { - FetchGroup fg = pm.getFetchGroup(cls, "test" + count() + category); - Set expectedSet = new HashSet(); - expectedSet.addAll(Arrays.asList(expected)); - Set members = fg.getMembers(); - assertTrue("New FetchGroup should have no members; " + printFetchGroup(fg), members.isEmpty()); - fg.addCategory(category); - members = fg.getMembers(); - if (!members.equals(expectedSet)) { - appendMessage( - "FetchGroup(" - + cls.getName() - + ".addCategory(" - + category - + ") should contain\n" - + expectedSet - + " but contains\n" - + members); - } - } - - private String printFetchGroup(FetchGroup fg) { - StringBuffer sb = new StringBuffer("FetchGroup ("); - sb.append(fg.getType().isInterface() ? "interface: " : "class: "); - sb.append(fg.getType().getName()); - sb.append("; name: "); - sb.append(fg.getName()); - sb.append(fg.isUnmodifiable() ? "; unmodifiable" : "; modifiable"); - Set members = fg.getMembers(); - Iterator it = members.iterator(); - if (it.hasNext()) { - sb.append("; members: "); - String member = (String) it.next(); - formatMember(sb, fg, member); - } - while (it.hasNext()) { - sb.append(", "); - String member = (String) it.next(); - formatMember(sb, fg, member); - } - sb.append(")"); - return sb.toString(); - } - - protected void formatMember(StringBuffer sb, FetchGroup fg, String member) { - sb.append(member); - sb.append("["); - sb.append(fg.getRecursionDepth(member)); - sb.append("]"); - } - - /** Counter */ - protected int counter = 0; - - protected String count() { - return String.valueOf(counter++); - } + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(FetchGroupTest.class); + } + + /** All fetch groups in this PMF. */ + protected Set allPMFFetchGroups; + + /** + * Employee.java: + private Date hiredate; + private double weeklyhours; + private DentalInsurance dentalInsurance; + private MedicalInsurance medicalInsurance; + private Department department; + private Department fundingDept; + private Employee manager; + private Employee mentor; + private Employee protege; + private Employee hradvisor; + private transient Set reviewedProjects = new HashSet(); // element-type is Project + private transient Set projects = new HashSet(); // element-type is Project + private transient Set team = new HashSet(); // element-type is Employee + private transient Set hradvisees = new HashSet(); // element-type is Employee + * Person.java: + private long personid; + private String firstname; + private String lastname; + private String middlename; + private Date birthdate; + private Address address; + private Map phoneNumbers = new HashMap(); + */ + protected String[] basicMembers = new String[]{"hiredate", "weeklyhours", + "personid", "firstname", "lastname", "middlename", "birthdate"}; + /** In org/apache/jdo/tck/pc/package.jdo, middlename is not in DFG */ + protected String[] defaultMembers = new String[]{"hiredate", "weeklyhours", + "personid", "firstname", "lastname","birthdate"}; + protected String[] allMembers = new String[]{"hiredate", "weeklyhours", + "dentalInsurance", "medicalInsurance", "department", "fundingDept", + "manager", "mentor", "protege", "hradvisor", + "reviewedProjects", "projects", "team", "hradvisees", + "personid", "firstname", "lastname", "middlename", "birthdate", + "address", "phoneNumbers"}; + /** Address address is of type Address and is a relationship */ + protected String[] relationshipMembers = new String[]{ + "dentalInsurance", "medicalInsurance", "department", "fundingDept", + "manager", "mentor", "protege", "hradvisor", + "reviewedProjects", "projects", "team", "hradvisees", "address"}; + /** Map phoneNumbers is not a relationship but is multivalued */ + protected String[] multivaluedMembers = new String[]{ + "reviewedProjects", "projects", "team", "hradvisees", "phoneNumbers"}; + protected String[] allButMultivaluedMembers = new String[] + {"hiredate", "weeklyhours", + "dentalInsurance", "medicalInsurance", "department", "fundingDept", + "manager", "mentor", "protege", "hradvisor", + "personid", "firstname", "lastname", "middlename", "birthdate", + "address"}; + + /** + * SetUp for test. + */ + public void localSetUp() { + getPM(); // initialize pmf and pm fields + } + + public void testPMFGetFetchGroup() { + allPMFFetchGroups = pmf.getFetchGroups(); + Map unscopedFetchGroupMap = new HashMap(); + unscopedFetchGroupMap.put("Address+default", + pmf.getFetchGroup(Address.class, "default")); + unscopedFetchGroupMap.put("Company+default", + pmf.getFetchGroup(Company.class, "default")); + unscopedFetchGroupMap.put("DentalInsurance+default", + pmf.getFetchGroup(DentalInsurance.class, "default")); + unscopedFetchGroupMap.put("Department+default", + pmf.getFetchGroup(Department.class, "default")); + unscopedFetchGroupMap.put("Employee+default", + pmf.getFetchGroup(Employee.class, "default")); + unscopedFetchGroupMap.put("FullTimeEmployee+default", + pmf.getFetchGroup(FullTimeEmployee.class, "default")); + unscopedFetchGroupMap.put("Insurance+default", + pmf.getFetchGroup(Insurance.class, "default")); + unscopedFetchGroupMap.put("MedicalInsurance+default", + pmf.getFetchGroup(MedicalInsurance.class, "default")); + unscopedFetchGroupMap.put("PartTimeEmployee+default", + pmf.getFetchGroup(PartTimeEmployee.class, "default")); + unscopedFetchGroupMap.put("Person+default", + pmf.getFetchGroup(Person.class, "default")); + unscopedFetchGroupMap.put("Project+default", + pmf.getFetchGroup(Project.class, "default")); + } + + public void testPMFGetFetchGroupHashCode() { + FetchGroup scoped = pm.getFetchGroup(Address.class, "default"); + FetchGroup unscoped = pmf.getFetchGroup(Address.class, "default"); + int actual = scoped.hashCode(); + int expected = unscoped.hashCode(); + assertEquals("Scoped hash code does not equal unscoped hash code;" + + "Expected: " + expected + " actual: " + actual, + actual, expected); + } + + public void testPMGetFetchGroupIdentical() { + FetchGroup scoped = pm.getFetchGroup(Address.class, "default"); + FetchGroup identical = pm.getFetchGroup(Address.class, "default"); + assertSame("Modifiable FetchGroup is not identical to modifiable FetchGroup;" + + "FetchGroup: " + printFetchGroup(scoped) + + " identical: " + printFetchGroup(identical), + scoped, identical); + } + + public void testPMGetFetchGroupUnmodifiableNotIdentical() { + FetchGroup scoped = pm.getFetchGroup(Address.class, "default"); + scoped.setUnmodifiable(); + FetchGroup modifiable = pm.getFetchGroup(Address.class, "default"); + assertNotSame("Unmodifiable FetchGroup is identical to modifiable FetchGroup;" + + "\nunmodifiable: " + printFetchGroup(scoped) + + "\n modifiable: " + printFetchGroup(modifiable), + scoped, modifiable); + } + + public void testPMFGetFetchGroupNotIdentical() { + FetchGroup first = pmf.getFetchGroup(Address.class, "default"); + FetchGroup second = pmf.getFetchGroup(Address.class, "default"); + assertNotSame("First FetchGroup is identical to second FetchGroup;" + + "\n first: " + printFetchGroup(first) + + "\nsecond: " + printFetchGroup(second), + first, second); + } + + public void testPMGetFetchGroupEquals() { + FetchGroup unmodifiable = pm.getFetchGroup(Address.class, "default"); + unmodifiable.setUnmodifiable(); + FetchGroup modifiable = pm.getFetchGroup(Address.class, "default"); + assertEquals("Unmodifiable FetchGroup is not equal to modifiable FetchGroup;" + + "\nunmodifiable: " + printFetchGroup(unmodifiable) + + "\n modifiable: " + printFetchGroup(modifiable), + unmodifiable, modifiable); + } + + public void testPMModifiable() { + FetchGroup scoped = pm.getFetchGroup(Address.class, "default"); + assertFalse("Scoped FetchGroup should be modifiable initially, but is unmodifiable.", + scoped.isUnmodifiable()); + scoped.setUnmodifiable(); + assertTrue("Scoped FetchGroup should be unmodifiable after setUnmodifiable, but is modifiable.", + scoped.isUnmodifiable()); + } + + public void testPMFModifiable() { + FetchGroup scoped = pmf.getFetchGroup(Address.class, "default"); + assertFalse("Unscoped FetchGroup should be modifiable initially, but is unmodifiable.", + scoped.isUnmodifiable()); + scoped.setUnmodifiable(); + assertTrue("Unscoped FetchGroup should be unmodifiable after setUnmodifiable, but is modifiable.", + scoped.isUnmodifiable()); + } + + public void testCategoriesClass() { + checkAddCategory(Employee.class, FetchGroup.ALL, allMembers); + checkAddCategory(Employee.class, FetchGroup.BASIC, basicMembers); + checkAddCategory(Employee.class, FetchGroup.DEFAULT, defaultMembers); + checkAddCategory(Employee.class, FetchGroup.RELATIONSHIP, relationshipMembers); + checkAddCategory(Employee.class, FetchGroup.MULTIVALUED, multivaluedMembers); + failOnError(); + } + + public void testCategoriesInterface() { + checkAddCategory(PIEmployee.class, FetchGroup.ALL, allMembers); + checkAddCategory(PIEmployee.class, FetchGroup.BASIC, basicMembers); + checkAddCategory(PIEmployee.class, FetchGroup.DEFAULT, defaultMembers); + checkAddCategory(PIEmployee.class, FetchGroup.RELATIONSHIP, relationshipMembers); + checkAddCategory(PIEmployee.class, FetchGroup.MULTIVALUED, multivaluedMembers); + failOnError(); + } + + public void testRemoveCategory() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testRemoveCategory"); + Set expectedSet = new HashSet(); + expectedSet.addAll(Arrays.asList(allButMultivaluedMembers)); + Set members = fg.getMembers(); + fg.addCategory(FetchGroup.ALL); + fg.removeCategory(FetchGroup.MULTIVALUED); + members = fg.getMembers(); + assertEquals("FetchGroup.addCategory(all).removeCategory(multivalued)" + + " should contain all but multivalued members.\n", + expectedSet, members); + } + + public void testAddMember() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testAddMember"); + for (int i = 0; i < allMembers.length; ++i) { + String member = allMembers[i]; + fg.addMember(member); + Set members = fg.getMembers(); + assertTrue("FetchGroup should contain " + member + " but does not.\n" + + printFetchGroup(fg), + members.contains(member)); + assertEquals("FetchGroup should contain " + i+1 + + "members, but does not; ", + i+1, members.size()); + } + } + + public void testAddMembers() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testAddMembers"); + fg.addMembers(multivaluedMembers); + fg.addMembers(allButMultivaluedMembers); + Set members = fg.getMembers(); + Set expectedSet = new HashSet(); + expectedSet.addAll(Arrays.asList(allMembers)); + assertEquals("FetchGroup should contain all members.\n", + expectedSet, members); + } + + public void testRemoveMembers() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testRemoveMembers"); + fg.addMembers(allMembers); + fg.removeMembers(relationshipMembers); + Set members = fg.getMembers(); + Set expectedSet = new HashSet(); + expectedSet.addAll(Arrays.asList(basicMembers)); + expectedSet.add("phoneNumbers"); + assertEquals("FetchGroup should contain basic members " + + "plus address plus phoneNumbers.\n", + expectedSet, members); + fg.removeMembers(basicMembers); + members = fg.getMembers(); + expectedSet = new HashSet(); + expectedSet.add("phoneNumbers"); + assertEquals("FetchGroup should contain address plus phoneNumbers.\n", + expectedSet, members); + } + + public void testRemoveMember() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testRemoveMember"); + fg.addCategory(FetchGroup.ALL); + for (int i = allMembers.length - 1; i >= 0; --i) { + String member = allMembers[i]; + fg.removeMember(member); + Set members = fg.getMembers(); + assertFalse("FetchGroup should not contain " + member + " but does.\n" + + printFetchGroup(fg), + members.contains(member)); + assertEquals("FetchGroup should contain " + i + + "members, but does not; ", + i, members.size()); + } + } + + public void testRecursionDepth() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testRecursionDepth"); + fg.addMember("manager"); + int depth = fg.getRecursionDepth("manager"); + assertEquals("Initial recursion depth for manager should be 1." + + printFetchGroup(fg), + 1, depth); + fg.setRecursionDepth("manager", 64); + assertEquals("Recursion depth for manager should be 64." + + printFetchGroup(fg), + 64, fg.getRecursionDepth("manager")); + } + + public void testPostLoad() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testPostLoad"); + assertFalse("New FetchGroup should have post-load false; " + + printFetchGroup(fg), + fg.getPostLoad()); + fg.setPostLoad(true); + assertTrue("After setPostLoad(true) FetchGroup should have post-load true; " + + printFetchGroup(fg), + fg.getPostLoad()); + fg.setPostLoad(false); + assertFalse("After setPostLoad, FetchGroup should have post-load false; " + + printFetchGroup(fg), + fg.getPostLoad()); + } + + public void testUnmodifiableSetPostLoad() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testUnmodifiableSetPostLoad"); + fg.setUnmodifiable(); + try { + fg.setPostLoad(true); + fail("Unmodifiable FetchGroup should throw on setPostLoad."); + } catch(JDOException ex) { + // good catch! + } + } + + public void testUnmodifiableAddMember() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testUnmodifiableAddMember"); + fg.setUnmodifiable(); + try { + fg.addMember("hiredate"); + fail("Unmodifiable FetchGroup should throw on addMember."); + } catch(JDOException ex) { + // good catch! + } + } + + public void testUnmodifiableAddMembers() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testUnmodifiableAddMembers"); + fg.setUnmodifiable(); + try { + fg.addMembers(allMembers); + fail("Unmodifiable FetchGroup should throw on addMembers."); + } catch(JDOException ex) { + // good catch! + } + } + + public void testUnmodifiableRemoveMember() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testUnmodifiableRemoveMember"); + fg.addMembers(allMembers); + fg.setUnmodifiable(); + try { + fg.removeMember("hiredate"); + fail("Unmodifiable FetchGroup should throw on removeMember."); + } catch(JDOException ex) { + // good catch! + } + } + + public void testUnmodifiableRemoveMembers() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testUnmodifiableRemoveMembers"); + fg.addMembers(allMembers); + fg.setUnmodifiable(); + try { + fg.removeMembers(allMembers); + fail("Unmodifiable FetchGroup should throw on removeMembers."); + } catch(JDOException ex) { + // good catch! + } + } + + public void testUnmodifiableAddCategory() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testUnmodifiableAddCategory"); + fg.setUnmodifiable(); + try { + fg.addCategory(FetchGroup.ALL); + fail("Unmodifiable FetchGroup should throw on addCategory."); + } catch(JDOException ex) { + // good catch! + } + } + + public void testUnmodifiableRemoveCategory() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testUnmodifiableRemoveCategory"); + fg.addCategory(FetchGroup.ALL); + fg.setUnmodifiable(); + try { + fg.removeCategory(FetchGroup.ALL); + fail("Unmodifiable FetchGroup should throw on removeCategory."); + } catch(JDOException ex) { + // good catch! + } + } + + public void testUnmodifiableSetRecursionDepth() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testUnmodifiableSetRecursionDepth"); + fg.setUnmodifiable(); + try { + fg.setRecursionDepth("hiredate", 64); + fail("Unmodifiable FetchGroup should throw on setRecursionDepth."); + } catch(JDOException ex) { + // good catch! + } + } + + public void testUnmodifiableSetUnmodifiable() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testUnmodifiableSetUnmodifiable"); + fg.setUnmodifiable(); + fg.setUnmodifiable(); // should be ok + } + + public void testPMGetFetchGroupClassNotPersistenceCapable() { + try { + FetchGroup fg = pm.getFetchGroup(Integer.class, "testPMGetFetchGroupClassNotPersistenceCapable"); + fail("getFetchGroup should throw on nonPersistenceCapable class."); + } catch(JDOException ex) { + // good catch! + } + } + + public void testPMGetFetchGroupInterfaceNotPersistenceCapable() { + try { + FetchGroup fg = pm.getFetchGroup(IEmployee.class, "testPMGetFetchGroupInterfaceNotPersistenceCapable"); + fail("getFetchGroup should throw on nonPersistenceCapable interface."); + } catch(JDOException ex) { + // good catch! + } + } + + public void testPMFGetFetchGroupClassNotPersistenceCapable() { + try { + FetchGroup fg = pmf.getFetchGroup(Integer.class, "testtestPMFGetFetchGroupClassNotPersistenceCapableGetFetchGroupClassNotPersistenceCapable"); + fail("getFetchGroup should throw on nonPersistenceCapable class."); + } catch(JDOException ex) { + // good catch! + } + } + + public void testPMFGetFetchGroupInterfaceNotPersistenceCapable() { + try { + FetchGroup fg = pmf.getFetchGroup(IEmployee.class, "testPMFGetFetchGroupInterfaceNotPersistenceCapable"); + fail("getFetchGroup should throw on nonPersistenceCapable interface."); + } catch(JDOException ex) { + // good catch! + } + } + + public void testAddMemberNotAMember() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testAddMemberNotAMember"); + try { + fg.addMember("NotAMember"); + fail("FetchGroup should throw on addMember(NotAMember)."); + } catch(JDOException ex) { + // good catch! + } + } + + public void testAddMembersNotAMember() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testAddMembersNotAMember"); + try { + fg.addMembers(new String[]{"NotAMember"}); + fail("FetchGroup should throw on addMembers(NotAMember)."); + } catch(JDOException ex) { + // good catch! + } + } + + public void testRemoveMemberNotAMember() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testRemoveMemberNotAMember"); + fg.addCategory(FetchGroup.ALL); + try { + fg.removeMember("NotAMember"); + fail("FetchGroup should throw on removeMember(NotAMember)."); + } catch(JDOException ex) { + // good catch! + } + } + + public void testRemoveMembersNotAMember() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testRemoveMembersNotAMember"); + fg.addCategory(FetchGroup.ALL); + try { + fg.removeMembers(new String[]{"NotAMember"}); + fail("FetchGroup should throw on removeMembers(NotAMember)."); + } catch(JDOException ex) { + // good catch! + } + } + + public void testSetRecursionDepthNotAMember() { + FetchGroup fg = pm.getFetchGroup(Employee.class, "testSetRecursionDepthNotAMember"); + try { + fg.setRecursionDepth("NotAMember", 64); + fail("FetchGroup should throw on setRecursionDepth(NotAMember)."); + } catch(JDOException ex) { + // good catch! + } + } + + private void checkAddCategory(Class cls, String category, String[] expected) { + FetchGroup fg = pm.getFetchGroup(cls, "test" + count() + category); + Set expectedSet = new HashSet(); + expectedSet.addAll(Arrays.asList(expected)); + Set members = fg.getMembers(); + assertTrue("New FetchGroup should have no members; " + + printFetchGroup(fg), + members.isEmpty()); + fg.addCategory(category); + members = fg.getMembers(); + if (!members.equals(expectedSet)) { + appendMessage("FetchGroup(" + cls.getName() + + ".addCategory(" + category + ") should contain\n" + + expectedSet + " but contains\n" + members); + } + } + + private String printFetchGroup(FetchGroup fg) { + StringBuffer sb = new StringBuffer("FetchGroup ("); + sb.append(fg.getType().isInterface()?"interface: ":"class: "); + sb.append(fg.getType().getName()); + sb.append("; name: "); + sb.append(fg.getName()); + sb.append(fg.isUnmodifiable()?"; unmodifiable":"; modifiable"); + Set members = fg.getMembers(); + Iterator it = members.iterator(); + if (it.hasNext()) { + sb.append("; members: "); + String member = (String)it.next(); + formatMember(sb, fg, member); + } + while (it.hasNext()) { + sb.append(", "); + String member = (String)it.next(); + formatMember(sb, fg, member); + } + sb.append(")"); + return sb.toString(); + } + + protected void formatMember(StringBuffer sb, FetchGroup fg, String member) { + sb.append(member); + sb.append("["); + sb.append(fg.getRecursionDepth(member)); + sb.append("]"); + } + + /** Counter */ + protected int counter = 0; + protected String count() { + return String.valueOf(counter++); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/AbstractInstanceLifecycleListener.java b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/AbstractInstanceLifecycleListener.java index d13dae2da..148e6cb66 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/AbstractInstanceLifecycleListener.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/AbstractInstanceLifecycleListener.java @@ -5,455 +5,513 @@ * 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 + * + * 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.jdo.tck.api.instancecallbacks; import java.util.ArrayList; import java.util.List; + import javax.jdo.JDOHelper; + +import javax.jdo.listener.InstanceLifecycleEvent; +import javax.jdo.listener.InstanceLifecycleListener; import javax.jdo.listener.AttachLifecycleListener; import javax.jdo.listener.ClearLifecycleListener; import javax.jdo.listener.CreateLifecycleListener; import javax.jdo.listener.DeleteLifecycleListener; import javax.jdo.listener.DetachLifecycleListener; import javax.jdo.listener.DirtyLifecycleListener; -import javax.jdo.listener.InstanceLifecycleEvent; import javax.jdo.listener.LoadLifecycleListener; import javax.jdo.listener.StoreLifecycleListener; + import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.PCPoint; + +import org.apache.jdo.tck.util.BatchTestRunner; + + /** - * Title: Abstract test AbstractInstanceLifecycleListener
    - * Keywords: LifeCycleListener lifecycle listener callback
    - * Assertion IDs: A12.15-1, A12.15-2, A12.15-3, A12.15-4, A12.15-5, A12.15-6, A12.15-7, - * A12.15-8, A12.15-9, A12.15-10, A12.15-11, A12.15-12, A12.15-13, A12.15-14,
    - * Assertion Description: A12.15-1 void postCreate(InstanceLifecycleEvent event); This - * method is called whenever a persistent instance is created, during makePersistent. It is called - * after the instance transitions to persistent-new. A12.15-2 void postLoad(InstanceLifecycleEvent - * event); This method is called whenever a persistent instance is loaded. It is called after the - * jdoPostLoad method is invoked on the instance. A12.15-3 void preStore(InstanceLifecycleEvent - * event); This method is called whenever a persistent instance is stored, for example during flush - * or commit. It is called before the jdoPreStore method is invoked on the instance. A12.15-4 void - * postStore(InstanceLifecycleEvent event); This method is called whenever a persistent instance is - * stored, for example during flush or commit. It is called after the jdoPreStore method is invoked - * on the instance. An object identity for a per?sistent-new instance must have been assigned to the - * instance when this callback is invoked. A12.15-5 void preClear(InstanceLifecycleEvent event); - * This method is called whenever a persistent instance is cleared, for example during - * afterCompletion. It is called before the jdoPreClear method is invoked on the instance. A12.15-6 - * void postClear(InstanceLifecycleEvent event); This method is called whenever a persistent - * instance is cleared, for example during afterCom?pletion. It is called after the jdoPreClear - * method is invoked on the instance and the fields have been cleared by the JDO implementation. - * A12.15-7 void preDelete(InstanceLifecycleEvent event); This method is called whenever a - * persistent instance is deleted, during deletePersistent. It is called before the state transition - * and before the jdoPreDelete method is invoked on the instance. A12.15-8 void - * postDelete(InstanceLifecycleEvent event); This method is called whenever a persistent instance is - * deleted, during deletePersistent. It is called after the jdoPreDelete method is invoked on the - * instance and after the state transition. A12.15-9 void preDirty(InstanceLifecycleEvent event); - * This method is called whenever a persistent clean instance is first made dirty, during an - * operation that modifies the value of a persistent or transactional field. It is called before the - * field value is changed. A12.15-10 void postDirty(InstanceLifecycleEvent event); This method is - * called whenever a persistent clean instance is first made dirty, during an operation that - * modifies the value of a persistent or transactional field. It is called after the field value was - * changed. A12.15-11 void preDetach(InstanceLifecycleEvent event); This method is called before a - * persistent instance is copied for detachment. A12.15-12 void postDetach(InstanceLifecycleEvent - * event); This method is called whenever a persistent instance is copied for detachment. The source - * instance is the detached copy; the target instance is the persistent instance. A12.15-13 void - * preAttach(InstanceLifecycleEvent event); This method is called before a detached instance is - * attached. The source instance is the detached instance]. A12.15-14 void - * postAttach(InstanceLifecycleEvent event); This method is called after a detached instance is - * attached. The source instance is the corresponding persistent instance in the cache; the target - * instance is the detached instance. + * Title: Abstract test AbstractInstanceLifecycleListener + *
    + * Keywords: LifeCycleListener lifecycle listener callback + *
    + * Assertion IDs: A12.15-1, A12.15-2, A12.15-3, A12.15-4, A12.15-5, + * A12.15-6, A12.15-7, A12.15-8, A12.15-9, A12.15-10, A12.15-11, A12.15-12, + * A12.15-13, A12.15-14, + *
    + * Assertion Description: + * A12.15-1 void postCreate(InstanceLifecycleEvent event); + * This method is called whenever a persistent instance is created, + * during makePersistent. It is called after the instance transitions + * to persistent-new. + * A12.15-2 void postLoad(InstanceLifecycleEvent event); + * This method is called whenever a persistent instance is loaded. + * It is called after the jdoPostLoad method is invoked on the instance. + * A12.15-3 void preStore(InstanceLifecycleEvent event); + * This method is called whenever a persistent instance is stored, + * for example during flush or commit. It is called + * before the jdoPreStore method is invoked on the instance. + * A12.15-4 void postStore(InstanceLifecycleEvent event); + * This method is called whenever a persistent instance is stored, + * for example during flush or commit. It is called + * after the jdoPreStore method is invoked on the instance. + * An object identity for a per?sistent-new instance must have been assigned + * to the instance when this callback is invoked. + * A12.15-5 void preClear(InstanceLifecycleEvent event); + * This method is called whenever a persistent instance + * is cleared, for example during afterCompletion. It is called + * before the jdoPreClear method is invoked on the instance. + * A12.15-6 void postClear(InstanceLifecycleEvent event); + * This method is called whenever a persistent instance + * is cleared, for example during afterCom?pletion. It is called + * after the jdoPreClear method is invoked on the instance and the fields + * have been cleared by the JDO implementation. + * A12.15-7 void preDelete(InstanceLifecycleEvent event); + * This method is called whenever a persistent instance + * is deleted, during deletePersistent. It is called before + * the state transition and before the jdoPreDelete method + * is invoked on the instance. + * A12.15-8 void postDelete(InstanceLifecycleEvent event); + * This method is called whenever a persistent instance + * is deleted, during deletePersistent. It is called + * after the jdoPreDelete method is invoked on the instance + * and after the state transition. + * A12.15-9 void preDirty(InstanceLifecycleEvent event); + * This method is called whenever a persistent clean instance + * is first made dirty, during an operation that modifies + * the value of a persistent or transactional field. It is called + * before the field value is changed. + * A12.15-10 void postDirty(InstanceLifecycleEvent event); + * This method is called whenever a persistent clean instance + * is first made dirty, during an operation that modifies + * the value of a persistent or transactional field. It is called + * after the field value was changed. + * A12.15-11 void preDetach(InstanceLifecycleEvent event); + * This method is called before a persistent instance is copied + * for detachment. + * A12.15-12 void postDetach(InstanceLifecycleEvent event); + * This method is called whenever a persistent instance is copied + * for detachment. + * The source instance is the detached copy; the target instance + * is the persistent instance. + * A12.15-13 void preAttach(InstanceLifecycleEvent event); + * This method is called before a detached instance is attached. + * The source instance is the detached instance]. + * A12.15-14 void postAttach(InstanceLifecycleEvent event); + * This method is called after a detached instance is attached. + * The source instance is the corresponding persistent instance in the cache; + * the target instance is the detached instance. * - *

    This is the abstract base class for the lifecycle listener test classes. It contains - * constants, variables, and methods used by each listener test class. This class implements the - * setup and teardown methods used by each concrete test class. + * This is the abstract base class for the lifecycle listener test classes. + * It contains constants, variables, and methods used by each listener test + * class. This class implements the setup and teardown methods used by each + * concrete test class. * - *

    This class also includes the listener base class that is extended by each specific listener. + * This class also includes the listener base class that is extended by + * each specific listener. * - *

    The strategy of each test case is the same. A specific listener is implemented that responds - * only to events for that specific test; a specific persistence-capable class is also implemented, - * that responds only to callbacks for the specific test. A sequence of operations that stimulates - * the callbacks is executed. During these operations, listener events and callbacks are collected - * by the listener instance. Finally, the actual events and callbacks that were collected are - * analyzed and differences are reported. + * The strategy of each test case is the same. A specific listener is + * implemented that responds only to events for that specific test; a + * specific persistence-capable class is also implemented, that responds + * only to callbacks for the specific test. A sequence of operations that + * stimulates the callbacks is executed. During these operations, listener + * events and callbacks are collected by the listener instance. Finally, + * the actual events and callbacks that were collected are analyzed and + * differences are reported. */ + public abstract class AbstractInstanceLifecycleListener extends JDO_Test { - /** */ - protected static final String ASSERTION1_FAILED = - "Assertion A12.15-1 (TestInstanceLifecycleListenerCreate) failed: "; - - protected static final String ASSERTION2_FAILED = - "Assertion A12.15-2 (TestInstanceLifecycleListener) failed: "; - protected static final String ASSERTION3_FAILED = - "Assertion A12.15-3 (TestInstanceLifecycleListener) failed: "; - protected static final String ASSERTION4_FAILED = - "Assertion A12.15-4 (TestInstanceLifecycleListener) failed: "; - protected static final String ASSERTION5_FAILED = - "Assertion A12.15-5 (TestInstanceLifecycleListener) failed: "; - protected static final String ASSERTION6_FAILED = - "Assertion A12.15-6 (TestInstanceLifecycleListener) failed: "; - protected static final String ASSERTION7_FAILED = - "Assertion A12.15-7 (TestInstanceLifecycleListenerDelete) failed: "; - protected static final String ASSERTION8_FAILED = - "Assertion A12.15-8 (TestInstanceLifecycleListenerDelete) failed: "; - protected static final String ASSERTION9_FAILED = - "Assertion A12.15-9 (TestInstanceLifecycleListener) failed: "; - protected static final String ASSERTION10_FAILED = - "Assertion A12.15-10 (TestInstanceLifecycleListener) failed: "; - protected static final String ASSERTION11_FAILED = - "Assertion A12.15-11 (TestInstanceLifecycleListener) failed: "; - protected static final String ASSERTION12_FAILED = - "Assertion A12.15-12 (TestInstanceLifecycleListener) failed: "; - protected static final String ASSERTION13_FAILED = - "Assertion A12.15-13 (TestInstanceLifecycleListener) failed: "; - protected static final String ASSERTION14_FAILED = - "Assertion A12.15-14 (TestInstanceLifecycleListener) failed: "; - - /** - * The listener to be used for the test. This method is implemented by the subclasses to use the - * proper listener. - * - * @return listener - */ - protected abstract InstanceLifecycleListenerImpl getListener(); - - /** - * The classes to be used for the test. This method is implemented by the subclasses to use the - * proper classes. The classes returned by this method are used for two purposes: they are used to - * register listeners; and they are used as the teardown classes whose instances are removed from - * the datastore at the end of the test. - * - * @return classes - */ - protected abstract Class[] getPersistentClasses(); - - /** Register a new InstanceLifecycleListenerImpl with the PersistenceManager. */ - protected void addListener() { - getPM(); - pm.addInstanceLifecycleListener(getListener(), getPersistentClasses()); - } - - /** Unregister the InstanceLifecycleListenerImpl with the PersistenceManager. */ - protected void removeListener() { - getPM(); - pm.removeInstanceLifecycleListener(getListener()); - } - - /** Set up for lifecycle tests: Register the LifecycleListener; add PCPoint to tearDownClasses. */ - protected void localSetUp() { - addListener(); - addTearDownClass(getPersistentClasses()); - } - - /** Clean up after lifecycle tests: Unregister the LifecycleListener. */ - protected void localTearDown() { - removeListener(); // no callbacks for teardown - super.localTearDown(); - } - - /** - * The LifeCycleListener to be registered with the PersistenceManager. This is the base class that - * is extended by each test. - */ - protected abstract static class InstanceLifecycleListenerImpl - implements AttachLifecycleListener, - ClearLifecycleListener, - CreateLifecycleListener, - DeleteLifecycleListener, - DetachLifecycleListener, - DirtyLifecycleListener, - LoadLifecycleListener, - StoreLifecycleListener { - - protected InstanceLifecycleListenerImpl() {} - - protected Object expectedSource = null; - protected Object expectedTarget = null; - - public void setExpectedSource(Object source) { - expectedSource = source; - } + /** */ + protected static final String ASSERTION1_FAILED = + "Assertion A12.15-1 (TestInstanceLifecycleListenerCreate) failed: "; + protected static final String ASSERTION2_FAILED = + "Assertion A12.15-2 (TestInstanceLifecycleListener) failed: "; + protected static final String ASSERTION3_FAILED = + "Assertion A12.15-3 (TestInstanceLifecycleListener) failed: "; + protected static final String ASSERTION4_FAILED = + "Assertion A12.15-4 (TestInstanceLifecycleListener) failed: "; + protected static final String ASSERTION5_FAILED = + "Assertion A12.15-5 (TestInstanceLifecycleListener) failed: "; + protected static final String ASSERTION6_FAILED = + "Assertion A12.15-6 (TestInstanceLifecycleListener) failed: "; + protected static final String ASSERTION7_FAILED = + "Assertion A12.15-7 (TestInstanceLifecycleListenerDelete) failed: "; + protected static final String ASSERTION8_FAILED = + "Assertion A12.15-8 (TestInstanceLifecycleListenerDelete) failed: "; + protected static final String ASSERTION9_FAILED = + "Assertion A12.15-9 (TestInstanceLifecycleListener) failed: "; + protected static final String ASSERTION10_FAILED = + "Assertion A12.15-10 (TestInstanceLifecycleListener) failed: "; + protected static final String ASSERTION11_FAILED = + "Assertion A12.15-11 (TestInstanceLifecycleListener) failed: "; + protected static final String ASSERTION12_FAILED = + "Assertion A12.15-12 (TestInstanceLifecycleListener) failed: "; + protected static final String ASSERTION13_FAILED = + "Assertion A12.15-13 (TestInstanceLifecycleListener) failed: "; + protected static final String ASSERTION14_FAILED = + "Assertion A12.15-14 (TestInstanceLifecycleListener) failed: "; + + /** + * The listener to be used for the test. This method is implemented + * by the subclasses to use the proper listener. + * @return listener + */ + protected abstract InstanceLifecycleListenerImpl getListener(); + + /** + * The classes to be used for the test. This method is implemented + * by the subclasses to use the proper classes. The classes returned + * by this method are used for two purposes: they are used to register + * listeners; and they are used as the teardown classes whose instances + * are removed from the datastore at the end of the test. + * @return classes + */ + protected abstract Class[] getPersistentClasses(); - public void setExpectedTarget(Object target) { - expectedTarget = target; + /** + * Register a new InstanceLifecycleListenerImpl with the + * PersistenceManager. + */ + protected void addListener() { + getPM(); + pm.addInstanceLifecycleListener(getListener(), getPersistentClasses()); } - + /** - * This is the list names of locations for listener events and callbacks. Each instance of an - * event or callback has a specific name that is associated with the value. The values are used - * during collection of events and both names and values are used for reporting results. + * Unregister the InstanceLifecycleListenerImpl with the + * PersistenceManager. */ - private static List locations = new ArrayList(); + protected void removeListener() { + getPM(); + pm.removeInstanceLifecycleListener(getListener()); + } - /** - * These are indexes into the sequence array. Each index represents the position in the sequence - * array for the corresponding callback or listener event. + /** + * Set up for lifecycle tests: + * Register the LifecycleListener; add PCPoint to tearDownClasses. */ - public static final int PRE_ATTACH_CALLBACK; - - public static final int POST_ATTACH_CALLBACK; - public static final int PRE_ATTACH_LISTENER; - public static final int POST_ATTACH_LISTENER; - public static final int PRE_CLEAR_CALLBACK; - public static final int PRE_CLEAR_LISTENER; - public static final int POST_CLEAR_LISTENER; - public static final int POST_CREATE_LISTENER; - public static final int PRE_DELETE_CALLBACK; - public static final int PRE_DELETE_LISTENER; - public static final int POST_DELETE_LISTENER; - public static final int PRE_DETACH_CALLBACK; - public static final int POST_DETACH_CALLBACK; - public static final int PRE_DETACH_LISTENER; - public static final int POST_DETACH_LISTENER; - public static final int PRE_DIRTY_LISTENER; - public static final int POST_DIRTY_LISTENER; - public static final int POST_LOAD_CALLBACK; - public static final int POST_LOAD_LISTENER; - public static final int PRE_STORE_CALLBACK; - public static final int PRE_STORE_LISTENER; - public static final int POST_STORE_LISTENER; - - /* - * Initialize the list of names and the associated values. For each - * listener event and callback, add the name and then assign the value. + protected void localSetUp() { + addListener(); + addTearDownClass(getPersistentClasses()); + } + + /** + * Clean up after lifecycle tests: + * Unregister the LifecycleListener. */ - static { - int index = 0; - locations.add("PRE_ATTACH_LISTENER"); - PRE_ATTACH_LISTENER = index++; - locations.add("PRE_ATTACH_CALLBACK"); - PRE_ATTACH_CALLBACK = index++; - locations.add("POST_ATTACH_CALLBACK"); - POST_ATTACH_CALLBACK = index++; - locations.add("POST_ATTACH_LISTENER"); - POST_ATTACH_LISTENER = index++; - locations.add("PRE_CLEAR_LISTENER"); - PRE_CLEAR_LISTENER = index++; - locations.add("PRE_CLEAR_CALLBACK"); - PRE_CLEAR_CALLBACK = index++; - locations.add("POST_CLEAR_LISTENER"); - POST_CLEAR_LISTENER = index++; - locations.add("POST_CREATE_LISTENER"); - POST_CREATE_LISTENER = index++; - locations.add("PRE_DELETE_LISTENER"); - PRE_DELETE_LISTENER = index++; - locations.add("PRE_DELETE_CALLBACK"); - PRE_DELETE_CALLBACK = index++; - locations.add("POST_DELETE_LISTENER"); - POST_DELETE_LISTENER = index++; - locations.add("POST_DETACH_CALLBACK"); - POST_DETACH_CALLBACK = index++; - locations.add("PRE_DETACH_LISTENER"); - PRE_DETACH_LISTENER = index++; - locations.add("PRE_DETACH_CALLBACK"); - PRE_DETACH_CALLBACK = index++; - locations.add("POST_DETACH_LISTENER"); - POST_DETACH_LISTENER = index++; - locations.add("PRE_DIRTY_LISTENER"); - PRE_DIRTY_LISTENER = index++; - locations.add("POST_DIRTY_LISTENER"); - POST_DIRTY_LISTENER = index++; - locations.add("POST_LOAD_CALLBACK"); - POST_LOAD_CALLBACK = index++; - locations.add("POST_LOAD_LISTENER"); - POST_LOAD_LISTENER = index++; - locations.add("PRE_STORE_LISTENER"); - PRE_STORE_LISTENER = index++; - locations.add("PRE_STORE_CALLBACK"); - PRE_STORE_CALLBACK = index++; - locations.add("POST_STORE_LISTENER"); - POST_STORE_LISTENER = index++; + protected void localTearDown() { + removeListener(); // no callbacks for teardown + super.localTearDown(); } - private int[] actual = new int[locations.size()]; + /** + * The LifeCycleListener to be registered with the + * PersistenceManager. This is the base class that is extended + * by each test. + */ + protected abstract static class InstanceLifecycleListenerImpl + implements AttachLifecycleListener, ClearLifecycleListener, + CreateLifecycleListener, DeleteLifecycleListener, + DetachLifecycleListener, DirtyLifecycleListener, + LoadLifecycleListener, StoreLifecycleListener { + + protected InstanceLifecycleListenerImpl() {} + + protected Object expectedSource = null; + protected Object expectedTarget = null; + + public void setExpectedSource(Object source) { + expectedSource = source; + } - /** Track the current sequence of callbacks. */ - private int current = 0; + public void setExpectedTarget(Object target) { + expectedTarget = target; + } - public void notifyEvent(int event) { - actual[event] = ++current; - } + /** + * This is the list names of locations for listener events and + * callbacks. Each instance of an event or callback has a specific + * name that is associated with the value. The values + * are used during collection of events and both names and values + * are used for reporting results. + */ + private static List locations = new ArrayList(); + + /** These are indexes into the sequence array. Each index + * represents the position in the sequence array for the + * corresponding callback or listener event. + */ + public static final int PRE_ATTACH_CALLBACK; + public static final int POST_ATTACH_CALLBACK; + public static final int PRE_ATTACH_LISTENER; + public static final int POST_ATTACH_LISTENER; + public static final int PRE_CLEAR_CALLBACK; + public static final int PRE_CLEAR_LISTENER; + public static final int POST_CLEAR_LISTENER; + public static final int POST_CREATE_LISTENER; + public static final int PRE_DELETE_CALLBACK; + public static final int PRE_DELETE_LISTENER; + public static final int POST_DELETE_LISTENER; + public static final int PRE_DETACH_CALLBACK; + public static final int POST_DETACH_CALLBACK; + public static final int PRE_DETACH_LISTENER; + public static final int POST_DETACH_LISTENER; + public static final int PRE_DIRTY_LISTENER; + public static final int POST_DIRTY_LISTENER; + public static final int POST_LOAD_CALLBACK; + public static final int POST_LOAD_LISTENER; + public static final int PRE_STORE_CALLBACK; + public static final int PRE_STORE_LISTENER; + public static final int POST_STORE_LISTENER; + + /* + * Initialize the list of names and the associated values. For each + * listener event and callback, add the name and then assign the value. + */ + static { + int index = 0; + locations.add("PRE_ATTACH_LISTENER"); + PRE_ATTACH_LISTENER = index++; + locations.add("PRE_ATTACH_CALLBACK"); + PRE_ATTACH_CALLBACK = index++; + locations.add("POST_ATTACH_CALLBACK"); + POST_ATTACH_CALLBACK = index++; + locations.add("POST_ATTACH_LISTENER"); + POST_ATTACH_LISTENER = index++; + locations.add("PRE_CLEAR_LISTENER"); + PRE_CLEAR_LISTENER = index++; + locations.add("PRE_CLEAR_CALLBACK"); + PRE_CLEAR_CALLBACK = index++; + locations.add("POST_CLEAR_LISTENER"); + POST_CLEAR_LISTENER = index++; + locations.add("POST_CREATE_LISTENER"); + POST_CREATE_LISTENER = index++; + locations.add("PRE_DELETE_LISTENER"); + PRE_DELETE_LISTENER = index++; + locations.add("PRE_DELETE_CALLBACK"); + PRE_DELETE_CALLBACK = index++; + locations.add("POST_DELETE_LISTENER"); + POST_DELETE_LISTENER = index++; + locations.add("POST_DETACH_CALLBACK"); + POST_DETACH_CALLBACK = index++; + locations.add("PRE_DETACH_LISTENER"); + PRE_DETACH_LISTENER = index++; + locations.add("PRE_DETACH_CALLBACK"); + PRE_DETACH_CALLBACK = index++; + locations.add("POST_DETACH_LISTENER"); + POST_DETACH_LISTENER = index++; + locations.add("PRE_DIRTY_LISTENER"); + PRE_DIRTY_LISTENER = index++; + locations.add("POST_DIRTY_LISTENER"); + POST_DIRTY_LISTENER = index++; + locations.add("POST_LOAD_CALLBACK"); + POST_LOAD_CALLBACK = index++; + locations.add("POST_LOAD_LISTENER"); + POST_LOAD_LISTENER = index++; + locations.add("PRE_STORE_LISTENER"); + PRE_STORE_LISTENER = index++; + locations.add("PRE_STORE_CALLBACK"); + PRE_STORE_CALLBACK = index++; + locations.add("POST_STORE_LISTENER"); + POST_STORE_LISTENER = index++; + } - /** - * Initialize the expected ordering of callbacks and listeners. Each entry in the sequence is - * one of the PRE_ or POST_XXX_LISTENER or _CALLBACK above. The order in the sequence is the - * expected calling order. - */ - private static int[] newExpected(int[] sequence) { - int order = 0; - int[] result = new int[locations.size()]; - for (int i = 0; i < sequence.length; ++i) { - result[sequence[i]] = ++order; - } - return result; - } + private int[] actual = new int[locations.size()]; - /** The error message buffer to report exceptions. */ - protected StringBuffer messages = new StringBuffer(); - - protected void checkEventType(String where, int expected, int actual) { - if (expected != actual) { - messages.append( - where - + "wrong event type: " - + "expected <" - + expected - + ">, actual <" - + actual - + ">\n"); - } - } + /** Track the current sequence of callbacks. + */ + private int current = 0; - protected void checkEventSource(String where, Object eventSource) { - if (expectedSource != eventSource) { - messages.append( - where - + "wrong event source: " - + "expected <" - + expectedSource - + ">, actual <" - + eventSource - + ">\n"); - } - } + public void notifyEvent(int event) { + actual[event] = ++current; + } - protected void checkEventTarget(String where, Object eventTarget) { - if (expectedTarget != eventTarget) { - messages.append( - where - + "wrong event target: " - + "expected <" - + expectedTarget - + ">, actual <" - + eventTarget - + ">\n"); - } - } + /** + * Initialize the expected ordering of callbacks and listeners. + * Each entry in the sequence is one of the PRE_ or POST_XXX_LISTENER + * or _CALLBACK above. The order in the sequence is the expected + * calling order. + */ + private static int[] newExpected(int[] sequence) { + int order = 0; + int[] result = new int[locations.size()]; + for (int i = 0; i < sequence.length; ++i) { + result[sequence[i]] = ++order; + } + return result; + } - protected void checkTrue(String where, boolean condition) { - if (!condition) { - messages.append(where + "was not true.\n"); - } - } + /** + * The error message buffer to report exceptions. + */ + protected StringBuffer messages = new StringBuffer(); + + protected void checkEventType(String where, int expected, int actual) { + if (expected != actual) { + messages.append(where + "wrong event type: " + + "expected <" + expected + + ">, actual <" + actual + ">\n"); + } + } + + protected void checkEventSource(String where, Object eventSource) { + if (expectedSource != eventSource) { + messages.append(where + "wrong event source: " + + "expected <" + expectedSource + + ">, actual <" + eventSource + ">\n"); + } + } - protected void checkSame(String where, Object expected, Object actual) { - if (expected != actual) { - messages.append(where + "expected <" + expected + ">, actual <" + actual + ">\n"); - } - } + protected void checkEventTarget(String where, Object eventTarget) { + if (expectedTarget != eventTarget) { + messages.append(where + "wrong event target: " + + "expected <" + expectedTarget + + ">, actual <" + eventTarget + ">\n"); + } + } - protected void checkPersistent(String where, Object obj) { - if (!JDOHelper.isPersistent(obj)) { - messages.append(where + "object should be persistent.\n"); - } - } + protected void checkTrue(String where, boolean condition) { + if (!condition) { + messages.append(where + "was not true.\n"); + } + } - protected void checkNotPersistent(String where, Object obj) { - if (JDOHelper.isPersistent(obj)) { - messages.append(where + "object should not be persistent.\n"); - } - } + protected void checkSame(String where, + Object expected, Object actual) { + if (expected != actual) { + messages.append(where + + "expected <" + expected + + ">, actual <" + actual + ">\n"); + } + } - protected void checkDirty(String where, Object obj) { - if (!JDOHelper.isDirty(obj)) { - messages.append(where + "object should be dirty.\n"); - } - } + protected void checkPersistent(String where, Object obj) { + if (!JDOHelper.isPersistent(obj)) { + messages.append(where + "object should be persistent.\n"); + } + } - protected void checkNotDirty(String where, Object obj) { - if (JDOHelper.isDirty(obj)) { - messages.append(where + "object should not be dirty.\n"); - } - } + protected void checkNotPersistent(String where, Object obj) { + if (JDOHelper.isPersistent(obj)) { + messages.append(where + "object should not be persistent.\n"); + } + } - protected void checkNew(String where, Object obj) { - if (!JDOHelper.isNew(obj)) { - messages.append(where + "object should be new.\n"); - } - } + protected void checkDirty(String where, Object obj) { + if (!JDOHelper.isDirty(obj)) { + messages.append(where + "object should be dirty.\n"); + } + } - protected void checkNotNew(String where, Object obj) { - if (JDOHelper.isNew(obj)) { - messages.append(where + "object should not be new.\n"); - } - } + protected void checkNotDirty(String where, Object obj) { + if (JDOHelper.isDirty(obj)) { + messages.append(where + "object should not be dirty.\n"); + } + } - protected void checkDeleted(String where, Object obj) { - if (!JDOHelper.isDeleted(obj)) { - messages.append(where + "object should be deleted.\n"); - } - } + protected void checkNew(String where, Object obj) { + if (!JDOHelper.isNew(obj)) { + messages.append(where + "object should be new.\n"); + } + } - protected void checkNotDeleted(String where, Object obj) { - if (JDOHelper.isDeleted(obj)) { - messages.append(where + "object should not be deleted.\n"); - } - } + protected void checkNotNew(String where, Object obj) { + if (JDOHelper.isNew(obj)) { + messages.append(where + "object should not be new.\n"); + } + } - /** - * Verify the actual sequence of callbacks and listeners against the expected. Each of the - * expected and actual are int arrays in which each listener and callback have one position in - * the array and the value of the array at that position is the order, starting with 1, of the - * callback. If the callback or listener was never invoked, the value is 0. - * - * @param where where - * @param expected expected - */ - public void verifyCallbacks(String where, int[] expected) { - int[] expectedSequence = newExpected(expected); - for (int index = 0; index < locations.size(); ++index) { - if (expectedSequence[index] != actual[index]) { - messages.append( - "\nSequence verification failed for " - + locations.get(index) - + "; expected: <" - + expectedSequence[index] - + "> actual: <" - + actual[index] - + ">\n"); - } - } - if (messages.length() > 0) { - fail(where + "\n" + messages.toString()); - } - } + protected void checkDeleted(String where, Object obj) { + if (!JDOHelper.isDeleted(obj)) { + messages.append(where + "object should be deleted.\n"); + } + } - public void postAttach(InstanceLifecycleEvent event) {} + protected void checkNotDeleted(String where, Object obj) { + if (JDOHelper.isDeleted(obj)) { + messages.append(where + "object should not be deleted.\n"); + } + } - public void postClear(InstanceLifecycleEvent event) {} + /** + * Verify the actual sequence of callbacks and listeners + * against the expected. Each of the expected and actual are + * int arrays in which each listener and callback have one + * position in the array and the value of the array at that + * position is the order, starting with 1, of the callback. + * If the callback or listener was never invoked, the value + * is 0. + * @param where where + * @param expected expected + */ + public void verifyCallbacks(String where, int[] expected) { + int[] expectedSequence = newExpected(expected); + for (int index = 0; index < locations.size(); ++index) { + if (expectedSequence[index] != actual[index]) { + messages.append("\nSequence verification failed for " + + locations.get(index) + + "; expected: <" + expectedSequence[index] + + "> actual: <" + actual[index] + + ">\n"); + } + } + if (messages.length() > 0) { + fail(where + "\n" + messages.toString()); + } + } - public void postCreate(InstanceLifecycleEvent event) {} + public void postAttach(InstanceLifecycleEvent event) { + } - public void postDelete(InstanceLifecycleEvent event) {} + public void postClear(InstanceLifecycleEvent event) { + } - public void postDetach(InstanceLifecycleEvent event) {} + public void postCreate(InstanceLifecycleEvent event) { + } - public void postDirty(InstanceLifecycleEvent event) {} + public void postDelete(InstanceLifecycleEvent event) { + } - public void postLoad(InstanceLifecycleEvent event) {} + public void postDetach(InstanceLifecycleEvent event) { + } - public void postStore(InstanceLifecycleEvent event) {} + public void postDirty(InstanceLifecycleEvent event) { + } - public void preAttach(InstanceLifecycleEvent event) {} + public void postLoad(InstanceLifecycleEvent event) { + } - public void preClear(InstanceLifecycleEvent event) {} + public void postStore(InstanceLifecycleEvent event) { + } - public void preDelete(InstanceLifecycleEvent event) {} + public void preAttach(InstanceLifecycleEvent event) { + } - public void preDetach(InstanceLifecycleEvent event) {} + public void preClear(InstanceLifecycleEvent event) { + } - public void preDirty(InstanceLifecycleEvent event) {} + public void preDelete(InstanceLifecycleEvent event) { + } + + public void preDetach(InstanceLifecycleEvent event) { + } - public void preStore(InstanceLifecycleEvent event) {} - } + public void preDirty(InstanceLifecycleEvent event) { + } + + public void preStore(InstanceLifecycleEvent event) { + } + + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/AccessOtherInstancesInPrestore.java b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/AccessOtherInstancesInPrestore.java index fcd22e7ab..08a283c69 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/AccessOtherInstancesInPrestore.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/AccessOtherInstancesInPrestore.java @@ -5,37 +5,47 @@ * 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 + * + * 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.jdo.tck.api.instancecallbacks; import java.util.Date; + import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Access Other Instances In Prestore Method
    - * Keywords: instancecallbacks
    - * Assertion ID: A10.2-3.
    - * Assertion Description: The context in which a call is made to jdoPreStore() - * allows access to the PersistenceManager and other persistent JDO instances. + *Title: Access Other Instances In Prestore Method + *
    + *Keywords: instancecallbacks + *
    + *Assertion ID: A10.2-3. + *
    + *Assertion Description: +The context in which a call is made to jdoPreStore() allows access +to the PersistenceManager and other persistent JDO instances. + */ + /* * Within jdoPreStore(), locate the PersistenceManager (JDOHelper.getPersistenceManager()) and use it * to call currentTransaction(). Use the Transaction to call isActive() and verify active. These operations * are done to help verify that we had access to a usable PersistenceManager. * - * Create objects. + * Create objects. * Within jdoPreStore(), capture information about objects referenced. * This includes a String, Date and Collection attribute. * After commit() verify jdoPreStore() called and found what expected. @@ -43,66 +53,60 @@ public class AccessOtherInstancesInPrestore extends TestParts { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A10.2-3 (AccessOtherInstancesInPrestore) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(AccessOtherInstancesInPrestore.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - protected void localSetUp() { - addTearDownClass(InstanceCallbackClass.class); - } - - /** */ - public void test() { - pm = getPM(); - Transaction t = pm.currentTransaction(); - - InstanceCallbackClass.initializeStaticsForTest(); - - InstanceCallbackClass.performPreStoreTests = true; - t.begin(); - // Create primaryObj which has a collection (children) of two objects and references another - // (nextObj). - // None of the other objects have a non-empty collection. The also all have nextObj set to - // null. - Date createTime = new Date(); - InstanceCallbackClass secondaryObj = - new InstanceCallbackClass("secondaryObj", createTime, 2, 2.0, (short) -1, '2', null); - InstanceCallbackClass primaryObj = - new InstanceCallbackClass("primaryObj", createTime, 1, 1.0, (short) 3, '1', secondaryObj); - InstanceCallbackClass childA = - new InstanceCallbackClass("childA", createTime, 3, 3.0, (short) -2, '3', null); - InstanceCallbackClass childB = - new InstanceCallbackClass("childB", createTime, 4, 4.0, (short) -3, '4', null); - pm.makePersistent(primaryObj); - primaryObj.addChild(childA); - primaryObj.addChild(childB); - t.commit(); - - // check that jdoPreStore provides access to instances for primaryObj - checkInstances(ASSERTION_FAILED, "jdoStore instance access: ", 1, "secondaryObj", 2, 7); - // check that jdoPreStore provides access to PersistenceManager for primaryObj - checkPMAccess(ASSERTION_FAILED, "jdoPreDelete PersistenceManager access: ", 1, true); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A10.2-3 (AccessOtherInstancesInPrestore) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(AccessOtherInstancesInPrestore.class); + } - // check that jdoPreStore provides access to instances for secondaryObj - checkInstances(ASSERTION_FAILED, "jdoStore instance access: ", 2, null, 0, 0); - // check that jdoPreStore provides access to PersistenceManager for secondaryObj - checkPMAccess(ASSERTION_FAILED, "jdoPreDelete PersistenceManager access: ", 2, true); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + protected void localSetUp() { + addTearDownClass(InstanceCallbackClass.class); + } + + /** */ + public void test() { + pm = getPM(); + Transaction t = pm.currentTransaction(); + + InstanceCallbackClass.initializeStaticsForTest(); - // There is no need to check childA or childB. They are no different than secondaryObj. + InstanceCallbackClass.performPreStoreTests = true; + t.begin(); + // Create primaryObj which has a collection (children) of two objects and references another (nextObj). + // None of the other objects have a non-empty collection. The also all have nextObj set to null. + Date createTime = new Date(); + InstanceCallbackClass secondaryObj = new InstanceCallbackClass("secondaryObj", createTime, 2, 2.0, (short)-1, '2', null); + InstanceCallbackClass primaryObj = new InstanceCallbackClass("primaryObj", createTime, 1, 1.0, (short)3, '1', secondaryObj); + InstanceCallbackClass childA = new InstanceCallbackClass("childA", createTime, 3, 3.0, (short)-2, '3', null); + InstanceCallbackClass childB = new InstanceCallbackClass("childB", createTime, 4, 4.0, (short)-3, '4', null); + pm.makePersistent(primaryObj); + primaryObj.addChild(childA); + primaryObj.addChild(childB); + t.commit(); - pm.close(); - pm = null; - } + // check that jdoPreStore provides access to instances for primaryObj + checkInstances(ASSERTION_FAILED, "jdoStore instance access: ", 1, "secondaryObj", 2, 7); + // check that jdoPreStore provides access to PersistenceManager for primaryObj + checkPMAccess(ASSERTION_FAILED, "jdoPreDelete PersistenceManager access: ", 1, true); + + // check that jdoPreStore provides access to instances for secondaryObj + checkInstances(ASSERTION_FAILED, "jdoStore instance access: ", 2, null, 0, 0); + // check that jdoPreStore provides access to PersistenceManager for secondaryObj + checkPMAccess(ASSERTION_FAILED, "jdoPreDelete PersistenceManager access: ", 2, true); + + // There is no need to check childA or childB. They are no different than secondaryObj. + + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/AccessingFieldsInPredelete.java b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/AccessingFieldsInPredelete.java index 62b27e877..31260665a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/AccessingFieldsInPredelete.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/AccessingFieldsInPredelete.java @@ -5,35 +5,44 @@ * 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 + * + * 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.jdo.tck.api.instancecallbacks; import java.util.Date; + import javax.jdo.JDODataStoreException; import javax.jdo.JDOUserException; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Accessing Fields In Predelete
    - * Keywords: instancecallbacks
    - * Assertion ID: A10.4-2.
    - * Assertion Description: Access to field values within a call to jdoPreDelete() - * of a class implementing InstanceCallbacks are valid. + *Title: Accessing Fields In Predelete + *
    + *Keywords: instancecallbacks + *
    + *Assertion ID: A10.4-2. + *
    + *Assertion Description: + Access to field values within a call to jdoPreDelete() + of a class implementing InstanceCallbacks are valid. + */ /* - * Define a PersistenceCapable class containing some primative types, + * Define a PersistenceCapable class containing some primative types, * a Date attribute, a String attribute, * one reference to an object of the same class and one * Set collection attribute containing two instances of objects of this class. @@ -50,168 +59,127 @@ */ public class AccessingFieldsInPredelete extends TestParts { - - private static final String ASSERTION_FAILED = - "Assertion A10.4-2 (AccessingFieldsInPredelete) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(AccessingFieldsInPredelete.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(InstanceCallbackClass.class); - } - - /** */ - public void test() { - pm = getPM(); - Transaction t = pm.currentTransaction(); - - InstanceCallbackClass.initializeStaticsForTest(); - - InstanceCallbackClass.performPreDeleteTests = true; - t.begin(); - Date createTime = new Date(); - InstanceCallbackClass secondaryObj = - new InstanceCallbackClass("secondaryObj", createTime, 2, 2.0, (short) -1, '2', null); - InstanceCallbackClass primaryObj = - new InstanceCallbackClass("primaryObj", createTime, 1, 1.0, (short) 3, '1', secondaryObj); - InstanceCallbackClass childA = - new InstanceCallbackClass("childA", createTime, 3, 3.0, (short) -2, '3', null); - InstanceCallbackClass childB = - new InstanceCallbackClass("childB", createTime, 4, 4.0, (short) -3, '4', null); - pm.makePersistent(primaryObj); - pm.makePersistent(secondaryObj); - pm.makePersistent(childA); - pm.makePersistent(childB); - primaryObj.addChild(childA); - primaryObj.addChild(childB); - Object secondaryObjId = pm.getObjectId(secondaryObj); - Object primaryObjId = pm.getObjectId(primaryObj); - Object childAId = pm.getObjectId(childA); - Object childBId = pm.getObjectId(childB); - t.commit(); - - t.begin(); - primaryObj = (InstanceCallbackClass) pm.getObjectById(primaryObjId, true); - pm.deletePersistent(primaryObj); - t.commit(); - - t.begin(); - try { - primaryObj = (InstanceCallbackClass) pm.getObjectById(primaryObjId, true); - fail(ASSERTION_FAILED, "primaryObj deleted but getObjectById() on its Id succeeded."); - } catch (JDOUserException e) { - // expected one of these exceptions - } catch (JDODataStoreException e) { - // expected one of these exceptions + + private static final String ASSERTION_FAILED = + "Assertion A10.4-2 (AccessingFieldsInPredelete) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(AccessingFieldsInPredelete.class); } - - // check that jdoPreDelete() provided proper access to the attributes in primaryObj - checkFieldValues( - ASSERTION_FAILED, - "jdoPreDelete attribute access: ", - 1, - "primaryObj", - createTime, - 1.0, - (short) 3, - '1'); - checkInstances(ASSERTION_FAILED, "jdoPreDelete instance access: ", 1, "secondaryObj", 2, 7); - checkPMAccess(ASSERTION_FAILED, "jdoPreDelete PersistenceManager access: ", 1, true); - - // check that secondaryObj had jdoPreDelete() called on it and provided proper access to its - // attributes. - checkFieldValues( - ASSERTION_FAILED, - "jdoPreDelete attribute access: ", - 2, - "secondaryObj", - createTime, - 2.0, - (short) -1, - '2'); - checkInstances(ASSERTION_FAILED, "jdoPreDelete instance access: ", 2, null, 0, 0); - checkPMAccess(ASSERTION_FAILED, "jdoPreDelete PersistenceManager access: ", 2, true); - - // check that secondaryObj was deleted. - try { - secondaryObj = (InstanceCallbackClass) pm.getObjectById(secondaryObjId, true); - fail( - ASSERTION_FAILED, - "secondaryObj should have been deleted but getObjectById() on its Id succeeded."); - } catch (JDOUserException e) { - // expected one of these exceptions - } catch (JDODataStoreException e) { - // expected one of these exceptions + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(InstanceCallbackClass.class); } - - // check that first added member of Set had jdoPreDelete() called on it and provided proper - // access to its attributes. - checkFieldValues( - ASSERTION_FAILED, - "jdoPreDelete attribute access: ", - 3, - "childA", - createTime, - 3.0, - (short) -2, - '3'); - checkInstances(ASSERTION_FAILED, "jdoPreDelete instance access: ", 3, null, 0, 0); - checkPMAccess(ASSERTION_FAILED, "jdoPreDelete PersistenceManager access: ", 3, true); - - // verify first added member of Set was actaully deleted. - try { - childA = (InstanceCallbackClass) pm.getObjectById(childAId, true); - fail( - ASSERTION_FAILED, - "First added member of Set primaryObj.children should have been deleted but getObjectById() on its Id succeeded."); - } catch (JDOUserException e) { - // expected one of these exceptions - } catch (JDODataStoreException e) { - // expected one of these exceptions + + /** */ + public void test() { + pm = getPM(); + Transaction t = pm.currentTransaction(); + + InstanceCallbackClass.initializeStaticsForTest(); + + InstanceCallbackClass.performPreDeleteTests = true; + t.begin(); + Date createTime = new Date(); + InstanceCallbackClass secondaryObj = new InstanceCallbackClass("secondaryObj", createTime, 2, 2.0, (short)-1, '2', null); + InstanceCallbackClass primaryObj = new InstanceCallbackClass("primaryObj", createTime, 1, 1.0, (short)3, '1', secondaryObj); + InstanceCallbackClass childA = new InstanceCallbackClass("childA", createTime, 3, 3.0, (short)-2, '3', null); + InstanceCallbackClass childB = new InstanceCallbackClass("childB", createTime, 4, 4.0, (short)-3, '4', null); + pm.makePersistent(primaryObj); + pm.makePersistent(secondaryObj); + pm.makePersistent(childA); + pm.makePersistent(childB); + primaryObj.addChild(childA); + primaryObj.addChild(childB); + Object secondaryObjId = pm.getObjectId(secondaryObj); + Object primaryObjId = pm.getObjectId(primaryObj); + Object childAId = pm.getObjectId(childA); + Object childBId = pm.getObjectId(childB); + t.commit(); + + t.begin(); + primaryObj = (InstanceCallbackClass)pm.getObjectById(primaryObjId, true); + pm.deletePersistent(primaryObj); + t.commit(); + + t.begin(); + try { + primaryObj = (InstanceCallbackClass)pm.getObjectById(primaryObjId, true); + fail(ASSERTION_FAILED, "primaryObj deleted but getObjectById() on its Id succeeded."); + } catch (JDOUserException e) { + // expected one of these exceptions + } catch (JDODataStoreException e) { + // expected one of these exceptions + } + + // check that jdoPreDelete() provided proper access to the attributes in primaryObj + checkFieldValues(ASSERTION_FAILED, "jdoPreDelete attribute access: ", 1, "primaryObj", createTime, 1.0, (short)3, '1'); + checkInstances(ASSERTION_FAILED, "jdoPreDelete instance access: ", 1, "secondaryObj", 2, 7); + checkPMAccess(ASSERTION_FAILED, "jdoPreDelete PersistenceManager access: ", 1, true); + + // check that secondaryObj had jdoPreDelete() called on it and provided proper access to its attributes. + checkFieldValues(ASSERTION_FAILED, "jdoPreDelete attribute access: ", 2, "secondaryObj", createTime, 2.0, (short)-1, '2'); + checkInstances(ASSERTION_FAILED, "jdoPreDelete instance access: ", 2, null, 0, 0); + checkPMAccess(ASSERTION_FAILED, "jdoPreDelete PersistenceManager access: ", 2, true); + + // check that secondaryObj was deleted. + try { + secondaryObj = (InstanceCallbackClass)pm.getObjectById(secondaryObjId, true); + fail(ASSERTION_FAILED, "secondaryObj should have been deleted but getObjectById() on its Id succeeded."); + } catch (JDOUserException e) { + // expected one of these exceptions + } catch (JDODataStoreException e) { + // expected one of these exceptions + } + + // check that first added member of Set had jdoPreDelete() called on it and provided proper access to its attributes. + checkFieldValues(ASSERTION_FAILED, "jdoPreDelete attribute access: ", 3, "childA", createTime, 3.0, (short)-2, '3'); + checkInstances(ASSERTION_FAILED, "jdoPreDelete instance access: ", 3, null, 0, 0); + checkPMAccess(ASSERTION_FAILED, "jdoPreDelete PersistenceManager access: ", 3, true); + + // verify first added member of Set was actaully deleted. + try { + childA = (InstanceCallbackClass)pm.getObjectById(childAId, true); + fail(ASSERTION_FAILED, "First added member of Set primaryObj.children should have been deleted but getObjectById() on its Id succeeded."); + } catch (JDOUserException e) { + // expected one of these exceptions + } catch (JDODataStoreException e) { + // expected one of these exceptions + } + + // check that the second added member of Set did not have jdoPreDelete() called on it and it was not deleted. + if(InstanceCallbackClass.processedIndex[4] == true) { + fail(ASSERTION_FAILED, "jdoPreDelete() called on childB--it was not deleted."); + } + + try { + childB = (InstanceCallbackClass)pm.getObjectById(childBId, true); + if( childB == null ){ + if (debug) logger.debug("childB object is null"); + } else { + if( childB.name == null ) + if (debug) logger.debug("childB.name is null"); + } + if(!childB.name.equals("childB")) { + fail(ASSERTION_FAILED, "childB.name should be \"childB\". Instead its value is \"" + childB.name + "\"."); + } + } catch (JDOUserException e) { + fail(ASSERTION_FAILED, "Second added member of Set primaryObj.children should exist but getObjectById() got JDOUserException " + e); + } catch (JDODataStoreException e) { + fail(ASSERTION_FAILED, "Second added member of Set primaryObj.children should exist but getObjectById() got JDODataStoreException " + e); + } + t.rollback(); + pm.close(); + pm = null; } - - // check that the second added member of Set did not have jdoPreDelete() called on it and it was - // not deleted. - if (InstanceCallbackClass.processedIndex[4] == true) { - fail(ASSERTION_FAILED, "jdoPreDelete() called on childB--it was not deleted."); - } - - try { - childB = (InstanceCallbackClass) pm.getObjectById(childBId, true); - if (childB == null) { - if (debug) logger.debug("childB object is null"); - } else { - if (childB.name == null) if (debug) logger.debug("childB.name is null"); - } - if (!childB.name.equals("childB")) { - fail( - ASSERTION_FAILED, - "childB.name should be \"childB\". Instead its value is \"" + childB.name + "\"."); - } - } catch (JDOUserException e) { - fail( - ASSERTION_FAILED, - "Second added member of Set primaryObj.children should exist but getObjectById() got JDOUserException " - + e); - } catch (JDODataStoreException e) { - fail( - ASSERTION_FAILED, - "Second added member of Set primaryObj.children should exist but getObjectById() got JDODataStoreException " - + e); - } - t.rollback(); - pm.close(); - pm = null; - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPostload.java b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPostload.java index 611dd8e50..0aa115fd9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPostload.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPostload.java @@ -5,34 +5,42 @@ * 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 + * + * 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.jdo.tck.api.instancecallbacks; import javax.jdo.JDODataStoreException; import javax.jdo.JDOUserException; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackNonPersistFdsClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Calling InstanceCallbacks Postload Method
    - * Keywords: instancecallbacks
    - * Assertion ID: A10.1-1.
    - * Assertion Description: The jdoPostLoad() method of a class implementing - * InstanceCallbacks is called after the default fetch group values are loaded from the - * StateManager into the instance. + *Title: Calling InstanceCallbacks Postload Method + *
    + *Keywords: instancecallbacks + *
    + *Assertion ID: A10.1-1. + *
    + *Assertion Description: +The jdoPostLoad() method of a class implementing +InstanceCallbacks is called after the default fetch +group values are loaded from the StateManager into the instance. + */ + /* * Create a persistent object and commit(). * @@ -48,116 +56,99 @@ */ public class CallingJdoPostload extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A10.1-1 (CallingJdoPostload) failed"; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CallingJdoPostload.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(InstanceCallbackNonPersistFdsClass.class); - } - - /** */ - public void test() { - pm = getPM(); - Transaction t = pm.currentTransaction(); - t.setRetainValues(false); - - InstanceCallbackNonPersistFdsClass.initializeStaticsForTest(); - - t.begin(); - // create instance - InstanceCallbackNonPersistFdsClass obj1 = new InstanceCallbackNonPersistFdsClass(2.2f, 13); - pm.makePersistent(obj1); - Object objPtr1 = pm.getObjectId(obj1); - obj1.setNonPersist(1, (char) 2, 3.3, (short) 4); - t.commit(); - - t.begin(); - // set applicationStep before and after getObjectById() to be sure when jdoPostLoad() gets - // called. - InstanceCallbackNonPersistFdsClass.applicationStep = - InstanceCallbackNonPersistFdsClass.beforeGetObjectById; - try { - obj1 = - (InstanceCallbackNonPersistFdsClass) - pm.getObjectById(objPtr1, true); // jdoPreLoad() called - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail( - ASSERTION_FAILED, - "CallingJdoPostload: Could not locate persistent object obj1 created in previous transaction " - + e); - return; - } catch (JDODataStoreException e) { - // could not locate persistent object created in previous transaction - fail( - ASSERTION_FAILED, - "CallingJdoPostload: Could not locate persistent object obj1 created in previous transaction " - + e); - return; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A10.1-1 (CallingJdoPostload) failed"; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CallingJdoPostload.class); } - - int objectState = currentState(obj1); - // expect state to be hollow or persistent-clean - if (objectState != HOLLOW && objectState != PERSISTENT_CLEAN) { - fail( - ASSERTION_FAILED, - "State of object was not hollow or persistent clean after accessed via getObjectById((), state is " - + states[objectState]); + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(InstanceCallbackNonPersistFdsClass.class); } - - InstanceCallbackNonPersistFdsClass.applicationStep = - InstanceCallbackNonPersistFdsClass.afterGetObjectById; - int getIntValue = obj1.intValue; // reference attribute in default fetch group - objectState = currentState(obj1); - - // expect jdoPostLoad() was called - if (!InstanceCallbackNonPersistFdsClass.postloadCalled) { - fail(ASSERTION_FAILED, "jdoPostLoad() never called"); + + /** */ + public void test() { + pm = getPM(); + Transaction t = pm.currentTransaction(); + t.setRetainValues(false); + + InstanceCallbackNonPersistFdsClass.initializeStaticsForTest(); + + t.begin(); + // create instance + InstanceCallbackNonPersistFdsClass obj1 = new InstanceCallbackNonPersistFdsClass(2.2f, 13); + pm.makePersistent(obj1); + Object objPtr1 = pm.getObjectId (obj1); + obj1.setNonPersist(1, (char)2, 3.3, (short)4); + t.commit(); + + t.begin(); + // set applicationStep before and after getObjectById() to be sure when jdoPostLoad() gets called. + InstanceCallbackNonPersistFdsClass.applicationStep = InstanceCallbackNonPersistFdsClass.beforeGetObjectById; + try { + obj1 = (InstanceCallbackNonPersistFdsClass)pm.getObjectById(objPtr1, true); // jdoPreLoad() called + } catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, "CallingJdoPostload: Could not locate persistent object obj1 created in previous transaction " + e); + return; + } catch (JDODataStoreException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, "CallingJdoPostload: Could not locate persistent object obj1 created in previous transaction " + e); + return; + } + + int objectState = currentState(obj1); + // expect state to be hollow or persistent-clean + if(objectState != HOLLOW && objectState != PERSISTENT_CLEAN) { + fail(ASSERTION_FAILED, "State of object was not hollow or persistent clean after accessed via getObjectById((), state is " + states[objectState]); + } + + InstanceCallbackNonPersistFdsClass.applicationStep = InstanceCallbackNonPersistFdsClass.afterGetObjectById; + int getIntValue = obj1.intValue; // reference attribute in default fetch group + objectState = currentState(obj1); + + // expect jdoPostLoad() was called + if(!InstanceCallbackNonPersistFdsClass.postloadCalled) { + fail(ASSERTION_FAILED, "jdoPostLoad() never called"); + } + + // only check other information if jdoPostLoad() called + if(InstanceCallbackNonPersistFdsClass.postloadCalled) { + // expect jdoPostLoad() was called only once + if(InstanceCallbackNonPersistFdsClass.postloadCalledMultipleTimes) { + fail(ASSERTION_FAILED, "jdoPostLoad was called more than once for the same loaded object"); + } + + // verify the value of intValue was available in jdoPostLoad() + if(InstanceCallbackNonPersistFdsClass.savedIntValue != getIntValue) { + fail(ASSERTION_FAILED, + "intValue available in jdoPostLoad is incorrect. It was " + + InstanceCallbackNonPersistFdsClass.savedIntValue + + ", it should be " + getIntValue); + } + + // verify the value of floatValue was available in jdoPostLoad() + if(InstanceCallbackNonPersistFdsClass.savedFloatValue != obj1.floatValue) { + fail(ASSERTION_FAILED, + "floatValue available in jdoPostLoad is incorrect. It was " + + InstanceCallbackNonPersistFdsClass.savedFloatValue + + ", it should be " + obj1.floatValue); + } + } + + t.rollback(); + pm.close(); + pm = null; } - - // only check other information if jdoPostLoad() called - if (InstanceCallbackNonPersistFdsClass.postloadCalled) { - // expect jdoPostLoad() was called only once - if (InstanceCallbackNonPersistFdsClass.postloadCalledMultipleTimes) { - fail(ASSERTION_FAILED, "jdoPostLoad was called more than once for the same loaded object"); - } - - // verify the value of intValue was available in jdoPostLoad() - if (InstanceCallbackNonPersistFdsClass.savedIntValue != getIntValue) { - fail( - ASSERTION_FAILED, - "intValue available in jdoPostLoad is incorrect. It was " - + InstanceCallbackNonPersistFdsClass.savedIntValue - + ", it should be " - + getIntValue); - } - - // verify the value of floatValue was available in jdoPostLoad() - if (InstanceCallbackNonPersistFdsClass.savedFloatValue != obj1.floatValue) { - fail( - ASSERTION_FAILED, - "floatValue available in jdoPostLoad is incorrect. It was " - + InstanceCallbackNonPersistFdsClass.savedFloatValue - + ", it should be " - + obj1.floatValue); - } - } - - t.rollback(); - pm.close(); - pm = null; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPreclear.java b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPreclear.java index 8bea35ca1..5bcffe7ca 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPreclear.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPreclear.java @@ -5,37 +5,47 @@ * 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 + * + * 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.jdo.tck.api.instancecallbacks; + import java.util.Calendar; import java.util.Date; + import javax.jdo.JDODataStoreException; import javax.jdo.JDOUserException; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Calling Jdo Preclear
    - * Keywords: instancecallbacks
    - * Assertion ID: A10.3-1.
    - * Assertion Description: The jdoPreClear() method of a class implementing - * InstanceCallbacks is called before the values in the instance are cleared. (This - * happens during the state transition to hollow.) + *Title: Calling Jdo Preclear + *
    + *Keywords: instancecallbacks + *
    + *Assertion ID: A10.3-1. + *
    + *Assertion Description: +The jdoPreClear() method of a class implementing +InstanceCallbacks is called before the values in the instance +are cleared. (This happens during the state transition to hollow.) + */ /* - * Create a new object, reference an existing object and + * Create a new object, reference an existing object and * modify an existing object and then commit. * * Check that each instance contains the values set into @@ -44,128 +54,105 @@ public class CallingJdoPreclear extends TestParts { - /** */ - private static final String ASSERTION_FAILED = "Assertion A10.3-1 (CallingJdoPreclear) failed"; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CallingJdoPreclear.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(InstanceCallbackClass.class); - } - - /** */ - public void test() { - pm = getPM(); - Transaction t = pm.currentTransaction(); - t.setRetainValues(false); // instances transit'n to hollow after commit - - InstanceCallbackClass.initializeStaticsForTest(); - - t.begin(); - Calendar cal = Calendar.getInstance(); - cal.set(1999, 1, 15, 12, 0); - Date createTime = cal.getTime(); - cal.set(2002, 1, 15, 12, 0); - Date laterDate = cal.getTime(); - InstanceCallbackClass secondaryObj = - new InstanceCallbackClass("secondaryObj", createTime, 2, 2.2, (short) -20, '2', null); - InstanceCallbackClass primaryObj = - new InstanceCallbackClass("primaryObj", laterDate, 1, 1.1, (short) -10, '1', secondaryObj); - pm.makePersistent(primaryObj); - pm.makePersistent(secondaryObj); - Object secondaryObjId = pm.getObjectId(secondaryObj); - Object primaryObjId = pm.getObjectId(primaryObj); - t.commit(); - - InstanceCallbackClass.performPreClearTests = true; - t.setOptimistic(false); - t.begin(); - try { - primaryObj = (InstanceCallbackClass) pm.getObjectById(primaryObjId, true); - pm.retrieve(primaryObj); // load fields (make it persistent-clean) - - } catch (JDOUserException e) { - fail( - ASSERTION_FAILED, - "Failed to find primaryObj created in " - + "previous transaction. Got JDOUserException " - + e); - return; - } catch (JDODataStoreException e) { - fail( - ASSERTION_FAILED, - "Failed to find primaryObj created in " - + "previous transaction. Got JDODataStoreException " - + e); - return; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A10.3-1 (CallingJdoPreclear) failed"; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CallingJdoPreclear.class); } - - secondaryObj = primaryObj.nextObj; - if (secondaryObj == null) { - fail( - ASSERTION_FAILED, - "Failed to find secondaryObj created in " - + "previous transaction using reference from primaryObj."); - return; + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(InstanceCallbackClass.class); + } + + /** */ + public void test() { + pm = getPM(); + Transaction t = pm.currentTransaction(); + t.setRetainValues(false); // instances transit'n to hollow after commit + + InstanceCallbackClass.initializeStaticsForTest(); + + t.begin(); + Calendar cal = Calendar.getInstance(); + cal.set(1999, 1, 15, 12, 0); + Date createTime = cal.getTime(); + cal.set(2002, 1, 15, 12, 0); + Date laterDate = cal.getTime(); + InstanceCallbackClass secondaryObj = + new InstanceCallbackClass("secondaryObj", createTime, 2, 2.2, + (short)-20, '2', null); + InstanceCallbackClass primaryObj = + new InstanceCallbackClass("primaryObj", laterDate, 1, 1.1, + (short)-10, '1', secondaryObj); + pm.makePersistent(primaryObj); + pm.makePersistent(secondaryObj); + Object secondaryObjId = pm.getObjectId(secondaryObj); + Object primaryObjId = pm.getObjectId(primaryObj); + t.commit(); + + InstanceCallbackClass.performPreClearTests = true; + t.setOptimistic(false); + t.begin(); + try { + primaryObj = (InstanceCallbackClass)pm.getObjectById(primaryObjId, + true); + pm.retrieve(primaryObj); // load fields (make it persistent-clean) + + } catch (JDOUserException e) { + fail(ASSERTION_FAILED, "Failed to find primaryObj created in " + + "previous transaction. Got JDOUserException " + e); + return; + } catch (JDODataStoreException e) { + fail(ASSERTION_FAILED, "Failed to find primaryObj created in " + + "previous transaction. Got JDODataStoreException " + e); + return; + } + + secondaryObj = primaryObj.nextObj; + if(secondaryObj == null) { + fail(ASSERTION_FAILED, "Failed to find secondaryObj created in " + + "previous transaction using reference from primaryObj."); + return; + } + pm.retrieve(secondaryObj); + + // primaryObj contains one child; secondaryObj contains none + primaryObj.addChild(secondaryObj); // primaryObj is now dirty + + cal.set(2005, 6, 28, 0, 0); + Date stillLaterDate = cal.getTime(); + InstanceCallbackClass ternaryObj = + new InstanceCallbackClass("ternaryObj", stillLaterDate, 3, 3.3, + (short)-30, '3', null); + pm.makePersistent(ternaryObj); + ternaryObj.addChild(primaryObj); + t.commit(); + + // verify attributes in what was persistent-clean object--secondaryObj + checkFieldValues(ASSERTION_FAILED, "jdoPreClear attribute access: ", + 2, "secondaryObj", createTime, 2.2, (short)-20, '2'); + + // verify attributes in what was persistent-dirty object--primaryObj + checkFieldValues(ASSERTION_FAILED, "jdoPreClear attribute access: ", + 1, "primaryObj", laterDate, 1.1, (short)-10, '1'); + + + // verify attributes in what was persistent-new object--ternaryObj + checkFieldValues(ASSERTION_FAILED, "jdoPreClear attribute access: ", + 3, "ternaryObj", stillLaterDate, 3.3, (short)-30, '3'); + pm.close(); + pm = null; + InstanceCallbackClass.performPreClearTests = false; } - pm.retrieve(secondaryObj); - - // primaryObj contains one child; secondaryObj contains none - primaryObj.addChild(secondaryObj); // primaryObj is now dirty - - cal.set(2005, 6, 28, 0, 0); - Date stillLaterDate = cal.getTime(); - InstanceCallbackClass ternaryObj = - new InstanceCallbackClass("ternaryObj", stillLaterDate, 3, 3.3, (short) -30, '3', null); - pm.makePersistent(ternaryObj); - ternaryObj.addChild(primaryObj); - t.commit(); - - // verify attributes in what was persistent-clean object--secondaryObj - checkFieldValues( - ASSERTION_FAILED, - "jdoPreClear attribute access: ", - 2, - "secondaryObj", - createTime, - 2.2, - (short) -20, - '2'); - - // verify attributes in what was persistent-dirty object--primaryObj - checkFieldValues( - ASSERTION_FAILED, - "jdoPreClear attribute access: ", - 1, - "primaryObj", - laterDate, - 1.1, - (short) -10, - '1'); - - // verify attributes in what was persistent-new object--ternaryObj - checkFieldValues( - ASSERTION_FAILED, - "jdoPreClear attribute access: ", - 3, - "ternaryObj", - stillLaterDate, - 3.3, - (short) -30, - '3'); - pm.close(); - pm = null; - InstanceCallbackClass.performPreClearTests = false; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPredelete.java b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPredelete.java index 20556b749..4d933a0fb 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPredelete.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPredelete.java @@ -5,32 +5,39 @@ * 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 + * + * 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.jdo.tck.api.instancecallbacks; import javax.jdo.JDOException; import javax.jdo.JDOUserException; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Calling JDO Predelete
    - * Keywords: instancecallbacks
    - * Assertion ID: A10.4-1.
    - * Assertion Description: jdoPreDelete() is called during the execution of - * deletePersistent before the state transition to persistent-deleted or - * persistent-new-deleted. + *Title: Calling JDO Predelete + *
    + *Keywords: instancecallbacks + *
    + *Assertion ID: A10.4-1. + *
    + *Assertion Description: +jdoPreDelete() is called during the execution of +deletePersistent before the state transition to persistent-deleted +or persistent-new-deleted. + */ /* @@ -50,100 +57,95 @@ */ public class CallingJdoPredelete extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A10.4-1 (CallingJdoPredelete) failed"; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CallingJdoPredelete.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(InstanceCallbackClass.class); - } - - /** */ - public void test() { - pm = getPM(); - Transaction t = pm.currentTransaction(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A10.4-1 (CallingJdoPredelete) failed"; - InstanceCallbackClass.initializeStaticsForTest(); - - InstanceCallbackClass.performPreDeleteTests = true; // enabling PreDelete tests - t.begin(); - InstanceCallbackClass a = new InstanceCallbackClass(null, null, 1, 1.0, (short) -1, '1', null); - InstanceCallbackClass b = new InstanceCallbackClass(null, null, 2, 2.0, (short) -1, '2', null); - pm.makePersistent(a); - pm.makePersistent(b); - Object aId = pm.getObjectId(a); - Object bId = pm.getObjectId(b); - t.commit(); - - t.begin(); - try { - a = (InstanceCallbackClass) pm.getObjectById(aId, true); - } catch (JDOUserException e) { - fail( - ASSERTION_FAILED, - "CallingJdoPredelete: Failed to find object a created in previous transaction, got JDOUserException " - + e); - return; + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CallingJdoPredelete.class); } - try { - b = (InstanceCallbackClass) pm.getObjectById(bId, true); - } catch (JDOException e) { - fail( - ASSERTION_FAILED, - "CallingJdoPredelete: Failed to find object b created in previous transaction, got JDOUserException " - + e); - return; - } - - int getfld = a.intValue; // cause instance to be persistent-clean - int getfld2 = a.childToDelete; - b.childToDelete++; // make second object dirty - InstanceCallbackClass c = new InstanceCallbackClass(null, null, 3, 3.0, (short) -1, '3', null); - pm.makePersistent(c); // create persistent-new object - - InstanceCallbackClass.preDeleteCalled = false; - pm.deletePersistent(a); - if (!InstanceCallbackClass.preDeleteCalled) { - fail(ASSERTION_FAILED, "jdoPreDelete not called when PERSISTENT_CLEAN object deleted."); - } else { - if (InstanceCallbackClass.objectState == PERSISTENT_DELETED) { - fail(ASSERTION_FAILED, "Error, state was persistent-deleted in jdoPredelete callback"); - } - } - - InstanceCallbackClass.preDeleteCalled = false; - pm.deletePersistent(b); - if (!InstanceCallbackClass.preDeleteCalled) { - fail(ASSERTION_FAILED, "jdoPreDelete not called when PERSISTENT_DIRTY object deleted."); - } else { - if (InstanceCallbackClass.objectState == PERSISTENT_DELETED) { - fail(ASSERTION_FAILED, "Error, state was persistent-deleted in jdoPredelete callback"); - } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(InstanceCallbackClass.class); } + + /** */ + public void test() { + pm = getPM(); + Transaction t = pm.currentTransaction(); + + InstanceCallbackClass.initializeStaticsForTest(); - InstanceCallbackClass.preDeleteCalled = false; - pm.deletePersistent(c); - if (!InstanceCallbackClass.preDeleteCalled) { - fail(ASSERTION_FAILED, "jdoPreDelete not called when PERSISTENT_NEW object deleted."); - } else { - if (InstanceCallbackClass.objectState == PERSISTENT_NEW_DELETED) { - fail(ASSERTION_FAILED, "Error, state was persistent-new-deleted in jdoPredelete callback"); - } + InstanceCallbackClass.performPreDeleteTests = true; // enabling PreDelete tests + t.begin(); + InstanceCallbackClass a = new InstanceCallbackClass(null, null, 1, 1.0, (short)-1, '1', null); + InstanceCallbackClass b = new InstanceCallbackClass(null, null, 2, 2.0, (short)-1, '2', null); + pm.makePersistent(a); + pm.makePersistent(b); + Object aId = pm.getObjectId(a); + Object bId = pm.getObjectId(b); + t.commit(); + + t.begin(); + try { + a = (InstanceCallbackClass)pm.getObjectById(aId, true); + } catch (JDOUserException e) { + fail(ASSERTION_FAILED, "CallingJdoPredelete: Failed to find object a created in previous transaction, got JDOUserException " + e); + return; + } + try { + b = (InstanceCallbackClass)pm.getObjectById(bId, true); + } catch (JDOException e) { + fail(ASSERTION_FAILED, "CallingJdoPredelete: Failed to find object b created in previous transaction, got JDOUserException " + e); + return; + } + + int getfld = a.intValue; // cause instance to be persistent-clean + int getfld2 = a.childToDelete; + b.childToDelete++; // make second object dirty + InstanceCallbackClass c = new InstanceCallbackClass(null, null, 3, 3.0, (short)-1, '3', null); + pm.makePersistent(c); // create persistent-new object + + InstanceCallbackClass.preDeleteCalled = false; + pm.deletePersistent(a); + if(!InstanceCallbackClass.preDeleteCalled) { + fail(ASSERTION_FAILED, "jdoPreDelete not called when PERSISTENT_CLEAN object deleted."); + } else { + if(InstanceCallbackClass.objectState == PERSISTENT_DELETED) { + fail(ASSERTION_FAILED, "Error, state was persistent-deleted in jdoPredelete callback"); + } + } + + InstanceCallbackClass.preDeleteCalled = false; + pm.deletePersistent(b); + if(!InstanceCallbackClass.preDeleteCalled) { + fail(ASSERTION_FAILED, "jdoPreDelete not called when PERSISTENT_DIRTY object deleted."); + } else { + if(InstanceCallbackClass.objectState == PERSISTENT_DELETED) { + fail(ASSERTION_FAILED, "Error, state was persistent-deleted in jdoPredelete callback"); + } + } + + InstanceCallbackClass.preDeleteCalled = false; + pm.deletePersistent(c); + if(!InstanceCallbackClass.preDeleteCalled) { + fail(ASSERTION_FAILED,"jdoPreDelete not called when PERSISTENT_NEW object deleted."); + } else { + if(InstanceCallbackClass.objectState == PERSISTENT_NEW_DELETED) { + fail(ASSERTION_FAILED, "Error, state was persistent-new-deleted in jdoPredelete callback"); + } + } + t.rollback(); + pm.close(); + pm = null; } - t.rollback(); - pm.close(); - pm = null; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPrestore.java b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPrestore.java index e10021015..c2dc26098 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPrestore.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/CallingJdoPrestore.java @@ -5,33 +5,39 @@ * 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 + * + * 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.jdo.tck.api.instancecallbacks; import javax.jdo.JDODataStoreException; import javax.jdo.JDOUserException; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackClass; import org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackNonPersistFdsClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Calling InstanceCallbacks Prestore Method
    - * Keywords: instancecallbacks
    - * Assertion ID: A10.2-1.
    - * Assertion Description: The jdoPreStore() method of a class implementing - * InstanceCallbacks is called before the values are stored from the instance to the - * StateManager. + *Title: Calling InstanceCallbacks Prestore Method + *
    + *Keywords: instancecallbacks + *
    + *Assertion ID: A10.2-1. + *
    + *Assertion Description: +The jdoPreStore() method of a class implementing +InstanceCallbacks is called before the values are +stored from the instance to the StateManager. + */ /* @@ -42,231 +48,170 @@ * jdoPreStore() should have been called again when obj2 was modified. * jdoPreStore() should not be called a second time on obj1 because it was not modified. - /* - This test is accomplished in three transactions. + /* + This test is accomplished in three transactions. 1) object1 and object2 are created. At commit, we expect jdoPreStore() - to be called on each and calculate values of persistent attributes from non-presistent attributes. + to be called on each and calculate values of persistent attributes from non-presistent attributes. 2) Retrieve object1 and object2 from the database and verify the persistent attributes have values calculated in the jdoPreStore()s called in the previous transaction. - Change non-persistent fields in each but only change a persistent field in one of them. + Change non-persistent fields in each but only change a persistent field in one of them. 3) Retrieve object1 and object2 from the database and verify that again jdoPreStore() - was called for each in the previous transaction. -*/ + was called for each in the previous transaction. +*/ public class CallingJdoPrestore extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A10.2-1 (CallingJdoPrestore) failed"; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CallingJdoPrestore.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(InstanceCallbackNonPersistFdsClass.class); - } - - /** */ - public void test() { - pm = getPM(); - Transaction t = pm.currentTransaction(); - - InstanceCallbackClass.initializeStaticsForTest(); - - InstanceCallbackClass.performPreStoreTests = true; - t.begin(); - int expectedIntValue1, expectedIntValue2; - float expectedFloatValue1, expectedFloatValue2; - - int origIntValue1 = 10, origIntValue2 = 12; - float origFloatValue1 = 2.5f, origFloatValue2 = -3.0f; - - // create two instances - - InstanceCallbackNonPersistFdsClass obj1 = - new InstanceCallbackNonPersistFdsClass(origFloatValue1, origIntValue1); - pm.makePersistent(obj1); - Object objPtr1 = pm.getObjectId(obj1); - obj1.setNonPersist(5, (char) 10, .25, (short) 100); - expectedIntValue1 = obj1.calcIntValue(); - expectedFloatValue1 = obj1.calcFloatValue(); - - InstanceCallbackNonPersistFdsClass obj2 = - new InstanceCallbackNonPersistFdsClass(origFloatValue2, origIntValue2); - pm.makePersistent(obj2); - Object objPtr2 = pm.getObjectId(obj2); - obj2.setNonPersist(2, (char) 125, .1, (short) 750); - expectedIntValue2 = obj2.calcIntValue(); - expectedFloatValue2 = obj2.calcFloatValue(); - - t.commit(); - - t.begin(); - // read both objects back in to determine persistent state is as expected. - try { - obj1 = (InstanceCallbackNonPersistFdsClass) pm.getObjectById(objPtr1, true); - checkValues( - "Object1 created and read back in: ", origIntValue1, expectedIntValue1, obj1.intValue); - checkValues( - "Object1 created and read back in: ", - origFloatValue1, - expectedFloatValue1, - obj1.floatValue); - origIntValue1 = obj1.intValue; - origFloatValue1 = obj1.floatValue; - obj1.setNonManaged(-1, (char) 62); - expectedIntValue1 = obj1.calcIntValue(); - expectedFloatValue1 = obj1.calcFloatValue(); - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail( - ASSERTION_FAILED, - "CallingJdoPrestore: Failed to find object obj1 created in previous transaction, got " - + e); - return; - } catch (JDODataStoreException e) { - // could not locate persistent object created in previous transaction - fail( - ASSERTION_FAILED, - "CallingJdoPrestore: Failed to find object obj1 created in previous transaction, got " - + e); - return; - } - - try { - obj2 = (InstanceCallbackNonPersistFdsClass) pm.getObjectById(objPtr2, true); - checkValues( - "Object2 created and read back in: ", origIntValue2, expectedIntValue2, obj2.intValue); - checkValues( - "Object2 created and read back in: ", - origFloatValue2, - expectedFloatValue2, - obj2.floatValue); - origIntValue2 = obj2.intValue; - origFloatValue2 = obj2.floatValue; - obj2.setNonPersist(12, (char) 30, 5.0, (short) 137); - expectedIntValue2 = obj2.calcIntValue(); - expectedFloatValue2 = obj2.calcFloatValue(); - - // change obj2 making it persistent dirty (leave obj1 persistent clean). - obj2.incrementIntValue(); - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail( - ASSERTION_FAILED, - "CallingJdoPrestore: Failed to find object obj2 created in previous transaction, got " - + e); - return; - } catch (JDODataStoreException e) { - // could not locate persistent object created in previous transaction - fail( - ASSERTION_FAILED, - "CallingJdoPrestore: Failed to find object obj2 created in previous transaction, got " - + e); - return; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A10.2-1 (CallingJdoPrestore) failed"; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CallingJdoPrestore.class); } - - t.commit(); - - t.begin(); - // read both objects back in to determine persistent state is as expected. - try { - // obj1 not made dirty, so jdoPreStore() should not have been called. - obj1 = (InstanceCallbackNonPersistFdsClass) pm.getObjectById(objPtr1, true); - checkValues( - "Object1, did not expect jdoPreStore to be called: ", - origIntValue1, - origIntValue1, - obj1.intValue); - checkValues( - "Object1, did not expect jdoPreStore to be called: ", - origFloatValue1, - origFloatValue1, - obj1.floatValue); - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail( - ASSERTION_FAILED, - "CallingJdoPrestore: Failed to find object obj1 created in previous transaction, got " - + e); - return; - } catch (JDODataStoreException e) { - // could not locate persistent object created in previous transaction - fail( - ASSERTION_FAILED, - "CallingJdoPrestore: Failed to find object obj1 created in previous transaction, got " - + e); - return; + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(InstanceCallbackNonPersistFdsClass.class); } - - try { - obj2 = (InstanceCallbackNonPersistFdsClass) pm.getObjectById(objPtr2, true); - checkValues( - "Object2, expected jdoPreStore() to be called: ", - origIntValue2, - expectedIntValue2, - obj2.intValue); - checkValues( - "Object2, expected jdoPreStore() to be called: ", - origFloatValue2, - expectedFloatValue2, - obj2.floatValue); - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail( - ASSERTION_FAILED, - "CallingJdoPrestore: Failed to find object obj2 created in previous transaction, got " - + e); - return; - } catch (JDODataStoreException e) { - // could not locate persistent object created in previous transaction - fail( - ASSERTION_FAILED, - "CallingJdoPrestore: Failed to find object obj2 created in previous transaction, got " - + e); - return; + + /** */ + public void test() { + pm = getPM(); + Transaction t = pm.currentTransaction(); + + InstanceCallbackClass.initializeStaticsForTest(); + + InstanceCallbackClass.performPreStoreTests = true; + t.begin(); + int expectedIntValue1, expectedIntValue2; + float expectedFloatValue1, expectedFloatValue2; + + int origIntValue1 = 10, origIntValue2 = 12; + float origFloatValue1 = 2.5f, origFloatValue2 = -3.0f; + + // create two instances + + InstanceCallbackNonPersistFdsClass obj1 = new InstanceCallbackNonPersistFdsClass(origFloatValue1, origIntValue1); + pm.makePersistent(obj1); + Object objPtr1 = pm.getObjectId (obj1); + obj1.setNonPersist(5, (char)10, .25, (short)100); + expectedIntValue1 = obj1.calcIntValue(); + expectedFloatValue1 = obj1.calcFloatValue(); + + InstanceCallbackNonPersistFdsClass obj2 = new InstanceCallbackNonPersistFdsClass(origFloatValue2, origIntValue2); + pm.makePersistent(obj2); + Object objPtr2 = pm.getObjectId (obj2); + obj2.setNonPersist(2, (char)125, .1, (short)750); + expectedIntValue2 = obj2.calcIntValue(); + expectedFloatValue2 = obj2.calcFloatValue(); + + t.commit(); + + t.begin(); + // read both objects back in to determine persistent state is as expected. + try { + obj1 = (InstanceCallbackNonPersistFdsClass)pm.getObjectById(objPtr1, true); + checkValues("Object1 created and read back in: ", origIntValue1, expectedIntValue1, obj1.intValue); + checkValues("Object1 created and read back in: ", origFloatValue1, expectedFloatValue1, obj1.floatValue); + origIntValue1 = obj1.intValue; + origFloatValue1 = obj1.floatValue; + obj1.setNonManaged(-1, (char)62); + expectedIntValue1 = obj1.calcIntValue(); + expectedFloatValue1 = obj1.calcFloatValue(); + } catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, "CallingJdoPrestore: Failed to find object obj1 created in previous transaction, got " + e); + return; + } catch (JDODataStoreException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, "CallingJdoPrestore: Failed to find object obj1 created in previous transaction, got " + e); + return; + } + + try { + obj2 = (InstanceCallbackNonPersistFdsClass)pm.getObjectById(objPtr2, true); + checkValues("Object2 created and read back in: ", origIntValue2, expectedIntValue2, obj2.intValue); + checkValues("Object2 created and read back in: ", origFloatValue2, expectedFloatValue2, obj2.floatValue); + origIntValue2 = obj2.intValue; + origFloatValue2 = obj2.floatValue; + obj2.setNonPersist(12, (char)30, 5.0, (short)137); + expectedIntValue2 = obj2.calcIntValue(); + expectedFloatValue2 = obj2.calcFloatValue(); + + // change obj2 making it persistent dirty (leave obj1 persistent clean). + obj2.incrementIntValue(); + } catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, "CallingJdoPrestore: Failed to find object obj2 created in previous transaction, got " + e); + return; + } catch (JDODataStoreException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, "CallingJdoPrestore: Failed to find object obj2 created in previous transaction, got " + e); + return; + } + + t.commit(); + + t.begin(); + // read both objects back in to determine persistent state is as expected. + try { + // obj1 not made dirty, so jdoPreStore() should not have been called. + obj1 = (InstanceCallbackNonPersistFdsClass)pm.getObjectById(objPtr1, true); + checkValues("Object1, did not expect jdoPreStore to be called: ", origIntValue1, origIntValue1, obj1.intValue); + checkValues("Object1, did not expect jdoPreStore to be called: ", origFloatValue1, origFloatValue1, obj1.floatValue); + } catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, "CallingJdoPrestore: Failed to find object obj1 created in previous transaction, got " + e); + return; + } catch (JDODataStoreException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, "CallingJdoPrestore: Failed to find object obj1 created in previous transaction, got " + e); + return; + } + + try { + obj2 = (InstanceCallbackNonPersistFdsClass)pm.getObjectById(objPtr2, true); + checkValues("Object2, expected jdoPreStore() to be called: ", origIntValue2, expectedIntValue2, obj2.intValue); + checkValues("Object2, expected jdoPreStore() to be called: ", origFloatValue2, expectedFloatValue2, obj2.floatValue); + } catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, "CallingJdoPrestore: Failed to find object obj2 created in previous transaction, got " + e); + return; + } catch (JDODataStoreException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, "CallingJdoPrestore: Failed to find object obj2 created in previous transaction, got " + e); + return; + } + t.rollback(); + pm.close(); + pm = null; } - t.rollback(); - pm.close(); - pm = null; - } - - /** */ - void checkValues(String title, int origIntValue, int expectedIntValue, int intValue) { - if (expectedIntValue != intValue) { - fail( - ASSERTION_FAILED, - title - + "Original persistent intValue is " - + origIntValue - + ", expected " - + expectedIntValue - + ". Instead intValue is " - + intValue); + + /** */ + void checkValues(String title, int origIntValue, int expectedIntValue, int intValue) { + if(expectedIntValue != intValue) { + fail(ASSERTION_FAILED, + title + "Original persistent intValue is " + origIntValue + + ", expected " + expectedIntValue + + ". Instead intValue is " + intValue); + } } - } - - /** */ - void checkValues(String title, float origFloatValue, float expectedFloatValue, float floatValue) { - if (expectedFloatValue != floatValue) { - fail( - ASSERTION_FAILED, - title - + "Original persistent floatValue is " - + origFloatValue - + ", expected " - + expectedFloatValue - + ". Instead floatVal is " - + floatValue); + + /** */ + void checkValues(String title, float origFloatValue, float expectedFloatValue, float floatValue) { + if(expectedFloatValue != floatValue) { + fail(ASSERTION_FAILED, + title + "Original persistent floatValue is " + origFloatValue + + ", expected " + expectedFloatValue + + ". Instead floatVal is " + floatValue); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerAttach.java b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerAttach.java index 552462a30..bb2e2b439 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerAttach.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerAttach.java @@ -5,145 +5,179 @@ * 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 + * + * 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.jdo.tck.api.instancecallbacks; import java.util.Date; + import javax.jdo.listener.AttachCallback; + +import javax.jdo.JDOHelper; + import javax.jdo.listener.InstanceLifecycleEvent; +import javax.jdo.listener.InstanceLifecycleListener; +import javax.jdo.listener.ClearLifecycleListener; + +import org.apache.jdo.tck.JDO_Test; + +import org.apache.jdo.tck.pc.mylib.PCPoint; + import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Test TestInstanceLifecycleListenerAttach
    - * Keywords: LifeCycleListener preAttach postAttach
    - * Assertion IDs: A12.15-13 A12.15-14
    - * Assertion Description: A12.15-13 void preAttach(InstanceLifecycleEvent event); This - * method is called before a detached instance is attached. The source instance is the detached - * instance]. A12.15-14 void postAttach(InstanceLifecycleEvent event); This method is called after a - * detached instance is attached. The source instance is the corresponding persistent instance in - * the cache; the target instance is the detached instance. + * Title: Test TestInstanceLifecycleListenerAttach + *
    + * Keywords: LifeCycleListener preAttach postAttach + *
    + * Assertion IDs: A12.15-13 A12.15-14 + *
    + * Assertion Description: + * A12.15-13 void preAttach(InstanceLifecycleEvent event); + * This method is called before a detached instance is attached. + * The source instance is the detached instance]. + * A12.15-14 void postAttach(InstanceLifecycleEvent event); + * This method is called after a detached instance is attached. + * The source instance is the corresponding persistent instance in the cache; + * the target instance is the detached instance. */ -public class InstanceLifecycleListenerAttach extends AbstractInstanceLifecycleListener { - - /** The InstanceLifecycleListener used for this test */ - InstanceLifecycleListenerImpl listener = new InstanceLifecycleListenerAttachImpl(); - - /** Return the listener. */ - protected InstanceLifecycleListenerImpl getListener() { - return listener; - } - - /** The persistent classes used for this test. */ - private static Class[] persistentClasses = new Class[] {PC.class}; - - /** Return the persistent classes. */ - protected Class[] getPersistentClasses() { - return persistentClasses; - } - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(InstanceLifecycleListenerAttach.class); - } - - /** - * This test creates a new persistent instance and detaches it. The instance is attached in a new - * transaction, which causes the attach callbacks and listeners to be called. - */ - public void testAttach() { - - // set up the persistent instance - PC pc = new PC(); - - getPM(); - pm.currentTransaction().begin(); - pm.makePersistent(pc); - PC detached = (PC) pm.detachCopy(pc); - detached.listener = listener; - pm.currentTransaction().commit(); - pm.currentTransaction().begin(); - listener.setExpectedSource(detached); - // makePersistent should cause the attach listeners to be called - PC attached = (PC) pm.makePersistent(detached); - pm.currentTransaction().commit(); - - // now check the callback and listener were called - listener.verifyCallbacks( - ASSERTION13_FAILED, - new int[] { - listener.PRE_ATTACH_LISTENER, listener.PRE_ATTACH_CALLBACK, listener.POST_ATTACH_LISTENER - }); - } - - /** The LifeCycleListener to be registered with the PersistenceManager. */ - private static class InstanceLifecycleListenerAttachImpl extends InstanceLifecycleListenerImpl { - - public void preAttach(InstanceLifecycleEvent event) { - notifyEvent(PRE_ATTACH_LISTENER); - checkEventType(ASSERTION13_FAILED, InstanceLifecycleEvent.ATTACH, event.getEventType()); - checkEventSource(ASSERTION13_FAILED, event.getSource()); - } - - public void postAttach(InstanceLifecycleEvent event) { - notifyEvent(POST_ATTACH_LISTENER); - checkEventType(ASSERTION14_FAILED, InstanceLifecycleEvent.ATTACH, event.getEventType()); - checkPersistent(ASSERTION14_FAILED + "in postAttach, source ", event.getSource()); - checkTrue( - ASSERTION14_FAILED + "in postAttach, source wasPostAttachCalled() ", - ((PC) event.getSource()).wasPostAttachCalled()); - checkSame(ASSERTION14_FAILED + "in postAttach, target ", expectedSource, event.getTarget()); - } - } - /** The persistence-capable class that implements the attach callback. */ - public static class PC implements AttachCallback { - transient InstanceLifecycleListenerImpl listener; +public class InstanceLifecycleListenerAttach + extends AbstractInstanceLifecycleListener { - transient boolean postAttachCalled = false; + + /** + * The InstanceLifecycleListener used for this test + */ + InstanceLifecycleListenerImpl listener = + new InstanceLifecycleListenerAttachImpl(); - public boolean wasPostAttachCalled() { - return postAttachCalled; + /** Return the listener. + */ + protected InstanceLifecycleListenerImpl getListener() { + return listener; } - transient Object postAttachObject = null; + /** + * The persistent classes used for this test. + */ + private static Class[] persistentClasses = new Class[] {PC.class}; - public Object getPostAttachObject() { - return postAttachObject; + /** Return the persistent classes. + */ + protected Class[] getPersistentClasses() { + return persistentClasses; } - int id; - - public PC() {} - - public PC(InstanceLifecycleListenerImpl listener) { - id = counter++; - this.listener = listener; + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(InstanceLifecycleListenerAttach.class); } - static int counter = (int) (new Date().getTime()); + /** + * This test creates a new persistent instance and detaches it. + * The instance is attached in a new transaction, which causes + * the attach callbacks and listeners to be called. + */ + public void testAttach() { + + // set up the persistent instance + PC pc = new PC(); + + getPM(); + pm.currentTransaction().begin(); + pm.makePersistent(pc); + PC detached = (PC)pm.detachCopy(pc); + detached.listener = listener; + pm.currentTransaction().commit(); + pm.currentTransaction().begin(); + listener.setExpectedSource(detached); + // makePersistent should cause the attach listeners to be called + PC attached = (PC)pm.makePersistent(detached); + pm.currentTransaction().commit(); + + // now check the callback and listener were called + listener.verifyCallbacks(ASSERTION13_FAILED, new int[] { + listener.PRE_ATTACH_LISTENER, + listener.PRE_ATTACH_CALLBACK, + listener.POST_ATTACH_LISTENER}); + } + + /** + * The LifeCycleListener to be registered with the + * PersistenceManager. + */ + private static class InstanceLifecycleListenerAttachImpl + extends InstanceLifecycleListenerImpl { + + public void preAttach(InstanceLifecycleEvent event) { + notifyEvent(PRE_ATTACH_LISTENER); + checkEventType(ASSERTION13_FAILED, + InstanceLifecycleEvent.ATTACH, event.getEventType()); + checkEventSource(ASSERTION13_FAILED, event.getSource()); + } + + public void postAttach(InstanceLifecycleEvent event) { + notifyEvent(POST_ATTACH_LISTENER); + checkEventType(ASSERTION14_FAILED, + InstanceLifecycleEvent.ATTACH, event.getEventType()); + checkPersistent(ASSERTION14_FAILED + "in postAttach, source ", + event.getSource()); + checkTrue(ASSERTION14_FAILED + + "in postAttach, source wasPostAttachCalled() ", + ((PC)event.getSource()).wasPostAttachCalled()); + checkSame(ASSERTION14_FAILED + "in postAttach, target ", + expectedSource, event.getTarget()); + } - public void jdoPreAttach() { - if (listener != null) { - listener.notifyEvent(listener.PRE_ATTACH_CALLBACK); - } } - public void jdoPostAttach(Object obj) { - postAttachCalled = true; - postAttachObject = obj; + /** The persistence-capable class that implements the attach callback. + */ + public static class PC implements AttachCallback { + transient InstanceLifecycleListenerImpl listener; + + transient boolean postAttachCalled = false; + public boolean wasPostAttachCalled() { + return postAttachCalled; + } + + transient Object postAttachObject = null; + public Object getPostAttachObject() { + return postAttachObject; + } + + int id; + public PC() { + } + public PC(InstanceLifecycleListenerImpl listener) { + id = counter++; + this.listener = listener; + } + static int counter = (int)(new Date().getTime()); + + public void jdoPreAttach() { + if (listener != null) { + listener.notifyEvent(listener.PRE_ATTACH_CALLBACK); + } + } + public void jdoPostAttach(Object obj) { + postAttachCalled = true; + postAttachObject = obj; + } } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerClear.java b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerClear.java index 760eaf67d..70468e1c5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerClear.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerClear.java @@ -5,123 +5,161 @@ * 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 + * + * 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.jdo.tck.api.instancecallbacks; import java.util.Date; + import javax.jdo.listener.ClearCallback; + +import javax.jdo.JDOHelper; + import javax.jdo.listener.InstanceLifecycleEvent; +import javax.jdo.listener.InstanceLifecycleListener; +import javax.jdo.listener.ClearLifecycleListener; + +import org.apache.jdo.tck.JDO_Test; + +import org.apache.jdo.tck.pc.mylib.PCPoint; + import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Test TestInstanceLifecycleListenerClear
    - * Keywords: LifeCycleListener hollow preClear postClear
    - * Assertion IDs: A12.15-5 A12.15-6
    - * Assertion Description: A12.15-5 void preClear(InstanceLifecycleEvent event); This method - * is called whenever a persistent instance is cleared, for example during afterCompletion. It is - * called before the jdoPreClear method is invoked on the instance. A12.15-6 void - * postClear(InstanceLifecycleEvent event); This method is called whenever a persistent instance is - * cleared, for example during afterCompletion. It is called after the jdoPreClear method is invoked - * on the instance and the fields have been cleared by the JDO implementation. + * Title: Test TestInstanceLifecycleListenerClear + *
    + * Keywords: LifeCycleListener hollow preClear postClear + *
    + * Assertion IDs: A12.15-5 A12.15-6 + *
    + * Assertion Description: + * A12.15-5 void preClear(InstanceLifecycleEvent event); + * This method is called whenever a persistent instance + * is cleared, for example during afterCompletion. It is called + * before the jdoPreClear method is invoked on the instance. + * A12.15-6 void postClear(InstanceLifecycleEvent event); + * This method is called whenever a persistent instance + * is cleared, for example during afterCompletion. It is called + * after the jdoPreClear method is invoked on the instance and the fields + * have been cleared by the JDO implementation. */ -public class InstanceLifecycleListenerClear extends AbstractInstanceLifecycleListener { - - /** The InstanceLifecycleListener used for this test */ - InstanceLifecycleListenerImpl listener = new InstanceLifecycleListenerClearImpl(); - - /** Return the listener. */ - protected InstanceLifecycleListenerImpl getListener() { - return listener; - } - - /** The persistent classes used for this test. */ - private static Class[] persistentClasses = new Class[] {PC.class}; - - /** Return the persistent classes. */ - protected Class[] getPersistentClasses() { - return persistentClasses; - } - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(InstanceLifecycleListenerClear.class); - } - - /** - * This test creates a new persistent instance and commits it. Since the RetainValues flag is set - * to false, the persistent fields will be cleared, and the pre-clear listener, pre-clear - * callback, and post-clear listener will be called. - */ - public void testClear() { - - // set up the persistent instance - PC pc = new PC(listener); - listener.setExpectedSource(pc); - - // commit should cause the clear listeners to be called - getPM(); - pm.currentTransaction().begin(); - pm.currentTransaction().setRetainValues(false); - pm.makePersistent(pc); - pm.currentTransaction().commit(); - - // now check the callback and listeners were called - listener.verifyCallbacks( - ASSERTION5_FAILED, - new int[] { - listener.PRE_CLEAR_LISTENER, listener.PRE_CLEAR_CALLBACK, listener.POST_CLEAR_LISTENER - }); - } - - /** The LifeCycleListener to be registered with the PersistenceManager. */ - private static class InstanceLifecycleListenerClearImpl extends InstanceLifecycleListenerImpl { - - public void preClear(InstanceLifecycleEvent event) { - notifyEvent(PRE_CLEAR_LISTENER); - checkEventType(ASSERTION5_FAILED, InstanceLifecycleEvent.CLEAR, event.getEventType()); - checkEventSource(ASSERTION5_FAILED, event.getSource()); - checkPersistent(ASSERTION5_FAILED + " in preClear, ", expectedSource); - } - public void postClear(InstanceLifecycleEvent event) { - notifyEvent(POST_CLEAR_LISTENER); - checkEventType(ASSERTION6_FAILED, InstanceLifecycleEvent.CLEAR, event.getEventType()); - checkEventSource(ASSERTION6_FAILED, event.getSource()); - checkPersistent(ASSERTION6_FAILED + " in postClear, ", expectedSource); +public class InstanceLifecycleListenerClear + extends AbstractInstanceLifecycleListener { + + + /** + * The InstanceLifecycleListener used for this test + */ + InstanceLifecycleListenerImpl listener = + new InstanceLifecycleListenerClearImpl(); + + /** Return the listener. + */ + protected InstanceLifecycleListenerImpl getListener() { + return listener; } - } - /** The persistence-capable class that implements the clear callback. */ - public static class PC implements ClearCallback { - transient InstanceLifecycleListenerImpl listener; - int id; + /** + * The persistent classes used for this test. + */ + private static Class[] persistentClasses = new Class[] {PC.class}; + + /** Return the persistent classes. + */ + protected Class[] getPersistentClasses() { + return persistentClasses; + } - public PC() {} + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(InstanceLifecycleListenerClear.class); + } - public PC(InstanceLifecycleListenerImpl listener) { - id = counter++; - this.listener = listener; + /** + * This test creates a new persistent instance and commits it. + * Since the RetainValues flag is set to false, the persistent + * fields will be cleared, and the pre-clear listener, + * pre-clear callback, and post-clear listener will be called. + */ + public void testClear() { + + // set up the persistent instance + PC pc = new PC(listener); + listener.setExpectedSource(pc); + + // commit should cause the clear listeners to be called + getPM(); + pm.currentTransaction().begin(); + pm.currentTransaction().setRetainValues(false); + pm.makePersistent(pc); + pm.currentTransaction().commit(); + + // now check the callback and listeners were called + listener.verifyCallbacks(ASSERTION5_FAILED, new int[] { + listener.PRE_CLEAR_LISTENER, + listener.PRE_CLEAR_CALLBACK, + listener.POST_CLEAR_LISTENER}); } + + /** + * The LifeCycleListener to be registered with the + * PersistenceManager. + */ + private static class InstanceLifecycleListenerClearImpl + extends InstanceLifecycleListenerImpl { + + public void preClear(InstanceLifecycleEvent event) { + notifyEvent(PRE_CLEAR_LISTENER); + checkEventType(ASSERTION5_FAILED, + InstanceLifecycleEvent.CLEAR, event.getEventType()); + checkEventSource(ASSERTION5_FAILED, event.getSource()); + checkPersistent(ASSERTION5_FAILED + " in preClear, ", + expectedSource); + } + + public void postClear(InstanceLifecycleEvent event) { + notifyEvent(POST_CLEAR_LISTENER); + checkEventType(ASSERTION6_FAILED, + InstanceLifecycleEvent.CLEAR, event.getEventType()); + checkEventSource(ASSERTION6_FAILED, event.getSource()); + checkPersistent(ASSERTION6_FAILED + " in postClear, ", + expectedSource); + } - static int counter = (int) (new Date().getTime()); + } - public void jdoPreClear() { - if (listener != null) { - listener.notifyEvent(listener.PRE_CLEAR_CALLBACK); - } + /** The persistence-capable class that implements the clear callback. + */ + public static class PC implements ClearCallback { + transient InstanceLifecycleListenerImpl listener; + int id; + public PC() { + } + public PC(InstanceLifecycleListenerImpl listener) { + id = counter++; + this.listener = listener; + } + static int counter = (int)(new Date().getTime()); + + public void jdoPreClear() { + if (listener != null) { + listener.notifyEvent(listener.PRE_CLEAR_CALLBACK); + } + } } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerCreate.java b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerCreate.java index 24225b31e..8893aab0d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerCreate.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerCreate.java @@ -5,83 +5,121 @@ * 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 + * + * 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.jdo.tck.api.instancecallbacks; +import javax.jdo.JDOHelper; + import javax.jdo.listener.InstanceLifecycleEvent; +import javax.jdo.listener.InstanceLifecycleListener; +import javax.jdo.listener.AttachLifecycleListener; +import javax.jdo.listener.ClearLifecycleListener; +import javax.jdo.listener.CreateLifecycleListener; +import javax.jdo.listener.DeleteLifecycleListener; +import javax.jdo.listener.DetachLifecycleListener; +import javax.jdo.listener.LoadLifecycleListener; +import javax.jdo.listener.StoreLifecycleListener; + +import org.apache.jdo.tck.JDO_Test; + import org.apache.jdo.tck.pc.mylib.PCPoint; + import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Test TestInstanceLifecycleListener
    - * Keywords: addLifeCycleListener removeLifeCycleListener
    - * Assertion IDs: A12.15-1
    - * Assertion Description: A12.15-1 void postCreate(InstanceLifecycleEvent event); This - * method is called whenever a persistent instance is created, during makePersistent. It is called - * after the instance transitions to persistent-new. + * Title: Test TestInstanceLifecycleListener + *
    + * Keywords: addLifeCycleListener removeLifeCycleListener + *
    + * Assertion IDs: A12.15-1 + *
    + * Assertion Description: + * A12.15-1 void postCreate(InstanceLifecycleEvent event); + * This method is called whenever a persistent instance is created, + * during makePersistent. It is called after the instance transitions + * to persistent-new. */ -public class InstanceLifecycleListenerCreate extends AbstractInstanceLifecycleListener { - - /** The InstanceLifecycleListener used for this test */ - InstanceLifecycleListenerImpl listener = new InstanceLifecycleListenerCreateImpl(); - - /** Return the listener. */ - protected InstanceLifecycleListenerImpl getListener() { - return listener; - } - - /** The persistent classes used for this test. */ - private static Class[] persistentClasses = new Class[] {PCPoint.class}; - - /** Return the persistent classes. */ - protected Class[] getPersistentClasses() { - return persistentClasses; - } - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(InstanceLifecycleListenerCreate.class); - } - - /** */ - public void testCreate() { - - // set up the persistent instance - PCPoint point = new PCPoint(12, 15); - listener.setExpectedSource(point); - - // makePersistent should cause the create listener to be called - getPM(); - pm.currentTransaction().begin(); - pm.makePersistent(point); - pm.currentTransaction().commit(); - - // verify that the listener was called - listener.verifyCallbacks(ASSERTION1_FAILED, new int[] {listener.POST_CREATE_LISTENER}); - } - - /** The LifeCycleListener class to be registered with the PersistenceManager. */ - private static class InstanceLifecycleListenerCreateImpl extends InstanceLifecycleListenerImpl { - - public void postCreate(InstanceLifecycleEvent event) { - notifyEvent(POST_CREATE_LISTENER); - checkEventType(ASSERTION1_FAILED, InstanceLifecycleEvent.CREATE, event.getEventType()); - checkEventSource(ASSERTION1_FAILED, event.getSource()); - checkPersistent(ASSERTION1_FAILED + " in postCreate, ", expectedSource); - checkNew(ASSERTION1_FAILED + " in postCreate, ", expectedSource); + +public class InstanceLifecycleListenerCreate + extends AbstractInstanceLifecycleListener { + + /** + * The InstanceLifecycleListener used for this test + */ + InstanceLifecycleListenerImpl listener = + new InstanceLifecycleListenerCreateImpl(); + + /** Return the listener. + */ + protected InstanceLifecycleListenerImpl getListener() { + return listener; + } + + /** + * The persistent classes used for this test. + */ + private static Class[] persistentClasses = new Class[] {PCPoint.class}; + + /** Return the persistent classes. + */ + protected Class[] getPersistentClasses() { + return persistentClasses; + } + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(InstanceLifecycleListenerCreate.class); + } + + /** */ + public void testCreate() { + + // set up the persistent instance + PCPoint point = new PCPoint(12, 15); + listener.setExpectedSource(point); + + // makePersistent should cause the create listener to be called + getPM(); + pm.currentTransaction().begin(); + pm.makePersistent(point); + pm.currentTransaction().commit(); + + // verify that the listener was called + listener.verifyCallbacks(ASSERTION1_FAILED, new int[] { + listener.POST_CREATE_LISTENER}); + } + + /** + * The LifeCycleListener class to be registered with the + * PersistenceManager. + */ + private static class InstanceLifecycleListenerCreateImpl + extends InstanceLifecycleListenerImpl { + + public void postCreate(InstanceLifecycleEvent event) { + notifyEvent(POST_CREATE_LISTENER); + checkEventType(ASSERTION1_FAILED, + InstanceLifecycleEvent.CREATE, event.getEventType()); + checkEventSource(ASSERTION1_FAILED, event.getSource()); + checkPersistent(ASSERTION1_FAILED + " in postCreate, ", + expectedSource); + checkNew(ASSERTION1_FAILED + " in postCreate, ", + expectedSource); + } + } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDelete.java b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDelete.java index 908fdb643..cdd384af3 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDelete.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDelete.java @@ -5,124 +5,163 @@ * 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 + * + * 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.jdo.tck.api.instancecallbacks; import java.util.Date; + import javax.jdo.listener.DeleteCallback; +import javax.jdo.JDOHelper; + import javax.jdo.listener.InstanceLifecycleEvent; +import javax.jdo.listener.InstanceLifecycleListener; +import javax.jdo.listener.DeleteLifecycleListener; + +import org.apache.jdo.tck.JDO_Test; + +import org.apache.jdo.tck.pc.mylib.PCPoint; + import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Test TestInstanceLifecycleListenerDelete
    - * Keywords: LifeCycleListener deletePersistent preDelete postDelete
    - * Assertion IDs: A12.15-7 A12.15-8
    - * Assertion Description: A12.15-7 void preDelete(InstanceLifecycleEvent event); This method - * is called whenever a persistent instance is deleted, during deletePersistent. It is called before - * the state transition and before the jdoPreDelete method is invoked on the instance. A12.15-8 void - * postDelete(InstanceLifecycleEvent event); This method is called whenever a persistent instance is - * deleted, during deletePersistent. It is called after the jdoPreDelete method is invoked on the - * instance and after the state transition. + * Title: Test TestInstanceLifecycleListenerDelete + *
    + * Keywords: LifeCycleListener deletePersistent preDelete postDelete + *
    + * Assertion IDs: A12.15-7 A12.15-8 + *
    + * Assertion Description: + * A12.15-7 void preDelete(InstanceLifecycleEvent event); + * This method is called whenever a persistent instance + * is deleted, during deletePersistent. It is called before + * the state transition and before the jdoPreDelete method + * is invoked on the instance. + * A12.15-8 void postDelete(InstanceLifecycleEvent event); + * This method is called whenever a persistent instance + * is deleted, during deletePersistent. It is called + * after the jdoPreDelete method is invoked on the instance + * and after the state transition. */ -public class InstanceLifecycleListenerDelete extends AbstractInstanceLifecycleListener { - - /** The InstanceLifecycleListener used for this test */ - InstanceLifecycleListenerImpl listener = new InstanceLifecycleListenerDeleteImpl(); - - /** Return the listener. */ - protected InstanceLifecycleListenerImpl getListener() { - return listener; - } - - /** The persistent classes used for this test. */ - private static Class[] persistentClasses = new Class[] {PC.class}; - - /** Return the persistent classes. */ - protected Class[] getPersistentClasses() { - return persistentClasses; - } - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(InstanceLifecycleListenerDelete.class); - } - - /** - * This test creates a new persistent instance, and deletes it. The pre-delete listener, - * pre-delete callback, and post-delete listener will be called. - */ - public void testDelete() { - - // set up the persistent instance - PC pc = new PC(listener); - listener.setExpectedSource(pc); - - // deletePersistent should cause the delete listeners to be called - getPM(); - pm.currentTransaction().begin(); - pm.makePersistent(pc); - pm.deletePersistent(pc); - pm.currentTransaction().commit(); - - // now check the callback and listeners were called - listener.verifyCallbacks( - ASSERTION7_FAILED, - (new int[] { - listener.PRE_DELETE_LISTENER, listener.PRE_DELETE_CALLBACK, listener.POST_DELETE_LISTENER - })); - } - - /** The LifeCycleListener to be registered with the PersistenceManager. */ - private static class InstanceLifecycleListenerDeleteImpl extends InstanceLifecycleListenerImpl { - - public void preDelete(InstanceLifecycleEvent event) { - notifyEvent(PRE_DELETE_LISTENER); - checkEventType(ASSERTION7_FAILED, InstanceLifecycleEvent.DELETE, event.getEventType()); - checkEventSource(ASSERTION7_FAILED, event.getSource()); - checkPersistent(ASSERTION7_FAILED + " in preDelete, ", expectedSource); - checkNotDeleted(ASSERTION7_FAILED + " in preDelete, ", expectedSource); - } - public void postDelete(InstanceLifecycleEvent event) { - notifyEvent(POST_DELETE_LISTENER); - checkEventType(ASSERTION8_FAILED, InstanceLifecycleEvent.DELETE, event.getEventType()); - checkEventSource(ASSERTION8_FAILED, event.getSource()); - checkPersistent(ASSERTION8_FAILED + " in postDelete, ", expectedSource); - checkDeleted(ASSERTION8_FAILED + " in postDelete, ", expectedSource); +public class InstanceLifecycleListenerDelete + extends AbstractInstanceLifecycleListener { + + + /** + * The InstanceLifecycleListener used for this test + */ + InstanceLifecycleListenerImpl listener = + new InstanceLifecycleListenerDeleteImpl(); + + /** Return the listener. + */ + protected InstanceLifecycleListenerImpl getListener() { + return listener; } - } - /** The persistence-capable class that implements the delete callback. */ - public static class PC implements DeleteCallback { - transient InstanceLifecycleListenerImpl listener; - int id; + /** + * The persistent classes used for this test. + */ + private static Class[] persistentClasses = new Class[] {PC.class}; - public PC() {} + /** Return the persistent classes. + */ + protected Class[] getPersistentClasses() { + return persistentClasses; + } - public PC(InstanceLifecycleListenerImpl listener) { - id = counter++; - this.listener = listener; + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(InstanceLifecycleListenerDelete.class); } - static int counter = (int) (new Date().getTime()); + /** + * This test creates a new persistent instance, and deletes it. + * The pre-delete listener, pre-delete callback, and post-delete + * listener will be called. + */ + public void testDelete() { + + // set up the persistent instance + PC pc = new PC(listener); + listener.setExpectedSource(pc); + + // deletePersistent should cause the delete listeners to be called + getPM(); + pm.currentTransaction().begin(); + pm.makePersistent(pc); + pm.deletePersistent(pc); + pm.currentTransaction().commit(); + + // now check the callback and listeners were called + listener.verifyCallbacks(ASSERTION7_FAILED, (new int[] { + listener.PRE_DELETE_LISTENER, + listener.PRE_DELETE_CALLBACK, + listener.POST_DELETE_LISTENER})); + } + + /** + * The LifeCycleListener to be registered with the + * PersistenceManager. + */ + private static class InstanceLifecycleListenerDeleteImpl + extends InstanceLifecycleListenerImpl { + + public void preDelete(InstanceLifecycleEvent event) { + notifyEvent(PRE_DELETE_LISTENER); + checkEventType(ASSERTION7_FAILED, + InstanceLifecycleEvent.DELETE, event.getEventType()); + checkEventSource(ASSERTION7_FAILED, event.getSource()); + checkPersistent(ASSERTION7_FAILED + " in preDelete, ", + expectedSource); + checkNotDeleted(ASSERTION7_FAILED + " in preDelete, ", + expectedSource); + } + + public void postDelete(InstanceLifecycleEvent event) { + notifyEvent(POST_DELETE_LISTENER); + checkEventType(ASSERTION8_FAILED, + InstanceLifecycleEvent.DELETE, event.getEventType()); + checkEventSource(ASSERTION8_FAILED, event.getSource()); + checkPersistent(ASSERTION8_FAILED + " in postDelete, ", + expectedSource); + checkDeleted(ASSERTION8_FAILED + " in postDelete, ", + expectedSource); + } + } - public void jdoPreDelete() { - if (listener != null) { - listener.notifyEvent(listener.PRE_DELETE_CALLBACK); - } + /** The persistence-capable class that implements the delete callback. + */ + public static class PC implements DeleteCallback { + transient InstanceLifecycleListenerImpl listener; + int id; + public PC() { + } + public PC(InstanceLifecycleListenerImpl listener) { + id = counter++; + this.listener = listener; + } + static int counter = (int)(new Date().getTime()); + + public void jdoPreDelete() { + if (listener != null) { + listener.notifyEvent(listener.PRE_DELETE_CALLBACK); + } + } } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDetach.java b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDetach.java index badc5f332..577046266 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDetach.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDetach.java @@ -5,143 +5,178 @@ * 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 + * + * 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.jdo.tck.api.instancecallbacks; import java.util.Date; + import javax.jdo.listener.DetachCallback; + +import javax.jdo.JDOHelper; + import javax.jdo.listener.InstanceLifecycleEvent; +import javax.jdo.listener.InstanceLifecycleListener; +import javax.jdo.listener.ClearLifecycleListener; + +import org.apache.jdo.tck.JDO_Test; + import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Test InstanceLifecycleListenerDetach
    - * Keywords: LifeCycleListener preDetach postDetach
    - * Assertion IDs: A12.15-11 A12.15-12
    - * Assertion Description: A12.15-11 void preDetach(InstanceLifecycleEvent event); This - * method is called before a persistent instance is copied for detachment. A12.15-12 void - * postDetach(InstanceLifecycleEvent event); This method is called whenever a persistent instance is - * copied for detachment. The source instance is the detached copy; the target instance is the - * persistent instance. + * Title: Test InstanceLifecycleListenerDetach + *
    + * Keywords: LifeCycleListener preDetach postDetach + *
    + * Assertion IDs: A12.15-11 A12.15-12 + *
    + * Assertion Description: + * A12.15-11 void preDetach(InstanceLifecycleEvent event); + * This method is called before a persistent instance is copied + * for detachment. + * A12.15-12 void postDetach(InstanceLifecycleEvent event); + * This method is called whenever a persistent instance is copied + * for detachment. + * The source instance is the detached copy; the target instance + * is the persistent instance. */ -public class InstanceLifecycleListenerDetach extends AbstractInstanceLifecycleListener { - - /** The InstanceLifecycleListener used for this test */ - InstanceLifecycleListenerImpl listener = new InstanceLifecycleListenerDetachImpl(); - - /** Return the listener. */ - protected InstanceLifecycleListenerImpl getListener() { - return listener; - } - - /** The persistent classes used for this test. */ - private static Class[] persistentClasses = new Class[] {PC.class}; - - /** Return the persistent classes. */ - protected Class[] getPersistentClasses() { - return persistentClasses; - } - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(InstanceLifecycleListenerLoad.class); - } - - /** - * This test creates a new persistent instance and commits it. Since the RetainValues flag is set - * to false, the persistent fields will be cleared, and the pre-clear listener, pre-clear - * callback, and post-clear listener will be called. - */ - public void testDetach() { - - // set up the persistent instance - PC pc = new PC(listener); - listener.setExpectedSource(pc); - - getPM(); - pm.currentTransaction().begin(); - pm.makePersistent(pc); - // detachCopy should cause the detach listeners to be called - PC detached = (PC) pm.detachCopy(pc); - pm.currentTransaction().commit(); - - // now check the callback and listener were called - listener.verifyCallbacks( - ASSERTION11_FAILED, - new int[] { - listener.PRE_DETACH_LISTENER, listener.PRE_DETACH_CALLBACK, listener.POST_DETACH_LISTENER - }); - } - - /** The LifeCycleListener to be registered with the PersistenceManager. */ - private static class InstanceLifecycleListenerDetachImpl extends InstanceLifecycleListenerImpl { - - public void preDetach(InstanceLifecycleEvent event) { - notifyEvent(PRE_DETACH_LISTENER); - checkEventType(ASSERTION11_FAILED, InstanceLifecycleEvent.DETACH, event.getEventType()); - checkEventSource(ASSERTION11_FAILED, event.getSource()); - checkPersistent(ASSERTION11_FAILED + "in preDetach, source ", event.getSource()); - } - - public void postDetach(InstanceLifecycleEvent event) { - notifyEvent(POST_DETACH_LISTENER); - checkEventType(ASSERTION12_FAILED, InstanceLifecycleEvent.DETACH, event.getEventType()); - checkSame(ASSERTION12_FAILED + "in postDetach, target ", expectedSource, event.getTarget()); - checkNotPersistent(ASSERTION12_FAILED + "in postDetach, source ", event.getSource()); - checkPersistent(ASSERTION12_FAILED + "in postDetach, target ", event.getTarget()); - checkTrue( - ASSERTION12_FAILED + "in postDetach, source wasPostDetachCalled() ", - ((PC) event.getSource()).wasPostDetachCalled()); - } - } - /** The persistence-capable class that implements the load callback. */ - public static class PC implements DetachCallback { - transient InstanceLifecycleListenerImpl listener; - int id; +public class InstanceLifecycleListenerDetach + extends AbstractInstanceLifecycleListener { - public PC() {} + + /** + * The InstanceLifecycleListener used for this test + */ + InstanceLifecycleListenerImpl listener = + new InstanceLifecycleListenerDetachImpl(); - public PC(InstanceLifecycleListenerImpl listener) { - id = counter++; - this.listener = listener; + /** Return the listener. + */ + protected InstanceLifecycleListenerImpl getListener() { + return listener; } - static int counter = (int) (new Date().getTime()); + /** + * The persistent classes used for this test. + */ + private static Class[] persistentClasses = new Class[] {PC.class}; - transient boolean postDetachCalled = false; - - public boolean wasPostDetachCalled() { - return postDetachCalled; + /** Return the persistent classes. + */ + protected Class[] getPersistentClasses() { + return persistentClasses; } - transient Object postDetachObject = null; + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(InstanceLifecycleListenerLoad.class); + } - public Object getPostDetachObject() { - return postDetachObject; + /** + * This test creates a new persistent instance and commits it. + * Since the RetainValues flag is set to false, the persistent + * fields will be cleared, and the pre-clear listener, + * pre-clear callback, and post-clear listener will be called. + */ + public void testDetach() { + + // set up the persistent instance + PC pc = new PC(listener); + listener.setExpectedSource(pc); + + getPM(); + pm.currentTransaction().begin(); + pm.makePersistent(pc); + // detachCopy should cause the detach listeners to be called + PC detached = (PC)pm.detachCopy(pc); + pm.currentTransaction().commit(); + + // now check the callback and listener were called + listener.verifyCallbacks(ASSERTION11_FAILED, new int[] { + listener.PRE_DETACH_LISTENER, + listener.PRE_DETACH_CALLBACK, + listener.POST_DETACH_LISTENER}); } + + /** + * The LifeCycleListener to be registered with the + * PersistenceManager. + */ + private static class InstanceLifecycleListenerDetachImpl + extends InstanceLifecycleListenerImpl { + + public void preDetach(InstanceLifecycleEvent event) { + notifyEvent(PRE_DETACH_LISTENER); + checkEventType(ASSERTION11_FAILED, + InstanceLifecycleEvent.DETACH, event.getEventType()); + checkEventSource(ASSERTION11_FAILED, event.getSource()); + checkPersistent(ASSERTION11_FAILED + "in preDetach, source ", + event.getSource()); + } + + public void postDetach(InstanceLifecycleEvent event) { + notifyEvent(POST_DETACH_LISTENER); + checkEventType(ASSERTION12_FAILED, + InstanceLifecycleEvent.DETACH, event.getEventType()); + checkSame(ASSERTION12_FAILED + "in postDetach, target ", + expectedSource, event.getTarget()); + checkNotPersistent(ASSERTION12_FAILED + "in postDetach, source ", + event.getSource()); + checkPersistent(ASSERTION12_FAILED + "in postDetach, target ", + event.getTarget()); + checkTrue(ASSERTION12_FAILED + + "in postDetach, source wasPostDetachCalled() ", + ((PC)event.getSource()).wasPostDetachCalled()); + } - public void jdoPreDetach() { - if (listener != null) { - listener.notifyEvent(listener.PRE_DETACH_CALLBACK); - } } - public void jdoPostDetach(Object obj) { - postDetachCalled = true; - postDetachObject = obj; + /** The persistence-capable class that implements the load callback. + */ + public static class PC implements DetachCallback { + transient InstanceLifecycleListenerImpl listener; + int id; + public PC() { + } + public PC(InstanceLifecycleListenerImpl listener) { + id = counter++; + this.listener = listener; + } + static int counter = (int)(new Date().getTime()); + + transient boolean postDetachCalled = false; + public boolean wasPostDetachCalled() { + return postDetachCalled; + } + + transient Object postDetachObject = null; + public Object getPostDetachObject() { + return postDetachObject; + } + + public void jdoPreDetach() { + if (listener != null) { + listener.notifyEvent(listener.PRE_DETACH_CALLBACK); + } + } + public void jdoPostDetach(Object obj) { + postDetachCalled = true; + postDetachObject = obj; + } } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDirty.java b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDirty.java index 97e55c6b0..b22fc0f37 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDirty.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerDirty.java @@ -5,101 +5,144 @@ * 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 + * + * 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.jdo.tck.api.instancecallbacks; +import java.util.Date; + +import javax.jdo.JDOHelper; + import javax.jdo.listener.InstanceLifecycleEvent; +import javax.jdo.listener.InstanceLifecycleListener; +import javax.jdo.listener.ClearLifecycleListener; + +import org.apache.jdo.tck.JDO_Test; + import org.apache.jdo.tck.pc.mylib.PCPoint; + import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Test InstanceLifecycleListenerDirty
    - * Keywords: LifeCycleListener preDirty postDirty
    - * Assertion IDs: A12.15-9 A12.15-10
    - * Assertion Description: A12.15-9 void preDirty(InstanceLifecycleEvent event); This method - * is called whenever a persistent clean instance is first made dirty, during an operation that - * modifies the value of a persistent or transactional field. It is called before the field value is - * changed. A12.15-10 void postDirty(InstanceLifecycleEvent event); This method is called whenever a - * persistent clean instance is first made dirty, during an operation that modifies the value of a - * persistent or transactional field. It is called after the field value was changed. + * Title: Test InstanceLifecycleListenerDirty + *
    + * Keywords: LifeCycleListener preDirty postDirty + *
    + * Assertion IDs: A12.15-9 A12.15-10 + *
    + * Assertion Description: + * A12.15-9 void preDirty(InstanceLifecycleEvent event); + * This method is called whenever a persistent clean instance + * is first made dirty, during an operation that modifies + * the value of a persistent or transactional field. It is called + * before the field value is changed. + * A12.15-10 void postDirty(InstanceLifecycleEvent event); + * This method is called whenever a persistent clean instance + * is first made dirty, during an operation that modifies + * the value of a persistent or transactional field. It is called + * after the field value was changed. */ -public class InstanceLifecycleListenerDirty extends AbstractInstanceLifecycleListener { - - /** The InstanceLifecycleListener used for this test */ - InstanceLifecycleListenerImpl listener = new InstanceLifecycleListenerDirtyImpl(); - - /** Return the listener. */ - protected InstanceLifecycleListenerImpl getListener() { - return listener; - } - - /** The persistent classes used for this test. */ - private static Class[] persistentClasses = new Class[] {PCPoint.class}; - - /** Return the persistent classes. */ - protected Class[] getPersistentClasses() { - return persistentClasses; - } - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(InstanceLifecycleListenerDirty.class); - } - - /** - * This test creates a new persistent instance and commits it. A new transaction is started and a - * persistent field is modified. This will call the dirty listeners. - */ - public void testDirty() { - - // set up the persistent instance - PCPoint pc = new PCPoint(100, 200); - listener.setExpectedSource(pc); - - // setY should cause the dirty listeners to be called - getPM(); - pm.currentTransaction().begin(); - pm.makePersistent(pc); - pm.currentTransaction().commit(); - pm.currentTransaction().begin(); - pc.setY(Integer.valueOf(666)); - pm.currentTransaction().commit(); - - // now check the callback and listener were called - listener.verifyCallbacks( - ASSERTION10_FAILED, new int[] {listener.PRE_DIRTY_LISTENER, listener.POST_DIRTY_LISTENER}); - } - - /** The LifeCycleListener to be registered with the PersistenceManager. */ - private static class InstanceLifecycleListenerDirtyImpl extends InstanceLifecycleListenerImpl { - - public void preDirty(InstanceLifecycleEvent event) { - notifyEvent(PRE_DIRTY_LISTENER); - checkEventType(ASSERTION9_FAILED, InstanceLifecycleEvent.DIRTY, event.getEventType()); - checkEventSource(ASSERTION9_FAILED, event.getSource()); - checkPersistent(ASSERTION9_FAILED + " in preDirty, ", expectedSource); - checkNotDirty(ASSERTION9_FAILED + " in preDirty, ", expectedSource); + +public class InstanceLifecycleListenerDirty + extends AbstractInstanceLifecycleListener { + + + /** + * The InstanceLifecycleListener used for this test + */ + InstanceLifecycleListenerImpl listener = + new InstanceLifecycleListenerDirtyImpl(); + + /** Return the listener. + */ + protected InstanceLifecycleListenerImpl getListener() { + return listener; } - public void postDirty(InstanceLifecycleEvent event) { - notifyEvent(POST_DIRTY_LISTENER); - checkEventType(ASSERTION10_FAILED, InstanceLifecycleEvent.DIRTY, event.getEventType()); - checkEventSource(ASSERTION10_FAILED, event.getSource()); - checkPersistent(ASSERTION10_FAILED + " in postDirty,", expectedSource); - checkDirty(ASSERTION9_FAILED + " in postDirty, ", expectedSource); + /** + * The persistent classes used for this test. + */ + private static Class[] persistentClasses = new Class[] {PCPoint.class}; + + /** Return the persistent classes. + */ + protected Class[] getPersistentClasses() { + return persistentClasses; } - } + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(InstanceLifecycleListenerDirty.class); + } + + /** + * This test creates a new persistent instance and commits it. + * A new transaction is started and a persistent field is modified. + * This will call the dirty listeners. + */ + public void testDirty() { + + // set up the persistent instance + PCPoint pc = new PCPoint(100, 200); + listener.setExpectedSource(pc); + + // setY should cause the dirty listeners to be called + getPM(); + pm.currentTransaction().begin(); + pm.makePersistent(pc); + pm.currentTransaction().commit(); + pm.currentTransaction().begin(); + pc.setY(Integer.valueOf(666)); + pm.currentTransaction().commit(); + + // now check the callback and listener were called + listener.verifyCallbacks(ASSERTION10_FAILED, new int[] { + listener.PRE_DIRTY_LISTENER, + listener.POST_DIRTY_LISTENER}); + } + + /** + * The LifeCycleListener to be registered with the + * PersistenceManager. + */ + private static class InstanceLifecycleListenerDirtyImpl + extends InstanceLifecycleListenerImpl { + + public void preDirty(InstanceLifecycleEvent event) { + notifyEvent(PRE_DIRTY_LISTENER); + checkEventType(ASSERTION9_FAILED, + InstanceLifecycleEvent.DIRTY, event.getEventType()); + checkEventSource(ASSERTION9_FAILED, event.getSource()); + checkPersistent(ASSERTION9_FAILED + " in preDirty, ", + expectedSource); + checkNotDirty(ASSERTION9_FAILED + " in preDirty, ", + expectedSource); + } + + public void postDirty(InstanceLifecycleEvent event) { + notifyEvent(POST_DIRTY_LISTENER); + checkEventType(ASSERTION10_FAILED, + InstanceLifecycleEvent.DIRTY, event.getEventType()); + checkEventSource(ASSERTION10_FAILED, event.getSource()); + checkPersistent(ASSERTION10_FAILED + " in postDirty,", + expectedSource); + checkDirty(ASSERTION9_FAILED + " in postDirty, ", + expectedSource); + } + + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerLoad.java b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerLoad.java index 48a7ad57d..4692dc5d6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerLoad.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerLoad.java @@ -5,118 +5,151 @@ * 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 + * + * 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.jdo.tck.api.instancecallbacks; import java.util.Date; -import javax.jdo.listener.InstanceLifecycleEvent; + import javax.jdo.listener.LoadCallback; + +import javax.jdo.JDOHelper; + +import javax.jdo.listener.InstanceLifecycleEvent; +import javax.jdo.listener.InstanceLifecycleListener; +import javax.jdo.listener.ClearLifecycleListener; + +import org.apache.jdo.tck.JDO_Test; + import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Test InstanceLifecycleListenerLoad
    - * Keywords: LifeCycleListener postLoad
    - * Assertion IDs: A12.15-2
    - * Assertion Description: A12.15-2 void postLoad(InstanceLifecycleEvent event); This method - * is called whenever a persistent instance is loaded. It is called after the jdoPostLoad method is - * invoked on the instance. + * Title: Test InstanceLifecycleListenerLoad + *
    + * Keywords: LifeCycleListener postLoad + *
    + * Assertion IDs: A12.15-2 + *
    + * Assertion Description: + * A12.15-2 void postLoad(InstanceLifecycleEvent event); + * This method is called whenever a persistent instance is loaded. + * It is called after the jdoPostLoad method is invoked on the instance. */ -public class InstanceLifecycleListenerLoad extends AbstractInstanceLifecycleListener { - - /** The InstanceLifecycleListener used for this test */ - InstanceLifecycleListenerImpl listener = new InstanceLifecycleListenerLoadImpl(); - - /** Return the listener. */ - protected InstanceLifecycleListenerImpl getListener() { - return listener; - } - - /** The persistent classes used for this test. */ - private static Class[] persistentClasses = new Class[] {PC.class}; - - /** Return the persistent classes. */ - protected Class[] getPersistentClasses() { - return persistentClasses; - } - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(InstanceLifecycleListenerLoad.class); - } - - /** - * This test creates a new persistent instance and commits it. In a new transaction, a value is - * accessed, which causes the instance to be loaded. - */ - public void testLoad() { - - // set up the persistent instance - PC pc = new PC(listener); - listener.setExpectedSource(pc); - - // field access should cause the load listeners to be called - getPM(); - pm.currentTransaction().begin(); - pm.currentTransaction().setRetainValues(false); - pm.makePersistent(pc); - pm.currentTransaction().commit(); - pm.currentTransaction().begin(); - pc.getValue(); - pm.currentTransaction().commit(); - - // now check the callback and listener were called - listener.verifyCallbacks( - ASSERTION2_FAILED, new int[] {listener.POST_LOAD_CALLBACK, listener.POST_LOAD_LISTENER}); - } - - /** The LifeCycleListener to be registered with the PersistenceManager. */ - private static class InstanceLifecycleListenerLoadImpl extends InstanceLifecycleListenerImpl { - - public void postLoad(InstanceLifecycleEvent event) { - notifyEvent(POST_LOAD_LISTENER); - checkEventType(ASSERTION2_FAILED, InstanceLifecycleEvent.LOAD, event.getEventType()); - checkEventSource(ASSERTION2_FAILED, event.getSource()); - checkPersistent(ASSERTION2_FAILED + " in postLoad, ", expectedSource); - checkNotNew(ASSERTION2_FAILED + " in postLoad, ", expectedSource); + +public class InstanceLifecycleListenerLoad + extends AbstractInstanceLifecycleListener { + + + /** + * The InstanceLifecycleListener used for this test + */ + InstanceLifecycleListenerImpl listener = + new InstanceLifecycleListenerLoadImpl(); + + /** Return the listener. + */ + protected InstanceLifecycleListenerImpl getListener() { + return listener; } - } - /** The persistence-capable class that implements the load callback. */ - public static class PC implements LoadCallback { - transient InstanceLifecycleListenerImpl listener; - int id; - int value; + /** + * The persistent classes used for this test. + */ + private static Class[] persistentClasses = new Class[] {PC.class}; - public int getValue() { - return value; + /** Return the persistent classes. + */ + protected Class[] getPersistentClasses() { + return persistentClasses; } - public PC() {} + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(InstanceLifecycleListenerLoad.class); + } - public PC(InstanceLifecycleListenerImpl listener) { - id = counter++; - this.listener = listener; + /** + * This test creates a new persistent instance and commits it. + * In a new transaction, a value is accessed, which causes the + * instance to be loaded. + */ + public void testLoad() { + + // set up the persistent instance + PC pc = new PC(listener); + listener.setExpectedSource(pc); + + // field access should cause the load listeners to be called + getPM(); + pm.currentTransaction().begin(); + pm.currentTransaction().setRetainValues(false); + pm.makePersistent(pc); + pm.currentTransaction().commit(); + pm.currentTransaction().begin(); + pc.getValue(); + pm.currentTransaction().commit(); + + // now check the callback and listener were called + listener.verifyCallbacks(ASSERTION2_FAILED, new int[] { + listener.POST_LOAD_CALLBACK, + listener.POST_LOAD_LISTENER}); } + + /** + * The LifeCycleListener to be registered with the + * PersistenceManager. + */ + private static class InstanceLifecycleListenerLoadImpl + extends InstanceLifecycleListenerImpl { + + public void postLoad(InstanceLifecycleEvent event) { + notifyEvent(POST_LOAD_LISTENER); + checkEventType(ASSERTION2_FAILED, + InstanceLifecycleEvent.LOAD, event.getEventType()); + checkEventSource(ASSERTION2_FAILED, event.getSource()); + checkPersistent(ASSERTION2_FAILED + " in postLoad, ", + expectedSource); + checkNotNew(ASSERTION2_FAILED + " in postLoad, ", + expectedSource); + } - static int counter = (int) (new Date().getTime()); + } - public void jdoPostLoad() { - if (listener != null) { - listener.notifyEvent(listener.POST_LOAD_CALLBACK); - } + /** The persistence-capable class that implements the load callback. + */ + public static class PC implements LoadCallback { + transient InstanceLifecycleListenerImpl listener; + int id; + int value; + public int getValue() { + return value; + } + public PC() { + } + public PC(InstanceLifecycleListenerImpl listener) { + id = counter++; + this.listener = listener; + } + static int counter = (int)(new Date().getTime()); + + public void jdoPostLoad() { + if (listener != null) { + listener.notifyEvent(listener.POST_LOAD_CALLBACK); + } + } } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerStore.java b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerStore.java index fb9e15646..d1592464c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerStore.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/InstanceLifecycleListenerStore.java @@ -5,122 +5,157 @@ * 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 + * + * 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.jdo.tck.api.instancecallbacks; import java.util.Date; -import javax.jdo.listener.InstanceLifecycleEvent; + import javax.jdo.listener.StoreCallback; + +import javax.jdo.JDOHelper; + +import javax.jdo.listener.InstanceLifecycleEvent; +import javax.jdo.listener.InstanceLifecycleListener; +import javax.jdo.listener.ClearLifecycleListener; + +import org.apache.jdo.tck.JDO_Test; + import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Test InstanceLifecycleListenerLoad
    - * Keywords: LifeCycleListener preStore postStore
    - * Assertion IDs: A12.15-3 A12.15-4
    - * Assertion Description: A12.15-3 void preStore(InstanceLifecycleEvent event); This method - * is called whenever a persistent instance is stored, for example during flush or commit. It is - * called before the jdoPreStore method is invoked on the instance. A12.15-4 void - * postStore(InstanceLifecycleEvent event); This method is called whenever a persistent instance is - * stored, for example during flush or commit. It is called after the jdoPreStore method is invoked - * on the instance. An object identity for a per?sistent-new instance must have been assigned to the - * instance when this callback is invoked. + * Title: Test InstanceLifecycleListenerLoad + *
    + * Keywords: LifeCycleListener preStore postStore + *
    + * Assertion IDs: A12.15-3 A12.15-4 + *
    + * Assertion Description: + * A12.15-3 void preStore(InstanceLifecycleEvent event); + * This method is called whenever a persistent instance is stored, + * for example during flush or commit. It is called + * before the jdoPreStore method is invoked on the instance. + * A12.15-4 void postStore(InstanceLifecycleEvent event); + * This method is called whenever a persistent instance is stored, + * for example during flush or commit. It is called + * after the jdoPreStore method is invoked on the instance. + * An object identity for a per?sistent-new instance must have been assigned + * to the instance when this callback is invoked. */ -public class InstanceLifecycleListenerStore extends AbstractInstanceLifecycleListener { - - /** The InstanceLifecycleListener used for this test */ - InstanceLifecycleListenerImpl listener = new InstanceLifecycleListenerStoreImpl(); - - /** Return the listener. */ - protected InstanceLifecycleListenerImpl getListener() { - return listener; - } - - /** The persistent classes used for this test. */ - private static Class[] persistentClasses = new Class[] {PC.class}; - - /** Return the persistent classes. */ - protected Class[] getPersistentClasses() { - return persistentClasses; - } - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(InstanceLifecycleListenerStore.class); - } - - /** - * This test creates a new persistent instance and commits it. The store callback and listeners - * will be called. - */ - public void testStore() { - - // set up the persistent instance - PC pc = new PC(listener); - listener.setExpectedSource(pc); - - // commit should cause the store listeners to be called - getPM(); - pm.currentTransaction().begin(); - pm.makePersistent(pc); - pm.currentTransaction().commit(); - - // now check the callback and listener were called - listener.verifyCallbacks( - ASSERTION2_FAILED, - new int[] { - listener.PRE_STORE_LISTENER, listener.PRE_STORE_CALLBACK, listener.POST_STORE_LISTENER - }); - } - - /** The LifeCycleListener to be registered with the PersistenceManager. */ - private static class InstanceLifecycleListenerStoreImpl extends InstanceLifecycleListenerImpl { - - public void preStore(InstanceLifecycleEvent event) { - notifyEvent(PRE_STORE_LISTENER); - checkEventType(ASSERTION3_FAILED, InstanceLifecycleEvent.STORE, event.getEventType()); - checkEventSource(ASSERTION3_FAILED, event.getSource()); - checkPersistent(ASSERTION3_FAILED + " in preStore, ", expectedSource); - } - public void postStore(InstanceLifecycleEvent event) { - notifyEvent(POST_STORE_LISTENER); - checkEventType(ASSERTION4_FAILED, InstanceLifecycleEvent.STORE, event.getEventType()); - checkEventSource(ASSERTION4_FAILED, event.getSource()); - checkPersistent(ASSERTION4_FAILED + " in postStore, ", expectedSource); +public class InstanceLifecycleListenerStore + extends AbstractInstanceLifecycleListener { + + + /** + * The InstanceLifecycleListener used for this test + */ + InstanceLifecycleListenerImpl listener = + new InstanceLifecycleListenerStoreImpl(); + + /** Return the listener. + */ + protected InstanceLifecycleListenerImpl getListener() { + return listener; } - } - /** The persistence-capable class that implements the load callback. */ - public static class PC implements StoreCallback { - transient InstanceLifecycleListenerImpl listener; - int id; + /** + * The persistent classes used for this test. + */ + private static Class[] persistentClasses = new Class[] {PC.class}; + + /** Return the persistent classes. + */ + protected Class[] getPersistentClasses() { + return persistentClasses; + } - public PC() {} + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(InstanceLifecycleListenerStore.class); + } - public PC(InstanceLifecycleListenerImpl listener) { - id = counter++; - this.listener = listener; + /** + * This test creates a new persistent instance and commits it. + * The store callback and listeners will be called. + */ + public void testStore() { + + // set up the persistent instance + PC pc = new PC(listener); + listener.setExpectedSource(pc); + + // commit should cause the store listeners to be called + getPM(); + pm.currentTransaction().begin(); + pm.makePersistent(pc); + pm.currentTransaction().commit(); + + // now check the callback and listener were called + listener.verifyCallbacks(ASSERTION2_FAILED, new int[] { + listener.PRE_STORE_LISTENER, + listener.PRE_STORE_CALLBACK, + listener.POST_STORE_LISTENER}); } + + /** + * The LifeCycleListener to be registered with the + * PersistenceManager. + */ + private static class InstanceLifecycleListenerStoreImpl + extends InstanceLifecycleListenerImpl { + + public void preStore(InstanceLifecycleEvent event) { + notifyEvent(PRE_STORE_LISTENER); + checkEventType(ASSERTION3_FAILED, + InstanceLifecycleEvent.STORE, event.getEventType()); + checkEventSource(ASSERTION3_FAILED, event.getSource()); + checkPersistent(ASSERTION3_FAILED + " in preStore, ", + expectedSource); + } + + public void postStore(InstanceLifecycleEvent event) { + notifyEvent(POST_STORE_LISTENER); + checkEventType(ASSERTION4_FAILED, + InstanceLifecycleEvent.STORE, event.getEventType()); + checkEventSource(ASSERTION4_FAILED, event.getSource()); + checkPersistent(ASSERTION4_FAILED + " in postStore, ", + expectedSource); + } - static int counter = (int) (new Date().getTime()); + } - public void jdoPreStore() { - if (listener != null) { - listener.notifyEvent(listener.PRE_STORE_CALLBACK); - } + /** The persistence-capable class that implements the load callback. + */ + public static class PC implements StoreCallback { + transient InstanceLifecycleListenerImpl listener; + int id; + public PC() { + } + public PC(InstanceLifecycleListenerImpl listener) { + id = counter++; + this.listener = listener; + } + static int counter = (int)(new Date().getTime()); + + public void jdoPreStore() { + if (listener != null) { + listener.notifyEvent(listener.PRE_STORE_CALLBACK); + } + } } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/ModificationOfNontransactionalNonpersistentFields.java b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/ModificationOfNontransactionalNonpersistentFields.java index 84f04cf67..7aec74afa 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/ModificationOfNontransactionalNonpersistentFields.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/ModificationOfNontransactionalNonpersistentFields.java @@ -5,33 +5,40 @@ * 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 + * + * 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.jdo.tck.api.instancecallbacks; import java.util.Iterator; + import javax.jdo.JDODataStoreException; import javax.jdo.JDOUserException; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackNonPersistFdsClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Modification of Nontransactional Nonpersistent Fields
    - * Keywords: instancecallbacks
    - * Assertion ID: A6.4.1-3.
    - * Assertion Description: Nontransactional non-persistent fields may be modified during - * execution of user-written callbacks defined in interface InstanceCallbacks at - * specific points in the life cycle. + *Title: Modification of Nontransactional Nonpersistent Fields + *
    + *Keywords: instancecallbacks + *
    + *Assertion ID: A6.4.1-3. + *
    + *Assertion Description: +Nontransactional non-persistent fields may be modified during execution of +user-written callbacks defined in interface InstanceCallbacks +at specific points in the life cycle. + */ /* @@ -45,151 +52,131 @@ */ public class ModificationOfNontransactionalNonpersistentFields extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.1-3 (ModificationOfNontransactionalNonpersistentFields) failed"; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ModificationOfNontransactionalNonpersistentFields.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(InstanceCallbackNonPersistFdsClass.class); - } - - /** */ - public void test() { - pm = getPM(); - Transaction t = pm.currentTransaction(); - t.setRetainValues(false); - - InstanceCallbackNonPersistFdsClass.initializeStaticsForTest(); - - t.begin(); - // create instance - InstanceCallbackNonPersistFdsClass obj1 = new InstanceCallbackNonPersistFdsClass(1.1f, 1); - pm.makePersistent(obj1); - Object objPtr1 = pm.getObjectId(obj1); - obj1.setNonPersist(1, (char) 1, 0, (short) 0); - t.commit(); // jdoPreStore() and jdoPreClear() called - - t.begin(); - try { - obj1 = - (InstanceCallbackNonPersistFdsClass) - pm.getObjectById(objPtr1, true); // jdoPostLoad() called - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail( - ASSERTION_FAILED, - "ModificationOfNontransactionalNonpersistentFields: Could not locate persistent object obj1 created in previous transaction, got " - + e); - return; - } catch (JDODataStoreException e) { - // could not locate persistent object created in previous transaction - fail( - ASSERTION_FAILED, - "ModificationOfNontransactionalNonpersistentFields: Could not locate persistent object obj1 created in previous transaction, got " - + e); - return; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.1-3 (ModificationOfNontransactionalNonpersistentFields) failed"; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ModificationOfNontransactionalNonpersistentFields.class); } - // check fields set in jdoPostLoad() - if (obj1.i != -10) { - fail(ASSERTION_FAILED, "jdoPostLoad: Value incorrect, obj1.i != -10; it is " + obj1.i); - } - if (obj1.c != '2') { - fail(ASSERTION_FAILED, "jdoPostLoad: Value incorrect, obj1.c != '2'; it is " + obj1.c); - } - if (obj1.d != 30.0) { - fail(ASSERTION_FAILED, "jdoPostLoad: Value incorrect, obj1.d != 30.0; it is " + obj1.d); - } - if (obj1.s != 40) { - fail(ASSERTION_FAILED, "jdoPostLoad: Value incorrect, obj1.s != 40; it is " + obj1.s); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(InstanceCallbackNonPersistFdsClass.class); } - if (obj1.loadTime != InstanceCallbackNonPersistFdsClass.savedLoadTime) { - fail( - ASSERTION_FAILED, - "jdoPostLoad: Value incorrect, obj1.loadTime != " - + InstanceCallbackNonPersistFdsClass.savedLoadTime - + "; it is " - + obj1.loadTime); - } - boolean childrenValueIncorrect = false; - if (obj1.children.size() != 3) { - childrenValueIncorrect = true; - } else { - if (!obj1.children.contains(InstanceCallbackNonPersistFdsClass.member1)) { - childrenValueIncorrect = true; - } - if (!obj1.children.contains(InstanceCallbackNonPersistFdsClass.member2)) { - childrenValueIncorrect = true; - } - if (!obj1.children.contains(InstanceCallbackNonPersistFdsClass.member3)) { - childrenValueIncorrect = true; - } - } - if (childrenValueIncorrect) { - if (debug) { - logger.debug( - "jdoPostLoad: Value incorrect, obj1.children does not contain the correct String members"); - logger.debug( - "The members should be: " - + InstanceCallbackNonPersistFdsClass.member1 - + ", " - + InstanceCallbackNonPersistFdsClass.member2 - + ", " - + InstanceCallbackNonPersistFdsClass.member3); - logger.debug("obj1.children contains " + obj1.children.size() + " members"); - if (obj1.children.size() != 0) { - logger.debug("Those members are:"); - for (Iterator i = obj1.children.iterator(); i.hasNext(); ) { - logger.debug((String) i.next()); - } + + /** */ + public void test() { + pm = getPM(); + Transaction t = pm.currentTransaction(); + t.setRetainValues(false); + + InstanceCallbackNonPersistFdsClass.initializeStaticsForTest(); + + t.begin(); + // create instance + InstanceCallbackNonPersistFdsClass obj1 = new InstanceCallbackNonPersistFdsClass(1.1f, 1); + pm.makePersistent(obj1); + Object objPtr1 = pm.getObjectId (obj1); + obj1.setNonPersist(1, (char)1, 0, (short)0); + t.commit(); // jdoPreStore() and jdoPreClear() called + + t.begin(); + try { + obj1 = (InstanceCallbackNonPersistFdsClass)pm.getObjectById(objPtr1, true); // jdoPostLoad() called + } catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, "ModificationOfNontransactionalNonpersistentFields: Could not locate persistent object obj1 created in previous transaction, got " + e); + return; + } catch (JDODataStoreException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, "ModificationOfNontransactionalNonpersistentFields: Could not locate persistent object obj1 created in previous transaction, got " + e); + return; } - } - fail( - ASSERTION_FAILED, - "jdoPostLoad: Value incorrect, obj1.children does not contain the correct String members"); - } - - pm.deletePersistent(obj1); // jdoPreDelete() called - t.commit(); - // check result of jdoPreStore(), jdoPreClear() and jdoPreDelete() - if (!InstanceCallbackNonPersistFdsClass.preClearCalled) { - fail(ASSERTION_FAILED, "jdoPreClear() never called on obj1"); - } - - if (!InstanceCallbackNonPersistFdsClass.preStoreCalled) { - fail(ASSERTION_FAILED, "jdoPreStore() never called on obj1"); - } - - if (!InstanceCallbackNonPersistFdsClass.preDeleteCalled) { - fail(ASSERTION_FAILED, "jdoPreDelete() never called on obj1"); - } - - if (InstanceCallbackNonPersistFdsClass.exceptions.size() != 0) { - for (int index = 0; index < InstanceCallbackNonPersistFdsClass.exceptions.size(); index++) { - fail( - ASSERTION_FAILED, - "" - + InstanceCallbackNonPersistFdsClass.callbackCalled.get(index) - + "operation " - + InstanceCallbackNonPersistFdsClass.attributeOpCausingExceptions.get(index) - + " resulted in exception " - + InstanceCallbackNonPersistFdsClass.exceptions.get(index)); - } + + // check fields set in jdoPostLoad() + if(obj1.i != -10) { + fail(ASSERTION_FAILED, "jdoPostLoad: Value incorrect, obj1.i != -10; it is " + obj1.i); + } + if(obj1.c != '2') { + fail(ASSERTION_FAILED, "jdoPostLoad: Value incorrect, obj1.c != '2'; it is " + obj1.c); + } + if(obj1.d != 30.0) { + fail(ASSERTION_FAILED, "jdoPostLoad: Value incorrect, obj1.d != 30.0; it is " + obj1.d); + } + if(obj1.s != 40) { + fail(ASSERTION_FAILED, "jdoPostLoad: Value incorrect, obj1.s != 40; it is " + obj1.s); + } + if(obj1.loadTime != InstanceCallbackNonPersistFdsClass.savedLoadTime) { + fail(ASSERTION_FAILED, + "jdoPostLoad: Value incorrect, obj1.loadTime != " + + InstanceCallbackNonPersistFdsClass.savedLoadTime + + "; it is " + obj1.loadTime); + } + boolean childrenValueIncorrect = false; + if(obj1.children.size() != 3) { + childrenValueIncorrect = true; + }else { + if(!obj1.children.contains(InstanceCallbackNonPersistFdsClass.member1)) { + childrenValueIncorrect = true; + } + if(!obj1.children.contains(InstanceCallbackNonPersistFdsClass.member2)) { + childrenValueIncorrect = true; + } + if(!obj1.children.contains(InstanceCallbackNonPersistFdsClass.member3)) { + childrenValueIncorrect = true; + } + } + if(childrenValueIncorrect) { + if (debug) { + logger.debug("jdoPostLoad: Value incorrect, obj1.children does not contain the correct String members"); + logger.debug("The members should be: " + InstanceCallbackNonPersistFdsClass.member1 + ", " + + InstanceCallbackNonPersistFdsClass.member2 + ", " + InstanceCallbackNonPersistFdsClass.member3); + logger.debug("obj1.children contains " + obj1.children.size() + " members"); + if(obj1.children.size() != 0) { + logger.debug("Those members are:"); + for(Iterator i = obj1.children.iterator(); i.hasNext();) { + logger.debug((String)i.next()); + } + } + } + fail(ASSERTION_FAILED, "jdoPostLoad: Value incorrect, obj1.children does not contain the correct String members"); + } + + pm.deletePersistent(obj1); // jdoPreDelete() called + t.commit(); + // check result of jdoPreStore(), jdoPreClear() and jdoPreDelete() + if (!InstanceCallbackNonPersistFdsClass.preClearCalled) { + fail(ASSERTION_FAILED, "jdoPreClear() never called on obj1"); + } + + if(!InstanceCallbackNonPersistFdsClass.preStoreCalled) { + fail(ASSERTION_FAILED, "jdoPreStore() never called on obj1"); + } + + if(!InstanceCallbackNonPersistFdsClass.preDeleteCalled) { + fail(ASSERTION_FAILED, "jdoPreDelete() never called on obj1"); + } + + if(InstanceCallbackNonPersistFdsClass.exceptions.size() != 0) { + for(int index = 0; index < InstanceCallbackNonPersistFdsClass.exceptions.size(); index++) { + fail(ASSERTION_FAILED, + "" + InstanceCallbackNonPersistFdsClass.callbackCalled.get(index) + + "operation " + + InstanceCallbackNonPersistFdsClass.attributeOpCausingExceptions.get(index) + + " resulted in exception " + + InstanceCallbackNonPersistFdsClass.exceptions.get(index)); + } + } + pm.close(); + pm = null; } - pm.close(); - pm = null; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/NoAccessToFieldsAfterPredelete.java b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/NoAccessToFieldsAfterPredelete.java index 933d642a4..9d095d807 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/NoAccessToFieldsAfterPredelete.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/NoAccessToFieldsAfterPredelete.java @@ -5,33 +5,40 @@ * 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 + * + * 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.jdo.tck.api.instancecallbacks; import java.util.Date; import java.util.HashSet; + import javax.jdo.JDODataStoreException; import javax.jdo.JDOUserException; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: No Access To Fields After Predelete
    - * Keywords: instancecallbacks
    - * Assertion ID: A10.4-3.
    - * Assertion Description: Access to field values after a call to jdoPreDelete() - * of a class implementing InstanceCallbacks are disallowed. + *Title: No Access To Fields After Predelete + *
    + *Keywords: instancecallbacks + *
    + *Assertion ID: A10.4-3. + *
    + *Assertion Description: +Access to field values after a call to jdoPreDelete() +of a class implementing InstanceCallbacks are disallowed. + */ /* @@ -43,139 +50,122 @@ public class NoAccessToFieldsAfterPredelete extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A10.4-3 (NoAccessToFieldsAfterPredelete) failed"; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NoAccessToFieldsAfterPredelete.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(InstanceCallbackClass.class); - } - - /** */ - public void test() { - pm = getPM(); - Transaction t = pm.currentTransaction(); - - InstanceCallbackClass.initializeStaticsForTest(); - - t.begin(); - // make intValue outside the range of zero to arraySize-1 to skip most jdoPreDelete() code. - InstanceCallbackClass a = - new InstanceCallbackClass( - "object a", null, InstanceCallbackClass.arraySize, 6.0, (short) -1, '6', null); - pm.makePersistent(a); - Object aId = pm.getObjectId(a); - t.commit(); - - t.begin(); - // relocte object. - try { - a = (InstanceCallbackClass) pm.getObjectById(aId, true); - } catch (JDOUserException e) { - fail( - ASSERTION_FAILED, - "NoAccessToFieldsAfterPredelete: Could not locate persistent object created in previous transaction, got " - + e); - return; - } catch (JDODataStoreException e) { - fail( - ASSERTION_FAILED, - "NoAccessToFieldsAfterPredelete: Could not locate persistent object created in previous transaction, got " - + e); - return; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A10.4-3 (NoAccessToFieldsAfterPredelete) failed"; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NoAccessToFieldsAfterPredelete.class); } - pm.deletePersistent(a); - performAccessFieldTests("Object in state persistent-deleted: ", a); - - InstanceCallbackClass b = - new InstanceCallbackClass( - "object b", null, InstanceCallbackClass.arraySize + 1, 7.0, (short) -1, '7', null); - pm.makePersistent(b); - pm.deletePersistent(b); - performAccessFieldTests("Object in state persistent-new-deleted: ", b); - - t.rollback(); - pm.close(); - pm = null; - } - - /** */ - void performAccessFieldTests(String title, InstanceCallbackClass o) { - try { - short x1 = o.childToDelete; - // http://issues.apache.org/jira/browse/JDO-413 - // fail(ASSERTION_FAILED, title + "Accessed persistent short field childToDelete--should have - // gotten JDOUserException"); - } catch (JDOUserException e) { - // expected - } - - try { - double x2 = o.doubleValue; - // http://issues.apache.org/jira/browse/JDO-413 - // fail(ASSERTION_FAILED, title + "Accessed persistent double field doubleValue--should have - // gotten JDOUserException"); - } catch (JDOUserException e) { - // expected - } - - try { - char x3 = o.charValue; - // http://issues.apache.org/jira/browse/JDO-413 - // fail(ASSERTION_FAILED, title + "Accessed persistent char field charValue--should have - // gotten JDOUserException"); - } catch (JDOUserException e) { - // expected + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(InstanceCallbackClass.class); } - - try { - String x4 = o.name; - // http://issues.apache.org/jira/browse/JDO-413 - // fail(ASSERTION_FAILED,title + "Accessed persistent String field name--should have gotten - // JDOUserException"); - } catch (JDOUserException e) { - // expected - } - - try { - Date x5 = o.timeStamp; - // http://issues.apache.org/jira/browse/JDO-413 - // fail(ASSERTION_FAILED, title + "Accessed persistent Date field timeStamp--should have - // gotten JDOUserException"); - } catch (JDOUserException e) { - // expected + + /** */ + public void test() { + pm = getPM(); + Transaction t = pm.currentTransaction(); + + InstanceCallbackClass.initializeStaticsForTest(); + + t.begin(); + // make intValue outside the range of zero to arraySize-1 to skip most jdoPreDelete() code. + InstanceCallbackClass a = new InstanceCallbackClass("object a", null, InstanceCallbackClass.arraySize, 6.0, (short)-1, '6', null); + pm.makePersistent(a); + Object aId = pm.getObjectId(a); + t.commit(); + + t.begin(); + // relocte object. + try { + a = (InstanceCallbackClass)pm.getObjectById(aId, true); + } catch (JDOUserException e) { + fail(ASSERTION_FAILED, "NoAccessToFieldsAfterPredelete: Could not locate persistent object created in previous transaction, got " + e); + return; + } catch (JDODataStoreException e) { + fail(ASSERTION_FAILED, "NoAccessToFieldsAfterPredelete: Could not locate persistent object created in previous transaction, got " + e); + return; + } + + pm.deletePersistent(a); + performAccessFieldTests("Object in state persistent-deleted: ", a); + + InstanceCallbackClass b = new InstanceCallbackClass("object b", null, InstanceCallbackClass.arraySize + 1, 7.0, (short)-1, '7', null); + pm.makePersistent(b); + pm.deletePersistent(b); + performAccessFieldTests("Object in state persistent-new-deleted: ", b); + + t.rollback(); + pm.close(); + pm = null; } - - try { - HashSet x6 = o.children; - // http://issues.apache.org/jira/browse/JDO-413 - // fail(ASSERTION_FAILED, title + "Accessed persistent HashSet field Children--should have - // gotten JDOUserException"); - } catch (JDOUserException e) { - // expected - } - - try { - InstanceCallbackClass x7 = o.nextObj; - // http://issues.apache.org/jira/browse/JDO-413 - // fail(ASSERTION_FAILED, title + "Accessed persistent InstanceCallbackClass reference field - // nextObj--should have gotten JDOUserException"); - } catch (JDOUserException e) { - // expected + + /** */ + void performAccessFieldTests(String title, InstanceCallbackClass o) { + try { + short x1 = o.childToDelete; + // http://issues.apache.org/jira/browse/JDO-413 + // fail(ASSERTION_FAILED, title + "Accessed persistent short field childToDelete--should have gotten JDOUserException"); + } catch (JDOUserException e) { + // expected + } + + try { + double x2 = o.doubleValue; + // http://issues.apache.org/jira/browse/JDO-413 + // fail(ASSERTION_FAILED, title + "Accessed persistent double field doubleValue--should have gotten JDOUserException"); + } catch (JDOUserException e) { + // expected + } + + try { + char x3 = o.charValue; + // http://issues.apache.org/jira/browse/JDO-413 + // fail(ASSERTION_FAILED, title + "Accessed persistent char field charValue--should have gotten JDOUserException"); + } catch (JDOUserException e) { + // expected + } + + try { + String x4 = o.name; + // http://issues.apache.org/jira/browse/JDO-413 + // fail(ASSERTION_FAILED,title + "Accessed persistent String field name--should have gotten JDOUserException"); + } catch (JDOUserException e) { + // expected + } + + try { + Date x5 = o.timeStamp; + // http://issues.apache.org/jira/browse/JDO-413 + // fail(ASSERTION_FAILED, title + "Accessed persistent Date field timeStamp--should have gotten JDOUserException"); + } catch (JDOUserException e) { + // expected + } + + try { + HashSet x6 = o.children; + // http://issues.apache.org/jira/browse/JDO-413 + // fail(ASSERTION_FAILED, title + "Accessed persistent HashSet field Children--should have gotten JDOUserException"); + } catch (JDOUserException e) { + // expected + } + + try { + InstanceCallbackClass x7 = o.nextObj; + // http://issues.apache.org/jira/browse/JDO-413 + // fail(ASSERTION_FAILED, title + "Accessed persistent InstanceCallbackClass reference field nextObj--should have gotten JDOUserException"); + } catch (JDOUserException e) { + // expected + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/TestParts.java b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/TestParts.java index 275a7b303..002621b85 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/TestParts.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/instancecallbacks/TestParts.java @@ -5,197 +5,136 @@ * 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 + * + * 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.jdo.tck.api.instancecallbacks; import java.util.Date; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackClass; public abstract class TestParts extends JDO_Test { - /** */ - public TestParts() {} - - /** */ - void checkInstances( - String assertion, - String label, - int intValue, - String capturedNextObjName, - int numberOfChildren, - int sumOfChildrenIntValue) { - if (InstanceCallbackClass.processedIndex[intValue] != true) { - fail(assertion, label + "Callback never made on object with intValue = " + intValue); - } - if (capturedNextObjName != null - && InstanceCallbackClass.capturedNextObjName[intValue] == null) { - fail( - assertion, - label - + "nextObj attribute for object with intValue = " - + intValue - + " should not have been null."); - } else if (capturedNextObjName == null - && InstanceCallbackClass.capturedNextObjName[intValue] != null) { - fail( - assertion, - label - + "nextObj attribute for object with intValue = " - + intValue - + " should have been null."); - } else if (capturedNextObjName != null - && !InstanceCallbackClass.capturedNextObjName[intValue].equals(capturedNextObjName)) { - fail( - assertion, - label - + "nextObj.name attribute for object with intValue = " - + intValue - + " should have been \"" - + capturedNextObjName - + "\". It was \"" - + InstanceCallbackClass.capturedNextObjName[intValue] - + "\" instead."); - } - - if (InstanceCallbackClass.numberOfChildren[intValue] != numberOfChildren) { - fail( - assertion, - label - + "Number of instances in attribute children for object with intValue = " - + intValue - + " should have been " - + numberOfChildren - + ". It was " - + InstanceCallbackClass.numberOfChildren[intValue] - + " instead."); - } - - if (InstanceCallbackClass.sumOfChildrenIntValue[intValue] != sumOfChildrenIntValue) { - fail( - assertion, - label - + "Sum of intValue of instances in attribute children for object with intValue = " - + intValue - + " should have been " - + sumOfChildrenIntValue - + ". It was " - + InstanceCallbackClass.sumOfChildrenIntValue[intValue] - + " instead."); + /** */ + public TestParts() { } - } - /** */ - void checkPMAccess(String assertion, String label, int intValue, boolean transactionActive) { - if (InstanceCallbackClass.processedIndex[intValue] != true) { - fail(assertion, label + "Callback never made on object with intValue = " + intValue); - return; + /** */ + void checkInstances(String assertion, String label, int intValue, String capturedNextObjName, + int numberOfChildren, int sumOfChildrenIntValue) { + if (InstanceCallbackClass.processedIndex[intValue] != true) { + fail(assertion, label + "Callback never made on object with intValue = " + intValue); + } + if (capturedNextObjName != null && + InstanceCallbackClass.capturedNextObjName[intValue] == null) { + fail(assertion, label + "nextObj attribute for object with intValue = " + + intValue + " should not have been null."); + } else if (capturedNextObjName == null && + InstanceCallbackClass.capturedNextObjName[intValue] != null) { + fail(assertion, label + "nextObj attribute for object with intValue = " + + intValue + " should have been null."); + } else if(capturedNextObjName != null && + !InstanceCallbackClass.capturedNextObjName[intValue].equals(capturedNextObjName)) { + fail(assertion, + label + "nextObj.name attribute for object with intValue = " + intValue + + " should have been \"" + capturedNextObjName + "\". It was \"" + + InstanceCallbackClass.capturedNextObjName[intValue] + "\" instead."); + } + + if(InstanceCallbackClass.numberOfChildren[intValue] != numberOfChildren) { + fail(assertion, + label + "Number of instances in attribute children for object with intValue = " + + intValue + " should have been " + numberOfChildren + ". It was " + + InstanceCallbackClass.numberOfChildren[intValue] + " instead."); + } + + if(InstanceCallbackClass.sumOfChildrenIntValue[intValue] != sumOfChildrenIntValue) { + fail(assertion, + label + "Sum of intValue of instances in attribute children for object with intValue = " + + intValue + " should have been " + sumOfChildrenIntValue + ". It was " + + InstanceCallbackClass.sumOfChildrenIntValue[intValue] + " instead."); + } } - // Only verify isActive() returned true for the object if transactionActive is true - if (transactionActive && InstanceCallbackClass.transactionActive[intValue] != true) { - fail(assertion, label + "PersistenceManager.currentTransaction.isAcive() returned false"); + + /** */ + void checkPMAccess(String assertion, String label, int intValue, boolean transactionActive) { + if (InstanceCallbackClass.processedIndex[intValue] != true) { + fail(assertion, label + "Callback never made on object with intValue = " + intValue); + return; + } + // Only verify isActive() returned true for the object if transactionActive is true + if (transactionActive && InstanceCallbackClass.transactionActive[intValue] != true) { + fail(assertion, label + "PersistenceManager.currentTransaction.isAcive() returned false"); + } } - } + + /** + * The attributes are: label, name, date, intValue, doubleValue, + * childToDelete, charValue + */ + void checkFieldValues(String assertion, String label, int intValue, + String name, Date timeStamp, double doubleValue, + short childToDelete, char charValue) { + if (InstanceCallbackClass.processedIndex[intValue] != true) { + fail(assertion, label + "Callback never made on object with intValue = " + intValue); + return; + } + + if (!InstanceCallbackClass.capturedName[intValue].equals(name)) { + fail(assertion, + label + "name attribute for object with intValue = " + intValue + + " should be \"" + name + "\". It was \"" + + InstanceCallbackClass.capturedName[intValue] + "\" instead."); + } - /** The attributes are: label, name, date, intValue, doubleValue, childToDelete, charValue */ - void checkFieldValues( - String assertion, - String label, - int intValue, - String name, - Date timeStamp, - double doubleValue, - short childToDelete, - char charValue) { - if (InstanceCallbackClass.processedIndex[intValue] != true) { - fail(assertion, label + "Callback never made on object with intValue = " + intValue); - return; - } + if (!InstanceCallbackClass.capturedTimeStamp[intValue].equals(timeStamp)) { + fail(assertion, + label + "timeStamp attribute for object with intValue = " + intValue + + " should be " + timeStamp + ". It was " + + InstanceCallbackClass.capturedTimeStamp[intValue] + " instead."); + } - if (!InstanceCallbackClass.capturedName[intValue].equals(name)) { - fail( - assertion, - label - + "name attribute for object with intValue = " - + intValue - + " should be \"" - + name - + "\". It was \"" - + InstanceCallbackClass.capturedName[intValue] - + "\" instead."); - } + if (InstanceCallbackClass.capturedDoubleValue[intValue] != doubleValue) { + fail (assertion, + label + "doubleValue attribute for object with intValue = " + + intValue + " should be " + doubleValue + ". It was " + + InstanceCallbackClass.capturedDoubleValue[intValue] + " instead."); + } - if (!InstanceCallbackClass.capturedTimeStamp[intValue].equals(timeStamp)) { - fail( - assertion, - label - + "timeStamp attribute for object with intValue = " - + intValue - + " should be " - + timeStamp - + ". It was " - + InstanceCallbackClass.capturedTimeStamp[intValue] - + " instead."); - } + if (InstanceCallbackClass.capturedCharValue[intValue] != charValue) { + fail(assertion, + label + "charValue attribute for object with intValue = " + + intValue + " should be " + charValue + ". It was " + + InstanceCallbackClass.capturedCharValue[intValue] + " instead."); + } - if (InstanceCallbackClass.capturedDoubleValue[intValue] != doubleValue) { - fail( - assertion, - label - + "doubleValue attribute for object with intValue = " - + intValue - + " should be " - + doubleValue - + ". It was " - + InstanceCallbackClass.capturedDoubleValue[intValue] - + " instead."); + if (InstanceCallbackClass.capturedChildToDelete[intValue] != childToDelete) { + fail(assertion, + label + "childToDelete attribute for object with intValue = " + + intValue + " should be " + childToDelete + ". It was " + + InstanceCallbackClass.capturedChildToDelete[intValue] + " instead."); + } } - - if (InstanceCallbackClass.capturedCharValue[intValue] != charValue) { - fail( - assertion, - label - + "charValue attribute for object with intValue = " - + intValue - + " should be " - + charValue - + ". It was " - + InstanceCallbackClass.capturedCharValue[intValue] - + " instead."); + + /** Touch fields to guarantee that they are loaded into the instance + */ + double touchFields (InstanceCallbackClass o) { + // make a checksum from the fields and return it; this cannot be optimized out... + double rc = o.doubleValue; + rc += o.intValue; + rc += o.charValue; + rc += o.childToDelete; + rc += o.name.length(); + rc += o.timeStamp.getTime(); + return rc; } - - if (InstanceCallbackClass.capturedChildToDelete[intValue] != childToDelete) { - fail( - assertion, - label - + "childToDelete attribute for object with intValue = " - + intValue - + " should be " - + childToDelete - + ". It was " - + InstanceCallbackClass.capturedChildToDelete[intValue] - + " instead."); - } - } - - /** Touch fields to guarantee that they are loaded into the instance */ - double touchFields(InstanceCallbackClass o) { - // make a checksum from the fields and return it; this cannot be optimized out... - double rc = o.doubleValue; - rc += o.intValue; - rc += o.charValue; - rc += o.childToDelete; - rc += o.name.length(); - rc += o.timeStamp.getTime(); - return rc; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetObjectId.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetObjectId.java index 672969b60..8ab4eadb9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetObjectId.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetObjectId.java @@ -5,82 +5,86 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get Objectid
    - * Keywords: jdohelper
    - * Assertion ID: A8.3-1
    - * Assertion Description: The jdohelper.getObjectId method returns an ObjectId instance that - * represents the object identity of the specified JDO Instance. Test: The method getObjectById - * returns the exact same object, evaluating to true when == is used . + *Title: Get Objectid + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.3-1 + *
    + *Assertion Description: + * The jdohelper.getObjectId method returns an ObjectId instance that represents + * the object identity of the specified JDO Instance. Test: The method + * getObjectById returns the exact same object, evaluating to true when == is used . */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/26/01 1.0 */ public class GetObjectId extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.3-1 (GetObjectId) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectId.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.3-1 (GetObjectId) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectId.class); + } - /* test JDOHelper.getObjectId(Object pc) - * - */ - public void testGetObjectId() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - Object oid = JDOHelper.getObjectId(p1); - if (oid == null) - fail( - ASSERTION_FAILED, - "JDOHelper.getObjectId called for a P_NEW instance returned null ObjectId"); - Object p2 = pm.getObjectById(oid, false); - if (p2 != p1) - fail( - ASSERTION_FAILED, - "JDOHelper.getObjectBy returned different instance " + p2 + " expected " + p1); - tx.commit(); - pm.close(); - pm = null; - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /* test JDOHelper.getObjectId(Object pc) + * + */ + public void testGetObjectId() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + Object oid = JDOHelper.getObjectId(p1); + if (oid == null) + fail(ASSERTION_FAILED, + "JDOHelper.getObjectId called for a P_NEW instance returned null ObjectId"); + Object p2 = pm.getObjectById(oid, false); + if (p2 != p1) + fail(ASSERTION_FAILED, + "JDOHelper.getObjectBy returned different instance " + p2 + " expected " + p1); + tx.commit(); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetObjectIdForNull.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetObjectIdForNull.java index d1e04b5a0..09fe80e45 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetObjectIdForNull.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetObjectIdForNull.java @@ -5,65 +5,73 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Get Object Id For Null
    - * Keywords: jdohelper
    - * Assertion ID: A8.3-4.
    - * Assertion Description: The jdohelper.getObjectId method returns null if Object is null. - * Evaluating to true when == is used. + *Title: Get Object Id For Null + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.3-4. + *
    + *Assertion Description: +The jdohelper.getObjectId method returns null if Object is null. + Evaluating to true when == is used. + */ -/* + + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/26/01 1.0 */ - + public class GetObjectIdForNull extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.3-4 (GetObjectIdForNull) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectIdForNull.class); - } - - /* test jdohelper.getObjectId(Object pc) - */ - public void testGetObjectIdForNull() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - Object p1 = null; - Object oid = JDOHelper.getObjectId(p1); - tx.commit(); - if (oid != null) - fail( - ASSERTION_FAILED, - "JDOHelper.getObjectId called for null instance returned non-null ObjectId"); - pm.close(); - pm = null; - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.3-4 (GetObjectIdForNull) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectIdForNull.class); + } + + /* test jdohelper.getObjectId(Object pc) + */ + public void testGetObjectIdForNull() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Object p1 = null; + Object oid = JDOHelper.getObjectId(p1); + tx.commit(); + if (oid != null) + fail(ASSERTION_FAILED, + "JDOHelper.getObjectId called for null instance returned non-null ObjectId"); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetObjectIdForTransient.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetObjectIdForTransient.java index bd6116b90..119f16269 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetObjectIdForTransient.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetObjectIdForTransient.java @@ -5,68 +5,72 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get Object Id For Transient
    - * Keywords: jdohelper
    - * Assertion ID: A8.3-2.
    - * Assertion Description: The jdohelper.getObjectId method returns null if Object is a - * transient. Evaluating to true when == is used. + *Title: Get Object Id For Transient + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.3-2. + *
    + *Assertion Description: +The jdohelper.getObjectId method returns null if Object is a transient. +Evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/27/01 1.0 */ - + public class GetObjectIdForTransient extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.3-2 (GetObjectIdForTransient) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectIdForTransient.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.3-2 (GetObjectIdForTransient) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectIdForTransient.class); + } - /* test JDOHelper.getObjectId(Object pc) - * - */ - public void testGetObjectIdForTransient() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - Object oid = JDOHelper.getObjectId(p1); - tx.commit(); - if (oid != null) - fail( - ASSERTION_FAILED, - "JDOHelper.getObjectId called for transient instance returned non-null ObjectId " + oid); - pm.close(); - pm = null; - } + /* test JDOHelper.getObjectId(Object pc) + * + */ + public void testGetObjectIdForTransient() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + Object oid = JDOHelper.getObjectId(p1); + tx.commit(); + if (oid != null) + fail(ASSERTION_FAILED, + "JDOHelper.getObjectId called for transient instance returned non-null ObjectId " + oid); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetObjectIdNotPersistenceCapable.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetObjectIdNotPersistenceCapable.java index 44d6dac69..8018c8917 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetObjectIdNotPersistenceCapable.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetObjectIdNotPersistenceCapable.java @@ -5,70 +5,73 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.Point; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get Object Id Not Persistence Capable
    - * Keywords: jdohelper
    - * Assertion ID: A8.3-3.
    - * Assertion Description: The jdohelper.getObjectId method returns null if Object is not - * persistence capable + *Title: Get Object Id Not Persistence Capable + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.3-3. + *
    + *Assertion Description: +The jdohelper.getObjectId method returns null if Object is not persistence capable + */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/26/01 1.0 */ public class GetObjectIdNotPersistenceCapable extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.3-3 (GetObjectIdNotPersistenceCapable) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectIdNotPersistenceCapable.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.3-3 (GetObjectIdNotPersistenceCapable) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectIdNotPersistenceCapable.class); + } - /* test JDOHelper.getObjectId(Object pc) - * - */ - public void testGetObjectIdNotPersistenceCapable() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - Point p1 = new Point(1, 3); - Object oid = JDOHelper.getObjectId(p1); - tx.commit(); - if (oid != null) - fail( - ASSERTION_FAILED, - "JDOHelper.getObjectId called for instance of non-pc class returned non-null ObjectId " - + oid); - pm.close(); - pm = null; - } + /* test JDOHelper.getObjectId(Object pc) + * + */ + public void testGetObjectIdNotPersistenceCapable() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Point p1 = new Point(1,3); + Object oid = JDOHelper.getObjectId(p1); + tx.commit(); + if (oid != null) + fail(ASSERTION_FAILED, + "JDOHelper.getObjectId called for instance of non-pc class returned non-null ObjectId " + oid); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetObjectIds.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetObjectIds.java index 5984642b7..f971fd688 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetObjectIds.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetObjectIds.java @@ -5,252 +5,257 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; +import java.util.List; import java.util.Arrays; import java.util.Collection; import java.util.Date; import java.util.Iterator; -import java.util.List; + import javax.jdo.JDOHelper; import javax.jdo.PersistenceManager; import javax.jdo.identity.SingleFieldIdentity; + import org.apache.jdo.tck.JDO_Test; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.pc.singlefieldidentity.PCPointSingleFieldInteger; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test GetObjectIds
    - * Keywords: getObjectIds getObjectId
    - * Assertion IDs: A8.3-11
    - * Assertion Description: These methods return the JDO identities of the parameter - * instances. For each instance in the parameter, the getObjectId method is called. They return one - * identity instance for each persistence-capable instance in the parameter. The order of iteration - * of the returned Collection exactly matches the order of iteration of the parameter Collection.] + *Title: Test GetObjectIds + *
    + *Keywords: getObjectIds getObjectId + *
    + *Assertion IDs: A8.3-11 + *
    + *Assertion Description: + * These methods return the JDO identities of the parameter instances. + * For each instance in the parameter, the getObjectId method is called. + * They return one identity instance for each persistence-capable instance + * in the parameter. The order of iteration of the returned Collection + * exactly matches the order of iteration of the parameter Collection.] */ -public class GetObjectIds extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.3-11 (GetObjectIds) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectIds.class); - } - - /** The parameter objects */ - Object obj0; - - Object obj1; - Object obj2; - Object obj3; - Object obj4; - Object[] objs; - - /** The object ids */ - Object oid0; +public class GetObjectIds extends JDO_Test { - Object oid1; - Object oid2; - Object oid3; - Object oid4; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.3-11 (GetObjectIds) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectIds.class); + } - Object[] oids; + /** The parameter objects + */ + Object obj0; + Object obj1; + Object obj2; + Object obj3; + Object obj4; - /** Typed objects */ - PCPointSingleFieldInteger singleFieldIdentityObj0; + Object[] objs; - PCPointSingleFieldInteger singleFieldIdentityObj1; + /** The object ids + */ + Object oid0; + Object oid1; + Object oid2; + Object oid3; + Object oid4; - PCPointSingleFieldInteger[] singleFieldIdentityObjs; + Object[] oids; - /** Typed object ids */ - SingleFieldIdentity singleFieldIdentityOid0; + /** Typed objects + */ + PCPointSingleFieldInteger singleFieldIdentityObj0; + PCPointSingleFieldInteger singleFieldIdentityObj1; - SingleFieldIdentity singleFieldIdentityOid1; + PCPointSingleFieldInteger[] singleFieldIdentityObjs; - SingleFieldIdentity[] singleFieldIdentityOids; + /** Typed object ids + */ + SingleFieldIdentity singleFieldIdentityOid0; + SingleFieldIdentity singleFieldIdentityOid1; - /** The second persistence manager. */ - PersistenceManager pm2; + SingleFieldIdentity[] singleFieldIdentityOids; - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - objs = - new Object[] { - obj0 = null, - obj1 = new Date(), - obj2 = new PCPoint(23, 45), // persistent in pm1 - obj3 = new PCPoint(26, 47), // persistent in pm2 - obj4 = new PCPoint(23, 45) // not persistent + /** The second persistence manager. + */ + PersistenceManager pm2; + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + objs = new Object[] { + obj0 = null, + obj1 = new Date(), + obj2 = new PCPoint(23,45), // persistent in pm1 + obj3 = new PCPoint(26,47), // persistent in pm2 + obj4 = new PCPoint(23,45) // not persistent }; - singleFieldIdentityObjs = - new PCPointSingleFieldInteger[] { - singleFieldIdentityObj0 = new PCPointSingleFieldInteger(0, 1), // persistent in pm1 - singleFieldIdentityObj1 = new PCPointSingleFieldInteger(1, 1) // persistent in pm1 + singleFieldIdentityObjs = new PCPointSingleFieldInteger[] { + singleFieldIdentityObj0 = new PCPointSingleFieldInteger(0, 1), // persistent in pm1 + singleFieldIdentityObj1 = new PCPointSingleFieldInteger(1, 1) // persistent in pm1 }; - getPM(); - pm.currentTransaction().begin(); - pm.makePersistent(obj2); - if (runsWithApplicationIdentity()) { - pm.makePersistent(singleFieldIdentityObj0); - pm.makePersistent(singleFieldIdentityObj1); - } - pm.currentTransaction().commit(); - - pm2 = getPMF().getPersistenceManager(); - pm2.currentTransaction().begin(); - pm2.makePersistent(obj3); - pm2.currentTransaction().commit(); - - oids = - new Object[] { - oid0 = JDOHelper.getObjectId(obj0), - oid1 = JDOHelper.getObjectId(obj1), - oid2 = JDOHelper.getObjectId(obj2), - oid3 = JDOHelper.getObjectId(obj3), - oid4 = JDOHelper.getObjectId(obj4), + getPM(); + pm.currentTransaction().begin(); + pm.makePersistent(obj2); + if (runsWithApplicationIdentity()) { + pm.makePersistent(singleFieldIdentityObj0); + pm.makePersistent(singleFieldIdentityObj1); + } + pm.currentTransaction().commit(); + + pm2 = getPMF().getPersistenceManager(); + pm2.currentTransaction().begin(); + pm2.makePersistent(obj3); + pm2.currentTransaction().commit(); + + oids = new Object[] { + oid0 = JDOHelper.getObjectId(obj0), + oid1 = JDOHelper.getObjectId(obj1), + oid2 = JDOHelper.getObjectId(obj2), + oid3 = JDOHelper.getObjectId(obj3), + oid4 = JDOHelper.getObjectId(obj4), }; - singleFieldIdentityOids = - new SingleFieldIdentity[] { - singleFieldIdentityOid0 = - (SingleFieldIdentity) JDOHelper.getObjectId(singleFieldIdentityObj0), - singleFieldIdentityOid1 = - (SingleFieldIdentity) JDOHelper.getObjectId(singleFieldIdentityObj1) + singleFieldIdentityOids = new SingleFieldIdentity[] { + singleFieldIdentityOid0 = (SingleFieldIdentity)JDOHelper.getObjectId(singleFieldIdentityObj0), + singleFieldIdentityOid1 = (SingleFieldIdentity)JDOHelper.getObjectId(singleFieldIdentityObj1) }; - } - /** - * @see org.apache.jdo.tck.JDO_Test#localTearDown() - */ - @Override - protected void localTearDown() { - pm2.close(); - } - - /** */ - public void testGetObjectIdsArray() { - StringBuffer messages = new StringBuffer(); - Object[] expectedArray = oids; - Object[] actualArray = JDOHelper.getObjectIds(objs); - for (int i = 0; i < objs.length; ++i) { - Object expected = expectedArray[i]; - Object actual = actualArray[i]; - if (expected == null ? actual != null : !expected.equals(actual)) { - messages.append( - "\nComparison failed for object ids at position " - + i - + "\nexpected: " - + expected - + "\nactual: " - + actual); - } - } - if (messages.length() != 0) { - fail(ASSERTION_FAILED + "getObjectIds(Object[] pcs) " + messages.toString()); } - } - /** */ - public void testGetObjectIdsCollection() { - StringBuffer messages = new StringBuffer(); - List paramList = Arrays.asList(objs); - List expectedList = Arrays.asList(oids); - Collection actualCollection = JDOHelper.getObjectIds(paramList); - Iterator expectedIterator = expectedList.iterator(); - Iterator actualIterator = actualCollection.iterator(); - for (int i = 0; i < objs.length; ++i) { - Object expected = expectedIterator.next(); - Object actual = actualIterator.next(); - if (expected == null ? actual != null : !expected.equals(actual)) { - messages.append( - "\nComparison failed for object ids at position " - + i - + "\nexpected: " - + expected - + "\nactual: " - + actual); - } - } - if (messages.length() != 0) { - fail(ASSERTION_FAILED + "getObjectIds(Collection pcs) " + messages.toString()); + /** + * @see org.apache.jdo.tck.JDO_Test#localTearDown() + */ + @Override + protected void localTearDown() { + pm2.close(); } - } - /** */ - public void testTypedGetObjectIdsArray() { - if (!runsWithApplicationIdentity()) return; - StringBuffer messages = new StringBuffer(); - Object[] expectedArray = singleFieldIdentityOids; - Object[] actualArray = JDOHelper.getObjectIds(singleFieldIdentityObjs); - for (int i = 0; i < singleFieldIdentityObjs.length; ++i) { - Object expected = expectedArray[i]; - Object actual = actualArray[i]; - if (expected == null ? actual != null : !expected.equals(actual)) { - messages.append( - "\nComparison failed for object ids at position " - + i - + "\nexpected: " - + expected - + "\nactual: " - + actual); - } + /** */ + public void testGetObjectIdsArray() { + StringBuffer messages = new StringBuffer(); + Object[] expectedArray = oids; + Object[] actualArray = JDOHelper.getObjectIds(objs); + for (int i = 0; i < objs.length; ++i) { + Object expected = expectedArray[i]; + Object actual = actualArray[i]; + if (expected == null? + actual != null: + !expected.equals(actual)) { + messages.append( + "\nComparison failed for object ids at position " + i + + "\nexpected: " + expected + + "\nactual: " + actual); + } + } + if (messages.length() != 0) { + fail(ASSERTION_FAILED + "getObjectIds(Object[] pcs) " + + messages.toString()); + } } - if (messages.length() != 0) { - fail(ASSERTION_FAILED + "getObjectIds(Object[] pcs) " + messages.toString()); + + /** */ + public void testGetObjectIdsCollection() { + StringBuffer messages = new StringBuffer(); + List paramList = Arrays.asList(objs); + List expectedList = Arrays.asList(oids); + Collection actualCollection = JDOHelper.getObjectIds(paramList); + Iterator expectedIterator = expectedList.iterator(); + Iterator actualIterator = actualCollection.iterator(); + for (int i = 0; i < objs.length; ++i) { + Object expected = expectedIterator.next(); + Object actual = actualIterator.next(); + if (expected == null? + actual != null: + !expected.equals(actual)) { + messages.append( + "\nComparison failed for object ids at position " + i + + "\nexpected: " + expected + + "\nactual: " + actual); + } + } + if (messages.length() != 0) { + fail(ASSERTION_FAILED + "getObjectIds(Collection pcs) " + + messages.toString()); + } } - } - /** */ - public void testTypedGetObjectIdsCollection() { - if (!runsWithApplicationIdentity()) return; - StringBuffer messages = new StringBuffer(); - List paramList = Arrays.asList(singleFieldIdentityObjs); - List expectedList = Arrays.asList(singleFieldIdentityOids); - Collection actualCollection = JDOHelper.getObjectIds(paramList); - Iterator expectedIterator = expectedList.iterator(); - Iterator actualIterator = actualCollection.iterator(); - for (int i = 0; i < singleFieldIdentityObjs.length; ++i) { - Object expected = expectedIterator.next(); - Object actual = actualIterator.next(); - if (expected == null ? actual != null : !expected.equals(actual)) { - messages.append( - "\nComparison failed for object ids at position " - + i - + "\nexpected: " - + expected - + "\nactual: " - + actual); - } + /** */ + public void testTypedGetObjectIdsArray() { + if (!runsWithApplicationIdentity()) return; + StringBuffer messages = new StringBuffer(); + Object[] expectedArray = singleFieldIdentityOids; + Object[] actualArray = JDOHelper.getObjectIds(singleFieldIdentityObjs); + for (int i = 0; i < singleFieldIdentityObjs.length; ++i) { + Object expected = expectedArray[i]; + Object actual = actualArray[i]; + if (expected == null? + actual != null: + !expected.equals(actual)) { + messages.append( + "\nComparison failed for object ids at position " + i + + "\nexpected: " + expected + + "\nactual: " + actual); + } + } + if (messages.length() != 0) { + fail(ASSERTION_FAILED + "getObjectIds(Object[] pcs) " + + messages.toString()); + } } - if (messages.length() != 0) { - fail( - ASSERTION_FAILED - + "getObjectIds(Collection pcs) " - + messages.toString()); + + /** */ + public void testTypedGetObjectIdsCollection() { + if (!runsWithApplicationIdentity()) return; + StringBuffer messages = new StringBuffer(); + List paramList = Arrays.asList(singleFieldIdentityObjs); + List expectedList = Arrays.asList(singleFieldIdentityOids); + Collection actualCollection = JDOHelper.getObjectIds(paramList); + Iterator expectedIterator = expectedList.iterator(); + Iterator actualIterator = actualCollection.iterator(); + for (int i = 0; i < singleFieldIdentityObjs.length; ++i) { + Object expected = expectedIterator.next(); + Object actual = actualIterator.next(); + if (expected == null? + actual != null: + !expected.equals(actual)) { + messages.append( + "\nComparison failed for object ids at position " + i + + "\nexpected: " + expected + + "\nactual: " + actual); + } + } + if (messages.length() != 0) { + fail(ASSERTION_FAILED + "getObjectIds(Collection pcs) " + + messages.toString()); + } } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetPersistenceManager.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetPersistenceManager.java index 762e2674e..6900624af 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetPersistenceManager.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetPersistenceManager.java @@ -5,82 +5,88 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get Persistence Manager
    - * Keywords: jdohelper
    - * Assertion ID: A8.1-1.
    - * Assertion Description: The jdohelper.getPersistenceManager method returns associated - * persistence manager if the object parameter is not null and implements persistenceCapable. - * evaluating to true when == is used. + *Title: Get Persistence Manager + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.1-1. + *
    + *Assertion Description: +The jdohelper.getPersistenceManager method returns associated persistence manager + if the object parameter is not null and implements persistenceCapable. + evaluating to true when == is used. */ -/* + + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/26/01 1.0 */ public class GetPersistenceManager extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.1-1 (GetPersistenceManager) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPersistenceManager.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.1-1 (GetPersistenceManager) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPersistenceManager.class); + } - /* test jdohelper.getPersistenceManager(Object pc) - * - */ - public void testGetPersistenceManager() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - PersistenceManager pm1 = JDOHelper.getPersistenceManager(p1); - tx.commit(); - if (pm1 == null) - fail( - ASSERTION_FAILED, "JDOHelper.getPersistenceManager returns null for persistent instance"); - if (pm1 != pm) - fail( - ASSERTION_FAILED, - "JDOHelper.getPersistenceManager returns wrong pm " + pm1 + ", expected " + pm); - pm.close(); - pm = null; - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /* test jdohelper.getPersistenceManager(Object pc) + * + */ + public void testGetPersistenceManager() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + PersistenceManager pm1= JDOHelper.getPersistenceManager(p1); + tx.commit(); + if (pm1 == null) + fail(ASSERTION_FAILED, + "JDOHelper.getPersistenceManager returns null for persistent instance"); + if (pm1 != pm) + fail(ASSERTION_FAILED, + "JDOHelper.getPersistenceManager returns wrong pm " + pm1 + + ", expected " + pm); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetPersistenceManagerForNull.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetPersistenceManagerForNull.java index eb382be8c..13f504f85 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetPersistenceManagerForNull.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetPersistenceManagerForNull.java @@ -5,68 +5,74 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Get Persistence Manager For Null
    - * Keywords: jdohelper
    - * Assertion ID: A8.1-4.
    - * Assertion Description: The jdohelper.getPersistenceManager method returns null if Object - * is null. Evaluating to true when == is used. + *Title: Get Persistence Manager For Null + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.1-4. + *
    + *Assertion Description: +The jdohelper.getPersistenceManager method returns null if Object is null. +Evaluating to true when == is used. */ -/* + + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/27/01 1.0 - */ + */ public class GetPersistenceManagerForNull extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.1-4 (GetPersistenceManagerForNull) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPersistenceManagerForNull.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.1-4 (GetPersistenceManagerForNull) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPersistenceManagerForNull.class); + } - /** */ - public void testGetPersistenceManagerForNull() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - Object p1 = null; - PersistenceManager pm1 = JDOHelper.getPersistenceManager(p1); - tx.commit(); + /** */ + public void testGetPersistenceManagerForNull() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Object p1 = null; + PersistenceManager pm1 = JDOHelper.getPersistenceManager(p1); + tx.commit(); - if (pm1 != null) - fail( - ASSERTION_FAILED, - "JDOHelper.getPersistenceManager with argument null returned non-null pm " + pm1); - pm.close(); - pm = null; - } + if (pm1 != null) + fail(ASSERTION_FAILED, + "JDOHelper.getPersistenceManager with argument null returned non-null pm " + pm1); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetPersistenceManagerForTransient.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetPersistenceManagerForTransient.java index 8ead928fa..4ccf23a7f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetPersistenceManagerForTransient.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetPersistenceManagerForTransient.java @@ -5,69 +5,72 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get Persistence Manager For Transien
    - * Keywords: jdohelper
    - * Assertion ID: A8.1-2.
    - * Assertion Description: The jdohelper.getPersistenceManager method returns null if object - * is transient evaluating to true when == is used. + *Title: Get Persistence Manager For Transien + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.1-2. + *
    + *Assertion Description: +The jdohelper.getPersistenceManager method returns null if object is transient + evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/28/01 1.0 */ public class GetPersistenceManagerForTransient extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.1-2 (GetPersistenceManagerForTransient) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPersistenceManagerForTransient.class); - } - - /* test jdohelper.getPersistenceManager(Object transient) - */ - public void testGetPersistenceManagerForTransient() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - tx.commit(); - PersistenceManager pm1 = JDOHelper.getPersistenceManager(p1); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.1-2 (GetPersistenceManagerForTransient) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPersistenceManagerForTransient.class); + } - if (pm1 != null) - fail( - ASSERTION_FAILED, - "JDOHelper.getPersistenceManager called for transient instance returned non-null pm " - + pm1); - } + /* test jdohelper.getPersistenceManager(Object transient) + */ + public void testGetPersistenceManagerForTransient() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + tx.commit(); + PersistenceManager pm1 = JDOHelper.getPersistenceManager(p1); + + if (pm1 != null) + fail(ASSERTION_FAILED, + "JDOHelper.getPersistenceManager called for transient instance returned non-null pm " + pm1); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetPersistenceManagerNotPersistenceCapable.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetPersistenceManagerNotPersistenceCapable.java index 3d5f2ca05..939a2da4a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetPersistenceManagerNotPersistenceCapable.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetPersistenceManagerNotPersistenceCapable.java @@ -5,69 +5,72 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.Point; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get Persistence Manager Not Persistence Capable
    - * Keywords: jdohelper
    - * Assertion ID: A8.1-3.
    - * Assertion Description: The jdohelper.getPersistenceManager method returns null if object - * is not persistence capable evaluating to true when == is used. + *Title: Get Persistence Manager Not Persistence Capable + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.1-3. + *
    + *Assertion Description: +The jdohelper.getPersistenceManager method returns null if object is not +persistence capable evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/28/01 1.0 */ public class GetPersistenceManagerNotPersistenceCapable extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.1-3 (GetPersistenceManagerNotPersistenceCapable) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPersistenceManagerNotPersistenceCapable.class); - } - - /* test jdohelper.getPersistenceManager(Object pc) - * - */ - public void testGetPersistenceManagerNotPersistenceCapable() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - Point p1 = new Point(1, 3); - tx.commit(); - PersistenceManager pm1 = JDOHelper.getPersistenceManager(p1); - if (pm1 != null) - fail( - ASSERTION_FAILED, - "JDOHelper.getPersistenceManager called for instance of non-pc class returned non-null pm " - + pm1); - pm.close(); - pm = null; - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.1-3 (GetPersistenceManagerNotPersistenceCapable) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPersistenceManagerNotPersistenceCapable.class); + } + + /* test jdohelper.getPersistenceManager(Object pc) + * + */ + public void testGetPersistenceManagerNotPersistenceCapable() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Point p1 = new Point(1,3); + tx.commit(); + PersistenceManager pm1 = JDOHelper.getPersistenceManager(p1); + if (pm1 != null) + fail(ASSERTION_FAILED, + "JDOHelper.getPersistenceManager called for instance of non-pc class returned non-null pm " + pm1); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetTransactionalObjectId.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetTransactionalObjectId.java index 0a50f9c4e..55dc55fdc 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetTransactionalObjectId.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetTransactionalObjectId.java @@ -5,77 +5,83 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get Transactional Object Id
    - * Keywords: jdohelper
    - * Assertion ID: A8.3-5
    - * Assertion Description: If the object parameter implements PersistenceCapable, - * JDOHelper.getTransactionalObjectId delegates to the parameter instance and returns the JDO - * identity of the instance. + *Title: Get Transactional Object Id + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.3-5 + *
    + *Assertion Description: + If the object parameter implements PersistenceCapable, + JDOHelper.getTransactionalObjectId delegates to the parameter instance and + returns the JDO identity of the instance. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/26/01 1.0 */ public class GetTransactionalObjectId extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.3-5 (GetTransactionalObjectId) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetTransactionalObjectId.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.3-5 (GetTransactionalObjectId) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetTransactionalObjectId.class); + } - /* test JDOHelper.getTransactionalObjectId(Object pc) - * - */ - public void testGetTransactionalObjectId() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - Object oid = JDOHelper.getTransactionalObjectId(p1); - tx.commit(); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /* test JDOHelper.getTransactionalObjectId(Object pc) + * + */ + public void testGetTransactionalObjectId() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + Object oid = JDOHelper.getTransactionalObjectId(p1); + tx.commit(); - if (oid == null) - fail(ASSERTION_FAILED, "JDOHelper.getTransactionalObjectId returned null oid."); - pm.close(); - pm = null; - } + if (oid == null) + fail(ASSERTION_FAILED, + "JDOHelper.getTransactionalObjectId returned null oid."); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetTransactionalObjectIdForNull.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetTransactionalObjectIdForNull.java index 7c785cf65..54f2c104b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetTransactionalObjectIdForNull.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetTransactionalObjectIdForNull.java @@ -5,68 +5,72 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get Transactional Object Id For Null
    - * Keywords: jdohelper
    - * Assertion ID: A8.3-8
    - * Assertion Description: The jdohelper.getTransactionalObjectIdForNull method returns null - * if Object is null.Evaluating to true when == is used. + *Title: Get Transactional Object Id For Null + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.3-8 + *
    + *Assertion Description: + The jdohelper.getTransactionalObjectIdForNull method returns null if Object is null.Evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/1/01 1.0 */ - + public class GetTransactionalObjectIdForNull extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.3-8 (GetTransactionalObjectIdForNull) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetTransactionalObjectIdForNull.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.3-8 (GetTransactionalObjectIdForNull) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetTransactionalObjectIdForNull.class); + } - /* test jdohelper.getTransactionalObjectId(Object pc) - * - */ - public void testGetTransactionalObjectIdForNull() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - Object p1 = null; - Object oid = JDOHelper.getTransactionalObjectId(p1); - tx.commit(); + /* test jdohelper.getTransactionalObjectId(Object pc) + * + */ + public void testGetTransactionalObjectIdForNull() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Object p1 = null; + Object oid = JDOHelper.getTransactionalObjectId(p1); + tx.commit(); - if (oid != null) - fail( - ASSERTION_FAILED, - "JDOHelper.getTransactionalObjectId with argument null returned non-null oid " + oid); - pm.close(); - pm = null; - } + if (oid != null) + fail(ASSERTION_FAILED, + "JDOHelper.getTransactionalObjectId with argument null returned non-null oid " + oid); + pm.close(); + pm = null; + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetTransactionalObjectIdForTransient.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetTransactionalObjectIdForTransient.java index caf1c2583..88b5e9f1b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetTransactionalObjectIdForTransient.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetTransactionalObjectIdForTransient.java @@ -5,71 +5,73 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get Transactional Object Id For Transient
    - * Keywords: jdohelper
    - * Assertion ID: A8.3-6
    - * Assertion Description: The jdohelper.getTransactionalObjectIdForTransient method returns - * null if Object is a transient.Evaluating to true when == is used. + *Title: Get Transactional Object Id For Transient + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.3-6 + *
    + *Assertion Description: + The jdohelper.getTransactionalObjectIdForTransient method returns null if Object is a transient.Evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/1/01 1.0 */ - + public class GetTransactionalObjectIdForTransient extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.3-6 (GetTransactionalObjectIdForTransient) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetTransactionalObjectIdForTransient.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.3-6 (GetTransactionalObjectIdForTransient) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetTransactionalObjectIdForTransient.class); + } - /* test JDOHelper.getTransactionalObjectId(Object pc) - * - */ - public void testGetTransactionalObjectIdForTransient() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - Object oid = JDOHelper.getTransactionalObjectId(p1); - tx.commit(); + /* test JDOHelper.getTransactionalObjectId(Object pc) + * + */ + public void testGetTransactionalObjectIdForTransient() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + Object oid = JDOHelper.getTransactionalObjectId(p1); + tx.commit(); - if (oid != null) - fail( - ASSERTION_FAILED, - "JDOHelper.getTransactionalObjectId called for transiewt instance returned non-null oid " - + oid); - pm.close(); - pm = null; - } + if (oid != null) + fail(ASSERTION_FAILED, + "JDOHelper.getTransactionalObjectId called for transiewt instance returned non-null oid " + oid); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetTransactionalObjectIdNotPersistenceCapable.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetTransactionalObjectIdNotPersistenceCapable.java index 3e0d4e107..d9b7aea67 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetTransactionalObjectIdNotPersistenceCapable.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/GetTransactionalObjectIdNotPersistenceCapable.java @@ -5,68 +5,70 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.Point; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get Object Id Not Persistence Capable
    - * Keywords: jdohelper
    - * Assertion ID: A8.3-7
    - * Assertion Description: The jdohelper.getTransactionalObjectId method returns null if - * Object is not PC.Evaluating to true when == is used. + *Title: Get Object Id Not Persistence Capable + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.3-7 + *
    + *Assertion Description: + The jdohelper.getTransactionalObjectId method returns null if Object is not PC.Evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/1/01 1.0 */ public class GetTransactionalObjectIdNotPersistenceCapable extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.3-7 (GetTransactionalObjectIdNotPersistenceCapable) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetTransactionalObjectIdNotPersistenceCapable.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.3-7 (GetTransactionalObjectIdNotPersistenceCapable) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetTransactionalObjectIdNotPersistenceCapable.class); + } - /* test JDOHelper.getTransactionalObjectId(Object pc) - * - */ - public void testGetTransactionalObjectIdNotPersistenceCapable() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - Point p1 = new Point(1, 3); - Object oid = JDOHelper.getTransactionalObjectId(p1); - tx.commit(); + /* test JDOHelper.getTransactionalObjectId(Object pc) + * + */ + public void testGetTransactionalObjectIdNotPersistenceCapable() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Point p1 = new Point(1,3); + Object oid = JDOHelper.getTransactionalObjectId(p1); + tx.commit(); - if (oid != null) - fail( - ASSERTION_FAILED, - "JDOHelper.getTransactionalObjectId called for instance of non-pc class returned non-null ObjectId " - + oid); - } + if (oid != null) + fail(ASSERTION_FAILED, + "JDOHelper.getTransactionalObjectId called for instance of non-pc class returned non-null ObjectId " + oid); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDeleted.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDeleted.java index 0e21277a1..c9e969227 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDeleted.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDeleted.java @@ -5,75 +5,83 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is Deleted
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.5-1
    - * Assertion Description: The jdohelper.isDeleted method returns true if the instance of - * persistence capable have been deleted in the current transaction evaluating to true when == is - * used. + *Title: Is Deleted + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.5-1 + *
    + *Assertion Description: + The jdohelper.isDeleted method returns true if the instance of persistence capable + have been deleted in the current transaction + evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/26/01 1.0 */ public class IsDeleted extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.4.5-1 (IsDeleted) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsDeleted.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.5-1 (IsDeleted) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsDeleted.class); + } - /* test jdohelper.isDeleted(Object pc) - * - */ - public void testIsDeleted() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - pm.deletePersistent(p1); - boolean deleted = JDOHelper.isDeleted(p1); - tx.commit(); - if (!deleted) fail(ASSERTION_FAILED, "JDOHelper.isDeleted returns false for deleted instance"); - pm.close(); - pm = null; - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /* test jdohelper.isDeleted(Object pc) + * + */ + public void testIsDeleted() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + pm.deletePersistent(p1); + boolean deleted = JDOHelper.isDeleted(p1); + tx.commit(); + if (!deleted) + fail(ASSERTION_FAILED, + "JDOHelper.isDeleted returns false for deleted instance"); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDeletedFalse.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDeletedFalse.java index bb366fb09..e3093bb58 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDeletedFalse.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDeletedFalse.java @@ -5,76 +5,84 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is Deleted False
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.5-2
    - * Assertion Description: The object parameter that implements PersistenceCapable, - * JDOHelper.isDeleted delegates to the parameter instance and instances that have not been deleted - * in the current transaction return false. evaluating to true when == is used. + *Title: Is Deleted False + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.5-2 + *
    + *Assertion Description: + The object parameter that implements PersistenceCapable, JDOHelper.isDeleted + delegates to the parameter instance and instances that have not been deleted + in the current transaction return false. + evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/29/01 1.0 */ public class IsDeletedFalse extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.4.5-2 (IsDeletedFalse) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsDeletedFalse.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.5-2 (IsDeletedFalse) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsDeletedFalse.class); + } - /* test JDOHelper.isDeleted(Object pc) - * - */ - public void testIsDeletedFalse() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - // pm.deletePersistent(p1); - boolean deleted = JDOHelper.isDeleted(p1); - tx.commit(); - if (deleted) - fail(ASSERTION_FAILED, "JDOHelper.isDeleted returns true for non-deleted instance"); - pm.close(); - pm = null; - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /* test JDOHelper.isDeleted(Object pc) + * + */ + public void testIsDeletedFalse() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + //pm.deletePersistent(p1); + boolean deleted = JDOHelper.isDeleted(p1); + tx.commit(); + if (deleted) + fail(ASSERTION_FAILED, + "JDOHelper.isDeleted returns true for non-deleted instance"); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDeletedForNull.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDeletedForNull.java index 90593c944..a9faea59c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDeletedForNull.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDeletedForNull.java @@ -5,64 +5,72 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is Deleted For Null
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.5-5
    - * Assertion Description: The jdohelper.isDeleted method returns false for the instance of - * null, evaluating to true when == is used. + *Title: Is Deleted For Null + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.5-5 + *
    + *Assertion Description: + The jdohelper.isDeleted method returns false for the instance of null, + evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/28/01 1.0 */ - + public class IsDeletedForNull extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.4.5-5 (IsDeletedForNull) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsDeletedForNull.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.5-5 (IsDeletedForNull) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsDeletedForNull.class); + } - /* test JDOHelper.IsDeleted(object PC) - * - */ - public void testIsDeletedForNull() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - Object p1 = null; - // pm.deletePersistent(p1); - boolean deleted = JDOHelper.isDeleted(p1); - tx.commit(); - if (deleted) fail(ASSERTION_FAILED, "JDOHelper.isDeleted with argumnet null returns true."); - pm.close(); - pm = null; - } + /* test JDOHelper.IsDeleted(object PC) + * + */ + public void testIsDeletedForNull() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Object p1 = null; + //pm.deletePersistent(p1); + boolean deleted = JDOHelper.isDeleted(p1); + tx.commit(); + if (deleted) + fail(ASSERTION_FAILED, + "JDOHelper.isDeleted with argumnet null returns true."); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDeletedForTransient.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDeletedForTransient.java index dadad8c30..f40b1da89 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDeletedForTransient.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDeletedForTransient.java @@ -5,66 +5,72 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is Deleted For Transient
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.5-3
    - * Assertion Description: The JDOHelper.IsDeleted method returns false if the instance is a - * transient, evaluating to true when == is used. + *Title: Is Deleted For Transient + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.5-3 + *
    + *Assertion Description: + The JDOHelper.IsDeleted method returns false if the instance is a transient, + evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/26/01 1.0 */ public class IsDeletedForTransient extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.4.5-3 (IsDeletedForTransient) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsDeletedForTransient.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.5-3 (IsDeletedForTransient) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsDeletedForTransient.class); + } - /* test JDOHelper.IsDeleted(Object pc) - * - */ - public void testIsDeletedForTransient() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - boolean deleted = JDOHelper.isDeleted(p1); - tx.commit(); - if (deleted) - fail(ASSERTION_FAILED, "JDOHelper.isDeleted called for transient instance returns true."); - pm.close(); - pm = null; - } + /* test JDOHelper.IsDeleted(Object pc) + * + */ + public void testIsDeletedForTransient() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + boolean deleted = JDOHelper.isDeleted(p1); + tx.commit(); + if (deleted) + fail(ASSERTION_FAILED, + "JDOHelper.isDeleted called for transient instance returns true."); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDeletedNotPersistenceCapable.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDeletedNotPersistenceCapable.java index 4723778ee..1145f68c9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDeletedNotPersistenceCapable.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDeletedNotPersistenceCapable.java @@ -5,68 +5,72 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.Point; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is Deleted Not Persistence Capable
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.5-4
    - * Assertion Description: The JDOHelper.IsDeleted method returns false if the instance is - * not persistence capable , evaluating to true when == is used. + *Title: Is Deleted Not Persistence Capable + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.5-4 + *
    + *Assertion Description: + The JDOHelper.IsDeleted method returns false if the instance is not persistence + capable , evaluating to true when == is used. */ /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/26/01 1.0 */ public class IsDeletedNotPersistenceCapable extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.4.5-4 (IsDeletedNotPersistenceCapable) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsDeletedNotPersistenceCapable.class); - } - - /* test JDOHelper.isDeleted(Object pc) - * - */ - public void testIsDeletedNotPersistenceCapable() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - Point p1 = new Point(1, 3); - boolean deleted = JDOHelper.isDeleted(p1); - tx.commit(); - if (deleted) - fail( - ASSERTION_FAILED, - "JDOHelper.isDeleted called for instance of non-pc class returns true."); - pm.close(); - pm = null; - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.5-4 (IsDeletedNotPersistenceCapable) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsDeletedNotPersistenceCapable.class); + } + + /* test JDOHelper.isDeleted(Object pc) + * + */ + public void testIsDeletedNotPersistenceCapable() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Point p1 = new Point(1,3); + boolean deleted = JDOHelper.isDeleted(p1); + tx.commit(); + if (deleted) + fail(ASSERTION_FAILED, + "JDOHelper.isDeleted called for instance of non-pc class returns true."); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDetached.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDetached.java index 5fc386dbe..840fdcd74 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDetached.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDetached.java @@ -5,79 +5,81 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; -import javax.jdo.JDOHelper; -import javax.jdo.Transaction; import org.apache.jdo.tck.api.persistencemanager.detach.DetachTest; import org.apache.jdo.tck.pc.shoppingcart.Cart; import org.apache.jdo.tck.pc.shoppingcart.Undetachable; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOHelper; +import javax.jdo.Transaction; + /** - * Title: Test IsDetached
    - * Keywords:
    - * Assertion IDs: A8.5.6-1
    - * Assertion Description: Instances that have been detached return true. The method returns - * false if the instance is transient or null or if its class is not detachable. + * Title: Test IsDetached + *
    + * Keywords: + *
    + * Assertion IDs: A8.5.6-1 + *
    + * Assertion Description: + * Instances that have been detached return true. + * The method returns false if the instance is transient or null or if its class is not detachable. */ public class IsDetached extends DetachTest { - private static final String ASSERTION_FAILED = - "Assertion A8.5.6-1 JDOHelper.isDetached(Object) failed: "; + private static final String ASSERTION_FAILED = "Assertion A8.5.6-1 JDOHelper.isDetached(Object) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsDetached.class); - } + /** + * The main is called when the class + * is directly executed from the command line. + * + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsDetached.class); + } - public void testNullTransientAndUndetachableIsDetachedFalse() { - pm = getPM(); - pm.currentTransaction().begin(); + public void testNullTransientAndUndetachableIsDetachedFalse() { + pm = getPM(); + pm.currentTransaction().begin(); - assertFalse(ASSERTION_FAILED + "null object is detached", JDOHelper.isDetached(null)); - assertFalse( - ASSERTION_FAILED + "transient object is detached", JDOHelper.isDetached(new Cart("bob"))); - assertFalse( - ASSERTION_FAILED + "object of class marked not detachabled is detached", - JDOHelper.isDetached(new Undetachable())); + assertFalse(ASSERTION_FAILED + "null object is detached", JDOHelper.isDetached(null)); + assertFalse(ASSERTION_FAILED + "transient object is detached", JDOHelper.isDetached(new Cart("bob"))); + assertFalse(ASSERTION_FAILED + "object of class marked not detachabled is detached", JDOHelper.isDetached(new Undetachable())); - pm.currentTransaction().commit(); - } + pm.currentTransaction().commit(); + } - public void testDetachableIsDetachedTrue() { - pm = getPM(); - Transaction txn = pm.currentTransaction(); + public void testDetachableIsDetachedTrue() { + pm = getPM(); + Transaction txn = pm.currentTransaction(); - Cart c, detached; - Object oid; - txn.begin(); - { - c = new Cart("bob"); - pm.makePersistent(c); - oid = pm.getObjectId(c); - } - txn.commit(); + Cart c, detached; + Object oid; + txn.begin(); + { + c = new Cart("bob"); + pm.makePersistent(c); + oid = pm.getObjectId(c); + } + txn.commit(); - txn.begin(); - { - c = (Cart) pm.getObjectById(oid); - detached = (Cart) pm.detachCopy(c); - assertTrue(JDOHelper.isDetached(detached)); + txn.begin(); + { + c = (Cart) pm.getObjectById(oid); + detached = (Cart) pm.detachCopy(c); + assertTrue(JDOHelper.isDetached(detached)); + } + txn.commit(); } - txn.commit(); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDirty.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDirty.java index e5a8286a4..699ba3dfc 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDirty.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDirty.java @@ -5,75 +5,83 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is Dirty
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.1-1
    - * Assertion Description: The jdohelper.isDirty method returns true if the instance of - * persistence capable have changed the state in the current transaction evaluating to true when == - * is used. + *Title: Is Dirty + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.1-1 + *
    + *Assertion Description: + The jdohelper.isDirty method returns true if the instance of persistence capable + have changed the state in the current transaction + evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/30/01 1.0 */ public class IsDirty extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.4.1-1 (IsDirty) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsDirty.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } - - /* test JDOHelper.isDeleted(Object pc) - * - */ - public void testIsDirty() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - - boolean dirty = JDOHelper.isDirty(p1); - tx.commit(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.1-1 (IsDirty) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsDirty.class); + } - if (!dirty) fail(ASSERTION_FAILED, "JDOHelper.isDirty returns false for P-NEW instance"); - pm.close(); - pm = null; - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /* test JDOHelper.isDeleted(Object pc) + * + */ + public void testIsDirty() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + + boolean dirty = JDOHelper.isDirty(p1); + tx.commit(); + + if (!dirty) + fail(ASSERTION_FAILED, + "JDOHelper.isDirty returns false for P-NEW instance"); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDirtyFalse.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDirtyFalse.java index 8556213ba..9bc914ab3 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDirtyFalse.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDirtyFalse.java @@ -5,78 +5,86 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is Dirty False
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.1-2
    - * Assertion Description: The jdohelper.isDirty method returns false if the instance of - * persistence capable have not changed the state in the current transaction evaluating to true when - * == is used. + *Title: Is Dirty False + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.1-2 + *
    + *Assertion Description: + The jdohelper.isDirty method returns false if the instance of persistence capable + have not changed the state in the current transaction + evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/25/01 1.0 */ public class IsDirtyFalse extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.4.1-2 (IsDirtyFalse) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsDirtyFalse.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } - - /* test JDOHelper.isDirty(Object pc) - * - */ - public void testIsDirtyFalse() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - tx.commit(); - - tx.begin(); - // access p1 field to make sure the instance is loaded in new tx - p1.getX(); - boolean dirty = JDOHelper.isDirty(p1); - tx.commit(); - if (dirty) fail(ASSERTION_FAILED, "JDOHelper.isDirty returns true for P-CLEAN instance"); - pm.close(); - pm = null; - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.1-2 (IsDirtyFalse) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsDirtyFalse.class); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /* test JDOHelper.isDirty(Object pc) + * + */ + public void testIsDirtyFalse() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + tx.commit(); + + tx.begin(); + // access p1 field to make sure the instance is loaded in new tx + p1.getX(); + boolean dirty = JDOHelper.isDirty(p1); + tx.commit(); + if (dirty) + fail(ASSERTION_FAILED, + "JDOHelper.isDirty returns true for P-CLEAN instance"); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDirtyForNull.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDirtyForNull.java index c3e8e5497..0ae3a0421 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDirtyForNull.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDirtyForNull.java @@ -5,63 +5,71 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is Dirty For Null
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.1-5
    - * Assertion Description: The jdohelper.isDirty method returns false if the instance is - * null, evaluating to true when == is used. + *Title: Is Dirty For Null + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.1-5 + *
    + *Assertion Description: + The jdohelper.isDirty method returns false if the instance is null, + evaluating to true when == is used. */ /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/27/01 1.0 */ public class IsDirtyForNull extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.4.1-5 (IsDirtyForNull) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsDirtyForNull.class); - } - - /* test JDOHelper.isDirthy(Object pc) - * - */ - public void testIsDirtyForNull() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - Object p1 = null; - boolean dirty = JDOHelper.isDirty(p1); - tx.commit(); - if (dirty) fail(ASSERTION_FAILED, "JDOHelper.isDirty with argument null returns true."); - pm.close(); - pm = null; - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.1-5 (IsDirtyForNull) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsDirtyForNull.class); + } + + /* test JDOHelper.isDirthy(Object pc) + * + */ + public void testIsDirtyForNull() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Object p1 = null; + boolean dirty = JDOHelper.isDirty(p1); + tx.commit(); + if (dirty) + fail(ASSERTION_FAILED, + "JDOHelper.isDirty with argument null returns true."); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDirtyForTransient.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDirtyForTransient.java index 9aeaf2afb..ef815e975 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDirtyForTransient.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDirtyForTransient.java @@ -5,65 +5,72 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is Dirty For Transient
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.1-3
    - * Assertion Description: The jdohelper.isDirty method returns false If the instance is - * transient, evaluating to true when == is used. + *Title: Is Dirty For Transient + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.1-3 + *
    + *Assertion Description: + The jdohelper.isDirty method returns false If the instance is transient, + evaluating to true when == is used. */ - -/* + + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/28/01 1.0 */ public class IsDirtyForTransient extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.4.1-3 (IsDirtyForTransient) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsDirtyForTransient.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.1-3 (IsDirtyForTransient) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsDirtyForTransient.class); + } - /* test JDOHelper.isDeleted(Object pc) - * - */ - public void testIsDirtyForTransient() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - boolean dirty = JDOHelper.isDirty(p1); - tx.commit(); - if (dirty) fail(ASSERTION_FAILED, "JDOHelper.isDirty returns true for transient instance"); - pm.close(); - pm = null; - } + /* test JDOHelper.isDeleted(Object pc) + * + */ + public void testIsDirtyForTransient() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + boolean dirty = JDOHelper.isDirty(p1); + tx.commit(); + if (dirty) + fail(ASSERTION_FAILED, + "JDOHelper.isDirty returns true for transient instance"); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDirtyNotPersistenceCapable.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDirtyNotPersistenceCapable.java index bb765b686..253e6b55b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDirtyNotPersistenceCapable.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsDirtyNotPersistenceCapable.java @@ -5,66 +5,72 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.Point; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is Dirty Not Persistence Capable
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.1-4
    - * Assertion Description: The jdohelper.isDirty method returns false If the instance does - * not implement PersistenceCapable evaluating to true when == is used. + *Title: Is Dirty Not Persistence Capable + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.1-4 + *
    + *Assertion Description: + The jdohelper.isDirty method returns false If the instance does not implement PersistenceCapable + evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/26/01 1.0 */ - + public class IsDirtyNotPersistenceCapable extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.4.1-4 (IsDirtyNotPersistenceCapable) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsDirtyNotPersistenceCapable.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.1-4 (IsDirtyNotPersistenceCapable) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsDirtyNotPersistenceCapable.class); + } - /* test JDOHelper.isDeleted(Object pc) - * - */ - public void testIsDirtyNotPersistenceCapable() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - Point p1 = new Point(1, 3); - boolean dirty = JDOHelper.isDirty(p1); - tx.commit(); - if (dirty) - fail(ASSERTION_FAILED, "JDOHelper.isDirty returns true for instance of non-pc class."); - pm.close(); - pm = null; - } + /* test JDOHelper.isDeleted(Object pc) + * + */ + public void testIsDirtyNotPersistenceCapable() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Point p1 = new Point(1,3); + boolean dirty = JDOHelper.isDirty(p1); + tx.commit(); + if (dirty) + fail(ASSERTION_FAILED, + "JDOHelper.isDirty returns true for instance of non-pc class."); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsNew.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsNew.java index 275e58d8b..099c047bd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsNew.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsNew.java @@ -5,72 +5,81 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is New
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.4-1
    - * Assertion Description: The jdohelper.isNew method returns true for instances that have - * been made persistent in the current transactionthe evaluating to true when == is used. + *Title: Is New + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.4-1 + *
    + *Assertion Description: + The jdohelper.isNew method returns true for instances that have + been made persistent in the current transactionthe evaluating to + true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/2/01 1.0 */ public class IsNew extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.4.4-1 (IsNew) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsNew.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.4-1 (IsNew) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsNew.class); + } - /* test JDOHelper.isNew(Object pc) - * - */ - public void testIsNew() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - boolean isNew = JDOHelper.isNew(p1); - tx.commit(); - if (!isNew) fail(ASSERTION_FAILED, "JDOHelper.isNew returns false for P-NEW instance"); - pm.close(); - pm = null; - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /* test JDOHelper.isNew(Object pc) + * + */ + public void testIsNew() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + boolean isNew = JDOHelper.isNew(p1); + tx.commit(); + if (!isNew) + fail(ASSERTION_FAILED, + "JDOHelper.isNew returns false for P-NEW instance"); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsNewFalse.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsNewFalse.java index 15157312a..1aa1c7f87 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsNewFalse.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsNewFalse.java @@ -5,68 +5,77 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is New False
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.4-2
    - * Assertion Description: The jdohelper.isnew method returns false for the instances that - * have not been made persistent in the current transaction evaluating to true when == is used. + *Title: Is New False + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.4-2 + *
    + *Assertion Description: + The jdohelper.isnew method returns false for the instances that have not +been made persistent in the current transaction + evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/2/01 1.0 */ public class IsNewFalse extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.4.4-2 (IsNewFalse) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsNewFalse.class); - } - - /* test JDOHelper.isNew(Object pc) - * - */ - public void testIsNewFalse() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - tx.commit(); - - tx.begin(); - // access p1 field to make sure the instance is loaded in new tx - p1.getX(); - boolean isNew = JDOHelper.isNew(p1); - tx.commit(); - if (isNew) fail(ASSERTION_FAILED, "JDOHelper.isNew returns true for P-CLEAN instance"); - pm.close(); - pm = null; - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.4-2 (IsNewFalse) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsNewFalse.class); + } + + /* test JDOHelper.isNew(Object pc) + * + */ + public void testIsNewFalse() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + tx.commit(); + + tx.begin(); + // access p1 field to make sure the instance is loaded in new tx + p1.getX(); + boolean isNew = JDOHelper.isNew(p1); + tx.commit(); + if (isNew) + fail(ASSERTION_FAILED, + "JDOHelper.isNew returns true for P-CLEAN instance"); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsNewForNull.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsNewForNull.java index 1f4429915..e80a2b923 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsNewForNull.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsNewForNull.java @@ -5,63 +5,71 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is New For Null
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.4-5
    - * Assertion Description: The jdohelper.isNew method returns false for the instance which is - * null, evaluating to true when == is used. + *Title: Is New For Null + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.4-5 + *
    + *Assertion Description: + The jdohelper.isNew method returns false for the instance which is null, + evaluating to true when == is used. */ /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/2/01 1.0 */ public class IsNewForNull extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.4.4-5 (IsNewForNull) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsNewForNull.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.4-5 (IsNewForNull) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsNewForNull.class); + } - /* test JDOHelper.isNew(Object pc) - * - */ - public void testIsNewForNull() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - Object p1 = null; - boolean isNew = JDOHelper.isNew(p1); - tx.commit(); - if (isNew) fail(ASSERTION_FAILED, "JDOHelper.isNew with argument null returns true"); - pm.close(); - pm = null; - } + /* test JDOHelper.isNew(Object pc) + * + */ + public void testIsNewForNull() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Object p1 = null; + boolean isNew = JDOHelper.isNew(p1); + tx.commit(); + if (isNew) + fail(ASSERTION_FAILED, + "JDOHelper.isNew with argument null returns true"); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsNewForTransient.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsNewForTransient.java index 32c2b0052..ffcfbf80d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsNewForTransient.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsNewForTransient.java @@ -5,64 +5,72 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is New For Transient
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.4-3
    - * Assertion Description: The jdohelper.isNew method returns false If the instance is - * transient, evaluating to true when == is used. + *Title: Is New For Transient + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.4-3 + *
    + *Assertion Description: + The jdohelper.isNew method returns false If the instance is transient, + evaluating to true when == is used. */ - -/* + + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/2/01 1.0 */ public class IsNewForTransient extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.4.4-3 (IsNewForTransient) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsNewForTransient.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.4-3 (IsNewForTransient) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsNewForTransient.class); + } - /* test JDOHelper.isNew(Object pc) - * - */ - public void testIsNewForTransient() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - boolean isNew = JDOHelper.isNew(p1); - tx.commit(); - if (isNew) fail(ASSERTION_FAILED, "JDOHelper.isNew returns true for transient instance"); - pm.close(); - pm = null; - } + /* test JDOHelper.isNew(Object pc) + * + */ + public void testIsNewForTransient() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + boolean isNew = JDOHelper.isNew(p1); + tx.commit(); + if (isNew) + fail(ASSERTION_FAILED, + "JDOHelper.isNew returns true for transient instance"); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsNewNotPersistenceCapable.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsNewNotPersistenceCapable.java index ce370e5e1..8e8ee7a92 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsNewNotPersistenceCapable.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsNewNotPersistenceCapable.java @@ -5,65 +5,72 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.Point; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is New Not Persistence Capable
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.4-4
    - * Assertion Description: The jdohelper.isNew method returns false If the instance does not - * implement PersistenceCapable evaluating to true when == is used. + *Title: Is New Not Persistence Capable + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.4-4 + *
    + *Assertion Description: + The jdohelper.isNew method returns false If the instance does not implement PersistenceCapable + evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/2/01 1.0 */ - + public class IsNewNotPersistenceCapable extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.4.4-4 (IsNewNotPersistenceCapable) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsNewNotPersistenceCapable.class); - } - - /* test JDOHelper.isNew(Object pc) - * - */ - public void testIsNewNotPersistenceCapable() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - Point p1 = new Point(1, 3); - boolean isNew = JDOHelper.isNew(p1); - tx.commit(); - if (isNew) fail(ASSERTION_FAILED, "JDOHelper.isNew returns true for instance of non-pc class."); - pm.close(); - pm = null; - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.4-4 (IsNewNotPersistenceCapable) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsNewNotPersistenceCapable.class); + } + + /* test JDOHelper.isNew(Object pc) + * + */ + public void testIsNewNotPersistenceCapable() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Point p1 = new Point(1,3); + boolean isNew = JDOHelper.isNew(p1); + tx.commit(); + if (isNew) + fail(ASSERTION_FAILED, + "JDOHelper.isNew returns true for instance of non-pc class."); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsPersistent.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsPersistent.java index f00a06c03..af849463a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsPersistent.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsPersistent.java @@ -5,73 +5,81 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is Persistent
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.3-1
    - * Assertion Description: The JDOHelper.isPersistent method returns true if instances - * represent persistent objects in the data store true when == is used. + *Title: Is Persistent + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.3-1 + *
    + *Assertion Description: + The JDOHelper.isPersistent method returns true if instances represent + persistent objects in the data store + true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/2/01 1.0 */ public class IsPersistent extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.4.3-1 (IsPersistent) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsPersistent.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.3-1 (IsPersistent) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsPersistent.class); + } - /* test JDOHelper.isPersistent(Object pc) - * - */ - public void testIsPersistent() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - boolean persistent = JDOHelper.isPersistent(p1); - tx.commit(); - if (!persistent) - fail(ASSERTION_FAILED, "JDOHelper.isPersistent returns false for P-NEW instance."); - pm.close(); - pm = null; - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /* test JDOHelper.isPersistent(Object pc) + * + */ + public void testIsPersistent() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + boolean persistent = JDOHelper.isPersistent(p1); + tx.commit(); + if (!persistent) + fail(ASSERTION_FAILED, + "JDOHelper.isPersistent returns false for P-NEW instance."); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsPersistentFalse.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsPersistentFalse.java index d18419b75..5eb121cbe 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsPersistentFalse.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsPersistentFalse.java @@ -5,64 +5,72 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is Persistent False
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.3-2
    - * Assertion Description: The jdohelper.isPersistent method returns false for instances - * which do not represent persistent objects in the data store . evaluating to true when == is used. + *Title: Is Persistent False + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.3-2 + *
    + *Assertion Description: + The jdohelper.isPersistent method returns false for instances which do not represent + persistent objects in the data store . + evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/2/01 1.0 */ public class IsPersistentFalse extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.4.3-2 (IsPersistentFalse) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsPersistentFalse.class); - } - - /* test JDOHelper.isPersistent(Object pc) - * - */ - public void testIsPersistentFalse() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - boolean persistent = JDOHelper.isPersistent(p1); - tx.commit(); - if (persistent) - fail(ASSERTION_FAILED, "JDOHelper.isPersistent returns true for transient instance."); - pm.close(); - pm = null; - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.3-2 (IsPersistentFalse) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsPersistentFalse.class); + } + + /* test JDOHelper.isPersistent(Object pc) + * + */ + public void testIsPersistentFalse() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + boolean persistent = JDOHelper.isPersistent(p1); + tx.commit(); + if (persistent) + fail(ASSERTION_FAILED, + "JDOHelper.isPersistent returns true for transient instance."); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsPersistentForNull.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsPersistentForNull.java index 7cd0ded6c..9723c2333 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsPersistentForNull.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsPersistentForNull.java @@ -5,65 +5,71 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is Persistent For Null
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.3-5
    - * Assertion Description: The jdohelper.isPersistent method returns false for the instance - * which is null, evaluating to true when == is used. + *Title: Is Persistent For Null + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.3-5 + *
    + *Assertion Description: + The jdohelper.isPersistent method returns false for the instance which is null, + evaluating to true when == is used. */ /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/2/01 1.0 */ public class IsPersistentForNull extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.4.3-5 (IsPersistentForNull) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsPersistentForNull.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.3-5 (IsPersistentForNull) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsPersistentForNull.class); + } - /* test JDOHelper.isPersistent(Object pc) - * - */ - public void testIsPersistentForNull() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - Object p1 = null; - boolean persistent = JDOHelper.isPersistent(p1); - tx.commit(); - if (persistent) - fail(ASSERTION_FAILED, "JDOHelper.isPersistent with argumnet null returns true."); - pm.close(); - pm = null; - } + /* test JDOHelper.isPersistent(Object pc) + * + */ + public void testIsPersistentForNull() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Object p1 = null; + boolean persistent = JDOHelper.isPersistent(p1); + tx.commit(); + if (persistent) + fail(ASSERTION_FAILED, + "JDOHelper.isPersistent with argumnet null returns true."); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsPersistentForTransient.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsPersistentForTransient.java index 4d578157c..a89f7adcf 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsPersistentForTransient.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsPersistentForTransient.java @@ -5,66 +5,73 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is Persistent For Transient
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.3-3
    - * Assertion Description: The jdohelper.isPersistent method returns false If the instance is - * transient, evaluating to true when == is used. + *Title: Is Persistent For Transient + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.3-3 + *
    + *Assertion Description: + The jdohelper.isPersistent method returns false If the instance is transient, + evaluating to true when == is used. */ - -/* + + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/2/01 1.0 */ public class IsPersistentForTransient extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.4.3-3 (IsPersistentForTransient) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsPersistentForTransient.class); - } - - /* test JDOHelper.isPersistent(Object pc) - * - */ - public void testIsPersistentForTransient() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - boolean persistent = JDOHelper.isPersistent(p1); - tx.commit(); - if (persistent) - fail(ASSERTION_FAILED, "JDOHelper.isPersistent returns true for transient instance."); - pm.close(); - pm = null; - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.3-3 (IsPersistentForTransient) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsPersistentForTransient.class); + } + + /* test JDOHelper.isPersistent(Object pc) + * + */ + public void testIsPersistentForTransient() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + boolean persistent = JDOHelper.isPersistent(p1); + tx.commit(); + if (persistent) + fail(ASSERTION_FAILED, + "JDOHelper.isPersistent returns true for transient instance."); + pm.close(); + pm = null; + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsPersistentNotPersistenceCapable.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsPersistentNotPersistenceCapable.java index 1599f8c5e..f81e094ca 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsPersistentNotPersistenceCapable.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsPersistentNotPersistenceCapable.java @@ -5,66 +5,72 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.Point; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is Persistent Not Persistence Capable
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.3-4
    - * Assertion Description: The jdohelper.isPersistent method returns false If the instance - * does not implement PersistenceCapable evaluating to true when == is used. + *Title: Is Persistent Not Persistence Capable + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.3-4 + *
    + *Assertion Description: + The jdohelper.isPersistent method returns false If the instance does not implement PersistenceCapable + evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/2/01 1.0 */ - + public class IsPersistentNotPersistenceCapable extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.4.3-4 (IsPersistentNotPersistenceCapable) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsPersistentNotPersistenceCapable.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.3-4 (IsPersistentNotPersistenceCapable) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsPersistentNotPersistenceCapable.class); + } - /* test JDOHelper.isPersistent(Object pc) - * - */ - public void testIsPersistentNotPersistenceCapable() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - Point p1 = new Point(1, 3); - boolean persistent = JDOHelper.isPersistent(p1); - tx.commit(); - if (persistent) - fail(ASSERTION_FAILED, "JDOHelper.isPersistent returns false for instance of non-pc class."); - pm.close(); - pm = null; - } + /* test JDOHelper.isPersistent(Object pc) + * + */ + public void testIsPersistentNotPersistenceCapable() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Point p1 = new Point(1,3); + boolean persistent = JDOHelper.isPersistent(p1); + tx.commit(); + if (persistent) + fail(ASSERTION_FAILED, + "JDOHelper.isPersistent returns false for instance of non-pc class."); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsTransactional.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsTransactional.java index 534c22f6d..9492e2cb6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsTransactional.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsTransactional.java @@ -5,82 +5,88 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is Transactional
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.2-1
    - * Assertion Description: The jdohelper.isTransactional method returns true and delegates to - * the parameter instance and instances whose state is associated with the current transaction . - * evaluating to true when == is used. + *Title: Is Transactional + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.2-1 + *
    + *Assertion Description: + The jdohelper.isTransactional method returns true and delegates to the parameter instance + and instances whose state is associated with the current transaction . evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/4/01 1.0 */ public class IsTransactional extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.4.2-1 (IsTransactional) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsTransactional.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } - - /* test JDOHelper.IsTransactional(Object pc) - * - */ - public void testIsTransactional() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - boolean transactional = JDOHelper.isTransactional(p1); - tx.commit(); - if (!transactional) - fail(ASSERTION_FAILED, "JDOHelper.isTransactional returns false for P-NEW instance"); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.2-1 (IsTransactional) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsTransactional.class); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /* test JDOHelper.IsTransactional(Object pc) + * + */ + public void testIsTransactional() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + boolean transactional = JDOHelper.isTransactional(p1); + tx.commit(); + if (!transactional) + fail(ASSERTION_FAILED, + "JDOHelper.isTransactional returns false for P-NEW instance"); - tx.begin(); - // check transactional flag in new tx - transactional = JDOHelper.isTransactional(p1); - tx.commit(); - if (transactional) - fail( - ASSERTION_FAILED, "JDOHelper.isTransactional returns true for P-HOLLOW/P-NONTX instance"); - pm.close(); - pm = null; - } + tx.begin(); + // check transactional flag in new tx + transactional = JDOHelper.isTransactional(p1); + tx.commit(); + if (transactional) + fail(ASSERTION_FAILED, + "JDOHelper.isTransactional returns true for P-HOLLOW/P-NONTX instance"); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsTransactionalFalse.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsTransactionalFalse.java index 046ecf5b0..1f1699d71 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsTransactionalFalse.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsTransactionalFalse.java @@ -5,89 +5,94 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is Transactional False
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.2-2
    - * Assertion Description: The jdohelper.isTransactional method returns false and delegates - * to the parameter instance and instances whose state is not associated with the current - * transaction return false. + *Title: Is Transactional False + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.2-2 + *
    + *Assertion Description: + The jdohelper.isTransactional method returns false and delegates to the parameter +instance and instances whose state is not associated with the current transaction return false. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/4/01 1.0 */ public class IsTransactionalFalse extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.4.2-2 (IsTransactionalFalse) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsTransactionalFalse.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } - - /* test JDOHelper.IsTransactionalFalse(Object pc) - * - */ - public void testIsTransactionalFalse() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.setOptimistic(false); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - tx.commit(); - - tx.begin(); - boolean transactional = JDOHelper.isTransactional(p1); - tx.commit(); - if (transactional) - fail( - ASSERTION_FAILED, "JDOHelper.isTransactional returns true for P-HOLLOW/P-NONTX instance"); - - tx.begin(); - // access field to make sure the instance is P-CLEAN - p1.getX(); - transactional = JDOHelper.isTransactional(p1); - tx.commit(); - if (!transactional) - fail(ASSERTION_FAILED, "JDOHelper.isTransactional returns false for P-CLEAN instance"); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.2-2 (IsTransactionalFalse) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsTransactionalFalse.class); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /* test JDOHelper.IsTransactionalFalse(Object pc) + * + */ + public void testIsTransactionalFalse() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.setOptimistic(false); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + tx.commit(); + + tx.begin(); + boolean transactional = JDOHelper.isTransactional(p1); + tx.commit(); + if (transactional) + fail(ASSERTION_FAILED, + "JDOHelper.isTransactional returns true for P-HOLLOW/P-NONTX instance"); + + tx.begin(); + // access field to make sure the instance is P-CLEAN + p1.getX(); + transactional = JDOHelper.isTransactional(p1); + tx.commit(); + if (!transactional) + fail(ASSERTION_FAILED, + "JDOHelper.isTransactional returns false for P-CLEAN instance"); - pm.close(); - pm = null; - } + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsTransactionalForNull.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsTransactionalForNull.java index b982e34e8..88daa31a4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsTransactionalForNull.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsTransactionalForNull.java @@ -5,64 +5,69 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is Transactional For Null
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.2-5
    - * Assertion Description: The jdohelper.isTransactional method returns false, if the - * instance is null. + *Title: Is Transactional For Null + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.2-5 + *
    + *Assertion Description: + The jdohelper.isTransactional method returns false, if the instance is null. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/4/01 1.0 */ public class IsTransactionalForNull extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.4.2-5 (IsTransactionalForNull) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsTransactionalForNull.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.2-5 (IsTransactionalForNull) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsTransactionalForNull.class); + } - /* test JDOHelper.IsTransactionalForNull(Object pc) - * - */ - public void testIsTransactionalForNull() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - Object p1 = null; - boolean transactional = JDOHelper.isTransactional(p1); - tx.commit(); - if (transactional) - fail(ASSERTION_FAILED, "JDOHelper.isTransactional with argument null returns true."); - pm.close(); - pm = null; - } + /* test JDOHelper.IsTransactionalForNull(Object pc) + * + */ + public void testIsTransactionalForNull() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Object p1 = null; + boolean transactional = JDOHelper.isTransactional(p1); + tx.commit(); + if (transactional) + fail(ASSERTION_FAILED, + "JDOHelper.isTransactional with argument null returns true."); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsTransactionalForTransient.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsTransactionalForTransient.java index 4ec57e960..2850b3c62 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsTransactionalForTransient.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsTransactionalForTransient.java @@ -5,65 +5,70 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is Transactional For Transient
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.2-3
    - * Assertion Description: The jdohelper.isTransactional method returns false if the instance - * is transien . evaluating to true when == is used. + *Title: Is Transactional For Transient + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.2-3 + *
    + *Assertion Description: + The jdohelper.isTransactional method returns false if the instance is transien . evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/4/01 1.0 */ public class IsTransactionalForTransient extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.4.2-3 (IsTransactionalForTransient) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsTransactionalForTransient.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.2-3 (IsTransactionalForTransient) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsTransactionalForTransient.class); + } - /* test JDOHelper.IsTransactionalForTransient(Object pc) - * - */ - public void testIsTransactionalForTransient() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - boolean transactional = JDOHelper.isTransactional(p1); - tx.commit(); - if (transactional) - fail(ASSERTION_FAILED, "JDOHelper.isTransactional returns true for transient instance."); - pm.close(); - pm = null; - } + /* test JDOHelper.IsTransactionalForTransient(Object pc) + * + */ + public void testIsTransactionalForTransient() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + boolean transactional = JDOHelper.isTransactional(p1); + tx.commit(); + if (transactional) + fail(ASSERTION_FAILED, + "JDOHelper.isTransactional returns true for transient instance."); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsTransactionalNotPersistenceCapable.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsTransactionalNotPersistenceCapable.java index 5cd7e743a..430ee7bc5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsTransactionalNotPersistenceCapable.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/IsTransactionalNotPersistenceCapable.java @@ -5,66 +5,71 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.Point; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Is Transactional Not Persistence Capable
    - * Keywords: jdohelper
    - * Assertion ID: A8.4.2-4
    - * Assertion Description: The jdohelper.isTransactional method returns false If the instance - * does not implement PersistenceCapable . evaluating to true when == is used. + *Title: Is Transactional Not Persistence Capable + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.4.2-4 + *
    + *Assertion Description: + The jdohelper.isTransactional method returns false If + the instance does not implement PersistenceCapable . evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/4/01 1.0 */ public class IsTransactionalNotPersistenceCapable extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.4.2-4 (IsTransactionalNotPersistenceCapable) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsTransactionalNotPersistenceCapable.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.4.2-4 (IsTransactionalNotPersistenceCapable) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsTransactionalNotPersistenceCapable.class); + } - /* test JDOHelper.IsTransactionalNotPersistenceCapable(Object pc) - * - */ - public void testIsTransactionalNotPersistenceCapable() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - Point p1 = new Point(1, 3); - boolean transactional = JDOHelper.isTransactional(p1); - tx.commit(); - if (transactional) - fail( - ASSERTION_FAILED, "JDOHelper.isTransactional returns true for instance of non-pc class."); - pm.close(); - pm = null; - } + /* test JDOHelper.IsTransactionalNotPersistenceCapable(Object pc) + * + */ + public void testIsTransactionalNotPersistenceCapable() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Point p1 = new Point(1,3); + boolean transactional = JDOHelper.isTransactional(p1); + tx.commit(); + if (transactional) + fail(ASSERTION_FAILED, + "JDOHelper.isTransactional returns true for instance of non-pc class."); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/MakeDirty.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/MakeDirty.java index 8f537c1a5..de76da1f7 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/MakeDirty.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/MakeDirty.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,66 +19,74 @@ import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Make Dirty
    - * Keywords: jdohelper
    - * Assertion ID: A8.2-1
    - * Assertion Description: The jdohelper.makeDirty method delegates to the parameter instance - * and marks the specified field dirty if parameter is instance of Persistence capable . evaluating - * to true when == is used. + *Title: Make Dirty + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.2-1 + *
    + *Assertion Description: + The jdohelper.makeDirty method delegates to the parameter instance + and marks the specified field dirty if parameter is instance of Persistence + capable . evaluating to true when == is used. */ -/* + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/2/01 1.0 */ public class MakeDirty extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.2-1 (MakeDirty) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeDirty.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } - - /* test JDOHelper.MakeDirty(Object pc) - * - */ - public void testMakeDirty() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - if (debug) logger.debug(" isDirty1:" + JDOHelper.isDirty(p1)); - tx.commit(); - if (debug) logger.debug(" isDirty2:" + JDOHelper.isDirty(p1)); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.2-1 (MakeDirty) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeDirty.class); + } - tx.begin(); - JDOHelper.makeDirty(p1, "x"); - boolean dirty = JDOHelper.isDirty(p1); - tx.commit(); - if (debug) logger.debug(" isDirty3:" + dirty); - if (!dirty) fail(ASSERTION_FAILED, "Instance is not dirty after calling JDOHelper.makeDirty"); - pm.close(); - pm = null; - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /* test JDOHelper.MakeDirty(Object pc) + * + */ + public void testMakeDirty() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + if (debug) logger.debug(" isDirty1:"+ JDOHelper.isDirty(p1)); + tx.commit(); + if (debug) logger.debug(" isDirty2:" + JDOHelper.isDirty(p1)); + + tx.begin(); + JDOHelper.makeDirty(p1,"x"); + boolean dirty = JDOHelper.isDirty(p1); + tx.commit(); + if (debug) logger.debug(" isDirty3:" + dirty); + if (!dirty) + fail(ASSERTION_FAILED, + "Instance is not dirty after calling JDOHelper.makeDirty"); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/MakeDirtyForNull.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/MakeDirtyForNull.java index 26a988d28..90eabd2db 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/MakeDirtyForNull.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/MakeDirtyForNull.java @@ -5,64 +5,72 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Make Dirty For Null
    - * Keywords: jdohelper
    - * Assertion ID: A8.2-3
    - * Assertion Description: The JDOHelper.makeDirty method has no affect if the instance is - * null, evaluating to true when == is used. + *Title: Make Dirty For Null + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.2-3 + *
    + *Assertion Description: + The JDOHelper.makeDirty method has no affect if the instance is null, + evaluating to true when == is used. */ /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/27/01 1.0 */ public class MakeDirtyForNull extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.2-3 (MakeDirtyForNull) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeDirtyForNull.class); - } - - /* test JDOHelper.makeDirthy(Object pc) - * - */ - public void testMakeDirtyForNull() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - Object p1 = null; - JDOHelper.makeDirty(p1, "x"); - boolean dirty = JDOHelper.isDirty(p1); - tx.commit(); - if (dirty) fail(ASSERTION_FAILED, "null instance is dirty after calling JDOHelper.makeDirty."); - pm.close(); - pm = null; - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.2-3 (MakeDirtyForNull) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeDirtyForNull.class); + } + + /* test JDOHelper.makeDirthy(Object pc) + * + */ + public void testMakeDirtyForNull() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Object p1 = null; + JDOHelper.makeDirty(p1,"x"); + boolean dirty = JDOHelper.isDirty(p1); + tx.commit(); + if (dirty) + fail(ASSERTION_FAILED, + "null instance is dirty after calling JDOHelper.makeDirty."); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/MakeDirtyForTransient.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/MakeDirtyForTransient.java index d564a194f..5477aee13 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/MakeDirtyForTransient.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/MakeDirtyForTransient.java @@ -5,69 +5,75 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Make Dirty For Transient
    - * Keywords: jdohelper
    - * Assertion ID: A8.2-2
    - * Assertion Description: The JDOHelper.makeDirty method has no affect if the instance is - * transient, evaluating to true when == is used. + *Title: Make Dirty For Transient + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.2-2 + *
    + *Assertion Description: + The JDOHelper.makeDirty method has no affect if the instance is transient, + evaluating to true when == is used. */ /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/3/01 1.0 */ public class MakeDirtyForTransient extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.2-2 (MakeDirtyForTransient) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeDirtyForTransient.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.2-2 (MakeDirtyForTransient) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeDirtyForTransient.class); + } - /* test JDOHelper.makeDirthy(Object pc) - * - */ - public void testMakeDirtyForTransient() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(1, 2); - if (debug) logger.debug(" isDirty1:" + JDOHelper.isDirty(p1)); - JDOHelper.makeDirty(p1, "x"); - if (debug) logger.debug(" isDirty2:" + JDOHelper.isDirty(p1)); - boolean dirty = JDOHelper.isDirty(p1); - tx.commit(); - if (dirty) - fail(ASSERTION_FAILED, "transient instance is dirty after calling JDOHelper.makeDirty."); - pm.close(); - pm = null; - } + /* test JDOHelper.makeDirthy(Object pc) + * + */ + public void testMakeDirtyForTransient() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(1,2); + if (debug) logger.debug(" isDirty1:"+ JDOHelper.isDirty(p1)); + JDOHelper.makeDirty(p1,"x"); + if (debug) logger.debug(" isDirty2:"+ JDOHelper.isDirty(p1)); + boolean dirty = JDOHelper.isDirty(p1); + tx.commit(); + if (dirty) + fail(ASSERTION_FAILED, + "transient instance is dirty after calling JDOHelper.makeDirty."); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/MakeDirtyNotPersistenceCapable.java b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/MakeDirtyNotPersistenceCapable.java index 025e5fdb1..9ed4513de 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/MakeDirtyNotPersistenceCapable.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/jdohelper/MakeDirtyNotPersistenceCapable.java @@ -5,68 +5,73 @@ * 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 + * + * 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.jdo.tck.api.jdohelper; import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.Point; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Make Dirty Not Persistence Capable
    - * Keywords: jdohelper
    - * Assertion ID: A8.2-4
    - * Assertion Description: The JDOHelper.makeDirty method has no affect if the instance is - * not persistence capable evaluating to true when == is used. + *Title: Make Dirty Not Persistence Capable + *
    + *Keywords: jdohelper + *
    + *Assertion ID: A8.2-4 + *
    + *Assertion Description: + The JDOHelper.makeDirty method has no affect if the instance is not persistence capable + evaluating to true when == is used. */ /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/3/01 1.0 */ public class MakeDirtyNotPersistenceCapable extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.2-4 (MakeDirtyNotPersistenceCapable) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeDirtyNotPersistenceCapable.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.2-4 (MakeDirtyNotPersistenceCapable) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeDirtyNotPersistenceCapable.class); + } - /* test JDOHelper.makeDirthy(Object pc) - * - */ - public void testMakeDirtyNotPersistenceCapable() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - Point p1 = new Point(1, 2); - JDOHelper.makeDirty(p1, "x"); - boolean dirty = JDOHelper.isDirty(p1); - tx.commit(); - if (dirty) - fail( - ASSERTION_FAILED, "instance of non-pc class is dirty after calling JDOHelper.makeDirty."); - pm.close(); - pm = null; - } + /* test JDOHelper.makeDirthy(Object pc) + * + */ + public void testMakeDirtyNotPersistenceCapable() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Point p1 = new Point(1,2); + JDOHelper.makeDirty(p1,"x"); + boolean dirty = JDOHelper.isDirty(p1); + tx.commit(); + if (dirty) + fail(ASSERTION_FAILED, + "instance of non-pc class is dirty after calling JDOHelper.makeDirty."); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencecapable/AbstractPersistenceCapableTest.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencecapable/AbstractPersistenceCapableTest.java index c0e03c3f5..f83c88456 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencecapable/AbstractPersistenceCapableTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencecapable/AbstractPersistenceCapableTest.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,46 +20,50 @@ import javax.jdo.JDOHelper; import javax.jdo.PersistenceManager; import javax.jdo.spi.PersistenceCapable; + import org.apache.jdo.tck.JDO_Test; /** - * This class is the super class for all persistence-capable tests. - * + * This class is the super class for all persistence-capable tests. * @author Michael Watzek */ abstract class AbstractPersistenceCapableTest extends JDO_Test { - /** - * Makes the given object persistent, adds it as tear down instance, and returns its object id. - * - * @param pc the transient instance to be made persistent - * @return the object id of the persistent instance - */ - protected Object makePersistent(Object pc) { - addTearDownClass(pc.getClass()); - PersistenceManager pm = getPM(); - pm.currentTransaction().begin(); - pm.makePersistent(pc); - Object result = JDOHelper.getObjectId(pc); - pm.currentTransaction().commit(); - return result; - } - - protected boolean isTestToBePerformed() { - String testName = getClass().getName(); - if (!isBinaryCompatibilitySupported()) { - printUnsupportedOptionalFeatureNotTested(testName, "javax.jdo.option.BinaryCompatibility"); - } else if (!isApplicationIdentitySupported()) { - printUnsupportedOptionalFeatureNotTested(testName, "javax.jdo.option.ApplicationIdentity"); + /** + * Makes the given object persistent, + * adds it as tear down instance, + * and returns its object id. + * @param pc the transient instance to be made persistent + * @return the object id of the persistent instance + */ + protected Object makePersistent(Object pc) { + addTearDownClass(pc.getClass()); + PersistenceManager pm = getPM(); + pm.currentTransaction().begin(); + pm.makePersistent(pc); + Object result = JDOHelper.getObjectId(pc); + pm.currentTransaction().commit(); + return result; } - return isBinaryCompatibilitySupported() - && isApplicationIdentitySupported() - && runsWithApplicationIdentity(); - } - - protected void assertPersistenceCapable(Object o) { - if (!(o instanceof PersistenceCapable)) { - throw new IllegalArgumentException("Argument o must be instance of PersistenceCapable."); + + protected boolean isTestToBePerformed() { + String testName = getClass().getName(); + if (!isBinaryCompatibilitySupported()) { + printUnsupportedOptionalFeatureNotTested( + testName, "javax.jdo.option.BinaryCompatibility"); + } else if (!isApplicationIdentitySupported()) { + printUnsupportedOptionalFeatureNotTested( + testName, "javax.jdo.option.ApplicationIdentity"); + } + return isBinaryCompatibilitySupported() && + isApplicationIdentitySupported() && + runsWithApplicationIdentity(); + } + + protected void assertPersistenceCapable(Object o) { + if (!(o instanceof PersistenceCapable)) { + throw new IllegalArgumentException + ("Argument o must be instance of PersistenceCapable."); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencecapable/CopyKeyFieldsFromObjectId.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencecapable/CopyKeyFieldsFromObjectId.java index d42ca851d..8b97b479f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencecapable/CopyKeyFieldsFromObjectId.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencecapable/CopyKeyFieldsFromObjectId.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -26,6 +26,7 @@ import javax.jdo.identity.SingleFieldIdentity; import javax.jdo.identity.StringIdentity; import javax.jdo.spi.PersistenceCapable; + import org.apache.jdo.tck.pc.singlefieldidentity.AbstractPCPointSingleField; import org.apache.jdo.tck.pc.singlefieldidentity.PCPointSingleFieldByte; import org.apache.jdo.tck.pc.singlefieldidentity.PCPointSingleFieldCharacter; @@ -42,234 +43,254 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:CopyKeyFieldsFromObjectId of PersistenceCapable
    - * Keywords: persistencecapable
    - * Assertion IDs: A7.12-25
    - * Assertion Description: - * - *

    A7.12-25
    - * public void jdoCopyKeyFieldsFromObjectId(ObjectIdFieldConsumer fc, Object oid); This method - * copies fields to the field manager instance from the second parameter instance. - * + *Title:CopyKeyFieldsFromObjectId of PersistenceCapable + *
    + *Keywords: persistencecapable + *
    + *Assertion IDs: A7.12-25 + *
    + *Assertion Description: + *

    + * A7.12-25
    + * public void jdoCopyKeyFieldsFromObjectId(ObjectIdFieldConsumer fc, Object oid); + * This method copies fields to the field manager instance + * from the second parameter instance. + * * @author Michael Watzek */ -public class CopyKeyFieldsFromObjectId extends AbstractPersistenceCapableTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A7.12-25 (jdoCopyKeyFieldsFromObjectId) failed: "; +public class CopyKeyFieldsFromObjectId extends AbstractPersistenceCapableTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CopyKeyFieldsFromObjectId.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A7.12-25 (jdoCopyKeyFieldsFromObjectId) failed: "; - public void testSingleFieldIdentitybyte() { - if (isTestToBePerformed()) { - singleFieldIdentity(new PCPointSingleFieldPrimitivebyte(1, 2)); + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CopyKeyFieldsFromObjectId .class); } - } - public void testSingleFieldIdentityByte() { - if (isTestToBePerformed()) { - singleFieldIdentity(new PCPointSingleFieldByte(1, 2)); + public void testSingleFieldIdentitybyte() { + if (isTestToBePerformed()) { + singleFieldIdentity(new PCPointSingleFieldPrimitivebyte(1, 2)); + } } - } - - public void testSingleFieldIdentitychar() { - if (isTestToBePerformed()) { - singleFieldIdentity(new PCPointSingleFieldPrimitivechar(1, 2)); + + public void testSingleFieldIdentityByte() { + if (isTestToBePerformed()) { + singleFieldIdentity(new PCPointSingleFieldByte(1, 2)); + } } - } - - public void testSingleFieldIdentityCharacter() { - if (isTestToBePerformed()) { - singleFieldIdentity(new PCPointSingleFieldCharacter(1, 2)); + + public void testSingleFieldIdentitychar() { + if (isTestToBePerformed()) { + singleFieldIdentity(new PCPointSingleFieldPrimitivechar(1, 2)); + } } - } - - public void testSingleFieldIdentityint() { - if (isTestToBePerformed()) { - singleFieldIdentity(new PCPointSingleFieldPrimitiveint(1, 2)); + + public void testSingleFieldIdentityCharacter() { + if (isTestToBePerformed()) { + singleFieldIdentity(new PCPointSingleFieldCharacter(1, 2)); + } } - } - - public void testSingleFieldIdentityInteger() { - if (isTestToBePerformed()) { - singleFieldIdentity(new PCPointSingleFieldInteger(1, 2)); + + public void testSingleFieldIdentityint() { + if (isTestToBePerformed()) { + singleFieldIdentity(new PCPointSingleFieldPrimitiveint(1, 2)); + } } - } - - public void testSingleFieldIdentitylong() { - if (isTestToBePerformed()) { - singleFieldIdentity(new PCPointSingleFieldPrimitivelong(1, 2)); + + public void testSingleFieldIdentityInteger() { + if (isTestToBePerformed()) { + singleFieldIdentity(new PCPointSingleFieldInteger(1, 2)); + } } - } - - public void testSingleFieldIdentityLong() { - if (isTestToBePerformed()) { - singleFieldIdentity(new PCPointSingleFieldLong(1, 2)); + + public void testSingleFieldIdentitylong() { + if (isTestToBePerformed()) { + singleFieldIdentity(new PCPointSingleFieldPrimitivelong(1, 2)); + } } - } - - public void testSingleFieldIdentityshort() { - if (isTestToBePerformed()) { - singleFieldIdentity(new PCPointSingleFieldPrimitiveshort(1, 2)); + + public void testSingleFieldIdentityLong() { + if (isTestToBePerformed()) { + singleFieldIdentity(new PCPointSingleFieldLong(1, 2)); + } } - } - - public void testSingleFieldIdentityShort() { - if (isTestToBePerformed()) { - singleFieldIdentity(new PCPointSingleFieldShort(1, 2)); + + public void testSingleFieldIdentityshort() { + if (isTestToBePerformed()) { + singleFieldIdentity(new PCPointSingleFieldPrimitiveshort(1, 2)); + } } - } - - public void testSingleFieldIdentityString() { - if (isTestToBePerformed()) { - singleFieldIdentity(new PCPointSingleFieldString(1, 2)); + + public void testSingleFieldIdentityShort() { + if (isTestToBePerformed()) { + singleFieldIdentity(new PCPointSingleFieldShort(1, 2)); + } } - } - - public void testSingleFieldIdentityDate() { - if (isTestToBePerformed()) { - singleFieldIdentity(new PCPointSingleFieldDate(1, 2)); + + public void testSingleFieldIdentityString() { + if (isTestToBePerformed()) { + singleFieldIdentity(new PCPointSingleFieldString(1, 2)); + } } - } - - /** - * The common method for test cases checking for assertion A7.12-25:
    - * public void jdoCopyKeyFieldsFromObjectId(ObjectIdFieldConsumer fc, Object oid); This method - * copies fields to the field manager instance from the second parameter instance. - * - * @param o the object to check - */ - private void singleFieldIdentity(AbstractPCPointSingleField o) { - assertPersistenceCapable(o); - SingleFieldIdentity sfi = (SingleFieldIdentity) makePersistent(o); - PersistenceCapable pc = (PersistenceCapable) o; - ObjectIdFieldConsumer objectIdFieldConsumer = new ObjectIdFieldConsumer(); - pc.jdoCopyKeyFieldsFromObjectId(objectIdFieldConsumer, sfi); - if (!objectIdFieldConsumer.equals(sfi)) { - fail( - ASSERTION_FAILED - + "pc.jdoCopyKeyFieldsFromObjectId copies unexpected " - + "fields into an object id field consumer using a " - + "single field indentity object id."); + + public void testSingleFieldIdentityDate() { + if (isTestToBePerformed()) { + singleFieldIdentity(new PCPointSingleFieldDate(1, 2)); + } } - } - - private static class ObjectIdFieldConsumer implements PersistenceCapable.ObjectIdFieldConsumer { - - private boolean booleanField; - private byte byteField; - private char charField; - private double doubleField; - private float floatField; - private int intField; - private long longField; - private short shortField; - private String stringField; - private Object objectField; - - /* - * @see PersistenceCapable.ObjectIdFieldConsumer#storeBooleanField(int, boolean) + + /** + * The common method for test cases checking for assertion A7.12-25:
    + * public void jdoCopyKeyFieldsFromObjectId(ObjectIdFieldConsumer fc, Object oid); + * This method copies fields to the field manager instance + * from the second parameter instance. + * @param o the object to check */ - public void storeBooleanField(int fieldNumber, boolean value) { - this.booleanField = value; + private void singleFieldIdentity(AbstractPCPointSingleField o) { + assertPersistenceCapable(o); + SingleFieldIdentity sfi = (SingleFieldIdentity) makePersistent(o); + PersistenceCapable pc = (PersistenceCapable) o; + ObjectIdFieldConsumer objectIdFieldConsumer = + new ObjectIdFieldConsumer(); + pc.jdoCopyKeyFieldsFromObjectId(objectIdFieldConsumer, sfi); + if (!objectIdFieldConsumer.equals(sfi)) { + fail(ASSERTION_FAILED + + "pc.jdoCopyKeyFieldsFromObjectId copies unexpected " + + "fields into an object id field consumer using a " + + "single field indentity object id."); + } } - /* - * @see PersistenceCapable.ObjectIdFieldConsumer#storeCharField(int, char) - */ - public void storeCharField(int fieldNumber, char value) { - this.charField = value; - } + private static class ObjectIdFieldConsumer + implements PersistenceCapable.ObjectIdFieldConsumer { + + private boolean booleanField; + private byte byteField; + private char charField; + private double doubleField; + private float floatField; + private int intField; + private long longField; + private short shortField; + private String stringField; + private Object objectField; - /* - * @see PersistenceCapable.ObjectIdFieldConsumer#storeByteField(int, byte) - */ - public void storeByteField(int fieldNumber, byte value) { - this.byteField = value; - } + /* + * @see PersistenceCapable.ObjectIdFieldConsumer#storeBooleanField(int, boolean) + */ + public void storeBooleanField(int fieldNumber, boolean value) { + this.booleanField = value; + } - /* - * @see PersistenceCapable.ObjectIdFieldConsumer#storeShortField(int, short) - */ - public void storeShortField(int fieldNumber, short value) { - this.shortField = value; - } + /* + * @see PersistenceCapable.ObjectIdFieldConsumer#storeCharField(int, char) + */ + public void storeCharField(int fieldNumber, char value) { + this.charField = value; + } - /* - * @see PersistenceCapable.ObjectIdFieldConsumer#storeIntField(int, int) - */ - public void storeIntField(int fieldNumber, int value) { - this.intField = value; - } + /* + * @see PersistenceCapable.ObjectIdFieldConsumer#storeByteField(int, byte) + */ + public void storeByteField(int fieldNumber, byte value) { + this.byteField = value; + } - /* - * @see PersistenceCapable.ObjectIdFieldConsumer#storeLongField(int, long) - */ - public void storeLongField(int fieldNumber, long value) { - this.longField = value; - } + /* + * @see PersistenceCapable.ObjectIdFieldConsumer#storeShortField(int, short) + */ + public void storeShortField(int fieldNumber, short value) { + this.shortField = value; + } - /* - * @see PersistenceCapable.ObjectIdFieldConsumer#storeFloatField(int, float) - */ - public void storeFloatField(int fieldNumber, float value) { - this.floatField = value; - } + /* + * @see PersistenceCapable.ObjectIdFieldConsumer#storeIntField(int, int) + */ + public void storeIntField(int fieldNumber, int value) { + this.intField = value; + } - /* - * @see PersistenceCapable.ObjectIdFieldConsumer#storeDoubleField(int, double) - */ - public void storeDoubleField(int fieldNumber, double value) { - this.doubleField = value; - } + /* + * @see PersistenceCapable.ObjectIdFieldConsumer#storeLongField(int, long) + */ + public void storeLongField(int fieldNumber, long value) { + this.longField = value; + } - /* - * @see PersistenceCapable.ObjectIdFieldConsumer#storeStringField(int, java.lang.String) - */ - public void storeStringField(int fieldNumber, String value) { - this.stringField = value; - } + /* + * @see PersistenceCapable.ObjectIdFieldConsumer#storeFloatField(int, float) + */ + public void storeFloatField(int fieldNumber, float value) { + this.floatField = value; + } - /* - * @see PersistenceCapable.ObjectIdFieldConsumer#storeObjectField(int, java.lang.Object) - */ - public void storeObjectField(int fieldNumber, Object value) { - if (value instanceof Boolean) this.booleanField = ((Boolean) value).booleanValue(); - else if (value instanceof Boolean) this.booleanField = ((Boolean) value).booleanValue(); - else if (value instanceof Byte) this.byteField = ((Byte) value).byteValue(); - else if (value instanceof Character) this.charField = ((Character) value).charValue(); - else if (value instanceof Double) this.doubleField = ((Double) value).doubleValue(); - else if (value instanceof Float) this.floatField = ((Float) value).floatValue(); - else if (value instanceof Integer) this.intField = ((Integer) value).intValue(); - else if (value instanceof Long) this.longField = ((Long) value).longValue(); - else if (value instanceof Short) this.shortField = ((Short) value).shortValue(); - else if (value instanceof String) this.stringField = (String) value; - else this.objectField = value; - } + /* + * @see PersistenceCapable.ObjectIdFieldConsumer#storeDoubleField(int, double) + */ + public void storeDoubleField(int fieldNumber, double value) { + this.doubleField = value; + } + + /* + * @see PersistenceCapable.ObjectIdFieldConsumer#storeStringField(int, java.lang.String) + */ + public void storeStringField(int fieldNumber, String value) { + this.stringField = value; + } - public boolean equals(SingleFieldIdentity sfi) { - if (sfi == null) throw new IllegalArgumentException("Argument sfi must not be null"); - boolean result = false; - if (sfi instanceof ByteIdentity) result = ((ByteIdentity) sfi).getKey() == this.byteField; - else if (sfi instanceof CharIdentity) - result = ((CharIdentity) sfi).getKey() == this.charField; - else if (sfi instanceof IntIdentity) result = ((IntIdentity) sfi).getKey() == this.intField; - else if (sfi instanceof LongIdentity) - result = ((LongIdentity) sfi).getKey() == this.longField; - else if (sfi instanceof ShortIdentity) - result = ((ShortIdentity) sfi).getKey() == this.shortField; - else if (sfi instanceof StringIdentity) - result = ((StringIdentity) sfi).getKey().equals(this.stringField); - else result = ((ObjectIdentity) sfi).getKey().equals(this.objectField); - return result; + /* + * @see PersistenceCapable.ObjectIdFieldConsumer#storeObjectField(int, java.lang.Object) + */ + public void storeObjectField(int fieldNumber, Object value) { + if (value instanceof Boolean) + this.booleanField = ((Boolean)value).booleanValue(); + else if (value instanceof Boolean) + this.booleanField = ((Boolean)value).booleanValue(); + else if (value instanceof Byte) + this.byteField = ((Byte)value).byteValue(); + else if (value instanceof Character) + this.charField = ((Character)value).charValue(); + else if (value instanceof Double) + this.doubleField = ((Double)value).doubleValue(); + else if (value instanceof Float) + this.floatField = ((Float)value).floatValue(); + else if (value instanceof Integer) + this.intField = ((Integer)value).intValue(); + else if (value instanceof Long) + this.longField = ((Long)value).longValue(); + else if (value instanceof Short) + this.shortField = ((Short)value).shortValue(); + else if (value instanceof String) + this.stringField = (String)value; + else + this.objectField = value; + } + + public boolean equals(SingleFieldIdentity sfi) { + if (sfi==null) + throw new IllegalArgumentException ("Argument sfi must not be null"); + boolean result = false; + if (sfi instanceof ByteIdentity) + result = ((ByteIdentity)sfi).getKey()==this.byteField; + else if (sfi instanceof CharIdentity) + result = ((CharIdentity)sfi).getKey()==this.charField; + else if (sfi instanceof IntIdentity) + result = ((IntIdentity)sfi).getKey()==this.intField; + else if (sfi instanceof LongIdentity) + result = ((LongIdentity)sfi).getKey()==this.longField; + else if (sfi instanceof ShortIdentity) + result = ((ShortIdentity)sfi).getKey()==this.shortField; + else if (sfi instanceof StringIdentity) + result = ((StringIdentity)sfi).getKey().equals(this.stringField); + else + result = ((ObjectIdentity)sfi).getKey().equals(this.objectField); + return result; + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencecapable/NewObjectIdInstance.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencecapable/NewObjectIdInstance.java index 452337dde..0334d852d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencecapable/NewObjectIdInstance.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencecapable/NewObjectIdInstance.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,6 +20,7 @@ import javax.jdo.JDONullIdentityException; import javax.jdo.identity.SingleFieldIdentity; import javax.jdo.spi.PersistenceCapable; + import org.apache.jdo.tck.pc.singlefieldidentity.AbstractPCPointSingleField; import org.apache.jdo.tck.pc.singlefieldidentity.PCPointSingleFieldByte; import org.apache.jdo.tck.pc.singlefieldidentity.PCPointSingleFieldCharacter; @@ -36,197 +37,202 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:NewObjectIdInstance of PersistenceCapable
    - * Keywords: persistencecapable
    - * Assertion IDs: A7.12-38, A7.12-39
    - * Assertion Description: - * - *

    A7.12-38:
    - * For classes using single field identity method PersistenceCapable.newObjectIdInstance() - * must be called on a persistent instance with its primary key field initialized, or a - * JDONullIdentityException is thrown. - * - *

    A7.12-39:
    - * The instance returned is initialized with the value of the primary key field of the instance on - * which the method is called. - * + *Title:NewObjectIdInstance of PersistenceCapable + *
    + *Keywords: persistencecapable + *
    + *Assertion IDs: A7.12-38, A7.12-39 + *
    + *Assertion Description: + *

    + * A7.12-38:
    + * For classes using single field identity method + * PersistenceCapable.newObjectIdInstance() must be called + * on a persistent instance with its primary key field initialized, + * or a JDONullIdentityException is thrown.

    + * + * A7.12-39:
    + * The instance returned is initialized with the value of the primary key + * field of the instance on which the method is called. + * * @author Michael Watzek */ public class NewObjectIdInstance extends AbstractPersistenceCapableTest { - /** */ - private static final String FAILED = " (jdoNewObjectIdInstance) failed: "; - - /** */ - private static final String ASSERTION_A7_12_38_FAILED = "Assertion A7.12-38" + FAILED; - - /** */ - private static final String ASSERTION_A7_12_39_FAILED = "Assertion A7.12-39" + FAILED; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NewObjectIdInstance.class); - } - - public void testSingleFieldIdentityNotInitializedByte() { - if (isTestToBePerformed()) { - singleFieldIdentityNotInitialized(new PCPointSingleFieldByte()); - } - } - - public void testSingleFieldIdentityNotInitializedCharacter() { - if (isTestToBePerformed()) { - singleFieldIdentityNotInitialized(new PCPointSingleFieldCharacter()); - } - } - - public void testSingleFieldIdentityNotInitializedInteger() { - if (isTestToBePerformed()) { - singleFieldIdentityNotInitialized(new PCPointSingleFieldInteger()); - } - } - - public void testSingleFieldIdentityNotInitializedLong() { - if (isTestToBePerformed()) { - singleFieldIdentityNotInitialized(new PCPointSingleFieldLong()); + /** */ + private static final String FAILED = + " (jdoNewObjectIdInstance) failed: "; + + /** */ + private static final String ASSERTION_A7_12_38_FAILED = + "Assertion A7.12-38" + FAILED; + + /** */ + private static final String ASSERTION_A7_12_39_FAILED = + "Assertion A7.12-39" + FAILED; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NewObjectIdInstance.class); + } + + public void testSingleFieldIdentityNotInitializedByte() { + if (isTestToBePerformed()) { + singleFieldIdentityNotInitialized(new PCPointSingleFieldByte()); + } + } + + public void testSingleFieldIdentityNotInitializedCharacter() { + if (isTestToBePerformed()) { + singleFieldIdentityNotInitialized(new PCPointSingleFieldCharacter()); + } + } + + public void testSingleFieldIdentityNotInitializedInteger() { + if (isTestToBePerformed()) { + singleFieldIdentityNotInitialized(new PCPointSingleFieldInteger()); + } + } + + public void testSingleFieldIdentityNotInitializedLong() { + if (isTestToBePerformed()) { + singleFieldIdentityNotInitialized(new PCPointSingleFieldLong()); + } + } + + public void testSingleFieldIdentityNotInitializedShort() { + if (isTestToBePerformed()) { + singleFieldIdentityNotInitialized(new PCPointSingleFieldShort()); + } + } + + public void testSingleFieldIdentityNotInitializedString() { + if (isTestToBePerformed()) { + singleFieldIdentityNotInitialized(new PCPointSingleFieldString()); + } + } + + public void testSingleFieldIdentityNotInitializedDate() { + if (isTestToBePerformed()) { + singleFieldIdentityNotInitialized(new PCPointSingleFieldDate()); + } + } + + public void testSingleFieldIdentityInitializedbyte() { + if (isTestToBePerformed()) { + singleFieldIdentityInitialized(new PCPointSingleFieldPrimitivebyte(1, 2)); + } + } + + public void testSingleFieldIdentityInitializedByte() { + if (isTestToBePerformed()) { + singleFieldIdentityInitialized(new PCPointSingleFieldByte(1, 2)); + } + } + + public void testSingleFieldIdentityInitializedchar() { + if (isTestToBePerformed()) { + singleFieldIdentityInitialized(new PCPointSingleFieldPrimitivechar(1, 2)); + } + } + + public void testSingleFieldIdentityInitializedCharacter() { + if (isTestToBePerformed()) { + singleFieldIdentityInitialized(new PCPointSingleFieldCharacter(1, 2)); + } + } + + public void testSingleFieldIdentityInitializedint() { + if (isTestToBePerformed()) { + singleFieldIdentityInitialized(new PCPointSingleFieldPrimitiveint(1, 2)); + } + } + + public void testSingleFieldIdentityInitializedInteger() { + if (isTestToBePerformed()) { + singleFieldIdentityInitialized(new PCPointSingleFieldInteger(1, 2)); + } + } + + public void testSingleFieldIdentityInitializedlong() { + if (isTestToBePerformed()) { + singleFieldIdentityInitialized(new PCPointSingleFieldPrimitivelong(1, 2)); + } + } + + public void testSingleFieldIdentityInitializedLong() { + if (isTestToBePerformed()) { + singleFieldIdentityInitialized(new PCPointSingleFieldLong(1, 2)); + } + } + + public void testSingleFieldIdentityInitializedshort() { + if (isTestToBePerformed()) { + singleFieldIdentityInitialized(new PCPointSingleFieldPrimitiveshort(1, 2)); + } + } + + public void testSingleFieldIdentityInitializedShort() { + if (isTestToBePerformed()) { + singleFieldIdentityInitialized(new PCPointSingleFieldShort(1, 2)); + } + } + + public void testSingleFieldIdentityInitializedString() { + if (isTestToBePerformed()) { + singleFieldIdentityInitialized(new PCPointSingleFieldString(1, 2)); + } + } + + public void testSingleFieldIdentityInitializedDate() { + if (isTestToBePerformed()) { + singleFieldIdentityInitialized(new PCPointSingleFieldDate(1, 2)); + } + } + + /** + * The common method for test cases checking for assertion A7.12-38:
    + * For classes using single field identity method + * PersistenceCapable.newObjectIdInstance() must be called + * on a persistent instance with its primary key field initialized, + * @param o the object to check + */ + private void singleFieldIdentityNotInitialized(AbstractPCPointSingleField o) { + assertPersistenceCapable(o); + PersistenceCapable pc = (PersistenceCapable) o; + try { + Object sfi = pc.jdoNewObjectIdInstance(); + String message = ASSERTION_A7_12_38_FAILED + + "pc.jdoNewObjectIdInstance should throw " + + "JDONullIdentityException if PK field is null, but it returned "+sfi; + fail(message); + } catch (JDONullIdentityException e) { + // expected exception + if (debug) + logger.debug("caught expected exception " + e.toString()); + } + } + + /** + * The common method for test cases checking for assertion A7.12-39:
    + * The instance returned is initialized with the value of the primary key + * field of the instance on which the method is called. + * @param o the persistent instance to check + */ + private void singleFieldIdentityInitialized(AbstractPCPointSingleField o) { + assertPersistenceCapable(o); + makePersistent(o); + PersistenceCapable pc = (PersistenceCapable) o; + SingleFieldIdentity sfi = + (SingleFieldIdentity) pc.jdoNewObjectIdInstance(); + if (!o.equalsPKField(sfi)) { + fail(ASSERTION_A7_12_39_FAILED + + "pc.jdoNewObjectIdInstance() returned unexpected " + + "single field identity object id."); + } } - } - - public void testSingleFieldIdentityNotInitializedShort() { - if (isTestToBePerformed()) { - singleFieldIdentityNotInitialized(new PCPointSingleFieldShort()); - } - } - - public void testSingleFieldIdentityNotInitializedString() { - if (isTestToBePerformed()) { - singleFieldIdentityNotInitialized(new PCPointSingleFieldString()); - } - } - - public void testSingleFieldIdentityNotInitializedDate() { - if (isTestToBePerformed()) { - singleFieldIdentityNotInitialized(new PCPointSingleFieldDate()); - } - } - - public void testSingleFieldIdentityInitializedbyte() { - if (isTestToBePerformed()) { - singleFieldIdentityInitialized(new PCPointSingleFieldPrimitivebyte(1, 2)); - } - } - - public void testSingleFieldIdentityInitializedByte() { - if (isTestToBePerformed()) { - singleFieldIdentityInitialized(new PCPointSingleFieldByte(1, 2)); - } - } - - public void testSingleFieldIdentityInitializedchar() { - if (isTestToBePerformed()) { - singleFieldIdentityInitialized(new PCPointSingleFieldPrimitivechar(1, 2)); - } - } - - public void testSingleFieldIdentityInitializedCharacter() { - if (isTestToBePerformed()) { - singleFieldIdentityInitialized(new PCPointSingleFieldCharacter(1, 2)); - } - } - - public void testSingleFieldIdentityInitializedint() { - if (isTestToBePerformed()) { - singleFieldIdentityInitialized(new PCPointSingleFieldPrimitiveint(1, 2)); - } - } - - public void testSingleFieldIdentityInitializedInteger() { - if (isTestToBePerformed()) { - singleFieldIdentityInitialized(new PCPointSingleFieldInteger(1, 2)); - } - } - - public void testSingleFieldIdentityInitializedlong() { - if (isTestToBePerformed()) { - singleFieldIdentityInitialized(new PCPointSingleFieldPrimitivelong(1, 2)); - } - } - - public void testSingleFieldIdentityInitializedLong() { - if (isTestToBePerformed()) { - singleFieldIdentityInitialized(new PCPointSingleFieldLong(1, 2)); - } - } - - public void testSingleFieldIdentityInitializedshort() { - if (isTestToBePerformed()) { - singleFieldIdentityInitialized(new PCPointSingleFieldPrimitiveshort(1, 2)); - } - } - - public void testSingleFieldIdentityInitializedShort() { - if (isTestToBePerformed()) { - singleFieldIdentityInitialized(new PCPointSingleFieldShort(1, 2)); - } - } - - public void testSingleFieldIdentityInitializedString() { - if (isTestToBePerformed()) { - singleFieldIdentityInitialized(new PCPointSingleFieldString(1, 2)); - } - } - - public void testSingleFieldIdentityInitializedDate() { - if (isTestToBePerformed()) { - singleFieldIdentityInitialized(new PCPointSingleFieldDate(1, 2)); - } - } - - /** - * The common method for test cases checking for assertion A7.12-38:
    - * For classes using single field identity method PersistenceCapable.newObjectIdInstance() - * must be called on a persistent instance with its primary key field initialized, - * - * @param o the object to check - */ - private void singleFieldIdentityNotInitialized(AbstractPCPointSingleField o) { - assertPersistenceCapable(o); - PersistenceCapable pc = (PersistenceCapable) o; - try { - Object sfi = pc.jdoNewObjectIdInstance(); - String message = - ASSERTION_A7_12_38_FAILED - + "pc.jdoNewObjectIdInstance should throw " - + "JDONullIdentityException if PK field is null, but it returned " - + sfi; - fail(message); - } catch (JDONullIdentityException e) { - // expected exception - if (debug) logger.debug("caught expected exception " + e.toString()); - } - } - - /** - * The common method for test cases checking for assertion A7.12-39:
    - * The instance returned is initialized with the value of the primary key field of the instance on - * which the method is called. - * - * @param o the persistent instance to check - */ - private void singleFieldIdentityInitialized(AbstractPCPointSingleField o) { - assertPersistenceCapable(o); - makePersistent(o); - PersistenceCapable pc = (PersistenceCapable) o; - SingleFieldIdentity sfi = (SingleFieldIdentity) pc.jdoNewObjectIdInstance(); - if (!o.equalsPKField(sfi)) { - fail( - ASSERTION_A7_12_39_FAILED - + "pc.jdoNewObjectIdInstance() returned unexpected " - + "single field identity object id."); - } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/ChangingObjectIdHasNoEffectOnInstance.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/ChangingObjectIdHasNoEffectOnInstance.java index e20a21ae8..2ef71fc3f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/ChangingObjectIdHasNoEffectOnInstance.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/ChangingObjectIdHasNoEffectOnInstance.java @@ -5,60 +5,66 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Changing ObjectId Has No Effect On Instance
    - * Keywords: identity
    - * Assertion ID: A12.5.6-13.
    - * Assertion Description: If the application makes a change to the ObjectId - * instance returned by PersistenceManager.getObjectId, there is no effect on the - * instance from which the ObjectId was obtained. - */ -public class ChangingObjectIdHasNoEffectOnInstance extends PersistenceManagerTest { + *Title: Changing ObjectId Has No Effect On Instance + *
    + *Keywords: identity + *
    + *Assertion ID: A12.5.6-13. + *
    + *Assertion Description: +If the application makes a change to the ObjectId instance +returned by PersistenceManager.getObjectId, there is no effect +on the instance from which the ObjectId was obtained. - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.6-13 (ChangingObjectIdHasNoEffectOnInstance) failed: "; + */ - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ChangingObjectIdHasNoEffectOnInstance.class); - } +public class ChangingObjectIdHasNoEffectOnInstance extends PersistenceManagerTest { - /** - * @throws Exception exception - */ - public void testChangingObjectIdHasNoEffectOnInstance() throws Exception { - pm = getPM(); - Object oid = createPCPointInstance(pm); - Object p1 = pm.getObjectById(oid, false); - Object oid2 = pm.getObjectId(p1); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.6-13 (ChangingObjectIdHasNoEffectOnInstance) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ChangingObjectIdHasNoEffectOnInstance.class); + } - mangleObject(oid); - // now oid3 should equal oid2 even though we mangled oid - Object oid3 = getPM().getObjectId(p1); - if (!oid2.equals(oid3)) - fail( - ASSERTION_FAILED, - "Changing the ObjectId returned by getObjectId has an effect on ObjectId's returned by subsequent calls of getObjectId"); - pm.close(); - pm = null; - } + /** + * @throws Exception exception + */ + public void testChangingObjectIdHasNoEffectOnInstance() throws Exception { + pm = getPM(); + Object oid = createPCPointInstance(pm); + Object p1 = pm.getObjectById(oid, false); + Object oid2 = pm.getObjectId(p1); + + mangleObject(oid); + // now oid3 should equal oid2 even though we mangled oid + Object oid3 = getPM().getObjectId(p1); + if (!oid2.equals(oid3)) + fail(ASSERTION_FAILED, + "Changing the ObjectId returned by getObjectId has an effect on ObjectId's returned by subsequent calls of getObjectId"); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/ConcurrentPersistenceManagers.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/ConcurrentPersistenceManagers.java index 4301356e2..0d277da68 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/ConcurrentPersistenceManagers.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/ConcurrentPersistenceManagers.java @@ -5,78 +5,89 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import java.util.Properties; + import javax.jdo.JDOHelper; import javax.jdo.PersistenceManager; import javax.jdo.PersistenceManagerFactory; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Concurrent Persistence Managers
    - * Keywords: concurrency multipleJDOimpls
    - * Assertion ID: A5.2-1.
    - * Assertion Description: An implementation should support its own PersistenceManager - * concurrently with another PersistenceManager. A non-reference implementation - * will be tested concurrently with the Reference Implementation. + *Title: Concurrent Persistence Managers + *
    + *Keywords: concurrency multipleJDOimpls + *
    + *Assertion ID: A5.2-1. + *
    + *Assertion Description: +An implementation should support its own PersistenceManager +concurrently with another PersistenceManager. +A non-reference implementation will be tested concurrently +with the Reference Implementation. + */ -public class ConcurrentPersistenceManagers extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A5.2-1 (ConcurrentPersistenceManagers) failed: "; +public class ConcurrentPersistenceManagers extends JDO_Test { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ConcurrentPersistenceManagers.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A5.2-1 (ConcurrentPersistenceManagers) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ConcurrentPersistenceManagers.class); + } - /** */ - public void test() { - Properties pmfProperties = loadPMF2Properties(); - PersistenceManagerFactory pmf2 = JDOHelper.getPersistenceManagerFactory(pmfProperties); - PersistenceManager pm2 = pmf2.getPersistenceManager(); - Transaction tx2 = pm2.currentTransaction(); - pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - tx2.begin(); - tx.commit(); - tx = null; - tx2.commit(); - tx2 = null; - } finally { - cleanupPM(pm); - pm = null; - cleanupPM(pm2); - pm2 = null; - closePMF(pmf2); + /** */ + public void test() { + Properties pmfProperties = loadPMF2Properties(); + PersistenceManagerFactory pmf2 = JDOHelper.getPersistenceManagerFactory(pmfProperties); + PersistenceManager pm2 = pmf2.getPersistenceManager(); + Transaction tx2 = pm2.currentTransaction(); + pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + tx2.begin(); + tx.commit(); + tx = null; + tx2.commit(); + tx2 = null; + } + finally { + cleanupPM(pm); + pm = null; + cleanupPM(pm2); + pm2 = null; + closePMF(pmf2); + } } - } - private Properties loadPMF2Properties() { - String PMF2 = System.getProperty("PMF2Properties", "jdori2.properties"); - if (debug) logger.debug("Got PMF2Properties file name:" + PMF2); - Properties ret = loadProperties(PMF2); - if (debug) logger.debug("Got PMF2Properties: " + ret); - return ret; - } + private Properties loadPMF2Properties() { + String PMF2 = System.getProperty ("PMF2Properties", "jdori2.properties"); + if (debug) logger.debug("Got PMF2Properties file name:" + PMF2); + Properties ret = loadProperties (PMF2); + if (debug) logger.debug("Got PMF2Properties: " + ret); + return ret; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/ConcurrentPersistenceManagersSameClasses.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/ConcurrentPersistenceManagersSameClasses.java index 677331f5f..fd8713483 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/ConcurrentPersistenceManagersSameClasses.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/ConcurrentPersistenceManagersSameClasses.java @@ -5,152 +5,154 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import java.util.Collection; import java.util.Iterator; import java.util.Properties; + import javax.jdo.JDOHelper; import javax.jdo.PersistenceManager; import javax.jdo.PersistenceManagerFactory; import javax.jdo.Query; import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.pc.mylib.PCRect; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Same Classes with Concurrent Persistence Managers
    - * Keywords: concurrency multipleJDOimpls
    - * Assertion ID: A5.2-2.
    - * Assertion Description: The same classes must be supported concurrently by multiple - * PersistenceManagers from different implementations. - */ -public class ConcurrentPersistenceManagersSameClasses extends PersistenceManagerTest { + *Title: Same Classes with Concurrent Persistence Managers + *
    + *Keywords: concurrency multipleJDOimpls + *
    + *Assertion ID: A5.2-2. + *
    + *Assertion Description: +The same classes must be supported concurrently by multiple +PersistenceManagers from different implementations. - /** */ - private static final String ASSERTION_FAILED = - "Assertion A5.2-2 (ConcurrentPersistenceManagersSameClasses) failed: "; + */ - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ConcurrentPersistenceManagersSameClasses.class); - } +public class ConcurrentPersistenceManagersSameClasses extends PersistenceManagerTest { - /** */ - public void test() { - if (!isBinaryCompatibilitySupported()) { - printUnsupportedOptionalFeatureNotTested( - "org.apache.jdo.tck.api.persistencemanager.ConcurrentPersistenceManagersSameClasses", - "javax.jdo.option.BinaryCompatibility"); - return; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A5.2-2 (ConcurrentPersistenceManagersSameClasses) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ConcurrentPersistenceManagersSameClasses.class); } - Properties pmfProperties = loadPMF2Properties(); - PersistenceManagerFactory pmf2 = JDOHelper.getPersistenceManagerFactory(pmfProperties); - PersistenceManager pm2 = pmf2.getPersistenceManager(); - Transaction tx2 = pm2.currentTransaction(); - PCPoint p21 = null; - PCPoint p22 = null; - PCRect rect2 = null; - - pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - tx2.begin(); - - PCPoint p11 = new PCPoint(110, 120); - PCPoint p12 = new PCPoint(120, 140); - PCRect rect1 = new PCRect(0, p11, p12); - pm.makePersistent(rect1); - - p21 = new PCPoint(210, 220); - p22 = new PCPoint(220, 240); - rect2 = new PCRect(0, p21, p22); - pm2.makePersistent(rect2); - - tx.commit(); - tx2.commit(); - - tx.begin(); - tx2.begin(); - - PCPoint p11a = findPoint(pm, 110, 120); - if (p11a != p11) { - fail( - ASSERTION_FAILED, - "unexpected PCPoint instance, expected: 110, 120, found: " - + p11a.getX() - + ", " - + p11a.getY()); - } - - PCPoint p21a = findPoint(pm2, 210, 220); - if (p21a != p21) { - fail( - ASSERTION_FAILED, - "unexpected PCPoint instance, expected: 210, 220, found: " - + p21a.getX() - + ", " - + p21a.getY()); - } - - tx.commit(); - tx = null; - tx2.commit(); - tx2 = null; - } finally { - cleanupPM(pm); - pm = null; - try { - // delete pm2 instances - if (pm2.currentTransaction().isActive()) { - pm2.currentTransaction().rollback(); + + /** */ + public void test() { + if (!isBinaryCompatibilitySupported()) { + printUnsupportedOptionalFeatureNotTested( + "org.apache.jdo.tck.api.persistencemanager.ConcurrentPersistenceManagersSameClasses", + "javax.jdo.option.BinaryCompatibility"); + return; + } + Properties pmfProperties = loadPMF2Properties(); + PersistenceManagerFactory pmf2 = JDOHelper.getPersistenceManagerFactory(pmfProperties); + PersistenceManager pm2 = pmf2.getPersistenceManager(); + Transaction tx2 = pm2.currentTransaction(); + PCPoint p21 = null; + PCPoint p22 = null; + PCRect rect2 = null; + + pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + tx2.begin(); + + PCPoint p11 = new PCPoint(110, 120); + PCPoint p12 = new PCPoint(120, 140); + PCRect rect1 = new PCRect (0, p11, p12); + pm.makePersistent (rect1); + + p21 = new PCPoint(210, 220); + p22 = new PCPoint(220, 240); + rect2 = new PCRect (0, p21, p22); + pm2.makePersistent (rect2); + + tx.commit(); + tx2.commit(); + + tx.begin(); + tx2.begin(); + + PCPoint p11a = findPoint (pm, 110, 120); + if (p11a != p11) { + fail(ASSERTION_FAILED, + "unexpected PCPoint instance, expected: 110, 120, found: " + p11a.getX() + ", " + p11a.getY()); + } + + PCPoint p21a = findPoint (pm2, 210, 220); + if (p21a != p21) { + fail(ASSERTION_FAILED, + "unexpected PCPoint instance, expected: 210, 220, found: " + p21a.getX() + ", " + p21a.getY()); + } + + tx.commit(); + tx = null; + tx2.commit(); + tx2 = null; + } + finally { + cleanupPM(pm); + pm = null; + try { + // delete pm2 instances + if (pm2.currentTransaction().isActive()) { + pm2.currentTransaction().rollback(); + } + pm2.currentTransaction().begin(); + pm2.deletePersistent(rect2); + pm2.deletePersistent(p21); + pm2.deletePersistent(p22); + pm2.currentTransaction().commit(); + } finally { + cleanupPM(pm2); + pm2 = null; + closePMF(pmf2); + } } - pm2.currentTransaction().begin(); - pm2.deletePersistent(rect2); - pm2.deletePersistent(p21); - pm2.deletePersistent(p22); - pm2.currentTransaction().commit(); - } finally { - cleanupPM(pm2); - pm2 = null; - closePMF(pmf2); - } } - } - /** */ - private Properties loadPMF2Properties() { - String PMF2 = System.getProperty("PMF2Properties", "jdori2.properties"); - if (debug) logger.debug("Got PMF2Properties file name:" + PMF2); - Properties ret = loadProperties(PMF2); - if (debug) logger.debug("Got PMF2Properties: " + ret); - return ret; - } + /** */ + private Properties loadPMF2Properties() { + String PMF2 = System.getProperty ("PMF2Properties", "jdori2.properties"); + if (debug) logger.debug("Got PMF2Properties file name:" + PMF2); + Properties ret = loadProperties (PMF2); + if (debug) logger.debug("Got PMF2Properties: " + ret); + return ret; + } - /** */ - private PCPoint findPoint(PersistenceManager pm, int x, int y) { - Query q = pm.newQuery(PCPoint.class); - q.declareParameters("int px, int py"); - q.setFilter("x == px & y == py"); - Collection results = (Collection) q.execute(Integer.valueOf(x), Integer.valueOf(y)); - Iterator it = results.iterator(); - PCPoint ret = (PCPoint) it.next(); - return ret; - } + /** */ + private PCPoint findPoint (PersistenceManager pm, int x, int y) { + Query q = pm.newQuery (PCPoint.class); + q.declareParameters ("int px, int py"); + q.setFilter ("x == px & y == py"); + Collection results = (Collection)q.execute (Integer.valueOf(x), Integer.valueOf(y)); + Iterator it = results.iterator(); + PCPoint ret = (PCPoint)it.next(); + return ret; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/CurrentTransaction.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/CurrentTransaction.java index 141ecb4b3..27ae998b0 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/CurrentTransaction.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/CurrentTransaction.java @@ -5,53 +5,60 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: CurrentTransaction
    - * Keywords:
    - * Assertion ID: A12.5.2-1
    - * Assertion Description: The PersistenceManager.currentTransaction method returns the - * Transaction instance associated with the PersistenceManager. - */ -public class CurrentTransaction extends PersistenceManagerTest { + *Title: CurrentTransaction + *
    + *Keywords: + *
    + *Assertion ID: A12.5.2-1 + *
    + *Assertion Description: +The PersistenceManager.currentTransaction method returns the +Transaction instance associated with the PersistenceManager. - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.2-1 (CurrentTransaction) failed: "; + */ - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CurrentTransaction.class); - } +public class CurrentTransaction extends PersistenceManagerTest { - /** */ - public void testCurrentTransaction() { - pm = getPM(); - PCPoint p1 = new PCPoint(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - pm.makePersistent(p1); - tx.commit(); - pm.close(); - pm = null; - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.2-1 (CurrentTransaction) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CurrentTransaction.class); + } + + /** */ + public void testCurrentTransaction() { + pm = getPM(); + PCPoint p1 = new PCPoint(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + pm.makePersistent(p1); + tx.commit(); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DataStoreCacheTest.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DataStoreCacheTest.java index 48e408689..70c766801 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DataStoreCacheTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DataStoreCacheTest.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,72 +19,86 @@ import java.util.Collection; import java.util.HashSet; + import javax.jdo.datastore.DataStoreCache; + import org.apache.jdo.tck.pc.mylib.PCPoint; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: DataStoreCacheTest
    - * Keywords: DataStoreCache cache pin unpin evict
    - * Assertion ID: A11.8
    - * Assertion Description: Most JDO implementations allow instances to be cached in a - * second-level cache, and allow direct management of the cache by knowledgeable applications. The - * second-level cache is typically a single VM cache and is used for persistent instances associated - * with a single PersistenceManagerFactory. For the purpose of standardizing this behavior, the - * DataStoreCache interface is used. + * Title: DataStoreCacheTest + *
    + * Keywords: DataStoreCache cache pin unpin evict + *
    + * Assertion ID: A11.8 + *
    + * Assertion Description: +Most JDO implementations allow instances +to be cached in a second-level cache, and allow +direct management of the cache by knowledgeable +applications. The second-level cache is +typically a single VM cache and is used for +persistent instances associated with a single +PersistenceManagerFactory. For the purpose +of standardizing this behavior, the +DataStoreCache interface is used. */ -public class DataStoreCacheTest extends PersistenceManagerTest { - Object pointoid; - Collection pointoidCollection; - Object[] pointoidArray; - - /** */ - private static final String ASSERTION_FAILED = "Assertion A11.8 (DataStoreCacheTest) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DataStoreCacheTest.class); - } +public class DataStoreCacheTest extends PersistenceManagerTest { - /** - * In setup, create a persistent instance and get its oid. The oid is a valid parameter to the - * cache APIs. - */ - protected void localSetUp() { - addTearDownClass(PCPoint.class); - PCPoint point = new PCPoint(50, 100); - getPM().currentTransaction().begin(); - pm.makePersistent(point); - pointoid = pm.getObjectId(point); - pointoidCollection = new HashSet(); - pointoidCollection.add(pointoid); - pointoidArray = new Object[] {pointoid}; - pm.currentTransaction().commit(); - } + Object pointoid; + Collection pointoidCollection; + Object[] pointoidArray; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.8 (DataStoreCacheTest) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DataStoreCacheTest.class); + } + + /** + * In setup, create a persistent instance and get its oid. + * The oid is a valid parameter to the cache APIs. + */ + protected void localSetUp() { + addTearDownClass(PCPoint.class); + PCPoint point = new PCPoint(50, 100); + getPM().currentTransaction().begin(); + pm.makePersistent(point); + pointoid = pm.getObjectId(point); + pointoidCollection = new HashSet(); + pointoidCollection.add(pointoid); + pointoidArray = new Object[] {pointoid}; + pm.currentTransaction().commit(); + } - /** - * There is no mandated behavior of the DataStoreCache methods. This test makes sure that the - * instance returned does not throw exceptions on any method. - */ - public void testDataStoreCache() { - DataStoreCache ds = getPMF().getDataStoreCache(); - ds.evict(pointoid); - ds.evictAll(); - ds.evictAll(pointoidCollection); - ds.evictAll(pointoidArray); - ds.evictAll(PCPoint.class, true); - ds.pin(pointoid); - ds.unpin(pointoid); - ds.pinAll(pointoidCollection); - ds.unpinAll(pointoidCollection); - ds.pinAll(pointoidArray); - ds.unpinAll(pointoidArray); - ds.pinAll(PCPoint.class, true); - ds.unpinAll(PCPoint.class, true); - } + /** + * There is no mandated behavior of the DataStoreCache + * methods. This test makes sure that the instance + * returned does not throw exceptions on any method. + */ + public void testDataStoreCache() { + DataStoreCache ds = getPMF().getDataStoreCache(); + ds.evict(pointoid); + ds.evictAll(); + ds.evictAll(pointoidCollection); + ds.evictAll(pointoidArray); + ds.evictAll(PCPoint.class, true); + ds.pin(pointoid); + ds.unpin(pointoid); + ds.pinAll(pointoidCollection); + ds.unpinAll(pointoidCollection); + ds.pinAll(pointoidArray); + ds.unpinAll(pointoidArray); + ds.pinAll(PCPoint.class, true); + ds.unpinAll(PCPoint.class, true); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DataStoreConnection.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DataStoreConnection.java index 270d07795..778af7812 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DataStoreConnection.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DataStoreConnection.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,118 +20,126 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; + import java.util.Collection; import java.util.HashSet; + import javax.jdo.datastore.JDOConnection; + import org.apache.jdo.tck.pc.mylib.PCPoint; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: DataStoreConnection
    - * Keywords:
    - * Assertion ID: A12.5.2-1
    - * Assertion Description: In order for the application to perform some datastore-specific - * functions, such as to execute a query that is not directly supported by JDO, applications might - * need access to the datastore connection used by the JDO implementation. This method returns a - * wrapped connection that can be cast to the appropriate datastore connection and used by the - * application. The capability to get the datastore connection is indicated by the optional feature - * string javax.jdo.option.GetDataStoreConnection. - */ -public class DataStoreConnection extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.2-1 (DataStoreConnection) failed: "; + *Title: DataStoreConnection + *
    + *Keywords: + *
    + *Assertion ID: A12.5.2-1 + *
    + *Assertion Description: +In order for the application to perform some +datastore-specific functions, such as to execute +a query that is not directly supported by JDO, +applications might need access to the +datastore connection used by the JDO implementation. +This method returns a wrapped +connection that can be cast to the appropriate +datastore connection and used by the application. +The capability to get the datastore connection is +indicated by the optional feature string +javax.jdo.option.GetDataStoreConnection. - protected PCPoint goldenPoint; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DataStoreConnection.class); - } + */ - /** */ - protected void localSetUp() { - addTearDownClass(PCPoint.class); - PCPoint point = new PCPoint(50, 100); - goldenPoint = new PCPoint(point.getX(), point.getY()); - getPM().currentTransaction().begin(); - pm.makePersistent(point); - pm.currentTransaction().commit(); - } +public class DataStoreConnection extends PersistenceManagerTest { - /** */ - public void testDataStoreConnection() { - if (!(isDataStoreConnectionSupported() && isSQLSupported())) { - printUnsupportedOptionalFeatureNotTested( - this.getClass().getName(), "getDataStoreConnection AND SQLSupported."); - return; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.2-1 (DataStoreConnection) failed: "; + + protected PCPoint goldenPoint; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DataStoreConnection.class); + } + + /** */ + protected void localSetUp() { + addTearDownClass(PCPoint.class); + PCPoint point = new PCPoint(50, 100); + goldenPoint = new PCPoint(point.getX(), point.getY()); + getPM().currentTransaction().begin(); + pm.makePersistent(point); + pm.currentTransaction().commit(); } - getPM().currentTransaction().setOptimistic(false); - executeSQLWithDataStoreConnection(); - if (!isOptimisticSupported()) { - printUnsupportedOptionalFeatureNotTested( - this.getClass().getName(), "getDataStoreConnection AND SQLSupported AND Optimistic."); - return; + + /** */ + public void testDataStoreConnection() { + if (!(isDataStoreConnectionSupported() && isSQLSupported())) { + printUnsupportedOptionalFeatureNotTested( + this.getClass().getName(), + "getDataStoreConnection AND SQLSupported."); + return; + } + getPM().currentTransaction().setOptimistic(false); + executeSQLWithDataStoreConnection(); + if (!isOptimisticSupported()) { + printUnsupportedOptionalFeatureNotTested( + this.getClass().getName(), + "getDataStoreConnection AND SQLSupported AND Optimistic."); + return; + } + getPM().currentTransaction().setOptimistic(true); + executeSQLWithDataStoreConnection(); } - getPM().currentTransaction().setOptimistic(true); - executeSQLWithDataStoreConnection(); - } - private void executeSQLWithDataStoreConnection() { - String schema = getPMFProperty("javax.jdo.mapping.Schema"); - String sql = "SELECT X, Y FROM " + schema + ".PCPoint"; - JDOConnection jconn = null; - try { - getPM().currentTransaction().begin(); - jconn = pm.getDataStoreConnection(); - Connection conn = (Connection) jconn; - if (conn.getAutoCommit()) { - appendMessage(ASSERTION_FAILED + "Autocommit must not be true in JDO connection."); - } - ; - PreparedStatement ps = conn.prepareStatement(sql); - ResultSet rs = ps.executeQuery(); - Collection actuals = new HashSet(); - while (rs.next()) { - PCPoint p = new PCPoint(rs.getInt(1), rs.getInt(2)); - actuals.add(p); - } - if (actuals.size() != 1) { - appendMessage( - ASSERTION_FAILED - + "Wrong size of result of " - + sql - + NL - + "expected: 1, actual: " - + actuals.size()); - } else { - PCPoint actual = (PCPoint) actuals.iterator().next(); - if (goldenPoint.getX() != actual.getX() || !goldenPoint.getY().equals(actual.getY())) { - appendMessage( - ASSERTION_FAILED - + "Wrong values of PCPoint from SQL" - + "expected x: " - + goldenPoint.getX() - + ", y: " - + goldenPoint.getX() - + NL - + "actual x: " - + actual.getX() - + ", y: " - + actual.getX()); + private void executeSQLWithDataStoreConnection() { + String schema = getPMFProperty("javax.jdo.mapping.Schema"); + String sql = "SELECT X, Y FROM " + schema + ".PCPoint"; + JDOConnection jconn = null; + try { + getPM().currentTransaction().begin(); + jconn = pm.getDataStoreConnection(); + Connection conn = (Connection)jconn; + if (conn.getAutoCommit()) { + appendMessage(ASSERTION_FAILED + + "Autocommit must not be true in JDO connection."); + }; + PreparedStatement ps = conn.prepareStatement(sql); + ResultSet rs = ps.executeQuery(); + Collection actuals = new HashSet(); + while (rs.next()) { + PCPoint p = new PCPoint(rs.getInt(1), rs.getInt(2)); + actuals.add(p); + } + if (actuals.size() != 1) { + appendMessage(ASSERTION_FAILED + "Wrong size of result of " + + sql + NL + "expected: 1, actual: " + actuals.size()); + } else { + PCPoint actual = (PCPoint)actuals.iterator().next(); + if (goldenPoint.getX() != actual.getX() || + !goldenPoint.getY().equals(actual.getY())) { + appendMessage(ASSERTION_FAILED + + "Wrong values of PCPoint from SQL" + + "expected x: " + goldenPoint.getX() + + ", y: " + goldenPoint.getX() + NL + + "actual x: " + actual.getX() + + ", y: " + actual.getX() + ); + } + } + } catch (Exception ex) { + appendMessage(ASSERTION_FAILED + " caught exception:" + ex); + } finally { + jconn.close(); + getPM().currentTransaction().commit(); + failOnError(); } - } - } catch (Exception ex) { - appendMessage(ASSERTION_FAILED + " caught exception:" + ex); - } finally { - jconn.close(); - getPM().currentTransaction().commit(); - failOnError(); } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DataStoreConnectionThrows.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DataStoreConnectionThrows.java index 8cb5cab8f..f5b453f92 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DataStoreConnectionThrows.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DataStoreConnectionThrows.java @@ -5,204 +5,190 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import java.sql.Connection; +import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; + +import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; + import javax.jdo.datastore.JDOConnection; + import org.apache.jdo.tck.pc.mylib.PCPoint; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: DataStoreConnectionThrows
    - * Keywords:
    - * Assertion ID: A12.16-2
    - * Assertion Description: For portability, a JDBC-based JDO implementation will return an - * instance that implements java.sql.Connection. The instance will throw an exception for any of the - * following method calls: commit, getMetaData, releaseSavepoint, rollback, setAutoCommit, - * setCatalog, setHoldability, setReadOnly, setSavepoint, setTransactionIsolation, and setTypeMap. + *Title: DataStoreConnectionThrows + *
    + *Keywords: + *
    + *Assertion ID: A12.16-2 + *
    + *Assertion Description: +For portability, a JDBC-based JDO implementation +will return an instance that implements +java.sql.Connection. The instance +will throw an exception for any of the +following method calls: commit, getMetaData, +releaseSavepoint, rollback, setAutoCommit, +setCatalog, setHoldability, setReadOnly, +setSavepoint, setTransactionIsolation, and +setTypeMap. */ -public class DataStoreConnectionThrows extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.16-2 (DataStoreConnectionThrows) failed: "; - protected PCPoint goldenPoint; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DataStoreConnectionThrows.class); - } +public class DataStoreConnectionThrows extends PersistenceManagerTest { - /** - * @param conn connection - * @param call call - */ - protected void checkThrow(Connection conn, Call call) { - try { - call.execute(conn); - appendMessage(ASSERTION_FAILED + "Failed to throw an exception for " + call.getName()); - } catch (SQLException ex) { - appendMessage(ASSERTION_FAILED + "Threw a SQLException for " + call.getName() + NL + ex); - return; - } catch (Exception ex) { - return; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.16-2 (DataStoreConnectionThrows) failed: "; + + protected PCPoint goldenPoint; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DataStoreConnectionThrows.class); } - } - - /** */ - interface Call { - String getName(); - void execute(Connection conn) throws SQLException; - } - - /** */ - public void testDataStoreConnectionThrows() { - if (!(isDataStoreConnectionSupported() && isSQLSupported())) { - printUnsupportedOptionalFeatureNotTested( - this.getClass().getName(), "getDataStoreConnection AND SQLSupported."); - return; - } - JDOConnection jconn = getPM().getDataStoreConnection(); - Connection conn = (Connection) jconn; - check13Methods(conn); - if (isJRE14orBetter()) { - check14Methods(conn); + /** + * + * @param conn connection + * @param call call + */ + protected void checkThrow(Connection conn, Call call) { + try { + call.execute(conn); + appendMessage(ASSERTION_FAILED + + "Failed to throw an exception for " + call.getName()); + } catch (SQLException ex) { + appendMessage(ASSERTION_FAILED + + "Threw a SQLException for " + call.getName() + NL + ex); + return; + } catch (Exception ex) { + return; + } } - jconn.close(); - failOnError(); - } - /** - * These methods are defined in Java 1.3 Connection. - * - * @param conn connection - */ - protected void check13Methods(Connection conn) { - checkThrow( - conn, - new Call() { - public String getName() { - return "commit"; - } - - public void execute(Connection conn) throws SQLException { - conn.commit(); - } - }); - checkThrow( - conn, - new Call() { - public String getName() { - return "rollback"; - } - - public void execute(Connection conn) throws SQLException { - conn.rollback(); - } - }); - checkThrow( - conn, - new Call() { - public String getName() { - return "setTransactionIsolation"; - } - - public void execute(Connection conn) throws SQLException { - conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); - } - }); - checkThrow( - conn, - new Call() { - public String getName() { - return "setAutoCommit"; - } - - public void execute(Connection conn) throws SQLException { - conn.setAutoCommit(true); - } - }); - checkThrow( - conn, - new Call() { - public String getName() { - return "setCatalog"; - } - - public void execute(Connection conn) throws SQLException { - conn.setCatalog("NONE"); - } - }); - } - - /** - * These methods are defined in Java 1.4 Connection. - * - * @param conn connection - */ - protected void check14Methods(Connection conn) { - checkThrow( - conn, - new Call() { - public String getName() { - return "setSavepoint"; - } - - public void execute(Connection conn) throws SQLException { - conn.setSavepoint(); - } - }); - checkThrow( - conn, - new Call() { - public String getName() { - return "releaseSavepoint"; - } + /** */ + interface Call { + String getName(); + void execute(Connection conn) throws SQLException; + } - public void execute(Connection conn) throws SQLException { - conn.releaseSavepoint(null); - } - }); - checkThrow( - conn, - new Call() { - public String getName() { - return "setHoldability"; - } + /** */ + public void testDataStoreConnectionThrows() { + if (!(isDataStoreConnectionSupported() && isSQLSupported())) { + printUnsupportedOptionalFeatureNotTested( + this.getClass().getName(), + "getDataStoreConnection AND SQLSupported."); + return; + } + JDOConnection jconn = getPM().getDataStoreConnection(); + Connection conn = (Connection)jconn; + check13Methods(conn); + if (isJRE14orBetter()) { + check14Methods(conn); + } + jconn.close(); + failOnError(); + } - public void execute(Connection conn) throws SQLException { - conn.setHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT); - } - }); - checkThrow( - conn, - new Call() { - public String getName() { - return "setTypeMap"; - } + /** + * These methods are defined in Java 1.3 Connection. + * @param conn connection + */ + protected void check13Methods(Connection conn) { + checkThrow(conn, + new Call() { + public String getName() {return "commit";} + public void execute(Connection conn) + throws SQLException {conn.commit();} + } + ); + checkThrow(conn, + new Call() { + public String getName() {return "rollback";} + public void execute(Connection conn) + throws SQLException {conn.rollback();} + } + ); + checkThrow(conn, + new Call() { + public String getName() {return "setTransactionIsolation";} + public void execute(Connection conn) + throws SQLException { + conn.setTransactionIsolation( + Connection.TRANSACTION_READ_COMMITTED);} + } + ); + checkThrow(conn, + new Call() { + public String getName() {return "setAutoCommit";} + public void execute(Connection conn) + throws SQLException {conn.setAutoCommit(true);} + } + ); + checkThrow(conn, + new Call() { + public String getName() {return "setCatalog";} + public void execute(Connection conn) + throws SQLException {conn.setCatalog("NONE");} + } + ); + } - public void execute(Connection conn) throws SQLException { - conn.setTypeMap(new HashMap()); - } - }); - } + /** + * These methods are defined in Java 1.4 Connection. + * @param conn connection + */ + protected void check14Methods(Connection conn) { + checkThrow(conn, + new Call() { + public String getName() {return "setSavepoint";} + public void execute(Connection conn) + throws SQLException {conn.setSavepoint();} + } + ); + checkThrow(conn, + new Call() { + public String getName() {return "releaseSavepoint";} + public void execute(Connection conn) + throws SQLException {conn.releaseSavepoint(null);} + } + ); + checkThrow(conn, + new Call() { + public String getName() {return "setHoldability";} + public void execute(Connection conn) + throws SQLException { + conn.setHoldability( + ResultSet.CLOSE_CURSORS_AT_COMMIT);} + } + ); + checkThrow(conn, + new Call() { + public String getName() {return "setTypeMap";} + public void execute(Connection conn) + throws SQLException {conn.setTypeMap(new HashMap());} + } + ); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DatastoreTimeout.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DatastoreTimeout.java index 5e847cd89..8c7f59373 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DatastoreTimeout.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DatastoreTimeout.java @@ -5,26 +5,29 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import java.util.List; -import javax.jdo.JDODataStoreException; + +import junit.framework.AssertionFailedError; + import javax.jdo.JDOFatalException; +import javax.jdo.JDODataStoreException; import javax.jdo.JDOUnsupportedOptionException; import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; -import junit.framework.AssertionFailedError; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.pc.mylib.PCRect; @@ -32,506 +35,495 @@ import org.apache.jdo.tck.util.ThreadExceptionHandler; /** - * Title: DatastoreTimeout
    - * Keywords: datastore timeout
    - * Assertion ID: A12.6.9-1, A14.6.1-7
    - * Assertion Description: + *Title: DatastoreTimeout + *
    + *Keywords: datastore timeout + *
    + *Assertion ID: A12.6.9-1, A14.6.1-7 + *
    + *Assertion Description: */ + public class DatastoreTimeout extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.6.9-1, A14.6.1-7 (DatastoreTimeout) failed: "; - - /** Timeout value for datastore read */ - private static Integer READ_TIMEOUT = Integer.valueOf(100); - - /** Timeout value for datastore write */ - private static Integer WRITE_TIMEOUT = Integer.valueOf(100); - - /** Zero Timeout value */ - private static Integer ZERO_TIMEOUT = Integer.valueOf(0); - - /** Time for the main thread to sleep after starting a parallel thread. */ - private static int MAIN_SLEEP_MILLIS = 1000; - - /** Time for the parallel threads to sleep before commit. */ - private static int THREAD_SLEEP_MILLIS_SHORT = 2500; - - /** Time for the parallel threads to sleep before commit. */ - private static int THREAD_SLEEP_MILLIS_LONG = 7500; - - /** Oid of the PCRect instance created by localSetUp */ - private Object rectOid; - - /** Oid of the first PCPOint instance created by localSetUp */ - private Object point1Oid; - - /** Oid of the second PCPoint instance created by localSetUp */ - private Object point2Oid; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DatastoreTimeout.class); - } - - /** - * Method testing DatastoreReadTimeout. - * - * @throws Exception exception - */ - public void testDatastoreReadTimeout() throws Exception { - - if (debug) logger.debug("isDatastoreTimeoutSupported:" + isDatastoreTimeoutSupported()); - - // Parallel thread writing the instances and causing them to be locked - ThreadExceptionHandler group = new ThreadExceptionHandler(); - ParallelWriter runnable = new ParallelWriter(THREAD_SLEEP_MILLIS_LONG); - Thread t = new Thread(group, runnable, "Parallel Writer"); - t.start(); - - // Wait for a second such that the other thread can lock the instances - Thread.sleep(MAIN_SLEEP_MILLIS); - - try { - runQueryReadingPCPointInstances(READ_TIMEOUT); - runGetObjectByIdReadingPCPointInstance(READ_TIMEOUT); - runNavigationalReadPCPointInstance(READ_TIMEOUT); - } finally { - t.join(); - Throwable problem = group.getUncaughtException(t); - if (problem != null) { - if (problem instanceof AssertionFailedError) throw (AssertionFailedError) problem; - else - throw new JDOFatalException("Thread " + t.getName() + " results in exception ", problem); - } - } - } - - /** - * Method testing DatastoreWriteTimeout. - * - * @throws Exception exception - */ - public void testDatastoreWriteTimeout() throws Exception { - - if (debug) logger.debug("isDatastoreTimeoutSupported:" + isDatastoreTimeoutSupported()); - - // Parallel thread reading the instances and causing them to be locked - ThreadExceptionHandler group = new ThreadExceptionHandler(); - ParallelReader runnable = new ParallelReader(THREAD_SLEEP_MILLIS_LONG); - Thread t = new Thread(group, runnable, "Parallel Reader"); - t.start(); - - // Wait for a second such that the other thread can lock the instances - Thread.sleep(MAIN_SLEEP_MILLIS); - - try { - runUpdatePCointInstance(WRITE_TIMEOUT); - runDeletePCPointInstance(WRITE_TIMEOUT); - runDeletePCPointInstancesByQuery(WRITE_TIMEOUT); - } finally { - t.join(); - Throwable problem = group.getUncaughtException(t); - if (problem != null) { - if (problem instanceof AssertionFailedError) throw (AssertionFailedError) problem; - else - throw new JDOFatalException("Thread " + t.getName() + " results in exception ", problem); - } - } - } - - /** - * Method testing zero DatastoreReadTimeout. - * - * @throws Exception exception - */ - public void testZeroDatastoreReadTimeout() throws Exception { - - // Parallel thread writing the instances and causing them to be locked - ThreadExceptionHandler group = new ThreadExceptionHandler(); - ParallelWriter runnable = new ParallelWriter(THREAD_SLEEP_MILLIS_SHORT); - Thread t = new Thread(group, runnable, "Parallel Writer"); - t.start(); - - // Wait for a second such that the other thread can lock the instances - Thread.sleep(MAIN_SLEEP_MILLIS); - - try { - runQueryReadingPCPointInstances(ZERO_TIMEOUT); - } finally { - t.join(); - Throwable problem = group.getUncaughtException(t); - if (problem != null) { - if (problem instanceof AssertionFailedError) throw (AssertionFailedError) problem; - else - throw new JDOFatalException("Thread " + t.getName() + " results in exception ", problem); - } - } - } - - /** - * Method testing zero DatastoreWriteTimeout. - * - * @throws Exception exception - */ - public void testZeroDatastoreWriteTimeout() throws Exception { - - // Parallel thread reading the instances and causing them to be locked - ThreadExceptionHandler group = new ThreadExceptionHandler(); - ParallelReader runnable = new ParallelReader(THREAD_SLEEP_MILLIS_SHORT); - Thread t = new Thread(group, runnable, "Parallel Reader"); - t.start(); - - // Wait for a second such that the other thread can lock the instances - Thread.sleep(MAIN_SLEEP_MILLIS); - - try { - runUpdatePCointInstance(ZERO_TIMEOUT); - } finally { - t.join(); - Throwable problem = group.getUncaughtException(t); - if (problem != null) { - if (problem instanceof AssertionFailedError) throw (AssertionFailedError) problem; - else - throw new JDOFatalException("Thread " + t.getName() + " results in exception ", problem); - } - } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCRect.class); - addTearDownClass(PCPoint.class); - - getPM(); - try { - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(110, 120); - PCPoint p2 = new PCPoint(130, 140); - PCRect rect = new PCRect(0, p1, p2); - pm.makePersistent(rect); - tx.commit(); - rectOid = pm.getObjectId(rect); - point1Oid = pm.getObjectId(p1); - point2Oid = pm.getObjectId(p2); - } finally { - cleanupPM(); - } - } - - // ----------------- Helper methods --------------------------- - - /** DatastoreReadTimeout helper method: query reading PCPoint instance. */ - private void runQueryReadingPCPointInstances(Integer timeout) { - getPM(); - try { - pm.currentTransaction().begin(); - Query q = pm.newQuery(PCPoint.class); - q.setDatastoreReadTimeoutMillis(timeout); - @SuppressWarnings("unused") - List result = (List) q.execute(); - pm.currentTransaction().commit(); - if (!isDatastoreTimeoutSupported()) { - fail( - ASSERTION_FAILED, - "Query.setDatastoreReadTimeoutMillis should throw a " - + "JDOUnsupportedOptionException, if datastore timeout is not supported "); - } - } catch (JDOUnsupportedOptionException ex) { - if (isDatastoreTimeoutSupported()) { - fail( - ASSERTION_FAILED, - "Query.setDatastoreReadTimeoutMillis should not result " - + "in a JDOUnsupportedOptionException, if datastore timeout is supported "); - } - } catch (JDODataStoreException ex) { - if (!isDatastoreTimeoutSupported()) { - fail( - ASSERTION_FAILED, - "Query.execute should not result in a " - + "JDODataStoreException, if datastore timeout is not supported."); - } else if (timeout == ZERO_TIMEOUT) { - fail( - ASSERTION_FAILED, - "Query.execute should not result in a " - + "JDODataStoreException, if zero timeout is specified (meaning no timeout)."); - } - } finally { - cleanupPM(); - } - } - - /** DatastoreReadTimeout helper method: getObjectById reading PCPoint instance. */ - private void runGetObjectByIdReadingPCPointInstance(Integer timeout) { - getPM(); - try { - pm.currentTransaction().begin(); - pm.setDatastoreReadTimeoutMillis(timeout); - @SuppressWarnings("unused") - PCPoint point1 = (PCPoint) pm.getObjectById(point1Oid, true); - pm.currentTransaction().commit(); - if (!isDatastoreTimeoutSupported()) { - fail( - ASSERTION_FAILED, - "PM.setDatastoreReadTimeoutMillis should throw a " - + "JDOUnsupportedOptionException, if datastore timeout is not supported "); - } - } catch (JDOUnsupportedOptionException ex) { - if (isDatastoreTimeoutSupported()) { - fail( - ASSERTION_FAILED, - "PM.setDatastoreReadTimeoutMillis should not result " - + "in a JDOUnsupportedOptionException, if datastore timeout is supported "); - } - } catch (JDODataStoreException ex) { - if (!isDatastoreTimeoutSupported()) { - fail( - ASSERTION_FAILED, - "PM.getObjectById should not result in a " - + "JDODataStoreException, if datastore timeout is not supported."); - } else if (timeout == ZERO_TIMEOUT) { - fail( - ASSERTION_FAILED, - "PM.getObjectById should not result in a " - + "JDODataStoreException, if zero timeout is specified (meaning no timeout)."); - } - } finally { - cleanupPM(); - } - } - - /** DatastoreReadTimeout helper method: navigation reading PCPoint instance. */ - private void runNavigationalReadPCPointInstance(Integer timeout) { - getPM(); - try { - pm.currentTransaction().begin(); - pm.setDatastoreReadTimeoutMillis(timeout); - PCRect rect = (PCRect) pm.getObjectById(rectOid, true); - PCPoint p1 = rect.getUpperLeft(); - p1.name(); - pm.currentTransaction().commit(); - if (!isDatastoreTimeoutSupported()) { - fail( - ASSERTION_FAILED, - "PM.setDatastoreReadTimeoutMillis should throw a " - + "JDOUnsupportedOptionException, if datastore timeout is not supported "); - } - } catch (JDOUnsupportedOptionException ex) { - if (isDatastoreTimeoutSupported()) { - fail( - ASSERTION_FAILED, - "PM.setDatastoreReadTimeoutMillis should not result " - + "in a JDOUnsupportedOptionException, if datastore timeout is supported "); - } - } catch (JDODataStoreException ex) { - if (!isDatastoreTimeoutSupported()) { - fail( - ASSERTION_FAILED, - "Navigational access should not result in a " - + "JDODataStoreException, if datastore timeout is not supported."); - } else if (timeout == ZERO_TIMEOUT) { - fail( - ASSERTION_FAILED, - "Navigational access should not result in a " - + "JDODataStoreException, if zero timeout is specified (meaning no timeout)."); - } - } finally { - cleanupPM(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.6.9-1, A14.6.1-7 (DatastoreTimeout) failed: "; + + /** Timeout value for datastore read */ + private static Integer READ_TIMEOUT = Integer.valueOf(100); + + /** Timeout value for datastore write */ + private static Integer WRITE_TIMEOUT = Integer.valueOf(100); + + /** Zero Timeout value */ + private static Integer ZERO_TIMEOUT = Integer.valueOf(0); + + /** Time for the main thread to sleep after starting a parallel thread. */ + private static int MAIN_SLEEP_MILLIS = 1000; + + /** Time for the parallel threads to sleep before commit. */ + private static int THREAD_SLEEP_MILLIS_SHORT = 2500; + + /** Time for the parallel threads to sleep before commit. */ + private static int THREAD_SLEEP_MILLIS_LONG = 7500; + + /** Oid of the PCRect instance created by localSetUp */ + private Object rectOid; + + /** Oid of the first PCPOint instance created by localSetUp */ + private Object point1Oid; + + /** Oid of the second PCPoint instance created by localSetUp */ + private Object point2Oid; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DatastoreTimeout.class); } - } - - /** DatastoreWriteTimeout helper method: update PCPoint instance. */ - private void runUpdatePCointInstance(Integer timeout) { - getPM(); - try { - pm.currentTransaction().begin(); - pm.setDatastoreWriteTimeoutMillis(timeout); - PCPoint point1 = (PCPoint) pm.getObjectById(point1Oid, true); - point1.setX(500); - pm.currentTransaction().commit(); - if (!isDatastoreTimeoutSupported()) { - fail( - ASSERTION_FAILED, - "PM.setDatastoreWriteTimeoutMillis should throw a " - + "JDOUnsupportedOptionException, if datastore timeout is not supported "); - } - } catch (JDOUnsupportedOptionException ex) { - if (isDatastoreTimeoutSupported()) { - fail( - ASSERTION_FAILED, - "PM.setDatastoreWriteTimeoutMillis should not result " - + "in a JDOUnsupportedOptionException, if datastore timeout is supported "); - } - } catch (JDODataStoreException ex) { - if (!isDatastoreTimeoutSupported()) { - fail( - ASSERTION_FAILED, - "PM.getObjectById should not result in a " - + "JDODataStoreException, if datastore timeout is not supported."); - } else if (timeout == ZERO_TIMEOUT) { - fail( - ASSERTION_FAILED, - "PM.getObjectById should not result in a " - + "JDODataStoreException, if zero timeout is specified (meaning no timeout)."); - } - } finally { - cleanupPM(); + + /** + * Method testing DatastoreReadTimeout. + * @throws Exception exception + */ + public void testDatastoreReadTimeout() throws Exception { + + if (debug) logger.debug("isDatastoreTimeoutSupported:" + isDatastoreTimeoutSupported()); + + // Parallel thread writing the instances and causing them to be locked + ThreadExceptionHandler group = new ThreadExceptionHandler(); + ParallelWriter runnable = new ParallelWriter(THREAD_SLEEP_MILLIS_LONG); + Thread t = new Thread(group, runnable, "Parallel Writer"); + t.start(); + + // Wait for a second such that the other thread can lock the instances + Thread.sleep(MAIN_SLEEP_MILLIS); + + try { + runQueryReadingPCPointInstances(READ_TIMEOUT); + runGetObjectByIdReadingPCPointInstance(READ_TIMEOUT); + runNavigationalReadPCPointInstance(READ_TIMEOUT); + } + finally { + t.join(); + Throwable problem = group.getUncaughtException(t); + if (problem != null) { + if (problem instanceof AssertionFailedError) + throw (AssertionFailedError)problem; + else + throw new JDOFatalException( "Thread " + t.getName()+ + " results in exception ", problem); + } + } } - } - - /** DatastoreWriteTimeout helper method: delete PCPoint instance. */ - private void runDeletePCPointInstance(Integer timeout) { - getPM(); - try { - pm.currentTransaction().begin(); - pm.setDatastoreWriteTimeoutMillis(timeout); - PCPoint point1 = (PCPoint) pm.getObjectById(point1Oid, true); - pm.deletePersistent(point1); - pm.currentTransaction().commit(); - if (!isDatastoreTimeoutSupported()) { - fail( - ASSERTION_FAILED, - "PM.setDatastoreWriteTimeoutMillis should throw a " - + "JDOUnsupportedOptionException, if datastore timeout is not supported "); - } - } catch (JDOUnsupportedOptionException ex) { - if (isDatastoreTimeoutSupported()) { - fail( - ASSERTION_FAILED, - "PM.setDatastoreWriteTimeoutMillis should not result " - + "in a JDOUnsupportedOptionException, if datastore timeout is supported "); - } - } catch (JDODataStoreException ex) { - if (!isDatastoreTimeoutSupported()) { - fail( - ASSERTION_FAILED, - "PM.getObjectById should not result in a " - + "JDODataStoreException, if datastore timeout is not supported."); - } else if (timeout == ZERO_TIMEOUT) { - fail( - ASSERTION_FAILED, - "PM.getObjectById should not result in a " - + "JDODataStoreException, if zero timeout is specified (meaning no timeout)."); - } - } finally { - cleanupPM(); + + /** + * Method testing DatastoreWriteTimeout. + * @throws Exception exception + */ + public void testDatastoreWriteTimeout() throws Exception { + + if (debug) logger.debug("isDatastoreTimeoutSupported:" + isDatastoreTimeoutSupported()); + + // Parallel thread reading the instances and causing them to be locked + ThreadExceptionHandler group = new ThreadExceptionHandler(); + ParallelReader runnable = new ParallelReader(THREAD_SLEEP_MILLIS_LONG); + Thread t = new Thread(group, runnable, "Parallel Reader"); + t.start(); + + // Wait for a second such that the other thread can lock the instances + Thread.sleep(MAIN_SLEEP_MILLIS); + + try { + runUpdatePCointInstance(WRITE_TIMEOUT); + runDeletePCPointInstance(WRITE_TIMEOUT); + runDeletePCPointInstancesByQuery(WRITE_TIMEOUT); + } + finally { + t.join(); + Throwable problem = group.getUncaughtException(t); + if (problem != null) { + if (problem instanceof AssertionFailedError) + throw (AssertionFailedError)problem; + else + throw new JDOFatalException( "Thread " + t.getName()+ + " results in exception ", problem); + } + } } - } - - /** DatastoreWriteTimeout helper method: delete by query. */ - private void runDeletePCPointInstancesByQuery(Integer timeout) { - getPM(); - try { - pm.currentTransaction().begin(); - Query q = pm.newQuery(PCPoint.class); - q.setDatastoreWriteTimeoutMillis(timeout); - q.deletePersistentAll(); - pm.currentTransaction().commit(); - if (!isDatastoreTimeoutSupported()) { - fail( - ASSERTION_FAILED, - "Query.setDatastoreWriteTimeoutMillis should throw a " - + "JDOUnsupportedOptionException, if datastore timeout is not supported "); - } - } catch (JDOUnsupportedOptionException ex) { - if (isDatastoreTimeoutSupported()) { - fail( - ASSERTION_FAILED, - "Query.setDatastoreWriteTimeoutMillis should not result " - + "in a JDOUnsupportedOptionException, if datastore timeout is supported "); - } - } catch (JDODataStoreException ex) { - if (!isDatastoreTimeoutSupported()) { - fail( - ASSERTION_FAILED, - "Query.deletePersistentAll should not result in a " - + "JDODataStoreException, if datastore timeout is not supported."); - } else if (timeout == ZERO_TIMEOUT) { - fail( - ASSERTION_FAILED, - "Query.deletePersistentAll should not result in a " - + "JDODataStoreException, if zero timeout is specified (meaning no timeout)."); - } - } finally { - cleanupPM(); + + /** + * Method testing zero DatastoreReadTimeout. + * @throws Exception exception + */ + public void testZeroDatastoreReadTimeout() throws Exception { + + // Parallel thread writing the instances and causing them to be locked + ThreadExceptionHandler group = new ThreadExceptionHandler(); + ParallelWriter runnable = new ParallelWriter(THREAD_SLEEP_MILLIS_SHORT); + Thread t = new Thread(group, runnable, "Parallel Writer"); + t.start(); + + // Wait for a second such that the other thread can lock the instances + Thread.sleep(MAIN_SLEEP_MILLIS); + + try { + runQueryReadingPCPointInstances(ZERO_TIMEOUT); + } + finally { + t.join(); + Throwable problem = group.getUncaughtException(t); + if (problem != null) { + if (problem instanceof AssertionFailedError) + throw (AssertionFailedError)problem; + else + throw new JDOFatalException( "Thread " + t.getName()+ + " results in exception ", problem); + } + } } - } - // ------------- Helper classes ------------------------------- + /** + * Method testing zero DatastoreWriteTimeout. + * @throws Exception exception + */ + public void testZeroDatastoreWriteTimeout() throws Exception { + + // Parallel thread reading the instances and causing them to be locked + ThreadExceptionHandler group = new ThreadExceptionHandler(); + ParallelReader runnable = new ParallelReader(THREAD_SLEEP_MILLIS_SHORT); + Thread t = new Thread(group, runnable, "Parallel Reader"); + t.start(); + + // Wait for a second such that the other thread can lock the instances + Thread.sleep(MAIN_SLEEP_MILLIS); + + try { + runUpdatePCointInstance(ZERO_TIMEOUT); + } + finally { + t.join(); + Throwable problem = group.getUncaughtException(t); + if (problem != null) { + if (problem instanceof AssertionFailedError) + throw (AssertionFailedError)problem; + else + throw new JDOFatalException( "Thread " + t.getName()+ + " results in exception ", problem); + } + } + } - /** Runnable class updating instances and causing them to be read locked. */ - class ParallelReader implements Runnable { + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCRect.class); + addTearDownClass(PCPoint.class); + + getPM(); + try { + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint(110, 120); + PCPoint p2 = new PCPoint(130, 140); + PCRect rect = new PCRect (0, p1, p2); + pm.makePersistent (rect); + tx.commit(); + rectOid = pm.getObjectId(rect); + point1Oid = pm.getObjectId(p1); + point2Oid = pm.getObjectId(p2); + } + finally { + cleanupPM(); + } + } - private final int sleepMillis; + // ----------------- Helper methods --------------------------- + + /** DatastoreReadTimeout helper method: query reading PCPoint instance. */ + private void runQueryReadingPCPointInstances(Integer timeout) { + getPM(); + try { + pm.currentTransaction().begin(); + Query q = pm.newQuery(PCPoint.class); + q.setDatastoreReadTimeoutMillis(timeout); + @SuppressWarnings("unused") + List result = (List)q.execute(); + pm.currentTransaction().commit(); + if (!isDatastoreTimeoutSupported()) { + fail(ASSERTION_FAILED, "Query.setDatastoreReadTimeoutMillis should throw a " + + "JDOUnsupportedOptionException, if datastore timeout is not supported "); + } + } + catch (JDOUnsupportedOptionException ex) { + if (isDatastoreTimeoutSupported()) { + fail(ASSERTION_FAILED, "Query.setDatastoreReadTimeoutMillis should not result " + + "in a JDOUnsupportedOptionException, if datastore timeout is supported "); + } + } + catch (JDODataStoreException ex) { + if (!isDatastoreTimeoutSupported()) { + fail(ASSERTION_FAILED, "Query.execute should not result in a " + + "JDODataStoreException, if datastore timeout is not supported."); + } else if (timeout == ZERO_TIMEOUT) { + fail(ASSERTION_FAILED, "Query.execute should not result in a " + + "JDODataStoreException, if zero timeout is specified (meaning no timeout)."); + } + } + finally { + cleanupPM(); + } + } - ParallelReader(int sleepMillis) { - this.sleepMillis = sleepMillis; + /** DatastoreReadTimeout helper method: getObjectById reading PCPoint instance. */ + private void runGetObjectByIdReadingPCPointInstance(Integer timeout) { + getPM(); + try { + pm.currentTransaction().begin(); + pm.setDatastoreReadTimeoutMillis(timeout); + @SuppressWarnings("unused") + PCPoint point1 = (PCPoint)pm.getObjectById(point1Oid, true); + pm.currentTransaction().commit(); + if (!isDatastoreTimeoutSupported()) { + fail(ASSERTION_FAILED, "PM.setDatastoreReadTimeoutMillis should throw a " + + "JDOUnsupportedOptionException, if datastore timeout is not supported "); + } + } + catch (JDOUnsupportedOptionException ex) { + if (isDatastoreTimeoutSupported()) { + fail(ASSERTION_FAILED, "PM.setDatastoreReadTimeoutMillis should not result " + + "in a JDOUnsupportedOptionException, if datastore timeout is supported "); + } + } + catch (JDODataStoreException ex) { + if (!isDatastoreTimeoutSupported()) { + fail(ASSERTION_FAILED, "PM.getObjectById should not result in a " + + "JDODataStoreException, if datastore timeout is not supported."); + } else if (timeout == ZERO_TIMEOUT) { + fail(ASSERTION_FAILED, "PM.getObjectById should not result in a " + + "JDODataStoreException, if zero timeout is specified (meaning no timeout)."); + } + } + finally { + cleanupPM(); + } } - public void run() { - PersistenceManager parallelPM = getPMF().getPersistenceManager(); - Transaction tx = parallelPM.currentTransaction(); - // Run datastore transaction - tx.setOptimistic(false); - try { - tx.begin(); - // read PCPoint instances - PCPoint p1 = (PCPoint) parallelPM.getObjectById(point1Oid, true); - p1.name(); - PCPoint p2 = (PCPoint) parallelPM.getObjectById(point2Oid, true); - p2.name(); - // Give the main thread a chance to try to write the instances - Thread.sleep(sleepMillis); - tx.commit(); - } catch (InterruptedException ex) { - throw new RuntimeException(ex); - } finally { - cleanupPM(parallelPM); - } + /** DatastoreReadTimeout helper method: navigation reading PCPoint instance. */ + private void runNavigationalReadPCPointInstance(Integer timeout) { + getPM(); + try { + pm.currentTransaction().begin(); + pm.setDatastoreReadTimeoutMillis(timeout); + PCRect rect = (PCRect)pm.getObjectById(rectOid, true); + PCPoint p1 = rect.getUpperLeft(); + p1.name(); + pm.currentTransaction().commit(); + if (!isDatastoreTimeoutSupported()) { + fail(ASSERTION_FAILED, "PM.setDatastoreReadTimeoutMillis should throw a " + + "JDOUnsupportedOptionException, if datastore timeout is not supported "); + } + } + catch (JDOUnsupportedOptionException ex) { + if (isDatastoreTimeoutSupported()) { + fail(ASSERTION_FAILED, "PM.setDatastoreReadTimeoutMillis should not result " + + "in a JDOUnsupportedOptionException, if datastore timeout is supported "); + } + } + catch (JDODataStoreException ex) { + if (!isDatastoreTimeoutSupported()) { + fail(ASSERTION_FAILED, "Navigational access should not result in a " + + "JDODataStoreException, if datastore timeout is not supported."); + } else if (timeout == ZERO_TIMEOUT) { + fail(ASSERTION_FAILED, "Navigational access should not result in a " + + "JDODataStoreException, if zero timeout is specified (meaning no timeout)."); + } + } + finally { + cleanupPM(); + } } - } - /** Runnable class updating instances and causing them to be write locked. */ - class ParallelWriter implements Runnable { + /** DatastoreWriteTimeout helper method: update PCPoint instance. */ + private void runUpdatePCointInstance(Integer timeout) { + getPM(); + try { + pm.currentTransaction().begin(); + pm.setDatastoreWriteTimeoutMillis(timeout); + PCPoint point1 = (PCPoint)pm.getObjectById(point1Oid, true); + point1.setX(500); + pm.currentTransaction().commit(); + if (!isDatastoreTimeoutSupported()) { + fail(ASSERTION_FAILED, "PM.setDatastoreWriteTimeoutMillis should throw a " + + "JDOUnsupportedOptionException, if datastore timeout is not supported "); + } + } + catch (JDOUnsupportedOptionException ex) { + if (isDatastoreTimeoutSupported()) { + fail(ASSERTION_FAILED, "PM.setDatastoreWriteTimeoutMillis should not result " + + "in a JDOUnsupportedOptionException, if datastore timeout is supported "); + } + } + catch (JDODataStoreException ex) { + if (!isDatastoreTimeoutSupported()) { + fail(ASSERTION_FAILED, "PM.getObjectById should not result in a " + + "JDODataStoreException, if datastore timeout is not supported."); + } else if (timeout == ZERO_TIMEOUT) { + fail(ASSERTION_FAILED, "PM.getObjectById should not result in a " + + "JDODataStoreException, if zero timeout is specified (meaning no timeout)."); + } + } + finally { + cleanupPM(); + } + } - private final int sleepMillis; + /** DatastoreWriteTimeout helper method: delete PCPoint instance. */ + private void runDeletePCPointInstance(Integer timeout) { + getPM(); + try { + pm.currentTransaction().begin(); + pm.setDatastoreWriteTimeoutMillis(timeout); + PCPoint point1 = (PCPoint)pm.getObjectById(point1Oid, true); + pm.deletePersistent(point1); + pm.currentTransaction().commit(); + if (!isDatastoreTimeoutSupported()) { + fail(ASSERTION_FAILED, "PM.setDatastoreWriteTimeoutMillis should throw a " + + "JDOUnsupportedOptionException, if datastore timeout is not supported "); + } + } + catch (JDOUnsupportedOptionException ex) { + if (isDatastoreTimeoutSupported()) { + fail(ASSERTION_FAILED, "PM.setDatastoreWriteTimeoutMillis should not result " + + "in a JDOUnsupportedOptionException, if datastore timeout is supported "); + } + } + catch (JDODataStoreException ex) { + if (!isDatastoreTimeoutSupported()) { + fail(ASSERTION_FAILED, "PM.getObjectById should not result in a " + + "JDODataStoreException, if datastore timeout is not supported."); + } else if (timeout == ZERO_TIMEOUT) { + fail(ASSERTION_FAILED, "PM.getObjectById should not result in a " + + "JDODataStoreException, if zero timeout is specified (meaning no timeout)."); + } + } + finally { + cleanupPM(); + } + } + + /** DatastoreWriteTimeout helper method: delete by query. */ + private void runDeletePCPointInstancesByQuery(Integer timeout) { + getPM(); + try { + pm.currentTransaction().begin(); + Query q = pm.newQuery(PCPoint.class); + q.setDatastoreWriteTimeoutMillis(timeout); + q.deletePersistentAll(); + pm.currentTransaction().commit(); + if (!isDatastoreTimeoutSupported()) { + fail(ASSERTION_FAILED, "Query.setDatastoreWriteTimeoutMillis should throw a " + + "JDOUnsupportedOptionException, if datastore timeout is not supported "); + } + } + catch (JDOUnsupportedOptionException ex) { + if (isDatastoreTimeoutSupported()) { + fail(ASSERTION_FAILED, "Query.setDatastoreWriteTimeoutMillis should not result " + + "in a JDOUnsupportedOptionException, if datastore timeout is supported "); + } + } + catch (JDODataStoreException ex) { + if (!isDatastoreTimeoutSupported()) { + fail(ASSERTION_FAILED, "Query.deletePersistentAll should not result in a " + + "JDODataStoreException, if datastore timeout is not supported."); + } else if (timeout == ZERO_TIMEOUT) { + fail(ASSERTION_FAILED, "Query.deletePersistentAll should not result in a " + + "JDODataStoreException, if zero timeout is specified (meaning no timeout)."); + } + } + finally { + cleanupPM(); + } + } - ParallelWriter(int sleepMillis) { - this.sleepMillis = sleepMillis; + // ------------- Helper classes ------------------------------- + + /** Runnable class updating instances and causing them to be read locked. */ + class ParallelReader implements Runnable { + + private final int sleepMillis; + + ParallelReader(int sleepMillis) { + this.sleepMillis = sleepMillis; + } + + public void run() { + PersistenceManager parallelPM = getPMF().getPersistenceManager(); + Transaction tx = parallelPM.currentTransaction(); + // Run datastore transaction + tx.setOptimistic(false); + try { + tx.begin(); + // read PCPoint instances + PCPoint p1 = (PCPoint)parallelPM.getObjectById(point1Oid, true); + p1.name(); + PCPoint p2 = (PCPoint)parallelPM.getObjectById(point2Oid, true); + p2.name(); + // Give the main thread a chance to try to write the instances + Thread.sleep(sleepMillis); + tx.commit(); + } + catch (InterruptedException ex) { + throw new RuntimeException(ex); + } + finally { + cleanupPM(parallelPM); + } + } } - public void run() { - PersistenceManager parallelPM = getPMF().getPersistenceManager(); - Transaction tx = parallelPM.currentTransaction(); - // Run datastore transaction - tx.setOptimistic(false); - try { - tx.begin(); - PCPoint p1 = (PCPoint) parallelPM.getObjectById(point1Oid); - p1.setX(210); - p1.setY(220); - PCPoint p2 = (PCPoint) parallelPM.getObjectById(point2Oid); - p2.setX(230); - p2.setY(240); - // Flush will set a write lock on the instances - parallelPM.flush(); - // Give the main thread a chance to try to read the instances - Thread.sleep(sleepMillis); - tx.commit(); - } catch (InterruptedException ex) { - throw new RuntimeException(ex); - } finally { - cleanupPM(parallelPM); - } + /** Runnable class updating instances and causing them to be write locked. */ + class ParallelWriter implements Runnable { + + private final int sleepMillis; + + ParallelWriter(int sleepMillis) { + this.sleepMillis = sleepMillis; + } + + public void run() { + PersistenceManager parallelPM = getPMF().getPersistenceManager(); + Transaction tx = parallelPM.currentTransaction(); + // Run datastore transaction + tx.setOptimistic(false); + try { + tx.begin(); + PCPoint p1 = (PCPoint)parallelPM.getObjectById(point1Oid); + p1.setX(210); + p1.setY(220); + PCPoint p2 = (PCPoint)parallelPM.getObjectById(point2Oid); + p2.setX(230); + p2.setY(240); + // Flush will set a write lock on the instances + parallelPM.flush(); + // Give the main thread a chance to try to read the instances + Thread.sleep(sleepMillis); + tx.commit(); + } + catch (InterruptedException ex) { + throw new RuntimeException(ex); + } + finally { + cleanupPM(parallelPM); + } + } } - } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistent.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistent.java index e396d1f06..560476ae1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistent.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistent.java @@ -5,230 +5,251 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import java.util.Collection; import java.util.HashSet; + import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Delete Persistent
    - * Keywords:
    - * Assertion IDs: A12.5.7-9
    - * Assertion Description: PersistenceManager.deletePersistent and deletePersistentAll delete - * a persistent instance(s) from the data store. It must be called in the context of an active - * transaction, or a JDOUserExceptionis thrown. The representation in the data store will be deleted - * when this instance is flushed to the data store (via commit, or evict). + *Title: Delete Persistent + *
    + *Keywords: + *
    + *Assertion IDs: A12.5.7-9 + *
    + *Assertion Description: +PersistenceManager.deletePersistent and deletePersistentAll delete a persistent instance(s) from the data store. It must be called in the context of an active transaction, or a JDOUserExceptionis thrown. The representation in the data store will be deleted when this instance is flushed to the data store (via commit, or evict). + */ -public class DeletePersistent extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A12.5.7-9 (DeletePersistent) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DeletePersistent.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - - /** */ - public void testDeletePersistent() { - pm = getPM(); - createObjects(pm); - - /* positive tests */ - /* method called in the context of an active transaction */ - runTestDeletePersistent1(pm); - runTestDeletePersistent2(pm); - runTestDeletePersistent3(pm); - - /* negative tests */ - /* method called in the context of an non-active transaction */ - runTestDeletePersistent4(pm); - runTestDeletePersistent5(pm); - runTestDeletePersistent6(pm); - - pm.close(); - pm = null; - } - - /** */ - private void createObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - - pm.makePersistent(p1); - pm.makePersistent(p2); - pm.makePersistent(p3); - pm.makePersistent(p4); - pm.makePersistent(p5); - - tx.commit(); - } finally { - if (tx.isActive()) tx.rollback(); - } - } - - /** test deletePersistent (Object pc) */ - private void runTestDeletePersistent1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx = pm.currentTransaction(); - tx.begin(); - pm.deletePersistent(p1); - tx.commit(); - if (debug) logger.debug(" \nPASSED in testDeletePersistent1()"); - } finally { - if (tx.isActive()) tx.rollback(); +public class DeletePersistent extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-9 (DeletePersistent) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DeletePersistent.class); } - } - - /* test deletePersistentAll (Collection pcs) */ - private void runTestDeletePersistent2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Collection col1 = new java.util.HashSet(); - col1.add(p2); - col1.add(p3); - - pm.deletePersistentAll(col1); - tx.commit(); - if (debug) logger.debug(" \nPASSED in testDeletePersistent2()"); - } finally { - if (tx.isActive()) tx.rollback(); + + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + + /** */ + public void testDeletePersistent() { + pm = getPM(); + createObjects(pm); + + /* positive tests */ + /* method called in the context of an active transaction */ + runTestDeletePersistent1(pm); + runTestDeletePersistent2(pm); + runTestDeletePersistent3(pm); + + /* negative tests */ + /* method called in the context of an non-active transaction */ + runTestDeletePersistent4(pm); + runTestDeletePersistent5(pm); + runTestDeletePersistent6(pm); + + pm.close(); + pm = null; } - } - /* test deletePersistentAll (Object[] o) */ - private void runTestDeletePersistent3(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Collection col1 = new HashSet(); - col1.add(p4); - col1.add(p5); + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint(5,7); + + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + pm.makePersistent(p5); + + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } - Object[] obj1 = col1.toArray(); + /** test deletePersistent (Object pc) */ + private void runTestDeletePersistent1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx = pm.currentTransaction(); + tx.begin(); + pm.deletePersistent(p1); + tx.commit(); + if (debug) logger.debug(" \nPASSED in testDeletePersistent1()"); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } - pm.deletePersistentAll(obj1); - tx.commit(); - if (debug) logger.debug(" \nPASSED in testDeletePersistent3()"); - } finally { - if (tx.isActive()) tx.rollback(); + /* test deletePersistentAll (Collection pcs) */ + private void runTestDeletePersistent2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 = new java.util.HashSet(); + col1.add(p2); + col1.add(p3); + + pm.deletePersistentAll(col1); + tx.commit(); + if (debug) logger.debug(" \nPASSED in testDeletePersistent2()"); + } + finally { + if (tx.isActive()) + tx.rollback(); + } } - } - - /* test deletePersistent (Object pc) */ - public void runTestDeletePersistent4(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - PCPoint np1 = new PCPoint(1, 3); - pm.makePersistent(np1); - tx.commit(); - - try { - pm.deletePersistent(np1); - fail( - ASSERTION_FAILED, - "pm.deletePersistent(Object) outside of tx should throw an exception"); - } catch (JDOUserException ex) { - // expected exception - } - } finally { - if (tx.isActive()) tx.rollback(); + + /* test deletePersistentAll (Object[] o) */ + private void runTestDeletePersistent3(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 = new HashSet(); + col1.add(p4); + col1.add(p5); + + Object[] obj1= col1.toArray(); + + pm.deletePersistentAll(obj1); + tx.commit(); + if (debug) logger.debug(" \nPASSED in testDeletePersistent3()"); + } + finally { + if (tx.isActive()) + tx.rollback(); + } } - } - - /* test deletePersistentAll (Collection pcs) */ - public void runTestDeletePersistent5(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - PCPoint np1 = new PCPoint(3, 3); - PCPoint np2 = new PCPoint(4, 4); - pm.makePersistent(np1); - pm.makePersistent(np2); - tx.commit(); - - Collection col1 = new java.util.HashSet(); - col1.add(np1); - col1.add(np2); - - try { - pm.deletePersistentAll(col1); - fail( - ASSERTION_FAILED, - "pm.deletePersistentAll(Collection) outside of tx should throw an exception"); - } catch (JDOUserException ex) { - // expected exception - } - } finally { - if (tx.isActive()) tx.rollback(); + + /* test deletePersistent (Object pc) */ + public void runTestDeletePersistent4(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + PCPoint np1 = new PCPoint(1,3); + pm.makePersistent(np1); + tx.commit(); + + try { + pm.deletePersistent(np1); + fail(ASSERTION_FAILED, + "pm.deletePersistent(Object) outside of tx should throw an exception"); + } + catch (JDOUserException ex) { + // expected exception + } + } + finally { + if (tx.isActive()) + tx.rollback(); + } } - } - - /* test deletePersistentAll (Object[] o) */ - public void runTestDeletePersistent6(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - PCPoint np1 = new PCPoint(3, 3); - PCPoint np2 = new PCPoint(4, 4); - - pm.makePersistent(np1); - pm.makePersistent(np2); - tx.commit(); - - Collection col1 = new java.util.HashSet(); - col1.add(np1); - col1.add(np2); - Object[] obj1 = col1.toArray(); - - try { - pm.deletePersistentAll(obj1); - fail( - ASSERTION_FAILED, - "pm.deletePersistentAll(Object[]) outside of tx should throw an exception"); - } catch (JDOUserException ex) { - // expected exception - } - } finally { - if (tx.isActive()) tx.rollback(); + + /* test deletePersistentAll (Collection pcs) */ + public void runTestDeletePersistent5(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + PCPoint np1 = new PCPoint (3,3); + PCPoint np2 = new PCPoint (4,4); + pm.makePersistent(np1); + pm.makePersistent(np2); + tx.commit(); + + Collection col1 = new java.util.HashSet(); + col1.add(np1); + col1.add(np2); + + try { + pm.deletePersistentAll(col1); + fail(ASSERTION_FAILED, + "pm.deletePersistentAll(Collection) outside of tx should throw an exception"); + } + catch (JDOUserException ex) { + // expected exception + } + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /* test deletePersistentAll (Object[] o) */ + public void runTestDeletePersistent6(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + PCPoint np1 = new PCPoint (3,3); + PCPoint np2 = new PCPoint (4,4); + + pm.makePersistent(np1); + pm.makePersistent(np2); + tx.commit(); + + Collection col1 = new java.util.HashSet(); + col1.add(np1); + col1.add(np2); + Object[] obj1=col1.toArray(); + + try { + pm.deletePersistentAll(obj1); + fail(ASSERTION_FAILED, + "pm.deletePersistentAll(Object[]) outside of tx should throw an exception"); + } + catch (JDOUserException ex) { + // expected exception + } + } + finally { + if (tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentAllFails.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentAllFails.java index 77a971bee..7dda2060b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentAllFails.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentAllFails.java @@ -5,143 +5,152 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import java.util.Collection; + import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.pc.mylib.Point; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: DeletePersistentAll Fails
    - * Keywords: exception
    - * Assertion IDs: A12.5.7-2.
    - * Assertion Description: If a collection or array of instances is passed to - * PersistenceManager.deletePersistentAll, and one or more of the instances fail to complete the - * required operation, then all instances will be attempted, and a JDOUserException will be thrown - * which contains nested exceptions, each of which contains one of the failing instances. The - * succeeding instances will transition to the specified life cycle state, and the failing instances - * will remain in their current state. + *Title: DeletePersistentAll Fails + *
    + *Keywords: exception + *
    + *Assertion IDs: A12.5.7-2. + *
    + *Assertion Description: +If a collection or array of instances is passed to PersistenceManager.deletePersistentAll, and one or more of the instances fail to complete the required operation, then all instances will be attempted, and a JDOUserException will be thrown which contains nested exceptions, each of which contains one of the failing instances. The succeeding instances will transition to the specified life cycle state, and the failing instances will remain in their current state. */ -public class DeletePersistentAllFails extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-2 (DeletePersistentAllFails) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DeletePersistentAllFails.class); - } - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - - /** */ - public void testDeletePersistentAllFails() { - pm = getPM(); - createObjects(pm); - runTestDeletePersistentAllFails1(pm); - runTestDeletePersistentAllFails2(pm); - pm.close(); - pm = null; - } - - private void createObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - - pm.makePersistent(p1); - pm.makePersistent(p2); - pm.makePersistent(p3); - pm.makePersistent(p4); - pm.makePersistent(p5); - - tx.commit(); - } finally { - if (tx.isActive()) tx.rollback(); +public class DeletePersistentAllFails extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-2 (DeletePersistentAllFails) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DeletePersistentAllFails.class); } - } - - /* test deletePersistentAll (Collection pcs) */ - private void runTestDeletePersistentAllFails1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Point np3 = new Point(5, 5); - - Collection col1 = new java.util.HashSet(); - col1.add(p1); - col1.add(p2); - col1.add(np3); - - try { - pm.deletePersistentAll(col1); - fail( - ASSERTION_FAILED, - "pm.deletePersistentAll(Collection) with non persistent instances should throw an exception"); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - } finally { - if (tx.isActive()) tx.rollback(); + + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + + /** */ + public void testDeletePersistentAllFails() { + pm = getPM(); + createObjects(pm); + runTestDeletePersistentAllFails1(pm); + runTestDeletePersistentAllFails2(pm); + pm.close(); + pm = null; } - } - - /* test deletePersistentAll (Object[] o) */ - private void runTestDeletePersistentAllFails2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Point np3 = new Point(5, 5); - - Collection col1 = new java.util.HashSet(); - col1.add(p3); - col1.add(p4); - col1.add(np3); - - Object[] obj1 = col1.toArray(); - - try { - pm.deletePersistentAll(obj1); - fail( - ASSERTION_FAILED, - "pm.deletePersistentAll(Object[]) with non persistent instances should throw an exception"); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - } finally { - if (tx.isActive()) tx.rollback(); + private void createObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint(5,7); + + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + pm.makePersistent(p5); + + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /* test deletePersistentAll (Collection pcs) */ + private void runTestDeletePersistentAllFails1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Point np3 = new Point (5,5); + + Collection col1 = new java.util.HashSet(); + col1.add(p1); + col1.add(p2); + col1.add(np3); + + try { + pm.deletePersistentAll(col1); + fail(ASSERTION_FAILED, + "pm.deletePersistentAll(Collection) with non persistent instances should throw an exception"); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /* test deletePersistentAll (Object[] o) */ + private void runTestDeletePersistentAllFails2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Point np3 = new Point (5,5); + + Collection col1 = new java.util.HashSet(); + col1.add(p3); + col1.add(p4); + col1.add(np3); + + Object[] obj1=col1.toArray(); + + try { + pm.deletePersistentAll(obj1); + fail(ASSERTION_FAILED, + "pm.deletePersistentAll(Object[]) with non persistent instances should throw an exception"); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentFailsIfInstanceIsTransient.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentFailsIfInstanceIsTransient.java index 1242c8fb2..52bf9e594 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentFailsIfInstanceIsTransient.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentFailsIfInstanceIsTransient.java @@ -5,129 +5,143 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import java.util.Collection; + import javax.jdo.JDOUserException; import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: DeletePersistent Fails If Instance Is Transient
    - * Keywords: exception
    - * Assertion IDs: A12.5.7-12.
    - * Assertion Description: PersistenceManager.deletePersistent and deletePersistentAll will - * throw a JDOUserException if the parameter instance is transient. + *Title: DeletePersistent Fails If Instance Is Transient + *
    + *Keywords: exception + *
    + *Assertion IDs: A12.5.7-12. + *
    + *Assertion Description: +PersistenceManager.deletePersistent and deletePersistentAll will throw a JDOUserException if the parameter instance is transient. */ -public class DeletePersistentFailsIfInstanceIsTransient extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-12 (DeletePersistentFailsIfInstanceIsTransient) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DeletePersistentFailsIfInstanceIsTransient.class); - } - - /** */ - public void testDeletePersistentFailsIfInstanceIsTransient() { - pm = getPM(); - runTestDeletePersistent(); - runTestDeletePersistentAll1(); - runTestDeletePersistentAll2(); - pm.close(); - pm = null; - } - - /* test deletePersistent (Object pc) */ - private void runTestDeletePersistent() { - Transaction tx = pm.currentTransaction(); - try { - tx = pm.currentTransaction(); - tx.begin(); - PCPoint p1 = new PCPoint(3, 3); - try { - pm.deletePersistent(p1); - fail( - ASSERTION_FAILED, - "pm.deletePersistent(Object) with transient instance should throw exception"); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - } finally { - if (tx.isActive()) tx.rollback(); +public class DeletePersistentFailsIfInstanceIsTransient extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-12 (DeletePersistentFailsIfInstanceIsTransient) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DeletePersistentFailsIfInstanceIsTransient.class); } - } - - /* test deletePersistentAll (Collection pcs) */ - private void runTestDeletePersistentAll1() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - PCPoint p1 = new PCPoint(3, 3); - PCPoint p2 = new PCPoint(4, 4); - - Collection col1 = new java.util.HashSet(); - col1.add(p1); - col1.add(p2); - - try { - pm.deletePersistentAll(col1); - fail( - ASSERTION_FAILED, - "pm.deletePersistent(Collection) with transient instance(s) should throw exception"); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - } finally { - if (tx.isActive()) tx.rollback(); + + /** */ + public void testDeletePersistentFailsIfInstanceIsTransient() { + pm = getPM(); + runTestDeletePersistent(); + runTestDeletePersistentAll1(); + runTestDeletePersistentAll2(); + pm.close(); + pm = null; } - } - - /* test deletePersistentAll (Object[] o) */ - private void runTestDeletePersistentAll2() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - PCPoint p1 = new PCPoint(3, 3); - PCPoint p2 = new PCPoint(4, 4); + /* test deletePersistent (Object pc) */ + private void runTestDeletePersistent() { + Transaction tx = pm.currentTransaction(); + try { + + tx = pm.currentTransaction(); + tx.begin(); + PCPoint p1 = new PCPoint (3,3); + try { + pm.deletePersistent(p1); + fail(ASSERTION_FAILED, + "pm.deletePersistent(Object) with transient instance should throw exception"); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } - Collection col1 = new java.util.HashSet(); - col1.add(p1); - col1.add(p2); - try { - pm.deletePersistentAll(col1.toArray()); - fail( - ASSERTION_FAILED, - "pm.deletePersistent(Object[]) with transient instance(s) should throw exception"); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - } finally { - if (tx.isActive()) tx.rollback(); - } - } + /* test deletePersistentAll (Collection pcs) */ + private void runTestDeletePersistentAll1() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + PCPoint p1 = new PCPoint (3,3); + PCPoint p2 = new PCPoint (4,4); + + Collection col1 = new java.util.HashSet(); + col1.add(p1); + col1.add(p2); + + try { + pm.deletePersistentAll(col1); + fail(ASSERTION_FAILED, + "pm.deletePersistent(Collection) with transient instance(s) should throw exception"); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /* test deletePersistentAll (Object[] o) */ + private void runTestDeletePersistentAll2() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + PCPoint p1 = new PCPoint (3,3); + PCPoint p2 = new PCPoint (4,4); + + Collection col1 = new java.util.HashSet(); + col1.add(p1); + col1.add(p2); + + try { + pm.deletePersistentAll(col1.toArray()); + fail(ASSERTION_FAILED, + "pm.deletePersistent(Object[]) with transient instance(s) should throw exception"); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager.java index c5a9ab258..924416009 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager.java @@ -5,160 +5,176 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import java.util.Collection; import java.util.HashSet; + import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: DeletePersistent Fails If Instance Managed By Another PersistenceManager
    - * Keywords: exception
    - * Assertion IDs: A12.5.7-11.
    - * Assertion Description: PersistenceManager.deletePersistent and deletePersistentAll will - * throw a JDOUserException if the parameter instance is managed by a different PersistenceManager. - */ -public class DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager - extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-11 (DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; + *Title: DeletePersistent Fails If Instance Managed By Another PersistenceManager + *
    + *Keywords: exception + *
    + *Assertion IDs: A12.5.7-11. + *
    + *Assertion Description: + PersistenceManager.deletePersistent and deletePersistentAll will throw a JDOUserException if the parameter instance is managed by a different PersistenceManager. - /** */ - public void testDeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager() { - pm = getPM(); - PersistenceManager pm2 = getPMF().getPersistenceManager(); - try { - createObjects(pm2); + */ - /* positive tests */ - runTestDeletePersistent(pm); - runTestDeletePersistentAll1(pm); - runTestDeletePersistentAll2(pm); - } finally { - cleanupPM(pm2); - pm2 = null; - cleanupPM(pm); - pm = null; +public class DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-11 (DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager.class); } - } - - /** */ - private void createObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - pm.makePersistent(p1); - pm.makePersistent(p2); - pm.makePersistent(p3); - pm.makePersistent(p4); - pm.makePersistent(p5); - tx.commit(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + + /** */ + public void testDeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager() { + pm = getPM(); + PersistenceManager pm2 = getPMF().getPersistenceManager(); + try { + createObjects(pm2); + + /* positive tests */ + runTestDeletePersistent(pm); + runTestDeletePersistentAll1(pm); + runTestDeletePersistentAll2(pm); + } + finally { + cleanupPM(pm2); + pm2 = null; + cleanupPM(pm); + pm = null; + } } - } - - /* test deletePersistent (Object pc) */ - private void runTestDeletePersistent(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - try { - pm.deletePersistent(p1); - fail( - ASSERTION_FAILED, - "pm.deletePersistent(Object) with pc instance managed by another pm should throw exception"); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - } finally { - if (tx.isActive()) tx.rollback(); + + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint(5,7); + + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + pm.makePersistent(p5); + tx.commit(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /* test deletePersistentAll (Collection pcs) */ - private void runTestDeletePersistentAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Collection col1 = new HashSet(); - col1.add(p2); - col1.add(p3); - - try { - pm.deletePersistentAll(col1); - fail( - ASSERTION_FAILED, - "pm.deletePersistent(Collection) with pc instance(s) managed by another pm should throw exception"); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - } finally { - if (tx.isActive()) tx.rollback(); + /* test deletePersistent (Object pc) */ + private void runTestDeletePersistent(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + try { + pm.deletePersistent(p1); + fail(ASSERTION_FAILED, + "pm.deletePersistent(Object) with pc instance managed by another pm should throw exception"); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /* test deletePersistentAll (Collection pcs) */ + private void runTestDeletePersistentAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 = new HashSet(); + col1.add(p2); + col1.add(p3); + + try { + pm.deletePersistentAll(col1); + fail(ASSERTION_FAILED, + "pm.deletePersistent(Collection) with pc instance(s) managed by another pm should throw exception"); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } } - } - - /* test deletePersistentAll (Object[] o) */ - private void runTestDeletePersistentAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Collection col1 = new HashSet(); - col1.add(p4); - col1.add(p5); - Object[] obj1 = col1.toArray(); - try { - pm.deletePersistentAll(obj1); - fail( - ASSERTION_FAILED, - "pm.deletePersistent(Object[]) with pc instance(s) managed by another pm should throw exception"); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - } finally { - if (tx.isActive()) tx.rollback(); + /* test deletePersistentAll (Object[] o) */ + private void runTestDeletePersistentAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 = new HashSet(); + col1.add(p4); + col1.add(p5); + Object[] obj1= col1.toArray(); + try { + pm.deletePersistentAll(obj1); + fail(ASSERTION_FAILED, + "pm.deletePersistent(Object[]) with pc instance(s) managed by another pm should throw exception"); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentHasNoEffectOnDeletedInstances.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentHasNoEffectOnDeletedInstances.java index 00746c7a3..1f55a16e6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentHasNoEffectOnDeletedInstances.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentHasNoEffectOnDeletedInstances.java @@ -5,143 +5,158 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: DeletePersistent Has No Effect On Deleted Instances
    - * Keywords:
    - * Assertion IDs: A12.5.7-10.
    - * Assertion Description: PersistenceManager.deletePersistent and deletePersistentAll have - * no effect on parameter instances already deleted in the transaction. + *Title: DeletePersistent Has No Effect On Deleted Instances + *
    + *Keywords: + *
    + *Assertion IDs: A12.5.7-10. + *
    + *Assertion Description: + PersistenceManager.deletePersistent and deletePersistentAll have no effect on parameter instances already deleted in the transaction. + */ + public class DeletePersistentHasNoEffectOnDeletedInstances extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-10 (DeletePersistentHasNoEffectOnDeletedInstances) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DeletePersistentHasNoEffectOnDeletedInstances.class); + } + + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + + /** */ + public void testDeletePersistentHasNoEffectOnDeletedInstances() { + pm = getPM(); + createObjects(pm); + runTestDeletePersistent(pm); + runTestDeletePersistentAll1(pm); + runTestDeletePersistentAll2(pm); + pm.close(); + pm = null; + } - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-10 (DeletePersistentHasNoEffectOnDeletedInstances) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DeletePersistentHasNoEffectOnDeletedInstances.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - - /** */ - public void testDeletePersistentHasNoEffectOnDeletedInstances() { - pm = getPM(); - createObjects(pm); - runTestDeletePersistent(pm); - runTestDeletePersistentAll1(pm); - runTestDeletePersistentAll2(pm); - pm.close(); - pm = null; - } - - /** */ - private void createObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - - pm.makePersistent(p1); - pm.makePersistent(p2); - pm.makePersistent(p3); - pm.makePersistent(p4); - pm.makePersistent(p5); - - tx.commit(); - } finally { - if (tx.isActive()) tx.rollback(); + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint(5,7); + + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + pm.makePersistent(p5); + + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } } - } - - /* test makePersistent (Object pc) */ - private void runTestDeletePersistent(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - pm.deletePersistent(p1); - pm.deletePersistent(p1); - pm.deletePersistent(p1); - pm.deletePersistent(p1); - tx.commit(); - if (debug) logger.debug(" \nPASSED in testDeletePersistent()"); - } finally { - if (tx.isActive()) tx.rollback(); + + /* test makePersistent (Object pc) */ + private void runTestDeletePersistent(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + pm.deletePersistent(p1); + pm.deletePersistent(p1); + pm.deletePersistent(p1); + pm.deletePersistent(p1); + tx.commit(); + if (debug) logger.debug(" \nPASSED in testDeletePersistent()"); + } + finally { + if (tx.isActive()) + tx.rollback(); + } } - } - - /* test makePersistentAll (Collection pcs) */ - private void runTestDeletePersistentAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx = pm.currentTransaction(); - - Collection col1 = new java.util.HashSet(); - col1.add(p2); - col1.add(p3); - - tx.begin(); - pm.deletePersistentAll(col1); - pm.deletePersistentAll(col1); - pm.deletePersistentAll(col1); - pm.deletePersistentAll(col1); - tx.commit(); - if (debug) logger.debug(" \nPASSED in testDeletePersistentAll1()"); - } finally { - if (tx.isActive()) tx.rollback(); + + /* test makePersistentAll (Collection pcs) */ + private void runTestDeletePersistentAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx = pm.currentTransaction(); + + Collection col1 = new java.util.HashSet(); + col1.add(p2); + col1.add(p3); + + tx.begin(); + pm.deletePersistentAll(col1); + pm.deletePersistentAll(col1); + pm.deletePersistentAll(col1); + pm.deletePersistentAll(col1); + tx.commit(); + if (debug) logger.debug(" \nPASSED in testDeletePersistentAll1()"); + } + finally { + if (tx.isActive()) + tx.rollback(); + } } - } - - /* test makePersistentAll (Object[] o) */ - private void runTestDeletePersistentAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - Collection col1 = new java.util.HashSet(); - col1.add(p4); - col1.add(p5); - - Object[] obj1 = col1.toArray(); - - tx.begin(); - pm.deletePersistentAll(obj1); - pm.deletePersistentAll(obj1); - pm.deletePersistentAll(obj1); - pm.deletePersistentAll(obj1); - tx.commit(); - if (debug) logger.debug(" \nPASSED in testDeletePersistentAll2()"); - } finally { - if (tx.isActive()) tx.rollback(); + + /* test makePersistentAll (Object[] o) */ + private void runTestDeletePersistentAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + Collection col1 = new java.util.HashSet(); + col1.add(p4); + col1.add(p5); + + Object[] obj1= col1.toArray(); + + tx.begin(); + pm.deletePersistentAll(obj1); + pm.deletePersistentAll(obj1); + pm.deletePersistentAll(obj1); + pm.deletePersistentAll(obj1); + tx.commit(); + if (debug) logger.debug(" \nPASSED in testDeletePersistentAll2()"); + } + finally { + if (tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetPersistenceManagerFactory.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetPersistenceManagerFactory.java index f4b6b4b0e..0395ff314 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetPersistenceManagerFactory.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetPersistenceManagerFactory.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,41 +19,49 @@ import javax.jdo.PersistenceManager; import javax.jdo.PersistenceManagerFactory; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get PersistenceManagerFactory
    - * Keywords:
    - * Assertion ID: A12.9-1.
    - * Assertion Description: The PersistenceManagerFactory that created a PersistenceManager is - * returned by the method getPersistenceManagerFactory. - */ -public class GetPersistenceManagerFactory extends PersistenceManagerTest { + *Title: Get PersistenceManagerFactory + *
    + *Keywords: + *
    + *Assertion ID: A12.9-1. + *
    + *Assertion Description: +The PersistenceManagerFactory that created a +PersistenceManager is returned by the method getPersistenceManagerFactory. - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.9-1 (GetPersistenceManagerFactory) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPersistenceManagerFactory.class); - } + */ - /** */ - public void testGetPersistenceManagerFactory() { - PersistenceManagerFactory pmf = getPMF(); - // Note, getPM uses the pmf returned by getPMF - PersistenceManager pm = getPM(); - PersistenceManagerFactory pmf2 = pm.getPersistenceManagerFactory(); - pm.close(); - if (pmf2 != pmf) { - fail( - ASSERTION_FAILED, - "pm.getPMF() returned different pmf, expected " + pmf + ", got " + pmf2); +public class GetPersistenceManagerFactory extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.9-1 (GetPersistenceManagerFactory) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPersistenceManagerFactory.class); + } + + /** */ + public void testGetPersistenceManagerFactory() { + PersistenceManagerFactory pmf = getPMF(); + // Note, getPM uses the pmf returned by getPMF + PersistenceManager pm = getPM(); + PersistenceManagerFactory pmf2 = pm.getPersistenceManagerFactory(); + pm.close(); + if (pmf2 != pmf) { + fail(ASSERTION_FAILED, + "pm.getPMF() returned different pmf, expected " + + pmf + ", got " + pmf2); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetProperties.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetProperties.java index c8a74ae6e..1d35a6dd7 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetProperties.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetProperties.java @@ -5,16 +5,16 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import java.util.Collection; @@ -22,433 +22,327 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import javax.jdo.Constants; + import javax.jdo.PersistenceManager; +import javax.jdo.Constants; + import org.apache.jdo.tck.JDO_Test; + import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Test GetProperties
    - * Keywords: getProperties getSupportedProperties setProperty
    - * Assertion IDs:
    - * Assertion Description: + *Title: Test GetProperties + *
    + *Keywords: getProperties getSupportedProperties setProperty + *
    + *Assertion IDs: + *
    + *Assertion Description: */ -public class GetProperties extends JDO_Test implements Constants { - /** */ - private static final String ASSERTION_FAILED_12_19_1 = - "Assertion 12.19-1 setProperty() " - + "If a vendor-specific property is not recognized, it is silently ignored.\n"; - - private static final String ASSERTION_FAILED_12_19_2 = - "Assertion 12.19-2 setProperty() If the value for the property is not supported by the implementation, " - + "a JDOUserException is thrown.\n"; - private static final String ASSERTION_FAILED_12_19_3 = - "Assertion 12.19-3 setProperty() " - + "Property names might exactly match the names of the properties in javax.jdo.Constants " - + "or might differ in case only.\n"; - private static final String ASSERTION_FAILED_12_19_4 = - "Assertion 12.19-4 setProperty() " - + "Properties of the transaction associated with a persistence manager " - + "can be accessed via the named property in javax.jdo.Constants.\n"; - private static final String ASSERTION_FAILED_12_19_5 = - "Assertion 12.19-5 getProperties() " - + "getProperties() Return a map of String, " - + "Object with the properties and values currently in effect.\n"; - private static final String ASSERTION_FAILED_12_19_6 = - "Assertion 12.19-6 Changing the values in the map will not affect the properties in the PersistenceManager. "; - private static final String ASSERTION_FAILED_12_19_7 = - "Assertion 12.19-7 getSupportedProperties() Return the set of properties " - + "supported by this PersistenceManager.\n"; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetProperties.class); - } - - public void localSetUp() { - getPM(); - } - - public void localTearDown() { - // the PM is left in an unknown state due to setting properties so it must be cleaned up - cleanupPM(); - } - - private Collection supportedOptions; - private Set supportedProperties; - private static Set testRequiredProperties = new HashSet(); - private static Map> testOptionalProperties = - new HashMap>(); - - private interface TestProperty { - void test(PersistenceManager pm, Set supportedProperties); - - Object get(PersistenceManager pm); - - void set(PersistenceManager pm, Object value); - - void setMessageForNullResult(String messageForNullResult); - - void setMessageForWrongResultAfterSet(String messageForWrongResultAfterSet); - } - - abstract class AbstractTestProperty implements TestProperty { - String propertyName; - Object testValue1; - Object testValue2; - protected String messageForNullResult = ASSERTION_FAILED_12_19_5; - protected String messageForWrongResultAfterSet = ASSERTION_FAILED_12_19_5; - - AbstractTestProperty(String propertyName, Object testValue1, Object testValue2) { - this.propertyName = propertyName; - this.testValue1 = testValue1; - this.testValue2 = testValue2; - } - - public void setMessageForNullResult(String messageForNullResult) { - this.messageForNullResult = messageForNullResult; - } +public class GetProperties extends JDO_Test implements Constants { - public void setMessageForWrongResultAfterSet(String messageForWrongResultAfterSet) { - this.messageForWrongResultAfterSet = messageForWrongResultAfterSet; - } - } - - /** - * For each non-api supported property, getProperty(XXX) should return a value setProperty(XXX, - * value1) should succeed getProperties() should return value1 setProperty(XXX, value2) should - * succeed getProperties() should return value2 - */ - abstract class AbstractNonAPITestProperty extends AbstractTestProperty { - AbstractNonAPITestProperty(String propertyName, Object testValue1, Object testValue2) { - super(propertyName, testValue1, testValue2); + /** */ + private static final String ASSERTION_FAILED_12_19_1 = + "Assertion 12.19-1 setProperty() " + + "If a vendor-specific property is not recognized, it is silently ignored.\n"; + private static final String ASSERTION_FAILED_12_19_2 = + "Assertion 12.19-2 setProperty() If the value for the property is not supported by the implementation, " + + "a JDOUserException is thrown.\n"; + private static final String ASSERTION_FAILED_12_19_3 = + "Assertion 12.19-3 setProperty() " + + "Property names might exactly match the names of the properties in javax.jdo.Constants " + + "or might differ in case only.\n"; + private static final String ASSERTION_FAILED_12_19_4 = + "Assertion 12.19-4 setProperty() " + + "Properties of the transaction associated with a persistence manager " + + "can be accessed via the named property in javax.jdo.Constants.\n"; + private static final String ASSERTION_FAILED_12_19_5 = + "Assertion 12.19-5 getProperties() " + + "getProperties() Return a map of String, " + + "Object with the properties and values currently in effect.\n"; + private static final String ASSERTION_FAILED_12_19_6 = + "Assertion 12.19-6 Changing the values in the map will not affect the properties in the PersistenceManager. "; + private static final String ASSERTION_FAILED_12_19_7 = + "Assertion 12.19-7 getSupportedProperties() Return the set of properties " + + "supported by this PersistenceManager.\n"; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetProperties.class); } - public Object get(PersistenceManager pm) { - throw new RuntimeException("not implemented"); + public void localSetUp() { + getPM(); } - ; - public void set(PersistenceManager pm, Object value) { - throw new RuntimeException("not implemented"); - } - ; - - public void test(PersistenceManager pm, Set supportedProperties) { - Object result0 = pm.getProperties().get(propertyName); - errorIfEqual( - this.messageForNullResult + "getProperties().get(" + propertyName + ")", null, result0); - pm.setProperty(propertyName, testValue1); - Object result1 = pm.getProperties().get(propertyName); - errorIfNotEqual( - this.messageForWrongResultAfterSet - + "after pm.setProperty(" - + propertyName - + ", " - + testValue1 - + "), getProperties().get(" - + propertyName - + ")", - testValue1, - result1); - - pm.setProperty(propertyName, testValue2); - Object result2 = pm.getProperties().get(propertyName); - errorIfNotEqual( - this.messageForWrongResultAfterSet - + "after pm.setProperty(" - + propertyName - + ", " - + testValue2 - + "), getProperties().get(" - + propertyName - + ")", - testValue2, - result2); - } - } - - /** - * For each api supported property, and for each of two values getProperty(XXX) should return a - * value setProperty(XXX, value1) should succeed getXXX() should return value1 setXXX(value2) - * should succeed getProperties() should return value2 - */ - abstract class AbstractAPITestProperty extends AbstractTestProperty { - AbstractAPITestProperty(String propertyName, Object testValue1, Object testValue2) { - super(propertyName, testValue1, testValue2); + public void localTearDown() { + // the PM is left in an unknown state due to setting properties so it must be cleaned up + cleanupPM(); } - public void test(PersistenceManager pm, Set supportedProperties) { - Object result0 = pm.getProperties().get(propertyName); - errorIfEqual( - this.messageForNullResult + "getProperties().get(" + propertyName + ")", null, result0); - pm.setProperty(propertyName, testValue1); - Object result1 = get(pm); - errorIfNotEqual( - this.messageForWrongResultAfterSet - + "after pm.setProperty(" - + propertyName - + ", " - + testValue1 - + "), getXXX for " - + propertyName, - testValue1, - result1); - - set(pm, testValue2); - Object result2 = pm.getProperties().get(propertyName); - errorIfNotEqual( - this.messageForWrongResultAfterSet - + "after pm.setXXX(), getProperties.get(" - + propertyName - + ")", - testValue2, - result2); + private Collection supportedOptions; + private Set supportedProperties; + private static Set testRequiredProperties = new HashSet(); + private static Map> testOptionalProperties = new HashMap>(); + + private interface TestProperty { + void test(PersistenceManager pm, Set supportedProperties); + Object get(PersistenceManager pm); + void set(PersistenceManager pm, Object value); + void setMessageForNullResult(String messageForNullResult); + void setMessageForWrongResultAfterSet(String messageForWrongResultAfterSet); } - } - ; - private TestProperty testCopyOnAttach = - new AbstractAPITestProperty(PROPERTY_COPY_ON_ATTACH, true, false) { - public Object get(PersistenceManager pm) { - return pm.getCopyOnAttach(); + abstract class AbstractTestProperty implements TestProperty { + String propertyName; + Object testValue1; + Object testValue2; + protected String messageForNullResult = ASSERTION_FAILED_12_19_5; + protected String messageForWrongResultAfterSet = ASSERTION_FAILED_12_19_5; + AbstractTestProperty(String propertyName, Object testValue1, Object testValue2) { + this.propertyName = propertyName; + this.testValue1 = testValue1; + this.testValue2 = testValue2; } - - public void set(PersistenceManager pm, Object value) { - pm.setCopyOnAttach((Boolean) value); + public void setMessageForNullResult(String messageForNullResult) { + this.messageForNullResult = messageForNullResult; } - }; - - private TestProperty testDatastoreReadTimeoutMillis = - new AbstractAPITestProperty(PROPERTY_DATASTORE_READ_TIMEOUT_MILLIS, 20, 40) { - public Object get(PersistenceManager pm) { - return pm.getDatastoreReadTimeoutMillis(); - } - - public void set(PersistenceManager pm, Object value) { - pm.setDatastoreReadTimeoutMillis((Integer) value); - } - }; - - private TestProperty testDatastoreWriteTimeoutMillis = - new AbstractAPITestProperty(PROPERTY_DATASTORE_WRITE_TIMEOUT_MILLIS, 60, 80) { - public Object get(PersistenceManager pm) { - return pm.getDatastoreWriteTimeoutMillis(); - } - - public void set(PersistenceManager pm, Object value) { - pm.setDatastoreWriteTimeoutMillis((Integer) value); - } - }; - - private TestProperty testMultithreaded = - new AbstractAPITestProperty(PROPERTY_MULTITHREADED, true, false) { - public Object get(PersistenceManager pm) { - return pm.getMultithreaded(); - } - - public void set(PersistenceManager pm, Object value) { - pm.setMultithreaded((Boolean) value); - } - }; - - private TestProperty testLowerCaseMultithreaded = - new AbstractAPITestProperty(PROPERTY_MULTITHREADED, true, false) { - public Object get(PersistenceManager pm) { - return pm.getMultithreaded(); - } - - public void set(PersistenceManager pm, Object value) { - pm.setProperty("javax.jdo.option.multithreaded", (Boolean) value); - } - }; - - private TestProperty testUpperCaseMultithreaded = - new AbstractAPITestProperty(PROPERTY_MULTITHREADED, true, false) { - public Object get(PersistenceManager pm) { - return pm.getMultithreaded(); - } - - public void set(PersistenceManager pm, Object value) { - pm.setProperty("javax.jdo.option.MULTITHREADED", (Boolean) value); - } - }; - - private TestProperty testDetachAllOnCommit = - new AbstractAPITestProperty(PROPERTY_DETACH_ALL_ON_COMMIT, true, false) { - public Object get(PersistenceManager pm) { - return pm.getDetachAllOnCommit(); - } - - public void set(PersistenceManager pm, Object value) { - pm.setDetachAllOnCommit((Boolean) value); - } - }; - - private TestProperty testIgnoreCache = - new AbstractAPITestProperty(PROPERTY_IGNORE_CACHE, true, false) { - public Object get(PersistenceManager pm) { - return pm.getIgnoreCache(); + public void setMessageForWrongResultAfterSet(String messageForWrongResultAfterSet) { + this.messageForWrongResultAfterSet = messageForWrongResultAfterSet; } + } - public void set(PersistenceManager pm, Object value) { - pm.setIgnoreCache((Boolean) value); + /** For each non-api supported property, + * getProperty(XXX) should return a value + * setProperty(XXX, value1) should succeed + * getProperties() should return value1 + * setProperty(XXX, value2) should succeed + * getProperties() should return value2 + */ + abstract class AbstractNonAPITestProperty extends AbstractTestProperty { + AbstractNonAPITestProperty(String propertyName, Object testValue1, Object testValue2) { + super(propertyName, testValue1, testValue2); } - }; - - private TestProperty testOptimistic = - new AbstractAPITestProperty(PROPERTY_OPTIMISTIC, true, false) { - public Object get(PersistenceManager pm) { - return pm.currentTransaction().getOptimistic(); + public Object get(PersistenceManager pm) {throw new RuntimeException("not implemented");}; + public void set(PersistenceManager pm, Object value) {throw new RuntimeException("not implemented");}; + public void test(PersistenceManager pm, Set supportedProperties) { + Object result0 = pm.getProperties().get(propertyName); + errorIfEqual(this.messageForNullResult + "getProperties().get(" + propertyName + ")", null, result0); + pm.setProperty(propertyName, testValue1); + Object result1 = pm.getProperties().get(propertyName); + errorIfNotEqual(this.messageForWrongResultAfterSet + "after pm.setProperty(" + propertyName + ", " + testValue1 + "), getProperties().get(" + propertyName + ")", + testValue1, result1); + + pm.setProperty(propertyName, testValue2); + Object result2 = pm.getProperties().get(propertyName); + errorIfNotEqual(this.messageForWrongResultAfterSet + "after pm.setProperty(" + propertyName + ", " + testValue2 + "), getProperties().get(" + propertyName + ")", + testValue2, result2); } + } - public void set(PersistenceManager pm, Object value) { - pm.currentTransaction().setOptimistic((Boolean) value); + /** For each api supported property, and for each of two values + * getProperty(XXX) should return a value + * setProperty(XXX, value1) should succeed + * getXXX() should return value1 + * setXXX(value2) should succeed + * getProperties() should return value2 + */ + abstract class AbstractAPITestProperty extends AbstractTestProperty { + AbstractAPITestProperty(String propertyName, Object testValue1, Object testValue2) { + super(propertyName, testValue1, testValue2); } - }; - - private TestProperty testRetainValues = - new AbstractAPITestProperty(PROPERTY_RETAIN_VALUES, true, false) { - public Object get(PersistenceManager pm) { - return pm.currentTransaction().getRetainValues(); + public void test(PersistenceManager pm, Set supportedProperties) { + Object result0 = pm.getProperties().get(propertyName); + errorIfEqual(this.messageForNullResult + "getProperties().get(" + propertyName + ")", null, result0); + pm.setProperty(propertyName, testValue1); + Object result1 = get(pm); + errorIfNotEqual(this.messageForWrongResultAfterSet + "after pm.setProperty(" + propertyName + ", " + testValue1 + "), getXXX for " + propertyName, + testValue1, result1); + + set(pm, testValue2); + Object result2 = pm.getProperties().get(propertyName); + errorIfNotEqual(this.messageForWrongResultAfterSet + "after pm.setXXX(), getProperties.get(" + propertyName + ")", + testValue2, result2); } - - public void set(PersistenceManager pm, Object value) { - pm.currentTransaction().setRetainValues((Boolean) value); + }; + + private TestProperty testCopyOnAttach = + new AbstractAPITestProperty(PROPERTY_COPY_ON_ATTACH, true, false) { + public Object get(PersistenceManager pm) {return pm.getCopyOnAttach();} + public void set(PersistenceManager pm, Object value) {pm.setCopyOnAttach((Boolean) value);} + }; + + private TestProperty testDatastoreReadTimeoutMillis = + new AbstractAPITestProperty(PROPERTY_DATASTORE_READ_TIMEOUT_MILLIS, 20, 40) { + public Object get(PersistenceManager pm) {return pm.getDatastoreReadTimeoutMillis();} + public void set(PersistenceManager pm, Object value) {pm.setDatastoreReadTimeoutMillis((Integer) value);} + }; + + private TestProperty testDatastoreWriteTimeoutMillis = + new AbstractAPITestProperty(PROPERTY_DATASTORE_WRITE_TIMEOUT_MILLIS, 60, 80) { + public Object get(PersistenceManager pm) {return pm.getDatastoreWriteTimeoutMillis();} + public void set(PersistenceManager pm, Object value) {pm.setDatastoreWriteTimeoutMillis((Integer) value);} + }; + + private TestProperty testMultithreaded = + new AbstractAPITestProperty(PROPERTY_MULTITHREADED, true, false) { + public Object get(PersistenceManager pm) {return pm.getMultithreaded();} + public void set(PersistenceManager pm, Object value) {pm.setMultithreaded((Boolean) value);} + }; + + private TestProperty testLowerCaseMultithreaded = + new AbstractAPITestProperty(PROPERTY_MULTITHREADED, true, false) { + public Object get(PersistenceManager pm) {return pm.getMultithreaded();} + public void set(PersistenceManager pm, Object value) {pm.setProperty("javax.jdo.option.multithreaded", (Boolean) value);} + }; + + private TestProperty testUpperCaseMultithreaded = + new AbstractAPITestProperty(PROPERTY_MULTITHREADED, true, false) { + public Object get(PersistenceManager pm) {return pm.getMultithreaded();} + public void set(PersistenceManager pm, Object value) {pm.setProperty("javax.jdo.option.MULTITHREADED", (Boolean) value);} +}; + + private TestProperty testDetachAllOnCommit = + new AbstractAPITestProperty(PROPERTY_DETACH_ALL_ON_COMMIT, true, false) { + public Object get(PersistenceManager pm) {return pm.getDetachAllOnCommit();} + public void set(PersistenceManager pm, Object value) {pm.setDetachAllOnCommit((Boolean) value);} + }; + + private TestProperty testIgnoreCache = + new AbstractAPITestProperty(PROPERTY_IGNORE_CACHE, true, false) { + public Object get(PersistenceManager pm) {return pm.getIgnoreCache();} + public void set(PersistenceManager pm, Object value) {pm.setIgnoreCache((Boolean) value);} + }; + + private TestProperty testOptimistic = + new AbstractAPITestProperty(PROPERTY_OPTIMISTIC, true, false) { + public Object get(PersistenceManager pm) {return pm.currentTransaction().getOptimistic();} + public void set(PersistenceManager pm, Object value) {pm.currentTransaction().setOptimistic((Boolean) value);} + }; + + private TestProperty testRetainValues = + new AbstractAPITestProperty(PROPERTY_RETAIN_VALUES, true, false) { + public Object get(PersistenceManager pm) {return pm.currentTransaction().getRetainValues();} + public void set(PersistenceManager pm, Object value) {pm.currentTransaction().setRetainValues((Boolean) value);} + }; + + private TestProperty testRestoreValues = + new AbstractAPITestProperty(PROPERTY_RESTORE_VALUES, true, false) { + public Object get(PersistenceManager pm) {return pm.currentTransaction().getRestoreValues();} + public void set(PersistenceManager pm, Object value) {pm.currentTransaction().setRestoreValues((Boolean) value);} + }; + + private TestProperty testNontransactionalRead = + new AbstractAPITestProperty(PROPERTY_NONTRANSACTIONAL_READ, true, false) { + public Object get(PersistenceManager pm) {return pm.currentTransaction().getNontransactionalRead();} + public void set(PersistenceManager pm, Object value) {pm.currentTransaction().setNontransactionalRead((Boolean) value);} + }; + + private TestProperty testNontransactionalWrite = + new AbstractAPITestProperty(PROPERTY_NONTRANSACTIONAL_WRITE, true, false) { + public Object get(PersistenceManager pm) {return pm.currentTransaction().getNontransactionalWrite();} + public void set(PersistenceManager pm, Object value) {pm.currentTransaction().setNontransactionalWrite((Boolean) value);} + }; + + private TestProperty testIllegalArgument = + new AbstractNonAPITestProperty(PROPERTY_IGNORE_CACHE, 1, false) { + }; + + private Set setOf(TestProperty... testPropertys) { + Set result = new HashSet(); + for (TestProperty testProperty: testPropertys) { + result.add(testProperty); } - }; + return result; + } - private TestProperty testRestoreValues = - new AbstractAPITestProperty(PROPERTY_RESTORE_VALUES, true, false) { - public Object get(PersistenceManager pm) { - return pm.currentTransaction().getRestoreValues(); + /** + * For each option supported by the PMF, test that + * the corresponding pm property is supported. + */ + public void testGetSupportedProperties() { + testRequiredProperties.add(testCopyOnAttach); + testRequiredProperties.add(testDetachAllOnCommit); + testRequiredProperties.add(testIgnoreCache); + testRestoreValues.setMessageForWrongResultAfterSet(ASSERTION_FAILED_12_19_4); + testRequiredProperties.add(testRestoreValues); + + testLowerCaseMultithreaded.setMessageForWrongResultAfterSet(ASSERTION_FAILED_12_19_3); + testUpperCaseMultithreaded.setMessageForWrongResultAfterSet(ASSERTION_FAILED_12_19_3); + testOptionalProperties.put(PROPERTY_MULTITHREADED, setOf(testMultithreaded, testLowerCaseMultithreaded, + testUpperCaseMultithreaded)); + testOptionalProperties.put(OPTION_DATASTORE_TIMEOUT, + setOf(testDatastoreReadTimeoutMillis, testDatastoreWriteTimeoutMillis)); + + testOptimistic.setMessageForWrongResultAfterSet(ASSERTION_FAILED_12_19_4); + testOptionalProperties.put(PROPERTY_OPTIMISTIC, setOf(testOptimistic)); + testRetainValues.setMessageForWrongResultAfterSet(ASSERTION_FAILED_12_19_4); + testOptionalProperties.put(PROPERTY_RETAIN_VALUES, setOf(testRetainValues)); + testNontransactionalRead.setMessageForWrongResultAfterSet(ASSERTION_FAILED_12_19_4); + testOptionalProperties.put(PROPERTY_NONTRANSACTIONAL_READ, setOf(testNontransactionalRead)); + testNontransactionalWrite.setMessageForWrongResultAfterSet(ASSERTION_FAILED_12_19_4); + testOptionalProperties.put(PROPERTY_NONTRANSACTIONAL_WRITE, setOf(testNontransactionalWrite)); + + supportedOptions = pmf.supportedOptions(); + for (String supportedOption: supportedOptions) { + System.out.println("supportedOptions returned: " + supportedOption); } - public void set(PersistenceManager pm, Object value) { - pm.currentTransaction().setRestoreValues((Boolean) value); + supportedProperties = pm.getSupportedProperties(); + errorIfEqual(ASSERTION_FAILED_12_19_7, null, supportedProperties); + for (String supportedProperty: supportedProperties) { + System.out.println("supportedProperties returned: " + supportedProperty); } - }; - private TestProperty testNontransactionalRead = - new AbstractAPITestProperty(PROPERTY_NONTRANSACTIONAL_READ, true, false) { - public Object get(PersistenceManager pm) { - return pm.currentTransaction().getNontransactionalRead(); + // test required properties + for (TestProperty testProperty: testRequiredProperties) { + testProperty.test(pm, supportedProperties); } - - public void set(PersistenceManager pm, Object value) { - pm.currentTransaction().setNontransactionalRead((Boolean) value); + + Set> properties = pm.getProperties().entrySet(); + for (Map.Entry entry: properties) { + System.out.println("getProperties returned: " + entry.getKey() + ": " + entry.getValue()); } - }; - private TestProperty testNontransactionalWrite = - new AbstractAPITestProperty(PROPERTY_NONTRANSACTIONAL_WRITE, true, false) { - public Object get(PersistenceManager pm) { - return pm.currentTransaction().getNontransactionalWrite(); + // for each supported option, test the corresponding supported property + for (String supportedOption: supportedOptions) { + Set supportedOptionTestList = testOptionalProperties.get(supportedOption); + if (supportedOptionTestList != null) { + System.out.println("testing " + supportedOption); + for (TestProperty supportedOptionTest: supportedOptionTestList) { + supportedOptionTest.test(pm, supportedProperties); + } + } } - public void set(PersistenceManager pm, Object value) { - pm.currentTransaction().setNontransactionalWrite((Boolean) value); + try { + testIllegalArgument.test(pm, supportedProperties); + appendMessage(ASSERTION_FAILED_12_19_2 + "setProperty(PROPERTY_IGNORE_CACHE, 1) failed: " + + "Illegal argument PROPERTY_IGNORE_CACHE failed to throw an exception."); + } catch (Throwable t) { + // good catch } - }; - - private TestProperty testIllegalArgument = - new AbstractNonAPITestProperty(PROPERTY_IGNORE_CACHE, 1, false) {}; - - private Set setOf(TestProperty... testPropertys) { - Set result = new HashSet(); - for (TestProperty testProperty : testPropertys) { - result.add(testProperty); - } - return result; - } - - /** For each option supported by the PMF, test that the corresponding pm property is supported. */ - public void testGetSupportedProperties() { - testRequiredProperties.add(testCopyOnAttach); - testRequiredProperties.add(testDetachAllOnCommit); - testRequiredProperties.add(testIgnoreCache); - testRestoreValues.setMessageForWrongResultAfterSet(ASSERTION_FAILED_12_19_4); - testRequiredProperties.add(testRestoreValues); - - testLowerCaseMultithreaded.setMessageForWrongResultAfterSet(ASSERTION_FAILED_12_19_3); - testUpperCaseMultithreaded.setMessageForWrongResultAfterSet(ASSERTION_FAILED_12_19_3); - testOptionalProperties.put( - PROPERTY_MULTITHREADED, - setOf(testMultithreaded, testLowerCaseMultithreaded, testUpperCaseMultithreaded)); - testOptionalProperties.put( - OPTION_DATASTORE_TIMEOUT, - setOf(testDatastoreReadTimeoutMillis, testDatastoreWriteTimeoutMillis)); - - testOptimistic.setMessageForWrongResultAfterSet(ASSERTION_FAILED_12_19_4); - testOptionalProperties.put(PROPERTY_OPTIMISTIC, setOf(testOptimistic)); - testRetainValues.setMessageForWrongResultAfterSet(ASSERTION_FAILED_12_19_4); - testOptionalProperties.put(PROPERTY_RETAIN_VALUES, setOf(testRetainValues)); - testNontransactionalRead.setMessageForWrongResultAfterSet(ASSERTION_FAILED_12_19_4); - testOptionalProperties.put(PROPERTY_NONTRANSACTIONAL_READ, setOf(testNontransactionalRead)); - testNontransactionalWrite.setMessageForWrongResultAfterSet(ASSERTION_FAILED_12_19_4); - testOptionalProperties.put(PROPERTY_NONTRANSACTIONAL_WRITE, setOf(testNontransactionalWrite)); - - supportedOptions = pmf.supportedOptions(); - for (String supportedOption : supportedOptions) { - System.out.println("supportedOptions returned: " + supportedOption); - } - - supportedProperties = pm.getSupportedProperties(); - errorIfEqual(ASSERTION_FAILED_12_19_7, null, supportedProperties); - for (String supportedProperty : supportedProperties) { - System.out.println("supportedProperties returned: " + supportedProperty); - } - // test required properties - for (TestProperty testProperty : testRequiredProperties) { - testProperty.test(pm, supportedProperties); - } - - Set> properties = pm.getProperties().entrySet(); - for (Map.Entry entry : properties) { - System.out.println("getProperties returned: " + entry.getKey() + ": " + entry.getValue()); - } - - // for each supported option, test the corresponding supported property - for (String supportedOption : supportedOptions) { - Set supportedOptionTestList = testOptionalProperties.get(supportedOption); - if (supportedOptionTestList != null) { - System.out.println("testing " + supportedOption); - for (TestProperty supportedOptionTest : supportedOptionTestList) { - supportedOptionTest.test(pm, supportedProperties); + try { + // unknown property should be ignored + pm.setProperty("com.mystery.property", true); + } catch (Throwable t) { + appendMessage(ASSERTION_FAILED_12_19_1 + "Property com.mystery.property threw an exception."); } - } - } - try { - testIllegalArgument.test(pm, supportedProperties); - appendMessage( - ASSERTION_FAILED_12_19_2 - + "setProperty(PROPERTY_IGNORE_CACHE, 1) failed: " - + "Illegal argument PROPERTY_IGNORE_CACHE failed to throw an exception."); - } catch (Throwable t) { - // good catch - } + // changing a property of the returned set of property values must not change the underlying property value + pm.setProperty(PROPERTY_COPY_ON_ATTACH, true); + Map props = pm.getProperties(); + props.put(PROPERTY_COPY_ON_ATTACH, false); + errorIfNotEqual(ASSERTION_FAILED_12_19_6, true, pm.getCopyOnAttach()); - try { - // unknown property should be ignored - pm.setProperty("com.mystery.property", true); - } catch (Throwable t) { - appendMessage(ASSERTION_FAILED_12_19_1 + "Property com.mystery.property threw an exception."); + failOnError(); } - // changing a property of the returned set of property values must not change the underlying - // property value - pm.setProperty(PROPERTY_COPY_ON_ATTACH, true); - Map props = pm.getProperties(); - props.put(PROPERTY_COPY_ON_ATTACH, false); - errorIfNotEqual(ASSERTION_FAILED_12_19_6, true, pm.getCopyOnAttach()); - - failOnError(); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetPutRemoveUserObject.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetPutRemoveUserObject.java index 6f3c6152b..9cd9b673f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetPutRemoveUserObject.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetPutRemoveUserObject.java @@ -5,142 +5,164 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import org.apache.jdo.tck.JDO_Test; + import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Test GetPutRemoveUserObject
    - * Keywords: getUserObject putUserObject removeUserObject
    - * Assertion IDs: A12.11-1
    - * Assertion Description: Object putUserObject(Object key, Object value); This method models - * the put method of Map. The current value associated with the key is returned and replaced by the - * parameter value. If the parameter value is null, the implementation may remove the entry from the - * table of managed key/value pairs Object removeUserObject(Object key); This method models the - * remove method of Map. The current value associated with the key is returned and removed. Object - * getUserObject(Object key); This method models the get method of Map. The current value associated - * with the key is returned. If the key is not found in the table, null is returned.]..] + *Title: Test GetPutRemoveUserObject + *
    + *Keywords: getUserObject putUserObject removeUserObject + *
    + *Assertion IDs: A12.11-1 + *
    + *Assertion Description: + * Object putUserObject(Object key, Object value); This method models + * the put method of Map. The current value associated with the key + * is returned and replaced by the parameter value. + * If the parameter value is null, the implementation may remove + * the entry from the table of managed key/value pairs + * Object removeUserObject(Object key); This method models + * the remove method of Map. The current value associated with the key + * is returned and removed. + * Object getUserObject(Object key); This method models + * the get method of Map. The current value associated with the key + * is returned. If the key is not found in the table, null is returned.]..] */ -public class GetPutRemoveUserObject extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.11-1 (GetPutRemoveUserObject) failed: "; - /** First key */ - private static final String KEY1 = "jdo.tck.key1"; +public class GetPutRemoveUserObject extends JDO_Test { - /** Second key */ - private static final String KEY2 = "jdo.tck.key2"; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.11-1 (GetPutRemoveUserObject) failed: "; - /** Non-existent key */ - private static final String KEY_DOES_NOT_EXIST = "jdo.tck.keyDoesNotExist"; + /** First key + */ + private static final String KEY1 = "jdo.tck.key1"; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPutRemoveUserObject.class); - } + /** Second key + */ + private static final String KEY2 = "jdo.tck.key2"; - /** */ - public void testGetNonexistentKey() { - getPM(); - assertNull( - ASSERTION_FAILED + "Non-null value returned from key that does not exist.", - pm.getUserObject(KEY_DOES_NOT_EXIST)); - } + /** Non-existent key + */ + private static final String KEY_DOES_NOT_EXIST = "jdo.tck.keyDoesNotExist"; - public void testPutKey() { - getPM(); - UserObject obj1p = new UserObject(); - UserObject obj2p = new UserObject(); - UserObject obj3p = new UserObject(); - UserObject obj4p = new UserObject(); - Object obj1pv = pm.putUserObject(KEY1, obj1p); - Object obj2pv = pm.putUserObject(KEY2, obj2p); - Object obj1rv = pm.putUserObject(KEY1, obj3p); - Object obj2rv = pm.putUserObject(KEY2, obj4p); - assertNull( - ASSERTION_FAILED + "putUserObject expected null on first put" + "; actual: " + obj1pv, - obj1pv); - assertSame( - ASSERTION_FAILED - + "putUserObject expected replaced object returned: " - + obj1p - + "; actual: " - + obj1rv, - obj1p, - obj1rv); - assertNull( - ASSERTION_FAILED + "putUserObject expected null on first put" + "; actual: " + obj2pv, - obj2pv); - assertSame( - ASSERTION_FAILED - + "putUserObject expected replaced object returned: " - + obj2p - + "; actual: " - + obj2rv, - obj2p, - obj2rv); - } + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPutRemoveUserObject.class); + } - public void testGetKey() { - getPM(); - UserObject obj1p = new UserObject(); - UserObject obj2p = new UserObject(); - Object obj1pv = pm.putUserObject(KEY1, obj1p); - Object obj2pv = pm.putUserObject(KEY2, obj2p); - Object obj1g = pm.getUserObject(KEY1); - Object obj2g = pm.getUserObject(KEY2); - pm.putUserObject(KEY1, null); - pm.putUserObject(KEY2, null); - assertNull(ASSERTION_FAILED + "putUserObject expected null" + "; actual: " + obj1pv, obj1pv); - assertSame( - ASSERTION_FAILED + "getUserObject expected: " + obj1p + "; actual: " + obj1g, obj1p, obj1g); - assertNull(ASSERTION_FAILED + "putUserObject expected null" + "; actual: " + obj2pv, obj2pv); - assertSame( - ASSERTION_FAILED + "getUserObject expected: " + obj2p + "; actual: " + obj2g, obj2p, obj2g); - } + /** */ + public void testGetNonexistentKey() { + getPM(); + assertNull(ASSERTION_FAILED + + "Non-null value returned from key that does not exist.", + pm.getUserObject(KEY_DOES_NOT_EXIST)); + } - public void testRemoveKey() { - getPM(); - UserObject obj1p = new UserObject(); - UserObject obj2p = new UserObject(); - pm.putUserObject(KEY1, obj1p); - pm.putUserObject(KEY2, obj2p); - Object obj1r = pm.removeUserObject(KEY1); - Object obj1rr = pm.removeUserObject(KEY1); - Object obj2r = pm.removeUserObject(KEY2); - Object obj2rr = pm.removeUserObject(KEY2); - assertSame( - ASSERTION_FAILED + "removeUserObject(KEY1) expected: " + obj1p + "; actual: " + obj1r, - obj1p, - obj1r); - assertNull( - ASSERTION_FAILED + "getUserObject(KEY1) expected null: " + "; actual: " + obj1rr, obj1rr); - assertSame( - ASSERTION_FAILED + "removeUserObject(KEY2) returned: " + obj2p + "; actual: " + obj2r, - obj2p, - obj2r); - assertNull( - ASSERTION_FAILED + "getUserObject(KEY2) expected null: " + "; actual: " + obj2rr, obj2rr); - } + public void testPutKey() { + getPM(); + UserObject obj1p = new UserObject(); + UserObject obj2p = new UserObject(); + UserObject obj3p = new UserObject(); + UserObject obj4p = new UserObject(); + Object obj1pv = pm.putUserObject(KEY1, obj1p); + Object obj2pv = pm.putUserObject(KEY2, obj2p); + Object obj1rv = pm.putUserObject(KEY1, obj3p); + Object obj2rv = pm.putUserObject(KEY2, obj4p); + assertNull(ASSERTION_FAILED + + "putUserObject expected null on first put" + + "; actual: " + obj1pv, + obj1pv); + assertSame(ASSERTION_FAILED + + "putUserObject expected replaced object returned: " + obj1p + + "; actual: " + obj1rv, + obj1p, obj1rv); + assertNull(ASSERTION_FAILED + + "putUserObject expected null on first put" + + "; actual: " + obj2pv, + obj2pv); + assertSame(ASSERTION_FAILED + + "putUserObject expected replaced object returned: " + obj2p + + "; actual: " + obj2rv, + obj2p, obj2rv); + } - private class UserObject { - // No implementation needed for this class. It is only usedwith == comparisons. - } + public void testGetKey() { + getPM(); + UserObject obj1p = new UserObject(); + UserObject obj2p = new UserObject(); + Object obj1pv = pm.putUserObject(KEY1, obj1p); + Object obj2pv = pm.putUserObject(KEY2, obj2p); + Object obj1g = pm.getUserObject(KEY1); + Object obj2g = pm.getUserObject(KEY2); + pm.putUserObject(KEY1, null); + pm.putUserObject(KEY2, null); + assertNull(ASSERTION_FAILED + + "putUserObject expected null" + + "; actual: " + obj1pv, + obj1pv); + assertSame(ASSERTION_FAILED + + "getUserObject expected: " + obj1p + + "; actual: " + obj1g, + obj1p, obj1g); + assertNull(ASSERTION_FAILED + + "putUserObject expected null" + + "; actual: " + obj2pv, + obj2pv); + assertSame(ASSERTION_FAILED + + "getUserObject expected: " + obj2p + + "; actual: " + obj2g, + obj2p, obj2g); + } + + public void testRemoveKey() { + getPM(); + UserObject obj1p = new UserObject(); + UserObject obj2p = new UserObject(); + pm.putUserObject(KEY1, obj1p); + pm.putUserObject(KEY2, obj2p); + Object obj1r = pm.removeUserObject(KEY1); + Object obj1rr = pm.removeUserObject(KEY1); + Object obj2r = pm.removeUserObject(KEY2); + Object obj2rr = pm.removeUserObject(KEY2); + assertSame(ASSERTION_FAILED + + "removeUserObject(KEY1) expected: " + obj1p + + "; actual: " + obj1r, + obj1p, obj1r); + assertNull(ASSERTION_FAILED + + "getUserObject(KEY1) expected null: " + + "; actual: " + obj1rr, + obj1rr); + assertSame(ASSERTION_FAILED + + "removeUserObject(KEY2) returned: " + obj2p + + "; actual: " + obj2r, + obj2p, obj2r); + assertNull(ASSERTION_FAILED + + "getUserObject(KEY2) expected null: " + + "; actual: " + obj2rr, + obj2rr); + } + + private class UserObject { + // No implementation needed for this class. It is only usedwith == comparisons. + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetSetUserObject.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetSetUserObject.java index 3e6aca8c0..7bb2641db 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetSetUserObject.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetSetUserObject.java @@ -5,66 +5,77 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.mylib.Point; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get/Set User Object
    - * Keywords:
    - * Assertion ID: A12.8-1.
    - * Assertion Description: The PersistenceManager.setUserObject method is used to store an - * object associated with the PersistenceManager. One uses the method getUserObject to later - * retrieve the object. - */ -public class GetSetUserObject extends PersistenceManagerTest { + *Title: Get/Set User Object + *
    + *Keywords: + *
    + *Assertion ID: A12.8-1. + *
    + *Assertion Description: +The PersistenceManager.setUserObject method is used to store an object associated with the PersistenceManager. One uses the method getUserObject to later +retrieve the object. - /** */ - private static final String ASSERTION_FAILED = "Assertion A12.8-1 (GetSetUserObject) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetSetUserObject.class); - } + */ - /** */ - public void testGetSetUserObject() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Point p = new Point(10, 10); - pm.setUserObject(p); - tx.commit(); +public class GetSetUserObject extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.8-1 (GetSetUserObject) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetSetUserObject.class); + } - tx.begin(); - Object obj = pm.getUserObject(); + /** */ + public void testGetSetUserObject() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Point p = new Point(10,10); + pm.setUserObject(p); + tx.commit(); - if (obj != p) { - fail(ASSERTION_FAILED, "Unexpected pm user object, expected " + p + ", got " + obj); - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + tx.begin(); + Object obj = pm.getUserObject(); + + if (obj != p) { + fail(ASSERTION_FAILED, + "Unexpected pm user object, expected " + p + ", got " + obj); + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm = null; } - pm.close(); - pm = null; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWhenObjectIdBeingChanged.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWhenObjectIdBeingChanged.java index 706ee38ee..683db99c6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWhenObjectIdBeingChanged.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWhenObjectIdBeingChanged.java @@ -5,76 +5,92 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get Transactional ObjectId When ObjectId Being Changed
    - * Keywords: identity applicationidentity
    - * Assertion ID: A12.5.6-15.
    - * Assertion Description: If the object identity is being changed in the transaction, by the - * application modifying one or more of the application key fields, then - * PersistenceManager.getTransactionalObjectId returns the current identity in the - * transaction. + *Title: Get Transactional ObjectId When ObjectId Being Changed + *
    + *Keywords: identity applicationidentity + *
    + *Assertion ID: A12.5.6-15. + *
    + *Assertion Description: +If the object identity is being changed in the transaction, by the application +modifying one or more of the application key fields, then +PersistenceManager.getTransactionalObjectId returns the current +identity in the transaction. + */ -public class GetTransactionalObjectIdWhenObjectIdBeingChanged extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.6-15 (GetTransactionalObjectIdWhenObjectIdBeingChanged) failed: "; +public class GetTransactionalObjectIdWhenObjectIdBeingChanged extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.6-15 (GetTransactionalObjectIdWhenObjectIdBeingChanged) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetTransactionalObjectIdWhenObjectIdBeingChanged.class); + } - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetTransactionalObjectIdWhenObjectIdBeingChanged.class); - } + /** */ + public void testGetObjectByIdWhenObjectIdBeingChanged() { + if (!isChangeApplicationIdentitySupported()) { + if (debug) + logger.debug("Implementation does not support chaning application identity"); + return; + } - /** */ - public void testGetObjectByIdWhenObjectIdBeingChanged() { - if (!isChangeApplicationIdentitySupported()) { - if (debug) logger.debug("Implementation does not support chaning application identity"); - return; - } - if (debug) logger.debug("\nSTART GetTransactionalObjectIdWhenObjectIdBeingChanged"); - pm = getPM(); - Object oid = createPCPointInstance(pm); - PCPoint p1 = (PCPoint) pm.getObjectById(oid, false); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - p1.setX(10000); // this is the primary key - Object oid2 = pm.getTransactionalObjectId(p1); // should be different - tx.commit(); - Object oid3 = pm.getObjectId(p1); // should be same as oid2 - if (oid.equals(oid2)) { - fail(ASSERTION_FAILED, "Oid before is the same as transactional oid after modifying pk"); - } + if (debug) + logger.debug("\nSTART GetTransactionalObjectIdWhenObjectIdBeingChanged"); + pm = getPM(); + Object oid = createPCPointInstance(pm); + PCPoint p1 = (PCPoint) pm.getObjectById (oid, false); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + p1.setX(10000); // this is the primary key + Object oid2 = pm.getTransactionalObjectId (p1); // should be different + tx.commit(); + Object oid3 = pm.getObjectId (p1); // should be same as oid2 + if (oid.equals(oid2)) { + fail(ASSERTION_FAILED, + "Oid before is the same as transactional oid after modifying pk"); + } - if (!oid2.equals(oid3)) { - fail(ASSERTION_FAILED, "Oid after is different from transactional oid after modifying pk"); - } - } finally { - if (debug) logger.debug("END GetTransactionalObjectIdWhenObjectIdBeingChanged"); - if ((tx != null) && tx.isActive()) tx.rollback(); + if (!oid2.equals(oid3)) { + fail(ASSERTION_FAILED, + "Oid after is different from transactional oid after modifying pk"); + } + } + finally { + if (debug) + logger.debug("END GetTransactionalObjectIdWhenObjectIdBeingChanged"); + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm = null; } - pm.close(); - pm = null; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWithNoTransaction.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWithNoTransaction.java index 3f668be0c..856ccaa11 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWithNoTransaction.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWithNoTransaction.java @@ -5,70 +5,77 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get Transactional ObjectId With No Transaction
    - * Keywords: identity
    - * Assertion ID: A12.5.6-16
    - * Assertion Description: If there is no transaction in progress, or if none of the key - * fields is being modified, then PersistenceManager.getTransactionalObjectId has the same behavior - * as getObjectId. - */ -public class GetTransactionalObjectIdWithNoTransaction extends PersistenceManagerTest { + *Title: Get Transactional ObjectId With No Transaction + *
    + *Keywords: identity + *
    + *Assertion ID: A12.5.6-16 + *
    + *Assertion Description: +If there is no transaction in progress, or if none of the key fields is being +modified, then PersistenceManager.getTransactionalObjectId has the same behavior as +getObjectId. - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.6-16 (GetTransactionalObjectIdWithNoTransaction) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetTransactionalObjectIdWithNoTransaction.class); - } + */ - /** */ - public void testGetTransactionalObjectIdWithNoTransaction() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - PCPoint p1 = new PCPoint(); +public class GetTransactionalObjectIdWithNoTransaction extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.6-16 (GetTransactionalObjectIdWithNoTransaction) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetTransactionalObjectIdWithNoTransaction.class); + } - tx.begin(); - pm.makePersistent(p1); - Object oid = pm.getObjectId(p1); - tx.commit(); + /** */ + public void testGetTransactionalObjectIdWithNoTransaction() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + PCPoint p1 = new PCPoint(); - Object toid = pm.getTransactionalObjectId(p1); - if (!toid.equals(oid)) { - fail( - ASSERTION_FAILED, - "pm.getTransactionalObjectId(p1) returned unexpected ObjectId, expected " - + oid - + ", got " - + toid); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + tx.begin(); + pm.makePersistent(p1); + Object oid = pm.getObjectId(p1); + tx.commit(); + + Object toid = pm.getTransactionalObjectId(p1); + if (!toid.equals(oid)) { + fail(ASSERTION_FAILED, + "pm.getTransactionalObjectId(p1) returned unexpected ObjectId, expected " + + oid + ", got " + toid); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm = null; } - pm.close(); - pm = null; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/NewInstance.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/NewInstance.java index 9c7d6450a..6bb91b44b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/NewInstance.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/NewInstance.java @@ -5,110 +5,120 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; import org.apache.jdo.tck.pc.newInstance.AAddress; -import org.apache.jdo.tck.pc.newInstance.AAddress_bad; import org.apache.jdo.tck.pc.newInstance.Address; -import org.apache.jdo.tck.pc.newInstance.Address_bad; import org.apache.jdo.tck.pc.newInstance.IAddress; +import org.apache.jdo.tck.pc.newInstance.AAddress_bad; +import org.apache.jdo.tck.pc.newInstance.Address_bad; import org.apache.jdo.tck.pc.newInstance.IAddress_bad; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Delete Persistent
    - * Keywords:
    - * Assertion IDs: A12.6.6-2
    - * Assertion Description: Persistent properties declared in the interface are defined as - * those that have both a get and a set method or both an is and a set method, named according to - * the JavaBeans naming conventions, and of a type supported as a persistent type. The implementing - * class will provide a suitable implementation for all property access methods and will throw - * JDOUserException for all other methods of the interface. + *Title: Delete Persistent + *
    + *Keywords: + *
    + *Assertion IDs: A12.6.6-2 + *
    + *Assertion Description: + * Persistent properties declared in the interface are defined as those that have both a get and a set method + * or both an is and a set method, named according to the JavaBeans naming conventions, and + * of a type supported as a persistent type. + * The implementing class will provide a suitable implementation for all property access methods and + * will throw JDOUserException for all other methods of the interface. */ -public class NewInstance extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A12.6.6-2 (NewInstance) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NewInstance.class); - } - - /** test newInstance (Class pcInterface) */ - public void testNewInstanceInterface() { - pm = getPM(); - IAddress instance = pm.newInstance(IAddress.class); - } +public class NewInstance extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.6.6-2 (NewInstance) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NewInstance.class); + } + + /** test newInstance (Class pcInterface) */ + public void testNewInstanceInterface() { + pm = getPM(); + IAddress instance = pm.newInstance(IAddress.class); + } - /** test newInstance (Class pcAbstractClass) */ - public void testNewInstanceAbstractClass() { - pm = getPM(); - AAddress instance = pm.newInstance(AAddress.class); - } + /** test newInstance (Class pcAbstractClass) */ + public void testNewInstanceAbstractClass() { + pm = getPM(); + AAddress instance = pm.newInstance(AAddress.class); + } - /** test newInstance (Class pcClass) */ - public void testNewInstanceClass() { - pm = getPM(); - Address instance = pm.newInstance(Address.class); - } + /** test newInstance (Class pcClass) */ + public void testNewInstanceClass() { + pm = getPM(); + Address instance = pm.newInstance(Address.class); + } - /** test newInstance (Class pcInterface) */ - public void testNewInstanceInterfaceBad() { - pm = getPM(); - try { - pm.newInstance(IAddress_bad.class); - fail( - "Expected JDOUserException but no exception thrown. " - + "Interface contains a method that is not property."); - } catch (javax.jdo.JDOUserException jdoe) { - // Expected exception - } catch (Exception e) { - fail("Expected JDOUserException but " + e.getMessage() + " thrown instead."); + /** test newInstance (Class pcInterface) */ + public void testNewInstanceInterfaceBad() { + pm = getPM(); + try { + pm.newInstance(IAddress_bad.class); + fail("Expected JDOUserException but no exception thrown. " + + "Interface contains a method that is not property."); + } catch (javax.jdo.JDOUserException jdoe) { + // Expected exception + } catch (Exception e) { + fail("Expected JDOUserException but " + e.getMessage() + + " thrown instead."); + } } - } - /** test newInstance (Class pcAbstractClass) */ - public void testNewInstanceAbstractClassBad() { - pm = getPM(); - try { - pm.newInstance(AAddress_bad.class); - fail( - "Expected JDOUserException but no exception thrown. " - + "Abstract class contains a method that is not property."); - } catch (javax.jdo.JDOUserException jdoe) { - // Expected exception - } catch (Exception e) { - fail("Expected JDOUserException but " + e.getMessage() + "t hrown instead."); + /** test newInstance (Class pcAbstractClass) */ + public void testNewInstanceAbstractClassBad() { + pm = getPM(); + try { + pm.newInstance(AAddress_bad.class); + fail("Expected JDOUserException but no exception thrown. " + + "Abstract class contains a method that is not property."); + } catch (javax.jdo.JDOUserException jdoe) { + // Expected exception + } catch (Exception e) { + fail("Expected JDOUserException but " + e.getMessage() + + "t hrown instead."); + } } - } - /** test newInstance (Class pcClass) */ - public void testNewInstanceClassBad() { - pm = getPM(); - try { - pm.newInstance(Address_bad.class); - fail( - "Expected JDOUserException but no exception thrown. " - + "Class contains non-public no-args constructor."); - } catch (javax.jdo.JDOUserException jdoe) { - // Expected exception - } catch (Exception e) { - fail("Expected JDOUserException but " + e.getMessage() + " thrown instead."); + /** test newInstance (Class pcClass) */ + public void testNewInstanceClassBad() { + pm = getPM(); + try { + pm.newInstance(Address_bad.class); + fail("Expected JDOUserException but no exception thrown. " + + "Class contains non-public no-args constructor."); + } catch (javax.jdo.JDOUserException jdoe) { + // Expected exception + } catch (Exception e) { + fail("Expected JDOUserException but " + e.getMessage() + + " thrown instead."); + } } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/NoPersistenceManagerIfTransient.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/NoPersistenceManagerIfTransient.java index 3b5372938..1ec83a219 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/NoPersistenceManagerIfTransient.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/NoPersistenceManagerIfTransient.java @@ -5,47 +5,54 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: No PersistenceManager If Transient
    - * Keywords: transient
    - * Assertion ID: A12.5-1.
    - * Assertion Description: A JDO Instance is associated with no PersistenceManager - * if and only if the instance is in the transient state. This is a duplicate of A8.1-2. - */ -public class NoPersistenceManagerIfTransient extends JDO_Test { + *Title: No PersistenceManager If Transient + *
    + *Keywords: transient + *
    + *Assertion ID: A12.5-1. + *
    + *Assertion Description: +A JDO Instance is associated with no PersistenceManager +if and only if the instance is in the transient state. +This is a duplicate of A8.1-2. - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5-1 (NoPersistenceManagerIfTransient) failed: "; + */ - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NoPersistenceManagerIfTransient.class); - } +public class NoPersistenceManagerIfTransient extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5-1 (NoPersistenceManagerIfTransient) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NoPersistenceManagerIfTransient.class); + } - /** */ - public void test() { - if (debug) - logger.debug( - "org.apache.jdo.tck.api.persistencemanager.NoPersistenceManagerIfTransient duplicate of A8.1-2."); - } + /** */ + public void test() { + if (debug) + logger.debug("org.apache.jdo.tck.api.persistencemanager.NoPersistenceManagerIfTransient duplicate of A8.1-2."); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/ObjectIdUniqueAmongInstances.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/ObjectIdUniqueAmongInstances.java index 113470b64..1a7fb445f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/ObjectIdUniqueAmongInstances.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/ObjectIdUniqueAmongInstances.java @@ -5,85 +5,97 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import java.util.HashSet; import java.util.Iterator; + import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: ObjectId Unique Among Instances
    - * Keywords: identity
    - * Assertion ID: A12.5.6-12.
    - * Assertion Description: Within a transaction, the ObjectId returned will - * compare equal to the ObjectId returned by only one among all JDO instances - * associated with the PersistenceManager regardless of the type of ObjectId - * . - */ -public class ObjectIdUniqueAmongInstances extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.6-12 (ObjectIdUniqueAmongInstances) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ObjectIdUniqueAmongInstances.class); - } + *Title: ObjectId Unique Among Instances + *
    + *Keywords: identity + *
    + *Assertion ID: A12.5.6-12. + *
    + *Assertion Description: +Within a transaction, the ObjectId returned will compare equal +to the ObjectId returned by only one among all JDO instances +associated with the PersistenceManager regardless of the type of +ObjectId. - /** */ - public void test() { - final int count = 1000; - - HashSet instances = new HashSet(count); - HashSet oids = new HashSet(count); - - pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - // Construct "count" persistent instances, and save them in a - // hashset. - for (int i = 0; i < count; ++i) { - PCPoint p = new PCPoint(i, count - i); - pm.makePersistent(p); - instances.add(p); - } + */ - // For all new persistent instances, get the object ids and - // save them in another hashset. There should be the same - // number if the ids are all unique. - for (Iterator it = instances.iterator(); it.hasNext(); ) { - oids.add(pm.getObjectId(it.next())); - } +public class ObjectIdUniqueAmongInstances extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.6-12 (ObjectIdUniqueAmongInstances) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ObjectIdUniqueAmongInstances.class); + } - tx.commit(); - tx = null; + /** */ + public void test() { + final int count = 1000; + + HashSet instances = new HashSet(count); + HashSet oids = new HashSet(count); - if (oids.size() != instances.size()) { - fail(ASSERTION_FAILED, "Oids has size: " + oids.size() + "; expected: " + instances.size()); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + // Construct "count" persistent instances, and save them in a + // hashset. + for (int i = 0; i < count; ++i) { + PCPoint p = new PCPoint (i, count-i); + pm.makePersistent(p); + instances.add(p); + } + + // For all new persistent instances, get the object ids and + // save them in another hashset. There should be the same + // number if the ids are all unique. + for (Iterator it = instances.iterator(); it.hasNext();) { + oids.add(pm.getObjectId(it.next())); + } + + tx.commit(); + tx = null; + + if (oids.size() != instances.size()) { + fail(ASSERTION_FAILED, + "Oids has size: " + oids.size() + "; expected: " + instances.size()); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm = null; } - pm.close(); - pm = null; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/OneInstanceOfObjectPerPersistenceManager.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/OneInstanceOfObjectPerPersistenceManager.java index 81674bc5e..375d4f86b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/OneInstanceOfObjectPerPersistenceManager.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/OneInstanceOfObjectPerPersistenceManager.java @@ -5,125 +5,139 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import java.util.Collection; import java.util.Iterator; + import javax.jdo.Query; import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.pc.mylib.PCRect; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Only one instance of persistent object in cache per PersistenceManager
    - * Keywords: cache
    - * Assertion ID: A5.4-10.
    - * Assertion Description: JDO implementations must manage the cache of JDO instances such - * that there is only one JDO instance, associated with each PersistenceManager - * representing the persistent state of each corresponding data store object. + *Title: Only one instance of persistent object in cache per + PersistenceManager + *
    + *Keywords: cache + *
    + *Assertion ID: A5.4-10. + *
    + *Assertion Description: +JDO implementations must manage the cache of JDO instances such that there is +only one JDO instance, associated with each PersistenceManager +representing the persistent state of each corresponding data store object. */ -public class OneInstanceOfObjectPerPersistenceManager extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A5.4-10 (OneInstanceOfObjectPerPersistenceManager) " + "failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(OneInstanceOfObjectPerPersistenceManager.class); - } - - /** - * This test creates objects in one transaction and commits. The important object is p1. Then, in - * a second transaction, it gets an object p1a by id, gets another object p1b by navigation, and a - * third object p1c by query. All of these represent the same datastore object and therefore must - * be identical in the same PersistenceManager. - */ - public void test() { - // The getPM method is declared in a superclass. - // This is the standard way to get a PersistenceManager. - // The method automatically gets a PersistenceManagerFactory, gets a PersistenceManager, - // and puts the PersistenceManager into the field pm. - getPM(); - // This is the standard way to get a Transaction. - Transaction tx = pm.currentTransaction(); - - // Any values for these flags should be set before beginning a transaction. - tx.setRetainValues(false); - tx.setRestoreValues(false); - - // This is the standard way to begin a transaction. - tx.begin(); - // Create new objects to be persisted. - PCPoint p1 = new PCPoint(10, 20); - PCPoint p2 = new PCPoint(20, 40); - PCRect rect = new PCRect(0, p1, p2); - // This test relies on persistence by reachability. - pm.makePersistent(rect); - // This is the standard way to commit a transaction. - tx.commit(); - - // Begin a new transaction so that the navigation uses the object id to load the target object - // into the cache. The RetainValues flag false guarantees that the object fields are no longer - // loaded. - tx.begin(); - Object p1Id = pm.getObjectId(p1); - // Retrieves the field values from the datastore. - PCPoint p1a = (PCPoint) pm.getObjectById(p1Id, true); - // Navigate to the point. - PCPoint p1b = rect.getUpperLeft(); - // Query for the point by its values in the datastore. - PCPoint p1c = findPoint(10, 20); - tx.commit(); - tx = null; - - // Use a StringBuffer to collect results. - StringBuffer results = new StringBuffer(); - - // Compare the original object with the object obtained by getObjectById. - if (p1 != p1a) { - results.append("getObjectById results differ. "); - } - // Compare the original object with the object obtained by navigating from another object. - if (p1 != p1b) { - results.append("navigation results differ. "); +public class OneInstanceOfObjectPerPersistenceManager extends + PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A5.4-10 (OneInstanceOfObjectPerPersistenceManager) " + + "failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(OneInstanceOfObjectPerPersistenceManager.class); } - // Compare the original object with the object obtained by query. - if (p1 != p1c) { - results.append("query results differ. "); - } - if (results.length() != 0) { - fail(ASSERTION_FAILED + results.toString()); + + /** + * This test creates objects in one transaction and commits. + * The important object is p1. + * Then, in a second transaction, it gets an object p1a by id, + * gets another object p1b by navigation, and a third object p1c by + * query. All of these represent the same datastore object and + * therefore must be identical in the same PersistenceManager. + */ + public void test() { + // The getPM method is declared in a superclass. + // This is the standard way to get a PersistenceManager. + // The method automatically gets a PersistenceManagerFactory, gets a PersistenceManager, + // and puts the PersistenceManager into the field pm. + getPM(); + // This is the standard way to get a Transaction. + Transaction tx = pm.currentTransaction(); + + // Any values for these flags should be set before beginning a transaction. + tx.setRetainValues(false); + tx.setRestoreValues(false); + + // This is the standard way to begin a transaction. + tx.begin(); + // Create new objects to be persisted. + PCPoint p1 = new PCPoint(10, 20); + PCPoint p2 = new PCPoint(20, 40); + PCRect rect = new PCRect(0, p1, p2); + // This test relies on persistence by reachability. + pm.makePersistent(rect); + // This is the standard way to commit a transaction. + tx.commit(); + + // Begin a new transaction so that the navigation uses the object id to load the target object + // into the cache. The RetainValues flag false guarantees that the object fields are no longer loaded. + tx.begin(); + Object p1Id = pm.getObjectId(p1); + // Retrieves the field values from the datastore. + PCPoint p1a = (PCPoint)pm.getObjectById(p1Id, true); + // Navigate to the point. + PCPoint p1b = rect.getUpperLeft(); + // Query for the point by its values in the datastore. + PCPoint p1c = findPoint(10, 20); + tx.commit(); + tx = null; + + // Use a StringBuffer to collect results. + StringBuffer results = new StringBuffer(); + + // Compare the original object with the object obtained by getObjectById. + if (p1 != p1a) { + results.append("getObjectById results differ. "); + } + + // Compare the original object with the object obtained by navigating from another object. + if (p1 != p1b) { + results.append("navigation results differ. "); + } + // Compare the original object with the object obtained by query. + if (p1 != p1c) { + results.append("query results differ. "); + } + if (results.length() != 0) { + fail(ASSERTION_FAILED + results.toString()); + } + + // The standard way to end each test method is to simply return. Exceptions are caught by JUnit. + // The tearDown method ends the transaction and closes the PersistenceManager. } - // The standard way to end each test method is to simply return. Exceptions are caught by JUnit. - // The tearDown method ends the transaction and closes the PersistenceManager. - } - - /** */ - private PCPoint findPoint(int x, int y) { - Query q = getPM().newQuery(PCPoint.class); - q.declareParameters("int px, int py"); - q.setFilter("x == px & y == py"); - Collection results = (Collection) q.execute(Integer.valueOf(x), Integer.valueOf(y)); - Iterator it = results.iterator(); - PCPoint ret = (PCPoint) it.next(); - return ret; - } + /** */ + private PCPoint findPoint (int x, int y) { + Query q = getPM().newQuery (PCPoint.class); + q.declareParameters ("int px, int py"); + q.setFilter ("x == px & y == py"); + Collection results = (Collection)q.execute (Integer.valueOf(x), + Integer.valueOf(y)); + Iterator it = results.iterator(); + PCPoint ret = (PCPoint)it.next(); + return ret; + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/OnePersistenceManagerIfPersistentOrTransactional.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/OnePersistenceManagerIfPersistentOrTransactional.java index 1dfe3b3d1..addcf687e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/OnePersistenceManagerIfPersistentOrTransactional.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/OnePersistenceManagerIfPersistentOrTransactional.java @@ -5,47 +5,52 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: One PersistenceManager If Persistent or Transactional
    - * Keywords:
    - * Assertion ID: A12.5-2.
    - * Assertion Description: A JDO Instance is associated with exactly one - * PersistenceManager if the instance is persistent or transactional. This is a duplicate - * test. + *Title: One PersistenceManager If Persistent or Transactional + *
    + *Keywords: + *
    + *Assertion ID: A12.5-2. + *
    + *Assertion Description: +A JDO Instance is associated with exactly one PersistenceManager +if the instance is persistent or transactional. +This is a duplicate test. */ -public class OnePersistenceManagerIfPersistentOrTransactional extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5-2 (OnePersistenceManagerIfPersistentOrTransactional) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(OnePersistenceManagerIfPersistentOrTransactional.class); - } +public class OnePersistenceManagerIfPersistentOrTransactional extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5-2 (OnePersistenceManagerIfPersistentOrTransactional) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(OnePersistenceManagerIfPersistentOrTransactional.class); + } - /** */ - public void test() { - if (debug) - logger.debug( - "org.apache.jdo.tck.api.persistencemanager.OnePersistenceManagerIfPersistentOrTransactional.run duplicate"); - } + /** */ + public void test() { + if (debug) + logger.debug("org.apache.jdo.tck.api.persistencemanager.OnePersistenceManagerIfPersistentOrTransactional.run duplicate"); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/OptimisticFailure.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/OptimisticFailure.java index 0313f8d96..e547faa3b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/OptimisticFailure.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/OptimisticFailure.java @@ -5,220 +5,241 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import java.util.HashSet; import java.util.Set; + import javax.jdo.JDOException; import javax.jdo.JDOHelper; import javax.jdo.JDOOptimisticVerificationException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.mylib.VersionedPCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: OptimisticFailure
    - * Keywords: optimistic
    - * Assertion IDs: A13.5-1
    - * Assertion Description: If any instance fails the verification, a - * JDOOptimisticVerificationException is thrown which contains an array of - * JDOOptimisticVerificationException, one for each instance that failed the verification. The - * optimistic transaction is failed, and the transaction is rolled back. The definition of "changed - * instance" is a JDO implementation choice, but it is required that a field that has been changed - * to different values in different transactions results in one of the transactions failing. + *Title: OptimisticFailure + *
    + *Keywords: optimistic + *
    + *Assertion IDs: A13.5-1 + *
    + *Assertion Description: + * If any instance fails the verification, a JDOOptimisticVerificationException + * is thrown which contains an array of JDOOptimisticVerificationException, + * one for each instance that failed the verification. The optimistic + * transaction is failed, and the transaction is rolled back. + * The definition of "changed instance" is a JDO implementation choice, + * but it is required that a field that has been changed to different + * values in different transactions results in one of the transactions + * failing. */ -public class OptimisticFailure extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A13.5-1 (OptimisticFailure) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(OptimisticFailure.class); - } - - private VersionedPCPoint p1 = - new VersionedPCPoint(1, 1); // this will be updated in tx1, updated in tx2, verified in tx3 - private VersionedPCPoint p2 = - new VersionedPCPoint(2, 2); // this will be updated in tx1, deleted in tx2, verified in tx3 - private VersionedPCPoint p3 = - new VersionedPCPoint(3, 3); // this will be deleted in tx1, updated in tx2 - private VersionedPCPoint p4 = - new VersionedPCPoint(4, 4); // this will be deleted in tx1, deleted in tx2 - private VersionedPCPoint p5 = - new VersionedPCPoint(5, 5); // this will be unchanged in tx1, updated in tx2, verified in tx3 - private Object p1oid = null; - private Object p2oid = null; - private Object p3oid = null; - private Object p4oid = null; - private Object p5oid = null; - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(VersionedPCPoint.class); - } - - /** */ - public void test() { - pm = getPM(); - PersistenceManager pm2 = pmf.getPersistenceManager(); - PersistenceManager pm3 = pmf.getPersistenceManager(); - - try { - runTestOptimistic(pm, pm2, pm3); - } finally { - cleanupPM(pm3); - pm3 = null; - cleanupPM(pm2); - pm2 = null; - cleanupPM(pm); - pm = null; +public class OptimisticFailure extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.5-1 (OptimisticFailure) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(OptimisticFailure.class); } - } - /** */ - private void runTestOptimistic( - PersistenceManager pm1, PersistenceManager pm2, PersistenceManager pm3) { - if (!isOptimisticSupported()) { - if (debug) logger.debug("OptimisticFailure tests not run; Optimistic not supported"); - return; + private VersionedPCPoint p1 = new VersionedPCPoint(1,1); // this will be updated in tx1, updated in tx2, verified in tx3 + private VersionedPCPoint p2 = new VersionedPCPoint(2,2); // this will be updated in tx1, deleted in tx2, verified in tx3 + private VersionedPCPoint p3 = new VersionedPCPoint(3,3); // this will be deleted in tx1, updated in tx2 + private VersionedPCPoint p4 = new VersionedPCPoint(4,4); // this will be deleted in tx1, deleted in tx2 + private VersionedPCPoint p5 = new VersionedPCPoint(5,5); // this will be unchanged in tx1, updated in tx2, verified in tx3 + private Object p1oid = null; + private Object p2oid = null; + private Object p3oid = null; + private Object p4oid = null; + private Object p5oid = null; + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(VersionedPCPoint.class); } - Transaction tx1 = pm1.currentTransaction(); - Transaction tx2 = pm2.currentTransaction(); - Transaction tx3 = pm3.currentTransaction(); - try { - tx1.setOptimistic(true); - tx2.setOptimistic(true); + /** */ + public void test() { + pm = getPM(); + PersistenceManager pm2 = pmf.getPersistenceManager(); + PersistenceManager pm3 = pmf.getPersistenceManager(); - // create five instances to test - tx1.begin(); - pm1.makePersistent(p1); - pm1.makePersistent(p2); - pm1.makePersistent(p3); - pm1.makePersistent(p4); - pm1.makePersistent(p5); - p1oid = pm1.getObjectId(p1); - p2oid = pm1.getObjectId(p2); - p3oid = pm1.getObjectId(p3); - p4oid = pm1.getObjectId(p4); - p5oid = pm1.getObjectId(p5); - tx1.commit(); - - // update/delete the instances in tx1 - tx1.begin(); - VersionedPCPoint p1tx1 = (VersionedPCPoint) pm1.getObjectById(p1oid, true); - VersionedPCPoint p2tx1 = (VersionedPCPoint) pm1.getObjectById(p2oid, true); - VersionedPCPoint p3tx1 = (VersionedPCPoint) pm1.getObjectById(p3oid, true); - VersionedPCPoint p4tx1 = (VersionedPCPoint) pm1.getObjectById(p4oid, true); - p1tx1.setX(101); - p2tx1.setX(201); - pm1.deletePersistent(p3tx1); - pm1.deletePersistent(p4tx1); - - // update/delete the instances in tx2 - tx2.begin(); - VersionedPCPoint p1tx2 = (VersionedPCPoint) pm2.getObjectById(p1oid, true); - VersionedPCPoint p2tx2 = (VersionedPCPoint) pm2.getObjectById(p2oid, true); - VersionedPCPoint p3tx2 = (VersionedPCPoint) pm2.getObjectById(p3oid, true); - VersionedPCPoint p4tx2 = (VersionedPCPoint) pm2.getObjectById(p4oid, true); - VersionedPCPoint p5tx2 = (VersionedPCPoint) pm2.getObjectById(p5oid, true); - p1tx2.setX(102); - pm2.deletePersistent(p2tx2); - p3tx2.setX(202); - pm2.deletePersistent(p4tx2); - p5tx2.setX(502); // this change must not be committed - Set expectedFailedObjects = new HashSet(); - expectedFailedObjects.add(p1tx2); - expectedFailedObjects.add(p2tx2); - expectedFailedObjects.add(p3tx2); - expectedFailedObjects.add(p4tx2); - - // commit tx1 (should succeed) - tx1.commit(); - tx1 = null; - - // commit tx2 (should fail) - try { - tx2.commit(); - fail(ASSERTION_FAILED, "concurrent commit not detected"); - } catch (JDOOptimisticVerificationException ex) { - // verify the correct information in the exception - Throwable[] ts = ex.getNestedExceptions(); - int length = ts == null ? 0 : ts.length; - int expectedFailures = expectedFailedObjects.size(); - if (length != expectedFailures) { - fail( - ASSERTION_FAILED, - "Nested exceptions[] wrong size: expected " + expectedFailures + ", got " + length); + try { + runTestOptimistic(pm, pm2, pm3); } - for (int i = 0; i < length; ++i) { - Throwable t = ts[i]; - if (t instanceof JDOOptimisticVerificationException) { - if (debug) logger.debug("Expected exception caught " + t.toString()); - JDOException jex = (JDOException) t; - Object failed = jex.getFailedObject(); - if (failed == null) { - fail(ASSERTION_FAILED, "Found unexpected null in failed object"); - } else { - if (expectedFailedObjects.remove(failed)) { - if (debug) - logger.debug( - "Found expected failed instance, oid: " + JDOHelper.getObjectId(failed)); - } else { - fail(ASSERTION_FAILED, "Unexpected failed instance: " + failed.toString()); - } - } - } else { - fail(ASSERTION_FAILED, "Unexpected nested exception: " + t.toString()); - } + finally { + cleanupPM(pm3); + pm3 = null; + cleanupPM(pm2); + pm2 = null; + cleanupPM(pm); + pm = null; + } + } + + /** */ + private void runTestOptimistic(PersistenceManager pm1, + PersistenceManager pm2, + PersistenceManager pm3) { + if (!isOptimisticSupported()) { + if (debug) + logger.debug("OptimisticFailure tests not run; Optimistic not supported"); + return; } - } - tx2 = null; - tx3.begin(); - VersionedPCPoint p1tx3 = (VersionedPCPoint) pm3.getObjectById(p1oid, true); - VersionedPCPoint p2tx3 = (VersionedPCPoint) pm3.getObjectById(p2oid, true); - VersionedPCPoint p5tx3 = (VersionedPCPoint) pm3.getObjectById(p5oid, true); - verify(p1tx3, 101); - verify(p2tx3, 201); - verify(p5tx3, 5); - tx3.commit(); - tx3 = null; - } finally { - if ((tx3 != null) && tx3.isActive()) tx3.rollback(); - if ((tx2 != null) && tx2.isActive()) tx2.rollback(); - if ((tx1 != null) && tx1.isActive()) tx1.rollback(); + Transaction tx1 = pm1.currentTransaction(); + Transaction tx2 = pm2.currentTransaction(); + Transaction tx3 = pm3.currentTransaction(); + try { + tx1.setOptimistic(true); + tx2.setOptimistic(true); + + // create five instances to test + tx1.begin(); + pm1.makePersistent(p1); + pm1.makePersistent(p2); + pm1.makePersistent(p3); + pm1.makePersistent(p4); + pm1.makePersistent(p5); + p1oid = pm1.getObjectId(p1); + p2oid = pm1.getObjectId(p2); + p3oid = pm1.getObjectId(p3); + p4oid = pm1.getObjectId(p4); + p5oid = pm1.getObjectId(p5); + tx1.commit(); + + // update/delete the instances in tx1 + tx1.begin(); + VersionedPCPoint p1tx1 = (VersionedPCPoint)pm1.getObjectById(p1oid, true); + VersionedPCPoint p2tx1 = (VersionedPCPoint)pm1.getObjectById(p2oid, true); + VersionedPCPoint p3tx1 = (VersionedPCPoint)pm1.getObjectById(p3oid, true); + VersionedPCPoint p4tx1 = (VersionedPCPoint)pm1.getObjectById(p4oid, true); + p1tx1.setX(101); + p2tx1.setX(201); + pm1.deletePersistent(p3tx1); + pm1.deletePersistent(p4tx1); + + // update/delete the instances in tx2 + tx2.begin(); + VersionedPCPoint p1tx2 = (VersionedPCPoint)pm2.getObjectById(p1oid, true); + VersionedPCPoint p2tx2 = (VersionedPCPoint)pm2.getObjectById(p2oid, true); + VersionedPCPoint p3tx2 = (VersionedPCPoint)pm2.getObjectById(p3oid, true); + VersionedPCPoint p4tx2 = (VersionedPCPoint)pm2.getObjectById(p4oid, true); + VersionedPCPoint p5tx2 = (VersionedPCPoint)pm2.getObjectById(p5oid, true); + p1tx2.setX(102); + pm2.deletePersistent(p2tx2); + p3tx2.setX(202); + pm2.deletePersistent(p4tx2); + p5tx2.setX(502); // this change must not be committed + Set expectedFailedObjects = new HashSet(); + expectedFailedObjects.add(p1tx2); + expectedFailedObjects.add(p2tx2); + expectedFailedObjects.add(p3tx2); + expectedFailedObjects.add(p4tx2); + + // commit tx1 (should succeed) + tx1.commit(); + tx1 = null; + + // commit tx2 (should fail) + try { + tx2.commit(); + fail(ASSERTION_FAILED, "concurrent commit not detected"); + } + catch (JDOOptimisticVerificationException ex) { + // verify the correct information in the exception + Throwable[] ts = ex.getNestedExceptions(); + int length = ts==null ? 0 : ts.length; + int expectedFailures = expectedFailedObjects.size(); + if (length != expectedFailures) { + fail(ASSERTION_FAILED, + "Nested exceptions[] wrong size: expected " + + expectedFailures + ", got " + length); + } + for (int i = 0; i < length; ++i) { + Throwable t = ts[i]; + if (t instanceof JDOOptimisticVerificationException) { + if (debug) + logger.debug("Expected exception caught " + t.toString()); + JDOException jex = (JDOException)t; + Object failed = jex.getFailedObject(); + if (failed == null) { + fail(ASSERTION_FAILED, + "Found unexpected null in failed object"); + } + else { + if (expectedFailedObjects.remove(failed)) { + if (debug) + logger.debug("Found expected failed instance, oid: " + + JDOHelper.getObjectId(failed)); + } + else { + fail(ASSERTION_FAILED, + "Unexpected failed instance: " + failed.toString()); + } + } + } + else { + fail(ASSERTION_FAILED, + "Unexpected nested exception: " + t.toString()); + } + } + } + tx2 = null; + + tx3.begin(); + VersionedPCPoint p1tx3 = (VersionedPCPoint)pm3.getObjectById(p1oid, true); + VersionedPCPoint p2tx3 = (VersionedPCPoint)pm3.getObjectById(p2oid, true); + VersionedPCPoint p5tx3 = (VersionedPCPoint)pm3.getObjectById(p5oid, true); + verify(p1tx3, 101); + verify(p2tx3, 201); + verify(p5tx3, 5); + tx3.commit(); + tx3 = null; + } + finally { + if ((tx3 != null) && tx3.isActive()) + tx3.rollback(); + if ((tx2 != null) && tx2.isActive()) + tx2.rollback(); + if ((tx1 != null) && tx1.isActive()) + tx1.rollback(); + } } - } - /** - * @param p PCPoint instance - * @param value value - */ - protected void verify(VersionedPCPoint p, int value) { - if (p.getX() != value) { - fail( - ASSERTION_FAILED, - "VersionedPCPoint has wrong value: expected " + value + ", got " + p.getX()); + /** + * + * @param p PCPoint instance + * @param value value + */ + protected void verify(VersionedPCPoint p, int value) { + if (p.getX() != value) { + fail(ASSERTION_FAILED, + "VersionedPCPoint has wrong value: expected " + value + ", got " + p.getX()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/PersistenceManagerTest.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/PersistenceManagerTest.java index 45734475b..52b798205 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/PersistenceManagerTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/PersistenceManagerTest.java @@ -5,20 +5,22 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.Company; import org.apache.jdo.tck.pc.company.Department; @@ -27,94 +29,105 @@ import org.apache.jdo.tck.pc.mylib.PCRect; public abstract class PersistenceManagerTest extends JDO_Test { + + /** */ + protected PersistenceManagerTest() { } - /** */ - protected PersistenceManagerTest() {} - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - // The order of addTearDownClass calls is significant - // as it takes into account database FKs. - addTearDownClass(PCRect.class); - addTearDownClass(PCPoint.class); - addTearDownClass(Department.class); - addTearDownClass(Company.class); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + // The order of addTearDownClass calls is significant + // as it takes into account database FKs. + addTearDownClass(PCRect.class); + addTearDownClass(PCPoint.class); + addTearDownClass(Department.class); + addTearDownClass(Company.class); + } - /** - * @param pm the PersistenceManager - * @return PCPOint instance - */ - protected Object createPCPointInstance(PersistenceManager pm) { - PCPoint p1 = new PCPoint(8, 8); - Transaction tx = pm.currentTransaction(); - tx.begin(); - pm.makePersistent(p1); - Object oid = pm.getObjectId(p1); - tx.commit(); - return oid; - } + /** + * + * @param pm the PersistenceManager + * @return PCPOint instance + */ + protected Object createPCPointInstance(PersistenceManager pm) { + PCPoint p1 = new PCPoint(8,8); + Transaction tx = pm.currentTransaction(); + tx.begin(); + pm.makePersistent(p1); + Object oid = pm.getObjectId(p1); + tx.commit(); + return oid; + } - /** - * @param pm the PersistenceManager - * @param oid the ID of the instance to be deleted - */ - public void deletePCPointInstance(PersistenceManager pm, Object oid) { - Transaction tx = pm.currentTransaction(); - tx.begin(); - Object p1 = pm.getObjectById(oid, true); - pm.deletePersistent(p1); - tx.commit(); - } + /** + * + * @param pm the PersistenceManager + * @param oid the ID of the instance to be deleted + */ + public void deletePCPointInstance (PersistenceManager pm, Object oid) { + Transaction tx = pm.currentTransaction(); + tx.begin(); + Object p1 = pm.getObjectById(oid, true); + pm.deletePersistent(p1); + tx.commit(); + } - /** - * @param obj PCPoint instance - * @param expectState expected state - * @param str state description - * @return true if test successful - */ - public boolean testState(PCPoint obj, int expectState, String str) { - int actualState = currentState(obj); - if (actualState != expectState) { - if (debug) { - logger.debug(" Object not in " + str + " state for X = " + obj.getX()); - logger.debug(" current state: " + actualState + " expected state: " + expectState); - } - return false; + /** + * + * @param obj PCPoint instance + * @param expectState expected state + * @param str state description + * @return true if test successful + */ + public boolean testState(PCPoint obj, int expectState, String str) { + int actualState = currentState(obj); + if (actualState != expectState) { + if (debug) { + logger.debug(" Object not in " + str + " state for X = " + + obj.getX()); + logger.debug(" current state: " + actualState + + " expected state: " + expectState); + } + return false; + } + return true; } - return true; - } - /** - * @param obj PCPoint instance - * @param expectState expected state - * @param str state description - * @return true if test successful - */ - public boolean testState(PCPoint2 obj, int expectState, String str) { - int actualState = currentState(obj); - if (actualState != expectState) { - if (debug) { - logger.debug(" Object not in " + str + " state for X = " + obj.getX()); - logger.debug(" current state: " + actualState + " expected state: " + expectState); - } - return false; + /** + * + * @param obj PCPoint instance + * @param expectState expected state + * @param str state description + * @return true if test successful + */ + public boolean testState(PCPoint2 obj, int expectState, String str) { + int actualState = currentState(obj); + if (actualState != expectState) { + if (debug) { + logger.debug(" Object not in " + str + " state for X = " + + obj.getX() ); + logger.debug(" current state: " + actualState + + " expected state: " + expectState); + } + return false; + } + return true; } - return true; - } - /** - * @param p PCPoint instance - * @param value value - * @param assertion assertion - * @param label label - */ - public void assertGetX(PCPoint p, int value, String assertion, String label) { - if (p.getX() != value) { - fail(assertion, label); + /** + * + * @param p PCPoint instance + * @param value value + * @param assertion assertion + * @param label label + */ + public void assertGetX(PCPoint p, int value, String assertion, String label) { + if (p.getX() != value) { + fail(assertion, label); + } } - } } + + diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/SameTransactionInstanceForAllCallsToCurrentTransaction.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/SameTransactionInstanceForAllCallsToCurrentTransaction.java index 0124e39fd..c9a68d542 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/SameTransactionInstanceForAllCallsToCurrentTransaction.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/SameTransactionInstanceForAllCallsToCurrentTransaction.java @@ -5,67 +5,77 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Same Transaction Instance For All Calls To Current Transaction
    - * Keywords:
    - * Assertion ID: A12.5.2-2.
    - * Assertion Description: The identical Transaction instance will be returned - * by all currentTransaction calls to the same PersistenceManager until - * close. - */ -public class SameTransactionInstanceForAllCallsToCurrentTransaction extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.2-2 (SameTransactionInstanceForAllCallsToCurrentTransaction) failed: "; + *Title: Same Transaction Instance For All Calls To Current Transaction + *
    + *Keywords: + *
    + *Assertion ID: A12.5.2-2. + *
    + *Assertion Description: +The identical Transaction instance will be returned by all +currentTransaction calls to the same PersistenceManager +until close. - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SameTransactionInstanceForAllCallsToCurrentTransaction.class); - } + */ - /** */ - public void test() { - pm = getPM(); +public class SameTransactionInstanceForAllCallsToCurrentTransaction extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.2-2 (SameTransactionInstanceForAllCallsToCurrentTransaction) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SameTransactionInstanceForAllCallsToCurrentTransaction.class); + } - Transaction tx1 = getPM().currentTransaction(); - tx1.begin(); - Transaction tx2 = getPM().currentTransaction(); - tx1.commit(); - Transaction tx3 = getPM().currentTransaction(); + /** */ + public void test() { + pm = getPM(); - if (tx1 != tx2) { - fail(ASSERTION_FAILED, "tx1 before begin different from tx2 after begin"); - } - if (tx2 != tx3) { - fail(ASSERTION_FAILED, "tx2 after begin different from tx3 after commit"); - } + Transaction tx1 = getPM().currentTransaction(); + tx1.begin(); + Transaction tx2 = getPM().currentTransaction(); + tx1.commit(); + Transaction tx3 = getPM().currentTransaction(); + + if (tx1 != tx2) { + fail(ASSERTION_FAILED, + "tx1 before begin different from tx2 after begin"); + } + if (tx2 != tx3) { + fail(ASSERTION_FAILED, + "tx2 after begin different from tx3 after commit"); + } - if (!pm.isClosed()) { - if (pm.currentTransaction().isActive()) { - pm.currentTransaction().rollback(); - } - pm.close(); + if (!pm.isClosed()) { + if (pm.currentTransaction().isActive()) { + pm.currentTransaction().rollback(); + } + pm.close(); + } + pm = null; } - pm = null; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/ThreadSafe.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/ThreadSafe.java index bdfa947d4..004fd4a06 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/ThreadSafe.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/ThreadSafe.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,187 +20,192 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; + import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; -import org.apache.jdo.tck.util.RogueBarrier; import org.apache.jdo.tck.util.ThreadExceptionHandler; +import org.apache.jdo.tck.util.RogueBarrier; /** - * Title: Thread Safe
    - * Keywords: multithreaded
    - * Assertion ID: A12.4-1.
    - * Assertion Description: It is a requirement for all JDO implementations to be thread-safe. - * That is, the behavior of the implementation must be predictable in the presence of multiple - * application threads. This assertion will generate multiple test cases to be evaluated. + *Title: Thread Safe + *
    + *Keywords: multithreaded + *
    + *Assertion ID: A12.4-1. + *
    + *Assertion Description: +It is a requirement for all JDO implementations to be thread-safe. That is, the behavior of the implementation must be predictable in the presence of multiple application threads. This assertion will generate multiple test cases to be evaluated. + */ public class ThreadSafe extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A12.4-1 (ThreadSafe) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ThreadSafe.class); - } - - private final int threadCount = 10; - private final ThreadExceptionHandler group = new ThreadExceptionHandler(); - private final RogueBarrier barrier = new RogueBarrier(threadCount); - private int successCount = 0; - private int exceptionCount = 0; - - /** - * @throws Exception exception - */ - public void testThreadSafe() throws Exception { - if (debug) logger.debug("\nSTART testThreadSafe"); - - // test thread-safety of PMF.getPersistenceManager(): - // pmf.getPM(), pm.close() - final PCPoint[] nullPC = new PCPoint[threadCount]; - runThreads(nullPC, "Concurrent PMF.getPersistenceManager()", threadCount); - - // test thread-safety of PMF.getPersistenceManager(): - // pmf.getPM(), pm.makePersistent(private transient PC), pm.close() - final PCPoint[] localPC = new PCPoint[threadCount]; - for (int i = 0; i < threadCount; i++) { - localPC[i] = new PCPoint(1, i); - } - runThreads( - localPC, "Concurrent PMF.getPersistenceManager()" + ".makePersistent()", threadCount); - - // test thread-safety of PM.makePersistent(): - // pmf.getPM(), pm.makePersistent(shared transient PC), pm.close() - final PCPoint[] sharedPC = new PCPoint[threadCount]; - final PCPoint p1 = new PCPoint(3, 3); - for (int i = 0; i < threadCount; i++) { - sharedPC[i] = p1; - } - runThreads(sharedPC, "Concurrent PM.makePersistent(" + "shared transient PC)", 1); - } - - /** - * @param pc objects - * @param header header - * @param toSucceed to succeed - */ - public void runThreads(Object[] pc, String header, int toSucceed) { - // start threads with their pc instance - final Thread[] threads = new Thread[threadCount]; - for (int i = 0; i < threadCount; i++) { - Thread t = new Thread(group, new PMThread(pc[i])); - t.setName("ThreadSafeID-" + i); - threads[i] = t; - t.start(); + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.4-1 (ThreadSafe) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ThreadSafe.class); } - // wait for all threads to finish - for (int i = 0; i < threadCount; i++) { - while (true) { - try { - threads[i].join(); - break; - } catch (InterruptedException e) { // swallow + private final int threadCount = 10; + private final ThreadExceptionHandler group = new ThreadExceptionHandler(); + private final RogueBarrier barrier = new RogueBarrier(threadCount); + private int successCount = 0; + private int exceptionCount = 0; + + /** + * + * @throws Exception exception + */ + public void testThreadSafe() throws Exception { + if (debug) logger.debug("\nSTART testThreadSafe"); + + // test thread-safety of PMF.getPersistenceManager(): + // pmf.getPM(), pm.close() + final PCPoint[] nullPC = new PCPoint[threadCount]; + runThreads(nullPC, "Concurrent PMF.getPersistenceManager()", + threadCount); + + // test thread-safety of PMF.getPersistenceManager(): + // pmf.getPM(), pm.makePersistent(private transient PC), pm.close() + final PCPoint[] localPC = new PCPoint[threadCount]; + for (int i = 0; i < threadCount; i++) { + localPC[i] = new PCPoint(1,i); + } + runThreads(localPC, "Concurrent PMF.getPersistenceManager()" + + ".makePersistent()", threadCount); + + // test thread-safety of PM.makePersistent(): + // pmf.getPM(), pm.makePersistent(shared transient PC), pm.close() + final PCPoint[] sharedPC = new PCPoint[threadCount]; + final PCPoint p1 = new PCPoint(3,3); + for (int i = 0; i < threadCount; i++) { + sharedPC[i] = p1; } - } + runThreads(sharedPC, "Concurrent PM.makePersistent(" + + "shared transient PC)", 1); } - checkResults(header, toSucceed); - } - - /** - * @param header header - * @param toSucceed to succeed - */ - protected synchronized void checkResults(String header, int toSucceed) { - // check unhandled exceptions - final Set uncaught = group.getAllUncaughtExceptions(); - if ((uncaught != null) && !uncaught.isEmpty()) { - StringBuffer report = new StringBuffer("Uncaught exceptions:\n"); - for (Iterator i = uncaught.iterator(); i.hasNext(); ) { - Map.Entry next = (Map.Entry) i.next(); - Thread thread = (Thread) next.getKey(); - Throwable problem = (Throwable) next.getValue(); - report.append(header + ": Uncaught exception " + problem + " in thread " + thread + "\n"); - } - fail(ASSERTION_FAILED, report.toString()); - group.clear(); - } + /** + * + * @param pc objects + * @param header header + * @param toSucceed to succeed + */ + public void runThreads(Object[] pc, String header, int toSucceed) { + // start threads with their pc instance + final Thread[] threads = new Thread[threadCount]; + for (int i = 0; i < threadCount; i++) { + Thread t = new Thread(group, new PMThread(pc[i])); + t.setName("ThreadSafeID-" + i); + threads[i] = t; + t.start(); + } - // check success count - if (successCount != toSucceed) { - fail( - ASSERTION_FAILED, - header - + ": Incorrect number of " - + "\"succeeding\" threads; expected=" - + toSucceed - + " found=" - + successCount); - } - successCount = 0; - - // check exception count - final int toExcept = threadCount - toSucceed; - if (exceptionCount != toExcept) { - fail( - ASSERTION_FAILED, - header - + ": Incorrect number of " - + "\"failing\" threads; expected=" - + toExcept - + " found=" - + exceptionCount); - } - exceptionCount = 0; - } + // wait for all threads to finish + for (int i = 0; i < threadCount; i++) { + while (true) { + try { + threads[i].join(); + break; + } catch (InterruptedException e) { // swallow + } + } + } - /** */ - protected synchronized void markSuccess() { - logger.debug("[" + Thread.currentThread().getName() + "]: success"); - successCount++; - } + checkResults(header, toSucceed); + } - /** */ - protected synchronized void markExpectedException() { - logger.debug("[" + Thread.currentThread().getName() + "]: expected exception"); - exceptionCount++; - } + /** + * + * @param header header + * @param toSucceed to succeed + */ + protected synchronized void checkResults(String header, int toSucceed) { + // check unhandled exceptions + final Set uncaught = group.getAllUncaughtExceptions(); + if ((uncaught != null) && !uncaught.isEmpty()) { + StringBuffer report = new StringBuffer("Uncaught exceptions:\n"); + for (Iterator i = uncaught.iterator(); i.hasNext();) { + Map.Entry next = (Map.Entry)i.next(); + Thread thread = (Thread)next.getKey(); + Throwable problem = (Throwable)next.getValue(); + report.append(header + ": Uncaught exception " + problem + + " in thread " + thread + "\n"); + } + fail(ASSERTION_FAILED, report.toString()); + group.clear(); + } + + // check success count + if (successCount != toSucceed) { + fail(ASSERTION_FAILED, header + ": Incorrect number of " + + "\"succeeding\" threads; expected=" + toSucceed + + " found=" + successCount); + } + successCount = 0; + + // check exception count + final int toExcept = threadCount - toSucceed; + if (exceptionCount != toExcept) { + fail(ASSERTION_FAILED, header + ": Incorrect number of " + + "\"failing\" threads; expected=" + toExcept + + " found=" + exceptionCount); + } + exceptionCount = 0; + } - /** */ - class PMThread implements Runnable { - private final Object pc; + /** */ + protected synchronized void markSuccess() { + logger.debug("[" + Thread.currentThread().getName() + "]: success"); + successCount++; + } /** */ - PMThread(Object pc) { - this.pc = pc; + protected synchronized void markExpectedException() { + logger.debug("[" + Thread.currentThread().getName() + "]: expected exception"); + exceptionCount++; } /** */ - public void run() { - ThreadSafe.this.logger.debug("[" + Thread.currentThread().getName() + "]: running"); - final PersistenceManager pm = pmf.getPersistenceManager(); - try { - Transaction tx = pm.currentTransaction(); - tx.begin(); - if (pc != null) { - pm.makePersistent(pc); + class PMThread implements Runnable { + private final Object pc; + + /** */ + PMThread(Object pc) { + this.pc = pc; + } + + /** */ + public void run() { + ThreadSafe.this.logger.debug("[" + Thread.currentThread().getName() + + "]: running"); + final PersistenceManager pm = pmf.getPersistenceManager(); + try { + Transaction tx = pm.currentTransaction(); + tx.begin(); + if (pc != null) { + pm.makePersistent(pc); + } + tx.commit(); + markSuccess(); + } catch (JDOUserException ex) { + markExpectedException(); + } finally { + barrier.await(); + cleanupPM(pm); + } } - tx.commit(); - markSuccess(); - } catch (JDOUserException ex) { - markExpectedException(); - } finally { - barrier.await(); - cleanupPM(pm); - } } - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/TransientTransactionalInstanceRetainsValuesAtCommit.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/TransientTransactionalInstanceRetainsValuesAtCommit.java index fad7bada6..c0e57ec24 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/TransientTransactionalInstanceRetainsValuesAtCommit.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/TransientTransactionalInstanceRetainsValuesAtCommit.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,134 +19,147 @@ import java.util.Collection; import java.util.HashSet; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Transient Transactional Instance Retains Values At Commit
    - * Keywords: transienttransactional
    - * Assertion ID: A12.5.7-21
    - * Assertion Description: If the transaction in which an instance is made transactional (by - * calling PersistenceManager.makeTransactional or makeTransactionalAll) commits, then the transient - * instance retains its values. + *Title: Transient Transactional Instance Retains Values At Commit + *
    + *Keywords: transienttransactional + *
    + *Assertion ID: A12.5.7-21 + *
    + *Assertion Description: +If the transaction in which an instance is made transactional (by calling PersistenceManager.makeTransactional or makeTransactionalAll) commits, then the transient instance retains its values. + */ + public class TransientTransactionalInstanceRetainsValuesAtCommit extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-21 (TransientTransactionalInstanceRetainsValuesAtCommit) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TransientTransactionalInstanceRetainsValuesAtCommit.class); + } + + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + + private Collection col1 = new HashSet(); + private Collection col2 = new HashSet(); + - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-21 (TransientTransactionalInstanceRetainsValuesAtCommit) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TransientTransactionalInstanceRetainsValuesAtCommit.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - - private Collection col1 = new HashSet(); - private Collection col2 = new HashSet(); - - /** */ - public void testTransientTransactionalInstanceRetainsValuesAtCommit() { - pm = getPM(); - - createObjects(pm); - runTestTransientTransactional1(pm); - runTestTransientTransactional2(pm); - runTestTransientTransactional3(pm); - - pm.close(); - pm = null; - } - - /** */ - private void createObjects(PersistenceManager pm) { - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - - col1.add(p2); - col1.add(p3); - - col2.add(p4); - col2.add(p5); - } - - /** */ - private void runTestTransientTransactional1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - if (debug) logger.debug(" ** in runTestTransientTransactional1() "); - try { - PCPoint p1 = new PCPoint(8, 8); - p1.setX(100); - tx.begin(); - p1.setX(200); - pm.makeTransactional(p1); - p1.setX(300); - tx.commit(); - tx = null; - - assertGetX(p1, 300, ASSERTION_FAILED, "runTestTransientTransactional1"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + public void testTransientTransactionalInstanceRetainsValuesAtCommit() { + pm = getPM(); + + createObjects(pm); + runTestTransientTransactional1(pm); + runTestTransientTransactional2(pm); + runTestTransientTransactional3(pm); + + pm.close(); + pm = null; + } + + /** */ + private void createObjects(PersistenceManager pm) { + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint (5,7); + + col1.add(p2); + col1.add(p3); + + col2.add(p4); + col2.add(p5); } - } - - /** */ - private void runTestTransientTransactional2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - if (debug) logger.debug(" ** in runTestTransientTransactional2() "); - try { - p2.setX(100); - p3.setX(100); - tx.begin(); - p2.setX(201); - p3.setX(201); - pm.makeTransactionalAll(col1); - p2.setX(301); - p3.setX(301); - tx.commit(); - tx = null; - - assertGetX(p2, 301, ASSERTION_FAILED, "runTestTransientTransactional2"); - assertGetX(p3, 301, ASSERTION_FAILED, "runTestTransientTransactional2"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + private void runTestTransientTransactional1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + if (debug) logger.debug(" ** in runTestTransientTransactional1() "); + try { + PCPoint p1 = new PCPoint(8,8); + p1.setX(100); + tx.begin(); + p1.setX(200); + pm.makeTransactional(p1); + p1.setX(300); + tx.commit(); + tx = null; + + assertGetX (p1, 300, ASSERTION_FAILED, "runTestTransientTransactional1"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void runTestTransientTransactional2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + if (debug) logger.debug(" ** in runTestTransientTransactional2() "); + try { + p2.setX(100); + p3.setX(100); + tx.begin(); + p2.setX(201); + p3.setX(201); + pm.makeTransactionalAll(col1); + p2.setX(301); + p3.setX(301); + tx.commit(); + tx = null; + + assertGetX (p2, 301, ASSERTION_FAILED, "runTestTransientTransactional2"); + assertGetX (p3, 301, ASSERTION_FAILED, "runTestTransientTransactional2"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - private void runTestTransientTransactional3(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - if (debug) logger.debug(" ** in runTestTransientTransactional3() "); - try { - p4.setX(100); - p5.setX(100); - tx.begin(); - p4.setX(201); - p5.setX(201); - pm.makeTransactionalAll(col2.toArray()); - p4.setX(301); - p5.setX(301); - tx.commit(); - tx = null; - - assertGetX(p4, 301, ASSERTION_FAILED, "runTestTransientTransactional2"); - assertGetX(p5, 301, ASSERTION_FAILED, "runTestTransientTransactional2"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + private void runTestTransientTransactional3(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + if (debug) logger.debug(" ** in runTestTransientTransactional3() "); + try { + p4.setX(100); + p5.setX(100); + tx.begin(); + p4.setX(201); + p5.setX(201); + pm.makeTransactionalAll(col2.toArray()); + p4.setX(301); + p5.setX(301); + tx.commit(); + tx = null; + + assertGetX (p4, 301, ASSERTION_FAILED, "runTestTransientTransactional2"); + assertGetX (p5, 301, ASSERTION_FAILED, "runTestTransientTransactional2"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/CallingEvictAllWithCollectionContainingNulls.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/CallingEvictAllWithCollectionContainingNulls.java index 652d5e32c..7b09ca499 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/CallingEvictAllWithCollectionContainingNulls.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/CallingEvictAllWithCollectionContainingNulls.java @@ -5,122 +5,137 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.cache; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Calling EvictAll With Collection Containing Nulls
    - * Keywords: cache
    - * Assertion IDs: A12.5-11
    - * Assertion Description: Passing a non-null Object[] or Collection arguments to evictAll - * that contain null elements will have the documented behavior for non-null elements, and the null - * elements will be ignored. - */ -public class CallingEvictAllWithCollectionContainingNulls extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5-11 (CallingEvictAllWithCollectionContainingNulls) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CallingEvictAllWithCollectionContainingNulls.class); - } - - private PCPoint p1; - private PCPoint p2; - private PCPoint p3; - private PCPoint p4; - private PCPoint p5; - - /** */ - public void testCallingEvictAllWithCollectionContainingNulls() { - pm = getPM(); - createObjects(pm); - runTestEvictAll1(pm); - runTestEvictAll2(pm); - pm.close(); - pm = null; - } + *Title: Calling EvictAll With Collection Containing Nulls + *
    + *Keywords: cache + *
    + *Assertion IDs: A12.5-11 + *
    + *Assertion Description: +Passing a non-null Object[] or Collection arguments to evictAll that +contain null elements will have the documented behavior for non-null elements, and the null elements +will be ignored. - /** - * @param pm the PersistenceManager - */ - private void createObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - p1 = new PCPoint(1, 3); - p2 = new PCPoint(4, 3); - p3 = new PCPoint(4, 2); - p4 = new PCPoint(3, 3); + */ - pm.makePersistent(p1); - pm.makePersistent(p2); - pm.makePersistent(p3); - pm.makePersistent(p4); +public class CallingEvictAllWithCollectionContainingNulls extends PersistenceManagerTest { - tx.commit(); - } finally { - if (tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5-11 (CallingEvictAllWithCollectionContainingNulls) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CallingEvictAllWithCollectionContainingNulls.class); } - } - - /* test evictAll (Collection col1) */ - private void runTestEvictAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - PCPoint p5 = null; - Collection col1 = new java.util.HashSet(); - col1.add(p1); - col1.add(p5); - col1.add(p2); - - pm.evictAll(col1); - if (debug) logger.debug(" \nPASSED in testEvictAll1()"); - } finally { - if (tx.isActive()) tx.rollback(); + + private PCPoint p1; + private PCPoint p2; + private PCPoint p3; + private PCPoint p4; + private PCPoint p5; + + /** */ + public void testCallingEvictAllWithCollectionContainingNulls() { + pm = getPM(); + createObjects(pm); + runTestEvictAll1(pm); + runTestEvictAll2(pm); + pm.close(); + pm = null; } - } - /** test evictAll (Object[] objArray) */ - private void runTestEvictAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - PCPoint p5 = null; - Collection col1 = new java.util.HashSet(); - col1.add(p3); - col1.add(p4); - col1.add(p5); - - pm.evictAll(col1.toArray()); - if (debug) logger.debug(" \nPASSED in testEvictAll2()"); - } finally { - if (tx.isActive()) tx.rollback(); + /** + * @param pm the PersistenceManager + */ + private void createObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + p1 = new PCPoint (1,3); + p2 = new PCPoint (4,3); + p3 = new PCPoint (4,2); + p4 = new PCPoint (3,3); + + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /* test evictAll (Collection col1) */ + private void runTestEvictAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + PCPoint p5 = null; + Collection col1 = new java.util.HashSet(); + col1.add (p1); + col1.add (p5); + col1.add (p2); + + pm.evictAll(col1); + if (debug) logger.debug(" \nPASSED in testEvictAll1()"); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /** test evictAll (Object[] objArray) */ + private void runTestEvictAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + PCPoint p5 = null; + Collection col1 = new java.util.HashSet(); + col1.add (p3); + col1.add (p4); + col1.add (p5); + + pm.evictAll(col1.toArray()); + if (debug) logger.debug(" \nPASSED in testEvictAll2()"); + } + finally { + if (tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/CallingRefreshAllWithCollectionContainingNulls.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/CallingRefreshAllWithCollectionContainingNulls.java index 6e35cde66..7b6bbebdf 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/CallingRefreshAllWithCollectionContainingNulls.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/CallingRefreshAllWithCollectionContainingNulls.java @@ -5,124 +5,140 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.cache; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Calling RefreshAll With Collection Containing Nulls
    - * Keywords: cache
    - * Assertion IDs: A12.5-12
    - * Assertion Description: Passing a non-null Object[] or Collection arguments to refreshAll - * that contain null elements will have the documented behavior for non-null elements, and the null - * elements will be ignored. + *Title: Calling RefreshAll With Collection Containing Nulls + *
    + *Keywords: cache + *
    + *Assertion IDs: A12.5-12 + *
    + *Assertion Description: +Passing a non-null Object[] or Collection arguments to refreshAll that +contain null elements will have the documented behavior for non-null elements, and the null +elements will be ignored. + */ + public class CallingRefreshAllWithCollectionContainingNulls extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5-12 (CallingRefreshAllWithCollectionContainingNulls) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CallingRefreshAllWithCollectionContainingNulls.class); - } - - private PCPoint p1; - private PCPoint p2; - private PCPoint p3; - private PCPoint p4; - private PCPoint p5; - - /** */ - public void testCallingRefreshAllWithCollectionContainingNulls() { - pm = getPM(); - createObjects(pm); - runTestRefreshAll1(pm); - runTestRefreshAll2(pm); - pm.close(); - pm = null; - } - - /** - * @param pm the PersistenceManager - */ - private void createObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 3); - p3 = new PCPoint(4, 2); - p4 = new PCPoint(3, 3); - - pm.makePersistent(p1); - pm.makePersistent(p2); - pm.makePersistent(p3); - pm.makePersistent(p4); - - tx.commit(); - } finally { - if (tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5-12 (CallingRefreshAllWithCollectionContainingNulls) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CallingRefreshAllWithCollectionContainingNulls.class); } - } - - /** test refreshAll (Collection col1) */ - private void runTestRefreshAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - PCPoint p5 = null; - Collection col1 = new java.util.HashSet(); - col1.add(p1); - col1.add(p5); - col1.add(p2); - - pm.refreshAll(col1); - if (debug) logger.debug(" \nPASSED in testRefreshAll1()"); - tx.rollback(); - } finally { - if (tx.isActive()) tx.rollback(); + + private PCPoint p1; + private PCPoint p2; + private PCPoint p3; + private PCPoint p4; + private PCPoint p5; + + /** */ + public void testCallingRefreshAllWithCollectionContainingNulls() { + pm = getPM(); + createObjects(pm); + runTestRefreshAll1(pm); + runTestRefreshAll2(pm); + pm.close(); + pm = null; } - } - - /* test refreshAll (Object[] objArray) */ - private void runTestRefreshAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - PCPoint p5 = null; - Collection col1 = new java.util.HashSet(); - col1.add(p3); - col1.add(p4); - col1.add(p5); - - pm.refreshAll(col1.toArray()); - if (debug) logger.debug(" \nPASSED in testRefreshAll2()"); - tx.rollback(); - } finally { - if (tx.isActive()) tx.rollback(); + + /** + * @param pm the PersistenceManager + */ + private void createObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + p1 = new PCPoint (1,3); + p2 = new PCPoint (2,3); + p3 = new PCPoint (4,2); + p4 = new PCPoint (3,3); + + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /** test refreshAll (Collection col1) */ + private void runTestRefreshAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + PCPoint p5 = null; + Collection col1 = new java.util.HashSet(); + col1.add (p1); + col1.add (p5); + col1.add (p2); + + pm.refreshAll(col1); + if (debug) logger.debug(" \nPASSED in testRefreshAll1()"); + tx.rollback(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + + /* test refreshAll (Object[] objArray) */ + private void runTestRefreshAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + PCPoint p5 = null; + Collection col1 = new java.util.HashSet(); + col1.add (p3); + col1.add (p4); + col1.add (p5); + + pm.refreshAll(col1.toArray()); + if (debug) logger.debug(" \nPASSED in testRefreshAll2()"); + tx.rollback(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictAllWithNoParameters.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictAllWithNoParameters.java index f2623dff1..c9020ad61 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictAllWithNoParameters.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictAllWithNoParameters.java @@ -5,127 +5,141 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.cache; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.pc.mylib.PCPoint2; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: EvictAllWithNoParameters
    - * Keywords: cache
    - * Assertion IDs: A12.5.1-2
    - * Assertion Description: If PersistenceManager.evict is called with no parameter, then all - * referenced instances are evicted. For each instance evicted, it: - * - *

      - *
    • calls the jdoPreClearmethod on each instance, if the class of the instance implements - * InstanceCallbacks - *
    • clears persistent fields on each instance after the call to jdoPreClear() - *
    • changes the state of instances to hollow or persistent-nontransactional (cannot distinguish - * between these two states) this is not directly testable. - *
    - */ -public class EvictAllWithNoParameters extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.1-2 (EvictAllWithNoParameters) failed: "; + *Title: EvictAllWithNoParameters + *
    + *Keywords: cache + *
    + *Assertion IDs: A12.5.1-2 + *
    + *Assertion Description: + If PersistenceManager.evict is called with no parameter, then all referenced instances are evicted. For each instance evicted, it: + *
      + *
    • calls the jdoPreClearmethod on each instance, if the class of the instance implements InstanceCallbacks
    • + *
    • clears persistent fields on each instance after the call to jdoPreClear()
    • + *
    • changes the state of instances to hollow or persistent-nontransactional (cannot distinguish between these two states) this is not directly testable.
    • + *
    - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(EvictAllWithNoParameters.class); - } - - private PCPoint2 pnt1 = null; - private PCPoint2 p1 = null; + */ - /** */ - public void testEvictAllWithNoParameters() { - pm = getPM(); - createObjects(pm); - runTestEvictAll(pm); - pm.close(); - pm = null; - } +public class EvictAllWithNoParameters extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.1-2 (EvictAllWithNoParameters) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(EvictAllWithNoParameters.class); + } + + private PCPoint2 pnt1 = null; + private PCPoint2 p1 = null; - /** - * @param pm the PersistenceManager - */ - private void createObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - pnt1 = new PCPoint2(1, 3); - p1 = new PCPoint2(3, 5); - pm.makePersistent(pnt1); - pm.makePersistent(p1); - tx.commit(); + /** */ + public void testEvictAllWithNoParameters() { + pm = getPM(); + createObjects(pm); + runTestEvictAll(pm); + pm.close(); + pm = null; + } - // P-nontransactional instance - // Check whether pmf supported optimitic tx - tx.setOptimistic(isOptimisticSupported()); - tx.begin(); - pnt1.getX(); - tx.commit(); + /** + * @param pm the PersistenceManager + */ + private void createObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + pnt1 = new PCPoint2(1,3); + p1 = new PCPoint2 (3,5); + pm.makePersistent(pnt1); + pm.makePersistent(p1); + tx.commit(); - // P-clean instance - tx.setOptimistic(false); - tx.begin(); - p1.getX(); - tx.commit(); - } finally { - if (tx.isActive()) tx.rollback(); + // P-nontransactional instance + // Check whether pmf supported optimitic tx + tx.setOptimistic(isOptimisticSupported()); + tx.begin(); + pnt1.getX(); + tx.commit(); + + // P-clean instance + tx.setOptimistic(false); + tx.begin(); + p1.getX(); + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } } - } - /** */ - private void runTestEvictAll(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - pm.evictAll(); + /** */ + private void runTestEvictAll(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + pm.evictAll(); - if (!p1.wasClearCalled()) { - fail(ASSERTION_FAILED, "missing call of p1.jdoPreClear during pm.evictAll"); - } - if (!pnt1.wasClearCalled()) { - fail(ASSERTION_FAILED, "missing call of pnt1.jdoPreClear during pm.evictAll"); - } + if ( !p1.wasClearCalled()) { + fail(ASSERTION_FAILED, + "missing call of p1.jdoPreClear during pm.evictAll"); + } + if ( !pnt1.wasClearCalled()) { + fail(ASSERTION_FAILED, + "missing call of pnt1.jdoPreClear during pm.evictAll"); + } - if (testState(p1, HOLLOW, "hollow") - || testState(p1, PERSISTENT_NONTRANSACTIONAL, "persistent_nontransaction")) { - ; // expected result - } else { - fail(ASSERTION_FAILED, "p1 should be HOLLOW or P-NONTX after pm.evictAll."); - } + if ( testState(p1, HOLLOW, "hollow") || + testState(p1, PERSISTENT_NONTRANSACTIONAL, "persistent_nontransaction")) { + ; // expected result + } + else { + fail(ASSERTION_FAILED, + "p1 should be HOLLOW or P-NONTX after pm.evictAll."); + } - if (testState(pnt1, HOLLOW, "hollow") - || testState(pnt1, PERSISTENT_NONTRANSACTIONAL, "persistent_nontransaction")) { - ; // expected result - } else { - fail(ASSERTION_FAILED, "pnt1 should be HOLLOW or P-NONTX after pm.evictAll."); - } - tx.commit(); - if (debug) logger.debug(" \nPASSED in testEvictAll()"); - } finally { - if (tx.isActive()) tx.rollback(); + if ( testState(pnt1, HOLLOW, "hollow") || + testState(pnt1, PERSISTENT_NONTRANSACTIONAL, "persistent_nontransaction")) { + ; // expected result + } + else { + fail(ASSERTION_FAILED, + "pnt1 should be HOLLOW or P-NONTX after pm.evictAll."); + } + tx.commit(); + if (debug) logger.debug(" \nPASSED in testEvictAll()"); + } + finally { + if (tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictingCollectionOfInstancesSideEffects.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictingCollectionOfInstancesSideEffects.java index d27f5783e..79c0414e7 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictingCollectionOfInstancesSideEffects.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictingCollectionOfInstancesSideEffects.java @@ -5,190 +5,211 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.cache; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.pc.mylib.PCPoint2; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: EvictingCollectionOfInstancesSideEffects
    - * Keywords: cache
    - * Assertion IDs: A12.5.1-4
    - * Assertion Description: If PersistenceManager.evict is called with no parameter, then all - * referenced instances are evicted. For each instance evicted, it: - * - *
      - *
    • calls the jdoPreClearmethod on each instance, if the class of the instance implements - * InstanceCallbacks - *
    • clears persistent fields on each instance after the call to jdoPreClear() - *
    • changes the state of instances to hollow or persistent-nontransactional (cannot distinguish - * between these two states) this is not directly testable. - *
    + *Title: EvictingCollectionOfInstancesSideEffects + *
    + *Keywords: cache + *
    + *Assertion IDs: A12.5.1-4 + *
    + *Assertion Description: + If PersistenceManager.evict is called with no parameter, then all referenced instances are evicted. For each instance evicted, it: + *
      + *
    • calls the jdoPreClearmethod on each instance, if the class of the instance implements InstanceCallbacks
    • + *
    • clears persistent fields on each instance after the call to jdoPreClear()
    • + *
    • changes the state of instances to hollow or persistent-nontransactional (cannot distinguish between these two states) this is not directly testable.
    • + *
    + */ + public class EvictingCollectionOfInstancesSideEffects extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.1-4 (EvictingCollectionOfInstancesSideEffects) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(EvictingCollectionOfInstancesSideEffects.class); + } + + private PCPoint2 pnt1 = null; + private PCPoint2 pnt2 = null; + private PCPoint2 p1 = null; + private PCPoint2 p2 = null; + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint2.class); + super.localSetUp(); + } - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.1-4 (EvictingCollectionOfInstancesSideEffects) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(EvictingCollectionOfInstancesSideEffects.class); - } - - private PCPoint2 pnt1 = null; - private PCPoint2 pnt2 = null; - private PCPoint2 p1 = null; - private PCPoint2 p2 = null; - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint2.class); - super.localSetUp(); - } - - /** */ - public void testEvictingCollectionOfInstancesSideEffects() { - pm = getPM(); - createObjects(pm); - runTestEvictAllCollection(pm); - runTestEvictAllArray(pm); - pm.close(); - pm = null; - } - - /** - * @param pm the PersistenceManager - */ - private void createObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - pnt1 = new PCPoint2(1, 2); - pnt2 = new PCPoint2(2, 3); - p1 = new PCPoint2(3, 1); - p2 = new PCPoint2(4, 2); - pm.makePersistent(pnt1); - pm.makePersistent(pnt2); - pm.makePersistent(p1); - pm.makePersistent(p2); - tx.commit(); - - // P-nontransactional instance - // Check whether pmf supported optimitic tx - tx.setOptimistic(isOptimisticSupported()); - tx.begin(); - pnt1.getX(); - pnt2.getX(); - tx.commit(); - - /* P-clean instance */ - tx.setOptimistic(false); - tx.begin(); - p1.getX(); - p2.getX(); - tx.commit(); - } finally { - if (tx.isActive()) tx.rollback(); + /** */ + public void testEvictingCollectionOfInstancesSideEffects() { + pm = getPM(); + createObjects(pm); + runTestEvictAllCollection(pm); + runTestEvictAllArray(pm); + pm.close(); + pm = null; } - } - - /** */ - private void runTestEvictAllCollection(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Collection col1 = new java.util.HashSet(); - col1.add(pnt1); - col1.add(p1); - - pm.evictAll(col1); - - if (!p1.wasClearCalled()) { - fail(ASSERTION_FAILED, "missing call of p1.jdoPreClear during pm.evictAll(Collection)"); - } - if (!pnt1.wasClearCalled()) { - fail(ASSERTION_FAILED, "missing call of pnt1.jdoPreClear during pm.evictAll(Collection)"); - } - - if (testState(p1, HOLLOW, "hollow") - || testState(p1, PERSISTENT_NONTRANSACTIONAL, "persistent_nontransactional")) { - ; // expected result - } else { - fail(ASSERTION_FAILED, "p1 should be HOLLOW or P-NONTX after pm.evictAll(Collection)."); - } - - if (testState(pnt1, HOLLOW, "hollow") - || testState(pnt1, PERSISTENT_NONTRANSACTIONAL, "persistent_nontransactional")) { - ; // expected result - } else { - fail(ASSERTION_FAILED, "pnt1 should be HOLLOW or P-NONTX after pm.evictAll(Collection)."); - } - - tx.commit(); - } finally { - if (tx.isActive()) tx.rollback(); + + /** + * @param pm the PersistenceManager + */ + private void createObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + pnt1 = new PCPoint2(1,2); + pnt2 = new PCPoint2(2,3); + p1 = new PCPoint2 (3,1); + p2 = new PCPoint2 (4,2); + pm.makePersistent(pnt1); + pm.makePersistent(pnt2); + pm.makePersistent(p1); + pm.makePersistent(p2); + tx.commit(); + + // P-nontransactional instance + // Check whether pmf supported optimitic tx + tx.setOptimistic(isOptimisticSupported()); + tx.begin(); + pnt1.getX(); + pnt2.getX(); + tx.commit(); + + /* P-clean instance */ + tx.setOptimistic(false); + tx.begin(); + p1.getX(); + p2.getX(); + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void runTestEvictAllCollection(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 = new java.util.HashSet(); + col1.add(pnt1); + col1.add(p1); + + pm.evictAll(col1); + + if ( !p1.wasClearCalled()) { + fail(ASSERTION_FAILED, + "missing call of p1.jdoPreClear during pm.evictAll(Collection)"); + } + if ( !pnt1.wasClearCalled()) { + fail(ASSERTION_FAILED, + "missing call of pnt1.jdoPreClear during pm.evictAll(Collection)"); + } + + if ( testState(p1, HOLLOW, "hollow") || + testState(p1, PERSISTENT_NONTRANSACTIONAL, "persistent_nontransactional")) { + ; // expected result + } + else { + fail(ASSERTION_FAILED, + "p1 should be HOLLOW or P-NONTX after pm.evictAll(Collection)."); + } + + if ( testState(pnt1, HOLLOW, "hollow") || + testState(pnt1, PERSISTENT_NONTRANSACTIONAL, "persistent_nontransactional")) { + ; // expected result + } else { + fail(ASSERTION_FAILED, + "pnt1 should be HOLLOW or P-NONTX after pm.evictAll(Collection)."); + } + + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } } - } - - /** */ - private void runTestEvictAllArray(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Collection col1 = new java.util.HashSet(); - col1.add(pnt2); - col1.add(p2); - - pm.evictAll(col1.toArray()); - - if (!p2.wasClearCalled()) { - fail(ASSERTION_FAILED, "missing call of p2.jdoPreClear during pm.evictAll(Object[])"); - } - if (!pnt2.wasClearCalled()) { - fail(ASSERTION_FAILED, "missing call of pnt2.jdoPreClear during pm.evictAll(Object[])"); - } - - if (testState(p2, HOLLOW, "hollow") - || testState(p2, PERSISTENT_NONTRANSACTIONAL, "persistent_nontransactional")) { - ; // expected result - } else { - fail(ASSERTION_FAILED, "p2 should be HOLLOW or P-NONTX after pm.evictAll(Object[])."); - } - - if (testState(pnt2, HOLLOW, "hollow") - || testState(pnt2, PERSISTENT_NONTRANSACTIONAL, "persistent_nontransactional")) { - ; // expected result - } else { - fail(ASSERTION_FAILED, "pnt2 should be HOLLOW or P-NONTX after pm.evictAll(Object[])."); - } - - tx.commit(); - } finally { - if (tx.isActive()) tx.rollback(); + + /** */ + private void runTestEvictAllArray(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 = new java.util.HashSet(); + col1.add(pnt2); + col1.add(p2); + + pm.evictAll(col1.toArray()); + + if ( !p2.wasClearCalled()) { + fail(ASSERTION_FAILED, + "missing call of p2.jdoPreClear during pm.evictAll(Object[])"); + } + if ( !pnt2.wasClearCalled()) { + fail(ASSERTION_FAILED, + "missing call of pnt2.jdoPreClear during pm.evictAll(Object[])"); + } + + if ( testState(p2, HOLLOW, "hollow") || + testState(p2, PERSISTENT_NONTRANSACTIONAL, "persistent_nontransactional")) { + ; // expected result + } else { + fail(ASSERTION_FAILED, + "p2 should be HOLLOW or P-NONTX after pm.evictAll(Object[])."); + } + + if ( testState(pnt2, HOLLOW, "hollow") || + testState(pnt2, PERSISTENT_NONTRANSACTIONAL, "persistent_nontransactional")) { + ; // expected result + } else { + fail(ASSERTION_FAILED, + "pnt2 should be HOLLOW or P-NONTX after pm.evictAll(Object[])."); + } + + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictingWithRestoreValuesFalse.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictingWithRestoreValuesFalse.java index 393641bf6..d046de045 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictingWithRestoreValuesFalse.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictingWithRestoreValuesFalse.java @@ -5,134 +5,140 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.cache; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.pc.mylib.PCPoint2; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Evicting With RestoreValues False
    - * Keywords: cache
    - * Assertion ID: A12.6.1-1.
    - * Assertion Description: If users wish to automatically evict transactional - * instances at transaction rollback time, then they should set RestoreValues - * to false. For each persistent-clean instance that the JDO - * PersistenceManager evicts, it: - * - *
      - *
    • calls the jdoPreClear method on each instance, if the class of the instance - * implements InstanceCallbacks - *
    • clears persistent fields on each instance (sets the value of the field to its Java default - * value) - *
    • changes the state of instances to hollow - *
    + *Title: Evicting With RestoreValues False + *
    + *Keywords: cache + *
    + *Assertion ID: A12.6.1-1. + *
    + *Assertion Description: +If users wish to automatically evict transactional instances at transaction +rollback time, then they should set RestoreValues to false. +For each persistent-clean instance that the +JDO PersistenceManager evicts, it: +
      +
    • calls the jdoPreClear method on each instance, +if the class of the instance implements InstanceCallbacks
    • +
    • clears persistent fields on each instance (sets the value of the field to its Java default value)
    • +
    • changes the state of instances to hollow
    • +
    + */ + public class EvictingWithRestoreValuesFalse extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.6.1-1 (EvictingWithRestoreValuesFalse) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(EvictingWithRestoreValuesFalse.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint2.class); - super.localSetUp(); - } - - /** */ - public void test() { - pm = getPM(); - PCPoint2 pt = getHollowInstance(); - - Transaction tx = pm.currentTransaction(); - tx.setRestoreValues( - false); // This should cause eviction of transactional instances when transaction is later - // rolled back. - - // Test - tx.begin(); - makePersistentClean(pt); - tx.rollback(); // This should evict pt - verify(pt); - } - - /** */ - private PCPoint2 getHollowInstance() { - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint2 pt = new PCPoint2(1, 2); - pm.makePersistent(pt); - tx.commit(); - - int curr = currentState(pt); - if (curr != HOLLOW) { - fail(ASSERTION_FAILED, "Unable to create HOLLOW instance, state is " + states[curr]); - } - return pt; - } - - /** - * @param pt PCPont2 instance - */ - private void makePersistentClean(PCPoint2 pt) { - pm.makeTransactional(pt); - int curr = currentState(pt); - if (curr != PERSISTENT_CLEAN) { - fail( - ASSERTION_FAILED, "Unable to create PERSISTENT_CLEAN instance, state is " + states[curr]); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.6.1-1 (EvictingWithRestoreValuesFalse) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(EvictingWithRestoreValuesFalse.class); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint2.class); + super.localSetUp(); } - } - - /** - * @param pt PCPoint2 instance - */ - private void verify(PCPoint2 pt) { - // When PersistenceManager evicts instances, it: calls the jdoPreClear method on each instance - if (!pt.wasClearCalled()) { - fail(ASSERTION_FAILED, "missing call of jdoPreClear"); + + /** */ + public void test() { + pm = getPM(); + PCPoint2 pt = getHollowInstance(); + + Transaction tx = pm.currentTransaction(); + tx.setRestoreValues(false); //This should cause eviction of transactional instances when transaction is later rolled back. + + //Test + tx.begin(); + makePersistentClean(pt); + tx.rollback(); // This should evict pt + verify(pt); } - // When PersistenceManager evicts instances, it: changes the state of the instances to hollow - int curr = currentState(pt); - if ((curr != HOLLOW) && (curr != PERSISTENT_NONTRANSACTIONAL)) { - fail( - ASSERTION_FAILED, - "Instance should be HOLLOW after tx.rollback(), state is " + states[curr]); + /** */ + private PCPoint2 getHollowInstance() { + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint2 pt = new PCPoint2(1,2); + pm.makePersistent(pt); + tx.commit(); + + int curr = currentState(pt); + if (curr != HOLLOW){ + fail(ASSERTION_FAILED, + "Unable to create HOLLOW instance, state is " + states[curr]); + } + return pt; } - pm.makeTransient(pt); - // When PersistenceManager evicts instances, it: clears persistent fields on each instance (sets - // the value of the field to its Java default value) - int x = pt.getX(); - Integer y = pt.getY(); - if ((x != 0) || (y != null)) { - fail( - ASSERTION_FAILED, - "persistent fields not cleared, pt.getX()==" + x + " and pt.getY()==" + y); + /** + * + * @param pt PCPont2 instance + */ + private void makePersistentClean(PCPoint2 pt) { + pm.makeTransactional(pt); + int curr = currentState(pt); + if (curr != PERSISTENT_CLEAN){ + fail(ASSERTION_FAILED, + "Unable to create PERSISTENT_CLEAN instance, state is " + states[curr]); + } } - } + + /** + * + * @param pt PCPoint2 instance + */ + private void verify(PCPoint2 pt) { + // When PersistenceManager evicts instances, it: calls the jdoPreClear method on each instance + if ( !pt.wasClearCalled()) { + fail(ASSERTION_FAILED, + "missing call of jdoPreClear"); + } + + // When PersistenceManager evicts instances, it: changes the state of the instances to hollow + int curr = currentState(pt); + if ( (curr != HOLLOW) && (curr != PERSISTENT_NONTRANSACTIONAL) ) { + fail(ASSERTION_FAILED, + "Instance should be HOLLOW after tx.rollback(), state is " + states[curr]); + } + + pm.makeTransient(pt); + // When PersistenceManager evicts instances, it: clears persistent fields on each instance (sets the value of the field to its Java default value) + int x=pt.getX(); + Integer y=pt.getY(); + if ((x != 0) || (y != null)) { + fail(ASSERTION_FAILED, + "persistent fields not cleared, pt.getX()=="+x+" and pt.getY()=="+y); + } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictingWithRetainValuesFalse.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictingWithRetainValuesFalse.java index 9387f3c02..b221a42c4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictingWithRetainValuesFalse.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictingWithRetainValuesFalse.java @@ -5,140 +5,148 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.cache; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.pc.mylib.PCPoint2; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Evicting With RetainValues False
    - * Keywords: cache
    - * Assertion ID: A12.5.1-3.
    - * Assertion Description: If users wish to automatically evict transactional - * instances at transaction commit time, then they should set RetainValues - * to false. For each persistent-clean instance that the JDO PersistenceManager - * evicts, it: - * - *
      - *
    • calls the jdoPreClear method on each instance, if the class of the instance - * implements InstanceCallbacks - *
    • clears persistent fields on each instance (sets the value of the field to its Java default - * value) - *
    • changes the state of instances to hollow - *
    + *Title: Evicting With RetainValues False + *
    + *Keywords: cache + *
    + *Assertion ID: A12.5.1-3. + *
    + *Assertion Description: +If users wish to automatically evict transactional instances at transaction +commit time, then they should set RetainValues to false. +For each persistent-clean instance that the +JDO PersistenceManager evicts, it: +
      +
    • calls the jdoPreClear method on each instance, +if the class of the instance implements InstanceCallbacks
    • +
    • clears persistent fields on each instance (sets the value of the field to its Java default value)
    • +
    • changes the state of instances to hollow
    • +
    + */ + public class EvictingWithRetainValuesFalse extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.1-3 (EvictingWithRetainValuesFalse) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(EvictingWithRetainValuesFalse.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint2.class); - super.localSetUp(); - } - - /** */ - public void test() { - - if (!isRetainValuesSupported()) { - printUnsupportedOptionalFeatureNotTested( - getClass().getName(), "javax.jdo.option.RetainValues"); - } else { - pm = getPM(); - PCPoint2 pt = getHollowInstance(); - - Transaction tx = pm.currentTransaction(); - tx.setRetainValues( - false); // This should cause eviction of transactional instances when transaction is later - // commited. - - // Test - tx.begin(); - makePersistentClean(pt); - tx.commit(); // This should evict pt - verify(pt); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.1-3 (EvictingWithRetainValuesFalse) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(EvictingWithRetainValuesFalse.class); } - } - - /** */ - private PCPoint2 getHollowInstance() { - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint2 pt = new PCPoint2(1, 2); - pm.makePersistent(pt); - tx.commit(); - - int curr = currentState(pt); - if (curr != HOLLOW) { - fail(ASSERTION_FAILED, "Unable to create HOLLOW instance, state is " + states[curr]); - } - return pt; - } - - /** - * @param pt PCPoint2 instance - */ - private void makePersistentClean(PCPoint2 pt) { - pm.makeTransactional(pt); - int curr = currentState(pt); - if (curr != PERSISTENT_CLEAN) { - fail( - ASSERTION_FAILED, "Unable to create PERSISTENT_CLEAN instance, state is " + states[curr]); + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint2.class); + super.localSetUp(); } - } - - /** - * @param pt PCPoint2 instance - */ - private void verify(PCPoint2 pt) { - // When PersistenceManager evicts instances, it: calls the jdoPreClear method on each instance - if (!pt.wasClearCalled()) { - fail(ASSERTION_FAILED, "missing call of jdoPreClear"); + + /** */ + public void test() { + + if (!isRetainValuesSupported()) { + printUnsupportedOptionalFeatureNotTested( + getClass().getName(), "javax.jdo.option.RetainValues"); + } + else + { + pm = getPM(); + PCPoint2 pt = getHollowInstance(); + + Transaction tx = pm.currentTransaction(); + tx.setRetainValues(false); //This should cause eviction of transactional instances when transaction is later commited. + + //Test + tx.begin(); + makePersistentClean(pt); + tx.commit(); // This should evict pt + verify(pt); + } } - // When PersistenceManager evicts instances, it: changes the state of the instances to hollow - int curr = currentState(pt); - if ((curr != HOLLOW) && (curr != PERSISTENT_NONTRANSACTIONAL)) { - fail( - ASSERTION_FAILED, - "Instance should be HOLLOW after tx.commit(), state is " + states[curr]); + /** */ + private PCPoint2 getHollowInstance() { + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint2 pt = new PCPoint2(1,2); + pm.makePersistent(pt); + tx.commit(); + + int curr = currentState(pt); + if (curr != HOLLOW){ + fail(ASSERTION_FAILED, + "Unable to create HOLLOW instance, state is " + states[curr]); + } + return pt; } - pm.makeTransient(pt); - // When PersistenceManager evicts instances, it: clears persistent fields on each instance (sets - // the value of the field to its Java default value) - int x = pt.getX(); - Integer y = pt.getY(); - if ((x != 0) || (y != null)) { - fail( - ASSERTION_FAILED, - "persistent fields not cleared, pt.getX()==" + x + " and pt.getY()==" + y); + /** + * + * @param pt PCPoint2 instance + */ + private void makePersistentClean(PCPoint2 pt) { + pm.makeTransactional(pt); + int curr = currentState(pt); + if (curr != PERSISTENT_CLEAN){ + fail(ASSERTION_FAILED, + "Unable to create PERSISTENT_CLEAN instance, state is " + states[curr]); + } } - } + + /** + * + * @param pt PCPoint2 instance + */ + private void verify(PCPoint2 pt) { + // When PersistenceManager evicts instances, it: calls the jdoPreClear method on each instance + if ( !pt.wasClearCalled()) { + fail(ASSERTION_FAILED, + "missing call of jdoPreClear"); + } + + // When PersistenceManager evicts instances, it: changes the state of the instances to hollow + int curr = currentState(pt); + if ( (curr != HOLLOW) && (curr != PERSISTENT_NONTRANSACTIONAL) ) { + fail(ASSERTION_FAILED, + "Instance should be HOLLOW after tx.commit(), state is " + states[curr]); + } + + pm.makeTransient(pt); + // When PersistenceManager evicts instances, it: clears persistent fields on each instance (sets the value of the field to its Java default value) + int x=pt.getX(); + Integer y=pt.getY(); + if ((x != 0) || (y != null)) { + fail(ASSERTION_FAILED, + "persistent fields not cleared, pt.getX()=="+x+" and pt.getY()=="+y); + } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/PassingNullToEvictAllThrowsException.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/PassingNullToEvictAllThrowsException.java index 7fa8882eb..f599c39fc 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/PassingNullToEvictAllThrowsException.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/PassingNullToEvictAllThrowsException.java @@ -5,102 +5,113 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.cache; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: PassingNullToEvictAllThrowsException
    - * Keywords:
    - * Assertion IDs: A12.5-9
    - * Assertion Description: Passing a null valued argument to evictAll will throw a - * NullPointerException. - */ -public class PassingNullToEvictAllThrowsException extends PersistenceManagerTest { + *Title: PassingNullToEvictAllThrowsException + *
    + *Keywords: + *
    + *Assertion IDs: A12.5-9 + *
    + *Assertion Description: +Passing a null valued argument to evictAll will throw a NullPointerException. - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5-9 (PassingNullToEvictAllThrowsException) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(PassingNullToEvictAllThrowsException.class); - } + */ - /** */ - public void testPassingNullToEvictAllThrowsException() { - pm = getPM(); +public class PassingNullToEvictAllThrowsException extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5-9 (PassingNullToEvictAllThrowsException) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(PassingNullToEvictAllThrowsException.class); + } - runTestEvictAll1(pm); - runTestEvictAll2(pm); + /** */ + public void testPassingNullToEvictAllThrowsException() { + pm = getPM(); - pm.close(); - pm = null; - } + runTestEvictAll1(pm); + runTestEvictAll2(pm); + + pm.close(); + pm = null; + } - /** - * test evictAll (Collection pcs) - * - * @param pm the PersistenceManager - */ - private void runTestEvictAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - if (debug) logger.debug("** in runTestEvictAll1() "); - try { - tx.begin(); - Collection col1 = null; - try { - pm.evictAll(col1); - fail( - ASSERTION_FAILED, - "pm.evictAll should throw NullPointerException when called with argument null"); - } catch (NullPointerException ex) { - // expected exception - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * test evictAll (Collection pcs) + * @param pm the PersistenceManager + */ + private void runTestEvictAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + if (debug) logger.debug ("** in runTestEvictAll1() "); + try { + tx.begin(); + Collection col1 = null; + try { + pm.evictAll(col1); + fail(ASSERTION_FAILED, + "pm.evictAll should throw NullPointerException when called with argument null"); + } + catch (NullPointerException ex) { + // expected exception + } + tx .rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /* test evictAll (Object[] objArray) */ - private void runTestEvictAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - if (debug) logger.debug("** in runTestEvictAll1() "); - try { - tx.begin(); - Object[] arr = null; - try { - pm.evictAll(arr); - fail( - ASSERTION_FAILED, - "pm.evictAll should throw NullPointerException when called with argument null"); - } catch (NullPointerException ex) { - // expected exception - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /* test evictAll (Object[] objArray) */ + private void runTestEvictAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + if (debug) logger.debug ("** in runTestEvictAll1() "); + try { + tx.begin(); + Object[] arr = null; + try { + pm.evictAll(arr); + fail(ASSERTION_FAILED, + "pm.evictAll should throw NullPointerException when called with argument null"); + } + catch (NullPointerException ex) { + // expected exception + } + tx .rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/PassingNullToEvictHasNoEffect.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/PassingNullToEvictHasNoEffect.java index b0ace2888..0e93a8a43 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/PassingNullToEvictHasNoEffect.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/PassingNullToEvictHasNoEffect.java @@ -5,70 +5,80 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.cache; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: PassingNullToEvictHasNoEffect
    - * Keywords:
    - * Assertion IDs: A12.5-7
    - * Assertion Description: Passing a null value to PersistenceManager.evict will have no - * effect. A NullPointerException should NOT be thrown. - */ -public class PassingNullToEvictHasNoEffect extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5-7 (PassingNullToEvictHasNoEffect) failed: "; + *Title: PassingNullToEvictHasNoEffect + *
    + *Keywords: + *
    + *Assertion IDs: A12.5-7 + *
    + *Assertion Description: +Passing a null value to PersistenceManager.evict will have no effect. A +NullPointerException should NOT be thrown. - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(PassingNullToEvictHasNoEffect.class); - } - - /** */ - public void test() { - pm = getPM(); + */ - runTestPassingNullToEvictHasNoEffect(pm); +public class PassingNullToEvictHasNoEffect extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5-7 (PassingNullToEvictHasNoEffect) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(PassingNullToEvictHasNoEffect.class); + } - pm.close(); - pm = null; - } + /** */ + public void test() { + pm = getPM(); - /** - * test evict (object pc) - * - * @param pm the PersistenceManager - */ - public void runTestPassingNullToEvictHasNoEffect(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - pm.evict(null); - if (debug) logger.debug(" \nPASSED in testPassingNullToEvictHasNoEffect()"); - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + runTestPassingNullToEvictHasNoEffect(pm); + + pm.close(); + pm = null; + } + + /** + * test evict (object pc) + * @param pm the PersistenceManager + */ + public void runTestPassingNullToEvictHasNoEffect(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + pm.evict(null); + if (debug) + logger.debug (" \nPASSED in testPassingNullToEvictHasNoEffect()"); + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/PassingNullToRefreshAllThrowsException.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/PassingNullToRefreshAllThrowsException.java index 2fa1279dd..43564369c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/PassingNullToRefreshAllThrowsException.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/PassingNullToRefreshAllThrowsException.java @@ -5,103 +5,116 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.cache; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Passing Null to RefreshAll Throws Exception
    - * Keywords: cache
    - * Assertion IDs: A12.5-10.
    - * Assertion Description: Passing a null valued argument to refreshAll will throw a - * NullPointerException. - */ -public class PassingNullToRefreshAllThrowsException extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5-10 (PassingNullToRefreshAllThrowsException) failed: "; + *Title: Passing Null to RefreshAll Throws Exception + *
    + *Keywords: cache + *
    + *Assertion IDs: A12.5-10. + *
    + *Assertion Description: +Passing a null valued argument to refreshAll will throw a +NullPointerException. - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(PassingNullToRefreshAllThrowsException.class); - } - - /** */ - public void testPassingNullToRefreshAllThrowsException() { - pm = getPM(); + */ - runTestRefreshAll1(pm); - runTestRefreshAll2(pm); +public class PassingNullToRefreshAllThrowsException + extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5-10 (PassingNullToRefreshAllThrowsException) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(PassingNullToRefreshAllThrowsException.class); + } - pm.close(); - pm = null; - } + /** */ + public void testPassingNullToRefreshAllThrowsException() { + pm = getPM(); + + runTestRefreshAll1(pm); + runTestRefreshAll2(pm); + + pm.close(); + pm = null; + } - /** - * test refreshAll (Collection pcs) - * - * @param pm the PersistenceManager - */ - public void runTestRefreshAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - if (debug) logger.debug("** in runTestRefreshAll1() "); - try { - tx.begin(); - Collection col1 = null; - try { - pm.refreshAll(col1); - fail( - ASSERTION_FAILED, - "pm.refreshAll should throw NullPointerException when called with argument null"); - } catch (NullPointerException ex) { - // expected exception - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * test refreshAll (Collection pcs) + * @param pm the PersistenceManager + */ + public void runTestRefreshAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + if (debug) logger.debug("** in runTestRefreshAll1() "); + try { + tx.begin(); + Collection col1 = null; + try { + pm.refreshAll(col1); + fail(ASSERTION_FAILED, + "pm.refreshAll should throw NullPointerException when called with argument null"); + } + catch (NullPointerException ex) { + // expected exception + } + tx .rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /* test refreshAll (Object[] objArray) */ - public void runTestRefreshAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - if (debug) logger.debug("** in runTestRefreshAll1() "); - try { - tx = pm.currentTransaction(); - tx.begin(); - Object[] arr = null; - try { - pm.refreshAll(arr); - fail( - ASSERTION_FAILED, - "pm.refreshAll should throw NullPointerException when called with argument null"); - } catch (NullPointerException ex) { - // expected exception - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /* test refreshAll (Object[] objArray) */ + public void runTestRefreshAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + if (debug) logger.debug ("** in runTestRefreshAll1() "); + try { + tx = pm.currentTransaction(); + tx.begin(); + Object[] arr = null; + try { + pm.refreshAll(arr); + fail(ASSERTION_FAILED, + "pm.refreshAll should throw NullPointerException when called with argument null"); + } + catch (NullPointerException ex) { + // expected exception + } + tx .rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/PassingNullToRefreshHasNoEffect.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/PassingNullToRefreshHasNoEffect.java index 2f8db0777..577a59ce9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/PassingNullToRefreshHasNoEffect.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/PassingNullToRefreshHasNoEffect.java @@ -5,72 +5,81 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.cache; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Passing Null to Refresh has no Effect
    - * Keywords:
    - * Assertion IDs: A12.5-8
    - * Assertion Description: Passing a null value to PersistenceManager.refresh will have no - * effect. A NullPointerException should NOT be thrown. - */ -public class PassingNullToRefreshHasNoEffect extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5-8 (PassingNullToRefreshHasNoEffect) failed: "; + *Title: Passing Null to Refresh has no Effect + *
    + *Keywords: + *
    + *Assertion IDs: A12.5-8 + *
    + *Assertion Description: +Passing a null value to PersistenceManager.refresh will have no effect. A NullPointerException should NOT be thrown. - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(PassingNullToRefreshHasNoEffect.class); - } + */ - /** */ - public void test() { - pm = getPM(); +public class PassingNullToRefreshHasNoEffect extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5-8 (PassingNullToRefreshHasNoEffect) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(PassingNullToRefreshHasNoEffect.class); + } - runTestPassingNullToRefreshHasNoEffect(pm); + /** */ + public void test() { + pm = getPM(); - pm.close(); - pm = null; - } + runTestPassingNullToRefreshHasNoEffect(pm); + + pm.close(); + pm = null; + } - /** - * test evict (object pc) - * - * @param pm the PersistenceManager - */ - private void runTestPassingNullToRefreshHasNoEffect(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - PCPoint p1 = null; - pm.refresh(p1); - if (debug) logger.debug(" \nPASSED in testPassingNullToRefreshHasNoEffect()"); - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * test evict (object pc) + * @param pm the PersistenceManager + */ + private void runTestPassingNullToRefreshHasNoEffect(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 = null; + pm.refresh(p1); + if (debug) + logger.debug (" \nPASSED in testPassingNullToRefreshHasNoEffect()"); + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/RefreshAllNoParameterSideEffects.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/RefreshAllNoParameterSideEffects.java index 970b8e49a..6f5eb9074 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/RefreshAllNoParameterSideEffects.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/RefreshAllNoParameterSideEffects.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,148 +19,149 @@ import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.pc.mylib.VersionedPCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Refresh All No Parameters Side Effects
    - * Keywords: cache
    - * Assertion ID: A12.5.1-5B
    - * Assertion Description: The refreshAll() updates the values in the parameter instance[s] - * from the data in the data store. ((The intended use is for optimistic transactions where the - * state of the JDO Instance is not guaranteed to reflect the state in the data store. This method - * can be used to minimize the occurrence of commit failures due to mismatch between the state of - * cached instances and the state of data in the data store.)) This can be tested by using 2 - * PersistenceManagers, independently change an object, then refresh. + *Title: Refresh All No Parameters Side Effects + *
    + *Keywords: cache + *
    + *Assertion ID: A12.5.1-5B + *
    + *Assertion Description: +The refreshAll() updates the values in the parameter +instance[s] from the data in the data store. ((The intended use is for optimistic transactions where the state of +the JDO Instance is not guaranteed to reflect the state in the data store. This method can be used to minimize +the occurrence of commit failures due to mismatch between the state of cached instances and the state of +data in the data store.)) This can be tested by using 2 PersistenceManagers, independently change an object, +then refresh. */ public class RefreshAllNoParameterSideEffects extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.1-5B (RefreshAllNoParameterSideEffects) failed: "; - - Object oid = null; - - PersistenceManager pm1; - PersistenceManager pm2; - PersistenceManager pmVerify; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(RefreshAllNoParameterSideEffects.class); - } - - /** */ - public void localSetUp() { - addTearDownClass(VersionedPCPoint.class); - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - VersionedPCPoint pnt = new VersionedPCPoint(0, 0); - pm.makePersistent(pnt); - oid = pm.getObjectId((Object) pnt); - tx.commit(); - } - - /** */ - public void test() { - if (!isOptimisticSupported()) { - printUnsupportedOptionalFeatureNotTested( - "RefreshAllNoParameterSideEffect", "javax.jdo.option.Optimistic"); - return; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.1-5B (RefreshAllNoParameterSideEffects) failed: "; + Object oid = null; + + PersistenceManager pm1; + PersistenceManager pm2; + PersistenceManager pmVerify; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(RefreshAllNoParameterSideEffects.class); } - pm1 = pmf.getPersistenceManager(); - pm2 = pmf.getPersistenceManager(); - pmVerify = pmf.getPersistenceManager(); - - try { - // don't refresh cache - runTestRefreshAllNoParameterSideEffects(false); - // refresh cache - runTestRefreshAllNoParameterSideEffects(true); - } finally { - cleanupPM(pmVerify); - pmVerify = null; - cleanupPM(pm1); - pm1 = null; - cleanupPM(pm1); - pm2 = null; + /** */ + public void localSetUp () { + addTearDownClass(VersionedPCPoint.class); + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + VersionedPCPoint pnt = new VersionedPCPoint (0,0); + pm.makePersistent(pnt); + oid = pm.getObjectId((Object)pnt); + tx.commit(); } - failOnError(); - } - /** - * @param doRefresh doRefresh flag - */ - private void runTestRefreshAllNoParameterSideEffects(boolean doRefresh) { - - if (debug) logger.debug("\nSTART RefreshAllNoParameterSideEffects"); - - Transaction tx1 = pm1.currentTransaction(); - tx1.setOptimistic(true); - tx1.begin(); - VersionedPCPoint pnt1 = (VersionedPCPoint) pm1.getObjectById(oid, true); - pnt1.setX(11); // make transactional - - Transaction tx2 = pm2.currentTransaction(); - tx2.begin(); - VersionedPCPoint pnt2 = (VersionedPCPoint) pm2.getObjectById(oid); - pnt2.setX(22); - pnt2.setY(Integer.valueOf("22")); - tx2.commit(); - - if (doRefresh) pm1.refreshAll(); - pnt1.setX(33); - pnt1.setY(Integer.valueOf("33")); - try { - tx1.commit(); - } catch (javax.jdo.JDOOptimisticVerificationException ove) { - if (doRefresh) { - appendMessage( - "Expected no exception on commit with doRefresh " + "true, but got " + ove.toString()); - } - // else expect exception - } catch (Exception e) { - appendMessage( - "Unexpected exception on commit. doRefresh is " - + doRefresh - + ". Exception is: " - + e.toString()); + /** */ + public void test() { + if (!isOptimisticSupported()) { + printUnsupportedOptionalFeatureNotTested( + "RefreshAllNoParameterSideEffect", + "javax.jdo.option.Optimistic"); + return; + } + + pm1 = pmf.getPersistenceManager(); + pm2 = pmf.getPersistenceManager(); + pmVerify = pmf.getPersistenceManager(); + + try { + // don't refresh cache + runTestRefreshAllNoParameterSideEffects(false); + // refresh cache + runTestRefreshAllNoParameterSideEffects(true); + } + finally { + cleanupPM(pmVerify); + pmVerify = null; + cleanupPM(pm1); + pm1 = null; + cleanupPM(pm1); + pm2 = null; + } + failOnError(); } - // verify that correct value was committed - VersionedPCPoint pntExpected = new VersionedPCPoint(33, 33); - if (!doRefresh) { - pntExpected.setX(22); - pntExpected.setY(Integer.valueOf("22")); + /** + * + * @param doRefresh doRefresh flag + */ + private void runTestRefreshAllNoParameterSideEffects(boolean doRefresh) { + + if (debug) logger.debug ("\nSTART RefreshAllNoParameterSideEffects"); + + Transaction tx1 = pm1.currentTransaction(); + tx1.setOptimistic(true); + tx1.begin(); + VersionedPCPoint pnt1 = (VersionedPCPoint)pm1.getObjectById(oid, true); + pnt1.setX(11); // make transactional + + Transaction tx2 = pm2.currentTransaction(); + tx2.begin(); + VersionedPCPoint pnt2 = (VersionedPCPoint)pm2.getObjectById(oid); + pnt2.setX(22); + pnt2.setY(Integer.valueOf("22")); + tx2.commit(); + + if (doRefresh) + pm1.refreshAll(); + pnt1.setX(33); + pnt1.setY(Integer.valueOf("33")); + try { + tx1.commit(); + } catch (javax.jdo.JDOOptimisticVerificationException ove) { + if (doRefresh) { + appendMessage("Expected no exception on commit with doRefresh " + + "true, but got " + ove.toString()); + } + // else expect exception + } catch (Exception e) { + appendMessage("Unexpected exception on commit. doRefresh is " + + doRefresh + ". Exception is: " + e.toString()); + } + + // verify that correct value was committed + VersionedPCPoint pntExpected = new VersionedPCPoint(33, 33); + if (!doRefresh) { + pntExpected.setX(22); + pntExpected.setY(Integer.valueOf("22")); + } + + Transaction txVerify = pmVerify.currentTransaction(); + txVerify.begin(); + VersionedPCPoint pntVerify = + (VersionedPCPoint)pmVerify.getObjectById(oid, true); + if (pntVerify.getX() != pntExpected.getX() + || pntVerify.getY().intValue() != pntExpected.getY().intValue()) + { + appendMessage("After commit with doRefresh " + doRefresh + + " expected (" + + pntExpected.getX() + ", " + pntExpected.getY() + + ") but actual is (" + + pntVerify.getX() + ", " + pntVerify.getY() + ")."); + } + txVerify.commit(); + + if (debug) logger.debug ("END RefreshAllNoParameterSideEffects" + + "doRefresh is " + doRefresh); } - - Transaction txVerify = pmVerify.currentTransaction(); - txVerify.begin(); - VersionedPCPoint pntVerify = (VersionedPCPoint) pmVerify.getObjectById(oid, true); - if (pntVerify.getX() != pntExpected.getX() - || pntVerify.getY().intValue() != pntExpected.getY().intValue()) { - appendMessage( - "After commit with doRefresh " - + doRefresh - + " expected (" - + pntExpected.getX() - + ", " - + pntExpected.getY() - + ") but actual is (" - + pntVerify.getX() - + ", " - + pntVerify.getY() - + ")."); - } - txVerify.commit(); - - if (debug) logger.debug("END RefreshAllNoParameterSideEffects" + "doRefresh is " + doRefresh); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/RefreshAllSideEffects.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/RefreshAllSideEffects.java index 9dc603933..a669efe52 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/RefreshAllSideEffects.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/RefreshAllSideEffects.java @@ -5,189 +5,195 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.cache; -import java.util.ArrayList; import java.util.Collection; +import java.util.ArrayList; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.pc.mylib.VersionedPCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Refresh All Side Effects
    - * Keywords: cache
    - * Assertion ID: A12.5.1-5D
    - * Assertion Description: The refreshAll(Object[] pcs) updates the values in the parameter - * instance[s] from the data in the data store. ((The intended use is for optimistic transactions - * where the state of the JDO Instance is not guaranteed to reflect the state in the data store. - * This method can be used to minimize the occurrence of commit failures due to mismatch between the - * state of cached instances and the state of data in the data store.)) This can be tested by using - * 2 PersistenceManagers, independently change an object, then refresh. + *Title: Refresh All Side Effects + *
    + *Keywords: cache + *
    + *Assertion ID: A12.5.1-5D + *
    + *Assertion Description: +The refreshAll(Object[] pcs) updates the values in the parameter +instance[s] from the data in the data store. ((The intended use is for optimistic transactions where the state of +the JDO Instance is not guaranteed to reflect the state in the data store. This method can be used to minimize +the occurrence of commit failures due to mismatch between the state of cached instances and the state of +data in the data store.)) This can be tested by using 2 PersistenceManagers, independently change an object, +then refresh. */ public class RefreshAllSideEffects extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.1-5D (RefreshAllSideEffects) failed: "; - - ArrayList oids = new ArrayList(); - - PersistenceManager pm1; - PersistenceManager pm2; - PersistenceManager pmVerify; - Collection coll = new ArrayList(); // Collection of persistent instances - boolean useCollection = true; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(RefreshAllSideEffects.class); - } - - /** */ - public void localSetUp() { - addTearDownClass(VersionedPCPoint.class); - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - VersionedPCPoint pnt1 = new VersionedPCPoint(0, 0); - VersionedPCPoint pnt2 = new VersionedPCPoint(-1, -1); - coll.add(pnt1); - coll.add(pnt2); - pm.makePersistentAll(coll); - - oids.add(0, pm.getObjectId((Object) pnt1)); - oids.add(1, pm.getObjectId((Object) pnt2)); - tx.commit(); - } - - /** */ - public void testRefreshAllWithCollection() { - useCollection = true; - runtest(); - } - - /** */ - public void testRefreshAllWithArray() { - useCollection = false; - runtest(); - } - - /** */ - private void runtest() { - if (!isOptimisticSupported()) { - printUnsupportedOptionalFeatureNotTested( - "RefreshAllSideEffects", "javax.jdo.option.Optimistic"); - return; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.1-5D (RefreshAllSideEffects) failed: "; + + ArrayList oids = new ArrayList(); + + PersistenceManager pm1; + PersistenceManager pm2; + PersistenceManager pmVerify; + Collection coll = new ArrayList(); // Collection of persistent instances + boolean useCollection = true; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(RefreshAllSideEffects.class); } - pm1 = pmf.getPersistenceManager(); - pm2 = pmf.getPersistenceManager(); - pmVerify = pmf.getPersistenceManager(); - - try { - // don't refresh cache - runTestRefreshAllSideEffects(false); - // refresh cache - runTestRefreshAllSideEffects(true); - } finally { - cleanupPM(pmVerify); - pmVerify = null; - cleanupPM(pm1); - pm1 = null; - cleanupPM(pm1); - pm2 = null; - } - failOnError(); - } - - /** */ - private void runTestRefreshAllSideEffects(boolean doRefresh) { - - if (debug) logger.debug("\nSTART RefreshAllSideEffects"); - - Transaction tx1 = pm1.currentTransaction(); - tx1.setOptimistic(true); - tx1.begin(); - Collection points1 = pm1.getObjectsById(oids, true); - ((VersionedPCPoint) points1.toArray()[0]).setX(11); // make transactional - - Transaction tx2 = pm2.currentTransaction(); - tx2.begin(); - Collection points2 = pm2.getObjectsById(oids); - ((VersionedPCPoint) points2.toArray()[0]).setX(22); - ((VersionedPCPoint) points2.toArray()[1]).setX(22); - ((VersionedPCPoint) points2.toArray()[0]).setY(Integer.valueOf("22")); - ((VersionedPCPoint) points2.toArray()[1]).setY(Integer.valueOf("22")); - tx2.commit(); - - if (doRefresh) { - if (useCollection) pm1.refreshAll(points1); - else pm1.refreshAll(points1.toArray()); - } - ((VersionedPCPoint) points1.toArray()[0]).setX(33); - ((VersionedPCPoint) points1.toArray()[1]).setX(33); - ((VersionedPCPoint) points1.toArray()[0]).setY(Integer.valueOf("33")); - ((VersionedPCPoint) points1.toArray()[1]).setY(Integer.valueOf("33")); - try { - tx1.commit(); - } catch (javax.jdo.JDOOptimisticVerificationException ove) { - if (doRefresh) { - appendMessage( - "Expected no exception on commit with doRefresh " + "true, but got " + ove.toString()); - } - // else expect exception - } catch (Exception e) { - appendMessage( - "Unexpected exception on commit. doRefresh is " - + doRefresh - + ". Exception is: " - + e.toString()); + /** */ + public void localSetUp () { + addTearDownClass(VersionedPCPoint.class); + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + VersionedPCPoint pnt1 = new VersionedPCPoint(0,0); + VersionedPCPoint pnt2 = new VersionedPCPoint (-1,-1); + coll.add(pnt1); + coll.add(pnt2); + pm.makePersistentAll(coll); + + oids.add(0, pm.getObjectId((Object)pnt1)); + oids.add(1, pm.getObjectId((Object)pnt2)); + tx.commit(); } - // verify that correct value was committed - VersionedPCPoint pntExpected = new VersionedPCPoint(33, 33); - if (!doRefresh) { - pntExpected.setX(22); - pntExpected.setY(Integer.valueOf("22")); + /** */ + public void testRefreshAllWithCollection() { + useCollection = true; + runtest(); } - Transaction txVerify = pmVerify.currentTransaction(); - txVerify.begin(); - Collection pointsVerify = pmVerify.getObjectsById(oids, true); - if (((VersionedPCPoint) pointsVerify.toArray()[0]).getX() != pntExpected.getX() - || ((VersionedPCPoint) pointsVerify.toArray()[0]).getY().intValue() - != pntExpected.getY().intValue()) { - appendMessage( - "After commit with doRefresh " - + doRefresh - + " expected (" - + pntExpected.getX() - + ", " - + pntExpected.getY() - + ") but actual is (" - + ((VersionedPCPoint) pointsVerify.toArray()[0]).getX() - + ", " - + ((VersionedPCPoint) pointsVerify.toArray()[0]).getY().intValue() - + ")."); + /** */ + public void testRefreshAllWithArray() { + useCollection = false; + runtest(); } - txVerify.commit(); - if (debug) logger.debug("END RefreshAllSideEffects" + "doRefresh is " + doRefresh); - } + /** */ + private void runtest() { + if (!isOptimisticSupported()) { + printUnsupportedOptionalFeatureNotTested( + "RefreshAllSideEffects", + "javax.jdo.option.Optimistic"); + return; + } + + pm1 = pmf.getPersistenceManager(); + pm2 = pmf.getPersistenceManager(); + pmVerify = pmf.getPersistenceManager(); + + try { + // don't refresh cache + runTestRefreshAllSideEffects(false); + // refresh cache + runTestRefreshAllSideEffects(true); + } + finally { + cleanupPM(pmVerify); + pmVerify = null; + cleanupPM(pm1); + pm1 = null; + cleanupPM(pm1); + pm2 = null; + } + failOnError(); + } + + /** */ + private void runTestRefreshAllSideEffects(boolean doRefresh) { + + if (debug) logger.debug ("\nSTART RefreshAllSideEffects"); + + Transaction tx1 = pm1.currentTransaction(); + tx1.setOptimistic(true); + tx1.begin(); + Collection points1 = pm1.getObjectsById(oids, true); + ((VersionedPCPoint)points1.toArray()[0]).setX(11); // make transactional + + Transaction tx2 = pm2.currentTransaction(); + tx2.begin(); + Collection points2 = pm2.getObjectsById(oids); + ((VersionedPCPoint)points2.toArray()[0]).setX(22); + ((VersionedPCPoint)points2.toArray()[1]).setX(22); + ((VersionedPCPoint)points2.toArray()[0]).setY(Integer.valueOf("22")); + ((VersionedPCPoint)points2.toArray()[1]).setY(Integer.valueOf("22")); + tx2.commit(); + + if (doRefresh) { + if (useCollection) + pm1.refreshAll(points1); + else pm1.refreshAll(points1.toArray()); + } + ((VersionedPCPoint)points1.toArray()[0]).setX(33); + ((VersionedPCPoint)points1.toArray()[1]).setX(33); + ((VersionedPCPoint)points1.toArray()[0]).setY(Integer.valueOf("33")); + ((VersionedPCPoint)points1.toArray()[1]).setY(Integer.valueOf("33")); + try { + tx1.commit(); + } catch (javax.jdo.JDOOptimisticVerificationException ove) { + if (doRefresh) { + appendMessage("Expected no exception on commit with doRefresh " + + "true, but got " + ove.toString()); + } + // else expect exception + } catch (Exception e) { + appendMessage("Unexpected exception on commit. doRefresh is " + + doRefresh + ". Exception is: " + e.toString()); + } + + // verify that correct value was committed + VersionedPCPoint pntExpected = new VersionedPCPoint(33, 33); + if (!doRefresh) { + pntExpected.setX(22); + pntExpected.setY(Integer.valueOf("22")); + } + + Transaction txVerify = pmVerify.currentTransaction(); + txVerify.begin(); + Collection pointsVerify = + pmVerify.getObjectsById(oids, true); + if (((VersionedPCPoint)pointsVerify.toArray()[0]).getX() + != pntExpected.getX() + || ((VersionedPCPoint)pointsVerify.toArray()[0]).getY().intValue() + != pntExpected.getY().intValue()) + { + appendMessage("After commit with doRefresh " + doRefresh + + " expected (" + + pntExpected.getX() + ", " + pntExpected.getY() + + ") but actual is (" + + ((VersionedPCPoint)pointsVerify.toArray()[0]).getX() + + ", " + + ((VersionedPCPoint)pointsVerify.toArray()[0]).getY().intValue() + + ")."); + } + txVerify.commit(); + + if (debug) logger.debug ("END RefreshAllSideEffects" + + "doRefresh is " + doRefresh); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/RefreshAllWithNoParameters.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/RefreshAllWithNoParameters.java index 364d3784e..d2b199f2f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/RefreshAllWithNoParameters.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/RefreshAllWithNoParameters.java @@ -5,90 +5,101 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.cache; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Refresh All With No Parameters
    - * Keywords: cache
    - * Assertion ID: A12.5.1-6.
    - * Assertion Description: The PersistenceManager.refreshAll method with no - * parameters causes all transactional instances to be refreshed. Note that this method will cause - * loss of changes made to affected instances by the application due to refreshing the contents from - * the data store. The JDO PersistenceManager: - * - *
      - *
    • loads persistent values from the data store; - *
    • loads persistent fields into the instance; - *
    • calls the jdoPostLoad method on each persistent instance, if the class of the - * instance implements InstanceCallbacks; and - *
    • changes the state of persistent-dirty instances to persistent-clean. - *
    - */ -public class RefreshAllWithNoParameters extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.1-6 (RefreshAllWithNoParameters) failed: "; + *Title: Refresh All With No Parameters + *
    + *Keywords: cache + *
    + *Assertion ID: A12.5.1-6. + *
    + *Assertion Description: + The PersistenceManager.refreshAll method with no parameters + causes all transactional instances to be refreshed. Note that this method + will cause loss of changes made to affected instances by the application + due to refreshing the contents from the data store. + The JDO PersistenceManager: +
      +
    • loads persistent values from the data store;
    • +
    • loads persistent fields into the instance;
    • +
    • calls the jdoPostLoad method on each persistent instance, + if the class of the instance implements InstanceCallbacks; and
    • +
    • changes the state of persistent-dirty instances to persistent-clean.
    • +
    - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(RefreshAllWithNoParameters.class); - } - - /** */ - public void test() { - pm = getPM(); + */ - runTestRefreshAll(pm); +public class RefreshAllWithNoParameters extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.1-6 (RefreshAllWithNoParameters) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(RefreshAllWithNoParameters.class); + } - pm.close(); - pm = null; - } + /** */ + public void test() { + pm = getPM(); - /** - * @param pm the PersistenceManager - */ - private void runTestRefreshAll(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - PCPoint p = new PCPoint(100, 200); - pm.makePersistent(p); - tx.commit(); + runTestRefreshAll(pm); - tx.begin(); - p.setX(500); - p.setY(Integer.valueOf(800)); - pm.refreshAll(); - int currentX = p.getX(); - Integer currentY = p.getY(); - if ((currentX != 100) || !currentY.equals(Integer.valueOf(200))) { - fail(ASSERTION_FAILED, "RefreshAll expected 100, 200; got " + currentX + ", " + currentY); - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + pm.close(); + pm = null; + } + + /** + * @param pm the PersistenceManager + */ + private void runTestRefreshAll(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + PCPoint p = new PCPoint (100, 200); + pm.makePersistent(p); + tx.commit(); + + tx.begin(); + p.setX(500); + p.setY(Integer.valueOf(800)); + pm.refreshAll(); + int currentX = p.getX(); + Integer currentY = p.getY(); + if ((currentX != 100) || !currentY.equals(Integer.valueOf(200))) { + fail(ASSERTION_FAILED, + "RefreshAll expected 100, 200; got " + currentX + ", " + currentY); + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/RefreshSideEffects.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/RefreshSideEffects.java index 1db01d443..54a9c699a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/RefreshSideEffects.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/RefreshSideEffects.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -21,204 +21,225 @@ import javax.jdo.PersistenceManager; import javax.jdo.PersistenceManagerFactory; import javax.jdo.Transaction; + import junit.framework.AssertionFailedError; + import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; import org.apache.jdo.tck.util.ThreadExceptionHandler; /** - * Title: Refresh Side Effects
    - * Keywords: cache
    - * Assertion ID: A12.5.1-5A
    - * Assertion Description: The refresh method updates the values in the parameter instance[s] - * from the data in the data store. ((The intended use is for optimistic transactions where the - * state of the JDO Instance is not guaranteed to reflect the state in the data store. This method - * can be used to minimize the occurrence of commit failures due to mismatch between the state of - * cached instances and the state of data in the data store.)) This can be tested by using 2 - * PersistenceManagers, independently change an object, then refresh. + *Title: Refresh Side Effects + *
    + *Keywords: cache + *
    + *Assertion ID: A12.5.1-5A + *
    + *Assertion Description: + The refresh method updates the values in the parameter + instance[s] from the data in the data store. ((The intended use is for optimistic transactions where the state of + the JDO Instance is not guaranteed to reflect the state in the data store. This method can be used to minimize + the occurrence of commit failures due to mismatch between the state of cached instances and the state of + data in the data store.)) This can be tested by using 2 PersistenceManagers, independently change an object, + then refresh. */ public class RefreshSideEffects extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.1-5A (RefreshSideEffects) failed: "; - - /** */ - static final int DELAY = 100; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(RefreshSideEffects.class); - } - - /** - * @throws Exception exception - */ - public void test() throws Exception { - PersistenceManagerFactory pmf = getPMF(); - PersistenceManager pm1 = pmf.getPersistenceManager(); - PersistenceManager pm2 = pmf.getPersistenceManager(); - - try { - runTestRefreshSideEffects(pm1, pm2); - } finally { - cleanupPM(pm2); - pm2 = null; - cleanupPM(pm1); - pm1 = null; - } - } - - /** - * @param pm1 the first PersistenceManager - * @param pm2 the second PersistenceManager - * @throws Exception - */ - private void runTestRefreshSideEffects(PersistenceManager pm1, PersistenceManager pm2) - throws Exception { - if (debug) logger.debug("\nSTART RefreshSideEffects"); - - ThreadExceptionHandler group = new ThreadExceptionHandler(); - RefreshThreadT1 thread1 = new RefreshThreadT1(pm1); - Thread T1 = new Thread(group, thread1, "T1"); - RefreshThreadT2 thread2 = new RefreshThreadT2(pm2); - Thread T2 = new Thread(group, thread2, "T2"); - thread1.setOther(thread2); - thread2.setOther(thread1); - - T1.start(); - T2.start(); - - T1.join(); - T2.join(); - - Throwable t1Problem = group.getUncaughtException(T1); - if (t1Problem != null) { - if (t1Problem instanceof AssertionFailedError) throw (AssertionFailedError) t1Problem; - else - throw new JDOFatalException("Thread " + T1.getName() + " results in exception ", t1Problem); - } - Throwable t2Problem = group.getUncaughtException(T2); - if (t2Problem != null) { - if (t2Problem instanceof AssertionFailedError) throw (AssertionFailedError) t2Problem; - else - throw new JDOFatalException("Thread " + T2.getName() + " results in exception ", t2Problem); - } - - if (debug) logger.debug("END RefreshSideEffects"); - } - - /** */ - class RefreshThreadT1 implements Runnable { - - PersistenceManager pm; - RefreshThreadT2 other; - boolean commitDone; - + /** */ - RefreshThreadT1(PersistenceManager pm) { - this.pm = pm; - this.other = null; - this.commitDone = false; - } - + private static final String ASSERTION_FAILED = + "Assertion A12.5.1-5A (RefreshSideEffects) failed: "; + /** */ - void setOther(RefreshThreadT2 other) { - this.other = other; + static final int DELAY = 100; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(RefreshSideEffects.class); } - /** */ - boolean isCommitDone() { - return commitDone; + /** + * @throws Exception exception + */ + public void test () throws Exception { + PersistenceManagerFactory pmf = getPMF(); + PersistenceManager pm1 = pmf.getPersistenceManager(); + PersistenceManager pm2 = pmf.getPersistenceManager(); + + try { + runTestRefreshSideEffects(pm1, pm2); + } + finally { + cleanupPM(pm2); + pm2 = null; + cleanupPM(pm1); + pm1 = null; + } } - /** */ - public synchronized void run() { - PCPoint n1 = new PCPoint(5, 1); - Transaction tx = pm.currentTransaction(); - try { - RefreshSideEffects.this.logger.debug(" ThreadT1: START"); - tx.begin(); - n1.setX(500); - pm.makePersistent(n1); - pm.refresh(n1); - - RefreshSideEffects.this.logger.debug(" ThreadT1: waiting for ThreadT2.done"); - while (!other.isDone()) { - try { - Thread.sleep(DELAY); - } catch (InterruptedException ex) { - // ignore - } + /** + * + * @param pm1 the first PersistenceManager + * @param pm2 the second PersistenceManager + * @throws Exception + */ + private void runTestRefreshSideEffects(PersistenceManager pm1, + PersistenceManager pm2) throws Exception { + if (debug) logger.debug ("\nSTART RefreshSideEffects"); + + ThreadExceptionHandler group = new ThreadExceptionHandler(); + RefreshThreadT1 thread1 = new RefreshThreadT1(pm1); + Thread T1 = new Thread(group, thread1, "T1"); + RefreshThreadT2 thread2 = new RefreshThreadT2(pm2); + Thread T2 = new Thread(group, thread2, "T2"); + thread1.setOther(thread2); + thread2.setOther(thread1); + + T1.start(); + T2.start(); + + T1.join(); + T2.join(); + + Throwable t1Problem = group.getUncaughtException(T1); + if (t1Problem != null) { + if (t1Problem instanceof AssertionFailedError) + throw (AssertionFailedError)t1Problem; + else + throw new JDOFatalException( "Thread "+T1.getName()+" results in exception ", t1Problem ); + } + Throwable t2Problem = group.getUncaughtException(T2); + if (t2Problem != null) { + if (t2Problem instanceof AssertionFailedError) + throw (AssertionFailedError)t2Problem; + else + throw new JDOFatalException( "Thread "+T2.getName()+" results in exception ", t2Problem ); } - tx.commit(); - tx = null; - commitDone = true; - RefreshSideEffects.this.logger.debug(" ThreadT1: commit finished."); - } finally { - commitDone = true; - if ((tx != null) && tx.isActive()) tx.rollback(); - } + if (debug) logger.debug ("END RefreshSideEffects"); } - } - /** */ - class RefreshThreadT2 implements Runnable { + /** */ + class RefreshThreadT1 implements Runnable { - PersistenceManager pm; - RefreshThreadT1 other; - boolean done; + PersistenceManager pm; + RefreshThreadT2 other; + boolean commitDone; - /** */ - RefreshThreadT2(PersistenceManager pm) { - this.pm = pm; - this.other = null; - this.done = false; - } + /** */ + RefreshThreadT1(PersistenceManager pm) { + this.pm = pm; + this.other = null; + this.commitDone = false; + } - /** */ - boolean isDone() { - return done; + /** */ + void setOther(RefreshThreadT2 other) { + this.other = other; + } + + /** */ + boolean isCommitDone() { + return commitDone; + } + + /** */ + synchronized public void run() { + PCPoint n1 = new PCPoint (5,1); + Transaction tx = pm.currentTransaction(); + try { + RefreshSideEffects.this.logger.debug(" ThreadT1: START"); + tx.begin(); + n1.setX(500); + pm.makePersistent(n1); + pm.refresh(n1); + + RefreshSideEffects.this.logger.debug( + " ThreadT1: waiting for ThreadT2.done"); + while (!other.isDone()) { + try { + Thread.sleep(DELAY); + } + catch (InterruptedException ex) { + // ignore + } + } + + tx.commit(); + tx = null; + commitDone = true; + RefreshSideEffects.this.logger.debug( + " ThreadT1: commit finished."); + } + finally { + commitDone = true; + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } } /** */ - void setOther(RefreshThreadT1 other) { - this.other = other; - } + class RefreshThreadT2 implements Runnable { + + PersistenceManager pm; + RefreshThreadT1 other; + boolean done; + + /** */ + RefreshThreadT2(PersistenceManager pm) { + this.pm = pm; + this.other = null; + this.done = false; + } + + /** */ + boolean isDone() { + return done; + } + + + /** */ + void setOther(RefreshThreadT1 other) { + this.other = other; + } - /* test refresh() */ - public synchronized void run() { - PCPoint p1 = new PCPoint(5, 1); - Transaction tx = pm.currentTransaction(); - try { - RefreshSideEffects.this.logger.debug(" ThreadT2: START"); - tx.begin(); - p1.setX(201); - pm.makePersistent(p1); - pm.refresh(p1); - done = true; - - RefreshSideEffects.this.logger.debug(" ThreadT2: waiting for commit of ThreadT1"); - while (!other.isCommitDone()) { - try { - Thread.sleep(DELAY); - } catch (InterruptedException ex) { - // ignore - } + /* test refresh() */ + synchronized public void run() { + PCPoint p1 = new PCPoint (5,1); + Transaction tx = pm.currentTransaction(); + try { + RefreshSideEffects.this.logger.debug(" ThreadT2: START"); + tx.begin(); + p1.setX(201); + pm.makePersistent(p1); + pm.refresh(p1); + done = true; + + RefreshSideEffects.this.logger.debug( + " ThreadT2: waiting for commit of ThreadT1"); + while (!other.isCommitDone()) { + try { + Thread.sleep(DELAY); + } + catch (InterruptedException ex) { + // ignore + } + } + tx.commit(); + tx = null; + RefreshSideEffects.this.logger.debug( + " ThreadT2: commit finished."); + } + finally { + done = true; + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - tx.commit(); - tx = null; - RefreshSideEffects.this.logger.debug(" ThreadT2: commit finished."); - } finally { - done = true; - if ((tx != null) && tx.isActive()) tx.rollback(); - } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/Retrieve.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/Retrieve.java index 398c21edb..2d705e520 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/Retrieve.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/cache/Retrieve.java @@ -5,322 +5,346 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.cache; import java.util.ArrayList; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.pc.mylib.PCPoint2; import org.apache.jdo.tck.pc.mylib.PCRect; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Retrieve
    - * Keywords: cache
    - * Assertion IDs: A12.6.1-2, A12.6.1-5
    - * Assertion Description: These methods request the PersistenceManager to load all - * persistent fields into the parameter instances. Subsequent to this call, the application might - * call makeTransient on the parameter instances, and the fields can no longer be touched by the - * PersistenceManager. The PersistenceManager might also retrieve related instances according to a - * pre-read policy (not specified by JDO). The JDO PersistenceManager loads persistent values from - * the datastore into the instance and if the class of the instance implements InstanceCallbacks - * calls jdoPostLoad. + *Title: Retrieve + *
    + *Keywords: cache + *
    + *Assertion IDs: A12.6.1-2, A12.6.1-5 + *
    + *Assertion Description: +These methods request the PersistenceManager to load all persistent fields into +the parameter instances. Subsequent to this call, the application might +call makeTransient on the parameter instances, and the fields can no +longer be touched by the PersistenceManager. The PersistenceManager +might also retrieve related instances according to a pre-read policy +(not specified by JDO). +The JDO PersistenceManager loads persistent values from the datastore into the instance +and if the class of the instance implements InstanceCallbacks calls jdoPostLoad. */ -public class Retrieve extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertions A12.6.1-2, A12.6.1-5 (Retrieve) failed: "; +public class Retrieve extends PersistenceManagerTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Retrieve.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertions A12.6.1-2, A12.6.1-5 (Retrieve) failed: "; - private PCPoint p1 = null; - private String p1print = null; - private PCPoint p2 = null; - private PCPoint2 p3 = null; - private PCRect rect = null; + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Retrieve.class); + } - private static final Integer one = Integer.valueOf(1); - private static final Integer three = Integer.valueOf(3); + private PCPoint p1 = null; + private String p1print = null; + private PCPoint p2 = null; + private PCPoint2 p3 = null; + private PCRect rect = null; - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint2.class); - addTearDownClass(PCRect.class); - addTearDownClass(PCPoint.class); - } + private static final Integer one = Integer.valueOf(1); + private static final Integer three = Integer.valueOf(3); - /** */ - public void test() { - pm = getPM(); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint2.class); + addTearDownClass(PCRect.class); + addTearDownClass(PCPoint.class); + } - runTestRetrieve(pm); - runTestRetrieveAllWithCollection(pm); - runTestRetrieveAllWithArray(pm); - runTestRetrieveAllWithCollectionDFGtrue(pm); - runTestRetrieveAllWithArrayDFGtrue(pm); - runTestRetrieveAllWithCollectionDFGfalse(pm); - runTestRetrieveAllWithArrayDFGfalse(pm); + /** */ + public void test () { + pm = getPM(); - pm.close(); - pm = null; - } + runTestRetrieve(pm); + runTestRetrieveAllWithCollection(pm); + runTestRetrieveAllWithArray(pm); + runTestRetrieveAllWithCollectionDFGtrue(pm); + runTestRetrieveAllWithArrayDFGtrue(pm); + runTestRetrieveAllWithCollectionDFGfalse(pm); + runTestRetrieveAllWithArrayDFGfalse(pm); - /** - * @param pm the PersistenceManager - */ - private void runTestRetrieve(PersistenceManager pm) { - createObjects(pm); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - pm.retrieve(p1); - pm.retrieve(p3); - pm.retrieve(rect); - pm.makeTransient(p1); - pm.makeTransient(p3); - pm.makeTransient(rect); - tx.commit(); - tx = null; - checkP1(); - checkP3(); - checkRectP1(); - checkRectId(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + pm.close(); + pm = null; } - } - /** */ - private void runTestRetrieveAllWithCollection(PersistenceManager pm) { - createObjects(pm); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Collection coll = new ArrayList(); - coll.add(p1); - coll.add(p3); - coll.add(rect); - pm.retrieveAll(coll); - pm.makeTransientAll(coll); - tx.commit(); - tx = null; - checkP1(); - checkP3(); - checkRectP1(); - checkRectId(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * @param pm the PersistenceManager + */ + private void runTestRetrieve(PersistenceManager pm) { + createObjects(pm); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + pm.retrieve(p1); + pm.retrieve(p3); + pm.retrieve(rect); + pm.makeTransient(p1); + pm.makeTransient(p3); + pm.makeTransient(rect); + tx.commit(); + tx = null; + checkP1(); + checkP3(); + checkRectP1(); + checkRectId(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** */ - private void runTestRetrieveAllWithCollectionDFGtrue(PersistenceManager pm) { - createObjects(pm); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Collection coll = new ArrayList(); - coll.add(p1); - coll.add(p3); - coll.add(rect); - pm.retrieveAll(coll, true); - pm.makeTransientAll(coll); - tx.commit(); - tx = null; - checkP1(); - checkP3(); - // checkRectP1(); p1 is not in the default fetch group by default - checkRectId(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private void runTestRetrieveAllWithCollection(PersistenceManager pm) { + createObjects(pm); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Collection coll = new ArrayList(); + coll.add(p1); + coll.add(p3); + coll.add(rect); + pm.retrieveAll(coll); + pm.makeTransientAll(coll); + tx.commit(); + tx = null; + checkP1(); + checkP3(); + checkRectP1(); + checkRectId(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** */ - private void runTestRetrieveAllWithCollectionDFGfalse(PersistenceManager pm) { - createObjects(pm); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Collection coll = new ArrayList(); - coll.add(p1); - coll.add(p3); - coll.add(rect); - pm.retrieveAll(coll, false); - pm.makeTransientAll(coll); - tx.commit(); - tx = null; - checkP1(); - checkP3(); - checkRectP1(); - checkRectId(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private void runTestRetrieveAllWithCollectionDFGtrue(PersistenceManager pm) { + createObjects(pm); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Collection coll = new ArrayList(); + coll.add(p1); + coll.add(p3); + coll.add(rect); + pm.retrieveAll(coll, true); + pm.makeTransientAll(coll); + tx.commit(); + tx = null; + checkP1(); + checkP3(); + // checkRectP1(); p1 is not in the default fetch group by default + checkRectId(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** */ - private void runTestRetrieveAllWithArray(PersistenceManager pm) { - createObjects(pm); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Object[] objs = new Object[3]; - objs[0] = p1; - objs[1] = p3; - objs[2] = rect; - pm.retrieveAll(objs); - pm.makeTransientAll(objs); - tx.commit(); - tx = null; - checkP1(); - checkP3(); - checkRectP1(); - checkRectId(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private void runTestRetrieveAllWithCollectionDFGfalse(PersistenceManager pm) { + createObjects(pm); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Collection coll = new ArrayList(); + coll.add(p1); + coll.add(p3); + coll.add(rect); + pm.retrieveAll(coll, false); + pm.makeTransientAll(coll); + tx.commit(); + tx = null; + checkP1(); + checkP3(); + checkRectP1(); + checkRectId(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** */ - private void runTestRetrieveAllWithArrayDFGtrue(PersistenceManager pm) { - createObjects(pm); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Object[] objs = new Object[3]; - objs[0] = p1; - objs[1] = p3; - objs[2] = rect; - pm.retrieveAll(true, objs); - pm.makeTransientAll(objs); - tx.commit(); - tx = null; - checkP1(); - checkP3(); - // checkRectP1(); p1 is not in the default fetch group by default - checkRectId(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private void runTestRetrieveAllWithArray(PersistenceManager pm) { + createObjects(pm); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Object[] objs = new Object[3]; + objs[0] = p1; + objs[1] = p3; + objs[2] = rect; + pm.retrieveAll(objs); + pm.makeTransientAll(objs); + tx.commit(); + tx = null; + checkP1(); + checkP3(); + checkRectP1(); + checkRectId(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** */ - private void runTestRetrieveAllWithArrayDFGfalse(PersistenceManager pm) { - createObjects(pm); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Object[] objs = new Object[3]; - objs[0] = p1; - objs[1] = p3; - objs[2] = rect; - pm.retrieveAll(false, objs); - pm.makeTransientAll(objs); - tx.commit(); - tx = null; - checkP1(); - checkP3(); - checkRectP1(); - checkRectId(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private void runTestRetrieveAllWithArrayDFGtrue(PersistenceManager pm) { + createObjects(pm); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Object[] objs = new Object[3]; + objs[0] = p1; + objs[1] = p3; + objs[2] = rect; + pm.retrieveAll(true, objs); + pm.makeTransientAll(objs); + tx.commit(); + tx = null; + checkP1(); + checkP3(); + // checkRectP1(); p1 is not in the default fetch group by default + checkRectId(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** */ - private void createObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.setRetainValues(false); - tx.begin(); - p1 = new PCPoint(1, 1); - p1print = p1.toString(); - p2 = new PCPoint(2, 2); - p3 = new PCPoint2(3, 3); - rect = new PCRect(100, p1, p2); - pm.makePersistent(p1); - pm.makePersistent(p2); - pm.makePersistent(p3); - pm.makePersistent(rect); - if (debug) { - logger.debug("p1: " + p1.name()); - logger.debug("p2: " + p2.name()); - logger.debug("p3: " + p3.name()); - logger.debug( - "rect id: " - + rect.getId() - + ", upperLeft: " - + rect.getUpperLeft().name() - + ", lowerRight: " - + rect.getLowerRight().name()); - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private void runTestRetrieveAllWithArrayDFGfalse(PersistenceManager pm) { + createObjects(pm); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Object[] objs = new Object[3]; + objs[0] = p1; + objs[1] = p3; + objs[2] = rect; + pm.retrieveAll(false, objs); + pm.makeTransientAll(objs); + tx.commit(); + tx = null; + checkP1(); + checkP3(); + checkRectP1(); + checkRectId(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** */ - private void checkP1() { - if (((p1.getX() != 1) || (!one.equals(p1.getY())))) { - fail( - ASSERTION_FAILED, - "Error in p1 fields. Expected x:1, y:1; got x:" + p1.getX() + ", y:" + p1.getY()); + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.setRetainValues(false); + tx.begin(); + p1 = new PCPoint(1,1); + p1print = p1.toString(); + p2 = new PCPoint(2,2); + p3 = new PCPoint2(3,3); + rect = new PCRect(100, p1, p2); + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(rect); + if (debug) { + logger.debug("p1: " + p1.name()); + logger.debug("p2: " + p2.name()); + logger.debug("p3: " + p3.name()); + logger.debug("rect id: " + rect.getId() + + ", upperLeft: " + rect.getUpperLeft().name() + + ", lowerRight: " + rect.getLowerRight().name()); + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** */ - private void checkP3() { - if ((p3.getX() != 3) || (!three.equals(p3.getY()))) { - fail( - ASSERTION_FAILED, - "Error in p3 fields. Expected x:3, y:3; got x:" + p3.getX() + ", y:" + p3.getY()); + /** */ + private void checkP1() { + if (((p1.getX() != 1) || (!one.equals(p1.getY())))) { + fail(ASSERTION_FAILED, + "Error in p1 fields. Expected x:1, y:1; got x:" + p1.getX() + + ", y:" + p1.getY()); + } } - if (!p3.wasPostLoadCalled()) { - fail(ASSERTION_FAILED, "missing call of jdoPostLoad for p3"); + /** */ + private void checkP3() { + if ((p3.getX() != 3) || (!three.equals(p3.getY()))) { + fail(ASSERTION_FAILED, + "Error in p3 fields. Expected x:3, y:3; got x:" + p3.getX() + + ", y:" + p3.getY()); + } + + if (!p3.wasPostLoadCalled()) { + fail(ASSERTION_FAILED, + "missing call of jdoPostLoad for p3"); + } } - } - /** */ - private void checkRectId() { - if (rect.getId() == 0) { - fail(ASSERTION_FAILED, "Error in rect field id. Expected id!= 0; got id:0"); + /** */ + private void checkRectId() { + if (rect.getId() == 0) { + fail(ASSERTION_FAILED, + "Error in rect field id. Expected id!= 0; got id:0"); + } } - } - /** */ - private void checkRectP1() { - if (rect.getUpperLeft() != p1) { - fail( - ASSERTION_FAILED, - "Error in rect field upperLeft. Expected:" + p1print + ", got:" + rect.getUpperLeft()); + /** */ + private void checkRectP1() { + if (rect.getUpperLeft()!= p1) { + fail(ASSERTION_FAILED, + "Error in rect field upperLeft. Expected:" + p1print + + ", got:" + rect.getUpperLeft()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/AfterCloseAllMethodsThrowException.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/AfterCloseAllMethodsThrowException.java index 194441985..fb81dec0e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/AfterCloseAllMethodsThrowException.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/AfterCloseAllMethodsThrowException.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -21,67 +21,82 @@ import javax.jdo.PersistenceManager; import javax.jdo.PersistenceManagerFactory; import javax.jdo.Transaction; + import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: AfterCloseAllMethodsThrowException
    - * Keywords: exception
    - * Assertion IDs: A12.5-6
    - * Assertion Description: After the PersistenceManager.close method completes, all methods - * on PersistenceManager except isClosed throw a JDOFatalUserException. - */ -public class AfterCloseAllMethodsThrowException extends PersistenceManagerTest { + *Title: AfterCloseAllMethodsThrowException + *
    + *Keywords: exception + *
    + *Assertion IDs: A12.5-6 + *
    + *Assertion Description: +After the PersistenceManager.close method completes, +all methods on PersistenceManager except isClosed throw a +JDOFatalUserException. - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5-6 (AfterCloseAllMethodsThrowException) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(AfterCloseAllMethodsThrowException.class); - } + */ - private PersistenceManagerFactory pmf; - private PersistenceManager pm; - private Transaction tx; +public class AfterCloseAllMethodsThrowException extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5-6 (AfterCloseAllMethodsThrowException) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(AfterCloseAllMethodsThrowException.class); + } + + private PersistenceManagerFactory pmf; + private PersistenceManager pm; + private Transaction tx; - /** */ - public void testAfterCloseAllMethodsThrowException() { - pm = getPM(); - pm.close(); - runTestEvict(); - runTestRefresh(); - runTestIsClosed(); - pm = null; - } + /** */ + public void testAfterCloseAllMethodsThrowException() { + pm = getPM(); + pm.close(); + runTestEvict(); + runTestRefresh(); + runTestIsClosed(); + pm = null; + } - /** */ - private void runTestEvict() { - try { - pm.evictAll(); - fail(ASSERTION_FAILED, "pm.evictAll does not throw exception if pm is closed."); - } catch (JDOFatalUserException ex) { - // caught expected exception + /** */ + private void runTestEvict() { + try { + pm.evictAll(); + fail(ASSERTION_FAILED, + "pm.evictAll does not throw exception if pm is closed."); + } + catch (JDOFatalUserException ex) { + // caught expected exception + } } - } - /** */ - private void runTestRefresh() { - try { - pm.refreshAll(); - fail(ASSERTION_FAILED, "pm.refreshAll does not throw exception if pm is closed."); - } catch (JDOFatalUserException ex) { - // caught expected exception - } - } + /** */ + private void runTestRefresh() { + try { + pm.refreshAll(); + fail(ASSERTION_FAILED, + "pm.refreshAll does not throw exception if pm is closed."); + } + catch (JDOFatalUserException ex) { + // caught expected exception + } + } - /** */ - private void runTestIsClosed() { - if (!pm.isClosed()) fail(ASSERTION_FAILED, "pm.isClosed returns false for closed pm."); - } + /** */ + private void runTestIsClosed() { + if (!pm.isClosed()) + fail(ASSERTION_FAILED, + "pm.isClosed returns false for closed pm."); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/AutoCloseable.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/AutoCloseable.java index b1fe45d34..d821e55c5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/AutoCloseable.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/AutoCloseable.java @@ -5,85 +5,94 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.close; import javax.jdo.PersistenceManager; + import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: AutoCloseable
    - * Keywords: exception
    - * Assertion IDs: A12.6 ?.
    - * Assertion Description: In a non-managed environment, if the PM is created with - * try-with-resources then it is automatically closed at the end of that block. + *Title: AutoCloseable + *
    + *Keywords: exception + *
    + *Assertion IDs: A12.6 ?. + *
    + *Assertion Description: + * In a non-managed environment, if the PM is created with try-with-resources + * then it is automatically closed at the end of that block. */ -public class AutoCloseable extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A12.6-? (AutoCloseable) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(AutoCloseable.class); - } +public class AutoCloseable extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.6-? (AutoCloseable) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(AutoCloseable.class); + } - /** - * The method creates a pm with try-with-resources and checks that it is closed after the block. - */ - public void testTryWithResource() { + /** + * The method creates a pm with try-with-resources and checks that it is closed after the block. + */ + public void testTryWithResource() { - try (PersistenceManager pm1 = getPM()) { - pm = pm1; - if (pm.isClosed()) { - fail( - ASSERTION_FAILED, - "PersistenceManager is expected to be open inside try-with-resource block."); - } - } + try (PersistenceManager pm1 = getPM()) { + pm = pm1; + if (pm.isClosed()) { + fail(ASSERTION_FAILED, + "PersistenceManager is expected to be open inside try-with-resource block."); + } + } - if (!pm.isClosed()) { - fail(ASSERTION_FAILED, "PersistenceManager should be closed after try-with-resource block."); + if (!pm.isClosed()) { + fail(ASSERTION_FAILED, + "PersistenceManager should be closed after try-with-resource block."); + } } - } - /** - * The method creates a pm with try-with-resources and checks that it is closed after the block, - * if the block is ended with an exception. - */ - public void testTryWithResourceThrowingException() { + /** + * The method creates a pm with try-with-resources and checks that it is closed after the block, + * if the block is ended with an exception. + */ + public void testTryWithResourceThrowingException() { - try (PersistenceManager pm1 = getPM()) { - pm = pm1; - if (pm.isClosed()) { - fail( - ASSERTION_FAILED, - "PersistenceManager is expected to be open inside try-with-resource block."); - } - throw new DummyException(); - } catch (DummyException ex) { - // exception is expected - } + try (PersistenceManager pm1 = getPM()) { + pm = pm1; + if (pm.isClosed()) { + fail(ASSERTION_FAILED, + "PersistenceManager is expected to be open inside try-with-resource block."); + } + throw new DummyException(); + } catch (DummyException ex) { + // exception is expected + } - if (!pm.isClosed()) { - fail(ASSERTION_FAILED, "PersistenceManager should be closed after try-with-resource block."); + if (!pm.isClosed()) { + fail(ASSERTION_FAILED, + "PersistenceManager should be closed after try-with-resource block."); + } } - } - /** DummyException used in method testTryWithResourceThrowingException. */ - private static final class DummyException extends Exception {} + /** + * DummyException used in method testTryWithResourceThrowingException. + */ + private static final class DummyException extends Exception {} } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/CloseWithActiveTxRollsBack.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/CloseWithActiveTxRollsBack.java index 2b3ae18ba..cbc226e3b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/CloseWithActiveTxRollsBack.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/CloseWithActiveTxRollsBack.java @@ -5,83 +5,91 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.close; import javax.jdo.JDOObjectNotFoundException; +import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Close Throws Exception
    - * Keywords: exception
    - * Assertion IDs: A12.6-2.
    - * Assertion Description: In a non-managed environment, if the current transaction is - * active, close will roll back the transaction. + *Title: Close Throws Exception + *
    + *Keywords: exception + *
    + *Assertion IDs: A12.6-2. + *
    + *Assertion Description: +In a non-managed environment, if the current transaction is active, close will roll back the transaction. */ -public class CloseWithActiveTxRollsBack extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.6-2 (CloseWithActiveTxRollsBack) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CloseWithActiveTxRollsBack.class); - } +public class CloseWithActiveTxRollsBack extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.6-2 (CloseWithActiveTxRollsBack) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CloseWithActiveTxRollsBack.class); + } - /** */ - public void test() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); + /** */ + public void test() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); - Object id = null; - try { - PCPoint pc = new PCPoint(101, 200); - pm.makePersistent(pc); - id = pm.getObjectId(pc); + Object id = null; + try { + PCPoint pc = new PCPoint(101, 200); + pm.makePersistent(pc); + id = pm.getObjectId(pc); - // This should rollback the transaction - pm.close(); + // This should rollback the transaction + pm.close(); - assertFalse(tx.isActive()); - assertTrue(pm.isClosed()); - } finally { - pm = null; - PersistenceManager pm2 = getPM(); - pm2.currentTransaction().begin(); - try { - try { - pm2.getObjectById(id); - fail( - "Object was persisted despite closing the PM. Active transaction should have rolled back"); - } catch (JDOObjectNotFoundException onfe) { - // Expected, since rolled back - } - } finally { - if (pm2.currentTransaction().isActive()) { - pm2.currentTransaction().rollback(); + assertFalse(tx.isActive()); + assertTrue(pm.isClosed()); } - pm2.close(); - pm = null; - } + finally { + pm = null; + PersistenceManager pm2 = getPM(); + pm2.currentTransaction().begin(); + try { + try { + pm2.getObjectById(id); + fail("Object was persisted despite closing the PM. Active transaction should have rolled back"); + } + catch (JDOObjectNotFoundException onfe) { + // Expected, since rolled back + } + } + finally { + if (pm2.currentTransaction().isActive()) { + pm2.currentTransaction().rollback(); + } + pm2.close(); + pm = null; + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/IsClosedIsFalseUponConstruction.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/IsClosedIsFalseUponConstruction.java index 42d89f15e..9eb3550f5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/IsClosedIsFalseUponConstruction.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/IsClosedIsFalseUponConstruction.java @@ -5,49 +5,56 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.close; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Is Closed returns false Upon Construction
    - * Keywords:
    - * Assertion IDs: A12.5-3
    - * Assertion Description: The PersistenceManager.isClosed method returns false upon - * construction of the PersistenceManager instance. - */ -public class IsClosedIsFalseUponConstruction extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5-3 (IsClosedIsFalseUponConstruction) failed: "; + *Title: Is Closed returns false Upon Construction + *
    + *Keywords: + *
    + *Assertion IDs: A12.5-3 + *
    + *Assertion Description: +The PersistenceManager.isClosed method returns false upon construction of +the PersistenceManager instance. +*/ - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsClosedIsFalseUponConstruction.class); - } - - /** */ - public void test() { - pm = getPM(); +public class IsClosedIsFalseUponConstruction extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5-3 (IsClosedIsFalseUponConstruction) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsClosedIsFalseUponConstruction.class); + } - if (pm.isClosed()) { - fail(ASSERTION_FAILED, "pm is closed after creation"); + /** */ + public void test() { + pm = getPM(); + + if (pm.isClosed()) { + fail(ASSERTION_FAILED, + "pm is closed after creation"); + } } - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/IsClosedIsFalseUponRetrievalFromPool.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/IsClosedIsFalseUponRetrievalFromPool.java index 9d1f61926..1556a9e75 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/IsClosedIsFalseUponRetrievalFromPool.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/IsClosedIsFalseUponRetrievalFromPool.java @@ -5,53 +5,59 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.close; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Is Closed Is False Upon Retrieval From a Pool
    - * Keywords:
    - * Assertion IDs: A12.5-4
    - * Assertion Description: The PersistenceManager.isClosed method returns false upon - * retrieval of a PersistenceManager from a pool. - */ -public class IsClosedIsFalseUponRetrievalFromPool extends PersistenceManagerTest { + *Title: Is Closed Is False Upon Retrieval From a Pool + *
    + *Keywords: + *
    + *Assertion IDs: A12.5-4 + *
    + *Assertion Description: +The PersistenceManager.isClosed method returns false upon retrieval +of a PersistenceManager from a pool. +*/ - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5-4 (IsClosedIsFalseUponRetrievalFromPool) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsClosedIsFalseUponRetrievalFromPool.class); - } +public class IsClosedIsFalseUponRetrievalFromPool extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5-4 (IsClosedIsFalseUponRetrievalFromPool) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsClosedIsFalseUponRetrievalFromPool.class); + } - /** */ - public void testIsClosed() { - String sname = "Jojo"; - String spswd = "mypswd"; + /** */ + public void testIsClosed() { + String sname="Jojo"; + String spswd="mypswd"; - pmf = getPMF(); - pm = pmf.getPersistenceManager(sname, spswd); + pmf = getPMF(); + pm = pmf.getPersistenceManager(sname,spswd); - if (pm.isClosed()) { - fail(ASSERTION_FAILED, "pm is closed after creation"); + if (pm.isClosed()) { + fail(ASSERTION_FAILED, + "pm is closed after creation"); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/IsClosedIsTrueAfterClose.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/IsClosedIsTrueAfterClose.java index f3d4fee79..9478233bd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/IsClosedIsTrueAfterClose.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/close/IsClosedIsTrueAfterClose.java @@ -5,53 +5,59 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.close; import javax.jdo.PersistenceManagerFactory; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Is Closed Is True After Close
    - * Keywords:
    - * Assertion IDs: A12.5-5
    - * Assertion Description: The PersistenceManager.isClosed method returns true only after the - * closemethod completes successfully, meaning the PersistenceManager has been closed. (same as - * A35-01). - */ -public class IsClosedIsTrueAfterClose extends PersistenceManagerTest { + *Title: Is Closed Is True After Close + *
    + *Keywords: + *
    + *Assertion IDs: A12.5-5 + *
    + *Assertion Description: +The PersistenceManager.isClosed method returns true only after the +closemethod completes successfully, meaning the PersistenceManager has been closed. (same as A35-01). +*/ - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5-5 (IsClosedIsTrueAfterClose) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsClosedIsTrueAfterClose.class); - } - - /** */ - public void test() { - PersistenceManagerFactory pmf = getPMF(); - pm = pmf.getPersistenceManager(); - pm.close(); +public class IsClosedIsTrueAfterClose extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5-5 (IsClosedIsTrueAfterClose) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsClosedIsTrueAfterClose.class); + } - if (!pm.isClosed()) { - fail(ASSERTION_FAILED, "pm.isClosed returns false after pm.close"); + /** */ + public void test() { + PersistenceManagerFactory pmf = getPMF(); + pm = pmf.getPersistenceManager(); + pm.close(); + + if (!pm.isClosed()) { + fail(ASSERTION_FAILED, + "pm.isClosed returns false after pm.close"); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/CopyOnAttachFalse.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/CopyOnAttachFalse.java index 0f6c933a2..641a24aff 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/CopyOnAttachFalse.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/CopyOnAttachFalse.java @@ -5,80 +5,93 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.detach; + + + import javax.jdo.JDOUserException; import org.apache.jdo.tck.pc.shoppingcart.Cart; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test DetachAttach
    - * Keywords: makePersistent detach
    - * Assertion IDs:
    - * Assertion Description: A12.6.8-29 [If the CopyOnAttach property is false, then the - * instance itself is transitioned to persistent-clean for datastore transactions or - * persistent-nontransactional for optimistic transactions. If there already is an instance in the - * cache with the same identity, JDOUserException is thrown.] + * Title: Test DetachAttach + *
    + * Keywords: makePersistent detach + *
    + * Assertion IDs: + *
    + * Assertion Description: + * A12.6.8-29 [If the CopyOnAttach property is false, then the instance itself +is transitioned to persistent-clean for datastore transactions or persistent-nontransactional for optimistic +transactions. If there already is an instance in the cache with the same identity, JDOUserException +is thrown.] */ public class CopyOnAttachFalse extends DetachTest { + + private static final String ASSERTION_FAILED = + "Assertion A12.6.8 (CopyOnAttachFalse) failed: "; - private static final String ASSERTION_FAILED = "Assertion A12.6.8 (CopyOnAttachFalse) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CopyOnAttachFalse.class); - } + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CopyOnAttachFalse.class); + } - /** */ - public void testAttachClean() { - Cart detachedCart = createDetachedInstance(ASSERTION_FAILED); - pm.setCopyOnAttach(false); - pm.currentTransaction().begin(); - Cart attachedCart = (Cart) pm.makePersistent(detachedCart); - assertTrue("Expected attached object to == detached object.", attachedCart == detachedCart); - pm.currentTransaction().commit(); - } + /** + */ + public void testAttachClean() { + Cart detachedCart = createDetachedInstance(ASSERTION_FAILED); + pm.setCopyOnAttach(false); + pm.currentTransaction().begin(); + Cart attachedCart = (Cart)pm.makePersistent(detachedCart); + assertTrue("Expected attached object to == detached object.", + attachedCart == detachedCart); + pm.currentTransaction().commit(); + } - /** */ - public void testAttachDirty() { - Cart detachedCart = createDetachedInstance(ASSERTION_FAILED); - pm.setCopyOnAttach(false); - pm.currentTransaction().begin(); - cartEntry1.setQuantity(500); - goldenCartEntry.setQuantity(500); - Cart attachedCart = (Cart) pm.makePersistent(detachedCart); - assertTrue("Expected attached object to == detached object.", attachedCart == detachedCart); - pm.currentTransaction().commit(); - } + /** */ + public void testAttachDirty() { + Cart detachedCart = createDetachedInstance(ASSERTION_FAILED); + pm.setCopyOnAttach(false); + pm.currentTransaction().begin(); + cartEntry1.setQuantity(500); + goldenCartEntry.setQuantity(500); + Cart attachedCart = (Cart)pm.makePersistent(detachedCart); + assertTrue("Expected attached object to == detached object.", + attachedCart == detachedCart); + pm.currentTransaction().commit(); + } - /** */ - public void testNegativeAttachClean() { - Cart detachedCart = createDetachedInstance(ASSERTION_FAILED); - pm.setCopyOnAttach(false); - pm.currentTransaction().begin(); - // Obtain new instance of cart1 - pm.getObjectById(cart1oid, false); - try { - Cart attachedCart = (Cart) pm.makePersistent(detachedCart); - fail( - "Expected JDOUserException. Object with same identity as " - + "attached object is already in the cache."); - } catch (JDOUserException jdoe) { - // expected exception + /** + */ + public void testNegativeAttachClean() { + Cart detachedCart = createDetachedInstance(ASSERTION_FAILED); + pm.setCopyOnAttach(false); + pm.currentTransaction().begin(); + // Obtain new instance of cart1 + pm.getObjectById(cart1oid, false); + try { + Cart attachedCart = (Cart)pm.makePersistent(detachedCart); + fail("Expected JDOUserException. Object with same identity as " + + "attached object is already in the cache."); + } catch (JDOUserException jdoe) { + // expected exception + } + pm.currentTransaction().commit(); } - pm.currentTransaction().commit(); - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachAccessUnloadedField.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachAccessUnloadedField.java index 9720ef702..9bafbf26e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachAccessUnloadedField.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachAccessUnloadedField.java @@ -5,126 +5,138 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.detach; + import javax.jdo.FetchPlan; import javax.jdo.JDODetachedFieldAccessException; import org.apache.jdo.tck.pc.shoppingcart.CartEntry; import org.apache.jdo.tck.pc.shoppingcart.Product; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test DetachCopy
    - * Keywords: detachCopy detach
    - * Assertion IDs: A12.6.8-21
    - * Assertion Description: While detached, any field access to a field that was not loaded - * throws JDODetachedFieldAccessException. + * Title: Test DetachCopy + *
    + * Keywords: detachCopy detach + *
    + * Assertion IDs: A12.6.8-21 + *
    + * Assertion Description: + * While detached, any field access to a field that was not loaded throws JDODetachedFieldAccessException. */ public class DetachAccessUnloadedField extends DetachTest { + + private static final String ASSERTION_FAILED = + "Assertion A12.6.8-21 (DetachCopy) failed: "; - private static final String ASSERTION_FAILED = "Assertion A12.6.8-21 (DetachCopy) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DetachAccessUnloadedField.class); - } + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DetachAccessUnloadedField.class); + } - /** - * Positive test for field access of detached instance Field is in fetch group, loaded at - * detachment with DETACH_LOAD_FIELDS true - */ - public void testDetachCopyFieldAccessOk() { - // datastore transaction, retainValues=false - getPM().currentTransaction().begin(); - // sets fetch group cart, entries, product - setCartFetchGroups(); - // DETACH_LOAD_FIELDS true by default - CartEntry cartEntryDetached = (CartEntry) pm.detachCopy(cartEntry1); - try { - Product prod = cartEntryDetached.getProduct(); - } catch (JDODetachedFieldAccessException jdoex) { - fail("Unexpected exception caught: " + jdoex.getMessage()); + /** + * Positive test for field access of detached instance + * Field is in fetch group, + * loaded at detachment with DETACH_LOAD_FIELDS true + */ + public void testDetachCopyFieldAccessOk() { + // datastore transaction, retainValues=false + getPM().currentTransaction().begin(); + // sets fetch group cart, entries, product + setCartFetchGroups(); + // DETACH_LOAD_FIELDS true by default + CartEntry cartEntryDetached = (CartEntry)pm.detachCopy(cartEntry1); + try { + Product prod = cartEntryDetached.getProduct(); + } catch (JDODetachedFieldAccessException jdoex) { + fail("Unexpected exception caught: " + jdoex.getMessage()); + } + pm.currentTransaction().commit(); } - pm.currentTransaction().commit(); - } - /** - * Positive test for access of loaded field of detached instance All fields are in the fetch plan - * detachment options = 0, fields loaded by access of an instance - */ - public void testDetachCopyAccessLoadedField() { - // datastore transaction, retainValues=false - getPM().currentTransaction().begin(); - // sets fetch group cart, entries, product - setCartFetchGroups(); - // loads Product field - int quantity = cartEntry1.getQuantity(); + /** + * Positive test for access of loaded field of detached instance + * All fields are in the fetch plan + * detachment options = 0, fields loaded by access of an instance + */ + public void testDetachCopyAccessLoadedField() { + // datastore transaction, retainValues=false + getPM().currentTransaction().begin(); + // sets fetch group cart, entries, product + setCartFetchGroups(); + // loads Product field + int quantity = cartEntry1.getQuantity(); - pm.getFetchPlan().setDetachmentOptions(0); - CartEntry cartEntryDetached = (CartEntry) pm.detachCopy(cartEntry1); - try { - Product prodDetached = cartEntryDetached.getProduct(); - } catch (JDODetachedFieldAccessException jdoex) { - fail("Unexpected exception caught: " + jdoex.getMessage()); - } finally { - pm.currentTransaction().commit(); + pm.getFetchPlan().setDetachmentOptions(0); + CartEntry cartEntryDetached = (CartEntry)pm.detachCopy(cartEntry1); + try { + Product prodDetached = cartEntryDetached.getProduct(); + } catch (JDODetachedFieldAccessException jdoex) { + fail("Unexpected exception caught: " + jdoex.getMessage()); + } finally { + pm.currentTransaction().commit(); + } } - } - /** - * Negative test for access of unloaded field of detached instance with DETACH_UNLOAD_FIELDS set - */ - public void testDetachCopyAccessUnloadedField() { - // datastore transaction, retainValues=false - getPM().currentTransaction().begin(); - // sets fetch group cart, entries, product - setCartFetchGroups(); - Product prod = cartEntry1.getProduct(); - pm.getFetchPlan().removeGroup(CARTENTRY_PRODUCT); - pm.getFetchPlan().setDetachmentOptions(FetchPlan.DETACH_UNLOAD_FIELDS); - CartEntry cartEntryDetached = (CartEntry) pm.detachCopy(cartEntry1); - try { - Product prodDetached = cartEntryDetached.getProduct(); - fail("Expected exception on access of unloaded field, " + "but none thrown."); - } catch (JDODetachedFieldAccessException jdoex) { - // expect exception - } finally { - pm.currentTransaction().commit(); + /** + * Negative test for access of unloaded field of detached instance + * with DETACH_UNLOAD_FIELDS set + */ + public void testDetachCopyAccessUnloadedField() { + // datastore transaction, retainValues=false + getPM().currentTransaction().begin(); + // sets fetch group cart, entries, product + setCartFetchGroups(); + Product prod = cartEntry1.getProduct(); + pm.getFetchPlan().removeGroup(CARTENTRY_PRODUCT); + pm.getFetchPlan().setDetachmentOptions(FetchPlan.DETACH_UNLOAD_FIELDS); + CartEntry cartEntryDetached = (CartEntry)pm.detachCopy(cartEntry1); + try { + Product prodDetached = cartEntryDetached.getProduct(); + fail("Expected exception on access of unloaded field, " + + "but none thrown."); + } catch (JDODetachedFieldAccessException jdoex) { + // expect exception + } finally { + pm.currentTransaction().commit(); + } } - } - /** Negative test for access of field of detached instance where field was not loaded */ - public void testDetachCopyAccessFieldNotInFetchPlan() { - // datastore transaction, retainValues=false - getPM().currentTransaction().begin(); - FetchPlan fp = pm.getFetchPlan(); - // Product field not in Fetch Plan - fp.addGroup(CART_ENTRIES); - fp.addGroup(CARTENTRY_CART); + /** + * Negative test for access of field of detached instance + * where field was not loaded + */ + public void testDetachCopyAccessFieldNotInFetchPlan() { + // datastore transaction, retainValues=false + getPM().currentTransaction().begin(); + FetchPlan fp = pm.getFetchPlan(); + // Product field not in Fetch Plan + fp.addGroup(CART_ENTRIES); + fp.addGroup(CARTENTRY_CART); - CartEntry cartEntryDetached = (CartEntry) pm.detachCopy(cartEntry1); - try { - Product prod = cartEntryDetached.getProduct(); - fail( - "Expected exception on access of field not in fetch plan" - + " and not loaded, but none thrown."); - } catch (JDODetachedFieldAccessException jdoex) { - // expect exception - } finally { - pm.currentTransaction().commit(); + CartEntry cartEntryDetached = (CartEntry)pm.detachCopy(cartEntry1); + try { + Product prod = cartEntryDetached.getProduct(); + fail("Expected exception on access of field not in fetch plan" + + " and not loaded, but none thrown."); + } catch (JDODetachedFieldAccessException jdoex) { + // expect exception + } finally { + pm.currentTransaction().commit(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachAllOnCommit.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachAllOnCommit.java index a74354b63..492774cca 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachAllOnCommit.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachAllOnCommit.java @@ -5,52 +5,78 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.detach; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +import java.util.Collection; +import java.util.HashSet; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.shoppingcart.Cart; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test DetachAllOnCommit
    - * Keywords: DetachAllOnCommit detach
    - * Assertion IDs: A12.6.8-3
    - * Assertion Description: With this flag set to true, during beforeCompletion all cached - * instances are prepared for detachment according to the fetch plan in effect at commit. Loading - * fields and unload- ing fields required by the fetch plan is done after calling the user's - * beforeCompletion callback. During afterCompletion, before calling the user's afterCompletion - * callback, all detachable persistent instances in the cache transition to detached; non-detachable - * persistent instances transition to transient; and detachable instances can be serialized as - * detached instances. Transient transactional instances are unaffected by this flag. + * Title: Test DetachAllOnCommit + *
    + * Keywords: DetachAllOnCommit detach + *
    + * Assertion IDs: A12.6.8-3 + *
    + * Assertion Description: +With this flag set to true, during beforeCompletion +all cached instances are prepared +for detachment according to the fetch plan +in effect at commit. Loading fields and unload- +ing fields required by the fetch plan +is done after calling the user's beforeCompletion +callback. During afterCompletion, before calling +the user's afterCompletion callback, all detachable +persistent instances in the cache transition +to detached; non-detachable persistent instances +transition to transient; and detachable instances can be serialized +as detached instances. Transient transactional instances +are unaffected by this flag. */ public class DetachAllOnCommit extends DetachTest { + + private static final String ASSERTION_FAILED = + "Assertion A12.6.8-3 (DetachAllOnCommit) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DetachAllOnCommit.class); + } + + /** */ + public void testDetachAllOnCommit() { + getPM().currentTransaction().begin(); + setCartFetchGroups(); + pm.retrieveAll(cartClosure); + pm.setDetachAllOnCommit(true); + pm.currentTransaction().commit(); + checkCartValues(ASSERTION_FAILED + + "after commit with DetachAllOnCommit," + NL, cart1); + failOnError(); + } - private static final String ASSERTION_FAILED = "Assertion A12.6.8-3 (DetachAllOnCommit) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DetachAllOnCommit.class); - } - - /** */ - public void testDetachAllOnCommit() { - getPM().currentTransaction().begin(); - setCartFetchGroups(); - pm.retrieveAll(cartClosure); - pm.setDetachAllOnCommit(true); - pm.currentTransaction().commit(); - checkCartValues(ASSERTION_FAILED + "after commit with DetachAllOnCommit," + NL, cart1); - failOnError(); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachAttach.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachAttach.java index 0e0a692c5..ff69855dd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachAttach.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachAttach.java @@ -5,47 +5,66 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.detach; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +import java.util.Collection; +import java.util.HashSet; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.shoppingcart.Cart; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test DetachAttach
    - * Keywords: makePersistent detach
    - * Assertion IDs:
    - * Assertion Description: For a detached instance, they locate or create a persistent - * instance with the same JDO identity as the detached instance + * Title: Test DetachAttach + *
    + * Keywords: makePersistent detach + *
    + * Assertion IDs: + *
    + * Assertion Description: +For a detached instance, they locate or create a persistent +instance with the same JDO identity as the detached instance */ public class DetachAttach extends DetachTest { + + private static final String ASSERTION_FAILED = + "Assertion A12.6.8 (DetachAttach) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DetachAttach.class); + } + + /** */ + public void testAttachClean() { + Cart detachedCart = createDetachedInstance(ASSERTION_FAILED); + pm.currentTransaction().begin(); + Cart attachedCart = (Cart)pm.makePersistent(detachedCart); + checkCartValues(ASSERTION_FAILED + + "after attach," + NL, attachedCart, true); + pm.currentTransaction().commit(); + failOnError(); + } - private static final String ASSERTION_FAILED = "Assertion A12.6.8 (DetachAttach) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DetachAttach.class); - } - - /** */ - public void testAttachClean() { - Cart detachedCart = createDetachedInstance(ASSERTION_FAILED); - pm.currentTransaction().begin(); - Cart attachedCart = (Cart) pm.makePersistent(detachedCart); - checkCartValues(ASSERTION_FAILED + "after attach," + NL, attachedCart, true); - pm.currentTransaction().commit(); - failOnError(); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachAttachDirty.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachAttachDirty.java index 86f865d4f..9de765b56 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachAttachDirty.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachAttachDirty.java @@ -5,58 +5,75 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.detach; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +import java.util.Collection; +import java.util.HashSet; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.shoppingcart.Cart; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test DetachAttach
    - * Keywords: makePersistent detach dirty
    - * Assertion IDs: A12.6.8-26
    - * Assertion Description: For a detached instance, they locate or create a persistent - * instance with the same JDO identity as the detached instance, and merge the persistent state of - * the detached instance into the persistent instance. + * Title: Test DetachAttach + *
    + * Keywords: makePersistent detach dirty + *
    + * Assertion IDs: A12.6.8-26 + *
    + * Assertion Description: +For a detached instance, they locate or create a persistent +instance with the same JDO identity as the detached instance, +and merge the persistent +state of the detached instance into the persistent instance. */ public class DetachAttachDirty extends DetachTest { + + private static final String ASSERTION_FAILED = + "Assertion A12.6.8-26 (DetachAttachDirty) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DetachAttach.class); + } - private static final String ASSERTION_FAILED = - "Assertion A12.6.8-26 (DetachAttachDirty) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DetachAttach.class); - } - - /** */ - public void testAttachDirty() { - Cart detachedCart = createDetachedInstance(ASSERTION_FAILED); - pm.currentTransaction().begin(); - cartEntry1.setQuantity(500); - goldenCartEntry.setQuantity(500); - Cart attachedCart = (Cart) pm.makePersistent(detachedCart); - checkCartValues(ASSERTION_FAILED + "after attach," + NL, attachedCart, true); - pm.currentTransaction().commit(); - pm.currentTransaction().begin(); - Cart persistentCart = (Cart) pm.getObjectById(cart1oid); - checkCartValues( - ASSERTION_FAILED + "after attach, commit, begin, getObjectById," + NL, - persistentCart, - true); - pm.currentTransaction().commit(); - failOnError(); - } + /** */ + public void testAttachDirty() { + Cart detachedCart = createDetachedInstance(ASSERTION_FAILED); + pm.currentTransaction().begin(); + cartEntry1.setQuantity(500); + goldenCartEntry.setQuantity(500); + Cart attachedCart = (Cart)pm.makePersistent(detachedCart); + checkCartValues(ASSERTION_FAILED + + "after attach," + NL, attachedCart, true); + pm.currentTransaction().commit(); + pm.currentTransaction().begin(); + Cart persistentCart = (Cart)pm.getObjectById(cart1oid); + checkCartValues(ASSERTION_FAILED + + "after attach, commit, begin, getObjectById," + NL, + persistentCart, true); + pm.currentTransaction().commit(); + failOnError(); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachCopy.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachCopy.java index 97254afff..fb54f93cc 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachCopy.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachCopy.java @@ -5,81 +5,101 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.detach; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + import java.util.Collection; import java.util.HashSet; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.shoppingcart.Cart; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test DetachCopy
    - * Keywords: detachCopy detach
    - * Assertion IDs: A12.6.8-13, A12.6.8-18, A12.6.8-19, A12.6.8-20
    - * Assertion Description: For each instance in the parameter Collection, a corresponding - * detached copy is returned. Each field in the persistent instance is handled based on its type and - * whether the field is contained in the fetch group for the persistence-capable class. If there are - * duplicates in the parameter Collection, the corresponding detached copy is used for each such - * duplicate. + * Title: Test DetachCopy + *
    + * Keywords: detachCopy detach + *
    + * Assertion IDs: A12.6.8-13, A12.6.8-18, A12.6.8-19, A12.6.8-20 + *
    + * Assertion Description: +For each instance in the parameter Collection, a +corresponding detached copy is returned. Each field in the +persistent instance is handled based on its type and whether the +field is contained in the fetch group for the persistence-capable +class. If there are duplicates in the parameter Collection, +the corresponding detached copy is used for each such duplicate. */ public class DetachCopy extends DetachTest { + + private static final String ASSERTION_FAILED = + "Assertion A12.6.8-13, A12.6.8-18, A12.6.8-19, A12.6.8-20" + + " (DetachCopy) failed: "; - private static final String ASSERTION_FAILED = - "Assertion A12.6.8-13, A12.6.8-18, A12.6.8-19, A12.6.8-20" + " (DetachCopy) failed: "; + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DetachCopy.class); + } - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DetachCopy.class); - } + /** */ + public void testDetachCopy() { + getPM().currentTransaction().begin(); + setCartFetchGroups(); + //pm.retrieveAll(cartClosure); + Cart cartDetached = (Cart)pm.detachCopy(cart1); + checkCartValues(ASSERTION_FAILED + + "after detachCopy," + NL, cartDetached); + pm.currentTransaction().commit(); + failOnError(); + } - /** */ - public void testDetachCopy() { - getPM().currentTransaction().begin(); - setCartFetchGroups(); - // pm.retrieveAll(cartClosure); - Cart cartDetached = (Cart) pm.detachCopy(cart1); - checkCartValues(ASSERTION_FAILED + "after detachCopy," + NL, cartDetached); - pm.currentTransaction().commit(); - failOnError(); - } + /** */ + public void testDetachCopyAllCollection() { + getPM().currentTransaction().begin(); + setCartFetchGroups(); + //pm.retrieveAll(cartClosure); + Collection instances = new HashSet(); + instances.add(cart1); + Collection detached = pm.detachCopyAll(instances); + Cart cartDetached = (Cart)detached.iterator().next(); + checkCartValues(ASSERTION_FAILED + + "after detachCopyAll(Collection)," + NL, cartDetached); + pm.currentTransaction().commit(); + failOnError(); + } - /** */ - public void testDetachCopyAllCollection() { - getPM().currentTransaction().begin(); - setCartFetchGroups(); - // pm.retrieveAll(cartClosure); - Collection instances = new HashSet(); - instances.add(cart1); - Collection detached = pm.detachCopyAll(instances); - Cart cartDetached = (Cart) detached.iterator().next(); - checkCartValues(ASSERTION_FAILED + "after detachCopyAll(Collection)," + NL, cartDetached); - pm.currentTransaction().commit(); - failOnError(); - } + /** */ + public void testDetachCopyAllArray() { + getPM().currentTransaction().begin(); + setCartFetchGroups(); + //pm.retrieveAll(cartClosure); + Object[] instances = new Object[]{cart1}; + Object[] detached = pm.detachCopyAll(instances); + Cart cartDetached = (Cart)detached[0]; + checkCartValues(ASSERTION_FAILED + + "after detachCopyAll(Object[])," + NL, cartDetached); + pm.currentTransaction().commit(); + failOnError(); + } - /** */ - public void testDetachCopyAllArray() { - getPM().currentTransaction().begin(); - setCartFetchGroups(); - // pm.retrieveAll(cartClosure); - Object[] instances = new Object[] {cart1}; - Object[] detached = pm.detachCopyAll(instances); - Cart cartDetached = (Cart) detached[0]; - checkCartValues(ASSERTION_FAILED + "after detachCopyAll(Object[])," + NL, cartDetached); - pm.currentTransaction().commit(); - failOnError(); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachSerialize.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachSerialize.java index a457ff0cf..8b5d24a85 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachSerialize.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachSerialize.java @@ -5,13 +5,13 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.detach; @@ -20,76 +20,93 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.shoppingcart.Cart; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test DetachSerialize
    - * Keywords: serialize detach
    - * Assertion IDs: A12.6.8-4, A12.6.8-5
    - * Assertion Description: The JDO 1.0 specification requires that serialized instances be - * made ready for serialization by instantiating all serializable persistent fields before calling - * writeObject. For binary- compatible implementations, this is done by the enhancer adding a call - * to the StateManager prior to invoking the user's writeObject method. The behavior is the same in - * JDO 2.0, with the additional requirement that restored detachable serialized instances are - * treated as detached instances. + * Title: Test DetachSerialize + *
    + * Keywords: serialize detach + *
    + * Assertion IDs: A12.6.8-4, A12.6.8-5 + *
    + * Assertion Description: +The JDO 1.0 specification requires that serialized instances +be made ready for serialization +by instantiating all serializable persistent fields +before calling writeObject. For binary- +compatible implementations, this is done by the enhancer +adding a call to the StateManager prior to invoking the user's +writeObject method. +The behavior is the same in +JDO 2.0, with the additional requirement that restored +detachable serialized instances are +treated as detached instances. */ public class DetachSerialize extends DetachTest { + + private static final String ASSERTION_FAILED = + "Assertion A12.6.8-4, A12.6.8-5 (DetachSerialize) failed: "; - private static final String ASSERTION_FAILED = - "Assertion A12.6.8-4, A12.6.8-5 (DetachSerialize) failed: "; + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DetachSerialize.class); + } - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DetachSerialize.class); - } + /** */ + public void testDetachSerialize() { + getPM().currentTransaction().begin(); + setCartFetchGroups(); + //pm.retrieveAll(cartClosure); + Cart cartDetached = (Cart)detachClosure(cart1); + checkCartValues(ASSERTION_FAILED + "after deserializing cart," + NL, + cartDetached); + pm.currentTransaction().commit(); + failOnError(); + } - /** */ - public void testDetachSerialize() { - getPM().currentTransaction().begin(); - setCartFetchGroups(); - // pm.retrieveAll(cartClosure); - Cart cartDetached = (Cart) detachClosure(cart1); - checkCartValues(ASSERTION_FAILED + "after deserializing cart," + NL, cartDetached); - pm.currentTransaction().commit(); - failOnError(); - } + /** + * Detach the parameter instance. + * @param pc pc instance + * @return detached instance + */ + protected Object detachClosure(Object pc) { + byte[] cartStream = serialize(pc); + return deserialize(cartStream); + } + /** */ - /** - * Detach the parameter instance. - * - * @param pc pc instance - * @return detached instance - */ - protected Object detachClosure(Object pc) { - byte[] cartStream = serialize(pc); - return deserialize(cartStream); - } - /** */ - private byte[] serialize(Object root) { - try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(baos); - oos.writeObject(root); - return baos.toByteArray(); - } catch (Exception ex) { - fail(ASSERTION_FAILED + "serializing cart:" + ex.toString()); - return null; // will not be reached + private byte[] serialize(Object root) { + try { + ByteArrayOutputStream baos = + new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(root); + return baos.toByteArray(); + } catch (Exception ex) { + fail(ASSERTION_FAILED + "serializing cart:" + ex.toString()); + return null; // will not be reached + } } - } - private Object deserialize(byte[] stream) { - try { - ByteArrayInputStream bais = new ByteArrayInputStream(stream); - ObjectInputStream ois = new ObjectInputStream(bais); - return ois.readObject(); - } catch (Exception ex) { - fail(ASSERTION_FAILED + "deserializing cart:" + ex.toString()); - return null; // will not be reached + private Object deserialize(byte[] stream) { + try { + ByteArrayInputStream bais = + new ByteArrayInputStream(stream); + ObjectInputStream ois = new ObjectInputStream(bais); + return ois.readObject(); + } catch (Exception ex) { + fail(ASSERTION_FAILED + "deserializing cart:" + ex.toString()); + return null; // will not be reached + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachTest.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachTest.java index 22ea3a2c5..35030f64b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachTest.java @@ -5,181 +5,208 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.detach; import java.util.Iterator; + import javax.jdo.FetchPlan; import javax.jdo.JDOHelper; + import org.apache.jdo.tck.JDO_Test; -import org.apache.jdo.tck.pc.shoppingcart.Cart; import org.apache.jdo.tck.pc.shoppingcart.CartEntry; +import org.apache.jdo.tck.pc.shoppingcart.Cart; import org.apache.jdo.tck.pc.shoppingcart.Product; import org.apache.jdo.tck.pc.shoppingcart.Undetachable; -/** */ +import javax.jdo.PersistenceManager; + +/** + * + */ public abstract class DetachTest extends JDO_Test { - protected Cart cart1; - protected CartEntry cartEntry1; - protected Product product1; - - protected Object cart1oid; - - protected Cart goldenCart; - protected CartEntry goldenCartEntry; - - protected Object[] cartClosure; - - protected static final String CART_ENTRIES = "Cart.entries"; - protected static final String CARTENTRY_CART = "CartEntry.cart"; - protected static final String CARTENTRY_PRODUCT = "CartEntry.product"; - protected static final String[] CART_FETCH_GROUPS = - new String[] {FetchPlan.DEFAULT, CART_ENTRIES, CARTENTRY_CART, CARTENTRY_PRODUCT}; - - /** Creates a new instance of DetachTest */ - public DetachTest() {} - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CartEntry.class); - addTearDownClass(Cart.class); - addTearDownClass(Product.class); - addTearDownClass(Undetachable.class); - - Product goldenProduct = new Product("PRODUCT1", "Product 1"); - goldenCart = new Cart("142857"); - goldenCartEntry = goldenCart.newCartEntry(goldenProduct, 100); - - product1 = new Product("PRODUCT1", "Product 1"); - cart1 = new Cart("142857"); - cartEntry1 = new CartEntry(cart1, goldenCartEntry.getId(), product1, 100); - cartClosure = new Object[] {cart1, cartEntry1, product1}; - - getPM().currentTransaction().begin(); - pm.makePersistent(cart1); - cart1oid = pm.getObjectId(cart1); - pm.currentTransaction().commit(); - } - - /** */ - protected void setCartFetchGroups() { - FetchPlan fp = getPM().getFetchPlan(); - fp.setGroups(CART_FETCH_GROUPS); - fp.setMaxFetchDepth(2); - } - - /** - * @param location location - * @param obj object - * @param persistent persistent option - */ - protected void checkState(String location, Object obj, boolean persistent) { - if (persistent) { - if (JDOHelper.isPersistent(obj)) return; - } else if (JDOHelper.isDetached(obj)) return; - appendMessage( - location - + " should be " - + (persistent ? "persistent" : "detached") - + " but is not. The object state is: " - + states[currentState(obj)] - + " " - + getStateOfInstance(obj)); - } - - /** - * @param location location - * @param expected expected value - * @param actual actual value - */ - protected void reportDifference(String location, long expected, long actual) { - appendMessage(location + NL + "expected: " + expected + NL + "actual: " + actual); - } - - /** - * @param location location - * @param expected expected value - * @param actual actual value - */ - protected void reportDifference(String location, Object expected, Object actual) { - appendMessage(location + NL + "expected: " + expected + NL + " actual: " + actual); - } - - /** - * @param location location - * @param cart cart - */ - protected void checkCartValues(String location, Cart cart) { - checkCartValues(location, cart, false); - } - - /** - * @param location location - * @param cart cart - * @param persistent persistent option - */ - protected void checkCartValues(String location, Cart cart, boolean persistent) { - checkState(location + "Cart instance", cart, persistent); - if (!goldenCart.getCustomerId().equals(cart.getCustomerId())) - reportDifference( - location + " differences in cart.customerId", - goldenCart.getCustomerId(), - cart.getCustomerId()); - Iterator goldenCartEntries = goldenCart.getEntries(); - Iterator cartEntries = cart.getEntries(); - while (cartEntries.hasNext()) { - CartEntry goldenCartEntry = (CartEntry) goldenCartEntries.next(); - CartEntry cartEntry = (CartEntry) cartEntries.next(); - checkState(location + "CartEntry instance", cartEntry, persistent); - Cart cartEntryCart = cartEntry.getCart(); - if (cartEntryCart != cart) { - reportDifference(location + " incorrect value for cartEntry.cart", cart, cartEntryCart); - } - if (goldenCartEntry.getId() != cartEntry.getId()) - reportDifference( - location + " differences in cartEntry.id", goldenCartEntry.getId(), cartEntry.getId()); - if (goldenCartEntry.getQuantity() != cartEntry.getQuantity()) - reportDifference( - location + " differences in cartEntry.quantity", - goldenCartEntry.getQuantity(), - cartEntry.getQuantity()); - Product goldenProduct = goldenCartEntry.getProduct(); - Product product = cartEntry.getProduct(); - checkState(location + "Product instance", product, persistent); - if (!goldenProduct.getDescription().equals(product.getDescription())) - reportDifference( - location + " differences in product.description", - goldenProduct.getDescription(), - product.getDescription()); + protected Cart cart1; + protected CartEntry cartEntry1; + protected Product product1; + + protected Object cart1oid; + + protected Cart goldenCart; + protected CartEntry goldenCartEntry; + + protected Object[] cartClosure; + + protected final static String CART_ENTRIES = "Cart.entries"; + protected final static String CARTENTRY_CART = "CartEntry.cart"; + protected final static String CARTENTRY_PRODUCT = "CartEntry.product"; + protected final static String[] CART_FETCH_GROUPS = new String[] + {FetchPlan.DEFAULT, CART_ENTRIES, CARTENTRY_CART, CARTENTRY_PRODUCT}; + + /** Creates a new instance of DetachTest */ + public DetachTest() { + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CartEntry.class); + addTearDownClass(Cart.class); + addTearDownClass(Product.class); + addTearDownClass(Undetachable.class); + + Product goldenProduct = new Product("PRODUCT1", "Product 1"); + goldenCart = new Cart("142857"); + goldenCartEntry = + goldenCart.newCartEntry(goldenProduct, 100); + + product1 = new Product("PRODUCT1", "Product 1"); + cart1 = new Cart("142857"); + cartEntry1 = new CartEntry( + cart1, goldenCartEntry.getId(), product1, 100); + cartClosure = new Object[] + {cart1, cartEntry1, product1}; + + getPM().currentTransaction().begin(); + pm.makePersistent(cart1); + cart1oid = pm.getObjectId(cart1); + pm.currentTransaction().commit(); + } + + /** */ + protected void setCartFetchGroups() { + FetchPlan fp = getPM().getFetchPlan(); + fp.setGroups(CART_FETCH_GROUPS); + fp.setMaxFetchDepth(2); + } + + /** + * + * @param location location + * @param obj object + * @param persistent persistent option + */ + protected void checkState(String location, Object obj, + boolean persistent) { + if(persistent) { + if (JDOHelper.isPersistent(obj)) + return; + } else if (JDOHelper.isDetached(obj)) + return; + appendMessage(location + + " should be " + + (persistent?"persistent":"detached") + + " but is not. The object state is: " + + states[currentState(obj)] + " " + getStateOfInstance(obj)); + } + + /** + * + * @param location location + * @param expected expected value + * @param actual actual value + */ + protected void reportDifference(String location, + long expected, long actual) { + appendMessage(location + NL + + "expected: " + expected + NL + + "actual: " + actual); + } + + /** + * + * @param location location + * @param expected expected value + * @param actual actual value + */ + protected void reportDifference(String location, + Object expected, Object actual) { + appendMessage(location + NL + + "expected: " + expected + NL + + " actual: " + actual); + } + + /** + * + * @param location location + * @param cart cart + */ + protected void checkCartValues(String location, Cart cart) { + checkCartValues(location, cart, false); + } + + /** + * + * @param location location + * @param cart cart + * @param persistent persistent option + */ + protected void checkCartValues(String location, Cart cart, + boolean persistent) { + checkState(location + "Cart instance", cart, persistent); + if (!goldenCart.getCustomerId().equals(cart.getCustomerId())) + reportDifference(location + + " differences in cart.customerId", + goldenCart.getCustomerId(), cart.getCustomerId()); + Iterator goldenCartEntries = goldenCart.getEntries(); + Iterator cartEntries = cart.getEntries(); + while (cartEntries.hasNext()) { + CartEntry goldenCartEntry = (CartEntry)goldenCartEntries.next(); + CartEntry cartEntry = (CartEntry)cartEntries.next(); + checkState(location + "CartEntry instance", cartEntry, + persistent); + Cart cartEntryCart = cartEntry.getCart(); + if (cartEntryCart != cart) { + reportDifference(location + + " incorrect value for cartEntry.cart", + cart, cartEntryCart); + } + if (goldenCartEntry.getId() != cartEntry.getId()) + reportDifference(location + + " differences in cartEntry.id", + goldenCartEntry.getId(), cartEntry.getId()); + if (goldenCartEntry.getQuantity() != cartEntry.getQuantity()) + reportDifference(location + + " differences in cartEntry.quantity", + goldenCartEntry.getQuantity(), cartEntry.getQuantity()); + Product goldenProduct = goldenCartEntry.getProduct(); + Product product = cartEntry.getProduct(); + checkState(location + "Product instance", product, + persistent); + if (!goldenProduct.getDescription() + .equals(product.getDescription())) + reportDifference(location + + " differences in product.description", + goldenProduct.getDescription(), product.getDescription()); + } + } + + /** + * + * @param ASSERTION_FAILED assertion + * @return cart + */ + protected Cart createDetachedInstance(String ASSERTION_FAILED) { + getPM().currentTransaction().begin(); + setCartFetchGroups(); + pm.retrieveAll(cartClosure); + pm.setDetachAllOnCommit(true); + pm.currentTransaction().commit(); + checkCartValues(ASSERTION_FAILED + + "after commit with DetachAllOnCommit,", cart1); + failOnError(); + pm.setDetachAllOnCommit(false); + return cart1; } - } - - /** - * @param ASSERTION_FAILED assertion - * @return cart - */ - protected Cart createDetachedInstance(String ASSERTION_FAILED) { - getPM().currentTransaction().begin(); - setCartFetchGroups(); - pm.retrieveAll(cartClosure); - pm.setDetachAllOnCommit(true); - pm.currentTransaction().commit(); - checkCartValues(ASSERTION_FAILED + "after commit with DetachAllOnCommit,", cart1); - failOnError(); - pm.setDetachAllOnCommit(false); - return cart1; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachUndetachable.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachUndetachable.java index 7122b66c5..d193efca8 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachUndetachable.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/DetachUndetachable.java @@ -5,66 +5,68 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.detach; import javax.jdo.JDOHelper; + import org.apache.jdo.tck.pc.shoppingcart.Undetachable; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test DetachUndetachable
    - * Keywords: detachCopy detach detachable
    - * Assertion IDs: A12.6.8-32
    - * Assertion Description: Instances to be detached that are not of a Detachable class are - * detached as transient instances. + * Title: Test DetachUndetachable + *
    + * Keywords: detachCopy detach detachable + *
    + * Assertion IDs: A12.6.8-32 + *
    + * Assertion Description: +Instances to be detached that are not of a Detachable class are detached as transient instances. */ public class DetachUndetachable extends DetachTest { + + private static final String ASSERTION_FAILED = + "Assertion A12.6.8-32 (DetachUndetachable) failed: "; - private static final String ASSERTION_FAILED = - "Assertion A12.6.8-32 (DetachUndetachable) failed: "; - - protected Undetachable un1; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DetachUndetachable.class); - } + protected Undetachable un1; - /** */ - public void testDetachUndetachable() { - setupUndetachable(); - getPM().currentTransaction().begin(); - Undetachable instance = (Undetachable) pm.detachCopy(un1); - if (JDOHelper.isPersistent((Object) instance)) { - appendMessage( - "testDetachUndetachable: should be transient" - + " but is not. The object state is: " - + states[currentState((Object) instance)] - + " " - + getStateOfInstance((Object) instance)); + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DetachUndetachable.class); } - pm.currentTransaction().commit(); - failOnError(); - } - protected void setupUndetachable() { - un1 = new Undetachable(); + /** */ + public void testDetachUndetachable() { + setupUndetachable(); + getPM().currentTransaction().begin(); + Undetachable instance = (Undetachable)pm.detachCopy(un1); + if (JDOHelper.isPersistent((Object)instance)) { + appendMessage("testDetachUndetachable: should be transient" + + " but is not. The object state is: " + + states[currentState((Object)instance)] + + " " + getStateOfInstance((Object)instance)); + } + pm.currentTransaction().commit(); + failOnError(); + } - getPM().currentTransaction().begin(); - pm.makePersistent(un1); - pm.currentTransaction().commit(); - } + protected void setupUndetachable() { + un1 = new Undetachable(); + + getPM().currentTransaction().begin(); + pm.makePersistent(un1); + pm.currentTransaction().commit(); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/SetDetachAllOnCommit.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/SetDetachAllOnCommit.java index f805c5478..a366865a7 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/SetDetachAllOnCommit.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/detach/SetDetachAllOnCommit.java @@ -5,69 +5,73 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.detach; import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; +import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test SetDetachAllOnCommit
    - * Keywords: DetachAllOnCommit commit detach
    - * Assertion IDs: A12.6.8-1, A12.6.8-2
    - * Assertion Description: We define a new property called DetachAllOnCommit - * PersistenceManager.setDetachAllOnCommit(boolean detachAllOnCommit) sets the DetachAllOnCommit - * property PersistenceManager.getDetachAllOnCommit() The value of the DetachAllOnCommit flag is - * returned. + * Title: Test SetDetachAllOnCommit + *
    + * Keywords: DetachAllOnCommit commit detach + *
    + * Assertion IDs: A12.6.8-1, A12.6.8-2 + *
    + * Assertion Description: + * We define a new property called DetachAllOnCommit + * PersistenceManager.setDetachAllOnCommit(boolean detachAllOnCommit) + * sets the DetachAllOnCommit property + * PersistenceManager.getDetachAllOnCommit() + * The value of the DetachAllOnCommit flag is returned. */ public class SetDetachAllOnCommit extends DetachTest { + + private static final String ASSERTION_FAILED = "Assertion A12.6.8-1 (pm.setDetachAllOnCommit) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetDetachAllOnCommit.class); + } - private static final String ASSERTION_FAILED = - "Assertion A12.6.8-1 (pm.setDetachAllOnCommit) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetDetachAllOnCommit.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTestSetDetachAllOnCommit(pm); - - pm.close(); - pm = null; - } - - /** - * @param pm the PersistenceManager - */ - protected void runTestSetDetachAllOnCommit(PersistenceManager pm) { - pm.setDetachAllOnCommit(false); - if (pm.getDetachAllOnCommit()) { - fail( - ASSERTION_FAILED, - "pm.getDetachAllOnCommit() should return false after setting the flag to false."); + /** */ + public void test() { + pm = getPM(); + + runTestSetDetachAllOnCommit(pm); + + pm.close(); + pm = null; } - pm.setDetachAllOnCommit(true); - if (!pm.getDetachAllOnCommit()) { - fail( - ASSERTION_FAILED, - "pm.getDetachAllOnCommit() should return true after setting the flag to true."); + /** + * @param pm the PersistenceManager + */ + protected void runTestSetDetachAllOnCommit(PersistenceManager pm) { + pm.setDetachAllOnCommit(false); + if (pm.getDetachAllOnCommit()) { + fail(ASSERTION_FAILED, + "pm.getDetachAllOnCommit() should return false after setting the flag to false."); + } + + pm.setDetachAllOnCommit(true); + if (!pm.getDetachAllOnCommit()) { + fail(ASSERTION_FAILED, + "pm.getDetachAllOnCommit() should return true after setting the flag to true."); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/extent/GetExtentWithInstancesMadePersistentViaReachability.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/extent/GetExtentWithInstancesMadePersistentViaReachability.java index b0c2bf7d3..9c2e86b1b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/extent/GetExtentWithInstancesMadePersistentViaReachability.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/extent/GetExtentWithInstancesMadePersistentViaReachability.java @@ -5,111 +5,112 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.extent; -import java.util.Date; import java.util.Iterator; +import java.util.Date; + import javax.jdo.Extent; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; -import org.apache.jdo.tck.pc.company.Address; + import org.apache.jdo.tck.pc.company.Company; import org.apache.jdo.tck.pc.company.Department; +import org.apache.jdo.tck.pc.company.Address; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: GetExtentWithInstancesMadePersistentViaReachability
    - * Keywords: inheritance extent
    - * Assertion ID: A12.5.4-1.
    - * Assertion Description: If an instance of a class or interface that has a managed extent - * is made persistent via reachability, the instance is put into the extent implicitly. + *Title: GetExtentWithInstancesMadePersistentViaReachability + *
    + *Keywords: inheritance extent + *
    + *Assertion ID: A12.5.4-1. + *
    + *Assertion Description: +If an instance of a class or interface that has a managed extent is made persistent via reachability, the instance is put into the extent implicitly. */ + public class GetExtentWithInstancesMadePersistentViaReachability extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.4-3 (GetExtentWithInstancesMadePersistentViaReachability) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetExtentWithInstancesMadePersistentViaReachability.class); - } - - /** */ - public void test() { - pm = getPM(); - createObjects(pm); - runTest(pm); - } - - /** */ - private void createObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - tx.begin(); - Company comp = - new Company(1L, "Sun Microsystems", new Date(), new Address(0, "", "", "", "", "")); - pm.makePersistent(comp); - // Add transient departments - comp.addDepartment(new Department(1L, "Department 1")); - comp.addDepartment(new Department(2L, "Department 2")); - comp.addDepartment(new Department(3L, "Department 3")); - tx.commit(); // Now the transient departments should be made persistent via reachability - } - - /** */ - private void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - tx.begin(); - Extent e = pm.getExtent(Department.class, false); - - boolean foundDep1 = false; - boolean foundDep2 = false; - boolean foundDep3 = false; - - for (Iterator i = e.iterator(); i.hasNext(); ) { - Department dep = (Department) i.next(); - if (dep.getName().equals("Department 1")) foundDep1 = true; - else if (dep.getName().equals("Department 2")) foundDep2 = true; - else if (dep.getName().equals("Department 3")) foundDep3 = true; - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.4-3 (GetExtentWithInstancesMadePersistentViaReachability) failed: "; - if (!foundDep1) { - fail( - ASSERTION_FAILED, - "Extent of class " - + Department.class.getName() - + " does not include instance with deptid 1L"); + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetExtentWithInstancesMadePersistentViaReachability.class); } - if (!foundDep2) { - fail( - ASSERTION_FAILED, - "Extent of class " - + Department.class.getName() - + " does not include instance with deptid 2L"); + + /** */ + public void test() { + pm = getPM(); + createObjects(pm); + runTest(pm); } - if (!foundDep3) { - fail( - ASSERTION_FAILED, - "Extent of class " - + Department.class.getName() - + " does not include instance with deptid 3L"); + + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + tx.begin(); + Company comp = new Company(1L, "Sun Microsystems", new Date(), new Address(0,"","","","","")); + pm.makePersistent(comp); + //Add transient departments + comp.addDepartment(new Department(1L, "Department 1")); + comp.addDepartment(new Department(2L, "Department 2")); + comp.addDepartment(new Department(3L, "Department 3")); + tx.commit(); //Now the transient departments should be made persistent via reachability } - tx.commit(); - } + /** */ + private void runTest(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + tx.begin(); + Extent e = pm.getExtent(Department.class, false); + + boolean foundDep1 = false; + boolean foundDep2 = false; + boolean foundDep3 = false; + + for (Iterator i = e.iterator(); i.hasNext();) { + Department dep = (Department) i.next(); + if (dep.getName().equals("Department 1")) + foundDep1=true; + else if (dep.getName().equals("Department 2")) + foundDep2=true; + else if (dep.getName().equals("Department 3")) + foundDep3=true; + } + + if (!foundDep1) { + fail(ASSERTION_FAILED, + "Extent of class " + Department.class.getName() + " does not include instance with deptid 1L"); + } + if (!foundDep2) { + fail(ASSERTION_FAILED, + "Extent of class " + Department.class.getName() + " does not include instance with deptid 2L"); + } + if (!foundDep3) { + fail(ASSERTION_FAILED, + "Extent of class " + Department.class.getName() + " does not include instance with deptid 3L"); + } + + tx.commit(); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/extent/GetExtentWithNoSubclasses.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/extent/GetExtentWithNoSubclasses.java index ca46c1427..df4e8b15c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/extent/GetExtentWithNoSubclasses.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/extent/GetExtentWithNoSubclasses.java @@ -5,101 +5,109 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.extent; import java.util.Iterator; + import javax.jdo.Extent; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: GetExtentWithNoSubclasses
    - * Keywords: inheritance extent
    - * Assertion ID: A12.5.4-2.
    - * Assertion Description: The getExtent method returns an Extent that contains all of the - * instances in the parameter class. With the subclasses parameter false, only instances of the - * specified class are returned. - */ -public class GetExtentWithNoSubclasses extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.4-2 (GetExtentWithNoSubclasses) failed: "; + *Title: GetExtentWithNoSubclasses + *
    + *Keywords: inheritance extent + *
    + *Assertion ID: A12.5.4-2. + *
    + *Assertion Description: +The getExtent method returns an Extent that contains all of the instances in the parameter class. With the subclasses parameter false, only instances of the specified class are returned. - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetExtentWithNoSubclasses.class); - } + */ - private PCPoint p1 = null; - private PCPoint p2 = null; +public class GetExtentWithNoSubclasses extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.4-2 (GetExtentWithNoSubclasses) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetExtentWithNoSubclasses.class); + } - /** */ - public void testGetExtentWithNoSubclasses() { - pm = getPM(); - createObjects(pm); - runTestGetExtent(pm); - pm.close(); - pm = null; - } + private PCPoint p1 = null; + private PCPoint p2 = null; - /** */ - private void createObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - PCPoint p2 = new PCPoint(3, 5); - pm.makePersistent(p1); - pm.makePersistent(p2); - tx.commit(); - } finally { - if (tx.isActive()) tx.rollback(); + /** */ + public void testGetExtentWithNoSubclasses() { + pm = getPM(); + createObjects(pm); + runTestGetExtent(pm); + pm.close(); + pm = null; } - } - /** */ - private void runTestGetExtent(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Extent e = pm.getExtent(PCPoint.class, false); + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 = new PCPoint (1,3); + PCPoint p2 = new PCPoint (3,5); + pm.makePersistent(p1); + pm.makePersistent(p2); + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } - int c = 0; - for (Iterator i = e.iterator(); i.hasNext(); ) { - PCPoint p = (PCPoint) i.next(); - if (debug) logger.debug("p.getX() = " + p.getX()); - if ((p.getX() == 1) || (p.getX() == 3)) { - // OK - } else { - fail( - ASSERTION_FAILED, - "Extent of class " - + PCPoint.class.getName() - + " includes unexpected instance, p.getX():" - + p.getX()); + /** */ + private void runTestGetExtent(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Extent e = pm.getExtent(PCPoint.class, false); + + int c = 0; + for (Iterator i = e.iterator(); i.hasNext();) { + PCPoint p = (PCPoint) i.next(); + if (debug) logger.debug("p.getX() = " + p.getX()); + if ((p.getX() == 1) || (p.getX() == 3)) { + // OK + } + else { + fail(ASSERTION_FAILED, + "Extent of class " + PCPoint.class.getName() + + " includes unexpected instance, p.getX():" + p.getX()); + } + } + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); } - } - tx.commit(); - } finally { - if (tx.isActive()) tx.rollback(); } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/extent/GetExtentWithSubclasses.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/extent/GetExtentWithSubclasses.java index 2673b9fb8..567dfe0cb 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/extent/GetExtentWithSubclasses.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/extent/GetExtentWithSubclasses.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,9 +19,12 @@ import java.util.Date; import java.util.Iterator; + import javax.jdo.Extent; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.FullTimeEmployee; @@ -30,122 +33,109 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: GetExtentWithSubclasses
    - * Keywords: inheritance extent
    - * Assertion ID: A12.5.4-3.
    - * Assertion Description: The getExtent method returns an Extent that contains all of the - * instances in the parameter class or interface, and if the subclasses flag is true, all of the - * instances of the parameter class and its subclasses. + *Title: GetExtentWithSubclasses + *
    + *Keywords: inheritance extent + *
    + *Assertion ID: A12.5.4-3. + *
    + *Assertion Description: +The getExtent method returns an Extent that contains all of the instances in the parameter class or interface, and if the subclasses flag is true, all of the instances of the parameter class and its subclasses. */ + public class GetExtentWithSubclasses extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.4-3 (GetExtentWithSubclasses) failed: "; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.4-3 (GetExtentWithSubclasses) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetExtentWithSubclasses.class); + } - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetExtentWithSubclasses.class); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FullTimeEmployee.class); + addTearDownClass(PartTimeEmployee.class); + addTearDownClass(Person.class); + super.localSetUp(); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FullTimeEmployee.class); - addTearDownClass(PartTimeEmployee.class); - addTearDownClass(Person.class); - super.localSetUp(); - } + /** */ + public void test() { + pm = getPM(); + createObjects(pm); + runTest(pm); + } - /** */ - public void test() { - pm = getPM(); - createObjects(pm); - runTest(pm); - } + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + tx.begin(); + Date date = new Date(); + Person p1 = new Person(1L, "Craig", "Russell", null, date, null); + Employee p2 = new FullTimeEmployee(2L, "Michael", "Bouschen", null, date, null, date, 0.0); + Employee p3 = new PartTimeEmployee(3L, "Michelle", "Caisse", null, date, null, date, 0.0); + Employee p4 = new FullTimeEmployee(4L, "Victor", "Kirkebo", null, date, null, date, 0.0); + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + tx.commit(); + } - /** */ - private void createObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - tx.begin(); - Date date = new Date(); - Person p1 = new Person(1L, "Craig", "Russell", null, date, null); - Employee p2 = new FullTimeEmployee(2L, "Michael", "Bouschen", null, date, null, date, 0.0); - Employee p3 = new PartTimeEmployee(3L, "Michelle", "Caisse", null, date, null, date, 0.0); - Employee p4 = new FullTimeEmployee(4L, "Victor", "Kirkebo", null, date, null, date, 0.0); - pm.makePersistent(p1); - pm.makePersistent(p2); - pm.makePersistent(p3); - pm.makePersistent(p4); - tx.commit(); - } + /** */ + private void runTest(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + tx.begin(); + Extent e = pm.getExtent(Person.class, true); - /** */ - private void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - tx.begin(); - Extent e = pm.getExtent(Person.class, true); + boolean foundCraig = false; + boolean foundMichael = false; + boolean foundMichelle = false; + boolean foundVictor = false; - boolean foundCraig = false; - boolean foundMichael = false; - boolean foundMichelle = false; - boolean foundVictor = false; + for (Iterator i = e.iterator(); i.hasNext();) { + Person p = (Person) i.next(); + if ((p.getFirstname().equals("Craig")) && (p.getLastname().equals("Russell"))) + foundCraig=true; + else if ((p.getFirstname().equals("Michael")) && (p.getLastname().equals("Bouschen"))) + foundMichael=true; + else if ((p.getFirstname().equals("Michelle")) && (p.getLastname().equals("Caisse"))) + foundMichelle=true; + else if ((p.getFirstname().equals("Victor")) && (p.getLastname().equals("Kirkebo"))) + foundVictor=true; + } - for (Iterator i = e.iterator(); i.hasNext(); ) { - Person p = (Person) i.next(); - if ((p.getFirstname().equals("Craig")) && (p.getLastname().equals("Russell"))) - foundCraig = true; - else if ((p.getFirstname().equals("Michael")) && (p.getLastname().equals("Bouschen"))) - foundMichael = true; - else if ((p.getFirstname().equals("Michelle")) && (p.getLastname().equals("Caisse"))) - foundMichelle = true; - else if ((p.getFirstname().equals("Victor")) && (p.getLastname().equals("Kirkebo"))) - foundVictor = true; - } + if (!foundCraig) { + fail(ASSERTION_FAILED, + "Extent of class " + Person.class.getName() + + " does not include instance of class " + Person.class.getName() + " with personid 1L"); + } + if (!foundMichael) { + fail(ASSERTION_FAILED, + "Extent of class " + Person.class.getName() + + " does not include instance of class " + Employee.class.getName() + " with personid 2L"); + } + if (!foundMichelle) { + fail(ASSERTION_FAILED, + "Extent of class " + Person.class.getName() + + " does not include instance of class " + PartTimeEmployee.class.getName() + " with personid 3L"); + } + if (!foundVictor) { + fail(ASSERTION_FAILED, + "Extent of class " + Person.class.getName() + + " does not include instance of class " + FullTimeEmployee.class.getName() + " with personid 4L"); + } - if (!foundCraig) { - fail( - ASSERTION_FAILED, - "Extent of class " - + Person.class.getName() - + " does not include instance of class " - + Person.class.getName() - + " with personid 1L"); - } - if (!foundMichael) { - fail( - ASSERTION_FAILED, - "Extent of class " - + Person.class.getName() - + " does not include instance of class " - + Employee.class.getName() - + " with personid 2L"); + tx.commit(); } - if (!foundMichelle) { - fail( - ASSERTION_FAILED, - "Extent of class " - + Person.class.getName() - + " does not include instance of class " - + PartTimeEmployee.class.getName() - + " with personid 3L"); - } - if (!foundVictor) { - fail( - ASSERTION_FAILED, - "Extent of class " - + Person.class.getName() - + " does not include instance of class " - + FullTimeEmployee.class.getName() - + " with personid 4L"); - } - - tx.commit(); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/AbstractFetchPlanTest.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/AbstractFetchPlanTest.java index 346f13216..b900db931 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/AbstractFetchPlanTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/AbstractFetchPlanTest.java @@ -5,159 +5,159 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.fetchplan; import java.util.Collection; import java.util.HashSet; + import javax.jdo.FetchPlan; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.pc.mylib.PCRect; /** - * This class is an abstract superclass for the fetch plan tests. It contains methods useful for - * testing the behavior of the fetch plan. + * This class is an abstract superclass for the fetch plan tests. + * It contains methods useful for testing the behavior of the + * fetch plan. */ public class AbstractFetchPlanTest extends JDO_Test { - /* - * The main method is not defined in this abstract class. - */ - - /** The persistent instances used in the test. */ - protected PCPoint upperLeft; - - protected PCPoint lowerRight; - protected PCRect pcrect; - - /** The oids of the persistent instances used in the test. */ - protected Object upperLeftoid; - - protected Object lowerRightoid; - protected Object pcrectoid; - - /** The String arrays used for setting fetch groups. */ - protected String[] defaultGroup = new String[] {"default"}; - - protected String[] upperLeftGroup = new String[] {"default", "PCRect.upperLeft"}; - protected String[] lowerRightGroup = new String[] {"default", "PCRect.lowerRight"}; - protected String[] bothGroup = new String[] {"default", "PCRect.upperLeft", "PCRect.lowerRight"}; - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCRect.class); - addTearDownClass(PCPoint.class); - upperLeft = new PCPoint(0, 10); - lowerRight = new PCPoint(10, 0); - pcrect = new PCRect(upperLeft, lowerRight); - getPM().currentTransaction().begin(); - pm.makePersistent(pcrect); // makes all three persistent - upperLeftoid = pm.getObjectId(upperLeft); - lowerRightoid = pm.getObjectId(lowerRight); - pcrectoid = pm.getObjectId(pcrect); - pm.currentTransaction().commit(); - } - - /** Set the default plus upper left field as the fetch group. */ - protected void setDefaultGroup() { - FetchPlan fp = getPM().getFetchPlan(); - fp.setGroups(defaultGroup); - } - - /** Set the default plus upper left field as the fetch group. */ - protected void setUpperLeftGroup() { - FetchPlan fp = getPM().getFetchPlan(); - fp.setGroups(upperLeftGroup); - } - - /** Set the default plus lower right field as the fetch group. */ - protected void setLowerRightGroup() { - FetchPlan fp = getPM().getFetchPlan(); - fp.setGroups(upperLeftGroup); - } - - /** Set the default plus both fields as the fetch group. */ - protected void setBothGroup() { - FetchPlan fp = getPM().getFetchPlan(); - fp.setGroups(bothGroup); - } - - /** - * @param location location - * @param pcrect PCREct instance - */ - protected void checkBothLoaded(String location, PCRect pcrect) { - checkUpperLeftLoaded(location, pcrect); - checkLowerRightLoaded(location, pcrect); - } - - /** - * @param location location - * @param pcrect PCREct instance - */ - protected void checkUpperLeftLoaded(String location, PCRect pcrect) { - if (pcrect.upperLeft == null) { - appendMessage( - location - + NL - + "Upper Left was null." - + NL - + "The fetch plan includes PCRect.upperLeft and this field" - + " should have been loaded."); + /* + * The main method is not defined in this abstract class. + */ + + /** The persistent instances used in the test. + */ + protected PCPoint upperLeft; + protected PCPoint lowerRight; + protected PCRect pcrect; + + /** The oids of the persistent instances used in the test. + */ + protected Object upperLeftoid; + protected Object lowerRightoid; + protected Object pcrectoid; + + /** The String arrays used for setting fetch groups. + */ + protected String[] defaultGroup = new String[] + {"default"}; + protected String[] upperLeftGroup = new String[] + {"default", "PCRect.upperLeft"}; + protected String[] lowerRightGroup = new String[] + {"default", "PCRect.lowerRight"}; + protected String[] bothGroup = new String[]{ + "default", "PCRect.upperLeft", "PCRect.lowerRight"}; + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCRect.class); + addTearDownClass(PCPoint.class); + upperLeft = new PCPoint(0,10); + lowerRight = new PCPoint(10,0); + pcrect = new PCRect(upperLeft, lowerRight); + getPM().currentTransaction().begin(); + pm.makePersistent(pcrect); // makes all three persistent + upperLeftoid = pm.getObjectId(upperLeft); + lowerRightoid = pm.getObjectId(lowerRight); + pcrectoid = pm.getObjectId(pcrect); + pm.currentTransaction().commit(); + } + + /** Set the default plus upper left field as the fetch group. + */ + protected void setDefaultGroup() { + FetchPlan fp = getPM().getFetchPlan(); + fp.setGroups(defaultGroup); + } + + /** Set the default plus upper left field as the fetch group. + */ + protected void setUpperLeftGroup() { + FetchPlan fp = getPM().getFetchPlan(); + fp.setGroups(upperLeftGroup); + } + + /** Set the default plus lower right field as the fetch group. + */ + protected void setLowerRightGroup() { + FetchPlan fp = getPM().getFetchPlan(); + fp.setGroups(upperLeftGroup); + } + + /** Set the default plus both fields as the fetch group. + */ + protected void setBothGroup() { + FetchPlan fp = getPM().getFetchPlan(); + fp.setGroups(bothGroup); + } + + /** + * + * @param location location + * @param pcrect PCREct instance + */ + protected void checkBothLoaded(String location, PCRect pcrect) { + checkUpperLeftLoaded(location, pcrect); + checkLowerRightLoaded(location, pcrect); } - } - - /** - * @param location location - * @param pcrect pc instance - */ - protected void checkLowerRightLoaded(String location, PCRect pcrect) { - if (pcrect.lowerRight == null) { - appendMessage( - location - + NL - + "Lower Right was null." - + NL - + "The fetch plan includes PCRect.lowerRight and this field" - + " should have been loaded."); + + /** + * + * @param location location + * @param pcrect PCREct instance + */ + protected void checkUpperLeftLoaded(String location, PCRect pcrect) { + if (pcrect.upperLeft == null) { + appendMessage(location + NL + "Upper Left was null." + NL + + "The fetch plan includes PCRect.upperLeft and this field" + + " should have been loaded."); + } } - } - - /** - * @param location location - * @param fetchPlan fetch plan - * @param groups groups - */ - protected void checkGroups(String location, FetchPlan fetchPlan, String[] groups) { - Collection expected = new HashSet(); - Collection actual = fetchPlan.getGroups(); - for (int i = 0; i < groups.length; ++i) { - expected.add(groups[i]); + + /** + * + * @param location location + * @param pcrect pc instance + */ + protected void checkLowerRightLoaded(String location, PCRect pcrect) { + if (pcrect.lowerRight == null) { + appendMessage(location + NL + "Lower Right was null." + NL + + "The fetch plan includes PCRect.lowerRight and this field" + + " should have been loaded."); + } } - if (!expected.equals(actual)) { - appendMessage( - location - + NL - + "Fetch groups differ." - + NL - + "expected: " - + expected - + NL - + "actual: " - + actual - + NL); + + /** + * + * @param location location + * @param fetchPlan fetch plan + * @param groups groups + */ + protected void checkGroups(String location, + FetchPlan fetchPlan, String[] groups) { + Collection expected = new HashSet(); + Collection actual = fetchPlan.getGroups(); + for (int i = 0; i < groups.length; ++i) { + expected.add(groups[i]); + } + if (!expected.equals(actual)) { + appendMessage(location + NL + "Fetch groups differ." + NL + + "expected: " + expected + NL + + "actual: " + actual + NL); + } } - } -} +} \ No newline at end of file diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanInterface.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanInterface.java index 694bb2f35..834d66243 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanInterface.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanInterface.java @@ -5,341 +5,388 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.fetchplan; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.Set; + import javax.jdo.FetchPlan; + import org.apache.jdo.tck.JDO_Test; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.pc.mylib.PCRect; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test TITLE
    - * Keywords: fetch plan
    - * Assertion IDs: 12.7.1-1
    - * Assertion Description: public interface FetchPlan { String DEFAULT = "default"; String - * ALL = "all"; int FETCH_SIZE_GREEDY = -1; int FETCH_SIZE_OPTIMAL = 0; int DETACH_LOAD_FIELDS = 1; - * int DETACH_UNLOAD_FIELDS = 2; A12.7.1-1 [/** Add the fetchgroup to the set of active fetch - * groups. Duplicate names will be removed. FetchPlan addGroup(String fetchGroupName); /** Remove - * the fetch group from the set active fetch groups. FetchPlan removeGroup(String fetchGroupName); - * /** Remove all active groups, including the default fetch group. FetchPlan clearGroups(); /** - * Return an immutable Set of the names of all active fetch groups. Set getGroups(); /** Set a - * Collection of group names to replace the current groups. Duplicate names will be removed. - * FetchPlan setGroups(Collection fetchGroupNames); /** Set an array of group names to replace the - * current groups. Duplicate names will be removed. FetchPlan setGroups(String[] fetchGroupNames); - * /** Set a single group to replace the current groups. FetchPlan setGroup(String fetchGroupName);] - * /** Set the roots for DetachAllOnCommit FetchPlan setDetachmentRoots(Collection roots); /** Get - * the roots for DetachAllOnCommit Collection getDetachmentRoots(); /** Set the roots for - * DetachAllOnCommit FetchPlan setDetachmentRootClasses(Class[] rootClasses); /** Get the roots for - * DetachAllOnCommit Class[] getDetachmentRootClasses(); /** Set the maximum fetch depth. FetchPlan - * setMaxFetchDepth(int fetchDepth); /** Get the maximum fetch depth. int getMaxFetchDepth(); - * A12.7.1-2 [/** Set the fetch size for large result set support. FetchPlan setFetchSize(int - * fetchSize); /** Return the fetch size; 0 if not set; -1 for greedy fetching. int getFetchSize();] - * A12.7.1-3 [/** Set detachment options FetchPlan setDetachmentOptions(int options); /** Return the - * detachment options int getDetachmentOptions();] + *Title: Test TITLE + *
    + *Keywords: fetch plan + *
    + *Assertion IDs: 12.7.1-1 + *
    + *Assertion Description: +public interface FetchPlan { +String DEFAULT = "default"; +String ALL = "all"; +int FETCH_SIZE_GREEDY = -1; +int FETCH_SIZE_OPTIMAL = 0; +int DETACH_LOAD_FIELDS = 1; +int DETACH_UNLOAD_FIELDS = 2; +A12.7.1-1 [/** Add the fetchgroup to the set of active fetch groups. Duplicate names will be removed. +FetchPlan addGroup(String fetchGroupName); +/** Remove the fetch group from the set active fetch groups. +FetchPlan removeGroup(String fetchGroupName); +/** Remove all active groups, including the default fetch group. +FetchPlan clearGroups(); +/** Return an immutable Set of the names of all active fetch groups. +Set getGroups(); +/** Set a Collection of group names to replace the current groups. Duplicate names will be removed. +FetchPlan setGroups(Collection fetchGroupNames); +/** Set an array of group names to replace the current groups. Duplicate names will be removed. +FetchPlan setGroups(String[] fetchGroupNames); +/** Set a single group to replace the current groups. +FetchPlan setGroup(String fetchGroupName);] +/** Set the roots for DetachAllOnCommit +FetchPlan setDetachmentRoots(Collection roots); +/** Get the roots for DetachAllOnCommit +Collection getDetachmentRoots(); +/** Set the roots for DetachAllOnCommit +FetchPlan setDetachmentRootClasses(Class[] rootClasses); +/** Get the roots for DetachAllOnCommit +Class[] getDetachmentRootClasses(); +/** Set the maximum fetch depth. +FetchPlan setMaxFetchDepth(int fetchDepth); +/** Get the maximum fetch depth. +int getMaxFetchDepth(); +A12.7.1-2 [/** Set the fetch size for large result set support. +FetchPlan setFetchSize(int fetchSize); +/** Return the fetch size; 0 if not set; -1 for greedy fetching. +int getFetchSize();] +A12.7.1-3 [/** Set detachment options +FetchPlan setDetachmentOptions(int options); +/** Return the detachment options +int getDetachmentOptions();] */ -public class FetchPlanInterface extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion 12.7.1-1 (FetchPlanTest) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(FetchPlanInterface.class); - } +public class FetchPlanInterface extends JDO_Test { - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCRect.class); - addTearDownClass(PCPoint.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion 12.7.1-1 (FetchPlanTest) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(FetchPlanInterface.class); + } - /** - * @param expected expected value - * @param actual actual value - * @return true if equal - */ - protected boolean setEquals(Collection expected, Collection actual) { - if (expected == actual) return true; - if (expected == null || actual == null) return false; - Set expectedSet = new HashSet(expected); - Set actualSet = new HashSet(actual); - return expectedSet.equals(actualSet); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCRect.class); + addTearDownClass(PCPoint.class); + } - /** - * @param message message - * @param expected expected value - * @param actual actual value - */ - protected void failCompare(String message, Object expected, Object actual) { - appendMessage(ASSERTION_FAILED + message); - appendMessage("expected: " + expected); - appendMessage("actual: " + actual); - } + /** + * + * @param expected expected value + * @param actual actual value + * @return true if equal + */ + protected boolean setEquals + (Collection expected, Collection actual) { + if (expected == actual) + return true; + if (expected == null || actual == null) + return false; + Set expectedSet = new HashSet(expected); + Set actualSet = new HashSet(actual); + return expectedSet.equals(actualSet); + } - /** - * @param message message - * @param expected expected value - * @param actual actual value - */ - protected void failCompare(String message, int expected, int actual) { - appendMessage(ASSERTION_FAILED + message); - appendMessage("expected: " + expected); - appendMessage("actual: " + actual); - } + /** + * + * @param message message + * @param expected expected value + * @param actual actual value + */ + protected void failCompare(String message, + Object expected, Object actual) { + appendMessage(ASSERTION_FAILED + message); + appendMessage("expected: " + expected); + appendMessage("actual: " + actual); + } - /** */ - public void testGroups() { - checkDefaultGroups(); - checkClearGroups(); - checkSetGroup(); - checkAddGroup(); - checkRemoveGroup(); - checkClearGroups(); - checkSetGroupsCollection(); - checkSetGroupsArray(); - failOnError(); - } + /** + * + * @param message message + * @param expected expected value + * @param actual actual value + */ + protected void failCompare(String message, + int expected, int actual) { + appendMessage(ASSERTION_FAILED + message); + appendMessage("expected: " + expected); + appendMessage("actual: " + actual); + } - /** */ - public void testDetachmentRoots() { - checkGetDetachmentRoots(); - checkSetDetachmentRoots(); - checkSetDetachmentRootClasses(); - failOnError(); - } + /** */ + public void testGroups() { + checkDefaultGroups(); + checkClearGroups(); + checkSetGroup(); + checkAddGroup(); + checkRemoveGroup(); + checkClearGroups(); + checkSetGroupsCollection(); + checkSetGroupsArray(); + failOnError(); + } - /** */ - public void testDetachmentOptions() { - int expectedOptions = FetchPlan.DETACH_LOAD_FIELDS + FetchPlan.DETACH_UNLOAD_FIELDS; - FetchPlan fp = getPM().getFetchPlan(); - int initialOptions = fp.getDetachmentOptions(); - if (FetchPlan.DETACH_LOAD_FIELDS != initialOptions) { - failCompare( - "testDetachmentOptions(): wrong getDetachmentOptions() " - + "after getPersistenceManager().", - FetchPlan.DETACH_LOAD_FIELDS, - initialOptions); + /** */ + public void testDetachmentRoots() { + checkGetDetachmentRoots(); + checkSetDetachmentRoots(); + checkSetDetachmentRootClasses(); + failOnError(); } - fp.setDetachmentOptions(expectedOptions); - int actualOptions = fp.getDetachmentOptions(); - if (expectedOptions != actualOptions) { - failCompare( - "testDetachmentOptions(): wrong getDetachmentOptions() " - + "after setDetachmentOptions().", - expectedOptions, - actualOptions); + + /** */ + public void testDetachmentOptions() { + int expectedOptions = + FetchPlan.DETACH_LOAD_FIELDS + + FetchPlan.DETACH_UNLOAD_FIELDS; + FetchPlan fp = getPM().getFetchPlan(); + int initialOptions = fp.getDetachmentOptions(); + if (FetchPlan.DETACH_LOAD_FIELDS != initialOptions) { + failCompare( + "testDetachmentOptions(): wrong getDetachmentOptions() " + + "after getPersistenceManager().", + FetchPlan.DETACH_LOAD_FIELDS, initialOptions); + } + fp.setDetachmentOptions(expectedOptions); + int actualOptions = fp.getDetachmentOptions(); + if (expectedOptions != actualOptions) { + failCompare( + "testDetachmentOptions(): wrong getDetachmentOptions() " + + "after setDetachmentOptions().", + expectedOptions, actualOptions); + } + cleanupPM(); + failOnError(); } - cleanupPM(); - failOnError(); - } - /** */ - public void testMaxFetchDepth() { - int expectedMaxFetchDepth = 12; - FetchPlan fp = getPM().getFetchPlan(); - fp.setMaxFetchDepth(expectedMaxFetchDepth); - int actualMaxFetchDepth = fp.getMaxFetchDepth(); - if (expectedMaxFetchDepth != actualMaxFetchDepth) { - failCompare( - "testMaxFetchDepth(): wrong getMaxFetchDepth() " + "after setMaxFetchDepth().", - expectedMaxFetchDepth, - actualMaxFetchDepth); + /** */ + public void testMaxFetchDepth() { + int expectedMaxFetchDepth = 12; + FetchPlan fp = getPM().getFetchPlan(); + fp.setMaxFetchDepth(expectedMaxFetchDepth); + int actualMaxFetchDepth = fp.getMaxFetchDepth(); + if (expectedMaxFetchDepth != actualMaxFetchDepth) { + failCompare( + "testMaxFetchDepth(): wrong getMaxFetchDepth() " + + "after setMaxFetchDepth().", + expectedMaxFetchDepth, actualMaxFetchDepth); + } + cleanupPM(); + failOnError(); } - cleanupPM(); - failOnError(); - } - /** */ - public void testFetchSize() { - int expectedFetchSize = 12; - FetchPlan fp = getPM().getFetchPlan(); - fp.setFetchSize(expectedFetchSize); - int actualFetchSize = fp.getFetchSize(); - if (expectedFetchSize != actualFetchSize) { - failCompare( - "testFetchSize(): wrong getFetchSize() " + "after setFetchSize().", - expectedFetchSize, - actualFetchSize); + /** */ + public void testFetchSize() { + int expectedFetchSize = 12; + FetchPlan fp = getPM().getFetchPlan(); + fp.setFetchSize(expectedFetchSize); + int actualFetchSize = fp.getFetchSize(); + if (expectedFetchSize != actualFetchSize) { + failCompare( + "testFetchSize(): wrong getFetchSize() " + + "after setFetchSize().", + expectedFetchSize, actualFetchSize); + } + cleanupPM(); + failOnError(); } - cleanupPM(); - failOnError(); - } - /** */ - public void checkDefaultGroups() { - Set expectedGroups = new HashSet(); - expectedGroups.add("default"); - FetchPlan fp = getPM().getFetchPlan(); - Collection groups = fp.getGroups(); - if (!setEquals(expectedGroups, groups)) { - failCompare( - "checkDefaultGroups(): wrong getGroups() " + "after getPersistenceManager().", - expectedGroups, - groups); + /** */ + public void checkDefaultGroups() { + Set expectedGroups = new HashSet(); + expectedGroups.add("default"); + FetchPlan fp = getPM().getFetchPlan(); + Collection groups = fp.getGroups(); + if (!setEquals(expectedGroups, groups)) { + failCompare( + "checkDefaultGroups(): wrong getGroups() " + + "after getPersistenceManager().", + expectedGroups, groups); + } + cleanupPM(); } - cleanupPM(); - } - /** */ - public void checkClearGroups() { - Set expectedGroups = new HashSet(); - FetchPlan fp = getPM().getFetchPlan(); - fp.clearGroups(); - Collection groups = fp.getGroups(); - if (!setEquals(expectedGroups, groups)) { - failCompare( - "checkClearGroups(): wrong getGroups() " + "after clearGroups.", expectedGroups, groups); + /** */ + public void checkClearGroups() { + Set expectedGroups = new HashSet(); + FetchPlan fp = getPM().getFetchPlan(); + fp.clearGroups(); + Collection groups = fp.getGroups(); + if (!setEquals(expectedGroups, groups)) { + failCompare( + "checkClearGroups(): wrong getGroups() " + + "after clearGroups.", + expectedGroups, groups); + } + cleanupPM(); } - cleanupPM(); - } - /** */ - public void checkSetGroup() { - Set expectedGroups = new HashSet(); - expectedGroups.add("group1"); - FetchPlan fp = getPM().getFetchPlan(); - fp.setGroup("group1"); - Collection groups = fp.getGroups(); - if (!setEquals(expectedGroups, groups)) { - failCompare( - "checkSetGroup(): wrong getGroups() " + "after setGroup.", expectedGroups, groups); + /** */ + public void checkSetGroup() { + Set expectedGroups = new HashSet(); + expectedGroups.add("group1"); + FetchPlan fp = getPM().getFetchPlan(); + fp.setGroup("group1"); + Collection groups = fp.getGroups(); + if (!setEquals(expectedGroups, groups)) { + failCompare( + "checkSetGroup(): wrong getGroups() " + + "after setGroup.", + expectedGroups, groups); + } + cleanupPM(); } - cleanupPM(); - } - /** */ - public void checkAddGroup() { - Set expectedGroups = new HashSet(); - expectedGroups.add("default"); - expectedGroups.add("group1"); - FetchPlan fp = getPM().getFetchPlan(); - fp.addGroup("group1"); - Collection groups = fp.getGroups(); - if (!setEquals(expectedGroups, groups)) { - failCompare( - "checkAddGroup(): wrong getGroups() " + "after addGroup.", expectedGroups, groups); + /** */ + public void checkAddGroup() { + Set expectedGroups = new HashSet(); + expectedGroups.add("default"); + expectedGroups.add("group1"); + FetchPlan fp = getPM().getFetchPlan(); + fp.addGroup("group1"); + Collection groups = fp.getGroups(); + if (!setEquals(expectedGroups, groups)) { + failCompare( + "checkAddGroup(): wrong getGroups() " + + "after addGroup.", + expectedGroups, groups); + } + cleanupPM(); } - cleanupPM(); - } - /** */ - public void checkRemoveGroup() { - Set expectedGroups = new HashSet(); - FetchPlan fp = getPM().getFetchPlan(); - fp.removeGroup("default"); - Collection groups = fp.getGroups(); - if (!setEquals(expectedGroups, groups)) { - failCompare( - "checkRemoveGroup(): wrong getGroups() " + "after removeGroup.", expectedGroups, groups); + /** */ + public void checkRemoveGroup() { + Set expectedGroups = new HashSet(); + FetchPlan fp = getPM().getFetchPlan(); + fp.removeGroup("default"); + Collection groups = fp.getGroups(); + if (!setEquals(expectedGroups, groups)) { + failCompare( + "checkRemoveGroup(): wrong getGroups() " + + "after removeGroup.", + expectedGroups, groups); + } + cleanupPM(); } - cleanupPM(); - } - /** */ - public void checkSetGroupsCollection() { - Set expectedGroups = new HashSet(); - expectedGroups.add("default"); - expectedGroups.add("group1"); - expectedGroups.add("group2"); - FetchPlan fp = getPM().getFetchPlan(); - fp.setGroups(expectedGroups); - Collection groups = fp.getGroups(); - if (!setEquals(expectedGroups, groups)) { - failCompare( - "checkSetGroupsCollection(): wrong getGroups() " + "after SetGroups(Collection).", - expectedGroups, - groups); + /** */ + public void checkSetGroupsCollection() { + Set expectedGroups = new HashSet(); + expectedGroups.add("default"); + expectedGroups.add("group1"); + expectedGroups.add("group2"); + FetchPlan fp = getPM().getFetchPlan(); + fp.setGroups(expectedGroups); + Collection groups = fp.getGroups(); + if (!setEquals(expectedGroups, groups)) { + failCompare( + "checkSetGroupsCollection(): wrong getGroups() " + + "after SetGroups(Collection).", + expectedGroups, groups); + } + cleanupPM(); } - cleanupPM(); - } - /** */ - public void checkSetGroupsArray() { - Set expectedGroups = new HashSet(); - expectedGroups.add("default"); - expectedGroups.add("group1"); - expectedGroups.add("group2"); - FetchPlan fp = getPM().getFetchPlan(); - fp.setGroups(new String[] {"default", "group1", "group2"}); - Collection groups = fp.getGroups(); - if (!setEquals(expectedGroups, groups)) { - failCompare( - "checkSetGroupsArray(): wrong getGroups() " + "after setGroups(String[]).", - expectedGroups, - groups); + /** */ + public void checkSetGroupsArray() { + Set expectedGroups = new HashSet(); + expectedGroups.add("default"); + expectedGroups.add("group1"); + expectedGroups.add("group2"); + FetchPlan fp = getPM().getFetchPlan(); + fp.setGroups(new String[] {"default", "group1", "group2"}); + Collection groups = fp.getGroups(); + if (!setEquals(expectedGroups, groups)) { + failCompare( + "checkSetGroupsArray(): wrong getGroups() " + + "after setGroups(String[]).", + expectedGroups, groups); + } + cleanupPM(); } - cleanupPM(); - } - /** */ - protected void checkGetDetachmentRoots() { - Set expectedRoots = new HashSet(); - FetchPlan fp = getPM().getFetchPlan(); - Collection roots = fp.getDetachmentRoots(); - if (!setEquals(expectedRoots, roots)) { - failCompare( - "checkGetDetachmentRoots(): wrong getDetachmentRoots() " - + "after getPersistenceManager().", - expectedRoots, - roots); + /** */ + protected void checkGetDetachmentRoots() { + Set expectedRoots = new HashSet(); + FetchPlan fp = getPM().getFetchPlan(); + Collection roots = fp.getDetachmentRoots(); + if (!setEquals(expectedRoots, roots)) { + failCompare( + "checkGetDetachmentRoots(): wrong getDetachmentRoots() " + + "after getPersistenceManager().", + expectedRoots, roots); + } + cleanupPM(); } - cleanupPM(); - } - /** */ - protected void checkSetDetachmentRoots() { - PCPoint p = new PCPoint(10, 20); - Set expectedRoots = new HashSet(); - expectedRoots.add(p); - FetchPlan fp = getPM().getFetchPlan(); - fp.setDetachmentRoots(expectedRoots); - Collection roots = fp.getDetachmentRoots(); - if (!setEquals(expectedRoots, roots)) { - failCompare( - "checkGetDetachmentRoots(): wrong getDetachmentRoots() " + "after setDetachmentRoots().", - expectedRoots, - roots); + /** */ + protected void checkSetDetachmentRoots() { + PCPoint p = new PCPoint(10, 20); + Set expectedRoots = new HashSet(); + expectedRoots.add(p); + FetchPlan fp = getPM().getFetchPlan(); + fp.setDetachmentRoots(expectedRoots); + Collection roots = fp.getDetachmentRoots(); + if (!setEquals(expectedRoots, roots)) { + failCompare( + "checkGetDetachmentRoots(): wrong getDetachmentRoots() " + + "after setDetachmentRoots().", + expectedRoots, roots); + } + cleanupPM(); } - cleanupPM(); - } - /** */ - private void checkSetDetachmentRootClasses() { - Class[] expectedRootClasses = new Class[] {PCPoint.class}; - FetchPlan fp = getPM().getFetchPlan(); - fp.setDetachmentRootClasses(expectedRootClasses); - Class[] rootClasses = fp.getDetachmentRootClasses(); - if (!Arrays.equals(expectedRootClasses, rootClasses)) { - failCompare( - "checkGetDetachmentRootClasses(): " - + "wrong getDetachmentRootClasses() " - + "after setDetachmentRootClasses().", - expectedRootClasses, - rootClasses); + /** */ + private void checkSetDetachmentRootClasses() { + Class[] expectedRootClasses = new Class[] {PCPoint.class}; + FetchPlan fp = getPM().getFetchPlan(); + fp.setDetachmentRootClasses( + expectedRootClasses); + Class[] rootClasses = fp.getDetachmentRootClasses(); + if (!Arrays.equals(expectedRootClasses, rootClasses)) { + failCompare( + "checkGetDetachmentRootClasses(): " + + "wrong getDetachmentRootClasses() " + + "after setDetachmentRootClasses().", + expectedRootClasses, rootClasses); + } + cleanupPM(); } - cleanupPM(); - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanIsCopy.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanIsCopy.java index dc952aae7..b267e04e8 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanIsCopy.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanIsCopy.java @@ -5,119 +5,138 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.fetchplan; import java.util.Arrays; + import javax.jdo.Extent; +import javax.jdo.FetchPlan; import javax.jdo.Query; + +import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.pc.mylib.PCRect; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test TITLE
    - * Keywords: fetch plan
    - * Assertion IDs: 12.7.5-1
    - * Assertion Description: Subsequent modifications of the Query FetchPlan are not reflected - * in the FetchPlan of the PersistenceManager. + *Title: Test TITLE + *
    + *Keywords: fetch plan + *
    + *Assertion IDs: 12.7.5-1 + *
    + *Assertion Description: Subsequent modifications of the Query FetchPlan are not reflected in the FetchPlan of the PersistenceManager. */ + public class FetchPlanIsCopy extends AbstractFetchPlanTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion 12.7.5-1 (FetchPlanIsCopy) failed: "; - - Query query = null; - Extent extent = null; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(FetchPlanIsCopy.class); - } - - /** */ - public void testRemoveGroup() { - beginFPTest(); - query.getFetchPlan().removeGroup("PCRect.upperLeft"); - // check that query fetch plan is changed - checkGroups(ASSERTION_FAILED + " testRemoveGroup()", query.getFetchPlan(), defaultGroup); - closeFPTest("testRemoveGroup()"); - } - - /** */ - public void testAddGroup() { - beginFPTest(); - query.getFetchPlan().addGroup("PCRect.lowerRight"); - // check that query fetch plan is changed - checkGroups(ASSERTION_FAILED + " testAddGroup()", query.getFetchPlan(), bothGroup); - closeFPTest("testAddGroup()"); - } - - /** */ - public void testClearGroups() { - beginFPTest(); - query.getFetchPlan().clearGroups(); - // check that query fetch plan is changed - checkGroups(ASSERTION_FAILED + " testClearGroups()", query.getFetchPlan(), new String[] {}); - closeFPTest("testClearGroup()"); - } - - /** */ - public void testSetGroup() { - beginFPTest(); - query.getFetchPlan().setGroup("default"); - // check that query fetch plan is changed - checkGroups(ASSERTION_FAILED + " testSetGroup()", query.getFetchPlan(), defaultGroup); - closeFPTest("testSetGroup()"); - } - - /** */ - public void testSetGroupsCollection() { - beginFPTest(); - query.getFetchPlan().setGroups(Arrays.asList(bothGroup)); - // check that query fetch plan is changed - checkGroups(ASSERTION_FAILED + " testSetGroupsCollection()", query.getFetchPlan(), bothGroup); - closeFPTest("testSetGroupsCollection()"); - } - - /** */ - public void testSetGroupsArray() { - beginFPTest(); - query.getFetchPlan().setGroups(bothGroup); - // check that query fetch plan is changed - checkGroups(ASSERTION_FAILED + " testSetGroupsArray()", query.getFetchPlan(), bothGroup); - closeFPTest("testSetGroupsArray()"); - } - - /** */ - public void beginFPTest() { - setUpperLeftGroup(); - pm.currentTransaction().begin(); - query = pm.newQuery(PCRect.class); - extent = pm.getExtent(PCRect.class); - } - - /** - * @param location location - */ - public void closeFPTest(String location) { - // check that pm fetch plan is unchanged - checkGroups(ASSERTION_FAILED + " " + location, pm.getFetchPlan(), upperLeftGroup); - // check that extent fetch plan is unchanged - checkGroups(ASSERTION_FAILED + " " + location, extent.getFetchPlan(), upperLeftGroup); - pm.currentTransaction().rollback(); - failOnError(); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion 12.7.5-1 (FetchPlanIsCopy) failed: "; + + Query query = null; + Extent extent = null; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(FetchPlanIsCopy.class); + } + + /** */ + public void testRemoveGroup() { + beginFPTest(); + query.getFetchPlan().removeGroup("PCRect.upperLeft"); + // check that query fetch plan is changed + checkGroups(ASSERTION_FAILED + " testRemoveGroup()", + query.getFetchPlan(), defaultGroup); + closeFPTest("testRemoveGroup()"); + } + + /** */ + public void testAddGroup() { + beginFPTest(); + query.getFetchPlan().addGroup("PCRect.lowerRight"); + // check that query fetch plan is changed + checkGroups(ASSERTION_FAILED + " testAddGroup()", + query.getFetchPlan(), bothGroup); + closeFPTest("testAddGroup()"); + } + + /** */ + public void testClearGroups() { + beginFPTest(); + query.getFetchPlan().clearGroups(); + // check that query fetch plan is changed + checkGroups(ASSERTION_FAILED + " testClearGroups()", + query.getFetchPlan(), new String[]{}); + closeFPTest("testClearGroup()"); + } + + /** */ + public void testSetGroup() { + beginFPTest(); + query.getFetchPlan().setGroup("default"); + // check that query fetch plan is changed + checkGroups(ASSERTION_FAILED + " testSetGroup()", + query.getFetchPlan(), defaultGroup); + closeFPTest("testSetGroup()"); + } + + /** */ + public void testSetGroupsCollection() { + beginFPTest(); + query.getFetchPlan().setGroups(Arrays.asList(bothGroup)); + // check that query fetch plan is changed + checkGroups(ASSERTION_FAILED + " testSetGroupsCollection()", + query.getFetchPlan(), bothGroup); + closeFPTest("testSetGroupsCollection()"); + } + + /** */ + public void testSetGroupsArray() { + beginFPTest(); + query.getFetchPlan().setGroups(bothGroup); + // check that query fetch plan is changed + checkGroups(ASSERTION_FAILED + " testSetGroupsArray()", + query.getFetchPlan(), bothGroup); + closeFPTest("testSetGroupsArray()"); + } + + /** */ + public void beginFPTest() { + setUpperLeftGroup(); + pm.currentTransaction().begin(); + query = pm.newQuery(PCRect.class); + extent = pm.getExtent(PCRect.class); + } + + /** + * + * @param location location + */ + public void closeFPTest(String location) { + // check that pm fetch plan is unchanged + checkGroups(ASSERTION_FAILED + " " + location, + pm.getFetchPlan(), upperLeftGroup); + // check that extent fetch plan is unchanged + checkGroups(ASSERTION_FAILED + " " + location, + extent.getFetchPlan(), upperLeftGroup); + pm.currentTransaction().rollback(); + failOnError(); + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanMakeTransient.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanMakeTransient.java index e89988f47..cbad2dcce 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanMakeTransient.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanMakeTransient.java @@ -5,81 +5,91 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.fetchplan; import java.util.Collection; import java.util.HashSet; + +import org.apache.jdo.tck.api.persistencemanager.fetchplan.AbstractFetchPlanTest; + import org.apache.jdo.tck.pc.mylib.PCRect; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test FetchPlanMakeTransient
    - * Keywords: FetchPlan makeTransient
    - * Assertion IDs: Assertion 12.7.1
    - * Assertion Description: If the useFetchPlan parameter is true, the current FetchPlan, - * including MaxFetchDepth, DETACH_LOAD_FIELDS, and DETACH_UNLOAD_FIELDS, is applied to the pc or - * pcs parameter instance(s) to load fields and instances from the datastore. The DetachmentRoots is - * not affected. After the fetch plan is used to load instances, the entire graph of instances - * reachable via loaded fields of the parameter instances is made transient. Transient fields are - * not modified by the method. + *Title: Test FetchPlanMakeTransient + *
    + *Keywords: FetchPlan makeTransient + *
    + *Assertion IDs: Assertion 12.7.1 + *
    + *Assertion Description: +If the useFetchPlan parameter is true, the current FetchPlan, +including MaxFetchDepth, DETACH_LOAD_FIELDS, and DETACH_UNLOAD_FIELDS, +is applied to the pc or pcs parameter instance(s) to load fields +and instances from the datastore. The DetachmentRoots is not affected. +After the fetch plan is used to load instances, the entire graph +of instances reachable via loaded fields of the parameter instances +is made transient. Transient fields are not modified by the method. */ -public class FetchPlanMakeTransient extends AbstractFetchPlanTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion 12.7.1 (FetchPlanMakeTransient) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(FetchPlanMakeTransient.class); - } +public class FetchPlanMakeTransient extends AbstractFetchPlanTest { - /** */ - public void testMakeTransientAllCollection() { - setBothGroup(); - pm.currentTransaction().begin(); - PCRect instance = (PCRect) pm.getObjectById(pcrectoid, false); - Collection instances = new HashSet(); - instances.add(instance); - pm.makeTransientAll(instances, true); - checkBothLoaded(ASSERTION_FAILED, instance); - pm.currentTransaction().commit(); - failOnError(); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion 12.7.1 (FetchPlanMakeTransient) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(FetchPlanMakeTransient.class); + } + + /** */ + public void testMakeTransientAllCollection() { + setBothGroup(); + pm.currentTransaction().begin(); + PCRect instance = (PCRect)pm.getObjectById(pcrectoid, false); + Collection instances = new HashSet(); + instances.add(instance); + pm.makeTransientAll(instances, true); + checkBothLoaded(ASSERTION_FAILED, instance); + pm.currentTransaction().commit(); + failOnError(); + } - /** */ - public void testMakeTransientAllArray() { - setBothGroup(); - pm.currentTransaction().begin(); - PCRect instance = (PCRect) pm.getObjectById(pcrectoid, false); - pm.makeTransientAll(true, new Object[] {instance}); - checkBothLoaded(ASSERTION_FAILED, instance); - pm.currentTransaction().commit(); - failOnError(); - } + /** */ + public void testMakeTransientAllArray() { + setBothGroup(); + pm.currentTransaction().begin(); + PCRect instance = (PCRect)pm.getObjectById(pcrectoid, false); + pm.makeTransientAll(true, new Object[]{instance}); + checkBothLoaded(ASSERTION_FAILED, instance); + pm.currentTransaction().commit(); + failOnError(); + } - /** */ - public void testMakeTransient() { - setBothGroup(); - pm.currentTransaction().begin(); - PCRect instance = (PCRect) pm.getObjectById(pcrectoid, false); - pm.makeTransient(instance, true); - checkBothLoaded(ASSERTION_FAILED, instance); - pm.currentTransaction().commit(); - failOnError(); - } + /** */ + public void testMakeTransient() { + setBothGroup(); + pm.currentTransaction().begin(); + PCRect instance = (PCRect)pm.getObjectById(pcrectoid, false); + pm.makeTransient(instance, true); + checkBothLoaded(ASSERTION_FAILED, instance); + pm.currentTransaction().commit(); + failOnError(); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanQuery.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanQuery.java index 256ef5e8f..5d4b36907 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanQuery.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanQuery.java @@ -5,54 +5,66 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.fetchplan; +import javax.jdo.FetchPlan; import javax.jdo.Query; + +import org.apache.jdo.tck.api.persistencemanager.fetchplan.AbstractFetchPlanTest; + import org.apache.jdo.tck.pc.mylib.PCRect; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test FetchPlanQuery
    - * Keywords: FetchPlan Query
    - * Assertion IDs: Assertion 12.7.1
    - * Assertion Description: 12.7.1 When executing a query the JDO implementation loads the - * fields as specified in the fetch plan associated with the Query instance. + *Title: Test FetchPlanQuery + *
    + *Keywords: FetchPlan Query + *
    + *Assertion IDs: Assertion 12.7.1 + *
    + *Assertion Description: +12.7.1 When executing a query the JDO implementation loads the fields +as specified in the fetch plan associated with the Query instance. */ + public class FetchPlanQuery extends AbstractFetchPlanTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion 12.7.1 (FetchPlanQuery) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(FetchPlanQuery.class); - } - - /** */ - public void testQuery() { - setBothGroup(); - pm.currentTransaction().begin(); - Query query = pm.newQuery(PCRect.class); - checkGroups( - ASSERTION_FAILED + " after newQuery().getFetchPlan()", query.getFetchPlan(), bothGroup); - query.setUnique(true); - PCRect instance = (PCRect) query.execute(); - checkBothLoaded(ASSERTION_FAILED + " after query.execute()", instance); - pm.currentTransaction().commit(); - failOnError(); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion 12.7.1 (FetchPlanQuery) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(FetchPlanQuery.class); + } + + /** */ + public void testQuery() { + setBothGroup(); + pm.currentTransaction().begin(); + Query query = pm.newQuery(PCRect.class); + checkGroups(ASSERTION_FAILED + " after newQuery().getFetchPlan()", + query.getFetchPlan(), bothGroup); + query.setUnique(true); + PCRect instance = (PCRect)query.execute(); + checkBothLoaded(ASSERTION_FAILED + " after query.execute()", instance); + pm.currentTransaction().commit(); + failOnError(); + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanRefresh.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanRefresh.java index 02df883f5..7deeabfbc 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanRefresh.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanRefresh.java @@ -5,77 +5,87 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.fetchplan; import java.util.Collection; import java.util.HashSet; +import org.apache.jdo.tck.api.persistencemanager.fetchplan.AbstractFetchPlanTest; + import org.apache.jdo.tck.pc.mylib.PCRect; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test FetchPlanRefresh
    - * Keywords: FetchPlan getObjectById
    - * Assertion IDs: Assertion 12.7.1
    - * Assertion Description: 12.7.1 For refresh, after clearing fields in the instances, the - * JDO implementation uses the fetch plan to determine which fields to load from the datastore. + *Title: Test FetchPlanRefresh + *
    + *Keywords: FetchPlan getObjectById + *
    + *Assertion IDs: Assertion 12.7.1 + *
    + *Assertion Description: +12.7.1 For refresh, after clearing fields in the instances, +the JDO implementation uses the fetch plan to determine +which fields to load from the datastore. */ -public class FetchPlanRefresh extends AbstractFetchPlanTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion 12.7.1 (FetchPlanRefresh) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(FetchPlanRefresh.class); - } - - /** */ - public void testRefresh() { - setBothGroup(); - pm.currentTransaction().begin(); - PCRect instance = (PCRect) pm.getObjectById(pcrectoid, false); - pm.refresh(instance); - checkBothLoaded(ASSERTION_FAILED, instance); - pm.currentTransaction().commit(); - failOnError(); - } - - /** */ - public void testRefreshAllCollection() { - setBothGroup(); - pm.currentTransaction().begin(); - PCRect instance = (PCRect) pm.getObjectById(pcrectoid, false); - Collection instances = new HashSet(); - instances.add(instance); - pm.refreshAll(instances); - checkBothLoaded(ASSERTION_FAILED, instance); - pm.currentTransaction().commit(); - failOnError(); - } +public class FetchPlanRefresh extends AbstractFetchPlanTest { - /** */ - public void testRefreshAllArray() { - setBothGroup(); - pm.currentTransaction().begin(); - PCRect instance = (PCRect) pm.getObjectById(pcrectoid, false); - Object[] instances = new Object[] {instance}; - pm.refreshAll(instances); - checkBothLoaded(ASSERTION_FAILED, instance); - pm.currentTransaction().commit(); - failOnError(); - } -} + /** */ + private static final String ASSERTION_FAILED = + "Assertion 12.7.1 (FetchPlanRefresh) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(FetchPlanRefresh.class); + } + + /** */ + public void testRefresh() { + setBothGroup(); + pm.currentTransaction().begin(); + PCRect instance = (PCRect)pm.getObjectById(pcrectoid, false); + pm.refresh(instance); + checkBothLoaded(ASSERTION_FAILED, instance); + pm.currentTransaction().commit(); + failOnError(); + } + + /** */ + public void testRefreshAllCollection() { + setBothGroup(); + pm.currentTransaction().begin(); + PCRect instance = (PCRect)pm.getObjectById(pcrectoid, false); + Collection instances = new HashSet(); + instances.add(instance); + pm.refreshAll(instances); + checkBothLoaded(ASSERTION_FAILED, instance); + pm.currentTransaction().commit(); + failOnError(); + } + + /** */ + public void testRefreshAllArray() { + setBothGroup(); + pm.currentTransaction().begin(); + PCRect instance = (PCRect)pm.getObjectById(pcrectoid, false); + Object[] instances = new Object[]{instance}; + pm.refreshAll(instances); + checkBothLoaded(ASSERTION_FAILED, instance); + pm.currentTransaction().commit(); + failOnError(); + } +} \ No newline at end of file diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanRetrieve.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanRetrieve.java index e03a754db..72efb7b0a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanRetrieve.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/fetchplan/FetchPlanRetrieve.java @@ -5,79 +5,88 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.fetchplan; import java.util.Collection; import java.util.HashSet; +import org.apache.jdo.tck.api.persistencemanager.fetchplan.AbstractFetchPlanTest; + import org.apache.jdo.tck.pc.mylib.PCRect; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test FetchPlanRetrieve
    - * Keywords: FetchPlan getObjectById
    - * Assertion IDs: Assertion 12.7.1
    - * Assertion Description: 12.7.1 For retrieve with FGonly true, the implementation uses the - * fetch plan to determine which fields are loaded from the datastore. With FGonly false, the - * implementation reverts to JDO 1 behavior, which loads all fields from the datastore; in this - * case, no related instances are loaded. + *Title: Test FetchPlanRetrieve + *
    + *Keywords: FetchPlan getObjectById + *
    + *Assertion IDs: Assertion 12.7.1 + *
    + *Assertion Description: +12.7.1 For retrieve with FGonly true, the implementation uses the fetch plan to +determine which fields are loaded from the datastore. With FGonly false, the +implementation reverts to JDO 1 behavior, which loads all fields from the +datastore; in this case, no related instances are loaded. */ -public class FetchPlanRetrieve extends AbstractFetchPlanTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion 12.7.1 (FetchPlanRetrieve) failed: "; +public class FetchPlanRetrieve extends AbstractFetchPlanTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(FetchPlanRetrieve.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion 12.7.1 (FetchPlanRetrieve) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(FetchPlanRetrieve.class); + } - /** */ - public void testRetrieve() { - setBothGroup(); - pm.currentTransaction().begin(); - PCRect instance = (PCRect) pm.getObjectById(pcrectoid, false); - pm.retrieve(instance, true); - checkBothLoaded(ASSERTION_FAILED, instance); - pm.currentTransaction().commit(); - failOnError(); - } + /** */ + public void testRetrieve() { + setBothGroup(); + pm.currentTransaction().begin(); + PCRect instance = (PCRect)pm.getObjectById(pcrectoid, false); + pm.retrieve(instance, true); + checkBothLoaded(ASSERTION_FAILED, instance); + pm.currentTransaction().commit(); + failOnError(); + } - /** */ - public void testRetrieveAllCollection() { - setBothGroup(); - pm.currentTransaction().begin(); - PCRect instance = (PCRect) pm.getObjectById(pcrectoid, false); - Collection instances = new HashSet(); - instances.add(instance); - pm.retrieveAll(instances, true); - checkBothLoaded(ASSERTION_FAILED, instance); - pm.currentTransaction().commit(); - failOnError(); - } + /** */ + public void testRetrieveAllCollection() { + setBothGroup(); + pm.currentTransaction().begin(); + PCRect instance = (PCRect)pm.getObjectById(pcrectoid, false); + Collection instances = new HashSet(); + instances.add(instance); + pm.retrieveAll(instances, true); + checkBothLoaded(ASSERTION_FAILED, instance); + pm.currentTransaction().commit(); + failOnError(); + } - /** */ - public void testRetrieveAllArray() { - setBothGroup(); - pm.currentTransaction().begin(); - PCRect instance = (PCRect) pm.getObjectById(pcrectoid, false); - Object[] instances = new Object[] {instance}; - pm.retrieveAll(true, instances); - checkBothLoaded(ASSERTION_FAILED, instance); - pm.currentTransaction().commit(); - failOnError(); - } + /** */ + public void testRetrieveAllArray() { + setBothGroup(); + pm.currentTransaction().begin(); + PCRect instance = (PCRect)pm.getObjectById(pcrectoid, false); + Object[] instances = new Object[]{instance}; + pm.retrieveAll(true, instances); + checkBothLoaded(ASSERTION_FAILED, instance); + pm.currentTransaction().commit(); + failOnError(); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/GetIgnoreCache.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/GetIgnoreCache.java index ff8778503..7c4d832c5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/GetIgnoreCache.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/GetIgnoreCache.java @@ -5,61 +5,72 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.flags; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Get IgnoreCache Value from PersistenceManager
    - * Keywords:
    - * Assertion ID: A12.5.3-1.
    - * Assertion Description: The PersistenceManager.getIgnoreCache method returns the current - * value of the IgnoreCache option. - */ -public class GetIgnoreCache extends PersistenceManagerTest { + *Title: Get IgnoreCache Value from PersistenceManager + *
    + *Keywords: + *
    + *Assertion ID: A12.5.3-1. + *
    + *Assertion Description: + The PersistenceManager.getIgnoreCache method returns the current value of the + IgnoreCache option. - /** */ - private static final String ASSERTION_FAILED = "Assertion A12.5.3-1 (GetIgnoreCache) failed: "; + */ - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetIgnoreCache.class); - } +public class GetIgnoreCache extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.3-1 (GetIgnoreCache) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetIgnoreCache.class); + } - /** */ - public void testGetIgnoreCache() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - PCPoint p1 = new PCPoint(); - tx.begin(); - pm.setIgnoreCache(true); - boolean returnValue = pm.getIgnoreCache(); + /** */ + public void testGetIgnoreCache() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + PCPoint p1 = new PCPoint(); + tx.begin(); + pm.setIgnoreCache(true); + boolean returnValue = pm.getIgnoreCache(); - if (!returnValue) - fail(ASSERTION_FAILED, "pm.getIgnoreCache() returns false after setting the falg to true"); - tx.commit(); - } finally { - if (tx.isActive()) tx.rollback(); + if (!returnValue) + fail(ASSERTION_FAILED, + "pm.getIgnoreCache() returns false after setting the falg to true"); + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + pm.close(); + pm = null; } - pm.close(); - pm = null; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/SetIgnoreCacheToFalse.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/SetIgnoreCacheToFalse.java index 408f0a019..f72f74242 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/SetIgnoreCacheToFalse.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/SetIgnoreCacheToFalse.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,61 +19,69 @@ import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Set IgnoreCache To False
    - * Keywords:cache
    - * Assertion ID: A12.5.3-3.
    - * Assertion Description: The PersistenceManager.setIgnoreCache method called with a value - * of false instructs the query engine that the user expects queries to return results that reflect - * changed values in the cache. - */ -public class SetIgnoreCacheToFalse extends PersistenceManagerTest { + *Title: Set IgnoreCache To False + *
    + *Keywords:cache + *
    + *Assertion ID: A12.5.3-3. + *
    + *Assertion Description: +The PersistenceManager.setIgnoreCache method called with a value of false instructs the +query engine that the user expects queries to return results that reflect changed values in the cache. - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.3-3 (SetIgnoreCacheToFalse) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetIgnoreCacheToFalse.class); - } - - /** */ - public void test() { - pm = getPM(); + */ - runTestSetIgnoreCacheToFalse(pm); +public class SetIgnoreCacheToFalse extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.3-3 (SetIgnoreCacheToFalse) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetIgnoreCacheToFalse.class); + } - pm.close(); - pm = null; - } + /** */ + public void test() { + pm = getPM(); + + runTestSetIgnoreCacheToFalse(pm); + + pm.close(); + pm = null; + } - /** - * @param pm the PersistenceManager - */ - private void runTestSetIgnoreCacheToFalse(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - PCPoint p1 = new PCPoint(); - tx.begin(); - pm.setIgnoreCache(false); - if (pm.getIgnoreCache()) { - fail( - ASSERTION_FAILED, - "pm.getIgnoreCache() should return false after setting the flag to false."); - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * @param pm the PersistenceManager + */ + private void runTestSetIgnoreCacheToFalse(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + PCPoint p1 = new PCPoint(); + tx.begin(); + pm.setIgnoreCache(false); + if (pm.getIgnoreCache()) { + fail(ASSERTION_FAILED, + "pm.getIgnoreCache() should return false after setting the flag to false."); + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/SetIgnoreCacheToTrue.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/SetIgnoreCacheToTrue.java index 2098b8c76..cb442965d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/SetIgnoreCacheToTrue.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/SetIgnoreCacheToTrue.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,62 +19,70 @@ import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Set IgnoreCache To True
    - * Keywords:cache
    - * Assertion ID: A12.5.3-2.
    - * Assertion Description: The PersistenceManager.setIgnoreCache method called with a value - * of true is a hint to the query engine that the user expects queries to be optimized to return - * approximate results by ignoring changed values in the cache. This is not testable, except to see - * whether the get/set works. - */ -public class SetIgnoreCacheToTrue extends PersistenceManagerTest { + *Title: Set IgnoreCache To True + *
    + *Keywords:cache + *
    + *Assertion ID: A12.5.3-2. + *
    + *Assertion Description: +The PersistenceManager.setIgnoreCache method called with a value of true is a hint to the +query engine that the user expects queries to be optimized to return approximate results by ignoring changed values in the +cache. This is not testable, except to see whether the get/set works. - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.3-2 (SetIgnoreCacheToTrue) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetIgnoreCacheToTrue.class); - } - - /** */ - public void test() { - pm = getPM(); + */ - runTestSetIgnoreCacheToTrue(pm); +public class SetIgnoreCacheToTrue extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.3-2 (SetIgnoreCacheToTrue) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetIgnoreCacheToTrue.class); + } - pm.close(); - pm = null; - } + /** */ + public void test() { + pm = getPM(); + + runTestSetIgnoreCacheToTrue(pm); + + pm.close(); + pm = null; + } - /** - * @param pm the PersistenceManager - */ - public void runTestSetIgnoreCacheToTrue(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - PCPoint p1 = new PCPoint(); - tx.begin(); - pm.setIgnoreCache(true); - if (!pm.getIgnoreCache()) { - fail( - ASSERTION_FAILED, - "pm.getIgnoreCache() should return true after setting the flag to true."); - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * @param pm the PersistenceManager + */ + public void runTestSetIgnoreCacheToTrue(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + PCPoint p1 = new PCPoint(); + tx.begin(); + pm.setIgnoreCache(true); + if (!pm.getIgnoreCache()) { + fail(ASSERTION_FAILED, + "pm.getIgnoreCache() should return true after setting the flag to true."); + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/SetMultithreadedFalse.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/SetMultithreadedFalse.java index 4a9fa1fa2..dd9aeccfc 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/SetMultithreadedFalse.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/SetMultithreadedFalse.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,60 +19,68 @@ import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Set Multithreaded False
    - * Keywords: multithreaded
    - * Assertion ID: A12.7-2.
    - * Assertion Description: If PersistenceManager.setMultithreaded is called with a value of - * false, a value of false will be returned when getMultithreaded is called. - */ -public class SetMultithreadedFalse extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.7-2 (SetMultithreadedFalse) failed: "; + *Title: Set Multithreaded False + *
    + *Keywords: multithreaded + *
    + *Assertion ID: A12.7-2. + *
    + *Assertion Description: +If PersistenceManager.setMultithreaded is called with a value of false, a value of false +will be returned when getMultithreaded is called. - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetMultithreadedFalse.class); - } - - /** */ - public void test() { - pm = getPM(); + */ - runTestSetMultithreadedFalse(pm); +public class SetMultithreadedFalse extends PersistenceManagerTest{ + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.7-2 (SetMultithreadedFalse) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetMultithreadedFalse.class); + } - pm.close(); - pm = null; - } + /** */ + public void test() { + pm = getPM(); + + runTestSetMultithreadedFalse(pm); + + pm.close(); + pm = null; + } - /** - * @param pm the PersistenceManager - */ - private void runTestSetMultithreadedFalse(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - PCPoint p1 = new PCPoint(); - tx.begin(); - pm.setMultithreaded(false); - if (pm.getMultithreaded()) { - fail( - ASSERTION_FAILED, - "pm.getMultithreaded() should false true after setting the flag to false."); - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * @param pm the PersistenceManager + */ + private void runTestSetMultithreadedFalse(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + PCPoint p1 = new PCPoint(); + tx.begin(); + pm.setMultithreaded(false); + if (pm.getMultithreaded()) { + fail(ASSERTION_FAILED, + "pm.getMultithreaded() should false true after setting the flag to false."); + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/SetMultithreadedTrue.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/SetMultithreadedTrue.java index 043e8592b..f365e53e5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/SetMultithreadedTrue.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/SetMultithreadedTrue.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,60 +19,67 @@ import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Set Multithreaded True
    - * Keywords: multithreaded
    - * Assertion ID: A12.7-1.
    - * Assertion Description: If PersistenceManager.setMultithreaded is called with a value of - * true, then the JDO implementation must perform synchronizations to support multiple application - * threads. A value of true will be returned when getMultithreaded is called. In testing, - * multi-threading should be turned on and then multi-threading tests should be run. + *Title: Set Multithreaded True + *
    + *Keywords: multithreaded + *
    + *Assertion ID: A12.7-1. + *
    + *Assertion Description: +If PersistenceManager.setMultithreaded is called with a value of true, then the JDO +implementation must perform synchronizations to support multiple application threads. A value of true will be returned +when getMultithreaded is called. In testing, multi-threading should be turned on and then multi-threading tests should +be run. */ -public class SetMultithreadedTrue extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.7-1 (SetMultithreadedTrue) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetMultithreadedTrue.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTestSetMultithreadedTrue(pm); +public class SetMultithreadedTrue extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.7-1 (SetMultithreadedTrue) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetMultithreadedTrue.class); + } - pm.close(); - pm = null; - } + /** */ + public void test() { + pm = getPM(); + + runTestSetMultithreadedTrue(pm); + + pm.close(); + pm = null; + } - /** - * @param pm the PersistenceManager - */ - public void runTestSetMultithreadedTrue(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - pm.setMultithreaded(true); - if (!pm.getMultithreaded()) { - fail( - ASSERTION_FAILED, - "pm.getMultithreaded() should true true after setting the flag to true."); - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * @param pm the PersistenceManager + */ + public void runTestSetMultithreadedTrue(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + pm.setMultithreaded(true); + if (!pm.getMultithreaded()) { + fail(ASSERTION_FAILED, + "pm.getMultithreaded() should true true after setting the flag to true."); + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/SettingFlagsWithTransactionInstance.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/SettingFlagsWithTransactionInstance.java index f17806448..9df12d454 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/SettingFlagsWithTransactionInstance.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/flags/SettingFlagsWithTransactionInstance.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,48 +19,55 @@ import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Setting Flags With Transaction instance
    - * Keywords:
    - * Assertion ID: A12.5.2-3.
    - * Assertion Description: Even if the Transaction instance returned by - * PersistenceManager.currentTransaction cannot be used for transaction completion (due to external - * transaction management), it still can be used to set flags. - */ -public class SettingFlagsWithTransactionInstance extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.2-3 (SettingFlagsWithTransactionInstance) failed: "; + *Title: Setting Flags With Transaction instance + *
    + *Keywords: + *
    + *Assertion ID: A12.5.2-3. + *
    + *Assertion Description: +Even if the Transaction instance returned by PersistenceManager.currentTransaction +cannot be used for transaction completion (due to external transaction management), it still can be used to set flags. - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SettingFlagsWithTransactionInstance.class); - } + */ - /** */ - public void test() { - pm = getPM(); +public class SettingFlagsWithTransactionInstance extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.2-3 (SettingFlagsWithTransactionInstance) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SettingFlagsWithTransactionInstance.class); + } - runTestSettingFlagsWithTransactionInstance(pm); + /** */ + public void test() { + pm = getPM(); + + runTestSettingFlagsWithTransactionInstance(pm); + + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } - /** */ - private void runTestSettingFlagsWithTransactionInstance(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - tx.setNontransactionalRead(false); - tx.setNontransactionalWrite(false); - tx.setRetainValues(false); - tx.setOptimistic(false); - } + /** */ + private void runTestSettingFlagsWithTransactionInstance(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + tx.setNontransactionalRead(false); + tx.setNontransactionalWrite(false); + tx.setRetainValues(false); + tx.setOptimistic(false); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectById.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectById.java index f3b107a77..32dc85887 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectById.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectById.java @@ -5,128 +5,138 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.getobject; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Get Object By Id
    - * Keywords: identity cache
    - * Assertion ID: A12.5.6-9.
    - * Assertion Description: If PersistenceManager.getObjectById is called with a - * value of true for the second parameter named validate, and there is not - * an instance already in the cache with the same JDO identity as the oid parameter, then this - * method creates an instance with the specified JDO identity, verifies that it exists in the data - * store, and returns it. - * - *
      - *
    1. If there is no transaction in progress, the returned instance will be hollow or - * persistent-nontransactional, at the choice of the implementation. - *
    2. If there is a data store transaction in progress, the returned instance will be - * persistent-clean. - *
    3. If there is an optimistic transaction in progress, the returned instance will be - * persistent-nontransactional. - *
    - */ -public class GetObjectById extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A12.5.6-9 (GetObjectById) failed: "; + *Title: Get Object By Id + *
    + *Keywords: identity cache + *
    + *Assertion ID: A12.5.6-9. + *
    + *Assertion Description: + If PersistenceManager.getObjectById is called with a value of + true for the second parameter named validate, + and there is not an instance already in the cache with the same JDO identity + as the oid parameter, then this method creates an instance with the specified + JDO identity, verifies that it exists in the data store, and returns it. +
      +
    1. If there is no transaction in progress, the returned instance will be + hollow or persistent-nontransactional, at the choice of the implementation.
    2. +
    3. If there is a data store transaction in progress, + the returned instance will be persistent-clean.
    4. +
    5. If there is an optimistic transaction in progress, + the returned instance will be persistent-nontransactional.
    6. +
    - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectById.class); - } - - /** */ - public void testGetObjectById() { - if (debug) logger.debug("\nSTART GetObjectById"); + */ - Transaction tx = null; - try { - pm = getPM(); - Object oid = createPCPointInstance(pm); - if (pm != null) { - pm.close(); - pm = null; // make sure to get a different pm so obj is not in cache - } +public class GetObjectById extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.6-9 (GetObjectById) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectById.class); + } - Object obj = null; - int state = 0; + /** */ + public void testGetObjectById() { + if (debug) logger.debug ("\nSTART GetObjectById"); - // nontransactional access - if (isNontransactionalReadSupported()) { - if (debug) logger.debug("nontransactional"); - pm = getPM(); - tx = pm.currentTransaction(); - tx.setNontransactionalRead(true); - obj = pm.getObjectById(oid, true); - state = currentState(obj); - if (state != PERSISTENT_NONTRANSACTIONAL && state != HOLLOW) { - fail( - ASSERTION_FAILED, - "Expected persistent-nontransactional or hollow; got " + getStateOfInstance(obj)); + Transaction tx = null; + try { + pm = getPM(); + Object oid = createPCPointInstance(pm); + if (pm != null) { + pm.close(); + pm = null; // make sure to get a different pm so obj is not in cache + } + + Object obj = null; + int state = 0; + + // nontransactional access + if (isNontransactionalReadSupported()) { + if (debug) logger.debug("nontransactional"); + pm = getPM(); + tx = pm.currentTransaction(); + tx.setNontransactionalRead(true); + obj = pm.getObjectById(oid, true); + state = currentState (obj); + if (state != PERSISTENT_NONTRANSACTIONAL && state != HOLLOW) { + fail(ASSERTION_FAILED, + "Expected persistent-nontransactional or hollow; got " + + getStateOfInstance(obj)); + } + tx = null; + pm.close(); + pm = null; // make sure to get a different pm so obj is not in cache + } + + // pessimistic transactional access + if (debug) logger.debug("pessimistic"); + pm = getPM(); + tx = pm.currentTransaction(); + tx.setOptimistic(false); + tx.begin(); + obj = pm.getObjectById(oid, true); + state = currentState (obj); + tx.commit(); + tx = null; + if (state != PERSISTENT_CLEAN) { + fail(ASSERTION_FAILED, + "Expected persistent-clean; got " + getStateOfInstance(obj)); + } + pm.close(); + pm = null; // make sure to get a different pm so obj is not in cache + + // optimistic transactional access + if (isOptimisticSupported()) { + if (debug) logger.debug("optimistic"); + pm = getPM(); + tx = pm.currentTransaction(); + tx.setOptimistic(true); + tx.begin(); + obj = pm.getObjectById(oid, true); + state = currentState (obj); + tx.commit(); + if (state != PERSISTENT_NONTRANSACTIONAL & state != HOLLOW) { + fail(ASSERTION_FAILED, + "Expected persistent-nontransactional; got " + getStateOfInstance(obj)); + } + tx = null; + pm.close(); + pm = null; // make sure to get a different pm so obj is not in cache + } } - tx = null; - pm.close(); - pm = null; // make sure to get a different pm so obj is not in cache - } - - // pessimistic transactional access - if (debug) logger.debug("pessimistic"); - pm = getPM(); - tx = pm.currentTransaction(); - tx.setOptimistic(false); - tx.begin(); - obj = pm.getObjectById(oid, true); - state = currentState(obj); - tx.commit(); - tx = null; - if (state != PERSISTENT_CLEAN) { - fail(ASSERTION_FAILED, "Expected persistent-clean; got " + getStateOfInstance(obj)); - } - pm.close(); - pm = null; // make sure to get a different pm so obj is not in cache + finally { + if (debug) logger.debug ("END GetObjectById"); - // optimistic transactional access - if (isOptimisticSupported()) { - if (debug) logger.debug("optimistic"); - pm = getPM(); - tx = pm.currentTransaction(); - tx.setOptimistic(true); - tx.begin(); - obj = pm.getObjectById(oid, true); - state = currentState(obj); - tx.commit(); - if (state != PERSISTENT_NONTRANSACTIONAL & state != HOLLOW) { - fail( - ASSERTION_FAILED, - "Expected persistent-nontransactional; got " + getStateOfInstance(obj)); + if ((tx != null) && tx.isActive()) + tx.rollback(); } - tx = null; - pm.close(); - pm = null; // make sure to get a different pm so obj is not in cache - } - } finally { - if (debug) logger.debug("END GetObjectById"); - - if ((tx != null) && tx.isActive()) tx.rollback(); } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdExactClass.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdExactClass.java index fb49135d3..6b0e3ebbf 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdExactClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdExactClass.java @@ -5,260 +5,277 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.getobject; import java.util.Date; -import javax.jdo.JDOException; import javax.jdo.Transaction; +import javax.jdo.JDOException; + import javax.jdo.identity.LongIdentity; + +import org.apache.jdo.tck.util.BatchTestRunner; import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +import org.apache.jdo.tck.pc.singlefieldidentity.Person; import org.apache.jdo.tck.pc.singlefieldidentity.Employee; -import org.apache.jdo.tck.pc.singlefieldidentity.FullTimeEmployee; import org.apache.jdo.tck.pc.singlefieldidentity.PartTimeEmployee; -import org.apache.jdo.tck.pc.singlefieldidentity.Person; -import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.pc.singlefieldidentity.FullTimeEmployee; /** - * Title: Get Object By Id
    - * Keywords: identity cache
    - * Assertion ID: A12.5.6-2.
    - * Assertion Description: If the validate flag is false, the user asserts that the instance - * exists and the object id represents the exact class of the persistent instance (specifically not - * a subclass or an interface). If the class is abstract, throw JDOUserException (we cannot - * construct a hollow instance of an abstract class). If the class is actually not correct, an - * exception with an error message will be thrown later if any field other than the identity field - * id accessed. + *Title: Get Object By Id + *
    + *Keywords: identity cache + *
    + *Assertion ID: A12.5.6-2. + *
    + *Assertion Description: + * If the validate flag is false, the user asserts that the instance exists + * and the object id represents the exact class of the persistent instance + * (specifically not a subclass or an interface). + * If the class is abstract, throw JDOUserException (we cannot construct + * a hollow instance of an abstract class). + * If the class is actually not correct, an exception with an + * error message will be thrown later if any field other than the identity + * field id accessed. */ -public class GetObjectByIdExactClass extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A12.5.6-2 (GetObjectById) failed: "; - - /** */ - private LongIdentity oid; +public class GetObjectByIdExactClass extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.6-2 (GetObjectById) failed: "; - /** */ - private long id; + /** */ + private LongIdentity oid; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectByIdExactClass.class); - } + /** */ + private long id; - @Override - public void localSetUp() { - if (!runsWithApplicationIdentity()) { - printNonApplicableIdentityType("GetObjectIdExactClass", APPLICATION_IDENTITY); - return; + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectByIdExactClass.class); } - pm = getPM(); - pm.currentTransaction().begin(); - // create an instance of FullTimeEmployee. - FullTimeEmployee instance = new FullTimeEmployee(); - instance.setPersonid(1000000L); - instance.setFirstname("Full"); - instance.setLastname("Timer"); - instance.setBirthdate(new Date()); - pm.makePersistent(instance); - pm.currentTransaction().commit(); - oid = (LongIdentity) pm.getObjectId(instance); - id = oid.getKey(); - pm.close(); - pm = null; - addTearDownClass(FullTimeEmployee.class); - } - /** */ - public void testAbstractSuperclassExact() { - if (!runsWithApplicationIdentity()) return; - Transaction tx = null; - try { - pm = getPM(); - pm.currentTransaction().begin(); - // create the oid - Object abstractOid = new LongIdentity(Employee.class, id); - pm.getObjectById(abstractOid, false); - appendMessage( - ASSERTION_FAILED + "getObjectById exact " + "for abstract superclass must fail."); - } catch (JDOException ex) { - // good catch - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + @Override + public void localSetUp() { + if (!runsWithApplicationIdentity()) { + printNonApplicableIdentityType( + "GetObjectIdExactClass", + APPLICATION_IDENTITY); + return; + } + pm = getPM(); + pm.currentTransaction().begin(); + // create an instance of FullTimeEmployee. + FullTimeEmployee instance = new FullTimeEmployee(); + instance.setPersonid(1000000L); + instance.setFirstname("Full"); + instance.setLastname("Timer"); + instance.setBirthdate(new Date()); + pm.makePersistent(instance); + pm.currentTransaction().commit(); + oid = (LongIdentity)pm.getObjectId(instance); + id = oid.getKey(); + pm.close(); + pm = null; + addTearDownClass(FullTimeEmployee.class); } - failOnError(); - } - /** */ - public void testAbstractSuperclassNotExact() { - if (!runsWithApplicationIdentity()) return; - Transaction tx = null; - try { - pm = getPM(); - pm.currentTransaction().begin(); - // create the oid - Object abstractOid = new LongIdentity(Employee.class, id); - Object abstractInstance = pm.getObjectById(abstractOid, true); - if (abstractInstance.getClass() != FullTimeEmployee.class) { - appendMessage( - ASSERTION_FAILED - + "getObjectById not exact " - + "for abstract superclass returned wrong type " - + abstractInstance.getClass().getName()); - } - } catch (JDOException ex) { - appendMessage( - ASSERTION_FAILED - + "getObjectById not exact " - + "for abstract superclass threw exception " - + ex.getMessage()); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + public void testAbstractSuperclassExact() { + if (!runsWithApplicationIdentity()) return; + Transaction tx = null; + try { + pm = getPM(); + pm.currentTransaction().begin(); + // create the oid + Object abstractOid = new LongIdentity(Employee.class, id); + pm.getObjectById(abstractOid, false); + appendMessage(ASSERTION_FAILED + "getObjectById exact " + + "for abstract superclass must fail."); + } catch (JDOException ex) { + // good catch + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + failOnError(); } - failOnError(); - } - /** */ - public void testConcreteSuperclassExact() { - if (!runsWithApplicationIdentity()) return; - Transaction tx = null; - Person instance = null; - try { - pm = getPM(); - pm.currentTransaction().begin(); - // create the oid - Object superclassOid = new LongIdentity(Person.class, id); - instance = (Person) pm.getObjectById(superclassOid, false); - if (instance.getClass() != Person.class) { - appendMessage( - ASSERTION_FAILED - + "getObjectById exact for " - + "concrete superclass should return " - + "Person.class but returned wrong type " - + instance.getClass().getName()); - } - } catch (Exception ex) { - appendMessage( - ASSERTION_FAILED - + "getObjectById exact for " - + "concrete superclass must succeed before accessing database."); + /** */ + public void testAbstractSuperclassNotExact() { + if (!runsWithApplicationIdentity()) return; + Transaction tx = null; + try { + pm = getPM(); + pm.currentTransaction().begin(); + // create the oid + Object abstractOid = new LongIdentity(Employee.class, id); + Object abstractInstance = pm.getObjectById(abstractOid, true); + if (abstractInstance.getClass() != FullTimeEmployee.class) { + appendMessage(ASSERTION_FAILED + "getObjectById not exact " + + "for abstract superclass returned wrong type " + + abstractInstance.getClass().getName()); + } + } catch (JDOException ex) { + appendMessage(ASSERTION_FAILED + "getObjectById not exact " + + "for abstract superclass threw exception " + + ex.getMessage()); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + failOnError(); } - try { - instance.toString(); // accesses non-key fields - appendMessage( - ASSERTION_FAILED - + "getObjectById exact for " - + "concrete superclass must fail when accessing database."); - } catch (JDOException ex) { - // good catch - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void testConcreteSuperclassExact() { + if (!runsWithApplicationIdentity()) return; + Transaction tx = null; + Person instance = null; + try { + pm = getPM(); + pm.currentTransaction().begin(); + // create the oid + Object superclassOid = new LongIdentity(Person.class, id); + instance = (Person)pm.getObjectById(superclassOid, false); + if (instance.getClass() != Person.class) { + appendMessage(ASSERTION_FAILED + "getObjectById exact for " + + "concrete superclass should return " + + "Person.class but returned wrong type " + + instance.getClass().getName()); + } + } catch (Exception ex) { + appendMessage(ASSERTION_FAILED + "getObjectById exact for " + + "concrete superclass must succeed before accessing database."); + } + try { + instance.toString(); // accesses non-key fields + appendMessage(ASSERTION_FAILED + "getObjectById exact for " + + "concrete superclass must fail when accessing database."); + } catch (JDOException ex) { + // good catch + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + failOnError(); } - failOnError(); - } - /** */ - public void testConcreteSuperclassNotExact() { - if (!runsWithApplicationIdentity()) return; - Transaction tx = null; - try { - pm = getPM(); - pm.currentTransaction().begin(); - // create the oid - Object superclassOid = new LongIdentity(Person.class, id); - Object instance = pm.getObjectById(superclassOid, true); - if (instance.getClass() != FullTimeEmployee.class) { - appendMessage( - ASSERTION_FAILED - + "getObjectById not exact for " - + "concrete superclass should return FullTimeEmployee " - + "but returned wrong type " - + instance.getClass().getName()); - } - } catch (JDOException ex) { - appendMessage( - ASSERTION_FAILED - + " getObjectById not exact for " - + "concrete superclass must succeed but threw " - + ex.getMessage()); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + public void testConcreteSuperclassNotExact() { + if (!runsWithApplicationIdentity()) return; + Transaction tx = null; + try { + pm = getPM(); + pm.currentTransaction().begin(); + // create the oid + Object superclassOid = new LongIdentity(Person.class, id); + Object instance = pm.getObjectById(superclassOid, true); + if (instance.getClass() != FullTimeEmployee.class) { + appendMessage(ASSERTION_FAILED + "getObjectById not exact for " + + "concrete superclass should return FullTimeEmployee " + + "but returned wrong type " + + instance.getClass().getName()); + } + } catch (JDOException ex) { + appendMessage(ASSERTION_FAILED + " getObjectById not exact for " + + "concrete superclass must succeed but threw " + + ex.getMessage()); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + failOnError(); } - failOnError(); - } - /** */ - public void testWrongClass() { - if (!runsWithApplicationIdentity()) return; - Transaction tx = null; - try { - pm = getPM(); - pm.currentTransaction().begin(); - // create the oid - Object wrongOid = new LongIdentity(PartTimeEmployee.class, id); - PartTimeEmployee wrongInstance = (PartTimeEmployee) pm.getObjectById(wrongOid, false); - wrongInstance.toString(); - appendMessage( - ASSERTION_FAILED - + " getObjectById exact " - + "for wrong class must throw JDOUserException."); - } catch (JDOException ex) { - // good catch - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + public void testWrongClass() { + if (!runsWithApplicationIdentity()) return; + Transaction tx = null; + try { + pm = getPM(); + pm.currentTransaction().begin(); + // create the oid + Object wrongOid = new LongIdentity(PartTimeEmployee.class, id); + PartTimeEmployee wrongInstance = + (PartTimeEmployee)pm.getObjectById(wrongOid, false); + wrongInstance.toString(); + appendMessage(ASSERTION_FAILED + " getObjectById exact " + + "for wrong class must throw JDOUserException."); + } catch (JDOException ex) { + // good catch + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + failOnError(); } - failOnError(); - } - /** */ - public void testRightClassNotExact() { - if (!runsWithApplicationIdentity()) return; - Transaction tx = null; - try { - pm = getPM(); - pm.currentTransaction().begin(); - // create the oid - Object rightOid = new LongIdentity(FullTimeEmployee.class, id); - FullTimeEmployee rightInstance = (FullTimeEmployee) pm.getObjectById(rightOid, true); - rightInstance.toString(); - } catch (JDOException ex) { - appendMessage( - ASSERTION_FAILED + " getObjectById not exact " + "for right class must succeed."); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + public void testRightClassNotExact() { + if (!runsWithApplicationIdentity()) return; + Transaction tx = null; + try { + pm = getPM(); + pm.currentTransaction().begin(); + // create the oid + Object rightOid = new LongIdentity(FullTimeEmployee.class, id); + FullTimeEmployee rightInstance = + (FullTimeEmployee)pm.getObjectById(rightOid, true); + rightInstance.toString(); + } catch (JDOException ex) { + appendMessage(ASSERTION_FAILED + " getObjectById not exact " + + "for right class must succeed."); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + failOnError(); } - failOnError(); - } - /** */ - public void testRightClassExact() { - if (!runsWithApplicationIdentity()) return; - Transaction tx = null; - try { - pm = getPM(); - pm.currentTransaction().begin(); - // create the oid - Object rightOid = new LongIdentity(FullTimeEmployee.class, id); - FullTimeEmployee rightInstance = (FullTimeEmployee) pm.getObjectById(rightOid, false); - rightInstance.toString(); - } catch (JDOException ex) { - appendMessage(ASSERTION_FAILED + " getObjectById exact " + "for right class must succeed."); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + public void testRightClassExact() { + if (!runsWithApplicationIdentity()) return; + Transaction tx = null; + try { + pm = getPM(); + pm.currentTransaction().begin(); + // create the oid + Object rightOid = new LongIdentity(FullTimeEmployee.class, id); + FullTimeEmployee rightInstance = + (FullTimeEmployee)pm.getObjectById(rightOid, false); + rightInstance.toString(); + } catch (JDOException ex) { + appendMessage(ASSERTION_FAILED + " getObjectById exact " + + "for right class must succeed."); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + failOnError(); } - failOnError(); - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationInstanceInCache.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationInstanceInCache.java index 9d8f65b85..341061142 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationInstanceInCache.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationInstanceInCache.java @@ -5,73 +5,82 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.getobject; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Get Object By Id No Validation, Instance In Cache
    - * Keywords: identity cache
    - * Assertion IDs: A12.5.6-2
    - * Assertion Description: If PersistenceManager.getObjectById is called with a value of - * false for the second parameter named validate, and there is already an instance in the cache with - * the same JDO identity as the oid parameter, then this method returns it. + *Title: Get Object By Id No Validation, Instance In Cache + *
    + *Keywords: identity cache + *
    + *Assertion IDs: A12.5.6-2 + *
    + *Assertion Description: +If PersistenceManager.getObjectById is called with a value of false +for the second parameter named validate, and there is already an instance in the cache with the +same JDO identity as the oid parameter, then this method returns it. + */ -public class GetObjectByIdNoValidationInstanceInCache extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.6-2 (GetObjectByIdNoValidationInstanceInCache) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectByIdNoValidationInstanceInCache.class); - } +public class GetObjectByIdNoValidationInstanceInCache extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.6-2 (GetObjectByIdNoValidationInstanceInCache) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectByIdNoValidationInstanceInCache.class); + } - /** */ - public void testGetObjectByIdNoValidationInstanceInCache() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); + /** */ + public void testGetObjectByIdNoValidationInstanceInCache() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - int curr = currentState(p1); + PCPoint p1 = new PCPoint (1,3); + pm.makePersistent(p1); + int curr = currentState(p1); - Object oid = pm.getObjectId(p1); - tx.commit(); + Object oid = pm.getObjectId(p1); + tx.commit(); - tx.begin(); - Object obj = pm.getObjectById(oid, false); + tx.begin(); + Object obj = pm.getObjectById(oid, false); - if (p1 != obj) - fail( - ASSERTION_FAILED, - "pm.getObjectById(oid, false) should find existing instance in pm cache"); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + if (p1 != obj) + fail(ASSERTION_FAILED, + "pm.getObjectById(oid, false) should find existing instance in pm cache"); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm = null; } - pm.close(); - pm = null; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationInstanceInCacheNoStateChange.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationInstanceInCacheNoStateChange.java index 4ce3d93d8..b26f2861e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationInstanceInCacheNoStateChange.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationInstanceInCacheNoStateChange.java @@ -5,76 +5,81 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.getobject; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Get Object By Id No Validation, Instance In Cache, No State Change
    - * Keywords: identity cache lifecycle
    - * Assertion IDs: A12.5.6-3
    - * Assertion Description: If PersistenceManager.getObjectById is called with a value of - * false for the second parameter named validate, and there is already an instance in the cache with - * the same JDO identity as the oid parameter, there is no change made to the state of the returned - * instance. + *Title: Get Object By Id No Validation, Instance In Cache, No State Change + *
    + *Keywords: identity cache lifecycle + *
    + *Assertion IDs: A12.5.6-3 + *
    + *Assertion Description: +If PersistenceManager.getObjectById is called with a value of false for the second parameter named validate, and there is already an instance in the cache with the same JDO identity as the oid parameter, there is no change made to the state of the returned instance. */ -public class GetObjectByIdNoValidationInstanceInCacheNoStateChange extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.6-3 (GetObjectByIdNoValidationInstanceInCacheNoStateChange) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectByIdNoValidationInstanceInCacheNoStateChange.class); - } - - /** */ - public void testGetObjectByIdNoValidationInstanceInCacheNoStateChange() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); +public class GetObjectByIdNoValidationInstanceInCacheNoStateChange extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.6-3 (GetObjectByIdNoValidationInstanceInCacheNoStateChange) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectByIdNoValidationInstanceInCacheNoStateChange.class); + } - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - Object oid = pm.getObjectId(p1); - tx.commit(); - int curr = currentState(p1); + /** */ + public void testGetObjectByIdNoValidationInstanceInCacheNoStateChange() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + PCPoint p1 = new PCPoint (1,3); + pm.makePersistent(p1); + Object oid = pm.getObjectId(p1); + tx.commit(); + int curr = currentState(p1); - tx.begin(); - Object obj = pm.getObjectById(oid, false); + tx.begin(); + Object obj = pm.getObjectById (oid, false); - int actualState = currentState(obj); + int actualState = currentState(obj); - if (actualState != curr) { - fail( - ASSERTION_FAILED, - "State mismatched - Expected state: " + curr + " Actual state: " + actualState); - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + if (actualState != curr) { + fail(ASSERTION_FAILED, + "State mismatched - Expected state: " + + curr + " Actual state: " + actualState); + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm = null; } - pm.close(); - pm = null; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationInstanceNotInCache.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationInstanceNotInCache.java index 5fb8b6758..abac27e38 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationInstanceNotInCache.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationInstanceNotInCache.java @@ -5,76 +5,85 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.getobject; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Get Object By Id No Validation Instance Not In Cache
    - * Keywords: identity cache
    - * Assertion IDs: A12.5.6-5
    - * Assertion Description: If PersistenceManager.getObjectById is called with a value of - * false for the second parameter named validate, and there is not an instance already in the cache - * with the same JDO identity as the oid parameter, and there is a transaction in progress, then - * this method creates an instance with the specified JDO identity and returns it with a state of - * hollow, persistent-nontransactional, or persistent-clean, at the choice of the implementation. + *Title: Get Object By Id No Validation Instance Not In Cache + *
    + *Keywords: identity cache + *
    + *Assertion IDs: A12.5.6-5 + *
    + *Assertion Description: +If PersistenceManager.getObjectById is called with a value of false for the second parameter named validate, and there is not an instance already in the cache with the same JDO identity as the oid parameter, and there is a transaction in progress, then this method creates an instance with the specified JDO identity and returns it with a state of hollow, persistent-nontransactional, or persistent-clean, at the choice of the implementation. */ -public class GetObjectByIdNoValidationInstanceNotInCache extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.6-5 (GetObjectByIdNoValidationInstanceNotInCache) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectByIdNoValidationInstanceNotInCache.class); - } +public class GetObjectByIdNoValidationInstanceNotInCache extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.6-5 (GetObjectByIdNoValidationInstanceNotInCache) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectByIdNoValidationInstanceNotInCache.class); + } - /** */ - public void testGetObjectByIdNoValidationInstanceNotInCache() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); + /** */ + public void testGetObjectByIdNoValidationInstanceNotInCache() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - Object oid = pm.getObjectId(p1); - pm.evict(p1); - tx.commit(); + PCPoint p1 = new PCPoint (1,3); + pm.makePersistent(p1); + Object oid = pm.getObjectId(p1); + pm.evict(p1); + tx.commit(); - tx.begin(); - Object obj = pm.getObjectById(oid, false); + tx.begin(); + Object obj = pm.getObjectById (oid, false); - int curr = currentState(obj); - if (curr == HOLLOW || curr == PERSISTENT_NONTRANSACTIONAL || curr == PERSISTENT_CLEAN) { - ; // expected result - } else { - fail(ASSERTION_FAILED, "returned state mismatched - " + " Actual state " + curr); - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + int curr = currentState(obj); + if ( curr == HOLLOW || + curr == PERSISTENT_NONTRANSACTIONAL || + curr == PERSISTENT_CLEAN ) { + ; // expected result + } + else { + fail(ASSERTION_FAILED, + "returned state mismatched - " + + " Actual state " + curr); + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm = null; } - pm.close(); - pm = null; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationInstanceNotInCacheNoTx.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationInstanceNotInCacheNoTx.java index 9fa69e90e..0864f371a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationInstanceNotInCacheNoTx.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationInstanceNotInCacheNoTx.java @@ -5,76 +5,86 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.getobject; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Get Object By Id No Validation Instance Not In Cache, No Tx
    - * Keywords: identity cache
    - * Assertion IDs: A12.5.6-4
    - * Assertion Description: If PersistenceManager.getObjectById is called with a value of - * false for the second parameter named validate, and there is not an instance already in the cache - * with the same JDO identity as the oid parameter, and there is no transaction in progress, then - * this method creates an instance with the specified JDO identity and returns it with a state of - * hollow or persistent-nontransactional, at the choice of the implementation. + *Title: Get Object By Id No Validation Instance Not In Cache, No Tx + *
    + *Keywords: identity cache + *
    + *Assertion IDs: A12.5.6-4 + *
    + *Assertion Description: +If PersistenceManager.getObjectById is called with a value of false for the +second parameter named validate, and there is not an instance already in the cache with the same JDO identity as the oid parameter, and there is no transaction in progress, then this method creates an instance with the specified JDO identity and returns it with a state of hollow or persistent-nontransactional, at the choice of the implementation. */ -public class GetObjectByIdNoValidationInstanceNotInCacheNoTx extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.6-4 (GetObjectByIdNoValidationInstanceNotInCacheNoTx) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectByIdNoValidationInstanceNotInCacheNoTx.class); - } +public class GetObjectByIdNoValidationInstanceNotInCacheNoTx extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.6-4 (GetObjectByIdNoValidationInstanceNotInCacheNoTx) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectByIdNoValidationInstanceNotInCacheNoTx.class); + } - /** */ - public void testGetObjectByIdNoValidationInstanceNotInCacheNoTx() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); + /** */ + public void testGetObjectByIdNoValidationInstanceNotInCacheNoTx() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - Object oid = pm.getObjectId(p1); - pm.evict(p1); - tx.commit(); + PCPoint p1 = new PCPoint (1,3); + pm.makePersistent(p1); + Object oid = pm.getObjectId(p1); + pm.evict(p1); + tx.commit(); - /* get oid for p1, no transaction in progress */ - Object obj = pm.getObjectById(oid, false); + /* get oid for p1, no transaction in progress */ + Object obj = pm.getObjectById (oid, false); - int curr = currentState(p1); + int curr = currentState(p1); - if (curr == HOLLOW || curr == PERSISTENT_NONTRANSACTIONAL || curr == PERSISTENT_CLEAN) { - // expected result - } else { - fail(ASSERTION_FAILED, "returned state mismatched - " + " Actual state " + curr); - } - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + if (curr == HOLLOW || + curr == PERSISTENT_NONTRANSACTIONAL || + curr == PERSISTENT_CLEAN ) { + // expected result + } + else { + fail(ASSERTION_FAILED, + "returned state mismatched - " + + " Actual state " + curr); + } + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm = null; } - pm.close(); - pm = null; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationInstanceNotInDatastore.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationInstanceNotInDatastore.java index a837c6764..9610f615b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationInstanceNotInDatastore.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationInstanceNotInDatastore.java @@ -5,65 +5,79 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.getobject; import javax.jdo.JDOObjectNotFoundException; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Get Object By Id No Validation Instance Not In Datastore
    - * Keywords: identity exception
    - * Assertion ID: A12.5.6-6.
    - * Assertion Description: If PersistenceManager.getObjectById is called with a - * value of false for the second parameter named validate, and the - * instance does not exist in the data store, a subsequent access of the fields of the instance will - * throw a JDODatastoreException if the instance does not exist at that time. - */ -public class GetObjectByIdNoValidationInstanceNotInDatastore extends PersistenceManagerTest { + *Title: Get Object By Id No Validation Instance Not In Datastore + *
    + *Keywords: identity exception + *
    + *Assertion ID: A12.5.6-6. + *
    + *Assertion Description: +If PersistenceManager.getObjectById is called with a value of +false for the second parameter named validate, +and the instance does not exist in the data store, a subsequent access +of the fields of the instance will throw a JDODatastoreException +if the instance does not exist at that time. - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.6-6 (GetIgnoreCGetObjectByIdNoValidationInstanceNotInDatastore) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectByIdNoValidationInstanceNotInDatastore.class); - } - - /** */ - public void testGetObjectByIdNoValidationInstanceNotInDatastore() { - if (debug) logger.debug("\nSTART GetObjectByIdNoValidationInstanceNotInDatastore"); - Object oid = null; - pm = getPM(); - oid = createPCPointInstance(pm); - deletePCPointInstance(pm, oid); + */ - try { - pm.currentTransaction().begin(); - PCPoint p1 = (PCPoint) pm.getObjectById(oid, false); // might throw exception here - if (debug) logger.debug("Got object in cache, even though not in datastore."); - p1.getX(); // if not thrown above, throws exception here - pm.currentTransaction().commit(); - fail(ASSERTION_FAILED, "accessing unknown instance should throw JDOObjectNotFoundException"); - } catch (JDOObjectNotFoundException ex) { - // expected exception +public class GetObjectByIdNoValidationInstanceNotInDatastore extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.6-6 (GetIgnoreCGetObjectByIdNoValidationInstanceNotInDatastore) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectByIdNoValidationInstanceNotInDatastore.class); } - if (debug) logger.debug("END GetObjectByIdNoValidationInstanceNotInDatastore"); - } + + /** */ + public void testGetObjectByIdNoValidationInstanceNotInDatastore() { + if (debug) + logger.debug ("\nSTART GetObjectByIdNoValidationInstanceNotInDatastore"); + Object oid = null; + pm = getPM(); + oid = createPCPointInstance(pm); + deletePCPointInstance(pm, oid); + + try { + pm.currentTransaction().begin(); + PCPoint p1 = (PCPoint)pm.getObjectById(oid, false); // might throw exception here + if (debug) + logger.debug ("Got object in cache, even though not in datastore."); + p1.getX(); // if not thrown above, throws exception here + pm.currentTransaction().commit(); + fail(ASSERTION_FAILED, + "accessing unknown instance should throw JDOObjectNotFoundException"); + } + catch (JDOObjectNotFoundException ex) { + // expected exception + } + if (debug) + logger.debug ("END GetObjectByIdNoValidationInstanceNotInDatastore"); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNotResolved.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNotResolved.java index c6bed500d..06e31afe7 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNotResolved.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNotResolved.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,61 +19,69 @@ import javax.jdo.JDOObjectNotFoundException; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Get ObjectId For Null Or Not Persistent
    - * Keywords: identity
    - * Assertion IDs: A12.5.6-1
    - * Assertion Description: In a call to PersistenceManager.getObjectById, if the - * PersistenceManager is unable to resolve the oid parameter to an ObjectId instance, then it throws - * a JDOUserException. + *Title: Get ObjectId For Null Or Not Persistent + *
    + *Keywords: identity + *
    + *Assertion IDs: A12.5.6-1 + *
    + *Assertion Description: +In a call to PersistenceManager.getObjectById, if the PersistenceManager is +unable to resolve the oid parameter to an ObjectId instance, then it throws a JDOUserException. */ -public class GetObjectByIdNotResolved extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.6-1 (GetObjectByIdNotResolved) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectByIdNotResolved.class); - } +public class GetObjectByIdNotResolved extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.6-1 (GetObjectByIdNotResolved) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectByIdNotResolved.class); + } - /* passing null paramameter to getObjectId */ - public void testGetObjectByIdNotResolved() { - pm = getPM(); - if (debug) logger.debug(" *** testObjectByIdNotResolved *** "); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - Object oid = pm.getObjectId(p1); - pm.deletePersistent(p1); - tx.commit(); + /* passing null paramameter to getObjectId */ + public void testGetObjectByIdNotResolved() { + pm = getPM(); + if (debug) logger.debug(" *** testObjectByIdNotResolved *** "); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 = new PCPoint (1,3); + pm.makePersistent(p1); + Object oid = pm.getObjectId(p1); + pm.deletePersistent(p1); + tx.commit(); - tx.begin(); - try { - PCPoint p2 = (PCPoint) pm.getObjectById(oid, true); - fail( - ASSERTION_FAILED, - "pm.getObjectById(oid, true) should throw JDOObjectNotFoundException, if oid refers to an non existing object"); - } catch (JDOObjectNotFoundException e) { - // expected exception - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + tx.begin(); + try { + PCPoint p2 = (PCPoint) pm.getObjectById(oid, true); + fail(ASSERTION_FAILED, + "pm.getObjectById(oid, true) should throw JDOObjectNotFoundException, if oid refers to an non existing object"); + } + catch (JDOObjectNotFoundException e) { + // expected exception + } + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm = null; } - pm.close(); - pm = null; - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdWithValidationInstanceInCache.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdWithValidationInstanceInCache.java index 3c3ad4045..412ee8009 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdWithValidationInstanceInCache.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdWithValidationInstanceInCache.java @@ -5,84 +5,85 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.getobject; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Get Object By Id With Validation Instance in Cache
    - * Keywords: identity cache
    - * Assertion IDs: A12.5.6-7
    - * Assertion Description: If PersistenceManager.getObjectById is called with a value of true - * for the second parameter named validate, and there is already a transactional instance in the - * cache with the same JDO identity as the oid parameter, then this method returns it. There is no - * change made to the state of the returned instance. + *Title: Get Object By Id With Validation Instance in Cache + *
    + *Keywords: identity cache + *
    + *Assertion IDs: A12.5.6-7 + *
    + *Assertion Description: +If PersistenceManager.getObjectById is called with a value of true for the second parameter named validate, and there is already a transactional instance in the cache with the same JDO identity as the oid parameter, then this method returns it. There is no change made to the state of the returned instance. */ -public class GetObjectByIdWithValidationInstanceInCache extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.6-7 (GetObjectByIdWithValidationInstanceInCache) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectByIdWithValidationInstanceInCache.class); - } - - /** */ - public void testGetObjectByIdWithValidationInstanceInCache() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); +public class GetObjectByIdWithValidationInstanceInCache extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.6-7 (GetObjectByIdWithValidationInstanceInCache) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectByIdWithValidationInstanceInCache.class); + } - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - Object oid = pm.getObjectId(p1); - tx.commit(); - int curr = currentState(p1); + /** */ + public void testGetObjectByIdWithValidationInstanceInCache() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); - tx.begin(); - Object obj = pm.getObjectById(oid, false); - int curr2 = currentState(obj); + PCPoint p1 = new PCPoint (1,3); + pm.makePersistent(p1); + Object oid = pm.getObjectId(p1); + tx.commit(); + int curr = currentState(p1); - if (obj != p1) { - fail( - ASSERTION_FAILED, - "pm.getObjectById(oid, false) should find existing instance in pm cache"); - } + tx.begin(); + Object obj = pm.getObjectById(oid, false); + int curr2 = currentState(obj); - if (curr2 != curr) { - fail( - ASSERTION_FAILED, - "State changed in the returned instance, expected state: " - + curr - + " Actual state: " - + curr2); - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + if (obj != p1) { + fail(ASSERTION_FAILED, + "pm.getObjectById(oid, false) should find existing instance in pm cache"); + } + + if (curr2 != curr) { + fail(ASSERTION_FAILED, + "State changed in the returned instance, expected state: " + + curr + " Actual state: " + curr2); + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm = null; } - pm.close(); - pm = null; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdWithValidationInstanceInCacheNotInDatastore.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdWithValidationInstanceInCacheNotInDatastore.java index b3f3c24da..06175aa1d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdWithValidationInstanceInCacheNotInDatastore.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdWithValidationInstanceInCacheNotInDatastore.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,63 +19,71 @@ import javax.jdo.JDOObjectNotFoundException; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Get Object By Id With Validation, Instance in Cache, Not in Datastore
    - * Keywords: identity cache
    - * Assertion IDs: A12.5.6-8.
    - * Assertion Description: If PersistenceManager.getObjectById is called with a value of true - * for the second parameter named validate, and there is an instance already in the cache with the - * same JDO identity as the oid parameter, and the instance is not transactional, and the instance - * does not exist in the datastore, then a JDODatastoreException is thrown. - */ -public class GetObjectByIdWithValidationInstanceInCacheNotInDatastore - extends PersistenceManagerTest { + *Title: Get Object By Id With Validation, Instance in Cache, Not in Datastore + *
    + *Keywords: identity cache + *
    + *Assertion IDs: A12.5.6-8. + *
    + *Assertion Description: +If PersistenceManager.getObjectById is called with a value of true +for the second parameter named validate, and there is an instance already in the cache with the +same JDO identity as the oid parameter, and the instance is not transactional, and the instance +does not exist in the datastore, then a JDODatastoreException is thrown. - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.6-8 (GetObjectByIdWithValidationInstanceInCacheNotInDatastore) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectByIdWithValidationInstanceInCacheNotInDatastore.class); - } + */ - /* passing null paramameter to getObjectId */ - public void testGetObjectByIdWithValidationInstanceInCacheNotInDatastore() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); +public class GetObjectByIdWithValidationInstanceInCacheNotInDatastore extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.6-8 (GetObjectByIdWithValidationInstanceInCacheNotInDatastore) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectByIdWithValidationInstanceInCacheNotInDatastore.class); + } - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - Object oid = pm.getObjectId(p1); - pm.deletePersistent(p1); - tx.commit(); + /* passing null paramameter to getObjectId */ + public void testGetObjectByIdWithValidationInstanceInCacheNotInDatastore() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); - tx.begin(); - try { - PCPoint p2 = (PCPoint) pm.getObjectById(oid, true); - fail( - ASSERTION_FAILED, - "pm.getObjectById(oid, true) should throw JDOObjectNotFoundException, if oid refers to an non existing object"); - } catch (JDOObjectNotFoundException ex) { - // expected exception - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); - } - pm.close(); - pm = null; - } + PCPoint p1 = new PCPoint (1,3); + pm.makePersistent(p1); + Object oid = pm.getObjectId(p1); + pm.deletePersistent(p1); + tx.commit(); + + tx.begin(); + try { + PCPoint p2 = (PCPoint) pm.getObjectById(oid, true); + fail(ASSERTION_FAILED, + "pm.getObjectById(oid, true) should throw JDOObjectNotFoundException, if oid refers to an non existing object"); + } + catch (JDOObjectNotFoundException ex) { + // expected exception + } + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdWithValidationInstanceNotInCacheNotInDatastore.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdWithValidationInstanceNotInCacheNotInDatastore.java index 769fd9af8..df4a887a8 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdWithValidationInstanceNotInCacheNotInDatastore.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdWithValidationInstanceNotInCacheNotInDatastore.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,57 +19,58 @@ import javax.jdo.JDOObjectNotFoundException; import javax.jdo.Transaction; + import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get Object By Id With Validation, Instance Not in Cache, Not in Datastore
    - * Keywords: exception
    - * Assertion IDs: A12.6.5-2.
    - * Assertion Description: Object getObjectById (Object oid, boolean validate) with - * validate==true. If the instance does not exist in the datastore, then a - * JDOObjectNotFoundException is thrown. + *Title: Get Object By Id With Validation, Instance Not in Cache, Not in Datastore + *
    + *Keywords: exception + *
    + *Assertion IDs: A12.6.5-2. + *
    + *Assertion Description: +Object getObjectById (Object oid, boolean validate) with validate==true. If the instance does not exist in the datastore, then a JDOObjectNotFoundException is thrown. */ -public class GetObjectByIdWithValidationInstanceNotInCacheNotInDatastore - extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.6.5-2 (GetObjectByIdWithValidationInstanceNotInCacheNotInDatastore) failed: "; +public class GetObjectByIdWithValidationInstanceNotInCacheNotInDatastore extends PersistenceManagerTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectByIdWithValidationInstanceNotInCacheNotInDatastore.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.6.5-2 (GetObjectByIdWithValidationInstanceNotInCacheNotInDatastore) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectByIdWithValidationInstanceNotInCacheNotInDatastore.class); + } - /** */ - public void test() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.setRestoreValues( - false); // This should cause eviction of transactional instances when transaction is later - // rolled back. - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - Object oid = pm.getObjectId(p1); - tx.rollback(); + /** */ + public void test() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.setRestoreValues(false); //This should cause eviction of transactional instances when transaction is later rolled back. + tx.begin(); + PCPoint p1 = new PCPoint (1,3); + pm.makePersistent(p1); + Object oid = pm.getObjectId(p1); + tx.rollback(); - tx.begin(); - try { - PCPoint p2 = (PCPoint) pm.getObjectById(oid, true); - fail( - ASSERTION_FAILED, - "pm.getObjectById(oid, true) should throw JDOObjectNotFoundException, if oid refers to an non existing object"); - } catch (JDOObjectNotFoundException ex) { - // expected exception - } finally { - tx.rollback(); + tx.begin(); + try { + PCPoint p2 = (PCPoint) pm.getObjectById(oid, true); + fail(ASSERTION_FAILED, "pm.getObjectById(oid, true) should throw JDOObjectNotFoundException, if oid refers to an non existing object"); + } + catch (JDOObjectNotFoundException ex) { + // expected exception + } + finally { + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectId.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectId.java index 51da09088..593dc0ca4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectId.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectId.java @@ -5,71 +5,78 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.getobject; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Get Objectid
    - * Keywords: identity
    - * Assertion ID: A12.5.6-10
    - * Assertion Description: The PersistenceManager.getObjectId method returns an ObjectId - * instance that re presents the object identity of the specified JDO Instance. Test: The method g - * etObjectById returns the exact same object, evaluating to true when == is used . - */ -public class GetObjectId extends PersistenceManagerTest { + *Title: Get Objectid + *
    + *Keywords: identity + *
    + *Assertion ID: A12.5.6-10 + *
    + *Assertion Description: +The PersistenceManager.getObjectId method returns an ObjectId instance that re presents the object identity of the specified JDO Instance. Test: The method g etObjectById returns the exact same object, evaluating to true when == is used . - /** */ - private static final String ASSERTION_FAILED = "Assertion A12.5.6-10 (GetObjectId) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectId.class); - } + */ - /** */ - public void testGetObjectId() { - pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - PCPoint p1 = new PCPoint(8, 8); +public class GetObjectId extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.6-10 (GetObjectId) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectId.class); + } + + /** */ + public void testGetObjectId() { + pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + PCPoint p1 = new PCPoint(8,8); - tx = pm.currentTransaction(); - tx.begin(); - pm.makePersistent(p1); - Object oid = pm.getObjectId(p1); - tx.commit(); + tx = pm.currentTransaction(); + tx.begin(); + pm.makePersistent(p1); + Object oid = pm.getObjectId(p1); + tx.commit(); - tx.begin(); - Object obj = pm.getObjectById(oid, false); - if (obj != p1) { - fail( - ASSERTION_FAILED, - "m.getObjectById(oid, false) should find existing instance in pm cache."); - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + tx.begin(); + Object obj = pm.getObjectById(oid, false); + if (obj != p1) { + fail(ASSERTION_FAILED, + "m.getObjectById(oid, false) should find existing instance in pm cache."); + } + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm = null; } - pm.close(); - pm = null; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectIdClass.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectIdClass.java index 34864ffa9..55570be92 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectIdClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectIdClass.java @@ -5,88 +5,98 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.getobject; import javax.jdo.PersistenceManager; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Get ObjectId Class
    - * Keywords: identity
    - * Assertion IDs: A12.10-1
    - * Assertion Description: The method PersistenceManager.getObjectIdClass returns the class - * of the object id for the given class. If the parameter class is not persistence-capable, or the - * parameter is null, null is returned. If the object-id class defined in the metadata for the - * parameter class is abstract then null is returned. If the implementation does not support - * application identity, and the class is defined in the jdo metadata to use application identity, - * then null is returned. + *Title: Get ObjectId Class + *
    + *Keywords: identity + *
    + *Assertion IDs: A12.10-1 + *
    + *Assertion Description: +The method PersistenceManager.getObjectIdClass returns the class of the +object id for the given class. +If the parameter class is not persistence-capable, or the parameter is null, + null is returned. If the object-id class defined in the metadata for the + parameter class is abstract then null is returned. +If the implementation does not support application identity, and the class + is defined in the jdo metadata to use application identity, + then null is returned. */ -public class GetObjectIdClass extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A12.10-1 (GetObjectIdClass) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectIdClass.class); - } +public class GetObjectIdClass extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.10-1 (GetObjectIdClass) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectIdClass.class); + } - /** */ - public void test() { - pm = getPM(); - runTestGetObjectIdClassForNull(pm); - runTestGetObjectIdClassForNonPCClass(pm); - runTestGetObjectIdClassForAbstractClass(pm); - runTestGetObjectIdClass(pm); - pm.close(); - pm = null; - } + /** */ + public void test() { + pm = getPM(); + runTestGetObjectIdClassForNull(pm); + runTestGetObjectIdClassForNonPCClass(pm); + runTestGetObjectIdClassForAbstractClass(pm); + runTestGetObjectIdClass(pm); + pm.close(); + pm = null; + } - /** */ - private void runTestGetObjectIdClass(PersistenceManager pm) { - if (pm.getObjectIdClass(PCPoint.class) == null) { - fail(ASSERTION_FAILED, "pm.getObjectIdClass(PCPoint.class) returned null"); + /** */ + private void runTestGetObjectIdClass(PersistenceManager pm) { + if (pm.getObjectIdClass(PCPoint.class) == null) { + fail(ASSERTION_FAILED, + "pm.getObjectIdClass(PCPoint.class) returned null"); + } } - } - /** */ - private void runTestGetObjectIdClassForNull(PersistenceManager pm) { - Class cl = pm.getObjectIdClass(null); - if (cl != null) { - fail( - ASSERTION_FAILED, - "pm.getObjectIdClass for null returned non-null class: " + cl.getName()); + /** */ + private void runTestGetObjectIdClassForNull(PersistenceManager pm) { + Class cl = pm.getObjectIdClass(null); + if (cl != null) { + fail(ASSERTION_FAILED, + "pm.getObjectIdClass for null returned non-null class: " + + cl.getName()); + } } - } - /** */ - private void runTestGetObjectIdClassForNonPCClass(PersistenceManager pm) { - Class cl = pm.getObjectIdClass(java.lang.Throwable.class); - if (cl != null) { - fail( - ASSERTION_FAILED, - "pm.getObjectIdClass for non-PC class returned non-null class: " + cl.getName()); + /** */ + private void runTestGetObjectIdClassForNonPCClass(PersistenceManager pm) { + Class cl = pm.getObjectIdClass(java.lang.Throwable.class); + if (cl != null) { + fail(ASSERTION_FAILED, + "pm.getObjectIdClass for non-PC class returned non-null class: " + + cl.getName()); + } } - } - private void runTestGetObjectIdClassForAbstractClass(PersistenceManager pm) { - // not implemented; the tck contains no classes with which to test this. - // we need an abstract class whose object-id class is itself abstract. - } + private void runTestGetObjectIdClassForAbstractClass(PersistenceManager pm) { + // not implemented; the tck contains no classes with which to test this. + // we need an abstract class whose object-id class is itself abstract. + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectIdClassForAbstractOrNonPersistenceCapableClass.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectIdClassForAbstractOrNonPersistenceCapableClass.java index a1b50d89b..5ce583034 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectIdClassForAbstractOrNonPersistenceCapableClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectIdClassForAbstractOrNonPersistenceCapableClass.java @@ -5,71 +5,75 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.getobject; import javax.jdo.PersistenceManager; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.Point; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Get ObjectId Class For Abstract or Non-PersistenceCapable Class
    - * Keywords: identity
    - * Assertion IDs: A12.10-2
    - * Assertion Description: A call to PersistenceManager.getObjectIdClass returns null if the - * class is abstract or not persistence-capable, or the parameter is null. + *Title: Get ObjectId Class For Abstract or Non-PersistenceCapable Class + *
    + *Keywords: identity + *
    + *Assertion IDs: A12.10-2 + *
    + *Assertion Description: +A call to PersistenceManager.getObjectIdClass returns null if the class is abstract or not persistence-capable, or the parameter is null. */ -public class GetObjectIdClassForAbstractOrNonPersistenceCapableClass - extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.10-2 (GetObjectIdClassForAbstractOrNonPersistenceCapableClass) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectIdClassForAbstractOrNonPersistenceCapableClass.class); - } - - /** */ - public void testGetObjectIdClassForAbstractOrNonPersistenceCapableClass() { - pm = getPM(); - runTestNonPcClass(pm); - runTestNullParam(pm); - pm.close(); - pm = null; - } +public class GetObjectIdClassForAbstractOrNonPersistenceCapableClass extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.10-2 (GetObjectIdClassForAbstractOrNonPersistenceCapableClass) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectIdClassForAbstractOrNonPersistenceCapableClass.class); + } - /** */ - private void runTestNonPcClass(PersistenceManager pm) { - Class c1 = pm.getObjectIdClass(Point.class); - if (c1 != null) { - fail( - ASSERTION_FAILED, "pm.getObjectIdClass returns non-null ObjectId class for non pc class"); + /** */ + public void testGetObjectIdClassForAbstractOrNonPersistenceCapableClass() { + pm = getPM(); + runTestNonPcClass(pm); + runTestNullParam(pm); + pm.close(); + pm = null; + } + + /** */ + private void runTestNonPcClass(PersistenceManager pm) { + Class c1 = pm.getObjectIdClass(Point.class); + if ( c1 != null) { + fail(ASSERTION_FAILED, + "pm.getObjectIdClass returns non-null ObjectId class for non pc class"); + } } - } - /** */ - private void runTestNullParam(PersistenceManager pm) { - Class c1 = pm.getObjectIdClass(null); - if (c1 != null) { - fail( - ASSERTION_FAILED, - "pm.getObjectIdClass for null returned non-null class: " + c1.getName()); + /** */ + private void runTestNullParam(PersistenceManager pm) { + Class c1 = pm.getObjectIdClass(null); + if (c1 != null) { + fail(ASSERTION_FAILED, + "pm.getObjectIdClass for null returned non-null class: " + + c1.getName()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectIdForNullOrNotPersistent.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectIdForNullOrNotPersistent.java index 2122b8a21..c9294f425 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectIdForNullOrNotPersistent.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectIdForNullOrNotPersistent.java @@ -5,70 +5,78 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.getobject; import javax.jdo.PersistenceManager; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.Point; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: GetObjectIdForNullOrNotPersistent
    - * Keywords: identity
    - * Assertion IDs: A12.5.6-14.
    - * Assertion Description: If a call is made to PersistenceManager.getObjectId and the - * parameter pc is not persistent, or is null, then null is returned. + *Title: GetObjectIdForNullOrNotPersistent + *
    + *Keywords: identity + *
    + *Assertion IDs: A12.5.6-14. + *
    + *Assertion Description: +If a call is made to PersistenceManager.getObjectId and the +parameter pc is not persistent, or is null, then null is returned. */ -public class GetObjectIdForNullOrNotPersistent extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.6-14 (GetObjectIdForNullOrNotPersistent) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectIdForNullOrNotPersistent.class); - } - - /** */ - public void testGetObjectIdForNullOrNotPersistent() { - pm = getPM(); - runTestNonPcClass(pm); - runTestNullParam(pm); - pm.close(); - pm = null; - } +public class GetObjectIdForNullOrNotPersistent extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.6-14 (GetObjectIdForNullOrNotPersistent) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectIdForNullOrNotPersistent.class); + } - /** */ - private void runTestNonPcClass(PersistenceManager pm) { - Point p = new Point(1, 3); - Object oid = pm.getObjectId(p); - if (oid != null) { - fail( - ASSERTION_FAILED, - "pm.getObjectId returned non null ObjectId: " + oid + " for instance of non-pc class"); + /** */ + public void testGetObjectIdForNullOrNotPersistent() { + pm = getPM(); + runTestNonPcClass(pm); + runTestNullParam(pm); + pm.close(); + pm = null; } - } - /** */ - private void runTestNullParam(PersistenceManager pm) { - Object oid = pm.getObjectId(null); - if (oid != null) { - fail(ASSERTION_FAILED, "pm.getObjectId(null) returned non null ObjectId: " + oid); + /** */ + private void runTestNonPcClass(PersistenceManager pm) { + Point p = new Point(1,3); + Object oid = pm.getObjectId(p); + if (oid != null) { + fail(ASSERTION_FAILED, + "pm.getObjectId returned non null ObjectId: " + oid + + " for instance of non-pc class"); + } + } + + /** */ + private void runTestNullParam(PersistenceManager pm) { + Object oid = pm.getObjectId(null); + if (oid != null) { + fail(ASSERTION_FAILED, + "pm.getObjectId(null) returned non null ObjectId: " + oid); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectIdForPersistentInterface.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectIdForPersistentInterface.java index a70bd3997..08a63400b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectIdForPersistentInterface.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectIdForPersistentInterface.java @@ -5,80 +5,92 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.getobject; import java.util.Date; + import javax.jdo.Transaction; + import javax.jdo.identity.LongIdentity; + import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +import org.apache.jdo.tck.pc.company.Company; import org.apache.jdo.tck.pc.company.ICompany; import org.apache.jdo.tck.pc.company.PICompany; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get ObjectidForPersistentInterface
    - * Keywords: identity
    - * Assertion ID: A12.6.6-1
    - * Assertion Description: For interfaces and classes that use a SingleFieldIdentity as the - * object-id class, if the returned instance is subsequently made persistent, the target class - * stored in the object-id instance is the parameter of the newInstance method that created it. + *Title: Get ObjectidForPersistentInterface + *
    + *Keywords: identity + *
    + *Assertion ID: A12.6.6-1 + *
    + *Assertion Description: + * For interfaces and classes that use a SingleFieldIdentity as + * the object-id class, if the returned instance is subsequently + * made persistent, the target class stored in the object-id + * instance is the parameter of the newInstance method that created it. */ -public class GetObjectIdForPersistentInterface extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A12.6.6-1 (GetObjectId) failed: "; +public class GetObjectIdForPersistentInterface extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.6.6-1 (GetObjectId) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectIdForPersistentInterface.class); + } - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectIdForPersistentInterface.class); - } + public void localSetUp() { + addTearDownClass(PICompany.class); + } - public void localSetUp() { - addTearDownClass(PICompany.class); - } + /** */ + public void testGetObjectId() { + if (!runsWithApplicationIdentity()) { + printNonApplicableIdentityType( + "GetObjectIdForPersistentInterface", + APPLICATION_IDENTITY); + return; + } + pm = getPM(); + Transaction tx = pm.currentTransaction(); + ICompany icompany = (ICompany)pm.newInstance(PICompany.class); + icompany.setCompanyid(1001); + icompany.setName("GooTube"); + icompany.setFounded(new Date()); - /** */ - public void testGetObjectId() { - if (!runsWithApplicationIdentity()) { - printNonApplicableIdentityType("GetObjectIdForPersistentInterface", APPLICATION_IDENTITY); - return; - } - pm = getPM(); - Transaction tx = pm.currentTransaction(); - ICompany icompany = (ICompany) pm.newInstance(PICompany.class); - icompany.setCompanyid(1001); - icompany.setName("GooTube"); - icompany.setFounded(new Date()); + tx.begin(); + pm.makePersistent(icompany); + LongIdentity ioid = (LongIdentity)pm.getObjectId(icompany); + tx.commit(); - tx.begin(); - pm.makePersistent(icompany); - LongIdentity ioid = (LongIdentity) pm.getObjectId(icompany); - tx.commit(); + Class pICompanyOidTargetClass = ioid.getTargetClass(); + if (pICompanyOidTargetClass != PICompany.class) + appendMessage(ASSERTION_FAILED + + " getObjectId(icompany) should return interface class.\n" + + "expected: " + icompany.getClass().getName() + "\n" + + "actual: " + pICompanyOidTargetClass.getName()); + failOnError(); - Class pICompanyOidTargetClass = ioid.getTargetClass(); - if (pICompanyOidTargetClass != PICompany.class) - appendMessage( - ASSERTION_FAILED - + " getObjectId(icompany) should return interface class.\n" - + "expected: " - + icompany.getClass().getName() - + "\n" - + "actual: " - + pICompanyOidTargetClass.getName()); - failOnError(); - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectIdWithApplicationModifyingIdentity.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectIdWithApplicationModifyingIdentity.java index b87f3e53a..c18b0a6f8 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectIdWithApplicationModifyingIdentity.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectIdWithApplicationModifyingIdentity.java @@ -5,79 +5,95 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.getobject; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Get ObjectId With Application Modifying Identity
    - * Keywords: identity applicationidentity
    - * Assertion ID: A12.5.6-11.
    - * Assertion Description: If the object identity is being changed in the transaction, by the - * application modifying one or more of the application key fields, then the method - * PersistenceManager.getObjectId returns the identity as of the beginning of the - * transaction. The value returned by getObjectId will be different following - * afterCompletion processing for successful transactions. - */ -public class GetObjectIdWithApplicationModifyingIdentity extends PersistenceManagerTest { + *Title: Get ObjectId With Application Modifying Identity + *
    + *Keywords: identity applicationidentity + *
    + *Assertion ID: A12.5.6-11. + *
    + *Assertion Description: +If the object identity is being changed in the transaction, +by the application modifying one or more of the application key fields, +then the method PersistenceManager.getObjectId returns the +identity as of the beginning of the transaction. The value returned by +getObjectId will be different following afterCompletion +processing for successful transactions. - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.6-11 (GetObjectIdWithApplicationModifyingIdentity) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectIdWithApplicationModifyingIdentity.class); - } + */ - /** */ - public void testGetObjectByIdWithApplicationModifyingIdentity() { - if (!isChangeApplicationIdentitySupported()) { - if (debug) logger.debug("Implementation does not support chaning application identity"); - return; +public class GetObjectIdWithApplicationModifyingIdentity extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.6-11 (GetObjectIdWithApplicationModifyingIdentity) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectIdWithApplicationModifyingIdentity.class); } - if (debug) logger.debug("\nSTART GetObjectIdWithApplicationModifyingIdentity"); - pm = getPM(); - Object oid = createPCPointInstance(pm); - PCPoint p1 = (PCPoint) pm.getObjectById(oid, false); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - p1.setX(10000); // this is the primary key - Object oid2 = pm.getObjectId(p1); // should be the same - tx.commit(); - - Object oid3 = pm.getObjectId(p1); // should be same as oid3 - if (!oid.equals(oid2)) { - fail(ASSERTION_FAILED, "Oid before is different from oid after modifying pk"); - } - - if (oid.equals(oid3)) { - fail(ASSERTION_FAILED, "Oid before is the same as oid after modifying pk"); - } - } finally { - if (debug) logger.debug("END GetObjectIdWithApplicationModifyingIdentity"); - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + public void testGetObjectByIdWithApplicationModifyingIdentity() { + if (!isChangeApplicationIdentitySupported()) { + if (debug) + logger.debug("Implementation does not support chaning application identity"); + return; + } + + if (debug) + logger.debug("\nSTART GetObjectIdWithApplicationModifyingIdentity"); + pm = getPM(); + Object oid = createPCPointInstance(pm); + PCPoint p1 = (PCPoint) pm.getObjectById(oid, false); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + p1.setX(10000); // this is the primary key + Object oid2 = pm.getObjectId (p1); // should be the same + tx.commit(); + + Object oid3 = pm.getObjectId (p1); // should be same as oid3 + if (!oid.equals(oid2)) { + fail(ASSERTION_FAILED, + "Oid before is different from oid after modifying pk"); + } + + if (oid.equals(oid3)) { + fail(ASSERTION_FAILED, + "Oid before is the same as oid after modifying pk"); + } + } + finally { + if (debug) + logger.debug("END GetObjectIdWithApplicationModifyingIdentity"); + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm = null; } - pm.close(); - pm = null; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectsById.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectsById.java index 566d571d7..c4332bed6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectsById.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/getobject/GetObjectsById.java @@ -5,189 +5,213 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.getobject; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; + import org.apache.jdo.tck.JDO_Test; + import org.apache.jdo.tck.pc.mylib.PCPoint; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test GetObjectsById
    - * Keywords: getObjectsById getObjectById
    - * Assertion IDs: 12.5.6-17
    - * Assertion Description: 12.5.6-17 [Collection getObjectsById (Collection oids); Object[] - * getObjectsById (Object[] oids); Collection getObjectsById (Collection oids, boolean validate); - * Object[] getObjectsById (Object[] oids, boolean validate); The getObjectsById method attempts to - * find instances in the cache with the specified JDO identities. The elements of the oids parameter - * object might have been returned by earlier calls to getObjectId or getTransactionalObjectId, or - * might have been constructed by the application. If a method with no validate parameter is used, - * the method behaves exactly as the correspond ing method with the validate flag set to true. If - * the Object[] form of the method is used, the returned objects correspond by position with the - * object ids in the oids parameter. If the Collection form of the method is used, the iterator over - * the returned Collection returns instances in the same order as the oids returned by an iterator - * over the parameter Collection. The cardinality of the return value is the same as the cardinality - * of the oids parameter. ] + *Title: Test GetObjectsById + *
    + *Keywords: getObjectsById getObjectById + *
    + *Assertion IDs: 12.5.6-17 + *
    + *Assertion Description: + * 12.5.6-17 [Collection getObjectsById (Collection oids); + * Object[] getObjectsById (Object[] oids); + * Collection getObjectsById (Collection oids, boolean validate); + * Object[] getObjectsById (Object[] oids, boolean validate); + * The getObjectsById method attempts to find instances in the cache + * with the specified JDO identities. The elements of the oids parameter + * object might have been returned by earlier calls to getObjectId + * or getTransactionalObjectId, or might have been constructed by + * the application. If a method with no validate parameter is used, + * the method behaves exactly as the correspond ing method with + * the validate flag set to true. If the Object[] form of the method + * is used, the returned objects correspond by position with + * the object ids in the oids parameter. If the Collection form + * of the method is used, the iterator over the returned Collection + * returns instances in the same order as the oids returned by + * an iterator over the parameter Collection. The cardinality of + * the return value is the same as the cardinality of + * the oids parameter. ] */ + public class GetObjectsById extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion 12.5.6-17 (GetObjectsById) failed: "; - - /** Number of persistent instances */ - private static final int NUMBER_OF_INSTANCES = 50; - - /** Persistent instances */ - private final Collection instanceCollection = new ArrayList(NUMBER_OF_INSTANCES); - - /** Object ids */ - private final Collection oidCollection = new ArrayList(NUMBER_OF_INSTANCES); - - /** Persistent instances */ - private final Object[] instanceArray = new Object[NUMBER_OF_INSTANCES]; - - /** Object ids */ - private final Object[] oidArray = new Object[NUMBER_OF_INSTANCES]; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetObjectsById.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - getPM().currentTransaction().begin(); - Object instance; - Object oid; - instanceCollection.clear(); - oidCollection.clear(); - for (int i = 0; i < NUMBER_OF_INSTANCES; ++i) { - instance = new PCPoint(i, 1000 + i); - pm.makePersistent(instance); - instanceCollection.add(instance); - instanceArray[i] = instance; - oid = pm.getObjectId(instance); - oidCollection.add(oid); - oidArray[i] = oid; + /** */ + private static final String ASSERTION_FAILED = + "Assertion 12.5.6-17 (GetObjectsById) failed: "; + + /** Number of persistent instances */ + private static final int NUMBER_OF_INSTANCES = 50; + + /** Persistent instances */ + private final Collection instanceCollection = + new ArrayList(NUMBER_OF_INSTANCES); + + /** Object ids */ + private final Collection oidCollection = + new ArrayList(NUMBER_OF_INSTANCES); + + /** Persistent instances */ + private final Object[] instanceArray = + new Object[NUMBER_OF_INSTANCES]; + + /** Object ids */ + private final Object[] oidArray = + new Object[NUMBER_OF_INSTANCES]; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetObjectsById.class); } - pm.currentTransaction().commit(); - } - - /** */ - public void testCollection() { - getPM().currentTransaction().begin(); - Collection result = pm.getObjectsById(oidCollection); - pm.currentTransaction().commit(); - checkResultCollection("after getObjectsById(Collection)", result); - failOnError(); - } - - /** */ - public void testCollectionTrue() { - getPM().currentTransaction().begin(); - Collection result = pm.getObjectsById(oidCollection, true); - pm.currentTransaction().commit(); - checkResultCollection("after getObjectsById(Collection, true)", result); - failOnError(); - } - - /** */ - public void testCollectionFalse() { - getPM().currentTransaction().begin(); - Collection result = pm.getObjectsById(oidCollection, false); - pm.currentTransaction().commit(); - checkResultCollection("after getObjectsById(Collection, false)", result); - failOnError(); - } - - /** */ - public void testArray() { - getPM().currentTransaction().begin(); - Object[] result = pm.getObjectsById(oidArray); - pm.currentTransaction().commit(); - checkResultArray("after getObjectsById(Object[], false)", result); - failOnError(); - } - - /** */ - public void testArrayTrue() { - getPM().currentTransaction().begin(); - Object[] result = pm.getObjectsById(true, oidArray); - pm.currentTransaction().commit(); - checkResultArray("after getObjectsById(Object[], false)", result); - failOnError(); - } - - /** */ - public void testArrayFalse() { - getPM().currentTransaction().begin(); - Object[] result = pm.getObjectsById(false, oidArray); - pm.currentTransaction().commit(); - checkResultArray("after getObjectsById(Object[], false)", result); - failOnError(); - } - - /** Check the results of getObjectsById */ - private void checkResultCollection(String location, Collection instances) { - Iterator expected = instanceCollection.iterator(); - Iterator actual = instances.iterator(); - for (int i = 0; i < NUMBER_OF_INSTANCES; ++i) { - checkIdentity( - ASSERTION_FAILED + location + ", position " + i, expected.next(), actual.next()); + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + getPM().currentTransaction().begin(); + Object instance; + Object oid; + instanceCollection.clear(); + oidCollection.clear(); + for (int i = 0; i < NUMBER_OF_INSTANCES; ++i) { + instance = new PCPoint(i, 1000 + i); + pm.makePersistent(instance); + instanceCollection.add(instance); + instanceArray[i] = instance; + oid = pm.getObjectId(instance); + oidCollection.add(oid); + oidArray[i] = oid; + } + pm.currentTransaction().commit(); + } + + /** */ + public void testCollection() { + getPM().currentTransaction().begin(); + Collection result = pm.getObjectsById(oidCollection); + pm.currentTransaction().commit(); + checkResultCollection("after getObjectsById(Collection)", + result); + failOnError(); } - checkIteratorComplete(ASSERTION_FAILED, actual); - } - - /** Check the results of getObjectsById */ - private void checkResultArray(String location, Object[] actual) { - int length = actual.length; - if (length != NUMBER_OF_INSTANCES) { - appendMessage( - location - + "incorrect length of result. " - + "expected: " - + NUMBER_OF_INSTANCES - + " actual: " - + length); + + /** */ + public void testCollectionTrue() { + getPM().currentTransaction().begin(); + Collection result = pm.getObjectsById(oidCollection, true); + pm.currentTransaction().commit(); + checkResultCollection( + "after getObjectsById(Collection, true)", + result); + failOnError(); + } + + /** */ + public void testCollectionFalse() { + getPM().currentTransaction().begin(); + Collection result = pm.getObjectsById(oidCollection, false); + pm.currentTransaction().commit(); + checkResultCollection( + "after getObjectsById(Collection, false)", + result); + failOnError(); } - Object[] expected = instanceArray; - for (int i = 0; i < NUMBER_OF_INSTANCES; ++i) { - checkIdentity(ASSERTION_FAILED + location + ", position " + i, expected[i], actual[i]); + + /** */ + public void testArray() { + getPM().currentTransaction().begin(); + Object[] result = pm.getObjectsById(oidArray); + pm.currentTransaction().commit(); + checkResultArray("after getObjectsById(Object[], false)", result); + failOnError(); + } + + /** */ + public void testArrayTrue() { + getPM().currentTransaction().begin(); + Object[] result = pm.getObjectsById(true, oidArray); + pm.currentTransaction().commit(); + checkResultArray("after getObjectsById(Object[], false)", result); + failOnError(); + } + + /** */ + public void testArrayFalse() { + getPM().currentTransaction().begin(); + Object[] result = pm.getObjectsById(false, oidArray); + pm.currentTransaction().commit(); + checkResultArray("after getObjectsById(Object[], false)", result); + failOnError(); + } + + /** Check the results of getObjectsById */ + private void checkResultCollection(String location, Collection instances) { + Iterator expected = instanceCollection.iterator(); + Iterator actual = instances.iterator(); + for (int i = 0; i < NUMBER_OF_INSTANCES; ++i) { + checkIdentity(ASSERTION_FAILED + location + ", position " + i, + expected.next(), actual.next()); + } + checkIteratorComplete(ASSERTION_FAILED, + actual); + } + + /** Check the results of getObjectsById */ + private void checkResultArray(String location, Object[] actual) { + int length = actual.length; + if (length != NUMBER_OF_INSTANCES) { + appendMessage(location + "incorrect length of result. " + + "expected: " + NUMBER_OF_INSTANCES + + " actual: " + length); + } + Object[] expected = instanceArray; + for (int i = 0; i < NUMBER_OF_INSTANCES; ++i) { + checkIdentity(ASSERTION_FAILED + location + ", position " + i, + expected[i], actual[i]); + } } - } - /** Check the identity of the instances */ - private void checkIdentity(String location, Object expected, Object actual) { - if (expected != actual) { - appendMessage( - location + "failed to compare \n" + "expected: " + expected + " actual: " + actual); + /** Check the identity of the instances */ + private void checkIdentity(String location, + Object expected, Object actual) { + if (expected != actual) { + appendMessage(location + "failed to compare \n" + + "expected: " + expected + " actual: " + actual); + } } - } - /** Check that the iterator has no more elements */ - private void checkIteratorComplete(String location, Iterator iterator) { - if (iterator.hasNext()) { - appendMessage(location + "result iterator has more elements than expected."); + /** Check that the iterator has no more elements */ + private void checkIteratorComplete (String location, Iterator iterator) { + if (iterator.hasNext()) { + appendMessage(location + + "result iterator has more elements than expected."); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeNontransactionalAllFails.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeNontransactionalAllFails.java index 3bacb6885..bd1a6311e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeNontransactionalAllFails.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeNontransactionalAllFails.java @@ -5,162 +5,171 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.lifecycle; import java.util.Collection; + import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.pc.mylib.Point; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: MakeNontransactionalAllFails
    - * Keywords: exception
    - * Assertion ID: A12.5.7-5
    - * Assertion Description: If a collection or array of instances is passed to - * PersistenceManager.makeNontransactionalAll, and one or more of the instances fail to complete the - * required operation, then all instances will be attempted, and a JDOUserException will be thrown - * which contains a nested exception array, each exception of which contains one of the failing - * instances. The succeeding instances will transition to the specified life cycle state, and the - * failing instances will remain in their current state. - */ -public class MakeNontransactionalAllFails extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-5 (MakeNontransactionalAllFails) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeNontransactionalAllFails.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private Point p5 = null; - - /** */ - public void testTransactionalInst() { - pm = getPM(); - - createObjects(pm); - runTestMakeNontransactional1(pm); - runTestMakeNontransactionalAll1(pm); - - pm.close(); - pm = null; - } + *Title: MakeNontransactionalAllFails + *
    + *Keywords: exception + *
    + *Assertion ID: A12.5.7-5 + *
    + *Assertion Description: +If a collection or array of instances is passed to PersistenceManager.makeNontransactionalAll, and one or more of the instances fail to complete the required operation, then all instances will be attempted, and a JDOUserException will be thrown which contains a nested exception array, each exception of which contains one of the failing instances. The succeeding instances will transition to the specified life cycle state, and the failing instances will remain in their current state. - /** */ - private void createObjects(PersistenceManager pm) { - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - } + */ - /* test makeNontransactional (Object pc) */ - private void runTestMakeNontransactional1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - pm.makePersistent(p1); - try { - pm.makeNontransactional(p1); - fail( - ASSERTION_FAILED, - "pm.makeNontransactional should throw a JDOUserException when called for a P-NEW instance."); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); +public class MakeNontransactionalAllFails extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-5 (MakeNontransactionalAllFails) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeNontransactionalAllFails.class); } - } - - /* test makeNontransactionalAll (Collection pcs) */ - private void runTestMakeNontransactionalAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - pm.makePersistent(p2); - tx.commit(); - - tx.begin(); - pm.makePersistent(p3); - pm.makePersistent(p4); - - Collection col1 = new java.util.HashSet(); - col1.add(p2); - col1.add(p3); - col1.add(p4); - - try { - pm.makeNontransactionalAll(col1); - fail( - ASSERTION_FAILED, - "pm.makeNontransactionalAll(Collection) should throw a JDOUserException when called for collection including P-NEW instances."); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private Point p5 = null; + + /** */ + public void testTransactionalInst() { + pm = getPM(); + + createObjects(pm); + runTestMakeNontransactional1(pm); + runTestMakeNontransactionalAll1(pm); + + pm.close(); + pm = null; + } + + /** */ + private void createObjects(PersistenceManager pm) { + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + } + + /* test makeNontransactional (Object pc) */ + private void runTestMakeNontransactional1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + pm.makePersistent(p1); + try { + pm.makeNontransactional(p1); + fail(ASSERTION_FAILED, + "pm.makeNontransactional should throw a JDOUserException when called for a P-NEW instance."); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /* test makeNontransactionalAll (Collection pcs) */ + private void runTestMakeNontransactionalAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + pm.makePersistent(p2); + tx.commit(); + + tx.begin(); + pm.makePersistent(p3); + pm.makePersistent(p4); + + Collection col1 = new java.util.HashSet(); + col1.add(p2); + col1.add(p3); + col1.add(p4); + + try { + pm.makeNontransactionalAll(col1); + fail(ASSERTION_FAILED, + "pm.makeNontransactionalAll(Collection) should throw a JDOUserException when called for collection including P-NEW instances."); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /* test makeNontransactionalAll (Object[] pcs) */ - private void testMakeNontransactionalAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx = pm.currentTransaction(); - tx.begin(); - pm.makePersistent(p2); - tx.commit(); - - tx.begin(); - pm.makePersistent(p3); - pm.makePersistent(p4); - - Collection col1 = new java.util.HashSet(); - col1.add(p2); - col1.add(p3); - col1.add(p4); - try { - pm.makeNontransactionalAll(col1.toArray()); - fail( - ASSERTION_FAILED, - "pm.makeNontransactionalAll(Object []) should throw a JDOUserException when called for an array including P-NEW instances."); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /* test makeNontransactionalAll (Object[] pcs) */ + private void testMakeNontransactionalAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx = pm.currentTransaction(); + tx.begin(); + pm.makePersistent(p2); + tx.commit(); + + tx.begin(); + pm.makePersistent(p3); + pm.makePersistent(p4); + + Collection col1 = new java.util.HashSet(); + col1.add(p2); + col1.add(p3); + col1.add(p4); + + try { + pm.makeNontransactionalAll(col1.toArray()); + fail(ASSERTION_FAILED, + "pm.makeNontransactionalAll(Object []) should throw a JDOUserException when called for an array including P-NEW instances."); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeNontransactionalDirtyInstance.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeNontransactionalDirtyInstance.java index c2e556e84..cbf570732 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeNontransactionalDirtyInstance.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeNontransactionalDirtyInstance.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,271 +20,287 @@ import java.util.Collection; import java.util.HashSet; import java.util.Iterator; + import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Make Nontransactional a Dirty Instance
    - * Keywords: exception
    - * Assertion IDs: A12.5.7-28
    - * Assertion Description: If PersistenceManager.makeNontransactional or - * makeNontransactionalAll is called with an explicit dirty parameter instance, a JDOUserException - * is thrown. - */ -public class MakeNontransactionalDirtyInstance extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-28 (MakeNontransactionalDirtyInstance) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeNontransactionalDirtyInstance.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - private PCPoint p6 = null; - private PCPoint p7 = null; + *Title: Make Nontransactional a Dirty Instance + *
    + *Keywords: exception + *
    + *Assertion IDs: A12.5.7-28 + *
    + *Assertion Description: +If PersistenceManager.makeNontransactional or makeNontransactionalAll is called with an explicit dirty parameter instance, a JDOUserException is thrown. - private PCPoint c1 = null; - private PCPoint c2 = null; - private PCPoint c3 = null; - private PCPoint c4 = null; - private PCPoint c5 = null; - private PCPoint c6 = null; - private PCPoint c7 = null; - - private Collection pcol1 = new HashSet(); - private Collection pcol2 = new HashSet(); - private Collection ccol1 = new HashSet(); - private Collection ccol2 = new HashSet(); - - /** */ - public void testMakeNontransactional() { - pm = getPM(); - /* call with an explicit persistent dirty parameter instance */ - String pstate = "persistent"; - createPersistentObjects(pm); - if (debug) logger.debug(" -- testing with persistent dirty instance -- "); - runTestMakeNontransactionalDirtyInstance(pm, p1, pstate); - runTestMakeNontransactionalDirtyInstanceAll1(pm, pcol1, pstate); - runTestMakeNontransactionalDirtyInstanceAll2(pm, pcol2, pstate); - - /* call with an explicit transient dirty parameter instance */ - pstate = "transient"; - createTcleanObjects(pm); - if (debug) logger.debug(" -- testing with transient dirty instance -- "); - runTestMakeNontransactionalDirtyInstance(pm, c1, pstate); - runTestMakeNontransactionalDirtyInstanceAll1(pm, ccol1, pstate); - runTestMakeNontransactionalDirtyInstanceAll2(pm, ccol2, pstate); + */ - pm.close(); - pm = null; - } +public class MakeNontransactionalDirtyInstance extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-28 (MakeNontransactionalDirtyInstance) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeNontransactionalDirtyInstance.class); + } - /** */ - private void createTcleanObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - c1 = new PCPoint(1, 3); - c2 = new PCPoint(2, 4); - c3 = new PCPoint(3, 5); - c4 = new PCPoint(4, 6); - c5 = new PCPoint(5, 7); - c6 = new PCPoint(6, 8); - c7 = new PCPoint(7, 9); + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + private PCPoint p6 = null; + private PCPoint p7 = null; - ccol1.add(c2); - ccol1.add(c3); - ccol1.add(c4); + private PCPoint c1 = null; + private PCPoint c2 = null; + private PCPoint c3 = null; + private PCPoint c4 = null; + private PCPoint c5 = null; + private PCPoint c6 = null; + private PCPoint c7 = null; - ccol2.add(c5); - ccol2.add(c6); - ccol2.add(c7); + private Collection pcol1 = new HashSet(); + private Collection pcol2 = new HashSet(); + private Collection ccol1 = new HashSet(); + private Collection ccol2 = new HashSet(); - pm.makeTransactional(c1); - pm.makeTransactional(c2); - pm.makeTransactional(c3); - pm.makeTransactional(c4); - pm.makeTransactional(c5); - pm.makeTransactional(c6); - pm.makeTransactional(c7); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + public void testMakeNontransactional() { + pm = getPM(); + /* call with an explicit persistent dirty parameter instance */ + String pstate="persistent"; + createPersistentObjects(pm); + if (debug) + logger.debug(" -- testing with persistent dirty instance -- "); + runTestMakeNontransactionalDirtyInstance(pm, p1,pstate); + runTestMakeNontransactionalDirtyInstanceAll1(pm, pcol1, pstate); + runTestMakeNontransactionalDirtyInstanceAll2(pm, pcol2, pstate); + + /* call with an explicit transient dirty parameter instance */ + pstate="transient"; + createTcleanObjects(pm); + if (debug) + logger.debug (" -- testing with transient dirty instance -- "); + runTestMakeNontransactionalDirtyInstance(pm, c1,pstate); + runTestMakeNontransactionalDirtyInstanceAll1(pm, ccol1, pstate); + runTestMakeNontransactionalDirtyInstanceAll2(pm, ccol2, pstate); + + pm.close(); + pm = null; + } + + /** */ + private void createTcleanObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + c1 = new PCPoint(1,3); + c2 = new PCPoint(2,4); + c3 = new PCPoint(3,5); + c4 = new PCPoint(4,6); + c5 = new PCPoint (5,7); + c6 = new PCPoint (6,8); + c7 = new PCPoint (7,9); + + ccol1.add(c2); + ccol1.add(c3); + ccol1.add(c4); + + ccol2.add(c5); + ccol2.add(c6); + ccol2.add(c7); + + pm.makeTransactional(c1); + pm.makeTransactional(c2); + pm.makeTransactional(c3); + pm.makeTransactional(c4); + pm.makeTransactional(c5); + pm.makeTransactional(c6); + pm.makeTransactional(c7); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** */ - private void createPersistentObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - p6 = new PCPoint(6, 8); - p7 = new PCPoint(7, 9); + /** */ + private void createPersistentObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint (5,7); + p6 = new PCPoint (6,8); + p7 = new PCPoint (7,9); - pm.makePersistent(p1); - pm.makePersistent(p2); - pm.makePersistent(p3); - pm.makePersistent(p4); - pm.makePersistent(p5); - pm.makePersistent(p6); - pm.makePersistent(p7); + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + pm.makePersistent(p5); + pm.makePersistent(p6); + pm.makePersistent(p7); - pcol1.add(p2); - pcol1.add(p3); - pcol1.add(p4); + pcol1.add(p2); + pcol1.add(p3); + pcol1.add(p4); - pcol2.add(p5); - pcol2.add(p6); - pcol2.add(p7); - tx.commit(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + pcol2.add(p5); + pcol2.add(p6); + pcol2.add(p7); + tx.commit(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - private void runTestMakeNontransactionalDirtyInstance( - PersistenceManager pm, PCPoint obj, String state) { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in testMakeNontransactionalDirtyInstance()"); - int curr; - tx.begin(); - if (makeAndTestDirtyInstance(obj, state)) { + + /** */ + private void runTestMakeNontransactionalDirtyInstance(PersistenceManager pm, PCPoint obj, String state) { + Transaction tx = pm.currentTransaction(); try { - pm.makeNontransactional(obj); - fail( - ASSERTION_FAILED, - "pm.makeNontransactional should throw a JDOUserException when called for P-DIRTY instance."); - } catch (JDOUserException ex) { - // expected exception + if (debug) + logger.debug(" ** in testMakeNontransactionalDirtyInstance()"); + int curr; + tx.begin(); + if (makeAndTestDirtyInstance(obj,state)) { + try { + pm.makeNontransactional(obj); + fail (ASSERTION_FAILED, + "pm.makeNontransactional should throw a JDOUserException when called for P-DIRTY instance."); + } + catch (JDOUserException ex) { + // expected exception + } + } + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } - /** */ - private void runTestMakeNontransactionalDirtyInstanceAll1( - PersistenceManager pm, Collection tcol, String state) { - Transaction tx = pm.currentTransaction(); - boolean stopFlag = false; - try { - if (debug) logger.debug(" ** in testMakeNontransactionalDirtyInstanceAll1()"); - int curr; - tx.begin(); + /** */ + private void runTestMakeNontransactionalDirtyInstanceAll1(PersistenceManager pm, Collection tcol, String state) { + Transaction tx = pm.currentTransaction(); + boolean stopFlag = false; + try { + if (debug) + logger.debug(" ** in testMakeNontransactionalDirtyInstanceAll1()"); + int curr; + tx.begin(); - Iterator iter = tcol.iterator(); - while (iter.hasNext()) { - PCPoint p = (PCPoint) iter.next(); - if (makeAndTestDirtyInstance(p, state)) stopFlag = true; - } + Iterator iter = tcol.iterator(); + while (iter.hasNext()) { + PCPoint p = (PCPoint) iter.next(); + if (makeAndTestDirtyInstance(p,state)) + stopFlag = true; + } - if (!stopFlag) { - try { - pm.makeNontransactionalAll(tcol); - fail( - ASSERTION_FAILED, - "pm.makeNontransactionalAll(Collection) should throw a JDOUserException when called for a collection including P-DIRTY instances."); - } catch (JDOUserException ex) { - // expected exception + if (! stopFlag) { + try { + pm.makeNontransactionalAll(tcol); + fail (ASSERTION_FAILED, + "pm.makeNontransactionalAll(Collection) should throw a JDOUserException when called for a collection including P-DIRTY instances."); + } + catch (JDOUserException ex) { + // expected exception + } + } + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } - /** */ - private void runTestMakeNontransactionalDirtyInstanceAll2( - PersistenceManager pm, Collection tcol, String state) { - Transaction tx = pm.currentTransaction(); - boolean stopFlag = false; - try { - if (debug) logger.debug(" ** in testMakeNontransactionalDirtyInstanceAll2()"); - tx.begin(); + /** */ + private void runTestMakeNontransactionalDirtyInstanceAll2(PersistenceManager pm, + Collection tcol, + String state) { + Transaction tx = pm.currentTransaction(); + boolean stopFlag = false; + try { + if (debug) + logger.debug(" ** in testMakeNontransactionalDirtyInstanceAll2()"); + tx.begin(); - Iterator iter = tcol.iterator(); - while (iter.hasNext()) { - PCPoint p = (PCPoint) iter.next(); - if (makeAndTestDirtyInstance(p, state)) stopFlag = true; - } + Iterator iter = tcol.iterator(); + while (iter.hasNext()) { + PCPoint p = (PCPoint) iter.next(); + if (makeAndTestDirtyInstance(p,state)) + stopFlag = true; + } - Object[] objArray = tcol.toArray(); + Object[] objArray = tcol.toArray(); - if (!stopFlag) { - try { - pm.makeNontransactionalAll(objArray); - fail( - ASSERTION_FAILED, - "pm.makeNontransactionalAll(Object []) should throw a JDOUserException when called for an arry including P-DIRTY instances."); - } catch (JDOUserException ex) { - // expected exception + if (! stopFlag) { + try { + pm.makeNontransactionalAll(objArray); + fail (ASSERTION_FAILED, + "pm.makeNontransactionalAll(Object []) should throw a JDOUserException when called for an arry including P-DIRTY instances."); + } + catch (JDOUserException ex) { + // expected exception + } + } + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } - /** */ - private boolean makeAndTestDirtyInstance(PCPoint obj, String state) { - int i = obj.getX(); - i = i * 10; + /** */ + private boolean makeAndTestDirtyInstance (PCPoint obj, String state) { + int i = obj.getX(); + i = i*10; - obj.setX(i); - int curr = currentState(obj); + obj.setX(i); + int curr = currentState(obj); - if (state.equals("persistent")) { - if (curr != PERSISTENT_DIRTY) { - fail( - ASSERTION_FAILED, - " Object not in persistent dirty state " - + " for " - + obj.getX() - + " current state: " - + curr); - return false; - } - } else if (state.equals("transient")) { - if (curr != TRANSIENT_DIRTY) { - fail( - ASSERTION_FAILED, - " Object not in transient dirty state " - + " for " - + obj.getX() - + " current state: " - + curr); - return false; - } + if (state.equals("persistent")) { + if ( curr != PERSISTENT_DIRTY ) { + fail(ASSERTION_FAILED, + " Object not in persistent dirty state " + + " for " + obj.getX() + " current state: " + curr); + return false; + } + } + else if (state.equals("transient")) { + if ( curr != TRANSIENT_DIRTY ) { + fail(ASSERTION_FAILED, + " Object not in transient dirty state " + + " for " + obj.getX() + " current state: " + curr); + return false; + } + } + return true; } - return true; - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeNontransactionalIsImmediate.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeNontransactionalIsImmediate.java index 8a84cce0a..5968b9cd0 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeNontransactionalIsImmediate.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeNontransactionalIsImmediate.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,212 +20,226 @@ import java.util.Collection; import java.util.HashSet; import java.util.Iterator; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Make Nontransactional is immediate
    - * Keywords:
    - * Assertion IDs: A12.5.7-29
    - * Assertion Description: The effect of PersistenceManager.makeNontransactional or - * makeNontransactionalAll is immediate and not subject to rollback. + *Title: Make Nontransactional is immediate + *
    + *Keywords: + *
    + *Assertion IDs: A12.5.7-29 + *
    + *Assertion Description: +The effect of PersistenceManager.makeNontransactional or +makeNontransactionalAll is immediate and not subject to rollback. */ + public class MakeNontransactionalIsImmediate extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-29 (MakeNontransactionalIsImmediate) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeNontransactionalIsImmediate.class); + } + + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + private PCPoint p6 = null; + private PCPoint p7 = null; + + private Collection col1 = new HashSet(); + private Collection col2 = new HashSet(); + + /** */ + public void testTransactionalInst() { + pm = getPM(); + + createTcleanObjects(); + runTestMakeNontransactionalIsImmediate(pm); + runTestMakeNontransactionalIsImmediateAll1(pm); + runTestMakeNontransactionalIsImmediateAll2(pm); + + pm.close(); + pm = null; + } - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-29 (MakeNontransactionalIsImmediate) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeNontransactionalIsImmediate.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - private PCPoint p6 = null; - private PCPoint p7 = null; - - private Collection col1 = new HashSet(); - private Collection col2 = new HashSet(); - - /** */ - public void testTransactionalInst() { - pm = getPM(); - - createTcleanObjects(); - runTestMakeNontransactionalIsImmediate(pm); - runTestMakeNontransactionalIsImmediateAll1(pm); - runTestMakeNontransactionalIsImmediateAll2(pm); - - pm.close(); - pm = null; - } - - /** */ - private void createTcleanObjects() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - p6 = new PCPoint(6, 8); - p7 = new PCPoint(7, 9); - - col1.add(p2); - col1.add(p3); - col1.add(p4); - - col2.add(p5); - col2.add(p6); - col2.add(p7); - - pm.makeTransactional(p1); - pm.makeTransactional(p2); - pm.makeTransactional(p3); - pm.makeTransactional(p4); - pm.makeTransactional(p5); - pm.makeTransactional(p6); - pm.makeTransactional(p7); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private void createTcleanObjects() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint (5,7); + p6 = new PCPoint (6,8); + p7 = new PCPoint (7,9); + + col1.add(p2); + col1.add(p3); + col1.add(p4); + + col2.add(p5); + col2.add(p6); + col2.add(p7); + + pm.makeTransactional(p1); + pm.makeTransactional(p2); + pm.makeTransactional(p3); + pm.makeTransactional(p4); + pm.makeTransactional(p5); + pm.makeTransactional(p6); + pm.makeTransactional(p7); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - private void runTestMakeNontransactionalIsImmediate(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in runTestMakeNontransactionalIsImmediate()"); - int curr; - tx.begin(); - - if (testState(p1, TRANSIENT_CLEAN, "transient clean")) { - pm.makeNontransactional(p1); - if (!testState(p1, TRANSIENT, "transient")) { - fail( - ASSERTION_FAILED, - "transient clean instance shoud become transient immediately after pm.makeNontransactional"); + + /** */ + private void runTestMakeNontransactionalIsImmediate(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + if (debug) + logger.debug (" ** in runTestMakeNontransactionalIsImmediate()"); + int curr; + tx.begin(); + + if (testState(p1, TRANSIENT_CLEAN, "transient clean")) { + pm.makeNontransactional(p1); + if (! testState(p1, TRANSIENT, "transient")) { + fail(ASSERTION_FAILED, + "transient clean instance shoud become transient immediately after pm.makeNontransactional"); + } + } + tx.rollback(); + tx = null; + + if (! testState(p1, TRANSIENT, "transient")) { + fail(ASSERTION_FAILED, + "tx.rollback should rollback effect of pm.makeNontransactional"); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - tx.rollback(); - tx = null; - - if (!testState(p1, TRANSIENT, "transient")) { - fail(ASSERTION_FAILED, "tx.rollback should rollback effect of pm.makeNontransactional"); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } - - /** */ - private void runTestMakeNontransactionalIsImmediateAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in runTestMakeNontransactionalIsImmediateAll1()"); - int curr; - tx.begin(); - - if (testState(p2, TRANSIENT_CLEAN, "transient clean") - && testState(p3, TRANSIENT_CLEAN, "transient clean") - && testState(p4, TRANSIENT_CLEAN, "transient clean")) { - - pm.makeNontransactionalAll(col1); - if (!navigateAndTestTransientCol(col1)) { - fail( - ASSERTION_FAILED, - "transient clean instances shoud become transient immediately after pm.makeNontransactionalAll(Collection)"); + + /** */ + private void runTestMakeNontransactionalIsImmediateAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + if (debug) + logger.debug(" ** in runTestMakeNontransactionalIsImmediateAll1()"); + int curr; + tx.begin(); + + if (testState (p2, TRANSIENT_CLEAN, "transient clean") && + testState (p3, TRANSIENT_CLEAN, "transient clean") && + testState (p4, TRANSIENT_CLEAN, "transient clean")) { + + pm.makeNontransactionalAll(col1); + if (! navigateAndTestTransientCol(col1)) { + fail(ASSERTION_FAILED, + "transient clean instances shoud become transient immediately after pm.makeNontransactionalAll(Collection)"); + } + } + + tx.rollback(); + + tx.begin(); + if (! navigateAndTestTransientCol(col1)) { + fail(ASSERTION_FAILED, + "tx.rollback should rollback effect of pm.makeNontransactionalAll(Collection)"); + } + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - - tx.rollback(); - - tx.begin(); - if (!navigateAndTestTransientCol(col1)) { - fail( - ASSERTION_FAILED, - "tx.rollback should rollback effect of pm.makeNontransactionalAll(Collection)"); - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } - - /** */ - private void runTestMakeNontransactionalIsImmediateAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in runTestMakeNontransactionalIsImmediateAll2()"); - int curr; - tx.begin(); - Object[] objArray = col2.toArray(); - - if (testState(p5, TRANSIENT_CLEAN, "transient clean") - && testState(p6, TRANSIENT_CLEAN, "transient clean") - && testState(p7, TRANSIENT_CLEAN, "transient clean")) { - - pm.makeNontransactionalAll(objArray); - if (!navigateAndTestTransientArray(objArray)) { - fail( - ASSERTION_FAILED, - "transient clean instances shoud become transient immediately after pm.makeNontransactionalAll(Object[])"); + + /** */ + private void runTestMakeNontransactionalIsImmediateAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + if (debug) + logger.debug(" ** in runTestMakeNontransactionalIsImmediateAll2()"); + int curr; + tx.begin(); + Object[] objArray = col2.toArray(); + + if (testState (p5, TRANSIENT_CLEAN, "transient clean") && + testState (p6, TRANSIENT_CLEAN, "transient clean") && + testState (p7, TRANSIENT_CLEAN, "transient clean")) { + + pm.makeNontransactionalAll(objArray); + if (! navigateAndTestTransientArray(objArray)) { + fail(ASSERTION_FAILED, + "transient clean instances shoud become transient immediately after pm.makeNontransactionalAll(Object[])"); + } + } + tx.rollback(); + + tx.begin(); + if (! navigateAndTestTransientArray(objArray)) { + fail(ASSERTION_FAILED, + "tx.rollback should rollback effect of pm.makeNontransactionalAll(Object[])"); + } + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - tx.rollback(); - - tx.begin(); - if (!navigateAndTestTransientArray(objArray)) { - fail( - ASSERTION_FAILED, - "tx.rollback should rollback effect of pm.makeNontransactionalAll(Object[])"); - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } - - /** */ - private boolean navigateAndTestTransientCol(Collection col) { - boolean noError = true; - Iterator iter = col1.iterator(); - while (iter.hasNext()) { - PCPoint p = (PCPoint) iter.next(); - if (!testState(p, TRANSIENT, "transient")) { - noError = false; - } + + /** */ + private boolean navigateAndTestTransientCol (Collection col) { + boolean noError = true; + Iterator iter = col1.iterator(); + while (iter.hasNext() ) { + PCPoint p = (PCPoint) iter.next(); + if (! testState(p, TRANSIENT, "transient")) { + noError = false; + } + } + return noError; } - return noError; - } - - /** */ - private boolean navigateAndTestTransientArray(Object[] objArray) { - boolean noError = true; - for (int i = 0; i < objArray.length; i++) { - PCPoint p = (PCPoint) objArray[i]; - if (!testState(p, TRANSIENT, "transient")) { - noError = false; - } + + /** */ + private boolean navigateAndTestTransientArray (Object[] objArray) { + boolean noError = true; + for (int i=0; i < objArray.length; i++) { + PCPoint p = (PCPoint) objArray[i]; + if (! testState(p, TRANSIENT, "transient")) { + noError = false; + } + } + return noError; } - return noError; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeNontransactionalPersistentCleanInstance.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeNontransactionalPersistentCleanInstance.java index ddf3ad06a..63bd66e2f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeNontransactionalPersistentCleanInstance.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeNontransactionalPersistentCleanInstance.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,194 +19,223 @@ import java.util.Collection; import java.util.Iterator; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Make Nontransactional a Persistent-Clean Instance
    - * Keywords: lifecycle
    - * Assertion IDs: A12.5.7-27
    - * Assertion Description: PersistenceManager.makeNontransactional and - * makeNontransactionalAll makes a persistent-clean instance nontransactional and causes a state - * transition to persistent-nontransactional. + *Title: Make Nontransactional a Persistent-Clean Instance + *
    + *Keywords: lifecycle + *
    + *Assertion IDs: A12.5.7-27 + *
    + *Assertion Description: +PersistenceManager.makeNontransactional and makeNontransactionalAll makes a + *persistent-clean instance nontransactional and causes a state transition to + *persistent-nontransactional. */ -public class MakeNontransactionalPersistentCleanInstance extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-27 (MakeNontransactionalPersistentCleanInstance) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeNontransactionalPersistentCleanInstance.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - private PCPoint p6 = null; - private PCPoint p7 = null; - - private Collection col1 = new java.util.HashSet(); - private Collection col2 = new java.util.HashSet(); - - /** */ - public void testTransactionalInstance() { - pm = getPM(); - - createObjects(pm); - runTestMakeNontransactionalPersistentCleanInstance(pm); - runTestMakeNontransactionalPersistentCleanInstanceAll1(pm); - runTestMakeNontransactionalPersistentCleanInstanceAll2(pm); - - pm.close(); - pm = null; - } - - /** */ - private void createObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.setOptimistic(false); - tx.begin(); - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - p6 = new PCPoint(6, 8); - p7 = new PCPoint(7, 9); - - col1.add(p2); - col1.add(p3); - col1.add(p4); - - col2.add(p5); - col2.add(p6); - col2.add(p7); - - pm.makePersistent(p1); - pm.makePersistent(p2); - pm.makePersistent(p3); - pm.makePersistent(p4); - pm.makePersistent(p5); - pm.makePersistent(p6); - pm.makePersistent(p7); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + +public class MakeNontransactionalPersistentCleanInstance + extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-27 (MakeNontransactionalPersistentCleanInstance) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeNontransactionalPersistentCleanInstance.class); + } + + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + private PCPoint p6 = null; + private PCPoint p7 = null; + + private Collection col1 = new java.util.HashSet(); + private Collection col2 = new java.util.HashSet(); + + /** */ + public void testTransactionalInstance() { + pm = getPM(); + + createObjects(pm); + runTestMakeNontransactionalPersistentCleanInstance(pm); + runTestMakeNontransactionalPersistentCleanInstanceAll1(pm); + runTestMakeNontransactionalPersistentCleanInstanceAll2(pm); + + pm.close(); + pm = null; + } + + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.setOptimistic(false); + tx.begin(); + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint (5,7); + p6 = new PCPoint (6,8); + p7 = new PCPoint (7,9); + + col1.add(p2); + col1.add(p3); + col1.add(p4); + + col2.add(p5); + col2.add(p6); + col2.add(p7); + + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + pm.makePersistent(p5); + pm.makePersistent(p6); + pm.makePersistent(p7); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - private void runTestMakeNontransactionalPersistentCleanInstance(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in testMakeNontransactionalPersistentCleanInstance()"); - int curr; - tx.setOptimistic(false); - tx.begin(); - - if (makePersistentCleanInstance(p1)) { - pm.makeNontransactional(p1); - curr = currentState(p1); - - if (curr == HOLLOW || curr == PERSISTENT_NONTRANSACTIONAL) { - } else { - fail( - ASSERTION_FAILED, - "Excpected P-HOLLOW or P-NONTX instance, instance is " + getStateOfInstance(p1)); + + /** */ + private void runTestMakeNontransactionalPersistentCleanInstance( + PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + if (debug) + logger.debug(" ** in testMakeNontransactionalPersistentCleanInstance()"); + int curr; + tx.setOptimistic(false); + tx.begin(); + + if (makePersistentCleanInstance(p1)) { + pm.makeNontransactional(p1); + curr = currentState(p1); + + if (curr == HOLLOW || + curr == PERSISTENT_NONTRANSACTIONAL) { + } + else { + fail(ASSERTION_FAILED, + "Excpected P-HOLLOW or P-NONTX instance, instance is " + + getStateOfInstance(p1)); + } + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } - - /** */ - private void runTestMakeNontransactionalPersistentCleanInstanceAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in testMakeNontransactionalPersistentCleanInstanceAll1()"); - int curr; - - tx.setOptimistic(false); - tx.begin(); - - if (makePersistentCleanInstance(p2) - && makePersistentCleanInstance(p3) - && makePersistentCleanInstance(p4)) { - - pm.makeNontransactionalAll(col1); - Iterator iter = col1.iterator(); - while (iter.hasNext()) { - PCPoint p = (PCPoint) iter.next(); - curr = currentState(p); - if (curr == HOLLOW || curr == PERSISTENT_NONTRANSACTIONAL) { - } else { - fail( - ASSERTION_FAILED, - "Expected persistent-nontransactional or hollow; got " + getStateOfInstance(p)); - } + + /** */ + private void runTestMakeNontransactionalPersistentCleanInstanceAll1( + PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + if (debug) + logger.debug(" ** in testMakeNontransactionalPersistentCleanInstanceAll1()"); + int curr; + + tx.setOptimistic(false); + tx.begin(); + + if ( makePersistentCleanInstance(p2) && + makePersistentCleanInstance(p3) && + makePersistentCleanInstance(p4)) { + + pm.makeNontransactionalAll(col1); + Iterator iter = col1.iterator(); + while (iter.hasNext() ) { + PCPoint p = (PCPoint) iter.next(); + curr = currentState(p); + if (curr == HOLLOW || + curr == PERSISTENT_NONTRANSACTIONAL) { + } + else { + fail(ASSERTION_FAILED, + "Expected persistent-nontransactional or hollow; got " + + getStateOfInstance(p)); + } + } + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + } - } - - /** */ - private void runTestMakeNontransactionalPersistentCleanInstanceAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in testMakeNontransactionalPersistentCleanInstanceAll2()"); - int curr; - if (tx.getOptimistic()) if (debug) logger.debug(" opt flag set to true"); - tx.begin(); - - Object[] objArray = col2.toArray(); - - if (makePersistentCleanInstance(p5) - && makePersistentCleanInstance(p6) - && makePersistentCleanInstance(p7)) { - - pm.makeNontransactionalAll(objArray); - - for (int i = 0; i < objArray.length; i++) { - PCPoint p = (PCPoint) objArray[i]; - curr = currentState(p); - if (curr == HOLLOW || curr == PERSISTENT_NONTRANSACTIONAL) { - } else { - fail( - ASSERTION_FAILED, - "Expected persistent-nontransactional or hollow; got " + getStateOfInstance(p)); - } + + /** */ + private void runTestMakeNontransactionalPersistentCleanInstanceAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + if (debug) + logger.debug(" ** in testMakeNontransactionalPersistentCleanInstanceAll2()"); + int curr; + if (tx.getOptimistic()) + if (debug) logger.debug (" opt flag set to true"); + tx.begin(); + + Object[] objArray = col2.toArray(); + + if ( makePersistentCleanInstance(p5) && + makePersistentCleanInstance(p6) && + makePersistentCleanInstance(p7)) { + + pm.makeNontransactionalAll(objArray); + + for (int i=0; i < objArray.length; i++) { + PCPoint p = (PCPoint) objArray[i]; + curr = currentState(p); + if (curr == HOLLOW || + curr == PERSISTENT_NONTRANSACTIONAL) { + } + else { + fail(ASSERTION_FAILED, + "Expected persistent-nontransactional or hollow; got " + + getStateOfInstance(p)); + } + } + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } - /** */ - private boolean makePersistentCleanInstance(PCPoint obj) { - int val = obj.getX(); - return (testState(obj, PERSISTENT_CLEAN, "persistent clean")); - } + /** */ + private boolean makePersistentCleanInstance (PCPoint obj) { + int val = obj.getX(); + return (testState(obj, PERSISTENT_CLEAN, "persistent clean")); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeNontransactionalTransientCleanInstance.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeNontransactionalTransientCleanInstance.java index 840038815..39c3301d7 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeNontransactionalTransientCleanInstance.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeNontransactionalTransientCleanInstance.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,187 +19,202 @@ import java.util.Collection; import java.util.Iterator; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: MakeNontransactionalTransientCleanInstance
    - * Keywords: lifecycle
    - * Assertion IDs: A12.5.7-26
    - * Assertion Description: PersistenceManager.makeNontransactional and - * makeNontransactionalAll makes a transient-clean instance nontransactional and causes a state - * transition to transient. After the method completes, the instance does not observe transaction - * boundaries. + *Title: MakeNontransactionalTransientCleanInstance + *
    + *Keywords: lifecycle + *
    + *Assertion IDs: A12.5.7-26 + *
    + *Assertion Description: +PersistenceManager.makeNontransactional and makeNontransactionalAll makes a transient-clean instance nontransactional and causes a state transition to transient. After the method completes, the instance does not observe transaction boundaries. */ + public class MakeNontransactionalTransientCleanInstance extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-26 (MakeNontransactionalTransientCleanInstance) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeNontransactionalTransientCleanInstance.class); + } + + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + private PCPoint p6 = null; + private PCPoint p7 = null; + + private Collection col1 = new java.util.HashSet(); + private Collection col2 = new java.util.HashSet(); + + /** */ + public void testTransactionalInst() { + pm = getPM(); + + createTcleanObjects(pm); + runTestMakeNontransactionalTransientCleanInstance(pm); + runTestMakeNontransactionalTransientCleanInstanceAll1(pm); + runTestMakeNontransactionalTransientCleanInstanceAll2(pm); + + pm.close(); + pm = null; + } - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-26 (MakeNontransactionalTransientCleanInstance) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeNontransactionalTransientCleanInstance.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - private PCPoint p6 = null; - private PCPoint p7 = null; - - private Collection col1 = new java.util.HashSet(); - private Collection col2 = new java.util.HashSet(); - - /** */ - public void testTransactionalInst() { - pm = getPM(); - - createTcleanObjects(pm); - runTestMakeNontransactionalTransientCleanInstance(pm); - runTestMakeNontransactionalTransientCleanInstanceAll1(pm); - runTestMakeNontransactionalTransientCleanInstanceAll2(pm); - - pm.close(); - pm = null; - } - - /** */ - private void createTcleanObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx = pm.currentTransaction(); - tx.begin(); - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - p6 = new PCPoint(6, 8); - p7 = new PCPoint(7, 9); - - col1.add(p2); - col1.add(p3); - col1.add(p4); - - col2.add(p5); - col2.add(p6); - col2.add(p7); - - pm.makeTransactional(p1); - pm.makeTransactional(p2); - pm.makeTransactional(p3); - pm.makeTransactional(p4); - pm.makeTransactional(p5); - pm.makeTransactional(p6); - pm.makeTransactional(p7); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private void createTcleanObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx = pm.currentTransaction(); + tx.begin(); + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint (5,7); + p6 = new PCPoint (6,8); + p7 = new PCPoint (7,9); + + col1.add(p2); + col1.add(p3); + col1.add(p4); + + col2.add(p5); + col2.add(p6); + col2.add(p7); + + pm.makeTransactional(p1); + pm.makeTransactional(p2); + pm.makeTransactional(p3); + pm.makeTransactional(p4); + pm.makeTransactional(p5); + pm.makeTransactional(p6); + pm.makeTransactional(p7); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - private void runTestMakeNontransactionalTransientCleanInstance(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in testMakeNontransactionalTransientCleanInstance()"); - int curr; - tx.begin(); - - if (testState(p1, TRANSIENT_CLEAN, "transient clean")) { - pm.makeNontransactional(p1); - - if (testState(p1, TRANSIENT, "transient")) { - // expected result - } else { - fail( - ASSERTION_FAILED, - "expected transient instance after pm.makeNontransactional, instance is " - + getStateOfInstance(p1)); + + /** */ + private void runTestMakeNontransactionalTransientCleanInstance(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + if (debug) + logger.debug(" ** in testMakeNontransactionalTransientCleanInstance()"); + int curr; + tx.begin(); + + if (testState(p1, TRANSIENT_CLEAN, "transient clean")) { + pm.makeNontransactional(p1); + + if (testState(p1, TRANSIENT, "transient")) { + // expected result + } + else { + fail(ASSERTION_FAILED, + "expected transient instance after pm.makeNontransactional, instance is " + + getStateOfInstance(p1)); + } + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } - - /** */ - private void runTestMakeNontransactionalTransientCleanInstanceAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in testMakeNontransactionalTransientCleanInstanceAll1()"); - int curr; - tx.begin(); - - if (testState(p2, TRANSIENT_CLEAN, "transient clean") - && testState(p3, TRANSIENT_CLEAN, "transient clean") - && testState(p4, TRANSIENT_CLEAN, "transient clean")) { - - pm.makeNontransactionalAll(col1); - Iterator iter = col1.iterator(); - while (iter.hasNext()) { - PCPoint p = (PCPoint) iter.next(); - if (testState(p, TRANSIENT, "transient")) { - // expected result - } else { - fail( - ASSERTION_FAILED, - "expected transient instance after pm.makeNontransactionalAll, instance is " - + getStateOfInstance(p)); - } + + /** */ + private void runTestMakeNontransactionalTransientCleanInstanceAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + if (debug) + logger.debug(" ** in testMakeNontransactionalTransientCleanInstanceAll1()"); + int curr; + tx.begin(); + + if (testState(p2, TRANSIENT_CLEAN, "transient clean") && + testState(p3, TRANSIENT_CLEAN, "transient clean") && + testState(p4, TRANSIENT_CLEAN, "transient clean")) { + + pm.makeNontransactionalAll(col1); + Iterator iter = col1.iterator(); + while (iter.hasNext() ) { + PCPoint p = (PCPoint) iter.next(); + if (testState(p, TRANSIENT, "transient")) { + // expected result + } + else { + fail(ASSERTION_FAILED, + "expected transient instance after pm.makeNontransactionalAll, instance is " + + getStateOfInstance(p)); + } + } + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } - - /** */ - private void runTestMakeNontransactionalTransientCleanInstanceAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in testMakeNontransactionalTransientCleanInstanceAll2()"); - int curr; - tx.begin(); - - Object[] objArray = col2.toArray(); - - if (testState(p5, TRANSIENT_CLEAN, "transient clean") - && testState(p6, TRANSIENT_CLEAN, "transient clean") - && testState(p7, TRANSIENT_CLEAN, "transient clean")) { - - pm.makeNontransactionalAll(objArray); - - for (int i = 0; i < objArray.length; i++) { - PCPoint p = (PCPoint) objArray[i]; - if (testState(p, TRANSIENT, "transient")) { - // expected result - } else { - fail( - ASSERTION_FAILED, - "expected transient instance after pm.makeNontransactionalAll, instance is " - + getStateOfInstance(p)); - } + + /** */ + private void runTestMakeNontransactionalTransientCleanInstanceAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + if (debug) + logger.debug (" ** in testMakeNontransactionalTransientCleanInstanceAll2()"); + int curr; + tx.begin(); + + Object[] objArray = col2.toArray(); + + if (testState(p5, TRANSIENT_CLEAN, "transient clean") && + testState(p6, TRANSIENT_CLEAN, "transient clean") && + testState(p7, TRANSIENT_CLEAN, "transient clean")) { + + pm.makeNontransactionalAll(objArray); + + for (int i=0; i < objArray.length; i++) { + PCPoint p = (PCPoint) objArray[i]; + if (testState(p, TRANSIENT, "transient")) { + // expected result + } + else { + fail(ASSERTION_FAILED, + "expected transient instance after pm.makeNontransactionalAll, instance is " + + getStateOfInstance(p)); + } + } + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistent.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistent.java index c03e2ff1f..4e4884a8d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistent.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistent.java @@ -5,201 +5,226 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.lifecycle; import java.util.Collection; import java.util.HashSet; + import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: make instance persistent
    - * Keywords: persistencemanager
    - * Assertion IDs: A12.5.7-6A
    - * Assertion Description: The method PersistenceManager.makePersistent and - * makePersistentAll makes a transient instance(s) persistent directly. It must be - * called in the context of an active transaction, or a JDOUserException is thrown. + *Title: make instance persistent + *
    + *Keywords: persistencemanager + *
    + *Assertion IDs: A12.5.7-6A + *
    + *Assertion Description: +The method PersistenceManager.makePersistent and +makePersistentAll makes a transient instance(s) persistent directly. +It must be called in the context of an active transaction, +or a JDOUserException is thrown. + */ -public class MakePersistent extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A12.5.7-6A (MakePersistent) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakePersistent.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - - /** Overrides parent method to avoid querying for classes that may not exist in the schema */ - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } - - /** */ - public void testMakePersistent() { - pm = getPM(); - - createObjects(); - - /* positive tests */ - runTestMakePersistent1(pm); - runTestMakePersistent2(pm); - runTestMakePersistent3(pm); - - /* negative tests */ - runTestMakePersistent4(pm); - runTestMakePersistent5(pm); - runTestMakePersistent6(pm); - - pm.close(); - pm = null; - } - - /** */ - private void createObjects() { - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - } - - /* test makePersistent (Object pc) */ - private void runTestMakePersistent1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - pm.makePersistent(p1); - tx.commit(); - tx = null; - if (debug) logger.debug(" \nPASSED in runTestMakePersistent1()"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); - } - } - - /* test makePersistentAll (Collection pcs) */ - private void runTestMakePersistent2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Collection col1 = new HashSet(); - col1.add(p2); - col1.add(p3); - - pm.makePersistentAll(col1); - tx.commit(); - tx = null; - if (debug) logger.debug(" \nPASSED in runTestMakePersistent2()"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); - } - } - - /* test makePersistentAll (Object[] o) */ - private void runTestMakePersistent3(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx = pm.currentTransaction(); - tx.begin(); - - Collection col1 = new HashSet(); - col1.add(p1); - col1.add(p2); - - Object[] obj1 = col1.toArray(); - - pm.makePersistentAll(obj1); - tx.commit(); - tx = null; - if (debug) logger.debug(" \nPASSED in runTestMakePersistent3()"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); +public class MakePersistent extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-6A (MakePersistent) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakePersistent.class); } - } - - /* test makePersistent (Object pc) */ - private void runTestMakePersistent4(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - if (tx.isActive()) tx.rollback(); - - PCPoint np1 = new PCPoint(1, 3); - try { - pm.makePersistent(np1); - fail(ASSERTION_FAILED, "pm.makePersistent outside of a tx should throw a JDOUserException"); - } catch (JDOUserException ex) { - // expected expected + + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + + /** + * Overrides parent method to avoid querying for classes + * that may not exist in the schema + */ + protected void localSetUp() { + addTearDownClass(PCPoint.class); } - } - - /* test makePersistentAll (Collection pcs) */ - private void runTestMakePersistent5(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - if (tx.isActive()) tx.rollback(); - - PCPoint np1 = new PCPoint(3, 3); - PCPoint np2 = new PCPoint(4, 4); - - Collection col1 = new HashSet(); - col1.add(np1); - col1.add(np2); - - try { - pm.makePersistentAll(col1); - fail( - ASSERTION_FAILED, - "pm.makePersistentAll(Collection) outside of a tx should throw a JDOUserException"); - } catch (JDOUserException ex) { - // expected expected + + /** */ + public void testMakePersistent() { + pm = getPM(); + + createObjects(); + + /* positive tests */ + runTestMakePersistent1(pm); + runTestMakePersistent2(pm); + runTestMakePersistent3(pm); + + /* negative tests */ + runTestMakePersistent4(pm); + runTestMakePersistent5(pm); + runTestMakePersistent6(pm); + + pm.close(); + pm = null; } - } - /* test makePersistentAll (Object[] o) */ - private void runTestMakePersistent6(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - if (tx.isActive()) tx.rollback(); + /** */ + private void createObjects() { + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint(5,7); + } - PCPoint np1 = new PCPoint(3, 3); - PCPoint np2 = new PCPoint(4, 4); + /* test makePersistent (Object pc) */ + private void runTestMakePersistent1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + pm.makePersistent(p1); + tx.commit(); + tx = null; + if (debug) logger.debug(" \nPASSED in runTestMakePersistent1()"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } - Collection col1 = new HashSet(); - col1.add(np1); - col1.add(np2); + /* test makePersistentAll (Collection pcs) */ + private void runTestMakePersistent2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 = new HashSet(); + col1.add(p2); + col1.add(p3); + + pm.makePersistentAll(col1); + tx.commit(); + tx = null; + if (debug) logger.debug(" \nPASSED in runTestMakePersistent2()"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /* test makePersistentAll (Object[] o) */ + private void runTestMakePersistent3(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx = pm.currentTransaction(); + tx.begin(); + + Collection col1 = new HashSet(); + col1.add(p1); + col1.add(p2); + + Object[] obj1= col1.toArray(); + + pm.makePersistentAll(obj1); + tx.commit(); + tx = null; + if (debug) logger.debug (" \nPASSED in runTestMakePersistent3()"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /* test makePersistent (Object pc) */ + private void runTestMakePersistent4(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + if (tx.isActive()) + tx.rollback(); + + PCPoint np1 = new PCPoint(1,3); + try { + pm.makePersistent(np1); + fail(ASSERTION_FAILED, + "pm.makePersistent outside of a tx should throw a JDOUserException"); + } + catch (JDOUserException ex) { + // expected expected + } + } - Object[] obj1 = col1.toArray(); + /* test makePersistentAll (Collection pcs) */ + private void runTestMakePersistent5(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + if (tx.isActive()) + tx.rollback(); + + PCPoint np1 = new PCPoint (3,3); + PCPoint np2 = new PCPoint (4,4); + + Collection col1 = new HashSet(); + col1.add(np1); + col1.add(np2); + + try { + pm.makePersistentAll(col1); + fail(ASSERTION_FAILED, + "pm.makePersistentAll(Collection) outside of a tx should throw a JDOUserException"); + } + catch (JDOUserException ex) { + // expected expected + } + } - try { - pm.makePersistentAll(obj1); - fail( - ASSERTION_FAILED, - "pm.makePersistentAll(Object[]) outside of a tx should throw a JDOUserException"); - } catch (JDOUserException ex) { - // expected expected + /* test makePersistentAll (Object[] o) */ + private void runTestMakePersistent6(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + if (tx.isActive()) + tx.rollback(); + + PCPoint np1 = new PCPoint (3,3); + PCPoint np2 = new PCPoint (4,4); + + Collection col1 = new HashSet(); + col1.add(np1); + col1.add(np2); + + Object[] obj1=col1.toArray(); + + try { + pm.makePersistentAll(obj1); + fail(ASSERTION_FAILED, + "pm.makePersistentAll(Object[]) outside of a tx should throw a JDOUserException"); + } + catch (JDOUserException ex) { + // expected expected + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentAllFails.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentAllFails.java index 54c15c001..9c94bf461 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentAllFails.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentAllFails.java @@ -5,123 +5,129 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.lifecycle; import java.util.Collection; + import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.pc.mylib.Point; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: MakePersistentAll Fails
    - * Keywords: exception
    - * Assertion IDs: A12.5.7-1.
    - * Assertion Description: If a collection or array of instances is passed to - * PersistenceManager.makePersistentAll, and one or more of the instances fail to complete the - * operation, then all instances will be attempted, and a JDOUserException will be thrown which - * contains a nested exception array, each exception of which contains one of the failing instances. - * The succeeding instances will transition to the specified life cycle state, and the failing - * instances will remain in their current state. + *Title: MakePersistentAll Fails + *
    + *Keywords: exception + *
    + *Assertion IDs: A12.5.7-1. + *
    + *Assertion Description: +If a collection or array of instances is passed to PersistenceManager.makePersistentAll, and one or more of the instances fail to complete the operation, then all instances will be attempted, and a JDOUserException will be thrown which contains a nested exception array, each exception of which contains one of the failing instances. The succeeding instances will transition to the specified life cycle state, and the failing instances will remain in their current state. */ -public class MakePersistentAllFails extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-1 (MakePersistentAllFails) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakePersistentAllFails.class); - } - - /** */ - public void testMakePersistentAllFails() { - pm = getPM(); - - runTestMakePersistentAllFails1(pm); - runTestMakePersistentAllFails2(pm); - pm.close(); - pm = null; - } - - /* test makePersistentAll (Collection pcs) */ - private void runTestMakePersistentAllFails1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - PCPoint np1 = new PCPoint(3, 3); - PCPoint np2 = new PCPoint(4, 4); - Point np3 = new Point(5, 5); - - Collection col1 = new java.util.HashSet(); - col1.add(np1); - col1.add(np2); - col1.add(np3); - - try { - pm.makePersistentAll(col1); - fail( - ASSERTION_FAILED, - "pm.makePersistentAll(Collection) should thro JDOUserException when called for collection including instance of non-pc class."); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); +public class MakePersistentAllFails extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-1 (MakePersistentAllFails) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakePersistentAllFails.class); } - } - /* test makePersistentAll (Object[] o) */ - private void runTestMakePersistentAllFails2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - PCPoint np1 = new PCPoint(3, 3); - PCPoint np2 = new PCPoint(4, 4); - Point np3 = new Point(5, 5); - - Collection col1 = new java.util.HashSet(); - col1.add(np1); - col1.add(np2); - col1.add(np3); - - Object[] obj1 = col1.toArray(); + /** */ + public void testMakePersistentAllFails() { + pm = getPM(); + + runTestMakePersistentAllFails1(pm); + runTestMakePersistentAllFails2(pm); + + pm.close(); + pm = null; + } - try { - pm.makePersistentAll(obj1); - fail( - ASSERTION_FAILED, - "pm.makePersistentAll(Object[]) should thro JDOUserException when called for array including instance of non-pc class "); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /* test makePersistentAll (Collection pcs) */ + private void runTestMakePersistentAllFails1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + PCPoint np1 = new PCPoint (3,3); + PCPoint np2 = new PCPoint (4,4); + Point np3 = new Point (5,5); + + Collection col1 = new java.util.HashSet(); + col1.add(np1); + col1.add(np2); + col1.add(np3); + + try { + pm.makePersistentAll(col1); + fail(ASSERTION_FAILED, + "pm.makePersistentAll(Collection) should thro JDOUserException when called for collection including instance of non-pc class."); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /* test makePersistentAll (Object[] o) */ + private void runTestMakePersistentAllFails2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + PCPoint np1 = new PCPoint (3,3); + PCPoint np2 = new PCPoint (4,4); + Point np3 = new Point (5,5); + + Collection col1 = new java.util.HashSet(); + col1.add(np1); + col1.add(np2); + col1.add(np3); + + Object[] obj1=col1.toArray(); + + try { + pm.makePersistentAll(obj1); + fail(ASSERTION_FAILED, + "pm.makePersistentAll(Object[]) should thro JDOUserException when called for array including instance of non-pc class "); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentAndInstancesNotReachable.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentAndInstancesNotReachable.java index 6c22b1c8d..9a1c4f753 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentAndInstancesNotReachable.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentAndInstancesNotReachable.java @@ -5,21 +5,23 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.lifecycle; import java.util.Date; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; import org.apache.jdo.tck.pc.company.Address; import org.apache.jdo.tck.pc.company.Company; @@ -27,90 +29,93 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: MakePersistent And Instances Not Reachable
    - * Keywords:
    - * Assertion ID: A12.5.7-6C.
    - * Assertion Description: When calling PersistenceManager.makePersistent or - * makePersistentAll, transient instances will become persistent and any transient - * instances reachable via persistent fields will become provisionally persistent. That is, they - * behave as persistent-new instances (return true to isPersistent, isNew, and isDirty). But at - * commit time, the reachability algorithm is run again, and instances made provisionally persistent - * that are not currently reachable from persistent instances will revert to transient. + *Title: MakePersistent And Instances Not Reachable + *
    + *Keywords: + *
    + *Assertion ID: A12.5.7-6C. + *
    + *Assertion Description: +When calling PersistenceManager.makePersistent or makePersistentAll, +transient instances will become persistent and any transient instances reachable via persistent +fields will become provisionally persistent. That is, they behave as persistent-new instances +(return true to isPersistent, isNew, and isDirty). +But at commit time, the reachability algorithm is run again, +and instances made provisionally persistent that are not +currently reachable from persistent instances will revert to transient. */ -public class MakePersistentAndInstancesNotReachable extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-6C (MakePersistentAndInstancesNotReachable) failed: "; - private Department dep1 = null; - private Department dep2 = null; - private Department dep3 = null; +public class MakePersistentAndInstancesNotReachable extends PersistenceManagerTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakePersistentAndInstancesNotReachable.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-6C (MakePersistentAndInstancesNotReachable) failed: "; + + private Department dep1 = null; + private Department dep2 = null; + private Department dep3 = null; - /** */ - public void test() { - pm = getPM(); - createObjects(pm); - runTest(pm); - } - - /** */ - private void createObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - tx.begin(); - Company comp = - new Company(1L, "Sun Microsystems", new Date(), new Address(0, "", "", "", "", "")); - // Add transient departments - dep1 = new Department(1L, "Department 1"); - dep2 = new Department(2L, "Department 1"); - dep3 = new Department(3L, "Department 1"); - comp.addDepartment(dep1); - comp.addDepartment(dep2); - comp.addDepartment(dep3); - pm.makePersistent( - comp); // Now the transient departments should be made provisionally persistent via - // reachability - int curr = currentState(dep1); - if (curr != PERSISTENT_NEW) { - fail(ASSERTION_FAILED, "dep1 should be persistent-new, state is " + states[curr]); - } - curr = currentState(dep2); - if (curr != PERSISTENT_NEW) { - fail(ASSERTION_FAILED, "dep2 should be persistent-new, state is " + states[curr]); - } - curr = currentState(dep3); - if (curr != PERSISTENT_NEW) { - fail(ASSERTION_FAILED, "dep3 should be persistent-new, state is " + states[curr]); + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakePersistentAndInstancesNotReachable.class); } - // Remove departments - comp.removeDepartment(dep1); - comp.removeDepartment(dep2); - comp.removeDepartment(dep3); - tx.commit(); // Now the removed departments should be made transient again + + /** */ + public void test() { + pm = getPM(); + createObjects(pm); + runTest(pm); } - /** */ - void runTest(PersistenceManager pm) { - int curr = currentState(dep1); - if (curr != TRANSIENT) { - fail(ASSERTION_FAILED, "dep1 should be transient, state is " + states[curr]); + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + tx.begin(); + Company comp = new Company(1L, "Sun Microsystems", new Date(), new Address(0,"","","","","")); + //Add transient departments + dep1 = new Department(1L, "Department 1"); + dep2 = new Department(2L, "Department 1"); + dep3 = new Department(3L, "Department 1"); + comp.addDepartment(dep1); + comp.addDepartment(dep2); + comp.addDepartment(dep3); + pm.makePersistent(comp); //Now the transient departments should be made provisionally persistent via reachability + int curr = currentState(dep1); + if( curr != PERSISTENT_NEW ){ + fail(ASSERTION_FAILED, "dep1 should be persistent-new, state is " + states[curr]); + } + curr = currentState(dep2); + if( curr != PERSISTENT_NEW ){ + fail(ASSERTION_FAILED, "dep2 should be persistent-new, state is " + states[curr]); + } + curr = currentState(dep3); + if( curr != PERSISTENT_NEW ){ + fail(ASSERTION_FAILED, "dep3 should be persistent-new, state is " + states[curr]); + } + //Remove departments + comp.removeDepartment(dep1); + comp.removeDepartment(dep2); + comp.removeDepartment(dep3); + tx.commit(); //Now the removed departments should be made transient again } - curr = currentState(dep2); - if (curr != TRANSIENT) { - fail(ASSERTION_FAILED, "dep2 should be transient, state is " + states[curr]); - } - curr = currentState(dep3); - if (curr != TRANSIENT) { - fail(ASSERTION_FAILED, "dep3 should be transient, state is " + states[curr]); + + /** */ + void runTest(PersistenceManager pm) { + int curr = currentState(dep1); + if( curr != TRANSIENT ){ + fail(ASSERTION_FAILED, "dep1 should be transient, state is " + states[curr]); + } + curr = currentState(dep2); + if( curr != TRANSIENT ){ + fail(ASSERTION_FAILED, "dep2 should be transient, state is " + states[curr]); + } + curr = currentState(dep3); + if( curr != TRANSIENT ){ + fail(ASSERTION_FAILED, "dep3 should be transient, state is " + states[curr]); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentAssignsObjectId.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentAssignsObjectId.java index d420fba4a..8eb556daa 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentAssignsObjectId.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentAssignsObjectId.java @@ -5,165 +5,181 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.lifecycle; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; -import javax.jdo.PersistenceManager; + import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; +import javax.jdo.PersistenceManager; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: make instance persistent
    - * Keywords: identity
    - * Assertion IDs: A12.5.7-6B
    - * Assertion Description: The method PersistenceManager.makePersistent and makePersistentAll - * will assign an object identity to the instance and transitions it to persistent-new. + *Title: make instance persistent + *
    + *Keywords: identity + *
    + *Assertion IDs: A12.5.7-6B + *
    + *Assertion Description: +The method PersistenceManager.makePersistent and +makePersistentAll will assign an object identity to the instance +and transitions it to persistent-new. + */ -public class MakePersistentAssignsObjectId extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-6B (MakePersistentAssignsObjectId) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakePersistentAssignsObjectId.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - - /** */ - public void testMakePersistentAssignsObjectId() { - pm = getPM(); - - createObjects(); - - /* positive tests */ - runTestMakePersistentAssignsObjectId1(pm); - runTestMakePersistentAssignsObjectId2(pm); - runTestMakePersistentAssignsObjectId3(pm); - - pm.close(); - pm = null; - } - - /** */ - private void createObjects() { - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - } - - /* test makePersistent (Object pc) */ - private void runTestMakePersistentAssignsObjectId1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - pm.makePersistent(p1); - - if (!testState(p1, PERSISTENT_NEW, "persistent_new")) { - fail( - ASSERTION_FAILED, - "expected P-NEW instance, instance is " + getStateOfInstance(p1) + "."); - } - if (pm.getObjectId(p1) == null) { - fail(ASSERTION_FAILED, "pm.makePersistent should assign non-null oid."); - } - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); +public class MakePersistentAssignsObjectId extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-6B (MakePersistentAssignsObjectId) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakePersistentAssignsObjectId.class); } - } - - /* test makePersistentAll (Collection pcs) */ - private void runTestMakePersistentAssignsObjectId2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Collection col1 = new HashSet(); - col1.add(p2); - col1.add(p3); - - pm.makePersistentAll(col1); - - for (Iterator i = col1.iterator(); i.hasNext(); ) { - PCPoint p = (PCPoint) i.next(); - if (!testState(p, PERSISTENT_NEW, "persistent_new")) { - fail( - ASSERTION_FAILED, - "expected P-NEW instance, instance is " + getStateOfInstance(p) + "."); - } - if (pm.getObjectId(p) == null) { - fail(ASSERTION_FAILED, "pm.makePersistentAll should assign non-null oid."); - } - } + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + + /** */ + public void testMakePersistentAssignsObjectId() { + pm = getPM(); + + createObjects(); + + /* positive tests */ + runTestMakePersistentAssignsObjectId1(pm); + runTestMakePersistentAssignsObjectId2(pm); + runTestMakePersistentAssignsObjectId3(pm); + + pm.close(); + pm = null; + } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private void createObjects() { + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint(5,7); } - } - - /* test makePersistentAll (Object[] o) */ - private void runTestMakePersistentAssignsObjectId3(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - int NUM_OBJS = 2; - tx.begin(); - - Collection col1 = new HashSet(); - col1.add(p4); - col1.add(p5); - - Object[] obj1 = col1.toArray(); - - pm.makePersistentAll(obj1); - for (int i = 0; i < NUM_OBJS; i++) { - PCPoint p = (PCPoint) obj1[i]; - if (!testState(p, PERSISTENT_NEW, "persistent_new")) { - fail( - ASSERTION_FAILED, - "expected P-NEW instance, instance is " + getStateOfInstance(p) + "."); + + /* test makePersistent (Object pc) */ + private void runTestMakePersistentAssignsObjectId1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + pm.makePersistent(p1); + + if (!testState(p1, PERSISTENT_NEW, "persistent_new")) { + fail(ASSERTION_FAILED, + "expected P-NEW instance, instance is " + getStateOfInstance(p1) + "."); + } + if (pm.getObjectId(p1) == null) { + fail(ASSERTION_FAILED, + "pm.makePersistent should assign non-null oid."); + } + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } + } - if (pm.getObjectId(p) == null) { - fail(ASSERTION_FAILED, "pm.makePersistentAll should assign non-null oid."); + /* test makePersistentAll (Collection pcs) */ + private void runTestMakePersistentAssignsObjectId2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 = new HashSet(); + col1.add(p2); + col1.add(p3); + + pm.makePersistentAll(col1); + + for (Iterator i = col1.iterator(); i.hasNext();) { + PCPoint p = (PCPoint)i.next(); + if (!testState(p, PERSISTENT_NEW, "persistent_new")) { + fail(ASSERTION_FAILED, + "expected P-NEW instance, instance is " + getStateOfInstance(p) + "."); + } + + if (pm.getObjectId(p) == null) { + fail(ASSERTION_FAILED, + "pm.makePersistentAll should assign non-null oid."); + } + } + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } + } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /* test makePersistentAll (Object[] o) */ + private void runTestMakePersistentAssignsObjectId3(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + int NUM_OBJS = 2; + tx.begin(); + + Collection col1 = new HashSet(); + col1.add(p4); + col1.add(p5); + + Object[] obj1= col1.toArray(); + + pm.makePersistentAll(obj1); + for (int i = 0; i < NUM_OBJS; i++) { + PCPoint p = (PCPoint)obj1[i]; + if (!testState(p, PERSISTENT_NEW, "persistent_new")) { + fail(ASSERTION_FAILED, + "expected P-NEW instance, instance is " + getStateOfInstance(p) + "."); + } + + if (pm.getObjectId(p) == null) { + fail(ASSERTION_FAILED, + "pm.makePersistentAll should assign non-null oid."); + } + } + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentFailsIfInstanceManagedByAnotherPersistenceManager.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentFailsIfInstanceManagedByAnotherPersistenceManager.java index a0dbe4b51..5a2ced6ff 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentFailsIfInstanceManagedByAnotherPersistenceManager.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentFailsIfInstanceManagedByAnotherPersistenceManager.java @@ -5,166 +5,182 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.lifecycle; import java.util.Collection; + import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: MakePersistent Fails If Instance Managed By Another PersistenceManager
    - * Keywords: exception
    - * Assertion IDs: A12.5.7-8.
    - * Assertion Description: PersistenceManager.makePersistent and makePersistentAll will throw - * a JDOUserException if the parameter instance is managed by a different PersistenceManager. + *Title: MakePersistent Fails If Instance Managed By Another PersistenceManager + *
    + *Keywords: exception + *
    + *Assertion IDs: A12.5.7-8. + *
    + *Assertion Description: +PersistenceManager.makePersistent and makePersistentAll will throw a JDOUserException if the parameter instance is managed by a different PersistenceManager. + */ -public class MakePersistentFailsIfInstanceManagedByAnotherPersistenceManager - extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-8 (MakePersistentFailsIfInstanceManagedByAnotherPersistenceManager) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakePersistentFailsIfInstanceManagedByAnotherPersistenceManager.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - - /** */ - public void testMakePersistentFailsIfInstanceManagedByAnotherPersistenceManager() { - pm = getPM(); - - PersistenceManager pm2 = getPMF().getPersistenceManager(); - try { - createObjects(pm2); - - /* positive tests */ - runTestMakePersistent(pm); - runTestMakePersistentAll1(pm); - runTestMakePersistentAll2(pm); - } finally { - cleanupPM(pm2); - pm2 = null; - cleanupPM(pm); - pm = null; + +public class MakePersistentFailsIfInstanceManagedByAnotherPersistenceManager extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-8 (MakePersistentFailsIfInstanceManagedByAnotherPersistenceManager) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakePersistentFailsIfInstanceManagedByAnotherPersistenceManager.class); } - } - - /** */ - private void createObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - - pm.makePersistent(p1); - pm.makePersistent(p2); - pm.makePersistent(p3); - pm.makePersistent(p4); - pm.makePersistent(p5); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + + /** */ + public void testMakePersistentFailsIfInstanceManagedByAnotherPersistenceManager() { + pm = getPM(); + + PersistenceManager pm2 = getPMF().getPersistenceManager(); + try { + createObjects(pm2); + + /* positive tests */ + runTestMakePersistent(pm); + runTestMakePersistentAll1(pm); + runTestMakePersistentAll2(pm); + } + finally { + cleanupPM(pm2); + pm2 = null; + cleanupPM(pm); + pm = null; + } + } + + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint(5,7); + + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + pm.makePersistent(p5); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /* test makePersistent (Object pc) */ - private void runTestMakePersistent(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - try { - pm.makePersistent(p1); - fail( - ASSERTION_FAILED, - "pm.makePersistent should throw JDOUserException if instance is already made persistence by different pm."); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /* test makePersistent (Object pc) */ + private void runTestMakePersistent(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + try { + pm.makePersistent(p1); + fail(ASSERTION_FAILED, + "pm.makePersistent should throw JDOUserException if instance is already made persistence by different pm."); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /* test makePersistentAll (Collection pcs) */ - private void runTestMakePersistentAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Collection col1 = new java.util.HashSet(); - col1.add(p2); - col1.add(p3); - - try { - pm.makePersistentAll(col1); - fail( - ASSERTION_FAILED, - "pm.makePersistentAll(Collection) should throw JDOUserException if instance is already made persistence by different pm."); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /* test makePersistentAll (Collection pcs) */ + private void runTestMakePersistentAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 = new java.util.HashSet(); + col1.add(p2); + col1.add(p3); + + try { + pm.makePersistentAll(col1); + fail(ASSERTION_FAILED, + "pm.makePersistentAll(Collection) should throw JDOUserException if instance is already made persistence by different pm."); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /* test makePersistentAll (Object[] o) */ - private void runTestMakePersistentAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Collection col1 = new java.util.HashSet(); - col1.add(p4); - col1.add(p5); - Object[] obj1 = col1.toArray(); - - try { - pm.makePersistentAll(obj1); - fail( - ASSERTION_FAILED, - "pm.makePersistentAll(Object[]) should throw JDOUserException if instance is already made persistence by different pm."); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /* test makePersistentAll (Object[] o) */ + private void runTestMakePersistentAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 = new java.util.HashSet(); + col1.add(p4); + col1.add(p5); + Object[] obj1= col1.toArray(); + + try { + pm.makePersistentAll(obj1); + fail(ASSERTION_FAILED, + "pm.makePersistentAll(Object[]) should throw JDOUserException if instance is already made persistence by different pm."); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentHasNoEffectOnPersistentInstances.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentHasNoEffectOnPersistentInstances.java index 7cb2075bf..f55742188 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentHasNoEffectOnPersistentInstances.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentHasNoEffectOnPersistentInstances.java @@ -5,145 +5,163 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.lifecycle; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: MakePersistent Has No Effect On Persistent Instances
    - * Keywords:
    - * Assertion IDs: A12.5.7-7.
    - * Assertion Description: PersistenceManager.makePersistent and makePersistentAll have no - * effect on parameter persistent instances already managed by the same PersistenceManager. + *Title: MakePersistent Has No Effect On Persistent Instances + *
    + *Keywords: + *
    + *Assertion IDs: A12.5.7-7. + *
    + *Assertion Description: +PersistenceManager.makePersistent and makePersistentAll have no effect on + *parameter persistent instances already managed by the same PersistenceManager. + */ -public class MakePersistentHasNoEffectOnPersistentInstances extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-7 (MakePersistentHasNoEffectOnPersistentInstances) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakePersistentHasNoEffectOnPersistentInstances.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - - /** */ - public void testMakePersistentHasNoEffectOnPersistentInstances() { - pm = getPM(); - - createObjects(pm); - - runTestMakePersistent(pm); - runTestMakePersistentAll1(pm); - runTestMakePersistentAll2(pm); - - pm.close(); - pm = null; - } - - /** */ - private void createObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + +public class MakePersistentHasNoEffectOnPersistentInstances + extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-7 (MakePersistentHasNoEffectOnPersistentInstances) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakePersistentHasNoEffectOnPersistentInstances.class); + } + + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + + /** */ + public void testMakePersistentHasNoEffectOnPersistentInstances() { + pm = getPM(); + + createObjects(pm); + + runTestMakePersistent(pm); + runTestMakePersistentAll1(pm); + runTestMakePersistentAll2(pm); + + pm.close(); + pm = null; + } + + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint(5,7); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /* test makePersistent (Object pc) */ - private void runTestMakePersistent(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx = pm.currentTransaction(); - tx.begin(); - pm.makePersistent(p1); - pm.makePersistent(p1); - pm.makePersistent(p1); - pm.makePersistent(p1); - tx.commit(); - tx = null; - if (debug) logger.debug(" \nPASSED in runTestMakePersistent()"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /* test makePersistent (Object pc) */ + private void runTestMakePersistent(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx = pm.currentTransaction(); + tx.begin(); + pm.makePersistent(p1); + pm.makePersistent(p1); + pm.makePersistent(p1); + pm.makePersistent(p1); + tx.commit(); + tx = null; + if (debug) logger.debug (" \nPASSED in runTestMakePersistent()"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /* test makePersistentAll (Collection pcs) */ - private void runTestMakePersistentAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Collection col1 = new java.util.HashSet(); - col1.add(p2); - col1.add(p3); - - pm.makePersistentAll(col1); - pm.makePersistentAll(col1); - pm.makePersistentAll(col1); - pm.makePersistentAll(col1); - tx.commit(); - tx = null; - if (debug) logger.debug(" \nPASSED in runTestMakePersistentAll1()"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /* test makePersistentAll (Collection pcs) */ + private void runTestMakePersistentAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 = new java.util.HashSet(); + col1.add(p2); + col1.add(p3); + + pm.makePersistentAll(col1); + pm.makePersistentAll(col1); + pm.makePersistentAll(col1); + pm.makePersistentAll(col1); + tx.commit(); + tx = null; + if (debug) logger.debug (" \nPASSED in runTestMakePersistentAll1()"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /* test makePersistentAll (Object[] o) */ - private void runTestMakePersistentAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Collection col1 = new java.util.HashSet(); - col1.add(p1); - col1.add(p2); - - Object[] obj1 = col1.toArray(); - - pm.makePersistentAll(obj1); - pm.makePersistentAll(obj1); - pm.makePersistentAll(obj1); - pm.makePersistentAll(obj1); - tx.commit(); - tx = null; - if (debug) logger.debug(" \nPASSED in runTestMakePersistentAll2()"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /* test makePersistentAll (Object[] o) */ + private void runTestMakePersistentAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 = new java.util.HashSet(); + col1.add(p1); + col1.add(p2); + + Object[] obj1= col1.toArray(); + + pm.makePersistentAll(obj1); + pm.makePersistentAll(obj1); + pm.makePersistentAll(obj1); + pm.makePersistentAll(obj1); + tx.commit(); + tx = null; + if (debug) logger.debug (" \nPASSED in runTestMakePersistentAll2()"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactional.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactional.java index f2f123437..fae458864 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactional.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactional.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,135 +19,150 @@ import java.util.Collection; import java.util.Iterator; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: MakeTransactional
    - * Keywords: transienttransactional lifecycle
    - * Assertion IDs: A12.5.7-20
    - * Assertion Description: PersistenceManager.makeTransactional and makeTransactionalAll - * makes a transient instance transactional and causes a state transition to transient-clean. After - * the method completes, the instance observes transaction boundaries. - */ -public class MakeTransactional extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-20 (MakeTransactional) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeTransactional.class); - } - - private PCPoint p = null; - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - - /** */ - public void testTransactionalInst() { - pm = getPM(); - - createObjects(); - testMakeTransactional(pm); - testMakeTransactionalAll1(pm); - testMakeTransactionalAll2(pm); - - pm.close(); - pm = null; - } + *Title: MakeTransactional + *
    + *Keywords: transienttransactional lifecycle + *
    + *Assertion IDs: A12.5.7-20 + *
    + *Assertion Description: +PersistenceManager.makeTransactional and makeTransactionalAll makes a transient instance transactional and causes a state transition to transient-clean. After the method completes, the instance observes transaction boundaries. - /** */ - private void createObjects() { - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - } + */ - /** - * @param pm the PersistenceManager - */ - public void testMakeTransactional(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - pm.makeTransactional(p1); - if (currentState(p1) != TRANSIENT_CLEAN) { - fail( - ASSERTION_FAILED, - "Expected T-CLEAN instance, instance is " + getStateOfInstance(p1) + "."); - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); +public class MakeTransactional extends PersistenceManagerTest{ + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-20 (MakeTransactional) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeTransactional.class); + } + + private PCPoint p = null; + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + + /** */ + public void testTransactionalInst() { + pm = getPM(); + + createObjects(); + testMakeTransactional(pm); + testMakeTransactionalAll1(pm); + testMakeTransactionalAll2(pm); + + pm.close(); + pm = null; } - } - - /** - * @param pm the PersistenceManager - */ - public void testMakeTransactionalAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Collection col1 = new java.util.HashSet(); - col1.add(p1); - col1.add(p2); - col1.add(p3); - col1.add(p4); + /** */ + private void createObjects() { + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + } - pm.makeTransactionalAll(col1); - Iterator iter = col1.iterator(); - while (iter.hasNext()) { - PCPoint p = (PCPoint) iter.next(); - if (currentState(p) != TRANSIENT_CLEAN) { - fail( - ASSERTION_FAILED, - "Expected T-CLEAN instance, instance " + p + " is " + getStateOfInstance(p1) + "."); + /** + * + * @param pm the PersistenceManager + */ + public void testMakeTransactional(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + pm.makeTransactional(p1); + if (currentState(p1) != TRANSIENT_CLEAN) { + fail(ASSERTION_FAILED, + "Expected T-CLEAN instance, instance is " + + getStateOfInstance(p1) + "."); + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } - /** */ - private void testMakeTransactionalAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Object[] objArray = {p1, p2, p3, p4}; - pm.makeTransactionalAll(objArray); + /** + * + * @param pm the PersistenceManager + */ + public void testMakeTransactionalAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 = new java.util.HashSet(); + col1.add(p1); + col1.add(p2); + col1.add(p3); + col1.add(p4); + + pm.makeTransactionalAll(col1); + Iterator iter = col1.iterator(); + while (iter.hasNext() ) { + PCPoint p = (PCPoint) iter.next(); + if (currentState(p) != TRANSIENT_CLEAN) { + fail(ASSERTION_FAILED, + "Expected T-CLEAN instance, instance " + p + " is " + + getStateOfInstance(p1) + "."); + } + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } - for (int i = 0; i < objArray.length; i++) { - p = (PCPoint) objArray[i]; - if (currentState(p) != TRANSIENT_CLEAN) { - fail( - ASSERTION_FAILED, - "Expected T-CLEAN instance, instance " + p + " is " + getStateOfInstance(p1) + "."); + /** */ + private void testMakeTransactionalAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Object[] objArray = {p1,p2,p3,p4}; + pm.makeTransactionalAll(objArray); + + for ( int i=0; i < objArray.length; i++) { + p = (PCPoint) objArray[i]; + if (currentState(p) != TRANSIENT_CLEAN) { + fail(ASSERTION_FAILED, + "Expected T-CLEAN instance, instance " + p + " is " + + getStateOfInstance(p1) + "."); + } + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalANontransactionalPersistentInstance.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalANontransactionalPersistentInstance.java index 81f033181..8d9472c1b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalANontransactionalPersistentInstance.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalANontransactionalPersistentInstance.java @@ -5,292 +5,312 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.lifecycle; import java.util.Collection; + import javax.jdo.JDOUserException; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Make Transactional A Persistent Nontransactional Instance
    - * Keywords: persistentnontransactional
    - * Assertion IDs: A12.5.7-24
    - * Assertion Description: PersistenceManager.makeTransactional and makeTransactionalAll can - * be used to mark a nontransactional persistent instance as being part of the read-consistency set - * of the transaction. In this case, the call must be made in the context of an active transaction, - * or a JDOUserException is thrown. To test this, get an instance in the - * persistence-nontransactional state, make it transactional, then in a different transaction commit - * a change to the instance. An exception should then be thrown when the first transaction commits. + *Title: Make Transactional A Persistent Nontransactional Instance + *
    + *Keywords: persistentnontransactional + *
    + *Assertion IDs: A12.5.7-24 + *
    + *Assertion Description: +PersistenceManager.makeTransactional and makeTransactionalAll can be used to mark a nontransactional persistent instance as being part of the read-consistency set of the transaction. In this case, the call must be made in the context of an active transaction, or a JDOUserException is thrown. To test this, get an instance in the persistence-nontransactional state, make it transactional, then in a +different transaction commit a change to the instance. An exception should then be thrown when the first transaction commits. + */ -public class MakeTransactionalANontransactionalPersistentInstance extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-24 (MakeTransactionalANontransactionalPersistentInstance) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeTransactionalANontransactionalPersistentInstance.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - private PCPoint p6 = null; - private PCPoint p7 = null; - - private Collection col1 = new java.util.HashSet(); - private Collection col2 = new java.util.HashSet(); - - /** */ - public void testTransactionalInstance() { - if (isOptimisticSupported()) { - pm = getPM(); - - createPNonTranObjects(); - - /* Positive cases */ - runTestMakeTransactional(); - runTestMakeTransactionalAll1(); - runTestMakeTransactionalAll2(); - - /* Negative cases */ - runTestMakeTransactionalNeg(); - runTestMakeTransactionalAll1Neg(); - runTestMakeTransactionalAll2Neg(); - - pm.close(); - pm = null; +public class MakeTransactionalANontransactionalPersistentInstance extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-24 (MakeTransactionalANontransactionalPersistentInstance) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeTransactionalANontransactionalPersistentInstance.class); + } + + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + private PCPoint p6 = null; + private PCPoint p7 = null; + + private Collection col1 = new java.util.HashSet(); + private Collection col2 = new java.util.HashSet(); + + /** */ + public void testTransactionalInstance() { + if (isOptimisticSupported()) { + pm = getPM(); + + createPNonTranObjects(); + + /* Positive cases */ + runTestMakeTransactional(); + runTestMakeTransactionalAll1(); + runTestMakeTransactionalAll2(); + + /* Negative cases */ + runTestMakeTransactionalNeg(); + runTestMakeTransactionalAll1Neg(); + runTestMakeTransactionalAll2Neg(); + + pm.close(); + pm = null; + } } - } - - /** */ - private void createPNonTranObjects() { - Transaction tx = pm.currentTransaction(); - try { - tx.setOptimistic(false); - tx.begin(); - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - p6 = new PCPoint(6, 8); - p7 = new PCPoint(7, 9); - - col1.add(p2); - col1.add(p3); - col1.add(p4); - - col2.add(p5); - col2.add(p6); - col2.add(p7); - - pm.makePersistent(p1); - pm.makePersistent(p2); - pm.makePersistent(p3); - pm.makePersistent(p4); - pm.makePersistent(p5); - pm.makePersistent(p6); - pm.makePersistent(p7); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + private void createPNonTranObjects() { + Transaction tx = pm.currentTransaction(); + try { + tx.setOptimistic(false); + tx.begin(); + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint (5,7); + p6 = new PCPoint (6,8); + p7 = new PCPoint (7,9); + + col1.add(p2); + col1.add(p3); + col1.add(p4); + + col2.add(p5); + col2.add(p6); + col2.add(p7); + + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + pm.makePersistent(p5); + pm.makePersistent(p6); + pm.makePersistent(p7); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - public void runTestMakeTransactional() { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in runTestMakeTransactional()"); - int curr; - - tx.setOptimistic(true); - tx.begin(); - - if (makePersistentNonTranInstance(p1)) { - pm.makeTransactional(p1); - } - tx.commit(); - tx = null; - if (debug) logger.debug(" \nPASSED in runTestMakeTransactional()"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void runTestMakeTransactional() { + Transaction tx = pm.currentTransaction(); + try { + if (debug) logger.debug(" ** in runTestMakeTransactional()"); + int curr; + + tx.setOptimistic(true); + tx.begin(); + + if (makePersistentNonTranInstance(p1)) { + pm.makeTransactional(p1); + } + tx.commit(); + tx = null; + if (debug) logger.debug(" \nPASSED in runTestMakeTransactional()"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - public void runTestMakeTransactionalNeg() { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in runTestMakeTransactionalNeg()"); - int curr; - - tx.setOptimistic(true); - tx.begin(); - - if (makePersistentNonTranInstance(p1)) { - ; // expected result - } - tx.commit(); - tx = null; - - try { - pm.makeTransactional(p1); - fail(ASSERTION_FAILED, "pm.makeTransactional should throw JDOUserException outside of tx"); - } catch (JDOUserException ex) { - // expected exception - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void runTestMakeTransactionalNeg() { + Transaction tx = pm.currentTransaction(); + try { + if (debug) logger.debug(" ** in runTestMakeTransactionalNeg()"); + int curr; + + tx.setOptimistic(true); + tx.begin(); + + if (makePersistentNonTranInstance(p1)) { + ; // expected result + } + tx.commit(); + tx = null; + + try { + pm.makeTransactional(p1); + fail(ASSERTION_FAILED, + "pm.makeTransactional should throw JDOUserException outside of tx"); + } + catch (JDOUserException ex) { + // expected exception + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - public void runTestMakeTransactionalAll1() { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in runTestMakeTransactionalAll1()"); - int curr; - tx.setOptimistic(true); - tx.begin(); - - if (makePersistentNonTranInstance(p2) - && makePersistentNonTranInstance(p3) - && makePersistentNonTranInstance(p4)) { - - pm.makeTransactionalAll(col1); - } - - tx.commit(); - tx = null; - if (debug) logger.debug(" \nPASSED in runTestMakeTransactionalAll1()"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void runTestMakeTransactionalAll1() { + Transaction tx = pm.currentTransaction(); + try { + if (debug) logger.debug(" ** in runTestMakeTransactionalAll1()"); + int curr; + tx.setOptimistic(true); + tx.begin(); + + if ( makePersistentNonTranInstance(p2) && + makePersistentNonTranInstance(p3) && + makePersistentNonTranInstance(p4)) { + + pm.makeTransactionalAll(col1); + } + + tx.commit(); + tx = null; + if (debug) + logger.debug(" \nPASSED in runTestMakeTransactionalAll1()"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - public void runTestMakeTransactionalAll1Neg() { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in runTestMakeTransactionalAll1Neg()"); - int curr; - tx.setOptimistic(true); - tx.begin(); - - if (makePersistentNonTranInstance(p2) - && makePersistentNonTranInstance(p3) - && makePersistentNonTranInstance(p4)) { - ; // expected result - } - tx.commit(); - - try { - pm.makeTransactionalAll(col1); - fail( - ASSERTION_FAILED, - "pm.makeTransactionalAll(Collection) should throw JDOUserException outside of tx"); - } catch (JDOUserException ex) { - // expected exception - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void runTestMakeTransactionalAll1Neg() { + Transaction tx = pm.currentTransaction(); + try { + if (debug) logger.debug(" ** in runTestMakeTransactionalAll1Neg()"); + int curr; + tx.setOptimistic(true); + tx.begin(); + + if ( makePersistentNonTranInstance(p2) && + makePersistentNonTranInstance(p3) && + makePersistentNonTranInstance(p4)) { + ; // expected result + } + tx.commit(); + + try { + pm.makeTransactionalAll(col1); + fail(ASSERTION_FAILED, + "pm.makeTransactionalAll(Collection) should throw JDOUserException outside of tx"); + } + catch (JDOUserException ex) { + // expected exception + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - public void runTestMakeTransactionalAll2() { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in runTestMakeTransactionalAll2()"); - int curr; - tx.setOptimistic(true); - tx.begin(); - - Object[] objArray = col2.toArray(); - - if (makePersistentNonTranInstance(p5) - && makePersistentNonTranInstance(p6) - && makePersistentNonTranInstance(p7)) { - - pm.makeTransactionalAll(objArray); - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void runTestMakeTransactionalAll2() { + Transaction tx = pm.currentTransaction(); + try { + if (debug) logger.debug(" ** in runTestMakeTransactionalAll2()"); + int curr; + tx.setOptimistic(true); + tx.begin(); + + Object[] objArray = col2.toArray(); + + if ( makePersistentNonTranInstance(p5) && + makePersistentNonTranInstance(p6) && + makePersistentNonTranInstance(p7)) { + + pm.makeTransactionalAll(objArray); + + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - public void runTestMakeTransactionalAll2Neg() { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in runTestMakeTransactionalAll2Neg()"); - int curr; - tx = pm.currentTransaction(); - tx.setOptimistic(true); - tx.begin(); - - Object[] objArray = col2.toArray(); - if (makePersistentNonTranInstance(p5) - && makePersistentNonTranInstance(p6) - && makePersistentNonTranInstance(p7)) { - ; // expected result - } - tx.commit(); - - try { - pm.makeTransactionalAll(objArray); - fail( - ASSERTION_FAILED, - "pm.makeTransactionalAll(Object[]) should throw JDOUserException outside of tx"); - } catch (JDOUserException ex) { - // expected exception - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void runTestMakeTransactionalAll2Neg() { + Transaction tx = pm.currentTransaction(); + try { + if (debug) logger.debug(" ** in runTestMakeTransactionalAll2Neg()"); + int curr; + tx = pm.currentTransaction(); + tx.setOptimistic(true); + tx.begin(); + + Object[] objArray = col2.toArray(); + if ( makePersistentNonTranInstance(p5) && + makePersistentNonTranInstance(p6) && + makePersistentNonTranInstance(p7)) { + ; // expected result + } + tx.commit(); + + try { + pm.makeTransactionalAll(objArray); + fail(ASSERTION_FAILED, + "pm.makeTransactionalAll(Object[]) should throw JDOUserException outside of tx"); + } + catch (JDOUserException ex) { + // expected exception + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** - * @param obj the PCPoint instance - * @return true - */ - public boolean makePersistentNonTranInstance(PCPoint obj) { - int val = obj.getX(); - int curr = currentState(obj); - if (curr != PERSISTENT_NONTRANSACTIONAL && curr != HOLLOW) { - fail( - ASSERTION_FAILED, - "expected P-HOLLOW or P-NONTX instance, instance " - + obj - + " is " - + getStateOfInstance(obj) - + "."); - return false; + + /** + * + * @param obj the PCPoint instance + * @return true + */ + public boolean makePersistentNonTranInstance (PCPoint obj) { + int val = obj.getX(); + int curr = currentState(obj); + if ( curr != PERSISTENT_NONTRANSACTIONAL && + curr != HOLLOW) { + fail(ASSERTION_FAILED, + "expected P-HOLLOW or P-NONTX instance, instance " + obj + + " is " + getStateOfInstance(obj) + "."); + return false; + } + return true; } - return true; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalAllFails.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalAllFails.java index be5f53aed..ab3871d42 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalAllFails.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalAllFails.java @@ -5,118 +5,131 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.lifecycle; import java.util.Collection; + import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.pc.mylib.Point; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: MakeTransactionalAllFails
    - * Keywords: exception
    - * Assertion ID: A12.5.7-4
    - * Assertion Description: If a collection or array of instances is passed to - * PersistenceManager.makeTransactionalAll, and one or more of the instances fail to complete the - * required o peration, then all instances will be attempted, and a JDOUserException will be thrown - * which contains a nested exception array, each exception of which conta ins one of the failing - * instances. The succeeding instances will transition to the specified life cycle state, and the - * failing instances will remain in their current state. - */ -public class MakeTransactionalAllFails extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-4 (MakeTransactionalAllFails) failed: "; + *Title: MakeTransactionalAllFails + *
    + *Keywords: exception + *
    + *Assertion ID: A12.5.7-4 + *
    + *Assertion Description: +If a collection or array of instances is passed to + *PersistenceManager.makeTransactionalAll, and one or more of the instances + *fail to complete the required o peration, then all instances will be + *attempted, and a JDOUserException will be thrown which contains a nested + *exception array, each exception of which conta ins one of the failing + *instances. The succeeding instances will transition to the specified life + *cycle state, and the failing instances will remain in their current state. - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeTransactionalAllFails.class); - } - - private PCPoint p1 = null; - private Point p2 = null; - private Collection col1 = new java.util.HashSet(); + */ - /** */ - public void testTransactionalInst() { - pm = getPM(); +public class MakeTransactionalAllFails extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-4 (MakeTransactionalAllFails) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeTransactionalAllFails.class); + } + + private PCPoint p1 = null; + private Point p2 = null; + private Collection col1 = new java.util.HashSet(); - createObjects(); - runTestMakeTransactionalAll1(pm); - runTestMakeTransactionalAll2(pm); + /** */ + public void testTransactionalInst() { + pm = getPM(); - pm.close(); - pm = null; - } + createObjects(); + runTestMakeTransactionalAll1(pm); + runTestMakeTransactionalAll2(pm); - /** */ - private void createObjects() { - p1 = new PCPoint(1, 3); - p2 = new Point(2, 4); - col1 = new java.util.HashSet(); - col1.add(p1); - col1.add(p2); - } + pm.close(); + pm = null; + } - /* test makeTransactional (Collection pcs) */ - private void runTestMakeTransactionalAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - if (debug) logger.debug(" in runTestMakeTransactionalAll2() "); - try { - tx.begin(); + /** */ + private void createObjects() { + p1 = new PCPoint(1,3); + p2 = new Point(2,4); + col1 = new java.util.HashSet(); + col1.add(p1); + col1.add(p2); + } - col1.add(p1); - col1.add(p2); - try { - pm.makeTransactionalAll(col1); - fail( - ASSERTION_FAILED, - "pm.makeTransactionalAll(Collection) should throw JDOUserException when called for collection icnluding instance of non-pc class"); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /* test makeTransactional (Collection pcs) */ + private void runTestMakeTransactionalAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + if (debug) logger.debug(" in runTestMakeTransactionalAll2() "); + try { + tx.begin(); + + col1.add(p1); + col1.add(p2); + try { + pm.makeTransactionalAll(col1); + fail(ASSERTION_FAILED, + "pm.makeTransactionalAll(Collection) should throw JDOUserException when called for collection icnluding instance of non-pc class"); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /* test makeTransactionalAll (Object[] pcs) */ - private void runTestMakeTransactionalAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - if (debug) logger.debug(" in runTestMakeTransactionalAll2() "); - try { - tx.begin(); - try { - pm.makeTransactionalAll(col1.toArray()); - fail( - ASSERTION_FAILED, - "pm.makeTransactionalAll(Object[]) should throw JDOUserException when called for collection icnluding instance of non-pc class"); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /* test makeTransactionalAll (Object[] pcs) */ + private void runTestMakeTransactionalAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + if (debug) logger.debug(" in runTestMakeTransactionalAll2() "); + try { + tx.begin(); + try { + pm.makeTransactionalAll(col1.toArray()); + fail(ASSERTION_FAILED, + "pm.makeTransactionalAll(Object[]) should throw JDOUserException when called for collection icnluding instance of non-pc class"); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalIsImmediate.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalIsImmediate.java index 4dbda95f3..1c6d2e9f4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalIsImmediate.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalIsImmediate.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,150 +20,167 @@ import java.util.Collection; import java.util.HashSet; import java.util.Iterator; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: Make Nontransactional is immediate
    - * Keywords:
    - * Assertion IDs: A12.5.7-25
    - * Assertion Description: The effect of PersistenceManager.makeTransactional or - * makeTransactionalAll is immediate and not subject to rollback. + *Title: Make Nontransactional is immediate + *
    + *Keywords: + *
    + *Assertion IDs: A12.5.7-25 + *
    + *Assertion Description: +The effect of PersistenceManager.makeTransactional or +makeTransactionalAll is immediate and not subject to rollback. */ -public class MakeTransactionalIsImmediate extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-25 (MakeTransactionalIsImmediate) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeTransactionalIsImmediate.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - private PCPoint p6 = null; - private PCPoint p7 = null; - - private Collection col1 = new HashSet(); - private Collection col2 = new HashSet(); - - /** */ - public void testTransactionalInst() { - pm = getPM(); - - createTcleanObjects(pm); - runTestMakeTransactionalIsImmediate(pm); - runTestMakeTransactionalIsImmediateAll1(pm); - runTestMakeTransactionalIsImmediateAll2(pm); - - pm.close(); - pm = null; - } - - /** */ - private void createTcleanObjects(PersistenceManager pm) { - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - p6 = new PCPoint(6, 8); - p7 = new PCPoint(7, 9); - col1.add(p2); - col1.add(p3); - col1.add(p4); - col2.add(p5); - col2.add(p6); - col2.add(p7); - - pm.makeTransactional(p1); - pm.makeTransactional(p2); - pm.makeTransactional(p3); - pm.makeTransactional(p4); - pm.makeTransactional(p5); - pm.makeTransactional(p6); - pm.makeTransactional(p7); - } - - /** */ - private void runTestMakeTransactionalIsImmediate(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in runTestMakeTransactionalIsImmediate()"); - - tx.begin(); - pm.makeTransactional(p1); - tx.rollback(); - - if (!testState(p1, TRANSIENT_CLEAN, "transient_clean")) { - fail( - ASSERTION_FAILED, - "expected T-CLEAN instance, instance " + p1 + " is " + getStateOfInstance(p1)); - } - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); +public class MakeTransactionalIsImmediate extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-25 (MakeTransactionalIsImmediate) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeTransactionalIsImmediate.class); + } + + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + private PCPoint p6 = null; + private PCPoint p7 = null; + + private Collection col1 = new HashSet(); + private Collection col2 = new HashSet(); + + /** */ + public void testTransactionalInst() { + pm = getPM(); + + createTcleanObjects(pm); + runTestMakeTransactionalIsImmediate(pm); + runTestMakeTransactionalIsImmediateAll1(pm); + runTestMakeTransactionalIsImmediateAll2(pm); + + pm.close(); + pm = null; } - } - /** */ - private void runTestMakeTransactionalIsImmediateAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in runTestMakeTransactionalIsImmediateAll1()"); - tx = pm.currentTransaction(); - tx.begin(); - pm.makeTransactionalAll(col1); - tx.rollback(); + /** */ + private void createTcleanObjects(PersistenceManager pm) { + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint (5,7); + p6 = new PCPoint (6,8); + p7 = new PCPoint (7,9); + + col1.add(p2); + col1.add(p3); + col1.add(p4); + + col2.add(p5); + col2.add(p6); + col2.add(p7); + + pm.makeTransactional(p1); + pm.makeTransactional(p2); + pm.makeTransactional(p3); + pm.makeTransactional(p4); + pm.makeTransactional(p5); + pm.makeTransactional(p6); + pm.makeTransactional(p7); + } - for (Iterator iter = col1.iterator(); iter.hasNext(); ) { - PCPoint p = (PCPoint) iter.next(); - if (!testState(p, TRANSIENT_CLEAN, "transient_clean")) { - fail( - ASSERTION_FAILED, - "expected T-CLEAN instance, instance " + p1 + " is " + getStateOfInstance(p)); + /** */ + private void runTestMakeTransactionalIsImmediate(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + if (debug) + logger.debug(" ** in runTestMakeTransactionalIsImmediate()"); + + tx.begin(); + pm.makeTransactional(p1); + tx.rollback(); + + if (!testState (p1, TRANSIENT_CLEAN, "transient_clean")) { + fail(ASSERTION_FAILED, + "expected T-CLEAN instance, instance " + p1 + + " is " + getStateOfInstance(p1)); + } + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } - /** */ - private void runTestMakeTransactionalIsImmediateAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in runTestMakeTransactionalIsImmediateAll2()"); - tx.begin(); - Object[] objArray = col2.toArray(); - pm.makeTransactionalAll(objArray); - tx.rollback(); + /** */ + private void runTestMakeTransactionalIsImmediateAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + if (debug) + logger.debug(" ** in runTestMakeTransactionalIsImmediateAll1()"); + tx = pm.currentTransaction(); + tx.begin(); + pm.makeTransactionalAll(col1); + tx.rollback(); + + for (Iterator iter = col1.iterator(); iter.hasNext();) { + PCPoint p = (PCPoint) iter.next(); + if (!testState(p, TRANSIENT_CLEAN, "transient_clean")) { + fail(ASSERTION_FAILED, + "expected T-CLEAN instance, instance " + p1 + + " is " + getStateOfInstance(p)); + } + } + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } - for (int i = 0; i < objArray.length; i++) { - PCPoint p = (PCPoint) objArray[i]; - if (!testState(p, TRANSIENT_CLEAN, "transient_clean")) { - fail( - ASSERTION_FAILED, - "expected T-CLEAN instance, instance " + p1 + " is " + getStateOfInstance(p)); + /** */ + private void runTestMakeTransactionalIsImmediateAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + if (debug) + logger.debug(" ** in runTestMakeTransactionalIsImmediateAll2()"); + tx.begin(); + Object[] objArray = col2.toArray(); + pm.makeTransactionalAll(objArray); + tx.rollback(); + + for (int i=0; i < objArray.length; i++) { + PCPoint p = (PCPoint) objArray[i]; + if (!testState(p, TRANSIENT_CLEAN, "transient_clean")) { + fail(ASSERTION_FAILED, + "expected T-CLEAN instance, instance " + p1 + + " is " + getStateOfInstance(p)); + } + } + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalPriorToTransactionRolledback.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalPriorToTransactionRolledback.java index 1bc8267a5..1891a7a5a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalPriorToTransactionRolledback.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalPriorToTransactionRolledback.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,178 +19,200 @@ import java.util.Collection; import java.util.HashSet; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: MakeTransactional Prior To a Transaction Rolledback
    - * Keywords:
    - * Assertion IDs: A12.5.7-23
    - * Assertion Description: If the transaction in which an instance is made transactional (by - * calling PersistenceManager.makeTransactional or makeTransactionalAll) is rolled back, then the - * transient instance takes its values as of the beginning of the transaction, if the call to - * makeTransactional was made prior to the beginning of the current transaction. + *Title: MakeTransactional Prior To a Transaction Rolledback + *
    + *Keywords: + *
    + *Assertion IDs: A12.5.7-23 + *
    + *Assertion Description: +If the transaction in which an instance is made transactional (by +calling PersistenceManager.makeTransactional or makeTransactionalAll) is +rolled back, then the transient instance takes its values as of the beginning of the +transaction, if the call to makeTransactional was made prior to the beginning of the +current transaction. + */ -public class MakeTransactionalPriorToTransactionRolledback extends PersistenceManagerTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-23 (MakeTransactionalPriorToTransactionRolledback) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeTransactionalPriorToTransactionRolledback.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - private PCPoint p6 = null; - private PCPoint p7 = null; - - private Collection col1 = new HashSet(); - private Collection col2 = new HashSet(); - - /** */ - public void testTransactionalInst() { - pm = getPM(); - pm.currentTransaction().setRestoreValues(true); - - createObjects(); - runTestMakeTransactionalPriorToTransactionRolledback(pm); - runTestMakeTransactionalPriorToTransactionRolledbackAll1(pm); - runTestMakeTransactionalPriorToTransactionRolledbackAll2(pm); - - pm.close(); - pm = null; - } - - /** */ - private void createObjects() { - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - - col1.add(p2); - col1.add(p3); - - col2.add(p4); - col2.add(p5); - } - - public void runTestMakeTransactionalPriorToTransactionRolledback(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in runTestMakeTransactionalPriorToTransactionRolledback()"); - p1.setY(Integer.valueOf(50)); - - tx.begin(); - p1.setY(Integer.valueOf(100)); - pm.makeTransactional(p1); - p1.setY(Integer.valueOf(200)); - tx.rollback(); - - p1.setY(Integer.valueOf(300)); - tx.begin(); - p1.setY(Integer.valueOf(400)); - tx.rollback(); - - if (p1.getY().intValue() != 300) { - fail( - ASSERTION_FAILED, - "wrong value of p1.y, expected: 300, actual: " + p1.getY().intValue()); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); +public class MakeTransactionalPriorToTransactionRolledback extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-23 (MakeTransactionalPriorToTransactionRolledback) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeTransactionalPriorToTransactionRolledback.class); + } + + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + private PCPoint p6 = null; + private PCPoint p7 = null; + + private Collection col1 = new HashSet(); + private Collection col2 = new HashSet(); + + /** */ + public void testTransactionalInst() { + pm = getPM(); + pm.currentTransaction().setRestoreValues(true); + + createObjects(); + runTestMakeTransactionalPriorToTransactionRolledback(pm); + runTestMakeTransactionalPriorToTransactionRolledbackAll1(pm); + runTestMakeTransactionalPriorToTransactionRolledbackAll2(pm); + + pm.close(); + pm = null; + } + + /** */ + private void createObjects() { + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint(5,7); + + col1.add(p2); + col1.add(p3); + + col2.add(p4); + col2.add(p5); } - } - - /** */ - private void runTestMakeTransactionalPriorToTransactionRolledbackAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in runTestMakeTransactionalPriorToTransactionRolledbackAll1()"); - p2.setY(Integer.valueOf(50)); - p3.setY(Integer.valueOf(50)); - tx.begin(); - p2.setY(Integer.valueOf(100)); - p3.setY(Integer.valueOf(100)); - pm.makeTransactionalAll(col1); - p2.setY(Integer.valueOf(200)); - p3.setY(Integer.valueOf(200)); - tx.rollback(); - - p2.setY(Integer.valueOf(300)); - p3.setY(Integer.valueOf(300)); - tx.begin(); - p2.setY(Integer.valueOf(400)); - p3.setY(Integer.valueOf(400)); - tx.rollback(); - - if (p2.getY().intValue() != 300) { - fail( - ASSERTION_FAILED, - "wrong value of p2.y, expected: 300, actual: " + p2.getY().intValue()); - } - if (p3.getY().intValue() != 300) { - fail( - ASSERTION_FAILED, - "wrong value of p3.y, expected: 300, actual: " + p3.getY().intValue()); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + + public void runTestMakeTransactionalPriorToTransactionRolledback( + PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + if (debug) + logger.debug(" ** in runTestMakeTransactionalPriorToTransactionRolledback()"); + p1.setY(Integer.valueOf(50)); + + tx.begin(); + p1.setY(Integer.valueOf(100)); + pm.makeTransactional(p1); + p1.setY(Integer.valueOf(200)); + tx.rollback(); + + p1.setY(Integer.valueOf(300)); + tx.begin(); + p1.setY(Integer.valueOf(400)); + tx.rollback(); + + if (p1.getY().intValue() != 300) { + fail(ASSERTION_FAILED, + "wrong value of p1.y, expected: 300, actual: " + + p1.getY().intValue()); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** - * @param pm the PersistenceManager - */ - public void runTestMakeTransactionalPriorToTransactionRolledbackAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in runTestMakeTransactionalPriorToTransactionRolledbackAll2()"); - p2.setY(Integer.valueOf(50)); - p3.setY(Integer.valueOf(50)); - tx.begin(); - p2.setY(Integer.valueOf(100)); - p3.setY(Integer.valueOf(100)); - - Object[] objArray = col2.toArray(); - pm.makeTransactionalAll(objArray); - p2.setY(Integer.valueOf(200)); - p3.setY(Integer.valueOf(200)); - tx.rollback(); - - p2.setY(Integer.valueOf(300)); - p3.setY(Integer.valueOf(300)); - tx.begin(); - p2.setY(Integer.valueOf(400)); - p3.setY(Integer.valueOf(400)); - tx.rollback(); - - if (p2.getY().intValue() != 300) { - fail( - ASSERTION_FAILED, - "wrong value of p2.y, expected: 300, actual: " + p2.getY().intValue()); - } - if (p3.getY().intValue() != 300) { - fail( - ASSERTION_FAILED, - "wrong value of p3.y, expected: 300, actual: " + p3.getY().intValue()); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + private void runTestMakeTransactionalPriorToTransactionRolledbackAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + if (debug) + logger.debug(" ** in runTestMakeTransactionalPriorToTransactionRolledbackAll1()"); + p2.setY(Integer.valueOf(50)); + p3.setY(Integer.valueOf(50)); + tx.begin(); + p2.setY(Integer.valueOf(100)); + p3.setY(Integer.valueOf(100)); + pm.makeTransactionalAll(col1); + p2.setY(Integer.valueOf(200)); + p3.setY(Integer.valueOf(200)); + tx.rollback(); + + p2.setY(Integer.valueOf(300)); + p3.setY(Integer.valueOf(300)); + tx.begin(); + p2.setY(Integer.valueOf(400)); + p3.setY(Integer.valueOf(400)); + tx.rollback(); + + if (p2.getY().intValue() != 300) { + fail(ASSERTION_FAILED, + "wrong value of p2.y, expected: 300, actual: " + + p2.getY().intValue()); + } + if (p3.getY().intValue() != 300) { + fail(ASSERTION_FAILED, + "wrong value of p3.y, expected: 300, actual: " + + p3.getY().intValue()); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** + * + * @param pm the PersistenceManager + */ + public void runTestMakeTransactionalPriorToTransactionRolledbackAll2( + PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + if (debug) + logger.debug (" ** in runTestMakeTransactionalPriorToTransactionRolledbackAll2()"); + p2.setY(Integer.valueOf(50)); + p3.setY(Integer.valueOf(50)); + tx.begin(); + p2.setY(Integer.valueOf(100)); + p3.setY(Integer.valueOf(100)); + + Object[] objArray = col2.toArray(); + pm.makeTransactionalAll(objArray); + p2.setY(Integer.valueOf(200)); + p3.setY(Integer.valueOf(200)); + tx.rollback(); + + p2.setY(Integer.valueOf(300)); + p3.setY(Integer.valueOf(300)); + tx.begin(); + p2.setY(Integer.valueOf(400)); + p3.setY(Integer.valueOf(400)); + tx.rollback(); + + if (p2.getY().intValue() != 300) { + fail(ASSERTION_FAILED, + "wrong value of p2.y, expected: 300, actual: " + + p2.getY().intValue()); + } + if (p3.getY().intValue() != 300) { + fail(ASSERTION_FAILED, + "wrong value of p3.y, expected: 300, actual: " + + p3.getY().intValue()); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalWithinTransactionRolledback.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalWithinTransactionRolledback.java index cbca9a712..0b6925897 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalWithinTransactionRolledback.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalWithinTransactionRolledback.java @@ -5,174 +5,192 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.lifecycle; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: MakeTransactionalWithinTransactionRolledback
    - * Keywords: transienttransactional
    - * Assertion IDs: A12.5.7-22
    - * Assertion Description: If the transaction in which an instance is made transactional (by - * calling PersistenceManager.makeTransactional or makeTransactionalAll) is rolled back, then the - * transient instance takes its values as of the call to makeTransactional if the call was made - * within the current transaction. + *Title: MakeTransactionalWithinTransactionRolledback + *
    + *Keywords: transienttransactional + *
    + *Assertion IDs: A12.5.7-22 + *
    + *Assertion Description: +If the transaction in which an instance is made transactional (by +calling PersistenceManager.makeTransactional or makeTransactionalAll) is +rolled back, then the transient instance takes its values as of the call to +makeTransactional if the call was made within the current transaction. + */ + public class MakeTransactionalWithinTransactionRolledback extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-22 (MakeTransactionalWithinTransactionRolledback) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeTransactionalWithinTransactionRolledback.class); + } + + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + private PCPoint p6 = null; + private PCPoint p7 = null; + + private Collection col1 = new java.util.HashSet(); + private Collection col2 = new java.util.HashSet(); + + /** */ + public void testTransactionalInst() { + pm = getPM(); + pm.currentTransaction().setRestoreValues(true); + + createObjects(); + runTestMakeTransactionalWithinTransactionRolledback(pm); + runTestMakeTransactionalWithinTransactionRolledbackAll1(pm); + runTestMakeTransactionalWithinTransactionRolledbackAll2(pm); + pm.close(); + pm = null; + } + + /** */ + private void createObjects() { + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint (5,7); + + col1.add(p2); + col1.add(p3); + + col2.add(p4); + col2.add(p5); + } - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-22 (MakeTransactionalWithinTransactionRolledback) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeTransactionalWithinTransactionRolledback.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - private PCPoint p6 = null; - private PCPoint p7 = null; - - private Collection col1 = new java.util.HashSet(); - private Collection col2 = new java.util.HashSet(); - - /** */ - public void testTransactionalInst() { - pm = getPM(); - pm.currentTransaction().setRestoreValues(true); - - createObjects(); - runTestMakeTransactionalWithinTransactionRolledback(pm); - runTestMakeTransactionalWithinTransactionRolledbackAll1(pm); - runTestMakeTransactionalWithinTransactionRolledbackAll2(pm); - pm.close(); - pm = null; - } - - /** */ - private void createObjects() { - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - - col1.add(p2); - col1.add(p3); - - col2.add(p4); - col2.add(p5); - } - - /** - * @param pm the PersistenceManager - */ - public void runTestMakeTransactionalWithinTransactionRolledback(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in runTestMakeTransactionalWithinTransactionRolledback()"); - - p1.setY(Integer.valueOf(100)); - tx.begin(); - p1.setY(Integer.valueOf(200)); - pm.makeTransactional(p1); - p1.setY(Integer.valueOf(300)); - tx.rollback(); - - if (p1.getY().intValue() != 200) { - fail( - ASSERTION_FAILED, - "wrong value of p1.y, expected: 200, actual: " + p1.getY().intValue()); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * + * @param pm the PersistenceManager + */ + public void runTestMakeTransactionalWithinTransactionRolledback(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + if (debug) + logger.debug(" ** in runTestMakeTransactionalWithinTransactionRolledback()"); + + p1.setY(Integer.valueOf(100)); + tx.begin(); + p1.setY(Integer.valueOf(200)); + pm.makeTransactional(p1); + p1.setY(Integer.valueOf(300)); + tx.rollback(); + + if (p1.getY().intValue() != 200) { + fail(ASSERTION_FAILED, + "wrong value of p1.y, expected: 200, actual: " + p1.getY().intValue()); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** - * @param pm the PersistenceManager - */ - private void runTestMakeTransactionalWithinTransactionRolledbackAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in runTestMakeTransactionalWithinTransactionRolledbackAll1()"); - p2.setY(Integer.valueOf(100)); - p3.setY(Integer.valueOf(100)); - tx.begin(); - p2.setY(Integer.valueOf(200)); - p3.setY(Integer.valueOf(200)); - pm.makeTransactionalAll(col1); - p2.setY(Integer.valueOf(300)); - p3.setY(Integer.valueOf(300)); - tx.rollback(); - - if (p2.getY().intValue() != 200) { - fail( - ASSERTION_FAILED, "wrong value of p2.y expected: 200, actual: " + p2.getY().intValue()); - } - - if (p3.getY().intValue() != 200) { - fail( - ASSERTION_FAILED, - "wrong value of p3.y, expected: 200, actual: " + p3.getY().intValue()); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** + * + * @param pm the PersistenceManager + */ + private void runTestMakeTransactionalWithinTransactionRolledbackAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + if (debug) + logger.debug(" ** in runTestMakeTransactionalWithinTransactionRolledbackAll1()"); + p2.setY(Integer.valueOf(100)); + p3.setY(Integer.valueOf(100)); + tx.begin(); + p2.setY(Integer.valueOf(200)); + p3.setY(Integer.valueOf(200)); + pm.makeTransactionalAll(col1); + p2.setY(Integer.valueOf(300)); + p3.setY(Integer.valueOf(300)); + tx.rollback(); + + if (p2.getY().intValue() != 200) { + fail(ASSERTION_FAILED, + "wrong value of p2.y expected: 200, actual: " + p2.getY().intValue()); + } + + if (p3.getY().intValue() != 200) { + fail(ASSERTION_FAILED, + "wrong value of p3.y, expected: 200, actual: " + p3.getY().intValue()); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** - * @param pm the PersistenceManager - */ - private void runTestMakeTransactionalWithinTransactionRolledbackAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - if (debug) logger.debug(" ** in runTestMakeTransactionalWithinTransactionRolledbackAll2()"); - - p4.setY(Integer.valueOf(100)); - p5.setY(Integer.valueOf(100)); - tx.begin(); - p4.setY(Integer.valueOf(200)); - p5.setY(Integer.valueOf(200)); - Object[] objArray = col2.toArray(); - pm.makeTransactionalAll(objArray); - p4.setY(Integer.valueOf(300)); - p5.setY(Integer.valueOf(300)); - tx.rollback(); - - if (p4.getY().intValue() != 200) { - fail(ASSERTION_FAILED, "wrong value of p4, expected: 200, actual: " + p4.getY().intValue()); - } - - if (p5.getY().intValue() != 200) { - fail( - ASSERTION_FAILED, - "wrong value of p5.y, expected: 200, actual: " + p5.getY().intValue()); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** + * + * @param pm the PersistenceManager + */ + private void runTestMakeTransactionalWithinTransactionRolledbackAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + if (debug) + logger.debug(" ** in runTestMakeTransactionalWithinTransactionRolledbackAll2()"); + + p4.setY(Integer.valueOf(100)); + p5.setY(Integer.valueOf(100)); + tx.begin(); + p4.setY(Integer.valueOf(200)); + p5.setY(Integer.valueOf(200)); + Object[] objArray = col2.toArray(); + pm.makeTransactionalAll(objArray); + p4.setY(Integer.valueOf(300)); + p5.setY(Integer.valueOf(300)); + tx.rollback(); + + if (p4.getY().intValue() != 200) { + fail(ASSERTION_FAILED, + "wrong value of p4, expected: 200, actual: " + p4.getY().intValue()); + } + + if (p5.getY().intValue() != 200) { + fail(ASSERTION_FAILED, + "wrong value of p5.y, expected: 200, actual: " + p5.getY().intValue()); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransient.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransient.java index e38aff1a7..0c866ab9c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransient.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransient.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,142 +19,161 @@ import java.util.Collection; import java.util.Iterator; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: MakeTransient
    - * Keywords: transient
    - * Assertion IDs: A12.5.7-13
    - * Assertion Description: PersistenceManager.makeTransient and makeTransientAll make a - * persistent instance transient, so it is not associated with the PersistenceManager instance. It - * does not affect the persistent state in the data store. + *Title: MakeTransient + *
    + *Keywords: transient + *
    + *Assertion IDs: A12.5.7-13 + *
    + *Assertion Description: +PersistenceManager.makeTransient and makeTransientAll make a persistent instance transient, so it is not associated with the PersistenceManager instance. It does not affect the persistent state in the data store. + */ + public class MakeTransient extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-13 (MakeTransient) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeTransient.class); + } + + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + + /** */ + public void testMakeTransient() { + pm = getPM(); - /** */ - private static final String ASSERTION_FAILED = "Assertion A12.5.7-13 (MakeTransient) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeTransient.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - - /** */ - public void testMakeTransient() { - pm = getPM(); - - createPersistentObjects(pm); - runTestMakeTransient1(pm); - runTestMakeTransientAll1(pm); - runTestMakeTransientAll2(pm); - - pm.close(); - pm = null; - } - - /** */ - private void createPersistentObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - - pm.makePersistent(p1); - pm.makePersistent(p2); - pm.makePersistent(p3); - pm.makePersistent(p4); - pm.makePersistent(p5); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + createPersistentObjects(pm); + runTestMakeTransient1(pm); + runTestMakeTransientAll1(pm); + runTestMakeTransientAll2(pm); + + pm.close(); + pm = null; } - } - - /* test makeTransient (Object pc) */ - private void runTestMakeTransient1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - pm.makeTransient(p1); - tx.commit(); - tx = null; - - if (!testState(p1, TRANSIENT, "transient")) { - fail("expected TRANSIENT instance, instance " + p1 + " is " + getStateOfInstance(p1)); + + /** */ + private void createPersistentObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint(5,7); + + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + pm.makePersistent(p5); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /* test makeTransient (Object pc) */ + private void runTestMakeTransient1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + pm.makeTransient(p1); + tx.commit(); + tx = null; + + if (!testState(p1, TRANSIENT, "transient")) { + fail("expected TRANSIENT instance, instance " + p1 + + " is " + getStateOfInstance(p1)); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } - - /* test makeTransientAll (Collection pcs) */ - private void runTestMakeTransientAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Collection col1 = new java.util.HashSet(); - col1.add(p2); - col1.add(p3); - - pm.makeTransientAll(col1); - tx.commit(); - tx = null; - - for (Iterator iter = col1.iterator(); iter.hasNext(); ) { - PCPoint p = (PCPoint) iter.next(); - if (!testState(p, TRANSIENT, "transient")) { - fail("expected TRANSIENT instance, instance " + p1 + " is " + getStateOfInstance(p)); + + /* test makeTransientAll (Collection pcs) */ + private void runTestMakeTransientAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 = new java.util.HashSet(); + col1.add(p2); + col1.add(p3); + + pm.makeTransientAll(col1); + tx.commit(); + tx = null; + + for (Iterator iter = col1.iterator(); iter.hasNext();) { + PCPoint p = (PCPoint) iter.next(); + if (!testState(p, TRANSIENT, "transient")) { + fail("expected TRANSIENT instance, instance " + p1 + + " is " + getStateOfInstance(p)); + } + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } - - /* test makeTransientAll (Object[] o) */ - private void runTestMakeTransientAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - int NUM_OBJS = 2; - tx.begin(); - - Collection col1 = new java.util.HashSet(); - col1.add(p4); - col1.add(p5); - Object[] obj1 = col1.toArray(); - - pm.makeTransientAll(obj1); - tx.commit(); - tx = null; - - for (int i = 0; i < NUM_OBJS; ++i) { - PCPoint p = (PCPoint) obj1[i]; - if (!testState(p, TRANSIENT, "transient")) { - fail("expected TRANSIENT instance, instance " + p1 + " is " + getStateOfInstance(p)); + + /* test makeTransientAll (Object[] o) */ + private void runTestMakeTransientAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + int NUM_OBJS = 2; + tx.begin(); + + Collection col1 = new java.util.HashSet(); + col1.add(p4); + col1.add(p5); + Object[] obj1= col1.toArray(); + + pm.makeTransientAll(obj1); + tx.commit(); + tx = null; + + for (int i=0; i < NUM_OBJS; ++i ) { + PCPoint p = (PCPoint) obj1[i]; + if (!testState(p, TRANSIENT, "transient")) { + fail("expected TRANSIENT instance, instance " + p1 + + " is " + getStateOfInstance(p)); + } + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientAllFails.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientAllFails.java index fb7135da8..f2b4a47ca 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientAllFails.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientAllFails.java @@ -5,124 +5,132 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.lifecycle; import java.util.Collection; import java.util.HashSet; + import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.pc.mylib.Point; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title:MakeTransientAll Fail
    - * Keywords: exception
    - * Assertion IDs: A12.5.7-3
    - * Assertion Description: If a collection or array of instances is passed to - * PersistenceManager.makeTransientAll, and one or more of the instances fail to complete the - * required operation, then all instances will be attempted, and a JDOUserException will be thrown - * which contains a nested exception array, each exception of which contains one of the failing - * instances. The succeeding instances will transition to the specified life cycle state, and the - * failing instances will remain in their current state. + *Title:MakeTransientAll Fail + *
    + *Keywords: exception + *
    + *Assertion IDs: A12.5.7-3 + *
    + *Assertion Description: +If a collection or array of instances is passed to PersistenceManager.makeTransientAll, and one or more of the instances fail to complete the required operation, then all instances will be attempted, and a JDOUserException will be thrown which contains a nested exception array, each exception of which contains one of the failing instances. The succeeding instances will transition to the specified life cycle state, and the failing instances will remain in their current state. + */ + public class MakeTransientAllFails extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-3 (MakeTransientAllFails) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeTransientAllFails.class); + } + + /** */ + public void testMakeTransientAllFails() { + pm = getPM(); - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-3 (MakeTransientAllFails) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeTransientAllFails.class); - } - - /** */ - public void testMakeTransientAllFails() { - pm = getPM(); - - runTestMakeTransientAllFails1(pm); - runTestMakeTransientAllFails2(pm); - - pm.close(); - pm = null; - } - - /* test makeTansientAll (Collection pcs) */ - private void runTestMakeTransientAllFails1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - PCPoint np1 = new PCPoint(3, 3); - PCPoint np2 = new PCPoint(4, 4); - Point np3 = new Point(5, 5); - - Collection col1 = new HashSet(); - col1.add(np1); - col1.add(np2); - col1.add(np3); - - try { - pm.makeTransientAll(col1); - fail( - ASSERTION_FAILED, - "pm.makeTransientAll(Collection) should throw JDOUserException when called for a collection including an instance of a non-pc class"); - } catch (JDOUserException ex) { - // expected exception - } - - tx.rollback(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + runTestMakeTransientAllFails1(pm); + runTestMakeTransientAllFails2(pm); + + pm.close(); + pm = null; } - } - - /* test makeTransientAll (Object[] o) */ - private void runTestMakeTransientAllFails2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - PCPoint np1 = new PCPoint(3, 3); - PCPoint np2 = new PCPoint(4, 4); - Point np3 = new Point(5, 5); - - Collection col1 = new java.util.HashSet(); - col1.add(np1); - col1.add(np2); - col1.add(np3); - - Object[] obj1 = col1.toArray(); - - try { - pm.makeTransientAll(obj1); - fail( - ASSERTION_FAILED, - "pm.makeTransientAll(Object[]) should throw JDOUserException when called for an array including an instance of a non-pc class"); - } catch (JDOUserException ex) { - // expected exception - } - - tx.rollback(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /* test makeTansientAll (Collection pcs) */ + private void runTestMakeTransientAllFails1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + PCPoint np1 = new PCPoint (3,3); + PCPoint np2 = new PCPoint (4,4); + Point np3 = new Point (5,5); + + Collection col1 = new HashSet(); + col1.add(np1); + col1.add(np2); + col1.add(np3); + + try { + pm.makeTransientAll(col1); + fail(ASSERTION_FAILED, + "pm.makeTransientAll(Collection) should throw JDOUserException when called for a collection including an instance of a non-pc class"); + } + catch (JDOUserException ex) { + // expected exception + } + + tx.rollback(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /* test makeTransientAll (Object[] o) */ + private void runTestMakeTransientAllFails2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + PCPoint np1 = new PCPoint (3,3); + PCPoint np2 = new PCPoint (4,4); + Point np3 = new Point (5,5); + + Collection col1 = new java.util.HashSet(); + col1.add(np1); + col1.add(np2); + col1.add(np3); + + Object[] obj1=col1.toArray(); + + try { + pm.makeTransientAll(obj1); + fail(ASSERTION_FAILED, + "pm.makeTransientAll(Object[]) should throw JDOUserException when called for an array including an instance of a non-pc class"); + } + catch (JDOUserException ex) { + // expected exception + } + + tx.rollback(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientCausesLossOfIdentity.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientCausesLossOfIdentity.java index ccb074206..76d451dcc 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientCausesLossOfIdentity.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientCausesLossOfIdentity.java @@ -5,170 +5,181 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.lifecycle; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: MakeTransientCausesLossOfIdentity
    - * Keywords: transient identity
    - * Assertion IDs: A12.5.7-14
    - * Assertion Description: PersistenceManager.makeTransient and makeTransientAll transition - * an instance to transient, causing it to lose its JDO identity. + *Title: MakeTransientCausesLossOfIdentity + *
    + *Keywords: transient identity + *
    + *Assertion IDs: A12.5.7-14 + *
    + *Assertion Description: +PersistenceManager.makeTransient and makeTransientAll transition an instance to transient, causing it to lose its JDO identity. + */ + public class MakeTransientCausesLossOfIdentity extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-14 (MakeTransientCausesLossOfIdentity) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeTransientCausesLossOfIdentity.class); + } - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-14 (MakeTransientCausesLossOfIdentity) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeTransientCausesLossOfIdentity.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - - /** */ - public void testMakeTransientCausesLossOfIdentity() { - pm = getPM(); - - createPersistentObjects(pm); - runTestMakeTransientCausesLossOfIdentity1(pm); - runTestMakeTransientCausesLossOfIdentityAll1(pm); - runTestMakeTransientCausesLossOfIdentityAll2(pm); - - pm.close(); - pm = null; - } - - /** */ - private void createPersistentObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - - pm.makePersistent(p1); - pm.makePersistent(p2); - pm.makePersistent(p3); - pm.makePersistent(p4); - pm.makePersistent(p5); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + + /** */ + public void testMakeTransientCausesLossOfIdentity() { + pm = getPM(); + + createPersistentObjects(pm); + runTestMakeTransientCausesLossOfIdentity1(pm); + runTestMakeTransientCausesLossOfIdentityAll1(pm); + runTestMakeTransientCausesLossOfIdentityAll2(pm); + + pm.close(); + pm = null; } - } - - /* test makeTransient (Object pc) */ - private void runTestMakeTransientCausesLossOfIdentity1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx = pm.currentTransaction(); - tx.begin(); - pm.makeTransient(p1); - tx.commit(); - - Object oid = pm.getObjectId(p1); - if (oid != null) { - fail( - ASSERTION_FAILED, - "pm.getObjectId(p1) returned non null ObjectId " + oid + " for transient instance"); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + private void createPersistentObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint(5,7); + + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + pm.makePersistent(p5); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /* test makeTransientAll (Collection pcs) */ - private void runTestMakeTransientCausesLossOfIdentityAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx = pm.currentTransaction(); - tx.begin(); - - Collection col1 = new java.util.HashSet(); - col1.add(p2); - col1.add(p3); - - pm.makeTransientAll(col1); - tx.commit(); - - Object oid1 = pm.getObjectId(p2); - if (oid1 != null) { - fail( - ASSERTION_FAILED, - "pm.getObjectId(p2) returned non null ObjectId " + oid1 + " for transient instance"); - } - Object oid2 = pm.getObjectId(p3); - if (oid2 != null) { - fail( - ASSERTION_FAILED, - "pm.getObjectId(p3) returned non null ObjectId " + oid2 + " for transient instance"); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /* test makeTransient (Object pc) */ + private void runTestMakeTransientCausesLossOfIdentity1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx = pm.currentTransaction(); + tx.begin(); + pm.makeTransient(p1); + tx.commit(); + + Object oid = pm.getObjectId(p1); + if (oid != null) { + fail(ASSERTION_FAILED, + "pm.getObjectId(p1) returned non null ObjectId " + oid + " for transient instance"); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /* test makeTransientAll (Object[] o) */ - private void runTestMakeTransientCausesLossOfIdentityAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx = pm.currentTransaction(); - tx.begin(); - - Collection col1 = new java.util.HashSet(); - col1.add(p4); - col1.add(p5); - - Object[] obj1 = col1.toArray(); - - pm.makeTransientAll(obj1); - tx.commit(); - - Object oid1 = pm.getObjectId(p4); - if (oid1 != null) { - fail( - ASSERTION_FAILED, - "pm.getObjectId(p4) returned non null ObjectId " + oid1 + " for transient instance"); - } - Object oid2 = pm.getObjectId(p5); - if (oid2 != null) { - fail( - ASSERTION_FAILED, - "pm.getObjectId(p5) returned non null ObjectId " + oid2 + " for transient instance"); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /* test makeTransientAll (Collection pcs) */ + private void runTestMakeTransientCausesLossOfIdentityAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx = pm.currentTransaction(); + tx.begin(); + + Collection col1 = new java.util.HashSet(); + col1.add(p2); + col1.add(p3); + + pm.makeTransientAll(col1); + tx.commit(); + + Object oid1 = pm.getObjectId(p2); + if (oid1 != null) { + fail(ASSERTION_FAILED, + "pm.getObjectId(p2) returned non null ObjectId " + oid1 + " for transient instance"); + } + Object oid2 = pm.getObjectId(p3); + if (oid2 != null) { + fail(ASSERTION_FAILED, + "pm.getObjectId(p3) returned non null ObjectId " + oid2 + " for transient instance"); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /* test makeTransientAll (Object[] o) */ + private void runTestMakeTransientCausesLossOfIdentityAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx = pm.currentTransaction(); + tx.begin(); + + Collection col1 = new java.util.HashSet(); + col1.add(p4); + col1.add(p5); + + Object[] obj1= col1.toArray(); + + pm.makeTransientAll(obj1); + tx.commit(); + + Object oid1 = pm.getObjectId(p4); + if (oid1 != null) { + fail(ASSERTION_FAILED, + "pm.getObjectId(p4) returned non null ObjectId " + oid1 + " for transient instance"); + } + Object oid2 = pm.getObjectId(p5); + if (oid2 != null) { + fail(ASSERTION_FAILED, + "pm.getObjectId(p5) returned non null ObjectId " + oid2 + " for transient instance"); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientFailsWithDirtyInstance.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientFailsWithDirtyInstance.java index 03cae391e..645410e91 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientFailsWithDirtyInstance.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientFailsWithDirtyInstance.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,159 +19,174 @@ import java.util.Collection; import java.util.HashSet; + import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title:MakeTransientFailsWithDirtyInstance
    - * Keywords: exception
    - * Assertion IDs: A12.5.7-16
    - * Assertion Description: If the instance passed to PersistenceManager.makeTransient or - * makeTransientAll is dirty, a JDOUserException is thrown. + *Title:MakeTransientFailsWithDirtyInstance + *
    + *Keywords: exception + *
    + *Assertion IDs: A12.5.7-16 + *
    + *Assertion Description: +If the instance passed to PersistenceManager.makeTransient or makeTransientAll is dirty, a JDOUserException is thrown. + */ + public class MakeTransientFailsWithDirtyInstance extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-16 (MakeTransientFailsWithDirtyInstance) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeTransientFailsWithDirtyInstance.class); + } + + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-16 (MakeTransientFailsWithDirtyInstance) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeTransientFailsWithDirtyInstance.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - - /** */ - public void testMakeTransientFailsWithDirtyInstance() { - pm = getPM(); - - createObjects(pm); - runTestMakeTransient(pm); - runTestMakeTransientAll1(pm); - runTestMakeTransientAll2(pm); - - pm.close(); - pm = null; - } - - /** */ - private void createObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx = pm.currentTransaction(); - tx.begin(); - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - - pm.makePersistent(p1); - pm.makePersistent(p2); - pm.makePersistent(p3); - pm.makePersistent(p4); - pm.makePersistent(p5); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + public void testMakeTransientFailsWithDirtyInstance() { + pm = getPM(); + + createObjects(pm); + runTestMakeTransient(pm); + runTestMakeTransientAll1(pm); + runTestMakeTransientAll2(pm); + + pm.close(); + pm = null; } - } - - /* test makeTansient (Object pc) */ - private void runTestMakeTransient(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - // make instance dirty - p1.setX(100); - - try { - pm.makeTransient(p1); - fail( - ASSERTION_FAILED, - "pm.makeTransient should throw JDOUserException when called for P-DIRTY instance."); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx = pm.currentTransaction(); + tx.begin(); + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint(5,7); + + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + pm.makePersistent(p5); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /* test makeTansientAll (Collection pcs) */ - private void runTestMakeTransientAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - - tx = pm.currentTransaction(); - tx.begin(); - - Collection col1 = new HashSet(); - col1.add(p2); - col1.add(p3); - - p2.setX(200); - p3.setX(201); - - try { - pm.makeTransientAll(col1); - fail( - ASSERTION_FAILED, - "pm.makeTransientAll(Collection) should throw JDOUserException when called for a collection including P-DIRTY instances."); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /* test makeTansient (Object pc) */ + private void runTestMakeTransient(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + // make instance dirty + p1.setX(100); + + try { + pm.makeTransient(p1); + fail(ASSERTION_FAILED, + "pm.makeTransient should throw JDOUserException when called for P-DIRTY instance."); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /* test makeTransientAll (Object[] o) */ - private void runTestMakeTransientAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Collection col1 = new HashSet(); - col1.add(p4); - col1.add(p5); - - p4.setX(300); - p5.setX(301); - - Object[] obj1 = col1.toArray(); - - try { - pm.makeTransientAll(obj1); - fail( - ASSERTION_FAILED, - "pm.makeTransientAll(Object[]) should throw JDOUserException when called for an array including P-DIRTY instances."); - } catch (JDOUserException ex) { - // expected exception - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /* test makeTansientAll (Collection pcs) */ + private void runTestMakeTransientAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + + tx = pm.currentTransaction(); + tx.begin(); + + Collection col1 = new HashSet(); + col1.add(p2); + col1.add(p3); + + p2.setX(200); + p3.setX(201); + + try { + pm.makeTransientAll(col1); + fail(ASSERTION_FAILED, + "pm.makeTransientAll(Collection) should throw JDOUserException when called for a collection including P-DIRTY instances."); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /* test makeTransientAll (Object[] o) */ + private void runTestMakeTransientAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 = new HashSet(); + col1.add(p4); + col1.add(p5); + + p4.setX(300); + p5.setX(301); + + Object[] obj1=col1.toArray(); + + try { + pm.makeTransientAll(obj1); + fail(ASSERTION_FAILED, + "pm.makeTransientAll(Object[]) should throw JDOUserException when called for an array including P-DIRTY instances."); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientFieldsPreservedUnchanged.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientFieldsPreservedUnchanged.java index b258518e1..20f031206 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientFieldsPreservedUnchanged.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientFieldsPreservedUnchanged.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,210 +20,226 @@ import java.util.Collection; import java.util.HashSet; import java.util.Iterator; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: MakeTransient Fields Preserved Unchanged
    - * Keywords: transient
    - * Assertion IDs: A12.5.7-15, A12.5.7-18
    - * Assertion Description: If the instance passed to PersistenceManager.makeTransient or - * makeTransientAll has field values (persistent-nontransactional or persistent-clean), the fields - * in the cache are preserved unchanged. The instance(s) are not modified in any way. + *Title: MakeTransient Fields Preserved Unchanged + *
    + *Keywords: transient + *
    + *Assertion IDs: A12.5.7-15, A12.5.7-18 + *
    + *Assertion Description: +If the instance passed to PersistenceManager.makeTransient or makeTransientAll has field values (persistent-nontransactional or persistent-clean), the fields in the cache are preserved unchanged. The instance(s) are not modified in any way. */ + public class MakeTransientFieldsPreservedUnchanged extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-15, A12.5.7-18 (MakeTransientFieldsPreservedUnchanged) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeTransientFieldsPreservedUnchanged.class); + } + + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + + private PCPoint np1 = null; + private PCPoint np2 = null; + private PCPoint np3 = null; + private PCPoint np4 = null; + private PCPoint np5 = null; + + /** */ + public void testMakeTransientFieldsPreservedUnchanged() { + pm = getPM(); + + createObjects(pm); + runTestMakeTransientFieldsPreservedUnchanged1(pm); + runTestMakeTransientFieldsPreservedUnchangedAll1(pm); + runTestMakeTransientFieldsPreservedUnchangedAll2(pm); + + pm.close(); + pm = null; + } - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-15, A12.5.7-18 (MakeTransientFieldsPreservedUnchanged) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeTransientFieldsPreservedUnchanged.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - - private PCPoint np1 = null; - private PCPoint np2 = null; - private PCPoint np3 = null; - private PCPoint np4 = null; - private PCPoint np5 = null; - - /** */ - public void testMakeTransientFieldsPreservedUnchanged() { - pm = getPM(); - - createObjects(pm); - runTestMakeTransientFieldsPreservedUnchanged1(pm); - runTestMakeTransientFieldsPreservedUnchangedAll1(pm); - runTestMakeTransientFieldsPreservedUnchangedAll2(pm); - - pm.close(); - pm = null; - } - - /** */ - private void createObjects(PersistenceManager pm) { - createPCleanObjects(pm); - createPNonTransactionalObjects(pm); - } - - /** */ - private void createPCleanObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - // create P-clean instances - tx.setOptimistic(false); - tx.begin(); - - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - - pm.makePersistent(p1); - pm.makePersistent(p2); - pm.makePersistent(p3); - pm.makePersistent(p4); - pm.makePersistent(p5); - tx.commit(); - - tx.begin(); - p1.getX(); - p2.getX(); - p3.getX(); - p4.getX(); - p5.getX(); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private void createObjects(PersistenceManager pm) { + createPCleanObjects(pm); + createPNonTransactionalObjects(pm); + } + + /** */ + private void createPCleanObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + // create P-clean instances + tx.setOptimistic(false); + tx.begin(); + + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint(5,7); + + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + pm.makePersistent(p5); + tx.commit(); + + tx.begin(); + p1.getX(); + p2.getX(); + p3.getX(); + p4.getX(); + p5.getX(); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - private void createPNonTransactionalObjects(PersistenceManager pm) { - if (isOptimisticSupported()) { - Transaction tx = pm.currentTransaction(); - try { - tx.setOptimistic(true); - tx.begin(); - - np1 = new PCPoint(1, 3); - np2 = new PCPoint(2, 4); - np3 = new PCPoint(3, 5); - np4 = new PCPoint(4, 6); - np5 = new PCPoint(5, 7); - - pm.makePersistent(np1); - pm.makePersistent(np2); - pm.makePersistent(np3); - pm.makePersistent(np4); - pm.makePersistent(np5); - tx.commit(); - - tx.begin(); - np1.getX(); - np2.getX(); - np3.getX(); - np4.getX(); - np5.getX(); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); - } + + /** */ + private void createPNonTransactionalObjects(PersistenceManager pm) { + if (isOptimisticSupported()) { + Transaction tx = pm.currentTransaction(); + try { + tx.setOptimistic(true); + tx.begin(); + + np1 = new PCPoint(1,3); + np2 = new PCPoint(2,4); + np3 = new PCPoint(3,5); + np4 = new PCPoint(4,6); + np5 = new PCPoint(5,7); + + pm.makePersistent(np1); + pm.makePersistent(np2); + pm.makePersistent(np3); + pm.makePersistent(np4); + pm.makePersistent(np5); + tx.commit(); + + tx.begin(); + np1.getX(); + np2.getX(); + np3.getX(); + np4.getX(); + np5.getX(); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } } - } - - /* test makeTransient (Object pc) - * instance passed has field values and is P-nontransactional * - */ - private void runTestMakeTransientFieldsPreservedUnchanged1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - pm.makeTransient(p1); - tx.commit(); - tx = null; - - if (!testState(p1, TRANSIENT, "transient")) { - fail( - ASSERTION_FAILED, - "expected TRANSIENT instance, instance " + p1 + " is " + getStateOfInstance(p1)); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /* test makeTransient (Object pc) + * instance passed has field values and is P-nontransactional * + */ + private void runTestMakeTransientFieldsPreservedUnchanged1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + pm.makeTransient(p1); + tx.commit(); + tx = null; + + if (!testState(p1, TRANSIENT, "transient")) { + fail(ASSERTION_FAILED, + "expected TRANSIENT instance, instance " + p1 + + " is " + getStateOfInstance(p1)); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /* test makeTransientAll (Collection pcs) */ - private void runTestMakeTransientFieldsPreservedUnchangedAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Collection col1 = new HashSet(); - col1.add(p2); - col1.add(p3); - - pm.makeTransientAll(col1); - tx.commit(); - tx = null; - - for (Iterator iter = col1.iterator(); iter.hasNext(); ) { - PCPoint p = (PCPoint) iter.next(); - if (!testState(p, TRANSIENT, "transient")) { - fail( - ASSERTION_FAILED, - "expected TRANSIENT instance, instance " + p + " is " + getStateOfInstance(p)); + + /* test makeTransientAll (Collection pcs) */ + private void runTestMakeTransientFieldsPreservedUnchangedAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 = new HashSet(); + col1.add(p2); + col1.add(p3); + + pm.makeTransientAll(col1); + tx.commit(); + tx = null; + + for (Iterator iter = col1.iterator(); iter.hasNext();) { + PCPoint p = (PCPoint) iter.next(); + if (!testState(p, TRANSIENT, "transient")) { + fail(ASSERTION_FAILED, + "expected TRANSIENT instance, instance " + p + + " is " + getStateOfInstance(p)); + } + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } - - /* test makeTransientAll (Object[] o) */ - private void runTestMakeTransientFieldsPreservedUnchangedAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - int NUM_OBJS = 2; - tx.begin(); - - Collection col1 = new HashSet(); - col1.add(p4); - col1.add(p5); - - Object[] obj1 = col1.toArray(); - - pm.makeTransientAll(obj1); - tx.commit(); - tx = null; - - for (int i = 0; i < NUM_OBJS; ++i) { - PCPoint p = (PCPoint) obj1[i]; - if (!testState(p, TRANSIENT, "transient")) { - fail( - ASSERTION_FAILED, - "expected TRANSIENT instance, instance " + p + " is " + getStateOfInstance(p)); + + /* test makeTransientAll (Object[] o) */ + private void runTestMakeTransientFieldsPreservedUnchangedAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + int NUM_OBJS = 2; + tx.begin(); + + Collection col1 = new HashSet(); + col1.add(p4); + col1.add(p5); + + Object[] obj1= col1.toArray(); + + pm.makeTransientAll(obj1); + tx.commit(); + tx = null; + + for (int i=0; i < NUM_OBJS; ++i ) { + PCPoint p = (PCPoint) obj1[i]; + if (!testState(p, TRANSIENT, "transient")) { + fail(ASSERTION_FAILED, + "expected TRANSIENT instance, instance " + p + + " is " + getStateOfInstance(p)); + } + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientHasNoEffectOnTransientInstances.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientHasNoEffectOnTransientInstances.java index 82d89855e..6564f19da 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientHasNoEffectOnTransientInstances.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientHasNoEffectOnTransientInstances.java @@ -5,129 +5,148 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.lifecycle; import java.util.Collection; import java.util.HashSet; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: MakeTransientHasNoEffectOnTransientInstances
    - * Keywords: transient
    - * Assertion IDs: A12.5.7-19
    - * Assertion Description: PersistenceManager.makeTransient and makeTransientAll have no - * effect if the parameter instance is transient. + *Title: MakeTransientHasNoEffectOnTransientInstances + *
    + *Keywords: transient + *
    + *Assertion IDs: A12.5.7-19 + *
    + *Assertion Description: +PersistenceManager.makeTransient and +makeTransientAll have no effect if the parameter instance is transient. + */ -public class MakeTransientHasNoEffectOnTransientInstances extends PersistenceManagerTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-19 (MakeTransientHasNoEffectOnTransientInstances) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeTransientHasNoEffectOnTransientInstances.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - - /** */ - public void testMakeTransientHasNoEffectOnTransientInstances() { - pm = getPM(); - - createTransientObjects(); - runTestMakeTransientHasNoEffectOnTransientInstances1(pm); - runTestMakeTransientHasNoEffectOnTransientInstancesAll1(pm); - runTestMakeTransientHasNoEffectOnTransientInstancesAll2(pm); - - pm.close(); - pm = null; - } - - /** */ - private void createTransientObjects() { - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - } - - /* test makeTransient (Object pc) */ - private void runTestMakeTransientHasNoEffectOnTransientInstances1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - pm.makeTransient(p1); - tx.commit(); - tx = null; - if (debug) logger.debug(" \nPASSED in runTestMakeTransientHasNoEffectOnTransientInstances()"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + +public class MakeTransientHasNoEffectOnTransientInstances + extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-19 (MakeTransientHasNoEffectOnTransientInstances) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeTransientHasNoEffectOnTransientInstances.class); + } + + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + + /** */ + public void testMakeTransientHasNoEffectOnTransientInstances() { + pm = getPM(); + + createTransientObjects(); + runTestMakeTransientHasNoEffectOnTransientInstances1(pm); + runTestMakeTransientHasNoEffectOnTransientInstancesAll1(pm); + runTestMakeTransientHasNoEffectOnTransientInstancesAll2(pm); + + pm.close(); + pm = null; } - } - - /* test makeTransientAll (Collection pcs) */ - private void runTestMakeTransientHasNoEffectOnTransientInstancesAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Collection col1 = new HashSet(); - col1.add(p2); - col1.add(p3); - - pm.makeTransientAll(col1); - tx.commit(); - tx = null; - if (debug) - logger.debug(" \nPASSED in runTestMakeTransientHasNoEffectOnTransientInstancesAll1()"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + private void createTransientObjects() { + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint(5,7); } - } - - /* test makeTransientAll (Object[] o) */ - private void runTestMakeTransientHasNoEffectOnTransientInstancesAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Collection col1 = new HashSet(); - col1.add(p4); - col1.add(p5); - - Object[] obj1 = col1.toArray(); - - pm.makeTransientAll(obj1); - tx.commit(); - tx = null; - if (debug) - logger.debug(" \nPASSED in runTestMakeTransientHasNoEffectOnTransientInstancesAll2()"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /* test makeTransient (Object pc) */ + private void runTestMakeTransientHasNoEffectOnTransientInstances1( + PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + pm.makeTransient(p1); + tx.commit(); + tx = null; + if (debug) + logger.debug (" \nPASSED in runTestMakeTransientHasNoEffectOnTransientInstances()"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /* test makeTransientAll (Collection pcs) */ + private void runTestMakeTransientHasNoEffectOnTransientInstancesAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 = new HashSet(); + col1.add(p2); + col1.add(p3); + + pm.makeTransientAll(col1); + tx.commit(); + tx = null; + if (debug) + logger.debug(" \nPASSED in runTestMakeTransientHasNoEffectOnTransientInstancesAll1()"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /* test makeTransientAll (Object[] o) */ + private void runTestMakeTransientHasNoEffectOnTransientInstancesAll2( + PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 = new HashSet(); + col1.add(p4); + col1.add(p5); + + Object[] obj1= col1.toArray(); + + pm.makeTransientAll(obj1); + tx.commit(); + tx = null; + if (debug) + logger.debug (" \nPASSED in runTestMakeTransientHasNoEffectOnTransientInstancesAll2()"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientNotSubjectToRollback.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientNotSubjectToRollback.java index 2f9752c7b..045a40dcb 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientNotSubjectToRollback.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientNotSubjectToRollback.java @@ -5,166 +5,182 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.lifecycle; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; /** - * Title: MakeTransientNotSubjectToRollback
    - * Keywords:
    - * Assertion IDs: A12.5.7-17
    - * Assertion Description: The effect of PersistenceManager.makeTransient or makeTransientAll - * is immediate and not subject to rollback. + *Title: MakeTransientNotSubjectToRollback + *
    + *Keywords: + *
    + *Assertion IDs: A12.5.7-17 + *
    + *Assertion Description: +The effect of PersistenceManager.makeTransient or makeTransientAll is immediate and not subject to rollback. + */ + public class MakeTransientNotSubjectToRollback extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.5.7-17 (MakeTransientNotSubjectToRollback) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeTransientNotSubjectToRollback.class); + } - /** */ - private static final String ASSERTION_FAILED = - "Assertion A12.5.7-17 (MakeTransientNotSubjectToRollback) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeTransientNotSubjectToRollback.class); - } - - private PCPoint p1 = null; - private PCPoint p2 = null; - private PCPoint p3 = null; - private PCPoint p4 = null; - private PCPoint p5 = null; - - /** */ - public void testMakeTransientNotSubjectToRollback() { - pm = getPM(); - - createPersistentObjects(pm); - runTestMakeTransientNotSubjectToRollback1(pm); - runTestMakeTransientNotSubjectToRollbackAll1(pm); - runTestMakeTransientNotSubjectToRollbackAll2(pm); - - pm.close(); - pm = null; - } - - /** */ - private void createPersistentObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - p1 = new PCPoint(1, 3); - p2 = new PCPoint(2, 4); - p3 = new PCPoint(3, 5); - p4 = new PCPoint(4, 6); - p5 = new PCPoint(5, 7); - - pm.makePersistent(p1); - pm.makePersistent(p2); - pm.makePersistent(p3); - pm.makePersistent(p4); - pm.makePersistent(p5); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + private PCPoint p1 = null; + private PCPoint p2 = null; + private PCPoint p3 = null; + private PCPoint p4 = null; + private PCPoint p5 = null; + + /** */ + public void testMakeTransientNotSubjectToRollback() { + pm = getPM(); + + createPersistentObjects(pm); + runTestMakeTransientNotSubjectToRollback1(pm); + runTestMakeTransientNotSubjectToRollbackAll1(pm); + runTestMakeTransientNotSubjectToRollbackAll2(pm); + + pm.close(); + pm = null; + } + + /** */ + private void createPersistentObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + p1 = new PCPoint(1,3); + p2 = new PCPoint(2,4); + p3 = new PCPoint(3,5); + p4 = new PCPoint(4,6); + p5 = new PCPoint(5,7); + + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + pm.makePersistent(p5); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /* test makeTransient (Object pc) */ - private void runTestMakeTransientNotSubjectToRollback1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - pm.makeTransient(p1); - int curr1 = currentState(p1); - tx.rollback(); - - if (curr1 != currentState(p1)) { - fail( - ASSERTION_FAILED, - "expected TRANSIENT instancew, instance " + p1 + " is " + getStateOfInstance(p1)); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /* test makeTransient (Object pc) */ + private void runTestMakeTransientNotSubjectToRollback1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + pm.makeTransient(p1); + int curr1 = currentState(p1); + tx.rollback(); + + if (curr1 != currentState(p1)) { + fail(ASSERTION_FAILED, + "expected TRANSIENT instancew, instance " + p1 + + " is " + getStateOfInstance(p1)); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /* test makeTransientAll (Collection pcs) */ - private void runTestMakeTransientNotSubjectToRollbackAll1(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Collection col1 = new java.util.HashSet(); - col1.add(p2); - col1.add(p3); - pm.makeTransientAll(col1); - int p2_curr = currentState(p2); - int p3_curr = currentState(p3); - tx.rollback(); - - if (p2_curr != currentState(p2)) { - fail( - ASSERTION_FAILED, - "expected TRANSIENT instancew, instance " + p2 + " is " + getStateOfInstance(p2)); - } - if (p3_curr != currentState(p3)) { - fail( - ASSERTION_FAILED, - "expected TRANSIENT instancew, instance " + p3 + " is " + getStateOfInstance(p3)); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /* test makeTransientAll (Collection pcs) */ + private void runTestMakeTransientNotSubjectToRollbackAll1(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 = new java.util.HashSet(); + col1.add(p2); + col1.add(p3); + pm.makeTransientAll(col1); + int p2_curr = currentState(p2); + int p3_curr = currentState(p3); + tx.rollback(); + + if (p2_curr != currentState(p2)) { + fail(ASSERTION_FAILED, + "expected TRANSIENT instancew, instance " + p2 + + " is " + getStateOfInstance(p2)); + } + if (p3_curr != currentState(p3)) { + fail(ASSERTION_FAILED, + "expected TRANSIENT instancew, instance " + p3 + + " is " + getStateOfInstance(p3)); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /* test makeTransientAll (Object[] o) */ - private void runTestMakeTransientNotSubjectToRollbackAll2(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Collection col1 = new java.util.HashSet(); - col1.add(p4); - col1.add(p5); - - Object[] obj1 = col1.toArray(); - - pm.makeTransientAll(obj1); - int p4_curr = currentState(p4); - int p5_curr = currentState(p5); - tx.rollback(); - - if (p4_curr != currentState(p4)) { - fail( - ASSERTION_FAILED, - "expected TRANSIENT instancew, instance " + p4 + " is " + getStateOfInstance(p2)); - } - if (p5_curr != currentState(p5)) { - fail( - ASSERTION_FAILED, - "expected TRANSIENT instancew, instance " + p5 + " is " + getStateOfInstance(p5)); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /* test makeTransientAll (Object[] o) */ + private void runTestMakeTransientNotSubjectToRollbackAll2(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 = new java.util.HashSet(); + col1.add(p4); + col1.add(p5); + + Object[] obj1= col1.toArray(); + + pm.makeTransientAll(obj1); + int p4_curr = currentState(p4); + int p5_curr = currentState(p5); + tx.rollback(); + + if (p4_curr != currentState(p4)) { + fail(ASSERTION_FAILED, + "expected TRANSIENT instancew, instance " + p4 + + " is " + getStateOfInstance(p2)); + } + if (p5_curr != currentState(p5)) { + fail(ASSERTION_FAILED, + "expected TRANSIENT instancew, instance " + p5 + + " is " + getStateOfInstance(p5)); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/DeletePersistentNullArgs.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/DeletePersistentNullArgs.java index 27d0e4f87..4bcfc7449 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/DeletePersistentNullArgs.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/DeletePersistentNullArgs.java @@ -5,93 +5,105 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.nullargs; import java.util.Collection; + +import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: deletePersistent with Null Arguments
    - * Keywords:
    - * Assertion IDs: A12.6-3, A12.6-4, A12.6-5
    - * Assertion Description: A12.6-3 [Null arguments to APIs that take an Object parameter - * cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or - * Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or - * Collection arguments that contain null elements will have the documented behavior for non-null - * elements, and the null elements will be ignored.] + *Title: deletePersistent with Null Arguments + *
    + *Keywords: + *
    + *Assertion IDs: A12.6-3, A12.6-4, A12.6-5 + *
    + *Assertion Description: +A12.6-3 [Null arguments to APIs that take an Object parameter cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or Collection arguments that contain null elements will have the documented behavior for non-null elements, and the null elements will be ignored.] */ -public class DeletePersistentNullArgs extends PersistenceManagerNullsTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DeletePersistentNullArgs.class); - } +public class DeletePersistentNullArgs extends PersistenceManagerNullsTest { + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DeletePersistentNullArgs.class); + } - static MethodUnderTest deletePersistent = new MethodUnderTestDeletePersistent(); + static MethodUnderTest deletePersistent = + new MethodUnderTestDeletePersistent(); + static class MethodUnderTestDeletePersistent extends MethodUnderTest { + public void pmApi(PersistenceManager pm, Object pc) { + pm.deletePersistent(pc); + } + public void pmApi(PersistenceManager pm, Collection pcs) { + pm.deletePersistentAll(pcs); + } + public void pmApi(PersistenceManager pm, Object[] pcs) { + pm.deletePersistentAll(pcs); + } + }; - static class MethodUnderTestDeletePersistent extends MethodUnderTest { - public void pmApi(PersistenceManager pm, Object pc) { - pm.deletePersistent(pc); + /** + * Test that deletePersistent() with null valued argument does nothing. + */ + public void testDeletePersistentNullObject() { + executeNullObjectParameter(deletePersistent, "deletePersistent(null)"); } - public void pmApi(PersistenceManager pm, Collection pcs) { - pm.deletePersistentAll(pcs); + /** + * Test that deletePersistentAll() with null valued Collection argument + * throws NullPointerException. + */ + public void testDeletePersistentNullCollection() { + executeNullCollectionParameter(deletePersistent, + "deletePersistentAll((Collection)null)"); } - public void pmApi(PersistenceManager pm, Object[] pcs) { - pm.deletePersistentAll(pcs); + /** + * Test that deletePersistentAll() with null valued array argument + * throws NullPointerException. + */ + public void testDeletePersistentNullArray() { + executeNullArrayParameter(deletePersistent, + "deletePersistentAll((Object[])null)"); } - } - ; - - /** Test that deletePersistent() with null valued argument does nothing. */ - public void testDeletePersistentNullObject() { - executeNullObjectParameter(deletePersistent, "deletePersistent(null)"); - } - - /** - * Test that deletePersistentAll() with null valued Collection argument throws - * NullPointerException. - */ - public void testDeletePersistentNullCollection() { - executeNullCollectionParameter(deletePersistent, "deletePersistentAll((Collection)null)"); - } - /** - * Test that deletePersistentAll() with null valued array argument throws NullPointerException. - */ - public void testDeletePersistentNullArray() { - executeNullArrayParameter(deletePersistent, "deletePersistentAll((Object[])null)"); - } + /** + * Test that deletePersistentAll() with a null element of a + * Collection argument throws NullPointerException. + */ + public void testDeletePersistentCollectionNullElement() { + executeCollectionNullElement(collNullElem, deletePersistent, + "deletePersistentAll(Collection)"); + } - /** - * Test that deletePersistentAll() with a null element of a Collection argument throws - * NullPointerException. - */ - public void testDeletePersistentCollectionNullElement() { - executeCollectionNullElement(collNullElem, deletePersistent, "deletePersistentAll(Collection)"); - } + /** + * Test that deletePersistentAll() with a null element of a + * array argument throws NullPointerException. + */ + public void testDeletePersistentArrayNullElement() { + executeArrayNullElement(arrayNullElem, deletePersistent, + "deletePersistentAll(Object[])"); + } - /** - * Test that deletePersistentAll() with a null element of a array argument throws - * NullPointerException. - */ - public void testDeletePersistentArrayNullElement() { - executeArrayNullElement(arrayNullElem, deletePersistent, "deletePersistentAll(Object[])"); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/DetachCopyNullArgs.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/DetachCopyNullArgs.java index 93d3dc9dc..d1b0c59b8 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/DetachCopyNullArgs.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/DetachCopyNullArgs.java @@ -5,87 +5,104 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.nullargs; import java.util.Collection; + +import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: detachCopy with Null Arguments
    - * Keywords:
    - * Assertion IDs: A12.6-3, A12.6-4, A12.6-5
    - * Assertion Description: A12.6-3 [Null arguments to APIs that take an Object parameter - * cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or - * Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or - * Collection arguments that contain null elements will have the documented behavior for non-null - * elements, and the null elements will be ignored.] + *Title: detachCopy with Null Arguments + *
    + *Keywords: + *
    + *Assertion IDs: A12.6-3, A12.6-4, A12.6-5 + *
    + *Assertion Description: +A12.6-3 [Null arguments to APIs that take an Object parameter cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or Collection arguments that contain null elements will have the documented behavior for non-null elements, and the null elements will be ignored.] */ -public class DetachCopyNullArgs extends PersistenceManagerNullsTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DetachCopyNullArgs.class); - } +public class DetachCopyNullArgs extends PersistenceManagerNullsTest { + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DetachCopyNullArgs.class); + } - static MethodUnderTest detachCopy = new MethodUnderTestDetachCopy(); + static MethodUnderTest detachCopy = new MethodUnderTestDetachCopy(); + static class MethodUnderTestDetachCopy extends MethodUnderTest { + public Object pmApiReturn(PersistenceManager pm, Object pc) { + return pm.detachCopy(pc); + } + public Collection pmApiReturn(PersistenceManager pm, Collection pcs) { + return pm.detachCopyAll(pcs); + } + public Object[] pmApiReturn(PersistenceManager pm, Object[] pcs) { + return pm.detachCopyAll(pcs); + } + }; - static class MethodUnderTestDetachCopy extends MethodUnderTest { - public Object pmApiReturn(PersistenceManager pm, Object pc) { - return pm.detachCopy(pc); + /** + * Test that detachCopy() with null valued argument does nothing. + */ + public void testDetachCopyNullObject() { + executeNullObjectParameterReturn(detachCopy, "detachCopy(null)"); } - public Collection pmApiReturn(PersistenceManager pm, Collection pcs) { - return pm.detachCopyAll(pcs); + /** + * Test that detachCopyAll() with null valued Collection argument + * throws NullPointerException. + */ + public void testDetachCopyNullCollection() { + executeNullCollectionParameterReturn(detachCopy, + "detachCopyAll((Collection)null)"); } - public Object[] pmApiReturn(PersistenceManager pm, Object[] pcs) { - return pm.detachCopyAll(pcs); + /** + * Test that detachCopyAll() with null valued array argument + * throws NullPointerException. + */ + public void testDetachCopyNullArray() { + executeNullArrayParameterReturn(detachCopy, + "detachCopyAll((Array)null)"); } - } - ; - - /** Test that detachCopy() with null valued argument does nothing. */ - public void testDetachCopyNullObject() { - executeNullObjectParameterReturn(detachCopy, "detachCopy(null)"); - } - - /** Test that detachCopyAll() with null valued Collection argument throws NullPointerException. */ - public void testDetachCopyNullCollection() { - executeNullCollectionParameterReturn(detachCopy, "detachCopyAll((Collection)null)"); - } - /** Test that detachCopyAll() with null valued array argument throws NullPointerException. */ - public void testDetachCopyNullArray() { - executeNullArrayParameterReturn(detachCopy, "detachCopyAll((Array)null)"); - } + /** + * Test that detachCopyAll() with a null element of a + * Collection argument throws NullPointerException. + */ + public void testDetachCopyCollectionNullElement() { + executeCollectionNullElementReturn(collNullElem, detachCopy, + "detachCopyAll(Collection)"); + } - /** - * Test that detachCopyAll() with a null element of a Collection argument throws - * NullPointerException. - */ - public void testDetachCopyCollectionNullElement() { - executeCollectionNullElementReturn(collNullElem, detachCopy, "detachCopyAll(Collection)"); - } + /** + * Test that detachCopyAll() with a null element of a + * array argument throws NullPointerException. + */ + public void testDetachCopyArrayNullElement() { + executeArrayNullElementReturn(arrayNullElem, detachCopy, + "detachCopyAll(Array)"); + } - /** - * Test that detachCopyAll() with a null element of a array argument throws NullPointerException. - */ - public void testDetachCopyArrayNullElement() { - executeArrayNullElementReturn(arrayNullElem, detachCopy, "detachCopyAll(Array)"); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/EvictNullArgs.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/EvictNullArgs.java index a125b9745..5c0be7e59 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/EvictNullArgs.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/EvictNullArgs.java @@ -5,84 +5,105 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.nullargs; import java.util.Collection; + +import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: evict with Null Arguments
    - * Keywords:
    - * Assertion IDs: A12.6-3, A12.6-4, A12.6-5
    - * Assertion Description: A12.6-3 [Null arguments to APIs that take an Object parameter - * cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or - * Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or - * Collection arguments that contain null elements will have the documented behavior for non-null - * elements, and the null elements will be ignored.] + *Title: evict with Null Arguments + *
    + *Keywords: + *
    + *Assertion IDs: A12.6-3, A12.6-4, A12.6-5 + *
    + *Assertion Description: +A12.6-3 [Null arguments to APIs that take an Object parameter cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or Collection arguments that contain null elements will have the documented behavior for non-null elements, and the null elements will be ignored.] */ -public class EvictNullArgs extends PersistenceManagerNullsTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(EvictNullArgs.class); - } +public class EvictNullArgs extends PersistenceManagerNullsTest { + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(EvictNullArgs.class); + } - static MethodUnderTest evict = new MethodUnderTestEvict(); + static MethodUnderTest evict = + new MethodUnderTestEvict(); + static class MethodUnderTestEvict extends MethodUnderTest { + public void pmApi(PersistenceManager pm, Object pc) { + pm.evict(pc); + } + public void pmApi(PersistenceManager pm, Collection pcs) { + pm.evictAll(pcs); + } + public void pmApi(PersistenceManager pm, Object[] pcs) { + pm.evictAll(pcs); + } + }; - static class MethodUnderTestEvict extends MethodUnderTest { - public void pmApi(PersistenceManager pm, Object pc) { - pm.evict(pc); + /** + * Test that evict() with null valued argument does nothing. + */ + public void testEvictNullObject() { + executeNullObjectParameter(evict, "evict(null)"); } - public void pmApi(PersistenceManager pm, Collection pcs) { - pm.evictAll(pcs); + /** + * Test that evictAll() with null valued Collection argument + * throws NullPointerException. + */ + public void testEvictNullCollection() { + executeNullCollectionParameter(evict, + "evictAll((Collection)null)"); } - public void pmApi(PersistenceManager pm, Object[] pcs) { - pm.evictAll(pcs); + /** + * Test that evictAll() with null valued array argument + * throws NullPointerException. + */ + public void testEvictNullArray() { + executeNullArrayParameter(evict, + "evictAll((Object[])null)"); } - } - ; - - /** Test that evict() with null valued argument does nothing. */ - public void testEvictNullObject() { - executeNullObjectParameter(evict, "evict(null)"); - } - - /** Test that evictAll() with null valued Collection argument throws NullPointerException. */ - public void testEvictNullCollection() { - executeNullCollectionParameter(evict, "evictAll((Collection)null)"); - } - /** Test that evictAll() with null valued array argument throws NullPointerException. */ - public void testEvictNullArray() { - executeNullArrayParameter(evict, "evictAll((Object[])null)"); - } + /** + * Test that evictAll() with a null element of a + * Collection argument throws NullPointerException. + */ + public void testEvictCollectionNullElement() { + executeCollectionNullElement(collNullElem, evict, + "evictAll(Collection)"); + } - /** - * Test that evictAll() with a null element of a Collection argument throws NullPointerException. - */ - public void testEvictCollectionNullElement() { - executeCollectionNullElement(collNullElem, evict, "evictAll(Collection)"); - } + /** + * Test that evictAll() with a null element of a + * array argument throws NullPointerException. + */ + public void testEvictArrayNullElement() { + executeArrayNullElement(arrayNullElem, evict, + "evictAll(Object[])"); + } - /** Test that evictAll() with a null element of a array argument throws NullPointerException. */ - public void testEvictArrayNullElement() { - executeArrayNullElement(arrayNullElem, evict, "evictAll(Object[])"); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeNontransactionalNullArgs.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeNontransactionalNullArgs.java index 870fd993e..621435e1d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeNontransactionalNullArgs.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeNontransactionalNullArgs.java @@ -5,97 +5,105 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.nullargs; import java.util.Collection; + +import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: makeNontransactional with Null Arguments
    - * Keywords:
    - * Assertion IDs: A12.6-3, A12.6-4, A12.6-5
    - * Assertion Description: A12.6-3 [Null arguments to APIs that take an Object parameter - * cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or - * Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or - * Collection arguments that contain null elements will have the documented behavior for non-null - * elements, and the null elements will be ignored.] + *Title: makeNontransactional with Null Arguments + *
    + *Keywords: + *
    + *Assertion IDs: A12.6-3, A12.6-4, A12.6-5 + *
    + *Assertion Description: +A12.6-3 [Null arguments to APIs that take an Object parameter cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or Collection arguments that contain null elements will have the documented behavior for non-null elements, and the null elements will be ignored.] */ -public class MakeNontransactionalNullArgs extends PersistenceManagerNullsTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeNontransactionalNullArgs.class); - } +public class MakeNontransactionalNullArgs extends PersistenceManagerNullsTest { + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeNontransactionalNullArgs.class); + } - static MethodUnderTest makeNontransactional = new MethodUnderTestMakeNontransactional(); + static MethodUnderTest makeNontransactional = + new MethodUnderTestMakeNontransactional(); + static class MethodUnderTestMakeNontransactional extends MethodUnderTest { + public void pmApi(PersistenceManager pm, Object pc) { + pm.makeNontransactional(pc); + } + public void pmApi(PersistenceManager pm, Collection pcs) { + pm.makeNontransactionalAll(pcs); + } + public void pmApi(PersistenceManager pm, Object[] pcs) { + pm.makeNontransactionalAll(pcs); + } + }; - static class MethodUnderTestMakeNontransactional extends MethodUnderTest { - public void pmApi(PersistenceManager pm, Object pc) { - pm.makeNontransactional(pc); + /** + * Test that makeNontransactional() with null valued argument does nothing. + */ + public void testMakeNontransactionalNullObject() { + executeNullObjectParameter(makeNontransactional, "makeNontransactional(null)"); } - public void pmApi(PersistenceManager pm, Collection pcs) { - pm.makeNontransactionalAll(pcs); + /** + * Test that makeNontransactionalAll() with null valued Collection argument + * throws NullPointerException. + */ + public void testMakeNontransactionalNullCollection() { + executeNullCollectionParameter(makeNontransactional, + "makeNontransactionalAll((Collection)null)"); } - public void pmApi(PersistenceManager pm, Object[] pcs) { - pm.makeNontransactionalAll(pcs); + /** + * Test that makeNontransactionalAll() with null valued array argument + * throws NullPointerException. + */ + public void testMakeNontransactionalNullArray() { + executeNullArrayParameter(makeNontransactional, + "makeNontransactionalAll((Object[])null)"); } - } - ; - - /** Test that makeNontransactional() with null valued argument does nothing. */ - public void testMakeNontransactionalNullObject() { - executeNullObjectParameter(makeNontransactional, "makeNontransactional(null)"); - } - - /** - * Test that makeNontransactionalAll() with null valued Collection argument throws - * NullPointerException. - */ - public void testMakeNontransactionalNullCollection() { - executeNullCollectionParameter( - makeNontransactional, "makeNontransactionalAll((Collection)null)"); - } - /** - * Test that makeNontransactionalAll() with null valued array argument throws - * NullPointerException. - */ - public void testMakeNontransactionalNullArray() { - executeNullArrayParameter(makeNontransactional, "makeNontransactionalAll((Object[])null)"); - } + /** + * Test that makeNontransactionalAll() with a null element of a + * Collection argument throws NullPointerException. + */ + public void testMakeNontransactionalCollectionNullElement() { + executeCollectionNullElement(collNullElem, makeNontransactional, + "makeNontransactionalAll(Collection)"); + } - /** - * Test that makeNontransactionalAll() with a null element of a Collection argument throws - * NullPointerException. - */ - public void testMakeNontransactionalCollectionNullElement() { - executeCollectionNullElement( - collNullElem, makeNontransactional, "makeNontransactionalAll(Collection)"); - } + /** + * Test that makeNontransactionalAll() with a null element of a + * array argument throws NullPointerException. + */ + public void testMakeNontransactionalArrayNullElement() { + executeArrayNullElement(arrayNullElem, makeNontransactional, + "makeNontransactionalAll(Object[])"); + } - /** - * Test that makeNontransactionalAll() with a null element of a array argument throws - * NullPointerException. - */ - public void testMakeNontransactionalArrayNullElement() { - executeArrayNullElement( - arrayNullElem, makeNontransactional, "makeNontransactionalAll(Object[])"); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakePersistentNullArgs.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakePersistentNullArgs.java index efa657a47..2920730b0 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakePersistentNullArgs.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakePersistentNullArgs.java @@ -5,91 +5,104 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.nullargs; import java.util.Collection; + +import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: makePersistent with Null Arguments
    - * Keywords:
    - * Assertion IDs: A12.6-3, A12.6-4, A12.6-5
    - * Assertion Description: A12.6-3 [Null arguments to APIs that take an Object parameter - * cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or - * Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or - * Collection arguments that contain null elements will have the documented behavior for non-null - * elements, and the null elements will be ignored.] + *Title: makePersistent with Null Arguments + *
    + *Keywords: + *
    + *Assertion IDs: A12.6-3, A12.6-4, A12.6-5 + *
    + *Assertion Description: +A12.6-3 [Null arguments to APIs that take an Object parameter cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or Collection arguments that contain null elements will have the documented behavior for non-null elements, and the null elements will be ignored.] */ -public class MakePersistentNullArgs extends PersistenceManagerNullsTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakePersistentNullArgs.class); - } +public class MakePersistentNullArgs extends PersistenceManagerNullsTest { + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakePersistentNullArgs.class); + } - static MethodUnderTest makePersistent = new MethodUnderTestMakePersistent(); + static MethodUnderTest makePersistent = new MethodUnderTestMakePersistent(); + static class MethodUnderTestMakePersistent extends MethodUnderTest { + public Object pmApiReturn(PersistenceManager pm, Object pc) { + return pm.makePersistent(pc); + } + public Collection pmApiReturn(PersistenceManager pm, Collection pcs) { + return pm.makePersistentAll(pcs); + } + public Object[] pmApiReturn(PersistenceManager pm, Object[] pcs) { + return pm.makePersistentAll(pcs); + } + }; - static class MethodUnderTestMakePersistent extends MethodUnderTest { - public Object pmApiReturn(PersistenceManager pm, Object pc) { - return pm.makePersistent(pc); + /** + * Test that makePersistent() with null valued argument does nothing. + */ + public void testMakePersistentNullObject() { + executeNullObjectParameterReturn(makePersistent, "makePersistent(null)"); } - public Collection pmApiReturn(PersistenceManager pm, Collection pcs) { - return pm.makePersistentAll(pcs); + /** + * Test that makePersistentAll() with null valued Collection argument + * throws NullPointerException. + */ + public void testMakePersistentNullCollection() { + executeNullCollectionParameterReturn(makePersistent, + "makePersistentAll((Collection)null)"); } - public Object[] pmApiReturn(PersistenceManager pm, Object[] pcs) { - return pm.makePersistentAll(pcs); + /** + * Test that makePersistentAll() with null valued array argument + * throws NullPointerException. + */ + public void testMakePersistentNullArray() { + executeNullArrayParameterReturn(makePersistent, + "makePersistentAll((Array)null)"); } - } - ; - - /** Test that makePersistent() with null valued argument does nothing. */ - public void testMakePersistentNullObject() { - executeNullObjectParameterReturn(makePersistent, "makePersistent(null)"); - } - - /** - * Test that makePersistentAll() with null valued Collection argument throws NullPointerException. - */ - public void testMakePersistentNullCollection() { - executeNullCollectionParameterReturn(makePersistent, "makePersistentAll((Collection)null)"); - } - /** Test that makePersistentAll() with null valued array argument throws NullPointerException. */ - public void testMakePersistentNullArray() { - executeNullArrayParameterReturn(makePersistent, "makePersistentAll((Array)null)"); - } + /** + * Test that makePersistentAll() with a null element of a + * Collection argument throws NullPointerException. + */ + public void testMakePersistentCollectionNullElement() { + executeCollectionNullElementReturn(collNullElem, makePersistent, + "makePersistentAll(Collection)"); + } - /** - * Test that makePersistentAll() with a null element of a Collection argument throws - * NullPointerException. - */ - public void testMakePersistentCollectionNullElement() { - executeCollectionNullElementReturn( - collNullElem, makePersistent, "makePersistentAll(Collection)"); - } + /** + * Test that makePersistentAll() with a null element of a + * array argument throws NullPointerException. + */ + public void testMakePersistentArrayNullElement() { + executeArrayNullElementReturn(arrayNullElem, makePersistent, + "makePersistentAll(Array)"); + } - /** - * Test that makePersistentAll() with a null element of a array argument throws - * NullPointerException. - */ - public void testMakePersistentArrayNullElement() { - executeArrayNullElementReturn(arrayNullElem, makePersistent, "makePersistentAll(Array)"); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeTransactionalNullArgs.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeTransactionalNullArgs.java index 6485c6579..03ea95fe2 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeTransactionalNullArgs.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeTransactionalNullArgs.java @@ -5,94 +5,105 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.nullargs; import java.util.Collection; + +import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: makeTransactional with Null Arguments
    - * Keywords:
    - * Assertion IDs: A12.6-3, A12.6-4, A12.6-5
    - * Assertion Description: A12.6-3 [Null arguments to APIs that take an Object parameter - * cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or - * Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or - * Collection arguments that contain null elements will have the documented behavior for non-null - * elements, and the null elements will be ignored.] + *Title: makeTransactional with Null Arguments + *
    + *Keywords: + *
    + *Assertion IDs: A12.6-3, A12.6-4, A12.6-5 + *
    + *Assertion Description: +A12.6-3 [Null arguments to APIs that take an Object parameter cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or Collection arguments that contain null elements will have the documented behavior for non-null elements, and the null elements will be ignored.] */ -public class MakeTransactionalNullArgs extends PersistenceManagerNullsTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeTransactionalNullArgs.class); - } +public class MakeTransactionalNullArgs extends PersistenceManagerNullsTest { + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeTransactionalNullArgs.class); + } - static MethodUnderTest makeTransactional = new MethodUnderTestMakeTransactional(); + static MethodUnderTest makeTransactional = + new MethodUnderTestMakeTransactional(); + static class MethodUnderTestMakeTransactional extends MethodUnderTest { + public void pmApi(PersistenceManager pm, Object pc) { + pm.makeTransactional(pc); + } + public void pmApi(PersistenceManager pm, Collection pcs) { + pm.makeTransactionalAll(pcs); + } + public void pmApi(PersistenceManager pm, Object[] pcs) { + pm.makeTransactionalAll(pcs); + } + }; - static class MethodUnderTestMakeTransactional extends MethodUnderTest { - public void pmApi(PersistenceManager pm, Object pc) { - pm.makeTransactional(pc); + /** + * Test that makeTransactional() with null valued argument does nothing. + */ + public void testMakeTransactionalNullObject() { + executeNullObjectParameter(makeTransactional, "makeTransactional(null)"); } - public void pmApi(PersistenceManager pm, Collection pcs) { - pm.makeTransactionalAll(pcs); + /** + * Test that makeTransactionalAll() with null valued Collection argument + * throws NullPointerException. + */ + public void testMakeTransactionalNullCollection() { + executeNullCollectionParameter(makeTransactional, + "makeTransactionalAll((Collection)null)"); } - public void pmApi(PersistenceManager pm, Object[] pcs) { - pm.makeTransactionalAll(pcs); + /** + * Test that makeTransactionalAll() with null valued array argument + * throws NullPointerException. + */ + public void testMakeTransactionalNullArray() { + executeNullArrayParameter(makeTransactional, + "makeTransactionalAll((Object[])null)"); } - } - ; - - /** Test that makeTransactional() with null valued argument does nothing. */ - public void testMakeTransactionalNullObject() { - executeNullObjectParameter(makeTransactional, "makeTransactional(null)"); - } - - /** - * Test that makeTransactionalAll() with null valued Collection argument throws - * NullPointerException. - */ - public void testMakeTransactionalNullCollection() { - executeNullCollectionParameter(makeTransactional, "makeTransactionalAll((Collection)null)"); - } - /** - * Test that makeTransactionalAll() with null valued array argument throws NullPointerException. - */ - public void testMakeTransactionalNullArray() { - executeNullArrayParameter(makeTransactional, "makeTransactionalAll((Object[])null)"); - } + /** + * Test that makeTransactionalAll() with a null element of a + * Collection argument throws NullPointerException. + */ + public void testMakeTransactionalCollectionNullElement() { + executeCollectionNullElement(collNullElem, makeTransactional, + "makeTransactionalAll(Collection)"); + } - /** - * Test that makeTransactionalAll() with a null element of a Collection argument throws - * NullPointerException. - */ - public void testMakeTransactionalCollectionNullElement() { - executeCollectionNullElement( - collNullElem, makeTransactional, "makeTransactionalAll(Collection)"); - } + /** + * Test that makeTransactionalAll() with a null element of a + * array argument throws NullPointerException. + */ + public void testMakeTransactionalArrayNullElement() { + executeArrayNullElement(arrayNullElem, makeTransactional, + "makeTransactionalAll(Object[])"); + } - /** - * Test that makeTransactionalAll() with a null element of a array argument throws - * NullPointerException. - */ - public void testMakeTransactionalArrayNullElement() { - executeArrayNullElement(arrayNullElem, makeTransactional, "makeTransactionalAll(Object[])"); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeTransientNullArgs.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeTransientNullArgs.java index 5b193f785..0cad7aa0a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeTransientNullArgs.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/MakeTransientNullArgs.java @@ -5,90 +5,105 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.nullargs; import java.util.Collection; + +import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: makeTransient with Null Arguments
    - * Keywords:
    - * Assertion IDs: A12.6-3, A12.6-4, A12.6-5
    - * Assertion Description: A12.6-3 [Null arguments to APIs that take an Object parameter - * cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or - * Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or - * Collection arguments that contain null elements will have the documented behavior for non-null - * elements, and the null elements will be ignored.] + *Title: makeTransient with Null Arguments + *
    + *Keywords: + *
    + *Assertion IDs: A12.6-3, A12.6-4, A12.6-5 + *
    + *Assertion Description: +A12.6-3 [Null arguments to APIs that take an Object parameter cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or Collection arguments that contain null elements will have the documented behavior for non-null elements, and the null elements will be ignored.] */ -public class MakeTransientNullArgs extends PersistenceManagerNullsTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MakeTransientNullArgs.class); - } +public class MakeTransientNullArgs extends PersistenceManagerNullsTest { + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MakeTransientNullArgs.class); + } - static MethodUnderTest makeTransient = new MethodUnderTestMakeTransient(); + static MethodUnderTest makeTransient = + new MethodUnderTestMakeTransient(); + static class MethodUnderTestMakeTransient extends MethodUnderTest { + public void pmApi(PersistenceManager pm, Object pc) { + pm.makeTransient(pc); + } + public void pmApi(PersistenceManager pm, Collection pcs) { + pm.makeTransientAll(pcs); + } + public void pmApi(PersistenceManager pm, Object[] pcs) { + pm.makeTransientAll(pcs); + } + }; - static class MethodUnderTestMakeTransient extends MethodUnderTest { - public void pmApi(PersistenceManager pm, Object pc) { - pm.makeTransient(pc); + /** + * Test that makeTransient() with null valued argument does nothing. + */ + public void testMakeTransientNullObject() { + executeNullObjectParameter(makeTransient, "makeTransient(null)"); } - public void pmApi(PersistenceManager pm, Collection pcs) { - pm.makeTransientAll(pcs); + /** + * Test that makeTransientAll() with null valued Collection argument + * throws NullPointerException. + */ + public void testMakeTransientNullCollection() { + executeNullCollectionParameter(makeTransient, + "makeTransientAll((Collection)null)"); } - public void pmApi(PersistenceManager pm, Object[] pcs) { - pm.makeTransientAll(pcs); + /** + * Test that makeTransientAll() with null valued array argument + * throws NullPointerException. + */ + public void testMakeTransientNullArray() { + executeNullArrayParameter(makeTransient, + "makeTransientAll((Object[])null)"); } - } - ; - - /** Test that makeTransient() with null valued argument does nothing. */ - public void testMakeTransientNullObject() { - executeNullObjectParameter(makeTransient, "makeTransient(null)"); - } - - /** - * Test that makeTransientAll() with null valued Collection argument throws NullPointerException. - */ - public void testMakeTransientNullCollection() { - executeNullCollectionParameter(makeTransient, "makeTransientAll((Collection)null)"); - } - /** Test that makeTransientAll() with null valued array argument throws NullPointerException. */ - public void testMakeTransientNullArray() { - executeNullArrayParameter(makeTransient, "makeTransientAll((Object[])null)"); - } + /** + * Test that makeTransientAll() with a null element of a + * Collection argument throws NullPointerException. + */ + public void testMakeTransientCollectionNullElement() { + executeCollectionNullElement(collNullElem, makeTransient, + "makeTransientAll(Collection)"); + } - /** - * Test that makeTransientAll() with a null element of a Collection argument throws - * NullPointerException. - */ - public void testMakeTransientCollectionNullElement() { - executeCollectionNullElement(collNullElem, makeTransient, "makeTransientAll(Collection)"); - } + /** + * Test that makeTransientAll() with a null element of a + * array argument throws NullPointerException. + */ + public void testMakeTransientArrayNullElement() { + executeArrayNullElement(arrayNullElem, makeTransient, + "makeTransientAll(Object[])"); + } - /** - * Test that makeTransientAll() with a null element of a array argument throws - * NullPointerException. - */ - public void testMakeTransientArrayNullElement() { - executeArrayNullElement(arrayNullElem, makeTransient, "makeTransientAll(Object[])"); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/PersistenceManagerNullsTest.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/PersistenceManagerNullsTest.java index 69f48a625..7e7fc744f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/PersistenceManagerNullsTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/PersistenceManagerNullsTest.java @@ -5,530 +5,553 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.nullargs; + import java.util.Arrays; +import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; + +import javax.jdo.JDOHelper; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; /** - * The superclass for the tests of null arguments to pm methods. - * - *

    Null arguments to APIs that take an Object parameter cause the API to have no effect. Null - * arguments to APIs that take Object[] or Collection will cause the API to throw - * NullPointerException. Non-null Object[] or Collection arguments that contain null elements will - * have the documented behavior for non-null elements, and the null elements will be ignored. - */ + * The superclass for the tests of null arguments to pm methods. + * + * Null arguments to APIs that take an Object parameter cause the API + * to have no effect. Null arguments to APIs that take Object[] or Collection + * will cause the API to throw NullPointerException. Non-null Object[] or + * Collection arguments that contain null elements will have the documented + * behavior for non-null elements, and the null elements will be ignored. + * + */ + public class PersistenceManagerNullsTest extends JDO_Test { - /** */ - public static class MethodUnderTest { - public void pmApi(PersistenceManager pm, Object obj) { - throw new UnsupportedOperationException("Test must implement this method"); - } + /** + */ + public static class MethodUnderTest { + public void pmApi(PersistenceManager pm, Object obj) { + throw new UnsupportedOperationException("Test must implement this method"); + } + public void pmApi(PersistenceManager pm, Collection coll) { + throw new UnsupportedOperationException("Test must implement this method"); + } + public void pmApi(PersistenceManager pm, Object[] objs) { + throw new UnsupportedOperationException("Test must implement this method"); + } + public Object pmApiReturn(PersistenceManager pm, Object obj) { + throw new UnsupportedOperationException("Test must implement this method"); + } + public Collection pmApiReturn(PersistenceManager pm, Collection coll) { + throw new UnsupportedOperationException("Test must implement this method"); + } + public Object[] pmApiReturn(PersistenceManager pm, Object[] objs) { + throw new UnsupportedOperationException("Test must implement this method"); + } + } + + + private static final String ASSERTION3_FAILED = + "Assertion A12.6-3 failed: "; + + private static final String ASSERTION4_FAILED = + "Assertion A12.6-4 failed: "; + + private static final String ASSERTION5_FAILED = + "Assertion A12.6-5 failed: "; + + protected PCPoint pNotNull = null; + protected Collection collNullElem = null; + protected Collection expectedCollection = null; + protected Object[] arrayNullElem = new Object[] {null, null}; + protected Object[] expectedArray = new Object[] {null, null}; + protected Collection testInstances = null; + + /** */ + protected PersistenceManagerNullsTest() { } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + // The order of addTearDownClass calls is significant + // as it takes into account database FKs. + addTearDownClass(PCPoint.class); + + // Initialize test objects and expected values + pNotNull = new PCPoint(3, 5); + arrayNullElem[1] = pNotNull; + expectedArray[1] = pNotNull; + collNullElem = Arrays.asList(arrayNullElem); + + pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx = pm.currentTransaction(); + + tx.begin(); + try { + pm.makePersistent(pNotNull); + } catch (Exception e) { + e.printStackTrace(); + } + tx.commit(); + + logger.debug(" \nSetup committed in DeletePersistentNullArgs()"); + } + finally { + if (tx.isActive()) { + tx.rollback(); + } + } expectedCollection = Arrays.asList(arrayNullElem); - public void pmApi(PersistenceManager pm, Collection coll) { - throw new UnsupportedOperationException("Test must implement this method"); } - - public void pmApi(PersistenceManager pm, Object[] objs) { - throw new UnsupportedOperationException("Test must implement this method"); + + protected static String toString(Object[] objs) { + StringBuffer out = new StringBuffer(); + for (int i=0; i < objs.length; i++) { + out.append("[" + i + "]: "); + if (objs[i] == null) + out.append("null"); + else out.append(objs[i].toString()); + out.append(", "); + } + return out.toString(); } - public Object pmApiReturn(PersistenceManager pm, Object obj) { - throw new UnsupportedOperationException("Test must implement this method"); + protected static String toString(Collection objs) { + return toString(objs.toArray()); } - public Collection pmApiReturn(PersistenceManager pm, Collection coll) { - throw new UnsupportedOperationException("Test must implement this method"); + /** + * Checks if expected and actual arguments match for null/non-null value + * @return true if arguments match + * @param expected Collection + * @param actual Collection + */ + protected boolean checkReturn(Collection expected, Collection actual) { + Object eElem = null; + Object aElem = null; + if (expected.size() != actual.size()) + return false; + Iterator eIt = expected.iterator(); + Iterator aIt = actual.iterator(); + while (eIt.hasNext()) { + eElem = eIt.next(); + aElem = aIt.next(); + if ( (eElem == null && aElem != null) + || (aElem == null && eElem != null) ) + return false; + } + return true; } - public Object[] pmApiReturn(PersistenceManager pm, Object[] objs) { - throw new UnsupportedOperationException("Test must implement this method"); - } - } - - private static final String ASSERTION3_FAILED = "Assertion A12.6-3 failed: "; - - private static final String ASSERTION4_FAILED = "Assertion A12.6-4 failed: "; - - private static final String ASSERTION5_FAILED = "Assertion A12.6-5 failed: "; - - protected PCPoint pNotNull = null; - protected Collection collNullElem = null; - protected Collection expectedCollection = null; - protected Object[] arrayNullElem = new Object[] {null, null}; - protected Object[] expectedArray = new Object[] {null, null}; - protected Collection testInstances = null; - - /** */ - protected PersistenceManagerNullsTest() {} - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - // The order of addTearDownClass calls is significant - // as it takes into account database FKs. - addTearDownClass(PCPoint.class); - - // Initialize test objects and expected values - pNotNull = new PCPoint(3, 5); - arrayNullElem[1] = pNotNull; - expectedArray[1] = pNotNull; - collNullElem = Arrays.asList(arrayNullElem); - - pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx = pm.currentTransaction(); - - tx.begin(); - try { - pm.makePersistent(pNotNull); - } catch (Exception e) { - e.printStackTrace(); - } - tx.commit(); - - logger.debug(" \nSetup committed in DeletePersistentNullArgs()"); - } finally { - if (tx.isActive()) { - tx.rollback(); - } + /** + * Checks if expected and actual arguments match for null/non-null value + * @return true if arguments match + * @param expected Object[] + * @param actual Object[] + */ + protected boolean checkReturn(Object[] expected, Object[] actual) { + Object eElem = null; + Object aElem = null; + if (expected.length != actual.length) + return false; + for (int i=0; i < expected.length; i++) { + eElem = expected[i]; + aElem = actual[i]; + if ( (eElem == null && aElem != null) + || (aElem == null && eElem != null) ) + return false; + } + return true; } - expectedCollection = Arrays.asList(arrayNullElem); - } - - protected static String toString(Object[] objs) { - StringBuffer out = new StringBuffer(); - for (int i = 0; i < objs.length; i++) { - out.append("[" + i + "]: "); - if (objs[i] == null) out.append("null"); - else out.append(objs[i].toString()); - out.append(", "); - } - return out.toString(); - } - - protected static String toString(Collection objs) { - return toString(objs.toArray()); - } - - /** - * Checks if expected and actual arguments match for null/non-null value - * - * @return true if arguments match - * @param expected Collection - * @param actual Collection - */ - protected boolean checkReturn(Collection expected, Collection actual) { - Object eElem = null; - Object aElem = null; - if (expected.size() != actual.size()) return false; - Iterator eIt = expected.iterator(); - Iterator aIt = actual.iterator(); - while (eIt.hasNext()) { - eElem = eIt.next(); - aElem = aIt.next(); - if ((eElem == null && aElem != null) || (aElem == null && eElem != null)) return false; - } - return true; - } - - /** - * Checks if expected and actual arguments match for null/non-null value - * - * @return true if arguments match - * @param expected Object[] - * @param actual Object[] - */ - protected boolean checkReturn(Object[] expected, Object[] actual) { - Object eElem = null; - Object aElem = null; - if (expected.length != actual.length) return false; - for (int i = 0; i < expected.length; i++) { - eElem = expected[i]; - aElem = actual[i]; - if ((eElem == null && aElem != null) || (aElem == null && eElem != null)) return false; - } - return true; - } - - /** - * Test that method under test with null valued argument does nothing. - * - * @param mut method under test - * @param method method name - */ - public void executeNullObjectParameter(MethodUnderTest mut, String method) { - - Transaction tx = pm.currentTransaction(); - Object obj = null; - try { - tx = pm.currentTransaction(); - - tx.begin(); - try { - mut.pmApi(pm, obj); - } catch (Exception e) { - fail( - ASSERTION3_FAILED, - method + " on a null object should do nothing." + " Instead we get: " + e.toString()); - } - tx.commit(); - - logger.debug(" \nPASSED in executeNullObjectParameter() on " + method); - } finally { - if (tx.isActive()) tx.rollback(); + + /** + * Test that method under test with null valued argument does nothing. + * @param mut method under test + * @param method method name + */ + public void executeNullObjectParameter(MethodUnderTest mut, String method) { + + Transaction tx = pm.currentTransaction(); + Object obj = null; + try { + tx = pm.currentTransaction(); + + tx.begin(); + try { + mut.pmApi(pm, obj); + } catch (Exception e) { + fail(ASSERTION3_FAILED, + method + " on a null object should do nothing." + + " Instead we get: " + e.toString()); + } + tx.commit(); + + logger.debug(" \nPASSED in executeNullObjectParameter() on " + + method); + } finally { + if (tx.isActive()) + tx.rollback(); + } + } - } - - /** - * Test that the method under test with null valued Collection argument throws - * NullPointerException. - * - * @param mut method under test - * @param method method name - */ - public void executeNullCollectionParameter(MethodUnderTest mut, String method) { - - Collection coll = null; - Transaction tx = pm.currentTransaction(); - - try { - tx.begin(); - try { - mut.pmApi(pm, coll); - fail(ASSERTION4_FAILED, method + " with null Collection argument should throw NPE."); - } catch (NullPointerException npe) { - // this is what we want - } catch (Exception e) { - fail( - ASSERTION4_FAILED, - method - + " with null Collection argument should throw NPE." - + " Instead we get: " - + e.toString()); - e.printStackTrace(); - } - tx.commit(); - - logger.debug(" \nPASSED in executeNullCollectionParameter()"); - } finally { - if (tx.isActive()) tx.rollback(); + + /** + * Test that the method under test with null valued Collection argument + * throws NullPointerException. + * @param mut method under test + * @param method method name + */ + public void executeNullCollectionParameter(MethodUnderTest mut, + String method) { + + Collection coll = null; + Transaction tx = pm.currentTransaction(); + + try { + tx.begin(); + try { + mut.pmApi(pm, coll); + fail(ASSERTION4_FAILED, + method + + " with null Collection argument should throw NPE."); + } catch (NullPointerException npe) { + // this is what we want + } catch (Exception e) { + fail(ASSERTION4_FAILED, + method + + " with null Collection argument should throw NPE." + + " Instead we get: " + e.toString()); + e.printStackTrace(); + } + tx.commit(); + + logger.debug(" \nPASSED in executeNullCollectionParameter()"); + } finally { + if (tx.isActive()) + tx.rollback(); + } + } - } - - /** - * Test that the method under test with null valued array argument throws NullPointerException. - * - * @param mut method under test - * @param method method name - */ - public void executeNullArrayParameter(MethodUnderTest mut, String method) { - - Object[] array = null; - Transaction tx = pm.currentTransaction(); - - try { - tx.begin(); - try { - mut.pmApi(pm, array); - fail(ASSERTION4_FAILED, method + " with null array argument should throw NPE."); - } catch (NullPointerException npe) { - // this is what we want - } catch (Exception e) { - fail( - ASSERTION4_FAILED, - method - + " with null array argument should throw NPE." - + " Instead we get: " - + e.toString()); - e.printStackTrace(); - } - tx.commit(); - - logger.debug(" \nPASSED in executeNullArrayParameter()"); - } finally { - if (tx.isActive()) tx.rollback(); + + /** + * Test that the method under test with null valued array argument + * throws NullPointerException. + * @param mut method under test + * @param method method name + */ + public void executeNullArrayParameter(MethodUnderTest mut, + String method) { + + Object[] array = null; + Transaction tx = pm.currentTransaction(); + + try { + tx.begin(); + try { + mut.pmApi(pm, array); + fail(ASSERTION4_FAILED, method + + " with null array argument should throw NPE."); + } catch (NullPointerException npe) { + // this is what we want + } catch (Exception e) { + fail(ASSERTION4_FAILED, + method + " with null array argument should throw NPE." + + " Instead we get: " + e.toString()); + e.printStackTrace(); + } + tx.commit(); + + logger.debug(" \nPASSED in executeNullArrayParameter()"); + } finally { + if (tx.isActive()) + tx.rollback(); + } + } - } - - /** - * Test that the method under test with a null element of a Collection argument ignores the null - * element. - * - * @param coll collection argument - * @param mut method under test - * @param method method name - */ - public void executeCollectionNullElement(Collection coll, MethodUnderTest mut, String method) { - - Transaction tx = pm.currentTransaction(); - try { - tx = pm.currentTransaction(); - - tx.begin(); - try { - mut.pmApi(pm, coll); - } catch (Exception e) { - fail( - ASSERTION5_FAILED, - method - + " on a null Collection element should" - + " do nothing. Instead we get: " - + e.toString()); - e.printStackTrace(); - } - - tx.commit(); - } finally { - if (tx.isActive()) tx.rollback(); + + /** + * Test that the method under test with a null element of a + * Collection argument ignores the null element. + * @param coll collection argument + * @param mut method under test + * @param method method name + */ + public void executeCollectionNullElement(Collection coll, + MethodUnderTest mut, String method) { + + Transaction tx = pm.currentTransaction(); + try { + tx = pm.currentTransaction(); + + tx.begin(); + try { + mut.pmApi(pm, coll); + } catch (Exception e) { + fail(ASSERTION5_FAILED, + method + " on a null Collection element should" + + " do nothing. Instead we get: " + e.toString()); + e.printStackTrace(); + } + + tx.commit(); + } finally { + if (tx.isActive()) + tx.rollback(); + } + } - } - - /** - * Test that the method under test with a null element of a array argument ignores the null - * element. - * - * @param array argument - * @param mut method under test - * @param method method name - */ - public void executeArrayNullElement(Object[] array, MethodUnderTest mut, String method) { - - Transaction tx = pm.currentTransaction(); - try { - tx = pm.currentTransaction(); - - tx.begin(); - try { - mut.pmApi(pm, array); - } catch (Exception e) { - fail( - ASSERTION5_FAILED, - method - + " on a null array element should " - + "do nothing. Instead we get: " - + e.toString()); - e.printStackTrace(); - } - - tx.commit(); - - } finally { - if (tx.isActive()) tx.rollback(); + + /** + * Test that the method under test with a null element of a + * array argument ignores the null element. + * @param array argument + * @param mut method under test + * @param method method name + */ + public void executeArrayNullElement(Object[] array, MethodUnderTest mut, + String method) { + + Transaction tx = pm.currentTransaction(); + try { + tx = pm.currentTransaction(); + + tx.begin(); + try { + mut.pmApi(pm, array); + } catch (Exception e) { + fail(ASSERTION5_FAILED, + method + " on a null array element should " + + "do nothing. Instead we get: " + e.toString()); + e.printStackTrace(); + } + + tx.commit(); + + } finally { + if (tx.isActive()) + tx.rollback(); + } + } - } - - /** - * Test that method under test with null valued argument does nothing. - * - * @param mut method under test - * @param method method name - */ - public void executeNullObjectParameterReturn(MethodUnderTest mut, String method) { - - Object returnVal = null; - Object obj = null; - Transaction tx = pm.currentTransaction(); - try { - tx = pm.currentTransaction(); - - tx.begin(); - try { - returnVal = mut.pmApiReturn(pm, obj); - } catch (Exception e) { - fail( - ASSERTION3_FAILED, - method + " on a null object should do nothing." + " Instead we get: " + e.toString()); - e.printStackTrace(); - } - if (returnVal != null) - fail(ASSERTION3_FAILED, method + " returns non-null Object; expected null."); - - tx.commit(); - - logger.debug(" \nPASSED in executeNullObjectParameter() on " + method); - } finally { - if (tx.isActive()) tx.rollback(); + + /** + * Test that method under test with null valued argument does nothing. + * @param mut method under test + * @param method method name + */ + public void executeNullObjectParameterReturn(MethodUnderTest mut, + String method) { + + Object returnVal = null; + Object obj = null; + Transaction tx = pm.currentTransaction(); + try { + tx = pm.currentTransaction(); + + tx.begin(); + try { + returnVal = mut.pmApiReturn(pm, obj); + } catch (Exception e) { + fail(ASSERTION3_FAILED, + method + " on a null object should do nothing." + + " Instead we get: " + e.toString()); + e.printStackTrace(); + } + if (returnVal != null) + fail(ASSERTION3_FAILED, + method + " returns non-null Object; expected null."); + + tx.commit(); + + logger.debug(" \nPASSED in executeNullObjectParameter() on " + + method); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } - } - - /** - * Test that the method under test with null valued Collection argument throws - * NullPointerException. - * - * @param mut method under test - * @param method method name - */ - public void executeNullCollectionParameterReturn(MethodUnderTest mut, String method) { - - Collection returnVal = null; - Collection coll = null; - Transaction tx = pm.currentTransaction(); - - try { - tx.begin(); - try { - returnVal = mut.pmApiReturn(pm, coll); - fail(ASSERTION4_FAILED, method + " with null Collection argument should throw NPE."); - } catch (NullPointerException npe) { - // this is what we want - } catch (Exception e) { - fail( - ASSERTION4_FAILED, - method - + " with null Collection argument should throw NPE." - + " Instead we get: " - + e.toString()); - e.printStackTrace(); - } - if (returnVal != null) fail(ASSERTION4_FAILED, method + " returns non-null Object. "); - tx.commit(); - - logger.debug(" \nPASSED in executeNullCollectionParameter()"); - } finally { - if (tx.isActive()) tx.rollback(); + + /** + * Test that the method under test with null valued Collection argument + * throws NullPointerException. + * @param mut method under test + * @param method method name + */ + public void executeNullCollectionParameterReturn( MethodUnderTest mut, + String method) { + + Collection returnVal = null; + Collection coll = null; + Transaction tx = pm.currentTransaction(); + + try { + tx.begin(); + try { + returnVal = mut.pmApiReturn(pm, coll); + fail(ASSERTION4_FAILED, + method + + " with null Collection argument should throw NPE."); + } catch (NullPointerException npe) { + // this is what we want + } catch (Exception e) { + fail(ASSERTION4_FAILED, + method + + " with null Collection argument should throw NPE." + + " Instead we get: " + e.toString()); + e.printStackTrace(); + } + if (returnVal != null) + fail(ASSERTION4_FAILED, + method + " returns non-null Object. "); + tx.commit(); + + logger.debug(" \nPASSED in executeNullCollectionParameter()"); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } - } - - /** - * Test that the method under test with null valued array argument throws NullPointerException. - * - * @param mut method under test - * @param method method name - */ - public void executeNullArrayParameterReturn(MethodUnderTest mut, String method) { - - Object[] returnVal = null; - Object[] array = null; - Transaction tx = pm.currentTransaction(); - - try { - tx.begin(); - try { - returnVal = mut.pmApiReturn(pm, array); - fail(ASSERTION4_FAILED, method + " with null array argument should throw NPE."); - } catch (NullPointerException npe) { - // this is what we want - } catch (Exception e) { - fail( - ASSERTION4_FAILED, - method - + " with null array argument should throw NPE." - + " Instead we get: " - + e.toString()); - e.printStackTrace(); - } - if (returnVal != null) fail(ASSERTION4_FAILED, method + " returns non-null Object."); - tx.commit(); - - logger.debug(" \nPASSED in executeNullArrayParameter()"); - } finally { - if (tx.isActive()) tx.rollback(); + + /** + * Test that the method under test with null valued array argument + * throws NullPointerException. + * @param mut method under test + * @param method method name + */ + public void executeNullArrayParameterReturn(MethodUnderTest mut, + String method) { + + Object[] returnVal = null; + Object[] array = null; + Transaction tx = pm.currentTransaction(); + + try { + tx.begin(); + try { + returnVal = mut.pmApiReturn(pm, array); + fail(ASSERTION4_FAILED, method + + " with null array argument should throw NPE."); + } catch (NullPointerException npe) { + // this is what we want + } catch (Exception e) { + fail(ASSERTION4_FAILED, + method + " with null array argument should throw NPE." + + " Instead we get: " + e.toString()); + e.printStackTrace(); + } + if (returnVal != null) + fail(ASSERTION4_FAILED, + method + " returns non-null Object."); + tx.commit(); + + logger.debug(" \nPASSED in executeNullArrayParameter()"); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } - } - - /** - * Test that the method under test with a null element of a Collection argument ignores the null - * element. - * - * @param coll argument - * @param mut method under test - * @param method method name - */ - public void executeCollectionNullElementReturn( - Collection coll, MethodUnderTest mut, String method) { - - Collection returnVal = null; - Transaction tx = pm.currentTransaction(); - try { - tx = pm.currentTransaction(); - - tx.begin(); - try { - returnVal = mut.pmApiReturn(pm, coll); - } catch (Exception e) { - fail( - ASSERTION5_FAILED, - method - + " on a null Collection element should" - + " do nothing. Instead we get: " - + e.toString()); - e.printStackTrace(); - } - - if (!checkReturn(expectedCollection, returnVal)) - fail( - ASSERTION5_FAILED, - method - + " returns incorrect Object. Expected " - + expectedCollection.toString() - + " actual was " - + returnVal.toString()); - tx.commit(); - } finally { - if (tx.isActive()) tx.rollback(); + + /** + * Test that the method under test with a null element of a + * Collection argument ignores the null element. + * @param coll argument + * @param mut method under test + * @param method method name + */ + public void executeCollectionNullElementReturn(Collection coll, + MethodUnderTest mut, String method) { + + Collection returnVal = null; + Transaction tx = pm.currentTransaction(); + try { + tx = pm.currentTransaction(); + + tx.begin(); + try { + returnVal = mut.pmApiReturn(pm, coll); + } catch (Exception e) { + fail(ASSERTION5_FAILED, + method + " on a null Collection element should" + + " do nothing. Instead we get: " + e.toString()); + e.printStackTrace(); + } + + if (!checkReturn(expectedCollection, returnVal)) + fail(ASSERTION5_FAILED, + method + " returns incorrect Object. Expected " + + expectedCollection.toString() + " actual was " + + returnVal.toString()); + tx.commit(); + } finally { + if (tx.isActive()) + tx.rollback(); + } + } - } - - /** - * Test that the method under test with a null element of a array argument ignores the null - * element. - * - * @param obj argument - * @param mut method under test - * @param method method name - */ - public void executeArrayNullElementReturn(Object[] obj, MethodUnderTest mut, String method) { - - Object[] returnVal = null; - Transaction tx = pm.currentTransaction(); - try { - tx = pm.currentTransaction(); - - tx.begin(); - try { - returnVal = mut.pmApiReturn(pm, obj); - } catch (Exception e) { - fail( - ASSERTION5_FAILED, - method - + " on a null array element should " - + "do nothing. Instead we get: " - + e.toString()); - e.printStackTrace(); - } - - if (!checkReturn(expectedArray, returnVal)) - fail( - ASSERTION5_FAILED, - method - + " returns incorrect Object. Expected " - + Arrays.asList(expectedArray).toString() - + " actual was " - + Arrays.asList(returnVal).toString()); - tx.commit(); - - } finally { - if (tx.isActive()) tx.rollback(); + + /** + * Test that the method under test with a null element of a + * array argument ignores the null element. + * @param obj argument + * @param mut method under test + * @param method method name + */ + public void executeArrayNullElementReturn(Object[] obj, + MethodUnderTest mut, String method) { + + Object[] returnVal = null; + Transaction tx = pm.currentTransaction(); + try { + tx = pm.currentTransaction(); + + tx.begin(); + try { + returnVal = mut.pmApiReturn(pm, obj); + } catch (Exception e) { + fail(ASSERTION5_FAILED, + method + " on a null array element should " + + "do nothing. Instead we get: " + e.toString()); + e.printStackTrace(); + } + + if (!checkReturn(expectedArray, returnVal)) + fail(ASSERTION5_FAILED, + method + " returns incorrect Object. Expected " + + Arrays.asList(expectedArray).toString() + + " actual was " + + Arrays.asList(returnVal).toString()); + tx.commit(); + + } finally { + if (tx.isActive()) + tx.rollback(); + } + } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RefreshNullArgs.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RefreshNullArgs.java index 6b26fbb08..a64420189 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RefreshNullArgs.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RefreshNullArgs.java @@ -5,85 +5,105 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.nullargs; import java.util.Collection; + +import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: refresh with Null Arguments
    - * Keywords:
    - * Assertion IDs: A12.6-3, A12.6-4, A12.6-5
    - * Assertion Description: A12.6-3 [Null arguments to APIs that take an Object parameter - * cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or - * Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or - * Collection arguments that contain null elements will have the documented behavior for non-null - * elements, and the null elements will be ignored.] + *Title: refresh with Null Arguments + *
    + *Keywords: + *
    + *Assertion IDs: A12.6-3, A12.6-4, A12.6-5 + *
    + *Assertion Description: +A12.6-3 [Null arguments to APIs that take an Object parameter cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or Collection arguments that contain null elements will have the documented behavior for non-null elements, and the null elements will be ignored.] */ -public class RefreshNullArgs extends PersistenceManagerNullsTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(RefreshNullArgs.class); - } +public class RefreshNullArgs extends PersistenceManagerNullsTest { + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(RefreshNullArgs.class); + } - static MethodUnderTest refresh = new MethodUnderTestRefresh(); + static MethodUnderTest refresh = + new MethodUnderTestRefresh(); + static class MethodUnderTestRefresh extends MethodUnderTest { + public void pmApi(PersistenceManager pm, Object pc) { + pm.refresh(pc); + } + public void pmApi(PersistenceManager pm, Collection pcs) { + pm.refreshAll(pcs); + } + public void pmApi(PersistenceManager pm, Object[] pcs) { + pm.refreshAll(pcs); + } + }; - static class MethodUnderTestRefresh extends MethodUnderTest { - public void pmApi(PersistenceManager pm, Object pc) { - pm.refresh(pc); + /** + * Test that refresh() with null valued argument does nothing. + */ + public void testRefreshNullObject() { + executeNullObjectParameter(refresh, "refresh(null)"); } - public void pmApi(PersistenceManager pm, Collection pcs) { - pm.refreshAll(pcs); + /** + * Test that refreshAll() with null valued Collection argument + * throws NullPointerException. + */ + public void testRefreshNullCollection() { + executeNullCollectionParameter(refresh, + "refreshAll((Collection)null)"); } - public void pmApi(PersistenceManager pm, Object[] pcs) { - pm.refreshAll(pcs); + /** + * Test that refreshAll() with null valued array argument + * throws NullPointerException. + */ + public void testRefreshNullArray() { + executeNullArrayParameter(refresh, + "refreshAll((Object[])null)"); } - } - ; - - /** Test that refresh() with null valued argument does nothing. */ - public void testRefreshNullObject() { - executeNullObjectParameter(refresh, "refresh(null)"); - } - - /** Test that refreshAll() with null valued Collection argument throws NullPointerException. */ - public void testRefreshNullCollection() { - executeNullCollectionParameter(refresh, "refreshAll((Collection)null)"); - } - /** Test that refreshAll() with null valued array argument throws NullPointerException. */ - public void testRefreshNullArray() { - executeNullArrayParameter(refresh, "refreshAll((Object[])null)"); - } + /** + * Test that refreshAll() with a null element of a + * Collection argument throws NullPointerException. + */ + public void testRefreshCollectionNullElement() { + executeCollectionNullElement(collNullElem, refresh, + "refreshAll(Collection)"); + } - /** - * Test that refreshAll() with a null element of a Collection argument throws - * NullPointerException. - */ - public void testRefreshCollectionNullElement() { - executeCollectionNullElement(collNullElem, refresh, "refreshAll(Collection)"); - } + /** + * Test that refreshAll() with a null element of a + * array argument throws NullPointerException. + */ + public void testRefreshArrayNullElement() { + executeArrayNullElement(arrayNullElem, refresh, + "refreshAll(Object[])"); + } - /** Test that refreshAll() with a null element of a array argument throws NullPointerException. */ - public void testRefreshArrayNullElement() { - executeArrayNullElement(arrayNullElem, refresh, "refreshAll(Object[])"); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RetrieveNullArgs.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RetrieveNullArgs.java index b6e248b31..3e78b2ae9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RetrieveNullArgs.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RetrieveNullArgs.java @@ -5,87 +5,105 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.nullargs; import java.util.Collection; + +import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: retrieve with Null Arguments
    - * Keywords:
    - * Assertion IDs: A12.6-3, A12.6-4, A12.6-5
    - * Assertion Description: A12.6-3 [Null arguments to APIs that take an Object parameter - * cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or - * Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or - * Collection arguments that contain null elements will have the documented behavior for non-null - * elements, and the null elements will be ignored.] + *Title: retrieve with Null Arguments + *
    + *Keywords: + *
    + *Assertion IDs: A12.6-3, A12.6-4, A12.6-5 + *
    + *Assertion Description: +A12.6-3 [Null arguments to APIs that take an Object parameter cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or Collection arguments that contain null elements will have the documented behavior for non-null elements, and the null elements will be ignored.] */ -public class RetrieveNullArgs extends PersistenceManagerNullsTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(RetrieveNullArgs.class); - } +public class RetrieveNullArgs extends PersistenceManagerNullsTest { + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(RetrieveNullArgs.class); + } - static MethodUnderTest retrieve = new MethodUnderTestRetrieve(); + static MethodUnderTest retrieve = + new MethodUnderTestRetrieve(); + static class MethodUnderTestRetrieve extends MethodUnderTest { + public void pmApi(PersistenceManager pm, Object pc) { + pm.retrieve(pc); + } + public void pmApi(PersistenceManager pm, Collection pcs) { + pm.retrieveAll(pcs); + } + public void pmApi(PersistenceManager pm, Object[] pcs) { + pm.retrieveAll(pcs); + } + }; - static class MethodUnderTestRetrieve extends MethodUnderTest { - public void pmApi(PersistenceManager pm, Object pc) { - pm.retrieve(pc); + /** + * Test that retrieve() with null valued argument does nothing. + */ + public void testRetrieveNullObject() { + executeNullObjectParameter(retrieve, "retrieve(null)"); } - public void pmApi(PersistenceManager pm, Collection pcs) { - pm.retrieveAll(pcs); + /** + * Test that retrieveAll() with null valued Collection argument + * throws NullPointerException. + */ + public void testRetrieveNullCollection() { + executeNullCollectionParameter(retrieve, + "retrieveAll((Collection)null)"); } - public void pmApi(PersistenceManager pm, Object[] pcs) { - pm.retrieveAll(pcs); + /** + * Test that retrieveAll() with null valued array argument + * throws NullPointerException. + */ + public void testRetrieveNullArray() { + executeNullArrayParameter(retrieve, + "retrieveAll((Object[])null)"); } - } - ; - - /** Test that retrieve() with null valued argument does nothing. */ - public void testRetrieveNullObject() { - executeNullObjectParameter(retrieve, "retrieve(null)"); - } - - /** Test that retrieveAll() with null valued Collection argument throws NullPointerException. */ - public void testRetrieveNullCollection() { - executeNullCollectionParameter(retrieve, "retrieveAll((Collection)null)"); - } - /** Test that retrieveAll() with null valued array argument throws NullPointerException. */ - public void testRetrieveNullArray() { - executeNullArrayParameter(retrieve, "retrieveAll((Object[])null)"); - } + /** + * Test that retrieveAll() with a null element of a + * Collection argument throws NullPointerException. + */ + public void testRetrieveCollectionNullElement() { + executeCollectionNullElement(collNullElem, retrieve, + "retrieveAll(Collection)"); + } - /** - * Test that retrieveAll() with a null element of a Collection argument throws - * NullPointerException. - */ - public void testRetrieveCollectionNullElement() { - executeCollectionNullElement(collNullElem, retrieve, "retrieveAll(Collection)"); - } + /** + * Test that retrieveAll() with a null element of a + * array argument throws NullPointerException. + */ + public void testRetrieveArrayNullElement() { + executeArrayNullElement(arrayNullElem, retrieve, + "retrieveAll(Object[])"); + } - /** - * Test that retrieveAll() with a null element of a array argument throws NullPointerException. - */ - public void testRetrieveArrayNullElement() { - executeArrayNullElement(arrayNullElem, retrieve, "retrieveAll(Object[])"); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RetrieveWithFetchPlanNullArgs.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RetrieveWithFetchPlanNullArgs.java index b53228469..adc7c4233 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RetrieveWithFetchPlanNullArgs.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanager/nullargs/RetrieveWithFetchPlanNullArgs.java @@ -5,97 +5,105 @@ * 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 + * + * 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.jdo.tck.api.persistencemanager.nullargs; import java.util.Collection; + +import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: retrieveWithFetchPlan with Null Arguments
    - * Keywords:
    - * Assertion IDs: A12.6-3, A12.6-4, A12.6-5
    - * Assertion Description: A12.6-3 [Null arguments to APIs that take an Object parameter - * cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or - * Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or - * Collection arguments that contain null elements will have the documented behavior for non-null - * elements, and the null elements will be ignored.] + *Title: retrieveWithFetchPlan with Null Arguments + *
    + *Keywords: + *
    + *Assertion IDs: A12.6-3, A12.6-4, A12.6-5 + *
    + *Assertion Description: +A12.6-3 [Null arguments to APIs that take an Object parameter cause the API to have no effect.] A12.6-4 [Null arguments to APIs that take Object[] or Collection will cause the API to throw NullPointerException.] A12.6-5 [Non-null Object[] or Collection arguments that contain null elements will have the documented behavior for non-null elements, and the null elements will be ignored.] */ -public class RetrieveWithFetchPlanNullArgs extends PersistenceManagerNullsTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(RetrieveWithFetchPlanNullArgs.class); - } +public class RetrieveWithFetchPlanNullArgs extends PersistenceManagerNullsTest { + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(RetrieveWithFetchPlanNullArgs.class); + } - static MethodUnderTest retrieveWithFetchPlan = new MethodUnderTestRetrieveWithFetchPlan(); + static MethodUnderTest retrieveWithFetchPlan = + new MethodUnderTestRetrieveWithFetchPlan(); + static class MethodUnderTestRetrieveWithFetchPlan extends MethodUnderTest { + public void pmApi(PersistenceManager pm, Object pc) { + pm.retrieve(pc, false); + } + public void pmApi(PersistenceManager pm, Collection pcs) { + pm.retrieveAll(pcs, false); + } + public void pmApi(PersistenceManager pm, Object[] pcs) { + pm.retrieveAll(false, pcs); + } + }; - static class MethodUnderTestRetrieveWithFetchPlan extends MethodUnderTest { - public void pmApi(PersistenceManager pm, Object pc) { - pm.retrieve(pc, false); + /** + * Test that retrieveWithFetchPlan() with null valued argument does nothing. + */ + public void testRetrieveWithFetchPlanNullObject() { + executeNullObjectParameter(retrieveWithFetchPlan, "retrieveWithFetchPlan(null)"); } - public void pmApi(PersistenceManager pm, Collection pcs) { - pm.retrieveAll(pcs, false); + /** + * Test that retrieveWithFetchPlanAll() with null valued Collection argument + * throws NullPointerException. + */ + public void testRetrieveWithFetchPlanNullCollection() { + executeNullCollectionParameter(retrieveWithFetchPlan, + "retrieveWithFetchPlanAll((Collection)null)"); } - public void pmApi(PersistenceManager pm, Object[] pcs) { - pm.retrieveAll(false, pcs); + /** + * Test that retrieveWithFetchPlanAll() with null valued array argument + * throws NullPointerException. + */ + public void testRetrieveWithFetchPlanNullArray() { + executeNullArrayParameter(retrieveWithFetchPlan, + "retrieveWithFetchPlanAll((Object[])null)"); } - } - ; - - /** Test that retrieveWithFetchPlan() with null valued argument does nothing. */ - public void testRetrieveWithFetchPlanNullObject() { - executeNullObjectParameter(retrieveWithFetchPlan, "retrieveWithFetchPlan(null)"); - } - - /** - * Test that retrieveWithFetchPlanAll() with null valued Collection argument throws - * NullPointerException. - */ - public void testRetrieveWithFetchPlanNullCollection() { - executeNullCollectionParameter( - retrieveWithFetchPlan, "retrieveWithFetchPlanAll((Collection)null)"); - } - /** - * Test that retrieveWithFetchPlanAll() with null valued array argument throws - * NullPointerException. - */ - public void testRetrieveWithFetchPlanNullArray() { - executeNullArrayParameter(retrieveWithFetchPlan, "retrieveWithFetchPlanAll((Object[])null)"); - } + /** + * Test that retrieveWithFetchPlanAll() with a null element of a + * Collection argument throws NullPointerException. + */ + public void testRetrieveWithFetchPlanCollectionNullElement() { + executeCollectionNullElement(collNullElem, retrieveWithFetchPlan, + "retrieveWithFetchPlanAll(Collection)"); + } - /** - * Test that retrieveWithFetchPlanAll() with a null element of a Collection argument throws - * NullPointerException. - */ - public void testRetrieveWithFetchPlanCollectionNullElement() { - executeCollectionNullElement( - collNullElem, retrieveWithFetchPlan, "retrieveWithFetchPlanAll(Collection)"); - } + /** + * Test that retrieveWithFetchPlanAll() with a null element of a + * array argument throws NullPointerException. + */ + public void testRetrieveWithFetchPlanArrayNullElement() { + executeArrayNullElement(arrayNullElem, retrieveWithFetchPlan, + "retrieveWithFetchPlanAll(Object[])"); + } - /** - * Test that retrieveWithFetchPlanAll() with a null element of a array argument throws - * NullPointerException. - */ - public void testRetrieveWithFetchPlanArrayNullElement() { - executeArrayNullElement( - arrayNullElem, retrieveWithFetchPlan, "retrieveWithFetchPlanAll(Object[])"); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/AbstractGetPMF.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/AbstractGetPMF.java index 83528e416..8d47d4350 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/AbstractGetPMF.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/AbstractGetPMF.java @@ -5,195 +5,209 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; -import java.io.File; import java.lang.reflect.Method; + +import java.io.File; import java.util.Iterator; import java.util.Map.Entry; import java.util.Properties; import java.util.Set; + import javax.jdo.JDOFatalUserException; import javax.jdo.PersistenceManagerFactory; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; /** - * The abstract super class for all GetPMF test cases. - * + * The abstract super class for all GetPMF test cases. * @author Michael Watzek */ -abstract class AbstractGetPMF extends JDO_Test { - - /** - * Used as the PMF name in positive tests. The variable is set to test/conf/jdori.properties. This - * file contains valid JDO properties. - */ - protected static final String validPropertiesFile = PMFProperties; - - /** - * Used as the PMF name in negative tests. The variable is set to test/conf/logging.properties. - * This file does not contain valid JDO properties. - */ - /* protected static final String invalidPropertiesFile = - validPropertiesFile.substring(0, validPropertiesFile.lastIndexOf(File.separatorChar)+1) + - "logging.properties"; - */ - protected static String invalidPropertiesFile; - - static { - if (validPropertiesFile == null) System.out.println("******************************"); - invalidPropertiesFile = - validPropertiesFile.substring(0, validPropertiesFile.lastIndexOf(File.separatorChar) + 1) - + "logging.properties"; - } - - /** - * Used as the PMF name in positive JNDI tests. The variable is set to jdori.properties. This - * resource contains valid JDO properties. - */ - protected static final String jndiName = - validPropertiesFile.substring(0, validPropertiesFile.lastIndexOf(File.separatorChar) + 1) - + "pmf.ser"; - /** - * Removing the path prefix from argument name. - * - * @param name the name - * @return argument name removed by the path prefix. - */ - protected String removePathPrefix(String name) { - int index = name.lastIndexOf(File.separatorChar); - if (index != -1) { - name = name.substring(index + 1); +abstract class AbstractGetPMF extends JDO_Test { + + /** + * Used as the PMF name in positive tests. + * The variable is set to test/conf/jdori.properties. + * This file contains valid JDO properties. + */ + protected static final String validPropertiesFile = PMFProperties; + + /** + * Used as the PMF name in negative tests. + * The variable is set to test/conf/logging.properties. + * This file does not contain valid JDO properties. + */ +/* protected static final String invalidPropertiesFile = + validPropertiesFile.substring(0, validPropertiesFile.lastIndexOf(File.separatorChar)+1) + + "logging.properties"; +*/ + protected static String invalidPropertiesFile; + static + { + if (validPropertiesFile==null) + System.out.println ("******************************"); + invalidPropertiesFile = validPropertiesFile.substring(0, validPropertiesFile.lastIndexOf(File.separatorChar)+1) + + "logging.properties"; } - return name; - } - - protected void makePersistent() { - addTearDownClass(PCPoint.class); - pm = pmf.getPersistenceManager(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint comp = new PCPoint(1, 2); - pm.makePersistent(comp); - tx.commit(); - } - /** - * Returns pmf instance for the given name. Subclasses may use argument name as file - * name, resource name etc. - * - * @param name the name - * @return the pmf instance - */ - protected abstract PersistenceManagerFactory getPMF(String name); + /** + * Used as the PMF name in positive JNDI tests. + * The variable is set to jdori.properties. + * This resource contains valid JDO properties. + */ + protected static final String jndiName = + validPropertiesFile.substring(0, validPropertiesFile.lastIndexOf(File.separatorChar)+1) + + "pmf.ser"; + + /** + * Removing the path prefix from argument name. + * @param name the name + * @return argument name removed by the path prefix. + */ + protected String removePathPrefix(String name) { + int index = name.lastIndexOf(File.separatorChar); + if (index!=-1) { + name = name.substring(index+1); + } + return name; + } - /** - * This method creates a PMF calling method AbstractGetPMF#getPMF(name). It passes an name of an - * invalid properties file as parameter. The method expects the PMF creation to fail. - * - * @param assertionMessage the assertion message if the test fails. - */ - protected void checkGetPMFWithInvalidProperties(String assertionMessage) { - try { - pmf = getPMF(invalidPropertiesFile); - fail(assertionMessage); - } catch (JDOFatalUserException e) { - // expected exception - if (debug) logger.debug("caught expected exception " + e.toString()); + protected void makePersistent() { + addTearDownClass(PCPoint.class); + pm = pmf.getPersistenceManager(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint comp = new PCPoint(1, 2); + pm.makePersistent(comp); + tx.commit(); } - } - /** - * This method creates a PMF calling method AbstractGetPMF#getPMF(name). It passes an name of a - * valid properties file as parameter. The method expects the PMF creation to succeed. - */ - protected void checkGetPMFWithValidProperties() { - pmf = getPMF(validPropertiesFile); - verifyProperties(pmf, loadProperties(validPropertiesFile)); - makePersistent(); - } + /** + * Returns pmf instance for the given name. + * Subclasses may use argument name as file name, + * resource name etc. + * @param name the name + * @return the pmf instance + */ + protected abstract PersistenceManagerFactory getPMF(String name); - /** - * Verify that the Properties are correctly set in the PMF. - * - * @param pmf the PersistenceManagerFactory - * @param props the Properties - */ - protected void verifyProperties(PersistenceManagerFactory pmf, Properties props) { - Object[] noArgs = new Object[] {}; - String javaxjdooption = "javax.jdo.option."; - Class pmfclass = pmf.getClass(); - Set entries = props.entrySet(); - StringBuffer buffer = new StringBuffer(); - for (Iterator it = entries.iterator(); it.hasNext(); ) { - Entry entry = (Entry) it.next(); - String key = (String) entry.getKey(); - if (key.equals("javax.jdo.option.ConnectionPassword")) { - continue; - } - if (key.equals("javax.jdo.option.ConnectionUserName")) { - continue; - } - String expected = (String) entry.getValue(); - if (key.startsWith(javaxjdooption)) { - String optionName = key.substring(javaxjdooption.length()); - Method getMethod = getGetMethod(pmfclass, optionName); - Object actual = getValue(getMethod, pmf, noArgs); - if (actual == null) { - buffer.append("\n"); - buffer.append("Key "); - buffer.append(key); - buffer.append(" was null."); - continue; - } - String actualString = actual.toString(); - if (!expected.equals(actualString)) { - buffer.append("\n"); - buffer.append("Key "); - buffer.append(key); - buffer.append(" expected: \""); - buffer.append(expected); - buffer.append("\" actual: \""); - buffer.append(actual); - buffer.append("\"."); + /** + * This method creates a PMF calling + * method AbstractGetPMF#getPMF(name). + * It passes an name of an invalid properties file as parameter. + * The method expects the PMF creation to fail. + * @param assertionMessage the assertion message if the test fails. + */ + protected void checkGetPMFWithInvalidProperties(String assertionMessage) { + try { + pmf = getPMF(invalidPropertiesFile); + fail(assertionMessage); + } catch (JDOFatalUserException e) { + // expected exception + if (debug) + logger.debug("caught expected exception " + e.toString()); } - } } - if (buffer.length() != 0) { - fail(buffer.toString()); + + /** + * This method creates a PMF calling + * method AbstractGetPMF#getPMF(name). + * It passes an name of a valid properties file as parameter. + * The method expects the PMF creation to succeed. + */ + protected void checkGetPMFWithValidProperties() { + pmf = getPMF(validPropertiesFile); + verifyProperties(pmf, loadProperties(validPropertiesFile)); + makePersistent(); } - } - /** Get the "get" method corresponding to the option name. */ - Method getGetMethod(Class cls, String optionName) { - try { - return cls.getMethod("get" + optionName, new Class[] {}); - } catch (Exception ex) { - fail("Unexpected exception thrown from getMethod on PMF class with option name" + optionName); - return null; + /** + * Verify that the Properties are correctly set in the PMF. + * @param pmf the PersistenceManagerFactory + * @param props the Properties + */ + protected void verifyProperties(PersistenceManagerFactory pmf, + Properties props) { + Object[] noArgs = new Object[]{}; + String javaxjdooption = "javax.jdo.option."; + Class pmfclass = pmf.getClass(); + Set entries = props.entrySet(); + StringBuffer buffer = new StringBuffer(); + for (Iterator it = entries.iterator(); it.hasNext();) { + Entry entry = (Entry)it.next(); + String key = (String)entry.getKey(); + if (key.equals("javax.jdo.option.ConnectionPassword")) { + continue; + } + if (key.equals("javax.jdo.option.ConnectionUserName")) { + continue; + } + String expected = (String)entry.getValue(); + if (key.startsWith(javaxjdooption)) { + String optionName = key.substring(javaxjdooption.length()); + Method getMethod = getGetMethod(pmfclass, optionName); + Object actual = getValue(getMethod, pmf, noArgs); + if (actual == null) { + buffer.append("\n"); + buffer.append("Key "); + buffer.append(key); + buffer.append(" was null."); + continue; + } + String actualString = actual.toString(); + if (!expected.equals(actualString)) { + buffer.append("\n"); + buffer.append("Key "); + buffer.append(key); + buffer.append(" expected: \""); + buffer.append(expected); + buffer.append("\" actual: \""); + buffer.append(actual); + buffer.append("\"."); + } + } + } + if (buffer.length() != 0) { + fail(buffer.toString()); + } } - } - - /** Get the result of executing the Method. */ - Object getValue(Method method, Object obj, Object[] args) { - try { - return method.invoke(obj, args); - } catch (Exception ex) { - fail("Unexpected exception executing method " + method.getName() + "."); - return null; + + /** Get the "get" method corresponding to the option name. + */ + Method getGetMethod(Class cls, String optionName) { + try { + return cls.getMethod("get" + optionName, new Class[]{}); + } catch (Exception ex) { + fail("Unexpected exception thrown from getMethod on PMF class with option name" + + optionName); + return null; + } + } + + /** + * Get the result of executing the Method. + */ + Object getValue(Method method, Object obj, Object[] args) { + try { + return method.invoke(obj, args); + } catch (Exception ex) { + fail("Unexpected exception executing method " + + method.getName() + "."); + return null; + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseGetPMThrowsException.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseGetPMThrowsException.java index 106ad1d3c..8c2e9839e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseGetPMThrowsException.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseGetPMThrowsException.java @@ -5,32 +5,37 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import javax.jdo.JDOFatalUserException; import javax.jdo.JDOUserException; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:AfterCloseGetPMThrowsException of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.4-9B.
    - * Assertion Description: PersistenceManagerFactory.getPersistenceManager() throws + *Title:AfterCloseGetPMThrowsException of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.4-9B. + *
    + *Assertion Description: + * PersistenceManagerFactory.getPersistenceManager() throws * JDOUserException after the PersistenceManagerFactory is closed. */ -/* +/* * Revision History * ================ * Author : Craig Russell @@ -39,40 +44,40 @@ */ public class AfterCloseGetPMThrowsException extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.4-9B (AfterCloseGetPMThrowsException) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(AfterCloseGetPMThrowsException.class); + } - /** */ - private static final String ASSERTION_FAILED = - "Assertion A11.4-9B (AfterCloseGetPMThrowsException) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(AfterCloseGetPMThrowsException.class); - } - - /** */ - public void test() { - try { - pmf = getPMF(); - closePMF(pmf); // don't use closePMF() because that sets pmf to null - pm = pmf.getPersistenceManager(); - fail( - ASSERTION_FAILED, - "pmf.getPersistenceManager should throw JDOUserException if pmf is closed."); - } catch (JDOUserException ex) { - // expected exception - if (debug) logger.debug("caught expected exception " + ex.toString()); - } catch (JDOFatalUserException ex) { - // unexpected exception - fail( - ASSERTION_FAILED, - "Wrong exception thrown from getPersistenceManager after close.\n" - + "Expected JDOUserException, got JDOFatalUserException."); - } finally { - if (pm != null) pm.close(); + /** */ + public void test() { + try { + pmf = getPMF(); + closePMF(pmf); // don't use closePMF() because that sets pmf to null + pm = pmf.getPersistenceManager(); + fail(ASSERTION_FAILED, + "pmf.getPersistenceManager should throw JDOUserException if pmf is closed."); + } catch (JDOUserException ex) { + // expected exception + if (debug) + logger.debug("caught expected exception " + ex.toString()); + } catch (JDOFatalUserException ex) { + // unexpected exception + fail(ASSERTION_FAILED, + "Wrong exception thrown from getPersistenceManager after close.\n" + + "Expected JDOUserException, got JDOFatalUserException."); + } finally { + if (pm != null) + pm.close(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseSetMethodsThrowException.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseSetMethodsThrowException.java index ef966e4d6..96497f1f3 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseSetMethodsThrowException.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseSetMethodsThrowException.java @@ -5,36 +5,41 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import java.util.Arrays; import java.util.Collection; import java.util.Iterator; + import javax.jdo.JDOFatalInternalException; import javax.jdo.JDOUserException; import javax.jdo.PersistenceManagerFactory; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:AfterCloseSetMethodsThrowException
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.4-9A.
    - * Assertion Description: If a set method is called after close, then JDOUserException is - * thrown. + *Title:AfterCloseSetMethodsThrowException + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.4-9A. + *
    + *Assertion Description: + * If a set method is called after close, then JDOUserException is thrown. */ -/* +/* * Revision History * ================ * Author : Craig Russell @@ -43,181 +48,182 @@ */ public class AfterCloseSetMethodsThrowException extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.4-9A (AfterCloseSetMethodsThrowException) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(AfterCloseSetMethodsThrowException.class); + } - /** */ - private static final String ASSERTION_FAILED = - "Assertion A11.4-9A (AfterCloseSetMethodsThrowException) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(AfterCloseSetMethodsThrowException.class); - } - - /** */ - public void test() { - Class[] stringParameters = new Class[] {String.class}; - Class[] booleanParameters = new Class[] {boolean.class}; - Class[] objectParameters = new Class[] {Object.class}; - Class[] integerParameters = new Class[] {Integer.class}; - Object[] stringParameter = new Object[] {"Nobody knows the trouble"}; - Object[] booleanParameter = new Object[] {Boolean.FALSE}; - Object[] objectParameter = new Object[] {null}; - Object[] integerParameter = new Object[] {Integer.valueOf(0)}; - - SetProperty[] setMethods = - new SetProperty[] { - new SetProperty("setConnectionDriverName", stringParameters, stringParameter), - new SetProperty("setConnectionFactory", objectParameters, objectParameter), - new SetProperty("setConnectionFactory2", objectParameters, objectParameter), - new SetProperty("setConnectionFactoryName", stringParameters, stringParameter), - new SetProperty("setConnectionFactory2Name", stringParameters, stringParameter), - new SetProperty("setConnectionPassword", stringParameters, stringParameter), - new SetProperty("setConnectionURL", stringParameters, stringParameter), - new SetProperty("setConnectionUserName", stringParameters, stringParameter), - new SetProperty("setCopyOnAttach", booleanParameters, booleanParameter), - new SetProperty("setDetachAllOnCommit", booleanParameters, booleanParameter), - new SetProperty("setIgnoreCache", booleanParameters, booleanParameter), - new SetProperty("setMapping", stringParameters, stringParameter), - new SetProperty("setMultithreaded", booleanParameters, booleanParameter), - new SetProperty("setName", stringParameters, stringParameter), - new SetProperty("setNontransactionalRead", booleanParameters, booleanParameter), - new SetProperty("setNontransactionalWrite", booleanParameters, booleanParameter), - new SetProperty("setOptimistic", booleanParameters, booleanParameter), - new SetProperty("setPersistenceUnitName", stringParameters, stringParameter), - new SetProperty("setReadOnly", booleanParameters, booleanParameter), - new SetProperty("setRestoreValues", booleanParameters, booleanParameter), - new SetProperty("setRetainValues", booleanParameters, booleanParameter), - new SetProperty("setServerTimeZoneID", stringParameters, stringParameter), - new SetProperty("setTransactionIsolationLevel", stringParameters, stringParameter), - new SetProperty("setTransactionType", stringParameters, stringParameter) + /** */ + public void test() { + Class[] stringParameters = new Class[]{String.class}; + Class[] booleanParameters = new Class[]{boolean.class}; + Class[] objectParameters = new Class[]{Object.class}; + Class[] integerParameters = new Class[]{Integer.class}; + Object[] stringParameter = new Object[]{"Nobody knows the trouble"}; + Object[] booleanParameter = new Object[]{Boolean.FALSE}; + Object[] objectParameter = new Object[]{null}; + Object[] integerParameter = new Object[]{Integer.valueOf(0)}; + + SetProperty[] setMethods = new SetProperty[] { + new SetProperty("setConnectionDriverName", stringParameters, stringParameter), + new SetProperty("setConnectionFactory", objectParameters, objectParameter), + new SetProperty("setConnectionFactory2", objectParameters, objectParameter), + new SetProperty("setConnectionFactoryName", stringParameters, stringParameter), + new SetProperty("setConnectionFactory2Name", stringParameters, stringParameter), + new SetProperty("setConnectionPassword", stringParameters, stringParameter), + new SetProperty("setConnectionURL", stringParameters, stringParameter), + new SetProperty("setConnectionUserName", stringParameters, stringParameter), + new SetProperty("setCopyOnAttach", booleanParameters, booleanParameter), + new SetProperty("setDetachAllOnCommit", booleanParameters, booleanParameter), + new SetProperty("setIgnoreCache", booleanParameters, booleanParameter), + new SetProperty("setMapping", stringParameters, stringParameter), + new SetProperty("setMultithreaded", booleanParameters, booleanParameter), + new SetProperty("setName", stringParameters, stringParameter), + new SetProperty("setNontransactionalRead", booleanParameters, booleanParameter), + new SetProperty("setNontransactionalWrite", booleanParameters, booleanParameter), + new SetProperty("setOptimistic", booleanParameters, booleanParameter), + new SetProperty("setPersistenceUnitName", stringParameters, stringParameter), + new SetProperty("setReadOnly", booleanParameters, booleanParameter), + new SetProperty("setRestoreValues", booleanParameters, booleanParameter), + new SetProperty("setRetainValues", booleanParameters, booleanParameter), + new SetProperty("setServerTimeZoneID", stringParameters, stringParameter), + new SetProperty("setTransactionIsolationLevel", stringParameters, stringParameter), + new SetProperty("setTransactionType", stringParameters, stringParameter) }; - GetProperty[] getMethods = - new GetProperty[] { - new GetProperty("getConnectionDriverName"), - new GetProperty("getConnectionFactory"), - new GetProperty("getConnectionFactory2"), - new GetProperty("getConnectionFactoryName"), - new GetProperty("getConnectionFactory2Name"), - new GetProperty("getConnectionURL"), - new GetProperty("getConnectionUserName"), - new GetProperty("getCopyOnAttach"), - new GetProperty("getDataStoreCache"), - new GetProperty("getDetachAllOnCommit"), - new GetProperty("getFetchGroups"), - new GetProperty("getIgnoreCache"), - new GetProperty("getMapping"), - new GetProperty("getMultithreaded"), - new GetProperty("getName"), - new GetProperty("getNontransactionalRead"), - new GetProperty("getNontransactionalWrite"), - new GetProperty("getOptimistic"), - new GetProperty("getPersistenceUnitName"), - new GetProperty("getProperties"), - new GetProperty("getReadOnly"), - new GetProperty("getRestoreValues"), - new GetProperty("getRetainValues"), - new GetProperty("getServerTimeZoneID"), - new GetProperty("getTransactionIsolationLevel"), - new GetProperty("getTransactionType") + GetProperty[] getMethods = new GetProperty[] { + new GetProperty("getConnectionDriverName"), + new GetProperty("getConnectionFactory"), + new GetProperty("getConnectionFactory2"), + new GetProperty("getConnectionFactoryName"), + new GetProperty("getConnectionFactory2Name"), + new GetProperty("getConnectionURL"), + new GetProperty("getConnectionUserName"), + new GetProperty("getCopyOnAttach"), + new GetProperty("getDataStoreCache"), + new GetProperty("getDetachAllOnCommit"), + new GetProperty("getFetchGroups"), + new GetProperty("getIgnoreCache"), + new GetProperty("getMapping"), + new GetProperty("getMultithreaded"), + new GetProperty("getName"), + new GetProperty("getNontransactionalRead"), + new GetProperty("getNontransactionalWrite"), + new GetProperty("getOptimistic"), + new GetProperty("getPersistenceUnitName"), + new GetProperty("getProperties"), + new GetProperty("getReadOnly"), + new GetProperty("getRestoreValues"), + new GetProperty("getRetainValues"), + new GetProperty("getServerTimeZoneID"), + new GetProperty("getTransactionIsolationLevel"), + new GetProperty("getTransactionType") }; - pmf = getPMF(); - closePMF(pmf); // don't use closePMF() because that sets pmf to null - // each set method should throw an exception - Collection setCollection = Arrays.asList(setMethods); - for (Iterator it = setCollection.iterator(); it.hasNext(); ) { - SetProperty sp = (SetProperty) it.next(); - String where = sp.getMethodName(); - try { - sp.execute(pmf); - fail( - ASSERTION_FAILED, - "pmf method " + where + " should throw JDOUserException when called for closed pmf"); - } catch (JDOUserException ex) { - if (debug) logger.debug("Caught expected exception " + ex.toString() + " from " + where); - } catch (Exception ex) { - fail(ASSERTION_FAILED, "Caught unexpected exception " + ex.toString() + " from " + where); - } + pmf = getPMF(); + closePMF(pmf); // don't use closePMF() because that sets pmf to null + // each set method should throw an exception + Collection setCollection = Arrays.asList(setMethods); + for (Iterator it = setCollection.iterator(); it.hasNext();) { + SetProperty sp = (SetProperty)it.next(); + String where = sp.getMethodName(); + try { + sp.execute(pmf); + fail(ASSERTION_FAILED, + "pmf method " + where + " should throw JDOUserException when called for closed pmf"); + } catch (JDOUserException ex) { + if (debug) + logger.debug("Caught expected exception " + ex.toString() + + " from " + where); + } catch (Exception ex) { + fail(ASSERTION_FAILED, + "Caught unexpected exception " + ex.toString() + " from " + where); + } + } + // each get method should succeed + Collection getCollection = Arrays.asList(getMethods); + for (Iterator it = getCollection.iterator(); it.hasNext();) { + GetProperty gp = (GetProperty)it.next(); + String where = gp.getMethodName(); + try { + gp.execute(pmf); + } catch (Exception ex) { + fail(ASSERTION_FAILED, + "Caught unexpected exception " + ex.toString() + " from " + + where); + } + } } - // each get method should succeed - Collection getCollection = Arrays.asList(getMethods); - for (Iterator it = getCollection.iterator(); it.hasNext(); ) { - GetProperty gp = (GetProperty) it.next(); - String where = gp.getMethodName(); - try { - gp.execute(pmf); - } catch (Exception ex) { - fail(ASSERTION_FAILED, "Caught unexpected exception " + ex.toString() + " from " + where); - } + + /** */ + class SetProperty { + + java.lang.reflect.Method method; + String methodName; + Class[] parameters; + Object[] parameter; + + SetProperty(String methodName, Class[] parameters, Object[] parameter) { + this.methodName = methodName; + this.parameters = parameters; + this.parameter = parameter; + try { + method = PersistenceManagerFactory.class.getMethod(methodName, parameters); + } catch (NoSuchMethodException ex) { + throw new JDOFatalInternalException("Method not defined: " + methodName); + } + } + void execute(PersistenceManagerFactory pmf) { + try { + method.invoke(pmf, parameter); + } catch (IllegalAccessException ex) { + throw new JDOFatalInternalException("IllegalAccessException", ex); + } catch (java.lang.reflect.InvocationTargetException ex) { + throw (RuntimeException)ex.getTargetException(); + } + } + + String getMethodName() { + return methodName; + } } - } - - /** */ - class SetProperty { - - java.lang.reflect.Method method; - String methodName; - Class[] parameters; - Object[] parameter; - - SetProperty(String methodName, Class[] parameters, Object[] parameter) { - this.methodName = methodName; - this.parameters = parameters; - this.parameter = parameter; - try { - method = PersistenceManagerFactory.class.getMethod(methodName, parameters); - } catch (NoSuchMethodException ex) { - throw new JDOFatalInternalException("Method not defined: " + methodName); - } - } - - void execute(PersistenceManagerFactory pmf) { - try { - method.invoke(pmf, parameter); - } catch (IllegalAccessException ex) { - throw new JDOFatalInternalException("IllegalAccessException", ex); - } catch (java.lang.reflect.InvocationTargetException ex) { - throw (RuntimeException) ex.getTargetException(); - } - } - - String getMethodName() { - return methodName; - } - } - - /** */ - class GetProperty { - - java.lang.reflect.Method method; - String methodName; - - GetProperty(String methodName) { - this.methodName = methodName; - try { - method = PersistenceManagerFactory.class.getMethod(methodName, (Class[]) null); - } catch (NoSuchMethodException ex) { - throw new JDOFatalInternalException("Method not defined: " + methodName); - } - } - - void execute(PersistenceManagerFactory pmf) { - try { - method.invoke(pmf, (Object[]) null); - } catch (IllegalAccessException ex) { - throw new JDOFatalInternalException("IllegalAccessException", ex); - } catch (java.lang.reflect.InvocationTargetException ex) { - throw (RuntimeException) ex.getTargetException(); - } - } - - String getMethodName() { - return methodName; + + /** */ + class GetProperty { + + java.lang.reflect.Method method; + String methodName; + + GetProperty(String methodName) { + this.methodName = methodName; + try { + method = PersistenceManagerFactory.class.getMethod(methodName, + (Class[])null); + } catch (NoSuchMethodException ex) { + throw new JDOFatalInternalException("Method not defined: " + methodName); + } + } + void execute(PersistenceManagerFactory pmf) { + try { + method.invoke(pmf, (Object[])null); + } catch (IllegalAccessException ex) { + throw new JDOFatalInternalException("IllegalAccessException", ex); + } catch (java.lang.reflect.InvocationTargetException ex) { + throw (RuntimeException)ex.getTargetException(); + } + } + + String getMethodName() { + return methodName; + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterGetPersistenceManagerNoSetMethodsSucceed.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterGetPersistenceManagerNoSetMethodsSucceed.java index bb6bc98c1..ee42c1864 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterGetPersistenceManagerNoSetMethodsSucceed.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterGetPersistenceManagerNoSetMethodsSucceed.java @@ -5,220 +5,229 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import java.util.Arrays; import java.util.Collection; import java.util.Iterator; import java.util.Properties; + import javax.jdo.JDOException; import javax.jdo.JDOFatalInternalException; import javax.jdo.JDOUserException; import javax.jdo.PersistenceManagerFactory; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: After GetPersistenceManager No Set Methods Succeed
    - * Keywords:
    - * Assertion ID: A11.3-3.
    - * Assertion Description: After the first use of - * PersistenceManagerFactory.getPersistenceManager(), none of the set methods - * will succeed. + *Title: After GetPersistenceManager No Set Methods Succeed + *
    + *Keywords: + *
    + *Assertion ID: A11.3-3. + *
    + *Assertion Description: + * After the first use of + * PersistenceManagerFactory.getPersistenceManager(), + * none of the set methods will succeed. */ + public class AfterGetPersistenceManagerNoSetMethodsSucceed extends JDO_Test { - private String username; - private String password; - - private Class[] stringParameters = null; - private Class[] booleanParameters = null; - private Object[] stringParameter = null; - private Object[] booleanParameter = null; - private SetProperty[] setMethods = null; - private GetProperty[] getMethods = null; - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A11.3-3 (AfterGetPersistenceManagerNoSetMethodsSucceed) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(AfterGetPersistenceManagerNoSetMethodsSucceed.class); - } - - /** */ - public AfterGetPersistenceManagerNoSetMethodsSucceed() { - super(); - initVariables(); - } - - /** */ - public void initVariables() { - stringParameters = new Class[] {String.class}; - booleanParameters = new Class[] {boolean.class}; - stringParameter = new Object[] {"Nobody knows the trouble"}; - booleanParameter = new Object[] {Boolean.FALSE}; - - setMethods = - new SetProperty[] { - new SetProperty("setConnectionDriverName", stringParameters, stringParameter), - new SetProperty("setConnectionFactoryName", stringParameters, stringParameter), - new SetProperty("setConnectionFactory2Name", stringParameters, stringParameter), - new SetProperty("setConnectionURL", stringParameters, stringParameter), - new SetProperty("setConnectionUserName", stringParameters, stringParameter), - new SetProperty("setConnectionPassword", stringParameters, stringParameter), - new SetProperty("setIgnoreCache", booleanParameters, booleanParameter), - new SetProperty("setMultithreaded", booleanParameters, booleanParameter), - new SetProperty("setNontransactionalRead", booleanParameters, booleanParameter), - new SetProperty("setNontransactionalWrite", booleanParameters, booleanParameter), - new SetProperty("setOptimistic", booleanParameters, booleanParameter), - new SetProperty("setRestoreValues", booleanParameters, booleanParameter), - new SetProperty("setRetainValues", booleanParameters, booleanParameter) + private String username; + private String password; + + private Class[] stringParameters = null; + private Class[] booleanParameters = null; + private Object[] stringParameter = null; + private Object[] booleanParameter = null; + private SetProperty[] setMethods = null; + private GetProperty[] getMethods = null; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.3-3 (AfterGetPersistenceManagerNoSetMethodsSucceed) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(AfterGetPersistenceManagerNoSetMethodsSucceed.class); + } + + /** */ + public AfterGetPersistenceManagerNoSetMethodsSucceed() { + super(); + initVariables(); + } + + /** */ + public void initVariables() { + stringParameters = new Class[]{String.class}; + booleanParameters = new Class[]{boolean.class}; + stringParameter = new Object[]{"Nobody knows the trouble"}; + booleanParameter = new Object[]{Boolean.FALSE}; + + setMethods = new SetProperty[] { + new SetProperty("setConnectionDriverName", stringParameters, stringParameter), + new SetProperty("setConnectionFactoryName", stringParameters, stringParameter), + new SetProperty("setConnectionFactory2Name", stringParameters, stringParameter), + new SetProperty("setConnectionURL", stringParameters, stringParameter), + new SetProperty("setConnectionUserName", stringParameters, stringParameter), + new SetProperty("setConnectionPassword", stringParameters, stringParameter), + new SetProperty("setIgnoreCache", booleanParameters, booleanParameter), + new SetProperty("setMultithreaded", booleanParameters, booleanParameter), + new SetProperty("setNontransactionalRead", booleanParameters, booleanParameter), + new SetProperty("setNontransactionalWrite", booleanParameters, booleanParameter), + new SetProperty("setOptimistic", booleanParameters, booleanParameter), + new SetProperty("setRestoreValues", booleanParameters, booleanParameter), + new SetProperty("setRetainValues", booleanParameters, booleanParameter) }; - getMethods = - new GetProperty[] { - new GetProperty("getConnectionDriverName"), - new GetProperty("getConnectionFactoryName"), - new GetProperty("getConnectionFactory2Name"), - new GetProperty("getConnectionURL"), - new GetProperty("getConnectionUserName"), - new GetProperty("getIgnoreCache"), - new GetProperty("getMultithreaded"), - new GetProperty("getNontransactionalRead"), - new GetProperty("getNontransactionalWrite"), - new GetProperty("getOptimistic"), - new GetProperty("getRestoreValues"), - new GetProperty("getRetainValues") + getMethods = new GetProperty[] { + new GetProperty("getConnectionDriverName"), + new GetProperty("getConnectionFactoryName"), + new GetProperty("getConnectionFactory2Name"), + new GetProperty("getConnectionURL"), + new GetProperty("getConnectionUserName"), + new GetProperty("getIgnoreCache"), + new GetProperty("getMultithreaded"), + new GetProperty("getNontransactionalRead"), + new GetProperty("getNontransactionalWrite"), + new GetProperty("getOptimistic"), + new GetProperty("getRestoreValues"), + new GetProperty("getRetainValues") }; - } - - /** */ - public void testGetPersistenceManagerWithNoParametes() { - runTest(false); - } - - /** */ - public void testGetPersistenceManagerWithParameters() { - Properties props = loadProperties(PMFProperties); - username = props.getProperty(CONNECTION_USERNAME_PROP); - password = props.getProperty(CONNECTION_PASSWORD_PROP); - runTest(true); - } - - /** - * @param bUserAndPasswd flag whether to use user nad password - */ - public void runTest(boolean bUserAndPasswd) { - pmf = getPMF(); - if (!bUserAndPasswd) pm = getPM(); - else pm = getPMF().getPersistenceManager(username, password); - - // each set method should throw an exception - Collection setCollection = Arrays.asList(setMethods); - for (Iterator it = setCollection.iterator(); it.hasNext(); ) { - SetProperty sp = (SetProperty) it.next(); - String where = sp.getMethodName(); - try { - sp.execute(pmf); - fail( - ASSERTION_FAILED, - "pmf method " - + where - + " should throw JDOUserException when called after getPersistenceManager"); - } catch (JDOUserException ex) { - if (debug) logger.debug("Caught expected exception " + ex.toString() + " from " + where); - } - } - // each get method should succeed - Collection getCollection = Arrays.asList(getMethods); - for (Iterator it = getCollection.iterator(); it.hasNext(); ) { - GetProperty gp = (GetProperty) it.next(); - String where = gp.getMethodName(); - try { - gp.execute(pmf); - } catch (JDOUserException ex) { - fail(ASSERTION_FAILED, "Caught unexpected exception " + ex.toString() + " from " + where); - } - } - } - - /** */ - static class SetProperty { - - java.lang.reflect.Method method; - String methodName; - Class[] parameters; - Object[] parameter; - - SetProperty(String methodName, Class[] parameters, Object[] parameter) { - this.methodName = methodName; - this.parameters = parameters; - this.parameter = parameter; - try { - method = PersistenceManagerFactory.class.getMethod(methodName, parameters); - } catch (NoSuchMethodException ex) { - throw new JDOFatalInternalException("Method not defined: " + methodName); - } } - void execute(PersistenceManagerFactory pmf) { - try { - method.invoke(pmf, parameter); - } catch (IllegalAccessException ex) { - throw new JDOFatalInternalException("IllegalAccessException", ex); - } catch (java.lang.reflect.InvocationTargetException ex) { - throw (JDOException) ex.getTargetException(); - } + /** */ + public void testGetPersistenceManagerWithNoParametes() { + runTest(false); } - String getMethodName() { - return methodName; + /** */ + public void testGetPersistenceManagerWithParameters() { + Properties props = loadProperties(PMFProperties); + username = props.getProperty(CONNECTION_USERNAME_PROP); + password = props.getProperty(CONNECTION_PASSWORD_PROP); + runTest(true); } - } - - /** */ - static class GetProperty { - java.lang.reflect.Method method; - String methodName; - - GetProperty(String methodName) { - this.methodName = methodName; - try { - method = PersistenceManagerFactory.class.getMethod(methodName, (Class[]) null); - } catch (NoSuchMethodException ex) { - throw new JDOFatalInternalException("Method not defined: " + methodName); - } + /** + * + * @param bUserAndPasswd flag whether to use user nad password + */ + public void runTest(boolean bUserAndPasswd) { + pmf = getPMF(); + if (!bUserAndPasswd) + pm = getPM(); + else + pm = getPMF().getPersistenceManager(username,password); + + // each set method should throw an exception + Collection setCollection = Arrays.asList(setMethods); + for (Iterator it = setCollection.iterator(); it.hasNext();) { + SetProperty sp = (SetProperty)it.next(); + String where = sp.getMethodName(); + try { + sp.execute(pmf); + fail(ASSERTION_FAILED, + "pmf method " + where + + " should throw JDOUserException when called after getPersistenceManager"); + } catch (JDOUserException ex) { + if (debug) + logger.debug("Caught expected exception " + ex.toString() + " from " + where); + } + } + // each get method should succeed + Collection getCollection = Arrays.asList(getMethods); + for (Iterator it = getCollection.iterator(); it.hasNext();) { + GetProperty gp = (GetProperty)it.next(); + String where = gp.getMethodName(); + try { + gp.execute(pmf); + } catch (JDOUserException ex) { + fail(ASSERTION_FAILED, + "Caught unexpected exception " + ex.toString() + " from " + where); + } + } } - - void execute(PersistenceManagerFactory pmf) { - try { - method.invoke(pmf, (Object[]) null); - } catch (IllegalAccessException ex) { - throw new JDOFatalInternalException("IllegalAccessException", ex); - } catch (java.lang.reflect.InvocationTargetException ex) { - throw (JDOException) ex.getTargetException(); - } + + /** */ + static class SetProperty { + + java.lang.reflect.Method method; + String methodName; + Class[] parameters; + Object[] parameter; + + SetProperty(String methodName, Class[] parameters, Object[] parameter) { + this.methodName = methodName; + this.parameters = parameters; + this.parameter = parameter; + try { + method = PersistenceManagerFactory.class.getMethod(methodName, parameters); + } catch (NoSuchMethodException ex) { + throw new JDOFatalInternalException("Method not defined: " + methodName); + } + } + void execute(PersistenceManagerFactory pmf) { + try { + method.invoke(pmf, parameter); + } catch (IllegalAccessException ex) { + throw new JDOFatalInternalException("IllegalAccessException", ex); + } catch (java.lang.reflect.InvocationTargetException ex) { + throw (JDOException)ex.getTargetException(); + } + } + + String getMethodName() { + return methodName; + } } - - String getMethodName() { - return methodName; + + /** */ + static class GetProperty { + + java.lang.reflect.Method method; + String methodName; + + GetProperty(String methodName) { + this.methodName = methodName; + try { + method = PersistenceManagerFactory.class.getMethod(methodName, + (Class[])null); + } catch (NoSuchMethodException ex) { + throw new JDOFatalInternalException( + "Method not defined: " + methodName); + } + } + void execute(PersistenceManagerFactory pmf) { + try { + method.invoke(pmf, (Object[])null); + } catch (IllegalAccessException ex) { + throw new JDOFatalInternalException("IllegalAccessException", ex); + } catch (java.lang.reflect.InvocationTargetException ex) { + throw (JDOException)ex.getTargetException(); + } + } + + String getMethodName() { + return methodName; + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/Close.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/Close.java index f6a7cd06e..15b503fe1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/Close.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/Close.java @@ -5,123 +5,136 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; +import javax.jdo.JDOFatalInternalException; +import javax.jdo.LegacyJava; import java.lang.reflect.InvocationTargetException; import java.security.PrivilegedAction; -import javax.jdo.JDOFatalInternalException; + import javax.jdo.JDOFatalUserException; import javax.jdo.JDOUserException; -import javax.jdo.LegacyJava; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:Close of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.4-2, A11.4-10
    - * Assertion Description: PersistenceManagerFactory.close() closes this - * PersistenceManagerFactory. Assertion Description: PersistenceManagerFactory.isClosed(); - * Return true if this PersistenceManagerFactory is closed; and false otherwise. + *Title:Close of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.4-2, A11.4-10 + *
    + *Assertion Description: + * PersistenceManagerFactory.close() closes this PersistenceManagerFactory. + *Assertion Description: + * PersistenceManagerFactory.isClosed(); Return true if this PersistenceManagerFactory is closed; and false otherwise. */ -public class Close extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertions A11.4-2 (Close), A11.4-10 (isClosed) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Close.class); - } +public class Close extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertions A11.4-2 (Close), A11.4-10 (isClosed) failed: "; - @SuppressWarnings("unchecked") - private static T doPrivileged(PrivilegedAction privilegedAction) { - try { - return (T) LegacyJava.doPrivilegedAction.invoke(null, privilegedAction); - } catch (IllegalAccessException | InvocationTargetException e) { - if (e.getCause() instanceof RuntimeException) { - throw (RuntimeException) e.getCause(); - } - throw new JDOFatalInternalException(e.getMessage()); + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Close.class); } - } - /** */ - public void test() { - pmf = getPMF(); + @SuppressWarnings("unchecked") + private static T doPrivileged(PrivilegedAction privilegedAction) { + try { + return (T) LegacyJava.doPrivilegedAction.invoke(null, privilegedAction); + } catch (IllegalAccessException | InvocationTargetException e) { + if (e.getCause() instanceof RuntimeException) { + throw (RuntimeException) e.getCause(); + } + throw new JDOFatalInternalException(e.getMessage()); + } + } - // check pmf.isClosed() before and after pmf.close() - try { - if (pmf.isClosed()) { - fail(ASSERTION_FAILED, "PMF.isClosed() returned true on an open pmf"); - } + /** */ + public void test() { + pmf = getPMF(); - closePMF(pmf); // don't use closePMF() because that sets pmf to null + // check pmf.isClosed() before and after pmf.close() + try { + if (pmf.isClosed()) { + fail(ASSERTION_FAILED, + "PMF.isClosed() returned true on an open pmf"); + } + + closePMF(pmf); // don't use closePMF() because that sets pmf to null + + if (!pmf.isClosed()) { + fail(ASSERTION_FAILED, + "PMF.isClosed() returned false on a closed pmf"); + } + } catch (JDOUserException ex) { + // unexpected exception + fail(ASSERTION_FAILED, + "Unexpected exception at pmf.close()/isClosed(): " + ex); + } catch (JDOFatalUserException ex) { + // unexpected exception + fail(ASSERTION_FAILED, + "Unexpected exception at pmf.close()/isClosed(): " + ex); + } - if (!pmf.isClosed()) { - fail(ASSERTION_FAILED, "PMF.isClosed() returned false on a closed pmf"); - } - } catch (JDOUserException ex) { - // unexpected exception - fail(ASSERTION_FAILED, "Unexpected exception at pmf.close()/isClosed(): " + ex); - } catch (JDOFatalUserException ex) { - // unexpected exception - fail(ASSERTION_FAILED, "Unexpected exception at pmf.close()/isClosed(): " + ex); - } + // pmf.close() on already-closed pmf should not throw an exception + try { + // don't use closePMF methods because they check isClosed before calling + doPrivileged( + new PrivilegedAction () { + public Object run () { + pmf.close(); + return null; + } + } + ); + } catch (JDOUserException ex) { + // unexpected exception + fail(ASSERTION_FAILED, + "Unexpected exception at repeated pmf.close(): " + ex); + } catch (JDOFatalUserException ex) { + // unexpected exception + fail(ASSERTION_FAILED, + "Unexpected exception at repeated pmf.close(): " + ex); + } - // pmf.close() on already-closed pmf should not throw an exception - try { - // don't use closePMF methods because they check isClosed before calling - doPrivileged( - new PrivilegedAction() { - public Object run() { - pmf.close(); - return null; + // trying to get a getPersistenceManager should result in a exception + try { + pm = pmf.getPersistenceManager(); + fail(ASSERTION_FAILED, + "JDOUserException was not thrown when calling pmf.getPersistenceManager() after pmf was closed"); + } catch (JDOUserException ex) { + // expected exception + if (debug) { + logger.debug("caught expected exception " + ex.toString()); } - }); - } catch (JDOUserException ex) { - // unexpected exception - fail(ASSERTION_FAILED, "Unexpected exception at repeated pmf.close(): " + ex); - } catch (JDOFatalUserException ex) { - // unexpected exception - fail(ASSERTION_FAILED, "Unexpected exception at repeated pmf.close(): " + ex); - } + } catch (JDOFatalUserException ex) { + // unexpected exception + fail(ASSERTION_FAILED, + "Wrong exception thrown from getPersistenceManager after close.\n" + + "Expected JDOUserException, got JDOFatalUserException."); + } - // trying to get a getPersistenceManager should result in a exception - try { - pm = pmf.getPersistenceManager(); - fail( - ASSERTION_FAILED, - "JDOUserException was not thrown when calling pmf.getPersistenceManager() after pmf was closed"); - } catch (JDOUserException ex) { - // expected exception - if (debug) { - logger.debug("caught expected exception " + ex.toString()); - } - } catch (JDOFatalUserException ex) { - // unexpected exception - fail( - ASSERTION_FAILED, - "Wrong exception thrown from getPersistenceManager after close.\n" - + "Expected JDOUserException, got JDOFatalUserException."); + // have next invocation of getPMF() get a new pmf + pmf = null; } - - // have next invocation of getPMF() get a new pmf - pmf = null; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseFailsIfTransactionActive.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseFailsIfTransactionActive.java index 13c4635a9..5d1d2fc0b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseFailsIfTransactionActive.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseFailsIfTransactionActive.java @@ -5,16 +5,16 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import javax.jdo.JDOException; @@ -22,21 +22,29 @@ import javax.jdo.PersistenceManager; import javax.jdo.PersistenceManagerFactory; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:CloseFailsIfTransactionActive of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.4-4.
    - * Assertion Description: PersistenceManagerFactory.getPersistenceManager() throws - * JDOUserException after the PersistenceManagerFactory is closed. The exception contains an array - * of nested exceptions; each nested exception contains as its failed object the PersistenceManager - * whose Transaction is still active. During close of the PersistenceManagerFactory, all - * PersistenceManager instances obtained from this PersistenceManagerFactory are themselves closed. + *Title:CloseFailsIfTransactionActive of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.4-4. + *
    + *Assertion Description: + * PersistenceManagerFactory.getPersistenceManager() throws + * JDOUserException after the PersistenceManagerFactory is closed. + * The exception contains an array of nested exceptions; each nested + * exception contains as its failed object the PersistenceManager whose + * Transaction is still active. + * During close of the PersistenceManagerFactory, all PersistenceManager + * instances obtained from this PersistenceManagerFactory are + * themselves closed. */ -/* +/* * Revision History * ================ * Author : Craig Russell @@ -45,142 +53,168 @@ */ public class CloseFailsIfTransactionActive extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.4-4 (CloseFailsIfTransactionActive) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CloseFailsIfTransactionActive.class); + } - /** */ - private static final String ASSERTION_FAILED = - "Assertion A11.4-4 (CloseFailsIfTransactionActive) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CloseFailsIfTransactionActive.class); - } - - protected boolean aborted = false; - - /** */ - public void test() { - PersistenceManager pm1 = null; - PersistenceManager pm2 = null; - cleanupPMF(getPMF()); - pmf = null; - - try { - pm1 = getPM(); - pm2 = getPM(); - pm1.currentTransaction().begin(); - pm1.currentTransaction().commit(); - pm2.currentTransaction().begin(); - closePMF(pmf); // don't use closePMF() because that sets pmf to null - setAborted(); - fail(ASSERTION_FAILED, "Close incorrectly succeeded with active transaction"); - } catch (JDOUserException ex) { - try { - if (debug) logger.debug("Caught expected exception " + ex.getMessage()); - PersistenceManager[] pms = getFailedPersistenceManagers(ex); - if (pms.length != 1) { - setAborted(); - fail(ASSERTION_FAILED, "Unexpected number of nested exceptions: " + pms.length); - } else { - Object failed = pms[0]; - if (pm2.equals(failed)) { - if (debug) logger.debug("Found expected failed object " + failed.toString()); - } else { + protected boolean aborted = false; + + /** */ + public void test() { + PersistenceManager pm1 = null; + PersistenceManager pm2 = null; + cleanupPMF(getPMF()); + pmf = null; + + try { + pm1 = getPM(); + pm2 = getPM(); + pm1.currentTransaction().begin(); + pm1.currentTransaction().commit(); + pm2.currentTransaction().begin(); + closePMF(pmf); // don't use closePMF() because that sets pmf to null setAborted(); - fail(ASSERTION_FAILED, "Found unexpected failed object " + failed.toString()); - } - } - if (pm1.isClosed()) { - fail(ASSERTION_FAILED, "Unexpected pm1 is closed."); + fail(ASSERTION_FAILED, + "Close incorrectly succeeded with active transaction"); + } + catch (JDOUserException ex) { + try { + if (debug) + logger.debug("Caught expected exception " + ex.getMessage()); + PersistenceManager[] pms = getFailedPersistenceManagers(ex); + if (pms.length != 1) { + setAborted(); + fail(ASSERTION_FAILED, + "Unexpected number of nested exceptions: " + pms.length); + } + else { + Object failed = pms[0]; + if (pm2.equals(failed)) { + if (debug) + logger.debug("Found expected failed object " + + failed.toString()); + } + else { + setAborted(); + fail(ASSERTION_FAILED, + "Found unexpected failed object " + + failed.toString()); + } + } + if (pm1.isClosed()){ + fail(ASSERTION_FAILED, "Unexpected pm1 is closed."); + } + if (pm2.isClosed()){ + fail(ASSERTION_FAILED, "Unexpected pm2 is closed."); + } + } + catch (Exception uex) { + setAborted(); + fail(ASSERTION_FAILED, + "Caught 1 unexpected exception " + uex.toString()); + } + } + catch (Exception ex) { + setAborted(); + fail(ASSERTION_FAILED, + "Caught 2 unexpected exception " + ex.toString()); } - if (pm2.isClosed()) { - fail(ASSERTION_FAILED, "Unexpected pm2 is closed."); + + if (!isAborted()) { + try { + pm2.currentTransaction().commit(); + closePMF(pmf); // don't use closePMF() because that sets pmf to null + if (!pm1.isClosed()){ + fail(ASSERTION_FAILED, + "Unexpected pm1 is not closed."); + } + if (!pm2.isClosed()) { + fail(ASSERTION_FAILED, + "Unexpected pm2 is not closed."); + } + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "Caught 3 unexpected exception " + ex.toString()); + } } - } catch (Exception uex) { - setAborted(); - fail(ASSERTION_FAILED, "Caught 1 unexpected exception " + uex.toString()); - } - } catch (Exception ex) { - setAborted(); - fail(ASSERTION_FAILED, "Caught 2 unexpected exception " + ex.toString()); } - if (!isAborted()) { - try { - pm2.currentTransaction().commit(); - closePMF(pmf); // don't use closePMF() because that sets pmf to null - if (!pm1.isClosed()) { - fail(ASSERTION_FAILED, "Unexpected pm1 is not closed."); + /** + * + * @param pmf the PersistenceManagerFactory + */ + protected void cleanupPMF(PersistenceManagerFactory pmf) { + try { + closePMF(pmf); // don't use closePMF() because that sets pmf to null + } catch (JDOException ex) { + PersistenceManager[] pms = getFailedPersistenceManagers(ex); + int numberOfPersistenceManagers = pms.length; + for (int i = 0; i < numberOfPersistenceManagers; ++i) { + PersistenceManager pm = pms[i]; + if (pm == null) { + fail(ASSERTION_FAILED, + "Found unexpected null PersistenceManager"); + } + else { + Transaction tx = pm.currentTransaction(); + if (tx.isActive()) { + if (debug) + logger.debug("Found active transaction; rolling back."); + tx.rollback(); + } + else { + fail(ASSERTION_FAILED, + "Unexpectedly, this transaction is not active: " + tx); + } + } + } } - if (!pm2.isClosed()) { - fail(ASSERTION_FAILED, "Unexpected pm2 is not closed."); - } - } catch (Exception ex) { - fail(ASSERTION_FAILED, "Caught 3 unexpected exception " + ex.toString()); - } } - } - - /** - * @param pmf the PersistenceManagerFactory - */ - protected void cleanupPMF(PersistenceManagerFactory pmf) { - try { - closePMF(pmf); // don't use closePMF() because that sets pmf to null - } catch (JDOException ex) { - PersistenceManager[] pms = getFailedPersistenceManagers(ex); - int numberOfPersistenceManagers = pms.length; - for (int i = 0; i < numberOfPersistenceManagers; ++i) { - PersistenceManager pm = pms[i]; - if (pm == null) { - fail(ASSERTION_FAILED, "Found unexpected null PersistenceManager"); - } else { - Transaction tx = pm.currentTransaction(); - if (tx.isActive()) { - if (debug) logger.debug("Found active transaction; rolling back."); - tx.rollback(); - } else { - fail(ASSERTION_FAILED, "Unexpectedly, this transaction is not active: " + tx); - } - } - } + + /** */ + protected void setAborted() { + aborted = true; } - } - - /** */ - protected void setAborted() { - aborted = true; - } - /** - * @return true if aborted - */ - protected boolean isAborted() { - return aborted; - } + /** + * + * @return true if aborted + */ + protected boolean isAborted() { + return aborted; + } - /** - * @param ex JDOException - * @return arry of failed PersistenceManager - */ - protected PersistenceManager[] getFailedPersistenceManagers(JDOException ex) { - Throwable[] nesteds = ex.getNestedExceptions(); - int numberOfExceptions = nesteds == null ? 0 : nesteds.length; - PersistenceManager[] result = new PersistenceManager[numberOfExceptions]; - for (int i = 0; i < numberOfExceptions; ++i) { - JDOException exc = (JDOException) nesteds[i]; - Object failedObject = exc.getFailedObject(); - if (exc.getFailedObject() instanceof PersistenceManager) { - result[i] = (PersistenceManager) failedObject; - } else { - fail( - ASSERTION_FAILED, - "Unexpected failed object of type: " + failedObject.getClass().getName()); - } + /** + * + * @param ex JDOException + * @return arry of failed PersistenceManager + */ + protected PersistenceManager[] getFailedPersistenceManagers(JDOException ex) { + Throwable[] nesteds = ex.getNestedExceptions(); + int numberOfExceptions = nesteds==null ? 0 : nesteds.length; + PersistenceManager[] result = new PersistenceManager[numberOfExceptions]; + for (int i = 0; i < numberOfExceptions; ++i) { + JDOException exc = (JDOException)nesteds[i]; + Object failedObject = exc.getFailedObject(); + if (exc.getFailedObject() instanceof PersistenceManager) { + result[i] = (PersistenceManager)failedObject; + } else { + fail(ASSERTION_FAILED, + "Unexpected failed object of type: " + + failedObject.getClass().getName()); + } + } + return result; } - return result; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseWithoutPermissionThrowsSecurityException.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseWithoutPermissionThrowsSecurityException.java index 1384c8c7b..e24eeafb0 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseWithoutPermissionThrowsSecurityException.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/CloseWithoutPermissionThrowsSecurityException.java @@ -5,93 +5,103 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import java.security.Permission; + import javax.jdo.JDOException; import javax.jdo.LegacyJava; import javax.jdo.PersistenceManagerFactory; import javax.jdo.spi.JDOPermission; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:Close of PersistenceManagerFactory Throws SecurityException if - * JDOPermission("closePersistenceManagerFactory") Is Not Set
    - * Keywords: persistencemanagerfactory SecurityException
    - * Assertion IDs: A11.4-3
    - * Assertion Description: PersistenceManagerFactory.close() closes this - * PersistenceManagerFactory. If JDOPermission("closePersistenceManagerFactory") is not set, then - * SecurityException in thrown. + *Title:Close of PersistenceManagerFactory Throws SecurityException if + * JDOPermission("closePersistenceManagerFactory") Is Not Set + *
    + *Keywords: persistencemanagerfactory SecurityException + *
    + *Assertion IDs: A11.4-3 + *
    + *Assertion Description: + * PersistenceManagerFactory.close() closes this PersistenceManagerFactory. + * If JDOPermission("closePersistenceManagerFactory") is not set, then + * SecurityException in thrown. */ -public class CloseWithoutPermissionThrowsSecurityException extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertions A11.4-3 (CloseWithoutPermissionThrowsSecurityException) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CloseWithoutPermissionThrowsSecurityException.class); - } - /** */ - public void test() { - pmf = getPMF(); +public class CloseWithoutPermissionThrowsSecurityException extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertions A11.4-3 (CloseWithoutPermissionThrowsSecurityException) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CloseWithoutPermissionThrowsSecurityException.class); + } - closeWithMySecurityManager(pmf); + /** */ + public void test() { + pmf = getPMF(); - closePMF(pmf); + closeWithMySecurityManager(pmf); - closeWithMySecurityManager(pmf); - } + closePMF(pmf); - private void closeWithMySecurityManager(PersistenceManagerFactory pmf) { - if (LegacyJava.isSecurityManagerDeprecated()) { - return; - } - SecurityManager oldSecMgr = System.getSecurityManager(); - try { - System.setSecurityManager(new MySecurityManager()); - } catch (SecurityException se) { - // running with the TCK SecurityManager; don't run this test - return; + closeWithMySecurityManager(pmf); } - try { - pmf.close(); - fail( - ASSERTION_FAILED, - "SecurityException was not thrown when calling pmf.close() " - + "without JDOPermission.CLOSE_PERSISTENCE_MANAGER_FACTORY"); - } catch (SecurityException ex) { - // expected exception if JDOPermission("closePersistenceManagerFactory") is not set - if (debug) logger.debug("caught expected exception " + ex.toString()); - } catch (JDOException e) { - fail(ASSERTION_FAILED, "Unexpected exception at pmf.close(): " + e); - } finally { - System.setSecurityManager(oldSecMgr); + private void closeWithMySecurityManager(PersistenceManagerFactory pmf) { + if (LegacyJava.isSecurityManagerDeprecated()) { + return; + } + SecurityManager oldSecMgr = System.getSecurityManager(); + try { + System.setSecurityManager(new MySecurityManager()); + } catch (SecurityException se) { + // running with the TCK SecurityManager; don't run this test + return; + } + + try { + pmf.close(); + fail(ASSERTION_FAILED, + "SecurityException was not thrown when calling pmf.close() " + + "without JDOPermission.CLOSE_PERSISTENCE_MANAGER_FACTORY"); + } catch (SecurityException ex) { + // expected exception if JDOPermission("closePersistenceManagerFactory") is not set + if (debug) + logger.debug("caught expected exception " + ex.toString()); + } catch (JDOException e) { + fail(ASSERTION_FAILED, "Unexpected exception at pmf.close(): " + e); + } + finally { + System.setSecurityManager(oldSecMgr); + } } - } - public class MySecurityManager extends SecurityManager { - public void checkPermission(Permission perm) { - if (perm == JDOPermission.CLOSE_PERSISTENCE_MANAGER_FACTORY) - throw new SecurityException("JDOPermission.CLOSE_PERSISTENCE_MANAGER_FACTORY not set"); + public class MySecurityManager extends SecurityManager { + public void checkPermission(Permission perm) { + if (perm==JDOPermission.CLOSE_PERSISTENCE_MANAGER_FACTORY) + throw new SecurityException( + "JDOPermission.CLOSE_PERSISTENCE_MANAGER_FACTORY not set"); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/FlushThrowsIfReadOnly.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/FlushThrowsIfReadOnly.java index 9709e3003..5b6ecd2a5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/FlushThrowsIfReadOnly.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/FlushThrowsIfReadOnly.java @@ -5,164 +5,163 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import java.util.Date; + import java.util.Properties; import javax.jdo.Constants; import javax.jdo.JDOHelper; import javax.jdo.JDOReadOnlyException; import javax.jdo.PersistenceManagerFactory; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.Address; import org.apache.jdo.tck.pc.company.Company; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:ReadOnly property of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.1-28
    - * Assertion Description: if an attempt is made to write (via flush) then - * JDOReadOnlyException is thrown. + *Title:ReadOnly property of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.1-28 + *
    + *Assertion Description: + * if an attempt is made to write (via flush) then JDOReadOnlyException + * is thrown. */ -public class FlushThrowsIfReadOnly extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A11.1-28 FlushThrowsIfReadOnly failed: "; - /** Second PMF that is read-only */ - PersistenceManagerFactory pmf2; +public class FlushThrowsIfReadOnly extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.1-28 FlushThrowsIfReadOnly failed: "; + + /** Second PMF that is read-only */ + PersistenceManagerFactory pmf2; - /** The company oid */ - Object oid; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(FlushThrowsIfReadOnly.class); - } + /** The company oid */ + Object oid; + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(FlushThrowsIfReadOnly.class); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(Company.class); - Properties properties = loadProperties(PMFProperties); - properties.put(Constants.PROPERTY_READONLY, "true"); - pmf2 = JDOHelper.getPersistenceManagerFactory(properties); - // insert an instance to find - getPM(); - pm.currentTransaction().begin(); - Company comp = - new Company(1L, "Sun Microsystems", new Date(), new Address(0, "", "", "", "", "")); - pm.makePersistent(comp); - oid = pm.getObjectId(comp); - pm.currentTransaction().commit(); - pm.close(); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(Company.class); + Properties properties = loadProperties(PMFProperties); + properties.put(Constants.PROPERTY_READONLY, "true"); + pmf2 = JDOHelper.getPersistenceManagerFactory(properties); + // insert an instance to find + getPM(); + pm.currentTransaction().begin(); + Company comp = new Company(1L, "Sun Microsystems", new Date(), + new Address(0,"","","","","")); + pm.makePersistent(comp); + oid = pm.getObjectId(comp); + pm.currentTransaction().commit(); + pm.close(); + } - /** */ - public void testMakePersistent() { - // Try to makePersistent and flush the transaction - pm = pmf2.getPersistenceManager(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - Company comp = - new Company(2L, "Sun Microsystems2", new Date(), new Address(0, "", "", "", "", "")); - try { - pm.makePersistent(comp); - pm.flush(); - fail( - "When the PersistenceManagerFactory is read only, " - + "flush of a persistent-new instance must throw " - + "JDOReadOnlyException."); - } catch (JDOReadOnlyException jDOReadOnlyException) { - // good catch - } catch (Throwable t) { - fail( - "When the PersistenceManagerFactory is read only, " - + "flush of a persistent-deleted instance must throw " - + "JDOReadOnlyException. Flush threw " - + t); + /** */ + public void testMakePersistent() { + //Try to makePersistent and flush the transaction + pm = pmf2.getPersistenceManager(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Company comp = new Company(2L, "Sun Microsystems2", new Date(), + new Address(0,"","","","","")); + try { + pm.makePersistent(comp); + pm.flush(); + fail("When the PersistenceManagerFactory is read only, " + + "flush of a persistent-new instance must throw " + + "JDOReadOnlyException."); + } catch (JDOReadOnlyException jDOReadOnlyException) { + // good catch + } catch (Throwable t) { + fail("When the PersistenceManagerFactory is read only, " + + "flush of a persistent-deleted instance must throw " + + "JDOReadOnlyException. Flush threw " + t); + } + tx.rollback(); + pm.close(); + pm = null; + closePMF(pmf2); } - tx.rollback(); - pm.close(); - pm = null; - closePMF(pmf2); - } - /** */ - public void testUpdate() { - // Try to update and flush the transaction - pm = pmf2.getPersistenceManager(); - pm.getExtent(Company.class); // make sure that oid class is loaded - Transaction tx = pm.currentTransaction(); - tx.begin(); - Company comp = (Company) pm.getObjectById(oid); - try { - comp.setName("new name"); - pm.flush(); - fail( - "When the PersistenceManagerFactory is read only, " - + "flush of an updated instance must throw " - + "JDOReadOnlyException."); - } catch (JDOReadOnlyException jDOReadOnlyException) { - // good catch - } catch (Throwable t) { - fail( - "When the PersistenceManagerFactory is read only, " - + "flush of a persistent-deleted instance must throw " - + "JDOReadOnlyException. Flush threw " - + t); + /** */ + public void testUpdate() { + //Try to update and flush the transaction + pm = pmf2.getPersistenceManager(); + pm.getExtent(Company.class); // make sure that oid class is loaded + Transaction tx = pm.currentTransaction(); + tx.begin(); + Company comp = (Company)pm.getObjectById(oid); + try { + comp.setName("new name"); + pm.flush(); + fail("When the PersistenceManagerFactory is read only, " + + "flush of an updated instance must throw " + + "JDOReadOnlyException."); + } catch (JDOReadOnlyException jDOReadOnlyException) { + // good catch + } catch (Throwable t) { + fail("When the PersistenceManagerFactory is read only, " + + "flush of a persistent-deleted instance must throw " + + "JDOReadOnlyException. Flush threw " + t); + } + tx.rollback(); + pm.close(); + pm = null; + closePMF(pmf2); } - tx.rollback(); - pm.close(); - pm = null; - closePMF(pmf2); - } - /** */ - public void testDeletePersistent() { - // Try to deletePersistent and flush the transaction - pm = pmf2.getPersistenceManager(); - pm.getExtent(Company.class); // make sure that oid class is loaded - Transaction tx = pm.currentTransaction(); - tx.begin(); - Company comp = (Company) pm.getObjectById(oid); - try { - pm.deletePersistent(comp); - pm.flush(); - fail( - "When the PersistenceManagerFactory is read only, " - + "flush of a persistent-deleted instance must throw " - + "JDOReadOnlyException."); - } catch (JDOReadOnlyException jDOReadOnlyException) { - // good catch - } catch (Throwable t) { - fail( - "When the PersistenceManagerFactory is read only, " - + "flush of a persistent-deleted instance must throw " - + "JDOReadOnlyException. Flush threw " - + t); + /** */ + public void testDeletePersistent() { + //Try to deletePersistent and flush the transaction + pm = pmf2.getPersistenceManager(); + pm.getExtent(Company.class); // make sure that oid class is loaded + Transaction tx = pm.currentTransaction(); + tx.begin(); + Company comp = (Company)pm.getObjectById(oid); + try { + pm.deletePersistent(comp); + pm.flush(); + fail("When the PersistenceManagerFactory is read only, " + + "flush of a persistent-deleted instance must throw " + + "JDOReadOnlyException."); + } catch (JDOReadOnlyException jDOReadOnlyException) { + // good catch + } catch (Throwable t) { + fail("When the PersistenceManagerFactory is read only, " + + "flush of a persistent-deleted instance must throw " + + "JDOReadOnlyException. Flush threw " + t); + } + tx.rollback(); + pm.close(); + pm = null; + closePMF(pmf2); } - tx.rollback(); - pm.close(); - pm = null; - closePMF(pmf2); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetManagedClasses.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetManagedClasses.java index 2a3ccafc5..9e41b9734 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetManagedClasses.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetManagedClasses.java @@ -5,71 +5,78 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import java.util.Collection; + import javax.jdo.Query; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.pc.mylib.PCRect; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:GetManagedClasses of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs:
    - * Assertion Description: Test output from PersistenceManagerFactory.getManagedClasses(). + *Title:GetManagedClasses of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: + *
    + *Assertion Description: + * Test output from PersistenceManagerFactory.getManagedClasses(). */ + public class GetManagedClasses extends JDO_Test { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetManagedClasses.class); - } + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetManagedClasses.class); + } - /** */ - public void test() { - try { - // Get PMF and a PM, and do an Extent on some classes - pmf = getPMF(); - pm = pmf.getPersistenceManager(); - try { - pm.currentTransaction().begin(); + /** */ + public void test() { + try { + // Get PMF and a PM, and do an Extent on some classes + pmf = getPMF(); + pm = pmf.getPersistenceManager(); + try { + pm.currentTransaction().begin(); - pm.getExtent(PCPoint.class); + pm.getExtent(PCPoint.class); - Query q = pm.newQuery(PCRect.class); - q.execute(); + Query q = pm.newQuery(PCRect.class); + q.execute(); - pm.currentTransaction().rollback(); - } catch (Exception e) { - fail("Exception failed accessing Extents"); - } finally { - if (pm.currentTransaction().isActive()) { - pm.currentTransaction().rollback(); - } - } + pm.currentTransaction().rollback(); + } catch (Exception e) { + fail("Exception failed accessing Extents"); + } finally { + if (pm.currentTransaction().isActive()) { + pm.currentTransaction().rollback(); + } + } - // Check that the classes are now managed - Collection managedClasses = pmf.getManagedClasses(); - assertTrue("PCPoint ought to be managed but isnt", managedClasses.contains(PCPoint.class)); - assertTrue("PCRect ought to be managed but isnt", managedClasses.contains(PCRect.class)); - } finally { - pm.close(); + // Check that the classes are now managed + Collection managedClasses = pmf.getManagedClasses(); + assertTrue("PCPoint ought to be managed but isnt", managedClasses.contains(PCPoint.class)); + assertTrue("PCRect ought to be managed but isnt", managedClasses.contains(PCRect.class)); + } finally { + pm.close(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByFile.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByFile.java index 45c83da3b..d6814e5d5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByFile.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByFile.java @@ -5,63 +5,75 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import java.io.File; + import javax.jdo.JDOHelper; import javax.jdo.PersistenceManagerFactory; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:GetPMFByFile of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A8.6-13.
    - * Assertion Description: Uses the parameter(s) passed as arguments to construct a - * Properties instance, and then delegates to the static method getPersistenceManagerFactory in the - * class named in the property javax.jdo.PersistenceManagerFactoryClass. If there are any exceptions - * while trying to construct the Properties instance or to call the static method, then either - * A8.6-4 [JDOFatalUserException] or A8.6-5 [JDOFatalInternalException is thrown], depending on - * whether the exception is due to the user or the implementation. The nested exception indicates - * the cause of the exception. - * + *Title:GetPMFByFile of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A8.6-13. + *
    + *Assertion Description: + * Uses the parameter(s) passed as arguments to construct a Properties + * instance, and then delegates to the static method + * getPersistenceManagerFactory in the class named in the property + * javax.jdo.PersistenceManagerFactoryClass. + * If there are any exceptions while trying to construct the Properties + * instance or to call the static method, + * then either A8.6-4 [JDOFatalUserException] or + * A8.6-5 [JDOFatalInternalException is thrown], + * depending on whether the exception is due to the user + * or the implementation. + * The nested exception indicates the cause of the exception. + * * @author Michael Watzek */ -public class GetPMFByFile extends AbstractGetPMF { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.6-13 (GetPMFByFile) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPMFByFile.class); - } +public class GetPMFByFile extends AbstractGetPMF { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.6-13 (GetPMFByFile) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPMFByFile.class); + } - /** */ - public void testInvalidGetPMF() { - checkGetPMFWithInvalidProperties(ASSERTION_FAILED); - } + /** */ + public void testInvalidGetPMF() { + checkGetPMFWithInvalidProperties(ASSERTION_FAILED); + } - /** */ - public void testValidGetPMF() { - checkGetPMFWithValidProperties(); - } + /** */ + public void testValidGetPMF() { + checkGetPMFWithValidProperties(); + } - /** */ - protected PersistenceManagerFactory getPMF(String name) { - return JDOHelper.getPersistenceManagerFactory(new File(name)); - } + /** */ + protected PersistenceManagerFactory getPMF(String name) { + return JDOHelper.getPersistenceManagerFactory(new File(name)); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByFileAndClassLoader.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByFileAndClassLoader.java index 64503be54..ea8301597 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByFileAndClassLoader.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByFileAndClassLoader.java @@ -5,68 +5,81 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import java.io.File; + import javax.jdo.JDOHelper; import javax.jdo.PersistenceManagerFactory; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:GetPMFByFileAndClassLoader of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A8.6-14.
    - * Assertion Description: Uses the parameter(s) passed as arguments to construct a - * Properties instance, and then delegates to the static method getPersistenceManagerFactory in the - * class named in the property javax.jdo.PersistenceManagerFactoryClass. If there are any exceptions - * while trying to construct the Properties instance or to call the static method, then either - * A8.6-4 [JDOFatalUserException] or A8.6-5 [JDOFatalInternalException is thrown], depending on - * whether the exception is due to the user or the implementation. The nested exception indicates - * the cause of the exception. - * + *Title:GetPMFByFileAndClassLoader of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A8.6-14. + *
    + *Assertion Description: + * Uses the parameter(s) passed as arguments to construct a Properties + * instance, and then delegates to the static method + * getPersistenceManagerFactory in the class named in the property + * javax.jdo.PersistenceManagerFactoryClass. + * If there are any exceptions while trying to construct the Properties + * instance or to call the static method, + * then either A8.6-4 [JDOFatalUserException] or + * A8.6-5 [JDOFatalInternalException is thrown], + * depending on whether the exception is due to the user + * or the implementation. + * The nested exception indicates the cause of the exception. + * * @author Michael Watzek */ -public class GetPMFByFileAndClassLoader extends AbstractGetPMF { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.6-14 (GetPMFByFileAndClassLoader) failed: "; - - private static final String propertiesFileDoesNotExist = "FileDoesNotExist.properties"; - private static final String propertiesFileExists = System.getProperty("PMFProperties"); - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPMFByFileAndClassLoader.class); - } +public class GetPMFByFileAndClassLoader extends AbstractGetPMF { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.6-14 (GetPMFByFileAndClassLoader) failed: "; + + private static final String propertiesFileDoesNotExist = + "FileDoesNotExist.properties"; + private static final String propertiesFileExists = + System.getProperty("PMFProperties"); + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPMFByFileAndClassLoader.class); + } - /** */ - public void testInvalidGetPMF() { - checkGetPMFWithInvalidProperties(ASSERTION_FAILED); - } + /** */ + public void testInvalidGetPMF() { + checkGetPMFWithInvalidProperties(ASSERTION_FAILED); + } - /** */ - public void testValidGetPMF() { - checkGetPMFWithValidProperties(); - } + /** */ + public void testValidGetPMF() { + checkGetPMFWithValidProperties(); + } - /** */ - protected PersistenceManagerFactory getPMF(String name) { - return JDOHelper.getPersistenceManagerFactory( - new File(name), Thread.currentThread().getContextClassLoader()); - } + /** */ + protected PersistenceManagerFactory getPMF(String name) { + return JDOHelper.getPersistenceManagerFactory(new File(name), + Thread.currentThread().getContextClassLoader()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByJNDILocation.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByJNDILocation.java index d68b547d7..f9cd9ee69 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByJNDILocation.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByJNDILocation.java @@ -5,102 +5,116 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import java.io.File; + import javax.jdo.JDOFatalException; import javax.jdo.JDOHelper; import javax.jdo.PersistenceManagerFactory; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:GetPMFByJNDILocation of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A8.6-19.
    - * Assertion Description: Uses the parameter(s) passed as arguments to construct a - * Properties instance, and then delegates to the static method getPersistenceManagerFactory in the - * class named in the property javax.jdo.PersistenceManagerFactoryClass. If there are any exceptions - * while trying to construct the Properties instance or to call the static method, then either - * A8.6-4 [JDOFatalUserException] or A8.6-5 [JDOFatalInternalException is thrown], depending on - * whether the exception is due to the user or the implementation. The nested exception indicates - * the cause of the exception. - * + *Title:GetPMFByJNDILocation of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A8.6-19. + *
    + *Assertion Description: + * Uses the parameter(s) passed as arguments to construct a Properties + * instance, and then delegates to the static method + * getPersistenceManagerFactory in the class named in the property + * javax.jdo.PersistenceManagerFactoryClass. + * If there are any exceptions while trying to construct the Properties + * instance or to call the static method, + * then either A8.6-4 [JDOFatalUserException] or + * A8.6-5 [JDOFatalInternalException is thrown], + * depending on whether the exception is due to the user + * or the implementation. + * The nested exception indicates the cause of the exception. + * * @author Michael Watzek */ -public class GetPMFByJNDILocation extends AbstractGetPMF { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.6-19 (GetPMFByJNDILocation) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPMFByJNDILocation.class); - } +public class GetPMFByJNDILocation extends AbstractGetPMF { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.6-19 (GetPMFByJNDILocation) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPMFByJNDILocation.class); + } - /** */ - public void testInvalidGetPMF() { - if (SKIP_JNDI) { - logger.debug( - "Skipped test GetPMFByJNDILocation.testInvalidGetPMF because of jdo.tck.skipJndi."); - } else { - checkGetPMFWithInvalidProperties(ASSERTION_FAILED); + /** */ + public void testInvalidGetPMF() { + if (SKIP_JNDI) { + logger.debug( + "Skipped test GetPMFByJNDILocation.testInvalidGetPMF because of jdo.tck.skipJndi."); + } else { + checkGetPMFWithInvalidProperties(ASSERTION_FAILED); + } } - } - /** */ - public void testValidGetPMF() { - if (SKIP_JNDI) { - logger.debug( - "Skipped test GetPMFByJNDILocation.testValidGetPMF because of jdo.tck.skipJndi."); - } else { - checkGetPMFWithValidProperties(); + /** */ + public void testValidGetPMF() { + if (SKIP_JNDI) { + logger.debug( + "Skipped test GetPMFByJNDILocation.testValidGetPMF because of jdo.tck.skipJndi."); + } else { + checkGetPMFWithValidProperties(); + } } - } - /** */ - protected PersistenceManagerFactory getPMF(String name) { - Context context = null; - try { - // We need a JNDI context which contains a PMF instance. - // For this reason, we create a JNDI context, - // create a PMF instance and bind that to the context. - context = new InitialContext(); - if (name.equals(validPropertiesFile)) { - PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(new File(name)); - verifyProperties(pmf, loadProperties(validPropertiesFile)); - context.bind(jndiName, pmf); - } - return JDOHelper.getPersistenceManagerFactory(jndiName, context); - } catch (NamingException e) { - throw new JDOFatalException("Caught NamingException trying to bind " + e.getMessage(), e); - } finally { - if (context != null) { + /** */ + protected PersistenceManagerFactory getPMF(String name) { + Context context = null; try { - context.unbind(jndiName); - context.close(); + //We need a JNDI context which contains a PMF instance. + //For this reason, we create a JNDI context, + //create a PMF instance and bind that to the context. + context = new InitialContext(); + if (name.equals(validPropertiesFile)) { + PersistenceManagerFactory pmf = + JDOHelper.getPersistenceManagerFactory(new File(name)); + verifyProperties(pmf, loadProperties(validPropertiesFile)); + context.bind(jndiName, pmf); + } + return JDOHelper.getPersistenceManagerFactory(jndiName, context); } catch (NamingException e) { - fail("Caught NamingException trying to unbind or close." + e.getMessage()); - // stay quiet + throw new JDOFatalException("Caught NamingException trying to bind " + + e.getMessage(), e); + } finally { + if (context != null) { + try { + context.unbind(jndiName); + context.close(); + } catch (NamingException e) { + fail("Caught NamingException trying to unbind or close." + + e.getMessage()); + // stay quiet + } + } } - } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByJNDILocationAndClassLoader.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByJNDILocationAndClassLoader.java index 5c4bb396e..dbf631e19 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByJNDILocationAndClassLoader.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByJNDILocationAndClassLoader.java @@ -5,101 +5,113 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import java.io.File; + import javax.jdo.JDOFatalException; import javax.jdo.JDOHelper; import javax.jdo.PersistenceManagerFactory; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:GetPMFByJNDILocationAndClassLoader of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A8.6-20.
    - * Assertion Description: Uses the parameter(s) passed as arguments to construct a - * Properties instance, and then delegates to the static method getPersistenceManagerFactory in the - * class named in the property javax.jdo.PersistenceManagerFactoryClass. If there are any exceptions - * while trying to construct the Properties instance or to call the static method, then either - * A8.6-4 [JDOFatalUserException] or A8.6-5 [JDOFatalInternalException is thrown], depending on - * whether the exception is due to the user or the implementation. The nested exception indicates - * the cause of the exception. - * + *Title:GetPMFByJNDILocationAndClassLoader of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A8.6-20. + *
    + *Assertion Description: + * Uses the parameter(s) passed as arguments to construct a Properties + * instance, and then delegates to the static method + * getPersistenceManagerFactory in the class named in the property + * javax.jdo.PersistenceManagerFactoryClass. + * If there are any exceptions while trying to construct the Properties + * instance or to call the static method, + * then either A8.6-4 [JDOFatalUserException] or + * A8.6-5 [JDOFatalInternalException is thrown], + * depending on whether the exception is due to the user + * or the implementation. + * The nested exception indicates the cause of the exception. + * * @author Michael Watzek */ -public class GetPMFByJNDILocationAndClassLoader extends AbstractGetPMF { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.6-20 (GetPMFByJNDILocationAndClassLoader) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPMFByJNDILocationAndClassLoader.class); - } +public class GetPMFByJNDILocationAndClassLoader extends AbstractGetPMF { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.6-20 (GetPMFByJNDILocationAndClassLoader) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPMFByJNDILocationAndClassLoader.class); + } - /** */ - public void testInvalidGetPMF() { - if (SKIP_JNDI) { - logger.debug( - "Skipped test GetPMFByJNDILocationAndClassLoader.testInvalidGetPMF because of jdo.tck.skipJndi."); - } else { - checkGetPMFWithInvalidProperties(ASSERTION_FAILED); + /** */ + public void testInvalidGetPMF() { + if (SKIP_JNDI) { + logger.debug( + "Skipped test GetPMFByJNDILocationAndClassLoader.testInvalidGetPMF because of jdo.tck.skipJndi."); + } else { + checkGetPMFWithInvalidProperties(ASSERTION_FAILED); + } } - } - /** */ - public void testValidGetPMF() { - if (SKIP_JNDI) { - logger.debug( - "Skipped test GetPMFByJNDILocationAndClassLoader.testValidGetPMF because of jdo.tck.skipJndi."); - } else { - checkGetPMFWithValidProperties(); + /** */ + public void testValidGetPMF() { + if (SKIP_JNDI) { + logger.debug( + "Skipped test GetPMFByJNDILocationAndClassLoader.testValidGetPMF because of jdo.tck.skipJndi."); + } else { + checkGetPMFWithValidProperties(); + } } - } - /** */ - protected PersistenceManagerFactory getPMF(String name) { - Context context = null; - try { - // We need a JNDI context which contains a PMF instance. - // For this reason, we create a JNDI context, - // create a PMF instance and bind that to the context. - context = new InitialContext(); - if (name.equals(validPropertiesFile)) { - PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(new File(name)); - context.bind(jndiName, pmf); - } - return JDOHelper.getPersistenceManagerFactory( - jndiName, context, Thread.currentThread().getContextClassLoader()); - } catch (NamingException e) { - throw new JDOFatalException("", e); - } finally { - if (context != null) { + /** */ + protected PersistenceManagerFactory getPMF(String name) { + Context context = null; try { - context.unbind(jndiName); - context.close(); + //We need a JNDI context which contains a PMF instance. + //For this reason, we create a JNDI context, + //create a PMF instance and bind that to the context. + context = new InitialContext(); + if (name.equals(validPropertiesFile)) { + PersistenceManagerFactory pmf = + JDOHelper.getPersistenceManagerFactory(new File(name)); + context.bind(jndiName, pmf); + } + return JDOHelper.getPersistenceManagerFactory(jndiName, context, + Thread.currentThread().getContextClassLoader()); } catch (NamingException e) { - // stay quiet + throw new JDOFatalException("", e); + } finally { + if (context != null) { + try { + context.unbind(jndiName); + context.close(); + } catch (NamingException e) { + // stay quiet + } + } } - } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByResource.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByResource.java index 5205a6747..1a5e9b3e6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByResource.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByResource.java @@ -5,62 +5,73 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import javax.jdo.JDOHelper; import javax.jdo.PersistenceManagerFactory; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:GetPMFByResource of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A8.6-15.
    - * Assertion Description: Uses the parameter(s) passed as arguments to construct a - * Properties instance, and then delegates to the static method getPersistenceManagerFactory in the - * class named in the property javax.jdo.PersistenceManagerFactoryClass. If there are any exceptions - * while trying to construct the Properties instance or to call the static method, then either - * A8.6-4 [JDOFatalUserException] or A8.6-5 [JDOFatalInternalException is thrown], depending on - * whether the exception is due to the user or the implementation. The nested exception indicates - * the cause of the exception. - * + *Title:GetPMFByResource of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A8.6-15. + *
    + *Assertion Description: + * Uses the parameter(s) passed as arguments to construct a Properties + * instance, and then delegates to the static method + * getPersistenceManagerFactory in the class named in the property + * javax.jdo.PersistenceManagerFactoryClass. + * If there are any exceptions while trying to construct the Properties + * instance or to call the static method, + * then either A8.6-4 [JDOFatalUserException] or + * A8.6-5 [JDOFatalInternalException is thrown], + * depending on whether the exception is due to the user + * or the implementation. + * The nested exception indicates the cause of the exception. + * * @author Michael Watzek */ -public class GetPMFByResource extends AbstractGetPMF { - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.6-15 (GetPMFByResource) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPMFByResource.class); - } +public class GetPMFByResource extends AbstractGetPMF { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.6-15 (GetPMFByResource) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPMFByResource.class); + } - /** */ - public void testInvalidGetPMF() { - checkGetPMFWithInvalidProperties(ASSERTION_FAILED); - } + /** */ + public void testInvalidGetPMF() { + checkGetPMFWithInvalidProperties(ASSERTION_FAILED); + } - /** */ - public void testValidGetPMF() { - checkGetPMFWithValidProperties(); - } + /** */ + public void testValidGetPMF() { + checkGetPMFWithValidProperties(); + } - /** */ - protected PersistenceManagerFactory getPMF(String name) { - return JDOHelper.getPersistenceManagerFactory(removePathPrefix(name)); - } + /** */ + protected PersistenceManagerFactory getPMF(String name) { + return JDOHelper.getPersistenceManagerFactory(removePathPrefix(name)); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByResourceAndClassLoader.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByResourceAndClassLoader.java index 501f15983..a54d988ae 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByResourceAndClassLoader.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByResourceAndClassLoader.java @@ -5,64 +5,74 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import javax.jdo.JDOHelper; import javax.jdo.PersistenceManagerFactory; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:GetPMFByResourceAndClassLoader of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A8.6-16.
    - * Assertion Description: Uses the parameter(s) passed as arguments to construct a - * Properties instance, and then delegates to the static method getPersistenceManagerFactory in the - * class named in the property javax.jdo.PersistenceManagerFactoryClass. If there are any exceptions - * while trying to construct the Properties instance or to call the static method, then either - * A8.6-4 [JDOFatalUserException] or A8.6-5 [JDOFatalInternalException is thrown], depending on - * whether the exception is due to the user or the implementation. The nested exception indicates - * the cause of the exception. - * + *Title:GetPMFByResourceAndClassLoader of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A8.6-16. + *
    + *Assertion Description: + * Uses the parameter(s) passed as arguments to construct a Properties + * instance, and then delegates to the static method + * getPersistenceManagerFactory in the class named in the property + * javax.jdo.PersistenceManagerFactoryClass. + * If there are any exceptions while trying to construct the Properties + * instance or to call the static method, + * then either A8.6-4 [JDOFatalUserException] or + * A8.6-5 [JDOFatalInternalException is thrown], + * depending on whether the exception is due to the user + * or the implementation. + * The nested exception indicates the cause of the exception. + * * @author Michael Watzek */ -public class GetPMFByResourceAndClassLoader extends AbstractGetPMF { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.6-16 (GetPMFByResourceAndClassLoader) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPMFByResourceAndClassLoader.class); - } +public class GetPMFByResourceAndClassLoader extends AbstractGetPMF { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.6-16 (GetPMFByResourceAndClassLoader) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPMFByResourceAndClassLoader.class); + } - /** */ - public void testInvalidGetPMF() { - checkGetPMFWithInvalidProperties(ASSERTION_FAILED); - } + /** */ + public void testInvalidGetPMF() { + checkGetPMFWithInvalidProperties(ASSERTION_FAILED); + } - /** */ - public void testValidGetPMF() { - checkGetPMFWithValidProperties(); - } + /** */ + public void testValidGetPMF() { + checkGetPMFWithValidProperties(); + } - /** */ - protected PersistenceManagerFactory getPMF(String name) { - return JDOHelper.getPersistenceManagerFactory( - removePathPrefix(name), Thread.currentThread().getContextClassLoader()); - } + /** */ + protected PersistenceManagerFactory getPMF(String name) { + return JDOHelper.getPersistenceManagerFactory(removePathPrefix(name), + Thread.currentThread().getContextClassLoader()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByStream.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByStream.java index b79331e2f..40d721210 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByStream.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByStream.java @@ -5,79 +5,91 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; + import javax.jdo.JDOHelper; import javax.jdo.PersistenceManagerFactory; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:GetPMFByStream of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A8.6-17.
    - * Assertion Description: Uses the parameter(s) passed as arguments to construct a - * Properties instance, and then delegates to the static method getPersistenceManagerFactory in the - * class named in the property javax.jdo.PersistenceManagerFactoryClass. If there are any exceptions - * while trying to construct the Properties instance or to call the static method, then either - * A8.6-4 [JDOFatalUserException] or A8.6-5 [JDOFatalInternalException is thrown], depending on - * whether the exception is due to the user or the implementation. The nested exception indicates - * the cause of the exception. - * + *Title:GetPMFByStream of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A8.6-17. + *
    + *Assertion Description: + * Uses the parameter(s) passed as arguments to construct a Properties + * instance, and then delegates to the static method + * getPersistenceManagerFactory in the class named in the property + * javax.jdo.PersistenceManagerFactoryClass. + * If there are any exceptions while trying to construct the Properties + * instance or to call the static method, + * then either A8.6-4 [JDOFatalUserException] or + * A8.6-5 [JDOFatalInternalException is thrown], + * depending on whether the exception is due to the user + * or the implementation. + * The nested exception indicates the cause of the exception. + * * @author Michael Watzek */ -public class GetPMFByStream extends AbstractGetPMF { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A8.6-17 (GetPMFByStream) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPMFByStream.class); - } +public class GetPMFByStream extends AbstractGetPMF { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.6-17 (GetPMFByStream) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPMFByStream.class); + } - /** */ - public void testInvalidGetPMF() { - checkGetPMFWithInvalidProperties(ASSERTION_FAILED); - } + /** */ + public void testInvalidGetPMF() { + checkGetPMFWithInvalidProperties(ASSERTION_FAILED); + } - /** */ - public void testValidGetPMF() { - checkGetPMFWithValidProperties(); - } + /** */ + public void testValidGetPMF() { + checkGetPMFWithValidProperties(); + } - /** */ - protected PersistenceManagerFactory getPMF(String name) { - FileInputStream stream = null; - try { - stream = new FileInputStream(name); - return JDOHelper.getPersistenceManagerFactory(stream); - } catch (FileNotFoundException e) { - throw new RuntimeException("", e); - } finally { - if (stream != null) { + /** */ + protected PersistenceManagerFactory getPMF(String name) { + FileInputStream stream = null; try { - stream.close(); - } catch (IOException e) { - throw new RuntimeException(e); + stream = new FileInputStream(name); + return JDOHelper.getPersistenceManagerFactory(stream); + } catch (FileNotFoundException e) { + throw new RuntimeException("", e); + } finally { + if (stream != null) { + try { + stream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } } - } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByStreamAndClassLoader.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByStreamAndClassLoader.java index a2ef87c7c..75fb894a7 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByStreamAndClassLoader.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPMFByStreamAndClassLoader.java @@ -5,81 +5,92 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; + import javax.jdo.JDOHelper; import javax.jdo.PersistenceManagerFactory; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:GetPMFByStreamAndClassLoader of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A8.6-18.
    - * Assertion Description: Uses the parameter(s) passed as arguments to construct a - * Properties instance, and then delegates to the static method getPersistenceManagerFactory in the - * class named in the property javax.jdo.PersistenceManagerFactoryClass. If there are any exceptions - * while trying to construct the Properties instance or to call the static method, then either - * A8.6-4 [JDOFatalUserException] or A8.6-5 [JDOFatalInternalException is thrown], depending on - * whether the exception is due to the user or the implementation. The nested exception indicates - * the cause of the exception. - * + *Title:GetPMFByStreamAndClassLoader of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A8.6-18. + *
    + *Assertion Description: + * Uses the parameter(s) passed as arguments to construct a Properties + * instance, and then delegates to the static method + * getPersistenceManagerFactory in the class named in the property + * javax.jdo.PersistenceManagerFactoryClass. + * If there are any exceptions while trying to construct the Properties + * instance or to call the static method, + * then either A8.6-4 [JDOFatalUserException] or + * A8.6-5 [JDOFatalInternalException is thrown], + * depending on whether the exception is due to the user + * or the implementation. + * The nested exception indicates the cause of the exception. + * * @author Michael Watzek */ -public class GetPMFByStreamAndClassLoader extends AbstractGetPMF { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A8.6-18 (GetPMFByStreamAndClassLoader) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPMFByStreamAndClassLoader.class); - } +public class GetPMFByStreamAndClassLoader extends AbstractGetPMF { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A8.6-18 (GetPMFByStreamAndClassLoader) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPMFByStreamAndClassLoader.class); + } - /** */ - public void testInvalidGetPMF() { - checkGetPMFWithInvalidProperties(ASSERTION_FAILED); - } + /** */ + public void testInvalidGetPMF() { + checkGetPMFWithInvalidProperties(ASSERTION_FAILED); + } - /** */ - public void testValidGetPMF() { - checkGetPMFWithValidProperties(); - } + /** */ + public void testValidGetPMF() { + checkGetPMFWithValidProperties(); + } - /** */ - protected PersistenceManagerFactory getPMF(String name) { - FileInputStream stream = null; - try { - stream = new FileInputStream(name); - return JDOHelper.getPersistenceManagerFactory( - stream, Thread.currentThread().getContextClassLoader()); - } catch (FileNotFoundException e) { - throw new RuntimeException("", e); - } finally { - if (stream != null) { + /** */ + protected PersistenceManagerFactory getPMF(String name) { + FileInputStream stream = null; try { - stream.close(); - } catch (IOException e) { - throw new RuntimeException(e); + stream = new FileInputStream(name); + return JDOHelper.getPersistenceManagerFactory(stream, + Thread.currentThread().getContextClassLoader()); + } catch (FileNotFoundException e) { + throw new RuntimeException("", e); + } finally { + if (stream != null) { + try { + stream.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } } - } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManager.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManager.java index afe876942..b34d5eafa 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManager.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManager.java @@ -5,58 +5,67 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import javax.jdo.PersistenceManager; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:GetPersistenceManager of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.3-1.
    - * Assertion Description: PersistenceManagerFactory.getPersistenceManager() returns a - * PersistenceManager instance with the configured properties and the default values for option - * settings. + *Title:GetPersistenceManager of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.3-1. + *
    + *Assertion Description: + * PersistenceManagerFactory.getPersistenceManager() returns a + * PersistenceManager instance with the configured properties and the + * default values for option settings. */ -public class GetPersistenceManager extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A11.3-1 (GetPersistenceManager) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPersistenceManager.class); - } +public class GetPersistenceManager extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.3-1 (GetPersistenceManager) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPersistenceManager.class); + } - /** */ - public void test() { - PersistenceManager pm = null; - try { - pm = pmf.getPersistenceManager(); - if (pm == null) { - fail(ASSERTION_FAILED, "pmf.getPersistenceManager should " + "return a non-null value."); - } - } finally { - if ((pm != null) && !pm.isClosed()) { - pm.close(); - } - closePMF(); + /** */ + public void test() { + PersistenceManager pm = null; + try { + pm = pmf.getPersistenceManager(); + if (pm == null) { + fail(ASSERTION_FAILED, "pmf.getPersistenceManager should " + + "return a non-null value."); + } + } + finally { + if ((pm != null) && !pm.isClosed()) { + pm.close(); + } + closePMF(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerFactoryByPropertiesInstance.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerFactoryByPropertiesInstance.java index 763c66398..89d252fcc 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerFactoryByPropertiesInstance.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerFactoryByPropertiesInstance.java @@ -5,70 +5,79 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import java.util.Date; + import javax.jdo.JDOHelper; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.Address; import org.apache.jdo.tck.pc.company.Company; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:Close of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.1-32
    - * Assertion Description: An implementation must provide a method to construct a - * PersistenceManagerFactory by a Properties instance. This static method is called by the JDOHelper - * method getPersistenceManagerFactory (Properties props). + *Title:Close of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.1-32 + *
    + *Assertion Description: + * An implementation must provide a method to construct a + * PersistenceManagerFactory by a Properties instance. This static method is + * called by the JDOHelper method getPersistenceManagerFactory (Properties + * props). */ -public class GetPersistenceManagerFactoryByPropertiesInstance extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertions A11.1-32 (GetPersistenceManagerFactoryByPropertiesInstance) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPersistenceManagerFactoryByPropertiesInstance.class); - } +public class GetPersistenceManagerFactoryByPropertiesInstance extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertions A11.1-32 (GetPersistenceManagerFactoryByPropertiesInstance) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPersistenceManagerFactoryByPropertiesInstance.class); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(Company.class); - PMFPropertiesObject = loadProperties(PMFProperties); - pmf = JDOHelper.getPersistenceManagerFactory(PMFPropertiesObject); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(Company.class); + PMFPropertiesObject = loadProperties(PMFProperties); + pmf = JDOHelper.getPersistenceManagerFactory(PMFPropertiesObject); + } - /** */ - public void test() { - // Try to get a PersistenceManager and begin and commit a transaction - pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - Company comp = - new Company(1L, "Sun Microsystems", new Date(), new Address(0, "", "", "", "", "")); - pm.makePersistent(comp); - tx.commit(); - pm.close(); - pm = null; - } + /** */ + public void test() { + //Try to get a PersistenceManager and begin and commit a transaction + pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + Company comp = new Company(1L, "Sun Microsystems", new Date(), + new Address(0,"","","","","")); + pm.makePersistent(comp); + tx.commit(); + pm.close(); + pm = null; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerForUser.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerForUser.java index 56bc2ce70..0201cd4a3 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerForUser.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerForUser.java @@ -5,76 +5,86 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import java.util.Properties; + import javax.jdo.JDOHelper; import javax.jdo.PersistenceManager; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:GetPersistenceManagerForUser of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.3-2.
    - * Assertion Description: PersistenceManagerFactory.getPersistenceManager(String userid, - * String password) returns a PersistenceManager instance with the configured properties and the - * default values for option settings. + *Title:GetPersistenceManagerForUser of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.3-2. + *
    + *Assertion Description: + * PersistenceManagerFactory.getPersistenceManager(String userid, + * String password) returns a PersistenceManager instance with the + * configured properties and the default values for option settings. */ -public class GetPersistenceManagerForUser extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A11.3-2 (GetPersistenceManagerForUser) failed: "; - - /** The value of the ConnectionUserName property. */ - private String username; +public class GetPersistenceManagerForUser extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.3-2 (GetPersistenceManagerForUser) failed: "; + + /** The value of the ConnectionUserName property. */ + private String username; - /** The value of the ConnectionPassword property. */ - private String password; + /** The value of the ConnectionPassword property. */ + private String password; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPersistenceManagerForUser.class); - } + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPersistenceManagerForUser.class); + } - /** */ - protected void localSetUp() { - Properties props = loadProperties(PMFProperties); - username = (String) props.remove(CONNECTION_USERNAME_PROP); - password = (String) props.remove(CONNECTION_PASSWORD_PROP); - pmf = JDOHelper.getPersistenceManagerFactory(props); - } + /** */ + protected void localSetUp() { + Properties props = loadProperties(PMFProperties); + username = (String)props.remove(CONNECTION_USERNAME_PROP); + password = (String)props.remove(CONNECTION_PASSWORD_PROP); + pmf = JDOHelper.getPersistenceManagerFactory(props); + } - /** */ - public void test() { - PersistenceManager pm = null; - try { - pm = pmf.getPersistenceManager(username, password); - if (pm == null) { - fail( - ASSERTION_FAILED, - "pmf.getPersistenceManager(user, password) should " + "return a non-null value."); - } - } finally { - if ((pm != null) && !pm.isClosed()) { - pm.close(); - } - closePMF(); + /** */ + public void test() { + PersistenceManager pm = null; + try { + pm = pmf.getPersistenceManager(username, password); + if (pm == null) { + fail(ASSERTION_FAILED, + "pmf.getPersistenceManager(user, password) should " + + "return a non-null value."); + } + } + finally { + if ((pm != null) && !pm.isClosed()) { + pm.close(); + } + closePMF(); + } } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetProperties.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetProperties.java index e2bb6e449..d35a683af 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetProperties.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetProperties.java @@ -5,63 +5,74 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import java.util.Enumeration; import java.util.Properties; + import javax.jdo.PersistenceManagerFactory; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:Get properties of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.4-1.
    - * Assertion Description: PersistenceManagerFactory.getProperties() returns a Properties - * instance containing two standard JDO implementation properties VendorName: The name of the JDO - * vendor. VersionNumber: The version number string. + *Title:Get properties of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.4-1. + *
    + *Assertion Description: + PersistenceManagerFactory.getProperties() returns a Properties instance + containing two standard JDO implementation properties + VendorName: The name of the JDO vendor. + VersionNumber: The version number string. */ -public class GetProperties extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A11.4-1 (GetProperties) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetProperties.class); - } - - /** */ - public void test() { - PersistenceManagerFactory pmf = getPMF(); - int foundStandardProperties = 0; - - Properties p = pmf.getProperties(); - for (Enumeration e = p.propertyNames(); e.hasMoreElements(); ) { - String s = (String) e.nextElement(); - if (debug) logger.debug("\t" + s + ": " + p.getProperty(s)); - - if (s.equals("VendorName") || s.equals("VersionNumber")) { - foundStandardProperties++; - } +public class GetProperties extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.4-1 (GetProperties) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetProperties.class); } - if (foundStandardProperties != 2) { - fail(ASSERTION_FAILED, "Standard properties not found."); - } - } + /** */ + public void test() { + PersistenceManagerFactory pmf = getPMF(); + int foundStandardProperties = 0; + + Properties p = pmf.getProperties(); + for (Enumeration e = p.propertyNames(); e.hasMoreElements(); ) { + String s = (String) e.nextElement(); + if (debug) logger.debug ("\t" + s + ": " + p.getProperty(s)); + + if (s.equals("VendorName") || s.equals("VersionNumber")) { + foundStandardProperties++; + } + } + + if (foundStandardProperties != 2) { + fail(ASSERTION_FAILED, + "Standard properties not found."); + } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionPassword.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionPassword.java index 086bfdc4c..70ec0c562 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionPassword.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionPassword.java @@ -5,59 +5,67 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:Set ConnectionPassword of persistencemanagerfactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.1-15.
    - * Assertion Description: PersistenceManagerFactory.setConnectionPassword(String password) - * sets the value of the ConnectionPassword property (the password for the user) + *Title:Set ConnectionPassword of persistencemanagerfactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.1-15. + *
    + *Assertion Description: + * PersistenceManagerFactory.setConnectionPassword(String password) sets the + * value of the ConnectionPassword property (the password for the user) */ -public class SetConnectionPassword extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A11.1-15 (SetConnectionPassword) failed: "; - /** The value of the ConnectionPassword property. */ - private String password; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetConnectionPassword.class); - } +public class SetConnectionPassword extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.1-15 (SetConnectionPassword) failed: "; + + /** The value of the ConnectionPassword property. */ + private String password; - /** */ - protected void localSetUp() { - closePMF(); - pmf = getUnconfiguredPMF(); - password = getPMFProperty(CONNECTION_PASSWORD_PROP); - } + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetConnectionPassword.class); + } - /** Set ConnectionPassword. */ - public void test() { - try { - pmf.setConnectionPassword(password); - } finally { - closePMF(); + /** */ + protected void localSetUp() { + closePMF(); + pmf = getUnconfiguredPMF(); + password = getPMFProperty(CONNECTION_PASSWORD_PROP); + } + + /** + * Set ConnectionPassword. + */ + public void test() { + try { + pmf.setConnectionPassword(password); + } finally { + closePMF(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionURL.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionURL.java index 678e267f9..ce7025725 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionURL.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionURL.java @@ -5,74 +5,79 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import javax.jdo.JDOException; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:Set ConnectionURL of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.1-16,A11.1-17.
    - * Assertion Description: PersistenceManagerFactory.setConnectionURL(String URL) sets the - * value of the ConnectionURL property (the URL for the data source). - * PersistenceManagerFactory.getConnectionURL() returns the value of the ConnectionURL property. + *Title:Set ConnectionURL of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.1-16,A11.1-17. + *
    + *Assertion Description: + * PersistenceManagerFactory.setConnectionURL(String URL) sets the value of + * the ConnectionURL property (the URL for the data source). + * PersistenceManagerFactory.getConnectionURL() returns the value of the + * ConnectionURL property. */ -public class SetConnectionURL extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A11.1-16,A11.1-17 (SetConnectionURL) failed: "; - /** The value of the ConnectionURL property. */ - private String url; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetConnectionURL.class); - } +public class SetConnectionURL extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.1-16,A11.1-17 (SetConnectionURL) failed: "; + + /** The value of the ConnectionURL property. */ + private String url; - /** */ - protected void localSetUp() { - closePMF(); - pmf = getUnconfiguredPMF(); - url = getPMFProperty(CONNECTION_URL_PROP); - } + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetConnectionURL.class); + } - /** Set ConnectionURL value and get ConnectionURL value to verify. */ - public void test() { - try { - if (url == null) { - throw new JDOException("Missing PMF property " + CONNECTION_URL_PROP); - } - pmf.setConnectionURL(url); - if (!url.equals(pmf.getConnectionURL())) { - fail( - ASSERTION_FAILED, - "ConnectionURL set to '" - + url - + "' ," - + "value returned by PMF is '" - + pmf.getConnectionURL() - + "'."); - } - } finally { - closePMF(); + /** */ + protected void localSetUp() { + closePMF(); + pmf = getUnconfiguredPMF(); + url = getPMFProperty(CONNECTION_URL_PROP); + } + + /** Set ConnectionURL value and get ConnectionURL value to verify. */ + public void test() { + try { + if (url == null) { + throw new JDOException( + "Missing PMF property " + CONNECTION_URL_PROP); + } + pmf.setConnectionURL(url); + if (!url.equals(pmf.getConnectionURL())) { + fail(ASSERTION_FAILED, + "ConnectionURL set to '" + url + "' ," + + "value returned by PMF is '" + + pmf.getConnectionURL() + "'."); + } + } finally { + closePMF(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionUserName.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionUserName.java index 6dfcac6bc..16e060c19 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionUserName.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionUserName.java @@ -5,74 +5,84 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import javax.jdo.JDOException; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:Set ConnectionUserName of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.1-13,A11.1-14.
    - * Assertion Description: PersistenceManagerFactory.setConnectionUserName(String name) sets - * the value of the ConnectionUserName property (the name of the user establishing the connection). + *Title:Set ConnectionUserName of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.1-13,A11.1-14. + *
    + *Assertion Description: + * PersistenceManagerFactory.setConnectionUserName(String name) sets the value + * of the ConnectionUserName property (the name of the user establishing the + * connection). */ -public class SetConnectionUserName extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertions A11.1-13,A11.1-14 (SetConnectionUserName) failed: "; - /** The value of the ConnectionUserName property. */ - private String username; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetConnectionUserName.class); - } +public class SetConnectionUserName extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertions A11.1-13,A11.1-14 (SetConnectionUserName) failed: "; + + /** The value of the ConnectionUserName property. */ + private String username; - /** */ - protected void localSetUp() { - closePMF(); - pmf = getUnconfiguredPMF(); - username = getPMFProperty(CONNECTION_USERNAME_PROP); - } + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetConnectionUserName.class); + } - /** Set ConnectionUserName value and get ConnectionUserName value to verify. */ - public void test() { - try { - if (username == null) { - throw new JDOException("Missing PMF property " + CONNECTION_USERNAME_PROP); - } - pmf.setConnectionUserName(username); - if (!username.equals(pmf.getConnectionUserName())) { - fail( - ASSERTION_FAILED, - "ConnectionUserName set to '" - + username - + "' ," - + "value returned by PMF is '" - + pmf.getConnectionUserName() - + "'."); - } - } catch (Exception ex) { - fail(ASSERTION_FAILED, "Failed in setting ConnectionUserName " + ex); + /** */ + protected void localSetUp() { + closePMF(); + pmf = getUnconfiguredPMF(); + username = getPMFProperty(CONNECTION_USERNAME_PROP); + } + + /** + * Set ConnectionUserName value and get ConnectionUserName value to verify. + */ + public void test() { + try { + if (username == null) { + throw new JDOException( + "Missing PMF property " + CONNECTION_USERNAME_PROP); + } + pmf.setConnectionUserName(username); + if (!username.equals(pmf.getConnectionUserName())) { + fail(ASSERTION_FAILED, + "ConnectionUserName set to '" + username + "' ," + + "value returned by PMF is '" + + pmf.getConnectionUserName() + "'."); + } + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "Failed in setting ConnectionUserName " + ex); + } + if (debug) + logger.debug("ConnectionUserName: " + pmf.getConnectionUserName()); } - if (debug) logger.debug("ConnectionUserName: " + pmf.getConnectionUserName()); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetIgnoreCache.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetIgnoreCache.java index fb17e7c47..fef077f28 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetIgnoreCache.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetIgnoreCache.java @@ -5,67 +5,76 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; +import javax.jdo.PersistenceManagerFactory; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:Set IgnoreCache of persistencemanagerfactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.1-5.
    - * Assertion Description: PersistenceManagerFactory.setIgnoreCache(boolean flag) sets the - * value of the IgnoreCache property (the query mode that specifies whether cached instances are - * considered when evaluating the filter expression). + *Title:Set IgnoreCache of persistencemanagerfactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.1-5. + *
    + *Assertion Description: + * PersistenceManagerFactory.setIgnoreCache(boolean flag) sets the value of + * the IgnoreCache property (the query mode that specifies whether cached + * instances are considered when evaluating the filter expression). */ -public class SetIgnoreCache extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A11.1-5 (SetIgnoreCache) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetIgnoreCache.class); - } +public class SetIgnoreCache extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.1-5 (SetIgnoreCache) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetIgnoreCache.class); + } - /** */ - protected void localSetUp() { - closePMF(); - pmf = getUnconfiguredPMF(); - } + /** */ + protected void localSetUp() { + closePMF(); + pmf = getUnconfiguredPMF(); + } - /** Set IgnoreCache to true or false and use getIgnoreCache value to verify. */ - public void test() { - try { - setIgnoreCache(false); - setIgnoreCache(true); - } finally { - closePMF(); + /** + * Set IgnoreCache to true or false and use getIgnoreCache value to verify. + */ + public void test() { + try { + setIgnoreCache(false); + setIgnoreCache(true); + } finally { + closePMF(); + } } - } - /** */ - private void setIgnoreCache(boolean newValue) { - pmf.setIgnoreCache(newValue); - boolean current = pmf.getIgnoreCache(); - if (current != newValue) { - fail( - ASSERTION_FAILED, - "IgnoreCache set to " + newValue + ", value returned by PMF is " + current); + /** */ + private void setIgnoreCache(boolean newValue) { + pmf.setIgnoreCache(newValue); + boolean current = pmf.getIgnoreCache(); + if (current != newValue) { + fail(ASSERTION_FAILED, "IgnoreCache set to " + newValue + + ", value returned by PMF is " + current); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetMultithreaded.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetMultithreaded.java index 9af3964fa..1f92c2c79 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetMultithreaded.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetMultithreaded.java @@ -5,68 +5,81 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; +import java.util.Properties; + +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:Set Multithreaded of persistencemanagerfactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.1-11,A11.1-12.
    - * Assertion Description: PersistenceManagerFactory.setMultithreaded(boolean flag) sets the - * value of the Multithreaded flag that indicates that the application will invoke methods or access - * fields of managed instances from multiple threads. + *Title:Set Multithreaded of persistencemanagerfactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.1-11,A11.1-12. + *
    + *Assertion Description: + * PersistenceManagerFactory.setMultithreaded(boolean flag) sets the value of + * the Multithreaded flag that indicates that the application will invoke + * methods or access fields of managed instances from multiple threads. */ -public class SetMultithreaded extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertions A11.1-11,A11.1-12 (SetMultithreaded) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetMultithreaded.class); - } +public class SetMultithreaded extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertions A11.1-11,A11.1-12 (SetMultithreaded) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetMultithreaded.class); + } - /** */ - protected void localSetUp() { - closePMF(); - pmf = getUnconfiguredPMF(); - } + /** */ + protected void localSetUp() { + closePMF(); + pmf = getUnconfiguredPMF(); + } - /** Set Multithreaded to true or false and use getMultithreaded value to verify. */ - public void test() { - try { - setMultithreaded(false); - setMultithreaded(true); - } finally { - closePMF(); + /** + * Set Multithreaded to true or false and use getMultithreaded value to + * verify. + */ + public void test() { + try { + setMultithreaded(false); + setMultithreaded(true); + } finally { + closePMF(); + } } - } - /** */ - private void setMultithreaded(boolean newValue) { - pmf.setMultithreaded(newValue); - boolean current = pmf.getMultithreaded(); - if (current != newValue) { - fail( - ASSERTION_FAILED, - "Multithreaded set to " + newValue + ", value returned by PMF is " + current); + /** */ + private void setMultithreaded(boolean newValue) { + pmf.setMultithreaded(newValue); + boolean current = pmf.getMultithreaded(); + if (current != newValue) { + fail(ASSERTION_FAILED, "Multithreaded set to " + newValue + + ", value returned by PMF is " + current); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalRead.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalRead.java index 458d3f8e3..2b1dab683 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalRead.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalRead.java @@ -5,68 +5,78 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; +import javax.jdo.PersistenceManagerFactory; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:Set NonTransactionalRead of persistencemanagerfactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.1-7,A11.1-8.
    - * Assertion Description: PersistenceManagerFactory.setNontransactionalRead(boolean flag) - * sets the value of the NontransactionalRead property (the PersistenceManager mode that allows - * instances to be read outside a transaction). + *Title:Set NonTransactionalRead of persistencemanagerfactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.1-7,A11.1-8. + *
    + *Assertion Description: + * PersistenceManagerFactory.setNontransactionalRead(boolean flag) sets the + * value of the NontransactionalRead property (the PersistenceManager mode + * that allows instances to be read outside a transaction). */ -public class SetNonTransactionalRead extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertions A11.1-7,A11.1-8 (SetNonTransactionalRead) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetNonTransactionalRead.class); - } +public class SetNonTransactionalRead extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertions A11.1-7,A11.1-8 (SetNonTransactionalRead) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetNonTransactionalRead.class); + } - /** */ - protected void localSetUp() { - closePMF(); - pmf = getUnconfiguredPMF(); - } + /** */ + protected void localSetUp() { + closePMF(); + pmf = getUnconfiguredPMF(); + } - /** Set NonTransactionalRead to true or false and use getNonTransactionalRead value to verify. */ - public void test() { - try { - setNontransactionalRead(false); - setNontransactionalRead(true); - } finally { - closePMF(); + /** + * Set NonTransactionalRead to true or false and use + * getNonTransactionalRead value to verify. + */ + public void test() { + try { + setNontransactionalRead(false); + setNontransactionalRead(true); + } finally { + closePMF(); + } } - } - /** */ - private void setNontransactionalRead(boolean newValue) { - pmf.setNontransactionalRead(newValue); - boolean current = pmf.getNontransactionalRead(); - if (current != newValue) { - fail( - ASSERTION_FAILED, - "NonTransactionalRead set to " + newValue + ", value returned by PMF is " + current); + /** */ + private void setNontransactionalRead(boolean newValue) { + pmf.setNontransactionalRead(newValue); + boolean current = pmf.getNontransactionalRead(); + if (current != newValue) { + fail(ASSERTION_FAILED, "NonTransactionalRead set to " + newValue + + ", value returned by PMF is " + current); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalWrite.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalWrite.java index aad5b5fd1..739cbbc76 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalWrite.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalWrite.java @@ -5,77 +5,84 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; +import javax.jdo.PersistenceManagerFactory; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:Set NonTransactionalWrite of persistencemanagerfactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.1-9,A11.1-10.
    - * Assertion Description: PersistenceManagerFactory.setNontransactionalWrite(boolean flag) - * sets the value of the NontransactionalWrite property (the PersistenceManager mode that allows - * instances to be written outside a transaction). + *Title:Set NonTransactionalWrite of persistencemanagerfactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.1-9,A11.1-10. + *
    + *Assertion Description: + * PersistenceManagerFactory.setNontransactionalWrite(boolean flag) sets the + * value of the NontransactionalWrite property (the PersistenceManager mode + * that allows instances to be written outside a transaction). */ -public class SetNonTransactionalWrite extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertions A11.1-9,A11.1-10 (SetNonTransactionalWrite) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetNonTransactionalWrite.class); - } - - /** */ - protected void localSetUp() { - closePMF(); - pmf = getUnconfiguredPMF(); - } +public class SetNonTransactionalWrite extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertions A11.1-9,A11.1-10 (SetNonTransactionalWrite) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetNonTransactionalWrite.class); + } - /** - * Set NonTransactionalWrite to true or false and use getNonTransactionalWrite value to verify. - */ - public void test() { - if (!isNontransactionalWriteSupported()) { - printUnsupportedOptionalFeatureNotTested( - "org.apache.jdo.tck.api.persistencemanagerfactory.SetNonTransactionalWrite", - "javax.jdo.option.NontransactionalWrite"); - return; + /** */ + protected void localSetUp() { + closePMF(); + pmf = getUnconfiguredPMF(); } - try { - setNontransactionalWrite(false); - setNontransactionalWrite(true); - } finally { - closePMF(); + /** Set NonTransactionalWrite to true or false and use + * getNonTransactionalWrite value to verify. + */ + public void test () { + if (!isNontransactionalWriteSupported()) { + printUnsupportedOptionalFeatureNotTested( + "org.apache.jdo.tck.api.persistencemanagerfactory.SetNonTransactionalWrite", + "javax.jdo.option.NontransactionalWrite"); + return; + } + + try { + setNontransactionalWrite(false); + setNontransactionalWrite(true); + } finally { + closePMF(); + } } - } - /** */ - private void setNontransactionalWrite(boolean newValue) { - pmf.setNontransactionalWrite(newValue); - boolean current = pmf.getNontransactionalWrite(); - if (current != newValue) { - fail( - ASSERTION_FAILED, - "NonTransactionalWrite set to " + newValue + ", value returned by PMF is " + current); + /** */ + private void setNontransactionalWrite(boolean newValue) { + pmf.setNontransactionalWrite(newValue); + boolean current = pmf.getNontransactionalWrite(); + if (current != newValue) { + fail(ASSERTION_FAILED, "NonTransactionalWrite set to " + newValue + + ", value returned by PMF is " + current); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetOptimistic.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetOptimistic.java index b641f6917..065489e08 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetOptimistic.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetOptimistic.java @@ -5,75 +5,81 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:Set optimistic of persistencemanagerfactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.1-1, A11.1-2.
    - * Assertion Description: PersistenceManagerFactory.getOptimistic() returns Value of the - * Optimistic property,persistenceManagerFactory.setOptimistic(boolean flag) sets the value of the - * Optimistic property (the transaction mode that specifies concurrency control. + *Title:Set optimistic of persistencemanagerfactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.1-1, A11.1-2. + *
    + *Assertion Description: + * PersistenceManagerFactory.getOptimistic() returns Value of the Optimistic + * property,persistenceManagerFactory.setOptimistic(boolean flag) sets the + * value of the Optimistic property (the transaction mode that specifies + * concurrency control. */ -public class SetOptimistic extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A11.1-1, A11.1-2 (SetOptimistic) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetOptimistic.class); - } - - /** */ - protected void localSetUp() { - closePMF(); - pmf = getUnconfiguredPMF(); - } +public class SetOptimistic extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.1-1, A11.1-2 (SetOptimistic) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetOptimistic.class); + } - /** Set Optimistic to true or false and use getOptimistic value to verify. */ - public void test() { - if (!isOptimisticSupported()) { - printUnsupportedOptionalFeatureNotTested( - "org.apache.jdo.tck.api.persistencemanagerfactory.SetOptimistic", - "javax.jdo.option.Optimistic"); - return; + /** */ + protected void localSetUp() { + closePMF(); + pmf = getUnconfiguredPMF(); } - try { - setOptimistic(false); - setOptimistic(true); - } finally { - closePMF(); + /** Set Optimistic to true or false and use getOptimistic value to verify. */ + public void test() { + if (!isOptimisticSupported()) { + printUnsupportedOptionalFeatureNotTested( + "org.apache.jdo.tck.api.persistencemanagerfactory.SetOptimistic", + "javax.jdo.option.Optimistic"); + return; + } + + try { + setOptimistic(false); + setOptimistic(true); + } finally { + closePMF(); + } } - } - /** */ - private void setOptimistic(boolean newValue) { - pmf.setOptimistic(newValue); - boolean optimistic = pmf.getOptimistic(); - if (optimistic != newValue) { - fail( - ASSERTION_FAILED, - "Optimistic set to " + newValue + ", value returned by PMF is " + optimistic); + /** */ + private void setOptimistic(boolean newValue) { + pmf.setOptimistic(newValue); + boolean optimistic = pmf.getOptimistic(); + if (optimistic != newValue) { + fail(ASSERTION_FAILED, "Optimistic set to " + newValue + + ", value returned by PMF is " + optimistic); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetReadOnly.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetReadOnly.java index 4252ab17d..d63dc1c8f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetReadOnly.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetReadOnly.java @@ -5,68 +5,77 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; +import javax.jdo.PersistenceManagerFactory; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:Set ReadOnly property of persistencemanagerfactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.1-29, A11.1-30
    - * Assertion Description: PersistenceManagerFactory.setReadOnly(boolean) sets the value of - * the ReadOnly property PersistenceManagerFactory.getReadOnly() returns the value of the ReadOnly - * property + *Title:Set ReadOnly property of persistencemanagerfactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.1-29, A11.1-30 + *
    + *Assertion Description: + * PersistenceManagerFactory.setReadOnly(boolean) sets the value of the + * ReadOnly property + * PersistenceManagerFactory.getReadOnly() returns the value of the + * ReadOnly property */ -public class SetReadOnly extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A11.1-29, A11.1-30 (SetRetainValues) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetReadOnly.class); - } +public class SetReadOnly extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.1-29, A11.1-30 (SetRetainValues) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetReadOnly.class); + } - /** */ - protected void localSetUp() { - closePMF(); - pmf = getUnconfiguredPMF(); - } + /** */ + protected void localSetUp() { + closePMF(); + pmf = getUnconfiguredPMF(); + } - /** Set ReadOnly to true or false and use getReadOnly to verify. */ - public void test() { - try { - setReadOnly(false); - setReadOnly(true); - } finally { - closePMF(); + /** + * Set ReadOnly to true or false and use getReadOnly to verify. + */ + public void test() { + try { + setReadOnly(false); + setReadOnly(true); + } finally { + closePMF(); + } } - } - /** */ - private void setReadOnly(boolean newValue) { - pmf.setReadOnly(newValue); - boolean current = pmf.getReadOnly(); - if (current != newValue) { - fail( - ASSERTION_FAILED, - "ReadOnly set to " + newValue + ", value returned by PMF is " + current); + /** */ + private void setReadOnly(boolean newValue) { + pmf.setReadOnly(newValue); + boolean current = pmf.getReadOnly(); + if (current != newValue) { + fail(ASSERTION_FAILED, "ReadOnly set to " + newValue + + ", value returned by PMF is " + current); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetRetainValues.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetRetainValues.java index 27a964f79..aa9073190 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetRetainValues.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetRetainValues.java @@ -5,69 +5,79 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; +import javax.jdo.PersistenceManagerFactory; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:Set RetainValues of persistencemanagerfactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.1-3,A11.1-4.
    - * Assertion Description: PersistenceManagerFactory.setRetainValues(boolean flag) sets the - * value of the RetainValues property (the transaction mode that specifies the treatment of - * persistent instances after commit), PersistenceManagerFactory.getRetainValues() returns the value - * of the RetainValues property. + *Title:Set RetainValues of persistencemanagerfactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.1-3,A11.1-4. + *
    + *Assertion Description: + * PersistenceManagerFactory.setRetainValues(boolean flag) sets the value of + * the RetainValues property (the transaction mode that specifies the + * treatment of persistent instances after commit), + * PersistenceManagerFactory.getRetainValues() returns the value of the + * RetainValues property. */ -public class SetRetainValues extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A11.1-3,A11.1-4 (SetRetainValues) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetRetainValues.class); - } +public class SetRetainValues extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.1-3,A11.1-4 (SetRetainValues) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetRetainValues.class); + } - /** */ - protected void localSetUp() { - closePMF(); - pmf = getUnconfiguredPMF(); - } + /** */ + protected void localSetUp() { + closePMF(); + pmf = getUnconfiguredPMF(); + } - /** Set RetainValues to true or false and use getRetainValues value to verify. */ - public void test() { - try { - setRetainValues(false); - setRetainValues(true); - } finally { - closePMF(); + /** + * Set RetainValues to true or false and use getRetainValues value to + * verify. + */ + public void test() { + try { + setRetainValues(false); + setRetainValues(true); + } finally { + closePMF(); + } } - } - /** */ - private void setRetainValues(boolean newValue) { - pmf.setRetainValues(newValue); - boolean current = pmf.getRetainValues(); - if (current != newValue) { - fail( - ASSERTION_FAILED, - "RetainValues set to " + newValue + ", value returned by PMF is " + current); + /** */ + private void setRetainValues(boolean newValue) { + pmf.setRetainValues(newValue); + boolean current = pmf.getRetainValues(); + if (current != newValue) { + fail(ASSERTION_FAILED, "RetainValues set to " + newValue + + ", value returned by PMF is " + current); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetTransactionIsolationLevel.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetTransactionIsolationLevel.java index 02f11bd2f..194897d04 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetTransactionIsolationLevel.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetTransactionIsolationLevel.java @@ -5,16 +5,16 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import java.util.HashMap; @@ -27,171 +27,166 @@ import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:Set transaction isolation level of persistencemanagerfactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.1-xxxx, A11.1-xxxx.
    - * Assertion Description: PersistenceManagerFactory.getTransactionIsolationLevel() returns - * the value of the transaction isolation level. - * PersistenceManagerFactory.setTransactionIsolationLevel(String) sets the value of the transaction - * isolation level. + *Title:Set transaction isolation level of persistencemanagerfactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.1-xxxx, A11.1-xxxx. + *
    + *Assertion Description: + * PersistenceManagerFactory.getTransactionIsolationLevel() returns the value + * of the transaction isolation level. + * PersistenceManagerFactory.setTransactionIsolationLevel(String) sets the value + * of the transaction isolation level. */ -public class SetTransactionIsolationLevel extends JDO_Test implements Constants { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A11.1-1, A11.1-2 (setTransactionIsolationLevel) failed: "; +public class SetTransactionIsolationLevel extends JDO_Test + implements Constants { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.1-1, A11.1-2 (setTransactionIsolationLevel) failed: "; - /** All specified transaction isolation levels */ - private static final String[] transactionIsolationLevels = - new String[] { - TX_READ_UNCOMMITTED, TX_READ_COMMITTED, TX_REPEATABLE_READ, TX_SNAPSHOT, TX_SERIALIZABLE - }; + /** All specified transaction isolation levels */ + private static final String[] transactionIsolationLevels = new String[] { + TX_READ_UNCOMMITTED, + TX_READ_COMMITTED, + TX_REPEATABLE_READ, + TX_SNAPSHOT, + TX_SERIALIZABLE + }; - private PersistenceManagerFactory pmf2; + private PersistenceManagerFactory pmf2; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetTransactionIsolationLevel.class); - } + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetTransactionIsolationLevel.class); + } - /** */ - protected void localSetUp() { - // setUp gets a PMF that needs to be closed - closePMF(); - } + /** */ + protected void localSetUp() { + // setUp gets a PMF that needs to be closed + closePMF(); + } - /** Set TransactionIsolationLevel to all values via API. */ - public void testSetTransactionIsolationLevelByAPI() { - // iterate through all possible TransactionIsolationLevels - for (int i = 0; i < transactionIsolationLevels.length; ++i) { - String transactionIsolationLevel = transactionIsolationLevels[i]; - setTransactionIsolationLevelByAPI(transactionIsolationLevel); + /** Set TransactionIsolationLevel to all values via API. */ + public void testSetTransactionIsolationLevelByAPI() { + // iterate through all possible TransactionIsolationLevels + for (int i = 0; i < transactionIsolationLevels.length; ++i) { + String transactionIsolationLevel = transactionIsolationLevels[i]; + setTransactionIsolationLevelByAPI(transactionIsolationLevel); + } + failOnError(); } - failOnError(); - } - /** Set TransactionIsolationLevel to all values from properties. */ - public void testSetTransactionIsolationLevelFromProperties() { - // iterate through all possible TransactionIsolationLevels - for (int i = 0; i < transactionIsolationLevels.length; ++i) { - String transactionIsolationLevel = transactionIsolationLevels[i]; - getPMFsetTransactionIsolationLevelFromProperties(transactionIsolationLevel); + /** Set TransactionIsolationLevel to all values from properties. */ + public void testSetTransactionIsolationLevelFromProperties() { + // iterate through all possible TransactionIsolationLevels + for (int i = 0; i < transactionIsolationLevels.length; ++i) { + String transactionIsolationLevel = transactionIsolationLevels[i]; + getPMFsetTransactionIsolationLevelFromProperties(transactionIsolationLevel); + } + failOnError(); } - failOnError(); - } - /** Set TransactionIsolationLevel to all values. */ - public void testTransactionIsolationLevelReadCommittedSupported() { - // this test depends on setUp initializing supportedOptions - String readCommitted = PROPERTY_TRANSACTION_ISOLATION_LEVEL_READ_COMMITTED; - // make sure read committed is supported - if (!isSupported(readCommitted)) { - appendMessage( - ASSERTION_FAILED + "\nSupportedOptions does not include " + readCommitted + "."); + /** Set TransactionIsolationLevel to all values. */ + public void testTransactionIsolationLevelReadCommittedSupported() { + // this test depends on setUp initializing supportedOptions + String readCommitted = + PROPERTY_TRANSACTION_ISOLATION_LEVEL_READ_COMMITTED; + // make sure read committed is supported + if (!isSupported(readCommitted)) { + appendMessage(ASSERTION_FAILED + + "\nSupportedOptions does not include " + + readCommitted + + "."); + } + failOnError(); } - failOnError(); - } - /** */ - private void setTransactionIsolationLevelByAPI(String level) { - pmf = getUnconfiguredPMF(); - // Set datastore details so the implementation knows what is supported - pmf.setConnectionURL(getPMFProperty(CONNECTION_URL_PROP)); - pmf.setConnectionUserName(getPMFProperty(CONNECTION_USERNAME_PROP)); - pmf.setConnectionPassword(getPMFProperty(CONNECTION_PASSWORD_PROP)); - pmf.setConnectionDriverName(getPMFProperty(PROPERTY_CONNECTION_DRIVER_NAME)); + /** */ + private void setTransactionIsolationLevelByAPI(String level) { + pmf = getUnconfiguredPMF(); + // Set datastore details so the implementation knows what is supported + pmf.setConnectionURL(getPMFProperty(CONNECTION_URL_PROP)); + pmf.setConnectionUserName(getPMFProperty(CONNECTION_USERNAME_PROP)); + pmf.setConnectionPassword(getPMFProperty(CONNECTION_PASSWORD_PROP)); + pmf.setConnectionDriverName(getPMFProperty(PROPERTY_CONNECTION_DRIVER_NAME)); - String property = PROPERTY_TRANSACTION_ISOLATION_LEVEL + "." + level; - try { - pmf.setTransactionIsolationLevel(level); + String property = PROPERTY_TRANSACTION_ISOLATION_LEVEL + "." + level; + try { + pmf.setTransactionIsolationLevel(level); - // Get first PM so the PMF is frozen - pmf.getPersistenceManager(); - if (!isSupported(property)) { - appendMessage( - ASSERTION_FAILED - + "\nCreated PersistenceManager for isolation level " - + level - + " yet the PMF says that this level is not supported!\n"); - } - } catch (JDOUnsupportedOptionException ex) { - // not supported, so check with the PMF if this should be supported - if (isSupported(property)) { - appendMessage( - ASSERTION_FAILED - + "\nReceived JDOUnsupportedOptionException on creating the " - + "first PersistenceManager yet the PMF says that isolation level " - + "is supported!\n"); - } - } catch (Throwable t) { - appendMessage( - ASSERTION_FAILED - + "\nThe expected JDOUnsupportedOptionException was not " - + "thrown for unsupported isolation level " - + level - + " but unexpected exception:\n" - + t); - } + // Get first PM so the PMF is frozen + pmf.getPersistenceManager(); + if (!isSupported(property)) { + appendMessage(ASSERTION_FAILED + + "\nCreated PersistenceManager for isolation level "+ + level + " yet the PMF says that this level is not supported!\n"); + } + } catch (JDOUnsupportedOptionException ex) { + // not supported, so check with the PMF if this should be supported + if (isSupported(property)) { + appendMessage(ASSERTION_FAILED + + "\nReceived JDOUnsupportedOptionException on creating the "+ + "first PersistenceManager yet the PMF says that isolation level "+ + "is supported!\n"); + } + } catch (Throwable t) { + appendMessage(ASSERTION_FAILED + + "\nThe expected JDOUnsupportedOptionException was not " + + "thrown for unsupported isolation level " + level + + " but unexpected exception:\n" + t); + } - closePMF(); - return; - } - /** */ - private void getPMFsetTransactionIsolationLevelFromProperties(String level) { - String property = PROPERTY_TRANSACTION_ISOLATION_LEVEL + "." + level; - Map modifiedProps = new HashMap(PMFPropertiesObject); - modifiedProps.put(PROPERTY_TRANSACTION_ISOLATION_LEVEL, level); - if (isSupported(property)) { - pmf2 = JDOHelper.getPersistenceManagerFactory(modifiedProps); - String actual = pmf2.getTransactionIsolationLevel(); - if (!validLevelSubstitution(level, actual)) { - appendMessage( - ASSERTION_FAILED - + "\nTransactionIsolationLevel set to " - + level - + "; value returned by PMF is " - + actual); - } - PersistenceManager pm2 = pmf2.getPersistenceManager(); - actual = pm2.currentTransaction().getIsolationLevel(); - if (!validLevelSubstitution(level, actual)) { - appendMessage( - ASSERTION_FAILED - + "\nTransactionIsolationLevel set to " - + level - + "; value returned by Transaction is " - + actual); - } - } else { - try { - pmf2 = JDOHelper.getPersistenceManagerFactory(modifiedProps); - // no exception thrown; bad - appendMessage( - ASSERTION_FAILED - + "\nThe expected JDOUserException was not thrown for " - + "JDOHelper.getPersistenceManagerFactory " - + "for unsupported isolation level " - + level - + "."); - } catch (JDOUnsupportedOptionException ex) { - // good catch - } catch (Throwable t) { - appendMessage( - ASSERTION_FAILED - + "\nThe expected JDOUserException was not thrown for " - + "JDOHelper.getPersistenceManagerFactory " - + "for unsupported isolation level " - + level - + "but unexpected exception:\n" - + t); - } + closePMF(); + return; + } + /** */ + private void getPMFsetTransactionIsolationLevelFromProperties(String level) { + String property = PROPERTY_TRANSACTION_ISOLATION_LEVEL + "." + level; + Map modifiedProps = new HashMap(PMFPropertiesObject); + modifiedProps.put(PROPERTY_TRANSACTION_ISOLATION_LEVEL, level); + if (isSupported(property)) { + pmf2 = JDOHelper.getPersistenceManagerFactory(modifiedProps); + String actual = pmf2.getTransactionIsolationLevel(); + if (!validLevelSubstitution(level, actual)) { + appendMessage(ASSERTION_FAILED + + "\nTransactionIsolationLevel set to " + level + + "; value returned by PMF is " + actual); + } + PersistenceManager pm2 = pmf2.getPersistenceManager(); + actual = pm2.currentTransaction().getIsolationLevel(); + if (!validLevelSubstitution(level, actual)) { + appendMessage(ASSERTION_FAILED + + "\nTransactionIsolationLevel set to " + level + + "; value returned by Transaction is " + actual); + } + } else { + try { + pmf2 = JDOHelper.getPersistenceManagerFactory(modifiedProps); + // no exception thrown; bad + appendMessage(ASSERTION_FAILED + + "\nThe expected JDOUserException was not thrown for " + + "JDOHelper.getPersistenceManagerFactory " + + "for unsupported isolation level " + level + "."); + } catch (JDOUnsupportedOptionException ex) { + // good catch + } catch (Throwable t) { + appendMessage(ASSERTION_FAILED + + "\nThe expected JDOUserException was not thrown for " + + "JDOHelper.getPersistenceManagerFactory " + + "for unsupported isolation level " + level + + "but unexpected exception:\n" + t); + } + } + closePMF(pmf2); + return; } - closePMF(pmf2); - return; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SupportedOptions.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SupportedOptions.java index 83fcfa0d9..b221d3d17 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SupportedOptions.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/SupportedOptions.java @@ -5,34 +5,41 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory; import java.util.Collection; import java.util.Iterator; + import javax.jdo.PersistenceManagerFactory; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:SupportedOptions of persistencemanagerfactory
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.5-1.
    - * Assertion Description: PersistenceManagerFactory.supportedOptions() returns a Collection - * of String, each String instance representing an optional feature of the implementation or a - * supported query language. + *Title:SupportedOptions of persistencemanagerfactory + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.5-1. + *
    + *Assertion Description: + * PersistenceManagerFactory.supportedOptions() returns a Collection +of String, each String instance representing an optional feature of the +implementation or a supported query language. */ -/* +/* * Revision History * ================ * Author : Linga Neerathilingam @@ -41,28 +48,30 @@ */ public class SupportedOptions extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A11.5-1 (SupportedOptions) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SupportedOptions.class); - } - - /** */ - public void test() { - PersistenceManagerFactory pmf = getPMF(); - if (debug) logger.debug("Options supported by this implementation:"); - Collection c = pmf.supportedOptions(); - Iterator iter = c.iterator(); - while (iter.hasNext()) { - String option = (String) iter.next(); - if (debug) logger.debug(option); + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.5-1 (SupportedOptions) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SupportedOptions.class); } - } + + /** */ + public void test() { + PersistenceManagerFactory pmf = getPMF(); + if (debug) logger.debug("Options supported by this implementation:"); + Collection c = pmf.supportedOptions(); + Iterator iter = c.iterator(); + while( iter.hasNext() ){ + String option = (String) iter.next(); + if (debug) logger.debug(option); + } + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/JDOConfigListener.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/JDOConfigListener.java index 691361aca..bc93d08f5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/JDOConfigListener.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/JDOConfigListener.java @@ -5,13 +5,13 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory.config; @@ -26,115 +26,137 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:JDOConfigListener
    - * Keywords: persistencemanagerfactory, jdoconfig.xml
    - * Assertion IDs: A11.1-40
    - * Assertion Description: Properties whose key begins with the prefix - * "javax.jdo.listener.InstanceLifecycleListener." have special treatment. The part of the key - * following the prefix is used as the class name of a class that implements - * javax.jdo.listener.InstanceLifecycleListener. The implementation first attempts to get an - * instance via the static method getInstance() that returns an instance that implements the - * javax.jdo.listener.InstanceLifecycleListener. If this is unsuccessful, an instance of this class - * is constructed via a no-args constructor. The value of the key is a comma-separated list of - * classes to which the instantiated listener is registered to listen. + *Title:JDOConfigListener + *
    + *Keywords: persistencemanagerfactory, jdoconfig.xml + *
    + *Assertion IDs: A11.1-40 + *
    + *Assertion Description: + Properties whose key begins with the prefix + * "javax.jdo.listener.InstanceLifecycleListener." have special treatment. + * The part of the key following the prefix is used as the class name of a class + * that implements javax.jdo.listener.InstanceLifecycleListener. + * The implementation first attempts to get an instance via the static method + * getInstance() that returns an instance that implements the + * javax.jdo.listener.InstanceLifecycleListener. If this is unsuccessful, + * an instance of this class is constructed via a no-args constructor. + * The value of the key is a comma-separated list of classes to which + * the instantiated listener is registered to listen. */ -public class JDOConfigListener extends JDO_Test { - /** Creates a new instance of JDOConfigListener */ - public JDOConfigListener() {} - /** */ - private static final String ASSERTION_FAILED = "Assertions 11.1-40 failed: "; +public class JDOConfigListener extends JDO_Test { - private static final String ANONYMOUS_PMF_NAME = ""; - // Do not use superclass pmf, pm - private PersistenceManagerFactory pmf = null; - private PersistenceManager pm = null; - private HashMap overrides = new HashMap(); + /** Creates a new instance of JDOConfigListener */ + public JDOConfigListener() { + } + /** */ + private static final String ASSERTION_FAILED = + "Assertions 11.1-40 failed: "; + private static final String ANONYMOUS_PMF_NAME = ""; + // Do not use superclass pmf, pm + private PersistenceManagerFactory pmf = null; + private PersistenceManager pm = null; + private HashMap overrides = new HashMap(); - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(JDOConfigListener.class); - } + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(JDOConfigListener.class); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - /* Instance can be persisted ONLY if javax.jdo.mapping.Schema - * is overriden with - * JDOHelper.getPersistenceManagerFactory(Map overrides, ...). - * The value depends on identity type so can only be known at runtime. + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() */ - if (isTestToBePerformed()) { - overrides.put("javax.jdo.mapping.Schema", SCHEMANAME); + @Override + protected void localSetUp() { + /* Instance can be persisted ONLY if javax.jdo.mapping.Schema + * is overriden with + * JDOHelper.getPersistenceManagerFactory(Map overrides, ...). + * The value depends on identity type so can only be known at runtime. + */ + if (isTestToBePerformed()) { + overrides.put("javax.jdo.mapping.Schema", SCHEMANAME); + } } - } - /** - * Test instantiation of InstanceLifecycleListener where listener class and target classes are - * specified in jdoconfig.xml where listener class provides only a public no-args constructor. - */ - public void testPCPointListener() { - String pmfname = "testInstanceLifecycleListenerStore"; - pmf = JDOHelper.getPersistenceManagerFactory(overrides, pmfname); - makePersistent(); - assertTrue("Expected preStore() to have been invoked.", StoreListener.isPreStore()); - assertTrue("Expected postStore() to have been invoked.", StoreListener.isPostStore()); - } + /** + * Test instantiation of InstanceLifecycleListener where listener class + * and target classes are specified in jdoconfig.xml where listener + * class provides only a public no-args constructor. + */ + public void testPCPointListener() { + String pmfname = "testInstanceLifecycleListenerStore"; + pmf = JDOHelper.getPersistenceManagerFactory(overrides, pmfname); + makePersistent(); + assertTrue("Expected preStore() to have been invoked.", + StoreListener.isPreStore()); + assertTrue("Expected postStore() to have been invoked.", + StoreListener.isPostStore()); + } - /** - * Test instantiation of InstanceLifecycleListener where listener class and target classes are - * specified in jdoconfig.xml where listener class provides a static method getInstance(). - */ - public void testPCPointListenerGetInstance() { - String pmfname = "testInstanceLifecycleListenerStoreGetInstance"; - pmf = JDOHelper.getPersistenceManagerFactory(overrides, pmfname); - makePersistent(); - assertTrue("Expected preStore() to have been invoked.", StoreListenerGetInstance.isPreStore()); - assertTrue( - "Expected postStore() to have been invoked.", StoreListenerGetInstance.isPostStore()); - } + /** + * Test instantiation of InstanceLifecycleListener where listener class + * and target classes are specified in jdoconfig.xml where listener + * class provides a static method getInstance(). + */ + public void testPCPointListenerGetInstance() { + String pmfname = "testInstanceLifecycleListenerStoreGetInstance"; + pmf = JDOHelper.getPersistenceManagerFactory(overrides, pmfname); + makePersistent(); + assertTrue("Expected preStore() to have been invoked.", + StoreListenerGetInstance.isPreStore()); + assertTrue("Expected postStore() to have been invoked.", + StoreListenerGetInstance.isPostStore()); + } - /** Test instantiation of Instance LifeCycleListener specified via property overrides. */ - public void testPCPointListenerOverrides() { - overrides.put( - "javax.jdo.listener.InstanceLifecycleListener.org.apache.jdo.tck.api.persistencemanagerfactory.config.StoreListener", - "org.apache.jdo.tck.pc.mylib.PCPoint"); - String pmfname = "testInstanceLifecycleListenerStoreOverrides"; - pmf = JDOHelper.getPersistenceManagerFactory(overrides, pmfname); - makePersistent(); - assertTrue("Expected preStore() to have been invoked.", StoreListener.isPreStore()); - assertTrue("Expected postStore() to have been invoked.", StoreListener.isPostStore()); - } + /** + * Test instantiation of Instance LifeCycleListener specified via + * property overrides. + */ + public void testPCPointListenerOverrides() { + overrides.put("javax.jdo.listener.InstanceLifecycleListener.org.apache.jdo.tck.api.persistencemanagerfactory.config.StoreListener", + "org.apache.jdo.tck.pc.mylib.PCPoint"); + String pmfname = "testInstanceLifecycleListenerStoreOverrides"; + pmf = JDOHelper.getPersistenceManagerFactory(overrides, pmfname); + makePersistent(); + assertTrue("Expected preStore() to have been invoked.", + StoreListener.isPreStore()); + assertTrue("Expected postStore() to have been invoked.", + StoreListener.isPostStore()); + } - /** Test instantiation of InstanceLifecycleListener where class value is null */ - public void testPCPointListenerNullClasses() { - String pmfname = "testInstanceLifecycleListenerClassesNull"; - pmf = JDOHelper.getPersistenceManagerFactory(overrides, pmfname); - makePersistent(); - assertTrue("Expected preStore() to have been invoked.", StoreListener.isPreStore()); - assertTrue("Expected postStore() to have been invoked.", StoreListener.isPostStore()); - } + /** + * Test instantiation of InstanceLifecycleListener where class value + * is null + */ + public void testPCPointListenerNullClasses() { + String pmfname = "testInstanceLifecycleListenerClassesNull"; + pmf = JDOHelper.getPersistenceManagerFactory(overrides, pmfname); + makePersistent(); + assertTrue("Expected preStore() to have been invoked.", + StoreListener.isPreStore()); + assertTrue("Expected postStore() to have been invoked.", + StoreListener.isPostStore()); + } - protected void makePersistent() { - addTearDownClass(PCPoint.class); - pm = pmf.getPersistenceManager(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint comp = new PCPoint(1, 2); - pm.makePersistent(comp); - tx.commit(); - } + protected void makePersistent() { + addTearDownClass(PCPoint.class); + pm = pmf.getPersistenceManager(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint comp = new PCPoint(1, 2); + pm.makePersistent(comp); + tx.commit(); + } - protected void localTearDown() { - super.localTearDown(); - StoreListener.resetValues(); - StoreListenerGetInstance.resetValues(); - closePMF(); - } + protected void localTearDown() { + super.localTearDown(); + StoreListener.resetValues(); + StoreListenerGetInstance.resetValues(); + closePMF(); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/Jdoconfig.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/Jdoconfig.java index 7c00afc2b..01bea8f11 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/Jdoconfig.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/Jdoconfig.java @@ -5,13 +5,13 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory.config; @@ -26,160 +26,172 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:Close of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory, jdoconfig.xml
    - * Assertion IDs: A11.1.2-1
    - * Assertion Description: Users can access a PersistenceManagerFactory by creating a - * jdoconfig.xml file and making it available on the class path as META-INF/jdoconfig.xml. + *Title:Close of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory, jdoconfig.xml + *
    + *Assertion IDs: A11.1.2-1 + *
    + *Assertion Description: + * Users can access a PersistenceManagerFactory by creating a jdoconfig.xml file + * and making it available on the class path as META-INF/jdoconfig.xml. */ public class Jdoconfig extends JDO_Test { - /** Creates a new instance of Jdoconfig */ - public Jdoconfig() {} - /** */ - private static final String ASSERTION_FAILED = "Assertion A11.1.2-1 failed: "; - - private static final String ANONYMOUS_PMF_NAME = ""; - // Do not use superclass pmf, pm - private PersistenceManagerFactory privatePmf = null; - private PersistenceManager privatePm = null; - private HashMap overrides = new HashMap(); - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Jdoconfig.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - /* Instance can be persisted ONLY if javax.jdo.mapping.Schema - * is overriden with - * JDOHelper.getPersistenceManagerFactory(Map overrides, ...). - * The value depends on identity type so can only be known at runtime. + /** Creates a new instance of Jdoconfig */ + public Jdoconfig() { + } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.1.2-1 failed: "; + private static final String ANONYMOUS_PMF_NAME = ""; + // Do not use superclass pmf, pm + private PersistenceManagerFactory privatePmf = null; + private PersistenceManager privatePm = null; + private HashMap overrides = new HashMap(); + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Jdoconfig.class); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + /* Instance can be persisted ONLY if javax.jdo.mapping.Schema + * is overriden with + * JDOHelper.getPersistenceManagerFactory(Map overrides, ...). + * The value depends on identity type so can only be known at runtime. + */ + if (isTestToBePerformed()) { + overrides.put("javax.jdo.mapping.Schema", SCHEMANAME); + } + } + + /** */ + public void testGetPMFNoArgs() { + privatePmf = JDOHelper.getPersistenceManagerFactory(); + checkIsOpen(ANONYMOUS_PMF_NAME); + } + + /** */ + public void testGetPMFEmptyString() { + String name = ""; + privatePmf = JDOHelper.getPersistenceManagerFactory(name); + checkIsOpen(ANONYMOUS_PMF_NAME); + } + + /** */ + public void testGetPMFNull() { + String name = null; + privatePmf = JDOHelper.getPersistenceManagerFactory(name); + checkIsOpen(ANONYMOUS_PMF_NAME); + } + + /** */ + public void testGetPMFStringSpace() { + String name = " "; + privatePmf = JDOHelper.getPersistenceManagerFactory(name); + checkIsOpen(ANONYMOUS_PMF_NAME); + } + + /** */ + public void testGetPMFNamed() { + String name = "namedPMF0"; + privatePmf = JDOHelper.getPersistenceManagerFactory(name); + assertEquals("Incorrect value for RestoreValues", + privatePmf.getRestoreValues(), false); + checkIsOpen(name); + } + + /** */ + public void testGetPMFEmptyStringOverrides() { + String name = ""; + privatePmf = JDOHelper.getPersistenceManagerFactory(overrides, name); + checkPersistent(ANONYMOUS_PMF_NAME); + } + + /** */ + public void testGetPMFNullOverrides() { + String name = null; + privatePmf = JDOHelper.getPersistenceManagerFactory(overrides, name); + checkPersistent(ANONYMOUS_PMF_NAME); + } + + /** */ + public void testGetPMFStringSpaceOverrides() { + String name = " "; + privatePmf = JDOHelper.getPersistenceManagerFactory(overrides, name); + checkPersistent(ANONYMOUS_PMF_NAME); + } + + /** */ + public void testGetPMFNamedOverrides() { + String name = "namedPMF0"; + privatePmf = JDOHelper.getPersistenceManagerFactory(overrides, name); + assertEquals("Incorrect value for RestoreValues", + privatePmf.getRestoreValues(), false); + checkPersistent(name); + } + + /** */ + public void testGetPMFNamedSpacesOverrides() { + String name = "namedPMF1"; + privatePmf = JDOHelper.getPersistenceManagerFactory(overrides, + " \t" + name + " \n"); + assertEquals("Incorrect value for RestoreValues", + privatePmf.getRestoreValues(), true); + checkPersistent(name); + } + + /** + * + * @param name the name + */ + public void checkIsOpen(String name) { + assertEquals("Incorrect PMF name", name, privatePmf.getName()); + if (privatePmf.isClosed()) { + fail(ASSERTION_FAILED, + "PMF.isClosed() returned true on an open pmf"); + } + closePMF(privatePmf); + // have next invocation of getPMF() get a new pmf + privatePmf = null; + } + + /** + * Checks if instance can be persisted. Can be used if + * javax.jdo.mapping.Schema is overriden with the correct value + * with JDOHelper.getPersistenceManagerFactory(Map overrides, ...). + * @param name the name */ - if (isTestToBePerformed()) { - overrides.put("javax.jdo.mapping.Schema", SCHEMANAME); - } - } - - /** */ - public void testGetPMFNoArgs() { - privatePmf = JDOHelper.getPersistenceManagerFactory(); - checkIsOpen(ANONYMOUS_PMF_NAME); - } - - /** */ - public void testGetPMFEmptyString() { - String name = ""; - privatePmf = JDOHelper.getPersistenceManagerFactory(name); - checkIsOpen(ANONYMOUS_PMF_NAME); - } - - /** */ - public void testGetPMFNull() { - String name = null; - privatePmf = JDOHelper.getPersistenceManagerFactory(name); - checkIsOpen(ANONYMOUS_PMF_NAME); - } - - /** */ - public void testGetPMFStringSpace() { - String name = " "; - privatePmf = JDOHelper.getPersistenceManagerFactory(name); - checkIsOpen(ANONYMOUS_PMF_NAME); - } - - /** */ - public void testGetPMFNamed() { - String name = "namedPMF0"; - privatePmf = JDOHelper.getPersistenceManagerFactory(name); - assertEquals("Incorrect value for RestoreValues", privatePmf.getRestoreValues(), false); - checkIsOpen(name); - } - - /** */ - public void testGetPMFEmptyStringOverrides() { - String name = ""; - privatePmf = JDOHelper.getPersistenceManagerFactory(overrides, name); - checkPersistent(ANONYMOUS_PMF_NAME); - } - - /** */ - public void testGetPMFNullOverrides() { - String name = null; - privatePmf = JDOHelper.getPersistenceManagerFactory(overrides, name); - checkPersistent(ANONYMOUS_PMF_NAME); - } - - /** */ - public void testGetPMFStringSpaceOverrides() { - String name = " "; - privatePmf = JDOHelper.getPersistenceManagerFactory(overrides, name); - checkPersistent(ANONYMOUS_PMF_NAME); - } - - /** */ - public void testGetPMFNamedOverrides() { - String name = "namedPMF0"; - privatePmf = JDOHelper.getPersistenceManagerFactory(overrides, name); - assertEquals("Incorrect value for RestoreValues", privatePmf.getRestoreValues(), false); - checkPersistent(name); - } - - /** */ - public void testGetPMFNamedSpacesOverrides() { - String name = "namedPMF1"; - privatePmf = JDOHelper.getPersistenceManagerFactory(overrides, " \t" + name + " \n"); - assertEquals("Incorrect value for RestoreValues", privatePmf.getRestoreValues(), true); - checkPersistent(name); - } - - /** - * @param name the name - */ - public void checkIsOpen(String name) { - assertEquals("Incorrect PMF name", name, privatePmf.getName()); - if (privatePmf.isClosed()) { - fail(ASSERTION_FAILED, "PMF.isClosed() returned true on an open pmf"); - } - closePMF(privatePmf); - // have next invocation of getPMF() get a new pmf - privatePmf = null; - } - - /** - * Checks if instance can be persisted. Can be used if javax.jdo.mapping.Schema is overriden with - * the correct value with JDOHelper.getPersistenceManagerFactory(Map overrides, ...). - * - * @param name the name - */ - public void checkPersistent(String name) { - assertEquals("Incorrect PMF name", name, privatePmf.getName()); - - makePersistent(); - - closePMF(privatePmf); - if (!privatePmf.isClosed()) { - fail(ASSERTION_FAILED, "PMF.isClosed() returned false on a closed pmf"); - } - // have next invocation of getPMF() get a new pmf - privatePmf = null; - } - - protected void makePersistent() { - addTearDownClass(PCPoint.class); - privatePm = privatePmf.getPersistenceManager(); - Transaction tx = privatePm.currentTransaction(); - tx.begin(); - PCPoint comp = new PCPoint(1, 2); - privatePm.makePersistent(comp); - tx.commit(); - } + public void checkPersistent(String name) { + assertEquals("Incorrect PMF name", name, privatePmf.getName()); + + makePersistent(); + + closePMF(privatePmf); + if (!privatePmf.isClosed()) { + fail(ASSERTION_FAILED, + "PMF.isClosed() returned false on a closed pmf"); + } + // have next invocation of getPMF() get a new pmf + privatePmf = null; + } + + protected void makePersistent() { + addTearDownClass(PCPoint.class); + privatePm = privatePmf.getPersistenceManager(); + Transaction tx = privatePm.currentTransaction(); + tx.begin(); + PCPoint comp = new PCPoint(1, 2); + privatePm.makePersistent(comp); + tx.commit(); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/Persistence.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/Persistence.java index 4d7207de4..7f11717ad 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/Persistence.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/Persistence.java @@ -5,13 +5,13 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory.config; @@ -29,104 +29,117 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:Close of PersistenceManagerFactory
    - * Keywords: persistencemanagerfactory, jdoconfig.xml
    - * Assertion IDs: A8.7-1
    - * Assertion Description: The application provides a resource named META-INF/persistence.xml - * and optionally META-INF/services/javax.persistence.EntityManagerFactory which contain - * configuration information + *Title:Close of PersistenceManagerFactory + *
    + *Keywords: persistencemanagerfactory, jdoconfig.xml + *
    + *Assertion IDs: A8.7-1 + *
    + *Assertion Description: + * The application provides a resource named META-INF/persistence.xml and + * optionally META-INF/services/javax.persistence.EntityManagerFactory which + * contain configuration information */ public class Persistence extends JDO_Test { - /** Creates a new instance of Jdoconfig */ - public Persistence() {} - /** */ - private static final String ASSERTION_FAILED = "Assertion A11.1.2-1 failed: "; - // Do not use superclass pmf, pm - private PersistenceManagerFactory pmf = null; - private PersistenceManager pm = null; + /** Creates a new instance of Jdoconfig */ + public Persistence() { + } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.1.2-1 failed: "; + // Do not use superclass pmf, pm + private PersistenceManagerFactory pmf = null; + private PersistenceManager pm = null; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Persistence.class); - } + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Persistence.class); + } - /** */ - public void testGetPMFfromNamedPU() { - String name = "PUNamed_" + IDENTITYTYPE + "0"; - pmf = JDOHelper.getPersistenceManagerFactory(name); - assertEquals("Incorrect value for RestoreValues", false, pmf.getRestoreValues()); - runTest(name); - } + /** */ + public void testGetPMFfromNamedPU() { + String name = "PUNamed_" + IDENTITYTYPE + "0"; + pmf = JDOHelper.getPersistenceManagerFactory(name); + assertEquals("Incorrect value for RestoreValues", + false, pmf.getRestoreValues()); + runTest(name); + } - /** */ - public void testGetPMFfromNamedPUWithNullOverrides() { - String name = "PUNamed_" + IDENTITYTYPE + "0"; - pmf = JDOHelper.getPersistenceManagerFactory(null, name); - assertEquals("Incorrect value for RestoreValues", false, pmf.getRestoreValues()); - runTest(name); - } + /** */ + public void testGetPMFfromNamedPUWithNullOverrides() { + String name = "PUNamed_" + IDENTITYTYPE + "0"; + pmf = JDOHelper.getPersistenceManagerFactory(null, name); + assertEquals("Incorrect value for RestoreValues", + false, pmf.getRestoreValues()); + runTest(name); + } - /** */ - public void testGetPMFfromNamedPUWithEmptyOverrides() { - String name = "PUNamed_" + IDENTITYTYPE + "0"; - Map overrides = new HashMap(); - pmf = JDOHelper.getPersistenceManagerFactory(overrides, name); - assertEquals("Incorrect value for RestoreValues", false, pmf.getRestoreValues()); - runTest(name); - } + /** */ + public void testGetPMFfromNamedPUWithEmptyOverrides() { + String name = "PUNamed_" + IDENTITYTYPE + "0"; + Map overrides = new HashMap(); + pmf = JDOHelper.getPersistenceManagerFactory(overrides, name); + assertEquals("Incorrect value for RestoreValues", + false, pmf.getRestoreValues()); + runTest(name); + } - /** */ - public void testGetPMFfromNamedPUWithOverrides() { - String name = "PUNamed_" + IDENTITYTYPE + "0"; - Properties overrides = new Properties(); - overrides.setProperty(Constants.PROPERTY_RESTORE_VALUES, "true"); - pmf = JDOHelper.getPersistenceManagerFactory(overrides, name); - assertEquals("Incorrect value for RestoreValues", true, pmf.getRestoreValues()); - runTest(name); - } + /** */ + public void testGetPMFfromNamedPUWithOverrides() { + String name = "PUNamed_" + IDENTITYTYPE + "0"; + Properties overrides = new Properties(); + overrides.setProperty(Constants.PROPERTY_RESTORE_VALUES, "true"); + pmf = JDOHelper.getPersistenceManagerFactory(overrides, name); + assertEquals("Incorrect value for RestoreValues", + true, pmf.getRestoreValues()); + runTest(name); + } - /** */ - public void testGetPMFfromNamedPUWithWhiteSpace() { - String name = "PUNamed_" + IDENTITYTYPE + "0"; - pmf = JDOHelper.getPersistenceManagerFactory(" \t" + name + " \n"); - assertEquals("Incorrect value for RestoreValues", false, pmf.getRestoreValues()); - runTest(name); - } + /** */ + public void testGetPMFfromNamedPUWithWhiteSpace() { + String name = "PUNamed_" + IDENTITYTYPE + "0"; + pmf = JDOHelper.getPersistenceManagerFactory(" \t" + name + " \n"); + assertEquals("Incorrect value for RestoreValues", + false, pmf.getRestoreValues()); + runTest(name); + } - /** - * @param name the name - */ - public void runTest(String name) { - String actualPUName = pmf.getPersistenceUnitName(); - assertEquals("Incorrect PersistenceUnitName", name, actualPUName); + /** + * @param name the name + */ + public void runTest(String name) { + String actualPUName = pmf.getPersistenceUnitName(); + assertEquals("Incorrect PersistenceUnitName", name, actualPUName); - // check pmf.isClosed() before and after pmf.close() - if (pmf.isClosed()) { - fail(ASSERTION_FAILED, "PMF.isClosed() returned true on an open pmf"); - } - makePersistent(); + // check pmf.isClosed() before and after pmf.close() + if (pmf.isClosed()) { + fail(ASSERTION_FAILED, + "PMF.isClosed() returned true on an open pmf"); + } + makePersistent(); - closePMF(pmf); // don't use closePMF() because that sets pmf to null + closePMF(pmf); // don't use closePMF() because that sets pmf to null - if (!pmf.isClosed()) { - fail(ASSERTION_FAILED, "PMF.isClosed() returned false on a closed pmf"); + if (!pmf.isClosed()) { + fail(ASSERTION_FAILED, + "PMF.isClosed() returned false on a closed pmf"); + } + // have next invocation of getPMF() get a new pmf + pmf = null; } - // have next invocation of getPMF() get a new pmf - pmf = null; - } - protected void makePersistent() { - addTearDownClass(PCPoint.class); - pm = pmf.getPersistenceManager(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - PCPoint comp = new PCPoint(1, 2); - pm.makePersistent(comp); - tx.commit(); - } + protected void makePersistent() { + addTearDownClass(PCPoint.class); + pm = pmf.getPersistenceManager(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + PCPoint comp = new PCPoint(1, 2); + pm.makePersistent(comp); + tx.commit(); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/StoreListener.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/StoreListener.java index 9a3b52497..b2915de34 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/StoreListener.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/StoreListener.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -21,39 +21,40 @@ import javax.jdo.listener.StoreLifecycleListener; /** - * A StoreLivecycleListener implementation that provides a public no-args constructor that may be - * invoked by a JDO implementation, but NO getInstance() method. + * A StoreLivecycleListener implementation that provides a public no-args + * constructor that may be invoked by a JDO implementation, + * but NO getInstance() method. */ public class StoreListener implements StoreLifecycleListener { - private static boolean preStore = false; - private static boolean postStore = false; - private static int instanceCount = 0; + private static boolean preStore = false; + private static boolean postStore = false; + private static int instanceCount = 0; - public StoreListener() { - instanceCount++; - } + public StoreListener() { + instanceCount++; + } - public static boolean isPreStore() { - return preStore; - } + public static boolean isPreStore() { + return preStore; + } - public static boolean isPostStore() { - return postStore; - } + public static boolean isPostStore() { + return postStore; + } - public static void resetValues() { - preStore = false; - postStore = false; - } + public static void resetValues() { + preStore = false; + postStore = false; + } - public void preStore(InstanceLifecycleEvent event) { - // System.out.println("preStore: event is " + event); - preStore = true; - } + public void preStore(InstanceLifecycleEvent event) { +// System.out.println("preStore: event is " + event); + preStore = true; + } - public void postStore(InstanceLifecycleEvent event) { - // System.out.println("postStore: event is " + event); - postStore = true; - } + public void postStore(InstanceLifecycleEvent event) { +// System.out.println("postStore: event is " + event); + postStore = true; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/StoreListenerGetInstance.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/StoreListenerGetInstance.java index b32496ed8..a25ceb80a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/StoreListenerGetInstance.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/StoreListenerGetInstance.java @@ -5,13 +5,13 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory.config; @@ -20,44 +20,45 @@ import javax.jdo.listener.StoreLifecycleListener; /** - * A StoreLifecycleListener implementation that provides a getInstance() method that may be invoked - * by a JDO implementation. + * A StoreLifecycleListener implementation that provides a getInstance() method + * that may be invoked by a JDO implementation. */ public class StoreListenerGetInstance implements StoreLifecycleListener { - private static boolean preStore = false; - private static boolean postStore = false; - private static int instanceCount = 0; - private static StoreListenerGetInstance slInstance = new StoreListenerGetInstance(); - - private StoreListenerGetInstance() { - instanceCount++; - } - - public static StoreListenerGetInstance getInstance() { - return slInstance; - } - - public static boolean isPreStore() { - return preStore; - } - - public static boolean isPostStore() { - return postStore; - } - - public static void resetValues() { - preStore = false; - postStore = false; - } - - public void preStore(InstanceLifecycleEvent event) { - // System.out.println("preStore: event is " + event); - preStore = true; - } - - public void postStore(InstanceLifecycleEvent event) { - // System.out.println("postStore: event is " + event); - postStore = true; - } + private static boolean preStore = false; + private static boolean postStore = false; + private static int instanceCount = 0; + private static StoreListenerGetInstance slInstance = + new StoreListenerGetInstance(); + + private StoreListenerGetInstance() { + instanceCount++; + } + + public static StoreListenerGetInstance getInstance() { + return slInstance; + } + + public static boolean isPreStore() { + return preStore; + } + + public static boolean isPostStore() { + return postStore; + } + + public static void resetValues() { + preStore = false; + postStore = false; + } + + public void preStore(InstanceLifecycleEvent event) { +// System.out.println("preStore: event is " + event); + preStore = true; + } + + public void postStore(InstanceLifecycleEvent event) { +// System.out.println("postStore: event is " + event); + postStore = true; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/ThrowOnUnknownStandardProperties.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/ThrowOnUnknownStandardProperties.java index 0bb0c2ee2..116575119 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/ThrowOnUnknownStandardProperties.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/config/ThrowOnUnknownStandardProperties.java @@ -5,13 +5,13 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory.config; @@ -21,113 +21,116 @@ import java.lang.reflect.Modifier; import java.util.Map; import java.util.Properties; + import javax.jdo.JDOException; import javax.jdo.JDOUserException; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; public class ThrowOnUnknownStandardProperties extends JDO_Test { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ThrowOnUnknownStandardProperties.class); - } - - protected boolean preSetUp() { - return false; - } - - protected boolean preTearDown() { - return false; - } - - protected Method getStaticGetPMFMethod() { - Class pmfClass = getPMFClass(); - try { - Method m = - pmfClass.getDeclaredMethod("getPersistenceManagerFactory", new Class[] {Map.class}); - - if ((m.getModifiers() & Modifier.STATIC) != Modifier.STATIC) { - throw new JDOException( - "PMF class " - + pmfClass.getName() - + " method 'getPersistenceManagerFactory' is not static"); - } - - return m; - } catch (SecurityException e) { - throw new JDOException( - "Cannot get method 'getPersistenceManagerFactory' from PMF class " + pmfClass.getName(), - e); - } catch (NoSuchMethodException e) { - throw new JDOException( - "No method 'getPersistenceManagerFactory' from PMF class " + pmfClass.getName(), e); + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ThrowOnUnknownStandardProperties.class); + } + + protected boolean preSetUp() { + return false; + } + + protected boolean preTearDown() { + return false; + } + + protected Method getStaticGetPMFMethod() { + Class pmfClass = getPMFClass(); + try { + Method m = pmfClass.getDeclaredMethod( + "getPersistenceManagerFactory", new Class[] {Map.class}); + + if ((m.getModifiers() & Modifier.STATIC) != Modifier.STATIC) { + throw new JDOException( + "PMF class " + + pmfClass.getName() + + " method 'getPersistenceManagerFactory' is not static"); + } + + return m; + } catch (SecurityException e) { + throw new JDOException( + "Cannot get method 'getPersistenceManagerFactory' from PMF class " + + pmfClass.getName(), e); + } catch (NoSuchMethodException e) { + throw new JDOException( + "No method 'getPersistenceManagerFactory' from PMF class " + + pmfClass.getName(), e); + } } - } - - protected void invokeGetPMF(Object... args) throws Exception { - Method getPMF = getStaticGetPMFMethod(); - getPMF.invoke(null, args); - } - - public void testUnknownStandardProperty() { - Properties p = new Properties(); - p.setProperty("javax.jdo.unknown.standard.property", "value"); - try { - invokeGetPMF(p); - fail( - "testUnknownStandardProperty should result in JDOUserException. " - + "No exception was thrown."); - } catch (InvocationTargetException ite) { - Throwable cause = ite.getCause(); - if (cause != null && cause instanceof JDOUserException) { - // :) - } else { - throw new JDOException("PMF threw " + cause + " instead of JDOException"); - } - } catch (Exception e) { - throw new JDOException( - "failed to invoke static getPersistenceManagerFactory(Map) method on PMF class", e); + + protected void invokeGetPMF(Object... args) throws Exception { + Method getPMF = getStaticGetPMFMethod(); + getPMF.invoke(null, args); } - } - - public void testUnknownStandardProperties() { - Properties p = new Properties(); - p.setProperty("javax.jdo.unknown.standard.property.1", "value"); - p.setProperty("javax.jdo.unknown.standard.property.2", "value"); - - JDOUserException x = null; - - try { - invokeGetPMF(p); - fail( - "testUnknownStandardProperties should result in JDOUserException. " - + "No exception was thrown."); - } catch (InvocationTargetException ite) { - Throwable cause = ite.getCause(); - if (cause != null && cause instanceof JDOUserException) { - x = (JDOUserException) cause; - } else { - throw new JDOException("PMF threw " + cause + " instead of JDOException"); - } - } catch (Exception e) { - throw new JDOException( - "failed to invoke static getPersistenceManagerFactory(Map) method on PMF class", e); + + public void testUnknownStandardProperty() { + Properties p = new Properties(); + p.setProperty("javax.jdo.unknown.standard.property", "value"); + try { + invokeGetPMF(p); + fail("testUnknownStandardProperty should result in JDOUserException. " + + "No exception was thrown."); + } catch (InvocationTargetException ite) { + Throwable cause = ite.getCause(); + if (cause != null && cause instanceof JDOUserException) { + // :) + } else { + throw new JDOException("PMF threw " + cause + " instead of JDOException"); + } + } catch (Exception e) { + throw new JDOException( + "failed to invoke static getPersistenceManagerFactory(Map) method on PMF class", + e); + } } - Throwable[] nesteds = x.getNestedExceptions(); + public void testUnknownStandardProperties() { + Properties p = new Properties(); + p.setProperty("javax.jdo.unknown.standard.property.1", "value"); + p.setProperty("javax.jdo.unknown.standard.property.2", "value"); + + JDOUserException x = null; + + try { + invokeGetPMF(p); + fail("testUnknownStandardProperties should result in JDOUserException. " + + "No exception was thrown."); + } catch (InvocationTargetException ite) { + Throwable cause = ite.getCause(); + if (cause != null && cause instanceof JDOUserException) { + x = (JDOUserException) cause; + } else { + throw new JDOException("PMF threw " + cause + " instead of JDOException"); + } + } catch (Exception e) { + throw new JDOException( + "failed to invoke static getPersistenceManagerFactory(Map) method on PMF class", + e); + } + + Throwable[] nesteds = x.getNestedExceptions(); - assertNotNull(nesteds); - assertEquals("should have been 2 nested exceptions", 2, nesteds.length); - for (int i = 0; i < nesteds.length; i++) { - Throwable t = nesteds[i]; - assertTrue( - "nested exception " + i + " should have been JDOUserException", - t instanceof JDOUserException); + assertNotNull(nesteds); + assertEquals("should have been 2 nested exceptions", 2, nesteds.length); + for (int i = 0; i < nesteds.length; i++) { + Throwable t = nesteds[i]; + assertTrue("nested exception " + i + + " should have been JDOUserException", + t instanceof JDOUserException); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/metadata/GetMetadataTest.java b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/metadata/GetMetadataTest.java index 53ebdd9e7..ae401b271 100644 --- a/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/metadata/GetMetadataTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/api/persistencemanagerfactory/metadata/GetMetadataTest.java @@ -5,16 +5,17 @@ * 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 + * + * 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.jdo.tck.api.persistencemanagerfactory.metadata; import javax.jdo.metadata.ColumnMetadata; @@ -22,103 +23,107 @@ import javax.jdo.metadata.Metadata; import javax.jdo.metadata.PackageMetadata; import javax.jdo.metadata.TypeMetadata; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title:Metadata Test
    - * Keywords:
    - * Assertion IDs: A11.10-1
    - * Assertion Description: Method to return the metadata object for the specified - * class/interface, if there is metadata defined for that class/interface. If the parameter is null, - * null is returned. If there is no metadata for the specified class/interface then null will be - * returned. + *Title:Metadata Test + *
    + *Keywords: + *
    + *Assertion IDs: A11.10-1 + *
    + *Assertion Description: + * Method to return the metadata object for the specified class/interface, if there is + * metadata defined for that class/interface. + * If the parameter is null, null is returned. + * If there is no metadata for the specified class/interface then null will be returned. */ -public class GetMetadataTest extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A11.10-1 (getMetadata) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetMetadataTest.class); - } - - /** test getMetadata with null class name */ - public void testNullParameter() { - pm = getPM(); - String className = null; - TypeMetadata metadata = pmf.getMetadata(className); - assertNull(ASSERTION_FAILED + "metadata should return null if null parameter", metadata); - } - - /** test getMetadata with concrete class name */ - public void testConcreteClassName() { - pm = getPM(); - String className = "org.apache.jdo.tck.pc.company.PartTimeEmployee"; - TypeMetadata metadata = pmf.getMetadata(className); - assertNotNull( - ASSERTION_FAILED + "metadata must not be null for abstract class " + className, metadata); - Metadata parent = metadata.getParent(); - assertNotNull( - ASSERTION_FAILED + "parent metadata must not be null for concrete class " + className, - parent); - String name = metadata.getName(); - String packageName = ((PackageMetadata) parent).getName(); - assertEquals( - ASSERTION_FAILED + "metadata name and class name must match.", - className, - packageName + "." + name); - } +public class GetMetadataTest extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.10-1 (getMetadata) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetMetadataTest.class); + } + + /** test getMetadata with null class name*/ + public void testNullParameter() { + pm = getPM(); + String className = null; + TypeMetadata metadata = pmf.getMetadata(className); + assertNull(ASSERTION_FAILED + + "metadata should return null if null parameter", metadata); + } - /** test getMetadata with abstract class name */ - public void testAbstractClassName() { - pm = getPM(); - String className = "org.apache.jdo.tck.pc.company.Employee"; - TypeMetadata metadata = pmf.getMetadata(className); - assertNotNull( - ASSERTION_FAILED + "metadata must not be null for abstract class " + className, metadata); - Metadata parent = metadata.getParent(); - assertNotNull( - ASSERTION_FAILED + "parent metadata must not be null for abstract class " + className, - parent); - String name = metadata.getName(); - String packageName = ((PackageMetadata) parent).getName(); - assertEquals( - ASSERTION_FAILED + "metadata name and class name must match.", - className, - packageName + "." + name); - } + /** test getMetadata with concrete class name*/ + public void testConcreteClassName() { + pm = getPM(); + String className = "org.apache.jdo.tck.pc.company.PartTimeEmployee"; + TypeMetadata metadata = pmf.getMetadata(className); + assertNotNull(ASSERTION_FAILED + + "metadata must not be null for abstract class " + className, metadata); + Metadata parent = metadata.getParent(); + assertNotNull(ASSERTION_FAILED + + "parent metadata must not be null for concrete class " + className, parent); + String name = metadata.getName(); + String packageName = ((PackageMetadata)parent).getName(); + assertEquals(ASSERTION_FAILED + + "metadata name and class name must match.", className, packageName + "." + name); + } - /** test getMetadata with invalid class name */ - public void testInvalidName() { - pm = getPM(); - String className = "org.apache.jdo.tck.pc.company.Bogus"; - TypeMetadata metadata = pmf.getMetadata(className); - assertNull(ASSERTION_FAILED + "metadata should return null if unknown parameter", metadata); - } + /** test getMetadata with abstract class name*/ + public void testAbstractClassName() { + pm = getPM(); + String className = "org.apache.jdo.tck.pc.company.Employee"; + TypeMetadata metadata = pmf.getMetadata(className); + assertNotNull(ASSERTION_FAILED + + "metadata must not be null for abstract class " + className, metadata); + Metadata parent = metadata.getParent(); + assertNotNull(ASSERTION_FAILED + + "parent metadata must not be null for abstract class " + className, parent); + String name = metadata.getName(); + String packageName = ((PackageMetadata)parent).getName(); + assertEquals(ASSERTION_FAILED + + "metadata name and class name must match.", className, packageName + "." + name); + } - /** dump the contents of this metadata */ - @SuppressWarnings("unused") - private void dump(TypeMetadata typeMetadata) { - StringBuilder buffer = new StringBuilder("Metadata for " + typeMetadata.getName()); - buffer.append(" identityType: " + typeMetadata.getIdentityType()); - MemberMetadata[] members = typeMetadata.getMembers(); - if (members != null) { - for (MemberMetadata memberMetadata : members) { - buffer.append(" member: " + memberMetadata.getName()); - } + /** test getMetadata with invalid class name*/ + public void testInvalidName() { + pm = getPM(); + String className = "org.apache.jdo.tck.pc.company.Bogus"; + TypeMetadata metadata = pmf.getMetadata(className); + assertNull(ASSERTION_FAILED + + "metadata should return null if unknown parameter", metadata); } - ColumnMetadata[] columns = typeMetadata.getColumns(); - if (columns != null) { - for (ColumnMetadata columnMetadata : columns) { - buffer.append("ColumnMetadata for " + columnMetadata.getName()); - } + + /** dump the contents of this metadata */ + @SuppressWarnings("unused") + private void dump(TypeMetadata typeMetadata) { + StringBuilder buffer = new StringBuilder("Metadata for " + typeMetadata.getName()); + buffer.append(" identityType: " + typeMetadata.getIdentityType()); + MemberMetadata[] members = typeMetadata.getMembers(); + if (members != null) { + for (MemberMetadata memberMetadata: members) { + buffer.append(" member: " + memberMetadata.getName()); + } + } + ColumnMetadata[] columns = typeMetadata.getColumns(); + if (columns != null) { + for (ColumnMetadata columnMetadata: columns) { + buffer.append("ColumnMetadata for " + columnMetadata.getName()); + } + } + System.out.println(buffer.toString()); } - System.out.println(buffer.toString()); - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/enhancement/EnhancerTest.java b/tck/src/main/java/org/apache/jdo/tck/enhancement/EnhancerTest.java index 22290204a..c5cbc53da 100644 --- a/tck/src/main/java/org/apache/jdo/tck/enhancement/EnhancerTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/enhancement/EnhancerTest.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -29,76 +29,83 @@ import java.util.List; import java.util.Properties; import java.util.StringTokenizer; + import org.apache.jdo.tck.JDO_Test; /** - * @author Craig Russell + * + * @author Craig Russell * @version 1.0 */ public abstract class EnhancerTest extends JDO_Test { - /** Creates new EnhancerTest */ - public EnhancerTest() {} - - /** - * @param resourceName name of teh resource - * @return Properties object - */ - protected Properties getProperties(String resourceName) { - Properties props = null; - try { - InputStream in = this.getClass().getClassLoader().getResourceAsStream(resourceName); - props = new Properties(); - props.load(in); - } catch (Exception ex) { - ex.printStackTrace(); - fail("EnhancerTest:", "Error loading properties " + resourceName + " exception " + ex); + /** Creates new EnhancerTest */ + public EnhancerTest() { } - return props; - } - /** - * @param packageName package name - * @param fullyQualifiedClassNameList list of class names - */ - protected abstract void runTestOnePackage(String packageName, List fullyQualifiedClassNameList); - - /** - * @param packageName package name - * @param className class name - * @return converted class name - */ - protected String convertClassName(String packageName, String className) { - return packageName + "." + className; - } - - /** */ - void runTestAllPackages() { - // First, get classes to test from properties file. - Properties classesToTest = getProperties("enhancement-test.properties"); // NOI18N - - Enumeration enumeration = classesToTest.propertyNames(); - int numberOfPackages = 0; + /** + * + * @param resourceName name of teh resource + * @return Properties object + */ + protected Properties getProperties(String resourceName) { + Properties props = null; + try { + InputStream in = this.getClass().getClassLoader().getResourceAsStream(resourceName); + props = new Properties(); + props.load(in); + } catch (Exception ex) { + ex.printStackTrace(); + fail("EnhancerTest:", + "Error loading properties " + resourceName + " exception " + ex); + } + return props; + } + + /** + * + * @param packageName package name + * @param fullyQualifiedClassNameList list of class names + */ + protected abstract void runTestOnePackage (String packageName, List fullyQualifiedClassNameList); + + /** + * + * @param packageName package name + * @param className class name + * @return converted class name + */ + protected String convertClassName (String packageName, String className) { + return packageName + "." + className; + } - // Each key is a package name; the value is a list of class names to test. - while (enumeration.hasMoreElements()) { - ++numberOfPackages; - String packageName = (String) enumeration.nextElement(); - if (debug) logger.debug("EnhancerTest Package: " + packageName); - String classNames = (String) classesToTest.get(packageName); - if (debug) logger.debug("EnhancerTest Classes: " + classNames); - StringTokenizer st = new StringTokenizer(classNames, " ,"); - ArrayList classNameList = new ArrayList(); - // Each entry is a list of class names separated by comma or space - while (st.hasMoreTokens()) { - String className = st.nextToken(); - String listEntry = convertClassName(packageName, className); - classNameList.add(listEntry); - if (debug) logger.debug("EnhancerTest Class: " + className); - } - runTestOnePackage(packageName, classNameList); + /** */ + void runTestAllPackages() { + // First, get classes to test from properties file. + Properties classesToTest = getProperties("enhancement-test.properties"); //NOI18N + + Enumeration enumeration = classesToTest.propertyNames(); + int numberOfPackages = 0; + + // Each key is a package name; the value is a list of class names to test. + while (enumeration.hasMoreElements()) { + ++numberOfPackages; + String packageName = (String) enumeration.nextElement(); + if (debug) logger.debug("EnhancerTest Package: " + packageName); + String classNames = (String) classesToTest.get(packageName); + if (debug) logger.debug("EnhancerTest Classes: " + classNames); + StringTokenizer st = new StringTokenizer(classNames, " ,"); + ArrayList classNameList = new ArrayList(); + // Each entry is a list of class names separated by comma or space + while (st.hasMoreTokens()) { + String className = st.nextToken(); + String listEntry = convertClassName(packageName, className); + classNameList.add (listEntry); + if (debug) logger.debug("EnhancerTest Class: " + className); + } + runTestOnePackage (packageName, classNameList); + } + if (debug) logger.debug("EnhancerTest numberOfPackages: " + numberOfPackages); + return; } - if (debug) logger.debug("EnhancerTest numberOfPackages: " + numberOfPackages); - return; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/extents/AutoCloseable.java b/tck/src/main/java/org/apache/jdo/tck/extents/AutoCloseable.java index 0a3ba137c..13ea70f46 100644 --- a/tck/src/main/java/org/apache/jdo/tck/extents/AutoCloseable.java +++ b/tck/src/main/java/org/apache/jdo/tck/extents/AutoCloseable.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,137 +19,149 @@ import java.util.Iterator; import java.util.NoSuchElementException; + import javax.jdo.Extent; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.pc.company.Department; + +import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.pc.company.Department; /** - * Title: AutoCloseable
    - * Keywords: exception
    - * Assertion IDs: A12.6 ?.
    - * Assertion Description: In a non-managed environment, if the extent is created with - * try-with-resources all results of execute(...) methods on this query instance are automatically + *Title: AutoCloseable + *
    + *Keywords: exception + *
    + *Assertion IDs: A12.6 ?. + *
    + *Assertion Description: + * In a non-managed environment, if the extent is created with try-with-resources + * all results of execute(...) methods on this query instance are automatically * closed at the end of that block and all resources associated with it are released. */ public class AutoCloseable extends ExtentTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A12.6-? (AutoCloseable) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(AutoCloseable.class); + } - /** */ - private static final String ASSERTION_FAILED = "Assertion A12.6-? (AutoCloseable) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(AutoCloseable.class); - } - - /** - * This methods creates an extent instance with try-with-resources and checks that an iterator for - * the query result is not accessible after the block. - */ - public void testTryWithResource() { - - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - - try { - tx.begin(); - - Extent extent = null; - Iterator iterator = null; - try (Extent extent1 = pm.getExtent(Department.class)) { - extent = extent1; - iterator = extent1.iterator(); - if (!iterator.hasNext()) { - fail(ASSERTION_FAILED, "(1) Open extent iterator should have elements."); + /** + * This methods creates an extent instance with try-with-resources and + * checks that an iterator for the query result is not accessible after the block. + */ + public void testTryWithResource() { + + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + + try { + tx.begin(); + + Extent extent = null; + Iterator iterator = null; + try (Extent extent1 = pm.getExtent(Department.class)) { + extent = extent1; + iterator = extent1.iterator(); + if (!iterator.hasNext()) { + fail(ASSERTION_FAILED, "(1) Open extent iterator should have elements."); + } + } catch (Exception ex) { + fail(ASSERTION_FAILED, "(2) Unexpected exception " + ex); + } + + // check iterator retrieved in try-with-resource block + if (iterator.hasNext()) { + fail(ASSERTION_FAILED, + "(3) Closed extent iterator should return false on hasNext()."); + } + try { + Department next = iterator.next(); + fail(ASSERTION_FAILED, + "(4) Closed extent iterator should throw NoSuchElementException on next()."); + } catch (NoSuchElementException ex) { + // expected exception + } + + Iterator iterator2 = extent.iterator(); + if (!iterator2.hasNext()) { + fail(ASSERTION_FAILED, "(5) extent should be usable and should have elements."); + } + + tx.commit(); + } finally { + if (tx != null && tx.isActive()) { + tx.rollback(); + } } - } catch (Exception ex) { - fail(ASSERTION_FAILED, "(2) Unexpected exception " + ex); - } - - // check iterator retrieved in try-with-resource block - if (iterator.hasNext()) { - fail(ASSERTION_FAILED, "(3) Closed extent iterator should return false on hasNext()."); - } - try { - Department next = iterator.next(); - fail( - ASSERTION_FAILED, - "(4) Closed extent iterator should throw NoSuchElementException on next()."); - } catch (NoSuchElementException ex) { - // expected exception - } - - Iterator iterator2 = extent.iterator(); - if (!iterator2.hasNext()) { - fail(ASSERTION_FAILED, "(5) extent should be usable and should have elements."); - } - - tx.commit(); - } finally { - if (tx != null && tx.isActive()) { - tx.rollback(); - } } - } - - /** - * This methods creates an extent instance with try-with-resources and checks that an iterator for - * the query result is not accessible after the block, if the block is ended with an exception. - */ - public void testTryWithResourceThrowingException() { - - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - - try { - tx.begin(); - - Extent extent = null; - Iterator iterator = null; - try (Extent extent1 = pm.getExtent(Department.class)) { - extent = extent1; - iterator = extent1.iterator(); - if (!iterator.hasNext()) { - fail(ASSERTION_FAILED, "(1) Open extent iterator should have elements."); + + /** + * This methods creates an extent instance with try-with-resources and + * checks that an iterator for the query result is not accessible after the block, + * if the block is ended with an exception. + */ + public void testTryWithResourceThrowingException() { + + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + + try { + tx.begin(); + + Extent extent = null; + Iterator iterator = null; + try (Extent extent1 = pm.getExtent(Department.class)) { + extent = extent1; + iterator = extent1.iterator(); + if (!iterator.hasNext()) { + fail(ASSERTION_FAILED, "(1) Open extent iterator should have elements."); + } + throw new DummyException(); + } catch (DummyException ex) { + // expected exception + } catch (Exception ex) { + fail(ASSERTION_FAILED, "(2) Unexpected exception " + ex); + } + + // check iterator retrieved in try-with-resource block + if (iterator.hasNext()) { + fail(ASSERTION_FAILED, + "(3) Closed extent iterator should return false on hasNext()."); + } + try { + Department next = iterator.next(); + fail(ASSERTION_FAILED, + "(4) Closed extent iterator should throw NoSuchElementException on next()."); + } catch (NoSuchElementException ex) { + // expected exception + } + + Iterator iterator2 = extent.iterator(); + if (!iterator2.hasNext()) { + fail(ASSERTION_FAILED, "(5) extent should be usable and should have elements."); + } + + tx.commit(); + } finally { + if (tx != null && tx.isActive()) { + tx.rollback(); + } } - throw new DummyException(); - } catch (DummyException ex) { - // expected exception - } catch (Exception ex) { - fail(ASSERTION_FAILED, "(2) Unexpected exception " + ex); - } - - // check iterator retrieved in try-with-resource block - if (iterator.hasNext()) { - fail(ASSERTION_FAILED, "(3) Closed extent iterator should return false on hasNext()."); - } - try { - Department next = iterator.next(); - fail( - ASSERTION_FAILED, - "(4) Closed extent iterator should throw NoSuchElementException on next()."); - } catch (NoSuchElementException ex) { - // expected exception - } - - Iterator iterator2 = extent.iterator(); - if (!iterator2.hasNext()) { - fail(ASSERTION_FAILED, "(5) extent should be usable and should have elements."); - } - - tx.commit(); - } finally { - if (tx != null && tx.isActive()) { - tx.rollback(); - } } - } - /** DummyException used in method testTryWithResourceThrowingException. */ - private static final class DummyException extends Exception {} + /** + * DummyException used in method testTryWithResourceThrowingException. + */ + private static final class DummyException extends Exception {} + } diff --git a/tck/src/main/java/org/apache/jdo/tck/extents/CloseAll.java b/tck/src/main/java/org/apache/jdo/tck/extents/CloseAll.java index 3d1584610..a414bbb10 100644 --- a/tck/src/main/java/org/apache/jdo/tck/extents/CloseAll.java +++ b/tck/src/main/java/org/apache/jdo/tck/extents/CloseAll.java @@ -5,67 +5,81 @@ * 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 + * + * 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.jdo.tck.extents; import java.util.Iterator; + import javax.jdo.Extent; + import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: CloseAll
    - * Keywords: extent
    - * Assertion ID: A15.3-12.
    - * Assertion Description: After a call to Extent.closeAll(), all iterators - * acquired from this Extent will return false to hasNext(). + *Title: CloseAll + *
    + *Keywords: extent + *
    + *Assertion ID: A15.3-12. + *
    + *Assertion Description: +After a call to Extent.closeAll(), all iterators acquired from this +Extent will return false to hasNext(). + */ -public class CloseAll extends ExtentTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A15.3-12 (CloseAll) failed: "; +public class CloseAll extends ExtentTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CloseAll.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A15.3-12 (CloseAll) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CloseAll.class); + } - /** */ - public void test() { - try { - beginTransaction(); - Extent ex = getPM().getExtent(Employee.class, true); - Iterator it1 = ex.iterator(); - deleteEmployee((Employee) it1.next()); - Iterator it2 = ex.iterator(); - addEmployee(); - Iterator it3 = ex.iterator(); - ex.closeAll(); - if (it1.hasNext()) { - fail(ASSERTION_FAILED, "After extent.closeAll() iterator1.hasNext(): " + it1.hasNext()); - } - if (it2.hasNext()) { - fail(ASSERTION_FAILED, "After extent.closeAll() iterator2.hasNext(): " + it2.hasNext()); - } - if (it3.hasNext()) { - fail(ASSERTION_FAILED, "After extent.closeAll() iterator3.hasNext(): " + it3.hasNext()); - } - if (debug) logger.debug("Assertion A15.3-12 passed"); - } finally { - rollbackTransaction(); + /** */ + public void test() { + try { + beginTransaction(); + Extent ex = getPM().getExtent (Employee.class, true); + Iterator it1 = ex.iterator(); + deleteEmployee((Employee)it1.next()); + Iterator it2 = ex.iterator(); + addEmployee(); + Iterator it3 = ex.iterator(); + ex.closeAll(); + if (it1.hasNext()) { + fail(ASSERTION_FAILED, + "After extent.closeAll() iterator1.hasNext(): " + it1.hasNext()); + } + if (it2.hasNext()) { + fail(ASSERTION_FAILED, + "After extent.closeAll() iterator2.hasNext(): " + it2.hasNext()); + } + if (it3.hasNext()) { + fail(ASSERTION_FAILED, + "After extent.closeAll() iterator3.hasNext(): " + it3.hasNext()); + } + if (debug) logger.debug("Assertion A15.3-12 passed"); + } + finally { + rollbackTransaction(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/extents/CloseOfExtentIteratorIsIteratorSpecific.java b/tck/src/main/java/org/apache/jdo/tck/extents/CloseOfExtentIteratorIsIteratorSpecific.java index 695e3aeac..ff34408d8 100644 --- a/tck/src/main/java/org/apache/jdo/tck/extents/CloseOfExtentIteratorIsIteratorSpecific.java +++ b/tck/src/main/java/org/apache/jdo/tck/extents/CloseOfExtentIteratorIsIteratorSpecific.java @@ -5,70 +5,76 @@ * 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 + * + * 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.jdo.tck.extents; import java.util.Collection; import java.util.Iterator; + import javax.jdo.Extent; import javax.jdo.Query; + import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Close of Extent Iterator is Iterator Specific
    - * Keywords: extent
    - * Assertion ID: A15.3-11.
    - * Assertion Description: After a call to Extent.close(Iterator i), the - * Extent itself can still be used to acquire other iterators and can be used as the - * Extent for queries. - */ -public class CloseOfExtentIteratorIsIteratorSpecific extends ExtentTest { + *Title: Close of Extent Iterator is Iterator Specific + *
    + *Keywords: extent + *
    + *Assertion ID: A15.3-11. + *
    + *Assertion Description: +After a call to Extent.close(Iterator i), +the Extent itself can still be used to acquire other +iterators and can be used as the Extent for queries. - /** */ - private static final String ASSERTION_FAILED = - "Assertion A15.3-11 (CloseOfExtentIteratorIsIteratorSpecific) failed: "; + */ - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CloseOfExtentIteratorIsIteratorSpecific.class); - } +public class CloseOfExtentIteratorIsIteratorSpecific extends ExtentTest { - /** */ - public void test() { - Extent ex = getExtent(); - beginTransaction(); - Iterator it1 = ex.iterator(); - ex.close(it1); - int count = countIterator(ex.iterator()); - if (count != 2) { - fail( - ASSERTION_FAILED, - "iterating Employees after close of first iterator; counted " - + count - + " instances; should be 2"); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A15.3-11 (CloseOfExtentIteratorIsIteratorSpecific) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CloseOfExtentIteratorIsIteratorSpecific.class); } - Query q = getPM().newQuery(ex); - Collection c = (Collection) q.execute(); - int count2 = countIterator(c.iterator()); - commitTransaction(); - if (count2 != 2) { - fail( - ASSERTION_FAILED, - "in query after closing iterator; counted " + count2 + " instances; should be 2"); + + /** */ + public void test() { + Extent ex = getExtent(); + beginTransaction(); + Iterator it1 = ex.iterator(); + ex.close(it1); + int count = countIterator(ex.iterator()); + if (count != 2) { + fail(ASSERTION_FAILED, + "iterating Employees after close of first iterator; counted " + count + " instances; should be 2"); + } + Query q = getPM().newQuery(ex); + Collection c = (Collection)q.execute(); + int count2 = countIterator(c.iterator()); + commitTransaction(); + if (count2 != 2) { + fail(ASSERTION_FAILED, + "in query after closing iterator; counted " + count2 + " instances; should be 2"); + } + if (debug) logger.debug("Assertion A15.3-11 passed"); } - if (debug) logger.debug("Assertion A15.3-11 passed"); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/extents/ExtentTest.java b/tck/src/main/java/org/apache/jdo/tck/extents/ExtentTest.java index ab8494a07..95c7f8046 100644 --- a/tck/src/main/java/org/apache/jdo/tck/extents/ExtentTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/extents/ExtentTest.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -24,10 +24,12 @@ import java.util.HashSet; import java.util.Iterator; import java.util.TimeZone; + import javax.jdo.Extent; import javax.jdo.JDOFatalInternalException; import javax.jdo.PersistenceManager; import javax.jdo.PersistenceManagerFactory; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.Address; import org.apache.jdo.tck.pc.company.Company; @@ -40,248 +42,262 @@ import org.apache.jdo.tck.pc.company.Project; /** - * @author Craig Russell + * + * @author Craig Russell * @version 1.0 */ abstract class ExtentTest extends JDO_Test { - protected Class extentClass = Employee.class; - protected Company company; - protected Object companyOID; - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(DentalInsurance.class); - addTearDownClass(MedicalInsurance.class); - addTearDownClass(Project.class); - addTearDownClass(FullTimeEmployee.class); - addTearDownClass(PartTimeEmployee.class); - addTearDownClass(Employee.class); - addTearDownClass(Department.class); - addTearDownClass(Company.class); - } - - /** Creates new ExtentTest */ - public ExtentTest() { - if (PMFProperties == null) { - PMFProperties = System.getProperty("user.home") + "/.jdo/PMFProperties.properties"; - if (PMFProperties == null) - System.out.println( - "Please specify PMF properties in {user.home}/.jdo/PMFProperties.properties"); + protected Class extentClass = Employee.class; + protected Company company; + protected Object companyOID; + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(DentalInsurance.class); + addTearDownClass(MedicalInsurance.class); + addTearDownClass(Project.class); + addTearDownClass(FullTimeEmployee.class); + addTearDownClass(PartTimeEmployee.class); + addTearDownClass(Employee.class); + addTearDownClass(Department.class); + addTearDownClass(Company.class); } - } - - /** */ - protected void checkPM() { - try { - // Don't use beginTransaction() because this calls getPM() which calls checkPM()! - pm.currentTransaction().begin(); - Extent ex = getPM().getExtent(Company.class, false); - int count = countIterator(ex.iterator()); - pm.currentTransaction().commit(); - if (count == 1) { - if (debug) logger.debug("Found company"); - return; - } - } catch (Exception e) { - e.printStackTrace(System.err); - System.err.println("Failed to find Company; initializing DB"); + + /** Creates new ExtentTest */ + public ExtentTest() { + if (PMFProperties == null) + { + PMFProperties = System.getProperty("user.home") + "/.jdo/PMFProperties.properties"; + if (PMFProperties == null) + System.out.println ("Please specify PMF properties in {user.home}/.jdo/PMFProperties.properties"); + } } - initDB(); - } - - /** */ - protected void initDB() { - HashSet h; - Address addr1 = new Address(7001L, "18 Network Circle", "Santa Clara", "CA", "94455", "USA"); - company = new Company(1L, "Sun Microsystems", new Date(), addr1); - GregorianCalendar born = new GregorianCalendar(TimeZone.getTimeZone("America/Los_Angeles")); - GregorianCalendar hired = new GregorianCalendar(TimeZone.getTimeZone("America/Los_Angeles")); - - born.set(1969, 7, 20); - hired.set(1982, 5, 5); - Address addr2 = new Address(7002L, "43 Sematery Drive", "Woodside", "CA", "94320", "USA"); - Employee scott = - new FullTimeEmployee( - 3001L, "Scott", "McNealy", "G", born.getTime(), addr2, hired.getTime(), 200000.0); - born.set(1960, 4, 8); - hired.set(1985, 2, 3); - Address addr3 = new Address(7003L, "1298 Wanderlust Road", "Pleasanton", "CA", "95560", "USA"); - Employee ed = - new PartTimeEmployee( - 3002L, "Ed", "Zander", null, born.getTime(), addr3, hired.getTime(), 400000.0); - scott.addToTeam(ed); - - // Set up their departments. - Department board = new Department(2001L, "board", company); - h = new HashSet(); - h.add(scott); - board.setEmployees(h); - scott.setDepartment(board); - - company.addDepartment(board); + + /** */ + protected void checkPM() { + try { + // Don't use beginTransaction() because this calls getPM() which calls checkPM()! + pm.currentTransaction().begin(); + Extent ex = getPM().getExtent(Company.class, false); + int count = countIterator(ex.iterator()); + pm.currentTransaction().commit(); + if (count == 1) { + if (debug) logger.debug ("Found company"); + return; + } + } catch (Exception e) { + e.printStackTrace(System.err); + System.err.println ("Failed to find Company; initializing DB"); + } + initDB(); + } + + /** */ + protected void initDB() { + HashSet h; + Address addr1 = new Address (7001L, "18 Network Circle", + "Santa Clara", "CA", "94455", "USA"); + company = new Company (1L, "Sun Microsystems", new Date(), addr1); + GregorianCalendar born = + new GregorianCalendar(TimeZone.getTimeZone("America/Los_Angeles")); + GregorianCalendar hired = + new GregorianCalendar(TimeZone.getTimeZone("America/Los_Angeles")); - Department emg = new Department(2002L, "emg", company); - h = new HashSet(); - h.add(ed); - emg.setEmployees(h); - ed.setDepartment(emg); + born.set(1969, 7, 20); + hired.set(1982, 5, 5); + Address addr2 = new Address (7002L, "43 Sematery Drive", + "Woodside", "CA", "94320", "USA"); + Employee scott = new FullTimeEmployee(3001L, "Scott", "McNealy", "G", + born.getTime(), addr2, + hired.getTime(), 200000.0); + born.set(1960, 4, 8); + hired.set(1985, 2, 3); + Address addr3 = new Address (7003L, "1298 Wanderlust Road", + "Pleasanton", "CA", "95560", "USA"); + Employee ed = new PartTimeEmployee(3002L, "Ed", "Zander", null, + born.getTime(), addr3, + hired.getTime(), 400000.0); + scott.addToTeam(ed); - company.addDepartment(emg); + // Set up their departments. + Department board = + new Department(2001L, "board", company); + h = new HashSet(); + h.add(scott); + board.setEmployees(h); + scott.setDepartment(board); + + company.addDepartment(board); - // Insure these guys - DentalInsurance scottDentalIns = - new DentalInsurance(5001L, "Aetna", scott, new BigDecimal("12000")); - MedicalInsurance scottMedicalIns = new MedicalInsurance(5002L, "Aetna", scott, "PPO"); - DentalInsurance edDentalIns = - new DentalInsurance(5003L, "BlueCross", ed, new BigDecimal("10000")); - MedicalInsurance edMedicalIns = new MedicalInsurance(5004L, "BlueCross", ed, "EPO"); - scott.setDentalInsurance(scottDentalIns); - scott.setMedicalInsurance(scottMedicalIns); - ed.setDentalInsurance(edDentalIns); - ed.setMedicalInsurance(edMedicalIns); + Department emg = new Department(2002L, "emg", company); + h = new HashSet(); + h.add(ed); + emg.setEmployees(h); + ed.setDepartment(emg); + + company.addDepartment(emg); - // Give them some projects to work on. Scott works on both; Ed only - // on one. - Project solaris = new Project(4001L, "Solaris", new BigDecimal(100.375)); - Project sparc = new Project(4002L, "Sparc", new BigDecimal(200.500)); - h = new HashSet(); - h.add(scott); - h.add(ed); - solaris.setMembers(h); // Solaris is worked on by Scott and Ed + // Insure these guys + DentalInsurance scottDentalIns = new DentalInsurance( + 5001L, "Aetna", scott, new BigDecimal("12000")); + MedicalInsurance scottMedicalIns = new MedicalInsurance( + 5002L, "Aetna", scott, "PPO"); + DentalInsurance edDentalIns = new DentalInsurance( + 5003L, "BlueCross", ed, new BigDecimal("10000")); + MedicalInsurance edMedicalIns = new MedicalInsurance( + 5004L, "BlueCross", ed, "EPO"); + scott.setDentalInsurance(scottDentalIns); + scott.setMedicalInsurance(scottMedicalIns); + ed.setDentalInsurance(edDentalIns); + ed.setMedicalInsurance(edMedicalIns); - h = new HashSet(); - h.add(scott); - sparc.setMembers(h); // Sparc is worked on by Scott + // Give them some projects to work on. Scott works on both; Ed only + // on one. + Project solaris = new Project(4001L, "Solaris", new BigDecimal(100.375)); + Project sparc = new Project(4002L, "Sparc", new BigDecimal(200.500)); + h = new HashSet(); + h.add(scott); + h.add(ed); + solaris.setMembers(h); // Solaris is worked on by Scott and Ed - h = new HashSet(); - h.add(solaris); - h.add(sparc); - scott.setProjects(h); // Scott works on Solaris and Sparc + h = new HashSet(); + h.add(scott); + sparc.setMembers(h); // Sparc is worked on by Scott + + h = new HashSet(); + h.add(solaris); + h.add(sparc); + scott.setProjects(h); // Scott works on Solaris and Sparc - h = new HashSet(); - h.add(solaris); - ed.setProjects(h); // Ed works on Solaris + h = new HashSet(); + h.add(solaris); + ed.setProjects(h); // Ed works on Solaris + + /* Now put all of these into the database + */ + pm.currentTransaction().begin(); + pm.makePersistent (company); + pm.currentTransaction().commit(); + // System.out.println ("Company OID: " + pm.getObjectId(company)); + } - /* Now put all of these into the database + /** + * + * @return new employee */ - pm.currentTransaction().begin(); - pm.makePersistent(company); - pm.currentTransaction().commit(); - // System.out.println ("Company OID: " + pm.getObjectId(company)); - } - - /** - * @return new employee - */ - protected Employee addEmployee() { - Address addr1 = new Address(7004L, "456 Chelsey Lane", "Mountain View", "CA", "94040", "USA"); - Employee emp1 = - new FullTimeEmployee( - 3003L, "First3003", "Last3003", "Middle3003", new Date(), addr1, new Date(), 10000.0); - getPM().makePersistent(emp1); - return emp1; - } - - /** - * @param e employee - */ - protected void deleteEmployee(Employee e) { - getPM().deletePersistent(e); - } - - /** - * @param it iterator - * @return count - */ - protected int countIterator(Iterator it) { - int count = 0; - for (; it.hasNext(); count++, it.next()) - ; - return count; - } - - /** - * @param it iterator - * @return count - */ - protected int printIterator(Iterator it) { - int count = 0; - for (; it.hasNext(); count++) { - System.out.println(it.next().toString()); + protected Employee addEmployee() { + Address addr1 = new Address (7004L, "456 Chelsey Lane", + "Mountain View", "CA", "94040", "USA"); + Employee emp1 = new FullTimeEmployee (3003L, "First3003", "Last3003", "Middle3003", + new Date(), addr1, new Date(), 10000.0); + getPM().makePersistent (emp1); + return emp1; } - return count; - } - /** - * @return extent - */ - protected Extent getExtent() { - return getPM().getExtent(extentClass, true); - } + /** + * + * @param e employee + */ + protected void deleteEmployee(Employee e) { + getPM().deletePersistent (e); + } - /** - * @return OID - */ - protected Object getCompanyOID() { - String companyOIDString = - (String) PMFPropertiesObject.get("org.apache.jdo.tck.extents.CompanyOID"); - String companyOIDClassName = - (String) PMFPropertiesObject.get("org.apache.jdo.tck.extents.CompanyOIDClass"); - if (companyOIDClassName == null) { - companyOIDClassName = "org.apache.jdo.impl.fostore.OID"; + /** + * + * @param it iterator + * @return count + */ + protected int countIterator(Iterator it) { + int count = 0; + for (;it.hasNext();count++, it.next()); + return count; } - try { - Class companyOIDClass = Class.forName(companyOIDClassName); - Constructor companyOIDConstructor = - companyOIDClass.getConstructor(new Class[] {String.class}); - Object companyOID = companyOIDConstructor.newInstance(new Object[] {companyOIDString}); - return companyOID; - } catch (Exception ex) { - throw new JDOFatalInternalException( - "PMFProperties must be configured with the following properties\n" - + "\torg.apache.jdo.tck.extents.CompanyOID = \n" - + "\torg.apache.jdo.tck.extents.CompanyOIDClass = \n", - ex); + + /** + * @param it iterator + * @return count + */ + protected int printIterator(Iterator it) { + int count = 0; + for (;it.hasNext();count++) { + System.out.println (it.next().toString()); + } + return count; } - } - /** - * @return PersistenceManager - */ - protected PersistenceManager getPM() { - if (pm == null) { - pm = getPMF().getPersistenceManager(); - checkPM(); + /** + * + * @return extent + */ + protected Extent getExtent() { + return getPM().getExtent(extentClass, true); } - return pm; - } - /** - * @return PersistenceManagerFactory - */ - public PersistenceManagerFactory getPMF() { - if (pmf == null) { - pmf = super.getPMF(); + /** + * + * @return OID + */ + protected Object getCompanyOID () { + String companyOIDString = (String) + PMFPropertiesObject.get("org.apache.jdo.tck.extents.CompanyOID"); + String companyOIDClassName = (String) + PMFPropertiesObject.get("org.apache.jdo.tck.extents.CompanyOIDClass"); + if (companyOIDClassName == null) { + companyOIDClassName = "org.apache.jdo.impl.fostore.OID"; + } + try { + Class companyOIDClass = Class.forName(companyOIDClassName); + Constructor companyOIDConstructor = companyOIDClass.getConstructor(new Class[] {String.class}); + Object companyOID = companyOIDConstructor.newInstance (new Object[] {companyOIDString}); + return companyOID; + } + catch (Exception ex) { + throw new JDOFatalInternalException ( + "PMFProperties must be configured with the following properties\n" + + "\torg.apache.jdo.tck.extents.CompanyOID = \n" + + "\torg.apache.jdo.tck.extents.CompanyOIDClass = \n", ex); + } } - return pmf; - } - /** */ - protected void beginTransaction() { - getPM().currentTransaction().begin(); - } - - /** */ - protected void commitTransaction() { - getPM().currentTransaction().commit(); - } + /** + * + * @return PersistenceManager + */ + protected PersistenceManager getPM() { + if (pm == null) { + pm = getPMF().getPersistenceManager(); + checkPM(); + } + return pm; + } - /** */ - protected void rollbackTransaction() { - getPM().currentTransaction().rollback(); - } + /** + * + * @return PersistenceManagerFactory + */ + public PersistenceManagerFactory getPMF() { + if (pmf == null) { + pmf = super.getPMF(); + } + return pmf; + } + + /** */ + protected void beginTransaction() { + getPM().currentTransaction().begin(); + } + + /** */ + protected void commitTransaction() { + getPM().currentTransaction().commit(); + } + + /** */ + protected void rollbackTransaction() { + getPM().currentTransaction().rollback(); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/extents/GetCandidateClass.java b/tck/src/main/java/org/apache/jdo/tck/extents/GetCandidateClass.java index dd2c890db..cdef69ac9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/extents/GetCandidateClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/extents/GetCandidateClass.java @@ -5,49 +5,57 @@ * 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 + * + * 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.jdo.tck.extents; import javax.jdo.Extent; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get Candidate Class
    - * Keywords: extent
    - * Assertion ID: A15.3-7.
    - * Assertion Description: Extent.getCandidateClass() returns the class of the - * instances contained in this Extent. + *Title: Get Candidate Class + *
    + *Keywords: extent + *
    + *Assertion ID: A15.3-7. + *
    + *Assertion Description: +Extent.getCandidateClass() returns the class of the instances +contained in this Extent. + */ + public class GetCandidateClass extends ExtentTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A15.3-7 (GetCandidateClass) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetCandidateClass.class); - } - - /** */ - public void test() { - Extent ex = getExtent(); - if (extentClass != ex.getCandidateClass()) { - fail( - ASSERTION_FAILED, - "Candidate class in extent should be: " + extentClass.getClass().getName()); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A15.3-7 (GetCandidateClass) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetCandidateClass.class); + } + + /** */ + public void test() { + Extent ex = getExtent(); + if (extentClass != ex.getCandidateClass()) { + fail(ASSERTION_FAILED, + "Candidate class in extent should be: " + extentClass.getClass().getName()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/extents/GetPersistenceManager.java b/tck/src/main/java/org/apache/jdo/tck/extents/GetPersistenceManager.java index 0bd6c47f8..ed6156085 100644 --- a/tck/src/main/java/org/apache/jdo/tck/extents/GetPersistenceManager.java +++ b/tck/src/main/java/org/apache/jdo/tck/extents/GetPersistenceManager.java @@ -5,51 +5,59 @@ * 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 + * + * 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.jdo.tck.extents; import javax.jdo.Extent; + import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get PersistenceManager
    - * Keywords: extent
    - * Assertion ID: A15.3-8.
    - * Assertion Description: Extent.getPersistenceManager() returns the - * PersistenceManager which created this Extent. + *Title: Get PersistenceManager + *
    + *Keywords: extent + *
    + *Assertion ID: A15.3-8. + *
    + *Assertion Description: +Extent.getPersistenceManager() returns the +PersistenceManager which created this Extent. + */ + public class GetPersistenceManager extends ExtentTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A15.3-8 (GetPersistenceManager) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPersistenceManager.class); - } - - /** */ - public void test() { - Extent ex = getPM().getExtent(Employee.class, true); - if (pm != ex.getPersistenceManager()) { - fail( - ASSERTION_FAILED, - "unexpected pm of extent, expected " + pm + ", got " + ex.getPersistenceManager()); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A15.3-8 (GetPersistenceManager) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPersistenceManager.class); + } + + /** */ + public void test() { + Extent ex = getPM().getExtent (Employee.class, true); + if (pm != ex.getPersistenceManager()) { + fail(ASSERTION_FAILED, + "unexpected pm of extent, expected " + pm + + ", got " + ex.getPersistenceManager()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/extents/HasSubclassesFalse.java b/tck/src/main/java/org/apache/jdo/tck/extents/HasSubclassesFalse.java index 17a1cd646..744a1d635 100644 --- a/tck/src/main/java/org/apache/jdo/tck/extents/HasSubclassesFalse.java +++ b/tck/src/main/java/org/apache/jdo/tck/extents/HasSubclassesFalse.java @@ -5,50 +5,58 @@ * 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 + * + * 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.jdo.tck.extents; import javax.jdo.Extent; + import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Has Subclasses is False
    - * Keywords: extent inheritance
    - * Assertion ID: A15.3-5.
    - * Assertion Description: Extent.hasSubclasses() returns false if - * the extent does not include subclasses. + *Title: Has Subclasses is False + *
    + *Keywords: extent inheritance + *
    + *Assertion ID: A15.3-5. + *
    + *Assertion Description: +Extent.hasSubclasses() returns false +if the extent does not include subclasses. + */ + public class HasSubclassesFalse extends ExtentTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A15.3-5 (HasSubclassesFalse) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(HasSubclassesFalse.class); - } - - /** */ - public void test() { - Extent ex = getPM().getExtent(Employee.class, false); - if (ex.hasSubclasses()) { - fail( - ASSERTION_FAILED, - "ex.hasSubclasses() returned true, but extent was created with subclasses=false."); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A15.3-5 (HasSubclassesFalse) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(HasSubclassesFalse.class); + } + + /** */ + public void test() { + Extent ex = getPM().getExtent (Employee.class, false); + if (ex.hasSubclasses()) { + fail(ASSERTION_FAILED, + "ex.hasSubclasses() returned true, but extent was created with subclasses=false."); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/extents/HasSubclassesTrue.java b/tck/src/main/java/org/apache/jdo/tck/extents/HasSubclassesTrue.java index eeadfd370..321961ea1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/extents/HasSubclassesTrue.java +++ b/tck/src/main/java/org/apache/jdo/tck/extents/HasSubclassesTrue.java @@ -5,50 +5,58 @@ * 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 + * + * 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.jdo.tck.extents; import javax.jdo.Extent; + import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Has Subclasses is True
    - * Keywords: extent inheritance
    - * Assertion ID: A15.3-6.
    - * Assertion Description: Extent.hasSubclasses() returns true if - * the extent includes subclasses. + *Title: Has Subclasses is True + *
    + *Keywords: extent inheritance + *
    + *Assertion ID: A15.3-6. + *
    + *Assertion Description: +Extent.hasSubclasses() returns true +if the extent includes subclasses. + */ + public class HasSubclassesTrue extends ExtentTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A15.3-6 (HasSubclassesTrue) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(HasSubclassesTrue.class); - } - - /** */ - public void test() { - Extent ex = getPM().getExtent(Employee.class, true); - if (!ex.hasSubclasses()) { - fail( - ASSERTION_FAILED, - "ex.hasSubclasses() returned false, but extent was created with subclasses=true."); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A15.3-6 (HasSubclassesTrue) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(HasSubclassesTrue.class); + } + + /** */ + public void test() { + Extent ex = getPM().getExtent (Employee.class, true); + if (!ex.hasSubclasses()) { + fail(ASSERTION_FAILED, + "ex.hasSubclasses() returned false, but extent was created with subclasses=true."); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/extents/InstancesDeletedPriorToIterationNotReturned.java b/tck/src/main/java/org/apache/jdo/tck/extents/InstancesDeletedPriorToIterationNotReturned.java index f0958d4a6..fd8bb7690 100644 --- a/tck/src/main/java/org/apache/jdo/tck/extents/InstancesDeletedPriorToIterationNotReturned.java +++ b/tck/src/main/java/org/apache/jdo/tck/extents/InstancesDeletedPriorToIterationNotReturned.java @@ -5,70 +5,82 @@ * 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 + * + * 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.jdo.tck.extents; import java.util.Iterator; + import javax.jdo.Extent; + import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Instances Deleted Prior to Iteration not Returned
    - * Keywords: extent
    - * Assertion ID: A15.3-3.
    - * Assertion Description: If instances were deleted in the transaction prior to the - * execution of Extent.iterator(), the returned Iterator will not contain - * the instances. - */ -public class InstancesDeletedPriorToIterationNotReturned extends ExtentTest { + *Title: Instances Deleted Prior to Iteration not Returned + *
    + *Keywords: extent + *
    + *Assertion ID: A15.3-3. + *
    + *Assertion Description: +If instances were deleted in the transaction prior to the execution of +Extent.iterator(), the returned Iterator +will not contain the instances. - /** */ - private static final String ASSERTION_FAILED = - "Assertion A15.3-3 (InstancesDeletedPriorToIterationNotReturned) failed: "; + */ - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(InstancesDeletedPriorToIterationNotReturned.class); - } +public class InstancesDeletedPriorToIterationNotReturned extends ExtentTest { - /** */ - public void test() { - try { - beginTransaction(); - getPM().setIgnoreCache(false); - Extent ex = getPM().getExtent(Employee.class, true); - Iterator it1 = ex.iterator(); - deleteEmployee((Employee) it1.next()); - Iterator it2 = ex.iterator(); - int count = countIterator(it2); - rollbackTransaction(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A15.3-3 (InstancesDeletedPriorToIterationNotReturned) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(InstancesDeletedPriorToIterationNotReturned.class); + } - beginTransaction(); - Iterator it3 = ex.iterator(); - int count3 = countIterator(it3); - commitTransaction(); + /** */ + public void test() { + try { + beginTransaction(); + getPM().setIgnoreCache(false); + Extent ex = getPM().getExtent (Employee.class, true); + Iterator it1 = ex.iterator(); + deleteEmployee((Employee)it1.next()); + Iterator it2 = ex.iterator(); + int count = countIterator(it2); + rollbackTransaction(); - if (count != 1) { - fail(ASSERTION_FAILED, "counted " + count + " after delete; should be 1"); - } - if (count3 != 2) { - fail(ASSERTION_FAILED, "counted " + count3 + "after rollback; should be 2"); - } - } finally { + beginTransaction(); + Iterator it3 = ex.iterator(); + int count3 = countIterator(it3); + commitTransaction(); + + if (count != 1) { + fail(ASSERTION_FAILED, + "counted " + count + " after delete; should be 1"); + } + if (count3 != 2) { + fail(ASSERTION_FAILED, + "counted " + count3 + "after rollback; should be 2"); + } + } + finally { + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/extents/InstancesPersistedPriorToIterationReturned.java b/tck/src/main/java/org/apache/jdo/tck/extents/InstancesPersistedPriorToIterationReturned.java index a7d59fcfa..2c137a5e1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/extents/InstancesPersistedPriorToIterationReturned.java +++ b/tck/src/main/java/org/apache/jdo/tck/extents/InstancesPersistedPriorToIterationReturned.java @@ -5,70 +5,82 @@ * 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 + * + * 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.jdo.tck.extents; import java.util.Iterator; + import javax.jdo.Extent; + import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Instances Persisted Prior to Iteration Returned
    - * Keywords: extent
    - * Assertion ID: A15.3-2.
    - * Assertion Description: If instances were made persistent in the transaction prior to the - * execution of Extent.iterator(), the returned Iterator will contain the - * instances. - */ -public class InstancesPersistedPriorToIterationReturned extends ExtentTest { + *Title: Instances Persisted Prior to Iteration Returned + *
    + *Keywords: extent + *
    + *Assertion ID: A15.3-2. + *
    + *Assertion Description: +If instances were made persistent in the transaction prior to the execution of +Extent.iterator(), the returned Iterator +will contain the instances. - /** */ - private static final String ASSERTION_FAILED = - "Assertion A15.3-2 (InstancesPersistedPriorToIterationReturned) failed: "; + */ - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(InstancesPersistedPriorToIterationReturned.class); - } +public class InstancesPersistedPriorToIterationReturned extends ExtentTest { - /** */ - public void test() { + /** */ + private static final String ASSERTION_FAILED = + "Assertion A15.3-2 (InstancesPersistedPriorToIterationReturned) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(InstancesPersistedPriorToIterationReturned.class); + } - try { - beginTransaction(); - getPM().setIgnoreCache(false); - Extent ex = getPM().getExtent(Employee.class, true); - addEmployee(); - Iterator it = ex.iterator(); - int count = countIterator(it); - rollbackTransaction(); + /** */ + public void test() { - beginTransaction(); - Iterator it2 = ex.iterator(); - int count2 = countIterator(it2); - commitTransaction(); + try { + beginTransaction(); + getPM().setIgnoreCache(false); + Extent ex = getPM().getExtent (Employee.class, true); + addEmployee(); + Iterator it = ex.iterator(); + int count = countIterator(it); + rollbackTransaction(); - if (count != 3) { - fail(ASSERTION_FAILED, "Iterator: " + count + " should be 3"); - } - if (count2 != 2) { - fail(ASSERTION_FAILED, "Iterator2: " + count2 + "should be 2"); - } - } finally { + beginTransaction(); + Iterator it2 = ex.iterator(); + int count2 = countIterator(it2); + commitTransaction(); + + if (count != 3) { + fail(ASSERTION_FAILED, + "Iterator: " + count + " should be 3"); + } + if (count2 != 2) { + fail(ASSERTION_FAILED, + "Iterator2: " + count2 + "should be 2"); + } + } + finally { + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/extents/IteratorHasNextFalseAfterExtentClose.java b/tck/src/main/java/org/apache/jdo/tck/extents/IteratorHasNextFalseAfterExtentClose.java index 312dd4e9d..c277cd23d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/extents/IteratorHasNextFalseAfterExtentClose.java +++ b/tck/src/main/java/org/apache/jdo/tck/extents/IteratorHasNextFalseAfterExtentClose.java @@ -5,80 +5,95 @@ * 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 + * + * 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.jdo.tck.extents; import java.util.Iterator; + import javax.jdo.Extent; + import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Iterator HasNext returns False after Extent.close
    - * Keywords: extent
    - * Assertion ID: A15.3-9.
    - * Assertion Description: After a call to Extent.close(Iterator i), the - * parameter Iterator will return false to hasNext(). - */ -public class IteratorHasNextFalseAfterExtentClose extends ExtentTest { + *Title: Iterator HasNext returns False after Extent.close + *
    + *Keywords: extent + *
    + *Assertion ID: A15.3-9. + *
    + *Assertion Description: +After a call to Extent.close(Iterator i), +the parameter Iterator will return false +to hasNext(). - /** */ - private static final String ASSERTION_FAILED = - "Assertion A15.3-9 (IteratorHasNextFalseAfterExtentClose) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IteratorHasNextFalseAfterExtentClose.class); - } + */ - /** */ - public void test() { +public class IteratorHasNextFalseAfterExtentClose extends ExtentTest { - try { - beginTransaction(); - Extent ex = getPM().getExtent(Employee.class, true); - Iterator it1 = ex.iterator(); - deleteEmployee((Employee) it1.next()); - Iterator it2 = ex.iterator(); - addEmployee(); - Iterator it3 = ex.iterator(); - ex.close(it1); - ex.close(it2); - ex.close(it3); - rollbackTransaction(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A15.3-9 (IteratorHasNextFalseAfterExtentClose) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IteratorHasNextFalseAfterExtentClose.class); + } - beginTransaction(); - Iterator it4 = ex.iterator(); - int count4 = countIterator(it4); - rollbackTransaction(); - if (debug) logger.debug("Iterator4 after rollback: " + count4); + /** */ + public void test() { - if (it1.hasNext()) { - fail(ASSERTION_FAILED, "iterator1.hasNext(): " + it1.hasNext()); - } - if (it2.hasNext()) { - fail(ASSERTION_FAILED, "iterator2.hasNext(): " + it2.hasNext()); - } - if (it3.hasNext()) { - fail(ASSERTION_FAILED, "iterator3.hasNext(): " + it3.hasNext()); - } - if (count4 != 2) { - fail(ASSERTION_FAILED, "Iterator " + count4 + " should be 2"); - } - } finally { + try { + beginTransaction(); + Extent ex = getPM().getExtent (Employee.class, true); + Iterator it1 = ex.iterator(); + deleteEmployee((Employee)it1.next()); + Iterator it2 = ex.iterator(); + addEmployee(); + Iterator it3 = ex.iterator(); + ex.close(it1); + ex.close(it2); + ex.close(it3); + rollbackTransaction(); + + beginTransaction(); + Iterator it4 = ex.iterator(); + int count4 = countIterator(it4); + rollbackTransaction(); + if (debug) logger.debug ("Iterator4 after rollback: " + count4); + + if (it1.hasNext()) { + fail(ASSERTION_FAILED, + "iterator1.hasNext(): " + it1.hasNext()); + } + if (it2.hasNext()) { + fail(ASSERTION_FAILED, + "iterator2.hasNext(): " + it2.hasNext()); + } + if (it3.hasNext()) { + fail(ASSERTION_FAILED, + "iterator3.hasNext(): " + it3.hasNext()); + } + if (count4 != 2) { + fail(ASSERTION_FAILED, + "Iterator " + count4 + " should be 2"); + } + } + finally { + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/extents/IteratorMutatingMethods.java b/tck/src/main/java/org/apache/jdo/tck/extents/IteratorMutatingMethods.java index 0410798e6..3f3ddcecd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/extents/IteratorMutatingMethods.java +++ b/tck/src/main/java/org/apache/jdo/tck/extents/IteratorMutatingMethods.java @@ -5,61 +5,71 @@ * 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 + * + * 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.jdo.tck.extents; import java.util.Iterator; + import javax.jdo.Extent; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Iterator Mutating Methods
    - * Keywords: extent exception
    - * Assertion ID: A15.3-4.
    - * Assertion Description: If any mutating method, including the remove method, - * is called on the Iterator returned by Extent.iterator(), an - * UnsupportedOperationException is thrown. + *Title: Iterator Mutating Methods + *
    + *Keywords: extent exception + *
    + *Assertion ID: A15.3-4. + *
    + *Assertion Description: +If any mutating method, including the remove method, +is called on the Iterator returned by Extent.iterator(), +an UnsupportedOperationException is thrown. + */ -public class IteratorMutatingMethods extends ExtentTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A15.3-4 (IteratorMutatingMethods) failed: "; +public class IteratorMutatingMethods extends ExtentTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IteratorMutatingMethods.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A15.3-4 (IteratorMutatingMethods) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IteratorMutatingMethods.class); + } - /** */ - public void test() { - beginTransaction(); - Extent ex = getExtent(); - Iterator it = ex.iterator(); - it.next(); - try { - it.remove(); - fail( - ASSERTION_FAILED, - "extent.iterator().remove() should throw UnsupportedOperationException"); - } catch (UnsupportedOperationException expected) { - // expected exception - if (debug) logger.debug("expected exception " + ex); - } finally { + /** */ + public void test() { + beginTransaction(); + Extent ex = getExtent(); + Iterator it = ex.iterator(); + it.next(); + try { + it.remove(); + fail(ASSERTION_FAILED, + "extent.iterator().remove() should throw UnsupportedOperationException"); + } + catch (UnsupportedOperationException expected) { + // expected exception + if (debug) logger.debug("expected exception " + ex); + } + finally { + } + commitTransaction(); } - commitTransaction(); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/extents/IteratorNextAfterExtentClose.java b/tck/src/main/java/org/apache/jdo/tck/extents/IteratorNextAfterExtentClose.java index 1c71c3df2..3c56efcca 100644 --- a/tck/src/main/java/org/apache/jdo/tck/extents/IteratorNextAfterExtentClose.java +++ b/tck/src/main/java/org/apache/jdo/tck/extents/IteratorNextAfterExtentClose.java @@ -5,91 +5,107 @@ * 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 + * + * 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.jdo.tck.extents; import java.util.Iterator; import java.util.NoSuchElementException; + import javax.jdo.Extent; + import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Iterator Next After Extent Close
    - * Keywords: extent exception
    - * Assertion ID: A15.3-10.
    - * Assertion Description: After a call to Extent.close(Iterator i), the - * parameter Iterator will throw a NoSuchElementException to next() - * . - */ -public class IteratorNextAfterExtentClose extends ExtentTest { + *Title: Iterator Next After Extent Close + *
    + *Keywords: extent exception + *
    + *Assertion ID: A15.3-10. + *
    + *Assertion Description: +After a call to Extent.close(Iterator i), +the parameter Iterator +will throw a NoSuchElementException to next(). - /** */ - private static final String ASSERTION_FAILED = - "Assertion A15.3-10 (IteratorNextAfterExtentClose) failed: "; + */ - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IteratorNextAfterExtentClose.class); - } +public class IteratorNextAfterExtentClose extends ExtentTest { - /** */ - public void test() { - try { - beginTransaction(); - Extent ex = getPM().getExtent(Employee.class, true); - Iterator it1 = ex.iterator(); - deleteEmployee((Employee) it1.next()); - Iterator it2 = ex.iterator(); - addEmployee(); - Iterator it3 = ex.iterator(); - ex.close(it1); - ex.close(it2); - ex.close(it3); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A15.3-10 (IteratorNextAfterExtentClose) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IteratorNextAfterExtentClose.class); + } - try { - tryNext(it1); - tryNext(it2); - tryNext(it3); - rollbackTransaction(); + /** */ + public void test() { - beginTransaction(); - Iterator it4 = ex.iterator(); - int count4 = countIterator(it4); - commitTransaction(); + try { + beginTransaction(); + Extent ex = getPM().getExtent (Employee.class, true); + Iterator it1 = ex.iterator(); + deleteEmployee((Employee)it1.next()); + Iterator it2 = ex.iterator(); + addEmployee(); + Iterator it3 = ex.iterator(); + ex.close(it1); + ex.close(it2); + ex.close(it3); - if (count4 != 2) { - fail(ASSERTION_FAILED, "Iterator4 after rollback: " + count4 + "; should be 2"); - } - } catch (Exception unexpected) { - fail(ASSERTION_FAILED, "unexpected exception " + unexpected); - } - } catch (Exception unexpected) { - fail(ASSERTION_FAILED, "unexpected exception " + unexpected); + try { + tryNext(it1); + tryNext(it2); + tryNext(it3); + rollbackTransaction(); + + beginTransaction(); + Iterator it4 = ex.iterator(); + int count4 = countIterator(it4); + commitTransaction(); + + if (count4 != 2) { + fail(ASSERTION_FAILED, + "Iterator4 after rollback: " + count4 + "; should be 2"); + } + } + catch (Exception unexpected) { + fail(ASSERTION_FAILED, + "unexpected exception " + unexpected); + } + } + catch (Exception unexpected) { + fail(ASSERTION_FAILED, + "unexpected exception " + unexpected); + } } - } - /** */ - void tryNext(Iterator it) throws Exception { - try { - it.next(); - fail(ASSERTION_FAILED, "expected NoSuchElementException thrown by iterator.next()."); - } catch (NoSuchElementException expected) { - // expecteed exception + /** */ + void tryNext (Iterator it) throws Exception { + try { + it.next(); + fail(ASSERTION_FAILED, + "expected NoSuchElementException thrown by iterator.next()."); + } catch (NoSuchElementException expected) { + // expecteed exception + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/extents/IteratorNextAfterExtentCloseAll.java b/tck/src/main/java/org/apache/jdo/tck/extents/IteratorNextAfterExtentCloseAll.java index 3acbed44a..a63be5268 100644 --- a/tck/src/main/java/org/apache/jdo/tck/extents/IteratorNextAfterExtentCloseAll.java +++ b/tck/src/main/java/org/apache/jdo/tck/extents/IteratorNextAfterExtentCloseAll.java @@ -5,81 +5,97 @@ * 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 + * + * 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.jdo.tck.extents; import java.util.Iterator; import java.util.NoSuchElementException; + import javax.jdo.Extent; + import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Iterator Next After Extent CloseAll
    - * Keywords: extent
    - * Assertion ID: A15.3-13.
    - * Assertion Description: After a call to Extent.closeAll(), all iterators - * acquired from this Extent will throw a NoSuchElementException to - * next(). + *Title: Iterator Next After Extent CloseAll + *
    + *Keywords: extent + *
    + *Assertion ID: A15.3-13. + *
    + *Assertion Description: +After a call to Extent.closeAll(), all iterators acquired from this +Extent will throw a NoSuchElementException +to next(). + */ + public class IteratorNextAfterExtentCloseAll extends ExtentTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A15.3-13 (IteratorNextAfterExtentCloseAll) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IteratorNextAfterExtentCloseAll.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A15.3-13 (IteratorNextAfterExtentCloseAll) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IteratorNextAfterExtentCloseAll.class); + } - /** */ - public void test() { + /** */ + public void test() { - try { - beginTransaction(); - Extent ex = getPM().getExtent(Employee.class, true); - Iterator it1 = ex.iterator(); - deleteEmployee((Employee) it1.next()); - Iterator it2 = ex.iterator(); - addEmployee(); - Iterator it3 = ex.iterator(); - ex.closeAll(); + try { + beginTransaction(); + Extent ex = getPM().getExtent (Employee.class, true); + Iterator it1 = ex.iterator(); + deleteEmployee((Employee)it1.next()); + Iterator it2 = ex.iterator(); + addEmployee(); + Iterator it3 = ex.iterator(); + ex.closeAll(); - if (!tryNext(it1)) { - fail(ASSERTION_FAILED, "iterator1.next() does not throw NoSuchElementException."); - } - if (!tryNext(it2)) { - fail(ASSERTION_FAILED, "iterator2.next() does not throw NoSuchElementException."); - } - if (!tryNext(it3)) { - fail(ASSERTION_FAILED, "iterator3.next() does not throw NoSuchElementException."); - } - } finally { - rollbackTransaction(); + if (!tryNext(it1)) { + fail(ASSERTION_FAILED, + "iterator1.next() does not throw NoSuchElementException."); + } + if (!tryNext(it2)) { + fail(ASSERTION_FAILED, + "iterator2.next() does not throw NoSuchElementException."); + } + if (!tryNext(it3)) { + fail(ASSERTION_FAILED, + "iterator3.next() does not throw NoSuchElementException."); + } + } + finally { + rollbackTransaction(); + } } - } - - /** */ - boolean tryNext(Iterator it) { - try { - it.next(); - } catch (NoSuchElementException expected) { - return true; + + /** */ + boolean tryNext (Iterator it) { + try { + it.next(); + } catch (NoSuchElementException expected) { + return true; + } + return false; } - return false; - } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/extents/Iterators.java b/tck/src/main/java/org/apache/jdo/tck/extents/Iterators.java index c63f0e3a2..25a8d698b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/extents/Iterators.java +++ b/tck/src/main/java/org/apache/jdo/tck/extents/Iterators.java @@ -5,58 +5,69 @@ * 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 + * + * 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.jdo.tck.extents; import java.util.Iterator; + import javax.jdo.Extent; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Iterators
    - * Keywords: extent
    - * Assertion ID: A15.3-1.
    - * Assertion Description: Extent.iterator() returns an Iterator - * over all the instances in the Extent. - */ -public class Iterators extends ExtentTest { + *Title: Iterators + *
    + *Keywords: extent + *
    + *Assertion ID: A15.3-1. + *
    + *Assertion Description: +Extent.iterator() returns an Iterator +over all the instances in the Extent. - /** */ - private static final String ASSERTION_FAILED = "Assertion A15.3-1 (Iterators) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Iterators.class); - } - - /** */ - public void test() { + */ - Extent ex = getExtent(); +public class Iterators extends ExtentTest { - int count = 0; - beginTransaction(); - for (Iterator it = ex.iterator(); it.hasNext(); ++count) { - Object emp = it.next(); - if (debug) logger.debug(emp.toString()); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A15.3-1 (Iterators) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Iterators.class); } - rollbackTransaction(); - if (count != 2) { - fail(ASSERTION_FAILED, "Emplyoee extent should have 2 instances, got " + count); + /** */ + public void test() { + + Extent ex = getExtent(); + + int count = 0; + beginTransaction(); + for (Iterator it = ex.iterator(); it.hasNext();++count) { + Object emp = it.next(); + if (debug) logger.debug(emp.toString()); + } + rollbackTransaction(); + + if (count != 2) { + fail(ASSERTION_FAILED, + "Emplyoee extent should have 2 instances, got " + count); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/lifecycle/HollowInstanceMaintainsPK.java b/tck/src/main/java/org/apache/jdo/tck/lifecycle/HollowInstanceMaintainsPK.java index afe1a3c52..2bcf48548 100644 --- a/tck/src/main/java/org/apache/jdo/tck/lifecycle/HollowInstanceMaintainsPK.java +++ b/tck/src/main/java/org/apache/jdo/tck/lifecycle/HollowInstanceMaintainsPK.java @@ -5,16 +5,16 @@ * 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 + * + * 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.jdo.tck.lifecycle; import org.apache.jdo.tck.JDO_Test; @@ -23,78 +23,83 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test that Hollow Instances maintains PK
    - * Keywords: lifecycle hollow instance PK
    - * Assertion IDs: A5.5.4-3
    - * Assertion Description: If the instance is of a class using application identity, the - * hollow instance maintains its primary key fields. + *Title: Test that Hollow Instances maintains PK + *
    + *Keywords: lifecycle hollow instance PK + *
    + *Assertion IDs: A5.5.4-3 + *
    + *Assertion Description: + If the instance is of a class using application identity, the hollow instance maintains its primary key fields. */ -public class HollowInstanceMaintainsPK extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A5.5.4-3 (HollowInstanceMaintainsPK) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(HollowInstanceMaintainsPK.class); - } +public class HollowInstanceMaintainsPK extends JDO_Test { - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCRect.class); - addTearDownClass(PCPoint.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A5.5.4-3 (HollowInstanceMaintainsPK) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(HollowInstanceMaintainsPK.class); + } - /** */ - public void test() { - if (!isApplicationIdentitySupported()) { - printUnsupportedOptionalFeatureNotTested( - getClass().getName(), "javax.jdo.option.ApplicationIdentity"); - } else if (!runsWithApplicationIdentity()) { - printNonApplicableIdentityType(getClass().getName(), "javax.jdo.option.ApplicationIdentity"); - } else { - pm = getPM(); - pm.currentTransaction().begin(); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCRect.class); + addTearDownClass(PCPoint.class); + } + + /** */ + public void test() { + if (!isApplicationIdentitySupported()) { + printUnsupportedOptionalFeatureNotTested( + getClass().getName(), + "javax.jdo.option.ApplicationIdentity"); + } else if (!runsWithApplicationIdentity()) { + printNonApplicableIdentityType( + getClass().getName(), + "javax.jdo.option.ApplicationIdentity"); + } + else { + pm = getPM(); + pm.currentTransaction().begin(); - PCRect obj = getPersistentNewInstance(); - long beforeValue = obj.getId(); - pm.currentTransaction().commit(); // obj should transition to HOLLOW - // The next call obj.getId() is a primary key access. - // The method must not be called inside a transaction, - // because a JDO implementation must allow primary key accesses - // outside of transactions. - long afterValue = obj.getId(); - if (beforeValue != afterValue) { - fail( - ASSERTION_FAILED, - "Key field value incorrect after commit. Expected: " - + beforeValue - + " Found: " - + afterValue); - } + PCRect obj = getPersistentNewInstance(); + long beforeValue=obj.getId(); + pm.currentTransaction().commit(); // obj should transition to HOLLOW + //The next call obj.getId() is a primary key access. + //The method must not be called inside a transaction, + //because a JDO implementation must allow primary key accesses + //outside of transactions. + long afterValue=obj.getId(); + if (beforeValue!=afterValue) { + fail(ASSERTION_FAILED, + "Key field value incorrect after commit. Expected: " + + beforeValue + " Found: " + afterValue); + } + } } - } - /** */ - private PCRect getPersistentNewInstance() { - PCRect obj = new PCRect(0, new PCPoint(1, 5), new PCPoint(7, 3)); - pm.makePersistent(obj); // obj should transition to persistent-new - int curr = currentState(obj); - if (curr != PERSISTENT_NEW) { - fail( - ASSERTION_FAILED, - "StateTransitions: Unable to create persistent-new instance " - + "from transient instance via makePersistent(), state is " - + states[curr]); + /** */ + private PCRect getPersistentNewInstance() { + PCRect obj = new PCRect(0, new PCPoint(1,5), new PCPoint(7,3)); + pm.makePersistent(obj); // obj should transition to persistent-new + int curr = currentState(obj); + if( curr != PERSISTENT_NEW ){ + fail(ASSERTION_FAILED, + "StateTransitions: Unable to create persistent-new instance " + + "from transient instance via makePersistent(), state is " + + states[curr]); + } + return obj; } - return obj; - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/lifecycle/MultiplePMsReturnInstancesRepresentingSamePC.java b/tck/src/main/java/org/apache/jdo/tck/lifecycle/MultiplePMsReturnInstancesRepresentingSamePC.java index a0d95bfb3..5f9caf43a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/lifecycle/MultiplePMsReturnInstancesRepresentingSamePC.java +++ b/tck/src/main/java/org/apache/jdo/tck/lifecycle/MultiplePMsReturnInstancesRepresentingSamePC.java @@ -5,148 +5,153 @@ * 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 + * + * 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.jdo.tck.lifecycle; import java.util.Iterator; + import javax.jdo.Extent; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.lifecycle.StateTransitionObj; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test that Multiple PMs return different instances representing same PC object
    - * Keywords: lifecycle Multiple PMs getObjectById equal
    - * Assertion IDs: A5.4-7
    - * Assertion Description: The instance returned by a call to getObjectById(Object) of - * different PersistenceManager instances returned by the same PersistenceManagerFactory represent - * the same persistent object, but with different Java object identity (specifically, all instances - * returned by getObjectId from the instances must return true to equals comparisons with all - * others). + *Title: Test that Multiple PMs return different instances representing same PC object + *
    + *Keywords: lifecycle Multiple PMs getObjectById equal + *
    + *Assertion IDs: A5.4-7 + *
    + *Assertion Description: + The instance returned by a call to getObjectById(Object) of different PersistenceManager + instances returned by the same PersistenceManagerFactory represent the same persistent object, + but with different Java object identity (specifically, all instances returned by getObjectId from the instances + must return true to equals comparisons with all others). */ -public class MultiplePMsReturnInstancesRepresentingSamePC extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A5.4-7 (MultiplePMsReturnInstancesRepresentingSamePC) failed: "; - - private static final int NUM_OBJECTS = 50; - - /** The persistent instances of this test. */ - private Object[] obj; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MultiplePMsReturnInstancesRepresentingSamePC.class); - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - pm = getPM(); - addTearDownClass(StateTransitionObj.class); - obj = generatePersistentInstances(); - } - - public void test() { - PersistenceManager pm2 = null; - PersistenceManager pm3 = null; - - try { - // Get two more PMs - pm2 = pmf.getPersistenceManager(); - pm3 = pmf.getPersistenceManager(); - - pm.currentTransaction().begin(); - - Extent extent = pm.getExtent(StateTransitionObj.class, false); - Iterator iter = extent.iterator(); - if (!iter.hasNext()) { - fail(ASSERTION_FAILED, "Extent for StateTransitionObj should not be empty"); - } - extent.close(iter); - - for (int i = 0; i < NUM_OBJECTS; i++) { - Object obj1 = obj[i]; - Object objId1 = pm.getObjectId(obj1); - Object obj2 = pm2.getObjectById(objId1, false); - Object objId2 = pm2.getObjectId(obj2); - Object obj3 = pm3.getObjectById(objId1, false); - Object objId3 = pm3.getObjectId(obj3); - - // Verify that objects are different instances - if (!((obj1 != obj2) && (obj1 != obj3))) { - fail( - ASSERTION_FAILED, - "Objects are not different instances. obj1=" - + obj1 - + " obj2= " - + obj2 - + " obj3= " - + obj3); - } - - // Verify that object Ids are equal - if (!(objId1.equals(objId2) && objId1.equals(objId3))) { - fail( - ASSERTION_FAILED, - "Object Ids are not equal. objId1=" - + objId1 - + " objId2= " - + objId2 - + " objId3= " - + objId3); - } - } +public class MultiplePMsReturnInstancesRepresentingSamePC extends JDO_Test { - pm.currentTransaction().commit(); - } finally { - if (pm != null && pm.currentTransaction().isActive()) { - pm.currentTransaction().rollback(); - } - if (pm2 != null && !pm2.isClosed()) { - pm2.close(); - } - if (pm3 != null && !pm3.isClosed()) { - pm3.close(); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A5.4-7 (MultiplePMsReturnInstancesRepresentingSamePC) failed: "; + + private static final int NUM_OBJECTS = 50; + + /** The persistent instances of this test. */ + private Object[] obj; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MultiplePMsReturnInstancesRepresentingSamePC.class); } - } - private Object[] generatePersistentInstances() { - StateTransitionObj[] objects = new StateTransitionObj[NUM_OBJECTS]; - try { - Transaction t = pm.currentTransaction(); - t.begin(); - for (int i = 0; i < NUM_OBJECTS; ++i) { - objects[i] = new StateTransitionObj(i); - objects[i].writeField(i); - pm.makePersistent(objects[i]); - } - t.commit(); - return objects; - } finally { - Transaction tx = pm.currentTransaction(); - if (tx.isActive()) { - tx.rollback(); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + pm = getPM(); + addTearDownClass(StateTransitionObj.class); + obj = generatePersistentInstances(); } - } + + public void test() { + PersistenceManager pm2 = null; + PersistenceManager pm3 = null; + + try { + // Get two more PMs + pm2 = pmf.getPersistenceManager(); + pm3 = pmf.getPersistenceManager(); + + pm.currentTransaction().begin(); + + Extent extent = pm.getExtent(StateTransitionObj.class, false); + Iterator iter = extent.iterator(); + if( !iter.hasNext() ){ + fail(ASSERTION_FAILED, + "Extent for StateTransitionObj should not be empty"); + } + extent.close(iter); + + + for (int i=0; iTitle: Test NontransactionalWriteDatastoreCommit
    - * Keywords: NontransactionalWrite datastore commit
    - * Assertion ID: A5.6.2-4, A5.6.2-6, A5.6.2-8, A5.6.2-10.
    - * Assertion Description: A5.6.2-4 [If a datastore transaction is begun, commit will write - * the changes to the datastore with no checking as to the current state of the instances in the - * datastore. That is, the changes made outside the transaction together with any changes made - * inside the transaction will overwrite the current state of the datastore.] - * - *

    A5.6.2-6 [If a datastore transaction is begun, rollback will not write any changes to the - * datastore.] - * - *

    A5.6.2-8 [If an optimistic transaction is begun, commit will write the changes to the - * datastore after checking as to the current state of the instances in the datastore. The changes - * made outside the transaction together with any changes made inside the transaction will update - * the current state of the datastore if the version checking is successful.] - * - *

    A5.6.2-10 [If an optimistic transaction is begun, rollback will not write any changes to the - * datastore. The persistent-nontransactional-dirty instances will transition according to the - * RestoreValues flag. ] + *Title: Test NontransactionalWriteDatastoreCommit + *
    + *Keywords: NontransactionalWrite datastore commit + *
    + *Assertion ID: A5.6.2-4, A5.6.2-6, A5.6.2-8, A5.6.2-10. + *
    + *Assertion Description: +A5.6.2-4 [If a datastore transaction is begun, commit will write +the changes to the datastore with no checking as to +the current state of the instances in the datastore. +That is, the changes made outside the transaction +together with any changes made inside the transaction +will overwrite the current state of the datastore.] + +A5.6.2-6 [If a datastore transaction is begun, rollback will not write +any changes to the datastore.] + +A5.6.2-8 [If an optimistic transaction is begun, commit will write +the changes to the datastore after checking as to the current state +of the instances in the datastore. The changes made outside +the transaction together with any changes made inside the transaction +will update the current state of the datastore if the version +checking is successful.] + +A5.6.2-10 [If an optimistic transaction is begun, rollback will not write +any changes to the datastore. The persistent-nontransactional-dirty +instances will transition according to the RestoreValues flag. ] */ -public class NontransactionalWriteDatastoreCommit extends NontransactionalWriteTest { - /** */ - protected static final String ASSERTION_FAILED = - "Assertion A5.6.2-4 (NontransactionalWriteDatastoreCommit) failed: "; +public class NontransactionalWriteDatastoreCommit + extends NontransactionalWriteTest { + + /** */ + protected static final String ASSERTION_FAILED = + "Assertion A5.6.2-4 (NontransactionalWriteDatastoreCommit) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NontransactionalWriteDatastoreCommit.class); + } - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NontransactionalWriteDatastoreCommit.class); - } + /** + * Create a nontransactional dirty instance, begin and commit + * a datastore transaction, and check that the instance in + * the datastore has the value as changed by the transaction. + */ + public void testDatastoreCommit() { + if (!checkNontransactionalFeaturesSupported(false)) + return; + createAndModifyVersionedPCPoint(); + beginAndCommitTransaction(false); + checkXValue(ASSERTION_FAILED + "after datastore commit", + newXValue); + failOnError(); + } - /** - * Create a nontransactional dirty instance, begin and commit a datastore transaction, and check - * that the instance in the datastore has the value as changed by the transaction. - */ - public void testDatastoreCommit() { - if (!checkNontransactionalFeaturesSupported(false)) return; - createAndModifyVersionedPCPoint(); - beginAndCommitTransaction(false); - checkXValue(ASSERTION_FAILED + "after datastore commit", newXValue); - failOnError(); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreCommitConflict.java b/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreCommitConflict.java index be12f77f5..0fee8e816 100644 --- a/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreCommitConflict.java +++ b/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreCommitConflict.java @@ -5,67 +5,89 @@ * 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 + * + * 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.jdo.tck.lifecycle; +import javax.jdo.JDOUnsupportedOptionException; +import javax.jdo.PersistenceManager; + +import org.apache.jdo.tck.JDO_Test; + +import org.apache.jdo.tck.pc.mylib.VersionedPCPoint; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test NontransactionalWriteDatastoreCommitConflict
    - * Keywords: NontransactionalWrite datastore commit
    - * Assertion ID: A5.6.2-4, A5.6.2-6, A5.6.2-8, A5.6.2-10.
    - * Assertion Description: A5.6.2-4 [If a datastore transaction is begun, commit will write - * the changes to the datastore with no checking as to the current state of the instances in the - * datastore. That is, the changes made outside the transaction together with any changes made - * inside the transaction will overwrite the current state of the datastore.] - * - *

    A5.6.2-6 [If a datastore transaction is begun, rollback will not write any changes to the - * datastore.] - * - *

    A5.6.2-8 [If an optimistic transaction is begun, commit will write the changes to the - * datastore after checking as to the current state of the instances in the datastore. The changes - * made outside the transaction together with any changes made inside the transaction will update - * the current state of the datastore if the version checking is successful.] - * - *

    A5.6.2-10 [If an optimistic transaction is begun, rollback will not write any changes to the - * datastore. The persistent-nontransactional-dirty instances will transition according to the - * RestoreValues flag. ] + *Title: Test NontransactionalWriteDatastoreCommitConflict + *
    + *Keywords: NontransactionalWrite datastore commit + *
    + *Assertion ID: A5.6.2-4, A5.6.2-6, A5.6.2-8, A5.6.2-10. + *
    + *Assertion Description: +A5.6.2-4 [If a datastore transaction is begun, commit will write +the changes to the datastore with no checking as to +the current state of the instances in the datastore. +That is, the changes made outside the transaction +together with any changes made inside the transaction +will overwrite the current state of the datastore.] + +A5.6.2-6 [If a datastore transaction is begun, rollback will not write +any changes to the datastore.] + +A5.6.2-8 [If an optimistic transaction is begun, commit will write +the changes to the datastore after checking as to the current state +of the instances in the datastore. The changes made outside +the transaction together with any changes made inside the transaction +will update the current state of the datastore if the version +checking is successful.] + +A5.6.2-10 [If an optimistic transaction is begun, rollback will not write +any changes to the datastore. The persistent-nontransactional-dirty +instances will transition according to the RestoreValues flag. ] */ -public class NontransactionalWriteDatastoreCommitConflict extends NontransactionalWriteTest { - /** */ - protected static final String ASSERTION_FAILED = - "Assertion A5.6.2-4 " + "(NontransactionalWriteDatastoreCommitConflict) failed: "; +public class NontransactionalWriteDatastoreCommitConflict + extends NontransactionalWriteTest { + + /** */ + protected static final String ASSERTION_FAILED = + "Assertion A5.6.2-4 " + + "(NontransactionalWriteDatastoreCommitConflict) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NontransactionalWriteDatastoreCommitConflict.class); + } - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NontransactionalWriteDatastoreCommitConflict.class); - } + /** + * Create a nontransactional dirty instance, begin and commit + * a conflicting transaction, begin and commit a datastore + * transaction, and check that the instance in the datastore + * was overwritten by this datastore transaction. + */ + public void testDatastoreCommitConflict() { + if (!checkNontransactionalFeaturesSupported(false)) + return; + createAndModifyVersionedPCPoint(); + conflictingUpdate(); + beginAndCommitTransaction(false); + checkXValue(ASSERTION_FAILED + "after datastore commit with conflict", + newXValue); + failOnError(); + } - /** - * Create a nontransactional dirty instance, begin and commit a conflicting transaction, begin and - * commit a datastore transaction, and check that the instance in the datastore was overwritten by - * this datastore transaction. - */ - public void testDatastoreCommitConflict() { - if (!checkNontransactionalFeaturesSupported(false)) return; - createAndModifyVersionedPCPoint(); - conflictingUpdate(); - beginAndCommitTransaction(false); - checkXValue(ASSERTION_FAILED + "after datastore commit with conflict", newXValue); - failOnError(); - } -} +} \ No newline at end of file diff --git a/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreRollback.java b/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreRollback.java index 583b1339f..2cec89c71 100644 --- a/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreRollback.java +++ b/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteDatastoreRollback.java @@ -5,65 +5,86 @@ * 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 + * + * 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.jdo.tck.lifecycle; +import javax.jdo.JDOUnsupportedOptionException; +import javax.jdo.PersistenceManager; + +import org.apache.jdo.tck.JDO_Test; + +import org.apache.jdo.tck.pc.mylib.VersionedPCPoint; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test NontransactionalWriteDatastoreRollback
    - * Keywords: NontransactionalWrite datastore rollback
    - * Assertion ID: A5.6.2-4, A5.6.2-6, A5.6.2-8, A5.6.2-10.
    - * Assertion Description: A5.6.2-4 [If a datastore transaction is begun, commit will write - * the changes to the datastore with no checking as to the current state of the instances in the - * datastore. That is, the changes made outside the transaction together with any changes made - * inside the transaction will overwrite the current state of the datastore.] - * - *

    A5.6.2-6 [If a datastore transaction is begun, rollback will not write any changes to the - * datastore.] - * - *

    A5.6.2-8 [If an optimistic transaction is begun, commit will write the changes to the - * datastore after checking as to the current state of the instances in the datastore. The changes - * made outside the transaction together with any changes made inside the transaction will update - * the current state of the datastore if the version checking is successful.] - * - *

    A5.6.2-10 [If an optimistic transaction is begun, rollback will not write any changes to the - * datastore. The persistent-nontransactional-dirty instances will transition according to the - * RestoreValues flag. ] + *Title: Test NontransactionalWriteDatastoreRollback + *
    + *Keywords: NontransactionalWrite datastore rollback + *
    + *Assertion ID: A5.6.2-4, A5.6.2-6, A5.6.2-8, A5.6.2-10. + *
    + *Assertion Description: +A5.6.2-4 [If a datastore transaction is begun, commit will write +the changes to the datastore with no checking as to +the current state of the instances in the datastore. +That is, the changes made outside the transaction +together with any changes made inside the transaction +will overwrite the current state of the datastore.] + +A5.6.2-6 [If a datastore transaction is begun, rollback will not write +any changes to the datastore.] + +A5.6.2-8 [If an optimistic transaction is begun, commit will write +the changes to the datastore after checking as to the current state +of the instances in the datastore. The changes made outside +the transaction together with any changes made inside the transaction +will update the current state of the datastore if the version +checking is successful.] + +A5.6.2-10 [If an optimistic transaction is begun, rollback will not write +any changes to the datastore. The persistent-nontransactional-dirty +instances will transition according to the RestoreValues flag. ] */ -public class NontransactionalWriteDatastoreRollback extends NontransactionalWriteTest { - /** */ - protected static final String ASSERTION_FAILED = - "Assertion A5.6.2-6 (NontransactionalWriteDatastoreRollback) failed: "; +public class NontransactionalWriteDatastoreRollback + extends NontransactionalWriteTest { + + /** */ + protected static final String ASSERTION_FAILED = + "Assertion A5.6.2-6 (NontransactionalWriteDatastoreRollback) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NontransactionalWriteDatastoreRollback.class); + } - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NontransactionalWriteDatastoreRollback.class); - } + /** + * Create a nontransactional dirty instance, begin and rollback + * a datastore transaction, and check that the instance in + * the datastore has the original value. + */ + public void testDatastoreRollback() { + if (!checkNontransactionalFeaturesSupported(false)) + return; + createAndModifyVersionedPCPoint(); + beginAndRollbackTransaction(false); + checkXValue(ASSERTION_FAILED + "after datastore rollback", + originalXValue); + failOnError(); + } - /** - * Create a nontransactional dirty instance, begin and rollback a datastore transaction, and check - * that the instance in the datastore has the original value. - */ - public void testDatastoreRollback() { - if (!checkNontransactionalFeaturesSupported(false)) return; - createAndModifyVersionedPCPoint(); - beginAndRollbackTransaction(false); - checkXValue(ASSERTION_FAILED + "after datastore rollback", originalXValue); - failOnError(); - } -} +} \ No newline at end of file diff --git a/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticCommit.java b/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticCommit.java index 2f42ec5ce..d41c0d492 100644 --- a/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticCommit.java +++ b/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticCommit.java @@ -5,65 +5,86 @@ * 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 + * + * 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.jdo.tck.lifecycle; +import javax.jdo.JDOUnsupportedOptionException; +import javax.jdo.PersistenceManager; + +import org.apache.jdo.tck.JDO_Test; + +import org.apache.jdo.tck.pc.mylib.VersionedPCPoint; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: TestNontransactionalWriteOptimisticCommit
    - * Keywords: NontransactionalWrite optimistic commit
    - * Assertion ID: A5.6.2-4, A5.6.2-6, A5.6.2-8, A5.6.2-10.
    - * Assertion Description: A5.6.2-4 [If a datastore transaction is begun, commit will write - * the changes to the datastore with no checking as to the current state of the instances in the - * datastore. That is, the changes made outside the transaction together with any changes made - * inside the transaction will overwrite the current state of the datastore.] - * - *

    A5.6.2-6 [If a datastore transaction is begun, rollback will not write any changes to the - * datastore.] - * - *

    A5.6.2-8 [If an optimistic transaction is begun, commit will write the changes to the - * datastore after checking as to the current state of the instances in the datastore. The changes - * made outside the transaction together with any changes made inside the transaction will update - * the current state of the datastore if the version checking is successful.] - * - *

    A5.6.2-10 [If an optimistic transaction is begun, rollback will not write any changes to the - * datastore. The persistent-nontransactional-dirty instances will transition according to the - * RestoreValues flag. ] + *Title: TestNontransactionalWriteOptimisticCommit + *
    + *Keywords: NontransactionalWrite optimistic commit + *
    + *Assertion ID: A5.6.2-4, A5.6.2-6, A5.6.2-8, A5.6.2-10. + *
    + *Assertion Description: +A5.6.2-4 [If a datastore transaction is begun, commit will write +the changes to the datastore with no checking as to +the current state of the instances in the datastore. +That is, the changes made outside the transaction +together with any changes made inside the transaction +will overwrite the current state of the datastore.] + +A5.6.2-6 [If a datastore transaction is begun, rollback will not write +any changes to the datastore.] + +A5.6.2-8 [If an optimistic transaction is begun, commit will write +the changes to the datastore after checking as to the current state +of the instances in the datastore. The changes made outside +the transaction together with any changes made inside the transaction +will update the current state of the datastore if the version +checking is successful.] + +A5.6.2-10 [If an optimistic transaction is begun, rollback will not write +any changes to the datastore. The persistent-nontransactional-dirty +instances will transition according to the RestoreValues flag. ] */ -public class NontransactionalWriteOptimisticCommit extends NontransactionalWriteTest { - /** */ - protected static final String ASSERTION_FAILED = - "Assertion A5.6.2-8 (NontransactionalWriteOptimisticCommit) failed: "; +public class NontransactionalWriteOptimisticCommit + extends NontransactionalWriteTest { + + /** */ + protected static final String ASSERTION_FAILED = + "Assertion A5.6.2-8 (NontransactionalWriteOptimisticCommit) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NontransactionalWriteOptimisticCommit.class); + } - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NontransactionalWriteOptimisticCommit.class); - } + /** + * Create a nontransactional dirty instance, begin and commit + * an optimistic transaction, and check that the instance in + * the datastore has the value as changed by the transaction. + */ + public void testOptimisticCommit() { + if (!checkNontransactionalFeaturesSupported(true)) + return; + createAndModifyVersionedPCPoint(); + beginAndCommitTransaction(true); + checkXValue(ASSERTION_FAILED + "after optimistic commit", + newXValue); + failOnError(); + } - /** - * Create a nontransactional dirty instance, begin and commit an optimistic transaction, and check - * that the instance in the datastore has the value as changed by the transaction. - */ - public void testOptimisticCommit() { - if (!checkNontransactionalFeaturesSupported(true)) return; - createAndModifyVersionedPCPoint(); - beginAndCommitTransaction(true); - checkXValue(ASSERTION_FAILED + "after optimistic commit", newXValue); - failOnError(); - } -} +} \ No newline at end of file diff --git a/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticCommitConflict.java b/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticCommitConflict.java index 9c3533762..4bed5136b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticCommitConflict.java +++ b/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticCommitConflict.java @@ -5,68 +5,91 @@ * 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 + * + * 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.jdo.tck.lifecycle; +import javax.jdo.JDOUnsupportedOptionException; +import javax.jdo.PersistenceManager; + +import org.apache.jdo.tck.JDO_Test; + +import org.apache.jdo.tck.pc.mylib.VersionedPCPoint; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test NontransactionalWriteOptimisticCommitConflict
    - * Keywords: NontransactionalWrite optimistic
    - * Assertion ID: A5.6.2-4, A5.6.2-6, A5.6.2-8, A5.6.2-10.
    - * Assertion Description: A5.6.2-4 [If a datastore transaction is begun, commit will write - * the changes to the datastore with no checking as to the current state of the instances in the - * datastore. That is, the changes made outside the transaction together with any changes made - * inside the transaction will overwrite the current state of the datastore.] - * - *

    A5.6.2-6 [If a datastore transaction is begun, rollback will not write any changes to the - * datastore.] - * - *

    A5.6.2-8 [If an optimistic transaction is begun, commit will write the changes to the - * datastore after checking as to the current state of the instances in the datastore. The changes - * made outside the transaction together with any changes made inside the transaction will update - * the current state of the datastore if the version checking is successful.] - * - *

    A5.6.2-10 [If an optimistic transaction is begun, rollback will not write any changes to the - * datastore. The persistent-nontransactional-dirty instances will transition according to the - * RestoreValues flag. ] + *Title: Test NontransactionalWriteOptimisticCommitConflict + *
    + *Keywords: NontransactionalWrite optimistic + *
    + *Assertion ID: A5.6.2-4, A5.6.2-6, A5.6.2-8, A5.6.2-10. + *
    + *Assertion Description: +A5.6.2-4 [If a datastore transaction is begun, commit will write +the changes to the datastore with no checking as to +the current state of the instances in the datastore. +That is, the changes made outside the transaction +together with any changes made inside the transaction +will overwrite the current state of the datastore.] + +A5.6.2-6 [If a datastore transaction is begun, rollback will not write +any changes to the datastore.] + +A5.6.2-8 [If an optimistic transaction is begun, commit will write +the changes to the datastore after checking as to the current state +of the instances in the datastore. The changes made outside +the transaction together with any changes made inside the transaction +will update the current state of the datastore if the version +checking is successful.] + +A5.6.2-10 [If an optimistic transaction is begun, rollback will not write +any changes to the datastore. The persistent-nontransactional-dirty +instances will transition according to the RestoreValues flag. ] */ -public class NontransactionalWriteOptimisticCommitConflict extends NontransactionalWriteTest { - /** */ - protected static final String ASSERTION_FAILED = - "Assertion A5.6.2-8 " + "(NontransactionalWriteOptimisticCommitConflict) failed: "; +public class NontransactionalWriteOptimisticCommitConflict + extends NontransactionalWriteTest { + + /** */ + protected static final String ASSERTION_FAILED = + "Assertion A5.6.2-8 " + + "(NontransactionalWriteOptimisticCommitConflict) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run + (NontransactionalWriteOptimisticCommitConflict.class); + } - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NontransactionalWriteOptimisticCommitConflict.class); - } + /** + * Create a nontransactional dirty instance, begin and commit + * a conflicting transaction, begin and commit an optimistic + * transaction and check that the instance in the datastore + * has the value as changed by the conflicting transaction. + */ + public void testOptimisticCommitConflict() { + if (!checkNontransactionalFeaturesSupported(true)) + return; + String location = + ASSERTION_FAILED + "after optimistic commit with conflict"; + createAndModifyVersionedPCPoint(); + conflictingUpdate(); + beginAndCommitTransactionFails(location, true); + checkXValue(location, conflictXValue); + failOnError(); + } - /** - * Create a nontransactional dirty instance, begin and commit a conflicting transaction, begin and - * commit an optimistic transaction and check that the instance in the datastore has the value as - * changed by the conflicting transaction. - */ - public void testOptimisticCommitConflict() { - if (!checkNontransactionalFeaturesSupported(true)) return; - String location = ASSERTION_FAILED + "after optimistic commit with conflict"; - createAndModifyVersionedPCPoint(); - conflictingUpdate(); - beginAndCommitTransactionFails(location, true); - checkXValue(location, conflictXValue); - failOnError(); - } -} +} \ No newline at end of file diff --git a/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticRollback.java b/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticRollback.java index 19ea682c5..ed20df756 100644 --- a/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticRollback.java +++ b/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteOptimisticRollback.java @@ -5,65 +5,86 @@ * 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 + * + * 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.jdo.tck.lifecycle; +import javax.jdo.JDOUnsupportedOptionException; +import javax.jdo.PersistenceManager; + +import org.apache.jdo.tck.JDO_Test; + +import org.apache.jdo.tck.pc.mylib.VersionedPCPoint; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test NontransactionalWriteOptimisticRollback
    - * Keywords: NontransactionalWrite optimistic rollback
    - * Assertion ID: A5.6.2-4, A5.6.2-6, A5.6.2-8, A5.6.2-10.
    - * Assertion Description: A5.6.2-4 [If a datastore transaction is begun, commit will write - * the changes to the datastore with no checking as to the current state of the instances in the - * datastore. That is, the changes made outside the transaction together with any changes made - * inside the transaction will overwrite the current state of the datastore.] - * - *

    A5.6.2-6 [If a datastore transaction is begun, rollback will not write any changes to the - * datastore.] - * - *

    A5.6.2-8 [If an optimistic transaction is begun, commit will write the changes to the - * datastore after checking as to the current state of the instances in the datastore. The changes - * made outside the transaction together with any changes made inside the transaction will update - * the current state of the datastore if the version checking is successful.] - * - *

    A5.6.2-10 [If an optimistic transaction is begun, rollback will not write any changes to the - * datastore. The persistent-nontransactional-dirty instances will transition according to the - * RestoreValues flag. ] + *Title: Test NontransactionalWriteOptimisticRollback + *
    + *Keywords: NontransactionalWrite optimistic rollback + *
    + *Assertion ID: A5.6.2-4, A5.6.2-6, A5.6.2-8, A5.6.2-10. + *
    + *Assertion Description: +A5.6.2-4 [If a datastore transaction is begun, commit will write +the changes to the datastore with no checking as to +the current state of the instances in the datastore. +That is, the changes made outside the transaction +together with any changes made inside the transaction +will overwrite the current state of the datastore.] + +A5.6.2-6 [If a datastore transaction is begun, rollback will not write +any changes to the datastore.] + +A5.6.2-8 [If an optimistic transaction is begun, commit will write +the changes to the datastore after checking as to the current state +of the instances in the datastore. The changes made outside +the transaction together with any changes made inside the transaction +will update the current state of the datastore if the version +checking is successful.] + +A5.6.2-10 [If an optimistic transaction is begun, rollback will not write +any changes to the datastore. The persistent-nontransactional-dirty +instances will transition according to the RestoreValues flag. ] */ -public class NontransactionalWriteOptimisticRollback extends NontransactionalWriteTest { - /** */ - protected static final String ASSERTION_FAILED = - "Assertion A5.6.2-10 (NontransactionalWriteOptimisticRollback) failed: "; +public class NontransactionalWriteOptimisticRollback + extends NontransactionalWriteTest { + + /** */ + protected static final String ASSERTION_FAILED = + "Assertion A5.6.2-10 (NontransactionalWriteOptimisticRollback) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NontransactionalWriteOptimisticRollback.class); + } - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NontransactionalWriteOptimisticRollback.class); - } + /** + * Create a nontransactional dirty instance, begin and rollback + * a transaction, and check that the instance in the datastore + * has not been changed. + */ + public void testOptimisticRollback() { + if (!checkNontransactionalFeaturesSupported(true)) + return; + createAndModifyVersionedPCPoint(); + beginAndRollbackTransaction(true); + checkXValue(ASSERTION_FAILED + "after optimistic rollback", + originalXValue); + failOnError(); + } - /** - * Create a nontransactional dirty instance, begin and rollback a transaction, and check that the - * instance in the datastore has not been changed. - */ - public void testOptimisticRollback() { - if (!checkNontransactionalFeaturesSupported(true)) return; - createAndModifyVersionedPCPoint(); - beginAndRollbackTransaction(true); - checkXValue(ASSERTION_FAILED + "after optimistic rollback", originalXValue); - failOnError(); - } -} +} \ No newline at end of file diff --git a/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteTest.java b/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteTest.java index 0acb26022..04028dfce 100644 --- a/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteTest.java @@ -5,219 +5,243 @@ * 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 + * + * 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.jdo.tck.lifecycle; import javax.jdo.JDOOptimisticVerificationException; + import javax.jdo.PersistenceManager; + import org.apache.jdo.tck.JDO_Test; + import org.apache.jdo.tck.pc.mylib.VersionedPCPoint; /** - * Title: Test NontransactionalWrite abstract base class
    - * Keywords: NontransactionalWrite
    - * Assertion ID:
    - * Assertion Description: + *Title: Test NontransactionalWrite abstract base class + *
    + *Keywords: NontransactionalWrite + *
    + *Assertion ID: + *
    + *Assertion Description: */ -public abstract class NontransactionalWriteTest extends JDO_Test { - - /** The ObjectId of the pc instance, set by method createAndModifyInstance. */ - protected Object oid; - - /** - * The original value of the X field of the pc instance, set by method createAndModifyInstance. - */ - protected int originalXValue = 100; - - protected int newXValue = 999; - protected int conflictXValue = 555; - - /** - * Create a new VersionedPCPoint instance,modify its X value, and store its oid in the test class - * oid. The persistence manager referenced by the pm field (in the superclass) manages the - * nontransactional dirty instance. This method is only executed if the JDO implementation - * supports the required features, otherwise this method would be localSetUp. - * - * @return PCPoint instance - */ - protected VersionedPCPoint createAndModifyVersionedPCPoint() { - addTearDownClass(VersionedPCPoint.class); - getPM().currentTransaction().begin(); - pm.currentTransaction().setNontransactionalWrite(true); - pm.currentTransaction().setNontransactionalRead(true); - pm.currentTransaction().setRetainValues(true); - VersionedPCPoint instance = new VersionedPCPoint(originalXValue, 200); - pm.makePersistent(instance); - oid = pm.getObjectId(instance); - pm.currentTransaction().commit(); - instance.setX(newXValue); - return instance; - } - - /** - * Begin and rollback a transaction using the persistence manager that manages the - * nontransactional dirty instance. - * - * @param optimistic use optimistic transaction - */ - protected void beginAndRollbackTransaction(boolean optimistic) { - getPM().currentTransaction().setOptimistic(optimistic); - pm.currentTransaction().begin(); - pm.currentTransaction().rollback(); - } - - /** - * Begin and commit a transaction using the persistence manager that manages the nontransactional - * dirty instance. - * - * @param optimistic use optimistic transaction - */ - protected void beginAndCommitTransaction(boolean optimistic) { - getPM().currentTransaction().setOptimistic(optimistic); - pm.currentTransaction().begin(); - pm.currentTransaction().commit(); - } - - /** - * Begin and commit a transaction using the persistence manager that manages the nontransactional - * dirty instance. This transaction must fail due to a conflicting update. - * - * @param location location for error message - * @param optimistic use optimistic transaction - */ - protected void beginAndCommitTransactionFails(String location, boolean optimistic) { - getPM().currentTransaction().setOptimistic(optimistic); - pm.currentTransaction().begin(); - try { - pm.currentTransaction().commit(); - } catch (JDOOptimisticVerificationException ex) { - // good catch; return - return; + +abstract public class NontransactionalWriteTest extends JDO_Test { + + /** + * The ObjectId of the pc instance, set by method + * createAndModifyInstance. + */ + protected Object oid; + + /** + * The original value of the X field of the pc instance, + * set by method createAndModifyInstance. + */ + protected int originalXValue = 100; + protected int newXValue = 999; + protected int conflictXValue = 555; + + /** + * Create a new VersionedPCPoint instance,modify its X value, + * and store its oid in the test class oid. The persistence manager + * referenced by the pm field (in the superclass) manages the + * nontransactional dirty instance. + * This method is only executed if the + * JDO implementation supports the required features, otherwise + * this method would be localSetUp. + * @return PCPoint instance + */ + protected VersionedPCPoint createAndModifyVersionedPCPoint() { + addTearDownClass(VersionedPCPoint.class); + getPM().currentTransaction().begin(); + pm.currentTransaction().setNontransactionalWrite(true); + pm.currentTransaction().setNontransactionalRead(true); + pm.currentTransaction().setRetainValues(true); + VersionedPCPoint instance = new VersionedPCPoint(originalXValue, 200); + pm.makePersistent(instance); + oid = pm.getObjectId(instance); + pm.currentTransaction().commit(); + instance.setX(newXValue); + return instance; } - appendMessage(location + "transaction succeeded but" + " should not succeed."); - } - - /** - * Check the x value of the persistent instance referenced by the oid. Use a new persistence - * manager and check the value in a new transaction so there is no interference with the - * persistence manager that managed the nontransactional dirty instance. - * - * @param location location for error message - * @param expectedXValue expected value - */ - protected void checkXValue(String location, int expectedXValue) { - PersistenceManager pmCheck = pmf.getPersistenceManager(); - try { - pmCheck.currentTransaction().begin(); - VersionedPCPoint instance = (VersionedPCPoint) pmCheck.getObjectById(oid, true); - int actualXValue = instance.getX(); - pmCheck.currentTransaction().commit(); - if (expectedXValue != actualXValue) { - appendMessage( - location + NL + "expected: " + expectedXValue + NL + " actual: " + actualXValue); - } - } finally { - cleanupPM(pmCheck); + + /** + * Begin and rollback a transaction using the persistence manager + * that manages the nontransactional dirty instance. + * @param optimistic use optimistic transaction + */ + protected void beginAndRollbackTransaction(boolean optimistic) { + getPM().currentTransaction().setOptimistic(optimistic); + pm.currentTransaction().begin(); + pm.currentTransaction().rollback(); } - } - - /** - * Perform a conflicting transaction that updates the same field as the nontransactional dirty - * instance. The field value is conflictXValue. This conflicting transaction uses a new - * persistence manager. - */ - protected void conflictingUpdate() { - PersistenceManager pmConflict = pmf.getPersistenceManager(); - try { - pmConflict.currentTransaction().setOptimistic(false); - pmConflict.currentTransaction().begin(); - VersionedPCPoint instance = (VersionedPCPoint) pmConflict.getObjectById(oid); - instance.setX(conflictXValue); - pmConflict.currentTransaction().commit(); - } finally { - cleanupPM(pmConflict); + + /** + * Begin and commit a transaction using the persistence manager + * that manages the nontransactional dirty instance. + * @param optimistic use optimistic transaction + */ + protected void beginAndCommitTransaction(boolean optimistic) { + getPM().currentTransaction().setOptimistic(optimistic); + pm.currentTransaction().begin(); + pm.currentTransaction().commit(); } - } - - /** - * Check that all Nontransactional features are supported. - * - * @param optimistic check for whether Optimistic is supported as well. - * @return true if nontransactional supported - */ - protected boolean checkNontransactionalFeaturesSupported(boolean optimistic) { - if (!checkNontransactionalWriteSupported() - || !checkNontransactionalReadSupported() - || !checkRetainValuesSupported()) return false; - if (optimistic) { - if (!checkOptimisticSupported()) { - return false; - } + + /** + * Begin and commit a transaction using the persistence manager + * that manages the nontransactional dirty instance. This + * transaction must fail due to a conflicting update. + * @param location location for error message + * @param optimistic use optimistic transaction + */ + protected void beginAndCommitTransactionFails(String location, + boolean optimistic) { + getPM().currentTransaction().setOptimistic(optimistic); + pm.currentTransaction().begin(); + try { + pm.currentTransaction().commit(); + } catch (JDOOptimisticVerificationException ex) { + // good catch; return + return; + } + appendMessage(location + "transaction succeeded but" + + " should not succeed."); } - return true; - } - - /** - * Check if NontransactionalWrite is supported, and log a debug message if it is not. - * - * @return true if NontransactionalWriteSupported - */ - protected boolean checkNontransactionalWriteSupported() { - if (!isNontransactionalWriteSupported()) { - printUnsupportedOptionalFeatureNotTested( - getClass().getName(), "javax.jdo.option.NontransactionalWrite"); - return false; + + /** + * Check the x value of the persistent instance referenced + * by the oid. Use a new persistence manager and check the + * value in a new transaction so there is no interference + * with the persistence manager that managed the nontransactional + * dirty instance. + * @param location location for error message + * @param expectedXValue expected value + */ + protected void checkXValue(String location, int expectedXValue) { + PersistenceManager pmCheck = pmf.getPersistenceManager(); + try { + pmCheck.currentTransaction().begin(); + VersionedPCPoint instance = + (VersionedPCPoint)pmCheck.getObjectById(oid, true); + int actualXValue = instance.getX(); + pmCheck.currentTransaction().commit(); + if (expectedXValue != actualXValue) { + appendMessage(location + NL + + "expected: " + expectedXValue + NL + + " actual: " + actualXValue); + } + } finally { + cleanupPM(pmCheck); + } } - return true; - } - - /** - * Check if NontransactionalRead is supported, and log a debug message if it is not. - * - * @return true NontransactionalReadSupported - */ - protected boolean checkNontransactionalReadSupported() { - if (!isNontransactionalReadSupported()) { - printUnsupportedOptionalFeatureNotTested( - getClass().getName(), "javax.jdo.option.NontransactionalRead"); - return false; + + /** + * Perform a conflicting transaction that updates the same field + * as the nontransactional dirty instance. The field value is + * conflictXValue. This conflicting transaction uses a new + * persistence manager. + */ + protected void conflictingUpdate() { + PersistenceManager pmConflict = pmf.getPersistenceManager(); + try { + pmConflict.currentTransaction().setOptimistic(false); + pmConflict.currentTransaction().begin(); + VersionedPCPoint instance = + (VersionedPCPoint)pmConflict.getObjectById(oid); + instance.setX(conflictXValue); + pmConflict.currentTransaction().commit(); + } finally { + cleanupPM(pmConflict); + } } - return true; - } - - /** - * Check if Optimistic is supported, and log a debug message if it is not. - * - * @return true if optimistic is supported - */ - protected boolean checkOptimisticSupported() { - if (!isOptimisticSupported()) { - printUnsupportedOptionalFeatureNotTested(getClass().getName(), "javax.jdo.option.Optimistic"); - return false; + + /** + * Check that all Nontransactional features are supported. + * @param optimistic check for whether Optimistic is supported as well. + * @return true if nontransactional supported + */ + protected boolean checkNontransactionalFeaturesSupported + (boolean optimistic) { + if (!checkNontransactionalWriteSupported() + || !checkNontransactionalReadSupported() + || !checkRetainValuesSupported()) + return false; + if (optimistic) { + if (!checkOptimisticSupported()) { + return false; + } + } + return true; } - return true; - } - - /** - * Check if RetainValues is supported, and log a debug message if it is not. - * - * @return true if retain values is supported - */ - protected boolean checkRetainValuesSupported() { - if (!isRetainValuesSupported()) { - printUnsupportedOptionalFeatureNotTested( - getClass().getName(), "javax.jdo.option.RetainValues"); - return false; + + /** + * Check if NontransactionalWrite is supported, and log a debug + * message if it is not. + * @return true if NontransactionalWriteSupported + */ + protected boolean checkNontransactionalWriteSupported() { + if (!isNontransactionalWriteSupported()) { + printUnsupportedOptionalFeatureNotTested( + getClass().getName(), + "javax.jdo.option.NontransactionalWrite"); + return false; + } + return true; } - return true; - } + + /** + * Check if NontransactionalRead is supported, and log a debug + * message if it is not. + * @return true NontransactionalReadSupported + */ + protected boolean checkNontransactionalReadSupported() { + if (!isNontransactionalReadSupported()) { + printUnsupportedOptionalFeatureNotTested( + getClass().getName(), + "javax.jdo.option.NontransactionalRead"); + return false; + } + return true; + } + + /** + * Check if Optimistic is supported, and log a debug + * message if it is not. + * @return true if optimistic is supported + */ + protected boolean checkOptimisticSupported() { + if (!isOptimisticSupported()) { + printUnsupportedOptionalFeatureNotTested( + getClass().getName(), + "javax.jdo.option.Optimistic"); + return false; + } + return true; + } + + /** + * Check if RetainValues is supported, and log a debug + * message if it is not. + * @return true if retain values is supported + */ + protected boolean checkRetainValuesSupported() { + if (!isRetainValuesSupported()) { + printUnsupportedOptionalFeatureNotTested( + getClass().getName(), + "javax.jdo.option.RetainValues"); + return false; + } + return true; + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteThrows.java b/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteThrows.java index f4ac4b5cb..3b73fa0fa 100644 --- a/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteThrows.java +++ b/tck/src/main/java/org/apache/jdo/tck/lifecycle/NontransactionalWriteThrows.java @@ -5,60 +5,73 @@ * 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 + * + * 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.jdo.tck.lifecycle; import javax.jdo.JDOUnsupportedOptionException; +import javax.jdo.PersistenceManager; + +import org.apache.jdo.tck.JDO_Test; + +import org.apache.jdo.tck.pc.mylib.VersionedPCPoint; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test NontransactionalWriteThrows
    - * Keywords: NontransactionalWrite
    - * Assertion ID: A13.4.2-6
    - * Assertion Description: If an implementation does not support the [NontranasctionalWrite] - * option, then an attempt to set the flag to an unsupported value will throw - * JDOUnsupportedOptionException. + *Title: Test NontransactionalWriteThrows + *
    + *Keywords: NontransactionalWrite + *
    + *Assertion ID: A13.4.2-6 + *
    + *Assertion Description: +If an implementation does not support the [NontranasctionalWrite] +option, then an attempt to set the flag to an unsupported value +will throw JDOUnsupportedOptionException. */ -public class NontransactionalWriteThrows extends NontransactionalWriteTest { - /** */ - protected static final String ASSERTION_FAILED = - "Assertion A13.4.2-6 (NontransactionalWriteThrows) failed: "; +public class NontransactionalWriteThrows extends NontransactionalWriteTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NontransactionalWriteThrows.class); - } + /** */ + protected static final String ASSERTION_FAILED = + "Assertion A13.4.2-6 (NontransactionalWriteThrows) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NontransactionalWriteThrows.class); + } - /** - * Make sure that if NontransactionalWrite is not supported, an exception is thrown when setting - * NontransactionalWrite. - */ - public void testNontransactionalWriteThrows() { - if (!checkNontransactionalWriteSupported()) { - try { - getPM().currentTransaction().setNontransactionalWrite(true); - } catch (JDOUnsupportedOptionException ex) { - return; // good catch - } catch (Exception ex) { - // threw wrong exception - appendMessage(ASSERTION_FAILED + "threw wrong exception " + ex); - } - appendMessage(ASSERTION_FAILED + "failed to throw " + "JDOUnsupportedOptionException"); + /** + * Make sure that if NontransactionalWrite is not supported, + * an exception is thrown when setting NontransactionalWrite. + */ + public void testNontransactionalWriteThrows() { + if (!checkNontransactionalWriteSupported()) { + try { + getPM().currentTransaction().setNontransactionalWrite(true); + } catch (JDOUnsupportedOptionException ex) { + return; // good catch + } catch (Exception ex) { + // threw wrong exception + appendMessage (ASSERTION_FAILED + "threw wrong exception " + ex); + } + appendMessage (ASSERTION_FAILED + "failed to throw " + + "JDOUnsupportedOptionException"); + } + failOnError(); } - failOnError(); - } -} + +} \ No newline at end of file diff --git a/tck/src/main/java/org/apache/jdo/tck/lifecycle/ObjectIdNotModifiedWhenObjectIdInstanceModified.java b/tck/src/main/java/org/apache/jdo/tck/lifecycle/ObjectIdNotModifiedWhenObjectIdInstanceModified.java index b19e64709..adce0ec87 100644 --- a/tck/src/main/java/org/apache/jdo/tck/lifecycle/ObjectIdNotModifiedWhenObjectIdInstanceModified.java +++ b/tck/src/main/java/org/apache/jdo/tck/lifecycle/ObjectIdNotModifiedWhenObjectIdInstanceModified.java @@ -5,137 +5,147 @@ * 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 + * + * 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.jdo.tck.lifecycle; +import java.util.ArrayList; import java.util.Iterator; +import java.util.List; + import javax.jdo.Extent; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.lifecycle.StateTransitionObj; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test that ObjectId is not modified even if ObjectId returned by GetObjectId() is - * modified
    - * Keywords: lifecycle GetObjectId
    - * Assertion IDs: A5.4-6
    - * Assertion Description: The object returned by any call to getObjectId might be modified - * by the user, but that modification does not affect the identity of the object that was originally - * referred. + *Title: Test that ObjectId is not modified even if ObjectId returned by GetObjectId() is modified + *
    + *Keywords: lifecycle GetObjectId + *
    + *Assertion IDs: A5.4-6 + *
    + *Assertion Description: + The object returned by any call to getObjectId might be modified by the user, + but that modification does not affect the identity of the object that was originally referred. */ -public class ObjectIdNotModifiedWhenObjectIdInstanceModified extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A5.4-6 (ObjectIdNotModifiedWhenObjectIdInstanceModified) failed: "; - - private static final int NUM_OBJECTS = 50; - - /** The persistent instances of this test. */ - private Object[] obj; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ObjectIdNotModifiedWhenObjectIdInstanceModified.class); - } +public class ObjectIdNotModifiedWhenObjectIdInstanceModified extends JDO_Test { - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - pm = getPM(); - addTearDownClass(StateTransitionObj.class); - obj = generatePersistentInstances(); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A5.4-6 (ObjectIdNotModifiedWhenObjectIdInstanceModified) failed: "; + + private static final int NUM_OBJECTS = 50; - public void test() throws Exception { - pm.currentTransaction().begin(); - try { - Extent extent = pm.getExtent(StateTransitionObj.class, false); - Iterator iter = extent.iterator(); - if (!iter.hasNext()) { - fail(ASSERTION_FAILED, "Extent for StateTransitionObj should not be empty"); - } - extent.close(iter); - int failures = 0; - StringBuffer report = new StringBuffer("Failures comparing oids.\n"); - for (int i = 0; i < NUM_OBJECTS; i++) { - Object objId1 = pm.getObjectId(obj[i]); - String before = objId1.toString(); - int objId1HashCode = objId1.hashCode(); - Object objId2 = pm.getObjectId(obj[i]); - if (!mangleObject(objId2)) { - /* The object id class is immutable, so the test succeeds. */ - break; - } - int objId2HashCode = objId2.hashCode(); - Object objId3 = pm.getObjectId(obj[i]); // get another ObjectId copy - if (!(objId1.equals(objId3) && objId1HashCode != objId2HashCode)) { - /* The object id obtained after mangling the second object id - * must equal the original object id, and the mangling must - * have changed the mangled id. - */ - report.append("Index= "); - report.append(i); - report.append("\n"); - report.append(" before= "); - report.append(before); - report.append("\n"); - report.append("mangled= "); - report.append(objId2.toString()); - report.append("\n"); - report.append(" after= "); - report.append(objId3.toString()); - report.append("\n"); - ++failures; - } - } - if (failures != 0) { - if (debug) { - logger.debug(report.toString()); - } - fail(ASSERTION_FAILED, "Failed to compare " + failures + " object ids."); - } - pm.currentTransaction().commit(); - } finally { - if (pm != null && pm.currentTransaction().isActive()) { - pm.currentTransaction().rollback(); - } + /** The persistent instances of this test. */ + private Object[] obj; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ObjectIdNotModifiedWhenObjectIdInstanceModified.class); } - } - private Object[] generatePersistentInstances() { - StateTransitionObj[] objects = new StateTransitionObj[NUM_OBJECTS]; - try { - Transaction t = pm.currentTransaction(); - t.begin(); - for (int i = 0; i < NUM_OBJECTS; ++i) { - objects[i] = new StateTransitionObj(i); - objects[i].writeField(i); - pm.makePersistent(objects[i]); - } - t.commit(); - return objects; - } finally { - Transaction tx = pm.currentTransaction(); - if (tx.isActive()) { - tx.rollback(); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + pm = getPM(); + addTearDownClass(StateTransitionObj.class); + obj = generatePersistentInstances(); } - } + + public void test() throws Exception { + pm.currentTransaction().begin(); + try { + Extent extent = pm.getExtent(StateTransitionObj.class, false); + Iterator iter = extent.iterator(); + if( !iter.hasNext() ){ + fail(ASSERTION_FAILED, + "Extent for StateTransitionObj should not be empty"); + } + extent.close(iter); + int failures = 0; + StringBuffer report = new StringBuffer("Failures comparing oids.\n"); + for (int i=0; iTitle: Test that a PM returns the same JDO instance if getObjectById(ObjectId) is called - * multiple times with the same objectId instance
    - * Keywords: lifecycle getObjectById
    - * Assertion IDs: A5.4-2, A5.4-8
    - * Assertion Description: Any instances returned by any calls to getObjectById(Object) with - * the same object id instance to the same PersistenceManager instance must be identical (assuming - * the instances were not garbage collected between calls). + *Title: Test that a PM returns the same JDO instance if getObjectById(ObjectId) is called multiple times with the same objectId instance + *
    + *Keywords: lifecycle getObjectById + *
    + *Assertion IDs: A5.4-2, A5.4-8 + *
    + *Assertion Description: + Any instances returned by any calls to getObjectById(Object) with the same object id instance to the same + PersistenceManager instance must be identical (assuming the instances were not garbage collected between calls). */ -public class PMReturnsIdenticalInstancesForEqualObjIds extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertions A5.4-2, A5.4-8 (PMReturnsIdenticalInstancesForEqualObjIds) failed: "; - - private static final int NUM_OBJECTS = 50; - /** The persistent instances of this test. */ - private Object[] obj; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(PMReturnsIdenticalInstancesForEqualObjIds.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - pm = getPM(); - addTearDownClass(StateTransitionObj.class); - obj = generatePersistentInstances(); - } +public class PMReturnsIdenticalInstancesForEqualObjIds extends JDO_Test { - public void test() { - pm.currentTransaction().begin(); - try { - Extent extent = pm.getExtent(StateTransitionObj.class, false); - Iterator iter = extent.iterator(); - if (!iter.hasNext()) { - fail(ASSERTION_FAILED, "Extent for StateTransitionObj should not be empty"); - } - extent.close(iter); + /** */ + private static final String ASSERTION_FAILED = + "Assertions A5.4-2, A5.4-8 (PMReturnsIdenticalInstancesForEqualObjIds) failed: "; + + private static final int NUM_OBJECTS = 50; - for (int i = 0; i < NUM_OBJECTS; i++) { - Object objId = pm.getObjectId(obj[i]); - // check that getObjectById returns identical instance - Object obj2 = pm.getObjectById(objId, true); - if (!(obj2 == obj[i])) { - fail(ASSERTION_FAILED, "objects with OId = " + objId + " are not identical"); - } - } - pm.currentTransaction().commit(); - } finally { - if (pm != null && pm.currentTransaction().isActive()) { - pm.currentTransaction().rollback(); - } + /** The persistent instances of this test. */ + private Object[] obj; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(PMReturnsIdenticalInstancesForEqualObjIds.class); } - } - private Object[] generatePersistentInstances() { - StateTransitionObj[] objects = new StateTransitionObj[NUM_OBJECTS]; - try { - Transaction t = pm.currentTransaction(); - t.begin(); - for (int i = 0; i < NUM_OBJECTS; ++i) { - objects[i] = new StateTransitionObj(i); - objects[i].writeField(i); - pm.makePersistent(objects[i]); - } - t.commit(); - return objects; - } finally { - Transaction tx = pm.currentTransaction(); - if (tx.isActive()) { - tx.rollback(); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + pm = getPM(); + addTearDownClass(StateTransitionObj.class); + obj = generatePersistentInstances(); } - } + + public void test() { + pm.currentTransaction().begin(); + try { + Extent extent = pm.getExtent(StateTransitionObj.class, false); + Iterator iter = extent.iterator(); + if( !iter.hasNext() ){ + fail(ASSERTION_FAILED, + "Extent for StateTransitionObj should not be empty"); + } + extent.close(iter); + + for (int i=0; iTitle: Test PM ability to share PC classes but not PC instances
    - * Keywords: PM share PC class
    - * Assertion IDs: A5.2-1,A5.2-2,A5.2-3
    - * Assertion Description: Several JDO PersistenceManagers might be coresident and might - * share the same persistence capable classes] (although a JDO instance can be associated with only - * one PersistenceManager at a time) + *Title: Test PM ability to share PC classes but not PC instances + *
    + *Keywords: PM share PC class + *
    + *Assertion IDs: A5.2-1,A5.2-2,A5.2-3 + *
    + *Assertion Description: + Several JDO PersistenceManagers might be coresident and might + share the same persistence capable classes] (although a JDO instance can be + associated with only one PersistenceManager at a time) */ + public class PMsCanSharePCClassesButNotPCInstances extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertions A5.2-1,A5.2-2,A5.2-3 (PMsCanSharePCClassesButNotPCInstances) failed: "; - - /** The number of active threads. Each thread has its own PM. */ - private int threads = 0; - - /** The total number of attempts to insert PC instances */ - private int attempts = 0; - - /** The number of inserters. Each inserter runs in its own thread. */ - private int inserters = 5; - - /** The number of objects inserted. */ - protected int insertedCount = 0; - - /** The number of objects that is expected to have been inserted. */ - protected int insertedCountExpected = 0; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(PMsCanSharePCClassesButNotPCInstances.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(StateTransitionObj.class); - } - - public void testSharedPC() { - // test shared PC - only one PM should succeed to insert the shared PC - threads = 0; - attempts = 0; - insertedCount = 0; - insertedCountExpected = 1; - insertObjects(true); - } - - public void testNonSharedPC() { - // test non-shared PCs - each PM should succeed to insert its own non-shared PC - threads = 0; - attempts = 0; - // insertedCount = 0; //Don't reset this value since we have not deleted the inserted object - // from the shared PC test above - insertedCountExpected += inserters; - insertObjects(false); - } - - protected void insertObjects(boolean sharedPC) { - Object pc = null; - - ThreadExceptionHandler threadGroup = new ThreadExceptionHandler(); - for (int i = 0; i < inserters; i++) { - if (sharedPC) { // each thread shares one PC - if (pc == null) pc = new StateTransitionObj(i); - } else { // each thread has its own PC - pc = new StateTransitionObj(i); - } - threads++; - Thread t = new Thread(threadGroup, new Inserter(pmf, pc, sharedPC)); - t.setName("Inserter-" + i); - t.start(); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertions A5.2-1,A5.2-2,A5.2-3 (PMsCanSharePCClassesButNotPCInstances) failed: "; - Thread.yield(); + /** The number of active threads. Each thread has its own PM. */ + private int threads = 0; - while (!attemptsComplete()) { - try { - Thread.sleep(100); - } catch (InterruptedException ex) { - logger.debug("interrupted while waiting for threads to insert"); - } - } + /** The total number of attempts to insert PC instances */ + private int attempts = 0; - while (threads > 0) { - try { - Thread.sleep(100); - } catch (InterruptedException ex) { - logger.debug("interrupted while waiting for threads to finish"); - } + /** The number of inserters. Each inserter runs in its own thread. */ + private int inserters = 5; + + /** The number of objects inserted. */ + protected int insertedCount = 0; + + /** The number of objects that is expected to have been inserted. */ + protected int insertedCountExpected = 0; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(PMsCanSharePCClassesButNotPCInstances.class); } - Collection exceptions = threadGroup.getAllUncaughtExceptions(); - for (Iterator i = exceptions.iterator(); i.hasNext(); ) { - Map.Entry entry = (Map.Entry) i.next(); - Thread thread = (Thread) entry.getKey(); - Throwable throwable = (Throwable) entry.getValue(); - String message = "Uncaught exception " + throwable + " in thread " + thread; - if (throwable instanceof AssertionFailedError) fail(ASSERTION_FAILED, message); - else throw new JDOFatalException(message, throwable); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(StateTransitionObj.class); } - } - - synchronized void signal() { - threads--; - } - - protected synchronized void incrAttempts() { - attempts++; - } - - protected synchronized boolean attemptsComplete() { - return attempts == inserters; - } - - class Inserter implements Runnable { - private final PersistenceManager pm; - private final Object pc; - private final Class instanceClass; - private final boolean sharedPC; - - Inserter(PersistenceManagerFactory pmf, Object pc, boolean sharedPC) { - this.pm = pmf.getPersistenceManager(); - this.pc = pc; - this.instanceClass = pc.getClass(); - this.sharedPC = sharedPC; + + public void testSharedPC() { + // test shared PC - only one PM should succeed to insert the shared PC + threads = 0; + attempts = 0; + insertedCount = 0; + insertedCountExpected = 1; + insertObjects(true); } - protected synchronized void announce(String msg, Object pc) { - insertedCount++; - Object oid = JDOHelper.getObjectId(pc); - if (debug) logger.debug(msg + this.getClass().getName() + ": " + oid + ", " + pc); + public void testNonSharedPC() { + // test non-shared PCs - each PM should succeed to insert its own non-shared PC + threads = 0; + attempts = 0; + //insertedCount = 0; //Don't reset this value since we have not deleted the inserted object from the shared PC test above + insertedCountExpected += inserters; + insertObjects(false); } - public void run() { - Transaction tx = null; - try { - if (debug) logger.debug("running"); - tx = pm.currentTransaction(); - tx.begin(); - try { - pm.makePersistent(pc); - announce("inserted ", pc); - tx.commit(); - } catch (JDOException ex) { - if (!sharedPC) // we expect an exception for all but one of the inserters in the case of a - // shared PC - throw ex; - } finally { - incrAttempts(); - if (tx != null && tx.isActive()) tx.rollback(); + protected void insertObjects(boolean sharedPC) { + Object pc = null; + + ThreadExceptionHandler threadGroup = new ThreadExceptionHandler(); + for (int i = 0; i < inserters; i++) { + if (sharedPC) { // each thread shares one PC + if (pc==null) + pc = new StateTransitionObj(i); + } + else { // each thread has its own PC + pc = new StateTransitionObj(i); + } + threads++; + Thread t = new Thread(threadGroup, new Inserter(pmf, pc, sharedPC)); + t.setName("Inserter-" + i); + t.start(); + } + + Thread.yield(); + + while (! attemptsComplete()) { + try { + Thread.sleep(100); + } catch (InterruptedException ex) { + logger.debug("interrupted while waiting for threads to insert"); + } } - while (!attemptsComplete()) { - try { - Thread.sleep(100); - } catch (InterruptedException ex) { - if (debug) logger.debug(" interrupted"); - } + while (threads > 0) { + try { + Thread.sleep(100); + } catch (InterruptedException ex) { + logger.debug("interrupted while waiting for threads to finish"); + } + } + + Collection exceptions = threadGroup.getAllUncaughtExceptions(); + for (Iterator i = exceptions.iterator(); i.hasNext(); ) { + Map.Entry entry = (Map.Entry) i.next(); + Thread thread = (Thread)entry.getKey(); + Throwable throwable = (Throwable)entry.getValue(); + String message = "Uncaught exception " + throwable + " in thread " + thread; + if( throwable instanceof AssertionFailedError ) + fail(ASSERTION_FAILED, message); + else + throw new JDOFatalException(message, throwable); } + + } - // Verify that the number of inserted objects matches the expected number - if (insertedCount != insertedCountExpected) { - fail( - ASSERTION_FAILED, - "Wrong number of objects in extent. Inserted=" - + insertedCount - + " Expected=" - + insertedCountExpected); + synchronized void signal() { + threads--; + } + + protected synchronized void incrAttempts() { + attempts++; + } + + protected synchronized boolean attemptsComplete() { + return attempts == inserters; + } + + class Inserter implements Runnable { + private final PersistenceManager pm; + private final Object pc; + private final Class instanceClass; + private final boolean sharedPC; + + Inserter(PersistenceManagerFactory pmf, Object pc, boolean sharedPC) { + this.pm = pmf.getPersistenceManager(); + this.pc = pc; + this.instanceClass = pc.getClass(); + this.sharedPC = sharedPC; } - if (debug) logger.debug("getting Extent"); - int objCount = 0; - if (debug) logger.debug("getting Extent of " + instanceClass.getName()); - tx.begin(); - Extent e = pm.getExtent(instanceClass, false); - for (Iterator i = e.iterator(); i.hasNext(); ) { - Object instance = (Object) i.next(); - objCount++; + protected synchronized void announce(String msg, Object pc) { + insertedCount++; + Object oid = JDOHelper.getObjectId(pc); + if (debug) + logger.debug(msg + this.getClass().getName() + ": " + oid + + ", " + pc); } - tx.commit(); - - // Verify that the number of inserted objects matches the number of objects in the extent - if (insertedCount != objCount) { - fail( - ASSERTION_FAILED, - "Wrong number of objects in extent. Inserted=" - + insertedCount - + " Found=" - + objCount); + + public void run() { + Transaction tx = null; + try { + if (debug) logger.debug("running"); + tx = pm.currentTransaction(); + tx.begin(); + try { + pm.makePersistent(pc); + announce("inserted ", pc); + tx.commit(); + } + catch (JDOException ex) { + if (!sharedPC) //we expect an exception for all but one of the inserters in the case of a shared PC + throw ex; + } + finally { + incrAttempts(); + if (tx != null && tx.isActive()) + tx.rollback(); + } + + while (!attemptsComplete()) { + try { + Thread.sleep(100); + } catch (InterruptedException ex) { + if (debug) logger.debug(" interrupted"); + } + } + + //Verify that the number of inserted objects matches the expected number + if (insertedCount!=insertedCountExpected) + { + fail(ASSERTION_FAILED, + "Wrong number of objects in extent. Inserted=" + + insertedCount + " Expected=" + insertedCountExpected); + } + + if (debug) logger.debug("getting Extent"); + int objCount = 0; + if (debug) + logger.debug("getting Extent of " + instanceClass.getName()); + tx.begin(); + Extent e = pm.getExtent(instanceClass, false); + for (Iterator i = e.iterator(); i.hasNext();) { + Object instance = (Object)i.next(); + objCount++; + } + tx.commit(); + + //Verify that the number of inserted objects matches the number of objects in the extent + if (insertedCount!=objCount) + { + fail(ASSERTION_FAILED, + "Wrong number of objects in extent. Inserted="+insertedCount+" Found="+objCount); + } + } finally { + if (tx != null && tx.isActive()) + tx.rollback(); + if (pm != null && !pm.isClosed()) + pm.close(); + PMsCanSharePCClassesButNotPCInstances.this.signal(); + } } - } finally { - if (tx != null && tx.isActive()) tx.rollback(); - if (pm != null && !pm.isClosed()) pm.close(); - PMsCanSharePCClassesButNotPCInstances.this.signal(); - } - } - public String toString() { - String rc = "Inserter "; - if (debug) { - rc += Thread.currentThread().toString(); - } - return rc; + public String toString() { + String rc = "Inserter "; + if (debug) { + rc += Thread.currentThread().toString(); + } + return rc; + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/lifecycle/StateTransitions.java b/tck/src/main/java/org/apache/jdo/tck/lifecycle/StateTransitions.java index 5cfc7b726..c73ce4e70 100644 --- a/tck/src/main/java/org/apache/jdo/tck/lifecycle/StateTransitions.java +++ b/tck/src/main/java/org/apache/jdo/tck/lifecycle/StateTransitions.java @@ -5,1165 +5,1123 @@ * 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 + * + * 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.jdo.tck.lifecycle; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.util.Iterator; + import javax.jdo.Extent; import javax.jdo.JDOFatalException; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.lifecycle.StateTransitionObj; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test State Transitions
    - * Keywords: lifecycle
    - * Assertion IDs: A5.9-1 through A5.9-190 Assertion Description: All possible state - * transistions are being tested in this test. + *Title: Test State Transitions + *
    + *Keywords: lifecycle + *
    + *Assertion IDs: A5.9-1 through A5.9-190 + *Assertion Description: + All possible state transistions are being tested in this test. */ + public class StateTransitions extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertions A5.9-1 through A5.9-190 (StateTransitions) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(StateTransitions.class); - } - - private Transaction transaction; - private int scenario; - private int operation; - private int current_state; - private int expected_state; - private int new_state; - - /** Operations that cause state changes */ - private static final int MAKEPERSISTENT = 0; - - private static final int DELETEPERSISTENT = 1; - private static final int MAKETRANSACTIONAL = 2; - private static final int MAKENONTRANSACTIONAL = 3; - private static final int MAKETRANSIENT = 4; - private static final int COMMITNORETAINVALUES = 5; - private static final int COMMITRETAINVALUES = 6; - private static final int ROLLBACKNORESTOREVALUES = 7; - private static final int ROLLBACKRESTOREVALUES = 8; - private static final int REFRESHDATASTORE = 9; - private static final int REFRESHOPTIMISTIC = 10; - private static final int EVICT = 11; - private static final int READOUTSIDETX = 12; - private static final int READOPTIMISTIC = 13; - private static final int READDATASTORE = 14; - private static final int WRITEOUTSIDETX = 15; - private static final int WRITEINSIDETX = 16; - private static final int RETRIEVEOUTSIDETX = 17; - private static final int RETRIEVEINSIDETX = 18; - private static final int DETACHALLONCOMMIT = 19; - private static final int DETACHCOPYOUTSIDETXNTRTRU = 20; - private static final int DETACHCOPYOUTSIDETXNTRFLS = 21; - private static final int DETACHCOPYINSIDEDATASTORETX = 22; - private static final int DETACHCOPYINSIDEOPTIMISTICTX = 23; - private static final int SERIALIZEOUTSIDETX = 24; - private static final int SERIALIZEDATASTORE = 25; - private static final int SERIALIZEOPTIMISTIC = 26; - - private static final int NUM_OPERATIONS = 27; - - private static final String[] operations = { - "makePersistent", - "deletePersistent", - "makeTransactional", - "makeNontransactional", - "makeTransient", - "commit, retainValues=false", - "commit, retainValues=true", - "rollback, restoreValues=false", - "rollback, restoreValues=true", - "refresh with active datastore tx", - "refresh with active optimistic tx", - "evict", - "read field outside tx", - "read field with active optimistic tx", - "read field with active datastore tx", - "write field outside tx", - "write field with active tx", - "retrieve outside tx", - "retrieve with active tx", - "commit, detachAllOnCommit=true", - "detachCopy outside tx with NontransactionalRead=true", - "detachCopy outside tx with NontransactionalRead=false", - "detachCopy with active datastore tx", - "detachCopy with active optimistic tx", - "serialize outside tx", - "serialize with active datastore tx", - "serialize with active optimistic tx" - }; - - /** Illegal state transitions */ - private static final int UNCHANGED = -1; - - private static final int ERROR = -2; - private static final int IMPOSSIBLE = -3; - private static final int NOT_APPLICABLE = -4; - private static final int UNSPECIFIED = -5; - - /** State transitions */ - public static final int[][] transitions = { // [operation] [current state] = new state - // TRANSIENT, PERSISTENT_NEW, PERSISTENT_CLEAN, - // PERSISTENT_DIRTY, HOLLOW, TRANSIENT_CLEAN, - // TRANSIENT_DIRTY, PERSISTENT_NEW_DELETED, PERSISTENT_DELETED, - // PERSISTENT_NONTRANSACTIONAL, PERSISTENT_NONTRANSACTIONAL_DIRTY, DETACHED_CLEAN, - // DETACHED_DIRTY - - // makePersistent - { - PERSISTENT_NEW, UNCHANGED, UNCHANGED, - UNCHANGED, UNCHANGED, PERSISTENT_NEW, - PERSISTENT_NEW, UNCHANGED, UNCHANGED, - UNCHANGED, UNCHANGED, DETACHED_CLEAN, - DETACHED_DIRTY - }, - - // deletePersistent - { - ERROR, PERSISTENT_NEW_DELETED, PERSISTENT_DELETED, - PERSISTENT_DELETED, PERSISTENT_DELETED, ERROR, - ERROR, UNCHANGED, UNCHANGED, - PERSISTENT_DELETED, PERSISTENT_DELETED, ERROR, - ERROR - }, - - // makeTransactional - { - TRANSIENT_CLEAN, UNCHANGED, UNCHANGED, - UNCHANGED, PERSISTENT_CLEAN, UNCHANGED, - UNCHANGED, UNCHANGED, UNCHANGED, - PERSISTENT_CLEAN, PERSISTENT_DIRTY, ERROR, - ERROR - }, - - // makeNontransactional - { - ERROR, ERROR, PERSISTENT_NONTRANSACTIONAL, - ERROR, UNCHANGED, TRANSIENT, - ERROR, ERROR, ERROR, - UNCHANGED, UNCHANGED, ERROR, - ERROR - }, - - // makeTransient - { - UNCHANGED, ERROR, TRANSIENT, - ERROR, TRANSIENT, UNCHANGED, - UNCHANGED, ERROR, ERROR, - TRANSIENT, ERROR, ERROR, - ERROR - }, - - // commit, retainValues = false - { - UNCHANGED, HOLLOW, HOLLOW, - HOLLOW, UNCHANGED, UNCHANGED, - TRANSIENT_CLEAN, TRANSIENT, TRANSIENT, - UNCHANGED, HOLLOW, UNCHANGED, - UNCHANGED - }, - - // commit, retainValues = true - { - UNCHANGED, PERSISTENT_NONTRANSACTIONAL, PERSISTENT_NONTRANSACTIONAL, - PERSISTENT_NONTRANSACTIONAL, UNCHANGED, UNCHANGED, - TRANSIENT_CLEAN, TRANSIENT, TRANSIENT, - UNCHANGED, PERSISTENT_NONTRANSACTIONAL, UNCHANGED, - UNCHANGED - }, - - // TRANSIENT, PERSISTENT_NEW, PERSISTENT_CLEAN, - // PERSISTENT_DIRTY, HOLLOW, TRANSIENT_CLEAN, - // TRANSIENT_DIRTY, PERSISTENT_NEW_DELETED, PERSISTENT_DELETED, - // PERSISTENT_NONTRANSACTIONAL, PERSISTENT_NONTRANSACTIONAL_DIRTY, DETACHED_CLEAN, - // DETACHED_DIRTY - - // rollback, restoreValues = false - { - UNCHANGED, TRANSIENT, HOLLOW, - HOLLOW, UNCHANGED, UNCHANGED, - TRANSIENT_CLEAN, TRANSIENT, HOLLOW, - UNCHANGED, HOLLOW, UNCHANGED, - UNCHANGED - }, - - // rollback, restoreValues = true - { - UNCHANGED, TRANSIENT, PERSISTENT_NONTRANSACTIONAL, - PERSISTENT_NONTRANSACTIONAL, UNCHANGED, UNCHANGED, - TRANSIENT_CLEAN, TRANSIENT, PERSISTENT_NONTRANSACTIONAL, - UNCHANGED, UNCHANGED, UNCHANGED, - UNCHANGED - }, - - // refresh with active datastore transaction - { - UNCHANGED, UNCHANGED, UNCHANGED, - PERSISTENT_CLEAN, UNCHANGED, UNCHANGED, - UNCHANGED, UNCHANGED, UNCHANGED, - UNCHANGED, PERSISTENT_NONTRANSACTIONAL, UNCHANGED, - UNCHANGED - }, - - // refresh with active optimistic transaction - { - UNCHANGED, UNCHANGED, UNCHANGED, - PERSISTENT_NONTRANSACTIONAL, UNCHANGED, UNCHANGED, - UNCHANGED, UNCHANGED, UNCHANGED, - UNCHANGED, PERSISTENT_NONTRANSACTIONAL, UNCHANGED, - UNCHANGED - }, - - // evict - { - NOT_APPLICABLE, UNCHANGED, HOLLOW, - UNCHANGED, UNCHANGED, UNCHANGED, - UNCHANGED, UNCHANGED, UNCHANGED, - HOLLOW, HOLLOW, UNCHANGED, - UNCHANGED - }, - - // read field outside transaction - { - UNCHANGED, IMPOSSIBLE, IMPOSSIBLE, - IMPOSSIBLE, PERSISTENT_NONTRANSACTIONAL, IMPOSSIBLE, - IMPOSSIBLE, IMPOSSIBLE, IMPOSSIBLE, - UNCHANGED, UNCHANGED, UNCHANGED, - UNCHANGED - }, - - // read field with active optimistic transaction - { - UNCHANGED, UNCHANGED, UNCHANGED, - UNCHANGED, PERSISTENT_NONTRANSACTIONAL, UNCHANGED, - UNCHANGED, UNSPECIFIED, UNSPECIFIED, - UNCHANGED, UNCHANGED, UNCHANGED, - UNCHANGED - }, - - // TRANSIENT, PERSISTENT_NEW, PERSISTENT_CLEAN, - // PERSISTENT_DIRTY, HOLLOW, TRANSIENT_CLEAN, - // TRANSIENT_DIRTY, PERSISTENT_NEW_DELETED, PERSISTENT_DELETED, - // PERSISTENT_NONTRANSACTIONAL, PERSISTENT_NONTRANSACTIONAL_DIRTY, DETACHED_CLEAN, - // DETACHED_DIRTY - - // read field with active datastore transaction - { - UNCHANGED, UNCHANGED, UNCHANGED, - UNCHANGED, PERSISTENT_CLEAN, UNCHANGED, - UNCHANGED, UNSPECIFIED, UNSPECIFIED, - PERSISTENT_CLEAN, UNCHANGED, UNCHANGED, - UNCHANGED - }, - - // write field outside transaction - { - UNCHANGED, IMPOSSIBLE, IMPOSSIBLE, - IMPOSSIBLE, PERSISTENT_NONTRANSACTIONAL, IMPOSSIBLE, - IMPOSSIBLE, IMPOSSIBLE, IMPOSSIBLE, - PERSISTENT_NONTRANSACTIONAL_DIRTY, UNCHANGED, DETACHED_DIRTY, - UNCHANGED - }, - - // write field with active transaction - { - UNCHANGED, UNCHANGED, PERSISTENT_DIRTY, - UNCHANGED, PERSISTENT_DIRTY, TRANSIENT_DIRTY, - UNCHANGED, ERROR, ERROR, - PERSISTENT_DIRTY, UNCHANGED, DETACHED_DIRTY, - UNCHANGED - }, - - // retrieve outside transaction - { - UNCHANGED, IMPOSSIBLE, IMPOSSIBLE, - IMPOSSIBLE, PERSISTENT_NONTRANSACTIONAL, IMPOSSIBLE, - IMPOSSIBLE, IMPOSSIBLE, IMPOSSIBLE, - UNCHANGED, UNCHANGED, UNCHANGED, - UNCHANGED - }, - - // retrieve with active transaction - { - UNCHANGED, UNCHANGED, UNCHANGED, - UNCHANGED, PERSISTENT_CLEAN, UNCHANGED, - UNCHANGED, UNCHANGED, UNCHANGED, - PERSISTENT_CLEAN, UNCHANGED, UNCHANGED, - UNCHANGED - }, - - // commit, detachAllOnCommit = true - { - UNCHANGED, DETACHED_CLEAN, DETACHED_CLEAN, - DETACHED_CLEAN, DETACHED_CLEAN, UNCHANGED, - TRANSIENT_CLEAN, TRANSIENT, TRANSIENT, - DETACHED_CLEAN, DETACHED_CLEAN, UNCHANGED, - UNCHANGED - }, - - // TRANSIENT, PERSISTENT_NEW, PERSISTENT_CLEAN, - // PERSISTENT_DIRTY, HOLLOW, TRANSIENT_CLEAN, - // TRANSIENT_DIRTY, PERSISTENT_NEW_DELETED, PERSISTENT_DELETED, - // PERSISTENT_NONTRANSACTIONAL, PERSISTENT_NONTRANSACTIONAL_DIRTY, DETACHED_CLEAN, - // DETACHED_DIRTY - - // detachCopy outside tx with NontransactionalRead=true - { - ERROR, IMPOSSIBLE, IMPOSSIBLE, - IMPOSSIBLE, PERSISTENT_NONTRANSACTIONAL, ERROR, - IMPOSSIBLE, IMPOSSIBLE, IMPOSSIBLE, - UNCHANGED, UNCHANGED, UNCHANGED, - UNCHANGED - }, - - // detachCopy outside tx with NontransactionalRead=false - { - ERROR, IMPOSSIBLE, IMPOSSIBLE, - IMPOSSIBLE, ERROR, ERROR, - IMPOSSIBLE, IMPOSSIBLE, IMPOSSIBLE, - ERROR, ERROR, ERROR, - ERROR - }, - - // detachCopy with active datastore tx - { - PERSISTENT_NEW, UNCHANGED, UNCHANGED, - UNCHANGED, PERSISTENT_CLEAN, PERSISTENT_NEW, - PERSISTENT_NEW, ERROR, ERROR, - PERSISTENT_CLEAN, IMPOSSIBLE, UNCHANGED, - UNCHANGED - }, - - // detachCopy with active optimistic tx - { - PERSISTENT_NEW, UNCHANGED, UNCHANGED, - UNCHANGED, PERSISTENT_NONTRANSACTIONAL, PERSISTENT_NEW, - PERSISTENT_NEW, ERROR, ERROR, - UNCHANGED, IMPOSSIBLE, UNCHANGED, - UNCHANGED - }, - - // serialize outside tx - { - UNCHANGED, IMPOSSIBLE, IMPOSSIBLE, - IMPOSSIBLE, UNCHANGED, IMPOSSIBLE, - IMPOSSIBLE, IMPOSSIBLE, IMPOSSIBLE, - UNCHANGED, UNCHANGED, UNCHANGED, - UNCHANGED - }, - - // serialize with active datastore tx - { - UNCHANGED, UNCHANGED, UNCHANGED, - UNCHANGED, PERSISTENT_CLEAN, UNCHANGED, - UNCHANGED, UNCHANGED, UNCHANGED, - PERSISTENT_CLEAN, UNCHANGED, UNCHANGED, - UNCHANGED - }, - - // serialize with active optimistic tx - { - UNCHANGED, UNCHANGED, UNCHANGED, - UNCHANGED, UNCHANGED, UNCHANGED, - UNCHANGED, UNCHANGED, UNCHANGED, - UNCHANGED, UNCHANGED, UNCHANGED, - UNCHANGED - }, - }; - - private static final int DATASTORE_TX = 0; - private static final int OPTIMISTIC_TX = 1; - private static final int NO_TX = 2; - - private static final String[] scenario_string = { - "datastore transaction", "optimistic transaction", "no transaction" - }; - - private static final boolean[][] applies_to_scenario = { - // Datastore Optimistic No tx - {true, true, false}, // makePersistent - {true, true, false}, // deletePersistent - {true, true, false}, // makeTransactional - {true, true, false}, // makeNontransactional - {true, true, false}, // makeTransient - {true, true, false}, // commit RetainValues = false - {true, true, false}, // commit RetainValues = true - {true, true, false}, // rollback RestoreValues = false - {true, true, false}, // rollback RestoreValues = true - {true, false, false}, // refresh with active datastore transaction - {false, true, false}, // refresh with active optimistic transaction - {true, true, false}, // evict - {false, false, true}, // read field outside of a transaction - {false, true, false}, // read field with active optimistic transaction - {true, false, false}, // read field with active datastore transaction - {false, false, true}, // write field or makeDirty outside of a transaction - {true, true, false}, // write field or makeDirty with active transaction - {false, true, true}, // retrieve outside of a transaction or with active optimistic transaction - {true, false, false}, // retrieve with active datastore transaction - {true, true, false}, // commit, DetachAllOnCommit = true - {false, false, true}, // detachCopy outside tx with NonTransactionaRead=true - {false, false, true}, // detachCopy outside tx with NonTransactionaRead=false - {true, false, false}, // detachCopy with active datastore tx - {false, true, false}, // detachCopy with active optimistic tx - {false, false, true}, // serialize outside tx - {true, false, false}, // serialize with active datastore tx - {false, true, false} // serialize with active optimistic tx - }; - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - pm = getPM(); - addTearDownClass(StateTransitionObj.class); - generatePersistentInstances(); - } - - public void test() { - scenario = DATASTORE_TX; - checkTransitions(); - - if (isOptimisticSupported()) { - scenario = OPTIMISTIC_TX; - checkTransitions(); + /** */ + private static final String ASSERTION_FAILED = + "Assertions A5.9-1 through A5.9-190 (StateTransitions) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(StateTransitions.class); } + + private Transaction transaction; + private int scenario; + private int operation; + private int current_state; + private int expected_state; + private int new_state; + + /** + * Operations that cause state changes + */ + private static final int MAKEPERSISTENT = 0; + private static final int DELETEPERSISTENT = 1; + private static final int MAKETRANSACTIONAL = 2; + private static final int MAKENONTRANSACTIONAL = 3; + private static final int MAKETRANSIENT = 4; + private static final int COMMITNORETAINVALUES = 5; + private static final int COMMITRETAINVALUES = 6; + private static final int ROLLBACKNORESTOREVALUES = 7; + private static final int ROLLBACKRESTOREVALUES = 8; + private static final int REFRESHDATASTORE = 9; + private static final int REFRESHOPTIMISTIC = 10; + private static final int EVICT = 11; + private static final int READOUTSIDETX = 12; + private static final int READOPTIMISTIC = 13; + private static final int READDATASTORE = 14; + private static final int WRITEOUTSIDETX = 15; + private static final int WRITEINSIDETX = 16; + private static final int RETRIEVEOUTSIDETX = 17; + private static final int RETRIEVEINSIDETX = 18; + private static final int DETACHALLONCOMMIT = 19; + private static final int DETACHCOPYOUTSIDETXNTRTRU = 20; + private static final int DETACHCOPYOUTSIDETXNTRFLS = 21; + private static final int DETACHCOPYINSIDEDATASTORETX = 22; + private static final int DETACHCOPYINSIDEOPTIMISTICTX = 23; + private static final int SERIALIZEOUTSIDETX = 24; + private static final int SERIALIZEDATASTORE = 25; + private static final int SERIALIZEOPTIMISTIC = 26; + + private static final int NUM_OPERATIONS = 27; + + private static final String[] operations = { + "makePersistent", + "deletePersistent", + "makeTransactional", + "makeNontransactional", + "makeTransient", + "commit, retainValues=false", + "commit, retainValues=true", + "rollback, restoreValues=false", + "rollback, restoreValues=true", + "refresh with active datastore tx", + "refresh with active optimistic tx", + "evict", + "read field outside tx", + "read field with active optimistic tx", + "read field with active datastore tx", + "write field outside tx", + "write field with active tx", + "retrieve outside tx", + "retrieve with active tx", + "commit, detachAllOnCommit=true", + "detachCopy outside tx with NontransactionalRead=true", + "detachCopy outside tx with NontransactionalRead=false", + "detachCopy with active datastore tx", + "detachCopy with active optimistic tx", + "serialize outside tx", + "serialize with active datastore tx", + "serialize with active optimistic tx" + }; + + /** + * Illegal state transitions + */ + private static final int UNCHANGED = -1; + private static final int ERROR = -2; + private static final int IMPOSSIBLE = -3; + private static final int NOT_APPLICABLE = -4; + private static final int UNSPECIFIED = -5; + + /** + * State transitions + */ + public static final int[][] transitions = { // [operation] [current state] = new state + // TRANSIENT, PERSISTENT_NEW, PERSISTENT_CLEAN, + // PERSISTENT_DIRTY, HOLLOW, TRANSIENT_CLEAN, + // TRANSIENT_DIRTY, PERSISTENT_NEW_DELETED, PERSISTENT_DELETED, + // PERSISTENT_NONTRANSACTIONAL, PERSISTENT_NONTRANSACTIONAL_DIRTY, DETACHED_CLEAN, + // DETACHED_DIRTY + + // makePersistent + { PERSISTENT_NEW, UNCHANGED, UNCHANGED, + UNCHANGED, UNCHANGED, PERSISTENT_NEW, + PERSISTENT_NEW, UNCHANGED, UNCHANGED, + UNCHANGED, UNCHANGED, DETACHED_CLEAN, + DETACHED_DIRTY}, + + // deletePersistent + { ERROR, PERSISTENT_NEW_DELETED, PERSISTENT_DELETED, + PERSISTENT_DELETED, PERSISTENT_DELETED, ERROR, + ERROR, UNCHANGED, UNCHANGED, + PERSISTENT_DELETED, PERSISTENT_DELETED, ERROR, + ERROR}, + + // makeTransactional + { TRANSIENT_CLEAN, UNCHANGED, UNCHANGED, + UNCHANGED, PERSISTENT_CLEAN, UNCHANGED, + UNCHANGED, UNCHANGED, UNCHANGED, + PERSISTENT_CLEAN, PERSISTENT_DIRTY, ERROR, + ERROR}, + + // makeNontransactional + { ERROR, ERROR, PERSISTENT_NONTRANSACTIONAL, + ERROR, UNCHANGED, TRANSIENT, + ERROR, ERROR, ERROR, + UNCHANGED, UNCHANGED, ERROR, + ERROR}, + + // makeTransient + { UNCHANGED, ERROR, TRANSIENT, + ERROR, TRANSIENT, UNCHANGED, + UNCHANGED, ERROR, ERROR, + TRANSIENT, ERROR, ERROR, + ERROR}, + + // commit, retainValues = false + { UNCHANGED, HOLLOW, HOLLOW, + HOLLOW, UNCHANGED, UNCHANGED, + TRANSIENT_CLEAN, TRANSIENT, TRANSIENT, + UNCHANGED, HOLLOW, UNCHANGED, + UNCHANGED}, + + // commit, retainValues = true + { UNCHANGED, PERSISTENT_NONTRANSACTIONAL, PERSISTENT_NONTRANSACTIONAL, + PERSISTENT_NONTRANSACTIONAL, UNCHANGED, UNCHANGED, + TRANSIENT_CLEAN, TRANSIENT, TRANSIENT, + UNCHANGED, PERSISTENT_NONTRANSACTIONAL, UNCHANGED, + UNCHANGED}, + + // TRANSIENT, PERSISTENT_NEW, PERSISTENT_CLEAN, + // PERSISTENT_DIRTY, HOLLOW, TRANSIENT_CLEAN, + // TRANSIENT_DIRTY, PERSISTENT_NEW_DELETED, PERSISTENT_DELETED, + // PERSISTENT_NONTRANSACTIONAL, PERSISTENT_NONTRANSACTIONAL_DIRTY, DETACHED_CLEAN, + // DETACHED_DIRTY + + // rollback, restoreValues = false + { UNCHANGED, TRANSIENT, HOLLOW, + HOLLOW, UNCHANGED, UNCHANGED, + TRANSIENT_CLEAN, TRANSIENT, HOLLOW, + UNCHANGED, HOLLOW, UNCHANGED, + UNCHANGED}, + + // rollback, restoreValues = true + { UNCHANGED, TRANSIENT, PERSISTENT_NONTRANSACTIONAL, + PERSISTENT_NONTRANSACTIONAL, UNCHANGED, UNCHANGED, + TRANSIENT_CLEAN, TRANSIENT, PERSISTENT_NONTRANSACTIONAL, + UNCHANGED, UNCHANGED, UNCHANGED, + UNCHANGED}, + + // refresh with active datastore transaction + { UNCHANGED, UNCHANGED, UNCHANGED, + PERSISTENT_CLEAN, UNCHANGED, UNCHANGED, + UNCHANGED, UNCHANGED, UNCHANGED, + UNCHANGED, PERSISTENT_NONTRANSACTIONAL, UNCHANGED, + UNCHANGED}, + + // refresh with active optimistic transaction + { UNCHANGED, UNCHANGED, UNCHANGED, + PERSISTENT_NONTRANSACTIONAL, UNCHANGED, UNCHANGED, + UNCHANGED, UNCHANGED, UNCHANGED, + UNCHANGED, PERSISTENT_NONTRANSACTIONAL, UNCHANGED, + UNCHANGED}, + + // evict + { NOT_APPLICABLE, UNCHANGED, HOLLOW, + UNCHANGED, UNCHANGED, UNCHANGED, + UNCHANGED, UNCHANGED, UNCHANGED, + HOLLOW, HOLLOW, UNCHANGED, + UNCHANGED}, + + // read field outside transaction + { UNCHANGED, IMPOSSIBLE, IMPOSSIBLE, + IMPOSSIBLE, PERSISTENT_NONTRANSACTIONAL, IMPOSSIBLE, + IMPOSSIBLE, IMPOSSIBLE, IMPOSSIBLE, + UNCHANGED, UNCHANGED, UNCHANGED, + UNCHANGED}, + + // read field with active optimistic transaction + { UNCHANGED, UNCHANGED, UNCHANGED, + UNCHANGED, PERSISTENT_NONTRANSACTIONAL, UNCHANGED, + UNCHANGED, UNSPECIFIED, UNSPECIFIED, + UNCHANGED, UNCHANGED, UNCHANGED, + UNCHANGED}, + + // TRANSIENT, PERSISTENT_NEW, PERSISTENT_CLEAN, + // PERSISTENT_DIRTY, HOLLOW, TRANSIENT_CLEAN, + // TRANSIENT_DIRTY, PERSISTENT_NEW_DELETED, PERSISTENT_DELETED, + // PERSISTENT_NONTRANSACTIONAL, PERSISTENT_NONTRANSACTIONAL_DIRTY, DETACHED_CLEAN, + // DETACHED_DIRTY + + // read field with active datastore transaction + { UNCHANGED, UNCHANGED, UNCHANGED, + UNCHANGED, PERSISTENT_CLEAN, UNCHANGED, + UNCHANGED, UNSPECIFIED, UNSPECIFIED, + PERSISTENT_CLEAN, UNCHANGED, UNCHANGED, + UNCHANGED}, + + // write field outside transaction + { UNCHANGED, IMPOSSIBLE, IMPOSSIBLE, + IMPOSSIBLE, PERSISTENT_NONTRANSACTIONAL, IMPOSSIBLE, + IMPOSSIBLE, IMPOSSIBLE, IMPOSSIBLE, + PERSISTENT_NONTRANSACTIONAL_DIRTY, UNCHANGED, DETACHED_DIRTY, + UNCHANGED}, + + // write field with active transaction + { UNCHANGED, UNCHANGED, PERSISTENT_DIRTY, + UNCHANGED, PERSISTENT_DIRTY, TRANSIENT_DIRTY, + UNCHANGED, ERROR, ERROR, + PERSISTENT_DIRTY, UNCHANGED, DETACHED_DIRTY, + UNCHANGED}, + + // retrieve outside transaction + { UNCHANGED, IMPOSSIBLE, IMPOSSIBLE, + IMPOSSIBLE, PERSISTENT_NONTRANSACTIONAL, IMPOSSIBLE, + IMPOSSIBLE, IMPOSSIBLE, IMPOSSIBLE, + UNCHANGED, UNCHANGED, UNCHANGED, + UNCHANGED}, + + // retrieve with active transaction + { UNCHANGED, UNCHANGED, UNCHANGED, + UNCHANGED, PERSISTENT_CLEAN, UNCHANGED, + UNCHANGED, UNCHANGED, UNCHANGED, + PERSISTENT_CLEAN, UNCHANGED, UNCHANGED, + UNCHANGED}, + + // commit, detachAllOnCommit = true + { UNCHANGED, DETACHED_CLEAN, DETACHED_CLEAN, + DETACHED_CLEAN, DETACHED_CLEAN, UNCHANGED, + TRANSIENT_CLEAN, TRANSIENT, TRANSIENT, + DETACHED_CLEAN, DETACHED_CLEAN, UNCHANGED, + UNCHANGED}, + + // TRANSIENT, PERSISTENT_NEW, PERSISTENT_CLEAN, + // PERSISTENT_DIRTY, HOLLOW, TRANSIENT_CLEAN, + // TRANSIENT_DIRTY, PERSISTENT_NEW_DELETED, PERSISTENT_DELETED, + // PERSISTENT_NONTRANSACTIONAL, PERSISTENT_NONTRANSACTIONAL_DIRTY, DETACHED_CLEAN, + // DETACHED_DIRTY + + // detachCopy outside tx with NontransactionalRead=true + { ERROR, IMPOSSIBLE, IMPOSSIBLE, + IMPOSSIBLE, PERSISTENT_NONTRANSACTIONAL, ERROR, + IMPOSSIBLE, IMPOSSIBLE, IMPOSSIBLE, + UNCHANGED, UNCHANGED, UNCHANGED, + UNCHANGED}, + + // detachCopy outside tx with NontransactionalRead=false + { ERROR, IMPOSSIBLE, IMPOSSIBLE, + IMPOSSIBLE, ERROR, ERROR, + IMPOSSIBLE, IMPOSSIBLE, IMPOSSIBLE, + ERROR, ERROR, ERROR, + ERROR}, + + // detachCopy with active datastore tx + { PERSISTENT_NEW, UNCHANGED, UNCHANGED, + UNCHANGED, PERSISTENT_CLEAN, PERSISTENT_NEW, + PERSISTENT_NEW, ERROR, ERROR, + PERSISTENT_CLEAN, IMPOSSIBLE, UNCHANGED, + UNCHANGED}, + + // detachCopy with active optimistic tx + { PERSISTENT_NEW, UNCHANGED, UNCHANGED, + UNCHANGED, PERSISTENT_NONTRANSACTIONAL, PERSISTENT_NEW, + PERSISTENT_NEW, ERROR, ERROR, + UNCHANGED, IMPOSSIBLE, UNCHANGED, + UNCHANGED}, + + // serialize outside tx + { UNCHANGED, IMPOSSIBLE, IMPOSSIBLE, + IMPOSSIBLE, UNCHANGED, IMPOSSIBLE, + IMPOSSIBLE, IMPOSSIBLE, IMPOSSIBLE, + UNCHANGED, UNCHANGED, UNCHANGED, + UNCHANGED}, + + // serialize with active datastore tx + { UNCHANGED, UNCHANGED, UNCHANGED, + UNCHANGED, PERSISTENT_CLEAN, UNCHANGED, + UNCHANGED, UNCHANGED, UNCHANGED, + PERSISTENT_CLEAN, UNCHANGED, UNCHANGED, + UNCHANGED}, + + // serialize with active optimistic tx + { UNCHANGED, UNCHANGED, UNCHANGED, + UNCHANGED, UNCHANGED, UNCHANGED, + UNCHANGED, UNCHANGED, UNCHANGED, + UNCHANGED, UNCHANGED, UNCHANGED, + UNCHANGED}, + }; + + private static final int DATASTORE_TX = 0; + private static final int OPTIMISTIC_TX = 1; + private static final int NO_TX = 2; + + private static final String[] scenario_string = { + "datastore transaction", "optimistic transaction", "no transaction" + }; + + private static final boolean[][] applies_to_scenario = { + // Datastore Optimistic No tx + { true, true, false }, // makePersistent + { true, true, false }, // deletePersistent + { true, true, false }, // makeTransactional + { true, true, false }, // makeNontransactional + { true, true, false }, // makeTransient + { true, true, false }, // commit RetainValues = false + { true, true, false }, // commit RetainValues = true + { true, true, false }, // rollback RestoreValues = false + { true, true, false }, // rollback RestoreValues = true + { true, false, false }, // refresh with active datastore transaction + { false, true, false }, // refresh with active optimistic transaction + { true, true, false }, // evict + { false, false, true }, // read field outside of a transaction + { false, true, false }, // read field with active optimistic transaction + { true, false, false }, // read field with active datastore transaction + { false, false, true }, // write field or makeDirty outside of a transaction + { true, true, false }, // write field or makeDirty with active transaction + { false, true, true }, // retrieve outside of a transaction or with active optimistic transaction + { true, false, false }, // retrieve with active datastore transaction + { true, true, false }, // commit, DetachAllOnCommit = true + { false, false, true }, // detachCopy outside tx with NonTransactionaRead=true + { false, false, true }, // detachCopy outside tx with NonTransactionaRead=false + { true, false, false }, // detachCopy with active datastore tx + { false, true, false }, // detachCopy with active optimistic tx + { false, false, true }, // serialize outside tx + { true, false, false }, // serialize with active datastore tx + { false, true, false } // serialize with active optimistic tx + }; + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + pm = getPM(); + addTearDownClass(StateTransitionObj.class); + generatePersistentInstances(); + } + + public void test() { + scenario = DATASTORE_TX; + checkTransitions(); + + if( isOptimisticSupported() ){ + scenario = OPTIMISTIC_TX; + checkTransitions(); + } - scenario = NO_TX; - checkTransitions(); - failOnError(); - } - - /** */ - private void generatePersistentInstances() { - if (doPersistentInstancesExist()) return; - int i; - Transaction t = pm.currentTransaction(); - t.begin(); - for (i = 0; i < 50; ++i) { - StateTransitionObj sto = new StateTransitionObj(i); - sto.writeField(i); - pm.makePersistent(sto); + scenario = NO_TX; + checkTransitions(); + failOnError(); } - t.commit(); - if (!doPersistentInstancesExist()) - if (debug) logger.debug("StateTransitions unable to create instances of StateTransitionsObj"); - } - - /** */ - private boolean doPersistentInstancesExist() { - boolean ret; - Transaction t = pm.currentTransaction(); - t.begin(); - Extent e = pm.getExtent(StateTransitionObj.class, false); - Iterator iter = e.iterator(); - ret = iter.hasNext(); - t.rollback(); - return ret; - } - - /** - * @param transaction the transaction - */ - public void prepareTransactionAndJDOSettings(Transaction transaction) { - transaction.setNontransactionalRead(false); - transaction.setNontransactionalWrite(false); - if (scenario != NO_TX) { - if (operation == COMMITNORETAINVALUES) transaction.setRetainValues(false); - if (operation == COMMITRETAINVALUES) transaction.setRetainValues(true); - if (operation == ROLLBACKNORESTOREVALUES) transaction.setRestoreValues(false); - if (operation == ROLLBACKRESTOREVALUES) transaction.setRestoreValues(true); - if (operation == DETACHALLONCOMMIT) pm.setDetachAllOnCommit(true); - else pm.setDetachAllOnCommit(false); - - transaction.setOptimistic(scenario == OPTIMISTIC_TX); - transaction.begin(); - if (!transaction.isActive()) - if (debug) logger.debug("StateTransitions: Transaction should be active, but it is not"); - } else { - if (operation == READOUTSIDETX - || operation == RETRIEVEOUTSIDETX - || operation == DETACHCOPYOUTSIDETXNTRTRU - || operation == SERIALIZEOUTSIDETX) { - transaction.setNontransactionalRead(true); - } - if (operation == WRITEOUTSIDETX || current_state == PERSISTENT_NONTRANSACTIONAL_DIRTY) { - transaction.setNontransactionalWrite(true); - } + + /** */ + private void generatePersistentInstances() + { + if( doPersistentInstancesExist() ) return; + int i; + Transaction t = pm.currentTransaction(); + t.begin(); + for( i = 0; i < 50; ++i ){ + StateTransitionObj sto = new StateTransitionObj(i); + sto.writeField(i); + pm.makePersistent(sto); + } + t.commit(); + if( !doPersistentInstancesExist() ) + if (debug) + logger.debug("StateTransitions unable to create instances of StateTransitionsObj"); + } + + /** */ + private boolean doPersistentInstancesExist() + { + boolean ret; + Transaction t = pm.currentTransaction(); + t.begin(); + Extent e = pm.getExtent(StateTransitionObj.class, false); + Iterator iter = e.iterator(); + ret = iter.hasNext(); + t.rollback(); + return ret; } - } - - /** */ - void checkTransitions() { - for (operation = 0; operation < NUM_OPERATIONS; ++operation) { - // rule out situations that do not apply - if (!applies_to_scenario[operation][scenario]) continue; - if ((operation == READOUTSIDETX - || operation == RETRIEVEOUTSIDETX - || operation == DETACHCOPYOUTSIDETXNTRTRU - || operation == SERIALIZEOUTSIDETX) - && !isNontransactionalReadSupported()) continue; - if (operation == WRITEOUTSIDETX && !isNontransactionalWriteSupported()) continue; - if (operation == COMMITRETAINVALUES && !isRetainValuesSupported()) continue; - if (operation == MAKENONTRANSACTIONAL - && !(isNontransactionalReadSupported() || isNontransactionalWriteSupported())) continue; - int NUM_JDO1_STATES = NUM_STATES - 2; // JDO1 is tested so far here. - for (current_state = 0; current_state < NUM_JDO1_STATES; ++current_state) { - if (scenario == OPTIMISTIC_TX && current_state == PERSISTENT_CLEAN) continue; - if ((current_state == TRANSIENT_CLEAN || current_state == TRANSIENT_DIRTY) - && !isTransientTransactionalSupported()) - continue; // this state is not supported by implementation - if (current_state == PERSISTENT_NONTRANSACTIONAL - && !(isNontransactionalReadSupported() || isNontransactionalWriteSupported())) - continue; // this state is not supported by implementation - if (current_state == PERSISTENT_NONTRANSACTIONAL_DIRTY - && !isNontransactionalWriteSupported()) continue; - - expected_state = transitions[operation][current_state]; - if (expected_state == IMPOSSIBLE) continue; - if (expected_state == NOT_APPLICABLE) continue; - if (expected_state == UNSPECIFIED) continue; - if (expected_state == UNCHANGED) expected_state = current_state; - try { - transaction = pm.currentTransaction(); - if (transaction.isActive()) { - if (debug) logger.debug("Transaction is active (but should not be), rolling back"); - transaction.rollback(); - } - - prepareTransactionAndJDOSettings(transaction); - - printSituation(); - - StateTransitionObj obj = getInstanceInState(current_state); - if (obj == null) { // could not get object in state - if (transaction.isActive()) transaction.rollback(); - continue; - } - - // Apply operation, catching possible exception - Exception e = null; - try { - applyOperation(operation, obj); - } catch (Exception excep) { - if (excep instanceof javax.jdo.JDOUserException) { - e = excep; - } else { - appendMessage( - ASSERTION_FAILED - + NL - + "StateTransitions: " - + scenario_string[scenario] - + "; current state " - + states[current_state] - + NL - + operations[operation] - + "; unexpected exception:" - + excep); - continue; + + /** + * + * @param transaction the transaction + */ + public void prepareTransactionAndJDOSettings(Transaction transaction) { + transaction.setNontransactionalRead(false); + transaction.setNontransactionalWrite(false); + if( scenario != NO_TX ) { + if( operation == COMMITNORETAINVALUES ) + transaction.setRetainValues(false); + if( operation == COMMITRETAINVALUES ) + transaction.setRetainValues(true); + if( operation == ROLLBACKNORESTOREVALUES ) + transaction.setRestoreValues(false); + if( operation == ROLLBACKRESTOREVALUES ) + transaction.setRestoreValues(true); + if( operation == DETACHALLONCOMMIT ) + pm.setDetachAllOnCommit(true); + else + pm.setDetachAllOnCommit(false); + + transaction.setOptimistic(scenario == OPTIMISTIC_TX); + transaction.begin(); + if( !transaction.isActive() ) + if (debug) + logger.debug("StateTransitions: Transaction should be active, but it is not"); + } else { + if( operation == READOUTSIDETX || + operation == RETRIEVEOUTSIDETX || + operation == DETACHCOPYOUTSIDETXNTRTRU || + operation == SERIALIZEOUTSIDETX ) { + transaction.setNontransactionalRead(true); } - } - - // Get new state, verify correct transition and exceptions occurred - new_state = currentState(obj); - if (expected_state == ERROR) { - if (e == null) { - appendMessage( - ASSERTION_FAILED - + NL - + "StateTransitions: " - + scenario_string[scenario] - + "; current state " - + states[current_state] - + NL - + operations[operation] - + "; JDOUserException should have been thrown"); - } else { - if (!compareStates(new_state, current_state)) { - appendMessage( - ASSERTION_FAILED - + NL - + "StateTransitions: " - + scenario_string[scenario] - + "; current state " - + states[current_state] - + NL - + operations[operation] - + "; JDOUserException properly thrown, but instance should remain in current state," - + "instance changed state to " - + states[new_state]); - } + if( operation == WRITEOUTSIDETX || + current_state == PERSISTENT_NONTRANSACTIONAL_DIRTY) { + transaction.setNontransactionalWrite(true); } - } - if (!compareStates(new_state, expected_state)) { - appendMessage( - ASSERTION_FAILED - + NL - + "StateTransitions: " - + scenario_string[scenario] - + "; current state " - + states[current_state] - + NL - + operations[operation] - + " transitioned instance to invalid state " - + states[new_state] - + "; expected state " - + states[expected_state]); - } - if (transaction.isActive()) transaction.rollback(); - } catch (Exception unexpected_exception) { - if (debug) { - unexpected_exception.printStackTrace(); - } - if (transaction.isActive()) transaction.rollback(); - appendMessage( - ASSERTION_FAILED - + NL - + "StateTransitions: " - + scenario_string[scenario] - + "; current state " - + states[current_state] - + NL - + operations[operation] - + "; unexpected exception caught: " - + unexpected_exception); } - } } - } - - /** */ - void printSituation() { - if (debug) { - logger.debug( - " (" - + scenario_string[scenario] - + ", initial state=" - + states[current_state] - + ", operation=" - + operations[operation] - + ")"); + + /** */ + void checkTransitions() + { + for( operation = 0; operation < NUM_OPERATIONS; ++operation ){ + // rule out situations that do not apply + if( !applies_to_scenario[operation][scenario] ) continue; + if( (operation == READOUTSIDETX || + operation == RETRIEVEOUTSIDETX || + operation == DETACHCOPYOUTSIDETXNTRTRU || + operation == SERIALIZEOUTSIDETX) && + !isNontransactionalReadSupported() ) continue; + if( operation == WRITEOUTSIDETX && !isNontransactionalWriteSupported() ) continue; + if( operation == COMMITRETAINVALUES && !isRetainValuesSupported() ) continue; + if( operation == MAKENONTRANSACTIONAL && + !(isNontransactionalReadSupported() || isNontransactionalWriteSupported()) ) + continue; + int NUM_JDO1_STATES = NUM_STATES - 2; // JDO1 is tested so far here. + for( current_state = 0; current_state < NUM_JDO1_STATES; ++current_state){ + if( scenario == OPTIMISTIC_TX && current_state == PERSISTENT_CLEAN ) continue; + if( (current_state == TRANSIENT_CLEAN || current_state == TRANSIENT_DIRTY) && + !isTransientTransactionalSupported() ) + continue; // this state is not supported by implementation + if( current_state == PERSISTENT_NONTRANSACTIONAL && + !(isNontransactionalReadSupported() || isNontransactionalWriteSupported()) ) + continue; // this state is not supported by implementation + if( current_state == PERSISTENT_NONTRANSACTIONAL_DIRTY && + !isNontransactionalWriteSupported() ) + continue; + + expected_state = transitions[operation][current_state]; + if( expected_state == IMPOSSIBLE ) continue; + if( expected_state == NOT_APPLICABLE ) continue; + if( expected_state == UNSPECIFIED ) continue; + if( expected_state == UNCHANGED ) expected_state = current_state; + try { + transaction = pm.currentTransaction(); + if( transaction.isActive()){ + if (debug) + logger.debug("Transaction is active (but should not be), rolling back"); + transaction.rollback(); + } + + prepareTransactionAndJDOSettings(transaction); + + printSituation(); + + StateTransitionObj obj = getInstanceInState(current_state); + if( obj == null ){ // could not get object in state + if( transaction.isActive() ) transaction.rollback(); + continue; + } + + // Apply operation, catching possible exception + Exception e = null; + try { + applyOperation(operation, obj); + } catch( Exception excep ){ + if( excep instanceof javax.jdo.JDOUserException ){ + e = excep; + } else { + appendMessage(ASSERTION_FAILED + NL + + "StateTransitions: " + + scenario_string[scenario] + + "; current state " + states[current_state] + NL + + operations[operation] + + "; unexpected exception:" + excep); + continue; + } + } + + // Get new state, verify correct transition and exceptions occurred + new_state = currentState(obj); + if( expected_state == ERROR ){ + if( e == null ){ + appendMessage(ASSERTION_FAILED + NL + + "StateTransitions: " + + scenario_string[scenario] + + "; current state " + states[current_state] + NL + + operations[operation] + + "; JDOUserException should have been thrown"); + } else { + if( !compareStates(new_state, current_state) ) { + appendMessage(ASSERTION_FAILED + NL + + "StateTransitions: " + + scenario_string[scenario] + + "; current state " + states[current_state] + NL + + operations[operation] + + "; JDOUserException properly thrown, but instance should remain in current state," + + "instance changed state to " + states[new_state]); + } + } + } + if( !compareStates(new_state, expected_state) ) { + appendMessage(ASSERTION_FAILED + NL + + "StateTransitions: " + + scenario_string[scenario] + + "; current state " + states[current_state] + NL + + operations[operation] + + " transitioned instance to invalid state " + states[new_state] + + "; expected state " + states[expected_state]); + } + if( transaction.isActive() ) transaction.rollback(); + } + catch(Exception unexpected_exception) { + if (debug) { + unexpected_exception.printStackTrace(); + } + if (transaction.isActive()) + transaction.rollback(); + appendMessage(ASSERTION_FAILED + NL + + "StateTransitions: " + + scenario_string[scenario] + + "; current state " + states[current_state] + NL + + operations[operation] + + "; unexpected exception caught: " + unexpected_exception); + } + } + } + } + + /** */ + void printSituation() + { + if (debug) { + logger.debug(" (" + scenario_string[scenario] + + ", initial state=" + states[current_state] + + ", operation=" + operations[operation] + ")"); + } } - } - /** */ - void applyOperation(int operation, StateTransitionObj stobj) { - StateTransitionObj obj = (StateTransitionObj) stobj; - switch (operation) { - case MAKEPERSISTENT: + /** */ + void applyOperation(int operation, StateTransitionObj stobj) + { + StateTransitionObj obj = (StateTransitionObj) stobj; + switch( operation ){ + case MAKEPERSISTENT: { - pm.makePersistent(obj); - break; + pm.makePersistent(obj); + break; } - case DELETEPERSISTENT: + case DELETEPERSISTENT: { - pm.deletePersistent(obj); - break; + pm.deletePersistent(obj); + break; } - case MAKETRANSACTIONAL: + case MAKETRANSACTIONAL: { - pm.makeTransactional(obj); - break; + pm.makeTransactional(obj); + break; } - case MAKENONTRANSACTIONAL: + case MAKENONTRANSACTIONAL: { - pm.makeNontransactional(obj); - break; + pm.makeNontransactional(obj); + break; } - case MAKETRANSIENT: + case MAKETRANSIENT: { - pm.makeTransient(obj); - break; + pm.makeTransient(obj); + break; } - case COMMITNORETAINVALUES: + case COMMITNORETAINVALUES: { - pm.currentTransaction().commit(); - break; + pm.currentTransaction().commit(); + break; } - case COMMITRETAINVALUES: + case COMMITRETAINVALUES: { - pm.currentTransaction().commit(); - break; + pm.currentTransaction().commit(); + break; } - case ROLLBACKNORESTOREVALUES: + case ROLLBACKNORESTOREVALUES: { - pm.currentTransaction().rollback(); - break; + pm.currentTransaction().rollback(); + break; } - case ROLLBACKRESTOREVALUES: + case ROLLBACKRESTOREVALUES: { - pm.currentTransaction().rollback(); - break; + pm.currentTransaction().rollback(); + break; } - case REFRESHDATASTORE: + case REFRESHDATASTORE: { - pm.refresh(obj); - break; + pm.refresh(obj); + break; } - case REFRESHOPTIMISTIC: + case REFRESHOPTIMISTIC: { - pm.refresh(obj); - break; + pm.refresh(obj); + break; } - case EVICT: + case EVICT: { - pm.evict(obj); - break; + pm.evict(obj); + break; } - case READOUTSIDETX: + case READOUTSIDETX: { - obj.readField(); - break; + obj.readField(); + break; } - case READOPTIMISTIC: + case READOPTIMISTIC: { - obj.readField(); - break; + obj.readField(); + break; } - case READDATASTORE: + case READDATASTORE: { - obj.readField(); - break; + obj.readField(); + break; } - case WRITEOUTSIDETX: + case WRITEOUTSIDETX: { - obj.writeField(42); - break; + obj.writeField(42); + break; } - case WRITEINSIDETX: + case WRITEINSIDETX: { - obj.writeField(42); - break; + obj.writeField(42); + break; } - case RETRIEVEOUTSIDETX: + case RETRIEVEOUTSIDETX: { - pm.retrieve(obj); - break; + pm.retrieve(obj); + break; } - case RETRIEVEINSIDETX: + case RETRIEVEINSIDETX: { - pm.retrieve(obj); - break; + pm.retrieve(obj); + break; } - case DETACHALLONCOMMIT: + case DETACHALLONCOMMIT: { - pm.currentTransaction().commit(); - break; + pm.currentTransaction().commit(); + break; } - case DETACHCOPYOUTSIDETXNTRTRU: + case DETACHCOPYOUTSIDETXNTRTRU: { - pm.detachCopy(obj); - break; + pm.detachCopy(obj); + break; } - case DETACHCOPYOUTSIDETXNTRFLS: + case DETACHCOPYOUTSIDETXNTRFLS: { - pm.detachCopy(obj); - break; + pm.detachCopy(obj); + break; } - case DETACHCOPYINSIDEDATASTORETX: + case DETACHCOPYINSIDEDATASTORETX: { - pm.detachCopy(obj); - break; + pm.detachCopy(obj); + break; } - case DETACHCOPYINSIDEOPTIMISTICTX: + case DETACHCOPYINSIDEOPTIMISTICTX: { - pm.detachCopy(obj); - break; + pm.detachCopy(obj); + break; } - case SERIALIZEOUTSIDETX: + case SERIALIZEOUTSIDETX: { - ObjectOutputStream oos = null; - try { - oos = new ObjectOutputStream(new ByteArrayOutputStream()); - oos.writeObject(obj); - } catch (IOException e) { - throw new JDOFatalException(e.getMessage(), e); - } finally { - if (oos != null) { - try { - oos.close(); - } catch (IOException e) { + ObjectOutputStream oos = null; + try { + oos = new ObjectOutputStream(new ByteArrayOutputStream()); + oos.writeObject(obj); + } catch (IOException e) { throw new JDOFatalException(e.getMessage(), e); - } + } finally { + if (oos != null) { + try { + oos.close(); + } catch (IOException e) { + throw new JDOFatalException(e.getMessage(), e); + } + } } - } - break; + break; } - case SERIALIZEDATASTORE: - case SERIALIZEOPTIMISTIC: + case SERIALIZEDATASTORE: + case SERIALIZEOPTIMISTIC: { - ObjectOutputStream oos = null; - try { - oos = new ObjectOutputStream(new ByteArrayOutputStream()); - oos.writeObject(obj); - } catch (IOException e) { - throw new JDOFatalException(e.getMessage(), e); - } finally { - if (oos != null) { - try { - oos.close(); - } catch (IOException e) { + ObjectOutputStream oos = null; + try { + oos = new ObjectOutputStream(new ByteArrayOutputStream()); + oos.writeObject(obj); + } catch (IOException e) { throw new JDOFatalException(e.getMessage(), e); - } + } finally { + if (oos != null) { + try { + oos.close(); + } catch (IOException e) { + throw new JDOFatalException(e.getMessage(), e); + } + } } - } - break; + break; } - default: + default: { - appendMessage( - ASSERTION_FAILED - + NL - + "StateTransitions: " - + scenario_string[scenario] - + "; internal error, illegal operation: " - + operation); + appendMessage(ASSERTION_FAILED + NL + + "StateTransitions: " + + scenario_string[scenario] + + "; internal error, illegal operation: " + operation); + } } } - } - - /** - * Get an instance in the specified state. - * - * @param state the state - * @return instance in the specified state. - */ - public StateTransitionObj getInstanceInState(int state) { - switch (state) { - case TRANSIENT: - return getTransientInstance(); - case PERSISTENT_NEW: - return getPersistentNewInstance(); - case PERSISTENT_CLEAN: - return getPersistentCleanInstance(); - case PERSISTENT_DIRTY: - return getPersistentDirtyInstance(); - case HOLLOW: - return getHollowInstance(); - case TRANSIENT_CLEAN: - return getTransientCleanInstance(); - case TRANSIENT_DIRTY: - return getTransientDirtyInstance(); - case PERSISTENT_NEW_DELETED: - return getPersistentNewDeletedInstance(); - case PERSISTENT_DELETED: - return getPersistentDeletedInstance(); - case PERSISTENT_NONTRANSACTIONAL: - return getPersistentNontransactionalInstance(); - case PERSISTENT_NONTRANSACTIONAL_DIRTY: - return getPersistentNontransactionalDirtyInstance(); - case DETACHED_CLEAN: - return getDetachedCleanInstance(); - case DETACHED_DIRTY: - return getDetachedDirtyInstance(); - default: - return null; - } - } - - /** - * @return transient instance - */ - public StateTransitionObj getTransientInstance() { - StateTransitionObj obj = new StateTransitionObj(23); - int curr = currentState(obj); - if (curr != TRANSIENT) { - if (debug) { - logger.debug( - "StateTransitions: Unable to create transient instance, state is " + states[curr]); - } - return null; + + /** + * Get an instance in the specified state. + * @param state the state + * @return instance in the specified state. + */ + public StateTransitionObj getInstanceInState(int state) + { + switch(state) { + case TRANSIENT: + return getTransientInstance(); + case PERSISTENT_NEW: + return getPersistentNewInstance(); + case PERSISTENT_CLEAN: + return getPersistentCleanInstance(); + case PERSISTENT_DIRTY: + return getPersistentDirtyInstance(); + case HOLLOW: + return getHollowInstance(); + case TRANSIENT_CLEAN: + return getTransientCleanInstance(); + case TRANSIENT_DIRTY: + return getTransientDirtyInstance(); + case PERSISTENT_NEW_DELETED: + return getPersistentNewDeletedInstance(); + case PERSISTENT_DELETED: + return getPersistentDeletedInstance(); + case PERSISTENT_NONTRANSACTIONAL: + return getPersistentNontransactionalInstance(); + case PERSISTENT_NONTRANSACTIONAL_DIRTY: + return getPersistentNontransactionalDirtyInstance(); + case DETACHED_CLEAN: + return getDetachedCleanInstance(); + case DETACHED_DIRTY: + return getDetachedDirtyInstance(); + default: + return null; + } } - return obj; - } - - /** - * @return persistent new instance - */ - public StateTransitionObj getPersistentNewInstance() { - StateTransitionObj obj = getTransientInstance(); - if (obj == null) return null; - pm.makePersistent(obj); // should transition to persistent-new - int curr = currentState(obj); - if (curr != PERSISTENT_NEW) { - if (debug) { - logger.debug( - "StateTransitions: Unable to create persistent-new instance" - + " from transient instance via makePersistent(), state is " - + states[curr]); - } - return null; + + /** + * + * @return transient instance + */ + public StateTransitionObj getTransientInstance() + { + StateTransitionObj obj = new StateTransitionObj(23); + int curr = currentState(obj); + if( curr != TRANSIENT ) { + if (debug) { + logger.debug("StateTransitions: Unable to create transient instance, state is " + + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return persistent clean instance - */ - public StateTransitionObj getPersistentCleanInstance() { - StateTransitionObj obj = getHollowInstance(); - if (obj == null) return null; - StateTransitionObj sto = (StateTransitionObj) obj; - sto.readField(); - int curr = currentState(sto); - if (curr != PERSISTENT_CLEAN) { - if (debug) { - logger.debug( - "StateTransition: Unable to create persistent-clean instance" - + " from a hollow instance by reading a field, state is " - + states[curr]); - } - return null; + + /** + * + * @return persistent new instance + */ + public StateTransitionObj getPersistentNewInstance() + { + StateTransitionObj obj = getTransientInstance(); + if( obj == null ) return null; + pm.makePersistent(obj); // should transition to persistent-new + int curr = currentState(obj); + if( curr != PERSISTENT_NEW ) { + if (debug) { + logger.debug("StateTransitions: Unable to create persistent-new instance" + + " from transient instance via makePersistent(), state is " + + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return persistent dirty instance - */ - public StateTransitionObj getPersistentDirtyInstance() { - StateTransitionObj obj = getHollowInstance(); - if (obj == null) return null; - StateTransitionObj pcobj = (StateTransitionObj) obj; - pcobj.writeField(23); - int curr = currentState(obj); - if (curr != PERSISTENT_DIRTY) { - if (debug) { - logger.debug( - "StateTransition: Unable to create persistent-dirty instance" - + " from a hollow instance by writing a field, state is " - + states[curr]); - } - return null; + + /** + * + * @return persistent clean instance + */ + public StateTransitionObj getPersistentCleanInstance() + { + StateTransitionObj obj = getHollowInstance(); + if( obj == null ) return null; + StateTransitionObj sto = (StateTransitionObj) obj; + sto.readField(); + int curr = currentState(sto); + if( curr != PERSISTENT_CLEAN ) { + if (debug) { + logger.debug("StateTransition: Unable to create persistent-clean instance" + + " from a hollow instance by reading a field, state is " + + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return hollow instance - */ - public StateTransitionObj getHollowInstance() { - if (!transaction.isActive()) transaction.begin(); - if (!transaction.isActive()) - if (debug) logger.debug("getHollowInstance: Transaction should be active, but it is not"); - - Extent extent = pm.getExtent(StateTransitionObj.class, false); - Iterator iter = extent.iterator(); - if (!iter.hasNext()) { - if (debug) logger.debug("Extent for StateTransitionObj should not be empty"); - return null; + + /** + * + * @return persistent dirty instance + */ + public StateTransitionObj getPersistentDirtyInstance() + { + StateTransitionObj obj = getHollowInstance(); + if( obj == null ) return null; + StateTransitionObj pcobj = (StateTransitionObj) obj; + pcobj.writeField(23); + int curr = currentState(obj); + if( curr != PERSISTENT_DIRTY ) { + if (debug) { + logger.debug("StateTransition: Unable to create persistent-dirty instance" + + " from a hollow instance by writing a field, state is " + + states[curr]); + } + return null; + } + return obj; } - StateTransitionObj obj = (StateTransitionObj) iter.next(); - - pm.makeTransactional(obj); - transaction.setRetainValues(false); - transaction.commit(); // This should put the instance in the HOLLOW state - - prepareTransactionAndJDOSettings(transaction); - - int curr = currentState(obj); - if (curr != HOLLOW && curr != PERSISTENT_NONTRANSACTIONAL) { - if (debug) { - logger.debug( - "getHollowInstance: Attempt to get hollow instance via accessing extent failed, state is " - + states[curr]); - } - return null; + + /** + * + * @return hollow instance + */ + public StateTransitionObj getHollowInstance() + { + if ( !transaction.isActive() ) + transaction.begin(); + if( !transaction.isActive() ) + if (debug) + logger.debug("getHollowInstance: Transaction should be active, but it is not"); + + Extent extent = pm.getExtent(StateTransitionObj.class, false); + Iterator iter = extent.iterator(); + if( !iter.hasNext() ){ + if (debug) + logger.debug("Extent for StateTransitionObj should not be empty"); + return null; + } + StateTransitionObj obj = (StateTransitionObj) iter.next(); + + pm.makeTransactional(obj); + transaction.setRetainValues(false); + transaction.commit(); // This should put the instance in the HOLLOW state + + prepareTransactionAndJDOSettings(transaction); + + int curr = currentState(obj); + if( curr != HOLLOW && curr != PERSISTENT_NONTRANSACTIONAL ){ + if (debug) { + logger.debug("getHollowInstance: Attempt to get hollow instance via accessing extent failed, state is " + + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return transient clean instance - */ - public StateTransitionObj getTransientCleanInstance() { - StateTransitionObj obj = getTransientInstance(); - if (obj == null) return null; - pm.makeTransactional(obj); - int curr = currentState(obj); - if (curr != TRANSIENT_CLEAN) { - if (debug) { - logger.debug( - "StateTransition: Unable to create transient-clean instance" - + " from a transient instance via makeTransactional(), state is " - + states[curr]); - } - return null; + + /** + * + * @return transient clean instance + */ + public StateTransitionObj getTransientCleanInstance() + { + StateTransitionObj obj = getTransientInstance(); + if( obj == null ) return null; + pm.makeTransactional(obj); + int curr = currentState(obj); + if( curr != TRANSIENT_CLEAN ) { + if (debug) { + logger.debug("StateTransition: Unable to create transient-clean instance" + + " from a transient instance via makeTransactional(), state is " + + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return transient dirty instance - */ - public StateTransitionObj getTransientDirtyInstance() { - StateTransitionObj obj = getTransientCleanInstance(); - if (obj == null) return null; - StateTransitionObj pcobj = (StateTransitionObj) obj; - pcobj.writeField(23); - int curr = currentState(obj); - if (curr != TRANSIENT_DIRTY) { - if (debug) { - logger.debug( - "StateTransition: Unable to create transient-dirty instance" - + " from a transient-clean instance via modifying a field, state is " - + states[curr]); - } - return null; + + /** + * + * @return transient dirty instance + */ + public StateTransitionObj getTransientDirtyInstance() + { + StateTransitionObj obj = getTransientCleanInstance(); + if( obj == null ) return null; + StateTransitionObj pcobj = (StateTransitionObj) obj; + pcobj.writeField(23); + int curr = currentState(obj); + if( curr != TRANSIENT_DIRTY ) { + if (debug) { + logger.debug("StateTransition: Unable to create transient-dirty instance" + + " from a transient-clean instance via modifying a field, state is " + + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return persitent new deleted instance - */ - public StateTransitionObj getPersistentNewDeletedInstance() { - StateTransitionObj obj = getPersistentNewInstance(); - if (obj == null) return null; - pm.deletePersistent(obj); // should transition to persistent-new-deleted - int curr = currentState(obj); - if (curr != PERSISTENT_NEW_DELETED) { - if (debug) { - logger.debug( - "StateTransition: Unable to create persistent-new-deleted instance" - + " from a persistent-new instance via deletePersistent, state is " - + states[curr]); - } - return null; + + /** + * + * @return persitent new deleted instance + */ + public StateTransitionObj getPersistentNewDeletedInstance() + { + StateTransitionObj obj = getPersistentNewInstance(); + if( obj == null ) return null; + pm.deletePersistent(obj); // should transition to persistent-new-deleted + int curr = currentState(obj); + if( curr != PERSISTENT_NEW_DELETED) { + if (debug) { + logger.debug("StateTransition: Unable to create persistent-new-deleted instance" + + " from a persistent-new instance via deletePersistent, state is " + + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return persitent deleted instance - */ - public StateTransitionObj getPersistentDeletedInstance() { - StateTransitionObj obj = getHollowInstance(); - if (obj == null) return null; - pm.deletePersistent(obj); - int curr = currentState(obj); - if (curr != PERSISTENT_DELETED) { - if (debug) { - logger.debug( - "StateTransition: Unable to create persistent-deleted instance" - + " from a persistent instance via deletePersistent(), state is " - + states[curr]); - } - return null; + + /** + * + * @return persitent deleted instance + */ + public StateTransitionObj getPersistentDeletedInstance() + { + StateTransitionObj obj = getHollowInstance(); + if( obj == null ) return null; + pm.deletePersistent(obj); + int curr = currentState(obj); + if( curr != PERSISTENT_DELETED ) { + if (debug) { + logger.debug("StateTransition: Unable to create persistent-deleted instance" + + " from a persistent instance via deletePersistent(), state is " + + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return persient nontransactional instance - */ - public StateTransitionObj getPersistentNontransactionalInstance() { - StateTransitionObj obj = getHollowInstance(); - if (obj == null) return null; - boolean nontransactionalRead = pm.currentTransaction().getNontransactionalRead(); - pm.currentTransaction().setNontransactionalRead(true); - obj.readField(); - pm.makeNontransactional(obj); - pm.currentTransaction().setNontransactionalRead(nontransactionalRead); - int curr = currentState(obj); - if (curr != PERSISTENT_NONTRANSACTIONAL && curr != HOLLOW) { - if (debug) { - logger.debug( - "StateTransition: Unable to create persistent-nontransactional instance" - + " from a persistent-clean instance via makeNontransactional(), state is " - + states[curr]); - } - return null; + + /** + * + * @return persient nontransactional instance + */ + public StateTransitionObj getPersistentNontransactionalInstance() + { + StateTransitionObj obj = getHollowInstance(); + if( obj == null ) return null; + boolean nontransactionalRead = + pm.currentTransaction().getNontransactionalRead(); + pm.currentTransaction().setNontransactionalRead(true); + obj.readField(); + pm.makeNontransactional(obj); + pm.currentTransaction().setNontransactionalRead(nontransactionalRead); + int curr = currentState(obj); + if( curr != PERSISTENT_NONTRANSACTIONAL && curr != HOLLOW ) { + if (debug) { + logger.debug("StateTransition: Unable to create persistent-nontransactional instance" + + " from a persistent-clean instance via makeNontransactional(), state is " + + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return persient nontransactional dirty instance - */ - public StateTransitionObj getPersistentNontransactionalDirtyInstance() { - StateTransitionObj obj = getPersistentNontransactionalInstance(); - if (obj == null) return null; - obj.writeField(10000); - int curr = currentState(obj); - if (curr != PERSISTENT_NONTRANSACTIONAL_DIRTY) { - if (debug) { - logger.debug( - "StateTransition: Unable to create persistent-nontransactional-dirty instance" - + " from a persistent-clean instance via makeNontransactional()/JDOHelper.makeDirty," - + " state is " - + states[curr]); - } - return null; + + /** + * + * @return persient nontransactional dirty instance + */ + public StateTransitionObj getPersistentNontransactionalDirtyInstance() + { + StateTransitionObj obj = getPersistentNontransactionalInstance(); + if( obj == null ) return null; + obj.writeField(10000); + int curr = currentState(obj); + if( curr != PERSISTENT_NONTRANSACTIONAL_DIRTY ) { + if (debug) { + logger.debug("StateTransition: Unable to create persistent-nontransactional-dirty instance" + + " from a persistent-clean instance via makeNontransactional()/JDOHelper.makeDirty," + + " state is " + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return detached clean instance - */ - public StateTransitionObj getDetachedCleanInstance() { - StateTransitionObj obj = getHollowInstance(); - if (obj == null) return null; - obj = (StateTransitionObj) pm.detachCopy(obj); - int curr = currentState(obj); - if (curr != DETACHED_CLEAN) { - if (debug) { - logger.debug( - "StateTransition: Unable to create detached-clean instance" - + " from a persistent-clean instance via detachCopy," - + " state is " - + states[curr]); - } - return null; + + /** + * + * @return detached clean instance + */ + public StateTransitionObj getDetachedCleanInstance() + { + StateTransitionObj obj = getHollowInstance(); + if( obj == null ) return null; + obj = (StateTransitionObj) pm.detachCopy(obj); + int curr = currentState(obj); + if( curr != DETACHED_CLEAN ) { + if (debug) { + logger.debug("StateTransition: Unable to create detached-clean instance" + + " from a persistent-clean instance via detachCopy," + + " state is " + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return detached dirty instance - */ - public StateTransitionObj getDetachedDirtyInstance() { - StateTransitionObj obj = getHollowInstance(); - if (obj == null) return null; - obj = (StateTransitionObj) pm.detachCopy(obj); - obj.writeField(1000); - int curr = currentState(obj); - if (curr != DETACHED_DIRTY) { - if (debug) { - logger.debug( - "StateTransition: Unable to create detached-dirty instance" - + " from a persistent-clean instance via detachCopy/persistent field modification," - + " state is " - + states[curr]); - } - return null; + + /** + * + * @return detached dirty instance + */ + public StateTransitionObj getDetachedDirtyInstance() + { + StateTransitionObj obj = getHollowInstance(); + if( obj == null ) return null; + obj = (StateTransitionObj) pm.detachCopy(obj); + obj.writeField(1000); + int curr = currentState(obj); + if( curr != DETACHED_DIRTY ) { + if (debug) { + logger.debug("StateTransition: Unable to create detached-dirty instance" + + " from a persistent-clean instance via detachCopy/persistent field modification," + + " state is " + states[curr]); + } + return null; + } + return obj; } - return obj; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/lifecycle/StateTransitionsReturnedObjects.java b/tck/src/main/java/org/apache/jdo/tck/lifecycle/StateTransitionsReturnedObjects.java index 6d5c28298..ac3f22af7 100644 --- a/tck/src/main/java/org/apache/jdo/tck/lifecycle/StateTransitionsReturnedObjects.java +++ b/tck/src/main/java/org/apache/jdo/tck/lifecycle/StateTransitionsReturnedObjects.java @@ -5,16 +5,16 @@ * 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 + * + * 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.jdo.tck.lifecycle; import java.io.ByteArrayInputStream; @@ -23,777 +23,763 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.Iterator; + import javax.jdo.Extent; import javax.jdo.JDOFatalException; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.lifecycle.StateTransitionObj; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test State Transitions
    - * Keywords: lifecycle
    - * Assertion IDs: A5.9-1 through A5.9-190 Assertion Description: All possible state - * transistions are being tested in this test. + *Title: Test State Transitions + *
    + *Keywords: lifecycle + *
    + *Assertion IDs: A5.9-1 through A5.9-190 + *Assertion Description: + All possible state transistions are being tested in this test. */ + public class StateTransitionsReturnedObjects extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertions A5.9-1 through A5.5.8 (serialization, detachment, attachment) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(StateTransitionsReturnedObjects.class); - } - - private Transaction transaction; - private int scenario; - private int operation; - private int current_state; - private int expected_state; - private int new_state; - - /** Operations that cause state changes */ - private static final int MAKEPERSISTENTOPTIMISTIC = 0; - - private static final int MAKEPERSISTENTDATASTORE = 1; - private static final int DETACHCOPYOUTSIDETXNTRTRU = 2; - private static final int DETACHCOPYOUTSIDETXNTRFLS = 3; - private static final int DETACHCOPYINSIDEDATASTORETX = 4; - private static final int DETACHCOPYINSIDEOPTIMISTICTX = 5; - private static final int SERIALIZEOUTSIDETX = 6; - private static final int SERIALIZEINSIDETX = 7; - - private static final int NUM_OPERATIONS = 8; - - private static final String[] operations = { - "makePersistent with active optimistic tx", - "makePersistent with active datastore tx", - "detachCopy outside tx with NontransactionalRead true", - "detachCopy outside tx with NontransactionalRead false", - "detachCopy with active datastore tx", - "detachCopy with active optimistic tx", - "serialize outside tx", - "serialize with active tx" - }; - - /** Illegal state transitions */ - private static final int UNCHANGED = -1; - - private static final int ERROR = -2; - private static final int IMPOSSIBLE = -3; - private static final int NOT_APPLICABLE = -4; - private static final int UNSPECIFIED = -5; - - /** State transitions */ - public static final int[][] statesOfReturnedObjects = { // [operation] [current state] = new state - // TRANSIENT, PERSISTENT_NEW, PERSISTENT_CLEAN, - // PERSISTENT_DIRTY, HOLLOW, TRANSIENT_CLEAN, - // TRANSIENT_DIRTY, PERSISTENT_NEW_DELETED, PERSISTENT_DELETED, - // PERSISTENT_NONTRANSACTIONAL, PERSISTENT_NONTRANSACTIONAL_DIRTY, DETACHED_CLEAN, - // DETACHED_DIRTY - - // makePersistent optimistic transaction - { - PERSISTENT_NEW, UNCHANGED, UNCHANGED, - UNCHANGED, UNCHANGED, PERSISTENT_NEW, - PERSISTENT_NEW, UNCHANGED, UNCHANGED, - UNCHANGED, UNCHANGED, PERSISTENT_NONTRANSACTIONAL, - PERSISTENT_DIRTY - }, - - // makePersistent datastore transaction - { - PERSISTENT_NEW, UNCHANGED, UNCHANGED, - UNCHANGED, UNCHANGED, PERSISTENT_NEW, - PERSISTENT_NEW, UNCHANGED, UNCHANGED, - UNCHANGED, UNCHANGED, PERSISTENT_CLEAN, - PERSISTENT_DIRTY - }, - - // detachCopy outside tx with NontransactionalRead=true - { - ERROR, IMPOSSIBLE, IMPOSSIBLE, - IMPOSSIBLE, DETACHED_CLEAN, ERROR, - IMPOSSIBLE, IMPOSSIBLE, IMPOSSIBLE, - DETACHED_CLEAN, UNSPECIFIED, DETACHED_CLEAN, - UNSPECIFIED - }, - - // detachCopy outside tx with NontransactionalRead=false - { - ERROR, ERROR, ERROR, - ERROR, ERROR, ERROR, - IMPOSSIBLE, IMPOSSIBLE, IMPOSSIBLE, - ERROR, ERROR, ERROR, - ERROR - }, - - // detachCopy with active datastore tx - { - DETACHED_CLEAN, DETACHED_CLEAN, DETACHED_CLEAN, - DETACHED_CLEAN, DETACHED_CLEAN, DETACHED_CLEAN, - DETACHED_CLEAN, ERROR, ERROR, - DETACHED_CLEAN, IMPOSSIBLE, DETACHED_CLEAN, - DETACHED_CLEAN - }, - - // detachCopy with active optimistic tx - { - DETACHED_CLEAN, DETACHED_CLEAN, DETACHED_CLEAN, - DETACHED_CLEAN, DETACHED_CLEAN, DETACHED_CLEAN, - DETACHED_CLEAN, ERROR, ERROR, - DETACHED_CLEAN, IMPOSSIBLE, DETACHED_CLEAN, - DETACHED_CLEAN - }, - - // serialize outside tx - { - UNCHANGED, IMPOSSIBLE, IMPOSSIBLE, - IMPOSSIBLE, DETACHED_CLEAN, IMPOSSIBLE, - IMPOSSIBLE, IMPOSSIBLE, IMPOSSIBLE, - DETACHED_CLEAN, UNSPECIFIED, UNCHANGED, - UNCHANGED - }, - - // serialize with active tx - { - UNCHANGED, DETACHED_CLEAN, DETACHED_CLEAN, - DETACHED_CLEAN, DETACHED_CLEAN, TRANSIENT, - TRANSIENT, TRANSIENT, TRANSIENT, - DETACHED_CLEAN, TRANSIENT, UNCHANGED, - UNCHANGED - }, - }; - - private static final int DATASTORE_TX = 0; - private static final int OPTIMISTIC_TX = 1; - private static final int NO_TX = 2; - - private static final String[] scenario_string = { - "datastore transaction", "optimistic transaction", "no transaction" - }; - - private static final boolean[][] applies_to_scenario = { - // Datastore Optimistic No tx - {false, true, false}, // makePersistent active optimistic transaction - {true, false, false}, // makePersistent active datastore transaction - // since the spec leaves detachCopy outside tx a bit underspecified, - // we decided to disable this scanario for now - {false, false, true}, // detachCopy outside tx with NontransactionalRead=true - {false, false, false}, // detachCopy outside tx with NontransactionalRead=false - {true, true, false}, // detachCopy with active datastore tx - {true, true, false}, // detachCopy with active optimistic tx - {false, false, true}, // serialize outside tx - {true, true, false} // serialize with active tx - }; - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - pm = getPM(); - addTearDownClass(StateTransitionObj.class); - generatePersistentInstances(); - } - - public void test() { - scenario = DATASTORE_TX; - checkTransitions(); - - if (isOptimisticSupported()) { - scenario = OPTIMISTIC_TX; - checkTransitions(); + /** */ + private static final String ASSERTION_FAILED = + "Assertions A5.9-1 through A5.5.8 (serialization, detachment, attachment) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(StateTransitionsReturnedObjects.class); + } + + private Transaction transaction; + private int scenario; + private int operation; + private int current_state; + private int expected_state; + private int new_state; + + /** + * Operations that cause state changes + */ + private static final int MAKEPERSISTENTOPTIMISTIC = 0; + private static final int MAKEPERSISTENTDATASTORE = 1; + private static final int DETACHCOPYOUTSIDETXNTRTRU = 2; + private static final int DETACHCOPYOUTSIDETXNTRFLS = 3; + private static final int DETACHCOPYINSIDEDATASTORETX = 4; + private static final int DETACHCOPYINSIDEOPTIMISTICTX = 5; + private static final int SERIALIZEOUTSIDETX = 6; + private static final int SERIALIZEINSIDETX = 7; + + private static final int NUM_OPERATIONS = 8; + + private static final String[] operations = { + "makePersistent with active optimistic tx", + "makePersistent with active datastore tx", + "detachCopy outside tx with NontransactionalRead true", + "detachCopy outside tx with NontransactionalRead false", + "detachCopy with active datastore tx", + "detachCopy with active optimistic tx", + "serialize outside tx", + "serialize with active tx" + }; + + /** + * Illegal state transitions + */ + private static final int UNCHANGED = -1; + private static final int ERROR = -2; + private static final int IMPOSSIBLE = -3; + private static final int NOT_APPLICABLE = -4; + private static final int UNSPECIFIED = -5; + + /** + * State transitions + */ + public static final int[][] statesOfReturnedObjects = { // [operation] [current state] = new state + // TRANSIENT, PERSISTENT_NEW, PERSISTENT_CLEAN, + // PERSISTENT_DIRTY, HOLLOW, TRANSIENT_CLEAN, + // TRANSIENT_DIRTY, PERSISTENT_NEW_DELETED, PERSISTENT_DELETED, + // PERSISTENT_NONTRANSACTIONAL, PERSISTENT_NONTRANSACTIONAL_DIRTY, DETACHED_CLEAN, + // DETACHED_DIRTY + + // makePersistent optimistic transaction + { PERSISTENT_NEW, UNCHANGED, UNCHANGED, + UNCHANGED, UNCHANGED, PERSISTENT_NEW, + PERSISTENT_NEW, UNCHANGED, UNCHANGED, + UNCHANGED, UNCHANGED, PERSISTENT_NONTRANSACTIONAL, + PERSISTENT_DIRTY}, + + // makePersistent datastore transaction + { PERSISTENT_NEW, UNCHANGED, UNCHANGED, + UNCHANGED, UNCHANGED, PERSISTENT_NEW, + PERSISTENT_NEW, UNCHANGED, UNCHANGED, + UNCHANGED, UNCHANGED, PERSISTENT_CLEAN, + PERSISTENT_DIRTY}, + + // detachCopy outside tx with NontransactionalRead=true + { ERROR, IMPOSSIBLE, IMPOSSIBLE, + IMPOSSIBLE, DETACHED_CLEAN, ERROR, + IMPOSSIBLE, IMPOSSIBLE, IMPOSSIBLE, + DETACHED_CLEAN, UNSPECIFIED, DETACHED_CLEAN, + UNSPECIFIED}, + + // detachCopy outside tx with NontransactionalRead=false + { ERROR, ERROR, ERROR, + ERROR, ERROR, ERROR, + IMPOSSIBLE, IMPOSSIBLE, IMPOSSIBLE, + ERROR, ERROR, ERROR, + ERROR}, + + // detachCopy with active datastore tx + { DETACHED_CLEAN, DETACHED_CLEAN, DETACHED_CLEAN, + DETACHED_CLEAN, DETACHED_CLEAN, DETACHED_CLEAN, + DETACHED_CLEAN, ERROR, ERROR, + DETACHED_CLEAN, IMPOSSIBLE, DETACHED_CLEAN, + DETACHED_CLEAN}, + + // detachCopy with active optimistic tx + { DETACHED_CLEAN, DETACHED_CLEAN, DETACHED_CLEAN, + DETACHED_CLEAN, DETACHED_CLEAN, DETACHED_CLEAN, + DETACHED_CLEAN, ERROR, ERROR, + DETACHED_CLEAN, IMPOSSIBLE, DETACHED_CLEAN, + DETACHED_CLEAN}, + + // serialize outside tx + { UNCHANGED, IMPOSSIBLE, IMPOSSIBLE, + IMPOSSIBLE, DETACHED_CLEAN, IMPOSSIBLE, + IMPOSSIBLE, IMPOSSIBLE, IMPOSSIBLE, + DETACHED_CLEAN, UNSPECIFIED, UNCHANGED, + UNCHANGED}, + + // serialize with active tx + { UNCHANGED, DETACHED_CLEAN, DETACHED_CLEAN, + DETACHED_CLEAN, DETACHED_CLEAN, TRANSIENT, + TRANSIENT, TRANSIENT, TRANSIENT, + DETACHED_CLEAN, TRANSIENT, UNCHANGED, + UNCHANGED}, + }; + + private static final int DATASTORE_TX = 0; + private static final int OPTIMISTIC_TX = 1; + private static final int NO_TX = 2; + + private static final String[] scenario_string = { + "datastore transaction", "optimistic transaction", "no transaction" + }; + + private static final boolean[][] applies_to_scenario = { + // Datastore Optimistic No tx + { false, true, false }, // makePersistent active optimistic transaction + { true, false, false }, // makePersistent active datastore transaction + // since the spec leaves detachCopy outside tx a bit underspecified, + // we decided to disable this scanario for now + { false, false, true }, // detachCopy outside tx with NontransactionalRead=true + { false, false, false }, // detachCopy outside tx with NontransactionalRead=false + { true, true, false }, // detachCopy with active datastore tx + { true, true, false }, // detachCopy with active optimistic tx + { false, false, true }, // serialize outside tx + { true, true, false } // serialize with active tx + }; + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + pm = getPM(); + addTearDownClass(StateTransitionObj.class); + generatePersistentInstances(); } + + public void test() { + scenario = DATASTORE_TX; + checkTransitions(); + + if( isOptimisticSupported() ){ + scenario = OPTIMISTIC_TX; + checkTransitions(); + } - scenario = NO_TX; - checkTransitions(); - failOnError(); - } - - /** */ - private void generatePersistentInstances() { - if (doPersistentInstancesExist()) return; - int i; - Transaction t = pm.currentTransaction(); - t.begin(); - for (i = 0; i < 50; ++i) { - StateTransitionObj sto = new StateTransitionObj(i); - sto.writeField(i); - pm.makePersistent(sto); + scenario = NO_TX; + checkTransitions(); + failOnError(); } - t.commit(); - if (!doPersistentInstancesExist()) - if (debug) - logger.debug( - "StateTransitionsReturnedObjects unable to create instances of StateTransitionsObj"); - } - - /** */ - private boolean doPersistentInstancesExist() { - boolean ret; - Transaction t = pm.currentTransaction(); - t.begin(); - Extent e = pm.getExtent(StateTransitionObj.class, false); - Iterator iter = e.iterator(); - ret = iter.hasNext(); - t.rollback(); - return ret; - } - - /** - * @param transaction the transaction - */ - public void prepareTransactionAndJDOSettings(Transaction transaction) { - if (scenario != NO_TX) { - transaction.setNontransactionalRead(false); - transaction.setNontransactionalWrite(false); - pm.setDetachAllOnCommit(false); - - transaction.setOptimistic(scenario == OPTIMISTIC_TX); - transaction.begin(); - if (!transaction.isActive()) - if (debug) - logger.debug( - "StateTransitionsReturnedObjects: Transaction should be active, but it is not"); - } else { - if (operation == DETACHCOPYOUTSIDETXNTRTRU || operation == SERIALIZEOUTSIDETX) { - transaction.setNontransactionalRead(true); - } - if (current_state == PERSISTENT_NONTRANSACTIONAL_DIRTY) { - transaction.setNontransactionalWrite(true); - } + + /** */ + private void generatePersistentInstances() + { + if( doPersistentInstancesExist() ) return; + int i; + Transaction t = pm.currentTransaction(); + t.begin(); + for( i = 0; i < 50; ++i ){ + StateTransitionObj sto = new StateTransitionObj(i); + sto.writeField(i); + pm.makePersistent(sto); + } + t.commit(); + if( !doPersistentInstancesExist() ) + if (debug) + logger.debug("StateTransitionsReturnedObjects unable to create instances of StateTransitionsObj"); } - } - - /** */ - void checkTransitions() { - for (operation = 0; operation < NUM_OPERATIONS; ++operation) { - // rule out situations that do not apply - if (!applies_to_scenario[operation][scenario]) continue; - if ((operation == DETACHCOPYOUTSIDETXNTRTRU || operation == SERIALIZEOUTSIDETX) - && !isNontransactionalReadSupported()) continue; - - for (current_state = 0; current_state < NUM_STATES; ++current_state) { - if (scenario == OPTIMISTIC_TX && current_state == PERSISTENT_CLEAN) continue; - if ((current_state == TRANSIENT_CLEAN || current_state == TRANSIENT_DIRTY) - && !isTransientTransactionalSupported()) - continue; // this state is not supported by implementation - if (current_state == PERSISTENT_NONTRANSACTIONAL - && !(isNontransactionalReadSupported() || isNontransactionalWriteSupported())) - continue; // this state is not supported by implementation - if (current_state == PERSISTENT_NONTRANSACTIONAL_DIRTY - && !isNontransactionalWriteSupported()) continue; - - expected_state = statesOfReturnedObjects[operation][current_state]; - if (expected_state == IMPOSSIBLE) continue; - if (expected_state == NOT_APPLICABLE) continue; - if (expected_state == UNSPECIFIED) continue; - if (expected_state == UNCHANGED) expected_state = current_state; - try { - transaction = pm.currentTransaction(); - if (transaction.isActive()) { - if (debug) logger.debug("Transaction is active (but should not be), rolling back"); - transaction.rollback(); - } - - prepareTransactionAndJDOSettings(transaction); - - printSituation(); - - StateTransitionObj obj = getInstanceInState(current_state); - if (obj == null) { // could not get object in state - if (transaction.isActive()) transaction.rollback(); - continue; - } - - // Apply operation, catching possible exception - Exception e = null; - Object returnedObject = null; - try { - returnedObject = applyOperation(operation, obj); - } catch (Exception excep) { - if (excep instanceof javax.jdo.JDOUserException) { - e = excep; - } else { - appendMessage( - ASSERTION_FAILED - + NL - + "StateTransitionsReturnedObjects: " - + scenario_string[scenario] - + "; current state " - + states[current_state] - + NL - + operations[operation] - + "; unexpected exception: " - + excep); - continue; - } - } - - if (expected_state == ERROR) { - if (e == null) { - appendMessage( - ASSERTION_FAILED - + NL - + "StateTransitionsReturnedObjects: " - + scenario_string[scenario] - + "; current state " - + states[current_state] - + NL - + operations[operation] - + "; JDOUserException should have been thrown"); - } else { - int stateOfObj = currentState(obj); - if (stateOfObj != current_state) { - appendMessage( - ASSERTION_FAILED - + NL - + "StateTransitionsReturnedObjects: " - + scenario_string[scenario] - + "; current state " - + states[current_state] - + NL - + operations[operation] - + "; JDOUserException properly thrown, but instance should remain in current state," - + " instance changed state to " - + states[stateOfObj]); - } + + /** */ + private boolean doPersistentInstancesExist() + { + boolean ret; + Transaction t = pm.currentTransaction(); + t.begin(); + Extent e = pm.getExtent(StateTransitionObj.class, false); + Iterator iter = e.iterator(); + ret = iter.hasNext(); + t.rollback(); + return ret; + } + + /** + * + * @param transaction the transaction + */ + public void prepareTransactionAndJDOSettings(Transaction transaction) { + if( scenario != NO_TX ) { + transaction.setNontransactionalRead(false); + transaction.setNontransactionalWrite(false); + pm.setDetachAllOnCommit(false); + + transaction.setOptimistic(scenario == OPTIMISTIC_TX); + transaction.begin(); + if( !transaction.isActive() ) + if (debug) + logger.debug("StateTransitionsReturnedObjects: Transaction should be active, but it is not"); + } else { + if( operation == DETACHCOPYOUTSIDETXNTRTRU || + operation == SERIALIZEOUTSIDETX ) { + transaction.setNontransactionalRead(true); } - } else { - // Get new state, verify correct transition and exceptions occurred - new_state = currentState(returnedObject); - if (!compareStates(new_state, expected_state)) { - appendMessage( - ASSERTION_FAILED - + NL - + "StateTransitionsReturnedObjects: " - + scenario_string[scenario] - + "; current state " - + states[current_state] - + NL - + operations[operation] - + " returned instance in invalid state " - + states[new_state] - + "; expected state " - + states[expected_state]); + if( current_state == PERSISTENT_NONTRANSACTIONAL_DIRTY) { + transaction.setNontransactionalWrite(true); } - } - if (transaction.isActive()) transaction.rollback(); - } catch (Exception unexpected_exception) { - if (transaction.isActive()) transaction.rollback(); - appendMessage( - ASSERTION_FAILED - + NL - + "StateTransitionsReturnedObjects: " - + scenario_string[scenario] - + "; current state " - + states[current_state] - + NL - + operations[operation] - + "; unexpected exception caught: " - + unexpected_exception); } - } } - } - - /** */ - void printSituation() { - if (debug) { - logger.debug( - " (" - + scenario_string[scenario] - + ", initial state=" - + states[current_state] - + ", " - + operations[operation] - + ")"); - } - } - - /** */ - Object applyOperation(int operation, StateTransitionObj stobj) { - Object result = null; - StateTransitionObj obj = (StateTransitionObj) stobj; - switch (operation) { - case MAKEPERSISTENTOPTIMISTIC: - case MAKEPERSISTENTDATASTORE: - result = pm.makePersistent(obj); - break; - - case DETACHCOPYOUTSIDETXNTRTRU: - case DETACHCOPYOUTSIDETXNTRFLS: - case DETACHCOPYINSIDEDATASTORETX: - case DETACHCOPYINSIDEOPTIMISTICTX: - result = pm.detachCopy(obj); - break; - - case SERIALIZEOUTSIDETX: - case SERIALIZEINSIDETX: - ObjectOutputStream oos = null; - ObjectInputStream ois = null; - try { - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - oos = new ObjectOutputStream(byteArrayOutputStream); - oos.writeObject(obj); - ois = - new ObjectInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray())); - result = ois.readObject(); - } catch (IOException e) { - throw new JDOFatalException(e.getMessage(), e); - } catch (ClassNotFoundException e) { - throw new JDOFatalException(e.getMessage(), e); - } finally { - try { - if (oos != null) { - oos.close(); - } - if (ois != null) { - ois.close(); + + /** */ + void checkTransitions() + { + for( operation = 0; operation < NUM_OPERATIONS; ++operation ){ + // rule out situations that do not apply + if( !applies_to_scenario[operation][scenario] ) continue; + if( (operation == DETACHCOPYOUTSIDETXNTRTRU || + operation == SERIALIZEOUTSIDETX) && + !isNontransactionalReadSupported() ) continue; + + for( current_state = 0; current_state < NUM_STATES; ++current_state){ + if( scenario == OPTIMISTIC_TX && current_state == PERSISTENT_CLEAN ) continue; + if( (current_state == TRANSIENT_CLEAN || current_state == TRANSIENT_DIRTY) && + !isTransientTransactionalSupported() ) + continue; // this state is not supported by implementation + if( current_state == PERSISTENT_NONTRANSACTIONAL && + !(isNontransactionalReadSupported() || isNontransactionalWriteSupported()) ) + continue; // this state is not supported by implementation + if( current_state == PERSISTENT_NONTRANSACTIONAL_DIRTY && + !isNontransactionalWriteSupported() ) + continue; + + expected_state = statesOfReturnedObjects[operation][current_state]; + if( expected_state == IMPOSSIBLE ) continue; + if( expected_state == NOT_APPLICABLE ) continue; + if( expected_state == UNSPECIFIED ) continue; + if( expected_state == UNCHANGED ) expected_state = current_state; + try { + transaction = pm.currentTransaction(); + if( transaction.isActive()){ + if (debug) + logger.debug("Transaction is active (but should not be), rolling back"); + transaction.rollback(); + } + + prepareTransactionAndJDOSettings(transaction); + + printSituation(); + + StateTransitionObj obj = getInstanceInState(current_state); + if( obj == null ){ // could not get object in state + if( transaction.isActive() ) transaction.rollback(); + continue; + } + + // Apply operation, catching possible exception + Exception e = null; + Object returnedObject = null; + try { + returnedObject = applyOperation(operation, obj); + } catch( Exception excep ){ + if( excep instanceof javax.jdo.JDOUserException ){ + e = excep; + } else { + appendMessage(ASSERTION_FAILED + NL + + "StateTransitionsReturnedObjects: " + + scenario_string[scenario] + + "; current state " + states[current_state] + NL + + operations[operation] + + "; unexpected exception: " + excep); + continue; + } + } + + if( expected_state == ERROR ){ + if( e == null ){ + appendMessage(ASSERTION_FAILED + NL + + "StateTransitionsReturnedObjects: " + + scenario_string[scenario] + + "; current state " + states[current_state] + NL + + operations[operation] + + "; JDOUserException should have been thrown"); + } else { + int stateOfObj = currentState(obj); + if( stateOfObj != current_state ){ + appendMessage(ASSERTION_FAILED + NL + + "StateTransitionsReturnedObjects: " + + scenario_string[scenario] + + "; current state " + states[current_state] + NL + + operations[operation] + + "; JDOUserException properly thrown, but instance should remain in current state," + + " instance changed state to " + states[stateOfObj]); + } + } + } else { + // Get new state, verify correct transition and exceptions occurred + new_state = currentState(returnedObject); + if( !compareStates(new_state, expected_state) ) { + appendMessage(ASSERTION_FAILED + NL + + "StateTransitionsReturnedObjects: " + + scenario_string[scenario] + + "; current state " + states[current_state] + NL + + operations[operation] + + " returned instance in invalid state " + states[new_state] + + "; expected state " + states[expected_state]); + } + } + if( transaction.isActive() ) transaction.rollback(); + } + catch(Exception unexpected_exception) { + if (transaction.isActive()) + transaction.rollback(); + appendMessage(ASSERTION_FAILED + NL + + "StateTransitionsReturnedObjects: " + + scenario_string[scenario] + + "; current state " + states[current_state] + NL + + operations[operation] + + "; unexpected exception caught: " + unexpected_exception); + } } - } catch (IOException e) { - throw new JDOFatalException(e.getMessage(), e); - } } - break; - - default: - appendMessage( - ASSERTION_FAILED - + NL - + "StateTransitionsReturnedObjects: " - + scenario_string[scenario] - + "; internal error, illegal operation: " - + operation); } - return result; - } - - /** - * Get an instance in the specified state. - * - * @param state the state - * @return instance in the specified state. - */ - public StateTransitionObj getInstanceInState(int state) { - switch (state) { - case TRANSIENT: - return getTransientInstance(); - case PERSISTENT_NEW: - return getPersistentNewInstance(); - case PERSISTENT_CLEAN: - return getPersistentCleanInstance(); - case PERSISTENT_DIRTY: - return getPersistentDirtyInstance(); - case HOLLOW: - return getHollowInstance(); - case TRANSIENT_CLEAN: - return getTransientCleanInstance(); - case TRANSIENT_DIRTY: - return getTransientDirtyInstance(); - case PERSISTENT_NEW_DELETED: - return getPersistentNewDeletedInstance(); - case PERSISTENT_DELETED: - return getPersistentDeletedInstance(); - case PERSISTENT_NONTRANSACTIONAL: - return getPersistentNontransactionalInstance(); - case PERSISTENT_NONTRANSACTIONAL_DIRTY: - return getPersistentNontransactionalDirtyInstance(); - case DETACHED_CLEAN: - return getDetachedCleanInstance(); - case DETACHED_DIRTY: - return getDetachedDirtyInstance(); - default: - return null; + + /** */ + void printSituation() + { + if (debug) { + logger.debug(" (" + scenario_string[scenario] + + ", initial state=" + states[current_state] + + ", " + operations[operation] + ")"); + } } - } - - /** - * @return transient instance - */ - public StateTransitionObj getTransientInstance() { - StateTransitionObj obj = new StateTransitionObj(23); - int curr = currentState(obj); - if (curr != TRANSIENT) { - if (debug) { - logger.debug( - "StateTransitionsReturnedObjects: Unable to create transient instance, state is " - + states[curr]); - } - return null; + + /** */ + Object applyOperation(int operation, StateTransitionObj stobj) + { + Object result = null; + StateTransitionObj obj = (StateTransitionObj) stobj; + switch( operation ){ + case MAKEPERSISTENTOPTIMISTIC: + case MAKEPERSISTENTDATASTORE: + result = pm.makePersistent(obj); + break; + + case DETACHCOPYOUTSIDETXNTRTRU: + case DETACHCOPYOUTSIDETXNTRFLS: + case DETACHCOPYINSIDEDATASTORETX: + case DETACHCOPYINSIDEOPTIMISTICTX: + result = pm.detachCopy(obj); + break; + + case SERIALIZEOUTSIDETX: + case SERIALIZEINSIDETX: + ObjectOutputStream oos = null; + ObjectInputStream ois = null; + try { + ByteArrayOutputStream byteArrayOutputStream = + new ByteArrayOutputStream(); + oos = new ObjectOutputStream(byteArrayOutputStream); + oos.writeObject(obj); + ois = new ObjectInputStream(new ByteArrayInputStream( + byteArrayOutputStream.toByteArray())); + result = ois.readObject(); + } catch (IOException e) { + throw new JDOFatalException(e.getMessage(), e); + } catch (ClassNotFoundException e) { + throw new JDOFatalException(e.getMessage(), e); + } finally { + try { + if (oos != null) { + oos.close(); + } + if (ois != null) { + ois.close(); + } + } catch (IOException e) { + throw new JDOFatalException(e.getMessage(), e); + } + } + break; + + default: + appendMessage(ASSERTION_FAILED + NL + + "StateTransitionsReturnedObjects: " + + scenario_string[scenario] + + "; internal error, illegal operation: " + operation); + } + return result; + } + + /** + * Get an instance in the specified state. + * @param state the state + * @return instance in the specified state. + */ + public StateTransitionObj getInstanceInState(int state) + { + switch(state) { + case TRANSIENT: + return getTransientInstance(); + case PERSISTENT_NEW: + return getPersistentNewInstance(); + case PERSISTENT_CLEAN: + return getPersistentCleanInstance(); + case PERSISTENT_DIRTY: + return getPersistentDirtyInstance(); + case HOLLOW: + return getHollowInstance(); + case TRANSIENT_CLEAN: + return getTransientCleanInstance(); + case TRANSIENT_DIRTY: + return getTransientDirtyInstance(); + case PERSISTENT_NEW_DELETED: + return getPersistentNewDeletedInstance(); + case PERSISTENT_DELETED: + return getPersistentDeletedInstance(); + case PERSISTENT_NONTRANSACTIONAL: + return getPersistentNontransactionalInstance(); + case PERSISTENT_NONTRANSACTIONAL_DIRTY: + return getPersistentNontransactionalDirtyInstance(); + case DETACHED_CLEAN: + return getDetachedCleanInstance(); + case DETACHED_DIRTY: + return getDetachedDirtyInstance(); + default: + return null; + } } - return obj; - } - - /** - * @return persistent new instance - */ - public StateTransitionObj getPersistentNewInstance() { - StateTransitionObj obj = getTransientInstance(); - if (obj == null) return null; - pm.makePersistent(obj); // should transition to persistent-new - int curr = currentState(obj); - if (curr != PERSISTENT_NEW) { - if (debug) { - logger.debug( - "StateTransitionsReturnedObjects: Unable to create persistent-new instance" - + " from transient instance via makePersistent(), state is " - + states[curr]); - } - return null; + + /** + * + * @return transient instance + */ + public StateTransitionObj getTransientInstance() + { + StateTransitionObj obj = new StateTransitionObj(23); + int curr = currentState(obj); + if( curr != TRANSIENT ) { + if (debug) { + logger.debug("StateTransitionsReturnedObjects: Unable to create transient instance, state is " + + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return persistent clean instance - */ - public StateTransitionObj getPersistentCleanInstance() { - StateTransitionObj obj = getHollowInstance(); - if (obj == null) return null; - StateTransitionObj sto = (StateTransitionObj) obj; - sto.readField(); - int curr = currentState(sto); - if (curr != PERSISTENT_CLEAN) { - if (debug) { - logger.debug( - "StateTransitionsReturnedObjects: Unable to create persistent-clean instance" - + " from a hollow instance by reading a field, state is " - + states[curr]); - } - return null; + + /** + * + * @return persistent new instance + */ + public StateTransitionObj getPersistentNewInstance() + { + StateTransitionObj obj = getTransientInstance(); + if( obj == null ) return null; + pm.makePersistent(obj); // should transition to persistent-new + int curr = currentState(obj); + if( curr != PERSISTENT_NEW ) { + if (debug) { + logger.debug("StateTransitionsReturnedObjects: Unable to create persistent-new instance" + + " from transient instance via makePersistent(), state is " + + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return persistent dirty instance - */ - public StateTransitionObj getPersistentDirtyInstance() { - StateTransitionObj obj = getHollowInstance(); - if (obj == null) return null; - StateTransitionObj pcobj = (StateTransitionObj) obj; - pcobj.writeField(23); - int curr = currentState(obj); - if (curr != PERSISTENT_DIRTY) { - if (debug) { - logger.debug( - "StateTransitionsReturnedObjects: Unable to create persistent-dirty instance" - + " from a hollow instance by writing a field, state is " - + states[curr]); - } - return null; + + /** + * + * @return persistent clean instance + */ + public StateTransitionObj getPersistentCleanInstance() + { + StateTransitionObj obj = getHollowInstance(); + if( obj == null ) return null; + StateTransitionObj sto = (StateTransitionObj) obj; + sto.readField(); + int curr = currentState(sto); + if( curr != PERSISTENT_CLEAN ) { + if (debug) { + logger.debug("StateTransitionsReturnedObjects: Unable to create persistent-clean instance" + + " from a hollow instance by reading a field, state is " + + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return hollow instance - */ - public StateTransitionObj getHollowInstance() { - if (!transaction.isActive()) transaction.begin(); - if (!transaction.isActive()) - if (debug) logger.debug("getHollowInstance: Transaction should be active, but it is not"); - - Extent extent = pm.getExtent(StateTransitionObj.class, false); - Iterator iter = extent.iterator(); - if (!iter.hasNext()) { - if (debug) logger.debug("Extent for StateTransitionObj should not be empty"); - return null; + + /** + * + * @return persistent dirty instance + */ + public StateTransitionObj getPersistentDirtyInstance() + { + StateTransitionObj obj = getHollowInstance(); + if( obj == null ) return null; + StateTransitionObj pcobj = (StateTransitionObj) obj; + pcobj.writeField(23); + int curr = currentState(obj); + if( curr != PERSISTENT_DIRTY ) { + if (debug) { + logger.debug("StateTransitionsReturnedObjects: Unable to create persistent-dirty instance" + + " from a hollow instance by writing a field, state is " + + states[curr]); + } + return null; + } + return obj; } - StateTransitionObj obj = (StateTransitionObj) iter.next(); - - pm.makeTransactional(obj); - transaction.setRetainValues(false); - transaction.commit(); // This should put the instance in the HOLLOW state - - prepareTransactionAndJDOSettings(transaction); - - int curr = currentState(obj); - if (curr != HOLLOW && curr != PERSISTENT_NONTRANSACTIONAL) { - if (debug) { - logger.debug( - "getHollowInstance: Attempt to get hollow instance via accessing extent failed, state is " - + states[curr]); - } - return null; + + /** + * + * @return hollow instance + */ + public StateTransitionObj getHollowInstance() + { + if ( !transaction.isActive() ) + transaction.begin(); + if( !transaction.isActive() ) + if (debug) + logger.debug("getHollowInstance: Transaction should be active, but it is not"); + + Extent extent = pm.getExtent(StateTransitionObj.class, false); + Iterator iter = extent.iterator(); + if( !iter.hasNext() ){ + if (debug) + logger.debug("Extent for StateTransitionObj should not be empty"); + return null; + } + StateTransitionObj obj = (StateTransitionObj) iter.next(); + + pm.makeTransactional(obj); + transaction.setRetainValues(false); + transaction.commit(); // This should put the instance in the HOLLOW state + + prepareTransactionAndJDOSettings(transaction); + + int curr = currentState(obj); + if( curr != HOLLOW && curr != PERSISTENT_NONTRANSACTIONAL ){ + if (debug) { + logger.debug("getHollowInstance: Attempt to get hollow instance via accessing extent failed, state is " + + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return transient clean instance - */ - public StateTransitionObj getTransientCleanInstance() { - StateTransitionObj obj = getTransientInstance(); - if (obj == null) return null; - pm.makeTransactional(obj); - int curr = currentState(obj); - if (curr != TRANSIENT_CLEAN) { - if (debug) { - logger.debug( - "StateTransitionsReturnedObjects: Unable to create transient-clean instance" - + " from a transient instance via makeTransactional(), state is " - + states[curr]); - } - return null; + + /** + * + * @return transient clean instance + */ + public StateTransitionObj getTransientCleanInstance() + { + StateTransitionObj obj = getTransientInstance(); + if( obj == null ) return null; + pm.makeTransactional(obj); + int curr = currentState(obj); + if( curr != TRANSIENT_CLEAN ) { + if (debug) { + logger.debug("StateTransitionsReturnedObjects: Unable to create transient-clean instance" + + " from a transient instance via makeTransactional(), state is " + + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return transient dirty instance - */ - public StateTransitionObj getTransientDirtyInstance() { - StateTransitionObj obj = getTransientCleanInstance(); - if (obj == null) return null; - StateTransitionObj pcobj = (StateTransitionObj) obj; - pcobj.writeField(23); - int curr = currentState(obj); - if (curr != TRANSIENT_DIRTY) { - if (debug) { - logger.debug( - "StateTransitionsReturnedObjects: Unable to create transient-dirty instance" - + " from a transient-clean instance via modifying a field, state is " - + states[curr]); - } - return null; + + /** + * + * @return transient dirty instance + */ + public StateTransitionObj getTransientDirtyInstance() + { + StateTransitionObj obj = getTransientCleanInstance(); + if( obj == null ) return null; + StateTransitionObj pcobj = (StateTransitionObj) obj; + pcobj.writeField(23); + int curr = currentState(obj); + if( curr != TRANSIENT_DIRTY ) { + if (debug) { + logger.debug("StateTransitionsReturnedObjects: Unable to create transient-dirty instance" + + " from a transient-clean instance via modifying a field, state is " + + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return persistent new deleted instance - */ - public StateTransitionObj getPersistentNewDeletedInstance() { - StateTransitionObj obj = getPersistentNewInstance(); - if (obj == null) return null; - pm.deletePersistent(obj); // should transition to persistent-new-deleted - int curr = currentState(obj); - if (curr != PERSISTENT_NEW_DELETED) { - if (debug) { - logger.debug( - "StateTransitionsReturnedObjects: Unable to create persistent-new-deleted instance" - + " from a persistent-new instance via deletePersistent, state is " - + states[curr]); - } - return null; + + /** + * + * @return persistent new deleted instance + */ + public StateTransitionObj getPersistentNewDeletedInstance() + { + StateTransitionObj obj = getPersistentNewInstance(); + if( obj == null ) return null; + pm.deletePersistent(obj); // should transition to persistent-new-deleted + int curr = currentState(obj); + if( curr != PERSISTENT_NEW_DELETED) { + if (debug) { + logger.debug("StateTransitionsReturnedObjects: Unable to create persistent-new-deleted instance" + + " from a persistent-new instance via deletePersistent, state is " + + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return persistent deleted instance - */ - public StateTransitionObj getPersistentDeletedInstance() { - StateTransitionObj obj = getHollowInstance(); - if (obj == null) return null; - pm.deletePersistent(obj); - int curr = currentState(obj); - if (curr != PERSISTENT_DELETED) { - if (debug) { - logger.debug( - "StateTransitionsReturnedObjects: Unable to create persistent-deleted instance" - + " from a persistent instance via deletePersistent(), state is " - + states[curr]); - } - return null; + + /** + * + * @return persistent deleted instance + */ + public StateTransitionObj getPersistentDeletedInstance() + { + StateTransitionObj obj = getHollowInstance(); + if( obj == null ) return null; + pm.deletePersistent(obj); + int curr = currentState(obj); + if( curr != PERSISTENT_DELETED ) { + if (debug) { + logger.debug("StateTransitionsReturnedObjects: Unable to create persistent-deleted instance" + + " from a persistent instance via deletePersistent(), state is " + + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return persistent nontransactional instance - */ - public StateTransitionObj getPersistentNontransactionalInstance() { - StateTransitionObj obj = getHollowInstance(); - if (obj == null) return null; - boolean nontransactionalRead = pm.currentTransaction().getNontransactionalRead(); - pm.currentTransaction().setNontransactionalRead(true); - obj.readField(); - pm.makeNontransactional(obj); - pm.currentTransaction().setNontransactionalRead(nontransactionalRead); - int curr = currentState(obj); - if (curr != PERSISTENT_NONTRANSACTIONAL && curr != HOLLOW) { - if (debug) { - logger.debug( - "StateTransitionsReturnedObjects: Unable to create persistent-nontransactional instance" - + " from a persistent-clean instance via makeNontransactional(), state is " - + states[curr]); - } - return null; + + /** + * + * @return persistent nontransactional instance + */ + public StateTransitionObj getPersistentNontransactionalInstance() + { + StateTransitionObj obj = getHollowInstance(); + if( obj == null ) return null; + boolean nontransactionalRead = + pm.currentTransaction().getNontransactionalRead(); + pm.currentTransaction().setNontransactionalRead(true); + obj.readField(); + pm.makeNontransactional(obj); + pm.currentTransaction().setNontransactionalRead(nontransactionalRead); + int curr = currentState(obj); + if( curr != PERSISTENT_NONTRANSACTIONAL && curr != HOLLOW ) { + if (debug) { + logger.debug("StateTransitionsReturnedObjects: Unable to create persistent-nontransactional instance" + + " from a persistent-clean instance via makeNontransactional(), state is " + + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return persistent nontransactional dirty instance - */ - public StateTransitionObj getPersistentNontransactionalDirtyInstance() { - StateTransitionObj obj = getPersistentNontransactionalInstance(); - if (obj == null) return null; - obj.writeField(10000); - int curr = currentState(obj); - if (curr != PERSISTENT_NONTRANSACTIONAL_DIRTY) { - if (debug) { - logger.debug( - "StateTransitionsReturnedObjects: Unable to create persistent-nontransactional-dirty instance" - + " from a persistent-clean instance via makeNontransactional()/JDOHelper.makeDirty," - + " state is " - + states[curr]); - } - return null; + + /** + * + * @return persistent nontransactional dirty instance + */ + public StateTransitionObj getPersistentNontransactionalDirtyInstance() + { + StateTransitionObj obj = getPersistentNontransactionalInstance(); + if( obj == null ) return null; + obj.writeField(10000); + int curr = currentState(obj); + if( curr != PERSISTENT_NONTRANSACTIONAL_DIRTY ) { + if (debug) { + logger.debug("StateTransitionsReturnedObjects: Unable to create persistent-nontransactional-dirty instance" + + " from a persistent-clean instance via makeNontransactional()/JDOHelper.makeDirty," + + " state is " + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return detached clean instance - */ - public StateTransitionObj getDetachedCleanInstance() { - StateTransitionObj obj = getHollowInstance(); - if (obj == null) return null; - obj = (StateTransitionObj) pm.detachCopy(obj); - int curr = currentState(obj); - if (curr != DETACHED_CLEAN) { - if (debug) { - logger.debug( - "StateTransitionsReturnedObjects: Unable to create detached-clean instance" - + " from a persistent-clean instance via detachCopy," - + " state is " - + states[curr]); - } - return null; + + /** + * + * @return detached clean instance + */ + public StateTransitionObj getDetachedCleanInstance() + { + StateTransitionObj obj = getHollowInstance(); + if( obj == null ) return null; + obj = (StateTransitionObj) pm.detachCopy(obj); + int curr = currentState(obj); + if( curr != DETACHED_CLEAN ) { + if (debug) { + logger.debug("StateTransitionsReturnedObjects: Unable to create detached-clean instance" + + " from a persistent-clean instance via detachCopy," + + " state is " + states[curr]); + } + return null; + } + return obj; } - return obj; - } - - /** - * @return detached dirty instance - */ - public StateTransitionObj getDetachedDirtyInstance() { - StateTransitionObj obj = getHollowInstance(); - if (obj == null) return null; - obj = (StateTransitionObj) pm.detachCopy(obj); - obj.writeField(1000); - int curr = currentState(obj); - if (curr != DETACHED_DIRTY) { - if (debug) { - logger.debug( - "StateTransitionsReturnedObjects: Unable to create detached-dirty instance" - + " from a persistent-clean instance via detachCopy/persistent field modification," - + " state is " - + states[curr]); - } - return null; + + /** + * + * @return detached dirty instance + */ + public StateTransitionObj getDetachedDirtyInstance() + { + StateTransitionObj obj = getHollowInstance(); + if( obj == null ) return null; + obj = (StateTransitionObj) pm.detachCopy(obj); + obj.writeField(1000); + int curr = currentState(obj); + if( curr != DETACHED_DIRTY ) { + if (debug) { + logger.debug("StateTransitionsReturnedObjects: Unable to create detached-dirty instance" + + " from a persistent-clean instance via detachCopy/persistent field modification," + + " state is " + states[curr]); + } + return null; + } + return obj; } - return obj; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/lifecycle/TransientTransactionalStateCommit.java b/tck/src/main/java/org/apache/jdo/tck/lifecycle/TransientTransactionalStateCommit.java index f50434db3..db576e30e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/lifecycle/TransientTransactionalStateCommit.java +++ b/tck/src/main/java/org/apache/jdo/tck/lifecycle/TransientTransactionalStateCommit.java @@ -5,16 +5,16 @@ * 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 + * + * 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.jdo.tck.lifecycle; import org.apache.jdo.tck.JDO_Test; @@ -22,90 +22,95 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test Transient Transactional Commit
    - * Keywords: lifecycle transienttransactional commit
    - * Assertion IDs: A5.1-3
    - * Assertion Description: If TransientTransactional is supported, a transient - * transactional instance will have its state preserved when its associated transaction commits. - */ -public class TransientTransactionalStateCommit extends JDO_Test { + *Title: Test Transient Transactional Commit + *
    + *Keywords: lifecycle transienttransactional commit + *
    + *Assertion IDs: A5.1-3 + *
    + *Assertion Description: + If TransientTransactional is supported, a transient transactional instance + will have its state preserved when its associated transaction commits. +*/ - /** */ - private static final String ASSERTION_FAILED = - "Assertion A5.1-3 (TransientTransactionalStateCommit) failed: "; - private static final int CLEAN_VALUE = 12; - private static final int DIRTY_VALUE = 123; +public class TransientTransactionalStateCommit extends JDO_Test { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TransientTransactionalStateCommit.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A5.1-3 (TransientTransactionalStateCommit) failed: "; - /** */ - public void test() { - if (!isTransientTransactionalSupported()) { - logger.debug("Transient transactional instances are not supported"); - } else { - pm = getPM(); + private static final int CLEAN_VALUE = 12; + private static final int DIRTY_VALUE = 123; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TransientTransactionalStateCommit.class); + } - StateTransitionObj obj = getTransientInstance(); + /** */ + public void test() { + if (!isTransientTransactionalSupported()) { + logger.debug("Transient transactional instances are not supported"); + } + else { + pm = getPM(); - pm.currentTransaction().begin(); + StateTransitionObj obj = getTransientInstance(); - makeTransientDirty(obj); + pm.currentTransaction().begin(); - int beforeValue = obj.readField(); - pm.currentTransaction().commit(); - int afterValue = obj.readField(); - if (beforeValue != afterValue) { - fail( - ASSERTION_FAILED, - "Field value incorrect after commit. Expected: " - + beforeValue - + " Found: " - + afterValue); - } - } - } + makeTransientDirty(obj); - protected StateTransitionObj getTransientInstance() { - StateTransitionObj obj = new StateTransitionObj(CLEAN_VALUE); - int curr = currentState(obj); - if (curr != TRANSIENT) { - fail(ASSERTION_FAILED, "Unable to create transient instance, state is " + states[curr]); + int beforeValue=obj.readField(); + pm.currentTransaction().commit(); + int afterValue=obj.readField(); + if (beforeValue!=afterValue) + { + fail(ASSERTION_FAILED, + "Field value incorrect after commit. Expected: " + + beforeValue + " Found: " + afterValue); + } + } } - return obj; - } - protected void makeTransientClean(StateTransitionObj obj) { - if (obj == null) return; - pm.makeTransactional(obj); - int curr = currentState(obj); - if (curr != TRANSIENT_CLEAN) { - fail( - ASSERTION_FAILED, - "Unable to create transient-clean instance " - + "from a transient instance via makeTransactional(), state is " - + states[curr]); + protected StateTransitionObj getTransientInstance() { + StateTransitionObj obj = new StateTransitionObj(CLEAN_VALUE); + int curr = currentState(obj); + if( curr != TRANSIENT ){ + fail(ASSERTION_FAILED, + "Unable to create transient instance, state is " + + states[curr]); + } + return obj; + } + + protected void makeTransientClean(StateTransitionObj obj) { + if( obj == null ) return; + pm.makeTransactional(obj); + int curr = currentState(obj); + if( curr != TRANSIENT_CLEAN ){ + fail(ASSERTION_FAILED, + "Unable to create transient-clean instance " + + "from a transient instance via makeTransactional(), state is " + + states[curr]); + } } - } - protected void makeTransientDirty(StateTransitionObj obj) { - if (obj == null) return; - makeTransientClean(obj); - obj.writeField(DIRTY_VALUE); - int curr = currentState(obj); - if (curr != TRANSIENT_DIRTY) { - fail( - ASSERTION_FAILED, - "Unable to create transient-dirty instance " - + "from a transient-clean instance via modifying a field, state is " - + states[curr]); + protected void makeTransientDirty(StateTransitionObj obj) { + if( obj == null ) return; + makeTransientClean(obj); + obj.writeField(DIRTY_VALUE); + int curr = currentState(obj); + if( curr != TRANSIENT_DIRTY ){ + fail(ASSERTION_FAILED, + "Unable to create transient-dirty instance " + + "from a transient-clean instance via modifying a field, state is " + + states[curr]); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/lifecycle/TransientTransactionalStateRollback.java b/tck/src/main/java/org/apache/jdo/tck/lifecycle/TransientTransactionalStateRollback.java index c30269432..e9b32fc83 100644 --- a/tck/src/main/java/org/apache/jdo/tck/lifecycle/TransientTransactionalStateRollback.java +++ b/tck/src/main/java/org/apache/jdo/tck/lifecycle/TransientTransactionalStateRollback.java @@ -5,124 +5,123 @@ * 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 + * + * 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.jdo.tck.lifecycle; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.lifecycle.StateTransitionObj; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test Transient Transactional Rollback
    - * Keywords: lifecycle transienttransactional rollback
    - * Assertion IDs: A5.1-4 Assertion Description: If TransientTransactional - * is supported, a transient transactional instance will have its state restored to its - * state prior to becoming transactional when its associated transaction aborts or on rollback. + *Title: Test Transient Transactional Rollback + *
    + *Keywords: lifecycle transienttransactional rollback + *
    + *Assertion IDs: A5.1-4 + *Assertion Description: + If TransientTransactional is supported, a transient transactional instance + will have its state restored to its state prior to becoming transactional when + its associated transaction aborts or on rollback. */ -public class TransientTransactionalStateRollback extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A5.1-4 (TransientTransactionalStateRollback) failed: "; - - private static final int CLEAN_VALUE = 12; - private static final int DIRTY_VALUE = 123; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TransientTransactionalStateRollback.class); - } - - /** */ - public void test() { - if (!isTransientTransactionalSupported()) { - logger.debug("Transient transactional instances are not supported"); - } else { - pm = getPM(); - // Get transient instance and read field value - StateTransitionObj obj = getTransientInstance(); - - int beforeValue = obj.readField(); - - // Start transaction - Transaction tx = pm.currentTransaction(); - tx.begin(); - - // Get transient dirty instance - makeTransientDirty(obj); - - // Rollback - tx.rollback(); - int curr = currentState(obj); - if (curr != TRANSIENT_CLEAN) { - fail( - ASSERTION_FAILED, - "StateTransition: Unable to create transient-clean instance " - + "from a transient-dirty instance via tx.rollback(), state is " - + states[curr]); - } +public class TransientTransactionalStateRollback extends JDO_Test { - // Check that field value has been rolled back - int afterValue = obj.readField(); - if (beforeValue != afterValue) { - fail( - ASSERTION_FAILED, - "Field value incorrect after rollback. Expected: " - + beforeValue - + " Found: " - + afterValue); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A5.1-4 (TransientTransactionalStateRollback) failed: "; + + private static final int CLEAN_VALUE = 12; + private static final int DIRTY_VALUE = 123; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TransientTransactionalStateRollback.class); + } + + /** */ + public void test() { + if (!isTransientTransactionalSupported()) { + logger.debug("Transient transactional instances are not supported"); + } + else { + pm = getPM(); + + // Get transient instance and read field value + StateTransitionObj obj = getTransientInstance(); + + int beforeValue=obj.readField(); + + // Start transaction + Transaction tx = pm.currentTransaction(); + tx.begin(); + + // Get transient dirty instance + makeTransientDirty(obj); + + // Rollback + tx.rollback(); + int curr = currentState(obj); + if( curr != TRANSIENT_CLEAN ){ + fail(ASSERTION_FAILED, + "StateTransition: Unable to create transient-clean instance " + + "from a transient-dirty instance via tx.rollback(), state is " + states[curr]); + } + + // Check that field value has been rolled back + int afterValue=obj.readField(); + if (beforeValue!=afterValue) + { + fail(ASSERTION_FAILED, + "Field value incorrect after rollback. Expected: "+beforeValue+" Found: "+afterValue); + } + } } - } - protected StateTransitionObj getTransientInstance() { - StateTransitionObj obj = new StateTransitionObj(CLEAN_VALUE); - int curr = currentState(obj); - if (curr != TRANSIENT) { - fail(ASSERTION_FAILED, "Unable to create transient instance, state is " + states[curr]); + protected StateTransitionObj getTransientInstance() { + StateTransitionObj obj = new StateTransitionObj(CLEAN_VALUE); + int curr = currentState(obj); + if( curr != TRANSIENT ){ + fail(ASSERTION_FAILED, + "Unable to create transient instance, state is " + states[curr]); + } + return obj; } - return obj; - } - protected void makeTransientClean(StateTransitionObj obj) { - if (obj == null) return; - pm.makeTransactional(obj); - int curr = currentState(obj); - if (curr != TRANSIENT_CLEAN) { - fail( - ASSERTION_FAILED, - "Unable to create transient-clean instance " - + "from a transient instance via makeTransactional(), state is " - + states[curr]); + protected void makeTransientClean(StateTransitionObj obj) { + if( obj == null ) return; + pm.makeTransactional(obj); + int curr = currentState(obj); + if( curr != TRANSIENT_CLEAN ){ + fail(ASSERTION_FAILED, + "Unable to create transient-clean instance " + + "from a transient instance via makeTransactional(), state is " + states[curr]); + } } - } - protected void makeTransientDirty(StateTransitionObj obj) { - if (obj == null) return; - makeTransientClean(obj); - obj.writeField(DIRTY_VALUE); - int curr = currentState(obj); - if (curr != TRANSIENT_DIRTY) { - fail( - ASSERTION_FAILED, - "Unable to create transient-dirty instance " - + "from a transient-clean instance via modifying a field, state is " - + states[curr]); + protected void makeTransientDirty(StateTransitionObj obj) { + if( obj == null ) return; + makeTransientClean(obj); + obj.writeField(DIRTY_VALUE); + int curr = currentState(obj); + if( curr != TRANSIENT_DIRTY ){ + fail(ASSERTION_FAILED, + "Unable to create transient-dirty instance " + + "from a transient-clean instance via modifying a field, state is " + states[curr]); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/mapping/AbstractRelationshipTest.java b/tck/src/main/java/org/apache/jdo/tck/mapping/AbstractRelationshipTest.java index 05d392ba4..b3cc72943 100644 --- a/tck/src/main/java/org/apache/jdo/tck/mapping/AbstractRelationshipTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/mapping/AbstractRelationshipTest.java @@ -21,6 +21,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; + import org.apache.jdo.tck.AbstractReaderTest; import org.apache.jdo.tck.pc.company.CompanyFactoryRegistry; import org.apache.jdo.tck.pc.company.CompanyModelReader; @@ -31,63 +32,66 @@ * Abstract class for managed relationship tests */ public class AbstractRelationshipTest extends AbstractReaderTest { - - protected CompanyModelReader reader = null; - - /** */ - protected final boolean isTestToBePerformed = isTestToBePerformed(); - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - if (isTestToBePerformed()) { - getPM(); - CompanyFactoryRegistry.registerFactory(pm); - reader = new CompanyModelReader(inputFilename); - addTearDownClass(reader.getTearDownClassesFromFactory()); - // persist test data - pm.currentTransaction().begin(); - List rootList = getRootList(reader); - pm.makePersistentAll(rootList); - rootOids = new ArrayList(); - for (Iterator i = rootList.iterator(); i.hasNext(); ) { - Object pc = i.next(); - rootOids.add(pm.getObjectId(pc)); - } - // DO THIS - // in xmlBeanFactory String[] getBeanDefinitionNames() - oidMap.put("emp1", pm.getObjectId(reader.getEmployee("emp1"))); - oidMap.put("emp2", pm.getObjectId(reader.getEmployee("emp2"))); - oidMap.put("emp4", pm.getObjectId(reader.getEmployee("emp4"))); - oidMap.put("medicalIns1", pm.getObjectId(reader.getMedicalInsurance("medicalIns1"))); - oidMap.put("medicalIns2", pm.getObjectId(reader.getMedicalInsurance("medicalIns2"))); - oidMap.put("dept1", pm.getObjectId(reader.getDepartment("dept1"))); - oidMap.put("dept2", pm.getObjectId(reader.getDepartment("dept2"))); - oidMap.put("proj1", pm.getObjectId(reader.getProject("proj1"))); - oidMap.put("proj2", pm.getObjectId(reader.getProject("proj2"))); - - pm.currentTransaction().commit(); - cleanupPM(); + + protected CompanyModelReader reader = null; + + /** */ + protected final boolean isTestToBePerformed = isTestToBePerformed(); + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + if (isTestToBePerformed()) { + getPM(); + CompanyFactoryRegistry.registerFactory(pm); + reader = new CompanyModelReader(inputFilename); + addTearDownClass(reader.getTearDownClassesFromFactory()); + // persist test data + pm.currentTransaction().begin(); + List rootList = getRootList(reader); + pm.makePersistentAll(rootList); + rootOids = new ArrayList(); + for (Iterator i = rootList.iterator(); i.hasNext(); ) { + Object pc = i.next(); + rootOids.add(pm.getObjectId(pc)); + } + // DO THIS + // in xmlBeanFactory String[] getBeanDefinitionNames() + oidMap.put("emp1", pm.getObjectId(reader.getEmployee("emp1"))); + oidMap.put("emp2", pm.getObjectId(reader.getEmployee("emp2"))); + oidMap.put("emp4", pm.getObjectId(reader.getEmployee("emp4"))); + oidMap.put("medicalIns1", + pm.getObjectId(reader.getMedicalInsurance("medicalIns1"))); + oidMap.put("medicalIns2", + pm.getObjectId(reader.getMedicalInsurance("medicalIns2"))); + oidMap.put("dept1", pm.getObjectId(reader.getDepartment("dept1"))); + oidMap.put("dept2", pm.getObjectId(reader.getDepartment("dept2"))); + oidMap.put("proj1", pm.getObjectId(reader.getProject("proj1"))); + oidMap.put("proj2", pm.getObjectId(reader.getProject("proj2"))); + + pm.currentTransaction().commit(); + cleanupPM(); + } } - } - protected boolean containsEmployee(Collection employees, long empid) { - for (Employee emp : employees) { - if (emp.getPersonid() == empid) { - return true; - } + protected boolean containsEmployee(Collection employees, long empid) { + for (Employee emp: employees) { + if (emp.getPersonid() == empid) { + return true; + } + } + return false; } - return false; - } - protected boolean containsProject(Collection projects, long projid) { - for (Project project : projects) { - if (project.getProjid() == projid) { - return true; - } + protected boolean containsProject(Collection projects, long projid) { + for (Project project: projects) { + if (project.getProjid() == projid) { + return true; + } + } + return false; } - return false; - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/mapping/CompletenessTest.java b/tck/src/main/java/org/apache/jdo/tck/mapping/CompletenessTest.java index a3cd12e1f..568d686b9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/mapping/CompletenessTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/mapping/CompletenessTest.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; + import org.apache.jdo.tck.AbstractReaderTest; import org.apache.jdo.tck.pc.company.CompanyFactoryRegistry; import org.apache.jdo.tck.pc.company.CompanyModelReader; @@ -28,89 +29,91 @@ import org.apache.jdo.tck.util.EqualityHelper; /** - * Title:Completeness Test
    - * Keywords: mapping
    - * Assertion ID: A18.[not identified]
    - * Assertion Description: + *Title:Completeness Test + *
    + *Keywords: mapping + *
    + *Assertion ID: A18.[not identified] + *
    + *Assertion Description: */ -public class CompletenessTest extends AbstractReaderTest { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A18-[not identified] failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CompletenessTest.class); - } +public class CompletenessTest extends AbstractReaderTest { - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - if (isTestToBePerformed()) { - getPM(); - CompanyFactoryRegistry.registerFactory(pm); - CompanyModelReader reader = new CompanyModelReader(inputFilename); - addTearDownClass(reader.getTearDownClassesFromFactory()); - // persist test data - pm.currentTransaction().begin(); - List rootList = getRootList(reader); - pm.makePersistentAll(rootList); - rootOids = new ArrayList(); - for (Iterator i = rootList.iterator(); i.hasNext(); ) { - Object pc = i.next(); - rootOids.add(pm.getObjectId(pc)); - } - pm.currentTransaction().commit(); - cleanupPM(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A18-[not identified] failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CompletenessTest.class); } - } - /** */ - public void test() { - if (isTestToBePerformed()) { - // register the default factory - CompanyFactoryRegistry.registerFactory(); - // get new obj graph to compare persistent graph with - CompanyModelReader reader = new CompanyModelReader(inputFilename); - List rootList = getRootList(reader); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + if (isTestToBePerformed()) { + getPM(); + CompanyFactoryRegistry.registerFactory(pm); + CompanyModelReader reader = new CompanyModelReader(inputFilename); + addTearDownClass(reader.getTearDownClassesFromFactory()); + // persist test data + pm.currentTransaction().begin(); + List rootList = getRootList(reader); + pm.makePersistentAll(rootList); + rootOids = new ArrayList(); + for (Iterator i = rootList.iterator(); i.hasNext(); ) { + Object pc = i.next(); + rootOids.add(pm.getObjectId(pc)); + } + pm.currentTransaction().commit(); + cleanupPM(); + } + } - getPM(); - pm.currentTransaction().begin(); - // compare persisted and new - int size = rootList.size(); - StringBuffer msg = new StringBuffer(); - for (int i = 0; i < size; i++) { - DeepEquality expected = (DeepEquality) rootList.get(i); - Object oid = rootOids.get(i); - Object persisted = pm.getObjectById(oid); - EqualityHelper equalityHelper = new EqualityHelper(); - if (!expected.deepCompareFields(persisted, equalityHelper)) { - if (msg.length() > 0) { - msg.append("\n"); - } - msg.append( - "Expected this instance:\n " - + expected - + "\n" - + "Got persistent instance:" - + "\n " - + persisted - + "\n" - + "Detailed list of differences follows...\n"); - msg.append(equalityHelper.getUnequalBuffer()); + /** */ + public void test() { + if (isTestToBePerformed()) { + // register the default factory + CompanyFactoryRegistry.registerFactory(); + // get new obj graph to compare persistent graph with + CompanyModelReader reader = new CompanyModelReader(inputFilename); + List rootList = getRootList(reader); + + getPM(); + pm.currentTransaction().begin(); + // compare persisted and new + int size = rootList.size(); + StringBuffer msg = new StringBuffer(); + for (int i = 0; i < size; i++) { + DeepEquality expected = (DeepEquality) rootList.get(i); + Object oid = rootOids.get(i); + Object persisted = pm.getObjectById(oid); + EqualityHelper equalityHelper = new EqualityHelper(); + if (!expected.deepCompareFields(persisted, equalityHelper)) { + if (msg.length() > 0) { + msg.append("\n"); + } + msg.append("Expected this instance:\n " + + expected + "\n" + + "Got persistent instance:" + "\n " + + persisted + "\n" + + "Detailed list of differences follows...\n"); + msg.append(equalityHelper.getUnequalBuffer()); + } + } + pm.currentTransaction().commit(); + // fail test if at least one of the instances is not the expected one + if (msg.length() > 0) { + fail("CompletenessTest failed; see list of failures below:", + msg.toString()); + } } - } - pm.currentTransaction().commit(); - // fail test if at least one of the instances is not the expected one - if (msg.length() > 0) { - fail("CompletenessTest failed; see list of failures below:", msg.toString()); - } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/mapping/CompletenessTestJPA.java b/tck/src/main/java/org/apache/jdo/tck/mapping/CompletenessTestJPA.java index e42e5fa02..d089d1dce 100644 --- a/tck/src/main/java/org/apache/jdo/tck/mapping/CompletenessTestJPA.java +++ b/tck/src/main/java/org/apache/jdo/tck/mapping/CompletenessTestJPA.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; + import org.apache.jdo.tck.AbstractReaderTest; import org.apache.jdo.tck.pc.company.CompanyFactoryRegistry; import org.apache.jdo.tck.pc.company.CompanyModelReader; @@ -28,92 +29,94 @@ import org.apache.jdo.tck.util.EqualityHelper; /** - * Title:Completeness Test JPA
    - * Keywords: mapping
    - * Assertion ID: A18.[not identified]
    - * Assertion Description: + *Title:Completeness Test JPA + *
    + *Keywords: mapping + *
    + *Assertion ID: A18.[not identified] + *
    + *Assertion Description: */ -public class CompletenessTestJPA extends AbstractReaderTest { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A18-[not identified] failed: "; - - /** */ - private final boolean isTestToBePerformed = isTestToBePerformed(); - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CompletenessTestJPA.class); - } +public class CompletenessTestJPA extends AbstractReaderTest { - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - if (runsWithApplicationIdentity()) { - getPM(); - CompanyFactoryRegistry.registerFactory(pm); - CompanyModelReader reader = new CompanyModelReader(inputFilename); - addTearDownClass(reader.getTearDownClassesFromFactory()); - // persist test data - pm.currentTransaction().begin(); - List rootList = getRootList(reader); - pm.makePersistentAll(rootList); - rootOids = new ArrayList(); - for (Iterator i = rootList.iterator(); i.hasNext(); ) { - Object pc = i.next(); - rootOids.add(pm.getObjectId(pc)); - } - pm.currentTransaction().commit(); - cleanupPM(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A18-[not identified] failed: "; + + /** */ + private final boolean isTestToBePerformed = isTestToBePerformed(); + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CompletenessTestJPA.class); } - } - /** */ - public void test() { - if (runsWithApplicationIdentity()) { - // register the default factory - CompanyFactoryRegistry.registerFactory(); - // get new obj graph to compare persistent graph with - CompanyModelReader reader = new CompanyModelReader(inputFilename); - List rootList = getRootList(reader); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + if (runsWithApplicationIdentity()) { + getPM(); + CompanyFactoryRegistry.registerFactory(pm); + CompanyModelReader reader = new CompanyModelReader(inputFilename); + addTearDownClass(reader.getTearDownClassesFromFactory()); + // persist test data + pm.currentTransaction().begin(); + List rootList = getRootList(reader); + pm.makePersistentAll(rootList); + rootOids = new ArrayList(); + for (Iterator i = rootList.iterator(); i.hasNext(); ) { + Object pc = i.next(); + rootOids.add(pm.getObjectId(pc)); + } + pm.currentTransaction().commit(); + cleanupPM(); + } + } - getPM(); - pm.currentTransaction().begin(); - // compare persisted and new - int size = rootList.size(); - StringBuffer msg = new StringBuffer(); - for (int i = 0; i < size; i++) { - DeepEquality expected = (DeepEquality) rootList.get(i); - Object oid = rootOids.get(i); - Object persisted = pm.getObjectById(oid); - EqualityHelper equalityHelper = new EqualityHelper(); - if (!expected.deepCompareFields(persisted, equalityHelper)) { - if (msg.length() > 0) { - msg.append("\n"); - } - msg.append( - "Expected this instance:\n " - + expected - + "\n" - + "Got persistent instance:" - + "\n " - + persisted - + "\n" - + "Detailed list of differences follows...\n"); - msg.append(equalityHelper.getUnequalBuffer()); + /** */ + public void test() { + if (runsWithApplicationIdentity()) { + // register the default factory + CompanyFactoryRegistry.registerFactory(); + // get new obj graph to compare persistent graph with + CompanyModelReader reader = new CompanyModelReader(inputFilename); + List rootList = getRootList(reader); + + getPM(); + pm.currentTransaction().begin(); + // compare persisted and new + int size = rootList.size(); + StringBuffer msg = new StringBuffer(); + for (int i = 0; i < size; i++) { + DeepEquality expected = (DeepEquality) rootList.get(i); + Object oid = rootOids.get(i); + Object persisted = pm.getObjectById(oid); + EqualityHelper equalityHelper = new EqualityHelper(); + if (!expected.deepCompareFields(persisted, equalityHelper)) { + if (msg.length() > 0) { + msg.append("\n"); + } + msg.append("Expected this instance:\n " + + expected + "\n" + + "Got persistent instance:" + "\n " + + persisted + "\n" + + "Detailed list of differences follows...\n"); + msg.append(equalityHelper.getUnequalBuffer()); + } + } + pm.currentTransaction().commit(); + // fail test if at least one of the instances is not the expected one + if (msg.length() > 0) { + fail("CompletenessTest failed; see list of failures below:", + msg.toString()); + } } - } - pm.currentTransaction().commit(); - // fail test if at least one of the instances is not the expected one - if (msg.length() > 0) { - fail("CompletenessTest failed; see list of failures below:", msg.toString()); - } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/mapping/CompletenessTestList.java b/tck/src/main/java/org/apache/jdo/tck/mapping/CompletenessTestList.java index 1ee5bcf8a..1068d2688 100644 --- a/tck/src/main/java/org/apache/jdo/tck/mapping/CompletenessTestList.java +++ b/tck/src/main/java/org/apache/jdo/tck/mapping/CompletenessTestList.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; + import org.apache.jdo.tck.AbstractReaderTest; import org.apache.jdo.tck.pc.companyListWithoutJoin.CompanyFactoryRegistry; import org.apache.jdo.tck.pc.companyListWithoutJoin.CompanyModelReader; @@ -28,92 +29,94 @@ import org.apache.jdo.tck.util.EqualityHelper; /** - * Title:Completeness Test List
    - * Keywords: mapping
    - * Assertion ID: A18.[not identified]
    - * Assertion Description: + *Title:Completeness Test List + *
    + *Keywords: mapping + *
    + *Assertion ID: A18.[not identified] + *
    + *Assertion Description: */ -public class CompletenessTestList extends AbstractReaderTest { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A18-[not identified] failed: "; - - /** */ - private final boolean isTestToBePerformed = isTestToBePerformed(); - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CompletenessTestList.class); - } +public class CompletenessTestList extends AbstractReaderTest { - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - if (isTestToBePerformed) { - getPM(); - CompanyFactoryRegistry.registerFactory(pm); - CompanyModelReader reader = new CompanyModelReader(inputFilename); - addTearDownClass(reader.getTearDownClassesFromFactory()); - // persist test data - pm.currentTransaction().begin(); - List rootList = getRootList(reader); - pm.makePersistentAll(rootList); - rootOids = new ArrayList(); - for (Iterator i = rootList.iterator(); i.hasNext(); ) { - Object pc = i.next(); - rootOids.add(pm.getObjectId(pc)); - } - pm.currentTransaction().commit(); - cleanupPM(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A18-[not identified] failed: "; + + /** */ + private final boolean isTestToBePerformed = isTestToBePerformed(); + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CompletenessTestList.class); } - } - /** */ - public void test() { - if (isTestToBePerformed) { - // register the default factory - CompanyFactoryRegistry.registerFactory(); - // get new obj graph to compare persistent graph with - CompanyModelReader reader = new CompanyModelReader(inputFilename); - List rootList = getRootList(reader); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + if (isTestToBePerformed) { + getPM(); + CompanyFactoryRegistry.registerFactory(pm); + CompanyModelReader reader = new CompanyModelReader(inputFilename); + addTearDownClass(reader.getTearDownClassesFromFactory()); + // persist test data + pm.currentTransaction().begin(); + List rootList = getRootList(reader); + pm.makePersistentAll(rootList); + rootOids = new ArrayList(); + for (Iterator i = rootList.iterator(); i.hasNext(); ) { + Object pc = i.next(); + rootOids.add(pm.getObjectId(pc)); + } + pm.currentTransaction().commit(); + cleanupPM(); + } + } - getPM(); - pm.currentTransaction().begin(); - // compare persisted and new - int size = rootList.size(); - StringBuffer msg = new StringBuffer(); - for (int i = 0; i < size; i++) { - DeepEquality expected = (DeepEquality) rootList.get(i); - Object oid = rootOids.get(i); - Object persisted = pm.getObjectById(oid); - EqualityHelper equalityHelper = new EqualityHelper(); - if (!expected.deepCompareFields(persisted, equalityHelper)) { - if (msg.length() > 0) { - msg.append("\n"); - } - msg.append( - "Expected this instance:\n " - + expected - + "\n" - + "Got persistent instance:" - + "\n " - + persisted - + "\n" - + "Detailed list of differences follows...\n"); - msg.append(equalityHelper.getUnequalBuffer()); + /** */ + public void test() { + if (isTestToBePerformed) { + // register the default factory + CompanyFactoryRegistry.registerFactory(); + // get new obj graph to compare persistent graph with + CompanyModelReader reader = new CompanyModelReader(inputFilename); + List rootList = getRootList(reader); + + getPM(); + pm.currentTransaction().begin(); + // compare persisted and new + int size = rootList.size(); + StringBuffer msg = new StringBuffer(); + for (int i = 0; i < size; i++) { + DeepEquality expected = (DeepEquality) rootList.get(i); + Object oid = rootOids.get(i); + Object persisted = pm.getObjectById(oid); + EqualityHelper equalityHelper = new EqualityHelper(); + if (!expected.deepCompareFields(persisted, equalityHelper)) { + if (msg.length() > 0) { + msg.append("\n"); + } + msg.append("Expected this instance:\n " + + expected + "\n" + + "Got persistent instance:" + "\n " + + persisted + "\n" + + "Detailed list of differences follows...\n"); + msg.append(equalityHelper.getUnequalBuffer()); + } + } + pm.currentTransaction().commit(); + // fail test if at least one of the instances is not the expected one + if (msg.length() > 0) { + fail("CompletenessTestList failed; see list of failures below:", + msg.toString()); + } } - } - pm.currentTransaction().commit(); - // fail test if at least one of the instances is not the expected one - if (msg.length() > 0) { - fail("CompletenessTestList failed; see list of failures below:", msg.toString()); - } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/mapping/CompletenessTestMap.java b/tck/src/main/java/org/apache/jdo/tck/mapping/CompletenessTestMap.java index df0a4e8ea..d39afc890 100644 --- a/tck/src/main/java/org/apache/jdo/tck/mapping/CompletenessTestMap.java +++ b/tck/src/main/java/org/apache/jdo/tck/mapping/CompletenessTestMap.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; + import org.apache.jdo.tck.AbstractReaderTest; import org.apache.jdo.tck.pc.companyMapWithoutJoin.CompanyFactoryRegistry; import org.apache.jdo.tck.pc.companyMapWithoutJoin.CompanyModelReader; @@ -28,92 +29,94 @@ import org.apache.jdo.tck.util.EqualityHelper; /** - * Title:Completeness Test Map
    - * Keywords: mapping
    - * Assertion ID: A18.[not identified]
    - * Assertion Description: + *Title:Completeness Test Map + *
    + *Keywords: mapping + *
    + *Assertion ID: A18.[not identified] + *
    + *Assertion Description: */ -public class CompletenessTestMap extends AbstractReaderTest { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A18-[not identified] failed: "; - - /** */ - private final boolean isTestToBePerformed = isTestToBePerformed(); - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CompletenessTestMap.class); - } +public class CompletenessTestMap extends AbstractReaderTest { - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - if (isTestToBePerformed) { - getPM(); - CompanyFactoryRegistry.registerFactory(pm); - CompanyModelReader reader = new CompanyModelReader(inputFilename); - addTearDownClass(reader.getTearDownClassesFromFactory()); - // persist test data - pm.currentTransaction().begin(); - List rootList = getRootList(reader); - pm.makePersistentAll(rootList); - rootOids = new ArrayList(); - for (Iterator i = rootList.iterator(); i.hasNext(); ) { - Object pc = i.next(); - rootOids.add(pm.getObjectId(pc)); - } - pm.currentTransaction().commit(); - cleanupPM(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A18-[not identified] failed: "; + + /** */ + private final boolean isTestToBePerformed = isTestToBePerformed(); + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CompletenessTestMap.class); } - } - /** */ - public void test() { - if (isTestToBePerformed) { - // register the default factory - CompanyFactoryRegistry.registerFactory(); - // get new obj graph to compare persistent graph with - CompanyModelReader reader = new CompanyModelReader(inputFilename); - List rootList = getRootList(reader); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + if (isTestToBePerformed) { + getPM(); + CompanyFactoryRegistry.registerFactory(pm); + CompanyModelReader reader = new CompanyModelReader(inputFilename); + addTearDownClass(reader.getTearDownClassesFromFactory()); + // persist test data + pm.currentTransaction().begin(); + List rootList = getRootList(reader); + pm.makePersistentAll(rootList); + rootOids = new ArrayList(); + for (Iterator i = rootList.iterator(); i.hasNext(); ) { + Object pc = i.next(); + rootOids.add(pm.getObjectId(pc)); + } + pm.currentTransaction().commit(); + cleanupPM(); + } + } - getPM(); - pm.currentTransaction().begin(); - // compare persisted and new - int size = rootList.size(); - StringBuffer msg = new StringBuffer(); - for (int i = 0; i < size; i++) { - DeepEquality expected = (DeepEquality) rootList.get(i); - Object oid = rootOids.get(i); - Object persisted = pm.getObjectById(oid); - EqualityHelper equalityHelper = new EqualityHelper(); - if (!expected.deepCompareFields(persisted, equalityHelper)) { - if (msg.length() > 0) { - msg.append("\n"); - } - msg.append( - "Expected this instance:\n " - + expected - + "\n" - + "Got persistent instance:" - + "\n " - + persisted - + "\n" - + "Detailed list of differences follows...\n"); - msg.append(equalityHelper.getUnequalBuffer()); + /** */ + public void test() { + if (isTestToBePerformed) { + // register the default factory + CompanyFactoryRegistry.registerFactory(); + // get new obj graph to compare persistent graph with + CompanyModelReader reader = new CompanyModelReader(inputFilename); + List rootList = getRootList(reader); + + getPM(); + pm.currentTransaction().begin(); + // compare persisted and new + int size = rootList.size(); + StringBuffer msg = new StringBuffer(); + for (int i = 0; i < size; i++) { + DeepEquality expected = (DeepEquality) rootList.get(i); + Object oid = rootOids.get(i); + Object persisted = pm.getObjectById(oid); + EqualityHelper equalityHelper = new EqualityHelper(); + if (!expected.deepCompareFields(persisted, equalityHelper)) { + if (msg.length() > 0) { + msg.append("\n"); + } + msg.append("Expected this instance:\n " + + expected + "\n" + + "Got persistent instance:" + "\n " + + persisted + "\n" + + "Detailed list of differences follows...\n"); + msg.append(equalityHelper.getUnequalBuffer()); + } + } + pm.currentTransaction().commit(); + // fail test if at least one of the instances is not the expected one + if (msg.length() > 0) { + fail("CompletenessTestMap failed; see list of failures below:", + msg.toString()); + } } - } - pm.currentTransaction().commit(); - // fail test if at least one of the instances is not the expected one - if (msg.length() > 0) { - fail("CompletenessTestMap failed; see list of failures below:", msg.toString()); - } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/mapping/CompletenessTestOrder.java b/tck/src/main/java/org/apache/jdo/tck/mapping/CompletenessTestOrder.java index a5da74e96..5283010a6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/mapping/CompletenessTestOrder.java +++ b/tck/src/main/java/org/apache/jdo/tck/mapping/CompletenessTestOrder.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; + import org.apache.jdo.tck.AbstractReaderTest; import org.apache.jdo.tck.pc.order.OrderFactoryRegistry; import org.apache.jdo.tck.pc.order.OrderModelReader; @@ -28,92 +29,91 @@ import org.apache.jdo.tck.util.EqualityHelper; /** - * Title:Completeness Test for the Order model
    - * Keywords: mapping compound identity
    - * Assertion ID: A5.4.1-5
    - * Assertion Description: Compound identity is a special case of application identity. References - * to other persistence-capable classes can be defined as key fields. In this case, the object id - * class contains a field that is of the type of the object id of the relationship field. + *Title:Completeness Test for the Order model + *
    + *Keywords: mapping compound identity + *
    + *Assertion ID: A5.4.1-5 + *
    + *Assertion Description: Compound identity is a special case of application identity. References to other persistence-capable classes can be defined as key fields. In this case, the object id class contains a field that is of the type of the object id of the relationship field. */ -public class CompletenessTestOrder extends AbstractReaderTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A5.4.1-5[Compound identity is a special case of application identity. References to other persistence-capable classes can be defined as key fields. In this case, the object id class contains a field that is of the type of the object id of the relationship field.] failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CompletenessTestOrder.class); - } +public class CompletenessTestOrder extends AbstractReaderTest { - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - if (runsWithApplicationIdentity()) { - getPM(); - OrderFactoryRegistry.registerFactory(pm); - OrderModelReader reader = new OrderModelReader(inputFilename); - addTearDownClass(reader.getTearDownClassesFromFactory()); - // persist test data - pm.currentTransaction().begin(); - List rootList = getRootList(reader); - pm.makePersistentAll(rootList); - rootOids = new ArrayList(); - for (Iterator i = rootList.iterator(); i.hasNext(); ) { - Object pc = i.next(); - rootOids.add(pm.getObjectId(pc)); - } - pm.currentTransaction().commit(); - cleanupPM(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A5.4.1-5[Compound identity is a special case of application identity. References to other persistence-capable classes can be defined as key fields. In this case, the object id class contains a field that is of the type of the object id of the relationship field.] failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CompletenessTestOrder.class); } - } - /** */ - public void test() { - if (runsWithApplicationIdentity()) { - // register the default factory - OrderFactoryRegistry.registerFactory(); - // get new obj graph to compare persistent graph with - OrderModelReader reader = new OrderModelReader(inputFilename); - List rootList = getRootList(reader); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + if (runsWithApplicationIdentity()) { + getPM(); + OrderFactoryRegistry.registerFactory(pm); + OrderModelReader reader = new OrderModelReader(inputFilename); + addTearDownClass(reader.getTearDownClassesFromFactory()); + // persist test data + pm.currentTransaction().begin(); + List rootList = getRootList(reader); + pm.makePersistentAll(rootList); + rootOids = new ArrayList(); + for (Iterator i = rootList.iterator(); i.hasNext(); ) { + Object pc = i.next(); + rootOids.add(pm.getObjectId(pc)); + } + pm.currentTransaction().commit(); + cleanupPM(); + } + } - getPM(); - pm.currentTransaction().begin(); - // compare persisted and new - int size = rootList.size(); - StringBuffer msg = new StringBuffer(); - for (int i = 0; i < size; i++) { - DeepEquality expected = (DeepEquality) rootList.get(i); - Object oid = rootOids.get(i); - Object persisted = pm.getObjectById(oid); - EqualityHelper equalityHelper = new EqualityHelper(); - if (!expected.deepCompareFields(persisted, equalityHelper)) { - if (msg.length() > 0) { - msg.append("\n"); - } - msg.append( - "Expected this instance:\n " - + expected - + "\n" - + "Got persistent instance:" - + "\n " - + persisted - + "\n" - + "Detailed list of differences follows...\n"); - msg.append(equalityHelper.getUnequalBuffer()); + /** */ + public void test() { + if (runsWithApplicationIdentity()) { + // register the default factory + OrderFactoryRegistry.registerFactory(); + // get new obj graph to compare persistent graph with + OrderModelReader reader = new OrderModelReader(inputFilename); + List rootList = getRootList(reader); + + getPM(); + pm.currentTransaction().begin(); + // compare persisted and new + int size = rootList.size(); + StringBuffer msg = new StringBuffer(); + for (int i = 0; i < size; i++) { + DeepEquality expected = (DeepEquality) rootList.get(i); + Object oid = rootOids.get(i); + Object persisted = pm.getObjectById(oid); + EqualityHelper equalityHelper = new EqualityHelper(); + if (!expected.deepCompareFields(persisted, equalityHelper)) { + if (msg.length() > 0) { + msg.append("\n"); + } + msg.append("Expected this instance:\n " + + expected + "\n" + + "Got persistent instance:" + "\n " + + persisted + "\n" + + "Detailed list of differences follows...\n"); + msg.append(equalityHelper.getUnequalBuffer()); + } + } + pm.currentTransaction().commit(); + //fail test if at least one of the instances is not the expected one + if (msg.length() > 0) { + fail("CompletenessTestOrder failed; see list of failures below:", + msg.toString()); + } } - } - pm.currentTransaction().commit(); - // fail test if at least one of the instances is not the expected one - if (msg.length() > 0) { - fail("CompletenessTestOrder failed; see list of failures below:", msg.toString()); - } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/mapping/Relationship1To1AllRelationships.java b/tck/src/main/java/org/apache/jdo/tck/mapping/Relationship1To1AllRelationships.java index c00ca6dec..6109dd1aa 100644 --- a/tck/src/main/java/org/apache/jdo/tck/mapping/Relationship1To1AllRelationships.java +++ b/tck/src/main/java/org/apache/jdo/tck/mapping/Relationship1To1AllRelationships.java @@ -24,403 +24,397 @@ import org.apache.jdo.tck.pc.company.MedicalInsurance; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:Relationship1To1AllRelationships
    - * Keywords: mapping, managed relationships
    - * Assertion ID: A15.3-14
    - * Assertion Description: Regardless of which side changes the relationship, flush (whether done - * as part of commit or explicitly by the user) will modify the datastore to reflect the change and - * will update the memory model for consistency... + *Title:Relationship1To1AllRelationships + *
    + *Keywords: mapping, managed relationships + *
    + *Assertion ID: A15.3-14 + *
    + *Assertion Description: Regardless of which side changes the relationship, + * flush (whether done as part of commit or explicitly by the user) will modify + * the datastore to reflect the change and will update the memory model + * for consistency... */ -public class Relationship1To1AllRelationships extends AbstractRelationshipTest { - - String testMethod = null; - protected String ASSERTION_FAILED = - "Assertion A15-3.14 (Relationship1To1AllRelationships) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Relationship1To1AllRelationships.class); - } - - Object emp1Oid = null; - Object emp2Oid = null; - Object medIns1Oid = null; - Object medIns2Oid = null; - IEmployee emp1 = null; - IEmployee emp2 = null; - IMedicalInsurance medIns1 = null; - IMedicalInsurance medIns2 = null; - - /** - * @see AbstractRelationshipTest#localSetUp() - */ - @Override - protected void localSetUp() { - super.localSetUp(); - if (isTestToBePerformed) { - getPM(); - pm.currentTransaction().begin(); - - emp1Oid = getOidByName("emp1"); - emp2Oid = getOidByName("emp2"); - medIns1Oid = getOidByName("medicalIns1"); - medIns2Oid = getOidByName("medicalIns2"); - emp1 = (IEmployee) pm.getObjectById(emp1Oid); - emp2 = (IEmployee) pm.getObjectById(emp2Oid); - medIns1 = (IMedicalInsurance) pm.getObjectById(medIns1Oid); - medIns2 = (IMedicalInsurance) pm.getObjectById(medIns2Oid); - // Preconditions - assertTrue( - ASSERTION_FAILED - + testMethod - + ": Test aborted, precondition is false; " - + "expected emp.getMedicalInsurance()to be medicalIns1", - emp1.getMedicalInsurance() == medIns1); - assertTrue( - ASSERTION_FAILED - + testMethod - + ": Test aborted, precondition is false; " - + "expected ins.getEmployee() to be emp1", - medIns1.getEmployee() == emp1); - assertTrue( - ASSERTION_FAILED - + testMethod - + ": Test aborted, precondition is false; " - + "expected emp.getMedicalInsurance()to be medicalIns1", - emp2.getMedicalInsurance() == medIns2); - assertTrue( - ASSERTION_FAILED - + testMethod - + ": Test aborted, precondition is false; " - + "expected ins.getEmployee() to be emp1", - medIns2.getEmployee() == emp2); +public class Relationship1To1AllRelationships extends AbstractRelationshipTest { + + String testMethod = null; + protected String ASSERTION_FAILED = + "Assertion A15-3.14 (Relationship1To1AllRelationships) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Relationship1To1AllRelationships.class); } - } - - /** */ - public void testSetToExistingFromMappedSide() { - testMethod = "testSetToExistingFromMappedSide"; - if (isTestToBePerformed) { - - // Set relationship - medIns1.setEmployee(emp2); - pm.flush(); - - // Postcondition - deferredAssertTrue( - emp2.getMedicalInsurance() == medIns1, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - deferredAssertTrue( - emp1.getMedicalInsurance() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship (emp1) not nulled on flush"); - deferredAssertTrue( - medIns2.getEmployee() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship (medIns2) not nulled on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (IEmployee) pm.getObjectById(emp1Oid); - emp2 = (IEmployee) pm.getObjectById(emp2Oid); - medIns1 = (IMedicalInsurance) pm.getObjectById(medIns1Oid); - medIns2 = (IMedicalInsurance) pm.getObjectById(medIns2Oid); - deferredAssertTrue( - emp2.getMedicalInsurance() == medIns1, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set in new pm"); - deferredAssertTrue( - emp1.getMedicalInsurance() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship (emp1) not nulled in new pm"); - deferredAssertTrue( - medIns2.getEmployee() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship (medIns2) not nulled in new pm"); - pm.currentTransaction().commit(); - - failOnError(); + + Object emp1Oid = null; + Object emp2Oid = null; + Object medIns1Oid = null; + Object medIns2Oid = null; + IEmployee emp1 = null; + IEmployee emp2 = null; + IMedicalInsurance medIns1 = null; + IMedicalInsurance medIns2 = null; + + /** + * @see AbstractRelationshipTest#localSetUp() + */ + @Override + protected void localSetUp() { + super.localSetUp(); + if (isTestToBePerformed) { + getPM(); + pm.currentTransaction().begin(); + + emp1Oid = getOidByName("emp1"); + emp2Oid = getOidByName("emp2"); + medIns1Oid = getOidByName("medicalIns1"); + medIns2Oid = getOidByName("medicalIns2"); + emp1 = (IEmployee)pm.getObjectById(emp1Oid); + emp2 = (IEmployee)pm.getObjectById(emp2Oid); + medIns1 = (IMedicalInsurance)pm.getObjectById(medIns1Oid); + medIns2 = (IMedicalInsurance)pm.getObjectById(medIns2Oid); + + // Preconditions + assertTrue(ASSERTION_FAILED + testMethod + + ": Test aborted, precondition is false; " + + "expected emp.getMedicalInsurance()to be medicalIns1", + emp1.getMedicalInsurance() == medIns1); + assertTrue(ASSERTION_FAILED + testMethod + + ": Test aborted, precondition is false; " + + "expected ins.getEmployee() to be emp1", + medIns1.getEmployee() == emp1); + assertTrue(ASSERTION_FAILED + testMethod + + ": Test aborted, precondition is false; " + + "expected emp.getMedicalInsurance()to be medicalIns1", + emp2.getMedicalInsurance() == medIns2); + assertTrue(ASSERTION_FAILED + testMethod + + ": Test aborted, precondition is false; " + + "expected ins.getEmployee() to be emp1", + medIns2.getEmployee() == emp2); + } } - } - - /** */ - public void testSetToExistingFromMappedBySide() { - testMethod = "testSetToExistingFromMappedBySide"; - if (isTestToBePerformed) { - - // Set relationship - emp1.setMedicalInsurance(medIns2); - pm.flush(); - - // Postcondition - deferredAssertTrue( - medIns2.getEmployee() == emp1, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush."); - deferredAssertTrue( - medIns1.getEmployee() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship (medIns1) not nulled on flush."); - deferredAssertTrue( - emp2.getMedicalInsurance() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship (emp2) not nulled on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (IEmployee) pm.getObjectById(emp1Oid); - emp2 = (IEmployee) pm.getObjectById(emp2Oid); - medIns1 = (IMedicalInsurance) pm.getObjectById(medIns1Oid); - medIns2 = (IMedicalInsurance) pm.getObjectById(medIns2Oid); - deferredAssertTrue( - medIns2.getEmployee() == emp1, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set in new pm."); - deferredAssertTrue( - medIns1.getEmployee() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship (medIns1) not nulled in new pm."); - deferredAssertTrue( - emp2.getMedicalInsurance() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship (emp2) not nulled in new pm."); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testSetToExistingFromMappedSide() { + testMethod = "testSetToExistingFromMappedSide"; + if (isTestToBePerformed) { + + // Set relationship + medIns1.setEmployee(emp2); + pm.flush(); + + // Postcondition + deferredAssertTrue(emp2.getMedicalInsurance() == medIns1, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + deferredAssertTrue(emp1.getMedicalInsurance() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship (emp1) not nulled on flush"); + deferredAssertTrue(medIns2.getEmployee() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship (medIns2) not nulled on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (IEmployee)pm.getObjectById(emp1Oid); + emp2 = (IEmployee)pm.getObjectById(emp2Oid); + medIns1 = (IMedicalInsurance)pm.getObjectById(medIns1Oid); + medIns2 = (IMedicalInsurance)pm.getObjectById(medIns2Oid); + deferredAssertTrue(emp2.getMedicalInsurance() == medIns1, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set in new pm"); + deferredAssertTrue(emp1.getMedicalInsurance() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship (emp1) not nulled in new pm"); + deferredAssertTrue(medIns2.getEmployee() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship (medIns2) not nulled in new pm"); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testSetToNullFromMappedSide() { - testMethod = "testSetToNullFromMappedSide"; - if (isTestToBePerformed) { - - // Set relationship - medIns1.setEmployee(null); - pm.flush(); - - // Postcondition - deferredAssertTrue( - emp1.getMedicalInsurance() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (IEmployee) pm.getObjectById(emp1Oid); - deferredAssertTrue( - emp1.getMedicalInsurance() == null, - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testSetToExistingFromMappedBySide() { + testMethod = "testSetToExistingFromMappedBySide"; + if (isTestToBePerformed) { + + // Set relationship + emp1.setMedicalInsurance(medIns2); + pm.flush(); + + // Postcondition + deferredAssertTrue(medIns2.getEmployee() == emp1, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush."); + deferredAssertTrue(medIns1.getEmployee() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship (medIns1) not nulled on flush."); + deferredAssertTrue(emp2.getMedicalInsurance() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship (emp2) not nulled on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (IEmployee)pm.getObjectById(emp1Oid); + emp2 = (IEmployee)pm.getObjectById(emp2Oid); + medIns1 = (IMedicalInsurance)pm.getObjectById(medIns1Oid); + medIns2 = (IMedicalInsurance)pm.getObjectById(medIns2Oid); + deferredAssertTrue(medIns2.getEmployee() == emp1, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set in new pm."); + deferredAssertTrue(medIns1.getEmployee() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship (medIns1) not nulled in new pm."); + deferredAssertTrue(emp2.getMedicalInsurance() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship (emp2) not nulled in new pm."); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testSetToNullFromMappedBySide() { - testMethod = "testSetToNullFromMappedBySide"; - if (isTestToBePerformed) { - - // Set relationship - emp1.setMedicalInsurance(null); - pm.flush(); - - // Postcondition - deferredAssertTrue( - medIns1.getEmployee() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - // emp1 = (IEmployee)pm.getObjectById(emp1Oid); - medIns1 = (IMedicalInsurance) pm.getObjectById(medIns1Oid); - deferredAssertTrue( - medIns1.getEmployee() == null, - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testSetToNullFromMappedSide() { + testMethod = "testSetToNullFromMappedSide"; + if (isTestToBePerformed) { + + // Set relationship + medIns1.setEmployee(null); + pm.flush(); + + // Postcondition + deferredAssertTrue(emp1.getMedicalInsurance() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (IEmployee)pm.getObjectById(emp1Oid); + deferredAssertTrue( + emp1.getMedicalInsurance() == null, + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testSetToNewFromMappedSide() { - testMethod = "testSetToNewFromMappedSide"; - if (isTestToBePerformed) { - - // Set relationship - IEmployee empNew = - new FullTimeEmployee(99, "Matthew", "", "Adams", new Date(0L), new Date(10000L), 125000); - pm.makePersistent(empNew); - medIns1.setEmployee(empNew); - Object empNewOid = pm.getObjectId((Object) empNew); - pm.flush(); - - assertFalse( - testMethod - + ": Test aborted, precondition is false; " - + "expected empNewOid to be non-null", - empNewOid == null); - - // Postcondition - deferredAssertTrue( - empNew.getMedicalInsurance() == medIns1, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - deferredAssertTrue( - emp1.getMedicalInsurance() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship (emp1) not nulled on flush"); - - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (IEmployee) pm.getObjectById(emp1Oid); - empNew = (IEmployee) pm.getObjectById(empNewOid); - medIns1 = (IMedicalInsurance) pm.getObjectById(medIns1Oid); - deferredAssertTrue( - empNew.getMedicalInsurance() == medIns1, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set in new pm"); - deferredAssertTrue( - emp1.getMedicalInsurance() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship (emp1) not nulled in new pm"); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testSetToNullFromMappedBySide() { + testMethod = "testSetToNullFromMappedBySide"; + if (isTestToBePerformed) { + + // Set relationship + emp1.setMedicalInsurance(null); + pm.flush(); + + // Postcondition + deferredAssertTrue(medIns1.getEmployee() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + //emp1 = (IEmployee)pm.getObjectById(emp1Oid); + medIns1 = (IMedicalInsurance)pm.getObjectById(medIns1Oid); + deferredAssertTrue( + medIns1.getEmployee() == null, + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testSetToNewFromMappedBySide() { - testMethod = "testSetToNewFromMappedBySide"; - if (isTestToBePerformed) { - - // Set relationship - IMedicalInsurance medInsNew = new MedicalInsurance(99L, "Ameriblast", "B"); - pm.makePersistent(medInsNew); - emp1.setMedicalInsurance(medInsNew); - Object medInsNewOid = pm.getObjectId((Object) medInsNew); - pm.flush(); - - assertFalse( - testMethod - + ": Test aborted, precondition is false; " - + "expected medInsNewOid to be non-null", - medInsNewOid == null); - - // Postcondition - deferredAssertTrue( - medInsNew.getEmployee() == emp1, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush."); - deferredAssertTrue( - medIns1.getEmployee() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship (medIns1) not nulled on flush."); - - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (IEmployee) pm.getObjectById(emp1Oid); - medInsNew = (IMedicalInsurance) pm.getObjectById(medInsNewOid); - medIns1 = (IMedicalInsurance) pm.getObjectById(medIns1Oid); - deferredAssertTrue( - medInsNew.getEmployee() == emp1, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set in new pm"); - deferredAssertTrue( - medIns1.getEmployee() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship (medIns1) not nulled in new pm"); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testSetToNewFromMappedSide() { + testMethod = "testSetToNewFromMappedSide"; + if (isTestToBePerformed) { + + // Set relationship + IEmployee empNew = new FullTimeEmployee(99, "Matthew", "", "Adams", + new Date(0L), new Date(10000L), 125000); + pm.makePersistent(empNew); + medIns1.setEmployee(empNew); + Object empNewOid = pm.getObjectId((Object)empNew); + pm.flush(); + + assertFalse(testMethod + ": Test aborted, precondition is false; " + + "expected empNewOid to be non-null", empNewOid == null); + + // Postcondition + deferredAssertTrue(empNew.getMedicalInsurance() == medIns1, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + deferredAssertTrue(emp1.getMedicalInsurance() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship (emp1) not nulled on flush"); + + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (IEmployee)pm.getObjectById(emp1Oid); + empNew = (IEmployee)pm.getObjectById(empNewOid); + medIns1 = (IMedicalInsurance)pm.getObjectById(medIns1Oid); + deferredAssertTrue(empNew.getMedicalInsurance() == medIns1, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set in new pm"); + deferredAssertTrue(emp1.getMedicalInsurance() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship (emp1) not nulled in new pm"); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - /** */ - public void testDeleteFromMappedSide() { - testMethod = "testDeleteFromMappedSide"; - if (isTestToBePerformed) { - // Set relationship - pm.deletePersistent(medIns1); - pm.flush(); - - // Postcondition - deferredAssertTrue( - emp1.getMedicalInsurance() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (IEmployee) pm.getObjectById(emp1Oid); - deferredAssertTrue( - emp1.getMedicalInsurance() == null, - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testSetToNewFromMappedBySide() { + testMethod = "testSetToNewFromMappedBySide"; + if (isTestToBePerformed) { + + // Set relationship + IMedicalInsurance medInsNew = new MedicalInsurance(99L, + "Ameriblast", "B"); + pm.makePersistent(medInsNew); + emp1.setMedicalInsurance(medInsNew); + Object medInsNewOid = pm.getObjectId((Object)medInsNew); + pm.flush(); + + assertFalse(testMethod + ": Test aborted, precondition is false; " + + "expected medInsNewOid to be non-null", medInsNewOid == null); + + // Postcondition + deferredAssertTrue(medInsNew.getEmployee() == emp1, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush."); + deferredAssertTrue(medIns1.getEmployee() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship (medIns1) not nulled on flush."); + + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (IEmployee)pm.getObjectById(emp1Oid); + medInsNew = (IMedicalInsurance)pm.getObjectById(medInsNewOid); + medIns1 = (IMedicalInsurance)pm.getObjectById(medIns1Oid); + deferredAssertTrue(medInsNew.getEmployee() == emp1, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set in new pm"); + deferredAssertTrue(medIns1.getEmployee() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship (medIns1) not nulled in new pm"); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testDeleteFromMappedBySide() { - testMethod = "testDeleteFromMappedBySide"; - if (isTestToBePerformed) { - // Set relationship - pm.deletePersistent(emp1); - pm.flush(); - - // Postcondition - deferredAssertTrue( - medIns1.getEmployee() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - medIns1 = (IMedicalInsurance) pm.getObjectById(medIns1Oid); - deferredAssertTrue( - medIns1.getEmployee() == null, - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + /** */ + public void testDeleteFromMappedSide() { + testMethod = "testDeleteFromMappedSide"; + if (isTestToBePerformed) { + // Set relationship + pm.deletePersistent(medIns1); + pm.flush(); + + // Postcondition + deferredAssertTrue(emp1.getMedicalInsurance() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (IEmployee)pm.getObjectById(emp1Oid); + deferredAssertTrue( + emp1.getMedicalInsurance() == null, + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } + } + + /** */ + public void testDeleteFromMappedBySide() { + testMethod = "testDeleteFromMappedBySide"; + if (isTestToBePerformed) { + // Set relationship + pm.deletePersistent(emp1); + pm.flush(); + + // Postcondition + deferredAssertTrue(medIns1.getEmployee() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + medIns1 = (IMedicalInsurance)pm.getObjectById(medIns1Oid); + deferredAssertTrue( + medIns1.getEmployee() == null, + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/mapping/Relationship1To1NoRelationships.java b/tck/src/main/java/org/apache/jdo/tck/mapping/Relationship1To1NoRelationships.java index d2e094bc3..f3a86f268 100644 --- a/tck/src/main/java/org/apache/jdo/tck/mapping/Relationship1To1NoRelationships.java +++ b/tck/src/main/java/org/apache/jdo/tck/mapping/Relationship1To1NoRelationships.java @@ -23,201 +23,206 @@ import org.apache.jdo.tck.pc.company.MedicalInsurance; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:Relationship1To1NoRelationships
    - * Keywords: mapping, managed relationships
    - * Assertion ID: A15.3-14
    - * Assertion Description: Regardless of which side changes the relationship, flush (whether done - * as part of commit or explicitly by the user) will modify the datastore to reflect the change and - * will update the memory model for consistency... + *Title:Relationship1To1NoRelationships + *
    + *Keywords: mapping, managed relationships + *
    + *Assertion ID: A15.3-14 + *
    + *Assertion Description: Regardless of which side changes the relationship, + * flush (whether done as part of commit or explicitly by the user) will modify + * the datastore to reflect the change and will update the memory model + * for consistency... */ -public class Relationship1To1NoRelationships extends AbstractRelationshipTest { - - String testMethod = null; - protected String ASSERTION_FAILED = - "Assertion A15-3.14 (Relationship1To1NoRelationships) failed: "; - - Object emp1Oid = null; - Object emp2Oid = null; - Object medIns1Oid = null; - Object medIns2Oid = null; - Employee emp1 = null; - Employee emp2 = null; - MedicalInsurance medIns1 = null; - MedicalInsurance medIns2 = null; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Relationship1To1NoRelationships.class); - } - - /** - * @see AbstractRelationshipTest#localSetUp() - */ - @Override - protected void localSetUp() { - super.localSetUp(); - if (isTestToBePerformed) { - getPM(); - pm.currentTransaction().begin(); - - emp1Oid = getOidByName("emp1"); - medIns1Oid = getOidByName("medicalIns1"); - emp1 = (Employee) pm.getObjectById(emp1Oid); - medIns1 = (MedicalInsurance) pm.getObjectById(medIns1Oid); - - // Preconditions - assertTrue( - ASSERTION_FAILED - + ": Test aborted, precondition is false; " - + "expected emp.getMedicalInsurance()to be null", - emp1.getMedicalInsurance() == null); - assertTrue( - ASSERTION_FAILED - + ": Test aborted, precondition is false; " - + "expected ins.getEmployee() to be null", - medIns1.getEmployee() == null); +public class Relationship1To1NoRelationships extends AbstractRelationshipTest { + + String testMethod = null; + protected String ASSERTION_FAILED = + "Assertion A15-3.14 (Relationship1To1NoRelationships) failed: "; + + Object emp1Oid = null; + Object emp2Oid = null; + Object medIns1Oid = null; + Object medIns2Oid = null; + Employee emp1 = null; + Employee emp2 = null; + MedicalInsurance medIns1 = null; + MedicalInsurance medIns2 = null; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Relationship1To1NoRelationships.class); } - } - - /** */ - public void testSetToExistingFromMappedSide() { - testMethod = "testSetToExistingFromMappedSide"; - if (isTestToBePerformed) { - - // Set relationship - medIns1.setEmployee(emp1); - pm.flush(); - - // Postcondition - deferredAssertTrue( - emp1.getMedicalInsurance() == medIns1, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - medIns1 = (MedicalInsurance) pm.getObjectById(medIns1Oid); - deferredAssertTrue( - emp1.getMedicalInsurance() == medIns1, - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + + /** + * @see AbstractRelationshipTest#localSetUp() + */ + @Override + protected void localSetUp() { + super.localSetUp(); + if (isTestToBePerformed) { + getPM(); + pm.currentTransaction().begin(); + + emp1Oid = getOidByName("emp1"); + medIns1Oid = getOidByName("medicalIns1"); + emp1 = (Employee)pm.getObjectById(emp1Oid); + medIns1 = (MedicalInsurance)pm.getObjectById(medIns1Oid); + + // Preconditions + assertTrue(ASSERTION_FAILED + + ": Test aborted, precondition is false; " + + "expected emp.getMedicalInsurance()to be null", + emp1.getMedicalInsurance() == null); + assertTrue(ASSERTION_FAILED + + ": Test aborted, precondition is false; " + + "expected ins.getEmployee() to be null", + medIns1.getEmployee() == null); + } } - } - - /** */ - public void testSetToExistingFromMappedBySide() { - testMethod = "testSetToExistingFromMappedBySide"; - if (isTestToBePerformed) { - - // Set relationship - emp1.setMedicalInsurance(medIns1); - pm.flush(); - - // Postcondition - deferredAssertTrue( - medIns1.getEmployee() == emp1, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - medIns1 = (MedicalInsurance) pm.getObjectById(medIns1Oid); - deferredAssertTrue( - medIns1.getEmployee() == emp1, - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testSetToExistingFromMappedSide() { + testMethod = "testSetToExistingFromMappedSide"; + if (isTestToBePerformed) { + + // Set relationship + medIns1.setEmployee(emp1); + pm.flush(); + + // Postcondition + deferredAssertTrue(emp1.getMedicalInsurance() == medIns1, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + medIns1 = (MedicalInsurance)pm.getObjectById(medIns1Oid); + deferredAssertTrue( + emp1.getMedicalInsurance() == medIns1, + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testSetToNewFromMappedSide() { - testMethod = "testSetToNewFromMappedSide"; - if (isTestToBePerformed) { - - // Set relationship - Employee empNew = - new FullTimeEmployee(99, "Matthew", "", "Adams", new Date(0L), new Date(10000L), 125000); - pm.makePersistent(empNew); - medIns1.setEmployee(empNew); - Object empNewOid = pm.getObjectId((Object) empNew); - pm.flush(); - - // Postcondition - deferredAssertTrue( - empNew.getMedicalInsurance() == medIns1, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - empNew = (Employee) pm.getObjectById(empNewOid); - medIns1 = (MedicalInsurance) pm.getObjectById(medIns1Oid); - deferredAssertTrue( - empNew.getMedicalInsurance() == medIns1, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set in new pm"); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testSetToExistingFromMappedBySide() { + testMethod = "testSetToExistingFromMappedBySide"; + if (isTestToBePerformed) { + + // Set relationship + emp1.setMedicalInsurance(medIns1); + pm.flush(); + + // Postcondition + deferredAssertTrue(medIns1.getEmployee() == emp1, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + medIns1 = (MedicalInsurance)pm.getObjectById(medIns1Oid); + deferredAssertTrue( + medIns1.getEmployee() == emp1, + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testSetToNewFromMappedBySide() { - testMethod = "testSetToNewFromMappedBySide"; - if (isTestToBePerformed) { - - // Set relationship - MedicalInsurance medInsNew = new MedicalInsurance(99L, "Ameriblast", "B"); - pm.makePersistent(medInsNew); - emp1.setMedicalInsurance(medInsNew); - Object medInsNewOid = pm.getObjectId((Object) medInsNew); - pm.flush(); - - // Postcondition - deferredAssertTrue( - medInsNew.getEmployee() == emp1, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush."); - - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - medInsNew = (MedicalInsurance) pm.getObjectById(medInsNewOid); - medIns1 = (MedicalInsurance) pm.getObjectById(medIns1Oid); - deferredAssertTrue( - medInsNew.getEmployee() == emp1, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set in new pm"); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testSetToNewFromMappedSide() { + testMethod = "testSetToNewFromMappedSide"; + if (isTestToBePerformed) { + + // Set relationship + Employee empNew = new FullTimeEmployee(99, "Matthew", "", "Adams", + new Date(0L), new Date(10000L), 125000); + pm.makePersistent(empNew); + medIns1.setEmployee(empNew); + Object empNewOid = pm.getObjectId((Object)empNew); + pm.flush(); + + // Postcondition + deferredAssertTrue(empNew.getMedicalInsurance() == medIns1, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + empNew = (Employee)pm.getObjectById(empNewOid); + medIns1 = (MedicalInsurance)pm.getObjectById(medIns1Oid); + deferredAssertTrue(empNew.getMedicalInsurance() == medIns1, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set in new pm"); + pm.currentTransaction().commit(); + + failOnError(); + } + } + + /** */ + public void testSetToNewFromMappedBySide() { + testMethod = "testSetToNewFromMappedBySide"; + if (isTestToBePerformed) { + + // Set relationship + MedicalInsurance medInsNew = new MedicalInsurance(99L, + "Ameriblast", "B"); + pm.makePersistent(medInsNew); + emp1.setMedicalInsurance(medInsNew); + Object medInsNewOid = pm.getObjectId((Object)medInsNew); + pm.flush(); + + // Postcondition + deferredAssertTrue(medInsNew.getEmployee() == emp1, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush."); + + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + medInsNew = (MedicalInsurance)pm.getObjectById(medInsNewOid); + medIns1 = (MedicalInsurance)pm.getObjectById(medIns1Oid); + deferredAssertTrue(medInsNew.getEmployee() == emp1, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set in new pm"); + pm.currentTransaction().commit(); + + failOnError(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/mapping/Relationship1ToManyAllRelationships.java b/tck/src/main/java/org/apache/jdo/tck/mapping/Relationship1ToManyAllRelationships.java index 153a9e60e..d8fa5e786 100644 --- a/tck/src/main/java/org/apache/jdo/tck/mapping/Relationship1ToManyAllRelationships.java +++ b/tck/src/main/java/org/apache/jdo/tck/mapping/Relationship1ToManyAllRelationships.java @@ -19,452 +19,453 @@ import java.util.Date; import java.util.HashSet; +import java.util.Iterator; import java.util.Set; + +import javax.jdo.JDOHelper; + import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.FullTimeEmployee; import org.apache.jdo.tck.pc.company.IDepartment; +import org.apache.jdo.tck.pc.company.IEmployee; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:Relationship1ToManyAllRelationships
    - * Keywords: mapping, managed relationships
    - * Assertion ID: A15.3-14
    - * Assertion Description: Regardless of which side changes the relationship, flush (whether done - * as part of commit or explicitly by the user) will modify the datastore to reflect the change and - * will update the memory model for consistency... + *Title:Relationship1ToManyAllRelationships + *
    + *Keywords: mapping, managed relationships + *
    + *Assertion ID: A15.3-14 + *
    + *Assertion Description: Regardless of which side changes the relationship, + * flush (whether done as part of commit or explicitly by the user) will modify + * the datastore to reflect the change and will update the memory model + * for consistency... */ -public class Relationship1ToManyAllRelationships extends AbstractRelationshipTest { - - String testMethod = null; - protected String ASSERTION_FAILED = - "Assertion A15-3.14 (Relationship1ToManyAllRelationships) failed: "; - - Object emp1Oid = null; - Object dept1Oid = null; - Object dept2Oid = null; - Employee emp1 = null; - Department dept1 = null; - Department dept2 = null; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Relationship1ToManyAllRelationships.class); - } - - /** - * @see AbstractRelationshipTest#localSetUp() - */ - @Override - protected void localSetUp() { - super.localSetUp(); - if (isTestToBePerformed) { - getPM(); - pm.currentTransaction().begin(); - emp1Oid = getOidByName("emp1"); - dept1Oid = getOidByName("dept1"); - dept2Oid = getOidByName("dept2"); - emp1 = (Employee) pm.getObjectById(emp1Oid); - dept1 = (Department) pm.getObjectById(dept1Oid); - dept2 = (Department) pm.getObjectById(dept2Oid); - - // Preconditions - assertTrue( - ASSERTION_FAILED - + ": Test aborted, precondition is false; " - + "expected emp.getDepartment()to be dept1", - emp1.getDepartment() == dept1); - assertTrue( - ASSERTION_FAILED - + ": Test aborted, precondition is false; " - + "expected dept.getEmployees() to contain emp1", - dept1.getEmployees().contains(emp1)); +public class Relationship1ToManyAllRelationships extends AbstractRelationshipTest { + + String testMethod = null; + protected String ASSERTION_FAILED = + "Assertion A15-3.14 (Relationship1ToManyAllRelationships) failed: "; + + Object emp1Oid = null; + Object dept1Oid = null; + Object dept2Oid = null; + Employee emp1 = null; + Department dept1 = null; + Department dept2 = null; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Relationship1ToManyAllRelationships.class); } - } - - /** */ - public void testSetToExistingFromMappedSide() { - testMethod = "testSetToExistingFromMappedSide"; - if (isTestToBePerformed) { - - // Set relationship - emp1.setDepartment(dept2); - pm.flush(); - - // Postcondition - deferredAssertTrue( - dept2.getEmployees().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - deferredAssertTrue( - !dept1.getEmployees().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; reference emp1 not removed " - + "from previous relationship (dept1.employees)"); - - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - dept1 = (Department) pm.getObjectById(dept1Oid); - dept2 = (Department) pm.getObjectById(dept2Oid); - deferredAssertTrue( - dept2.getEmployees().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set in new pm"); - deferredAssertTrue( - !dept1.getEmployees().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; reference emp1 not removed " - + "from previous relationship (dept1.employees)"); - pm.currentTransaction().commit(); - - failOnError(); + + /** + * @see AbstractRelationshipTest#localSetUp() + */ + @Override + protected void localSetUp() { + super.localSetUp(); + if (isTestToBePerformed) { + getPM(); + pm.currentTransaction().begin(); + + emp1Oid = getOidByName("emp1"); + dept1Oid = getOidByName("dept1"); + dept2Oid = getOidByName("dept2"); + emp1 = (Employee)pm.getObjectById(emp1Oid); + dept1 = (Department)pm.getObjectById(dept1Oid); + dept2 = (Department)pm.getObjectById(dept2Oid); + + // Preconditions + assertTrue(ASSERTION_FAILED + + ": Test aborted, precondition is false; " + + "expected emp.getDepartment()to be dept1", + emp1.getDepartment() == dept1); + assertTrue(ASSERTION_FAILED + + ": Test aborted, precondition is false; " + + "expected dept.getEmployees() to contain emp1", + dept1.getEmployees().contains(emp1)); + } } - } - - /** */ - public void testAddExistingFromMappedbySide() { - testMethod = "testAddExistingFromMappedbySide"; - if (isTestToBePerformed) { - - // Set relationship - Object emp4Oid = getOidByName("emp4"); - Employee emp4 = (Employee) pm.getObjectById(emp4Oid); - Object dept2Oid = getOidByName("dept2"); - Department dept2 = (Department) pm.getObjectById(dept2Oid); - - dept1.addEmployee(emp4); - pm.flush(); - - // Postcondition - deferredAssertTrue( - emp4.getDepartment() == dept1, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - deferredAssertTrue( - !dept2.getEmployees().contains(emp4), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship not unset on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp4 = (Employee) pm.getObjectById(emp4Oid); - dept1 = (Department) pm.getObjectById(dept1Oid); - dept2 = (Department) pm.getObjectById(dept2Oid); - deferredAssertTrue( - emp4.getDepartment() == dept1, - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - deferredAssertTrue( - !dept2.getEmployees().contains(emp4), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship not unset on flush"); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testSetToExistingFromMappedSide() { + testMethod = "testSetToExistingFromMappedSide"; + if (isTestToBePerformed) { + + // Set relationship + emp1.setDepartment(dept2); + pm.flush(); + + // Postcondition + deferredAssertTrue(dept2.getEmployees().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + deferredAssertTrue(!dept1.getEmployees().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; reference emp1 not removed " + + "from previous relationship (dept1.employees)"); + + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + dept1 = (Department)pm.getObjectById(dept1Oid); + dept2 = (Department)pm.getObjectById(dept2Oid); + deferredAssertTrue(dept2.getEmployees().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set in new pm"); + deferredAssertTrue(!dept1.getEmployees().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; reference emp1 not removed " + + "from previous relationship (dept1.employees)"); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testReplaceFromMappedbySide() { - testMethod = "testReplaceFromMappedbySide"; - if (isTestToBePerformed) { - - // Set relationship - Object emp4Oid = getOidByName("emp4"); - Employee emp4 = (Employee) pm.getObjectById(emp4Oid); - Object dept2Oid = getOidByName("dept2"); - Department dept2 = (Department) pm.getObjectById(dept2Oid); - - Set emps = new HashSet(); - emps.add(emp4); - dept1.setEmployees(emps); - pm.flush(); - - // Postcondition - deferredAssertTrue( - emp4.getDepartment() == dept1, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - deferredAssertTrue( - !dept2.getEmployees().contains(emp4), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship not unset on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp4 = (Employee) pm.getObjectById(emp4Oid); - dept1 = (Department) pm.getObjectById(dept1Oid); - dept2 = (Department) pm.getObjectById(dept2Oid); - deferredAssertTrue( - emp4.getDepartment() == dept1, - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - deferredAssertTrue( - !dept2.getEmployees().contains(emp4), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship not unset on flush"); - pm.currentTransaction().commit(); - - failOnError(); + + + /** */ + public void testAddExistingFromMappedbySide() { + testMethod = "testAddExistingFromMappedbySide"; + if (isTestToBePerformed) { + + // Set relationship + Object emp4Oid = getOidByName("emp4"); + Employee emp4 = (Employee)pm.getObjectById(emp4Oid); + Object dept2Oid = getOidByName("dept2"); + Department dept2 = (Department)pm.getObjectById(dept2Oid); + + dept1.addEmployee(emp4); + pm.flush(); + + // Postcondition + deferredAssertTrue(emp4.getDepartment() == dept1, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + deferredAssertTrue(!dept2.getEmployees().contains(emp4), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship not unset on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp4 = (Employee)pm.getObjectById(emp4Oid); + dept1 = (Department)pm.getObjectById(dept1Oid); + dept2 = (Department)pm.getObjectById(dept2Oid); + deferredAssertTrue(emp4.getDepartment() == dept1, + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + deferredAssertTrue(!dept2.getEmployees().contains(emp4), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship not unset on flush"); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testAddNewFromMappedbySide() { - testMethod = "testAddNewFromMappedbySide"; - if (isTestToBePerformed) { - - // Set relationship - Employee empNew = - new FullTimeEmployee( - 101, "Jenny", "Merriwether", "White", new Date(500L), new Date(10000L), 135000); - pm.makePersistent(empNew); - Object empNewOid = pm.getObjectId((Object) empNew); - - dept1.addEmployee(empNew); - pm.flush(); - // Postcondition - deferredAssertTrue( - empNew.getDepartment() == dept1, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - empNew = (Employee) pm.getObjectById(empNewOid); - dept1 = (Department) pm.getObjectById(dept1Oid); - deferredAssertTrue( - empNew.getDepartment() == dept1, - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + /** */ + public void testReplaceFromMappedbySide() { + testMethod = "testReplaceFromMappedbySide"; + if (isTestToBePerformed) { + + // Set relationship + Object emp4Oid = getOidByName("emp4"); + Employee emp4 = (Employee)pm.getObjectById(emp4Oid); + Object dept2Oid = getOidByName("dept2"); + Department dept2 = (Department)pm.getObjectById(dept2Oid); + + Set emps = new HashSet(); + emps.add(emp4); + dept1.setEmployees(emps); + pm.flush(); + + // Postcondition + deferredAssertTrue(emp4.getDepartment() == dept1, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + deferredAssertTrue(!dept2.getEmployees().contains(emp4), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship not unset on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp4 = (Employee)pm.getObjectById(emp4Oid); + dept1 = (Department)pm.getObjectById(dept1Oid); + dept2 = (Department)pm.getObjectById(dept2Oid); + deferredAssertTrue(emp4.getDepartment() == dept1, + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + deferredAssertTrue(!dept2.getEmployees().contains(emp4), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship not unset on flush"); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testSetToNullFromMappedSide() { - testMethod = "testSetToNullFromMappedSide"; - if (isTestToBePerformed) { - // Set relationship - emp1.setDepartment(null); - pm.flush(); - - // Postcondition - deferredAssertTrue( - !dept1.getEmployees().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - dept1 = (Department) pm.getObjectById(dept1Oid); - deferredAssertTrue( - !dept1.getEmployees().contains(emp1), - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + /** */ + public void testAddNewFromMappedbySide() { + testMethod = "testAddNewFromMappedbySide"; + if (isTestToBePerformed) { + + // Set relationship + Employee empNew = new FullTimeEmployee(101, "Jenny", "Merriwether", + "White", new Date(500L), new Date(10000L), 135000); + pm.makePersistent(empNew); + Object empNewOid = pm.getObjectId((Object)empNew); + + dept1.addEmployee(empNew); + pm.flush(); + + // Postcondition + deferredAssertTrue(empNew.getDepartment() == dept1, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + empNew = (Employee)pm.getObjectById(empNewOid); + dept1 = (Department)pm.getObjectById(dept1Oid); + deferredAssertTrue(empNew.getDepartment() == dept1, + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testSetToNullFromMappedbySide() { - testMethod = "testSetToNullFromMappedbySide"; - if (isTestToBePerformed) { - - // Set relationship - dept1.setEmployees(null); - pm.flush(); - - // Postcondition - deferredAssertTrue( - emp1.getDepartment() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - deferredAssertTrue( - emp1.getDepartment() == null, - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + /** */ + public void testSetToNullFromMappedSide() { + testMethod = "testSetToNullFromMappedSide"; + if (isTestToBePerformed) { + // Set relationship + emp1.setDepartment(null); + pm.flush(); + + // Postcondition + deferredAssertTrue(!dept1.getEmployees().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + dept1 = (Department)pm.getObjectById(dept1Oid); + deferredAssertTrue( + !dept1.getEmployees().contains(emp1), + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testSetToNewFromMappedSide() { - testMethod = "testSetToNewFromMappedSide"; - if (isTestToBePerformed) { - - // Set relationship - IDepartment deptNew = new Department(99L, "The New Department"); - pm.makePersistent(deptNew); - emp1.setDepartment(deptNew); - Object deptNewOid = pm.getObjectId((Object) deptNew); - pm.flush(); - - assertFalse( - testMethod - + ": Test aborted, precondition is false; " - + "expected deptNewOid to be non-null", - deptNewOid == null); - - // Postcondition - deferredAssertTrue( - deptNew.getEmployees().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - deferredAssertTrue( - !dept1.getEmployees().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship (dept1) not nulled on flush"); - - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - deptNew = (Department) pm.getObjectById(deptNewOid); - dept1 = (Department) pm.getObjectById(dept1Oid); - deferredAssertTrue( - deptNew.getEmployees().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set in new pm"); - deferredAssertTrue( - !dept1.getEmployees().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship (dept1) not nulled in new pm"); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testSetToNullFromMappedbySide() { + testMethod = "testSetToNullFromMappedbySide"; + if (isTestToBePerformed) { + + // Set relationship + dept1.setEmployees(null); + pm.flush(); + + // Postcondition + deferredAssertTrue(emp1.getDepartment() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + deferredAssertTrue( + emp1.getDepartment() == null, + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testRemoveFromMappedbySide() { - testMethod = "testRemoveFromMappedbySide"; - if (isTestToBePerformed) { - - // Set relationship - dept1.removeEmployee(emp1); - pm.flush(); - - // Postcondition - deferredAssertTrue( - emp1.getDepartment() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - deferredAssertTrue( - emp1.getDepartment() == null, - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testSetToNewFromMappedSide() { + testMethod = "testSetToNewFromMappedSide"; + if (isTestToBePerformed) { + + // Set relationship + IDepartment deptNew = new Department(99L, "The New Department"); + pm.makePersistent(deptNew); + emp1.setDepartment(deptNew); + Object deptNewOid = pm.getObjectId((Object)deptNew); + pm.flush(); + + assertFalse(testMethod + ": Test aborted, precondition is false; " + + "expected deptNewOid to be non-null", deptNewOid == null); + + // Postcondition + deferredAssertTrue(deptNew.getEmployees().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + deferredAssertTrue(!dept1.getEmployees().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship (dept1) not nulled on flush"); + + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + deptNew = (Department)pm.getObjectById(deptNewOid); + dept1 = (Department)pm.getObjectById(dept1Oid); + deferredAssertTrue(deptNew.getEmployees().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set in new pm"); + deferredAssertTrue(!dept1.getEmployees().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship (dept1) not nulled in new pm"); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testDeleteFromMappedSide() { - testMethod = "testDeleteFromMappedSide"; - if (isTestToBePerformed) { - // remember id - long emp1Id = emp1.getPersonid(); - // Set relationship - pm.deletePersistent(emp1); - pm.flush(); - - // Postcondition - deferredAssertTrue( - !containsEmployee(dept1.getEmployees(), emp1Id), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - dept1 = (Department) pm.getObjectById(dept1Oid); - deferredAssertTrue( - !containsEmployee(dept1.getEmployees(), emp1Id), - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testRemoveFromMappedbySide() { + testMethod = "testRemoveFromMappedbySide"; + if (isTestToBePerformed) { + + // Set relationship + dept1.removeEmployee(emp1); + pm.flush(); + + // Postcondition + deferredAssertTrue(emp1.getDepartment() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + deferredAssertTrue( + emp1.getDepartment() == null, + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testDeleteFromMappedbySide() { - testMethod = "testDeleteFromMappedbySide"; - if (isTestToBePerformed) { - - // Set relationship - pm.deletePersistent(dept1); - pm.flush(); - - // Postcondition - deferredAssertTrue( - emp1.getDepartment() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - deferredAssertTrue( - emp1.getDepartment() == null, - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testDeleteFromMappedSide() { + testMethod = "testDeleteFromMappedSide"; + if (isTestToBePerformed) { + // remember id + long emp1Id = emp1.getPersonid(); + // Set relationship + pm.deletePersistent(emp1); + pm.flush(); + + // Postcondition + deferredAssertTrue(!containsEmployee(dept1.getEmployees(), emp1Id), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + dept1 = (Department)pm.getObjectById(dept1Oid); + deferredAssertTrue( + !containsEmployee(dept1.getEmployees(), emp1Id), + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } + } + + /** */ + public void testDeleteFromMappedbySide() { + testMethod = "testDeleteFromMappedbySide"; + if (isTestToBePerformed) { + + // Set relationship + pm.deletePersistent(dept1); + pm.flush(); + + // Postcondition + deferredAssertTrue(emp1.getDepartment() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + deferredAssertTrue( + emp1.getDepartment() == null, + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/mapping/Relationship1ToManyNoRelationships.java b/tck/src/main/java/org/apache/jdo/tck/mapping/Relationship1ToManyNoRelationships.java index e15c48a2f..72a0228ae 100644 --- a/tck/src/main/java/org/apache/jdo/tck/mapping/Relationship1ToManyNoRelationships.java +++ b/tck/src/main/java/org/apache/jdo/tck/mapping/Relationship1ToManyNoRelationships.java @@ -25,228 +25,227 @@ import org.apache.jdo.tck.pc.company.FullTimeEmployee; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:Relationship1ToManyNoRelationships
    - * Keywords: mapping, managed relationships
    - * Assertion ID: A15.3-14
    - * Assertion Description: Regardless of which side changes the relationship, flush (whether done - * as part of commit or explicitly by the user) will modify the datastore to reflect the change and - * will update the memory model for consistency... + *Title:Relationship1ToManyNoRelationships + *
    + *Keywords: mapping, managed relationships + *
    + *Assertion ID: A15.3-14 + *
    + *Assertion Description: Regardless of which side changes the relationship, + * flush (whether done as part of commit or explicitly by the user) will modify + * the datastore to reflect the change and will update the memory model + * for consistency... */ -public class Relationship1ToManyNoRelationships extends AbstractRelationshipTest { - - String testMethod = null; - protected String ASSERTION_FAILED = - "Assertion A15-3.14 (Relationship1ToManyNoRelationships) failed: "; - - Object emp1Oid = null; - Object dept1Oid = null; - Object dept2Oid = null; - Employee emp1 = null; - Department dept1 = null; - Department dept2 = null; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Relationship1ToManyNoRelationships.class); - } - - /** - * @see AbstractRelationshipTest#localSetUp() - */ - @Override - protected void localSetUp() { - super.localSetUp(); - if (isTestToBePerformed) { - getPM(); - pm.currentTransaction().begin(); - - emp1Oid = getOidByName("emp1"); - dept1Oid = getOidByName("dept1"); - dept2Oid = getOidByName("dept2"); - emp1 = (Employee) pm.getObjectById(emp1Oid); - dept1 = (Department) pm.getObjectById(dept1Oid); - dept2 = (Department) pm.getObjectById(dept2Oid); - - // Preconditions - assertTrue( - ASSERTION_FAILED - + ": Test aborted, precondition is false; " - + "expected emp.getDepartment()to be null", - emp1.getDepartment() == null); - assertTrue( - ASSERTION_FAILED - + testMethod - + ": Test aborted, precondition is false; " - + "expected dept.getEmployees() to be empty", - dept1.getEmployees().isEmpty()); +public class Relationship1ToManyNoRelationships extends AbstractRelationshipTest { + + String testMethod = null; + protected String ASSERTION_FAILED = + "Assertion A15-3.14 (Relationship1ToManyNoRelationships) failed: "; + + Object emp1Oid = null; + Object dept1Oid = null; + Object dept2Oid = null; + Employee emp1 = null; + Department dept1 = null; + Department dept2 = null; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Relationship1ToManyNoRelationships.class); } - } - - /** */ - public void testSetToExistingFromMappedSide() { - testMethod = "testSetToExistingFromMappedSide"; - if (isTestToBePerformed) { - - // Set relationship - emp1.setDepartment(dept1); - pm.flush(); - - // Postcondition - deferredAssertTrue( - dept1.getEmployees().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - dept1 = (Department) pm.getObjectById(dept1Oid); - deferredAssertTrue( - dept1.getEmployees().contains(emp1), - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + + /** + * @see AbstractRelationshipTest#localSetUp() + */ + @Override + protected void localSetUp() { + super.localSetUp(); + if (isTestToBePerformed) { + getPM(); + pm.currentTransaction().begin(); + + emp1Oid = getOidByName("emp1"); + dept1Oid = getOidByName("dept1"); + dept2Oid = getOidByName("dept2"); + emp1 = (Employee)pm.getObjectById(emp1Oid); + dept1 = (Department)pm.getObjectById(dept1Oid); + dept2 = (Department)pm.getObjectById(dept2Oid); + + // Preconditions + assertTrue(ASSERTION_FAILED + + ": Test aborted, precondition is false; " + + "expected emp.getDepartment()to be null", + emp1.getDepartment() == null); + assertTrue(ASSERTION_FAILED + testMethod + + ": Test aborted, precondition is false; " + + "expected dept.getEmployees() to be empty", + dept1.getEmployees().isEmpty()); + } } - } - - /** */ - public void testAddExistingFromMappedbySide() { - testMethod = "testSetToExistingFromMappedbySide"; - if (isTestToBePerformed) { - - // Set relationship - Set emps = new HashSet(); - emps.add(emp1); - dept1.setEmployees(emps); - pm.flush(); - - // Postcondition - deferredAssertTrue( - emp1.getDepartment() == dept1, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - dept1 = (Department) pm.getObjectById(dept1Oid); - deferredAssertTrue( - emp1.getDepartment() == dept1, - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testSetToExistingFromMappedSide() { + testMethod = "testSetToExistingFromMappedSide"; + if (isTestToBePerformed) { + + // Set relationship + emp1.setDepartment(dept1); + pm.flush(); + + // Postcondition + deferredAssertTrue(dept1.getEmployees().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + dept1 = (Department)pm.getObjectById(dept1Oid); + deferredAssertTrue( + dept1.getEmployees().contains(emp1), + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testSetToNewFromMappedSide() { - testMethod = "testSetToNewFromMappedSide"; - if (isTestToBePerformed) { - - // Set relationship - Department deptNew = new Department(99L, "The New Department"); - emp1.setDepartment(deptNew); - pm.makePersistent(deptNew); - Object deptNewOid = pm.getObjectId((Object) deptNew); - pm.flush(); - - assertFalse( - testMethod - + ": Test aborted, precondition is false; " - + "expected deptNewOid to be non-null", - deptNewOid == null); - - // Postcondition - deferredAssertTrue( - deptNew.getEmployees().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - deferredAssertTrue( - !dept1.getEmployees().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship (dept1) not nulled on flush"); - - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - deptNew = (Department) pm.getObjectById(deptNewOid); - dept1 = (Department) pm.getObjectById(dept1Oid); - deferredAssertTrue( - deptNew.getEmployees().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set in new pm"); - deferredAssertTrue( - !dept1.getEmployees().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship (dept1) not nulled in new pm"); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testAddExistingFromMappedbySide() { + testMethod = "testSetToExistingFromMappedbySide"; + if (isTestToBePerformed) { + + // Set relationship + Set emps = new HashSet(); + emps.add(emp1); + dept1.setEmployees(emps); + pm.flush(); + + // Postcondition + deferredAssertTrue(emp1.getDepartment() == dept1, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + dept1 = (Department)pm.getObjectById(dept1Oid); + deferredAssertTrue( + emp1.getDepartment() == dept1, + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testSetToNewFromMappedbySide() { - testMethod = "testSetToNewFromMappedbySide"; - if (isTestToBePerformed) { - - // Set relationship - Set emps = new HashSet(); - Employee empNew = - new FullTimeEmployee( - 101, "Jenny", "Merriwether", "White", new Date(500L), new Date(10000L), 135000); - pm.makePersistent(empNew); - emps.add(empNew); - dept1.setEmployees(emps); - Object empNewOid = pm.getObjectId((Object) empNew); - pm.flush(); - - // Postcondition - deferredAssertTrue( - empNew.getDepartment() == dept1, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - deferredAssertTrue( - emp1.getDepartment() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship not nulled on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - empNew = (Employee) pm.getObjectById(empNewOid); - emp1 = (Employee) pm.getObjectById(emp1Oid); - dept1 = (Department) pm.getObjectById(dept1Oid); - deferredAssertTrue( - empNew.getDepartment() == dept1, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set in new pm"); - deferredAssertTrue( - emp1.getDepartment() == null, - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "previous relationship not nulled in new pm"); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testSetToNewFromMappedSide() { + testMethod = "testSetToNewFromMappedSide"; + if (isTestToBePerformed) { + + // Set relationship + Department deptNew = new Department(99L, "The New Department"); + emp1.setDepartment(deptNew); + pm.makePersistent(deptNew); + Object deptNewOid = pm.getObjectId((Object)deptNew); + pm.flush(); + + assertFalse(testMethod + ": Test aborted, precondition is false; " + + "expected deptNewOid to be non-null", deptNewOid == null); + + // Postcondition + deferredAssertTrue(deptNew.getEmployees().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + deferredAssertTrue(!dept1.getEmployees().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship (dept1) not nulled on flush"); + + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + deptNew = (Department)pm.getObjectById(deptNewOid); + dept1 = (Department)pm.getObjectById(dept1Oid); + deferredAssertTrue(deptNew.getEmployees().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set in new pm"); + deferredAssertTrue(!dept1.getEmployees().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship (dept1) not nulled in new pm"); + pm.currentTransaction().commit(); + + failOnError(); + } + } + + /** */ + public void testSetToNewFromMappedbySide() { + testMethod = "testSetToNewFromMappedbySide"; + if (isTestToBePerformed) { + + // Set relationship + Set emps = new HashSet(); + Employee empNew = new FullTimeEmployee(101, "Jenny", "Merriwether", + "White", new Date(500L), new Date(10000L), 135000); + pm.makePersistent(empNew); + emps.add(empNew); + dept1.setEmployees(emps); + Object empNewOid = pm.getObjectId((Object)empNew); + pm.flush(); + + // Postcondition + deferredAssertTrue(empNew.getDepartment() == dept1, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + deferredAssertTrue(emp1.getDepartment() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship not nulled on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + empNew = (Employee)pm.getObjectById(empNewOid); + emp1 = (Employee)pm.getObjectById(emp1Oid); + dept1 = (Department)pm.getObjectById(dept1Oid); + deferredAssertTrue(empNew.getDepartment() == dept1, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set in new pm"); + deferredAssertTrue(emp1.getDepartment() == null, + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "previous relationship not nulled in new pm"); + pm.currentTransaction().commit(); + + failOnError(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/mapping/RelationshipManyToManyAllRelationships.java b/tck/src/main/java/org/apache/jdo/tck/mapping/RelationshipManyToManyAllRelationships.java index 8fd28509d..83bf55919 100644 --- a/tck/src/main/java/org/apache/jdo/tck/mapping/RelationshipManyToManyAllRelationships.java +++ b/tck/src/main/java/org/apache/jdo/tck/mapping/RelationshipManyToManyAllRelationships.java @@ -28,469 +28,474 @@ import org.apache.jdo.tck.pc.company.Project; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:RelationshipManyToManyAllRelationships
    - * Keywords: mapping, managed relationships
    - * Assertion ID: A15.3-14
    - * Assertion Description: Regardless of which side changes the relationship, flush (whether done - * as part of commit or explicitly by the user) will modify the datastore to reflect the change and - * will update the memory model for consistency... + *Title:RelationshipManyToManyAllRelationships + *
    + *Keywords: mapping, managed relationships + *
    + *Assertion ID: A15.3-14 + *
    + *Assertion Description: Regardless of which side changes the relationship, + * flush (whether done as part of commit or explicitly by the user) will modify + * the datastore to reflect the change and will update the memory model + * for consistency... */ -public class RelationshipManyToManyAllRelationships extends AbstractRelationshipTest { - - String testMethod = null; - protected String ASSERTION_FAILED = - "Assertion A15-3.14 (RelationshipManyToManyAllRelationships) failed: "; - - Object emp1Oid = null; - Object proj1Oid = null; - Employee emp1 = null; - Project proj1 = null; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(RelationshipManyToManyAllRelationships.class); - } - /** - * @see AbstractRelationshipTest#localSetUp() - */ - @Override - protected void localSetUp() { - super.localSetUp(); - if (isTestToBePerformed) { - - getPM(); - pm.currentTransaction().begin(); - - emp1Oid = getOidByName("emp1"); - proj1Oid = getOidByName("proj1"); - emp1 = (Employee) pm.getObjectById(emp1Oid); - proj1 = (Project) pm.getObjectById(proj1Oid); - - // Preconditions - assertTrue( - testMethod - + ": Test aborted, precondition is false; " - + "expected emp.getProjects()to be contain proj1", - emp1.getProjects().contains(proj1)); - assertTrue( - testMethod - + ": Test aborted, precondition is false; " - + "expected proj.getMembers() to contain emp1", - proj1.getMembers().contains(emp1)); +public class RelationshipManyToManyAllRelationships + extends AbstractRelationshipTest { + + String testMethod = null; + protected String ASSERTION_FAILED = + "Assertion A15-3.14 (RelationshipManyToManyAllRelationships) failed: "; + + Object emp1Oid = null; + Object proj1Oid = null; + Employee emp1 = null; + Project proj1 = null; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(RelationshipManyToManyAllRelationships.class); } - } - - /** */ - public void testSetToNullFromMappedSide() { - testMethod = "testSetToNullFromMappedSide"; - if (isTestToBePerformed) { - - // Set relationship - proj1.setMembers(null); - pm.flush(); - - // Postcondition - deferredAssertTrue( - !emp1.getProjects().contains(proj1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - proj1 = (Project) pm.getObjectById(proj1Oid); - deferredAssertTrue( - !emp1.getProjects().contains(proj1), - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + + /** + * @see AbstractRelationshipTest#localSetUp() + */ + @Override + protected void localSetUp() { + super.localSetUp(); + if (isTestToBePerformed) { + + getPM(); + pm.currentTransaction().begin(); + + emp1Oid = getOidByName("emp1"); + proj1Oid = getOidByName("proj1"); + emp1 = (Employee)pm.getObjectById(emp1Oid); + proj1 = (Project)pm.getObjectById(proj1Oid); + + // Preconditions + assertTrue(testMethod + + ": Test aborted, precondition is false; " + + "expected emp.getProjects()to be contain proj1", + emp1.getProjects().contains(proj1)); + assertTrue(testMethod + + ": Test aborted, precondition is false; " + + "expected proj.getMembers() to contain emp1", + proj1.getMembers().contains(emp1)); + } } - } - - /** */ - public void testSetToNullFromMappedbySide() { - testMethod = "testSetToNullFromMappedbySide"; - if (isTestToBePerformed) { - // Set relationship - emp1.setProjects(null); - pm.flush(); - - // Postcondition - deferredAssertTrue( - !proj1.getMembers().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - proj1 = (Project) pm.getObjectById(proj1Oid); - deferredAssertTrue( - !proj1.getMembers().contains(emp1), - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testSetToNullFromMappedSide() { + testMethod = "testSetToNullFromMappedSide"; + if (isTestToBePerformed) { + + // Set relationship + proj1.setMembers(null); + pm.flush(); + + // Postcondition + deferredAssertTrue(!emp1.getProjects().contains(proj1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + proj1 = (Project)pm.getObjectById(proj1Oid); + deferredAssertTrue( + !emp1.getProjects().contains(proj1), + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testReplaceFromMappedSide() { - testMethod = "testReplaceFromMappedSide"; - if (isTestToBePerformed) { - - // Set relationship - IEmployee empNew = - new FullTimeEmployee( - 100, "Jerry", "Valentine", "Brown", new Date(500L), new Date(10000L), 125000); - pm.makePersistent(empNew); - Set members = new HashSet(); - members.add(empNew); - proj1.setMembers(members); - Object empNewOid = pm.getObjectId((Object) empNew); - pm.flush(); - - // Postcondition - - deferredAssertTrue( - empNew.getProjects().contains(proj1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - empNew = (IEmployee) pm.getObjectById(empNewOid); - emp1 = (Employee) pm.getObjectById(emp1Oid); - proj1 = (Project) pm.getObjectById(proj1Oid); - deferredAssertTrue( - empNew.getProjects().contains(proj1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set in new pm"); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testSetToNullFromMappedbySide() { + testMethod = "testSetToNullFromMappedbySide"; + if (isTestToBePerformed) { + // Set relationship + emp1.setProjects(null); + pm.flush(); + + // Postcondition + deferredAssertTrue(!proj1.getMembers().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + proj1 = (Project)pm.getObjectById(proj1Oid); + deferredAssertTrue( + !proj1.getMembers().contains(emp1), + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testReplaceFromMappedbySide() { - testMethod = "testReplaceFromMappedbySide"; - if (isTestToBePerformed) { - - // Set relationship - IProject projNew = new Project(99L, "Skunkworks", new BigDecimal(10000.35)); - pm.makePersistent(projNew); - Set projects = new HashSet(); - projects.add(projNew); - emp1.setProjects(projects); - Object projNewOid = pm.getObjectId((Object) projNew); - pm.flush(); - // Postcondition - deferredAssertTrue( - projNew.getMembers().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - projNew = (Project) pm.getObjectById(projNewOid); - proj1 = (Project) pm.getObjectById(proj1Oid); - deferredAssertTrue( - projNew.getMembers().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set in new pm"); - pm.currentTransaction().commit(); - - failOnError(); + /** */ + public void testReplaceFromMappedSide() { + testMethod = "testReplaceFromMappedSide"; + if (isTestToBePerformed) { + + // Set relationship + IEmployee empNew = new FullTimeEmployee(100, "Jerry", "Valentine", + "Brown", new Date(500L), new Date(10000L), 125000); + pm.makePersistent(empNew); + Set members = new HashSet(); + members.add(empNew); + proj1.setMembers(members); + Object empNewOid = pm.getObjectId((Object)empNew); + pm.flush(); + + // Postcondition + + deferredAssertTrue(empNew.getProjects().contains(proj1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + empNew = (IEmployee)pm.getObjectById(empNewOid); + emp1 = (Employee)pm.getObjectById(emp1Oid); + proj1 = (Project)pm.getObjectById(proj1Oid); + deferredAssertTrue(empNew.getProjects().contains(proj1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set in new pm"); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testAddNewFromMappedSide() { - testMethod = "testAddNewFromMappedSide"; - if (isTestToBePerformed) { - - // Set relationship - Employee empNew = - new FullTimeEmployee( - 100, "Jerry", "Valentine", "Brown", new Date(500L), new Date(10000L), 125000); - pm.makePersistent(empNew); - proj1.addMember(empNew); - Object empNewOid = pm.getObjectId((Object) empNew); - pm.flush(); - - // Postcondition - - deferredAssertTrue( - empNew.getProjects().contains(proj1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - empNew = (Employee) pm.getObjectById(empNewOid); - emp1 = (Employee) pm.getObjectById(emp1Oid); - proj1 = (Project) pm.getObjectById(proj1Oid); - deferredAssertTrue( - empNew.getProjects().contains(proj1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set in new pm"); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testReplaceFromMappedbySide() { + testMethod = "testReplaceFromMappedbySide"; + if (isTestToBePerformed) { + + // Set relationship + IProject projNew = new Project(99L, "Skunkworks", + new BigDecimal(10000.35)); + pm.makePersistent(projNew); + Set projects = new HashSet(); + projects.add(projNew); + emp1.setProjects(projects); + Object projNewOid = pm.getObjectId((Object)projNew); + pm.flush(); + + // Postcondition + deferredAssertTrue(projNew.getMembers().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + projNew = (Project)pm.getObjectById(projNewOid); + proj1 = (Project)pm.getObjectById(proj1Oid); + deferredAssertTrue(projNew.getMembers().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set in new pm"); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - /** */ - public void testAddNewFromMappedbySide() { - testMethod = "testAddNewFromMappedbySide"; - if (isTestToBePerformed) { - - // Set relationship - Project projNew = new Project(99L, "Skunkworks", new BigDecimal(10000.35)); - pm.makePersistent(projNew); - emp1.addProject(projNew); - Object projNewOid = pm.getObjectId((Object) projNew); - pm.flush(); - - // Postcondition - deferredAssertTrue( - projNew.getMembers().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - projNew = (Project) pm.getObjectById(projNewOid); - proj1 = (Project) pm.getObjectById(proj1Oid); - deferredAssertTrue( - projNew.getMembers().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set in new pm"); - pm.currentTransaction().commit(); - - failOnError(); + /** */ + public void testAddNewFromMappedSide() { + testMethod = "testAddNewFromMappedSide"; + if (isTestToBePerformed) { + + // Set relationship + Employee empNew = new FullTimeEmployee(100, "Jerry", "Valentine", + "Brown", new Date(500L), new Date(10000L), 125000); + pm.makePersistent(empNew); + proj1.addMember(empNew); + Object empNewOid = pm.getObjectId((Object)empNew); + pm.flush(); + + // Postcondition + + deferredAssertTrue(empNew.getProjects().contains(proj1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + empNew = (Employee)pm.getObjectById(empNewOid); + emp1 = (Employee)pm.getObjectById(emp1Oid); + proj1 = (Project)pm.getObjectById(proj1Oid); + deferredAssertTrue(empNew.getProjects().contains(proj1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set in new pm"); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - /** */ - public void testAddExistingFromMappedSide() { - testMethod = "testAddExistingFromMappedSide"; - if (isTestToBePerformed) { - - // Set relationship - Object emp4Oid = getOidByName("emp4"); - Employee emp4 = (Employee) pm.getObjectById(emp4Oid); - proj1.addMember(emp4); - pm.flush(); - - // Postcondition - - deferredAssertTrue( - emp4.getProjects().contains(proj1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp4 = (Employee) pm.getObjectById(emp4Oid); - emp1 = (Employee) pm.getObjectById(emp1Oid); - proj1 = (Project) pm.getObjectById(proj1Oid); - deferredAssertTrue( - emp4.getProjects().contains(proj1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set in new pm"); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testAddNewFromMappedbySide() { + testMethod = "testAddNewFromMappedbySide"; + if (isTestToBePerformed) { + + // Set relationship + Project projNew = new Project(99L, "Skunkworks", + new BigDecimal(10000.35)); + pm.makePersistent(projNew); + emp1.addProject(projNew); + Object projNewOid = pm.getObjectId((Object)projNew); + pm.flush(); + + // Postcondition + deferredAssertTrue(projNew.getMembers().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + projNew = (Project)pm.getObjectById(projNewOid); + proj1 = (Project)pm.getObjectById(proj1Oid); + deferredAssertTrue(projNew.getMembers().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set in new pm"); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testAddExistingFromMappedbySide() { - testMethod = "testAddExistingFromMappedbySide"; - if (isTestToBePerformed) { - - // Set relationship - Object proj2Oid = getOidByName("proj2"); - Project proj2 = (Project) pm.getObjectById(proj2Oid); - emp1.addProject(proj2); - pm.flush(); - - // Postcondition - deferredAssertTrue( - proj2.getMembers().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - proj2 = (Project) pm.getObjectById(proj2Oid); - proj1 = (Project) pm.getObjectById(proj1Oid); - deferredAssertTrue( - proj2.getMembers().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set in new pm"); - pm.currentTransaction().commit(); - - failOnError(); + /** */ + public void testAddExistingFromMappedSide() { + testMethod = "testAddExistingFromMappedSide"; + if (isTestToBePerformed) { + + // Set relationship + Object emp4Oid = getOidByName("emp4"); + Employee emp4 = (Employee)pm.getObjectById(emp4Oid); + proj1.addMember(emp4); + pm.flush(); + + // Postcondition + + deferredAssertTrue(emp4.getProjects().contains(proj1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp4 = (Employee)pm.getObjectById(emp4Oid); + emp1 = (Employee)pm.getObjectById(emp1Oid); + proj1 = (Project)pm.getObjectById(proj1Oid); + deferredAssertTrue(emp4.getProjects().contains(proj1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set in new pm"); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testRemoveFromMappedSide() { - testMethod = "testRemoveFromMappedSide"; - if (isTestToBePerformed) { - - // Set relationship - proj1.removeMember(emp1); - pm.flush(); - - // Postcondition - deferredAssertTrue( - !emp1.getProjects().contains(proj1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - proj1 = (Project) pm.getObjectById(proj1Oid); - deferredAssertTrue( - !emp1.getProjects().contains(proj1), - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testAddExistingFromMappedbySide() { + testMethod = "testAddExistingFromMappedbySide"; + if (isTestToBePerformed) { + + // Set relationship + Object proj2Oid = getOidByName("proj2"); + Project proj2 = (Project)pm.getObjectById(proj2Oid); + emp1.addProject(proj2); + pm.flush(); + + // Postcondition + deferredAssertTrue(proj2.getMembers().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + proj2 = (Project)pm.getObjectById(proj2Oid); + proj1 = (Project)pm.getObjectById(proj1Oid); + deferredAssertTrue(proj2.getMembers().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set in new pm"); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testRemoveFromMappedbySide() { - testMethod = "testRemoveFromMappedbySide"; - if (isTestToBePerformed) { - // Set relationship - emp1.removeProject(proj1); - pm.flush(); - - // Postcondition - deferredAssertTrue( - !proj1.getMembers().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - proj1 = (Project) pm.getObjectById(proj1Oid); - deferredAssertTrue( - !proj1.getMembers().contains(emp1), - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + /** */ + public void testRemoveFromMappedSide() { + testMethod = "testRemoveFromMappedSide"; + if (isTestToBePerformed) { + + // Set relationship + proj1.removeMember(emp1); + pm.flush(); + + // Postcondition + deferredAssertTrue(!emp1.getProjects().contains(proj1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + proj1 = (Project)pm.getObjectById(proj1Oid); + deferredAssertTrue( + !emp1.getProjects().contains(proj1), + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } + } + + /** */ + public void testRemoveFromMappedbySide() { + testMethod = "testRemoveFromMappedbySide"; + if (isTestToBePerformed) { + + // Set relationship + emp1.removeProject(proj1); + pm.flush(); + + // Postcondition + deferredAssertTrue(!proj1.getMembers().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + proj1 = (Project)pm.getObjectById(proj1Oid); + deferredAssertTrue( + !proj1.getMembers().contains(emp1), + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - /** */ - public void testDeleteFromMappedSide() { + /** */ + public void testDeleteFromMappedSide() { testMethod = "testDeleteFromMappedSide"; - if (isTestToBePerformed) { - // remember id - long proj1Id = proj1.getProjid(); - // Set relationship - pm.deletePersistent(proj1); - pm.flush(); - - // Postcondition - deferredAssertTrue( - !containsProject(emp1.getProjects(), proj1Id), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - deferredAssertTrue( - !containsProject(emp1.getProjects(), proj1Id), - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + if (isTestToBePerformed) { + // remember id + long proj1Id = proj1.getProjid(); + // Set relationship + pm.deletePersistent(proj1); + pm.flush(); + + // Postcondition + deferredAssertTrue(!containsProject(emp1.getProjects(), proj1Id), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + deferredAssertTrue( + !containsProject(emp1.getProjects(), proj1Id), + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testDeleteFromMappedbySide() { - testMethod = "testDeleteFromMappedbySide"; - if (isTestToBePerformed) { - // remember id - long emp1Id = emp1.getPersonid(); - // Set relationship - pm.deletePersistent(emp1); - pm.flush(); - - // Postcondition - deferredAssertTrue( - !containsEmployee(proj1.getMembers(), emp1Id), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - proj1 = (Project) pm.getObjectById(proj1Oid); - deferredAssertTrue( - !containsEmployee(proj1.getMembers(), emp1Id), - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testDeleteFromMappedbySide() { + testMethod = "testDeleteFromMappedbySide"; + if (isTestToBePerformed) { + // remember id + long emp1Id = emp1.getPersonid(); + // Set relationship + pm.deletePersistent(emp1); + pm.flush(); + + // Postcondition + deferredAssertTrue(!containsEmployee(proj1.getMembers(), emp1Id), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + proj1 = (Project)pm.getObjectById(proj1Oid); + deferredAssertTrue( + !containsEmployee(proj1.getMembers(), emp1Id), + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/mapping/RelationshipManyToManyNoRelationships.java b/tck/src/main/java/org/apache/jdo/tck/mapping/RelationshipManyToManyNoRelationships.java index 02fc17cf2..7a5a0eb11 100644 --- a/tck/src/main/java/org/apache/jdo/tck/mapping/RelationshipManyToManyNoRelationships.java +++ b/tck/src/main/java/org/apache/jdo/tck/mapping/RelationshipManyToManyNoRelationships.java @@ -26,217 +26,216 @@ import org.apache.jdo.tck.pc.company.Project; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:RelationshipManyToManyNoRelationships
    - * Keywords: mapping, managed relationships
    - * Assertion ID: A15.3-14
    - * Assertion Description: Regardless of which side changes the relationship, flush (whether done - * as part of commit or explicitly by the user) will modify the datastore to reflect the change and - * will update the memory model for consistency... + *Title:RelationshipManyToManyNoRelationships + *
    + *Keywords: mapping, managed relationships + *
    + *Assertion ID: A15.3-14 + *
    + *Assertion Description: Regardless of which side changes the relationship, + * flush (whether done as part of commit or explicitly by the user) will modify + * the datastore to reflect the change and will update the memory model + * for consistency... */ -public class RelationshipManyToManyNoRelationships extends AbstractRelationshipTest { - - String testMethod = null; - protected String ASSERTION_FAILED = - "Assertion A15-3.14 (RelationshipManyToManyNoRelationships) failed: "; - - Object emp1Oid = null; - Object proj1Oid = null; - Employee emp1 = null; - Project proj1 = null; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(RelationshipManyToManyNoRelationships.class); - } - /** - * @see AbstractRelationshipTest#localSetUp() - */ - @Override - protected void localSetUp() { - super.localSetUp(); - if (isTestToBePerformed) { - getPM(); - pm.currentTransaction().begin(); - - emp1Oid = getOidByName("emp1"); - proj1Oid = getOidByName("proj1"); - emp1 = (Employee) pm.getObjectById(emp1Oid); - proj1 = (Project) pm.getObjectById(proj1Oid); - - // Preconditions - assertTrue( - testMethod - + ": Test aborted, precondition is false; " - + "expected emp.getProjects()to be empty", - emp1.getProjects().isEmpty()); - assertTrue( - testMethod - + ": Test aborted, precondition is false; " - + "expected ins.getMembers() to be empty", - proj1.getMembers().isEmpty()); +public class RelationshipManyToManyNoRelationships extends AbstractRelationshipTest { + + String testMethod = null; + protected String ASSERTION_FAILED = + "Assertion A15-3.14 (RelationshipManyToManyNoRelationships) failed: "; + + Object emp1Oid = null; + Object proj1Oid = null; + Employee emp1 = null; + Project proj1 = null; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(RelationshipManyToManyNoRelationships.class); } - } - - /** */ - public void testAddFromMappedSide() { - testMethod = "testAddFromMappedSide"; - if (isTestToBePerformed) { - - // Set relationship - Set emps = new HashSet(); - emps.add(emp1); - proj1.setMembers(emps); - pm.flush(); - - // Postcondition - deferredAssertTrue( - emp1.getProjects().contains(proj1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - proj1 = (Project) pm.getObjectById(proj1Oid); - deferredAssertTrue( - emp1.getProjects().contains(proj1), - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + + /** + * @see AbstractRelationshipTest#localSetUp() + */ + @Override + protected void localSetUp() { + super.localSetUp(); + if (isTestToBePerformed) { + getPM(); + pm.currentTransaction().begin(); + + emp1Oid = getOidByName("emp1"); + proj1Oid = getOidByName("proj1"); + emp1 = (Employee)pm.getObjectById(emp1Oid); + proj1 = (Project)pm.getObjectById(proj1Oid); + + // Preconditions + assertTrue(testMethod + + ": Test aborted, precondition is false; " + + "expected emp.getProjects()to be empty", + emp1.getProjects().isEmpty()); + assertTrue(testMethod + + ": Test aborted, precondition is false; " + + "expected ins.getMembers() to be empty", + proj1.getMembers().isEmpty()); + } } - } - - /** */ - public void testAddFromMappedbySide() { - testMethod = "testAddFromMappedbySide"; - if (isTestToBePerformed) { - - // Set relationship - Set projs = new HashSet(); - projs.add(proj1); - emp1.setProjects(projs); - pm.flush(); - - // Postcondition - deferredAssertTrue( - proj1.getMembers().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - proj1 = (Project) pm.getObjectById(proj1Oid); - deferredAssertTrue( - proj1.getMembers().contains(emp1), - ASSERTION_FAILED + testMethod, - "In new transaction, postcondition is false; " - + "other side of relationship is not set."); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testAddFromMappedSide() { + testMethod = "testAddFromMappedSide"; + if (isTestToBePerformed) { + + // Set relationship + Set emps = new HashSet(); + emps.add(emp1); + proj1.setMembers(emps); + pm.flush(); + + // Postcondition + deferredAssertTrue(emp1.getProjects().contains(proj1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + proj1 = (Project)pm.getObjectById(proj1Oid); + deferredAssertTrue( + emp1.getProjects().contains(proj1), + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testReplaceFromMappedSide() { - testMethod = "testReplaceFromMappedSide"; - if (isTestToBePerformed) { - - // Set relationship - Set members = new HashSet(); - Employee empNew = - new FullTimeEmployee( - 100, "Jerry", "Valentine", "Brown", new Date(500L), new Date(10000L), 125000); - pm.makePersistent(empNew); - members.add(empNew); - proj1.setMembers(members); - Object empNewOid = pm.getObjectId(empNew); - pm.flush(); - - assertFalse( - testMethod - + ": Test aborted, precondition is false; " - + "expected empNewOid to be non-null", - empNewOid == null); - - // Postcondition - - deferredAssertTrue( - empNew.getProjects().contains(proj1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - empNew = (Employee) pm.getObjectById(empNewOid); - emp1 = (Employee) pm.getObjectById(emp1Oid); - proj1 = (Project) pm.getObjectById(proj1Oid); - deferredAssertTrue( - empNew.getProjects().contains(proj1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set in new pm"); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testAddFromMappedbySide() { + testMethod = "testAddFromMappedbySide"; + if (isTestToBePerformed) { + + // Set relationship + Set projs = new HashSet(); + projs.add(proj1); + emp1.setProjects(projs); + pm.flush(); + + // Postcondition + deferredAssertTrue(proj1.getMembers().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + proj1 = (Project)pm.getObjectById(proj1Oid); + deferredAssertTrue( + proj1.getMembers().contains(emp1), + ASSERTION_FAILED + testMethod, + "In new transaction, postcondition is false; " + + "other side of relationship is not set."); + pm.currentTransaction().commit(); + + failOnError(); + } } - } - - /** */ - public void testReplaceFromMappedbySide() { - testMethod = "testReplaceFromMappedbySide"; - if (isTestToBePerformed) { - - // Set relationship - Set projects = new HashSet(); - Project projNew = new Project(99L, "Skunkworks", new BigDecimal(10000.35)); - pm.makePersistent(projNew); - projects.add(projNew); - emp1.setProjects(projects); - Object projNewOid = pm.getObjectId((Object) projNew); - pm.flush(); - - assertFalse( - testMethod - + ": Test aborted, precondition is false; " - + "expected projNewOid to be non-null", - projNewOid == null); - - // Postcondition - deferredAssertTrue( - projNew.getMembers().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set on flush"); - pm.currentTransaction().commit(); - cleanupPM(); - getPM(); - - pm.currentTransaction().begin(); - emp1 = (Employee) pm.getObjectById(emp1Oid); - projNew = (Project) pm.getObjectById(projNewOid); - proj1 = (Project) pm.getObjectById(proj1Oid); - deferredAssertTrue( - projNew.getMembers().contains(emp1), - ASSERTION_FAILED + testMethod, - "Postcondition is false; " + "other side of relationship not set in new pm"); - pm.currentTransaction().commit(); - - failOnError(); + + /** */ + public void testReplaceFromMappedSide() { + testMethod = "testReplaceFromMappedSide"; + if (isTestToBePerformed) { + + // Set relationship + Set members = new HashSet(); + Employee empNew = new FullTimeEmployee(100, "Jerry", "Valentine", + "Brown", new Date(500L), new Date(10000L), 125000); + pm.makePersistent(empNew); + members.add(empNew); + proj1.setMembers(members); + Object empNewOid = pm.getObjectId(empNew); + pm.flush(); + + assertFalse(testMethod + ": Test aborted, precondition is false; " + + "expected empNewOid to be non-null", empNewOid == null); + + // Postcondition + + deferredAssertTrue(empNew.getProjects().contains(proj1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + empNew = (Employee)pm.getObjectById(empNewOid); + emp1 = (Employee)pm.getObjectById(emp1Oid); + proj1 = (Project)pm.getObjectById(proj1Oid); + deferredAssertTrue(empNew.getProjects().contains(proj1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set in new pm"); + pm.currentTransaction().commit(); + + failOnError(); + } } - } + + /** */ + public void testReplaceFromMappedbySide() { + testMethod = "testReplaceFromMappedbySide"; + if (isTestToBePerformed) { + + // Set relationship + Set projects = new HashSet(); + Project projNew = new Project(99L, "Skunkworks", + new BigDecimal(10000.35)); + pm.makePersistent(projNew); + projects.add(projNew); + emp1.setProjects(projects); + Object projNewOid = pm.getObjectId((Object)projNew); + pm.flush(); + + assertFalse(testMethod + ": Test aborted, precondition is false; " + + "expected projNewOid to be non-null", projNewOid == null); + + // Postcondition + deferredAssertTrue(projNew.getMembers().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set on flush"); + pm.currentTransaction().commit(); + cleanupPM(); + getPM(); + + pm.currentTransaction().begin(); + emp1 = (Employee)pm.getObjectById(emp1Oid); + projNew = (Project)pm.getObjectById(projNewOid); + proj1 = (Project)pm.getObjectById(proj1Oid); + deferredAssertTrue(projNew.getMembers().contains(emp1), + ASSERTION_FAILED + testMethod, + "Postcondition is false; " + + "other side of relationship not set in new pm"); + pm.currentTransaction().commit(); + + failOnError(); + } + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/mapping/RelationshipNegative1To1Test.java b/tck/src/main/java/org/apache/jdo/tck/mapping/RelationshipNegative1To1Test.java index e279194e8..b0e07a681 100644 --- a/tck/src/main/java/org/apache/jdo/tck/mapping/RelationshipNegative1To1Test.java +++ b/tck/src/main/java/org/apache/jdo/tck/mapping/RelationshipNegative1To1Test.java @@ -25,120 +25,131 @@ import org.apache.jdo.tck.pc.company.MedicalInsurance; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:RelationshipNegative1To1Test
    - * Keywords: mapping, managed relationships
    - * Assertion ID: A15.3-14
    - * Assertion Description: Regardless of which side changes the relationship, flush (whether done - * as part of commit or explicitly by the user) will modify the datastore to reflect the change and - * will update the memory model for consistency... + *Title:RelationshipNegative1To1Test + *
    + *Keywords: mapping, managed relationships + *
    + *Assertion ID: A15.3-14 + *
    + *Assertion Description: Regardless of which side changes the relationship, + * flush (whether done as part of commit or explicitly by the user) will modify + * the datastore to reflect the change and will update the memory model + * for consistency... */ -public class RelationshipNegative1To1Test extends AbstractRelationshipTest { - - String testMethod = null; - protected String ASSERTION_FAILED = "Assertion A15-3.14 (RelationshipNegative1To1Test) failed: "; - - Object emp1Oid = null; - Object emp2Oid = null; - Object medIns1Oid = null; - Object medIns2Oid = null; - IEmployee emp1 = null; - IEmployee emp2 = null; - IMedicalInsurance medIns1 = null; - IMedicalInsurance medIns2 = null; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(RelationshipNegative1To1Test.class); - } - - /** - * @see AbstractRelationshipTest#localSetUp() - */ - @Override - protected void localSetUp() { - super.localSetUp(); - if (isTestToBePerformed) { - getPM(); - pm.currentTransaction().begin(); - - emp1Oid = getOidByName("emp1"); - emp2Oid = getOidByName("emp2"); - medIns1Oid = getOidByName("medicalIns1"); - medIns2Oid = getOidByName("medicalIns2"); - emp1 = (IEmployee) pm.getObjectById(emp1Oid); - emp2 = (IEmployee) pm.getObjectById(emp2Oid); - medIns1 = (IMedicalInsurance) pm.getObjectById(medIns1Oid); - medIns2 = (IMedicalInsurance) pm.getObjectById(medIns2Oid); +public class RelationshipNegative1To1Test extends AbstractRelationshipTest { + + String testMethod = null; + protected String ASSERTION_FAILED = + "Assertion A15-3.14 (RelationshipNegative1To1Test) failed: "; + + Object emp1Oid = null; + Object emp2Oid = null; + Object medIns1Oid = null; + Object medIns2Oid = null; + IEmployee emp1 = null; + IEmployee emp2 = null; + IMedicalInsurance medIns1 = null; + IMedicalInsurance medIns2 = null; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(RelationshipNegative1To1Test.class); } - } - - /** - * Test that JdoUserException is thrown if two sides of a relationship do not refer to each other. - */ - public void testA2BbutNotB2AMapped() { - testMethod = "testA2BbutNotB2AMapped"; - if (isTestToBePerformed) { - IEmployee empNew = - new FullTimeEmployee(99, "Matthew", "", "Adams", new Date(0L), new Date(10000L), 125000); - pm.makePersistent(empNew); - emp1.setMedicalInsurance(medIns2); - medIns2.setEmployee(empNew); - doFlush(testMethod); + + /** + * @see AbstractRelationshipTest#localSetUp() + */ + @Override + protected void localSetUp() { + super.localSetUp(); + if (isTestToBePerformed) { + getPM(); + pm.currentTransaction().begin(); + + emp1Oid = getOidByName("emp1"); + emp2Oid = getOidByName("emp2"); + medIns1Oid = getOidByName("medicalIns1"); + medIns2Oid = getOidByName("medicalIns2"); + emp1 = (IEmployee)pm.getObjectById(emp1Oid); + emp2 = (IEmployee)pm.getObjectById(emp2Oid); + medIns1 = (IMedicalInsurance)pm.getObjectById(medIns1Oid); + medIns2 = (IMedicalInsurance)pm.getObjectById(medIns2Oid); + } } - } - - /** - * Test that JdoUserException is thrown if two sides of a relationship do not refer to each other. - */ - public void testA2BbutNotB2AMappedBy() { - testMethod = "testA2BbutNotB2AMappedBy"; - if (isTestToBePerformed) { - IMedicalInsurance medInsNew = new MedicalInsurance(99, "The American Company", "B"); - pm.makePersistent(medInsNew); - medIns2.setEmployee(emp1); - emp1.setMedicalInsurance(medInsNew); - doFlush(testMethod); + + /** + * Test that JdoUserException is thrown if two sides of a relationship + * do not refer to each other. + */ + public void testA2BbutNotB2AMapped() { + testMethod = "testA2BbutNotB2AMapped"; + if (isTestToBePerformed) { + IEmployee empNew = new FullTimeEmployee(99, "Matthew", "", "Adams", + new Date(0L), new Date(10000L), 125000); + pm.makePersistent(empNew); + emp1.setMedicalInsurance(medIns2); + medIns2.setEmployee(empNew); + doFlush(testMethod); + } } - } - - /** - * Test that JdoUserException is thrown setting mapped side of a one-to-one relationship and - * setting the other side to null - */ - public void testSetOtherSideToNullMapped() { - testMethod = "testSetOtherSideToNullMapped"; - if (isTestToBePerformed) { - emp1.setMedicalInsurance(medIns2); - medIns2.setEmployee(null); - doFlush(testMethod); + + /** + * Test that JdoUserException is thrown if two sides of a relationship + * do not refer to each other. + */ + public void testA2BbutNotB2AMappedBy() { + testMethod = "testA2BbutNotB2AMappedBy"; + if (isTestToBePerformed) { + IMedicalInsurance medInsNew = new MedicalInsurance(99, + "The American Company", "B"); + pm.makePersistent(medInsNew); + medIns2.setEmployee(emp1); + emp1.setMedicalInsurance(medInsNew); + doFlush(testMethod); + } } - } - - /** - * Test that JdoUserException is thrown setting mapped by side of a one-to-one relationship and - * setting the other side to null - */ - public void testSetOtherSideToNullMappedBy() { - testMethod = "testSetOtherSideToNullMappedBy"; - if (isTestToBePerformed) { - medIns2.setEmployee(emp1); - emp1.setMedicalInsurance(null); - doFlush(testMethod); + + /** + * Test that JdoUserException is thrown setting mapped side + * of a one-to-one relationship and setting the other side to null + */ + public void testSetOtherSideToNullMapped() { + testMethod = "testSetOtherSideToNullMapped"; + if (isTestToBePerformed) { + emp1.setMedicalInsurance(medIns2); + medIns2.setEmployee(null); + doFlush(testMethod); + } } - } - - protected void doFlush(String method) { - try { - pm.flush(); - fail(ASSERTION_FAILED + testMethod + ": expected JDOUserException on flush!"); - } catch (JDOUserException jdoe) { - // expected exception + + /** + * Test that JdoUserException is thrown setting mapped by side + * of a one-to-one relationship and setting the other side to null + */ + public void testSetOtherSideToNullMappedBy() { + testMethod = "testSetOtherSideToNullMappedBy"; + if (isTestToBePerformed) { + medIns2.setEmployee(emp1); + emp1.setMedicalInsurance(null); + doFlush(testMethod); + } + } + + protected void doFlush(String method) { + try { + pm.flush(); + fail(ASSERTION_FAILED + testMethod + + ": expected JDOUserException on flush!"); + } catch (JDOUserException jdoe) { + // expected exception + } + pm.currentTransaction().rollback(); } - pm.currentTransaction().rollback(); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/mapping/RelationshipNegative1ToManyTest.java b/tck/src/main/java/org/apache/jdo/tck/mapping/RelationshipNegative1ToManyTest.java index b5207fca5..0ffc5c3a2 100644 --- a/tck/src/main/java/org/apache/jdo/tck/mapping/RelationshipNegative1ToManyTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/mapping/RelationshipNegative1ToManyTest.java @@ -24,106 +24,114 @@ import org.apache.jdo.tck.pc.company.FullTimeEmployee; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:RelationshipNegative1ToManyTest
    - * Keywords: mapping, managed relationships
    - * Assertion ID: A15.3-14
    - * Assertion Description: Regardless of which side changes the relationship, flush (whether done - * as part of commit or explicitly by the user) will modify the datastore to reflect the change and - * will update the memory model for consistency... + *Title:RelationshipNegative1ToManyTest + *
    + *Keywords: mapping, managed relationships + *
    + *Assertion ID: A15.3-14 + *
    + *Assertion Description: Regardless of which side changes the relationship, + * flush (whether done as part of commit or explicitly by the user) will modify + * the datastore to reflect the change and will update the memory model + * for consistency... */ -public class RelationshipNegative1ToManyTest extends AbstractRelationshipTest { - - String testMethod = null; - protected String ASSERTION_FAILED = - "Assertion A15-3.14 (RelationshipNegative1ToManyTest) failed: "; - - Object emp1Oid = null; - Object dept1Oid = null; - Object dept2Oid = null; - Employee emp1 = null; - Department dept1 = null; - Department dept2 = null; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(RelationshipNegative1ToManyTest.class); - } - - /** - * @see AbstractRelationshipTest#localSetUp() - */ - @Override - protected void localSetUp() { - super.localSetUp(); - if (isTestToBePerformed) { - getPM(); - pm.currentTransaction().begin(); - emp1Oid = getOidByName("emp1"); - dept1Oid = getOidByName("dept1"); - dept2Oid = getOidByName("dept2"); - emp1 = (Employee) pm.getObjectById(emp1Oid); - dept1 = (Department) pm.getObjectById(dept1Oid); - dept2 = (Department) pm.getObjectById(dept2Oid); +public class RelationshipNegative1ToManyTest extends AbstractRelationshipTest { + + String testMethod = null; + protected String ASSERTION_FAILED = + "Assertion A15-3.14 (RelationshipNegative1ToManyTest) failed: "; + + Object emp1Oid = null; + Object dept1Oid = null; + Object dept2Oid = null; + Employee emp1 = null; + Department dept1 = null; + Department dept2 = null; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(RelationshipNegative1ToManyTest.class); } - } - - /** - * Test that JdoUserException is thrown setting one side of a one-to-many relationship and - * deleting the other side - */ - public void testDeleteOtherSide() { - testMethod = "testDeleteOtherSide"; - if (isTestToBePerformed) { - dept2.addEmployee(emp1); - pm.deletePersistent(emp1); - doFlush(testMethod); + + /** + * @see AbstractRelationshipTest#localSetUp() + */ + @Override + protected void localSetUp() { + super.localSetUp(); + if (isTestToBePerformed) { + getPM(); + pm.currentTransaction().begin(); + + emp1Oid = getOidByName("emp1"); + dept1Oid = getOidByName("dept1"); + dept2Oid = getOidByName("dept2"); + emp1 = (Employee)pm.getObjectById(emp1Oid); + dept1 = (Department)pm.getObjectById(dept1Oid); + dept2 = (Department)pm.getObjectById(dept2Oid); + } } - } - - /** - * adding a related instance (with a single-valued mapped-by relationship field) to more than one - * one-to-many collection relationship - */ - public void testAddToMoreThanOne() { - testMethod = "testAddToMoreThanOne"; - if (isTestToBePerformed) { - Employee empNew = - new FullTimeEmployee(99, "Matthew", "", "Adams", new Date(0L), new Date(10000L), 125000); - pm.makePersistent(empNew); - dept1.addEmployee(empNew); - dept2.addEmployee(empNew); - doFlush(testMethod); + + /** + * Test that JdoUserException is thrown setting one side + * of a one-to-many relationship and deleting the other side + */ + public void testDeleteOtherSide() { + testMethod = "testDeleteOtherSide"; + if (isTestToBePerformed) { + dept2.addEmployee(emp1); + pm.deletePersistent(emp1); + doFlush(testMethod); + } } - } - - /** - * adding a related instance to a collection and setting the other side to a different instance - */ - public void testAInBbutNotB2A() { - testMethod = "testAInBbutNotB2A"; - if (isTestToBePerformed) { - Employee empNew = - new FullTimeEmployee(99, "Matthew", "", "Adams", new Date(0L), new Date(10000L), 125000); - pm.makePersistent(empNew); - dept1.addEmployee(empNew); - empNew.setDepartment(dept2); - doFlush(testMethod); + + /** + * adding a related instance (with a single-valued mapped-by relationship + * field) to more than one one-to-many collection relationship + */ + public void testAddToMoreThanOne() { + testMethod = "testAddToMoreThanOne"; + if (isTestToBePerformed) { + Employee empNew = new FullTimeEmployee(99, "Matthew", "", "Adams", + new Date(0L), new Date(10000L), 125000); + pm.makePersistent(empNew); + dept1.addEmployee(empNew); + dept2.addEmployee(empNew); + doFlush(testMethod); + } } - } - - protected void doFlush(String method) { - try { - pm.flush(); - fail(ASSERTION_FAILED + testMethod + ": expected JDOUserException on flush!"); - } catch (JDOUserException jdoe) { - // expected exception + + /** + * adding a related instance to a collection and setting the other side + * to a different instance + */ + public void testAInBbutNotB2A() { + testMethod = "testAInBbutNotB2A"; + if (isTestToBePerformed) { + Employee empNew = new FullTimeEmployee(99, "Matthew", "", "Adams", + new Date(0L), new Date(10000L), 125000); + pm.makePersistent(empNew); + dept1.addEmployee(empNew); + empNew.setDepartment(dept2); + doFlush(testMethod); + } + } + + protected void doFlush(String method) { + try { + pm.flush(); + fail(ASSERTION_FAILED + testMethod + + ": expected JDOUserException on flush!"); + } catch (JDOUserException jdoe) { + // expected exception + } + pm.currentTransaction().rollback(); } - pm.currentTransaction().rollback(); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/embedded/EmbeddedInheritance.java b/tck/src/main/java/org/apache/jdo/tck/models/embedded/EmbeddedInheritance.java index 8ba41e999..cbf7eafb8 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/embedded/EmbeddedInheritance.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/embedded/EmbeddedInheritance.java @@ -5,205 +5,211 @@ * 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 + * + * 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.jdo.tck.models.embedded; import java.util.List; + import javax.jdo.Query; + import org.apache.jdo.tck.JDO_Test; + import org.apache.jdo.tck.pc.building.Kitchen; import org.apache.jdo.tck.pc.building.MultifunctionOven; import org.apache.jdo.tck.pc.building.Oven; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test EmbeddedInheritance
    - * Keywords:
    - * Assertion IDs:
    + * Title: Test EmbeddedInheritance + *
    + * Keywords: + *
    + * Assertion IDs: + *
    * Assertion Description: */ public class EmbeddedInheritance extends JDO_Test { - /** */ - protected void localSetUp() { - addTearDownClass(Kitchen.class); - } - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(EmbeddedInheritance.class); - } - - /** - * Test for basic persistence of object with embedded object which has inheritance and persisting - * the base type of the embedded object. - */ - public void testPersistBase() { - Object id = null; - try { - getPM().currentTransaction().begin(); - Kitchen kitchen1 = new Kitchen(1); - Oven oven = new Oven("Westinghouse", "Economy"); - kitchen1.setOven(oven); - getPM().makePersistent(kitchen1); - getPM().currentTransaction().commit(); - id = getPM().getObjectId(kitchen1); - } catch (Exception e) { - fail("Exception on persist : " + e.getMessage()); - } finally { - if (getPM().currentTransaction().isActive()) { - getPM().currentTransaction().rollback(); - } + /** */ + protected void localSetUp() { + addTearDownClass(Kitchen.class); } - getPM().currentTransaction().begin(); - Kitchen kitchen = (Kitchen) getPM().getObjectById(id); - assertEquals("Id of object is incorrect", 1, kitchen.getId()); - Oven oven = kitchen.getOven(); - assertNotNull("Oven of Kitchen is null!", oven); - assertEquals("Oven is of incorrect type", Oven.class.getName(), oven.getClass().getName()); - assertEquals("Oven make is incorrect", "Westinghouse", oven.getMake()); - assertEquals("Oven model is incorrect", "Economy", oven.getModel()); - getPM().currentTransaction().commit(); - } - - /** - * Test for basic persistence of object with embedded object which has inheritance and persisting - * the subclass type of the embedded object. - */ - public void testPersistSubclass() { - Object id = null; - try { - getPM().currentTransaction().begin(); - Kitchen kitchen = new Kitchen(1); - MultifunctionOven oven = new MultifunctionOven("Westinghouse", "Economy"); - oven.setMicrowave(true); - oven.setCapabilities("TIMER,CLOCK"); - kitchen.setOven(oven); - getPM().makePersistent(kitchen); - getPM().currentTransaction().commit(); - id = getPM().getObjectId(kitchen); - } catch (Exception e) { - fail("Exception on persist : " + e.getMessage()); - } finally { - if (getPM().currentTransaction().isActive()) { - getPM().currentTransaction().rollback(); - } + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(EmbeddedInheritance.class); } - getPM().currentTransaction().begin(); - Kitchen kitchen = (Kitchen) getPM().getObjectById(id); - assertEquals("Id of object is incorrect", 1, kitchen.getId()); - Oven oven = kitchen.getOven(); - assertNotNull("Oven of Kitchen is null!", oven); - assertEquals( - "Oven is of incorrect type", MultifunctionOven.class.getName(), oven.getClass().getName()); - MultifunctionOven multioven = (MultifunctionOven) oven; - assertEquals("Oven make is incorrect", "Westinghouse", multioven.getMake()); - assertEquals("Oven model is incorrect", "Economy", multioven.getModel()); - assertEquals("Oven microwave setting is incorrect", true, multioven.getMicrowave()); - assertEquals("Oven capabilities is incorrect", "TIMER,CLOCK", multioven.getCapabilities()); - getPM().currentTransaction().commit(); - } - - /** Test for querying of fields of base type of an embedded object. */ - @SuppressWarnings("unchecked") - public void testQueryBase() { - Object id = null; - try { - getPM().currentTransaction().begin(); - Kitchen kitchen = new Kitchen(1); - MultifunctionOven oven = new MultifunctionOven("Westinghouse", "Economy"); - oven.setMicrowave(true); - oven.setCapabilities("TIMER,CLOCK"); - kitchen.setOven(oven); - getPM().makePersistent(kitchen); - getPM().currentTransaction().commit(); - id = getPM().getObjectId(kitchen); - } catch (Exception e) { - fail("Exception on persist : " + e.getMessage()); - } finally { - if (getPM().currentTransaction().isActive()) { - getPM().currentTransaction().rollback(); - } + /** + * Test for basic persistence of object with embedded object which has inheritance + * and persisting the base type of the embedded object. + */ + public void testPersistBase() { + Object id = null; + try { + getPM().currentTransaction().begin(); + Kitchen kitchen1 = new Kitchen(1); + Oven oven = new Oven("Westinghouse", "Economy"); + kitchen1.setOven(oven); + getPM().makePersistent(kitchen1); + getPM().currentTransaction().commit(); + id = getPM().getObjectId(kitchen1); + } + catch (Exception e) { + fail("Exception on persist : " + e.getMessage()); + } + finally { + if (getPM().currentTransaction().isActive()) { + getPM().currentTransaction().rollback(); + } + } + + getPM().currentTransaction().begin(); + Kitchen kitchen = (Kitchen)getPM().getObjectById(id); + assertEquals("Id of object is incorrect", 1, kitchen.getId()); + Oven oven = kitchen.getOven(); + assertNotNull("Oven of Kitchen is null!", oven); + assertEquals("Oven is of incorrect type", Oven.class.getName(), oven.getClass().getName()); + assertEquals("Oven make is incorrect", "Westinghouse", oven.getMake()); + assertEquals("Oven model is incorrect", "Economy", oven.getModel()); + getPM().currentTransaction().commit(); } - getPM().currentTransaction().begin(); - - Query q = - getPM() - .newQuery( - "SELECT FROM " - + Kitchen.class.getName() - + " WHERE this.oven.make == 'Westinghouse'"); - List kitchens = (List) q.execute(); - assertNotNull("No results from query!", kitchens); - assertEquals("Number of query results was incorrect", 1, kitchens.size()); - Kitchen kit = kitchens.iterator().next(); - assertEquals("Kitchen result is incorrect", id, getPM().getObjectId(kit)); - - getPM().currentTransaction().commit(); - } - - /** Test for querying of fields of subclass type of an embedded object. */ - @SuppressWarnings("unchecked") - public void testQuerySubclass() { - Object id = null; - try { - getPM().currentTransaction().begin(); - Kitchen kitchen = new Kitchen(1); - MultifunctionOven oven = new MultifunctionOven("Westinghouse", "Economy"); - oven.setMicrowave(true); - oven.setCapabilities("TIMER,CLOCK"); - kitchen.setOven(oven); - getPM().makePersistent(kitchen); - getPM().currentTransaction().commit(); - id = getPM().getObjectId(kitchen); - } catch (Exception e) { - fail("Exception on persist : " + e.getMessage()); - } finally { - if (getPM().currentTransaction().isActive()) { - getPM().currentTransaction().rollback(); - } + /** + * Test for basic persistence of object with embedded object which has inheritance + * and persisting the subclass type of the embedded object. + */ + public void testPersistSubclass() { + Object id = null; + try { + getPM().currentTransaction().begin(); + Kitchen kitchen = new Kitchen(1); + MultifunctionOven oven = new MultifunctionOven("Westinghouse", "Economy"); + oven.setMicrowave(true); + oven.setCapabilities("TIMER,CLOCK"); + kitchen.setOven(oven); + getPM().makePersistent(kitchen); + getPM().currentTransaction().commit(); + id = getPM().getObjectId(kitchen); + } + catch (Exception e) { + fail("Exception on persist : " + e.getMessage()); + } + finally { + if (getPM().currentTransaction().isActive()) { + getPM().currentTransaction().rollback(); + } + } + + getPM().currentTransaction().begin(); + Kitchen kitchen = (Kitchen)getPM().getObjectById(id); + assertEquals("Id of object is incorrect", 1, kitchen.getId()); + Oven oven = kitchen.getOven(); + assertNotNull("Oven of Kitchen is null!", oven); + assertEquals("Oven is of incorrect type", MultifunctionOven.class.getName(), + oven.getClass().getName()); + MultifunctionOven multioven = (MultifunctionOven)oven; + assertEquals("Oven make is incorrect", "Westinghouse", multioven.getMake()); + assertEquals("Oven model is incorrect", "Economy", multioven.getModel()); + assertEquals("Oven microwave setting is incorrect", true, multioven.getMicrowave()); + assertEquals("Oven capabilities is incorrect", "TIMER,CLOCK", multioven.getCapabilities()); + getPM().currentTransaction().commit(); } - getPM().currentTransaction().begin(); - - Query q1 = - getPM() - .newQuery( - "SELECT FROM " - + Kitchen.class.getName() - + " WHERE this.oven instanceof org.apache.jdo.tck.pc.building.MultifunctionOven"); - List kitchens1 = (List) q1.execute(); - assertNotNull("No results from query!", kitchens1); - assertEquals("Number of query results was incorrect", 1, kitchens1.size()); - - // Query using cast and a field of the subclass embedded class - Query q2 = - getPM() - .newQuery( - "SELECT FROM " - + Kitchen.class.getName() - + " WHERE ((org.apache.jdo.tck.pc.building.MultifunctionOven)this.oven).capabilities == 'TIMER,CLOCK'"); - List kitchens2 = (List) q2.execute(); - assertNotNull("No results from query!", kitchens2); - assertEquals("Number of query results was incorrect", 1, kitchens2.size()); - Kitchen kit = kitchens2.iterator().next(); - assertEquals("Kitchen result is incorrect", id, getPM().getObjectId(kit)); - - getPM().currentTransaction().commit(); - } + /** + * Test for querying of fields of base type of an embedded object. + */ + @SuppressWarnings("unchecked") + public void testQueryBase() { + Object id = null; + try { + getPM().currentTransaction().begin(); + Kitchen kitchen = new Kitchen(1); + MultifunctionOven oven = new MultifunctionOven("Westinghouse", "Economy"); + oven.setMicrowave(true); + oven.setCapabilities("TIMER,CLOCK"); + kitchen.setOven(oven); + getPM().makePersistent(kitchen); + getPM().currentTransaction().commit(); + id = getPM().getObjectId(kitchen); + } + catch (Exception e) { + fail("Exception on persist : " + e.getMessage()); + } + finally { + if (getPM().currentTransaction().isActive()) { + getPM().currentTransaction().rollback(); + } + } + + getPM().currentTransaction().begin(); + + Query q = getPM().newQuery("SELECT FROM " + Kitchen.class.getName() + + " WHERE this.oven.make == 'Westinghouse'"); + List kitchens = (List)q.execute(); + assertNotNull("No results from query!", kitchens); + assertEquals("Number of query results was incorrect", 1, kitchens.size()); + Kitchen kit = kitchens.iterator().next(); + assertEquals("Kitchen result is incorrect", id, getPM().getObjectId(kit)); + + getPM().currentTransaction().commit(); + } + + /** + * Test for querying of fields of subclass type of an embedded object. + */ + @SuppressWarnings("unchecked") + public void testQuerySubclass() { + Object id = null; + try { + getPM().currentTransaction().begin(); + Kitchen kitchen = new Kitchen(1); + MultifunctionOven oven = new MultifunctionOven("Westinghouse", "Economy"); + oven.setMicrowave(true); + oven.setCapabilities("TIMER,CLOCK"); + kitchen.setOven(oven); + getPM().makePersistent(kitchen); + getPM().currentTransaction().commit(); + id = getPM().getObjectId(kitchen); + } + catch (Exception e) { + fail("Exception on persist : " + e.getMessage()); + } + finally { + if (getPM().currentTransaction().isActive()) { + getPM().currentTransaction().rollback(); + } + } + + getPM().currentTransaction().begin(); + + Query q1 = getPM().newQuery("SELECT FROM " + Kitchen.class.getName() + + " WHERE this.oven instanceof org.apache.jdo.tck.pc.building.MultifunctionOven"); + List kitchens1 = (List)q1.execute(); + assertNotNull("No results from query!", kitchens1); + assertEquals("Number of query results was incorrect", 1, kitchens1.size()); + + // Query using cast and a field of the subclass embedded class + Query q2 = getPM().newQuery("SELECT FROM " + Kitchen.class.getName() + + " WHERE ((org.apache.jdo.tck.pc.building.MultifunctionOven)this.oven).capabilities == 'TIMER,CLOCK'"); + List kitchens2 = (List)q2.execute(); + assertNotNull("No results from query!", kitchens2); + assertEquals("Number of query results was incorrect", 1, kitchens2.size()); + Kitchen kit = kitchens2.iterator().next(); + assertEquals("Kitchen result is incorrect", id, getPM().getObjectId(kit)); + + getPM().currentTransaction().commit(); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/embedded/SecondClassObjectsTrackTheirChanges.java b/tck/src/main/java/org/apache/jdo/tck/models/embedded/SecondClassObjectsTrackTheirChanges.java index 46ac44635..9f5e10f3f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/embedded/SecondClassObjectsTrackTheirChanges.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/embedded/SecondClassObjectsTrackTheirChanges.java @@ -5,20 +5,22 @@ * 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 + * + * 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.jdo.tck.models.embedded; import java.util.Date; import java.util.Set; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.Address; import org.apache.jdo.tck.pc.company.Company; @@ -26,132 +28,122 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: SecondClassObjectsTrackTheirChanges
    - * Keywords: embedded lifecycle
    - * Assertion ID: A14.6.9-9
    - * Assertion Description: If an SCO field is in the result, the projected field is not owned - * by any persistent instance, and modifying the SCO value has no effect on any persistent instance. - * If an FCO field is in the result, the projected field is a persistent instance, and modifications - * made to the instance are are reflected as changes to the datastore per transaction requirements. + *Title: SecondClassObjectsTrackTheirChanges + *
    + *Keywords: embedded lifecycle + *
    + *Assertion ID: A14.6.9-9 + *
    + *Assertion Description: +If an SCO field is in the result, the projected field is not owned by any persistent instance, and modifying the SCO value has no effect on any persistent instance. If an FCO field is in the result, the projected field is a persistent instance, and modifications made to the instance are are reflected as changes to the datastore per transaction requirements. */ -public class SecondClassObjectsTrackTheirChanges extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.9-9 (SecondClassObjectsTrackTheirChanges) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SecondClassObjectsTrackTheirChanges.class); - } +public class SecondClassObjectsTrackTheirChanges extends JDO_Test { - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(Company.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.9-9 (SecondClassObjectsTrackTheirChanges) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SecondClassObjectsTrackTheirChanges.class); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(Company.class); + } - /** - * This tests that persistence-capable instances track changes or notify their owning instance - * that they are dirty - */ - public void testPCInstance() { - pm = getPM(); - pm.currentTransaction().begin(); - Company comp = getPersistentNewInstance(0); - pm.currentTransaction().commit(); // obj should transition to hollow - testHollowInstance(comp); - pm.currentTransaction().begin(); - makePersistentCleanInstance(comp); + /** This tests that persistence-capable instances track changes + * or notify their owning instance that they are dirty */ + public void testPCInstance() { + pm = getPM(); + pm.currentTransaction().begin(); + Company comp = getPersistentNewInstance(0); + pm.currentTransaction().commit(); // obj should transition to hollow + testHollowInstance(comp); + pm.currentTransaction().begin(); + makePersistentCleanInstance(comp); - Address addr = (Address) comp.getAddress(); - // comp or addr should transition to persistent-dirty - addr.setStreet("200 Orange Street"); - int currComp = currentState(comp); - int currAddr = currentState(addr); - if ((currComp != PERSISTENT_DIRTY) && (currAddr != PERSISTENT_DIRTY)) { - fail( - ASSERTION_FAILED, - "Unable to create persistent-dirty instance " - + "from persistent-clean instance via changing Address instance, " - + "state of Company instance is " - + states[currComp] - + " and state of Address instance is " - + states[currAddr]); + Address addr = (Address)comp.getAddress(); + // comp or addr should transition to persistent-dirty + addr.setStreet("200 Orange Street"); + int currComp = currentState(comp); + int currAddr = currentState(addr); + if ((currComp != PERSISTENT_DIRTY) && (currAddr != PERSISTENT_DIRTY)){ + fail(ASSERTION_FAILED, + "Unable to create persistent-dirty instance " + + "from persistent-clean instance via changing Address instance, " + + "state of Company instance is " + states[currComp] + + " and state of Address instance is " + states[currAddr]); + } } - } - /** - * This tests that mutable system class instances track changes or notify their owning instance - * that they are dirty - */ - public void testMutableSystemClass() { - pm = getPM(); - pm.currentTransaction().begin(); - Company comp = getPersistentNewInstance(1); - pm.currentTransaction().commit(); // obj should transition to hollow - testHollowInstance(comp); - pm.currentTransaction().begin(); - makePersistentCleanInstance(comp); + /** This tests that mutable system class instances track changes + * or notify their owning instance that they are dirty */ + public void testMutableSystemClass() { + pm = getPM(); + pm.currentTransaction().begin(); + Company comp = getPersistentNewInstance(1); + pm.currentTransaction().commit(); // obj should transition to hollow + testHollowInstance(comp); + pm.currentTransaction().begin(); + makePersistentCleanInstance(comp); - Set depts = comp.getDepartments(); - // comp or depts should transition to persistent-dirty - comp.addDepartment(new Department(0, "HR", comp)); - int currComp = currentState(comp); - int currDepts = currentState(depts); - if ((currComp != PERSISTENT_DIRTY) && (currDepts != PERSISTENT_DIRTY)) { - fail( - ASSERTION_FAILED, - "Unable to create persistent-dirty instance " - + "from persistent-clean instance via changing Departments " - + "instance, state of Company instance is " - + states[currComp] - + " and state of Departments instance is " - + states[currDepts]); + Set depts = comp.getDepartments(); + // comp or depts should transition to persistent-dirty + comp.addDepartment(new Department(0, "HR", comp)); + int currComp = currentState(comp); + int currDepts = currentState(depts); + if ((currComp != PERSISTENT_DIRTY) && (currDepts != PERSISTENT_DIRTY)){ + fail(ASSERTION_FAILED, + "Unable to create persistent-dirty instance " + + "from persistent-clean instance via changing Departments " + + "instance, state of Company instance is " + + states[currComp] + " and state of Departments instance is " + + states[currDepts]); + } } - } - public Company getPersistentNewInstance(long companyid) { - Company obj = - new Company(companyid, "MyCompany", new Date(), new Address(0, "", "", "", "", "")); - pm.makePersistent(obj); // obj should transition to persistent-new - int curr = currentState(obj); - if (curr != PERSISTENT_NEW) { - fail( - ASSERTION_FAILED, - "Unable to create persistent-new instance " - + "from transient instance via makePersistent(), state is " - + states[curr]); + public Company getPersistentNewInstance(long companyid) { + Company obj = new Company(companyid, "MyCompany", new Date(), + new Address(0,"","","","","")); + pm.makePersistent(obj); // obj should transition to persistent-new + int curr = currentState(obj); + if( curr != PERSISTENT_NEW ){ + fail(ASSERTION_FAILED, + "Unable to create persistent-new instance " + + "from transient instance via makePersistent(), state is " + + states[curr]); + } + return obj; } - return obj; - } - public void testHollowInstance(Company obj) { - int curr = currentState(obj); - if (curr != HOLLOW) { - fail( - ASSERTION_FAILED, - "Unable to create hollow instance " - + "from persistent-new instance via commit(), state is " - + states[curr]); + public void testHollowInstance(Company obj) { + int curr = currentState(obj); + if( curr != HOLLOW ){ + fail(ASSERTION_FAILED, + "Unable to create hollow instance " + + "from persistent-new instance via commit(), state is " + + states[curr]); + } } - } - public void makePersistentCleanInstance(Company obj) { - pm.makeTransactional(obj); // obj should transition to persistent-clean - int curr = currentState(obj); - if (curr != PERSISTENT_CLEAN) { - fail( - ASSERTION_FAILED, - "Unable to create persistent-clean instance " - + "from hollow instance via makeTransactional(obj), state is " - + states[curr]); + public void makePersistentCleanInstance(Company obj) { + pm.makeTransactional(obj); // obj should transition to persistent-clean + int curr = currentState(obj); + if( curr != PERSISTENT_CLEAN ){ + fail(ASSERTION_FAILED, + "Unable to create persistent-clean instance " + + "from hollow instance via makeTransactional(obj), state is " + + states[curr]); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestArrayCollections.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestArrayCollections.java index 4db40ddc9..977498747 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestArrayCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestArrayCollections.java @@ -5,188 +5,201 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.lang.reflect.Array; + import java.math.BigDecimal; + import java.util.Arrays; +import java.util.Collection; import java.util.Vector; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.ArrayCollections; import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type array.
    - * Keywords: model
    - * Assertion ID: A6.4.3-39.
    - * Assertion Description: JDO implementations may optionally support fields of array types. + *Title: Support of field type array. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-39. + *
    + *Assertion Description: +JDO implementations may optionally support fields of array types. */ + public class TestArrayCollections extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion (TestArrayCollections) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestArrayCollections.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(ArrayCollections.class); - addTearDownClass(SimpleClass.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTest(pm); - - pm.close(); - pm = null; - } - - /** */ - void runTest(PersistenceManager pm) { - if (!isArraySupported()) { - if (debug) logger.debug("JDO Implementation does not support" + "optional feature Array"); - return; + /** */ + private static final String ASSERTION_FAILED = + "Assertion (TestArrayCollections) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestArrayCollections.class); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(ArrayCollections.class); + addTearDownClass(SimpleClass.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; } + + /** */ + void runTest(PersistenceManager pm) + { + if (!isArraySupported()) { + if (debug) + logger.debug("JDO Implementation does not support" + + "optional feature Array"); + return; + } - Transaction tx = pm.currentTransaction(); - ArrayCollections expectedValue = new ArrayCollections(); - - // turn on datastore transactions - tx.setOptimistic(false); - tx.begin(); - ArrayCollections pi = new ArrayCollections(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - // Provide initial set of values - setValues(pi, 1); - - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - setValues(expectedValue, 1); - - // check if persistent fields have values set - checkValues(oid, expectedValue); - pi = (ArrayCollections) pm.getObjectById(oid, true); - - // Provide new set of values - setValues(pi, 2); - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - setValues(expectedValue, 2); - checkValues(oid, expectedValue); - tx.commit(); - } - - /** */ - private void setValues(ArrayCollections collect, int order) { - Vector value; - Class vectorClass = null; - int n = collect.getLength(); - for (int i = 0; i < n; ++i) { - String valueType = TestUtil.getFieldSpecs(ArrayCollections.fieldSpecs[i]); - value = TestUtil.makeNewVectorInstance(valueType, order); - try { - // get the right class to instantiate - vectorClass = value.get(0).getClass(); - } catch (Exception e) { - } - - Object[] valueArray = (Object[]) Array.newInstance(vectorClass, value.size()); - value.toArray(valueArray); - - collect.set(i, valueArray); - if (debug) logger.debug("Set " + i + "th value to: " + valueArray.toString()); + Transaction tx = pm.currentTransaction(); + ArrayCollections expectedValue = new ArrayCollections(); + + // turn on datastore transactions + tx.setOptimistic(false); + tx.begin(); + ArrayCollections pi = new ArrayCollections(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + // Provide initial set of values + setValues(pi, 1); + + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + setValues(expectedValue, 1); + + // check if persistent fields have values set + checkValues(oid, expectedValue); + pi = (ArrayCollections) pm.getObjectById(oid, true); + + // Provide new set of values + setValues(pi, 2); + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + setValues(expectedValue, 2); + checkValues(oid, expectedValue); + tx.commit(); } - } - - /** */ - private void checkValues(Object oid, ArrayCollections expectedValue) { - StringBuffer sbuf = new StringBuffer(); - ArrayCollections pi = (ArrayCollections) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (int i = 0; i < n; ++i) { - Object obj = new Object(); - Class objClass = obj.getClass(); - Object[] expected = (Object[]) Array.newInstance(objClass, 5); - Object[] actual = (Object[]) Array.newInstance(objClass, 5); - expected = expectedValue.get(i); - actual = pi.get(i); - if (actual == null) { - sbuf.append("\nFor " + ArrayCollections.fieldSpecs[i] + ", retrieved field is null."); - continue; - } - if (expected.length != actual.length) { - sbuf.append( - "\nFor element " - + i - + ", expected size = " - + expected.length - + ", actual size = " - + actual.length - + " . "); - continue; - } else if (!Arrays.equals(expected, actual)) { - if (TestUtil.getFieldSpecs(ArrayCollections.fieldSpecs[i]).equals("BigDecimal")) { - for (int j = 0; j < actual.length; ++j) { - BigDecimal expectedBD = (BigDecimal) expected[j]; - BigDecimal actualBD = (BigDecimal) actual[j]; - if ((expectedBD.compareTo(actualBD) != 0)) { - sbuf.append( - "\nFor element " - + i - + "[" - + j - + "], expected = " - + expectedBD - + ", actual = " - + actualBD - + " . "); + + /** */ + private void setValues(ArrayCollections collect, int order) + { + Vector value; + Class vectorClass = null; + int n = collect.getLength(); + for (int i = 0; i < n; ++i) { + String valueType = TestUtil.getFieldSpecs( + ArrayCollections.fieldSpecs[i]); + value = TestUtil.makeNewVectorInstance(valueType, order); + try { + // get the right class to instantiate + vectorClass = value.get(0).getClass(); + } catch (Exception e) { } - } - } else { - sbuf.append( - "\nFor element " + i + ", expected = " + expected + ", actual = " + actual + " . "); + + Object[] valueArray = (Object[])Array.newInstance(vectorClass, + value.size()); + value.toArray(valueArray); + + collect.set(i, valueArray); + if (debug) + logger.debug("Set " + i + "th value to: " + + valueArray.toString()); } - } } - if (sbuf.length() > 0) { - fail(ASSERTION_FAILED, "Expected and observed do not match!!" + sbuf.toString()); + + /** */ + private void checkValues(Object oid, ArrayCollections expectedValue) + { + StringBuffer sbuf = new StringBuffer(); + ArrayCollections pi = (ArrayCollections) pm.getObjectById(oid, true); + int n = pi.getLength(); + for (int i = 0; i < n; ++i) { + Object obj = new Object(); + Class objClass = obj.getClass(); + Object[] expected = (Object[])Array.newInstance(objClass, 5); + Object[] actual = (Object[])Array.newInstance(objClass, 5); + expected = expectedValue.get(i); + actual = pi.get(i); + if (actual == null) { + sbuf.append("\nFor " + ArrayCollections.fieldSpecs[i] + + ", retrieved field is null."); + continue; + } + if (expected.length != actual.length) { + sbuf.append("\nFor element " + i + ", expected size = " + + expected.length + ", actual size = " + actual.length + + " . "); + continue; + } + else if (!Arrays.equals(expected, actual)) { + if (TestUtil.getFieldSpecs(ArrayCollections.fieldSpecs[i] + ).equals("BigDecimal")) { + for (int j = 0; j < actual.length; ++j) { + BigDecimal expectedBD = (BigDecimal)expected[j]; + BigDecimal actualBD = (BigDecimal)actual[j]; + if ((expectedBD.compareTo(actualBD) != 0)) { + sbuf.append("\nFor element " + i + "[" + j + + "], expected = " + expectedBD + + ", actual = " + actualBD + " . "); + } + } + } + else { + sbuf.append("\nFor element " + i + ", expected = " + + expected + ", actual = " + actual + " . "); + } + } + } + if (sbuf.length() > 0) { + fail(ASSERTION_FAILED, + "Expected and observed do not match!!" + sbuf.toString()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestArrayListCollections.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestArrayListCollections.java index de635fc59..0293d5975 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestArrayListCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestArrayListCollections.java @@ -5,190 +5,196 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.math.BigDecimal; import java.util.ArrayList; -import java.util.Collection; import java.util.List; +import java.util.Collection; import java.util.Vector; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.ArrayListCollections; import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type ArrayList.
    - * Keywords: model
    - * Assertion ID: A6.4.3-23.
    - * Assertion Description: If the ArrayList optional feature is supported, then JDO - * implementation must support fields of the mutable object class ArrayList, supporting - * them as Second Class Objects or First Class Objects. + *Title: Support of field type ArrayList. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-23. + *
    + *Assertion Description: + If the ArrayList optional feature is supported, then JDO implementation must + support fields of the mutable object class ArrayList, + supporting them as Second Class Objects or First Class Objects. */ -public class TestArrayListCollections extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-23 (TestArrayListCollections) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestArrayListCollections.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(ArrayListCollections.class); - addTearDownClass(SimpleClass.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTest(pm); - - pm.close(); - pm = null; - } +public class TestArrayListCollections extends JDO_Test { - /** */ - void runTest(PersistenceManager pm) { - if (!isArrayListSupported()) { - if (debug) - logger.debug("JDO Implementation does not support optional " + "feature ArrayList"); - return; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-23 (TestArrayListCollections) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestArrayListCollections.class); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(ArrayListCollections.class); + addTearDownClass(SimpleClass.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; } - Transaction tx = pm.currentTransaction(); - ArrayListCollections expectedValue = new ArrayListCollections(); - - // turn on datastore transactions - tx.setOptimistic(false); - tx.begin(); - ArrayListCollections pi = new ArrayListCollections(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - // Provide initial set of values - setValues(pi, 1); - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - - setValues(expectedValue, 1); - checkValues(oid, expectedValue); - pi = (ArrayListCollections) pm.getObjectById(oid, true); - - // Provide new set of values - setValues(pi, 2); - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - setValues(expectedValue, 2); - checkValues(oid, expectedValue); - tx.commit(); - } + /** */ + void runTest(PersistenceManager pm) + { + if (!isArrayListSupported()) { + if (debug) + logger.debug("JDO Implementation does not support optional " + + "feature ArrayList"); + return; + } + + Transaction tx = pm.currentTransaction(); + ArrayListCollections expectedValue = new ArrayListCollections(); + + // turn on datastore transactions + tx.setOptimistic(false); + tx.begin(); + ArrayListCollections pi = new ArrayListCollections(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + // Provide initial set of values + setValues(pi, 1); + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + + setValues(expectedValue, 1); + checkValues(oid, expectedValue); + pi = (ArrayListCollections) pm.getObjectById(oid, true); + + // Provide new set of values + setValues(pi, 2); + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + setValues(expectedValue, 2); + checkValues(oid, expectedValue); + tx.commit(); + } - /** */ - private void setValues(ArrayListCollections collect, int order) { - Collection value; - int n = collect.getLength(); - for (int i = 0; i < n; ++i) { - String valueType = TestUtil.getFieldSpecs(ArrayListCollections.fieldSpecs[i]); - value = (Collection) TestUtil.makeNewVectorInstance(valueType, order); - ArrayList arrayListValue = new ArrayList(value); - collect.set(i, arrayListValue); - if (debug) logger.debug("Set " + i + "th value to: " + value.toString()); + /** */ + private void setValues(ArrayListCollections collect, int order) + { + Collection value; + int n = collect.getLength(); + for (int i = 0; i < n; ++i) { + String valueType = TestUtil.getFieldSpecs( + ArrayListCollections.fieldSpecs[i]); + value = (Collection)TestUtil.makeNewVectorInstance( + valueType, order); + ArrayList arrayListValue = new ArrayList(value); + collect.set(i, arrayListValue); + if (debug) + logger.debug("Set " + i + "th value to: " + value.toString()); + } } - } - /** */ - private void checkValues(Object oid, ArrayListCollections expectedValue) { - int i; - StringBuffer sbuf = new StringBuffer(); - ArrayListCollections pi = (ArrayListCollections) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - Collection expected = expectedValue.get(i); - Collection actual = pi.get(i); - if (actual == null) { - sbuf.append("\nFor element " + i + ", retrieved instance is null"); - continue; - } - if (actual.size() != expected.size()) { - sbuf.append( - "\nFor element " - + i - + ", expected size = " - + expected.size() - + ", actual size = " - + actual.size() - + " . "); - continue; - } else if (!expected.equals(actual)) { - if (TestUtil.getFieldSpecs(ArrayListCollections.fieldSpecs[i]).equals("BigDecimal")) { - if (debug) { - logger.debug( - "Field is " - + i - + " Class name is " - + actual.getClass().getName() - + " isInstance of Vector is " - + actual.getClass().isInstance((Object) new Vector())); - } - List expectedL = (List) expected; - List actualL = (List) actual; - for (int j = 0; j < actualL.size(); ++j) { - BigDecimal bigDecCompareWith = (BigDecimal) expectedL.get(j); - BigDecimal bigDecVal = (BigDecimal) actualL.get(j); - if ((bigDecCompareWith.compareTo(bigDecVal) != 0)) { - sbuf.append( - "\nFor element " - + i - + "(" - + j - + "), expected = " - + expected - + ", actual = " - + actualL - + " . "); + /** */ + private void checkValues(Object oid, ArrayListCollections expectedValue) + { + int i; + StringBuffer sbuf = new StringBuffer(); + ArrayListCollections pi = (ArrayListCollections) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for (i = 0; i < n; ++i) { + Collection expected = expectedValue.get(i); + Collection actual = pi.get(i); + if (actual == null) { + sbuf.append("\nFor element " + i + + ", retrieved instance is null"); + continue; + } + if (actual.size() != expected.size()) { + sbuf.append("\nFor element " + i + ", expected size = " + + expected.size() + ", actual size = " + actual.size() + + " . "); + continue; + } + else if (! expected.equals(actual)) { + if (TestUtil.getFieldSpecs(ArrayListCollections.fieldSpecs[i] + ).equals("BigDecimal")) { + if (debug) { + logger.debug("Field is " + i + " Class name is " + + actual.getClass().getName() + + " isInstance of Vector is " + + actual.getClass().isInstance((Object)new Vector())); + } + List expectedL = (List)expected; + List actualL = (List)actual; + for (int j = 0; j < actualL.size(); ++j) { + BigDecimal bigDecCompareWith = + (BigDecimal)expectedL.get(j); + BigDecimal bigDecVal = (BigDecimal)actualL.get(j); + if ((bigDecCompareWith.compareTo(bigDecVal) != 0)) { + sbuf.append("\nFor element " + i + "(" + j + + "), expected = " + expected + + ", actual = " + actualL + " . "); + } + } + } + else { + sbuf.append("\nFor element " + i + ", expected = " + + expected + ", actual = " + actual + " . "); + } } - } - } else { - sbuf.append( - "\nFor element " + i + ", expected = " + expected + ", actual = " + actual + " . "); } - } - } - if (sbuf.length() > 0) { - fail(ASSERTION_FAILED, "Expected and observed do not match!!" + sbuf.toString()); + if (sbuf.length() > 0) { + fail(ASSERTION_FAILED, + "Expected and observed do not match!!" + sbuf.toString()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestCollectionCollections.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestCollectionCollections.java index 86819985f..06059c987 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestCollectionCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestCollectionCollections.java @@ -5,177 +5,181 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.math.BigDecimal; import java.util.Collection; import java.util.List; import java.util.Vector; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.CollectionCollections; import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type Collection.
    - * Keywords: model
    - * Assertion ID: A6.4.3-33.
    - * Assertion Description: JDO implementations must support fields of the interface type - * java.util.Collection, and may choose to support them as Second Class Objects or - * First Class Objects. + *Title: Support of field type Collection. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-33. + *
    + *Assertion Description: + JDO implementations must support fields of the interface type + java.util.Collection, and may choose to support them + as Second Class Objects or First Class Objects. */ -public class TestCollectionCollections extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-33 (TestCollectionCollections) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestCollectionCollections.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CollectionCollections.class); - addTearDownClass(SimpleClass.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTest(pm); - - pm.close(); - pm = null; - } - - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - CollectionCollections expectedValue = new CollectionCollections(); - // turn on datastore transactions - tx.setOptimistic(false); - tx.begin(); - CollectionCollections pi = new CollectionCollections(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - // Provide initial set of values - setValues(pi, 1); - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - setValues(expectedValue, 1); - // check if persistent fields have values set - checkValues(oid, expectedValue); - pi = (CollectionCollections) pm.getObjectById(oid, true); - // Provide new set of values - setValues(pi, 2); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); +public class TestCollectionCollections extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-33 (TestCollectionCollections) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestCollectionCollections.class); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CollectionCollections.class); + addTearDownClass(SimpleClass.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } - tx.begin(); - // check new values - setValues(expectedValue, 2); - checkValues(oid, expectedValue); - tx.commit(); - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + CollectionCollections expectedValue = new CollectionCollections(); + + // turn on datastore transactions + tx.setOptimistic(false); + tx.begin(); + CollectionCollections pi = new CollectionCollections(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + // Provide initial set of values + setValues(pi, 1); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + setValues(expectedValue, 1); + // check if persistent fields have values set + checkValues(oid, expectedValue); + pi = (CollectionCollections) pm.getObjectById(oid, true); + // Provide new set of values + setValues(pi, 2); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + setValues(expectedValue, 2); + checkValues(oid, expectedValue); + tx.commit(); + } - /** */ - private void setValues(CollectionCollections colcol, int order) { - Vector value; - int n = colcol.getLength(); - for (int i = 0; i < n; ++i) { - String valueType = TestUtil.getFieldSpecs(CollectionCollections.fieldSpecs[i]); - value = TestUtil.makeNewVectorInstance(valueType, order); - colcol.set(i, value); - if (debug) logger.debug("Set " + i + "th value to: " + value.toString()); + /** */ + private void setValues(CollectionCollections colcol, int order) + { + Vector value; + int n = colcol.getLength(); + for (int i = 0; i < n; ++i) { + String valueType = TestUtil.getFieldSpecs( + CollectionCollections.fieldSpecs[i]); + value = TestUtil.makeNewVectorInstance(valueType, order); + colcol.set(i, value); + if (debug) + logger.debug("Set " + i + "th value to: " + value.toString()); + } } - } - /** */ - private void checkValues(Object oid, CollectionCollections expectedValue) { - StringBuffer sbuf = new StringBuffer(); - CollectionCollections pi = (CollectionCollections) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (int i = 0; i < n; ++i) { - Collection expected = expectedValue.get(i); - Collection actual = pi.get(i); - if (actual.size() != expected.size()) { - sbuf.append( - "\nFor element " - + i - + ", expected size = " - + expected.size() - + ", actual size = " - + actual.size() - + " . "); - } else if (!expected.equals(actual)) { - if (TestUtil.getFieldSpecs(CollectionCollections.fieldSpecs[i]).equals("BigDecimal")) { - if (debug) { - logger.debug( - "Field is " - + i - + " Class name is " - + actual.getClass().getName() - + " isInstance of Vector is " - + actual.getClass().isInstance((Object) new Vector())); - } - List expectedL = (List) expected; - List actualL = (List) actual; - for (int j = 0; j < actualL.size(); ++j) { - BigDecimal bigDecCompareWith = (BigDecimal) expectedL.get(j); - BigDecimal bigDecVal = (BigDecimal) actualL.get(j); - if ((bigDecCompareWith.compareTo(bigDecVal) != 0)) { - sbuf.append( - "\nFor element " - + i - + "(" - + j - + "), expected = " - + expected - + ", actual = " - + actualL - + " . "); + /** */ + private void checkValues(Object oid, CollectionCollections expectedValue) + { + StringBuffer sbuf = new StringBuffer(); + CollectionCollections pi = (CollectionCollections) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for (int i = 0; i < n; ++i) { + Collection expected = expectedValue.get(i); + Collection actual = pi.get(i); + if (actual.size() != expected.size()) { + sbuf.append("\nFor element " + i + ", expected size = " + + expected.size() + ", actual size = " + actual.size() + + " . "); + } + else if (! expected.equals(actual)) { + if (TestUtil.getFieldSpecs(CollectionCollections.fieldSpecs[i] + ).equals("BigDecimal")) { + if (debug) { + logger.debug("Field is " + i + " Class name is " + + actual.getClass().getName() + + " isInstance of Vector is " + + actual.getClass().isInstance((Object)new Vector())); + } + List expectedL = (List)expected; + List actualL = (List)actual; + for (int j = 0; j < actualL.size(); ++j) { + BigDecimal bigDecCompareWith = + (BigDecimal)expectedL.get(j); + BigDecimal bigDecVal = (BigDecimal)actualL.get(j); + if ((bigDecCompareWith.compareTo(bigDecVal) != 0)) { + sbuf.append("\nFor element " + i + "(" + j + + "), expected = " + expected + + ", actual = " + actualL + " . "); + } + } + } + else { + sbuf.append("\nFor element " + i + ", expected = " + + expected + ", actual = " + actual + " . "); + } } - } - } else { - sbuf.append( - "\nFor element " + i + ", expected = " + expected + ", actual = " + actual + " . "); } - } - } - if (sbuf.length() > 0) { - fail(ASSERTION_FAILED, "Expected and observed do not match!!" + sbuf.toString()); + if (sbuf.length() > 0) { + fail(ASSERTION_FAILED, + "Expected and observed do not match!!" + sbuf.toString()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBigDecimal.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBigDecimal.java index 2ea6ea783..6ae6500ee 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBigDecimal.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBigDecimal.java @@ -5,126 +5,130 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.math.BigDecimal; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfBigDecimal; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type BigDecimal.
    - * Keywords: model
    - * Assertion ID: A6.4.3-19.
    - * Assertion Description: JDO implementations must support fields of the immutable object - * class java.math.BigDecimal, and may choose to support them as Second Class Objects - * or First Class Objects. + *Title: Support of field type BigDecimal. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-19. + *
    + *Assertion Description: + JDO implementations must support fields of the immutable object class + java.math.BigDecimal, and may choose to support them as + Second Class Objects or First Class Objects. */ -public class TestFieldsOfBigDecimal extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-19 (TestFieldsOfBigDecimal) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfBigDecimal.class); - } +public class TestFieldsOfBigDecimal extends JDO_Test { - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfBigDecimal.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-19 (TestFieldsOfBigDecimal) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfBigDecimal.class); + } - /** */ - public void test() { - pm = getPM(); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfBigDecimal.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); - runTest(pm); + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + BigDecimal firstValue = new BigDecimal("20079.0237"); + BigDecimal secondValue = new BigDecimal("8907489.658"); + tx.begin(); + FieldsOfBigDecimal pi = new FieldsOfBigDecimal(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - BigDecimal firstValue = new BigDecimal("20079.0237"); - BigDecimal secondValue = new BigDecimal("8907489.658"); - tx.begin(); - FieldsOfBigDecimal pi = new FieldsOfBigDecimal(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0; i < n; ++i) { - pi.set(i, firstValue); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfBigDecimal) pm.getObjectById(oid, true); + checkValues(oid, firstValue); - pi = (FieldsOfBigDecimal) pm.getObjectById(oid, true); - checkValues(oid, firstValue); + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0; i < n; ++i) { - pi.set(i, secondValue); + tx.begin(); + // check new values + checkValues(oid, secondValue); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, secondValue); - tx.commit(); - } - /** */ - private void checkValues(Object oid, BigDecimal startValue) { - int i; - BigDecimal value; - FieldsOfBigDecimal pi = (FieldsOfBigDecimal) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0, value = startValue; i < n; ++i) { - if (!FieldsOfBigDecimal.isPersistent[i]) continue; - BigDecimal val = pi.get(i); - if (val.compareTo(value) != 0) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfBigDecimal.fieldSpecs[i] - + ", expected value " - + value.toString() - + ", value is " - + val.toString()); - } + /** */ + private void checkValues(Object oid, BigDecimal startValue){ + int i; + BigDecimal value; + FieldsOfBigDecimal pi = (FieldsOfBigDecimal) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0, value = startValue; i < n; ++i){ + if( !FieldsOfBigDecimal.isPersistent[i] ) continue; + BigDecimal val = pi.get(i); + if(val.compareTo(value) != 0){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfBigDecimal.fieldSpecs[i] + + ", expected value " + value.toString() + + ", value is " + val.toString()); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBigInteger.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBigInteger.java index 58f98ffa1..5014f56f4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBigInteger.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBigInteger.java @@ -5,126 +5,131 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.math.BigInteger; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfBigInteger; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type BigInteger.
    - * Keywords: model
    - * Assertion ID: A6.4.3-20.
    - * Assertion Description: JDO implementations must support fields of the immutable object - * class java.math.BigInteger, and may choose to support them as Second Class Objects - * or First Class Objects. + *Title: Support of field type BigInteger. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-20. + *
    + *Assertion Description: + JDO implementations must support fields of the immutable object class + java.math.BigInteger, and may choose to support them as + Second Class Objects or First Class Objects. */ -public class TestFieldsOfBigInteger extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-20 (TestFieldsOfBigInteger) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfBigInteger.class); - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfBigInteger.class); - } +public class TestFieldsOfBigInteger extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-20 (TestFieldsOfBigInteger) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfBigInteger.class); + } - /** */ - public void test() { - pm = getPM(); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfBigInteger.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); - runTest(pm); + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + BigInteger firstValue = new BigInteger("3958262948201938571947294821"); + BigInteger secondValue = new BigInteger("896738"); + tx.begin(); + FieldsOfBigInteger pi = new FieldsOfBigInteger(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - BigInteger firstValue = new BigInteger("3958262948201938571947294821"); - BigInteger secondValue = new BigInteger("896738"); - tx.begin(); - FieldsOfBigInteger pi = new FieldsOfBigInteger(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0; i < n; ++i) { - pi.set(i, firstValue); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfBigInteger) pm.getObjectById(oid, true); + checkValues(oid, firstValue); - pi = (FieldsOfBigInteger) pm.getObjectById(oid, true); - checkValues(oid, firstValue); + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0; i < n; ++i) { - pi.set(i, secondValue); + tx.begin(); + // check new values + checkValues(oid, secondValue); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, secondValue); - tx.commit(); - } - /** */ - private void checkValues(Object oid, BigInteger startValue) { - int i; - BigInteger value = startValue; - FieldsOfBigInteger pi = (FieldsOfBigInteger) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - if (!FieldsOfBigInteger.isPersistent[i]) continue; - BigInteger val = pi.get(i); - if (!val.equals(value)) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfBigInteger.fieldSpecs[i] - + ", expected value " - + value.toString() - + ", value is " - + val.toString()); - } + /** */ + private void checkValues(Object oid, BigInteger startValue){ + int i; + BigInteger value = startValue; + FieldsOfBigInteger pi = (FieldsOfBigInteger) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfBigInteger.isPersistent[i] ) + continue; + BigInteger val = pi.get(i); + if(!val.equals(value) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfBigInteger.fieldSpecs[i] + + ", expected value " + value.toString() + + ", value is " + val.toString()); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBoolean.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBoolean.java index f7b7b5269..67cb86727 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBoolean.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfBoolean.java @@ -5,124 +5,128 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfBoolean; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type Boolean.
    - * Keywords: model
    - * Assertion ID: A6.4.3-9.
    - * Assertion Description: JDO implementations must support fields of the immutable object - * class java.lang.Boolean, and may choose to support them as Second Class Objects or - * First Class Objects. + *Title: Support of field type Boolean. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-9. + *
    + *Assertion Description: + JDO implementations must support fields of the immutable object class + java.lang.Boolean, and may choose to support them as + Second Class Objects or First Class Objects. */ -public class TestFieldsOfBoolean extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-9 (TestFieldsOfBoolean) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfBoolean.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfBoolean.class); - } +public class TestFieldsOfBoolean extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-9 (TestFieldsOfBoolean) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfBoolean.class); + } - /** */ - public void test() { - pm = getPM(); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfBoolean.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); - runTest(pm); + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + Boolean firstValue = Boolean.TRUE; + Boolean secondValue = Boolean.FALSE; + tx.begin(); + FieldsOfBoolean pi = new FieldsOfBoolean(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - Boolean firstValue = Boolean.TRUE; - Boolean secondValue = Boolean.FALSE; - tx.begin(); - FieldsOfBoolean pi = new FieldsOfBoolean(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0; i < n; ++i) { - pi.set(i, firstValue); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfBoolean) pm.getObjectById(oid, true); + checkValues(oid, firstValue); - pi = (FieldsOfBoolean) pm.getObjectById(oid, true); - checkValues(oid, firstValue); + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0; i < n; ++i) { - pi.set(i, secondValue); + tx.begin(); + // check new values + checkValues(oid, secondValue); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, secondValue); - tx.commit(); - } - /** */ - private void checkValues(Object oid, Boolean startValue) { - int i; - FieldsOfBoolean pi = (FieldsOfBoolean) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - if (!FieldsOfBoolean.isPersistent[i]) continue; - Boolean val = pi.get(i); - if (!val.equals(startValue)) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfBoolean.fieldSpecs[i] - + ", expected value " - + startValue.toString() - + ", value is " - + val.toString()); - } + /** */ + private void checkValues(Object oid, Boolean startValue){ + int i; + FieldsOfBoolean pi = (FieldsOfBoolean) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfBoolean.isPersistent[i] ) + continue; + Boolean val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfBoolean.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val.toString()); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfByte.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfByte.java index 59ac3f94c..e9b8cd991 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfByte.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfByte.java @@ -5,123 +5,129 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfByte; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type Byte.
    - * Keywords: model
    - * Assertion ID: A6.4.3-11.
    - * Assertion Description: JDO implementations must support fields of the immutable object - * class java.lang.Byte, and may choose to support them as Second Class Objects or - * First Class Objects. + *Title: Support of field type Byte. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-11. + *
    + *Assertion Description: + JDO implementations must support fields of the immutable object class + java.lang.Byte, and may choose to support them as + Second Class Objects or First Class Objects. */ -public class TestFieldsOfByte extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A6.4.3-11 (TestFieldsOfByte) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfByte.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfByte.class); - } +public class TestFieldsOfByte extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-11 (TestFieldsOfByte) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfByte.class); + } - /** */ - public void test() { - pm = getPM(); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfByte.class); + } + + /** */ + public void test() { + pm = getPM(); - runTest(pm); + runTest(pm); + + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + Byte firstValue = Byte.valueOf((byte)Byte.MIN_VALUE); + Byte secondValue = Byte.valueOf((byte)Byte.MAX_VALUE); + tx.begin(); + FieldsOfByte pi = new FieldsOfByte(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - Byte firstValue = Byte.valueOf((byte) Byte.MIN_VALUE); - Byte secondValue = Byte.valueOf((byte) Byte.MAX_VALUE); - tx.begin(); - FieldsOfByte pi = new FieldsOfByte(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0; i < n; ++i) { - pi.set(i, firstValue); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfByte) pm.getObjectById(oid, true); + checkValues(oid, firstValue); - pi = (FieldsOfByte) pm.getObjectById(oid, true); - checkValues(oid, firstValue); + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0; i < n; ++i) { - pi.set(i, secondValue); + tx.begin(); + // check new values + checkValues(oid, secondValue); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, secondValue); - tx.commit(); - } - /** */ - private void checkValues(Object oid, Byte startValue) { - int i; - FieldsOfByte pi = (FieldsOfByte) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - if (!FieldsOfByte.isPersistent[i]) continue; - Byte val = pi.get(i); - if (!val.equals(startValue)) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfByte.fieldSpecs[i] - + ", expected value " - + startValue.toString() - + ", value is " - + val.toString()); - } + /** */ + private void checkValues(Object oid, Byte startValue){ + int i; + FieldsOfByte pi = (FieldsOfByte) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfByte.isPersistent[i] ) + continue; + Byte val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfByte.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val.toString()); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfCharacter.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfCharacter.java index e9ff1c8d4..ec763d3bd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfCharacter.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfCharacter.java @@ -5,124 +5,129 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfCharacter; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type Character.
    - * Keywords: model
    - * Assertion ID: A6.4.3-10.
    - * Assertion Description: JDO implementations must support fields of the immutable object - * class java.lang.Character, and may choose to support them as Second Class Objects or - * First Class Objects. + *Title: Support of field type Character. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-10. + *
    + *Assertion Description: + JDO implementations must support fields of the immutable object class + java.lang.Character, and may choose to support them as + Second Class Objects or First Class Objects. */ -public class TestFieldsOfCharacter extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-10 (TestFieldsOfCharacter) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfCharacter.class); - } +public class TestFieldsOfCharacter extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-10 (TestFieldsOfCharacter) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfCharacter.class); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfCharacter.class); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfCharacter.class); + } + + /** */ + public void test() { + pm = getPM(); - /** */ - public void test() { - pm = getPM(); + runTest(pm); - runTest(pm); + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + Character firstValue = Character.valueOf((char)Character.MIN_VALUE); + Character secondValue = Character.valueOf((char)Character.MAX_VALUE); + tx.begin(); + FieldsOfCharacter pi = new FieldsOfCharacter(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - Character firstValue = Character.valueOf((char) Character.MIN_VALUE); - Character secondValue = Character.valueOf((char) Character.MAX_VALUE); - tx.begin(); - FieldsOfCharacter pi = new FieldsOfCharacter(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0; i < n; ++i) { - pi.set(i, firstValue); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfCharacter) pm.getObjectById(oid, true); + checkValues(oid, firstValue); - pi = (FieldsOfCharacter) pm.getObjectById(oid, true); - checkValues(oid, firstValue); + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0; i < n; ++i) { - pi.set(i, secondValue); + tx.begin(); + // check new values + checkValues(oid, secondValue); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, secondValue); - tx.commit(); - } - /** */ - private void checkValues(Object oid, Character startValue) { - int i; - FieldsOfCharacter pi = (FieldsOfCharacter) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - if (!FieldsOfCharacter.isPersistent[i]) continue; - Character val = pi.get(i); - if (!val.equals(startValue)) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfCharacter.fieldSpecs[i] - + ", expected value " - + startValue.toString() - + ", value is " - + val.toString()); - } + /** */ + private void checkValues(Object oid, Character startValue){ + int i; + FieldsOfCharacter pi = (FieldsOfCharacter) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfCharacter.isPersistent[i] ) + continue; + Character val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfCharacter.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val.toString()); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfDate.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfDate.java index 002afc486..8abb4460b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfDate.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfDate.java @@ -5,124 +5,129 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.util.Date; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfDate; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type Date.
    - * Keywords: model
    - * Assertion ID: A6.4.3-21.
    - * Assertion Description: JDO implementations must support fields of the mutable object - * class java.util.Date, and may choose to support them as Second Class Objects or - * First Class Objects. + *Title: Support of field type Date. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-21. + *
    + *Assertion Description: + JDO implementations must support fields of the mutable object class + java.util.Date, and may choose to support them as + Second Class Objects or First Class Objects. */ -public class TestFieldsOfDate extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A6.4.3-21 (TestFieldsOfDate) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfDate.class); - } +public class TestFieldsOfDate extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-21 (TestFieldsOfDate) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfDate.class); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfDate.class); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfDate.class); + } + + /** */ + public void test() { + pm = getPM(); - /** */ - public void test() { - pm = getPM(); + runTest(pm); - runTest(pm); + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + Date firstValue = new Date(2007908); + Date secondValue = new Date(890748967382l); + tx.begin(); + FieldsOfDate pi = new FieldsOfDate(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - Date firstValue = new Date(2007908); - Date secondValue = new Date(890748967382l); - tx.begin(); - FieldsOfDate pi = new FieldsOfDate(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0; i < n; ++i) { - pi.set(i, firstValue); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfDate) pm.getObjectById(oid, true); + checkValues(oid, firstValue); - pi = (FieldsOfDate) pm.getObjectById(oid, true); - checkValues(oid, firstValue); + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0; i < n; ++i) { - pi.set(i, secondValue); + tx.begin(); + // check new values + checkValues(oid, secondValue); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, secondValue); - tx.commit(); - } - /** */ - private void checkValues(Object oid, Date startValue) { - int i; - FieldsOfDate pi = (FieldsOfDate) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - if (!FieldsOfDate.isPersistent[i]) continue; - Date val = pi.get(i); - if (!val.equals(startValue)) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfDate.fieldSpecs[i] - + ", expected value " - + startValue.toString() - + ", value is " - + val.toString()); - } + /** */ + private void checkValues(Object oid, Date startValue){ + int i; + FieldsOfDate pi = (FieldsOfDate) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfDate.isPersistent[i] ) continue; + Date val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfDate.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val.toString()); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfDouble.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfDouble.java index 4d78b83ab..a584a6117 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfDouble.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfDouble.java @@ -5,125 +5,128 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.AllTypes; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfDouble; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type Double.
    - * Keywords: model
    - * Assertion ID: A6.4.3-16.
    - * Assertion Description: JDO implementations must support fields of the immutable object - * class java.lang.Double, and may choose to support them as Second Class Objects or - * First Class Objects. + *Title: Support of field type Double. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-16. + *
    + *Assertion Description: + JDO implementations must support fields of the immutable object class + java.lang.Double, and may choose to support them as + Second Class Objects or First Class Objects. */ -public class TestFieldsOfDouble extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-16 (TestFieldsOfDouble) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfDouble.class); - } +public class TestFieldsOfDouble extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-16 (TestFieldsOfDouble) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfDouble.class); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfDouble.class); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfDouble.class); + } + + /** */ + public void test() { + pm = getPM(); - /** */ - public void test() { - pm = getPM(); + runTest(pm); - runTest(pm); + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + Double firstValue = Double.valueOf(AllTypes.DOUBLE_SMALLEST); + Double secondValue = Double.valueOf(AllTypes.DOUBLE_LARGEST); + tx.begin(); + FieldsOfDouble pi = new FieldsOfDouble(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - Double firstValue = Double.valueOf(AllTypes.DOUBLE_SMALLEST); - Double secondValue = Double.valueOf(AllTypes.DOUBLE_LARGEST); - tx.begin(); - FieldsOfDouble pi = new FieldsOfDouble(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0; i < n; ++i) { - pi.set(i, firstValue); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfDouble) pm.getObjectById(oid, true); + checkValues(oid, firstValue); - pi = (FieldsOfDouble) pm.getObjectById(oid, true); - checkValues(oid, firstValue); + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0; i < n; ++i) { - pi.set(i, secondValue); + tx.begin(); + // check new values + checkValues(oid, secondValue); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, secondValue); - tx.commit(); - } - /** */ - private void checkValues(Object oid, Double startValue) { - int i; - FieldsOfDouble pi = (FieldsOfDouble) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - if (!FieldsOfDouble.isPersistent[i]) continue; - Double val = pi.get(i); - if (!val.equals(startValue)) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfDouble.fieldSpecs[i] - + ", expected value " - + startValue.toString() - + ", value is " - + val.toString()); - } + /** */ + private void checkValues(Object oid, Double startValue){ + int i; + FieldsOfDouble pi = (FieldsOfDouble) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfDouble.isPersistent[i] ) continue; + Double val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfDouble.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val.toString()); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfFloat.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfFloat.java index a7200fb32..0c0a91d6d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfFloat.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfFloat.java @@ -5,124 +5,129 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.AllTypes; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfFloat; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type Float.
    - * Keywords: model
    - * Assertion ID: A6.4.3-15.
    - * Assertion Description: JDO implementations must support fields of the immutable object - * class java.lang.Float, and may choose to support them as Second Class Objects or - * First Class Objects. + *Title: Support of field type Float. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-15. + *
    + *Assertion Description: +JDO implementations must support fields of the immutable object class +java.lang.Float, and may choose to support them as +Second Class Objects or First Class Objects. */ -public class TestFieldsOfFloat extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A6.4.3-15 (TestFieldsOfFloat) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfFloat.class); - } +public class TestFieldsOfFloat extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-15 (TestFieldsOfFloat) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfFloat.class); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfFloat.class); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfFloat.class); + } + + /** */ + public void test() { + pm = getPM(); - /** */ - public void test() { - pm = getPM(); + runTest(pm); - runTest(pm); + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + Float firstValue = Float.valueOf((float)AllTypes.FLOAT_SMALLEST); + Float secondValue = Float.valueOf((float)AllTypes.FLOAT_LARGEST); + tx.begin(); + FieldsOfFloat pi = new FieldsOfFloat(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - Float firstValue = Float.valueOf((float) AllTypes.FLOAT_SMALLEST); - Float secondValue = Float.valueOf((float) AllTypes.FLOAT_LARGEST); - tx.begin(); - FieldsOfFloat pi = new FieldsOfFloat(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0; i < n; ++i) { - pi.set(i, firstValue); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfFloat) pm.getObjectById(oid, true); + checkValues(oid, firstValue); - pi = (FieldsOfFloat) pm.getObjectById(oid, true); - checkValues(oid, firstValue); + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0; i < n; ++i) { - pi.set(i, secondValue); + tx.begin(); + // check new values + checkValues(oid, secondValue); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, secondValue); - tx.commit(); - } - /** */ - private void checkValues(Object oid, Float startValue) { - int i; - FieldsOfFloat pi = (FieldsOfFloat) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - if (!FieldsOfFloat.isPersistent[i]) continue; - Float val = pi.get(i); - if (!val.equals(startValue)) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfFloat.fieldSpecs[i] - + ", expected value " - + startValue.toString() - + ", value is " - + val.toString()); - } + /** */ + private void checkValues(Object oid, Float startValue){ + int i; + FieldsOfFloat pi = (FieldsOfFloat) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfFloat.isPersistent[i] ) continue; + Float val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfFloat.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val.toString()); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfInteger.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfInteger.java index bc2807080..fbce0e00d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfInteger.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfInteger.java @@ -5,124 +5,127 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfInteger; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type Integer.
    - * Keywords: model
    - * Assertion ID: A6.4.3-13.
    - * Assertion Description: JDO implementations must support fields of the immutable object - * class java.lang.Integer, and may choose to support them as Second Class Objects or - * First Class Objects. + *Title: Support of field type Integer. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-13. + *
    + *Assertion Description: +JDO implementations must support fields of the immutable object class +java.lang.Integer, and may choose to support them as +Second Class Objects or First Class Objects. */ -public class TestFieldsOfInteger extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-13 (TestFieldsOfInteger) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfInteger.class); - } +public class TestFieldsOfInteger extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-13 (TestFieldsOfInteger) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfInteger.class); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfInteger.class); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfInteger.class); + } + + /** */ + public void test() { + pm = getPM(); - /** */ - public void test() { - pm = getPM(); + runTest(pm); - runTest(pm); + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + Integer firstValue = Integer.valueOf(Integer.MIN_VALUE); + Integer secondValue = Integer.valueOf(Integer.MAX_VALUE); + tx.begin(); + FieldsOfInteger pi = new FieldsOfInteger(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - Integer firstValue = Integer.valueOf(Integer.MIN_VALUE); - Integer secondValue = Integer.valueOf(Integer.MAX_VALUE); - tx.begin(); - FieldsOfInteger pi = new FieldsOfInteger(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0; i < n; ++i) { - pi.set(i, firstValue); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfInteger) pm.getObjectById(oid, true); + checkValues(oid, firstValue); - pi = (FieldsOfInteger) pm.getObjectById(oid, true); - checkValues(oid, firstValue); + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0; i < n; ++i) { - pi.set(i, secondValue); + tx.begin(); + // check new values + checkValues(oid, secondValue); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, secondValue); - tx.commit(); - } - /** */ - private void checkValues(Object oid, Integer startValue) { - int i; - FieldsOfInteger pi = (FieldsOfInteger) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - if (!FieldsOfInteger.isPersistent[i]) continue; - Integer val = pi.get(i); - if (!val.equals(startValue)) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfInteger.fieldSpecs[i] - + ", expected value " - + startValue.toString() - + ", value is " - + val.toString()); - } + /** */ + private void checkValues(Object oid, Integer startValue){ + int i; + FieldsOfInteger pi = (FieldsOfInteger) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfInteger.isPersistent[i] ) continue; + Integer val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfInteger.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val.toString()); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfLocale.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfLocale.java index 1e385dc53..de3a72c37 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfLocale.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfLocale.java @@ -5,126 +5,130 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.util.Locale; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfLocale; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type Locale.
    - * Keywords: model
    - * Assertion ID: A6.4.3-18.
    - * Assertion Description: JDO implementations must support fields of the immutable object - * class java.util.Locale, and may choose to support them as Second Class Objects or - * First Class Objects. + *Title: Support of field type Locale. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-18. + *
    + *Assertion Description: +JDO implementations must support fields of the immutable object class +java.util.Locale, and may choose to support them as +Second Class Objects or First Class Objects. */ -public class TestFieldsOfLocale extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-18 (TestFieldsOfLocale) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfLocale.class); - } +public class TestFieldsOfLocale extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-18 (TestFieldsOfLocale) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfLocale.class); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfLocale.class); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfLocale.class); + } + + /** */ + public void test() { + pm = getPM(); - /** */ - public void test() { - pm = getPM(); + runTest(pm); - runTest(pm); + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + Locale firstValue = Locale.CHINA; + Locale secondValue = Locale.JAPANESE; + tx.begin(); + FieldsOfLocale pi = new FieldsOfLocale(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - Locale firstValue = Locale.CHINA; - Locale secondValue = Locale.JAPANESE; - tx.begin(); - FieldsOfLocale pi = new FieldsOfLocale(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0; i < n; ++i) { - pi.set(i, firstValue); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfLocale) pm.getObjectById(oid, true); + checkValues(oid, firstValue); - pi = (FieldsOfLocale) pm.getObjectById(oid, true); - checkValues(oid, firstValue); + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0; i < n; ++i) { - pi.set(i, secondValue); + tx.begin(); + // check new values + checkValues(oid, secondValue); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, secondValue); - tx.commit(); - } - /** */ - private void checkValues(Object oid, Locale startValue) { - int i; - Locale value; - FieldsOfLocale pi = (FieldsOfLocale) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - if (!FieldsOfLocale.isPersistent[i]) continue; - Locale val = pi.get(i); - if (!val.equals(startValue)) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfLocale.fieldSpecs[i] - + ", expected value " - + startValue.toString() - + ", value is " - + val.toString()); - } + /** */ + private void checkValues(Object oid, Locale startValue){ + int i; + Locale value; + FieldsOfLocale pi = (FieldsOfLocale) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfLocale.isPersistent[i] ) continue; + Locale val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfLocale.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val.toString()); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfLong.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfLong.java index 6fe1e6b07..193a34f7d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfLong.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfLong.java @@ -5,123 +5,128 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfLong; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type Long.
    - * Keywords: model
    - * Assertion ID: A6.4.3-14.
    - * Assertion Description: JDO implementations must support fields of the immutable object - * class java.lang.Long, and may choose to support them as Second Class Objects or - * First Class Objects. + *Title: Support of field type Long. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-14. + *
    + *Assertion Description: +JDO implementations must support fields of the immutable object class +java.lang.Long, and may choose to support them as +Second Class Objects or First Class Objects. */ -public class TestFieldsOfLong extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A6.4.3-14 (TestFieldsOfLong) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfLong.class); - } +public class TestFieldsOfLong extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-14 (TestFieldsOfLong) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfLong.class); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfLong.class); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfLong.class); + } + + /** */ + public void test() { + pm = getPM(); - /** */ - public void test() { - pm = getPM(); + runTest(pm); - runTest(pm); + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + Long firstValue = Long.valueOf(Long.MIN_VALUE); + Long secondValue = Long.valueOf(Long.MAX_VALUE); + tx.begin(); + FieldsOfLong pi = new FieldsOfLong(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - Long firstValue = Long.valueOf(Long.MIN_VALUE); - Long secondValue = Long.valueOf(Long.MAX_VALUE); - tx.begin(); - FieldsOfLong pi = new FieldsOfLong(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0; i < n; ++i) { - pi.set(i, firstValue); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfLong) pm.getObjectById(oid, true); + checkValues(oid, firstValue); - pi = (FieldsOfLong) pm.getObjectById(oid, true); - checkValues(oid, firstValue); + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0; i < n; ++i) { - pi.set(i, secondValue); + tx.begin(); + // check new values + checkValues(oid, secondValue); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, secondValue); - tx.commit(); - } - /** */ - private void checkValues(Object oid, Long startValue) { - int i; - FieldsOfLong pi = (FieldsOfLong) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - if (!FieldsOfLong.isPersistent[i]) continue; - Long val = pi.get(i); - if (!val.equals(startValue)) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfLong.fieldSpecs[i] - + ", expected value " - + startValue.toString() - + ", value is " - + val.toString()); - } + /** */ + private void checkValues(Object oid, Long startValue){ + int i; + FieldsOfLong pi = (FieldsOfLong) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfLong.isPersistent[i] ) continue; + Long val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfLong.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val.toString()); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfObject.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfObject.java index 5ee4ab3bd..9415c4d2d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfObject.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfObject.java @@ -5,137 +5,146 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfObject; import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type Object.
    - * Keywords: model
    - * Assertion ID: A6.4.3-31.
    - * Assertion Description: JDO implementations must support fields of Object - * class type as First Class Objects. The implementation is permitted, but is not required, to allow - * any class to be assigned to the field. If an implementation restricts instances to be assigned to - * the field, a ClassCastException must be thrown at the time of any incorrect - * assignment. + *Title: Support of field type Object. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-31. + *
    + *Assertion Description: +JDO implementations must support fields of Object class type +as First Class Objects. The implementation is permitted, but is not required, +to allow any class to be assigned to the field. If an implementation restricts +instances to be assigned to the field, a ClassCastException +must be thrown at the time of any incorrect assignment. */ -public class TestFieldsOfObject extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-31 (TestFieldsOfObject) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfObject.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfObject.class); - } +public class TestFieldsOfObject extends JDO_Test { - /** */ - public void test() { - pm = getPM(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-31 (TestFieldsOfObject) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfObject.class); + } - runTest(pm); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfObject.class); + } + + /** */ + public void test() { + pm = getPM(); - pm.close(); - pm = null; - } + runTest(pm); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - Object firstValue = new SimpleClass(1, "Hello"); - Object secondValue = new SimpleClass(333, "420"); - tx.begin(); - FieldsOfObject pi = new FieldsOfObject(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0; i < n; ++i) { - pi.set(i, firstValue); + pm.close(); + pm = null; } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - tx.begin(); - pi = (FieldsOfObject) pm.getObjectById(oid, true); - checkValues(oid, firstValue); + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + Object firstValue = new SimpleClass(1, "Hello"); + Object secondValue = new SimpleClass(333, "420"); + tx.begin(); + FieldsOfObject pi = new FieldsOfObject(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0; i < n; ++i) { - pi.set(i, secondValue); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); + pi = (FieldsOfObject) pm.getObjectById(oid, true); + checkValues(oid, firstValue); - tx.begin(); - // check new values - checkValues(oid, secondValue); - tx.commit(); - } + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - private void checkValues(Object oid, Object startValue) { - int i; - FieldsOfObject pi = (FieldsOfObject) pm.getObjectById(oid, true); - int n = pi.getLength(); - StringBuffer buffer = new StringBuffer(); - for (i = 0; i < n; ++i) { - if (!FieldsOfObject.isPersistent[i]) continue; - Object val = pi.get(i); - if (val == null) { - buffer.append("Field "); - buffer.append(FieldsOfObject.fieldSpecs[i]); - buffer.append(" is null. Expected "); - buffer.append(startValue.toString()); - buffer.append(".\n"); - continue; - } - if (!val.equals(startValue)) { - buffer.append("Field "); - buffer.append(FieldsOfObject.fieldSpecs[i]); - buffer.append(" has wrong value: expected "); - buffer.append(startValue.toString()); - buffer.append(" actual "); - buffer.append(val.toString()); - buffer.append(".\n"); - } + tx.begin(); + // check new values + checkValues(oid, secondValue); + tx.commit(); } - if (buffer.length() > 0) { - fail(ASSERTION_FAILED, buffer.toString()); + + /** */ + private void checkValues(Object oid, Object startValue){ + int i; + FieldsOfObject pi = (FieldsOfObject) pm.getObjectById(oid, true); + int n = pi.getLength(); + StringBuffer buffer = new StringBuffer(); + for( i = 0; i < n; ++i){ + if( !FieldsOfObject.isPersistent[i] ) continue; + Object val = pi.get(i); + if (val == null) { + buffer.append("Field "); + buffer.append(FieldsOfObject.fieldSpecs[i]); + buffer.append(" is null. Expected "); + buffer.append(startValue.toString()); + buffer.append(".\n"); + continue; + } + if(!val.equals(startValue) ){ + buffer.append("Field "); + buffer.append(FieldsOfObject.fieldSpecs[i]); + buffer.append(" has wrong value: expected "); + buffer.append(startValue.toString()); + buffer.append(" actual "); + buffer.append(val.toString()); + buffer.append(".\n"); + } + } + if (buffer.length() > 0) { + fail(ASSERTION_FAILED, + buffer.toString()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveboolean.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveboolean.java index 5f295c884..0b06ec8bc 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveboolean.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveboolean.java @@ -5,122 +5,126 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfPrimitiveboolean; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type boolean.
    - * Keywords: model
    - * Assertion ID: A6.4.3-1.
    - * Assertion Description: JDO implementations must support fields of the primitive type - * boolean. + *Title: Support of field type boolean. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-1. + *
    + *Assertion Description: +JDO implementations must support fields of the primitive type boolean. */ -public class TestFieldsOfPrimitiveboolean extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-1 (TestFieldsOfPrimitiveboolean) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfPrimitiveboolean.class); - } +public class TestFieldsOfPrimitiveboolean extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-1 (TestFieldsOfPrimitiveboolean) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfPrimitiveboolean.class); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfPrimitiveboolean.class); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfPrimitiveboolean.class); + } + + /** */ + public void test() { + pm = getPM(); - /** */ - public void test() { - pm = getPM(); + runTest(pm); - runTest(pm); + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + boolean value; + tx.begin(); + FieldsOfPrimitiveboolean pi = new FieldsOfPrimitiveboolean(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0, value = true; i < n; ++i){ + pi.set( i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - boolean value; - tx.begin(); - FieldsOfPrimitiveboolean pi = new FieldsOfPrimitiveboolean(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0, value = true; i < n; ++i) { - pi.set(i, value); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfPrimitiveboolean) pm.getObjectById(oid, true); + checkValues(oid, true); - pi = (FieldsOfPrimitiveboolean) pm.getObjectById(oid, true); - checkValues(oid, true); + // Provide new set of values + for( i = 0, value = false; i < n; ++i){ + pi.set(i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0, value = false; i < n; ++i) { - pi.set(i, value); + tx.begin(); + // check new values + checkValues(oid, false); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, false); - tx.commit(); - } - /** */ - private void checkValues(Object oid, boolean startValue) { - int i; - FieldsOfPrimitiveboolean pi = (FieldsOfPrimitiveboolean) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - if (!FieldsOfPrimitiveboolean.isPersistent[i]) continue; - boolean val = pi.get(i); - if (val != startValue) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfPrimitiveboolean.fieldSpecs[i] - + ", expected value " - + startValue - + ", value is " - + val); - } + /** */ + private void checkValues(Object oid, boolean startValue){ + int i; + FieldsOfPrimitiveboolean pi = (FieldsOfPrimitiveboolean) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfPrimitiveboolean.isPersistent[i] ) continue; + boolean val = pi.get(i); + if( val != startValue ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + + FieldsOfPrimitiveboolean.fieldSpecs[i] + + ", expected value " + startValue + + ", value is " + val); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivebyte.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivebyte.java index 3cd86f417..550cae390 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivebyte.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivebyte.java @@ -5,122 +5,127 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfPrimitivebyte; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type byte.
    - * Keywords: model
    - * Assertion ID: A6.4.3-2.
    - * Assertion Description: JDO implementations must support fields of the primitive type - * int. + *Title: Support of field type byte. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-2. + *
    + *Assertion Description: +JDO implementations must support fields of the primitive type int. */ -public class TestFieldsOfPrimitivebyte extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-2 (TestFieldsOfPrimitivebyte) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfPrimitivebyte.class); - } +public class TestFieldsOfPrimitivebyte extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-2 (TestFieldsOfPrimitivebyte) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfPrimitivebyte.class); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfPrimitivebyte.class); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfPrimitivebyte.class); + } + + /** */ + public void test() { + pm = getPM(); - /** */ - public void test() { - pm = getPM(); + runTest(pm); - runTest(pm); + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + byte value; + tx.begin(); + FieldsOfPrimitivebyte pi = new FieldsOfPrimitivebyte(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0, value = 10; i < n; ++i){ + pi.set( i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - byte value; - tx.begin(); - FieldsOfPrimitivebyte pi = new FieldsOfPrimitivebyte(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0, value = 10; i < n; ++i) { - pi.set(i, value); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfPrimitivebyte) pm.getObjectById(oid, true); + checkValues(oid, (byte)10); - pi = (FieldsOfPrimitivebyte) pm.getObjectById(oid, true); - checkValues(oid, (byte) 10); + // Provide new set of values + for( i = 0, value = 127; i < n; ++i){ + pi.set(i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0, value = 127; i < n; ++i) { - pi.set(i, value); + tx.begin(); + // check new values + checkValues(oid, (byte)127); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, (byte) 127); - tx.commit(); - } - /** */ - private void checkValues(Object oid, byte startValue) { - int i; - FieldsOfPrimitivebyte pi = (FieldsOfPrimitivebyte) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - if (!FieldsOfPrimitivebyte.isPersistent[i]) continue; - byte val = pi.get(i); - if (val != startValue) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfPrimitivebyte.fieldSpecs[i] - + ", expected value " - + startValue - + ", value is " - + val); - } + /** */ + private void checkValues(Object oid, byte startValue){ + int i; + FieldsOfPrimitivebyte pi = (FieldsOfPrimitivebyte) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfPrimitivebyte.isPersistent[i] ) continue; + byte val = pi.get(i); + if( val != startValue ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + + FieldsOfPrimitivebyte.fieldSpecs[i] + + ", expected value " + startValue + + ", value is " + val); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivechar.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivechar.java index 9086c8136..78c14c69b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivechar.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivechar.java @@ -5,122 +5,127 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfPrimitivechar; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type char.
    - * Keywords: model
    - * Assertion ID: A6.4.3-6.
    - * Assertion Description: JDO implementations must support fields of the primitive type - * char. + *Title: Support of field type char. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-6. + *
    + *Assertion Description: +JDO implementations must support fields of the primitive type char. */ -public class TestFieldsOfPrimitivechar extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-6 (TestFieldsOfPrimitivechar) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfPrimitivechar.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfPrimitivechar.class); - } +public class TestFieldsOfPrimitivechar extends JDO_Test { + /** */ - public void test() { - pm = getPM(); + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-6 (TestFieldsOfPrimitivechar) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfPrimitivechar.class); + } - runTest(pm); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfPrimitivechar.class); + } + + /** */ + public void test() { + pm = getPM(); - pm.close(); - pm = null; - } + runTest(pm); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - char value; - tx.begin(); - FieldsOfPrimitivechar pi = new FieldsOfPrimitivechar(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0, value = 'a'; i < n; ++i) { - pi.set(i, value); + pm.close(); + pm = null; } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - tx.begin(); + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + char value; + tx.begin(); + FieldsOfPrimitivechar pi = new FieldsOfPrimitivechar(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0, value = 'a'; i < n; ++i){ + pi.set( i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - pi = (FieldsOfPrimitivechar) pm.getObjectById(oid, true); - checkValues(oid, 'a'); // check if persistent fields have values set + tx.begin(); - // Provide new set of values - for (i = 0, value = 'Z'; i < n; ++i) { - pi.set(i, value); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + pi = (FieldsOfPrimitivechar) pm.getObjectById(oid, true); + checkValues(oid, 'a'); // check if persistent fields have values set - tx.begin(); - // check new values - checkValues(oid, 'Z'); - tx.commit(); - } + // Provide new set of values + for( i = 0, value = 'Z'; i < n; ++i){ + pi.set(i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - private void checkValues(Object oid, char startValue) { - int i; - FieldsOfPrimitivechar pi = (FieldsOfPrimitivechar) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - if (!FieldsOfPrimitivechar.isPersistent[i]) continue; - char val = pi.get(i); - if (val != startValue) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfPrimitivechar.fieldSpecs[i] - + ", expected value " - + startValue - + ", value is " - + val); - } + tx.begin(); + // check new values + checkValues(oid, 'Z'); + tx.commit(); + } + + /** */ + private void checkValues(Object oid, char startValue){ + int i; + FieldsOfPrimitivechar pi = (FieldsOfPrimitivechar) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfPrimitivechar.isPersistent[i] ) continue; + char val = pi.get(i); + if( val != startValue ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + + FieldsOfPrimitivechar.fieldSpecs[i] + + ", expected value " + startValue + + ", value is " + val); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivedouble.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivedouble.java index 873d7896a..02f434e42 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivedouble.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivedouble.java @@ -5,122 +5,127 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfPrimitivedouble; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type double.
    - * Keywords: model
    - * Assertion ID: A6.4.3-8.
    - * Assertion Description: JDO implementations must support fields of the primitive type - * double. + *Title: Support of field type double. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-8. + *
    + *Assertion Description: +JDO implementations must support fields of the primitive type double. */ -public class TestFieldsOfPrimitivedouble extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-8 (TestFieldsOfPrimitivedouble) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfPrimitivedouble.class); - } +public class TestFieldsOfPrimitivedouble extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-8 (TestFieldsOfPrimitivedouble) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfPrimitivedouble.class); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfPrimitivedouble.class); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfPrimitivedouble.class); + } + + /** */ + public void test() { + pm = getPM(); - /** */ - public void test() { - pm = getPM(); + runTest(pm); - runTest(pm); + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + double value; + tx.begin(); + FieldsOfPrimitivedouble pi = new FieldsOfPrimitivedouble(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0, value = (double)10.15; i < n; ++i){ + pi.set( i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - double value; - tx.begin(); - FieldsOfPrimitivedouble pi = new FieldsOfPrimitivedouble(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0, value = (double) 10.15; i < n; ++i) { - pi.set(i, value); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfPrimitivedouble) pm.getObjectById(oid, true); + checkValues(oid, (double)10.15); - pi = (FieldsOfPrimitivedouble) pm.getObjectById(oid, true); - checkValues(oid, (double) 10.15); + // Provide new set of values + for( i = 0, value = (double)68000.15; i < n; ++i){ + pi.set(i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0, value = (double) 68000.15; i < n; ++i) { - pi.set(i, value); + tx.begin(); + // check new values + checkValues(oid, (double)68000.15); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, (double) 68000.15); - tx.commit(); - } - /** */ - private void checkValues(Object oid, double startValue) { - int i; - FieldsOfPrimitivedouble pi = (FieldsOfPrimitivedouble) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - if (!FieldsOfPrimitivedouble.isPersistent[i]) continue; - double val = pi.get(i); - if (val != startValue) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfPrimitivedouble.fieldSpecs[i] - + ", expected value " - + startValue - + ", value is " - + val); - } + /** */ + private void checkValues(Object oid, double startValue){ + int i; + FieldsOfPrimitivedouble pi = (FieldsOfPrimitivedouble) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfPrimitivedouble.isPersistent[i] ) continue; + double val = pi.get(i); + if( val != startValue ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + + FieldsOfPrimitivedouble.fieldSpecs[i] + + ", expected value " + startValue + + ", value is " + val); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivefloat.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivefloat.java index f1dc27eb0..e7ed741ae 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivefloat.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivefloat.java @@ -5,122 +5,127 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfPrimitivefloat; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type float.
    - * Keywords: model
    - * Assertion ID: A6.4.3-7.
    - * Assertion Description: JDO implementations must support fields of the primitive type - * float. + *Title: Support of field type float. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-7. + *
    + *Assertion Description: +JDO implementations must support fields of the primitive type float. */ -public class TestFieldsOfPrimitivefloat extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-7 (TestFieldsOfPrimitivefloat) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfPrimitivefloat.class); - } +public class TestFieldsOfPrimitivefloat extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-7 (TestFieldsOfPrimitivefloat) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfPrimitivefloat.class); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfPrimitivefloat.class); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfPrimitivefloat.class); + } + + /** */ + public void test() { + pm = getPM(); - /** */ - public void test() { - pm = getPM(); + runTest(pm); - runTest(pm); + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + float value; + tx.begin(); + FieldsOfPrimitivefloat pi = new FieldsOfPrimitivefloat(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0, value = (float)10.15; i < n; ++i){ + pi.set( i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - float value; - tx.begin(); - FieldsOfPrimitivefloat pi = new FieldsOfPrimitivefloat(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0, value = (float) 10.15; i < n; ++i) { - pi.set(i, value); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfPrimitivefloat) pm.getObjectById(oid, true); + checkValues(oid, (float)10.15); - pi = (FieldsOfPrimitivefloat) pm.getObjectById(oid, true); - checkValues(oid, (float) 10.15); + // Provide new set of values + for( i = 0, value = (float)33000.15; i < n; ++i){ + pi.set(i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0, value = (float) 33000.15; i < n; ++i) { - pi.set(i, value); + tx.begin(); + // check new values + checkValues(oid, (float)33000.15); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, (float) 33000.15); - tx.commit(); - } - /** */ - private void checkValues(Object oid, float startValue) { - int i; - FieldsOfPrimitivefloat pi = (FieldsOfPrimitivefloat) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - if (!FieldsOfPrimitivefloat.isPersistent[i]) continue; - float val = pi.get(i); - if (val != startValue) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfPrimitivefloat.fieldSpecs[i] - + ", expected value " - + startValue - + ", value is " - + val); - } + /** */ + private void checkValues(Object oid, float startValue){ + int i; + FieldsOfPrimitivefloat pi = (FieldsOfPrimitivefloat) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfPrimitivefloat.isPersistent[i] ) continue; + float val = pi.get(i); + if( val != startValue ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + + FieldsOfPrimitivefloat.fieldSpecs[i] + + ", expected value " + startValue + + ", value is " + val); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveint.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveint.java index 38d310099..57ed942c9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveint.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveint.java @@ -5,120 +5,125 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfPrimitiveint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type int.
    - * Keywords: model
    - * Assertion ID: A6.4.3-4.
    - * Assertion Description: JDO implementations must support fields of the primitive type - * int. + *Title: Support of field type int. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-4. + *
    + *Assertion Description: +JDO implementations must support fields of the primitive type int. */ -public class TestFieldsOfPrimitiveint extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-4 (TestFieldsOfPrimitiveint) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfPrimitiveint.class); - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfPrimitiveint.class); - } - /** */ - public void test() { - pm = getPM(); - - runTest(pm); - - pm.close(); - pm = null; - } +public class TestFieldsOfPrimitiveint extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-4 (TestFieldsOfPrimitiveint) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfPrimitiveint.class); + } - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n, value; - tx.begin(); - FieldsOfPrimitiveint pi = new FieldsOfPrimitiveint(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0, value = 0; i < n; ++i, ++value) { - pi.set(i, value); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfPrimitiveint.class); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + + /** */ + public void test() { + pm = getPM(); - tx.begin(); - pi = (FieldsOfPrimitiveint) pm.getObjectById(oid, true); - checkValues(oid, 0); // check if persistent fields have values set + runTest(pm); - // Provide new set of values - for (i = 0, value = 1000; i < n; ++i, ++value) { - pi.set(i, value); + pm.close(); + pm = null; } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - tx.begin(); - // check new values - checkValues(oid, 1000); - tx.commit(); - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n, value; + tx.begin(); + FieldsOfPrimitiveint pi = new FieldsOfPrimitiveint(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0, value = 0; i < n; ++i, ++value ){ + pi.set( i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + pi = (FieldsOfPrimitiveint) pm.getObjectById(oid, true); + checkValues(oid, 0); // check if persistent fields have values set - /** */ - private void checkValues(Object oid, int startValue) { - int i, value; - FieldsOfPrimitiveint pi = (FieldsOfPrimitiveint) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0, value = startValue; i < n; ++i, ++value) { - if (!FieldsOfPrimitiveint.isPersistent[i]) continue; - int val = pi.get(i); - if (val != value) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfPrimitiveint.fieldSpecs[i] - + ", expected value " - + startValue - + ", value is " - + val); - } + // Provide new set of values + for( i = 0, value = 1000; i < n; ++i, ++value ){ + pi.set(i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, 1000); + tx.commit(); + } + + /** */ + private void checkValues(Object oid, int startValue){ + int i, value; + FieldsOfPrimitiveint pi = (FieldsOfPrimitiveint) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0, value = startValue; i < n; ++i, ++value){ + if( !FieldsOfPrimitiveint.isPersistent[i] ) continue; + int val = pi.get(i); + if( val != value ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + + FieldsOfPrimitiveint.fieldSpecs[i] + + ", expected value " + startValue + + ", value is " + val); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivelong.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivelong.java index fac4a7908..5b6d63d41 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivelong.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitivelong.java @@ -5,123 +5,128 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfPrimitivelong; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type long.
    - * Keywords: model
    - * Assertion ID: A6.4.3-5.
    - * Assertion Description: JDO implementations must support fields of the primitive type - * long. + *Title: Support of field type long. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-5. + *
    + *Assertion Description: +JDO implementations must support fields of the primitive type long. */ -public class TestFieldsOfPrimitivelong extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-5 (TestFieldsOfPrimitivelong) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfPrimitivelong.class); - } +public class TestFieldsOfPrimitivelong extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-5 (TestFieldsOfPrimitivelong) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfPrimitivelong.class); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfPrimitivelong.class); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfPrimitivelong.class); + } + + /** */ + public void test() { + pm = getPM(); - /** */ - public void test() { - pm = getPM(); + runTest(pm); - runTest(pm); + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + long value; + tx.begin(); + FieldsOfPrimitivelong pi = new FieldsOfPrimitivelong(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0, value = 10; i < n; ++i){ + pi.set( i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - long value; - tx.begin(); - FieldsOfPrimitivelong pi = new FieldsOfPrimitivelong(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0, value = 10; i < n; ++i) { - pi.set(i, value); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfPrimitivelong) pm.getObjectById(oid, true); + checkValues(oid, 10); // check if persistent fields have values set - pi = (FieldsOfPrimitivelong) pm.getObjectById(oid, true); - checkValues(oid, 10); // check if persistent fields have values set + // Provide new set of values + for( i = 0, value = 67000; i < n; ++i){ + pi.set(i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0, value = 67000; i < n; ++i) { - pi.set(i, value); + tx.begin(); + // check new values + checkValues(oid, 67000); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, 67000); - tx.commit(); - } - /** */ - private void checkValues(Object oid, long startValue) { - int i; - long value; - FieldsOfPrimitivelong pi = (FieldsOfPrimitivelong) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - if (!FieldsOfPrimitivelong.isPersistent[i]) continue; - long val = pi.get(i); - if (val != startValue) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfPrimitivelong.fieldSpecs[i] - + ", expected value " - + startValue - + ", value is " - + val); - } + /** */ + private void checkValues(Object oid, long startValue){ + int i; + long value; + FieldsOfPrimitivelong pi = (FieldsOfPrimitivelong) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfPrimitivelong.isPersistent[i] ) continue; + long val = pi.get(i); + if( val != startValue ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + + FieldsOfPrimitivelong.fieldSpecs[i] + + ", expected value " + startValue + + ", value is " + val); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveshort.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveshort.java index d575f277a..e2b103777 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveshort.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfPrimitiveshort.java @@ -5,122 +5,126 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfPrimitiveshort; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type short.
    - * Keywords: model
    - * Assertion ID: A6.4.3-3.
    - * Assertion Description: JDO implementations must support fields of the primitive type - * short. + *Title: Support of field type short. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-3. + *
    + *Assertion Description: +JDO implementations must support fields of the primitive type short. */ -public class TestFieldsOfPrimitiveshort extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-3 (TestFieldsOfPrimitiveshort) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfPrimitiveshort.class); - } +public class TestFieldsOfPrimitiveshort extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-3 (TestFieldsOfPrimitiveshort) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfPrimitiveshort.class); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfPrimitiveshort.class); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfPrimitiveshort.class); + } + + /** */ + public void test() { + pm = getPM(); - /** */ - public void test() { - pm = getPM(); + runTest(pm); - runTest(pm); + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + short value; + tx.begin(); + FieldsOfPrimitiveshort pi = new FieldsOfPrimitiveshort(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0, value = 10; i < n; ++i){ + pi.set( i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - short value; - tx.begin(); - FieldsOfPrimitiveshort pi = new FieldsOfPrimitiveshort(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0, value = 10; i < n; ++i) { - pi.set(i, value); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfPrimitiveshort) pm.getObjectById(oid, true); + checkValues(oid, (short)10); - pi = (FieldsOfPrimitiveshort) pm.getObjectById(oid, true); - checkValues(oid, (short) 10); + // Provide new set of values + for( i = 0, value = 32000; i < n; ++i){ + pi.set(i, value); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0, value = 32000; i < n; ++i) { - pi.set(i, value); + tx.begin(); + // check new values + checkValues(oid, (short)32000); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, (short) 32000); - tx.commit(); - } - /** */ - private void checkValues(Object oid, short startValue) { - int i; - FieldsOfPrimitiveshort pi = (FieldsOfPrimitiveshort) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - if (!FieldsOfPrimitiveshort.isPersistent[i]) continue; - short val = pi.get(i); - if (val != startValue) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfPrimitiveshort.fieldSpecs[i] - + ", expected value " - + startValue - + ", value is " - + val); - } + /** */ + private void checkValues(Object oid, short startValue){ + int i; + FieldsOfPrimitiveshort pi = (FieldsOfPrimitiveshort) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfPrimitiveshort.isPersistent[i] ) continue; + short val = pi.get(i); + if( val != startValue ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + + FieldsOfPrimitiveshort.fieldSpecs[i] + + ", expected value " + startValue + + ", value is " + val); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfShort.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfShort.java index ec32f82d8..cc3acfa16 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfShort.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfShort.java @@ -5,124 +5,129 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfShort; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type Short.
    - * Keywords: model
    - * Assertion ID: A6.4.3-12.
    - * Assertion Description: JDO implementations must support fields of the immutable object - * class java.lang.Short, and may choose to support them as Second Class Objects or - * First Class Objects. + *Title: Support of field type Short. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-12. + *
    + *Assertion Description: +JDO implementations must support fields of the immutable object class +java.lang.Short, and may choose to support them as +Second Class Objects or First Class Objects. */ -public class TestFieldsOfShort extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A6.4.3-12 (TestFieldsOfShort) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfShort.class); - } +public class TestFieldsOfShort extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-12 (TestFieldsOfShort) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfShort.class); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfShort.class); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfShort.class); + } + + /** */ + public void test() { + pm = getPM(); - /** */ - public void test() { - pm = getPM(); + runTest(pm); - runTest(pm); + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + Short firstValue = Short.valueOf(Short.MIN_VALUE); + Short secondValue = Short.valueOf(Short.MAX_VALUE); + tx.begin(); + FieldsOfShort pi = new FieldsOfShort(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - Short firstValue = Short.valueOf(Short.MIN_VALUE); - Short secondValue = Short.valueOf(Short.MAX_VALUE); - tx.begin(); - FieldsOfShort pi = new FieldsOfShort(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0; i < n; ++i) { - pi.set(i, firstValue); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfShort) pm.getObjectById(oid, true); + checkValues(oid, firstValue); - pi = (FieldsOfShort) pm.getObjectById(oid, true); - checkValues(oid, firstValue); + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0; i < n; ++i) { - pi.set(i, secondValue); + tx.begin(); + // check new values + checkValues(oid, secondValue); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, secondValue); - tx.commit(); - } - /** */ - private void checkValues(Object oid, Short startValue) { - int i; - Short value; - FieldsOfShort pi = (FieldsOfShort) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0, value = startValue; i < n; ++i) { - if (!FieldsOfShort.isPersistent[i]) continue; - Short val = pi.get(i); - if (!val.equals(startValue)) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfShort.fieldSpecs[i] - + ", expected value " - + startValue.toString() - + ", value is " - + val.toString()); - } + /** */ + private void checkValues(Object oid, Short startValue){ + int i; + Short value; + FieldsOfShort pi = (FieldsOfShort) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0, value = startValue; i < n; ++i){ + if( !FieldsOfShort.isPersistent[i] ) continue; + Short val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfShort.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val.toString()); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleClass.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleClass.java index e036e737a..f86096dc2 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleClass.java @@ -5,117 +5,127 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfSimpleClass; import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of fields of PersistenceCapable class types
    - * Keywords: model
    - * Assertion ID: A6.4.3-30.
    - * Assertion Description: JDO implementations must support fields of - * PersistenceCapable class types as First Class Objects. + *Title: Support of fields of PersistenceCapable class types + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-30. + *
    + *Assertion Description: +JDO implementations must support fields of PersistenceCapable +class types as First Class Objects. */ -public class TestFieldsOfSimpleClass extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-30 (TestFieldsOfSimpleClass) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfSimpleClass.class); - } +public class TestFieldsOfSimpleClass extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-30 (TestFieldsOfSimpleClass) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfSimpleClass.class); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfSimpleClass.class); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfSimpleClass.class); + } + + /** */ + public void test() { + pm = getPM(); - /** */ - public void test() { - pm = getPM(); + runTest(pm); - runTest(pm); + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + SimpleClass firstValue = new SimpleClass(100, "Hello"); + SimpleClass secondValue = new SimpleClass(2000, "Hello World"); + tx.begin(); + FieldsOfSimpleClass pi = new FieldsOfSimpleClass(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - SimpleClass firstValue = new SimpleClass(100, "Hello"); - SimpleClass secondValue = new SimpleClass(2000, "Hello World"); - tx.begin(); - FieldsOfSimpleClass pi = new FieldsOfSimpleClass(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0; i < n; ++i) { - pi.set(i, firstValue); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfSimpleClass) pm.getObjectById(oid, true); + checkValues(oid, firstValue); - pi = (FieldsOfSimpleClass) pm.getObjectById(oid, true); - checkValues(oid, firstValue); + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0; i < n; ++i) { - pi.set(i, secondValue); + tx.begin(); + // check new values + checkValues(oid, secondValue); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, secondValue); - tx.commit(); - } - /** */ - private void checkValues(Object oid, SimpleClass startValue) { - int i; - FieldsOfSimpleClass pi = (FieldsOfSimpleClass) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - if (!FieldsOfSimpleClass.isPersistent[i]) continue; - SimpleClass val = pi.get(i); - if (!val.equals(startValue)) { - fail(ASSERTION_FAILED, "Incorrect value for " + FieldsOfSimpleClass.fieldSpecs[i]); - } + /** */ + private void checkValues(Object oid, SimpleClass startValue){ + int i; + FieldsOfSimpleClass pi = (FieldsOfSimpleClass) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfSimpleClass.isPersistent[i] ) continue; + SimpleClass val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + + FieldsOfSimpleClass.fieldSpecs[i]); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleEnum.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleEnum.java index ccf037057..f64557f31 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleEnum.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleEnum.java @@ -19,110 +19,113 @@ import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfSimpleEnum; import org.apache.jdo.tck.pc.fieldtypes.SimpleEnum; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type Enum.
    - * Keywords: model
    - * Assertion ID: A???
    - * Assertion Description: TBD + *Title: Support of field type Enum. + *
    + *Keywords: model + *
    + *Assertion ID: A??? + *
    + *Assertion Description: + * TBD */ -public class TestFieldsOfSimpleEnum extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A6.4.3-13 (TestFieldsOfEnum) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfSimpleEnum.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfSimpleEnum.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTest(pm); - - pm.close(); - pm = null; - } - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - SimpleEnum firstValue = SimpleEnum.AL; - SimpleEnum secondValue = SimpleEnum.WY; - tx.begin(); - FieldsOfSimpleEnum pi = new FieldsOfSimpleEnum(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0; i < n; ++i) { - pi.set(i, firstValue); +public class TestFieldsOfSimpleEnum extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-13 (TestFieldsOfEnum) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfSimpleEnum.class); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - pi = (FieldsOfSimpleEnum) pm.getObjectById(oid, true); - checkValues(oid, firstValue); - - // Provide new set of values - for (i = 0; i < n; ++i) { - pi.set(i, secondValue); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfSimpleEnum.class); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, secondValue); - tx.commit(); - - failOnError(); - } - - /** */ - private void checkValues(Object oid, SimpleEnum startValue) { - int i; - FieldsOfSimpleEnum pi = (FieldsOfSimpleEnum) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - if (!FieldsOfSimpleEnum.isPersistent[i]) continue; - SimpleEnum val = pi.get(i); - if (!startValue.equals(val)) { - appendMessage( - ASSERTION_FAILED - + "Incorrect value for " - + FieldsOfSimpleEnum.fieldSpecs[i] - + ", expected value " - + startValue.toString() - + ", value is " - + val); - } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + int i, n; + SimpleEnum firstValue = SimpleEnum.AL; + SimpleEnum secondValue = SimpleEnum.WY; + tx.begin(); + FieldsOfSimpleEnum pi = new FieldsOfSimpleEnum(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + + pi = (FieldsOfSimpleEnum) pm.getObjectById(oid, true); + checkValues(oid, firstValue); + + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + checkValues(oid, secondValue); + tx.commit(); + + failOnError(); + } + + /** */ + private void checkValues(Object oid, SimpleEnum startValue){ + int i; + FieldsOfSimpleEnum pi = (FieldsOfSimpleEnum)pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfSimpleEnum.isPersistent[i] ) continue; + SimpleEnum val = pi.get(i); + if(!startValue.equals(val) ){ + appendMessage(ASSERTION_FAILED + + "Incorrect value for " + FieldsOfSimpleEnum.fieldSpecs[i] + + ", expected value " + startValue.toString() + + ", value is " + val); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleInterface.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleInterface.java index 4225a00cf..64d0bf6c8 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleInterface.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfSimpleInterface.java @@ -5,20 +5,21 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfSimpleInterface; import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; @@ -26,97 +27,107 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of interfaces as field type.
    - * Keywords: model
    - * Assertion ID: A6.4.3-32.
    - * Assertion Description: JDO implementations must support fields of interface types, and - * may choose to support them as Second Class Objects or First Class Objects. + *Title: Support of interfaces as field type. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-32. + *
    + *Assertion Description: +JDO implementations must support fields of interface types, and may choose +to support them as Second Class Objects or First Class Objects. */ -public class TestFieldsOfSimpleInterface extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-32 (TestFieldsOfSimpleInterface) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfSimpleInterface.class); - } +public class TestFieldsOfSimpleInterface extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-32 (TestFieldsOfSimpleInterface) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfSimpleInterface.class); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfSimpleInterface.class); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfSimpleInterface.class); + } + + /** */ + public void test() { + pm = getPM(); - /** */ - public void test() { - pm = getPM(); + runTest(pm); - runTest(pm); + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + SimpleInterface firstValue = new SimpleClass(100, "Hello"); + SimpleInterface secondValue = new SimpleClass(2000, "Hello World"); + tx.begin(); + FieldsOfSimpleInterface pi = new FieldsOfSimpleInterface(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - SimpleInterface firstValue = new SimpleClass(100, "Hello"); - SimpleInterface secondValue = new SimpleClass(2000, "Hello World"); - tx.begin(); - FieldsOfSimpleInterface pi = new FieldsOfSimpleInterface(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0; i < n; ++i) { - pi.set(i, firstValue); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfSimpleInterface) pm.getObjectById(oid, true); + checkValues(oid, firstValue); - pi = (FieldsOfSimpleInterface) pm.getObjectById(oid, true); - checkValues(oid, firstValue); + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0; i < n; ++i) { - pi.set(i, secondValue); + tx.begin(); + // check new values + checkValues(oid, secondValue); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, secondValue); - tx.commit(); - } - /** */ - private void checkValues(Object oid, SimpleInterface startValue) { - int i; - FieldsOfSimpleInterface pi = (FieldsOfSimpleInterface) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - if (!FieldsOfSimpleInterface.isPersistent[i]) continue; - SimpleInterface val = pi.get(i); - if (!val.equals(startValue)) { - fail(ASSERTION_FAILED, "Incorrect value for " + FieldsOfSimpleInterface.fieldSpecs[i]); - } + /** */ + private void checkValues(Object oid, SimpleInterface startValue){ + int i; + FieldsOfSimpleInterface pi = (FieldsOfSimpleInterface) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0; i < n; ++i){ + if( !FieldsOfSimpleInterface.isPersistent[i] ) continue; + SimpleInterface val = pi.get(i); + if(!val.equals(startValue)){ + fail(ASSERTION_FAILED, + "Incorrect value for " + + FieldsOfSimpleInterface.fieldSpecs[i]); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfString.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfString.java index 454d0c649..3ac0607a1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfString.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestFieldsOfString.java @@ -5,125 +5,129 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfString; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type String.
    - * Keywords: model
    - * Assertion ID: A6.4.3-17.
    - * Assertion Description: JDO implementations must support fields of the immutable object - * class java.lang.String, and may choose to support them as Second Class Objects or - * First Class Objects. + *Title: Support of field type String. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-17. + *
    + *Assertion Description: +JDO implementations must support fields of the immutable object class +java.lang.String, and may choose to support them as +Second Class Objects or First Class Objects. */ -public class TestFieldsOfString extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-17 (TestFieldsOfString) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestFieldsOfString.class); - } +public class TestFieldsOfString extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-17 (TestFieldsOfString) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestFieldsOfString.class); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfString.class); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfString.class); + } + + /** */ + public void test() { + pm = getPM(); - /** */ - public void test() { - pm = getPM(); + runTest(pm); - runTest(pm); + pm.close(); + pm = null; + } - pm.close(); - pm = null; - } + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + int i, n; + String firstValue = new String("Hello"); + String secondValue = new String("Hello World"); + tx.begin(); + FieldsOfString pi = new FieldsOfString(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + n = pi.getLength(); + // Provide initial set of values + for( i = 0; i < n; ++i){ + pi.set( i, firstValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - int i, n; - String firstValue = new String("Hello"); - String secondValue = new String("Hello World"); - tx.begin(); - FieldsOfString pi = new FieldsOfString(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - n = pi.getLength(); - // Provide initial set of values - for (i = 0; i < n; ++i) { - pi.set(i, firstValue); - } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); + tx.begin(); - tx.begin(); + pi = (FieldsOfString) pm.getObjectById(oid, true); + checkValues(oid, firstValue); - pi = (FieldsOfString) pm.getObjectById(oid, true); - checkValues(oid, firstValue); + // Provide new set of values + for( i = 0; i < n; ++i){ + pi.set(i, secondValue); + } + tx.commit(); + // cache will be flushed + pi = null; + System.gc(); - // Provide new set of values - for (i = 0; i < n; ++i) { - pi.set(i, secondValue); + tx.begin(); + // check new values + checkValues(oid, secondValue); + tx.commit(); } - tx.commit(); - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - checkValues(oid, secondValue); - tx.commit(); - } - /** */ - private void checkValues(Object oid, String startValue) { - int i; - String value; - FieldsOfString pi = (FieldsOfString) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0, value = startValue; i < n; ++i) { - if (!FieldsOfString.isPersistent[i]) continue; - String val = pi.get(i); - if (!val.equals(startValue)) { - fail( - ASSERTION_FAILED, - "Incorrect value for " - + FieldsOfString.fieldSpecs[i] - + ", expected value " - + value - + ", value is " - + val.toString()); - } + /** */ + private void checkValues(Object oid, String startValue){ + int i; + String value; + FieldsOfString pi = (FieldsOfString) pm.getObjectById(oid, true); + int n = pi.getLength(); + for( i = 0, value = startValue; i < n; ++i){ + if( !FieldsOfString.isPersistent[i] ) continue; + String val = pi.get(i); + if(!val.equals(startValue) ){ + fail(ASSERTION_FAILED, + "Incorrect value for " + FieldsOfString.fieldSpecs[i] + + ", expected value " + value + + ", value is " + val.toString()); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringKeyCollections.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringKeyCollections.java index d859cfb9e..2b695118e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringKeyCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringKeyCollections.java @@ -5,183 +5,198 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.math.BigDecimal; + import java.util.HashMap; +import java.util.Hashtable; import java.util.Iterator; import java.util.Set; import java.util.Vector; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.HashMapStringKeyCollections; import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type HashMap, varying value type
    - * Keywords: model
    - * Assertion ID: A6.4.3-24.
    - * Assertion Description: If the HashMap optional feature is supported, then JDO - * implementation must support fields of the mutable object class HashMap, supporting - * them as Second Class Objects or First Class Objects. + *Title: Support of field type HashMap, varying value type + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-24. + *
    + *Assertion Description: +If the HashMap optional feature is supported, then JDO implementation must +support fields of the mutable object class HashMap, +supporting them as Second Class Objects or First Class Objects. */ + + public class TestHashMapStringKeyCollections extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-24 (TestHashMapStringKeyCollections) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestHashMapStringKeyCollections.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(HashMapStringKeyCollections.class); - addTearDownClass(SimpleClass.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTest(pm); - - pm.close(); - pm = null; - } - - /** */ - void runTest(PersistenceManager pm) { - if (!isHashMapSupported()) { - if (debug) - logger.debug("JDO Implementation does not support " + "the optional feature HashMap"); - return; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-24 (TestHashMapStringKeyCollections) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestHashMapStringKeyCollections.class); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(HashMapStringKeyCollections.class); + addTearDownClass(SimpleClass.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + if (!isHashMapSupported()) { + if (debug) + logger.debug("JDO Implementation does not support " + + "the optional feature HashMap"); + return; + } + + Transaction tx = pm.currentTransaction(); + HashMapStringKeyCollections expectedValue = + new HashMapStringKeyCollections(); + + // turn on datastore transactions + tx.setOptimistic(false); + tx.begin(); + HashMapStringKeyCollections pi = new HashMapStringKeyCollections(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + // Provide initial set of values + setValues(pi, 1); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + setValues(expectedValue, 1); + checkValues(oid, expectedValue); + pi = (HashMapStringKeyCollections) pm.getObjectById(oid, true); + setValues(pi, 2); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + setValues(expectedValue, 2); + checkValues(oid, expectedValue); + tx.commit(); } - Transaction tx = pm.currentTransaction(); - HashMapStringKeyCollections expectedValue = new HashMapStringKeyCollections(); - - // turn on datastore transactions - tx.setOptimistic(false); - tx.begin(); - HashMapStringKeyCollections pi = new HashMapStringKeyCollections(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - // Provide initial set of values - setValues(pi, 1); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - setValues(expectedValue, 1); - checkValues(oid, expectedValue); - pi = (HashMapStringKeyCollections) pm.getObjectById(oid, true); - setValues(pi, 2); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - setValues(expectedValue, 2); - checkValues(oid, expectedValue); - tx.commit(); - } - - /** */ - private void setValues(HashMapStringKeyCollections collect, int order) { - int keyOrder = order; - int valueOrder = (order == 1) ? 2 : 1; // why?? - int n = collect.getLength(); - for (int i = 0; i < n; ++i) { - Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashMapStringKeyCollections.fieldSpecs[i]); - Vector key = TestUtil.makeNewVectorInstance((String) fieldSpecs.get(0), keyOrder); - Vector value = TestUtil.makeNewVectorInstance((String) fieldSpecs.get(1), valueOrder); - - HashMap map = new HashMap(); - for (int j = 0; j < key.size(); j++) { - map.put(key.get(j), value.get(j)); - } - collect.set(i, map); - if (debug) logger.debug("Set " + i + "th value to: " + map.toString()); + /** */ + private void setValues(HashMapStringKeyCollections collect, int order) + { + int keyOrder = order; + int valueOrder = (order == 1) ? 2 : 1; // why?? + int n = collect.getLength(); + for (int i = 0; i < n; ++i) { + Vector fieldSpecs = TestUtil.getFieldSpecsForMap( + HashMapStringKeyCollections.fieldSpecs[i]); + Vector key = TestUtil.makeNewVectorInstance( + (String)fieldSpecs.get(0), keyOrder); + Vector value = TestUtil.makeNewVectorInstance( + (String)fieldSpecs.get(1), valueOrder); + + HashMap map = new HashMap(); + for (int j = 0; j< key.size(); j++) { + map.put(key.get(j), value.get(j)); + } + collect.set(i, map); + if (debug) + logger.debug("Set " + i + "th value to: " + map.toString()); + } } - } - - /** */ - private void checkValues(Object oid, HashMapStringKeyCollections expectedValue) { - StringBuffer sbuf = new StringBuffer(); - HashMapStringKeyCollections pi = (HashMapStringKeyCollections) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (int i = 0; i < n; ++i) { - HashMap expected = expectedValue.get(i); - HashMap actual = pi.get(i); - if (actual.size() != expected.size()) { - sbuf.append( - "\nFor element " - + i - + ", expected size = " - + expected.size() - + ", actual size = " - + actual.size() - + " . "); - } else if (!expected.equals(actual)) { - if (TestUtil.getFieldSpecsForMap(HashMapStringKeyCollections.fieldSpecs[i]) - .get(1) - .equals("BigDecimal")) { - Set keys = expected.keySet(); - Iterator iter = keys.iterator(); - while (iter.hasNext()) { - Object nextKey = iter.next(); - BigDecimal expectedMapValue = (BigDecimal) expected.get(nextKey); - BigDecimal actualMapValue = (BigDecimal) actual.get(nextKey); - if ((expectedMapValue.compareTo(actualMapValue) != 0)) { - sbuf.append( - "\nFor element " - + i - + "(" - + (String) nextKey - + "), expected = " - + expectedMapValue - + ", actual = " - + actualMapValue - + " . "); + + /** */ + private void checkValues(Object oid, + HashMapStringKeyCollections expectedValue) + { + StringBuffer sbuf = new StringBuffer(); + HashMapStringKeyCollections pi = (HashMapStringKeyCollections) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for (int i = 0; i < n; ++i) { + HashMap expected = expectedValue.get(i); + HashMap actual = pi.get(i); + if (actual.size() != expected.size()) { + sbuf.append("\nFor element " + i + ", expected size = " + + expected.size() + ", actual size = " + actual.size() + + " . "); + } + else if (! expected.equals(actual)) { + if (TestUtil.getFieldSpecsForMap( + HashMapStringKeyCollections.fieldSpecs[i] + ).get(1).equals("BigDecimal")) { + Set keys = expected.keySet(); + Iterator iter = keys.iterator(); + while (iter.hasNext()) { + Object nextKey = iter.next(); + BigDecimal expectedMapValue = + (BigDecimal)expected.get(nextKey); + BigDecimal actualMapValue = + (BigDecimal)actual.get(nextKey); + if ((expectedMapValue.compareTo(actualMapValue) != 0)) { + sbuf.append("\nFor element " + i + "(" + + (String)nextKey + + "), expected = " + expectedMapValue + + ", actual = " + actualMapValue + " . "); + } + } + } + else { + sbuf.append("\nFor element " + i + ", expected = " + + expected + ", actual = " + actual + " . "); } } - } else { - sbuf.append( - "\nFor element " + i + ", expected = " + expected + ", actual = " + actual + " . "); } - } - } - if (sbuf.length() > 0) { - fail(ASSERTION_FAILED, "Expected and observed do not match!!" + sbuf.toString()); + if (sbuf.length() > 0) { + fail(ASSERTION_FAILED, + "Expected and observed do not match!!" + sbuf.toString()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringValueCollections.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringValueCollections.java index 7303bfd56..eb1a56e0d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringValueCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestHashMapStringValueCollections.java @@ -5,196 +5,207 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.math.BigDecimal; + import java.util.HashMap; import java.util.Iterator; import java.util.Set; import java.util.Vector; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.HashMapStringValueCollections; import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type HashMap, varying key type
    - * Keywords: model
    - * Assertion ID: A6.4.3-24.
    - * Assertion Description: If the HashMap optional feature is supported, then JDO - * implementation must support fields of the mutable object class HashMap, supporting - * them as Second Class Objects or First Class Objects. + *Title: Support of field type HashMap, varying key type + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-24. + *
    + *Assertion Description: +If the HashMap optional feature is supported, then JDO implementation must +support fields of the mutable object class HashMap, +supporting them as Second Class Objects or First Class Objects. */ + public class TestHashMapStringValueCollections extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-24 (TestHashMapStringValueCollections) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestHashMapStringValueCollections.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(HashMapStringValueCollections.class); - addTearDownClass(SimpleClass.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTest(pm); - - pm.close(); - pm = null; - } - - /** */ - void runTest(PersistenceManager pm) { - if (!isHashMapSupported()) { - if (debug) - logger.debug("JDO Implementation does not support " + "the optional feature HashMap"); - return; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-24 (TestHashMapStringValueCollections) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestHashMapStringValueCollections.class); } - Transaction tx = pm.currentTransaction(); - HashMapStringValueCollections expectedValue = new HashMapStringValueCollections(); - - // turn on datastore transactions - tx.setOptimistic(false); - tx.begin(); - HashMapStringValueCollections pi = new HashMapStringValueCollections(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - // Provide initial set of values - setValues(pi, 1); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - setValues(expectedValue, 1); - checkValues(oid, expectedValue); - pi = (HashMapStringValueCollections) pm.getObjectById(oid, true); - // Provide new set of values -- reverse the keys and values - setValues(pi, 2); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - setValues(expectedValue, 2); - checkValues(oid, expectedValue); - pi = (HashMapStringValueCollections) pm.getObjectById(oid, true); - tx.commit(); - } - - /** */ - private void setValues(HashMapStringValueCollections collect, int order) { - int keyOrder = order; - int valueOrder = (order == 1) ? 2 : 1; // why?? - int n = collect.getLength(); - for (int i = 0; i < n; ++i) { - Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashMapStringValueCollections.fieldSpecs[i]); - Vector key = TestUtil.makeNewVectorInstance((String) fieldSpecs.get(0), keyOrder); - Vector value = TestUtil.makeNewVectorInstance((String) fieldSpecs.get(1), valueOrder); - - HashMap map = new HashMap(); - for (int j = 0; j < key.size(); j++) { - map.put(key.get(j), value.get(j)); - } - collect.set(i, map); - if (debug) logger.debug("Set " + i + "th value to: " + map.toString()); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(HashMapStringValueCollections.class); + addTearDownClass(SimpleClass.class); } - } - - /** */ - private void checkValues(Object oid, HashMapStringValueCollections expectedValue) { - StringBuffer sbuf = new StringBuffer(); - HashMapStringValueCollections pi = (HashMapStringValueCollections) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (int i = 0; i < n; ++i) { - HashMap expected = expectedValue.get(i); - HashMap actual = pi.get(i); - if (actual.size() != expected.size()) { - sbuf.append( - "\nFor element " - + i - + ", expected size = " - + expected.size() - + ", actual size = " - + actual.size() - + " . "); - } else if (!expected.equals(actual)) { - if (TestUtil.getFieldSpecsForMap(HashMapStringValueCollections.fieldSpecs[i]) - .get(0) - .equals("BigDecimal")) { - Set expectedKeySet = expected.keySet(); - Set actualKeySet = actual.keySet(); - Iterator expectedIter = expectedKeySet.iterator(); - while (expectedIter.hasNext()) { - BigDecimal expectedKey = (BigDecimal) expectedIter.next(); - // compare keys - if (!TestUtil.containsBigDecimalKey(expectedKey, actualKeySet)) { - sbuf.append( - "\nFor element " - + i - + " expected key = " - + expectedKey - + " not found in actual Map. Actual keyset is " - + actualKeySet.toString()); - // compare values - } else { - String expectedVal = (String) expected.get(expectedKey); - String actualValue = - (String) actual.get(TestUtil.getBigDecimalKey(expectedKey, actualKeySet)); - if (!expectedVal.equals(actualValue)) { - sbuf.append( - "\nFor element " - + i - + " expected value = " - + expectedVal - + " actual Value = " - + actualValue); - } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + if (!isHashMapSupported()) { + if (debug) + logger.debug("JDO Implementation does not support " + + "the optional feature HashMap"); + return; + } + + Transaction tx = pm.currentTransaction(); + HashMapStringValueCollections expectedValue = + new HashMapStringValueCollections(); + + // turn on datastore transactions + tx.setOptimistic(false); + tx.begin(); + HashMapStringValueCollections pi = new HashMapStringValueCollections(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + // Provide initial set of values + setValues(pi, 1); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + setValues(expectedValue, 1); + checkValues(oid, expectedValue); + pi = (HashMapStringValueCollections) pm.getObjectById(oid, true); + // Provide new set of values -- reverse the keys and values + setValues(pi, 2); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + setValues(expectedValue, 2); + checkValues(oid, expectedValue); + pi = (HashMapStringValueCollections) pm.getObjectById(oid, true); + tx.commit(); + } + + /** */ + private void setValues(HashMapStringValueCollections collect, int order) + { + int keyOrder = order; + int valueOrder = (order == 1) ? 2 : 1; // why?? + int n = collect.getLength(); + for (int i = 0; i < n; ++i) { + Vector fieldSpecs = TestUtil.getFieldSpecsForMap( + HashMapStringValueCollections.fieldSpecs[i]); + Vector key = TestUtil.makeNewVectorInstance( + (String)fieldSpecs.get(0), keyOrder); + Vector value = TestUtil.makeNewVectorInstance( + (String)fieldSpecs.get(1), valueOrder); + + HashMap map = new HashMap(); + for (int j = 0; j< key.size(); j++) { + map.put(key.get(j), value.get(j)); } - } - } else { - sbuf.append( - "\nFor element " + i + ", expected = " + expected + ", actual = " + actual + " . "); + collect.set(i, map); + if (debug) + logger.debug("Set " + i + "th value to: " + map.toString()); } - } } - if (sbuf.length() > 0) { - fail(ASSERTION_FAILED, "Expected and observed do not match!!" + sbuf.toString()); + + /** */ + private void checkValues(Object oid, + HashMapStringValueCollections expectedValue) + { + StringBuffer sbuf = new StringBuffer(); + HashMapStringValueCollections pi = (HashMapStringValueCollections) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for (int i = 0; i < n; ++i) { + HashMap expected = expectedValue.get(i); + HashMap actual = pi.get(i); + if (actual.size() != expected.size()) { + sbuf.append("\nFor element " + i + ", expected size = " + + expected.size() + ", actual size = " + actual.size() + + " . "); + } + else if (! expected.equals(actual)) { + if (TestUtil.getFieldSpecsForMap( + HashMapStringValueCollections.fieldSpecs[i] + ).get(0).equals("BigDecimal")) { + Set expectedKeySet = expected.keySet(); + Set actualKeySet = actual.keySet(); + Iterator expectedIter = expectedKeySet.iterator(); + while (expectedIter.hasNext()) { + BigDecimal expectedKey = (BigDecimal) expectedIter.next(); + // compare keys + if (!TestUtil.containsBigDecimalKey(expectedKey, actualKeySet)) { + sbuf.append("\nFor element " + i + + " expected key = " + expectedKey + + " not found in actual Map. Actual keyset is " + + actualKeySet.toString()); + // compare values + } else { + String expectedVal = (String) expected.get(expectedKey); + String actualValue = (String) + actual.get(TestUtil.getBigDecimalKey(expectedKey, + actualKeySet)); + if (!expectedVal.equals(actualValue)) { + sbuf.append("\nFor element " + i + + " expected value = " + expectedVal + + " actual Value = " + actualValue); + } + } + } + } + else { + sbuf.append("\nFor element " + i + ", expected = " + + expected + ", actual = " + actual + " . "); + } + } + } + if (sbuf.length() > 0) { + fail(ASSERTION_FAILED, + "Expected and observed do not match!!" + sbuf.toString()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestHashSetCollections.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestHashSetCollections.java index fb394230c..979e87ace 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestHashSetCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestHashSetCollections.java @@ -5,174 +5,186 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.math.BigDecimal; + import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.TreeSet; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.HashSetCollections; import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type HashSet
    - * Keywords: model
    - * Assertion ID: A6.4.3-22.
    - * Assertion Description: JDO implementations must support fields of the mutable object - * class java.util.HashSet, and may choose to support them as Second Class Objects or - * First Class Objects. + *Title: Support of field type HashSet + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-22. + *
    + *Assertion Description: +JDO implementations must support fields of the mutable object class +java.util.HashSet, and may choose to support them as +Second Class Objects or First Class Objects. */ + + public class TestHashSetCollections extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-22 (TestHashSetCollections) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestHashSetCollections.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(HashSetCollections.class); - addTearDownClass(SimpleClass.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTest(pm); - - pm.close(); - pm = null; - } - - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - HashSetCollections expectedValue = new HashSetCollections(); - - // turn on datastore transactions - tx.setOptimistic(false); - tx.begin(); - HashSetCollections pi = new HashSetCollections(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - // Provide initial set of values - setValues(pi, 1); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - setValues(expectedValue, 1); - checkValues(oid, expectedValue); - pi = (HashSetCollections) pm.getObjectById(oid, true); - // Provide new set of values - setValues(pi, 2); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - setValues(expectedValue, 2); - checkValues(oid, expectedValue); - pi = (HashSetCollections) pm.getObjectById(oid, true); - tx.commit(); - } - - /** */ - private void setValues(HashSetCollections collect, int order) { - Collection value; - int n = collect.getLength(); - for (int i = 0; i < n; ++i) { - String valueType = TestUtil.getFieldSpecs(HashSetCollections.fieldSpecs[i]); - value = (Collection) TestUtil.makeNewVectorInstance(valueType, order); - HashSet lvalue = new HashSet(value); - collect.set(i, lvalue); - if (debug) logger.debug("Set " + i + "th value to: " + value.toString()); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-22 (TestHashSetCollections) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestHashSetCollections.class); } - } - - /** */ - private void checkValues(Object oid, HashSetCollections expectedValue) { - int i; - StringBuffer sbuf = new StringBuffer(); - HashSetCollections pi = (HashSetCollections) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - HashSet expected = expectedValue.get(i); - HashSet actual = pi.get(i); - if (actual.size() != expected.size()) { - sbuf.append( - "\nFor element " - + i - + ", expected size = " - + expected.size() - + ", actual size = " - + actual.size() - + " . "); - } else if (!expected.equals(actual)) { - if (TestUtil.getFieldSpecs(HashSetCollections.fieldSpecs[i]).equals("BigDecimal")) { - // sort values for comparison - TreeSet expectedTS = new TreeSet(expected); - TreeSet actualTS = new TreeSet(actual); - Iterator expectedIter = expectedTS.iterator(); - Iterator actualIter = actualTS.iterator(); - for (int j = 0; j < expectedTS.size(); j++) { - BigDecimal bigDecExpected = (BigDecimal) (expectedIter.next()); - BigDecimal bigDecActual = (BigDecimal) (actualIter.next()); - bigDecActual.setScale(bigDecExpected.scale()); - if ((bigDecExpected.compareTo(bigDecActual)) != 0) { - sbuf.append( - "\nFor element " - + i - + "(" - + j - + "), expected = " - + bigDecExpected - + ", actual = " - + bigDecActual); - } - } - } else { - sbuf.append( - "\nFor element " + i + ", expected = " + expected + ", actual = " + actual + " . "); + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(HashSetCollections.class); + addTearDownClass(SimpleClass.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + Transaction tx = pm.currentTransaction(); + HashSetCollections expectedValue = new HashSetCollections(); + + // turn on datastore transactions + tx.setOptimistic(false); + tx.begin(); + HashSetCollections pi = new HashSetCollections(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + // Provide initial set of values + setValues(pi, 1); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + setValues(expectedValue, 1); + checkValues(oid, expectedValue); + pi = (HashSetCollections) pm.getObjectById(oid, true); + // Provide new set of values + setValues(pi, 2); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + setValues(expectedValue, 2); + checkValues(oid, expectedValue); + pi = (HashSetCollections) pm.getObjectById(oid, true); + tx.commit(); + } + + /** */ + private void setValues(HashSetCollections collect, int order) + { + Collection value; + int n = collect.getLength(); + for (int i = 0; i < n; ++i) { + String valueType = TestUtil.getFieldSpecs( + HashSetCollections.fieldSpecs[i]); + value = (Collection)TestUtil.makeNewVectorInstance( + valueType, order); + HashSet lvalue = new HashSet(value); + collect.set(i, lvalue); + if (debug) + logger.debug("Set " + i + "th value to: " + value.toString()); } - } } - if (sbuf.length() > 0) { - fail(ASSERTION_FAILED, "Expected and observed do not match!!" + sbuf.toString()); + + /** */ + private void checkValues(Object oid, HashSetCollections expectedValue) + { + int i; + StringBuffer sbuf = new StringBuffer(); + HashSetCollections pi = (HashSetCollections) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for (i = 0; i < n; ++i) { + HashSet expected = expectedValue.get(i); + HashSet actual = pi.get(i); + if (actual.size() != expected.size()) { + sbuf.append("\nFor element " + i + ", expected size = " + + expected.size() + ", actual size = " + actual.size() + + " . "); + } + else if (! expected.equals(actual)) { + if (TestUtil.getFieldSpecs(HashSetCollections.fieldSpecs[i] + ).equals("BigDecimal")) { + // sort values for comparison + TreeSet expectedTS = new TreeSet(expected); + TreeSet actualTS = new TreeSet(actual); + Iterator expectedIter = expectedTS.iterator(); + Iterator actualIter = actualTS.iterator(); + for (int j=0; j < expectedTS.size(); j++) { + BigDecimal bigDecExpected = + (BigDecimal)(expectedIter.next()); + BigDecimal bigDecActual = + (BigDecimal)(actualIter.next()); + bigDecActual.setScale(bigDecExpected.scale()); + if ((bigDecExpected.compareTo(bigDecActual)) != 0) { + sbuf.append("\nFor element " + i + "(" + j + + "), expected = " + bigDecExpected + + ", actual = " + bigDecActual); + } + } + } + else { + sbuf.append("\nFor element " + i + ", expected = " + + expected + ", actual = " + actual + " . "); + } + + } + } + if (sbuf.length() > 0) { + fail(ASSERTION_FAILED, + "Expected and observed do not match!!" + sbuf.toString()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringKeyCollections.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringKeyCollections.java index fbdf9d5de..d4993edc7 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringKeyCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringKeyCollections.java @@ -5,184 +5,200 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.math.BigDecimal; + import java.util.Hashtable; import java.util.Iterator; +import java.util.List; import java.util.Set; import java.util.Vector; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.HashtableStringKeyCollections; import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type Hashtable, varying value type
    - * Keywords: model
    - * Assertion ID: A6.4.3-25.
    - * Assertion Description: If the Hashtable optional feature is supported, then JDO - * implementation must support fields of the mutable object class Hashtable, supporting - * them as Second Class Objects or First Class Objects. + *Title: Support of field type Hashtable, varying value type + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-25. + *
    + *Assertion Description: +If the Hashtable optional feature is supported, then JDO implementation must +support fields of the mutable object class Hashtable, +supporting them as Second Class Objects or First Class Objects. */ + + public class TestHashtableStringKeyCollections extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-25 (TestHashtableStringKeyCollections) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestHashtableStringKeyCollections.class); + } - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-25 (TestHashtableStringKeyCollections) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestHashtableStringKeyCollections.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(HashtableStringKeyCollections.class); - addTearDownClass(SimpleClass.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTest(pm); - - pm.close(); - pm = null; - } - - /** */ - void runTest(PersistenceManager pm) { - if (!isHashtableSupported()) { - if (debug) - logger.debug("JDO Implementation does not support " + "the optional feature Hashtable"); - return; + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(HashtableStringKeyCollections.class); + addTearDownClass(SimpleClass.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + if (!isHashtableSupported()) { + if (debug) + logger.debug("JDO Implementation does not support " + + "the optional feature Hashtable"); + return; + } + + Transaction tx = pm.currentTransaction(); + HashtableStringKeyCollections expectedValue = + new HashtableStringKeyCollections(); + + // turn on datastore transactions + tx.setOptimistic(false); + tx.begin(); + HashtableStringKeyCollections pi = + new HashtableStringKeyCollections(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + // Provide initial set of values + setValues(pi, 1); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + setValues(expectedValue, 1); + checkValues(oid, expectedValue); + pi = (HashtableStringKeyCollections) pm.getObjectById(oid, true); + // Provide new set of values -- reverse the keys and values + setValues(pi, 2); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + setValues(expectedValue, 2); + // check new values + checkValues(oid, expectedValue); + tx.commit(); } - Transaction tx = pm.currentTransaction(); - HashtableStringKeyCollections expectedValue = new HashtableStringKeyCollections(); - - // turn on datastore transactions - tx.setOptimistic(false); - tx.begin(); - HashtableStringKeyCollections pi = new HashtableStringKeyCollections(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - // Provide initial set of values - setValues(pi, 1); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - setValues(expectedValue, 1); - checkValues(oid, expectedValue); - pi = (HashtableStringKeyCollections) pm.getObjectById(oid, true); - // Provide new set of values -- reverse the keys and values - setValues(pi, 2); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - setValues(expectedValue, 2); - // check new values - checkValues(oid, expectedValue); - tx.commit(); - } - - /** */ - private void setValues(HashtableStringKeyCollections collect, int order) { - int keyOrder = order; - int valueOrder = (order == 1) ? 2 : 1; // why?? - int n = collect.getLength(); - for (int i = 0; i < n; ++i) { - Vector fieldSpecs = TestUtil.getFieldSpecsForMap(HashtableStringKeyCollections.fieldSpecs[i]); - Vector key = TestUtil.makeNewVectorInstance((String) fieldSpecs.get(0), keyOrder); - Vector value = TestUtil.makeNewVectorInstance((String) fieldSpecs.get(1), valueOrder); - - Hashtable map = new Hashtable(); - for (int j = 0; j < key.size(); j++) { - map.put(key.get(j), value.get(j)); - } - collect.set(i, map); - if (debug) logger.debug("Set " + i + "th value to: " + map.toString()); + /** */ + private void setValues(HashtableStringKeyCollections collect, int order) + { + int keyOrder = order; + int valueOrder = (order == 1) ? 2 : 1; // why?? + int n = collect.getLength(); + for (int i = 0; i < n; ++i) { + Vector fieldSpecs = TestUtil.getFieldSpecsForMap( + HashtableStringKeyCollections.fieldSpecs[i]); + Vector key = TestUtil.makeNewVectorInstance( + (String)fieldSpecs.get(0), keyOrder); + Vector value = TestUtil.makeNewVectorInstance( + (String)fieldSpecs.get(1), valueOrder); + + Hashtable map = new Hashtable(); + for (int j = 0; j< key.size(); j++) { + map.put(key.get(j), value.get(j)); + } + collect.set(i, map); + if (debug) + logger.debug("Set " + i + "th value to: " + map.toString()); + } } - } - - /** */ - private void checkValues(Object oid, HashtableStringKeyCollections expectedValue) { - StringBuffer sbuf = new StringBuffer(); - HashtableStringKeyCollections pi = (HashtableStringKeyCollections) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (int i = 0; i < n; ++i) { - Hashtable expected = expectedValue.get(i); - Hashtable actual = pi.get(i); - if (actual.size() != expected.size()) { - sbuf.append( - "\nFor element " - + i - + ", expected size = " - + expected.size() - + ", actual size = " - + actual.size() - + " . "); - } else if (!expected.equals(actual)) { - if (TestUtil.getFieldSpecsForMap(HashtableStringKeyCollections.fieldSpecs[i]) - .get(1) - .equals("BigDecimal")) { - Set keys = expected.keySet(); - Iterator iter = keys.iterator(); - while (iter.hasNext()) { - Object nextKey = iter.next(); - BigDecimal expectedMapValue = (BigDecimal) expected.get(nextKey); - BigDecimal actualMapValue = (BigDecimal) actual.get(nextKey); - if ((expectedMapValue.compareTo(actualMapValue) != 0)) { - sbuf.append( - "\nFor element " - + i - + "(" - + (String) nextKey - + "), expected = " - + expectedMapValue - + ", actual = " - + actualMapValue - + " . "); + + /** */ + private void checkValues(Object oid, + HashtableStringKeyCollections expectedValue) + { + StringBuffer sbuf = new StringBuffer(); + HashtableStringKeyCollections pi = (HashtableStringKeyCollections) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for (int i = 0; i < n; ++i) { + Hashtable expected = expectedValue.get(i); + Hashtable actual = pi.get(i); + if (actual.size() != expected.size()) { + sbuf.append("\nFor element " + i + ", expected size = " + + expected.size() + ", actual size = " + actual.size() + + " . "); + } + else if (! expected.equals(actual)) { + if (TestUtil.getFieldSpecsForMap( + HashtableStringKeyCollections.fieldSpecs[i] + ).get(1).equals("BigDecimal")) { + Set keys = expected.keySet(); + Iterator iter = keys.iterator(); + while (iter.hasNext()) { + Object nextKey = iter.next(); + BigDecimal expectedMapValue = + (BigDecimal)expected.get(nextKey); + BigDecimal actualMapValue = + (BigDecimal)actual.get(nextKey); + if ((expectedMapValue.compareTo(actualMapValue) != 0)) { + sbuf.append("\nFor element " + i + "(" + + (String)nextKey + + "), expected = " + expectedMapValue + + ", actual = " + actualMapValue + " . "); + } + } + } + else { + sbuf.append("\nFor element " + i + ", expected = " + + expected + ", actual = " + actual + " . "); } } - } else { - sbuf.append( - "\nFor element " + i + ", expected = " + expected + ", actual = " + actual + " . "); } - } - } - if (sbuf.length() > 0) { - fail(ASSERTION_FAILED, "Expected and observed do not match!!" + sbuf.toString()); + if (sbuf.length() > 0) { + fail(ASSERTION_FAILED, + "Expected and observed do not match!!" + sbuf.toString()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringValueCollections.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringValueCollections.java index e66d46461..cd8ce029f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringValueCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestHashtableStringValueCollections.java @@ -5,196 +5,206 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.math.BigDecimal; + import java.util.Hashtable; import java.util.Iterator; import java.util.Set; import java.util.Vector; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.HashtableStringValueCollections; import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type Hashtable, varying key type
    - * Keywords: model
    - * Assertion ID: A6.4.3-25.
    - * Assertion Description: If the Hashtable optional feature is supported, then JDO - * implementation must support fields of the mutable object class Hashtable, supporting - * them as Second Class Objects or First Class Objects. + *Title: Support of field type Hashtable, varying key type + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-25. + *
    + *Assertion Description: +If the Hashtable optional feature is supported, then JDO implementation must +support fields of the mutable object class Hashtable, +supporting them as Second Class Objects or First Class Objects. */ + + public class TestHashtableStringValueCollections extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-25 (TestHashtableStringValueCollections) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestHashtableStringValueCollections.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(HashtableStringValueCollections.class); - addTearDownClass(SimpleClass.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTest(pm); - - pm.close(); - pm = null; - } - - /** */ - void runTest(PersistenceManager pm) { - if (!isHashtableSupported()) { - if (debug) - logger.debug("JDO Implementation does not support " + "the optional feature Hashtable"); - return; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-25 (TestHashtableStringValueCollections) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestHashtableStringValueCollections.class); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(HashtableStringValueCollections.class); + addTearDownClass(SimpleClass.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) { + if (!isHashtableSupported()) { + if (debug) + logger.debug("JDO Implementation does not support " + + "the optional feature Hashtable"); + return; + } + + Transaction tx = pm.currentTransaction(); + HashtableStringValueCollections expectedValue = + new HashtableStringValueCollections(); + + // turn on datastore transactions + tx.setOptimistic(false); + tx.begin(); + HashtableStringValueCollections pi = + new HashtableStringValueCollections(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + // Provide initial set of values + setValues(pi, 1); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + setValues(expectedValue, 1); + checkValues(oid, expectedValue); + pi = (HashtableStringValueCollections) pm.getObjectById(oid, true); + setValues(pi, 2); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + setValues(expectedValue, 2); + checkValues(oid, expectedValue); + tx.commit(); } - Transaction tx = pm.currentTransaction(); - HashtableStringValueCollections expectedValue = new HashtableStringValueCollections(); - - // turn on datastore transactions - tx.setOptimistic(false); - tx.begin(); - HashtableStringValueCollections pi = new HashtableStringValueCollections(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - // Provide initial set of values - setValues(pi, 1); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - setValues(expectedValue, 1); - checkValues(oid, expectedValue); - pi = (HashtableStringValueCollections) pm.getObjectById(oid, true); - setValues(pi, 2); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - setValues(expectedValue, 2); - checkValues(oid, expectedValue); - tx.commit(); - } - - /** */ - private void setValues(HashtableStringValueCollections collect, int order) { - int keyOrder = order; - int valueOrder = (order == 1) ? 2 : 1; // why?? - int n = collect.getLength(); - for (int i = 0; i < n; ++i) { - Vector fieldSpecs = - TestUtil.getFieldSpecsForMap(HashtableStringValueCollections.fieldSpecs[i]); - Vector key = TestUtil.makeNewVectorInstance((String) fieldSpecs.get(0), keyOrder); - Vector value = TestUtil.makeNewVectorInstance((String) fieldSpecs.get(1), valueOrder); - - Hashtable map = new Hashtable(); - for (int j = 0; j < key.size(); j++) { - map.put(key.get(j), value.get(j)); - } - collect.set(i, map); - if (debug) logger.debug("Set " + i + "th value to: " + map.toString()); + /** */ + private void setValues(HashtableStringValueCollections collect, int order) + { + int keyOrder = order; + int valueOrder = (order == 1) ? 2 : 1; // why?? + int n = collect.getLength(); + for (int i = 0; i < n; ++i) { + Vector fieldSpecs = TestUtil.getFieldSpecsForMap( + HashtableStringValueCollections.fieldSpecs[i]); + Vector key = TestUtil.makeNewVectorInstance( + (String)fieldSpecs.get(0), keyOrder); + Vector value = TestUtil.makeNewVectorInstance( + (String)fieldSpecs.get(1), valueOrder); + + Hashtable map = new Hashtable(); + for (int j = 0; j< key.size(); j++) { + map.put(key.get(j), value.get(j)); + } + collect.set(i, map); + if (debug) + logger.debug("Set " + i + "th value to: " + map.toString()); + } } - } - - /** */ - private void checkValues(Object oid, HashtableStringValueCollections expectedValue) { - StringBuffer sbuf = new StringBuffer(); - HashtableStringValueCollections pi = - (HashtableStringValueCollections) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (int i = 0; i < n; ++i) { - Hashtable expected = expectedValue.get(i); - Hashtable actual = pi.get(i); - if (actual.size() != expected.size()) { - sbuf.append( - "\nFor element " - + i - + ", expected size = " - + expected.size() - + ", actual size = " - + actual.size() - + " . "); - } else if (!expected.equals(actual)) { - if (TestUtil.getFieldSpecsForMap(HashtableStringValueCollections.fieldSpecs[i]) - .get(0) - .equals("BigDecimal")) { - Set expectedKeySet = expected.keySet(); - Set actualKeySet = actual.keySet(); - Iterator expectedIter = expectedKeySet.iterator(); - while (expectedIter.hasNext()) { - BigDecimal expectedKey = (BigDecimal) expectedIter.next(); - // compare keys - if (!TestUtil.containsBigDecimalKey(expectedKey, actualKeySet)) { - sbuf.append( - "\nFor element " - + i - + " expected key = " - + expectedKey - + " not found in actual Map. Actual keyset is " - + actualKeySet.toString()); - // compare values - } else { - String expectedVal = (String) expected.get(expectedKey); - String actualValue = - (String) actual.get(TestUtil.getBigDecimalKey(expectedKey, actualKeySet)); - if (!expectedVal.equals(actualValue)) { - sbuf.append( - "\nFor element " - + i - + " expected value = " - + expectedVal - + " actual Value = " - + actualValue); - } + + /** */ + private void checkValues(Object oid, + HashtableStringValueCollections expectedValue) + { + StringBuffer sbuf = new StringBuffer(); + HashtableStringValueCollections pi = (HashtableStringValueCollections) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for (int i = 0; i < n; ++i) { + Hashtable expected = expectedValue.get(i); + Hashtable actual = pi.get(i); + if (actual.size() != expected.size()) { + sbuf.append("\nFor element " + i + ", expected size = " + + expected.size() + ", actual size = " + actual.size() + + " . "); + } + else if (! expected.equals(actual)) { + if (TestUtil.getFieldSpecsForMap( + HashtableStringValueCollections.fieldSpecs[i] + ).get(0).equals("BigDecimal")) { + Set expectedKeySet = expected.keySet(); + Set actualKeySet = actual.keySet(); + Iterator expectedIter = expectedKeySet.iterator(); + while (expectedIter.hasNext()) { + BigDecimal expectedKey = (BigDecimal) expectedIter.next(); + // compare keys + if (!TestUtil.containsBigDecimalKey(expectedKey, actualKeySet)) { + sbuf.append("\nFor element " + i + + " expected key = " + expectedKey + + " not found in actual Map. Actual keyset is " + + actualKeySet.toString()); + // compare values + } else { + String expectedVal = (String) expected.get(expectedKey); + String actualValue = (String) + actual.get(TestUtil.getBigDecimalKey(expectedKey, + actualKeySet)); + if (!expectedVal.equals(actualValue)) { + sbuf.append("\nFor element " + i + + " expected value = " + expectedVal + + " actual Value = " + actualValue); + } + } + } + } + else { + sbuf.append("\nFor element " + i + ", expected = " + + expected + ", actual = " + actual + " . "); } } - } else { - sbuf.append( - "\nFor element " + i + ", expected = " + expected + ", actual = " + actual + " . "); } - } - } - if (sbuf.length() > 0) { - fail(ASSERTION_FAILED, "Expected and observed do not match!!" + sbuf.toString()); + if (sbuf.length() > 0) { + fail(ASSERTION_FAILED, + "Expected and observed do not match!!" + sbuf.toString()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestLinkedListCollections.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestLinkedListCollections.java index 5de616c0f..22517ce5c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestLinkedListCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestLinkedListCollections.java @@ -5,177 +5,188 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.math.BigDecimal; + import java.util.Collection; -import java.util.LinkedList; import java.util.ListIterator; +import java.util.LinkedList; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.LinkedListCollections; import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type LinkedList
    - * Keywords: model
    - * Assertion ID: A6.4.3-26.
    - * Assertion Description: If the LinkedList optional feature is supported, then JDO - * implementation must support fields of the mutable object class LinkedList, - * supporting them as Second Class Objects or First Class Objects. + *Title: Support of field type LinkedList + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-26. + *
    + *Assertion Description: +If the LinkedList optional feature is supported, then JDO implementation +must support fields of the mutable object class LinkedList, +supporting them as Second Class Objects or First Class Objects. */ -public class TestLinkedListCollections extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-26 (TestLinkedListCollections) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestLinkedListCollections.class); - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(LinkedListCollections.class); - addTearDownClass(SimpleClass.class); - } - /** */ - public void test() { - pm = getPM(); - - runTest(pm); - - pm.close(); - pm = null; - } +public class TestLinkedListCollections extends JDO_Test { - /** */ - void runTest(PersistenceManager pm) { - if (!isLinkedListSupported()) { - if (debug) - logger.debug("JDO Implementation does not support " + "the optional feature LinkedList"); - return; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-26 (TestLinkedListCollections) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestLinkedListCollections.class); } - Transaction tx = pm.currentTransaction(); - LinkedListCollections expectedValue = new LinkedListCollections(); - - // turn on datastore transactions - tx.setOptimistic(false); - tx.begin(); - LinkedListCollections pi = new LinkedListCollections(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - // Provide initial set of values - setValues(pi, 1); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - setValues(expectedValue, 1); - // check if persistent fields have values set - checkValues(oid, expectedValue); - pi = (LinkedListCollections) pm.getObjectById(oid, true); - // Provide new set of values - setValues(pi, 2); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - setValues(expectedValue, 2); - checkValues(oid, expectedValue); - tx.commit(); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(LinkedListCollections.class); + addTearDownClass(SimpleClass.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + if (!isLinkedListSupported()) { + if (debug) + logger.debug("JDO Implementation does not support " + + "the optional feature LinkedList"); + return; + } + + Transaction tx = pm.currentTransaction(); + LinkedListCollections expectedValue = new LinkedListCollections(); + + // turn on datastore transactions + tx.setOptimistic(false); + tx.begin(); + LinkedListCollections pi = new LinkedListCollections(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + // Provide initial set of values + setValues(pi, 1); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + setValues(expectedValue, 1); + // check if persistent fields have values set + checkValues(oid, expectedValue); + pi = (LinkedListCollections) pm.getObjectById(oid, true); + // Provide new set of values + setValues(pi, 2); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + setValues(expectedValue, 2); + checkValues(oid, expectedValue); + tx.commit(); + } - /** */ - private void setValues(LinkedListCollections collect, int order) { - Collection value; - int n = collect.getLength(); - for (int i = 0; i < n; ++i) { - String valueType = TestUtil.getFieldSpecs(LinkedListCollections.fieldSpecs[i]); - value = (Collection) TestUtil.makeNewVectorInstance(valueType, order); - LinkedList lvalue = new LinkedList(value); - collect.set(i, lvalue); - if (debug) logger.debug("Set " + i + "th value to: " + value.toString()); + /** */ + private void setValues(LinkedListCollections collect, int order) + { + Collection value; + int n = collect.getLength(); + for (int i = 0; i < n; ++i) { + String valueType = TestUtil.getFieldSpecs( + LinkedListCollections.fieldSpecs[i]); + value = (Collection)TestUtil.makeNewVectorInstance( + valueType, order); + LinkedList lvalue = new LinkedList(value); + collect.set(i, lvalue); + if (debug) + logger.debug("Set " + i + "th value to: " + value.toString()); + } } - } - /** */ - private void checkValues(Object oid, LinkedListCollections expectedValue) { - int i; - StringBuffer sbuf = new StringBuffer(); - LinkedListCollections pi = (LinkedListCollections) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - LinkedList expected = expectedValue.get(i); - LinkedList actual = pi.get(i); - if (actual.size() != expected.size()) { - sbuf.append( - "\nFor element " - + i - + ", expected size = " - + expected.size() - + ", actual size = " - + actual.size() - + " . "); - } else if (!expected.equals(actual)) { - if (TestUtil.getFieldSpecs(LinkedListCollections.fieldSpecs[i]).equals("BigDecimal")) { - ListIterator expectedIT = expected.listIterator(); - ListIterator actualIt = actual.listIterator(); - int index = 0; - while (expectedIT.hasNext()) { - BigDecimal bigDecExpected = (BigDecimal) (expectedIT.next()); - BigDecimal bigDecActual = (BigDecimal) (actualIt.next()); - if ((bigDecExpected.compareTo(bigDecActual)) != 0) { - sbuf.append( - "\nFor element " - + i - + "(" - + index - + "), expected = " - + bigDecExpected - + ", actual = " - + bigDecActual); + /** */ + private void checkValues(Object oid, LinkedListCollections expectedValue) + { + int i; + StringBuffer sbuf = new StringBuffer(); + LinkedListCollections pi = (LinkedListCollections) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for (i = 0; i < n; ++i) { + LinkedList expected = expectedValue.get(i); + LinkedList actual = pi.get(i); + if (actual.size() != expected.size()) { + sbuf.append("\nFor element " + i + ", expected size = " + + expected.size() + ", actual size = " + actual.size() + + " . "); } - index++; - } - } else { - sbuf.append( - "\nFor element " + i + ", expected = " + expected + ", actual = " + actual + " . "); + else if (! expected.equals(actual)) { + if (TestUtil.getFieldSpecs(LinkedListCollections.fieldSpecs[i] + ).equals("BigDecimal")) { + ListIterator expectedIT = expected.listIterator(); + ListIterator actualIt = actual.listIterator(); + int index = 0; + while (expectedIT.hasNext()) { + BigDecimal bigDecExpected = + (BigDecimal)(expectedIT.next()); + BigDecimal bigDecActual = (BigDecimal)(actualIt.next()); + if ((bigDecExpected.compareTo(bigDecActual)) != 0) { + sbuf.append("\nFor element " + i + "(" + index + + "), expected = " + bigDecExpected + + ", actual = " + bigDecActual); + } + index++; + } + } + else { + sbuf.append("\nFor element " + i + ", expected = " + + expected + ", actual = " + actual + " . "); + } + + } } + if (sbuf.length() > 0) { + fail(ASSERTION_FAILED, + "Expected and observed do not match!!" + sbuf.toString()); } - } - } - if (sbuf.length() > 0) { - fail(ASSERTION_FAILED, "Expected and observed do not match!!" + sbuf.toString()); } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestListCollections.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestListCollections.java index be3247a17..2ff6c4c22 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestListCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestListCollections.java @@ -5,24 +5,28 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.math.BigDecimal; + +import java.util.Collection; +import java.util.Vector; import java.util.List; import java.util.ListIterator; -import java.util.Vector; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.ListCollections; import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; @@ -30,156 +34,167 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type List
    - * Keywords: model
    - * Assertion ID: A6.4.3-36.
    - * Assertion Description: If the List optional feature is supported, then JDO - * implementations must support fields of the interface type List, supporting them as - * Second Class Objects or First Class Objects. + *Title: Support of field type List + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-36. + *
    + *Assertion Description: +If the List optional feature is supported, then JDO implementations must +support fields of the interface type List, +supporting them as Second Class Objects or First Class Objects. */ + + public class TestListCollections extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A6.4.3-36 (Commit) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Commit.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(ListCollections.class); - addTearDownClass(SimpleClass.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTest(pm); - - pm.close(); - pm = null; - } - - /** */ - void runTest(PersistenceManager pm) { - if (!isListSupported()) { - if (debug) logger.debug("JDO Implementation does not support " + "the optional feature List"); - return; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-36 (Commit) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Commit.class); } - if (!isLinkedListSupported() && !isArrayListSupported()) { - fail( - ASSERTION_FAILED, - "JDO Implementation supports List, but neither " + "ArrayList nor LinkedList."); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(ListCollections.class); + addTearDownClass(SimpleClass.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; } - Transaction tx = pm.currentTransaction(); - ListCollections expectedValue = new ListCollections(); - - // turn on datastore transactions - tx.setOptimistic(false); - tx.begin(); - ListCollections pi = new ListCollections(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - // Provide initial set of values - setValues(pi, 1); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - setValues(expectedValue, 1); - // check if persistent fields have values set - checkValues(oid, expectedValue); - pi = (ListCollections) pm.getObjectById(oid, true); - // Provide new set of values - setValues(pi, 2); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - setValues(expectedValue, 2); - checkValues(oid, expectedValue); - tx.commit(); - } - - /** */ - private void setValues(ListCollections collect, int order) { - Vector value; - int n = collect.getLength(); - for (int i = 0; i < n; ++i) { - String valueType = TestUtil.getFieldSpecs(ListCollections.fieldSpecs[i]); - value = TestUtil.makeNewVectorInstance(valueType, order); - collect.set(i, value); - if (debug) logger.debug("Set " + i + "th value to: " + value.toString()); + /** */ + void runTest(PersistenceManager pm) { + if (!isListSupported()) { + if (debug) + logger.debug("JDO Implementation does not support " + + "the optional feature List"); + return; + } + + if (!isLinkedListSupported() && !isArrayListSupported()) { + fail(ASSERTION_FAILED, + "JDO Implementation supports List, but neither " + + "ArrayList nor LinkedList."); + } + + Transaction tx = pm.currentTransaction(); + ListCollections expectedValue = new ListCollections(); + + // turn on datastore transactions + tx.setOptimistic(false); + tx.begin(); + ListCollections pi = new ListCollections(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + // Provide initial set of values + setValues(pi, 1); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + setValues(expectedValue, 1); + // check if persistent fields have values set + checkValues(oid, expectedValue); + pi = (ListCollections) pm.getObjectById(oid, true); + // Provide new set of values + setValues(pi, 2); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + setValues(expectedValue, 2); + checkValues(oid, expectedValue); + tx.commit(); } - } - - /** */ - private void checkValues(Object oid, ListCollections expectedValue) { - int i; - StringBuffer sbuf = new StringBuffer(); - ListCollections pi = (ListCollections) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - List expected = expectedValue.get(i); - List actual = pi.get(i); - if (actual.size() != expected.size()) { - sbuf.append( - "\nFor element " - + i - + ", expected size = " - + expected.size() - + ", actual size = " - + actual.size() - + " . "); - } else if (!expected.equals(actual)) { - if (TestUtil.getFieldSpecs(ListCollections.fieldSpecs[i]).equals("BigDecimal")) { - ListIterator expectedIt = expected.listIterator(); - ListIterator actualIt = actual.listIterator(); - int index = 0; - while (expectedIt.hasNext()) { - BigDecimal bigDecExpected = (BigDecimal) (expectedIt.next()); - BigDecimal bigDecActual = (BigDecimal) (actualIt.next()); - if ((bigDecExpected.compareTo(bigDecActual)) != 0) { - sbuf.append( - "\nFor element " - + i - + "(" - + index - + "), expected = " - + bigDecExpected - + ", actual = " - + bigDecActual); - } - index++; - } - } else { - sbuf.append( - "\nFor element " + i + ", expected = " + expected + ", actual = " + actual + " . "); + + /** */ + private void setValues(ListCollections collect, int order) + { + Vector value; + int n = collect.getLength(); + for (int i = 0; i < n; ++i) { + String valueType = TestUtil.getFieldSpecs( + ListCollections.fieldSpecs[i]); + value = TestUtil.makeNewVectorInstance(valueType, order); + collect.set( i, value); + if (debug) + logger.debug("Set " + i + "th value to: " + value.toString()); } - } } - if (sbuf.length() > 0) { - fail(ASSERTION_FAILED, "Expected and observed do not match!!" + sbuf.toString()); + + /** */ + private void checkValues(Object oid, ListCollections expectedValue) + { + int i; + StringBuffer sbuf = new StringBuffer(); + ListCollections pi = (ListCollections) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for (i = 0; i < n; ++i) { + List expected = expectedValue.get(i); + List actual = pi.get(i); + if (actual.size() != expected.size()) { + sbuf.append("\nFor element " + i + ", expected size = " + + expected.size() + ", actual size = " + actual.size() + + " . "); + } + else if (! expected.equals(actual)) { + if (TestUtil.getFieldSpecs(ListCollections.fieldSpecs[i] + ).equals("BigDecimal")) { + ListIterator expectedIt = expected.listIterator(); + ListIterator actualIt = actual.listIterator(); + int index = 0; + while (expectedIt.hasNext()) { + BigDecimal bigDecExpected = + (BigDecimal)(expectedIt.next()); + BigDecimal bigDecActual = (BigDecimal)(actualIt.next()); + if ((bigDecExpected.compareTo(bigDecActual)) != 0) { + sbuf.append("\nFor element " + i + "(" + index + + "), expected = " + bigDecExpected + + ", actual = " + bigDecActual); + } + index++; + } + } + else { + sbuf.append("\nFor element " + i + ", expected = " + + expected + ", actual = " + actual + " . "); + } + + } + } + if (sbuf.length() > 0) { + fail(ASSERTION_FAILED, + "Expected and observed do not match!!" + sbuf.toString()); + } } - } + + } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringKeyCollections.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringKeyCollections.java index 481a4d245..8c9e349f3 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringKeyCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringKeyCollections.java @@ -5,185 +5,199 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.math.BigDecimal; + import java.util.HashMap; import java.util.Iterator; -import java.util.Map; import java.util.Set; +import java.util.Map; import java.util.Vector; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.MapStringKeyCollections; import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type Map, varying value type
    - * Keywords: model
    - * Assertion ID: A6.4.3-35.
    - * Assertion Description: If the Map optional feature is supported, then JDO implementations - * must support fields of the interface type Map, supporting them as Second Class - * Objects or First Class Objects. + *Title: Support of field type Map, varying value type + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-35. + *
    + *Assertion Description: +If the Map optional feature is supported, then JDO implementations +must support fields of the interface type Map, +supporting them as Second Class Objects or First Class Objects. */ -public class TestMapStringKeyCollections extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-35 (TestMapStringKeyCollections) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestMapStringKeyCollections.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(MapStringKeyCollections.class); - addTearDownClass(SimpleClass.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTest(pm); +public class TestMapStringKeyCollections extends JDO_Test { - pm.close(); - pm = null; - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-35 (TestMapStringKeyCollections) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestMapStringKeyCollections.class); + } - /** */ - void runTest(PersistenceManager pm) { - if (!isMapSupported()) { - if (debug) logger.debug("JDO Implementation does not support " + "the optional feature Map"); - return; + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(MapStringKeyCollections.class); + addTearDownClass(SimpleClass.class); } - if (!isMapSupported() && !isTreeMapSupported()) { - fail(ASSERTION_FAILED, "JDO Implementation supports Map, but neither " + "Map nor TreeMap."); + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) { + if (!isMapSupported()) { + if (debug) + logger.debug("JDO Implementation does not support " + + "the optional feature Map"); + return; + } + if (!isMapSupported() && !isTreeMapSupported()) { + fail(ASSERTION_FAILED, + "JDO Implementation supports Map, but neither " + + "Map nor TreeMap."); + } + Transaction tx = pm.currentTransaction(); + MapStringKeyCollections expectedValue = new MapStringKeyCollections(); + + // turn on datastore transactions + tx.setOptimistic(false); + tx.begin(); + MapStringKeyCollections pi = new MapStringKeyCollections(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + // Provide initial set of values + setValues(pi, 1); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + setValues(expectedValue, 1); + checkValues(oid, expectedValue); + pi = (MapStringKeyCollections) pm.getObjectById(oid, true); + setValues(pi, 2); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + setValues(expectedValue, 2); + checkValues(oid, expectedValue); + tx.commit(); } - Transaction tx = pm.currentTransaction(); - MapStringKeyCollections expectedValue = new MapStringKeyCollections(); - - // turn on datastore transactions - tx.setOptimistic(false); - tx.begin(); - MapStringKeyCollections pi = new MapStringKeyCollections(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - // Provide initial set of values - setValues(pi, 1); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - setValues(expectedValue, 1); - checkValues(oid, expectedValue); - pi = (MapStringKeyCollections) pm.getObjectById(oid, true); - setValues(pi, 2); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - setValues(expectedValue, 2); - checkValues(oid, expectedValue); - tx.commit(); - } - - /** */ - private void setValues(MapStringKeyCollections collect, int order) { - int keyOrder = order; - int valueOrder = (order == 1) ? 2 : 1; // why?? - int n = collect.getLength(); - for (int i = 0; i < n; ++i) { - Vector fieldSpecs = TestUtil.getFieldSpecsForMap(MapStringKeyCollections.fieldSpecs[i]); - Vector key = TestUtil.makeNewVectorInstance((String) fieldSpecs.get(0), keyOrder); - Vector value = TestUtil.makeNewVectorInstance((String) fieldSpecs.get(1), valueOrder); - HashMap map = new HashMap(); - for (int j = 0; j < key.size(); j++) { - map.put(key.get(j), value.get(j)); - } - collect.set(i, map); - if (debug) logger.debug("Set " + i + "th value to: " + map.toString()); + /** */ + private void setValues(MapStringKeyCollections collect, int order) + { + int keyOrder = order; + int valueOrder = (order == 1) ? 2 : 1; // why?? + int n = collect.getLength(); + for (int i = 0; i < n; ++i) { + Vector fieldSpecs = TestUtil.getFieldSpecsForMap( + MapStringKeyCollections.fieldSpecs[i]); + Vector key = TestUtil.makeNewVectorInstance( + (String)fieldSpecs.get(0), keyOrder); + Vector value = TestUtil.makeNewVectorInstance( + (String)fieldSpecs.get(1), valueOrder); + + HashMap map = new HashMap(); + for (int j = 0; j< key.size(); j++) { + map.put(key.get(j), value.get(j)); + } + collect.set(i, map); + if (debug) + logger.debug("Set " + i + "th value to: " + map.toString()); + } } - } - /** */ - private void checkValues(Object oid, MapStringKeyCollections expectedValue) { - StringBuffer sbuf = new StringBuffer(); - MapStringKeyCollections pi = (MapStringKeyCollections) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (int i = 0; i < n; ++i) { - Map expected = expectedValue.get(i); - Map actual = pi.get(i); - if (actual.size() != expected.size()) { - sbuf.append( - "\nFor element " - + i - + ", expected size = " - + expected.size() - + ", actual size = " - + actual.size() - + " . "); - } else if (!expected.equals(actual)) { - if (TestUtil.getFieldSpecsForMap(MapStringKeyCollections.fieldSpecs[i]) - .get(1) - .equals("BigDecimal")) { - Set keys = expected.keySet(); - Iterator iter = keys.iterator(); - while (iter.hasNext()) { - Object nextKey = iter.next(); - BigDecimal expectedMapValue = (BigDecimal) expected.get(nextKey); - BigDecimal actualMapValue = (BigDecimal) actual.get(nextKey); - if ((expectedMapValue.compareTo(actualMapValue) != 0)) { - sbuf.append( - "\nFor element " - + i - + "(" - + (String) nextKey - + "), expected = " - + expectedMapValue - + ", actual = " - + actualMapValue - + " . "); + /** */ + private void checkValues(Object oid, + MapStringKeyCollections expectedValue) + { + StringBuffer sbuf = new StringBuffer(); + MapStringKeyCollections pi = (MapStringKeyCollections) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for (int i = 0; i < n; ++i) { + Map expected = expectedValue.get(i); + Map actual = pi.get(i); + if (actual.size() != expected.size()) { + sbuf.append("\nFor element " + i + ", expected size = " + + expected.size() + ", actual size = " + actual.size() + + " . "); + } + else if (! expected.equals(actual)) { + if (TestUtil.getFieldSpecsForMap( + MapStringKeyCollections.fieldSpecs[i] + ).get(1).equals("BigDecimal")) { + Set keys = expected.keySet(); + Iterator iter = keys.iterator(); + while (iter.hasNext()) { + Object nextKey = iter.next(); + BigDecimal expectedMapValue = + (BigDecimal)expected.get(nextKey); + BigDecimal actualMapValue = + (BigDecimal)actual.get(nextKey); + if ((expectedMapValue.compareTo(actualMapValue) != 0)) { + sbuf.append("\nFor element " + i + "(" + + (String)nextKey + + "), expected = " + expectedMapValue + + ", actual = " + actualMapValue + " . "); + } + } + } + else { + sbuf.append("\nFor element " + i + ", expected = " + + expected + ", actual = " + actual + " . "); } } - } else { - sbuf.append( - "\nFor element " + i + ", expected = " + expected + ", actual = " + actual + " . "); } - } - } - if (sbuf.length() > 0) { - fail(ASSERTION_FAILED, "Expected and observed do not match!!" + sbuf.toString()); + if (sbuf.length() > 0) { + fail(ASSERTION_FAILED, + "Expected and observed do not match!!" + sbuf.toString()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringValueCollections.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringValueCollections.java index d5b5a9b9f..ee7f10145 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringValueCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestMapStringValueCollections.java @@ -5,197 +5,211 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.math.BigDecimal; + import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.Vector; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.MapStringValueCollections; import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type Map, varying key type
    - * Keywords: model
    - * Assertion ID: A6.4.3-35.
    - * Assertion Description: If the Map optional feature is supported, then JDO implementations - * must support fields of the interface type Map, supporting them as Second Class - * Objects or First Class Objects. + *Title: Support of field type Map, varying key type + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-35. + *
    + *Assertion Description: +If the Map optional feature is supported, then JDO implementations +must support fields of the interface type Map, +supporting them as Second Class Objects or First Class Objects. */ + + public class TestMapStringValueCollections extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-35 (TestMapStringValueCollections) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestMapStringValueCollections.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(MapStringValueCollections.class); - addTearDownClass(SimpleClass.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTest(pm); - - pm.close(); - pm = null; - } - - /** */ - void runTest(PersistenceManager pm) { - if (!isMapSupported()) { - if (debug) logger.debug("JDO Implementation does not support " + "the optional feature Map"); - return; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-35 (TestMapStringValueCollections) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestMapStringValueCollections.class); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(MapStringValueCollections.class); + addTearDownClass(SimpleClass.class); } - if (!isMapSupported() && !isTreeMapSupported()) { - fail(ASSERTION_FAILED, "JDO Implementation supports Map, but neither " + "Map nor TreeMap."); + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; } + + /** */ + void runTest(PersistenceManager pm) { + if (!isMapSupported()) { + if (debug) + logger.debug("JDO Implementation does not support " + + "the optional feature Map"); + return; + } + if (!isMapSupported() && !isTreeMapSupported()) { + fail(ASSERTION_FAILED, + "JDO Implementation supports Map, but neither " + + "Map nor TreeMap."); + } - Transaction tx = pm.currentTransaction(); - MapStringValueCollections expectedValue = new MapStringValueCollections(); - - // turn on datastore transactions - tx.setOptimistic(false); - tx.begin(); - MapStringValueCollections pi = new MapStringValueCollections(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - // Provide initial set of values - setValues(pi, 1); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - setValues(expectedValue, 1); - checkValues(oid, expectedValue); - pi = (MapStringValueCollections) pm.getObjectById(oid, true); - setValues(pi, 2); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - setValues(expectedValue, 2); - checkValues(oid, expectedValue); - tx.commit(); - } - - /** */ - private void setValues(MapStringValueCollections collect, int order) { - int keyOrder = order; - int valueOrder = (order == 1) ? 2 : 1; // why?? - int n = collect.getLength(); - for (int i = 0; i < n; ++i) { - Vector fieldSpecs = TestUtil.getFieldSpecsForMap(MapStringValueCollections.fieldSpecs[i]); - Vector key = TestUtil.makeNewVectorInstance((String) fieldSpecs.get(0), keyOrder); - Vector value = TestUtil.makeNewVectorInstance((String) fieldSpecs.get(1), valueOrder); - - HashMap map = new HashMap(); - for (int j = 0; j < key.size(); j++) { - map.put(key.get(j), value.get(j)); - } - collect.set(i, map); - if (debug) logger.debug("Set " + i + "th value to: " + map.toString()); + Transaction tx = pm.currentTransaction(); + MapStringValueCollections expectedValue = + new MapStringValueCollections(); + + // turn on datastore transactions + tx.setOptimistic(false); + tx.begin(); + MapStringValueCollections pi = new MapStringValueCollections(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + // Provide initial set of values + setValues(pi, 1); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + setValues(expectedValue, 1); + checkValues(oid, expectedValue); + pi = (MapStringValueCollections) pm.getObjectById(oid, true); + setValues(pi, 2); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + setValues(expectedValue, 2); + checkValues(oid, expectedValue); + tx.commit(); } - } - - /** */ - private void checkValues(Object oid, MapStringValueCollections expectedValue) { - StringBuffer sbuf = new StringBuffer(); - MapStringValueCollections pi = (MapStringValueCollections) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (int i = 0; i < n; ++i) { - Map expected = expectedValue.get(i); - Map actual = pi.get(i); - if (actual.size() != expected.size()) { - sbuf.append( - "\nFor element " - + i - + ", expected size = " - + expected.size() - + ", actual size = " - + actual.size() - + " . "); - } else if (!expected.equals(actual)) { - if (TestUtil.getFieldSpecsForMap(MapStringValueCollections.fieldSpecs[i]) - .get(0) - .equals("BigDecimal")) { - Set expectedKeySet = expected.keySet(); - Set actualKeySet = actual.keySet(); - Iterator expectedIter = expectedKeySet.iterator(); - while (expectedIter.hasNext()) { - BigDecimal expectedKey = (BigDecimal) expectedIter.next(); - // compare keys - if (!TestUtil.containsBigDecimalKey(expectedKey, actualKeySet)) { - sbuf.append( - "\nFor element " - + i - + " expected key = " - + expectedKey - + " not found in actual Map. Actual keyset is " - + actualKeySet.toString()); - // compare values - } else { - String expectedVal = (String) expected.get(expectedKey); - String actualValue = - (String) actual.get(TestUtil.getBigDecimalKey(expectedKey, actualKeySet)); - if (!expectedVal.equals(actualValue)) { - sbuf.append( - "\nFor element " - + i - + " expected value = " - + expectedVal - + " actual Value = " - + actualValue); - } + + /** */ + private void setValues(MapStringValueCollections collect, int order) + { + int keyOrder = order; + int valueOrder = (order == 1) ? 2 : 1; // why?? + int n = collect.getLength(); + for (int i = 0; i < n; ++i) { + Vector fieldSpecs = TestUtil.getFieldSpecsForMap( + MapStringValueCollections.fieldSpecs[i]); + Vector key = TestUtil.makeNewVectorInstance( + (String)fieldSpecs.get(0), keyOrder); + Vector value = TestUtil.makeNewVectorInstance( + (String)fieldSpecs.get(1), valueOrder); + + HashMap map = new HashMap(); + for (int j = 0; j< key.size(); j++) { + map.put(key.get(j), value.get(j)); } - } - } else { - sbuf.append( - "\nFor element " + i + ", expected = " + expected + ", actual = " + actual + " . "); + collect.set(i, map); + if (debug) + logger.debug("Set " + i + "th value to: " + map.toString()); } - } } - if (sbuf.length() > 0) { - fail(ASSERTION_FAILED, "Expected and observed do not match!!" + sbuf.toString()); + + /** */ + private void checkValues(Object oid, + MapStringValueCollections expectedValue) + { + StringBuffer sbuf = new StringBuffer(); + MapStringValueCollections pi = (MapStringValueCollections) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for (int i = 0; i < n; ++i) { + Map expected = expectedValue.get(i); + Map actual = pi.get(i); + if (actual.size() != expected.size()) { + sbuf.append("\nFor element " + i + ", expected size = " + + expected.size() + ", actual size = " + actual.size() + + " . "); + } + else if (! expected.equals(actual)) { + if (TestUtil.getFieldSpecsForMap( + MapStringValueCollections.fieldSpecs[i] + ).get(0).equals("BigDecimal")) { + Set expectedKeySet = expected.keySet(); + Set actualKeySet = actual.keySet(); + Iterator expectedIter = expectedKeySet.iterator(); + while (expectedIter.hasNext()) { + BigDecimal expectedKey = (BigDecimal) expectedIter.next(); + // compare keys + if (!TestUtil.containsBigDecimalKey(expectedKey, actualKeySet)) { + sbuf.append("\nFor element " + i + + " expected key = " + expectedKey + + " not found in actual Map. Actual keyset is " + + actualKeySet.toString()); + // compare values + } else { + String expectedVal = (String) expected.get(expectedKey); + String actualValue = (String) + actual.get(TestUtil.getBigDecimalKey(expectedKey, + actualKeySet)); + if (!expectedVal.equals(actualValue)) { + sbuf.append("\nFor element " + i + + " expected value = " + expectedVal + + " actual Value = " + actualValue); + } + } + } + } + else { + sbuf.append("\nFor element " + i + ", expected = " + + expected + ", actual = " + actual + " . "); + } + } + } + if (sbuf.length() > 0) { + fail(ASSERTION_FAILED, + "Expected and observed do not match!!" + sbuf.toString()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestSetCollections.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestSetCollections.java index 8ce019c14..c0f1d821e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestSetCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestSetCollections.java @@ -5,174 +5,184 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.math.BigDecimal; + import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import java.util.TreeSet; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.SetCollections; import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type Set.
    - * Keywords: model
    - * Assertion ID: A6.4.3-34.
    - * Assertion Description: JDO implementations must support fields of the interface type - * java.util.Set, and may choose to support them as Second Class Objects or First Class - * Objects. + *Title: Support of field type Set. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-34. + *
    + *Assertion Description: +JDO implementations must support fields of the interface type +java.util.Set, and may choose to support them +as Second Class Objects or First Class Objects. */ -public class TestSetCollections extends JDO_Test { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-34 (TestSetCollections) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestSetCollections.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(SetCollections.class); - addTearDownClass(SimpleClass.class); - } - - /** */ - public void test() { - pm = getPM(); - runTest(pm); - - pm.close(); - pm = null; - } - - /** */ - void runTest(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - SetCollections expectedValue = new SetCollections(); - // turn on datastore transactions - tx.setOptimistic(false); - tx.begin(); - SetCollections pi = new SetCollections(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - // Provide initial set of values - setValues(pi, 1); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); +public class TestSetCollections extends JDO_Test { - tx.begin(); - setValues(expectedValue, 1); - // check if persistent fields have values set - checkValues(oid, expectedValue); - pi = (SetCollections) pm.getObjectById(oid, true); - // Provide new set of values - setValues(pi, 2); - tx.commit(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-34 (TestSetCollections) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestSetCollections.class); + } - // cache will be flushed - pi = null; - System.gc(); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(SetCollections.class); + addTearDownClass(SimpleClass.class); + } + + /** */ + public void test() { + pm = getPM(); + runTest(pm); + + pm.close(); + pm = null; + } - tx.begin(); - // check new values - setValues(expectedValue, 2); - checkValues(oid, expectedValue); - tx.commit(); - } + /** */ + void runTest(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + SetCollections expectedValue = new SetCollections(); + + // turn on datastore transactions + tx.setOptimistic(false); + tx.begin(); + SetCollections pi = new SetCollections(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + // Provide initial set of values + setValues(pi, 1); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + setValues(expectedValue, 1); + // check if persistent fields have values set + checkValues(oid, expectedValue); + pi = (SetCollections) pm.getObjectById(oid, true); + // Provide new set of values + setValues(pi, 2); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + setValues(expectedValue, 2); + checkValues(oid, expectedValue); + tx.commit(); + } - /** */ - private void setValues(SetCollections collect, int order) { - Collection value; - int n = collect.getLength(); - for (int i = 0; i < n; ++i) { - String valueType = TestUtil.getFieldSpecs(SetCollections.fieldSpecs[i]); - value = (Collection) TestUtil.makeNewVectorInstance(valueType, order); - Set lvalue = new HashSet(value); - collect.set(i, lvalue); - if (debug) logger.debug("Set " + i + "th value to: " + value.toString()); + /** */ + private void setValues(SetCollections collect, int order) + { + Collection value; + int n = collect.getLength(); + for (int i = 0; i < n; ++i) { + String valueType = TestUtil.getFieldSpecs( + SetCollections.fieldSpecs[i]); + value = (Collection)TestUtil.makeNewVectorInstance( + valueType, order); + Set lvalue = new HashSet(value); + collect.set(i, lvalue); + if (debug) + logger.debug("Set " + i + "th value to: " + value.toString()); + } } - } - /** */ - private void checkValues(Object oid, SetCollections expectedValue) { - int i; - StringBuffer sbuf = new StringBuffer(); - SetCollections pi = (SetCollections) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (i = 0; i < n; ++i) { - Set expected = expectedValue.get(i); - Set actual = pi.get(i); - if (actual.size() != expected.size()) { - sbuf.append( - "\nFor element " - + i - + ", expected size = " - + expected.size() - + ", actual size = " - + actual.size() - + " . "); - } else if (!expected.equals(actual)) { - if (TestUtil.getFieldSpecs(SetCollections.fieldSpecs[i]).equals("BigDecimal")) { - // sort values for comparison - TreeSet expectedTS = new TreeSet(expected); - TreeSet actualTS = new TreeSet(actual); - Iterator expectedIter = expectedTS.iterator(); - Iterator actualIter = actualTS.iterator(); - for (int j = 0; j < expectedTS.size(); j++) { - BigDecimal bigDecExpected = (BigDecimal) (expectedIter.next()); - BigDecimal bigDecActual = (BigDecimal) (actualIter.next()); - bigDecActual.setScale(bigDecExpected.scale()); - if ((bigDecExpected.compareTo(bigDecActual)) != 0) { - sbuf.append( - "\nFor element " - + i - + "(" - + j - + "), expected = " - + bigDecExpected - + ", actual = " - + bigDecActual); + /** */ + private void checkValues(Object oid, SetCollections expectedValue) + { + int i; + StringBuffer sbuf = new StringBuffer(); + SetCollections pi = (SetCollections) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for (i = 0; i < n; ++i) { + Set expected = expectedValue.get(i); + Set actual = pi.get(i); + if (actual.size() != expected.size()) { + sbuf.append("\nFor element " + i + ", expected size = " + + expected.size() + ", actual size = " + actual.size() + + " . "); + } + else if (! expected.equals(actual)) { + if (TestUtil.getFieldSpecs(SetCollections.fieldSpecs[i] + ).equals("BigDecimal")) { + // sort values for comparison + TreeSet expectedTS = new TreeSet(expected); + TreeSet actualTS = new TreeSet(actual); + Iterator expectedIter = expectedTS.iterator(); + Iterator actualIter = actualTS.iterator(); + for (int j=0; j < expectedTS.size(); j++) { + BigDecimal bigDecExpected = + (BigDecimal)(expectedIter.next()); + BigDecimal bigDecActual = + (BigDecimal)(actualIter.next()); + bigDecActual.setScale(bigDecExpected.scale()); + if ((bigDecExpected.compareTo(bigDecActual)) != 0) { + sbuf.append("\nFor element " + i + "(" + j + + "), expected = " + bigDecExpected + + ", actual = " + bigDecActual); + } + } + } + else { + sbuf.append("\nFor element " + i + ", expected = " + + expected + ", actual = " + actual + " . "); + } + } - } - } else { - sbuf.append( - "\nFor element " + i + ", expected = " + expected + ", actual = " + actual + " . "); } - } - } - if (sbuf.length() > 0) { - fail(ASSERTION_FAILED, "Expected and observed do not match!!" + sbuf.toString()); - } + if (sbuf.length() > 0) { + fail(ASSERTION_FAILED, + "Expected and observed do not match!!" + sbuf.toString()); + } } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestTreeMapStringKeyCollections.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestTreeMapStringKeyCollections.java index caf60c42b..aa15adfb2 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestTreeMapStringKeyCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestTreeMapStringKeyCollections.java @@ -5,183 +5,197 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.math.BigDecimal; + import java.util.Iterator; +import java.util.List; import java.util.Set; import java.util.TreeMap; import java.util.Vector; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; -import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.pc.fieldtypes.TreeMapStringKeyCollections; +import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type TreeMap, varying value type
    - * Keywords: model
    - * Assertion ID: A6.4.3-27.
    - * Assertion Description: If the TreeMap optional feature is supported, then JDO - * implementation must support fields of the mutable object class TreeMap, supporting - * them as Second Class Objects or First Class Objects. + *Title: Support of field type TreeMap, varying value type + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-27. + *
    + *Assertion Description: +If the TreeMap optional feature is supported, then JDO implementation +must support fields of the mutable object class TreeMap, +supporting them as Second Class Objects or First Class Objects. */ + + public class TestTreeMapStringKeyCollections extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-27 (TestTreeMapStringKeyCollections) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestTreeMapStringKeyCollections.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(TreeMapStringKeyCollections.class); - addTearDownClass(SimpleClass.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTest(pm); - - pm.close(); - pm = null; - } - - /** */ - void runTest(PersistenceManager pm) { - if (!isTreeMapSupported()) { - if (debug) - logger.debug("JDO Implementation does not support " + "the optional feature TreeMap"); - return; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-27 (TestTreeMapStringKeyCollections) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestTreeMapStringKeyCollections.class); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(TreeMapStringKeyCollections.class); + addTearDownClass(SimpleClass.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) { + if (!isTreeMapSupported()) { + if (debug) + logger.debug("JDO Implementation does not support " + + "the optional feature TreeMap"); + return; + } + + Transaction tx = pm.currentTransaction(); + TreeMapStringKeyCollections expectedValue = + new TreeMapStringKeyCollections(); + + // turn on datastore transactions + tx.setOptimistic(false); + tx.begin(); + TreeMapStringKeyCollections pi = new TreeMapStringKeyCollections(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + // Provide initial set of values + setValues(pi, 1); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + setValues(expectedValue, 1); + checkValues(oid, expectedValue); + pi = (TreeMapStringKeyCollections) pm.getObjectById(oid, true); + setValues(pi, 2); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + setValues(expectedValue, 2); + checkValues(oid, expectedValue); + tx.commit(); } - Transaction tx = pm.currentTransaction(); - TreeMapStringKeyCollections expectedValue = new TreeMapStringKeyCollections(); - - // turn on datastore transactions - tx.setOptimistic(false); - tx.begin(); - TreeMapStringKeyCollections pi = new TreeMapStringKeyCollections(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - // Provide initial set of values - setValues(pi, 1); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - setValues(expectedValue, 1); - checkValues(oid, expectedValue); - pi = (TreeMapStringKeyCollections) pm.getObjectById(oid, true); - setValues(pi, 2); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - setValues(expectedValue, 2); - checkValues(oid, expectedValue); - tx.commit(); - } - - /** */ - private void setValues(TreeMapStringKeyCollections collect, int order) { - int keyOrder = order; - int valueOrder = (order == 1) ? 2 : 1; // why?? - int n = collect.getLength(); - for (int i = 0; i < n; ++i) { - Vector fieldSpecs = TestUtil.getFieldSpecsForMap(TreeMapStringKeyCollections.fieldSpecs[i]); - Vector key = TestUtil.makeNewVectorInstance((String) fieldSpecs.get(0), keyOrder); - Vector value = TestUtil.makeNewVectorInstance((String) fieldSpecs.get(1), valueOrder); - - TreeMap map = new TreeMap(); - for (int j = 0; j < key.size(); j++) { - map.put(key.get(j), value.get(j)); - } - collect.set(i, map); - if (debug) logger.debug("Set " + i + "th value to: " + map.toString()); + /** */ + private void setValues(TreeMapStringKeyCollections collect, int order) + { + int keyOrder = order; + int valueOrder = (order == 1) ? 2 : 1; // why?? + int n = collect.getLength(); + for (int i = 0; i < n; ++i) { + Vector fieldSpecs = TestUtil.getFieldSpecsForMap( + TreeMapStringKeyCollections.fieldSpecs[i]); + Vector key = TestUtil.makeNewVectorInstance( + (String)fieldSpecs.get(0), keyOrder); + Vector value = TestUtil.makeNewVectorInstance( + (String)fieldSpecs.get(1), valueOrder); + + TreeMap map = new TreeMap(); + for (int j = 0; j< key.size(); j++) { + map.put(key.get(j), value.get(j)); + } + collect.set(i, map); + if (debug) + logger.debug("Set " + i + "th value to: " + map.toString()); + } } - } - - /** */ - private void checkValues(Object oid, TreeMapStringKeyCollections expectedValue) { - StringBuffer sbuf = new StringBuffer(); - TreeMapStringKeyCollections pi = (TreeMapStringKeyCollections) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (int i = 0; i < n; ++i) { - TreeMap expected = expectedValue.get(i); - TreeMap actual = pi.get(i); - if (actual.size() != expected.size()) { - sbuf.append( - "\nFor element " - + i - + ", expected size = " - + expected.size() - + ", actual size = " - + actual.size() - + " . "); - } else if (!expected.equals(actual)) { - if (TestUtil.getFieldSpecsForMap(TreeMapStringKeyCollections.fieldSpecs[i]) - .get(1) - .equals("BigDecimal")) { - Set keys = expected.keySet(); - Iterator iter = keys.iterator(); - while (iter.hasNext()) { - Object nextKey = iter.next(); - BigDecimal expectedMapValue = (BigDecimal) expected.get(nextKey); - BigDecimal actualMapValue = (BigDecimal) actual.get(nextKey); - if ((expectedMapValue.compareTo(actualMapValue) != 0)) { - sbuf.append( - "\nFor element " - + i - + "(" - + (String) nextKey - + "), expected = " - + expectedMapValue - + ", actual = " - + actualMapValue - + " . "); + + /** */ + private void checkValues(Object oid, + TreeMapStringKeyCollections expectedValue) + { + StringBuffer sbuf = new StringBuffer(); + TreeMapStringKeyCollections pi = (TreeMapStringKeyCollections) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for (int i = 0; i < n; ++i) { + TreeMap expected = expectedValue.get(i); + TreeMap actual = pi.get(i); + if (actual.size() != expected.size()) { + sbuf.append("\nFor element " + i + ", expected size = " + + expected.size() + ", actual size = " + actual.size() + + " . "); + } + else if (! expected.equals(actual)) { + if (TestUtil.getFieldSpecsForMap( + TreeMapStringKeyCollections.fieldSpecs[i] + ).get(1).equals("BigDecimal")) { + Set keys = expected.keySet(); + Iterator iter = keys.iterator(); + while (iter.hasNext()) { + Object nextKey = iter.next(); + BigDecimal expectedMapValue = + (BigDecimal)expected.get(nextKey); + BigDecimal actualMapValue = + (BigDecimal)actual.get(nextKey); + if ((expectedMapValue.compareTo(actualMapValue) != 0)) { + sbuf.append("\nFor element " + i + "(" + + (String)nextKey + + "), expected = " + expectedMapValue + + ", actual = " + actualMapValue + " . "); + } + } + } + else { + sbuf.append("\nFor element " + i + ", expected = " + + expected + ", actual = " + actual + " . "); } } - } else { - sbuf.append( - "\nFor element " + i + ", expected = " + expected + ", actual = " + actual + " . "); } - } - } - if (sbuf.length() > 0) { - fail(ASSERTION_FAILED, "Expected and observed do not match!!" + sbuf.toString()); + if (sbuf.length() > 0) { + fail(ASSERTION_FAILED, + "Expected and observed do not match!!" + sbuf.toString()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestTreeMapStringValueCollections.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestTreeMapStringValueCollections.java index e1186b036..8ffdae8c7 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestTreeMapStringValueCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestTreeMapStringValueCollections.java @@ -5,194 +5,204 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.math.BigDecimal; + import java.util.Iterator; import java.util.Set; import java.util.TreeMap; import java.util.Vector; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; -import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.pc.fieldtypes.TreeMapStringValueCollections; +import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type TreeMap, varying key type
    - * Keywords: model
    - * Assertion ID: A6.4.3-27.
    - * Assertion Description: If the TreeMap optional feature is supported, then JDO - * implementation must support fields of the mutable object class TreeMap, supporting - * them as Second Class Objects or First Class Objects. + *Title: Support of field type TreeMap, varying key type + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-27. + *
    + *Assertion Description: +If the TreeMap optional feature is supported, then JDO implementation +must support fields of the mutable object class TreeMap, +supporting them as Second Class Objects or First Class Objects. */ + public class TestTreeMapStringValueCollections extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-27 (TestTreeMapStringValueCollections) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestTreeMapStringValueCollections.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(TreeMapStringValueCollections.class); - addTearDownClass(SimpleClass.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTest(pm); - - pm.close(); - pm = null; - } - - /** */ - void runTest(PersistenceManager pm) { - if (!isTreeMapSupported()) { - if (debug) - logger.debug("JDO Implementation does not support " + "the optional feature TreeMap"); - return; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-27 (TestTreeMapStringValueCollections) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestTreeMapStringValueCollections.class); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(TreeMapStringValueCollections.class); + addTearDownClass(SimpleClass.class); } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) { + if (!isTreeMapSupported()) { + if (debug) + logger.debug("JDO Implementation does not support " + + "the optional feature TreeMap"); + return; + } - Transaction tx = pm.currentTransaction(); - TreeMapStringValueCollections expectedValue = new TreeMapStringValueCollections(); - - // turn on datastore transactions - tx.setOptimistic(false); - tx.begin(); - TreeMapStringValueCollections pi = new TreeMapStringValueCollections(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - // Provide initial set of values - setValues(pi, 1); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - setValues(expectedValue, 1); - checkValues(oid, expectedValue); - pi = (TreeMapStringValueCollections) pm.getObjectById(oid, true); - setValues(pi, 2); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - setValues(expectedValue, 2); - checkValues(oid, expectedValue); - tx.commit(); - } - - /** */ - private void setValues(TreeMapStringValueCollections collect, int order) { - int keyOrder = order; - int valueOrder = (order == 1) ? 2 : 1; // why?? - int n = collect.getLength(); - for (int i = 0; i < n; ++i) { - Vector fieldSpecs = TestUtil.getFieldSpecsForMap(TreeMapStringValueCollections.fieldSpecs[i]); - Vector key = TestUtil.makeNewVectorInstance((String) fieldSpecs.get(0), keyOrder); - Vector value = TestUtil.makeNewVectorInstance((String) fieldSpecs.get(1), valueOrder); - - TreeMap map = new TreeMap(); - for (int j = 0; j < key.size(); j++) { - map.put(key.get(j), value.get(j)); - } - collect.set(i, map); - if (debug) logger.debug("Set " + i + "th value to: " + map.toString()); + Transaction tx = pm.currentTransaction(); + TreeMapStringValueCollections expectedValue = + new TreeMapStringValueCollections(); + + // turn on datastore transactions + tx.setOptimistic(false); + tx.begin(); + TreeMapStringValueCollections pi = new TreeMapStringValueCollections(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + // Provide initial set of values + setValues(pi, 1); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + setValues(expectedValue, 1); + checkValues(oid, expectedValue); + pi = (TreeMapStringValueCollections) pm.getObjectById(oid, true); + setValues(pi, 2); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + setValues(expectedValue, 2); + checkValues(oid, expectedValue); + tx.commit(); } - } - - /** */ - private void checkValues(Object oid, TreeMapStringValueCollections expectedValue) { - StringBuffer sbuf = new StringBuffer(); - TreeMapStringValueCollections pi = (TreeMapStringValueCollections) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (int i = 0; i < n; ++i) { - TreeMap expected = expectedValue.get(i); - TreeMap actual = pi.get(i); - if (actual.size() != expected.size()) { - sbuf.append( - "\nFor element " - + i - + ", expected size = " - + expected.size() - + ", actual size = " - + actual.size() - + " . "); - } else if (!expected.equals(actual)) { - if (TestUtil.getFieldSpecsForMap(TreeMapStringValueCollections.fieldSpecs[i]) - .get(0) - .equals("BigDecimal")) { - Set expectedKeySet = expected.keySet(); - Set actualKeySet = actual.keySet(); - Iterator expectedIter = expectedKeySet.iterator(); - while (expectedIter.hasNext()) { - BigDecimal expectedKey = (BigDecimal) expectedIter.next(); - // compare keys - if (!TestUtil.containsBigDecimalKey(expectedKey, actualKeySet)) { - sbuf.append( - "\nFor element " - + i - + " expected key = " - + expectedKey - + " not found in actual Map. Actual keyset is " - + actualKeySet.toString()); - // compare values - } else { - String expectedVal = (String) expected.get(expectedKey); - String actualValue = - (String) actual.get(TestUtil.getBigDecimalKey(expectedKey, actualKeySet)); - if (!expectedVal.equals(actualValue)) { - sbuf.append( - "\nFor element " - + i - + " expected value = " - + expectedVal - + " actual Value = " - + actualValue); - } + + /** */ + private void setValues(TreeMapStringValueCollections collect, int order) + { + int keyOrder = order; + int valueOrder = (order == 1) ? 2 : 1; // why?? + int n = collect.getLength(); + for (int i = 0; i < n; ++i) { + Vector fieldSpecs = TestUtil.getFieldSpecsForMap( + TreeMapStringValueCollections.fieldSpecs[i]); + Vector key = TestUtil.makeNewVectorInstance( + (String)fieldSpecs.get(0), keyOrder); + Vector value = TestUtil.makeNewVectorInstance( + (String)fieldSpecs.get(1), valueOrder); + + TreeMap map = new TreeMap(); + for (int j = 0; j< key.size(); j++) { + map.put(key.get(j), value.get(j)); } - } - } else { - sbuf.append( - "\nFor element " + i + ", expected = " + expected + ", actual = " + actual + " . "); + collect.set(i, map); + if (debug) + logger.debug("Set " + i + "th value to: " + map.toString()); } - } } - if (sbuf.length() > 0) { - fail(ASSERTION_FAILED, "Expected and observed do not match!!" + sbuf.toString()); + + /** */ + private void checkValues(Object oid, + TreeMapStringValueCollections expectedValue) + { + StringBuffer sbuf = new StringBuffer(); + TreeMapStringValueCollections pi = (TreeMapStringValueCollections) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for (int i = 0; i < n; ++i) { + TreeMap expected = expectedValue.get(i); + TreeMap actual = pi.get(i); + if (actual.size() != expected.size()) { + sbuf.append("\nFor element " + i + ", expected size = " + + expected.size() + ", actual size = " + actual.size() + + " . "); + } + else if (! expected.equals(actual)) { + if (TestUtil.getFieldSpecsForMap( + TreeMapStringValueCollections.fieldSpecs[i] + ).get(0).equals("BigDecimal")) { + Set expectedKeySet = expected.keySet(); + Set actualKeySet = actual.keySet(); + Iterator expectedIter = expectedKeySet.iterator(); + while (expectedIter.hasNext()) { + BigDecimal expectedKey = (BigDecimal) expectedIter.next(); + // compare keys + if (!TestUtil.containsBigDecimalKey(expectedKey, actualKeySet)) { + sbuf.append("\nFor element " + i + + " expected key = " + expectedKey + + " not found in actual Map. Actual keyset is " + + actualKeySet.toString()); + // compare values + } else { + String expectedVal = (String) expected.get(expectedKey); + String actualValue = (String) + actual.get(TestUtil.getBigDecimalKey(expectedKey, + actualKeySet)); + if (!expectedVal.equals(actualValue)) { + sbuf.append("\nFor element " + i + + " expected value = " + expectedVal + + " actual Value = " + actualValue); + } + } + } + } + else { + sbuf.append("\nFor element " + i + ", expected = " + + expected + ", actual = " + actual + " . "); + } + } + } + if (sbuf.length() > 0) { + fail(ASSERTION_FAILED, + "Expected and observed do not match!!" + sbuf.toString()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestTreeSetCollections.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestTreeSetCollections.java index 580c15c63..5bc15afb8 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestTreeSetCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestTreeSetCollections.java @@ -5,159 +5,169 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.util.Collection; import java.util.TreeSet; import java.util.Vector; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; -import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.pc.fieldtypes.TreeSetCollections; +import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type TreeSet.
    - * Keywords: model
    - * Assertion ID: A6.4.3-28.
    - * Assertion Description: If the TreeSet optional feature is supported, then JDO - * implementation must support fields of the mutable object class TreeSet, supporting - * them as Second Class Objects or First Class Objects. + *Title: Support of field type TreeSet. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-28. + *
    + *Assertion Description: +If the TreeSet optional feature is supported, then JDO implementation +must support fields of the mutable object class TreeSet, +supporting them as Second Class Objects or First Class Objects. */ -public class TestTreeSetCollections extends JDO_Test { - private PersistenceManager pm; - private Transaction tx; - private static String prefix = "TestTreeSetCollections: "; - private TreeSet defaultValue; // do not initialize, should be 0 for int - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-28 (TestTreeSetCollections) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestTreeSetCollections.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(TreeSetCollections.class); - addTearDownClass(SimpleClass.class); - } - - /** */ - public void test() { - pm = getPM(); - runTest(pm); - pm.close(); - pm = null; - } - - /** */ - void runTest(PersistenceManager pm) { - if (!isTreeSetSupported()) { - if (debug) - logger.debug("JDO Implementation does not support " + "the optional feature TreeSet"); - return; +public class TestTreeSetCollections extends JDO_Test { + private PersistenceManager pm; + private Transaction tx; + private static String prefix = "TestTreeSetCollections: "; + private TreeSet defaultValue; // do not initialize, should be 0 for int + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-28 (TestTreeSetCollections) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestTreeSetCollections.class); } - Transaction tx = pm.currentTransaction(); - TreeSetCollections expectedValue = new TreeSetCollections(); - - // turn on datastore transactions - tx.setOptimistic(false); - tx.begin(); - TreeSetCollections pi = new TreeSetCollections(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - // Provide initial set of values - setValues(pi, 1); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - setValues(expectedValue, 1); - // check if persistent fields have values set - checkValues(oid, expectedValue); - pi = (TreeSetCollections) pm.getObjectById(oid, true); - // Provide new set of values - setValues(pi, 2); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - setValues(expectedValue, 2); - checkValues(oid, expectedValue); - tx.commit(); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(TreeSetCollections.class); + addTearDownClass(SimpleClass.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } - /** */ - private void setValues(TreeSetCollections collect, int order) { - Vector value; - int n = collect.getLength(); - for (int i = 0; i < n; ++i) { - String valueType = TestUtil.getFieldSpecs(TreeSetCollections.fieldSpecs[i]); - value = TestUtil.makeNewVectorInstance(valueType, order); - TreeSet treeSet = new TreeSet((Collection) value); - collect.set(i, treeSet); - if (debug) logger.debug("Set " + i + "th value to: " + treeSet.toString()); + /** */ + void runTest(PersistenceManager pm) { + if (!isTreeSetSupported()) { + if (debug) + logger.debug("JDO Implementation does not support " + + "the optional feature TreeSet"); + return; + } + + Transaction tx = pm.currentTransaction(); + TreeSetCollections expectedValue = new TreeSetCollections(); + + // turn on datastore transactions + tx.setOptimistic(false); + tx.begin(); + TreeSetCollections pi = new TreeSetCollections(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + // Provide initial set of values + setValues(pi, 1); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + setValues(expectedValue, 1); + // check if persistent fields have values set + checkValues(oid, expectedValue); + pi = (TreeSetCollections) pm.getObjectById(oid, true); + // Provide new set of values + setValues(pi, 2); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + setValues(expectedValue, 2); + checkValues(oid, expectedValue); + tx.commit(); } - } - /** */ - private void checkValues(Object oid, TreeSetCollections expectedValue) { - StringBuffer sbuf = new StringBuffer(); - TreeSetCollections pi = (TreeSetCollections) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (int i = 0; i < n; ++i) { - Collection expected = expectedValue.get(i); - Collection actual = pi.get(i); - if (actual.size() != expected.size()) { - sbuf.append( - "\nFor element " - + i - + ", expected size = " - + expected.size() - + ", actual size = " - + actual.size() - + " . "); - continue; - } - if (!expected.equals(actual)) { - sbuf.append( - "\nFor element " + i + ", expected = " + expected + ", actual = " + actual + " . "); - } + /** */ + private void setValues(TreeSetCollections collect, int order) + { + Vector value; + int n = collect.getLength(); + for (int i = 0; i < n; ++i) { + String valueType = TestUtil.getFieldSpecs( + TreeSetCollections.fieldSpecs[i]); + value = TestUtil.makeNewVectorInstance(valueType, order); + TreeSet treeSet = new TreeSet((Collection)value); + collect.set(i, treeSet); + if (debug) + logger.debug("Set " + i + "th value to: " + treeSet.toString()); + } } - if (sbuf.length() > 0) { - fail(ASSERTION_FAILED, "Expected and observed do not match!!" + sbuf.toString()); + + /** */ + private void checkValues(Object oid, TreeSetCollections expectedValue) + { + StringBuffer sbuf = new StringBuffer(); + TreeSetCollections pi = (TreeSetCollections) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for (int i = 0; i < n; ++i) { + Collection expected = expectedValue.get(i); + Collection actual = pi.get(i); + if (actual.size() != expected.size()) { + sbuf.append("\nFor element " + i + ", expected size = " + + expected.size() + ", actual size = " + actual.size() + + " . "); + continue; + } + if (! expected.equals(actual)) { + sbuf.append("\nFor element " + i + ", expected = " + + expected + ", actual = " + actual + " . "); + } + } + if (sbuf.length() > 0) { + fail(ASSERTION_FAILED, + "Expected and observed do not match!!" + sbuf.toString()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestUtil.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestUtil.java index 103b3f8fb..6db01b6a8 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestUtil.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestUtil.java @@ -5,37 +5,36 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.Date; -import java.util.Iterator; -import java.util.Locale; -import java.util.Set; -import java.util.Vector; +import java.util.*; +import java.math.*; + import org.apache.jdo.tck.pc.fieldtypes.AllTypes; import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.pc.fieldtypes.SimpleEnum; public class TestUtil { - public TestUtil() {} + public TestUtil() { + } - // gets the value type for fields of a collection class + //gets the value type for fields of a collection class public static String getFieldSpecs(String field) { - // sample field =public Collection CollectionOfObject0 - // look for last space and get the String before the numbers + //sample field =public Collection CollectionOfObject0 + //look for last space and get the String before the numbers String valueType = ""; int indexOfLastSpace = field.lastIndexOf(" "); @@ -43,7 +42,7 @@ public static String getFieldSpecs(String field) { int indexOfValueType = fieldName.indexOf("Of") + 2; String valueTypeWithNumber = fieldName.substring(indexOfValueType); int lastIndexOfValueType = 0; - for (int i = valueTypeWithNumber.length() - 1; i >= 0; i--) { + for (int i=valueTypeWithNumber.length() -1; i>=0; i--) { if (Character.isDigit(valueTypeWithNumber.charAt(i))) { continue; } else { @@ -51,316 +50,316 @@ public static String getFieldSpecs(String field) { break; } } - valueType = valueTypeWithNumber.substring(0, lastIndexOfValueType + 1); + valueType = valueTypeWithNumber.substring(0, lastIndexOfValueType+1); return valueType; } - // gets the key type and value type for fields of a Map class + + //gets the key type and value type for fields of a Map class public static Vector getFieldSpecsForMap(String field) { - // sample field =public HashMap HashMapOfObject_Object0 - // fieldType -- look for the last space and get the value between Of and _ - // valueType -- look for last _ and get the String before the numbers - String fieldType = ""; - String valueType = ""; + //sample field =public HashMap HashMapOfObject_Object0 + //fieldType -- look for the last space and get the value between Of and _ + //valueType -- look for last _ and get the String before the numbers + String fieldType = ""; + String valueType = ""; - int indexOfLastSpace = field.lastIndexOf(" "); - String fieldName = field.substring(indexOfLastSpace); - int indexOfFieldType = fieldName.indexOf("Of") + 2; - String fieldTypeWithValueType = fieldName.substring(indexOfFieldType); - int indexOfUnderScore = fieldTypeWithValueType.indexOf("_"); - fieldType = fieldTypeWithValueType.substring(0, indexOfUnderScore); + int indexOfLastSpace = field.lastIndexOf(" "); + String fieldName = field.substring(indexOfLastSpace); + int indexOfFieldType = fieldName.indexOf("Of") + 2; + String fieldTypeWithValueType = fieldName.substring(indexOfFieldType); + int indexOfUnderScore = fieldTypeWithValueType.indexOf("_"); + fieldType = fieldTypeWithValueType.substring(0, indexOfUnderScore); - String valueTypeWithNumber = fieldTypeWithValueType.substring(indexOfUnderScore + 1); - int lastIndexOfValueType = 0; - for (int i = valueTypeWithNumber.length() - 1; i >= 0; i--) { - if (Character.isDigit(valueTypeWithNumber.charAt(i))) { - continue; - } else { - lastIndexOfValueType = i; - break; + String valueTypeWithNumber = + fieldTypeWithValueType.substring(indexOfUnderScore + 1); + int lastIndexOfValueType = 0; + for (int i=valueTypeWithNumber.length() -1; i>=0; i--) { + if (Character.isDigit(valueTypeWithNumber.charAt(i))) { + continue; + } else { + lastIndexOfValueType = i; + break; + } } - } - valueType = valueTypeWithNumber.substring(0, lastIndexOfValueType + 1); + valueType = valueTypeWithNumber.substring(0, lastIndexOfValueType+1); - Vector fieldSpecs = new Vector(); - fieldSpecs.add(fieldType); - fieldSpecs.add(valueType); + Vector fieldSpecs = new Vector(); + fieldSpecs.add(fieldType); + fieldSpecs.add(valueType); - return fieldSpecs; + return fieldSpecs; } - public static String[] elementTypes = - new String[] { - "Object", - "SimpleClass", - "SimpleInterface", - "String", - "Date", - "Locale", - "BigDecimal", - "BigInteger", - "Byte", - "Double", - "Float", - "Integer", - "Long", - "Short", - "SimpleEnum" - }; + public static String [] elementTypes = new String[] + {"Object", "SimpleClass", "SimpleInterface", + "String", "Date", "Locale", "BigDecimal", + "BigInteger", "Byte", "Double", "Float", + "Integer", "Long", "Short", "SimpleEnum"}; private static int getIndexOf(String type) { - for (int i = 0; i < elementTypes.length; i++) { - if (type.equals(elementTypes[i])) return i; - } - return 9999; + for (int i=0; i < elementTypes.length; i++) { + if (type.equals(elementTypes[i])) + return i; + } + return 9999; } public static Vector makeNewVectorInstance(String type, int order) { - Vector vec = new Vector(); + Vector vec = new Vector(); - switch (order) { - case (1): - switch (getIndexOf(type)) { - case (0): - vec.add(0, new SimpleClass(1, "Hello World")); - vec.add(1, new SimpleClass(2, "Java Data Objects")); - vec.add(2, new SimpleClass(2, "Java")); - vec.add(3, new SimpleClass(4, "Origami")); - vec.add(4, new SimpleClass(5, "watch")); - break; - case (1): - case (2): - vec.add(0, new SimpleClass(1, "Welcome")); - vec.add(1, new SimpleClass(2, "To")); - vec.add(2, new SimpleClass(3, "The")); - vec.add(3, new SimpleClass(4, "Beautiful")); - vec.add(4, new SimpleClass(5, "World")); - break; - case (3): - vec.add(0, new String("Hello")); - vec.add(1, new String("Welcome")); - vec.add(2, new String("To The")); - vec.add(3, new String("Beautiful")); - vec.add(4, new String("World")); - break; - case (4): - vec.add(0, new Date(2007908)); - vec.add(1, new Date(89067382l)); - vec.add(2, new Date(890673822)); - vec.add(3, new Date(890673823)); - vec.add(4, new Date(890673824)); - break; - case (5): - vec.add(0, Locale.CHINA); - vec.add(1, Locale.FRANCE); - vec.add(2, Locale.GERMANY); - vec.add(3, Locale.JAPAN); - vec.add(4, Locale.ITALY); - break; - case (6): - vec.add(0, new BigDecimal("2007908.54548")); - vec.add(1, new BigDecimal("0.544")); - vec.add(2, new BigDecimal("3002323232.545454")); - vec.add(3, new BigDecimal("64564645656.78657")); - vec.add(4, new BigDecimal("4564565465.2342")); - break; - case (7): - vec.add(0, new BigInteger("2007908")); - vec.add(1, new BigInteger("767575")); - vec.add(2, new BigInteger("3002323232")); - vec.add(3, new BigInteger("64564645656")); - vec.add(4, new BigInteger("456445645")); - break; - case (8): - vec.add(0, Byte.valueOf((byte) Byte.MIN_VALUE)); - vec.add(1, Byte.valueOf((byte) Byte.MAX_VALUE)); - vec.add(2, Byte.valueOf((byte) (Byte.MAX_VALUE - 20))); - vec.add(3, Byte.valueOf((byte) (Byte.MAX_VALUE - 50))); - vec.add(4, Byte.valueOf((byte) (Byte.MAX_VALUE - 75))); - break; - case (9): - vec.add(0, Double.valueOf(AllTypes.DOUBLE_SMALLEST)); - vec.add(1, Double.valueOf(AllTypes.DOUBLE_LARGEST)); - vec.add(2, Double.valueOf(AllTypes.DOUBLE_LARGEST - 20000)); - vec.add(3, Double.valueOf(AllTypes.DOUBLE_LARGEST - 454545.436664)); - vec.add(4, Double.valueOf(AllTypes.DOUBLE_LARGEST - 2323235.76764677)); - break; - case (10): - vec.add(0, Float.valueOf((float) AllTypes.FLOAT_SMALLEST)); - vec.add(1, Float.valueOf((float) AllTypes.FLOAT_LARGEST)); - vec.add(2, Float.valueOf((float) AllTypes.FLOAT_LARGEST - 20000)); - vec.add(3, Float.valueOf((float) (AllTypes.FLOAT_LARGEST - 454545.434))); - vec.add(4, Float.valueOf((float) (AllTypes.FLOAT_LARGEST - 565656.43434))); - break; - case (11): - vec.add(0, Integer.valueOf(Integer.MIN_VALUE)); - vec.add(1, Integer.valueOf(Integer.MAX_VALUE)); - vec.add(2, Integer.valueOf(Integer.MAX_VALUE - 20000)); - vec.add(3, Integer.valueOf(Integer.MAX_VALUE - 343434343)); - vec.add(4, Integer.valueOf(Integer.MAX_VALUE - 565656)); - break; - case (12): - vec.add(0, Long.valueOf(Long.MIN_VALUE)); - vec.add(1, Long.valueOf(Long.MAX_VALUE)); - vec.add(2, Long.valueOf(Long.MAX_VALUE - 20000)); - vec.add(3, Long.valueOf(Long.MAX_VALUE - 343434343)); - vec.add(4, Long.valueOf(Long.MAX_VALUE - 565656)); - break; - case (13): - vec.add(0, Short.valueOf(Short.MIN_VALUE)); - vec.add(1, Short.valueOf(Short.MAX_VALUE)); - vec.add(2, Short.valueOf((short) (Short.MAX_VALUE - 20000))); - vec.add(3, Short.valueOf((short) (Short.MAX_VALUE - 343))); - vec.add(4, Short.valueOf((short) (Short.MAX_VALUE - 5656))); - break; - case (14): - vec.add(0, (SimpleEnum) SimpleEnum.AK); - vec.add(1, (SimpleEnum) SimpleEnum.FM); - vec.add(2, (SimpleEnum) SimpleEnum.KS); - vec.add(3, (SimpleEnum) SimpleEnum.NJ); - vec.add(4, (SimpleEnum) SimpleEnum.WI); - break; + switch (order) { + case(1): + switch (getIndexOf(type)) { + case(0): + vec.add(0, new SimpleClass(1, "Hello World")); + vec.add(1, new SimpleClass(2, "Java Data Objects")); + vec.add(2, new SimpleClass(2, "Java")); + vec.add(3, new SimpleClass(4, "Origami")); + vec.add(4, new SimpleClass(5, "watch")); + break; + case(1): + case(2): + vec.add(0, new SimpleClass(1, "Welcome")); + vec.add(1, new SimpleClass(2, "To")); + vec.add(2, new SimpleClass(3, "The")); + vec.add(3, new SimpleClass(4, "Beautiful")); + vec.add(4, new SimpleClass(5, "World")); + break; + case(3): + vec.add(0, new String("Hello")); + vec.add(1, new String("Welcome")); + vec.add(2, new String("To The")); + vec.add(3, new String("Beautiful")); + vec.add(4, new String("World")); + break; + case(4): + vec.add(0, new Date(2007908)); + vec.add(1, new Date(89067382l)); + vec.add(2, new Date(890673822)); + vec.add(3, new Date(890673823)); + vec.add(4, new Date(890673824)); + break; + case(5): + vec.add(0, Locale.CHINA); + vec.add(1, Locale.FRANCE); + vec.add(2, Locale.GERMANY); + vec.add(3, Locale.JAPAN); + vec.add(4, Locale.ITALY); + break; + case(6): + vec.add(0, new BigDecimal("2007908.54548")); + vec.add(1, new BigDecimal("0.544")); + vec.add(2, new BigDecimal("3002323232.545454")); + vec.add(3, new BigDecimal("64564645656.78657")); + vec.add(4, new BigDecimal("4564565465.2342")); + break; + case(7): + vec.add(0, new BigInteger("2007908")); + vec.add(1, new BigInteger("767575")); + vec.add(2, new BigInteger("3002323232")); + vec.add(3, new BigInteger("64564645656")); + vec.add(4, new BigInteger("456445645")); + break; + case(8): + vec.add(0, Byte.valueOf((byte)Byte.MIN_VALUE)); + vec.add(1, Byte.valueOf((byte)Byte.MAX_VALUE)); + vec.add(2, Byte.valueOf((byte)(Byte.MAX_VALUE- 20))); + vec.add(3, Byte.valueOf((byte)(Byte.MAX_VALUE - 50))); + vec.add(4, Byte.valueOf((byte)(Byte.MAX_VALUE - 75))); + break; + case(9): + vec.add(0, Double.valueOf(AllTypes.DOUBLE_SMALLEST)); + vec.add(1, Double.valueOf(AllTypes.DOUBLE_LARGEST)); + vec.add(2, Double.valueOf(AllTypes.DOUBLE_LARGEST - 20000)); + vec.add(3, Double.valueOf(AllTypes.DOUBLE_LARGEST + - 454545.436664)); + vec.add(4, Double.valueOf(AllTypes.DOUBLE_LARGEST + - 2323235.76764677)); + break; + case(10): + vec.add(0, Float.valueOf((float)AllTypes.FLOAT_SMALLEST)); + vec.add(1, Float.valueOf((float)AllTypes.FLOAT_LARGEST)); + vec.add(2, Float.valueOf((float)AllTypes.FLOAT_LARGEST - 20000)); + vec.add(3, Float.valueOf((float)(AllTypes.FLOAT_LARGEST + - 454545.434))); + vec.add(4, Float.valueOf((float)(AllTypes.FLOAT_LARGEST + - 565656.43434))); + break; + case(11): + vec.add(0, Integer.valueOf(Integer.MIN_VALUE)); + vec.add(1, Integer.valueOf(Integer.MAX_VALUE)); + vec.add(2, Integer.valueOf(Integer.MAX_VALUE - 20000)); + vec.add(3, Integer.valueOf(Integer.MAX_VALUE - 343434343)); + vec.add(4, Integer.valueOf(Integer.MAX_VALUE - 565656)); + break; + case(12): + vec.add(0, Long.valueOf(Long.MIN_VALUE)); + vec.add(1, Long.valueOf(Long.MAX_VALUE)); + vec.add(2, Long.valueOf(Long.MAX_VALUE - 20000)); + vec.add(3, Long.valueOf(Long.MAX_VALUE - 343434343)); + vec.add(4, Long.valueOf(Long.MAX_VALUE - 565656)); + break; + case(13): + vec.add(0, Short.valueOf(Short.MIN_VALUE)); + vec.add(1, Short.valueOf(Short.MAX_VALUE)); + vec.add(2, Short.valueOf((short)(Short.MAX_VALUE - 20000))); + vec.add(3, Short.valueOf((short)(Short.MAX_VALUE - 343))); + vec.add(4, Short.valueOf((short)(Short.MAX_VALUE - 5656))); + break; + case(14): + vec.add(0, (SimpleEnum)SimpleEnum.AK); + vec.add(1, (SimpleEnum)SimpleEnum.FM); + vec.add(2, (SimpleEnum)SimpleEnum.KS); + vec.add(3, (SimpleEnum)SimpleEnum.NJ); + vec.add(4, (SimpleEnum)SimpleEnum.WI); + break; + default: + throw new IndexOutOfBoundsException(); + } + return vec; + case(2): + switch (getIndexOf(type)) { + case(0): + vec.add(0, new SimpleClass(1, "Hi There")); + vec.add(1, new SimpleClass(1, "Hi")); + vec.add(2, new SimpleClass(2, "Object")); + vec.add(3, new SimpleClass(0, "Relational")); + vec.add(4, new SimpleClass(3, "Hi There")); + break; + case(1): + vec.add(0, new SimpleClass(1, "Peaches")); + vec.add(1, new SimpleClass(2, "Oranges")); + vec.add(2, new SimpleClass(3, "Blue Berries")); + vec.add(3, new SimpleClass(4, "Apples")); + vec.add(4, new SimpleClass(5, "Strawberries")); + break; + case(2): + vec.add(0, new SimpleClass(1, "Peaches")); + vec.add(1, new SimpleClass(2, "Oranges")); + vec.add(2, new SimpleClass(3, "Blue Berries")); + vec.add(3, new SimpleClass(4, "Apples")); + vec.add(4, new SimpleClass(5, "Strawberries")); + break; + case(3): + vec.add(0, new String("Peaches")); + vec.add(1, new String("Oranges")); + vec.add(2, new String("Blue Berries")); + vec.add(3, new String("Apples")); + vec.add(4, new String("Strawberries")); + break; + case(4): + vec.add(0, new Date(54545)); + vec.add(1, new Date(8905454l)); + vec.add(2, new Date(323545445)); + vec.add(3, new Date(890748967382l)); + vec.add(4, new Date(954545)); + break; + case(5): + vec.add(0, Locale.ENGLISH); + vec.add(1, Locale.JAPANESE); + vec.add(2, Locale.CANADA_FRENCH); + vec.add(3, Locale.KOREA); + vec.add(4, Locale.UK); + break; + case(6): + vec.add(0, new BigDecimal("434238.5454898989")); + vec.add(1, new BigDecimal("6.544")); + vec.add(2, new BigDecimal("55552323232.545454")); + vec.add(3, new BigDecimal("6456456.7543543534865785")); + vec.add(4, new BigDecimal("456456.4353452342")); + break; + case(7): + vec.add(0, new BigInteger("345345345345345345345345")); + vec.add(1, new BigInteger("543543543543544")); + vec.add(2, new BigInteger("65323423432423423")); + vec.add(3, new BigInteger("87845634534543")); + vec.add(4, new BigInteger("53452567766657567")); + break; + case(8): + vec.add(0, Byte.valueOf((byte)(Byte.MAX_VALUE-34))); + vec.add(1, Byte.valueOf((byte)Byte.MIN_VALUE)); + vec.add(2, Byte.valueOf((byte)(Byte.MAX_VALUE- 76))); + vec.add(3, Byte.valueOf((byte)Byte.MAX_VALUE)); + vec.add(4, Byte.valueOf((byte)(Byte.MAX_VALUE - 12))); + break; + case(9): + vec.add(0, Double.valueOf(AllTypes.DOUBLE_LARGEST - 343434)); + vec.add(1, Double.valueOf(AllTypes.DOUBLE_SMALLEST)); + vec.add(2, Double.valueOf(AllTypes.DOUBLE_LARGEST)); + vec.add(3, Double.valueOf(AllTypes.DOUBLE_LARGEST + - 65423445.436664)); + vec.add(4, Double.valueOf(AllTypes.DOUBLE_LARGEST + - 7235.236764677)); + break; + case(10): + vec.add(0, Float.valueOf((float)(AllTypes.FLOAT_LARGEST - 5452))); + vec.add(1, Float.valueOf((float)AllTypes.FLOAT_SMALLEST)); + vec.add(2, Float.valueOf((float)(AllTypes.FLOAT_LARGEST - 6564560.54))); + vec.add(3, Float.valueOf((float)AllTypes.FLOAT_LARGEST)); + vec.add(4, Float.valueOf((float)(AllTypes.FLOAT_LARGEST - 9756.634))); + break; + case(11): + vec.add(0, Integer.valueOf(Integer.MAX_VALUE - 54454)); + vec.add(1, Integer.valueOf(Integer.MIN_VALUE)); + vec.add(2, Integer.valueOf(Integer.MAX_VALUE)); + vec.add(3, Integer.valueOf(Integer.MAX_VALUE - 767234)); + vec.add(4, Integer.valueOf(Integer.MAX_VALUE - 23673446)); + break; + case(12): + vec.add(0, Long.valueOf(Long.MAX_VALUE - 545345454)); + vec.add(1, Long.valueOf(Long.MIN_VALUE)); + vec.add(2, Long.valueOf(Long.MAX_VALUE)); + vec.add(3, Long.valueOf(Long.MAX_VALUE - 3543343)); + vec.add(4, Long.valueOf(Long.MAX_VALUE - 556)); + break; + case(13): + vec.add(0, Short.valueOf((short)(Short.MAX_VALUE - 3434))); + vec.add(1, Short.valueOf(Short.MIN_VALUE)); + vec.add(2, Short.valueOf((short)(Short.MAX_VALUE))); + vec.add(3, Short.valueOf((short)(Short.MAX_VALUE - 23344))); + vec.add(4, Short.valueOf((short)(Short.MAX_VALUE - 723))); + break; + case(14): + vec.add(0, (SimpleEnum)SimpleEnum.AZ); + vec.add(1, (SimpleEnum)SimpleEnum.SD); + vec.add(2, (SimpleEnum)SimpleEnum.NV); + vec.add(3, (SimpleEnum)SimpleEnum.WV); + vec.add(4, (SimpleEnum)SimpleEnum.PA); + break; + default: + throw new IndexOutOfBoundsException(); + } + return vec; default: - throw new IndexOutOfBoundsException(); - } - return vec; - case (2): - switch (getIndexOf(type)) { - case (0): - vec.add(0, new SimpleClass(1, "Hi There")); - vec.add(1, new SimpleClass(1, "Hi")); - vec.add(2, new SimpleClass(2, "Object")); - vec.add(3, new SimpleClass(0, "Relational")); - vec.add(4, new SimpleClass(3, "Hi There")); - break; - case (1): - vec.add(0, new SimpleClass(1, "Peaches")); - vec.add(1, new SimpleClass(2, "Oranges")); - vec.add(2, new SimpleClass(3, "Blue Berries")); - vec.add(3, new SimpleClass(4, "Apples")); - vec.add(4, new SimpleClass(5, "Strawberries")); - break; - case (2): - vec.add(0, new SimpleClass(1, "Peaches")); - vec.add(1, new SimpleClass(2, "Oranges")); - vec.add(2, new SimpleClass(3, "Blue Berries")); - vec.add(3, new SimpleClass(4, "Apples")); - vec.add(4, new SimpleClass(5, "Strawberries")); - break; - case (3): - vec.add(0, new String("Peaches")); - vec.add(1, new String("Oranges")); - vec.add(2, new String("Blue Berries")); - vec.add(3, new String("Apples")); - vec.add(4, new String("Strawberries")); - break; - case (4): - vec.add(0, new Date(54545)); - vec.add(1, new Date(8905454l)); - vec.add(2, new Date(323545445)); - vec.add(3, new Date(890748967382l)); - vec.add(4, new Date(954545)); - break; - case (5): - vec.add(0, Locale.ENGLISH); - vec.add(1, Locale.JAPANESE); - vec.add(2, Locale.CANADA_FRENCH); - vec.add(3, Locale.KOREA); - vec.add(4, Locale.UK); - break; - case (6): - vec.add(0, new BigDecimal("434238.5454898989")); - vec.add(1, new BigDecimal("6.544")); - vec.add(2, new BigDecimal("55552323232.545454")); - vec.add(3, new BigDecimal("6456456.7543543534865785")); - vec.add(4, new BigDecimal("456456.4353452342")); - break; - case (7): - vec.add(0, new BigInteger("345345345345345345345345")); - vec.add(1, new BigInteger("543543543543544")); - vec.add(2, new BigInteger("65323423432423423")); - vec.add(3, new BigInteger("87845634534543")); - vec.add(4, new BigInteger("53452567766657567")); - break; - case (8): - vec.add(0, Byte.valueOf((byte) (Byte.MAX_VALUE - 34))); - vec.add(1, Byte.valueOf((byte) Byte.MIN_VALUE)); - vec.add(2, Byte.valueOf((byte) (Byte.MAX_VALUE - 76))); - vec.add(3, Byte.valueOf((byte) Byte.MAX_VALUE)); - vec.add(4, Byte.valueOf((byte) (Byte.MAX_VALUE - 12))); - break; - case (9): - vec.add(0, Double.valueOf(AllTypes.DOUBLE_LARGEST - 343434)); - vec.add(1, Double.valueOf(AllTypes.DOUBLE_SMALLEST)); - vec.add(2, Double.valueOf(AllTypes.DOUBLE_LARGEST)); - vec.add(3, Double.valueOf(AllTypes.DOUBLE_LARGEST - 65423445.436664)); - vec.add(4, Double.valueOf(AllTypes.DOUBLE_LARGEST - 7235.236764677)); - break; - case (10): - vec.add(0, Float.valueOf((float) (AllTypes.FLOAT_LARGEST - 5452))); - vec.add(1, Float.valueOf((float) AllTypes.FLOAT_SMALLEST)); - vec.add(2, Float.valueOf((float) (AllTypes.FLOAT_LARGEST - 6564560.54))); - vec.add(3, Float.valueOf((float) AllTypes.FLOAT_LARGEST)); - vec.add(4, Float.valueOf((float) (AllTypes.FLOAT_LARGEST - 9756.634))); - break; - case (11): - vec.add(0, Integer.valueOf(Integer.MAX_VALUE - 54454)); - vec.add(1, Integer.valueOf(Integer.MIN_VALUE)); - vec.add(2, Integer.valueOf(Integer.MAX_VALUE)); - vec.add(3, Integer.valueOf(Integer.MAX_VALUE - 767234)); - vec.add(4, Integer.valueOf(Integer.MAX_VALUE - 23673446)); - break; - case (12): - vec.add(0, Long.valueOf(Long.MAX_VALUE - 545345454)); - vec.add(1, Long.valueOf(Long.MIN_VALUE)); - vec.add(2, Long.valueOf(Long.MAX_VALUE)); - vec.add(3, Long.valueOf(Long.MAX_VALUE - 3543343)); - vec.add(4, Long.valueOf(Long.MAX_VALUE - 556)); - break; - case (13): - vec.add(0, Short.valueOf((short) (Short.MAX_VALUE - 3434))); - vec.add(1, Short.valueOf(Short.MIN_VALUE)); - vec.add(2, Short.valueOf((short) (Short.MAX_VALUE))); - vec.add(3, Short.valueOf((short) (Short.MAX_VALUE - 23344))); - vec.add(4, Short.valueOf((short) (Short.MAX_VALUE - 723))); - break; - case (14): - vec.add(0, (SimpleEnum) SimpleEnum.AZ); - vec.add(1, (SimpleEnum) SimpleEnum.SD); - vec.add(2, (SimpleEnum) SimpleEnum.NV); - vec.add(3, (SimpleEnum) SimpleEnum.WV); - vec.add(4, (SimpleEnum) SimpleEnum.PA); - break; - default: - throw new IndexOutOfBoundsException(); - } - return vec; - default: - throw new IndexOutOfBoundsException(); + throw new IndexOutOfBoundsException(); + } } - } - protected static boolean containsBigDecimalKey(BigDecimal keyValue, Set bigDecimalKeySet) { - Iterator iter = bigDecimalKeySet.iterator(); - while (iter.hasNext()) { - BigDecimal nextVal = (BigDecimal) iter.next(); - if (keyValue.compareTo(nextVal) == 0) { - return true; - } + protected static boolean containsBigDecimalKey(BigDecimal keyValue, + Set bigDecimalKeySet) + { + Iterator iter = bigDecimalKeySet.iterator(); + while (iter.hasNext()) { + BigDecimal nextVal = (BigDecimal) iter.next(); + if (keyValue.compareTo(nextVal) == 0) { + return true; + } + } + return false; } - return false; - } - protected static BigDecimal getBigDecimalKey(BigDecimal keyValue, Set bigDecimalKeySet) { - Iterator iter = bigDecimalKeySet.iterator(); - while (iter.hasNext()) { - BigDecimal nextVal = (BigDecimal) iter.next(); - if (keyValue.compareTo(nextVal) == 0) { - return nextVal; - } + protected static BigDecimal getBigDecimalKey(BigDecimal keyValue, + Set bigDecimalKeySet) + { + Iterator iter = bigDecimalKeySet.iterator(); + while (iter.hasNext()) { + BigDecimal nextVal = (BigDecimal) iter.next(); + if (keyValue.compareTo(nextVal) == 0) { + return nextVal; + } + } + return null; } - return null; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestVectorCollections.java b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestVectorCollections.java index 6409caf2e..15b21b5fa 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestVectorCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/fieldtypes/TestVectorCollections.java @@ -5,175 +5,187 @@ * 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 + * + * 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.jdo.tck.models.fieldtypes; import java.math.BigDecimal; + +import java.util.Collection; import java.util.Vector; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; -import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.pc.fieldtypes.VectorCollections; +import org.apache.jdo.tck.pc.fieldtypes.SimpleClass; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support of field type Vector.
    - * Keywords: model
    - * Assertion ID: A6.4.3-29.
    - * Assertion Description: If the Vector optional feature is supported, then JDO - * implementation must support fields of the mutable object class Vector, supporting - * them as Second Class Objects or First Class Objects. + *Title: Support of field type Vector. + *
    + *Keywords: model + *
    + *Assertion ID: A6.4.3-29. + *
    + *Assertion Description: +If the Vector optional feature is supported, then JDO implementation +must support fields of the mutable object class Vector, +supporting them as Second Class Objects or First Class Objects. */ -public class TestVectorCollections extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.4.3-29 (TestVectorCollections) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TestVectorCollections.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(VectorCollections.class); - addTearDownClass(SimpleClass.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTest(pm); - - pm.close(); - pm = null; - } +public class TestVectorCollections extends JDO_Test { - /** */ - void runTest(PersistenceManager pm) { - if (!isVectorSupported()) { - if (debug) - logger.debug("JDO Implementation does not support " + "the optional feature Vector"); - return; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.4.3-29 (TestVectorCollections) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TestVectorCollections.class); } - Transaction tx = pm.currentTransaction(); - VectorCollections expectedValue = new VectorCollections(); - - // turn on datastore transactions - tx.setOptimistic(false); - tx.begin(); - VectorCollections pi = new VectorCollections(); - pi.identifier = 1; - pm.makePersistent(pi); - Object oid = pm.getObjectId(pi); - // Provide initial set of values - setValues(pi, 1); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - setValues(expectedValue, 1); - // check if persistent fields have values set - checkValues(oid, expectedValue); - pi = (VectorCollections) pm.getObjectById(oid, true); - // Provide new set of values - setValues(pi, 2); - tx.commit(); - - // cache will be flushed - pi = null; - System.gc(); - - tx.begin(); - // check new values - setValues(expectedValue, 2); - checkValues(oid, expectedValue); - tx.commit(); - } - - /** */ - private void setValues(VectorCollections collect, int order) { - Vector value; - int n = collect.getLength(); - for (int i = 0; i < n; ++i) { - String valueType = TestUtil.getFieldSpecs(VectorCollections.fieldSpecs[i]); - value = TestUtil.makeNewVectorInstance(valueType, order); - collect.set(i, value); - if (debug) logger.debug("Set " + i + "th value to: " + value.toString()); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(VectorCollections.class); + addTearDownClass(SimpleClass.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTest(PersistenceManager pm) + { + if (!isVectorSupported()) { + if (debug) + logger.debug("JDO Implementation does not support " + + "the optional feature Vector"); + return; + } + + Transaction tx = pm.currentTransaction(); + VectorCollections expectedValue = new VectorCollections(); + + // turn on datastore transactions + tx.setOptimistic(false); + tx.begin(); + VectorCollections pi = new VectorCollections(); + pi.identifier = 1; + pm.makePersistent(pi); + Object oid = pm.getObjectId(pi); + // Provide initial set of values + setValues(pi, 1); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + setValues(expectedValue, 1); + // check if persistent fields have values set + checkValues(oid, expectedValue); + pi = (VectorCollections) pm.getObjectById(oid, true); + // Provide new set of values + setValues(pi, 2); + tx.commit(); + + // cache will be flushed + pi = null; + System.gc(); + + tx.begin(); + // check new values + setValues(expectedValue, 2); + checkValues(oid, expectedValue); + tx.commit(); } - } - /** */ - private void checkValues(Object oid, VectorCollections expectedValue) { - StringBuffer sbuf = new StringBuffer(); - VectorCollections pi = (VectorCollections) pm.getObjectById(oid, true); - int n = pi.getLength(); - for (int i = 0; i < n; i++) { - Vector expected = expectedValue.get(i); - Vector actual = pi.get(i); - if (actual.size() != expected.size()) { - sbuf.append( - "\nFor element " - + i - + ", expected size = " - + expected.size() - + ", actual size = " - + actual.size() - + " . "); - } else if (!expected.equals(actual)) { - if (debug) { - logger.debug("Field number is " + i); - logger.debug("Persisted vector is " + actual); - logger.debug("Expected vector is " + expected); + /** */ + private void setValues(VectorCollections collect, int order) + { + Vector value; + int n = collect.getLength(); + for (int i = 0; i < n; ++i) { + String valueType = TestUtil.getFieldSpecs( + VectorCollections.fieldSpecs[i]); + value = TestUtil.makeNewVectorInstance(valueType, order); + collect.set(i, value); + if (debug) + logger.debug("Set " + i + "th value to: " + value.toString()); } - if (TestUtil.getFieldSpecs(VectorCollections.fieldSpecs[i]).equals("BigDecimal")) { - for (int j = 0; j < actual.size(); j++) { - BigDecimal bigDecActual = (BigDecimal) actual.elementAt(j); - BigDecimal bigDecExpected = (BigDecimal) expected.elementAt(j); - if ((bigDecExpected.compareTo(bigDecActual) != 0)) { - sbuf.append( - "\nFor element " - + i - + "(" - + j - + "), expected = " - + expected - + ", actual = " - + actual - + " . "); + } + + /** */ + private void checkValues(Object oid, VectorCollections expectedValue) + { + StringBuffer sbuf = new StringBuffer(); + VectorCollections pi = (VectorCollections) + pm.getObjectById(oid, true); + int n = pi.getLength(); + for (int i = 0; i < n; i++) { + Vector expected = expectedValue.get(i); + Vector actual = pi.get(i); + if (actual.size() != expected.size()) { + sbuf.append("\nFor element " + i + ", expected size = " + + expected.size() + ", actual size = " + actual.size() + + " . "); + } + else if (! expected.equals(actual)) { + if (debug) { + logger.debug("Field number is " + i); + logger.debug("Persisted vector is " + actual); + logger.debug("Expected vector is " + expected); + } + if (TestUtil.getFieldSpecs(VectorCollections.fieldSpecs[i] + ).equals("BigDecimal")) { + for (int j = 0; j < actual.size(); j++) { + BigDecimal bigDecActual = + (BigDecimal)actual.elementAt(j); + BigDecimal bigDecExpected = + (BigDecimal)expected.elementAt(j); + if ((bigDecExpected.compareTo(bigDecActual) != 0)) { + sbuf.append("\nFor element " + i + "(" + j + + "), expected = " + expected + + ", actual = " + actual + " . "); + } + } + } + else { + sbuf.append("\nFor element " + i + ", expected = " + + expected + ", actual = " + actual + " . "); + } } - } - } else { - sbuf.append( - "\nFor element " + i + ", expected = " + expected + ", actual = " + actual + " . "); + + } + if (sbuf.length() > 0) { + fail(ASSERTION_FAILED, + "Expected and observed do not match!!" + sbuf.toString()); } - } - } - if (sbuf.length() > 0) { - fail(ASSERTION_FAILED, "Expected and observed do not match!!" + sbuf.toString()); } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/inheritance/FieldWithSameNameInSuperclass.java b/tck/src/main/java/org/apache/jdo/tck/models/inheritance/FieldWithSameNameInSuperclass.java index 1f8f7891a..9b3d515e7 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/inheritance/FieldWithSameNameInSuperclass.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/inheritance/FieldWithSameNameInSuperclass.java @@ -5,344 +5,238 @@ * 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 + * + * 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.jdo.tck.models.inheritance; import java.util.Iterator; + import javax.jdo.Extent; import javax.jdo.JDOException; import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.inheritance.Constants; import org.apache.jdo.tck.pc.inheritance.FieldSameName4; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Field With the Same Name as a Field in a Superclass
    - * Keywords: inheritance
    - * Assertion ID: A6.5-7.
    - * Assertion Description: A class might define a new field with the same name as the field - * declared in the superclass, and might define it to be different (persistent or not) from the - * inherited field. But Java treats the declared field as a different field from the inherited - * field, so there is no conflict. - */ -public class FieldWithSameNameInSuperclass extends TestParts { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.5-7 (FieldWithSameNameInSuperclass) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(FieldWithSameNameInSuperclass.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldSameName4.class); - } + *Title: Field With the Same Name as a Field in a Superclass + *
    + *Keywords: inheritance + *
    + *Assertion ID: A6.5-7. + *
    + *Assertion Description: +A class might define a new field with the same name as the field declared +in the superclass, and might define it to be different (persistent or not) +from the inherited field. But Java treats the declared field as a different +field from the inherited field, so there is no conflict. - /** */ - public void test() { - pm = getPM(); - - runTest(pm); - - pm.close(); - pm = null; - } - - /** */ - void runTest(PersistenceManager pm) { - Transaction t = pm.currentTransaction(); - try { - t.setRestoreValues(true); - - t.begin(); - FieldSameName4 refa = - new FieldSameName4( - Constants.intA_V[1], - Constants.doubleB_V[1], - Constants.intB_V[1], - Constants.charC_V[1], - Constants.booleanD_V[1], - Constants.floatE_V[1], - Constants.shortF_V[1], - Constants.shortG_V[1], - Constants.intH_V[1]); - pm.makePersistent(refa); - Object objPtrA = pm.getObjectId(refa); - - refa.setSecondObj( - new FieldSameName4( - Constants.intA_V[2], - Constants.doubleB_V[2], - Constants.intB_V[2], - Constants.charC_V[2], - Constants.booleanD_V[2], - Constants.floatE_V[2], - Constants.shortF_V[2], - Constants.shortG_V[2], - Constants.intH_V[2])); - TestParts.secondObj_V[1] = refa.getSecondObj(); - refa.setThirdObj( - new FieldSameName4( - Constants.intA_V[3], - Constants.doubleB_V[3], - Constants.intB_V[3], - Constants.charC_V[3], - Constants.booleanD_V[3], - Constants.floatE_V[3], - Constants.shortF_V[3], - Constants.shortG_V[3], - Constants.intH_V[3])); - TestParts.thirdObj_V[1] = refa.getThirdObj(); - pm.makePersistent(TestParts.thirdObj_V[1]); - Object objPtrB = pm.getObjectId(TestParts.thirdObj_V[1]); - refa.setFourthObj( - new FieldSameName4( - Constants.intA_V[4], - Constants.doubleB_V[4], - Constants.intB_V[4], - Constants.charC_V[4], - Constants.booleanD_V[4], - Constants.floatE_V[4], - Constants.shortF_V[4], - Constants.shortG_V[4], - Constants.intH_V[4])); - TestParts.fourthObj_V[1] = refa.getFourthObj(); - try { - t.commit(); - } catch (JDOException e) { - Object o = e.getFailedObject(); - String cname = o == null ? "null" : o.getClass().getName(); - fail( - ASSERTION_FAILED, - "Exception thrown, failed object class is " + cname + " exception is " + e); - } - - t.begin(); - FieldSameName4 a = null; - FieldSameName4 b = null; + */ - try { // retrieve object created in previous transaction & store in value array for later - // comparison - TestParts.thirdObj_V[1] = (FieldSameName4) pm.getObjectById(objPtrB, true); - } catch (JDOUserException e) { - // could not locate persistent object created in previous - // transaction - fail(ASSERTION_FAILED, "JDOUserException " + e + " could not reference thirdObj."); - } +public class FieldWithSameNameInSuperclass extends TestParts { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.5-7 (FieldWithSameNameInSuperclass) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(FieldWithSameNameInSuperclass.class); + } - try { // retrieve object created in previous transaction - a = (FieldSameName4) pm.getObjectById(objPtrA, true); - checkPersistentAreCorrect( - ASSERTION_FAILED, - persistentAfterCommit, - 1, - a.getDoubleB(), - a.getIntB(), - a.getShortF(), - a.getThirdObj(), - a.getIntH()); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldSameName4.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } - // verify referenced persistent object contains correct values - b = a.getThirdObj(); - if (b != null) { // if previous error caused b to be null, then these tests cannot be - // performed. - checkPersistentAreCorrect( - ASSERTION_FAILED, - persistentAfterCommit, - 3, - b.getDoubleB(), - b.getIntB(), - b.getShortF(), - b.getThirdObj(), - b.getIntH()); + /** */ + void runTest(PersistenceManager pm) + { + Transaction t = pm.currentTransaction(); + try { + t.setRestoreValues(true); + + t.begin(); + FieldSameName4 refa = new FieldSameName4(Constants.intA_V[1], Constants.doubleB_V[1], Constants.intB_V[1], Constants.charC_V[1], Constants.booleanD_V[1], Constants.floatE_V[1], Constants.shortF_V[1], Constants.shortG_V[1], Constants.intH_V[1]); + pm.makePersistent(refa); + Object objPtrA = pm.getObjectId (refa); + + refa.setSecondObj(new FieldSameName4(Constants.intA_V[2], Constants.doubleB_V[2], Constants.intB_V[2], Constants.charC_V[2], Constants.booleanD_V[2], Constants.floatE_V[2], Constants.shortF_V[2], Constants.shortG_V[2], Constants.intH_V[2])); + TestParts.secondObj_V[1] = refa.getSecondObj(); + refa.setThirdObj(new FieldSameName4(Constants.intA_V[3], Constants.doubleB_V[3], Constants.intB_V[3], Constants.charC_V[3], Constants.booleanD_V[3], Constants.floatE_V[3], Constants.shortF_V[3], Constants.shortG_V[3], Constants.intH_V[3])); + TestParts.thirdObj_V[1] = refa.getThirdObj(); + pm.makePersistent(TestParts.thirdObj_V[1]); + Object objPtrB = pm.getObjectId(TestParts.thirdObj_V[1]); + refa.setFourthObj(new FieldSameName4(Constants.intA_V[4], Constants.doubleB_V[4], Constants.intB_V[4], Constants.charC_V[4], Constants.booleanD_V[4], Constants.floatE_V[4], Constants.shortF_V[4], Constants.shortG_V[4], Constants.intH_V[4])); + TestParts.fourthObj_V[1] = refa.getFourthObj(); + try { + t.commit(); + } catch(JDOException e) { + Object o = e.getFailedObject(); + String cname = o == null ? "null" : o.getClass().getName(); + fail(ASSERTION_FAILED, + "Exception thrown, failed object class is " + cname + " exception is " + e); + } + + t.begin(); + FieldSameName4 a = null; + FieldSameName4 b = null; + + try { // retrieve object created in previous transaction & store in value array for later comparison + TestParts.thirdObj_V[1] = (FieldSameName4) pm.getObjectById(objPtrB, true); + } + catch (JDOUserException e) { + // could not locate persistent object created in previous + // transaction + fail(ASSERTION_FAILED, + "JDOUserException " + e + " could not reference thirdObj."); + } + + try { // retrieve object created in previous transaction + a = (FieldSameName4) pm.getObjectById(objPtrA, true); + checkPersistentAreCorrect(ASSERTION_FAILED, persistentAfterCommit, 1, a.getDoubleB(), a.getIntB(), a.getShortF(), a.getThirdObj(), a.getIntH()); + + // verify referenced persistent object contains correct values + b = a.getThirdObj(); + if(b != null) { // if previous error caused b to be null, then these tests cannot be performed. + checkPersistentAreCorrect(ASSERTION_FAILED, persistentAfterCommit, 3, b.getDoubleB(), b.getIntB(), b.getShortF(), b.getThirdObj(), b.getIntH()); + } + } + catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, + "JDOUserException " + e + " could not reference previously created object."); + } + + // set in new values + a.setIntA(Constants.intA_V[5]); + a.setCharC(Constants.charC_V[5]); + a.setBooleanD(Constants.booleanD_V[5]); + a.setShortG(Constants.shortG_V[5]); + FieldSameName4 fourth = new FieldSameName4(Constants.intA_V[6], Constants.doubleB_V[6], Constants.intB_V[6], Constants.charC_V[6], Constants.booleanD_V[6], Constants.floatE_V[6], Constants.shortF_V[6], Constants.shortG_V[6], Constants.intH_V[6]); + a.setFourthObj(fourth); + a.setFloatE(Constants.floatE_V[5]); + a.setSecondObj(null); + a.setDoubleB(Constants.doubleB_V[5]); + a.setIntB(Constants.intB_V[5]); + a.setShortF(Constants.shortF_V[5]); + a.setThirdObj(null); + a.setIntH(Constants.intH_V[5]); + + b.setIntA(Constants.intA_V[7]); + b.setCharC(Constants.charC_V[7]); + b.setBooleanD(Constants.booleanD_V[7]); + b.setShortG(Constants.shortG_V[7]); + b.setFourthObj(null); + b.setFloatE(Constants.floatE_V[7]); + b.setSecondObj(null); + b.setDoubleB(Constants.doubleB_V[7]); + b.setIntB(Constants.intB_V[7]); + b.setShortF(Constants.shortF_V[7]); + b.setThirdObj(null); + b.setIntH(Constants.intH_V[7]); + + // create new objects and make persistent + FieldSameName4 c = new FieldSameName4(Constants.intA_V[8], Constants.doubleB_V[8], Constants.intB_V[8], Constants.charC_V[8], Constants.booleanD_V[8], Constants.floatE_V[8], Constants.shortF_V[8], Constants.shortG_V[8], Constants.intH_V[8]); + FieldSameName4 d = new FieldSameName4(Constants.intA_V[9], Constants.doubleB_V[9], Constants.intB_V[9], Constants.charC_V[9], Constants.booleanD_V[9], Constants.floatE_V[9], Constants.shortF_V[9], Constants.shortG_V[9], Constants.intH_V[9]); + c.setThirdObj(d); + c.setFourthObj(d); + TestParts.thirdObj_V[8] = d; + TestParts.fourthObj_V[8] = d; + pm.makePersistent(c); + + // change values of newly persistent object + c.setIntA(Constants.intA_V[10]); + c.setCharC(Constants.charC_V[10]); + c.setBooleanD(Constants.booleanD_V[10]); + c.setShortG(Constants.shortG_V[10]); + c.setFourthObj(null); + c.setFloatE(Constants.floatE_V[10]); + c.setSecondObj(null); + c.setDoubleB(Constants.doubleB_V[10]); + c.setIntB(Constants.intB_V[10]); + c.setShortF(Constants.shortF_V[10]); + c.setThirdObj(null); + c.setIntH(Constants.intH_V[10]); + + t.rollback(); + + // verify objects revert back to transient after rollback + checkPersistentAreCorrect(ASSERTION_FAILED, transientAfterRollback, 8, c.getDoubleB(), c.getIntB(), c.getShortF(), c.getThirdObj(), c.getIntH()); + checkTransactionalAreCorrect(ASSERTION_FAILED, transientAfterRollback, 8, c.getFloatE(), c.getSecondObj()); + checkNonpersistentAreCorrect(ASSERTION_FAILED, transientAfterRollback, 10, c.getIntA(), c.getCharC(), c.getBooleanD(), c.getShortG(), c.getFourthObj()); + + t.begin(); + + // verify rollback lost all persistent changes. + try { // retrieve object created in previous transaction & store in value array for later comparison + TestParts.thirdObj_V[1] = (FieldSameName4) pm.getObjectById(objPtrB, true); + } + catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, + "JDOUserException " + e + " could not reference thirdObj."); + } + + try { // retrieve object created in previous transaction + a = (FieldSameName4) pm.getObjectById(objPtrA, true); + checkPersistentAreCorrect(ASSERTION_FAILED, persistentAfterRollback, 1, a.getDoubleB(), a.getIntB(), a.getShortF(), a.getThirdObj(), a.getIntH()); + b = a.getThirdObj(); + if(b != null) { // if previous error caused b to be null, then these tests cannot be performed. + checkPersistentAreCorrect(ASSERTION_FAILED, persistentAfterRollback, 3, b.getDoubleB(), b.getIntB(), b.getShortF(), b.getThirdObj(), b.getIntH()); + } + } + catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, + "JDOUserException " + e + " could not reference previously created object."); + } + + t.rollback(); + t = null; } - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail( - ASSERTION_FAILED, - "JDOUserException " + e + " could not reference previously created object."); - } - - // set in new values - a.setIntA(Constants.intA_V[5]); - a.setCharC(Constants.charC_V[5]); - a.setBooleanD(Constants.booleanD_V[5]); - a.setShortG(Constants.shortG_V[5]); - FieldSameName4 fourth = - new FieldSameName4( - Constants.intA_V[6], - Constants.doubleB_V[6], - Constants.intB_V[6], - Constants.charC_V[6], - Constants.booleanD_V[6], - Constants.floatE_V[6], - Constants.shortF_V[6], - Constants.shortG_V[6], - Constants.intH_V[6]); - a.setFourthObj(fourth); - a.setFloatE(Constants.floatE_V[5]); - a.setSecondObj(null); - a.setDoubleB(Constants.doubleB_V[5]); - a.setIntB(Constants.intB_V[5]); - a.setShortF(Constants.shortF_V[5]); - a.setThirdObj(null); - a.setIntH(Constants.intH_V[5]); - - b.setIntA(Constants.intA_V[7]); - b.setCharC(Constants.charC_V[7]); - b.setBooleanD(Constants.booleanD_V[7]); - b.setShortG(Constants.shortG_V[7]); - b.setFourthObj(null); - b.setFloatE(Constants.floatE_V[7]); - b.setSecondObj(null); - b.setDoubleB(Constants.doubleB_V[7]); - b.setIntB(Constants.intB_V[7]); - b.setShortF(Constants.shortF_V[7]); - b.setThirdObj(null); - b.setIntH(Constants.intH_V[7]); - - // create new objects and make persistent - FieldSameName4 c = - new FieldSameName4( - Constants.intA_V[8], - Constants.doubleB_V[8], - Constants.intB_V[8], - Constants.charC_V[8], - Constants.booleanD_V[8], - Constants.floatE_V[8], - Constants.shortF_V[8], - Constants.shortG_V[8], - Constants.intH_V[8]); - FieldSameName4 d = - new FieldSameName4( - Constants.intA_V[9], - Constants.doubleB_V[9], - Constants.intB_V[9], - Constants.charC_V[9], - Constants.booleanD_V[9], - Constants.floatE_V[9], - Constants.shortF_V[9], - Constants.shortG_V[9], - Constants.intH_V[9]); - c.setThirdObj(d); - c.setFourthObj(d); - TestParts.thirdObj_V[8] = d; - TestParts.fourthObj_V[8] = d; - pm.makePersistent(c); - - // change values of newly persistent object - c.setIntA(Constants.intA_V[10]); - c.setCharC(Constants.charC_V[10]); - c.setBooleanD(Constants.booleanD_V[10]); - c.setShortG(Constants.shortG_V[10]); - c.setFourthObj(null); - c.setFloatE(Constants.floatE_V[10]); - c.setSecondObj(null); - c.setDoubleB(Constants.doubleB_V[10]); - c.setIntB(Constants.intB_V[10]); - c.setShortF(Constants.shortF_V[10]); - c.setThirdObj(null); - c.setIntH(Constants.intH_V[10]); - - t.rollback(); - - // verify objects revert back to transient after rollback - checkPersistentAreCorrect( - ASSERTION_FAILED, - transientAfterRollback, - 8, - c.getDoubleB(), - c.getIntB(), - c.getShortF(), - c.getThirdObj(), - c.getIntH()); - checkTransactionalAreCorrect( - ASSERTION_FAILED, transientAfterRollback, 8, c.getFloatE(), c.getSecondObj()); - checkNonpersistentAreCorrect( - ASSERTION_FAILED, - transientAfterRollback, - 10, - c.getIntA(), - c.getCharC(), - c.getBooleanD(), - c.getShortG(), - c.getFourthObj()); - - t.begin(); - - // verify rollback lost all persistent changes. - try { // retrieve object created in previous transaction & store in value array for later - // comparison - TestParts.thirdObj_V[1] = (FieldSameName4) pm.getObjectById(objPtrB, true); - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail(ASSERTION_FAILED, "JDOUserException " + e + " could not reference thirdObj."); - } - - try { // retrieve object created in previous transaction - a = (FieldSameName4) pm.getObjectById(objPtrA, true); - checkPersistentAreCorrect( - ASSERTION_FAILED, - persistentAfterRollback, - 1, - a.getDoubleB(), - a.getIntB(), - a.getShortF(), - a.getThirdObj(), - a.getIntH()); - b = a.getThirdObj(); - if (b != null) { // if previous error caused b to be null, then these tests cannot be - // performed. - checkPersistentAreCorrect( - ASSERTION_FAILED, - persistentAfterRollback, - 3, - b.getDoubleB(), - b.getIntB(), - b.getShortF(), - b.getThirdObj(), - b.getIntH()); + finally { + if ((t != null) && t.isActive()) + t.rollback(); } - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail( - ASSERTION_FAILED, - "JDOUserException " + e + " could not reference previously created object."); - } - - t.rollback(); - t = null; - } finally { - if ((t != null) && t.isActive()) t.rollback(); } - } - void removeAllInstances(PersistenceManager pm) { - Extent e = pm.getExtent(FieldSameName4.class, true); - Iterator i = e.iterator(); - while (i.hasNext()) { - pm.deletePersistent(i.next()); + void removeAllInstances(PersistenceManager pm) + { + Extent e = pm.getExtent(FieldSameName4.class, true); + Iterator i = e.iterator(); + while( i.hasNext() ){ + pm.deletePersistent(i.next()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/inheritance/NonPersistentFieldsAreNonPersistentInSubclasses.java b/tck/src/main/java/org/apache/jdo/tck/models/inheritance/NonPersistentFieldsAreNonPersistentInSubclasses.java index b73885b51..c81a6bb7e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/inheritance/NonPersistentFieldsAreNonPersistentInSubclasses.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/inheritance/NonPersistentFieldsAreNonPersistentInSubclasses.java @@ -5,141 +5,127 @@ * 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 + * + * 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.jdo.tck.models.inheritance; import java.util.Iterator; + import javax.jdo.Extent; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.inheritance.AllPersist4; import org.apache.jdo.tck.pc.inheritance.Constants; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Non-Persistent Fields Are Non-Persistent in Subclasses
    - * Keywords: inheritance
    - * Assertion ID: A6.5-6.
    - * Assertion Description: Fields marked as non-persistent in persistence-capable classes - * will be non-persistent in subclasses. - */ -public class NonPersistentFieldsAreNonPersistentInSubclasses extends TestParts { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.5-6 (NonPersistentFieldsAreNonPersistentInSubclasses) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NonPersistentFieldsAreNonPersistentInSubclasses.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(AllPersist4.class); - } - - /** */ - public void test() { - pm = getPM(); + *Title: Non-Persistent Fields Are Non-Persistent in Subclasses + *
    + *Keywords: inheritance + *
    + *Assertion ID: A6.5-6. + *
    + *Assertion Description: +Fields marked as non-persistent in persistence-capable classes +will be non-persistent in subclasses. - runTest(pm); - - pm.close(); - pm = null; - } - - /** */ - void runTest(PersistenceManager pm) { - Transaction t = pm.currentTransaction(); - try { - t.setRestoreValues(true); + */ - t.begin(); - // create new objects and make persistent - AllPersist4 c = - new AllPersist4( - Constants.intA_V[8], - Constants.doubleB_V[8], - Constants.intB_V[8], - Constants.charC_V[8], - Constants.booleanD_V[8], - Constants.floatE_V[8], - Constants.shortF_V[8], - Constants.shortG_V[8], - Constants.intH_V[8]); - AllPersist4 d = - new AllPersist4( - Constants.intA_V[9], - Constants.doubleB_V[9], - Constants.intB_V[9], - Constants.charC_V[9], - Constants.booleanD_V[9], - Constants.floatE_V[9], - Constants.shortF_V[9], - Constants.shortG_V[9], - Constants.intH_V[9]); - c.thirdObj = d; - c.fourthObj = d; - TestParts.thirdObj_V[8] = d; - TestParts.fourthObj_V[8] = d; - pm.makePersistent(c); +public class NonPersistentFieldsAreNonPersistentInSubclasses extends TestParts { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.5-6 (NonPersistentFieldsAreNonPersistentInSubclasses) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NonPersistentFieldsAreNonPersistentInSubclasses.class); + } - // change values of newly persistent object - c.intA = Constants.intA_V[10]; - c.charC = Constants.charC_V[10]; - c.booleanD = Constants.booleanD_V[10]; - c.shortG = Constants.shortG_V[10]; - c.fourthObj = null; - c.floatE = Constants.floatE_V[10]; - c.secondObj = null; - c.doubleB = Constants.doubleB_V[10]; - c.intB = Constants.intB_V[10]; - c.shortF = Constants.shortF_V[10]; - c.thirdObj = null; - c.intH = Constants.intH_V[10]; + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(AllPersist4.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); - t.rollback(); - t = null; + pm.close(); + pm = null; + } - // verify objects revert back to transient after rollback - checkNonpersistentAreCorrect( - ASSERTION_FAILED, - transientAfterRollback, - 10, - c.intA, - c.charC, - c.booleanD, - c.shortG, - c.fourthObj); - } finally { - if ((t != null) && t.isActive()) t.rollback(); + /** */ + void runTest(PersistenceManager pm) + { + Transaction t = pm.currentTransaction(); + try { + t.setRestoreValues(true); + + t.begin(); + // create new objects and make persistent + AllPersist4 c = new AllPersist4(Constants.intA_V[8], Constants.doubleB_V[8], Constants.intB_V[8], Constants.charC_V[8], Constants.booleanD_V[8], Constants.floatE_V[8], Constants.shortF_V[8], Constants.shortG_V[8], Constants.intH_V[8]); + AllPersist4 d = new AllPersist4(Constants.intA_V[9], Constants.doubleB_V[9], Constants.intB_V[9], Constants.charC_V[9], Constants.booleanD_V[9], Constants.floatE_V[9], Constants.shortF_V[9], Constants.shortG_V[9], Constants.intH_V[9]); + c.thirdObj = d; + c.fourthObj = d; + TestParts.thirdObj_V[8] = d; + TestParts.fourthObj_V[8] = d; + pm.makePersistent(c); + + // change values of newly persistent object + c.intA = Constants.intA_V[10]; + c.charC = Constants.charC_V[10]; + c.booleanD = Constants.booleanD_V[10]; + c.shortG = Constants.shortG_V[10]; + c.fourthObj = null; + c.floatE = Constants.floatE_V[10]; + c.secondObj = null; + c.doubleB = Constants.doubleB_V[10]; + c.intB = Constants.intB_V[10]; + c.shortF = Constants.shortF_V[10]; + c.thirdObj = null; + c.intH = Constants.intH_V[10]; + + t.rollback(); + t = null; + + // verify objects revert back to transient after rollback + checkNonpersistentAreCorrect(ASSERTION_FAILED, transientAfterRollback, 10, c.intA, c.charC, c.booleanD, c.shortG, c.fourthObj); + } + finally { + if ((t != null) && t.isActive()) + t.rollback(); + } } - } - void removeAllInstances(PersistenceManager pm) { - AllPersist4 a = new AllPersist4(0, 0.0, 0, '0', false, 0.0f, (short) 0, (short) 0, 0); - pm.makePersistent(a); // guarantee the class is registered; this will be removed - Extent e = pm.getExtent(AllPersist4.class, true); - Iterator i = e.iterator(); - while (i.hasNext()) { - pm.deletePersistent(i.next()); + void removeAllInstances(PersistenceManager pm) + { + AllPersist4 a = new AllPersist4(0, 0.0, 0, '0', false, 0.0f, (short)0, (short)0, 0); + pm.makePersistent(a); // guarantee the class is registered; this will be removed + Extent e = pm.getExtent(AllPersist4.class, true); + Iterator i = e.iterator(); + while( i.hasNext() ){ + pm.deletePersistent(i.next()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/inheritance/NonpersistentSuperClass.java b/tck/src/main/java/org/apache/jdo/tck/models/inheritance/NonpersistentSuperClass.java index 0b7a14d13..6bd564180 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/inheritance/NonpersistentSuperClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/inheritance/NonpersistentSuperClass.java @@ -5,332 +5,227 @@ * 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 + * + * 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.jdo.tck.models.inheritance; import java.util.Iterator; + import javax.jdo.Extent; import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.inheritance.Constants; import org.apache.jdo.tck.pc.inheritance.TopNonPersistH; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Non-persistent Super Class
    - * Keywords: inheritance
    - * Assertion ID: A6.5-1.
    - * Assertion Description: A class might be persistence-capable even if its superclass is not - * persistence-capable. - */ -public class NonpersistentSuperClass extends TestParts { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.5-1 (NonpersistentSuperClass) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NonpersistentSuperClass.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(TopNonPersistH.class); - } - - /** */ - public void test() { - pm = getPM(); + *Title: Non-persistent Super Class + *
    + *Keywords: inheritance + *
    + *Assertion ID: A6.5-1. + *
    + *Assertion Description: +A class might be persistence-capable even if its superclass is not persistence-capable. - runTest(pm); - - pm.close(); - pm = null; - } - - /** */ - void runTest(PersistenceManager pm) { - Transaction t = pm.currentTransaction(); - try { - t.setRestoreValues(true); - - t.begin(); - TopNonPersistH refa = - new TopNonPersistH( - Constants.intA_V[1], - Constants.doubleB_V[1], - Constants.intB_V[1], - Constants.charC_V[1], - Constants.booleanD_V[1], - Constants.floatE_V[1], - Constants.shortF_V[1], - Constants.shortG_V[1], - Constants.intH_V[1]); - pm.makePersistent(refa); - Object objPtrA = pm.getObjectId(refa); - - refa.secondObj = - new TopNonPersistH( - Constants.intA_V[2], - Constants.doubleB_V[2], - Constants.intB_V[2], - Constants.charC_V[2], - Constants.booleanD_V[2], - Constants.floatE_V[2], - Constants.shortF_V[2], - Constants.shortG_V[2], - Constants.intH_V[2]); - TestParts.secondObj_V[1] = refa.secondObj; - refa.thirdObj = - new TopNonPersistH( - Constants.intA_V[3], - Constants.doubleB_V[3], - Constants.intB_V[3], - Constants.charC_V[3], - Constants.booleanD_V[3], - Constants.floatE_V[3], - Constants.shortF_V[3], - Constants.shortG_V[3], - Constants.intH_V[3]); - TestParts.thirdObj_V[1] = refa.thirdObj; - pm.makePersistent(refa.thirdObj); - Object objPtrB = pm.getObjectId(refa.thirdObj); - refa.fourthObj = - new TopNonPersistH( - Constants.intA_V[4], - Constants.doubleB_V[4], - Constants.intB_V[4], - Constants.charC_V[4], - Constants.booleanD_V[4], - Constants.floatE_V[4], - Constants.shortF_V[4], - Constants.shortG_V[4], - Constants.intH_V[4]); - TestParts.fourthObj_V[1] = refa.fourthObj; - t.commit(); - - t.begin(); - TopNonPersistH a = null; - TopNonPersistH b = null; + */ - try { // retrieve object created in previous transaction & store in value array for later - // comparison - TestParts.thirdObj_V[1] = (TopNonPersistH) pm.getObjectById(objPtrB, true); - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail(ASSERTION_FAILED, "JDOUserException " + e + " could not reference thirdObj."); - } +public class NonpersistentSuperClass extends TestParts { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.5-1 (NonpersistentSuperClass) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NonpersistentSuperClass.class); + } - try { // retrieve object created in previous transaction - a = (TopNonPersistH) pm.getObjectById(objPtrA, true); - checkPersistentAreCorrect( - ASSERTION_FAILED, - persistentAfterCommit, - 1, - a.doubleB, - a.intB, - a.shortF, - a.thirdObj, - a.intH); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(TopNonPersistH.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } - // verify referenced persistent object contains correct values - b = a.thirdObj; - if (b != null) { // if previous error caused b to be null, then these tests cannot be - // performed. - checkPersistentAreCorrect( - ASSERTION_FAILED, - persistentAfterCommit, - 3, - b.doubleB, - b.intB, - b.shortF, - b.thirdObj, - b.intH); + /** */ + void runTest(PersistenceManager pm) + { + Transaction t = pm.currentTransaction(); + try { + t.setRestoreValues(true); + + t.begin(); + TopNonPersistH refa = new TopNonPersistH(Constants.intA_V[1], Constants.doubleB_V[1], Constants.intB_V[1], Constants.charC_V[1], Constants.booleanD_V[1], Constants.floatE_V[1], Constants.shortF_V[1], Constants.shortG_V[1], Constants.intH_V[1]); + pm.makePersistent(refa); + Object objPtrA = pm.getObjectId(refa); + + refa.secondObj = new TopNonPersistH(Constants.intA_V[2], Constants.doubleB_V[2], Constants.intB_V[2], Constants.charC_V[2], Constants.booleanD_V[2], Constants.floatE_V[2], Constants.shortF_V[2], Constants.shortG_V[2], Constants.intH_V[2]); + TestParts.secondObj_V[1] = refa.secondObj; + refa.thirdObj = new TopNonPersistH(Constants.intA_V[3], Constants.doubleB_V[3], Constants.intB_V[3], Constants.charC_V[3], Constants.booleanD_V[3], Constants.floatE_V[3], Constants.shortF_V[3], Constants.shortG_V[3], Constants.intH_V[3]); + TestParts.thirdObj_V[1] = refa.thirdObj; + pm.makePersistent(refa.thirdObj); + Object objPtrB = pm.getObjectId(refa.thirdObj); + refa.fourthObj = new TopNonPersistH(Constants.intA_V[4], Constants.doubleB_V[4], Constants.intB_V[4], Constants.charC_V[4], Constants.booleanD_V[4], Constants.floatE_V[4], Constants.shortF_V[4], Constants.shortG_V[4], Constants.intH_V[4]); + TestParts.fourthObj_V[1] = refa.fourthObj; + t.commit(); + + t.begin(); + TopNonPersistH a = null; + TopNonPersistH b = null; + + try { // retrieve object created in previous transaction & store in value array for later comparison + TestParts.thirdObj_V[1] = (TopNonPersistH)pm.getObjectById(objPtrB, true); + } + catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, + "JDOUserException " + e + " could not reference thirdObj."); + } + + try { // retrieve object created in previous transaction + a = (TopNonPersistH)pm.getObjectById(objPtrA, true); + checkPersistentAreCorrect(ASSERTION_FAILED, persistentAfterCommit, 1, a.doubleB, a.intB, a.shortF, a.thirdObj, a.intH); + + // verify referenced persistent object contains correct values + b = a.thirdObj; + if(b != null) { // if previous error caused b to be null, then these tests cannot be performed. + checkPersistentAreCorrect(ASSERTION_FAILED, persistentAfterCommit, 3, b.doubleB, b.intB, b.shortF, b.thirdObj, b.intH); + } + } + catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, + "JDOUserException " + e + " could not reference previously created object."); + } + + // set in new values + a.intA = Constants.intA_V[5]; + a.charC = Constants.charC_V[5]; + a.booleanD = Constants.booleanD_V[5]; + a.shortG = Constants.shortG_V[5]; + a.fourthObj = new TopNonPersistH(Constants.intA_V[6], Constants.doubleB_V[6], Constants.intB_V[6], Constants.charC_V[6], Constants.booleanD_V[6], Constants.floatE_V[6], Constants.shortF_V[6], Constants.shortG_V[6], Constants.intH_V[6]); + TestParts.fourthObj_V[5] = a.fourthObj; + a.floatE = Constants.floatE_V[5]; + a.secondObj = null; + a.doubleB = Constants.doubleB_V[5]; + a.intB = Constants.intB_V[5]; + a.shortF = Constants.shortF_V[5]; + a.thirdObj = null; + a.intH = Constants.intH_V[5]; + + b.intA = Constants.intA_V[7]; + b.charC = Constants.charC_V[7]; + b.booleanD = Constants.booleanD_V[7]; + b.shortG = Constants.shortG_V[7]; + b.fourthObj = null; + b.floatE = Constants.floatE_V[7]; + b.secondObj = null; + b.doubleB = Constants.doubleB_V[7]; + b.intB = Constants.intB_V[7]; + b.shortF = Constants.shortF_V[7]; + b.thirdObj = null; + b.intH = Constants.intH_V[7]; + + // create new objects and make persistent + TopNonPersistH c = new TopNonPersistH(Constants.intA_V[8], Constants.doubleB_V[8], Constants.intB_V[8], Constants.charC_V[8], Constants.booleanD_V[8], Constants.floatE_V[8], Constants.shortF_V[8], Constants.shortG_V[8], Constants.intH_V[8]); + TopNonPersistH d = new TopNonPersistH(Constants.intA_V[9], Constants.doubleB_V[9], Constants.intB_V[9], Constants.charC_V[9], Constants.booleanD_V[9], Constants.floatE_V[9], Constants.shortF_V[9], Constants.shortG_V[9], Constants.intH_V[9]); + c.thirdObj = d; + c.fourthObj = d; + TestParts.thirdObj_V[8] = d; + TestParts.fourthObj_V[8] = d; + pm.makePersistent(c); + + // change values of newly persistent object + c.intA = Constants.intA_V[10]; + c.charC = Constants.charC_V[10]; + c.booleanD = Constants.booleanD_V[10]; + c.shortG = Constants.shortG_V[10]; + c.fourthObj = null; + c.floatE = Constants.floatE_V[10]; + c.secondObj = null; + c.doubleB = Constants.doubleB_V[10]; + c.intB = Constants.intB_V[10]; + c.shortF = Constants.shortF_V[10]; + c.thirdObj = null; + c.intH = Constants.intH_V[10]; + + t.rollback(); + + // verify objects revert back to transient after rollback + checkPersistentAreCorrect(ASSERTION_FAILED, transientAfterRollback, 8, c.doubleB, c.intB, c.shortF, c.thirdObj, c.intH); + checkTransactionalAreCorrect(ASSERTION_FAILED, transientAfterRollback, 8, c.floatE, c.secondObj); + checkNonpersistentAreCorrect(ASSERTION_FAILED, transientAfterRollback, 10, c.intA, c.charC, c.booleanD, c.shortG, c.fourthObj); + + t.begin(); + + // verify rollback lost all persistent changes. + try { // retrieve object created in previous transaction & store in value array for later comparison + TestParts.thirdObj_V[1] = (TopNonPersistH)pm.getObjectById(objPtrB, true); + } + catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, + "JDOUserException " + e + " could not reference thirdObj."); + } + + try { // retrieve object created in previous transaction + a = (TopNonPersistH)pm.getObjectById(objPtrA, true); + checkPersistentAreCorrect(ASSERTION_FAILED, persistentAfterRollback, 1, a.doubleB, a.intB, a.shortF, a.thirdObj, a.intH); + b = a.thirdObj; + if(b != null) { // if previous error caused b to be null, then these tests cannot be performed. + checkPersistentAreCorrect(ASSERTION_FAILED, persistentAfterRollback, 3, b.doubleB, b.intB, b.shortF, b.thirdObj, b.intH); + } + } + catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, + "JDOUserException " + e + " could not reference previously created object."); + } + + t.rollback(); + t = null; } - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail( - ASSERTION_FAILED, - "JDOUserException " + e + " could not reference previously created object."); - } - - // set in new values - a.intA = Constants.intA_V[5]; - a.charC = Constants.charC_V[5]; - a.booleanD = Constants.booleanD_V[5]; - a.shortG = Constants.shortG_V[5]; - a.fourthObj = - new TopNonPersistH( - Constants.intA_V[6], - Constants.doubleB_V[6], - Constants.intB_V[6], - Constants.charC_V[6], - Constants.booleanD_V[6], - Constants.floatE_V[6], - Constants.shortF_V[6], - Constants.shortG_V[6], - Constants.intH_V[6]); - TestParts.fourthObj_V[5] = a.fourthObj; - a.floatE = Constants.floatE_V[5]; - a.secondObj = null; - a.doubleB = Constants.doubleB_V[5]; - a.intB = Constants.intB_V[5]; - a.shortF = Constants.shortF_V[5]; - a.thirdObj = null; - a.intH = Constants.intH_V[5]; - - b.intA = Constants.intA_V[7]; - b.charC = Constants.charC_V[7]; - b.booleanD = Constants.booleanD_V[7]; - b.shortG = Constants.shortG_V[7]; - b.fourthObj = null; - b.floatE = Constants.floatE_V[7]; - b.secondObj = null; - b.doubleB = Constants.doubleB_V[7]; - b.intB = Constants.intB_V[7]; - b.shortF = Constants.shortF_V[7]; - b.thirdObj = null; - b.intH = Constants.intH_V[7]; - - // create new objects and make persistent - TopNonPersistH c = - new TopNonPersistH( - Constants.intA_V[8], - Constants.doubleB_V[8], - Constants.intB_V[8], - Constants.charC_V[8], - Constants.booleanD_V[8], - Constants.floatE_V[8], - Constants.shortF_V[8], - Constants.shortG_V[8], - Constants.intH_V[8]); - TopNonPersistH d = - new TopNonPersistH( - Constants.intA_V[9], - Constants.doubleB_V[9], - Constants.intB_V[9], - Constants.charC_V[9], - Constants.booleanD_V[9], - Constants.floatE_V[9], - Constants.shortF_V[9], - Constants.shortG_V[9], - Constants.intH_V[9]); - c.thirdObj = d; - c.fourthObj = d; - TestParts.thirdObj_V[8] = d; - TestParts.fourthObj_V[8] = d; - pm.makePersistent(c); - - // change values of newly persistent object - c.intA = Constants.intA_V[10]; - c.charC = Constants.charC_V[10]; - c.booleanD = Constants.booleanD_V[10]; - c.shortG = Constants.shortG_V[10]; - c.fourthObj = null; - c.floatE = Constants.floatE_V[10]; - c.secondObj = null; - c.doubleB = Constants.doubleB_V[10]; - c.intB = Constants.intB_V[10]; - c.shortF = Constants.shortF_V[10]; - c.thirdObj = null; - c.intH = Constants.intH_V[10]; - - t.rollback(); - - // verify objects revert back to transient after rollback - checkPersistentAreCorrect( - ASSERTION_FAILED, - transientAfterRollback, - 8, - c.doubleB, - c.intB, - c.shortF, - c.thirdObj, - c.intH); - checkTransactionalAreCorrect( - ASSERTION_FAILED, transientAfterRollback, 8, c.floatE, c.secondObj); - checkNonpersistentAreCorrect( - ASSERTION_FAILED, - transientAfterRollback, - 10, - c.intA, - c.charC, - c.booleanD, - c.shortG, - c.fourthObj); - - t.begin(); - - // verify rollback lost all persistent changes. - try { // retrieve object created in previous transaction & store in value array for later - // comparison - TestParts.thirdObj_V[1] = (TopNonPersistH) pm.getObjectById(objPtrB, true); - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail(ASSERTION_FAILED, "JDOUserException " + e + " could not reference thirdObj."); - } - - try { // retrieve object created in previous transaction - a = (TopNonPersistH) pm.getObjectById(objPtrA, true); - checkPersistentAreCorrect( - ASSERTION_FAILED, - persistentAfterRollback, - 1, - a.doubleB, - a.intB, - a.shortF, - a.thirdObj, - a.intH); - b = a.thirdObj; - if (b != null) { // if previous error caused b to be null, then these tests cannot be - // performed. - checkPersistentAreCorrect( - ASSERTION_FAILED, - persistentAfterRollback, - 3, - b.doubleB, - b.intB, - b.shortF, - b.thirdObj, - b.intH); + finally { + if ((t != null) && t.isActive()) + t.rollback(); } - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail( - ASSERTION_FAILED, - "JDOUserException " + e + " could not reference previously created object."); - } - - t.rollback(); - t = null; - } finally { - if ((t != null) && t.isActive()) t.rollback(); } - } - void removeAllInstances(PersistenceManager pm) { - Extent e = pm.getExtent(TopNonPersistH.class, true); - Iterator i = e.iterator(); - while (i.hasNext()) { - pm.deletePersistent(i.next()); + void removeAllInstances(PersistenceManager pm) + { + Extent e = pm.getExtent(TopNonPersistH.class, true); + Iterator i = e.iterator(); + while( i.hasNext() ){ + pm.deletePersistent(i.next()); + } } - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/models/inheritance/PersistenceCapableFlexibilityInInheritanceHierarchy.java b/tck/src/main/java/org/apache/jdo/tck/models/inheritance/PersistenceCapableFlexibilityInInheritanceHierarchy.java index 1a305fbad..2652ac0ef 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/inheritance/PersistenceCapableFlexibilityInInheritanceHierarchy.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/inheritance/PersistenceCapableFlexibilityInInheritanceHierarchy.java @@ -5,334 +5,229 @@ * 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 + * + * 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.jdo.tck.models.inheritance; import java.util.Iterator; + import javax.jdo.Extent; import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.inheritance.Constants; import org.apache.jdo.tck.pc.inheritance.TopPersistH; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Persistence Capable Flexibility in Inheritance Hierarchy
    - * Keywords: inheritance
    - * Assertion ID: A6.5-3.
    - * Assertion Description: Subclasses of such classes that are not persistence-capable, but - * have a superclass that is persistence-capable might be persistence-capable. That is, it is - * possible for classes in the inheritance hierarchy to be alternately persistence-capable and not - * persistence-capable. - */ -public class PersistenceCapableFlexibilityInInheritanceHierarchy extends TestParts { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.5-3 (PersistenceCapableFlexibilityInInheritanceHierarchy) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(PersistenceCapableFlexibilityInInheritanceHierarchy.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(TopPersistH.class); - } + *Title: Persistence Capable Flexibility in Inheritance Hierarchy + *
    + *Keywords: inheritance + *
    + *Assertion ID: A6.5-3. + *
    + *Assertion Description: +Subclasses of such classes that are not persistence-capable, +but have a superclass that is persistence-capable might be persistence-capable. +That is, it is possible for classes in the inheritance hierarchy to be +alternately persistence-capable and not persistence-capable. - /** */ - public void test() { - pm = getPM(); - - runTest(pm); - - pm.close(); - pm = null; - } - - /** */ - void runTest(PersistenceManager pm) { - Transaction t = pm.currentTransaction(); - try { - t.setRestoreValues(true); - - t.begin(); - TopPersistH refa = - new TopPersistH( - Constants.intA_V[1], - Constants.doubleB_V[1], - Constants.intB_V[1], - Constants.charC_V[1], - Constants.booleanD_V[1], - Constants.floatE_V[1], - Constants.shortF_V[1], - Constants.shortG_V[1], - Constants.intH_V[1]); - pm.makePersistent(refa); - Object objPtrA = pm.getObjectId(refa); - - refa.secondObj = - new TopPersistH( - Constants.intA_V[2], - Constants.doubleB_V[2], - Constants.intB_V[2], - Constants.charC_V[2], - Constants.booleanD_V[2], - Constants.floatE_V[2], - Constants.shortF_V[2], - Constants.shortG_V[2], - Constants.intH_V[2]); - TestParts.secondObj_V[1] = refa.secondObj; - refa.thirdObj = - new TopPersistH( - Constants.intA_V[3], - Constants.doubleB_V[3], - Constants.intB_V[3], - Constants.charC_V[3], - Constants.booleanD_V[3], - Constants.floatE_V[3], - Constants.shortF_V[3], - Constants.shortG_V[3], - Constants.intH_V[3]); - TestParts.thirdObj_V[1] = refa.thirdObj; - pm.makePersistent(refa.thirdObj); - Object objPtrB = pm.getObjectId(refa.thirdObj); - refa.fourthObj = - new TopPersistH( - Constants.intA_V[4], - Constants.doubleB_V[4], - Constants.intB_V[4], - Constants.charC_V[4], - Constants.booleanD_V[4], - Constants.floatE_V[4], - Constants.shortF_V[4], - Constants.shortG_V[4], - Constants.intH_V[4]); - TestParts.fourthObj_V[1] = refa.fourthObj; - t.commit(); - - t.begin(); - TopPersistH a = null; - TopPersistH b = null; + */ - try { // retrieve object created in previous transaction & store in value array for later - // comparison - TestParts.thirdObj_V[1] = (TopPersistH) pm.getObjectById(objPtrB, true); - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail(ASSERTION_FAILED, "JDOUserException " + e + " could not reference thirdObj."); - } +public class PersistenceCapableFlexibilityInInheritanceHierarchy extends TestParts { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.5-3 (PersistenceCapableFlexibilityInInheritanceHierarchy) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(PersistenceCapableFlexibilityInInheritanceHierarchy.class); + } - try { // retrieve object created in previous transaction - a = (TopPersistH) pm.getObjectById(objPtrA, true); - checkPersistentAreCorrect( - ASSERTION_FAILED, - persistentAfterCommit, - 1, - a.doubleB, - a.intB, - a.shortF, - a.thirdObj, - a.intH); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(TopPersistH.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } - // verify referenced persistent object contains correct values - b = a.thirdObj; - if (b != null) { // if previous error caused b to be null, then these tests cannot be - // performed. - checkPersistentAreCorrect( - ASSERTION_FAILED, - persistentAfterCommit, - 3, - b.doubleB, - b.intB, - b.shortF, - b.thirdObj, - b.intH); + /** */ + void runTest(PersistenceManager pm) + { + Transaction t = pm.currentTransaction(); + try { + t.setRestoreValues(true); + + t.begin(); + TopPersistH refa = new TopPersistH(Constants.intA_V[1], Constants.doubleB_V[1], Constants.intB_V[1], Constants.charC_V[1], Constants.booleanD_V[1], Constants.floatE_V[1], Constants.shortF_V[1], Constants.shortG_V[1], Constants.intH_V[1]); + pm.makePersistent(refa); + Object objPtrA = pm.getObjectId(refa); + + refa.secondObj = new TopPersistH(Constants.intA_V[2], Constants.doubleB_V[2], Constants.intB_V[2], Constants.charC_V[2], Constants.booleanD_V[2], Constants.floatE_V[2], Constants.shortF_V[2], Constants.shortG_V[2], Constants.intH_V[2]); + TestParts.secondObj_V[1] = refa.secondObj; + refa.thirdObj = new TopPersistH(Constants.intA_V[3], Constants.doubleB_V[3], Constants.intB_V[3], Constants.charC_V[3], Constants.booleanD_V[3], Constants.floatE_V[3], Constants.shortF_V[3], Constants.shortG_V[3], Constants.intH_V[3]); + TestParts.thirdObj_V[1] = refa.thirdObj; + pm.makePersistent(refa.thirdObj); + Object objPtrB = pm.getObjectId(refa.thirdObj); + refa.fourthObj = new TopPersistH(Constants.intA_V[4], Constants.doubleB_V[4], Constants.intB_V[4], Constants.charC_V[4], Constants.booleanD_V[4], Constants.floatE_V[4], Constants.shortF_V[4], Constants.shortG_V[4], Constants.intH_V[4]); + TestParts.fourthObj_V[1] = refa.fourthObj; + t.commit(); + + t.begin(); + TopPersistH a = null; + TopPersistH b = null; + + try { // retrieve object created in previous transaction & store in value array for later comparison + TestParts.thirdObj_V[1] = (TopPersistH)pm.getObjectById(objPtrB, true); + } + catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, + "JDOUserException " + e + " could not reference thirdObj."); + } + + try { // retrieve object created in previous transaction + a = (TopPersistH)pm.getObjectById(objPtrA, true); + checkPersistentAreCorrect(ASSERTION_FAILED, persistentAfterCommit, 1, a.doubleB, a.intB, a.shortF, a.thirdObj, a.intH); + + // verify referenced persistent object contains correct values + b = a.thirdObj; + if(b != null) { // if previous error caused b to be null, then these tests cannot be performed. + checkPersistentAreCorrect(ASSERTION_FAILED, persistentAfterCommit, 3, b.doubleB, b.intB, b.shortF, b.thirdObj, b.intH); + } + } + catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, + "JDOUserException " + e + " could not reference previously created object."); + } + + // set in new values + a.intA = Constants.intA_V[5]; + a.charC = Constants.charC_V[5]; + a.booleanD = Constants.booleanD_V[5]; + a.shortG = Constants.shortG_V[5]; + a.fourthObj = new TopPersistH(Constants.intA_V[6], Constants.doubleB_V[6], Constants.intB_V[6], Constants.charC_V[6], Constants.booleanD_V[6], Constants.floatE_V[6], Constants.shortF_V[6], Constants.shortG_V[6], Constants.intH_V[6]); + TestParts.fourthObj_V[5] = a.fourthObj; + a.floatE = Constants.floatE_V[5]; + a.secondObj = null; + a.doubleB = Constants.doubleB_V[5]; + a.intB = Constants.intB_V[5]; + a.shortF = Constants.shortF_V[5]; + a.thirdObj = null; + a.intH = Constants.intH_V[5]; + + b.intA = Constants.intA_V[7]; + b.charC = Constants.charC_V[7]; + b.booleanD = Constants.booleanD_V[7]; + b.shortG = Constants.shortG_V[7]; + b.fourthObj = null; + b.floatE = Constants.floatE_V[7]; + b.secondObj = null; + b.doubleB = Constants.doubleB_V[7]; + b.intB = Constants.intB_V[7]; + b.shortF = Constants.shortF_V[7]; + b.thirdObj = null; + b.intH = Constants.intH_V[7]; + + // create new objects and make persistent + TopPersistH c = new TopPersistH(Constants.intA_V[8], Constants.doubleB_V[8], Constants.intB_V[8], Constants.charC_V[8], Constants.booleanD_V[8], Constants.floatE_V[8], Constants.shortF_V[8], Constants.shortG_V[8], Constants.intH_V[8]); + TopPersistH d = new TopPersistH(Constants.intA_V[9], Constants.doubleB_V[9], Constants.intB_V[9], Constants.charC_V[9], Constants.booleanD_V[9], Constants.floatE_V[9], Constants.shortF_V[9], Constants.shortG_V[9], Constants.intH_V[9]); + c.thirdObj = d; + c.fourthObj = d; + TestParts.thirdObj_V[8] = d; + TestParts.fourthObj_V[8] = d; + pm.makePersistent(c); + + // change values of newly persistent object + c.intA = Constants.intA_V[10]; + c.charC = Constants.charC_V[10]; + c.booleanD = Constants.booleanD_V[10]; + c.shortG = Constants.shortG_V[10]; + c.fourthObj = null; + c.floatE = Constants.floatE_V[10]; + c.secondObj = null; + c.doubleB = Constants.doubleB_V[10]; + c.intB = Constants.intB_V[10]; + c.shortF = Constants.shortF_V[10]; + c.thirdObj = null; + c.intH = Constants.intH_V[10]; + + t.rollback(); + + // verify objects revert back to transient after rollback + checkPersistentAreCorrect(ASSERTION_FAILED, transientAfterRollback, 8, c.doubleB, c.intB, c.shortF, c.thirdObj, c.intH); + checkTransactionalAreCorrect(ASSERTION_FAILED, transientAfterRollback, 8, c.floatE, c.secondObj); + checkNonpersistentAreCorrect(ASSERTION_FAILED, transientAfterRollback, 10, c.intA, c.charC, c.booleanD, c.shortG, c.fourthObj); + + t.begin(); + + // verify rollback lost all persistent changes. + try { // retrieve object created in previous transaction & store in value array for later comparison + TestParts.thirdObj_V[1] = (TopPersistH)pm.getObjectById(objPtrB, true); + } + catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, + "JDOUserException " + e + " could not reference thirdObj."); + } + + try { // retrieve object created in previous transaction + a = (TopPersistH)pm.getObjectById(objPtrA, true); + checkPersistentAreCorrect(ASSERTION_FAILED, persistentAfterRollback, 1, a.doubleB, a.intB, a.shortF, a.thirdObj, a.intH); + b = a.thirdObj; + if(b != null) { // if previous error caused b to be null, then these tests cannot be performed. + checkPersistentAreCorrect(ASSERTION_FAILED, persistentAfterRollback, 3, b.doubleB, b.intB, b.shortF, b.thirdObj, b.intH); + } + } + catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, + "JDOUserException " + e + " could not reference previously created object."); + } + + t.rollback(); + t = null; } - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail( - ASSERTION_FAILED, - "JDOUserException " + e + " could not reference previously created object."); - } - - // set in new values - a.intA = Constants.intA_V[5]; - a.charC = Constants.charC_V[5]; - a.booleanD = Constants.booleanD_V[5]; - a.shortG = Constants.shortG_V[5]; - a.fourthObj = - new TopPersistH( - Constants.intA_V[6], - Constants.doubleB_V[6], - Constants.intB_V[6], - Constants.charC_V[6], - Constants.booleanD_V[6], - Constants.floatE_V[6], - Constants.shortF_V[6], - Constants.shortG_V[6], - Constants.intH_V[6]); - TestParts.fourthObj_V[5] = a.fourthObj; - a.floatE = Constants.floatE_V[5]; - a.secondObj = null; - a.doubleB = Constants.doubleB_V[5]; - a.intB = Constants.intB_V[5]; - a.shortF = Constants.shortF_V[5]; - a.thirdObj = null; - a.intH = Constants.intH_V[5]; - - b.intA = Constants.intA_V[7]; - b.charC = Constants.charC_V[7]; - b.booleanD = Constants.booleanD_V[7]; - b.shortG = Constants.shortG_V[7]; - b.fourthObj = null; - b.floatE = Constants.floatE_V[7]; - b.secondObj = null; - b.doubleB = Constants.doubleB_V[7]; - b.intB = Constants.intB_V[7]; - b.shortF = Constants.shortF_V[7]; - b.thirdObj = null; - b.intH = Constants.intH_V[7]; - - // create new objects and make persistent - TopPersistH c = - new TopPersistH( - Constants.intA_V[8], - Constants.doubleB_V[8], - Constants.intB_V[8], - Constants.charC_V[8], - Constants.booleanD_V[8], - Constants.floatE_V[8], - Constants.shortF_V[8], - Constants.shortG_V[8], - Constants.intH_V[8]); - TopPersistH d = - new TopPersistH( - Constants.intA_V[9], - Constants.doubleB_V[9], - Constants.intB_V[9], - Constants.charC_V[9], - Constants.booleanD_V[9], - Constants.floatE_V[9], - Constants.shortF_V[9], - Constants.shortG_V[9], - Constants.intH_V[9]); - c.thirdObj = d; - c.fourthObj = d; - TestParts.thirdObj_V[8] = d; - TestParts.fourthObj_V[8] = d; - pm.makePersistent(c); - - // change values of newly persistent object - c.intA = Constants.intA_V[10]; - c.charC = Constants.charC_V[10]; - c.booleanD = Constants.booleanD_V[10]; - c.shortG = Constants.shortG_V[10]; - c.fourthObj = null; - c.floatE = Constants.floatE_V[10]; - c.secondObj = null; - c.doubleB = Constants.doubleB_V[10]; - c.intB = Constants.intB_V[10]; - c.shortF = Constants.shortF_V[10]; - c.thirdObj = null; - c.intH = Constants.intH_V[10]; - - t.rollback(); - - // verify objects revert back to transient after rollback - checkPersistentAreCorrect( - ASSERTION_FAILED, - transientAfterRollback, - 8, - c.doubleB, - c.intB, - c.shortF, - c.thirdObj, - c.intH); - checkTransactionalAreCorrect( - ASSERTION_FAILED, transientAfterRollback, 8, c.floatE, c.secondObj); - checkNonpersistentAreCorrect( - ASSERTION_FAILED, - transientAfterRollback, - 10, - c.intA, - c.charC, - c.booleanD, - c.shortG, - c.fourthObj); - - t.begin(); - - // verify rollback lost all persistent changes. - try { // retrieve object created in previous transaction & store in value array for later - // comparison - TestParts.thirdObj_V[1] = (TopPersistH) pm.getObjectById(objPtrB, true); - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail(ASSERTION_FAILED, "JDOUserException " + e + " could not reference thirdObj."); - } - - try { // retrieve object created in previous transaction - a = (TopPersistH) pm.getObjectById(objPtrA, true); - checkPersistentAreCorrect( - ASSERTION_FAILED, - persistentAfterRollback, - 1, - a.doubleB, - a.intB, - a.shortF, - a.thirdObj, - a.intH); - b = a.thirdObj; - if (b != null) { // if previous error caused b to be null, then these tests cannot be - // performed. - checkPersistentAreCorrect( - ASSERTION_FAILED, - persistentAfterRollback, - 3, - b.doubleB, - b.intB, - b.shortF, - b.thirdObj, - b.intH); + finally { + if ((t != null) && t.isActive()) + t.rollback(); } - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail( - ASSERTION_FAILED, - "JDOUserException " + e + " could not reference previously created object."); - } - - t.rollback(); - t = null; - } finally { - if ((t != null) && t.isActive()) t.rollback(); } - } - void removeAllInstances(PersistenceManager pm) { - Extent e = pm.getExtent(TopPersistH.class, true); - Iterator i = e.iterator(); - while (i.hasNext()) { - pm.deletePersistent(i.next()); + void removeAllInstances(PersistenceManager pm) + { + Extent e = pm.getExtent(TopPersistH.class, true); + Iterator i = e.iterator(); + while( i.hasNext() ){ + pm.deletePersistent(i.next()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/inheritance/PersistentFieldsArePersistentInSubClasses.java b/tck/src/main/java/org/apache/jdo/tck/models/inheritance/PersistentFieldsArePersistentInSubClasses.java index 97f313f02..e2ea9aa29 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/inheritance/PersistentFieldsArePersistentInSubClasses.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/inheritance/PersistentFieldsArePersistentInSubClasses.java @@ -5,323 +5,227 @@ * 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 + * + * 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.jdo.tck.models.inheritance; import java.util.Iterator; + import javax.jdo.Extent; import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.inheritance.AllPersist4; import org.apache.jdo.tck.pc.inheritance.Constants; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Persistent Fields Are Persistent in SubClasses
    - * Keywords: inheritance
    - * Assertion ID: A6.5-4.
    - * Assertion Description: Fields identified as persistent in persistence-capable classes - * will be persistent in subclasses. - */ -public class PersistentFieldsArePersistentInSubClasses extends TestParts { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.5-4 (PersistentFieldsArePersistentInSubClasses) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(PersistentFieldsArePersistentInSubClasses.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(AllPersist4.class); - } + *Title: Persistent Fields Are Persistent in SubClasses + *
    + *Keywords: inheritance + *
    + *Assertion ID: A6.5-4. + *
    + *Assertion Description: +Fields identified as persistent in persistence-capable classes +will be persistent in subclasses. - /** */ - public void test() { - pm = getPM(); - - runTest(pm); - - pm.close(); - pm = null; - } - - /** */ - void runTest(PersistenceManager pm) { - Transaction t = pm.currentTransaction(); - try { - t.setRestoreValues(true); - - t.begin(); - AllPersist4 refa = - new AllPersist4( - Constants.intA_V[1], - Constants.doubleB_V[1], - Constants.intB_V[1], - Constants.charC_V[1], - Constants.booleanD_V[1], - Constants.floatE_V[1], - Constants.shortF_V[1], - Constants.shortG_V[1], - Constants.intH_V[1]); - pm.makePersistent(refa); - Object objPtrA = pm.getObjectId(refa); - - refa.secondObj = - new AllPersist4( - Constants.intA_V[2], - Constants.doubleB_V[2], - Constants.intB_V[2], - Constants.charC_V[2], - Constants.booleanD_V[2], - Constants.floatE_V[2], - Constants.shortF_V[2], - Constants.shortG_V[2], - Constants.intH_V[2]); - TestParts.secondObj_V[1] = refa.secondObj; - refa.thirdObj = - new AllPersist4( - Constants.intA_V[3], - Constants.doubleB_V[3], - Constants.intB_V[3], - Constants.charC_V[3], - Constants.booleanD_V[3], - Constants.floatE_V[3], - Constants.shortF_V[3], - Constants.shortG_V[3], - Constants.intH_V[3]); - TestParts.thirdObj_V[1] = refa.thirdObj; - pm.makePersistent(refa.thirdObj); - Object objPtrB = pm.getObjectId(refa.thirdObj); - refa.fourthObj = - new AllPersist4( - Constants.intA_V[4], - Constants.doubleB_V[4], - Constants.intB_V[4], - Constants.charC_V[4], - Constants.booleanD_V[4], - Constants.floatE_V[4], - Constants.shortF_V[4], - Constants.shortG_V[4], - Constants.intH_V[4]); - TestParts.fourthObj_V[1] = refa.fourthObj; - t.commit(); - - t.begin(); - AllPersist4 a = null; - AllPersist4 b = null; + */ - try { // retrieve object created in previous transaction & store in value array for later - // comparison - TestParts.thirdObj_V[1] = (AllPersist4) pm.getObjectById(objPtrB, true); - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail(ASSERTION_FAILED, "JDOUserException " + e + " could not reference thirdObj."); - } +public class PersistentFieldsArePersistentInSubClasses extends TestParts { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.5-4 (PersistentFieldsArePersistentInSubClasses) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(PersistentFieldsArePersistentInSubClasses.class); + } - try { // retrieve object created in previous transaction - a = (AllPersist4) pm.getObjectById(objPtrA, true); - checkPersistentAreCorrect( - ASSERTION_FAILED, - persistentAfterCommit, - 1, - a.doubleB, - a.intB, - a.shortF, - a.thirdObj, - a.intH); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(AllPersist4.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); + + pm.close(); + pm = null; + } - // verify referenced persistent object contains correct values - b = a.thirdObj; - if (b != null) { // if previous error caused b to be null, then these tests cannot be - // performed. - checkPersistentAreCorrect( - ASSERTION_FAILED, - persistentAfterCommit, - 3, - b.doubleB, - b.intB, - b.shortF, - b.thirdObj, - b.intH); + /** */ + void runTest(PersistenceManager pm) + { + Transaction t = pm.currentTransaction(); + try { + t.setRestoreValues(true); + + t.begin(); + AllPersist4 refa = new AllPersist4(Constants.intA_V[1], Constants.doubleB_V[1], Constants.intB_V[1], Constants.charC_V[1], Constants.booleanD_V[1], Constants.floatE_V[1], Constants.shortF_V[1], Constants.shortG_V[1], Constants.intH_V[1]); + pm.makePersistent(refa); + Object objPtrA = pm.getObjectId (refa); + + refa.secondObj = new AllPersist4(Constants.intA_V[2], Constants.doubleB_V[2], Constants.intB_V[2], Constants.charC_V[2], Constants.booleanD_V[2], Constants.floatE_V[2], Constants.shortF_V[2], Constants.shortG_V[2], Constants.intH_V[2]); + TestParts.secondObj_V[1] = refa.secondObj; + refa.thirdObj = new AllPersist4(Constants.intA_V[3], Constants.doubleB_V[3], Constants.intB_V[3], Constants.charC_V[3], Constants.booleanD_V[3], Constants.floatE_V[3], Constants.shortF_V[3], Constants.shortG_V[3], Constants.intH_V[3]); + TestParts.thirdObj_V[1] = refa.thirdObj; + pm.makePersistent(refa.thirdObj); + Object objPtrB = pm.getObjectId (refa.thirdObj); + refa.fourthObj = new AllPersist4(Constants.intA_V[4], Constants.doubleB_V[4], Constants.intB_V[4], Constants.charC_V[4], Constants.booleanD_V[4], Constants.floatE_V[4], Constants.shortF_V[4], Constants.shortG_V[4], Constants.intH_V[4]); + TestParts.fourthObj_V[1] = refa.fourthObj; + t.commit(); + + t.begin(); + AllPersist4 a = null; + AllPersist4 b = null; + + try { // retrieve object created in previous transaction & store in value array for later comparison + TestParts.thirdObj_V[1] = (AllPersist4)pm.getObjectById(objPtrB, true); + } + catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, + "JDOUserException " + e + " could not reference thirdObj."); + } + + try { // retrieve object created in previous transaction + a = (AllPersist4)pm.getObjectById(objPtrA, true); + checkPersistentAreCorrect(ASSERTION_FAILED, persistentAfterCommit, 1, a.doubleB, a.intB, a.shortF, a.thirdObj, a.intH); + + // verify referenced persistent object contains correct values + b = a.thirdObj; + if(b != null) { // if previous error caused b to be null, then these tests cannot be performed. + checkPersistentAreCorrect(ASSERTION_FAILED, persistentAfterCommit, 3, b.doubleB, b.intB, b.shortF, b.thirdObj, b.intH); + } + } + catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, + "JDOUserException " + e + " could not reference previously created object."); + } + + // set in new values + a.intA = Constants.intA_V[5]; + a.charC = Constants.charC_V[5]; + a.booleanD = Constants.booleanD_V[5]; + a.shortG = Constants.shortG_V[5]; + a.fourthObj = new AllPersist4(Constants.intA_V[6], Constants.doubleB_V[6], Constants.intB_V[6], Constants.charC_V[6], Constants.booleanD_V[6], Constants.floatE_V[6], Constants.shortF_V[6], Constants.shortG_V[6], Constants.intH_V[6]); + TestParts.fourthObj_V[5] = a.fourthObj; + a.floatE = Constants.floatE_V[5]; + a.secondObj = null; + a.doubleB = Constants.doubleB_V[5]; + a.intB = Constants.intB_V[5]; + a.shortF = Constants.shortF_V[5]; + a.thirdObj = null; + a.intH = Constants.intH_V[5]; + + b.intA = Constants.intA_V[7]; + b.charC = Constants.charC_V[7]; + b.booleanD = Constants.booleanD_V[7]; + b.shortG = Constants.shortG_V[7]; + b.fourthObj = null; + b.floatE = Constants.floatE_V[7]; + b.secondObj = null; + b.doubleB = Constants.doubleB_V[7]; + b.intB = Constants.intB_V[7]; + b.shortF = Constants.shortF_V[7]; + b.thirdObj = null; + b.intH = Constants.intH_V[7]; + + // create new objects and make persistent + AllPersist4 c = new AllPersist4(Constants.intA_V[8], Constants.doubleB_V[8], Constants.intB_V[8], Constants.charC_V[8], Constants.booleanD_V[8], Constants.floatE_V[8], Constants.shortF_V[8], Constants.shortG_V[8], Constants.intH_V[8]); + AllPersist4 d = new AllPersist4(Constants.intA_V[9], Constants.doubleB_V[9], Constants.intB_V[9], Constants.charC_V[9], Constants.booleanD_V[9], Constants.floatE_V[9], Constants.shortF_V[9], Constants.shortG_V[9], Constants.intH_V[9]); + c.thirdObj = d; + c.fourthObj = d; + TestParts.thirdObj_V[8] = d; + TestParts.fourthObj_V[8] = d; + pm.makePersistent(c); + + // change values of newly persistent object + c.intA = Constants.intA_V[10]; + c.charC = Constants.charC_V[10]; + c.booleanD = Constants.booleanD_V[10]; + c.shortG = Constants.shortG_V[10]; + c.fourthObj = null; + c.floatE = Constants.floatE_V[10]; + c.secondObj = null; + c.doubleB = Constants.doubleB_V[10]; + c.intB = Constants.intB_V[10]; + c.shortF = Constants.shortF_V[10]; + c.thirdObj = null; + c.intH = Constants.intH_V[10]; + + t.rollback(); + + // verify objects revert back to transient after rollback + checkPersistentAreCorrect(ASSERTION_FAILED, transientAfterRollback, 8, c.doubleB, c.intB, c.shortF, c.thirdObj, c.intH); + + t.begin(); + + // verify rollback lost all persistent changes. + try { // retrieve object created in previous transaction & store in value array for later comparison + TestParts.thirdObj_V[1] = (AllPersist4)pm.getObjectById(objPtrB, true); + } + catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, + "JDOUserException " + e + " could not reference thirdObj."); + } + + try { // retrieve object created in previous transaction + a = (AllPersist4)pm.getObjectById(objPtrA, true); + checkPersistentAreCorrect(ASSERTION_FAILED, persistentAfterRollback, 1, a.doubleB, a.intB, a.shortF, a.thirdObj, a.intH); + b = a.thirdObj; + if(b != null) { // if previous error caused b to be null, then these tests cannot be performed. + checkPersistentAreCorrect(ASSERTION_FAILED, persistentAfterRollback, 3, b.doubleB, b.intB, b.shortF, b.thirdObj, b.intH); + } + } + catch (JDOUserException e) { + // could not locate persistent object created in previous transaction + fail(ASSERTION_FAILED, + "JDOUserException " + e + " could not reference previously created object."); + } + + t.rollback(); + t = null; } - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail( - ASSERTION_FAILED, - "JDOUserException " + e + " could not reference previously created object."); - } - - // set in new values - a.intA = Constants.intA_V[5]; - a.charC = Constants.charC_V[5]; - a.booleanD = Constants.booleanD_V[5]; - a.shortG = Constants.shortG_V[5]; - a.fourthObj = - new AllPersist4( - Constants.intA_V[6], - Constants.doubleB_V[6], - Constants.intB_V[6], - Constants.charC_V[6], - Constants.booleanD_V[6], - Constants.floatE_V[6], - Constants.shortF_V[6], - Constants.shortG_V[6], - Constants.intH_V[6]); - TestParts.fourthObj_V[5] = a.fourthObj; - a.floatE = Constants.floatE_V[5]; - a.secondObj = null; - a.doubleB = Constants.doubleB_V[5]; - a.intB = Constants.intB_V[5]; - a.shortF = Constants.shortF_V[5]; - a.thirdObj = null; - a.intH = Constants.intH_V[5]; - - b.intA = Constants.intA_V[7]; - b.charC = Constants.charC_V[7]; - b.booleanD = Constants.booleanD_V[7]; - b.shortG = Constants.shortG_V[7]; - b.fourthObj = null; - b.floatE = Constants.floatE_V[7]; - b.secondObj = null; - b.doubleB = Constants.doubleB_V[7]; - b.intB = Constants.intB_V[7]; - b.shortF = Constants.shortF_V[7]; - b.thirdObj = null; - b.intH = Constants.intH_V[7]; - - // create new objects and make persistent - AllPersist4 c = - new AllPersist4( - Constants.intA_V[8], - Constants.doubleB_V[8], - Constants.intB_V[8], - Constants.charC_V[8], - Constants.booleanD_V[8], - Constants.floatE_V[8], - Constants.shortF_V[8], - Constants.shortG_V[8], - Constants.intH_V[8]); - AllPersist4 d = - new AllPersist4( - Constants.intA_V[9], - Constants.doubleB_V[9], - Constants.intB_V[9], - Constants.charC_V[9], - Constants.booleanD_V[9], - Constants.floatE_V[9], - Constants.shortF_V[9], - Constants.shortG_V[9], - Constants.intH_V[9]); - c.thirdObj = d; - c.fourthObj = d; - TestParts.thirdObj_V[8] = d; - TestParts.fourthObj_V[8] = d; - pm.makePersistent(c); - - // change values of newly persistent object - c.intA = Constants.intA_V[10]; - c.charC = Constants.charC_V[10]; - c.booleanD = Constants.booleanD_V[10]; - c.shortG = Constants.shortG_V[10]; - c.fourthObj = null; - c.floatE = Constants.floatE_V[10]; - c.secondObj = null; - c.doubleB = Constants.doubleB_V[10]; - c.intB = Constants.intB_V[10]; - c.shortF = Constants.shortF_V[10]; - c.thirdObj = null; - c.intH = Constants.intH_V[10]; - - t.rollback(); - - // verify objects revert back to transient after rollback - checkPersistentAreCorrect( - ASSERTION_FAILED, - transientAfterRollback, - 8, - c.doubleB, - c.intB, - c.shortF, - c.thirdObj, - c.intH); - - t.begin(); - - // verify rollback lost all persistent changes. - try { // retrieve object created in previous transaction & store in value array for later - // comparison - TestParts.thirdObj_V[1] = (AllPersist4) pm.getObjectById(objPtrB, true); - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail(ASSERTION_FAILED, "JDOUserException " + e + " could not reference thirdObj."); - } - - try { // retrieve object created in previous transaction - a = (AllPersist4) pm.getObjectById(objPtrA, true); - checkPersistentAreCorrect( - ASSERTION_FAILED, - persistentAfterRollback, - 1, - a.doubleB, - a.intB, - a.shortF, - a.thirdObj, - a.intH); - b = a.thirdObj; - if (b != null) { // if previous error caused b to be null, then these tests cannot be - // performed. - checkPersistentAreCorrect( - ASSERTION_FAILED, - persistentAfterRollback, - 3, - b.doubleB, - b.intB, - b.shortF, - b.thirdObj, - b.intH); + finally { + if ((t != null) && t.isActive()) + t.rollback(); } - } catch (JDOUserException e) { - // could not locate persistent object created in previous transaction - fail( - ASSERTION_FAILED, - "JDOUserException " + e + " could not reference previously created object."); - } - - t.rollback(); - t = null; - } finally { - if ((t != null) && t.isActive()) t.rollback(); } - } - void removeAllInstances(PersistenceManager pm) { - AllPersist4 a = new AllPersist4(0, 0.0, 0, '0', false, 0.0f, (short) 0, (short) 0, 0); - pm.makePersistent(a); // guarantee the class is registered; this will be removed - Extent e = pm.getExtent(AllPersist4.class, true); - Iterator i = e.iterator(); - while (i.hasNext()) { - pm.deletePersistent(i.next()); + void removeAllInstances(PersistenceManager pm) + { + AllPersist4 a = new AllPersist4(0, 0.0, 0, '0', false, 0.0f, (short)0, (short)0, 0); + pm.makePersistent(a); // guarantee the class is registered; this will be removed + Extent e = pm.getExtent(AllPersist4.class, true); + Iterator i = e.iterator(); + while( i.hasNext() ){ + pm.deletePersistent(i.next()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/inheritance/TestParts.java b/tck/src/main/java/org/apache/jdo/tck/models/inheritance/TestParts.java index 223fd60f1..cd5f791a1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/inheritance/TestParts.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/inheritance/TestParts.java @@ -5,15 +5,16 @@ * 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 + * + * 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.jdo.tck.models.inheritance; @@ -21,170 +22,105 @@ import org.apache.jdo.tck.pc.inheritance.Constants; /** - * The test data is in arrays, making it easy to change values. The Inheritance test classes refer - * to the data via array index and the checkXXXX() routines carry an index value--indicating the - * expected value. If those attributes are references and should be other than null, as is the case - * with thirdObj, then the test code inserts the reference into the data array. + * The test data is in arrays, making it easy to change values. The Inheritance test classes refer to the + * data via array index and the checkXXXX() routines carry an index value--indicating the expected value. + * If those attributes are references and should be other than null, as is the case with thirdObj, then the + * test code inserts the reference into the data array. * - *

    Each test class follows the same pattern: 1. Persistent and transient object are created in - * the first transaction. 2. A second transaction is started, the first persistent object retrieved - * and checking is done on its attribute values. 3. A rollback is performed and value comparisions - * are made on the transient instances that were created. 4. A third transation is started and the - * first persistent object again retrieved and checking is done on its attribute values. + * Each test class follows the same pattern: + * 1. Persistent and transient object are created in the first transaction. + * 2. A second transaction is started, the first persistent object retrieved and checking is done on + * its attribute values. + * 3. A rollback is performed and value comparisions are made on the transient instances that were created. + * 4. A third transation is started and the first persistent object again retrieved and checking is done on + * its attribute values. */ public abstract class TestParts extends JDO_Test { - - // 0 1 2 3 4 5 6 7 8 9 - // 10 11 - static final Object[] secondObj_V = { - null, null, null, null, null, null, null, null, null, null, null, null - }; - static final Object[] thirdObj_V = { - null, null, null, null, null, null, null, null, null, null, null, null - }; - static final Object[] fourthObj_V = { - null, null, null, null, null, null, null, null, null, null, null, null - }; - - static String persistentAfterCommit = "Read object back after committed to Database. "; - static String persistentAfterRollback = "Read object back after rollback. "; - static String transientAfterRollback = "Object reverted to transient after rollback. "; - - /** */ - void checkPersistentAreCorrect( - String assertion, - String title, - int index, - double doubleB, - int intB, - short shortF, - Object thirdObj, - int intH) { - if (doubleB != Constants.doubleB_V[index]) { - fail( - assertion, - title - + "Persistent attribute doubleB is " - + doubleB - + ", it should be " - + Constants.doubleB_V[index]); - } - if (intB != Constants.intB_V[index]) { - fail( - assertion, - title - + "Persistent attribute intB is " - + intB - + ", it should be " - + Constants.intB_V[index]); - } - if (shortF != Constants.shortF_V[index]) { - fail( - assertion, - title - + "Persistent attribute shortF is " - + shortF - + ", it should be " - + Constants.shortF_V[index]); - } - if (thirdObj != TestParts.thirdObj_V[index]) { - fail( - assertion, - title - + "Persistent attribute thirdObj is " - + thirdObj - + ", it should be " - + TestParts.thirdObj_V[index]); + + // 0 1 2 3 4 5 6 7 8 9 10 11 + static final Object[] secondObj_V = { null, null, null, null, null, null, null, null, null, null, null, null}; + static final Object[] thirdObj_V = { null, null, null, null, null, null, null, null, null, null, null, null}; + static final Object[] fourthObj_V = { null, null, null, null, null, null, null, null, null, null, null, null}; + + static String persistentAfterCommit = "Read object back after committed to Database. "; + static String persistentAfterRollback = "Read object back after rollback. "; + static String transientAfterRollback = "Object reverted to transient after rollback. "; + + /** */ + void checkPersistentAreCorrect(String assertion, String title, int index, + double doubleB, int intB, short shortF, + Object thirdObj, int intH) { + if(doubleB != Constants.doubleB_V[index]) { + fail(assertion, + title + "Persistent attribute doubleB is " + doubleB + + ", it should be " + Constants.doubleB_V[index]); + } + if(intB != Constants.intB_V[index]) { + fail(assertion, + title + "Persistent attribute intB is " + intB + + ", it should be " + Constants.intB_V[index]); + } + if(shortF != Constants.shortF_V[index]) { + fail(assertion, + title + "Persistent attribute shortF is " + shortF + + ", it should be " + Constants.shortF_V[index]); + } + if(thirdObj != TestParts.thirdObj_V[index]) { + fail(assertion, + title + "Persistent attribute thirdObj is " + thirdObj + + ", it should be " + TestParts.thirdObj_V[index]); + } + if(intH != Constants.intH_V[index]) { + fail(assertion, + title + "Persistent attribute intH is " + intH + + ", it should be " + Constants.intH_V[index]); + } } - if (intH != Constants.intH_V[index]) { - fail( - assertion, - title - + "Persistent attribute intH is " - + intH - + ", it should be " - + Constants.intH_V[index]); - } - } - - /** */ - void checkTransactionalAreCorrect( - String assertion, String title, int index, float floatE, Object secondObj) { - - if (floatE != Constants.floatE_V[index]) { - fail( - assertion, - title - + "Transactional attribute floatE is " - + floatE - + ", it should be " - + Constants.floatE_V[index]); - } - if (secondObj != TestParts.secondObj_V[index]) { - fail( - assertion, - title - + "Transactional attribute secondObj is " - + secondObj - + ", it should be " - + TestParts.secondObj_V[index]); - } - } - /** */ - void checkNonpersistentAreCorrect( - String assertion, - String title, - int index, - int intA, - char charC, - boolean booleanD, - short shortG, - Object fourthObj) { - if (intA != Constants.intA_V[index]) { - fail( - assertion, - title - + "In non-persistent class, attribute intA is " - + intA - + ", it should be " - + Constants.intA_V[index]); - } - if (charC != Constants.charC_V[index]) { - fail( - assertion, - title - + "In non-persistent class, attribute charC is " - + charC - + ", it should be " - + Constants.charC_V[index]); - } - if (booleanD != Constants.booleanD_V[index]) { - fail( - assertion, - title - + "In non-persistent class, attribute booleanD is " - + booleanD - + ", it should be " - + Constants.booleanD_V[index]); - } - if (shortG != Constants.shortG_V[index]) { - fail( - assertion, - title - + "In non-persistent class, attribute shortG is " - + shortG - + ", it should be " - + Constants.shortG_V[index]); + /** */ + void checkTransactionalAreCorrect(String assertion, String title, int index, + float floatE, Object secondObj) { + + if(floatE != Constants.floatE_V[index]) { + fail(assertion, + title + "Transactional attribute floatE is " + floatE + + ", it should be " + Constants.floatE_V[index]); + } + if(secondObj != TestParts.secondObj_V[index]) { + fail(assertion, + title + "Transactional attribute secondObj is " + secondObj + + ", it should be " + TestParts.secondObj_V[index]); + } } - if (fourthObj != TestParts.fourthObj_V[index]) { - fail( - assertion, - title - + "In non-persistent class, attribute fourthObj is " - + fourthObj - + ", it should be " - + TestParts.fourthObj_V[index]); + + /** */ + void checkNonpersistentAreCorrect(String assertion, String title, int index, + int intA, char charC, boolean booleanD, + short shortG, Object fourthObj) { + if(intA != Constants.intA_V[index]) { + fail(assertion, + title + "In non-persistent class, attribute intA is " + intA + + ", it should be " + Constants.intA_V[index]); + } + if(charC != Constants.charC_V[index]) { + fail(assertion, + title + "In non-persistent class, attribute charC is " + charC + + ", it should be " + Constants.charC_V[index]); + } + if(booleanD != Constants.booleanD_V[index]) { + fail(assertion, + title + "In non-persistent class, attribute booleanD is " + booleanD + + ", it should be " + Constants.booleanD_V[index]); + } + if(shortG != Constants.shortG_V[index]) { + fail(assertion, + title + "In non-persistent class, attribute shortG is " + shortG + + ", it should be " + Constants.shortG_V[index]); + } + if(fourthObj != TestParts.fourthObj_V[index]) { + fail(assertion, + title + "In non-persistent class, attribute fourthObj is " + fourthObj + + ", it should be " + TestParts.fourthObj_V[index]); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/models/inheritance/TransactionalFieldsAreTransactionalInSubclasses.java b/tck/src/main/java/org/apache/jdo/tck/models/inheritance/TransactionalFieldsAreTransactionalInSubclasses.java index 199157e21..5e4f344ce 100644 --- a/tck/src/main/java/org/apache/jdo/tck/models/inheritance/TransactionalFieldsAreTransactionalInSubclasses.java +++ b/tck/src/main/java/org/apache/jdo/tck/models/inheritance/TransactionalFieldsAreTransactionalInSubclasses.java @@ -5,134 +5,127 @@ * 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 + * + * 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.jdo.tck.models.inheritance; import java.util.Iterator; + import javax.jdo.Extent; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.inheritance.AllPersist4; import org.apache.jdo.tck.pc.inheritance.Constants; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Transactional Fields are Transactional in Subclasses
    - * Keywords: inheritance
    - * Assertion ID: A6.5-5.
    - * Assertion Description: Fields marked as transactional in persistence-capable classes will - * be transactional in subclasses. - */ -public class TransactionalFieldsAreTransactionalInSubclasses extends TestParts { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A6.5-5 (TransactionalFieldsAreTransactionalInSubclasses) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(TransactionalFieldsAreTransactionalInSubclasses.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(AllPersist4.class); - } + *Title: Transactional Fields are Transactional in Subclasses + *
    + *Keywords: inheritance + *
    + *Assertion ID: A6.5-5. + *
    + *Assertion Description: +Fields marked as transactional in persistence-capable classes +will be transactional in subclasses. - /** */ - public void test() { - pm = getPM(); - - runTest(pm); - - pm.close(); - pm = null; - } + */ - /** */ - void runTest(PersistenceManager pm) { - Transaction t = pm.currentTransaction(); - try { - t.setRestoreValues(true); +public class TransactionalFieldsAreTransactionalInSubclasses extends TestParts { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A6.5-5 (TransactionalFieldsAreTransactionalInSubclasses) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(TransactionalFieldsAreTransactionalInSubclasses.class); + } - t.begin(); - // create new objects and make persistent - AllPersist4 c = - new AllPersist4( - Constants.intA_V[8], - Constants.doubleB_V[8], - Constants.intB_V[8], - Constants.charC_V[8], - Constants.booleanD_V[8], - Constants.floatE_V[8], - Constants.shortF_V[8], - Constants.shortG_V[8], - Constants.intH_V[8]); - AllPersist4 d = - new AllPersist4( - Constants.intA_V[9], - Constants.doubleB_V[9], - Constants.intB_V[9], - Constants.charC_V[9], - Constants.booleanD_V[9], - Constants.floatE_V[9], - Constants.shortF_V[9], - Constants.shortG_V[9], - Constants.intH_V[9]); - c.thirdObj = d; - c.fourthObj = d; - TestParts.thirdObj_V[8] = d; - TestParts.fourthObj_V[8] = d; - pm.makePersistent(c); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(AllPersist4.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTest(pm); - // change values of newly persistent object - c.intA = Constants.intA_V[10]; - c.charC = Constants.charC_V[10]; - c.booleanD = Constants.booleanD_V[10]; - c.shortG = Constants.shortG_V[10]; - c.fourthObj = null; - c.floatE = Constants.floatE_V[10]; - c.secondObj = d; - c.doubleB = Constants.doubleB_V[10]; - c.intB = Constants.intB_V[10]; - c.shortF = Constants.shortF_V[10]; - c.thirdObj = null; - c.intH = Constants.intH_V[10]; + pm.close(); + pm = null; + } - t.rollback(); - t = null; + /** */ + void runTest(PersistenceManager pm) + { + Transaction t = pm.currentTransaction(); + try { + t.setRestoreValues(true); + + t.begin(); + // create new objects and make persistent + AllPersist4 c = new AllPersist4(Constants.intA_V[8], Constants.doubleB_V[8], Constants.intB_V[8], Constants.charC_V[8], Constants.booleanD_V[8], Constants.floatE_V[8], Constants.shortF_V[8], Constants.shortG_V[8], Constants.intH_V[8]); + AllPersist4 d = new AllPersist4(Constants.intA_V[9], Constants.doubleB_V[9], Constants.intB_V[9], Constants.charC_V[9], Constants.booleanD_V[9], Constants.floatE_V[9], Constants.shortF_V[9], Constants.shortG_V[9], Constants.intH_V[9]); + c.thirdObj = d; + c.fourthObj = d; + TestParts.thirdObj_V[8] = d; + TestParts.fourthObj_V[8] = d; + pm.makePersistent(c); + + // change values of newly persistent object + c.intA = Constants.intA_V[10]; + c.charC = Constants.charC_V[10]; + c.booleanD = Constants.booleanD_V[10]; + c.shortG = Constants.shortG_V[10]; + c.fourthObj = null; + c.floatE = Constants.floatE_V[10]; + c.secondObj = d; + c.doubleB = Constants.doubleB_V[10]; + c.intB = Constants.intB_V[10]; + c.shortF = Constants.shortF_V[10]; + c.thirdObj = null; + c.intH = Constants.intH_V[10]; + + t.rollback(); + t = null; - // verify objects revert back to transient after rollback - checkTransactionalAreCorrect( - ASSERTION_FAILED, transientAfterRollback, 8, c.floatE, c.secondObj); - } finally { - if ((t != null) && t.isActive()) t.rollback(); + // verify objects revert back to transient after rollback + checkTransactionalAreCorrect(ASSERTION_FAILED, transientAfterRollback, 8, c.floatE, c.secondObj); + } + finally { + if ((t != null) && t.isActive()) + t.rollback(); + } } - } - void removeAllInstances(PersistenceManager pm) { - AllPersist4 a = new AllPersist4(0, 0.0, 0, '0', false, 0.0f, (short) 0, (short) 0, 0); - pm.makePersistent(a); // guarantee the class is registered; this will be removed - Extent e = pm.getExtent(AllPersist4.class, true); - Iterator i = e.iterator(); - while (i.hasNext()) { - pm.deletePersistent(i.next()); + void removeAllInstances(PersistenceManager pm) + { + AllPersist4 a = new AllPersist4(0, 0.0, 0, '0', false, 0.0f, (short)0, (short)0, 0); + pm.makePersistent(a); // guarantee the class is registered; this will be removed + Extent e = pm.getExtent(AllPersist4.class, true); + Iterator i = e.iterator(); + while( i.hasNext() ){ + pm.deletePersistent(i.next()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/building/Kitchen.java b/tck/src/main/java/org/apache/jdo/tck/pc/building/Kitchen.java index 8fd0c1020..886dd5cef 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/building/Kitchen.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/building/Kitchen.java @@ -5,112 +5,115 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.building; import java.io.Serializable; -/** This class represents an online shopping cart. It has a list of entries of type CartEntry. */ +/** This class represents an online shopping cart. It has a list of entries of + * type CartEntry. + */ public class Kitchen implements Serializable { - protected static long nextId = System.currentTimeMillis(); - - public static synchronized long nextId() { - return nextId++; - } - - /** Identity field for use with application identity */ - protected long id; + protected static long nextId = System.currentTimeMillis(); - /** The Oven we are using. */ - protected Oven oven; - - public Kitchen() { - this(nextId()); - } + public synchronized static long nextId() { + return nextId++; + } - public Kitchen(long id) { - setId(id); - } + /** Identity field for use with application identity */ + protected long id; - public long getId() { - return id; - } + /** The Oven we are using. */ + protected Oven oven; - protected void setId(long id) { - this.id = id; - } + public Kitchen() { + this(nextId()); + } - public void setOven(Oven ov) { - this.oven = ov; - } + public Kitchen(long id) { + setId(id); + } - public Oven getOven() { - return oven; - } + public long getId() { + return id; + } - public boolean equals(Object that) { - if (this == that) { - return true; + protected void setId(long id) { + this.id = id; } - if (that == null) { - return false; + + public void setOven(Oven ov) { + this.oven = ov; } - if (!(that instanceof Kitchen)) { - return false; + + public Oven getOven() { + return oven; } - return equals((Kitchen) that); - } - public boolean equals(Kitchen that) { - if (this == that) { - return true; + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (!(that instanceof Kitchen)) { + return false; + } + return equals((Kitchen) that); } - if (that == null) { - return false; + + public boolean equals(Kitchen that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + return this.id == that.id; } - return this.id == that.id; - } - public int hashCode() { - return (int) id; - } + public int hashCode() { + return (int) id; + } - public static class Oid implements Serializable { - public long id; + public static class Oid implements Serializable { + public long id; - public Oid() {} + public Oid() { + } - public Oid(String s) { - id = Long.parseLong(justTheId(s)); - } + public Oid(String s) { + id = Long.parseLong(justTheId(s)); + } - public String toString() { - return this.getClass().getName() + ":" + id; - } + public String toString() { + return this.getClass().getName() + ":" + id; + } - public int hashCode() { - return (int) id; - } + public int hashCode() { + return (int) id; + } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid that = (Oid) other; - return that.id == this.id; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid that = (Oid) other; + return that.id == this.id; + } + return false; + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/building/MultifunctionOven.java b/tck/src/main/java/org/apache/jdo/tck/pc/building/MultifunctionOven.java index f49ce5dea..829469957 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/building/MultifunctionOven.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/building/MultifunctionOven.java @@ -5,68 +5,70 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.building; import java.io.Serializable; -/** Representation of a multifunction oven in a fitted kitchen. */ +/** + * Representation of a multifunction oven in a fitted kitchen. + */ public class MultifunctionOven extends Oven implements Serializable { - /** Whether this oven provides a microwave. */ - protected boolean microwave; - - /** Capabilities of this model */ - protected String capabilities; - - public MultifunctionOven(String make, String model) { - super(make, model); - } + /** Whether this oven provides a microwave. */ + protected boolean microwave; - public void setMicrowave(boolean micro) { - this.microwave = micro; - } + /** Capabilities of this model */ + protected String capabilities; - public boolean getMicrowave() { - return microwave; - } - - public void setCapabilities(String caps) { - this.capabilities = caps; - } + public MultifunctionOven(String make, String model) { + super(make, model); + } - public String getCapabilities() { - return capabilities; - } + public void setMicrowave(boolean micro) { + this.microwave = micro; + } - public boolean equals(Object that) { - if (this == that) { - return true; + public boolean getMicrowave() { + return microwave; } - if (that == null) { - return false; + + public void setCapabilities(String caps) { + this.capabilities = caps; } - if (!(that instanceof MultifunctionOven)) { - return false; + + public String getCapabilities() { + return capabilities; } - return super.equals((MultifunctionOven) that); - } - public boolean equals(MultifunctionOven that) { - if (this == that) { - return true; + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (!(that instanceof MultifunctionOven)) { + return false; + } + return super.equals((MultifunctionOven) that); } - if (that == null) { - return false; + + public boolean equals(MultifunctionOven that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + return super.equals(that); } - return super.equals(that); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/building/Oven.java b/tck/src/main/java/org/apache/jdo/tck/pc/building/Oven.java index a29710386..048afbca3 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/building/Oven.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/building/Oven.java @@ -5,80 +5,84 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.building; import java.io.Serializable; -/** Representation of an oven in a fitted kitchen. */ +/** + * Representation of an oven in a fitted kitchen. + */ public class Oven implements Serializable { - /** Manufacturer of the appliance. */ - protected String make; - - /** Model of this appliance. */ - protected String model; - - public Oven(String make, String model) { - setMake(make); - setModel(model); - } - - public void setMake(String make) { - this.make = make; - } - - public String getMake() { - return make; - } - - public void setModel(String model) { - this.model = model; - } + /** Manufacturer of the appliance. */ + protected String make; - public String getModel() { - return model; - } + /** Model of this appliance. */ + protected String model; - public boolean equals(Object that) { - if (this == that) { - return true; + public Oven(String make, String model) { + setMake(make); + setModel(model); } - if (that == null) { - return false; + + public void setMake(String make) { + this.make = make; } - if (!(that instanceof Oven)) { - return false; + + public String getMake() { + return make; } - return equals((Oven) that); - } - public boolean equals(Oven that) { - if (this == that) { - return true; + public void setModel(String model) { + this.model = model; } - if (that == null) { - return false; + + public String getModel() { + return model; } - if ((make == null && that.make != null) || (make != null && that.make == null)) { - return false; + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (!(that instanceof Oven)) { + return false; + } + return equals((Oven) that); } - if ((model == null && that.model != null) || (model != null && that.model == null)) { - return false; + + public boolean equals(Oven that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + + if ((make == null && that.make != null) || + (make != null && that.make == null)) { + return false; + } + if ((model == null && that.model != null) || + (model != null && that.model == null)) { + return false; + } + return this.make.equals(that.make) && this.model.equals(that.make); } - return this.make.equals(that.make) && this.model.equals(that.make); - } - public int hashCode() { - return (make != null ? make.hashCode() : 0) ^ (model != null ? model.hashCode() : 0); - } + public int hashCode() { + return (make != null ? make.hashCode() : 0) ^ (model != null ? model.hashCode() : 0); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/Address.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/Address.java index 8daf60431..f3da67aa8 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/Address.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/Address.java @@ -5,339 +5,335 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.company; import java.io.Serializable; import java.util.Comparator; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a postal address. */ -public class Address implements IAddress, Serializable, Comparable, Comparator, DeepEquality { - - private long addrid; - private String street; - private String city; - private String state; - private String zipcode; - private String country; - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public Address() {} - - /** - * This constructor initializes the Address components. - * - * @param addrid The address ID. - * @param street The street address. - * @param city The city. - * @param state The state. - * @param zipcode The zip code. - * @param country The zip country. - */ - public Address( - long addrid, String street, String city, String state, String zipcode, String country) { - this.addrid = addrid; - this.street = street; - this.city = city; - this.state = state; - this.zipcode = zipcode; - this.country = country; - } - - /** - * Get the addrid associated with this object. - * - * @return the addrid. - */ - public long getAddrid() { - return addrid; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setAddrid(long id) { - if (this.addrid != 0) throw new IllegalStateException("Id is already set."); - this.addrid = id; - } - - /** - * Get the street component of the address. - * - * @return The street component of the address. - */ - public String getStreet() { - return street; - } - - /** - * Set the street component of the address. - * - * @param street The street component. - */ - public void setStreet(String street) { - this.street = street; - } - - /** - * Get the city. - * - * @return The city component of the address. - */ - public String getCity() { - return city; - } - - /** - * Set the city component of the address. - * - * @param city The city. - */ - public void setCity(String city) { - this.city = city; - } - - /** - * Get the state component of the address. - * - * @return The state. - */ - public String getState() { - return state; - } - - /** - * Set the state component of the address. - * - * @param state The state. - */ - public void setState(String state) { - this.state = state; - } - - /** - * Get the zipcode component of the address. - * - * @return The zipcode. - */ - public String getZipcode() { - return zipcode; - } - - /** - * Set the zip code component of the address. - * - * @param zipcode The zipcode. - */ - public void setZipcode(String zipcode) { - this.zipcode = zipcode; - } - - /** - * Get the country component of the address. - * - * @return The country. - */ - public String getCountry() { - return country; - } - - /** - * Set the country component of the address. - * - * @param country The country. - */ - public void setCountry(String country) { - this.country = country; - } - - /** - * Returns a String representation of a Address object. - * - * @return a String representation of a Address object. - */ - public String toString() { - return "Address(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(addrid); - rc.append(", street ").append(street); - rc.append(", city ").append(city); - rc.append(", state ").append(state); - rc.append(", zipcode ").append(zipcode); - rc.append(", country ").append(country); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IAddress otherAddress = (IAddress) other; - String where = "Address<" + addrid + ">"; - return helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") - & helper.equals(street, otherAddress.getStreet(), where + ".street") - & helper.equals(city, otherAddress.getCity(), where + ".city") - & helper.equals(state, otherAddress.getState(), where + ".state") - & helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") - & helper.equals(country, otherAddress.getCountry(), where + ".country"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((IAddress) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((IAddress) o1, (IAddress) o2); - } - - /** - * Compares this object with the specified Address object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Address object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Address object. - */ - public int compareTo(IAddress other) { - return compare(this, other); - } - - /** - * Compares its two IAddress arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IAddress object to be compared. - * @param o2 the second IAddress object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(IAddress o1, IAddress o2) { - return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof IAddress) { - return compareTo((IAddress) obj) == 0; +/** + * This class represents a postal address. + */ +public class Address + implements IAddress, Serializable, Comparable, Comparator, DeepEquality { + + private long addrid; + private String street; + private String city; + private String state; + private String zipcode; + private String country; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public Address() {} + + /** + * This constructor initializes the Address components. + * @param addrid The address ID. + * @param street The street address. + * @param city The city. + * @param state The state. + * @param zipcode The zip code. + * @param country The zip country. + */ + public Address(long addrid, String street, String city, + String state, String zipcode, String country) + { + this.addrid = addrid; + this.street = street; + this.city = city; + this.state = state; + this.zipcode = zipcode; + this.country = country; + } + + /** + * Get the addrid associated with this object. + * @return the addrid. + */ + public long getAddrid() { + return addrid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setAddrid(long id) { + if (this.addrid != 0) + throw new IllegalStateException("Id is already set."); + this.addrid = id; + } + + /** + * Get the street component of the address. + * @return The street component of the address. + */ + public String getStreet() { + return street; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) addrid; - } - - /** - * This class is used to represent the application identifier for the Address class. - */ - public static class Oid implements Serializable, Comparable { /** - * This is the identifier field for Address and must correspond in type and name to - * the field in Address. + * Set the street component of the address. + * @param street The street component. */ - public long addrid; + public void setStreet(String street) { + this.street = street; + } - /** The required public, no-arg constructor. */ - public Oid() { - addrid = 0; + /** + * Get the city. + * @return The city component of the address. + */ + public String getCity() { + return city; } /** - * A constructor to initialize the identifier field. - * - * @param addrid the id of the Address. + * Set the city component of the address. + * @param city The city. */ - public Oid(long addrid) { - this.addrid = addrid; + public void setCity(String city) { + this.city = city; + } + + /** + * Get the state component of the address. + * @return The state. + */ + public String getState() { + return state; } - public Oid(String s) { - addrid = Long.parseLong(justTheId(s)); + /** + * Set the state component of the address. + * @param state The state. + */ + public void setState(String state) { + this.state = state; + } + + /** + * Get the zipcode component of the address. + * @return The zipcode. + */ + public String getZipcode() { + return zipcode; + } + + /** + * Set the zip code component of the address. + * @param zipcode The zipcode. + */ + public void setZipcode(String zipcode) { + this.zipcode = zipcode; } + /** + * Get the country component of the address. + * @return The country. + */ + public String getCountry() { + return country; + } + + /** + * Set the country component of the address. + * @param country The country. + */ + public void setCountry(String country) { + this.country = country; + } + + /** + * Returns a String representation of a Address object. + * @return a String representation of a Address object. + */ public String toString() { - return this.getClass().getName() + ": " + addrid; + return "Address(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(addrid); + rc.append(", street ").append(street); + rc.append(", city ").append(city); + rc.append(", state ").append(state); + rc.append(", zipcode ").append(zipcode); + rc.append(", country ").append(country); + return rc.toString(); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.addrid != o.addrid) return (false); - return (true); + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IAddress otherAddress = (IAddress)other; + String where = "Address<" + addrid + ">"; + return + helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") & + helper.equals(street, otherAddress.getStreet(), where + ".street") & + helper.equals(city, otherAddress.getCity(), where + ".city") & + helper.equals(state, otherAddress.getState(), where + ".state") & + helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") & + helper.equals(country, otherAddress.getCountry(), where + ".country"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((IAddress)o); } - /** */ - public int hashCode() { - return ((int) addrid); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((IAddress)o1, (IAddress)o2); + } + + /** + * Compares this object with the specified Address object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Address object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Address + * object. + */ + public int compareTo(IAddress other) { + return compare(this, other); + } + + /** + * Compares its two IAddress arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IAddress object to be compared. + * @param o2 the second IAddress object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(IAddress o1, IAddress o2) { + return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof IAddress) { + return compareTo((IAddress)obj) == 0; + } + return false; } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)addrid; } + + /** + * This class is used to represent the application identifier + * for the Address class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This is the identifier field for Address and must + * correspond in type and name to the field in + * Address. + */ + public long addrid; + + /** The required public, no-arg constructor. */ + public Oid() + { + addrid = 0; + } + + /** + * A constructor to initialize the identifier field. + * @param addrid the id of the Address. + */ + public Oid(long addrid) { + this.addrid = addrid; + } + + public Oid(String s) { addrid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + addrid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.addrid != o.addrid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) addrid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( addrid < other.addrid ) return -1; + if( addrid > other.addrid ) return 1; + return 0; + } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (addrid < other.addrid) return -1; - if (addrid > other.addrid) return 1; - return 0; } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/Company.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/Company.java index 3f8e4aaa5..b766f1e4e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/Company.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/Company.java @@ -5,365 +5,367 @@ * 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 + * + * 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.jdo.tck.pc.company; -import java.io.IOException; -import java.io.ObjectInputStream; import java.io.Serializable; +import java.io.ObjectInputStream; +import java.io.IOException; + import java.text.SimpleDateFormat; + import java.util.Collections; import java.util.Comparator; -import java.util.Date; -import java.util.HashSet; import java.util.Set; -import javax.jdo.annotations.PersistenceCapable; +import java.util.HashSet; +import java.util.Date; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents information about a company. */ +import javax.jdo.annotations.PersistenceCapable; + +/** + * This class represents information about a company. + */ @PersistenceCapable -public class Company implements ICompany, Serializable, Comparable, Comparator, DeepEquality { - - private long companyid; - private String name; - private Date founded; - private Address address; - private transient Set departments = new HashSet(); // element type is Department - - protected static SimpleDateFormat formatter = new SimpleDateFormat("d/MMM/yyyy"); - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public Company() {} - - /** - * Initialize the Company instance. - * - * @param companyid The company id. - * @param name The company name. - * @param founded The date the company was founded. - */ - public Company(long companyid, String name, Date founded) { - this.companyid = companyid; - this.name = name; - this.founded = founded; - } - - /** - * Initialize the Company instance. - * - * @param companyid The company id. - * @param name The company name. - * @param founded The date the company was founded. - * @param addr The company's address. - */ - public Company(long companyid, String name, Date founded, IAddress addr) { - this(companyid, name, founded); - this.address = (Address) addr; - } - - /** - * Get the company id. - * - * @return The company id. - */ - public long getCompanyid() { - return companyid; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setCompanyid(long id) { - if (this.companyid != 0) throw new IllegalStateException("Id is already set."); - this.companyid = id; - } - - /** - * Get the name of the company. - * - * @return The name of the company. - */ - public String getName() { - return name; - } - - /** - * Set the name of the company. - * - * @param name The value to use for the name of the company. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Get the date that the company was founded. - * - * @return The date the company was founded. - */ - public Date getFounded() { - return founded; - } - - /** - * Set the date that the company was founded. - * - * @param founded The date to set that the company was founded. - */ - public void setFounded(Date founded) { - this.founded = founded; - } - - /** - * Get the address of the company. - * - * @return The primary address of the company. - */ - public IAddress getAddress() { - return address; - } - - /** - * Set the primary address for the company. - * - * @param address The address to set for the company. - */ - public void setAddress(IAddress address) { - this.address = (Address) address; - } - - /** - * Get the departments contained in the company. - * - * @return An unmodifiable Set that contains all the Departments of the - * company. - */ - public Set getDepartments() { - return Collections.unmodifiableSet(departments); - } - - /** - * Add a Department instance to the company. - * - * @param dept The Department instance to add. - */ - public void addDepartment(Department dept) { - departments.add(dept); - } - - /** - * Remove a Department instance from the company. - * - * @param dept The Department instance to remove. - */ - public void removeDepartment(Department dept) { - departments.remove(dept); - } - - /** - * Initialize the set of Departments in the company to the parameter. - * - * @param departments The set of Departments for the company. - */ - public void setDepartments(Set departments) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.departments = (departments != null) ? new HashSet(departments) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - departments = new HashSet(); - } - - /** - * Returns a String representation of a Company object. - * - * @return a String representation of a Company object. - */ - public String toString() { - return "Company(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(companyid); - rc.append(", name ").append(name); - rc.append(", founded ").append(founded == null ? "null" : formatter.format(founded)); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - ICompany otherCompany = (ICompany) other; - String where = "Company<" + companyid + ">"; - return helper.equals(companyid, otherCompany.getCompanyid(), where + ".companyid") - & helper.equals(name, otherCompany.getName(), where + ".name") - & helper.equals(founded, otherCompany.getFounded(), where + ".founded") - & helper.deepEquals(address, otherCompany.getAddress(), where + ".address") - & helper.deepEquals(departments, otherCompany.getDepartments(), where + ".departments"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((ICompany) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((ICompany) o1, (ICompany) o2); - } - - /** - * Compares this object with the specified Company object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Company object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Company object. - */ - public int compareTo(ICompany other) { - return compare(this, other); - } - - /** - * Compares its two ICompany arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first ICompany object to be compared. - * @param o2 the second ICompany object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(ICompany o1, ICompany o2) { - return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof ICompany) { - return compareTo((ICompany) obj) == 0; +public class Company + implements ICompany, Serializable, Comparable, Comparator, DeepEquality { + + private long companyid; + private String name; + private Date founded; + private Address address; + private transient Set departments = new HashSet(); // element type is Department + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public Company() {} + + /** + * Initialize the Company instance. + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + */ + public Company(long companyid, String name, Date founded) { + this.companyid = companyid; + this.name = name; + this.founded = founded; + } + + /** + * Initialize the Company instance. + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + * @param addr The company's address. + */ + public Company(long companyid, String name, Date founded, IAddress addr) { + this(companyid, name, founded); + this.address = (Address)addr; + } + + /** + * Get the company id. + * @return The company id. + */ + public long getCompanyid() { + return companyid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setCompanyid(long id) { + if (this.companyid != 0) + throw new IllegalStateException("Id is already set."); + this.companyid = id; + } + + /** + * Get the name of the company. + * @return The name of the company. + */ + public String getName() { + return name; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) companyid; - } - - /** - * The class to be used as the application identifier for the Company class. It - * consists of both the company name and the date that the company was founded. - */ - public static class Oid implements Serializable, Comparable { /** - * This field is part of the identifier and should match in name and type with a field in the - * Company class. + * Set the name of the company. + * @param name The value to use for the name of the company. */ - public long companyid; + public void setName(String name) { + this.name = name; + } - /** The required public no-arg constructor. */ - public Oid() {} + /** + * Get the date that the company was founded. + * @return The date the company was founded. + */ + public Date getFounded() { + return founded; + } /** - * Initialize the identifier. - * - * @param companyid The id of the company. + * Set the date that the company was founded. + * @param founded The date to set that the company was founded. */ - public Oid(long companyid) { - this.companyid = companyid; + public void setFounded(Date founded) { + this.founded = founded; } - public Oid(String s) { - companyid = Long.parseLong(justTheId(s)); + /** + * Get the address of the company. + * @return The primary address of the company. + */ + public IAddress getAddress() { + return address; + } + + /** + * Set the primary address for the company. + * @param address The address to set for the company. + */ + public void setAddress(IAddress address) { + this.address = (Address)address; } + /** + * Get the departments contained in the company. + * @return An unmodifiable Set that contains all the + * Departments of the company. + */ + public Set getDepartments() { + return Collections.unmodifiableSet(departments); + } + + /** + * Add a Department instance to the company. + * @param dept The Department instance to add. + */ + public void addDepartment(Department dept) { + departments.add(dept); + } + + /** + * Remove a Department instance from the company. + * @param dept The Department instance to remove. + */ + public void removeDepartment(Department dept) { + departments.remove(dept); + } + + /** + * Initialize the set of Departments in the company to the + * parameter. + * @param departments The set of Departments for the + * company. + */ + public void setDepartments(Set departments) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.departments = + (departments != null) ? new HashSet(departments) : null; + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + departments = new HashSet(); + } + + /** + * Returns a String representation of a Company object. + * @return a String representation of a Company object. + */ public String toString() { - return this.getClass().getName() + ": " + companyid; + return "Company(" + getFieldRepr()+ ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(companyid); + rc.append(", name ").append(name); + rc.append(", founded ").append( + founded==null ? "null" : formatter.format(founded)); + return rc.toString(); } - /** */ - public boolean equals(Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return false; - Oid o = (Oid) obj; - if (this.companyid != o.companyid) return false; - return true; + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + ICompany otherCompany = (ICompany)other; + String where = "Company<" + companyid + ">"; + return + helper.equals(companyid, otherCompany.getCompanyid(), where + ".companyid") & + helper.equals(name, otherCompany.getName(), where + ".name") & + helper.equals(founded, otherCompany.getFounded(), where + ".founded") & + helper.deepEquals(address, otherCompany.getAddress(), where + ".address") & + helper.deepEquals(departments, otherCompany.getDepartments(), where + ".departments"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((ICompany)o); } - /** */ - public int hashCode() { - return (int) companyid; + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((ICompany)o1, (ICompany)o2); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compares this object with the specified Company object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Company object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Company + * object. + */ + public int compareTo(ICompany other) { + return compare(this, other); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (companyid < other.companyid) return -1; - if (companyid > other.companyid) return 1; - return 0; + /** + * Compares its two ICompany arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first ICompany object to be compared. + * @param o2 the second ICompany object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(ICompany o1, ICompany o2) { + return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof ICompany) { + return compareTo((ICompany)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)companyid; } - } + + /** + * The class to be used as the application identifier + * for the Company class. It consists of both the company + * name and the date that the company was founded. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field is part of the identifier and should match in name + * and type with a field in the Company class. + */ + public long companyid; + + /** The required public no-arg constructor. */ + public Oid() { } + + /** + * Initialize the identifier. + * @param companyid The id of the company. + */ + public Oid(long companyid) { + this.companyid = companyid; + } + + public Oid(String s) { companyid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + companyid;} + + + /** */ + public boolean equals(Object obj) { + if (obj==null || !this.getClass().equals(obj.getClass())) + return false; + Oid o = (Oid) obj; + if (this.companyid != o.companyid) + return false; + return true; + } + + /** */ + public int hashCode() { + return (int)companyid; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( companyid < other.companyid ) return -1; + if( companyid > other.companyid ) return 1; + return 0; + } + + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactory.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactory.java index f00c204cb..542d6840d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactory.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactory.java @@ -5,16 +5,16 @@ * 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 + * + * 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. */ - + /* * CompanyFactory.java * @@ -23,66 +23,47 @@ package org.apache.jdo.tck.pc.company; import java.math.BigDecimal; + import java.util.Date; /** - * This interface is implemented by a factory class that can create Company model instances. The - * factory instance is registered with CompanyFactoryRegistry. + * This interface is implemented by a factory class that can create + * Company model instances. The factory instance is registered with + * CompanyFactoryRegistry. */ public interface CompanyFactory { - ICompany newCompany(long companyid, String name, Date founded); - - ICompany newCompany(long companyid, String name, Date founded, IAddress addr); - - IAddress newAddress( - long addrid, String street, String city, String state, String zipcode, String country); - - IMeetingRoom newMeetingRoom(long roomid, String name); - - IDentalInsurance newDentalInsurance(long insid, String carrier, BigDecimal lifetimeOrthoBenefit); - - IDentalInsurance newDentalInsurance( - long insid, String carrier, IEmployee employee, BigDecimal lifetimeOrthoBenefit); - - IDepartment newDepartment(long deptid, String name); - - IDepartment newDepartment(long deptid, String name, ICompany company); - - IDepartment newDepartment( - long deptid, String name, ICompany company, IEmployee employeeOfTheMonth); - - IFullTimeEmployee newFullTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - IAddress addr, - Date hired, - double sal); - - IFullTimeEmployee newFullTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double sal); - - IMedicalInsurance newMedicalInsurance(long insid, String carrier, String planType); - - IMedicalInsurance newMedicalInsurance( - long insid, String carrier, IEmployee employee, String planType); - - IPartTimeEmployee newPartTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double wage); - - IPartTimeEmployee newPartTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - IAddress addr, - Date hired, - double wage); - - IProject newProject(long projid, String name, BigDecimal budget); - - Class[] getTearDownClasses(); + ICompany newCompany(long companyid, String name, Date founded); + ICompany newCompany(long companyid, String name, Date founded, + IAddress addr); + IAddress newAddress(long addrid, String street, String city, + String state, String zipcode, String country); + IMeetingRoom newMeetingRoom(long roomid, String name); + IDentalInsurance newDentalInsurance(long insid, String carrier, + BigDecimal lifetimeOrthoBenefit); + IDentalInsurance newDentalInsurance(long insid, String carrier, + IEmployee employee, BigDecimal lifetimeOrthoBenefit); + IDepartment newDepartment(long deptid, String name); + IDepartment newDepartment(long deptid, + String name, ICompany company); + IDepartment newDepartment(long deptid, + String name, ICompany company, + IEmployee employeeOfTheMonth); + IFullTimeEmployee newFullTimeEmployee(long personid, + String first, String last, String middle, + Date born, IAddress addr, Date hired, double sal); + IFullTimeEmployee newFullTimeEmployee(long personid, + String first, String last, String middle, + Date born, Date hired, double sal); + IMedicalInsurance newMedicalInsurance(long insid, String carrier, + String planType); + IMedicalInsurance newMedicalInsurance(long insid, String carrier, + IEmployee employee, String planType); + IPartTimeEmployee newPartTimeEmployee(long personid, + String first, String last, String middle, + Date born, Date hired, double wage); + IPartTimeEmployee newPartTimeEmployee(long personid, + String first, String last, String middle, + Date born, IAddress addr, Date hired, double wage); + IProject newProject(long projid, String name, BigDecimal budget); + Class[] getTearDownClasses(); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryAbstractImpl.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryAbstractImpl.java index b201c0890..3ec47074b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryAbstractImpl.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryAbstractImpl.java @@ -18,6 +18,7 @@ package org.apache.jdo.tck.pc.company; import javax.jdo.PersistenceManager; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -28,249 +29,224 @@ * classes that implement only the methods to construct the instance. */ public abstract class CompanyFactoryAbstractImpl implements CompanyFactory { - - protected PersistenceManager pm; - - /** Logger */ - protected Log logger = LogFactory.getFactory().getInstance("org.apache.jdo.tck"); - - /** true if debug logging is enabled. */ - protected boolean debug = logger.isDebugEnabled(); - - /** - * Creates a new instance of CompanyFactoryAbstractImpl - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAbstractImpl(PersistenceManager pm) { - this.pm = pm; - } - - /** - * String indicating the type of identity used for the current test case. The value is either - * "applicationidentity" or "datastoreidentity". - */ - public final String identitytype = System.getProperty("jdo.tck.identitytype"); - - public boolean isAppIdentity = "applicationidentity".equals(identitytype); - - public abstract IAddress newAddress(); - - public abstract IMeetingRoom newMeetingRoom(); - - public abstract ICompany newCompany(); - - public abstract IDentalInsurance newDentalInsurance(); - - public abstract IDepartment newDepartment(); - - public abstract IFullTimeEmployee newFullTimeEmployee(); - - public abstract IMedicalInsurance newMedicalInsurance(); - - public abstract IPartTimeEmployee newPartTimeEmployee(); - - public abstract IProject newProject(); - - public IAddress newAddress( - long addrid, String street, String city, String state, String zipcode, String country) { - IAddress result = newAddress(); - result.setAddrid(addrid); - result.setStreet(street); - result.setCity(city); - result.setState(state); - result.setZipcode(zipcode); - result.setCountry(country); - if (debug) logger.debug("newAddress returned" + result); - return result; - } - - public IMeetingRoom newMeetingRoom(long roomid, String name) { - IMeetingRoom result = newMeetingRoom(); - result.setRoomid(roomid); - result.setName(name); - if (debug) logger.debug("newMeetingRoom returned" + result); - return result; - } - - public ICompany newCompany(long companyid, String name, java.util.Date founded) { - ICompany result = newCompany(); - result.setCompanyid(companyid); - result.setName(name); - result.setFounded(founded); - if (debug) logger.debug("newCompany returned" + result); - return result; - } - - public ICompany newCompany(long companyid, String name, java.util.Date founded, IAddress addr) { - ICompany result = newCompany(); - result.setCompanyid(companyid); - result.setName(name); - result.setFounded(founded); - result.setAddress(addr); - if (debug) logger.debug("newCompany returned" + result); - return result; - } - - public IDentalInsurance newDentalInsurance( - long insid, String carrier, java.math.BigDecimal lifetimeOrthoBenefit) { - IDentalInsurance result = newDentalInsurance(); - result.setInsid(insid); - result.setCarrier(carrier); - result.setLifetimeOrthoBenefit(lifetimeOrthoBenefit); - if (debug) logger.debug("newDentalInsurance returned" + result); - return result; - } - - public IDentalInsurance newDentalInsurance( - long insid, String carrier, IEmployee employee, java.math.BigDecimal lifetimeOrthoBenefit) { - IDentalInsurance result = newDentalInsurance(); - result.setInsid(insid); - result.setCarrier(carrier); - result.setEmployee(employee); - result.setLifetimeOrthoBenefit(lifetimeOrthoBenefit); - if (debug) logger.debug("newDentalInsurance returned" + result); - return result; - } - - public IDepartment newDepartment(long deptid, String name) { - IDepartment result = newDepartment(); - result.setDeptid(deptid); - result.setName(name); - if (debug) logger.debug("newDepartment returned" + result); - return result; - } - - public IDepartment newDepartment(long deptid, String name, ICompany company) { - IDepartment result = newDepartment(); - result.setDeptid(deptid); - result.setName(name); - result.setCompany(company); - if (debug) logger.debug("newDepartment returned" + result); - return result; - } - - public IDepartment newDepartment( - long deptid, String name, ICompany company, IEmployee employeeOfTheMonth) { - IDepartment result = newDepartment(); - result.setDeptid(deptid); - result.setName(name); - result.setCompany(company); - result.setEmployeeOfTheMonth(employeeOfTheMonth); - if (debug) logger.debug("newDepartment returned" + result); - return result; - } - - public IFullTimeEmployee newFullTimeEmployee( - long personid, - String first, - String last, - String middle, - java.util.Date born, - java.util.Date hired, - double sal) { - IFullTimeEmployee result = newFullTimeEmployee(); - result.setPersonid(personid); - result.setFirstname(first); - result.setLastname(last); - result.setMiddlename(middle); - result.setBirthdate(born); - result.setHiredate(hired); - result.setSalary(sal); - if (debug) logger.debug("newFullTimeEmployee returned" + result); - return result; - } - - public IFullTimeEmployee newFullTimeEmployee( - long personid, - String first, - String last, - String middle, - java.util.Date born, - IAddress addr, - java.util.Date hired, - double sal) { - IFullTimeEmployee result = newFullTimeEmployee(); - result.setPersonid(personid); - result.setFirstname(first); - result.setLastname(last); - result.setMiddlename(middle); - result.setBirthdate(born); - result.setAddress(addr); - result.setHiredate(hired); - result.setSalary(sal); - if (debug) logger.debug("newFullTimeEmployee returned" + result); - return result; - } - - public IMedicalInsurance newMedicalInsurance(long insid, String carrier, String planType) { - IMedicalInsurance result = newMedicalInsurance(); - result.setInsid(insid); - result.setCarrier(carrier); - result.setPlanType(planType); - if (debug) logger.debug("newMedicalInsurance returned" + result); - return result; - } - - public IMedicalInsurance newMedicalInsurance( - long insid, String carrier, IEmployee employee, String planType) { - IMedicalInsurance result = newMedicalInsurance(); - result.setInsid(insid); - result.setCarrier(carrier); - result.setEmployee(employee); - result.setPlanType(planType); - if (debug) logger.debug("newMedicalInsurance returned" + result); - return result; - } - - public IPartTimeEmployee newPartTimeEmployee( - long personid, - String first, - String last, - String middle, - java.util.Date born, - java.util.Date hired, - double wage) { - IPartTimeEmployee result = newPartTimeEmployee(); - result.setPersonid(personid); - result.setFirstname(first); - result.setLastname(last); - result.setMiddlename(middle); - result.setBirthdate(born); - result.setHiredate(hired); - result.setWage(wage); - if (debug) logger.debug("newPartTimeEmployee returned" + result); - return result; - } - - public IPartTimeEmployee newPartTimeEmployee( - long personid, - String first, - String last, - String middle, - java.util.Date born, - IAddress addr, - java.util.Date hired, - double wage) { - IPartTimeEmployee result = newPartTimeEmployee(); - result.setPersonid(personid); - result.setFirstname(first); - result.setLastname(last); - result.setMiddlename(middle); - result.setBirthdate(born); - result.setAddress(addr); - result.setHiredate(hired); - result.setWage(wage); - if (debug) logger.debug("newPartTimeEmployee returned" + result); - return result; - } - - public IProject newProject(long projid, String name, java.math.BigDecimal budget) { - IProject result = newProject(); - result.setProjid(projid); - result.setName(name); - result.setBudget(budget); - if (debug) logger.debug("newProject returned" + result); - return result; - } + + protected PersistenceManager pm; + + /** Logger */ + protected Log logger = + LogFactory.getFactory().getInstance("org.apache.jdo.tck"); + + /** true if debug logging is enabled. */ + protected boolean debug = logger.isDebugEnabled(); + + /** + * Creates a new instance of CompanyFactoryAbstractImpl + * @param pm the PersistenceManager + */ + public CompanyFactoryAbstractImpl(PersistenceManager pm) { + this.pm = pm; + } + + /** + * String indicating the type of identity used for the current test case. + * The value is either "applicationidentity" or "datastoreidentity". + */ + public final String identitytype = + System.getProperty("jdo.tck.identitytype"); + public boolean isAppIdentity = "applicationidentity".equals(identitytype); + + abstract public IAddress newAddress(); + abstract public IMeetingRoom newMeetingRoom(); + abstract public ICompany newCompany(); + abstract public IDentalInsurance newDentalInsurance(); + abstract public IDepartment newDepartment(); + abstract public IFullTimeEmployee newFullTimeEmployee(); + abstract public IMedicalInsurance newMedicalInsurance(); + abstract public IPartTimeEmployee newPartTimeEmployee(); + abstract public IProject newProject(); + + public IAddress newAddress(long addrid, String street, String city, + String state, String zipcode, String country) { + IAddress result = newAddress(); + result.setAddrid(addrid); + result.setStreet(street); + result.setCity(city); + result.setState(state); + result.setZipcode(zipcode); + result.setCountry(country); + if (debug) logger.debug("newAddress returned" + result); + return result; + } + + public IMeetingRoom newMeetingRoom(long roomid, String name) { + IMeetingRoom result = newMeetingRoom(); + result.setRoomid(roomid); + result.setName(name); + if (debug) logger.debug("newMeetingRoom returned" + result); + return result; + } + + public ICompany newCompany(long companyid, String name, + java.util.Date founded) { + ICompany result = newCompany(); + result.setCompanyid(companyid); + result.setName(name); + result.setFounded(founded); + if (debug) logger.debug("newCompany returned" + result); + return result; + } + + public ICompany newCompany(long companyid, String name, + java.util.Date founded, IAddress addr) { + ICompany result = newCompany(); + result.setCompanyid(companyid); + result.setName(name); + result.setFounded(founded); + result.setAddress(addr); + if (debug) logger.debug("newCompany returned" + result); + return result; + } + + public IDentalInsurance newDentalInsurance(long insid, String carrier, + java.math.BigDecimal lifetimeOrthoBenefit) { + IDentalInsurance result = newDentalInsurance(); + result.setInsid(insid); + result.setCarrier(carrier); + result.setLifetimeOrthoBenefit(lifetimeOrthoBenefit); + if (debug) logger.debug("newDentalInsurance returned" + result); + return result; + } + + public IDentalInsurance newDentalInsurance(long insid, String carrier, + IEmployee employee, java.math.BigDecimal lifetimeOrthoBenefit) { + IDentalInsurance result = newDentalInsurance(); + result.setInsid(insid); + result.setCarrier(carrier); + result.setEmployee(employee); + result.setLifetimeOrthoBenefit(lifetimeOrthoBenefit); + if (debug) logger.debug("newDentalInsurance returned" + result); + return result; + } + + public IDepartment newDepartment(long deptid, String name) { + IDepartment result = newDepartment(); + result.setDeptid(deptid); + result.setName(name); + if (debug) logger.debug("newDepartment returned" + result); + return result; + } + + public IDepartment newDepartment(long deptid, String name, + ICompany company) { + IDepartment result = newDepartment(); + result.setDeptid(deptid); + result.setName(name); + result.setCompany(company); + if (debug) logger.debug("newDepartment returned" + result); + return result; + } + + public IDepartment newDepartment(long deptid, String name, ICompany company, + IEmployee employeeOfTheMonth) { + IDepartment result = newDepartment(); + result.setDeptid(deptid); + result.setName(name); + result.setCompany(company); + result.setEmployeeOfTheMonth(employeeOfTheMonth); + if (debug) logger.debug("newDepartment returned" + result); + return result; + } + + public IFullTimeEmployee newFullTimeEmployee(long personid, String first, + String last, String middle, java.util.Date born, + java.util.Date hired, double sal) { + IFullTimeEmployee result = newFullTimeEmployee(); + result.setPersonid(personid); + result.setFirstname(first); + result.setLastname(last); + result.setMiddlename(middle); + result.setBirthdate(born); + result.setHiredate(hired); + result.setSalary(sal); + if (debug) logger.debug("newFullTimeEmployee returned" + result); + return result; + } + + public IFullTimeEmployee newFullTimeEmployee(long personid, String first, + String last, String middle, java.util.Date born, IAddress addr, + java.util.Date hired, double sal) { + IFullTimeEmployee result = newFullTimeEmployee(); + result.setPersonid(personid); + result.setFirstname(first); + result.setLastname(last); + result.setMiddlename(middle); + result.setBirthdate(born); + result.setAddress(addr); + result.setHiredate(hired); + result.setSalary(sal); + if (debug) logger.debug("newFullTimeEmployee returned" + result); + return result; + } + + public IMedicalInsurance newMedicalInsurance(long insid, String carrier, + String planType) { + IMedicalInsurance result = newMedicalInsurance(); + result.setInsid(insid); + result.setCarrier(carrier); + result.setPlanType(planType); + if (debug) logger.debug("newMedicalInsurance returned" + result); + return result; + } + + public IMedicalInsurance newMedicalInsurance(long insid, String carrier, + IEmployee employee, String planType) { + IMedicalInsurance result = newMedicalInsurance(); + result.setInsid(insid); + result.setCarrier(carrier); + result.setEmployee(employee); + result.setPlanType(planType); + if (debug) logger.debug("newMedicalInsurance returned" + result); + return result; + } + + public IPartTimeEmployee newPartTimeEmployee(long personid, String first, + String last, String middle, java.util.Date born, + java.util.Date hired, double wage) { + IPartTimeEmployee result = newPartTimeEmployee(); + result.setPersonid(personid); + result.setFirstname(first); + result.setLastname(last); + result.setMiddlename(middle); + result.setBirthdate(born); + result.setHiredate(hired); + result.setWage(wage); + if (debug) logger.debug("newPartTimeEmployee returned" + result); + return result; + } + + public IPartTimeEmployee newPartTimeEmployee(long personid, String first, + String last, String middle, java.util.Date born, IAddress addr, + java.util.Date hired, double wage) { + IPartTimeEmployee result = newPartTimeEmployee(); + result.setPersonid(personid); + result.setFirstname(first); + result.setLastname(last); + result.setMiddlename(middle); + result.setBirthdate(born); + result.setAddress(addr); + result.setHiredate(hired); + result.setWage(wage); + if (debug) logger.debug("newPartTimeEmployee returned" + result); + return result; + } + + public IProject newProject(long projid, String name, + java.math.BigDecimal budget) { + IProject result = newProject(); + result.setProjid(projid); + result.setName(name); + result.setBudget(budget); + if (debug) logger.debug("newProject returned" + result); + return result; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryAnnotatedAbstractDelegator.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryAnnotatedAbstractDelegator.java index 2892b5029..2cc86d79e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryAnnotatedAbstractDelegator.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryAnnotatedAbstractDelegator.java @@ -25,59 +25,60 @@ * This class uses the PersistenceManager.newInstance method with the concrete * class as a parameter. */ -public abstract class CompanyFactoryAnnotatedAbstractDelegator extends CompanyFactoryAbstractImpl { - - public CompanyFactoryNewInstance delegate = null; - - public final String identitytype = System.getProperty("jdo.tck.identitytype"); - public boolean isAppIdentity = "applicationidentity".equals(identitytype); - - /** - * Creates a new instance of CompanyFactory - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedAbstractDelegator(PersistenceManager pm) { - super(pm); - } - - public IAddress newAddress() { - return (IAddress) delegate.newAddress(); - } - - public IMeetingRoom newMeetingRoom() { - return (IMeetingRoom) delegate.newMeetingRoom(); - } - - public ICompany newCompany() { - return (ICompany) delegate.newCompany(); - } - - public IDentalInsurance newDentalInsurance() { - return (IDentalInsurance) delegate.newDentalInsurance(); - } - - public IDepartment newDepartment() { - return (IDepartment) delegate.newDepartment(); - } - - public IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) delegate.newFullTimeEmployee(); - } - - public IMedicalInsurance newMedicalInsurance() { - return (IMedicalInsurance) delegate.newMedicalInsurance(); - } - - public IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) delegate.newPartTimeEmployee(); - } - - public IProject newProject() { - return (IProject) delegate.newProject(); - } - - public Class[] getTearDownClasses() { - return delegate.getTearDownClasses(); - } +public abstract class CompanyFactoryAnnotatedAbstractDelegator + extends CompanyFactoryAbstractImpl { + + public CompanyFactoryNewInstance delegate = null; + + public final String identitytype = + System.getProperty("jdo.tck.identitytype"); + public boolean isAppIdentity = "applicationidentity".equals(identitytype); + + /** + * Creates a new instance of CompanyFactory + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedAbstractDelegator(PersistenceManager pm) { + super(pm); + } + + public IAddress newAddress() { + return (IAddress)delegate.newAddress(); + } + + public IMeetingRoom newMeetingRoom() { + return (IMeetingRoom)delegate.newMeetingRoom(); + } + + public ICompany newCompany() { + return (ICompany)delegate.newCompany(); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance)delegate.newDentalInsurance(); + } + + public IDepartment newDepartment() { + return (IDepartment)delegate.newDepartment(); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee)delegate.newFullTimeEmployee(); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance)delegate.newMedicalInsurance(); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee)delegate.newPartTimeEmployee(); + } + + public IProject newProject() { + return (IProject)delegate.newProject(); + } + + public Class[]getTearDownClasses() { + return delegate.getTearDownClasses(); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryConcreteClass.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryConcreteClass.java index 7345d30dd..18f36daaa 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryConcreteClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryConcreteClass.java @@ -18,140 +18,137 @@ package org.apache.jdo.tck.pc.company; import java.math.BigDecimal; + import java.util.Date; + import javax.jdo.PersistenceManager; /* * This class is the company factory that uses constructors of the * concrete classes. */ -public class CompanyFactoryConcreteClass implements CompanyFactory { - - /** */ - public static final Class[] tearDownClasses = - new Class[] { - DentalInsurance.class, - MedicalInsurance.class, - PartTimeEmployee.class, - FullTimeEmployee.class, - Project.class, - Department.class, - Company.class, - MeetingRoom.class - }; - - /** - * Creates a new instance of CompanyFactory - * - * @param pm the PersistenceManager - */ - public CompanyFactoryConcreteClass(PersistenceManager pm) {} - - public CompanyFactoryConcreteClass() {} - - public ICompany newCompany(long companyid, String name, Date founded) { - return new Company(companyid, name, founded); - } - - public ICompany newCompany(long companyid, String name, Date founded, IAddress addr) { - return new Company(companyid, name, founded, addr); - } - - public IAddress newAddress( - long addrid, String street, String city, String state, String zipcode, String country) { - return new Address(addrid, street, city, state, zipcode, country); - } - - public IMeetingRoom newMeetingRoom(long roomid, String name) { - return new MeetingRoom(roomid, name); - } - - public IDentalInsurance newDentalInsurance( - long insid, String carrier, BigDecimal lifetimeOrthoBenefit) { - return new DentalInsurance(insid, carrier, lifetimeOrthoBenefit); - } - - public IDentalInsurance newDentalInsurance( - long insid, String carrier, IEmployee employee, BigDecimal lifetimeOrthoBenefit) { - return new DentalInsurance(insid, carrier, lifetimeOrthoBenefit); - } - - public IDepartment newDepartment(long deptid, String name) { - return new Department(deptid, name); - } - - public IDepartment newDepartment(long deptid, String name, ICompany company) { - return new Department(deptid, name, company); - } - - public IDepartment newDepartment( - long deptid, String name, ICompany company, IEmployee employeeOfTheMonth) { - return new Department(deptid, name, company, employeeOfTheMonth); - } - - public IFullTimeEmployee newFullTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double sal) { - return new FullTimeEmployee(personid, first, last, middle, born, hired, sal); - } - - public IFullTimeEmployee newFullTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - IAddress addr, - Date hired, - double sal) { - return new FullTimeEmployee(personid, first, last, middle, born, addr, hired, sal); - } - - public IMedicalInsurance newMedicalInsurance(long insid, String carrier, String planType) { - return new MedicalInsurance(insid, carrier, planType); - } - - public IMedicalInsurance newMedicalInsurance( - long insid, String carrier, IEmployee employee, String planType) { - return new MedicalInsurance(insid, carrier, planType); - } - - public IPartTimeEmployee newPartTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double wage) { - return new PartTimeEmployee(personid, first, last, middle, born, hired, wage); - } - - public IPartTimeEmployee newPartTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - IAddress addr, - Date hired, - double wage) { - return new PartTimeEmployee(personid, first, last, middle, born, addr, hired, wage); - } - - public IPerson newPerson( - long personid, String firstname, String lastname, String middlename, Date birthdate) { - return new Person(personid, firstname, lastname, middlename, birthdate); - } - - public IPerson newPerson( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - IAddress address) { - return new Person(personid, firstname, lastname, middlename, birthdate, address); - } - - public IProject newProject(long projid, String name, BigDecimal budget) { - return new Project(projid, name, budget); - } - - public Class[] getTearDownClasses() { - return tearDownClasses; - } +public class CompanyFactoryConcreteClass implements CompanyFactory { + + /** */ + public static final Class[] tearDownClasses = new Class[] { + DentalInsurance.class, MedicalInsurance.class, + PartTimeEmployee.class, FullTimeEmployee.class, + Project.class, Department.class, Company.class, MeetingRoom.class + }; + + /** + * Creates a new instance of CompanyFactory + * @param pm the PersistenceManager + */ + public CompanyFactoryConcreteClass(PersistenceManager pm) { + } + + public CompanyFactoryConcreteClass() { + } + + public ICompany newCompany(long companyid, + String name, Date founded) { + return new Company(companyid, name, founded); + } + + public ICompany newCompany(long companyid, + String name, Date founded, IAddress addr) { + return new Company(companyid, name, founded, addr); + } + + public IAddress newAddress(long addrid, + String street, String city, String state, String zipcode, + String country) { + return new Address(addrid, street, city, state, zipcode, country); + } + + public IMeetingRoom newMeetingRoom(long roomid, String name) { + return new MeetingRoom(roomid, name); + } + + public IDentalInsurance newDentalInsurance(long insid, + String carrier, BigDecimal lifetimeOrthoBenefit) { + return new DentalInsurance(insid, carrier, lifetimeOrthoBenefit); + } + + public IDentalInsurance newDentalInsurance(long insid, + String carrier, IEmployee employee, + BigDecimal lifetimeOrthoBenefit) { + return new DentalInsurance(insid, carrier, lifetimeOrthoBenefit); + } + + public IDepartment newDepartment(long deptid, String name) { + return new Department(deptid, name); + } + + public IDepartment newDepartment(long deptid, + String name, ICompany company) { + return new Department(deptid, name, company); + } + + public IDepartment newDepartment(long deptid, + String name, ICompany company, IEmployee employeeOfTheMonth) { + return new Department(deptid, name, company, employeeOfTheMonth); + } + + public IFullTimeEmployee newFullTimeEmployee(long personid, + String first, String last, String middle, + Date born, Date hired, double sal) { + return new FullTimeEmployee(personid, first, last, middle, + born, hired, sal); + } + + public IFullTimeEmployee newFullTimeEmployee(long personid, + String first, String last, String middle, + Date born, IAddress addr, Date hired, double sal) { + return new FullTimeEmployee(personid, first, last, middle, + born, addr, hired, sal); + } + + public IMedicalInsurance newMedicalInsurance(long insid, + String carrier, String planType) { + return new MedicalInsurance(insid, carrier, planType); + } + + public IMedicalInsurance newMedicalInsurance(long insid, + String carrier, IEmployee employee, String planType) { + return new MedicalInsurance(insid, carrier, planType); + } + + public IPartTimeEmployee newPartTimeEmployee(long personid, + String first, String last, String middle, + Date born, Date hired, double wage ) { + return new PartTimeEmployee(personid, first, last, middle, + born, hired, wage); + } + + public IPartTimeEmployee newPartTimeEmployee(long personid, + String first, String last, String middle, + Date born, IAddress addr, Date hired, double wage) { + return new PartTimeEmployee(personid, first, last, middle, + born, addr, hired, wage); + } + + public IPerson newPerson(long personid, + String firstname, String lastname, String middlename, + Date birthdate) { + return new Person(personid, firstname, lastname, middlename, + birthdate); + } + + public IPerson newPerson(long personid, + String firstname, String lastname, String middlename, + Date birthdate, IAddress address) { + return new Person(personid, firstname, lastname, middlename, + birthdate, address); + } + + public IProject newProject(long projid, String name, + BigDecimal budget) { + return new Project(projid, name, budget); + } + + public Class[] getTearDownClasses() { + return tearDownClasses; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryNewInstance.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryNewInstance.java index 13525b047..a932b67f0 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryNewInstance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryNewInstance.java @@ -5,38 +5,31 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.company; -/** */ +/** + * + */ public interface CompanyFactoryNewInstance { - public abstract IAddress newAddress(); - - public abstract IMeetingRoom newMeetingRoom(); - - public abstract ICompany newCompany(); - - public abstract IDentalInsurance newDentalInsurance(); - - public abstract IDepartment newDepartment(); - - public abstract IFullTimeEmployee newFullTimeEmployee(); - - public abstract IMedicalInsurance newMedicalInsurance(); - - public abstract IPartTimeEmployee newPartTimeEmployee(); - - public abstract IProject newProject(); - - Class[] getTearDownClasses(); + abstract public IAddress newAddress(); + abstract public IMeetingRoom newMeetingRoom(); + abstract public ICompany newCompany(); + abstract public IDentalInsurance newDentalInsurance(); + abstract public IDepartment newDepartment(); + abstract public IFullTimeEmployee newFullTimeEmployee(); + abstract public IMedicalInsurance newMedicalInsurance(); + abstract public IPartTimeEmployee newPartTimeEmployee(); + abstract public IProject newProject(); + Class[] getTearDownClasses(); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryPMClass.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryPMClass.java index fe9fb853f..0f75f04eb 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryPMClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryPMClass.java @@ -23,69 +23,63 @@ * CompanyFactoryPMClass.java * * This class uses the PersistenceManager.newInstance method with the concrete - * class as a parameter. + * class as a parameter. */ -public class CompanyFactoryPMClass extends CompanyFactoryAbstractImpl { +public class CompanyFactoryPMClass + extends CompanyFactoryAbstractImpl { + + /** */ + public static final Class[] tearDownClasses = new Class[] { + DentalInsurance.class, MedicalInsurance.class, + PartTimeEmployee.class, FullTimeEmployee.class, + Project.class, Department.class, Company.class, MeetingRoom.class + }; - /** */ - public static final Class[] tearDownClasses = - new Class[] { - DentalInsurance.class, - MedicalInsurance.class, - PartTimeEmployee.class, - FullTimeEmployee.class, - Project.class, - Department.class, - Company.class, - MeetingRoom.class - }; + /** + * Creates a new instance of CompanyFactory + * @param pm the PersistenceManager + */ + public CompanyFactoryPMClass(PersistenceManager pm) { + super(pm); + } + + public IAddress newAddress() { + return (IAddress)pm.newInstance(Address.class); + } - /** - * Creates a new instance of CompanyFactory - * - * @param pm the PersistenceManager - */ - public CompanyFactoryPMClass(PersistenceManager pm) { - super(pm); - } + public IMeetingRoom newMeetingRoom() { + return (IMeetingRoom)pm.newInstance(MeetingRoom.class); + } + + public ICompany newCompany() { + return (ICompany)pm.newInstance(Company.class); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance)pm.newInstance(DentalInsurance.class); + } + + public IDepartment newDepartment() { + return (IDepartment)pm.newInstance(Department.class); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee)pm.newInstance(FullTimeEmployee.class); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance)pm.newInstance(MedicalInsurance.class); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee)pm.newInstance(PartTimeEmployee.class); + } + + public IProject newProject() { + return (IProject)pm.newInstance(Project.class); + } - public IAddress newAddress() { - return (IAddress) pm.newInstance(Address.class); - } - - public IMeetingRoom newMeetingRoom() { - return (IMeetingRoom) pm.newInstance(MeetingRoom.class); - } - - public ICompany newCompany() { - return (ICompany) pm.newInstance(Company.class); - } - - public IDentalInsurance newDentalInsurance() { - return (IDentalInsurance) pm.newInstance(DentalInsurance.class); - } - - public IDepartment newDepartment() { - return (IDepartment) pm.newInstance(Department.class); - } - - public IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) pm.newInstance(FullTimeEmployee.class); - } - - public IMedicalInsurance newMedicalInsurance() { - return (IMedicalInsurance) pm.newInstance(MedicalInsurance.class); - } - - public IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) pm.newInstance(PartTimeEmployee.class); - } - - public IProject newProject() { - return (IProject) pm.newInstance(Project.class); - } - - public Class[] getTearDownClasses() { - return tearDownClasses; - } + public Class[] getTearDownClasses() { + return tearDownClasses; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryPMInterface.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryPMInterface.java index 6f6c70cd1..f3cd9f175 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryPMInterface.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryPMInterface.java @@ -25,66 +25,61 @@ * Created on August 29, 2005, 9:56 PM * */ -public class CompanyFactoryPMInterface extends CompanyFactoryAbstractImpl { +public class CompanyFactoryPMInterface + extends CompanyFactoryAbstractImpl { + + /** */ + public static final Class[] tearDownClasses = new Class[] { + PIDentalInsurance.class, PIMedicalInsurance.class, + PIPartTimeEmployee.class, PIFullTimeEmployee.class, + PIProject.class, PIDepartment.class, PICompany.class + }; - /** */ - public static final Class[] tearDownClasses = - new Class[] { - PIDentalInsurance.class, - PIMedicalInsurance.class, - PIPartTimeEmployee.class, - PIFullTimeEmployee.class, - PIProject.class, - PIDepartment.class, - PICompany.class - }; + /** + * Creates a new instance of CompanyFactory + * @param pm the PersistenceManager + */ + public CompanyFactoryPMInterface(PersistenceManager pm) { + super(pm); + } + + public IAddress newAddress() { + return pm.newInstance(PIAddress.class); + } + + public IMeetingRoom newMeetingRoom() { + return pm.newInstance(PIMeetingRoom.class); + } + + public ICompany newCompany() { + return pm.newInstance(PICompany.class); + } + + public IDentalInsurance newDentalInsurance() { + return pm.newInstance(PIDentalInsurance.class); + } + + public IDepartment newDepartment() { + return pm.newInstance(PIDepartment.class); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return pm.newInstance(PIFullTimeEmployee.class); + } + + public IMedicalInsurance newMedicalInsurance() { + return pm.newInstance(PIMedicalInsurance.class); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return pm.newInstance(PIPartTimeEmployee.class); + } + + public IProject newProject() { + return pm.newInstance(PIProject.class); + } - /** - * Creates a new instance of CompanyFactory - * - * @param pm the PersistenceManager - */ - public CompanyFactoryPMInterface(PersistenceManager pm) { - super(pm); - } - - public IAddress newAddress() { - return pm.newInstance(PIAddress.class); - } - - public IMeetingRoom newMeetingRoom() { - return pm.newInstance(PIMeetingRoom.class); - } - - public ICompany newCompany() { - return pm.newInstance(PICompany.class); - } - - public IDentalInsurance newDentalInsurance() { - return pm.newInstance(PIDentalInsurance.class); - } - - public IDepartment newDepartment() { - return pm.newInstance(PIDepartment.class); - } - - public IFullTimeEmployee newFullTimeEmployee() { - return pm.newInstance(PIFullTimeEmployee.class); - } - - public IMedicalInsurance newMedicalInsurance() { - return pm.newInstance(PIMedicalInsurance.class); - } - - public IPartTimeEmployee newPartTimeEmployee() { - return pm.newInstance(PIPartTimeEmployee.class); - } - - public IProject newProject() { - return pm.newInstance(PIProject.class); - } - - public Class[] getTearDownClasses() { - return tearDownClasses; - } + public Class[] getTearDownClasses() { + return tearDownClasses; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryRegistry.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryRegistry.java index ead5dcd1a..418223edc 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryRegistry.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyFactoryRegistry.java @@ -5,25 +5,30 @@ * 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 + * + * 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.jdo.tck.pc.company; import java.lang.reflect.Constructor; + +import java.math.BigDecimal; + +import java.util.Date; + import javax.jdo.PersistenceManager; /* * This is the registry for company factories. It is used for the * CompletenessTest to create instances from input xml test data files. - * Factory instances that implement CompanyFactory interface are + * Factory instances that implement CompanyFactory interface are * registered (using the singleton pattern). *

    Several registration methods are available. The default factory, * which creates instances by construction, is automatically @@ -37,87 +42,99 @@ */ public class CompanyFactoryRegistry { - /** The system property for factory name */ - static final String FACTORY_PROPERTY_NAME = "jdo.tck.mapping.companyfactory"; - - /** The factory name if the system property is not set. */ - static final String DEFAULT_FACTORY_CLASS_NAME = - "org.apache.jdo.tck.pc.company.CompanyFactoryConcreteClass"; - - /** The default factory class name */ - static final String FACTORY_CLASS_NAME; - - static { - String prop = System.getProperty(FACTORY_PROPERTY_NAME); - if ((prop == null) || (prop.length() == 0)) prop = DEFAULT_FACTORY_CLASS_NAME; - FACTORY_CLASS_NAME = prop; - } - - /** - * This is the default company factory singleton. This is statically loaded regardless of the - * setting of the system property. - */ - static final CompanyFactory SINGLETON = new CompanyFactoryConcreteClass(); - - /** This is the currently registered factory. */ - static CompanyFactory instance = SINGLETON; - - /** Creates a new instance of CompanyFactoryRegistry */ - private CompanyFactoryRegistry() {} - - /** - * Get the currently registered factory. - * - * @return the factory - */ - public static CompanyFactory getInstance() { - return instance; - } - - /** Register the default factory. */ - public static void registerFactory() { - instance = SINGLETON; - } - - /** - * Register a factory using the default factory name from the system property. The factory must be - * available in the current class path and have a public constructor taking a PersistenceManager - * as a parameter. - * - * @param pm the PersistenceManager - */ - public static void registerFactory(PersistenceManager pm) { - registerFactory(FACTORY_CLASS_NAME, pm); - } - - /** - * Register a factory using the specified factoryName parameter. The factory class must be - * loadable by the current context classloader and have a public constructor taking a - * PersistenceManager as a parameter. - * - * @param factoryClassName the fully-qualified class name of the factory - * @param pm the PersistenceManager - */ - public static void registerFactory(String factoryClassName, PersistenceManager pm) { - CompanyFactory factory = null; - try { - if (factoryClassName != null) { - Class factoryClass = Class.forName(factoryClassName); - Constructor ctor = factoryClass.getConstructor(new Class[] {PersistenceManager.class}); - factory = (CompanyFactory) ctor.newInstance(new Object[] {pm}); - } - registerFactory(factory); - } catch (Exception ex) { - throw new RuntimeException("Unable to construct CompanyFactory " + factoryClassName, ex); + /** The system property for factory name + */ + final static String FACTORY_PROPERTY_NAME = + "jdo.tck.mapping.companyfactory"; + + /** The factory name if the system property is not set. + */ + final static String DEFAULT_FACTORY_CLASS_NAME = + "org.apache.jdo.tck.pc.company.CompanyFactoryConcreteClass"; + + /** + * The default factory class name + */ + final static String FACTORY_CLASS_NAME; + + static { + String prop = System.getProperty(FACTORY_PROPERTY_NAME); + if ((prop == null) || (prop.length() == 0)) + prop = DEFAULT_FACTORY_CLASS_NAME; + FACTORY_CLASS_NAME = prop; + } + + /** + * This is the default company factory singleton. This is statically + * loaded regardless of the setting of the system property. + */ + final static CompanyFactory SINGLETON = new CompanyFactoryConcreteClass(); + + /** + * This is the currently registered factory. + */ + static CompanyFactory instance = SINGLETON; + + /** + * Creates a new instance of CompanyFactoryRegistry + */ + private CompanyFactoryRegistry() { + } + + /** + * Get the currently registered factory. + * @return the factory + */ + public static CompanyFactory getInstance() { + return instance; + } + + /** Register the default factory. + */ + public static void registerFactory() { + instance = SINGLETON; + } + + /** Register a factory using the default factory name from the + * system property. The factory must be available in the current + * class path and have a public constructor + * taking a PersistenceManager as a parameter. + * @param pm the PersistenceManager + */ + public static void registerFactory(PersistenceManager pm) { + registerFactory(FACTORY_CLASS_NAME, pm); } - } - - /** - * Register the factory. - * - * @param factory the factory - */ - public static void registerFactory(CompanyFactory factory) { - instance = factory != null ? factory : SINGLETON; - } + + /** Register a factory using the specified factoryName + * parameter. The factory class must be loadable by the current context + * classloader and have a public constructor + * taking a PersistenceManager as a parameter. + * @param factoryClassName the fully-qualified class name of the factory + * @param pm the PersistenceManager + */ + public static void registerFactory(String factoryClassName, + PersistenceManager pm) { + CompanyFactory factory = null; + try { + if (factoryClassName != null) { + Class factoryClass = Class.forName(factoryClassName); + Constructor ctor = factoryClass.getConstructor(new Class[] + {PersistenceManager.class}); + factory = (CompanyFactory) + ctor.newInstance(new Object[]{pm}); + } + registerFactory(factory); + } catch (Exception ex) { + throw new RuntimeException ("Unable to construct CompanyFactory " + + factoryClassName, ex); + } + } + + /** Register the factory. + * @param factory the factory + */ + public static void registerFactory(CompanyFactory factory) { + instance = factory!=null?factory:SINGLETON; + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyModelReader.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyModelReader.java index f113ffb56..3750b2df1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyModelReader.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/CompanyModelReader.java @@ -5,21 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.company; import java.util.Date; import java.util.List; import java.util.Locale; + import org.apache.jdo.tck.util.ConversionHelper; import org.apache.jdo.tck.util.JDOCustomDateEditor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -27,216 +28,230 @@ import org.springframework.core.io.ClassPathResource; /** - * Utility class to create a graph of company model instances from an xml representation. + * Utility class to create a graph of company model instances from an xml + * representation. * * @author Michael Bouschen */ public class CompanyModelReader extends DefaultListableBeanFactory { - /** The name of the root list bean. */ - public static final String ROOT_LIST_NAME = "root"; - - /** The bean-factory name in the xml input files. */ - public static final String BEAN_FACTORY_NAME = "companyFactory"; - - /** The company factory instance. */ - private CompanyFactory companyFactory; - - /** Bean definition reader */ - private final XmlBeanDefinitionReader reader; - - /** - * Create a CompanyModelReader for the specified resourceName. - * - * @param resourceName the name of the resource - */ - public CompanyModelReader(String resourceName) { - // Use the class loader of the Company class to find the resource - this(resourceName, Company.class.getClassLoader()); - } - - /** - * Create a CompanyModelReader for the specified resourceName. - * - * @param resourceName the name of the resource - * @param classLoader the ClassLoader for the lookup - */ - public CompanyModelReader(String resourceName, ClassLoader classLoader) { - super(); - configureFactory(); - this.reader = new XmlBeanDefinitionReader(this); - this.reader.loadBeanDefinitions(new ClassPathResource(resourceName, classLoader)); - } - - /** - * Returns a list of root objects. The method expects to find a bean called "root" of type list in - * the xml and returns it. - * - * @return a list of root instances - */ - public List getRootList() { - return (List) getBean(ROOT_LIST_NAME); - } - - /** - * Configure the CompanyModelReader, e.g. register CustomEditor classes to convert the string - * representation of a property into an instance of the right type. - */ - private void configureFactory() { - registerCustomEditor(Date.class, JDOCustomDateEditor.class); - companyFactory = CompanyFactoryRegistry.getInstance(); - addSingleton(BEAN_FACTORY_NAME, companyFactory); - } - - /** - * @return Returns the tearDownClasses. - */ - public Class[] getTearDownClassesFromFactory() { - return companyFactory.getTearDownClasses(); - } - - /** - * @return Returns the tearDownClasses. - */ - public static Class[] getTearDownClasses() { - return CompanyFactoryConcreteClass.tearDownClasses; - } - - public static Date stringToUtilDate(String value) { - return ConversionHelper.toUtilDate(JDOCustomDateEditor.DATE_PATTERN, Locale.US, value); - } - - // Convenience methods - - /** - * Convenience method returning an Address instance for the specified name. The method returns - * null if there is no Address bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no Address bean. - */ - public IAddress getAddress(String name) { - return (IAddress) getBean(name, Address.class); - } - - /** - * Convenience method returning a MeetingRoom instance for the specified name. The method returns - * null if there is no MeetingRoom bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no MeetingRoom bean. - */ - public IMeetingRoom getMeetingRoom(String name) { - return (IMeetingRoom) getBean(name, MeetingRoom.class); - } - - /** - * Convenience method returning a Company instance for the specified name. The method returns - * null if there is no Company bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no Company bean. - */ - public ICompany getCompany(String name) { - return (ICompany) getBean(name, Company.class); - } - - /** - * Convenience method returning a DentalInsurance instance for the specified name. The method - * returns null if there is no DentalInsurance bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no DentalInsurance bean. - */ - public IDentalInsurance getDentalInsurance(String name) { - return (IDentalInsurance) getBean(name, DentalInsurance.class); - } - - /** - * Convenience method returning a Department instance for the specified name. The method returns - * null if there is no Department bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no Department bean. - */ - public IDepartment getDepartment(String name) { - return (IDepartment) getBean(name, Department.class); - } - - /** - * Convenience method returning an Employee instance for the specified name. The method returns - * null if there is no Employee bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no Employee bean. - */ - public IEmployee getEmployee(String name) { - return (IEmployee) getBean(name, Employee.class); - } - - /** - * Convenience method returning a FullTimeEmployee instance for the specified name. The method - * returns null if there is no FullTimeEmployee bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no FullTimeEmployee bean. - */ - public IFullTimeEmployee getFullTimeEmployee(String name) { - return (IFullTimeEmployee) getBean(name, FullTimeEmployee.class); - } - - /** - * Convenience method returning an Insurance instance for the specified name. The method returns - * null if there is no Insurance bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no Insurance bean. - */ - public IInsurance getInsurance(String name) { - return (IInsurance) getBean(name, Insurance.class); - } - - /** - * Convenience method returning a MedicalInsurance instance for the specified name. The method - * returns null if there is no MedicalInsurance bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no MedicalInsurance bean. - */ - public IMedicalInsurance getMedicalInsurance(String name) { - return (IMedicalInsurance) getBean(name, MedicalInsurance.class); - } - - /** - * Convenience method returning a PartTimeEmployee instance for the specified name. The method - * returns null if there is no PartTimeEmployee bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no PartTimeEmployee bean. - */ - public IPartTimeEmployee getPartTimeEmployee(String name) { - return (IPartTimeEmployee) getBean(name, PartTimeEmployee.class); - } - - /** - * Convenience method returning a Person instance for the specified name. The method returns - * null if there is no Person bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no Person bean. - */ - public IPerson getPerson(String name) { - return (IPerson) getBean(name, Person.class); - } - - /** - * Convenience method returning a Project instance for the specified name. The method returns - * null if there is no Project bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no Project bean. - */ - public IProject getProject(String name) { - return (IProject) getBean(name, Project.class); - } + /** The name of the root list bean. */ + public static final String ROOT_LIST_NAME = "root"; + + /** The bean-factory name in the xml input files. + */ + public static final String BEAN_FACTORY_NAME = "companyFactory"; + + /** The company factory instance. */ + private CompanyFactory companyFactory; + + /** Bean definition reader */ + private final XmlBeanDefinitionReader reader; + + /** + * Create a CompanyModelReader for the specified resourceName. + * @param resourceName the name of the resource + */ + public CompanyModelReader(String resourceName) { + // Use the class loader of the Company class to find the resource + this(resourceName, Company.class.getClassLoader()); + } + + /** + * Create a CompanyModelReader for the specified resourceName. + * @param resourceName the name of the resource + * @param classLoader the ClassLoader for the lookup + */ + public CompanyModelReader(String resourceName, ClassLoader classLoader) { + super(); + configureFactory(); + this.reader = new XmlBeanDefinitionReader(this); + this.reader.loadBeanDefinitions(new ClassPathResource(resourceName, classLoader)); + } + + /** + * Returns a list of root objects. The method expects to find a bean + * called "root" of type list in the xml and returns it. + * @return a list of root instances + */ + public List getRootList() { + return (List)getBean(ROOT_LIST_NAME); + } + + /** + * Configure the CompanyModelReader, e.g. register CustomEditor classes + * to convert the string representation of a property into an instance + * of the right type. + */ + private void configureFactory() { + registerCustomEditor(Date.class, JDOCustomDateEditor.class); + companyFactory = CompanyFactoryRegistry.getInstance(); + addSingleton(BEAN_FACTORY_NAME, companyFactory); + } + + /** + * @return Returns the tearDownClasses. + */ + public Class[] getTearDownClassesFromFactory() { + return companyFactory.getTearDownClasses(); + } + + /** + * @return Returns the tearDownClasses. + */ + public static Class[] getTearDownClasses() { + return CompanyFactoryConcreteClass.tearDownClasses; + } + + public static Date stringToUtilDate(String value) { + return ConversionHelper.toUtilDate(JDOCustomDateEditor.DATE_PATTERN, Locale.US, value); + } + + // Convenience methods + + /** + * Convenience method returning an Address instance for the specified + * name. The method returns null if there is no Address + * bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * Address bean. + */ + public IAddress getAddress(String name) { + return (IAddress)getBean(name, Address.class); + } + + /** + * Convenience method returning a MeetingRoom instance for the specified + * name. The method returns null if there is no MeetingRoom + * bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * MeetingRoom bean. + */ + public IMeetingRoom getMeetingRoom(String name) { + return (IMeetingRoom)getBean(name, MeetingRoom.class); + } + + /** + * Convenience method returning a Company instance for the specified + * name. The method returns null if there is no Company + * bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * Company bean. + */ + public ICompany getCompany(String name) { + return (ICompany)getBean(name, Company.class); + } + + /** + * Convenience method returning a DentalInsurance instance for the + * specified name. The method returns null if there is no + * DentalInsurance bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * DentalInsurance bean. + */ + public IDentalInsurance getDentalInsurance(String name) { + return (IDentalInsurance)getBean(name, DentalInsurance.class); + } + + /** + * Convenience method returning a Department instance for the specified + * name. The method returns null if there is no Department + * bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * Department bean. + */ + public IDepartment getDepartment(String name) { + return (IDepartment)getBean(name, Department.class); + } + + /** + * Convenience method returning an Employee instance for the specified + * name. The method returns null if there is no Employee + * bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * Employee bean. + */ + public IEmployee getEmployee(String name) { + return (IEmployee)getBean(name, Employee.class); + } + + /** + * Convenience method returning a FullTimeEmployee instance for the + * specified name. The method returns null if there is no + * FullTimeEmployee bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * FullTimeEmployee bean. + */ + public IFullTimeEmployee getFullTimeEmployee(String name) { + return (IFullTimeEmployee)getBean(name, FullTimeEmployee.class); + } + + /** + * Convenience method returning an Insurance instance for the specified + * name. The method returns null if there is no Insurance + * bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * Insurance bean. + */ + public IInsurance getInsurance(String name) { + return (IInsurance)getBean(name, Insurance.class); + } + + /** + * Convenience method returning a MedicalInsurance instance for the + * specified name. The method returns null if there is no + * MedicalInsurance bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * MedicalInsurance bean. + */ + public IMedicalInsurance getMedicalInsurance(String name) { + return (IMedicalInsurance)getBean(name, MedicalInsurance.class); + } + + /** + * Convenience method returning a PartTimeEmployee instance for the + * specified name. The method returns null if there is no + * PartTimeEmployee bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * PartTimeEmployee bean. + */ + public IPartTimeEmployee getPartTimeEmployee(String name) { + return (IPartTimeEmployee)getBean(name, PartTimeEmployee.class); + } + + /** + * Convenience method returning a Person instance for the specified + * name. The method returns null if there is no Person + * bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * Person bean. + */ + public IPerson getPerson(String name) { + return (IPerson)getBean(name, Person.class); + } + + /** + * Convenience method returning a Project instance for the specified + * name. The method returns null if there is no Project + * bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * Project bean. + */ + public IProject getProject(String name) { + return (IProject)getBean(name, Project.class); + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/DentalInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/DentalInsurance.java index 3f4691ea3..e936c70c9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/DentalInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/DentalInsurance.java @@ -5,119 +5,120 @@ * 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 + * + * 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.jdo.tck.pc.company; import java.math.BigDecimal; -import javax.jdo.annotations.PersistenceCapable; + +import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; +import javax.jdo.annotations.PersistenceCapable; + /** - * This class represents a dental insurance carrier selection for a particular Employee - * . + * This class represents a dental insurance carrier selection for a + * particular Employee. */ @PersistenceCapable public class DentalInsurance extends Insurance implements IDentalInsurance { - private BigDecimal lifetimeOrthoBenefit; + private BigDecimal lifetimeOrthoBenefit; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public DentalInsurance() {} - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public DentalInsurance() {} + /** + * Construct a DentalInsurance instance. + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public DentalInsurance(long insid, String carrier, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier); + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } - /** - * Construct a DentalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. - */ - public DentalInsurance(long insid, String carrier, BigDecimal lifetimeOrthoBenefit) { - super(insid, carrier); - this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; - } + /** + * Construct a DentalInsurance instance. + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public DentalInsurance(long insid, String carrier, IEmployee employee, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier, employee); + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } - /** - * Construct a DentalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param employee The employee associated with this insurance. - * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. - */ - public DentalInsurance( - long insid, String carrier, IEmployee employee, BigDecimal lifetimeOrthoBenefit) { - super(insid, carrier, employee); - this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; - } + /** + * Get the insurance lifetimeOrthoBenefit. + * @return The insurance lifetimeOrthoBenefit. + */ + public BigDecimal getLifetimeOrthoBenefit() { + return lifetimeOrthoBenefit; + } - /** - * Get the insurance lifetimeOrthoBenefit. - * - * @return The insurance lifetimeOrthoBenefit. - */ - public BigDecimal getLifetimeOrthoBenefit() { - return lifetimeOrthoBenefit; - } + /** + * Set the insurance lifetimeOrthoBenefit. + * @param lifetimeOrthoBenefit The insurance lifetimeOrthoBenefit. + */ + public void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit) { + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } - /** - * Set the insurance lifetimeOrthoBenefit. - * - * @param lifetimeOrthoBenefit The insurance lifetimeOrthoBenefit. - */ - public void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit) { - this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; - } + /** + * Returns a String representation of a DentalInsurance + * object. + * @return a String representation of a DentalInsurance + * object. + */ + public String toString() { + return "DentalInsurance(" + getFieldRepr()+ ")"; + } - /** - * Returns a String representation of a DentalInsurance object. - * - * @return a String representation of a DentalInsurance object. - */ - public String toString() { - return "DentalInsurance(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", lifetimeOrthoBenefit ").append(lifetimeOrthoBenefit); + return rc.toString(); + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", lifetimeOrthoBenefit ").append(lifetimeOrthoBenefit); - return rc.toString(); - } + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IDentalInsurance otherIns = (IDentalInsurance)other; + String where = "DentalInsurance<" + getInsid() + ">"; + return super.deepCompareFields(otherIns, helper) & + helper.equals(lifetimeOrthoBenefit, + otherIns.getLifetimeOrthoBenefit(), where + ".lifetimeOrthoBenefit"); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Object. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IDentalInsurance otherIns = (IDentalInsurance) other; - String where = "DentalInsurance<" + getInsid() + ">"; - return super.deepCompareFields(otherIns, helper) - & helper.equals( - lifetimeOrthoBenefit, - otherIns.getLifetimeOrthoBenefit(), - where + ".lifetimeOrthoBenefit"); - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/Department.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/Department.java index 7b7576501..4cadbc11e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/Department.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/Department.java @@ -5,454 +5,452 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.company; -import java.io.IOException; -import java.io.ObjectInputStream; import java.io.Serializable; +import java.io.ObjectInputStream; +import java.io.IOException; + import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Set; -import javax.jdo.annotations.PersistenceCapable; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a department within a company. */ +import javax.jdo.annotations.PersistenceCapable; + +/** + * This class represents a department within a company. + */ @PersistenceCapable -public class Department implements IDepartment, Serializable, Comparable, Comparator, DeepEquality { - - public static final int RECOMMENDED_NO_OF_EMPS = 2; - - private long deptid; - private String name; - private Company company; - private Employee employeeOfTheMonth; - private transient Set employees = new HashSet(); // element type is Employee - private transient Set fundedEmps = new HashSet(); // element type is Employee - private transient List meetingRooms = new ArrayList(); // element type is MeetingRoom - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public Department() {} - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - */ - public Department(long deptid, String name) { - this.deptid = deptid; - this.name = name; - } - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - * @param company The company that the department is associated with. - */ - public Department(long deptid, String name, ICompany company) { - this.deptid = deptid; - this.name = name; - this.company = (Company) company; - } - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - * @param company The company that the department is associated with. - * @param employeeOfTheMonth The employee of the month the department is associated with. - */ - public Department(long deptid, String name, ICompany company, IEmployee employeeOfTheMonth) { - this.deptid = deptid; - this.name = name; - this.company = (Company) company; - this.employeeOfTheMonth = (Employee) employeeOfTheMonth; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setDeptid(long id) { - if (this.deptid != 0) throw new IllegalStateException("Id is already set."); - this.deptid = id; - } - - /** - * Get the department id. - * - * @return The department id. - */ - public long getDeptid() { - return deptid; - } - - /** - * Get the name of the department. - * - * @return The name of the department. - */ - public String getName() { - return name; - } - - /** - * Set the name of the department. - * - * @param name The name to set for the department. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Get the company associated with the department. - * - * @return The company. - */ - public ICompany getCompany() { - return company; - } - - /** - * Set the company for the department. - * - * @param company The company to associate with the department. - */ - public void setCompany(ICompany company) { - this.company = (Company) company; - } - - /** - * Get the employee of the month associated with the department. - * - * @return The employee of the month. - */ - public IEmployee getEmployeeOfTheMonth() { - return employeeOfTheMonth; - } - - /** - * Set the employee of the month for the department. - * - * @param employeeOfTheMonth The employee of the month to associate with the department. - */ - public void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth) { - this.employeeOfTheMonth = (Employee) employeeOfTheMonth; - } - - /** - * Get the employees in the department as an unmodifiable set. - * - * @return The set of employees in the department, as an unmodifiable set. - */ - public Set getEmployees() { - return Collections.unmodifiableSet(employees); - } - - /** - * Add an employee to the department. - * - * @param emp The employee to add to the department. - */ - public void addEmployee(Employee emp) { - employees.add(emp); - } - - /** - * Remove an employee from the department. - * - * @param emp The employee to remove from the department. - */ - public void removeEmployee(Employee emp) { - employees.remove(emp); - } - - /** - * Set the employees to be in this department. - * - * @param employees The set of employees for this department. - */ - public void setEmployees(Set employees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.employees = (employees != null) ? new HashSet(employees) : null; - } - - /** - * Get the funded employees in the department as an unmodifiable set. - * - * @return The set of funded employees in the department, as an unmodifiable set. - */ - public Set getFundedEmps() { - return Collections.unmodifiableSet(fundedEmps); - } - - /** - * Add an employee to the collection of funded employees of this department. - * - * @param emp The employee to add to the department. - */ - public void addFundedEmp(Employee emp) { - fundedEmps.add(emp); - } - - /** - * Remove an employee from collection of funded employees of this department. - * - * @param emp The employee to remove from the department. - */ - public void removeFundedEmp(Employee emp) { - fundedEmps.remove(emp); - } - - /** - * Set the funded employees to be in this department. - * - * @param employees The set of funded employees for this department. - */ - public void setFundedEmps(Set employees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.fundedEmps = (fundedEmps != null) ? new HashSet(employees) : null; - } - - /** - * Get the meeting rooms in the department as an unmodifiable list. - * - * @return List of meeting rooms in the department, as an unmodifiable list. - */ - public List getMeetingRooms() { - return Collections.unmodifiableList(meetingRooms); - } - - /** - * Add a meeting room to the department. - * - * @param room Meeting room to add to the department. - */ - public void addMeetingRoom(MeetingRoom room) { - meetingRooms.add(room); - } - - /** - * Remove a meeting room from the department. - * - * @param room Meeting room to remove from the department. - */ - public void removeMeetingRoom(MeetingRoom room) { - meetingRooms.remove(room); - } - - /** - * Set the rooms for this department. - * - * @param rooms The rooms for this department. - */ - public void setMeetingRooms(List rooms) { - this.meetingRooms = (rooms != null) ? new ArrayList(rooms) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - employees = new HashSet(); - fundedEmps = new HashSet(); - meetingRooms = new ArrayList(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Department. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IDepartment otherDept = (IDepartment) other; - String where = "Department<" + deptid + ">"; - return helper.equals(deptid, otherDept.getDeptid(), where + ".deptid") - & helper.equals(name, otherDept.getName(), where + ".name") - & helper.deepEquals(company, otherDept.getCompany(), where + ".company") - & helper.deepEquals( - employeeOfTheMonth, otherDept.getEmployeeOfTheMonth(), where + ".employeeOfTheMonth") - & helper.deepEquals(employees, otherDept.getEmployees(), where + ".employees") - & helper.deepEquals(fundedEmps, otherDept.getFundedEmps(), where + ".fundedEmps"); - // TODO Add meetingRooms to comparison - } - - /** - * Returns a String representation of a Department object. - * - * @return a String representation of a Department object. - */ - public String toString() { - return "Department(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(deptid); - rc.append(", name ").append(name); - return rc.toString(); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((IDepartment) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((IDepartment) o1, (IDepartment) o2); - } - - /** - * Compares this object with the specified Department object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Department object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Department object. - */ - public int compareTo(IDepartment other) { - return compare(this, other); - } - - /** - * Compares its two IDepartment arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IDepartment object to be compared. - * @param o2 the second IDepartment object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(IDepartment o1, IDepartment o2) { - return EqualityHelper.compare(o1.getDeptid(), o2.getDeptid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof IDepartment) { - return compareTo((IDepartment) obj) == 0; - } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) deptid; - } - - /** The application identity class associated with the Department class. */ - public static class Oid implements Serializable, Comparable { +public class Department + implements IDepartment, Serializable, Comparable, Comparator, DeepEquality { + + public static final int RECOMMENDED_NO_OF_EMPS = 2; + + private long deptid; + private String name; + private Company company; + private Employee employeeOfTheMonth; + private transient Set employees = new HashSet(); // element type is Employee + private transient Set fundedEmps = new HashSet(); // element type is Employee + private transient List meetingRooms = new ArrayList(); // element type is MeetingRoom + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public Department() {} + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + */ + public Department(long deptid, String name) { + this.deptid = deptid; + this.name = name; + } /** - * This field represents the application identifier field for the Department class. - * It must match in name and type with the field in the Department class. + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + * @param company The company that the department is associated with. */ - public long deptid; + public Department(long deptid, String name, ICompany company) { + this.deptid = deptid; + this.name = name; + this.company = (Company)company; + } + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + * @param company The company that the department is associated with. + * @param employeeOfTheMonth The employee of the month the + * department is associated with. + */ + public Department(long deptid, String name, ICompany company, + IEmployee employeeOfTheMonth) { + this.deptid = deptid; + this.name = name; + this.company = (Company)company; + this.employeeOfTheMonth = (Employee)employeeOfTheMonth; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setDeptid(long id) { + if (this.deptid != 0) + throw new IllegalStateException("Id is already set."); + this.deptid = id; + } - /** The required public, no-arg constructor. */ - public Oid() {} + /** + * Get the department id. + * @return The department id. + */ + public long getDeptid() { + return deptid; + } /** - * A constructor to initialize the identifier field. - * - * @param deptid the deptid of the Department. + * Get the name of the department. + * @return The name of the department. */ - public Oid(long deptid) { - this.deptid = deptid; + public String getName() { + return name; } - public Oid(String s) { - deptid = Long.parseLong(justTheId(s)); + /** + * Set the name of the department. + * @param name The name to set for the department. + */ + public void setName(String name) { + this.name = name; } + /** + * Get the company associated with the department. + * @return The company. + */ + public ICompany getCompany() { + return company; + } + + /** + * Set the company for the department. + * @param company The company to associate with the department. + */ + public void setCompany(ICompany company) { + this.company = (Company)company; + } + + /** + * Get the employee of the month associated with the department. + * @return The employee of the month. + */ + public IEmployee getEmployeeOfTheMonth() { + return employeeOfTheMonth; + } + + /** + * Set the employee of the month for the department. + * @param employeeOfTheMonth The employee of the month to + * associate with the department. + */ + public void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth) { + this.employeeOfTheMonth = (Employee)employeeOfTheMonth; + } + + /** + * Get the employees in the department as an unmodifiable set. + * @return The set of employees in the department, as an unmodifiable + * set. + */ + public Set getEmployees() { + return Collections.unmodifiableSet(employees); + } + + /** + * Add an employee to the department. + * @param emp The employee to add to the department. + */ + public void addEmployee(Employee emp) { + employees.add(emp); + } + + /** + * Remove an employee from the department. + * @param emp The employee to remove from the department. + */ + public void removeEmployee(Employee emp) { + employees.remove(emp); + } + + /** + * Set the employees to be in this department. + * @param employees The set of employees for this department. + */ + public void setEmployees(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.employees = (employees != null) ? new HashSet(employees) : null; + } + + /** + * Get the funded employees in the department as an unmodifiable set. + * @return The set of funded employees in the department, as an + * unmodifiable set. + */ + public Set getFundedEmps() { + return Collections.unmodifiableSet(fundedEmps); + } + + /** + * Add an employee to the collection of funded employees of this + * department. + * @param emp The employee to add to the department. + */ + public void addFundedEmp(Employee emp) { + fundedEmps.add(emp); + } + + /** + * Remove an employee from collection of funded employees of this + * department. + * @param emp The employee to remove from the department. + */ + public void removeFundedEmp(Employee emp) { + fundedEmps.remove(emp); + } + + /** + * Set the funded employees to be in this department. + * @param employees The set of funded employees for this department. + */ + public void setFundedEmps(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.fundedEmps = (fundedEmps != null) ? new HashSet(employees) : null; + } + + /** + * Get the meeting rooms in the department as an unmodifiable list. + * @return List of meeting rooms in the department, as an unmodifiable list. + */ + public List getMeetingRooms() { + return Collections.unmodifiableList(meetingRooms); + } + + /** + * Add a meeting room to the department. + * @param room Meeting room to add to the department. + */ + public void addMeetingRoom(MeetingRoom room) { + meetingRooms.add(room); + } + + /** + * Remove a meeting room from the department. + * @param room Meeting room to remove from the department. + */ + public void removeMeetingRoom(MeetingRoom room) { + meetingRooms.remove(room); + } + + /** + * Set the rooms for this department. + * @param rooms The rooms for this department. + */ + public void setMeetingRooms(List rooms) { + this.meetingRooms = (rooms != null) ? new ArrayList(rooms) : null; + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + employees = new HashSet(); + fundedEmps = new HashSet(); + meetingRooms = new ArrayList(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Department. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IDepartment otherDept = (IDepartment)other; + String where = "Department<" + deptid + ">"; + return + helper.equals(deptid, otherDept.getDeptid(), where + ".deptid") & + helper.equals(name, otherDept.getName(), where + ".name") & + helper.deepEquals(company, otherDept.getCompany(), where + ".company") & + helper.deepEquals(employeeOfTheMonth, otherDept.getEmployeeOfTheMonth(), where + ".employeeOfTheMonth") & + helper.deepEquals(employees, otherDept.getEmployees(), where + ".employees") & + helper.deepEquals(fundedEmps, otherDept.getFundedEmps(), where + ".fundedEmps"); + // TODO Add meetingRooms to comparison + } + + /** + * Returns a String representation of a Department object. + * @return a String representation of a Department object. + */ public String toString() { - return this.getClass().getName() + ": " + deptid; + return "Department(" + getFieldRepr()+ ")"; } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.deptid != o.deptid) return (false); - return (true); + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(deptid); + rc.append(", name ").append(name); + return rc.toString(); } - /** */ - public int hashCode() { - return ((int) deptid); + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((IDepartment)o); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((IDepartment)o1, (IDepartment)o2); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (deptid < other.deptid) return -1; - if (deptid > other.deptid) return 1; - return 0; + /** + * Compares this object with the specified Department object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Department object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified + * Department object. + */ + public int compareTo(IDepartment other) { + return compare(this, other); } - } + + /** + * Compares its two IDepartment arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IDepartment object to be compared. + * @param o2 the second IDepartment object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(IDepartment o1, IDepartment o2) { + return EqualityHelper.compare(o1.getDeptid(), o2.getDeptid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof IDepartment) { + return compareTo((IDepartment)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)deptid; + } + + /** + * The application identity class associated with the + * Department class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the application identifier field + * for the Department class. + * It must match in name and type with the field in the + * Department class. + */ + public long deptid; + + /** + * The required public, no-arg constructor. + */ + public Oid() { } + + /** + * A constructor to initialize the identifier field. + * @param deptid the deptid of the Department. + */ + public Oid(long deptid) { + this.deptid = deptid; + } + + public Oid(String s) { deptid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + deptid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.deptid != o.deptid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) deptid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( deptid < other.deptid ) return -1; + if( deptid > other.deptid ) return 1; + return 0; + } + + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/Employee.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/Employee.java index e6ab0b0b4..5fbc5711b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/Employee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/Employee.java @@ -5,503 +5,470 @@ * 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 + * + * 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.jdo.tck.pc.company; -import java.io.IOException; import java.io.ObjectInputStream; +import java.io.IOException; + import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.Set; -import javax.jdo.annotations.PersistenceCapable; + import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents an employee. */ +import javax.jdo.annotations.PersistenceCapable; + +/** + * This class represents an employee. + */ @PersistenceCapable public abstract class Employee extends Person implements IEmployee { - private Date hiredate; - private double weeklyhours; - private DentalInsurance dentalInsurance; - private MedicalInsurance medicalInsurance; - private Department department; - private Department fundingDept; - private Employee manager; - private Employee mentor; - private Employee protege; - private Employee hradvisor; - private transient Set reviewedProjects = new HashSet(); // element-type is Project - private transient Set projects = new HashSet(); // element-type is Project - private transient Set team = new HashSet(); // element-type is Employee - private transient Set hradvisees = new HashSet(); // element-type is Employee - - /** This is the JDO-required no-args constructor */ - protected Employee() {} - - /** - * Construct an Employee instance. - * - * @param personid The identifier for the person. - * @param firstname The first name of the employee. - * @param lastname The last name of the employee. - * @param middlename The middle name of the employee. - * @param birthdate The birth date of the employee. - * @param hiredate The date that the employee was hired. - */ - public Employee( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - Date hiredate) { - super(personid, firstname, lastname, middlename, birthdate); - this.hiredate = hiredate; - } - - /** - * Construct an Employee instance. - * - * @param personid The identifier for the person. - * @param firstname The first name of the employee. - * @param lastname The last name of the employee. - * @param middlename The middle name of the employee. - * @param birthdate The birth date of the employee. - * @param address The address of the employee. - * @param hiredate The date that the employee was hired. - */ - public Employee( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - IAddress address, - Date hiredate) { - super(personid, firstname, lastname, middlename, birthdate, address); - this.hiredate = hiredate; - } - - /** - * Get the date that the employee was hired. - * - * @return The date the employee was hired. - */ - public Date getHiredate() { - return hiredate; - } - - /** - * Set the date that the employee was hired. - * - * @param hiredate The date the employee was hired. - */ - public void setHiredate(Date hiredate) { - this.hiredate = hiredate; - } - - /** - * Get the weekly hours of the employee. - * - * @return The number of hours per week that the employee works. - */ - public double getWeeklyhours() { - return weeklyhours; - } - - /** - * Set the number of hours per week that the employee works. - * - * @param weeklyhours The number of hours per week that the employee works. - */ - public void setWeeklyhours(double weeklyhours) { - this.weeklyhours = weeklyhours; - } - - /** - * Get the reviewed projects. - * - * @return The reviewed projects as an unmodifiable set. - */ - public Set getReviewedProjects() { - return Collections.unmodifiableSet(reviewedProjects); - } - - /** - * Add a reviewed project. - * - * @param project A reviewed project. - */ - public void addReviewedProjects(Project project) { - reviewedProjects.add(project); - } - - /** - * Remove a reviewed project. - * - * @param project A reviewed project. - */ - public void removeReviewedProject(Project project) { - reviewedProjects.remove(project); - } - - /** - * Set the reviewed projects for the employee. - * - * @param reviewedProjects The set of reviewed projects. - */ - public void setReviewedProjects(Set reviewedProjects) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.reviewedProjects = (reviewedProjects != null) ? new HashSet(reviewedProjects) : null; - } - - /** - * Get the employee's projects. - * - * @return The employee's projects are returned as an unmodifiable set. - */ - public Set getProjects() { - return Collections.unmodifiableSet(projects); - } - - /** - * Add a project for the employee. - * - * @param project The project. - */ - public void addProject(Project project) { - projects.add(project); - } - - /** - * Remove a project from an employee's set of projects. - * - * @param project The project. - */ - public void removeProject(Project project) { - projects.remove(project); - } - - /** - * Set the projects for the employee. - * - * @param projects The set of projects of the employee. - */ - public void setProjects(Set projects) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.projects = (projects != null) ? new HashSet(projects) : null; - } - - /** - * Get the dental insurance of the employee. - * - * @return The employee's dental insurance. - */ - public IDentalInsurance getDentalInsurance() { - return dentalInsurance; - } - - /** - * Set the dental insurance object for the employee. - * - * @param dentalInsurance The dental insurance object to associate with the employee. - */ - public void setDentalInsurance(IDentalInsurance dentalInsurance) { - this.dentalInsurance = (DentalInsurance) dentalInsurance; - } - /** - * Get the medical insurance of the employee. - * - * @return The employee's medical insurance. - */ - public IMedicalInsurance getMedicalInsurance() { - return medicalInsurance; - } - - /** - * Set the medical insurance object for the employee. - * - * @param medicalInsurance The medical insurance object to associate with the employee. - */ - public void setMedicalInsurance(IMedicalInsurance medicalInsurance) { - this.medicalInsurance = (MedicalInsurance) medicalInsurance; - } - - /** - * Get the employee's department. - * - * @return The department associated with the employee. - */ - public IDepartment getDepartment() { - return department; - } - - /** - * Set the employee's department. - * - * @param department The department. - */ - public void setDepartment(IDepartment department) { - this.department = (Department) department; - } - - /** - * Get the employee's funding department. - * - * @return The funding department associated with the employee. - */ - public IDepartment getFundingDept() { - return fundingDept; - } - - /** - * Set the employee's funding department. - * - * @param department The funding department. - */ - public void setFundingDept(IDepartment department) { - this.fundingDept = (Department) department; - } - - /** - * Get the employee's manager. - * - * @return The employee's manager. - */ - public IEmployee getManager() { - return manager; - } - - /** - * Set the employee's manager. - * - * @param manager The employee's manager. - */ - public void setManager(IEmployee manager) { - this.manager = (Employee) manager; - } - - /** - * Get the employee's team. - * - * @return The set of Employees on this employee's team, returned as an unmodifiable - * set. - */ - public Set getTeam() { - return Collections.unmodifiableSet(team); - } - - /** - * Add an Employee to this employee's team. This method sets both sides of the - * relationship, modifying this employees team to include parameter emp and modifying emp to set - * its manager attribute to this object. - * - * @param emp The Employee to add to the team. - */ - public void addToTeam(Employee emp) { - team.add(emp); - emp.manager = this; - } - - /** - * Remove an Employee from this employee's team. This method will also set the - * emp manager to null. - * - * @param emp The Employee to remove from the team. - */ - public void removeFromTeam(Employee emp) { - team.remove(emp); - emp.manager = null; - } - - /** - * Set the employee's team. - * - * @param team The set of Employees. - */ - public void setTeam(Set team) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.team = (team != null) ? new HashSet(team) : null; - } - - /** - * Set the mentor for this employee. - * - * @param mentor The mentor for this employee. - */ - public void setMentor(IEmployee mentor) { - this.mentor = (Employee) mentor; - } - - /** - * Get the mentor for this employee. - * - * @return The mentor. - */ - public IEmployee getMentor() { - return mentor; - } - - /** - * Set the protege for this employee. - * - * @param protege The protege for this employee. - */ - public void setProtege(IEmployee protege) { - this.protege = (Employee) protege; - } - - /** - * Get the protege of this employee. - * - * @return The protege of this employee. - */ - public IEmployee getProtege() { - return protege; - } - - /** - * Set the HR advisor for this employee. - * - * @param hradvisor The hradvisor for this employee. - */ - public void setHradvisor(IEmployee hradvisor) { - this.hradvisor = (Employee) hradvisor; - } - - /** - * Get the HR advisor for the employee. - * - * @return The HR advisor. - */ - public IEmployee getHradvisor() { - return hradvisor; - } - - /** - * Get the HR advisees of this HR advisor. - * - * @return An unmodifiable Set containing the Employees that are HR - * advisees of this employee. - */ - public Set getHradvisees() { - return Collections.unmodifiableSet(hradvisees); - } - - /** - * Add an Employee as an advisee of this HR advisor. This method also sets the - * emp hradvisor to reference this object. In other words, both sides of the relationship - * are set. - * - * @param emp The employee to add as an advisee. - */ - public void addAdvisee(Employee emp) { - hradvisees.add(emp); - emp.hradvisor = this; - } - - /** - * Remove an Employee as an advisee of this HR advisor. This method also sets the - * emp hradvisor to null. In other words, both sides of the relationship are set. - * - * @param emp The employee to add as an HR advisee. - */ - public void removeAdvisee(Employee emp) { - hradvisees.remove(emp); - emp.hradvisor = null; - } - - /** - * Set the HR advisees of this HR advisor. - * - * @param hradvisees The Employees that are HR advisees of this employee. - */ - public void setHradvisees(Set hradvisees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.hradvisees = (hradvisees != null) ? new HashSet(hradvisees) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - reviewedProjects = new HashSet(); - projects = new HashSet(); - team = new HashSet(); - hradvisees = new HashSet(); - } - - /** - * Return a String representation of a Employee object. - * - * @return a String representation of a Employee object. - */ - public String toString() { - return "Employee(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", hired ").append(hiredate == null ? "null" : formatter.format(hiredate)); - rc.append(", weeklyhours ").append(weeklyhours); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the - * corresponding fields of the specified Employee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IEmployee otherEmp = (IEmployee) other; - String where = "Employee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.equals(hiredate, otherEmp.getHiredate(), where + ".hiredate") - & helper.closeEnough(weeklyhours, otherEmp.getWeeklyhours(), where + ".weeklyhours") - & helper.deepEquals( - dentalInsurance, otherEmp.getDentalInsurance(), where + ".dentalInsurance") - & helper.deepEquals( - medicalInsurance, otherEmp.getMedicalInsurance(), where + ".medicalInsurance") - & helper.deepEquals(department, otherEmp.getDepartment(), where + ".department") - & helper.deepEquals(fundingDept, otherEmp.getFundingDept(), where + ".fundingDept") - & helper.deepEquals(manager, otherEmp.getManager(), where + ".manager") - & helper.deepEquals(mentor, otherEmp.getMentor(), where + ".mentor") - & helper.deepEquals(protege, otherEmp.getProtege(), where + ".protege") - & helper.deepEquals(hradvisor, otherEmp.getHradvisor(), where + ".hradvisor") - & helper.deepEquals( - reviewedProjects, otherEmp.getReviewedProjects(), where + ".reviewedProjects") - & helper.deepEquals(projects, otherEmp.getProjects(), where + ".projects") - & helper.deepEquals(team, otherEmp.getTeam(), where + ".team") - & helper.deepEquals(hradvisees, otherEmp.getHradvisees(), where + ".hradvisees"); - } + private Date hiredate; + private double weeklyhours; + private DentalInsurance dentalInsurance; + private MedicalInsurance medicalInsurance; + private Department department; + private Department fundingDept; + private Employee manager; + private Employee mentor; + private Employee protege; + private Employee hradvisor; + private transient Set reviewedProjects = new HashSet(); // element-type is Project + private transient Set projects = new HashSet(); // element-type is Project + private transient Set team = new HashSet(); // element-type is Employee + private transient Set hradvisees = new HashSet(); // element-type is Employee + + /** This is the JDO-required no-args constructor */ + protected Employee() {} + + /** + * Construct an Employee instance. + * @param personid The identifier for the person. + * @param firstname The first name of the employee. + * @param lastname The last name of the employee. + * @param middlename The middle name of the employee. + * @param birthdate The birth date of the employee. + * @param hiredate The date that the employee was hired. + */ + public Employee(long personid, String firstname, String lastname, + String middlename, Date birthdate, + Date hiredate) { + super(personid, firstname, lastname, middlename, birthdate); + this.hiredate = hiredate; + } + + /** + * Construct an Employee instance. + * @param personid The identifier for the person. + * @param firstname The first name of the employee. + * @param lastname The last name of the employee. + * @param middlename The middle name of the employee. + * @param birthdate The birth date of the employee. + * @param address The address of the employee. + * @param hiredate The date that the employee was hired. + */ + public Employee(long personid, String firstname, String lastname, + String middlename, Date birthdate, IAddress address, + Date hiredate) { + super(personid, firstname, lastname, middlename, birthdate, address); + this.hiredate = hiredate; + } + + /** + * Get the date that the employee was hired. + * @return The date the employee was hired. + */ + public Date getHiredate() { + return hiredate; + } + + /** + * Set the date that the employee was hired. + * @param hiredate The date the employee was hired. + */ + public void setHiredate(Date hiredate) { + this.hiredate = hiredate; + } + + /** + * Get the weekly hours of the employee. + * @return The number of hours per week that the employee works. + */ + public double getWeeklyhours() { + return weeklyhours; + } + + /** + * Set the number of hours per week that the employee works. + * @param weeklyhours The number of hours per week that the employee + * works. + */ + public void setWeeklyhours(double weeklyhours) { + this.weeklyhours = weeklyhours; + } + + /** + * Get the reviewed projects. + * @return The reviewed projects as an unmodifiable set. + */ + public Set getReviewedProjects() { + return Collections.unmodifiableSet(reviewedProjects); + } + + /** + * Add a reviewed project. + * @param project A reviewed project. + */ + public void addReviewedProjects(Project project) { + reviewedProjects.add(project); + } + + /** + * Remove a reviewed project. + * @param project A reviewed project. + */ + public void removeReviewedProject(Project project) { + reviewedProjects.remove(project); + } + + /** + * Set the reviewed projects for the employee. + * @param reviewedProjects The set of reviewed projects. + */ + public void setReviewedProjects(Set reviewedProjects) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.reviewedProjects = + (reviewedProjects != null) ? new HashSet(reviewedProjects) : null; + } + + /** + * Get the employee's projects. + * @return The employee's projects are returned as an unmodifiable + * set. + */ + public Set getProjects() { + return Collections.unmodifiableSet(projects); + } + + /** + * Add a project for the employee. + * @param project The project. + */ + public void addProject(Project project) { + projects.add(project); + } + + /** + * Remove a project from an employee's set of projects. + * @param project The project. + */ + public void removeProject(Project project) { + projects.remove(project); + } + + /** + * Set the projects for the employee. + * @param projects The set of projects of the employee. + */ + public void setProjects(Set projects) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.projects = (projects != null) ? new HashSet(projects) : null; + } + + /** + * Get the dental insurance of the employee. + * @return The employee's dental insurance. + */ + public IDentalInsurance getDentalInsurance() { + return dentalInsurance; + } + + /** + * Set the dental insurance object for the employee. + * @param dentalInsurance The dental insurance object to associate with + * the employee. + */ + public void setDentalInsurance(IDentalInsurance dentalInsurance) { + this.dentalInsurance = (DentalInsurance)dentalInsurance; + } + /** + * Get the medical insurance of the employee. + * @return The employee's medical insurance. + */ + public IMedicalInsurance getMedicalInsurance() { + return medicalInsurance; + } + + /** + * Set the medical insurance object for the employee. + * @param medicalInsurance The medical insurance object to associate + * with the employee. + */ + public void setMedicalInsurance(IMedicalInsurance medicalInsurance) { + this.medicalInsurance = (MedicalInsurance)medicalInsurance; + } + + /** + * Get the employee's department. + * @return The department associated with the employee. + */ + public IDepartment getDepartment() { + return department; + } + + /** + * Set the employee's department. + * @param department The department. + */ + public void setDepartment(IDepartment department) { + this.department = (Department)department; + } + + /** + * Get the employee's funding department. + * @return The funding department associated with the employee. + */ + public IDepartment getFundingDept() { + return fundingDept; + } + + /** + * Set the employee's funding department. + * @param department The funding department. + */ + public void setFundingDept(IDepartment department) { + this.fundingDept = (Department)department; + } + + /** + * Get the employee's manager. + * @return The employee's manager. + */ + public IEmployee getManager() { + return manager; + } + + /** + * Set the employee's manager. + * @param manager The employee's manager. + */ + public void setManager(IEmployee manager) { + this.manager = (Employee)manager; + } + + /** + * Get the employee's team. + * @return The set of Employees on this employee's team, + * returned as an unmodifiable set. + */ + public Set getTeam() { + return Collections.unmodifiableSet(team); + } + + /** + * Add an Employee to this employee's team. + * This method sets both sides of the relationship, modifying + * this employees team to include parameter emp and modifying + * emp to set its manager attribute to this object. + * @param emp The Employee to add to the team. + */ + public void addToTeam(Employee emp) { + team.add(emp); + emp.manager = this; + } + + /** + * Remove an Employee from this employee's team. + * This method will also set the emp manager to null. + * @param emp The Employee to remove from the team. + */ + public void removeFromTeam(Employee emp) { + team.remove(emp); + emp.manager = null; + } + + /** + * Set the employee's team. + * @param team The set of Employees. + */ + public void setTeam(Set team) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.team = (team != null) ? new HashSet(team) : null; + } + + /** + * Set the mentor for this employee. + * @param mentor The mentor for this employee. + */ + public void setMentor(IEmployee mentor) { + this.mentor = (Employee)mentor; + } + + /** + * Get the mentor for this employee. + * @return The mentor. + */ + public IEmployee getMentor() { + return mentor; + } + + /** + * Set the protege for this employee. + * @param protege The protege for this employee. + */ + public void setProtege(IEmployee protege) { + this.protege = (Employee)protege; + } + + /** + * Get the protege of this employee. + * @return The protege of this employee. + */ + public IEmployee getProtege() { + return protege; + } + + /** + * Set the HR advisor for this employee. + * @param hradvisor The hradvisor for this employee. + */ + public void setHradvisor(IEmployee hradvisor) { + this.hradvisor = (Employee)hradvisor; + } + + /** + * Get the HR advisor for the employee. + * @return The HR advisor. + */ + public IEmployee getHradvisor() { + return hradvisor; + } + + /** + * Get the HR advisees of this HR advisor. + * @return An unmodifiable Set containing the + * Employees that are HR advisees of this employee. + */ + public Set getHradvisees() { + return Collections.unmodifiableSet(hradvisees); + } + + /** + * Add an Employee as an advisee of this HR advisor. + * This method also sets the emp hradvisor to reference + * this object. In other words, both sides of the relationship are + * set. + * @param emp The employee to add as an advisee. + */ + public void addAdvisee(Employee emp) { + hradvisees.add(emp); + emp.hradvisor = this; + } + + /** + * Remove an Employee as an advisee of this HR advisor. + * This method also sets the emp hradvisor to null. + * In other words, both sides of the relationship are set. + * @param emp The employee to add as an HR advisee. + */ + public void removeAdvisee(Employee emp) { + hradvisees.remove(emp); + emp.hradvisor = null; + } + + /** + * Set the HR advisees of this HR advisor. + * @param hradvisees The Employees that are HR advisees of + * this employee. + */ + public void setHradvisees(Set hradvisees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.hradvisees = (hradvisees != null) ? new HashSet(hradvisees) : null; + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + reviewedProjects = new HashSet(); + projects = new HashSet(); + team = new HashSet(); + hradvisees = new HashSet(); + } + + /** + * Return a String representation of a Employee object. + * @return a String representation of a Employee object. + */ + public String toString() { + return "Employee(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", hired ").append( + hiredate==null ? "null" : formatter.format(hiredate)); + rc.append(", weeklyhours ").append(weeklyhours); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the corresponding fields of the specified Employee. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IEmployee otherEmp = (IEmployee)other; + String where = "Employee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.equals(hiredate, otherEmp.getHiredate(), where + ".hiredate") & + helper.closeEnough(weeklyhours, otherEmp.getWeeklyhours(), where + ".weeklyhours") & + helper.deepEquals(dentalInsurance, otherEmp.getDentalInsurance(), where + ".dentalInsurance") & + helper.deepEquals(medicalInsurance, otherEmp.getMedicalInsurance(), where + ".medicalInsurance") & + helper.deepEquals(department, otherEmp.getDepartment(), where + ".department") & + helper.deepEquals(fundingDept, otherEmp.getFundingDept(), where + ".fundingDept") & + helper.deepEquals(manager, otherEmp.getManager(), where + ".manager") & + helper.deepEquals(mentor, otherEmp.getMentor(), where + ".mentor") & + helper.deepEquals(protege, otherEmp.getProtege(), where + ".protege") & + helper.deepEquals(hradvisor, otherEmp.getHradvisor(), where + ".hradvisor") & + helper.deepEquals(reviewedProjects, otherEmp.getReviewedProjects(), where + ".reviewedProjects") & + helper.deepEquals(projects, otherEmp.getProjects(), where + ".projects") & + helper.deepEquals(team, otherEmp.getTeam(), where + ".team") & + helper.deepEquals(hradvisees, otherEmp.getHradvisees(), where + ".hradvisees"); + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/FullTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/FullTimeEmployee.java index 2f560c312..d6d8736ee 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/FullTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/FullTimeEmployee.java @@ -5,129 +5,125 @@ * 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 + * + * 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.jdo.tck.pc.company; import java.util.Date; -import javax.jdo.annotations.PersistenceCapable; + import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a full-time employee. */ +import javax.jdo.annotations.PersistenceCapable; + +/** + * This class represents a full-time employee. + */ @PersistenceCapable public class FullTimeEmployee extends Employee implements IFullTimeEmployee { - private double salary; - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FullTimeEmployee() {} - - /** - * Construct a full-time employee. - * - * @param personid The person identifier. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param hired The date that the person was hired. - * @param sal The salary of the full-time employee. - */ - public FullTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double sal) { - super(personid, first, last, middle, born, hired); - salary = sal; - } + private double salary; - /** - * Construct a full-time employee. - * - * @param personid The person identifier. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param addr The person's address. - * @param hired The date that the person was hired. - * @param sal The salary of the full-time employee. - */ - public FullTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - IAddress addr, - Date hired, - double sal) { - super(personid, first, last, middle, born, addr, hired); - salary = sal; - } + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FullTimeEmployee() {} - /** - * Get the salary of the full time employee. - * - * @return The salary of the full time employee. - */ - public double getSalary() { - return salary; - } + /** + * Construct a full-time employee. + * @param personid The person identifier. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param hired The date that the person was hired. + * @param sal The salary of the full-time employee. + */ + public FullTimeEmployee(long personid, String first, String last, + String middle, Date born, + Date hired, double sal) { + super(personid, first, last, middle, born, hired); + salary = sal; + } - /** - * Set the salary for the full-time employee. - * - * @param salary The salary to set for the full-time employee. - */ - public void setSalary(double salary) { - this.salary = salary; - } + /** + * Construct a full-time employee. + * @param personid The person identifier. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param addr The person's address. + * @param hired The date that the person was hired. + * @param sal The salary of the full-time employee. + */ + public FullTimeEmployee(long personid, String first, String last, + String middle, Date born, IAddress addr, + Date hired, double sal) { + super(personid, first, last, middle, born, addr, hired); + salary = sal; + } - /** - * Return a String representation of a FullTimeEmployee object. - * - * @return a String representation of a FullTimeEmployee object. - */ - public String toString() { - return "FullTimeEmployee(" + getFieldRepr() + ")"; - } + /** + * Get the salary of the full time employee. + * @return The salary of the full time employee. + */ + public double getSalary() { + return salary; + } + + /** + * Set the salary for the full-time employee. + * @param salary The salary to set for the full-time employee. + */ + public void setSalary(double salary) { + this.salary = salary; + } + + /** + * Return a String representation of a FullTimeEmployee object. + * @return a String representation of a FullTimeEmployee object. + */ + public String toString() { + return "FullTimeEmployee(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - public String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", $").append(salary); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + public String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", $").append(salary); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified FullTimeEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IFullTimeEmployee otherEmp = (IFullTimeEmployee) other; - String where = "FullTimeEmployee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.closeEnough(salary, otherEmp.getSalary(), where + ".salary"); - } + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified + * FullTimeEmployee. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IFullTimeEmployee otherEmp = (IFullTimeEmployee)other; + String where = "FullTimeEmployee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.closeEnough(salary, otherEmp.getSalary(), where + ".salary"); + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/IAddress.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/IAddress.java index 169f40eb8..250a2db1e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/IAddress.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/IAddress.java @@ -5,45 +5,36 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.company; /** - * This interface represents the persistent state of Address. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Address. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IAddress { - long getAddrid(); - - String getStreet(); - - String getCity(); - - String getState(); - - String getZipcode(); - - String getCountry(); - - void setAddrid(long addrid); - - void setStreet(String street); - - void setCity(String city); - - void setState(String state); - - void setZipcode(String zipcode); - - void setCountry(String country); + long getAddrid(); + String getStreet(); + String getCity(); + String getState(); + String getZipcode(); + String getCountry(); + + void setAddrid(long addrid); + void setStreet(String street); + void setCity(String city); + void setState(String state); + void setZipcode(String zipcode); + void setCountry(String country); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/ICompany.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/ICompany.java index 1ed722dd4..3070b6411 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/ICompany.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/ICompany.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -21,28 +21,21 @@ import java.util.Set; /** - * This interface represents the persistent state of Company. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Company. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface ICompany { - - IAddress getAddress(); - - long getCompanyid(); - - Set getDepartments(); - - Date getFounded(); - - String getName(); - - void setAddress(IAddress a); - - void setCompanyid(long id); - - void setDepartments(Set depts); - - void setFounded(Date date); - - void setName(String string); + + IAddress getAddress(); + long getCompanyid(); + Set getDepartments(); + Date getFounded(); + String getName(); + + void setAddress(IAddress a); + void setCompanyid(long id); + void setDepartments(Set depts); + void setFounded(Date date); + void setName(String string); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/IDentalInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/IDentalInsurance.java index f72edf7dd..fd4362a5c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/IDentalInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/IDentalInsurance.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -20,12 +20,12 @@ import java.math.BigDecimal; /** - * This interface represents the persistent state of DentalInsurance. Javadoc was deliberately - * omitted because it would distract from the purpose of the interface. + * This interface represents the persistent state of DentalInsurance. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IDentalInsurance extends IInsurance { - BigDecimal getLifetimeOrthoBenefit(); - - void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit); + BigDecimal getLifetimeOrthoBenefit(); + void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/IDepartment.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/IDepartment.java index 9e11aa7b0..147ad1cc0 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/IDepartment.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/IDepartment.java @@ -5,52 +5,41 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.company; import java.util.List; import java.util.Set; /** - * This interface represents the persistent state of Department. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Department. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IDepartment { - long getDeptid(); - - String getName(); - - ICompany getCompany(); - - IEmployee getEmployeeOfTheMonth(); - - Set getEmployees(); - - Set getFundedEmps(); - - List getMeetingRooms(); - - void setDeptid(long deptid); - - void setName(String name); - - void setCompany(ICompany company); - - void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth); - - void setEmployees(Set employees); - - void setFundedEmps(Set employees); - - void setMeetingRooms(List rooms); + long getDeptid(); + String getName(); + ICompany getCompany(); + IEmployee getEmployeeOfTheMonth(); + Set getEmployees(); + Set getFundedEmps(); + List getMeetingRooms(); + + void setDeptid(long deptid); + void setName(String name); + void setCompany(ICompany company); + void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth); + void setEmployees(Set employees); + void setFundedEmps(Set employees); + void setMeetingRooms(List rooms); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/IEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/IEmployee.java index 361966dd2..2cf21a954 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/IEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/IEmployee.java @@ -5,80 +5,56 @@ * 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 + * + * 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.jdo.tck.pc.company; import java.util.Date; import java.util.Set; /** - * This interface represents the persistent state of Employee. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Employee. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IEmployee extends IPerson { - Date getHiredate(); - - double getWeeklyhours(); - - Set getReviewedProjects(); - - Set getProjects(); - - IDentalInsurance getDentalInsurance(); - - IMedicalInsurance getMedicalInsurance(); - - IDepartment getDepartment(); - - IDepartment getFundingDept(); - - IEmployee getManager(); - - Set getTeam(); - - IEmployee getMentor(); - - IEmployee getProtege(); - - IEmployee getHradvisor(); - - Set getHradvisees(); - - void setHiredate(Date hiredate); - - void setWeeklyhours(double weeklyhours); - - void setReviewedProjects(Set reviewedProjects); - - void setProjects(Set projects); - - void setDentalInsurance(IDentalInsurance dentalInsurance); - - void setMedicalInsurance(IMedicalInsurance medicalInsurance); - - void setDepartment(IDepartment department); - - void setFundingDept(IDepartment department); - - void setManager(IEmployee manager); - - void setTeam(Set team); - - void setMentor(IEmployee mentor); - - void setProtege(IEmployee protege); - - void setHradvisor(IEmployee hradvisor); - - void setHradvisees(Set hradvisees); + Date getHiredate(); + double getWeeklyhours(); + Set getReviewedProjects(); + Set getProjects(); + IDentalInsurance getDentalInsurance(); + IMedicalInsurance getMedicalInsurance(); + IDepartment getDepartment(); + IDepartment getFundingDept(); + IEmployee getManager(); + Set getTeam(); + IEmployee getMentor(); + IEmployee getProtege(); + IEmployee getHradvisor(); + Set getHradvisees(); + + void setHiredate(Date hiredate); + void setWeeklyhours(double weeklyhours); + void setReviewedProjects(Set reviewedProjects); + void setProjects(Set projects); + void setDentalInsurance(IDentalInsurance dentalInsurance); + void setMedicalInsurance(IMedicalInsurance medicalInsurance); + void setDepartment(IDepartment department); + void setFundingDept(IDepartment department); + void setManager(IEmployee manager); + void setTeam(Set team); + void setMentor(IEmployee mentor); + void setProtege(IEmployee protege); + void setHradvisor(IEmployee hradvisor); + void setHradvisees(Set hradvisees); + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/IFullTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/IFullTimeEmployee.java index 606713a49..7bd768949 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/IFullTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/IFullTimeEmployee.java @@ -5,25 +5,25 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.company; /** - * This interface represents the persistent state of FullTimeEmployee. Javadoc was deliberately - * omitted because it would distract from the purpose of the interface. + * This interface represents the persistent state of FullTimeEmployee. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IFullTimeEmployee extends IEmployee { - double getSalary(); - - void setSalary(double salary); + double getSalary(); + void setSalary(double salary); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/IInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/IInsurance.java index e0d9e0397..728c4ac4b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/IInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/IInsurance.java @@ -5,33 +5,30 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.company; /** - * This interface represents the persistent state of Insurance. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Insurance. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IInsurance { - long getInsid(); - - String getCarrier(); - - IEmployee getEmployee(); - - void setInsid(long insid); - - void setCarrier(String carrier); + long getInsid(); + String getCarrier(); + IEmployee getEmployee(); - void setEmployee(IEmployee employee); + void setInsid(long insid); + void setCarrier(String carrier); + void setEmployee(IEmployee employee); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/IMedicalInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/IMedicalInsurance.java index 7db91de0b..499a17b66 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/IMedicalInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/IMedicalInsurance.java @@ -5,25 +5,25 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.company; /** - * This interface represents the persistent state of MedicalInsurance. Javadoc was deliberately - * omitted because it would distract from the purpose of the interface. + * This interface represents the persistent state of MedicalInsurance. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IMedicalInsurance extends IInsurance { - String getPlanType(); - - void setPlanType(String planType); + String getPlanType(); + void setPlanType(String planType); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/IMeetingRoom.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/IMeetingRoom.java index 589de6c80..729189309 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/IMeetingRoom.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/IMeetingRoom.java @@ -5,29 +5,28 @@ * 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 + * + * 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.jdo.tck.pc.company; /** - * This interface represents the persistent state of MeetingRoom. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of MeetingRoom. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IMeetingRoom { - long getRoomid(); + long getRoomid(); + String getName(); - String getName(); - - void setRoomid(long roomid); - - void setName(String name); -} + void setRoomid(long roomid); + void setName(String name); +} \ No newline at end of file diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/IPartTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/IPartTimeEmployee.java index 4b67287f1..ac49106dc 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/IPartTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/IPartTimeEmployee.java @@ -5,25 +5,25 @@ * 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 + * + * 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.jdo.tck.pc.company; /** - * This interface represents the persistent state of PartTimeEmployee. Javadoc was deliberately - * omitted because it would distract from the purpose of the interface. + * This interface represents the persistent state of PartTimeEmployee. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IPartTimeEmployee extends IEmployee { - double getWage(); - - void setWage(double wage); + double getWage(); + void setWage(double wage); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/IPerson.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/IPerson.java index 008808ae6..adf2bf1f1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/IPerson.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/IPerson.java @@ -5,52 +5,42 @@ * 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 + * + * 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.jdo.tck.pc.company; import java.util.Date; import java.util.Map; /** - * This interface represents the persistent state of Person. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Person. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IPerson { - long getPersonid(); - - String getLastname(); - - String getFirstname(); - - String getMiddlename(); - - IAddress getAddress(); - - Date getBirthdate(); - - Map getPhoneNumbers(); - - void setPersonid(long personid); - - void setLastname(String lastname); - - void setFirstname(String firstname); - - void setMiddlename(String middlename); - - void setAddress(IAddress address); - - void setBirthdate(Date birthdate); + long getPersonid(); + String getLastname(); + String getFirstname(); + String getMiddlename(); + IAddress getAddress(); + Date getBirthdate(); + Map getPhoneNumbers(); + + void setPersonid(long personid); + void setLastname(String lastname); + void setFirstname(String firstname); + void setMiddlename(String middlename); + void setAddress(IAddress address); + void setBirthdate(Date birthdate); + void setPhoneNumbers(Map phoneNumbers); - void setPhoneNumbers(Map phoneNumbers); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/IProject.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/IProject.java index 461dc9186..c963a7dd1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/IProject.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/IProject.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.company; @@ -20,28 +20,22 @@ import java.util.Set; /** - * This interface represents the persistent state of Project. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Project. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IProject { - long getProjid(); - - String getName(); - - BigDecimal getBudget(); - - Set getReviewers(); - - Set getMembers(); - - void setProjid(long projid); - - void setName(String name); - - void setBudget(BigDecimal budget); - - void setReviewers(Set reviewers); - - void setMembers(Set employees); + long getProjid(); + String getName(); + BigDecimal getBudget(); + Set getReviewers(); + Set getMembers(); + + void setProjid(long projid); + void setName(String name); + void setBudget(BigDecimal budget); + void setReviewers(Set reviewers); + void setMembers(Set employees); + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/Insurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/Insurance.java index 17f1eb0b3..d8691d41b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/Insurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/Insurance.java @@ -5,277 +5,282 @@ * 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 + * + * 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.jdo.tck.pc.company; import java.io.Serializable; + import java.util.Comparator; -import javax.jdo.annotations.PersistenceCapable; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents an insurance carrier selection for a particular Employee. */ +import javax.jdo.annotations.PersistenceCapable; + +/** + * This class represents an insurance carrier selection for a particular + * Employee. + */ @PersistenceCapable public abstract class Insurance - implements IInsurance, Serializable, Comparable, Comparator, DeepEquality { - - private long insid; - private String carrier; - private Employee employee; - - /** This is the JDO-required no-args constructor. */ - protected Insurance() {} - - /** - * Construct an Insurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - */ - protected Insurance(long insid, String carrier) { - this.insid = insid; - this.carrier = carrier; - } - - /** - * Construct an Insurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param employee The employee associated with this insurance. - */ - protected Insurance(long insid, String carrier, IEmployee employee) { - this.insid = insid; - this.carrier = carrier; - this.employee = (Employee) employee; - } - - /** - * Get the insurance ID. - * - * @return the insurance ID. - */ - public long getInsid() { - return insid; - } - - /** - * Set the insurance ID. - * - * @param id The insurance ID value. - */ - public void setInsid(long id) { - if (this.insid != 0) throw new IllegalStateException("Id is already set."); - this.insid = id; - } - - /** - * Get the insurance carrier. - * - * @return The insurance carrier. - */ - public String getCarrier() { - return carrier; - } - - /** - * Set the insurance carrier. - * - * @param carrier The insurance carrier. - */ - public void setCarrier(String carrier) { - this.carrier = carrier; - } - - /** - * Get the associated employee. - * - * @return The employee for this insurance. - */ - public IEmployee getEmployee() { - return employee; - } - - /** - * Set the associated employee. - * - * @param employee The associated employee. - */ - public void setEmployee(IEmployee employee) { - this.employee = (Employee) employee; - } + implements IInsurance, Serializable, Comparable, Comparator, DeepEquality { - /** - * Returns a String representation of a Insurance object. - * - * @return a String representation of a Insurance object. - */ - public String toString() { - return "Insurance(" + getFieldRepr() + ")"; - } + private long insid; + private String carrier; + private Employee employee; - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(insid); - rc.append(", carrier ").append(carrier); - return rc.toString(); - } + /** This is the JDO-required no-args constructor. */ + protected Insurance() {} - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Object. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IInsurance otherIns = (IInsurance) other; - String where = "Insurance<" + insid + ">"; - return helper.equals(insid, otherIns.getInsid(), where + ".insid") - & helper.equals(carrier, otherIns.getCarrier(), where + ".carrier") - & helper.deepEquals(employee, otherIns.getEmployee(), where + ".employee"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((IInsurance) o); - } + /** + * Construct an Insurance instance. + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + */ + protected Insurance(long insid, String carrier) { + this.insid = insid; + this.carrier = carrier; + } - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((IInsurance) o1, (IInsurance) o2); - } + /** + * Construct an Insurance instance. + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + */ + protected Insurance(long insid, String carrier, IEmployee employee) { + this.insid = insid; + this.carrier = carrier; + this.employee = (Employee)employee; + } - /** - * Compares this object with the specified Insurance object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Insurance object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Insurance object. - */ - public int compareTo(IInsurance other) { - return compare(this, other); - } + /** + * Get the insurance ID. + * @return the insurance ID. + */ + public long getInsid() { + return insid; + } - /** - * Compares its two IInsurance arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IInsurance object to be compared. - * @param o2 the second IInsurance object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(IInsurance o1, IInsurance o2) { - return EqualityHelper.compare(o1.getInsid(), o2.getInsid()); - } + /** + * Set the insurance ID. + * @param id The insurance ID value. + */ + public void setInsid(long id) { + if (this.insid != 0) + throw new IllegalStateException("Id is already set."); + this.insid = id; + } - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof IInsurance) { - return compareTo((IInsurance) obj) == 0; + /** + * Get the insurance carrier. + * @return The insurance carrier. + */ + public String getCarrier() { + return carrier; } - return false; - } - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) insid; - } + /** + * Set the insurance carrier. + * @param carrier The insurance carrier. + */ + public void setCarrier(String carrier) { + this.carrier = carrier; + } + + /** + * Get the associated employee. + * @return The employee for this insurance. + */ + public IEmployee getEmployee() { + return employee; + } - /** - * This class is used to represent the application identifier for the Insurance - * class. - */ - public static class Oid implements Serializable, Comparable { /** - * This field represents the application identifier for the Insurance class. It - * must match the field in the Insurance class in both name and type. + * Set the associated employee. + * @param employee The associated employee. */ - public long insid; + public void setEmployee(IEmployee employee) { + this.employee = (Employee)employee; + } - /** The required public no-args constructor. */ - public Oid() {} + /** + * Returns a String representation of a Insurance object. + * @return a String representation of a Insurance object. + */ + public String toString() { + return "Insurance(" + getFieldRepr() + ")"; + } /** - * Initialize with an insurance identifier. - * - * @param insid the insurance ID. + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. */ - public Oid(long insid) { - this.insid = insid; + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(insid); + rc.append(", carrier ").append(carrier); + return rc.toString(); } - public Oid(String s) { - insid = Long.parseLong(justTheId(s)); + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IInsurance otherIns = (IInsurance)other; + String where = "Insurance<" + insid + ">"; + return + helper.equals(insid, otherIns.getInsid(), where + ".insid") & + helper.equals(carrier, otherIns.getCarrier(), where + ".carrier") & + helper.deepEquals(employee, otherIns.getEmployee(), where + ".employee"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((IInsurance)o); } - public String toString() { - return this.getClass().getName() + ": " + insid; + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((IInsurance)o1, (IInsurance)o2); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.insid != o.insid) return (false); - return (true); + /** + * Compares this object with the specified Insurance object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Insurance object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified + * Insurance object. + */ + public int compareTo(IInsurance other) { + return compare(this, other); } - /** */ + /** + * Compares its two IInsurance arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IInsurance object to be compared. + * @param o2 the second IInsurance object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(IInsurance o1, IInsurance o2) { + return EqualityHelper.compare(o1.getInsid(), o2.getInsid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof IInsurance) { + return compareTo((IInsurance)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ public int hashCode() { - return ((int) insid); + return (int)insid; } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } + /** + * This class is used to represent the application + * identifier for the Insurance class. + */ + public static class Oid implements Serializable, Comparable + { + /** + * This field represents the application identifier for the + * Insurance class. It must match the field in the + * Insurance class in both name and type. + */ + public long insid; + + /** + * The required public no-args constructor. + */ + public Oid() { } + + /** + * Initialize with an insurance identifier. + * @param insid the insurance ID. + */ + public Oid(long insid) { + this.insid = insid; + } + + public Oid(String s) { insid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + insid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o=(Oid) obj; + if( this.insid!=o.insid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) insid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( insid < other.insid ) return -1; + if( insid > other.insid ) return 1; + return 0; + } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (insid < other.insid) return -1; - if (insid > other.insid) return 1; - return 0; } - } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/MedicalInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/MedicalInsurance.java index f472e23aa..3d7561fcf 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/MedicalInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/MedicalInsurance.java @@ -5,114 +5,120 @@ * 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 + * + * 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.jdo.tck.pc.company; -import javax.jdo.annotations.PersistenceCapable; +import java.io.Serializable; + +import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; +import javax.jdo.annotations.PersistenceCapable; + /** - * This class represents a dental insurance carrier selection for a particular Employee - * . + * This class represents a dental insurance carrier selection for a + * particular Employee. */ @PersistenceCapable public class MedicalInsurance extends Insurance implements IMedicalInsurance { - private String planType; // possible values: "PPO", "EPO", "NPO" + private String planType; // possible values: "PPO", "EPO", "NPO" - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public MedicalInsurance() {} + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public MedicalInsurance() {} - /** - * Construct a MedicalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param planType The planType. - */ - public MedicalInsurance(long insid, String carrier, String planType) { - super(insid, carrier); - this.planType = planType; - } + /** + * Construct a MedicalInsurance instance. + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param planType The planType. + */ + public MedicalInsurance(long insid, String carrier, + String planType) + { + super(insid, carrier); + this.planType = planType; + } - /** - * Construct a MedicalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param employee The employee associated with this insurance. - * @param planType The planType. - */ - public MedicalInsurance(long insid, String carrier, IEmployee employee, String planType) { - super(insid, carrier, employee); - this.planType = planType; - } + /** + * Construct a MedicalInsurance instance. + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + * @param planType The planType. + */ + public MedicalInsurance(long insid, String carrier, + IEmployee employee, String planType) + { + super(insid, carrier, employee); + this.planType = planType; + } - /** - * Get the insurance planType. - * - * @return The insurance planType. - */ - public String getPlanType() { - return planType; - } + /** + * Get the insurance planType. + * @return The insurance planType. + */ + public String getPlanType() { + return planType; + } - /** - * Set the insurance planType. - * - * @param planType The insurance planType. - */ - public void setPlanType(String planType) { - this.planType = planType; - } + /** + * Set the insurance planType. + * @param planType The insurance planType. + */ + public void setPlanType(String planType) { + this.planType = planType; + } - /** - * Returns a String representation of a MedicalInsurance object. - * - * @return a String representation of a MedicalInsurance object. - */ - public String toString() { - return "MedicalInsurance(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of a MedicalInsurance + * object. + * @return a String representation of a MedicalInsurance + * object. + */ + public String toString() { + return "MedicalInsurance(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", planType ").append(planType); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", planType ").append(planType); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Object. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IMedicalInsurance otherIns = (IMedicalInsurance) other; - String where = "MedicalInsurance<" + getInsid() + ">"; - return super.deepCompareFields(otherIns, helper) - & helper.equals(planType, otherIns.getPlanType(), where + ".planType"); - } + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IMedicalInsurance otherIns = (IMedicalInsurance)other; + String where = "MedicalInsurance<" + getInsid() + ">"; + return super.deepCompareFields(otherIns, helper) & + helper.equals(planType, otherIns.getPlanType(), where + ".planType"); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/MeetingRoom.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/MeetingRoom.java index 560f003f1..1af285213 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/MeetingRoom.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/MeetingRoom.java @@ -5,250 +5,251 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.company; import java.io.Serializable; import java.util.Comparator; -import javax.jdo.annotations.PersistenceCapable; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a meeting room. */ +import javax.jdo.annotations.PersistenceCapable; + +/** + * This class represents a meeting room. + */ @PersistenceCapable public class MeetingRoom implements IMeetingRoom, Serializable, Comparable, Comparator, DeepEquality { - private long roomid; - private String name; - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public MeetingRoom() {} - - /** - * This constructor initializes the MeetingRoom components. - * - * @param roomid The room ID. - * @param name The name of the room - */ - public MeetingRoom(long roomid, String name) { - this.roomid = roomid; - this.name = name; - } - - /** - * Get the room id associated with this object. - * - * @return the room id. - */ - public long getRoomid() { - return roomid; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setRoomid(long id) { - if (this.roomid != 0) throw new IllegalStateException("Id is already set."); - this.roomid = id; - } - - /** - * Get the name of the meeting room. - * - * @return The name of the meeting room. - */ - public String getName() { - return name; - } - - /** - * Set the name of the meeting room. - * - * @param name The name. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Returns a String representation of a Address object. - * - * @return a String representation of a MeetingRoom object. - */ - public String toString() { - return "MeetingRoom(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(roomid); - rc.append(", name ").append(name); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IMeetingRoom otherMeetingRoom = (IMeetingRoom) other; - String where = "MeetingRoom<" + roomid + ">"; - return helper.equals(roomid, otherMeetingRoom.getRoomid(), where + ".roomid") - & helper.equals(name, otherMeetingRoom.getName(), where + ".name"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((IMeetingRoom) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((IMeetingRoom) o1, (IMeetingRoom) o2); - } - - /** - * Compares this object with the specified MeetingRoom object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The MeetingRoom object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified MeetingRoom object. - */ - public int compareTo(IMeetingRoom other) { - return compare(this, other); - } - - /** - * Compares its two IMeetingRoom arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IMeetingRoom object to be compared. - * @param o2 the second IMeetingRoom object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(IMeetingRoom o1, IMeetingRoom o2) { - return EqualityHelper.compare(o1.getRoomid(), o2.getRoomid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof IMeetingRoom) { - return compareTo((IMeetingRoom) obj) == 0; - } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) roomid; - } - - /** - * This class is used to represent the application identifier for the MeetingRoom - * class. - */ - public static class Oid implements Serializable, Comparable { + private long roomid; + private String name; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public MeetingRoom() {} /** - * This is the identifier field for MeetingRoom and must correspond in type and - * name to the field in MeetingRoom. + * This constructor initializes the MeetingRoom components. + * @param roomid The room ID. + * @param name The name of the room */ - public long roomid; + public MeetingRoom(long roomid, String name) + { + this.roomid = roomid; + this.name = name; + } - /** The required public, no-arg constructor. */ - public Oid() { - roomid = 0; + /** + * Get the room id associated with this object. + * @return the room id. + */ + public long getRoomid() { + return roomid; } /** - * A constructor to initialize the identifier field. - * - * @param roomid the id of the MeetingRoom. + * Set the id associated with this object. + * @param id the id. + */ + public void setRoomid(long id) { + if (this.roomid != 0) + throw new IllegalStateException("Id is already set."); + this.roomid = id; + } + + /** + * Get the name of the meeting room. + * @return The name of the meeting room. */ - public Oid(long roomid) { - this.roomid = roomid; + public String getName() { + return name; } - public Oid(String s) { - roomid = Long.parseLong(justTheId(s)); + /** + * Set the name of the meeting room. + * @param name The name. + */ + public void setName(String name) { + this.name = name; } + /** + * Returns a String representation of a Address object. + * @return a String representation of a MeetingRoom object. + */ public String toString() { - return this.getClass().getName() + ": " + roomid; + return "MeetingRoom(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(roomid); + rc.append(", name ").append(name); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IMeetingRoom otherMeetingRoom = (IMeetingRoom)other; + String where = "MeetingRoom<" + roomid + ">"; + return + helper.equals(roomid, otherMeetingRoom.getRoomid(), where + ".roomid") & + helper.equals(name, otherMeetingRoom.getName(), where + ".name"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((IMeetingRoom)o); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.roomid != o.roomid) return (false); - return (true); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((IMeetingRoom)o1, (IMeetingRoom)o2); } - /** */ - public int hashCode() { - return ((int) roomid); + /** + * Compares this object with the specified MeetingRoom object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The MeetingRoom object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified MeetingRoom + * object. + */ + public int compareTo(IMeetingRoom other) { + return compare(this, other); + } + + /** + * Compares its two IMeetingRoom arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IMeetingRoom object to be compared. + * @param o2 the second IMeetingRoom object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(IMeetingRoom o1, IMeetingRoom o2) { + return EqualityHelper.compare(o1.getRoomid(), o2.getRoomid()); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof IMeetingRoom) { + return compareTo((IMeetingRoom)obj) == 0; + } + return false; } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (roomid < other.roomid) return -1; - if (roomid > other.roomid) return 1; - return 0; + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)roomid; + } + + /** + * This class is used to represent the application identifier + * for the MeetingRoom class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This is the identifier field for MeetingRoom and must + * correspond in type and name to the field in + * MeetingRoom. + */ + public long roomid; + + /** The required public, no-arg constructor. */ + public Oid() + { + roomid = 0; + } + + /** + * A constructor to initialize the identifier field. + * @param roomid the id of the MeetingRoom. + */ + public Oid(long roomid) { + this.roomid = roomid; + } + + public Oid(String s) { roomid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + roomid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.roomid != o.roomid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) roomid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( roomid < other.roomid ) return -1; + if( roomid > other.roomid ) return 1; + return 0; + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIAddress.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIAddress.java index b457b352d..acac6beb0 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIAddress.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIAddress.java @@ -5,45 +5,36 @@ * 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 + * + * 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.jdo.tck.pc.company; /** - * This interface represents the persistent state of Address. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Address. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface PIAddress extends IAddress { - long getAddrid(); - - String getStreet(); - - String getCity(); - - String getState(); - - String getZipcode(); - - String getCountry(); - - void setAddrid(long addrid); - - void setStreet(String street); - - void setCity(String city); - - void setState(String state); - - void setZipcode(String zipcode); - - void setCountry(String country); + long getAddrid(); + String getStreet(); + String getCity(); + String getState(); + String getZipcode(); + String getCountry(); + + void setAddrid(long addrid); + void setStreet(String street); + void setCity(String city); + void setState(String state); + void setZipcode(String zipcode); + void setCountry(String country); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/PICompany.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/PICompany.java index a8224d8fe..6c982f0bf 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/PICompany.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/PICompany.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -21,29 +21,22 @@ import java.util.Set; /** - * This interface represents the persistent state of Company. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Company. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface PICompany extends ICompany { - - // temporary for test. No methods should be here - IAddress getAddress(); - - long getCompanyid(); - - Set getDepartments(); - - Date getFounded(); - - String getName(); - - void setAddress(IAddress a); - - void setCompanyid(long id); - - void setDepartments(Set depts); - - void setFounded(Date date); - - void setName(String string); + + //temporary for test. No methods should be here + IAddress getAddress(); + long getCompanyid(); + Set getDepartments(); + Date getFounded(); + String getName(); + + void setAddress(IAddress a); + void setCompanyid(long id); + void setDepartments(Set depts); + void setFounded(Date date); + void setName(String string); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIDentalInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIDentalInsurance.java index 6164c5ea4..9caf82f9d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIDentalInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIDentalInsurance.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -20,12 +20,12 @@ import java.math.BigDecimal; /** - * This interface represents the persistent state of DentalInsurance. Javadoc was deliberately - * omitted because it would distract from the purpose of the interface. + * This interface represents the persistent state of DentalInsurance. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface PIDentalInsurance extends PIInsurance, IDentalInsurance { - BigDecimal getLifetimeOrthoBenefit(); - - void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit); + BigDecimal getLifetimeOrthoBenefit(); + void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIDepartment.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIDepartment.java index e5e71a56e..e2f158f2c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIDepartment.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIDepartment.java @@ -5,47 +5,39 @@ * 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 + * + * 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.jdo.tck.pc.company; import java.util.Set; /** - * This interface represents the persistent state of Department. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Department. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface PIDepartment extends IDepartment { - long getDeptid(); - - String getName(); - - ICompany getCompany(); - - IEmployee getEmployeeOfTheMonth(); - - Set getEmployees(); - - Set getFundedEmps(); - - void setDeptid(long deptid); - - void setName(String name); - - void setCompany(ICompany company); - - void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth); - - void setEmployees(Set employees); + long getDeptid(); + String getName(); + ICompany getCompany(); + IEmployee getEmployeeOfTheMonth(); + Set getEmployees(); + Set getFundedEmps(); + + void setDeptid(long deptid); + void setName(String name); + void setCompany(ICompany company); + void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth); + void setEmployees(Set employees); + void setFundedEmps(Set employees); - void setFundedEmps(Set employees); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIEmployee.java index 8b6ad3524..165df2668 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIEmployee.java @@ -5,80 +5,56 @@ * 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 + * + * 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.jdo.tck.pc.company; import java.util.Date; import java.util.Set; /** - * This interface represents the persistent state of Employee. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Employee. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface PIEmployee extends PIPerson, IEmployee { - Date getHiredate(); - - double getWeeklyhours(); - - Set getReviewedProjects(); - - Set getProjects(); - - IDentalInsurance getDentalInsurance(); - - IMedicalInsurance getMedicalInsurance(); - - IDepartment getDepartment(); - - IDepartment getFundingDept(); - - IEmployee getManager(); - - Set getTeam(); - - IEmployee getMentor(); - - IEmployee getProtege(); - - IEmployee getHradvisor(); - - Set getHradvisees(); - - void setHiredate(Date hiredate); - - void setWeeklyhours(double weeklyhours); - - void setReviewedProjects(Set reviewedProjects); - - void setProjects(Set projects); - - void setDentalInsurance(IDentalInsurance dentalInsurance); - - void setMedicalInsurance(IMedicalInsurance medicalInsurance); - - void setDepartment(IDepartment department); - - void setFundingDept(IDepartment department); - - void setManager(IEmployee manager); - - void setTeam(Set team); - - void setMentor(IEmployee mentor); - - void setProtege(IEmployee protege); - - void setHradvisor(IEmployee hradvisor); - - void setHradvisees(Set hradvisees); + Date getHiredate(); + double getWeeklyhours(); + Set getReviewedProjects(); + Set getProjects(); + IDentalInsurance getDentalInsurance(); + IMedicalInsurance getMedicalInsurance(); + IDepartment getDepartment(); + IDepartment getFundingDept(); + IEmployee getManager(); + Set getTeam(); + IEmployee getMentor(); + IEmployee getProtege(); + IEmployee getHradvisor(); + Set getHradvisees(); + + void setHiredate(Date hiredate); + void setWeeklyhours(double weeklyhours); + void setReviewedProjects(Set reviewedProjects); + void setProjects(Set projects); + void setDentalInsurance(IDentalInsurance dentalInsurance); + void setMedicalInsurance(IMedicalInsurance medicalInsurance); + void setDepartment(IDepartment department); + void setFundingDept(IDepartment department); + void setManager(IEmployee manager); + void setTeam(Set team); + void setMentor(IEmployee mentor); + void setProtege(IEmployee protege); + void setHradvisor(IEmployee hradvisor); + void setHradvisees(Set hradvisees); + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIFullTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIFullTimeEmployee.java index edb67abc9..48f85ef1c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIFullTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIFullTimeEmployee.java @@ -5,25 +5,25 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.company; /** - * This interface represents the persistent state of FullTimeEmployee. Javadoc was deliberately - * omitted because it would distract from the purpose of the interface. + * This interface represents the persistent state of FullTimeEmployee. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface PIFullTimeEmployee extends PIEmployee, IFullTimeEmployee { - double getSalary(); - - void setSalary(double salary); + double getSalary(); + void setSalary(double salary); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIInsurance.java index d8467d35c..c6b7d58e8 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIInsurance.java @@ -5,33 +5,30 @@ * 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 + * + * 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.jdo.tck.pc.company; /** - * This interface represents the persistent state of Insurance. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Insurance. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface PIInsurance extends IInsurance { - long getInsid(); - - String getCarrier(); - - IEmployee getEmployee(); - - void setInsid(long insid); - - void setCarrier(String carrier); + long getInsid(); + String getCarrier(); + IEmployee getEmployee(); - void setEmployee(IEmployee employee); + void setInsid(long insid); + void setCarrier(String carrier); + void setEmployee(IEmployee employee); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIMedicalInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIMedicalInsurance.java index bd929cc6b..2dce4672d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIMedicalInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIMedicalInsurance.java @@ -5,25 +5,25 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.company; /** - * This interface represents the persistent state of MedicalInsurance. Javadoc was deliberately - * omitted because it would distract from the purpose of the interface. + * This interface represents the persistent state of MedicalInsurance. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface PIMedicalInsurance extends PIInsurance, IMedicalInsurance { - String getPlanType(); - - void setPlanType(String planType); + String getPlanType(); + void setPlanType(String planType); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIMeetingRoom.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIMeetingRoom.java index b2998e271..27146b1e3 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIMeetingRoom.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIMeetingRoom.java @@ -5,29 +5,28 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.company; /** - * This interface represents the persistent state of MeetingRoom. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of MeetingRoom. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface PIMeetingRoom extends IMeetingRoom { - long getRoomid(); - - String getName(); - - void setRoomid(long roomid); - - void setName(String name); + long getRoomid(); + String getName(); + + void setRoomid(long roomid); + void setName(String name); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIPartTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIPartTimeEmployee.java index 7d5b132fb..bf0dfe7bd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIPartTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIPartTimeEmployee.java @@ -5,25 +5,25 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.company; /** - * This interface represents the persistent state of PartTimeEmployee. Javadoc was deliberately - * omitted because it would distract from the purpose of the interface. + * This interface represents the persistent state of PartTimeEmployee. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface PIPartTimeEmployee extends PIEmployee, IPartTimeEmployee { - double getWage(); - - void setWage(double wage); + double getWage(); + void setWage(double wage); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIPerson.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIPerson.java index 805c4c8c5..99083ad24 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIPerson.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIPerson.java @@ -5,52 +5,42 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.company; import java.util.Date; import java.util.Map; /** - * This interface represents the persistent state of Person. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Person. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface PIPerson extends IPerson { - long getPersonid(); - - String getLastname(); - - String getFirstname(); - - String getMiddlename(); - - IAddress getAddress(); - - Date getBirthdate(); - - Map getPhoneNumbers(); - - void setPersonid(long personid); - - void setLastname(String lastname); - - void setFirstname(String firstname); - - void setMiddlename(String middlename); - - void setAddress(IAddress address); - - void setBirthdate(Date birthdate); + long getPersonid(); + String getLastname(); + String getFirstname(); + String getMiddlename(); + IAddress getAddress(); + Date getBirthdate(); + Map getPhoneNumbers(); + + void setPersonid(long personid); + void setLastname(String lastname); + void setFirstname(String firstname); + void setMiddlename(String middlename); + void setAddress(IAddress address); + void setBirthdate(Date birthdate); + void setPhoneNumbers(Map phoneNumbers); - void setPhoneNumbers(Map phoneNumbers); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIProject.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIProject.java index 185048bfe..1571e0ebb 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/PIProject.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/PIProject.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.company; @@ -20,28 +20,22 @@ import java.util.Set; /** - * This interface represents the persistent state of Project. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Project. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface PIProject extends IProject { - long getProjid(); - - String getName(); - - BigDecimal getBudget(); - - Set getReviewers(); - - Set getMembers(); - - void setProjid(long projid); - - void setName(String name); - - void setBudget(BigDecimal budget); - - void setReviewers(Set reviewers); - - void setMembers(Set employees); + long getProjid(); + String getName(); + BigDecimal getBudget(); + Set getReviewers(); + Set getMembers(); + + void setProjid(long projid); + void setName(String name); + void setBudget(BigDecimal budget); + void setReviewers(Set reviewers); + void setMembers(Set employees); + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/PartTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/PartTimeEmployee.java index 69f23096c..001051499 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/PartTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/PartTimeEmployee.java @@ -5,126 +5,121 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.company; import java.util.Date; + +import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a part-time employee. */ +/** + * This class represents a part-time employee. + */ public class PartTimeEmployee extends Employee implements IPartTimeEmployee { - private double wage; + private double wage; - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public PartTimeEmployee() {} + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PartTimeEmployee() {} - /** - * Construct a part-time employee. - * - * @param personid The identifier for the person. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param hired The date the person was hired. - * @param wage The person's wage. - */ - public PartTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double wage) { - super(personid, first, last, middle, born, hired); - this.wage = wage; - } + /** + * Construct a part-time employee. + * @param personid The identifier for the person. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param hired The date the person was hired. + * @param wage The person's wage. + */ + public PartTimeEmployee(long personid, String first, String last, + String middle, Date born, + Date hired, double wage ) { + super(personid, first, last, middle, born, hired); + this.wage = wage; + } - /** - * Construct a part-time employee. - * - * @param personid The identifier for the person. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param addr The person's address. - * @param hired The date the person was hired. - * @param wage The person's wage. - */ - public PartTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - IAddress addr, - Date hired, - double wage) { - super(personid, first, last, middle, born, addr, hired); - this.wage = wage; - } + /** + * Construct a part-time employee. + * @param personid The identifier for the person. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param addr The person's address. + * @param hired The date the person was hired. + * @param wage The person's wage. + */ + public PartTimeEmployee(long personid, String first, String last, + String middle, Date born, IAddress addr, + Date hired, double wage ) { + super(personid, first, last, middle, born, addr, hired); + this.wage = wage; + } - /** - * Get the wage of the part-time employee. - * - * @return The wage of the part-time employee. - */ - public double getWage() { - return wage; - } + /** + * Get the wage of the part-time employee. + * @return The wage of the part-time employee. + */ + public double getWage() { + return wage; + } - /** - * Set the wage of the part-time employee. - * - * @param wage The wage of the part-time employee. - */ - public void setWage(double wage) { - this.wage = wage; - } + /** + * Set the wage of the part-time employee. + * @param wage The wage of the part-time employee. + */ + public void setWage(double wage) { + this.wage = wage; + } - /** - * Returns a String representation of a PartTimeEmployee object. - * - * @return a String representation of a PartTimeEmployee object. - */ - public String toString() { - return "PartTimeEmployee(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of a PartTimeEmployee object. + * @return a String representation of a PartTimeEmployee object. + */ + public String toString() { + return "PartTimeEmployee(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - public String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", $" + wage); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + public String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", $" + wage); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified PartTimeEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IPartTimeEmployee otherEmp = (IPartTimeEmployee) other; - String where = "PartTimeEmployee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.closeEnough(wage, otherEmp.getWage(), where + ".wage"); - } + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified + * PartTimeEmployee. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IPartTimeEmployee otherEmp = (IPartTimeEmployee)other; + String where = "PartTimeEmployee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.closeEnough(wage, otherEmp.getWage(), where + ".wage"); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/Person.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/Person.java index c1b2f3895..45ae75415 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/Person.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/Person.java @@ -5,429 +5,420 @@ * 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 + * + * 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.jdo.tck.pc.company; import java.io.Serializable; + import java.text.SimpleDateFormat; + import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.Map; -import javax.jdo.annotations.PersistenceCapable; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a person. */ +import javax.jdo.annotations.PersistenceCapable; + +/** + * This class represents a person. + */ @PersistenceCapable -public class Person implements IPerson, Serializable, Comparable, Comparator, DeepEquality { - - private long personid; - private String firstname; - private String lastname; - private String middlename; - private Date birthdate; - private Address address; - - // maps phone number types ("home", "work", "mobile", etc.) - // to phone numbers specified as String - private Map phoneNumbers = new HashMap(); - - protected static SimpleDateFormat formatter = new SimpleDateFormat("d/MMM/yyyy"); - - /** This is the JDO-required no-args constructor. */ - protected Person() {} - - /** - * Construct a Person instance. - * - * @param personid The person identifier. - * @param firstname The person's first name. - * @param lastname The person's last name. - * @param middlename The person's middle name. - * @param birthdate The person's birthdate. - */ - public Person( - long personid, String firstname, String lastname, String middlename, Date birthdate) { - this.personid = personid; - this.firstname = firstname; - this.lastname = lastname; - this.middlename = middlename; - this.birthdate = birthdate; - } - - /** - * Construct a Person instance. - * - * @param personid The person identifier. - * @param firstname The person's first name. - * @param lastname The person's last name. - * @param middlename The person's middle name. - * @param birthdate The person's birthdate. - * @param address The person's address. - */ - public Person( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - IAddress address) { - this(personid, firstname, lastname, middlename, birthdate); - this.address = (Address) address; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setPersonid(long id) { - if (this.personid != 0) throw new IllegalStateException("Id is already set."); - this.personid = id; - } - - /** - * Get the person's id. - * - * @return The personid. - */ - public long getPersonid() { - return personid; - } - - /** - * Set the person's id. - * - * @param personid The personid. - */ - public void setLastname(long personid) { - this.personid = personid; - } - - /** - * Get the person's last name. - * - * @return The last name. - */ - public String getLastname() { - return lastname; - } - - /** - * Set the person's last name. - * - * @param lastname The last name. - */ - public void setLastname(String lastname) { - this.lastname = lastname; - } - - /** - * Get the person's first name. - * - * @return The first name. - */ - public String getFirstname() { - return firstname; - } - - /** - * Set the person's first name. - * - * @param firstname The first name. - */ - public void setFirstname(String firstname) { - this.firstname = firstname; - } - - /** - * Get the person's middle name. - * - * @return The middle name. - */ - public String getMiddlename() { - return middlename; - } - - /** - * Set the person's middle name. - * - * @param middlename The middle name. - */ - public void setMiddlename(String middlename) { - this.middlename = middlename; - } - - /** - * Get the address. - * - * @return The address. - */ - public IAddress getAddress() { - return address; - } - - /** - * Set the address. - * - * @param address The address. - */ - public void setAddress(IAddress address) { - this.address = (Address) address; - } - - /** - * Get the person's birthdate. - * - * @return The person's birthdate. - */ - public Date getBirthdate() { - return birthdate; - } - - /** - * Set the person's birthdate. - * - * @param birthdate The person's birthdate. - */ - public void setBirthdate(Date birthdate) { - this.birthdate = birthdate; - } - - /** - * Get the map of phone numbers as an unmodifiable map. - * - * @return The map of phone numbers, as an unmodifiable map. - */ - public Map getPhoneNumbers() { - return Collections.unmodifiableMap(phoneNumbers); - } - - /** - * Get the phone number for the specified phone number type. - * - * @param type The phone number type ("home", "work", "mobile", etc.). - * @return The phone number associated with specified type, or null if there was no - * phone number for the type. - */ - public String getPhoneNumber(String type) { - return (String) phoneNumbers.get(type); - } - - /** - * Associates the specified phone number with the specified type in the map of phone numbers of - * this person. - * - * @param type The phone number type ("home", "work", "mobile", etc.). - * @param phoneNumber The phone number - * @return The previous phone number associated with specified type, or null if there - * was no phone number for the type. - */ - public String putPhoneNumber(String type, String phoneNumber) { - return (String) phoneNumbers.put(type, phoneNumber); - } - - /** - * Remove a phoneNumber from the map of phone numbers. - * - * @param type The phone number type ("home", "work", "mobile", etc.). - * @return The previous phone number associated with specified type, or null if there - * was no phone number for the type. - */ - public String removePhoneNumber(String type) { - return (String) phoneNumbers.remove(type); - } - - /** - * Set the phoneNumber map to be in this person. - * - * @param phoneNumbers The map of phoneNumbers for this person. - */ - public void setPhoneNumbers(Map phoneNumbers) { - // workaround: create a new HashMap, because fostore does not - // support LinkedHashMap - this.phoneNumbers = (phoneNumbers != null) ? new HashMap(phoneNumbers) : null; - } - - /** - * Returns a String representation of a Person object. - * - * @return a string representation of a Person object. - */ - public String toString() { - return "Person(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(personid); - rc.append(", ").append(lastname); - rc.append(", ").append(firstname); - rc.append(", born ").append(birthdate == null ? "null" : formatter.format(birthdate)); - rc.append(", phone ").append(phoneNumbers); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IPerson otherPerson = (IPerson) other; - String where = "Person<" + personid + ">"; - return helper.equals(personid, otherPerson.getPersonid(), where + ".personid") - & helper.equals(firstname, otherPerson.getFirstname(), where + ".firstname") - & helper.equals(lastname, otherPerson.getLastname(), where + ".lastname") - & helper.equals(middlename, otherPerson.getMiddlename(), where + ".middlename") - & helper.equals(birthdate, otherPerson.getBirthdate(), where + ".birthdate") - & helper.deepEquals(address, otherPerson.getAddress(), where + ".address") - & helper.deepEquals(phoneNumbers, otherPerson.getPhoneNumbers(), where + ".phoneNumbers"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((IPerson) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((IPerson) o1, (IPerson) o2); - } - - /** - * Compares this object with the specified Person object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Person object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Person object. - */ - public int compareTo(IPerson other) { - return compare(this, other); - } - - /** - * Compares its two IPerson arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IPerson object to be compared. - * @param o2 the second IPerson object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(IPerson o1, IPerson o2) { - return EqualityHelper.compare(o1.getPersonid(), o2.getPersonid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof IPerson) { - return compareTo((IPerson) obj) == 0; +public class Person + implements IPerson, Serializable, Comparable, Comparator, DeepEquality { + + private long personid; + private String firstname; + private String lastname; + private String middlename; + private Date birthdate; + private Address address; + + // maps phone number types ("home", "work", "mobile", etc.) + // to phone numbers specified as String + private Map phoneNumbers = new HashMap(); + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. */ + protected Person() {} + + /** + * Construct a Person instance. + * @param personid The person identifier. + * @param firstname The person's first name. + * @param lastname The person's last name. + * @param middlename The person's middle name. + * @param birthdate The person's birthdate. + */ + public Person(long personid, String firstname, String lastname, + String middlename, Date birthdate) { + this.personid = personid; + this.firstname = firstname; + this.lastname = lastname; + this.middlename = middlename; + this.birthdate = birthdate; + } + + /** + * Construct a Person instance. + * @param personid The person identifier. + * @param firstname The person's first name. + * @param lastname The person's last name. + * @param middlename The person's middle name. + * @param birthdate The person's birthdate. + * @param address The person's address. + */ + public Person(long personid, String firstname, String lastname, + String middlename, Date birthdate, IAddress address) { + this(personid, firstname, lastname, middlename, birthdate); + this.address = (Address)address; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) personid; - } - /** - * This class is used to represent the application identifier for the Person class. - */ - public static class Oid implements Serializable, Comparable { /** - * This field represents the identifier for the Person class. It must match a field - * in the Person class in both name and type. + * Set the id associated with this object. + * @param id the id. */ - public long personid; + public void setPersonid(long id) { + if (this.personid != 0) + throw new IllegalStateException("Id is already set."); + this.personid = id; + } - /** The required public no-arg constructor. */ - public Oid() {} + /** + * Get the person's id. + * @return The personid. + */ + public long getPersonid() { + return personid; + } /** - * Initialize the identifier. - * - * @param personid The person identifier. + * Set the person's id. + * @param personid The personid. + */ + public void setLastname(long personid) { + this.personid = personid; + } + + /** + * Get the person's last name. + * @return The last name. + */ + public String getLastname() { + return lastname; + } + + /** + * Set the person's last name. + * @param lastname The last name. + */ + public void setLastname(String lastname) { + this.lastname = lastname; + } + + /** + * Get the person's first name. + * @return The first name. + */ + public String getFirstname() { + return firstname; + } + + /** + * Set the person's first name. + * @param firstname The first name. + */ + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + /** + * Get the person's middle name. + * @return The middle name. */ - public Oid(long personid) { - this.personid = personid; + public String getMiddlename() { + return middlename; } - public Oid(String s) { - personid = Long.parseLong(justTheId(s)); + /** + * Set the person's middle name. + * @param middlename The middle name. + */ + public void setMiddlename(String middlename) { + this.middlename = middlename; } + /** + * Get the address. + * @return The address. + */ + public IAddress getAddress() { + return address; + } + + /** + * Set the address. + * @param address The address. + */ + public void setAddress(IAddress address) { + this.address = (Address)address; + } + + /** + * Get the person's birthdate. + * @return The person's birthdate. + */ + public Date getBirthdate() { + return birthdate; + } + + /** + * Set the person's birthdate. + * @param birthdate The person's birthdate. + */ + public void setBirthdate(Date birthdate) { + this. birthdate = birthdate; + } + + /** + * Get the map of phone numbers as an unmodifiable map. + * @return The map of phone numbers, as an unmodifiable map. + */ + public Map getPhoneNumbers() { + return Collections.unmodifiableMap(phoneNumbers); + } + + /** + * Get the phone number for the specified phone number type. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String getPhoneNumber(String type) { + return (String)phoneNumbers.get(type); + } + + /** + * Associates the specified phone number with the specified type in the + * map of phone numbers of this person. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @param phoneNumber The phone number + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String putPhoneNumber(String type, String phoneNumber) { + return (String)phoneNumbers.put(type, phoneNumber); + } + + /** + * Remove a phoneNumber from the map of phone numbers. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String removePhoneNumber(String type) { + return (String)phoneNumbers.remove(type); + } + + /** + * Set the phoneNumber map to be in this person. + * @param phoneNumbers The map of phoneNumbers for this person. + */ + public void setPhoneNumbers(Map phoneNumbers) { + // workaround: create a new HashMap, because fostore does not + // support LinkedHashMap + this.phoneNumbers = + (phoneNumbers != null) ? new HashMap(phoneNumbers) : null; + } + + /** + * Returns a String representation of a Person object. + * @return a string representation of a Person object. + */ public String toString() { - return this.getClass().getName() + ": " + personid; + return "Person(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(personid); + rc.append(", ").append(lastname); + rc.append(", ").append(firstname); + rc.append(", born ").append( + birthdate==null ? "null" : formatter.format(birthdate)); + rc.append(", phone ").append(phoneNumbers); + return rc.toString(); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.personid != o.personid) return (false); - return (true); + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IPerson otherPerson = (IPerson)other; + String where = "Person<" + personid + ">"; + return + helper.equals(personid, otherPerson.getPersonid(), where + ".personid") & + helper.equals(firstname, otherPerson.getFirstname(), where + ".firstname") & + helper.equals(lastname, otherPerson.getLastname(), where + ".lastname") & + helper.equals(middlename, otherPerson.getMiddlename(), where + ".middlename") & + helper.equals(birthdate, otherPerson.getBirthdate(), where + ".birthdate") & + helper.deepEquals(address, otherPerson.getAddress(), where + ".address") & + helper.deepEquals(phoneNumbers, otherPerson.getPhoneNumbers(), where + ".phoneNumbers"); } - /** */ - public int hashCode() { - return ((int) personid); + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((IPerson)o); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((IPerson)o1, (IPerson)o2); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (personid < other.personid) return -1; - if (personid > other.personid) return 1; - return 0; + /** + * Compares this object with the specified Person object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Person object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Person + * object. + */ + public int compareTo(IPerson other) { + return compare(this, other); } - } + + /** + * Compares its two IPerson arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IPerson object to be compared. + * @param o2 the second IPerson object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(IPerson o1, IPerson o2) { + return EqualityHelper.compare(o1.getPersonid(), o2.getPersonid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof IPerson) { + return compareTo((IPerson)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)personid; + } + /** + * This class is used to represent the application identifier + * for the Person class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the identifier for the Person + * class. It must match a field in the Person class in + * both name and type. + */ + public long personid; + + /** + * The required public no-arg constructor. + */ + public Oid() { } + + /** + * Initialize the identifier. + * @param personid The person identifier. + */ + public Oid(long personid) { + this.personid = personid; + } + + public Oid(String s) { personid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + personid;} + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || + !this.getClass().equals(obj.getClass()) ) return( false ); + Oid o = (Oid) obj; + if( this.personid != o.personid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) personid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( personid < other.personid ) return -1; + if( personid > other.personid ) return 1; + return 0; + } + + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/company/Project.java b/tck/src/main/java/org/apache/jdo/tck/pc/company/Project.java index e362423f3..75f335476 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/company/Project.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/company/Project.java @@ -5,365 +5,366 @@ * 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 + * + * 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.jdo.tck.pc.company; -import java.io.IOException; -import java.io.ObjectInputStream; import java.io.Serializable; -import java.math.BigDecimal; +import java.io.ObjectInputStream; +import java.io.IOException; + import java.util.Collections; import java.util.Comparator; -import java.util.HashSet; import java.util.Set; -import javax.jdo.annotations.PersistenceCapable; +import java.util.HashSet; +import java.math.BigDecimal; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a project, a budgeted task with one or more employees working on it. */ +import javax.jdo.annotations.PersistenceCapable; + +/** + * This class represents a project, a budgeted task with one or more + * employees working on it. + */ @PersistenceCapable -public class Project implements IProject, Serializable, Comparable, Comparator, DeepEquality { - - private long projid; - private String name; - private BigDecimal budget; - private transient Set reviewers = new HashSet(); // element type is Employee - private transient Set members = new HashSet(); // element type is Employee - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public Project() {} - - /** - * Initialize a project. - * - * @param projid The project identifier. - * @param name The name of the project. - * @param budget The budget for the project. - */ - public Project(long projid, String name, BigDecimal budget) { - this.projid = projid; - this.name = name; - this.budget = budget; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setProjid(long id) { - if (this.projid != 0) throw new IllegalStateException("Id is already set."); - this.projid = id; - } - - /** - * Get the project ID. - * - * @return The project ID. - */ - public long getProjid() { - return projid; - } - - /** - * Get the name of the project. - * - * @return The name of the project. - */ - public String getName() { - return name; - } - - /** - * Set the name of the project. - * - * @param name The name of the project. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Get the project's budget. - * - * @return The project's budget. - */ - public BigDecimal getBudget() { - return budget; - } - - /** - * Set the project's budget. - * - * @param budget The project's budget. - */ - public void setBudget(BigDecimal budget) { - this.budget = budget; - } - - /** Get the reviewers associated with this project. */ - public Set getReviewers() { - return Collections.unmodifiableSet(reviewers); - } - - /** - * Add a reviewer to the project. - * - * @param emp The employee to add as a reviewer. - */ - public void addReviewer(Employee emp) { - reviewers.add(emp); - } - - /** - * Remove a reviewer from the project. - * - * @param emp The employee to remove as a reviewer of this project. - */ - public void removeReviewer(Employee emp) { - reviewers.remove(emp); - } - - /** - * Set the reviewers associated with this project. - * - * @param reviewers The set of reviewers to associate with this project. - */ - public void setReviewers(Set reviewers) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.reviewers = (reviewers != null) ? new HashSet(reviewers) : null; - } - - /** - * Get the project members. - * - * @return The members of the project is returned as an unmodifiable set of Employee - * s. - */ - public Set getMembers() { - return Collections.unmodifiableSet(members); - } - - /** - * Add a new member to the project. - * - * @param emp The employee to add to the project. - */ - public void addMember(Employee emp) { - members.add(emp); - } - - /** - * Remove a member from the project. - * - * @param emp The employee to remove from the project. - */ - public void removeMember(Employee emp) { - members.remove(emp); - } - - /** - * Set the members of the project. - * - * @param employees The set of employees to be the members of this project. - */ - public void setMembers(Set employees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.members = (employees != null) ? new HashSet(employees) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - reviewers = new HashSet(); - members = new HashSet(); - } - - /** - * Returns a String representation of a Project object. - * - * @return a String representation of a Project object. - */ - public String toString() { - return "Project(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(projid); - rc.append(", name ").append(name); - rc.append(", budget ").append(budget); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IProject otherProject = (IProject) other; - String where = "Project<" + projid + ">"; - return helper.equals(projid, otherProject.getProjid(), where + ".projid") - & helper.equals(name, otherProject.getName(), where + ".name") - & helper.equals(budget, otherProject.getBudget(), where + ".budget") - & helper.deepEquals(reviewers, otherProject.getReviewers(), where + ".reviewers") - & helper.deepEquals(members, otherProject.getMembers(), where + ".members"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((IProject) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((IProject) o1, (IProject) o2); - } - - /** - * Compares this object with the specified Project object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Project object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Project object. - */ - public int compareTo(IProject other) { - return compare(this, other); - } - - /** - * Compares its two IProject arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IProject object to be compared. - * @param o2 the second IProject object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(IProject o1, IProject o2) { - return EqualityHelper.compare(o1.getProjid(), o2.getProjid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof IProject) { - return compareTo((IProject) obj) == 0; +public class Project + implements IProject, Serializable, Comparable, Comparator, DeepEquality { + + private long projid; + private String name; + private BigDecimal budget; + private transient Set reviewers = new HashSet(); // element type is Employee + private transient Set members = new HashSet(); // element type is Employee + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public Project() {} + + /** + * Initialize a project. + * @param projid The project identifier. + * @param name The name of the project. + * @param budget The budget for the project. + */ + public Project(long projid, String name, BigDecimal budget) { + this.projid = projid; + this.name = name; + this.budget = budget; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setProjid(long id) { + if (this.projid != 0) + throw new IllegalStateException("Id is already set."); + this.projid = id; + } + + /** + * Get the project ID. + * @return The project ID. + */ + public long getProjid() { + return projid; + } + + /** + * Get the name of the project. + * @return The name of the project. + */ + public String getName() { + return name; + } + + /** + * Set the name of the project. + * @param name The name of the project. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Get the project's budget. + * @return The project's budget. + */ + public BigDecimal getBudget() { + return budget; + } + + /** + * Set the project's budget. + * @param budget The project's budget. + */ + public void setBudget(BigDecimal budget) { + this.budget = budget; + } + + /** + * Get the reviewers associated with this project. + */ + public Set getReviewers() { + return Collections.unmodifiableSet(reviewers); } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) projid; - } - - /** - * This class is used to represent the application identity for the Project class. - */ - public static class Oid implements Serializable, Comparable { /** - * This field represents the identifier for the Project class. It must match a - * field in the Project class in both name and type. + * Add a reviewer to the project. + * @param emp The employee to add as a reviewer. */ - public long projid; + public void addReviewer(Employee emp) { + reviewers.add(emp); + } - /** The required public no-arg constructor. */ - public Oid() {} + /** + * Remove a reviewer from the project. + * @param emp The employee to remove as a reviewer of this project. + */ + public void removeReviewer(Employee emp) { + reviewers.remove(emp); + } /** - * Initialize the application identifier with a project ID. - * - * @param projid The id of the project. + * Set the reviewers associated with this project. + * @param reviewers The set of reviewers to associate with this project. */ - public Oid(long projid) { - this.projid = projid; + public void setReviewers(Set reviewers) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.reviewers = (reviewers != null) ? new HashSet(reviewers) : null; } - public Oid(String s) { - projid = Long.parseLong(justTheId(s)); + /** + * Get the project members. + * @return The members of the project is returned as an unmodifiable + * set of Employees. + */ + public Set getMembers() { + return Collections.unmodifiableSet(members); } + /** + * Add a new member to the project. + * @param emp The employee to add to the project. + */ + public void addMember(Employee emp) { + members.add(emp); + } + + /** + * Remove a member from the project. + * @param emp The employee to remove from the project. + */ + public void removeMember(Employee emp) { + members.remove(emp); + } + + /** + * Set the members of the project. + * @param employees The set of employees to be the members of this + * project. + */ + public void setMembers(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.members = (employees != null) ? new HashSet(employees) : null; + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + reviewers = new HashSet(); + members = new HashSet(); + } + + /** + * Returns a String representation of a Project object. + * @return a String representation of a Project object. + */ public String toString() { - return this.getClass().getName() + ": " + projid; + return "Project(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(projid); + rc.append(", name ").append(name); + rc.append(", budget ").append(budget); + return rc.toString(); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.projid != o.projid) return (false); - return (true); + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IProject otherProject = (IProject)other; + String where = "Project<" + projid + ">"; + return + helper.equals(projid, otherProject.getProjid(), where + ".projid") & + helper.equals(name, otherProject.getName(), where + ".name") & + helper.equals(budget, otherProject.getBudget(), where + ".budget") & + helper.deepEquals(reviewers, otherProject.getReviewers(), where + ".reviewers") & + helper.deepEquals(members, otherProject.getMembers(), where + ".members"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((IProject)o); } - /** */ - public int hashCode() { - return ((int) projid); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((IProject)o1, (IProject)o2); + } + + /** + * Compares this object with the specified Project object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Project object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Project + * object. + */ + public int compareTo(IProject other) { + return compare(this, other); + } + + /** + * Compares its two IProject arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IProject object to be compared. + * @param o2 the second IProject object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(IProject o1, IProject o2) { + return EqualityHelper.compare(o1.getProjid(), o2.getProjid()); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof IProject) { + return compareTo((IProject)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)projid; } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (projid < other.projid) return -1; - if (projid > other.projid) return 1; - return 0; + /** + * This class is used to represent the application identity + * for the Project class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the identifier for the + * Project class. It must match a field in the + * Project class in both name and type. + */ + public long projid; + + /** + * The required public no-arg constructor. + */ + public Oid() { } + + /** + * Initialize the application identifier with a project ID. + * @param projid The id of the project. + */ + public Oid(long projid) { + this.projid = projid; + } + + public Oid(String s) { projid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + projid;} + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.projid != o.projid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) projid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( projid < other.projid ) return -1; + if( projid > other.projid ) return 1; + return 0; + } + } - } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCAppConcrete.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCAppConcrete.java index 60ca407a2..88807087e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCAppConcrete.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCAppConcrete.java @@ -18,16 +18,7 @@ package org.apache.jdo.tck.pc.companyAnnotatedFC; import javax.jdo.PersistenceManager; -import org.apache.jdo.tck.pc.company.CompanyFactoryNewInstance; -import org.apache.jdo.tck.pc.company.IAddress; -import org.apache.jdo.tck.pc.company.ICompany; -import org.apache.jdo.tck.pc.company.IDentalInsurance; -import org.apache.jdo.tck.pc.company.IDepartment; -import org.apache.jdo.tck.pc.company.IFullTimeEmployee; -import org.apache.jdo.tck.pc.company.IMedicalInsurance; -import org.apache.jdo.tck.pc.company.IMeetingRoom; -import org.apache.jdo.tck.pc.company.IPartTimeEmployee; -import org.apache.jdo.tck.pc.company.IProject; +import org.apache.jdo.tck.pc.company.*; /* * CompanyFactoryAnnotatedPMFieldClass.java @@ -35,66 +26,66 @@ * This class uses the PersistenceManager.newInstance method with the concrete * class as a parameter. */ -public class CompanyFactoryAnnotatedFCAppConcrete implements CompanyFactoryNewInstance { +public class CompanyFactoryAnnotatedFCAppConcrete + implements CompanyFactoryNewInstance { + + PersistenceManager pm = null; - PersistenceManager pm = null; + /** + * Creates a new instance of CompanyFactoryAnnotatedFCAppConcrete + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedFCAppConcrete(PersistenceManager pm) { + this.pm = pm; + } + + public Class[] getTearDownClasses() { + return new Class[] { + FCAppDentalInsurance.class, + FCAppMedicalInsurance.class, + FCAppPartTimeEmployee.class, + FCAppFullTimeEmployee.class, + FCAppProject.class, + FCAppDepartment.class, + FCAppMeetingRoom.class, + FCAppCompany.class, + FCAppAddress.class + }; + } + + public IAddress newAddress() { + return (IAddress) new FCAppAddress(); + } - /** - * Creates a new instance of CompanyFactoryAnnotatedFCAppConcrete - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedFCAppConcrete(PersistenceManager pm) { - this.pm = pm; - } - - public Class[] getTearDownClasses() { - return new Class[] { - FCAppDentalInsurance.class, - FCAppMedicalInsurance.class, - FCAppPartTimeEmployee.class, - FCAppFullTimeEmployee.class, - FCAppProject.class, - FCAppDepartment.class, - FCAppMeetingRoom.class, - FCAppCompany.class, - FCAppAddress.class - }; - } - - public IAddress newAddress() { - return (IAddress) new FCAppAddress(); - } - - public IMeetingRoom newMeetingRoom() { - return (IMeetingRoom) new FCAppMeetingRoom(); - } - - public ICompany newCompany() { - return (ICompany) new FCAppCompany(); - } - - public IDentalInsurance newDentalInsurance() { - return (IDentalInsurance) new FCAppDentalInsurance(); - } - - public IDepartment newDepartment() { - return (IDepartment) new FCAppDepartment(); - } - - public IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) new FCAppFullTimeEmployee(); - } - - public IMedicalInsurance newMedicalInsurance() { - return (IMedicalInsurance) new FCAppMedicalInsurance(); - } - - public IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) new FCAppPartTimeEmployee(); - } - - public IProject newProject() { - return (IProject) new FCAppProject(); - } + public IMeetingRoom newMeetingRoom() { + return (IMeetingRoom) new FCAppMeetingRoom(); + } + + public ICompany newCompany() { + return (ICompany) new FCAppCompany(); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance) new FCAppDentalInsurance(); + } + + public IDepartment newDepartment() { + return (IDepartment) new FCAppDepartment(); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee) new FCAppFullTimeEmployee(); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance) new FCAppMedicalInsurance(); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee) new FCAppPartTimeEmployee(); + } + + public IProject newProject() { + return (IProject) new FCAppProject(); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCAppPM.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCAppPM.java index e4cbc39e7..a8ea2cd43 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCAppPM.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCAppPM.java @@ -18,16 +18,7 @@ package org.apache.jdo.tck.pc.companyAnnotatedFC; import javax.jdo.PersistenceManager; -import org.apache.jdo.tck.pc.company.CompanyFactoryNewInstance; -import org.apache.jdo.tck.pc.company.IAddress; -import org.apache.jdo.tck.pc.company.ICompany; -import org.apache.jdo.tck.pc.company.IDentalInsurance; -import org.apache.jdo.tck.pc.company.IDepartment; -import org.apache.jdo.tck.pc.company.IFullTimeEmployee; -import org.apache.jdo.tck.pc.company.IMedicalInsurance; -import org.apache.jdo.tck.pc.company.IMeetingRoom; -import org.apache.jdo.tck.pc.company.IPartTimeEmployee; -import org.apache.jdo.tck.pc.company.IProject; +import org.apache.jdo.tck.pc.company.*; /* * CompanyFactoryAnnotatedPMFieldClass.java @@ -35,66 +26,66 @@ * This class uses the PersistenceManager.newInstance method with the concrete * class as a parameter. */ -public class CompanyFactoryAnnotatedFCAppPM implements CompanyFactoryNewInstance { +public class CompanyFactoryAnnotatedFCAppPM + implements CompanyFactoryNewInstance { + + PersistenceManager pm = null; - PersistenceManager pm = null; + /** + * Creates a new instance of CompanyFactoryAnnotatedFCAppPM + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedFCAppPM(PersistenceManager pm) { + this.pm = pm; + } + + public Class[] getTearDownClasses() { + return new Class[] { + FCAppDentalInsurance.class, + FCAppMedicalInsurance.class, + FCAppPartTimeEmployee.class, + FCAppFullTimeEmployee.class, + FCAppProject.class, + FCAppDepartment.class, + FCAppMeetingRoom.class, + FCAppCompany.class, + FCAppAddress.class + }; + } + + public IAddress newAddress() { + return (IAddress)pm.newInstance(FCAppAddress.class); + } - /** - * Creates a new instance of CompanyFactoryAnnotatedFCAppPM - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedFCAppPM(PersistenceManager pm) { - this.pm = pm; - } - - public Class[] getTearDownClasses() { - return new Class[] { - FCAppDentalInsurance.class, - FCAppMedicalInsurance.class, - FCAppPartTimeEmployee.class, - FCAppFullTimeEmployee.class, - FCAppProject.class, - FCAppDepartment.class, - FCAppMeetingRoom.class, - FCAppCompany.class, - FCAppAddress.class - }; - } - - public IAddress newAddress() { - return (IAddress) pm.newInstance(FCAppAddress.class); - } - - public IMeetingRoom newMeetingRoom() { - return (IMeetingRoom) pm.newInstance(FCAppMeetingRoom.class); - } - - public ICompany newCompany() { - return (ICompany) pm.newInstance(FCAppCompany.class); - } - - public IDentalInsurance newDentalInsurance() { - return (IDentalInsurance) pm.newInstance(FCAppDentalInsurance.class); - } - - public IDepartment newDepartment() { - return (IDepartment) pm.newInstance(FCAppDepartment.class); - } - - public IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) pm.newInstance(FCAppFullTimeEmployee.class); - } - - public IMedicalInsurance newMedicalInsurance() { - return (IMedicalInsurance) pm.newInstance(FCAppMedicalInsurance.class); - } - - public IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) pm.newInstance(FCAppPartTimeEmployee.class); - } - - public IProject newProject() { - return (IProject) pm.newInstance(FCAppProject.class); - } + public IMeetingRoom newMeetingRoom() { + return (IMeetingRoom)pm.newInstance(FCAppMeetingRoom.class); + } + + public ICompany newCompany() { + return (ICompany)pm.newInstance(FCAppCompany.class); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance)pm.newInstance(FCAppDentalInsurance.class); + } + + public IDepartment newDepartment() { + return (IDepartment)pm.newInstance(FCAppDepartment.class); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee)pm.newInstance(FCAppFullTimeEmployee.class); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance)pm.newInstance(FCAppMedicalInsurance.class); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee)pm.newInstance(FCAppPartTimeEmployee.class); + } + + public IProject newProject() { + return (IProject)pm.newInstance(FCAppProject.class); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCConcreteDelegator.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCConcreteDelegator.java index 31f987ad0..1bf6238ba 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCConcreteDelegator.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCConcreteDelegator.java @@ -27,19 +27,19 @@ * class as a parameter. */ public class CompanyFactoryAnnotatedFCConcreteDelegator - extends CompanyFactoryAnnotatedAbstractDelegator { + extends CompanyFactoryAnnotatedAbstractDelegator { - /** - * Creates a new instance of CompanyFactoryAnnotatedFCConcreteDelegator - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedFCConcreteDelegator(PersistenceManager pm) { - super(pm); - if (isAppIdentity) { - delegate = new CompanyFactoryAnnotatedFCAppConcrete(pm); - } else { // datastoreidentity - delegate = new CompanyFactoryAnnotatedFCDSConcrete(pm); + /** + * Creates a new instance of CompanyFactoryAnnotatedFCConcreteDelegator + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedFCConcreteDelegator(PersistenceManager pm) { + super(pm); + if (isAppIdentity){ + delegate = new CompanyFactoryAnnotatedFCAppConcrete(pm); + } else { //datastoreidentity + delegate = new CompanyFactoryAnnotatedFCDSConcrete(pm); + } } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCDSConcrete.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCDSConcrete.java index deb009b0a..b772d0169 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCDSConcrete.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCDSConcrete.java @@ -18,16 +18,7 @@ package org.apache.jdo.tck.pc.companyAnnotatedFC; import javax.jdo.PersistenceManager; -import org.apache.jdo.tck.pc.company.CompanyFactoryNewInstance; -import org.apache.jdo.tck.pc.company.IAddress; -import org.apache.jdo.tck.pc.company.ICompany; -import org.apache.jdo.tck.pc.company.IDentalInsurance; -import org.apache.jdo.tck.pc.company.IDepartment; -import org.apache.jdo.tck.pc.company.IFullTimeEmployee; -import org.apache.jdo.tck.pc.company.IMedicalInsurance; -import org.apache.jdo.tck.pc.company.IMeetingRoom; -import org.apache.jdo.tck.pc.company.IPartTimeEmployee; -import org.apache.jdo.tck.pc.company.IProject; +import org.apache.jdo.tck.pc.company.*; /* * CompanyFactoryAnnotatedFCDSPM.java @@ -35,66 +26,66 @@ * This class uses the PersistenceManager.newInstance method with the concrete * class as a parameter. */ -public class CompanyFactoryAnnotatedFCDSConcrete implements CompanyFactoryNewInstance { +public class CompanyFactoryAnnotatedFCDSConcrete + implements CompanyFactoryNewInstance { + + PersistenceManager pm = null; - PersistenceManager pm = null; + /** + * Creates a new instance of CompanyFactoryAnnotatedFCDSConcrete + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedFCDSConcrete(PersistenceManager pm) { + this.pm = pm; + } + + public Class[] getTearDownClasses() { + return new Class[] { + FCDSDentalInsurance.class, + FCDSMedicalInsurance.class, + FCDSPartTimeEmployee.class, + FCDSFullTimeEmployee.class, + FCDSProject.class, + FCDSDepartment.class, + FCDSMeetingRoom.class, + FCDSCompany.class, + FCDSAddress.class + }; + } + + public IAddress newAddress() { + return (IAddress) new FCDSAddress(); + } - /** - * Creates a new instance of CompanyFactoryAnnotatedFCDSConcrete - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedFCDSConcrete(PersistenceManager pm) { - this.pm = pm; - } - - public Class[] getTearDownClasses() { - return new Class[] { - FCDSDentalInsurance.class, - FCDSMedicalInsurance.class, - FCDSPartTimeEmployee.class, - FCDSFullTimeEmployee.class, - FCDSProject.class, - FCDSDepartment.class, - FCDSMeetingRoom.class, - FCDSCompany.class, - FCDSAddress.class - }; - } - - public IAddress newAddress() { - return (IAddress) new FCDSAddress(); - } - - public IMeetingRoom newMeetingRoom() { - return (IMeetingRoom) new FCDSMeetingRoom(); - } - - public ICompany newCompany() { - return (ICompany) new FCDSCompany(); - } - - public IDentalInsurance newDentalInsurance() { - return (IDentalInsurance) new FCDSDentalInsurance(); - } - - public IDepartment newDepartment() { - return (IDepartment) new FCDSDepartment(); - } - - public IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) new FCDSFullTimeEmployee(); - } - - public IMedicalInsurance newMedicalInsurance() { - return (IMedicalInsurance) new FCDSMedicalInsurance(); - } - - public IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) new FCDSPartTimeEmployee(); - } - - public IProject newProject() { - return (IProject) new FCDSProject(); - } + public IMeetingRoom newMeetingRoom() { + return (IMeetingRoom) new FCDSMeetingRoom(); + } + + public ICompany newCompany() { + return (ICompany) new FCDSCompany(); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance) new FCDSDentalInsurance(); + } + + public IDepartment newDepartment() { + return (IDepartment) new FCDSDepartment(); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee) new FCDSFullTimeEmployee(); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance) new FCDSMedicalInsurance(); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee) new FCDSPartTimeEmployee(); + } + + public IProject newProject() { + return (IProject) new FCDSProject(); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCDSPM.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCDSPM.java index 020a3b4fc..882dae162 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCDSPM.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCDSPM.java @@ -18,16 +18,7 @@ package org.apache.jdo.tck.pc.companyAnnotatedFC; import javax.jdo.PersistenceManager; -import org.apache.jdo.tck.pc.company.CompanyFactoryNewInstance; -import org.apache.jdo.tck.pc.company.IAddress; -import org.apache.jdo.tck.pc.company.ICompany; -import org.apache.jdo.tck.pc.company.IDentalInsurance; -import org.apache.jdo.tck.pc.company.IDepartment; -import org.apache.jdo.tck.pc.company.IFullTimeEmployee; -import org.apache.jdo.tck.pc.company.IMedicalInsurance; -import org.apache.jdo.tck.pc.company.IMeetingRoom; -import org.apache.jdo.tck.pc.company.IPartTimeEmployee; -import org.apache.jdo.tck.pc.company.IProject; +import org.apache.jdo.tck.pc.company.*; /* * CompanyFactoryAnnotatedFCDSPM.java @@ -35,66 +26,66 @@ * This class uses the PersistenceManager.newInstance method with the concrete * class as a parameter. */ -public class CompanyFactoryAnnotatedFCDSPM implements CompanyFactoryNewInstance { +public class CompanyFactoryAnnotatedFCDSPM + implements CompanyFactoryNewInstance { + + PersistenceManager pm = null; - PersistenceManager pm = null; + /** + * Creates a new instance of CompanyFactoryAnnotatedFCDSPM + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedFCDSPM(PersistenceManager pm) { + this.pm = pm; + } + + public Class[] getTearDownClasses() { + return new Class[] { + FCDSDentalInsurance.class, + FCDSMedicalInsurance.class, + FCDSPartTimeEmployee.class, + FCDSFullTimeEmployee.class, + FCDSProject.class, + FCDSDepartment.class, + FCDSMeetingRoom.class, + FCDSCompany.class, + FCDSAddress.class + }; + } + + public IAddress newAddress() { + return (IAddress)pm.newInstance(FCDSAddress.class); + } - /** - * Creates a new instance of CompanyFactoryAnnotatedFCDSPM - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedFCDSPM(PersistenceManager pm) { - this.pm = pm; - } - - public Class[] getTearDownClasses() { - return new Class[] { - FCDSDentalInsurance.class, - FCDSMedicalInsurance.class, - FCDSPartTimeEmployee.class, - FCDSFullTimeEmployee.class, - FCDSProject.class, - FCDSDepartment.class, - FCDSMeetingRoom.class, - FCDSCompany.class, - FCDSAddress.class - }; - } - - public IAddress newAddress() { - return (IAddress) pm.newInstance(FCDSAddress.class); - } - - public IMeetingRoom newMeetingRoom() { - return (IMeetingRoom) pm.newInstance(FCDSMeetingRoom.class); - } - - public ICompany newCompany() { - return (ICompany) pm.newInstance(FCDSCompany.class); - } - - public IDentalInsurance newDentalInsurance() { - return (IDentalInsurance) pm.newInstance(FCDSDentalInsurance.class); - } - - public IDepartment newDepartment() { - return (IDepartment) pm.newInstance(FCDSDepartment.class); - } - - public IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) pm.newInstance(FCDSFullTimeEmployee.class); - } - - public IMedicalInsurance newMedicalInsurance() { - return (IMedicalInsurance) pm.newInstance(FCDSMedicalInsurance.class); - } - - public IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) pm.newInstance(FCDSPartTimeEmployee.class); - } - - public IProject newProject() { - return (IProject) pm.newInstance(FCDSProject.class); - } + public IMeetingRoom newMeetingRoom() { + return (IMeetingRoom)pm.newInstance(FCDSMeetingRoom.class); + } + + public ICompany newCompany() { + return (ICompany)pm.newInstance(FCDSCompany.class); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance)pm.newInstance(FCDSDentalInsurance.class); + } + + public IDepartment newDepartment() { + return (IDepartment)pm.newInstance(FCDSDepartment.class); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee)pm.newInstance(FCDSFullTimeEmployee.class); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance)pm.newInstance(FCDSMedicalInsurance.class); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee)pm.newInstance(FCDSPartTimeEmployee.class); + } + + public IProject newProject() { + return (IProject)pm.newInstance(FCDSProject.class); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCPMDelegator.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCPMDelegator.java index b7c64db29..78fa84a5e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCPMDelegator.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedFCPMDelegator.java @@ -26,19 +26,20 @@ * This class uses the PersistenceManager.newInstance method with the concrete * class as a parameter. */ -public class CompanyFactoryAnnotatedFCPMDelegator extends CompanyFactoryAnnotatedAbstractDelegator { +public class CompanyFactoryAnnotatedFCPMDelegator + extends CompanyFactoryAnnotatedAbstractDelegator { - /** - * Creates a new instance of CompanyFactoryAnnotatedFCPMDelegator - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedFCPMDelegator(PersistenceManager pm) { - super(pm); - if (isAppIdentity) { - delegate = new CompanyFactoryAnnotatedFCAppPM(pm); - } else { // datastoreidentity - delegate = new CompanyFactoryAnnotatedFCDSPM(pm); + /** + * Creates a new instance of CompanyFactoryAnnotatedFCPMDelegator + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedFCPMDelegator(PersistenceManager pm) { + super(pm); + if (isAppIdentity){ + delegate = new CompanyFactoryAnnotatedFCAppPM(pm); + } else { //datastoreidentity + delegate = new CompanyFactoryAnnotatedFCDSPM(pm); + } } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedPMFieldClass.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedPMFieldClass.java index 3d8abfcdc..c93cb67f4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedPMFieldClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/CompanyFactoryAnnotatedPMFieldClass.java @@ -18,15 +18,7 @@ package org.apache.jdo.tck.pc.companyAnnotatedFC; import javax.jdo.PersistenceManager; -import org.apache.jdo.tck.pc.company.IAddress; -import org.apache.jdo.tck.pc.company.ICompany; -import org.apache.jdo.tck.pc.company.IDentalInsurance; -import org.apache.jdo.tck.pc.company.IDepartment; -import org.apache.jdo.tck.pc.company.IFullTimeEmployee; -import org.apache.jdo.tck.pc.company.IMedicalInsurance; -import org.apache.jdo.tck.pc.company.IMeetingRoom; -import org.apache.jdo.tck.pc.company.IPartTimeEmployee; -import org.apache.jdo.tck.pc.company.IProject; +import org.apache.jdo.tck.pc.company.*; /* * CompanyFactoryAnnotatedPMFieldClass.java @@ -35,94 +27,112 @@ * class as a parameter. */ public class CompanyFactoryAnnotatedPMFieldClass - extends org.apache.jdo.tck.pc.company.CompanyFactoryAbstractImpl { + extends org.apache.jdo.tck.pc.company.CompanyFactoryAbstractImpl { + + Class addressClass = null; + Class dentalInsuranceClass = null; + Class medicalInsuranceClass = null; + Class partTimeEmployeeClass = null; + Class fullTimeEmployeeClass = null; + Class projectClass = null; + Class departmentClass = null; + Class meetingRoomClass = null; + Class companyClass = null; - Class addressClass = null; - Class dentalInsuranceClass = null; - Class medicalInsuranceClass = null; - Class partTimeEmployeeClass = null; - Class fullTimeEmployeeClass = null; - Class projectClass = null; - Class departmentClass = null; - Class meetingRoomClass = null; - Class companyClass = null; - - /** - * Creates a new instance of CompanyFactoryAnnotatedPMFieldClass - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedPMFieldClass(PersistenceManager pm) { - super(pm); - if (isAppIdentity) { - addressClass = org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppAddress.class; - dentalInsuranceClass = org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppDentalInsurance.class; - medicalInsuranceClass = org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppMedicalInsurance.class; - partTimeEmployeeClass = org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppPartTimeEmployee.class; - fullTimeEmployeeClass = org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppFullTimeEmployee.class; - projectClass = org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppProject.class; - departmentClass = org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppDepartment.class; - meetingRoomClass = org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppMeetingRoom.class; - companyClass = org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppCompany.class; - } else { // datastoreidentity - addressClass = org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSAddress.class; - dentalInsuranceClass = org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSDentalInsurance.class; - medicalInsuranceClass = org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSMedicalInsurance.class; - partTimeEmployeeClass = org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSPartTimeEmployee.class; - fullTimeEmployeeClass = org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSFullTimeEmployee.class; - projectClass = org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSProject.class; - departmentClass = org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSDepartment.class; - meetingRoomClass = org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSMeetingRoom.class; - companyClass = org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSCompany.class; + /** + * Creates a new instance of CompanyFactoryAnnotatedPMFieldClass + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedPMFieldClass(PersistenceManager pm) { + super(pm); + if (isAppIdentity){ + addressClass = + org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppAddress.class; + dentalInsuranceClass = + org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppDentalInsurance.class; + medicalInsuranceClass = + org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppMedicalInsurance.class; + partTimeEmployeeClass = + org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppPartTimeEmployee.class; + fullTimeEmployeeClass = + org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppFullTimeEmployee.class; + projectClass = + org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppProject.class; + departmentClass = + org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppDepartment.class; + meetingRoomClass = + org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppMeetingRoom.class; + companyClass = + org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppCompany.class; + } else { //datastoreidentity + addressClass = + org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSAddress.class; + dentalInsuranceClass = + org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSDentalInsurance.class; + medicalInsuranceClass = + org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSMedicalInsurance.class; + partTimeEmployeeClass = + org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSPartTimeEmployee.class; + fullTimeEmployeeClass = + org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSFullTimeEmployee.class; + projectClass = + org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSProject.class; + departmentClass = + org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSDepartment.class; + meetingRoomClass = + org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSMeetingRoom.class; + companyClass = + org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSCompany.class; + } + + } + + public Class[] getTearDownClasses() { + return new Class[] { + dentalInsuranceClass, + medicalInsuranceClass, + partTimeEmployeeClass, + fullTimeEmployeeClass, + projectClass, + departmentClass, + meetingRoomClass, + companyClass + }; + } + + public IAddress newAddress() { + return (IAddress)pm.newInstance(addressClass); } - } - - public Class[] getTearDownClasses() { - return new Class[] { - dentalInsuranceClass, - medicalInsuranceClass, - partTimeEmployeeClass, - fullTimeEmployeeClass, - projectClass, - departmentClass, - meetingRoomClass, - companyClass - }; - } - - public IAddress newAddress() { - return (IAddress) pm.newInstance(addressClass); - } - - public IMeetingRoom newMeetingRoom() { - return (IMeetingRoom) pm.newInstance(meetingRoomClass); - } - - public ICompany newCompany() { - return (ICompany) pm.newInstance(companyClass); - } - - public IDentalInsurance newDentalInsurance() { - return (IDentalInsurance) pm.newInstance(dentalInsuranceClass); - } - - public IDepartment newDepartment() { - return (IDepartment) pm.newInstance(departmentClass); - } - - public IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) pm.newInstance(fullTimeEmployeeClass); - } - - public IMedicalInsurance newMedicalInsurance() { - return (IMedicalInsurance) pm.newInstance(medicalInsuranceClass); - } - - public IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) pm.newInstance(partTimeEmployeeClass); - } - public IProject newProject() { - return (IProject) pm.newInstance(projectClass); - } + public IMeetingRoom newMeetingRoom() { + return (IMeetingRoom)pm.newInstance(meetingRoomClass); + } + + public ICompany newCompany() { + return (ICompany)pm.newInstance(companyClass); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance)pm.newInstance(dentalInsuranceClass); + } + + public IDepartment newDepartment() { + return (IDepartment)pm.newInstance(departmentClass); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee)pm.newInstance(fullTimeEmployeeClass); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance)pm.newInstance(medicalInsuranceClass); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee)pm.newInstance(partTimeEmployeeClass); + } + + public IProject newProject() { + return (IProject)pm.newInstance(projectClass); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/DatastoreIdDiscriminatorClassNameInheritanceNew.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/DatastoreIdDiscriminatorClassNameInheritanceNew.java index 721be202c..2554092e5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/DatastoreIdDiscriminatorClassNameInheritanceNew.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/DatastoreIdDiscriminatorClassNameInheritanceNew.java @@ -5,38 +5,32 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.IdGeneratorStrategy; import javax.jdo.annotations.IdentityType; import javax.jdo.annotations.InheritanceStrategy; +import javax.jdo.annotations.DiscriminatorStrategy; +import javax.jdo.annotations.IdGeneratorStrategy; @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -@javax.jdo.annotations.PersistenceCapable( - detachable = "true", - identityType = IdentityType.DATASTORE) -@javax.jdo.annotations.DatastoreIdentity( - strategy = IdGeneratorStrategy.IDENTITY, - column = "DATASTORE_IDENTITY") -@javax.jdo.annotations.Discriminator( - strategy = DiscriminatorStrategy.CLASS_NAME, - column = "DISCRIMINATOR", - indexed = "true") -@javax.jdo.annotations.Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -public @interface DatastoreIdDiscriminatorClassNameInheritanceNew {} +@javax.jdo.annotations.PersistenceCapable(detachable="true", identityType=IdentityType.DATASTORE) +@javax.jdo.annotations.DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY") +@javax.jdo.annotations.Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, column="DISCRIMINATOR", indexed="true") +@javax.jdo.annotations.Inheritance(strategy=InheritanceStrategy.NEW_TABLE) + +public @interface DatastoreIdDiscriminatorClassNameInheritanceNew { } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/DatastoreIdDiscriminatorClassNameInheritanceSuperclass.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/DatastoreIdDiscriminatorClassNameInheritanceSuperclass.java index 144e5b289..494defbe4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/DatastoreIdDiscriminatorClassNameInheritanceSuperclass.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/DatastoreIdDiscriminatorClassNameInheritanceSuperclass.java @@ -5,38 +5,32 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.IdGeneratorStrategy; import javax.jdo.annotations.IdentityType; import javax.jdo.annotations.InheritanceStrategy; +import javax.jdo.annotations.DiscriminatorStrategy; +import javax.jdo.annotations.IdGeneratorStrategy; @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -@javax.jdo.annotations.PersistenceCapable( - detachable = "true", - identityType = IdentityType.DATASTORE) -@javax.jdo.annotations.DatastoreIdentity( - strategy = IdGeneratorStrategy.IDENTITY, - column = "DATASTORE_IDENTITY") -@javax.jdo.annotations.Discriminator( - strategy = DiscriminatorStrategy.CLASS_NAME, - column = "DISCRIMINATOR", - indexed = "true") -@javax.jdo.annotations.Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE) -public @interface DatastoreIdDiscriminatorClassNameInheritanceSuperclass {} +@javax.jdo.annotations.PersistenceCapable(detachable="true", identityType=IdentityType.DATASTORE) +@javax.jdo.annotations.DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY") +@javax.jdo.annotations.Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, column="DISCRIMINATOR", indexed="true") +@javax.jdo.annotations.Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) + +public @interface DatastoreIdDiscriminatorClassNameInheritanceSuperclass { } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppAddress.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppAddress.java index a5b92c7a3..79b37ef9e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppAddress.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppAddress.java @@ -5,342 +5,343 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; import java.io.Serializable; import java.util.Comparator; -import javax.jdo.annotations.PersistenceCapable; + +import javax.jdo.annotations.*; + import org.apache.jdo.tck.pc.company.IAddress; import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a postal address. */ -@PersistenceCapable(embeddedOnly = "true", requiresExtent = "false") -public class FCAppAddress implements IAddress, Serializable, Comparable, Comparator, DeepEquality { - - private long addrid; - private String street; - private String city; - private String state; - private String zipcode; - private String country; - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FCAppAddress() {} - - /** - * This constructor initializes the FCAppAddress components. - * - * @param addrid The address ID. - * @param street The street address. - * @param city The city. - * @param state The state. - * @param zipcode The zip code. - * @param country The zip country. - */ - public FCAppAddress( - long addrid, String street, String city, String state, String zipcode, String country) { - this.addrid = addrid; - this.street = street; - this.city = city; - this.state = state; - this.zipcode = zipcode; - this.country = country; - } - - /** - * Get the addrid associated with this object. - * - * @return the addrid. - */ - public long getAddrid() { - return addrid; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setAddrid(long id) { - if (this.addrid != 0) throw new IllegalStateException("Id is already set."); - this.addrid = id; - } - - /** - * Get the street component of the address. - * - * @return The street component of the address. - */ - public String getStreet() { - return street; - } - - /** - * Set the street component of the address. - * - * @param street The street component. - */ - public void setStreet(String street) { - this.street = street; - } - - /** - * Get the city. - * - * @return The city component of the address. - */ - public String getCity() { - return city; - } - - /** - * Set the city component of the address. - * - * @param city The city. - */ - public void setCity(String city) { - this.city = city; - } - - /** - * Get the state component of the address. - * - * @return The state. - */ - public String getState() { - return state; - } - - /** - * Set the state component of the address. - * - * @param state The state. - */ - public void setState(String state) { - this.state = state; - } - - /** - * Get the zipcode component of the address. - * - * @return The zipcode. - */ - public String getZipcode() { - return zipcode; - } - - /** - * Set the zip code component of the address. - * - * @param zipcode The zipcode. - */ - public void setZipcode(String zipcode) { - this.zipcode = zipcode; - } - - /** - * Get the country component of the address. - * - * @return The country. - */ - public String getCountry() { - return country; - } - - /** - * Set the country component of the address. - * - * @param country The country. - */ - public void setCountry(String country) { - this.country = country; - } - - /** - * Returns a String representation of a Address object. - * - * @return a String representation of a Address object. - */ - public String toString() { - return "Address(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(addrid); - rc.append(", street ").append(street); - rc.append(", city ").append(city); - rc.append(", state ").append(state); - rc.append(", zipcode ").append(zipcode); - rc.append(", country ").append(country); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCAppAddress otherAddress = (FCAppAddress) other; - String where = "Address<" + addrid + ">"; - return helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") - & helper.equals(street, otherAddress.getStreet(), where + ".street") - & helper.equals(city, otherAddress.getCity(), where + ".city") - & helper.equals(state, otherAddress.getState(), where + ".state") - & helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") - & helper.equals(country, otherAddress.getCountry(), where + ".country"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((FCAppAddress) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((FCAppAddress) o1, (FCAppAddress) o2); - } - - /** - * Compares this object with the specified Address object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Address object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Address object. - */ - public int compareTo(FCAppAddress other) { - return compare(this, other); - } - - /** - * Compares its two FCAppAddress arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the firstFCAppAddresss object to be compared. - * @param o2 the second FFCPIAddressobject to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(FCAppAddress o1, FCAppAddress o2) { - return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof FCAppAddress) { - return compareTo((FCAppAddress) obj) == 0; +/** + * This class represents a postal address. + */ +@PersistenceCapable(embeddedOnly="true", requiresExtent="false") +public class FCAppAddress + implements IAddress, Serializable, Comparable, Comparator, DeepEquality { + + private long addrid; + private String street; + private String city; + private String state; + private String zipcode; + private String country; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCAppAddress() {} + + /** + * This constructor initializes the FCAppAddress components. + * + * + * @param addrid The address ID. + * @param street The street address. + * @param city The city. + * @param state The state. + * @param zipcode The zip code. + * @param country The zip country. + */ + public FCAppAddress(long addrid, String street, String city, + String state, String zipcode, String country) + { + this.addrid = addrid; + this.street = street; + this.city = city; + this.state = state; + this.zipcode = zipcode; + this.country = country; + } + + /** + * Get the addrid associated with this object. + * @return the addrid. + */ + public long getAddrid() { + return addrid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setAddrid(long id) { + if (this.addrid != 0) + throw new IllegalStateException("Id is already set."); + this.addrid = id; + } + + /** + * Get the street component of the address. + * @return The street component of the address. + */ + public String getStreet() { + return street; + } + + /** + * Set the street component of the address. + * @param street The street component. + */ + public void setStreet(String street) { + this.street = street; + } + + /** + * Get the city. + * @return The city component of the address. + */ + public String getCity() { + return city; + } + + /** + * Set the city component of the address. + * @param city The city. + */ + public void setCity(String city) { + this.city = city; + } + + /** + * Get the state component of the address. + * @return The state. + */ + public String getState() { + return state; + } + + /** + * Set the state component of the address. + * @param state The state. + */ + public void setState(String state) { + this.state = state; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) addrid; - } - - /** - * This class is used to represent the application identifier for the Address class. - */ - public static class Oid implements Serializable, Comparable { /** - * This is the identifier field for Address and must correspond in type and name to - * the field in Address. + * Get the zipcode component of the address. + * @return The zipcode. */ - public long addrid; + public String getZipcode() { + return zipcode; + } - /** The required public, no-arg constructor. */ - public Oid() { - addrid = 0; + /** + * Set the zip code component of the address. + * @param zipcode The zipcode. + */ + public void setZipcode(String zipcode) { + this.zipcode = zipcode; } /** - * A constructor to initialize the identifier field. - * - * @param addrid the id of the Address. + * Get the country component of the address. + * @return The country. */ - public Oid(long addrid) { - this.addrid = addrid; + public String getCountry() { + return country; } - public Oid(String s) { - addrid = Long.parseLong(justTheId(s)); + /** + * Set the country component of the address. + * @param country The country. + */ + public void setCountry(String country) { + this.country = country; } + /** + * Returns a String representation of a Address object. + * @return a String representation of a Address object. + */ public String toString() { - return this.getClass().getName() + ": " + addrid; + return "Address(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(addrid); + rc.append(", street ").append(street); + rc.append(", city ").append(city); + rc.append(", state ").append(state); + rc.append(", zipcode ").append(zipcode); + rc.append(", country ").append(country); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCAppAddress otherAddress = (FCAppAddress)other; + String where = "Address<" + addrid + ">"; + return + helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") & + helper.equals(street, otherAddress.getStreet(), where + ".street") & + helper.equals(city, otherAddress.getCity(), where + ".city") & + helper.equals(state, otherAddress.getState(), where + ".state") & + helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") & + helper.equals(country, otherAddress.getCountry(), where + ".country"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((FCAppAddress)o); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.addrid != o.addrid) return (false); - return (true); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((FCAppAddress)o1, (FCAppAddress)o2); } - /** */ - public int hashCode() { - return ((int) addrid); + /** + * Compares this object with the specified Address object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Address object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Address + * object. + */ + public int compareTo(FCAppAddress other) { + return compare(this, other); + } + + /** + * Compares its two FCAppAddress arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * + * + * @param o1 the firstFCAppAddresss object to be compared. + * @param o2 the second FFCPIAddressobject to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(FCAppAddress o1, FCAppAddress o2) { + return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof FCAppAddress) { + return compareTo((FCAppAddress)obj) == 0; + } + return false; } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (addrid < other.addrid) return -1; - if (addrid > other.addrid) return 1; - return 0; + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)addrid; + } + + /** + * This class is used to represent the application identifier + * for the Address class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This is the identifier field for Address and must + * correspond in type and name to the field in + * Address. + */ + public long addrid; + + /** The required public, no-arg constructor. */ + public Oid() + { + addrid = 0; + } + + /** + * A constructor to initialize the identifier field. + * @param addrid the id of the Address. + */ + public Oid(long addrid) { + this.addrid = addrid; + } + + public Oid(String s) { addrid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + addrid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.addrid != o.addrid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) addrid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( addrid < other.addrid ) return -1; + if( addrid > other.addrid ) return 1; + return 0; + } + } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppCompany.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppCompany.java index a467ebe24..c09f31a7c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppCompany.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppCompany.java @@ -5,400 +5,395 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; -import java.io.IOException; -import java.io.ObjectInputStream; +import javax.jdo.annotations.*; + import java.io.Serializable; +import java.io.ObjectInputStream; +import java.io.IOException; + import java.text.SimpleDateFormat; + import java.util.Collections; import java.util.Comparator; -import java.util.Date; -import java.util.HashSet; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.Embedded; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.PersistenceModifier; -import javax.jdo.annotations.Persistent; +import java.util.HashSet; +import java.util.Date; import org.apache.jdo.tck.pc.company.IAddress; + import org.apache.jdo.tck.pc.company.ICompany; import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents information about a company. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION, table = "companies") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator(strategy = DiscriminatorStrategy.CLASS_NAME, column = "DISCRIMINATOR") -public class FCAppCompany implements ICompany, Serializable, Comparable, Comparator, DeepEquality { - - @Persistent(primaryKey = "true") - @Column(name = "ID") - private long companyid; - - @Column(name = "NAME", jdbcType = "VARCHAR") - private String name; - - @Column(name = "FOUNDEDDATE") - private Date founded; - - @Persistent(persistenceModifier = PersistenceModifier.PERSISTENT) - @Embedded( - nullIndicatorColumn = "COUNTRY", - members = { - @Persistent(name = "addrid", columns = @Column(name = "ADDRID")), - @Persistent(name = "street", columns = @Column(name = "STREET")), - @Persistent(name = "city", columns = @Column(name = "CITY")), - @Persistent(name = "state", columns = @Column(name = "STATE")), - @Persistent(name = "zipcode", columns = @Column(name = "ZIPCODE")), - @Persistent(name = "country", columns = @Column(name = "COUNTRY")) - }) - private FCAppAddress address; - - @Persistent(persistenceModifier = PersistenceModifier.PERSISTENT, mappedBy = "company") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppDepartment.class) - private transient Set departments = new HashSet(); - - protected static SimpleDateFormat formatter = new SimpleDateFormat("d/MMM/yyyy"); - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FCAppCompany() {} - - /** - * Initialize the FCAppCompany instance. - * - * @param companyid The company id. - * @param name The company name. - * @param founded The date the company was founded. - */ - public FCAppCompany(long companyid, String name, Date founded) { - this.companyid = companyid; - this.name = name; - this.founded = founded; - } - - /** - * Initialize the Company instance. - * - * @param companyid The company id. - * @param name The company name. - * @param founded The date the company was founded. - * @param addr The company's address. - */ - public FCAppCompany(long companyid, String name, Date founded, IAddress addr) { - this(companyid, name, founded); - this.address = (FCAppAddress) addr; - } - - /** - * Get the company id. - * - * @return The company id. - */ - public long getCompanyid() { - return companyid; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setCompanyid(long id) { - if (this.companyid != 0) throw new IllegalStateException("Id is already set."); - this.companyid = id; - } - - /** - * Get the name of the company. - * - * @return The name of the company. - */ - public String getName() { - return name; - } - - /** - * Set the name of the company. - * - * @param name The value to use for the name of the company. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Get the date that the company was founded. - * - * @return The date the company was founded. - */ - public Date getFounded() { - return founded; - } - - /** - * Set the date that the company was founded. - * - * @param founded The date to set that the company was founded. - */ - public void setFounded(Date founded) { - this.founded = founded; - } - - /** - * Get the address of the company. - * - * @return The primary address of the company. - */ - public IAddress getAddress() { - return address; - } - - /** - * Set the primary address for the company. - * - * @param address The address to set for the company. - */ - public void setAddress(IAddress address) { - this.address = (FCAppAddress) address; - } - - /** - * Get the departments contained in the company. - * - * @return An unmodifiable Set that contains all the FCAppDepartments of - * the company. - */ - public Set getDepartments() { - return Collections.unmodifiableSet(departments); - } - - /** - * Add a FCAppDepartment instance to the company. - * - * @param dept The FCAppDepartment instance to add. - */ - public void addDepartment(FCAppDepartment dept) { - departments.add(dept); - } - - /** - * Remove a FCAppDepartment instance from the company. - * - * @param dept The FCAppDepartment instance to remove. - */ - public void removeDepartment(FCAppDepartment dept) { - departments.remove(dept); - } - - /** - * Initialize the set of FCAppDepartments in the company to the parameter. - * - * @param departments The set of FCAppDepartments for the company. - */ - public void setDepartments(Set departments) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.departments = (departments != null) ? new HashSet(departments) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - departments = new HashSet(); - } - - /** - * Returns a String representation of a Company object. - * - * @return a String representation of a Company object. - */ - public String toString() { - return "Company(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(companyid); - rc.append(", name ").append(name); - rc.append(", founded ").append(founded == null ? "null" : formatter.format(founded)); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCAppCompany otherCompany = (FCAppCompany) other; - String where = "Company<" + companyid + ">"; - return helper.equals(companyid, otherCompany.getCompanyid(), where + ".companyid") - & helper.equals(name, otherCompany.getName(), where + ".name") - & helper.equals(founded, otherCompany.getFounded(), where + ".founded") - & helper.deepEquals(address, otherCompany.getAddress(), where + ".address") - & helper.deepEquals(departments, otherCompany.getDepartments(), where + ".departments"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((FCAppCompany) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((FCAppCompany) o1, (FCAppCompany) o2); - } - - /** - * Compares this object with the specified Company object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Company object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Company object. - */ - public int compareTo(FCAppCompany other) { - return compare(this, other); - } - - /** - * Compares its two ICompany arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first ICompany object to be compared. - * @param o2 the second ICompany object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(FCAppCompany o1, FCAppCompany o2) { - return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof FCAppCompany) { - return compareTo((FCAppCompany) obj) == 0; +/** + * This class represents information about a company. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION,table="companies") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") + public class FCAppCompany + implements ICompany, Serializable, Comparable, Comparator, DeepEquality { + + @Persistent(primaryKey="true") + @Column(name="ID") + private long companyid; + @Column(name="NAME", jdbcType="VARCHAR") + private String name; + @Column(name="FOUNDEDDATE") + private Date founded; + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT) + @Embedded(nullIndicatorColumn="COUNTRY", + members={ + @Persistent(name="addrid", columns=@Column(name="ADDRID")), + @Persistent(name="street", columns=@Column(name="STREET")), + @Persistent(name="city", columns=@Column(name="CITY")), + @Persistent(name="state", columns=@Column(name="STATE")), + @Persistent(name="zipcode", columns=@Column(name="ZIPCODE")), + @Persistent(name="country", columns=@Column(name="COUNTRY")) + }) + private FCAppAddress address; + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT, + mappedBy="company") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppDepartment.class) + private transient Set departments = new HashSet(); + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCAppCompany() {} + + /** + * + * Initialize the FCAppCompany instance. + * + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + */ + public FCAppCompany(long companyid, String name, Date founded) { + this.companyid = companyid; + this.name = name; + this.founded = founded; + } + + /** + * Initialize the Company instance. + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + * @param addr The company's address. + */ + public FCAppCompany(long companyid, String name, Date founded, IAddress addr) { + this(companyid, name, founded); + this.address = (FCAppAddress)addr; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) companyid; - } - - /** - * The class to be used as the application identifier for the Company class. It - * consists of both the company name and the date that the company was founded. - */ - public static class Oid implements Serializable, Comparable { /** - * This field is part of the identifier and should match in name and type with a field in the - * Company class. + * Get the company id. + * @return The company id. */ - public long companyid; + public long getCompanyid() { + return companyid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setCompanyid(long id) { + if (this.companyid != 0) + throw new IllegalStateException("Id is already set."); + this.companyid = id; + } - /** The required public no-arg constructor. */ - public Oid() {} + /** + * Get the name of the company. + * @return The name of the company. + */ + public String getName() { + return name; + } /** - * Initialize the identifier. - * - * @param companyid The id of the company. + * Set the name of the company. + * @param name The value to use for the name of the company. */ - public Oid(long companyid) { - this.companyid = companyid; + public void setName(String name) { + this.name = name; } - public Oid(String s) { - companyid = Long.parseLong(justTheId(s)); + /** + * Get the date that the company was founded. + * @return The date the company was founded. + */ + public Date getFounded() { + return founded; + } + + /** + * Set the date that the company was founded. + * @param founded The date to set that the company was founded. + */ + public void setFounded(Date founded) { + this.founded = founded; } + /** + * Get the address of the company. + * @return The primary address of the company. + */ + public IAddress getAddress() { + return address; + } + + /** + * Set the primary address for the company. + * @param address The address to set for the company. + */ + public void setAddress(IAddress address) { + this.address = (FCAppAddress)address; + } + + /** + * Get the departments contained in the company. + * + * @return An unmodifiable Set that contains all the + * FCAppDepartments of the company. + */ + public Set getDepartments() { + return Collections.unmodifiableSet(departments); + } + + /** + * Add a FCAppDepartment instance to the company. + * + * @param dept The FCAppDepartment instance to add. + */ + public void addDepartment(FCAppDepartment dept) { + departments.add(dept); + } + + /** + * Remove a FCAppDepartment instance from the company. + * + * @param dept The FCAppDepartment instance to remove. + */ + public void removeDepartment(FCAppDepartment dept) { + departments.remove(dept); + } + + /** + * Initialize the set of FCAppDepartments in the company to the + * parameter. + * + * @param departments The set of FCAppDepartments for the + * company. + */ + public void setDepartments(Set departments) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.departments = + (departments != null) ? new HashSet(departments) : null; + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + departments = new HashSet(); + } + + /** + * Returns a String representation of a Company object. + * @return a String representation of a Company object. + */ public String toString() { - return this.getClass().getName() + ": " + companyid; + return "Company(" + getFieldRepr()+ ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(companyid); + rc.append(", name ").append(name); + rc.append(", founded ").append( + founded==null ? "null" : formatter.format(founded)); + return rc.toString(); } - /** */ - public boolean equals(Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return false; - Oid o = (Oid) obj; - if (this.companyid != o.companyid) return false; - return true; + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCAppCompany otherCompany = (FCAppCompany)other; + String where = "Company<" + companyid + ">"; + return + helper.equals(companyid, otherCompany.getCompanyid(), where + ".companyid") & + helper.equals(name, otherCompany.getName(), where + ".name") & + helper.equals(founded, otherCompany.getFounded(), where + ".founded") & + helper.deepEquals(address, otherCompany.getAddress(), where + ".address") & + helper.deepEquals(departments, otherCompany.getDepartments(), where + ".departments"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((FCAppCompany)o); } - /** */ - public int hashCode() { - return (int) companyid; + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((FCAppCompany)o1, (FCAppCompany)o2); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compares this object with the specified Company object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Company object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Company + * object. + */ + public int compareTo(FCAppCompany other) { + return compare(this, other); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (companyid < other.companyid) return -1; - if (companyid > other.companyid) return 1; - return 0; + /** + * Compares its two ICompany arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first ICompany object to be compared. + * @param o2 the second ICompany object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(FCAppCompany o1, FCAppCompany o2) { + return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); } - } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof FCAppCompany) { + return compareTo((FCAppCompany)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)companyid; + } + + /** + * The class to be used as the application identifier + * for the Company class. It consists of both the company + * name and the date that the company was founded. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field is part of the identifier and should match in name + * and type with a field in the Company class. + */ + public long companyid; + + /** The required public no-arg constructor. */ + public Oid() { } + + /** + * Initialize the identifier. + * @param companyid The id of the company. + */ + public Oid(long companyid) { + this.companyid = companyid; + } + + public Oid(String s) { companyid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + companyid;} + + + /** */ + public boolean equals(Object obj) { + if (obj==null || !this.getClass().equals(obj.getClass())) + return false; + Oid o = (Oid) obj; + if (this.companyid != o.companyid) + return false; + return true; + } + + /** */ + public int hashCode() { + return (int)companyid; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( companyid < other.companyid ) return -1; + if( companyid > other.companyid ) return 1; + return 0; + } + + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppDentalInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppDentalInsurance.java index 78f76cde1..cf79b78af 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppDentalInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppDentalInsurance.java @@ -5,124 +5,124 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; +import javax.jdo.annotations.*; + import java.math.BigDecimal; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.PersistenceCapable; + import org.apache.jdo.tck.pc.company.IDentalInsurance; import org.apache.jdo.tck.pc.company.IEmployee; import org.apache.jdo.tck.util.EqualityHelper; /** - * This class represents a dental insurance carrier selection for a particular Employee - * . + * This class represents a dental insurance carrier selection for a + * particular Employee. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION) +@PersistenceCapable(identityType=IdentityType.APPLICATION) public class FCAppDentalInsurance extends FCAppInsurance implements IDentalInsurance { - @Column(name = "LIFETIME_ORTHO_BENEFIT") - private BigDecimal lifetimeOrthoBenefit; + @Column(name="LIFETIME_ORTHO_BENEFIT") + private BigDecimal lifetimeOrthoBenefit; - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FCAppDentalInsurance() {} + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCAppDentalInsurance() {} - /** - * Construct a DentalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. - */ - public FCAppDentalInsurance(long insid, String carrier, BigDecimal lifetimeOrthoBenefit) { - super(insid, carrier); - this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; - } + /** + * Construct a DentalInsurance instance. + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public FCAppDentalInsurance(long insid, String carrier, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier); + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } - /** - * Construct a FCAppDentalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param employee The employee associated with this insurance. - * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. - */ - public FCAppDentalInsurance( - long insid, String carrier, IEmployee employee, BigDecimal lifetimeOrthoBenefit) { - super(insid, carrier, employee); - this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; - } + /** + * Construct a FCAppDentalInsurance instance. + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public FCAppDentalInsurance(long insid, String carrier, IEmployee employee, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier, employee); + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } - /** - * Get the insurance lifetimeOrthoBenefit. - * - * @return The insurance lifetimeOrthoBenefit. - */ - public BigDecimal getLifetimeOrthoBenefit() { - return lifetimeOrthoBenefit; - } + /** + * Get the insurance lifetimeOrthoBenefit. + * @return The insurance lifetimeOrthoBenefit. + */ + public BigDecimal getLifetimeOrthoBenefit() { + return lifetimeOrthoBenefit; + } - /** - * Set the insurance lifetimeOrthoBenefit. - * - * @param lifetimeOrthoBenefit The insurance lifetimeOrthoBenefit. - */ - public void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit) { - this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; - } + /** + * Set the insurance lifetimeOrthoBenefit. + * @param lifetimeOrthoBenefit The insurance lifetimeOrthoBenefit. + */ + public void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit) { + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } - /** - * Returns a String representation of a FCAppDentalInsurance object. - * - * @return a String representation of a FCAppDentalInsurance object. - */ - public String toString() { - return "FCDentalInsurance(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of a FCAppDentalInsurance + * object. + * + * @return a String representation of a FCAppDentalInsurance + * object. + */ + public String toString() { + return "FCDentalInsurance(" + getFieldRepr()+ ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", lifetimeOrthoBenefit ").append(lifetimeOrthoBenefit); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", lifetimeOrthoBenefit ").append(lifetimeOrthoBenefit); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCAppDentalInsurance otherIns = (FCAppDentalInsurance)other; + String where = "FCDentalInsurance<" + getInsid() + ">"; + return super.deepCompareFields(otherIns, helper) & + helper.equals(lifetimeOrthoBenefit, + otherIns.getLifetimeOrthoBenefit(), where + ".lifetimeOrthoBenefit"); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Object. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCAppDentalInsurance otherIns = (FCAppDentalInsurance) other; - String where = "FCDentalInsurance<" + getInsid() + ">"; - return super.deepCompareFields(otherIns, helper) - & helper.equals( - lifetimeOrthoBenefit, - otherIns.getLifetimeOrthoBenefit(), - where + ".lifetimeOrthoBenefit"); - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppDepartment.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppDepartment.java index 1b26b8325..e48a03159 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppDepartment.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppDepartment.java @@ -5,453 +5,448 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; -import java.io.IOException; -import java.io.ObjectInputStream; +import javax.jdo.annotations.*; + import java.io.Serializable; +import java.io.ObjectInputStream; +import java.io.IOException; + import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; -import javax.jdo.annotations.PrimaryKey; import org.apache.jdo.tck.pc.company.ICompany; + import org.apache.jdo.tck.pc.company.IDepartment; import org.apache.jdo.tck.pc.company.IEmployee; + import org.apache.jdo.tck.pc.compositeAnnotation.ApplicationIdDiscriminatorClassName; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a department within a company. */ -@PersistenceCapable(table = "departments") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) +/** + * This class represents a department within a company. + */ +@PersistenceCapable(table="departments") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) @ApplicationIdDiscriminatorClassName public class FCAppDepartment implements IDepartment, Serializable, Comparable, Comparator, DeepEquality { - public static final int RECOMMENDED_NO_OF_EMPS = 2; - - @PrimaryKey - @Column(name = "ID") - private long deptid; - - @Column(name = "NAME") - private String name; - - @Column(name = "COMPANYID") - private FCAppCompany company; - - @Column(name = "EMP_OF_THE_MONTH") - private FCAppEmployee employeeOfTheMonth; - - @Persistent(mappedBy = "department") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppEmployee.class) - private transient Set employees = new HashSet(); - - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppEmployee.class) - @Persistent(mappedBy = "fundingDept") - private transient Set fundedEmps = new HashSet(); - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FCAppDepartment() {} - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - */ - public FCAppDepartment(long deptid, String name) { - this.deptid = deptid; - this.name = name; - } - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - * @param company The company that the department is associated with. - */ - public FCAppDepartment(long deptid, String name, ICompany company) { - this.deptid = deptid; - this.name = name; - this.company = (FCAppCompany) company; - } - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - * @param company The company that the department is associated with. - * @param employeeOfTheMonth The employee of the month the department is associated with. - */ - public FCAppDepartment(long deptid, String name, ICompany company, IEmployee employeeOfTheMonth) { - this.deptid = deptid; - this.name = name; - this.company = (FCAppCompany) company; - this.employeeOfTheMonth = (FCAppEmployee) employeeOfTheMonth; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setDeptid(long id) { - if (this.deptid != 0) throw new IllegalStateException("Id is already set."); - this.deptid = id; - } - - /** - * Get the department id. - * - * @return The department id. - */ - public long getDeptid() { - return deptid; - } - - /** - * Get the name of the department. - * - * @return The name of the department. - */ - public String getName() { - return name; - } - - /** - * Set the name of the department. - * - * @param name The name to set for the department. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Get the company associated with the department. - * - * @return The company. - */ - public ICompany getCompany() { - return company; - } - - /** - * Set the company for the department. - * - * @param company The company to associate with the department. - */ - public void setCompany(ICompany company) { - this.company = (FCAppCompany) company; - } - - /** - * Get the employee of the month associated with the department. - * - * @return The employee of the month. - */ - public IEmployee getEmployeeOfTheMonth() { - return employeeOfTheMonth; - } - - /** - * Set the employee of the month for the department. - * - * @param employeeOfTheMonth The employee of the month to associate with the department. - */ - public void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth) { - this.employeeOfTheMonth = (FCAppEmployee) employeeOfTheMonth; - } - - /** - * Get the employees in the department as an unmodifiable set. - * - * @return The set of employees in the department, as an unmodifiable set. - */ - public Set getEmployees() { - return Collections.unmodifiableSet(employees); - } - - /** - * Add an employee to the department. - * - * @param emp The employee to add to the department. - */ - public void addEmployee(FCAppEmployee emp) { - employees.add(emp); - } - - /** - * Remove an employee from the department. - * - * @param emp The employee to remove from the department. - */ - public void removeEmployee(FCAppEmployee emp) { - employees.remove(emp); - } - - /** - * Set the employees to be in this department. - * - * @param employees The set of employees for this department. - */ - public void setEmployees(Set employees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.employees = (employees != null) ? new HashSet(employees) : null; - } - - /** - * Get the funded employees in the department as an unmodifiable set. - * - * @return The set of funded employees in the department, as an unmodifiable set. - */ - public Set getFundedEmps() { - return Collections.unmodifiableSet(fundedEmps); - } - - /** - * Add an employee to the collection of funded employees of this department. - * - * @param emp The employee to add to the department. - */ - public void addFundedEmp(FCAppEmployee emp) { - fundedEmps.add(emp); - } - - /** - * Remove an employee from collection of funded employees of this department. - * - * @param emp The employee to remove from the department. - */ - public void removeFundedEmp(FCAppEmployee emp) { - fundedEmps.remove(emp); - } - - /** - * Set the funded employees to be in this department. - * - * @param employees The set of funded employees for this department. - */ - public void setFundedEmps(Set employees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.fundedEmps = (fundedEmps != null) ? new HashSet(employees) : null; - } - - @Override - public List getMeetingRooms() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void setMeetingRooms(List rooms) { - // TODO Auto-generated method stub - - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - employees = new HashSet(); - fundedEmps = new HashSet(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other FCAppDepartment. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCAppDepartment otherDept = (FCAppDepartment) other; - String where = "FCDepartment<" + deptid + ">"; - return helper.equals(deptid, otherDept.getDeptid(), where + ".deptid") - & helper.equals(name, otherDept.getName(), where + ".name") - & helper.deepEquals(company, otherDept.getCompany(), where + ".company") - & helper.deepEquals( - employeeOfTheMonth, otherDept.getEmployeeOfTheMonth(), where + ".employeeOfTheMonth") - & helper.deepEquals(employees, otherDept.getEmployees(), where + ".employees") - & helper.deepEquals(fundedEmps, otherDept.getFundedEmps(), where + ".fundedEmps"); - } - - /** - * Returns a String representation of a FCAppDepartment object. - * - * @return a String representation of a FCAppDepartment object. - */ - public String toString() { - return "FCDepartment(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(deptid); - rc.append(", name ").append(name); - return rc.toString(); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((FCAppDepartment) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((FCAppDepartment) o1, (FCAppDepartment) o2); - } - - /** - * Compares this object with the specified Department object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Department object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Department object. - */ - public int compareTo(FCAppDepartment other) { - return compare(this, other); - } - - /** - * Compares its two IDepartment arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IDepartment object to be compared. - * @param o2 the second IDepartment object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(FCAppDepartment o1, FCAppDepartment o2) { - return EqualityHelper.compare(o1.getDeptid(), o2.getDeptid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof FCAppDepartment) { - return compareTo((FCAppDepartment) obj) == 0; + public static final int RECOMMENDED_NO_OF_EMPS = 2; + + @PrimaryKey + @Column(name="ID") + private long deptid; + @Column(name="NAME") + private String name; + @Column(name="COMPANYID") + private FCAppCompany company; + @Column(name="EMP_OF_THE_MONTH") + private FCAppEmployee employeeOfTheMonth; + @Persistent(mappedBy="department") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppEmployee.class) + private transient Set employees = new HashSet(); + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppEmployee.class) + @Persistent(mappedBy="fundingDept") + private transient Set fundedEmps = new HashSet(); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCAppDepartment() {} + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + */ + public FCAppDepartment(long deptid, String name) { + this.deptid = deptid; + this.name = name; } - return false; - } - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) deptid; - } + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + * @param company The company that the department is associated with. + */ + public FCAppDepartment(long deptid, String name, ICompany company) { + this.deptid = deptid; + this.name = name; + this.company = (FCAppCompany)company; + } - /** The application identity class associated with the Department class. */ - public static class Oid implements Serializable, Comparable { + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + * @param company The company that the department is associated with. + * @param employeeOfTheMonth The employee of the month the + * department is associated with. + */ + public FCAppDepartment(long deptid, String name, ICompany company, + IEmployee employeeOfTheMonth) { + this.deptid = deptid; + this.name = name; + this.company = (FCAppCompany)company; + this.employeeOfTheMonth = (FCAppEmployee)employeeOfTheMonth; + } /** - * This field represents the application identifier field for the Department class. - * It must match in name and type with the field in the Department class. + * Set the id associated with this object. + * @param id the id. */ - public long deptid; + public void setDeptid(long id) { + if (this.deptid != 0) + throw new IllegalStateException("Id is already set."); + this.deptid = id; + } - /** The required public, no-arg constructor. */ - public Oid() {} + /** + * Get the department id. + * @return The department id. + */ + public long getDeptid() { + return deptid; + } /** - * A constructor to initialize the identifier field. - * - * @param deptid the deptid of the Department. + * Get the name of the department. + * @return The name of the department. */ - public Oid(long deptid) { - this.deptid = deptid; + public String getName() { + return name; } - public Oid(String s) { - deptid = Long.parseLong(justTheId(s)); + /** + * Set the name of the department. + * @param name The name to set for the department. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Get the company associated with the department. + * @return The company. + */ + public ICompany getCompany() { + return company; + } + + /** + * Set the company for the department. + * @param company The company to associate with the department. + */ + public void setCompany(ICompany company) { + this.company = (FCAppCompany)company; + } + + /** + * Get the employee of the month associated with the department. + * @return The employee of the month. + */ + public IEmployee getEmployeeOfTheMonth() { + return employeeOfTheMonth; + } + + /** + * Set the employee of the month for the department. + * @param employeeOfTheMonth The employee of the month to + * associate with the department. + */ + public void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth) { + this.employeeOfTheMonth = (FCAppEmployee)employeeOfTheMonth; + } + + /** + * Get the employees in the department as an unmodifiable set. + * @return The set of employees in the department, as an unmodifiable + * set. + */ + public Set getEmployees() { + return Collections.unmodifiableSet(employees); + } + + /** + * Add an employee to the department. + * @param emp The employee to add to the department. + */ + public void addEmployee(FCAppEmployee emp) { + employees.add(emp); + } + + /** + * Remove an employee from the department. + * @param emp The employee to remove from the department. + */ + public void removeEmployee(FCAppEmployee emp) { + employees.remove(emp); } + /** + * Set the employees to be in this department. + * @param employees The set of employees for this department. + */ + public void setEmployees(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.employees = (employees != null) ? new HashSet(employees) : null; + } + + /** + * Get the funded employees in the department as an unmodifiable set. + * @return The set of funded employees in the department, as an + * unmodifiable set. + */ + public Set getFundedEmps() { + return Collections.unmodifiableSet(fundedEmps); + } + + /** + * Add an employee to the collection of funded employees of this + * department. + * @param emp The employee to add to the department. + */ + public void addFundedEmp(FCAppEmployee emp) { + fundedEmps.add(emp); + } + + /** + * Remove an employee from collection of funded employees of this + * department. + * @param emp The employee to remove from the department. + */ + public void removeFundedEmp(FCAppEmployee emp) { + fundedEmps.remove(emp); + } + + /** + * Set the funded employees to be in this department. + * @param employees The set of funded employees for this department. + */ + public void setFundedEmps(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.fundedEmps = (fundedEmps != null) ? new HashSet(employees) : null; + } + + @Override + public List getMeetingRooms() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setMeetingRooms(List rooms) { + // TODO Auto-generated method stub + + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + employees = new HashSet(); + fundedEmps = new HashSet(); + } + + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other FCAppDepartment. + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCAppDepartment otherDept = (FCAppDepartment)other; + String where = "FCDepartment<" + deptid + ">"; + return + helper.equals(deptid, otherDept.getDeptid(), where + ".deptid") & + helper.equals(name, otherDept.getName(), where + ".name") & + helper.deepEquals(company, otherDept.getCompany(), where + ".company") & + helper.deepEquals(employeeOfTheMonth, otherDept.getEmployeeOfTheMonth(), where + ".employeeOfTheMonth") & + helper.deepEquals(employees, otherDept.getEmployees(), where + ".employees") & + helper.deepEquals(fundedEmps, otherDept.getFundedEmps(), where + ".fundedEmps"); + } + + /** + * Returns a String representation of a FCAppDepartment object. + * + * @return a String representation of a FCAppDepartment object. + */ public String toString() { - return this.getClass().getName() + ": " + deptid; + return "FCDepartment(" + getFieldRepr()+ ")"; } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.deptid != o.deptid) return (false); - return (true); + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(deptid); + rc.append(", name ").append(name); + return rc.toString(); } - /** */ - public int hashCode() { - return ((int) deptid); + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((FCAppDepartment)o); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((FCAppDepartment)o1, (FCAppDepartment)o2); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (deptid < other.deptid) return -1; - if (deptid > other.deptid) return 1; - return 0; + /** + * Compares this object with the specified Department object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Department object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified + * Department object. + */ + public int compareTo(FCAppDepartment other) { + return compare(this, other); + } + + /** + * Compares its two IDepartment arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IDepartment object to be compared. + * @param o2 the second IDepartment object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(FCAppDepartment o1, FCAppDepartment o2) { + return EqualityHelper.compare(o1.getDeptid(), o2.getDeptid()); } - } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof FCAppDepartment) { + return compareTo((FCAppDepartment)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)deptid; + } + + /** + * The application identity class associated with the + * Department class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the application identifier field + * for the Department class. + * It must match in name and type with the field in the + * Department class. + */ + public long deptid; + + /** + * The required public, no-arg constructor. + */ + public Oid() { } + + /** + * A constructor to initialize the identifier field. + * @param deptid the deptid of the Department. + */ + public Oid(long deptid) { + this.deptid = deptid; + } + + public Oid(String s) { deptid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + deptid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.deptid != o.deptid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) deptid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( deptid < other.deptid ) return -1; + if( deptid > other.deptid ) return 1; + return 0; + } + + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppEmployee.java index 677b07e6f..e0cdae67d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppEmployee.java @@ -5,545 +5,511 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; -import java.io.IOException; +import javax.jdo.annotations.*; + import java.io.ObjectInputStream; +import java.io.IOException; + import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.Persistent; import org.apache.jdo.tck.pc.company.IAddress; import org.apache.jdo.tck.pc.company.IDentalInsurance; import org.apache.jdo.tck.pc.company.IDepartment; + import org.apache.jdo.tck.pc.company.IEmployee; import org.apache.jdo.tck.pc.company.IMedicalInsurance; + import org.apache.jdo.tck.pc.compositeAnnotation.ApplicationIdDiscriminatorClassName; + import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents an employee. */ -@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE) +/** + * This class represents an employee. + */ +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) @ApplicationIdDiscriminatorClassName public abstract class FCAppEmployee extends FCAppPerson implements IEmployee { - @Column(name = "HIREDATE") - private Date hiredate; - - @Column(name = "WEEKLYHOURS") - private double weeklyhours; - - @Persistent(mappedBy = "employee") - private FCAppDentalInsurance dentalInsurance; - - @Persistent(mappedBy = "employee") - private FCAppMedicalInsurance medicalInsurance; - - @Column(name = "DEPARTMENT") - private FCAppDepartment department; - - @Column(name = "FUNDINGDEPT") - private FCAppDepartment fundingDept; - - @Column(name = "MANAGER") - private FCAppEmployee manager; - - @Column(name = "MENTOR") - private FCAppEmployee mentor; - - @Persistent(mappedBy = "mentor") - private FCAppEmployee protege; - - @Column(name = "HRADVISOR") - private FCAppEmployee hradvisor; - - @Persistent(mappedBy = "reviewers") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppProject.class) - private transient Set reviewedProjects = new HashSet(); - - @Persistent(mappedBy = "members") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppProject.class) - private transient Set projects = new HashSet(); - - @Persistent(mappedBy = "manager") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppEmployee.class) - private transient Set team = new HashSet(); - - @Persistent(mappedBy = "hradvisor") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppEmployee.class) - private transient Set hradvisees = new HashSet(); - - /** This is the JDO-required no-args constructor */ - protected FCAppEmployee() {} - - /** - * Construct an FCAppEmployee instance. - * - * @param personid The identifier for the person. - * @param firstname The first name of the employee. - * @param lastname The last name of the employee. - * @param middlename The middle name of the employee. - * @param birthdate The birth date of the employee. - * @param hiredate The date that the employee was hired. - */ - public FCAppEmployee( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - Date hiredate) { - super(personid, firstname, lastname, middlename, birthdate); - this.hiredate = hiredate; - } - - /** - * Construct an FCAppEmployee instance. - * - * @param personid The identifier for the person. - * @param firstname The first name of the employee. - * @param lastname The last name of the employee. - * @param middlename The middle name of the employee. - * @param birthdate The birth date of the employee. - * @param address The address of the employee. - * @param hiredate The date that the employee was hired. - */ - public FCAppEmployee( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - IAddress address, - Date hiredate) { - super(personid, firstname, lastname, middlename, birthdate, (FCAppAddress) address); - this.hiredate = hiredate; - } - - /** - * Get the date that the employee was hired. - * - * @return The date the employee was hired. - */ - public Date getHiredate() { - return hiredate; - } - - /** - * Set the date that the employee was hired. - * - * @param hiredate The date the employee was hired. - */ - public void setHiredate(Date hiredate) { - this.hiredate = hiredate; - } - - /** - * Get the weekly hours of the employee. - * - * @return The number of hours per week that the employee works. - */ - public double getWeeklyhours() { - return weeklyhours; - } - - /** - * Set the number of hours per week that the employee works. - * - * @param weeklyhours The number of hours per week that the employee works. - */ - public void setWeeklyhours(double weeklyhours) { - this.weeklyhours = weeklyhours; - } - - /** - * Get the reviewed projects. - * - * @return The reviewed projects as an unmodifiable set. - */ - public Set getReviewedProjects() { - return Collections.unmodifiableSet(reviewedProjects); - } - - /** - * Add a reviewed project. - * - * @param project A reviewed project. - */ - public void addReviewedProjects(FCAppProject project) { - reviewedProjects.add(project); - } - - /** - * Remove a reviewed project. - * - * @param project A reviewed project. - */ - public void removeReviewedProject(FCAppProject project) { - reviewedProjects.remove(project); - } - - /** - * Set the reviewed projects for the employee. - * - * @param reviewedProjects The set of reviewed projects. - */ - public void setReviewedProjects(Set reviewedProjects) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.reviewedProjects = (reviewedProjects != null) ? new HashSet(reviewedProjects) : null; - } - - /** - * Get the employee's projects. - * - * @return The employee's projects are returned as an unmodifiable set. - */ - public Set getProjects() { - return Collections.unmodifiableSet(projects); - } - - /** - * Add a project for the employee. - * - * @param project The project. - */ - public void addProject(FCAppProject project) { - projects.add(project); - } - - /** - * Remove a project from an employee's set of projects. - * - * @param project The project. - */ - public void removeProject(FCAppProject project) { - projects.remove(project); - } - - /** - * Set the projects for the employee. - * - * @param projects The set of projects of the employee. - */ - public void setProjects(Set projects) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.projects = (projects != null) ? new HashSet(projects) : null; - } - - /** - * Get the dental insurance of the employee. - * - * @return The employee's dental insurance. - */ - public IDentalInsurance getDentalInsurance() { - return dentalInsurance; - } - - /** - * Set the dental insurance object for the employee. - * - * @param dentalInsurance The dental insurance object to associate with the employee. - */ - public void setDentalInsurance(IDentalInsurance dentalInsurance) { - this.dentalInsurance = (FCAppDentalInsurance) dentalInsurance; - } - /** - * Get the medical insurance of the employee. - * - * @return The employee's medical insurance. - */ - public IMedicalInsurance getMedicalInsurance() { - return medicalInsurance; - } - - /** - * Set the medical insurance object for the employee. - * - * @param medicalInsurance The medical insurance object to associate with the employee. - */ - public void setMedicalInsurance(IMedicalInsurance medicalInsurance) { - this.medicalInsurance = (FCAppMedicalInsurance) medicalInsurance; - } - - /** - * Get the employee's department. - * - * @return The department associated with the employee. - */ - public IDepartment getDepartment() { - return department; - } - - /** - * Set the employee's department. - * - * @param department The department. - */ - public void setDepartment(IDepartment department) { - this.department = (FCAppDepartment) department; - } - - /** - * Get the employee's funding department. - * - * @return The funding department associated with the employee. - */ - public IDepartment getFundingDept() { - return fundingDept; - } - - /** - * Set the employee's funding department. - * - * @param department The funding department. - */ - public void setFundingDept(IDepartment department) { - this.fundingDept = (FCAppDepartment) department; - } - - /** - * Get the employee's manager. - * - * @return The employee's manager. - */ - public IEmployee getManager() { - return manager; - } - - /** - * Set the employee's manager. - * - * @param manager The employee's manager. - */ - public void setManager(IEmployee manager) { - this.manager = (FCAppEmployee) manager; - } - - /** - * Get the employee's team. - * - * @return The set of FCAppEmployees on this employee's team, returned as an - * unmodifiable set. - */ - public Set getTeam() { - return Collections.unmodifiableSet(team); - } - - /** - * Add an FCAppEmployee to this employee's team. This method sets both sides of the - * relationship, modifying this employees team to include parameter emp and modifying emp to set - * its manager attribute to this object. - * - * @param emp The FCAppEmployee to add to the team. - */ - public void addToTeam(FCAppEmployee emp) { - team.add(emp); - emp.manager = this; - } - - /** - * Remove an FCAppEmployee from this employee's team. This method will also set the - * emp manager to null. - * - * @param emp The FCAppEmployee to remove from the team. - */ - public void removeFromTeam(FCAppEmployee emp) { - team.remove(emp); - emp.manager = null; - } - - /** - * Set the employee's team. - * - * @param team The set of FCAppEmployees. - */ - public void setTeam(Set team) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.team = (team != null) ? new HashSet(team) : null; - } - - /** - * Set the mentor for this employee. - * - * @param mentor The mentor for this employee. - */ - public void setMentor(IEmployee mentor) { - this.mentor = (FCAppEmployee) mentor; - } - - /** - * Get the mentor for this employee. - * - * @return The mentor. - */ - public IEmployee getMentor() { - return mentor; - } - - /** - * Set the protege for this employee. - * - * @param protege The protege for this employee. - */ - public void setProtege(IEmployee protege) { - this.protege = (FCAppEmployee) protege; - } - - /** - * Get the protege of this employee. - * - * @return The protege of this employee. - */ - public IEmployee getProtege() { - return protege; - } - - /** - * Set the HR advisor for this employee. - * - * @param hradvisor The hradvisor for this employee. - */ - public void setHradvisor(IEmployee hradvisor) { - this.hradvisor = (FCAppEmployee) hradvisor; - } - - /** - * Get the HR advisor for the employee. - * - * @return The HR advisor. - */ - public IEmployee getHradvisor() { - return hradvisor; - } - - /** - * Get the HR advisees of this HR advisor. - * - * @return An unmodifiable Set containing the FCAppEmployees that are HR - * advisees of this employee. - */ - public Set getHradvisees() { - return Collections.unmodifiableSet(hradvisees); - } - - /** - * Add an FCAppEmployee as an advisee of this HR advisor. This method also sets the - * emp hradvisor to reference this object. In other words, both sides of the - * relationship are set. - * - * @param emp The employee to add as an advisee. - */ - public void addAdvisee(FCAppEmployee emp) { - hradvisees.add(emp); - emp.hradvisor = this; - } - - /** - * Remove an FCAppEmployee as an advisee of this HR advisor. This method also sets - * the emp hradvisor to null. In other words, both sides of the relationship are set. - * - * @param emp The employee to add as an HR advisee. - */ - public void removeAdvisee(FCAppEmployee emp) { - hradvisees.remove(emp); - emp.hradvisor = null; - } - - /** - * Set the HR advisees of this HR advisor. - * - * @param hradvisees The FCAppEmployees that are HR advisees of this employee. - */ - public void setHradvisees(Set hradvisees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.hradvisees = (hradvisees != null) ? new HashSet(hradvisees) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - reviewedProjects = new HashSet(); - projects = new HashSet(); - team = new HashSet(); - hradvisees = new HashSet(); - } - - /** - * Return a String representation of a FCAppEmployee object. - * - * @return a String representation of a FCAppEmployee object. - */ - public String toString() { - return "FCEmployee(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", hired ").append(hiredate == null ? "null" : formatter.format(hiredate)); - rc.append(", weeklyhours ").append(weeklyhours); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the - * corresponding fields of the specified FCAppEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCAppEmployee otherEmp = (FCAppEmployee) other; - String where = "Employee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.equals(hiredate, otherEmp.getHiredate(), where + ".hiredate") - & helper.closeEnough(weeklyhours, otherEmp.getWeeklyhours(), where + ".weeklyhours") - & helper.deepEquals( - dentalInsurance, otherEmp.getDentalInsurance(), where + ".dentalInsurance") - & helper.deepEquals( - medicalInsurance, otherEmp.getMedicalInsurance(), where + ".medicalInsurance") - & helper.deepEquals(department, otherEmp.getDepartment(), where + ".department") - & helper.deepEquals(fundingDept, otherEmp.getFundingDept(), where + ".fundingDept") - & helper.deepEquals(manager, otherEmp.getManager(), where + ".manager") - & helper.deepEquals(mentor, otherEmp.getMentor(), where + ".mentor") - & helper.deepEquals(protege, otherEmp.getProtege(), where + ".protege") - & helper.deepEquals(hradvisor, otherEmp.getHradvisor(), where + ".hradvisor") - & helper.deepEquals( - reviewedProjects, otherEmp.getReviewedProjects(), where + ".reviewedProjects") - & helper.deepEquals(projects, otherEmp.getProjects(), where + ".projects") - & helper.deepEquals(team, otherEmp.getTeam(), where + ".team") - & helper.deepEquals(hradvisees, otherEmp.getHradvisees(), where + ".hradvisees"); - } + @Column(name="HIREDATE") + private Date hiredate; + @Column(name="WEEKLYHOURS") + private double weeklyhours; + @Persistent(mappedBy="employee") + private FCAppDentalInsurance dentalInsurance; + @Persistent(mappedBy="employee") + private FCAppMedicalInsurance medicalInsurance; + @Column(name="DEPARTMENT") + private FCAppDepartment department; + @Column(name="FUNDINGDEPT") + private FCAppDepartment fundingDept; + @Column(name="MANAGER") + private FCAppEmployee manager; + @Column(name="MENTOR") + private FCAppEmployee mentor; + @Persistent(mappedBy="mentor") + private FCAppEmployee protege; + @Column(name="HRADVISOR") + private FCAppEmployee hradvisor; + @Persistent(mappedBy="reviewers") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppProject.class) + private transient Set reviewedProjects = new HashSet(); + @Persistent(mappedBy="members") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppProject.class) + private transient Set projects = new HashSet(); + @Persistent(mappedBy="manager") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppEmployee.class) + private transient Set team = new HashSet(); + @Persistent(mappedBy="hradvisor") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppEmployee.class) + private transient Set hradvisees = new HashSet(); + + /** This is the JDO-required no-args constructor */ + protected FCAppEmployee() {} + + /** + * Construct an FCAppEmployee instance. + * + * @param personid The identifier for the person. + * @param firstname The first name of the employee. + * @param lastname The last name of the employee. + * @param middlename The middle name of the employee. + * @param birthdate The birth date of the employee. + * @param hiredate The date that the employee was hired. + */ + public FCAppEmployee(long personid, String firstname, String lastname, + String middlename, Date birthdate, + Date hiredate) { + super(personid, firstname, lastname, middlename, birthdate); + this.hiredate = hiredate; + } + + /** + * Construct an FCAppEmployee instance. + * + * @param personid The identifier for the person. + * @param firstname The first name of the employee. + * @param lastname The last name of the employee. + * @param middlename The middle name of the employee. + * @param birthdate The birth date of the employee. + * @param address The address of the employee. + * @param hiredate The date that the employee was hired. + */ + public FCAppEmployee(long personid, String firstname, String lastname, + String middlename, Date birthdate, IAddress address, + Date hiredate) { + super(personid, firstname, lastname, middlename, birthdate, + (FCAppAddress)address); + this.hiredate = hiredate; + } + + /** + * Get the date that the employee was hired. + * @return The date the employee was hired. + */ + public Date getHiredate() { + return hiredate; + } + + /** + * Set the date that the employee was hired. + * @param hiredate The date the employee was hired. + */ + public void setHiredate(Date hiredate) { + this.hiredate = hiredate; + } + + /** + * Get the weekly hours of the employee. + * @return The number of hours per week that the employee works. + */ + public double getWeeklyhours() { + return weeklyhours; + } + + /** + * Set the number of hours per week that the employee works. + * @param weeklyhours The number of hours per week that the employee + * works. + */ + public void setWeeklyhours(double weeklyhours) { + this.weeklyhours = weeklyhours; + } + + /** + * Get the reviewed projects. + * @return The reviewed projects as an unmodifiable set. + */ + public Set getReviewedProjects() { + return Collections.unmodifiableSet(reviewedProjects); + } + + /** + * Add a reviewed project. + * @param project A reviewed project. + */ + public void addReviewedProjects(FCAppProject project) { + reviewedProjects.add(project); + } + + /** + * Remove a reviewed project. + * @param project A reviewed project. + */ + public void removeReviewedProject(FCAppProject project) { + reviewedProjects.remove(project); + } + + /** + * Set the reviewed projects for the employee. + * @param reviewedProjects The set of reviewed projects. + */ + public void setReviewedProjects(Set reviewedProjects) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.reviewedProjects = + (reviewedProjects != null) ? new HashSet(reviewedProjects) : null; + } + + /** + * Get the employee's projects. + * @return The employee's projects are returned as an unmodifiable + * set. + */ + public Set getProjects() { + return Collections.unmodifiableSet(projects); + } + + /** + * Add a project for the employee. + * @param project The project. + */ + public void addProject(FCAppProject project) { + projects.add(project); + } + + /** + * Remove a project from an employee's set of projects. + * @param project The project. + */ + public void removeProject(FCAppProject project) { + projects.remove(project); + } + + /** + * Set the projects for the employee. + * @param projects The set of projects of the employee. + */ + public void setProjects(Set projects) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.projects = (projects != null) ? new HashSet(projects) : null; + } + + /** + * Get the dental insurance of the employee. + * @return The employee's dental insurance. + */ + public IDentalInsurance getDentalInsurance() { + return dentalInsurance; + } + + /** + * Set the dental insurance object for the employee. + * @param dentalInsurance The dental insurance object to associate with + * the employee. + */ + public void setDentalInsurance(IDentalInsurance dentalInsurance) { + this.dentalInsurance = (FCAppDentalInsurance)dentalInsurance; + } + /** + * Get the medical insurance of the employee. + * @return The employee's medical insurance. + */ + public IMedicalInsurance getMedicalInsurance() { + return medicalInsurance; + } + + /** + * Set the medical insurance object for the employee. + * @param medicalInsurance The medical insurance object to associate + * with the employee. + */ + public void setMedicalInsurance(IMedicalInsurance medicalInsurance) { + this.medicalInsurance = (FCAppMedicalInsurance)medicalInsurance; + } + + /** + * Get the employee's department. + * @return The department associated with the employee. + */ + public IDepartment getDepartment() { + return department; + } + + /** + * Set the employee's department. + * @param department The department. + */ + public void setDepartment(IDepartment department) { + this.department = (FCAppDepartment)department; + } + + /** + * Get the employee's funding department. + * @return The funding department associated with the employee. + */ + public IDepartment getFundingDept() { + return fundingDept; + } + + /** + * Set the employee's funding department. + * @param department The funding department. + */ + public void setFundingDept(IDepartment department) { + this.fundingDept = (FCAppDepartment)department; + } + + /** + * Get the employee's manager. + * @return The employee's manager. + */ + public IEmployee getManager() { + return manager; + } + + /** + * Set the employee's manager. + * @param manager The employee's manager. + */ + public void setManager(IEmployee manager) { + this.manager = (FCAppEmployee)manager; + } + + /** + * Get the employee's team. + * + * @return The set of FCAppEmployees on this employee's team, + * returned as an unmodifiable set. + */ + public Set getTeam() { + return Collections.unmodifiableSet(team); + } + + /** + * Add an FCAppEmployee to this employee's team. + * This method sets both sides of the relationship, modifying + * this employees team to include parameter emp and modifying + * emp to set its manager attribute to this object. + * + * @param emp The FCAppEmployee to add to the team. + */ + public void addToTeam(FCAppEmployee emp) { + team.add(emp); + emp.manager = this; + } + + /** + * Remove an FCAppEmployee from this employee's team. + * This method will also set the emp manager to null. + * + * @param emp The FCAppEmployee to remove from the team. + */ + public void removeFromTeam(FCAppEmployee emp) { + team.remove(emp); + emp.manager = null; + } + + /** + * Set the employee's team. + * + * @param team The set of FCAppEmployees. + */ + public void setTeam(Set team) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.team = (team != null) ? new HashSet(team) : null; + } + + /** + * Set the mentor for this employee. + * @param mentor The mentor for this employee. + */ + public void setMentor(IEmployee mentor) { + this.mentor = (FCAppEmployee)mentor; + } + + /** + * Get the mentor for this employee. + * @return The mentor. + */ + public IEmployee getMentor() { + return mentor; + } + + /** + * Set the protege for this employee. + * @param protege The protege for this employee. + */ + public void setProtege(IEmployee protege) { + this.protege = (FCAppEmployee)protege; + } + + /** + * Get the protege of this employee. + * @return The protege of this employee. + */ + public IEmployee getProtege() { + return protege; + } + + /** + * Set the HR advisor for this employee. + * @param hradvisor The hradvisor for this employee. + */ + public void setHradvisor(IEmployee hradvisor) { + this.hradvisor = (FCAppEmployee)hradvisor; + } + + /** + * Get the HR advisor for the employee. + * @return The HR advisor. + */ + public IEmployee getHradvisor() { + return hradvisor; + } + + /** + * Get the HR advisees of this HR advisor. + * + * @return An unmodifiable Set containing the + * FCAppEmployees that are HR advisees of this employee. + */ + public Set getHradvisees() { + return Collections.unmodifiableSet(hradvisees); + } + + /** + * Add an FCAppEmployee as an advisee of this HR advisor. + * This method also sets the emp hradvisor to reference + * this object. In other words, both sides of the relationship are + * set. + * + * @param emp The employee to add as an advisee. + */ + public void addAdvisee(FCAppEmployee emp) { + hradvisees.add(emp); + emp.hradvisor = this; + } + + /** + * Remove an FCAppEmployee as an advisee of this HR advisor. + * This method also sets the emp hradvisor to null. + * In other words, both sides of the relationship are set. + * + * @param emp The employee to add as an HR advisee. + */ + public void removeAdvisee(FCAppEmployee emp) { + hradvisees.remove(emp); + emp.hradvisor = null; + } + + /** + * Set the HR advisees of this HR advisor. + * + * @param hradvisees The FCAppEmployees that are HR advisees of + * this employee. + */ + public void setHradvisees(Set hradvisees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.hradvisees = (hradvisees != null) ? new HashSet(hradvisees) : null; + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + reviewedProjects = new HashSet(); + projects = new HashSet(); + team = new HashSet(); + hradvisees = new HashSet(); + } + + /** + * Return a String representation of a FCAppEmployee object. + * + * @return a String representation of a FCAppEmployee object. + */ + public String toString() { + return "FCEmployee(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", hired ").append( + hiredate==null ? "null" : formatter.format(hiredate)); + rc.append(", weeklyhours ").append(weeklyhours); + return rc.toString(); + } + + /** + * + * Returns true if all the fields of this instance are + * deep equal to the corresponding fields of the specified FCAppEmployee. + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCAppEmployee otherEmp = (FCAppEmployee)other; + String where = "Employee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.equals(hiredate, otherEmp.getHiredate(), where + ".hiredate") & + helper.closeEnough(weeklyhours, otherEmp.getWeeklyhours(), where + ".weeklyhours") & + helper.deepEquals(dentalInsurance, otherEmp.getDentalInsurance(), where + ".dentalInsurance") & + helper.deepEquals(medicalInsurance, otherEmp.getMedicalInsurance(), where + ".medicalInsurance") & + helper.deepEquals(department, otherEmp.getDepartment(), where + ".department") & + helper.deepEquals(fundingDept, otherEmp.getFundingDept(), where + ".fundingDept") & + helper.deepEquals(manager, otherEmp.getManager(), where + ".manager") & + helper.deepEquals(mentor, otherEmp.getMentor(), where + ".mentor") & + helper.deepEquals(protege, otherEmp.getProtege(), where + ".protege") & + helper.deepEquals(hradvisor, otherEmp.getHradvisor(), where + ".hradvisor") & + helper.deepEquals(reviewedProjects, otherEmp.getReviewedProjects(), where + ".reviewedProjects") & + helper.deepEquals(projects, otherEmp.getProjects(), where + ".projects") & + helper.deepEquals(team, otherEmp.getTeam(), where + ".team") & + helper.deepEquals(hradvisees, otherEmp.getHradvisees(), where + ".hradvisees"); + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppFullTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppFullTimeEmployee.java index a77d7cf38..0991d875f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppFullTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppFullTimeEmployee.java @@ -5,137 +5,133 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; +import javax.jdo.annotations.*; + import java.util.Date; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.PersistenceCapable; import org.apache.jdo.tck.pc.company.IAddress; + import org.apache.jdo.tck.pc.company.IFullTimeEmployee; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a full-time employee. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION) -@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE) -public class FCAppFullTimeEmployee extends FCAppEmployee implements IFullTimeEmployee { - - @Column(name = "SALARY") - private double salary; - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FCAppFullTimeEmployee() {} +/** + * This class represents a full-time employee. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION) +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) +public class FCAppFullTimeEmployee extends FCAppEmployee + implements IFullTimeEmployee { - /** - * Construct a full-time employee. - * - * @param personid The person identifier. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param hired The date that the person was hired. - * @param sal The salary of the full-time employee. - */ - public FCAppFullTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double sal) { - super(personid, first, last, middle, born, hired); - salary = sal; - } + @Column(name="SALARY") + private double salary; - /** - * Construct a full-time employee. - * - * @param personid The person identifier. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param addr The person's address. - * @param hired The date that the person was hired. - * @param sal The salary of the full-time employee. - */ - public FCAppFullTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - IAddress addr, - Date hired, - double sal) { - super(personid, first, last, middle, born, (FCAppAddress) addr, hired); - salary = sal; - } + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCAppFullTimeEmployee() {} - /** - * Get the salary of the full time employee. - * - * @return The salary of the full time employee. - */ - public double getSalary() { - return salary; - } + /** + * Construct a full-time employee. + * @param personid The person identifier. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param hired The date that the person was hired. + * @param sal The salary of the full-time employee. + */ + public FCAppFullTimeEmployee(long personid, String first, String last, + String middle, Date born, + Date hired, double sal) { + super(personid, first, last, middle, born, hired); + salary = sal; + } - /** - * Set the salary for the full-time employee. - * - * @param salary The salary to set for the full-time employee. - */ - public void setSalary(double salary) { - this.salary = salary; - } + /** + * Construct a full-time employee. + * @param personid The person identifier. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param addr The person's address. + * @param hired The date that the person was hired. + * @param sal The salary of the full-time employee. + */ + public FCAppFullTimeEmployee(long personid, String first, String last, + String middle, Date born, IAddress addr, + Date hired, double sal) { + super(personid, first, last, middle, born, (FCAppAddress)addr, hired); + salary = sal; + } - /** - * Return a String representation of a FCAppFullTimeEmployee object. - * - * @return a String representation of a FCAppFullTimeEmployee object. - */ - public String toString() { - return "FCFullTimeEmployee(" + getFieldRepr() + ")"; - } + /** + * Get the salary of the full time employee. + * @return The salary of the full time employee. + */ + public double getSalary() { + return salary; + } + + /** + * Set the salary for the full-time employee. + * @param salary The salary to set for the full-time employee. + */ + public void setSalary(double salary) { + this.salary = salary; + } + + /** + * Return a String representation of a FCAppFullTimeEmployee object. + * + * @return a String representation of a FCAppFullTimeEmployee object. + */ + public String toString() { + return "FCFullTimeEmployee(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - public String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", $").append(salary); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + public String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", $").append(salary); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified FCAppFullTimeEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCAppFullTimeEmployee otherEmp = (FCAppFullTimeEmployee) other; - String where = "FCFullTimeEmployee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.closeEnough(salary, otherEmp.getSalary(), where + ".salary"); - } + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified + * FCAppFullTimeEmployee. + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCAppFullTimeEmployee otherEmp = (FCAppFullTimeEmployee)other; + String where = "FCFullTimeEmployee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.closeEnough(salary, otherEmp.getSalary(), where + ".salary"); + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppInsurance.java index 97aae4195..68ba1c88e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppInsurance.java @@ -5,304 +5,296 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; +import javax.jdo.annotations.*; + import java.io.Serializable; + import java.util.Comparator; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Index; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.PrimaryKey; import org.apache.jdo.tck.pc.company.IEmployee; + import org.apache.jdo.tck.pc.company.IInsurance; import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; /** - * This class represents an insurance carrier selection for a particular FCAppEmployee. + * This class represents an insurance carrier selection for a particular + * FCAppEmployee. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION, table = "insuranceplans") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator( - strategy = DiscriminatorStrategy.CLASS_NAME, - column = "DISCRIMINATOR", - indexed = "true") -@Index( - name = "INS_DISCRIMINATOR_INDEX", - unique = "false", - columns = @Column(name = "DISCRIMINATOR")) -public class FCAppInsurance - implements IInsurance, Serializable, Comparable, Comparator, DeepEquality { - - @PrimaryKey - @Column(name = "INSID") - private long insid; - - @Column(name = "CARRIER") - private String carrier; - - @Column(name = "EMPLOYEE") - private FCAppEmployee employee; - - /** This is the JDO-required no-args constructor. */ - protected FCAppInsurance() {} - - /** - * Construct an FCAppInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - */ - protected FCAppInsurance(long insid, String carrier) { - this.insid = insid; - this.carrier = carrier; - } - - /** - * Construct an FCAppInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param employee The employee associated with this insurance. - */ - protected FCAppInsurance(long insid, String carrier, IEmployee employee) { - this.insid = insid; - this.carrier = carrier; - this.employee = (FCAppEmployee) employee; - } - - /** - * Get the insurance ID. - * - * @return the insurance ID. - */ - public long getInsid() { - return insid; - } - - /** - * Set the insurance ID. - * - * @param id The insurance ID value. - */ - public void setInsid(long id) { - if (this.insid != 0) throw new IllegalStateException("Id is already set."); - this.insid = id; - } - - /** - * Get the insurance carrier. - * - * @return The insurance carrier. - */ - public String getCarrier() { - return carrier; - } - - /** - * Set the insurance carrier. - * - * @param carrier The insurance carrier. - */ - public void setCarrier(String carrier) { - this.carrier = carrier; - } - - /** - * Get the associated employee. - * - * @return The employee for this insurance. - */ - public IEmployee getEmployee() { - return employee; - } - - /** - * Set the associated employee. - * - * @param employee The associated employee. - */ - public void setEmployee(IEmployee employee) { - this.employee = (FCAppEmployee) employee; - } +@PersistenceCapable(identityType=IdentityType.APPLICATION,table="insuranceplans" ) +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR", indexed="true") +@Index(name="INS_DISCRIMINATOR_INDEX", unique="false", + columns=@Column(name="DISCRIMINATOR")) +public class FCAppInsurance + implements IInsurance, Serializable, Comparable, Comparator, DeepEquality { + + @PrimaryKey + @Column(name="INSID") + private long insid; + @Column(name="CARRIER") + private String carrier; + @Column(name="EMPLOYEE") + private FCAppEmployee employee; + + /** This is the JDO-required no-args constructor. */ + protected FCAppInsurance() {} - /** - * Returns a String representation of a FCAppInsurance object. - * - * @return a String representation of a FCAppInsurance object. - */ - public String toString() { - return "FCInsurance(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(insid); - rc.append(", carrier ").append(carrier); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Object. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCAppInsurance otherIns = (FCAppInsurance) other; - String where = "FCInsurance<" + insid + ">"; - return helper.equals(insid, otherIns.getInsid(), where + ".insid") - & helper.equals(carrier, otherIns.getCarrier(), where + ".carrier") - & helper.deepEquals(employee, otherIns.getEmployee(), where + ".employee"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((FCAppInsurance) o); - } + /** + * Construct an FCAppInsurance instance. + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + */ + protected FCAppInsurance(long insid, String carrier) { + this.insid = insid; + this.carrier = carrier; + } - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((FCAppInsurance) o1, (FCAppInsurance) o2); - } + /** + * Construct an FCAppInsurance instance. + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + */ + protected FCAppInsurance(long insid, String carrier, IEmployee employee) { + this.insid = insid; + this.carrier = carrier; + this.employee = (FCAppEmployee)employee; + } - /** - * Compares this object with the specified Insurance object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Insurance object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Insurance object. - */ - public int compareTo(FCAppInsurance other) { - return compare(this, other); - } + /** + * Get the insurance ID. + * @return the insurance ID. + */ + public long getInsid() { + return insid; + } - /** - * Compares its two IInsurance arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IInsurance object to be compared. - * @param o2 the second IInsurance object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(FCAppInsurance o1, FCAppInsurance o2) { - return EqualityHelper.compare(o1.getInsid(), o2.getInsid()); - } + /** + * Set the insurance ID. + * @param id The insurance ID value. + */ + public void setInsid(long id) { + if (this.insid != 0) + throw new IllegalStateException("Id is already set."); + this.insid = id; + } - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof FCAppInsurance) { - return compareTo((FCAppInsurance) obj) == 0; + /** + * Get the insurance carrier. + * @return The insurance carrier. + */ + public String getCarrier() { + return carrier; } - return false; - } - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) insid; - } + /** + * Set the insurance carrier. + * @param carrier The insurance carrier. + */ + public void setCarrier(String carrier) { + this.carrier = carrier; + } + + /** + * Get the associated employee. + * @return The employee for this insurance. + */ + public IEmployee getEmployee() { + return employee; + } - /** - * This class is used to represent the application identifier for the Insurance - * class. - */ - public static class Oid implements Serializable, Comparable { /** - * This field represents the application identifier for the Insurance class. It - * must match the field in the Insurance class in both name and type. + * Set the associated employee. + * @param employee The associated employee. */ - public long insid; + public void setEmployee(IEmployee employee) { + this.employee = (FCAppEmployee)employee; + } - /** The required public no-args constructor. */ - public Oid() {} + /** + * Returns a String representation of a FCAppInsurance object. + * + * @return a String representation of a FCAppInsurance object. + */ + public String toString() { + return "FCInsurance(" + getFieldRepr() + ")"; + } /** - * Initialize with an insurance identifier. - * - * @param insid the insurance ID. + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. */ - public Oid(long insid) { - this.insid = insid; + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(insid); + rc.append(", carrier ").append(carrier); + return rc.toString(); } - public Oid(String s) { - insid = Long.parseLong(justTheId(s)); + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCAppInsurance otherIns = (FCAppInsurance)other; + String where = "FCInsurance<" + insid + ">"; + return + helper.equals(insid, otherIns.getInsid(), where + ".insid") & + helper.equals(carrier, otherIns.getCarrier(), where + ".carrier") & + helper.deepEquals(employee, otherIns.getEmployee(), where + ".employee"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((FCAppInsurance)o); } - public String toString() { - return this.getClass().getName() + ": " + insid; + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((FCAppInsurance)o1, (FCAppInsurance)o2); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.insid != o.insid) return (false); - return (true); + /** + * Compares this object with the specified Insurance object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Insurance object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified + * Insurance object. + */ + public int compareTo(FCAppInsurance other) { + return compare(this, other); } - /** */ + /** + * Compares its two IInsurance arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IInsurance object to be compared. + * @param o2 the second IInsurance object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(FCAppInsurance o1, FCAppInsurance o2) { + return EqualityHelper.compare(o1.getInsid(), o2.getInsid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof FCAppInsurance) { + return compareTo((FCAppInsurance)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ public int hashCode() { - return ((int) insid); + return (int)insid; } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } + /** + * This class is used to represent the application + * identifier for the Insurance class. + */ + public static class Oid implements Serializable, Comparable + { + /** + * This field represents the application identifier for the + * Insurance class. It must match the field in the + * Insurance class in both name and type. + */ + public long insid; + + /** + * The required public no-args constructor. + */ + public Oid() { } + + /** + * Initialize with an insurance identifier. + * @param insid the insurance ID. + */ + public Oid(long insid) { + this.insid = insid; + } + + public Oid(String s) { insid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + insid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o=(Oid) obj; + if( this.insid!=o.insid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) insid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( insid < other.insid ) return -1; + if( insid > other.insid ) return 1; + return 0; + } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (insid < other.insid) return -1; - if (insid > other.insid) return 1; - return 0; } - } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppMedicalInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppMedicalInsurance.java index fe8004eca..dfd17240e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppMedicalInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppMedicalInsurance.java @@ -5,119 +5,123 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.PersistenceCapable; +import javax.jdo.annotations.*; import org.apache.jdo.tck.pc.company.IEmployee; + import org.apache.jdo.tck.pc.company.IMedicalInsurance; import org.apache.jdo.tck.util.EqualityHelper; /** - * This class represents a dental insurance carrier selection for a particular Employee - * . + * This class represents a dental insurance carrier selection for a + * particular Employee. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION) +@PersistenceCapable(identityType=IdentityType.APPLICATION) public class FCAppMedicalInsurance extends FCAppInsurance implements IMedicalInsurance { - @Column(name = "PLANTYPE") - private String planType; // possible values: "PPO", "EPO", "NPO" + @Column(name="PLANTYPE") + private String planType; // possible values: "PPO", "EPO", "NPO" - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FCAppMedicalInsurance() {} + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCAppMedicalInsurance() {} - /** - * Construct a FCAppMedicalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param planType The planType. - */ - public FCAppMedicalInsurance(long insid, String carrier, String planType) { - super(insid, carrier); - this.planType = planType; - } + /** + * Construct a FCAppMedicalInsurance instance. + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param planType The planType. + */ + public FCAppMedicalInsurance(long insid, String carrier, + String planType) + { + super(insid, carrier); + this.planType = planType; + } - /** - * Construct a FCAppMedicalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param employee The employee associated with this insurance. - * @param planType The planType. - */ - public FCAppMedicalInsurance(long insid, String carrier, IEmployee employee, String planType) { - super(insid, carrier, (FCAppEmployee) employee); - this.planType = planType; - } + /** + * Construct a FCAppMedicalInsurance instance. + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + * @param planType The planType. + */ + public FCAppMedicalInsurance(long insid, String carrier, + IEmployee employee, String planType) + { + super(insid, carrier, (FCAppEmployee)employee); + this.planType = planType; + } - /** - * Get the insurance planType. - * - * @return The insurance planType. - */ - public String getPlanType() { - return planType; - } + /** + * Get the insurance planType. + * @return The insurance planType. + */ + public String getPlanType() { + return planType; + } - /** - * Set the insurance planType. - * - * @param planType The insurance planType. - */ - public void setPlanType(String planType) { - this.planType = planType; - } + /** + * Set the insurance planType. + * @param planType The insurance planType. + */ + public void setPlanType(String planType) { + this.planType = planType; + } - /** - * Returns a String representation of a FCAppMedicalInsurance object. - * - * @return a String representation of a FCAppMedicalInsurance object. - */ - public String toString() { - return "FCMedicalInsurance(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of a FCAppMedicalInsurance + * object. + * + * @return a String representation of a FCAppMedicalInsurance + * object. + */ + public String toString() { + return "FCMedicalInsurance(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", planType ").append(planType); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", planType ").append(planType); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Object. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCAppMedicalInsurance otherIns = (FCAppMedicalInsurance) other; - String where = "FCMedicalInsurance<" + getInsid() + ">"; - return super.deepCompareFields(otherIns, helper) - & helper.equals(planType, otherIns.getPlanType(), where + ".planType"); - } + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCAppMedicalInsurance otherIns = (FCAppMedicalInsurance)other; + String where = "FCMedicalInsurance<" + getInsid() + ">"; + return super.deepCompareFields(otherIns, helper) & + helper.equals(planType, otherIns.getPlanType(), where + ".planType"); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppMeetingRoom.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppMeetingRoom.java index d9e0bda72..e48ad0c6d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppMeetingRoom.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppMeetingRoom.java @@ -5,264 +5,258 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; +import javax.jdo.annotations.*; + import java.io.Serializable; import java.util.Comparator; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; + import org.apache.jdo.tck.pc.company.IMeetingRoom; import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a meeting room. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION, table = "meetingrooms") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator(strategy = DiscriminatorStrategy.CLASS_NAME, column = "DISCRIMINATOR") -public class FCAppMeetingRoom +/** + * This class represents a meeting room. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION,table="meetingrooms") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") +public class FCAppMeetingRoom implements IMeetingRoom, Serializable, Comparable, Comparator, DeepEquality { - @Persistent(primaryKey = "true") - @Column(name = "ID") - private long roomid; - - @Column(name = "NAME", jdbcType = "VARCHAR") - private String name; - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FCAppMeetingRoom() {} - - /** - * This constructor initializes the FCAppMeetingRoom components. - * - * @param roomid The room ID. - * @param name The name of the room - */ - public FCAppMeetingRoom(long roomid, String name) { - this.roomid = roomid; - this.name = name; - } - - /** - * Get the room id associated with this object. - * - * @return the room id. - */ - public long getRoomid() { - return roomid; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setRoomid(long id) { - if (this.roomid != 0) throw new IllegalStateException("Id is already set."); - this.roomid = id; - } - - /** - * Get the name of the meeting room. - * - * @return The name of the meeting room. - */ - public String getName() { - return name; - } - - /** - * Set the name of the meeting room. - * - * @param name The name. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Returns a String representation of a Address object. - * - * @return a String representation of a FCAppMeetingRoom object. - */ - public String toString() { - return "FCAppMeetingRoom(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(roomid); - rc.append(", name ").append(name); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IMeetingRoom otherMeetingRoom = (IMeetingRoom) other; - String where = "FCAppMeetingRoom<" + roomid + ">"; - return helper.equals(roomid, otherMeetingRoom.getRoomid(), where + ".roomid") - & helper.equals(name, otherMeetingRoom.getName(), where + ".name"); - } + @Persistent(primaryKey="true") + @Column(name="ID") + private long roomid; + @Column(name="NAME", jdbcType="VARCHAR") + private String name; - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((IMeetingRoom) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((IMeetingRoom) o1, (IMeetingRoom) o2); - } - - /** - * Compares this object with the specified FCAppMeetingRoom object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The MeetingRoom object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified MeetingRoom object. - */ - public int compareTo(IMeetingRoom other) { - return compare(this, other); - } + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCAppMeetingRoom() {} - /** - * Compares its two IMeetingRoom arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IMeetingRoom object to be compared. - * @param o2 the second IMeetingRoom object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(IMeetingRoom o1, IMeetingRoom o2) { - return EqualityHelper.compare(o1.getRoomid(), o2.getRoomid()); - } + /** + * This constructor initializes the FCAppMeetingRoom components. + * @param roomid The room ID. + * @param name The name of the room + */ + public FCAppMeetingRoom(long roomid, String name) + { + this.roomid = roomid; + this.name = name; + } - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof IMeetingRoom) { - return compareTo((IMeetingRoom) obj) == 0; + /** + * Get the room id associated with this object. + * @return the room id. + */ + public long getRoomid() { + return roomid; } - return false; - } - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) roomid; - } + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setRoomid(long id) { + if (this.roomid != 0) + throw new IllegalStateException("Id is already set."); + this.roomid = id; + } - /** - * This class is used to represent the application identifier for the FCAppMeetingRoom - * class. - */ - public static class Oid implements Serializable, Comparable { + /** + * Get the name of the meeting room. + * @return The name of the meeting room. + */ + public String getName() { + return name; + } /** - * This is the identifier field for FCAppMeetingRoom and must correspond in type - * and name to the field in FCAppMeetingRoom. + * Set the name of the meeting room. + * @param name The name. */ - public long roomid; - - /** The required public, no-arg constructor. */ - public Oid() { - roomid = 0; + public void setName(String name) { + this.name = name; } /** - * A constructor to initialize the identifier field. - * - * @param roomid the id of the FCAppMeetingRoom. + * Returns a String representation of a Address object. + * @return a String representation of a FCAppMeetingRoom object. */ - public Oid(long roomid) { - this.roomid = roomid; + public String toString() { + return "FCAppMeetingRoom(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(roomid); + rc.append(", name ").append(name); + return rc.toString(); } - public Oid(String s) { - roomid = Long.parseLong(justTheId(s)); + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IMeetingRoom otherMeetingRoom = (IMeetingRoom)other; + String where = "FCAppMeetingRoom<" + roomid + ">"; + return + helper.equals(roomid, otherMeetingRoom.getRoomid(), where + ".roomid") & + helper.equals(name, otherMeetingRoom.getName(), where + ".name"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((IMeetingRoom)o); } - public String toString() { - return this.getClass().getName() + ": " + roomid; + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((IMeetingRoom)o1, (IMeetingRoom)o2); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.roomid != o.roomid) return (false); - return (true); + /** + * Compares this object with the specified FCAppMeetingRoom object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The MeetingRoom object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified MeetingRoom + * object. + */ + public int compareTo(IMeetingRoom other) { + return compare(this, other); + } + + /** + * Compares its two IMeetingRoom arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IMeetingRoom object to be compared. + * @param o2 the second IMeetingRoom object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(IMeetingRoom o1, IMeetingRoom o2) { + return EqualityHelper.compare(o1.getRoomid(), o2.getRoomid()); } - /** */ - public int hashCode() { - return ((int) roomid); + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof IMeetingRoom) { + return compareTo((IMeetingRoom)obj) == 0; + } + return false; } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)roomid; } + + /** + * This class is used to represent the application identifier + * for the FCAppMeetingRoom class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This is the identifier field for FCAppMeetingRoom and must + * correspond in type and name to the field in + * FCAppMeetingRoom. + */ + public long roomid; + + /** The required public, no-arg constructor. */ + public Oid() + { + roomid = 0; + } + + /** + * A constructor to initialize the identifier field. + * @param roomid the id of the FCAppMeetingRoom. + */ + public Oid(long roomid) { + this.roomid = roomid; + } + + public Oid(String s) { roomid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + roomid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.roomid != o.roomid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) roomid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (roomid < other.roomid) return -1; - if (roomid > other.roomid) return 1; - return 0; + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( roomid < other.roomid ) return -1; + if( roomid > other.roomid ) return 1; + return 0; + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPartTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPartTimeEmployee.java index f6196ebea..1ca7a254c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPartTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPartTimeEmployee.java @@ -5,136 +5,132 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; +import javax.jdo.annotations.*; + import java.util.Date; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.PersistenceCapable; + import org.apache.jdo.tck.pc.company.IPartTimeEmployee; +import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a part-time employee. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION) -@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE) -public class FCAppPartTimeEmployee extends FCAppEmployee implements IPartTimeEmployee { +/** + * This class represents a part-time employee. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION) +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) +public class FCAppPartTimeEmployee extends FCAppEmployee + implements IPartTimeEmployee { - @Column(name = "WAGE") - private double wage; + @Column(name="WAGE") + private double wage; - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FCAppPartTimeEmployee() {} + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCAppPartTimeEmployee() {} - /** - * Construct a part-time employee. - * - * @param personid The identifier for the person. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param hired The date the person was hired. - * @param wage The person's wage. - */ - public FCAppPartTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double wage) { - super(personid, first, last, middle, born, hired); - this.wage = wage; - } + /** + * Construct a part-time employee. + * @param personid The identifier for the person. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param hired The date the person was hired. + * @param wage The person's wage. + */ + public FCAppPartTimeEmployee(long personid, String first, String last, + String middle, Date born, + Date hired, double wage ) { + super(personid, first, last, middle, born, hired); + this.wage = wage; + } - /** - * Construct a part-time employee. - * - * @param personid The identifier for the person. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param addr The person's address. - * @param hired The date the person was hired. - * @param wage The person's wage. - */ - public FCAppPartTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - FCAppAddress addr, - Date hired, - double wage) { - super(personid, first, last, middle, born, addr, hired); - this.wage = wage; - } + /** + * Construct a part-time employee. + * @param personid The identifier for the person. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param addr The person's address. + * @param hired The date the person was hired. + * @param wage The person's wage. + */ + public FCAppPartTimeEmployee(long personid, String first, String last, + String middle, Date born, FCAppAddress addr, + Date hired, double wage ) { + super(personid, first, last, middle, born, addr, hired); + this.wage = wage; + } - /** - * Get the wage of the part-time employee. - * - * @return The wage of the part-time employee. - */ - public double getWage() { - return wage; - } + /** + * Get the wage of the part-time employee. + * @return The wage of the part-time employee. + */ + public double getWage() { + return wage; + } - /** - * Set the wage of the part-time employee. - * - * @param wage The wage of the part-time employee. - */ - public void setWage(double wage) { - this.wage = wage; - } + /** + * Set the wage of the part-time employee. + * @param wage The wage of the part-time employee. + */ + public void setWage(double wage) { + this.wage = wage; + } - /** - * Returns a String representation of a FCAppPartTimeEmployee object. - * - * @return a String representation of a FCAppPartTimeEmployee object. - */ - public String toString() { - return "FCPartTimeEmployee(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of a FCAppPartTimeEmployee object. + * + * @return a String representation of a FCAppPartTimeEmployee object. + */ + public String toString() { + return "FCPartTimeEmployee(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - public String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", $" + wage); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + public String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", $" + wage); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified FCAppPartTimeEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCAppPartTimeEmployee otherEmp = (FCAppPartTimeEmployee) other; - String where = "FCPartTimeEmployee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.closeEnough(wage, otherEmp.getWage(), where + ".wage"); - } + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified + * FCAppPartTimeEmployee. + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCAppPartTimeEmployee otherEmp = (FCAppPartTimeEmployee)other; + String where = "FCPartTimeEmployee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.closeEnough(wage, otherEmp.getWage(), where + ".wage"); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPerson.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPerson.java index 1e064042f..cf0395bd7 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPerson.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPerson.java @@ -5,468 +5,453 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; +import javax.jdo.annotations.*; + import java.io.Serializable; + import java.text.SimpleDateFormat; + import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.Map; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Embedded; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.Join; -import javax.jdo.annotations.Key; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; -import javax.jdo.annotations.PrimaryKey; -import javax.jdo.annotations.Value; import org.apache.jdo.tck.pc.company.IAddress; + import org.apache.jdo.tck.pc.company.IPerson; -import org.apache.jdo.tck.pc.compositeAnnotation.ApplicationIdDiscriminatorClassName; import org.apache.jdo.tck.util.DeepEquality; + import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a person. */ -@PersistenceCapable(table = "persons") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) +import org.apache.jdo.tck.pc.compositeAnnotation.ApplicationIdDiscriminatorClassName; +/** + * This class represents a person. + */ +@PersistenceCapable(table="persons") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) @ApplicationIdDiscriminatorClassName -public class FCAppPerson implements IPerson, Serializable, Comparable, Comparator, DeepEquality { - - @PrimaryKey - @Column(name = "PERSONID") - private long personid; - - @Column(name = "FIRSTNAME") - private String firstname; - - @Column(name = "LASTNAME") - private String lastname; - - @Persistent(defaultFetchGroup = "false") - @Column(name = "MIDDLENAME", allowsNull = "true") - private String middlename; - - @Column(name = "BIRTHDATE") - private Date birthdate; - - @Embedded( - nullIndicatorColumn = "COUNTRY", - members = { - @Persistent(name = "addrid", columns = @Column(name = "ADDRID")), - @Persistent(name = "street", columns = @Column(name = "STREET")), - @Persistent(name = "city", columns = @Column(name = "CITY")), - @Persistent(name = "state", columns = @Column(name = "STATE")), - @Persistent(name = "zipcode", columns = @Column(name = "ZIPCODE")), - @Persistent(name = "country", columns = @Column(name = "COUNTRY")) - }) - private FCAppAddress address; - - // maps phone number types ("home", "work", "mobile", etc.) - // to phone numbers specified as String - @Persistent(table = "employee_phoneno_type") - @Join(column = "EMPID") - @Key(types = java.lang.String.class, column = "TYPE") - @Value(types = java.lang.String.class, column = "PHONENO") - private Map phoneNumbers = new HashMap(); - - protected static SimpleDateFormat formatter = new SimpleDateFormat("d/MMM/yyyy"); - - /** This is the JDO-required no-args constructor. */ - protected FCAppPerson() {} - - /** - * Construct a FCAppPerson instance. - * - * @param personid The person identifier. - * @param firstname The person's first name. - * @param lastname The person's last name. - * @param middlename The person's middle name. - * @param birthdate The person's birthdate. - */ - public FCAppPerson( - long personid, String firstname, String lastname, String middlename, Date birthdate) { - this.personid = personid; - this.firstname = firstname; - this.lastname = lastname; - this.middlename = middlename; - this.birthdate = birthdate; - } - - /** - * Construct a FCAppPerson instance. - * - * @param personid The person identifier. - * @param firstname The person's first name. - * @param lastname The person's last name. - * @param middlename The person's middle name. - * @param birthdate The person's birthdate. - * @param address The person's address. - */ - public FCAppPerson( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - IAddress address) { - this(personid, firstname, lastname, middlename, birthdate); - this.address = (FCAppAddress) address; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setPersonid(long id) { - if (this.personid != 0) throw new IllegalStateException("Id is already set."); - this.personid = id; - } - - /** - * Get the person's id. - * - * @return The personid. - */ - public long getPersonid() { - return personid; - } - - /** - * Set the person's id. - * - * @param personid The personid. - */ - public void setLastname(long personid) { - this.personid = personid; - } - - /** - * Get the person's last name. - * - * @return The last name. - */ - public String getLastname() { - return lastname; - } - - /** - * Set the person's last name. - * - * @param lastname The last name. - */ - public void setLastname(String lastname) { - this.lastname = lastname; - } - - /** - * Get the person's first name. - * - * @return The first name. - */ - public String getFirstname() { - return firstname; - } - - /** - * Set the person's first name. - * - * @param firstname The first name. - */ - public void setFirstname(String firstname) { - this.firstname = firstname; - } - - /** - * Get the person's middle name. - * - * @return The middle name. - */ - public String getMiddlename() { - return middlename; - } - - /** - * Set the person's middle name. - * - * @param middlename The middle name. - */ - public void setMiddlename(String middlename) { - this.middlename = middlename; - } - - /** - * Get the address. - * - * @return The address. - */ - public IAddress getAddress() { - return address; - } - - /** - * Set the address. - * - * @param address The address. - */ - public void setAddress(IAddress address) { - this.address = (FCAppAddress) address; - } - - /** - * Get the person's birthdate. - * - * @return The person's birthdate. - */ - public Date getBirthdate() { - return birthdate; - } - - /** - * Set the person's birthdate. - * - * @param birthdate The person's birthdate. - */ - public void setBirthdate(Date birthdate) { - this.birthdate = birthdate; - } - - /** - * Get the map of phone numbers as an unmodifiable map. - * - * @return The map of phone numbers, as an unmodifiable map. - */ - public Map getPhoneNumbers() { - return Collections.unmodifiableMap(phoneNumbers); - } - - /** - * Get the phone number for the specified phone number type. - * - * @param type The phone number type ("home", "work", "mobile", etc.). - * @return The phone number associated with specified type, or null if there was no - * phone number for the type. - */ - public String getPhoneNumber(String type) { - return (String) phoneNumbers.get(type); - } - - /** - * Associates the specified phone number with the specified type in the map of phone numbers of - * this person. - * - * @param type The phone number type ("home", "work", "mobile", etc.). - * @param phoneNumber The phone number - * @return The previous phone number associated with specified type, or null if there - * was no phone number for the type. - */ - public String putPhoneNumber(String type, String phoneNumber) { - return (String) phoneNumbers.put(type, phoneNumber); - } - - /** - * Remove a phoneNumber from the map of phone numbers. - * - * @param type The phone number type ("home", "work", "mobile", etc.). - * @return The previous phone number associated with specified type, or null if there - * was no phone number for the type. - */ - public String removePhoneNumber(String type) { - return (String) phoneNumbers.remove(type); - } - - /** - * Set the phoneNumber map to be in this person. - * - * @param phoneNumbers The map of phoneNumbers for this person. - */ - public void setPhoneNumbers(Map phoneNumbers) { - // workaround: create a new HashMap, because fostore does not - // support LinkedHashMap - this.phoneNumbers = (phoneNumbers != null) ? new HashMap(phoneNumbers) : null; - } - - /** - * Returns a String representation of a FCAppPerson object. - * - * @return a string representation of a FCAppPerson object. - */ - public String toString() { - return "FCPerson(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(personid); - rc.append(", ").append(lastname); - rc.append(", ").append(firstname); - rc.append(", born ").append(birthdate == null ? "null" : formatter.format(birthdate)); - rc.append(", phone ").append(phoneNumbers); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified FCAppPerson. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCAppPerson otherPerson = (FCAppPerson) other; - String where = "FCPerson<" + personid + ">"; - return helper.equals(personid, otherPerson.getPersonid(), where + ".personid") - & helper.equals(firstname, otherPerson.getFirstname(), where + ".firstname") - & helper.equals(lastname, otherPerson.getLastname(), where + ".lastname") - & helper.equals(middlename, otherPerson.getMiddlename(), where + ".middlename") - & helper.equals(birthdate, otherPerson.getBirthdate(), where + ".birthdate") - & helper.deepEquals(address, otherPerson.getAddress(), where + ".address") - & helper.deepEquals(phoneNumbers, otherPerson.getPhoneNumbers(), where + ".phoneNumbers"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((FCAppPerson) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((FCAppPerson) o1, (FCAppPerson) o2); - } - - /** - * Compares this object with the specified FCAppPerson object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The FCAppPerson object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified FFCAppPerson object. - */ - public int compareTo(FCAppPerson other) { - return compare(this, other); - } - - /** - * Compares its two IPerson arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IPerson object to be compared. - * @param o2 the second IPerson object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(FCAppPerson o1, FCAppPerson o2) { - return EqualityHelper.compare(o1.getPersonid(), o2.getPersonid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof FCAppPerson) { - return compareTo((FCAppPerson) obj) == 0; + +public class FCAppPerson + implements IPerson, Serializable, Comparable, Comparator, DeepEquality { + + @PrimaryKey + @Column(name="PERSONID") + private long personid; + @Column(name="FIRSTNAME") + private String firstname; + @Column(name="LASTNAME") + private String lastname; + @Persistent(defaultFetchGroup="false") + @Column(name="MIDDLENAME", allowsNull="true") + private String middlename; + @Column(name="BIRTHDATE") + private Date birthdate; + @Embedded(nullIndicatorColumn="COUNTRY", + members={ + @Persistent(name="addrid", columns=@Column(name="ADDRID")), + @Persistent(name="street", columns=@Column(name="STREET")), + @Persistent(name="city", columns=@Column(name="CITY")), + @Persistent(name="state", columns=@Column(name="STATE")), + @Persistent(name="zipcode", columns=@Column(name="ZIPCODE")), + @Persistent(name="country", columns=@Column(name="COUNTRY")) + }) + private FCAppAddress address; + + // maps phone number types ("home", "work", "mobile", etc.) + // to phone numbers specified as String + @Persistent(table="employee_phoneno_type") + @Join(column="EMPID") + @Key(types=java.lang.String.class, column="TYPE") + @Value(types=java.lang.String.class, column="PHONENO") + private Map phoneNumbers = new HashMap(); + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. */ + protected FCAppPerson() {} + + /** + * Construct a FCAppPerson instance. + * + * @param personid The person identifier. + * @param firstname The person's first name. + * @param lastname The person's last name. + * @param middlename The person's middle name. + * @param birthdate The person's birthdate. + */ + public FCAppPerson(long personid, String firstname, String lastname, + String middlename, Date birthdate) { + this.personid = personid; + this.firstname = firstname; + this.lastname = lastname; + this.middlename = middlename; + this.birthdate = birthdate; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) personid; - } - /** - * This class is used to represent the application identifier for the Person class. - */ - public static class Oid implements Serializable, Comparable { /** - * This field represents the identifier for the Person class. It must match a field - * in the Person class in both name and type. + * Construct a FCAppPerson instance. + * + * @param personid The person identifier. + * @param firstname The person's first name. + * @param lastname The person's last name. + * @param middlename The person's middle name. + * @param birthdate The person's birthdate. + * @param address The person's address. */ - public long personid; + public FCAppPerson(long personid, String firstname, String lastname, + String middlename, Date birthdate, IAddress address) { + this(personid, firstname, lastname, middlename, birthdate); + this.address = (FCAppAddress)address; + } - /** The required public no-arg constructor. */ - public Oid() {} + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setPersonid(long id) { + if (this.personid != 0) + throw new IllegalStateException("Id is already set."); + this.personid = id; + } /** - * Initialize the identifier. - * - * @param personid The person identifier. + * Get the person's id. + * @return The personid. + */ + public long getPersonid() { + return personid; + } + + /** + * Set the person's id. + * @param personid The personid. + */ + public void setLastname(long personid) { + this.personid = personid; + } + + /** + * Get the person's last name. + * @return The last name. */ - public Oid(long personid) { - this.personid = personid; + public String getLastname() { + return lastname; } - public Oid(String s) { - personid = Long.parseLong(justTheId(s)); + /** + * Set the person's last name. + * @param lastname The last name. + */ + public void setLastname(String lastname) { + this.lastname = lastname; + } + + /** + * Get the person's first name. + * @return The first name. + */ + public String getFirstname() { + return firstname; + } + + /** + * Set the person's first name. + * @param firstname The first name. + */ + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + /** + * Get the person's middle name. + * @return The middle name. + */ + public String getMiddlename() { + return middlename; } + /** + * Set the person's middle name. + * @param middlename The middle name. + */ + public void setMiddlename(String middlename) { + this.middlename = middlename; + } + + /** + * Get the address. + * @return The address. + */ + public IAddress getAddress() { + return address; + } + + /** + * Set the address. + * @param address The address. + */ + public void setAddress(IAddress address) { + this.address = (FCAppAddress)address; + } + + /** + * Get the person's birthdate. + * @return The person's birthdate. + */ + public Date getBirthdate() { + return birthdate; + } + + /** + * Set the person's birthdate. + * @param birthdate The person's birthdate. + */ + public void setBirthdate(Date birthdate) { + this. birthdate = birthdate; + } + + /** + * Get the map of phone numbers as an unmodifiable map. + * @return The map of phone numbers, as an unmodifiable map. + */ + public Map getPhoneNumbers() { + return Collections.unmodifiableMap(phoneNumbers); + } + + /** + * Get the phone number for the specified phone number type. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String getPhoneNumber(String type) { + return (String)phoneNumbers.get(type); + } + + /** + * Associates the specified phone number with the specified type in the + * map of phone numbers of this person. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @param phoneNumber The phone number + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String putPhoneNumber(String type, String phoneNumber) { + return (String)phoneNumbers.put(type, phoneNumber); + } + + /** + * Remove a phoneNumber from the map of phone numbers. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String removePhoneNumber(String type) { + return (String)phoneNumbers.remove(type); + } + + /** + * Set the phoneNumber map to be in this person. + * @param phoneNumbers The map of phoneNumbers for this person. + */ + public void setPhoneNumbers(Map phoneNumbers) { + // workaround: create a new HashMap, because fostore does not + // support LinkedHashMap + this.phoneNumbers = + (phoneNumbers != null) ? new HashMap(phoneNumbers) : null; + } + + /** + * Returns a String representation of a FCAppPerson object. + * + * @return a string representation of a FCAppPerson object. + */ public String toString() { - return this.getClass().getName() + ": " + personid; + return "FCPerson(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(personid); + rc.append(", ").append(lastname); + rc.append(", ").append(firstname); + rc.append(", born ").append( + birthdate==null ? "null" : formatter.format(birthdate)); + rc.append(", phone ").append(phoneNumbers); + return rc.toString(); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.personid != o.personid) return (false); - return (true); + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified FCAppPerson. + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCAppPerson otherPerson = (FCAppPerson)other; + String where = "FCPerson<" + personid + ">"; + return + helper.equals(personid, otherPerson.getPersonid(), where + ".personid") & + helper.equals(firstname, otherPerson.getFirstname(), where + ".firstname") & + helper.equals(lastname, otherPerson.getLastname(), where + ".lastname") & + helper.equals(middlename, otherPerson.getMiddlename(), where + ".middlename") & + helper.equals(birthdate, otherPerson.getBirthdate(), where + ".birthdate") & + helper.deepEquals(address, otherPerson.getAddress(), where + ".address") & + helper.deepEquals(phoneNumbers, otherPerson.getPhoneNumbers(), where + ".phoneNumbers"); } - /** */ - public int hashCode() { - return ((int) personid); + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((FCAppPerson)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((FCAppPerson)o1, (FCAppPerson)o2); + } + + /** + * + * Compares this object with the specified FCAppPerson object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * + * @param other The FCAppPerson object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified FFCAppPerson + * object. + */ + public int compareTo(FCAppPerson other) { + return compare(this, other); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compares its two IPerson arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IPerson object to be compared. + * @param o2 the second IPerson object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(FCAppPerson o1, FCAppPerson o2) { + return EqualityHelper.compare(o1.getPersonid(), o2.getPersonid()); } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof FCAppPerson) { + return compareTo((FCAppPerson)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)personid; + } + /** + * This class is used to represent the application identifier + * for the Person class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the identifier for the Person + * class. It must match a field in the Person class in + * both name and type. + */ + public long personid; + + /** + * The required public no-arg constructor. + */ + public Oid() { } + + /** + * Initialize the identifier. + * @param personid The person identifier. + */ + public Oid(long personid) { + this.personid = personid; + } + + public Oid(String s) { personid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + personid;} + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || + !this.getClass().equals(obj.getClass()) ) return( false ); + Oid o = (Oid) obj; + if( this.personid != o.personid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) personid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( personid < other.personid ) return -1; + if( personid > other.personid ) return 1; + return 0; + } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (personid < other.personid) return -1; - if (personid > other.personid) return 1; - return 0; } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppProject.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppProject.java index 326e528a6..951b25954 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppProject.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppProject.java @@ -5,398 +5,385 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; -import java.io.IOException; -import java.io.ObjectInputStream; +import javax.jdo.annotations.*; + import java.io.Serializable; -import java.math.BigDecimal; +import java.io.ObjectInputStream; +import java.io.IOException; + import java.util.Collections; import java.util.Comparator; -import java.util.HashSet; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.Join; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; -import javax.jdo.annotations.PrimaryKey; +import java.util.HashSet; +import java.math.BigDecimal; + import org.apache.jdo.tck.pc.company.IProject; import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a project, a budgeted task with one or more employees working on it. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION, table = "projects") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator(strategy = DiscriminatorStrategy.CLASS_NAME, column = "DISCRIMINATOR") -public class FCAppProject implements IProject, Serializable, Comparable, Comparator, DeepEquality { - - @PrimaryKey - @Column(name = "PROJID") - private long projid; - - @Column(name = "NAME") - private String name; - - @Column(name = "BUDGET", jdbcType = "DECIMAL", length = 11, scale = 2) - private BigDecimal budget; - - @Persistent(table = "project_reviewer") - @Element( - types = org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppEmployee.class, - column = "REVIEWER") - @Join(column = "PROJID", foreignKey = "PR_PROJ_FK") - private transient Set reviewers = new HashSet(); - - @Persistent(table = "project_member") - @Element( - types = org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppEmployee.class, - column = "MEMBER", - foreignKey = "PR_MEMB_FK") - @Join(column = "PROJID", foreignKey = "PR_PROJ_FK") - private transient Set members = new HashSet(); - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FCAppProject() {} - - /** - * Initialize a project. - * - * @param projid The project identifier. - * @param name The name of the project. - * @param budget The budget for the project. - */ - public FCAppProject(long projid, String name, BigDecimal budget) { - this.projid = projid; - this.name = name; - this.budget = budget; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setProjid(long id) { - if (this.projid != 0) throw new IllegalStateException("Id is already set."); - this.projid = id; - } - - /** - * Get the project ID. - * - * @return The project ID. - */ - public long getProjid() { - return projid; - } - - /** - * Get the name of the project. - * - * @return The name of the project. - */ - public String getName() { - return name; - } - - /** - * Set the name of the project. - * - * @param name The name of the project. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Get the project's budget. - * - * @return The project's budget. - */ - public BigDecimal getBudget() { - return budget; - } - - /** - * Set the project's budget. - * - * @param budget The project's budget. - */ - public void setBudget(BigDecimal budget) { - this.budget = budget; - } - - /** Get the reviewers associated with this project. */ - public Set getReviewers() { - return Collections.unmodifiableSet(reviewers); - } - - /** - * Add a reviewer to the project. - * - * @param emp The employee to add as a reviewer. - */ - public void addReviewer(FCAppEmployee emp) { - reviewers.add(emp); - } - - /** - * Remove a reviewer from the project. - * - * @param emp The employee to remove as a reviewer of this project. - */ - public void removeReviewer(FCAppEmployee emp) { - reviewers.remove(emp); - } - - /** - * Set the reviewers associated with this project. - * - * @param reviewers The set of reviewers to associate with this project. - */ - public void setReviewers(Set reviewers) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.reviewers = (reviewers != null) ? new HashSet(reviewers) : null; - } - - /** - * Get the project members. - * - * @return The members of the project is returned as an unmodifiable set of FCAppEmployee - * s. - */ - public Set getMembers() { - return Collections.unmodifiableSet(members); - } - - /** - * Add a new member to the project. - * - * @param emp The employee to add to the project. - */ - public void addMember(FCAppEmployee emp) { - members.add(emp); - } - - /** - * Remove a member from the project. - * - * @param emp The employee to remove from the project. - */ - public void removeMember(FCAppEmployee emp) { - members.remove(emp); - } - - /** - * Set the members of the project. - * - * @param employees The set of employees to be the members of this project. - */ - public void setMembers(Set employees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.members = (employees != null) ? new HashSet(employees) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - reviewers = new HashSet(); - members = new HashSet(); - } - - /** - * Returns a String representation of a FCAppProject object. - * - * @return a String representation of a FCAppProject object. - */ - public String toString() { - return "FCProject(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(projid); - rc.append(", name ").append(name); - rc.append(", budget ").append(budget); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCAppProject otherProject = (FCAppProject) other; - String where = "FCProject<" + projid + ">"; - return helper.equals(projid, otherProject.getProjid(), where + ".projid") - & helper.equals(name, otherProject.getName(), where + ".name") - & helper.equals(budget, otherProject.getBudget(), where + ".budget") - & helper.deepEquals(reviewers, otherProject.getReviewers(), where + ".reviewers") - & helper.deepEquals(members, otherProject.getMembers(), where + ".members"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((FCAppProject) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((FCAppProject) o1, (FCAppProject) o2); - } - - /** - * Compares this object with the specified FCAppProject object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The FCAppProject object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified FFCAppProject object. - */ - public int compareTo(FCAppProject other) { - return compare(this, other); - } - - /** - * Compares its two IProject arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IProject object to be compared. - * @param o2 the second IProject object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(FCAppProject o1, FCAppProject o2) { - return EqualityHelper.compare(o1.getProjid(), o2.getProjid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof FCAppProject) { - return compareTo((FCAppProject) obj) == 0; +/** + * This class represents a project, a budgeted task with one or more + * employees working on it. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION, table="projects") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") +public class FCAppProject + implements IProject, Serializable, Comparable, Comparator, DeepEquality { + + @PrimaryKey + @Column(name="PROJID") + private long projid; + @Column(name="NAME") + private String name; + @Column(name="BUDGET", jdbcType="DECIMAL", length=11, scale=2) + private BigDecimal budget; + @Persistent(table="project_reviewer") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppEmployee.class, + column="REVIEWER") + @Join(column="PROJID", foreignKey="PR_PROJ_FK") + private transient Set reviewers = new HashSet(); + @Persistent(table="project_member") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppEmployee.class, + column="MEMBER", foreignKey="PR_MEMB_FK") + @Join(column="PROJID", foreignKey="PR_PROJ_FK") + private transient Set members = new HashSet(); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCAppProject() {} + + /** + * Initialize a project. + * @param projid The project identifier. + * @param name The name of the project. + * @param budget The budget for the project. + */ + public FCAppProject(long projid, String name, BigDecimal budget) { + this.projid = projid; + this.name = name; + this.budget = budget; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setProjid(long id) { + if (this.projid != 0) + throw new IllegalStateException("Id is already set."); + this.projid = id; + } + + /** + * Get the project ID. + * @return The project ID. + */ + public long getProjid() { + return projid; + } + + /** + * Get the name of the project. + * @return The name of the project. + */ + public String getName() { + return name; + } + + /** + * Set the name of the project. + * @param name The name of the project. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Get the project's budget. + * @return The project's budget. + */ + public BigDecimal getBudget() { + return budget; + } + + /** + * Set the project's budget. + * @param budget The project's budget. + */ + public void setBudget(BigDecimal budget) { + this.budget = budget; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) projid; - } - - /** - * This class is used to represent the application identity for the FCAppProject - * class. - */ - public static class Oid implements Serializable, Comparable { /** - * This field represents the identifier for the FCAppProject class. It must match a - * field in the FCAppProject class in both name and type. + * Get the reviewers associated with this project. */ - public long projid; + public Set getReviewers() { + return Collections.unmodifiableSet(reviewers); + } - /** The required public no-arg constructor. */ - public Oid() {} + /** + * Add a reviewer to the project. + * @param emp The employee to add as a reviewer. + */ + public void addReviewer(FCAppEmployee emp) { + reviewers.add(emp); + } /** - * Initialize the application identifier with a project ID. - * - * @param projid The id of the project. + * Remove a reviewer from the project. + * @param emp The employee to remove as a reviewer of this project. */ - public Oid(long projid) { - this.projid = projid; + public void removeReviewer(FCAppEmployee emp) { + reviewers.remove(emp); } - public Oid(String s) { - projid = Long.parseLong(justTheId(s)); + /** + * Set the reviewers associated with this project. + * @param reviewers The set of reviewers to associate with this project. + */ + public void setReviewers(Set reviewers) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.reviewers = (reviewers != null) ? new HashSet(reviewers) : null; } + /** + * Get the project members. + * + * @return The members of the project is returned as an unmodifiable + * set of FCAppEmployees. + */ + public Set getMembers() { + return Collections.unmodifiableSet(members); + } + + /** + * Add a new member to the project. + * @param emp The employee to add to the project. + */ + public void addMember(FCAppEmployee emp) { + members.add(emp); + } + + /** + * Remove a member from the project. + * @param emp The employee to remove from the project. + */ + public void removeMember(FCAppEmployee emp) { + members.remove(emp); + } + + /** + * Set the members of the project. + * @param employees The set of employees to be the members of this + * project. + */ + public void setMembers(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.members = (employees != null) ? new HashSet(employees) : null; + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + reviewers = new HashSet(); + members = new HashSet(); + } + + /** + * Returns a String representation of a FCAppProject object. + * + * @return a String representation of a FCAppProject object. + */ public String toString() { - return this.getClass().getName() + ": " + projid; + return "FCProject(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(projid); + rc.append(", name ").append(name); + rc.append(", budget ").append(budget); + return rc.toString(); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.projid != o.projid) return (false); - return (true); + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCAppProject otherProject = (FCAppProject)other; + String where = "FCProject<" + projid + ">"; + return + helper.equals(projid, otherProject.getProjid(), where + ".projid") & + helper.equals(name, otherProject.getName(), where + ".name") & + helper.equals(budget, otherProject.getBudget(), where + ".budget") & + helper.deepEquals(reviewers, otherProject.getReviewers(), where + ".reviewers") & + helper.deepEquals(members, otherProject.getMembers(), where + ".members"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((FCAppProject)o); } - /** */ - public int hashCode() { - return ((int) projid); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((FCAppProject)o1, (FCAppProject)o2); + } + + /** + * + * Compares this object with the specified FCAppProject object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * + * @param other The FCAppProject object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified FFCAppProject object. + */ + public int compareTo(FCAppProject other) { + return compare(this, other); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compares its two IProject arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IProject object to be compared. + * @param o2 the second IProject object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(FCAppProject o1, FCAppProject o2) { + return EqualityHelper.compare(o1.getProjid(), o2.getProjid()); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (projid < other.projid) return -1; - if (projid > other.projid) return 1; - return 0; + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof FCAppProject) { + return compareTo((FCAppProject)obj) == 0; + } + return false; } - } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)projid; + } + + /** + * This class is used to represent the application identity + * for the FCAppProject class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the identifier for the + * FCAppProject class. It must match a field in the + * FCAppProject class in both name and type. + */ + public long projid; + + /** + * The required public no-arg constructor. + */ + public Oid() { } + + /** + * Initialize the application identifier with a project ID. + * @param projid The id of the project. + */ + public Oid(long projid) { + this.projid = projid; + } + + public Oid(String s) { projid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + projid;} + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.projid != o.projid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) projid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( projid < other.projid ) return -1; + if( projid > other.projid ) return 1; + return 0; + } + + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSAddress.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSAddress.java index 960783c17..da0158644 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSAddress.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSAddress.java @@ -5,342 +5,341 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; import java.io.Serializable; import java.util.Comparator; -import javax.jdo.annotations.PersistenceCapable; + +import javax.jdo.annotations.*; import org.apache.jdo.tck.pc.company.IAddress; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a postal address. */ -@PersistenceCapable(embeddedOnly = "true", requiresExtent = "false") -public class FCDSAddress implements IAddress, Serializable, Comparable, Comparator, DeepEquality { - - private long addrid; - private String street; - private String city; - private String state; - private String zipcode; - private String country; - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FCDSAddress() {} - - /** - * This constructor initializes the FCDSAddress components. - * - * @param addrid The address ID. - * @param street The street address. - * @param city The city. - * @param state The state. - * @param zipcode The zip code. - * @param country The zip country. - */ - public FCDSAddress( - long addrid, String street, String city, String state, String zipcode, String country) { - this.addrid = addrid; - this.street = street; - this.city = city; - this.state = state; - this.zipcode = zipcode; - this.country = country; - } - - /** - * Get the addrid associated with this object. - * - * @return the addrid. - */ - public long getAddrid() { - return addrid; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setAddrid(long id) { - if (this.addrid != 0) throw new IllegalStateException("Id is already set."); - this.addrid = id; - } - - /** - * Get the street component of the address. - * - * @return The street component of the address. - */ - public String getStreet() { - return street; - } - - /** - * Set the street component of the address. - * - * @param street The street component. - */ - public void setStreet(String street) { - this.street = street; - } - - /** - * Get the city. - * - * @return The city component of the address. - */ - public String getCity() { - return city; - } - - /** - * Set the city component of the address. - * - * @param city The city. - */ - public void setCity(String city) { - this.city = city; - } - - /** - * Get the state component of the address. - * - * @return The state. - */ - public String getState() { - return state; - } - - /** - * Set the state component of the address. - * - * @param state The state. - */ - public void setState(String state) { - this.state = state; - } - - /** - * Get the zipcode component of the address. - * - * @return The zipcode. - */ - public String getZipcode() { - return zipcode; - } - - /** - * Set the zip code component of the address. - * - * @param zipcode The zipcode. - */ - public void setZipcode(String zipcode) { - this.zipcode = zipcode; - } - - /** - * Get the country component of the address. - * - * @return The country. - */ - public String getCountry() { - return country; - } - - /** - * Set the country component of the address. - * - * @param country The country. - */ - public void setCountry(String country) { - this.country = country; - } - - /** - * Returns a String representation of a Address object. - * - * @return a String representation of a Address object. - */ - public String toString() { - return "Address(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(addrid); - rc.append(", street ").append(street); - rc.append(", city ").append(city); - rc.append(", state ").append(state); - rc.append(", zipcode ").append(zipcode); - rc.append(", country ").append(country); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCDSAddress otherAddress = (FCDSAddress) other; - String where = "Address<" + addrid + ">"; - return helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") - & helper.equals(street, otherAddress.getStreet(), where + ".street") - & helper.equals(city, otherAddress.getCity(), where + ".city") - & helper.equals(state, otherAddress.getState(), where + ".state") - & helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") - & helper.equals(country, otherAddress.getCountry(), where + ".country"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((FCDSAddress) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((FCDSAddress) o1, (FCDSAddress) o2); - } - - /** - * Compares this object with the specified Address object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Address object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Address object. - */ - public int compareTo(FCDSAddress other) { - return compare(this, other); - } - - /** - * Compares its two FCDSAddress arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first FCDSAddress object to be compared. - * @param o2 the second FFCDSAddressobject to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(FCDSAddress o1, FCDSAddress o2) { - return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof FCDSAddress) { - return compareTo((FCDSAddress) obj) == 0; +/** + * This class represents a postal address. + */ +@PersistenceCapable(embeddedOnly="true", requiresExtent="false") +public class FCDSAddress + implements IAddress, Serializable, Comparable, Comparator, DeepEquality { + + private long addrid; + private String street; + private String city; + private String state; + private String zipcode; + private String country; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCDSAddress() {} + + /** + * This constructor initializes the FCDSAddress components. + * + * @param addrid The address ID. + * @param street The street address. + * @param city The city. + * @param state The state. + * @param zipcode The zip code. + * @param country The zip country. + */ + public FCDSAddress(long addrid, String street, String city, + String state, String zipcode, String country) + { + this.addrid = addrid; + this.street = street; + this.city = city; + this.state = state; + this.zipcode = zipcode; + this.country = country; + } + + /** + * Get the addrid associated with this object. + * @return the addrid. + */ + public long getAddrid() { + return addrid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setAddrid(long id) { + if (this.addrid != 0) + throw new IllegalStateException("Id is already set."); + this.addrid = id; + } + + /** + * Get the street component of the address. + * @return The street component of the address. + */ + public String getStreet() { + return street; + } + + /** + * Set the street component of the address. + * @param street The street component. + */ + public void setStreet(String street) { + this.street = street; + } + + /** + * Get the city. + * @return The city component of the address. + */ + public String getCity() { + return city; + } + + /** + * Set the city component of the address. + * @param city The city. + */ + public void setCity(String city) { + this.city = city; + } + + /** + * Get the state component of the address. + * @return The state. + */ + public String getState() { + return state; + } + + /** + * Set the state component of the address. + * @param state The state. + */ + public void setState(String state) { + this.state = state; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) addrid; - } - - /** - * This class is used to represent the application identifier for the Address class. - */ - public static class Oid implements Serializable, Comparable { /** - * This is the identifier field for Address and must correspond in type and name to - * the field in Address. + * Get the zipcode component of the address. + * @return The zipcode. */ - public long addrid; + public String getZipcode() { + return zipcode; + } - /** The required public, no-arg constructor. */ - public Oid() { - addrid = 0; + /** + * Set the zip code component of the address. + * @param zipcode The zipcode. + */ + public void setZipcode(String zipcode) { + this.zipcode = zipcode; } /** - * A constructor to initialize the identifier field. - * - * @param addrid the id of the Address. + * Get the country component of the address. + * @return The country. */ - public Oid(long addrid) { - this.addrid = addrid; + public String getCountry() { + return country; } - public Oid(String s) { - addrid = Long.parseLong(justTheId(s)); + /** + * Set the country component of the address. + * @param country The country. + */ + public void setCountry(String country) { + this.country = country; } + /** + * Returns a String representation of a Address object. + * @return a String representation of a Address object. + */ public String toString() { - return this.getClass().getName() + ": " + addrid; + return "Address(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(addrid); + rc.append(", street ").append(street); + rc.append(", city ").append(city); + rc.append(", state ").append(state); + rc.append(", zipcode ").append(zipcode); + rc.append(", country ").append(country); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCDSAddress otherAddress = (FCDSAddress)other; + String where = "Address<" + addrid + ">"; + return + helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") & + helper.equals(street, otherAddress.getStreet(), where + ".street") & + helper.equals(city, otherAddress.getCity(), where + ".city") & + helper.equals(state, otherAddress.getState(), where + ".state") & + helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") & + helper.equals(country, otherAddress.getCountry(), where + ".country"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((FCDSAddress)o); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.addrid != o.addrid) return (false); - return (true); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((FCDSAddress)o1, (FCDSAddress)o2); } - /** */ - public int hashCode() { - return ((int) addrid); + /** + * Compares this object with the specified Address object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Address object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Address + * object. + */ + public int compareTo(FCDSAddress other) { + return compare(this, other); + } + + /** + * Compares its two FCDSAddress arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * + * @param o1 the first FCDSAddress object to be compared. + * @param o2 the second FFCDSAddressobject to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(FCDSAddress o1, FCDSAddress o2) { + return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof FCDSAddress) { + return compareTo((FCDSAddress)obj) == 0; + } + return false; } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (addrid < other.addrid) return -1; - if (addrid > other.addrid) return 1; - return 0; + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)addrid; + } + + /** + * This class is used to represent the application identifier + * for the Address class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This is the identifier field for Address and must + * correspond in type and name to the field in + * Address. + */ + public long addrid; + + /** The required public, no-arg constructor. */ + public Oid() + { + addrid = 0; + } + + /** + * A constructor to initialize the identifier field. + * @param addrid the id of the Address. + */ + public Oid(long addrid) { + this.addrid = addrid; + } + + public Oid(String s) { addrid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + addrid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.addrid != o.addrid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) addrid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( addrid < other.addrid ) return -1; + if( addrid > other.addrid ) return 1; + return 0; + } + } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSCompany.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSCompany.java index c2a7b7d9d..b9159d7bb 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSCompany.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSCompany.java @@ -5,393 +5,392 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; -import java.io.IOException; -import java.io.ObjectInputStream; +import javax.jdo.annotations.*; + import java.io.Serializable; +import java.io.ObjectInputStream; +import java.io.IOException; + import java.text.SimpleDateFormat; + import java.util.Collections; import java.util.Comparator; -import java.util.Date; -import java.util.HashSet; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.Embedded; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.PersistenceModifier; -import javax.jdo.annotations.Persistent; +import java.util.HashSet; +import java.util.Date; import org.apache.jdo.tck.pc.company.IAddress; import org.apache.jdo.tck.pc.company.ICompany; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents information about a company. */ -@PersistenceCapable(table = "companies") +/** + * This class represents information about a company. + */ +@PersistenceCapable(table="companies") @DatastoreIdDiscriminatorClassNameInheritanceNew -public class FCDSCompany implements ICompany, Serializable, Comparable, Comparator, DeepEquality { - - @Column(name = "ID") - private long companyid; - - @Column(name = "NAME", jdbcType = "VARCHAR") - private String name; - - @Column(name = "FOUNDEDDATE") - private Date founded; - - @Persistent(persistenceModifier = PersistenceModifier.PERSISTENT) - @Embedded( - nullIndicatorColumn = "COUNTRY", - members = { - @Persistent(name = "addrid", columns = @Column(name = "ADDRID")), - @Persistent(name = "street", columns = @Column(name = "STREET")), - @Persistent(name = "city", columns = @Column(name = "CITY")), - @Persistent(name = "state", columns = @Column(name = "STATE")), - @Persistent(name = "zipcode", columns = @Column(name = "ZIPCODE")), - @Persistent(name = "country", columns = @Column(name = "COUNTRY")) - }) - private FCDSAddress address; - - @Persistent(persistenceModifier = PersistenceModifier.PERSISTENT, mappedBy = "company") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSDepartment.class) - private transient Set departments = new HashSet(); - - protected static SimpleDateFormat formatter = new SimpleDateFormat("d/MMM/yyyy"); - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FCDSCompany() {} - - /** - * Initialize the FCDSCompany instance. - * - * @param companyid The company id. - * @param name The company name. - * @param founded The date the company was founded. - */ - public FCDSCompany(long companyid, String name, Date founded) { - this.companyid = companyid; - this.name = name; - this.founded = founded; - } - - /** - * Initialize the Company instance. - * - * @param companyid The company id. - * @param name The company name. - * @param founded The date the company was founded. - * @param addr The company's address. - */ - public FCDSCompany(long companyid, String name, Date founded, IAddress addr) { - this(companyid, name, founded); - this.address = (FCDSAddress) addr; - } - - /** - * Get the company id. - * - * @return The company id. - */ - public long getCompanyid() { - return companyid; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setCompanyid(long id) { - if (this.companyid != 0) throw new IllegalStateException("Id is already set."); - this.companyid = id; - } - - /** - * Get the name of the company. - * - * @return The name of the company. - */ - public String getName() { - return name; - } - - /** - * Set the name of the company. - * - * @param name The value to use for the name of the company. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Get the date that the company was founded. - * - * @return The date the company was founded. - */ - public Date getFounded() { - return founded; - } - - /** - * Set the date that the company was founded. - * - * @param founded The date to set that the company was founded. - */ - public void setFounded(Date founded) { - this.founded = founded; - } - - /** - * Get the address of the company. - * - * @return The primary address of the company. - */ - public IAddress getAddress() { - return address; - } - - /** - * Set the primary address for the company. - * - * @param address The address to set for the company. - */ - public void setAddress(IAddress address) { - this.address = (FCDSAddress) address; - } - - /** - * Get the departments contained in the company. - * - * @return An unmodifiable Set that contains all the FCDSDepartments of - * the company. - */ - public Set getDepartments() { - return Collections.unmodifiableSet(departments); - } - - /** - * Add a FCDSDepartment instance to the company. - * - * @param dept The FCDSDepartment instance to add. - */ - public void addDepartment(FCDSDepartment dept) { - departments.add(dept); - } - - /** - * Remove a FCDSDepartment instance from the company. - * - * @param dept The FCDSDepartment instance to remove. - */ - public void removeDepartment(FCDSDepartment dept) { - departments.remove(dept); - } - - /** - * Initialize the set of FCDSDepartments in the company to the parameter. - * - * @param departments The set of FCDSDepartments for the company. - */ - public void setDepartments(Set departments) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.departments = (departments != null) ? new HashSet(departments) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - departments = new HashSet(); - } - - /** - * Returns a String representation of a Company object. - * - * @return a String representation of a Company object. - */ - public String toString() { - return "Company(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(companyid); - rc.append(", name ").append(name); - rc.append(", founded ").append(founded == null ? "null" : formatter.format(founded)); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCDSCompany otherCompany = (FCDSCompany) other; - String where = "Company<" + companyid + ">"; - return helper.equals(companyid, otherCompany.getCompanyid(), where + ".companyid") - & helper.equals(name, otherCompany.getName(), where + ".name") - & helper.equals(founded, otherCompany.getFounded(), where + ".founded") - & helper.deepEquals(address, otherCompany.getAddress(), where + ".address") - & helper.deepEquals(departments, otherCompany.getDepartments(), where + ".departments"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((FCDSCompany) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((FCDSCompany) o1, (FCDSCompany) o2); - } - - /** - * Compares this object with the specified Company object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Company object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Company object. - */ - public int compareTo(FCDSCompany other) { - return compare(this, other); - } - - /** - * Compares its two ICompany arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first ICompany object to be compared. - * @param o2 the second ICompany object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(FCDSCompany o1, FCDSCompany o2) { - return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof FCDSCompany) { - return compareTo((FCDSCompany) obj) == 0; +public class FCDSCompany + implements ICompany, Serializable, Comparable, Comparator, DeepEquality { + + @Column(name="ID") + private long companyid; + @Column(name="NAME", jdbcType="VARCHAR") + private String name; + @Column(name="FOUNDEDDATE") + private Date founded; + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT) + @Embedded(nullIndicatorColumn="COUNTRY", + members={ + @Persistent(name="addrid", columns=@Column(name="ADDRID")), + @Persistent(name="street", columns=@Column(name="STREET")), + @Persistent(name="city", columns=@Column(name="CITY")), + @Persistent(name="state", columns=@Column(name="STATE")), + @Persistent(name="zipcode", columns=@Column(name="ZIPCODE")), + @Persistent(name="country", columns=@Column(name="COUNTRY")) + }) + private FCDSAddress address; + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT, + mappedBy="company") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSDepartment.class) + private transient Set departments = new HashSet(); + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCDSCompany() {} + + /** + * + * Initialize the FCDSCompany instance. + * + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + */ + public FCDSCompany(long companyid, String name, Date founded) { + this.companyid = companyid; + this.name = name; + this.founded = founded; + } + + /** + * Initialize the Company instance. + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + * @param addr The company's address. + */ + public FCDSCompany(long companyid, String name, Date founded, IAddress addr) { + this(companyid, name, founded); + this.address = (FCDSAddress)addr; + } + + /** + * Get the company id. + * @return The company id. + */ + public long getCompanyid() { + return companyid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setCompanyid(long id) { + if (this.companyid != 0) + throw new IllegalStateException("Id is already set."); + this.companyid = id; + } + + /** + * Get the name of the company. + * @return The name of the company. + */ + public String getName() { + return name; + } + + /** + * Set the name of the company. + * @param name The value to use for the name of the company. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Get the date that the company was founded. + * @return The date the company was founded. + */ + public Date getFounded() { + return founded; + } + + /** + * Set the date that the company was founded. + * @param founded The date to set that the company was founded. + */ + public void setFounded(Date founded) { + this.founded = founded; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) companyid; - } - - /** - * The class to be used as the application identifier for the Company class. It - * consists of both the company name and the date that the company was founded. - */ - public static class Oid implements Serializable, Comparable { /** - * This field is part of the identifier and should match in name and type with a field in the - * Company class. + * Get the address of the company. + * @return The primary address of the company. */ - public long companyid; + public IAddress getAddress() { + return address; + } + + /** + * Set the primary address for the company. + * @param address The address to set for the company. + */ + public void setAddress(IAddress address) { + this.address = (FCDSAddress)address; + } + + /** + * Get the departments contained in the company. + * + * @return An unmodifiable Set that contains all the + * FCDSDepartments of the company. + */ + public Set getDepartments() { + return Collections.unmodifiableSet(departments); + } + + /** + * Add a FCDSDepartment instance to the company. + * + * @param dept The FCDSDepartment instance to add. + */ + public void addDepartment(FCDSDepartment dept) { + departments.add(dept); + } - /** The required public no-arg constructor. */ - public Oid() {} + /** + * Remove a FCDSDepartment instance from the company. + * + * @param dept The FCDSDepartment instance to remove. + */ + public void removeDepartment(FCDSDepartment dept) { + departments.remove(dept); + } /** - * Initialize the identifier. - * - * @param companyid The id of the company. + * Initialize the set of FCDSDepartments in the company to the + * parameter. + * + * @param departments The set of FCDSDepartments for the + * company. */ - public Oid(long companyid) { - this.companyid = companyid; + public void setDepartments(Set departments) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.departments = + (departments != null) ? new HashSet(departments) : null; } - public Oid(String s) { - companyid = Long.parseLong(justTheId(s)); + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + departments = new HashSet(); } + /** + * Returns a String representation of a Company object. + * @return a String representation of a Company object. + */ public String toString() { - return this.getClass().getName() + ": " + companyid; + return "Company(" + getFieldRepr()+ ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(companyid); + rc.append(", name ").append(name); + rc.append(", founded ").append( + founded==null ? "null" : formatter.format(founded)); + return rc.toString(); } - /** */ - public boolean equals(Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return false; - Oid o = (Oid) obj; - if (this.companyid != o.companyid) return false; - return true; + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCDSCompany otherCompany = (FCDSCompany)other; + String where = "Company<" + companyid + ">"; + return + helper.equals(companyid, otherCompany.getCompanyid(), where + ".companyid") & + helper.equals(name, otherCompany.getName(), where + ".name") & + helper.equals(founded, otherCompany.getFounded(), where + ".founded") & + helper.deepEquals(address, otherCompany.getAddress(), where + ".address") & + helper.deepEquals(departments, otherCompany.getDepartments(), where + ".departments"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((FCDSCompany)o); } - /** */ - public int hashCode() { - return (int) companyid; + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((FCDSCompany)o1, (FCDSCompany)o2); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compares this object with the specified Company object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Company object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Company + * object. + */ + public int compareTo(FCDSCompany other) { + return compare(this, other); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (companyid < other.companyid) return -1; - if (companyid > other.companyid) return 1; - return 0; + /** + * Compares its two ICompany arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first ICompany object to be compared. + * @param o2 the second ICompany object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(FCDSCompany o1, FCDSCompany o2) { + return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); } - } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof FCDSCompany) { + return compareTo((FCDSCompany)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)companyid; + } + + /** + * The class to be used as the application identifier + * for the Company class. It consists of both the company + * name and the date that the company was founded. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field is part of the identifier and should match in name + * and type with a field in the Company class. + */ + public long companyid; + + /** The required public no-arg constructor. */ + public Oid() { } + + /** + * Initialize the identifier. + * @param companyid The id of the company. + */ + public Oid(long companyid) { + this.companyid = companyid; + } + + public Oid(String s) { companyid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + companyid;} + + + /** */ + public boolean equals(Object obj) { + if (obj==null || !this.getClass().equals(obj.getClass())) + return false; + Oid o = (Oid) obj; + if (this.companyid != o.companyid) + return false; + return true; + } + + /** */ + public int hashCode() { + return (int)companyid; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( companyid < other.companyid ) return -1; + if( companyid > other.companyid ) return 1; + return 0; + } + + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSDentalInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSDentalInsurance.java index dd075373e..2e162d61e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSDentalInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSDentalInsurance.java @@ -5,125 +5,124 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; +import javax.jdo.annotations.*; + import java.math.BigDecimal; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.DatastoreIdentity; -import javax.jdo.annotations.IdGeneratorStrategy; -import javax.jdo.annotations.PersistenceCapable; import org.apache.jdo.tck.pc.company.IDentalInsurance; import org.apache.jdo.tck.util.EqualityHelper; /** - * This class represents a dental insurance carrier selection for a particular Employee - * . + * This class represents a dental insurance carrier selection for a + * particular Employee. */ @PersistenceCapable -@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "DATASTORE_IDENTITY") -public class FCDSDentalInsurance extends FCDSInsurance implements IDentalInsurance { +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY") +public class FCDSDentalInsurance extends FCDSInsurance + implements IDentalInsurance { - @Column(name = "LIFETIME_ORTHO_BENEFIT") - private BigDecimal lifetimeOrthoBenefit; + @Column(name="LIFETIME_ORTHO_BENEFIT") + private BigDecimal lifetimeOrthoBenefit; - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FCDSDentalInsurance() {} + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCDSDentalInsurance() {} - /** - * Construct a DentalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. - */ - public FCDSDentalInsurance(long insid, String carrier, BigDecimal lifetimeOrthoBenefit) { - super(insid, carrier); - this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; - } + /** + * Construct a DentalInsurance instance. + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public FCDSDentalInsurance(long insid, String carrier, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier); + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } - /** - * Construct a FCDSDentalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param employee The employee associated with this insurance. - * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. - */ - public FCDSDentalInsurance( - long insid, String carrier, FCDSEmployee employee, BigDecimal lifetimeOrthoBenefit) { - super(insid, carrier, employee); - this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; - } + /** + * Construct a FCDSDentalInsurance instance. + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public FCDSDentalInsurance(long insid, String carrier, FCDSEmployee employee, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier, employee); + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } - /** - * Get the insurance lifetimeOrthoBenefit. - * - * @return The insurance lifetimeOrthoBenefit. - */ - public BigDecimal getLifetimeOrthoBenefit() { - return lifetimeOrthoBenefit; - } + /** + * Get the insurance lifetimeOrthoBenefit. + * @return The insurance lifetimeOrthoBenefit. + */ + public BigDecimal getLifetimeOrthoBenefit() { + return lifetimeOrthoBenefit; + } - /** - * Set the insurance lifetimeOrthoBenefit. - * - * @param lifetimeOrthoBenefit The insurance lifetimeOrthoBenefit. - */ - public void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit) { - this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; - } + /** + * Set the insurance lifetimeOrthoBenefit. + * @param lifetimeOrthoBenefit The insurance lifetimeOrthoBenefit. + */ + public void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit) { + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } - /** - * Returns a String representation of a FCDSDentalInsurance object. - * - * @return a String representation of a FCDSDentalInsurance object. - */ - public String toString() { - return "FCDentalInsurance(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of a FCDSDentalInsurance + * object. + * + * @return a String representation of a FCDSDentalInsurance + * object. + */ + public String toString() { + return "FCDentalInsurance(" + getFieldRepr()+ ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", lifetimeOrthoBenefit ").append(lifetimeOrthoBenefit); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", lifetimeOrthoBenefit ").append(lifetimeOrthoBenefit); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCDSDentalInsurance otherIns = (FCDSDentalInsurance)other; + String where = "FCDentalInsurance<" + getInsid() + ">"; + return super.deepCompareFields(otherIns, helper) & + helper.equals(lifetimeOrthoBenefit, + otherIns.getLifetimeOrthoBenefit(), where + ".lifetimeOrthoBenefit"); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Object. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCDSDentalInsurance otherIns = (FCDSDentalInsurance) other; - String where = "FCDentalInsurance<" + getInsid() + ">"; - return super.deepCompareFields(otherIns, helper) - & helper.equals( - lifetimeOrthoBenefit, - otherIns.getLifetimeOrthoBenefit(), - where + ".lifetimeOrthoBenefit"); - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSDepartment.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSDepartment.java index 1490572c0..ddbbb976e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSDepartment.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSDepartment.java @@ -5,447 +5,443 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; -import java.io.IOException; -import java.io.ObjectInputStream; +import javax.jdo.annotations.*; + import java.io.Serializable; +import java.io.ObjectInputStream; +import java.io.IOException; + import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; import org.apache.jdo.tck.pc.company.ICompany; import org.apache.jdo.tck.pc.company.IDepartment; import org.apache.jdo.tck.pc.company.IEmployee; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a department within a company. */ -@PersistenceCapable(table = "departments") +/** + * This class represents a department within a company. + */ +@PersistenceCapable(table="departments") @DatastoreIdDiscriminatorClassNameInheritanceNew public class FCDSDepartment implements IDepartment, Serializable, Comparable, Comparator, DeepEquality { - public static final int RECOMMENDED_NO_OF_EMPS = 2; - - @Column(name = "ID") - private long deptid; - - @Column(name = "NAME") - private String name; - - @Column(name = "COMPANYID") - private FCDSCompany company; - - @Column(name = "EMP_OF_THE_MONTH") - private FCDSEmployee employeeOfTheMonth; - - @Persistent(mappedBy = "department") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSEmployee.class) - private transient Set employees = new HashSet(); - - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSEmployee.class) - @Persistent(mappedBy = "fundingDept") - private transient Set fundedEmps = new HashSet(); - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FCDSDepartment() {} - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - */ - public FCDSDepartment(long deptid, String name) { - this.deptid = deptid; - this.name = name; - } - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - * @param company The company that the department is associated with. - */ - public FCDSDepartment(long deptid, String name, ICompany company) { - this.deptid = deptid; - this.name = name; - this.company = (FCDSCompany) company; - } - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - * @param company The company that the department is associated with. - * @param employeeOfTheMonth The employee of the month the department is associated with. - */ - public FCDSDepartment(long deptid, String name, ICompany company, IEmployee employeeOfTheMonth) { - this.deptid = deptid; - this.name = name; - this.company = (FCDSCompany) company; - this.employeeOfTheMonth = (FCDSEmployee) employeeOfTheMonth; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setDeptid(long id) { - if (this.deptid != 0) throw new IllegalStateException("Id is already set."); - this.deptid = id; - } - - /** - * Get the department id. - * - * @return The department id. - */ - public long getDeptid() { - return deptid; - } - - /** - * Get the name of the department. - * - * @return The name of the department. - */ - public String getName() { - return name; - } - - /** - * Set the name of the department. - * - * @param name The name to set for the department. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Get the company associated with the department. - * - * @return The company. - */ - public ICompany getCompany() { - return company; - } - - /** - * Set the company for the department. - * - * @param company The company to associate with the department. - */ - public void setCompany(ICompany company) { - this.company = (FCDSCompany) company; - } - - /** - * Get the employee of the month associated with the department. - * - * @return The employee of the month. - */ - public IEmployee getEmployeeOfTheMonth() { - return employeeOfTheMonth; - } - - /** - * Set the employee of the month for the department. - * - * @param employeeOfTheMonth The employee of the month to associate with the department. - */ - public void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth) { - this.employeeOfTheMonth = (FCDSEmployee) employeeOfTheMonth; - } - - /** - * Get the employees in the department as an unmodifiable set. - * - * @return The set of employees in the department, as an unmodifiable set. - */ - public Set getEmployees() { - return Collections.unmodifiableSet(employees); - } - - /** - * Add an employee to the department. - * - * @param emp The employee to add to the department. - */ - public void addEmployee(FCDSEmployee emp) { - employees.add(emp); - } - - /** - * Remove an employee from the department. - * - * @param emp The employee to remove from the department. - */ - public void removeEmployee(FCDSEmployee emp) { - employees.remove(emp); - } - - /** - * Set the employees to be in this department. - * - * @param employees The set of employees for this department. - */ - public void setEmployees(Set employees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.employees = (employees != null) ? new HashSet(employees) : null; - } - - /** - * Get the funded employees in the department as an unmodifiable set. - * - * @return The set of funded employees in the department, as an unmodifiable set. - */ - public Set getFundedEmps() { - return Collections.unmodifiableSet(fundedEmps); - } - - /** - * Add an employee to the collection of funded employees of this department. - * - * @param emp The employee to add to the department. - */ - public void addFundedEmp(FCDSEmployee emp) { - fundedEmps.add(emp); - } - - /** - * Remove an employee from collection of funded employees of this department. - * - * @param emp The employee to remove from the department. - */ - public void removeFundedEmp(FCDSEmployee emp) { - fundedEmps.remove(emp); - } - - /** - * Set the funded employees to be in this department. - * - * @param employees The set of funded employees for this department. - */ - public void setFundedEmps(Set employees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.fundedEmps = (fundedEmps != null) ? new HashSet(employees) : null; - } - - @Override - public List getMeetingRooms() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void setMeetingRooms(List rooms) { - // TODO Auto-generated method stub - - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - employees = new HashSet(); - fundedEmps = new HashSet(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other FCDSDepartment. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCDSDepartment otherDept = (FCDSDepartment) other; - String where = "FCDepartment<" + deptid + ">"; - return helper.equals(deptid, otherDept.getDeptid(), where + ".deptid") - & helper.equals(name, otherDept.getName(), where + ".name") - & helper.deepEquals(company, otherDept.getCompany(), where + ".company") - & helper.deepEquals( - employeeOfTheMonth, otherDept.getEmployeeOfTheMonth(), where + ".employeeOfTheMonth") - & helper.deepEquals(employees, otherDept.getEmployees(), where + ".employees") - & helper.deepEquals(fundedEmps, otherDept.getFundedEmps(), where + ".fundedEmps"); - } - - /** - * Returns a String representation of a FCDSDepartment object. - * - * @return a String representation of a FCDSDepartment object. - */ - public String toString() { - return "FCDepartment(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(deptid); - rc.append(", name ").append(name); - return rc.toString(); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((FCDSDepartment) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((FCDSDepartment) o1, (FCDSDepartment) o2); - } - - /** - * Compares this object with the specified Department object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Department object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Department object. - */ - public int compareTo(FCDSDepartment other) { - return compare(this, other); - } - - /** - * Compares its two IDepartment arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IDepartment object to be compared. - * @param o2 the second IDepartment object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(FCDSDepartment o1, FCDSDepartment o2) { - return EqualityHelper.compare(o1.getDeptid(), o2.getDeptid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof FCDSDepartment) { - return compareTo((FCDSDepartment) obj) == 0; + public static final int RECOMMENDED_NO_OF_EMPS = 2; + + @Column(name="ID") + private long deptid; + @Column(name="NAME") + private String name; + @Column(name="COMPANYID") + private FCDSCompany company; + @Column(name="EMP_OF_THE_MONTH") + private FCDSEmployee employeeOfTheMonth; + @Persistent(mappedBy="department") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSEmployee.class) + private transient Set employees = new HashSet(); + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSEmployee.class) + @Persistent(mappedBy="fundingDept") + private transient Set fundedEmps = new HashSet(); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCDSDepartment() {} + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + */ + public FCDSDepartment(long deptid, String name) { + this.deptid = deptid; + this.name = name; + } + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + * @param company The company that the department is associated with. + */ + public FCDSDepartment(long deptid, String name, ICompany company) { + this.deptid = deptid; + this.name = name; + this.company = (FCDSCompany)company; + } + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + * @param company The company that the department is associated with. + * @param employeeOfTheMonth The employee of the month the + * department is associated with. + */ + public FCDSDepartment(long deptid, String name, ICompany company, + IEmployee employeeOfTheMonth) { + this.deptid = deptid; + this.name = name; + this.company = (FCDSCompany)company; + this.employeeOfTheMonth = (FCDSEmployee)employeeOfTheMonth; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setDeptid(long id) { + if (this.deptid != 0) + throw new IllegalStateException("Id is already set."); + this.deptid = id; + } + + /** + * Get the department id. + * @return The department id. + */ + public long getDeptid() { + return deptid; } - return false; - } - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) deptid; - } + /** + * Get the name of the department. + * @return The name of the department. + */ + public String getName() { + return name; + } - /** The application identity class associated with the Department class. */ - public static class Oid implements Serializable, Comparable { + /** + * Set the name of the department. + * @param name The name to set for the department. + */ + public void setName(String name) { + this.name = name; + } /** - * This field represents the application identifier field for the Department class. - * It must match in name and type with the field in the Department class. + * Get the company associated with the department. + * @return The company. */ - public long deptid; + public ICompany getCompany() { + return company; + } - /** The required public, no-arg constructor. */ - public Oid() {} + /** + * Set the company for the department. + * @param company The company to associate with the department. + */ + public void setCompany(ICompany company) { + this.company = (FCDSCompany)company; + } /** - * A constructor to initialize the identifier field. - * - * @param deptid the deptid of the Department. + * Get the employee of the month associated with the department. + * @return The employee of the month. */ - public Oid(long deptid) { - this.deptid = deptid; + public IEmployee getEmployeeOfTheMonth() { + return employeeOfTheMonth; } - public Oid(String s) { - deptid = Long.parseLong(justTheId(s)); + /** + * Set the employee of the month for the department. + * @param employeeOfTheMonth The employee of the month to + * associate with the department. + */ + public void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth) { + this.employeeOfTheMonth = (FCDSEmployee)employeeOfTheMonth; } + /** + * Get the employees in the department as an unmodifiable set. + * @return The set of employees in the department, as an unmodifiable + * set. + */ + public Set getEmployees() { + return Collections.unmodifiableSet(employees); + } + + /** + * Add an employee to the department. + * @param emp The employee to add to the department. + */ + public void addEmployee(FCDSEmployee emp) { + employees.add(emp); + } + + /** + * Remove an employee from the department. + * @param emp The employee to remove from the department. + */ + public void removeEmployee(FCDSEmployee emp) { + employees.remove(emp); + } + + /** + * Set the employees to be in this department. + * @param employees The set of employees for this department. + */ + public void setEmployees(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.employees = (employees != null) ? new HashSet(employees) : null; + } + + /** + * Get the funded employees in the department as an unmodifiable set. + * @return The set of funded employees in the department, as an + * unmodifiable set. + */ + public Set getFundedEmps() { + return Collections.unmodifiableSet(fundedEmps); + } + + /** + * Add an employee to the collection of funded employees of this + * department. + * @param emp The employee to add to the department. + */ + public void addFundedEmp(FCDSEmployee emp) { + fundedEmps.add(emp); + } + + /** + * Remove an employee from collection of funded employees of this + * department. + * @param emp The employee to remove from the department. + */ + public void removeFundedEmp(FCDSEmployee emp) { + fundedEmps.remove(emp); + } + + /** + * Set the funded employees to be in this department. + * @param employees The set of funded employees for this department. + */ + public void setFundedEmps(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.fundedEmps = (fundedEmps != null) ? new HashSet(employees) : null; + } + + @Override + public List getMeetingRooms() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setMeetingRooms(List rooms) { + // TODO Auto-generated method stub + + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + employees = new HashSet(); + fundedEmps = new HashSet(); + } + + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other FCDSDepartment. + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCDSDepartment otherDept = (FCDSDepartment)other; + String where = "FCDepartment<" + deptid + ">"; + return + helper.equals(deptid, otherDept.getDeptid(), where + ".deptid") & + helper.equals(name, otherDept.getName(), where + ".name") & + helper.deepEquals(company, otherDept.getCompany(), where + ".company") & + helper.deepEquals(employeeOfTheMonth, otherDept.getEmployeeOfTheMonth(), where + ".employeeOfTheMonth") & + helper.deepEquals(employees, otherDept.getEmployees(), where + ".employees") & + helper.deepEquals(fundedEmps, otherDept.getFundedEmps(), where + ".fundedEmps"); + } + + /** + * Returns a String representation of a FCDSDepartment object. + * + * @return a String representation of a FCDSDepartment object. + */ public String toString() { - return this.getClass().getName() + ": " + deptid; + return "FCDepartment(" + getFieldRepr()+ ")"; } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.deptid != o.deptid) return (false); - return (true); + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(deptid); + rc.append(", name ").append(name); + return rc.toString(); } - /** */ - public int hashCode() { - return ((int) deptid); + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((FCDSDepartment)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((FCDSDepartment)o1, (FCDSDepartment)o2); + } + + /** + * Compares this object with the specified Department object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Department object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified + * Department object. + */ + public int compareTo(FCDSDepartment other) { + return compare(this, other); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compares its two IDepartment arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IDepartment object to be compared. + * @param o2 the second IDepartment object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(FCDSDepartment o1, FCDSDepartment o2) { + return EqualityHelper.compare(o1.getDeptid(), o2.getDeptid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof FCDSDepartment) { + return compareTo((FCDSDepartment)obj) == 0; + } + return false; } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)deptid; + } + + /** + * The application identity class associated with the + * Department class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the application identifier field + * for the Department class. + * It must match in name and type with the field in the + * Department class. + */ + public long deptid; + + /** + * The required public, no-arg constructor. + */ + public Oid() { } + + /** + * A constructor to initialize the identifier field. + * @param deptid the deptid of the Department. + */ + public Oid(long deptid) { + this.deptid = deptid; + } + + public Oid(String s) { deptid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + deptid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.deptid != o.deptid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) deptid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( deptid < other.deptid ) return -1; + if( deptid > other.deptid ) return 1; + return 0; + } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (deptid < other.deptid) return -1; - if (deptid > other.deptid) return 1; - return 0; } - } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSEmployee.java index 57b9ad563..cbef486c0 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSEmployee.java @@ -5,542 +5,506 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; -import java.io.IOException; +import javax.jdo.annotations.*; + import java.io.ObjectInputStream; +import java.io.IOException; + import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; import org.apache.jdo.tck.pc.company.IDentalInsurance; import org.apache.jdo.tck.pc.company.IDepartment; import org.apache.jdo.tck.pc.company.IEmployee; import org.apache.jdo.tck.pc.company.IMedicalInsurance; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents an employee. */ +/** + * This class represents an employee. + */ @DatastoreIdDiscriminatorClassNameInheritanceSuperclass -@PersistenceCapable(table = "persons") +@PersistenceCapable(table="persons") public abstract class FCDSEmployee extends FCDSPerson implements IEmployee { - @Column(name = "HIREDATE") - private Date hiredate; - - @Column(name = "WEEKLYHOURS") - private double weeklyhours; - - @Persistent(mappedBy = "employee") - private FCDSDentalInsurance dentalInsurance; - - @Persistent(mappedBy = "employee") - private FCDSMedicalInsurance medicalInsurance; - - @Column(name = "DEPARTMENT") - private FCDSDepartment department; - - @Column(name = "FUNDINGDEPT") - private FCDSDepartment fundingDept; - - @Column(name = "MANAGER") - private FCDSEmployee manager; - - @Column(name = "MENTOR") - private FCDSEmployee mentor; - - @Persistent(mappedBy = "mentor") - private FCDSEmployee protege; - - @Column(name = "HRADVISOR") - private FCDSEmployee hradvisor; - - @Persistent(mappedBy = "reviewers") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSProject.class) - private transient Set reviewedProjects = new HashSet(); - - @Persistent(mappedBy = "members") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSProject.class) - private transient Set projects = new HashSet(); - - @Persistent(mappedBy = "manager") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSEmployee.class) - private transient Set team = new HashSet(); - - @Persistent(mappedBy = "hradvisor") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSEmployee.class) - private transient Set hradvisees = new HashSet(); - - /** This is the JDO-required no-args constructor */ - protected FCDSEmployee() {} - - /** - * Construct an FCDSEmployee instance. - * - * @param personid The identifier for the person. - * @param firstname The first name of the employee. - * @param lastname The last name of the employee. - * @param middlename The middle name of the employee. - * @param birthdate The birth date of the employee. - * @param hiredate The date that the employee was hired. - */ - public FCDSEmployee( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - Date hiredate) { - super(personid, firstname, lastname, middlename, birthdate); - this.hiredate = hiredate; - } - - /** - * Construct an FCDSEmployee instance. - * - * @param personid The identifier for the person. - * @param firstname The first name of the employee. - * @param lastname The last name of the employee. - * @param middlename The middle name of the employee. - * @param birthdate The birth date of the employee. - * @param address The address of the employee. - * @param hiredate The date that the employee was hired. - */ - public FCDSEmployee( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - FCDSAddress address, - Date hiredate) { - super(personid, firstname, lastname, middlename, birthdate, address); - this.hiredate = hiredate; - } - - /** - * Get the date that the employee was hired. - * - * @return The date the employee was hired. - */ - public Date getHiredate() { - return hiredate; - } - - /** - * Set the date that the employee was hired. - * - * @param hiredate The date the employee was hired. - */ - public void setHiredate(Date hiredate) { - this.hiredate = hiredate; - } - - /** - * Get the weekly hours of the employee. - * - * @return The number of hours per week that the employee works. - */ - public double getWeeklyhours() { - return weeklyhours; - } - - /** - * Set the number of hours per week that the employee works. - * - * @param weeklyhours The number of hours per week that the employee works. - */ - public void setWeeklyhours(double weeklyhours) { - this.weeklyhours = weeklyhours; - } - - /** - * Get the reviewed projects. - * - * @return The reviewed projects as an unmodifiable set. - */ - public Set getReviewedProjects() { - return Collections.unmodifiableSet(reviewedProjects); - } - - /** - * Add a reviewed project. - * - * @param project A reviewed project. - */ - public void addReviewedProjects(FCDSProject project) { - reviewedProjects.add(project); - } - - /** - * Remove a reviewed project. - * - * @param project A reviewed project. - */ - public void removeReviewedProject(FCDSProject project) { - reviewedProjects.remove(project); - } - - /** - * Set the reviewed projects for the employee. - * - * @param reviewedProjects The set of reviewed projects. - */ - public void setReviewedProjects(Set reviewedProjects) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.reviewedProjects = (reviewedProjects != null) ? new HashSet(reviewedProjects) : null; - } - - /** - * Get the employee's projects. - * - * @return The employee's projects are returned as an unmodifiable set. - */ - public Set getProjects() { - return Collections.unmodifiableSet(projects); - } - - /** - * Add a project for the employee. - * - * @param project The project. - */ - public void addProject(FCDSProject project) { - projects.add(project); - } - - /** - * Remove a project from an employee's set of projects. - * - * @param project The project. - */ - public void removeProject(FCDSProject project) { - projects.remove(project); - } - - /** - * Set the projects for the employee. - * - * @param projects The set of projects of the employee. - */ - public void setProjects(Set projects) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.projects = (projects != null) ? new HashSet(projects) : null; - } - - /** - * Get the dental insurance of the employee. - * - * @return The employee's dental insurance. - */ - public IDentalInsurance getDentalInsurance() { - return dentalInsurance; - } - - /** - * Set the dental insurance object for the employee. - * - * @param dentalInsurance The dental insurance object to associate with the employee. - */ - public void setDentalInsurance(IDentalInsurance dentalInsurance) { - this.dentalInsurance = (FCDSDentalInsurance) dentalInsurance; - } - /** - * Get the medical insurance of the employee. - * - * @return The employee's medical insurance. - */ - public IMedicalInsurance getMedicalInsurance() { - return medicalInsurance; - } - - /** - * Set the medical insurance object for the employee. - * - * @param medicalInsurance The medical insurance object to associate with the employee. - */ - public void setMedicalInsurance(IMedicalInsurance medicalInsurance) { - this.medicalInsurance = (FCDSMedicalInsurance) medicalInsurance; - } - - /** - * Get the employee's department. - * - * @return The department associated with the employee. - */ - public IDepartment getDepartment() { - return department; - } - - /** - * Set the employee's department. - * - * @param department The department. - */ - public void setDepartment(IDepartment department) { - this.department = (FCDSDepartment) department; - } - - /** - * Get the employee's funding department. - * - * @return The funding department associated with the employee. - */ - public IDepartment getFundingDept() { - return fundingDept; - } - - /** - * Set the employee's funding department. - * - * @param department The funding department. - */ - public void setFundingDept(IDepartment department) { - this.fundingDept = (FCDSDepartment) department; - } - - /** - * Get the employee's manager. - * - * @return The employee's manager. - */ - public IEmployee getManager() { - return manager; - } - - /** - * Set the employee's manager. - * - * @param manager The employee's manager. - */ - public void setManager(IEmployee manager) { - this.manager = (FCDSEmployee) manager; - } - - /** - * Get the employee's team. - * - * @return The set of FCDSEmployees on this employee's team, returned as an - * unmodifiable set. - */ - public Set getTeam() { - return Collections.unmodifiableSet(team); - } - - /** - * Add an FCDSEmployee to this employee's team. This method sets both sides of the - * relationship, modifying this employees team to include parameter emp and modifying emp to set - * its manager attribute to this object. - * - * @param emp The FCDSEmployee to add to the team. - */ - public void addToTeam(FCDSEmployee emp) { - team.add(emp); - emp.manager = this; - } - - /** - * Remove an FCDSEmployee from this employee's team. This method will also set the - * emp manager to null. - * - * @param emp The FCDSEmployee to remove from the team. - */ - public void removeFromTeam(FCDSEmployee emp) { - team.remove(emp); - emp.manager = null; - } - - /** - * Set the employee's team. - * - * @param team The set of FCDSEmployees. - */ - public void setTeam(Set team) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.team = (team != null) ? new HashSet(team) : null; - } - - /** - * Set the mentor for this employee. - * - * @param mentor The mentor for this employee. - */ - public void setMentor(IEmployee mentor) { - this.mentor = (FCDSEmployee) mentor; - } - - /** - * Get the mentor for this employee. - * - * @return The mentor. - */ - public IEmployee getMentor() { - return mentor; - } - - /** - * Set the protege for this employee. - * - * @param protege The protege for this employee. - */ - public void setProtege(IEmployee protege) { - this.protege = (FCDSEmployee) protege; - } - - /** - * Get the protege of this employee. - * - * @return The protege of this employee. - */ - public IEmployee getProtege() { - return protege; - } - - /** - * Set the HR advisor for this employee. - * - * @param hradvisor The hradvisor for this employee. - */ - public void setHradvisor(IEmployee hradvisor) { - this.hradvisor = (FCDSEmployee) hradvisor; - } - - /** - * Get the HR advisor for the employee. - * - * @return The HR advisor. - */ - public IEmployee getHradvisor() { - return hradvisor; - } - - /** - * Get the HR advisees of this HR advisor. - * - * @return An unmodifiable Set containing the FCDSEmployees that are HR - * advisees of this employee. - */ - public Set getHradvisees() { - return Collections.unmodifiableSet(hradvisees); - } - - /** - * Add an FCDSEmployee as an advisee of this HR advisor. This method also sets the - * emp hradvisor to reference this object. In other words, both sides of the - * relationship are set. - * - * @param emp The employee to add as an advisee. - */ - public void addAdvisee(FCDSEmployee emp) { - hradvisees.add(emp); - emp.hradvisor = this; - } - - /** - * Remove an FCDSEmployee as an advisee of this HR advisor. This method also sets the - * emp hradvisor to null. In other words, both sides of the relationship are set. - * - * @param emp The employee to add as an HR advisee. - */ - public void removeAdvisee(FCDSEmployee emp) { - hradvisees.remove(emp); - emp.hradvisor = null; - } - - /** - * Set the HR advisees of this HR advisor. - * - * @param hradvisees The FCDSEmployees that are HR advisees of this employee. - */ - public void setHradvisees(Set hradvisees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.hradvisees = (hradvisees != null) ? new HashSet(hradvisees) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - reviewedProjects = new HashSet(); - projects = new HashSet(); - team = new HashSet(); - hradvisees = new HashSet(); - } - - /** - * Return a String representation of a FCDSEmployee object. - * - * @return a String representation of a FCDSEmployee object. - */ - public String toString() { - return "FCEmployee(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", hired ").append(hiredate == null ? "null" : formatter.format(hiredate)); - rc.append(", weeklyhours ").append(weeklyhours); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the - * corresponding fields of the specified FCDSEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCDSEmployee otherEmp = (FCDSEmployee) other; - String where = "Employee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.equals(hiredate, otherEmp.getHiredate(), where + ".hiredate") - & helper.closeEnough(weeklyhours, otherEmp.getWeeklyhours(), where + ".weeklyhours") - & helper.deepEquals( - dentalInsurance, otherEmp.getDentalInsurance(), where + ".dentalInsurance") - & helper.deepEquals( - medicalInsurance, otherEmp.getMedicalInsurance(), where + ".medicalInsurance") - & helper.deepEquals(department, otherEmp.getDepartment(), where + ".department") - & helper.deepEquals(fundingDept, otherEmp.getFundingDept(), where + ".fundingDept") - & helper.deepEquals(manager, otherEmp.getManager(), where + ".manager") - & helper.deepEquals(mentor, otherEmp.getMentor(), where + ".mentor") - & helper.deepEquals(protege, otherEmp.getProtege(), where + ".protege") - & helper.deepEquals(hradvisor, otherEmp.getHradvisor(), where + ".hradvisor") - & helper.deepEquals( - reviewedProjects, otherEmp.getReviewedProjects(), where + ".reviewedProjects") - & helper.deepEquals(projects, otherEmp.getProjects(), where + ".projects") - & helper.deepEquals(team, otherEmp.getTeam(), where + ".team") - & helper.deepEquals(hradvisees, otherEmp.getHradvisees(), where + ".hradvisees"); - } + @Column(name="HIREDATE") + private Date hiredate; + @Column(name="WEEKLYHOURS") + private double weeklyhours; + @Persistent(mappedBy="employee") + private FCDSDentalInsurance dentalInsurance; + @Persistent(mappedBy="employee") + private FCDSMedicalInsurance medicalInsurance; + @Column(name="DEPARTMENT") + private FCDSDepartment department; + @Column(name="FUNDINGDEPT") + private FCDSDepartment fundingDept; + @Column(name="MANAGER") + private FCDSEmployee manager; + @Column(name="MENTOR") + private FCDSEmployee mentor; + @Persistent(mappedBy="mentor") + private FCDSEmployee protege; + @Column(name="HRADVISOR") + private FCDSEmployee hradvisor; + @Persistent(mappedBy="reviewers") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSProject.class) + private transient Set reviewedProjects = new HashSet(); + @Persistent(mappedBy="members") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSProject.class) + private transient Set projects = new HashSet(); + @Persistent(mappedBy="manager") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSEmployee.class) + private transient Set team = new HashSet(); + @Persistent(mappedBy="hradvisor") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSEmployee.class) + private transient Set hradvisees = new HashSet(); + + + /** This is the JDO-required no-args constructor */ + protected FCDSEmployee() {} + + /** + * Construct an FCDSEmployee instance. + * + * @param personid The identifier for the person. + * @param firstname The first name of the employee. + * @param lastname The last name of the employee. + * @param middlename The middle name of the employee. + * @param birthdate The birth date of the employee. + * @param hiredate The date that the employee was hired. + */ + public FCDSEmployee(long personid, String firstname, String lastname, + String middlename, Date birthdate, + Date hiredate) { + super(personid, firstname, lastname, middlename, birthdate); + this.hiredate = hiredate; + } + + /** + * Construct an FCDSEmployee instance. + * + * @param personid The identifier for the person. + * @param firstname The first name of the employee. + * @param lastname The last name of the employee. + * @param middlename The middle name of the employee. + * @param birthdate The birth date of the employee. + * @param address The address of the employee. + * @param hiredate The date that the employee was hired. + */ + public FCDSEmployee(long personid, String firstname, String lastname, + String middlename, Date birthdate, FCDSAddress address, + Date hiredate) { + super(personid, firstname, lastname, middlename, birthdate, address); + this.hiredate = hiredate; + } + + /** + * Get the date that the employee was hired. + * @return The date the employee was hired. + */ + public Date getHiredate() { + return hiredate; + } + + /** + * Set the date that the employee was hired. + * @param hiredate The date the employee was hired. + */ + public void setHiredate(Date hiredate) { + this.hiredate = hiredate; + } + + /** + * Get the weekly hours of the employee. + * @return The number of hours per week that the employee works. + */ + public double getWeeklyhours() { + return weeklyhours; + } + + /** + * Set the number of hours per week that the employee works. + * @param weeklyhours The number of hours per week that the employee + * works. + */ + public void setWeeklyhours(double weeklyhours) { + this.weeklyhours = weeklyhours; + } + + /** + * Get the reviewed projects. + * @return The reviewed projects as an unmodifiable set. + */ + public Set getReviewedProjects() { + return Collections.unmodifiableSet(reviewedProjects); + } + + /** + * Add a reviewed project. + * @param project A reviewed project. + */ + public void addReviewedProjects(FCDSProject project) { + reviewedProjects.add(project); + } + + /** + * Remove a reviewed project. + * @param project A reviewed project. + */ + public void removeReviewedProject(FCDSProject project) { + reviewedProjects.remove(project); + } + + /** + * Set the reviewed projects for the employee. + * @param reviewedProjects The set of reviewed projects. + */ + public void setReviewedProjects(Set reviewedProjects) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.reviewedProjects = + (reviewedProjects != null) ? new HashSet(reviewedProjects) : null; + } + + /** + * Get the employee's projects. + * @return The employee's projects are returned as an unmodifiable + * set. + */ + public Set getProjects() { + return Collections.unmodifiableSet(projects); + } + + /** + * Add a project for the employee. + * @param project The project. + */ + public void addProject(FCDSProject project) { + projects.add(project); + } + + /** + * Remove a project from an employee's set of projects. + * @param project The project. + */ + public void removeProject(FCDSProject project) { + projects.remove(project); + } + + /** + * Set the projects for the employee. + * @param projects The set of projects of the employee. + */ + public void setProjects(Set projects) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.projects = (projects != null) ? new HashSet(projects) : null; + } + + /** + * Get the dental insurance of the employee. + * @return The employee's dental insurance. + */ + public IDentalInsurance getDentalInsurance() { + return dentalInsurance; + } + + /** + * Set the dental insurance object for the employee. + * @param dentalInsurance The dental insurance object to associate with + * the employee. + */ + public void setDentalInsurance(IDentalInsurance dentalInsurance) { + this.dentalInsurance = (FCDSDentalInsurance)dentalInsurance; + } + /** + * Get the medical insurance of the employee. + * @return The employee's medical insurance. + */ + public IMedicalInsurance getMedicalInsurance() { + return medicalInsurance; + } + + /** + * Set the medical insurance object for the employee. + * @param medicalInsurance The medical insurance object to associate + * with the employee. + */ + public void setMedicalInsurance(IMedicalInsurance medicalInsurance) { + this.medicalInsurance = (FCDSMedicalInsurance)medicalInsurance; + } + + /** + * Get the employee's department. + * @return The department associated with the employee. + */ + public IDepartment getDepartment() { + return department; + } + + /** + * Set the employee's department. + * @param department The department. + */ + public void setDepartment(IDepartment department) { + this.department = (FCDSDepartment)department; + } + + /** + * Get the employee's funding department. + * @return The funding department associated with the employee. + */ + public IDepartment getFundingDept() { + return fundingDept; + } + + /** + * Set the employee's funding department. + * @param department The funding department. + */ + public void setFundingDept(IDepartment department) { + this.fundingDept = (FCDSDepartment)department; + } + + /** + * Get the employee's manager. + * @return The employee's manager. + */ + public IEmployee getManager() { + return manager; + } + + /** + * Set the employee's manager. + * @param manager The employee's manager. + */ + public void setManager(IEmployee manager) { + this.manager = (FCDSEmployee)manager; + } + + /** + * Get the employee's team. + * + * @return The set of FCDSEmployees on this employee's team, + * returned as an unmodifiable set. + */ + public Set getTeam() { + return Collections.unmodifiableSet(team); + } + + /** + * Add an FCDSEmployee to this employee's team. + * This method sets both sides of the relationship, modifying + * this employees team to include parameter emp and modifying + * emp to set its manager attribute to this object. + * + * @param emp The FCDSEmployee to add to the team. + */ + public void addToTeam(FCDSEmployee emp) { + team.add(emp); + emp.manager = this; + } + + /** + * Remove an FCDSEmployee from this employee's team. + * This method will also set the emp manager to null. + * + * @param emp The FCDSEmployee to remove from the team. + */ + public void removeFromTeam(FCDSEmployee emp) { + team.remove(emp); + emp.manager = null; + } + + /** + * Set the employee's team. + * + * @param team The set of FCDSEmployees. + */ + public void setTeam(Set team) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.team = (team != null) ? new HashSet(team) : null; + } + + /** + * Set the mentor for this employee. + * @param mentor The mentor for this employee. + */ + public void setMentor(IEmployee mentor) { + this.mentor = (FCDSEmployee)mentor; + } + + /** + * Get the mentor for this employee. + * @return The mentor. + */ + public IEmployee getMentor() { + return mentor; + } + + /** + * Set the protege for this employee. + * @param protege The protege for this employee. + */ + public void setProtege(IEmployee protege) { + this.protege = (FCDSEmployee)protege; + } + + /** + * Get the protege of this employee. + * @return The protege of this employee. + */ + public IEmployee getProtege() { + return protege; + } + + /** + * Set the HR advisor for this employee. + * @param hradvisor The hradvisor for this employee. + */ + public void setHradvisor(IEmployee hradvisor) { + this.hradvisor = (FCDSEmployee)hradvisor; + } + + /** + * Get the HR advisor for the employee. + * @return The HR advisor. + */ + public IEmployee getHradvisor() { + return hradvisor; + } + + /** + * Get the HR advisees of this HR advisor. + * + * @return An unmodifiable Set containing the + * FCDSEmployees that are HR advisees of this employee. + */ + public Set getHradvisees() { + return Collections.unmodifiableSet(hradvisees); + } + + /** + * Add an FCDSEmployee as an advisee of this HR advisor. + * This method also sets the emp hradvisor to reference + * this object. In other words, both sides of the relationship are + * set. + * + * @param emp The employee to add as an advisee. + */ + public void addAdvisee(FCDSEmployee emp) { + hradvisees.add(emp); + emp.hradvisor = this; + } + + /** + * Remove an FCDSEmployee as an advisee of this HR advisor. + * This method also sets the emp hradvisor to null. + * In other words, both sides of the relationship are set. + * + * @param emp The employee to add as an HR advisee. + */ + public void removeAdvisee(FCDSEmployee emp) { + hradvisees.remove(emp); + emp.hradvisor = null; + } + + /** + * Set the HR advisees of this HR advisor. + * + * @param hradvisees The FCDSEmployees that are HR advisees of + * this employee. + */ + public void setHradvisees(Set hradvisees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.hradvisees = (hradvisees != null) ? new HashSet(hradvisees) : null; + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + reviewedProjects = new HashSet(); + projects = new HashSet(); + team = new HashSet(); + hradvisees = new HashSet(); + } + + /** + * Return a String representation of a FCDSEmployee object. + * + * @return a String representation of a FCDSEmployee object. + */ + public String toString() { + return "FCEmployee(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", hired ").append( + hiredate==null ? "null" : formatter.format(hiredate)); + rc.append(", weeklyhours ").append(weeklyhours); + return rc.toString(); + } + + /** + * + * Returns true if all the fields of this instance are + * deep equal to the corresponding fields of the specified FCDSEmployee. + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCDSEmployee otherEmp = (FCDSEmployee)other; + String where = "Employee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.equals(hiredate, otherEmp.getHiredate(), where + ".hiredate") & + helper.closeEnough(weeklyhours, otherEmp.getWeeklyhours(), where + ".weeklyhours") & + helper.deepEquals(dentalInsurance, otherEmp.getDentalInsurance(), where + ".dentalInsurance") & + helper.deepEquals(medicalInsurance, otherEmp.getMedicalInsurance(), where + ".medicalInsurance") & + helper.deepEquals(department, otherEmp.getDepartment(), where + ".department") & + helper.deepEquals(fundingDept, otherEmp.getFundingDept(), where + ".fundingDept") & + helper.deepEquals(manager, otherEmp.getManager(), where + ".manager") & + helper.deepEquals(mentor, otherEmp.getMentor(), where + ".mentor") & + helper.deepEquals(protege, otherEmp.getProtege(), where + ".protege") & + helper.deepEquals(hradvisor, otherEmp.getHradvisor(), where + ".hradvisor") & + helper.deepEquals(reviewedProjects, otherEmp.getReviewedProjects(), where + ".reviewedProjects") & + helper.deepEquals(projects, otherEmp.getProjects(), where + ".projects") & + helper.deepEquals(team, otherEmp.getTeam(), where + ".team") & + helper.deepEquals(hradvisees, otherEmp.getHradvisees(), where + ".hradvisees"); + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSFullTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSFullTimeEmployee.java index 82b71d14e..b6183ffe4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSFullTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSFullTimeEmployee.java @@ -5,134 +5,132 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; +import javax.jdo.annotations.*; + import java.util.Date; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.PersistenceCapable; import org.apache.jdo.tck.pc.company.IAddress; import org.apache.jdo.tck.pc.company.IFullTimeEmployee; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a full-time employee. */ +/** + * This class represents a full-time employee. + */ @DatastoreIdDiscriminatorClassNameInheritanceSuperclass -@PersistenceCapable(table = "persons") -public class FCDSFullTimeEmployee extends FCDSEmployee implements IFullTimeEmployee { - - @Column(name = "SALARY") - private double salary; - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FCDSFullTimeEmployee() {} +@PersistenceCapable(table="persons") +public class FCDSFullTimeEmployee extends FCDSEmployee + implements IFullTimeEmployee { - /** - * Construct a full-time employee. - * - * @param personid The person identifier. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param hired The date that the person was hired. - * @param sal The salary of the full-time employee. - */ - public FCDSFullTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double sal) { - super(personid, first, last, middle, born, hired); - salary = sal; - } + @Column(name="SALARY") + private double salary; - /** - * Construct a full-time employee. - * - * @param personid The person identifier. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param addr The person's address. - * @param hired The date that the person was hired. - * @param sal The salary of the full-time employee. - */ - public FCDSFullTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - IAddress addr, - Date hired, - double sal) { - super(personid, first, last, middle, born, (FCDSAddress) addr, hired); - salary = sal; - } + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCDSFullTimeEmployee() {} - /** - * Get the salary of the full time employee. - * - * @return The salary of the full time employee. - */ - public double getSalary() { - return salary; - } + /** + * Construct a full-time employee. + * @param personid The person identifier. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param hired The date that the person was hired. + * @param sal The salary of the full-time employee. + */ + public FCDSFullTimeEmployee(long personid, String first, String last, + String middle, Date born, + Date hired, double sal) { + super(personid, first, last, middle, born, hired); + salary = sal; + } - /** - * Set the salary for the full-time employee. - * - * @param salary The salary to set for the full-time employee. - */ - public void setSalary(double salary) { - this.salary = salary; - } + /** + * Construct a full-time employee. + * @param personid The person identifier. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param addr The person's address. + * @param hired The date that the person was hired. + * @param sal The salary of the full-time employee. + */ + public FCDSFullTimeEmployee(long personid, String first, String last, + String middle, Date born, IAddress addr, + Date hired, double sal) { + super(personid, first, last, middle, born, (FCDSAddress)addr, hired); + salary = sal; + } - /** - * Return a String representation of a FCDSFullTimeEmployee object. - * - * @return a String representation of a FCDSFullTimeEmployee object. - */ - public String toString() { - return "FCFullTimeEmployee(" + getFieldRepr() + ")"; - } + /** + * Get the salary of the full time employee. + * @return The salary of the full time employee. + */ + public double getSalary() { + return salary; + } + + /** + * Set the salary for the full-time employee. + * @param salary The salary to set for the full-time employee. + */ + public void setSalary(double salary) { + this.salary = salary; + } + + /** + * Return a String representation of a FCDSFullTimeEmployee object. + * + * @return a String representation of a FCDSFullTimeEmployee object. + */ + public String toString() { + return "FCFullTimeEmployee(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - public String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", $").append(salary); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + public String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", $").append(salary); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified FCDSFullTimeEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCDSFullTimeEmployee otherEmp = (FCDSFullTimeEmployee) other; - String where = "FCFullTimeEmployee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.closeEnough(salary, otherEmp.getSalary(), where + ".salary"); - } + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified + * FCDSFullTimeEmployee. + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCDSFullTimeEmployee otherEmp = (FCDSFullTimeEmployee)other; + String where = "FCFullTimeEmployee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.closeEnough(salary, otherEmp.getSalary(), where + ".salary"); + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSInsurance.java index 8184e9e5f..df7ec8c22 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSInsurance.java @@ -5,293 +5,293 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; +import javax.jdo.annotations.*; + import java.io.Serializable; + import java.util.Comparator; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Index; -import javax.jdo.annotations.PersistenceCapable; import org.apache.jdo.tck.pc.company.IEmployee; import org.apache.jdo.tck.pc.company.IInsurance; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; /** - * This class represents an insurance carrier selection for a particular FCDSEmployee. + * This class represents an insurance carrier selection for a particular + * FCDSEmployee. */ @DatastoreIdDiscriminatorClassNameInheritanceNew -@PersistenceCapable(table = "insuranceplans") -@Index( - name = "INS_DISCRIMINATOR_INDEX", - unique = "false", - columns = @Column(name = "DISCRIMINATOR")) -public class FCDSInsurance - implements IInsurance, Serializable, Comparable, Comparator, DeepEquality { - - @Column(name = "INSID") - private long insid; - - @Column(name = "CARRIER") - private String carrier; - - @Column(name = "EMPLOYEE") - private FCDSEmployee employee; - - /** This is the JDO-required no-args constructor. */ - protected FCDSInsurance() {} - - /** - * Construct an FCDSInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - */ - protected FCDSInsurance(long insid, String carrier) { - this.insid = insid; - this.carrier = carrier; - } - - /** - * Construct an FCDSInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param employee The employee associated with this insurance. - */ - protected FCDSInsurance(long insid, String carrier, FCDSEmployee employee) { - this.insid = insid; - this.carrier = carrier; - this.employee = employee; - } - - /** - * Get the insurance ID. - * - * @return the insurance ID. - */ - public long getInsid() { - return insid; - } - - /** - * Set the insurance ID. - * - * @param id The insurance ID value. - */ - public void setInsid(long id) { - if (this.insid != 0) throw new IllegalStateException("Id is already set."); - this.insid = id; - } - - /** - * Get the insurance carrier. - * - * @return The insurance carrier. - */ - public String getCarrier() { - return carrier; - } - - /** - * Set the insurance carrier. - * - * @param carrier The insurance carrier. - */ - public void setCarrier(String carrier) { - this.carrier = carrier; - } - - /** - * Get the associated employee. - * - * @return The employee for this insurance. - */ - public IEmployee getEmployee() { - return employee; - } - - /** - * Set the associated employee. - * - * @param employee The associated employee. - */ - public void setEmployee(IEmployee employee) { - this.employee = (FCDSEmployee) employee; - } +@PersistenceCapable(table="insuranceplans") +@Index(name="INS_DISCRIMINATOR_INDEX", unique="false", + columns=@Column(name="DISCRIMINATOR")) +public class FCDSInsurance + implements IInsurance, Serializable, Comparable, Comparator, DeepEquality { + + @Column(name="INSID") + private long insid; + @Column(name="CARRIER") + private String carrier; + @Column(name="EMPLOYEE") + private FCDSEmployee employee; + + /** This is the JDO-required no-args constructor. */ + protected FCDSInsurance() {} - /** - * Returns a String representation of a FCDSInsurance object. - * - * @return a String representation of a FCDSInsurance object. - */ - public String toString() { - return "FCInsurance(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(insid); - rc.append(", carrier ").append(carrier); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Object. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCDSInsurance otherIns = (FCDSInsurance) other; - String where = "FCInsurance<" + insid + ">"; - return helper.equals(insid, otherIns.getInsid(), where + ".insid") - & helper.equals(carrier, otherIns.getCarrier(), where + ".carrier") - & helper.deepEquals(employee, otherIns.getEmployee(), where + ".employee"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((FCDSInsurance) o); - } + /** + * Construct an FCDSInsurance instance. + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + */ + protected FCDSInsurance(long insid, String carrier) { + this.insid = insid; + this.carrier = carrier; + } - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((FCDSInsurance) o1, (FCDSInsurance) o2); - } + /** + * Construct an FCDSInsurance instance. + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + */ + protected FCDSInsurance(long insid, String carrier, FCDSEmployee employee) { + this.insid = insid; + this.carrier = carrier; + this.employee = employee; + } - /** - * Compares this object with the specified Insurance object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Insurance object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Insurance object. - */ - public int compareTo(FCDSInsurance other) { - return compare(this, other); - } + /** + * Get the insurance ID. + * @return the insurance ID. + */ + public long getInsid() { + return insid; + } - /** - * Compares its two IInsurance arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IInsurance object to be compared. - * @param o2 the second IInsurance object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(FCDSInsurance o1, FCDSInsurance o2) { - return EqualityHelper.compare(o1.getInsid(), o2.getInsid()); - } + /** + * Set the insurance ID. + * @param id The insurance ID value. + */ + public void setInsid(long id) { + if (this.insid != 0) + throw new IllegalStateException("Id is already set."); + this.insid = id; + } - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof FCDSInsurance) { - return compareTo((FCDSInsurance) obj) == 0; + /** + * Get the insurance carrier. + * @return The insurance carrier. + */ + public String getCarrier() { + return carrier; } - return false; - } - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) insid; - } + /** + * Set the insurance carrier. + * @param carrier The insurance carrier. + */ + public void setCarrier(String carrier) { + this.carrier = carrier; + } + + /** + * Get the associated employee. + * @return The employee for this insurance. + */ + public IEmployee getEmployee() { + return employee; + } - /** - * This class is used to represent the application identifier for the Insurance - * class. - */ - public static class Oid implements Serializable, Comparable { /** - * This field represents the application identifier for the Insurance class. It - * must match the field in the Insurance class in both name and type. + * Set the associated employee. + * @param employee The associated employee. */ - public long insid; + public void setEmployee(IEmployee employee) { + this.employee = (FCDSEmployee)employee; + } - /** The required public no-args constructor. */ - public Oid() {} + /** + * Returns a String representation of a FCDSInsurance object. + * + * @return a String representation of a FCDSInsurance object. + */ + public String toString() { + return "FCInsurance(" + getFieldRepr() + ")"; + } /** - * Initialize with an insurance identifier. - * - * @param insid the insurance ID. + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. */ - public Oid(long insid) { - this.insid = insid; + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(insid); + rc.append(", carrier ").append(carrier); + return rc.toString(); } - public Oid(String s) { - insid = Long.parseLong(justTheId(s)); + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCDSInsurance otherIns = (FCDSInsurance)other; + String where = "FCInsurance<" + insid + ">"; + return + helper.equals(insid, otherIns.getInsid(), where + ".insid") & + helper.equals(carrier, otherIns.getCarrier(), where + ".carrier") & + helper.deepEquals(employee, otherIns.getEmployee(), where + ".employee"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((FCDSInsurance)o); } - public String toString() { - return this.getClass().getName() + ": " + insid; + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((FCDSInsurance)o1, (FCDSInsurance)o2); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.insid != o.insid) return (false); - return (true); + /** + * Compares this object with the specified Insurance object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Insurance object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified + * Insurance object. + */ + public int compareTo(FCDSInsurance other) { + return compare(this, other); } - /** */ + /** + * Compares its two IInsurance arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IInsurance object to be compared. + * @param o2 the second IInsurance object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(FCDSInsurance o1, FCDSInsurance o2) { + return EqualityHelper.compare(o1.getInsid(), o2.getInsid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof FCDSInsurance) { + return compareTo((FCDSInsurance)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ public int hashCode() { - return ((int) insid); + return (int)insid; } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } + /** + * This class is used to represent the application + * identifier for the Insurance class. + */ + public static class Oid implements Serializable, Comparable + { + /** + * This field represents the application identifier for the + * Insurance class. It must match the field in the + * Insurance class in both name and type. + */ + public long insid; + + /** + * The required public no-args constructor. + */ + public Oid() { } + + /** + * Initialize with an insurance identifier. + * @param insid the insurance ID. + */ + public Oid(long insid) { + this.insid = insid; + } + + public Oid(String s) { insid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + insid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o=(Oid) obj; + if( this.insid!=o.insid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) insid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( insid < other.insid ) return -1; + if( insid > other.insid ) return 1; + return 0; + } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (insid < other.insid) return -1; - if (insid > other.insid) return 1; - return 0; } - } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSMedicalInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSMedicalInsurance.java index 82840c8bd..7510986ce 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSMedicalInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSMedicalInsurance.java @@ -5,120 +5,123 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.DatastoreIdentity; -import javax.jdo.annotations.IdGeneratorStrategy; -import javax.jdo.annotations.PersistenceCapable; +import javax.jdo.annotations.*; import org.apache.jdo.tck.pc.company.IMedicalInsurance; import org.apache.jdo.tck.util.EqualityHelper; /** - * This class represents a dental insurance carrier selection for a particular Employee - * . + * This class represents a dental insurance carrier selection for a + * particular Employee. */ @PersistenceCapable -@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "DATASTORE_IDENTITY") -public class FCDSMedicalInsurance extends FCDSInsurance implements IMedicalInsurance { +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY") +public class FCDSMedicalInsurance extends FCDSInsurance + implements IMedicalInsurance { - @Column(name = "PLANTYPE") - private String planType; // possible values: "PPO", "EPO", "NPO" + @Column(name="PLANTYPE") + private String planType; // possible values: "PPO", "EPO", "NPO" - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FCDSMedicalInsurance() {} + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCDSMedicalInsurance() {} - /** - * Construct a FCDSMedicalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param planType The planType. - */ - public FCDSMedicalInsurance(long insid, String carrier, String planType) { - super(insid, carrier); - this.planType = planType; - } + /** + * Construct a FCDSMedicalInsurance instance. + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param planType The planType. + */ + public FCDSMedicalInsurance(long insid, String carrier, + String planType) + { + super(insid, carrier); + this.planType = planType; + } - /** - * Construct a FCDSMedicalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param employee The employee associated with this insurance. - * @param planType The planType. - */ - public FCDSMedicalInsurance(long insid, String carrier, FCDSEmployee employee, String planType) { - super(insid, carrier, employee); - this.planType = planType; - } + /** + * Construct a FCDSMedicalInsurance instance. + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + * @param planType The planType. + */ + public FCDSMedicalInsurance(long insid, String carrier, + FCDSEmployee employee, String planType) + { + super(insid, carrier, employee); + this.planType = planType; + } - /** - * Get the insurance planType. - * - * @return The insurance planType. - */ - public String getPlanType() { - return planType; - } + /** + * Get the insurance planType. + * @return The insurance planType. + */ + public String getPlanType() { + return planType; + } - /** - * Set the insurance planType. - * - * @param planType The insurance planType. - */ - public void setPlanType(String planType) { - this.planType = planType; - } + /** + * Set the insurance planType. + * @param planType The insurance planType. + */ + public void setPlanType(String planType) { + this.planType = planType; + } - /** - * Returns a String representation of a FCDSMedicalInsurance object. - * - * @return a String representation of a FCDSMedicalInsurance object. - */ - public String toString() { - return "FCMedicalInsurance(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of a FCDSMedicalInsurance + * object. + * + * @return a String representation of a FCDSMedicalInsurance + * object. + */ + public String toString() { + return "FCMedicalInsurance(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", planType ").append(planType); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", planType ").append(planType); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Object. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCDSMedicalInsurance otherIns = (FCDSMedicalInsurance) other; - String where = "FCMedicalInsurance<" + getInsid() + ">"; - return super.deepCompareFields(otherIns, helper) - & helper.equals(planType, otherIns.getPlanType(), where + ".planType"); - } + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCDSMedicalInsurance otherIns = (FCDSMedicalInsurance)other; + String where = "FCMedicalInsurance<" + getInsid() + ">"; + return super.deepCompareFields(otherIns, helper) & + helper.equals(planType, otherIns.getPlanType(), where + ".planType"); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSMeetingRoom.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSMeetingRoom.java index 1f0173d45..7de6daff3 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSMeetingRoom.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSMeetingRoom.java @@ -5,256 +5,255 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; +import javax.jdo.annotations.*; + import java.io.Serializable; import java.util.Comparator; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.PersistenceCapable; + import org.apache.jdo.tck.pc.company.IMeetingRoom; import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a meeting room. */ -@PersistenceCapable(table = "meetingrooms") +/** + * This class represents a meeting room. + */ +@PersistenceCapable(table="meetingrooms") @DatastoreIdDiscriminatorClassNameInheritanceNew -public class FCDSMeetingRoom +public class FCDSMeetingRoom implements IMeetingRoom, Serializable, Comparable, Comparator, DeepEquality { - @Column(name = "ID") - private long roomid; - - @Column(name = "NAME", jdbcType = "VARCHAR") - private String name; - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FCDSMeetingRoom() {} - - /** - * This constructor initializes the FCDSMeetingRoom components. - * - * @param roomid The room ID. - * @param name The name of the room - */ - public FCDSMeetingRoom(long roomid, String name) { - this.roomid = roomid; - this.name = name; - } - - /** - * Get the room id associated with this object. - * - * @return the room id. - */ - public long getRoomid() { - return roomid; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setRoomid(long id) { - if (this.roomid != 0) throw new IllegalStateException("Id is already set."); - this.roomid = id; - } - - /** - * Get the name of the meeting room. - * - * @return The name of the meeting room. - */ - public String getName() { - return name; - } - - /** - * Set the name of the meeting room. - * - * @param name The name. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Returns a String representation of a Address object. - * - * @return a String representation of a FCDSMeetingRoom object. - */ - public String toString() { - return "FCDSMeetingRoom(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(roomid); - rc.append(", name ").append(name); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IMeetingRoom otherMeetingRoom = (IMeetingRoom) other; - String where = "FCDSMeetingRoom<" + roomid + ">"; - return helper.equals(roomid, otherMeetingRoom.getRoomid(), where + ".roomid") - & helper.equals(name, otherMeetingRoom.getName(), where + ".name"); - } + @Column(name="ID") + private long roomid; + @Column(name="NAME", jdbcType="VARCHAR") + private String name; - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((IMeetingRoom) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((IMeetingRoom) o1, (IMeetingRoom) o2); - } - - /** - * Compares this object with the specified FCDSMeetingRoom object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The MeetingRoom object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified MeetingRoom object. - */ - public int compareTo(IMeetingRoom other) { - return compare(this, other); - } + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCDSMeetingRoom() {} - /** - * Compares its two IMeetingRoom arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IMeetingRoom object to be compared. - * @param o2 the second IMeetingRoom object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(IMeetingRoom o1, IMeetingRoom o2) { - return EqualityHelper.compare(o1.getRoomid(), o2.getRoomid()); - } + /** + * This constructor initializes the FCDSMeetingRoom components. + * @param roomid The room ID. + * @param name The name of the room + */ + public FCDSMeetingRoom(long roomid, String name) + { + this.roomid = roomid; + this.name = name; + } - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof IMeetingRoom) { - return compareTo((IMeetingRoom) obj) == 0; + /** + * Get the room id associated with this object. + * @return the room id. + */ + public long getRoomid() { + return roomid; } - return false; - } - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) roomid; - } + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setRoomid(long id) { + if (this.roomid != 0) + throw new IllegalStateException("Id is already set."); + this.roomid = id; + } - /** - * This class is used to represent the application identifier for the FCDSMeetingRoom - * class. - */ - public static class Oid implements Serializable, Comparable { + /** + * Get the name of the meeting room. + * @return The name of the meeting room. + */ + public String getName() { + return name; + } /** - * This is the identifier field for FCDSMeetingRoom and must correspond in type and - * name to the field in FCDSMeetingRoom. + * Set the name of the meeting room. + * @param name The name. */ - public long roomid; - - /** The required public, no-arg constructor. */ - public Oid() { - roomid = 0; + public void setName(String name) { + this.name = name; } /** - * A constructor to initialize the identifier field. - * - * @param roomid the id of the FCDSMeetingRoom. + * Returns a String representation of a Address object. + * @return a String representation of a FCDSMeetingRoom object. */ - public Oid(long roomid) { - this.roomid = roomid; + public String toString() { + return "FCDSMeetingRoom(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(roomid); + rc.append(", name ").append(name); + return rc.toString(); } - public Oid(String s) { - roomid = Long.parseLong(justTheId(s)); + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IMeetingRoom otherMeetingRoom = (IMeetingRoom)other; + String where = "FCDSMeetingRoom<" + roomid + ">"; + return + helper.equals(roomid, otherMeetingRoom.getRoomid(), where + ".roomid") & + helper.equals(name, otherMeetingRoom.getName(), where + ".name"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((IMeetingRoom)o); } - public String toString() { - return this.getClass().getName() + ": " + roomid; + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((IMeetingRoom)o1, (IMeetingRoom)o2); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.roomid != o.roomid) return (false); - return (true); + /** + * Compares this object with the specified FCDSMeetingRoom object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The MeetingRoom object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified MeetingRoom + * object. + */ + public int compareTo(IMeetingRoom other) { + return compare(this, other); + } + + /** + * Compares its two IMeetingRoom arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IMeetingRoom object to be compared. + * @param o2 the second IMeetingRoom object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(IMeetingRoom o1, IMeetingRoom o2) { + return EqualityHelper.compare(o1.getRoomid(), o2.getRoomid()); } - /** */ - public int hashCode() { - return ((int) roomid); + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof IMeetingRoom) { + return compareTo((IMeetingRoom)obj) == 0; + } + return false; } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)roomid; } + + /** + * This class is used to represent the application identifier + * for the FCDSMeetingRoom class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This is the identifier field for FCDSMeetingRoom and must + * correspond in type and name to the field in + * FCDSMeetingRoom. + */ + public long roomid; + + /** The required public, no-arg constructor. */ + public Oid() + { + roomid = 0; + } + + /** + * A constructor to initialize the identifier field. + * @param roomid the id of the FCDSMeetingRoom. + */ + public Oid(long roomid) { + this.roomid = roomid; + } + + public Oid(String s) { roomid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + roomid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.roomid != o.roomid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) roomid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (roomid < other.roomid) return -1; - if (roomid > other.roomid) return 1; - return 0; + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( roomid < other.roomid ) return -1; + if( roomid > other.roomid ) return 1; + return 0; + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSPartTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSPartTimeEmployee.java index df6363e9a..b354e0a78 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSPartTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSPartTimeEmployee.java @@ -5,134 +5,130 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; +import javax.jdo.annotations.*; + import java.util.Date; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.PersistenceCapable; import org.apache.jdo.tck.pc.company.IAddress; import org.apache.jdo.tck.pc.company.IPartTimeEmployee; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a part-time employee. */ +/** + * This class represents a part-time employee. + */ @DatastoreIdDiscriminatorClassNameInheritanceSuperclass -@PersistenceCapable(table = "persons") +@PersistenceCapable(table="persons") public class FCDSPartTimeEmployee extends FCDSEmployee implements IPartTimeEmployee { - @Column(name = "WAGE") - private double wage; + @Column(name="WAGE") + private double wage; - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FCDSPartTimeEmployee() {} + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCDSPartTimeEmployee() {} - /** - * Construct a part-time employee. - * - * @param personid The identifier for the person. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param hired The date the person was hired. - * @param wage The person's wage. - */ - public FCDSPartTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double wage) { - super(personid, first, last, middle, born, hired); - this.wage = wage; - } + /** + * Construct a part-time employee. + * @param personid The identifier for the person. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param hired The date the person was hired. + * @param wage The person's wage. + */ + public FCDSPartTimeEmployee(long personid, String first, String last, + String middle, Date born, + Date hired, double wage ) { + super(personid, first, last, middle, born, hired); + this.wage = wage; + } - /** - * Construct a part-time employee. - * - * @param personid The identifier for the person. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param addr The person's address. - * @param hired The date the person was hired. - * @param wage The person's wage. - */ - public FCDSPartTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - IAddress addr, - Date hired, - double wage) { - super(personid, first, last, middle, born, (FCDSAddress) addr, hired); - this.wage = wage; - } + /** + * Construct a part-time employee. + * @param personid The identifier for the person. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param addr The person's address. + * @param hired The date the person was hired. + * @param wage The person's wage. + */ + public FCDSPartTimeEmployee(long personid, String first, String last, + String middle, Date born, IAddress addr, + Date hired, double wage ) { + super(personid, first, last, middle, born, (FCDSAddress)addr, hired); + this.wage = wage; + } - /** - * Get the wage of the part-time employee. - * - * @return The wage of the part-time employee. - */ - public double getWage() { - return wage; - } + /** + * Get the wage of the part-time employee. + * @return The wage of the part-time employee. + */ + public double getWage() { + return wage; + } - /** - * Set the wage of the part-time employee. - * - * @param wage The wage of the part-time employee. - */ - public void setWage(double wage) { - this.wage = wage; - } + /** + * Set the wage of the part-time employee. + * @param wage The wage of the part-time employee. + */ + public void setWage(double wage) { + this.wage = wage; + } - /** - * Returns a String representation of a FCDSPartTimeEmployee object. - * - * @return a String representation of a FCDSPartTimeEmployee object. - */ - public String toString() { - return "FCPartTimeEmployee(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of a FCDSPartTimeEmployee object. + * + * @return a String representation of a FCDSPartTimeEmployee object. + */ + public String toString() { + return "FCPartTimeEmployee(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - public String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", $" + wage); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + public String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", $" + wage); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified FCDSPartTimeEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCDSPartTimeEmployee otherEmp = (FCDSPartTimeEmployee) other; - String where = "FCPartTimeEmployee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.closeEnough(wage, otherEmp.getWage(), where + ".wage"); - } + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified + * FCDSPartTimeEmployee. + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCDSPartTimeEmployee otherEmp = (FCDSPartTimeEmployee)other; + String where = "FCPartTimeEmployee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.closeEnough(wage, otherEmp.getWage(), where + ".wage"); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSPerson.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSPerson.java index 19db98f88..d1382cb26 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSPerson.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSPerson.java @@ -5,465 +5,450 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; +import javax.jdo.annotations.*; + import java.io.Serializable; + import java.text.SimpleDateFormat; + import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.Map; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Embedded; -import javax.jdo.annotations.Join; -import javax.jdo.annotations.Key; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.PersistenceModifier; -import javax.jdo.annotations.Persistent; -import javax.jdo.annotations.Value; import org.apache.jdo.tck.pc.company.IAddress; import org.apache.jdo.tck.pc.company.IPerson; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a person. */ -@PersistenceCapable(table = "persons") +/** + * This class represents a person. + */ +@PersistenceCapable(table="persons") @DatastoreIdDiscriminatorClassNameInheritanceNew -public class FCDSPerson implements IPerson, Serializable, Comparable, Comparator, DeepEquality { - - @Column(name = "PERSONID") - private long personid; - - @Column(name = "FIRSTNAME") - private String firstname; - - @Column(name = "LASTNAME") - private String lastname; - - @Persistent(defaultFetchGroup = "false") - @Column(name = "MIDDLENAME", allowsNull = "true") - private String middlename; - - @Column(name = "BIRTHDATE") - private Date birthdate; - - @Persistent(persistenceModifier = PersistenceModifier.PERSISTENT) - @Embedded( - nullIndicatorColumn = "COUNTRY", - members = { - @Persistent(name = "addrid", columns = @Column(name = "ADDRID")), - @Persistent(name = "street", columns = @Column(name = "STREET")), - @Persistent(name = "city", columns = @Column(name = "CITY")), - @Persistent(name = "state", columns = @Column(name = "STATE")), - @Persistent(name = "zipcode", columns = @Column(name = "ZIPCODE")), - @Persistent(name = "country", columns = @Column(name = "COUNTRY")) - }) - private FCDSAddress address; - - // maps phone number types ("home", "work", "mobile", etc.) - // to phone numbers specified as String - @Persistent(table = "employee_phoneno_type") - @Join(column = "EMPID") - @Key(types = java.lang.String.class, column = "TYPE") - @Value(types = java.lang.String.class, column = "PHONENO") - private Map phoneNumbers = new HashMap(); - - protected static SimpleDateFormat formatter = new SimpleDateFormat("d/MMM/yyyy"); - - /** This is the JDO-required no-args constructor. */ - protected FCDSPerson() {} - - /** - * Construct a FCDSPerson instance. - * - * @param personid The person identifier. - * @param firstname The person's first name. - * @param lastname The person's last name. - * @param middlename The person's middle name. - * @param birthdate The person's birthdate. - */ - public FCDSPerson( - long personid, String firstname, String lastname, String middlename, Date birthdate) { - this.personid = personid; - this.firstname = firstname; - this.lastname = lastname; - this.middlename = middlename; - this.birthdate = birthdate; - } - - /** - * Construct a FCDSPerson instance. - * - * @param personid The person identifier. - * @param firstname The person's first name. - * @param lastname The person's last name. - * @param middlename The person's middle name. - * @param birthdate The person's birthdate. - * @param address The person's address. - */ - public FCDSPerson( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - IAddress address) { - this(personid, firstname, lastname, middlename, birthdate); - this.address = (FCDSAddress) address; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setPersonid(long id) { - if (this.personid != 0) throw new IllegalStateException("Id is already set."); - this.personid = id; - } - - /** - * Get the person's id. - * - * @return The personid. - */ - public long getPersonid() { - return personid; - } - - /** - * Set the person's id. - * - * @param personid The personid. - */ - public void setLastname(long personid) { - this.personid = personid; - } - - /** - * Get the person's last name. - * - * @return The last name. - */ - public String getLastname() { - return lastname; - } - - /** - * Set the person's last name. - * - * @param lastname The last name. - */ - public void setLastname(String lastname) { - this.lastname = lastname; - } - - /** - * Get the person's first name. - * - * @return The first name. - */ - public String getFirstname() { - return firstname; - } - - /** - * Set the person's first name. - * - * @param firstname The first name. - */ - public void setFirstname(String firstname) { - this.firstname = firstname; - } - - /** - * Get the person's middle name. - * - * @return The middle name. - */ - public String getMiddlename() { - return middlename; - } - - /** - * Set the person's middle name. - * - * @param middlename The middle name. - */ - public void setMiddlename(String middlename) { - this.middlename = middlename; - } - - /** - * Get the address. - * - * @return The address. - */ - public IAddress getAddress() { - return address; - } - - /** - * Set the address. - * - * @param address The address. - */ - public void setAddress(IAddress address) { - this.address = (FCDSAddress) address; - } - - /** - * Get the person's birthdate. - * - * @return The person's birthdate. - */ - public Date getBirthdate() { - return birthdate; - } - - /** - * Set the person's birthdate. - * - * @param birthdate The person's birthdate. - */ - public void setBirthdate(Date birthdate) { - this.birthdate = birthdate; - } - - /** - * Get the map of phone numbers as an unmodifiable map. - * - * @return The map of phone numbers, as an unmodifiable map. - */ - public Map getPhoneNumbers() { - return Collections.unmodifiableMap(phoneNumbers); - } - - /** - * Get the phone number for the specified phone number type. - * - * @param type The phone number type ("home", "work", "mobile", etc.). - * @return The phone number associated with specified type, or null if there was no - * phone number for the type. - */ - public String getPhoneNumber(String type) { - return (String) phoneNumbers.get(type); - } - - /** - * Associates the specified phone number with the specified type in the map of phone numbers of - * this person. - * - * @param type The phone number type ("home", "work", "mobile", etc.). - * @param phoneNumber The phone number - * @return The previous phone number associated with specified type, or null if there - * was no phone number for the type. - */ - public String putPhoneNumber(String type, String phoneNumber) { - return (String) phoneNumbers.put(type, phoneNumber); - } - - /** - * Remove a phoneNumber from the map of phone numbers. - * - * @param type The phone number type ("home", "work", "mobile", etc.). - * @return The previous phone number associated with specified type, or null if there - * was no phone number for the type. - */ - public String removePhoneNumber(String type) { - return (String) phoneNumbers.remove(type); - } - - /** - * Set the phoneNumber map to be in this person. - * - * @param phoneNumbers The map of phoneNumbers for this person. - */ - public void setPhoneNumbers(Map phoneNumbers) { - // workaround: create a new HashMap, because fostore does not - // support LinkedHashMap - this.phoneNumbers = (phoneNumbers != null) ? new HashMap(phoneNumbers) : null; - } - - /** - * Returns a String representation of a FCDSPerson object. - * - * @return a string representation of a FCDSPerson object. - */ - public String toString() { - return "FCPerson(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(personid); - rc.append(", ").append(lastname); - rc.append(", ").append(firstname); - rc.append(", born ").append(birthdate == null ? "null" : formatter.format(birthdate)); - rc.append(", phone ").append(phoneNumbers); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified FCDSPerson. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCDSPerson otherPerson = (FCDSPerson) other; - String where = "FCPerson<" + personid + ">"; - return helper.equals(personid, otherPerson.getPersonid(), where + ".personid") - & helper.equals(firstname, otherPerson.getFirstname(), where + ".firstname") - & helper.equals(lastname, otherPerson.getLastname(), where + ".lastname") - & helper.equals(middlename, otherPerson.getMiddlename(), where + ".middlename") - & helper.equals(birthdate, otherPerson.getBirthdate(), where + ".birthdate") - & helper.deepEquals(address, otherPerson.getAddress(), where + ".address") - & helper.deepEquals(phoneNumbers, otherPerson.getPhoneNumbers(), where + ".phoneNumbers"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((FCDSPerson) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((FCDSPerson) o1, (FCDSPerson) o2); - } - - /** - * Compares this object with the specified FCDSPerson object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The FCDSPerson object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified FFCDSPerson object. - */ - public int compareTo(FCDSPerson other) { - return compare(this, other); - } - - /** - * Compares its two IPerson arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IPerson object to be compared. - * @param o2 the second IPerson object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(FCDSPerson o1, FCDSPerson o2) { - return EqualityHelper.compare(o1.getPersonid(), o2.getPersonid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof FCDSPerson) { - return compareTo((FCDSPerson) obj) == 0; +public class FCDSPerson + implements IPerson, Serializable, Comparable, Comparator, DeepEquality { + + @Column(name="PERSONID") + private long personid; + @Column(name="FIRSTNAME") + private String firstname; + @Column(name="LASTNAME") + private String lastname; + @Persistent(defaultFetchGroup="false") + @Column(name="MIDDLENAME", allowsNull="true") + private String middlename; + @Column(name="BIRTHDATE") + private Date birthdate; + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT) + @Embedded(nullIndicatorColumn="COUNTRY", + members={ + @Persistent(name="addrid", columns=@Column(name="ADDRID")), + @Persistent(name="street", columns=@Column(name="STREET")), + @Persistent(name="city", columns=@Column(name="CITY")), + @Persistent(name="state", columns=@Column(name="STATE")), + @Persistent(name="zipcode", columns=@Column(name="ZIPCODE")), + @Persistent(name="country", columns=@Column(name="COUNTRY")) + }) + private FCDSAddress address; + + // maps phone number types ("home", "work", "mobile", etc.) + // to phone numbers specified as String + @Persistent(table="employee_phoneno_type") + @Join(column="EMPID") + @Key(types=java.lang.String.class, column="TYPE") + @Value(types=java.lang.String.class, column="PHONENO") + private Map phoneNumbers = new HashMap(); + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. */ + protected FCDSPerson() {} + + /** + * Construct a FCDSPerson instance. + * + * @param personid The person identifier. + * @param firstname The person's first name. + * @param lastname The person's last name. + * @param middlename The person's middle name. + * @param birthdate The person's birthdate. + */ + public FCDSPerson(long personid, String firstname, String lastname, + String middlename, Date birthdate) { + this.personid = personid; + this.firstname = firstname; + this.lastname = lastname; + this.middlename = middlename; + this.birthdate = birthdate; + } + + /** + * Construct a FCDSPerson instance. + * + * @param personid The person identifier. + * @param firstname The person's first name. + * @param lastname The person's last name. + * @param middlename The person's middle name. + * @param birthdate The person's birthdate. + * @param address The person's address. + */ + public FCDSPerson(long personid, String firstname, String lastname, + String middlename, Date birthdate, IAddress address) { + this(personid, firstname, lastname, middlename, birthdate); + this.address = (FCDSAddress)address; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) personid; - } - /** - * This class is used to represent the application identifier for the Person class. - */ - public static class Oid implements Serializable, Comparable { /** - * This field represents the identifier for the Person class. It must match a field - * in the Person class in both name and type. + * Set the id associated with this object. + * @param id the id. */ - public long personid; + public void setPersonid(long id) { + if (this.personid != 0) + throw new IllegalStateException("Id is already set."); + this.personid = id; + } - /** The required public no-arg constructor. */ - public Oid() {} + /** + * Get the person's id. + * @return The personid. + */ + public long getPersonid() { + return personid; + } /** - * Initialize the identifier. - * - * @param personid The person identifier. + * Set the person's id. + * @param personid The personid. + */ + public void setLastname(long personid) { + this.personid = personid; + } + + /** + * Get the person's last name. + * @return The last name. + */ + public String getLastname() { + return lastname; + } + + /** + * Set the person's last name. + * @param lastname The last name. + */ + public void setLastname(String lastname) { + this.lastname = lastname; + } + + /** + * Get the person's first name. + * @return The first name. + */ + public String getFirstname() { + return firstname; + } + + /** + * Set the person's first name. + * @param firstname The first name. + */ + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + /** + * Get the person's middle name. + * @return The middle name. */ - public Oid(long personid) { - this.personid = personid; + public String getMiddlename() { + return middlename; } - public Oid(String s) { - personid = Long.parseLong(justTheId(s)); + /** + * Set the person's middle name. + * @param middlename The middle name. + */ + public void setMiddlename(String middlename) { + this.middlename = middlename; } + /** + * Get the address. + * @return The address. + */ + public IAddress getAddress() { + return address; + } + + /** + * Set the address. + * @param address The address. + */ + public void setAddress(IAddress address) { + this.address = (FCDSAddress)address; + } + + /** + * Get the person's birthdate. + * @return The person's birthdate. + */ + public Date getBirthdate() { + return birthdate; + } + + /** + * Set the person's birthdate. + * @param birthdate The person's birthdate. + */ + public void setBirthdate(Date birthdate) { + this. birthdate = birthdate; + } + + /** + * Get the map of phone numbers as an unmodifiable map. + * @return The map of phone numbers, as an unmodifiable map. + */ + public Map getPhoneNumbers() { + return Collections.unmodifiableMap(phoneNumbers); + } + + /** + * Get the phone number for the specified phone number type. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String getPhoneNumber(String type) { + return (String)phoneNumbers.get(type); + } + + /** + * Associates the specified phone number with the specified type in the + * map of phone numbers of this person. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @param phoneNumber The phone number + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String putPhoneNumber(String type, String phoneNumber) { + return (String)phoneNumbers.put(type, phoneNumber); + } + + /** + * Remove a phoneNumber from the map of phone numbers. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String removePhoneNumber(String type) { + return (String)phoneNumbers.remove(type); + } + + /** + * Set the phoneNumber map to be in this person. + * @param phoneNumbers The map of phoneNumbers for this person. + */ + public void setPhoneNumbers(Map phoneNumbers) { + // workaround: create a new HashMap, because fostore does not + // support LinkedHashMap + this.phoneNumbers = + (phoneNumbers != null) ? new HashMap(phoneNumbers) : null; + } + + /** + * Returns a String representation of a FCDSPerson object. + * + * @return a string representation of a FCDSPerson object. + */ public String toString() { - return this.getClass().getName() + ": " + personid; + return "FCPerson(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(personid); + rc.append(", ").append(lastname); + rc.append(", ").append(firstname); + rc.append(", born ").append( + birthdate==null ? "null" : formatter.format(birthdate)); + rc.append(", phone ").append(phoneNumbers); + return rc.toString(); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.personid != o.personid) return (false); - return (true); + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified FCDSPerson. + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCDSPerson otherPerson = (FCDSPerson)other; + String where = "FCPerson<" + personid + ">"; + return + helper.equals(personid, otherPerson.getPersonid(), where + ".personid") & + helper.equals(firstname, otherPerson.getFirstname(), where + ".firstname") & + helper.equals(lastname, otherPerson.getLastname(), where + ".lastname") & + helper.equals(middlename, otherPerson.getMiddlename(), where + ".middlename") & + helper.equals(birthdate, otherPerson.getBirthdate(), where + ".birthdate") & + helper.deepEquals(address, otherPerson.getAddress(), where + ".address") & + helper.deepEquals(phoneNumbers, otherPerson.getPhoneNumbers(), where + ".phoneNumbers"); } - /** */ - public int hashCode() { - return ((int) personid); + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((FCDSPerson)o); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((FCDSPerson)o1, (FCDSPerson)o2); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (personid < other.personid) return -1; - if (personid > other.personid) return 1; - return 0; + /** + * + * Compares this object with the specified FCDSPerson object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * + * @param other The FCDSPerson object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified FFCDSPerson + * object. + */ + public int compareTo(FCDSPerson other) { + return compare(this, other); } - } + + /** + * Compares its two IPerson arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IPerson object to be compared. + * @param o2 the second IPerson object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(FCDSPerson o1, FCDSPerson o2) { + return EqualityHelper.compare(o1.getPersonid(), o2.getPersonid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof FCDSPerson) { + return compareTo((FCDSPerson)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)personid; + } + /** + * This class is used to represent the application identifier + * for the Person class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the identifier for the Person + * class. It must match a field in the Person class in + * both name and type. + */ + public long personid; + + /** + * The required public no-arg constructor. + */ + public Oid() { } + + /** + * Initialize the identifier. + * @param personid The person identifier. + */ + public Oid(long personid) { + this.personid = personid; + } + + public Oid(String s) { personid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + personid;} + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || + !this.getClass().equals(obj.getClass()) ) return( false ); + Oid o = (Oid) obj; + if( this.personid != o.personid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) personid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( personid < other.personid ) return -1; + if( personid > other.personid ) return 1; + return 0; + } + + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSProject.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSProject.java index 493e149b5..fbc089d7b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSProject.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSProject.java @@ -5,391 +5,382 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedFC; -import java.io.IOException; -import java.io.ObjectInputStream; +import javax.jdo.annotations.*; + import java.io.Serializable; -import java.math.BigDecimal; +import java.io.ObjectInputStream; +import java.io.IOException; + import java.util.Collections; import java.util.Comparator; -import java.util.HashSet; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.Join; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; +import java.util.HashSet; +import java.math.BigDecimal; import org.apache.jdo.tck.pc.company.IProject; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a project, a budgeted task with one or more employees working on it. */ -@PersistenceCapable(table = "projects") +/** + * This class represents a project, a budgeted task with one or more + * employees working on it. + */ +@PersistenceCapable(table="projects") @DatastoreIdDiscriminatorClassNameInheritanceNew -public class FCDSProject implements IProject, Serializable, Comparable, Comparator, DeepEquality { - - @Column(name = "PROJID") - private long projid; - - @Column(name = "NAME") - private String name; - - @Column(name = "BUDGET", jdbcType = "DECIMAL", length = 11, scale = 2) - private BigDecimal budget; - - @Persistent(table = "project_reviewer") - @Element( - types = org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSEmployee.class, - column = "REVIEWER", - foreignKey = "PR_REV_FK") - @Join(column = "PROJID", foreignKey = "PR_PROJ_FK") - private transient Set reviewers = new HashSet(); - - @Persistent(table = "project_member") - @Element( - types = org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSEmployee.class, - column = "MEMBER", - foreignKey = "PR_MEMB_FK") - @Join(column = "PROJID", foreignKey = "PR_PROJ_FK") - private transient Set members = new HashSet(); - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FCDSProject() {} - - /** - * Initialize a project. - * - * @param projid The project identifier. - * @param name The name of the project. - * @param budget The budget for the project. - */ - public FCDSProject(long projid, String name, BigDecimal budget) { - this.projid = projid; - this.name = name; - this.budget = budget; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setProjid(long id) { - if (this.projid != 0) throw new IllegalStateException("Id is already set."); - this.projid = id; - } - - /** - * Get the project ID. - * - * @return The project ID. - */ - public long getProjid() { - return projid; - } - - /** - * Get the name of the project. - * - * @return The name of the project. - */ - public String getName() { - return name; - } - - /** - * Set the name of the project. - * - * @param name The name of the project. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Get the project's budget. - * - * @return The project's budget. - */ - public BigDecimal getBudget() { - return budget; - } - - /** - * Set the project's budget. - * - * @param budget The project's budget. - */ - public void setBudget(BigDecimal budget) { - this.budget = budget; - } - - /** Get the reviewers associated with this project. */ - public Set getReviewers() { - return Collections.unmodifiableSet(reviewers); - } - - /** - * Add a reviewer to the project. - * - * @param emp The employee to add as a reviewer. - */ - public void addReviewer(FCDSEmployee emp) { - reviewers.add(emp); - } - - /** - * Remove a reviewer from the project. - * - * @param emp The employee to remove as a reviewer of this project. - */ - public void removeReviewer(FCDSEmployee emp) { - reviewers.remove(emp); - } - - /** - * Set the reviewers associated with this project. - * - * @param reviewers The set of reviewers to associate with this project. - */ - public void setReviewers(Set reviewers) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.reviewers = (reviewers != null) ? new HashSet(reviewers) : null; - } - - /** - * Get the project members. - * - * @return The members of the project is returned as an unmodifiable set of FCDSEmployee - * s. - */ - public Set getMembers() { - return Collections.unmodifiableSet(members); - } - - /** - * Add a new member to the project. - * - * @param emp The employee to add to the project. - */ - public void addMember(FCDSEmployee emp) { - members.add(emp); - } - - /** - * Remove a member from the project. - * - * @param emp The employee to remove from the project. - */ - public void removeMember(FCDSEmployee emp) { - members.remove(emp); - } - - /** - * Set the members of the project. - * - * @param employees The set of employees to be the members of this project. - */ - public void setMembers(Set employees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.members = (members != null) ? new HashSet(employees) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - reviewers = new HashSet(); - members = new HashSet(); - } - - /** - * Returns a String representation of a FCDSProject object. - * - * @return a String representation of a FCDSProject object. - */ - public String toString() { - return "FCProject(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(projid); - rc.append(", name ").append(name); - rc.append(", budget ").append(budget); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - FCDSProject otherProject = (FCDSProject) other; - String where = "FCProject<" + projid + ">"; - return helper.equals(projid, otherProject.getProjid(), where + ".projid") - & helper.equals(name, otherProject.getName(), where + ".name") - & helper.equals(budget, otherProject.getBudget(), where + ".budget") - & helper.deepEquals(reviewers, otherProject.getReviewers(), where + ".reviewers") - & helper.deepEquals(members, otherProject.getMembers(), where + ".members"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((FCDSProject) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((FCDSProject) o1, (FCDSProject) o2); - } - - /** - * Compares this object with the specified FCDSProject object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The FCDSProject object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified FFCDSProject object. - */ - public int compareTo(FCDSProject other) { - return compare(this, other); - } - - /** - * Compares its two IProject arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IProject object to be compared. - * @param o2 the second IProject object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(FCDSProject o1, FCDSProject o2) { - return EqualityHelper.compare(o1.getProjid(), o2.getProjid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof FCDSProject) { - return compareTo((FCDSProject) obj) == 0; +public class FCDSProject + implements IProject, Serializable, Comparable, Comparator, DeepEquality { + + @Column(name="PROJID") + private long projid; + @Column(name="NAME") + private String name; + @Column(name="BUDGET", jdbcType="DECIMAL", length=11, scale=2) + private BigDecimal budget; + @Persistent(table="project_reviewer") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSEmployee.class, + column="REVIEWER", foreignKey="PR_REV_FK") + @Join(column="PROJID", foreignKey="PR_PROJ_FK") + private transient Set reviewers = new HashSet(); + @Persistent(table="project_member") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSEmployee.class, + column="MEMBER", foreignKey="PR_MEMB_FK") + @Join(column="PROJID", foreignKey="PR_PROJ_FK") + private transient Set members = new HashSet(); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FCDSProject() {} + + /** + * Initialize a project. + * @param projid The project identifier. + * @param name The name of the project. + * @param budget The budget for the project. + */ + public FCDSProject(long projid, String name, BigDecimal budget) { + this.projid = projid; + this.name = name; + this.budget = budget; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setProjid(long id) { + if (this.projid != 0) + throw new IllegalStateException("Id is already set."); + this.projid = id; + } + + /** + * Get the project ID. + * @return The project ID. + */ + public long getProjid() { + return projid; + } + + /** + * Get the name of the project. + * @return The name of the project. + */ + public String getName() { + return name; + } + + /** + * Set the name of the project. + * @param name The name of the project. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Get the project's budget. + * @return The project's budget. + */ + public BigDecimal getBudget() { + return budget; + } + + /** + * Set the project's budget. + * @param budget The project's budget. + */ + public void setBudget(BigDecimal budget) { + this.budget = budget; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) projid; - } - - /** - * This class is used to represent the application identity for the FCDSProject - * class. - */ - public static class Oid implements Serializable, Comparable { /** - * This field represents the identifier for the FCDSProject class. It must match a - * field in the FCDSProject class in both name and type. + * Get the reviewers associated with this project. */ - public long projid; + public Set getReviewers() { + return Collections.unmodifiableSet(reviewers); + } - /** The required public no-arg constructor. */ - public Oid() {} + /** + * Add a reviewer to the project. + * @param emp The employee to add as a reviewer. + */ + public void addReviewer(FCDSEmployee emp) { + reviewers.add(emp); + } /** - * Initialize the application identifier with a project ID. - * - * @param projid The id of the project. + * Remove a reviewer from the project. + * @param emp The employee to remove as a reviewer of this project. */ - public Oid(long projid) { - this.projid = projid; + public void removeReviewer(FCDSEmployee emp) { + reviewers.remove(emp); } - public Oid(String s) { - projid = Long.parseLong(justTheId(s)); + /** + * Set the reviewers associated with this project. + * @param reviewers The set of reviewers to associate with this project. + */ + public void setReviewers(Set reviewers) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.reviewers = (reviewers != null) ? new HashSet(reviewers) : null; } + /** + * Get the project members. + * + * @return The members of the project is returned as an unmodifiable + * set of FCDSEmployees. + */ + public Set getMembers() { + return Collections.unmodifiableSet(members); + } + + /** + * Add a new member to the project. + * @param emp The employee to add to the project. + */ + public void addMember(FCDSEmployee emp) { + members.add(emp); + } + + /** + * Remove a member from the project. + * @param emp The employee to remove from the project. + */ + public void removeMember(FCDSEmployee emp) { + members.remove(emp); + } + + /** + * Set the members of the project. + * @param employees The set of employees to be the members of this + * project. + */ + public void setMembers(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.members = (members != null) ? new HashSet(employees) : null; + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + reviewers = new HashSet(); + members = new HashSet(); + } + + /** + * Returns a String representation of a FCDSProject object. + * + * @return a String representation of a FCDSProject object. + */ public String toString() { - return this.getClass().getName() + ": " + projid; + return "FCProject(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(projid); + rc.append(", name ").append(name); + rc.append(", budget ").append(budget); + return rc.toString(); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.projid != o.projid) return (false); - return (true); + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + FCDSProject otherProject = (FCDSProject)other; + String where = "FCProject<" + projid + ">"; + return + helper.equals(projid, otherProject.getProjid(), where + ".projid") & + helper.equals(name, otherProject.getName(), where + ".name") & + helper.equals(budget, otherProject.getBudget(), where + ".budget") & + helper.deepEquals(reviewers, otherProject.getReviewers(), where + ".reviewers") & + helper.deepEquals(members, otherProject.getMembers(), where + ".members"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((FCDSProject)o); } - /** */ - public int hashCode() { - return ((int) projid); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((FCDSProject)o1, (FCDSProject)o2); + } + + /** + * + * Compares this object with the specified FCDSProject object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * + * @param other The FCDSProject object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified FFCDSProject object. + */ + public int compareTo(FCDSProject other) { + return compare(this, other); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compares its two IProject arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IProject object to be compared. + * @param o2 the second IProject object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(FCDSProject o1, FCDSProject o2) { + return EqualityHelper.compare(o1.getProjid(), o2.getProjid()); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (projid < other.projid) return -1; - if (projid > other.projid) return 1; - return 0; + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof FCDSProject) { + return compareTo((FCDSProject)obj) == 0; + } + return false; } - } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)projid; + } + + /** + * This class is used to represent the application identity + * for the FCDSProject class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the identifier for the + * FCDSProject class. It must match a field in the + * FCDSProject class in both name and type. + */ + public long projid; + + /** + * The required public no-arg constructor. + */ + public Oid() { } + + /** + * Initialize the application identifier with a project ID. + * @param projid The id of the project. + */ + public Oid(long projid) { + this.projid = projid; + } + + public Oid(String s) { projid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + projid;} + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.projid != o.projid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) projid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( projid < other.projid ) return -1; + if( projid > other.projid ) return 1; + return 0; + } + + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/CompanyFactoryAnnotatedJPAAppConcrete.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/CompanyFactoryAnnotatedJPAAppConcrete.java index cbbd8478e..b91148d45 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/CompanyFactoryAnnotatedJPAAppConcrete.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/CompanyFactoryAnnotatedJPAAppConcrete.java @@ -18,16 +18,7 @@ package org.apache.jdo.tck.pc.companyAnnotatedJPA; import javax.jdo.PersistenceManager; -import org.apache.jdo.tck.pc.company.CompanyFactoryAbstractImpl; -import org.apache.jdo.tck.pc.company.IAddress; -import org.apache.jdo.tck.pc.company.ICompany; -import org.apache.jdo.tck.pc.company.IDentalInsurance; -import org.apache.jdo.tck.pc.company.IDepartment; -import org.apache.jdo.tck.pc.company.IFullTimeEmployee; -import org.apache.jdo.tck.pc.company.IMedicalInsurance; -import org.apache.jdo.tck.pc.company.IMeetingRoom; -import org.apache.jdo.tck.pc.company.IPartTimeEmployee; -import org.apache.jdo.tck.pc.company.IProject; +import org.apache.jdo.tck.pc.company.*; /* * CompanyFactoryAnnotatedPMFieldClass.java @@ -35,66 +26,66 @@ * This class uses the PersistenceManager.newInstance method with the concrete * class as a parameter. */ -public class CompanyFactoryAnnotatedJPAAppConcrete extends CompanyFactoryAbstractImpl { +public class CompanyFactoryAnnotatedJPAAppConcrete + extends CompanyFactoryAbstractImpl { + + PersistenceManager pm = null; - PersistenceManager pm = null; + /** + * Creates a new instance of CompanyFactoryAnnotatedJPAAppConcrete + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedJPAAppConcrete(PersistenceManager pm) { + super(pm); + this.pm = pm; + } + + public Class[] getTearDownClasses() { + return new Class[] { + JPAAppDentalInsurance.class, + JPAAppMedicalInsurance.class, + JPAAppPartTimeEmployee.class, + JPAAppFullTimeEmployee.class, + JPAAppProject.class, + JPAAppDepartment.class, + JPAAppCompany.class, + JPAAppAddress.class + }; + } + + public IAddress newAddress() { + return (IAddress) new JPAAppAddress(); + } - /** - * Creates a new instance of CompanyFactoryAnnotatedJPAAppConcrete - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedJPAAppConcrete(PersistenceManager pm) { - super(pm); - this.pm = pm; - } - - public Class[] getTearDownClasses() { - return new Class[] { - JPAAppDentalInsurance.class, - JPAAppMedicalInsurance.class, - JPAAppPartTimeEmployee.class, - JPAAppFullTimeEmployee.class, - JPAAppProject.class, - JPAAppDepartment.class, - JPAAppCompany.class, - JPAAppAddress.class - }; - } - - public IAddress newAddress() { - return (IAddress) new JPAAppAddress(); - } - - public IMeetingRoom newMeetingRoom() { - return (IMeetingRoom) null; - } - - public ICompany newCompany() { - return (ICompany) new JPAAppCompany(); - } - - public IDentalInsurance newDentalInsurance() { - return (IDentalInsurance) new JPAAppDentalInsurance(); - } - - public IDepartment newDepartment() { - return (IDepartment) new JPAAppDepartment(); - } - - public IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) new JPAAppFullTimeEmployee(); - } - - public IMedicalInsurance newMedicalInsurance() { - return (IMedicalInsurance) new JPAAppMedicalInsurance(); - } - - public IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) new JPAAppPartTimeEmployee(); - } - - public IProject newProject() { - return (IProject) new JPAAppProject(); - } + public IMeetingRoom newMeetingRoom() { + return (IMeetingRoom)null; + } + + public ICompany newCompany() { + return (ICompany) new JPAAppCompany(); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance) new JPAAppDentalInsurance(); + } + + public IDepartment newDepartment() { + return (IDepartment) new JPAAppDepartment(); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee) new JPAAppFullTimeEmployee(); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance) new JPAAppMedicalInsurance(); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee) new JPAAppPartTimeEmployee(); + } + + public IProject newProject() { + return (IProject) new JPAAppProject(); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/CompanyFactoryAnnotatedJPAAppPM.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/CompanyFactoryAnnotatedJPAAppPM.java index 4690f7d44..605b78024 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/CompanyFactoryAnnotatedJPAAppPM.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/CompanyFactoryAnnotatedJPAAppPM.java @@ -18,17 +18,7 @@ package org.apache.jdo.tck.pc.companyAnnotatedJPA; import javax.jdo.PersistenceManager; -import org.apache.jdo.tck.pc.company.CompanyFactoryAbstractImpl; -import org.apache.jdo.tck.pc.company.CompanyFactoryNewInstance; -import org.apache.jdo.tck.pc.company.IAddress; -import org.apache.jdo.tck.pc.company.ICompany; -import org.apache.jdo.tck.pc.company.IDentalInsurance; -import org.apache.jdo.tck.pc.company.IDepartment; -import org.apache.jdo.tck.pc.company.IFullTimeEmployee; -import org.apache.jdo.tck.pc.company.IMedicalInsurance; -import org.apache.jdo.tck.pc.company.IMeetingRoom; -import org.apache.jdo.tck.pc.company.IPartTimeEmployee; -import org.apache.jdo.tck.pc.company.IProject; +import org.apache.jdo.tck.pc.company.*; /* * CompanyFactoryAnnotatedPMFieldClass.java @@ -36,64 +26,64 @@ * This class uses the PersistenceManager.newInstance method with the concrete * class as a parameter. */ -public class CompanyFactoryAnnotatedJPAAppPM extends CompanyFactoryAbstractImpl - implements CompanyFactoryNewInstance { +public class CompanyFactoryAnnotatedJPAAppPM + extends CompanyFactoryAbstractImpl + implements CompanyFactoryNewInstance { - /** - * Creates a new instance of CompanyFactoryAnnotatedJPAAppPM - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedJPAAppPM(PersistenceManager pm) { - super(pm); - } + /** + * Creates a new instance of CompanyFactoryAnnotatedJPAAppPM + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedJPAAppPM(PersistenceManager pm) { + super(pm); + } + + public Class[] getTearDownClasses() { + return new Class[] { + JPAAppDentalInsurance.class, + JPAAppMedicalInsurance.class, + JPAAppPartTimeEmployee.class, + JPAAppFullTimeEmployee.class, + JPAAppProject.class, + JPAAppDepartment.class, + JPAAppCompany.class, + JPAAppAddress.class + }; + } + + public IAddress newAddress() { + return (IAddress)pm.newInstance(JPAAppAddress.class); + } - public Class[] getTearDownClasses() { - return new Class[] { - JPAAppDentalInsurance.class, - JPAAppMedicalInsurance.class, - JPAAppPartTimeEmployee.class, - JPAAppFullTimeEmployee.class, - JPAAppProject.class, - JPAAppDepartment.class, - JPAAppCompany.class, - JPAAppAddress.class - }; - } - - public IAddress newAddress() { - return (IAddress) pm.newInstance(JPAAppAddress.class); - } - - public IMeetingRoom newMeetingRoom() { - return (IMeetingRoom) null; - } - - public ICompany newCompany() { - return (ICompany) pm.newInstance(JPAAppCompany.class); - } - - public IDentalInsurance newDentalInsurance() { - return (IDentalInsurance) pm.newInstance(JPAAppDentalInsurance.class); - } - - public IDepartment newDepartment() { - return (IDepartment) pm.newInstance(JPAAppDepartment.class); - } - - public IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) pm.newInstance(JPAAppFullTimeEmployee.class); - } - - public IMedicalInsurance newMedicalInsurance() { - return (IMedicalInsurance) pm.newInstance(JPAAppMedicalInsurance.class); - } - - public IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) pm.newInstance(JPAAppPartTimeEmployee.class); - } - - public IProject newProject() { - return (IProject) pm.newInstance(JPAAppProject.class); - } + public IMeetingRoom newMeetingRoom() { + return (IMeetingRoom)null; + } + + public ICompany newCompany() { + return (ICompany)pm.newInstance(JPAAppCompany.class); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance)pm.newInstance(JPAAppDentalInsurance.class); + } + + public IDepartment newDepartment() { + return (IDepartment)pm.newInstance(JPAAppDepartment.class); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee)pm.newInstance(JPAAppFullTimeEmployee.class); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance)pm.newInstance(JPAAppMedicalInsurance.class); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee)pm.newInstance(JPAAppPartTimeEmployee.class); + } + + public IProject newProject() { + return (IProject)pm.newInstance(JPAAppProject.class); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/CompanyFactoryAnnotatedPMFieldClassJPA.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/CompanyFactoryAnnotatedPMFieldClassJPA.java index a7881c3f2..ef434442e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/CompanyFactoryAnnotatedPMFieldClassJPA.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/CompanyFactoryAnnotatedPMFieldClassJPA.java @@ -18,15 +18,7 @@ package org.apache.jdo.tck.pc.companyAnnotatedJPA; import javax.jdo.PersistenceManager; -import org.apache.jdo.tck.pc.company.IAddress; -import org.apache.jdo.tck.pc.company.ICompany; -import org.apache.jdo.tck.pc.company.IDentalInsurance; -import org.apache.jdo.tck.pc.company.IDepartment; -import org.apache.jdo.tck.pc.company.IFullTimeEmployee; -import org.apache.jdo.tck.pc.company.IMedicalInsurance; -import org.apache.jdo.tck.pc.company.IMeetingRoom; -import org.apache.jdo.tck.pc.company.IPartTimeEmployee; -import org.apache.jdo.tck.pc.company.IProject; +import org.apache.jdo.tck.pc.company.*; /* * CompanyFactoryAnnotatedPMFieldClassJPA.java @@ -35,79 +27,86 @@ * class as a parameter. */ public class CompanyFactoryAnnotatedPMFieldClassJPA - extends org.apache.jdo.tck.pc.company.CompanyFactoryAbstractImpl { + extends org.apache.jdo.tck.pc.company.CompanyFactoryAbstractImpl { + + Class addressClass = null; + Class dentalInsuranceClass = null; + Class medicalInsuranceClass = null; + Class partTimeEmployeeClass = null; + Class fullTimeEmployeeClass = null; + Class projectClass = null; + Class departmentClass = null; + Class companyClass = null; - Class addressClass = null; - Class dentalInsuranceClass = null; - Class medicalInsuranceClass = null; - Class partTimeEmployeeClass = null; - Class fullTimeEmployeeClass = null; - Class projectClass = null; - Class departmentClass = null; - Class companyClass = null; + /** + * Creates a new instance of CompanyFactoryAnnotatedPMFieldClassJPA + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedPMFieldClassJPA(PersistenceManager pm) { + super(pm); + addressClass = + org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppAddress.class; + dentalInsuranceClass = + org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppDentalInsurance.class; + medicalInsuranceClass = + org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppMedicalInsurance.class; + partTimeEmployeeClass = + org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppPartTimeEmployee.class; + fullTimeEmployeeClass = + org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppFullTimeEmployee.class; + projectClass = + org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppProject.class; + departmentClass = + org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppDepartment.class; + companyClass = + org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppCompany.class; + } + + public Class[] getTearDownClasses() { + return new Class[] { + dentalInsuranceClass, + medicalInsuranceClass, + partTimeEmployeeClass, + fullTimeEmployeeClass, + projectClass, + departmentClass, + companyClass + }; + } + + public IAddress newAddress() { + return (IAddress)pm.newInstance(addressClass); + } - /** - * Creates a new instance of CompanyFactoryAnnotatedPMFieldClassJPA - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedPMFieldClassJPA(PersistenceManager pm) { - super(pm); - addressClass = org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppAddress.class; - dentalInsuranceClass = org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppDentalInsurance.class; - medicalInsuranceClass = org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppMedicalInsurance.class; - partTimeEmployeeClass = org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppPartTimeEmployee.class; - fullTimeEmployeeClass = org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppFullTimeEmployee.class; - projectClass = org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppProject.class; - departmentClass = org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppDepartment.class; - companyClass = org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppCompany.class; - } - - public Class[] getTearDownClasses() { - return new Class[] { - dentalInsuranceClass, - medicalInsuranceClass, - partTimeEmployeeClass, - fullTimeEmployeeClass, - projectClass, - departmentClass, - companyClass - }; - } - - public IAddress newAddress() { - return (IAddress) pm.newInstance(addressClass); - } - - public IMeetingRoom newMeetingRoom() { - return (IMeetingRoom) null; - } - - public ICompany newCompany() { - return (ICompany) pm.newInstance(companyClass); - } - - public IDentalInsurance newDentalInsurance() { - return (IDentalInsurance) pm.newInstance(dentalInsuranceClass); - } - - public IDepartment newDepartment() { - return (IDepartment) pm.newInstance(departmentClass); - } - - public IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) pm.newInstance(fullTimeEmployeeClass); - } - - public IMedicalInsurance newMedicalInsurance() { - return (IMedicalInsurance) pm.newInstance(medicalInsuranceClass); - } - - public IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) pm.newInstance(partTimeEmployeeClass); - } - - public IProject newProject() { - return (IProject) pm.newInstance(projectClass); - } + public IMeetingRoom newMeetingRoom() { + return (IMeetingRoom)null; + } + + public ICompany newCompany() { + return (ICompany)pm.newInstance(companyClass); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance)pm.newInstance(dentalInsuranceClass); + } + + public IDepartment newDepartment() { + return (IDepartment)pm.newInstance(departmentClass); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee)pm.newInstance(fullTimeEmployeeClass); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance)pm.newInstance(medicalInsuranceClass); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee)pm.newInstance(partTimeEmployeeClass); + } + + public IProject newProject() { + return (IProject)pm.newInstance(projectClass); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppAddress.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppAddress.java index 73695f948..42f692f86 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppAddress.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppAddress.java @@ -5,342 +5,345 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedJPA; import java.io.Serializable; import java.util.Comparator; -import javax.persistence.Embeddable; + +import javax.persistence.*; + import org.apache.jdo.tck.pc.company.IAddress; import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a postal address. */ +/** + * This class represents a postal address. + */ @Embeddable -public class JPAAppAddress implements IAddress, Serializable, Comparable, Comparator, DeepEquality { - - private long addrid; - private String street; - private String city; - private String state; - private String zipcode; - private String country; - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public JPAAppAddress() {} - - /** - * This constructor initializes the JPAAppAddress components. - * - * @param addrid The address ID. - * @param street The street address. - * @param city The city. - * @param state The state. - * @param zipcode The zip code. - * @param country The zip country. - */ - public JPAAppAddress( - long addrid, String street, String city, String state, String zipcode, String country) { - this.addrid = addrid; - this.street = street; - this.city = city; - this.state = state; - this.zipcode = zipcode; - this.country = country; - } - - /** - * Get the addrid associated with this object. - * - * @return the addrid. - */ - public long getAddrid() { - return addrid; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setAddrid(long id) { - if (this.addrid != 0) throw new IllegalStateException("Id is already set."); - this.addrid = id; - } - - /** - * Get the street component of the address. - * - * @return The street component of the address. - */ - public String getStreet() { - return street; - } - - /** - * Set the street component of the address. - * - * @param street The street component. - */ - public void setStreet(String street) { - this.street = street; - } - - /** - * Get the city. - * - * @return The city component of the address. - */ - public String getCity() { - return city; - } - - /** - * Set the city component of the address. - * - * @param city The city. - */ - public void setCity(String city) { - this.city = city; - } - - /** - * Get the state component of the address. - * - * @return The state. - */ - public String getState() { - return state; - } - - /** - * Set the state component of the address. - * - * @param state The state. - */ - public void setState(String state) { - this.state = state; - } - - /** - * Get the zipcode component of the address. - * - * @return The zipcode. - */ - public String getZipcode() { - return zipcode; - } - - /** - * Set the zip code component of the address. - * - * @param zipcode The zipcode. - */ - public void setZipcode(String zipcode) { - this.zipcode = zipcode; - } - - /** - * Get the country component of the address. - * - * @return The country. - */ - public String getCountry() { - return country; - } - - /** - * Set the country component of the address. - * - * @param country The country. - */ - public void setCountry(String country) { - this.country = country; - } - - /** - * Returns a String representation of a Address object. - * - * @return a String representation of a Address object. - */ - public String toString() { - return "Address(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(addrid); - rc.append(", street ").append(street); - rc.append(", city ").append(city); - rc.append(", state ").append(state); - rc.append(", zipcode ").append(zipcode); - rc.append(", country ").append(country); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - JPAAppAddress otherAddress = (JPAAppAddress) other; - String where = "Address<" + addrid + ">"; - return helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") - & helper.equals(street, otherAddress.getStreet(), where + ".street") - & helper.equals(city, otherAddress.getCity(), where + ".city") - & helper.equals(state, otherAddress.getState(), where + ".state") - & helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") - & helper.equals(country, otherAddress.getCountry(), where + ".country"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((JPAAppAddress) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((JPAAppAddress) o1, (JPAAppAddress) o2); - } - - /** - * Compares this object with the specified Address object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Address object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Address object. - */ - public int compareTo(JPAAppAddress other) { - return compare(this, other); - } - - /** - * Compares its two JPAAppAddress arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first JPAAppAddresss object to be compared. - * @param o2 the second JPAAppAddressobject to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(JPAAppAddress o1, JPAAppAddress o2) { - return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof JPAAppAddress) { - return compareTo((JPAAppAddress) obj) == 0; +public class JPAAppAddress + implements IAddress, Serializable, Comparable, Comparator, DeepEquality { + + private long addrid; + private String street; + private String city; + private String state; + private String zipcode; + private String country; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public JPAAppAddress() {} + + /** + * This constructor initializes the JPAAppAddress components. + * + * + * + * @param addrid The address ID. + * @param street The street address. + * @param city The city. + * @param state The state. + * @param zipcode The zip code. + * @param country The zip country. + */ + public JPAAppAddress(long addrid, String street, String city, + String state, String zipcode, String country) + { + this.addrid = addrid; + this.street = street; + this.city = city; + this.state = state; + this.zipcode = zipcode; + this.country = country; + } + + /** + * Get the addrid associated with this object. + * @return the addrid. + */ + public long getAddrid() { + return addrid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setAddrid(long id) { + if (this.addrid != 0) + throw new IllegalStateException("Id is already set."); + this.addrid = id; + } + + /** + * Get the street component of the address. + * @return The street component of the address. + */ + public String getStreet() { + return street; + } + + /** + * Set the street component of the address. + * @param street The street component. + */ + public void setStreet(String street) { + this.street = street; + } + + /** + * Get the city. + * @return The city component of the address. + */ + public String getCity() { + return city; + } + + /** + * Set the city component of the address. + * @param city The city. + */ + public void setCity(String city) { + this.city = city; + } + + /** + * Get the state component of the address. + * @return The state. + */ + public String getState() { + return state; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) addrid; - } - - /** - * This class is used to represent the application identifier for the Address class. - */ - public static class Oid implements Serializable, Comparable { /** - * This is the identifier field for Address and must correspond in type and name to - * the field in Address. + * Set the state component of the address. + * @param state The state. */ - public long addrid; + public void setState(String state) { + this.state = state; + } - /** The required public, no-arg constructor. */ - public Oid() { - addrid = 0; + /** + * Get the zipcode component of the address. + * @return The zipcode. + */ + public String getZipcode() { + return zipcode; } /** - * A constructor to initialize the identifier field. - * - * @param addrid the id of the Address. + * Set the zip code component of the address. + * @param zipcode The zipcode. */ - public Oid(long addrid) { - this.addrid = addrid; + public void setZipcode(String zipcode) { + this.zipcode = zipcode; } - public Oid(String s) { - addrid = Long.parseLong(justTheId(s)); + /** + * Get the country component of the address. + * @return The country. + */ + public String getCountry() { + return country; + } + + /** + * Set the country component of the address. + * @param country The country. + */ + public void setCountry(String country) { + this.country = country; } + /** + * Returns a String representation of a Address object. + * @return a String representation of a Address object. + */ public String toString() { - return this.getClass().getName() + ": " + addrid; + return "Address(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(addrid); + rc.append(", street ").append(street); + rc.append(", city ").append(city); + rc.append(", state ").append(state); + rc.append(", zipcode ").append(zipcode); + rc.append(", country ").append(country); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + JPAAppAddress otherAddress = (JPAAppAddress)other; + String where = "Address<" + addrid + ">"; + return + helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") & + helper.equals(street, otherAddress.getStreet(), where + ".street") & + helper.equals(city, otherAddress.getCity(), where + ".city") & + helper.equals(state, otherAddress.getState(), where + ".state") & + helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") & + helper.equals(country, otherAddress.getCountry(), where + ".country"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((JPAAppAddress)o); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.addrid != o.addrid) return (false); - return (true); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((JPAAppAddress)o1, (JPAAppAddress)o2); } - /** */ - public int hashCode() { - return ((int) addrid); + /** + * Compares this object with the specified Address object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Address object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Address + * object. + */ + public int compareTo(JPAAppAddress other) { + return compare(this, other); + } + + /** + * Compares its two JPAAppAddress arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * + * + * + * @param o1 the first JPAAppAddresss object to be compared. + * @param o2 the second JPAAppAddressobject to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(JPAAppAddress o1, JPAAppAddress o2) { + return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof JPAAppAddress) { + return compareTo((JPAAppAddress)obj) == 0; + } + return false; } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (addrid < other.addrid) return -1; - if (addrid > other.addrid) return 1; - return 0; + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)addrid; + } + + /** + * This class is used to represent the application identifier + * for the Address class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This is the identifier field for Address and must + * correspond in type and name to the field in + * Address. + */ + public long addrid; + + /** The required public, no-arg constructor. */ + public Oid() + { + addrid = 0; + } + + /** + * A constructor to initialize the identifier field. + * @param addrid the id of the Address. + */ + public Oid(long addrid) { + this.addrid = addrid; + } + + public Oid(String s) { addrid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + addrid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.addrid != o.addrid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) addrid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( addrid < other.addrid ) return -1; + if( addrid > other.addrid ) return 1; + return 0; + } + } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppCompany.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppCompany.java index 454cab8d7..d1298b5cf 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppCompany.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppCompany.java @@ -5,403 +5,404 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedJPA; -import java.io.IOException; -import java.io.ObjectInputStream; +import javax.persistence.*; + import java.io.Serializable; +import java.io.ObjectInputStream; +import java.io.IOException; + import java.text.SimpleDateFormat; + import java.util.Collections; import java.util.Comparator; -import java.util.Date; -import java.util.HashSet; import java.util.Set; -import javax.persistence.AttributeOverride; -import javax.persistence.AttributeOverrides; -import javax.persistence.Basic; -import javax.persistence.Column; -import javax.persistence.DiscriminatorColumn; -import javax.persistence.DiscriminatorType; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.OneToMany; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; +import java.util.HashSet; +import java.util.Date; import org.apache.jdo.tck.pc.company.IAddress; + import org.apache.jdo.tck.pc.company.ICompany; import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents information about a company. */ -@Entity(name = "Company") -@Table(name = "companies") -@Inheritance(strategy = InheritanceType.SINGLE_TABLE) -@DiscriminatorColumn(discriminatorType = DiscriminatorType.STRING, name = "DISCRIMINATOR") -public class JPAAppCompany implements ICompany, Serializable, Comparable, Comparator, DeepEquality { - - @Id - @Column(name = "ID") - private long companyid; - - @Column(name = "NAME") - private String name; - - @Column(name = "FOUNDEDDATE") - @Temporal(TemporalType.TIMESTAMP) - private Date founded; - - @Basic - @Embedded - @AttributeOverrides({ - @AttributeOverride(name = "street", column = @Column(name = "STREET")), - @AttributeOverride(name = "city", column = @Column(name = "CITY")), - @AttributeOverride(name = "state", column = @Column(name = "STATE")), - @AttributeOverride(name = "zipcode", column = @Column(name = "ZIPCODE")), - @AttributeOverride(name = "country", column = @Column(name = "COUNTRY")) - }) - private JPAAppAddress address; - - @OneToMany(mappedBy = "company") - private Set departments = new HashSet(); - - protected static SimpleDateFormat formatter = new SimpleDateFormat("d/MMM/yyyy"); - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public JPAAppCompany() {} - - /** - * Initialize the JPAAppCompany instance. - * - * @param companyid The company id. - * @param name The company name. - * @param founded The date the company was founded. - */ - public JPAAppCompany(long companyid, String name, Date founded) { - this.companyid = companyid; - this.name = name; - this.founded = founded; - } - - /** - * Initialize the Company instance. - * - * @param companyid The company id. - * @param name The company name. - * @param founded The date the company was founded. - * @param addr The company's address. - */ - public JPAAppCompany(long companyid, String name, Date founded, IAddress addr) { - this(companyid, name, founded); - this.address = (JPAAppAddress) addr; - } - - /** - * Get the company id. - * - * @return The company id. - */ - public long getCompanyid() { - return companyid; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setCompanyid(long id) { - if (this.companyid != 0) throw new IllegalStateException("Id is already set."); - this.companyid = id; - } - - /** - * Get the name of the company. - * - * @return The name of the company. - */ - public String getName() { - return name; - } - - /** - * Set the name of the company. - * - * @param name The value to use for the name of the company. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Get the date that the company was founded. - * - * @return The date the company was founded. - */ - public Date getFounded() { - return founded; - } - - /** - * Set the date that the company was founded. - * - * @param founded The date to set that the company was founded. - */ - public void setFounded(Date founded) { - this.founded = founded; - } - - /** - * Get the address of the company. - * - * @return The primary address of the company. - */ - public IAddress getAddress() { - return address; - } - - /** - * Set the primary address for the company. - * - * @param address The address to set for the company. - */ - public void setAddress(IAddress address) { - this.address = (JPAAppAddress) address; - } - - /** - * Get the departments contained in the company. - * - * @return An unmodifiable Set that contains all the JPAAppDepartments - * of the company. - */ - public Set getDepartments() { - return Collections.unmodifiableSet(departments); - } - - /** - * Add a JPAAppDepartment instance to the company. - * - * @param dept The JPAAppDepartment instance to add. - */ - public void addDepartment(JPAAppDepartment dept) { - departments.add(dept); - } - - /** - * Remove a JPAAppDepartment instance from the company. - * - * @param dept The JPAAppDepartment instance to remove. - */ - public void removeDepartment(JPAAppDepartment dept) { - departments.remove(dept); - } - - /** - * Initialize the set of JPAAppDepartments in the company to the parameter. - * - * @param departments The set of JPAAppDepartments for the company. - */ - public void setDepartments(Set departments) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.departments = (departments != null) ? new HashSet(departments) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - departments = new HashSet(); - } - - /** - * Returns a String representation of a Company object. - * - * @return a String representation of a Company object. - */ - public String toString() { - return "Company(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(companyid); - rc.append(", name ").append(name); - rc.append(", founded ").append(founded == null ? "null" : formatter.format(founded)); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - JPAAppCompany otherCompany = (JPAAppCompany) other; - String where = "Company<" + companyid + ">"; - return helper.equals(companyid, otherCompany.getCompanyid(), where + ".companyid") - & helper.equals(name, otherCompany.getName(), where + ".name") - & helper.equals(founded, otherCompany.getFounded(), where + ".founded") - & helper.deepEquals(address, otherCompany.getAddress(), where + ".address") - & helper.deepEquals(departments, otherCompany.getDepartments(), where + ".departments"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((JPAAppCompany) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((JPAAppCompany) o1, (JPAAppCompany) o2); - } - - /** - * Compares this object with the specified Company object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Company object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Company object. - */ - public int compareTo(JPAAppCompany other) { - return compare(this, other); - } - - /** - * Compares its two ICompany arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first ICompany object to be compared. - * @param o2 the second ICompany object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(JPAAppCompany o1, JPAAppCompany o2) { - return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof JPAAppCompany) { - return compareTo((JPAAppCompany) obj) == 0; +/** + * This class represents information about a company. + */ +@Entity(name="Company") +@Table(name="companies") +@Inheritance(strategy=InheritanceType.SINGLE_TABLE) +@DiscriminatorColumn(discriminatorType=DiscriminatorType.STRING, + name="DISCRIMINATOR") + public class JPAAppCompany + implements ICompany, Serializable, Comparable, Comparator, DeepEquality { + + @Id + @Column(name="ID") + private long companyid; + @Column(name="NAME") + private String name; + @Column(name="FOUNDEDDATE") + @Temporal(TemporalType.TIMESTAMP) + private Date founded; + @Basic + @Embedded + @AttributeOverrides({ + @AttributeOverride(name="street", + column=@Column(name="STREET")), + @AttributeOverride(name="city", + column=@Column(name="CITY")), + @AttributeOverride(name="state", + column=@Column(name="STATE")), + @AttributeOverride(name="zipcode", + column=@Column(name="ZIPCODE")), + @AttributeOverride(name="country", + column=@Column(name="COUNTRY")) + }) + private JPAAppAddress address; + @OneToMany(mappedBy="company") + private Set departments = new HashSet(); + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public JPAAppCompany() {} + + /** + * + * Initialize the JPAAppCompany instance. + * + * + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + */ + public JPAAppCompany(long companyid, String name, Date founded) { + this.companyid = companyid; + this.name = name; + this.founded = founded; + } + + /** + * Initialize the Company instance. + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + * @param addr The company's address. + */ + public JPAAppCompany(long companyid, String name, Date founded, IAddress addr) { + this(companyid, name, founded); + this.address = (JPAAppAddress)addr; + } + + /** + * Get the company id. + * @return The company id. + */ + public long getCompanyid() { + return companyid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setCompanyid(long id) { + if (this.companyid != 0) + throw new IllegalStateException("Id is already set."); + this.companyid = id; + } + + /** + * Get the name of the company. + * @return The name of the company. + */ + public String getName() { + return name; + } + + /** + * Set the name of the company. + * @param name The value to use for the name of the company. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Get the date that the company was founded. + * @return The date the company was founded. + */ + public Date getFounded() { + return founded; + } + + /** + * Set the date that the company was founded. + * @param founded The date to set that the company was founded. + */ + public void setFounded(Date founded) { + this.founded = founded; + } + + /** + * Get the address of the company. + * @return The primary address of the company. + */ + public IAddress getAddress() { + return address; + } + + /** + * Set the primary address for the company. + * @param address The address to set for the company. + */ + public void setAddress(IAddress address) { + this.address = (JPAAppAddress)address; + } + + /** + * Get the departments contained in the company. + * + * + * @return An unmodifiable Set that contains all the + * JPAAppDepartments of the company. + */ + public Set getDepartments() { + return Collections.unmodifiableSet(departments); } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) companyid; - } - - /** - * The class to be used as the application identifier for the Company class. It - * consists of both the company name and the date that the company was founded. - */ - public static class Oid implements Serializable, Comparable { /** - * This field is part of the identifier and should match in name and type with a field in the - * Company class. + * Add a JPAAppDepartment instance to the company. + * + * + * @param dept The JPAAppDepartment instance to add. */ - public long companyid; + public void addDepartment(JPAAppDepartment dept) { + departments.add(dept); + } - /** The required public no-arg constructor. */ - public Oid() {} + /** + * Remove a JPAAppDepartment instance from the company. + * + * + * @param dept The JPAAppDepartment instance to remove. + */ + public void removeDepartment(JPAAppDepartment dept) { + departments.remove(dept); + } /** - * Initialize the identifier. - * - * @param companyid The id of the company. + * Initialize the set of JPAAppDepartments in the company to the + * parameter. + * + * + * @param departments The set of JPAAppDepartments for the + * company. */ - public Oid(long companyid) { - this.companyid = companyid; + public void setDepartments(Set departments) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.departments = + (departments != null) ? new HashSet(departments) : null; } - public Oid(String s) { - companyid = Long.parseLong(justTheId(s)); + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + departments = new HashSet(); } + /** + * Returns a String representation of a Company object. + * @return a String representation of a Company object. + */ public String toString() { - return this.getClass().getName() + ": " + companyid; + return "Company(" + getFieldRepr()+ ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(companyid); + rc.append(", name ").append(name); + rc.append(", founded ").append( + founded==null ? "null" : formatter.format(founded)); + return rc.toString(); } - /** */ - public boolean equals(Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return false; - Oid o = (Oid) obj; - if (this.companyid != o.companyid) return false; - return true; + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + JPAAppCompany otherCompany = (JPAAppCompany)other; + String where = "Company<" + companyid + ">"; + return + helper.equals(companyid, otherCompany.getCompanyid(), where + ".companyid") & + helper.equals(name, otherCompany.getName(), where + ".name") & + helper.equals(founded, otherCompany.getFounded(), where + ".founded") & + helper.deepEquals(address, otherCompany.getAddress(), where + ".address") & + helper.deepEquals(departments, otherCompany.getDepartments(), where + ".departments"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((JPAAppCompany)o); } - /** */ - public int hashCode() { - return (int) companyid; + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((JPAAppCompany)o1, (JPAAppCompany)o2); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compares this object with the specified Company object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Company object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Company + * object. + */ + public int compareTo(JPAAppCompany other) { + return compare(this, other); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (companyid < other.companyid) return -1; - if (companyid > other.companyid) return 1; - return 0; + /** + * Compares its two ICompany arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first ICompany object to be compared. + * @param o2 the second ICompany object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(JPAAppCompany o1, JPAAppCompany o2) { + return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); } - } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof JPAAppCompany) { + return compareTo((JPAAppCompany)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)companyid; + } + + /** + * The class to be used as the application identifier + * for the Company class. It consists of both the company + * name and the date that the company was founded. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field is part of the identifier and should match in name + * and type with a field in the Company class. + */ + public long companyid; + + /** The required public no-arg constructor. */ + public Oid() { } + + /** + * Initialize the identifier. + * @param companyid The id of the company. + */ + public Oid(long companyid) { + this.companyid = companyid; + } + + public Oid(String s) { companyid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + companyid;} + + + /** */ + public boolean equals(Object obj) { + if (obj==null || !this.getClass().equals(obj.getClass())) + return false; + Oid o = (Oid) obj; + if (this.companyid != o.companyid) + return false; + return true; + } + + /** */ + public int hashCode() { + return (int)companyid; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( companyid < other.companyid ) return -1; + if( companyid > other.companyid ) return 1; + return 0; + } + + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppDentalInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppDentalInsurance.java index 21990bd73..508c76d2f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppDentalInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppDentalInsurance.java @@ -5,123 +5,127 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedJPA; +import javax.persistence.*; + import java.math.BigDecimal; -import javax.persistence.Column; -import javax.persistence.Entity; + import org.apache.jdo.tck.pc.company.IDentalInsurance; import org.apache.jdo.tck.pc.company.IEmployee; import org.apache.jdo.tck.util.EqualityHelper; /** - * This class represents a dental insurance carrier selection for a particular Employee - * . + * This class represents a dental insurance carrier selection for a + * particular Employee. */ @Entity -public class JPAAppDentalInsurance extends JPAAppInsurance implements IDentalInsurance { +public class JPAAppDentalInsurance extends JPAAppInsurance + implements IDentalInsurance { - @Column(name = "LIFETIME_ORTHO_BENEFIT") - private BigDecimal lifetimeOrthoBenefit; + @Column(name="LIFETIME_ORTHO_BENEFIT") + private BigDecimal lifetimeOrthoBenefit; - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public JPAAppDentalInsurance() {} + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public JPAAppDentalInsurance() {} - /** - * Construct a DentalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. - */ - public JPAAppDentalInsurance(long insid, String carrier, BigDecimal lifetimeOrthoBenefit) { - super(insid, carrier); - this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; - } + /** + * Construct a DentalInsurance instance. + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public JPAAppDentalInsurance(long insid, String carrier, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier); + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } - /** - * Construct a JPAAppDentalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param employee The employee associated with this insurance. - * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. - */ - public JPAAppDentalInsurance( - long insid, String carrier, IEmployee employee, BigDecimal lifetimeOrthoBenefit) { - super(insid, carrier, employee); - this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; - } + /** + * Construct a JPAAppDentalInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public JPAAppDentalInsurance(long insid, String carrier, IEmployee employee, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier, employee); + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } - /** - * Get the insurance lifetimeOrthoBenefit. - * - * @return The insurance lifetimeOrthoBenefit. - */ - public BigDecimal getLifetimeOrthoBenefit() { - return lifetimeOrthoBenefit; - } + /** + * Get the insurance lifetimeOrthoBenefit. + * @return The insurance lifetimeOrthoBenefit. + */ + public BigDecimal getLifetimeOrthoBenefit() { + return lifetimeOrthoBenefit; + } - /** - * Set the insurance lifetimeOrthoBenefit. - * - * @param lifetimeOrthoBenefit The insurance lifetimeOrthoBenefit. - */ - public void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit) { - this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; - } + /** + * Set the insurance lifetimeOrthoBenefit. + * @param lifetimeOrthoBenefit The insurance lifetimeOrthoBenefit. + */ + public void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit) { + this.lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } - /** - * Returns a String representation of a JPAAppDentalInsurance object. - * - * @return a String representation of a JPAAppDentalInsurance object. - */ - public String toString() { - return "JPAAppDentalInsurance(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of a JPAAppDentalInsurance + * object. + * + * + * @return a String representation of a JPAAppDentalInsurance + * object. + */ + public String toString() { + return "JPAAppDentalInsurance(" + getFieldRepr()+ ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", lifetimeOrthoBenefit ").append(lifetimeOrthoBenefit); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", lifetimeOrthoBenefit ").append(lifetimeOrthoBenefit); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + JPAAppDentalInsurance otherIns = (JPAAppDentalInsurance)other; + String where = "JPAAppDentalInsurance<" + getInsid() + ">"; + return super.deepCompareFields(otherIns, helper) & + helper.equals(lifetimeOrthoBenefit, + otherIns.getLifetimeOrthoBenefit(), where + ".lifetimeOrthoBenefit"); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Object. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - JPAAppDentalInsurance otherIns = (JPAAppDentalInsurance) other; - String where = "JPAAppDentalInsurance<" + getInsid() + ">"; - return super.deepCompareFields(otherIns, helper) - & helper.equals( - lifetimeOrthoBenefit, - otherIns.getLifetimeOrthoBenefit(), - where + ".lifetimeOrthoBenefit"); - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppDepartment.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppDepartment.java index ce946548e..9204f671f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppDepartment.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppDepartment.java @@ -5,458 +5,449 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedJPA; -import java.io.IOException; -import java.io.ObjectInputStream; +import javax.persistence.*; + import java.io.Serializable; +import java.io.ObjectInputStream; +import java.io.IOException; + import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Set; -import javax.persistence.Column; -import javax.persistence.DiscriminatorColumn; -import javax.persistence.DiscriminatorType; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.OneToMany; -import javax.persistence.Table; import org.apache.jdo.tck.pc.company.ICompany; + import org.apache.jdo.tck.pc.company.IDepartment; import org.apache.jdo.tck.pc.company.IEmployee; import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a department within a company. */ +/** + * This class represents a department within a company. + */ @Entity -@Table(name = "departments") -@Inheritance(strategy = InheritanceType.SINGLE_TABLE) -@DiscriminatorColumn(discriminatorType = DiscriminatorType.STRING, name = "DISCRIMINATOR") +@Table(name="departments") +@Inheritance(strategy=InheritanceType.SINGLE_TABLE) +@DiscriminatorColumn(discriminatorType=DiscriminatorType.STRING, + name="DISCRIMINATOR") public class JPAAppDepartment implements IDepartment, Serializable, Comparable, Comparator, DeepEquality { - public static final int RECOMMENDED_NO_OF_EMPS = 2; - - @Id - @Column(name = "ID") - private long deptid; - - @Column(name = "NAME") - private String name; - - @Column(name = "COMPANYID") - private JPAAppCompany company; - - @Column(name = "EMP_OF_THE_MONTH") - private JPAAppEmployee employeeOfTheMonth; - - @OneToMany( - mappedBy = "department", - targetEntity = org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppEmployee.class) - private Set employees = new HashSet(); - - @OneToMany( - mappedBy = "fundingDept", - targetEntity = org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppEmployee.class) - private Set fundedEmps = new HashSet(); - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public JPAAppDepartment() {} - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - */ - public JPAAppDepartment(long deptid, String name) { - this.deptid = deptid; - this.name = name; - } - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - * @param company The company that the department is associated with. - */ - public JPAAppDepartment(long deptid, String name, ICompany company) { - this.deptid = deptid; - this.name = name; - this.company = (JPAAppCompany) company; - } - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - * @param company The company that the department is associated with. - * @param employeeOfTheMonth The employee of the month the department is associated with. - */ - public JPAAppDepartment( - long deptid, String name, ICompany company, IEmployee employeeOfTheMonth) { - this.deptid = deptid; - this.name = name; - this.company = (JPAAppCompany) company; - this.employeeOfTheMonth = (JPAAppEmployee) employeeOfTheMonth; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setDeptid(long id) { - if (this.deptid != 0) throw new IllegalStateException("Id is already set."); - this.deptid = id; - } - - /** - * Get the department id. - * - * @return The department id. - */ - public long getDeptid() { - return deptid; - } - - /** - * Get the name of the department. - * - * @return The name of the department. - */ - public String getName() { - return name; - } - - /** - * Set the name of the department. - * - * @param name The name to set for the department. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Get the company associated with the department. - * - * @return The company. - */ - public ICompany getCompany() { - return company; - } - - /** - * Set the company for the department. - * - * @param company The company to associate with the department. - */ - public void setCompany(ICompany company) { - this.company = (JPAAppCompany) company; - } - - /** - * Get the employee of the month associated with the department. - * - * @return The employee of the month. - */ - public IEmployee getEmployeeOfTheMonth() { - return employeeOfTheMonth; - } - - /** - * Set the employee of the month for the department. - * - * @param employeeOfTheMonth The employee of the month to associate with the department. - */ - public void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth) { - this.employeeOfTheMonth = (JPAAppEmployee) employeeOfTheMonth; - } - - /** - * Get the employees in the department as an unmodifiable set. - * - * @return The set of employees in the department, as an unmodifiable set. - */ - public Set getEmployees() { - return Collections.unmodifiableSet(employees); - } - - /** - * Add an employee to the department. - * - * @param emp The employee to add to the department. - */ - public void addEmployee(JPAAppEmployee emp) { - employees.add(emp); - } - - /** - * Remove an employee from the department. - * - * @param emp The employee to remove from the department. - */ - public void removeEmployee(JPAAppEmployee emp) { - employees.remove(emp); - } - - /** - * Set the employees to be in this department. - * - * @param employees The set of employees for this department. - */ - public void setEmployees(Set employees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.employees = (employees != null) ? new HashSet(employees) : null; - } - - /** - * Get the funded employees in the department as an unmodifiable set. - * - * @return The set of funded employees in the department, as an unmodifiable set. - */ - public Set getFundedEmps() { - return Collections.unmodifiableSet(fundedEmps); - } - - /** - * Add an employee to the collection of funded employees of this department. - * - * @param emp The employee to add to the department. - */ - public void addFundedEmp(JPAAppEmployee emp) { - fundedEmps.add(emp); - } - - /** - * Remove an employee from collection of funded employees of this department. - * - * @param emp The employee to remove from the department. - */ - public void removeFundedEmp(JPAAppEmployee emp) { - fundedEmps.remove(emp); - } - - /** - * Set the funded employees to be in this department. - * - * @param employees The set of funded employees for this department. - */ - public void setFundedEmps(Set employees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.fundedEmps = (fundedEmps != null) ? new HashSet(employees) : null; - } - - @Override - public List getMeetingRooms() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void setMeetingRooms(List rooms) { - // TODO Auto-generated method stub - - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - employees = new HashSet(); - fundedEmps = new HashSet(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other JPAAppDepartment. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - JPAAppDepartment otherDept = (JPAAppDepartment) other; - String where = "JPADepartment<" + deptid + ">"; - return helper.equals(deptid, otherDept.getDeptid(), where + ".deptid") - & helper.equals(name, otherDept.getName(), where + ".name") - & helper.deepEquals(company, otherDept.getCompany(), where + ".company") - & helper.deepEquals( - employeeOfTheMonth, otherDept.getEmployeeOfTheMonth(), where + ".employeeOfTheMonth") - & helper.deepEquals(employees, otherDept.getEmployees(), where + ".employees") - & helper.deepEquals(fundedEmps, otherDept.getFundedEmps(), where + ".fundedEmps"); - } - - /** - * Returns a String representation of a JPAAppDepartment object. - * - * @return a String representation of a JPAAppDepartment object. - */ - public String toString() { - return "JPADepartment(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(deptid); - rc.append(", name ").append(name); - return rc.toString(); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((JPAAppDepartment) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((JPAAppDepartment) o1, (JPAAppDepartment) o2); - } - - /** - * Compares this object with the specified Department object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Department object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Department object. - */ - public int compareTo(JPAAppDepartment other) { - return compare(this, other); - } - - /** - * Compares its two IDepartment arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IDepartment object to be compared. - * @param o2 the second IDepartment object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(JPAAppDepartment o1, JPAAppDepartment o2) { - return EqualityHelper.compare(o1.getDeptid(), o2.getDeptid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof JPAAppDepartment) { - return compareTo((JPAAppDepartment) obj) == 0; + public static final int RECOMMENDED_NO_OF_EMPS = 2; + + @Id + @Column(name="ID") + private long deptid; + @Column(name="NAME") + private String name; + @Column(name="COMPANYID") + private JPAAppCompany company; + @Column(name="EMP_OF_THE_MONTH") + private JPAAppEmployee employeeOfTheMonth; + @OneToMany(mappedBy="department", + targetEntity=org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppEmployee.class) + private Set employees = new HashSet(); + @OneToMany(mappedBy="fundingDept", + targetEntity=org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppEmployee.class) + private Set fundedEmps = new HashSet(); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public JPAAppDepartment() {} + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + */ + public JPAAppDepartment(long deptid, String name) { + this.deptid = deptid; + this.name = name; + } + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + * @param company The company that the department is associated with. + */ + public JPAAppDepartment(long deptid, String name, ICompany company) { + this.deptid = deptid; + this.name = name; + this.company = (JPAAppCompany)company; + } + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + * @param company The company that the department is associated with. + * @param employeeOfTheMonth The employee of the month the + * department is associated with. + */ + public JPAAppDepartment(long deptid, String name, ICompany company, + IEmployee employeeOfTheMonth) { + this.deptid = deptid; + this.name = name; + this.company = (JPAAppCompany)company; + this.employeeOfTheMonth = (JPAAppEmployee)employeeOfTheMonth; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setDeptid(long id) { + if (this.deptid != 0) + throw new IllegalStateException("Id is already set."); + this.deptid = id; + } + + /** + * Get the department id. + * @return The department id. + */ + public long getDeptid() { + return deptid; } - return false; - } - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) deptid; - } + /** + * Get the name of the department. + * @return The name of the department. + */ + public String getName() { + return name; + } - /** The application identity class associated with the Department class. */ - public static class Oid implements Serializable, Comparable { + /** + * Set the name of the department. + * @param name The name to set for the department. + */ + public void setName(String name) { + this.name = name; + } /** - * This field represents the application identifier field for the Department class. - * It must match in name and type with the field in the Department class. + * Get the company associated with the department. + * @return The company. */ - public long deptid; + public ICompany getCompany() { + return company; + } - /** The required public, no-arg constructor. */ - public Oid() {} + /** + * Set the company for the department. + * @param company The company to associate with the department. + */ + public void setCompany(ICompany company) { + this.company = (JPAAppCompany)company; + } /** - * A constructor to initialize the identifier field. - * - * @param deptid the deptid of the Department. + * Get the employee of the month associated with the department. + * @return The employee of the month. */ - public Oid(long deptid) { - this.deptid = deptid; + public IEmployee getEmployeeOfTheMonth() { + return employeeOfTheMonth; } - public Oid(String s) { - deptid = Long.parseLong(justTheId(s)); + /** + * Set the employee of the month for the department. + * @param employeeOfTheMonth The employee of the month to + * associate with the department. + */ + public void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth) { + this.employeeOfTheMonth = (JPAAppEmployee)employeeOfTheMonth; } + /** + * Get the employees in the department as an unmodifiable set. + * @return The set of employees in the department, as an unmodifiable + * set. + */ + public Set getEmployees() { + return Collections.unmodifiableSet(employees); + } + + /** + * Add an employee to the department. + * @param emp The employee to add to the department. + */ + public void addEmployee(JPAAppEmployee emp) { + employees.add(emp); + } + + /** + * Remove an employee from the department. + * @param emp The employee to remove from the department. + */ + public void removeEmployee(JPAAppEmployee emp) { + employees.remove(emp); + } + + /** + * Set the employees to be in this department. + * @param employees The set of employees for this department. + */ + public void setEmployees(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.employees = (employees != null) ? new HashSet(employees) : null; + } + + /** + * Get the funded employees in the department as an unmodifiable set. + * @return The set of funded employees in the department, as an + * unmodifiable set. + */ + public Set getFundedEmps() { + return Collections.unmodifiableSet(fundedEmps); + } + + /** + * Add an employee to the collection of funded employees of this + * department. + * @param emp The employee to add to the department. + */ + public void addFundedEmp(JPAAppEmployee emp) { + fundedEmps.add(emp); + } + + /** + * Remove an employee from collection of funded employees of this + * department. + * @param emp The employee to remove from the department. + */ + public void removeFundedEmp(JPAAppEmployee emp) { + fundedEmps.remove(emp); + } + + /** + * Set the funded employees to be in this department. + * @param employees The set of funded employees for this department. + */ + public void setFundedEmps(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.fundedEmps = (fundedEmps != null) ? new HashSet(employees) : null; + } + + @Override + public List getMeetingRooms() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setMeetingRooms(List rooms) { + // TODO Auto-generated method stub + + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + employees = new HashSet(); + fundedEmps = new HashSet(); + } + + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other JPAAppDepartment. + * + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + JPAAppDepartment otherDept = (JPAAppDepartment)other; + String where = "JPADepartment<" + deptid + ">"; + return + helper.equals(deptid, otherDept.getDeptid(), where + ".deptid") & + helper.equals(name, otherDept.getName(), where + ".name") & + helper.deepEquals(company, otherDept.getCompany(), where + ".company") & + helper.deepEquals(employeeOfTheMonth, otherDept.getEmployeeOfTheMonth(), where + ".employeeOfTheMonth") & + helper.deepEquals(employees, otherDept.getEmployees(), where + ".employees") & + helper.deepEquals(fundedEmps, otherDept.getFundedEmps(), where + ".fundedEmps"); + } + + /** + * Returns a String representation of a JPAAppDepartment object. + * + * + * @return a String representation of a JPAAppDepartment object. + */ public String toString() { - return this.getClass().getName() + ": " + deptid; + return "JPADepartment(" + getFieldRepr()+ ")"; } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.deptid != o.deptid) return (false); - return (true); + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(deptid); + rc.append(", name ").append(name); + return rc.toString(); } - /** */ - public int hashCode() { - return ((int) deptid); + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((JPAAppDepartment)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((JPAAppDepartment)o1, (JPAAppDepartment)o2); + } + + /** + * Compares this object with the specified Department object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Department object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified + * Department object. + */ + public int compareTo(JPAAppDepartment other) { + return compare(this, other); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compares its two IDepartment arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IDepartment object to be compared. + * @param o2 the second IDepartment object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(JPAAppDepartment o1, JPAAppDepartment o2) { + return EqualityHelper.compare(o1.getDeptid(), o2.getDeptid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof JPAAppDepartment) { + return compareTo((JPAAppDepartment)obj) == 0; + } + return false; } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)deptid; + } + + /** + * The application identity class associated with the + * Department class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the application identifier field + * for the Department class. + * It must match in name and type with the field in the + * Department class. + */ + public long deptid; + + /** + * The required public, no-arg constructor. + */ + public Oid() { } + + /** + * A constructor to initialize the identifier field. + * @param deptid the deptid of the Department. + */ + public Oid(long deptid) { + this.deptid = deptid; + } + + public Oid(String s) { deptid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + deptid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.deptid != o.deptid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) deptid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( deptid < other.deptid ) return -1; + if( deptid > other.deptid ) return 1; + return 0; + } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (deptid < other.deptid) return -1; - if (deptid > other.deptid) return 1; - return 0; } - } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppEmployee.java index 6298ab1cd..88e41ac30 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppEmployee.java @@ -5,552 +5,521 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedJPA; -import java.io.IOException; +import javax.persistence.*; + import java.io.ObjectInputStream; +import java.io.IOException; + import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.Set; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.ManyToMany; -import javax.persistence.OneToMany; -import javax.persistence.OneToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; import org.apache.jdo.tck.pc.company.IAddress; import org.apache.jdo.tck.pc.company.IDentalInsurance; import org.apache.jdo.tck.pc.company.IDepartment; + import org.apache.jdo.tck.pc.company.IEmployee; import org.apache.jdo.tck.pc.company.IMedicalInsurance; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents an employee. */ +/** + * This class represents an employee. + */ @Entity -@Table(name = "employees") +@Table(name="employees") public abstract class JPAAppEmployee extends JPAAppPerson implements IEmployee { - @Column(name = "HIREDATE") - @Temporal(TemporalType.TIMESTAMP) - private Date hiredate; - - @Column(name = "WEEKLYHOURS") - private double weeklyhours; - - @OneToOne(mappedBy = "employee") - private JPAAppDentalInsurance dentalInsurance; - - @OneToOne(mappedBy = "employee") - private JPAAppMedicalInsurance medicalInsurance; - - @Column(name = "DEPARTMENT") - private JPAAppDepartment department; - - @Column(name = "FUNDINGDEPT") - private JPAAppDepartment fundingDept; - - @Column(name = "MANAGER") - private JPAAppEmployee manager; - - @Column(name = "MENTOR") - private JPAAppEmployee mentor; - - @OneToOne(mappedBy = "mentor") - private JPAAppEmployee protege; - - @Column(name = "HRADVISOR") - private JPAAppEmployee hradvisor; - - @ManyToMany( - mappedBy = "reviewers", - targetEntity = org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppProject.class) - private Set reviewedProjects = new HashSet(); - - @ManyToMany( - mappedBy = "members", - targetEntity = org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppProject.class) - private Set projects = new HashSet(); - - @OneToMany( - mappedBy = "manager", - targetEntity = org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppEmployee.class) - private Set team = new HashSet(); - - @OneToMany( - mappedBy = "hradvisor", - targetEntity = org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppEmployee.class) - private Set hradvisees = new HashSet(); - - /** This is the JDO-required no-args constructor */ - protected JPAAppEmployee() {} - - /** - * Construct an JPAAppEmployee instance. - * - * @param personid The identifier for the person. - * @param firstname The first name of the employee. - * @param lastname The last name of the employee. - * @param middlename The middle name of the employee. - * @param birthdate The birth date of the employee. - * @param hiredate The date that the employee was hired. - */ - public JPAAppEmployee( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - Date hiredate) { - super(personid, firstname, lastname, middlename, birthdate); - this.hiredate = hiredate; - } - - /** - * Construct an JPAAppEmployee instance. - * - * @param personid The identifier for the person. - * @param firstname The first name of the employee. - * @param lastname The last name of the employee. - * @param middlename The middle name of the employee. - * @param birthdate The birth date of the employee. - * @param address The address of the employee. - * @param hiredate The date that the employee was hired. - */ - public JPAAppEmployee( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - IAddress address, - Date hiredate) { - super(personid, firstname, lastname, middlename, birthdate, (JPAAppAddress) address); - this.hiredate = hiredate; - } - - /** - * Get the date that the employee was hired. - * - * @return The date the employee was hired. - */ - public Date getHiredate() { - return hiredate; - } - - /** - * Set the date that the employee was hired. - * - * @param hiredate The date the employee was hired. - */ - public void setHiredate(Date hiredate) { - this.hiredate = hiredate; - } - - /** - * Get the weekly hours of the employee. - * - * @return The number of hours per week that the employee works. - */ - public double getWeeklyhours() { - return weeklyhours; - } - - /** - * Set the number of hours per week that the employee works. - * - * @param weeklyhours The number of hours per week that the employee works. - */ - public void setWeeklyhours(double weeklyhours) { - this.weeklyhours = weeklyhours; - } - - /** - * Get the reviewed projects. - * - * @return The reviewed projects as an unmodifiable set. - */ - public Set getReviewedProjects() { - return Collections.unmodifiableSet(reviewedProjects); - } - - /** - * Add a reviewed project. - * - * @param project A reviewed project. - */ - public void addReviewedProjects(JPAAppProject project) { - reviewedProjects.add(project); - } - - /** - * Remove a reviewed project. - * - * @param project A reviewed project. - */ - public void removeReviewedProject(JPAAppProject project) { - reviewedProjects.remove(project); - } - - /** - * Set the reviewed projects for the employee. - * - * @param reviewedProjects The set of reviewed projects. - */ - public void setReviewedProjects(Set reviewedProjects) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.reviewedProjects = (reviewedProjects != null) ? new HashSet(reviewedProjects) : null; - } - - /** - * Get the employee's projects. - * - * @return The employee's projects are returned as an unmodifiable set. - */ - public Set getProjects() { - return Collections.unmodifiableSet(projects); - } - - /** - * Add a project for the employee. - * - * @param project The project. - */ - public void addProject(JPAAppProject project) { - projects.add(project); - } - - /** - * Remove a project from an employee's set of projects. - * - * @param project The project. - */ - public void removeProject(JPAAppProject project) { - projects.remove(project); - } - - /** - * Set the projects for the employee. - * - * @param projects The set of projects of the employee. - */ - public void setProjects(Set projects) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.projects = (projects != null) ? new HashSet(projects) : null; - } - - /** - * Get the dental insurance of the employee. - * - * @return The employee's dental insurance. - */ - public IDentalInsurance getDentalInsurance() { - return dentalInsurance; - } - - /** - * Set the dental insurance object for the employee. - * - * @param dentalInsurance The dental insurance object to associate with the employee. - */ - public void setDentalInsurance(IDentalInsurance dentalInsurance) { - this.dentalInsurance = (JPAAppDentalInsurance) dentalInsurance; - } - /** - * Get the medical insurance of the employee. - * - * @return The employee's medical insurance. - */ - public IMedicalInsurance getMedicalInsurance() { - return medicalInsurance; - } - - /** - * Set the medical insurance object for the employee. - * - * @param medicalInsurance The medical insurance object to associate with the employee. - */ - public void setMedicalInsurance(IMedicalInsurance medicalInsurance) { - this.medicalInsurance = (JPAAppMedicalInsurance) medicalInsurance; - } - - /** - * Get the employee's department. - * - * @return The department associated with the employee. - */ - public IDepartment getDepartment() { - return department; - } - - /** - * Set the employee's department. - * - * @param department The department. - */ - public void setDepartment(IDepartment department) { - this.department = (JPAAppDepartment) department; - } - - /** - * Get the employee's funding department. - * - * @return The funding department associated with the employee. - */ - public IDepartment getFundingDept() { - return fundingDept; - } - - /** - * Set the employee's funding department. - * - * @param department The funding department. - */ - public void setFundingDept(IDepartment department) { - this.fundingDept = (JPAAppDepartment) department; - } - - /** - * Get the employee's manager. - * - * @return The employee's manager. - */ - public IEmployee getManager() { - return manager; - } - - /** - * Set the employee's manager. - * - * @param manager The employee's manager. - */ - public void setManager(IEmployee manager) { - this.manager = (JPAAppEmployee) manager; - } - - /** - * Get the employee's team. - * - * @return The set of JPAAppEmployees on this employee's team, returned as an - * unmodifiable set. - */ - public Set getTeam() { - return Collections.unmodifiableSet(team); - } - - /** - * Add an JPAAppEmployee to this employee's team. This method sets both sides of the - * relationship, modifying this employees team to include parameter emp and modifying emp to set - * its manager attribute to this object. - * - * @param emp The JPAAppEmployee to add to the team. - */ - public void addToTeam(JPAAppEmployee emp) { - team.add(emp); - emp.manager = this; - } - - /** - * Remove an JPAAppEmployee from this employee's team. This method will also set the - * emp manager to null. - * - * @param emp The JPAAppEmployee to remove from the team. - */ - public void removeFromTeam(JPAAppEmployee emp) { - team.remove(emp); - emp.manager = null; - } - - /** - * Set the employee's team. - * - * @param team The set of JPAAppEmployees. - */ - public void setTeam(Set team) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.team = (team != null) ? new HashSet(team) : null; - } - - /** - * Set the mentor for this employee. - * - * @param mentor The mentor for this employee. - */ - public void setMentor(IEmployee mentor) { - this.mentor = (JPAAppEmployee) mentor; - } - - /** - * Get the mentor for this employee. - * - * @return The mentor. - */ - public IEmployee getMentor() { - return mentor; - } - - /** - * Set the protege for this employee. - * - * @param protege The protege for this employee. - */ - public void setProtege(IEmployee protege) { - this.protege = (JPAAppEmployee) protege; - } - - /** - * Get the protege of this employee. - * - * @return The protege of this employee. - */ - public IEmployee getProtege() { - return protege; - } - - /** - * Set the HR advisor for this employee. - * - * @param hradvisor The hradvisor for this employee. - */ - public void setHradvisor(IEmployee hradvisor) { - this.hradvisor = (JPAAppEmployee) hradvisor; - } - - /** - * Get the HR advisor for the employee. - * - * @return The HR advisor. - */ - public IEmployee getHradvisor() { - return hradvisor; - } - - /** - * Get the HR advisees of this HR advisor. - * - * @return An unmodifiable Set containing the JPAAppEmployees that are - * HR advisees of this employee. - */ - public Set getHradvisees() { - return Collections.unmodifiableSet(hradvisees); - } - - /** - * Add an JPAAppEmployee as an advisee of this HR advisor. This method also sets the - * emp hradvisor to reference this object. In other words, both sides of the - * relationship are set. - * - * @param emp The employee to add as an advisee. - */ - public void addAdvisee(JPAAppEmployee emp) { - hradvisees.add(emp); - emp.hradvisor = this; - } - - /** - * Remove an JPAAppEmployee as an advisee of this HR advisor. This method also sets - * the emp hradvisor to null. In other words, both sides of the relationship are set. - * - * @param emp The employee to add as an HR advisee. - */ - public void removeAdvisee(JPAAppEmployee emp) { - hradvisees.remove(emp); - emp.hradvisor = null; - } - - /** - * Set the HR advisees of this HR advisor. - * - * @param hradvisees The JPAAppEmployees that are HR advisees of this employee. - */ - public void setHradvisees(Set hradvisees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.hradvisees = (hradvisees != null) ? new HashSet(hradvisees) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - reviewedProjects = new HashSet(); - projects = new HashSet(); - team = new HashSet(); - hradvisees = new HashSet(); - } - - /** - * Return a String representation of a JPAAppEmployee object. - * - * @return a String representation of a JPAAppEmployee object. - */ - public String toString() { - return "JPAAPPEmployee(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", hired ").append(hiredate == null ? "null" : formatter.format(hiredate)); - rc.append(", weeklyhours ").append(weeklyhours); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the - * corresponding fields of the specified JPAAppEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - JPAAppEmployee otherEmp = (JPAAppEmployee) other; - String where = "Employee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.equals(hiredate, otherEmp.getHiredate(), where + ".hiredate") - & helper.closeEnough(weeklyhours, otherEmp.getWeeklyhours(), where + ".weeklyhours") - & helper.deepEquals( - dentalInsurance, otherEmp.getDentalInsurance(), where + ".dentalInsurance") - & helper.deepEquals( - medicalInsurance, otherEmp.getMedicalInsurance(), where + ".medicalInsurance") - & helper.deepEquals(department, otherEmp.getDepartment(), where + ".department") - & helper.deepEquals(fundingDept, otherEmp.getFundingDept(), where + ".fundingDept") - & helper.deepEquals(manager, otherEmp.getManager(), where + ".manager") - & helper.deepEquals(mentor, otherEmp.getMentor(), where + ".mentor") - & helper.deepEquals(protege, otherEmp.getProtege(), where + ".protege") - & helper.deepEquals(hradvisor, otherEmp.getHradvisor(), where + ".hradvisor") - & helper.deepEquals( - reviewedProjects, otherEmp.getReviewedProjects(), where + ".reviewedProjects") - & helper.deepEquals(projects, otherEmp.getProjects(), where + ".projects") - & helper.deepEquals(team, otherEmp.getTeam(), where + ".team") - & helper.deepEquals(hradvisees, otherEmp.getHradvisees(), where + ".hradvisees"); - } + @Column(name="HIREDATE") + @Temporal(TemporalType.TIMESTAMP) + private Date hiredate; + @Column(name="WEEKLYHOURS") + private double weeklyhours; + @OneToOne(mappedBy="employee") + private JPAAppDentalInsurance dentalInsurance; + @OneToOne(mappedBy="employee") + private JPAAppMedicalInsurance medicalInsurance; + @Column(name="DEPARTMENT") + private JPAAppDepartment department; + @Column(name="FUNDINGDEPT") + private JPAAppDepartment fundingDept; + @Column(name="MANAGER") + private JPAAppEmployee manager; + @Column(name="MENTOR") + private JPAAppEmployee mentor; + @OneToOne(mappedBy="mentor") + private JPAAppEmployee protege; + @Column(name="HRADVISOR") + private JPAAppEmployee hradvisor; + @ManyToMany(mappedBy="reviewers", + targetEntity=org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppProject.class) + private Set reviewedProjects = new HashSet(); + @ManyToMany(mappedBy="members", + targetEntity=org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppProject.class) + private Set projects = new HashSet(); + @OneToMany(mappedBy="manager", + targetEntity=org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppEmployee.class) + private Set team = new HashSet(); + @OneToMany(mappedBy="hradvisor", + targetEntity=org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppEmployee.class) + private Set hradvisees = new HashSet(); + + /** This is the JDO-required no-args constructor */ + protected JPAAppEmployee() {} + + /** + * Construct an JPAAppEmployee instance. + * + * + * @param personid The identifier for the person. + * @param firstname The first name of the employee. + * @param lastname The last name of the employee. + * @param middlename The middle name of the employee. + * @param birthdate The birth date of the employee. + * @param hiredate The date that the employee was hired. + */ + public JPAAppEmployee(long personid, String firstname, String lastname, + String middlename, Date birthdate, + Date hiredate) { + super(personid, firstname, lastname, middlename, birthdate); + this.hiredate = hiredate; + } + + /** + * Construct an JPAAppEmployee instance. + * + * + * @param personid The identifier for the person. + * @param firstname The first name of the employee. + * @param lastname The last name of the employee. + * @param middlename The middle name of the employee. + * @param birthdate The birth date of the employee. + * @param address The address of the employee. + * @param hiredate The date that the employee was hired. + */ + public JPAAppEmployee(long personid, String firstname, String lastname, + String middlename, Date birthdate, IAddress address, + Date hiredate) { + super(personid, firstname, lastname, middlename, birthdate, + (JPAAppAddress)address); + this.hiredate = hiredate; + } + + /** + * Get the date that the employee was hired. + * @return The date the employee was hired. + */ + public Date getHiredate() { + return hiredate; + } + + /** + * Set the date that the employee was hired. + * @param hiredate The date the employee was hired. + */ + public void setHiredate(Date hiredate) { + this.hiredate = hiredate; + } + + /** + * Get the weekly hours of the employee. + * @return The number of hours per week that the employee works. + */ + public double getWeeklyhours() { + return weeklyhours; + } + + /** + * Set the number of hours per week that the employee works. + * @param weeklyhours The number of hours per week that the employee + * works. + */ + public void setWeeklyhours(double weeklyhours) { + this.weeklyhours = weeklyhours; + } + + /** + * Get the reviewed projects. + * @return The reviewed projects as an unmodifiable set. + */ + public Set getReviewedProjects() { + return Collections.unmodifiableSet(reviewedProjects); + } + + /** + * Add a reviewed project. + * @param project A reviewed project. + */ + public void addReviewedProjects(JPAAppProject project) { + reviewedProjects.add(project); + } + + /** + * Remove a reviewed project. + * @param project A reviewed project. + */ + public void removeReviewedProject(JPAAppProject project) { + reviewedProjects.remove(project); + } + + /** + * Set the reviewed projects for the employee. + * @param reviewedProjects The set of reviewed projects. + */ + public void setReviewedProjects(Set reviewedProjects) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.reviewedProjects = + (reviewedProjects != null) ? new HashSet(reviewedProjects) : null; + } + + /** + * Get the employee's projects. + * @return The employee's projects are returned as an unmodifiable + * set. + */ + public Set getProjects() { + return Collections.unmodifiableSet(projects); + } + + /** + * Add a project for the employee. + * @param project The project. + */ + public void addProject(JPAAppProject project) { + projects.add(project); + } + + /** + * Remove a project from an employee's set of projects. + * @param project The project. + */ + public void removeProject(JPAAppProject project) { + projects.remove(project); + } + + /** + * Set the projects for the employee. + * @param projects The set of projects of the employee. + */ + public void setProjects(Set projects) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.projects = (projects != null) ? new HashSet(projects) : null; + } + + /** + * Get the dental insurance of the employee. + * @return The employee's dental insurance. + */ + public IDentalInsurance getDentalInsurance() { + return dentalInsurance; + } + + /** + * Set the dental insurance object for the employee. + * @param dentalInsurance The dental insurance object to associate with + * the employee. + */ + public void setDentalInsurance(IDentalInsurance dentalInsurance) { + this.dentalInsurance = (JPAAppDentalInsurance)dentalInsurance; + } + /** + * Get the medical insurance of the employee. + * @return The employee's medical insurance. + */ + public IMedicalInsurance getMedicalInsurance() { + return medicalInsurance; + } + + /** + * Set the medical insurance object for the employee. + * @param medicalInsurance The medical insurance object to associate + * with the employee. + */ + public void setMedicalInsurance(IMedicalInsurance medicalInsurance) { + this.medicalInsurance = (JPAAppMedicalInsurance)medicalInsurance; + } + + /** + * Get the employee's department. + * @return The department associated with the employee. + */ + public IDepartment getDepartment() { + return department; + } + + /** + * Set the employee's department. + * @param department The department. + */ + public void setDepartment(IDepartment department) { + this.department = (JPAAppDepartment)department; + } + + /** + * Get the employee's funding department. + * @return The funding department associated with the employee. + */ + public IDepartment getFundingDept() { + return fundingDept; + } + + /** + * Set the employee's funding department. + * @param department The funding department. + */ + public void setFundingDept(IDepartment department) { + this.fundingDept = (JPAAppDepartment)department; + } + + /** + * Get the employee's manager. + * @return The employee's manager. + */ + public IEmployee getManager() { + return manager; + } + + /** + * Set the employee's manager. + * @param manager The employee's manager. + */ + public void setManager(IEmployee manager) { + this.manager = (JPAAppEmployee)manager; + } + + /** + * Get the employee's team. + * + * + * @return The set of JPAAppEmployees on this employee's team, + * returned as an unmodifiable set. + */ + public Set getTeam() { + return Collections.unmodifiableSet(team); + } + + /** + * Add an JPAAppEmployee to this employee's team. + * This method sets both sides of the relationship, modifying + * this employees team to include parameter emp and modifying + * emp to set its manager attribute to this object. + * + * + * @param emp The JPAAppEmployee to add to the team. + */ + public void addToTeam(JPAAppEmployee emp) { + team.add(emp); + emp.manager = this; + } + + /** + * Remove an JPAAppEmployee from this employee's team. + * This method will also set the emp manager to null. + * + * + * @param emp The JPAAppEmployee to remove from the team. + */ + public void removeFromTeam(JPAAppEmployee emp) { + team.remove(emp); + emp.manager = null; + } + + /** + * Set the employee's team. + * + * + * @param team The set of JPAAppEmployees. + */ + public void setTeam(Set team) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.team = (team != null) ? new HashSet(team) : null; + } + + /** + * Set the mentor for this employee. + * @param mentor The mentor for this employee. + */ + public void setMentor(IEmployee mentor) { + this.mentor = (JPAAppEmployee)mentor; + } + + /** + * Get the mentor for this employee. + * @return The mentor. + */ + public IEmployee getMentor() { + return mentor; + } + + /** + * Set the protege for this employee. + * @param protege The protege for this employee. + */ + public void setProtege(IEmployee protege) { + this.protege = (JPAAppEmployee)protege; + } + + /** + * Get the protege of this employee. + * @return The protege of this employee. + */ + public IEmployee getProtege() { + return protege; + } + + /** + * Set the HR advisor for this employee. + * @param hradvisor The hradvisor for this employee. + */ + public void setHradvisor(IEmployee hradvisor) { + this.hradvisor = (JPAAppEmployee)hradvisor; + } + + /** + * Get the HR advisor for the employee. + * @return The HR advisor. + */ + public IEmployee getHradvisor() { + return hradvisor; + } + + /** + * Get the HR advisees of this HR advisor. + * + * + * @return An unmodifiable Set containing the + * JPAAppEmployees that are HR advisees of this employee. + */ + public Set getHradvisees() { + return Collections.unmodifiableSet(hradvisees); + } + + /** + * Add an JPAAppEmployee as an advisee of this HR advisor. + * This method also sets the emp hradvisor to reference + * this object. In other words, both sides of the relationship are + * set. + * + * + * @param emp The employee to add as an advisee. + */ + public void addAdvisee(JPAAppEmployee emp) { + hradvisees.add(emp); + emp.hradvisor = this; + } + + /** + * Remove an JPAAppEmployee as an advisee of this HR advisor. + * This method also sets the emp hradvisor to null. + * In other words, both sides of the relationship are set. + * + * + * @param emp The employee to add as an HR advisee. + */ + public void removeAdvisee(JPAAppEmployee emp) { + hradvisees.remove(emp); + emp.hradvisor = null; + } + + /** + * Set the HR advisees of this HR advisor. + * + * + * @param hradvisees The JPAAppEmployees that are HR advisees of + * this employee. + */ + public void setHradvisees(Set hradvisees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.hradvisees = (hradvisees != null) ? new HashSet(hradvisees) : null; + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + reviewedProjects = new HashSet(); + projects = new HashSet(); + team = new HashSet(); + hradvisees = new HashSet(); + } + + /** + * Return a String representation of a JPAAppEmployee object. + * + * + * @return a String representation of a JPAAppEmployee object. + */ + public String toString() { + return "JPAAPPEmployee(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", hired ").append( + hiredate==null ? "null" : formatter.format(hiredate)); + rc.append(", weeklyhours ").append(weeklyhours); + return rc.toString(); + } + + /** + * + * Returns true if all the fields of this instance are + * deep equal to the corresponding fields of the specified JPAAppEmployee. + * + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + JPAAppEmployee otherEmp = (JPAAppEmployee)other; + String where = "Employee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.equals(hiredate, otherEmp.getHiredate(), where + ".hiredate") & + helper.closeEnough(weeklyhours, otherEmp.getWeeklyhours(), where + ".weeklyhours") & + helper.deepEquals(dentalInsurance, otherEmp.getDentalInsurance(), where + ".dentalInsurance") & + helper.deepEquals(medicalInsurance, otherEmp.getMedicalInsurance(), where + ".medicalInsurance") & + helper.deepEquals(department, otherEmp.getDepartment(), where + ".department") & + helper.deepEquals(fundingDept, otherEmp.getFundingDept(), where + ".fundingDept") & + helper.deepEquals(manager, otherEmp.getManager(), where + ".manager") & + helper.deepEquals(mentor, otherEmp.getMentor(), where + ".mentor") & + helper.deepEquals(protege, otherEmp.getProtege(), where + ".protege") & + helper.deepEquals(hradvisor, otherEmp.getHradvisor(), where + ".hradvisor") & + helper.deepEquals(reviewedProjects, otherEmp.getReviewedProjects(), where + ".reviewedProjects") & + helper.deepEquals(projects, otherEmp.getProjects(), where + ".projects") & + helper.deepEquals(team, otherEmp.getTeam(), where + ".team") & + helper.deepEquals(hradvisees, otherEmp.getHradvisees(), where + ".hradvisees"); + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppFullTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppFullTimeEmployee.java index 099084020..17ec2df1c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppFullTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppFullTimeEmployee.java @@ -5,133 +5,134 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedJPA; +import javax.persistence.*; + import java.util.Date; -import javax.persistence.Column; -import javax.persistence.Entity; import org.apache.jdo.tck.pc.company.IAddress; + import org.apache.jdo.tck.pc.company.IFullTimeEmployee; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a full-time employee. */ +/** + * This class represents a full-time employee. + */ @Entity -public class JPAAppFullTimeEmployee extends JPAAppEmployee implements IFullTimeEmployee { - - @Column(name = "SALARY") - private double salary; - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public JPAAppFullTimeEmployee() {} +public class JPAAppFullTimeEmployee extends JPAAppEmployee + implements IFullTimeEmployee { - /** - * Construct a full-time employee. - * - * @param personid The person identifier. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param hired The date that the person was hired. - * @param sal The salary of the full-time employee. - */ - public JPAAppFullTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double sal) { - super(personid, first, last, middle, born, hired); - salary = sal; - } + @Column(name="SALARY") + private double salary; - /** - * Construct a full-time employee. - * - * @param personid The person identifier. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param addr The person's address. - * @param hired The date that the person was hired. - * @param sal The salary of the full-time employee. - */ - public JPAAppFullTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - IAddress addr, - Date hired, - double sal) { - super(personid, first, last, middle, born, (JPAAppAddress) addr, hired); - salary = sal; - } + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public JPAAppFullTimeEmployee() {} - /** - * Get the salary of the full time employee. - * - * @return The salary of the full time employee. - */ - public double getSalary() { - return salary; - } + /** + * Construct a full-time employee. + * @param personid The person identifier. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param hired The date that the person was hired. + * @param sal The salary of the full-time employee. + */ + public JPAAppFullTimeEmployee(long personid, String first, String last, + String middle, Date born, + Date hired, double sal) { + super(personid, first, last, middle, born, hired); + salary = sal; + } - /** - * Set the salary for the full-time employee. - * - * @param salary The salary to set for the full-time employee. - */ - public void setSalary(double salary) { - this.salary = salary; - } + /** + * Construct a full-time employee. + * @param personid The person identifier. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param addr The person's address. + * @param hired The date that the person was hired. + * @param sal The salary of the full-time employee. + */ + public JPAAppFullTimeEmployee(long personid, String first, String last, + String middle, Date born, IAddress addr, + Date hired, double sal) { + super(personid, first, last, middle, born, (JPAAppAddress)addr, hired); + salary = sal; + } - /** - * Return a String representation of a JPAAppFullTimeEmployee object. - * - * @return a String representation of a JPAAppFullTimeEmployee object. - */ - public String toString() { - return "JPAAppFullTimeEmployee(" + getFieldRepr() + ")"; - } + /** + * Get the salary of the full time employee. + * @return The salary of the full time employee. + */ + public double getSalary() { + return salary; + } + + /** + * Set the salary for the full-time employee. + * @param salary The salary to set for the full-time employee. + */ + public void setSalary(double salary) { + this.salary = salary; + } + + /** + * Return a String representation of a JPAAppFullTimeEmployee object. + * + * + * @return a String representation of a JPAAppFullTimeEmployee object. + */ + public String toString() { + return "JPAAppFullTimeEmployee(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - public String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", $").append(salary); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + public String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", $").append(salary); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified JPAAppFullTimeEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - JPAAppFullTimeEmployee otherEmp = (JPAAppFullTimeEmployee) other; - String where = "JPAAppFullTimeEmployee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.closeEnough(salary, otherEmp.getSalary(), where + ".salary"); - } + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified + * JPAAppFullTimeEmployee. + * + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + JPAAppFullTimeEmployee otherEmp = (JPAAppFullTimeEmployee)other; + String where = "JPAAppFullTimeEmployee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.closeEnough(salary, otherEmp.getSalary(), where + ".salary"); + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppInsurance.java index 0940abae5..421a1d699 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppInsurance.java @@ -5,298 +5,298 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedJPA; +import javax.persistence.*; + import java.io.Serializable; + import java.util.Comparator; -import javax.persistence.Column; -import javax.persistence.DiscriminatorColumn; -import javax.persistence.DiscriminatorType; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.Table; import org.apache.jdo.tck.pc.company.IEmployee; + import org.apache.jdo.tck.pc.company.IInsurance; import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; /** - * This class represents an insurance carrier selection for a particular JPAAppEmployee - * . + * This class represents an insurance carrier selection for a particular + * JPAAppEmployee. */ @Entity -@Table(name = "insuranceplans") -@Inheritance(strategy = InheritanceType.SINGLE_TABLE) -@DiscriminatorColumn(discriminatorType = DiscriminatorType.STRING, name = "DISCRIMINATOR") -public class JPAAppInsurance - implements IInsurance, Serializable, Comparable, Comparator, DeepEquality { - - @Id - @Column(name = "INSID") - private long insid; - - @Column(name = "CARRIER") - private String carrier; - - @Column(name = "EMPLOYEE") - private JPAAppEmployee employee; - - /** This is the JDO-required no-args constructor. */ - protected JPAAppInsurance() {} - - /** - * Construct an JPAAppInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - */ - protected JPAAppInsurance(long insid, String carrier) { - this.insid = insid; - this.carrier = carrier; - } - - /** - * Construct an JPAAppInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param employee The employee associated with this insurance. - */ - protected JPAAppInsurance(long insid, String carrier, IEmployee employee) { - this.insid = insid; - this.carrier = carrier; - this.employee = (JPAAppEmployee) employee; - } - - /** - * Get the insurance ID. - * - * @return the insurance ID. - */ - public long getInsid() { - return insid; - } - - /** - * Set the insurance ID. - * - * @param id The insurance ID value. - */ - public void setInsid(long id) { - if (this.insid != 0) throw new IllegalStateException("Id is already set."); - this.insid = id; - } - - /** - * Get the insurance carrier. - * - * @return The insurance carrier. - */ - public String getCarrier() { - return carrier; - } - - /** - * Set the insurance carrier. - * - * @param carrier The insurance carrier. - */ - public void setCarrier(String carrier) { - this.carrier = carrier; - } - - /** - * Get the associated employee. - * - * @return The employee for this insurance. - */ - public IEmployee getEmployee() { - return employee; - } - - /** - * Set the associated employee. - * - * @param employee The associated employee. - */ - public void setEmployee(IEmployee employee) { - this.employee = (JPAAppEmployee) employee; - } +@Table(name="insuranceplans") +@Inheritance(strategy=InheritanceType.SINGLE_TABLE) +@DiscriminatorColumn(discriminatorType=DiscriminatorType.STRING, + name="DISCRIMINATOR") +public class JPAAppInsurance + implements IInsurance, Serializable, Comparable, Comparator, DeepEquality { + + @Id + @Column(name="INSID") + private long insid; + @Column(name="CARRIER") + private String carrier; + @Column(name="EMPLOYEE") + private JPAAppEmployee employee; + + /** This is the JDO-required no-args constructor. */ + protected JPAAppInsurance() {} - /** - * Returns a String representation of a JPAAppInsurance object. - * - * @return a String representation of a JPAAppInsurance object. - */ - public String toString() { - return "JPAAppInsurance(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(insid); - rc.append(", carrier ").append(carrier); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Object. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - JPAAppInsurance otherIns = (JPAAppInsurance) other; - String where = "JPAAppInsurance<" + insid + ">"; - return helper.equals(insid, otherIns.getInsid(), where + ".insid") - & helper.equals(carrier, otherIns.getCarrier(), where + ".carrier") - & helper.deepEquals(employee, otherIns.getEmployee(), where + ".employee"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((JPAAppInsurance) o); - } + /** + * Construct an JPAAppInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + */ + protected JPAAppInsurance(long insid, String carrier) { + this.insid = insid; + this.carrier = carrier; + } - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((JPAAppInsurance) o1, (JPAAppInsurance) o2); - } + /** + * Construct an JPAAppInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + */ + protected JPAAppInsurance(long insid, String carrier, IEmployee employee) { + this.insid = insid; + this.carrier = carrier; + this.employee = (JPAAppEmployee)employee; + } - /** - * Compares this object with the specified Insurance object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Insurance object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Insurance object. - */ - public int compareTo(JPAAppInsurance other) { - return compare(this, other); - } + /** + * Get the insurance ID. + * @return the insurance ID. + */ + public long getInsid() { + return insid; + } - /** - * Compares its two IInsurance arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IInsurance object to be compared. - * @param o2 the second IInsurance object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(JPAAppInsurance o1, JPAAppInsurance o2) { - return EqualityHelper.compare(o1.getInsid(), o2.getInsid()); - } + /** + * Set the insurance ID. + * @param id The insurance ID value. + */ + public void setInsid(long id) { + if (this.insid != 0) + throw new IllegalStateException("Id is already set."); + this.insid = id; + } - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof JPAAppInsurance) { - return compareTo((JPAAppInsurance) obj) == 0; + /** + * Get the insurance carrier. + * @return The insurance carrier. + */ + public String getCarrier() { + return carrier; } - return false; - } - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) insid; - } + /** + * Set the insurance carrier. + * @param carrier The insurance carrier. + */ + public void setCarrier(String carrier) { + this.carrier = carrier; + } + + /** + * Get the associated employee. + * @return The employee for this insurance. + */ + public IEmployee getEmployee() { + return employee; + } - /** - * This class is used to represent the application identifier for the Insurance - * class. - */ - public static class Oid implements Serializable, Comparable { /** - * This field represents the application identifier for the Insurance class. It - * must match the field in the Insurance class in both name and type. + * Set the associated employee. + * @param employee The associated employee. */ - public long insid; + public void setEmployee(IEmployee employee) { + this.employee = (JPAAppEmployee)employee; + } - /** The required public no-args constructor. */ - public Oid() {} + /** + * Returns a String representation of a JPAAppInsurance object. + * + * + * @return a String representation of a JPAAppInsurance object. + */ + public String toString() { + return "JPAAppInsurance(" + getFieldRepr() + ")"; + } /** - * Initialize with an insurance identifier. - * - * @param insid the insurance ID. + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. */ - public Oid(long insid) { - this.insid = insid; + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(insid); + rc.append(", carrier ").append(carrier); + return rc.toString(); } - public Oid(String s) { - insid = Long.parseLong(justTheId(s)); + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + JPAAppInsurance otherIns = (JPAAppInsurance)other; + String where = "JPAAppInsurance<" + insid + ">"; + return + helper.equals(insid, otherIns.getInsid(), where + ".insid") & + helper.equals(carrier, otherIns.getCarrier(), where + ".carrier") & + helper.deepEquals(employee, otherIns.getEmployee(), where + ".employee"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((JPAAppInsurance)o); } - public String toString() { - return this.getClass().getName() + ": " + insid; + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((JPAAppInsurance)o1, (JPAAppInsurance)o2); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.insid != o.insid) return (false); - return (true); + /** + * Compares this object with the specified Insurance object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Insurance object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified + * Insurance object. + */ + public int compareTo(JPAAppInsurance other) { + return compare(this, other); } - /** */ + /** + * Compares its two IInsurance arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IInsurance object to be compared. + * @param o2 the second IInsurance object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(JPAAppInsurance o1, JPAAppInsurance o2) { + return EqualityHelper.compare(o1.getInsid(), o2.getInsid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof JPAAppInsurance) { + return compareTo((JPAAppInsurance)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ public int hashCode() { - return ((int) insid); + return (int)insid; } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } + /** + * This class is used to represent the application + * identifier for the Insurance class. + */ + public static class Oid implements Serializable, Comparable + { + /** + * This field represents the application identifier for the + * Insurance class. It must match the field in the + * Insurance class in both name and type. + */ + public long insid; + + /** + * The required public no-args constructor. + */ + public Oid() { } + + /** + * Initialize with an insurance identifier. + * @param insid the insurance ID. + */ + public Oid(long insid) { + this.insid = insid; + } + + public Oid(String s) { insid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + insid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o=(Oid) obj; + if( this.insid!=o.insid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) insid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( insid < other.insid ) return -1; + if( insid > other.insid ) return 1; + return 0; + } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (insid < other.insid) return -1; - if (insid > other.insid) return 1; - return 0; } - } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppMedicalInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppMedicalInsurance.java index a45792d45..e006c326a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppMedicalInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppMedicalInsurance.java @@ -5,118 +5,126 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedJPA; -import javax.persistence.Column; -import javax.persistence.Entity; +import javax.persistence.*; + import org.apache.jdo.tck.pc.company.IEmployee; import org.apache.jdo.tck.pc.company.IMedicalInsurance; import org.apache.jdo.tck.util.EqualityHelper; /** - * This class represents a dental insurance carrier selection for a particular Employee - * . + * This class represents a dental insurance carrier selection for a + * particular Employee. */ @Entity public class JPAAppMedicalInsurance extends JPAAppInsurance implements IMedicalInsurance { - @Column(name = "PLANTYPE") - private String planType; // possible values: "PPO", "EPO", "NPO" + @Column(name="PLANTYPE") + private String planType; // possible values: "PPO", "EPO", "NPO" - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public JPAAppMedicalInsurance() {} + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public JPAAppMedicalInsurance() {} - /** - * Construct a JPAAppMedicalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param planType The planType. - */ - public JPAAppMedicalInsurance(long insid, String carrier, String planType) { - super(insid, carrier); - this.planType = planType; - } + /** + * Construct a JPAAppMedicalInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param planType The planType. + */ + public JPAAppMedicalInsurance(long insid, String carrier, + String planType) + { + super(insid, carrier); + this.planType = planType; + } - /** - * Construct a JPAAppMedicalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param employee The employee associated with this insurance. - * @param planType The planType. - */ - public JPAAppMedicalInsurance(long insid, String carrier, IEmployee employee, String planType) { - super(insid, carrier, (JPAAppEmployee) employee); - this.planType = planType; - } + /** + * Construct a JPAAppMedicalInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + * @param planType The planType. + */ + public JPAAppMedicalInsurance(long insid, String carrier, + IEmployee employee, String planType) + { + super(insid, carrier, (JPAAppEmployee)employee); + this.planType = planType; + } - /** - * Get the insurance planType. - * - * @return The insurance planType. - */ - public String getPlanType() { - return planType; - } + /** + * Get the insurance planType. + * @return The insurance planType. + */ + public String getPlanType() { + return planType; + } - /** - * Set the insurance planType. - * - * @param planType The insurance planType. - */ - public void setPlanType(String planType) { - this.planType = planType; - } + /** + * Set the insurance planType. + * @param planType The insurance planType. + */ + public void setPlanType(String planType) { + this.planType = planType; + } - /** - * Returns a String representation of a JPAAppMedicalInsurance object. - * - * @return a String representation of a JPAAppMedicalInsurance object. - */ - public String toString() { - return "JPAMedicalInsurance(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of a JPAAppMedicalInsurance + * object. + * + * + * @return a String representation of a JPAAppMedicalInsurance + * object. + */ + public String toString() { + return "JPAMedicalInsurance(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", planType ").append(planType); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", planType ").append(planType); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Object. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - JPAAppMedicalInsurance otherIns = (JPAAppMedicalInsurance) other; - String where = "JPAAppMedicalInsurance<" + getInsid() + ">"; - return super.deepCompareFields(otherIns, helper) - & helper.equals(planType, otherIns.getPlanType(), where + ".planType"); - } + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + JPAAppMedicalInsurance otherIns = (JPAAppMedicalInsurance)other; + String where = "JPAAppMedicalInsurance<" + getInsid() + ">"; + return super.deepCompareFields(otherIns, helper) & + helper.equals(planType, otherIns.getPlanType(), where + ".planType"); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppPartTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppPartTimeEmployee.java index b051a0f03..366dbab7d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppPartTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppPartTimeEmployee.java @@ -5,132 +5,133 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedJPA; +import javax.persistence.*; + import java.util.Date; -import javax.persistence.Column; -import javax.persistence.Entity; + import org.apache.jdo.tck.pc.company.IPartTimeEmployee; +import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a part-time employee. */ +/** + * This class represents a part-time employee. + */ @Entity -public class JPAAppPartTimeEmployee extends JPAAppEmployee implements IPartTimeEmployee { +public class JPAAppPartTimeEmployee extends JPAAppEmployee + implements IPartTimeEmployee { - @Column(name = "WAGE") - private double wage; + @Column(name="WAGE") + private double wage; - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public JPAAppPartTimeEmployee() {} + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public JPAAppPartTimeEmployee() {} - /** - * Construct a part-time employee. - * - * @param personid The identifier for the person. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param hired The date the person was hired. - * @param wage The person's wage. - */ - public JPAAppPartTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double wage) { - super(personid, first, last, middle, born, hired); - this.wage = wage; - } + /** + * Construct a part-time employee. + * @param personid The identifier for the person. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param hired The date the person was hired. + * @param wage The person's wage. + */ + public JPAAppPartTimeEmployee(long personid, String first, String last, + String middle, Date born, + Date hired, double wage ) { + super(personid, first, last, middle, born, hired); + this.wage = wage; + } - /** - * Construct a part-time employee. - * - * @param personid The identifier for the person. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param addr The person's address. - * @param hired The date the person was hired. - * @param wage The person's wage. - */ - public JPAAppPartTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - JPAAppAddress addr, - Date hired, - double wage) { - super(personid, first, last, middle, born, addr, hired); - this.wage = wage; - } + /** + * Construct a part-time employee. + * @param personid The identifier for the person. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param addr The person's address. + * @param hired The date the person was hired. + * @param wage The person's wage. + */ + public JPAAppPartTimeEmployee(long personid, String first, String last, + String middle, Date born, JPAAppAddress addr, + Date hired, double wage ) { + super(personid, first, last, middle, born, addr, hired); + this.wage = wage; + } - /** - * Get the wage of the part-time employee. - * - * @return The wage of the part-time employee. - */ - public double getWage() { - return wage; - } + /** + * Get the wage of the part-time employee. + * @return The wage of the part-time employee. + */ + public double getWage() { + return wage; + } - /** - * Set the wage of the part-time employee. - * - * @param wage The wage of the part-time employee. - */ - public void setWage(double wage) { - this.wage = wage; - } + /** + * Set the wage of the part-time employee. + * @param wage The wage of the part-time employee. + */ + public void setWage(double wage) { + this.wage = wage; + } - /** - * Returns a String representation of a JPAAppPartTimeEmployee object. - * - * @return a String representation of a JPAAppPartTimeEmployee object. - */ - public String toString() { - return "JPAPartTimeEmployee(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of a JPAAppPartTimeEmployee object. + * + * + * @return a String representation of a JPAAppPartTimeEmployee object. + */ + public String toString() { + return "JPAPartTimeEmployee(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - public String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", $" + wage); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + public String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", $" + wage); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified JPAAppPartTimeEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - JPAAppPartTimeEmployee otherEmp = (JPAAppPartTimeEmployee) other; - String where = "JPAPartTimeEmployee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.closeEnough(wage, otherEmp.getWage(), where + ".wage"); - } + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified + * JPAAppPartTimeEmployee. + * + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + JPAAppPartTimeEmployee otherEmp = (JPAAppPartTimeEmployee)other; + String where = "JPAPartTimeEmployee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.closeEnough(wage, otherEmp.getWage(), where + ".wage"); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppPerson.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppPerson.java index 3b428a08b..607d8f736 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppPerson.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppPerson.java @@ -5,513 +5,499 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedJPA; +import javax.persistence.*; + import java.io.Serializable; + import java.text.SimpleDateFormat; import java.util.Comparator; import java.util.Date; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; -import javax.persistence.AttributeOverride; -import javax.persistence.AttributeOverrides; -import javax.persistence.Basic; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.DiscriminatorColumn; -import javax.persistence.DiscriminatorType; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.MapKey; -import javax.persistence.OneToMany; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; +import java.util.Set; import org.apache.jdo.tck.pc.company.IAddress; + import org.apache.jdo.tck.pc.company.IPerson; import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a person. */ +/** + * This class represents a person. + */ @Entity -@Table(name = "persons") +@Table(name="persons") @IdClass(org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppPerson.Oid.class) -@Inheritance(strategy = InheritanceType.SINGLE_TABLE) -@DiscriminatorColumn(discriminatorType = DiscriminatorType.STRING, name = "DISCRIMINATOR") -public class JPAAppPerson implements IPerson, Serializable, Comparable, Comparator, DeepEquality { - - @Id - @Column(name = "PERSONID") - private long personid; - - @Column(name = "FIRSTNAME") - private String firstname; - - @Column(name = "LASTNAME") - private String lastname; - - @Basic(optional = true, fetch = FetchType.LAZY) - @Column(name = "MIDDLENAME") - private String middlename; - - @Column(name = "BIRTHDATE") - @Temporal(TemporalType.TIMESTAMP) - private Date birthdate; - - @Embedded - @AttributeOverrides({ - @AttributeOverride(name = "street", column = @Column(name = "STREET")), - @AttributeOverride(name = "city", column = @Column(name = "CITY")), - @AttributeOverride(name = "state", column = @Column(name = "STATE")), - @AttributeOverride(name = "zipcode", column = @Column(name = "ZIPCODE")), - @AttributeOverride(name = "country", column = @Column(name = "COUNTRY")) - }) - private JPAAppAddress address; - - @OneToMany(mappedBy = "person", cascade = CascadeType.ALL) - @MapKey(name = "type") - private Map phoneNumbers = new HashMap(); - - protected static SimpleDateFormat formatter = new SimpleDateFormat("d/MMM/yyyy"); - - /** This is the JDO-required no-args constructor. */ - protected JPAAppPerson() {} - - /** - * Construct a JPAAppPerson instance. - * - * @param personid The person identifier. - * @param firstname The person's first name. - * @param lastname The person's last name. - * @param middlename The person's middle name. - * @param birthdate The person's birthdate. - */ - public JPAAppPerson( - long personid, String firstname, String lastname, String middlename, Date birthdate) { - this.personid = personid; - this.firstname = firstname; - this.lastname = lastname; - this.middlename = middlename; - this.birthdate = birthdate; - } - - /** - * Construct a JPAAppPerson instance. - * - * @param personid The person identifier. - * @param firstname The person's first name. - * @param lastname The person's last name. - * @param middlename The person's middle name. - * @param birthdate The person's birthdate. - * @param address The person's address. - */ - public JPAAppPerson( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - IAddress address) { - this(personid, firstname, lastname, middlename, birthdate); - this.address = (JPAAppAddress) address; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setPersonid(long id) { - if (this.personid != 0) throw new IllegalStateException("Id is already set."); - this.personid = id; - } - - /** - * Get the person's id. - * - * @return The personid. - */ - public long getPersonid() { - return personid; - } - - /** - * Get the person's last name. - * - * @return The last name. - */ - public String getLastname() { - return lastname; - } - - /** - * Set the person's last name. - * - * @param lastname The last name. - */ - public void setLastname(String lastname) { - this.lastname = lastname; - } - - /** - * Get the person's first name. - * - * @return The first name. - */ - public String getFirstname() { - return firstname; - } - - /** - * Set the person's first name. - * - * @param firstname The first name. - */ - public void setFirstname(String firstname) { - this.firstname = firstname; - } - - /** - * Get the person's middle name. - * - * @return The middle name. - */ - public String getMiddlename() { - return middlename; - } - - /** - * Set the person's middle name. - * - * @param middlename The middle name. - */ - public void setMiddlename(String middlename) { - this.middlename = middlename; - } - - /** - * Get the address. - * - * @return The address. - */ - public IAddress getAddress() { - return address; - } - - /** - * Set the address. - * - * @param address The address. - */ - public void setAddress(IAddress address) { - this.address = (JPAAppAddress) address; - } - - /** - * Get the person's birthdate. - * - * @return The person's birthdate. - */ - public Date getBirthdate() { - return birthdate; - } - - /** - * Set the person's birthdate. - * - * @param birthdate The person's birthdate. - */ - public void setBirthdate(Date birthdate) { - this.birthdate = birthdate; - } - - /** - * Get the map of phone numbers as an unmodifiable map. - * - * @return A Map of phone numbers. - */ - public Map getPhoneNumbers() { - return (convertPhone2String(phoneNumbers)); - } - - /** - * Get the phone number for the specified phone number type. - * - * @param type The phone number type ("home", "work", "mobile", etc.). - * @return The phone number associated with specified type, or null if there was no - * phone number for the type. - */ - public String getPhoneNumber(String type) { - JPAAppPhoneNumber pnum = phoneNumbers.get(type); - return pnum.getPhoneNumber(); - } - - /** - * Associates the specified phone number with the specified type in the map of phone numbers of - * this person. - * - * @param type The phone number type ("home", "work", "mobile", etc.). - * @param phoneNumber The phone number - * @return The previous phone number associated with specified type, or null if there - * was no phone number for the type. - */ - public String putPhoneNumber(String type, String phoneNumber) { - JPAAppPhoneNumber pnum = phoneNumbers.get(type); - String pnumAsString = null; - if (pnum != null) { - pnumAsString = pnum.getPhoneNumber(); // old val +@Inheritance(strategy=InheritanceType.SINGLE_TABLE) +@DiscriminatorColumn(discriminatorType=DiscriminatorType.STRING, + name="DISCRIMINATOR") +public class JPAAppPerson + implements IPerson, Serializable, Comparable, Comparator, DeepEquality { + + @Id + @Column(name="PERSONID") + private long personid; + @Column(name="FIRSTNAME") + private String firstname; + @Column(name="LASTNAME") + private String lastname; + @Basic(optional=true, fetch=FetchType.LAZY) + @Column(name="MIDDLENAME") + private String middlename; + @Column(name="BIRTHDATE") + @Temporal(TemporalType.TIMESTAMP) + private Date birthdate; + @Embedded + @AttributeOverrides({ + @AttributeOverride(name="street", + column=@Column(name="STREET")), + @AttributeOverride(name="city", + column=@Column(name="CITY")), + @AttributeOverride(name="state", + column=@Column(name="STATE")), + @AttributeOverride(name="zipcode", + column=@Column(name="ZIPCODE")), + @AttributeOverride(name="country", + column=@Column(name="COUNTRY")) + }) + private JPAAppAddress address; + + @OneToMany(mappedBy="person", cascade=CascadeType.ALL) + @MapKey(name="type") + private Map phoneNumbers + = new HashMap(); + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. */ + protected JPAAppPerson() {} + + /** + * Construct a JPAAppPerson instance. + * + * + * @param personid The person identifier. + * @param firstname The person's first name. + * @param lastname The person's last name. + * @param middlename The person's middle name. + * @param birthdate The person's birthdate. + */ + public JPAAppPerson(long personid, String firstname, String lastname, + String middlename, Date birthdate) { + this.personid = personid; + this.firstname = firstname; + this.lastname = lastname; + this.middlename = middlename; + this.birthdate = birthdate; } - pnum = phoneNumbers.put(type, new JPAAppPhoneNumber(this, type, phoneNumber)); - return pnumAsString; - } - - /** - * Remove a phoneNumber from the map of phone numbers. - * - * @param type The phone number type ("home", "work", "mobile", etc.). - * @return The previous phone number associated with specified type, or null if there - * was no phone number for the type. - */ - public String removePhoneNumber(String type) { - JPAAppPhoneNumber pnum = phoneNumbers.get(type); - if (pnum == null) return null; - String pnumAsString = pnum.getPhoneNumber(); // old val - pnum = phoneNumbers.remove(type); - return pnumAsString; - } - - /** - * Set the phoneNumber map to be in this person. - * - * @param phoneNumbers A Map of phoneNumbers for this person. - */ - public void setPhoneNumbers(Map phoneNumbers) { - this.phoneNumbers = (phoneNumbers != null) ? convertString2Phone(phoneNumbers) : null; - } - - /** - * Converts HashMap of String, String to HashMap of String, JPAAppPhoneNmber - * - * @param pnums Map of phoneNumbers - * @return Map of phoneNumbers - */ - protected HashMap convertString2Phone(Map pnums) { - HashMap retval = new HashMap(); - for (Object objEntry : pnums.entrySet()) { - Map.Entry entry = (Map.Entry) objEntry; - String key = (String) entry.getKey(); - String value = (String) entry.getValue(); - JPAAppPhoneNumber newValue = new JPAAppPhoneNumber(this, key, value); - // System.out.println("Key = " + key + " Value = " + value); - retval.put(key, newValue); + + /** + * Construct a JPAAppPerson instance. + * + * + * @param personid The person identifier. + * @param firstname The person's first name. + * @param lastname The person's last name. + * @param middlename The person's middle name. + * @param birthdate The person's birthdate. + * @param address The person's address. + */ + public JPAAppPerson(long personid, String firstname, String lastname, + String middlename, Date birthdate, IAddress address) { + this(personid, firstname, lastname, middlename, birthdate); + this.address = (JPAAppAddress)address; } - return retval; - } - - /** - * Converts HashMap of String, JPAAppPhoneNmber to HashMap of String, String - * - * @param pnums Map of phoneNumbers - * @return Map of phoneNumbers - */ - protected HashMap convertPhone2String(Map pnums) { - HashMap retval = new HashMap(); - for (Object objEntry : pnums.entrySet()) { - Map.Entry entry = (Map.Entry) objEntry; - String key = (String) entry.getKey(); - JPAAppPhoneNumber value = (JPAAppPhoneNumber) entry.getValue(); - String newValue = value.getPhoneNumber(); - retval.put(key, newValue); + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setPersonid(long id) { + if (this.personid != 0) + throw new IllegalStateException("Id is already set."); + this.personid = id; } - return retval; - } - - /** - * Returns a String representation of a JPAAppPerson object. - * - * @return a string representation of a JPAAppPerson object. - */ - public String toString() { - return "JPAPerson(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(personid); - rc.append(", ").append(lastname); - rc.append(", ").append(firstname); - rc.append(", born ").append(birthdate == null ? "null" : formatter.format(birthdate)); - rc.append(", phone ").append(convertPhone2String(phoneNumbers)); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified JPAAppPerson. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - JPAAppPerson otherPerson = (JPAAppPerson) other; - String where = "JPAPerson<" + personid + ">"; - return helper.equals(personid, otherPerson.getPersonid(), where + ".personid") - & helper.equals(firstname, otherPerson.getFirstname(), where + ".firstname") - & helper.equals(lastname, otherPerson.getLastname(), where + ".lastname") - & helper.equals(middlename, otherPerson.getMiddlename(), where + ".middlename") - & helper.equals(birthdate, otherPerson.getBirthdate(), where + ".birthdate") - & helper.deepEquals(address, otherPerson.getAddress(), where + ".address") - & helper.deepEquals( - convertPhone2String(phoneNumbers), - otherPerson.getPhoneNumbers(), - where + ".phoneNumbers"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((JPAAppPerson) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((JPAAppPerson) o1, (JPAAppPerson) o2); - } - - /** - * Compares this object with the specified JPAAppPerson object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The JPAAppPerson object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified JPAAppPerson object. - */ - public int compareTo(JPAAppPerson other) { - return compare(this, other); - } - - /** - * Compares its two IPerson arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IPerson object to be compared. - * @param o2 the second IPerson object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(JPAAppPerson o1, JPAAppPerson o2) { - return EqualityHelper.compare(o1.getPersonid(), o2.getPersonid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof JPAAppPerson) { - return compareTo((JPAAppPerson) obj) == 0; + + /** + * Get the person's id. + * @return The personid. + */ + public long getPersonid() { + return personid; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) personid; - } - /** - * This class is used to represent the application identifier for the Person class. - */ - public static class Oid implements Serializable, Comparable { /** - * This field represents the identifier for the Person class. It must match a field - * in the Person class in both name and type. + * Get the person's last name. + * @return The last name. */ - public long personid; + public String getLastname() { + return lastname; + } - /** The required public no-arg constructor. */ - public Oid() {} + /** + * Set the person's last name. + * @param lastname The last name. + */ + public void setLastname(String lastname) { + this.lastname = lastname; + } /** - * Initialize the identifier. - * - * @param personid The person identifier. + * Get the person's first name. + * @return The first name. */ - public Oid(long personid) { - this.personid = personid; + public String getFirstname() { + return firstname; } - public Oid(String s) { - personid = Long.parseLong(justTheId(s)); + /** + * Set the person's first name. + * @param firstname The first name. + */ + public void setFirstname(String firstname) { + this.firstname = firstname; } + /** + * Get the person's middle name. + * @return The middle name. + */ + public String getMiddlename() { + return middlename; + } + + /** + * Set the person's middle name. + * @param middlename The middle name. + */ + public void setMiddlename(String middlename) { + this.middlename = middlename; + } + + /** + * Get the address. + * @return The address. + */ + public IAddress getAddress() { + return address; + } + + /** + * Set the address. + * @param address The address. + */ + public void setAddress(IAddress address) { + this.address = (JPAAppAddress)address; + } + + /** + * Get the person's birthdate. + * @return The person's birthdate. + */ + public Date getBirthdate() { + return birthdate; + } + + /** + * Set the person's birthdate. + * @param birthdate The person's birthdate. + */ + public void setBirthdate(Date birthdate) { + this. birthdate = birthdate; + } + + /** + * Get the map of phone numbers as an unmodifiable map. + * @return A Map of phone numbers. + */ + public Map getPhoneNumbers() { + return (convertPhone2String(phoneNumbers)); + } + + /** + * Get the phone number for the specified phone number type. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String getPhoneNumber(String type) { + JPAAppPhoneNumber pnum = phoneNumbers.get(type); + return pnum.getPhoneNumber(); + } + + /** + * Associates the specified phone number with the specified type in the + * map of phone numbers of this person. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @param phoneNumber The phone number + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String putPhoneNumber(String type, String phoneNumber) { + JPAAppPhoneNumber pnum = phoneNumbers.get(type); + String pnumAsString = null; + if (pnum != null) { + pnumAsString = pnum.getPhoneNumber(); // old val + } + pnum = phoneNumbers.put(type, + new JPAAppPhoneNumber(this, type, phoneNumber)); + return pnumAsString; + } + + /** + * Remove a phoneNumber from the map of phone numbers. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String removePhoneNumber(String type) { + JPAAppPhoneNumber pnum = phoneNumbers.get(type); + if (pnum == null) + return null; + String pnumAsString = pnum.getPhoneNumber(); // old val + pnum = phoneNumbers.remove(type); + return pnumAsString; + } + + /** + * Set the phoneNumber map to be in this person. + * @param phoneNumbers A Map of phoneNumbers for this person. + */ + public void setPhoneNumbers(Map phoneNumbers) { + this.phoneNumbers = (phoneNumbers != null) ? + convertString2Phone(phoneNumbers) : null; + } + + /** + * Converts HashMap of String, String to HashMap of String, JPAAppPhoneNmber + * @param pnums Map of phoneNumbers + * @return Map of phoneNumbers + */ + protected HashMap convertString2Phone(Map pnums) { + HashMap retval = new HashMap(); + for (Object objEntry: pnums.entrySet()) { + Map.Entry entry = (Map.Entry)objEntry; + String key = (String)entry.getKey(); + String value = (String)entry.getValue(); + JPAAppPhoneNumber newValue = + new JPAAppPhoneNumber(this, key, value); +// System.out.println("Key = " + key + " Value = " + value); + retval.put(key, newValue); + } + return retval; + } + + /** + * Converts HashMap of String, JPAAppPhoneNmber to HashMap of String, String + * @param pnums Map of phoneNumbers + * @return Map of phoneNumbers + */ + protected HashMap convertPhone2String(Map pnums) { + HashMap retval = new HashMap(); + for (Object objEntry: pnums.entrySet()) { + Map.Entry entry = (Map.Entry)objEntry; + String key = (String)entry.getKey(); + JPAAppPhoneNumber value = (JPAAppPhoneNumber)entry.getValue(); + String newValue = + value.getPhoneNumber(); + retval.put(key, newValue); + } + return retval; + } + + /** + * Returns a String representation of a JPAAppPerson object. + * + * @return a string representation of a JPAAppPerson object. + */ public String toString() { - return this.getClass().getName() + ": " + personid; + return "JPAPerson(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(personid); + rc.append(", ").append(lastname); + rc.append(", ").append(firstname); + rc.append(", born ").append( + birthdate==null ? "null" : formatter.format(birthdate)); + rc.append(", phone ").append(convertPhone2String(phoneNumbers)); + return rc.toString(); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.personid != o.personid) return (false); - return (true); + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified JPAAppPerson. + * + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + JPAAppPerson otherPerson = (JPAAppPerson)other; + String where = "JPAPerson<" + personid + ">"; + return + helper.equals(personid, otherPerson.getPersonid(), where + ".personid") & + helper.equals(firstname, otherPerson.getFirstname(), where + ".firstname") & + helper.equals(lastname, otherPerson.getLastname(), where + ".lastname") & + helper.equals(middlename, otherPerson.getMiddlename(), where + ".middlename") & + helper.equals(birthdate, otherPerson.getBirthdate(), where + ".birthdate") & + helper.deepEquals(address, otherPerson.getAddress(), where + ".address") & + helper.deepEquals(convertPhone2String(phoneNumbers), otherPerson.getPhoneNumbers(), where + ".phoneNumbers"); } - /** */ - public int hashCode() { - return ((int) personid); + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((JPAAppPerson)o); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((JPAAppPerson)o1, (JPAAppPerson)o2); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (personid < other.personid) return -1; - if (personid > other.personid) return 1; - return 0; + /** + * + * Compares this object with the specified JPAAppPerson object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * + * + * @param other The JPAAppPerson object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified JPAAppPerson + * object. + */ + public int compareTo(JPAAppPerson other) { + return compare(this, other); } - } + + /** + * Compares its two IPerson arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IPerson object to be compared. + * @param o2 the second IPerson object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(JPAAppPerson o1, JPAAppPerson o2) { + return EqualityHelper.compare(o1.getPersonid(), o2.getPersonid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof JPAAppPerson) { + return compareTo((JPAAppPerson)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)personid; + } + /** + * This class is used to represent the application identifier + * for the Person class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the identifier for the Person + * class. It must match a field in the Person class in + * both name and type. + */ + public long personid; + + /** + * The required public no-arg constructor. + */ + public Oid() { } + + /** + * Initialize the identifier. + * @param personid The person identifier. + */ + public Oid(long personid) { + this.personid = personid; + } + + public Oid(String s) { personid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + personid;} + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || + !this.getClass().equals(obj.getClass()) ) return( false ); + Oid o = (Oid) obj; + if( this.personid != o.personid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) personid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( personid < other.personid ) return -1; + if( personid > other.personid ) return 1; + return 0; + } + + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppPhoneNumber.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppPhoneNumber.java index cad75ef3b..ebad2ae1a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppPhoneNumber.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppPhoneNumber.java @@ -5,210 +5,207 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedJPA; +import javax.persistence.*; + import java.io.Serializable; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.IdClass; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.ManyToOne; -import javax.persistence.Table; - -/** This class represents a person. */ + +/** + * This class represents a person. + */ @Entity @IdClass(org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppPhoneNumber.Oid.class) -@Table(name = "employee_phoneno_type") -@Inheritance(strategy = InheritanceType.SINGLE_TABLE) -// @DiscriminatorColumn(discriminatorType=DiscriminatorType.STRING, +@Table(name="employee_phoneno_type") +@Inheritance(strategy=InheritanceType.SINGLE_TABLE) +//@DiscriminatorColumn(discriminatorType=DiscriminatorType.STRING, // name="DISCRIMINATOR") public class JPAAppPhoneNumber implements Serializable { - @Id - @ManyToOne - @Column(name = "EMPID") - private JPAAppPerson person; - - @Id - @Column(name = "TYPE") - private String type; - - @Column(name = "PHONENO") - private String phoneNumber; - - /** This is the JDO-required no-args constructor. */ - protected JPAAppPhoneNumber() {} - - /** - * Construct a JPAAppPhoneNumber instance. - * - * @param person The person instance - * @param type The type of the phone for this number - * @param phoneNumber The phone number - */ - public JPAAppPhoneNumber(JPAAppPerson person, String type, String phoneNumber) { - this.person = person; - this.type = type; - this.phoneNumber = phoneNumber; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setPerson(JPAAppPerson id) { - if (this.person != null) throw new IllegalStateException("Id is already set."); - this.person = id; - } - - /** - * Get the person's id. - * - * @return The person. - */ - public JPAAppPerson getPerson() { - return person; - } - - /** - * Get the person's last name. - * - * @return The last name. - */ - public String getType() { - return type; - } - - /** - * Set the phone number type - * - * @param type The phone number type - */ - public void setType(String type) { - this.type = type; - } - - /** - * Get the phone number. - * - * @return The phone number. - */ - public String getPhoneNumber() { - return phoneNumber; - } - - /** - * Set the phone number. - * - * @param phoneNumber The phone number. - */ - public void setPhoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - } - - /** - * Returns a String representation of a JPAAppPhoneNumber object. - * - * @return a string representation of a JPAAppPhoneNumber object. - */ - public String toString() { - return "JPAAppPhoneNumber(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(person.getPersonid()); - rc.append(", ").append(type); - rc.append(", phone ").append(phoneNumber); - return rc.toString(); - } - - /** - * This class is used to represent the application identifier for the Person class. - */ - public static class Oid implements Serializable, Comparable { + @Id + @ManyToOne + @Column(name="EMPID") + private JPAAppPerson person; + @Id + @Column(name="TYPE") + private String type; + @Column(name="PHONENO") + private String phoneNumber; + + /** This is the JDO-required no-args constructor. */ + protected JPAAppPhoneNumber() {} /** - * This field represents the identifier for the Person class. It must match a field - * in the Person class in both name and type. + * Construct a JPAAppPhoneNumber instance. + * + * @param person The person instance + * @param type The type of the phone for this number + * @param phoneNumber The phone number */ - public JPAAppPerson.Oid person; - - public String type; - - /** The required public no-arg constructor. */ - public Oid() {} + public JPAAppPhoneNumber(JPAAppPerson person, String type, + String phoneNumber) { + this.person = person; + this.type = type; + this.phoneNumber = phoneNumber; + } /** - * Initialize the identifier. - * - * @param person The person identifier. - * @param type The phone number type. + * Set the id associated with this object. + * @param id the id. */ - public Oid(JPAAppPerson.Oid person, String type) { - this.person = person; - this.type = type; + public void setPerson(JPAAppPerson id) { + if (this.person != null) + throw new IllegalStateException("Id is already set."); + this.person = id; } - public Oid(String s) { - person = new JPAAppPerson.Oid(justTheOid(s)); - type = justTheType(s); + /** + * Get the person's id. + * @return The person. + */ + public JPAAppPerson getPerson() { + return person; } - public String toString() { - return this.getClass().getName() + ": " + person + " + " + type; + /** + * Get the person's last name. + * @return The last name. + */ + + public String getType() { + return type; } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (!this.person.equals(o.person)) return (false); - if (!this.type.equals(o.type)) return (false); - return (true); + /** + * Set the phone number type + * @param type The phone number type + */ + public void setType(String type) { + this.type = type; } - /** */ - public int hashCode() { - return ((int) person.hashCode() + type.hashCode()); + /** + * Get the phone number. + * @return The phone number. + */ + public String getPhoneNumber() { + return phoneNumber; } - protected static String justTheOid(String str) { - return str.substring(str.indexOf(':') + 1, str.indexOf('+') - 1); + /** + * Set the phone number. + * @param phoneNumber The phone number. + */ + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; } - protected static String justTheType(String str) { - return str.substring(str.indexOf('+') + 1); + /** + * Returns a String representation of a JPAAppPhoneNumber object. + * + * @return a string representation of a JPAAppPhoneNumber object. + */ + public String toString() { + return "JPAAppPhoneNumber(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(person.getPersonid()); + rc.append(", ").append(type); + rc.append(", phone ").append(phoneNumber); + return rc.toString(); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - int comparison = person.compareTo(other.person); - if (comparison != 0) { - return comparison; - } else { - return type.compareTo(other.type); - } + /** + * This class is used to represent the application identifier + * for the Person class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the identifier for the Person + * class. It must match a field in the Person class in + * both name and type. + */ + public JPAAppPerson.Oid person; + + public String type; + + /** + * The required public no-arg constructor. + */ + public Oid() { } + + /** + * Initialize the identifier. + * @param person The person identifier. + * @param type The phone number type. + */ + public Oid(JPAAppPerson.Oid person, String type) { + this.person = person; + this.type = type; + } + + public Oid(String s) { + person = new JPAAppPerson.Oid(justTheOid(s)); + type = justTheType(s); + } + + public String toString() { + return this.getClass().getName() + ": " + person + " + " + type; + } + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || + !this.getClass().equals(obj.getClass()) ) return( false ); + Oid o = (Oid) obj; + if( !this.person.equals(o.person) ) return( false ); + if( !this.type.equals(o.type) ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) person.hashCode() + type.hashCode() ); + } + + protected static String justTheOid(String str) { + return str.substring(str.indexOf(':') + 1, str.indexOf('+') - 1); + } + + protected static String justTheType(String str) { + return str.substring(str.indexOf('+') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + int comparison = person.compareTo(other.person); + if( comparison != 0 ) { + return comparison; + } else { + return type.compareTo(other.type); + } + } + } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppProject.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppProject.java index aad0bef40..996dec580 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppProject.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppProject.java @@ -5,398 +5,388 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedJPA; -import java.io.IOException; -import java.io.ObjectInputStream; +import javax.persistence.*; + import java.io.Serializable; -import java.math.BigDecimal; +import java.io.ObjectInputStream; +import java.io.IOException; + import java.util.Collections; import java.util.Comparator; -import java.util.HashSet; import java.util.Set; -import javax.persistence.Column; -import javax.persistence.DiscriminatorColumn; -import javax.persistence.DiscriminatorType; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Inheritance; -import javax.persistence.InheritanceType; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.ManyToMany; -import javax.persistence.Table; +import java.util.HashSet; +import java.math.BigDecimal; + import org.apache.jdo.tck.pc.company.IProject; import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a project, a budgeted task with one or more employees working on it. */ +/** + * This class represents a project, a budgeted task with one or more + * employees working on it. + */ + @Entity -@Table(name = "projects") -@Inheritance(strategy = InheritanceType.SINGLE_TABLE) -@DiscriminatorColumn(discriminatorType = DiscriminatorType.STRING, name = "DISCRIMINATOR") -public class JPAAppProject implements IProject, Serializable, Comparable, Comparator, DeepEquality { - - @Id - @Column(name = "PROJID") - private long projid; - - @Column(name = "NAME") - private String name; - - @Column(name = "BUDGET", length = 11, scale = 2) - private BigDecimal budget; - - @ManyToMany(targetEntity = org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppEmployee.class) - @JoinTable( - name = "project_reviewer", - joinColumns = @JoinColumn(name = "PROJID"), - inverseJoinColumns = @JoinColumn(name = "REVIEWER")) - private Set reviewers = new HashSet(); - - @ManyToMany(targetEntity = org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppEmployee.class) - @JoinTable( - name = "project_member", - joinColumns = @JoinColumn(name = "PROJID"), - inverseJoinColumns = @JoinColumn(name = "MEMBER")) - private Set members = new HashSet(); - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public JPAAppProject() {} - - /** - * Initialize a project. - * - * @param projid The project identifier. - * @param name The name of the project. - * @param budget The budget for the project. - */ - public JPAAppProject(long projid, String name, BigDecimal budget) { - this.projid = projid; - this.name = name; - this.budget = budget; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setProjid(long id) { - if (this.projid != 0) throw new IllegalStateException("Id is already set."); - this.projid = id; - } - - /** - * Get the project ID. - * - * @return The project ID. - */ - public long getProjid() { - return projid; - } - - /** - * Get the name of the project. - * - * @return The name of the project. - */ - public String getName() { - return name; - } - - /** - * Set the name of the project. - * - * @param name The name of the project. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Get the project's budget. - * - * @return The project's budget. - */ - public BigDecimal getBudget() { - return budget; - } - - /** - * Set the project's budget. - * - * @param budget The project's budget. - */ - public void setBudget(BigDecimal budget) { - this.budget = budget; - } - - /** Get the reviewers associated with this project. */ - public Set getReviewers() { - return Collections.unmodifiableSet(reviewers); - } - - /** - * Add a reviewer to the project. - * - * @param emp The employee to add as a reviewer. - */ - public void addReviewer(JPAAppEmployee emp) { - reviewers.add(emp); - } - - /** - * Remove a reviewer from the project. - * - * @param emp The employee to remove as a reviewer of this project. - */ - public void removeReviewer(JPAAppEmployee emp) { - reviewers.remove(emp); - } - - /** - * Set the reviewers associated with this project. - * - * @param reviewers The set of reviewers to associate with this project. - */ - public void setReviewers(Set reviewers) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.reviewers = (reviewers != null) ? new HashSet(reviewers) : null; - } - - /** - * Get the project members. - * - * @return The members of the project is returned as an unmodifiable set of JPAAppEmployee - * s. - */ - public Set getMembers() { - return Collections.unmodifiableSet(members); - } - - /** - * Add a new member to the project. - * - * @param emp The employee to add to the project. - */ - public void addMember(JPAAppEmployee emp) { - members.add(emp); - } - - /** - * Remove a member from the project. - * - * @param emp The employee to remove from the project. - */ - public void removeMember(JPAAppEmployee emp) { - members.remove(emp); - } - - /** - * Set the members of the project. - * - * @param employees The set of employees to be the members of this project. - */ - public void setMembers(Set employees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.members = (employees != null) ? new HashSet(employees) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - reviewers = new HashSet(); - members = new HashSet(); - } - - /** - * Returns a String representation of a JPAAppProject object. - * - * @return a String representation of a JPAAppProject object. - */ - public String toString() { - return "JPAProject(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(projid); - rc.append(", name ").append(name); - rc.append(", budget ").append(budget); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - JPAAppProject otherProject = (JPAAppProject) other; - String where = "JPAProject<" + projid + ">"; - return helper.equals(projid, otherProject.getProjid(), where + ".projid") - & helper.equals(name, otherProject.getName(), where + ".name") - & helper.equals(budget, otherProject.getBudget(), where + ".budget") - & helper.deepEquals(reviewers, otherProject.getReviewers(), where + ".reviewers") - & helper.deepEquals(members, otherProject.getMembers(), where + ".members"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((JPAAppProject) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((JPAAppProject) o1, (JPAAppProject) o2); - } - - /** - * Compares this object with the specified JPAAppProject object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The JPAAppProject object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified JPAAppProject object. - */ - public int compareTo(JPAAppProject other) { - return compare(this, other); - } - - /** - * Compares its two IProject arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IProject object to be compared. - * @param o2 the second IProject object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(JPAAppProject o1, JPAAppProject o2) { - return EqualityHelper.compare(o1.getProjid(), o2.getProjid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof JPAAppProject) { - return compareTo((JPAAppProject) obj) == 0; +@Table(name="projects") +@Inheritance(strategy=InheritanceType.SINGLE_TABLE) +@DiscriminatorColumn(discriminatorType=DiscriminatorType.STRING, + name="DISCRIMINATOR") + public class JPAAppProject + implements IProject, Serializable, Comparable, Comparator, DeepEquality { + + @Id + @Column(name="PROJID") + private long projid; + @Column(name="NAME") + private String name; + @Column(name="BUDGET", length=11, scale=2) + private BigDecimal budget; + @ManyToMany(targetEntity=org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppEmployee.class) + @JoinTable(name="project_reviewer", joinColumns=@JoinColumn(name="PROJID"), + inverseJoinColumns=@JoinColumn(name="REVIEWER")) + private Set reviewers = new HashSet(); + @ManyToMany(targetEntity=org.apache.jdo.tck.pc.companyAnnotatedJPA.JPAAppEmployee.class) + @JoinTable(name="project_member", joinColumns=@JoinColumn(name="PROJID"), + inverseJoinColumns=@JoinColumn(name="MEMBER")) + private Set members = new HashSet(); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public JPAAppProject() {} + + /** + * Initialize a project. + * @param projid The project identifier. + * @param name The name of the project. + * @param budget The budget for the project. + */ + public JPAAppProject(long projid, String name, BigDecimal budget) { + this.projid = projid; + this.name = name; + this.budget = budget; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setProjid(long id) { + if (this.projid != 0) + throw new IllegalStateException("Id is already set."); + this.projid = id; + } + + /** + * Get the project ID. + * @return The project ID. + */ + public long getProjid() { + return projid; + } + + /** + * Get the name of the project. + * @return The name of the project. + */ + public String getName() { + return name; + } + + /** + * Set the name of the project. + * @param name The name of the project. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Get the project's budget. + * @return The project's budget. + */ + public BigDecimal getBudget() { + return budget; + } + + /** + * Set the project's budget. + * @param budget The project's budget. + */ + public void setBudget(BigDecimal budget) { + this.budget = budget; + } + + /** + * Get the reviewers associated with this project. + */ + public Set getReviewers() { + return Collections.unmodifiableSet(reviewers); + } + + /** + * Add a reviewer to the project. + * @param emp The employee to add as a reviewer. + */ + public void addReviewer(JPAAppEmployee emp) { + reviewers.add(emp); + } + + /** + * Remove a reviewer from the project. + * @param emp The employee to remove as a reviewer of this project. + */ + public void removeReviewer(JPAAppEmployee emp) { + reviewers.remove(emp); + } + + /** + * Set the reviewers associated with this project. + * @param reviewers The set of reviewers to associate with this project. + */ + public void setReviewers(Set reviewers) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.reviewers = (reviewers != null) ? new HashSet(reviewers) : null; + } + + /** + * Get the project members. + * + * + * @return The members of the project is returned as an unmodifiable + * set of JPAAppEmployees. + */ + public Set getMembers() { + return Collections.unmodifiableSet(members); } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) projid; - } - - /** - * This class is used to represent the application identity for the JPAAppProject - * class. - */ - public static class Oid implements Serializable, Comparable { /** - * This field represents the identifier for the JPAAppProject class. It must match - * a field in the JPAAppProject class in both name and type. + * Add a new member to the project. + * @param emp The employee to add to the project. */ - public long projid; + public void addMember(JPAAppEmployee emp) { + members.add(emp); + } - /** The required public no-arg constructor. */ - public Oid() {} + /** + * Remove a member from the project. + * @param emp The employee to remove from the project. + */ + public void removeMember(JPAAppEmployee emp) { + members.remove(emp); + } /** - * Initialize the application identifier with a project ID. - * - * @param projid The id of the project. + * Set the members of the project. + * @param employees The set of employees to be the members of this + * project. */ - public Oid(long projid) { - this.projid = projid; + public void setMembers(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.members = (employees != null) ? new HashSet(employees) : null; } - public Oid(String s) { - projid = Long.parseLong(justTheId(s)); + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + reviewers = new HashSet(); + members = new HashSet(); } + /** + * Returns a String representation of a JPAAppProject object. + * + * + * @return a String representation of a JPAAppProject object. + */ public String toString() { - return this.getClass().getName() + ": " + projid; + return "JPAProject(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(projid); + rc.append(", name ").append(name); + rc.append(", budget ").append(budget); + return rc.toString(); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.projid != o.projid) return (false); - return (true); + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + JPAAppProject otherProject = (JPAAppProject)other; + String where = "JPAProject<" + projid + ">"; + return + helper.equals(projid, otherProject.getProjid(), where + ".projid") & + helper.equals(name, otherProject.getName(), where + ".name") & + helper.equals(budget, otherProject.getBudget(), where + ".budget") & + helper.deepEquals(reviewers, otherProject.getReviewers(), where + ".reviewers") & + helper.deepEquals(members, otherProject.getMembers(), where + ".members"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((JPAAppProject)o); } - /** */ - public int hashCode() { - return ((int) projid); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((JPAAppProject)o1, (JPAAppProject)o2); + } + + /** + * + * Compares this object with the specified JPAAppProject object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * + * + * @param other The JPAAppProject object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified JPAAppProject object. + */ + public int compareTo(JPAAppProject other) { + return compare(this, other); + } + + /** + * Compares its two IProject arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IProject object to be compared. + * @param o2 the second IProject object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(JPAAppProject o1, JPAAppProject o2) { + return EqualityHelper.compare(o1.getProjid(), o2.getProjid()); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof JPAAppProject) { + return compareTo((JPAAppProject)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)projid; } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (projid < other.projid) return -1; - if (projid > other.projid) return 1; - return 0; + /** + * This class is used to represent the application identity + * for the JPAAppProject class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the identifier for the + * JPAAppProject class. It must match a field in the + * JPAAppProject class in both name and type. + */ + public long projid; + + /** + * The required public no-arg constructor. + */ + public Oid() { } + + /** + * Initialize the application identifier with a project ID. + * @param projid The id of the project. + */ + public Oid(long projid) { + this.projid = projid; + } + + public Oid(String s) { projid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + projid;} + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.projid != o.projid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) projid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( projid < other.projid ) return -1; + if( projid > other.projid ) return 1; + return 0; + } + } - } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCAppConcrete.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCAppConcrete.java index ae5ff9df8..40bffc578 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCAppConcrete.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCAppConcrete.java @@ -18,16 +18,7 @@ package org.apache.jdo.tck.pc.companyAnnotatedPC; import javax.jdo.PersistenceManager; -import org.apache.jdo.tck.pc.company.CompanyFactoryNewInstance; -import org.apache.jdo.tck.pc.company.IAddress; -import org.apache.jdo.tck.pc.company.ICompany; -import org.apache.jdo.tck.pc.company.IDentalInsurance; -import org.apache.jdo.tck.pc.company.IDepartment; -import org.apache.jdo.tck.pc.company.IFullTimeEmployee; -import org.apache.jdo.tck.pc.company.IMedicalInsurance; -import org.apache.jdo.tck.pc.company.IMeetingRoom; -import org.apache.jdo.tck.pc.company.IPartTimeEmployee; -import org.apache.jdo.tck.pc.company.IProject; +import org.apache.jdo.tck.pc.company.*; /* * CompanyFactoryAnnotatedPMFieldClass.java @@ -35,65 +26,65 @@ * This class uses the PersistenceManager.newInstance method with the concrete * class as a parameter. */ -public class CompanyFactoryAnnotatedPCAppConcrete implements CompanyFactoryNewInstance { +public class CompanyFactoryAnnotatedPCAppConcrete + implements CompanyFactoryNewInstance { + + PersistenceManager pm = null; - PersistenceManager pm = null; + /** + * Creates a new instance of CompanyFactoryAnnotatedPCAppConcrete + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedPCAppConcrete(PersistenceManager pm) { + this.pm = pm; + } + + public Class[] getTearDownClasses() { + return new Class[] { + PCAppDentalInsurance.class, + PCAppMedicalInsurance.class, + PCAppPartTimeEmployee.class, + PCAppFullTimeEmployee.class, + PCAppProject.class, + PCAppDepartment.class, + PCAppCompany.class, + PCAppAddress.class + }; + } + + public IAddress newAddress() { + return (IAddress) new PCAppAddress(); + } - /** - * Creates a new instance of CompanyFactoryAnnotatedPCAppConcrete - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedPCAppConcrete(PersistenceManager pm) { - this.pm = pm; - } - - public Class[] getTearDownClasses() { - return new Class[] { - PCAppDentalInsurance.class, - PCAppMedicalInsurance.class, - PCAppPartTimeEmployee.class, - PCAppFullTimeEmployee.class, - PCAppProject.class, - PCAppDepartment.class, - PCAppCompany.class, - PCAppAddress.class - }; - } - - public IAddress newAddress() { - return (IAddress) new PCAppAddress(); - } - - public IMeetingRoom newMeetingRoom() { - return (IMeetingRoom) null; - } - - public ICompany newCompany() { - return (ICompany) new PCAppCompany(); - } - - public IDentalInsurance newDentalInsurance() { - return (IDentalInsurance) new PCAppDentalInsurance(); - } - - public IDepartment newDepartment() { - return (IDepartment) new PCAppDepartment(); - } - - public IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) new PCAppFullTimeEmployee(); - } - - public IMedicalInsurance newMedicalInsurance() { - return (IMedicalInsurance) new PCAppMedicalInsurance(); - } - - public IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) new PCAppPartTimeEmployee(); - } - - public IProject newProject() { - return (IProject) new PCAppProject(); - } + public IMeetingRoom newMeetingRoom() { + return (IMeetingRoom)null; + } + + public ICompany newCompany() { + return (ICompany) new PCAppCompany(); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance) new PCAppDentalInsurance(); + } + + public IDepartment newDepartment() { + return (IDepartment) new PCAppDepartment(); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee) new PCAppFullTimeEmployee(); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance) new PCAppMedicalInsurance(); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee) new PCAppPartTimeEmployee(); + } + + public IProject newProject() { + return (IProject) new PCAppProject(); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCAppPM.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCAppPM.java index 5657d3339..aa4dffe2d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCAppPM.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCAppPM.java @@ -18,16 +18,7 @@ package org.apache.jdo.tck.pc.companyAnnotatedPC; import javax.jdo.PersistenceManager; -import org.apache.jdo.tck.pc.company.CompanyFactoryNewInstance; -import org.apache.jdo.tck.pc.company.IAddress; -import org.apache.jdo.tck.pc.company.ICompany; -import org.apache.jdo.tck.pc.company.IDentalInsurance; -import org.apache.jdo.tck.pc.company.IDepartment; -import org.apache.jdo.tck.pc.company.IFullTimeEmployee; -import org.apache.jdo.tck.pc.company.IMedicalInsurance; -import org.apache.jdo.tck.pc.company.IMeetingRoom; -import org.apache.jdo.tck.pc.company.IPartTimeEmployee; -import org.apache.jdo.tck.pc.company.IProject; +import org.apache.jdo.tck.pc.company.*; /* * CompanyFactoryAnnotatedPMFieldClass.java @@ -35,65 +26,65 @@ * This class uses the PersistenceManager.newInstance method with the concrete * class as a parameter. */ -public class CompanyFactoryAnnotatedPCAppPM implements CompanyFactoryNewInstance { +public class CompanyFactoryAnnotatedPCAppPM + implements CompanyFactoryNewInstance { + + PersistenceManager pm = null; - PersistenceManager pm = null; + /** + * Creates a new instance of CompanyFactoryAnnotatedPCAppPM + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedPCAppPM(PersistenceManager pm) { + this.pm = pm; + } + + public Class[] getTearDownClasses() { + return new Class[] { + PCAppDentalInsurance.class, + PCAppMedicalInsurance.class, + PCAppPartTimeEmployee.class, + PCAppFullTimeEmployee.class, + PCAppProject.class, + PCAppDepartment.class, + PCAppCompany.class, + PCAppAddress.class + }; + } + + public IAddress newAddress() { + return (IAddress)pm.newInstance(PCAppAddress.class); + } - /** - * Creates a new instance of CompanyFactoryAnnotatedPCAppPM - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedPCAppPM(PersistenceManager pm) { - this.pm = pm; - } - - public Class[] getTearDownClasses() { - return new Class[] { - PCAppDentalInsurance.class, - PCAppMedicalInsurance.class, - PCAppPartTimeEmployee.class, - PCAppFullTimeEmployee.class, - PCAppProject.class, - PCAppDepartment.class, - PCAppCompany.class, - PCAppAddress.class - }; - } - - public IAddress newAddress() { - return (IAddress) pm.newInstance(PCAppAddress.class); - } - - public IMeetingRoom newMeetingRoom() { - return (IMeetingRoom) null; - } - - public ICompany newCompany() { - return (ICompany) pm.newInstance(PCAppCompany.class); - } - - public IDentalInsurance newDentalInsurance() { - return (IDentalInsurance) pm.newInstance(PCAppDentalInsurance.class); - } - - public IDepartment newDepartment() { - return (IDepartment) pm.newInstance(PCAppDepartment.class); - } - - public IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) pm.newInstance(PCAppFullTimeEmployee.class); - } - - public IMedicalInsurance newMedicalInsurance() { - return (IMedicalInsurance) pm.newInstance(PCAppMedicalInsurance.class); - } - - public IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) pm.newInstance(PCAppPartTimeEmployee.class); - } - - public IProject newProject() { - return (IProject) pm.newInstance(PCAppProject.class); - } + public IMeetingRoom newMeetingRoom() { + return (IMeetingRoom)null; + } + + public ICompany newCompany() { + return (ICompany)pm.newInstance(PCAppCompany.class); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance)pm.newInstance(PCAppDentalInsurance.class); + } + + public IDepartment newDepartment() { + return (IDepartment)pm.newInstance(PCAppDepartment.class); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee)pm.newInstance(PCAppFullTimeEmployee.class); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance)pm.newInstance(PCAppMedicalInsurance.class); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee)pm.newInstance(PCAppPartTimeEmployee.class); + } + + public IProject newProject() { + return (IProject)pm.newInstance(PCAppProject.class); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCConcreteDelegator.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCConcreteDelegator.java index 3f10fd510..960553041 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCConcreteDelegator.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCConcreteDelegator.java @@ -27,19 +27,19 @@ * class as a parameter. */ public class CompanyFactoryAnnotatedPCConcreteDelegator - extends CompanyFactoryAnnotatedAbstractDelegator { + extends CompanyFactoryAnnotatedAbstractDelegator { - /** - * Creates a new instance of CompanyFactoryAnnotatedPCConcreteDelegator - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedPCConcreteDelegator(PersistenceManager pm) { - super(pm); - if (isAppIdentity) { - delegate = new CompanyFactoryAnnotatedPCAppConcrete(pm); - } else { // datastoreidentity - delegate = new CompanyFactoryAnnotatedPCDSConcrete(pm); + /** + * Creates a new instance of CompanyFactoryAnnotatedPCConcreteDelegator + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedPCConcreteDelegator(PersistenceManager pm) { + super(pm); + if (isAppIdentity){ + delegate = new CompanyFactoryAnnotatedPCAppConcrete(pm); + } else { //datastoreidentity + delegate = new CompanyFactoryAnnotatedPCDSConcrete(pm); + } } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCDSConcrete.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCDSConcrete.java index 101d2dcf0..d518bae3f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCDSConcrete.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCDSConcrete.java @@ -18,16 +18,7 @@ package org.apache.jdo.tck.pc.companyAnnotatedPC; import javax.jdo.PersistenceManager; -import org.apache.jdo.tck.pc.company.CompanyFactoryNewInstance; -import org.apache.jdo.tck.pc.company.IAddress; -import org.apache.jdo.tck.pc.company.ICompany; -import org.apache.jdo.tck.pc.company.IDentalInsurance; -import org.apache.jdo.tck.pc.company.IDepartment; -import org.apache.jdo.tck.pc.company.IFullTimeEmployee; -import org.apache.jdo.tck.pc.company.IMedicalInsurance; -import org.apache.jdo.tck.pc.company.IMeetingRoom; -import org.apache.jdo.tck.pc.company.IPartTimeEmployee; -import org.apache.jdo.tck.pc.company.IProject; +import org.apache.jdo.tck.pc.company.*; /* * CompanyFactoryAnnotatedFCDSPM.java @@ -35,65 +26,65 @@ * This class uses the PersistenceManager.newInstance method with the concrete * class as a parameter. */ -public class CompanyFactoryAnnotatedPCDSConcrete implements CompanyFactoryNewInstance { +public class CompanyFactoryAnnotatedPCDSConcrete + implements CompanyFactoryNewInstance { + + PersistenceManager pm = null; - PersistenceManager pm = null; + /** + * Creates a new instance of CompanyFactoryAnnotatedPCDSConcrete + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedPCDSConcrete(PersistenceManager pm) { + this.pm = pm; + } + + public Class[] getTearDownClasses() { + return new Class[] { + PCDSDentalInsurance.class, + PCDSMedicalInsurance.class, + PCDSPartTimeEmployee.class, + PCDSFullTimeEmployee.class, + PCDSProject.class, + PCDSDepartment.class, + PCDSCompany.class, + PCDSAddress.class + }; + } + + public IAddress newAddress() { + return (IAddress) new PCDSAddress(); + } - /** - * Creates a new instance of CompanyFactoryAnnotatedPCDSConcrete - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedPCDSConcrete(PersistenceManager pm) { - this.pm = pm; - } - - public Class[] getTearDownClasses() { - return new Class[] { - PCDSDentalInsurance.class, - PCDSMedicalInsurance.class, - PCDSPartTimeEmployee.class, - PCDSFullTimeEmployee.class, - PCDSProject.class, - PCDSDepartment.class, - PCDSCompany.class, - PCDSAddress.class - }; - } - - public IAddress newAddress() { - return (IAddress) new PCDSAddress(); - } - - public IMeetingRoom newMeetingRoom() { - return (IMeetingRoom) null; - } - - public ICompany newCompany() { - return (ICompany) new PCDSCompany(); - } - - public IDentalInsurance newDentalInsurance() { - return (IDentalInsurance) new PCDSDentalInsurance(); - } - - public IDepartment newDepartment() { - return (IDepartment) new PCDSDepartment(); - } - - public IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) new PCDSFullTimeEmployee(); - } - - public IMedicalInsurance newMedicalInsurance() { - return (IMedicalInsurance) new PCDSMedicalInsurance(); - } - - public IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) new PCDSPartTimeEmployee(); - } - - public IProject newProject() { - return (IProject) new PCDSProject(); - } + public IMeetingRoom newMeetingRoom() { + return (IMeetingRoom)null; + } + + public ICompany newCompany() { + return (ICompany) new PCDSCompany(); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance) new PCDSDentalInsurance(); + } + + public IDepartment newDepartment() { + return (IDepartment) new PCDSDepartment(); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee) new PCDSFullTimeEmployee(); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance) new PCDSMedicalInsurance(); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee) new PCDSPartTimeEmployee(); + } + + public IProject newProject() { + return (IProject) new PCDSProject(); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCDSPM.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCDSPM.java index 56bb472f1..0a12064c3 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCDSPM.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCDSPM.java @@ -18,16 +18,7 @@ package org.apache.jdo.tck.pc.companyAnnotatedPC; import javax.jdo.PersistenceManager; -import org.apache.jdo.tck.pc.company.CompanyFactoryNewInstance; -import org.apache.jdo.tck.pc.company.IAddress; -import org.apache.jdo.tck.pc.company.ICompany; -import org.apache.jdo.tck.pc.company.IDentalInsurance; -import org.apache.jdo.tck.pc.company.IDepartment; -import org.apache.jdo.tck.pc.company.IFullTimeEmployee; -import org.apache.jdo.tck.pc.company.IMedicalInsurance; -import org.apache.jdo.tck.pc.company.IMeetingRoom; -import org.apache.jdo.tck.pc.company.IPartTimeEmployee; -import org.apache.jdo.tck.pc.company.IProject; +import org.apache.jdo.tck.pc.company.*; /* * CompanyFactoryAnnotatedPCDSPM.java @@ -35,65 +26,65 @@ * This class uses the PersistenceManager.newInstance method with the concrete * class as a parameter. */ -public class CompanyFactoryAnnotatedPCDSPM implements CompanyFactoryNewInstance { +public class CompanyFactoryAnnotatedPCDSPM + implements CompanyFactoryNewInstance { + + PersistenceManager pm = null; - PersistenceManager pm = null; + /** + * Creates a new instance of CompanyFactoryAnnotatedPCDSPM + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedPCDSPM(PersistenceManager pm) { + this.pm = pm; + } + + public Class[] getTearDownClasses() { + return new Class[] { + PCDSDentalInsurance.class, + PCDSMedicalInsurance.class, + PCDSPartTimeEmployee.class, + PCDSFullTimeEmployee.class, + PCDSProject.class, + PCDSDepartment.class, + PCDSCompany.class, + PCDSAddress.class + }; + } + + public IAddress newAddress() { + return (IAddress)pm.newInstance(PCDSAddress.class); + } - /** - * Creates a new instance of CompanyFactoryAnnotatedPCDSPM - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedPCDSPM(PersistenceManager pm) { - this.pm = pm; - } - - public Class[] getTearDownClasses() { - return new Class[] { - PCDSDentalInsurance.class, - PCDSMedicalInsurance.class, - PCDSPartTimeEmployee.class, - PCDSFullTimeEmployee.class, - PCDSProject.class, - PCDSDepartment.class, - PCDSCompany.class, - PCDSAddress.class - }; - } - - public IAddress newAddress() { - return (IAddress) pm.newInstance(PCDSAddress.class); - } - - public IMeetingRoom newMeetingRoom() { - return (IMeetingRoom) null; - } - - public ICompany newCompany() { - return (ICompany) pm.newInstance(PCDSCompany.class); - } - - public IDentalInsurance newDentalInsurance() { - return (IDentalInsurance) pm.newInstance(PCDSDentalInsurance.class); - } - - public IDepartment newDepartment() { - return (IDepartment) pm.newInstance(PCDSDepartment.class); - } - - public IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) pm.newInstance(PCDSFullTimeEmployee.class); - } - - public IMedicalInsurance newMedicalInsurance() { - return (IMedicalInsurance) pm.newInstance(PCDSMedicalInsurance.class); - } - - public IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) pm.newInstance(PCDSPartTimeEmployee.class); - } - - public IProject newProject() { - return (IProject) pm.newInstance(PCDSProject.class); - } + public IMeetingRoom newMeetingRoom() { + return (IMeetingRoom)null; + } + + public ICompany newCompany() { + return (ICompany)pm.newInstance(PCDSCompany.class); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance)pm.newInstance(PCDSDentalInsurance.class); + } + + public IDepartment newDepartment() { + return (IDepartment)pm.newInstance(PCDSDepartment.class); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee)pm.newInstance(PCDSFullTimeEmployee.class); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance)pm.newInstance(PCDSMedicalInsurance.class); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee)pm.newInstance(PCDSPartTimeEmployee.class); + } + + public IProject newProject() { + return (IProject)pm.newInstance(PCDSProject.class); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCPMDelegator.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCPMDelegator.java index 86bce86c2..16bc7f773 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCPMDelegator.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/CompanyFactoryAnnotatedPCPMDelegator.java @@ -26,19 +26,20 @@ * This class uses the PersistenceManager.newInstance method with the concrete * class as a parameter. */ -public class CompanyFactoryAnnotatedPCPMDelegator extends CompanyFactoryAnnotatedAbstractDelegator { +public class CompanyFactoryAnnotatedPCPMDelegator + extends CompanyFactoryAnnotatedAbstractDelegator { - /** - * Creates a new instance of CompanyFactoryAnnotatedPCPMDelegator - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedPCPMDelegator(PersistenceManager pm) { - super(pm); - if (isAppIdentity) { - delegate = new CompanyFactoryAnnotatedPCAppPM(pm); - } else { // datastoreidentity - delegate = new CompanyFactoryAnnotatedPCDSPM(pm); + /** + * Creates a new instance of CompanyFactoryAnnotatedPCPMDelegator + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedPCPMDelegator(PersistenceManager pm) { + super(pm); + if (isAppIdentity){ + delegate = new CompanyFactoryAnnotatedPCAppPM(pm); + } else { //datastoreidentity + delegate = new CompanyFactoryAnnotatedPCDSPM(pm); + } } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppAddress.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppAddress.java index 0ec78029a..ff12c5361 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppAddress.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppAddress.java @@ -5,341 +5,343 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; import java.io.Serializable; import java.util.Comparator; -import javax.jdo.annotations.PersistenceCapable; + +import javax.jdo.annotations.*; + import org.apache.jdo.tck.pc.company.IAddress; import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a postal address. */ -@PersistenceCapable(embeddedOnly = "true", requiresExtent = "false") -public class PCAppAddress implements IAddress, Serializable, Comparable, Comparator, DeepEquality { - - private long addrid; - private String street; - private String city; - private String state; - private String zipcode; - private String country; - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public PCAppAddress() {} - - /** - * This constructor initializes the PCAppAddress components. - * - * @param addrid The address ID. - * @param street The street address. - * @param city The city. - * @param state The state. - * @param zipcode The zip code. - * @param country The zip country. - */ - public PCAppAddress( - long addrid, String street, String city, String state, String zipcode, String country) { - this.addrid = addrid; - this.street = street; - this.city = city; - this.state = state; - this.zipcode = zipcode; - this.country = country; - } - - /** - * Get the addrid associated with this object. - * - * @return the addrid. - */ - public long getAddrid() { - return addrid; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setAddrid(long id) { - this.addrid = id; - } - - /** - * Get the street component of the address. - * - * @return The street component of the address. - */ - public String getStreet() { - return street; - } - - /** - * Set the street component of the address. - * - * @param street The street component. - */ - public void setStreet(String street) { - this.street = street; - } - - /** - * Get the city. - * - * @return The city component of the address. - */ - public String getCity() { - return city; - } - - /** - * Set the city component of the address. - * - * @param city The city. - */ - public void setCity(String city) { - this.city = city; - } - - /** - * Get the state component of the address. - * - * @return The state. - */ - public String getState() { - return state; - } - - /** - * Set the state component of the address. - * - * @param state The state. - */ - public void setState(String state) { - this.state = state; - } - - /** - * Get the zipcode component of the address. - * - * @return The zipcode. - */ - public String getZipcode() { - return zipcode; - } - - /** - * Set the zip code component of the address. - * - * @param zipcode The zipcode. - */ - public void setZipcode(String zipcode) { - this.zipcode = zipcode; - } - - /** - * Get the country component of the address. - * - * @return The country. - */ - public String getCountry() { - return country; - } - - /** - * Set the country component of the address. - * - * @param country The country. - */ - public void setCountry(String country) { - this.country = country; - } - - /** - * Returns a String representation of a Address object. - * - * @return a String representation of a Address object. - */ - public String toString() { - return "Address(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(addrid); - rc.append(", street ").append(street); - rc.append(", city ").append(city); - rc.append(", state ").append(state); - rc.append(", zipcode ").append(zipcode); - rc.append(", country ").append(country); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCAppAddress otherAddress = (PCAppAddress) other; - String where = "Address<" + addrid + ">"; - return helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") - & helper.equals(street, otherAddress.getStreet(), where + ".street") - & helper.equals(city, otherAddress.getCity(), where + ".city") - & helper.equals(state, otherAddress.getState(), where + ".state") - & helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") - & helper.equals(country, otherAddress.getCountry(), where + ".country"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((PCAppAddress) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((PCAppAddress) o1, (PCAppAddress) o2); - } - - /** - * Compares this object with the specified Address object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Address object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Address object. - */ - public int compareTo(PCAppAddress other) { - return compare(this, other); - } - - /** - * Compares its two PCAppAddress arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first PCAppAddresss object to be compared. - * @param o2 the second FFCPIAddressobject to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(PCAppAddress o1, PCAppAddress o2) { - return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof PCAppAddress) { - return compareTo((PCAppAddress) obj) == 0; +/** + * This class represents a postal address. + */ +@PersistenceCapable(embeddedOnly="true", requiresExtent="false") +public class PCAppAddress + implements IAddress, Serializable, Comparable, Comparator, DeepEquality { + + private long addrid; + private String street; + private String city; + private String state; + private String zipcode; + private String country; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCAppAddress() {} + + /** + * This constructor initializes the PCAppAddress components. + * + * + * + * @param addrid The address ID. + * @param street The street address. + * @param city The city. + * @param state The state. + * @param zipcode The zip code. + * @param country The zip country. + */ + public PCAppAddress(long addrid, String street, String city, + String state, String zipcode, String country) + { + this.addrid = addrid; + this.street = street; + this.city = city; + this.state = state; + this.zipcode = zipcode; + this.country = country; + } + + /** + * Get the addrid associated with this object. + * @return the addrid. + */ + public long getAddrid() { + return addrid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setAddrid(long id) { + this.addrid = id; + } + + /** + * Get the street component of the address. + * @return The street component of the address. + */ + public String getStreet() { + return street; + } + + /** + * Set the street component of the address. + * @param street The street component. + */ + public void setStreet(String street) { + this.street = street; + } + + /** + * Get the city. + * @return The city component of the address. + */ + public String getCity() { + return city; + } + + /** + * Set the city component of the address. + * @param city The city. + */ + public void setCity(String city) { + this.city = city; + } + + /** + * Get the state component of the address. + * @return The state. + */ + public String getState() { + return state; + } + + /** + * Set the state component of the address. + * @param state The state. + */ + public void setState(String state) { + this.state = state; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) addrid; - } - - /** - * This class is used to represent the application identifier for the Address class. - */ - public static class Oid implements Serializable, Comparable { /** - * This is the identifier field for Address and must correspond in type and name to - * the field in Address. + * Get the zipcode component of the address. + * @return The zipcode. */ - public long addrid; + public String getZipcode() { + return zipcode; + } - /** The required public, no-arg constructor. */ - public Oid() { - addrid = 0; + /** + * Set the zip code component of the address. + * @param zipcode The zipcode. + */ + public void setZipcode(String zipcode) { + this.zipcode = zipcode; } /** - * A constructor to initialize the identifier field. - * - * @param addrid the id of the Address. + * Get the country component of the address. + * @return The country. */ - public Oid(long addrid) { - this.addrid = addrid; + public String getCountry() { + return country; } - public Oid(String s) { - addrid = Long.parseLong(justTheId(s)); + /** + * Set the country component of the address. + * @param country The country. + */ + public void setCountry(String country) { + this.country = country; } + /** + * Returns a String representation of a Address object. + * @return a String representation of a Address object. + */ public String toString() { - return this.getClass().getName() + ": " + addrid; + return "Address(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(addrid); + rc.append(", street ").append(street); + rc.append(", city ").append(city); + rc.append(", state ").append(state); + rc.append(", zipcode ").append(zipcode); + rc.append(", country ").append(country); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCAppAddress otherAddress = (PCAppAddress)other; + String where = "Address<" + addrid + ">"; + return + helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") & + helper.equals(street, otherAddress.getStreet(), where + ".street") & + helper.equals(city, otherAddress.getCity(), where + ".city") & + helper.equals(state, otherAddress.getState(), where + ".state") & + helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") & + helper.equals(country, otherAddress.getCountry(), where + ".country"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((PCAppAddress)o); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.addrid != o.addrid) return (false); - return (true); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCAppAddress)o1, (PCAppAddress)o2); } - /** */ - public int hashCode() { - return ((int) addrid); + /** + * Compares this object with the specified Address object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Address object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Address + * object. + */ + public int compareTo(PCAppAddress other) { + return compare(this, other); + } + + /** + * Compares its two PCAppAddress arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * + * + * + * @param o1 the first PCAppAddresss object to be compared. + * @param o2 the second FFCPIAddressobject to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(PCAppAddress o1, PCAppAddress o2) { + return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof PCAppAddress) { + return compareTo((PCAppAddress)obj) == 0; + } + return false; } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (addrid < other.addrid) return -1; - if (addrid > other.addrid) return 1; - return 0; + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)addrid; + } + + /** + * This class is used to represent the application identifier + * for the Address class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This is the identifier field for Address and must + * correspond in type and name to the field in + * Address. + */ + public long addrid; + + /** The required public, no-arg constructor. */ + public Oid() + { + addrid = 0; + } + + /** + * A constructor to initialize the identifier field. + * @param addrid the id of the Address. + */ + public Oid(long addrid) { + this.addrid = addrid; + } + + public Oid(String s) { addrid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + addrid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.addrid != o.addrid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) addrid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( addrid < other.addrid ) return -1; + if( addrid > other.addrid ) return 1; + return 0; + } + } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppCompany.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppCompany.java index 14e03da50..b923da860 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppCompany.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppCompany.java @@ -5,396 +5,404 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; -import java.io.IOException; -import java.io.ObjectInputStream; +import javax.jdo.annotations.*; + import java.io.Serializable; +import java.io.ObjectInputStream; +import java.io.IOException; + import java.text.SimpleDateFormat; + +import java.util.Collections; import java.util.Comparator; -import java.util.Date; -import java.util.HashSet; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.Embedded; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.PersistenceModifier; -import javax.jdo.annotations.Persistent; +import java.util.HashSet; +import java.util.Date; import org.apache.jdo.tck.pc.company.IAddress; + import org.apache.jdo.tck.pc.company.ICompany; import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents information about a company. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION, table = "companies") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator(strategy = DiscriminatorStrategy.CLASS_NAME, column = "DISCRIMINATOR") -public class PCAppCompany implements ICompany, Serializable, Comparable, Comparator, DeepEquality { - - @NotPersistent() private long _companyid; - @NotPersistent() private String _name; - @NotPersistent() private Date _founded; - @NotPersistent() private PCAppAddress _address; - @NotPersistent() private transient Set _departments = new HashSet(); - - protected static SimpleDateFormat formatter = new SimpleDateFormat("d/MMM/yyyy"); - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public PCAppCompany() {} - - /** - * Initialize the PCAppCompany instance. - * - * @param companyid The company id. - * @param name The company name. - * @param founded The date the company was founded. - */ - public PCAppCompany(long companyid, String name, Date founded) { - this._companyid = companyid; - this._name = name; - this._founded = founded; - } - - /** - * Initialize the Company instance. - * - * @param companyid The company id. - * @param name The company name. - * @param founded The date the company was founded. - * @param addr The company's address. - */ - public PCAppCompany(long companyid, String name, Date founded, IAddress addr) { - this(companyid, name, founded); - this._address = (PCAppAddress) addr; - } - - /** - * Get the company id. - * - * @return The company id. - */ - @Persistent(primaryKey = "true") - @Column(name = "ID") - public long getCompanyid() { - return _companyid; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setCompanyid(long id) { - this._companyid = id; - } - - /** - * Get the name of the company. - * - * @return The name of the company. - */ - @Column(name = "NAME", jdbcType = "VARCHAR") - public String getName() { - return _name; - } - - /** - * Set the name of the company. - * - * @param name The value to use for the name of the company. - */ - public void setName(String name) { - this._name = name; - } - - /** - * Get the date that the company was founded. - * - * @return The date the company was founded. - */ - @Column(name = "FOUNDEDDATE") - public Date getFounded() { - return _founded; - } - - /** - * Set the date that the company was founded. - * - * @param founded The date to set that the company was founded. - */ - public void setFounded(Date founded) { - this._founded = founded; - } - - /** - * Get the address of the company. - * - * @return The primary address of the company. - */ - @Persistent( - persistenceModifier = PersistenceModifier.PERSISTENT, - types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppAddress.class) - @Embedded( - nullIndicatorColumn = "COUNTRY", - members = { - @Persistent(name = "addrid", columns = @Column(name = "ADDRID")), - @Persistent(name = "street", columns = @Column(name = "STREET")), - @Persistent(name = "city", columns = @Column(name = "CITY")), - @Persistent(name = "state", columns = @Column(name = "STATE")), - @Persistent(name = "zipcode", columns = @Column(name = "ZIPCODE")), - @Persistent(name = "country", columns = @Column(name = "COUNTRY")) - }) - public IAddress getAddress() { - return _address; - } - - /** - * Set the primary address for the company. - * - * @param address The address to set for the company. - */ - public void setAddress(IAddress address) { - this._address = (PCAppAddress) address; - } - - /** - * Get the departments contained in the company. - * - * @return All the PCAppDepartments of the company. - */ - @Persistent(persistenceModifier = PersistenceModifier.PERSISTENT, mappedBy = "company") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppDepartment.class) - public Set getDepartments() { - return _departments; - } - - /** - * Add a PCAppDepartment instance to the company. - * - * @param dept The PCAppDepartment instance to add. - */ - public void addDepartment(PCAppDepartment dept) { - _departments.add(dept); - } - - /** - * Remove a PCAppDepartment instance from the company. - * - * @param dept The PCAppDepartment instance to remove. - */ - public void removeDepartment(PCAppDepartment dept) { - _departments.remove(dept); - } - - /** - * Initialize the set of PCAppDepartments in the company to the parameter. - * - * @param departments The set of PCAppDepartments for the company. - */ - public void setDepartments(Set departments) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this._departments = (departments != null) ? new HashSet(departments) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - _departments = new HashSet(); - } - - /** - * Returns a String representation of a Company object. - * - * @return a String representation of a Company object. - */ - public String toString() { - return "Company(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(_companyid); - rc.append(", name ").append(_name); - rc.append(", founded ").append(_founded == null ? "null" : formatter.format(_founded)); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCAppCompany otherCompany = (PCAppCompany) other; - String where = "Company<" + _companyid + ">"; - return helper.equals(_companyid, otherCompany.getCompanyid(), where + ".companyid") - & helper.equals(_name, otherCompany.getName(), where + ".name") - & helper.equals(_founded, otherCompany.getFounded(), where + ".founded") - & helper.deepEquals(_address, otherCompany.getAddress(), where + ".address") - & helper.deepEquals(_departments, otherCompany.getDepartments(), where + ".departments"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((PCAppCompany) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((PCAppCompany) o1, (PCAppCompany) o2); - } - - /** - * Compares this object with the specified Company object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Company object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Company object. - */ - public int compareTo(PCAppCompany other) { - return compare(this, other); - } - - /** - * Compares its two ICompany arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first ICompany object to be compared. - * @param o2 the second ICompany object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(PCAppCompany o1, PCAppCompany o2) { - return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof PCAppCompany) { - return compareTo((PCAppCompany) obj) == 0; +/** + * This class represents information about a company. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION,table="companies") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") + public class PCAppCompany + implements ICompany, Serializable, Comparable, Comparator, DeepEquality { + + @NotPersistent() + private long _companyid; + @NotPersistent() + private String _name; + @NotPersistent() + private Date _founded; + @NotPersistent() + private PCAppAddress _address; + @NotPersistent() + private transient Set _departments = new HashSet(); + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCAppCompany() {} + + /** + * + * Initialize the PCAppCompany instance. + * + * + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + */ + public PCAppCompany(long companyid, String name, Date founded) { + this._companyid = companyid; + this._name = name; + this._founded = founded; + } + + /** + * Initialize the Company instance. + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + * @param addr The company's address. + */ + public PCAppCompany(long companyid, String name, Date founded, IAddress addr) { + this(companyid, name, founded); + this._address = (PCAppAddress)addr; + } + + /** + * Get the company id. + * @return The company id. + */ + @Persistent(primaryKey="true") + @Column(name="ID") + public long getCompanyid() { + return _companyid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setCompanyid(long id) { + this._companyid = id; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) _companyid; - } - - /** - * The class to be used as the application identifier for the Company class. It - * consists of both the company name and the date that the company was founded. - */ - public static class Oid implements Serializable, Comparable { /** - * This field is part of the identifier and should match in name and type with a field in the - * Company class. + * Get the name of the company. + * @return The name of the company. */ - public long companyid; + @Column(name="NAME", jdbcType="VARCHAR") + public String getName() { + return _name; + } - /** The required public no-arg constructor. */ - public Oid() {} + /** + * Set the name of the company. + * @param name The value to use for the name of the company. + */ + public void setName(String name) { + this._name = name; + } + + /** + * Get the date that the company was founded. + * @return The date the company was founded. + */ + @Column(name="FOUNDEDDATE") + public Date getFounded() { + return _founded; + } /** - * Initialize the identifier. - * - * @param companyid The id of the company. + * Set the date that the company was founded. + * @param founded The date to set that the company was founded. */ - public Oid(long companyid) { - this.companyid = companyid; + public void setFounded(Date founded) { + this._founded = founded; } - public Oid(String s) { - companyid = Long.parseLong(justTheId(s)); + /** + * Get the address of the company. + * @return The primary address of the company. + */ + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT, + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppAddress.class) + @Embedded(nullIndicatorColumn="COUNTRY", + members={ + @Persistent(name="addrid", columns=@Column(name="ADDRID")), + @Persistent(name="street", columns=@Column(name="STREET")), + @Persistent(name="city", columns=@Column(name="CITY")), + @Persistent(name="state", columns=@Column(name="STATE")), + @Persistent(name="zipcode", columns=@Column(name="ZIPCODE")), + @Persistent(name="country", columns=@Column(name="COUNTRY")) + }) + public IAddress getAddress() { + return _address; + } + + /** + * Set the primary address for the company. + * @param address The address to set for the company. + */ + public void setAddress(IAddress address) { + this._address = (PCAppAddress)address; } + /** + * Get the departments contained in the company. + * + * + * @return All the PCAppDepartments of the company. + */ + + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT, + mappedBy="company") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppDepartment.class) + public Set getDepartments() { + return _departments; + } + + /** + * Add a PCAppDepartment instance to the company. + * + * + * @param dept The PCAppDepartment instance to add. + */ + public void addDepartment(PCAppDepartment dept) { + _departments.add(dept); + } + + /** + * Remove a PCAppDepartment instance from the company. + * + * + * @param dept The PCAppDepartment instance to remove. + */ + public void removeDepartment(PCAppDepartment dept) { + _departments.remove(dept); + } + + /** + * Initialize the set of PCAppDepartments in the company to the + * parameter. + * + * + * @param departments The set of PCAppDepartments for the + * company. + */ + public void setDepartments(Set departments) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._departments = + (departments != null) ? new HashSet(departments) : null; + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + _departments = new HashSet(); + } + + /** + * Returns a String representation of a Company object. + * @return a String representation of a Company object. + */ public String toString() { - return this.getClass().getName() + ": " + companyid; + return "Company(" + getFieldRepr()+ ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(_companyid); + rc.append(", name ").append(_name); + rc.append(", founded ").append( + _founded==null ? "null" : formatter.format(_founded)); + return rc.toString(); } - /** */ - public boolean equals(Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return false; - Oid o = (Oid) obj; - if (this.companyid != o.companyid) return false; - return true; + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCAppCompany otherCompany = (PCAppCompany)other; + String where = "Company<" + _companyid + ">"; + return + helper.equals(_companyid, otherCompany.getCompanyid(), where + ".companyid") & + helper.equals(_name, otherCompany.getName(), where + ".name") & + helper.equals(_founded, otherCompany.getFounded(), where + ".founded") & + helper.deepEquals(_address, otherCompany.getAddress(), where + ".address") & + helper.deepEquals(_departments, otherCompany.getDepartments(), where + ".departments"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((PCAppCompany)o); } - /** */ - public int hashCode() { - return (int) companyid; + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCAppCompany)o1, (PCAppCompany)o2); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compares this object with the specified Company object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Company object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Company + * object. + */ + public int compareTo(PCAppCompany other) { + return compare(this, other); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (companyid < other.companyid) return -1; - if (companyid > other.companyid) return 1; - return 0; + /** + * Compares its two ICompany arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first ICompany object to be compared. + * @param o2 the second ICompany object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(PCAppCompany o1, PCAppCompany o2) { + return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); } - } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof PCAppCompany) { + return compareTo((PCAppCompany)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)_companyid; + } + + /** + * The class to be used as the application identifier + * for the Company class. It consists of both the company + * name and the date that the company was founded. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field is part of the identifier and should match in name + * and type with a field in the Company class. + */ + public long companyid; + + /** The required public no-arg constructor. */ + public Oid() { } + + /** + * Initialize the identifier. + * @param companyid The id of the company. + */ + public Oid(long companyid) { + this.companyid = companyid; + } + + public Oid(String s) { companyid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + companyid;} + + + /** */ + public boolean equals(Object obj) { + if (obj==null || !this.getClass().equals(obj.getClass())) + return false; + Oid o = (Oid) obj; + if (this.companyid != o.companyid) + return false; + return true; + } + + /** */ + public int hashCode() { + return (int)companyid; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( companyid < other.companyid ) return -1; + if( companyid > other.companyid ) return 1; + return 0; + } + + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDentalInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDentalInsurance.java index 4a22a4226..0ccf0251f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDentalInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDentalInsurance.java @@ -5,125 +5,127 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; +import javax.jdo.annotations.*; + import java.math.BigDecimal; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; + import org.apache.jdo.tck.pc.company.IDentalInsurance; import org.apache.jdo.tck.pc.company.IEmployee; import org.apache.jdo.tck.util.EqualityHelper; /** - * This class represents a dental insurance carrier selection for a particular Employee - * . + * This class represents a dental insurance carrier selection for a + * particular Employee. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION) +@PersistenceCapable(identityType=IdentityType.APPLICATION) public class PCAppDentalInsurance extends PCAppInsurance implements IDentalInsurance { - @NotPersistent() private BigDecimal _lifetimeOrthoBenefit; + @NotPersistent() + private BigDecimal _lifetimeOrthoBenefit; - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public PCAppDentalInsurance() {} + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCAppDentalInsurance() {} - /** - * Construct a DentalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. - */ - public PCAppDentalInsurance(long insid, String carrier, BigDecimal lifetimeOrthoBenefit) { - super(insid, carrier); - this._lifetimeOrthoBenefit = lifetimeOrthoBenefit; - } + /** + * Construct a DentalInsurance instance. + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public PCAppDentalInsurance(long insid, String carrier, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier); + this._lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } - /** - * Construct a PCAppDentalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param employee The employee associated with this insurance. - * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. - */ - public PCAppDentalInsurance( - long insid, String carrier, IEmployee employee, BigDecimal lifetimeOrthoBenefit) { - super(insid, carrier, employee); - this._lifetimeOrthoBenefit = lifetimeOrthoBenefit; - } + /** + * Construct a PCAppDentalInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public PCAppDentalInsurance(long insid, String carrier, IEmployee employee, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier, employee); + this._lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } - /** - * Get the insurance lifetimeOrthoBenefit. - * - * @return The insurance lifetimeOrthoBenefit. - */ - @Column(name = "LIFETIME_ORTHO_BENEFIT") - public BigDecimal getLifetimeOrthoBenefit() { - return _lifetimeOrthoBenefit; - } + /** + * Get the insurance lifetimeOrthoBenefit. + * @return The insurance lifetimeOrthoBenefit. + */ + @Column(name="LIFETIME_ORTHO_BENEFIT") + public BigDecimal getLifetimeOrthoBenefit() { + return _lifetimeOrthoBenefit; + } - /** - * Set the insurance lifetimeOrthoBenefit. - * - * @param lifetimeOrthoBenefit The insurance lifetimeOrthoBenefit. - */ - public void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit) { - this._lifetimeOrthoBenefit = lifetimeOrthoBenefit; - } + /** + * Set the insurance lifetimeOrthoBenefit. + * @param lifetimeOrthoBenefit The insurance lifetimeOrthoBenefit. + */ + public void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit) { + this._lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } - /** - * Returns a String representation of a PCAppDentalInsurance object. - * - * @return a String representation of a PCAppDentalInsurance object. - */ - public String toString() { - return "FCDentalInsurance(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of a PCAppDentalInsurance + * object. + * + * + * @return a String representation of a PCAppDentalInsurance + * object. + */ + public String toString() { + return "FCDentalInsurance(" + getFieldRepr()+ ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", lifetimeOrthoBenefit ").append(_lifetimeOrthoBenefit); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", lifetimeOrthoBenefit ").append(_lifetimeOrthoBenefit); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCAppDentalInsurance otherIns = (PCAppDentalInsurance)other; + String where = "FCDentalInsurance<" + getInsid() + ">"; + return super.deepCompareFields(otherIns, helper) & + helper.equals(_lifetimeOrthoBenefit, + otherIns.getLifetimeOrthoBenefit(), where + ".lifetimeOrthoBenefit"); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Object. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCAppDentalInsurance otherIns = (PCAppDentalInsurance) other; - String where = "FCDentalInsurance<" + getInsid() + ">"; - return super.deepCompareFields(otherIns, helper) - & helper.equals( - _lifetimeOrthoBenefit, - otherIns.getLifetimeOrthoBenefit(), - where + ".lifetimeOrthoBenefit"); - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDepartment.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDepartment.java index fc49947fb..f2b0683a1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDepartment.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppDepartment.java @@ -5,451 +5,455 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; -import java.io.IOException; -import java.io.ObjectInputStream; +import javax.jdo.annotations.*; + import java.io.Serializable; +import java.io.ObjectInputStream; +import java.io.IOException; + +import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; -import javax.jdo.annotations.PrimaryKey; import org.apache.jdo.tck.pc.company.ICompany; + import org.apache.jdo.tck.pc.company.IDepartment; import org.apache.jdo.tck.pc.company.IEmployee; import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a department within a company. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION, table = "departments") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator(strategy = DiscriminatorStrategy.CLASS_NAME, column = "DISCRIMINATOR") +/** + * This class represents a department within a company. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION, table="departments") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") public class PCAppDepartment implements IDepartment, Serializable, Comparable, Comparator, DeepEquality { - public static final int RECOMMENDED_NO_OF_EMPS = 2; - - @NotPersistent() private long _deptid; - @NotPersistent() private String _name; - @NotPersistent() private PCAppCompany _company; - @NotPersistent() private PCAppEmployee _employeeOfTheMonth; - @NotPersistent() private transient Set _employees = new HashSet(); - @NotPersistent() private transient Set _fundedEmps = new HashSet(); - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public PCAppDepartment() {} - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - */ - public PCAppDepartment(long deptid, String name) { - this._deptid = deptid; - this._name = name; - } - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - * @param company The company that the department is associated with. - */ - public PCAppDepartment(long deptid, String name, ICompany company) { - this._deptid = deptid; - this._name = name; - this._company = (PCAppCompany) company; - } - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - * @param company The company that the department is associated with. - * @param employeeOfTheMonth The employee of the month the department is associated with. - */ - public PCAppDepartment(long deptid, String name, ICompany company, IEmployee employeeOfTheMonth) { - this._deptid = deptid; - this._name = name; - this._company = (PCAppCompany) company; - this._employeeOfTheMonth = (PCAppEmployee) employeeOfTheMonth; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setDeptid(long id) { - this._deptid = id; - } - - /** - * Get the department id. - * - * @return The department id. - */ - @PrimaryKey - @Column(name = "ID") - public long getDeptid() { - return _deptid; - } - - /** - * Get the name of the department. - * - * @return The name of the department. - */ - @Column(name = "NAME") - public String getName() { - return _name; - } - - /** - * Set the name of the department. - * - * @param name The name to set for the department. - */ - public void setName(String name) { - this._name = name; - } - - /** - * Get the company associated with the department. - * - * @return The company. - */ - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppCompany.class) - @Column(name = "COMPANYID") - public ICompany getCompany() { - return _company; - } - - /** - * Set the company for the department. - * - * @param company The company to associate with the department. - */ - public void setCompany(ICompany company) { - this._company = (PCAppCompany) company; - } - - /** - * Get the employee of the month associated with the department. - * - * @return The employee of the month. - */ - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) - @Column(name = "EMP_OF_THE_MONTH") - public IEmployee getEmployeeOfTheMonth() { - return _employeeOfTheMonth; - } - - /** - * Set the employee of the month for the department. - * - * @param employeeOfTheMonth The employee of the month to associate with the department. - */ - public void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth) { - this._employeeOfTheMonth = (PCAppEmployee) employeeOfTheMonth; - } - - /** - * Get the employees in the department. - * - * @return The set of employees in the department. - */ - @Persistent(mappedBy = "department") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) - public Set getEmployees() { - return _employees; - } - - /** - * Add an employee to the department. - * - * @param emp The employee to add to the department. - */ - public void addEmployee(PCAppEmployee emp) { - _employees.add(emp); - } - - /** - * Remove an employee from the department. - * - * @param emp The employee to remove from the department. - */ - public void removeEmployee(PCAppEmployee emp) { - _employees.remove(emp); - } - - /** - * Set the employees to be in this department. - * - * @param employees The set of employees for this department. - */ - public void setEmployees(Set employees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this._employees = (employees != null) ? new HashSet(employees) : null; - } - - /** - * Get the funded employees in the department. - * - * @return The set of funded employees in the department. - */ - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) - @Persistent(mappedBy = "fundingDept") - public Set getFundedEmps() { - return _fundedEmps; - } - - /** - * Add an employee to the collection of funded employees of this department. - * - * @param emp The employee to add to the department. - */ - public void addFundedEmp(PCAppEmployee emp) { - _fundedEmps.add(emp); - } - - /** - * Remove an employee from collection of funded employees of this department. - * - * @param emp The employee to remove from the department. - */ - public void removeFundedEmp(PCAppEmployee emp) { - _fundedEmps.remove(emp); - } - - /** - * Set the funded employees to be in this department. - * - * @param employees The set of funded employees for this department. - */ - public void setFundedEmps(Set employees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this._fundedEmps = (employees != null) ? new HashSet(employees) : null; - } - - @Override - public List getMeetingRooms() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void setMeetingRooms(List rooms) { - // TODO Auto-generated method stub - - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - _employees = new HashSet(); - _fundedEmps = new HashSet(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other PCAppDepartment. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCAppDepartment otherDept = (PCAppDepartment) other; - String where = "FCDepartment<" + _deptid + ">"; - return helper.equals(_deptid, otherDept.getDeptid(), where + ".deptid") - & helper.equals(_name, otherDept.getName(), where + ".name") - & helper.deepEquals(_company, otherDept.getCompany(), where + ".company") - & helper.deepEquals( - _employeeOfTheMonth, otherDept.getEmployeeOfTheMonth(), where + ".employeeOfTheMonth") - & helper.deepEquals(_employees, otherDept.getEmployees(), where + ".employees") - & helper.deepEquals(_fundedEmps, otherDept.getFundedEmps(), where + ".fundedEmps"); - } - - /** - * Returns a String representation of a PCAppDepartment object. - * - * @return a String representation of a PCAppDepartment object. - */ - public String toString() { - return "FCDepartment(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(_deptid); - rc.append(", name ").append(_name); - return rc.toString(); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((PCAppDepartment) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((PCAppDepartment) o1, (PCAppDepartment) o2); - } - - /** - * Compares this object with the specified Department object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Department object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Department object. - */ - public int compareTo(PCAppDepartment other) { - return compare(this, other); - } - - /** - * Compares its two IDepartment arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IDepartment object to be compared. - * @param o2 the second IDepartment object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(PCAppDepartment o1, PCAppDepartment o2) { - return EqualityHelper.compare(o1.getDeptid(), o2.getDeptid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof PCAppDepartment) { - return compareTo((PCAppDepartment) obj) == 0; + public static final int RECOMMENDED_NO_OF_EMPS = 2; + + @NotPersistent() + private long _deptid; + @NotPersistent() + private String _name; + @NotPersistent() + private PCAppCompany _company; + @NotPersistent() + private PCAppEmployee _employeeOfTheMonth; + @NotPersistent() + private transient Set _employees = new HashSet(); + @NotPersistent() + private transient Set _fundedEmps = new HashSet(); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCAppDepartment() {} + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + */ + public PCAppDepartment(long deptid, String name) { + this._deptid = deptid; + this._name = name; + } + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + * @param company The company that the department is associated with. + */ + public PCAppDepartment(long deptid, String name, ICompany company) { + this._deptid = deptid; + this._name = name; + this._company = (PCAppCompany)company; + } + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + * @param company The company that the department is associated with. + * @param employeeOfTheMonth The employee of the month the + * department is associated with. + */ + public PCAppDepartment(long deptid, String name, ICompany company, + IEmployee employeeOfTheMonth) { + this._deptid = deptid; + this._name = name; + this._company = (PCAppCompany)company; + this._employeeOfTheMonth = (PCAppEmployee)employeeOfTheMonth; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setDeptid(long id) { + this._deptid = id; + } + + /** + * Get the department id. + * @return The department id. + */ + + @PrimaryKey + @Column(name="ID") + public long getDeptid() { + return _deptid; + } + + /** + * Get the name of the department. + * @return The name of the department. + */ + @Column(name="NAME") + public String getName() { + return _name; + } + + /** + * Set the name of the department. + * @param name The name to set for the department. + */ + public void setName(String name) { + this._name = name; + } + + /** + * Get the company associated with the department. + * @return The company. + */ + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppCompany.class) + @Column(name="COMPANYID") + public ICompany getCompany() { + return _company; + } + + /** + * Set the company for the department. + * @param company The company to associate with the department. + */ + public void setCompany(ICompany company) { + this._company = (PCAppCompany)company; + } + + /** + * Get the employee of the month associated with the department. + * @return The employee of the month. + */ + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + @Column(name="EMP_OF_THE_MONTH") + public IEmployee getEmployeeOfTheMonth() { + return _employeeOfTheMonth; + } + + /** + * Set the employee of the month for the department. + * @param employeeOfTheMonth The employee of the month to + * associate with the department. + */ + public void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth) { + this._employeeOfTheMonth = (PCAppEmployee)employeeOfTheMonth; + } + + /** + * Get the employees in the department. + * @return The set of employees in the department. + */ + + @Persistent(mappedBy="department") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + public Set getEmployees() { + return _employees; + } + + /** + * Add an employee to the department. + * @param emp The employee to add to the department. + */ + public void addEmployee(PCAppEmployee emp) { + _employees.add(emp); + } + + /** + * Remove an employee from the department. + * @param emp The employee to remove from the department. + */ + public void removeEmployee(PCAppEmployee emp) { + _employees.remove(emp); + } + + /** + * Set the employees to be in this department. + * @param employees The set of employees for this department. + */ + public void setEmployees(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._employees = (employees != null) ? new HashSet(employees) : null; } - return false; - } - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) _deptid; - } + /** + * Get the funded employees in the department. + * @return The set of funded employees in the department. + */ - /** The application identity class associated with the Department class. */ - public static class Oid implements Serializable, Comparable { + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + @Persistent(mappedBy="fundingDept") + public Set getFundedEmps() { + return _fundedEmps; + } /** - * This field represents the application identifier field for the Department class. - * It must match in name and type with the field in the Department class. + * Add an employee to the collection of funded employees of this + * department. + * @param emp The employee to add to the department. */ - public long deptid; + public void addFundedEmp(PCAppEmployee emp) { + _fundedEmps.add(emp); + } - /** The required public, no-arg constructor. */ - public Oid() {} + /** + * Remove an employee from collection of funded employees of this + * department. + * @param emp The employee to remove from the department. + */ + public void removeFundedEmp(PCAppEmployee emp) { + _fundedEmps.remove(emp); + } /** - * A constructor to initialize the identifier field. - * - * @param deptid the deptid of the Department. + * Set the funded employees to be in this department. + * @param employees The set of funded employees for this department. */ - public Oid(long deptid) { - this.deptid = deptid; + public void setFundedEmps(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._fundedEmps = (employees != null) ? new HashSet(employees) : null; } - public Oid(String s) { - deptid = Long.parseLong(justTheId(s)); + @Override + public List getMeetingRooms() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setMeetingRooms(List rooms) { + // TODO Auto-generated method stub + + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + _employees = new HashSet(); + _fundedEmps = new HashSet(); } + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other PCAppDepartment. + * + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCAppDepartment otherDept = (PCAppDepartment)other; + String where = "FCDepartment<" + _deptid + ">"; + return + helper.equals(_deptid, otherDept.getDeptid(), where + ".deptid") & + helper.equals(_name, otherDept.getName(), where + ".name") & + helper.deepEquals(_company, otherDept.getCompany(), where + ".company") & + helper.deepEquals(_employeeOfTheMonth, otherDept.getEmployeeOfTheMonth(), where + ".employeeOfTheMonth") & + helper.deepEquals(_employees, otherDept.getEmployees(), where + ".employees") & + helper.deepEquals(_fundedEmps, otherDept.getFundedEmps(), where + ".fundedEmps"); + } + + /** + * Returns a String representation of a PCAppDepartment object. + * + * + * @return a String representation of a PCAppDepartment object. + */ public String toString() { - return this.getClass().getName() + ": " + deptid; + return "FCDepartment(" + getFieldRepr()+ ")"; } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.deptid != o.deptid) return (false); - return (true); + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(_deptid); + rc.append(", name ").append(_name); + return rc.toString(); } - /** */ - public int hashCode() { - return ((int) deptid); + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((PCAppDepartment)o); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCAppDepartment)o1, (PCAppDepartment)o2); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (deptid < other.deptid) return -1; - if (deptid > other.deptid) return 1; - return 0; + /** + * Compares this object with the specified Department object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Department object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified + * Department object. + */ + public int compareTo(PCAppDepartment other) { + return compare(this, other); + } + + /** + * Compares its two IDepartment arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IDepartment object to be compared. + * @param o2 the second IDepartment object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(PCAppDepartment o1, PCAppDepartment o2) { + return EqualityHelper.compare(o1.getDeptid(), o2.getDeptid()); } - } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof PCAppDepartment) { + return compareTo((PCAppDepartment)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)_deptid; + } + + /** + * The application identity class associated with the + * Department class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the application identifier field + * for the Department class. + * It must match in name and type with the field in the + * Department class. + */ + public long deptid; + + /** + * The required public, no-arg constructor. + */ + public Oid() { } + + /** + * A constructor to initialize the identifier field. + * @param deptid the deptid of the Department. + */ + public Oid(long deptid) { + this.deptid = deptid; + } + + public Oid(String s) { deptid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + deptid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.deptid != o.deptid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) deptid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( deptid < other.deptid ) return -1; + if( deptid > other.deptid ) return 1; + return 0; + } + + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppEmployee.java index 192c5962a..1794a2a65 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppEmployee.java @@ -5,542 +5,541 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; -import java.io.IOException; +import javax.jdo.annotations.*; + import java.io.ObjectInputStream; +import java.io.IOException; + +import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; import org.apache.jdo.tck.pc.company.IAddress; import org.apache.jdo.tck.pc.company.IDentalInsurance; import org.apache.jdo.tck.pc.company.IDepartment; + import org.apache.jdo.tck.pc.company.IEmployee; import org.apache.jdo.tck.pc.company.IMedicalInsurance; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents an employee. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION) -@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE) +/** + * This class represents an employee. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION) +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) public abstract class PCAppEmployee extends PCAppPerson implements IEmployee { - @NotPersistent() private Date _hiredate; - @NotPersistent() private double _weeklyhours; - @NotPersistent() private PCAppDentalInsurance _dentalInsurance; - @NotPersistent() private PCAppMedicalInsurance _medicalInsurance; - @NotPersistent() private PCAppDepartment _department; - @NotPersistent() private PCAppDepartment _fundingDept; - @NotPersistent() private PCAppEmployee _manager; - @NotPersistent() private PCAppEmployee _mentor; - @NotPersistent() private PCAppEmployee _protege; - @NotPersistent() private PCAppEmployee _hradvisor; - @NotPersistent() private transient Set _reviewedProjects = new HashSet(); - @NotPersistent() private transient Set _projects = new HashSet(); - @NotPersistent() private transient Set _team = new HashSet(); - @NotPersistent() private transient Set _hradvisees = new HashSet(); - - /** This is the JDO-required no-args constructor */ - protected PCAppEmployee() {} - - /** - * Construct an PCAppEmployee instance. - * - * @param personid The identifier for the person. - * @param firstname The first name of the employee. - * @param lastname The last name of the employee. - * @param middlename The middle name of the employee. - * @param birthdate The birth date of the employee. - * @param hiredate The date that the employee was hired. - */ - public PCAppEmployee( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - Date hiredate) { - super(personid, firstname, lastname, middlename, birthdate); - this._hiredate = hiredate; - } - - /** - * Construct an PCAppEmployee instance. - * - * @param personid The identifier for the person. - * @param firstname The first name of the employee. - * @param lastname The last name of the employee. - * @param middlename The middle name of the employee. - * @param birthdate The birth date of the employee. - * @param address The address of the employee. - * @param hiredate The date that the employee was hired. - */ - public PCAppEmployee( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - IAddress address, - Date hiredate) { - super(personid, firstname, lastname, middlename, birthdate, (PCAppAddress) address); - this._hiredate = hiredate; - } - - /** - * Get the date that the employee was hired. - * - * @return The date the employee was hired. - */ - @Column(name = "HIREDATE") - public Date getHiredate() { - return _hiredate; - } - - /** - * Set the date that the employee was hired. - * - * @param hiredate The date the employee was hired. - */ - public void setHiredate(Date hiredate) { - this._hiredate = hiredate; - } - - /** - * Get the weekly hours of the employee. - * - * @return The number of hours per week that the employee works. - */ - @Column(name = "WEEKLYHOURS") - public double getWeeklyhours() { - return _weeklyhours; - } - - /** - * Set the number of hours per week that the employee works. - * - * @param weeklyhours The number of hours per week that the employee works. - */ - public void setWeeklyhours(double weeklyhours) { - this._weeklyhours = weeklyhours; - } - - /** - * Get the reviewed projects. - * - * @return The reviewed projects. - */ - @Persistent(mappedBy = "reviewers") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppProject.class) - public Set getReviewedProjects() { - return _reviewedProjects; - } - - /** - * Add a reviewed project. - * - * @param project A reviewed project. - */ - public void addReviewedProjects(PCAppProject project) { - _reviewedProjects.add(project); - } - - /** - * Remove a reviewed project. - * - * @param project A reviewed project. - */ - public void removeReviewedProject(PCAppProject project) { - _reviewedProjects.remove(project); - } - - /** - * Set the reviewed projects for the employee. - * - * @param reviewedProjects The set of reviewed projects. - */ - public void setReviewedProjects(Set reviewedProjects) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this._reviewedProjects = (reviewedProjects != null) ? new HashSet(reviewedProjects) : null; - } - - /** - * Get the employee's projects. - * - * @return The employee's projects set. - */ - @Persistent(mappedBy = "members") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppProject.class) - public Set getProjects() { - return _projects; - } - - /** - * Add a project for the employee. - * - * @param project The project. - */ - public void addProject(PCAppProject project) { - _projects.add(project); - } - - /** - * Remove a project from an employee's set of projects. - * - * @param project The project. - */ - public void removeProject(PCAppProject project) { - _projects.remove(project); - } - - /** - * Set the projects for the employee. - * - * @param projects The set of projects of the employee. - */ - public void setProjects(Set projects) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this._projects = (projects != null) ? new HashSet(projects) : null; - } - - /** - * Get the dental insurance of the employee. - * - * @return The employee's dental insurance. - */ - @Persistent( - mappedBy = "employee", - types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppDentalInsurance.class) - public IDentalInsurance getDentalInsurance() { - return _dentalInsurance; - } - - /** - * Set the dental insurance object for the employee. - * - * @param dentalInsurance The dental insurance object to associate with the employee. - */ - public void setDentalInsurance(IDentalInsurance dentalInsurance) { - this._dentalInsurance = (PCAppDentalInsurance) dentalInsurance; - } - /** - * Get the medical insurance of the employee. - * - * @return The employee's medical insurance. - */ - @Persistent( - mappedBy = "employee", - types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppMedicalInsurance.class) - public IMedicalInsurance getMedicalInsurance() { - return _medicalInsurance; - } - - /** - * Set the medical insurance object for the employee. - * - * @param medicalInsurance The medical insurance object to associate with the employee. - */ - public void setMedicalInsurance(IMedicalInsurance medicalInsurance) { - this._medicalInsurance = (PCAppMedicalInsurance) medicalInsurance; - } - - /** - * Get the employee's department. - * - * @return The department associated with the employee. - */ - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppDepartment.class) - @Column(name = "DEPARTMENT") - public IDepartment getDepartment() { - return _department; - } - - /** - * Set the employee's department. - * - * @param department The department. - */ - public void setDepartment(IDepartment department) { - this._department = (PCAppDepartment) department; - } - - /** - * Get the employee's funding department. - * - * @return The funding department associated with the employee. - */ - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppDepartment.class) - @Column(name = "FUNDINGDEPT") - public IDepartment getFundingDept() { - return _fundingDept; - } - - /** - * Set the employee's funding department. - * - * @param department The funding department. - */ - public void setFundingDept(IDepartment department) { - this._fundingDept = (PCAppDepartment) department; - } - - /** - * Get the employee's manager. - * - * @return The employee's manager. - */ - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) - @Column(name = "MANAGER") - public IEmployee getManager() { - return _manager; - } - - /** - * Set the employee's manager. - * - * @param manager The employee's manager. - */ - public void setManager(IEmployee manager) { - this._manager = (PCAppEmployee) manager; - } - - /** - * Get the employee's team. - * - * @return The set of PCAppEmployees on this employee's team. - */ - @Persistent(mappedBy = "manager") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) - public Set getTeam() { - return _team; - } - - /** - * Add an PCAppEmployee to this employee's team. This method sets both sides of the - * relationship, modifying this employees team to include parameter emp and modifying emp to set - * its manager attribute to this object. - * - * @param emp The PCAppEmployee to add to the team. - */ - public void addToTeam(PCAppEmployee emp) { - _team.add(emp); - emp._manager = this; - } - - /** - * Remove an PCAppEmployee from this employee's team. This method will also set the - * emp manager to null. - * - * @param emp The PCAppEmployee to remove from the team. - */ - public void removeFromTeam(PCAppEmployee emp) { - _team.remove(emp); - emp._manager = null; - } - - /** - * Set the employee's team. - * - * @param team The set of PCAppEmployees. - */ - public void setTeam(Set team) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this._team = (team != null) ? new HashSet(team) : null; - } - - /** - * Set the mentor for this employee. - * - * @param mentor The mentor for this employee. - */ - public void setMentor(IEmployee mentor) { - this._mentor = (PCAppEmployee) mentor; - } - - /** - * Get the mentor for this employee. - * - * @return The mentor. - */ - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) - @Column(name = "MENTOR") - public IEmployee getMentor() { - return _mentor; - } - - /** - * Set the protege for this employee. - * - * @param protege The protege for this employee. - */ - public void setProtege(IEmployee protege) { - this._protege = (PCAppEmployee) protege; - } - - /** - * Get the protege of this employee. - * - * @return The protege of this employee. - */ - @Persistent( - mappedBy = "mentor", - types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) - public IEmployee getProtege() { - return _protege; - } - - /** - * Set the HR advisor for this employee. - * - * @param hradvisor The hradvisor for this employee. - */ - public void setHradvisor(IEmployee hradvisor) { - this._hradvisor = (PCAppEmployee) hradvisor; - } - - /** - * Get the HR advisor for the employee. - * - * @return The HR advisor. - */ - @Column(name = "HRADVISOR") - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) - public IEmployee getHradvisor() { - return _hradvisor; - } - - /** - * Get the HR advisees of this HR advisor. - * - * @return HR advisees of this employee. - */ - @Persistent(mappedBy = "hradvisor") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) - public Set getHradvisees() { - return _hradvisees; - } - - /** - * Add an PCAppEmployee as an advisee of this HR advisor. This method also sets the - * emp hradvisor to reference this object. In other words, both sides of the - * relationship are set. - * - * @param emp The employee to add as an advisee. - */ - public void addAdvisee(PCAppEmployee emp) { - _hradvisees.add(emp); - emp._hradvisor = this; - } - - /** - * Remove an PCAppEmployee as an advisee of this HR advisor. This method also sets - * the emp hradvisor to null. In other words, both sides of the relationship are set. - * - * @param emp The employee to add as an HR advisee. - */ - public void removeAdvisee(PCAppEmployee emp) { - _hradvisees.remove(emp); - emp._hradvisor = null; - } - - /** - * Set the HR advisees of this HR advisor. - * - * @param hradvisees The PCAppEmployees that are HR advisees of this employee. - */ - public void setHradvisees(Set hradvisees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this._hradvisees = (hradvisees != null) ? new HashSet(hradvisees) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - _reviewedProjects = new HashSet(); - _projects = new HashSet(); - _team = new HashSet(); - _hradvisees = new HashSet(); - } - - /** - * Return a String representation of a PCAppEmployee object. - * - * @return a String representation of a PCAppEmployee object. - */ - public String toString() { - return "FCEmployee(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", hired ").append(_hiredate == null ? "null" : formatter.format(_hiredate)); - rc.append(", weeklyhours ").append(_weeklyhours); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the - * corresponding fields of the specified PCAppEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCAppEmployee otherEmp = (PCAppEmployee) other; - String where = "Employee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.equals(_hiredate, otherEmp.getHiredate(), where + ".hiredate") - & helper.closeEnough(_weeklyhours, otherEmp.getWeeklyhours(), where + ".weeklyhours") - & helper.deepEquals( - _dentalInsurance, otherEmp.getDentalInsurance(), where + ".dentalInsurance") - & helper.deepEquals( - _medicalInsurance, otherEmp.getMedicalInsurance(), where + ".medicalInsurance") - & helper.deepEquals(_department, otherEmp.getDepartment(), where + ".department") - & helper.deepEquals(_fundingDept, otherEmp.getFundingDept(), where + ".fundingDept") - & helper.deepEquals(_manager, otherEmp.getManager(), where + ".manager") - & helper.deepEquals(_mentor, otherEmp.getMentor(), where + ".mentor") - & helper.deepEquals(_protege, otherEmp.getProtege(), where + ".protege") - & helper.deepEquals(_hradvisor, otherEmp.getHradvisor(), where + ".hradvisor") - & helper.deepEquals( - _reviewedProjects, otherEmp.getReviewedProjects(), where + ".reviewedProjects") - & helper.deepEquals(_projects, otherEmp.getProjects(), where + ".projects") - & helper.deepEquals(_team, otherEmp.getTeam(), where + ".team") - & helper.deepEquals(_hradvisees, otherEmp.getHradvisees(), where + ".hradvisees"); - } + @NotPersistent() + private Date _hiredate; + @NotPersistent() + private double _weeklyhours; + @NotPersistent() + private PCAppDentalInsurance _dentalInsurance; + @NotPersistent() + private PCAppMedicalInsurance _medicalInsurance; + @NotPersistent() + private PCAppDepartment _department; + @NotPersistent() + private PCAppDepartment _fundingDept; + @NotPersistent() + private PCAppEmployee _manager; + @NotPersistent() + private PCAppEmployee _mentor; + @NotPersistent() + private PCAppEmployee _protege; + @NotPersistent() + private PCAppEmployee _hradvisor; + @NotPersistent() + private transient Set _reviewedProjects = new HashSet(); + @NotPersistent() + private transient Set _projects = new HashSet(); + @NotPersistent() + private transient Set _team = new HashSet(); + @NotPersistent() + private transient Set _hradvisees = new HashSet(); + + /** This is the JDO-required no-args constructor */ + protected PCAppEmployee() {} + + /** + * Construct an PCAppEmployee instance. + * + * + * @param personid The identifier for the person. + * @param firstname The first name of the employee. + * @param lastname The last name of the employee. + * @param middlename The middle name of the employee. + * @param birthdate The birth date of the employee. + * @param hiredate The date that the employee was hired. + */ + public PCAppEmployee(long personid, String firstname, String lastname, + String middlename, Date birthdate, + Date hiredate) { + super(personid, firstname, lastname, middlename, birthdate); + this._hiredate = hiredate; + } + + /** + * Construct an PCAppEmployee instance. + * + * + * @param personid The identifier for the person. + * @param firstname The first name of the employee. + * @param lastname The last name of the employee. + * @param middlename The middle name of the employee. + * @param birthdate The birth date of the employee. + * @param address The address of the employee. + * @param hiredate The date that the employee was hired. + */ + public PCAppEmployee(long personid, String firstname, String lastname, + String middlename, Date birthdate, IAddress address, + Date hiredate) { + super(personid, firstname, lastname, middlename, birthdate, + (PCAppAddress)address); + this._hiredate = hiredate; + } + + /** + * Get the date that the employee was hired. + * @return The date the employee was hired. + */ + @Column(name="HIREDATE") + public Date getHiredate() { + return _hiredate; + } + + /** + * Set the date that the employee was hired. + * @param hiredate The date the employee was hired. + */ + public void setHiredate(Date hiredate) { + this._hiredate = hiredate; + } + + /** + * Get the weekly hours of the employee. + * @return The number of hours per week that the employee works. + */ + @Column(name="WEEKLYHOURS") + public double getWeeklyhours() { + return _weeklyhours; + } + + /** + * Set the number of hours per week that the employee works. + * @param weeklyhours The number of hours per week that the employee + * works. + */ + public void setWeeklyhours(double weeklyhours) { + this._weeklyhours = weeklyhours; + } + + /** + * Get the reviewed projects. + * @return The reviewed projects. + */ + @Persistent(mappedBy="reviewers") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppProject.class) + public Set getReviewedProjects() { + return _reviewedProjects; + } + + /** + * Add a reviewed project. + * @param project A reviewed project. + */ + public void addReviewedProjects(PCAppProject project) { + _reviewedProjects.add(project); + } + + /** + * Remove a reviewed project. + * @param project A reviewed project. + */ + public void removeReviewedProject(PCAppProject project) { + _reviewedProjects.remove(project); + } + + /** + * Set the reviewed projects for the employee. + * @param reviewedProjects The set of reviewed projects. + */ + public void setReviewedProjects(Set reviewedProjects) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._reviewedProjects = + (reviewedProjects != null) ? new HashSet(reviewedProjects) : null; + } + + /** + * Get the employee's projects. + * @return The employee's projects + * set. + */ + @Persistent(mappedBy="members") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppProject.class) + public Set getProjects() { + return _projects; + } + + /** + * Add a project for the employee. + * @param project The project. + */ + public void addProject(PCAppProject project) { + _projects.add(project); + } + + /** + * Remove a project from an employee's set of projects. + * @param project The project. + */ + public void removeProject(PCAppProject project) { + _projects.remove(project); + } + + /** + * Set the projects for the employee. + * @param projects The set of projects of the employee. + */ + public void setProjects(Set projects) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._projects = (projects != null) ? new HashSet(projects) : null; + } + + /** + * Get the dental insurance of the employee. + * @return The employee's dental insurance. + */ + + @Persistent(mappedBy="employee", + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppDentalInsurance.class) + public IDentalInsurance getDentalInsurance() { + return _dentalInsurance; + } + + /** + * Set the dental insurance object for the employee. + * @param dentalInsurance The dental insurance object to associate with + * the employee. + */ + public void setDentalInsurance(IDentalInsurance dentalInsurance) { + this._dentalInsurance = (PCAppDentalInsurance)dentalInsurance; + } + /** + * Get the medical insurance of the employee. + * @return The employee's medical insurance. + */ + @Persistent(mappedBy="employee", + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppMedicalInsurance.class) + public IMedicalInsurance getMedicalInsurance() { + return _medicalInsurance; + } + + /** + * Set the medical insurance object for the employee. + * @param medicalInsurance The medical insurance object to associate + * with the employee. + */ + public void setMedicalInsurance(IMedicalInsurance medicalInsurance) { + this._medicalInsurance = (PCAppMedicalInsurance)medicalInsurance; + } + + /** + * Get the employee's department. + * @return The department associated with the employee. + */ + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppDepartment.class) + @Column(name="DEPARTMENT") + public IDepartment getDepartment() { + return _department; + } + + /** + * Set the employee's department. + * @param department The department. + */ + public void setDepartment(IDepartment department) { + this._department = (PCAppDepartment)department; + } + + /** + * Get the employee's funding department. + * @return The funding department associated with the employee. + */ + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppDepartment.class) + @Column(name="FUNDINGDEPT") + public IDepartment getFundingDept() { + return _fundingDept; + } + + /** + * Set the employee's funding department. + * @param department The funding department. + */ + public void setFundingDept(IDepartment department) { + this._fundingDept = (PCAppDepartment)department; + } + + /** + * Get the employee's manager. + * @return The employee's manager. + */ + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + @Column(name="MANAGER") + public IEmployee getManager() { + return _manager; + } + + /** + * Set the employee's manager. + * @param manager The employee's manager. + */ + public void setManager(IEmployee manager) { + this._manager = (PCAppEmployee)manager; + } + + /** + * Get the employee's team. + * + * + * @return The set of PCAppEmployees on this employee's team. + */ + @Persistent(mappedBy="manager") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + public Set getTeam() { + return _team; + } + + /** + * Add an PCAppEmployee to this employee's team. + * This method sets both sides of the relationship, modifying + * this employees team to include parameter emp and modifying + * emp to set its manager attribute to this object. + * + * + * @param emp The PCAppEmployee to add to the team. + */ + public void addToTeam(PCAppEmployee emp) { + _team.add(emp); + emp._manager = this; + } + + /** + * Remove an PCAppEmployee from this employee's team. + * This method will also set the emp manager to null. + * + * + * @param emp The PCAppEmployee to remove from the team. + */ + public void removeFromTeam(PCAppEmployee emp) { + _team.remove(emp); + emp._manager = null; + } + + /** + * Set the employee's team. + * + * + * @param team The set of PCAppEmployees. + */ + public void setTeam(Set team) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._team = (team != null) ? new HashSet(team) : null; + } + + /** + * Set the mentor for this employee. + * @param mentor The mentor for this employee. + */ + public void setMentor(IEmployee mentor) { + this._mentor = (PCAppEmployee)mentor; + } + + /** + * Get the mentor for this employee. + * @return The mentor. + */ + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + @Column(name="MENTOR") + public IEmployee getMentor() { + return _mentor; + } + + /** + * Set the protege for this employee. + * @param protege The protege for this employee. + */ + public void setProtege(IEmployee protege) { + this._protege = (PCAppEmployee)protege; + } + + /** + * Get the protege of this employee. + * @return The protege of this employee. + */ + @Persistent(mappedBy="mentor", + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + public IEmployee getProtege() { + return _protege; + } + + /** + * Set the HR advisor for this employee. + * @param hradvisor The hradvisor for this employee. + */ + public void setHradvisor(IEmployee hradvisor) { + this._hradvisor = (PCAppEmployee)hradvisor; + } + + /** + * Get the HR advisor for the employee. + * @return The HR advisor. + */ + @Column(name="HRADVISOR") + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + public IEmployee getHradvisor() { + return _hradvisor; + } + + /** + * Get the HR advisees of this HR advisor. + * + * + * @return HR advisees of this employee. + */ + @Persistent(mappedBy="hradvisor") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + public Set getHradvisees() { + return _hradvisees; + } + + /** + * Add an PCAppEmployee as an advisee of this HR advisor. + * This method also sets the emp hradvisor to reference + * this object. In other words, both sides of the relationship are + * set. + * + * + * @param emp The employee to add as an advisee. + */ + public void addAdvisee(PCAppEmployee emp) { + _hradvisees.add(emp); + emp._hradvisor = this; + } + + /** + * Remove an PCAppEmployee as an advisee of this HR advisor. + * This method also sets the emp hradvisor to null. + * In other words, both sides of the relationship are set. + * + * + * @param emp The employee to add as an HR advisee. + */ + public void removeAdvisee(PCAppEmployee emp) { + _hradvisees.remove(emp); + emp._hradvisor = null; + } + + /** + * Set the HR advisees of this HR advisor. + * + * + * @param hradvisees The PCAppEmployees that are HR advisees of + * this employee. + */ + public void setHradvisees(Set hradvisees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._hradvisees = (hradvisees != null) ? new HashSet(hradvisees) : null; + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + _reviewedProjects = new HashSet(); + _projects = new HashSet(); + _team = new HashSet(); + _hradvisees = new HashSet(); + } + + /** + * Return a String representation of a PCAppEmployee object. + * + * + * @return a String representation of a PCAppEmployee object. + */ + public String toString() { + return "FCEmployee(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", hired ").append( + _hiredate==null ? "null" : formatter.format(_hiredate)); + rc.append(", weeklyhours ").append(_weeklyhours); + return rc.toString(); + } + + /** + * + * Returns true if all the fields of this instance are + * deep equal to the corresponding fields of the specified PCAppEmployee. + * + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCAppEmployee otherEmp = (PCAppEmployee)other; + String where = "Employee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.equals(_hiredate, otherEmp.getHiredate(), where + ".hiredate") & + helper.closeEnough(_weeklyhours, otherEmp.getWeeklyhours(), where + ".weeklyhours") & + helper.deepEquals(_dentalInsurance, otherEmp.getDentalInsurance(), where + ".dentalInsurance") & + helper.deepEquals(_medicalInsurance, otherEmp.getMedicalInsurance(), where + ".medicalInsurance") & + helper.deepEquals(_department, otherEmp.getDepartment(), where + ".department") & + helper.deepEquals(_fundingDept, otherEmp.getFundingDept(), where + ".fundingDept") & + helper.deepEquals(_manager, otherEmp.getManager(), where + ".manager") & + helper.deepEquals(_mentor, otherEmp.getMentor(), where + ".mentor") & + helper.deepEquals(_protege, otherEmp.getProtege(), where + ".protege") & + helper.deepEquals(_hradvisor, otherEmp.getHradvisor(), where + ".hradvisor") & + helper.deepEquals(_reviewedProjects, otherEmp.getReviewedProjects(), where + ".reviewedProjects") & + helper.deepEquals(_projects, otherEmp.getProjects(), where + ".projects") & + helper.deepEquals(_team, otherEmp.getTeam(), where + ".team") & + helper.deepEquals(_hradvisees, otherEmp.getHradvisees(), where + ".hradvisees"); + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppFullTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppFullTimeEmployee.java index a76a324e4..ef8b56643 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppFullTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppFullTimeEmployee.java @@ -5,138 +5,136 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; +import javax.jdo.annotations.*; + import java.util.Date; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; import org.apache.jdo.tck.pc.company.IAddress; + import org.apache.jdo.tck.pc.company.IFullTimeEmployee; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a full-time employee. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION) -@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE) -public class PCAppFullTimeEmployee extends PCAppEmployee implements IFullTimeEmployee { - - @NotPersistent() private double _salary; - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public PCAppFullTimeEmployee() {} +/** + * This class represents a full-time employee. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION) +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) +public class PCAppFullTimeEmployee extends PCAppEmployee + implements IFullTimeEmployee { - /** - * Construct a full-time employee. - * - * @param personid The person identifier. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param hired The date that the person was hired. - * @param sal The salary of the full-time employee. - */ - public PCAppFullTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double sal) { - super(personid, first, last, middle, born, hired); - _salary = sal; - } + @NotPersistent() + private double _salary; - /** - * Construct a full-time employee. - * - * @param personid The person identifier. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param addr The person's address. - * @param hired The date that the person was hired. - * @param sal The salary of the full-time employee. - */ - public PCAppFullTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - IAddress addr, - Date hired, - double sal) { - super(personid, first, last, middle, born, (PCAppAddress) addr, hired); - _salary = sal; - } + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCAppFullTimeEmployee() {} - /** - * Get the salary of the full time employee. - * - * @return The salary of the full time employee. - */ - @Column(name = "SALARY") - public double getSalary() { - return _salary; - } + /** + * Construct a full-time employee. + * @param personid The person identifier. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param hired The date that the person was hired. + * @param sal The salary of the full-time employee. + */ + public PCAppFullTimeEmployee(long personid, String first, String last, + String middle, Date born, + Date hired, double sal) { + super(personid, first, last, middle, born, hired); + _salary = sal; + } - /** - * Set the salary for the full-time employee. - * - * @param salary The salary to set for the full-time employee. - */ - public void setSalary(double salary) { - this._salary = salary; - } + /** + * Construct a full-time employee. + * @param personid The person identifier. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param addr The person's address. + * @param hired The date that the person was hired. + * @param sal The salary of the full-time employee. + */ + public PCAppFullTimeEmployee(long personid, String first, String last, + String middle, Date born, IAddress addr, + Date hired, double sal) { + super(personid, first, last, middle, born, (PCAppAddress)addr, hired); + _salary = sal; + } - /** - * Return a String representation of a PCAppFullTimeEmployee object. - * - * @return a String representation of a PCAppFullTimeEmployee object. - */ - public String toString() { - return "FCFullTimeEmployee(" + getFieldRepr() + ")"; - } + /** + * Get the salary of the full time employee. + * @return The salary of the full time employee. + */ + @Column(name="SALARY") + public double getSalary() { + return _salary; + } + + /** + * Set the salary for the full-time employee. + * @param salary The salary to set for the full-time employee. + */ + public void setSalary(double salary) { + this._salary = salary; + } + + /** + * Return a String representation of a PCAppFullTimeEmployee object. + * + * + * @return a String representation of a PCAppFullTimeEmployee object. + */ + public String toString() { + return "FCFullTimeEmployee(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - public String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", $").append(_salary); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + public String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", $").append(_salary); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified PCAppFullTimeEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCAppFullTimeEmployee otherEmp = (PCAppFullTimeEmployee) other; - String where = "FCFullTimeEmployee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.closeEnough(_salary, otherEmp.getSalary(), where + ".salary"); - } + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified + * PCAppFullTimeEmployee. + * + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCAppFullTimeEmployee otherEmp = (PCAppFullTimeEmployee)other; + String where = "FCFullTimeEmployee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.closeEnough(_salary, otherEmp.getSalary(), where + ".salary"); + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppInsurance.java index 8c391a27d..7acdd2727 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppInsurance.java @@ -5,304 +5,304 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; +import javax.jdo.annotations.*; + import java.io.Serializable; + import java.util.Comparator; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Index; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; -import javax.jdo.annotations.PrimaryKey; import org.apache.jdo.tck.pc.company.IEmployee; + import org.apache.jdo.tck.pc.company.IInsurance; import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; /** - * This class represents an insurance carrier selection for a particular PCAppEmployee. + * This class represents an insurance carrier selection for a particular + * PCAppEmployee. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION, table = "insuranceplans") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator( - strategy = DiscriminatorStrategy.CLASS_NAME, - column = "DISCRIMINATOR", - indexed = "true") -@Index( - name = "INS_DISCRIMINATOR_INDEX", - unique = "false", - columns = @Column(name = "DISCRIMINATOR")) -public class PCAppInsurance - implements IInsurance, Serializable, Comparable, Comparator, DeepEquality { - - @NotPersistent() private long _insid; - @NotPersistent() private String _carrier; - @NotPersistent() private PCAppEmployee _employee; - - /** This is the JDO-required no-args constructor. */ - protected PCAppInsurance() {} - - /** - * Construct an PCAppInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - */ - protected PCAppInsurance(long insid, String carrier) { - this._insid = insid; - this._carrier = carrier; - } - - /** - * Construct an PCAppInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param employee The employee associated with this insurance. - */ - protected PCAppInsurance(long insid, String carrier, IEmployee employee) { - this._insid = insid; - this._carrier = carrier; - this._employee = (PCAppEmployee) employee; - } - - /** - * Get the insurance ID. - * - * @return the insurance ID. - */ - @PrimaryKey - @Column(name = "INSID") - public long getInsid() { - return _insid; - } - - /** - * Set the insurance ID. - * - * @param id The insurance ID value. - */ - public void setInsid(long id) { - this._insid = id; - } - - /** - * Get the insurance carrier. - * - * @return The insurance carrier. - */ - @Column(name = "CARRIER") - public String getCarrier() { - return _carrier; - } - - /** - * Set the insurance carrier. - * - * @param carrier The insurance carrier. - */ - public void setCarrier(String carrier) { - this._carrier = carrier; - } - - /** - * Get the associated employee. - * - * @return The employee for this insurance. - */ - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) - @Column(name = "EMPLOYEE") - public IEmployee getEmployee() { - return _employee; - } - - /** - * Set the associated employee. - * - * @param employee The associated employee. - */ - public void setEmployee(IEmployee employee) { - this._employee = (PCAppEmployee) employee; - } - - /** - * Returns a String representation of a PCAppInsurance object. - * - * @return a String representation of a PCAppInsurance object. - */ - public String toString() { - return "FCInsurance(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(_insid); - rc.append(", carrier ").append(_carrier); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Object. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCAppInsurance otherIns = (PCAppInsurance) other; - String where = "FCInsurance<" + _insid + ">"; - return helper.equals(_insid, otherIns.getInsid(), where + ".insid") - & helper.equals(_carrier, otherIns.getCarrier(), where + ".carrier") - & helper.deepEquals(_employee, otherIns.getEmployee(), where + ".employee"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((PCAppInsurance) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((PCAppInsurance) o1, (PCAppInsurance) o2); - } - - /** - * Compares this object with the specified Insurance object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Insurance object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Insurance object. - */ - public int compareTo(PCAppInsurance other) { - return compare(this, other); - } - - /** - * Compares its two IInsurance arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IInsurance object to be compared. - * @param o2 the second IInsurance object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(PCAppInsurance o1, PCAppInsurance o2) { - return EqualityHelper.compare(o1.getInsid(), o2.getInsid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof PCAppInsurance) { - return compareTo((PCAppInsurance) obj) == 0; +@PersistenceCapable(identityType=IdentityType.APPLICATION,table="insuranceplans" ) +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR", indexed="true") +@Index(name="INS_DISCRIMINATOR_INDEX", unique="false", + columns=@Column(name="DISCRIMINATOR")) +public class PCAppInsurance + implements IInsurance, Serializable, Comparable, Comparator, DeepEquality { + + @NotPersistent() + private long _insid; + @NotPersistent() + private String _carrier; + @NotPersistent() + private PCAppEmployee _employee; + + /** This is the JDO-required no-args constructor. */ + protected PCAppInsurance() {} + + /** + * Construct an PCAppInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + */ + protected PCAppInsurance(long insid, String carrier) { + this._insid = insid; + this._carrier = carrier; + } + + /** + * Construct an PCAppInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + */ + protected PCAppInsurance(long insid, String carrier, IEmployee employee) { + this._insid = insid; + this._carrier = carrier; + this._employee = (PCAppEmployee)employee; + } + + /** + * Get the insurance ID. + * @return the insurance ID. + */ + + @PrimaryKey + @Column(name="INSID") + public long getInsid() { + return _insid; + } + + /** + * Set the insurance ID. + * @param id The insurance ID value. + */ + public void setInsid(long id) { + this._insid = id; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) _insid; - } - - /** - * This class is used to represent the application identifier for the Insurance - * class. - */ - public static class Oid implements Serializable, Comparable { + /** - * This field represents the application identifier for the Insurance class. It - * must match the field in the Insurance class in both name and type. + * Get the insurance carrier. + * @return The insurance carrier. */ - public long insid; - /** The required public no-args constructor. */ - public Oid() {} + @Column(name="CARRIER") + public String getCarrier() { + return _carrier; + } /** - * Initialize with an insurance identifier. - * - * @param insid the insurance ID. + * Set the insurance carrier. + * @param carrier The insurance carrier. */ - public Oid(long insid) { - this.insid = insid; + public void setCarrier(String carrier) { + this._carrier = carrier; + } + + /** + * Get the associated employee. + * @return The employee for this insurance. + */ + + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class) + @Column(name="EMPLOYEE") + public IEmployee getEmployee() { + return _employee; } - public Oid(String s) { - insid = Long.parseLong(justTheId(s)); + /** + * Set the associated employee. + * @param employee The associated employee. + */ + public void setEmployee(IEmployee employee) { + this._employee = (PCAppEmployee)employee; } + /** + * Returns a String representation of a PCAppInsurance object. + * + * + * @return a String representation of a PCAppInsurance object. + */ public String toString() { - return this.getClass().getName() + ": " + insid; + return "FCInsurance(" + getFieldRepr() + ")"; } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.insid != o.insid) return (false); - return (true); + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(_insid); + rc.append(", carrier ").append(_carrier); + return rc.toString(); } - /** */ - public int hashCode() { - return ((int) insid); + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCAppInsurance otherIns = (PCAppInsurance)other; + String where = "FCInsurance<" + _insid + ">"; + return + helper.equals(_insid, otherIns.getInsid(), where + ".insid") & + helper.equals(_carrier, otherIns.getCarrier(), where + ".carrier") & + helper.deepEquals(_employee, otherIns.getEmployee(), where + ".employee"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((PCAppInsurance)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCAppInsurance)o1, (PCAppInsurance)o2); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compares this object with the specified Insurance object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Insurance object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified + * Insurance object. + */ + public int compareTo(PCAppInsurance other) { + return compare(this, other); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (insid < other.insid) return -1; - if (insid > other.insid) return 1; - return 0; + /** + * Compares its two IInsurance arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IInsurance object to be compared. + * @param o2 the second IInsurance object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(PCAppInsurance o1, PCAppInsurance o2) { + return EqualityHelper.compare(o1.getInsid(), o2.getInsid()); } - } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof PCAppInsurance) { + return compareTo((PCAppInsurance)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)_insid; + } + + /** + * This class is used to represent the application + * identifier for the Insurance class. + */ + public static class Oid implements Serializable, Comparable + { + /** + * This field represents the application identifier for the + * Insurance class. It must match the field in the + * Insurance class in both name and type. + */ + public long insid; + + /** + * The required public no-args constructor. + */ + public Oid() { } + + /** + * Initialize with an insurance identifier. + * @param insid the insurance ID. + */ + public Oid(long insid) { + this.insid = insid; + } + + public Oid(String s) { insid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + insid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o=(Oid) obj; + if( this.insid!=o.insid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) insid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( insid < other.insid ) return -1; + if( insid > other.insid ) return 1; + return 0; + } + + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppMedicalInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppMedicalInsurance.java index 6b2a4fc74..d69abdde4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppMedicalInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppMedicalInsurance.java @@ -5,120 +5,128 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; +import javax.jdo.annotations.*; import org.apache.jdo.tck.pc.company.IEmployee; + import org.apache.jdo.tck.pc.company.IMedicalInsurance; import org.apache.jdo.tck.util.EqualityHelper; /** - * This class represents a dental insurance carrier selection for a particular Employee - * . + * This class represents a dental insurance carrier selection for a + * particular Employee. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION) +@PersistenceCapable(identityType=IdentityType.APPLICATION) public class PCAppMedicalInsurance extends PCAppInsurance implements IMedicalInsurance { - @NotPersistent private String _planType; // possible values: "PPO", "EPO", "NPO" + @NotPersistent + private String _planType; // possible values: "PPO", "EPO", "NPO" - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public PCAppMedicalInsurance() {} + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCAppMedicalInsurance() {} - /** - * Construct a PCAppMedicalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param planType The planType. - */ - public PCAppMedicalInsurance(long insid, String carrier, String planType) { - super(insid, carrier); - this._planType = planType; - } + /** + * Construct a PCAppMedicalInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param planType The planType. + */ + public PCAppMedicalInsurance(long insid, String carrier, + String planType) + { + super(insid, carrier); + this._planType = planType; + } - /** - * Construct a PCAppMedicalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param employee The employee associated with this insurance. - * @param planType The planType. - */ - public PCAppMedicalInsurance(long insid, String carrier, IEmployee employee, String planType) { - super(insid, carrier, (PCAppEmployee) employee); - this._planType = planType; - } + /** + * Construct a PCAppMedicalInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + * @param planType The planType. + */ + public PCAppMedicalInsurance(long insid, String carrier, + IEmployee employee, String planType) + { + super(insid, carrier, (PCAppEmployee)employee); + this._planType = planType; + } - /** - * Get the insurance planType. - * - * @return The insurance planType. - */ - @Column(name = "PLANTYPE") - public String getPlanType() { - return _planType; - } + /** + * Get the insurance planType. + * @return The insurance planType. + */ - /** - * Set the insurance planType. - * - * @param planType The insurance planType. - */ - public void setPlanType(String planType) { - this._planType = planType; - } + @Column(name="PLANTYPE") + public String getPlanType() { + return _planType; + } - /** - * Returns a String representation of a PCAppMedicalInsurance object. - * - * @return a String representation of a PCAppMedicalInsurance object. - */ - public String toString() { - return "FCMedicalInsurance(" + getFieldRepr() + ")"; - } + /** + * Set the insurance planType. + * @param planType The insurance planType. + */ + public void setPlanType(String planType) { + this._planType = planType; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", planType ").append(_planType); - return rc.toString(); - } + /** + * Returns a String representation of a PCAppMedicalInsurance + * object. + * + * + * @return a String representation of a PCAppMedicalInsurance + * object. + */ + public String toString() { + return "FCMedicalInsurance(" + getFieldRepr() + ")"; + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Object. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCAppMedicalInsurance otherIns = (PCAppMedicalInsurance) other; - String where = "FCMedicalInsurance<" + getInsid() + ">"; - return super.deepCompareFields(otherIns, helper) - & helper.equals(_planType, otherIns.getPlanType(), where + ".planType"); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", planType ").append(_planType); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCAppMedicalInsurance otherIns = (PCAppMedicalInsurance)other; + String where = "FCMedicalInsurance<" + getInsid() + ">"; + return super.deepCompareFields(otherIns, helper) & + helper.equals(_planType, otherIns.getPlanType(), where + ".planType"); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPartTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPartTimeEmployee.java index 7eec1ee1e..6858014aa 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPartTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPartTimeEmployee.java @@ -5,137 +5,136 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; +import javax.jdo.annotations.*; + import java.util.Date; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; + import org.apache.jdo.tck.pc.company.IPartTimeEmployee; +import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a part-time employee. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION) -@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE) -public class PCAppPartTimeEmployee extends PCAppEmployee implements IPartTimeEmployee { +/** + * This class represents a part-time employee. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION) +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) +public class PCAppPartTimeEmployee extends PCAppEmployee + implements IPartTimeEmployee { + + @NotPersistent() + private double _wage; - @NotPersistent() private double _wage; + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCAppPartTimeEmployee() {} - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public PCAppPartTimeEmployee() {} + /** + * Construct a part-time employee. + * @param personid The identifier for the person. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param hired The date the person was hired. + * @param wage The person's wage. + */ + public PCAppPartTimeEmployee(long personid, String first, String last, + String middle, Date born, + Date hired, double wage ) { + super(personid, first, last, middle, born, hired); + this._wage = wage; + } - /** - * Construct a part-time employee. - * - * @param personid The identifier for the person. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param hired The date the person was hired. - * @param wage The person's wage. - */ - public PCAppPartTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double wage) { - super(personid, first, last, middle, born, hired); - this._wage = wage; - } + /** + * Construct a part-time employee. + * @param personid The identifier for the person. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param addr The person's address. + * @param hired The date the person was hired. + * @param wage The person's wage. + */ + public PCAppPartTimeEmployee(long personid, String first, String last, + String middle, Date born, PCAppAddress addr, + Date hired, double wage ) { + super(personid, first, last, middle, born, addr, hired); + this._wage = wage; + } - /** - * Construct a part-time employee. - * - * @param personid The identifier for the person. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param addr The person's address. - * @param hired The date the person was hired. - * @param wage The person's wage. - */ - public PCAppPartTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - PCAppAddress addr, - Date hired, - double wage) { - super(personid, first, last, middle, born, addr, hired); - this._wage = wage; - } + /** + * Get the wage of the part-time employee. + * @return The wage of the part-time employee. + */ - /** - * Get the wage of the part-time employee. - * - * @return The wage of the part-time employee. - */ - @Column(name = "WAGE") - public double getWage() { - return _wage; - } + @Column(name="WAGE") + public double getWage() { + return _wage; + } - /** - * Set the wage of the part-time employee. - * - * @param wage The wage of the part-time employee. - */ - public void setWage(double wage) { - this._wage = wage; - } + /** + * Set the wage of the part-time employee. + * @param wage The wage of the part-time employee. + */ + public void setWage(double wage) { + this._wage = wage; + } - /** - * Returns a String representation of a PCAppPartTimeEmployee object. - * - * @return a String representation of a PCAppPartTimeEmployee object. - */ - public String toString() { - return "FCPartTimeEmployee(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of a PCAppPartTimeEmployee object. + * + * + * @return a String representation of a PCAppPartTimeEmployee object. + */ + public String toString() { + return "FCPartTimeEmployee(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - public String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", $" + _wage); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + public String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", $" + _wage); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified PCAppPartTimeEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCAppPartTimeEmployee otherEmp = (PCAppPartTimeEmployee) other; - String where = "FCPartTimeEmployee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.closeEnough(_wage, otherEmp.getWage(), where + ".wage"); - } + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified + * PCAppPartTimeEmployee. + * + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCAppPartTimeEmployee otherEmp = (PCAppPartTimeEmployee)other; + String where = "FCPartTimeEmployee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.closeEnough(_wage, otherEmp.getWage(), where + ".wage"); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPerson.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPerson.java index 9fe2aeb08..3f5d8c5bd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPerson.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPerson.java @@ -5,462 +5,460 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; +import javax.jdo.annotations.*; + import java.io.Serializable; + import java.text.SimpleDateFormat; + +import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.Map; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.Embedded; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.Join; -import javax.jdo.annotations.Key; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.PersistenceModifier; -import javax.jdo.annotations.Persistent; -import javax.jdo.annotations.PrimaryKey; -import javax.jdo.annotations.Value; import org.apache.jdo.tck.pc.company.IAddress; + import org.apache.jdo.tck.pc.company.IPerson; import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a person. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION, table = "persons") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator( - strategy = DiscriminatorStrategy.CLASS_NAME, - column = "DISCRIMINATOR", - indexed = "true") -public class PCAppPerson implements IPerson, Serializable, Comparable, Comparator, DeepEquality { - - @NotPersistent() private long _personid; - @NotPersistent() private String _firstname; - @NotPersistent() private String _lastname; - @NotPersistent() private String _middlename; - @NotPersistent() private Date _birthdate; - @NotPersistent() private PCAppAddress _address; - @NotPersistent() private Map _phoneNumbers = new HashMap(); - - protected static SimpleDateFormat formatter = new SimpleDateFormat("d/MMM/yyyy"); - - /** This is the JDO-required no-args constructor. */ - protected PCAppPerson() {} - - /** - * Construct a PCAppPerson instance. - * - * @param personid The person identifier. - * @param firstname The person's first name. - * @param lastname The person's last name. - * @param middlename The person's middle name. - * @param birthdate The person's birthdate. - */ - public PCAppPerson( - long personid, String firstname, String lastname, String middlename, Date birthdate) { - this._personid = personid; - this._firstname = firstname; - this._lastname = lastname; - this._middlename = middlename; - this._birthdate = birthdate; - } - - /** - * Construct a PCAppPerson instance. - * - * @param personid The person identifier. - * @param firstname The person's first name. - * @param lastname The person's last name. - * @param middlename The person's middle name. - * @param birthdate The person's birthdate. - * @param address The person's address. - */ - public PCAppPerson( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - IAddress address) { - this(personid, firstname, lastname, middlename, birthdate); - this._address = (PCAppAddress) _address; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setPersonid(long id) { - this._personid = id; - } - - /** - * Get the person's id. - * - * @return The personid. - */ - @PrimaryKey - @Column(name = "PERSONID") - public long getPersonid() { - return _personid; - } - - /** - * Get the person's last name. - * - * @return The last name. - */ - @Column(name = "LASTNAME") - public String getLastname() { - return _lastname; - } - - /** - * Set the person's last name. - * - * @param lastname The last name. - */ - public void setLastname(String lastname) { - this._lastname = lastname; - } - - /** - * Get the person's first name. - * - * @return The first name. - */ - @Column(name = "FIRSTNAME") - public String getFirstname() { - return _firstname; - } - - /** - * Set the person's first name. - * - * @param firstname The first name. - */ - public void setFirstname(String firstname) { - this._firstname = firstname; - } - - /** - * Get the person's middle name. - * - * @return The middle name. - */ - @Persistent(defaultFetchGroup = "false") - @Column(name = "MIDDLENAME", allowsNull = "true") - public String getMiddlename() { - return _middlename; - } - - /** - * Set the person's middle name. - * - * @param middlename The middle name. - */ - public void setMiddlename(String middlename) { - this._middlename = middlename; - } - - /** - * Get the address. - * - * @return The address. - */ - @Persistent( - persistenceModifier = PersistenceModifier.PERSISTENT, - types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppAddress.class) - @Embedded( - nullIndicatorColumn = "COUNTRY", - members = { - @Persistent(name = "addrid", columns = @Column(name = "ADDRID")), - @Persistent(name = "street", columns = @Column(name = "STREET")), - @Persistent(name = "city", columns = @Column(name = "CITY")), - @Persistent(name = "state", columns = @Column(name = "STATE")), - @Persistent(name = "zipcode", columns = @Column(name = "ZIPCODE")), - @Persistent(name = "country", columns = @Column(name = "COUNTRY")) - }) - public IAddress getAddress() { - return _address; - } - - /** - * Set the address. - * - * @param address The address. - */ - public void setAddress(IAddress address) { - this._address = (PCAppAddress) address; - } - - /** - * Get the person's birthdate. - * - * @return The person's birthdate. - */ - @Column(name = "BIRTHDATE") - public Date getBirthdate() { - return _birthdate; - } - - /** - * Set the person's birthdate. - * - * @param birthdate The person's birthdate. - */ - public void setBirthdate(Date birthdate) { - this._birthdate = birthdate; - } - - /** - * Get the map of phone numbers - * - * @return The map of phone numbers. - */ - // maps phone number types ("home", "work", "mobile", etc.) - // to phone numbers specified as String - @Persistent(table = "employee_phoneno_type") - @Join(column = "EMPID") - @Key(types = java.lang.String.class, column = "TYPE") - @Value(types = java.lang.String.class, column = "PHONENO") - public Map getPhoneNumbers() { - return _phoneNumbers; - } - - /** - * Get the phone number for the specified phone number type. - * - * @param type The phone number type ("home", "work", "mobile", etc.). - * @return The phone number associated with specified type, or null if there was no - * phone number for the type. - */ - public String getPhoneNumber(String type) { - return (String) _phoneNumbers.get(type); - } - - /** - * Associates the specified phone number with the specified type in the map of phone numbers of - * this person. - * - * @param type The phone number type ("home", "work", "mobile", etc.). - * @param phoneNumber The phone number - * @return The previous phone number associated with specified type, or null if there - * was no phone number for the type. - */ - public String putPhoneNumber(String type, String phoneNumber) { - return (String) _phoneNumbers.put(type, phoneNumber); - } - - /** - * Remove a phoneNumber from the map of phone numbers. - * - * @param type The phone number type ("home", "work", "mobile", etc.). - * @return The previous phone number associated with specified type, or null if there - * was no phone number for the type. - */ - public String removePhoneNumber(String type) { - return (String) _phoneNumbers.remove(type); - } - - /** - * Set the phoneNumber map to be in this person. - * - * @param phoneNumbers The map of phoneNumbers for this person. - */ - public void setPhoneNumbers(Map phoneNumbers) { - // workaround: create a new HashMap, because fostore does not - // support LinkedHashMap - this._phoneNumbers = (phoneNumbers != null) ? new HashMap(phoneNumbers) : null; - } - - /** - * Returns a String representation of a PCAppPerson object. - * - * @return a string representation of a PCAppPerson object. - */ - public String toString() { - return "FCPerson(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(_personid); - rc.append(", ").append(_lastname); - rc.append(", ").append(_firstname); - rc.append(", born ").append(_birthdate == null ? "null" : formatter.format(_birthdate)); - rc.append(", phone ").append(_phoneNumbers); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified PCAppPerson. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCAppPerson otherPerson = (PCAppPerson) other; - String where = "FCPerson<" + _personid + ">"; - return helper.equals(_personid, otherPerson.getPersonid(), where + ".personid") - & helper.equals(_firstname, otherPerson.getFirstname(), where + ".firstname") - & helper.equals(_lastname, otherPerson.getLastname(), where + ".lastname") - & helper.equals(_middlename, otherPerson.getMiddlename(), where + ".middlename") - & helper.equals(_birthdate, otherPerson.getBirthdate(), where + ".birthdate") - & helper.deepEquals(_address, otherPerson.getAddress(), where + ".address") - & helper.deepEquals(_phoneNumbers, otherPerson.getPhoneNumbers(), where + ".phoneNumbers"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((PCAppPerson) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((PCAppPerson) o1, (PCAppPerson) o2); - } - - /** - * Compares this object with the specified PCAppPerson object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The PCAppPerson object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified PFCAppPerson object. - */ - public int compareTo(PCAppPerson other) { - return compare(this, other); - } - - /** - * Compares its two IPerson arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IPerson object to be compared. - * @param o2 the second IPerson object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(PCAppPerson o1, PCAppPerson o2) { - return EqualityHelper.compare(o1.getPersonid(), o2.getPersonid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof PCAppPerson) { - return compareTo((PCAppPerson) obj) == 0; +/** + * This class represents a person. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION,table="persons") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR", indexed="true") +public class PCAppPerson + implements IPerson, Serializable, Comparable, Comparator, DeepEquality { + + @NotPersistent() + private long _personid; + @NotPersistent() + private String _firstname; + @NotPersistent() + private String _lastname; + @NotPersistent() + private String _middlename; + @NotPersistent() + private Date _birthdate; + @NotPersistent() + private PCAppAddress _address; + @NotPersistent() + private Map _phoneNumbers = new HashMap(); + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. */ + protected PCAppPerson() {} + + /** + * Construct a PCAppPerson instance. + * + * + * @param personid The person identifier. + * @param firstname The person's first name. + * @param lastname The person's last name. + * @param middlename The person's middle name. + * @param birthdate The person's birthdate. + */ + public PCAppPerson(long personid, String firstname, String lastname, + String middlename, Date birthdate) { + this._personid = personid; + this._firstname = firstname; + this._lastname = lastname; + this._middlename = middlename; + this._birthdate = birthdate; + } + + /** + * Construct a PCAppPerson instance. + * + * + * @param personid The person identifier. + * @param firstname The person's first name. + * @param lastname The person's last name. + * @param middlename The person's middle name. + * @param birthdate The person's birthdate. + * @param address The person's address. + */ + public PCAppPerson(long personid, String firstname, String lastname, + String middlename, Date birthdate, IAddress address) { + this(personid, firstname, lastname, middlename, birthdate); + this._address = (PCAppAddress)_address; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setPersonid(long id) { + this._personid = id; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) _personid; - } - /** - * This class is used to represent the application identifier for the Person class. - */ - public static class Oid implements Serializable, Comparable { /** - * This field represents the identifier for the Person class. It must match a field - * in the Person class in both name and type. + * Get the person's id. + * @return The personid. */ - public long personid; - /** The required public no-arg constructor. */ - public Oid() {} + @PrimaryKey + @Column(name="PERSONID") + public long getPersonid() { + return _personid; + } /** - * Initialize the identifier. - * - * @param personid The person identifier. + * Get the person's last name. + * @return The last name. + */ + + @Column(name="LASTNAME") + public String getLastname() { + return _lastname; + } + + /** + * Set the person's last name. + * @param lastname The last name. + */ + public void setLastname(String lastname) { + this._lastname = lastname; + } + + /** + * Get the person's first name. + * @return The first name. + */ + + @Column(name="FIRSTNAME") + public String getFirstname() { + return _firstname; + } + + /** + * Set the person's first name. + * @param firstname The first name. + */ + public void setFirstname(String firstname) { + this._firstname = firstname; + } + + /** + * Get the person's middle name. + * @return The middle name. + */ + + @Persistent(defaultFetchGroup="false") + @Column(name="MIDDLENAME", allowsNull="true") + public String getMiddlename() { + return _middlename; + } + + /** + * Set the person's middle name. + * @param middlename The middle name. + */ + public void setMiddlename(String middlename) { + this._middlename = middlename; + } + + /** + * Get the address. + * @return The address. + */ + + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT, + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppAddress.class) + @Embedded(nullIndicatorColumn="COUNTRY", + members={ + @Persistent(name="addrid", columns=@Column(name="ADDRID")), + @Persistent(name="street", columns=@Column(name="STREET")), + @Persistent(name="city", columns=@Column(name="CITY")), + @Persistent(name="state", columns=@Column(name="STATE")), + @Persistent(name="zipcode", columns=@Column(name="ZIPCODE")), + @Persistent(name="country", columns=@Column(name="COUNTRY")) + }) + public IAddress getAddress() { + return _address; + } + + /** + * Set the address. + * @param address The address. */ - public Oid(long personid) { - this.personid = personid; + public void setAddress(IAddress address) { + this._address = (PCAppAddress)address; } - public Oid(String s) { - personid = Long.parseLong(justTheId(s)); + /** + * Get the person's birthdate. + * @return The person's birthdate. + */ + @Column(name="BIRTHDATE") + public Date getBirthdate() { + return _birthdate; + } + + /** + * Set the person's birthdate. + * @param birthdate The person's birthdate. + */ + public void setBirthdate(Date birthdate) { + this._birthdate = birthdate; + } + + /** + * Get the map of phone numbers + * @return The map of phone numbers. + */ + // maps phone number types ("home", "work", "mobile", etc.) + // to phone numbers specified as String + @Persistent(table="employee_phoneno_type") + @Join(column="EMPID") + @Key(types=java.lang.String.class, column="TYPE") + @Value(types=java.lang.String.class, column="PHONENO") + public Map getPhoneNumbers() { + return _phoneNumbers; + } + + /** + * Get the phone number for the specified phone number type. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String getPhoneNumber(String type) { + return (String)_phoneNumbers.get(type); + } + + /** + * Associates the specified phone number with the specified type in the + * map of phone numbers of this person. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @param phoneNumber The phone number + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String putPhoneNumber(String type, String phoneNumber) { + return (String)_phoneNumbers.put(type, phoneNumber); } + /** + * Remove a phoneNumber from the map of phone numbers. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String removePhoneNumber(String type) { + return (String)_phoneNumbers.remove(type); + } + + /** + * Set the phoneNumber map to be in this person. + * @param phoneNumbers The map of phoneNumbers for this person. + */ + public void setPhoneNumbers(Map phoneNumbers) { + // workaround: create a new HashMap, because fostore does not + // support LinkedHashMap + this._phoneNumbers = + (phoneNumbers != null) ? new HashMap(phoneNumbers) : null; + } + + /** + * Returns a String representation of a PCAppPerson object. + * + * + * @return a string representation of a PCAppPerson object. + */ public String toString() { - return this.getClass().getName() + ": " + personid; + return "FCPerson(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(_personid); + rc.append(", ").append(_lastname); + rc.append(", ").append(_firstname); + rc.append(", born ").append( + _birthdate==null ? "null" : formatter.format(_birthdate)); + rc.append(", phone ").append(_phoneNumbers); + return rc.toString(); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.personid != o.personid) return (false); - return (true); + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified PCAppPerson. + * + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCAppPerson otherPerson = (PCAppPerson)other; + String where = "FCPerson<" + _personid + ">"; + return + helper.equals(_personid, otherPerson.getPersonid(), where + ".personid") & + helper.equals(_firstname, otherPerson.getFirstname(), where + ".firstname") & + helper.equals(_lastname, otherPerson.getLastname(), where + ".lastname") & + helper.equals(_middlename, otherPerson.getMiddlename(), where + ".middlename") & + helper.equals(_birthdate, otherPerson.getBirthdate(), where + ".birthdate") & + helper.deepEquals(_address, otherPerson.getAddress(), where + ".address") & + helper.deepEquals(_phoneNumbers, otherPerson.getPhoneNumbers(), where + ".phoneNumbers"); } - /** */ - public int hashCode() { - return ((int) personid); + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((PCAppPerson)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCAppPerson)o1, (PCAppPerson)o2); + } + + /** + * + * Compares this object with the specified PCAppPerson object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * + * + * @param other The PCAppPerson object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified PFCAppPerson + * object. + */ + public int compareTo(PCAppPerson other) { + return compare(this, other); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compares its two IPerson arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IPerson object to be compared. + * @param o2 the second IPerson object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(PCAppPerson o1, PCAppPerson o2) { + return EqualityHelper.compare(o1.getPersonid(), o2.getPersonid()); } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof PCAppPerson) { + return compareTo((PCAppPerson)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)_personid; + } + /** + * This class is used to represent the application identifier + * for the Person class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the identifier for the Person + * class. It must match a field in the Person class in + * both name and type. + */ + public long personid; + + /** + * The required public no-arg constructor. + */ + public Oid() { } + + /** + * Initialize the identifier. + * @param personid The person identifier. + */ + public Oid(long personid) { + this.personid = personid; + } + + public Oid(String s) { personid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + personid;} + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || + !this.getClass().equals(obj.getClass()) ) return( false ); + Oid o = (Oid) obj; + if( this.personid != o.personid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) personid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( personid < other.personid ) return -1; + if( personid > other.personid ) return 1; + return 0; + } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (personid < other.personid) return -1; - if (personid > other.personid) return 1; - return 0; } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppProject.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppProject.java index 76ff7b495..bbcc94f3c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppProject.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppProject.java @@ -5,392 +5,395 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; -import java.io.IOException; -import java.io.ObjectInputStream; +import javax.jdo.annotations.*; + import java.io.Serializable; -import java.math.BigDecimal; +import java.io.ObjectInputStream; +import java.io.IOException; + +import java.util.Collections; import java.util.Comparator; -import java.util.HashSet; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.Join; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; -import javax.jdo.annotations.PrimaryKey; +import java.util.HashSet; +import java.math.BigDecimal; + import org.apache.jdo.tck.pc.company.IProject; import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a project, a budgeted task with one or more employees working on it. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION, table = "projects") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator(strategy = DiscriminatorStrategy.CLASS_NAME, column = "DISCRIMINATOR") -public class PCAppProject implements IProject, Serializable, Comparable, Comparator, DeepEquality { - - @NotPersistent() private long _projid; - @NotPersistent() private String _name; - @NotPersistent() private BigDecimal _budget; - @NotPersistent() private transient Set _reviewers = new HashSet(); - @NotPersistent() private transient Set _members = new HashSet(); - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public PCAppProject() {} - - /** - * Initialize a project. - * - * @param projid The project identifier. - * @param name The name of the project. - * @param budget The budget for the project. - */ - public PCAppProject(long projid, String name, BigDecimal budget) { - this._projid = projid; - this._name = name; - this._budget = budget; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setProjid(long id) { - this._projid = id; - } - - /** - * Get the project ID. - * - * @return The project ID. - */ - @PrimaryKey - @Column(name = "PROJID") - public long getProjid() { - return _projid; - } - - /** - * Get the name of the project. - * - * @return The name of the project. - */ - @Column(name = "NAME") - public String getName() { - return _name; - } - - /** - * Set the name of the project. - * - * @param name The name of the project. - */ - public void setName(String name) { - this._name = name; - } - - /** - * Get the project's budget. - * - * @return The project's budget. - */ - @Column(name = "BUDGET", jdbcType = "DECIMAL", length = 11, scale = 2) - public BigDecimal getBudget() { - return _budget; - } - - /** - * Set the project's budget. - * - * @param budget The project's budget. - */ - public void setBudget(BigDecimal budget) { - this._budget = budget; - } - - /** Get the reviewers associated with this project. */ - @Persistent(table = "project_reviewer") - @Element( - types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class, - column = "REVIEWER") - @Join(column = "PROJID", foreignKey = "PR_PROJ_FK") - public Set getReviewers() { - return _reviewers; - } - - /** - * Add a reviewer to the project. - * - * @param emp The employee to add as a reviewer. - */ - public void addReviewer(PCAppEmployee emp) { - _reviewers.add(emp); - } - - /** - * Remove a reviewer from the project. - * - * @param emp The employee to remove as a reviewer of this project. - */ - public void removeReviewer(PCAppEmployee emp) { - _reviewers.remove(emp); - } - - /** - * Set the reviewers associated with this project. - * - * @param reviewers The set of reviewers to associate with this project. - */ - public void setReviewers(Set reviewers) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this._reviewers = (reviewers != null) ? new HashSet(reviewers) : null; - } - - /** - * Get the project members. - * - * @return The members of the project. - */ - @Persistent(table = "project_member") - @Element( - types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class, - column = "MEMBER", - foreignKey = "PR_MEMB_FK") - @Join(column = "PROJID", foreignKey = "PR_PROJ_FK") - public Set getMembers() { - return _members; - } - - /** - * Add a new member to the project. - * - * @param emp The employee to add to the project. - */ - public void addMember(PCAppEmployee emp) { - _members.add(emp); - } - - /** - * Remove a member from the project. - * - * @param emp The employee to remove from the project. - */ - public void removeMember(PCAppEmployee emp) { - _members.remove(emp); - } - - /** - * Set the members of the project. - * - * @param employees The set of employees to be the members of this project. - */ - public void setMembers(Set employees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this._members = (employees != null) ? new HashSet(employees) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - _reviewers = new HashSet(); - _members = new HashSet(); - } - - /** - * Returns a String representation of a PCAppProject object. - * - * @return a String representation of a PCAppProject object. - */ - public String toString() { - return "FCProject(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(_projid); - rc.append(", name ").append(_name); - rc.append(", budget ").append(_budget); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCAppProject otherProject = (PCAppProject) other; - String where = "FCProject<" + _projid + ">"; - return helper.equals(_projid, otherProject.getProjid(), where + ".projid") - & helper.equals(_name, otherProject.getName(), where + ".name") - & helper.equals(_budget, otherProject.getBudget(), where + ".budget") - & helper.deepEquals(_reviewers, otherProject.getReviewers(), where + ".reviewers") - & helper.deepEquals(_members, otherProject.getMembers(), where + ".members"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((PCAppProject) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((PCAppProject) o1, (PCAppProject) o2); - } - - /** - * Compares this object with the specified PCAppProject object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The PCAppProject object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified F\PFCAppProject object. - */ - public int compareTo(PCAppProject other) { - return compare(this, other); - } - - /** - * Compares its two IProject arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IProject object to be compared. - * @param o2 the second IProject object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(PCAppProject o1, PCAppProject o2) { - return EqualityHelper.compare(o1.getProjid(), o2.getProjid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof PCAppProject) { - return compareTo((PCAppProject) obj) == 0; +/** + * This class represents a project, a budgeted task with one or more + * employees working on it. + */ +@PersistenceCapable(identityType=IdentityType.APPLICATION, table="projects") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") +public class PCAppProject + implements IProject, Serializable, Comparable, Comparator, DeepEquality { + + @NotPersistent() + private long _projid; + @NotPersistent() + private String _name; + @NotPersistent() + private BigDecimal _budget; + @NotPersistent() + private transient Set _reviewers = new HashSet(); + @NotPersistent() + private transient Set _members = new HashSet(); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCAppProject() {} + + /** + * Initialize a project. + * @param projid The project identifier. + * @param name The name of the project. + * @param budget The budget for the project. + */ + public PCAppProject(long projid, String name, BigDecimal budget) { + this._projid = projid; + this._name = name; + this._budget = budget; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setProjid(long id) { + this._projid = id; + } + + /** + * Get the project ID. + * @return The project ID. + */ + + @PrimaryKey + @Column(name="PROJID") + public long getProjid() { + return _projid; + } + + /** + * Get the name of the project. + * @return The name of the project. + */ + + @Column(name="NAME") + public String getName() { + return _name; + } + + /** + * Set the name of the project. + * @param name The name of the project. + */ + public void setName(String name) { + this._name = name; + } + + /** + * Get the project's budget. + * @return The project's budget. + */ + + @Column(name="BUDGET", jdbcType="DECIMAL", length=11, scale=2) + public BigDecimal getBudget() { + return _budget; + } + + /** + * Set the project's budget. + * @param budget The project's budget. + */ + public void setBudget(BigDecimal budget) { + this._budget = budget; + } + + /** + * Get the reviewers associated with this project. + */ + + @Persistent(table="project_reviewer") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class, + column="REVIEWER") + @Join(column="PROJID", foreignKey="PR_PROJ_FK") + public Set getReviewers() { + return _reviewers; + } + + /** + * Add a reviewer to the project. + * @param emp The employee to add as a reviewer. + */ + public void addReviewer(PCAppEmployee emp) { + _reviewers.add(emp); } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) _projid; - } - - /** - * This class is used to represent the application identity for the PCAppProject - * class. - */ - public static class Oid implements Serializable, Comparable { /** - * This field represents the identifier for the PCAppProject class. It must match a - * field in the PCAppProject class in both name and type. + * Remove a reviewer from the project. + * @param emp The employee to remove as a reviewer of this project. */ - public long projid; + public void removeReviewer(PCAppEmployee emp) { + _reviewers.remove(emp); + } - /** The required public no-arg constructor. */ - public Oid() {} + /** + * Set the reviewers associated with this project. + * @param reviewers The set of reviewers to associate with this project. + */ + public void setReviewers(Set reviewers) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._reviewers = (reviewers != null) ? new HashSet(reviewers) : null; + } /** - * Initialize the application identifier with a project ID. - * - * @param projid The id of the project. + * Get the project members. + * + * + * @return The members of the project. */ - public Oid(long projid) { - this.projid = projid; + + @Persistent(table="project_member") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCAppEmployee.class, + column="MEMBER", foreignKey="PR_MEMB_FK") + @Join(column="PROJID", foreignKey="PR_PROJ_FK") + public Set getMembers() { + return _members; } - public Oid(String s) { - projid = Long.parseLong(justTheId(s)); + /** + * Add a new member to the project. + * @param emp The employee to add to the project. + */ + public void addMember(PCAppEmployee emp) { + _members.add(emp); } + /** + * Remove a member from the project. + * @param emp The employee to remove from the project. + */ + public void removeMember(PCAppEmployee emp) { + _members.remove(emp); + } + + /** + * Set the members of the project. + * @param employees The set of employees to be the members of this + * project. + */ + public void setMembers(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._members = (employees != null) ? new HashSet(employees) : null; + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + _reviewers = new HashSet(); + _members = new HashSet(); + } + + /** + * Returns a String representation of a PCAppProject object. + * + * + * @return a String representation of a PCAppProject object. + */ public String toString() { - return this.getClass().getName() + ": " + projid; + return "FCProject(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(_projid); + rc.append(", name ").append(_name); + rc.append(", budget ").append(_budget); + return rc.toString(); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.projid != o.projid) return (false); - return (true); + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCAppProject otherProject = (PCAppProject)other; + String where = "FCProject<" + _projid + ">"; + return + helper.equals(_projid, otherProject.getProjid(), where + ".projid") & + helper.equals(_name, otherProject.getName(), where + ".name") & + helper.equals(_budget, otherProject.getBudget(), where + ".budget") & + helper.deepEquals(_reviewers, otherProject.getReviewers(), where + ".reviewers") & + helper.deepEquals(_members, otherProject.getMembers(), where + ".members"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((PCAppProject)o); } - /** */ - public int hashCode() { - return ((int) projid); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCAppProject)o1, (PCAppProject)o2); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * + * Compares this object with the specified PCAppProject object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * + * + * @param other The PCAppProject object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified F\PFCAppProject object. + */ + public int compareTo(PCAppProject other) { + return compare(this, other); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (projid < other.projid) return -1; - if (projid > other.projid) return 1; - return 0; + /** + * Compares its two IProject arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IProject object to be compared. + * @param o2 the second IProject object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(PCAppProject o1, PCAppProject o2) { + return EqualityHelper.compare(o1.getProjid(), o2.getProjid()); } - } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof PCAppProject) { + return compareTo((PCAppProject)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)_projid; + } + + /** + * This class is used to represent the application identity + * for the PCAppProject class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the identifier for the + * PCAppProject class. It must match a field in the + * PCAppProject class in both name and type. + */ + public long projid; + + /** + * The required public no-arg constructor. + */ + public Oid() { } + + /** + * Initialize the application identifier with a project ID. + * @param projid The id of the project. + */ + public Oid(long projid) { + this.projid = projid; + } + + public Oid(String s) { projid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + projid;} + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.projid != o.projid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) projid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( projid < other.projid ) return -1; + if( projid > other.projid ) return 1; + return 0; + } + + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSAddress.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSAddress.java index 4fb4e4460..228a0d45f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSAddress.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSAddress.java @@ -5,341 +5,341 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; import java.io.Serializable; import java.util.Comparator; -import javax.jdo.annotations.PersistenceCapable; + +import javax.jdo.annotations.*; import org.apache.jdo.tck.pc.company.IAddress; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a postal address. */ -@PersistenceCapable(embeddedOnly = "true", requiresExtent = "false") -public class PCDSAddress implements IAddress, Serializable, Comparable, Comparator, DeepEquality { - - private long addrid; - private String street; - private String city; - private String state; - private String zipcode; - private String country; - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public PCDSAddress() {} - - /** - * This constructor initializes the PCDSAddress components. - * - * @param addrid The address ID. - * @param street The street address. - * @param city The city. - * @param state The state. - * @param zipcode The zip code. - * @param country The zip country. - */ - public PCDSAddress( - long addrid, String street, String city, String state, String zipcode, String country) { - this.addrid = addrid; - this.street = street; - this.city = city; - this.state = state; - this.zipcode = zipcode; - this.country = country; - } - - /** - * Get the addrid associated with this object. - * - * @return the addrid. - */ - public long getAddrid() { - return addrid; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setAddrid(long id) { - this.addrid = id; - } - - /** - * Get the street component of the address. - * - * @return The street component of the address. - */ - public String getStreet() { - return street; - } - - /** - * Set the street component of the address. - * - * @param street The street component. - */ - public void setStreet(String street) { - this.street = street; - } - - /** - * Get the city. - * - * @return The city component of the address. - */ - public String getCity() { - return city; - } - - /** - * Set the city component of the address. - * - * @param city The city. - */ - public void setCity(String city) { - this.city = city; - } - - /** - * Get the state component of the address. - * - * @return The state. - */ - public String getState() { - return state; - } - - /** - * Set the state component of the address. - * - * @param state The state. - */ - public void setState(String state) { - this.state = state; - } - - /** - * Get the zipcode component of the address. - * - * @return The zipcode. - */ - public String getZipcode() { - return zipcode; - } - - /** - * Set the zip code component of the address. - * - * @param zipcode The zipcode. - */ - public void setZipcode(String zipcode) { - this.zipcode = zipcode; - } - - /** - * Get the country component of the address. - * - * @return The country. - */ - public String getCountry() { - return country; - } - - /** - * Set the country component of the address. - * - * @param country The country. - */ - public void setCountry(String country) { - this.country = country; - } - - /** - * Returns a String representation of a Address object. - * - * @return a String representation of a Address object. - */ - public String toString() { - return "Address(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(addrid); - rc.append(", street ").append(street); - rc.append(", city ").append(city); - rc.append(", state ").append(state); - rc.append(", zipcode ").append(zipcode); - rc.append(", country ").append(country); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCDSAddress otherAddress = (PCDSAddress) other; - String where = "Address<" + addrid + ">"; - return helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") - & helper.equals(street, otherAddress.getStreet(), where + ".street") - & helper.equals(city, otherAddress.getCity(), where + ".city") - & helper.equals(state, otherAddress.getState(), where + ".state") - & helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") - & helper.equals(country, otherAddress.getCountry(), where + ".country"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((PCDSAddress) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((PCDSAddress) o1, (PCDSAddress) o2); - } - - /** - * Compares this object with the specified Address object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Address object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Address object. - */ - public int compareTo(PCDSAddress other) { - return compare(this, other); - } - - /** - * Compares its two PCDSAddress arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first PCDSAddress object to be compared. - * @param o2 the second PCDSAddressobject to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(PCDSAddress o1, PCDSAddress o2) { - return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof PCDSAddress) { - return compareTo((PCDSAddress) obj) == 0; +/** + * This class represents a postal address. + */ +@PersistenceCapable(embeddedOnly="true", requiresExtent="false") +public class PCDSAddress + implements IAddress, Serializable, Comparable, Comparator, DeepEquality { + + private long addrid; + private String street; + private String city; + private String state; + private String zipcode; + private String country; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCDSAddress() {} + + /** + * This constructor initializes the PCDSAddress components. + * + * + * @param addrid The address ID. + * @param street The street address. + * @param city The city. + * @param state The state. + * @param zipcode The zip code. + * @param country The zip country. + */ + public PCDSAddress(long addrid, String street, String city, + String state, String zipcode, String country) + { + this.addrid = addrid; + this.street = street; + this.city = city; + this.state = state; + this.zipcode = zipcode; + this.country = country; + } + + /** + * Get the addrid associated with this object. + * @return the addrid. + */ + public long getAddrid() { + return addrid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setAddrid(long id) { + this.addrid = id; + } + + /** + * Get the street component of the address. + * @return The street component of the address. + */ + public String getStreet() { + return street; + } + + /** + * Set the street component of the address. + * @param street The street component. + */ + public void setStreet(String street) { + this.street = street; + } + + /** + * Get the city. + * @return The city component of the address. + */ + public String getCity() { + return city; + } + + /** + * Set the city component of the address. + * @param city The city. + */ + public void setCity(String city) { + this.city = city; + } + + /** + * Get the state component of the address. + * @return The state. + */ + public String getState() { + return state; + } + + /** + * Set the state component of the address. + * @param state The state. + */ + public void setState(String state) { + this.state = state; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) addrid; - } - - /** - * This class is used to represent the application identifier for the Address class. - */ - public static class Oid implements Serializable, Comparable { /** - * This is the identifier field for Address and must correspond in type and name to - * the field in Address. + * Get the zipcode component of the address. + * @return The zipcode. */ - public long addrid; + public String getZipcode() { + return zipcode; + } - /** The required public, no-arg constructor. */ - public Oid() { - addrid = 0; + /** + * Set the zip code component of the address. + * @param zipcode The zipcode. + */ + public void setZipcode(String zipcode) { + this.zipcode = zipcode; } /** - * A constructor to initialize the identifier field. - * - * @param addrid the id of the Address. + * Get the country component of the address. + * @return The country. */ - public Oid(long addrid) { - this.addrid = addrid; + public String getCountry() { + return country; } - public Oid(String s) { - addrid = Long.parseLong(justTheId(s)); + /** + * Set the country component of the address. + * @param country The country. + */ + public void setCountry(String country) { + this.country = country; } + /** + * Returns a String representation of a Address object. + * @return a String representation of a Address object. + */ public String toString() { - return this.getClass().getName() + ": " + addrid; + return "Address(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(addrid); + rc.append(", street ").append(street); + rc.append(", city ").append(city); + rc.append(", state ").append(state); + rc.append(", zipcode ").append(zipcode); + rc.append(", country ").append(country); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCDSAddress otherAddress = (PCDSAddress)other; + String where = "Address<" + addrid + ">"; + return + helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") & + helper.equals(street, otherAddress.getStreet(), where + ".street") & + helper.equals(city, otherAddress.getCity(), where + ".city") & + helper.equals(state, otherAddress.getState(), where + ".state") & + helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") & + helper.equals(country, otherAddress.getCountry(), where + ".country"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((PCDSAddress)o); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.addrid != o.addrid) return (false); - return (true); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCDSAddress)o1, (PCDSAddress)o2); } - /** */ - public int hashCode() { - return ((int) addrid); + /** + * Compares this object with the specified Address object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Address object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Address + * object. + */ + public int compareTo(PCDSAddress other) { + return compare(this, other); + } + + /** + * Compares its two PCDSAddress arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * + * + * @param o1 the first PCDSAddress object to be compared. + * @param o2 the second PCDSAddressobject to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(PCDSAddress o1, PCDSAddress o2) { + return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof PCDSAddress) { + return compareTo((PCDSAddress)obj) == 0; + } + return false; } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (addrid < other.addrid) return -1; - if (addrid > other.addrid) return 1; - return 0; + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)addrid; + } + + /** + * This class is used to represent the application identifier + * for the Address class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This is the identifier field for Address and must + * correspond in type and name to the field in + * Address. + */ + public long addrid; + + /** The required public, no-arg constructor. */ + public Oid() + { + addrid = 0; + } + + /** + * A constructor to initialize the identifier field. + * @param addrid the id of the Address. + */ + public Oid(long addrid) { + this.addrid = addrid; + } + + public Oid(String s) { addrid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + addrid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.addrid != o.addrid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) addrid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( addrid < other.addrid ) return -1; + if( addrid > other.addrid ) return 1; + return 0; + } + } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSCompany.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSCompany.java index 60c5df9fe..e161b34b4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSCompany.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSCompany.java @@ -5,397 +5,409 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; -import java.io.IOException; -import java.io.ObjectInputStream; +import javax.jdo.annotations.*; + import java.io.Serializable; +import java.io.ObjectInputStream; +import java.io.IOException; + import java.text.SimpleDateFormat; + +import java.util.Collections; import java.util.Comparator; -import java.util.Date; -import java.util.HashSet; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.DatastoreIdentity; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.Embedded; -import javax.jdo.annotations.IdGeneratorStrategy; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.PersistenceModifier; -import javax.jdo.annotations.Persistent; +import java.util.HashSet; +import java.util.Date; import org.apache.jdo.tck.pc.company.IAddress; import org.apache.jdo.tck.pc.company.ICompany; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents information about a company. */ -@PersistenceCapable(table = "companies") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator(strategy = DiscriminatorStrategy.CLASS_NAME, column = "DISCRIMINATOR") -@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "DATASTORE_IDENTITY") -public class PCDSCompany implements ICompany, Serializable, Comparable, Comparator, DeepEquality { - - @NotPersistent() private long _companyid; - @NotPersistent() private String _name; - @NotPersistent() private Date _founded; - @NotPersistent() private PCDSAddress _address; - @NotPersistent() private transient Set _departments = new HashSet(); - - protected static SimpleDateFormat formatter = new SimpleDateFormat("d/MMM/yyyy"); - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public PCDSCompany() {} - - /** - * Initialize the PCDSCompany instance. - * - * @param companyid The company id. - * @param name The company name. - * @param founded The date the company was founded. - */ - public PCDSCompany(long companyid, String name, Date founded) { - this._companyid = companyid; - this._name = name; - this._founded = founded; - } - - /** - * Initialize the Company instance. - * - * @param companyid The company id. - * @param name The company name. - * @param founded The date the company was founded. - * @param addr The company's address. - */ - public PCDSCompany(long companyid, String name, Date founded, IAddress addr) { - this(companyid, name, founded); - this._address = (PCDSAddress) addr; - } - - /** - * Get the company id. - * - * @return The company id. - */ - @Column(name = "ID") - public long getCompanyid() { - return _companyid; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setCompanyid(long id) { - this._companyid = id; - } - - /** - * Get the name of the company. - * - * @return The name of the company. - */ - @Column(name = "NAME", jdbcType = "VARCHAR") - public String getName() { - return _name; - } - - /** - * Set the name of the company. - * - * @param name The value to use for the name of the company. - */ - public void setName(String name) { - this._name = name; - } - - /** - * Get the date that the company was founded. - * - * @return The date the company was founded. - */ - @Column(name = "FOUNDEDDATE") - public Date getFounded() { - return _founded; - } - - /** - * Set the date that the company was founded. - * - * @param founded The date to set that the company was founded. - */ - public void setFounded(Date founded) { - this._founded = founded; - } - - /** - * Get the address of the company. - * - * @return The primary address of the company. - */ - @Persistent( - persistenceModifier = PersistenceModifier.PERSISTENT, - types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSAddress.class) - @Embedded( - nullIndicatorColumn = "COUNTRY", - members = { - @Persistent(name = "addrid", columns = @Column(name = "ADDRID")), - @Persistent(name = "street", columns = @Column(name = "STREET")), - @Persistent(name = "city", columns = @Column(name = "CITY")), - @Persistent(name = "state", columns = @Column(name = "STATE")), - @Persistent(name = "zipcode", columns = @Column(name = "ZIPCODE")), - @Persistent(name = "country", columns = @Column(name = "COUNTRY")) - }) - public IAddress getAddress() { - return _address; - } - - /** - * Set the primary address for the company. - * - * @param address The address to set for the company. - */ - public void setAddress(IAddress address) { - this._address = (PCDSAddress) address; - } - - /** - * Get the departments contained in the company. - * - * @return All the PCDSDepartments of the company. - */ - @Persistent(persistenceModifier = PersistenceModifier.PERSISTENT, mappedBy = "company") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSDepartment.class) - public Set getDepartments() { - return _departments; - } - - /** - * Add a PCDSDepartment instance to the company. - * - * @param dept The PCDSDepartment instance to add. - */ - public void addDepartment(PCDSDepartment dept) { - _departments.add(dept); - } - - /** - * Remove a PCDSDepartment instance from the company. - * - * @param dept The PCDSDepartment instance to remove. - */ - public void removeDepartment(PCDSDepartment dept) { - _departments.remove(dept); - } - - /** - * Initialize the set of PCDSDepartments in the company to the parameter. - * - * @param departments The set of PCDSDepartments for the company. - */ - public void setDepartments(Set departments) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this._departments = (departments != null) ? new HashSet(departments) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - _departments = new HashSet(); - } - - /** - * Returns a String representation of a Company object. - * - * @return a String representation of a Company object. - */ - public String toString() { - return "Company(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(_companyid); - rc.append(", name ").append(_name); - rc.append(", founded ").append(_founded == null ? "null" : formatter.format(_founded)); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCDSCompany otherCompany = (PCDSCompany) other; - String where = "Company<" + _companyid + ">"; - return helper.equals(_companyid, otherCompany.getCompanyid(), where + ".companyid") - & helper.equals(_name, otherCompany.getName(), where + ".name") - & helper.equals(_founded, otherCompany.getFounded(), where + ".founded") - & helper.deepEquals(_address, otherCompany.getAddress(), where + ".address") - & helper.deepEquals(_departments, otherCompany.getDepartments(), where + ".departments"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((PCDSCompany) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((PCDSCompany) o1, (PCDSCompany) o2); - } - - /** - * Compares this object with the specified Company object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Company object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Company object. - */ - public int compareTo(PCDSCompany other) { - return compare(this, other); - } - - /** - * Compares its two ICompany arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first ICompany object to be compared. - * @param o2 the second ICompany object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(PCDSCompany o1, PCDSCompany o2) { - return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof PCDSCompany) { - return compareTo((PCDSCompany) obj) == 0; +/** + * This class represents information about a company. + */ +@PersistenceCapable(table="companies") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, + column="DATASTORE_IDENTITY") +public class PCDSCompany + implements ICompany, Serializable, Comparable, Comparator, DeepEquality { + + @NotPersistent() + private long _companyid; + @NotPersistent() + private String _name; + @NotPersistent() + private Date _founded; + @NotPersistent() + private PCDSAddress _address; + @NotPersistent() + private transient Set _departments = new HashSet(); + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCDSCompany() {} + + /** + * + * Initialize the PCDSCompany instance. + * + * + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + */ + public PCDSCompany(long companyid, String name, Date founded) { + this._companyid = companyid; + this._name = name; + this._founded = founded; + } + + /** + * Initialize the Company instance. + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + * @param addr The company's address. + */ + public PCDSCompany(long companyid, String name, Date founded, IAddress addr) { + this(companyid, name, founded); + this._address = (PCDSAddress)addr; + } + + /** + * Get the company id. + * @return The company id. + */ + + @Column(name="ID") + public long getCompanyid() { + return _companyid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setCompanyid(long id) { + this._companyid = id; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) _companyid; - } - - /** - * The class to be used as the application identifier for the Company class. It - * consists of both the company name and the date that the company was founded. - */ - public static class Oid implements Serializable, Comparable { /** - * This field is part of the identifier and should match in name and type with a field in the - * Company class. + * Get the name of the company. + * @return The name of the company. */ - public long companyid; - /** The required public no-arg constructor. */ - public Oid() {} + @Column(name="NAME", jdbcType="VARCHAR") + public String getName() { + return _name; + } /** - * Initialize the identifier. - * - * @param companyid The id of the company. + * Set the name of the company. + * @param name The value to use for the name of the company. */ - public Oid(long companyid) { - this.companyid = companyid; + public void setName(String name) { + this._name = name; } - public Oid(String s) { - companyid = Long.parseLong(justTheId(s)); + /** + * Get the date that the company was founded. + * @return The date the company was founded. + */ + + @Column(name="FOUNDEDDATE") + public Date getFounded() { + return _founded; } + /** + * Set the date that the company was founded. + * @param founded The date to set that the company was founded. + */ + public void setFounded(Date founded) { + this._founded = founded; + } + + /** + * Get the address of the company. + * @return The primary address of the company. + */ + + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT, + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSAddress.class) + @Embedded(nullIndicatorColumn="COUNTRY", + members={ + @Persistent(name="addrid", columns=@Column(name="ADDRID")), + @Persistent(name="street", columns=@Column(name="STREET")), + @Persistent(name="city", columns=@Column(name="CITY")), + @Persistent(name="state", columns=@Column(name="STATE")), + @Persistent(name="zipcode", columns=@Column(name="ZIPCODE")), + @Persistent(name="country", columns=@Column(name="COUNTRY")) + }) + public IAddress getAddress() { + return _address; + } + + /** + * Set the primary address for the company. + * @param address The address to set for the company. + */ + public void setAddress(IAddress address) { + this._address = (PCDSAddress)address; + } + + /** + * Get the departments contained in the company. + * + * + * @return All the PCDSDepartments of the company. + */ + + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT, + mappedBy="company") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSDepartment.class) + public Set getDepartments() { + return _departments; + } + + /** + * Add a PCDSDepartment instance to the company. + * + * + * @param dept The PCDSDepartment instance to add. + */ + public void addDepartment(PCDSDepartment dept) { + _departments.add(dept); + } + + /** + * Remove a PCDSDepartment instance from the company. + * + * + * @param dept The PCDSDepartment instance to remove. + */ + public void removeDepartment(PCDSDepartment dept) { + _departments.remove(dept); + } + + /** + * Initialize the set of PCDSDepartments in the company to the + * parameter. + * + * + * @param departments The set of PCDSDepartments for the + * company. + */ + public void setDepartments(Set departments) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._departments = + (departments != null) ? new HashSet(departments) : null; + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + _departments = new HashSet(); + } + + /** + * Returns a String representation of a Company object. + * @return a String representation of a Company object. + */ public String toString() { - return this.getClass().getName() + ": " + companyid; + return "Company(" + getFieldRepr()+ ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(_companyid); + rc.append(", name ").append(_name); + rc.append(", founded ").append( + _founded==null ? "null" : formatter.format(_founded)); + return rc.toString(); } - /** */ - public boolean equals(Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return false; - Oid o = (Oid) obj; - if (this.companyid != o.companyid) return false; - return true; + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCDSCompany otherCompany = (PCDSCompany)other; + String where = "Company<" + _companyid + ">"; + return + helper.equals(_companyid, otherCompany.getCompanyid(), where + ".companyid") & + helper.equals(_name, otherCompany.getName(), where + ".name") & + helper.equals(_founded, otherCompany.getFounded(), where + ".founded") & + helper.deepEquals(_address, otherCompany.getAddress(), where + ".address") & + helper.deepEquals(_departments, otherCompany.getDepartments(), where + ".departments"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((PCDSCompany)o); } - /** */ - public int hashCode() { - return (int) companyid; + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCDSCompany)o1, (PCDSCompany)o2); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compares this object with the specified Company object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Company object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Company + * object. + */ + public int compareTo(PCDSCompany other) { + return compare(this, other); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (companyid < other.companyid) return -1; - if (companyid > other.companyid) return 1; - return 0; + /** + * Compares its two ICompany arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first ICompany object to be compared. + * @param o2 the second ICompany object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(PCDSCompany o1, PCDSCompany o2) { + return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof PCDSCompany) { + return compareTo((PCDSCompany)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)_companyid; } - } + + /** + * The class to be used as the application identifier + * for the Company class. It consists of both the company + * name and the date that the company was founded. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field is part of the identifier and should match in name + * and type with a field in the Company class. + */ + public long companyid; + + /** The required public no-arg constructor. */ + public Oid() { } + + /** + * Initialize the identifier. + * @param companyid The id of the company. + */ + public Oid(long companyid) { + this.companyid = companyid; + } + + public Oid(String s) { companyid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + companyid;} + + + /** */ + public boolean equals(Object obj) { + if (obj==null || !this.getClass().equals(obj.getClass())) + return false; + Oid o = (Oid) obj; + if (this.companyid != o.companyid) + return false; + return true; + } + + /** */ + public int hashCode() { + return (int)companyid; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( companyid < other.companyid ) return -1; + if( companyid > other.companyid ) return 1; + return 0; + } + + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDentalInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDentalInsurance.java index 967b076bc..7af851c4d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDentalInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDentalInsurance.java @@ -5,126 +5,128 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; +import javax.jdo.annotations.*; + import java.math.BigDecimal; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.DatastoreIdentity; -import javax.jdo.annotations.IdGeneratorStrategy; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; import org.apache.jdo.tck.pc.company.IDentalInsurance; import org.apache.jdo.tck.util.EqualityHelper; /** - * This class represents a dental insurance carrier selection for a particular Employee - * . + * This class represents a dental insurance carrier selection for a + * particular Employee. */ @PersistenceCapable -@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "DATASTORE_IDENTITY") -public class PCDSDentalInsurance extends PCDSInsurance implements IDentalInsurance { +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY") +public class PCDSDentalInsurance extends PCDSInsurance + implements IDentalInsurance { + + @NotPersistent() + private BigDecimal _lifetimeOrthoBenefit; - @NotPersistent() private BigDecimal _lifetimeOrthoBenefit; + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCDSDentalInsurance() {} - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public PCDSDentalInsurance() {} + /** + * Construct a DentalInsurance instance. + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public PCDSDentalInsurance(long insid, String carrier, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier); + this._lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } - /** - * Construct a DentalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. - */ - public PCDSDentalInsurance(long insid, String carrier, BigDecimal lifetimeOrthoBenefit) { - super(insid, carrier); - this._lifetimeOrthoBenefit = lifetimeOrthoBenefit; - } + /** + * Construct a PCDSDentalInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. + */ + public PCDSDentalInsurance(long insid, String carrier, PCDSEmployee employee, + BigDecimal lifetimeOrthoBenefit) { + super(insid, carrier, employee); + this._lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } - /** - * Construct a PCDSDentalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param employee The employee associated with this insurance. - * @param lifetimeOrthoBenefit The lifetimeOrthoBenefit. - */ - public PCDSDentalInsurance( - long insid, String carrier, PCDSEmployee employee, BigDecimal lifetimeOrthoBenefit) { - super(insid, carrier, employee); - this._lifetimeOrthoBenefit = lifetimeOrthoBenefit; - } + /** + * Get the insurance lifetimeOrthoBenefit. + * @return The insurance lifetimeOrthoBenefit. + */ - /** - * Get the insurance lifetimeOrthoBenefit. - * - * @return The insurance lifetimeOrthoBenefit. - */ - @Column(name = "LIFETIME_ORTHO_BENEFIT") - public BigDecimal getLifetimeOrthoBenefit() { - return _lifetimeOrthoBenefit; - } + @Column(name="LIFETIME_ORTHO_BENEFIT") + public BigDecimal getLifetimeOrthoBenefit() { + return _lifetimeOrthoBenefit; + } - /** - * Set the insurance lifetimeOrthoBenefit. - * - * @param lifetimeOrthoBenefit The insurance lifetimeOrthoBenefit. - */ - public void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit) { - this._lifetimeOrthoBenefit = lifetimeOrthoBenefit; - } + /** + * Set the insurance lifetimeOrthoBenefit. + * @param lifetimeOrthoBenefit The insurance lifetimeOrthoBenefit. + */ + public void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit) { + this._lifetimeOrthoBenefit = lifetimeOrthoBenefit; + } - /** - * Returns a String representation of a PCDSDentalInsurance object. - * - * @return a String representation of a PCDSDentalInsurance object. - */ - public String toString() { - return "FCDentalInsurance(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of a PCDSDentalInsurance + * object. + * + * + * @return a String representation of a PCDSDentalInsurance + * object. + */ + public String toString() { + return "FCDentalInsurance(" + getFieldRepr()+ ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", lifetimeOrthoBenefit ").append(_lifetimeOrthoBenefit); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", lifetimeOrthoBenefit ").append(_lifetimeOrthoBenefit); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCDSDentalInsurance otherIns = (PCDSDentalInsurance)other; + String where = "FCDentalInsurance<" + getInsid() + ">"; + return super.deepCompareFields(otherIns, helper) & + helper.equals(_lifetimeOrthoBenefit, + otherIns.getLifetimeOrthoBenefit(), where + ".lifetimeOrthoBenefit"); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Object. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCDSDentalInsurance otherIns = (PCDSDentalInsurance) other; - String where = "FCDentalInsurance<" + getInsid() + ">"; - return super.deepCompareFields(otherIns, helper) - & helper.equals( - _lifetimeOrthoBenefit, - otherIns.getLifetimeOrthoBenefit(), - where + ".lifetimeOrthoBenefit"); - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDepartment.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDepartment.java index 6e59c9684..7540c391c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDepartment.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSDepartment.java @@ -5,451 +5,457 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; -import java.io.IOException; -import java.io.ObjectInputStream; +import javax.jdo.annotations.*; + import java.io.Serializable; +import java.io.ObjectInputStream; +import java.io.IOException; + +import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.DatastoreIdentity; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.IdGeneratorStrategy; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; import org.apache.jdo.tck.pc.company.ICompany; import org.apache.jdo.tck.pc.company.IDepartment; import org.apache.jdo.tck.pc.company.IEmployee; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a department within a company. */ -@PersistenceCapable(table = "departments") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator(strategy = DiscriminatorStrategy.CLASS_NAME, column = "DISCRIMINATOR") -@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "DATASTORE_IDENTITY") +/** + * This class represents a department within a company. + */ +@PersistenceCapable(table="departments") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, + column="DATASTORE_IDENTITY") public class PCDSDepartment implements IDepartment, Serializable, Comparable, Comparator, DeepEquality { - public static final int RECOMMENDED_NO_OF_EMPS = 2; - - @NotPersistent() private long _deptid; - @NotPersistent() private String _name; - @NotPersistent() private PCDSCompany _company; - @NotPersistent() private PCDSEmployee _employeeOfTheMonth; - @NotPersistent() private transient Set _employees = new HashSet(); - @NotPersistent() private transient Set _fundedEmps = new HashSet(); - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public PCDSDepartment() {} - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - */ - public PCDSDepartment(long deptid, String name) { - this._deptid = deptid; - this._name = name; - } - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - * @param company The company that the department is associated with. - */ - public PCDSDepartment(long deptid, String name, ICompany company) { - this._deptid = deptid; - this._name = name; - this._company = (PCDSCompany) company; - } - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - * @param company The company that the department is associated with. - * @param employeeOfTheMonth The employee of the month the department is associated with. - */ - public PCDSDepartment(long deptid, String name, ICompany company, IEmployee employeeOfTheMonth) { - this._deptid = deptid; - this._name = name; - this._company = (PCDSCompany) company; - this._employeeOfTheMonth = (PCDSEmployee) employeeOfTheMonth; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setDeptid(long id) { - this._deptid = id; - } - - /** - * Get the department id. - * - * @return The department id. - */ - @Column(name = "ID") - public long getDeptid() { - return _deptid; - } - - /** - * Get the name of the department. - * - * @return The name of the department. - */ - @Column(name = "NAME") - public String getName() { - return _name; - } - - /** - * Set the name of the department. - * - * @param name The name to set for the department. - */ - public void setName(String name) { - this._name = name; - } - - /** - * Get the company associated with the department. - * - * @return The company. - */ - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSCompany.class) - @Column(name = "COMPANYID") - public ICompany getCompany() { - return _company; - } - - /** - * Set the company for the department. - * - * @param company The company to associate with the department. - */ - public void setCompany(ICompany company) { - this._company = (PCDSCompany) company; - } - - /** - * Get the employee of the month associated with the department. - * - * @return The employee of the month. - */ - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) - @Column(name = "EMP_OF_THE_MONTH") - public IEmployee getEmployeeOfTheMonth() { - return _employeeOfTheMonth; - } - - /** - * Set the employee of the month for the department. - * - * @param employeeOfTheMonth The employee of the month to associate with the department. - */ - public void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth) { - this._employeeOfTheMonth = (PCDSEmployee) employeeOfTheMonth; - } - - /** - * Get the employees in the department. - * - * @return The set of employees in the department. - */ - @Persistent(mappedBy = "department") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) - public Set getEmployees() { - return _employees; - } - - /** - * Add an employee to the department. - * - * @param emp The employee to add to the department. - */ - public void addEmployee(PCDSEmployee emp) { - _employees.add(emp); - } - - /** - * Remove an employee from the department. - * - * @param emp The employee to remove from the department. - */ - public void removeEmployee(PCDSEmployee emp) { - _employees.remove(emp); - } - - /** - * Set the employees to be in this department. - * - * @param employees The set of employees for this department. - */ - public void setEmployees(Set employees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this._employees = (employees != null) ? new HashSet(employees) : null; - } - - /** - * Get the funded employees in the department. - * - * @return The set of funded employees in the department. - */ - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) - @Persistent(mappedBy = "fundingDept") - public Set getFundedEmps() { - return _fundedEmps; - } - - /** - * Add an employee to the collection of funded employees of this department. - * - * @param emp The employee to add to the department. - */ - public void addFundedEmp(PCDSEmployee emp) { - _fundedEmps.add(emp); - } - - /** - * Remove an employee from collection of funded employees of this department. - * - * @param emp The employee to remove from the department. - */ - public void removeFundedEmp(PCDSEmployee emp) { - _fundedEmps.remove(emp); - } - - /** - * Set the funded employees to be in this department. - * - * @param employees The set of funded employees for this department. - */ - public void setFundedEmps(Set employees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this._fundedEmps = (employees != null) ? new HashSet(employees) : null; - } - - @Override - public List getMeetingRooms() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void setMeetingRooms(List rooms) { - // TODO Auto-generated method stub - - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - _employees = new HashSet(); - _fundedEmps = new HashSet(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other PCDSDepartment. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCDSDepartment otherDept = (PCDSDepartment) other; - String where = "FCDepartment<" + _deptid + ">"; - return helper.equals(_deptid, otherDept.getDeptid(), where + ".deptid") - & helper.equals(_name, otherDept.getName(), where + ".name") - & helper.deepEquals(_company, otherDept.getCompany(), where + ".company") - & helper.deepEquals( - _employeeOfTheMonth, otherDept.getEmployeeOfTheMonth(), where + ".employeeOfTheMonth") - & helper.deepEquals(_employees, otherDept.getEmployees(), where + ".employees") - & helper.deepEquals(_fundedEmps, otherDept.getFundedEmps(), where + ".fundedEmps"); - } - - /** - * Returns a String representation of a PCDSDepartment object. - * - * @return a String representation of a PCDSDepartment object. - */ - public String toString() { - return "FCDepartment(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(_deptid); - rc.append(", name ").append(_name); - return rc.toString(); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((PCDSDepartment) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((PCDSDepartment) o1, (PCDSDepartment) o2); - } - - /** - * Compares this object with the specified Department object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Department object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Department object. - */ - public int compareTo(PCDSDepartment other) { - return compare(this, other); - } - - /** - * Compares its two IDepartment arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IDepartment object to be compared. - * @param o2 the second IDepartment object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(PCDSDepartment o1, PCDSDepartment o2) { - return EqualityHelper.compare(o1.getDeptid(), o2.getDeptid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof PCDSDepartment) { - return compareTo((PCDSDepartment) obj) == 0; + public static final int RECOMMENDED_NO_OF_EMPS = 2; + + @NotPersistent() + private long _deptid; + @NotPersistent() + private String _name; + @NotPersistent() + private PCDSCompany _company; + @NotPersistent() + private PCDSEmployee _employeeOfTheMonth; + @NotPersistent() + private transient Set _employees = new HashSet(); + @NotPersistent() + private transient Set _fundedEmps = new HashSet(); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCDSDepartment() {} + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + */ + public PCDSDepartment(long deptid, String name) { + this._deptid = deptid; + this._name = name; + } + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + * @param company The company that the department is associated with. + */ + public PCDSDepartment(long deptid, String name, ICompany company) { + this._deptid = deptid; + this._name = name; + this._company = (PCDSCompany)company; + } + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + * @param company The company that the department is associated with. + * @param employeeOfTheMonth The employee of the month the + * department is associated with. + */ + public PCDSDepartment(long deptid, String name, ICompany company, + IEmployee employeeOfTheMonth) { + this._deptid = deptid; + this._name = name; + this._company = (PCDSCompany)company; + this._employeeOfTheMonth = (PCDSEmployee)employeeOfTheMonth; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setDeptid(long id) { + this._deptid = id; + } + + /** + * Get the department id. + * @return The department id. + */ + @Column(name="ID") + public long getDeptid() { + return _deptid; + } + + /** + * Get the name of the department. + * @return The name of the department. + */ + + @Column(name="NAME") + public String getName() { + return _name; + } + + /** + * Set the name of the department. + * @param name The name to set for the department. + */ + public void setName(String name) { + this._name = name; + } + + /** + * Get the company associated with the department. + * @return The company. + */ + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSCompany.class) + @Column(name="COMPANYID") + public ICompany getCompany() { + return _company; + } + + /** + * Set the company for the department. + * @param company The company to associate with the department. + */ + public void setCompany(ICompany company) { + this._company = (PCDSCompany)company; } - return false; - } - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) _deptid; - } + /** + * Get the employee of the month associated with the department. + * @return The employee of the month. + */ + + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + @Column(name="EMP_OF_THE_MONTH") + public IEmployee getEmployeeOfTheMonth() { + return _employeeOfTheMonth; + } - /** The application identity class associated with the Department class. */ - public static class Oid implements Serializable, Comparable { + /** + * Set the employee of the month for the department. + * @param employeeOfTheMonth The employee of the month to + * associate with the department. + */ + public void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth) { + this._employeeOfTheMonth = (PCDSEmployee)employeeOfTheMonth; + } /** - * This field represents the application identifier field for the Department class. - * It must match in name and type with the field in the Department class. + * Get the employees in the department. + * @return The set of employees in the department. */ - public long deptid; - /** The required public, no-arg constructor. */ - public Oid() {} + @Persistent(mappedBy="department") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + public Set getEmployees() { + return _employees; + } /** - * A constructor to initialize the identifier field. - * - * @param deptid the deptid of the Department. + * Add an employee to the department. + * @param emp The employee to add to the department. */ - public Oid(long deptid) { - this.deptid = deptid; + public void addEmployee(PCDSEmployee emp) { + _employees.add(emp); } - public Oid(String s) { - deptid = Long.parseLong(justTheId(s)); + /** + * Remove an employee from the department. + * @param emp The employee to remove from the department. + */ + public void removeEmployee(PCDSEmployee emp) { + _employees.remove(emp); } + /** + * Set the employees to be in this department. + * @param employees The set of employees for this department. + */ + public void setEmployees(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._employees = (employees != null) ? new HashSet(employees) : null; + } + + /** + * Get the funded employees in the department. + * @return The set of funded employees in the department. + */ + + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + @Persistent(mappedBy="fundingDept") + public Set getFundedEmps() { + return _fundedEmps; + } + + /** + * Add an employee to the collection of funded employees of this + * department. + * @param emp The employee to add to the department. + */ + public void addFundedEmp(PCDSEmployee emp) { + _fundedEmps.add(emp); + } + + /** + * Remove an employee from collection of funded employees of this + * department. + * @param emp The employee to remove from the department. + */ + public void removeFundedEmp(PCDSEmployee emp) { + _fundedEmps.remove(emp); + } + + /** + * Set the funded employees to be in this department. + * @param employees The set of funded employees for this department. + */ + public void setFundedEmps(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._fundedEmps = (employees != null) ? new HashSet(employees) : null; + } + + @Override + public List getMeetingRooms() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void setMeetingRooms(List rooms) { + // TODO Auto-generated method stub + + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + _employees = new HashSet(); + _fundedEmps = new HashSet(); + } + + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other PCDSDepartment. + * + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCDSDepartment otherDept = (PCDSDepartment)other; + String where = "FCDepartment<" + _deptid + ">"; + return + helper.equals(_deptid, otherDept.getDeptid(), where + ".deptid") & + helper.equals(_name, otherDept.getName(), where + ".name") & + helper.deepEquals(_company, otherDept.getCompany(), where + ".company") & + helper.deepEquals(_employeeOfTheMonth, otherDept.getEmployeeOfTheMonth(), where + ".employeeOfTheMonth") & + helper.deepEquals(_employees, otherDept.getEmployees(), where + ".employees") & + helper.deepEquals(_fundedEmps, otherDept.getFundedEmps(), where + ".fundedEmps"); + } + + /** + * Returns a String representation of a PCDSDepartment object. + * + * + * @return a String representation of a PCDSDepartment object. + */ public String toString() { - return this.getClass().getName() + ": " + deptid; + return "FCDepartment(" + getFieldRepr()+ ")"; } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.deptid != o.deptid) return (false); - return (true); + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(_deptid); + rc.append(", name ").append(_name); + return rc.toString(); } - /** */ - public int hashCode() { - return ((int) deptid); + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((PCDSDepartment)o); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCDSDepartment)o1, (PCDSDepartment)o2); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (deptid < other.deptid) return -1; - if (deptid > other.deptid) return 1; - return 0; + /** + * Compares this object with the specified Department object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Department object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified + * Department object. + */ + public int compareTo(PCDSDepartment other) { + return compare(this, other); + } + + /** + * Compares its two IDepartment arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IDepartment object to be compared. + * @param o2 the second IDepartment object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(PCDSDepartment o1, PCDSDepartment o2) { + return EqualityHelper.compare(o1.getDeptid(), o2.getDeptid()); } - } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof PCDSDepartment) { + return compareTo((PCDSDepartment)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)_deptid; + } + + /** + * The application identity class associated with the + * Department class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the application identifier field + * for the Department class. + * It must match in name and type with the field in the + * Department class. + */ + public long deptid; + + /** + * The required public, no-arg constructor. + */ + public Oid() { } + + /** + * A constructor to initialize the identifier field. + * @param deptid the deptid of the Department. + */ + public Oid(long deptid) { + this.deptid = deptid; + } + + public Oid(String s) { deptid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + deptid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.deptid != o.deptid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) deptid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( deptid < other.deptid ) return -1; + if( deptid > other.deptid ) return 1; + return 0; + } + + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSEmployee.java index 5d861e626..1ab6ff754 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSEmployee.java @@ -5,544 +5,552 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; -import java.io.IOException; +import javax.jdo.annotations.*; + import java.io.ObjectInputStream; +import java.io.IOException; + +import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.DatastoreIdentity; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.IdGeneratorStrategy; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; import org.apache.jdo.tck.pc.company.IDentalInsurance; import org.apache.jdo.tck.pc.company.IDepartment; import org.apache.jdo.tck.pc.company.IEmployee; import org.apache.jdo.tck.pc.company.IMedicalInsurance; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents an employee. */ +/** + * This class represents an employee. + */ @PersistenceCapable -@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE) -@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "DATASTORE_IDENTITY") +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY") public abstract class PCDSEmployee extends PCDSPerson implements IEmployee { - @NotPersistent() private Date _hiredate; - @NotPersistent() private double _weeklyhours; - @NotPersistent() private PCDSDentalInsurance _dentalInsurance; - @NotPersistent() private PCDSMedicalInsurance _medicalInsurance; - @NotPersistent() private PCDSDepartment _department; - @NotPersistent() private PCDSDepartment _fundingDept; - @NotPersistent() private PCDSEmployee _manager; - @NotPersistent() private PCDSEmployee _mentor; - @NotPersistent() private PCDSEmployee _protege; - @NotPersistent() private PCDSEmployee _hradvisor; - @NotPersistent() private transient Set _reviewedProjects = new HashSet(); - @NotPersistent() private transient Set _projects = new HashSet(); - @NotPersistent() private transient Set _team = new HashSet(); - @NotPersistent() private transient Set _hradvisees = new HashSet(); - - /** This is the JDO-required no-args constructor */ - protected PCDSEmployee() {} - - /** - * Construct an PCDSEmployee instance. - * - * @param personid The identifier for the person. - * @param firstname The first name of the employee. - * @param lastname The last name of the employee. - * @param middlename The middle name of the employee. - * @param birthdate The birth date of the employee. - * @param hiredate The date that the employee was hired. - */ - public PCDSEmployee( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - Date hiredate) { - super(personid, firstname, lastname, middlename, birthdate); - this._hiredate = hiredate; - } - - /** - * Construct an PCDSEmployee instance. - * - * @param personid The identifier for the person. - * @param firstname The first name of the employee. - * @param lastname The last name of the employee. - * @param middlename The middle name of the employee. - * @param birthdate The birth date of the employee. - * @param address The address of the employee. - * @param hiredate The date that the employee was hired. - */ - public PCDSEmployee( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - PCDSAddress address, - Date hiredate) { - super(personid, firstname, lastname, middlename, birthdate, address); - this._hiredate = hiredate; - } - - /** - * Get the date that the employee was hired. - * - * @return The date the employee was hired. - */ - @Column(name = "HIREDATE") - public Date getHiredate() { - return _hiredate; - } - - /** - * Set the date that the employee was hired. - * - * @param hiredate The date the employee was hired. - */ - public void setHiredate(Date hiredate) { - this._hiredate = hiredate; - } - - /** - * Get the weekly hours of the employee. - * - * @return The number of hours per week that the employee works. - */ - @Column(name = "WEEKLYHOURS") - public double getWeeklyhours() { - return _weeklyhours; - } - - /** - * Set the number of hours per week that the employee works. - * - * @param weeklyhours The number of hours per week that the employee works. - */ - public void setWeeklyhours(double weeklyhours) { - this._weeklyhours = weeklyhours; - } - - /** - * Get the reviewed projects. - * - * @return The reviewed projects. - */ - @Persistent(mappedBy = "reviewers") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSProject.class) - public Set getReviewedProjects() { - return _reviewedProjects; - } - - /** - * Add a reviewed project. - * - * @param project A reviewed project. - */ - public void addReviewedProjects(PCDSProject project) { - _reviewedProjects.add(project); - } - - /** - * Remove a reviewed project. - * - * @param project A reviewed project. - */ - public void removeReviewedProject(PCDSProject project) { - _reviewedProjects.remove(project); - } - - /** - * Set the reviewed projects for the employee. - * - * @param reviewedProjects The set of reviewed projects. - */ - public void setReviewedProjects(Set reviewedProjects) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this._reviewedProjects = (reviewedProjects != null) ? new HashSet(reviewedProjects) : null; - } - - /** - * Get the employee's projects. - * - * @return The employee's projects. - */ - @Persistent(mappedBy = "members") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSProject.class) - public Set getProjects() { - return _projects; - } - - /** - * Add a project for the employee. - * - * @param project The project. - */ - public void addProject(PCDSProject project) { - _projects.add(project); - } - - /** - * Remove a project from an employee's set of projects. - * - * @param project The project. - */ - public void removeProject(PCDSProject project) { - _projects.remove(project); - } - - /** - * Set the projects for the employee. - * - * @param projects The set of projects of the employee. - */ - public void setProjects(Set projects) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this._projects = (projects != null) ? new HashSet(projects) : null; - } - - /** - * Get the dental insurance of the employee. - * - * @return The employee's dental insurance. - */ - @Persistent( - mappedBy = "employee", - types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSDentalInsurance.class) - public IDentalInsurance getDentalInsurance() { - return _dentalInsurance; - } - - /** - * Set the dental insurance object for the employee. - * - * @param dentalInsurance The dental insurance object to associate with the employee. - */ - public void setDentalInsurance(IDentalInsurance dentalInsurance) { - this._dentalInsurance = (PCDSDentalInsurance) dentalInsurance; - } - - /** - * Get the medical insurance of the employee. - * - * @return The employee's medical insurance. - */ - @Persistent( - mappedBy = "employee", - types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSMedicalInsurance.class) - public IMedicalInsurance getMedicalInsurance() { - return _medicalInsurance; - } - - /** - * Set the medical insurance object for the employee. - * - * @param medicalInsurance The medical insurance object to associate with the employee. - */ - public void setMedicalInsurance(IMedicalInsurance medicalInsurance) { - this._medicalInsurance = (PCDSMedicalInsurance) medicalInsurance; - } - - /** - * Get the employee's department. - * - * @return The department associated with the employee. - */ - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSDepartment.class) - @Column(name = "DEPARTMENT") - public IDepartment getDepartment() { - return _department; - } - - /** - * Set the employee's department. - * - * @param department The department. - */ - public void setDepartment(IDepartment department) { - this._department = (PCDSDepartment) department; - } - - /** - * Get the employee's funding department. - * - * @return The funding department associated with the employee. - */ - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSDepartment.class) - @Column(name = "FUNDINGDEPT") - public IDepartment getFundingDept() { - return _fundingDept; - } - - /** - * Set the employee's funding department. - * - * @param department The funding department. - */ - public void setFundingDept(IDepartment department) { - this._fundingDept = (PCDSDepartment) department; - } - - /** - * Get the employee's manager. - * - * @return The employee's manager. - */ - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) - @Column(name = "MANAGER") - public IEmployee getManager() { - return _manager; - } - - /** - * Set the employee's manager. - * - * @param manager The employee's manager. - */ - public void setManager(IEmployee manager) { - this._manager = (PCDSEmployee) manager; - } - - /** - * Get the employee's team. - * - * @return The set of PCDSEmployees on this employee's team. - */ - @Persistent(mappedBy = "manager") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) - public Set getTeam() { - return _team; - } - - /** - * Add an PCDSEmployee to this employee's team. This method sets both sides of the - * relationship, modifying this employees team to include parameter emp and modifying emp to set - * its manager attribute to this object. - * - * @param emp The PCDSEmployee to add to the team. - */ - public void addToTeam(PCDSEmployee emp) { - _team.add(emp); - emp._manager = this; - } - - /** - * Remove an PCDSEmployee from this employee's team. This method will also set the - * emp manager to null. - * - * @param emp The PCDSEmployee to remove from the team. - */ - public void removeFromTeam(PCDSEmployee emp) { - _team.remove(emp); - emp._manager = null; - } - - /** - * Set the employee's team. - * - * @param team The set of PCDSEmployees. - */ - public void setTeam(Set team) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this._team = (team != null) ? new HashSet(team) : null; - } - - /** - * Set the mentor for this employee. - * - * @param mentor The mentor for this employee. - */ - public void setMentor(IEmployee mentor) { - this._mentor = (PCDSEmployee) mentor; - } - - /** - * Get the mentor for this employee. - * - * @return The mentor. - */ - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) - @Column(name = "MENTOR") - public IEmployee getMentor() { - return _mentor; - } - - /** - * Set the protege for this employee. - * - * @param protege The protege for this employee. - */ - public void setProtege(IEmployee protege) { - this._protege = (PCDSEmployee) protege; - } - - /** - * Get the protege of this employee. - * - * @return The protege of this employee. - */ - @Persistent( - mappedBy = "mentor", - types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) - public IEmployee getProtege() { - return _protege; - } - - /** - * Set the HR advisor for this employee. - * - * @param hradvisor The hradvisor for this employee. - */ - public void setHradvisor(IEmployee hradvisor) { - this._hradvisor = (PCDSEmployee) hradvisor; - } - - /** - * Get the HR advisor for the employee. - * - * @return The HR advisor. - */ - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) - @Column(name = "HRADVISOR") - public IEmployee getHradvisor() { - return _hradvisor; - } - - /** - * Get the HR advisees of this HR advisor. - * - * @return The PCDSEmployees that are HR advisees of this employee. - */ - @Persistent(mappedBy = "hradvisor") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) - public Set getHradvisees() { - return _hradvisees; - } - - /** - * Add an PCDSEmployee as an advisee of this HR advisor. This method also sets the - * emp hradvisor to reference this object. In other words, both sides of the - * relationship are set. - * - * @param emp The employee to add as an advisee. - */ - public void addAdvisee(PCDSEmployee emp) { - _hradvisees.add(emp); - emp._hradvisor = this; - } - - /** - * Remove an PCDSEmployee as an advisee of this HR advisor. This method also sets the - * emp hradvisor to null. In other words, both sides of the relationship are set. - * - * @param emp The employee to add as an HR advisee. - */ - public void removeAdvisee(PCDSEmployee emp) { - _hradvisees.remove(emp); - emp._hradvisor = null; - } - - /** - * Set the HR advisees of this HR advisor. - * - * @param hradvisees The PCDSEmployees that are HR advisees of this employee. - */ - public void setHradvisees(Set hradvisees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this._hradvisees = (hradvisees != null) ? new HashSet(hradvisees) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - _reviewedProjects = new HashSet(); - _projects = new HashSet(); - _team = new HashSet(); - _hradvisees = new HashSet(); - } - - /** - * Return a String representation of a PCDSEmployee object. - * - * @return a String representation of a PCDSEmployee object. - */ - public String toString() { - return "FCEmployee(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", hired ").append(_hiredate == null ? "null" : formatter.format(_hiredate)); - rc.append(", weeklyhours ").append(_weeklyhours); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the - * corresponding fields of the specified PCDSEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCDSEmployee otherEmp = (PCDSEmployee) other; - String where = "Employee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.equals(_hiredate, otherEmp.getHiredate(), where + ".hiredate") - & helper.closeEnough(_weeklyhours, otherEmp.getWeeklyhours(), where + ".weeklyhours") - & helper.deepEquals( - _dentalInsurance, otherEmp.getDentalInsurance(), where + ".dentalInsurance") - & helper.deepEquals( - _medicalInsurance, otherEmp.getMedicalInsurance(), where + ".medicalInsurance") - & helper.deepEquals(_department, otherEmp.getDepartment(), where + ".department") - & helper.deepEquals(_fundingDept, otherEmp.getFundingDept(), where + ".fundingDept") - & helper.deepEquals(_manager, otherEmp.getManager(), where + ".manager") - & helper.deepEquals(_mentor, otherEmp.getMentor(), where + ".mentor") - & helper.deepEquals(_protege, otherEmp.getProtege(), where + ".protege") - & helper.deepEquals(_hradvisor, otherEmp.getHradvisor(), where + ".hradvisor") - & helper.deepEquals( - _reviewedProjects, otherEmp.getReviewedProjects(), where + ".reviewedProjects") - & helper.deepEquals(_projects, otherEmp.getProjects(), where + ".projects") - & helper.deepEquals(_team, otherEmp.getTeam(), where + ".team") - & helper.deepEquals(_hradvisees, otherEmp.getHradvisees(), where + ".hradvisees"); - } + @NotPersistent() + private Date _hiredate; + @NotPersistent() + private double _weeklyhours; + @NotPersistent() + private PCDSDentalInsurance _dentalInsurance; + @NotPersistent() + private PCDSMedicalInsurance _medicalInsurance; + @NotPersistent() + private PCDSDepartment _department; + @NotPersistent() + private PCDSDepartment _fundingDept; + @NotPersistent() + private PCDSEmployee _manager; + @NotPersistent() + private PCDSEmployee _mentor; + @NotPersistent() + private PCDSEmployee _protege; + @NotPersistent() + private PCDSEmployee _hradvisor; + @NotPersistent() + private transient Set _reviewedProjects = new HashSet(); + @NotPersistent() + private transient Set _projects = new HashSet(); + @NotPersistent() + private transient Set _team = new HashSet(); + @NotPersistent() + private transient Set _hradvisees = new HashSet(); + + + /** This is the JDO-required no-args constructor */ + protected PCDSEmployee() {} + + /** + * Construct an PCDSEmployee instance. + * + * + * @param personid The identifier for the person. + * @param firstname The first name of the employee. + * @param lastname The last name of the employee. + * @param middlename The middle name of the employee. + * @param birthdate The birth date of the employee. + * @param hiredate The date that the employee was hired. + */ + public PCDSEmployee(long personid, String firstname, String lastname, + String middlename, Date birthdate, + Date hiredate) { + super(personid, firstname, lastname, middlename, birthdate); + this._hiredate = hiredate; + } + + /** + * Construct an PCDSEmployee instance. + * + * + * @param personid The identifier for the person. + * @param firstname The first name of the employee. + * @param lastname The last name of the employee. + * @param middlename The middle name of the employee. + * @param birthdate The birth date of the employee. + * @param address The address of the employee. + * @param hiredate The date that the employee was hired. + */ + public PCDSEmployee(long personid, String firstname, String lastname, + String middlename, Date birthdate, PCDSAddress address, + Date hiredate) { + super(personid, firstname, lastname, middlename, birthdate, address); + this._hiredate = hiredate; + } + + /** + * Get the date that the employee was hired. + * @return The date the employee was hired. + */ + + @Column(name="HIREDATE") + public Date getHiredate() { + return _hiredate; + } + + /** + * Set the date that the employee was hired. + * @param hiredate The date the employee was hired. + */ + public void setHiredate(Date hiredate) { + this._hiredate = hiredate; + } + + /** + * Get the weekly hours of the employee. + * @return The number of hours per week that the employee works. + */ + + @Column(name="WEEKLYHOURS") + public double getWeeklyhours() { + return _weeklyhours; + } + + /** + * Set the number of hours per week that the employee works. + * @param weeklyhours The number of hours per week that the employee + * works. + */ + public void setWeeklyhours(double weeklyhours) { + this._weeklyhours = weeklyhours; + } + + /** + * Get the reviewed projects. + * @return The reviewed projects. + */ + + @Persistent(mappedBy="reviewers") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSProject.class) + public Set getReviewedProjects() { + return _reviewedProjects; + } + + /** + * Add a reviewed project. + * @param project A reviewed project. + */ + public void addReviewedProjects(PCDSProject project) { + _reviewedProjects.add(project); + } + + /** + * Remove a reviewed project. + * @param project A reviewed project. + */ + public void removeReviewedProject(PCDSProject project) { + _reviewedProjects.remove(project); + } + + /** + * Set the reviewed projects for the employee. + * @param reviewedProjects The set of reviewed projects. + */ + public void setReviewedProjects(Set reviewedProjects) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._reviewedProjects = + (reviewedProjects != null) ? new HashSet(reviewedProjects) : null; + } + + /** + * Get the employee's projects. + * @return The employee's projects. + */ + + @Persistent(mappedBy="members") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSProject.class) + public Set getProjects() { + return _projects; + } + + /** + * Add a project for the employee. + * @param project The project. + */ + public void addProject(PCDSProject project) { + _projects.add(project); + } + + /** + * Remove a project from an employee's set of projects. + * @param project The project. + */ + public void removeProject(PCDSProject project) { + _projects.remove(project); + } + + /** + * Set the projects for the employee. + * @param projects The set of projects of the employee. + */ + public void setProjects(Set projects) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._projects = (projects != null) ? new HashSet(projects) : null; + } + + /** + * Get the dental insurance of the employee. + * @return The employee's dental insurance. + */ + + @Persistent(mappedBy="employee", + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSDentalInsurance.class) + public IDentalInsurance getDentalInsurance() { + return _dentalInsurance; + } + + /** + * Set the dental insurance object for the employee. + * @param dentalInsurance The dental insurance object to associate with + * the employee. + */ + public void setDentalInsurance(IDentalInsurance dentalInsurance) { + this._dentalInsurance = (PCDSDentalInsurance)dentalInsurance; + } + + /** + * Get the medical insurance of the employee. + * @return The employee's medical insurance. + */ + @Persistent(mappedBy="employee", + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSMedicalInsurance.class) + public IMedicalInsurance getMedicalInsurance() { + return _medicalInsurance; + } + + /** + * Set the medical insurance object for the employee. + * @param medicalInsurance The medical insurance object to associate + * with the employee. + */ + public void setMedicalInsurance(IMedicalInsurance medicalInsurance) { + this._medicalInsurance = (PCDSMedicalInsurance)medicalInsurance; + } + + /** + * Get the employee's department. + * @return The department associated with the employee. + */ + + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSDepartment.class) + @Column(name="DEPARTMENT") + public IDepartment getDepartment() { + return _department; + } + + /** + * Set the employee's department. + * @param department The department. + */ + public void setDepartment(IDepartment department) { + this._department = (PCDSDepartment)department; + } + + /** + * Get the employee's funding department. + * @return The funding department associated with the employee. + */ + + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSDepartment.class) + @Column(name="FUNDINGDEPT") + public IDepartment getFundingDept() { + return _fundingDept; + } + + /** + * Set the employee's funding department. + * @param department The funding department. + */ + public void setFundingDept(IDepartment department) { + this._fundingDept = (PCDSDepartment)department; + } + + /** + * Get the employee's manager. + * @return The employee's manager. + */ + + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + @Column(name="MANAGER") + public IEmployee getManager() { + return _manager; + } + + /** + * Set the employee's manager. + * @param manager The employee's manager. + */ + public void setManager(IEmployee manager) { + this._manager = (PCDSEmployee)manager; + } + + /** + * Get the employee's team. + * + * + * @return The set of PCDSEmployees on this employee's team. + */ + + @Persistent(mappedBy="manager") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + public Set getTeam() { + return _team; + } + + /** + * Add an PCDSEmployee to this employee's team. + * This method sets both sides of the relationship, modifying + * this employees team to include parameter emp and modifying + * emp to set its manager attribute to this object. + * + * + * @param emp The PCDSEmployee to add to the team. + */ + public void addToTeam(PCDSEmployee emp) { + _team.add(emp); + emp._manager = this; + } + + /** + * Remove an PCDSEmployee from this employee's team. + * This method will also set the emp manager to null. + * + * + * @param emp The PCDSEmployee to remove from the team. + */ + public void removeFromTeam(PCDSEmployee emp) { + _team.remove(emp); + emp._manager = null; + } + + /** + * Set the employee's team. + * + * + * @param team The set of PCDSEmployees. + */ + public void setTeam(Set team) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._team = (team != null) ? new HashSet(team) : null; + } + + /** + * Set the mentor for this employee. + * @param mentor The mentor for this employee. + */ + public void setMentor(IEmployee mentor) { + this._mentor = (PCDSEmployee)mentor; + } + + /** + * Get the mentor for this employee. + * @return The mentor. + */ + + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + @Column(name="MENTOR") + public IEmployee getMentor() { + return _mentor; + } + + /** + * Set the protege for this employee. + * @param protege The protege for this employee. + */ + public void setProtege(IEmployee protege) { + this._protege = (PCDSEmployee)protege; + } + + /** + * Get the protege of this employee. + * @return The protege of this employee. + */ + + @Persistent(mappedBy="mentor", + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + public IEmployee getProtege() { + return _protege; + } + + /** + * Set the HR advisor for this employee. + * @param hradvisor The hradvisor for this employee. + */ + public void setHradvisor(IEmployee hradvisor) { + this._hradvisor = (PCDSEmployee)hradvisor; + } + + /** + * Get the HR advisor for the employee. + * @return The HR advisor. + */ + + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + @Column(name="HRADVISOR") + public IEmployee getHradvisor() { + return _hradvisor; + } + + /** + * Get the HR advisees of this HR advisor. + * + * + * @return The PCDSEmployees that are HR advisees of this employee. + */ + + @Persistent(mappedBy="hradvisor") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + public Set getHradvisees() { + return _hradvisees; + } + + /** + * Add an PCDSEmployee as an advisee of this HR advisor. + * This method also sets the emp hradvisor to reference + * this object. In other words, both sides of the relationship are + * set. + * + * + * @param emp The employee to add as an advisee. + */ + public void addAdvisee(PCDSEmployee emp) { + _hradvisees.add(emp); + emp._hradvisor = this; + } + + /** + * Remove an PCDSEmployee as an advisee of this HR advisor. + * This method also sets the emp hradvisor to null. + * In other words, both sides of the relationship are set. + * + * + * @param emp The employee to add as an HR advisee. + */ + public void removeAdvisee(PCDSEmployee emp) { + _hradvisees.remove(emp); + emp._hradvisor = null; + } + + /** + * Set the HR advisees of this HR advisor. + * + * + * @param hradvisees The PCDSEmployees that are HR advisees of + * this employee. + */ + public void setHradvisees(Set hradvisees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._hradvisees = (hradvisees != null) ? new HashSet(hradvisees) : null; + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + _reviewedProjects = new HashSet(); + _projects = new HashSet(); + _team = new HashSet(); + _hradvisees = new HashSet(); + } + + /** + * Return a String representation of a PCDSEmployee object. + * + * + * @return a String representation of a PCDSEmployee object. + */ + public String toString() { + return "FCEmployee(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", hired ").append( + _hiredate==null ? "null" : formatter.format(_hiredate)); + rc.append(", weeklyhours ").append(_weeklyhours); + return rc.toString(); + } + + /** + * + * Returns true if all the fields of this instance are + * deep equal to the corresponding fields of the specified PCDSEmployee. + * + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCDSEmployee otherEmp = (PCDSEmployee)other; + String where = "Employee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.equals(_hiredate, otherEmp.getHiredate(), where + ".hiredate") & + helper.closeEnough(_weeklyhours, otherEmp.getWeeklyhours(), where + ".weeklyhours") & + helper.deepEquals(_dentalInsurance, otherEmp.getDentalInsurance(), where + ".dentalInsurance") & + helper.deepEquals(_medicalInsurance, otherEmp.getMedicalInsurance(), where + ".medicalInsurance") & + helper.deepEquals(_department, otherEmp.getDepartment(), where + ".department") & + helper.deepEquals(_fundingDept, otherEmp.getFundingDept(), where + ".fundingDept") & + helper.deepEquals(_manager, otherEmp.getManager(), where + ".manager") & + helper.deepEquals(_mentor, otherEmp.getMentor(), where + ".mentor") & + helper.deepEquals(_protege, otherEmp.getProtege(), where + ".protege") & + helper.deepEquals(_hradvisor, otherEmp.getHradvisor(), where + ".hradvisor") & + helper.deepEquals(_reviewedProjects, otherEmp.getReviewedProjects(), where + ".reviewedProjects") & + helper.deepEquals(_projects, otherEmp.getProjects(), where + ".projects") & + helper.deepEquals(_team, otherEmp.getTeam(), where + ".team") & + helper.deepEquals(_hradvisees, otherEmp.getHradvisees(), where + ".hradvisees"); + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSFullTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSFullTimeEmployee.java index 54d5dd0c0..5725b597a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSFullTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSFullTimeEmployee.java @@ -5,140 +5,137 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; +import javax.jdo.annotations.*; + import java.util.Date; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.DatastoreIdentity; -import javax.jdo.annotations.IdGeneratorStrategy; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; import org.apache.jdo.tck.pc.company.IAddress; import org.apache.jdo.tck.pc.company.IFullTimeEmployee; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a full-time employee. */ +/** + * This class represents a full-time employee. + */ @PersistenceCapable -@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE) -@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "DATASTORE_IDENTITY") -public class PCDSFullTimeEmployee extends PCDSEmployee implements IFullTimeEmployee { - - @NotPersistent() private double _salary; +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY") +public class PCDSFullTimeEmployee extends PCDSEmployee + implements IFullTimeEmployee { - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public PCDSFullTimeEmployee() {} + @NotPersistent() + private double _salary; - /** - * Construct a full-time employee. - * - * @param personid The person identifier. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param hired The date that the person was hired. - * @param sal The salary of the full-time employee. - */ - public PCDSFullTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double sal) { - super(personid, first, last, middle, born, hired); - _salary = sal; - } + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCDSFullTimeEmployee() {} - /** - * Construct a full-time employee. - * - * @param personid The person identifier. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param addr The person's address. - * @param hired The date that the person was hired. - * @param sal The salary of the full-time employee. - */ - public PCDSFullTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - IAddress addr, - Date hired, - double sal) { - super(personid, first, last, middle, born, (PCDSAddress) addr, hired); - _salary = sal; - } + /** + * Construct a full-time employee. + * @param personid The person identifier. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param hired The date that the person was hired. + * @param sal The salary of the full-time employee. + */ + public PCDSFullTimeEmployee(long personid, String first, String last, + String middle, Date born, + Date hired, double sal) { + super(personid, first, last, middle, born, hired); + _salary = sal; + } - /** - * Get the salary of the full time employee. - * - * @return The salary of the full time employee. - */ - @Column(name = "SALARY") - public double getSalary() { - return _salary; - } + /** + * Construct a full-time employee. + * @param personid The person identifier. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param addr The person's address. + * @param hired The date that the person was hired. + * @param sal The salary of the full-time employee. + */ + public PCDSFullTimeEmployee(long personid, String first, String last, + String middle, Date born, IAddress addr, + Date hired, double sal) { + super(personid, first, last, middle, born, (PCDSAddress)addr, hired); + _salary = sal; + } - /** - * Set the salary for the full-time employee. - * - * @param salary The salary to set for the full-time employee. - */ - public void setSalary(double salary) { - this._salary = salary; - } + /** + * Get the salary of the full time employee. + * @return The salary of the full time employee. + */ - /** - * Return a String representation of a PCDSFullTimeEmployee object. - * - * @return a String representation of a PCDSFullTimeEmployee object. - */ - public String toString() { - return "FCFullTimeEmployee(" + getFieldRepr() + ")"; - } + @Column(name="SALARY") + public double getSalary() { + return _salary; + } + + /** + * Set the salary for the full-time employee. + * @param salary The salary to set for the full-time employee. + */ + public void setSalary(double salary) { + this._salary = salary; + } + + /** + * Return a String representation of a PCDSFullTimeEmployee object. + * + * + * @return a String representation of a PCDSFullTimeEmployee object. + */ + public String toString() { + return "FCFullTimeEmployee(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - public String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", $").append(_salary); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + public String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", $").append(_salary); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified PCDSFullTimeEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCDSFullTimeEmployee otherEmp = (PCDSFullTimeEmployee) other; - String where = "FCFullTimeEmployee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.closeEnough(_salary, otherEmp.getSalary(), where + ".salary"); - } + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified + * PCDSFullTimeEmployee. + * + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCDSFullTimeEmployee otherEmp = (PCDSFullTimeEmployee)other; + String where = "FCFullTimeEmployee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.closeEnough(_salary, otherEmp.getSalary(), where + ".salary"); + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSInsurance.java index 7922eeff9..5396a8291 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSInsurance.java @@ -5,304 +5,305 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; +import javax.jdo.annotations.*; + import java.io.Serializable; + import java.util.Comparator; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.DatastoreIdentity; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.IdGeneratorStrategy; -import javax.jdo.annotations.Index; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; import org.apache.jdo.tck.pc.company.IEmployee; import org.apache.jdo.tck.pc.company.IInsurance; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; /** - * This class represents an insurance carrier selection for a particular PCDSEmployee. + * This class represents an insurance carrier selection for a particular + * PCDSEmployee. */ -@PersistenceCapable(table = "insuranceplans") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator( - strategy = DiscriminatorStrategy.CLASS_NAME, - column = "DISCRIMINATOR", - indexed = "true") -@Index( - name = "INS_DISCRIMINATOR_INDEX", - unique = "false", - columns = @Column(name = "DISCRIMINATOR")) -@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "DATASTORE_IDENTITY") -public class PCDSInsurance - implements IInsurance, Serializable, Comparable, Comparator, DeepEquality { - - @NotPersistent() private long _insid; - @NotPersistent() private String _carrier; - @NotPersistent() private PCDSEmployee _employee; - - /** This is the JDO-required no-args constructor. */ - protected PCDSInsurance() {} - - /** - * Construct an PCDSInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - */ - protected PCDSInsurance(long insid, String carrier) { - this._insid = insid; - this._carrier = carrier; - } - - /** - * Construct an PCDSInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param employee The employee associated with this insurance. - */ - protected PCDSInsurance(long insid, String carrier, PCDSEmployee employee) { - this._insid = insid; - this._carrier = carrier; - this._employee = employee; - } - - /** - * Get the insurance ID. - * - * @return the insurance ID. - */ - @Column(name = "INSID") - public long getInsid() { - return _insid; - } - - /** - * Set the insurance ID. - * - * @param id The insurance ID value. - */ - public void setInsid(long id) { - this._insid = id; - } - - /** - * Get the insurance carrier. - * - * @return The insurance carrier. - */ - @Column(name = "CARRIER") - public String getCarrier() { - return _carrier; - } - - /** - * Set the insurance carrier. - * - * @param carrier The insurance carrier. - */ - public void setCarrier(String carrier) { - this._carrier = carrier; - } - - /** - * Get the associated employee. - * - * @return The employee for this insurance. - */ - @Column(name = "EMPLOYEE") - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) - public IEmployee getEmployee() { - return _employee; - } - - /** - * Set the associated employee. - * - * @param employee The associated employee. - */ - public void setEmployee(IEmployee employee) { - this._employee = (PCDSEmployee) employee; - } - - /** - * Returns a String representation of a PCDSInsurance object. - * - * @return a String representation of a PCDSInsurance object. - */ - public String toString() { - return "FCInsurance(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(_insid); - rc.append(", carrier ").append(_carrier); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Object. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCDSInsurance otherIns = (PCDSInsurance) other; - String where = "FCInsurance<" + _insid + ">"; - return helper.equals(_insid, otherIns.getInsid(), where + ".insid") - & helper.equals(_carrier, otherIns.getCarrier(), where + ".carrier") - & helper.deepEquals(_employee, otherIns.getEmployee(), where + ".employee"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((PCDSInsurance) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((PCDSInsurance) o1, (PCDSInsurance) o2); - } - - /** - * Compares this object with the specified Insurance object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Insurance object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Insurance object. - */ - public int compareTo(PCDSInsurance other) { - return compare(this, other); - } - - /** - * Compares its two IInsurance arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IInsurance object to be compared. - * @param o2 the second IInsurance object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(PCDSInsurance o1, PCDSInsurance o2) { - return EqualityHelper.compare(o1.getInsid(), o2.getInsid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof PCDSInsurance) { - return compareTo((PCDSInsurance) obj) == 0; +@PersistenceCapable(table="insuranceplans") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR", indexed="true") +@Index(name="INS_DISCRIMINATOR_INDEX", unique="false", + columns=@Column(name="DISCRIMINATOR")) +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, + column="DATASTORE_IDENTITY") +public class PCDSInsurance + implements IInsurance, Serializable, Comparable, Comparator, DeepEquality { + + @NotPersistent() + private long _insid; + @NotPersistent() + private String _carrier; + @NotPersistent() + private PCDSEmployee _employee; + + /** This is the JDO-required no-args constructor. */ + protected PCDSInsurance() {} + + /** + * Construct an PCDSInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + */ + protected PCDSInsurance(long insid, String carrier) { + this._insid = insid; + this._carrier = carrier; + } + + /** + * Construct an PCDSInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + */ + protected PCDSInsurance(long insid, String carrier, PCDSEmployee employee) { + this._insid = insid; + this._carrier = carrier; + this._employee = employee; + } + + /** + * Get the insurance ID. + * @return the insurance ID. + */ + + @Column(name="INSID") + public long getInsid() { + return _insid; + } + + /** + * Set the insurance ID. + * @param id The insurance ID value. + */ + public void setInsid(long id) { + this._insid = id; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) _insid; - } - - /** - * This class is used to represent the application identifier for the Insurance - * class. - */ - public static class Oid implements Serializable, Comparable { + /** - * This field represents the application identifier for the Insurance class. It - * must match the field in the Insurance class in both name and type. + * Get the insurance carrier. + * @return The insurance carrier. */ - public long insid; - /** The required public no-args constructor. */ - public Oid() {} + @Column(name="CARRIER") + public String getCarrier() { + return _carrier; + } /** - * Initialize with an insurance identifier. - * - * @param insid the insurance ID. + * Set the insurance carrier. + * @param carrier The insurance carrier. */ - public Oid(long insid) { - this.insid = insid; + public void setCarrier(String carrier) { + this._carrier = carrier; + } + + /** + * Get the associated employee. + * @return The employee for this insurance. + */ + + @Column(name="EMPLOYEE") + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class) + public IEmployee getEmployee() { + return _employee; } - public Oid(String s) { - insid = Long.parseLong(justTheId(s)); + /** + * Set the associated employee. + * @param employee The associated employee. + */ + public void setEmployee(IEmployee employee) { + this._employee = (PCDSEmployee)employee; } + /** + * Returns a String representation of a PCDSInsurance object. + * + * + * @return a String representation of a PCDSInsurance object. + */ public String toString() { - return this.getClass().getName() + ": " + insid; + return "FCInsurance(" + getFieldRepr() + ")"; } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.insid != o.insid) return (false); - return (true); + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(_insid); + rc.append(", carrier ").append(_carrier); + return rc.toString(); } - /** */ - public int hashCode() { - return ((int) insid); + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCDSInsurance otherIns = (PCDSInsurance)other; + String where = "FCInsurance<" + _insid + ">"; + return + helper.equals(_insid, otherIns.getInsid(), where + ".insid") & + helper.equals(_carrier, otherIns.getCarrier(), where + ".carrier") & + helper.deepEquals(_employee, otherIns.getEmployee(), where + ".employee"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((PCDSInsurance)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCDSInsurance)o1, (PCDSInsurance)o2); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compares this object with the specified Insurance object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Insurance object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified + * Insurance object. + */ + public int compareTo(PCDSInsurance other) { + return compare(this, other); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (insid < other.insid) return -1; - if (insid > other.insid) return 1; - return 0; + /** + * Compares its two IInsurance arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IInsurance object to be compared. + * @param o2 the second IInsurance object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(PCDSInsurance o1, PCDSInsurance o2) { + return EqualityHelper.compare(o1.getInsid(), o2.getInsid()); } - } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof PCDSInsurance) { + return compareTo((PCDSInsurance)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)_insid; + } + + /** + * This class is used to represent the application + * identifier for the Insurance class. + */ + public static class Oid implements Serializable, Comparable + { + /** + * This field represents the application identifier for the + * Insurance class. It must match the field in the + * Insurance class in both name and type. + */ + public long insid; + + /** + * The required public no-args constructor. + */ + public Oid() { } + + /** + * Initialize with an insurance identifier. + * @param insid the insurance ID. + */ + public Oid(long insid) { + this.insid = insid; + } + + public Oid(String s) { insid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + insid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o=(Oid) obj; + if( this.insid!=o.insid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) insid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( insid < other.insid ) return -1; + if( insid > other.insid ) return 1; + return 0; + } + + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSMedicalInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSMedicalInsurance.java index 8ff577ba3..ea4b6579e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSMedicalInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSMedicalInsurance.java @@ -5,121 +5,128 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.DatastoreIdentity; -import javax.jdo.annotations.IdGeneratorStrategy; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; +import javax.jdo.annotations.*; import org.apache.jdo.tck.pc.company.IMedicalInsurance; import org.apache.jdo.tck.util.EqualityHelper; /** - * This class represents a dental insurance carrier selection for a particular Employee - * . + * This class represents a dental insurance carrier selection for a + * particular Employee. */ @PersistenceCapable -@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "DATASTORE_IDENTITY") -public class PCDSMedicalInsurance extends PCDSInsurance implements IMedicalInsurance { +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY") +public class PCDSMedicalInsurance extends PCDSInsurance + implements IMedicalInsurance { + + @NotPersistent() + private String _planType; // possible values: "PPO", "EPO", "NPO" - @NotPersistent() private String _planType; // possible values: "PPO", "EPO", "NPO" + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCDSMedicalInsurance() {} - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public PCDSMedicalInsurance() {} + /** + * Construct a PCDSMedicalInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param planType The planType. + */ + public PCDSMedicalInsurance(long insid, String carrier, + String planType) + { + super(insid, carrier); + this._planType = planType; + } - /** - * Construct a PCDSMedicalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param planType The planType. - */ - public PCDSMedicalInsurance(long insid, String carrier, String planType) { - super(insid, carrier); - this._planType = planType; - } + /** + * Construct a PCDSMedicalInsurance instance. + * + * + * @param insid The insurance instance identifier. + * @param carrier The insurance carrier. + * @param employee The employee associated with this insurance. + * @param planType The planType. + */ + public PCDSMedicalInsurance(long insid, String carrier, + PCDSEmployee employee, String planType) + { + super(insid, carrier, employee); + this._planType = planType; + } - /** - * Construct a PCDSMedicalInsurance instance. - * - * @param insid The insurance instance identifier. - * @param carrier The insurance carrier. - * @param employee The employee associated with this insurance. - * @param planType The planType. - */ - public PCDSMedicalInsurance(long insid, String carrier, PCDSEmployee employee, String planType) { - super(insid, carrier, employee); - this._planType = planType; - } + /** + * Get the insurance planType. + * @return The insurance planType. + */ - /** - * Get the insurance planType. - * - * @return The insurance planType. - */ - @Column(name = "PLANTYPE") - public String getPlanType() { - return _planType; - } + @Column(name="PLANTYPE") + public String getPlanType() { + return _planType; + } - /** - * Set the insurance planType. - * - * @param planType The insurance planType. - */ - public void setPlanType(String planType) { - this._planType = planType; - } + /** + * Set the insurance planType. + * @param planType The insurance planType. + */ + public void setPlanType(String planType) { + this._planType = planType; + } - /** - * Returns a String representation of a PCDSMedicalInsurance object. - * - * @return a String representation of a PCDSMedicalInsurance object. - */ - public String toString() { - return "FCMedicalInsurance(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of a PCDSMedicalInsurance + * object. + * + * + * @return a String representation of a PCDSMedicalInsurance + * object. + */ + public String toString() { + return "FCMedicalInsurance(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", planType ").append(_planType); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", planType ").append(_planType); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Object. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCDSMedicalInsurance otherIns = (PCDSMedicalInsurance) other; - String where = "FCMedicalInsurance<" + getInsid() + ">"; - return super.deepCompareFields(otherIns, helper) - & helper.equals(_planType, otherIns.getPlanType(), where + ".planType"); - } + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Object. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCDSMedicalInsurance otherIns = (PCDSMedicalInsurance)other; + String where = "FCMedicalInsurance<" + getInsid() + ">"; + return super.deepCompareFields(otherIns, helper) & + helper.equals(_planType, otherIns.getPlanType(), where + ".planType"); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPartTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPartTimeEmployee.java index 74a0ebbd5..d91b6173f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPartTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPartTimeEmployee.java @@ -5,140 +5,135 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; +import javax.jdo.annotations.*; + import java.util.Date; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.DatastoreIdentity; -import javax.jdo.annotations.IdGeneratorStrategy; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; import org.apache.jdo.tck.pc.company.IAddress; import org.apache.jdo.tck.pc.company.IPartTimeEmployee; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a part-time employee. */ +/** + * This class represents a part-time employee. + */ @PersistenceCapable -@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE) -@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "DATASTORE_IDENTITY") +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY") public class PCDSPartTimeEmployee extends PCDSEmployee implements IPartTimeEmployee { - @NotPersistent() private double _wage; + @NotPersistent() + private double _wage; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCDSPartTimeEmployee() {} - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public PCDSPartTimeEmployee() {} + /** + * Construct a part-time employee. + * @param personid The identifier for the person. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param hired The date the person was hired. + * @param wage The person's wage. + */ + public PCDSPartTimeEmployee(long personid, String first, String last, + String middle, Date born, + Date hired, double wage ) { + super(personid, first, last, middle, born, hired); + this._wage = wage; + } - /** - * Construct a part-time employee. - * - * @param personid The identifier for the person. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param hired The date the person was hired. - * @param wage The person's wage. - */ - public PCDSPartTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double wage) { - super(personid, first, last, middle, born, hired); - this._wage = wage; - } + /** + * Construct a part-time employee. + * @param personid The identifier for the person. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param addr The person's address. + * @param hired The date the person was hired. + * @param wage The person's wage. + */ + public PCDSPartTimeEmployee(long personid, String first, String last, + String middle, Date born, IAddress addr, + Date hired, double wage ) { + super(personid, first, last, middle, born, (PCDSAddress)addr, hired); + this._wage = wage; + } - /** - * Construct a part-time employee. - * - * @param personid The identifier for the person. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param addr The person's address. - * @param hired The date the person was hired. - * @param wage The person's wage. - */ - public PCDSPartTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - IAddress addr, - Date hired, - double wage) { - super(personid, first, last, middle, born, (PCDSAddress) addr, hired); - this._wage = wage; - } + /** + * Get the wage of the part-time employee. + * @return The wage of the part-time employee. + */ - /** - * Get the wage of the part-time employee. - * - * @return The wage of the part-time employee. - */ - @Column(name = "WAGE") - public double getWage() { - return _wage; - } + @Column(name="WAGE") + public double getWage() { + return _wage; + } - /** - * Set the wage of the part-time employee. - * - * @param wage The wage of the part-time employee. - */ - public void setWage(double wage) { - this._wage = wage; - } + /** + * Set the wage of the part-time employee. + * @param wage The wage of the part-time employee. + */ + public void setWage(double wage) { + this._wage = wage; + } - /** - * Returns a String representation of a PCDSPartTimeEmployee object. - * - * @return a String representation of a PCDSPartTimeEmployee object. - */ - public String toString() { - return "FCPartTimeEmployee(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of a PCDSPartTimeEmployee object. + * + * + * @return a String representation of a PCDSPartTimeEmployee object. + */ + public String toString() { + return "FCPartTimeEmployee(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - public String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", $" + _wage); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + public String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", $" + _wage); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified PCDSPartTimeEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCDSPartTimeEmployee otherEmp = (PCDSPartTimeEmployee) other; - String where = "FCPartTimeEmployee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.closeEnough(_wage, otherEmp.getWage(), where + ".wage"); - } + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified + * PCDSPartTimeEmployee. + * + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCDSPartTimeEmployee otherEmp = (PCDSPartTimeEmployee)other; + String where = "FCPartTimeEmployee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.closeEnough(_wage, otherEmp.getWage(), where + ".wage"); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPerson.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPerson.java index a1dd30274..9ce2fce9b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPerson.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPerson.java @@ -5,462 +5,460 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; +import javax.jdo.annotations.*; + import java.io.Serializable; + import java.text.SimpleDateFormat; + +import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.Map; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.DatastoreIdentity; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.Embedded; -import javax.jdo.annotations.IdGeneratorStrategy; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.Join; -import javax.jdo.annotations.Key; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.PersistenceModifier; -import javax.jdo.annotations.Persistent; -import javax.jdo.annotations.Value; import org.apache.jdo.tck.pc.company.IAddress; import org.apache.jdo.tck.pc.company.IPerson; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a person. */ -@PersistenceCapable(table = "persons") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator( - strategy = DiscriminatorStrategy.CLASS_NAME, - column = "DISCRIMINATOR", - indexed = "true") -@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "DATASTORE_IDENTITY") -public class PCDSPerson implements IPerson, Serializable, Comparable, Comparator, DeepEquality { - - @NotPersistent() private long _personid; - @NotPersistent() private String _firstname; - @NotPersistent() private String _lastname; - @NotPersistent() private String _middlename; - @NotPersistent() private Date _birthdate; - @NotPersistent() private PCDSAddress _address; - @NotPersistent() private Map _phoneNumbers = new HashMap(); - - protected static SimpleDateFormat formatter = new SimpleDateFormat("d/MMM/yyyy"); - - /** This is the JDO-required no-args constructor. */ - protected PCDSPerson() {} - - /** - * Construct a PCDSPerson instance. - * - * @param personid The person identifier. - * @param firstname The person's first name. - * @param lastname The person's last name. - * @param middlename The person's middle name. - * @param birthdate The person's birthdate. - */ - public PCDSPerson( - long personid, String firstname, String lastname, String middlename, Date birthdate) { - this._personid = personid; - this._firstname = firstname; - this._lastname = lastname; - this._middlename = middlename; - this._birthdate = birthdate; - } - - /** - * Construct a PCDSPerson instance. - * - * @param personid The person identifier. - * @param firstname The person's first name. - * @param lastname The person's last name. - * @param middlename The person's middle name. - * @param birthdate The person's birthdate. - * @param address The person's address. - */ - public PCDSPerson( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - IAddress address) { - this(personid, firstname, lastname, middlename, birthdate); - this._address = (PCDSAddress) address; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setPersonid(long id) { - this._personid = id; - } - - /** - * Get the person's id. - * - * @return The personid. - */ - @Column(name = "PERSONID") - public long getPersonid() { - return _personid; - } - - /** - * Get the person's last name. - * - * @return The last name. - */ - @Column(name = "LASTNAME") - public String getLastname() { - return _lastname; - } - - /** - * Set the person's last name. - * - * @param lastname The last name. - */ - public void setLastname(String lastname) { - this._lastname = lastname; - } - - /** - * Get the person's first name. - * - * @return The first name. - */ - @Column(name = "FIRSTNAME") - public String getFirstname() { - return _firstname; - } - - /** - * Set the person's first name. - * - * @param firstname The first name. - */ - public void setFirstname(String firstname) { - this._firstname = firstname; - } - - /** - * Get the person's middle name. - * - * @return The middle name. - */ - @Persistent(defaultFetchGroup = "false") - @Column(name = "MIDDLENAME", allowsNull = "true") - public String getMiddlename() { - return _middlename; - } - - /** - * Set the person's middle name. - * - * @param middlename The middle name. - */ - public void setMiddlename(String middlename) { - this._middlename = middlename; - } - - /** - * Get the address. - * - * @return The address. - */ - @Persistent( - persistenceModifier = PersistenceModifier.PERSISTENT, - types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSAddress.class) - @Embedded( - nullIndicatorColumn = "COUNTRY", - members = { - @Persistent(name = "addrid", columns = @Column(name = "ADDRID")), - @Persistent(name = "street", columns = @Column(name = "STREET")), - @Persistent(name = "city", columns = @Column(name = "CITY")), - @Persistent(name = "state", columns = @Column(name = "STATE")), - @Persistent(name = "zipcode", columns = @Column(name = "ZIPCODE")), - @Persistent(name = "country", columns = @Column(name = "COUNTRY")) - }) - public IAddress getAddress() { - return _address; - } - - /** - * Set the address. - * - * @param address The address. - */ - public void setAddress(IAddress address) { - this._address = (PCDSAddress) address; - } - - /** - * Get the person's birthdate. - * - * @return The person's birthdate. - */ - @Column(name = "BIRTHDATE") - public Date getBirthdate() { - return _birthdate; - } - - /** - * Set the person's birthdate. - * - * @param birthdate The person's birthdate. - */ - public void setBirthdate(Date birthdate) { - this._birthdate = birthdate; - } - - /** - * Get the map of phone numbers as an unmodifiable map. - * - * @return The map of phone numbers, as an unmodifiable map. - */ - // maps phone number types ("home", "work", "mobile", etc.) - // to phone numbers specified as String - @Persistent(table = "employee_phoneno_type") - @Join(column = "EMPID") - @Key(types = java.lang.String.class, column = "TYPE") - @Value(types = java.lang.String.class, column = "PHONENO") - public Map getPhoneNumbers() { - return _phoneNumbers; - } - - /** - * Get the phone number for the specified phone number type. - * - * @param type The phone number type ("home", "work", "mobile", etc.). - * @return The phone number associated with specified type, or null if there was no - * phone number for the type. - */ - public String getPhoneNumber(String type) { - return (String) _phoneNumbers.get(type); - } - - /** - * Associates the specified phone number with the specified type in the map of phone numbers of - * this person. - * - * @param type The phone number type ("home", "work", "mobile", etc.). - * @param phoneNumber The phone number - * @return The previous phone number associated with specified type, or null if there - * was no phone number for the type. - */ - public String putPhoneNumber(String type, String phoneNumber) { - return (String) _phoneNumbers.put(type, phoneNumber); - } - - /** - * Remove a phoneNumber from the map of phone numbers. - * - * @param type The phone number type ("home", "work", "mobile", etc.). - * @return The previous phone number associated with specified type, or null if there - * was no phone number for the type. - */ - public String removePhoneNumber(String type) { - return (String) _phoneNumbers.remove(type); - } - - /** - * Set the phoneNumber map to be in this person. - * - * @param phoneNumbers The map of phoneNumbers for this person. - */ - public void setPhoneNumbers(Map phoneNumbers) { - // workaround: create a new HashMap, because fostore does not - // support LinkedHashMap - this._phoneNumbers = (phoneNumbers != null) ? new HashMap(phoneNumbers) : null; - } - - /** - * Returns a String representation of a PCDSPerson object. - * - * @return a string representation of a PCDSPerson object. - */ - public String toString() { - return "FCPerson(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(_personid); - rc.append(", ").append(_lastname); - rc.append(", ").append(_firstname); - rc.append(", born ").append(_birthdate == null ? "null" : formatter.format(_birthdate)); - rc.append(", phone ").append(_phoneNumbers); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified PCDSPerson. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCDSPerson otherPerson = (PCDSPerson) other; - String where = "FCPerson<" + _personid + ">"; - return helper.equals(_personid, otherPerson.getPersonid(), where + ".personid") - & helper.equals(_firstname, otherPerson.getFirstname(), where + ".firstname") - & helper.equals(_lastname, otherPerson.getLastname(), where + ".lastname") - & helper.equals(_middlename, otherPerson.getMiddlename(), where + ".middlename") - & helper.equals(_birthdate, otherPerson.getBirthdate(), where + ".birthdate") - & helper.deepEquals(_address, otherPerson.getAddress(), where + ".address") - & helper.deepEquals(_phoneNumbers, otherPerson.getPhoneNumbers(), where + ".phoneNumbers"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((PCDSPerson) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((PCDSPerson) o1, (PCDSPerson) o2); - } - - /** - * Compares this object with the specified PCDSPerson object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The PCDSPerson object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified PCDSPerson object. - */ - public int compareTo(PCDSPerson other) { - return compare(this, other); - } - - /** - * Compares its two IPerson arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IPerson object to be compared. - * @param o2 the second IPerson object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(PCDSPerson o1, PCDSPerson o2) { - return EqualityHelper.compare(o1.getPersonid(), o2.getPersonid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof PCDSPerson) { - return compareTo((PCDSPerson) obj) == 0; +/** + * This class represents a person. + */ +@PersistenceCapable(table="persons") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR", indexed="true") +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, + column="DATASTORE_IDENTITY") +public class PCDSPerson + implements IPerson, Serializable, Comparable, Comparator, DeepEquality { + + @NotPersistent() + private long _personid; + @NotPersistent() + private String _firstname; + @NotPersistent() + private String _lastname; + @NotPersistent() + private String _middlename; + @NotPersistent() + private Date _birthdate; + @NotPersistent() + private PCDSAddress _address; + @NotPersistent() + private Map _phoneNumbers = new HashMap(); + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. */ + protected PCDSPerson() {} + + /** + * Construct a PCDSPerson instance. + * + * + * @param personid The person identifier. + * @param firstname The person's first name. + * @param lastname The person's last name. + * @param middlename The person's middle name. + * @param birthdate The person's birthdate. + */ + public PCDSPerson(long personid, String firstname, String lastname, + String middlename, Date birthdate) { + this._personid = personid; + this._firstname = firstname; + this._lastname = lastname; + this._middlename = middlename; + this._birthdate = birthdate; + } + + /** + * Construct a PCDSPerson instance. + * + * + * @param personid The person identifier. + * @param firstname The person's first name. + * @param lastname The person's last name. + * @param middlename The person's middle name. + * @param birthdate The person's birthdate. + * @param address The person's address. + */ + public PCDSPerson(long personid, String firstname, String lastname, + String middlename, Date birthdate, IAddress address) { + this(personid, firstname, lastname, middlename, birthdate); + this._address = (PCDSAddress)address; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setPersonid(long id) { + this._personid = id; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) _personid; - } - /** - * This class is used to represent the application identifier for the Person class. - */ - public static class Oid implements Serializable, Comparable { /** - * This field represents the identifier for the Person class. It must match a field - * in the Person class in both name and type. + * Get the person's id. + * @return The personid. */ - public long personid; - /** The required public no-arg constructor. */ - public Oid() {} + @Column(name="PERSONID") + public long getPersonid() { + return _personid; + } /** - * Initialize the identifier. - * - * @param personid The person identifier. + * Get the person's last name. + * @return The last name. + */ + + @Column(name="LASTNAME") + public String getLastname() { + return _lastname; + } + + /** + * Set the person's last name. + * @param lastname The last name. + */ + public void setLastname(String lastname) { + this._lastname = lastname; + } + + /** + * Get the person's first name. + * @return The first name. + */ + + @Column(name="FIRSTNAME") + public String getFirstname() { + return _firstname; + } + + /** + * Set the person's first name. + * @param firstname The first name. + */ + public void setFirstname(String firstname) { + this._firstname = firstname; + } + + /** + * Get the person's middle name. + * @return The middle name. + */ + + @Persistent(defaultFetchGroup="false") + @Column(name="MIDDLENAME", allowsNull="true") + public String getMiddlename() { + return _middlename; + } + + /** + * Set the person's middle name. + * @param middlename The middle name. */ - public Oid(long personid) { - this.personid = personid; + public void setMiddlename(String middlename) { + this._middlename = middlename; } - public Oid(String s) { - personid = Long.parseLong(justTheId(s)); + /** + * Get the address. + * @return The address. + */ + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT, + types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSAddress.class) + @Embedded(nullIndicatorColumn="COUNTRY", + members={ + @Persistent(name="addrid", columns=@Column(name="ADDRID")), + @Persistent(name="street", columns=@Column(name="STREET")), + @Persistent(name="city", columns=@Column(name="CITY")), + @Persistent(name="state", columns=@Column(name="STATE")), + @Persistent(name="zipcode", columns=@Column(name="ZIPCODE")), + @Persistent(name="country", columns=@Column(name="COUNTRY")) + }) + public IAddress getAddress() { + return _address; } + /** + * Set the address. + * @param address The address. + */ + public void setAddress(IAddress address) { + this._address = (PCDSAddress)address; + } + + /** + * Get the person's birthdate. + * @return The person's birthdate. + */ + @Column(name="BIRTHDATE") + public Date getBirthdate() { + return _birthdate; + } + + /** + * Set the person's birthdate. + * @param birthdate The person's birthdate. + */ + public void setBirthdate(Date birthdate) { + this._birthdate = birthdate; + } + + /** + * Get the map of phone numbers as an unmodifiable map. + * @return The map of phone numbers, as an unmodifiable map. + */ + // maps phone number types ("home", "work", "mobile", etc.) + // to phone numbers specified as String + @Persistent(table="employee_phoneno_type") + @Join(column="EMPID") + @Key(types=java.lang.String.class, column="TYPE") + @Value(types=java.lang.String.class, column="PHONENO") + public Map getPhoneNumbers() { + return _phoneNumbers; + } + + /** + * Get the phone number for the specified phone number type. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String getPhoneNumber(String type) { + return (String)_phoneNumbers.get(type); + } + + /** + * Associates the specified phone number with the specified type in the + * map of phone numbers of this person. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @param phoneNumber The phone number + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String putPhoneNumber(String type, String phoneNumber) { + return (String)_phoneNumbers.put(type, phoneNumber); + } + + /** + * Remove a phoneNumber from the map of phone numbers. + * @param type The phone number type ("home", "work", "mobile", etc.). + * @return The previous phone number associated with specified type, or + * null if there was no phone number for the type. + */ + public String removePhoneNumber(String type) { + return (String)_phoneNumbers.remove(type); + } + + /** + * Set the phoneNumber map to be in this person. + * @param phoneNumbers The map of phoneNumbers for this person. + */ + public void setPhoneNumbers(Map phoneNumbers) { + // workaround: create a new HashMap, because fostore does not + // support LinkedHashMap + this._phoneNumbers = + (phoneNumbers != null) ? new HashMap(phoneNumbers) : null; + } + + /** + * Returns a String representation of a PCDSPerson object. + * + * + * @return a string representation of a PCDSPerson object. + */ public String toString() { - return this.getClass().getName() + ": " + personid; + return "FCPerson(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(_personid); + rc.append(", ").append(_lastname); + rc.append(", ").append(_firstname); + rc.append(", born ").append( + _birthdate==null ? "null" : formatter.format(_birthdate)); + rc.append(", phone ").append(_phoneNumbers); + return rc.toString(); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.personid != o.personid) return (false); - return (true); + /** + * + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified PCDSPerson. + * + * + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCDSPerson otherPerson = (PCDSPerson)other; + String where = "FCPerson<" + _personid + ">"; + return + helper.equals(_personid, otherPerson.getPersonid(), where + ".personid") & + helper.equals(_firstname, otherPerson.getFirstname(), where + ".firstname") & + helper.equals(_lastname, otherPerson.getLastname(), where + ".lastname") & + helper.equals(_middlename, otherPerson.getMiddlename(), where + ".middlename") & + helper.equals(_birthdate, otherPerson.getBirthdate(), where + ".birthdate") & + helper.deepEquals(_address, otherPerson.getAddress(), where + ".address") & + helper.deepEquals(_phoneNumbers, otherPerson.getPhoneNumbers(), where + ".phoneNumbers"); } - /** */ - public int hashCode() { - return ((int) personid); + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((PCDSPerson)o); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCDSPerson)o1, (PCDSPerson)o2); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (personid < other.personid) return -1; - if (personid > other.personid) return 1; - return 0; + /** + * + * Compares this object with the specified PCDSPerson object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * + * + * @param other The PCDSPerson object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified PCDSPerson + * object. + */ + public int compareTo(PCDSPerson other) { + return compare(this, other); } - } + + /** + * Compares its two IPerson arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IPerson object to be compared. + * @param o2 the second IPerson object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(PCDSPerson o1, PCDSPerson o2) { + return EqualityHelper.compare(o1.getPersonid(), o2.getPersonid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof PCDSPerson) { + return compareTo((PCDSPerson)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)_personid; + } + /** + * This class is used to represent the application identifier + * for the Person class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the identifier for the Person + * class. It must match a field in the Person class in + * both name and type. + */ + public long personid; + + /** + * The required public no-arg constructor. + */ + public Oid() { } + + /** + * Initialize the identifier. + * @param personid The person identifier. + */ + public Oid(long personid) { + this.personid = personid; + } + + public Oid(String s) { personid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + personid;} + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || + !this.getClass().equals(obj.getClass()) ) return( false ); + Oid o = (Oid) obj; + if( this.personid != o.personid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) personid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( personid < other.personid ) return -1; + if( personid > other.personid ) return 1; + return 0; + } + + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSProject.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSProject.java index b3cd11e1e..02297ac90 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSProject.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSProject.java @@ -5,393 +5,396 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPC; -import java.io.IOException; -import java.io.ObjectInputStream; +import javax.jdo.annotations.*; + import java.io.Serializable; -import java.math.BigDecimal; +import java.io.ObjectInputStream; +import java.io.IOException; + +import java.util.Collections; import java.util.Comparator; -import java.util.HashSet; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.DatastoreIdentity; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.IdGeneratorStrategy; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.Join; -import javax.jdo.annotations.NotPersistent; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; +import java.util.HashSet; +import java.math.BigDecimal; import org.apache.jdo.tck.pc.company.IProject; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a project, a budgeted task with one or more employees working on it. */ -@PersistenceCapable(table = "projects") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator(strategy = DiscriminatorStrategy.CLASS_NAME, column = "DISCRIMINATOR") -@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "DATASTORE_IDENTITY") -public class PCDSProject implements IProject, Serializable, Comparable, Comparator, DeepEquality { - - @NotPersistent() private long _projid; - @NotPersistent() private String _name; - @NotPersistent() private BigDecimal _budget; - @NotPersistent() private transient Set _reviewers = new HashSet(); - @NotPersistent() private transient Set _members = new HashSet(); - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public PCDSProject() {} - - /** - * Initialize a project. - * - * @param projid The project identifier. - * @param name The name of the project. - * @param budget The budget for the project. - */ - public PCDSProject(long projid, String name, BigDecimal budget) { - this._projid = projid; - this._name = name; - this._budget = budget; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setProjid(long id) { - this._projid = id; - } - - /** - * Get the project ID. - * - * @return The project ID. - */ - @Column(name = "PROJID") - public long getProjid() { - return _projid; - } - - /** - * Get the name of the project. - * - * @return The name of the project. - */ - @Column(name = "NAME") - public String getName() { - return _name; - } - - /** - * Set the name of the project. - * - * @param name The name of the project. - */ - public void setName(String name) { - this._name = name; - } - - /** - * Get the project's budget. - * - * @return The project's budget. - */ - @Column(name = "BUDGET", jdbcType = "DECIMAL", length = 11, scale = 2) - public BigDecimal getBudget() { - return _budget; - } - - /** - * Set the project's budget. - * - * @param budget The project's budget. - */ - public void setBudget(BigDecimal budget) { - this._budget = budget; - } - - /** Get the reviewers associated with this project. */ - @Persistent(table = "project_reviewer") - @Element( - types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class, - column = "REVIEWER", - foreignKey = "PR_REV_FK") - @Join(column = "PROJID", foreignKey = "PR_PROJ_FK") - public Set getReviewers() { - return _reviewers; - } - - /** - * Add a reviewer to the project. - * - * @param emp The employee to add as a reviewer. - */ - public void addReviewer(PCDSEmployee emp) { - _reviewers.add(emp); - } - - /** - * Remove a reviewer from the project. - * - * @param emp The employee to remove as a reviewer of this project. - */ - public void removeReviewer(PCDSEmployee emp) { - _reviewers.remove(emp); - } - - /** - * Set the reviewers associated with this project. - * - * @param reviewers The set of reviewers to associate with this project. - */ - public void setReviewers(Set reviewers) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this._reviewers = (reviewers != null) ? new HashSet(reviewers) : null; - } - - /** - * Get the project members. - * - * @return The members of the project is returned as a set of PCDSEmployees. - */ - @Persistent(table = "project_member") - @Element( - types = org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class, - column = "MEMBER", - foreignKey = "PR_MEMB_FK") - @Join(column = "PROJID", foreignKey = "PR_PROJ_FK") - public Set getMembers() { - return _members; - } - - /** - * Add a new member to the project. - * - * @param emp The employee to add to the project. - */ - public void addMember(PCDSEmployee emp) { - _members.add(emp); - } - - /** - * Remove a member from the project. - * - * @param emp The employee to remove from the project. - */ - public void removeMember(PCDSEmployee emp) { - _members.remove(emp); - } - - /** - * Set the members of the project. - * - * @param employees The set of employees to be the members of this project. - */ - public void setMembers(Set employees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this._members = (employees != null) ? new HashSet(employees) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - _reviewers = new HashSet(); - _members = new HashSet(); - } - - /** - * Returns a String representation of a PCDSProject object. - * - * @return a String representation of a PCDSProject object. - */ - public String toString() { - return "FCProject(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(_projid); - rc.append(", name ").append(_name); - rc.append(", budget ").append(_budget); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - PCDSProject otherProject = (PCDSProject) other; - String where = "FCProject<" + _projid + ">"; - return helper.equals(_projid, otherProject.getProjid(), where + ".projid") - & helper.equals(_name, otherProject.getName(), where + ".name") - & helper.equals(_budget, otherProject.getBudget(), where + ".budget") - & helper.deepEquals(_reviewers, otherProject.getReviewers(), where + ".reviewers") - & helper.deepEquals(_members, otherProject.getMembers(), where + ".members"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((PCDSProject) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((PCDSProject) o1, (PCDSProject) o2); - } - - /** - * Compares this object with the specified PCDSProject object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The PCDSProject object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified PCDSProject object. - */ - public int compareTo(PCDSProject other) { - return compare(this, other); - } - - /** - * Compares its two IProject arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IProject object to be compared. - * @param o2 the second IProject object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(PCDSProject o1, PCDSProject o2) { - return EqualityHelper.compare(o1.getProjid(), o2.getProjid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof PCDSProject) { - return compareTo((PCDSProject) obj) == 0; +/** + * This class represents a project, a budgeted task with one or more + * employees working on it. + */ +@PersistenceCapable(table="projects") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY") +public class PCDSProject + implements IProject, Serializable, Comparable, Comparator, DeepEquality { + + @NotPersistent() + private long _projid; + @NotPersistent() + private String _name; + @NotPersistent() + private BigDecimal _budget; + @NotPersistent() + private transient Set _reviewers = new HashSet(); + @NotPersistent() + private transient Set _members = new HashSet(); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PCDSProject() {} + + /** + * Initialize a project. + * @param projid The project identifier. + * @param name The name of the project. + * @param budget The budget for the project. + */ + public PCDSProject(long projid, String name, BigDecimal budget) { + this._projid = projid; + this._name = name; + this._budget = budget; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setProjid(long id) { + this._projid = id; + } + + /** + * Get the project ID. + * @return The project ID. + */ + + @Column(name="PROJID") + public long getProjid() { + return _projid; + } + + /** + * Get the name of the project. + * @return The name of the project. + */ + + @Column(name="NAME") + public String getName() { + return _name; + } + + /** + * Set the name of the project. + * @param name The name of the project. + */ + public void setName(String name) { + this._name = name; + } + + /** + * Get the project's budget. + * @return The project's budget. + */ + + @Column(name="BUDGET", jdbcType="DECIMAL", length=11, scale=2) + public BigDecimal getBudget() { + return _budget; + } + + /** + * Set the project's budget. + * @param budget The project's budget. + */ + public void setBudget(BigDecimal budget) { + this._budget = budget; + } + + /** + * Get the reviewers associated with this project. + */ + + @Persistent(table="project_reviewer") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class, + column="REVIEWER", foreignKey="PR_REV_FK") + @Join(column="PROJID", foreignKey="PR_PROJ_FK") + public Set getReviewers() { + return _reviewers; + } + + /** + * Add a reviewer to the project. + * @param emp The employee to add as a reviewer. + */ + public void addReviewer(PCDSEmployee emp) { + _reviewers.add(emp); } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) _projid; - } - - /** - * This class is used to represent the application identity for the PCDSProject - * class. - */ - public static class Oid implements Serializable, Comparable { /** - * This field represents the identifier for the PCDSProject class. It must match a - * field in the PCDSProject class in both name and type. + * Remove a reviewer from the project. + * @param emp The employee to remove as a reviewer of this project. */ - public long projid; + public void removeReviewer(PCDSEmployee emp) { + _reviewers.remove(emp); + } - /** The required public no-arg constructor. */ - public Oid() {} + /** + * Set the reviewers associated with this project. + * @param reviewers The set of reviewers to associate with this project. + */ + public void setReviewers(Set reviewers) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._reviewers = (reviewers != null) ? new HashSet(reviewers) : null; + } /** - * Initialize the application identifier with a project ID. - * - * @param projid The id of the project. + * Get the project members. + * + * + * @return The members of the project is returned as a + * set of PCDSEmployees. */ - public Oid(long projid) { - this.projid = projid; + + @Persistent(table="project_member") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPC.PCDSEmployee.class, + column="MEMBER", foreignKey="PR_MEMB_FK") + @Join(column="PROJID", foreignKey="PR_PROJ_FK") + public Set getMembers() { + return _members; } - public Oid(String s) { - projid = Long.parseLong(justTheId(s)); + /** + * Add a new member to the project. + * @param emp The employee to add to the project. + */ + public void addMember(PCDSEmployee emp) { + _members.add(emp); } + /** + * Remove a member from the project. + * @param emp The employee to remove from the project. + */ + public void removeMember(PCDSEmployee emp) { + _members.remove(emp); + } + + /** + * Set the members of the project. + * @param employees The set of employees to be the members of this + * project. + */ + public void setMembers(Set employees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this._members = (employees != null) ? new HashSet(employees) : null; + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + _reviewers = new HashSet(); + _members = new HashSet(); + } + + /** + * Returns a String representation of a PCDSProject object. + * + * + * @return a String representation of a PCDSProject object. + */ public String toString() { - return this.getClass().getName() + ": " + projid; + return "FCProject(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(_projid); + rc.append(", name ").append(_name); + rc.append(", budget ").append(_budget); + return rc.toString(); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.projid != o.projid) return (false); - return (true); + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + PCDSProject otherProject = (PCDSProject)other; + String where = "FCProject<" + _projid + ">"; + return + helper.equals(_projid, otherProject.getProjid(), where + ".projid") & + helper.equals(_name, otherProject.getName(), where + ".name") & + helper.equals(_budget, otherProject.getBudget(), where + ".budget") & + helper.deepEquals(_reviewers, otherProject.getReviewers(), where + ".reviewers") & + helper.deepEquals(_members, otherProject.getMembers(), where + ".members"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((PCDSProject)o); } - /** */ - public int hashCode() { - return ((int) projid); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((PCDSProject)o1, (PCDSProject)o2); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * + * Compares this object with the specified PCDSProject object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * + * + * @param other The PCDSProject object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified PCDSProject object. + */ + public int compareTo(PCDSProject other) { + return compare(this, other); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (projid < other.projid) return -1; - if (projid > other.projid) return 1; - return 0; + /** + * Compares its two IProject arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IProject object to be compared. + * @param o2 the second IProject object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(PCDSProject o1, PCDSProject o2) { + return EqualityHelper.compare(o1.getProjid(), o2.getProjid()); } - } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof PCDSProject) { + return compareTo((PCDSProject)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)_projid; + } + + /** + * This class is used to represent the application identity + * for the PCDSProject class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the identifier for the + * PCDSProject class. It must match a field in the + * PCDSProject class in both name and type. + */ + public long projid; + + /** + * The required public no-arg constructor. + */ + public Oid() { } + + /** + * Initialize the application identifier with a project ID. + * @param projid The id of the project. + */ + public Oid(long projid) { + this.projid = projid; + } + + public Oid(String s) { projid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + projid;} + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.projid != o.projid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) projid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( projid < other.projid ) return -1; + if( projid > other.projid ) return 1; + return 0; + } + + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/CompanyFactoryAnnotatedPIAppPM.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/CompanyFactoryAnnotatedPIAppPM.java index 7c432c74c..e85befdcc 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/CompanyFactoryAnnotatedPIAppPM.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/CompanyFactoryAnnotatedPIAppPM.java @@ -18,16 +18,7 @@ package org.apache.jdo.tck.pc.companyAnnotatedPI; import javax.jdo.PersistenceManager; -import org.apache.jdo.tck.pc.company.CompanyFactoryNewInstance; -import org.apache.jdo.tck.pc.company.IAddress; -import org.apache.jdo.tck.pc.company.ICompany; -import org.apache.jdo.tck.pc.company.IDentalInsurance; -import org.apache.jdo.tck.pc.company.IDepartment; -import org.apache.jdo.tck.pc.company.IFullTimeEmployee; -import org.apache.jdo.tck.pc.company.IMedicalInsurance; -import org.apache.jdo.tck.pc.company.IMeetingRoom; -import org.apache.jdo.tck.pc.company.IPartTimeEmployee; -import org.apache.jdo.tck.pc.company.IProject; +import org.apache.jdo.tck.pc.company.*; /* * CompanyFactoryAnnotatedPMFieldClass.java @@ -35,65 +26,65 @@ * This class uses the PersistenceManager.newInstance method with the concrete * class as a parameter. */ -public class CompanyFactoryAnnotatedPIAppPM implements CompanyFactoryNewInstance { +public class CompanyFactoryAnnotatedPIAppPM + implements CompanyFactoryNewInstance { + + PersistenceManager pm = null; - PersistenceManager pm = null; + /** + * Creates a new instance of CompanyFactoryAnnotatedPMFieldClass + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedPIAppPM(PersistenceManager pm) { + this.pm = pm; + } + + public Class[] getTearDownClasses() { + return new Class[] { + PIAppDentalInsurance.class, + PIAppMedicalInsurance.class, + PIAppPartTimeEmployee.class, + PIAppFullTimeEmployee.class, + PIAppProject.class, + PIAppDepartment.class, + PIAppCompany.class, + PIAppAddress.class + }; + } + + public IAddress newAddress() { + return (IAddress)pm.newInstance(PIAppAddress.class); + } - /** - * Creates a new instance of CompanyFactoryAnnotatedPMFieldClass - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedPIAppPM(PersistenceManager pm) { - this.pm = pm; - } - - public Class[] getTearDownClasses() { - return new Class[] { - PIAppDentalInsurance.class, - PIAppMedicalInsurance.class, - PIAppPartTimeEmployee.class, - PIAppFullTimeEmployee.class, - PIAppProject.class, - PIAppDepartment.class, - PIAppCompany.class, - PIAppAddress.class - }; - } - - public IAddress newAddress() { - return (IAddress) pm.newInstance(PIAppAddress.class); - } - - public IMeetingRoom newMeetingRoom() { - return (IMeetingRoom) null; - } - - public ICompany newCompany() { - return (ICompany) pm.newInstance(PIAppCompany.class); - } - - public IDentalInsurance newDentalInsurance() { - return (IDentalInsurance) pm.newInstance(PIAppDentalInsurance.class); - } - - public IDepartment newDepartment() { - return (IDepartment) pm.newInstance(PIAppDepartment.class); - } - - public IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) pm.newInstance(PIAppFullTimeEmployee.class); - } - - public IMedicalInsurance newMedicalInsurance() { - return (IMedicalInsurance) pm.newInstance(PIAppMedicalInsurance.class); - } - - public IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) pm.newInstance(PIAppPartTimeEmployee.class); - } - - public IProject newProject() { - return (IProject) pm.newInstance(PIAppProject.class); - } + public IMeetingRoom newMeetingRoom() { + return (IMeetingRoom)null; + } + + public ICompany newCompany() { + return (ICompany)pm.newInstance(PIAppCompany.class); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance)pm.newInstance(PIAppDentalInsurance.class); + } + + public IDepartment newDepartment() { + return (IDepartment)pm.newInstance(PIAppDepartment.class); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee)pm.newInstance(PIAppFullTimeEmployee.class); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance)pm.newInstance(PIAppMedicalInsurance.class); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee)pm.newInstance(PIAppPartTimeEmployee.class); + } + + public IProject newProject() { + return (IProject)pm.newInstance(PIAppProject.class); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/CompanyFactoryAnnotatedPIDSPM.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/CompanyFactoryAnnotatedPIDSPM.java index 0919edf58..be5322ac0 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/CompanyFactoryAnnotatedPIDSPM.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/CompanyFactoryAnnotatedPIDSPM.java @@ -18,16 +18,7 @@ package org.apache.jdo.tck.pc.companyAnnotatedPI; import javax.jdo.PersistenceManager; -import org.apache.jdo.tck.pc.company.CompanyFactoryNewInstance; -import org.apache.jdo.tck.pc.company.IAddress; -import org.apache.jdo.tck.pc.company.ICompany; -import org.apache.jdo.tck.pc.company.IDentalInsurance; -import org.apache.jdo.tck.pc.company.IDepartment; -import org.apache.jdo.tck.pc.company.IFullTimeEmployee; -import org.apache.jdo.tck.pc.company.IMedicalInsurance; -import org.apache.jdo.tck.pc.company.IMeetingRoom; -import org.apache.jdo.tck.pc.company.IPartTimeEmployee; -import org.apache.jdo.tck.pc.company.IProject; +import org.apache.jdo.tck.pc.company.*; /* * CompanyFactoryAnnotatedPIDSPM.java @@ -35,65 +26,65 @@ * This class uses the PersistenceManager.newInstance method with the concrete * class as a parameter. */ -public class CompanyFactoryAnnotatedPIDSPM implements CompanyFactoryNewInstance { +public class CompanyFactoryAnnotatedPIDSPM + implements CompanyFactoryNewInstance { + + PersistenceManager pm = null; - PersistenceManager pm = null; + /** + * Creates a new instance of CompanyFactoryAnnotatedPIDSPM + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedPIDSPM(PersistenceManager pm) { + this.pm = pm; + } + + public Class[] getTearDownClasses() { + return new Class[] { + PIDSDentalInsurance.class, + PIDSMedicalInsurance.class, + PIDSPartTimeEmployee.class, + PIDSFullTimeEmployee.class, + PIDSProject.class, + PIDSDepartment.class, + PIDSCompany.class, + PIDSAddress.class + }; + } + + public IAddress newAddress() { + return (IAddress)pm.newInstance(PIDSAddress.class); + } - /** - * Creates a new instance of CompanyFactoryAnnotatedPIDSPM - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedPIDSPM(PersistenceManager pm) { - this.pm = pm; - } - - public Class[] getTearDownClasses() { - return new Class[] { - PIDSDentalInsurance.class, - PIDSMedicalInsurance.class, - PIDSPartTimeEmployee.class, - PIDSFullTimeEmployee.class, - PIDSProject.class, - PIDSDepartment.class, - PIDSCompany.class, - PIDSAddress.class - }; - } - - public IAddress newAddress() { - return (IAddress) pm.newInstance(PIDSAddress.class); - } - - public IMeetingRoom newMeetingRoom() { - return (IMeetingRoom) null; - } - - public ICompany newCompany() { - return (ICompany) pm.newInstance(PIDSCompany.class); - } - - public IDentalInsurance newDentalInsurance() { - return (IDentalInsurance) pm.newInstance(PIDSDentalInsurance.class); - } - - public IDepartment newDepartment() { - return (IDepartment) pm.newInstance(PIDSDepartment.class); - } - - public IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) pm.newInstance(PIDSFullTimeEmployee.class); - } - - public IMedicalInsurance newMedicalInsurance() { - return (IMedicalInsurance) pm.newInstance(PIDSMedicalInsurance.class); - } - - public IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) pm.newInstance(PIDSPartTimeEmployee.class); - } - - public IProject newProject() { - return (IProject) pm.newInstance(PIDSProject.class); - } + public IMeetingRoom newMeetingRoom() { + return (IMeetingRoom)null; + } + + public ICompany newCompany() { + return (ICompany)pm.newInstance(PIDSCompany.class); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance)pm.newInstance(PIDSDentalInsurance.class); + } + + public IDepartment newDepartment() { + return (IDepartment)pm.newInstance(PIDSDepartment.class); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee)pm.newInstance(PIDSFullTimeEmployee.class); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance)pm.newInstance(PIDSMedicalInsurance.class); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee)pm.newInstance(PIDSPartTimeEmployee.class); + } + + public IProject newProject() { + return (IProject)pm.newInstance(PIDSProject.class); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/CompanyFactoryAnnotatedPIPMDelegator.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/CompanyFactoryAnnotatedPIPMDelegator.java index 9aa92ddf7..3966ab946 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/CompanyFactoryAnnotatedPIPMDelegator.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/CompanyFactoryAnnotatedPIPMDelegator.java @@ -26,19 +26,19 @@ * This class uses the PersistenceManager.newInstance method with the concrete * class as a parameter. */ -public class CompanyFactoryAnnotatedPIPMDelegator extends CompanyFactoryAnnotatedAbstractDelegator { +public class CompanyFactoryAnnotatedPIPMDelegator + extends CompanyFactoryAnnotatedAbstractDelegator { - /** - * Creates a new instance of CompanyFactoryAnnotatedPIPMDelegator - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedPIPMDelegator(PersistenceManager pm) { - super(pm); - if (isAppIdentity) { - delegate = new CompanyFactoryAnnotatedPIAppPM(pm); - } else { // datastoreidentity - delegate = new CompanyFactoryAnnotatedPIDSPM(pm); + /** + * Creates a new instance of CompanyFactoryAnnotatedPIPMDelegator + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedPIPMDelegator(PersistenceManager pm) { + super(pm); + if (isAppIdentity){ + delegate = new CompanyFactoryAnnotatedPIAppPM(pm); + } else { //datastoreidentity + delegate = new CompanyFactoryAnnotatedPIDSPM(pm); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/CompanyFactoryAnnotatedPMInterface.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/CompanyFactoryAnnotatedPMInterface.java index 37cf45c43..5bd4051c4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/CompanyFactoryAnnotatedPMInterface.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/CompanyFactoryAnnotatedPMInterface.java @@ -18,35 +18,26 @@ package org.apache.jdo.tck.pc.companyAnnotatedPI; import javax.jdo.PersistenceManager; -import org.apache.jdo.tck.pc.company.CompanyFactoryAbstractImpl; -import org.apache.jdo.tck.pc.company.IAddress; -import org.apache.jdo.tck.pc.company.ICompany; -import org.apache.jdo.tck.pc.company.IDentalInsurance; -import org.apache.jdo.tck.pc.company.IDepartment; -import org.apache.jdo.tck.pc.company.IFullTimeEmployee; -import org.apache.jdo.tck.pc.company.IMedicalInsurance; -import org.apache.jdo.tck.pc.company.IMeetingRoom; -import org.apache.jdo.tck.pc.company.IPartTimeEmployee; -import org.apache.jdo.tck.pc.company.IProject; +import org.apache.jdo.tck.pc.company.*; /* * CompanyFactoryAnnotatedPMInterface.java * */ -public class CompanyFactoryAnnotatedPMInterface extends CompanyFactoryAbstractImpl { - - Class addressClass = null; - Class dentalInsuranceClass = null; - Class medicalInsuranceClass = null; - Class partTimeEmployeeClass = null; - Class fullTimeEmployeeClass = null; - Class projectClass = null; - Class departmentClass = null; - Class companyClass = null; - - /** */ - public final Class[] tearDownClasses = - new Class[] { +public class CompanyFactoryAnnotatedPMInterface + extends CompanyFactoryAbstractImpl { + + Class addressClass = null; + Class dentalInsuranceClass = null; + Class medicalInsuranceClass = null; + Class partTimeEmployeeClass = null; + Class fullTimeEmployeeClass = null; + Class projectClass = null; + Class departmentClass = null; + Class companyClass = null; + + /** */ + public final Class[] tearDownClasses = new Class[] { dentalInsuranceClass, medicalInsuranceClass, partTimeEmployeeClass, @@ -54,74 +45,89 @@ public class CompanyFactoryAnnotatedPMInterface extends CompanyFactoryAbstractIm projectClass, departmentClass, companyClass - }; - - /** - * Creates a new instance of CompanyFactoryAnnotatedPMInterface - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAnnotatedPMInterface(PersistenceManager pm) { - super(pm); - - if (isAppIdentity) { - addressClass = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppAddress.class; - dentalInsuranceClass = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppDentalInsurance.class; - medicalInsuranceClass = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppMedicalInsurance.class; - partTimeEmployeeClass = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppPartTimeEmployee.class; - fullTimeEmployeeClass = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppFullTimeEmployee.class; - projectClass = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppProject.class; - departmentClass = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppDepartment.class; - companyClass = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppCompany.class; - } else { // datastoreidentity - addressClass = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSAddress.class; - dentalInsuranceClass = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSDentalInsurance.class; - medicalInsuranceClass = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSMedicalInsurance.class; - partTimeEmployeeClass = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSPartTimeEmployee.class; - fullTimeEmployeeClass = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSFullTimeEmployee.class; - projectClass = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSProject.class; - departmentClass = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSDepartment.class; - companyClass = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSCompany.class; + }; + + /** + * Creates a new instance of CompanyFactoryAnnotatedPMInterface + * @param pm the PersistenceManager + */ + public CompanyFactoryAnnotatedPMInterface(PersistenceManager pm) { + super(pm); + + if (isAppIdentity){ + addressClass = + org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppAddress.class; + dentalInsuranceClass = + org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppDentalInsurance.class; + medicalInsuranceClass = + org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppMedicalInsurance.class; + partTimeEmployeeClass = + org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppPartTimeEmployee.class; + fullTimeEmployeeClass = + org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppFullTimeEmployee.class; + projectClass = + org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppProject.class; + departmentClass = + org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppDepartment.class; + companyClass = + org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppCompany.class; + } else { //datastoreidentity + addressClass = + org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSAddress.class; + dentalInsuranceClass = + org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSDentalInsurance.class; + medicalInsuranceClass = + org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSMedicalInsurance.class; + partTimeEmployeeClass = + org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSPartTimeEmployee.class; + fullTimeEmployeeClass = + org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSFullTimeEmployee.class; + projectClass = + org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSProject.class; + departmentClass = + org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSDepartment.class; + companyClass = + org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSCompany.class; + } + } + + public IAddress newAddress() { + return (IAddress)pm.newInstance(addressClass); } - } - - public IAddress newAddress() { - return (IAddress) pm.newInstance(addressClass); - } - - public IMeetingRoom newMeetingRoom() { - return (IMeetingRoom) null; - } - - public ICompany newCompany() { - return (ICompany) pm.newInstance(companyClass); - } - - public IDentalInsurance newDentalInsurance() { - return (IDentalInsurance) pm.newInstance(dentalInsuranceClass); - } - - public IDepartment newDepartment() { - return (IDepartment) pm.newInstance(departmentClass); - } - - public IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) pm.newInstance(fullTimeEmployeeClass); - } - - public IMedicalInsurance newMedicalInsurance() { - return (IMedicalInsurance) pm.newInstance(medicalInsuranceClass); - } - - public IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) pm.newInstance(partTimeEmployeeClass); - } - public IProject newProject() { - return (IProject) pm.newInstance(projectClass); - } + public IMeetingRoom newMeetingRoom() { + return (IMeetingRoom)null; + } + + public ICompany newCompany() { + return (ICompany)pm.newInstance(companyClass); + } + + public IDentalInsurance newDentalInsurance() { + return (IDentalInsurance)pm.newInstance(dentalInsuranceClass); + } + + public IDepartment newDepartment() { + return (IDepartment)pm.newInstance(departmentClass); + } + + public IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee)pm.newInstance(fullTimeEmployeeClass); + } + + public IMedicalInsurance newMedicalInsurance() { + return (IMedicalInsurance)pm.newInstance(medicalInsuranceClass); + } + + public IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee)pm.newInstance(partTimeEmployeeClass); + } + + public IProject newProject() { + return (IProject)pm.newInstance(projectClass); + } - public Class[] getTearDownClasses() { - return tearDownClasses; - } + public Class[] getTearDownClasses() { + return tearDownClasses; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppAddress.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppAddress.java index 8886cbf20..e6d3beb80 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppAddress.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppAddress.java @@ -5,51 +5,42 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; +import javax.jdo.annotations.*; + import org.apache.jdo.tck.pc.company.IAddress; /** - * This interface represents the persistent state of Address. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Address. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ -@PersistenceCapable(embeddedOnly = "true", requiresExtent = "false") +@PersistenceCapable(embeddedOnly="true", requiresExtent="false") public interface PIAppAddress extends IAddress { - @Persistent(primaryKey = "true") - long getAddrid(); - - String getStreet(); - - String getCity(); - - String getState(); - - String getZipcode(); - - String getCountry(); - - void setAddrid(long addrid); - - void setStreet(String street); - - void setCity(String city); - - void setState(String state); - - void setZipcode(String zipcode); - - void setCountry(String country); + @Persistent(primaryKey="true") + long getAddrid(); + String getStreet(); + String getCity(); + String getState(); + String getZipcode(); + String getCountry(); + + void setAddrid(long addrid); + void setStreet(String street); + void setCity(String city); + void setState(String state); + void setZipcode(String zipcode); + void setCountry(String country); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppCompany.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppCompany.java index 91fb95142..fe1744ea5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppCompany.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppCompany.java @@ -5,77 +5,61 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; +import javax.jdo.annotations.*; + +import org.apache.jdo.tck.pc.company.ICompany; import java.util.Date; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.Embedded; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; -import javax.jdo.annotations.PrimaryKey; import org.apache.jdo.tck.pc.company.IAddress; -import org.apache.jdo.tck.pc.company.ICompany; /** - * This interface represents the persistent state of Company. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Company. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION, table = "companies") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator(strategy = DiscriminatorStrategy.CLASS_NAME, column = "DISCRIMINATOR") +@PersistenceCapable(identityType=IdentityType.APPLICATION, table="companies") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") public interface PIAppCompany extends ICompany { - - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppAddress.class) - @Embedded( - nullIndicatorColumn = "COUNTRY", - members = { - @Persistent(name = "addrid", columns = @Column(name = "ADDRID")), - @Persistent(name = "street", columns = @Column(name = "STREET")), - @Persistent(name = "city", columns = @Column(name = "CITY")), - @Persistent(name = "state", columns = @Column(name = "STATE")), - @Persistent(name = "zipcode", columns = @Column(name = "ZIPCODE")), - @Persistent(name = "country", columns = @Column(name = "COUNTRY")) - }) - IAddress getAddress(); - - @PrimaryKey - @Column(name = "ID") - long getCompanyid(); - - @Persistent(mappedBy = "company") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppDepartment.class) - Set getDepartments(); - - @Column(name = "FOUNDEDDATE") - Date getFounded(); - - @Column(name = "NAME", jdbcType = "VARCHAR") - String getName(); - - void setAddress(IAddress a); - - void setCompanyid(long id); - - void setDepartments(Set depts); - - void setFounded(Date date); - - void setName(String string); + + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppAddress.class) + @Embedded(nullIndicatorColumn="COUNTRY", + members={ + @Persistent(name="addrid", columns=@Column(name="ADDRID")), + @Persistent(name="street", columns=@Column(name="STREET")), + @Persistent(name="city", columns=@Column(name="CITY")), + @Persistent(name="state", columns=@Column(name="STATE")), + @Persistent(name="zipcode", columns=@Column(name="ZIPCODE")), + @Persistent(name="country", columns=@Column(name="COUNTRY")) + }) + IAddress getAddress(); + @PrimaryKey + @Column(name="ID") + long getCompanyid(); + @Persistent(mappedBy="company") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppDepartment.class) + Set getDepartments(); + @Column(name="FOUNDEDDATE") + Date getFounded(); + @Column(name="NAME", jdbcType="VARCHAR") + String getName(); + + void setAddress(IAddress a); + void setCompanyid(long id); + void setDepartments(Set depts); + void setFounded(Date date); + void setName(String string); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppDentalInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppDentalInsurance.java index d36fc0172..a9950c906 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppDentalInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppDentalInsurance.java @@ -5,33 +5,34 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; +import javax.jdo.annotations.*; + import java.math.BigDecimal; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.PersistenceCapable; + import org.apache.jdo.tck.pc.company.IDentalInsurance; /** - * This interface represents the persistent state of DentalInsurance. Javadoc was deliberately - * omitted because it would distract from the purpose of the interface. + * This interface represents the persistent state of DentalInsurance. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION) -public interface PIAppDentalInsurance extends IDentalInsurance, PIAppInsurance { - - @Column(name = "LIFETIME_ORTHO_BENEFIT") - BigDecimal getLifetimeOrthoBenefit(); +@PersistenceCapable(identityType=IdentityType.APPLICATION) +public interface PIAppDentalInsurance extends IDentalInsurance, + PIAppInsurance { - void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit); + @Column(name="LIFETIME_ORTHO_BENEFIT") + BigDecimal getLifetimeOrthoBenefit(); + void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppDepartment.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppDepartment.java index a58675cb5..861adf764 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppDepartment.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppDepartment.java @@ -5,74 +5,62 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; +import javax.jdo.annotations.*; + import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.PersistenceModifier; -import javax.jdo.annotations.Persistent; import org.apache.jdo.tck.pc.company.ICompany; + import org.apache.jdo.tck.pc.company.IDepartment; import org.apache.jdo.tck.pc.company.IEmployee; /** - * This interface represents the persistent state of Department. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Department. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION, table = "departments") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator(strategy = DiscriminatorStrategy.CLASS_NAME, column = "DISCRIMINATOR") +@PersistenceCapable(identityType=IdentityType.APPLICATION, table="departments") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") public interface PIAppDepartment extends IDepartment { - @Persistent(primaryKey = "true") - @Column(name = "ID") - long getDeptid(); - - @Column(name = "NAME") - String getName(); - - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppCompany.class) - @Column(name = "COMPANYID") - ICompany getCompany(); - - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class) - @Column(name = "EMP_OF_THE_MONTH") - IEmployee getEmployeeOfTheMonth(); - - @Persistent(persistenceModifier = PersistenceModifier.PERSISTENT, mappedBy = "department") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class) - Set getEmployees(); - - @Persistent(persistenceModifier = PersistenceModifier.PERSISTENT, mappedBy = "fundingDept") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class) - Set getFundedEmps(); - - void setDeptid(long deptid); - - void setName(String name); - - void setCompany(ICompany company); - - void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth); - - void setEmployees(Set employees); + @Persistent(primaryKey="true") + @Column(name="ID") + long getDeptid(); + @Column(name="NAME") + String getName(); + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppCompany.class) + @Column(name="COMPANYID") + ICompany getCompany(); + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class) + @Column(name="EMP_OF_THE_MONTH") + IEmployee getEmployeeOfTheMonth(); + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT, + mappedBy="department") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class) + Set getEmployees(); + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT, + mappedBy="fundingDept") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class) + Set getFundedEmps(); + + void setDeptid(long deptid); + void setName(String name); + void setCompany(ICompany company); + void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth); + void setEmployees(Set employees); + void setFundedEmps(Set employees); - void setFundedEmps(Set employees); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppEmployee.java index 1416ecc76..190824d91 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppEmployee.java @@ -5,124 +5,91 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; +import javax.jdo.annotations.*; + +import org.apache.jdo.tck.pc.company.IPerson; import java.util.Date; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.PersistenceModifier; -import javax.jdo.annotations.Persistent; import org.apache.jdo.tck.pc.company.IDentalInsurance; import org.apache.jdo.tck.pc.company.IDepartment; import org.apache.jdo.tck.pc.company.IEmployee; import org.apache.jdo.tck.pc.company.IMedicalInsurance; -import org.apache.jdo.tck.pc.company.IPerson; /** - * This interface represents the persistent state of Employee. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Employee. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION) -@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE) +@PersistenceCapable(identityType=IdentityType.APPLICATION) +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) public interface PIAppEmployee extends PIAppPerson, IPerson { - @Column(name = "HIREDATE") - Date getHiredate(); - - @Column(name = "WEEKLYHOURS") - double getWeeklyhours(); - - @Persistent(persistenceModifier = PersistenceModifier.PERSISTENT, mappedBy = "reviewers") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppProject.class) - Set getReviewedProjects(); - - @Persistent(persistenceModifier = PersistenceModifier.PERSISTENT, mappedBy = "members") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppProject.class) - Set getProjects(); - - @Persistent( - mappedBy = "employee", - types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppDentalInsurance.class) - IDentalInsurance getDentalInsurance(); - - @Persistent( - mappedBy = "employee", - types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppMedicalInsurance.class) - IMedicalInsurance getMedicalInsurance(); - - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppDepartment.class) - @Column(name = "DEPARTMENT") - IDepartment getDepartment(); - - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppDepartment.class) - @Column(name = "FUNDINGDEPT") - IDepartment getFundingDept(); - - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class) - @Column(name = "MANAGER") - IEmployee getManager(); - - @Persistent(persistenceModifier = PersistenceModifier.PERSISTENT, mappedBy = "manager") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class) - Set getTeam(); - - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class) - @Column(name = "MENTOR") - IEmployee getMentor(); - - @Persistent( - mappedBy = "mentor", - types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class) - IEmployee getProtege(); - - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class) - @Column(name = "HRADVISOR") - IEmployee getHradvisor(); - - @Persistent(mappedBy = "hradvisor", persistenceModifier = PersistenceModifier.PERSISTENT) - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class) - Set getHradvisees(); - - void setHiredate(Date hiredate); - - void setWeeklyhours(double weeklyhours); - - void setReviewedProjects(Set reviewedProjects); - - void setProjects(Set projects); - - void setDentalInsurance(IDentalInsurance dentalInsurance); - - void setMedicalInsurance(IMedicalInsurance medicalInsurance); - - void setDepartment(IDepartment department); - - void setFundingDept(IDepartment department); - - void setManager(IEmployee manager); - - void setTeam(Set team); - - void setMentor(IEmployee mentor); - - void setProtege(IEmployee protege); - - void setHradvisor(IEmployee hradvisor); - - void setHradvisees(Set hradvisees); + @Column(name="HIREDATE") + Date getHiredate(); + @Column(name="WEEKLYHOURS") + double getWeeklyhours(); + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT, + mappedBy="reviewers") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppProject.class) + Set getReviewedProjects(); + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT, + mappedBy="members") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppProject.class) + Set getProjects(); + @Persistent(mappedBy="employee", types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppDentalInsurance.class) + IDentalInsurance getDentalInsurance(); + @Persistent(mappedBy="employee", types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppMedicalInsurance.class) + IMedicalInsurance getMedicalInsurance(); + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppDepartment.class) + @Column(name="DEPARTMENT") + IDepartment getDepartment(); + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppDepartment.class) + @Column(name="FUNDINGDEPT") + IDepartment getFundingDept(); + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class) + @Column(name="MANAGER") + IEmployee getManager(); + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT, + mappedBy="manager") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class) + Set getTeam(); + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class) + @Column(name="MENTOR") + IEmployee getMentor(); + @Persistent(mappedBy="mentor", types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class) + IEmployee getProtege(); + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class) + @Column(name="HRADVISOR") + IEmployee getHradvisor(); + @Persistent(mappedBy="hradvisor", persistenceModifier=PersistenceModifier.PERSISTENT) + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class) + Set getHradvisees(); + + void setHiredate(Date hiredate); + void setWeeklyhours(double weeklyhours); + void setReviewedProjects(Set reviewedProjects); + void setProjects(Set projects); + void setDentalInsurance(IDentalInsurance dentalInsurance); + void setMedicalInsurance(IMedicalInsurance medicalInsurance); + void setDepartment(IDepartment department); + void setFundingDept(IDepartment department); + void setManager(IEmployee manager); + void setTeam(Set team); + void setMentor(IEmployee mentor); + void setProtege(IEmployee protege); + void setHradvisor(IEmployee hradvisor); + void setHradvisees(Set hradvisees); + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppFullTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppFullTimeEmployee.java index bee6f23a5..8c579b2e8 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppFullTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppFullTimeEmployee.java @@ -5,35 +5,31 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.PersistenceCapable; import org.apache.jdo.tck.pc.company.IFullTimeEmployee; +import javax.jdo.annotations.*; /** - * This interface represents the persistent state of FullTimeEmployee. Javadoc was deliberately - * omitted because it would distract from the purpose of the interface. + * This interface represents the persistent state of FullTimeEmployee. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION) -@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE) +@PersistenceCapable(identityType=IdentityType.APPLICATION) +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) public interface PIAppFullTimeEmployee extends PIAppEmployee, IFullTimeEmployee { - @Column(name = "SALARY") - double getSalary(); - - void setSalary(double salary); + @Column(name="SALARY") + double getSalary(); + void setSalary(double salary); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppInsurance.java index 4d7dc4503..23dbd4fbd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppInsurance.java @@ -5,60 +5,46 @@ * 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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Index; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; +import javax.jdo.annotations.*; import org.apache.jdo.tck.pc.company.IEmployee; + import org.apache.jdo.tck.pc.company.IInsurance; /** - * This interface represents the persistent state of Insurance. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Insurance. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION, table = "insuranceplans") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator( - strategy = DiscriminatorStrategy.CLASS_NAME, - column = "DISCRIMINATOR", - indexed = "true") -@Index( - name = "INS_DISCRIMINATOR_INDEX", - unique = "false", - columns = @Column(name = "DISCRIMINATOR")) -public interface PIAppInsurance extends IInsurance { - - @Persistent(primaryKey = "true") - @Column(name = "INSID") - long getInsid(); - - @Column(name = "CARRIER") - String getCarrier(); - - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class) - @Column(name = "EMPLOYEE") - IEmployee getEmployee(); - - void setInsid(long insid); - - void setCarrier(String carrier); - - void setEmployee(IEmployee employee); +@PersistenceCapable(identityType=IdentityType.APPLICATION,table="insuranceplans") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR", indexed="true") +@Index(name="INS_DISCRIMINATOR_INDEX", unique="false", + columns=@Column(name="DISCRIMINATOR")) + public interface PIAppInsurance extends IInsurance { + + @Persistent(primaryKey="true") + @Column(name="INSID") + long getInsid(); + @Column(name="CARRIER") + String getCarrier(); + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class) + @Column(name="EMPLOYEE") + IEmployee getEmployee(); + + void setInsid(long insid); + void setCarrier(String carrier); + void setEmployee(IEmployee employee); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppMedicalInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppMedicalInsurance.java index a6d684b43..9ac9bb242 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppMedicalInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppMedicalInsurance.java @@ -5,32 +5,32 @@ * 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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.PersistenceCapable; +import javax.jdo.annotations.*; + import org.apache.jdo.tck.pc.company.IMedicalInsurance; /** - * This interface represents the persistent state of MedicalInsurance. Javadoc was deliberately - * omitted because it would distract from the purpose of the interface. + * This interface represents the persistent state of MedicalInsurance. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION) -public interface PIAppMedicalInsurance extends PIAppInsurance, IMedicalInsurance { - - @Column(name = "PLANTYPE") - String getPlanType(); +@PersistenceCapable(identityType=IdentityType.APPLICATION) +public interface PIAppMedicalInsurance + extends PIAppInsurance, IMedicalInsurance{ - void setPlanType(String planType); + @Column(name="PLANTYPE") + String getPlanType(); + void setPlanType(String planType); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppPartTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppPartTimeEmployee.java index ce6e29493..7ac48d98d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppPartTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppPartTimeEmployee.java @@ -5,35 +5,31 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.PersistenceCapable; import org.apache.jdo.tck.pc.company.IPartTimeEmployee; +import javax.jdo.annotations.*; /** - * This interface represents the persistent state of PartTimeEmployee. Javadoc was deliberately - * omitted because it would distract from the purpose of the interface. + * This interface represents the persistent state of PartTimeEmployee. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION) -@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE) +@PersistenceCapable(identityType=IdentityType.APPLICATION) +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) public interface PIAppPartTimeEmployee extends PIAppEmployee, IPartTimeEmployee { - @Column(name = "WAGE") - double getWage(); - - void setWage(double wage); + @Column(name="WAGE") + double getWage(); + void setWage(double wage); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppPerson.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppPerson.java index 9fb01ab4e..7e338fb57 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppPerson.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppPerson.java @@ -5,97 +5,74 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; +import javax.jdo.annotations.*; + import java.util.Date; import java.util.Map; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.Embedded; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.Join; -import javax.jdo.annotations.Key; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.PersistenceModifier; -import javax.jdo.annotations.Persistent; -import javax.jdo.annotations.Value; import org.apache.jdo.tck.pc.company.IAddress; + import org.apache.jdo.tck.pc.company.IPerson; /** - * This interface represents the persistent state of Person. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Person. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION, table = "persons") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator( - strategy = DiscriminatorStrategy.CLASS_NAME, - column = "DISCRIMINATOR", - indexed = "true") +@PersistenceCapable(identityType=IdentityType.APPLICATION,table="persons") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR", indexed="true") public interface PIAppPerson extends IPerson { - @Persistent(primaryKey = "true") - @Column(name = "PERSONID") - long getPersonid(); - - @Column(name = "LASTNAME") - String getLastname(); - - @Column(name = "FIRSTNAME") - String getFirstname(); - - @Persistent(defaultFetchGroup = "false") - @Column(name = "MIDDLENAME", allowsNull = "true") - String getMiddlename(); - - @Persistent( - persistenceModifier = PersistenceModifier.PERSISTENT, - types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppAddress.class) - @Embedded( - nullIndicatorColumn = "COUNTRY", - members = { - @Persistent(name = "addrid", columns = @Column(name = "ADDRID")), - @Persistent(name = "street", columns = @Column(name = "STREET")), - @Persistent(name = "city", columns = @Column(name = "CITY")), - @Persistent(name = "state", columns = @Column(name = "STATE")), - @Persistent(name = "zipcode", columns = @Column(name = "ZIPCODE")), - @Persistent(name = "country", columns = @Column(name = "COUNTRY")) - }) - IAddress getAddress(); - - @Column(name = "BIRTHDATE") - Date getBirthdate(); - - @Persistent(persistenceModifier = PersistenceModifier.PERSISTENT, table = "employee_phoneno_type") - @Join(column = "EMPID") - @Key(types = java.lang.String.class, column = "TYPE") - @Value(types = java.lang.String.class, column = "PHONENO") - Map getPhoneNumbers(); - - void setPersonid(long personid); - - void setLastname(String lastname); - - void setFirstname(String firstname); - - void setMiddlename(String middlename); - - void setAddress(IAddress address); - - void setBirthdate(Date birthdate); + @Persistent(primaryKey="true") + @Column(name="PERSONID") + long getPersonid(); + @Column(name="LASTNAME") + String getLastname(); + @Column(name="FIRSTNAME") + String getFirstname(); + @Persistent(defaultFetchGroup="false") + @Column(name="MIDDLENAME", allowsNull="true") + String getMiddlename(); + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT, + types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppAddress.class) + @Embedded(nullIndicatorColumn="COUNTRY", + members={ + @Persistent(name="addrid", columns=@Column(name="ADDRID")), + @Persistent(name="street", columns=@Column(name="STREET")), + @Persistent(name="city", columns=@Column(name="CITY")), + @Persistent(name="state", columns=@Column(name="STATE")), + @Persistent(name="zipcode", columns=@Column(name="ZIPCODE")), + @Persistent(name="country", columns=@Column(name="COUNTRY")) + }) + IAddress getAddress(); + @Column(name="BIRTHDATE") + Date getBirthdate(); + @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT, + table="employee_phoneno_type") + @Join(column="EMPID") + @Key(types=java.lang.String.class, column="TYPE") + @Value(types=java.lang.String.class, column="PHONENO") + Map getPhoneNumbers(); + + void setPersonid(long personid); + void setLastname(String lastname); + void setFirstname(String firstname); + void setMiddlename(String middlename); + void setAddress(IAddress address); + void setBirthdate(Date birthdate); + void setPhoneNumbers(Map phoneNumbers); - void setPhoneNumbers(Map phoneNumbers); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppProject.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppProject.java index 56f2e1cd4..ab7491063 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppProject.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIAppProject.java @@ -5,74 +5,56 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; +import javax.jdo.annotations.*; + import java.math.BigDecimal; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.IdentityType; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.Join; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; -import javax.jdo.annotations.PrimaryKey; + import org.apache.jdo.tck.pc.company.IProject; /** - * This interface represents the persistent state of Project. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Project. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ -@PersistenceCapable(identityType = IdentityType.APPLICATION, table = "projects") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator(strategy = DiscriminatorStrategy.CLASS_NAME, column = "DISCRIMINATOR") +@PersistenceCapable(identityType=IdentityType.APPLICATION,table="projects") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") public interface PIAppProject extends IProject { - @PrimaryKey - @Column(name = "PROJID") - long getProjid(); - - @Column(name = "NAME") - String getName(); - - @Column(name = "BUDGET", jdbcType = "DECIMAL", length = 11, scale = 2) - BigDecimal getBudget(); - - @Persistent(table = "project_reviewer") - @Element( - types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class, - column = "REVIEWER", - foreignKey = "PR_REV_FK") - @Join(column = "PROJID", foreignKey = "PR_PROJ_FK") - Set getReviewers(); - - @Persistent(table = "project_member") - @Element( - types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class, - column = "MEMBER", - foreignKey = "PM_MEMB_FK") - @Join(column = "PROJID", foreignKey = "PM_PROJ_FK") - Set getMembers(); - - void setProjid(long projid); - - void setName(String name); - - void setBudget(BigDecimal budget); - - void setReviewers(Set reviewers); - - void setMembers(Set employees); + @PrimaryKey + @Column(name="PROJID") + long getProjid(); + @Column(name="NAME") + String getName(); + @Column(name="BUDGET", jdbcType="DECIMAL", length=11, scale=2) + BigDecimal getBudget(); + @Persistent(table="project_reviewer") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class, + column="REVIEWER", foreignKey="PR_REV_FK") + @Join(column="PROJID", foreignKey="PR_PROJ_FK") + Set getReviewers(); + @Persistent(table="project_member") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIAppEmployee.class, + column="MEMBER", foreignKey="PM_MEMB_FK") + @Join(column="PROJID", foreignKey="PM_PROJ_FK") + Set getMembers(); + + void setProjid(long projid); + void setName(String name); + void setBudget(BigDecimal budget); + void setReviewers(Set reviewers); + void setMembers(Set employees); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSAddress.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSAddress.java index e4039fa8a..0b3411551 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSAddress.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSAddress.java @@ -5,49 +5,40 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; -import javax.jdo.annotations.PersistenceCapable; +import javax.jdo.annotations.*; import org.apache.jdo.tck.pc.company.IAddress; /** - * This interface represents the persistent state of Address. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Address. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ -@PersistenceCapable(embeddedOnly = "true", requiresExtent = "false") +@PersistenceCapable(embeddedOnly="true", requiresExtent="false") public interface PIDSAddress extends IAddress { - long getAddrid(); - - String getStreet(); - - String getCity(); - - String getState(); - - String getZipcode(); - - String getCountry(); - - void setAddrid(long addrid); - - void setStreet(String street); - - void setCity(String city); - - void setState(String state); - - void setZipcode(String zipcode); - - void setCountry(String country); + long getAddrid(); + String getStreet(); + String getCity(); + String getState(); + String getZipcode(); + String getCountry(); + + void setAddrid(long addrid); + void setStreet(String street); + void setCity(String city); + void setState(String state); + void setZipcode(String zipcode); + void setCountry(String country); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSCompany.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSCompany.java index f33b5f434..9ac131228 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSCompany.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSCompany.java @@ -5,77 +5,63 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; +import javax.jdo.annotations.*; + import java.util.Date; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.DatastoreIdentity; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.Embedded; -import javax.jdo.annotations.IdGeneratorStrategy; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; import org.apache.jdo.tck.pc.company.IAddress; + import org.apache.jdo.tck.pc.company.ICompany; /** - * This interface represents the persistent state of Company. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Company. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ -@PersistenceCapable(table = "companies") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator(strategy = DiscriminatorStrategy.CLASS_NAME, column = "DISCRIMINATOR") -@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "DATASTORE_IDENTITY") +@PersistenceCapable(table="companies") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, + column="DATASTORE_IDENTITY") public interface PIDSCompany extends ICompany { - - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSAddress.class) - @Embedded( - nullIndicatorColumn = "COUNTRY", - members = { - @Persistent(name = "addrid", columns = @Column(name = "ADDRID")), - @Persistent(name = "street", columns = @Column(name = "STREET")), - @Persistent(name = "city", columns = @Column(name = "CITY")), - @Persistent(name = "state", columns = @Column(name = "STATE")), - @Persistent(name = "zipcode", columns = @Column(name = "ZIPCODE")), - @Persistent(name = "country", columns = @Column(name = "COUNTRY")) - }) - IAddress getAddress(); - - @Column(name = "ID") - long getCompanyid(); - - @Persistent(mappedBy = "company") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSDepartment.class) - Set getDepartments(); - - @Column(name = "FOUNDEDDATE") - Date getFounded(); - - @Column(name = "NAME", jdbcType = "VARCHAR") - String getName(); - - void setAddress(IAddress a); - - void setCompanyid(long id); - - void setDepartments(Set depts); - - void setFounded(Date date); - - void setName(String string); + + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSAddress.class) + @Embedded(nullIndicatorColumn="COUNTRY", + members={ + @Persistent(name="addrid", columns=@Column(name="ADDRID")), + @Persistent(name="street", columns=@Column(name="STREET")), + @Persistent(name="city", columns=@Column(name="CITY")), + @Persistent(name="state", columns=@Column(name="STATE")), + @Persistent(name="zipcode", columns=@Column(name="ZIPCODE")), + @Persistent(name="country", columns=@Column(name="COUNTRY")) + }) + IAddress getAddress(); + @Column(name="ID") + long getCompanyid(); + @Persistent(mappedBy="company") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSDepartment.class) + Set getDepartments(); + @Column(name="FOUNDEDDATE") + Date getFounded(); + @Column(name="NAME", jdbcType="VARCHAR") + String getName(); + + void setAddress(IAddress a); + void setCompanyid(long id); + void setDepartments(Set depts); + void setFounded(Date date); + void setName(String string); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSDentalInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSDentalInsurance.java index 772f69740..8ff0eb6f5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSDentalInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSDentalInsurance.java @@ -5,32 +5,33 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; +import javax.jdo.annotations.*; + import java.math.BigDecimal; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.PersistenceCapable; + import org.apache.jdo.tck.pc.company.IDentalInsurance; /** - * This interface represents the persistent state of DentalInsurance. Javadoc was deliberately - * omitted because it would distract from the purpose of the interface. + * This interface represents the persistent state of DentalInsurance. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ @PersistenceCapable public interface PIDSDentalInsurance extends IDentalInsurance, PIDSInsurance { - @Column(name = "LIFETIME_ORTHO_BENEFIT") - BigDecimal getLifetimeOrthoBenefit(); - - void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit); + @Column(name="LIFETIME_ORTHO_BENEFIT") + BigDecimal getLifetimeOrthoBenefit(); + void setLifetimeOrthoBenefit(BigDecimal lifetimeOrthoBenefit); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSDepartment.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSDepartment.java index a608280b6..2262e792f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSDepartment.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSDepartment.java @@ -5,74 +5,61 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; +import javax.jdo.annotations.*; + import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.DatastoreIdentity; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.IdGeneratorStrategy; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; import org.apache.jdo.tck.pc.company.ICompany; + import org.apache.jdo.tck.pc.company.IDepartment; import org.apache.jdo.tck.pc.company.IEmployee; /** - * This interface represents the persistent state of Department. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Department. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ -@PersistenceCapable(table = "departments") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator(strategy = DiscriminatorStrategy.CLASS_NAME, column = "DISCRIMINATOR") -@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "DATASTORE_IDENTITY") +@PersistenceCapable(table="departments") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, + column="DATASTORE_IDENTITY") public interface PIDSDepartment extends IDepartment { - @Column(name = "ID") - long getDeptid(); - - @Column(name = "NAME") - String getName(); - - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSCompany.class) - @Column(name = "COMPANYID") - ICompany getCompany(); - - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class) - @Column(name = "EMP_OF_THE_MONTH") - IEmployee getEmployeeOfTheMonth(); - - @Persistent(mappedBy = "department") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class) - Set getEmployees(); - - @Persistent(mappedBy = "fundingDept") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class) - Set getFundedEmps(); - - void setDeptid(long deptid); - - void setName(String name); - - void setCompany(ICompany company); - - void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth); - - void setEmployees(Set employees); + @Column(name="ID") + long getDeptid(); + @Column(name="NAME") + String getName(); + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSCompany.class) + @Column(name="COMPANYID") + ICompany getCompany(); + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class) + @Column(name="EMP_OF_THE_MONTH") + IEmployee getEmployeeOfTheMonth(); + @Persistent(mappedBy="department") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class) + Set getEmployees(); + @Persistent(mappedBy="fundingDept") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class) + Set getFundedEmps(); + + void setDeptid(long deptid); + void setName(String name); + void setCompany(ICompany company); + void setEmployeeOfTheMonth(IEmployee employeeOfTheMonth); + void setEmployees(Set employees); + void setFundedEmps(Set employees); - void setFundedEmps(Set employees); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSEmployee.java index 2a91bf4cd..a8c741115 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSEmployee.java @@ -5,121 +5,87 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; +import javax.jdo.annotations.*; + import java.util.Date; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; import org.apache.jdo.tck.pc.company.IDentalInsurance; import org.apache.jdo.tck.pc.company.IDepartment; import org.apache.jdo.tck.pc.company.IEmployee; import org.apache.jdo.tck.pc.company.IMedicalInsurance; /** - * This interface represents the persistent state of Employee. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Employee. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ @PersistenceCapable -@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE) +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) public interface PIDSEmployee extends IEmployee, PIDSPerson { - @Column(name = "HIREDATE") - Date getHiredate(); - - @Column(name = "WEEKLYHOURS") - double getWeeklyhours(); - - @Persistent(mappedBy = "reviewers") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSProject.class) - Set getReviewedProjects(); - - @Persistent(mappedBy = "members") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSProject.class) - Set getProjects(); - - @Persistent( - mappedBy = "employee", - types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSDentalInsurance.class) - IDentalInsurance getDentalInsurance(); - - @Persistent( - mappedBy = "employee", - types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSMedicalInsurance.class) - IMedicalInsurance getMedicalInsurance(); - - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSDepartment.class) - @Column(name = "DEPARTMENT") - IDepartment getDepartment(); - - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSDepartment.class) - @Column(name = "FUNDINGDEPT") - IDepartment getFundingDept(); - - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class) - @Column(name = "MANAGER") - IEmployee getManager(); - - @Persistent(mappedBy = "manager") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class) - Set getTeam(); - - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class) - @Column(name = "MENTOR") - IEmployee getMentor(); - - @Persistent( - types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class, - mappedBy = "mentor") - IEmployee getProtege(); - - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class) - @Column(name = "HRADVISOR") - IEmployee getHradvisor(); - - @Persistent(mappedBy = "hradvisor") - @Element(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class) - Set getHradvisees(); - - void setHiredate(Date hiredate); - - void setWeeklyhours(double weeklyhours); - - void setReviewedProjects(Set reviewedProjects); - - void setProjects(Set projects); - - void setDentalInsurance(IDentalInsurance dentalInsurance); - - void setMedicalInsurance(IMedicalInsurance medicalInsurance); - - void setDepartment(IDepartment department); - - void setFundingDept(IDepartment department); - - void setManager(IEmployee manager); - - void setTeam(Set team); - - void setMentor(IEmployee mentor); - - void setProtege(IEmployee protege); - - void setHradvisor(IEmployee hradvisor); - - void setHradvisees(Set hradvisees); + @Column(name="HIREDATE") + Date getHiredate(); + @Column(name="WEEKLYHOURS") + double getWeeklyhours(); + @Persistent(mappedBy="reviewers") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSProject.class) + Set getReviewedProjects(); + @Persistent(mappedBy="members") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSProject.class) + Set getProjects(); + @Persistent(mappedBy="employee",types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSDentalInsurance.class) + IDentalInsurance getDentalInsurance(); + @Persistent(mappedBy="employee",types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSMedicalInsurance.class) + IMedicalInsurance getMedicalInsurance(); + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSDepartment.class) + @Column(name="DEPARTMENT") + IDepartment getDepartment(); + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSDepartment.class) + @Column(name="FUNDINGDEPT") + IDepartment getFundingDept(); + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class) + @Column(name="MANAGER") + IEmployee getManager(); + @Persistent(mappedBy="manager") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class) + Set getTeam(); + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class) + @Column(name="MENTOR") + IEmployee getMentor(); + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class, mappedBy="mentor") + IEmployee getProtege(); + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class) + @Column(name="HRADVISOR") + IEmployee getHradvisor(); + @Persistent(mappedBy="hradvisor") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class) + Set getHradvisees(); + + void setHiredate(Date hiredate); + void setWeeklyhours(double weeklyhours); + void setReviewedProjects(Set reviewedProjects); + void setProjects(Set projects); + void setDentalInsurance(IDentalInsurance dentalInsurance); + void setMedicalInsurance(IMedicalInsurance medicalInsurance); + void setDepartment(IDepartment department); + void setFundingDept(IDepartment department); + void setManager(IEmployee manager); + void setTeam(Set team); + void setMentor(IEmployee mentor); + void setProtege(IEmployee protege); + void setHradvisor(IEmployee hradvisor); + void setHradvisees(Set hradvisees); + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSFullTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSFullTimeEmployee.java index ac9620a01..5d966c85b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSFullTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSFullTimeEmployee.java @@ -5,34 +5,32 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.PersistenceCapable; +import javax.jdo.annotations.*; + import org.apache.jdo.tck.pc.company.IFullTimeEmployee; /** - * This interface represents the persistent state of FullTimeEmployee. Javadoc was deliberately - * omitted because it would distract from the purpose of the interface. + * This interface represents the persistent state of FullTimeEmployee. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ @PersistenceCapable -@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE) +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) public interface PIDSFullTimeEmployee extends IFullTimeEmployee, PIDSEmployee { - @Column(name = "SALARY") - double getSalary(); - - void setSalary(double salary); + @Column(name="SALARY") + double getSalary(); + void setSalary(double salary); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSInsurance.java index 348468dd5..7fa80549e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSInsurance.java @@ -5,61 +5,47 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.DatastoreIdentity; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.IdGeneratorStrategy; -import javax.jdo.annotations.Index; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; +import javax.jdo.annotations.*; import org.apache.jdo.tck.pc.company.IEmployee; + import org.apache.jdo.tck.pc.company.IInsurance; /** - * This interface represents the persistent state of Insurance. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Insurance. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ -@PersistenceCapable(table = "insuranceplans") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator( - strategy = DiscriminatorStrategy.CLASS_NAME, - column = "DISCRIMINATOR", - indexed = "true") -@Index( - name = "INS_DISCRIMINATOR_INDEX", - unique = "false", - columns = @Column(name = "DISCRIMINATOR")) -@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "DATASTORE_IDENTITY") +@PersistenceCapable(table="insuranceplans") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR", indexed="true") +@Index(name="INS_DISCRIMINATOR_INDEX", unique="false", + columns=@Column(name="DISCRIMINATOR")) +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, + column="DATASTORE_IDENTITY") public interface PIDSInsurance extends IInsurance { - @Column(name = "INSID") - long getInsid(); - - @Column(name = "CARRIER") - String getCarrier(); - - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class) - @Column(name = "EMPLOYEE") - IEmployee getEmployee(); - - void setInsid(long insid); - - void setCarrier(String carrier); - - void setEmployee(IEmployee employee); + @Column(name="INSID") + long getInsid(); + @Column(name="CARRIER") + String getCarrier(); + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class) + @Column(name="EMPLOYEE") + IEmployee getEmployee(); + + void setInsid(long insid); + void setCarrier(String carrier); + void setEmployee(IEmployee employee); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSMedicalInsurance.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSMedicalInsurance.java index e3bb46354..6f865cf75 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSMedicalInsurance.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSMedicalInsurance.java @@ -5,31 +5,31 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.PersistenceCapable; +import javax.jdo.annotations.*; + import org.apache.jdo.tck.pc.company.IMedicalInsurance; /** - * This interface represents the persistent state of MedicalInsurance. Javadoc was deliberately - * omitted because it would distract from the purpose of the interface. + * This interface represents the persistent state of MedicalInsurance. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ @PersistenceCapable public interface PIDSMedicalInsurance extends IMedicalInsurance, PIDSInsurance { - @Column(name = "PLANTYPE") - String getPlanType(); - - void setPlanType(String planType); + @Column(name="PLANTYPE") + String getPlanType(); + void setPlanType(String planType); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSPartTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSPartTimeEmployee.java index 2ab7553c9..57824e7dd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSPartTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSPartTimeEmployee.java @@ -5,34 +5,32 @@ * 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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.PersistenceCapable; +import javax.jdo.annotations.*; + import org.apache.jdo.tck.pc.company.IPartTimeEmployee; /** - * This interface represents the persistent state of PartTimeEmployee. Javadoc was deliberately - * omitted because it would distract from the purpose of the interface. + * This interface represents the persistent state of PartTimeEmployee. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ @PersistenceCapable -@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE) +@Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE) public interface PIDSPartTimeEmployee extends IPartTimeEmployee, PIDSEmployee { - @Column(name = "WAGE") - double getWage(); - - void setWage(double wage); + @Column(name="WAGE") + double getWage(); + void setWage(double wage); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSPerson.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSPerson.java index c8915d8e5..ceec8f7d8 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSPerson.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSPerson.java @@ -5,95 +5,73 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; +import javax.jdo.annotations.*; + import java.util.Date; import java.util.Map; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.DatastoreIdentity; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.Embedded; -import javax.jdo.annotations.IdGeneratorStrategy; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.Join; -import javax.jdo.annotations.Key; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; -import javax.jdo.annotations.Value; import org.apache.jdo.tck.pc.company.IAddress; + import org.apache.jdo.tck.pc.company.IPerson; /** - * This interface represents the persistent state of Person. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Person. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ -@PersistenceCapable(table = "persons") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator( - strategy = DiscriminatorStrategy.CLASS_NAME, - column = "DISCRIMINATOR", - indexed = "true") -@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "DATASTORE_IDENTITY") +@PersistenceCapable(table="persons") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR", indexed="true") +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, + column="DATASTORE_IDENTITY") public interface PIDSPerson extends IPerson { - @Column(name = "PERSONID") - long getPersonid(); - - @Column(name = "LASTNAME") - String getLastname(); - - @Column(name = "FIRSTNAME") - String getFirstname(); - - @Persistent(defaultFetchGroup = "false") - @Column(name = "MIDDLENAME", allowsNull = "true") - String getMiddlename(); - - @Persistent(types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSAddress.class) - @Embedded( - nullIndicatorColumn = "COUNTRY", - members = { - @Persistent(name = "addrid", columns = @Column(name = "ADDRID")), - @Persistent(name = "street", columns = @Column(name = "STREET")), - @Persistent(name = "city", columns = @Column(name = "CITY")), - @Persistent(name = "state", columns = @Column(name = "STATE")), - @Persistent(name = "zipcode", columns = @Column(name = "ZIPCODE")), - @Persistent(name = "country", columns = @Column(name = "COUNTRY")) - }) - IAddress getAddress(); - - @Column(name = "BIRTHDATE") - Date getBirthdate(); - - @Persistent(table = "employee_phoneno_type") - @Join(column = "EMPID") - @Key(types = java.lang.String.class, column = "TYPE") - @Value(types = java.lang.String.class, column = "PHONENO") - Map getPhoneNumbers(); - - void setPersonid(long personid); - - void setLastname(String lastname); - - void setFirstname(String firstname); - - void setMiddlename(String middlename); - - void setAddress(IAddress address); - - void setBirthdate(Date birthdate); + @Column(name="PERSONID") + long getPersonid(); + @Column(name="LASTNAME") + String getLastname(); + @Column(name="FIRSTNAME") + String getFirstname(); + @Persistent(defaultFetchGroup="false") + @Column(name="MIDDLENAME", allowsNull="true") + String getMiddlename(); + @Persistent(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSAddress.class) + @Embedded(nullIndicatorColumn="COUNTRY", + members={ + @Persistent(name="addrid", columns=@Column(name="ADDRID")), + @Persistent(name="street", columns=@Column(name="STREET")), + @Persistent(name="city", columns=@Column(name="CITY")), + @Persistent(name="state", columns=@Column(name="STATE")), + @Persistent(name="zipcode", columns=@Column(name="ZIPCODE")), + @Persistent(name="country", columns=@Column(name="COUNTRY")) + }) + IAddress getAddress(); + @Column(name="BIRTHDATE") + Date getBirthdate(); + @Persistent(table="employee_phoneno_type") + @Join(column="EMPID") + @Key(types=java.lang.String.class, column="TYPE") + @Value(types=java.lang.String.class, column="PHONENO") + Map getPhoneNumbers(); + + void setPersonid(long personid); + void setLastname(String lastname); + void setFirstname(String firstname); + void setMiddlename(String middlename); + void setAddress(IAddress address); + void setBirthdate(Date birthdate); + void setPhoneNumbers(Map phoneNumbers); - void setPhoneNumbers(Map phoneNumbers); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSProject.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSProject.java index 6dfbe22ae..41922175b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSProject.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPI/PIDSProject.java @@ -5,74 +5,58 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyAnnotatedPI; +import javax.jdo.annotations.*; + import java.math.BigDecimal; import java.util.Set; -import javax.jdo.annotations.Column; -import javax.jdo.annotations.DatastoreIdentity; -import javax.jdo.annotations.Discriminator; -import javax.jdo.annotations.DiscriminatorStrategy; -import javax.jdo.annotations.Element; -import javax.jdo.annotations.IdGeneratorStrategy; -import javax.jdo.annotations.Inheritance; -import javax.jdo.annotations.InheritanceStrategy; -import javax.jdo.annotations.Join; -import javax.jdo.annotations.PersistenceCapable; -import javax.jdo.annotations.Persistent; + import org.apache.jdo.tck.pc.company.IProject; /** - * This interface represents the persistent state of Project. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Project. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ -@PersistenceCapable(table = "projects") -@Inheritance(strategy = InheritanceStrategy.NEW_TABLE) -@Discriminator(strategy = DiscriminatorStrategy.CLASS_NAME, column = "DISCRIMINATOR") -@DatastoreIdentity(strategy = IdGeneratorStrategy.IDENTITY, column = "DATASTORE_IDENTITY") +@PersistenceCapable(table="projects") +@Inheritance(strategy=InheritanceStrategy.NEW_TABLE) +@Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, + column="DISCRIMINATOR") +@DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, + column="DATASTORE_IDENTITY") public interface PIDSProject extends IProject { - @Column(name = "PROJID") - long getProjid(); - - @Column(name = "NAME") - String getName(); - - @Column(name = "BUDGET", jdbcType = "DECIMAL", length = 11, scale = 2) - BigDecimal getBudget(); - - @Persistent(table = "project_reviewer") - @Element( - types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class, - column = "REVIEWER", - foreignKey = "PR_REV_FK") - @Join(column = "PROJID", foreignKey = "PR_PROJ_FK") - Set getReviewers(); - - @Persistent(table = "project_member") - @Element( - types = org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class, - column = "MEMBER", - foreignKey = "PM_MEMB_FK") - @Join(column = "PROJID", foreignKey = "PM_PROJ_FK") - Set getMembers(); - - void setProjid(long projid); - - void setName(String name); - - void setBudget(BigDecimal budget); - - void setReviewers(Set reviewers); - - void setMembers(Set employees); + @Column(name="PROJID") + long getProjid(); + @Column(name="NAME") + String getName(); + @Column(name="BUDGET", jdbcType="DECIMAL", length=11, scale=2) + BigDecimal getBudget(); + @Persistent(table="project_reviewer") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class, + column="REVIEWER", foreignKey="PR_REV_FK") + @Join(column="PROJID", foreignKey="PR_PROJ_FK") + Set getReviewers(); + @Persistent(table="project_member") + @Element(types=org.apache.jdo.tck.pc.companyAnnotatedPI.PIDSEmployee.class, + column="MEMBER", foreignKey="PM_MEMB_FK") + @Join(column="PROJID", foreignKey="PM_PROJ_FK") + Set getMembers(); + + void setProjid(long projid); + void setName(String name); + void setBudget(BigDecimal budget); + void setReviewers(Set reviewers); + void setMembers(Set employees); + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/Company.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/Company.java index ae03a256b..acb0bb06d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/Company.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/Company.java @@ -5,330 +5,334 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyListWithoutJoin; -import java.io.IOException; -import java.io.ObjectInputStream; import java.io.Serializable; +import java.io.ObjectInputStream; +import java.io.IOException; + import java.text.SimpleDateFormat; + import java.util.Collections; import java.util.Comparator; -import java.util.Date; -import java.util.HashSet; import java.util.Set; +import java.util.HashSet; +import java.util.Date; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents information about a company. */ -public class Company implements ICompany, Serializable, Comparable, Comparator, DeepEquality { - - private long companyid; - private String name; - private Date founded; - private transient Set departments = new HashSet(); // element type is Department - - protected static SimpleDateFormat formatter = new SimpleDateFormat("d/MMM/yyyy"); - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public Company() {} - - /** - * Initialize the Company instance. - * - * @param companyid The company id. - * @param name The company name. - * @param founded The date the company was founded. - */ - public Company(long companyid, String name, Date founded) { - this.companyid = companyid; - this.name = name; - this.founded = founded; - } - - /** - * Get the company id. - * - * @return The company id. - */ - public long getCompanyid() { - return companyid; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setCompanyid(long id) { - if (this.companyid != 0) throw new IllegalStateException("Id is already set."); - this.companyid = id; - } - - /** - * Get the name of the company. - * - * @return The name of the company. - */ - public String getName() { - return name; - } - - /** - * Set the name of the company. - * - * @param name The value to use for the name of the company. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Get the date that the company was founded. - * - * @return The date the company was founded. - */ - public Date getFounded() { - return founded; - } - - /** - * Set the date that the company was founded. - * - * @param founded The date to set that the company was founded. - */ - public void setFounded(Date founded) { - this.founded = founded; - } - - /** - * Get the departments contained in the company. - * - * @return An unmodifiable Set that contains all the Departments of the - * company. - */ - public Set getDepartments() { - return Collections.unmodifiableSet(departments); - } - - /** - * Add a Department instance to the company. - * - * @param dept The Department instance to add. - */ - public void addDepartment(Department dept) { - departments.add(dept); - } - - /** - * Remove a Department instance from the company. - * - * @param dept The Department instance to remove. - */ - public void removeDepartment(Department dept) { - departments.remove(dept); - } - - /** - * Initialize the set of Departments in the company to the parameter. - * - * @param departments The set of Departments for the company. - */ - public void setDepartments(Set departments) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.departments = (departments != null) ? new HashSet(departments) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - departments = new HashSet(); - } - - /** - * Returns a String representation of a Company object. - * - * @return a String representation of a Company object. - */ - public String toString() { - return "Company(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(companyid); - rc.append(", name ").append(name); - rc.append(", founded ").append(founded == null ? "null" : formatter.format(founded)); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - ICompany otherCompany = (ICompany) other; - String where = "Company<" + companyid + ">"; - return helper.equals(companyid, otherCompany.getCompanyid(), where + ".companyid") - & helper.equals(name, otherCompany.getName(), where + ".name") - & helper.equals(founded, otherCompany.getFounded(), where + ".founded") - & helper.deepEquals(departments, otherCompany.getDepartments(), where + ".departments"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((ICompany) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((ICompany) o1, (ICompany) o2); - } - - /** - * Compares this object with the specified Company object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Company object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Company object. - */ - public int compareTo(ICompany other) { - return compare(this, other); - } - - /** - * Compares its two ICompany arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first ICompany object to be compared. - * @param o2 the second ICompany object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(ICompany o1, ICompany o2) { - return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof ICompany) { - return compareTo((ICompany) obj) == 0; +/** + * This class represents information about a company. + */ +public class Company + implements ICompany, Serializable, Comparable, Comparator, DeepEquality { + + private long companyid; + private String name; + private Date founded; + private transient Set departments = new HashSet(); // element type is Department + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public Company() {} + + /** + * Initialize the Company instance. + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + */ + public Company(long companyid, String name, Date founded) { + this.companyid = companyid; + this.name = name; + this.founded = founded; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) companyid; - } - - /** - * The class to be used as the application identifier for the Company class. It - * consists of both the company name and the date that the company was founded. - */ - public static class Oid implements Serializable, Comparable { /** - * This field is part of the identifier and should match in name and type with a field in the - * Company class. + * Get the company id. + * @return The company id. */ - public long companyid; + public long getCompanyid() { + return companyid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setCompanyid(long id) { + if (this.companyid != 0) + throw new IllegalStateException("Id is already set."); + this.companyid = id; + } + + /** + * Get the name of the company. + * @return The name of the company. + */ + public String getName() { + return name; + } - /** The required public no-arg constructor. */ - public Oid() {} + /** + * Set the name of the company. + * @param name The value to use for the name of the company. + */ + public void setName(String name) { + this.name = name; + } /** - * Initialize the identifier. - * - * @param companyid The id of the company. + * Get the date that the company was founded. + * @return The date the company was founded. */ - public Oid(long companyid) { - this.companyid = companyid; + public Date getFounded() { + return founded; } - public Oid(String s) { - companyid = Long.parseLong(justTheId(s)); + /** + * Set the date that the company was founded. + * @param founded The date to set that the company was founded. + */ + public void setFounded(Date founded) { + this.founded = founded; + } + + /** + * Get the departments contained in the company. + * @return An unmodifiable Set that contains all the + * Departments of the company. + */ + public Set getDepartments() { + return Collections.unmodifiableSet(departments); + } + + /** + * Add a Department instance to the company. + * @param dept The Department instance to add. + */ + public void addDepartment(Department dept) { + departments.add(dept); } + /** + * Remove a Department instance from the company. + * @param dept The Department instance to remove. + */ + public void removeDepartment(Department dept) { + departments.remove(dept); + } + + /** + * Initialize the set of Departments in the company to the + * parameter. + * @param departments The set of Departments for the + * company. + */ + public void setDepartments(Set departments) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.departments = + (departments != null) ? new HashSet(departments) : null; + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + departments = new HashSet(); + } + + /** + * Returns a String representation of a Company object. + * @return a String representation of a Company object. + */ public String toString() { - return this.getClass().getName() + ": " + companyid; + return "Company(" + getFieldRepr()+ ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(companyid); + rc.append(", name ").append(name); + rc.append(", founded ").append( + founded==null ? "null" : formatter.format(founded)); + return rc.toString(); } - /** */ - public boolean equals(Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return false; - Oid o = (Oid) obj; - if (this.companyid != o.companyid) return false; - return true; + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + ICompany otherCompany = (ICompany)other; + String where = "Company<" + companyid + ">"; + return + helper.equals(companyid, otherCompany.getCompanyid(), where + ".companyid") & + helper.equals(name, otherCompany.getName(), where + ".name") & + helper.equals(founded, otherCompany.getFounded(), where + ".founded") & + helper.deepEquals(departments, otherCompany.getDepartments(), where + ".departments"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((ICompany)o); } - /** */ - public int hashCode() { - return (int) companyid; + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((ICompany)o1, (ICompany)o2); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compares this object with the specified Company object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Company object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Company + * object. + */ + public int compareTo(ICompany other) { + return compare(this, other); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (companyid < other.companyid) return -1; - if (companyid > other.companyid) return 1; - return 0; + /** + * Compares its two ICompany arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first ICompany object to be compared. + * @param o2 the second ICompany object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(ICompany o1, ICompany o2) { + return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof ICompany) { + return compareTo((ICompany)obj) == 0; + } + return false; } - } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)companyid; + } + + /** + * The class to be used as the application identifier + * for the Company class. It consists of both the company + * name and the date that the company was founded. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field is part of the identifier and should match in name + * and type with a field in the Company class. + */ + public long companyid; + + /** The required public no-arg constructor. */ + public Oid() { } + + /** + * Initialize the identifier. + * @param companyid The id of the company. + */ + public Oid(long companyid) { + this.companyid = companyid; + } + + public Oid(String s) { companyid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + companyid;} + + + /** */ + public boolean equals(Object obj) { + if (obj==null || !this.getClass().equals(obj.getClass())) + return false; + Oid o = (Oid) obj; + if (this.companyid != o.companyid) + return false; + return true; + } + + /** */ + public int hashCode() { + return (int)companyid; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( companyid < other.companyid ) return -1; + if( companyid > other.companyid ) return 1; + return 0; + } + + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactory.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactory.java index f60261255..46017a59e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactory.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactory.java @@ -5,16 +5,16 @@ * 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 - * + * * https://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 + * + * 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. */ - + /* * CompanyFactory.java * @@ -22,24 +22,25 @@ package org.apache.jdo.tck.pc.companyListWithoutJoin; +import java.math.BigDecimal; + import java.util.Date; /** - * This interface is implemented by a factory class that can create Company model instances. The - * factory instance is registered with CompanyFactoryRegistry. + * This interface is implemented by a factory class that can create + * Company model instances. The factory instance is registered with + * CompanyFactoryRegistry. */ public interface CompanyFactory { - ICompany newCompany(long companyid, String name, Date founded); - - IDepartment newDepartment(long deptid, String name); - - IDepartment newDepartment(long deptid, String name, ICompany company); - - IFullTimeEmployee newFullTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double sal); - - IPartTimeEmployee newPartTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double wage); - - Class[] getTearDownClasses(); + ICompany newCompany(long companyid, String name, Date founded); + IDepartment newDepartment(long deptid, String name); + IDepartment newDepartment(long deptid, + String name, ICompany company); + IFullTimeEmployee newFullTimeEmployee(long personid, + String first, String last, String middle, + Date born, Date hired, double sal); + IPartTimeEmployee newPartTimeEmployee(long personid, + String first, String last, String middle, + Date born, Date hired, double wage); + Class[] getTearDownClasses(); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactoryAbstractImpl.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactoryAbstractImpl.java index 5ca32625a..d9b8bd096 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactoryAbstractImpl.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactoryAbstractImpl.java @@ -18,6 +18,7 @@ package org.apache.jdo.tck.pc.companyListWithoutJoin; import javax.jdo.PersistenceManager; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -28,95 +29,85 @@ * classes that implement only the methods to construct the instance. */ public abstract class CompanyFactoryAbstractImpl implements CompanyFactory { + + protected PersistenceManager pm; + + /** Logger */ + protected Log logger = + LogFactory.getFactory().getInstance("org.apache.jdo.tck"); + + /** true if debug logging is enabled. */ + protected boolean debug = logger.isDebugEnabled(); + + /** + * Creates a new instance of CompanyFactoryAbstractImpl + * @param pm the PersistenceManager + */ + public CompanyFactoryAbstractImpl(PersistenceManager pm) { + this.pm = pm; + } + + abstract ICompany newCompany(); + abstract IDepartment newDepartment(); + abstract IFullTimeEmployee newFullTimeEmployee(); + abstract IPartTimeEmployee newPartTimeEmployee(); + + public ICompany newCompany(long companyid, String name, + java.util.Date founded) { + ICompany result = newCompany(); + result.setCompanyid(companyid); + result.setName(name); + result.setFounded(founded); + if (debug) logger.debug("newCompany returned" + result); + return result; + } + + public IDepartment newDepartment(long deptid, String name) { + IDepartment result = newDepartment(); + result.setDeptid(deptid); + result.setName(name); + if (debug) logger.debug("newDepartment returned" + result); + return result; + } + + + public IDepartment newDepartment(long deptid, String name, ICompany company) { + IDepartment result = newDepartment(); + result.setDeptid(deptid); + result.setName(name); + result.setCompany(company); + if (debug) logger.debug("newDepartment returned" + result); + return result; + } + + public IFullTimeEmployee newFullTimeEmployee(long personid, String first, + String last, String middle, java.util.Date born, + java.util.Date hired, double sal) { + IFullTimeEmployee result = newFullTimeEmployee(); + result.setPersonid(personid); + result.setFirstname(first); + result.setLastname(last); + result.setMiddlename(middle); + result.setBirthdate(born); + result.setHiredate(hired); + result.setSalary(sal); + if (debug) logger.debug("newFullTimeEmployee returned" + result); + return result; + } + + public IPartTimeEmployee newPartTimeEmployee(long personid, String first, + String last, String middle, java.util.Date born, + java.util.Date hired, double wage) { + IPartTimeEmployee result = newPartTimeEmployee(); + result.setPersonid(personid); + result.setFirstname(first); + result.setLastname(last); + result.setMiddlename(middle); + result.setBirthdate(born); + result.setHiredate(hired); + result.setWage(wage); + if (debug) logger.debug("newPartTimeEmployee returned" + result); + return result; + } - protected PersistenceManager pm; - - /** Logger */ - protected Log logger = LogFactory.getFactory().getInstance("org.apache.jdo.tck"); - - /** true if debug logging is enabled. */ - protected boolean debug = logger.isDebugEnabled(); - - /** - * Creates a new instance of CompanyFactoryAbstractImpl - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAbstractImpl(PersistenceManager pm) { - this.pm = pm; - } - - abstract ICompany newCompany(); - - abstract IDepartment newDepartment(); - - abstract IFullTimeEmployee newFullTimeEmployee(); - - abstract IPartTimeEmployee newPartTimeEmployee(); - - public ICompany newCompany(long companyid, String name, java.util.Date founded) { - ICompany result = newCompany(); - result.setCompanyid(companyid); - result.setName(name); - result.setFounded(founded); - if (debug) logger.debug("newCompany returned" + result); - return result; - } - - public IDepartment newDepartment(long deptid, String name) { - IDepartment result = newDepartment(); - result.setDeptid(deptid); - result.setName(name); - if (debug) logger.debug("newDepartment returned" + result); - return result; - } - - public IDepartment newDepartment(long deptid, String name, ICompany company) { - IDepartment result = newDepartment(); - result.setDeptid(deptid); - result.setName(name); - result.setCompany(company); - if (debug) logger.debug("newDepartment returned" + result); - return result; - } - - public IFullTimeEmployee newFullTimeEmployee( - long personid, - String first, - String last, - String middle, - java.util.Date born, - java.util.Date hired, - double sal) { - IFullTimeEmployee result = newFullTimeEmployee(); - result.setPersonid(personid); - result.setFirstname(first); - result.setLastname(last); - result.setMiddlename(middle); - result.setBirthdate(born); - result.setHiredate(hired); - result.setSalary(sal); - if (debug) logger.debug("newFullTimeEmployee returned" + result); - return result; - } - - public IPartTimeEmployee newPartTimeEmployee( - long personid, - String first, - String last, - String middle, - java.util.Date born, - java.util.Date hired, - double wage) { - IPartTimeEmployee result = newPartTimeEmployee(); - result.setPersonid(personid); - result.setFirstname(first); - result.setLastname(last); - result.setMiddlename(middle); - result.setBirthdate(born); - result.setHiredate(hired); - result.setWage(wage); - if (debug) logger.debug("newPartTimeEmployee returned" + result); - return result; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactoryConcreteClass.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactoryConcreteClass.java index d648f3baf..fab50afa6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactoryConcreteClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactoryConcreteClass.java @@ -17,59 +17,70 @@ package org.apache.jdo.tck.pc.companyListWithoutJoin; +import java.math.BigDecimal; + import java.util.Date; + import javax.jdo.PersistenceManager; /* * This class is the company factory that uses constructors of the * concrete classes. */ -public class CompanyFactoryConcreteClass implements CompanyFactory { +public class CompanyFactoryConcreteClass implements CompanyFactory { - /** */ - public static final Class[] tearDownClasses = - new Class[] { - PartTimeEmployee.class, FullTimeEmployee.class, + /** */ + public static final Class[] tearDownClasses = new Class[] { + PartTimeEmployee.class, FullTimeEmployee.class, Department.class, Company.class - }; + }; - /** - * Creates a new instance of CompanyFactoryConcreteClass - * - * @param pm the PersistenceManager - */ - public CompanyFactoryConcreteClass(PersistenceManager pm) {} + /** + * Creates a new instance of CompanyFactoryConcreteClass + * @param pm the PersistenceManager + */ + public CompanyFactoryConcreteClass(PersistenceManager pm) { + } - public CompanyFactoryConcreteClass() {} + public CompanyFactoryConcreteClass() { + } - public ICompany newCompany(long companyid, String name, Date founded) { - return new Company(companyid, name, founded); - } + public ICompany newCompany(long companyid, + String name, Date founded) { + return new Company(companyid, name, founded); + } - public IDepartment newDepartment(long deptid, String name) { - return new Department(deptid, name); - } + public IDepartment newDepartment(long deptid, String name) { + return new Department(deptid, name); + } - public IDepartment newDepartment(long deptid, String name, ICompany company) { - return new Department(deptid, name, company); - } + public IDepartment newDepartment(long deptid, + String name, ICompany company) { + return new Department(deptid, name, company); + } - public IFullTimeEmployee newFullTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double sal) { - return new FullTimeEmployee(personid, first, last, middle, born, hired, sal); - } + public IFullTimeEmployee newFullTimeEmployee(long personid, + String first, String last, String middle, + Date born, Date hired, double sal) { + return new FullTimeEmployee(personid, first, last, middle, + born, hired, sal); + } - public IPartTimeEmployee newPartTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double wage) { - return new PartTimeEmployee(personid, first, last, middle, born, hired, wage); - } + public IPartTimeEmployee newPartTimeEmployee(long personid, + String first, String last, String middle, + Date born, Date hired, double wage) { + return new PartTimeEmployee(personid, first, last, middle, + born, hired, wage); + } - public IPerson newPerson( - long personid, String firstname, String lastname, String middlename, Date birthdate) { - return new Person(personid, firstname, lastname, middlename, birthdate); - } + public IPerson newPerson(long personid, + String firstname, String lastname, String middlename, + Date birthdate) { + return new Person(personid, firstname, lastname, middlename, + birthdate); + } - public Class[] getTearDownClasses() { - return tearDownClasses; - } + public Class[] getTearDownClasses() { + return tearDownClasses; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactoryPMClass.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactoryPMClass.java index 7296fa56d..7c15e1e49 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactoryPMClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactoryPMClass.java @@ -23,43 +23,42 @@ * CompanyFactoryPMClass.java * * This class uses the PersistenceManager.newInstance method with the concrete - * class as a parameter. + * class as a parameter. */ -public class CompanyFactoryPMClass extends CompanyFactoryAbstractImpl { - - /** */ - public static final Class[] tearDownClasses = - new Class[] { - PartTimeEmployee.class, FullTimeEmployee.class, +public class CompanyFactoryPMClass + extends CompanyFactoryAbstractImpl { + + /** */ + public static final Class[] tearDownClasses = new Class[] { + PartTimeEmployee.class, FullTimeEmployee.class, Department.class, Company.class - }; - - /** - * Creates a new instance of CompanyFactoryPMClass - * - * @param pm the PersistenceManager - */ - public CompanyFactoryPMClass(PersistenceManager pm) { - super(pm); - } - - ICompany newCompany() { - return (ICompany) pm.newInstance(Company.class); - } - - IDepartment newDepartment() { - return (IDepartment) pm.newInstance(Department.class); - } - - IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) pm.newInstance(FullTimeEmployee.class); - } - - IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) pm.newInstance(PartTimeEmployee.class); - } + }; - public Class[] getTearDownClasses() { - return tearDownClasses; - } + /** + * Creates a new instance of CompanyFactoryPMClass + * @param pm the PersistenceManager + */ + public CompanyFactoryPMClass(PersistenceManager pm) { + super(pm); + } + + ICompany newCompany() { + return (ICompany)pm.newInstance(Company.class); + } + + IDepartment newDepartment() { + return (IDepartment)pm.newInstance(Department.class); + } + + IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee)pm.newInstance(FullTimeEmployee.class); + } + + IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee)pm.newInstance(PartTimeEmployee.class); + } + + public Class[] getTearDownClasses() { + return tearDownClasses; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactoryPMInterface.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactoryPMInterface.java index 39d81bd8f..e2742edd9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactoryPMInterface.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactoryPMInterface.java @@ -25,41 +25,40 @@ * Created on August 29, 2005, 9:56 PM * */ -public class CompanyFactoryPMInterface extends CompanyFactoryAbstractImpl { - - /** */ - public static final Class[] tearDownClasses = - new Class[] { - IPartTimeEmployee.class, IFullTimeEmployee.class, +public class CompanyFactoryPMInterface + extends CompanyFactoryAbstractImpl { + + /** */ + public static final Class[] tearDownClasses = new Class[] { + IPartTimeEmployee.class, IFullTimeEmployee.class, IDepartment.class, ICompany.class - }; - - /** - * Creates a new instance of CompanyFactoryPMInterface - * - * @param pm the PersistenceManager - */ - public CompanyFactoryPMInterface(PersistenceManager pm) { - super(pm); - } - - ICompany newCompany() { - return (ICompany) pm.newInstance(ICompany.class); - } - - IDepartment newDepartment() { - return (IDepartment) pm.newInstance(IDepartment.class); - } - - IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) pm.newInstance(IFullTimeEmployee.class); - } - - IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) pm.newInstance(IPartTimeEmployee.class); - } + }; - public Class[] getTearDownClasses() { - return tearDownClasses; - } + /** + * Creates a new instance of CompanyFactoryPMInterface + * @param pm the PersistenceManager + */ + public CompanyFactoryPMInterface(PersistenceManager pm) { + super(pm); + } + + ICompany newCompany() { + return (ICompany)pm.newInstance(ICompany.class); + } + + IDepartment newDepartment() { + return (IDepartment)pm.newInstance(IDepartment.class); + } + + IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee)pm.newInstance(IFullTimeEmployee.class); + } + + IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee)pm.newInstance(IPartTimeEmployee.class); + } + + public Class[] getTearDownClasses() { + return tearDownClasses; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactoryRegistry.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactoryRegistry.java index 2e63e977d..61398725d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactoryRegistry.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyFactoryRegistry.java @@ -5,25 +5,30 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyListWithoutJoin; import java.lang.reflect.Constructor; + +import java.math.BigDecimal; + +import java.util.Date; + import javax.jdo.PersistenceManager; /* * This is the registry for company factories. It is used for the * CompletenessTest to create instances from input xml test data files. - * Factory instances that implement CompanyFactory interface are + * Factory instances that implement CompanyFactory interface are * registered (using the singleton pattern). *

    Several registration methods are available. The default factory, * which creates instances by construction, is automatically @@ -37,87 +42,99 @@ */ public class CompanyFactoryRegistry { - /** The system property for factory name */ - static final String FACTORY_PROPERTY_NAME = "jdo.tck.mapping.companyfactory"; - - /** The factory name if the system property is not set. */ - static final String DEFAULT_FACTORY_CLASS_NAME = - "org.apache.jdo.tck.pc.company.CompanyFactoryConcreteClass"; - - /** The default factory class name */ - static final String FACTORY_CLASS_NAME; - - static { - String prop = System.getProperty(FACTORY_PROPERTY_NAME); - if ((prop == null) || (prop.length() == 0)) prop = DEFAULT_FACTORY_CLASS_NAME; - FACTORY_CLASS_NAME = prop; - } - - /** - * This is the default company factory singleton. This is statically loaded regardless of the - * setting of the system property. - */ - static final CompanyFactory SINGLETON = new CompanyFactoryConcreteClass(); - - /** This is the currently registered factory. */ - static CompanyFactory instance = SINGLETON; - - /** Creates a new instance of CompanyFactoryRegistry */ - private CompanyFactoryRegistry() {} - - /** - * Get the currently registered factory. - * - * @return the factory - */ - public static CompanyFactory getInstance() { - return instance; - } - - /** Register the default factory. */ - public static void registerFactory() { - instance = SINGLETON; - } - - /** - * Register a factory using the default factory name from the system property. The factory must be - * available in the current class path and have a public constructor taking a PersistenceManager - * as a parameter. - * - * @param pm the PersistenceManager - */ - public static void registerFactory(PersistenceManager pm) { - registerFactory(FACTORY_CLASS_NAME, pm); - } - - /** - * Register a factory using the specified factoryName parameter. The factory class must be - * loadable by the current context classloader and have a public constructor taking a - * PersistenceManager as a parameter. - * - * @param factoryClassName the fully-qualified class name of the factory - * @param pm the PersistenceManager - */ - public static void registerFactory(String factoryClassName, PersistenceManager pm) { - CompanyFactory factory = null; - try { - if (factoryClassName != null) { - Class factoryClass = Class.forName(factoryClassName); - Constructor ctor = factoryClass.getConstructor(new Class[] {PersistenceManager.class}); - factory = (CompanyFactory) ctor.newInstance(new Object[] {pm}); - } - registerFactory(factory); - } catch (Exception ex) { - throw new RuntimeException("Unable to construct CompanyFactory " + factoryClassName, ex); + /** The system property for factory name + */ + final static String FACTORY_PROPERTY_NAME = + "jdo.tck.mapping.companyfactory"; + + /** The factory name if the system property is not set. + */ + final static String DEFAULT_FACTORY_CLASS_NAME = + "org.apache.jdo.tck.pc.company.CompanyFactoryConcreteClass"; + + /** + * The default factory class name + */ + final static String FACTORY_CLASS_NAME; + + static { + String prop = System.getProperty(FACTORY_PROPERTY_NAME); + if ((prop == null) || (prop.length() == 0)) + prop = DEFAULT_FACTORY_CLASS_NAME; + FACTORY_CLASS_NAME = prop; + } + + /** + * This is the default company factory singleton. This is statically + * loaded regardless of the setting of the system property. + */ + final static CompanyFactory SINGLETON = new CompanyFactoryConcreteClass(); + + /** + * This is the currently registered factory. + */ + static CompanyFactory instance = SINGLETON; + + /** + * Creates a new instance of CompanyFactoryRegistry + */ + private CompanyFactoryRegistry() { + } + + /** + * Get the currently registered factory. + * @return the factory + */ + public static CompanyFactory getInstance() { + return instance; + } + + /** Register the default factory. + */ + public static void registerFactory() { + instance = SINGLETON; + } + + /** Register a factory using the default factory name from the + * system property. The factory must be available in the current + * class path and have a public constructor + * taking a PersistenceManager as a parameter. + * @param pm the PersistenceManager + */ + public static void registerFactory(PersistenceManager pm) { + registerFactory(FACTORY_CLASS_NAME, pm); } - } - - /** - * Register the factory. - * - * @param factory the factory - */ - public static void registerFactory(CompanyFactory factory) { - instance = factory != null ? factory : SINGLETON; - } + + /** Register a factory using the specified factoryName + * parameter. The factory class must be loadable by the current context + * classloader and have a public constructor + * taking a PersistenceManager as a parameter. + * @param factoryClassName the fully-qualified class name of the factory + * @param pm the PersistenceManager + */ + public static void registerFactory(String factoryClassName, + PersistenceManager pm) { + CompanyFactory factory = null; + try { + if (factoryClassName != null) { + Class factoryClass = Class.forName(factoryClassName); + Constructor ctor = factoryClass.getConstructor(new Class[] + {PersistenceManager.class}); + factory = (CompanyFactory) + ctor.newInstance(new Object[]{pm}); + } + registerFactory(factory); + } catch (Exception ex) { + throw new RuntimeException ("Unable to construct CompanyFactory " + + factoryClassName, ex); + } + } + + /** Register the factory. + * @param factory the factory + */ + public static void registerFactory(CompanyFactory factory) { + instance = factory!=null?factory:SINGLETON; + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyModelReader.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyModelReader.java index 68236c896..73c99399c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyModelReader.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/CompanyModelReader.java @@ -5,21 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyListWithoutJoin; import java.util.Date; import java.util.List; import java.util.Locale; + import org.apache.jdo.tck.util.ConversionHelper; import org.apache.jdo.tck.util.JDOCustomDateEditor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -27,150 +28,157 @@ import org.springframework.core.io.ClassPathResource; /** - * Utility class to create a graph of company model instances from an xml representation. + * Utility class to create a graph of company model instances from an xml + * representation. * * @author Michael Bouschen */ public class CompanyModelReader extends DefaultListableBeanFactory { - /** The name of the root list bean. */ - public static final String ROOT_LIST_NAME = "root"; - - /** The bean-factory name in the xml input files. */ - public static final String BEAN_FACTORY_NAME = "companyFactory"; - - /** The company factory instance. */ - private CompanyFactory companyFactory; - - /** Bean definition reader */ - private final XmlBeanDefinitionReader reader; - - /** - * Create a CompanyModelReader for the specified resourceName. - * - * @param resourceName the name of the resource - */ - public CompanyModelReader(String resourceName) { - // Use the class loader of the Company class to find the resource - this(resourceName, Company.class.getClassLoader()); - } - - /** - * Create a CompanyModelReader for the specified resourceName. - * - * @param resourceName the name of the resource - * @param classLoader the ClassLoader for the lookup - */ - public CompanyModelReader(String resourceName, ClassLoader classLoader) { - super(); - configureFactory(); - this.reader = new XmlBeanDefinitionReader(this); - this.reader.loadBeanDefinitions(new ClassPathResource(resourceName, classLoader)); - } - - /** - * Returns a list of root objects. The method expects to find a bean called "root" of type list in - * the xml and returns it. - * - * @return a list of root instances - */ - public List getRootList() { - return (List) getBean(ROOT_LIST_NAME); - } - - /** - * Configure the CompanyModelReader, e.g. register CustomEditor classes to convert the string - * representation of a property into an instance of the right type. - */ - private void configureFactory() { - registerCustomEditor(Date.class, JDOCustomDateEditor.class); - companyFactory = CompanyFactoryRegistry.getInstance(); - addSingleton(BEAN_FACTORY_NAME, companyFactory); - } - - // Convenience methods - - /** - * Convenience method returning a Company instance for the specified name. The method returns - * null if there is no Company bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no Company bean. - */ - public Company getCompany(String name) { - return (Company) getBean(name, Company.class); - } - - /** - * Convenience method returning a Department instance for the specified name. The method returns - * null if there is no Department bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no Department bean. - */ - public Department getDepartment(String name) { - return (Department) getBean(name, Department.class); - } - - /** - * Convenience method returning an Employee instance for the specified name. The method returns - * null if there is no Employee bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no Employee bean. - */ - public Employee getEmployee(String name) { - return (Employee) getBean(name, Employee.class); - } - - /** - * Convenience method returning a FullTimeEmployee instance for the specified name. The method - * returns null if there is no FullTimeEmployee bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no FullTimeEmployee bean. - */ - public FullTimeEmployee getFullTimeEmployee(String name) { - return (FullTimeEmployee) getBean(name, FullTimeEmployee.class); - } - - /** - * Convenience method returning a PartTimeEmployee instance for the specified name. The method - * returns null if there is no PartTimeEmployee bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no PartTimeEmployee bean. - */ - public PartTimeEmployee getPartTimeEmployee(String name) { - return (PartTimeEmployee) getBean(name, PartTimeEmployee.class); - } - - /** - * Convenience method returning a Person instance for the specified name. The method returns - * null if there is no Person bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no Person bean. - */ - public Person getPerson(String name) { - return (Person) getBean(name, Person.class); - } - - /** - * @return Returns the tearDownClasses. - */ - public Class[] getTearDownClassesFromFactory() { - return companyFactory.getTearDownClasses(); - } - - /** - * @return Returns the tearDownClasses. - */ - public static Class[] getTearDownClasses() { - return CompanyFactoryConcreteClass.tearDownClasses; - } - - public static Date stringToUtilDate(String value) { - return ConversionHelper.toUtilDate(JDOCustomDateEditor.DATE_PATTERN, Locale.US, value); - } + /** The name of the root list bean. */ + public static final String ROOT_LIST_NAME = "root"; + + /** The bean-factory name in the xml input files. + */ + public static final String BEAN_FACTORY_NAME = "companyFactory"; + + /** The company factory instance. */ + private CompanyFactory companyFactory; + + /** Bean definition reader */ + private final XmlBeanDefinitionReader reader; + + /** + * Create a CompanyModelReader for the specified resourceName. + * @param resourceName the name of the resource + */ + public CompanyModelReader(String resourceName) { + // Use the class loader of the Company class to find the resource + this(resourceName, Company.class.getClassLoader()); + } + + /** + * Create a CompanyModelReader for the specified resourceName. + * @param resourceName the name of the resource + * @param classLoader the ClassLoader for the lookup + */ + public CompanyModelReader(String resourceName, ClassLoader classLoader) { + super(); + configureFactory(); + this.reader = new XmlBeanDefinitionReader(this); + this.reader.loadBeanDefinitions(new ClassPathResource(resourceName, classLoader)); + } + + /** + * Returns a list of root objects. The method expects to find a bean + * called "root" of type list in the xml and returns it. + * @return a list of root instances + */ + public List getRootList() { + return (List)getBean(ROOT_LIST_NAME); + } + + /** + * Configure the CompanyModelReader, e.g. register CustomEditor classes + * to convert the string representation of a property into an instance + * of the right type. + */ + private void configureFactory() { + registerCustomEditor(Date.class, JDOCustomDateEditor.class); + companyFactory = CompanyFactoryRegistry.getInstance(); + addSingleton(BEAN_FACTORY_NAME, companyFactory); + } + + // Convenience methods + + /** + * Convenience method returning a Company instance for the specified + * name. The method returns null if there is no Company + * bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * Company bean. + */ + public Company getCompany(String name) { + return (Company)getBean(name, Company.class); + } + + /** + * Convenience method returning a Department instance for the specified + * name. The method returns null if there is no Department + * bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * Department bean. + */ + public Department getDepartment(String name) { + return (Department)getBean(name, Department.class); + } + + /** + * Convenience method returning an Employee instance for the specified + * name. The method returns null if there is no Employee + * bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * Employee bean. + */ + public Employee getEmployee(String name) { + return (Employee)getBean(name, Employee.class); + } + + /** + * Convenience method returning a FullTimeEmployee instance for the + * specified name. The method returns null if there is no + * FullTimeEmployee bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * FullTimeEmployee bean. + */ + public FullTimeEmployee getFullTimeEmployee(String name) { + return (FullTimeEmployee)getBean(name, FullTimeEmployee.class); + } + + /** + * Convenience method returning a PartTimeEmployee instance for the + * specified name. The method returns null if there is no + * PartTimeEmployee bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * PartTimeEmployee bean. + */ + public PartTimeEmployee getPartTimeEmployee(String name) { + return (PartTimeEmployee)getBean(name, PartTimeEmployee.class); + } + + /** + * Convenience method returning a Person instance for the specified + * name. The method returns null if there is no Person + * bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * Person bean. + */ + public Person getPerson(String name) { + return (Person)getBean(name, Person.class); + } + + /** + * @return Returns the tearDownClasses. + */ + public Class[] getTearDownClassesFromFactory() { + return companyFactory.getTearDownClasses(); + } + + /** + * @return Returns the tearDownClasses. + */ + public static Class[] getTearDownClasses() { + return CompanyFactoryConcreteClass.tearDownClasses; + } + + public static Date stringToUtilDate(String value) { + return ConversionHelper.toUtilDate(JDOCustomDateEditor.DATE_PATTERN, Locale.US, value); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/Department.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/Department.java index 73d24d3b6..c11747bc8 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/Department.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/Department.java @@ -5,331 +5,338 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyListWithoutJoin; import java.io.Serializable; +import java.io.ObjectInputStream; +import java.io.IOException; + +import java.util.Collections; import java.util.Comparator; import java.util.List; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a department within a company. */ -public class Department implements IDepartment, Serializable, Comparable, Comparator, DeepEquality { - - public static final int RECOMMENDED_NO_OF_EMPS = 2; - - private long deptid; - private String name; - private Company company; - private List employees; - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public Department() {} - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - */ - public Department(long deptid, String name) { - this.deptid = deptid; - this.name = name; - } - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - * @param company The company that the department is associated with. - */ - public Department(long deptid, String name, ICompany company) { - this.deptid = deptid; - this.name = name; - this.company = (Company) company; - } - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - * @param company The company that the department is associated with. - * @param employees List of employees - */ - public Department(long deptid, String name, Company company, List employees) { - this.deptid = deptid; - this.name = name; - this.company = (Company) company; - this.employees = employees; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setDeptid(long id) { - if (this.deptid != 0) throw new IllegalStateException("Id is already set."); - this.deptid = id; - } - - /** - * Get the department id. - * - * @return The department id. - */ - public long getDeptid() { - return deptid; - } - - /** - * Get the name of the department. - * - * @return The name of the department. - */ - public String getName() { - return name; - } - - /** - * Set the name of the department. - * - * @param name The name to set for the department. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Get the company associated with the department. - * - * @return The company. - */ - public ICompany getCompany() { - return company; - } - - /** - * Set the company for the department. - * - * @param company The company to associate with the department. - */ - public void setCompany(ICompany company) { - this.company = (Company) company; - } - - /** - * Get the employees in the department as an unmodifiable set. ****************** FIX?? - * - * @return The set of employees in the department, as an unmodifiable set. - */ - public List getEmployees() { - return employees; - } - - /** - * Add an employee to the department. - * - * @param emp The employee to add to the department. - */ - public void addEmployee(Employee emp) { - employees.add(emp); - } - - /** - * Remove an employee from the department. - * - * @param index The index of the employee to remove from the department. - */ - public void removeEmployee(int index) { - employees.remove(index); - } - - /** - * Set the employees to be in this department. - * - * @param employees The employees for this department. - */ - public void setEmployees(List employees) { - this.employees = employees; - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Department. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IDepartment otherDept = (IDepartment) other; - String where = "Department<" + deptid + ">"; - return helper.equals(deptid, otherDept.getDeptid(), where + ".deptid") - & helper.equals(name, otherDept.getName(), where + ".name") - & helper.deepEquals(employees, otherDept.getEmployees(), where + ".employees") - & helper.deepEquals(company, otherDept.getCompany(), where + ".company"); - } - - /** - * Returns a String representation of a Department object. - * - * @return a String representation of a Department object. - */ - public String toString() { - return "Department(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(deptid); - rc.append(", name ").append(name); - return rc.toString(); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((IDepartment) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((IDepartment) o1, (IDepartment) o2); - } - - /** - * Compares this object with the specified Department object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Department object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Department object. - */ - public int compareTo(IDepartment other) { - return compare(this, other); - } - - /** - * Compares its two IDepartment arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IDepartment object to be compared. - * @param o2 the second IDepartment object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(IDepartment o1, IDepartment o2) { - return EqualityHelper.compare(o1.getDeptid(), o2.getDeptid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof IDepartment) { - return compareTo((IDepartment) obj) == 0; +/** + * This class represents a department within a company. + */ +public class Department + implements IDepartment, Serializable, Comparable, Comparator, DeepEquality { + + public static final int RECOMMENDED_NO_OF_EMPS = 2; + + private long deptid; + private String name; + private Company company; + private List employees; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public Department() {} + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + */ + public Department(long deptid, String name) { + this.deptid = deptid; + this.name = name; + } + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + * @param company The company that the department is associated with. + */ + public Department(long deptid, String name, ICompany company) { + this.deptid = deptid; + this.name = name; + this.company = (Company)company; + } + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + * @param company The company that the department is associated with. + * @param employees List of employees + */ + public Department(long deptid, String name, Company company, + List employees) { + this.deptid = deptid; + this.name = name; + this.company = (Company)company; + this.employees = employees; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setDeptid(long id) { + if (this.deptid != 0) + throw new IllegalStateException("Id is already set."); + this.deptid = id; } - return false; - } - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) deptid; - } + /** + * Get the department id. + * @return The department id. + */ + public long getDeptid() { + return deptid; + } + + /** + * Get the name of the department. + * @return The name of the department. + */ + public String getName() { + return name; + } - /** The application identity class associated with the Department class. */ - public static class Oid implements Serializable, Comparable { + /** + * Set the name of the department. + * @param name The name to set for the department. + */ + public void setName(String name) { + this.name = name; + } /** - * This field represents the application identifier field for the Department class. - * It must match in name and type with the field in the Department class. + * Get the company associated with the department. + * @return The company. */ - public long deptid; + public ICompany getCompany() { + return company; + } - /** The required public, no-arg constructor. */ - public Oid() {} + /** + * Set the company for the department. + * @param company The company to associate with the department. + */ + public void setCompany(ICompany company) { + this.company = (Company)company; + } /** - * A constructor to initialize the identifier field. - * - * @param deptid the deptid of the Department. + * Get the employees in the department as an unmodifiable set. + ******************* FIX?? + * @return The set of employees in the department, as an unmodifiable + * set. */ - public Oid(long deptid) { - this.deptid = deptid; + public List getEmployees() { + return employees; } - public Oid(String s) { - deptid = Long.parseLong(justTheId(s)); + /** + * Add an employee to the department. + * @param emp The employee to add to the department. + */ + public void addEmployee(Employee emp) { + employees.add(emp); } + /** + * Remove an employee from the department. + * @param index The index of the employee to remove from the department. + */ + public void removeEmployee(int index) { + employees.remove(index); + } + + /** + * Set the employees to be in this department. + * @param employees The employees for this department. + */ + public void setEmployees(List employees) { + this.employees = employees; + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Department. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IDepartment otherDept = (IDepartment)other; + String where = "Department<" + deptid + ">"; + return + helper.equals(deptid, otherDept.getDeptid(), where + ".deptid") & + helper.equals(name, otherDept.getName(), where + ".name") & + helper.deepEquals(employees, otherDept.getEmployees(), where + ".employees") & + helper.deepEquals(company, otherDept.getCompany(), where + ".company") ; + } + + /** + * Returns a String representation of a Department object. + * @return a String representation of a Department object. + */ public String toString() { - return this.getClass().getName() + ": " + deptid; + return "Department(" + getFieldRepr()+ ")"; } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.deptid != o.deptid) return (false); - return (true); + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(deptid); + rc.append(", name ").append(name); + return rc.toString(); } - /** */ - public int hashCode() { - return ((int) deptid); + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((IDepartment)o); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((IDepartment)o1, (IDepartment)o2); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (deptid < other.deptid) return -1; - if (deptid > other.deptid) return 1; - return 0; + /** + * Compares this object with the specified Department object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Department object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified + * Department object. + */ + public int compareTo(IDepartment other) { + return compare(this, other); } - } + + /** + * Compares its two IDepartment arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IDepartment object to be compared. + * @param o2 the second IDepartment object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(IDepartment o1, IDepartment o2) { + return EqualityHelper.compare(o1.getDeptid(), o2.getDeptid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof IDepartment) { + return compareTo((IDepartment)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)deptid; + } + + /** + * The application identity class associated with the + * Department class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the application identifier field + * for the Department class. + * It must match in name and type with the field in the + * Department class. + */ + public long deptid; + + /** + * The required public, no-arg constructor. + */ + public Oid() { } + + /** + * A constructor to initialize the identifier field. + * @param deptid the deptid of the Department. + */ + public Oid(long deptid) { + this.deptid = deptid; + } + + public Oid(String s) { deptid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + deptid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.deptid != o.deptid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) deptid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( deptid < other.deptid ) return -1; + if( deptid > other.deptid ) return 1; + return 0; + } + + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/Employee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/Employee.java index 0762db835..800aa78a9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/Employee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/Employee.java @@ -5,354 +5,338 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyListWithoutJoin; -import java.io.IOException; import java.io.ObjectInputStream; +import java.io.IOException; + import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.Set; + +import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents an employee. */ +/** + * This class represents an employee. + */ public abstract class Employee extends Person implements IEmployee { - private Date hiredate; - private double weeklyhours; - private Department department; - private Department fundingDept; - private Employee manager; - private Employee mentor; - private Employee protege; - private Employee hradvisor; - private transient Set team = new HashSet(); // element-type is Employee - private transient Set hradvisees = new HashSet(); // element-type is Employee - - /** This is the JDO-required no-args constructor */ - protected Employee() {} - - /** - * Construct an Employee instance. - * - * @param personid The identifier for the person. - * @param firstname The first name of the employee. - * @param lastname The last name of the employee. - * @param middlename The middle name of the employee. - * @param birthdate The birth date of the employee. - * @param hiredate The date that the employee was hired. - */ - public Employee( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - Date hiredate) { - super(personid, firstname, lastname, middlename, birthdate); - this.hiredate = hiredate; - } - - /** - * Get the date that the employee was hired. - * - * @return The date the employee was hired. - */ - public Date getHiredate() { - return hiredate; - } - - /** - * Set the date that the employee was hired. - * - * @param hiredate The date the employee was hired. - */ - public void setHiredate(Date hiredate) { - this.hiredate = hiredate; - } - - /** - * Get the weekly hours of the employee. - * - * @return The number of hours per week that the employee works. - */ - public double getWeeklyhours() { - return weeklyhours; - } - - /** - * Set the number of hours per week that the employee works. - * - * @param weeklyhours The number of hours per week that the employee works. - */ - public void setWeeklyhours(double weeklyhours) { - this.weeklyhours = weeklyhours; - } - - /** - * Get the employee's department. - * - * @return The department associated with the employee. - */ - public IDepartment getDepartment() { - return department; - } - - /** - * Set the employee's department. - * - * @param department The department. - */ - public void setDepartment(IDepartment department) { - this.department = (Department) department; - } - - /** - * Get the employee's funding department. - * - * @return The funding department associated with the employee. - */ - public IDepartment getFundingDept() { - return fundingDept; - } - - /** - * Set the employee's funding department. - * - * @param department The funding department. - */ - public void setFundingDept(IDepartment department) { - this.fundingDept = (Department) department; - } - - /** - * Get the employee's manager. - * - * @return The employee's manager. - */ - public IEmployee getManager() { - return manager; - } - - /** - * Set the employee's manager. - * - * @param manager The employee's manager. - */ - public void setManager(IEmployee manager) { - this.manager = (Employee) manager; - } - - /** - * Get the employee's team. - * - * @return The set of Employees on this employee's team, returned as an unmodifiable - * set. - */ - public Set getTeam() { - return Collections.unmodifiableSet(team); - } - - /** - * Add an Employee to this employee's team. This method sets both sides of the - * relationship, modifying this employees team to include parameter emp and modifying emp to set - * its manager attribute to this object. - * - * @param emp The Employee to add to the team. - */ - public void addToTeam(Employee emp) { - team.add(emp); - emp.manager = this; - } - - /** - * Remove an Employee from this employee's team. This method will also set the - * emp manager to null. - * - * @param emp The Employee to remove from the team. - */ - public void removeFromTeam(Employee emp) { - team.remove(emp); - emp.manager = null; - } - - /** - * Set the employee's team. - * - * @param team The set of Employees. - */ - public void setTeam(Set team) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.team = (team != null) ? new HashSet(team) : null; - } - - /** - * Set the mentor for this employee. - * - * @param mentor The mentor for this employee. - */ - public void setMentor(IEmployee mentor) { - this.mentor = (Employee) mentor; - } - - /** - * Get the mentor for this employee. - * - * @return The mentor. - */ - public IEmployee getMentor() { - return mentor; - } - - /** - * Set the protege for this employee. - * - * @param protege The protege for this employee. - */ - public void setProtege(IEmployee protege) { - this.protege = (Employee) protege; - } - - /** - * Get the protege of this employee. - * - * @return The protege of this employee. - */ - public IEmployee getProtege() { - return protege; - } - - /** - * Set the HR advisor for this employee. - * - * @param hradvisor The hradvisor for this employee. - */ - public void setHradvisor(IEmployee hradvisor) { - this.hradvisor = (Employee) hradvisor; - } - - /** - * Get the HR advisor for the employee. - * - * @return The HR advisor. - */ - public IEmployee getHradvisor() { - return hradvisor; - } - - /** - * Get the HR advisees of this HR advisor. - * - * @return An unmodifiable Set containing the Employees that are HR - * advisees of this employee. - */ - public Set getHradvisees() { - return Collections.unmodifiableSet(hradvisees); - } - - /** - * Add an Employee as an advisee of this HR advisor. This method also sets the - * emp hradvisor to reference this object. In other words, both sides of the relationship - * are set. - * - * @param emp The employee to add as an advisee. - */ - public void addAdvisee(Employee emp) { - hradvisees.add(emp); - emp.hradvisor = this; - } - - /** - * Remove an Employee as an advisee of this HR advisor. This method also sets the - * emp hradvisor to null. In other words, both sides of the relationship are set. - * - * @param emp The employee to add as an HR advisee. - */ - public void removeAdvisee(Employee emp) { - hradvisees.remove(emp); - emp.hradvisor = null; - } - - /** - * Set the HR advisees of this HR advisor. - * - * @param hradvisees The Employees that are HR advisees of this employee. - */ - public void setHradvisees(Set hradvisees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.hradvisees = (hradvisees != null) ? new HashSet(hradvisees) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - team = new HashSet(); - hradvisees = new HashSet(); - } - - /** - * Return a String representation of a Employee object. - * - * @return a String representation of a Employee object. - */ - public String toString() { - return "Employee(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", hired ").append(hiredate == null ? "null" : formatter.format(hiredate)); - rc.append(", weeklyhours ").append(weeklyhours); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the - * corresponding fields of the specified Employee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IEmployee otherEmp = (IEmployee) other; - String where = "Employee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.equals(hiredate, otherEmp.getHiredate(), where + ".hiredate") - & helper.closeEnough(weeklyhours, otherEmp.getWeeklyhours(), where + ".weeklyhours") - & helper.deepEquals(department, otherEmp.getDepartment(), where + ".department") - & helper.deepEquals(fundingDept, otherEmp.getFundingDept(), where + ".fundingDept") - & helper.deepEquals(manager, otherEmp.getManager(), where + ".manager") - & helper.deepEquals(mentor, otherEmp.getMentor(), where + ".mentor") - & helper.deepEquals(protege, otherEmp.getProtege(), where + ".protege") - & helper.deepEquals(hradvisor, otherEmp.getHradvisor(), where + ".hradvisor") - & helper.deepEquals(team, otherEmp.getTeam(), where + ".team") - & helper.deepEquals(hradvisees, otherEmp.getHradvisees(), where + ".hradvisees"); - } + private Date hiredate; + private double weeklyhours; + private Department department; + private Department fundingDept; + private Employee manager; + private Employee mentor; + private Employee protege; + private Employee hradvisor; + private transient Set team = new HashSet(); // element-type is Employee + private transient Set hradvisees = new HashSet(); // element-type is Employee + + /** This is the JDO-required no-args constructor */ + protected Employee() {} + + /** + * Construct an Employee instance. + * @param personid The identifier for the person. + * @param firstname The first name of the employee. + * @param lastname The last name of the employee. + * @param middlename The middle name of the employee. + * @param birthdate The birth date of the employee. + * @param hiredate The date that the employee was hired. + */ + public Employee(long personid, String firstname, String lastname, + String middlename, Date birthdate, + Date hiredate) { + super(personid, firstname, lastname, middlename, birthdate); + this.hiredate = hiredate; + } + + /** + * Get the date that the employee was hired. + * @return The date the employee was hired. + */ + public Date getHiredate() { + return hiredate; + } + + /** + * Set the date that the employee was hired. + * @param hiredate The date the employee was hired. + */ + public void setHiredate(Date hiredate) { + this.hiredate = hiredate; + } + + /** + * Get the weekly hours of the employee. + * @return The number of hours per week that the employee works. + */ + public double getWeeklyhours() { + return weeklyhours; + } + + /** + * Set the number of hours per week that the employee works. + * @param weeklyhours The number of hours per week that the employee + * works. + */ + public void setWeeklyhours(double weeklyhours) { + this.weeklyhours = weeklyhours; + } + + /** + * Get the employee's department. + * @return The department associated with the employee. + */ + public IDepartment getDepartment() { + return department; + } + + /** + * Set the employee's department. + * @param department The department. + */ + public void setDepartment(IDepartment department) { + this.department = (Department)department; + } + + /** + * Get the employee's funding department. + * @return The funding department associated with the employee. + */ + public IDepartment getFundingDept() { + return fundingDept; + } + + /** + * Set the employee's funding department. + * @param department The funding department. + */ + public void setFundingDept(IDepartment department) { + this.fundingDept = (Department)department; + } + + /** + * Get the employee's manager. + * @return The employee's manager. + */ + public IEmployee getManager() { + return manager; + } + + /** + * Set the employee's manager. + * @param manager The employee's manager. + */ + public void setManager(IEmployee manager) { + this.manager = (Employee)manager; + } + + /** + * Get the employee's team. + * @return The set of Employees on this employee's team, + * returned as an unmodifiable set. + */ + public Set getTeam() { + return Collections.unmodifiableSet(team); + } + + /** + * Add an Employee to this employee's team. + * This method sets both sides of the relationship, modifying + * this employees team to include parameter emp and modifying + * emp to set its manager attribute to this object. + * @param emp The Employee to add to the team. + */ + public void addToTeam(Employee emp) { + team.add(emp); + emp.manager = this; + } + + /** + * Remove an Employee from this employee's team. + * This method will also set the emp manager to null. + * @param emp The Employee to remove from the team. + */ + public void removeFromTeam(Employee emp) { + team.remove(emp); + emp.manager = null; + } + + /** + * Set the employee's team. + * @param team The set of Employees. + */ + public void setTeam(Set team) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.team = (team != null) ? new HashSet(team) : null; + } + + /** + * Set the mentor for this employee. + * @param mentor The mentor for this employee. + */ + public void setMentor(IEmployee mentor) { + this.mentor = (Employee)mentor; + } + + /** + * Get the mentor for this employee. + * @return The mentor. + */ + public IEmployee getMentor() { + return mentor; + } + + /** + * Set the protege for this employee. + * @param protege The protege for this employee. + */ + public void setProtege(IEmployee protege) { + this.protege = (Employee)protege; + } + + /** + * Get the protege of this employee. + * @return The protege of this employee. + */ + public IEmployee getProtege() { + return protege; + } + + /** + * Set the HR advisor for this employee. + * @param hradvisor The hradvisor for this employee. + */ + public void setHradvisor(IEmployee hradvisor) { + this.hradvisor = (Employee)hradvisor; + } + + /** + * Get the HR advisor for the employee. + * @return The HR advisor. + */ + public IEmployee getHradvisor() { + return hradvisor; + } + + /** + * Get the HR advisees of this HR advisor. + * @return An unmodifiable Set containing the + * Employees that are HR advisees of this employee. + */ + public Set getHradvisees() { + return Collections.unmodifiableSet(hradvisees); + } + + /** + * Add an Employee as an advisee of this HR advisor. + * This method also sets the emp hradvisor to reference + * this object. In other words, both sides of the relationship are + * set. + * @param emp The employee to add as an advisee. + */ + public void addAdvisee(Employee emp) { + hradvisees.add(emp); + emp.hradvisor = this; + } + + /** + * Remove an Employee as an advisee of this HR advisor. + * This method also sets the emp hradvisor to null. + * In other words, both sides of the relationship are set. + * @param emp The employee to add as an HR advisee. + */ + public void removeAdvisee(Employee emp) { + hradvisees.remove(emp); + emp.hradvisor = null; + } + + /** + * Set the HR advisees of this HR advisor. + * @param hradvisees The Employees that are HR advisees of + * this employee. + */ + public void setHradvisees(Set hradvisees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.hradvisees = (hradvisees != null) ? new HashSet(hradvisees) : null; + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + team = new HashSet(); + hradvisees = new HashSet(); + } + + /** + * Return a String representation of a Employee object. + * @return a String representation of a Employee object. + */ + public String toString() { + return "Employee(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", hired ").append( + hiredate==null ? "null" : formatter.format(hiredate)); + rc.append(", weeklyhours ").append(weeklyhours); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the corresponding fields of the specified Employee. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IEmployee otherEmp = (IEmployee)other; + String where = "Employee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.equals(hiredate, otherEmp.getHiredate(), where + ".hiredate") & + helper.closeEnough(weeklyhours, otherEmp.getWeeklyhours(), where + ".weeklyhours") & + helper.deepEquals(department, otherEmp.getDepartment(), where + ".department") & + helper.deepEquals(fundingDept, otherEmp.getFundingDept(), where + ".fundingDept") & + helper.deepEquals(manager, otherEmp.getManager(), where + ".manager") & + helper.deepEquals(mentor, otherEmp.getMentor(), where + ".mentor") & + helper.deepEquals(protege, otherEmp.getProtege(), where + ".protege") & + helper.deepEquals(hradvisor, otherEmp.getHradvisor(), where + ".hradvisor") & + helper.deepEquals(team, otherEmp.getTeam(), where + ".team") & + helper.deepEquals(hradvisees, otherEmp.getHradvisees(), where + ".hradvisees"); + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/FullTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/FullTimeEmployee.java index e3bc69b46..61e8a4969 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/FullTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/FullTimeEmployee.java @@ -5,102 +5,105 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyListWithoutJoin; import java.util.Date; + +import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a full-time employee. */ +/** + * This class represents a full-time employee. + */ public class FullTimeEmployee extends Employee implements IFullTimeEmployee { - private double salary; - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FullTimeEmployee() {} - - /** - * Construct a full-time employee. - * - * @param personid The person identifier. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param hired The date that the person was hired. - * @param sal The salary of the full-time employee. - */ - public FullTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double sal) { - super(personid, first, last, middle, born, hired); - salary = sal; - } + private double salary; - /** - * Get the salary of the full time employee. - * - * @return The salary of the full time employee. - */ - public double getSalary() { - return salary; - } + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FullTimeEmployee() {} - /** - * Set the salary for the full-time employee. - * - * @param salary The salary to set for the full-time employee. - */ - public void setSalary(double salary) { - this.salary = salary; - } + /** + * Construct a full-time employee. + * @param personid The person identifier. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param hired The date that the person was hired. + * @param sal The salary of the full-time employee. + */ + public FullTimeEmployee(long personid, String first, String last, + String middle, Date born, + Date hired, double sal) { + super(personid, first, last, middle, born, hired); + salary = sal; + } - /** - * Return a String representation of a FullTimeEmployee object. - * - * @return a String representation of a FullTimeEmployee object. - */ - public String toString() { - return "FullTimeEmployee(" + getFieldRepr() + ")"; - } + /** + * Get the salary of the full time employee. + * @return The salary of the full time employee. + */ + public double getSalary() { + return salary; + } + + /** + * Set the salary for the full-time employee. + * @param salary The salary to set for the full-time employee. + */ + public void setSalary(double salary) { + this.salary = salary; + } + + /** + * Return a String representation of a FullTimeEmployee object. + * @return a String representation of a FullTimeEmployee object. + */ + public String toString() { + return "FullTimeEmployee(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - public String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", $").append(salary); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + public String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", $").append(salary); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified FullTimeEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IFullTimeEmployee otherEmp = (IFullTimeEmployee) other; - String where = "FullTimeEmployee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.closeEnough(salary, otherEmp.getSalary(), where + ".salary"); - } + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified + * FullTimeEmployee. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IFullTimeEmployee otherEmp = (IFullTimeEmployee)other; + String where = "FullTimeEmployee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.closeEnough(salary, otherEmp.getSalary(), where + ".salary"); + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/ICompany.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/ICompany.java index 87b9fa5f5..e7ea23c78 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/ICompany.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/ICompany.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -21,24 +21,19 @@ import java.util.Set; /** - * This interface represents the persistent state of Company. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Company. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface ICompany { - - long getCompanyid(); - - Set getDepartments(); - - Date getFounded(); - - String getName(); - - void setCompanyid(long id); - - void setDepartments(Set depts); - - void setFounded(Date date); - - void setName(String string); + + long getCompanyid(); + Set getDepartments(); + Date getFounded(); + String getName(); + + void setCompanyid(long id); + void setDepartments(Set depts); + void setFounded(Date date); + void setName(String string); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/IDepartment.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/IDepartment.java index a03122b32..5e3722865 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/IDepartment.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/IDepartment.java @@ -5,39 +5,34 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyListWithoutJoin; import java.util.List; /** - * This interface represents the persistent state of Department. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Department. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IDepartment { - long getDeptid(); - - String getName(); - - ICompany getCompany(); - - List getEmployees(); - - void setDeptid(long deptid); - - void setName(String name); - - void setCompany(ICompany company); - - void setEmployees(List employees); + long getDeptid(); + String getName(); + ICompany getCompany(); + List getEmployees(); + + void setDeptid(long deptid); + void setName(String name); + void setCompany(ICompany company); + void setEmployees(List employees); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/IEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/IEmployee.java index 41319fb8c..1a675a23a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/IEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/IEmployee.java @@ -5,64 +5,48 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyListWithoutJoin; import java.util.Date; import java.util.Set; /** - * This interface represents the persistent state of Employee. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Employee. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IEmployee extends IPerson { - Date getHiredate(); - - double getWeeklyhours(); - - IDepartment getDepartment(); - - IDepartment getFundingDept(); - - IEmployee getManager(); - - Set getTeam(); - - IEmployee getMentor(); - - IEmployee getProtege(); - - IEmployee getHradvisor(); - - Set getHradvisees(); - - void setHiredate(Date hiredate); - - void setWeeklyhours(double weeklyhours); - - void setDepartment(IDepartment department); - - void setFundingDept(IDepartment department); - - void setManager(IEmployee manager); - - void setTeam(Set team); - - void setMentor(IEmployee mentor); - - void setProtege(IEmployee protege); - - void setHradvisor(IEmployee hradvisor); - - void setHradvisees(Set hradvisees); + Date getHiredate(); + double getWeeklyhours(); + IDepartment getDepartment(); + IDepartment getFundingDept(); + IEmployee getManager(); + Set getTeam(); + IEmployee getMentor(); + IEmployee getProtege(); + IEmployee getHradvisor(); + Set getHradvisees(); + + void setHiredate(Date hiredate); + void setWeeklyhours(double weeklyhours); + void setDepartment(IDepartment department); + void setFundingDept(IDepartment department); + void setManager(IEmployee manager); + void setTeam(Set team); + void setMentor(IEmployee mentor); + void setProtege(IEmployee protege); + void setHradvisor(IEmployee hradvisor); + void setHradvisees(Set hradvisees); + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/IFullTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/IFullTimeEmployee.java index cb61fa290..0e2eee97d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/IFullTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/IFullTimeEmployee.java @@ -5,25 +5,25 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyListWithoutJoin; /** - * This interface represents the persistent state of FullTimeEmployee. Javadoc was deliberately - * omitted because it would distract from the purpose of the interface. + * This interface represents the persistent state of FullTimeEmployee. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IFullTimeEmployee extends IEmployee { - double getSalary(); - - void setSalary(double salary); + double getSalary(); + void setSalary(double salary); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/IPartTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/IPartTimeEmployee.java index bde142394..86bf2a8f3 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/IPartTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/IPartTimeEmployee.java @@ -5,25 +5,25 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyListWithoutJoin; /** - * This interface represents the persistent state of PartTimeEmployee. Javadoc was deliberately - * omitted because it would distract from the purpose of the interface. + * This interface represents the persistent state of PartTimeEmployee. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IPartTimeEmployee extends IEmployee { - double getWage(); - - void setWage(double wage); + double getWage(); + void setWage(double wage); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/IPerson.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/IPerson.java index a06568d07..534b7e8a1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/IPerson.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/IPerson.java @@ -5,43 +5,37 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyListWithoutJoin; import java.util.Date; /** - * This interface represents the persistent state of Person. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Person. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IPerson { - long getPersonid(); - - String getLastname(); - - String getFirstname(); - - String getMiddlename(); - - Date getBirthdate(); - - void setPersonid(long personid); - - void setLastname(String lastname); - - void setFirstname(String firstname); - - void setMiddlename(String middlename); + long getPersonid(); + String getLastname(); + String getFirstname(); + String getMiddlename(); + Date getBirthdate(); + + void setPersonid(long personid); + void setLastname(String lastname); + void setFirstname(String firstname); + void setMiddlename(String middlename); + void setBirthdate(Date birthdate); - void setBirthdate(Date birthdate); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/PartTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/PartTimeEmployee.java index 9ed027cfc..cf7bf02ab 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/PartTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/PartTimeEmployee.java @@ -5,101 +5,103 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyListWithoutJoin; import java.util.Date; + +import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a part-time employee. */ +/** + * This class represents a part-time employee. + */ public class PartTimeEmployee extends Employee implements IPartTimeEmployee { - private double wage; + private double wage; - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public PartTimeEmployee() {} + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PartTimeEmployee() {} - /** - * Construct a part-time employee. - * - * @param personid The identifier for the person. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param hired The date the person was hired. - * @param wage The person's wage. - */ - public PartTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double wage) { - super(personid, first, last, middle, born, hired); - this.wage = wage; - } + /** + * Construct a part-time employee. + * @param personid The identifier for the person. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param hired The date the person was hired. + * @param wage The person's wage. + */ + public PartTimeEmployee(long personid, String first, String last, + String middle, Date born, + Date hired, double wage ) { + super(personid, first, last, middle, born, hired); + this.wage = wage; + } - /** - * Get the wage of the part-time employee. - * - * @return The wage of the part-time employee. - */ - public double getWage() { - return wage; - } + /** + * Get the wage of the part-time employee. + * @return The wage of the part-time employee. + */ + public double getWage() { + return wage; + } - /** - * Set the wage of the part-time employee. - * - * @param wage The wage of the part-time employee. - */ - public void setWage(double wage) { - this.wage = wage; - } + /** + * Set the wage of the part-time employee. + * @param wage The wage of the part-time employee. + */ + public void setWage(double wage) { + this.wage = wage; + } - /** - * Returns a String representation of a PartTimeEmployee object. - * - * @return a String representation of a PartTimeEmployee object. - */ - public String toString() { - return "PartTimeEmployee(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of a PartTimeEmployee object. + * @return a String representation of a PartTimeEmployee object. + */ + public String toString() { + return "PartTimeEmployee(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - public String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", $" + wage); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + public String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", $" + wage); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified PartTimeEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IPartTimeEmployee otherEmp = (IPartTimeEmployee) other; - String where = "PartTimeEmployee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.closeEnough(wage, otherEmp.getWage(), where + ".wage"); - } + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified + * PartTimeEmployee. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IPartTimeEmployee otherEmp = (IPartTimeEmployee)other; + String where = "PartTimeEmployee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.closeEnough(wage, otherEmp.getWage(), where + ".wage"); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/Person.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/Person.java index 6a83cb675..636241b06 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/Person.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyListWithoutJoin/Person.java @@ -5,322 +5,325 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.companyListWithoutJoin; import java.io.Serializable; + import java.text.SimpleDateFormat; + +import java.util.Collections; import java.util.Comparator; import java.util.Date; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a person. */ -public class Person implements IPerson, Serializable, Comparable, Comparator, DeepEquality { - - private long personid; - private String firstname; - private String lastname; - private String middlename; - private Date birthdate; - - protected static SimpleDateFormat formatter = new SimpleDateFormat("d/MMM/yyyy"); - - /** This is the JDO-required no-args constructor. */ - protected Person() {} - - /** - * Construct a Person instance. - * - * @param personid The person identifier. - * @param firstname The person's first name. - * @param lastname The person's last name. - * @param middlename The person's middle name. - * @param birthdate The person's birthdate. - */ - public Person( - long personid, String firstname, String lastname, String middlename, Date birthdate) { - this.personid = personid; - this.firstname = firstname; - this.lastname = lastname; - this.middlename = middlename; - this.birthdate = birthdate; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setPersonid(long id) { - if (this.personid != 0) throw new IllegalStateException("Id is already set."); - this.personid = id; - } - - /** - * Get the person's id. - * - * @return The personid. - */ - public long getPersonid() { - return personid; - } - - /** - * Set the person's id. - * - * @param personid The personid. - */ - public void setLastname(long personid) { - this.personid = personid; - } - - /** - * Get the person's last name. - * - * @return The last name. - */ - public String getLastname() { - return lastname; - } - - /** - * Set the person's last name. - * - * @param lastname The last name. - */ - public void setLastname(String lastname) { - this.lastname = lastname; - } - - /** - * Get the person's first name. - * - * @return The first name. - */ - public String getFirstname() { - return firstname; - } - - /** - * Set the person's first name. - * - * @param firstname The first name. - */ - public void setFirstname(String firstname) { - this.firstname = firstname; - } - - /** - * Get the person's middle name. - * - * @return The middle name. - */ - public String getMiddlename() { - return middlename; - } - - /** - * Set the person's middle name. - * - * @param middlename The middle name. - */ - public void setMiddlename(String middlename) { - this.middlename = middlename; - } - - /** - * Get the person's birthdate. - * - * @return The person's birthdate. - */ - public Date getBirthdate() { - return birthdate; - } - - /** - * Set the person's birthdate. - * - * @param birthdate The person's birthdate. - */ - public void setBirthdate(Date birthdate) { - this.birthdate = birthdate; - } - - /** - * Returns a String representation of a Person object. - * - * @return a string representation of a Person object. - */ - public String toString() { - return "Person(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(personid); - rc.append(", ").append(lastname); - rc.append(", ").append(firstname); - rc.append(", born ").append(birthdate == null ? "null" : formatter.format(birthdate)); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IPerson otherPerson = (IPerson) other; - String where = "Person<" + personid + ">"; - return helper.equals(personid, otherPerson.getPersonid(), where + ".personid") - & helper.equals(firstname, otherPerson.getFirstname(), where + ".firstname") - & helper.equals(lastname, otherPerson.getLastname(), where + ".lastname") - & helper.equals(middlename, otherPerson.getMiddlename(), where + ".middlename") - & helper.equals(birthdate, otherPerson.getBirthdate(), where + ".birthdate"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((IPerson) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((IPerson) o1, (IPerson) o2); - } - - /** - * Compares this object with the specified Person object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Person object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Person object. - */ - public int compareTo(IPerson other) { - return compare(this, other); - } - - /** - * Compares its two IPerson arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IPerson object to be compared. - * @param o2 the second IPerson object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(IPerson o1, IPerson o2) { - return EqualityHelper.compare(o1.getPersonid(), o2.getPersonid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof IPerson) { - return compareTo((IPerson) obj) == 0; +/** + * This class represents a person. + */ +public class Person + implements IPerson, Serializable, Comparable, Comparator, DeepEquality { + + private long personid; + private String firstname; + private String lastname; + private String middlename; + private Date birthdate; + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. */ + protected Person() {} + + /** + * Construct a Person instance. + * @param personid The person identifier. + * @param firstname The person's first name. + * @param lastname The person's last name. + * @param middlename The person's middle name. + * @param birthdate The person's birthdate. + */ + public Person(long personid, String firstname, String lastname, + String middlename, Date birthdate) { + this.personid = personid; + this.firstname = firstname; + this.lastname = lastname; + this.middlename = middlename; + this.birthdate = birthdate; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) personid; - } - /** - * This class is used to represent the application identifier for the Person class. - */ - public static class Oid implements Serializable, Comparable { /** - * This field represents the identifier for the Person class. It must match a field - * in the Person class in both name and type. + * Set the id associated with this object. + * @param id the id. */ - public long personid; + public void setPersonid(long id) { + if (this.personid != 0) + throw new IllegalStateException("Id is already set."); + this.personid = id; + } - /** The required public no-arg constructor. */ - public Oid() {} + /** + * Get the person's id. + * @return The personid. + */ + public long getPersonid() { + return personid; + } /** - * Initialize the identifier. - * - * @param personid The person identifier. + * Set the person's id. + * @param personid The personid. + */ + public void setLastname(long personid) { + this.personid = personid; + } + + /** + * Get the person's last name. + * @return The last name. + */ + public String getLastname() { + return lastname; + } + + /** + * Set the person's last name. + * @param lastname The last name. + */ + public void setLastname(String lastname) { + this.lastname = lastname; + } + + /** + * Get the person's first name. + * @return The first name. */ - public Oid(long personid) { - this.personid = personid; + public String getFirstname() { + return firstname; } - public Oid(String s) { - personid = Long.parseLong(justTheId(s)); + /** + * Set the person's first name. + * @param firstname The first name. + */ + public void setFirstname(String firstname) { + this.firstname = firstname; } + /** + * Get the person's middle name. + * @return The middle name. + */ + public String getMiddlename() { + return middlename; + } + + /** + * Set the person's middle name. + * @param middlename The middle name. + */ + public void setMiddlename(String middlename) { + this.middlename = middlename; + } + + /** + * Get the person's birthdate. + * @return The person's birthdate. + */ + public Date getBirthdate() { + return birthdate; + } + + /** + * Set the person's birthdate. + * @param birthdate The person's birthdate. + */ + public void setBirthdate(Date birthdate) { + this. birthdate = birthdate; + } + + /** + * Returns a String representation of a Person object. + * @return a string representation of a Person object. + */ public String toString() { - return this.getClass().getName() + ": " + personid; + return "Person(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(personid); + rc.append(", ").append(lastname); + rc.append(", ").append(firstname); + rc.append(", born ").append( + birthdate==null ? "null" : formatter.format(birthdate)); + return rc.toString(); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.personid != o.personid) return (false); - return (true); + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IPerson otherPerson = (IPerson)other; + String where = "Person<" + personid + ">"; + return + helper.equals(personid, otherPerson.getPersonid(), where + ".personid") & + helper.equals(firstname, otherPerson.getFirstname(), where + ".firstname") & + helper.equals(lastname, otherPerson.getLastname(), where + ".lastname") & + helper.equals(middlename, otherPerson.getMiddlename(), where + ".middlename") & + helper.equals(birthdate, otherPerson.getBirthdate(), where + ".birthdate") ; } - /** */ - public int hashCode() { - return ((int) personid); + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((IPerson)o); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((IPerson)o1, (IPerson)o2); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (personid < other.personid) return -1; - if (personid > other.personid) return 1; - return 0; + /** + * Compares this object with the specified Person object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Person object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Person + * object. + */ + public int compareTo(IPerson other) { + return compare(this, other); } - } + + /** + * Compares its two IPerson arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IPerson object to be compared. + * @param o2 the second IPerson object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(IPerson o1, IPerson o2) { + return EqualityHelper.compare(o1.getPersonid(), o2.getPersonid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof IPerson) { + return compareTo((IPerson)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)personid; + } + /** + * This class is used to represent the application identifier + * for the Person class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the identifier for the Person + * class. It must match a field in the Person class in + * both name and type. + */ + public long personid; + + /** + * The required public no-arg constructor. + */ + public Oid() { } + + /** + * Initialize the identifier. + * @param personid The person identifier. + */ + public Oid(long personid) { + this.personid = personid; + } + + public Oid(String s) { personid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + personid;} + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || + !this.getClass().equals(obj.getClass()) ) return( false ); + Oid o = (Oid) obj; + if( this.personid != o.personid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) personid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( personid < other.personid ) return -1; + if( personid > other.personid ) return 1; + return 0; + } + + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/Company.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/Company.java index ceaec0125..4436b3ce5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/Company.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/Company.java @@ -5,330 +5,334 @@ * 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 + * + * 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.jdo.tck.pc.companyMapWithoutJoin; -import java.io.IOException; -import java.io.ObjectInputStream; import java.io.Serializable; +import java.io.ObjectInputStream; +import java.io.IOException; + import java.text.SimpleDateFormat; + import java.util.Collections; import java.util.Comparator; -import java.util.Date; -import java.util.HashSet; import java.util.Set; +import java.util.HashSet; +import java.util.Date; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents information about a company. */ -public class Company implements ICompany, Serializable, Comparable, Comparator, DeepEquality { - - private long companyid; - private String name; - private Date founded; - private transient Set departments = new HashSet(); // element type is Department - - protected static SimpleDateFormat formatter = new SimpleDateFormat("d/MMM/yyyy"); - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public Company() {} - - /** - * Initialize the Company instance. - * - * @param companyid The company id. - * @param name The company name. - * @param founded The date the company was founded. - */ - public Company(long companyid, String name, Date founded) { - this.companyid = companyid; - this.name = name; - this.founded = founded; - } - - /** - * Get the company id. - * - * @return The company id. - */ - public long getCompanyid() { - return companyid; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setCompanyid(long id) { - if (this.companyid != 0) throw new IllegalStateException("Id is already set."); - this.companyid = id; - } - - /** - * Get the name of the company. - * - * @return The name of the company. - */ - public String getName() { - return name; - } - - /** - * Set the name of the company. - * - * @param name The value to use for the name of the company. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Get the date that the company was founded. - * - * @return The date the company was founded. - */ - public Date getFounded() { - return founded; - } - - /** - * Set the date that the company was founded. - * - * @param founded The date to set that the company was founded. - */ - public void setFounded(Date founded) { - this.founded = founded; - } - - /** - * Get the departments contained in the company. - * - * @return An unmodifiable Set that contains all the Departments of the - * company. - */ - public Set getDepartments() { - return Collections.unmodifiableSet(departments); - } - - /** - * Add a Department instance to the company. - * - * @param dept The Department instance to add. - */ - public void addDepartment(Department dept) { - departments.add(dept); - } - - /** - * Remove a Department instance from the company. - * - * @param dept The Department instance to remove. - */ - public void removeDepartment(Department dept) { - departments.remove(dept); - } - - /** - * Initialize the set of Departments in the company to the parameter. - * - * @param departments The set of Departments for the company. - */ - public void setDepartments(Set departments) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.departments = (departments != null) ? new HashSet(departments) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - departments = new HashSet(); - } - - /** - * Returns a String representation of a Company object. - * - * @return a String representation of a Company object. - */ - public String toString() { - return "Company(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(companyid); - rc.append(", name ").append(name); - rc.append(", founded ").append(founded == null ? "null" : formatter.format(founded)); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - ICompany otherCompany = (ICompany) other; - String where = "Company<" + companyid + ">"; - return helper.equals(companyid, otherCompany.getCompanyid(), where + ".companyid") - & helper.equals(name, otherCompany.getName(), where + ".name") - & helper.equals(founded, otherCompany.getFounded(), where + ".founded") - & helper.deepEquals(departments, otherCompany.getDepartments(), where + ".departments"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((ICompany) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((ICompany) o1, (ICompany) o2); - } - - /** - * Compares this object with the specified Company object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Company object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Company object. - */ - public int compareTo(ICompany other) { - return compare(this, other); - } - - /** - * Compares its two ICompany arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first ICompany object to be compared. - * @param o2 the second ICompany object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(ICompany o1, ICompany o2) { - return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof ICompany) { - return compareTo((ICompany) obj) == 0; +/** + * This class represents information about a company. + */ +public class Company + implements ICompany, Serializable, Comparable, Comparator, DeepEquality { + + private long companyid; + private String name; + private Date founded; + private transient Set departments = new HashSet(); // element type is Department + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public Company() {} + + /** + * Initialize the Company instance. + * @param companyid The company id. + * @param name The company name. + * @param founded The date the company was founded. + */ + public Company(long companyid, String name, Date founded) { + this.companyid = companyid; + this.name = name; + this.founded = founded; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) companyid; - } - - /** - * The class to be used as the application identifier for the Company class. It - * consists of both the company name and the date that the company was founded. - */ - public static class Oid implements Serializable, Comparable { /** - * This field is part of the identifier and should match in name and type with a field in the - * Company class. + * Get the company id. + * @return The company id. */ - public long companyid; + public long getCompanyid() { + return companyid; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setCompanyid(long id) { + if (this.companyid != 0) + throw new IllegalStateException("Id is already set."); + this.companyid = id; + } + + /** + * Get the name of the company. + * @return The name of the company. + */ + public String getName() { + return name; + } - /** The required public no-arg constructor. */ - public Oid() {} + /** + * Set the name of the company. + * @param name The value to use for the name of the company. + */ + public void setName(String name) { + this.name = name; + } /** - * Initialize the identifier. - * - * @param companyid The id of the company. + * Get the date that the company was founded. + * @return The date the company was founded. */ - public Oid(long companyid) { - this.companyid = companyid; + public Date getFounded() { + return founded; } - public Oid(String s) { - companyid = Long.parseLong(justTheId(s)); + /** + * Set the date that the company was founded. + * @param founded The date to set that the company was founded. + */ + public void setFounded(Date founded) { + this.founded = founded; + } + + /** + * Get the departments contained in the company. + * @return An unmodifiable Set that contains all the + * Departments of the company. + */ + public Set getDepartments() { + return Collections.unmodifiableSet(departments); + } + + /** + * Add a Department instance to the company. + * @param dept The Department instance to add. + */ + public void addDepartment(Department dept) { + departments.add(dept); } + /** + * Remove a Department instance from the company. + * @param dept The Department instance to remove. + */ + public void removeDepartment(Department dept) { + departments.remove(dept); + } + + /** + * Initialize the set of Departments in the company to the + * parameter. + * @param departments The set of Departments for the + * company. + */ + public void setDepartments(Set departments) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.departments = + (departments != null) ? new HashSet(departments) : null; + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + departments = new HashSet(); + } + + /** + * Returns a String representation of a Company object. + * @return a String representation of a Company object. + */ public String toString() { - return this.getClass().getName() + ": " + companyid; + return "Company(" + getFieldRepr()+ ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(companyid); + rc.append(", name ").append(name); + rc.append(", founded ").append( + founded==null ? "null" : formatter.format(founded)); + return rc.toString(); } - /** */ - public boolean equals(Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return false; - Oid o = (Oid) obj; - if (this.companyid != o.companyid) return false; - return true; + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + ICompany otherCompany = (ICompany)other; + String where = "Company<" + companyid + ">"; + return + helper.equals(companyid, otherCompany.getCompanyid(), where + ".companyid") & + helper.equals(name, otherCompany.getName(), where + ".name") & + helper.equals(founded, otherCompany.getFounded(), where + ".founded") & + helper.deepEquals(departments, otherCompany.getDepartments(), where + ".departments"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((ICompany)o); } - /** */ - public int hashCode() { - return (int) companyid; + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((ICompany)o1, (ICompany)o2); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compares this object with the specified Company object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Company object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Company + * object. + */ + public int compareTo(ICompany other) { + return compare(this, other); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (companyid < other.companyid) return -1; - if (companyid > other.companyid) return 1; - return 0; + /** + * Compares its two ICompany arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first ICompany object to be compared. + * @param o2 the second ICompany object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(ICompany o1, ICompany o2) { + return EqualityHelper.compare(o1.getCompanyid(), o2.getCompanyid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof ICompany) { + return compareTo((ICompany)obj) == 0; + } + return false; } - } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)companyid; + } + + /** + * The class to be used as the application identifier + * for the Company class. It consists of both the company + * name and the date that the company was founded. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field is part of the identifier and should match in name + * and type with a field in the Company class. + */ + public long companyid; + + /** The required public no-arg constructor. */ + public Oid() { } + + /** + * Initialize the identifier. + * @param companyid The id of the company. + */ + public Oid(long companyid) { + this.companyid = companyid; + } + + public Oid(String s) { companyid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + companyid;} + + + /** */ + public boolean equals(Object obj) { + if (obj==null || !this.getClass().equals(obj.getClass())) + return false; + Oid o = (Oid) obj; + if (this.companyid != o.companyid) + return false; + return true; + } + + /** */ + public int hashCode() { + return (int)companyid; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( companyid < other.companyid ) return -1; + if( companyid > other.companyid ) return 1; + return 0; + } + + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactory.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactory.java index b9af96759..0119f1d4a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactory.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactory.java @@ -5,16 +5,16 @@ * 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 + * + * 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. */ - + /* * CompanyFactory.java * @@ -22,38 +22,25 @@ package org.apache.jdo.tck.pc.companyMapWithoutJoin; +import java.math.BigDecimal; + import java.util.Date; /** - * This interface is implemented by a factory class that can create Company model instances. The - * factory instance is registered with CompanyFactoryRegistry. + * This interface is implemented by a factory class that can create + * Company model instances. The factory instance is registered with + * CompanyFactoryRegistry. */ public interface CompanyFactory { - ICompany newCompany(long companyid, String name, Date founded); - - IDepartment newDepartment(long deptid, String name); - - IDepartment newDepartment(long deptid, String name, ICompany company); - - IFullTimeEmployee newFullTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - Date hired, - String role, - double sal); - - IPartTimeEmployee newPartTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - Date hired, - String role, - double wage); - - Class[] getTearDownClasses(); + ICompany newCompany(long companyid, String name, Date founded); + IDepartment newDepartment(long deptid, String name); + IDepartment newDepartment(long deptid, + String name, ICompany company); + IFullTimeEmployee newFullTimeEmployee(long personid, + String first, String last, String middle, + Date born, Date hired, String role, double sal); + IPartTimeEmployee newPartTimeEmployee(long personid, + String first, String last, String middle, + Date born, Date hired, String role, double wage); + Class[] getTearDownClasses(); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactoryAbstractImpl.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactoryAbstractImpl.java index 1bffa28b9..1215f8b82 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactoryAbstractImpl.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactoryAbstractImpl.java @@ -18,6 +18,7 @@ package org.apache.jdo.tck.pc.companyMapWithoutJoin; import javax.jdo.PersistenceManager; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -28,99 +29,87 @@ * classes that implement only the methods to construct the instance. */ public abstract class CompanyFactoryAbstractImpl implements CompanyFactory { + + protected PersistenceManager pm; + + /** Logger */ + protected Log logger = + LogFactory.getFactory().getInstance("org.apache.jdo.tck"); + + /** true if debug logging is enabled. */ + protected boolean debug = logger.isDebugEnabled(); + + /** + * Creates a new instance of CompanyFactoryAbstractImpl + * @param pm the PersistenceManager + */ + public CompanyFactoryAbstractImpl(PersistenceManager pm) { + this.pm = pm; + } + + abstract ICompany newCompany(); + abstract IDepartment newDepartment(); + abstract IFullTimeEmployee newFullTimeEmployee(); + abstract IPartTimeEmployee newPartTimeEmployee(); + + public ICompany newCompany(long companyid, String name, + java.util.Date founded) { + ICompany result = newCompany(); + result.setCompanyid(companyid); + result.setName(name); + result.setFounded(founded); + if (debug) logger.debug("newCompany returned" + result); + return result; + } + + public IDepartment newDepartment(long deptid, String name) { + IDepartment result = newDepartment(); + result.setDeptid(deptid); + result.setName(name); + if (debug) logger.debug("newDepartment returned" + result); + return result; + } + + + public IDepartment newDepartment(long deptid, String name, ICompany company) { + IDepartment result = newDepartment(); + result.setDeptid(deptid); + result.setName(name); + result.setCompany(company); + if (debug) logger.debug("newDepartment returned" + result); + return result; + } + + public IFullTimeEmployee newFullTimeEmployee(long personid, String first, + String last, String middle, java.util.Date born, + java.util.Date hired, String role, double sal) { + IFullTimeEmployee result = newFullTimeEmployee(); + result.setPersonid(personid); + result.setFirstname(first); + result.setLastname(last); + result.setMiddlename(middle); + result.setBirthdate(born); + result.setHiredate(hired); + result.setRole(role); + result.setSalary(sal); + if (debug) logger.debug("newFullTimeEmployee returned" + result); + return result; + } + + public IPartTimeEmployee newPartTimeEmployee(long personid, String first, + String last, String middle, java.util.Date born, + java.util.Date hired, String role, double wage) { + IPartTimeEmployee result = newPartTimeEmployee(); + result.setPersonid(personid); + result.setFirstname(first); + result.setLastname(last); + result.setMiddlename(middle); + result.setBirthdate(born); + result.setHiredate(hired); + result.setRole(role); + result.setWage(wage); + if (debug) logger.debug("newPartTimeEmployee returned" + result); + return result; + } - protected PersistenceManager pm; - - /** Logger */ - protected Log logger = LogFactory.getFactory().getInstance("org.apache.jdo.tck"); - - /** true if debug logging is enabled. */ - protected boolean debug = logger.isDebugEnabled(); - - /** - * Creates a new instance of CompanyFactoryAbstractImpl - * - * @param pm the PersistenceManager - */ - public CompanyFactoryAbstractImpl(PersistenceManager pm) { - this.pm = pm; - } - - abstract ICompany newCompany(); - - abstract IDepartment newDepartment(); - - abstract IFullTimeEmployee newFullTimeEmployee(); - - abstract IPartTimeEmployee newPartTimeEmployee(); - - public ICompany newCompany(long companyid, String name, java.util.Date founded) { - ICompany result = newCompany(); - result.setCompanyid(companyid); - result.setName(name); - result.setFounded(founded); - if (debug) logger.debug("newCompany returned" + result); - return result; - } - - public IDepartment newDepartment(long deptid, String name) { - IDepartment result = newDepartment(); - result.setDeptid(deptid); - result.setName(name); - if (debug) logger.debug("newDepartment returned" + result); - return result; - } - - public IDepartment newDepartment(long deptid, String name, ICompany company) { - IDepartment result = newDepartment(); - result.setDeptid(deptid); - result.setName(name); - result.setCompany(company); - if (debug) logger.debug("newDepartment returned" + result); - return result; - } - - public IFullTimeEmployee newFullTimeEmployee( - long personid, - String first, - String last, - String middle, - java.util.Date born, - java.util.Date hired, - String role, - double sal) { - IFullTimeEmployee result = newFullTimeEmployee(); - result.setPersonid(personid); - result.setFirstname(first); - result.setLastname(last); - result.setMiddlename(middle); - result.setBirthdate(born); - result.setHiredate(hired); - result.setRole(role); - result.setSalary(sal); - if (debug) logger.debug("newFullTimeEmployee returned" + result); - return result; - } - - public IPartTimeEmployee newPartTimeEmployee( - long personid, - String first, - String last, - String middle, - java.util.Date born, - java.util.Date hired, - String role, - double wage) { - IPartTimeEmployee result = newPartTimeEmployee(); - result.setPersonid(personid); - result.setFirstname(first); - result.setLastname(last); - result.setMiddlename(middle); - result.setBirthdate(born); - result.setHiredate(hired); - result.setRole(role); - result.setWage(wage); - if (debug) logger.debug("newPartTimeEmployee returned" + result); - return result; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactoryConcreteClass.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactoryConcreteClass.java index 1fb264f60..da9ed07ce 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactoryConcreteClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactoryConcreteClass.java @@ -17,73 +17,70 @@ package org.apache.jdo.tck.pc.companyMapWithoutJoin; +import java.math.BigDecimal; + import java.util.Date; + import javax.jdo.PersistenceManager; /* * This class is the company factory that uses constructors of the * concrete classes. */ -public class CompanyFactoryConcreteClass implements CompanyFactory { +public class CompanyFactoryConcreteClass implements CompanyFactory { - /** */ - public static final Class[] tearDownClasses = - new Class[] { - PartTimeEmployee.class, FullTimeEmployee.class, + /** */ + public static final Class[] tearDownClasses = new Class[] { + PartTimeEmployee.class, FullTimeEmployee.class, Department.class, Company.class - }; + }; - /** - * Creates a new instance of CompanyFactoryConcreteClass - * - * @param pm the PersistenceManager - */ - public CompanyFactoryConcreteClass(PersistenceManager pm) {} + /** + * Creates a new instance of CompanyFactoryConcreteClass + * @param pm the PersistenceManager + */ + public CompanyFactoryConcreteClass(PersistenceManager pm) { + } - public CompanyFactoryConcreteClass() {} + public CompanyFactoryConcreteClass() { + } - public ICompany newCompany(long companyid, String name, Date founded) { - return new Company(companyid, name, founded); - } + public ICompany newCompany(long companyid, + String name, Date founded) { + return new Company(companyid, name, founded); + } - public IDepartment newDepartment(long deptid, String name) { - return new Department(deptid, name); - } + public IDepartment newDepartment(long deptid, String name) { + return new Department(deptid, name); + } - public IDepartment newDepartment(long deptid, String name, ICompany company) { - return new Department(deptid, name, company); - } + public IDepartment newDepartment(long deptid, + String name, ICompany company) { + return new Department(deptid, name, company); + } - public IFullTimeEmployee newFullTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - Date hired, - String role, - double sal) { - return new FullTimeEmployee(personid, first, last, middle, born, hired, role, sal); - } + public IFullTimeEmployee newFullTimeEmployee(long personid, + String first, String last, String middle, + Date born, Date hired, String role, double sal) { + return new FullTimeEmployee(personid, first, last, middle, + born, hired, role, sal); + } - public IPartTimeEmployee newPartTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - Date hired, - String role, - double wage) { - return new PartTimeEmployee(personid, first, last, middle, born, hired, role, wage); - } + public IPartTimeEmployee newPartTimeEmployee(long personid, + String first, String last, String middle, + Date born, Date hired, String role, double wage) { + return new PartTimeEmployee(personid, first, last, middle, + born, hired, role, wage); + } - public IPerson newPerson( - long personid, String firstname, String lastname, String middlename, Date birthdate) { - return new Person(personid, firstname, lastname, middlename, birthdate); - } + public IPerson newPerson(long personid, + String firstname, String lastname, String middlename, + Date birthdate) { + return new Person(personid, firstname, lastname, middlename, + birthdate); + } - public Class[] getTearDownClasses() { - return tearDownClasses; - } + public Class[] getTearDownClasses() { + return tearDownClasses; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactoryPMClass.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactoryPMClass.java index ee58cc5ce..0e9edb981 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactoryPMClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactoryPMClass.java @@ -23,43 +23,42 @@ * CompanyFactoryPMClass.java * * This class uses the PersistenceManager.newInstance method with the concrete - * class as a parameter. + * class as a parameter. */ -public class CompanyFactoryPMClass extends CompanyFactoryAbstractImpl { - - /** */ - public static final Class[] tearDownClasses = - new Class[] { - PartTimeEmployee.class, FullTimeEmployee.class, +public class CompanyFactoryPMClass + extends CompanyFactoryAbstractImpl { + + /** */ + public static final Class[] tearDownClasses = new Class[] { + PartTimeEmployee.class, FullTimeEmployee.class, Department.class, Company.class - }; - - /** - * Creates a new instance of CompanyFactoryPMClass - * - * @param pm the PersistenceManager - */ - public CompanyFactoryPMClass(PersistenceManager pm) { - super(pm); - } - - ICompany newCompany() { - return (ICompany) pm.newInstance(Company.class); - } - - IDepartment newDepartment() { - return (IDepartment) pm.newInstance(Department.class); - } - - IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) pm.newInstance(FullTimeEmployee.class); - } - - IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) pm.newInstance(PartTimeEmployee.class); - } + }; - public Class[] getTearDownClasses() { - return tearDownClasses; - } + /** + * Creates a new instance of CompanyFactoryPMClass + * @param pm the PersistenceManager + */ + public CompanyFactoryPMClass(PersistenceManager pm) { + super(pm); + } + + ICompany newCompany() { + return (ICompany)pm.newInstance(Company.class); + } + + IDepartment newDepartment() { + return (IDepartment)pm.newInstance(Department.class); + } + + IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee)pm.newInstance(FullTimeEmployee.class); + } + + IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee)pm.newInstance(PartTimeEmployee.class); + } + + public Class[] getTearDownClasses() { + return tearDownClasses; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactoryPMInterface.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactoryPMInterface.java index c34e61b0d..c0d27fcbe 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactoryPMInterface.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactoryPMInterface.java @@ -25,41 +25,40 @@ * Created on August 29, 2005, 9:56 PM * */ -public class CompanyFactoryPMInterface extends CompanyFactoryAbstractImpl { - - /** */ - public static final Class[] tearDownClasses = - new Class[] { - IPartTimeEmployee.class, IFullTimeEmployee.class, +public class CompanyFactoryPMInterface + extends CompanyFactoryAbstractImpl { + + /** */ + public static final Class[] tearDownClasses = new Class[] { + IPartTimeEmployee.class, IFullTimeEmployee.class, IDepartment.class, ICompany.class - }; - - /** - * Creates a new instance of CompanyFactoryPMInterface - * - * @param pm the PersistenceManager - */ - public CompanyFactoryPMInterface(PersistenceManager pm) { - super(pm); - } - - ICompany newCompany() { - return (ICompany) pm.newInstance(ICompany.class); - } - - IDepartment newDepartment() { - return (IDepartment) pm.newInstance(IDepartment.class); - } - - IFullTimeEmployee newFullTimeEmployee() { - return (IFullTimeEmployee) pm.newInstance(IFullTimeEmployee.class); - } - - IPartTimeEmployee newPartTimeEmployee() { - return (IPartTimeEmployee) pm.newInstance(IPartTimeEmployee.class); - } + }; - public Class[] getTearDownClasses() { - return tearDownClasses; - } + /** + * Creates a new instance of CompanyFactoryPMInterface + * @param pm the PersistenceManager + */ + public CompanyFactoryPMInterface(PersistenceManager pm) { + super(pm); + } + + ICompany newCompany() { + return (ICompany)pm.newInstance(ICompany.class); + } + + IDepartment newDepartment() { + return (IDepartment)pm.newInstance(IDepartment.class); + } + + IFullTimeEmployee newFullTimeEmployee() { + return (IFullTimeEmployee)pm.newInstance(IFullTimeEmployee.class); + } + + IPartTimeEmployee newPartTimeEmployee() { + return (IPartTimeEmployee)pm.newInstance(IPartTimeEmployee.class); + } + + public Class[] getTearDownClasses() { + return tearDownClasses; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactoryRegistry.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactoryRegistry.java index 64d736b23..9fd7ae28f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactoryRegistry.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyFactoryRegistry.java @@ -5,25 +5,30 @@ * 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 + * + * 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.jdo.tck.pc.companyMapWithoutJoin; import java.lang.reflect.Constructor; + +import java.math.BigDecimal; + +import java.util.Date; + import javax.jdo.PersistenceManager; /* * This is the registry for company factories. It is used for the * CompletenessTest to create instances from input xml test data files. - * Factory instances that implement CompanyFactory interface are + * Factory instances that implement CompanyFactory interface are * registered (using the singleton pattern). *

    Several registration methods are available. The default factory, * which creates instances by construction, is automatically @@ -37,87 +42,99 @@ */ public class CompanyFactoryRegistry { - /** The system property for factory name */ - static final String FACTORY_PROPERTY_NAME = "jdo.tck.mapping.companyfactory"; - - /** The factory name if the system property is not set. */ - static final String DEFAULT_FACTORY_CLASS_NAME = - "org.apache.jdo.tck.pc.company.CompanyFactoryConcreteClass"; - - /** The default factory class name */ - static final String FACTORY_CLASS_NAME; - - static { - String prop = System.getProperty(FACTORY_PROPERTY_NAME); - if ((prop == null) || (prop.length() == 0)) prop = DEFAULT_FACTORY_CLASS_NAME; - FACTORY_CLASS_NAME = prop; - } - - /** - * This is the default company factory singleton. This is statically loaded regardless of the - * setting of the system property. - */ - static final CompanyFactory SINGLETON = new CompanyFactoryConcreteClass(); - - /** This is the currently registered factory. */ - static CompanyFactory instance = SINGLETON; - - /** Creates a new instance of CompanyFactoryRegistry */ - private CompanyFactoryRegistry() {} - - /** - * Get the currently registered factory. - * - * @return the factory - */ - public static CompanyFactory getInstance() { - return instance; - } - - /** Register the default factory. */ - public static void registerFactory() { - instance = SINGLETON; - } - - /** - * Register a factory using the default factory name from the system property. The factory must be - * available in the current class path and have a public constructor taking a PersistenceManager - * as a parameter. - * - * @param pm the PersistenceManager - */ - public static void registerFactory(PersistenceManager pm) { - registerFactory(FACTORY_CLASS_NAME, pm); - } - - /** - * Register a factory using the specified factoryName parameter. The factory class must be - * loadable by the current context classloader and have a public constructor taking a - * PersistenceManager as a parameter. - * - * @param factoryClassName the fully-qualified class name of the factory - * @param pm the PersistenceManager - */ - public static void registerFactory(String factoryClassName, PersistenceManager pm) { - CompanyFactory factory = null; - try { - if (factoryClassName != null) { - Class factoryClass = Class.forName(factoryClassName); - Constructor ctor = factoryClass.getConstructor(new Class[] {PersistenceManager.class}); - factory = (CompanyFactory) ctor.newInstance(new Object[] {pm}); - } - registerFactory(factory); - } catch (Exception ex) { - throw new RuntimeException("Unable to construct CompanyFactory " + factoryClassName, ex); + /** The system property for factory name + */ + final static String FACTORY_PROPERTY_NAME = + "jdo.tck.mapping.companyfactory"; + + /** The factory name if the system property is not set. + */ + final static String DEFAULT_FACTORY_CLASS_NAME = + "org.apache.jdo.tck.pc.company.CompanyFactoryConcreteClass"; + + /** + * The default factory class name + */ + final static String FACTORY_CLASS_NAME; + + static { + String prop = System.getProperty(FACTORY_PROPERTY_NAME); + if ((prop == null) || (prop.length() == 0)) + prop = DEFAULT_FACTORY_CLASS_NAME; + FACTORY_CLASS_NAME = prop; + } + + /** + * This is the default company factory singleton. This is statically + * loaded regardless of the setting of the system property. + */ + final static CompanyFactory SINGLETON = new CompanyFactoryConcreteClass(); + + /** + * This is the currently registered factory. + */ + static CompanyFactory instance = SINGLETON; + + /** + * Creates a new instance of CompanyFactoryRegistry + */ + private CompanyFactoryRegistry() { + } + + /** + * Get the currently registered factory. + * @return the factory + */ + public static CompanyFactory getInstance() { + return instance; + } + + /** Register the default factory. + */ + public static void registerFactory() { + instance = SINGLETON; + } + + /** Register a factory using the default factory name from the + * system property. The factory must be available in the current + * class path and have a public constructor + * taking a PersistenceManager as a parameter. + * @param pm the PersistenceManager + */ + public static void registerFactory(PersistenceManager pm) { + registerFactory(FACTORY_CLASS_NAME, pm); } - } - - /** - * Register the factory. - * - * @param factory the factory - */ - public static void registerFactory(CompanyFactory factory) { - instance = factory != null ? factory : SINGLETON; - } + + /** Register a factory using the specified factoryName + * parameter. The factory class must be loadable by the current context + * classloader and have a public constructor + * taking a PersistenceManager as a parameter. + * @param factoryClassName the fully-qualified class name of the factory + * @param pm the PersistenceManager + */ + public static void registerFactory(String factoryClassName, + PersistenceManager pm) { + CompanyFactory factory = null; + try { + if (factoryClassName != null) { + Class factoryClass = Class.forName(factoryClassName); + Constructor ctor = factoryClass.getConstructor(new Class[] + {PersistenceManager.class}); + factory = (CompanyFactory) + ctor.newInstance(new Object[]{pm}); + } + registerFactory(factory); + } catch (Exception ex) { + throw new RuntimeException ("Unable to construct CompanyFactory " + + factoryClassName, ex); + } + } + + /** Register the factory. + * @param factory the factory + */ + public static void registerFactory(CompanyFactory factory) { + instance = factory!=null?factory:SINGLETON; + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyModelReader.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyModelReader.java index b4b1ea762..b63d85a85 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyModelReader.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/CompanyModelReader.java @@ -5,21 +5,22 @@ * 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 + * + * 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.jdo.tck.pc.companyMapWithoutJoin; import java.util.Date; import java.util.List; import java.util.Locale; + import org.apache.jdo.tck.util.ConversionHelper; import org.apache.jdo.tck.util.JDOCustomDateEditor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -27,150 +28,157 @@ import org.springframework.core.io.ClassPathResource; /** - * Utility class to create a graph of company model instances from an xml representation. + * Utility class to create a graph of company model instances from an xml + * representation. * * @author Michael Bouschen */ public class CompanyModelReader extends DefaultListableBeanFactory { - /** The name of the root list bean. */ - public static final String ROOT_LIST_NAME = "root"; - - /** The bean-factory name in the xml input files. */ - public static final String BEAN_FACTORY_NAME = "companyFactory"; - - /** The company factory instance. */ - private CompanyFactory companyFactory; - - /** Bean definition reader */ - private final XmlBeanDefinitionReader reader; - - /** - * Create a CompanyModelReader for the specified resourceName. - * - * @param resourceName the name of the resource - */ - public CompanyModelReader(String resourceName) { - // Use the class loader of the Company class to find the resource - this(resourceName, Company.class.getClassLoader()); - } - - /** - * Create a CompanyModelReader for the specified resourceName. - * - * @param resourceName the name of the resource - * @param classLoader the ClassLoader for the lookup - */ - public CompanyModelReader(String resourceName, ClassLoader classLoader) { - super(); - configureFactory(); - this.reader = new XmlBeanDefinitionReader(this); - this.reader.loadBeanDefinitions(new ClassPathResource(resourceName, classLoader)); - } - - /** - * Returns a list of root objects. The method expects to find a bean called "root" of type list in - * the xml and returns it. - * - * @return a list of root instances - */ - public List getRootList() { - return (List) getBean(ROOT_LIST_NAME); - } - - /** - * Configure the CompanyModelReader, e.g. register CustomEditor classes to convert the string - * representation of a property into an instance of the right type. - */ - private void configureFactory() { - registerCustomEditor(Date.class, JDOCustomDateEditor.class); - companyFactory = CompanyFactoryRegistry.getInstance(); - addSingleton(BEAN_FACTORY_NAME, companyFactory); - } - - // Convenience methods - - /** - * Convenience method returning a Company instance for the specified name. The method returns - * null if there is no Company bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no Company bean. - */ - public Company getCompany(String name) { - return (Company) getBean(name, Company.class); - } - - /** - * Convenience method returning a Department instance for the specified name. The method returns - * null if there is no Department bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no Department bean. - */ - public Department getDepartment(String name) { - return (Department) getBean(name, Department.class); - } - - /** - * Convenience method returning an Employee instance for the specified name. The method returns - * null if there is no Employee bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no Employee bean. - */ - public Employee getEmployee(String name) { - return (Employee) getBean(name, Employee.class); - } - - /** - * Convenience method returning a FullTimeEmployee instance for the specified name. The method - * returns null if there is no FullTimeEmployee bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no FullTimeEmployee bean. - */ - public FullTimeEmployee getFullTimeEmployee(String name) { - return (FullTimeEmployee) getBean(name, FullTimeEmployee.class); - } - - /** - * Convenience method returning a PartTimeEmployee instance for the specified name. The method - * returns null if there is no PartTimeEmployee bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no PartTimeEmployee bean. - */ - public PartTimeEmployee getPartTimeEmployee(String name) { - return (PartTimeEmployee) getBean(name, PartTimeEmployee.class); - } - - /** - * Convenience method returning a Person instance for the specified name. The method returns - * null if there is no Person bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no Person bean. - */ - public Person getPerson(String name) { - return (Person) getBean(name, Person.class); - } - - /** - * @return Returns the tearDownClasses. - */ - public Class[] getTearDownClassesFromFactory() { - return companyFactory.getTearDownClasses(); - } - - /** - * @return Returns the tearDownClasses. - */ - public static Class[] getTearDownClasses() { - return CompanyFactoryConcreteClass.tearDownClasses; - } - - public static Date stringToUtilDate(String value) { - return ConversionHelper.toUtilDate(JDOCustomDateEditor.DATE_PATTERN, Locale.US, value); - } + /** The name of the root list bean. */ + public static final String ROOT_LIST_NAME = "root"; + + /** The bean-factory name in the xml input files. + */ + public static final String BEAN_FACTORY_NAME = "companyFactory"; + + /** The company factory instance. */ + private CompanyFactory companyFactory; + + /** Bean definition reader */ + private final XmlBeanDefinitionReader reader; + + /** + * Create a CompanyModelReader for the specified resourceName. + * @param resourceName the name of the resource + */ + public CompanyModelReader(String resourceName) { + // Use the class loader of the Company class to find the resource + this(resourceName, Company.class.getClassLoader()); + } + + /** + * Create a CompanyModelReader for the specified resourceName. + * @param resourceName the name of the resource + * @param classLoader the ClassLoader for the lookup + */ + public CompanyModelReader(String resourceName, ClassLoader classLoader) { + super(); + configureFactory(); + this.reader = new XmlBeanDefinitionReader(this); + this.reader.loadBeanDefinitions(new ClassPathResource(resourceName, classLoader)); + } + + /** + * Returns a list of root objects. The method expects to find a bean + * called "root" of type list in the xml and returns it. + * @return a list of root instances + */ + public List getRootList() { + return (List)getBean(ROOT_LIST_NAME); + } + + /** + * Configure the CompanyModelReader, e.g. register CustomEditor classes + * to convert the string representation of a property into an instance + * of the right type. + */ + private void configureFactory() { + registerCustomEditor(Date.class, JDOCustomDateEditor.class); + companyFactory = CompanyFactoryRegistry.getInstance(); + addSingleton(BEAN_FACTORY_NAME, companyFactory); + } + + // Convenience methods + + /** + * Convenience method returning a Company instance for the specified + * name. The method returns null if there is no Company + * bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * Company bean. + */ + public Company getCompany(String name) { + return (Company)getBean(name, Company.class); + } + + /** + * Convenience method returning a Department instance for the specified + * name. The method returns null if there is no Department + * bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * Department bean. + */ + public Department getDepartment(String name) { + return (Department)getBean(name, Department.class); + } + + /** + * Convenience method returning an Employee instance for the specified + * name. The method returns null if there is no Employee + * bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * Employee bean. + */ + public Employee getEmployee(String name) { + return (Employee)getBean(name, Employee.class); + } + + /** + * Convenience method returning a FullTimeEmployee instance for the + * specified name. The method returns null if there is no + * FullTimeEmployee bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * FullTimeEmployee bean. + */ + public FullTimeEmployee getFullTimeEmployee(String name) { + return (FullTimeEmployee)getBean(name, FullTimeEmployee.class); + } + + /** + * Convenience method returning a PartTimeEmployee instance for the + * specified name. The method returns null if there is no + * PartTimeEmployee bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * PartTimeEmployee bean. + */ + public PartTimeEmployee getPartTimeEmployee(String name) { + return (PartTimeEmployee)getBean(name, PartTimeEmployee.class); + } + + /** + * Convenience method returning a Person instance for the specified + * name. The method returns null if there is no Person + * bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * Person bean. + */ + public Person getPerson(String name) { + return (Person)getBean(name, Person.class); + } + + /** + * @return Returns the tearDownClasses. + */ + public Class[] getTearDownClassesFromFactory() { + return companyFactory.getTearDownClasses(); + } + + /** + * @return Returns the tearDownClasses. + */ + public static Class[] getTearDownClasses() { + return CompanyFactoryConcreteClass.tearDownClasses; + } + + public static Date stringToUtilDate(String value) { + return ConversionHelper.toUtilDate(JDOCustomDateEditor.DATE_PATTERN, Locale.US, value); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/Department.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/Department.java index 1308eead6..f8b29a2b3 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/Department.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/Department.java @@ -5,332 +5,339 @@ * 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 + * + * 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.jdo.tck.pc.companyMapWithoutJoin; import java.io.Serializable; +import java.io.ObjectInputStream; +import java.io.IOException; + +import java.util.Collections; import java.util.Comparator; import java.util.Map; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a department within a company. */ -public class Department implements IDepartment, Serializable, Comparable, Comparator, DeepEquality { - - public static final int RECOMMENDED_NO_OF_EMPS = 2; - - private long deptid; - private String name; - private Company company; - private Map roles; - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public Department() {} - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - */ - public Department(long deptid, String name) { - this.deptid = deptid; - this.name = name; - } - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - * @param company The company that the department is associated with. - */ - public Department(long deptid, String name, ICompany company) { - this.deptid = deptid; - this.name = name; - this.company = (Company) company; - } - - /** - * Construct a Department instance. - * - * @param deptid The department id. - * @param name The name of the department. - * @param company The company that the department is associated with. - * @param roles Map of employees and their roles - */ - public Department(long deptid, String name, Company company, Map roles) { - this.deptid = deptid; - this.name = name; - this.company = (Company) company; - this.roles = roles; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setDeptid(long id) { - if (this.deptid != 0) throw new IllegalStateException("Id is already set."); - this.deptid = id; - } - - /** - * Get the department id. - * - * @return The department id. - */ - public long getDeptid() { - return deptid; - } - - /** - * Get the name of the department. - * - * @return The name of the department. - */ - public String getName() { - return name; - } - - /** - * Set the name of the department. - * - * @param name The name to set for the department. - */ - public void setName(String name) { - this.name = name; - } - - /** - * Get the company associated with the department. - * - * @return The company. - */ - public ICompany getCompany() { - return company; - } - - /** - * Set the company for the department. - * - * @param company The company to associate with the department. - */ - public void setCompany(ICompany company) { - this.company = (Company) company; - } - - /** - * Get the roles in the department as an unmodifiable set. ****************** FIX?? - * - * @return The set of employees in the department, as an unmodifiable set. - */ - public Map getRoles() { - return roles; - } - - /** - * Add an role to the department. - * - * @param role The role to add to the department. - * @param emp The employee in the role - */ - public void addRole(String role, Employee emp) { - roles.put(role, emp); - } - - /** - * Remove a role from the department. - * - * @param key The key of the role to remove from the department. - */ - public void removeRole(String key) { - roles.remove(key); - } - - /** - * Set the roles to be in this department. - * - * @param roles The roles for this department. - */ - public void setRoles(Map roles) { - this.roles = roles; - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the other Department. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IDepartment otherDept = (IDepartment) other; - String where = "Department<" + deptid + ">"; - return helper.equals(deptid, otherDept.getDeptid(), where + ".deptid") - & helper.equals(name, otherDept.getName(), where + ".name") - & helper.deepEquals(roles, otherDept.getRoles(), where + ".roles") - & helper.deepEquals(company, otherDept.getCompany(), where + ".company"); - } - - /** - * Returns a String representation of a Department object. - * - * @return a String representation of a Department object. - */ - public String toString() { - return "Department(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(deptid); - rc.append(", name ").append(name); - return rc.toString(); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((IDepartment) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((IDepartment) o1, (IDepartment) o2); - } - - /** - * Compares this object with the specified Department object for order. Returns a negative - * integer, zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Department object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Department object. - */ - public int compareTo(IDepartment other) { - return compare(this, other); - } - - /** - * Compares its two IDepartment arguments for order. Returns a negative integer, zero, or a - * positive integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IDepartment object to be compared. - * @param o2 the second IDepartment object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(IDepartment o1, IDepartment o2) { - return EqualityHelper.compare(o1.getDeptid(), o2.getDeptid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof IDepartment) { - return compareTo((IDepartment) obj) == 0; +/** + * This class represents a department within a company. + */ +public class Department + implements IDepartment, Serializable, Comparable, Comparator, DeepEquality { + + public static final int RECOMMENDED_NO_OF_EMPS = 2; + + private long deptid; + private String name; + private Company company; + private Map roles; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public Department() {} + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + */ + public Department(long deptid, String name) { + this.deptid = deptid; + this.name = name; + } + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + * @param company The company that the department is associated with. + */ + public Department(long deptid, String name, ICompany company) { + this.deptid = deptid; + this.name = name; + this.company = (Company)company; + } + + /** + * Construct a Department instance. + * @param deptid The department id. + * @param name The name of the department. + * @param company The company that the department is associated with. + * @param roles Map of employees and their roles + */ + public Department(long deptid, String name, Company company, + Map roles) { + this.deptid = deptid; + this.name = name; + this.company = (Company)company; + this.roles = roles; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setDeptid(long id) { + if (this.deptid != 0) + throw new IllegalStateException("Id is already set."); + this.deptid = id; } - return false; - } - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) deptid; - } + /** + * Get the department id. + * @return The department id. + */ + public long getDeptid() { + return deptid; + } + + /** + * Get the name of the department. + * @return The name of the department. + */ + public String getName() { + return name; + } - /** The application identity class associated with the Department class. */ - public static class Oid implements Serializable, Comparable { + /** + * Set the name of the department. + * @param name The name to set for the department. + */ + public void setName(String name) { + this.name = name; + } /** - * This field represents the application identifier field for the Department class. - * It must match in name and type with the field in the Department class. + * Get the company associated with the department. + * @return The company. */ - public long deptid; + public ICompany getCompany() { + return company; + } - /** The required public, no-arg constructor. */ - public Oid() {} + /** + * Set the company for the department. + * @param company The company to associate with the department. + */ + public void setCompany(ICompany company) { + this.company = (Company)company; + } /** - * A constructor to initialize the identifier field. - * - * @param deptid the deptid of the Department. + * Get the roles in the department as an unmodifiable set. + ******************* FIX?? + * @return The set of employees in the department, as an unmodifiable + * set. */ - public Oid(long deptid) { - this.deptid = deptid; + public Map getRoles() { + return roles; } - public Oid(String s) { - deptid = Long.parseLong(justTheId(s)); + /** + * Add an role to the department. + * @param role The role to add to the department. + * @param emp The employee in the role + */ + public void addRole(String role, Employee emp) { + roles.put(role, emp); } + /** + * Remove a role from the department. + * @param key The key of the role to remove from the department. + */ + public void removeRole(String key) { + roles.remove(key); + } + + /** + * Set the roles to be in this department. + * @param roles The roles for this department. + */ + public void setRoles(Map roles) { + this.roles = roles; + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the other Department. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IDepartment otherDept = (IDepartment)other; + String where = "Department<" + deptid + ">"; + return + helper.equals(deptid, otherDept.getDeptid(), where + ".deptid") & + helper.equals(name, otherDept.getName(), where + ".name") & + helper.deepEquals(roles, otherDept.getRoles(), where + ".roles") & + helper.deepEquals(company, otherDept.getCompany(), where + ".company") ; + } + + /** + * Returns a String representation of a Department object. + * @return a String representation of a Department object. + */ public String toString() { - return this.getClass().getName() + ": " + deptid; + return "Department(" + getFieldRepr()+ ")"; } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.deptid != o.deptid) return (false); - return (true); + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(deptid); + rc.append(", name ").append(name); + return rc.toString(); } - /** */ - public int hashCode() { - return ((int) deptid); + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((IDepartment)o); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((IDepartment)o1, (IDepartment)o2); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (deptid < other.deptid) return -1; - if (deptid > other.deptid) return 1; - return 0; + /** + * Compares this object with the specified Department object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Department object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified + * Department object. + */ + public int compareTo(IDepartment other) { + return compare(this, other); } - } + + /** + * Compares its two IDepartment arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IDepartment object to be compared. + * @param o2 the second IDepartment object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(IDepartment o1, IDepartment o2) { + return EqualityHelper.compare(o1.getDeptid(), o2.getDeptid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof IDepartment) { + return compareTo((IDepartment)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)deptid; + } + + /** + * The application identity class associated with the + * Department class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the application identifier field + * for the Department class. + * It must match in name and type with the field in the + * Department class. + */ + public long deptid; + + /** + * The required public, no-arg constructor. + */ + public Oid() { } + + /** + * A constructor to initialize the identifier field. + * @param deptid the deptid of the Department. + */ + public Oid(long deptid) { + this.deptid = deptid; + } + + public Oid(String s) { deptid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + deptid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.deptid != o.deptid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) deptid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( deptid < other.deptid ) return -1; + if( deptid > other.deptid ) return 1; + return 0; + } + + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/Employee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/Employee.java index 198bd7809..85ef21a13 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/Employee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/Employee.java @@ -5,378 +5,360 @@ * 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 + * + * 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.jdo.tck.pc.companyMapWithoutJoin; -import java.io.IOException; import java.io.ObjectInputStream; +import java.io.IOException; + import java.util.Collections; import java.util.Date; import java.util.HashSet; +import java.util.Map; import java.util.Set; + +import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents an employee. */ +/** + * This class represents an employee. + */ public abstract class Employee extends Person implements IEmployee { - private Date hiredate; - private double weeklyhours; - private Department department; - private Department fundingDept; - private String role; - private Employee manager; - private Employee mentor; - private Employee protege; - private Employee hradvisor; - private transient Set team = new HashSet(); // element-type is Employee - private transient Set hradvisees = new HashSet(); // element-type is Employee - - /** This is the JDO-required no-args constructor */ - protected Employee() {} - - /** - * Construct an Employee instance. - * - * @param personid The identifier for the person. - * @param firstname The first name of the employee. - * @param lastname The last name of the employee. - * @param middlename The middle name of the employee. - * @param birthdate The birth date of the employee. - * @param hiredate The date that the employee was hired. - * @param role The role of the employee. - */ - public Employee( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - Date hiredate, - String role) { - super(personid, firstname, lastname, middlename, birthdate); - this.hiredate = hiredate; - this.role = role; - } - - /** - * Get the date that the employee was hired. - * - * @return The date the employee was hired. - */ - public Date getHiredate() { - return hiredate; - } - - /** - * Set the date that the employee was hired. - * - * @param hiredate The date the employee was hired. - */ - public void setHiredate(Date hiredate) { - this.hiredate = hiredate; - } - - /** - * Get the weekly hours of the employee. - * - * @return The number of hours per week that the employee works. - */ - public double getWeeklyhours() { - return weeklyhours; - } - - /** - * Set the number of hours per week that the employee works. - * - * @param weeklyhours The number of hours per week that the employee works. - */ - public void setWeeklyhours(double weeklyhours) { - this.weeklyhours = weeklyhours; - } - - /** - * Get the role of the employee. - * - * @return The role of th employee. - */ - public String getRole() { - return role; - } - - /** - * Set the role of the employee. - * - * @param role The role of the employee. - */ - public void setRole(String role) { - this.role = role; - } - - /** - * Get the employee's department. - * - * @return The department associated with the employee. - */ - public IDepartment getDepartment() { - return department; - } - - /** - * Set the employee's department. - * - * @param department The department. - */ - public void setDepartment(IDepartment department) { - this.department = (Department) department; - } - - /** - * Get the employee's funding department. - * - * @return The funding department associated with the employee. - */ - public IDepartment getFundingDept() { - return fundingDept; - } - - /** - * Set the employee's funding department. - * - * @param department The funding department. - */ - public void setFundingDept(IDepartment department) { - this.fundingDept = (Department) department; - } - - /** - * Get the employee's manager. - * - * @return The employee's manager. - */ - public IEmployee getManager() { - return manager; - } - - /** - * Set the employee's manager. - * - * @param manager The employee's manager. - */ - public void setManager(IEmployee manager) { - this.manager = (Employee) manager; - } - - /** - * Get the employee's team. - * - * @return The set of Employees on this employee's team, returned as an unmodifiable - * set. - */ - public Set getTeam() { - return Collections.unmodifiableSet(team); - } - - /** - * Add an Employee to this employee's team. This method sets both sides of the - * relationship, modifying this employees team to include parameter emp and modifying emp to set - * its manager attribute to this object. - * - * @param emp The Employee to add to the team. - */ - public void addToTeam(Employee emp) { - team.add(emp); - emp.manager = this; - } - - /** - * Remove an Employee from this employee's team. This method will also set the - * emp manager to null. - * - * @param emp The Employee to remove from the team. - */ - public void removeFromTeam(Employee emp) { - team.remove(emp); - emp.manager = null; - } - - /** - * Set the employee's team. - * - * @param team The set of Employees. - */ - public void setTeam(Set team) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.team = (team != null) ? new HashSet(team) : null; - } - - /** - * Set the mentor for this employee. - * - * @param mentor The mentor for this employee. - */ - public void setMentor(IEmployee mentor) { - this.mentor = (Employee) mentor; - } - - /** - * Get the mentor for this employee. - * - * @return The mentor. - */ - public IEmployee getMentor() { - return mentor; - } - - /** - * Set the protege for this employee. - * - * @param protege The protege for this employee. - */ - public void setProtege(IEmployee protege) { - this.protege = (Employee) protege; - } - - /** - * Get the protege of this employee. - * - * @return The protege of this employee. - */ - public IEmployee getProtege() { - return protege; - } - - /** - * Set the HR advisor for this employee. - * - * @param hradvisor The hradvisor for this employee. - */ - public void setHradvisor(IEmployee hradvisor) { - this.hradvisor = (Employee) hradvisor; - } - - /** - * Get the HR advisor for the employee. - * - * @return The HR advisor. - */ - public IEmployee getHradvisor() { - return hradvisor; - } - - /** - * Get the HR advisees of this HR advisor. - * - * @return An unmodifiable Set containing the Employees that are HR - * advisees of this employee. - */ - public Set getHradvisees() { - return Collections.unmodifiableSet(hradvisees); - } - - /** - * Add an Employee as an advisee of this HR advisor. This method also sets the - * emp hradvisor to reference this object. In other words, both sides of the relationship - * are set. - * - * @param emp The employee to add as an advisee. - */ - public void addAdvisee(Employee emp) { - hradvisees.add(emp); - emp.hradvisor = this; - } - - /** - * Remove an Employee as an advisee of this HR advisor. This method also sets the - * emp hradvisor to null. In other words, both sides of the relationship are set. - * - * @param emp The employee to add as an HR advisee. - */ - public void removeAdvisee(Employee emp) { - hradvisees.remove(emp); - emp.hradvisor = null; - } - - /** - * Set the HR advisees of this HR advisor. - * - * @param hradvisees The Employees that are HR advisees of this employee. - */ - public void setHradvisees(Set hradvisees) { - // workaround: create a new HashSet, because fostore does not - // support LinkedHashSet - this.hradvisees = (hradvisees != null) ? new HashSet(hradvisees) : null; - } - - /** - * Serialization support: initialize transient fields. - * - * @param in stream - * @throws IOException error during reading - * @throws ClassNotFoundException class could not be found - */ - private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { - in.defaultReadObject(); - team = new HashSet(); - hradvisees = new HashSet(); - } - - /** - * Return a String representation of a Employee object. - * - * @return a String representation of a Employee object. - */ - public String toString() { - return "Employee(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", hired ").append(hiredate == null ? "null" : formatter.format(hiredate)); - rc.append(", weeklyhours ").append(weeklyhours); - rc.append(", role ").append(role); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the - * corresponding fields of the specified Employee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IEmployee otherEmp = (IEmployee) other; - String where = "Employee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.equals(hiredate, otherEmp.getHiredate(), where + ".hiredate") - & helper.closeEnough(weeklyhours, otherEmp.getWeeklyhours(), where + ".weeklyhours") - & helper.equals(role, otherEmp.getRole(), where + ".role") - & helper.deepEquals(department, otherEmp.getDepartment(), where + ".department") - & helper.deepEquals(fundingDept, otherEmp.getFundingDept(), where + ".fundingDept") - & helper.deepEquals(manager, otherEmp.getManager(), where + ".manager") - & helper.deepEquals(mentor, otherEmp.getMentor(), where + ".mentor") - & helper.deepEquals(protege, otherEmp.getProtege(), where + ".protege") - & helper.deepEquals(hradvisor, otherEmp.getHradvisor(), where + ".hradvisor") - & helper.deepEquals(team, otherEmp.getTeam(), where + ".team") - & helper.deepEquals(hradvisees, otherEmp.getHradvisees(), where + ".hradvisees"); - } + private Date hiredate; + private double weeklyhours; + private Department department; + private Department fundingDept; + private String role; + private Employee manager; + private Employee mentor; + private Employee protege; + private Employee hradvisor; + private transient Set team = new HashSet(); // element-type is Employee + private transient Set hradvisees = new HashSet(); // element-type is Employee + + /** This is the JDO-required no-args constructor */ + protected Employee() {} + + /** + * Construct an Employee instance. + * @param personid The identifier for the person. + * @param firstname The first name of the employee. + * @param lastname The last name of the employee. + * @param middlename The middle name of the employee. + * @param birthdate The birth date of the employee. + * @param hiredate The date that the employee was hired. + * @param role The role of the employee. + */ + public Employee(long personid, String firstname, String lastname, + String middlename, Date birthdate, + Date hiredate, String role) { + super(personid, firstname, lastname, middlename, birthdate); + this.hiredate = hiredate; + this.role = role; + } + + /** + * Get the date that the employee was hired. + * @return The date the employee was hired. + */ + public Date getHiredate() { + return hiredate; + } + + /** + * Set the date that the employee was hired. + * @param hiredate The date the employee was hired. + */ + public void setHiredate(Date hiredate) { + this.hiredate = hiredate; + } + + /** + * Get the weekly hours of the employee. + * @return The number of hours per week that the employee works. + */ + public double getWeeklyhours() { + return weeklyhours; + } + + /** + * Set the number of hours per week that the employee works. + * @param weeklyhours The number of hours per week that the employee + * works. + */ + public void setWeeklyhours(double weeklyhours) { + this.weeklyhours = weeklyhours; + } + + /** + * Get the role of the employee. + * @return The role of th employee. + */ + public String getRole() { + return role; + } + + /** + * Set the role of the employee. + * @param role The role of the employee. + */ + public void setRole(String role) { + this.role=role; + } + + /** + * Get the employee's department. + * @return The department associated with the employee. + */ + public IDepartment getDepartment() { + return department; + } + + /** + * Set the employee's department. + * @param department The department. + */ + public void setDepartment(IDepartment department) { + this.department = (Department)department; + } + + /** + * Get the employee's funding department. + * @return The funding department associated with the employee. + */ + public IDepartment getFundingDept() { + return fundingDept; + } + + /** + * Set the employee's funding department. + * @param department The funding department. + */ + public void setFundingDept(IDepartment department) { + this.fundingDept = (Department)department; + } + + /** + * Get the employee's manager. + * @return The employee's manager. + */ + public IEmployee getManager() { + return manager; + } + + /** + * Set the employee's manager. + * @param manager The employee's manager. + */ + public void setManager(IEmployee manager) { + this.manager = (Employee)manager; + } + + /** + * Get the employee's team. + * @return The set of Employees on this employee's team, + * returned as an unmodifiable set. + */ + public Set getTeam() { + return Collections.unmodifiableSet(team); + } + + /** + * Add an Employee to this employee's team. + * This method sets both sides of the relationship, modifying + * this employees team to include parameter emp and modifying + * emp to set its manager attribute to this object. + * @param emp The Employee to add to the team. + */ + public void addToTeam(Employee emp) { + team.add(emp); + emp.manager = this; + } + + /** + * Remove an Employee from this employee's team. + * This method will also set the emp manager to null. + * @param emp The Employee to remove from the team. + */ + public void removeFromTeam(Employee emp) { + team.remove(emp); + emp.manager = null; + } + + /** + * Set the employee's team. + * @param team The set of Employees. + */ + public void setTeam(Set team) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.team = (team != null) ? new HashSet(team) : null; + } + + /** + * Set the mentor for this employee. + * @param mentor The mentor for this employee. + */ + public void setMentor(IEmployee mentor) { + this.mentor = (Employee)mentor; + } + + /** + * Get the mentor for this employee. + * @return The mentor. + */ + public IEmployee getMentor() { + return mentor; + } + + /** + * Set the protege for this employee. + * @param protege The protege for this employee. + */ + public void setProtege(IEmployee protege) { + this.protege = (Employee)protege; + } + + /** + * Get the protege of this employee. + * @return The protege of this employee. + */ + public IEmployee getProtege() { + return protege; + } + + /** + * Set the HR advisor for this employee. + * @param hradvisor The hradvisor for this employee. + */ + public void setHradvisor(IEmployee hradvisor) { + this.hradvisor = (Employee)hradvisor; + } + + /** + * Get the HR advisor for the employee. + * @return The HR advisor. + */ + public IEmployee getHradvisor() { + return hradvisor; + } + + /** + * Get the HR advisees of this HR advisor. + * @return An unmodifiable Set containing the + * Employees that are HR advisees of this employee. + */ + public Set getHradvisees() { + return Collections.unmodifiableSet(hradvisees); + } + + /** + * Add an Employee as an advisee of this HR advisor. + * This method also sets the emp hradvisor to reference + * this object. In other words, both sides of the relationship are + * set. + * @param emp The employee to add as an advisee. + */ + public void addAdvisee(Employee emp) { + hradvisees.add(emp); + emp.hradvisor = this; + } + + /** + * Remove an Employee as an advisee of this HR advisor. + * This method also sets the emp hradvisor to null. + * In other words, both sides of the relationship are set. + * @param emp The employee to add as an HR advisee. + */ + public void removeAdvisee(Employee emp) { + hradvisees.remove(emp); + emp.hradvisor = null; + } + + /** + * Set the HR advisees of this HR advisor. + * @param hradvisees The Employees that are HR advisees of + * this employee. + */ + public void setHradvisees(Set hradvisees) { + // workaround: create a new HashSet, because fostore does not + // support LinkedHashSet + this.hradvisees = (hradvisees != null) ? new HashSet(hradvisees) : null; + } + + /** + * Serialization support: initialize transient fields. + * @param in stream + * @throws IOException error during reading + * @throws ClassNotFoundException class could not be found + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException { + in.defaultReadObject(); + team = new HashSet(); + hradvisees = new HashSet(); + } + + /** + * Return a String representation of a Employee object. + * @return a String representation of a Employee object. + */ + public String toString() { + return "Employee(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", hired ").append( + hiredate==null ? "null" : formatter.format(hiredate)); + rc.append(", weeklyhours ").append(weeklyhours); + rc.append(", role ").append(role); + return rc.toString(); + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the corresponding fields of the specified Employee. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IEmployee otherEmp = (IEmployee)other; + String where = "Employee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.equals(hiredate, otherEmp.getHiredate(), where + ".hiredate") & + helper.closeEnough(weeklyhours, otherEmp.getWeeklyhours(), where + ".weeklyhours") & + helper.equals(role, otherEmp.getRole(), where + ".role") & + helper.deepEquals(department, otherEmp.getDepartment(), where + ".department") & + helper.deepEquals(fundingDept, otherEmp.getFundingDept(), where + ".fundingDept") & + helper.deepEquals(manager, otherEmp.getManager(), where + ".manager") & + helper.deepEquals(mentor, otherEmp.getMentor(), where + ".mentor") & + helper.deepEquals(protege, otherEmp.getProtege(), where + ".protege") & + helper.deepEquals(hradvisor, otherEmp.getHradvisor(), where + ".hradvisor") & + helper.deepEquals(team, otherEmp.getTeam(), where + ".team") & + helper.deepEquals(hradvisees, otherEmp.getHradvisees(), where + ".hradvisees"); + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/FullTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/FullTimeEmployee.java index 29cad80b0..5a9d88910 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/FullTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/FullTimeEmployee.java @@ -5,110 +5,106 @@ * 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 + * + * 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.jdo.tck.pc.companyMapWithoutJoin; import java.util.Date; + +import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a full-time employee. */ +/** + * This class represents a full-time employee. + */ public class FullTimeEmployee extends Employee implements IFullTimeEmployee { - private double salary; - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FullTimeEmployee() {} - - /** - * Construct a full-time employee. - * - * @param personid The person identifier. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param hired The date that the person was hired. - * @param role The person's role - * @param sal The salary of the full-time employee. - */ - public FullTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - Date hired, - String role, - double sal) { - super(personid, first, last, middle, born, hired, role); - salary = sal; - } + private double salary; - /** - * Get the salary of the full time employee. - * - * @return The salary of the full time employee. - */ - public double getSalary() { - return salary; - } + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FullTimeEmployee() {} - /** - * Set the salary for the full-time employee. - * - * @param salary The salary to set for the full-time employee. - */ - public void setSalary(double salary) { - this.salary = salary; - } + /** + * Construct a full-time employee. + * @param personid The person identifier. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param hired The date that the person was hired. + * @param role The person's role + * @param sal The salary of the full-time employee. + */ + public FullTimeEmployee(long personid, String first, String last, + String middle, Date born, + Date hired, String role, double sal) { + super(personid, first, last, middle, born, hired, role); + salary = sal; + } - /** - * Return a String representation of a FullTimeEmployee object. - * - * @return a String representation of a FullTimeEmployee object. - */ - public String toString() { - return "FullTimeEmployee(" + getFieldRepr() + ")"; - } + /** + * Get the salary of the full time employee. + * @return The salary of the full time employee. + */ + public double getSalary() { + return salary; + } + + /** + * Set the salary for the full-time employee. + * @param salary The salary to set for the full-time employee. + */ + public void setSalary(double salary) { + this.salary = salary; + } + + /** + * Return a String representation of a FullTimeEmployee object. + * @return a String representation of a FullTimeEmployee object. + */ + public String toString() { + return "FullTimeEmployee(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - public String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", $").append(salary); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + public String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", $").append(salary); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified FullTimeEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IFullTimeEmployee otherEmp = (IFullTimeEmployee) other; - String where = "FullTimeEmployee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.closeEnough(salary, otherEmp.getSalary(), where + ".salary"); - } + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified + * FullTimeEmployee. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IFullTimeEmployee otherEmp = (IFullTimeEmployee)other; + String where = "FullTimeEmployee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.closeEnough(salary, otherEmp.getSalary(), where + ".salary"); + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/ICompany.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/ICompany.java index 158549cb0..dcdba8f15 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/ICompany.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/ICompany.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -21,24 +21,19 @@ import java.util.Set; /** - * This interface represents the persistent state of Company. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Company. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface ICompany { - - long getCompanyid(); - - Set getDepartments(); - - Date getFounded(); - - String getName(); - - void setCompanyid(long id); - - void setDepartments(Set depts); - - void setFounded(Date date); - - void setName(String string); + + long getCompanyid(); + Set getDepartments(); + Date getFounded(); + String getName(); + + void setCompanyid(long id); + void setDepartments(Set depts); + void setFounded(Date date); + void setName(String string); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/IDepartment.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/IDepartment.java index 615bafd7b..30a2e2122 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/IDepartment.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/IDepartment.java @@ -5,39 +5,34 @@ * 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 + * + * 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.jdo.tck.pc.companyMapWithoutJoin; import java.util.Map; /** - * This interface represents the persistent state of Department. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Department. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IDepartment { - long getDeptid(); - - String getName(); - - ICompany getCompany(); - - Map getRoles(); - - void setDeptid(long deptid); - - void setName(String name); - - void setCompany(ICompany company); - - void setRoles(Map roles); + long getDeptid(); + String getName(); + ICompany getCompany(); + Map getRoles(); + + void setDeptid(long deptid); + void setName(String name); + void setCompany(ICompany company); + void setRoles(Map roles); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/IEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/IEmployee.java index 1827c4cc7..8d3f117d6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/IEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/IEmployee.java @@ -5,68 +5,50 @@ * 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 + * + * 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.jdo.tck.pc.companyMapWithoutJoin; import java.util.Date; import java.util.Set; /** - * This interface represents the persistent state of Employee. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Employee. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IEmployee extends IPerson { - Date getHiredate(); - - double getWeeklyhours(); - - String getRole(); - - IDepartment getDepartment(); - - IDepartment getFundingDept(); - - IEmployee getManager(); - - Set getTeam(); - - IEmployee getMentor(); - - IEmployee getProtege(); - - IEmployee getHradvisor(); - - Set getHradvisees(); - - void setHiredate(Date hiredate); - - void setWeeklyhours(double weeklyhours); - - void setRole(String role); - - void setDepartment(IDepartment department); - - void setFundingDept(IDepartment department); - - void setManager(IEmployee manager); - - void setTeam(Set team); - - void setMentor(IEmployee mentor); - - void setProtege(IEmployee protege); - - void setHradvisor(IEmployee hradvisor); - - void setHradvisees(Set hradvisees); + Date getHiredate(); + double getWeeklyhours(); + String getRole(); + IDepartment getDepartment(); + IDepartment getFundingDept(); + IEmployee getManager(); + Set getTeam(); + IEmployee getMentor(); + IEmployee getProtege(); + IEmployee getHradvisor(); + Set getHradvisees(); + + void setHiredate(Date hiredate); + void setWeeklyhours(double weeklyhours); + void setRole(String role); + void setDepartment(IDepartment department); + void setFundingDept(IDepartment department); + void setManager(IEmployee manager); + void setTeam(Set team); + void setMentor(IEmployee mentor); + void setProtege(IEmployee protege); + void setHradvisor(IEmployee hradvisor); + void setHradvisees(Set hradvisees); + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/IFullTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/IFullTimeEmployee.java index 54492b30b..69ca49fa9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/IFullTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/IFullTimeEmployee.java @@ -5,25 +5,25 @@ * 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 + * + * 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.jdo.tck.pc.companyMapWithoutJoin; /** - * This interface represents the persistent state of FullTimeEmployee. Javadoc was deliberately - * omitted because it would distract from the purpose of the interface. + * This interface represents the persistent state of FullTimeEmployee. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IFullTimeEmployee extends IEmployee { - double getSalary(); - - void setSalary(double salary); + double getSalary(); + void setSalary(double salary); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/IPartTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/IPartTimeEmployee.java index cce38027f..5bbdb71c6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/IPartTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/IPartTimeEmployee.java @@ -5,25 +5,25 @@ * 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 + * + * 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.jdo.tck.pc.companyMapWithoutJoin; /** - * This interface represents the persistent state of PartTimeEmployee. Javadoc was deliberately - * omitted because it would distract from the purpose of the interface. + * This interface represents the persistent state of PartTimeEmployee. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IPartTimeEmployee extends IEmployee { - double getWage(); - - void setWage(double wage); + double getWage(); + void setWage(double wage); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/IPerson.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/IPerson.java index 1a4062757..3d80ad40e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/IPerson.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/IPerson.java @@ -5,43 +5,38 @@ * 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 + * + * 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.jdo.tck.pc.companyMapWithoutJoin; import java.util.Date; +import java.util.Map; /** - * This interface represents the persistent state of Person. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Person. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IPerson { - long getPersonid(); - - String getLastname(); - - String getFirstname(); - - String getMiddlename(); - - Date getBirthdate(); - - void setPersonid(long personid); - - void setLastname(String lastname); - - void setFirstname(String firstname); - - void setMiddlename(String middlename); + long getPersonid(); + String getLastname(); + String getFirstname(); + String getMiddlename(); + Date getBirthdate(); + + void setPersonid(long personid); + void setLastname(String lastname); + void setFirstname(String firstname); + void setMiddlename(String middlename); + void setBirthdate(Date birthdate); - void setBirthdate(Date birthdate); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/PartTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/PartTimeEmployee.java index 0fba36f1a..1e129809e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/PartTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/PartTimeEmployee.java @@ -5,109 +5,104 @@ * 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 + * + * 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.jdo.tck.pc.companyMapWithoutJoin; import java.util.Date; + +import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a part-time employee. */ +/** + * This class represents a part-time employee. + */ public class PartTimeEmployee extends Employee implements IPartTimeEmployee { - private double wage; + private double wage; - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public PartTimeEmployee() {} + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PartTimeEmployee() {} - /** - * Construct a part-time employee. - * - * @param personid The identifier for the person. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param hired The date the person was hired. - * @param role The person's role - * @param wage The person's wage. - */ - public PartTimeEmployee( - long personid, - String first, - String last, - String middle, - Date born, - Date hired, - String role, - double wage) { - super(personid, first, last, middle, born, hired, role); - this.wage = wage; - } + /** + * Construct a part-time employee. + * @param personid The identifier for the person. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param hired The date the person was hired. + * @param role The person's role + * @param wage The person's wage. + */ + public PartTimeEmployee(long personid, String first, String last, + String middle, Date born, + Date hired, String role, double wage ) { + super(personid, first, last, middle, born, hired, role); + this.wage = wage; + } - /** - * Get the wage of the part-time employee. - * - * @return The wage of the part-time employee. - */ - public double getWage() { - return wage; - } + /** + * Get the wage of the part-time employee. + * @return The wage of the part-time employee. + */ + public double getWage() { + return wage; + } - /** - * Set the wage of the part-time employee. - * - * @param wage The wage of the part-time employee. - */ - public void setWage(double wage) { - this.wage = wage; - } + /** + * Set the wage of the part-time employee. + * @param wage The wage of the part-time employee. + */ + public void setWage(double wage) { + this.wage = wage; + } - /** - * Returns a String representation of a PartTimeEmployee object. - * - * @return a String representation of a PartTimeEmployee object. - */ - public String toString() { - return "PartTimeEmployee(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of a PartTimeEmployee object. + * @return a String representation of a PartTimeEmployee object. + */ + public String toString() { + return "PartTimeEmployee(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - public String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", $" + wage); - return rc.toString(); - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + public String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", $" + wage); + return rc.toString(); + } - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified PartTimeEmployee. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IPartTimeEmployee otherEmp = (IPartTimeEmployee) other; - String where = "PartTimeEmployee<" + getPersonid() + ">"; - return super.deepCompareFields(otherEmp, helper) - & helper.closeEnough(wage, otherEmp.getWage(), where + ".wage"); - } + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified + * PartTimeEmployee. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IPartTimeEmployee otherEmp = (IPartTimeEmployee)other; + String where = "PartTimeEmployee<" + getPersonid() + ">"; + return super.deepCompareFields(otherEmp, helper) & + helper.closeEnough(wage, otherEmp.getWage(), where + ".wage"); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/Person.java b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/Person.java index 77d3de164..8f1258703 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/Person.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/companyMapWithoutJoin/Person.java @@ -5,322 +5,327 @@ * 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 + * + * 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.jdo.tck.pc.companyMapWithoutJoin; import java.io.Serializable; + import java.text.SimpleDateFormat; + +import java.util.Collections; import java.util.Comparator; import java.util.Date; +import java.util.HashMap; +import java.util.Map; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; -/** This class represents a person. */ -public class Person implements IPerson, Serializable, Comparable, Comparator, DeepEquality { - - private long personid; - private String firstname; - private String lastname; - private String middlename; - private Date birthdate; - - protected static SimpleDateFormat formatter = new SimpleDateFormat("d/MMM/yyyy"); - - /** This is the JDO-required no-args constructor. */ - protected Person() {} - - /** - * Construct a Person instance. - * - * @param personid The person identifier. - * @param firstname The person's first name. - * @param lastname The person's last name. - * @param middlename The person's middle name. - * @param birthdate The person's birthdate. - */ - public Person( - long personid, String firstname, String lastname, String middlename, Date birthdate) { - this.personid = personid; - this.firstname = firstname; - this.lastname = lastname; - this.middlename = middlename; - this.birthdate = birthdate; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setPersonid(long id) { - if (this.personid != 0) throw new IllegalStateException("Id is already set."); - this.personid = id; - } - - /** - * Get the person's id. - * - * @return The personid. - */ - public long getPersonid() { - return personid; - } - - /** - * Set the person's id. - * - * @param personid The personid. - */ - public void setLastname(long personid) { - this.personid = personid; - } - - /** - * Get the person's last name. - * - * @return The last name. - */ - public String getLastname() { - return lastname; - } - - /** - * Set the person's last name. - * - * @param lastname The last name. - */ - public void setLastname(String lastname) { - this.lastname = lastname; - } - - /** - * Get the person's first name. - * - * @return The first name. - */ - public String getFirstname() { - return firstname; - } - - /** - * Set the person's first name. - * - * @param firstname The first name. - */ - public void setFirstname(String firstname) { - this.firstname = firstname; - } - - /** - * Get the person's middle name. - * - * @return The middle name. - */ - public String getMiddlename() { - return middlename; - } - - /** - * Set the person's middle name. - * - * @param middlename The middle name. - */ - public void setMiddlename(String middlename) { - this.middlename = middlename; - } - - /** - * Get the person's birthdate. - * - * @return The person's birthdate. - */ - public Date getBirthdate() { - return birthdate; - } - - /** - * Set the person's birthdate. - * - * @param birthdate The person's birthdate. - */ - public void setBirthdate(Date birthdate) { - this.birthdate = birthdate; - } - - /** - * Returns a String representation of a Person object. - * - * @return a string representation of a Person object. - */ - public String toString() { - return "Person(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(personid); - rc.append(", ").append(lastname); - rc.append(", ").append(firstname); - rc.append(", born ").append(birthdate == null ? "null" : formatter.format(birthdate)); - return rc.toString(); - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - IPerson otherPerson = (IPerson) other; - String where = "Person<" + personid + ">"; - return helper.equals(personid, otherPerson.getPersonid(), where + ".personid") - & helper.equals(firstname, otherPerson.getFirstname(), where + ".firstname") - & helper.equals(lastname, otherPerson.getLastname(), where + ".lastname") - & helper.equals(middlename, otherPerson.getMiddlename(), where + ".middlename") - & helper.equals(birthdate, otherPerson.getBirthdate(), where + ".birthdate"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((IPerson) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((IPerson) o1, (IPerson) o2); - } - - /** - * Compares this object with the specified Person object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Person object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Person object. - */ - public int compareTo(IPerson other) { - return compare(this, other); - } - - /** - * Compares its two IPerson arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first IPerson object to be compared. - * @param o2 the second IPerson object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(IPerson o1, IPerson o2) { - return EqualityHelper.compare(o1.getPersonid(), o2.getPersonid()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof IPerson) { - return compareTo((IPerson) obj) == 0; +/** + * This class represents a person. + */ +public class Person + implements IPerson, Serializable, Comparable, Comparator, DeepEquality { + + private long personid; + private String firstname; + private String lastname; + private String middlename; + private Date birthdate; + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. */ + protected Person() {} + + /** + * Construct a Person instance. + * @param personid The person identifier. + * @param firstname The person's first name. + * @param lastname The person's last name. + * @param middlename The person's middle name. + * @param birthdate The person's birthdate. + */ + public Person(long personid, String firstname, String lastname, + String middlename, Date birthdate) { + this.personid = personid; + this.firstname = firstname; + this.lastname = lastname; + this.middlename = middlename; + this.birthdate = birthdate; } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) personid; - } - /** - * This class is used to represent the application identifier for the Person class. - */ - public static class Oid implements Serializable, Comparable { /** - * This field represents the identifier for the Person class. It must match a field - * in the Person class in both name and type. + * Set the id associated with this object. + * @param id the id. */ - public long personid; + public void setPersonid(long id) { + if (this.personid != 0) + throw new IllegalStateException("Id is already set."); + this.personid = id; + } - /** The required public no-arg constructor. */ - public Oid() {} + /** + * Get the person's id. + * @return The personid. + */ + public long getPersonid() { + return personid; + } /** - * Initialize the identifier. - * - * @param personid The person identifier. + * Set the person's id. + * @param personid The personid. + */ + public void setLastname(long personid) { + this.personid = personid; + } + + /** + * Get the person's last name. + * @return The last name. + */ + public String getLastname() { + return lastname; + } + + /** + * Set the person's last name. + * @param lastname The last name. + */ + public void setLastname(String lastname) { + this.lastname = lastname; + } + + /** + * Get the person's first name. + * @return The first name. */ - public Oid(long personid) { - this.personid = personid; + public String getFirstname() { + return firstname; } - public Oid(String s) { - personid = Long.parseLong(justTheId(s)); + /** + * Set the person's first name. + * @param firstname The first name. + */ + public void setFirstname(String firstname) { + this.firstname = firstname; } + /** + * Get the person's middle name. + * @return The middle name. + */ + public String getMiddlename() { + return middlename; + } + + /** + * Set the person's middle name. + * @param middlename The middle name. + */ + public void setMiddlename(String middlename) { + this.middlename = middlename; + } + + /** + * Get the person's birthdate. + * @return The person's birthdate. + */ + public Date getBirthdate() { + return birthdate; + } + + /** + * Set the person's birthdate. + * @param birthdate The person's birthdate. + */ + public void setBirthdate(Date birthdate) { + this. birthdate = birthdate; + } + + /** + * Returns a String representation of a Person object. + * @return a string representation of a Person object. + */ public String toString() { - return this.getClass().getName() + ": " + personid; + return "Person(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(personid); + rc.append(", ").append(lastname); + rc.append(", ").append(firstname); + rc.append(", born ").append( + birthdate==null ? "null" : formatter.format(birthdate)); + return rc.toString(); } - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.personid != o.personid) return (false); - return (true); + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + IPerson otherPerson = (IPerson)other; + String where = "Person<" + personid + ">"; + return + helper.equals(personid, otherPerson.getPersonid(), where + ".personid") & + helper.equals(firstname, otherPerson.getFirstname(), where + ".firstname") & + helper.equals(lastname, otherPerson.getLastname(), where + ".lastname") & + helper.equals(middlename, otherPerson.getMiddlename(), where + ".middlename") & + helper.equals(birthdate, otherPerson.getBirthdate(), where + ".birthdate") ; } - /** */ - public int hashCode() { - return ((int) personid); + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((IPerson)o); } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((IPerson)o1, (IPerson)o2); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (personid < other.personid) return -1; - if (personid > other.personid) return 1; - return 0; + /** + * Compares this object with the specified Person object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Person object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Person + * object. + */ + public int compareTo(IPerson other) { + return compare(this, other); } - } + + /** + * Compares its two IPerson arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first IPerson object to be compared. + * @param o2 the second IPerson object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(IPerson o1, IPerson o2) { + return EqualityHelper.compare(o1.getPersonid(), o2.getPersonid()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof IPerson) { + return compareTo((IPerson)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)personid; + } + /** + * This class is used to represent the application identifier + * for the Person class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field represents the identifier for the Person + * class. It must match a field in the Person class in + * both name and type. + */ + public long personid; + + /** + * The required public no-arg constructor. + */ + public Oid() { } + + /** + * Initialize the identifier. + * @param personid The person identifier. + */ + public Oid(long personid) { + this.personid = personid; + } + + public Oid(String s) { personid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + personid;} + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || + !this.getClass().equals(obj.getClass()) ) return( false ); + Oid o = (Oid) obj; + if( this.personid != o.personid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) personid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( personid < other.personid ) return -1; + if( personid > other.personid ) return 1; + return 0; + } + + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/compositeAnnotation/ApplicationIdDiscriminatorClassName.java b/tck/src/main/java/org/apache/jdo/tck/pc/compositeAnnotation/ApplicationIdDiscriminatorClassName.java index 93d7b601d..5a1fc32a5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/compositeAnnotation/ApplicationIdDiscriminatorClassName.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/compositeAnnotation/ApplicationIdDiscriminatorClassName.java @@ -5,32 +5,27 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.compositeAnnotation; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.jdo.annotations.DiscriminatorStrategy; import javax.jdo.annotations.IdentityType; +import javax.jdo.annotations.DiscriminatorStrategy; @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) -@javax.jdo.annotations.PersistenceCapable( - detachable = "true", - identityType = IdentityType.APPLICATION) -@javax.jdo.annotations.Discriminator( - strategy = DiscriminatorStrategy.CLASS_NAME, - column = "DISCRIMINATOR", - indexed = "true") -public @interface ApplicationIdDiscriminatorClassName {} +@javax.jdo.annotations.PersistenceCapable(detachable="true", identityType=IdentityType.APPLICATION) +@javax.jdo.annotations.Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, column="DISCRIMINATOR", indexed="true") + +public @interface ApplicationIdDiscriminatorClassName { } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/converter/IPCPoint.java b/tck/src/main/java/org/apache/jdo/tck/pc/converter/IPCPoint.java index 3b0124708..f1c552991 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/converter/IPCPoint.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/converter/IPCPoint.java @@ -17,15 +17,13 @@ package org.apache.jdo.tck.pc.converter; /** - * Interface for common methods of implementation classes PCPoint, PCPointAnnotated, PCPointProp and - * PCPointPropAnnotated. + * Interface for common methods of implementation classes PCPoint, PCPointAnnotated, + * PCPointProp and PCPointPropAnnotated. */ public interface IPCPoint { - int getX(); + int getX(); + void setX(int x); - void setX(int x); - - Integer getY(); - - void setY(Integer y); + Integer getY(); + void setY(Integer y); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/converter/IPCRect.java b/tck/src/main/java/org/apache/jdo/tck/pc/converter/IPCRect.java index f8b220923..e5e40f6dd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/converter/IPCRect.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/converter/IPCRect.java @@ -18,13 +18,13 @@ import org.apache.jdo.tck.pc.mylib.Point; -/** Interface for common methods of implementation classes PCRect and PCRectAnnotated. */ +/** + * Interface for common methods of implementation classes PCRect and PCRectAnnotated. + */ public interface IPCRect { - Point getUpperLeft(); - - void setUpperLeft(Point upperLeft); - - Point getLowerRight(); + Point getUpperLeft(); + void setUpperLeft(Point upperLeft); - void setLowerRight(Point lowerRight); + Point getLowerRight(); + void setLowerRight(Point lowerRight); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCPoint.java b/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCPoint.java index 10f5d6e5c..13686f0f8 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCPoint.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCPoint.java @@ -15,51 +15,47 @@ * limitations under the License. */ package org.apache.jdo.tck.pc.converter; - import java.util.Date; /** - * PersistenceCapable class to test JDO AttributeConverter interface. Its fields of type int and - * Integer are converted to strings in the datastore. + * PersistenceCapable class to test JDO AttributeConverter interface. + * Its fields of type int and Integer are converted to strings in the datastore. */ public class PCPoint implements IPCPoint { - private static long counter = new Date().getTime(); - - private static synchronized long newId() { - return counter++; - } - - private long id = newId(); - private int x; - private Integer y; - - public PCPoint() {} - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public int getX() { - return x; - } - - public void setX(int x) { - this.x = x; - } - - public Integer getY() { - return y; - } - - public void setY(Integer y) { - this.y = y; - } - - public String toString() { - return this.getClass().getName() + "(x: " + x + " / y: " + y + ")"; - } + private static long counter = new Date().getTime(); + + private static synchronized long newId() { + return counter++; + } + + private long id = newId(); + private int x; + private Integer y; + + public PCPoint() {} + + public long getId() { + return id; + } + public void setId(long id) { + this.id = id; + } + + public int getX() { + return x; + } + public void setX(int x) { + this.x = x; + } + + public Integer getY() { + return y; + } + public void setY(Integer y) { + this.y = y; + } + + public String toString() { + return this.getClass().getName() + "(x: " + x + " / y: " + y + ")"; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCPointAnnotated.java b/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCPointAnnotated.java index 560045b6f..26265c061 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCPointAnnotated.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCPointAnnotated.java @@ -16,62 +16,60 @@ */ package org.apache.jdo.tck.pc.converter; -import java.util.Date; +import org.apache.jdo.tck.util.IntegerToStringConverter; + import javax.jdo.annotations.Column; import javax.jdo.annotations.Convert; import javax.jdo.annotations.PersistenceCapable; -import org.apache.jdo.tck.util.IntegerToStringConverter; +import java.util.Date; /** - * PersistenceCapable class to test JDO AttributeConverter interface. Its fields of type int and - * Integer are converted to strings in the datastore. + * PersistenceCapable class to test JDO AttributeConverter interface. + * Its fields of type int and Integer are converted to strings in the datastore. */ -@PersistenceCapable(table = "PCPointConv") +@PersistenceCapable(table="PCPointConv") public class PCPointAnnotated implements IPCPoint { - private static long counter = new Date().getTime(); - - private static synchronized long newId() { - return counter++; - } - - @Column(name = "ID") - private long id = newId(); - - @Column(name = "X") - @Convert(value = IntegerToStringConverter.class) - private int x; + private static long counter = new Date().getTime(); - @Column(name = "Y") - @Convert(value = IntegerToStringConverter.class) - private Integer y; + private static synchronized long newId() { + return counter++; + } - public PCPointAnnotated() {} + @Column(name="ID") + private long id = newId(); - public long getId() { - return id; - } + @Column(name="X") + @Convert(value = IntegerToStringConverter.class) + private int x; - public void setId(long id) { - this.id = id; - } + @Column(name="Y") + @Convert(value = IntegerToStringConverter.class) + private Integer y; - public int getX() { - return x; - } + public PCPointAnnotated() {} - public void setX(int x) { - this.x = x; - } + public long getId() { + return id; + } + public void setId(long id) { + this.id = id; + } - public Integer getY() { - return y; - } + public int getX() { + return x; + } + public void setX(int x ) { + this.x = x; + } - public void setY(Integer y) { - this.y = y; - } + public Integer getY() { + return y; + } + public void setY(Integer y) { + this.y = y; + } - public String toString() { - return this.getClass().getName() + "(x: " + x + " / y: " + y + ")"; - } + public String toString() { + return this.getClass().getName() + "(x: " + x + " / y: " + y + ")"; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCPointProp.java b/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCPointProp.java index 3f37992cd..58ee56fd1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCPointProp.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCPointProp.java @@ -15,51 +15,47 @@ * limitations under the License. */ package org.apache.jdo.tck.pc.converter; - import java.util.Date; /** - * PersistenceCapable class to test JDO AttributeConverter interface. Its fields of type int and - * Integer are converted to strings in the datastore. + * PersistenceCapable class to test JDO AttributeConverter interface. + * Its fields of type int and Integer are converted to strings in the datastore. */ public class PCPointProp implements IPCPoint { - private static long counter = new Date().getTime(); - - private static synchronized long newId() { - return counter++; - } - - private long id = newId(); - private int x; - private Integer y; - - public PCPointProp() {} - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public int getX() { - return x; - } - - public void setX(int x) { - this.x = x; - } - - public Integer getY() { - return y; - } - - public void setY(Integer y) { - this.y = y; - } - - public String toString() { - return this.getClass().getName() + "(x: " + x + " / y: " + y + ")"; - } + private static long counter = new Date().getTime(); + + private static synchronized long newId() { + return counter++; + } + + private long id = newId(); + private int x; + private Integer y; + + public PCPointProp() {} + + public long getId() { + return id; + } + public void setId(long id) { + this.id = id; + } + + public int getX() { + return x; + } + public void setX(int x) { + this.x = x; + } + + public Integer getY() { + return y; + } + public void setY(Integer y) { + this.y = y; + } + + public String toString() { + return this.getClass().getName() + "(x: " + x + " / y: " + y + ")"; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCPointPropAnnotated.java b/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCPointPropAnnotated.java index 34e332c93..48dee76e6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCPointPropAnnotated.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCPointPropAnnotated.java @@ -16,60 +16,58 @@ */ package org.apache.jdo.tck.pc.converter; -import java.util.Date; +import org.apache.jdo.tck.util.IntegerToStringConverter; + import javax.jdo.annotations.Column; import javax.jdo.annotations.Convert; import javax.jdo.annotations.PersistenceCapable; -import org.apache.jdo.tck.util.IntegerToStringConverter; +import java.util.Date; /** - * PersistenceCapable class to test JDO AttributeConverter interface. Its fields of type int and - * Integer are converted to strings in the datastore. + * PersistenceCapable class to test JDO AttributeConverter interface. + * Its fields of type int and Integer are converted to strings in the datastore. */ -@PersistenceCapable(table = "PCPointConv") +@PersistenceCapable(table="PCPointConv") public class PCPointPropAnnotated implements IPCPoint { - private static long counter = new Date().getTime(); - - private static synchronized long newId() { - return counter++; - } - - private long id = newId(); - private int x; - private Integer y; - - public PCPointPropAnnotated() {} + private static long counter = new Date().getTime(); - @Column(name = "ID") - public long getId() { - return id; - } + private static synchronized long newId() { + return counter++; + } - public void setId(long id) { - this.id = id; - } + private long id = newId(); + private int x; + private Integer y; - @Column(name = "X") - @Convert(value = IntegerToStringConverter.class) - public int getX() { - return x; - } + public PCPointPropAnnotated() {} - public void setX(int x) { - this.x = x; - } + @Column(name="ID") + public long getId() { + return id; + } + public void setId(long id) { + this.id = id; + } - @Column(name = "Y") - @Convert(value = IntegerToStringConverter.class) - public Integer getY() { - return y; - } + @Column(name="X") + @Convert(value = IntegerToStringConverter.class) + public int getX() { + return x; + } + public void setX(int x ) { + this.x = x; + } - public void setY(Integer y) { - this.y = y; - } + @Column(name="Y") + @Convert(value = IntegerToStringConverter.class) + public Integer getY() { + return y; + } + public void setY(Integer y) { + this.y = y; + } - public String toString() { - return this.getClass().getName() + "(x: " + x + " / y: " + y + ")"; - } + public String toString() { + return this.getClass().getName() + "(x: " + x + " / y: " + y + ")"; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCRect.java b/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCRect.java index 66a3c2cbb..d071843df 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCRect.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCRect.java @@ -16,63 +16,58 @@ */ package org.apache.jdo.tck.pc.converter; -import java.util.Date; import org.apache.jdo.tck.pc.mylib.Point; +import java.util.Date; + /** - * PersistenceCapable class to test JDO AttributeConverter interface. Its fields of type Point are - * converted to strings in the datastore. + * PersistenceCapable class to test JDO AttributeConverter interface. + * Its fields of type Point are converted to strings in the datastore. */ public class PCRect implements IPCRect { - private static long counter = new Date().getTime(); - - private static synchronized long newId() { - return counter++; - } + private static long counter = new Date().getTime(); - private long id = newId(); - private Point upperLeft; - private Point lowerRight; - - public PCRect() {} - - public long getId() { - return id; - } + private static synchronized long newId() { + return counter++; + } - public void setId(long id) { - this.id = id; - } + private long id = newId(); + private Point upperLeft; + private Point lowerRight; - public Point getUpperLeft() { - return upperLeft; - } + public PCRect() {} - public void setUpperLeft(Point upperLeft) { - this.upperLeft = upperLeft; - } + public long getId() { + return id; + } + public void setId(long id) { + this.id = id; + } - public Point getLowerRight() { - return lowerRight; - } + public Point getUpperLeft() { + return upperLeft; + } + public void setUpperLeft(Point upperLeft) { + this.upperLeft = upperLeft; + } - public void setLowerRight(Point lowerRight) { - this.lowerRight = lowerRight; - } + public Point getLowerRight() { + return lowerRight; + } + public void setLowerRight(Point lowerRight) { + this.lowerRight = lowerRight; + } - public String toString() { - String rc = null; - Object obj = this; - try { - rc = - obj.getClass().getName() - + " ul: " - + getUpperLeft().name() - + " lr: " - + getLowerRight().name(); - } catch (NullPointerException ex) { - rc = "NPE getting PCRect's values"; + public String toString() { + String rc = null; + Object obj = this; + try { + rc = obj.getClass().getName() + + " ul: " + getUpperLeft().name() + + " lr: " + getLowerRight().name(); + } catch (NullPointerException ex) { + rc = "NPE getting PCRect's values"; + } + return rc; } - return rc; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCRectAnnotated.java b/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCRectAnnotated.java index c173f273e..380bc54d6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCRectAnnotated.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/converter/PCRectAnnotated.java @@ -16,75 +16,70 @@ */ package org.apache.jdo.tck.pc.converter; -import java.util.Date; +import org.apache.jdo.tck.pc.mylib.Point; +import org.apache.jdo.tck.util.PointToStringConverter; + import javax.jdo.annotations.Column; import javax.jdo.annotations.Convert; import javax.jdo.annotations.PersistenceCapable; -import org.apache.jdo.tck.pc.mylib.Point; -import org.apache.jdo.tck.util.PointToStringConverter; +import java.util.Date; /** - * PersistenceCapable class to test JDO AttributeConverter interface. Its fields of type Point are - * converted to strings in the datastore. + * PersistenceCapable class to test JDO AttributeConverter interface. + * Its fields of type Point are converted to strings in the datastore. */ -@PersistenceCapable(table = "PCRectConv") +@PersistenceCapable(table="PCRectConv") public class PCRectAnnotated implements IPCRect { - private static long counter = new Date().getTime(); - - private static synchronized long newId() { - return counter++; - } - - @Column(name = "ID") - private long id = newId(); + private static long counter = new Date().getTime(); - @Column(name = "UPPER_LEFT") - @Convert(value = PointToStringConverter.class) - private Point upperLeft; - - @Column(name = "LOWER_RIGHT") - @Convert(value = PointToStringConverter.class) - private Point lowerRight; + private static synchronized long newId() { + return counter++; + } - public PCRectAnnotated() {} + @Column(name="ID") + private long id = newId(); - public long getId() { - return id; - } + @Column(name="UPPER_LEFT") + @Convert(value = PointToStringConverter.class) + private Point upperLeft; - public void setId(long id) { - this.id = id; - } + @Column(name="LOWER_RIGHT") + @Convert(value = PointToStringConverter.class) + private Point lowerRight; - public Point getUpperLeft() { - return upperLeft; - } + public PCRectAnnotated() {} - public void setUpperLeft(Point upperLeft) { - this.upperLeft = upperLeft; - } + public long getId() { + return id; + } + public void setId(long id) { + this.id = id; + } - public Point getLowerRight() { - return lowerRight; - } + public Point getUpperLeft() { + return upperLeft; + } + public void setUpperLeft(Point upperLeft) { + this.upperLeft = upperLeft; + } - public void setLowerRight(Point lowerRight) { - this.lowerRight = lowerRight; - } + public Point getLowerRight() { + return lowerRight; + } + public void setLowerRight(Point lowerRight) { + this.lowerRight = lowerRight; + } - public String toString() { - String rc = null; - Object obj = this; - try { - rc = - obj.getClass().getName() - + " ul: " - + getUpperLeft().name() - + " lr: " - + getLowerRight().name(); - } catch (NullPointerException ex) { - rc = "NPE getting PCRectAnnotated's values"; + public String toString() { + String rc = null; + Object obj = this; + try { + rc = obj.getClass().getName() + + " ul: " + getUpperLeft().name() + + " lr: " + getLowerRight().name(); + } catch (NullPointerException ex) { + rc = "NPE getting PCRectAnnotated's values"; + } + return rc; } - return rc; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/AllTypes.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/AllTypes.java index 94d651b52..95ea440d0 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/AllTypes.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/AllTypes.java @@ -5,461 +5,313 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.Calendar; import java.util.Date; -import java.util.GregorianCalendar; import java.util.Locale; +import java.util.GregorianCalendar; +import java.util.Calendar; import java.util.TimeZone; -import javax.jdo.PersistenceManager; -import javax.jdo.Transaction; +import java.math.BigDecimal; +import java.math.BigInteger; + +import javax.jdo.*; public class AllTypes { - private int id; - private boolean fld_boolean; - private byte fld_byte; - private char fld_char; - private double fld_double; - private float fld_float; - private int fld_int; - private long fld_long; - private short fld_short; - - private Boolean fld_Boolean; - private Byte fld_Byte; - private Character fld_Character; - private Double fld_Double; - private Float fld_Float; - private Integer fld_Integer; - private Long fld_Long; - private Short fld_Short; - - private String fld_String; - private Locale fld_Locale; - private Date fld_Date; - private BigDecimal fld_BigDecimal; - private BigInteger fld_BigInteger; - - public static int veryLargePositiveInt = Integer.MAX_VALUE - 511; - public static int veryLargeNegativeInt = Integer.MIN_VALUE + 512; - - public static int NUM_VALUES = 10; // should equal number of elements in the following arrays - // DO NOT CHANGE THE FOLLOWING VALUES, OR MANY LINES OF CODE IN TESTS MUST CHANGE!!! - public static final boolean[] boolean_values = { - false, true, true, false, true, false, false, false, true, false - }; - public static final byte[] byte_values = { - Byte.MIN_VALUE, Byte.MAX_VALUE, 0, -100, 100, -10, 10, 50, 50, 75 - }; - public static final char[] char_values = { - Character.MIN_VALUE, Character.MAX_VALUE, ' ', 'A', 'z', 'B', 'F', 'z', 'M', 'M' - }; - public static final double DOUBLE_SMALLEST = -9999999999999.9; - public static final double DOUBLE_LARGEST = 9999999999999.9; - public static final double[] double_values = { - DOUBLE_SMALLEST, - DOUBLE_LARGEST, - 0.0, - 100.0, - 100.0, - 50000000.0, - -234234.234, - 1000000000.0, - 350.5, - -25.5 - }; - public static final float FLOAT_SMALLEST = -999999999999.9f; - public static final float FLOAT_LARGEST = 999999999999.9f; - public static final float[] float_values = { - FLOAT_SMALLEST, - FLOAT_LARGEST, - 0.0f, - 100.0f, - 100.0f, - 50000000.0f, - -234.23f, - 1000000000.0f, - 350.5f, - -25.5f - }; - public static final int[] int_values = { - veryLargeNegativeInt, veryLargePositiveInt, 0, 100, 100, 1000, -1000, 1000000, -1000000, 10000 - }; - public static final long[] long_values = { - Long.MIN_VALUE, Long.MAX_VALUE, 0, 100, 100, 1000, -1000, 1000000, -1000, -1000000 - }; - public static final short[] short_values = { - Short.MIN_VALUE, Short.MAX_VALUE, 0, 100, 100, 1000, -1000, 10000, -10000, -500 - }; - - public static final Boolean[] Boolean_values = { - false, true, true, false, true, - false, false, false, true, false - }; - public static final Byte[] Byte_values = { - Byte.MIN_VALUE, - Byte.MAX_VALUE, - (byte) 0, - (byte) -100, - (byte) 100, - (byte) -10, - (byte) 10, - (byte) 50, - (byte) 50, - (byte) 75 - }; - public static final Character[] Character_values = { - Character.MIN_VALUE, Character.MAX_VALUE, ' ', 'A', 'z', 'B', 'F', 'z', 'M', 'M' - }; - public static final Double[] Double_values = { - DOUBLE_SMALLEST, - DOUBLE_LARGEST, - 0.0, - 100.0, - 100.0, - 50000000.0, - -234234.234, - 1000000000.0, - 350.5, - -25.5 - }; - public static final Float[] Float_values = { - FLOAT_SMALLEST, - FLOAT_LARGEST, - 0.0f, - 100.0f, - 100.0f, - 50000000.0f, - 234234.234f, - 1000000000.0f, - 350.5f, - -25.5f - }; - public static final Integer[] Integer_values = { - veryLargeNegativeInt, veryLargePositiveInt, 0, 10000, 100, 100, 1000000, -1000000, -1000, 1000 - }; - public static final Long[] Long_values = { - Long.MIN_VALUE, Long.MAX_VALUE, 0L, 100L, -1000L, 1000L, -1000L, 1000000L, 100L, -1000000L - }; - public static final Short[] Short_values = { - Short.MIN_VALUE, - Short.MAX_VALUE, - (short) 0, - (short) 100, - (short) 100, - (short) 1000, - (short) -1000, - (short) 10000, - (short) -10000, - (short) -500 - }; - - public static final String[] String_values = { - new String(""), new String("hello world"), - new String("JDO has a very nice persistence API"), new String("JDO"), - new String("Java"), new String("abcde"), - new String("abcdef"), new String("JDO is a breeze to use"), - new String("Java"), new String("Long-live JDO") - }; - public static final Locale[] Locale_values = { - Locale.US, Locale.UK, Locale.FRANCE, Locale.GERMANY, Locale.CANADA, - Locale.JAPAN, Locale.ITALY, Locale.CHINA, Locale.KOREA, Locale.TAIWAN - }; - - public static final BigDecimal[] BigDecimal_values = { - new BigDecimal("24323423423.234234"), new BigDecimal("-1123123.22"), - new BigDecimal("100.0"), new BigDecimal("100.0"), - new BigDecimal("0"), new BigDecimal("123232.22"), - new BigDecimal("-234234.23333"), new BigDecimal("98345983475.23"), - new BigDecimal("-23.000034"), new BigDecimal("989899.98889") - }; - public static final BigInteger[] BigInteger_values = { - new BigInteger("-999999999999999999"), new BigInteger("987034534985043985"), - new BigInteger("0"), new BigInteger("39582"), - new BigInteger("39582"), new BigInteger("1000000000"), - new BigInteger("-1000000000"), new BigInteger("153"), - new BigInteger("-27345"), new BigInteger("1333330") - }; - - public static final Date[] Date_values = new Date[10]; - - static { - GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.UK); - gc.clear(); - gc.set(1999, Calendar.DECEMBER, 31, 9, 0, 0); - Date_values[0] = gc.getTime(); - gc.set(1957, Calendar.FEBRUARY, 1, 9, 0, 0); - Date_values[1] = gc.getTime(); - gc.set(2032, Calendar.MARCH, 15, 9, 0, 0); - Date_values[2] = gc.getTime(); - gc.set(1957, Calendar.FEBRUARY, 1, 9, 0, 0); - Date_values[3] = gc.getTime(); - gc.set(1995, Calendar.JUNE, 14, 9, 0, 0); - Date_values[4] = gc.getTime(); - gc.set(1992, Calendar.NOVEMBER, 22, 9, 0, 0); - Date_values[5] = gc.getTime(); - gc.set(1900, Calendar.JANUARY, 1, 9, 0, 0); - Date_values[6] = gc.getTime(); - gc.set(2015, Calendar.SEPTEMBER, 15, 9, 0, 0); - Date_values[7] = gc.getTime(); - gc.set(1979, Calendar.AUGUST, 12, 9, 0, 0); - Date_values[8] = gc.getTime(); - gc.set(1979, Calendar.AUGUST, 13, 9, 0, 0); - Date_values[9] = gc.getTime(); - } - - public AllTypes() { + private int id; + private boolean fld_boolean; + private byte fld_byte; + private char fld_char; + private double fld_double; + private float fld_float; + private int fld_int; + private long fld_long; + private short fld_short; + + private Boolean fld_Boolean; + private Byte fld_Byte; + private Character fld_Character; + private Double fld_Double; + private Float fld_Float; + private Integer fld_Integer; + private Long fld_Long; + private Short fld_Short; + + private String fld_String; + private Locale fld_Locale; + private Date fld_Date; + private BigDecimal fld_BigDecimal; + private BigInteger fld_BigInteger; + + public static int veryLargePositiveInt = Integer.MAX_VALUE - 511; + public static int veryLargeNegativeInt = Integer.MIN_VALUE + 512; + + public static int NUM_VALUES = 10; // should equal number of elements in the following arrays + // DO NOT CHANGE THE FOLLOWING VALUES, OR MANY LINES OF CODE IN TESTS MUST CHANGE!!! + public static final boolean[] boolean_values = + { false, true, true, false, true, false, false, false, true, false }; + public static final byte[] byte_values = + { Byte.MIN_VALUE, Byte.MAX_VALUE, 0, -100, 100, -10, 10, 50, 50, 75 }; + public static final char[] char_values = + { Character.MIN_VALUE, Character.MAX_VALUE, ' ', 'A', 'z', 'B', 'F', 'z', 'M', 'M'}; + public static final double DOUBLE_SMALLEST = -9999999999999.9; + public static final double DOUBLE_LARGEST = 9999999999999.9; + public static final double[] double_values = + { DOUBLE_SMALLEST, DOUBLE_LARGEST, 0.0, 100.0, 100.0, + 50000000.0, -234234.234, 1000000000.0, 350.5, -25.5 }; + public static final float FLOAT_SMALLEST = -999999999999.9f; + public static final float FLOAT_LARGEST = 999999999999.9f; + public static final float[] float_values = + { FLOAT_SMALLEST, FLOAT_LARGEST, 0.0f, 100.0f, 100.0f, + 50000000.0f, -234.23f, 1000000000.0f, 350.5f, -25.5f }; + public static final int[] int_values = + { veryLargeNegativeInt, veryLargePositiveInt, 0, 100, 100, 1000, -1000, 1000000, -1000000, 10000}; + public static final long[] long_values = + { Long.MIN_VALUE, Long.MAX_VALUE, 0, 100, 100, 1000, -1000, 1000000, -1000, -1000000}; + public static final short[] short_values = + { Short.MIN_VALUE, Short.MAX_VALUE, 0, 100, 100, 1000, -1000, 10000, -10000, -500}; + + public static final Boolean[] Boolean_values = { + false, true, true, false, true, + false, false, false, true, false + }; + public static final Byte[] Byte_values = { + Byte.MIN_VALUE, Byte.MAX_VALUE, (byte)0, (byte)-100, (byte)100, + (byte)-10, (byte)10, (byte)50, (byte)50, (byte)75 + }; + public static final Character[] Character_values = { + Character.MIN_VALUE, Character.MAX_VALUE, ' ', 'A', 'z', 'B', 'F', 'z', 'M', 'M' + }; + public static final Double[] Double_values = { + DOUBLE_SMALLEST, DOUBLE_LARGEST, + 0.0, 100.0, + 100.0, 50000000.0, + -234234.234, 1000000000.0, + 350.5, -25.5 + }; + public static final Float[] Float_values = { + FLOAT_SMALLEST, FLOAT_LARGEST, + 0.0f, 100.0f, + 100.0f, 50000000.0f, + 234234.234f, 1000000000.0f, + 350.5f, -25.5f + }; + public static final Integer[] Integer_values = { + veryLargeNegativeInt, veryLargePositiveInt, + 0, 10000, + 100, 100, + 1000000, -1000000, + -1000, 1000 + }; + public static final Long[] Long_values = { + Long.MIN_VALUE, Long.MAX_VALUE, + 0L, 100L, + -1000L, 1000L, + -1000L, 1000000L, + 100L, -1000000L + }; + public static final Short[] Short_values = { + Short.MIN_VALUE, Short.MAX_VALUE, + (short)0, (short)100, + (short)100, (short)1000, + (short)-1000, (short)10000, + (short)-10000, (short)-500 + }; + + public static final String[] String_values = { + new String(""), new String("hello world"), + new String("JDO has a very nice persistence API"), new String("JDO"), + new String("Java"), new String("abcde"), + new String("abcdef"), new String("JDO is a breeze to use"), + new String("Java"), new String("Long-live JDO") + }; + public static final Locale[] Locale_values = { + Locale.US, Locale.UK, Locale.FRANCE, Locale.GERMANY, Locale.CANADA, + Locale.JAPAN, Locale.ITALY, Locale.CHINA, Locale.KOREA, Locale.TAIWAN + }; + + public static final BigDecimal[] BigDecimal_values = { + new BigDecimal("24323423423.234234"), new BigDecimal("-1123123.22"), + new BigDecimal("100.0"), new BigDecimal("100.0"), + new BigDecimal("0"), new BigDecimal("123232.22"), + new BigDecimal("-234234.23333"), new BigDecimal("98345983475.23"), + new BigDecimal("-23.000034"), new BigDecimal("989899.98889") + }; + public static final BigInteger[] BigInteger_values = { + new BigInteger("-999999999999999999"), new BigInteger("987034534985043985"), + new BigInteger("0"), new BigInteger("39582"), + new BigInteger("39582"), new BigInteger("1000000000"), + new BigInteger("-1000000000"), new BigInteger("153"), + new BigInteger("-27345"), new BigInteger("1333330") + }; + + public static final Date[] Date_values = new Date[10]; + static { + GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.UK); + gc.clear(); + gc.set(1999, Calendar.DECEMBER, 31, 9, 0, 0); + Date_values[0] = gc.getTime(); + gc.set(1957, Calendar.FEBRUARY, 1, 9, 0, 0); + Date_values[1] = gc.getTime(); + gc.set(2032, Calendar.MARCH, 15, 9, 0, 0); + Date_values[2] = gc.getTime(); + gc.set(1957, Calendar.FEBRUARY, 1, 9, 0, 0); + Date_values[3] = gc.getTime(); + gc.set(1995, Calendar.JUNE, 14, 9, 0, 0); + Date_values[4] = gc.getTime(); + gc.set(1992, Calendar.NOVEMBER, 22, 9, 0, 0); + Date_values[5] = gc.getTime(); + gc.set(1900, Calendar.JANUARY, 1, 9, 0, 0); + Date_values[6] = gc.getTime(); + gc.set(2015, Calendar.SEPTEMBER, 15, 9, 0, 0); + Date_values[7] = gc.getTime(); + gc.set(1979, Calendar.AUGUST, 12, 9, 0, 0); + Date_values[8] = gc.getTime(); + gc.set(1979, Calendar.AUGUST, 13, 9, 0, 0); + Date_values[9] = gc.getTime(); + } + +public AllTypes() +{ id = 0; - } - - public AllTypes(int id) { - this.id = id; - } +} - public void setId(int id) { +public AllTypes(int id) +{ this.id = id; - } - - public boolean getboolean() { - return fld_boolean; - } - - public void setboolean(boolean b) { - fld_boolean = b; - } - - public byte getbyte() { - return fld_byte; - } - - public void setbyte(byte b) { - fld_byte = b; - } - - public char getchar() { - return fld_char; - } - - public void setchar(char c) { - fld_char = c; - } - - public double getdouble() { - return fld_double; - } - - public void setdouble(double d) { - fld_double = d; - } - - public float getfloat() { - return fld_float; - } - - public void setfloat(float f) { - fld_float = f; - } - - public int getint() { - return fld_int; - } - - public void setint(int i) { - fld_int = i; - } - - public long getlong() { - return fld_long; - } - - public void setlong(long l) { - fld_long = l; - } - - public short getshort() { - return fld_short; - } - - public void setshort(short s) { - fld_short = s; - } - - public Boolean getBoolean() { - return fld_Boolean; - } - - public void setBoolean(Boolean b) { - fld_Boolean = b; - } - - public Byte getByte() { - return fld_Byte; - } - - public void setByte(Byte b) { - fld_Byte = b; - } +} - public Character getCharacter() { - return fld_Character; - } +public void setId(int id) { this.id = id; } +public boolean getboolean() { return fld_boolean;} +public void setboolean(boolean b) { fld_boolean = b;} - public void setCharacter(Character c) { - fld_Character = c; - } +public byte getbyte() { return fld_byte;} +public void setbyte(byte b) { fld_byte = b;} - public Double getDouble() { - return fld_Double; - } +public char getchar() { return fld_char;} +public void setchar(char c) { fld_char = c;} - public void setDouble(Double d) { - fld_Double = d; - } +public double getdouble() { return fld_double;} +public void setdouble(double d) { fld_double = d;} - public Float getFloat() { - return fld_Float; - } +public float getfloat() { return fld_float;} +public void setfloat(float f) { fld_float = f;} - public void setFloat(Float f) { - fld_Float = f; - } +public int getint() { return fld_int;} +public void setint(int i) { fld_int = i;} - public Integer getInteger() { - return fld_Integer; - } +public long getlong() { return fld_long;} +public void setlong(long l) { fld_long = l;} - public void setInteger(Integer i) { - fld_Integer = i; - } +public short getshort() { return fld_short;} +public void setshort(short s) { fld_short = s;} - public Long getLong() { - return fld_Long; - } +public Boolean getBoolean() { return fld_Boolean;} +public void setBoolean(Boolean b) { fld_Boolean = b;} - public void setLong(Long l) { - fld_Long = l; - } +public Byte getByte() { return fld_Byte;} +public void setByte(Byte b) { fld_Byte = b;} - public Short getShort() { - return fld_Short; - } +public Character getCharacter() { return fld_Character;} +public void setCharacter(Character c){ fld_Character = c;} - public void setShort(Short s) { - fld_Short = s; - } +public Double getDouble() { return fld_Double;} +public void setDouble(Double d) { fld_Double = d;} - public String getString() { - return fld_String; - } +public Float getFloat() { return fld_Float;} +public void setFloat(Float f) { fld_Float = f;} - public void setString(String s) { - fld_String = s; - } +public Integer getInteger() { return fld_Integer;} +public void setInteger(Integer i) { fld_Integer = i;} - public Locale getLocale() { - return fld_Locale; - } +public Long getLong() { return fld_Long;} +public void setLong(Long l) { fld_Long = l;} - public void setLocale(Locale l) { - fld_Locale = l; - } +public Short getShort() { return fld_Short;} +public void setShort(Short s) { fld_Short = s;} - public Date getDate() { - return fld_Date; - } +public String getString() { return fld_String;} +public void setString(String s) { fld_String = s;} - public void setDate(Date d) { - fld_Date = d; - } +public Locale getLocale() { return fld_Locale;} +public void setLocale(Locale l) { fld_Locale = l;} - public BigDecimal getBigDecimal() { - return fld_BigDecimal; - } +public Date getDate() { return fld_Date;} +public void setDate(Date d) { fld_Date = d;} - public void setBigDecimal(BigDecimal bd) { - fld_BigDecimal = bd; - } +public BigDecimal getBigDecimal() { return fld_BigDecimal;} +public void setBigDecimal(BigDecimal bd) { fld_BigDecimal = bd;} - public BigInteger getBigInteger() { - return fld_BigInteger; - } +public BigInteger getBigInteger() { return fld_BigInteger;} +public void setBigInteger(BigInteger bi) { fld_BigInteger = bi;} - public void setBigInteger(BigInteger bi) { - fld_BigInteger = bi; - } - public static void load(PersistenceManager pm) { +public static void load(PersistenceManager pm) +{ Transaction t = pm.currentTransaction(); t.begin(); - for (int i = 0; i < NUM_VALUES; ++i) { - AllTypes o = new AllTypes(i); - pm.makePersistent(o); - o.setboolean(boolean_values[i]); - o.setBoolean(Boolean_values[i]); - o.setbyte(byte_values[i]); - o.setByte(Byte_values[i]); - o.setchar(char_values[i]); - o.setCharacter(Character_values[i]); - o.setdouble(double_values[i]); - o.setDouble(Double_values[i]); - o.setfloat(float_values[i]); - o.setFloat(Float_values[i]); - o.setint(int_values[i]); - o.setInteger(Integer_values[i]); - o.setlong(long_values[i]); - o.setLong(Long_values[i]); - o.setshort(short_values[i]); - o.setShort(Short_values[i]); - o.setString(String_values[i]); - o.setLocale(Locale_values[i]); - o.setDate(Date_values[i]); - o.setBigDecimal(BigDecimal_values[i]); - o.setBigInteger(BigInteger_values[i]); + for( int i = 0; i < NUM_VALUES; ++i){ + AllTypes o = new AllTypes(i); + pm.makePersistent(o); + o.setboolean(boolean_values[i]); + o.setBoolean(Boolean_values[i]); + o.setbyte(byte_values[i]); + o.setByte(Byte_values[i]); + o.setchar(char_values[i]); + o.setCharacter(Character_values[i]); + o.setdouble(double_values[i]); + o.setDouble(Double_values[i]); + o.setfloat(float_values[i]); + o.setFloat(Float_values[i]); + o.setint(int_values[i]); + o.setInteger(Integer_values[i]); + o.setlong(long_values[i]); + o.setLong(Long_values[i]); + o.setshort(short_values[i]); + o.setShort(Short_values[i]); + o.setString(String_values[i]); + o.setLocale(Locale_values[i]); + o.setDate(Date_values[i]); + o.setBigDecimal(BigDecimal_values[i]); + o.setBigInteger(BigInteger_values[i]); } - t.commit(); - } + t.commit(); +} - public static class Oid implements Serializable { - public int id; + public static class Oid implements Serializable { + public int id; - public Oid() {} + public Oid() { + } - public Oid(String s) { - id = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { id = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + id; - } + public String toString() { return this.getClass().getName() + ": " + id;} - public int hashCode() { - return (int) id; - } + public int hashCode() { return (int)id ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.id == this.id; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.id == this.id; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/ArrayCollections.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/ArrayCollections.java index 00c9da90d..30004c2bf 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/ArrayCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/ArrayCollections.java @@ -5,294 +5,291 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.Date; -import java.util.Locale; +import java.util.*; +import java.math.*; public class ArrayCollections { public int identifier; - public Object[] ArrayOfObject0; - public Object[] ArrayOfObject1; - public SimpleClass[] ArrayOfSimpleClass2; - public SimpleClass[] ArrayOfSimpleClass3; - public SimpleInterface[] ArrayOfSimpleInterface4; - public SimpleInterface[] ArrayOfSimpleInterface5; - public String[] ArrayOfString6; - public String[] ArrayOfString7; - public Date[] ArrayOfDate8; - public Date[] ArrayOfDate9; - public Locale[] ArrayOfLocale10; - public Locale[] ArrayOfLocale11; - public BigDecimal[] ArrayOfBigDecimal12; - public BigDecimal[] ArrayOfBigDecimal13; - public BigInteger[] ArrayOfBigInteger14; - public BigInteger[] ArrayOfBigInteger15; - public Byte[] ArrayOfByte16; - public Byte[] ArrayOfByte17; - public Double[] ArrayOfDouble18; - public Double[] ArrayOfDouble19; - public Float[] ArrayOfFloat20; - public Float[] ArrayOfFloat21; - public Integer[] ArrayOfInteger22; - public Integer[] ArrayOfInteger23; - public Long[] ArrayOfLong24; - public Long[] ArrayOfLong25; - public Short[] ArrayOfShort26; - public Short[] ArrayOfShort27; - public SimpleEnum[] ArrayOfSimpleEnum28; - public SimpleEnum[] ArrayOfSimpleEnum29; - public SimpleEnum[] ArrayOfSimpleEnum30; + public Object [] ArrayOfObject0; + public Object [] ArrayOfObject1; + public SimpleClass [] ArrayOfSimpleClass2; + public SimpleClass [] ArrayOfSimpleClass3; + public SimpleInterface [] ArrayOfSimpleInterface4; + public SimpleInterface [] ArrayOfSimpleInterface5; + public String [] ArrayOfString6; + public String [] ArrayOfString7; + public Date [] ArrayOfDate8; + public Date [] ArrayOfDate9; + public Locale [] ArrayOfLocale10; + public Locale [] ArrayOfLocale11; + public BigDecimal [] ArrayOfBigDecimal12; + public BigDecimal [] ArrayOfBigDecimal13; + public BigInteger [] ArrayOfBigInteger14; + public BigInteger [] ArrayOfBigInteger15; + public Byte [] ArrayOfByte16; + public Byte [] ArrayOfByte17; + public Double [] ArrayOfDouble18; + public Double [] ArrayOfDouble19; + public Float [] ArrayOfFloat20; + public Float [] ArrayOfFloat21; + public Integer [] ArrayOfInteger22; + public Integer [] ArrayOfInteger23; + public Long [] ArrayOfLong24; + public Long [] ArrayOfLong25; + public Short [] ArrayOfShort26; + public Short [] ArrayOfShort27; + public SimpleEnum [] ArrayOfSimpleEnum28; + public SimpleEnum [] ArrayOfSimpleEnum29; + public SimpleEnum [] ArrayOfSimpleEnum30; - public static final String[] fieldSpecs = { - "serialized=true public Object [] ArrayOfObject0", - "embedded-element=false public Object [] ArrayOfObject1", - "serialized=true public SimpleClass [] ArrayOfSimpleClass2", - "embedded-element=false public SimpleClass [] ArrayOfSimpleClass3", - "serialized=true public SimpleInterface [] ArrayOfSimpleInterface4", - "embedded-element=false public SimpleInterface [] ArrayOfSimpleInterface5", - "embedded-element=false public String [] ArrayOfString6", - "embedded-element=true public String [] ArrayOfString7", - "embedded-element=false public Date [] ArrayOfDate8", - "embedded-element=true public Date [] ArrayOfDate9", - "embedded-element=false public Locale [] ArrayOfLocale10", - "embedded-element=true public Locale [] ArrayOfLocale11", - "embedded-element=false public BigDecimal [] ArrayOfBigDecimal12", - "embedded-element=true public BigDecimal [] ArrayOfBigDecimal13", - "embedded-element=false public BigInteger [] ArrayOfBigInteger14", - "embedded-element=true public BigInteger [] ArrayOfBigInteger15", - "embedded-element=false public Byte [] ArrayOfByte16", - "embedded-element=true public Byte [] ArrayOfByte17", - "embedded-element=false public Double [] ArrayOfDouble18", - "embedded-element=true public Double [] ArrayOfDouble19", - "embedded-element=false public Float [] ArrayOfFloat20", - "embedded-element=true public Float [] ArrayOfFloat21", - "embedded-element=false public Integer [] ArrayOfInteger22", - "embedded-element=true public Integer [] ArrayOfInteger23", - "embedded-element=false public Long [] ArrayOfLong24", - "embedded-element=true public Long [] ArrayOfLong25", - "embedded-element=false public Short [] ArrayOfShort26", - "embedded-element=true public Short [] ArrayOfShort27", - "embedded-element=false public SimpleEnum [] ArrayOfSimpleEnum28", - "embedded-element=true public SimpleEnum [] ArrayOfSimpleEnum29", - "embedded-element=true public SimpleEnum [] ArrayOfSimpleEnum30" + public static final String [] fieldSpecs = { + "serialized=true public Object [] ArrayOfObject0", + "embedded-element=false public Object [] ArrayOfObject1", + "serialized=true public SimpleClass [] ArrayOfSimpleClass2", + "embedded-element=false public SimpleClass [] ArrayOfSimpleClass3", + "serialized=true public SimpleInterface [] ArrayOfSimpleInterface4", + "embedded-element=false public SimpleInterface [] ArrayOfSimpleInterface5", + "embedded-element=false public String [] ArrayOfString6", + "embedded-element=true public String [] ArrayOfString7", + "embedded-element=false public Date [] ArrayOfDate8", + "embedded-element=true public Date [] ArrayOfDate9", + "embedded-element=false public Locale [] ArrayOfLocale10", + "embedded-element=true public Locale [] ArrayOfLocale11", + "embedded-element=false public BigDecimal [] ArrayOfBigDecimal12", + "embedded-element=true public BigDecimal [] ArrayOfBigDecimal13", + "embedded-element=false public BigInteger [] ArrayOfBigInteger14", + "embedded-element=true public BigInteger [] ArrayOfBigInteger15", + "embedded-element=false public Byte [] ArrayOfByte16", + "embedded-element=true public Byte [] ArrayOfByte17", + "embedded-element=false public Double [] ArrayOfDouble18", + "embedded-element=true public Double [] ArrayOfDouble19", + "embedded-element=false public Float [] ArrayOfFloat20", + "embedded-element=true public Float [] ArrayOfFloat21", + "embedded-element=false public Integer [] ArrayOfInteger22", + "embedded-element=true public Integer [] ArrayOfInteger23", + "embedded-element=false public Long [] ArrayOfLong24", + "embedded-element=true public Long [] ArrayOfLong25", + "embedded-element=false public Short [] ArrayOfShort26", + "embedded-element=true public Short [] ArrayOfShort27", + "embedded-element=false public SimpleEnum [] ArrayOfSimpleEnum28", + "embedded-element=true public SimpleEnum [] ArrayOfSimpleEnum29", + "embedded-element=true public SimpleEnum [] ArrayOfSimpleEnum30" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public Object[] get(int index) { - switch (index) { - case (0): + public Object [] get(int index) + { + switch (index) + { + case(0): return ArrayOfObject0; - case (1): + case(1): return ArrayOfObject1; - case (2): + case(2): return ArrayOfSimpleClass2; - case (3): + case(3): return ArrayOfSimpleClass3; - case (4): + case(4): return ArrayOfSimpleInterface4; - case (5): + case(5): return ArrayOfSimpleInterface5; - case (6): + case(6): return ArrayOfString6; - case (7): + case(7): return ArrayOfString7; - case (8): + case(8): return ArrayOfDate8; - case (9): + case(9): return ArrayOfDate9; - case (10): + case(10): return ArrayOfLocale10; - case (11): + case(11): return ArrayOfLocale11; - case (12): + case(12): return ArrayOfBigDecimal12; - case (13): + case(13): return ArrayOfBigDecimal13; - case (14): + case(14): return ArrayOfBigInteger14; - case (15): + case(15): return ArrayOfBigInteger15; - case (16): + case(16): return ArrayOfByte16; - case (17): + case(17): return ArrayOfByte17; - case (18): + case(18): return ArrayOfDouble18; - case (19): + case(19): return ArrayOfDouble19; - case (20): + case(20): return ArrayOfFloat20; - case (21): + case(21): return ArrayOfFloat21; - case (22): + case(22): return ArrayOfInteger22; - case (23): + case(23): return ArrayOfInteger23; - case (24): + case(24): return ArrayOfLong24; - case (25): + case(25): return ArrayOfLong25; - case (26): + case(26): return ArrayOfShort26; - case (27): + case(27): return ArrayOfShort27; - case (28): + case(28): return ArrayOfSimpleEnum28; - case (29): + case(29): return ArrayOfSimpleEnum29; - case (30): + case(30): return ArrayOfSimpleEnum30; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, Object[] value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - ArrayOfObject0 = (Object[]) value; - break; - case (1): - ArrayOfObject1 = (Object[]) value; - break; - case (2): - ArrayOfSimpleClass2 = (SimpleClass[]) value; - break; - case (3): - ArrayOfSimpleClass3 = (SimpleClass[]) value; - break; - case (4): - ArrayOfSimpleInterface4 = (SimpleInterface[]) value; - break; - case (5): - ArrayOfSimpleInterface5 = (SimpleInterface[]) value; - break; - case (6): - ArrayOfString6 = (String[]) value; - break; - case (7): - ArrayOfString7 = (String[]) value; - break; - case (8): - ArrayOfDate8 = (Date[]) value; - break; - case (9): - ArrayOfDate9 = (Date[]) value; - break; - case (10): - ArrayOfLocale10 = (Locale[]) value; - break; - case (11): - ArrayOfLocale11 = (Locale[]) value; - break; - case (12): - ArrayOfBigDecimal12 = (BigDecimal[]) value; - break; - case (13): - ArrayOfBigDecimal13 = (BigDecimal[]) value; - break; - case (14): - ArrayOfBigInteger14 = (BigInteger[]) value; - break; - case (15): - ArrayOfBigInteger15 = (BigInteger[]) value; - break; - case (16): - ArrayOfByte16 = (Byte[]) value; - break; - case (17): - ArrayOfByte17 = (Byte[]) value; - break; - case (18): - ArrayOfDouble18 = (Double[]) value; - break; - case (19): - ArrayOfDouble19 = (Double[]) value; - break; - case (20): - ArrayOfFloat20 = (Float[]) value; - break; - case (21): - ArrayOfFloat21 = (Float[]) value; - break; - case (22): - ArrayOfInteger22 = (Integer[]) value; - break; - case (23): - ArrayOfInteger23 = (Integer[]) value; - break; - case (24): - ArrayOfLong24 = (Long[]) value; - break; - case (25): - ArrayOfLong25 = (Long[]) value; - break; - case (26): - ArrayOfShort26 = (Short[]) value; - break; - case (27): - ArrayOfShort27 = (Short[]) value; - break; - case (28): - ArrayOfSimpleEnum28 = (SimpleEnum[]) value; - break; - case (29): - ArrayOfSimpleEnum29 = (SimpleEnum[]) value; - break; - case (30): - ArrayOfSimpleEnum30 = (SimpleEnum[]) value; - break; + public boolean set(int index, Object [] value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + ArrayOfObject0= (Object []) value ; + break; + case(1): + ArrayOfObject1= (Object []) value ; + break; + case(2): + ArrayOfSimpleClass2= (SimpleClass []) value ; + break; + case(3): + ArrayOfSimpleClass3= (SimpleClass []) value ; + break; + case(4): + ArrayOfSimpleInterface4= (SimpleInterface []) value ; + break; + case(5): + ArrayOfSimpleInterface5= (SimpleInterface []) value ; + break; + case(6): + ArrayOfString6= (String []) value ; + break; + case(7): + ArrayOfString7= (String []) value ; + break; + case(8): + ArrayOfDate8= (Date []) value ; + break; + case(9): + ArrayOfDate9= (Date []) value ; + break; + case(10): + ArrayOfLocale10= (Locale []) value ; + break; + case(11): + ArrayOfLocale11= (Locale []) value ; + break; + case(12): + ArrayOfBigDecimal12= (BigDecimal []) value ; + break; + case(13): + ArrayOfBigDecimal13= (BigDecimal []) value ; + break; + case(14): + ArrayOfBigInteger14= (BigInteger []) value ; + break; + case(15): + ArrayOfBigInteger15= (BigInteger []) value ; + break; + case(16): + ArrayOfByte16= (Byte []) value ; + break; + case(17): + ArrayOfByte17= (Byte []) value ; + break; + case(18): + ArrayOfDouble18= (Double []) value ; + break; + case(19): + ArrayOfDouble19= (Double []) value ; + break; + case(20): + ArrayOfFloat20= (Float []) value ; + break; + case(21): + ArrayOfFloat21= (Float []) value ; + break; + case(22): + ArrayOfInteger22= (Integer []) value ; + break; + case(23): + ArrayOfInteger23= (Integer []) value ; + break; + case(24): + ArrayOfLong24= (Long []) value ; + break; + case(25): + ArrayOfLong25= (Long []) value ; + break; + case(26): + ArrayOfShort26= (Short []) value ; + break; + case(27): + ArrayOfShort27= (Short []) value ; + break; + case(28): + ArrayOfSimpleEnum28= (SimpleEnum []) value ; + break; + case(29): + ArrayOfSimpleEnum29= (SimpleEnum []) value ; + break; + case(30): + ArrayOfSimpleEnum30= (SimpleEnum []) value ; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/ArrayListCollections.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/ArrayListCollections.java index dd1598dd6..369b674e0 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/ArrayListCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/ArrayListCollections.java @@ -5,22 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; import java.util.ArrayList; -public class ArrayListCollections { +public class ArrayListCollections { public int identifier; public ArrayList ArrayListOfObject0; public ArrayList ArrayListOfObject1; @@ -70,338 +70,337 @@ public class ArrayListCollections { public ArrayList ArrayListOfSimpleEnum45; public ArrayList ArrayListOfSimpleEnum46; - public static final String[] fieldSpecs = { - "public ArrayList ArrayListOfObject0", - "embedded-element=true public ArrayList ArrayListOfObject1", - "embedded-element=false public ArrayList ArrayListOfObject2", - "public ArrayList ArrayListOfSimpleClass3", - "embedded-element=true public ArrayList ArrayListOfSimpleClass4", - "embedded-element=false public ArrayList ArrayListOfSimpleClass5", - "public ArrayList ArrayListOfSimpleInterface6", - "embedded-element=true public ArrayList ArrayListOfSimpleInterface7", - "embedded-element=false public ArrayList ArrayListOfSimpleInterface8", - "public ArrayList ArrayListOfString9", - "embedded-element=true public ArrayList ArrayListOfString10", - "embedded-element=false public ArrayList ArrayListOfString11", - "public ArrayList ArrayListOfDate12", - "embedded-element=true public ArrayList ArrayListOfDate13", - "embedded-element=false public ArrayList ArrayListOfDate14", - "public ArrayList ArrayListOfLocale15", - "embedded-element=true public ArrayList ArrayListOfLocale16", - "embedded-element=false public ArrayList ArrayListOfLocale17", - "public ArrayList ArrayListOfBigDecimal18", - "embedded-element=true public ArrayList ArrayListOfBigDecimal19", - "embedded-element=false public ArrayList ArrayListOfBigDecimal20", - "public ArrayList ArrayListOfBigInteger21", - "embedded-element=true public ArrayList ArrayListOfBigInteger22", - "embedded-element=false public ArrayList ArrayListOfBigInteger23", - "public ArrayList ArrayListOfByte24", - "embedded-element=true public ArrayList ArrayListOfByte25", - "embedded-element=false public ArrayList ArrayListOfByte26", - "public ArrayList ArrayListOfDouble27", - "embedded-element=true public ArrayList ArrayListOfDouble28", - "embedded-element=false public ArrayList ArrayListOfDouble29", - "public ArrayList ArrayListOfFloat30", - "embedded-element=true public ArrayList ArrayListOfFloat31", - "embedded-element=false public ArrayList ArrayListOfFloat32", - "public ArrayList ArrayListOfInteger33", - "embedded-element=true public ArrayList ArrayListOfInteger34", - "embedded-element=false public ArrayList ArrayListOfInteger35", - "public ArrayList ArrayListOfLong36", - "embedded-element=true public ArrayList ArrayListOfLong37", - "embedded-element=false public ArrayList ArrayListOfLong38", - "public ArrayList ArrayListOfShort39", - "embedded-element=true public ArrayList ArrayListOfShort40", - "embedded-element=false public ArrayList ArrayListOfShort41", - "public ArrayList ArrayListOfSimpleEnum42", - "embedded-element=true public ArrayList ArrayListOfSimpleEnum43", - "embedded-element=false public ArrayList ArrayListOfSimpleEnum44", - "public ArrayList ArrayListOfSimpleEnum45", - "embedded-element=false public ArrayList ArrayListOfSimpleEnum46" + public static final String [] fieldSpecs = { + "public ArrayList ArrayListOfObject0", + "embedded-element=true public ArrayList ArrayListOfObject1", + "embedded-element=false public ArrayList ArrayListOfObject2", + "public ArrayList ArrayListOfSimpleClass3", + "embedded-element=true public ArrayList ArrayListOfSimpleClass4", + "embedded-element=false public ArrayList ArrayListOfSimpleClass5", + "public ArrayList ArrayListOfSimpleInterface6", + "embedded-element=true public ArrayList ArrayListOfSimpleInterface7", + "embedded-element=false public ArrayList ArrayListOfSimpleInterface8", + "public ArrayList ArrayListOfString9", + "embedded-element=true public ArrayList ArrayListOfString10", + "embedded-element=false public ArrayList ArrayListOfString11", + "public ArrayList ArrayListOfDate12", + "embedded-element=true public ArrayList ArrayListOfDate13", + "embedded-element=false public ArrayList ArrayListOfDate14", + "public ArrayList ArrayListOfLocale15", + "embedded-element=true public ArrayList ArrayListOfLocale16", + "embedded-element=false public ArrayList ArrayListOfLocale17", + "public ArrayList ArrayListOfBigDecimal18", + "embedded-element=true public ArrayList ArrayListOfBigDecimal19", + "embedded-element=false public ArrayList ArrayListOfBigDecimal20", + "public ArrayList ArrayListOfBigInteger21", + "embedded-element=true public ArrayList ArrayListOfBigInteger22", + "embedded-element=false public ArrayList ArrayListOfBigInteger23", + "public ArrayList ArrayListOfByte24", + "embedded-element=true public ArrayList ArrayListOfByte25", + "embedded-element=false public ArrayList ArrayListOfByte26", + "public ArrayList ArrayListOfDouble27", + "embedded-element=true public ArrayList ArrayListOfDouble28", + "embedded-element=false public ArrayList ArrayListOfDouble29", + "public ArrayList ArrayListOfFloat30", + "embedded-element=true public ArrayList ArrayListOfFloat31", + "embedded-element=false public ArrayList ArrayListOfFloat32", + "public ArrayList ArrayListOfInteger33", + "embedded-element=true public ArrayList ArrayListOfInteger34", + "embedded-element=false public ArrayList ArrayListOfInteger35", + "public ArrayList ArrayListOfLong36", + "embedded-element=true public ArrayList ArrayListOfLong37", + "embedded-element=false public ArrayList ArrayListOfLong38", + "public ArrayList ArrayListOfShort39", + "embedded-element=true public ArrayList ArrayListOfShort40", + "embedded-element=false public ArrayList ArrayListOfShort41", + "public ArrayList ArrayListOfSimpleEnum42", + "embedded-element=true public ArrayList ArrayListOfSimpleEnum43", + "embedded-element=false public ArrayList ArrayListOfSimpleEnum44", + "public ArrayList ArrayListOfSimpleEnum45", + "embedded-element=false public ArrayList ArrayListOfSimpleEnum46" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public ArrayList get(int index) { - switch (index) { - case (0): + public ArrayList get(int index) + { + switch (index) + { + case(0): return ArrayListOfObject0; - case (1): + case(1): return ArrayListOfObject1; - case (2): + case(2): return ArrayListOfObject2; - case (3): + case(3): return ArrayListOfSimpleClass3; - case (4): + case(4): return ArrayListOfSimpleClass4; - case (5): + case(5): return ArrayListOfSimpleClass5; - case (6): + case(6): return ArrayListOfSimpleInterface6; - case (7): + case(7): return ArrayListOfSimpleInterface7; - case (8): + case(8): return ArrayListOfSimpleInterface8; - case (9): + case(9): return ArrayListOfString9; - case (10): + case(10): return ArrayListOfString10; - case (11): + case(11): return ArrayListOfString11; - case (12): + case(12): return ArrayListOfDate12; - case (13): + case(13): return ArrayListOfDate13; - case (14): + case(14): return ArrayListOfDate14; - case (15): + case(15): return ArrayListOfLocale15; - case (16): + case(16): return ArrayListOfLocale16; - case (17): + case(17): return ArrayListOfLocale17; - case (18): + case(18): return ArrayListOfBigDecimal18; - case (19): + case(19): return ArrayListOfBigDecimal19; - case (20): + case(20): return ArrayListOfBigDecimal20; - case (21): + case(21): return ArrayListOfBigInteger21; - case (22): + case(22): return ArrayListOfBigInteger22; - case (23): + case(23): return ArrayListOfBigInteger23; - case (24): + case(24): return ArrayListOfByte24; - case (25): + case(25): return ArrayListOfByte25; - case (26): + case(26): return ArrayListOfByte26; - case (27): + case(27): return ArrayListOfDouble27; - case (28): + case(28): return ArrayListOfDouble28; - case (29): + case(29): return ArrayListOfDouble29; - case (30): + case(30): return ArrayListOfFloat30; - case (31): + case(31): return ArrayListOfFloat31; - case (32): + case(32): return ArrayListOfFloat32; - case (33): + case(33): return ArrayListOfInteger33; - case (34): + case(34): return ArrayListOfInteger34; - case (35): + case(35): return ArrayListOfInteger35; - case (36): + case(36): return ArrayListOfLong36; - case (37): + case(37): return ArrayListOfLong37; - case (38): + case(38): return ArrayListOfLong38; - case (39): + case(39): return ArrayListOfShort39; - case (40): + case(40): return ArrayListOfShort40; - case (41): + case(41): return ArrayListOfShort41; - case (42): + case(42): return ArrayListOfSimpleEnum42; - case (43): + case(43): return ArrayListOfSimpleEnum43; - case (44): + case(44): return ArrayListOfSimpleEnum44; - case (45): + case(45): return ArrayListOfSimpleEnum45; - case (46): + case(46): return ArrayListOfSimpleEnum46; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, ArrayList value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - ArrayListOfObject0 = value; - break; - case (1): - ArrayListOfObject1 = value; - break; - case (2): - ArrayListOfObject2 = value; - break; - case (3): - ArrayListOfSimpleClass3 = value; - break; - case (4): - ArrayListOfSimpleClass4 = value; - break; - case (5): - ArrayListOfSimpleClass5 = value; - break; - case (6): - ArrayListOfSimpleInterface6 = value; - break; - case (7): - ArrayListOfSimpleInterface7 = value; - break; - case (8): - ArrayListOfSimpleInterface8 = value; - break; - case (9): - ArrayListOfString9 = value; - break; - case (10): - ArrayListOfString10 = value; - break; - case (11): - ArrayListOfString11 = value; - break; - case (12): - ArrayListOfDate12 = value; - break; - case (13): - ArrayListOfDate13 = value; - break; - case (14): - ArrayListOfDate14 = value; - break; - case (15): - ArrayListOfLocale15 = value; - break; - case (16): - ArrayListOfLocale16 = value; - break; - case (17): - ArrayListOfLocale17 = value; - break; - case (18): - ArrayListOfBigDecimal18 = value; - break; - case (19): - ArrayListOfBigDecimal19 = value; - break; - case (20): - ArrayListOfBigDecimal20 = value; - break; - case (21): - ArrayListOfBigInteger21 = value; - break; - case (22): - ArrayListOfBigInteger22 = value; - break; - case (23): - ArrayListOfBigInteger23 = value; - break; - case (24): - ArrayListOfByte24 = value; - break; - case (25): - ArrayListOfByte25 = value; - break; - case (26): - ArrayListOfByte26 = value; - break; - case (27): - ArrayListOfDouble27 = value; - break; - case (28): - ArrayListOfDouble28 = value; - break; - case (29): - ArrayListOfDouble29 = value; - break; - case (30): - ArrayListOfFloat30 = value; - break; - case (31): - ArrayListOfFloat31 = value; - break; - case (32): - ArrayListOfFloat32 = value; - break; - case (33): - ArrayListOfInteger33 = value; - break; - case (34): - ArrayListOfInteger34 = value; - break; - case (35): - ArrayListOfInteger35 = value; - break; - case (36): - ArrayListOfLong36 = value; - break; - case (37): - ArrayListOfLong37 = value; - break; - case (38): - ArrayListOfLong38 = value; - break; - case (39): - ArrayListOfShort39 = value; - break; - case (40): - ArrayListOfShort40 = value; - break; - case (41): - ArrayListOfShort41 = value; - break; - case (42): - ArrayListOfSimpleEnum42 = value; - break; - case (43): - ArrayListOfSimpleEnum43 = value; - break; - case (44): - ArrayListOfSimpleEnum44 = value; - break; - case (45): - ArrayListOfSimpleEnum45 = value; - break; - case (46): - ArrayListOfSimpleEnum46 = value; - break; + public boolean set(int index, ArrayList value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + ArrayListOfObject0= value; + break; + case(1): + ArrayListOfObject1= value; + break; + case(2): + ArrayListOfObject2= value; + break; + case(3): + ArrayListOfSimpleClass3= value; + break; + case(4): + ArrayListOfSimpleClass4= value; + break; + case(5): + ArrayListOfSimpleClass5= value; + break; + case(6): + ArrayListOfSimpleInterface6= value; + break; + case(7): + ArrayListOfSimpleInterface7= value; + break; + case(8): + ArrayListOfSimpleInterface8= value; + break; + case(9): + ArrayListOfString9= value; + break; + case(10): + ArrayListOfString10= value; + break; + case(11): + ArrayListOfString11= value; + break; + case(12): + ArrayListOfDate12= value; + break; + case(13): + ArrayListOfDate13= value; + break; + case(14): + ArrayListOfDate14= value; + break; + case(15): + ArrayListOfLocale15= value; + break; + case(16): + ArrayListOfLocale16= value; + break; + case(17): + ArrayListOfLocale17= value; + break; + case(18): + ArrayListOfBigDecimal18= value; + break; + case(19): + ArrayListOfBigDecimal19= value; + break; + case(20): + ArrayListOfBigDecimal20= value; + break; + case(21): + ArrayListOfBigInteger21= value; + break; + case(22): + ArrayListOfBigInteger22= value; + break; + case(23): + ArrayListOfBigInteger23= value; + break; + case(24): + ArrayListOfByte24= value; + break; + case(25): + ArrayListOfByte25= value; + break; + case(26): + ArrayListOfByte26= value; + break; + case(27): + ArrayListOfDouble27= value; + break; + case(28): + ArrayListOfDouble28= value; + break; + case(29): + ArrayListOfDouble29= value; + break; + case(30): + ArrayListOfFloat30= value; + break; + case(31): + ArrayListOfFloat31= value; + break; + case(32): + ArrayListOfFloat32= value; + break; + case(33): + ArrayListOfInteger33= value; + break; + case(34): + ArrayListOfInteger34= value; + break; + case(35): + ArrayListOfInteger35= value; + break; + case(36): + ArrayListOfLong36= value; + break; + case(37): + ArrayListOfLong37= value; + break; + case(38): + ArrayListOfLong38= value; + break; + case(39): + ArrayListOfShort39= value; + break; + case(40): + ArrayListOfShort40= value; + break; + case(41): + ArrayListOfShort41= value; + break; + case(42): + ArrayListOfSimpleEnum42= value; + break; + case(43): + ArrayListOfSimpleEnum43= value; + break; + case(44): + ArrayListOfSimpleEnum44= value; + break; + case(45): + ArrayListOfSimpleEnum45= value; + break; + case(46): + ArrayListOfSimpleEnum46= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/CollectionCollections.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/CollectionCollections.java index 31c277d90..7c13e3975 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/CollectionCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/CollectionCollections.java @@ -5,22 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; import java.util.Collection; -public class CollectionCollections { +public class CollectionCollections { public int identifier; public Collection CollectionOfObject0; public Collection CollectionOfObject1; @@ -66,314 +66,313 @@ public class CollectionCollections { public Collection CollectionOfShort41; public Collection CollectionOfSimpleClass42; - public static final String[] fieldSpecs = { - "public Collection CollectionOfObject0", - "embedded-element=true public Collection CollectionOfObject1", - "embedded-element=false public Collection CollectionOfObject2", - "public Collection CollectionOfSimpleClass3", - "embedded-element=true public Collection CollectionOfSimpleClass4", - "embedded-element=false public Collection CollectionOfSimpleClass5", - "public Collection CollectionOfSimpleInterface6", - "embedded-element=true public Collection CollectionOfSimpleInterface7", - "embedded-element=false public Collection CollectionOfSimpleInterface8", - "public Collection CollectionOfString9", - "embedded-element=true public Collection CollectionOfString10", - "embedded-element=false public Collection CollectionOfString11", - "public Collection CollectionOfDate12", - "embedded-element=true public Collection CollectionOfDate13", - "embedded-element=false public Collection CollectionOfDate14", - "public Collection CollectionOfLocale15", - "embedded-element=true public Collection CollectionOfLocale16", - "embedded-element=false public Collection CollectionOfLocale17", - "public Collection CollectionOfBigDecimal18", - "embedded-element=true public Collection CollectionOfBigDecimal19", - "embedded-element=false public Collection CollectionOfBigDecimal20", - "public Collection CollectionOfBigInteger21", - "embedded-element=true public Collection CollectionOfBigInteger22", - "embedded-element=false public Collection CollectionOfBigInteger23", - "public Collection CollectionOfByte24", - "embedded-element=true public Collection CollectionOfByte25", - "embedded-element=false public Collection CollectionOfByte26", - "public Collection CollectionOfDouble27", - "embedded-element=true public Collection CollectionOfDouble28", - "embedded-element=false public Collection CollectionOfDouble29", - "public Collection CollectionOfFloat30", - "embedded-element=true public Collection CollectionOfFloat31", - "embedded-element=false public Collection CollectionOfFloat32", - "public Collection CollectionOfInteger33", - "embedded-element=true public Collection CollectionOfInteger34", - "embedded-element=false public Collection CollectionOfInteger35", - "public Collection CollectionOfLong36", - "embedded-element=true public Collection CollectionOfLong37", - "embedded-element=false public Collection CollectionOfLong38", - "public Collection CollectionOfShort39", - "embedded-element=true public Collection CollectionOfShort40", - "embedded-element=false public Collection CollectionOfShort41", - "serialized=true public Collection CollectionOfSimpleClass42" + public static final String [] fieldSpecs = { + "public Collection CollectionOfObject0", + "embedded-element=true public Collection CollectionOfObject1", + "embedded-element=false public Collection CollectionOfObject2", + "public Collection CollectionOfSimpleClass3", + "embedded-element=true public Collection CollectionOfSimpleClass4", + "embedded-element=false public Collection CollectionOfSimpleClass5", + "public Collection CollectionOfSimpleInterface6", + "embedded-element=true public Collection CollectionOfSimpleInterface7", + "embedded-element=false public Collection CollectionOfSimpleInterface8", + "public Collection CollectionOfString9", + "embedded-element=true public Collection CollectionOfString10", + "embedded-element=false public Collection CollectionOfString11", + "public Collection CollectionOfDate12", + "embedded-element=true public Collection CollectionOfDate13", + "embedded-element=false public Collection CollectionOfDate14", + "public Collection CollectionOfLocale15", + "embedded-element=true public Collection CollectionOfLocale16", + "embedded-element=false public Collection CollectionOfLocale17", + "public Collection CollectionOfBigDecimal18", + "embedded-element=true public Collection CollectionOfBigDecimal19", + "embedded-element=false public Collection CollectionOfBigDecimal20", + "public Collection CollectionOfBigInteger21", + "embedded-element=true public Collection CollectionOfBigInteger22", + "embedded-element=false public Collection CollectionOfBigInteger23", + "public Collection CollectionOfByte24", + "embedded-element=true public Collection CollectionOfByte25", + "embedded-element=false public Collection CollectionOfByte26", + "public Collection CollectionOfDouble27", + "embedded-element=true public Collection CollectionOfDouble28", + "embedded-element=false public Collection CollectionOfDouble29", + "public Collection CollectionOfFloat30", + "embedded-element=true public Collection CollectionOfFloat31", + "embedded-element=false public Collection CollectionOfFloat32", + "public Collection CollectionOfInteger33", + "embedded-element=true public Collection CollectionOfInteger34", + "embedded-element=false public Collection CollectionOfInteger35", + "public Collection CollectionOfLong36", + "embedded-element=true public Collection CollectionOfLong37", + "embedded-element=false public Collection CollectionOfLong38", + "public Collection CollectionOfShort39", + "embedded-element=true public Collection CollectionOfShort40", + "embedded-element=false public Collection CollectionOfShort41", + "serialized=true public Collection CollectionOfSimpleClass42" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public Collection get(int index) { - switch (index) { - case (0): + public Collection get(int index) + { + switch (index) + { + case(0): return CollectionOfObject0; - case (1): + case(1): return CollectionOfObject1; - case (2): + case(2): return CollectionOfObject2; - case (3): + case(3): return CollectionOfSimpleClass3; - case (4): + case(4): return CollectionOfSimpleClass4; - case (5): + case(5): return CollectionOfSimpleClass5; - case (6): + case(6): return CollectionOfSimpleInterface6; - case (7): + case(7): return CollectionOfSimpleInterface7; - case (8): + case(8): return CollectionOfSimpleInterface8; - case (9): + case(9): return CollectionOfString9; - case (10): + case(10): return CollectionOfString10; - case (11): + case(11): return CollectionOfString11; - case (12): + case(12): return CollectionOfDate12; - case (13): + case(13): return CollectionOfDate13; - case (14): + case(14): return CollectionOfDate14; - case (15): + case(15): return CollectionOfLocale15; - case (16): + case(16): return CollectionOfLocale16; - case (17): + case(17): return CollectionOfLocale17; - case (18): + case(18): return CollectionOfBigDecimal18; - case (19): + case(19): return CollectionOfBigDecimal19; - case (20): + case(20): return CollectionOfBigDecimal20; - case (21): + case(21): return CollectionOfBigInteger21; - case (22): + case(22): return CollectionOfBigInteger22; - case (23): + case(23): return CollectionOfBigInteger23; - case (24): + case(24): return CollectionOfByte24; - case (25): + case(25): return CollectionOfByte25; - case (26): + case(26): return CollectionOfByte26; - case (27): + case(27): return CollectionOfDouble27; - case (28): + case(28): return CollectionOfDouble28; - case (29): + case(29): return CollectionOfDouble29; - case (30): + case(30): return CollectionOfFloat30; - case (31): + case(31): return CollectionOfFloat31; - case (32): + case(32): return CollectionOfFloat32; - case (33): + case(33): return CollectionOfInteger33; - case (34): + case(34): return CollectionOfInteger34; - case (35): + case(35): return CollectionOfInteger35; - case (36): + case(36): return CollectionOfLong36; - case (37): + case(37): return CollectionOfLong37; - case (38): + case(38): return CollectionOfLong38; - case (39): + case(39): return CollectionOfShort39; - case (40): + case(40): return CollectionOfShort40; - case (41): + case(41): return CollectionOfShort41; - case (42): + case(42): return CollectionOfSimpleClass42; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, Collection value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - CollectionOfObject0 = value; - break; - case (1): - CollectionOfObject1 = value; - break; - case (2): - CollectionOfObject2 = value; - break; - case (3): - CollectionOfSimpleClass3 = value; - break; - case (4): - CollectionOfSimpleClass4 = value; - break; - case (5): - CollectionOfSimpleClass5 = value; - break; - case (6): - CollectionOfSimpleInterface6 = value; - break; - case (7): - CollectionOfSimpleInterface7 = value; - break; - case (8): - CollectionOfSimpleInterface8 = value; - break; - case (9): - CollectionOfString9 = value; - break; - case (10): - CollectionOfString10 = value; - break; - case (11): - CollectionOfString11 = value; - break; - case (12): - CollectionOfDate12 = value; - break; - case (13): - CollectionOfDate13 = value; - break; - case (14): - CollectionOfDate14 = value; - break; - case (15): - CollectionOfLocale15 = value; - break; - case (16): - CollectionOfLocale16 = value; - break; - case (17): - CollectionOfLocale17 = value; - break; - case (18): - CollectionOfBigDecimal18 = value; - break; - case (19): - CollectionOfBigDecimal19 = value; - break; - case (20): - CollectionOfBigDecimal20 = value; - break; - case (21): - CollectionOfBigInteger21 = value; - break; - case (22): - CollectionOfBigInteger22 = value; - break; - case (23): - CollectionOfBigInteger23 = value; - break; - case (24): - CollectionOfByte24 = value; - break; - case (25): - CollectionOfByte25 = value; - break; - case (26): - CollectionOfByte26 = value; - break; - case (27): - CollectionOfDouble27 = value; - break; - case (28): - CollectionOfDouble28 = value; - break; - case (29): - CollectionOfDouble29 = value; - break; - case (30): - CollectionOfFloat30 = value; - break; - case (31): - CollectionOfFloat31 = value; - break; - case (32): - CollectionOfFloat32 = value; - break; - case (33): - CollectionOfInteger33 = value; - break; - case (34): - CollectionOfInteger34 = value; - break; - case (35): - CollectionOfInteger35 = value; - break; - case (36): - CollectionOfLong36 = value; - break; - case (37): - CollectionOfLong37 = value; - break; - case (38): - CollectionOfLong38 = value; - break; - case (39): - CollectionOfShort39 = value; - break; - case (40): - CollectionOfShort40 = value; - break; - case (41): - CollectionOfShort41 = value; - break; - case (42): - CollectionOfSimpleClass42 = value; - break; + public boolean set(int index,Collection value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + CollectionOfObject0= value; + break; + case(1): + CollectionOfObject1= value; + break; + case(2): + CollectionOfObject2= value; + break; + case(3): + CollectionOfSimpleClass3= value; + break; + case(4): + CollectionOfSimpleClass4= value; + break; + case(5): + CollectionOfSimpleClass5= value; + break; + case(6): + CollectionOfSimpleInterface6= value; + break; + case(7): + CollectionOfSimpleInterface7= value; + break; + case(8): + CollectionOfSimpleInterface8= value; + break; + case(9): + CollectionOfString9= value; + break; + case(10): + CollectionOfString10= value; + break; + case(11): + CollectionOfString11= value; + break; + case(12): + CollectionOfDate12= value; + break; + case(13): + CollectionOfDate13= value; + break; + case(14): + CollectionOfDate14= value; + break; + case(15): + CollectionOfLocale15= value; + break; + case(16): + CollectionOfLocale16= value; + break; + case(17): + CollectionOfLocale17= value; + break; + case(18): + CollectionOfBigDecimal18= value; + break; + case(19): + CollectionOfBigDecimal19= value; + break; + case(20): + CollectionOfBigDecimal20= value; + break; + case(21): + CollectionOfBigInteger21= value; + break; + case(22): + CollectionOfBigInteger22= value; + break; + case(23): + CollectionOfBigInteger23= value; + break; + case(24): + CollectionOfByte24= value; + break; + case(25): + CollectionOfByte25= value; + break; + case(26): + CollectionOfByte26= value; + break; + case(27): + CollectionOfDouble27= value; + break; + case(28): + CollectionOfDouble28= value; + break; + case(29): + CollectionOfDouble29= value; + break; + case(30): + CollectionOfFloat30= value; + break; + case(31): + CollectionOfFloat31= value; + break; + case(32): + CollectionOfFloat32= value; + break; + case(33): + CollectionOfInteger33= value; + break; + case(34): + CollectionOfInteger34= value; + break; + case(35): + CollectionOfInteger35= value; + break; + case(36): + CollectionOfLong36= value; + break; + case(37): + CollectionOfLong37= value; + break; + case(38): + CollectionOfLong38= value; + break; + case(39): + CollectionOfShort39= value; + break; + case(40): + CollectionOfShort40= value; + break; + case(41): + CollectionOfShort41= value; + break; + case(42): + CollectionOfSimpleClass42= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfBigDecimal.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfBigDecimal.java index e3fb84f0f..28883821c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfBigDecimal.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfBigDecimal.java @@ -5,22 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -import java.math.BigDecimal; -public class FieldsOfBigDecimal { +import java.math.*; +public class FieldsOfBigDecimal { public int identifier; private BigDecimal BigDecimal0; private BigDecimal BigDecimal1; @@ -49,14 +49,14 @@ public class FieldsOfBigDecimal { private static transient BigDecimal BigDecimal24; private static final BigDecimal BigDecimal25 = new BigDecimal(100.15); private static volatile BigDecimal BigDecimal26; - private final transient BigDecimal BigDecimal27 = new BigDecimal(100.15); + private transient final BigDecimal BigDecimal27 = new BigDecimal(100.15); private transient volatile BigDecimal BigDecimal28; private transient volatile BigDecimal BigDecimal29; private transient volatile BigDecimal BigDecimal30; private transient volatile BigDecimal BigDecimal31; private transient volatile BigDecimal BigDecimal32; private transient volatile BigDecimal BigDecimal33; - private static final transient BigDecimal BigDecimal34 = new BigDecimal(100.15); + private static transient final BigDecimal BigDecimal34 = new BigDecimal(100.15); private static transient volatile BigDecimal BigDecimal35; public BigDecimal BigDecimal36; public BigDecimal BigDecimal37; @@ -85,14 +85,14 @@ public class FieldsOfBigDecimal { public static transient BigDecimal BigDecimal60; public static final BigDecimal BigDecimal61 = new BigDecimal(100.15); public static volatile BigDecimal BigDecimal62; - public final transient BigDecimal BigDecimal63 = new BigDecimal(100.15); + public transient final BigDecimal BigDecimal63 = new BigDecimal(100.15); public transient volatile BigDecimal BigDecimal64; public transient volatile BigDecimal BigDecimal65; public transient volatile BigDecimal BigDecimal66; public transient volatile BigDecimal BigDecimal67; public transient volatile BigDecimal BigDecimal68; public transient volatile BigDecimal BigDecimal69; - public static final transient BigDecimal BigDecimal70 = new BigDecimal(100.15); + public static transient final BigDecimal BigDecimal70 = new BigDecimal(100.15); public static transient volatile BigDecimal BigDecimal71; protected BigDecimal BigDecimal72; protected BigDecimal BigDecimal73; @@ -121,14 +121,14 @@ public class FieldsOfBigDecimal { protected static transient BigDecimal BigDecimal96; protected static final BigDecimal BigDecimal97 = new BigDecimal(100.15); protected static volatile BigDecimal BigDecimal98; - protected final transient BigDecimal BigDecimal99 = new BigDecimal(100.15); + protected transient final BigDecimal BigDecimal99 = new BigDecimal(100.15); protected transient volatile BigDecimal BigDecimal100; protected transient volatile BigDecimal BigDecimal101; protected transient volatile BigDecimal BigDecimal102; protected transient volatile BigDecimal BigDecimal103; protected transient volatile BigDecimal BigDecimal104; protected transient volatile BigDecimal BigDecimal105; - protected static final transient BigDecimal BigDecimal106 = new BigDecimal(100.15); + protected static transient final BigDecimal BigDecimal106 = new BigDecimal(100.15); protected static transient volatile BigDecimal BigDecimal107; BigDecimal BigDecimal108; BigDecimal BigDecimal109; @@ -157,936 +157,935 @@ public class FieldsOfBigDecimal { static transient BigDecimal BigDecimal132; static final BigDecimal BigDecimal133 = new BigDecimal(100.15); static volatile BigDecimal BigDecimal134; - final transient BigDecimal BigDecimal135 = new BigDecimal(100.15); + transient final BigDecimal BigDecimal135 = new BigDecimal(100.15); transient volatile BigDecimal BigDecimal136; transient volatile BigDecimal BigDecimal137; transient volatile BigDecimal BigDecimal138; transient volatile BigDecimal BigDecimal139; transient volatile BigDecimal BigDecimal140; transient volatile BigDecimal BigDecimal141; - static final transient BigDecimal BigDecimal142 = new BigDecimal(100.15); + static transient final BigDecimal BigDecimal142 = new BigDecimal(100.15); static transient volatile BigDecimal BigDecimal143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private BigDecimal BigDecimal0", - "embedded= true private BigDecimal BigDecimal1", - "embedded= false private BigDecimal BigDecimal2", - "persistence-modifier= none private BigDecimal BigDecimal3", - "persistence-modifier= persistent private BigDecimal BigDecimal4", - "persistence-modifier= persistent embedded= true private BigDecimal BigDecimal5", - "persistence-modifier= persistent embedded= false private BigDecimal BigDecimal6", - "persistence-modifier= transactional private BigDecimal BigDecimal7", - "private static BigDecimal BigDecimal8", - "private transient BigDecimal BigDecimal9", - "persistence-modifier= none private transient BigDecimal BigDecimal10", - "persistence-modifier= persistent private transient BigDecimal BigDecimal11", - "persistence-modifier= persistent embedded= true private transient BigDecimal BigDecimal12", - "persistence-modifier= persistent embedded= false private transient BigDecimal BigDecimal13", - "persistence-modifier= transactional private transient BigDecimal BigDecimal14", - "private final BigDecimal BigDecimal15", - "private volatile BigDecimal BigDecimal16", - "embedded= true private volatile BigDecimal BigDecimal17", - "embedded= false private volatile BigDecimal BigDecimal18", - "persistence-modifier= none private volatile BigDecimal BigDecimal19", - "persistence-modifier= persistent private volatile BigDecimal BigDecimal20", - "persistence-modifier= persistent embedded= true private volatile BigDecimal BigDecimal21", - "persistence-modifier= persistent embedded= false private volatile BigDecimal BigDecimal22", - "persistence-modifier= transactional private volatile BigDecimal BigDecimal23", - "private static transient BigDecimal BigDecimal24", - "private static final BigDecimal BigDecimal25", - "private static volatile BigDecimal BigDecimal26", - "private transient final BigDecimal BigDecimal27", - "private transient volatile BigDecimal BigDecimal28", - "persistence-modifier= none private transient volatile BigDecimal BigDecimal29", - "persistence-modifier= persistent private transient volatile BigDecimal BigDecimal30", - "persistence-modifier= persistent embedded= true private transient volatile BigDecimal BigDecimal31", - "persistence-modifier= persistent embedded= false private transient volatile BigDecimal BigDecimal32", - "persistence-modifier= transactional private transient volatile BigDecimal BigDecimal33", - "private static transient final BigDecimal BigDecimal34", - "private static transient volatile BigDecimal BigDecimal35", - "public BigDecimal BigDecimal36", - "embedded= true public BigDecimal BigDecimal37", - "embedded= false public BigDecimal BigDecimal38", - "persistence-modifier= none public BigDecimal BigDecimal39", - "persistence-modifier= persistent public BigDecimal BigDecimal40", - "persistence-modifier= persistent embedded= true public BigDecimal BigDecimal41", - "persistence-modifier= persistent embedded= false public BigDecimal BigDecimal42", - "persistence-modifier= transactional public BigDecimal BigDecimal43", - "public static BigDecimal BigDecimal44", - "public transient BigDecimal BigDecimal45", - "persistence-modifier= none public transient BigDecimal BigDecimal46", - "persistence-modifier= persistent public transient BigDecimal BigDecimal47", - "persistence-modifier= persistent embedded= true public transient BigDecimal BigDecimal48", - "persistence-modifier= persistent embedded= false public transient BigDecimal BigDecimal49", - "persistence-modifier= transactional public transient BigDecimal BigDecimal50", - "public final BigDecimal BigDecimal51", - "public volatile BigDecimal BigDecimal52", - "embedded= true public volatile BigDecimal BigDecimal53", - "embedded= false public volatile BigDecimal BigDecimal54", - "persistence-modifier= none public volatile BigDecimal BigDecimal55", - "persistence-modifier= persistent public volatile BigDecimal BigDecimal56", - "persistence-modifier= persistent embedded= true public volatile BigDecimal BigDecimal57", - "persistence-modifier= persistent embedded= false public volatile BigDecimal BigDecimal58", - "persistence-modifier= transactional public volatile BigDecimal BigDecimal59", - "public static transient BigDecimal BigDecimal60", - "public static final BigDecimal BigDecimal61", - "public static volatile BigDecimal BigDecimal62", - "public transient final BigDecimal BigDecimal63", - "public transient volatile BigDecimal BigDecimal64", - "persistence-modifier= none public transient volatile BigDecimal BigDecimal65", - "persistence-modifier= persistent public transient volatile BigDecimal BigDecimal66", - "persistence-modifier= persistent embedded= true public transient volatile BigDecimal BigDecimal67", - "persistence-modifier= persistent embedded= false public transient volatile BigDecimal BigDecimal68", - "persistence-modifier= transactional public transient volatile BigDecimal BigDecimal69", - "public static transient final BigDecimal BigDecimal70", - "public static transient volatile BigDecimal BigDecimal71", - "protected BigDecimal BigDecimal72", - "embedded= true protected BigDecimal BigDecimal73", - "embedded= false protected BigDecimal BigDecimal74", - "persistence-modifier= none protected BigDecimal BigDecimal75", - "persistence-modifier= persistent protected BigDecimal BigDecimal76", - "persistence-modifier= persistent embedded= true protected BigDecimal BigDecimal77", - "persistence-modifier= persistent embedded= false protected BigDecimal BigDecimal78", - "persistence-modifier= transactional protected BigDecimal BigDecimal79", - "protected static BigDecimal BigDecimal80", - "protected transient BigDecimal BigDecimal81", - "persistence-modifier= none protected transient BigDecimal BigDecimal82", - "persistence-modifier= persistent protected transient BigDecimal BigDecimal83", - "persistence-modifier= persistent embedded= true protected transient BigDecimal BigDecimal84", - "persistence-modifier= persistent embedded= false protected transient BigDecimal BigDecimal85", - "persistence-modifier= transactional protected transient BigDecimal BigDecimal86", - "protected final BigDecimal BigDecimal87", - "protected volatile BigDecimal BigDecimal88", - "embedded= true protected volatile BigDecimal BigDecimal89", - "embedded= false protected volatile BigDecimal BigDecimal90", - "persistence-modifier= none protected volatile BigDecimal BigDecimal91", - "persistence-modifier= persistent protected volatile BigDecimal BigDecimal92", - "persistence-modifier= persistent embedded= true protected volatile BigDecimal BigDecimal93", - "persistence-modifier= persistent embedded= false protected volatile BigDecimal BigDecimal94", - "persistence-modifier= transactional protected volatile BigDecimal BigDecimal95", - "protected static transient BigDecimal BigDecimal96", - "protected static final BigDecimal BigDecimal97", - "protected static volatile BigDecimal BigDecimal98", - "protected transient final BigDecimal BigDecimal99", - "protected transient volatile BigDecimal BigDecimal100", - "persistence-modifier= none protected transient volatile BigDecimal BigDecimal101", - "persistence-modifier= persistent protected transient volatile BigDecimal BigDecimal102", - "persistence-modifier= persistent embedded= true protected transient volatile BigDecimal BigDecimal103", - "persistence-modifier= persistent embedded= false protected transient volatile BigDecimal BigDecimal104", - "persistence-modifier= transactional protected transient volatile BigDecimal BigDecimal105", - "protected static transient final BigDecimal BigDecimal106", - "protected static transient volatile BigDecimal BigDecimal107", - "BigDecimal BigDecimal108", - "embedded= true BigDecimal BigDecimal109", - "embedded= false BigDecimal BigDecimal110", - "persistence-modifier= none BigDecimal BigDecimal111", - "persistence-modifier= persistent BigDecimal BigDecimal112", - "persistence-modifier= persistent embedded= true BigDecimal BigDecimal113", - "persistence-modifier= persistent embedded= false BigDecimal BigDecimal114", - "persistence-modifier= transactional BigDecimal BigDecimal115", - "static BigDecimal BigDecimal116", - "transient BigDecimal BigDecimal117", - "persistence-modifier= none transient BigDecimal BigDecimal118", - "persistence-modifier= persistent transient BigDecimal BigDecimal119", - "persistence-modifier= persistent embedded= true transient BigDecimal BigDecimal120", - "persistence-modifier= persistent embedded= false transient BigDecimal BigDecimal121", - "persistence-modifier= transactional transient BigDecimal BigDecimal122", - "final BigDecimal BigDecimal123", - "volatile BigDecimal BigDecimal124", - "embedded= true volatile BigDecimal BigDecimal125", - "embedded= false volatile BigDecimal BigDecimal126", - "persistence-modifier= none volatile BigDecimal BigDecimal127", - "persistence-modifier= persistent volatile BigDecimal BigDecimal128", - "persistence-modifier= persistent embedded= true volatile BigDecimal BigDecimal129", - "persistence-modifier= persistent embedded= false volatile BigDecimal BigDecimal130", - "persistence-modifier= transactional volatile BigDecimal BigDecimal131", - "static transient BigDecimal BigDecimal132", - "static final BigDecimal BigDecimal133", - "static volatile BigDecimal BigDecimal134", - "transient final BigDecimal BigDecimal135", - "transient volatile BigDecimal BigDecimal136", - "persistence-modifier= none transient volatile BigDecimal BigDecimal137", - "persistence-modifier= persistent transient volatile BigDecimal BigDecimal138", - "persistence-modifier= persistent embedded= true transient volatile BigDecimal BigDecimal139", - "persistence-modifier= persistent embedded= false transient volatile BigDecimal BigDecimal140", - "persistence-modifier= transactional transient volatile BigDecimal BigDecimal141", - "static transient final BigDecimal BigDecimal142", - "static transient volatile BigDecimal BigDecimal143" + public static final String [] fieldSpecs = { + "private BigDecimal BigDecimal0", + "embedded= true private BigDecimal BigDecimal1", + "embedded= false private BigDecimal BigDecimal2", + "persistence-modifier= none private BigDecimal BigDecimal3", + "persistence-modifier= persistent private BigDecimal BigDecimal4", + "persistence-modifier= persistent embedded= true private BigDecimal BigDecimal5", + "persistence-modifier= persistent embedded= false private BigDecimal BigDecimal6", + "persistence-modifier= transactional private BigDecimal BigDecimal7", + "private static BigDecimal BigDecimal8", + "private transient BigDecimal BigDecimal9", + "persistence-modifier= none private transient BigDecimal BigDecimal10", + "persistence-modifier= persistent private transient BigDecimal BigDecimal11", + "persistence-modifier= persistent embedded= true private transient BigDecimal BigDecimal12", + "persistence-modifier= persistent embedded= false private transient BigDecimal BigDecimal13", + "persistence-modifier= transactional private transient BigDecimal BigDecimal14", + "private final BigDecimal BigDecimal15", + "private volatile BigDecimal BigDecimal16", + "embedded= true private volatile BigDecimal BigDecimal17", + "embedded= false private volatile BigDecimal BigDecimal18", + "persistence-modifier= none private volatile BigDecimal BigDecimal19", + "persistence-modifier= persistent private volatile BigDecimal BigDecimal20", + "persistence-modifier= persistent embedded= true private volatile BigDecimal BigDecimal21", + "persistence-modifier= persistent embedded= false private volatile BigDecimal BigDecimal22", + "persistence-modifier= transactional private volatile BigDecimal BigDecimal23", + "private static transient BigDecimal BigDecimal24", + "private static final BigDecimal BigDecimal25", + "private static volatile BigDecimal BigDecimal26", + "private transient final BigDecimal BigDecimal27", + "private transient volatile BigDecimal BigDecimal28", + "persistence-modifier= none private transient volatile BigDecimal BigDecimal29", + "persistence-modifier= persistent private transient volatile BigDecimal BigDecimal30", + "persistence-modifier= persistent embedded= true private transient volatile BigDecimal BigDecimal31", + "persistence-modifier= persistent embedded= false private transient volatile BigDecimal BigDecimal32", + "persistence-modifier= transactional private transient volatile BigDecimal BigDecimal33", + "private static transient final BigDecimal BigDecimal34", + "private static transient volatile BigDecimal BigDecimal35", + "public BigDecimal BigDecimal36", + "embedded= true public BigDecimal BigDecimal37", + "embedded= false public BigDecimal BigDecimal38", + "persistence-modifier= none public BigDecimal BigDecimal39", + "persistence-modifier= persistent public BigDecimal BigDecimal40", + "persistence-modifier= persistent embedded= true public BigDecimal BigDecimal41", + "persistence-modifier= persistent embedded= false public BigDecimal BigDecimal42", + "persistence-modifier= transactional public BigDecimal BigDecimal43", + "public static BigDecimal BigDecimal44", + "public transient BigDecimal BigDecimal45", + "persistence-modifier= none public transient BigDecimal BigDecimal46", + "persistence-modifier= persistent public transient BigDecimal BigDecimal47", + "persistence-modifier= persistent embedded= true public transient BigDecimal BigDecimal48", + "persistence-modifier= persistent embedded= false public transient BigDecimal BigDecimal49", + "persistence-modifier= transactional public transient BigDecimal BigDecimal50", + "public final BigDecimal BigDecimal51", + "public volatile BigDecimal BigDecimal52", + "embedded= true public volatile BigDecimal BigDecimal53", + "embedded= false public volatile BigDecimal BigDecimal54", + "persistence-modifier= none public volatile BigDecimal BigDecimal55", + "persistence-modifier= persistent public volatile BigDecimal BigDecimal56", + "persistence-modifier= persistent embedded= true public volatile BigDecimal BigDecimal57", + "persistence-modifier= persistent embedded= false public volatile BigDecimal BigDecimal58", + "persistence-modifier= transactional public volatile BigDecimal BigDecimal59", + "public static transient BigDecimal BigDecimal60", + "public static final BigDecimal BigDecimal61", + "public static volatile BigDecimal BigDecimal62", + "public transient final BigDecimal BigDecimal63", + "public transient volatile BigDecimal BigDecimal64", + "persistence-modifier= none public transient volatile BigDecimal BigDecimal65", + "persistence-modifier= persistent public transient volatile BigDecimal BigDecimal66", + "persistence-modifier= persistent embedded= true public transient volatile BigDecimal BigDecimal67", + "persistence-modifier= persistent embedded= false public transient volatile BigDecimal BigDecimal68", + "persistence-modifier= transactional public transient volatile BigDecimal BigDecimal69", + "public static transient final BigDecimal BigDecimal70", + "public static transient volatile BigDecimal BigDecimal71", + "protected BigDecimal BigDecimal72", + "embedded= true protected BigDecimal BigDecimal73", + "embedded= false protected BigDecimal BigDecimal74", + "persistence-modifier= none protected BigDecimal BigDecimal75", + "persistence-modifier= persistent protected BigDecimal BigDecimal76", + "persistence-modifier= persistent embedded= true protected BigDecimal BigDecimal77", + "persistence-modifier= persistent embedded= false protected BigDecimal BigDecimal78", + "persistence-modifier= transactional protected BigDecimal BigDecimal79", + "protected static BigDecimal BigDecimal80", + "protected transient BigDecimal BigDecimal81", + "persistence-modifier= none protected transient BigDecimal BigDecimal82", + "persistence-modifier= persistent protected transient BigDecimal BigDecimal83", + "persistence-modifier= persistent embedded= true protected transient BigDecimal BigDecimal84", + "persistence-modifier= persistent embedded= false protected transient BigDecimal BigDecimal85", + "persistence-modifier= transactional protected transient BigDecimal BigDecimal86", + "protected final BigDecimal BigDecimal87", + "protected volatile BigDecimal BigDecimal88", + "embedded= true protected volatile BigDecimal BigDecimal89", + "embedded= false protected volatile BigDecimal BigDecimal90", + "persistence-modifier= none protected volatile BigDecimal BigDecimal91", + "persistence-modifier= persistent protected volatile BigDecimal BigDecimal92", + "persistence-modifier= persistent embedded= true protected volatile BigDecimal BigDecimal93", + "persistence-modifier= persistent embedded= false protected volatile BigDecimal BigDecimal94", + "persistence-modifier= transactional protected volatile BigDecimal BigDecimal95", + "protected static transient BigDecimal BigDecimal96", + "protected static final BigDecimal BigDecimal97", + "protected static volatile BigDecimal BigDecimal98", + "protected transient final BigDecimal BigDecimal99", + "protected transient volatile BigDecimal BigDecimal100", + "persistence-modifier= none protected transient volatile BigDecimal BigDecimal101", + "persistence-modifier= persistent protected transient volatile BigDecimal BigDecimal102", + "persistence-modifier= persistent embedded= true protected transient volatile BigDecimal BigDecimal103", + "persistence-modifier= persistent embedded= false protected transient volatile BigDecimal BigDecimal104", + "persistence-modifier= transactional protected transient volatile BigDecimal BigDecimal105", + "protected static transient final BigDecimal BigDecimal106", + "protected static transient volatile BigDecimal BigDecimal107", + "BigDecimal BigDecimal108", + "embedded= true BigDecimal BigDecimal109", + "embedded= false BigDecimal BigDecimal110", + "persistence-modifier= none BigDecimal BigDecimal111", + "persistence-modifier= persistent BigDecimal BigDecimal112", + "persistence-modifier= persistent embedded= true BigDecimal BigDecimal113", + "persistence-modifier= persistent embedded= false BigDecimal BigDecimal114", + "persistence-modifier= transactional BigDecimal BigDecimal115", + "static BigDecimal BigDecimal116", + "transient BigDecimal BigDecimal117", + "persistence-modifier= none transient BigDecimal BigDecimal118", + "persistence-modifier= persistent transient BigDecimal BigDecimal119", + "persistence-modifier= persistent embedded= true transient BigDecimal BigDecimal120", + "persistence-modifier= persistent embedded= false transient BigDecimal BigDecimal121", + "persistence-modifier= transactional transient BigDecimal BigDecimal122", + "final BigDecimal BigDecimal123", + "volatile BigDecimal BigDecimal124", + "embedded= true volatile BigDecimal BigDecimal125", + "embedded= false volatile BigDecimal BigDecimal126", + "persistence-modifier= none volatile BigDecimal BigDecimal127", + "persistence-modifier= persistent volatile BigDecimal BigDecimal128", + "persistence-modifier= persistent embedded= true volatile BigDecimal BigDecimal129", + "persistence-modifier= persistent embedded= false volatile BigDecimal BigDecimal130", + "persistence-modifier= transactional volatile BigDecimal BigDecimal131", + "static transient BigDecimal BigDecimal132", + "static final BigDecimal BigDecimal133", + "static volatile BigDecimal BigDecimal134", + "transient final BigDecimal BigDecimal135", + "transient volatile BigDecimal BigDecimal136", + "persistence-modifier= none transient volatile BigDecimal BigDecimal137", + "persistence-modifier= persistent transient volatile BigDecimal BigDecimal138", + "persistence-modifier= persistent embedded= true transient volatile BigDecimal BigDecimal139", + "persistence-modifier= persistent embedded= false transient volatile BigDecimal BigDecimal140", + "persistence-modifier= transactional transient volatile BigDecimal BigDecimal141", + "static transient final BigDecimal BigDecimal142", + "static transient volatile BigDecimal BigDecimal143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public BigDecimal get(int index) { - switch (index) { - case (0): + public BigDecimal get(int index) + { + switch (index) + { + case(0): return BigDecimal0; - case (1): + case(1): return BigDecimal1; - case (2): + case(2): return BigDecimal2; - case (3): + case(3): return BigDecimal3; - case (4): + case(4): return BigDecimal4; - case (5): + case(5): return BigDecimal5; - case (6): + case(6): return BigDecimal6; - case (7): + case(7): return BigDecimal7; - case (8): + case(8): return BigDecimal8; - case (9): + case(9): return BigDecimal9; - case (10): + case(10): return BigDecimal10; - case (11): + case(11): return BigDecimal11; - case (12): + case(12): return BigDecimal12; - case (13): + case(13): return BigDecimal13; - case (14): + case(14): return BigDecimal14; - case (15): + case(15): return BigDecimal15; - case (16): + case(16): return BigDecimal16; - case (17): + case(17): return BigDecimal17; - case (18): + case(18): return BigDecimal18; - case (19): + case(19): return BigDecimal19; - case (20): + case(20): return BigDecimal20; - case (21): + case(21): return BigDecimal21; - case (22): + case(22): return BigDecimal22; - case (23): + case(23): return BigDecimal23; - case (24): + case(24): return BigDecimal24; - case (25): + case(25): return BigDecimal25; - case (26): + case(26): return BigDecimal26; - case (27): + case(27): return BigDecimal27; - case (28): + case(28): return BigDecimal28; - case (29): + case(29): return BigDecimal29; - case (30): + case(30): return BigDecimal30; - case (31): + case(31): return BigDecimal31; - case (32): + case(32): return BigDecimal32; - case (33): + case(33): return BigDecimal33; - case (34): + case(34): return BigDecimal34; - case (35): + case(35): return BigDecimal35; - case (36): + case(36): return BigDecimal36; - case (37): + case(37): return BigDecimal37; - case (38): + case(38): return BigDecimal38; - case (39): + case(39): return BigDecimal39; - case (40): + case(40): return BigDecimal40; - case (41): + case(41): return BigDecimal41; - case (42): + case(42): return BigDecimal42; - case (43): + case(43): return BigDecimal43; - case (44): + case(44): return BigDecimal44; - case (45): + case(45): return BigDecimal45; - case (46): + case(46): return BigDecimal46; - case (47): + case(47): return BigDecimal47; - case (48): + case(48): return BigDecimal48; - case (49): + case(49): return BigDecimal49; - case (50): + case(50): return BigDecimal50; - case (51): + case(51): return BigDecimal51; - case (52): + case(52): return BigDecimal52; - case (53): + case(53): return BigDecimal53; - case (54): + case(54): return BigDecimal54; - case (55): + case(55): return BigDecimal55; - case (56): + case(56): return BigDecimal56; - case (57): + case(57): return BigDecimal57; - case (58): + case(58): return BigDecimal58; - case (59): + case(59): return BigDecimal59; - case (60): + case(60): return BigDecimal60; - case (61): + case(61): return BigDecimal61; - case (62): + case(62): return BigDecimal62; - case (63): + case(63): return BigDecimal63; - case (64): + case(64): return BigDecimal64; - case (65): + case(65): return BigDecimal65; - case (66): + case(66): return BigDecimal66; - case (67): + case(67): return BigDecimal67; - case (68): + case(68): return BigDecimal68; - case (69): + case(69): return BigDecimal69; - case (70): + case(70): return BigDecimal70; - case (71): + case(71): return BigDecimal71; - case (72): + case(72): return BigDecimal72; - case (73): + case(73): return BigDecimal73; - case (74): + case(74): return BigDecimal74; - case (75): + case(75): return BigDecimal75; - case (76): + case(76): return BigDecimal76; - case (77): + case(77): return BigDecimal77; - case (78): + case(78): return BigDecimal78; - case (79): + case(79): return BigDecimal79; - case (80): + case(80): return BigDecimal80; - case (81): + case(81): return BigDecimal81; - case (82): + case(82): return BigDecimal82; - case (83): + case(83): return BigDecimal83; - case (84): + case(84): return BigDecimal84; - case (85): + case(85): return BigDecimal85; - case (86): + case(86): return BigDecimal86; - case (87): + case(87): return BigDecimal87; - case (88): + case(88): return BigDecimal88; - case (89): + case(89): return BigDecimal89; - case (90): + case(90): return BigDecimal90; - case (91): + case(91): return BigDecimal91; - case (92): + case(92): return BigDecimal92; - case (93): + case(93): return BigDecimal93; - case (94): + case(94): return BigDecimal94; - case (95): + case(95): return BigDecimal95; - case (96): + case(96): return BigDecimal96; - case (97): + case(97): return BigDecimal97; - case (98): + case(98): return BigDecimal98; - case (99): + case(99): return BigDecimal99; - case (100): + case(100): return BigDecimal100; - case (101): + case(101): return BigDecimal101; - case (102): + case(102): return BigDecimal102; - case (103): + case(103): return BigDecimal103; - case (104): + case(104): return BigDecimal104; - case (105): + case(105): return BigDecimal105; - case (106): + case(106): return BigDecimal106; - case (107): + case(107): return BigDecimal107; - case (108): + case(108): return BigDecimal108; - case (109): + case(109): return BigDecimal109; - case (110): + case(110): return BigDecimal110; - case (111): + case(111): return BigDecimal111; - case (112): + case(112): return BigDecimal112; - case (113): + case(113): return BigDecimal113; - case (114): + case(114): return BigDecimal114; - case (115): + case(115): return BigDecimal115; - case (116): + case(116): return BigDecimal116; - case (117): + case(117): return BigDecimal117; - case (118): + case(118): return BigDecimal118; - case (119): + case(119): return BigDecimal119; - case (120): + case(120): return BigDecimal120; - case (121): + case(121): return BigDecimal121; - case (122): + case(122): return BigDecimal122; - case (123): + case(123): return BigDecimal123; - case (124): + case(124): return BigDecimal124; - case (125): + case(125): return BigDecimal125; - case (126): + case(126): return BigDecimal126; - case (127): + case(127): return BigDecimal127; - case (128): + case(128): return BigDecimal128; - case (129): + case(129): return BigDecimal129; - case (130): + case(130): return BigDecimal130; - case (131): + case(131): return BigDecimal131; - case (132): + case(132): return BigDecimal132; - case (133): + case(133): return BigDecimal133; - case (134): + case(134): return BigDecimal134; - case (135): + case(135): return BigDecimal135; - case (136): + case(136): return BigDecimal136; - case (137): + case(137): return BigDecimal137; - case (138): + case(138): return BigDecimal138; - case (139): + case(139): return BigDecimal139; - case (140): + case(140): return BigDecimal140; - case (141): + case(141): return BigDecimal141; - case (142): + case(142): return BigDecimal142; - case (143): + case(143): return BigDecimal143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, BigDecimal value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - BigDecimal0 = value; - break; - case (1): - BigDecimal1 = value; - break; - case (2): - BigDecimal2 = value; - break; - case (3): - BigDecimal3 = value; - break; - case (4): - BigDecimal4 = value; - break; - case (5): - BigDecimal5 = value; - break; - case (6): - BigDecimal6 = value; - break; - case (7): - BigDecimal7 = value; - break; - case (8): - BigDecimal8 = value; - break; - case (9): - BigDecimal9 = value; - break; - case (10): - BigDecimal10 = value; - break; - case (11): - BigDecimal11 = value; - break; - case (12): - BigDecimal12 = value; - break; - case (13): - BigDecimal13 = value; - break; - case (14): - BigDecimal14 = value; - break; - case (16): - BigDecimal16 = value; - break; - case (17): - BigDecimal17 = value; - break; - case (18): - BigDecimal18 = value; - break; - case (19): - BigDecimal19 = value; - break; - case (20): - BigDecimal20 = value; - break; - case (21): - BigDecimal21 = value; - break; - case (22): - BigDecimal22 = value; - break; - case (23): - BigDecimal23 = value; - break; - case (24): - BigDecimal24 = value; - break; - case (26): - BigDecimal26 = value; - break; - case (28): - BigDecimal28 = value; - break; - case (29): - BigDecimal29 = value; - break; - case (30): - BigDecimal30 = value; - break; - case (31): - BigDecimal31 = value; - break; - case (32): - BigDecimal32 = value; - break; - case (33): - BigDecimal33 = value; - break; - case (35): - BigDecimal35 = value; - break; - case (36): - BigDecimal36 = value; - break; - case (37): - BigDecimal37 = value; - break; - case (38): - BigDecimal38 = value; - break; - case (39): - BigDecimal39 = value; - break; - case (40): - BigDecimal40 = value; - break; - case (41): - BigDecimal41 = value; - break; - case (42): - BigDecimal42 = value; - break; - case (43): - BigDecimal43 = value; - break; - case (44): - BigDecimal44 = value; - break; - case (45): - BigDecimal45 = value; - break; - case (46): - BigDecimal46 = value; - break; - case (47): - BigDecimal47 = value; - break; - case (48): - BigDecimal48 = value; - break; - case (49): - BigDecimal49 = value; - break; - case (50): - BigDecimal50 = value; - break; - case (52): - BigDecimal52 = value; - break; - case (53): - BigDecimal53 = value; - break; - case (54): - BigDecimal54 = value; - break; - case (55): - BigDecimal55 = value; - break; - case (56): - BigDecimal56 = value; - break; - case (57): - BigDecimal57 = value; - break; - case (58): - BigDecimal58 = value; - break; - case (59): - BigDecimal59 = value; - break; - case (60): - BigDecimal60 = value; - break; - case (62): - BigDecimal62 = value; - break; - case (64): - BigDecimal64 = value; - break; - case (65): - BigDecimal65 = value; - break; - case (66): - BigDecimal66 = value; - break; - case (67): - BigDecimal67 = value; - break; - case (68): - BigDecimal68 = value; - break; - case (69): - BigDecimal69 = value; - break; - case (71): - BigDecimal71 = value; - break; - case (72): - BigDecimal72 = value; - break; - case (73): - BigDecimal73 = value; - break; - case (74): - BigDecimal74 = value; - break; - case (75): - BigDecimal75 = value; - break; - case (76): - BigDecimal76 = value; - break; - case (77): - BigDecimal77 = value; - break; - case (78): - BigDecimal78 = value; - break; - case (79): - BigDecimal79 = value; - break; - case (80): - BigDecimal80 = value; - break; - case (81): - BigDecimal81 = value; - break; - case (82): - BigDecimal82 = value; - break; - case (83): - BigDecimal83 = value; - break; - case (84): - BigDecimal84 = value; - break; - case (85): - BigDecimal85 = value; - break; - case (86): - BigDecimal86 = value; - break; - case (88): - BigDecimal88 = value; - break; - case (89): - BigDecimal89 = value; - break; - case (90): - BigDecimal90 = value; - break; - case (91): - BigDecimal91 = value; - break; - case (92): - BigDecimal92 = value; - break; - case (93): - BigDecimal93 = value; - break; - case (94): - BigDecimal94 = value; - break; - case (95): - BigDecimal95 = value; - break; - case (96): - BigDecimal96 = value; - break; - case (98): - BigDecimal98 = value; - break; - case (100): - BigDecimal100 = value; - break; - case (101): - BigDecimal101 = value; - break; - case (102): - BigDecimal102 = value; - break; - case (103): - BigDecimal103 = value; - break; - case (104): - BigDecimal104 = value; - break; - case (105): - BigDecimal105 = value; - break; - case (107): - BigDecimal107 = value; - break; - case (108): - BigDecimal108 = value; - break; - case (109): - BigDecimal109 = value; - break; - case (110): - BigDecimal110 = value; - break; - case (111): - BigDecimal111 = value; - break; - case (112): - BigDecimal112 = value; - break; - case (113): - BigDecimal113 = value; - break; - case (114): - BigDecimal114 = value; - break; - case (115): - BigDecimal115 = value; - break; - case (116): - BigDecimal116 = value; - break; - case (117): - BigDecimal117 = value; - break; - case (118): - BigDecimal118 = value; - break; - case (119): - BigDecimal119 = value; - break; - case (120): - BigDecimal120 = value; - break; - case (121): - BigDecimal121 = value; - break; - case (122): - BigDecimal122 = value; - break; - case (124): - BigDecimal124 = value; - break; - case (125): - BigDecimal125 = value; - break; - case (126): - BigDecimal126 = value; - break; - case (127): - BigDecimal127 = value; - break; - case (128): - BigDecimal128 = value; - break; - case (129): - BigDecimal129 = value; - break; - case (130): - BigDecimal130 = value; - break; - case (131): - BigDecimal131 = value; - break; - case (132): - BigDecimal132 = value; - break; - case (134): - BigDecimal134 = value; - break; - case (136): - BigDecimal136 = value; - break; - case (137): - BigDecimal137 = value; - break; - case (138): - BigDecimal138 = value; - break; - case (139): - BigDecimal139 = value; - break; - case (140): - BigDecimal140 = value; - break; - case (141): - BigDecimal141 = value; - break; - case (143): - BigDecimal143 = value; - break; + public boolean set(int index,BigDecimal value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + BigDecimal0= value; + break; + case(1): + BigDecimal1= value; + break; + case(2): + BigDecimal2= value; + break; + case(3): + BigDecimal3= value; + break; + case(4): + BigDecimal4= value; + break; + case(5): + BigDecimal5= value; + break; + case(6): + BigDecimal6= value; + break; + case(7): + BigDecimal7= value; + break; + case(8): + BigDecimal8= value; + break; + case(9): + BigDecimal9= value; + break; + case(10): + BigDecimal10= value; + break; + case(11): + BigDecimal11= value; + break; + case(12): + BigDecimal12= value; + break; + case(13): + BigDecimal13= value; + break; + case(14): + BigDecimal14= value; + break; + case(16): + BigDecimal16= value; + break; + case(17): + BigDecimal17= value; + break; + case(18): + BigDecimal18= value; + break; + case(19): + BigDecimal19= value; + break; + case(20): + BigDecimal20= value; + break; + case(21): + BigDecimal21= value; + break; + case(22): + BigDecimal22= value; + break; + case(23): + BigDecimal23= value; + break; + case(24): + BigDecimal24= value; + break; + case(26): + BigDecimal26= value; + break; + case(28): + BigDecimal28= value; + break; + case(29): + BigDecimal29= value; + break; + case(30): + BigDecimal30= value; + break; + case(31): + BigDecimal31= value; + break; + case(32): + BigDecimal32= value; + break; + case(33): + BigDecimal33= value; + break; + case(35): + BigDecimal35= value; + break; + case(36): + BigDecimal36= value; + break; + case(37): + BigDecimal37= value; + break; + case(38): + BigDecimal38= value; + break; + case(39): + BigDecimal39= value; + break; + case(40): + BigDecimal40= value; + break; + case(41): + BigDecimal41= value; + break; + case(42): + BigDecimal42= value; + break; + case(43): + BigDecimal43= value; + break; + case(44): + BigDecimal44= value; + break; + case(45): + BigDecimal45= value; + break; + case(46): + BigDecimal46= value; + break; + case(47): + BigDecimal47= value; + break; + case(48): + BigDecimal48= value; + break; + case(49): + BigDecimal49= value; + break; + case(50): + BigDecimal50= value; + break; + case(52): + BigDecimal52= value; + break; + case(53): + BigDecimal53= value; + break; + case(54): + BigDecimal54= value; + break; + case(55): + BigDecimal55= value; + break; + case(56): + BigDecimal56= value; + break; + case(57): + BigDecimal57= value; + break; + case(58): + BigDecimal58= value; + break; + case(59): + BigDecimal59= value; + break; + case(60): + BigDecimal60= value; + break; + case(62): + BigDecimal62= value; + break; + case(64): + BigDecimal64= value; + break; + case(65): + BigDecimal65= value; + break; + case(66): + BigDecimal66= value; + break; + case(67): + BigDecimal67= value; + break; + case(68): + BigDecimal68= value; + break; + case(69): + BigDecimal69= value; + break; + case(71): + BigDecimal71= value; + break; + case(72): + BigDecimal72= value; + break; + case(73): + BigDecimal73= value; + break; + case(74): + BigDecimal74= value; + break; + case(75): + BigDecimal75= value; + break; + case(76): + BigDecimal76= value; + break; + case(77): + BigDecimal77= value; + break; + case(78): + BigDecimal78= value; + break; + case(79): + BigDecimal79= value; + break; + case(80): + BigDecimal80= value; + break; + case(81): + BigDecimal81= value; + break; + case(82): + BigDecimal82= value; + break; + case(83): + BigDecimal83= value; + break; + case(84): + BigDecimal84= value; + break; + case(85): + BigDecimal85= value; + break; + case(86): + BigDecimal86= value; + break; + case(88): + BigDecimal88= value; + break; + case(89): + BigDecimal89= value; + break; + case(90): + BigDecimal90= value; + break; + case(91): + BigDecimal91= value; + break; + case(92): + BigDecimal92= value; + break; + case(93): + BigDecimal93= value; + break; + case(94): + BigDecimal94= value; + break; + case(95): + BigDecimal95= value; + break; + case(96): + BigDecimal96= value; + break; + case(98): + BigDecimal98= value; + break; + case(100): + BigDecimal100= value; + break; + case(101): + BigDecimal101= value; + break; + case(102): + BigDecimal102= value; + break; + case(103): + BigDecimal103= value; + break; + case(104): + BigDecimal104= value; + break; + case(105): + BigDecimal105= value; + break; + case(107): + BigDecimal107= value; + break; + case(108): + BigDecimal108= value; + break; + case(109): + BigDecimal109= value; + break; + case(110): + BigDecimal110= value; + break; + case(111): + BigDecimal111= value; + break; + case(112): + BigDecimal112= value; + break; + case(113): + BigDecimal113= value; + break; + case(114): + BigDecimal114= value; + break; + case(115): + BigDecimal115= value; + break; + case(116): + BigDecimal116= value; + break; + case(117): + BigDecimal117= value; + break; + case(118): + BigDecimal118= value; + break; + case(119): + BigDecimal119= value; + break; + case(120): + BigDecimal120= value; + break; + case(121): + BigDecimal121= value; + break; + case(122): + BigDecimal122= value; + break; + case(124): + BigDecimal124= value; + break; + case(125): + BigDecimal125= value; + break; + case(126): + BigDecimal126= value; + break; + case(127): + BigDecimal127= value; + break; + case(128): + BigDecimal128= value; + break; + case(129): + BigDecimal129= value; + break; + case(130): + BigDecimal130= value; + break; + case(131): + BigDecimal131= value; + break; + case(132): + BigDecimal132= value; + break; + case(134): + BigDecimal134= value; + break; + case(136): + BigDecimal136= value; + break; + case(137): + BigDecimal137= value; + break; + case(138): + BigDecimal138= value; + break; + case(139): + BigDecimal139= value; + break; + case(140): + BigDecimal140= value; + break; + case(141): + BigDecimal141= value; + break; + case(143): + BigDecimal143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfBigInteger.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfBigInteger.java index 9b6fdb057..b5011ce7a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfBigInteger.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfBigInteger.java @@ -5,22 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -import java.math.BigInteger; -public class FieldsOfBigInteger { +import java.math.*; +public class FieldsOfBigInteger { public int identifier; private BigInteger BigInteger0; private BigInteger BigInteger1; @@ -49,14 +49,14 @@ public class FieldsOfBigInteger { private static transient BigInteger BigInteger24; private static final BigInteger BigInteger25 = new BigInteger("100"); private static volatile BigInteger BigInteger26; - private final transient BigInteger BigInteger27 = new BigInteger("100"); + private transient final BigInteger BigInteger27 = new BigInteger("100"); private transient volatile BigInteger BigInteger28; private transient volatile BigInteger BigInteger29; private transient volatile BigInteger BigInteger30; private transient volatile BigInteger BigInteger31; private transient volatile BigInteger BigInteger32; private transient volatile BigInteger BigInteger33; - private static final transient BigInteger BigInteger34 = new BigInteger("100"); + private static transient final BigInteger BigInteger34 = new BigInteger("100"); private static transient volatile BigInteger BigInteger35; public BigInteger BigInteger36; public BigInteger BigInteger37; @@ -85,14 +85,14 @@ public class FieldsOfBigInteger { public static transient BigInteger BigInteger60; public static final BigInteger BigInteger61 = new BigInteger("100"); public static volatile BigInteger BigInteger62; - public final transient BigInteger BigInteger63 = new BigInteger("100"); + public transient final BigInteger BigInteger63 = new BigInteger("100"); public transient volatile BigInteger BigInteger64; public transient volatile BigInteger BigInteger65; public transient volatile BigInteger BigInteger66; public transient volatile BigInteger BigInteger67; public transient volatile BigInteger BigInteger68; public transient volatile BigInteger BigInteger69; - public static final transient BigInteger BigInteger70 = new BigInteger("100"); + public static transient final BigInteger BigInteger70 = new BigInteger("100"); public static transient volatile BigInteger BigInteger71; protected BigInteger BigInteger72; protected BigInteger BigInteger73; @@ -121,14 +121,14 @@ public class FieldsOfBigInteger { protected static transient BigInteger BigInteger96; protected static final BigInteger BigInteger97 = new BigInteger("100"); protected static volatile BigInteger BigInteger98; - protected final transient BigInteger BigInteger99 = new BigInteger("100"); + protected transient final BigInteger BigInteger99 = new BigInteger("100"); protected transient volatile BigInteger BigInteger100; protected transient volatile BigInteger BigInteger101; protected transient volatile BigInteger BigInteger102; protected transient volatile BigInteger BigInteger103; protected transient volatile BigInteger BigInteger104; protected transient volatile BigInteger BigInteger105; - protected static final transient BigInteger BigInteger106 = new BigInteger("100"); + protected static transient final BigInteger BigInteger106 = new BigInteger("100"); protected static transient volatile BigInteger BigInteger107; BigInteger BigInteger108; BigInteger BigInteger109; @@ -157,936 +157,935 @@ public class FieldsOfBigInteger { static transient BigInteger BigInteger132; static final BigInteger BigInteger133 = new BigInteger("100"); static volatile BigInteger BigInteger134; - final transient BigInteger BigInteger135 = new BigInteger("100"); + transient final BigInteger BigInteger135 = new BigInteger("100"); transient volatile BigInteger BigInteger136; transient volatile BigInteger BigInteger137; transient volatile BigInteger BigInteger138; transient volatile BigInteger BigInteger139; transient volatile BigInteger BigInteger140; transient volatile BigInteger BigInteger141; - static final transient BigInteger BigInteger142 = new BigInteger("100"); + static transient final BigInteger BigInteger142 = new BigInteger("100"); static transient volatile BigInteger BigInteger143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private BigInteger BigInteger0", - "embedded= true private BigInteger BigInteger1", - "embedded= false private BigInteger BigInteger2", - "persistence-modifier= none private BigInteger BigInteger3", - "persistence-modifier= persistent private BigInteger BigInteger4", - "persistence-modifier= persistent embedded= true private BigInteger BigInteger5", - "persistence-modifier= persistent embedded= false private BigInteger BigInteger6", - "persistence-modifier= transactional private BigInteger BigInteger7", - "private static BigInteger BigInteger8", - "private transient BigInteger BigInteger9", - "persistence-modifier= none private transient BigInteger BigInteger10", - "persistence-modifier= persistent private transient BigInteger BigInteger11", - "persistence-modifier= persistent embedded= true private transient BigInteger BigInteger12", - "persistence-modifier= persistent embedded= false private transient BigInteger BigInteger13", - "persistence-modifier= transactional private transient BigInteger BigInteger14", - "private final BigInteger BigInteger15", - "private volatile BigInteger BigInteger16", - "embedded= true private volatile BigInteger BigInteger17", - "embedded= false private volatile BigInteger BigInteger18", - "persistence-modifier= none private volatile BigInteger BigInteger19", - "persistence-modifier= persistent private volatile BigInteger BigInteger20", - "persistence-modifier= persistent embedded= true private volatile BigInteger BigInteger21", - "persistence-modifier= persistent embedded= false private volatile BigInteger BigInteger22", - "persistence-modifier= transactional private volatile BigInteger BigInteger23", - "private static transient BigInteger BigInteger24", - "private static final BigInteger BigInteger25", - "private static volatile BigInteger BigInteger26", - "private transient final BigInteger BigInteger27", - "private transient volatile BigInteger BigInteger28", - "persistence-modifier= none private transient volatile BigInteger BigInteger29", - "persistence-modifier= persistent private transient volatile BigInteger BigInteger30", - "persistence-modifier= persistent embedded= true private transient volatile BigInteger BigInteger31", - "persistence-modifier= persistent embedded= false private transient volatile BigInteger BigInteger32", - "persistence-modifier= transactional private transient volatile BigInteger BigInteger33", - "private static transient final BigInteger BigInteger34", - "private static transient volatile BigInteger BigInteger35", - "public BigInteger BigInteger36", - "embedded= true public BigInteger BigInteger37", - "embedded= false public BigInteger BigInteger38", - "persistence-modifier= none public BigInteger BigInteger39", - "persistence-modifier= persistent public BigInteger BigInteger40", - "persistence-modifier= persistent embedded= true public BigInteger BigInteger41", - "persistence-modifier= persistent embedded= false public BigInteger BigInteger42", - "persistence-modifier= transactional public BigInteger BigInteger43", - "public static BigInteger BigInteger44", - "public transient BigInteger BigInteger45", - "persistence-modifier= none public transient BigInteger BigInteger46", - "persistence-modifier= persistent public transient BigInteger BigInteger47", - "persistence-modifier= persistent embedded= true public transient BigInteger BigInteger48", - "persistence-modifier= persistent embedded= false public transient BigInteger BigInteger49", - "persistence-modifier= transactional public transient BigInteger BigInteger50", - "public final BigInteger BigInteger51", - "public volatile BigInteger BigInteger52", - "embedded= true public volatile BigInteger BigInteger53", - "embedded= false public volatile BigInteger BigInteger54", - "persistence-modifier= none public volatile BigInteger BigInteger55", - "persistence-modifier= persistent public volatile BigInteger BigInteger56", - "persistence-modifier= persistent embedded= true public volatile BigInteger BigInteger57", - "persistence-modifier= persistent embedded= false public volatile BigInteger BigInteger58", - "persistence-modifier= transactional public volatile BigInteger BigInteger59", - "public static transient BigInteger BigInteger60", - "public static final BigInteger BigInteger61", - "public static volatile BigInteger BigInteger62", - "public transient final BigInteger BigInteger63", - "public transient volatile BigInteger BigInteger64", - "persistence-modifier= none public transient volatile BigInteger BigInteger65", - "persistence-modifier= persistent public transient volatile BigInteger BigInteger66", - "persistence-modifier= persistent embedded= true public transient volatile BigInteger BigInteger67", - "persistence-modifier= persistent embedded= false public transient volatile BigInteger BigInteger68", - "persistence-modifier= transactional public transient volatile BigInteger BigInteger69", - "public static transient final BigInteger BigInteger70", - "public static transient volatile BigInteger BigInteger71", - "protected BigInteger BigInteger72", - "embedded= true protected BigInteger BigInteger73", - "embedded= false protected BigInteger BigInteger74", - "persistence-modifier= none protected BigInteger BigInteger75", - "persistence-modifier= persistent protected BigInteger BigInteger76", - "persistence-modifier= persistent embedded= true protected BigInteger BigInteger77", - "persistence-modifier= persistent embedded= false protected BigInteger BigInteger78", - "persistence-modifier= transactional protected BigInteger BigInteger79", - "protected static BigInteger BigInteger80", - "protected transient BigInteger BigInteger81", - "persistence-modifier= none protected transient BigInteger BigInteger82", - "persistence-modifier= persistent protected transient BigInteger BigInteger83", - "persistence-modifier= persistent embedded= true protected transient BigInteger BigInteger84", - "persistence-modifier= persistent embedded= false protected transient BigInteger BigInteger85", - "persistence-modifier= transactional protected transient BigInteger BigInteger86", - "protected final BigInteger BigInteger87", - "protected volatile BigInteger BigInteger88", - "embedded= true protected volatile BigInteger BigInteger89", - "embedded= false protected volatile BigInteger BigInteger90", - "persistence-modifier= none protected volatile BigInteger BigInteger91", - "persistence-modifier= persistent protected volatile BigInteger BigInteger92", - "persistence-modifier= persistent embedded= true protected volatile BigInteger BigInteger93", - "persistence-modifier= persistent embedded= false protected volatile BigInteger BigInteger94", - "persistence-modifier= transactional protected volatile BigInteger BigInteger95", - "protected static transient BigInteger BigInteger96", - "protected static final BigInteger BigInteger97", - "protected static volatile BigInteger BigInteger98", - "protected transient final BigInteger BigInteger99", - "protected transient volatile BigInteger BigInteger100", - "persistence-modifier= none protected transient volatile BigInteger BigInteger101", - "persistence-modifier= persistent protected transient volatile BigInteger BigInteger102", - "persistence-modifier= persistent embedded= true protected transient volatile BigInteger BigInteger103", - "persistence-modifier= persistent embedded= false protected transient volatile BigInteger BigInteger104", - "persistence-modifier= transactional protected transient volatile BigInteger BigInteger105", - "protected static transient final BigInteger BigInteger106", - "protected static transient volatile BigInteger BigInteger107", - "BigInteger BigInteger108", - "embedded= true BigInteger BigInteger109", - "embedded= false BigInteger BigInteger110", - "persistence-modifier= none BigInteger BigInteger111", - "persistence-modifier= persistent BigInteger BigInteger112", - "persistence-modifier= persistent embedded= true BigInteger BigInteger113", - "persistence-modifier= persistent embedded= false BigInteger BigInteger114", - "persistence-modifier= transactional BigInteger BigInteger115", - "static BigInteger BigInteger116", - "transient BigInteger BigInteger117", - "persistence-modifier= none transient BigInteger BigInteger118", - "persistence-modifier= persistent transient BigInteger BigInteger119", - "persistence-modifier= persistent embedded= true transient BigInteger BigInteger120", - "persistence-modifier= persistent embedded= false transient BigInteger BigInteger121", - "persistence-modifier= transactional transient BigInteger BigInteger122", - "final BigInteger BigInteger123", - "volatile BigInteger BigInteger124", - "embedded= true volatile BigInteger BigInteger125", - "embedded= false volatile BigInteger BigInteger126", - "persistence-modifier= none volatile BigInteger BigInteger127", - "persistence-modifier= persistent volatile BigInteger BigInteger128", - "persistence-modifier= persistent embedded= true volatile BigInteger BigInteger129", - "persistence-modifier= persistent embedded= false volatile BigInteger BigInteger130", - "persistence-modifier= transactional volatile BigInteger BigInteger131", - "static transient BigInteger BigInteger132", - "static final BigInteger BigInteger133", - "static volatile BigInteger BigInteger134", - "transient final BigInteger BigInteger135", - "transient volatile BigInteger BigInteger136", - "persistence-modifier= none transient volatile BigInteger BigInteger137", - "persistence-modifier= persistent transient volatile BigInteger BigInteger138", - "persistence-modifier= persistent embedded= true transient volatile BigInteger BigInteger139", - "persistence-modifier= persistent embedded= false transient volatile BigInteger BigInteger140", - "persistence-modifier= transactional transient volatile BigInteger BigInteger141", - "static transient final BigInteger BigInteger142", - "static transient volatile BigInteger BigInteger143" + public static final String [] fieldSpecs = { + "private BigInteger BigInteger0", + "embedded= true private BigInteger BigInteger1", + "embedded= false private BigInteger BigInteger2", + "persistence-modifier= none private BigInteger BigInteger3", + "persistence-modifier= persistent private BigInteger BigInteger4", + "persistence-modifier= persistent embedded= true private BigInteger BigInteger5", + "persistence-modifier= persistent embedded= false private BigInteger BigInteger6", + "persistence-modifier= transactional private BigInteger BigInteger7", + "private static BigInteger BigInteger8", + "private transient BigInteger BigInteger9", + "persistence-modifier= none private transient BigInteger BigInteger10", + "persistence-modifier= persistent private transient BigInteger BigInteger11", + "persistence-modifier= persistent embedded= true private transient BigInteger BigInteger12", + "persistence-modifier= persistent embedded= false private transient BigInteger BigInteger13", + "persistence-modifier= transactional private transient BigInteger BigInteger14", + "private final BigInteger BigInteger15", + "private volatile BigInteger BigInteger16", + "embedded= true private volatile BigInteger BigInteger17", + "embedded= false private volatile BigInteger BigInteger18", + "persistence-modifier= none private volatile BigInteger BigInteger19", + "persistence-modifier= persistent private volatile BigInteger BigInteger20", + "persistence-modifier= persistent embedded= true private volatile BigInteger BigInteger21", + "persistence-modifier= persistent embedded= false private volatile BigInteger BigInteger22", + "persistence-modifier= transactional private volatile BigInteger BigInteger23", + "private static transient BigInteger BigInteger24", + "private static final BigInteger BigInteger25", + "private static volatile BigInteger BigInteger26", + "private transient final BigInteger BigInteger27", + "private transient volatile BigInteger BigInteger28", + "persistence-modifier= none private transient volatile BigInteger BigInteger29", + "persistence-modifier= persistent private transient volatile BigInteger BigInteger30", + "persistence-modifier= persistent embedded= true private transient volatile BigInteger BigInteger31", + "persistence-modifier= persistent embedded= false private transient volatile BigInteger BigInteger32", + "persistence-modifier= transactional private transient volatile BigInteger BigInteger33", + "private static transient final BigInteger BigInteger34", + "private static transient volatile BigInteger BigInteger35", + "public BigInteger BigInteger36", + "embedded= true public BigInteger BigInteger37", + "embedded= false public BigInteger BigInteger38", + "persistence-modifier= none public BigInteger BigInteger39", + "persistence-modifier= persistent public BigInteger BigInteger40", + "persistence-modifier= persistent embedded= true public BigInteger BigInteger41", + "persistence-modifier= persistent embedded= false public BigInteger BigInteger42", + "persistence-modifier= transactional public BigInteger BigInteger43", + "public static BigInteger BigInteger44", + "public transient BigInteger BigInteger45", + "persistence-modifier= none public transient BigInteger BigInteger46", + "persistence-modifier= persistent public transient BigInteger BigInteger47", + "persistence-modifier= persistent embedded= true public transient BigInteger BigInteger48", + "persistence-modifier= persistent embedded= false public transient BigInteger BigInteger49", + "persistence-modifier= transactional public transient BigInteger BigInteger50", + "public final BigInteger BigInteger51", + "public volatile BigInteger BigInteger52", + "embedded= true public volatile BigInteger BigInteger53", + "embedded= false public volatile BigInteger BigInteger54", + "persistence-modifier= none public volatile BigInteger BigInteger55", + "persistence-modifier= persistent public volatile BigInteger BigInteger56", + "persistence-modifier= persistent embedded= true public volatile BigInteger BigInteger57", + "persistence-modifier= persistent embedded= false public volatile BigInteger BigInteger58", + "persistence-modifier= transactional public volatile BigInteger BigInteger59", + "public static transient BigInteger BigInteger60", + "public static final BigInteger BigInteger61", + "public static volatile BigInteger BigInteger62", + "public transient final BigInteger BigInteger63", + "public transient volatile BigInteger BigInteger64", + "persistence-modifier= none public transient volatile BigInteger BigInteger65", + "persistence-modifier= persistent public transient volatile BigInteger BigInteger66", + "persistence-modifier= persistent embedded= true public transient volatile BigInteger BigInteger67", + "persistence-modifier= persistent embedded= false public transient volatile BigInteger BigInteger68", + "persistence-modifier= transactional public transient volatile BigInteger BigInteger69", + "public static transient final BigInteger BigInteger70", + "public static transient volatile BigInteger BigInteger71", + "protected BigInteger BigInteger72", + "embedded= true protected BigInteger BigInteger73", + "embedded= false protected BigInteger BigInteger74", + "persistence-modifier= none protected BigInteger BigInteger75", + "persistence-modifier= persistent protected BigInteger BigInteger76", + "persistence-modifier= persistent embedded= true protected BigInteger BigInteger77", + "persistence-modifier= persistent embedded= false protected BigInteger BigInteger78", + "persistence-modifier= transactional protected BigInteger BigInteger79", + "protected static BigInteger BigInteger80", + "protected transient BigInteger BigInteger81", + "persistence-modifier= none protected transient BigInteger BigInteger82", + "persistence-modifier= persistent protected transient BigInteger BigInteger83", + "persistence-modifier= persistent embedded= true protected transient BigInteger BigInteger84", + "persistence-modifier= persistent embedded= false protected transient BigInteger BigInteger85", + "persistence-modifier= transactional protected transient BigInteger BigInteger86", + "protected final BigInteger BigInteger87", + "protected volatile BigInteger BigInteger88", + "embedded= true protected volatile BigInteger BigInteger89", + "embedded= false protected volatile BigInteger BigInteger90", + "persistence-modifier= none protected volatile BigInteger BigInteger91", + "persistence-modifier= persistent protected volatile BigInteger BigInteger92", + "persistence-modifier= persistent embedded= true protected volatile BigInteger BigInteger93", + "persistence-modifier= persistent embedded= false protected volatile BigInteger BigInteger94", + "persistence-modifier= transactional protected volatile BigInteger BigInteger95", + "protected static transient BigInteger BigInteger96", + "protected static final BigInteger BigInteger97", + "protected static volatile BigInteger BigInteger98", + "protected transient final BigInteger BigInteger99", + "protected transient volatile BigInteger BigInteger100", + "persistence-modifier= none protected transient volatile BigInteger BigInteger101", + "persistence-modifier= persistent protected transient volatile BigInteger BigInteger102", + "persistence-modifier= persistent embedded= true protected transient volatile BigInteger BigInteger103", + "persistence-modifier= persistent embedded= false protected transient volatile BigInteger BigInteger104", + "persistence-modifier= transactional protected transient volatile BigInteger BigInteger105", + "protected static transient final BigInteger BigInteger106", + "protected static transient volatile BigInteger BigInteger107", + "BigInteger BigInteger108", + "embedded= true BigInteger BigInteger109", + "embedded= false BigInteger BigInteger110", + "persistence-modifier= none BigInteger BigInteger111", + "persistence-modifier= persistent BigInteger BigInteger112", + "persistence-modifier= persistent embedded= true BigInteger BigInteger113", + "persistence-modifier= persistent embedded= false BigInteger BigInteger114", + "persistence-modifier= transactional BigInteger BigInteger115", + "static BigInteger BigInteger116", + "transient BigInteger BigInteger117", + "persistence-modifier= none transient BigInteger BigInteger118", + "persistence-modifier= persistent transient BigInteger BigInteger119", + "persistence-modifier= persistent embedded= true transient BigInteger BigInteger120", + "persistence-modifier= persistent embedded= false transient BigInteger BigInteger121", + "persistence-modifier= transactional transient BigInteger BigInteger122", + "final BigInteger BigInteger123", + "volatile BigInteger BigInteger124", + "embedded= true volatile BigInteger BigInteger125", + "embedded= false volatile BigInteger BigInteger126", + "persistence-modifier= none volatile BigInteger BigInteger127", + "persistence-modifier= persistent volatile BigInteger BigInteger128", + "persistence-modifier= persistent embedded= true volatile BigInteger BigInteger129", + "persistence-modifier= persistent embedded= false volatile BigInteger BigInteger130", + "persistence-modifier= transactional volatile BigInteger BigInteger131", + "static transient BigInteger BigInteger132", + "static final BigInteger BigInteger133", + "static volatile BigInteger BigInteger134", + "transient final BigInteger BigInteger135", + "transient volatile BigInteger BigInteger136", + "persistence-modifier= none transient volatile BigInteger BigInteger137", + "persistence-modifier= persistent transient volatile BigInteger BigInteger138", + "persistence-modifier= persistent embedded= true transient volatile BigInteger BigInteger139", + "persistence-modifier= persistent embedded= false transient volatile BigInteger BigInteger140", + "persistence-modifier= transactional transient volatile BigInteger BigInteger141", + "static transient final BigInteger BigInteger142", + "static transient volatile BigInteger BigInteger143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public BigInteger get(int index) { - switch (index) { - case (0): + public BigInteger get(int index) + { + switch (index) + { + case(0): return BigInteger0; - case (1): + case(1): return BigInteger1; - case (2): + case(2): return BigInteger2; - case (3): + case(3): return BigInteger3; - case (4): + case(4): return BigInteger4; - case (5): + case(5): return BigInteger5; - case (6): + case(6): return BigInteger6; - case (7): + case(7): return BigInteger7; - case (8): + case(8): return BigInteger8; - case (9): + case(9): return BigInteger9; - case (10): + case(10): return BigInteger10; - case (11): + case(11): return BigInteger11; - case (12): + case(12): return BigInteger12; - case (13): + case(13): return BigInteger13; - case (14): + case(14): return BigInteger14; - case (15): + case(15): return BigInteger15; - case (16): + case(16): return BigInteger16; - case (17): + case(17): return BigInteger17; - case (18): + case(18): return BigInteger18; - case (19): + case(19): return BigInteger19; - case (20): + case(20): return BigInteger20; - case (21): + case(21): return BigInteger21; - case (22): + case(22): return BigInteger22; - case (23): + case(23): return BigInteger23; - case (24): + case(24): return BigInteger24; - case (25): + case(25): return BigInteger25; - case (26): + case(26): return BigInteger26; - case (27): + case(27): return BigInteger27; - case (28): + case(28): return BigInteger28; - case (29): + case(29): return BigInteger29; - case (30): + case(30): return BigInteger30; - case (31): + case(31): return BigInteger31; - case (32): + case(32): return BigInteger32; - case (33): + case(33): return BigInteger33; - case (34): + case(34): return BigInteger34; - case (35): + case(35): return BigInteger35; - case (36): + case(36): return BigInteger36; - case (37): + case(37): return BigInteger37; - case (38): + case(38): return BigInteger38; - case (39): + case(39): return BigInteger39; - case (40): + case(40): return BigInteger40; - case (41): + case(41): return BigInteger41; - case (42): + case(42): return BigInteger42; - case (43): + case(43): return BigInteger43; - case (44): + case(44): return BigInteger44; - case (45): + case(45): return BigInteger45; - case (46): + case(46): return BigInteger46; - case (47): + case(47): return BigInteger47; - case (48): + case(48): return BigInteger48; - case (49): + case(49): return BigInteger49; - case (50): + case(50): return BigInteger50; - case (51): + case(51): return BigInteger51; - case (52): + case(52): return BigInteger52; - case (53): + case(53): return BigInteger53; - case (54): + case(54): return BigInteger54; - case (55): + case(55): return BigInteger55; - case (56): + case(56): return BigInteger56; - case (57): + case(57): return BigInteger57; - case (58): + case(58): return BigInteger58; - case (59): + case(59): return BigInteger59; - case (60): + case(60): return BigInteger60; - case (61): + case(61): return BigInteger61; - case (62): + case(62): return BigInteger62; - case (63): + case(63): return BigInteger63; - case (64): + case(64): return BigInteger64; - case (65): + case(65): return BigInteger65; - case (66): + case(66): return BigInteger66; - case (67): + case(67): return BigInteger67; - case (68): + case(68): return BigInteger68; - case (69): + case(69): return BigInteger69; - case (70): + case(70): return BigInteger70; - case (71): + case(71): return BigInteger71; - case (72): + case(72): return BigInteger72; - case (73): + case(73): return BigInteger73; - case (74): + case(74): return BigInteger74; - case (75): + case(75): return BigInteger75; - case (76): + case(76): return BigInteger76; - case (77): + case(77): return BigInteger77; - case (78): + case(78): return BigInteger78; - case (79): + case(79): return BigInteger79; - case (80): + case(80): return BigInteger80; - case (81): + case(81): return BigInteger81; - case (82): + case(82): return BigInteger82; - case (83): + case(83): return BigInteger83; - case (84): + case(84): return BigInteger84; - case (85): + case(85): return BigInteger85; - case (86): + case(86): return BigInteger86; - case (87): + case(87): return BigInteger87; - case (88): + case(88): return BigInteger88; - case (89): + case(89): return BigInteger89; - case (90): + case(90): return BigInteger90; - case (91): + case(91): return BigInteger91; - case (92): + case(92): return BigInteger92; - case (93): + case(93): return BigInteger93; - case (94): + case(94): return BigInteger94; - case (95): + case(95): return BigInteger95; - case (96): + case(96): return BigInteger96; - case (97): + case(97): return BigInteger97; - case (98): + case(98): return BigInteger98; - case (99): + case(99): return BigInteger99; - case (100): + case(100): return BigInteger100; - case (101): + case(101): return BigInteger101; - case (102): + case(102): return BigInteger102; - case (103): + case(103): return BigInteger103; - case (104): + case(104): return BigInteger104; - case (105): + case(105): return BigInteger105; - case (106): + case(106): return BigInteger106; - case (107): + case(107): return BigInteger107; - case (108): + case(108): return BigInteger108; - case (109): + case(109): return BigInteger109; - case (110): + case(110): return BigInteger110; - case (111): + case(111): return BigInteger111; - case (112): + case(112): return BigInteger112; - case (113): + case(113): return BigInteger113; - case (114): + case(114): return BigInteger114; - case (115): + case(115): return BigInteger115; - case (116): + case(116): return BigInteger116; - case (117): + case(117): return BigInteger117; - case (118): + case(118): return BigInteger118; - case (119): + case(119): return BigInteger119; - case (120): + case(120): return BigInteger120; - case (121): + case(121): return BigInteger121; - case (122): + case(122): return BigInteger122; - case (123): + case(123): return BigInteger123; - case (124): + case(124): return BigInteger124; - case (125): + case(125): return BigInteger125; - case (126): + case(126): return BigInteger126; - case (127): + case(127): return BigInteger127; - case (128): + case(128): return BigInteger128; - case (129): + case(129): return BigInteger129; - case (130): + case(130): return BigInteger130; - case (131): + case(131): return BigInteger131; - case (132): + case(132): return BigInteger132; - case (133): + case(133): return BigInteger133; - case (134): + case(134): return BigInteger134; - case (135): + case(135): return BigInteger135; - case (136): + case(136): return BigInteger136; - case (137): + case(137): return BigInteger137; - case (138): + case(138): return BigInteger138; - case (139): + case(139): return BigInteger139; - case (140): + case(140): return BigInteger140; - case (141): + case(141): return BigInteger141; - case (142): + case(142): return BigInteger142; - case (143): + case(143): return BigInteger143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, BigInteger value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - BigInteger0 = value; - break; - case (1): - BigInteger1 = value; - break; - case (2): - BigInteger2 = value; - break; - case (3): - BigInteger3 = value; - break; - case (4): - BigInteger4 = value; - break; - case (5): - BigInteger5 = value; - break; - case (6): - BigInteger6 = value; - break; - case (7): - BigInteger7 = value; - break; - case (8): - BigInteger8 = value; - break; - case (9): - BigInteger9 = value; - break; - case (10): - BigInteger10 = value; - break; - case (11): - BigInteger11 = value; - break; - case (12): - BigInteger12 = value; - break; - case (13): - BigInteger13 = value; - break; - case (14): - BigInteger14 = value; - break; - case (16): - BigInteger16 = value; - break; - case (17): - BigInteger17 = value; - break; - case (18): - BigInteger18 = value; - break; - case (19): - BigInteger19 = value; - break; - case (20): - BigInteger20 = value; - break; - case (21): - BigInteger21 = value; - break; - case (22): - BigInteger22 = value; - break; - case (23): - BigInteger23 = value; - break; - case (24): - BigInteger24 = value; - break; - case (26): - BigInteger26 = value; - break; - case (28): - BigInteger28 = value; - break; - case (29): - BigInteger29 = value; - break; - case (30): - BigInteger30 = value; - break; - case (31): - BigInteger31 = value; - break; - case (32): - BigInteger32 = value; - break; - case (33): - BigInteger33 = value; - break; - case (35): - BigInteger35 = value; - break; - case (36): - BigInteger36 = value; - break; - case (37): - BigInteger37 = value; - break; - case (38): - BigInteger38 = value; - break; - case (39): - BigInteger39 = value; - break; - case (40): - BigInteger40 = value; - break; - case (41): - BigInteger41 = value; - break; - case (42): - BigInteger42 = value; - break; - case (43): - BigInteger43 = value; - break; - case (44): - BigInteger44 = value; - break; - case (45): - BigInteger45 = value; - break; - case (46): - BigInteger46 = value; - break; - case (47): - BigInteger47 = value; - break; - case (48): - BigInteger48 = value; - break; - case (49): - BigInteger49 = value; - break; - case (50): - BigInteger50 = value; - break; - case (52): - BigInteger52 = value; - break; - case (53): - BigInteger53 = value; - break; - case (54): - BigInteger54 = value; - break; - case (55): - BigInteger55 = value; - break; - case (56): - BigInteger56 = value; - break; - case (57): - BigInteger57 = value; - break; - case (58): - BigInteger58 = value; - break; - case (59): - BigInteger59 = value; - break; - case (60): - BigInteger60 = value; - break; - case (62): - BigInteger62 = value; - break; - case (64): - BigInteger64 = value; - break; - case (65): - BigInteger65 = value; - break; - case (66): - BigInteger66 = value; - break; - case (67): - BigInteger67 = value; - break; - case (68): - BigInteger68 = value; - break; - case (69): - BigInteger69 = value; - break; - case (71): - BigInteger71 = value; - break; - case (72): - BigInteger72 = value; - break; - case (73): - BigInteger73 = value; - break; - case (74): - BigInteger74 = value; - break; - case (75): - BigInteger75 = value; - break; - case (76): - BigInteger76 = value; - break; - case (77): - BigInteger77 = value; - break; - case (78): - BigInteger78 = value; - break; - case (79): - BigInteger79 = value; - break; - case (80): - BigInteger80 = value; - break; - case (81): - BigInteger81 = value; - break; - case (82): - BigInteger82 = value; - break; - case (83): - BigInteger83 = value; - break; - case (84): - BigInteger84 = value; - break; - case (85): - BigInteger85 = value; - break; - case (86): - BigInteger86 = value; - break; - case (88): - BigInteger88 = value; - break; - case (89): - BigInteger89 = value; - break; - case (90): - BigInteger90 = value; - break; - case (91): - BigInteger91 = value; - break; - case (92): - BigInteger92 = value; - break; - case (93): - BigInteger93 = value; - break; - case (94): - BigInteger94 = value; - break; - case (95): - BigInteger95 = value; - break; - case (96): - BigInteger96 = value; - break; - case (98): - BigInteger98 = value; - break; - case (100): - BigInteger100 = value; - break; - case (101): - BigInteger101 = value; - break; - case (102): - BigInteger102 = value; - break; - case (103): - BigInteger103 = value; - break; - case (104): - BigInteger104 = value; - break; - case (105): - BigInteger105 = value; - break; - case (107): - BigInteger107 = value; - break; - case (108): - BigInteger108 = value; - break; - case (109): - BigInteger109 = value; - break; - case (110): - BigInteger110 = value; - break; - case (111): - BigInteger111 = value; - break; - case (112): - BigInteger112 = value; - break; - case (113): - BigInteger113 = value; - break; - case (114): - BigInteger114 = value; - break; - case (115): - BigInteger115 = value; - break; - case (116): - BigInteger116 = value; - break; - case (117): - BigInteger117 = value; - break; - case (118): - BigInteger118 = value; - break; - case (119): - BigInteger119 = value; - break; - case (120): - BigInteger120 = value; - break; - case (121): - BigInteger121 = value; - break; - case (122): - BigInteger122 = value; - break; - case (124): - BigInteger124 = value; - break; - case (125): - BigInteger125 = value; - break; - case (126): - BigInteger126 = value; - break; - case (127): - BigInteger127 = value; - break; - case (128): - BigInteger128 = value; - break; - case (129): - BigInteger129 = value; - break; - case (130): - BigInteger130 = value; - break; - case (131): - BigInteger131 = value; - break; - case (132): - BigInteger132 = value; - break; - case (134): - BigInteger134 = value; - break; - case (136): - BigInteger136 = value; - break; - case (137): - BigInteger137 = value; - break; - case (138): - BigInteger138 = value; - break; - case (139): - BigInteger139 = value; - break; - case (140): - BigInteger140 = value; - break; - case (141): - BigInteger141 = value; - break; - case (143): - BigInteger143 = value; - break; + public boolean set(int index,BigInteger value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + BigInteger0= value; + break; + case(1): + BigInteger1= value; + break; + case(2): + BigInteger2= value; + break; + case(3): + BigInteger3= value; + break; + case(4): + BigInteger4= value; + break; + case(5): + BigInteger5= value; + break; + case(6): + BigInteger6= value; + break; + case(7): + BigInteger7= value; + break; + case(8): + BigInteger8= value; + break; + case(9): + BigInteger9= value; + break; + case(10): + BigInteger10= value; + break; + case(11): + BigInteger11= value; + break; + case(12): + BigInteger12= value; + break; + case(13): + BigInteger13= value; + break; + case(14): + BigInteger14= value; + break; + case(16): + BigInteger16= value; + break; + case(17): + BigInteger17= value; + break; + case(18): + BigInteger18= value; + break; + case(19): + BigInteger19= value; + break; + case(20): + BigInteger20= value; + break; + case(21): + BigInteger21= value; + break; + case(22): + BigInteger22= value; + break; + case(23): + BigInteger23= value; + break; + case(24): + BigInteger24= value; + break; + case(26): + BigInteger26= value; + break; + case(28): + BigInteger28= value; + break; + case(29): + BigInteger29= value; + break; + case(30): + BigInteger30= value; + break; + case(31): + BigInteger31= value; + break; + case(32): + BigInteger32= value; + break; + case(33): + BigInteger33= value; + break; + case(35): + BigInteger35= value; + break; + case(36): + BigInteger36= value; + break; + case(37): + BigInteger37= value; + break; + case(38): + BigInteger38= value; + break; + case(39): + BigInteger39= value; + break; + case(40): + BigInteger40= value; + break; + case(41): + BigInteger41= value; + break; + case(42): + BigInteger42= value; + break; + case(43): + BigInteger43= value; + break; + case(44): + BigInteger44= value; + break; + case(45): + BigInteger45= value; + break; + case(46): + BigInteger46= value; + break; + case(47): + BigInteger47= value; + break; + case(48): + BigInteger48= value; + break; + case(49): + BigInteger49= value; + break; + case(50): + BigInteger50= value; + break; + case(52): + BigInteger52= value; + break; + case(53): + BigInteger53= value; + break; + case(54): + BigInteger54= value; + break; + case(55): + BigInteger55= value; + break; + case(56): + BigInteger56= value; + break; + case(57): + BigInteger57= value; + break; + case(58): + BigInteger58= value; + break; + case(59): + BigInteger59= value; + break; + case(60): + BigInteger60= value; + break; + case(62): + BigInteger62= value; + break; + case(64): + BigInteger64= value; + break; + case(65): + BigInteger65= value; + break; + case(66): + BigInteger66= value; + break; + case(67): + BigInteger67= value; + break; + case(68): + BigInteger68= value; + break; + case(69): + BigInteger69= value; + break; + case(71): + BigInteger71= value; + break; + case(72): + BigInteger72= value; + break; + case(73): + BigInteger73= value; + break; + case(74): + BigInteger74= value; + break; + case(75): + BigInteger75= value; + break; + case(76): + BigInteger76= value; + break; + case(77): + BigInteger77= value; + break; + case(78): + BigInteger78= value; + break; + case(79): + BigInteger79= value; + break; + case(80): + BigInteger80= value; + break; + case(81): + BigInteger81= value; + break; + case(82): + BigInteger82= value; + break; + case(83): + BigInteger83= value; + break; + case(84): + BigInteger84= value; + break; + case(85): + BigInteger85= value; + break; + case(86): + BigInteger86= value; + break; + case(88): + BigInteger88= value; + break; + case(89): + BigInteger89= value; + break; + case(90): + BigInteger90= value; + break; + case(91): + BigInteger91= value; + break; + case(92): + BigInteger92= value; + break; + case(93): + BigInteger93= value; + break; + case(94): + BigInteger94= value; + break; + case(95): + BigInteger95= value; + break; + case(96): + BigInteger96= value; + break; + case(98): + BigInteger98= value; + break; + case(100): + BigInteger100= value; + break; + case(101): + BigInteger101= value; + break; + case(102): + BigInteger102= value; + break; + case(103): + BigInteger103= value; + break; + case(104): + BigInteger104= value; + break; + case(105): + BigInteger105= value; + break; + case(107): + BigInteger107= value; + break; + case(108): + BigInteger108= value; + break; + case(109): + BigInteger109= value; + break; + case(110): + BigInteger110= value; + break; + case(111): + BigInteger111= value; + break; + case(112): + BigInteger112= value; + break; + case(113): + BigInteger113= value; + break; + case(114): + BigInteger114= value; + break; + case(115): + BigInteger115= value; + break; + case(116): + BigInteger116= value; + break; + case(117): + BigInteger117= value; + break; + case(118): + BigInteger118= value; + break; + case(119): + BigInteger119= value; + break; + case(120): + BigInteger120= value; + break; + case(121): + BigInteger121= value; + break; + case(122): + BigInteger122= value; + break; + case(124): + BigInteger124= value; + break; + case(125): + BigInteger125= value; + break; + case(126): + BigInteger126= value; + break; + case(127): + BigInteger127= value; + break; + case(128): + BigInteger128= value; + break; + case(129): + BigInteger129= value; + break; + case(130): + BigInteger130= value; + break; + case(131): + BigInteger131= value; + break; + case(132): + BigInteger132= value; + break; + case(134): + BigInteger134= value; + break; + case(136): + BigInteger136= value; + break; + case(137): + BigInteger137= value; + break; + case(138): + BigInteger138= value; + break; + case(139): + BigInteger139= value; + break; + case(140): + BigInteger140= value; + break; + case(141): + BigInteger141= value; + break; + case(143): + BigInteger143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfBoolean.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfBoolean.java index b3e448239..050c94c4a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfBoolean.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfBoolean.java @@ -5,21 +5,21 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -public class FieldsOfBoolean { +public class FieldsOfBoolean { public int identifier; private Boolean Boolean0; private Boolean Boolean1; @@ -48,14 +48,14 @@ public class FieldsOfBoolean { private static transient Boolean Boolean24; private static final Boolean Boolean25 = Boolean.FALSE; private static volatile Boolean Boolean26; - private final transient Boolean Boolean27 = Boolean.FALSE; + private transient final Boolean Boolean27 = Boolean.FALSE; private transient volatile Boolean Boolean28; private transient volatile Boolean Boolean29; private transient volatile Boolean Boolean30; private transient volatile Boolean Boolean31; private transient volatile Boolean Boolean32; private transient volatile Boolean Boolean33; - private static final transient Boolean Boolean34 = Boolean.FALSE; + private static transient final Boolean Boolean34 = Boolean.FALSE; private static transient volatile Boolean Boolean35; public Boolean Boolean36; public Boolean Boolean37; @@ -84,14 +84,14 @@ public class FieldsOfBoolean { public static transient Boolean Boolean60; public static final Boolean Boolean61 = Boolean.FALSE; public static volatile Boolean Boolean62; - public final transient Boolean Boolean63 = Boolean.FALSE; + public transient final Boolean Boolean63 = Boolean.FALSE; public transient volatile Boolean Boolean64; public transient volatile Boolean Boolean65; public transient volatile Boolean Boolean66; public transient volatile Boolean Boolean67; public transient volatile Boolean Boolean68; public transient volatile Boolean Boolean69; - public static final transient Boolean Boolean70 = Boolean.FALSE; + public static transient final Boolean Boolean70 = Boolean.FALSE; public static transient volatile Boolean Boolean71; protected Boolean Boolean72; protected Boolean Boolean73; @@ -120,14 +120,14 @@ public class FieldsOfBoolean { protected static transient Boolean Boolean96; protected static final Boolean Boolean97 = Boolean.FALSE; protected static volatile Boolean Boolean98; - protected final transient Boolean Boolean99 = Boolean.FALSE; + protected transient final Boolean Boolean99 = Boolean.FALSE; protected transient volatile Boolean Boolean100; protected transient volatile Boolean Boolean101; protected transient volatile Boolean Boolean102; protected transient volatile Boolean Boolean103; protected transient volatile Boolean Boolean104; protected transient volatile Boolean Boolean105; - protected static final transient Boolean Boolean106 = Boolean.FALSE; + protected static transient final Boolean Boolean106 = Boolean.FALSE; protected static transient volatile Boolean Boolean107; Boolean Boolean108; Boolean Boolean109; @@ -156,936 +156,935 @@ public class FieldsOfBoolean { static transient Boolean Boolean132; static final Boolean Boolean133 = Boolean.FALSE; static volatile Boolean Boolean134; - final transient Boolean Boolean135 = Boolean.FALSE; + transient final Boolean Boolean135 = Boolean.FALSE; transient volatile Boolean Boolean136; transient volatile Boolean Boolean137; transient volatile Boolean Boolean138; transient volatile Boolean Boolean139; transient volatile Boolean Boolean140; transient volatile Boolean Boolean141; - static final transient Boolean Boolean142 = Boolean.FALSE; + static transient final Boolean Boolean142 = Boolean.FALSE; static transient volatile Boolean Boolean143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private Boolean Boolean0", - "embedded= true private Boolean Boolean1", - "embedded= false private Boolean Boolean2", - "persistence-modifier= none private Boolean Boolean3", - "persistence-modifier= persistent private Boolean Boolean4", - "persistence-modifier= persistent embedded= true private Boolean Boolean5", - "persistence-modifier= persistent embedded= false private Boolean Boolean6", - "persistence-modifier= transactional private Boolean Boolean7", - "private static Boolean Boolean8", - "private transient Boolean Boolean9", - "persistence-modifier= none private transient Boolean Boolean10", - "persistence-modifier= persistent private transient Boolean Boolean11", - "persistence-modifier= persistent embedded= true private transient Boolean Boolean12", - "persistence-modifier= persistent embedded= false private transient Boolean Boolean13", - "persistence-modifier= transactional private transient Boolean Boolean14", - "private final Boolean Boolean15", - "private volatile Boolean Boolean16", - "embedded= true private volatile Boolean Boolean17", - "embedded= false private volatile Boolean Boolean18", - "persistence-modifier= none private volatile Boolean Boolean19", - "persistence-modifier= persistent private volatile Boolean Boolean20", - "persistence-modifier= persistent embedded= true private volatile Boolean Boolean21", - "persistence-modifier= persistent embedded= false private volatile Boolean Boolean22", - "persistence-modifier= transactional private volatile Boolean Boolean23", - "private static transient Boolean Boolean24", - "private static final Boolean Boolean25", - "private static volatile Boolean Boolean26", - "private transient final Boolean Boolean27", - "private transient volatile Boolean Boolean28", - "persistence-modifier= none private transient volatile Boolean Boolean29", - "persistence-modifier= persistent private transient volatile Boolean Boolean30", - "persistence-modifier= persistent embedded= true private transient volatile Boolean Boolean31", - "persistence-modifier= persistent embedded= false private transient volatile Boolean Boolean32", - "persistence-modifier= transactional private transient volatile Boolean Boolean33", - "private static transient final Boolean Boolean34", - "private static transient volatile Boolean Boolean35", - "public Boolean Boolean36", - "embedded= true public Boolean Boolean37", - "embedded= false public Boolean Boolean38", - "persistence-modifier= none public Boolean Boolean39", - "persistence-modifier= persistent public Boolean Boolean40", - "persistence-modifier= persistent embedded= true public Boolean Boolean41", - "persistence-modifier= persistent embedded= false public Boolean Boolean42", - "persistence-modifier= transactional public Boolean Boolean43", - "public static Boolean Boolean44", - "public transient Boolean Boolean45", - "persistence-modifier= none public transient Boolean Boolean46", - "persistence-modifier= persistent public transient Boolean Boolean47", - "persistence-modifier= persistent embedded= true public transient Boolean Boolean48", - "persistence-modifier= persistent embedded= false public transient Boolean Boolean49", - "persistence-modifier= transactional public transient Boolean Boolean50", - "public final Boolean Boolean51", - "public volatile Boolean Boolean52", - "embedded= true public volatile Boolean Boolean53", - "embedded= false public volatile Boolean Boolean54", - "persistence-modifier= none public volatile Boolean Boolean55", - "persistence-modifier= persistent public volatile Boolean Boolean56", - "persistence-modifier= persistent embedded= true public volatile Boolean Boolean57", - "persistence-modifier= persistent embedded= false public volatile Boolean Boolean58", - "persistence-modifier= transactional public volatile Boolean Boolean59", - "public static transient Boolean Boolean60", - "public static final Boolean Boolean61", - "public static volatile Boolean Boolean62", - "public transient final Boolean Boolean63", - "public transient volatile Boolean Boolean64", - "persistence-modifier= none public transient volatile Boolean Boolean65", - "persistence-modifier= persistent public transient volatile Boolean Boolean66", - "persistence-modifier= persistent embedded= true public transient volatile Boolean Boolean67", - "persistence-modifier= persistent embedded= false public transient volatile Boolean Boolean68", - "persistence-modifier= transactional public transient volatile Boolean Boolean69", - "public static transient final Boolean Boolean70", - "public static transient volatile Boolean Boolean71", - "protected Boolean Boolean72", - "embedded= true protected Boolean Boolean73", - "embedded= false protected Boolean Boolean74", - "persistence-modifier= none protected Boolean Boolean75", - "persistence-modifier= persistent protected Boolean Boolean76", - "persistence-modifier= persistent embedded= true protected Boolean Boolean77", - "persistence-modifier= persistent embedded= false protected Boolean Boolean78", - "persistence-modifier= transactional protected Boolean Boolean79", - "protected static Boolean Boolean80", - "protected transient Boolean Boolean81", - "persistence-modifier= none protected transient Boolean Boolean82", - "persistence-modifier= persistent protected transient Boolean Boolean83", - "persistence-modifier= persistent embedded= true protected transient Boolean Boolean84", - "persistence-modifier= persistent embedded= false protected transient Boolean Boolean85", - "persistence-modifier= transactional protected transient Boolean Boolean86", - "protected final Boolean Boolean87", - "protected volatile Boolean Boolean88", - "embedded= true protected volatile Boolean Boolean89", - "embedded= false protected volatile Boolean Boolean90", - "persistence-modifier= none protected volatile Boolean Boolean91", - "persistence-modifier= persistent protected volatile Boolean Boolean92", - "persistence-modifier= persistent embedded= true protected volatile Boolean Boolean93", - "persistence-modifier= persistent embedded= false protected volatile Boolean Boolean94", - "persistence-modifier= transactional protected volatile Boolean Boolean95", - "protected static transient Boolean Boolean96", - "protected static final Boolean Boolean97", - "protected static volatile Boolean Boolean98", - "protected transient final Boolean Boolean99", - "protected transient volatile Boolean Boolean100", - "persistence-modifier= none protected transient volatile Boolean Boolean101", - "persistence-modifier= persistent protected transient volatile Boolean Boolean102", - "persistence-modifier= persistent embedded= true protected transient volatile Boolean Boolean103", - "persistence-modifier= persistent embedded= false protected transient volatile Boolean Boolean104", - "persistence-modifier= transactional protected transient volatile Boolean Boolean105", - "protected static transient final Boolean Boolean106", - "protected static transient volatile Boolean Boolean107", - "Boolean Boolean108", - "embedded= true Boolean Boolean109", - "embedded= false Boolean Boolean110", - "persistence-modifier= none Boolean Boolean111", - "persistence-modifier= persistent Boolean Boolean112", - "persistence-modifier= persistent embedded= true Boolean Boolean113", - "persistence-modifier= persistent embedded= false Boolean Boolean114", - "persistence-modifier= transactional Boolean Boolean115", - "static Boolean Boolean116", - "transient Boolean Boolean117", - "persistence-modifier= none transient Boolean Boolean118", - "persistence-modifier= persistent transient Boolean Boolean119", - "persistence-modifier= persistent embedded= true transient Boolean Boolean120", - "persistence-modifier= persistent embedded= false transient Boolean Boolean121", - "persistence-modifier= transactional transient Boolean Boolean122", - "final Boolean Boolean123", - "volatile Boolean Boolean124", - "embedded= true volatile Boolean Boolean125", - "embedded= false volatile Boolean Boolean126", - "persistence-modifier= none volatile Boolean Boolean127", - "persistence-modifier= persistent volatile Boolean Boolean128", - "persistence-modifier= persistent embedded= true volatile Boolean Boolean129", - "persistence-modifier= persistent embedded= false volatile Boolean Boolean130", - "persistence-modifier= transactional volatile Boolean Boolean131", - "static transient Boolean Boolean132", - "static final Boolean Boolean133", - "static volatile Boolean Boolean134", - "transient final Boolean Boolean135", - "transient volatile Boolean Boolean136", - "persistence-modifier= none transient volatile Boolean Boolean137", - "persistence-modifier= persistent transient volatile Boolean Boolean138", - "persistence-modifier= persistent embedded= true transient volatile Boolean Boolean139", - "persistence-modifier= persistent embedded= false transient volatile Boolean Boolean140", - "persistence-modifier= transactional transient volatile Boolean Boolean141", - "static transient final Boolean Boolean142", - "static transient volatile Boolean Boolean143" + public static final String [] fieldSpecs = { + "private Boolean Boolean0", + "embedded= true private Boolean Boolean1", + "embedded= false private Boolean Boolean2", + "persistence-modifier= none private Boolean Boolean3", + "persistence-modifier= persistent private Boolean Boolean4", + "persistence-modifier= persistent embedded= true private Boolean Boolean5", + "persistence-modifier= persistent embedded= false private Boolean Boolean6", + "persistence-modifier= transactional private Boolean Boolean7", + "private static Boolean Boolean8", + "private transient Boolean Boolean9", + "persistence-modifier= none private transient Boolean Boolean10", + "persistence-modifier= persistent private transient Boolean Boolean11", + "persistence-modifier= persistent embedded= true private transient Boolean Boolean12", + "persistence-modifier= persistent embedded= false private transient Boolean Boolean13", + "persistence-modifier= transactional private transient Boolean Boolean14", + "private final Boolean Boolean15", + "private volatile Boolean Boolean16", + "embedded= true private volatile Boolean Boolean17", + "embedded= false private volatile Boolean Boolean18", + "persistence-modifier= none private volatile Boolean Boolean19", + "persistence-modifier= persistent private volatile Boolean Boolean20", + "persistence-modifier= persistent embedded= true private volatile Boolean Boolean21", + "persistence-modifier= persistent embedded= false private volatile Boolean Boolean22", + "persistence-modifier= transactional private volatile Boolean Boolean23", + "private static transient Boolean Boolean24", + "private static final Boolean Boolean25", + "private static volatile Boolean Boolean26", + "private transient final Boolean Boolean27", + "private transient volatile Boolean Boolean28", + "persistence-modifier= none private transient volatile Boolean Boolean29", + "persistence-modifier= persistent private transient volatile Boolean Boolean30", + "persistence-modifier= persistent embedded= true private transient volatile Boolean Boolean31", + "persistence-modifier= persistent embedded= false private transient volatile Boolean Boolean32", + "persistence-modifier= transactional private transient volatile Boolean Boolean33", + "private static transient final Boolean Boolean34", + "private static transient volatile Boolean Boolean35", + "public Boolean Boolean36", + "embedded= true public Boolean Boolean37", + "embedded= false public Boolean Boolean38", + "persistence-modifier= none public Boolean Boolean39", + "persistence-modifier= persistent public Boolean Boolean40", + "persistence-modifier= persistent embedded= true public Boolean Boolean41", + "persistence-modifier= persistent embedded= false public Boolean Boolean42", + "persistence-modifier= transactional public Boolean Boolean43", + "public static Boolean Boolean44", + "public transient Boolean Boolean45", + "persistence-modifier= none public transient Boolean Boolean46", + "persistence-modifier= persistent public transient Boolean Boolean47", + "persistence-modifier= persistent embedded= true public transient Boolean Boolean48", + "persistence-modifier= persistent embedded= false public transient Boolean Boolean49", + "persistence-modifier= transactional public transient Boolean Boolean50", + "public final Boolean Boolean51", + "public volatile Boolean Boolean52", + "embedded= true public volatile Boolean Boolean53", + "embedded= false public volatile Boolean Boolean54", + "persistence-modifier= none public volatile Boolean Boolean55", + "persistence-modifier= persistent public volatile Boolean Boolean56", + "persistence-modifier= persistent embedded= true public volatile Boolean Boolean57", + "persistence-modifier= persistent embedded= false public volatile Boolean Boolean58", + "persistence-modifier= transactional public volatile Boolean Boolean59", + "public static transient Boolean Boolean60", + "public static final Boolean Boolean61", + "public static volatile Boolean Boolean62", + "public transient final Boolean Boolean63", + "public transient volatile Boolean Boolean64", + "persistence-modifier= none public transient volatile Boolean Boolean65", + "persistence-modifier= persistent public transient volatile Boolean Boolean66", + "persistence-modifier= persistent embedded= true public transient volatile Boolean Boolean67", + "persistence-modifier= persistent embedded= false public transient volatile Boolean Boolean68", + "persistence-modifier= transactional public transient volatile Boolean Boolean69", + "public static transient final Boolean Boolean70", + "public static transient volatile Boolean Boolean71", + "protected Boolean Boolean72", + "embedded= true protected Boolean Boolean73", + "embedded= false protected Boolean Boolean74", + "persistence-modifier= none protected Boolean Boolean75", + "persistence-modifier= persistent protected Boolean Boolean76", + "persistence-modifier= persistent embedded= true protected Boolean Boolean77", + "persistence-modifier= persistent embedded= false protected Boolean Boolean78", + "persistence-modifier= transactional protected Boolean Boolean79", + "protected static Boolean Boolean80", + "protected transient Boolean Boolean81", + "persistence-modifier= none protected transient Boolean Boolean82", + "persistence-modifier= persistent protected transient Boolean Boolean83", + "persistence-modifier= persistent embedded= true protected transient Boolean Boolean84", + "persistence-modifier= persistent embedded= false protected transient Boolean Boolean85", + "persistence-modifier= transactional protected transient Boolean Boolean86", + "protected final Boolean Boolean87", + "protected volatile Boolean Boolean88", + "embedded= true protected volatile Boolean Boolean89", + "embedded= false protected volatile Boolean Boolean90", + "persistence-modifier= none protected volatile Boolean Boolean91", + "persistence-modifier= persistent protected volatile Boolean Boolean92", + "persistence-modifier= persistent embedded= true protected volatile Boolean Boolean93", + "persistence-modifier= persistent embedded= false protected volatile Boolean Boolean94", + "persistence-modifier= transactional protected volatile Boolean Boolean95", + "protected static transient Boolean Boolean96", + "protected static final Boolean Boolean97", + "protected static volatile Boolean Boolean98", + "protected transient final Boolean Boolean99", + "protected transient volatile Boolean Boolean100", + "persistence-modifier= none protected transient volatile Boolean Boolean101", + "persistence-modifier= persistent protected transient volatile Boolean Boolean102", + "persistence-modifier= persistent embedded= true protected transient volatile Boolean Boolean103", + "persistence-modifier= persistent embedded= false protected transient volatile Boolean Boolean104", + "persistence-modifier= transactional protected transient volatile Boolean Boolean105", + "protected static transient final Boolean Boolean106", + "protected static transient volatile Boolean Boolean107", + "Boolean Boolean108", + "embedded= true Boolean Boolean109", + "embedded= false Boolean Boolean110", + "persistence-modifier= none Boolean Boolean111", + "persistence-modifier= persistent Boolean Boolean112", + "persistence-modifier= persistent embedded= true Boolean Boolean113", + "persistence-modifier= persistent embedded= false Boolean Boolean114", + "persistence-modifier= transactional Boolean Boolean115", + "static Boolean Boolean116", + "transient Boolean Boolean117", + "persistence-modifier= none transient Boolean Boolean118", + "persistence-modifier= persistent transient Boolean Boolean119", + "persistence-modifier= persistent embedded= true transient Boolean Boolean120", + "persistence-modifier= persistent embedded= false transient Boolean Boolean121", + "persistence-modifier= transactional transient Boolean Boolean122", + "final Boolean Boolean123", + "volatile Boolean Boolean124", + "embedded= true volatile Boolean Boolean125", + "embedded= false volatile Boolean Boolean126", + "persistence-modifier= none volatile Boolean Boolean127", + "persistence-modifier= persistent volatile Boolean Boolean128", + "persistence-modifier= persistent embedded= true volatile Boolean Boolean129", + "persistence-modifier= persistent embedded= false volatile Boolean Boolean130", + "persistence-modifier= transactional volatile Boolean Boolean131", + "static transient Boolean Boolean132", + "static final Boolean Boolean133", + "static volatile Boolean Boolean134", + "transient final Boolean Boolean135", + "transient volatile Boolean Boolean136", + "persistence-modifier= none transient volatile Boolean Boolean137", + "persistence-modifier= persistent transient volatile Boolean Boolean138", + "persistence-modifier= persistent embedded= true transient volatile Boolean Boolean139", + "persistence-modifier= persistent embedded= false transient volatile Boolean Boolean140", + "persistence-modifier= transactional transient volatile Boolean Boolean141", + "static transient final Boolean Boolean142", + "static transient volatile Boolean Boolean143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public Boolean get(int index) { - switch (index) { - case (0): + public Boolean get(int index) + { + switch (index) + { + case(0): return Boolean0; - case (1): + case(1): return Boolean1; - case (2): + case(2): return Boolean2; - case (3): + case(3): return Boolean3; - case (4): + case(4): return Boolean4; - case (5): + case(5): return Boolean5; - case (6): + case(6): return Boolean6; - case (7): + case(7): return Boolean7; - case (8): + case(8): return Boolean8; - case (9): + case(9): return Boolean9; - case (10): + case(10): return Boolean10; - case (11): + case(11): return Boolean11; - case (12): + case(12): return Boolean12; - case (13): + case(13): return Boolean13; - case (14): + case(14): return Boolean14; - case (15): + case(15): return Boolean15; - case (16): + case(16): return Boolean16; - case (17): + case(17): return Boolean17; - case (18): + case(18): return Boolean18; - case (19): + case(19): return Boolean19; - case (20): + case(20): return Boolean20; - case (21): + case(21): return Boolean21; - case (22): + case(22): return Boolean22; - case (23): + case(23): return Boolean23; - case (24): + case(24): return Boolean24; - case (25): + case(25): return Boolean25; - case (26): + case(26): return Boolean26; - case (27): + case(27): return Boolean27; - case (28): + case(28): return Boolean28; - case (29): + case(29): return Boolean29; - case (30): + case(30): return Boolean30; - case (31): + case(31): return Boolean31; - case (32): + case(32): return Boolean32; - case (33): + case(33): return Boolean33; - case (34): + case(34): return Boolean34; - case (35): + case(35): return Boolean35; - case (36): + case(36): return Boolean36; - case (37): + case(37): return Boolean37; - case (38): + case(38): return Boolean38; - case (39): + case(39): return Boolean39; - case (40): + case(40): return Boolean40; - case (41): + case(41): return Boolean41; - case (42): + case(42): return Boolean42; - case (43): + case(43): return Boolean43; - case (44): + case(44): return Boolean44; - case (45): + case(45): return Boolean45; - case (46): + case(46): return Boolean46; - case (47): + case(47): return Boolean47; - case (48): + case(48): return Boolean48; - case (49): + case(49): return Boolean49; - case (50): + case(50): return Boolean50; - case (51): + case(51): return Boolean51; - case (52): + case(52): return Boolean52; - case (53): + case(53): return Boolean53; - case (54): + case(54): return Boolean54; - case (55): + case(55): return Boolean55; - case (56): + case(56): return Boolean56; - case (57): + case(57): return Boolean57; - case (58): + case(58): return Boolean58; - case (59): + case(59): return Boolean59; - case (60): + case(60): return Boolean60; - case (61): + case(61): return Boolean61; - case (62): + case(62): return Boolean62; - case (63): + case(63): return Boolean63; - case (64): + case(64): return Boolean64; - case (65): + case(65): return Boolean65; - case (66): + case(66): return Boolean66; - case (67): + case(67): return Boolean67; - case (68): + case(68): return Boolean68; - case (69): + case(69): return Boolean69; - case (70): + case(70): return Boolean70; - case (71): + case(71): return Boolean71; - case (72): + case(72): return Boolean72; - case (73): + case(73): return Boolean73; - case (74): + case(74): return Boolean74; - case (75): + case(75): return Boolean75; - case (76): + case(76): return Boolean76; - case (77): + case(77): return Boolean77; - case (78): + case(78): return Boolean78; - case (79): + case(79): return Boolean79; - case (80): + case(80): return Boolean80; - case (81): + case(81): return Boolean81; - case (82): + case(82): return Boolean82; - case (83): + case(83): return Boolean83; - case (84): + case(84): return Boolean84; - case (85): + case(85): return Boolean85; - case (86): + case(86): return Boolean86; - case (87): + case(87): return Boolean87; - case (88): + case(88): return Boolean88; - case (89): + case(89): return Boolean89; - case (90): + case(90): return Boolean90; - case (91): + case(91): return Boolean91; - case (92): + case(92): return Boolean92; - case (93): + case(93): return Boolean93; - case (94): + case(94): return Boolean94; - case (95): + case(95): return Boolean95; - case (96): + case(96): return Boolean96; - case (97): + case(97): return Boolean97; - case (98): + case(98): return Boolean98; - case (99): + case(99): return Boolean99; - case (100): + case(100): return Boolean100; - case (101): + case(101): return Boolean101; - case (102): + case(102): return Boolean102; - case (103): + case(103): return Boolean103; - case (104): + case(104): return Boolean104; - case (105): + case(105): return Boolean105; - case (106): + case(106): return Boolean106; - case (107): + case(107): return Boolean107; - case (108): + case(108): return Boolean108; - case (109): + case(109): return Boolean109; - case (110): + case(110): return Boolean110; - case (111): + case(111): return Boolean111; - case (112): + case(112): return Boolean112; - case (113): + case(113): return Boolean113; - case (114): + case(114): return Boolean114; - case (115): + case(115): return Boolean115; - case (116): + case(116): return Boolean116; - case (117): + case(117): return Boolean117; - case (118): + case(118): return Boolean118; - case (119): + case(119): return Boolean119; - case (120): + case(120): return Boolean120; - case (121): + case(121): return Boolean121; - case (122): + case(122): return Boolean122; - case (123): + case(123): return Boolean123; - case (124): + case(124): return Boolean124; - case (125): + case(125): return Boolean125; - case (126): + case(126): return Boolean126; - case (127): + case(127): return Boolean127; - case (128): + case(128): return Boolean128; - case (129): + case(129): return Boolean129; - case (130): + case(130): return Boolean130; - case (131): + case(131): return Boolean131; - case (132): + case(132): return Boolean132; - case (133): + case(133): return Boolean133; - case (134): + case(134): return Boolean134; - case (135): + case(135): return Boolean135; - case (136): + case(136): return Boolean136; - case (137): + case(137): return Boolean137; - case (138): + case(138): return Boolean138; - case (139): + case(139): return Boolean139; - case (140): + case(140): return Boolean140; - case (141): + case(141): return Boolean141; - case (142): + case(142): return Boolean142; - case (143): + case(143): return Boolean143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, Boolean value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - Boolean0 = value; - break; - case (1): - Boolean1 = value; - break; - case (2): - Boolean2 = value; - break; - case (3): - Boolean3 = value; - break; - case (4): - Boolean4 = value; - break; - case (5): - Boolean5 = value; - break; - case (6): - Boolean6 = value; - break; - case (7): - Boolean7 = value; - break; - case (8): - Boolean8 = value; - break; - case (9): - Boolean9 = value; - break; - case (10): - Boolean10 = value; - break; - case (11): - Boolean11 = value; - break; - case (12): - Boolean12 = value; - break; - case (13): - Boolean13 = value; - break; - case (14): - Boolean14 = value; - break; - case (16): - Boolean16 = value; - break; - case (17): - Boolean17 = value; - break; - case (18): - Boolean18 = value; - break; - case (19): - Boolean19 = value; - break; - case (20): - Boolean20 = value; - break; - case (21): - Boolean21 = value; - break; - case (22): - Boolean22 = value; - break; - case (23): - Boolean23 = value; - break; - case (24): - Boolean24 = value; - break; - case (26): - Boolean26 = value; - break; - case (28): - Boolean28 = value; - break; - case (29): - Boolean29 = value; - break; - case (30): - Boolean30 = value; - break; - case (31): - Boolean31 = value; - break; - case (32): - Boolean32 = value; - break; - case (33): - Boolean33 = value; - break; - case (35): - Boolean35 = value; - break; - case (36): - Boolean36 = value; - break; - case (37): - Boolean37 = value; - break; - case (38): - Boolean38 = value; - break; - case (39): - Boolean39 = value; - break; - case (40): - Boolean40 = value; - break; - case (41): - Boolean41 = value; - break; - case (42): - Boolean42 = value; - break; - case (43): - Boolean43 = value; - break; - case (44): - Boolean44 = value; - break; - case (45): - Boolean45 = value; - break; - case (46): - Boolean46 = value; - break; - case (47): - Boolean47 = value; - break; - case (48): - Boolean48 = value; - break; - case (49): - Boolean49 = value; - break; - case (50): - Boolean50 = value; - break; - case (52): - Boolean52 = value; - break; - case (53): - Boolean53 = value; - break; - case (54): - Boolean54 = value; - break; - case (55): - Boolean55 = value; - break; - case (56): - Boolean56 = value; - break; - case (57): - Boolean57 = value; - break; - case (58): - Boolean58 = value; - break; - case (59): - Boolean59 = value; - break; - case (60): - Boolean60 = value; - break; - case (62): - Boolean62 = value; - break; - case (64): - Boolean64 = value; - break; - case (65): - Boolean65 = value; - break; - case (66): - Boolean66 = value; - break; - case (67): - Boolean67 = value; - break; - case (68): - Boolean68 = value; - break; - case (69): - Boolean69 = value; - break; - case (71): - Boolean71 = value; - break; - case (72): - Boolean72 = value; - break; - case (73): - Boolean73 = value; - break; - case (74): - Boolean74 = value; - break; - case (75): - Boolean75 = value; - break; - case (76): - Boolean76 = value; - break; - case (77): - Boolean77 = value; - break; - case (78): - Boolean78 = value; - break; - case (79): - Boolean79 = value; - break; - case (80): - Boolean80 = value; - break; - case (81): - Boolean81 = value; - break; - case (82): - Boolean82 = value; - break; - case (83): - Boolean83 = value; - break; - case (84): - Boolean84 = value; - break; - case (85): - Boolean85 = value; - break; - case (86): - Boolean86 = value; - break; - case (88): - Boolean88 = value; - break; - case (89): - Boolean89 = value; - break; - case (90): - Boolean90 = value; - break; - case (91): - Boolean91 = value; - break; - case (92): - Boolean92 = value; - break; - case (93): - Boolean93 = value; - break; - case (94): - Boolean94 = value; - break; - case (95): - Boolean95 = value; - break; - case (96): - Boolean96 = value; - break; - case (98): - Boolean98 = value; - break; - case (100): - Boolean100 = value; - break; - case (101): - Boolean101 = value; - break; - case (102): - Boolean102 = value; - break; - case (103): - Boolean103 = value; - break; - case (104): - Boolean104 = value; - break; - case (105): - Boolean105 = value; - break; - case (107): - Boolean107 = value; - break; - case (108): - Boolean108 = value; - break; - case (109): - Boolean109 = value; - break; - case (110): - Boolean110 = value; - break; - case (111): - Boolean111 = value; - break; - case (112): - Boolean112 = value; - break; - case (113): - Boolean113 = value; - break; - case (114): - Boolean114 = value; - break; - case (115): - Boolean115 = value; - break; - case (116): - Boolean116 = value; - break; - case (117): - Boolean117 = value; - break; - case (118): - Boolean118 = value; - break; - case (119): - Boolean119 = value; - break; - case (120): - Boolean120 = value; - break; - case (121): - Boolean121 = value; - break; - case (122): - Boolean122 = value; - break; - case (124): - Boolean124 = value; - break; - case (125): - Boolean125 = value; - break; - case (126): - Boolean126 = value; - break; - case (127): - Boolean127 = value; - break; - case (128): - Boolean128 = value; - break; - case (129): - Boolean129 = value; - break; - case (130): - Boolean130 = value; - break; - case (131): - Boolean131 = value; - break; - case (132): - Boolean132 = value; - break; - case (134): - Boolean134 = value; - break; - case (136): - Boolean136 = value; - break; - case (137): - Boolean137 = value; - break; - case (138): - Boolean138 = value; - break; - case (139): - Boolean139 = value; - break; - case (140): - Boolean140 = value; - break; - case (141): - Boolean141 = value; - break; - case (143): - Boolean143 = value; - break; + public boolean set(int index,Boolean value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + Boolean0= value; + break; + case(1): + Boolean1= value; + break; + case(2): + Boolean2= value; + break; + case(3): + Boolean3= value; + break; + case(4): + Boolean4= value; + break; + case(5): + Boolean5= value; + break; + case(6): + Boolean6= value; + break; + case(7): + Boolean7= value; + break; + case(8): + Boolean8= value; + break; + case(9): + Boolean9= value; + break; + case(10): + Boolean10= value; + break; + case(11): + Boolean11= value; + break; + case(12): + Boolean12= value; + break; + case(13): + Boolean13= value; + break; + case(14): + Boolean14= value; + break; + case(16): + Boolean16= value; + break; + case(17): + Boolean17= value; + break; + case(18): + Boolean18= value; + break; + case(19): + Boolean19= value; + break; + case(20): + Boolean20= value; + break; + case(21): + Boolean21= value; + break; + case(22): + Boolean22= value; + break; + case(23): + Boolean23= value; + break; + case(24): + Boolean24= value; + break; + case(26): + Boolean26= value; + break; + case(28): + Boolean28= value; + break; + case(29): + Boolean29= value; + break; + case(30): + Boolean30= value; + break; + case(31): + Boolean31= value; + break; + case(32): + Boolean32= value; + break; + case(33): + Boolean33= value; + break; + case(35): + Boolean35= value; + break; + case(36): + Boolean36= value; + break; + case(37): + Boolean37= value; + break; + case(38): + Boolean38= value; + break; + case(39): + Boolean39= value; + break; + case(40): + Boolean40= value; + break; + case(41): + Boolean41= value; + break; + case(42): + Boolean42= value; + break; + case(43): + Boolean43= value; + break; + case(44): + Boolean44= value; + break; + case(45): + Boolean45= value; + break; + case(46): + Boolean46= value; + break; + case(47): + Boolean47= value; + break; + case(48): + Boolean48= value; + break; + case(49): + Boolean49= value; + break; + case(50): + Boolean50= value; + break; + case(52): + Boolean52= value; + break; + case(53): + Boolean53= value; + break; + case(54): + Boolean54= value; + break; + case(55): + Boolean55= value; + break; + case(56): + Boolean56= value; + break; + case(57): + Boolean57= value; + break; + case(58): + Boolean58= value; + break; + case(59): + Boolean59= value; + break; + case(60): + Boolean60= value; + break; + case(62): + Boolean62= value; + break; + case(64): + Boolean64= value; + break; + case(65): + Boolean65= value; + break; + case(66): + Boolean66= value; + break; + case(67): + Boolean67= value; + break; + case(68): + Boolean68= value; + break; + case(69): + Boolean69= value; + break; + case(71): + Boolean71= value; + break; + case(72): + Boolean72= value; + break; + case(73): + Boolean73= value; + break; + case(74): + Boolean74= value; + break; + case(75): + Boolean75= value; + break; + case(76): + Boolean76= value; + break; + case(77): + Boolean77= value; + break; + case(78): + Boolean78= value; + break; + case(79): + Boolean79= value; + break; + case(80): + Boolean80= value; + break; + case(81): + Boolean81= value; + break; + case(82): + Boolean82= value; + break; + case(83): + Boolean83= value; + break; + case(84): + Boolean84= value; + break; + case(85): + Boolean85= value; + break; + case(86): + Boolean86= value; + break; + case(88): + Boolean88= value; + break; + case(89): + Boolean89= value; + break; + case(90): + Boolean90= value; + break; + case(91): + Boolean91= value; + break; + case(92): + Boolean92= value; + break; + case(93): + Boolean93= value; + break; + case(94): + Boolean94= value; + break; + case(95): + Boolean95= value; + break; + case(96): + Boolean96= value; + break; + case(98): + Boolean98= value; + break; + case(100): + Boolean100= value; + break; + case(101): + Boolean101= value; + break; + case(102): + Boolean102= value; + break; + case(103): + Boolean103= value; + break; + case(104): + Boolean104= value; + break; + case(105): + Boolean105= value; + break; + case(107): + Boolean107= value; + break; + case(108): + Boolean108= value; + break; + case(109): + Boolean109= value; + break; + case(110): + Boolean110= value; + break; + case(111): + Boolean111= value; + break; + case(112): + Boolean112= value; + break; + case(113): + Boolean113= value; + break; + case(114): + Boolean114= value; + break; + case(115): + Boolean115= value; + break; + case(116): + Boolean116= value; + break; + case(117): + Boolean117= value; + break; + case(118): + Boolean118= value; + break; + case(119): + Boolean119= value; + break; + case(120): + Boolean120= value; + break; + case(121): + Boolean121= value; + break; + case(122): + Boolean122= value; + break; + case(124): + Boolean124= value; + break; + case(125): + Boolean125= value; + break; + case(126): + Boolean126= value; + break; + case(127): + Boolean127= value; + break; + case(128): + Boolean128= value; + break; + case(129): + Boolean129= value; + break; + case(130): + Boolean130= value; + break; + case(131): + Boolean131= value; + break; + case(132): + Boolean132= value; + break; + case(134): + Boolean134= value; + break; + case(136): + Boolean136= value; + break; + case(137): + Boolean137= value; + break; + case(138): + Boolean138= value; + break; + case(139): + Boolean139= value; + break; + case(140): + Boolean140= value; + break; + case(141): + Boolean141= value; + break; + case(143): + Boolean143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfByte.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfByte.java index 7e2adb0ec..d9822258f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfByte.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfByte.java @@ -5,21 +5,21 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -public class FieldsOfByte { +public class FieldsOfByte { public int identifier; private Byte Byte0; private Byte Byte1; @@ -36,7 +36,7 @@ public class FieldsOfByte { private transient Byte Byte12; private transient Byte Byte13; private transient Byte Byte14; - private final Byte Byte15 = Byte.valueOf((byte) 5); + private final Byte Byte15 = Byte.valueOf((byte)5); private volatile Byte Byte16; private volatile Byte Byte17; private volatile Byte Byte18; @@ -46,16 +46,16 @@ public class FieldsOfByte { private volatile Byte Byte22; private volatile Byte Byte23; private static transient Byte Byte24; - private static final Byte Byte25 = Byte.valueOf((byte) 5); + private static final Byte Byte25 = Byte.valueOf((byte)5); private static volatile Byte Byte26; - private final transient Byte Byte27 = Byte.valueOf((byte) 5); + private transient final Byte Byte27 = Byte.valueOf((byte)5); private transient volatile Byte Byte28; private transient volatile Byte Byte29; private transient volatile Byte Byte30; private transient volatile Byte Byte31; private transient volatile Byte Byte32; private transient volatile Byte Byte33; - private static final transient Byte Byte34 = Byte.valueOf((byte) 5); + private static transient final Byte Byte34 = Byte.valueOf((byte)5); private static transient volatile Byte Byte35; public Byte Byte36; public Byte Byte37; @@ -72,7 +72,7 @@ public class FieldsOfByte { public transient Byte Byte48; public transient Byte Byte49; public transient Byte Byte50; - public final Byte Byte51 = Byte.valueOf((byte) 5); + public final Byte Byte51 = Byte.valueOf((byte)5); public volatile Byte Byte52; public volatile Byte Byte53; public volatile Byte Byte54; @@ -82,16 +82,16 @@ public class FieldsOfByte { public volatile Byte Byte58; public volatile Byte Byte59; public static transient Byte Byte60; - public static final Byte Byte61 = Byte.valueOf((byte) 5); + public static final Byte Byte61 = Byte.valueOf((byte)5); public static volatile Byte Byte62; - public final transient Byte Byte63 = Byte.valueOf((byte) 5); + public transient final Byte Byte63 = Byte.valueOf((byte)5); public transient volatile Byte Byte64; public transient volatile Byte Byte65; public transient volatile Byte Byte66; public transient volatile Byte Byte67; public transient volatile Byte Byte68; public transient volatile Byte Byte69; - public static final transient Byte Byte70 = Byte.valueOf((byte) 5); + public static transient final Byte Byte70 = Byte.valueOf((byte)5); public static transient volatile Byte Byte71; protected Byte Byte72; protected Byte Byte73; @@ -108,7 +108,7 @@ public class FieldsOfByte { protected transient Byte Byte84; protected transient Byte Byte85; protected transient Byte Byte86; - protected final Byte Byte87 = Byte.valueOf((byte) 5); + protected final Byte Byte87 = Byte.valueOf((byte)5); protected volatile Byte Byte88; protected volatile Byte Byte89; protected volatile Byte Byte90; @@ -118,16 +118,16 @@ public class FieldsOfByte { protected volatile Byte Byte94; protected volatile Byte Byte95; protected static transient Byte Byte96; - protected static final Byte Byte97 = Byte.valueOf((byte) 5); + protected static final Byte Byte97 = Byte.valueOf((byte)5); protected static volatile Byte Byte98; - protected final transient Byte Byte99 = Byte.valueOf((byte) 5); + protected transient final Byte Byte99 = Byte.valueOf((byte)5); protected transient volatile Byte Byte100; protected transient volatile Byte Byte101; protected transient volatile Byte Byte102; protected transient volatile Byte Byte103; protected transient volatile Byte Byte104; protected transient volatile Byte Byte105; - protected static final transient Byte Byte106 = Byte.valueOf((byte) 5); + protected static transient final Byte Byte106 = Byte.valueOf((byte)5); protected static transient volatile Byte Byte107; Byte Byte108; Byte Byte109; @@ -144,7 +144,7 @@ public class FieldsOfByte { transient Byte Byte120; transient Byte Byte121; transient Byte Byte122; - final Byte Byte123 = Byte.valueOf((byte) 5); + final Byte Byte123 = Byte.valueOf((byte)5); volatile Byte Byte124; volatile Byte Byte125; volatile Byte Byte126; @@ -154,938 +154,937 @@ public class FieldsOfByte { volatile Byte Byte130; volatile Byte Byte131; static transient Byte Byte132; - static final Byte Byte133 = Byte.valueOf((byte) 5); + static final Byte Byte133 = Byte.valueOf((byte)5); static volatile Byte Byte134; - final transient Byte Byte135 = Byte.valueOf((byte) 5); + transient final Byte Byte135 = Byte.valueOf((byte)5); transient volatile Byte Byte136; transient volatile Byte Byte137; transient volatile Byte Byte138; transient volatile Byte Byte139; transient volatile Byte Byte140; transient volatile Byte Byte141; - static final transient Byte Byte142 = Byte.valueOf((byte) 5); + static transient final Byte Byte142 = Byte.valueOf((byte)5); static transient volatile Byte Byte143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private Byte Byte0", - "embedded= true private Byte Byte1", - "embedded= false private Byte Byte2", - "persistence-modifier= none private Byte Byte3", - "persistence-modifier= persistent private Byte Byte4", - "persistence-modifier= persistent embedded= true private Byte Byte5", - "persistence-modifier= persistent embedded= false private Byte Byte6", - "persistence-modifier= transactional private Byte Byte7", - "private static Byte Byte8", - "private transient Byte Byte9", - "persistence-modifier= none private transient Byte Byte10", - "persistence-modifier= persistent private transient Byte Byte11", - "persistence-modifier= persistent embedded= true private transient Byte Byte12", - "persistence-modifier= persistent embedded= false private transient Byte Byte13", - "persistence-modifier= transactional private transient Byte Byte14", - "private final Byte Byte15", - "private volatile Byte Byte16", - "embedded= true private volatile Byte Byte17", - "embedded= false private volatile Byte Byte18", - "persistence-modifier= none private volatile Byte Byte19", - "persistence-modifier= persistent private volatile Byte Byte20", - "persistence-modifier= persistent embedded= true private volatile Byte Byte21", - "persistence-modifier= persistent embedded= false private volatile Byte Byte22", - "persistence-modifier= transactional private volatile Byte Byte23", - "private static transient Byte Byte24", - "private static final Byte Byte25", - "private static volatile Byte Byte26", - "private transient final Byte Byte27", - "private transient volatile Byte Byte28", - "persistence-modifier= none private transient volatile Byte Byte29", - "persistence-modifier= persistent private transient volatile Byte Byte30", - "persistence-modifier= persistent embedded= true private transient volatile Byte Byte31", - "persistence-modifier= persistent embedded= false private transient volatile Byte Byte32", - "persistence-modifier= transactional private transient volatile Byte Byte33", - "private static transient final Byte Byte34", - "private static transient volatile Byte Byte35", - "public Byte Byte36", - "embedded= true public Byte Byte37", - "embedded= false public Byte Byte38", - "persistence-modifier= none public Byte Byte39", - "persistence-modifier= persistent public Byte Byte40", - "persistence-modifier= persistent embedded= true public Byte Byte41", - "persistence-modifier= persistent embedded= false public Byte Byte42", - "persistence-modifier= transactional public Byte Byte43", - "public static Byte Byte44", - "public transient Byte Byte45", - "persistence-modifier= none public transient Byte Byte46", - "persistence-modifier= persistent public transient Byte Byte47", - "persistence-modifier= persistent embedded= true public transient Byte Byte48", - "persistence-modifier= persistent embedded= false public transient Byte Byte49", - "persistence-modifier= transactional public transient Byte Byte50", - "public final Byte Byte51", - "public volatile Byte Byte52", - "embedded= true public volatile Byte Byte53", - "embedded= false public volatile Byte Byte54", - "persistence-modifier= none public volatile Byte Byte55", - "persistence-modifier= persistent public volatile Byte Byte56", - "persistence-modifier= persistent embedded= true public volatile Byte Byte57", - "persistence-modifier= persistent embedded= false public volatile Byte Byte58", - "persistence-modifier= transactional public volatile Byte Byte59", - "public static transient Byte Byte60", - "public static final Byte Byte61", - "public static volatile Byte Byte62", - "public transient final Byte Byte63", - "public transient volatile Byte Byte64", - "persistence-modifier= none public transient volatile Byte Byte65", - "persistence-modifier= persistent public transient volatile Byte Byte66", - "persistence-modifier= persistent embedded= true public transient volatile Byte Byte67", - "persistence-modifier= persistent embedded= false public transient volatile Byte Byte68", - "persistence-modifier= transactional public transient volatile Byte Byte69", - "public static transient final Byte Byte70", - "public static transient volatile Byte Byte71", - "protected Byte Byte72", - "embedded= true protected Byte Byte73", - "embedded= false protected Byte Byte74", - "persistence-modifier= none protected Byte Byte75", - "persistence-modifier= persistent protected Byte Byte76", - "persistence-modifier= persistent embedded= true protected Byte Byte77", - "persistence-modifier= persistent embedded= false protected Byte Byte78", - "persistence-modifier= transactional protected Byte Byte79", - "protected static Byte Byte80", - "protected transient Byte Byte81", - "persistence-modifier= none protected transient Byte Byte82", - "persistence-modifier= persistent protected transient Byte Byte83", - "persistence-modifier= persistent embedded= true protected transient Byte Byte84", - "persistence-modifier= persistent embedded= false protected transient Byte Byte85", - "persistence-modifier= transactional protected transient Byte Byte86", - "protected final Byte Byte87", - "protected volatile Byte Byte88", - "embedded= true protected volatile Byte Byte89", - "embedded= false protected volatile Byte Byte90", - "persistence-modifier= none protected volatile Byte Byte91", - "persistence-modifier= persistent protected volatile Byte Byte92", - "persistence-modifier= persistent embedded= true protected volatile Byte Byte93", - "persistence-modifier= persistent embedded= false protected volatile Byte Byte94", - "persistence-modifier= transactional protected volatile Byte Byte95", - "protected static transient Byte Byte96", - "protected static final Byte Byte97", - "protected static volatile Byte Byte98", - "protected transient final Byte Byte99", - "protected transient volatile Byte Byte100", - "persistence-modifier= none protected transient volatile Byte Byte101", - "persistence-modifier= persistent protected transient volatile Byte Byte102", - "persistence-modifier= persistent embedded= true protected transient volatile Byte Byte103", - "persistence-modifier= persistent embedded= false protected transient volatile Byte Byte104", - "persistence-modifier= transactional protected transient volatile Byte Byte105", - "protected static transient final Byte Byte106", - "protected static transient volatile Byte Byte107", - "Byte Byte108", - "embedded= true Byte Byte109", - "embedded= false Byte Byte110", - "persistence-modifier= none Byte Byte111", - "persistence-modifier= persistent Byte Byte112", - "persistence-modifier= persistent embedded= true Byte Byte113", - "persistence-modifier= persistent embedded= false Byte Byte114", - "persistence-modifier= transactional Byte Byte115", - "static Byte Byte116", - "transient Byte Byte117", - "persistence-modifier= none transient Byte Byte118", - "persistence-modifier= persistent transient Byte Byte119", - "persistence-modifier= persistent embedded= true transient Byte Byte120", - "persistence-modifier= persistent embedded= false transient Byte Byte121", - "persistence-modifier= transactional transient Byte Byte122", - "final Byte Byte123", - "volatile Byte Byte124", - "embedded= true volatile Byte Byte125", - "embedded= false volatile Byte Byte126", - "persistence-modifier= none volatile Byte Byte127", - "persistence-modifier= persistent volatile Byte Byte128", - "persistence-modifier= persistent embedded= true volatile Byte Byte129", - "persistence-modifier= persistent embedded= false volatile Byte Byte130", - "persistence-modifier= transactional volatile Byte Byte131", - "static transient Byte Byte132", - "static final Byte Byte133", - "static volatile Byte Byte134", - "transient final Byte Byte135", - "transient volatile Byte Byte136", - "persistence-modifier= none transient volatile Byte Byte137", - "persistence-modifier= persistent transient volatile Byte Byte138", - "persistence-modifier= persistent embedded= true transient volatile Byte Byte139", - "persistence-modifier= persistent embedded= false transient volatile Byte Byte140", - "persistence-modifier= transactional transient volatile Byte Byte141", - "static transient final Byte Byte142", - "static transient volatile Byte Byte143" + public static final String [] fieldSpecs = { + "private Byte Byte0", + "embedded= true private Byte Byte1", + "embedded= false private Byte Byte2", + "persistence-modifier= none private Byte Byte3", + "persistence-modifier= persistent private Byte Byte4", + "persistence-modifier= persistent embedded= true private Byte Byte5", + "persistence-modifier= persistent embedded= false private Byte Byte6", + "persistence-modifier= transactional private Byte Byte7", + "private static Byte Byte8", + "private transient Byte Byte9", + "persistence-modifier= none private transient Byte Byte10", + "persistence-modifier= persistent private transient Byte Byte11", + "persistence-modifier= persistent embedded= true private transient Byte Byte12", + "persistence-modifier= persistent embedded= false private transient Byte Byte13", + "persistence-modifier= transactional private transient Byte Byte14", + "private final Byte Byte15", + "private volatile Byte Byte16", + "embedded= true private volatile Byte Byte17", + "embedded= false private volatile Byte Byte18", + "persistence-modifier= none private volatile Byte Byte19", + "persistence-modifier= persistent private volatile Byte Byte20", + "persistence-modifier= persistent embedded= true private volatile Byte Byte21", + "persistence-modifier= persistent embedded= false private volatile Byte Byte22", + "persistence-modifier= transactional private volatile Byte Byte23", + "private static transient Byte Byte24", + "private static final Byte Byte25", + "private static volatile Byte Byte26", + "private transient final Byte Byte27", + "private transient volatile Byte Byte28", + "persistence-modifier= none private transient volatile Byte Byte29", + "persistence-modifier= persistent private transient volatile Byte Byte30", + "persistence-modifier= persistent embedded= true private transient volatile Byte Byte31", + "persistence-modifier= persistent embedded= false private transient volatile Byte Byte32", + "persistence-modifier= transactional private transient volatile Byte Byte33", + "private static transient final Byte Byte34", + "private static transient volatile Byte Byte35", + "public Byte Byte36", + "embedded= true public Byte Byte37", + "embedded= false public Byte Byte38", + "persistence-modifier= none public Byte Byte39", + "persistence-modifier= persistent public Byte Byte40", + "persistence-modifier= persistent embedded= true public Byte Byte41", + "persistence-modifier= persistent embedded= false public Byte Byte42", + "persistence-modifier= transactional public Byte Byte43", + "public static Byte Byte44", + "public transient Byte Byte45", + "persistence-modifier= none public transient Byte Byte46", + "persistence-modifier= persistent public transient Byte Byte47", + "persistence-modifier= persistent embedded= true public transient Byte Byte48", + "persistence-modifier= persistent embedded= false public transient Byte Byte49", + "persistence-modifier= transactional public transient Byte Byte50", + "public final Byte Byte51", + "public volatile Byte Byte52", + "embedded= true public volatile Byte Byte53", + "embedded= false public volatile Byte Byte54", + "persistence-modifier= none public volatile Byte Byte55", + "persistence-modifier= persistent public volatile Byte Byte56", + "persistence-modifier= persistent embedded= true public volatile Byte Byte57", + "persistence-modifier= persistent embedded= false public volatile Byte Byte58", + "persistence-modifier= transactional public volatile Byte Byte59", + "public static transient Byte Byte60", + "public static final Byte Byte61", + "public static volatile Byte Byte62", + "public transient final Byte Byte63", + "public transient volatile Byte Byte64", + "persistence-modifier= none public transient volatile Byte Byte65", + "persistence-modifier= persistent public transient volatile Byte Byte66", + "persistence-modifier= persistent embedded= true public transient volatile Byte Byte67", + "persistence-modifier= persistent embedded= false public transient volatile Byte Byte68", + "persistence-modifier= transactional public transient volatile Byte Byte69", + "public static transient final Byte Byte70", + "public static transient volatile Byte Byte71", + "protected Byte Byte72", + "embedded= true protected Byte Byte73", + "embedded= false protected Byte Byte74", + "persistence-modifier= none protected Byte Byte75", + "persistence-modifier= persistent protected Byte Byte76", + "persistence-modifier= persistent embedded= true protected Byte Byte77", + "persistence-modifier= persistent embedded= false protected Byte Byte78", + "persistence-modifier= transactional protected Byte Byte79", + "protected static Byte Byte80", + "protected transient Byte Byte81", + "persistence-modifier= none protected transient Byte Byte82", + "persistence-modifier= persistent protected transient Byte Byte83", + "persistence-modifier= persistent embedded= true protected transient Byte Byte84", + "persistence-modifier= persistent embedded= false protected transient Byte Byte85", + "persistence-modifier= transactional protected transient Byte Byte86", + "protected final Byte Byte87", + "protected volatile Byte Byte88", + "embedded= true protected volatile Byte Byte89", + "embedded= false protected volatile Byte Byte90", + "persistence-modifier= none protected volatile Byte Byte91", + "persistence-modifier= persistent protected volatile Byte Byte92", + "persistence-modifier= persistent embedded= true protected volatile Byte Byte93", + "persistence-modifier= persistent embedded= false protected volatile Byte Byte94", + "persistence-modifier= transactional protected volatile Byte Byte95", + "protected static transient Byte Byte96", + "protected static final Byte Byte97", + "protected static volatile Byte Byte98", + "protected transient final Byte Byte99", + "protected transient volatile Byte Byte100", + "persistence-modifier= none protected transient volatile Byte Byte101", + "persistence-modifier= persistent protected transient volatile Byte Byte102", + "persistence-modifier= persistent embedded= true protected transient volatile Byte Byte103", + "persistence-modifier= persistent embedded= false protected transient volatile Byte Byte104", + "persistence-modifier= transactional protected transient volatile Byte Byte105", + "protected static transient final Byte Byte106", + "protected static transient volatile Byte Byte107", + "Byte Byte108", + "embedded= true Byte Byte109", + "embedded= false Byte Byte110", + "persistence-modifier= none Byte Byte111", + "persistence-modifier= persistent Byte Byte112", + "persistence-modifier= persistent embedded= true Byte Byte113", + "persistence-modifier= persistent embedded= false Byte Byte114", + "persistence-modifier= transactional Byte Byte115", + "static Byte Byte116", + "transient Byte Byte117", + "persistence-modifier= none transient Byte Byte118", + "persistence-modifier= persistent transient Byte Byte119", + "persistence-modifier= persistent embedded= true transient Byte Byte120", + "persistence-modifier= persistent embedded= false transient Byte Byte121", + "persistence-modifier= transactional transient Byte Byte122", + "final Byte Byte123", + "volatile Byte Byte124", + "embedded= true volatile Byte Byte125", + "embedded= false volatile Byte Byte126", + "persistence-modifier= none volatile Byte Byte127", + "persistence-modifier= persistent volatile Byte Byte128", + "persistence-modifier= persistent embedded= true volatile Byte Byte129", + "persistence-modifier= persistent embedded= false volatile Byte Byte130", + "persistence-modifier= transactional volatile Byte Byte131", + "static transient Byte Byte132", + "static final Byte Byte133", + "static volatile Byte Byte134", + "transient final Byte Byte135", + "transient volatile Byte Byte136", + "persistence-modifier= none transient volatile Byte Byte137", + "persistence-modifier= persistent transient volatile Byte Byte138", + "persistence-modifier= persistent embedded= true transient volatile Byte Byte139", + "persistence-modifier= persistent embedded= false transient volatile Byte Byte140", + "persistence-modifier= transactional transient volatile Byte Byte141", + "static transient final Byte Byte142", + "static transient volatile Byte Byte143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public Byte get(int index) { - switch (index) { - case (0): + public Byte get(int index) + { + switch (index) + { + case(0): return Byte0; - case (1): + case(1): return Byte1; - case (2): + case(2): return Byte2; - case (3): + case(3): return Byte3; - case (4): + case(4): return Byte4; - case (5): + case(5): return Byte5; - case (6): + case(6): return Byte6; - case (7): + case(7): return Byte7; - case (8): + case(8): return Byte8; - case (9): + case(9): return Byte9; - case (10): + case(10): return Byte10; - case (11): + case(11): return Byte11; - case (12): + case(12): return Byte12; - case (13): + case(13): return Byte13; - case (14): + case(14): return Byte14; - case (15): + case(15): return Byte15; - case (16): + case(16): return Byte16; - case (17): + case(17): return Byte17; - case (18): + case(18): return Byte18; - case (19): + case(19): return Byte19; - case (20): + case(20): return Byte20; - case (21): + case(21): return Byte21; - case (22): + case(22): return Byte22; - case (23): + case(23): return Byte23; - case (24): + case(24): return Byte24; - case (25): + case(25): return Byte25; - case (26): + case(26): return Byte26; - case (27): + case(27): return Byte27; - case (28): + case(28): return Byte28; - case (29): + case(29): return Byte29; - case (30): + case(30): return Byte30; - case (31): + case(31): return Byte31; - case (32): + case(32): return Byte32; - case (33): + case(33): return Byte33; - case (34): + case(34): return Byte34; - case (35): + case(35): return Byte35; - case (36): + case(36): return Byte36; - case (37): + case(37): return Byte37; - case (38): + case(38): return Byte38; - case (39): + case(39): return Byte39; - case (40): + case(40): return Byte40; - case (41): + case(41): return Byte41; - case (42): + case(42): return Byte42; - case (43): + case(43): return Byte43; - case (44): + case(44): return Byte44; - case (45): + case(45): return Byte45; - case (46): + case(46): return Byte46; - case (47): + case(47): return Byte47; - case (48): + case(48): return Byte48; - case (49): + case(49): return Byte49; - case (50): + case(50): return Byte50; - case (51): + case(51): return Byte51; - case (52): + case(52): return Byte52; - case (53): + case(53): return Byte53; - case (54): + case(54): return Byte54; - case (55): + case(55): return Byte55; - case (56): + case(56): return Byte56; - case (57): + case(57): return Byte57; - case (58): + case(58): return Byte58; - case (59): + case(59): return Byte59; - case (60): + case(60): return Byte60; - case (61): + case(61): return Byte61; - case (62): + case(62): return Byte62; - case (63): + case(63): return Byte63; - case (64): + case(64): return Byte64; - case (65): + case(65): return Byte65; - case (66): + case(66): return Byte66; - case (67): + case(67): return Byte67; - case (68): + case(68): return Byte68; - case (69): + case(69): return Byte69; - case (70): + case(70): return Byte70; - case (71): + case(71): return Byte71; - case (72): + case(72): return Byte72; - case (73): + case(73): return Byte73; - case (74): + case(74): return Byte74; - case (75): + case(75): return Byte75; - case (76): + case(76): return Byte76; - case (77): + case(77): return Byte77; - case (78): + case(78): return Byte78; - case (79): + case(79): return Byte79; - case (80): + case(80): return Byte80; - case (81): + case(81): return Byte81; - case (82): + case(82): return Byte82; - case (83): + case(83): return Byte83; - case (84): + case(84): return Byte84; - case (85): + case(85): return Byte85; - case (86): + case(86): return Byte86; - case (87): + case(87): return Byte87; - case (88): + case(88): return Byte88; - case (89): + case(89): return Byte89; - case (90): + case(90): return Byte90; - case (91): + case(91): return Byte91; - case (92): + case(92): return Byte92; - case (93): + case(93): return Byte93; - case (94): + case(94): return Byte94; - case (95): + case(95): return Byte95; - case (96): + case(96): return Byte96; - case (97): + case(97): return Byte97; - case (98): + case(98): return Byte98; - case (99): + case(99): return Byte99; - case (100): + case(100): return Byte100; - case (101): + case(101): return Byte101; - case (102): + case(102): return Byte102; - case (103): + case(103): return Byte103; - case (104): + case(104): return Byte104; - case (105): + case(105): return Byte105; - case (106): + case(106): return Byte106; - case (107): + case(107): return Byte107; - case (108): + case(108): return Byte108; - case (109): + case(109): return Byte109; - case (110): + case(110): return Byte110; - case (111): + case(111): return Byte111; - case (112): + case(112): return Byte112; - case (113): + case(113): return Byte113; - case (114): + case(114): return Byte114; - case (115): + case(115): return Byte115; - case (116): + case(116): return Byte116; - case (117): + case(117): return Byte117; - case (118): + case(118): return Byte118; - case (119): + case(119): return Byte119; - case (120): + case(120): return Byte120; - case (121): + case(121): return Byte121; - case (122): + case(122): return Byte122; - case (123): + case(123): return Byte123; - case (124): + case(124): return Byte124; - case (125): + case(125): return Byte125; - case (126): + case(126): return Byte126; - case (127): + case(127): return Byte127; - case (128): + case(128): return Byte128; - case (129): + case(129): return Byte129; - case (130): + case(130): return Byte130; - case (131): + case(131): return Byte131; - case (132): + case(132): return Byte132; - case (133): + case(133): return Byte133; - case (134): + case(134): return Byte134; - case (135): + case(135): return Byte135; - case (136): + case(136): return Byte136; - case (137): + case(137): return Byte137; - case (138): + case(138): return Byte138; - case (139): + case(139): return Byte139; - case (140): + case(140): return Byte140; - case (141): + case(141): return Byte141; - case (142): + case(142): return Byte142; - case (143): + case(143): return Byte143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, Byte value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - Byte0 = value; - break; - case (1): - Byte1 = value; - break; - case (2): - Byte2 = value; - break; - case (3): - Byte3 = value; - break; - case (4): - Byte4 = value; - break; - case (5): - Byte5 = value; - break; - case (6): - Byte6 = value; - break; - case (7): - Byte7 = value; - break; - case (8): - Byte8 = value; - break; - case (9): - Byte9 = value; - break; - case (10): - Byte10 = value; - break; - case (11): - Byte11 = value; - break; - case (12): - Byte12 = value; - break; - case (13): - Byte13 = value; - break; - case (14): - Byte14 = value; - break; - case (16): - Byte16 = value; - break; - case (17): - Byte17 = value; - break; - case (18): - Byte18 = value; - break; - case (19): - Byte19 = value; - break; - case (20): - Byte20 = value; - break; - case (21): - Byte21 = value; - break; - case (22): - Byte22 = value; - break; - case (23): - Byte23 = value; - break; - case (24): - Byte24 = value; - break; - case (26): - Byte26 = value; - break; - case (28): - Byte28 = value; - break; - case (29): - Byte29 = value; - break; - case (30): - Byte30 = value; - break; - case (31): - Byte31 = value; - break; - case (32): - Byte32 = value; - break; - case (33): - Byte33 = value; - break; - case (35): - Byte35 = value; - break; - case (36): - Byte36 = value; - break; - case (37): - Byte37 = value; - break; - case (38): - Byte38 = value; - break; - case (39): - Byte39 = value; - break; - case (40): - Byte40 = value; - break; - case (41): - Byte41 = value; - break; - case (42): - Byte42 = value; - break; - case (43): - Byte43 = value; - break; - case (44): - Byte44 = value; - break; - case (45): - Byte45 = value; - break; - case (46): - Byte46 = value; - break; - case (47): - Byte47 = value; - break; - case (48): - Byte48 = value; - break; - case (49): - Byte49 = value; - break; - case (50): - Byte50 = value; - break; - case (52): - Byte52 = value; - break; - case (53): - Byte53 = value; - break; - case (54): - Byte54 = value; - break; - case (55): - Byte55 = value; - break; - case (56): - Byte56 = value; - break; - case (57): - Byte57 = value; - break; - case (58): - Byte58 = value; - break; - case (59): - Byte59 = value; - break; - case (60): - Byte60 = value; - break; - case (62): - Byte62 = value; - break; - case (64): - Byte64 = value; - break; - case (65): - Byte65 = value; - break; - case (66): - Byte66 = value; - break; - case (67): - Byte67 = value; - break; - case (68): - Byte68 = value; - break; - case (69): - Byte69 = value; - break; - case (71): - Byte71 = value; - break; - case (72): - Byte72 = value; - break; - case (73): - Byte73 = value; - break; - case (74): - Byte74 = value; - break; - case (75): - Byte75 = value; - break; - case (76): - Byte76 = value; - break; - case (77): - Byte77 = value; - break; - case (78): - Byte78 = value; - break; - case (79): - Byte79 = value; - break; - case (80): - Byte80 = value; - break; - case (81): - Byte81 = value; - break; - case (82): - Byte82 = value; - break; - case (83): - Byte83 = value; - break; - case (84): - Byte84 = value; - break; - case (85): - Byte85 = value; - break; - case (86): - Byte86 = value; - break; - case (88): - Byte88 = value; - break; - case (89): - Byte89 = value; - break; - case (90): - Byte90 = value; - break; - case (91): - Byte91 = value; - break; - case (92): - Byte92 = value; - break; - case (93): - Byte93 = value; - break; - case (94): - Byte94 = value; - break; - case (95): - Byte95 = value; - break; - case (96): - Byte96 = value; - break; - case (98): - Byte98 = value; - break; - case (100): - Byte100 = value; - break; - case (101): - Byte101 = value; - break; - case (102): - Byte102 = value; - break; - case (103): - Byte103 = value; - break; - case (104): - Byte104 = value; - break; - case (105): - Byte105 = value; - break; - case (107): - Byte107 = value; - break; - case (108): - Byte108 = value; - break; - case (109): - Byte109 = value; - break; - case (110): - Byte110 = value; - break; - case (111): - Byte111 = value; - break; - case (112): - Byte112 = value; - break; - case (113): - Byte113 = value; - break; - case (114): - Byte114 = value; - break; - case (115): - Byte115 = value; - break; - case (116): - Byte116 = value; - break; - case (117): - Byte117 = value; - break; - case (118): - Byte118 = value; - break; - case (119): - Byte119 = value; - break; - case (120): - Byte120 = value; - break; - case (121): - Byte121 = value; - break; - case (122): - Byte122 = value; - break; - case (124): - Byte124 = value; - break; - case (125): - Byte125 = value; - break; - case (126): - Byte126 = value; - break; - case (127): - Byte127 = value; - break; - case (128): - Byte128 = value; - break; - case (129): - Byte129 = value; - break; - case (130): - Byte130 = value; - break; - case (131): - Byte131 = value; - break; - case (132): - Byte132 = value; - break; - case (134): - Byte134 = value; - break; - case (136): - Byte136 = value; - break; - case (137): - Byte137 = value; - break; - case (138): - Byte138 = value; - break; - case (139): - Byte139 = value; - break; - case (140): - Byte140 = value; - break; - case (141): - Byte141 = value; - break; - case (143): - Byte143 = value; - break; + public boolean set(int index,Byte value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + Byte0= value; + break; + case(1): + Byte1= value; + break; + case(2): + Byte2= value; + break; + case(3): + Byte3= value; + break; + case(4): + Byte4= value; + break; + case(5): + Byte5= value; + break; + case(6): + Byte6= value; + break; + case(7): + Byte7= value; + break; + case(8): + Byte8= value; + break; + case(9): + Byte9= value; + break; + case(10): + Byte10= value; + break; + case(11): + Byte11= value; + break; + case(12): + Byte12= value; + break; + case(13): + Byte13= value; + break; + case(14): + Byte14= value; + break; + case(16): + Byte16= value; + break; + case(17): + Byte17= value; + break; + case(18): + Byte18= value; + break; + case(19): + Byte19= value; + break; + case(20): + Byte20= value; + break; + case(21): + Byte21= value; + break; + case(22): + Byte22= value; + break; + case(23): + Byte23= value; + break; + case(24): + Byte24= value; + break; + case(26): + Byte26= value; + break; + case(28): + Byte28= value; + break; + case(29): + Byte29= value; + break; + case(30): + Byte30= value; + break; + case(31): + Byte31= value; + break; + case(32): + Byte32= value; + break; + case(33): + Byte33= value; + break; + case(35): + Byte35= value; + break; + case(36): + Byte36= value; + break; + case(37): + Byte37= value; + break; + case(38): + Byte38= value; + break; + case(39): + Byte39= value; + break; + case(40): + Byte40= value; + break; + case(41): + Byte41= value; + break; + case(42): + Byte42= value; + break; + case(43): + Byte43= value; + break; + case(44): + Byte44= value; + break; + case(45): + Byte45= value; + break; + case(46): + Byte46= value; + break; + case(47): + Byte47= value; + break; + case(48): + Byte48= value; + break; + case(49): + Byte49= value; + break; + case(50): + Byte50= value; + break; + case(52): + Byte52= value; + break; + case(53): + Byte53= value; + break; + case(54): + Byte54= value; + break; + case(55): + Byte55= value; + break; + case(56): + Byte56= value; + break; + case(57): + Byte57= value; + break; + case(58): + Byte58= value; + break; + case(59): + Byte59= value; + break; + case(60): + Byte60= value; + break; + case(62): + Byte62= value; + break; + case(64): + Byte64= value; + break; + case(65): + Byte65= value; + break; + case(66): + Byte66= value; + break; + case(67): + Byte67= value; + break; + case(68): + Byte68= value; + break; + case(69): + Byte69= value; + break; + case(71): + Byte71= value; + break; + case(72): + Byte72= value; + break; + case(73): + Byte73= value; + break; + case(74): + Byte74= value; + break; + case(75): + Byte75= value; + break; + case(76): + Byte76= value; + break; + case(77): + Byte77= value; + break; + case(78): + Byte78= value; + break; + case(79): + Byte79= value; + break; + case(80): + Byte80= value; + break; + case(81): + Byte81= value; + break; + case(82): + Byte82= value; + break; + case(83): + Byte83= value; + break; + case(84): + Byte84= value; + break; + case(85): + Byte85= value; + break; + case(86): + Byte86= value; + break; + case(88): + Byte88= value; + break; + case(89): + Byte89= value; + break; + case(90): + Byte90= value; + break; + case(91): + Byte91= value; + break; + case(92): + Byte92= value; + break; + case(93): + Byte93= value; + break; + case(94): + Byte94= value; + break; + case(95): + Byte95= value; + break; + case(96): + Byte96= value; + break; + case(98): + Byte98= value; + break; + case(100): + Byte100= value; + break; + case(101): + Byte101= value; + break; + case(102): + Byte102= value; + break; + case(103): + Byte103= value; + break; + case(104): + Byte104= value; + break; + case(105): + Byte105= value; + break; + case(107): + Byte107= value; + break; + case(108): + Byte108= value; + break; + case(109): + Byte109= value; + break; + case(110): + Byte110= value; + break; + case(111): + Byte111= value; + break; + case(112): + Byte112= value; + break; + case(113): + Byte113= value; + break; + case(114): + Byte114= value; + break; + case(115): + Byte115= value; + break; + case(116): + Byte116= value; + break; + case(117): + Byte117= value; + break; + case(118): + Byte118= value; + break; + case(119): + Byte119= value; + break; + case(120): + Byte120= value; + break; + case(121): + Byte121= value; + break; + case(122): + Byte122= value; + break; + case(124): + Byte124= value; + break; + case(125): + Byte125= value; + break; + case(126): + Byte126= value; + break; + case(127): + Byte127= value; + break; + case(128): + Byte128= value; + break; + case(129): + Byte129= value; + break; + case(130): + Byte130= value; + break; + case(131): + Byte131= value; + break; + case(132): + Byte132= value; + break; + case(134): + Byte134= value; + break; + case(136): + Byte136= value; + break; + case(137): + Byte137= value; + break; + case(138): + Byte138= value; + break; + case(139): + Byte139= value; + break; + case(140): + Byte140= value; + break; + case(141): + Byte141= value; + break; + case(143): + Byte143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfCharacter.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfCharacter.java index 2f6fdba0f..f30bb64e4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfCharacter.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfCharacter.java @@ -5,21 +5,21 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -public class FieldsOfCharacter { +public class FieldsOfCharacter { public int identifier; private Character Character0; private Character Character1; @@ -48,14 +48,14 @@ public class FieldsOfCharacter { private static transient Character Character24; private static final Character Character25 = Character.valueOf('a'); private static volatile Character Character26; - private final transient Character Character27 = Character.valueOf('a'); + private transient final Character Character27 = Character.valueOf('a'); private transient volatile Character Character28; private transient volatile Character Character29; private transient volatile Character Character30; private transient volatile Character Character31; private transient volatile Character Character32; private transient volatile Character Character33; - private static final transient Character Character34 = Character.valueOf('a'); + private static transient final Character Character34 = Character.valueOf('a'); private static transient volatile Character Character35; public Character Character36; public Character Character37; @@ -84,14 +84,14 @@ public class FieldsOfCharacter { public static transient Character Character60; public static final Character Character61 = Character.valueOf('a'); public static volatile Character Character62; - public final transient Character Character63 = Character.valueOf('a'); + public transient final Character Character63 = Character.valueOf('a'); public transient volatile Character Character64; public transient volatile Character Character65; public transient volatile Character Character66; public transient volatile Character Character67; public transient volatile Character Character68; public transient volatile Character Character69; - public static final transient Character Character70 = Character.valueOf('a'); + public static transient final Character Character70 = Character.valueOf('a'); public static transient volatile Character Character71; protected Character Character72; protected Character Character73; @@ -120,14 +120,14 @@ public class FieldsOfCharacter { protected static transient Character Character96; protected static final Character Character97 = Character.valueOf('a'); protected static volatile Character Character98; - protected final transient Character Character99 = Character.valueOf('a'); + protected transient final Character Character99 = Character.valueOf('a'); protected transient volatile Character Character100; protected transient volatile Character Character101; protected transient volatile Character Character102; protected transient volatile Character Character103; protected transient volatile Character Character104; protected transient volatile Character Character105; - protected static final transient Character Character106 = Character.valueOf('a'); + protected static transient final Character Character106 = Character.valueOf('a'); protected static transient volatile Character Character107; Character Character108; Character Character109; @@ -156,936 +156,935 @@ public class FieldsOfCharacter { static transient Character Character132; static final Character Character133 = Character.valueOf('a'); static volatile Character Character134; - final transient Character Character135 = Character.valueOf('a'); + transient final Character Character135 = Character.valueOf('a'); transient volatile Character Character136; transient volatile Character Character137; transient volatile Character Character138; transient volatile Character Character139; transient volatile Character Character140; transient volatile Character Character141; - static final transient Character Character142 = Character.valueOf('a'); + static transient final Character Character142 = Character.valueOf('a'); static transient volatile Character Character143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private Character Character0", - "embedded= true private Character Character1", - "embedded= false private Character Character2", - "persistence-modifier= none private Character Character3", - "persistence-modifier= persistent private Character Character4", - "persistence-modifier= persistent embedded= true private Character Character5", - "persistence-modifier= persistent embedded= false private Character Character6", - "persistence-modifier= transactional private Character Character7", - "private static Character Character8", - "private transient Character Character9", - "persistence-modifier= none private transient Character Character10", - "persistence-modifier= persistent private transient Character Character11", - "persistence-modifier= persistent embedded= true private transient Character Character12", - "persistence-modifier= persistent embedded= false private transient Character Character13", - "persistence-modifier= transactional private transient Character Character14", - "private final Character Character15", - "private volatile Character Character16", - "embedded= true private volatile Character Character17", - "embedded= false private volatile Character Character18", - "persistence-modifier= none private volatile Character Character19", - "persistence-modifier= persistent private volatile Character Character20", - "persistence-modifier= persistent embedded= true private volatile Character Character21", - "persistence-modifier= persistent embedded= false private volatile Character Character22", - "persistence-modifier= transactional private volatile Character Character23", - "private static transient Character Character24", - "private static final Character Character25", - "private static volatile Character Character26", - "private transient final Character Character27", - "private transient volatile Character Character28", - "persistence-modifier= none private transient volatile Character Character29", - "persistence-modifier= persistent private transient volatile Character Character30", - "persistence-modifier= persistent embedded= true private transient volatile Character Character31", - "persistence-modifier= persistent embedded= false private transient volatile Character Character32", - "persistence-modifier= transactional private transient volatile Character Character33", - "private static transient final Character Character34", - "private static transient volatile Character Character35", - "public Character Character36", - "embedded= true public Character Character37", - "embedded= false public Character Character38", - "persistence-modifier= none public Character Character39", - "persistence-modifier= persistent public Character Character40", - "persistence-modifier= persistent embedded= true public Character Character41", - "persistence-modifier= persistent embedded= false public Character Character42", - "persistence-modifier= transactional public Character Character43", - "public static Character Character44", - "public transient Character Character45", - "persistence-modifier= none public transient Character Character46", - "persistence-modifier= persistent public transient Character Character47", - "persistence-modifier= persistent embedded= true public transient Character Character48", - "persistence-modifier= persistent embedded= false public transient Character Character49", - "persistence-modifier= transactional public transient Character Character50", - "public final Character Character51", - "public volatile Character Character52", - "embedded= true public volatile Character Character53", - "embedded= false public volatile Character Character54", - "persistence-modifier= none public volatile Character Character55", - "persistence-modifier= persistent public volatile Character Character56", - "persistence-modifier= persistent embedded= true public volatile Character Character57", - "persistence-modifier= persistent embedded= false public volatile Character Character58", - "persistence-modifier= transactional public volatile Character Character59", - "public static transient Character Character60", - "public static final Character Character61", - "public static volatile Character Character62", - "public transient final Character Character63", - "public transient volatile Character Character64", - "persistence-modifier= none public transient volatile Character Character65", - "persistence-modifier= persistent public transient volatile Character Character66", - "persistence-modifier= persistent embedded= true public transient volatile Character Character67", - "persistence-modifier= persistent embedded= false public transient volatile Character Character68", - "persistence-modifier= transactional public transient volatile Character Character69", - "public static transient final Character Character70", - "public static transient volatile Character Character71", - "protected Character Character72", - "embedded= true protected Character Character73", - "embedded= false protected Character Character74", - "persistence-modifier= none protected Character Character75", - "persistence-modifier= persistent protected Character Character76", - "persistence-modifier= persistent embedded= true protected Character Character77", - "persistence-modifier= persistent embedded= false protected Character Character78", - "persistence-modifier= transactional protected Character Character79", - "protected static Character Character80", - "protected transient Character Character81", - "persistence-modifier= none protected transient Character Character82", - "persistence-modifier= persistent protected transient Character Character83", - "persistence-modifier= persistent embedded= true protected transient Character Character84", - "persistence-modifier= persistent embedded= false protected transient Character Character85", - "persistence-modifier= transactional protected transient Character Character86", - "protected final Character Character87", - "protected volatile Character Character88", - "embedded= true protected volatile Character Character89", - "embedded= false protected volatile Character Character90", - "persistence-modifier= none protected volatile Character Character91", - "persistence-modifier= persistent protected volatile Character Character92", - "persistence-modifier= persistent embedded= true protected volatile Character Character93", - "persistence-modifier= persistent embedded= false protected volatile Character Character94", - "persistence-modifier= transactional protected volatile Character Character95", - "protected static transient Character Character96", - "protected static final Character Character97", - "protected static volatile Character Character98", - "protected transient final Character Character99", - "protected transient volatile Character Character100", - "persistence-modifier= none protected transient volatile Character Character101", - "persistence-modifier= persistent protected transient volatile Character Character102", - "persistence-modifier= persistent embedded= true protected transient volatile Character Character103", - "persistence-modifier= persistent embedded= false protected transient volatile Character Character104", - "persistence-modifier= transactional protected transient volatile Character Character105", - "protected static transient final Character Character106", - "protected static transient volatile Character Character107", - "Character Character108", - "embedded= true Character Character109", - "embedded= false Character Character110", - "persistence-modifier= none Character Character111", - "persistence-modifier= persistent Character Character112", - "persistence-modifier= persistent embedded= true Character Character113", - "persistence-modifier= persistent embedded= false Character Character114", - "persistence-modifier= transactional Character Character115", - "static Character Character116", - "transient Character Character117", - "persistence-modifier= none transient Character Character118", - "persistence-modifier= persistent transient Character Character119", - "persistence-modifier= persistent embedded= true transient Character Character120", - "persistence-modifier= persistent embedded= false transient Character Character121", - "persistence-modifier= transactional transient Character Character122", - "final Character Character123", - "volatile Character Character124", - "embedded= true volatile Character Character125", - "embedded= false volatile Character Character126", - "persistence-modifier= none volatile Character Character127", - "persistence-modifier= persistent volatile Character Character128", - "persistence-modifier= persistent embedded= true volatile Character Character129", - "persistence-modifier= persistent embedded= false volatile Character Character130", - "persistence-modifier= transactional volatile Character Character131", - "static transient Character Character132", - "static final Character Character133", - "static volatile Character Character134", - "transient final Character Character135", - "transient volatile Character Character136", - "persistence-modifier= none transient volatile Character Character137", - "persistence-modifier= persistent transient volatile Character Character138", - "persistence-modifier= persistent embedded= true transient volatile Character Character139", - "persistence-modifier= persistent embedded= false transient volatile Character Character140", - "persistence-modifier= transactional transient volatile Character Character141", - "static transient final Character Character142", - "static transient volatile Character Character143" + public static final String [] fieldSpecs = { + "private Character Character0", + "embedded= true private Character Character1", + "embedded= false private Character Character2", + "persistence-modifier= none private Character Character3", + "persistence-modifier= persistent private Character Character4", + "persistence-modifier= persistent embedded= true private Character Character5", + "persistence-modifier= persistent embedded= false private Character Character6", + "persistence-modifier= transactional private Character Character7", + "private static Character Character8", + "private transient Character Character9", + "persistence-modifier= none private transient Character Character10", + "persistence-modifier= persistent private transient Character Character11", + "persistence-modifier= persistent embedded= true private transient Character Character12", + "persistence-modifier= persistent embedded= false private transient Character Character13", + "persistence-modifier= transactional private transient Character Character14", + "private final Character Character15", + "private volatile Character Character16", + "embedded= true private volatile Character Character17", + "embedded= false private volatile Character Character18", + "persistence-modifier= none private volatile Character Character19", + "persistence-modifier= persistent private volatile Character Character20", + "persistence-modifier= persistent embedded= true private volatile Character Character21", + "persistence-modifier= persistent embedded= false private volatile Character Character22", + "persistence-modifier= transactional private volatile Character Character23", + "private static transient Character Character24", + "private static final Character Character25", + "private static volatile Character Character26", + "private transient final Character Character27", + "private transient volatile Character Character28", + "persistence-modifier= none private transient volatile Character Character29", + "persistence-modifier= persistent private transient volatile Character Character30", + "persistence-modifier= persistent embedded= true private transient volatile Character Character31", + "persistence-modifier= persistent embedded= false private transient volatile Character Character32", + "persistence-modifier= transactional private transient volatile Character Character33", + "private static transient final Character Character34", + "private static transient volatile Character Character35", + "public Character Character36", + "embedded= true public Character Character37", + "embedded= false public Character Character38", + "persistence-modifier= none public Character Character39", + "persistence-modifier= persistent public Character Character40", + "persistence-modifier= persistent embedded= true public Character Character41", + "persistence-modifier= persistent embedded= false public Character Character42", + "persistence-modifier= transactional public Character Character43", + "public static Character Character44", + "public transient Character Character45", + "persistence-modifier= none public transient Character Character46", + "persistence-modifier= persistent public transient Character Character47", + "persistence-modifier= persistent embedded= true public transient Character Character48", + "persistence-modifier= persistent embedded= false public transient Character Character49", + "persistence-modifier= transactional public transient Character Character50", + "public final Character Character51", + "public volatile Character Character52", + "embedded= true public volatile Character Character53", + "embedded= false public volatile Character Character54", + "persistence-modifier= none public volatile Character Character55", + "persistence-modifier= persistent public volatile Character Character56", + "persistence-modifier= persistent embedded= true public volatile Character Character57", + "persistence-modifier= persistent embedded= false public volatile Character Character58", + "persistence-modifier= transactional public volatile Character Character59", + "public static transient Character Character60", + "public static final Character Character61", + "public static volatile Character Character62", + "public transient final Character Character63", + "public transient volatile Character Character64", + "persistence-modifier= none public transient volatile Character Character65", + "persistence-modifier= persistent public transient volatile Character Character66", + "persistence-modifier= persistent embedded= true public transient volatile Character Character67", + "persistence-modifier= persistent embedded= false public transient volatile Character Character68", + "persistence-modifier= transactional public transient volatile Character Character69", + "public static transient final Character Character70", + "public static transient volatile Character Character71", + "protected Character Character72", + "embedded= true protected Character Character73", + "embedded= false protected Character Character74", + "persistence-modifier= none protected Character Character75", + "persistence-modifier= persistent protected Character Character76", + "persistence-modifier= persistent embedded= true protected Character Character77", + "persistence-modifier= persistent embedded= false protected Character Character78", + "persistence-modifier= transactional protected Character Character79", + "protected static Character Character80", + "protected transient Character Character81", + "persistence-modifier= none protected transient Character Character82", + "persistence-modifier= persistent protected transient Character Character83", + "persistence-modifier= persistent embedded= true protected transient Character Character84", + "persistence-modifier= persistent embedded= false protected transient Character Character85", + "persistence-modifier= transactional protected transient Character Character86", + "protected final Character Character87", + "protected volatile Character Character88", + "embedded= true protected volatile Character Character89", + "embedded= false protected volatile Character Character90", + "persistence-modifier= none protected volatile Character Character91", + "persistence-modifier= persistent protected volatile Character Character92", + "persistence-modifier= persistent embedded= true protected volatile Character Character93", + "persistence-modifier= persistent embedded= false protected volatile Character Character94", + "persistence-modifier= transactional protected volatile Character Character95", + "protected static transient Character Character96", + "protected static final Character Character97", + "protected static volatile Character Character98", + "protected transient final Character Character99", + "protected transient volatile Character Character100", + "persistence-modifier= none protected transient volatile Character Character101", + "persistence-modifier= persistent protected transient volatile Character Character102", + "persistence-modifier= persistent embedded= true protected transient volatile Character Character103", + "persistence-modifier= persistent embedded= false protected transient volatile Character Character104", + "persistence-modifier= transactional protected transient volatile Character Character105", + "protected static transient final Character Character106", + "protected static transient volatile Character Character107", + "Character Character108", + "embedded= true Character Character109", + "embedded= false Character Character110", + "persistence-modifier= none Character Character111", + "persistence-modifier= persistent Character Character112", + "persistence-modifier= persistent embedded= true Character Character113", + "persistence-modifier= persistent embedded= false Character Character114", + "persistence-modifier= transactional Character Character115", + "static Character Character116", + "transient Character Character117", + "persistence-modifier= none transient Character Character118", + "persistence-modifier= persistent transient Character Character119", + "persistence-modifier= persistent embedded= true transient Character Character120", + "persistence-modifier= persistent embedded= false transient Character Character121", + "persistence-modifier= transactional transient Character Character122", + "final Character Character123", + "volatile Character Character124", + "embedded= true volatile Character Character125", + "embedded= false volatile Character Character126", + "persistence-modifier= none volatile Character Character127", + "persistence-modifier= persistent volatile Character Character128", + "persistence-modifier= persistent embedded= true volatile Character Character129", + "persistence-modifier= persistent embedded= false volatile Character Character130", + "persistence-modifier= transactional volatile Character Character131", + "static transient Character Character132", + "static final Character Character133", + "static volatile Character Character134", + "transient final Character Character135", + "transient volatile Character Character136", + "persistence-modifier= none transient volatile Character Character137", + "persistence-modifier= persistent transient volatile Character Character138", + "persistence-modifier= persistent embedded= true transient volatile Character Character139", + "persistence-modifier= persistent embedded= false transient volatile Character Character140", + "persistence-modifier= transactional transient volatile Character Character141", + "static transient final Character Character142", + "static transient volatile Character Character143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public Character get(int index) { - switch (index) { - case (0): + public Character get(int index) + { + switch (index) + { + case(0): return Character0; - case (1): + case(1): return Character1; - case (2): + case(2): return Character2; - case (3): + case(3): return Character3; - case (4): + case(4): return Character4; - case (5): + case(5): return Character5; - case (6): + case(6): return Character6; - case (7): + case(7): return Character7; - case (8): + case(8): return Character8; - case (9): + case(9): return Character9; - case (10): + case(10): return Character10; - case (11): + case(11): return Character11; - case (12): + case(12): return Character12; - case (13): + case(13): return Character13; - case (14): + case(14): return Character14; - case (15): + case(15): return Character15; - case (16): + case(16): return Character16; - case (17): + case(17): return Character17; - case (18): + case(18): return Character18; - case (19): + case(19): return Character19; - case (20): + case(20): return Character20; - case (21): + case(21): return Character21; - case (22): + case(22): return Character22; - case (23): + case(23): return Character23; - case (24): + case(24): return Character24; - case (25): + case(25): return Character25; - case (26): + case(26): return Character26; - case (27): + case(27): return Character27; - case (28): + case(28): return Character28; - case (29): + case(29): return Character29; - case (30): + case(30): return Character30; - case (31): + case(31): return Character31; - case (32): + case(32): return Character32; - case (33): + case(33): return Character33; - case (34): + case(34): return Character34; - case (35): + case(35): return Character35; - case (36): + case(36): return Character36; - case (37): + case(37): return Character37; - case (38): + case(38): return Character38; - case (39): + case(39): return Character39; - case (40): + case(40): return Character40; - case (41): + case(41): return Character41; - case (42): + case(42): return Character42; - case (43): + case(43): return Character43; - case (44): + case(44): return Character44; - case (45): + case(45): return Character45; - case (46): + case(46): return Character46; - case (47): + case(47): return Character47; - case (48): + case(48): return Character48; - case (49): + case(49): return Character49; - case (50): + case(50): return Character50; - case (51): + case(51): return Character51; - case (52): + case(52): return Character52; - case (53): + case(53): return Character53; - case (54): + case(54): return Character54; - case (55): + case(55): return Character55; - case (56): + case(56): return Character56; - case (57): + case(57): return Character57; - case (58): + case(58): return Character58; - case (59): + case(59): return Character59; - case (60): + case(60): return Character60; - case (61): + case(61): return Character61; - case (62): + case(62): return Character62; - case (63): + case(63): return Character63; - case (64): + case(64): return Character64; - case (65): + case(65): return Character65; - case (66): + case(66): return Character66; - case (67): + case(67): return Character67; - case (68): + case(68): return Character68; - case (69): + case(69): return Character69; - case (70): + case(70): return Character70; - case (71): + case(71): return Character71; - case (72): + case(72): return Character72; - case (73): + case(73): return Character73; - case (74): + case(74): return Character74; - case (75): + case(75): return Character75; - case (76): + case(76): return Character76; - case (77): + case(77): return Character77; - case (78): + case(78): return Character78; - case (79): + case(79): return Character79; - case (80): + case(80): return Character80; - case (81): + case(81): return Character81; - case (82): + case(82): return Character82; - case (83): + case(83): return Character83; - case (84): + case(84): return Character84; - case (85): + case(85): return Character85; - case (86): + case(86): return Character86; - case (87): + case(87): return Character87; - case (88): + case(88): return Character88; - case (89): + case(89): return Character89; - case (90): + case(90): return Character90; - case (91): + case(91): return Character91; - case (92): + case(92): return Character92; - case (93): + case(93): return Character93; - case (94): + case(94): return Character94; - case (95): + case(95): return Character95; - case (96): + case(96): return Character96; - case (97): + case(97): return Character97; - case (98): + case(98): return Character98; - case (99): + case(99): return Character99; - case (100): + case(100): return Character100; - case (101): + case(101): return Character101; - case (102): + case(102): return Character102; - case (103): + case(103): return Character103; - case (104): + case(104): return Character104; - case (105): + case(105): return Character105; - case (106): + case(106): return Character106; - case (107): + case(107): return Character107; - case (108): + case(108): return Character108; - case (109): + case(109): return Character109; - case (110): + case(110): return Character110; - case (111): + case(111): return Character111; - case (112): + case(112): return Character112; - case (113): + case(113): return Character113; - case (114): + case(114): return Character114; - case (115): + case(115): return Character115; - case (116): + case(116): return Character116; - case (117): + case(117): return Character117; - case (118): + case(118): return Character118; - case (119): + case(119): return Character119; - case (120): + case(120): return Character120; - case (121): + case(121): return Character121; - case (122): + case(122): return Character122; - case (123): + case(123): return Character123; - case (124): + case(124): return Character124; - case (125): + case(125): return Character125; - case (126): + case(126): return Character126; - case (127): + case(127): return Character127; - case (128): + case(128): return Character128; - case (129): + case(129): return Character129; - case (130): + case(130): return Character130; - case (131): + case(131): return Character131; - case (132): + case(132): return Character132; - case (133): + case(133): return Character133; - case (134): + case(134): return Character134; - case (135): + case(135): return Character135; - case (136): + case(136): return Character136; - case (137): + case(137): return Character137; - case (138): + case(138): return Character138; - case (139): + case(139): return Character139; - case (140): + case(140): return Character140; - case (141): + case(141): return Character141; - case (142): + case(142): return Character142; - case (143): + case(143): return Character143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, Character value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - Character0 = value; - break; - case (1): - Character1 = value; - break; - case (2): - Character2 = value; - break; - case (3): - Character3 = value; - break; - case (4): - Character4 = value; - break; - case (5): - Character5 = value; - break; - case (6): - Character6 = value; - break; - case (7): - Character7 = value; - break; - case (8): - Character8 = value; - break; - case (9): - Character9 = value; - break; - case (10): - Character10 = value; - break; - case (11): - Character11 = value; - break; - case (12): - Character12 = value; - break; - case (13): - Character13 = value; - break; - case (14): - Character14 = value; - break; - case (16): - Character16 = value; - break; - case (17): - Character17 = value; - break; - case (18): - Character18 = value; - break; - case (19): - Character19 = value; - break; - case (20): - Character20 = value; - break; - case (21): - Character21 = value; - break; - case (22): - Character22 = value; - break; - case (23): - Character23 = value; - break; - case (24): - Character24 = value; - break; - case (26): - Character26 = value; - break; - case (28): - Character28 = value; - break; - case (29): - Character29 = value; - break; - case (30): - Character30 = value; - break; - case (31): - Character31 = value; - break; - case (32): - Character32 = value; - break; - case (33): - Character33 = value; - break; - case (35): - Character35 = value; - break; - case (36): - Character36 = value; - break; - case (37): - Character37 = value; - break; - case (38): - Character38 = value; - break; - case (39): - Character39 = value; - break; - case (40): - Character40 = value; - break; - case (41): - Character41 = value; - break; - case (42): - Character42 = value; - break; - case (43): - Character43 = value; - break; - case (44): - Character44 = value; - break; - case (45): - Character45 = value; - break; - case (46): - Character46 = value; - break; - case (47): - Character47 = value; - break; - case (48): - Character48 = value; - break; - case (49): - Character49 = value; - break; - case (50): - Character50 = value; - break; - case (52): - Character52 = value; - break; - case (53): - Character53 = value; - break; - case (54): - Character54 = value; - break; - case (55): - Character55 = value; - break; - case (56): - Character56 = value; - break; - case (57): - Character57 = value; - break; - case (58): - Character58 = value; - break; - case (59): - Character59 = value; - break; - case (60): - Character60 = value; - break; - case (62): - Character62 = value; - break; - case (64): - Character64 = value; - break; - case (65): - Character65 = value; - break; - case (66): - Character66 = value; - break; - case (67): - Character67 = value; - break; - case (68): - Character68 = value; - break; - case (69): - Character69 = value; - break; - case (71): - Character71 = value; - break; - case (72): - Character72 = value; - break; - case (73): - Character73 = value; - break; - case (74): - Character74 = value; - break; - case (75): - Character75 = value; - break; - case (76): - Character76 = value; - break; - case (77): - Character77 = value; - break; - case (78): - Character78 = value; - break; - case (79): - Character79 = value; - break; - case (80): - Character80 = value; - break; - case (81): - Character81 = value; - break; - case (82): - Character82 = value; - break; - case (83): - Character83 = value; - break; - case (84): - Character84 = value; - break; - case (85): - Character85 = value; - break; - case (86): - Character86 = value; - break; - case (88): - Character88 = value; - break; - case (89): - Character89 = value; - break; - case (90): - Character90 = value; - break; - case (91): - Character91 = value; - break; - case (92): - Character92 = value; - break; - case (93): - Character93 = value; - break; - case (94): - Character94 = value; - break; - case (95): - Character95 = value; - break; - case (96): - Character96 = value; - break; - case (98): - Character98 = value; - break; - case (100): - Character100 = value; - break; - case (101): - Character101 = value; - break; - case (102): - Character102 = value; - break; - case (103): - Character103 = value; - break; - case (104): - Character104 = value; - break; - case (105): - Character105 = value; - break; - case (107): - Character107 = value; - break; - case (108): - Character108 = value; - break; - case (109): - Character109 = value; - break; - case (110): - Character110 = value; - break; - case (111): - Character111 = value; - break; - case (112): - Character112 = value; - break; - case (113): - Character113 = value; - break; - case (114): - Character114 = value; - break; - case (115): - Character115 = value; - break; - case (116): - Character116 = value; - break; - case (117): - Character117 = value; - break; - case (118): - Character118 = value; - break; - case (119): - Character119 = value; - break; - case (120): - Character120 = value; - break; - case (121): - Character121 = value; - break; - case (122): - Character122 = value; - break; - case (124): - Character124 = value; - break; - case (125): - Character125 = value; - break; - case (126): - Character126 = value; - break; - case (127): - Character127 = value; - break; - case (128): - Character128 = value; - break; - case (129): - Character129 = value; - break; - case (130): - Character130 = value; - break; - case (131): - Character131 = value; - break; - case (132): - Character132 = value; - break; - case (134): - Character134 = value; - break; - case (136): - Character136 = value; - break; - case (137): - Character137 = value; - break; - case (138): - Character138 = value; - break; - case (139): - Character139 = value; - break; - case (140): - Character140 = value; - break; - case (141): - Character141 = value; - break; - case (143): - Character143 = value; - break; + public boolean set(int index,Character value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + Character0= value; + break; + case(1): + Character1= value; + break; + case(2): + Character2= value; + break; + case(3): + Character3= value; + break; + case(4): + Character4= value; + break; + case(5): + Character5= value; + break; + case(6): + Character6= value; + break; + case(7): + Character7= value; + break; + case(8): + Character8= value; + break; + case(9): + Character9= value; + break; + case(10): + Character10= value; + break; + case(11): + Character11= value; + break; + case(12): + Character12= value; + break; + case(13): + Character13= value; + break; + case(14): + Character14= value; + break; + case(16): + Character16= value; + break; + case(17): + Character17= value; + break; + case(18): + Character18= value; + break; + case(19): + Character19= value; + break; + case(20): + Character20= value; + break; + case(21): + Character21= value; + break; + case(22): + Character22= value; + break; + case(23): + Character23= value; + break; + case(24): + Character24= value; + break; + case(26): + Character26= value; + break; + case(28): + Character28= value; + break; + case(29): + Character29= value; + break; + case(30): + Character30= value; + break; + case(31): + Character31= value; + break; + case(32): + Character32= value; + break; + case(33): + Character33= value; + break; + case(35): + Character35= value; + break; + case(36): + Character36= value; + break; + case(37): + Character37= value; + break; + case(38): + Character38= value; + break; + case(39): + Character39= value; + break; + case(40): + Character40= value; + break; + case(41): + Character41= value; + break; + case(42): + Character42= value; + break; + case(43): + Character43= value; + break; + case(44): + Character44= value; + break; + case(45): + Character45= value; + break; + case(46): + Character46= value; + break; + case(47): + Character47= value; + break; + case(48): + Character48= value; + break; + case(49): + Character49= value; + break; + case(50): + Character50= value; + break; + case(52): + Character52= value; + break; + case(53): + Character53= value; + break; + case(54): + Character54= value; + break; + case(55): + Character55= value; + break; + case(56): + Character56= value; + break; + case(57): + Character57= value; + break; + case(58): + Character58= value; + break; + case(59): + Character59= value; + break; + case(60): + Character60= value; + break; + case(62): + Character62= value; + break; + case(64): + Character64= value; + break; + case(65): + Character65= value; + break; + case(66): + Character66= value; + break; + case(67): + Character67= value; + break; + case(68): + Character68= value; + break; + case(69): + Character69= value; + break; + case(71): + Character71= value; + break; + case(72): + Character72= value; + break; + case(73): + Character73= value; + break; + case(74): + Character74= value; + break; + case(75): + Character75= value; + break; + case(76): + Character76= value; + break; + case(77): + Character77= value; + break; + case(78): + Character78= value; + break; + case(79): + Character79= value; + break; + case(80): + Character80= value; + break; + case(81): + Character81= value; + break; + case(82): + Character82= value; + break; + case(83): + Character83= value; + break; + case(84): + Character84= value; + break; + case(85): + Character85= value; + break; + case(86): + Character86= value; + break; + case(88): + Character88= value; + break; + case(89): + Character89= value; + break; + case(90): + Character90= value; + break; + case(91): + Character91= value; + break; + case(92): + Character92= value; + break; + case(93): + Character93= value; + break; + case(94): + Character94= value; + break; + case(95): + Character95= value; + break; + case(96): + Character96= value; + break; + case(98): + Character98= value; + break; + case(100): + Character100= value; + break; + case(101): + Character101= value; + break; + case(102): + Character102= value; + break; + case(103): + Character103= value; + break; + case(104): + Character104= value; + break; + case(105): + Character105= value; + break; + case(107): + Character107= value; + break; + case(108): + Character108= value; + break; + case(109): + Character109= value; + break; + case(110): + Character110= value; + break; + case(111): + Character111= value; + break; + case(112): + Character112= value; + break; + case(113): + Character113= value; + break; + case(114): + Character114= value; + break; + case(115): + Character115= value; + break; + case(116): + Character116= value; + break; + case(117): + Character117= value; + break; + case(118): + Character118= value; + break; + case(119): + Character119= value; + break; + case(120): + Character120= value; + break; + case(121): + Character121= value; + break; + case(122): + Character122= value; + break; + case(124): + Character124= value; + break; + case(125): + Character125= value; + break; + case(126): + Character126= value; + break; + case(127): + Character127= value; + break; + case(128): + Character128= value; + break; + case(129): + Character129= value; + break; + case(130): + Character130= value; + break; + case(131): + Character131= value; + break; + case(132): + Character132= value; + break; + case(134): + Character134= value; + break; + case(136): + Character136= value; + break; + case(137): + Character137= value; + break; + case(138): + Character138= value; + break; + case(139): + Character139= value; + break; + case(140): + Character140= value; + break; + case(141): + Character141= value; + break; + case(143): + Character143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfDate.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfDate.java index 3825aebb2..ed578c376 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfDate.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfDate.java @@ -5,22 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -import java.util.Date; -public class FieldsOfDate { +import java.util.*; +public class FieldsOfDate { public int identifier; private Date Date0; private Date Date1; @@ -49,14 +49,14 @@ public class FieldsOfDate { private static transient Date Date24; private static final Date Date25 = new Date(); private static volatile Date Date26; - private final transient Date Date27 = new Date(); + private transient final Date Date27 = new Date(); private transient volatile Date Date28; private transient volatile Date Date29; private transient volatile Date Date30; private transient volatile Date Date31; private transient volatile Date Date32; private transient volatile Date Date33; - private static final transient Date Date34 = new Date(); + private static transient final Date Date34 = new Date(); private static transient volatile Date Date35; public Date Date36; public Date Date37; @@ -85,14 +85,14 @@ public class FieldsOfDate { public static transient Date Date60; public static final Date Date61 = new Date(); public static volatile Date Date62; - public final transient Date Date63 = new Date(); + public transient final Date Date63 = new Date(); public transient volatile Date Date64; public transient volatile Date Date65; public transient volatile Date Date66; public transient volatile Date Date67; public transient volatile Date Date68; public transient volatile Date Date69; - public static final transient Date Date70 = new Date(); + public static transient final Date Date70 = new Date(); public static transient volatile Date Date71; protected Date Date72; protected Date Date73; @@ -121,14 +121,14 @@ public class FieldsOfDate { protected static transient Date Date96; protected static final Date Date97 = new Date(); protected static volatile Date Date98; - protected final transient Date Date99 = new Date(); + protected transient final Date Date99 = new Date(); protected transient volatile Date Date100; protected transient volatile Date Date101; protected transient volatile Date Date102; protected transient volatile Date Date103; protected transient volatile Date Date104; protected transient volatile Date Date105; - protected static final transient Date Date106 = new Date(); + protected static transient final Date Date106 = new Date(); protected static transient volatile Date Date107; Date Date108; Date Date109; @@ -157,936 +157,935 @@ public class FieldsOfDate { static transient Date Date132; static final Date Date133 = new Date(); static volatile Date Date134; - final transient Date Date135 = new Date(); + transient final Date Date135 = new Date(); transient volatile Date Date136; transient volatile Date Date137; transient volatile Date Date138; transient volatile Date Date139; transient volatile Date Date140; transient volatile Date Date141; - static final transient Date Date142 = new Date(); + static transient final Date Date142 = new Date(); static transient volatile Date Date143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private Date Date0", - "embedded= true private Date Date1", - "embedded= false private Date Date2", - "persistence-modifier= none private Date Date3", - "persistence-modifier= persistent private Date Date4", - "persistence-modifier= persistent embedded= true private Date Date5", - "persistence-modifier= persistent embedded= false private Date Date6", - "persistence-modifier= transactional private Date Date7", - "private static Date Date8", - "private transient Date Date9", - "persistence-modifier= none private transient Date Date10", - "persistence-modifier= persistent private transient Date Date11", - "persistence-modifier= persistent embedded= true private transient Date Date12", - "persistence-modifier= persistent embedded= false private transient Date Date13", - "persistence-modifier= transactional private transient Date Date14", - "private final Date Date15", - "private volatile Date Date16", - "embedded= true private volatile Date Date17", - "embedded= false private volatile Date Date18", - "persistence-modifier= none private volatile Date Date19", - "persistence-modifier= persistent private volatile Date Date20", - "persistence-modifier= persistent embedded= true private volatile Date Date21", - "persistence-modifier= persistent embedded= false private volatile Date Date22", - "persistence-modifier= transactional private volatile Date Date23", - "private static transient Date Date24", - "private static final Date Date25", - "private static volatile Date Date26", - "private transient final Date Date27", - "private transient volatile Date Date28", - "persistence-modifier= none private transient volatile Date Date29", - "persistence-modifier= persistent private transient volatile Date Date30", - "persistence-modifier= persistent embedded= true private transient volatile Date Date31", - "persistence-modifier= persistent embedded= false private transient volatile Date Date32", - "persistence-modifier= transactional private transient volatile Date Date33", - "private static transient final Date Date34", - "private static transient volatile Date Date35", - "public Date Date36", - "embedded= true public Date Date37", - "embedded= false public Date Date38", - "persistence-modifier= none public Date Date39", - "persistence-modifier= persistent public Date Date40", - "persistence-modifier= persistent embedded= true public Date Date41", - "persistence-modifier= persistent embedded= false public Date Date42", - "persistence-modifier= transactional public Date Date43", - "public static Date Date44", - "public transient Date Date45", - "persistence-modifier= none public transient Date Date46", - "persistence-modifier= persistent public transient Date Date47", - "persistence-modifier= persistent embedded= true public transient Date Date48", - "persistence-modifier= persistent embedded= false public transient Date Date49", - "persistence-modifier= transactional public transient Date Date50", - "public final Date Date51", - "public volatile Date Date52", - "embedded= true public volatile Date Date53", - "embedded= false public volatile Date Date54", - "persistence-modifier= none public volatile Date Date55", - "persistence-modifier= persistent public volatile Date Date56", - "persistence-modifier= persistent embedded= true public volatile Date Date57", - "persistence-modifier= persistent embedded= false public volatile Date Date58", - "persistence-modifier= transactional public volatile Date Date59", - "public static transient Date Date60", - "public static final Date Date61", - "public static volatile Date Date62", - "public transient final Date Date63", - "public transient volatile Date Date64", - "persistence-modifier= none public transient volatile Date Date65", - "persistence-modifier= persistent public transient volatile Date Date66", - "persistence-modifier= persistent embedded= true public transient volatile Date Date67", - "persistence-modifier= persistent embedded= false public transient volatile Date Date68", - "persistence-modifier= transactional public transient volatile Date Date69", - "public static transient final Date Date70", - "public static transient volatile Date Date71", - "protected Date Date72", - "embedded= true protected Date Date73", - "embedded= false protected Date Date74", - "persistence-modifier= none protected Date Date75", - "persistence-modifier= persistent protected Date Date76", - "persistence-modifier= persistent embedded= true protected Date Date77", - "persistence-modifier= persistent embedded= false protected Date Date78", - "persistence-modifier= transactional protected Date Date79", - "protected static Date Date80", - "protected transient Date Date81", - "persistence-modifier= none protected transient Date Date82", - "persistence-modifier= persistent protected transient Date Date83", - "persistence-modifier= persistent embedded= true protected transient Date Date84", - "persistence-modifier= persistent embedded= false protected transient Date Date85", - "persistence-modifier= transactional protected transient Date Date86", - "protected final Date Date87", - "protected volatile Date Date88", - "embedded= true protected volatile Date Date89", - "embedded= false protected volatile Date Date90", - "persistence-modifier= none protected volatile Date Date91", - "persistence-modifier= persistent protected volatile Date Date92", - "persistence-modifier= persistent embedded= true protected volatile Date Date93", - "persistence-modifier= persistent embedded= false protected volatile Date Date94", - "persistence-modifier= transactional protected volatile Date Date95", - "protected static transient Date Date96", - "protected static final Date Date97", - "protected static volatile Date Date98", - "protected transient final Date Date99", - "protected transient volatile Date Date100", - "persistence-modifier= none protected transient volatile Date Date101", - "persistence-modifier= persistent protected transient volatile Date Date102", - "persistence-modifier= persistent embedded= true protected transient volatile Date Date103", - "persistence-modifier= persistent embedded= false protected transient volatile Date Date104", - "persistence-modifier= transactional protected transient volatile Date Date105", - "protected static transient final Date Date106", - "protected static transient volatile Date Date107", - "Date Date108", - "embedded= true Date Date109", - "embedded= false Date Date110", - "persistence-modifier= none Date Date111", - "persistence-modifier= persistent Date Date112", - "persistence-modifier= persistent embedded= true Date Date113", - "persistence-modifier= persistent embedded= false Date Date114", - "persistence-modifier= transactional Date Date115", - "static Date Date116", - "transient Date Date117", - "persistence-modifier= none transient Date Date118", - "persistence-modifier= persistent transient Date Date119", - "persistence-modifier= persistent embedded= true transient Date Date120", - "persistence-modifier= persistent embedded= false transient Date Date121", - "persistence-modifier= transactional transient Date Date122", - "final Date Date123", - "volatile Date Date124", - "embedded= true volatile Date Date125", - "embedded= false volatile Date Date126", - "persistence-modifier= none volatile Date Date127", - "persistence-modifier= persistent volatile Date Date128", - "persistence-modifier= persistent embedded= true volatile Date Date129", - "persistence-modifier= persistent embedded= false volatile Date Date130", - "persistence-modifier= transactional volatile Date Date131", - "static transient Date Date132", - "static final Date Date133", - "static volatile Date Date134", - "transient final Date Date135", - "transient volatile Date Date136", - "persistence-modifier= none transient volatile Date Date137", - "persistence-modifier= persistent transient volatile Date Date138", - "persistence-modifier= persistent embedded= true transient volatile Date Date139", - "persistence-modifier= persistent embedded= false transient volatile Date Date140", - "persistence-modifier= transactional transient volatile Date Date141", - "static transient final Date Date142", - "static transient volatile Date Date143" + public static final String [] fieldSpecs = { + "private Date Date0", + "embedded= true private Date Date1", + "embedded= false private Date Date2", + "persistence-modifier= none private Date Date3", + "persistence-modifier= persistent private Date Date4", + "persistence-modifier= persistent embedded= true private Date Date5", + "persistence-modifier= persistent embedded= false private Date Date6", + "persistence-modifier= transactional private Date Date7", + "private static Date Date8", + "private transient Date Date9", + "persistence-modifier= none private transient Date Date10", + "persistence-modifier= persistent private transient Date Date11", + "persistence-modifier= persistent embedded= true private transient Date Date12", + "persistence-modifier= persistent embedded= false private transient Date Date13", + "persistence-modifier= transactional private transient Date Date14", + "private final Date Date15", + "private volatile Date Date16", + "embedded= true private volatile Date Date17", + "embedded= false private volatile Date Date18", + "persistence-modifier= none private volatile Date Date19", + "persistence-modifier= persistent private volatile Date Date20", + "persistence-modifier= persistent embedded= true private volatile Date Date21", + "persistence-modifier= persistent embedded= false private volatile Date Date22", + "persistence-modifier= transactional private volatile Date Date23", + "private static transient Date Date24", + "private static final Date Date25", + "private static volatile Date Date26", + "private transient final Date Date27", + "private transient volatile Date Date28", + "persistence-modifier= none private transient volatile Date Date29", + "persistence-modifier= persistent private transient volatile Date Date30", + "persistence-modifier= persistent embedded= true private transient volatile Date Date31", + "persistence-modifier= persistent embedded= false private transient volatile Date Date32", + "persistence-modifier= transactional private transient volatile Date Date33", + "private static transient final Date Date34", + "private static transient volatile Date Date35", + "public Date Date36", + "embedded= true public Date Date37", + "embedded= false public Date Date38", + "persistence-modifier= none public Date Date39", + "persistence-modifier= persistent public Date Date40", + "persistence-modifier= persistent embedded= true public Date Date41", + "persistence-modifier= persistent embedded= false public Date Date42", + "persistence-modifier= transactional public Date Date43", + "public static Date Date44", + "public transient Date Date45", + "persistence-modifier= none public transient Date Date46", + "persistence-modifier= persistent public transient Date Date47", + "persistence-modifier= persistent embedded= true public transient Date Date48", + "persistence-modifier= persistent embedded= false public transient Date Date49", + "persistence-modifier= transactional public transient Date Date50", + "public final Date Date51", + "public volatile Date Date52", + "embedded= true public volatile Date Date53", + "embedded= false public volatile Date Date54", + "persistence-modifier= none public volatile Date Date55", + "persistence-modifier= persistent public volatile Date Date56", + "persistence-modifier= persistent embedded= true public volatile Date Date57", + "persistence-modifier= persistent embedded= false public volatile Date Date58", + "persistence-modifier= transactional public volatile Date Date59", + "public static transient Date Date60", + "public static final Date Date61", + "public static volatile Date Date62", + "public transient final Date Date63", + "public transient volatile Date Date64", + "persistence-modifier= none public transient volatile Date Date65", + "persistence-modifier= persistent public transient volatile Date Date66", + "persistence-modifier= persistent embedded= true public transient volatile Date Date67", + "persistence-modifier= persistent embedded= false public transient volatile Date Date68", + "persistence-modifier= transactional public transient volatile Date Date69", + "public static transient final Date Date70", + "public static transient volatile Date Date71", + "protected Date Date72", + "embedded= true protected Date Date73", + "embedded= false protected Date Date74", + "persistence-modifier= none protected Date Date75", + "persistence-modifier= persistent protected Date Date76", + "persistence-modifier= persistent embedded= true protected Date Date77", + "persistence-modifier= persistent embedded= false protected Date Date78", + "persistence-modifier= transactional protected Date Date79", + "protected static Date Date80", + "protected transient Date Date81", + "persistence-modifier= none protected transient Date Date82", + "persistence-modifier= persistent protected transient Date Date83", + "persistence-modifier= persistent embedded= true protected transient Date Date84", + "persistence-modifier= persistent embedded= false protected transient Date Date85", + "persistence-modifier= transactional protected transient Date Date86", + "protected final Date Date87", + "protected volatile Date Date88", + "embedded= true protected volatile Date Date89", + "embedded= false protected volatile Date Date90", + "persistence-modifier= none protected volatile Date Date91", + "persistence-modifier= persistent protected volatile Date Date92", + "persistence-modifier= persistent embedded= true protected volatile Date Date93", + "persistence-modifier= persistent embedded= false protected volatile Date Date94", + "persistence-modifier= transactional protected volatile Date Date95", + "protected static transient Date Date96", + "protected static final Date Date97", + "protected static volatile Date Date98", + "protected transient final Date Date99", + "protected transient volatile Date Date100", + "persistence-modifier= none protected transient volatile Date Date101", + "persistence-modifier= persistent protected transient volatile Date Date102", + "persistence-modifier= persistent embedded= true protected transient volatile Date Date103", + "persistence-modifier= persistent embedded= false protected transient volatile Date Date104", + "persistence-modifier= transactional protected transient volatile Date Date105", + "protected static transient final Date Date106", + "protected static transient volatile Date Date107", + "Date Date108", + "embedded= true Date Date109", + "embedded= false Date Date110", + "persistence-modifier= none Date Date111", + "persistence-modifier= persistent Date Date112", + "persistence-modifier= persistent embedded= true Date Date113", + "persistence-modifier= persistent embedded= false Date Date114", + "persistence-modifier= transactional Date Date115", + "static Date Date116", + "transient Date Date117", + "persistence-modifier= none transient Date Date118", + "persistence-modifier= persistent transient Date Date119", + "persistence-modifier= persistent embedded= true transient Date Date120", + "persistence-modifier= persistent embedded= false transient Date Date121", + "persistence-modifier= transactional transient Date Date122", + "final Date Date123", + "volatile Date Date124", + "embedded= true volatile Date Date125", + "embedded= false volatile Date Date126", + "persistence-modifier= none volatile Date Date127", + "persistence-modifier= persistent volatile Date Date128", + "persistence-modifier= persistent embedded= true volatile Date Date129", + "persistence-modifier= persistent embedded= false volatile Date Date130", + "persistence-modifier= transactional volatile Date Date131", + "static transient Date Date132", + "static final Date Date133", + "static volatile Date Date134", + "transient final Date Date135", + "transient volatile Date Date136", + "persistence-modifier= none transient volatile Date Date137", + "persistence-modifier= persistent transient volatile Date Date138", + "persistence-modifier= persistent embedded= true transient volatile Date Date139", + "persistence-modifier= persistent embedded= false transient volatile Date Date140", + "persistence-modifier= transactional transient volatile Date Date141", + "static transient final Date Date142", + "static transient volatile Date Date143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public Date get(int index) { - switch (index) { - case (0): + public Date get(int index) + { + switch (index) + { + case(0): return Date0; - case (1): + case(1): return Date1; - case (2): + case(2): return Date2; - case (3): + case(3): return Date3; - case (4): + case(4): return Date4; - case (5): + case(5): return Date5; - case (6): + case(6): return Date6; - case (7): + case(7): return Date7; - case (8): + case(8): return Date8; - case (9): + case(9): return Date9; - case (10): + case(10): return Date10; - case (11): + case(11): return Date11; - case (12): + case(12): return Date12; - case (13): + case(13): return Date13; - case (14): + case(14): return Date14; - case (15): + case(15): return Date15; - case (16): + case(16): return Date16; - case (17): + case(17): return Date17; - case (18): + case(18): return Date18; - case (19): + case(19): return Date19; - case (20): + case(20): return Date20; - case (21): + case(21): return Date21; - case (22): + case(22): return Date22; - case (23): + case(23): return Date23; - case (24): + case(24): return Date24; - case (25): + case(25): return Date25; - case (26): + case(26): return Date26; - case (27): + case(27): return Date27; - case (28): + case(28): return Date28; - case (29): + case(29): return Date29; - case (30): + case(30): return Date30; - case (31): + case(31): return Date31; - case (32): + case(32): return Date32; - case (33): + case(33): return Date33; - case (34): + case(34): return Date34; - case (35): + case(35): return Date35; - case (36): + case(36): return Date36; - case (37): + case(37): return Date37; - case (38): + case(38): return Date38; - case (39): + case(39): return Date39; - case (40): + case(40): return Date40; - case (41): + case(41): return Date41; - case (42): + case(42): return Date42; - case (43): + case(43): return Date43; - case (44): + case(44): return Date44; - case (45): + case(45): return Date45; - case (46): + case(46): return Date46; - case (47): + case(47): return Date47; - case (48): + case(48): return Date48; - case (49): + case(49): return Date49; - case (50): + case(50): return Date50; - case (51): + case(51): return Date51; - case (52): + case(52): return Date52; - case (53): + case(53): return Date53; - case (54): + case(54): return Date54; - case (55): + case(55): return Date55; - case (56): + case(56): return Date56; - case (57): + case(57): return Date57; - case (58): + case(58): return Date58; - case (59): + case(59): return Date59; - case (60): + case(60): return Date60; - case (61): + case(61): return Date61; - case (62): + case(62): return Date62; - case (63): + case(63): return Date63; - case (64): + case(64): return Date64; - case (65): + case(65): return Date65; - case (66): + case(66): return Date66; - case (67): + case(67): return Date67; - case (68): + case(68): return Date68; - case (69): + case(69): return Date69; - case (70): + case(70): return Date70; - case (71): + case(71): return Date71; - case (72): + case(72): return Date72; - case (73): + case(73): return Date73; - case (74): + case(74): return Date74; - case (75): + case(75): return Date75; - case (76): + case(76): return Date76; - case (77): + case(77): return Date77; - case (78): + case(78): return Date78; - case (79): + case(79): return Date79; - case (80): + case(80): return Date80; - case (81): + case(81): return Date81; - case (82): + case(82): return Date82; - case (83): + case(83): return Date83; - case (84): + case(84): return Date84; - case (85): + case(85): return Date85; - case (86): + case(86): return Date86; - case (87): + case(87): return Date87; - case (88): + case(88): return Date88; - case (89): + case(89): return Date89; - case (90): + case(90): return Date90; - case (91): + case(91): return Date91; - case (92): + case(92): return Date92; - case (93): + case(93): return Date93; - case (94): + case(94): return Date94; - case (95): + case(95): return Date95; - case (96): + case(96): return Date96; - case (97): + case(97): return Date97; - case (98): + case(98): return Date98; - case (99): + case(99): return Date99; - case (100): + case(100): return Date100; - case (101): + case(101): return Date101; - case (102): + case(102): return Date102; - case (103): + case(103): return Date103; - case (104): + case(104): return Date104; - case (105): + case(105): return Date105; - case (106): + case(106): return Date106; - case (107): + case(107): return Date107; - case (108): + case(108): return Date108; - case (109): + case(109): return Date109; - case (110): + case(110): return Date110; - case (111): + case(111): return Date111; - case (112): + case(112): return Date112; - case (113): + case(113): return Date113; - case (114): + case(114): return Date114; - case (115): + case(115): return Date115; - case (116): + case(116): return Date116; - case (117): + case(117): return Date117; - case (118): + case(118): return Date118; - case (119): + case(119): return Date119; - case (120): + case(120): return Date120; - case (121): + case(121): return Date121; - case (122): + case(122): return Date122; - case (123): + case(123): return Date123; - case (124): + case(124): return Date124; - case (125): + case(125): return Date125; - case (126): + case(126): return Date126; - case (127): + case(127): return Date127; - case (128): + case(128): return Date128; - case (129): + case(129): return Date129; - case (130): + case(130): return Date130; - case (131): + case(131): return Date131; - case (132): + case(132): return Date132; - case (133): + case(133): return Date133; - case (134): + case(134): return Date134; - case (135): + case(135): return Date135; - case (136): + case(136): return Date136; - case (137): + case(137): return Date137; - case (138): + case(138): return Date138; - case (139): + case(139): return Date139; - case (140): + case(140): return Date140; - case (141): + case(141): return Date141; - case (142): + case(142): return Date142; - case (143): + case(143): return Date143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, Date value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - Date0 = value; - break; - case (1): - Date1 = value; - break; - case (2): - Date2 = value; - break; - case (3): - Date3 = value; - break; - case (4): - Date4 = value; - break; - case (5): - Date5 = value; - break; - case (6): - Date6 = value; - break; - case (7): - Date7 = value; - break; - case (8): - Date8 = value; - break; - case (9): - Date9 = value; - break; - case (10): - Date10 = value; - break; - case (11): - Date11 = value; - break; - case (12): - Date12 = value; - break; - case (13): - Date13 = value; - break; - case (14): - Date14 = value; - break; - case (16): - Date16 = value; - break; - case (17): - Date17 = value; - break; - case (18): - Date18 = value; - break; - case (19): - Date19 = value; - break; - case (20): - Date20 = value; - break; - case (21): - Date21 = value; - break; - case (22): - Date22 = value; - break; - case (23): - Date23 = value; - break; - case (24): - Date24 = value; - break; - case (26): - Date26 = value; - break; - case (28): - Date28 = value; - break; - case (29): - Date29 = value; - break; - case (30): - Date30 = value; - break; - case (31): - Date31 = value; - break; - case (32): - Date32 = value; - break; - case (33): - Date33 = value; - break; - case (35): - Date35 = value; - break; - case (36): - Date36 = value; - break; - case (37): - Date37 = value; - break; - case (38): - Date38 = value; - break; - case (39): - Date39 = value; - break; - case (40): - Date40 = value; - break; - case (41): - Date41 = value; - break; - case (42): - Date42 = value; - break; - case (43): - Date43 = value; - break; - case (44): - Date44 = value; - break; - case (45): - Date45 = value; - break; - case (46): - Date46 = value; - break; - case (47): - Date47 = value; - break; - case (48): - Date48 = value; - break; - case (49): - Date49 = value; - break; - case (50): - Date50 = value; - break; - case (52): - Date52 = value; - break; - case (53): - Date53 = value; - break; - case (54): - Date54 = value; - break; - case (55): - Date55 = value; - break; - case (56): - Date56 = value; - break; - case (57): - Date57 = value; - break; - case (58): - Date58 = value; - break; - case (59): - Date59 = value; - break; - case (60): - Date60 = value; - break; - case (62): - Date62 = value; - break; - case (64): - Date64 = value; - break; - case (65): - Date65 = value; - break; - case (66): - Date66 = value; - break; - case (67): - Date67 = value; - break; - case (68): - Date68 = value; - break; - case (69): - Date69 = value; - break; - case (71): - Date71 = value; - break; - case (72): - Date72 = value; - break; - case (73): - Date73 = value; - break; - case (74): - Date74 = value; - break; - case (75): - Date75 = value; - break; - case (76): - Date76 = value; - break; - case (77): - Date77 = value; - break; - case (78): - Date78 = value; - break; - case (79): - Date79 = value; - break; - case (80): - Date80 = value; - break; - case (81): - Date81 = value; - break; - case (82): - Date82 = value; - break; - case (83): - Date83 = value; - break; - case (84): - Date84 = value; - break; - case (85): - Date85 = value; - break; - case (86): - Date86 = value; - break; - case (88): - Date88 = value; - break; - case (89): - Date89 = value; - break; - case (90): - Date90 = value; - break; - case (91): - Date91 = value; - break; - case (92): - Date92 = value; - break; - case (93): - Date93 = value; - break; - case (94): - Date94 = value; - break; - case (95): - Date95 = value; - break; - case (96): - Date96 = value; - break; - case (98): - Date98 = value; - break; - case (100): - Date100 = value; - break; - case (101): - Date101 = value; - break; - case (102): - Date102 = value; - break; - case (103): - Date103 = value; - break; - case (104): - Date104 = value; - break; - case (105): - Date105 = value; - break; - case (107): - Date107 = value; - break; - case (108): - Date108 = value; - break; - case (109): - Date109 = value; - break; - case (110): - Date110 = value; - break; - case (111): - Date111 = value; - break; - case (112): - Date112 = value; - break; - case (113): - Date113 = value; - break; - case (114): - Date114 = value; - break; - case (115): - Date115 = value; - break; - case (116): - Date116 = value; - break; - case (117): - Date117 = value; - break; - case (118): - Date118 = value; - break; - case (119): - Date119 = value; - break; - case (120): - Date120 = value; - break; - case (121): - Date121 = value; - break; - case (122): - Date122 = value; - break; - case (124): - Date124 = value; - break; - case (125): - Date125 = value; - break; - case (126): - Date126 = value; - break; - case (127): - Date127 = value; - break; - case (128): - Date128 = value; - break; - case (129): - Date129 = value; - break; - case (130): - Date130 = value; - break; - case (131): - Date131 = value; - break; - case (132): - Date132 = value; - break; - case (134): - Date134 = value; - break; - case (136): - Date136 = value; - break; - case (137): - Date137 = value; - break; - case (138): - Date138 = value; - break; - case (139): - Date139 = value; - break; - case (140): - Date140 = value; - break; - case (141): - Date141 = value; - break; - case (143): - Date143 = value; - break; + public boolean set(int index,Date value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + Date0= value; + break; + case(1): + Date1= value; + break; + case(2): + Date2= value; + break; + case(3): + Date3= value; + break; + case(4): + Date4= value; + break; + case(5): + Date5= value; + break; + case(6): + Date6= value; + break; + case(7): + Date7= value; + break; + case(8): + Date8= value; + break; + case(9): + Date9= value; + break; + case(10): + Date10= value; + break; + case(11): + Date11= value; + break; + case(12): + Date12= value; + break; + case(13): + Date13= value; + break; + case(14): + Date14= value; + break; + case(16): + Date16= value; + break; + case(17): + Date17= value; + break; + case(18): + Date18= value; + break; + case(19): + Date19= value; + break; + case(20): + Date20= value; + break; + case(21): + Date21= value; + break; + case(22): + Date22= value; + break; + case(23): + Date23= value; + break; + case(24): + Date24= value; + break; + case(26): + Date26= value; + break; + case(28): + Date28= value; + break; + case(29): + Date29= value; + break; + case(30): + Date30= value; + break; + case(31): + Date31= value; + break; + case(32): + Date32= value; + break; + case(33): + Date33= value; + break; + case(35): + Date35= value; + break; + case(36): + Date36= value; + break; + case(37): + Date37= value; + break; + case(38): + Date38= value; + break; + case(39): + Date39= value; + break; + case(40): + Date40= value; + break; + case(41): + Date41= value; + break; + case(42): + Date42= value; + break; + case(43): + Date43= value; + break; + case(44): + Date44= value; + break; + case(45): + Date45= value; + break; + case(46): + Date46= value; + break; + case(47): + Date47= value; + break; + case(48): + Date48= value; + break; + case(49): + Date49= value; + break; + case(50): + Date50= value; + break; + case(52): + Date52= value; + break; + case(53): + Date53= value; + break; + case(54): + Date54= value; + break; + case(55): + Date55= value; + break; + case(56): + Date56= value; + break; + case(57): + Date57= value; + break; + case(58): + Date58= value; + break; + case(59): + Date59= value; + break; + case(60): + Date60= value; + break; + case(62): + Date62= value; + break; + case(64): + Date64= value; + break; + case(65): + Date65= value; + break; + case(66): + Date66= value; + break; + case(67): + Date67= value; + break; + case(68): + Date68= value; + break; + case(69): + Date69= value; + break; + case(71): + Date71= value; + break; + case(72): + Date72= value; + break; + case(73): + Date73= value; + break; + case(74): + Date74= value; + break; + case(75): + Date75= value; + break; + case(76): + Date76= value; + break; + case(77): + Date77= value; + break; + case(78): + Date78= value; + break; + case(79): + Date79= value; + break; + case(80): + Date80= value; + break; + case(81): + Date81= value; + break; + case(82): + Date82= value; + break; + case(83): + Date83= value; + break; + case(84): + Date84= value; + break; + case(85): + Date85= value; + break; + case(86): + Date86= value; + break; + case(88): + Date88= value; + break; + case(89): + Date89= value; + break; + case(90): + Date90= value; + break; + case(91): + Date91= value; + break; + case(92): + Date92= value; + break; + case(93): + Date93= value; + break; + case(94): + Date94= value; + break; + case(95): + Date95= value; + break; + case(96): + Date96= value; + break; + case(98): + Date98= value; + break; + case(100): + Date100= value; + break; + case(101): + Date101= value; + break; + case(102): + Date102= value; + break; + case(103): + Date103= value; + break; + case(104): + Date104= value; + break; + case(105): + Date105= value; + break; + case(107): + Date107= value; + break; + case(108): + Date108= value; + break; + case(109): + Date109= value; + break; + case(110): + Date110= value; + break; + case(111): + Date111= value; + break; + case(112): + Date112= value; + break; + case(113): + Date113= value; + break; + case(114): + Date114= value; + break; + case(115): + Date115= value; + break; + case(116): + Date116= value; + break; + case(117): + Date117= value; + break; + case(118): + Date118= value; + break; + case(119): + Date119= value; + break; + case(120): + Date120= value; + break; + case(121): + Date121= value; + break; + case(122): + Date122= value; + break; + case(124): + Date124= value; + break; + case(125): + Date125= value; + break; + case(126): + Date126= value; + break; + case(127): + Date127= value; + break; + case(128): + Date128= value; + break; + case(129): + Date129= value; + break; + case(130): + Date130= value; + break; + case(131): + Date131= value; + break; + case(132): + Date132= value; + break; + case(134): + Date134= value; + break; + case(136): + Date136= value; + break; + case(137): + Date137= value; + break; + case(138): + Date138= value; + break; + case(139): + Date139= value; + break; + case(140): + Date140= value; + break; + case(141): + Date141= value; + break; + case(143): + Date143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfDouble.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfDouble.java index db212a761..5662002d5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfDouble.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfDouble.java @@ -5,21 +5,21 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -public class FieldsOfDouble { +public class FieldsOfDouble { public int identifier; private Double Double0; private Double Double1; @@ -36,7 +36,7 @@ public class FieldsOfDouble { private transient Double Double12; private transient Double Double13; private transient Double Double14; - private final Double Double15 = Double.valueOf((double) 5); + private final Double Double15 = Double.valueOf((double)5); private volatile Double Double16; private volatile Double Double17; private volatile Double Double18; @@ -46,16 +46,16 @@ public class FieldsOfDouble { private volatile Double Double22; private volatile Double Double23; private static transient Double Double24; - private static final Double Double25 = Double.valueOf((double) 5); + private static final Double Double25 = Double.valueOf((double)5); private static volatile Double Double26; - private final transient Double Double27 = Double.valueOf((double) 5); + private transient final Double Double27 = Double.valueOf((double)5); private transient volatile Double Double28; private transient volatile Double Double29; private transient volatile Double Double30; private transient volatile Double Double31; private transient volatile Double Double32; private transient volatile Double Double33; - private static final transient Double Double34 = Double.valueOf((double) 5); + private static transient final Double Double34 = Double.valueOf((double)5); private static transient volatile Double Double35; public Double Double36; public Double Double37; @@ -72,7 +72,7 @@ public class FieldsOfDouble { public transient Double Double48; public transient Double Double49; public transient Double Double50; - public final Double Double51 = Double.valueOf((double) 5); + public final Double Double51 = Double.valueOf((double)5); public volatile Double Double52; public volatile Double Double53; public volatile Double Double54; @@ -82,16 +82,16 @@ public class FieldsOfDouble { public volatile Double Double58; public volatile Double Double59; public static transient Double Double60; - public static final Double Double61 = Double.valueOf((double) 5); + public static final Double Double61 = Double.valueOf((double)5); public static volatile Double Double62; - public final transient Double Double63 = Double.valueOf((double) 5); + public transient final Double Double63 = Double.valueOf((double)5); public transient volatile Double Double64; public transient volatile Double Double65; public transient volatile Double Double66; public transient volatile Double Double67; public transient volatile Double Double68; public transient volatile Double Double69; - public static final transient Double Double70 = Double.valueOf((double) 5); + public static transient final Double Double70 = Double.valueOf((double)5); public static transient volatile Double Double71; protected Double Double72; protected Double Double73; @@ -108,7 +108,7 @@ public class FieldsOfDouble { protected transient Double Double84; protected transient Double Double85; protected transient Double Double86; - protected final Double Double87 = Double.valueOf((double) 5); + protected final Double Double87 = Double.valueOf((double)5); protected volatile Double Double88; protected volatile Double Double89; protected volatile Double Double90; @@ -118,16 +118,16 @@ public class FieldsOfDouble { protected volatile Double Double94; protected volatile Double Double95; protected static transient Double Double96; - protected static final Double Double97 = Double.valueOf((double) 5); + protected static final Double Double97 = Double.valueOf((double)5); protected static volatile Double Double98; - protected final transient Double Double99 = Double.valueOf((double) 5); + protected transient final Double Double99 = Double.valueOf((double)5); protected transient volatile Double Double100; protected transient volatile Double Double101; protected transient volatile Double Double102; protected transient volatile Double Double103; protected transient volatile Double Double104; protected transient volatile Double Double105; - protected static final transient Double Double106 = Double.valueOf((double) 5); + protected static transient final Double Double106 = Double.valueOf((double)5); protected static transient volatile Double Double107; Double Double108; Double Double109; @@ -144,7 +144,7 @@ public class FieldsOfDouble { transient Double Double120; transient Double Double121; transient Double Double122; - final Double Double123 = Double.valueOf((double) 5); + final Double Double123 = Double.valueOf((double)5); volatile Double Double124; volatile Double Double125; volatile Double Double126; @@ -154,938 +154,937 @@ public class FieldsOfDouble { volatile Double Double130; volatile Double Double131; static transient Double Double132; - static final Double Double133 = Double.valueOf((double) 5); + static final Double Double133 = Double.valueOf((double)5); static volatile Double Double134; - final transient Double Double135 = Double.valueOf((double) 5); + transient final Double Double135 = Double.valueOf((double)5); transient volatile Double Double136; transient volatile Double Double137; transient volatile Double Double138; transient volatile Double Double139; transient volatile Double Double140; transient volatile Double Double141; - static final transient Double Double142 = Double.valueOf((double) 5); + static transient final Double Double142 = Double.valueOf((double)5); static transient volatile Double Double143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private Double Double0", - "embedded= true private Double Double1", - "embedded= false private Double Double2", - "persistence-modifier= none private Double Double3", - "persistence-modifier= persistent private Double Double4", - "persistence-modifier= persistent embedded= true private Double Double5", - "persistence-modifier= persistent embedded= false private Double Double6", - "persistence-modifier= transactional private Double Double7", - "private static Double Double8", - "private transient Double Double9", - "persistence-modifier= none private transient Double Double10", - "persistence-modifier= persistent private transient Double Double11", - "persistence-modifier= persistent embedded= true private transient Double Double12", - "persistence-modifier= persistent embedded= false private transient Double Double13", - "persistence-modifier= transactional private transient Double Double14", - "private final Double Double15", - "private volatile Double Double16", - "embedded= true private volatile Double Double17", - "embedded= false private volatile Double Double18", - "persistence-modifier= none private volatile Double Double19", - "persistence-modifier= persistent private volatile Double Double20", - "persistence-modifier= persistent embedded= true private volatile Double Double21", - "persistence-modifier= persistent embedded= false private volatile Double Double22", - "persistence-modifier= transactional private volatile Double Double23", - "private static transient Double Double24", - "private static final Double Double25", - "private static volatile Double Double26", - "private transient final Double Double27", - "private transient volatile Double Double28", - "persistence-modifier= none private transient volatile Double Double29", - "persistence-modifier= persistent private transient volatile Double Double30", - "persistence-modifier= persistent embedded= true private transient volatile Double Double31", - "persistence-modifier= persistent embedded= false private transient volatile Double Double32", - "persistence-modifier= transactional private transient volatile Double Double33", - "private static transient final Double Double34", - "private static transient volatile Double Double35", - "public Double Double36", - "embedded= true public Double Double37", - "embedded= false public Double Double38", - "persistence-modifier= none public Double Double39", - "persistence-modifier= persistent public Double Double40", - "persistence-modifier= persistent embedded= true public Double Double41", - "persistence-modifier= persistent embedded= false public Double Double42", - "persistence-modifier= transactional public Double Double43", - "public static Double Double44", - "public transient Double Double45", - "persistence-modifier= none public transient Double Double46", - "persistence-modifier= persistent public transient Double Double47", - "persistence-modifier= persistent embedded= true public transient Double Double48", - "persistence-modifier= persistent embedded= false public transient Double Double49", - "persistence-modifier= transactional public transient Double Double50", - "public final Double Double51", - "public volatile Double Double52", - "embedded= true public volatile Double Double53", - "embedded= false public volatile Double Double54", - "persistence-modifier= none public volatile Double Double55", - "persistence-modifier= persistent public volatile Double Double56", - "persistence-modifier= persistent embedded= true public volatile Double Double57", - "persistence-modifier= persistent embedded= false public volatile Double Double58", - "persistence-modifier= transactional public volatile Double Double59", - "public static transient Double Double60", - "public static final Double Double61", - "public static volatile Double Double62", - "public transient final Double Double63", - "public transient volatile Double Double64", - "persistence-modifier= none public transient volatile Double Double65", - "persistence-modifier= persistent public transient volatile Double Double66", - "persistence-modifier= persistent embedded= true public transient volatile Double Double67", - "persistence-modifier= persistent embedded= false public transient volatile Double Double68", - "persistence-modifier= transactional public transient volatile Double Double69", - "public static transient final Double Double70", - "public static transient volatile Double Double71", - "protected Double Double72", - "embedded= true protected Double Double73", - "embedded= false protected Double Double74", - "persistence-modifier= none protected Double Double75", - "persistence-modifier= persistent protected Double Double76", - "persistence-modifier= persistent embedded= true protected Double Double77", - "persistence-modifier= persistent embedded= false protected Double Double78", - "persistence-modifier= transactional protected Double Double79", - "protected static Double Double80", - "protected transient Double Double81", - "persistence-modifier= none protected transient Double Double82", - "persistence-modifier= persistent protected transient Double Double83", - "persistence-modifier= persistent embedded= true protected transient Double Double84", - "persistence-modifier= persistent embedded= false protected transient Double Double85", - "persistence-modifier= transactional protected transient Double Double86", - "protected final Double Double87", - "protected volatile Double Double88", - "embedded= true protected volatile Double Double89", - "embedded= false protected volatile Double Double90", - "persistence-modifier= none protected volatile Double Double91", - "persistence-modifier= persistent protected volatile Double Double92", - "persistence-modifier= persistent embedded= true protected volatile Double Double93", - "persistence-modifier= persistent embedded= false protected volatile Double Double94", - "persistence-modifier= transactional protected volatile Double Double95", - "protected static transient Double Double96", - "protected static final Double Double97", - "protected static volatile Double Double98", - "protected transient final Double Double99", - "protected transient volatile Double Double100", - "persistence-modifier= none protected transient volatile Double Double101", - "persistence-modifier= persistent protected transient volatile Double Double102", - "persistence-modifier= persistent embedded= true protected transient volatile Double Double103", - "persistence-modifier= persistent embedded= false protected transient volatile Double Double104", - "persistence-modifier= transactional protected transient volatile Double Double105", - "protected static transient final Double Double106", - "protected static transient volatile Double Double107", - "Double Double108", - "embedded= true Double Double109", - "embedded= false Double Double110", - "persistence-modifier= none Double Double111", - "persistence-modifier= persistent Double Double112", - "persistence-modifier= persistent embedded= true Double Double113", - "persistence-modifier= persistent embedded= false Double Double114", - "persistence-modifier= transactional Double Double115", - "static Double Double116", - "transient Double Double117", - "persistence-modifier= none transient Double Double118", - "persistence-modifier= persistent transient Double Double119", - "persistence-modifier= persistent embedded= true transient Double Double120", - "persistence-modifier= persistent embedded= false transient Double Double121", - "persistence-modifier= transactional transient Double Double122", - "final Double Double123", - "volatile Double Double124", - "embedded= true volatile Double Double125", - "embedded= false volatile Double Double126", - "persistence-modifier= none volatile Double Double127", - "persistence-modifier= persistent volatile Double Double128", - "persistence-modifier= persistent embedded= true volatile Double Double129", - "persistence-modifier= persistent embedded= false volatile Double Double130", - "persistence-modifier= transactional volatile Double Double131", - "static transient Double Double132", - "static final Double Double133", - "static volatile Double Double134", - "transient final Double Double135", - "transient volatile Double Double136", - "persistence-modifier= none transient volatile Double Double137", - "persistence-modifier= persistent transient volatile Double Double138", - "persistence-modifier= persistent embedded= true transient volatile Double Double139", - "persistence-modifier= persistent embedded= false transient volatile Double Double140", - "persistence-modifier= transactional transient volatile Double Double141", - "static transient final Double Double142", - "static transient volatile Double Double143" + public static final String [] fieldSpecs = { + "private Double Double0", + "embedded= true private Double Double1", + "embedded= false private Double Double2", + "persistence-modifier= none private Double Double3", + "persistence-modifier= persistent private Double Double4", + "persistence-modifier= persistent embedded= true private Double Double5", + "persistence-modifier= persistent embedded= false private Double Double6", + "persistence-modifier= transactional private Double Double7", + "private static Double Double8", + "private transient Double Double9", + "persistence-modifier= none private transient Double Double10", + "persistence-modifier= persistent private transient Double Double11", + "persistence-modifier= persistent embedded= true private transient Double Double12", + "persistence-modifier= persistent embedded= false private transient Double Double13", + "persistence-modifier= transactional private transient Double Double14", + "private final Double Double15", + "private volatile Double Double16", + "embedded= true private volatile Double Double17", + "embedded= false private volatile Double Double18", + "persistence-modifier= none private volatile Double Double19", + "persistence-modifier= persistent private volatile Double Double20", + "persistence-modifier= persistent embedded= true private volatile Double Double21", + "persistence-modifier= persistent embedded= false private volatile Double Double22", + "persistence-modifier= transactional private volatile Double Double23", + "private static transient Double Double24", + "private static final Double Double25", + "private static volatile Double Double26", + "private transient final Double Double27", + "private transient volatile Double Double28", + "persistence-modifier= none private transient volatile Double Double29", + "persistence-modifier= persistent private transient volatile Double Double30", + "persistence-modifier= persistent embedded= true private transient volatile Double Double31", + "persistence-modifier= persistent embedded= false private transient volatile Double Double32", + "persistence-modifier= transactional private transient volatile Double Double33", + "private static transient final Double Double34", + "private static transient volatile Double Double35", + "public Double Double36", + "embedded= true public Double Double37", + "embedded= false public Double Double38", + "persistence-modifier= none public Double Double39", + "persistence-modifier= persistent public Double Double40", + "persistence-modifier= persistent embedded= true public Double Double41", + "persistence-modifier= persistent embedded= false public Double Double42", + "persistence-modifier= transactional public Double Double43", + "public static Double Double44", + "public transient Double Double45", + "persistence-modifier= none public transient Double Double46", + "persistence-modifier= persistent public transient Double Double47", + "persistence-modifier= persistent embedded= true public transient Double Double48", + "persistence-modifier= persistent embedded= false public transient Double Double49", + "persistence-modifier= transactional public transient Double Double50", + "public final Double Double51", + "public volatile Double Double52", + "embedded= true public volatile Double Double53", + "embedded= false public volatile Double Double54", + "persistence-modifier= none public volatile Double Double55", + "persistence-modifier= persistent public volatile Double Double56", + "persistence-modifier= persistent embedded= true public volatile Double Double57", + "persistence-modifier= persistent embedded= false public volatile Double Double58", + "persistence-modifier= transactional public volatile Double Double59", + "public static transient Double Double60", + "public static final Double Double61", + "public static volatile Double Double62", + "public transient final Double Double63", + "public transient volatile Double Double64", + "persistence-modifier= none public transient volatile Double Double65", + "persistence-modifier= persistent public transient volatile Double Double66", + "persistence-modifier= persistent embedded= true public transient volatile Double Double67", + "persistence-modifier= persistent embedded= false public transient volatile Double Double68", + "persistence-modifier= transactional public transient volatile Double Double69", + "public static transient final Double Double70", + "public static transient volatile Double Double71", + "protected Double Double72", + "embedded= true protected Double Double73", + "embedded= false protected Double Double74", + "persistence-modifier= none protected Double Double75", + "persistence-modifier= persistent protected Double Double76", + "persistence-modifier= persistent embedded= true protected Double Double77", + "persistence-modifier= persistent embedded= false protected Double Double78", + "persistence-modifier= transactional protected Double Double79", + "protected static Double Double80", + "protected transient Double Double81", + "persistence-modifier= none protected transient Double Double82", + "persistence-modifier= persistent protected transient Double Double83", + "persistence-modifier= persistent embedded= true protected transient Double Double84", + "persistence-modifier= persistent embedded= false protected transient Double Double85", + "persistence-modifier= transactional protected transient Double Double86", + "protected final Double Double87", + "protected volatile Double Double88", + "embedded= true protected volatile Double Double89", + "embedded= false protected volatile Double Double90", + "persistence-modifier= none protected volatile Double Double91", + "persistence-modifier= persistent protected volatile Double Double92", + "persistence-modifier= persistent embedded= true protected volatile Double Double93", + "persistence-modifier= persistent embedded= false protected volatile Double Double94", + "persistence-modifier= transactional protected volatile Double Double95", + "protected static transient Double Double96", + "protected static final Double Double97", + "protected static volatile Double Double98", + "protected transient final Double Double99", + "protected transient volatile Double Double100", + "persistence-modifier= none protected transient volatile Double Double101", + "persistence-modifier= persistent protected transient volatile Double Double102", + "persistence-modifier= persistent embedded= true protected transient volatile Double Double103", + "persistence-modifier= persistent embedded= false protected transient volatile Double Double104", + "persistence-modifier= transactional protected transient volatile Double Double105", + "protected static transient final Double Double106", + "protected static transient volatile Double Double107", + "Double Double108", + "embedded= true Double Double109", + "embedded= false Double Double110", + "persistence-modifier= none Double Double111", + "persistence-modifier= persistent Double Double112", + "persistence-modifier= persistent embedded= true Double Double113", + "persistence-modifier= persistent embedded= false Double Double114", + "persistence-modifier= transactional Double Double115", + "static Double Double116", + "transient Double Double117", + "persistence-modifier= none transient Double Double118", + "persistence-modifier= persistent transient Double Double119", + "persistence-modifier= persistent embedded= true transient Double Double120", + "persistence-modifier= persistent embedded= false transient Double Double121", + "persistence-modifier= transactional transient Double Double122", + "final Double Double123", + "volatile Double Double124", + "embedded= true volatile Double Double125", + "embedded= false volatile Double Double126", + "persistence-modifier= none volatile Double Double127", + "persistence-modifier= persistent volatile Double Double128", + "persistence-modifier= persistent embedded= true volatile Double Double129", + "persistence-modifier= persistent embedded= false volatile Double Double130", + "persistence-modifier= transactional volatile Double Double131", + "static transient Double Double132", + "static final Double Double133", + "static volatile Double Double134", + "transient final Double Double135", + "transient volatile Double Double136", + "persistence-modifier= none transient volatile Double Double137", + "persistence-modifier= persistent transient volatile Double Double138", + "persistence-modifier= persistent embedded= true transient volatile Double Double139", + "persistence-modifier= persistent embedded= false transient volatile Double Double140", + "persistence-modifier= transactional transient volatile Double Double141", + "static transient final Double Double142", + "static transient volatile Double Double143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public Double get(int index) { - switch (index) { - case (0): + public Double get(int index) + { + switch (index) + { + case(0): return Double0; - case (1): + case(1): return Double1; - case (2): + case(2): return Double2; - case (3): + case(3): return Double3; - case (4): + case(4): return Double4; - case (5): + case(5): return Double5; - case (6): + case(6): return Double6; - case (7): + case(7): return Double7; - case (8): + case(8): return Double8; - case (9): + case(9): return Double9; - case (10): + case(10): return Double10; - case (11): + case(11): return Double11; - case (12): + case(12): return Double12; - case (13): + case(13): return Double13; - case (14): + case(14): return Double14; - case (15): + case(15): return Double15; - case (16): + case(16): return Double16; - case (17): + case(17): return Double17; - case (18): + case(18): return Double18; - case (19): + case(19): return Double19; - case (20): + case(20): return Double20; - case (21): + case(21): return Double21; - case (22): + case(22): return Double22; - case (23): + case(23): return Double23; - case (24): + case(24): return Double24; - case (25): + case(25): return Double25; - case (26): + case(26): return Double26; - case (27): + case(27): return Double27; - case (28): + case(28): return Double28; - case (29): + case(29): return Double29; - case (30): + case(30): return Double30; - case (31): + case(31): return Double31; - case (32): + case(32): return Double32; - case (33): + case(33): return Double33; - case (34): + case(34): return Double34; - case (35): + case(35): return Double35; - case (36): + case(36): return Double36; - case (37): + case(37): return Double37; - case (38): + case(38): return Double38; - case (39): + case(39): return Double39; - case (40): + case(40): return Double40; - case (41): + case(41): return Double41; - case (42): + case(42): return Double42; - case (43): + case(43): return Double43; - case (44): + case(44): return Double44; - case (45): + case(45): return Double45; - case (46): + case(46): return Double46; - case (47): + case(47): return Double47; - case (48): + case(48): return Double48; - case (49): + case(49): return Double49; - case (50): + case(50): return Double50; - case (51): + case(51): return Double51; - case (52): + case(52): return Double52; - case (53): + case(53): return Double53; - case (54): + case(54): return Double54; - case (55): + case(55): return Double55; - case (56): + case(56): return Double56; - case (57): + case(57): return Double57; - case (58): + case(58): return Double58; - case (59): + case(59): return Double59; - case (60): + case(60): return Double60; - case (61): + case(61): return Double61; - case (62): + case(62): return Double62; - case (63): + case(63): return Double63; - case (64): + case(64): return Double64; - case (65): + case(65): return Double65; - case (66): + case(66): return Double66; - case (67): + case(67): return Double67; - case (68): + case(68): return Double68; - case (69): + case(69): return Double69; - case (70): + case(70): return Double70; - case (71): + case(71): return Double71; - case (72): + case(72): return Double72; - case (73): + case(73): return Double73; - case (74): + case(74): return Double74; - case (75): + case(75): return Double75; - case (76): + case(76): return Double76; - case (77): + case(77): return Double77; - case (78): + case(78): return Double78; - case (79): + case(79): return Double79; - case (80): + case(80): return Double80; - case (81): + case(81): return Double81; - case (82): + case(82): return Double82; - case (83): + case(83): return Double83; - case (84): + case(84): return Double84; - case (85): + case(85): return Double85; - case (86): + case(86): return Double86; - case (87): + case(87): return Double87; - case (88): + case(88): return Double88; - case (89): + case(89): return Double89; - case (90): + case(90): return Double90; - case (91): + case(91): return Double91; - case (92): + case(92): return Double92; - case (93): + case(93): return Double93; - case (94): + case(94): return Double94; - case (95): + case(95): return Double95; - case (96): + case(96): return Double96; - case (97): + case(97): return Double97; - case (98): + case(98): return Double98; - case (99): + case(99): return Double99; - case (100): + case(100): return Double100; - case (101): + case(101): return Double101; - case (102): + case(102): return Double102; - case (103): + case(103): return Double103; - case (104): + case(104): return Double104; - case (105): + case(105): return Double105; - case (106): + case(106): return Double106; - case (107): + case(107): return Double107; - case (108): + case(108): return Double108; - case (109): + case(109): return Double109; - case (110): + case(110): return Double110; - case (111): + case(111): return Double111; - case (112): + case(112): return Double112; - case (113): + case(113): return Double113; - case (114): + case(114): return Double114; - case (115): + case(115): return Double115; - case (116): + case(116): return Double116; - case (117): + case(117): return Double117; - case (118): + case(118): return Double118; - case (119): + case(119): return Double119; - case (120): + case(120): return Double120; - case (121): + case(121): return Double121; - case (122): + case(122): return Double122; - case (123): + case(123): return Double123; - case (124): + case(124): return Double124; - case (125): + case(125): return Double125; - case (126): + case(126): return Double126; - case (127): + case(127): return Double127; - case (128): + case(128): return Double128; - case (129): + case(129): return Double129; - case (130): + case(130): return Double130; - case (131): + case(131): return Double131; - case (132): + case(132): return Double132; - case (133): + case(133): return Double133; - case (134): + case(134): return Double134; - case (135): + case(135): return Double135; - case (136): + case(136): return Double136; - case (137): + case(137): return Double137; - case (138): + case(138): return Double138; - case (139): + case(139): return Double139; - case (140): + case(140): return Double140; - case (141): + case(141): return Double141; - case (142): + case(142): return Double142; - case (143): + case(143): return Double143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, Double value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - Double0 = value; - break; - case (1): - Double1 = value; - break; - case (2): - Double2 = value; - break; - case (3): - Double3 = value; - break; - case (4): - Double4 = value; - break; - case (5): - Double5 = value; - break; - case (6): - Double6 = value; - break; - case (7): - Double7 = value; - break; - case (8): - Double8 = value; - break; - case (9): - Double9 = value; - break; - case (10): - Double10 = value; - break; - case (11): - Double11 = value; - break; - case (12): - Double12 = value; - break; - case (13): - Double13 = value; - break; - case (14): - Double14 = value; - break; - case (16): - Double16 = value; - break; - case (17): - Double17 = value; - break; - case (18): - Double18 = value; - break; - case (19): - Double19 = value; - break; - case (20): - Double20 = value; - break; - case (21): - Double21 = value; - break; - case (22): - Double22 = value; - break; - case (23): - Double23 = value; - break; - case (24): - Double24 = value; - break; - case (26): - Double26 = value; - break; - case (28): - Double28 = value; - break; - case (29): - Double29 = value; - break; - case (30): - Double30 = value; - break; - case (31): - Double31 = value; - break; - case (32): - Double32 = value; - break; - case (33): - Double33 = value; - break; - case (35): - Double35 = value; - break; - case (36): - Double36 = value; - break; - case (37): - Double37 = value; - break; - case (38): - Double38 = value; - break; - case (39): - Double39 = value; - break; - case (40): - Double40 = value; - break; - case (41): - Double41 = value; - break; - case (42): - Double42 = value; - break; - case (43): - Double43 = value; - break; - case (44): - Double44 = value; - break; - case (45): - Double45 = value; - break; - case (46): - Double46 = value; - break; - case (47): - Double47 = value; - break; - case (48): - Double48 = value; - break; - case (49): - Double49 = value; - break; - case (50): - Double50 = value; - break; - case (52): - Double52 = value; - break; - case (53): - Double53 = value; - break; - case (54): - Double54 = value; - break; - case (55): - Double55 = value; - break; - case (56): - Double56 = value; - break; - case (57): - Double57 = value; - break; - case (58): - Double58 = value; - break; - case (59): - Double59 = value; - break; - case (60): - Double60 = value; - break; - case (62): - Double62 = value; - break; - case (64): - Double64 = value; - break; - case (65): - Double65 = value; - break; - case (66): - Double66 = value; - break; - case (67): - Double67 = value; - break; - case (68): - Double68 = value; - break; - case (69): - Double69 = value; - break; - case (71): - Double71 = value; - break; - case (72): - Double72 = value; - break; - case (73): - Double73 = value; - break; - case (74): - Double74 = value; - break; - case (75): - Double75 = value; - break; - case (76): - Double76 = value; - break; - case (77): - Double77 = value; - break; - case (78): - Double78 = value; - break; - case (79): - Double79 = value; - break; - case (80): - Double80 = value; - break; - case (81): - Double81 = value; - break; - case (82): - Double82 = value; - break; - case (83): - Double83 = value; - break; - case (84): - Double84 = value; - break; - case (85): - Double85 = value; - break; - case (86): - Double86 = value; - break; - case (88): - Double88 = value; - break; - case (89): - Double89 = value; - break; - case (90): - Double90 = value; - break; - case (91): - Double91 = value; - break; - case (92): - Double92 = value; - break; - case (93): - Double93 = value; - break; - case (94): - Double94 = value; - break; - case (95): - Double95 = value; - break; - case (96): - Double96 = value; - break; - case (98): - Double98 = value; - break; - case (100): - Double100 = value; - break; - case (101): - Double101 = value; - break; - case (102): - Double102 = value; - break; - case (103): - Double103 = value; - break; - case (104): - Double104 = value; - break; - case (105): - Double105 = value; - break; - case (107): - Double107 = value; - break; - case (108): - Double108 = value; - break; - case (109): - Double109 = value; - break; - case (110): - Double110 = value; - break; - case (111): - Double111 = value; - break; - case (112): - Double112 = value; - break; - case (113): - Double113 = value; - break; - case (114): - Double114 = value; - break; - case (115): - Double115 = value; - break; - case (116): - Double116 = value; - break; - case (117): - Double117 = value; - break; - case (118): - Double118 = value; - break; - case (119): - Double119 = value; - break; - case (120): - Double120 = value; - break; - case (121): - Double121 = value; - break; - case (122): - Double122 = value; - break; - case (124): - Double124 = value; - break; - case (125): - Double125 = value; - break; - case (126): - Double126 = value; - break; - case (127): - Double127 = value; - break; - case (128): - Double128 = value; - break; - case (129): - Double129 = value; - break; - case (130): - Double130 = value; - break; - case (131): - Double131 = value; - break; - case (132): - Double132 = value; - break; - case (134): - Double134 = value; - break; - case (136): - Double136 = value; - break; - case (137): - Double137 = value; - break; - case (138): - Double138 = value; - break; - case (139): - Double139 = value; - break; - case (140): - Double140 = value; - break; - case (141): - Double141 = value; - break; - case (143): - Double143 = value; - break; + public boolean set(int index,Double value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + Double0= value; + break; + case(1): + Double1= value; + break; + case(2): + Double2= value; + break; + case(3): + Double3= value; + break; + case(4): + Double4= value; + break; + case(5): + Double5= value; + break; + case(6): + Double6= value; + break; + case(7): + Double7= value; + break; + case(8): + Double8= value; + break; + case(9): + Double9= value; + break; + case(10): + Double10= value; + break; + case(11): + Double11= value; + break; + case(12): + Double12= value; + break; + case(13): + Double13= value; + break; + case(14): + Double14= value; + break; + case(16): + Double16= value; + break; + case(17): + Double17= value; + break; + case(18): + Double18= value; + break; + case(19): + Double19= value; + break; + case(20): + Double20= value; + break; + case(21): + Double21= value; + break; + case(22): + Double22= value; + break; + case(23): + Double23= value; + break; + case(24): + Double24= value; + break; + case(26): + Double26= value; + break; + case(28): + Double28= value; + break; + case(29): + Double29= value; + break; + case(30): + Double30= value; + break; + case(31): + Double31= value; + break; + case(32): + Double32= value; + break; + case(33): + Double33= value; + break; + case(35): + Double35= value; + break; + case(36): + Double36= value; + break; + case(37): + Double37= value; + break; + case(38): + Double38= value; + break; + case(39): + Double39= value; + break; + case(40): + Double40= value; + break; + case(41): + Double41= value; + break; + case(42): + Double42= value; + break; + case(43): + Double43= value; + break; + case(44): + Double44= value; + break; + case(45): + Double45= value; + break; + case(46): + Double46= value; + break; + case(47): + Double47= value; + break; + case(48): + Double48= value; + break; + case(49): + Double49= value; + break; + case(50): + Double50= value; + break; + case(52): + Double52= value; + break; + case(53): + Double53= value; + break; + case(54): + Double54= value; + break; + case(55): + Double55= value; + break; + case(56): + Double56= value; + break; + case(57): + Double57= value; + break; + case(58): + Double58= value; + break; + case(59): + Double59= value; + break; + case(60): + Double60= value; + break; + case(62): + Double62= value; + break; + case(64): + Double64= value; + break; + case(65): + Double65= value; + break; + case(66): + Double66= value; + break; + case(67): + Double67= value; + break; + case(68): + Double68= value; + break; + case(69): + Double69= value; + break; + case(71): + Double71= value; + break; + case(72): + Double72= value; + break; + case(73): + Double73= value; + break; + case(74): + Double74= value; + break; + case(75): + Double75= value; + break; + case(76): + Double76= value; + break; + case(77): + Double77= value; + break; + case(78): + Double78= value; + break; + case(79): + Double79= value; + break; + case(80): + Double80= value; + break; + case(81): + Double81= value; + break; + case(82): + Double82= value; + break; + case(83): + Double83= value; + break; + case(84): + Double84= value; + break; + case(85): + Double85= value; + break; + case(86): + Double86= value; + break; + case(88): + Double88= value; + break; + case(89): + Double89= value; + break; + case(90): + Double90= value; + break; + case(91): + Double91= value; + break; + case(92): + Double92= value; + break; + case(93): + Double93= value; + break; + case(94): + Double94= value; + break; + case(95): + Double95= value; + break; + case(96): + Double96= value; + break; + case(98): + Double98= value; + break; + case(100): + Double100= value; + break; + case(101): + Double101= value; + break; + case(102): + Double102= value; + break; + case(103): + Double103= value; + break; + case(104): + Double104= value; + break; + case(105): + Double105= value; + break; + case(107): + Double107= value; + break; + case(108): + Double108= value; + break; + case(109): + Double109= value; + break; + case(110): + Double110= value; + break; + case(111): + Double111= value; + break; + case(112): + Double112= value; + break; + case(113): + Double113= value; + break; + case(114): + Double114= value; + break; + case(115): + Double115= value; + break; + case(116): + Double116= value; + break; + case(117): + Double117= value; + break; + case(118): + Double118= value; + break; + case(119): + Double119= value; + break; + case(120): + Double120= value; + break; + case(121): + Double121= value; + break; + case(122): + Double122= value; + break; + case(124): + Double124= value; + break; + case(125): + Double125= value; + break; + case(126): + Double126= value; + break; + case(127): + Double127= value; + break; + case(128): + Double128= value; + break; + case(129): + Double129= value; + break; + case(130): + Double130= value; + break; + case(131): + Double131= value; + break; + case(132): + Double132= value; + break; + case(134): + Double134= value; + break; + case(136): + Double136= value; + break; + case(137): + Double137= value; + break; + case(138): + Double138= value; + break; + case(139): + Double139= value; + break; + case(140): + Double140= value; + break; + case(141): + Double141= value; + break; + case(143): + Double143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfFloat.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfFloat.java index b9c11f7c3..5b045b01c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfFloat.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfFloat.java @@ -5,21 +5,21 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -public class FieldsOfFloat { +public class FieldsOfFloat { public int identifier; private Float Float0; private Float Float1; @@ -36,7 +36,7 @@ public class FieldsOfFloat { private transient Float Float12; private transient Float Float13; private transient Float Float14; - private final Float Float15 = Float.valueOf((float) 5); + private final Float Float15 = Float.valueOf((float)5); private volatile Float Float16; private volatile Float Float17; private volatile Float Float18; @@ -46,16 +46,16 @@ public class FieldsOfFloat { private volatile Float Float22; private volatile Float Float23; private static transient Float Float24; - private static final Float Float25 = Float.valueOf((float) 5); + private static final Float Float25 = Float.valueOf((float)5); private static volatile Float Float26; - private final transient Float Float27 = Float.valueOf((float) 5); + private transient final Float Float27 = Float.valueOf((float)5); private transient volatile Float Float28; private transient volatile Float Float29; private transient volatile Float Float30; private transient volatile Float Float31; private transient volatile Float Float32; private transient volatile Float Float33; - private static final transient Float Float34 = Float.valueOf((float) 5); + private static transient final Float Float34 = Float.valueOf((float)5); private static transient volatile Float Float35; public Float Float36; public Float Float37; @@ -72,7 +72,7 @@ public class FieldsOfFloat { public transient Float Float48; public transient Float Float49; public transient Float Float50; - public final Float Float51 = Float.valueOf((float) 5); + public final Float Float51 = Float.valueOf((float)5); public volatile Float Float52; public volatile Float Float53; public volatile Float Float54; @@ -82,16 +82,16 @@ public class FieldsOfFloat { public volatile Float Float58; public volatile Float Float59; public static transient Float Float60; - public static final Float Float61 = Float.valueOf((float) 5); + public static final Float Float61 = Float.valueOf((float)5); public static volatile Float Float62; - public final transient Float Float63 = Float.valueOf((float) 5); + public transient final Float Float63 = Float.valueOf((float)5); public transient volatile Float Float64; public transient volatile Float Float65; public transient volatile Float Float66; public transient volatile Float Float67; public transient volatile Float Float68; public transient volatile Float Float69; - public static final transient Float Float70 = Float.valueOf((float) 5); + public static transient final Float Float70 = Float.valueOf((float)5); public static transient volatile Float Float71; protected Float Float72; protected Float Float73; @@ -108,7 +108,7 @@ public class FieldsOfFloat { protected transient Float Float84; protected transient Float Float85; protected transient Float Float86; - protected final Float Float87 = Float.valueOf((float) 5); + protected final Float Float87 = Float.valueOf((float)5); protected volatile Float Float88; protected volatile Float Float89; protected volatile Float Float90; @@ -118,16 +118,16 @@ public class FieldsOfFloat { protected volatile Float Float94; protected volatile Float Float95; protected static transient Float Float96; - protected static final Float Float97 = Float.valueOf((float) 5); + protected static final Float Float97 = Float.valueOf((float)5); protected static volatile Float Float98; - protected final transient Float Float99 = Float.valueOf((float) 5); + protected transient final Float Float99 = Float.valueOf((float)5); protected transient volatile Float Float100; protected transient volatile Float Float101; protected transient volatile Float Float102; protected transient volatile Float Float103; protected transient volatile Float Float104; protected transient volatile Float Float105; - protected static final transient Float Float106 = Float.valueOf((float) 5); + protected static transient final Float Float106 = Float.valueOf((float)5); protected static transient volatile Float Float107; Float Float108; Float Float109; @@ -144,7 +144,7 @@ public class FieldsOfFloat { transient Float Float120; transient Float Float121; transient Float Float122; - final Float Float123 = Float.valueOf((float) 5); + final Float Float123 = Float.valueOf((float)5); volatile Float Float124; volatile Float Float125; volatile Float Float126; @@ -154,938 +154,937 @@ public class FieldsOfFloat { volatile Float Float130; volatile Float Float131; static transient Float Float132; - static final Float Float133 = Float.valueOf((float) 5); + static final Float Float133 = Float.valueOf((float)5); static volatile Float Float134; - final transient Float Float135 = Float.valueOf((float) 5); + transient final Float Float135 = Float.valueOf((float)5); transient volatile Float Float136; transient volatile Float Float137; transient volatile Float Float138; transient volatile Float Float139; transient volatile Float Float140; transient volatile Float Float141; - static final transient Float Float142 = Float.valueOf((float) 5); + static transient final Float Float142 = Float.valueOf((float)5); static transient volatile Float Float143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private Float Float0", - "embedded= true private Float Float1", - "embedded= false private Float Float2", - "persistence-modifier= none private Float Float3", - "persistence-modifier= persistent private Float Float4", - "persistence-modifier= persistent embedded= true private Float Float5", - "persistence-modifier= persistent embedded= false private Float Float6", - "persistence-modifier= transactional private Float Float7", - "private static Float Float8", - "private transient Float Float9", - "persistence-modifier= none private transient Float Float10", - "persistence-modifier= persistent private transient Float Float11", - "persistence-modifier= persistent embedded= true private transient Float Float12", - "persistence-modifier= persistent embedded= false private transient Float Float13", - "persistence-modifier= transactional private transient Float Float14", - "private final Float Float15", - "private volatile Float Float16", - "embedded= true private volatile Float Float17", - "embedded= false private volatile Float Float18", - "persistence-modifier= none private volatile Float Float19", - "persistence-modifier= persistent private volatile Float Float20", - "persistence-modifier= persistent embedded= true private volatile Float Float21", - "persistence-modifier= persistent embedded= false private volatile Float Float22", - "persistence-modifier= transactional private volatile Float Float23", - "private static transient Float Float24", - "private static final Float Float25", - "private static volatile Float Float26", - "private transient final Float Float27", - "private transient volatile Float Float28", - "persistence-modifier= none private transient volatile Float Float29", - "persistence-modifier= persistent private transient volatile Float Float30", - "persistence-modifier= persistent embedded= true private transient volatile Float Float31", - "persistence-modifier= persistent embedded= false private transient volatile Float Float32", - "persistence-modifier= transactional private transient volatile Float Float33", - "private static transient final Float Float34", - "private static transient volatile Float Float35", - "public Float Float36", - "embedded= true public Float Float37", - "embedded= false public Float Float38", - "persistence-modifier= none public Float Float39", - "persistence-modifier= persistent public Float Float40", - "persistence-modifier= persistent embedded= true public Float Float41", - "persistence-modifier= persistent embedded= false public Float Float42", - "persistence-modifier= transactional public Float Float43", - "public static Float Float44", - "public transient Float Float45", - "persistence-modifier= none public transient Float Float46", - "persistence-modifier= persistent public transient Float Float47", - "persistence-modifier= persistent embedded= true public transient Float Float48", - "persistence-modifier= persistent embedded= false public transient Float Float49", - "persistence-modifier= transactional public transient Float Float50", - "public final Float Float51", - "public volatile Float Float52", - "embedded= true public volatile Float Float53", - "embedded= false public volatile Float Float54", - "persistence-modifier= none public volatile Float Float55", - "persistence-modifier= persistent public volatile Float Float56", - "persistence-modifier= persistent embedded= true public volatile Float Float57", - "persistence-modifier= persistent embedded= false public volatile Float Float58", - "persistence-modifier= transactional public volatile Float Float59", - "public static transient Float Float60", - "public static final Float Float61", - "public static volatile Float Float62", - "public transient final Float Float63", - "public transient volatile Float Float64", - "persistence-modifier= none public transient volatile Float Float65", - "persistence-modifier= persistent public transient volatile Float Float66", - "persistence-modifier= persistent embedded= true public transient volatile Float Float67", - "persistence-modifier= persistent embedded= false public transient volatile Float Float68", - "persistence-modifier= transactional public transient volatile Float Float69", - "public static transient final Float Float70", - "public static transient volatile Float Float71", - "protected Float Float72", - "embedded= true protected Float Float73", - "embedded= false protected Float Float74", - "persistence-modifier= none protected Float Float75", - "persistence-modifier= persistent protected Float Float76", - "persistence-modifier= persistent embedded= true protected Float Float77", - "persistence-modifier= persistent embedded= false protected Float Float78", - "persistence-modifier= transactional protected Float Float79", - "protected static Float Float80", - "protected transient Float Float81", - "persistence-modifier= none protected transient Float Float82", - "persistence-modifier= persistent protected transient Float Float83", - "persistence-modifier= persistent embedded= true protected transient Float Float84", - "persistence-modifier= persistent embedded= false protected transient Float Float85", - "persistence-modifier= transactional protected transient Float Float86", - "protected final Float Float87", - "protected volatile Float Float88", - "embedded= true protected volatile Float Float89", - "embedded= false protected volatile Float Float90", - "persistence-modifier= none protected volatile Float Float91", - "persistence-modifier= persistent protected volatile Float Float92", - "persistence-modifier= persistent embedded= true protected volatile Float Float93", - "persistence-modifier= persistent embedded= false protected volatile Float Float94", - "persistence-modifier= transactional protected volatile Float Float95", - "protected static transient Float Float96", - "protected static final Float Float97", - "protected static volatile Float Float98", - "protected transient final Float Float99", - "protected transient volatile Float Float100", - "persistence-modifier= none protected transient volatile Float Float101", - "persistence-modifier= persistent protected transient volatile Float Float102", - "persistence-modifier= persistent embedded= true protected transient volatile Float Float103", - "persistence-modifier= persistent embedded= false protected transient volatile Float Float104", - "persistence-modifier= transactional protected transient volatile Float Float105", - "protected static transient final Float Float106", - "protected static transient volatile Float Float107", - "Float Float108", - "embedded= true Float Float109", - "embedded= false Float Float110", - "persistence-modifier= none Float Float111", - "persistence-modifier= persistent Float Float112", - "persistence-modifier= persistent embedded= true Float Float113", - "persistence-modifier= persistent embedded= false Float Float114", - "persistence-modifier= transactional Float Float115", - "static Float Float116", - "transient Float Float117", - "persistence-modifier= none transient Float Float118", - "persistence-modifier= persistent transient Float Float119", - "persistence-modifier= persistent embedded= true transient Float Float120", - "persistence-modifier= persistent embedded= false transient Float Float121", - "persistence-modifier= transactional transient Float Float122", - "final Float Float123", - "volatile Float Float124", - "embedded= true volatile Float Float125", - "embedded= false volatile Float Float126", - "persistence-modifier= none volatile Float Float127", - "persistence-modifier= persistent volatile Float Float128", - "persistence-modifier= persistent embedded= true volatile Float Float129", - "persistence-modifier= persistent embedded= false volatile Float Float130", - "persistence-modifier= transactional volatile Float Float131", - "static transient Float Float132", - "static final Float Float133", - "static volatile Float Float134", - "transient final Float Float135", - "transient volatile Float Float136", - "persistence-modifier= none transient volatile Float Float137", - "persistence-modifier= persistent transient volatile Float Float138", - "persistence-modifier= persistent embedded= true transient volatile Float Float139", - "persistence-modifier= persistent embedded= false transient volatile Float Float140", - "persistence-modifier= transactional transient volatile Float Float141", - "static transient final Float Float142", - "static transient volatile Float Float143" + public static final String [] fieldSpecs = { + "private Float Float0", + "embedded= true private Float Float1", + "embedded= false private Float Float2", + "persistence-modifier= none private Float Float3", + "persistence-modifier= persistent private Float Float4", + "persistence-modifier= persistent embedded= true private Float Float5", + "persistence-modifier= persistent embedded= false private Float Float6", + "persistence-modifier= transactional private Float Float7", + "private static Float Float8", + "private transient Float Float9", + "persistence-modifier= none private transient Float Float10", + "persistence-modifier= persistent private transient Float Float11", + "persistence-modifier= persistent embedded= true private transient Float Float12", + "persistence-modifier= persistent embedded= false private transient Float Float13", + "persistence-modifier= transactional private transient Float Float14", + "private final Float Float15", + "private volatile Float Float16", + "embedded= true private volatile Float Float17", + "embedded= false private volatile Float Float18", + "persistence-modifier= none private volatile Float Float19", + "persistence-modifier= persistent private volatile Float Float20", + "persistence-modifier= persistent embedded= true private volatile Float Float21", + "persistence-modifier= persistent embedded= false private volatile Float Float22", + "persistence-modifier= transactional private volatile Float Float23", + "private static transient Float Float24", + "private static final Float Float25", + "private static volatile Float Float26", + "private transient final Float Float27", + "private transient volatile Float Float28", + "persistence-modifier= none private transient volatile Float Float29", + "persistence-modifier= persistent private transient volatile Float Float30", + "persistence-modifier= persistent embedded= true private transient volatile Float Float31", + "persistence-modifier= persistent embedded= false private transient volatile Float Float32", + "persistence-modifier= transactional private transient volatile Float Float33", + "private static transient final Float Float34", + "private static transient volatile Float Float35", + "public Float Float36", + "embedded= true public Float Float37", + "embedded= false public Float Float38", + "persistence-modifier= none public Float Float39", + "persistence-modifier= persistent public Float Float40", + "persistence-modifier= persistent embedded= true public Float Float41", + "persistence-modifier= persistent embedded= false public Float Float42", + "persistence-modifier= transactional public Float Float43", + "public static Float Float44", + "public transient Float Float45", + "persistence-modifier= none public transient Float Float46", + "persistence-modifier= persistent public transient Float Float47", + "persistence-modifier= persistent embedded= true public transient Float Float48", + "persistence-modifier= persistent embedded= false public transient Float Float49", + "persistence-modifier= transactional public transient Float Float50", + "public final Float Float51", + "public volatile Float Float52", + "embedded= true public volatile Float Float53", + "embedded= false public volatile Float Float54", + "persistence-modifier= none public volatile Float Float55", + "persistence-modifier= persistent public volatile Float Float56", + "persistence-modifier= persistent embedded= true public volatile Float Float57", + "persistence-modifier= persistent embedded= false public volatile Float Float58", + "persistence-modifier= transactional public volatile Float Float59", + "public static transient Float Float60", + "public static final Float Float61", + "public static volatile Float Float62", + "public transient final Float Float63", + "public transient volatile Float Float64", + "persistence-modifier= none public transient volatile Float Float65", + "persistence-modifier= persistent public transient volatile Float Float66", + "persistence-modifier= persistent embedded= true public transient volatile Float Float67", + "persistence-modifier= persistent embedded= false public transient volatile Float Float68", + "persistence-modifier= transactional public transient volatile Float Float69", + "public static transient final Float Float70", + "public static transient volatile Float Float71", + "protected Float Float72", + "embedded= true protected Float Float73", + "embedded= false protected Float Float74", + "persistence-modifier= none protected Float Float75", + "persistence-modifier= persistent protected Float Float76", + "persistence-modifier= persistent embedded= true protected Float Float77", + "persistence-modifier= persistent embedded= false protected Float Float78", + "persistence-modifier= transactional protected Float Float79", + "protected static Float Float80", + "protected transient Float Float81", + "persistence-modifier= none protected transient Float Float82", + "persistence-modifier= persistent protected transient Float Float83", + "persistence-modifier= persistent embedded= true protected transient Float Float84", + "persistence-modifier= persistent embedded= false protected transient Float Float85", + "persistence-modifier= transactional protected transient Float Float86", + "protected final Float Float87", + "protected volatile Float Float88", + "embedded= true protected volatile Float Float89", + "embedded= false protected volatile Float Float90", + "persistence-modifier= none protected volatile Float Float91", + "persistence-modifier= persistent protected volatile Float Float92", + "persistence-modifier= persistent embedded= true protected volatile Float Float93", + "persistence-modifier= persistent embedded= false protected volatile Float Float94", + "persistence-modifier= transactional protected volatile Float Float95", + "protected static transient Float Float96", + "protected static final Float Float97", + "protected static volatile Float Float98", + "protected transient final Float Float99", + "protected transient volatile Float Float100", + "persistence-modifier= none protected transient volatile Float Float101", + "persistence-modifier= persistent protected transient volatile Float Float102", + "persistence-modifier= persistent embedded= true protected transient volatile Float Float103", + "persistence-modifier= persistent embedded= false protected transient volatile Float Float104", + "persistence-modifier= transactional protected transient volatile Float Float105", + "protected static transient final Float Float106", + "protected static transient volatile Float Float107", + "Float Float108", + "embedded= true Float Float109", + "embedded= false Float Float110", + "persistence-modifier= none Float Float111", + "persistence-modifier= persistent Float Float112", + "persistence-modifier= persistent embedded= true Float Float113", + "persistence-modifier= persistent embedded= false Float Float114", + "persistence-modifier= transactional Float Float115", + "static Float Float116", + "transient Float Float117", + "persistence-modifier= none transient Float Float118", + "persistence-modifier= persistent transient Float Float119", + "persistence-modifier= persistent embedded= true transient Float Float120", + "persistence-modifier= persistent embedded= false transient Float Float121", + "persistence-modifier= transactional transient Float Float122", + "final Float Float123", + "volatile Float Float124", + "embedded= true volatile Float Float125", + "embedded= false volatile Float Float126", + "persistence-modifier= none volatile Float Float127", + "persistence-modifier= persistent volatile Float Float128", + "persistence-modifier= persistent embedded= true volatile Float Float129", + "persistence-modifier= persistent embedded= false volatile Float Float130", + "persistence-modifier= transactional volatile Float Float131", + "static transient Float Float132", + "static final Float Float133", + "static volatile Float Float134", + "transient final Float Float135", + "transient volatile Float Float136", + "persistence-modifier= none transient volatile Float Float137", + "persistence-modifier= persistent transient volatile Float Float138", + "persistence-modifier= persistent embedded= true transient volatile Float Float139", + "persistence-modifier= persistent embedded= false transient volatile Float Float140", + "persistence-modifier= transactional transient volatile Float Float141", + "static transient final Float Float142", + "static transient volatile Float Float143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public Float get(int index) { - switch (index) { - case (0): + public Float get(int index) + { + switch (index) + { + case(0): return Float0; - case (1): + case(1): return Float1; - case (2): + case(2): return Float2; - case (3): + case(3): return Float3; - case (4): + case(4): return Float4; - case (5): + case(5): return Float5; - case (6): + case(6): return Float6; - case (7): + case(7): return Float7; - case (8): + case(8): return Float8; - case (9): + case(9): return Float9; - case (10): + case(10): return Float10; - case (11): + case(11): return Float11; - case (12): + case(12): return Float12; - case (13): + case(13): return Float13; - case (14): + case(14): return Float14; - case (15): + case(15): return Float15; - case (16): + case(16): return Float16; - case (17): + case(17): return Float17; - case (18): + case(18): return Float18; - case (19): + case(19): return Float19; - case (20): + case(20): return Float20; - case (21): + case(21): return Float21; - case (22): + case(22): return Float22; - case (23): + case(23): return Float23; - case (24): + case(24): return Float24; - case (25): + case(25): return Float25; - case (26): + case(26): return Float26; - case (27): + case(27): return Float27; - case (28): + case(28): return Float28; - case (29): + case(29): return Float29; - case (30): + case(30): return Float30; - case (31): + case(31): return Float31; - case (32): + case(32): return Float32; - case (33): + case(33): return Float33; - case (34): + case(34): return Float34; - case (35): + case(35): return Float35; - case (36): + case(36): return Float36; - case (37): + case(37): return Float37; - case (38): + case(38): return Float38; - case (39): + case(39): return Float39; - case (40): + case(40): return Float40; - case (41): + case(41): return Float41; - case (42): + case(42): return Float42; - case (43): + case(43): return Float43; - case (44): + case(44): return Float44; - case (45): + case(45): return Float45; - case (46): + case(46): return Float46; - case (47): + case(47): return Float47; - case (48): + case(48): return Float48; - case (49): + case(49): return Float49; - case (50): + case(50): return Float50; - case (51): + case(51): return Float51; - case (52): + case(52): return Float52; - case (53): + case(53): return Float53; - case (54): + case(54): return Float54; - case (55): + case(55): return Float55; - case (56): + case(56): return Float56; - case (57): + case(57): return Float57; - case (58): + case(58): return Float58; - case (59): + case(59): return Float59; - case (60): + case(60): return Float60; - case (61): + case(61): return Float61; - case (62): + case(62): return Float62; - case (63): + case(63): return Float63; - case (64): + case(64): return Float64; - case (65): + case(65): return Float65; - case (66): + case(66): return Float66; - case (67): + case(67): return Float67; - case (68): + case(68): return Float68; - case (69): + case(69): return Float69; - case (70): + case(70): return Float70; - case (71): + case(71): return Float71; - case (72): + case(72): return Float72; - case (73): + case(73): return Float73; - case (74): + case(74): return Float74; - case (75): + case(75): return Float75; - case (76): + case(76): return Float76; - case (77): + case(77): return Float77; - case (78): + case(78): return Float78; - case (79): + case(79): return Float79; - case (80): + case(80): return Float80; - case (81): + case(81): return Float81; - case (82): + case(82): return Float82; - case (83): + case(83): return Float83; - case (84): + case(84): return Float84; - case (85): + case(85): return Float85; - case (86): + case(86): return Float86; - case (87): + case(87): return Float87; - case (88): + case(88): return Float88; - case (89): + case(89): return Float89; - case (90): + case(90): return Float90; - case (91): + case(91): return Float91; - case (92): + case(92): return Float92; - case (93): + case(93): return Float93; - case (94): + case(94): return Float94; - case (95): + case(95): return Float95; - case (96): + case(96): return Float96; - case (97): + case(97): return Float97; - case (98): + case(98): return Float98; - case (99): + case(99): return Float99; - case (100): + case(100): return Float100; - case (101): + case(101): return Float101; - case (102): + case(102): return Float102; - case (103): + case(103): return Float103; - case (104): + case(104): return Float104; - case (105): + case(105): return Float105; - case (106): + case(106): return Float106; - case (107): + case(107): return Float107; - case (108): + case(108): return Float108; - case (109): + case(109): return Float109; - case (110): + case(110): return Float110; - case (111): + case(111): return Float111; - case (112): + case(112): return Float112; - case (113): + case(113): return Float113; - case (114): + case(114): return Float114; - case (115): + case(115): return Float115; - case (116): + case(116): return Float116; - case (117): + case(117): return Float117; - case (118): + case(118): return Float118; - case (119): + case(119): return Float119; - case (120): + case(120): return Float120; - case (121): + case(121): return Float121; - case (122): + case(122): return Float122; - case (123): + case(123): return Float123; - case (124): + case(124): return Float124; - case (125): + case(125): return Float125; - case (126): + case(126): return Float126; - case (127): + case(127): return Float127; - case (128): + case(128): return Float128; - case (129): + case(129): return Float129; - case (130): + case(130): return Float130; - case (131): + case(131): return Float131; - case (132): + case(132): return Float132; - case (133): + case(133): return Float133; - case (134): + case(134): return Float134; - case (135): + case(135): return Float135; - case (136): + case(136): return Float136; - case (137): + case(137): return Float137; - case (138): + case(138): return Float138; - case (139): + case(139): return Float139; - case (140): + case(140): return Float140; - case (141): + case(141): return Float141; - case (142): + case(142): return Float142; - case (143): + case(143): return Float143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, Float value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - Float0 = value; - break; - case (1): - Float1 = value; - break; - case (2): - Float2 = value; - break; - case (3): - Float3 = value; - break; - case (4): - Float4 = value; - break; - case (5): - Float5 = value; - break; - case (6): - Float6 = value; - break; - case (7): - Float7 = value; - break; - case (8): - Float8 = value; - break; - case (9): - Float9 = value; - break; - case (10): - Float10 = value; - break; - case (11): - Float11 = value; - break; - case (12): - Float12 = value; - break; - case (13): - Float13 = value; - break; - case (14): - Float14 = value; - break; - case (16): - Float16 = value; - break; - case (17): - Float17 = value; - break; - case (18): - Float18 = value; - break; - case (19): - Float19 = value; - break; - case (20): - Float20 = value; - break; - case (21): - Float21 = value; - break; - case (22): - Float22 = value; - break; - case (23): - Float23 = value; - break; - case (24): - Float24 = value; - break; - case (26): - Float26 = value; - break; - case (28): - Float28 = value; - break; - case (29): - Float29 = value; - break; - case (30): - Float30 = value; - break; - case (31): - Float31 = value; - break; - case (32): - Float32 = value; - break; - case (33): - Float33 = value; - break; - case (35): - Float35 = value; - break; - case (36): - Float36 = value; - break; - case (37): - Float37 = value; - break; - case (38): - Float38 = value; - break; - case (39): - Float39 = value; - break; - case (40): - Float40 = value; - break; - case (41): - Float41 = value; - break; - case (42): - Float42 = value; - break; - case (43): - Float43 = value; - break; - case (44): - Float44 = value; - break; - case (45): - Float45 = value; - break; - case (46): - Float46 = value; - break; - case (47): - Float47 = value; - break; - case (48): - Float48 = value; - break; - case (49): - Float49 = value; - break; - case (50): - Float50 = value; - break; - case (52): - Float52 = value; - break; - case (53): - Float53 = value; - break; - case (54): - Float54 = value; - break; - case (55): - Float55 = value; - break; - case (56): - Float56 = value; - break; - case (57): - Float57 = value; - break; - case (58): - Float58 = value; - break; - case (59): - Float59 = value; - break; - case (60): - Float60 = value; - break; - case (62): - Float62 = value; - break; - case (64): - Float64 = value; - break; - case (65): - Float65 = value; - break; - case (66): - Float66 = value; - break; - case (67): - Float67 = value; - break; - case (68): - Float68 = value; - break; - case (69): - Float69 = value; - break; - case (71): - Float71 = value; - break; - case (72): - Float72 = value; - break; - case (73): - Float73 = value; - break; - case (74): - Float74 = value; - break; - case (75): - Float75 = value; - break; - case (76): - Float76 = value; - break; - case (77): - Float77 = value; - break; - case (78): - Float78 = value; - break; - case (79): - Float79 = value; - break; - case (80): - Float80 = value; - break; - case (81): - Float81 = value; - break; - case (82): - Float82 = value; - break; - case (83): - Float83 = value; - break; - case (84): - Float84 = value; - break; - case (85): - Float85 = value; - break; - case (86): - Float86 = value; - break; - case (88): - Float88 = value; - break; - case (89): - Float89 = value; - break; - case (90): - Float90 = value; - break; - case (91): - Float91 = value; - break; - case (92): - Float92 = value; - break; - case (93): - Float93 = value; - break; - case (94): - Float94 = value; - break; - case (95): - Float95 = value; - break; - case (96): - Float96 = value; - break; - case (98): - Float98 = value; - break; - case (100): - Float100 = value; - break; - case (101): - Float101 = value; - break; - case (102): - Float102 = value; - break; - case (103): - Float103 = value; - break; - case (104): - Float104 = value; - break; - case (105): - Float105 = value; - break; - case (107): - Float107 = value; - break; - case (108): - Float108 = value; - break; - case (109): - Float109 = value; - break; - case (110): - Float110 = value; - break; - case (111): - Float111 = value; - break; - case (112): - Float112 = value; - break; - case (113): - Float113 = value; - break; - case (114): - Float114 = value; - break; - case (115): - Float115 = value; - break; - case (116): - Float116 = value; - break; - case (117): - Float117 = value; - break; - case (118): - Float118 = value; - break; - case (119): - Float119 = value; - break; - case (120): - Float120 = value; - break; - case (121): - Float121 = value; - break; - case (122): - Float122 = value; - break; - case (124): - Float124 = value; - break; - case (125): - Float125 = value; - break; - case (126): - Float126 = value; - break; - case (127): - Float127 = value; - break; - case (128): - Float128 = value; - break; - case (129): - Float129 = value; - break; - case (130): - Float130 = value; - break; - case (131): - Float131 = value; - break; - case (132): - Float132 = value; - break; - case (134): - Float134 = value; - break; - case (136): - Float136 = value; - break; - case (137): - Float137 = value; - break; - case (138): - Float138 = value; - break; - case (139): - Float139 = value; - break; - case (140): - Float140 = value; - break; - case (141): - Float141 = value; - break; - case (143): - Float143 = value; - break; + public boolean set(int index,Float value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + Float0= value; + break; + case(1): + Float1= value; + break; + case(2): + Float2= value; + break; + case(3): + Float3= value; + break; + case(4): + Float4= value; + break; + case(5): + Float5= value; + break; + case(6): + Float6= value; + break; + case(7): + Float7= value; + break; + case(8): + Float8= value; + break; + case(9): + Float9= value; + break; + case(10): + Float10= value; + break; + case(11): + Float11= value; + break; + case(12): + Float12= value; + break; + case(13): + Float13= value; + break; + case(14): + Float14= value; + break; + case(16): + Float16= value; + break; + case(17): + Float17= value; + break; + case(18): + Float18= value; + break; + case(19): + Float19= value; + break; + case(20): + Float20= value; + break; + case(21): + Float21= value; + break; + case(22): + Float22= value; + break; + case(23): + Float23= value; + break; + case(24): + Float24= value; + break; + case(26): + Float26= value; + break; + case(28): + Float28= value; + break; + case(29): + Float29= value; + break; + case(30): + Float30= value; + break; + case(31): + Float31= value; + break; + case(32): + Float32= value; + break; + case(33): + Float33= value; + break; + case(35): + Float35= value; + break; + case(36): + Float36= value; + break; + case(37): + Float37= value; + break; + case(38): + Float38= value; + break; + case(39): + Float39= value; + break; + case(40): + Float40= value; + break; + case(41): + Float41= value; + break; + case(42): + Float42= value; + break; + case(43): + Float43= value; + break; + case(44): + Float44= value; + break; + case(45): + Float45= value; + break; + case(46): + Float46= value; + break; + case(47): + Float47= value; + break; + case(48): + Float48= value; + break; + case(49): + Float49= value; + break; + case(50): + Float50= value; + break; + case(52): + Float52= value; + break; + case(53): + Float53= value; + break; + case(54): + Float54= value; + break; + case(55): + Float55= value; + break; + case(56): + Float56= value; + break; + case(57): + Float57= value; + break; + case(58): + Float58= value; + break; + case(59): + Float59= value; + break; + case(60): + Float60= value; + break; + case(62): + Float62= value; + break; + case(64): + Float64= value; + break; + case(65): + Float65= value; + break; + case(66): + Float66= value; + break; + case(67): + Float67= value; + break; + case(68): + Float68= value; + break; + case(69): + Float69= value; + break; + case(71): + Float71= value; + break; + case(72): + Float72= value; + break; + case(73): + Float73= value; + break; + case(74): + Float74= value; + break; + case(75): + Float75= value; + break; + case(76): + Float76= value; + break; + case(77): + Float77= value; + break; + case(78): + Float78= value; + break; + case(79): + Float79= value; + break; + case(80): + Float80= value; + break; + case(81): + Float81= value; + break; + case(82): + Float82= value; + break; + case(83): + Float83= value; + break; + case(84): + Float84= value; + break; + case(85): + Float85= value; + break; + case(86): + Float86= value; + break; + case(88): + Float88= value; + break; + case(89): + Float89= value; + break; + case(90): + Float90= value; + break; + case(91): + Float91= value; + break; + case(92): + Float92= value; + break; + case(93): + Float93= value; + break; + case(94): + Float94= value; + break; + case(95): + Float95= value; + break; + case(96): + Float96= value; + break; + case(98): + Float98= value; + break; + case(100): + Float100= value; + break; + case(101): + Float101= value; + break; + case(102): + Float102= value; + break; + case(103): + Float103= value; + break; + case(104): + Float104= value; + break; + case(105): + Float105= value; + break; + case(107): + Float107= value; + break; + case(108): + Float108= value; + break; + case(109): + Float109= value; + break; + case(110): + Float110= value; + break; + case(111): + Float111= value; + break; + case(112): + Float112= value; + break; + case(113): + Float113= value; + break; + case(114): + Float114= value; + break; + case(115): + Float115= value; + break; + case(116): + Float116= value; + break; + case(117): + Float117= value; + break; + case(118): + Float118= value; + break; + case(119): + Float119= value; + break; + case(120): + Float120= value; + break; + case(121): + Float121= value; + break; + case(122): + Float122= value; + break; + case(124): + Float124= value; + break; + case(125): + Float125= value; + break; + case(126): + Float126= value; + break; + case(127): + Float127= value; + break; + case(128): + Float128= value; + break; + case(129): + Float129= value; + break; + case(130): + Float130= value; + break; + case(131): + Float131= value; + break; + case(132): + Float132= value; + break; + case(134): + Float134= value; + break; + case(136): + Float136= value; + break; + case(137): + Float137= value; + break; + case(138): + Float138= value; + break; + case(139): + Float139= value; + break; + case(140): + Float140= value; + break; + case(141): + Float141= value; + break; + case(143): + Float143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfInteger.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfInteger.java index bbbb68dd5..02c0a6841 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfInteger.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfInteger.java @@ -5,21 +5,21 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -public class FieldsOfInteger { +public class FieldsOfInteger { public int identifier; private Integer Integer0; private Integer Integer1; @@ -36,7 +36,7 @@ public class FieldsOfInteger { private transient Integer Integer12; private transient Integer Integer13; private transient Integer Integer14; - private final Integer Integer15 = Integer.valueOf((int) 5); + private final Integer Integer15 = Integer.valueOf((int)5); private volatile Integer Integer16; private volatile Integer Integer17; private volatile Integer Integer18; @@ -46,16 +46,16 @@ public class FieldsOfInteger { private volatile Integer Integer22; private volatile Integer Integer23; private static transient Integer Integer24; - private static final Integer Integer25 = Integer.valueOf((int) 5); + private static final Integer Integer25 = Integer.valueOf((int)5); private static volatile Integer Integer26; - private final transient Integer Integer27 = Integer.valueOf((int) 5); + private transient final Integer Integer27 = Integer.valueOf((int)5); private transient volatile Integer Integer28; private transient volatile Integer Integer29; private transient volatile Integer Integer30; private transient volatile Integer Integer31; private transient volatile Integer Integer32; private transient volatile Integer Integer33; - private static final transient Integer Integer34 = Integer.valueOf((int) 5); + private static transient final Integer Integer34 = Integer.valueOf((int)5); private static transient volatile Integer Integer35; public Integer Integer36; public Integer Integer37; @@ -72,7 +72,7 @@ public class FieldsOfInteger { public transient Integer Integer48; public transient Integer Integer49; public transient Integer Integer50; - public final Integer Integer51 = Integer.valueOf((int) 5); + public final Integer Integer51 = Integer.valueOf((int)5); public volatile Integer Integer52; public volatile Integer Integer53; public volatile Integer Integer54; @@ -82,16 +82,16 @@ public class FieldsOfInteger { public volatile Integer Integer58; public volatile Integer Integer59; public static transient Integer Integer60; - public static final Integer Integer61 = Integer.valueOf((int) 5); + public static final Integer Integer61 = Integer.valueOf((int)5); public static volatile Integer Integer62; - public final transient Integer Integer63 = Integer.valueOf((int) 5); + public transient final Integer Integer63 = Integer.valueOf((int)5); public transient volatile Integer Integer64; public transient volatile Integer Integer65; public transient volatile Integer Integer66; public transient volatile Integer Integer67; public transient volatile Integer Integer68; public transient volatile Integer Integer69; - public static final transient Integer Integer70 = Integer.valueOf((int) 5); + public static transient final Integer Integer70 = Integer.valueOf((int)5); public static transient volatile Integer Integer71; protected Integer Integer72; protected Integer Integer73; @@ -108,7 +108,7 @@ public class FieldsOfInteger { protected transient Integer Integer84; protected transient Integer Integer85; protected transient Integer Integer86; - protected final Integer Integer87 = Integer.valueOf((int) 5); + protected final Integer Integer87 = Integer.valueOf((int)5); protected volatile Integer Integer88; protected volatile Integer Integer89; protected volatile Integer Integer90; @@ -118,16 +118,16 @@ public class FieldsOfInteger { protected volatile Integer Integer94; protected volatile Integer Integer95; protected static transient Integer Integer96; - protected static final Integer Integer97 = Integer.valueOf((int) 5); + protected static final Integer Integer97 = Integer.valueOf((int)5); protected static volatile Integer Integer98; - protected final transient Integer Integer99 = Integer.valueOf((int) 5); + protected transient final Integer Integer99 = Integer.valueOf((int)5); protected transient volatile Integer Integer100; protected transient volatile Integer Integer101; protected transient volatile Integer Integer102; protected transient volatile Integer Integer103; protected transient volatile Integer Integer104; protected transient volatile Integer Integer105; - protected static final transient Integer Integer106 = Integer.valueOf((int) 5); + protected static transient final Integer Integer106 = Integer.valueOf((int)5); protected static transient volatile Integer Integer107; Integer Integer108; Integer Integer109; @@ -144,7 +144,7 @@ public class FieldsOfInteger { transient Integer Integer120; transient Integer Integer121; transient Integer Integer122; - final Integer Integer123 = Integer.valueOf((int) 5); + final Integer Integer123 = Integer.valueOf((int)5); volatile Integer Integer124; volatile Integer Integer125; volatile Integer Integer126; @@ -154,938 +154,936 @@ public class FieldsOfInteger { volatile Integer Integer130; volatile Integer Integer131; static transient Integer Integer132; - static final Integer Integer133 = Integer.valueOf((int) 5); + static final Integer Integer133 = Integer.valueOf((int)5); static volatile Integer Integer134; - final transient Integer Integer135 = Integer.valueOf((int) 5); + transient final Integer Integer135 = Integer.valueOf((int)5); transient volatile Integer Integer136; transient volatile Integer Integer137; transient volatile Integer Integer138; transient volatile Integer Integer139; transient volatile Integer Integer140; transient volatile Integer Integer141; - static final transient Integer Integer142 = Integer.valueOf((int) 5); + static transient final Integer Integer142 = Integer.valueOf((int)5); static transient volatile Integer Integer143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private Integer Integer0", - "embedded= true private Integer Integer1", - "embedded= false private Integer Integer2", - "persistence-modifier= none private Integer Integer3", - "persistence-modifier= persistent private Integer Integer4", - "persistence-modifier= persistent embedded= true private Integer Integer5", - "persistence-modifier= persistent embedded= false private Integer Integer6", - "persistence-modifier= transactional private Integer Integer7", - "private static Integer Integer8", - "private transient Integer Integer9", - "persistence-modifier= none private transient Integer Integer10", - "persistence-modifier= persistent private transient Integer Integer11", - "persistence-modifier= persistent embedded= true private transient Integer Integer12", - "persistence-modifier= persistent embedded= false private transient Integer Integer13", - "persistence-modifier= transactional private transient Integer Integer14", - "private final Integer Integer15", - "private volatile Integer Integer16", - "embedded= true private volatile Integer Integer17", - "embedded= false private volatile Integer Integer18", - "persistence-modifier= none private volatile Integer Integer19", - "persistence-modifier= persistent private volatile Integer Integer20", - "persistence-modifier= persistent embedded= true private volatile Integer Integer21", - "persistence-modifier= persistent embedded= false private volatile Integer Integer22", - "persistence-modifier= transactional private volatile Integer Integer23", - "private static transient Integer Integer24", - "private static final Integer Integer25", - "private static volatile Integer Integer26", - "private transient final Integer Integer27", - "private transient volatile Integer Integer28", - "persistence-modifier= none private transient volatile Integer Integer29", - "persistence-modifier= persistent private transient volatile Integer Integer30", - "persistence-modifier= persistent embedded= true private transient volatile Integer Integer31", - "persistence-modifier= persistent embedded= false private transient volatile Integer Integer32", - "persistence-modifier= transactional private transient volatile Integer Integer33", - "private static transient final Integer Integer34", - "private static transient volatile Integer Integer35", - "public Integer Integer36", - "embedded= true public Integer Integer37", - "embedded= false public Integer Integer38", - "persistence-modifier= none public Integer Integer39", - "persistence-modifier= persistent public Integer Integer40", - "persistence-modifier= persistent embedded= true public Integer Integer41", - "persistence-modifier= persistent embedded= false public Integer Integer42", - "persistence-modifier= transactional public Integer Integer43", - "public static Integer Integer44", - "public transient Integer Integer45", - "persistence-modifier= none public transient Integer Integer46", - "persistence-modifier= persistent public transient Integer Integer47", - "persistence-modifier= persistent embedded= true public transient Integer Integer48", - "persistence-modifier= persistent embedded= false public transient Integer Integer49", - "persistence-modifier= transactional public transient Integer Integer50", - "public final Integer Integer51", - "public volatile Integer Integer52", - "embedded= true public volatile Integer Integer53", - "embedded= false public volatile Integer Integer54", - "persistence-modifier= none public volatile Integer Integer55", - "persistence-modifier= persistent public volatile Integer Integer56", - "persistence-modifier= persistent embedded= true public volatile Integer Integer57", - "persistence-modifier= persistent embedded= false public volatile Integer Integer58", - "persistence-modifier= transactional public volatile Integer Integer59", - "public static transient Integer Integer60", - "public static final Integer Integer61", - "public static volatile Integer Integer62", - "public transient final Integer Integer63", - "public transient volatile Integer Integer64", - "persistence-modifier= none public transient volatile Integer Integer65", - "persistence-modifier= persistent public transient volatile Integer Integer66", - "persistence-modifier= persistent embedded= true public transient volatile Integer Integer67", - "persistence-modifier= persistent embedded= false public transient volatile Integer Integer68", - "persistence-modifier= transactional public transient volatile Integer Integer69", - "public static transient final Integer Integer70", - "public static transient volatile Integer Integer71", - "protected Integer Integer72", - "embedded= true protected Integer Integer73", - "embedded= false protected Integer Integer74", - "persistence-modifier= none protected Integer Integer75", - "persistence-modifier= persistent protected Integer Integer76", - "persistence-modifier= persistent embedded= true protected Integer Integer77", - "persistence-modifier= persistent embedded= false protected Integer Integer78", - "persistence-modifier= transactional protected Integer Integer79", - "protected static Integer Integer80", - "protected transient Integer Integer81", - "persistence-modifier= none protected transient Integer Integer82", - "persistence-modifier= persistent protected transient Integer Integer83", - "persistence-modifier= persistent embedded= true protected transient Integer Integer84", - "persistence-modifier= persistent embedded= false protected transient Integer Integer85", - "persistence-modifier= transactional protected transient Integer Integer86", - "protected final Integer Integer87", - "protected volatile Integer Integer88", - "embedded= true protected volatile Integer Integer89", - "embedded= false protected volatile Integer Integer90", - "persistence-modifier= none protected volatile Integer Integer91", - "persistence-modifier= persistent protected volatile Integer Integer92", - "persistence-modifier= persistent embedded= true protected volatile Integer Integer93", - "persistence-modifier= persistent embedded= false protected volatile Integer Integer94", - "persistence-modifier= transactional protected volatile Integer Integer95", - "protected static transient Integer Integer96", - "protected static final Integer Integer97", - "protected static volatile Integer Integer98", - "protected transient final Integer Integer99", - "protected transient volatile Integer Integer100", - "persistence-modifier= none protected transient volatile Integer Integer101", - "persistence-modifier= persistent protected transient volatile Integer Integer102", - "persistence-modifier= persistent embedded= true protected transient volatile Integer Integer103", - "persistence-modifier= persistent embedded= false protected transient volatile Integer Integer104", - "persistence-modifier= transactional protected transient volatile Integer Integer105", - "protected static transient final Integer Integer106", - "protected static transient volatile Integer Integer107", - "Integer Integer108", - "embedded= true Integer Integer109", - "embedded= false Integer Integer110", - "persistence-modifier= none Integer Integer111", - "persistence-modifier= persistent Integer Integer112", - "persistence-modifier= persistent embedded= true Integer Integer113", - "persistence-modifier= persistent embedded= false Integer Integer114", - "persistence-modifier= transactional Integer Integer115", - "static Integer Integer116", - "transient Integer Integer117", - "persistence-modifier= none transient Integer Integer118", - "persistence-modifier= persistent transient Integer Integer119", - "persistence-modifier= persistent embedded= true transient Integer Integer120", - "persistence-modifier= persistent embedded= false transient Integer Integer121", - "persistence-modifier= transactional transient Integer Integer122", - "final Integer Integer123", - "volatile Integer Integer124", - "embedded= true volatile Integer Integer125", - "embedded= false volatile Integer Integer126", - "persistence-modifier= none volatile Integer Integer127", - "persistence-modifier= persistent volatile Integer Integer128", - "persistence-modifier= persistent embedded= true volatile Integer Integer129", - "persistence-modifier= persistent embedded= false volatile Integer Integer130", - "persistence-modifier= transactional volatile Integer Integer131", - "static transient Integer Integer132", - "static final Integer Integer133", - "static volatile Integer Integer134", - "transient final Integer Integer135", - "transient volatile Integer Integer136", - "persistence-modifier= none transient volatile Integer Integer137", - "persistence-modifier= persistent transient volatile Integer Integer138", - "persistence-modifier= persistent embedded= true transient volatile Integer Integer139", - "persistence-modifier= persistent embedded= false transient volatile Integer Integer140", - "persistence-modifier= transactional transient volatile Integer Integer141", - "static transient final Integer Integer142", - "static transient volatile Integer Integer143" + public static final String [] fieldSpecs = { + "private Integer Integer0", + "embedded= true private Integer Integer1", + "embedded= false private Integer Integer2", + "persistence-modifier= none private Integer Integer3", + "persistence-modifier= persistent private Integer Integer4", + "persistence-modifier= persistent embedded= true private Integer Integer5", + "persistence-modifier= persistent embedded= false private Integer Integer6", + "persistence-modifier= transactional private Integer Integer7", + "private static Integer Integer8", + "private transient Integer Integer9", + "persistence-modifier= none private transient Integer Integer10", + "persistence-modifier= persistent private transient Integer Integer11", + "persistence-modifier= persistent embedded= true private transient Integer Integer12", + "persistence-modifier= persistent embedded= false private transient Integer Integer13", + "persistence-modifier= transactional private transient Integer Integer14", + "private final Integer Integer15", + "private volatile Integer Integer16", + "embedded= true private volatile Integer Integer17", + "embedded= false private volatile Integer Integer18", + "persistence-modifier= none private volatile Integer Integer19", + "persistence-modifier= persistent private volatile Integer Integer20", + "persistence-modifier= persistent embedded= true private volatile Integer Integer21", + "persistence-modifier= persistent embedded= false private volatile Integer Integer22", + "persistence-modifier= transactional private volatile Integer Integer23", + "private static transient Integer Integer24", + "private static final Integer Integer25", + "private static volatile Integer Integer26", + "private transient final Integer Integer27", + "private transient volatile Integer Integer28", + "persistence-modifier= none private transient volatile Integer Integer29", + "persistence-modifier= persistent private transient volatile Integer Integer30", + "persistence-modifier= persistent embedded= true private transient volatile Integer Integer31", + "persistence-modifier= persistent embedded= false private transient volatile Integer Integer32", + "persistence-modifier= transactional private transient volatile Integer Integer33", + "private static transient final Integer Integer34", + "private static transient volatile Integer Integer35", + "public Integer Integer36", + "embedded= true public Integer Integer37", + "embedded= false public Integer Integer38", + "persistence-modifier= none public Integer Integer39", + "persistence-modifier= persistent public Integer Integer40", + "persistence-modifier= persistent embedded= true public Integer Integer41", + "persistence-modifier= persistent embedded= false public Integer Integer42", + "persistence-modifier= transactional public Integer Integer43", + "public static Integer Integer44", + "public transient Integer Integer45", + "persistence-modifier= none public transient Integer Integer46", + "persistence-modifier= persistent public transient Integer Integer47", + "persistence-modifier= persistent embedded= true public transient Integer Integer48", + "persistence-modifier= persistent embedded= false public transient Integer Integer49", + "persistence-modifier= transactional public transient Integer Integer50", + "public final Integer Integer51", + "public volatile Integer Integer52", + "embedded= true public volatile Integer Integer53", + "embedded= false public volatile Integer Integer54", + "persistence-modifier= none public volatile Integer Integer55", + "persistence-modifier= persistent public volatile Integer Integer56", + "persistence-modifier= persistent embedded= true public volatile Integer Integer57", + "persistence-modifier= persistent embedded= false public volatile Integer Integer58", + "persistence-modifier= transactional public volatile Integer Integer59", + "public static transient Integer Integer60", + "public static final Integer Integer61", + "public static volatile Integer Integer62", + "public transient final Integer Integer63", + "public transient volatile Integer Integer64", + "persistence-modifier= none public transient volatile Integer Integer65", + "persistence-modifier= persistent public transient volatile Integer Integer66", + "persistence-modifier= persistent embedded= true public transient volatile Integer Integer67", + "persistence-modifier= persistent embedded= false public transient volatile Integer Integer68", + "persistence-modifier= transactional public transient volatile Integer Integer69", + "public static transient final Integer Integer70", + "public static transient volatile Integer Integer71", + "protected Integer Integer72", + "embedded= true protected Integer Integer73", + "embedded= false protected Integer Integer74", + "persistence-modifier= none protected Integer Integer75", + "persistence-modifier= persistent protected Integer Integer76", + "persistence-modifier= persistent embedded= true protected Integer Integer77", + "persistence-modifier= persistent embedded= false protected Integer Integer78", + "persistence-modifier= transactional protected Integer Integer79", + "protected static Integer Integer80", + "protected transient Integer Integer81", + "persistence-modifier= none protected transient Integer Integer82", + "persistence-modifier= persistent protected transient Integer Integer83", + "persistence-modifier= persistent embedded= true protected transient Integer Integer84", + "persistence-modifier= persistent embedded= false protected transient Integer Integer85", + "persistence-modifier= transactional protected transient Integer Integer86", + "protected final Integer Integer87", + "protected volatile Integer Integer88", + "embedded= true protected volatile Integer Integer89", + "embedded= false protected volatile Integer Integer90", + "persistence-modifier= none protected volatile Integer Integer91", + "persistence-modifier= persistent protected volatile Integer Integer92", + "persistence-modifier= persistent embedded= true protected volatile Integer Integer93", + "persistence-modifier= persistent embedded= false protected volatile Integer Integer94", + "persistence-modifier= transactional protected volatile Integer Integer95", + "protected static transient Integer Integer96", + "protected static final Integer Integer97", + "protected static volatile Integer Integer98", + "protected transient final Integer Integer99", + "protected transient volatile Integer Integer100", + "persistence-modifier= none protected transient volatile Integer Integer101", + "persistence-modifier= persistent protected transient volatile Integer Integer102", + "persistence-modifier= persistent embedded= true protected transient volatile Integer Integer103", + "persistence-modifier= persistent embedded= false protected transient volatile Integer Integer104", + "persistence-modifier= transactional protected transient volatile Integer Integer105", + "protected static transient final Integer Integer106", + "protected static transient volatile Integer Integer107", + "Integer Integer108", + "embedded= true Integer Integer109", + "embedded= false Integer Integer110", + "persistence-modifier= none Integer Integer111", + "persistence-modifier= persistent Integer Integer112", + "persistence-modifier= persistent embedded= true Integer Integer113", + "persistence-modifier= persistent embedded= false Integer Integer114", + "persistence-modifier= transactional Integer Integer115", + "static Integer Integer116", + "transient Integer Integer117", + "persistence-modifier= none transient Integer Integer118", + "persistence-modifier= persistent transient Integer Integer119", + "persistence-modifier= persistent embedded= true transient Integer Integer120", + "persistence-modifier= persistent embedded= false transient Integer Integer121", + "persistence-modifier= transactional transient Integer Integer122", + "final Integer Integer123", + "volatile Integer Integer124", + "embedded= true volatile Integer Integer125", + "embedded= false volatile Integer Integer126", + "persistence-modifier= none volatile Integer Integer127", + "persistence-modifier= persistent volatile Integer Integer128", + "persistence-modifier= persistent embedded= true volatile Integer Integer129", + "persistence-modifier= persistent embedded= false volatile Integer Integer130", + "persistence-modifier= transactional volatile Integer Integer131", + "static transient Integer Integer132", + "static final Integer Integer133", + "static volatile Integer Integer134", + "transient final Integer Integer135", + "transient volatile Integer Integer136", + "persistence-modifier= none transient volatile Integer Integer137", + "persistence-modifier= persistent transient volatile Integer Integer138", + "persistence-modifier= persistent embedded= true transient volatile Integer Integer139", + "persistence-modifier= persistent embedded= false transient volatile Integer Integer140", + "persistence-modifier= transactional transient volatile Integer Integer141", + "static transient final Integer Integer142", + "static transient volatile Integer Integer143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public Integer get(int index) { - switch (index) { - case (0): + public Integer get(int index) + { + switch (index) + { + case(0): return Integer0; - case (1): + case(1): return Integer1; - case (2): + case(2): return Integer2; - case (3): + case(3): return Integer3; - case (4): + case(4): return Integer4; - case (5): + case(5): return Integer5; - case (6): + case(6): return Integer6; - case (7): + case(7): return Integer7; - case (8): + case(8): return Integer8; - case (9): + case(9): return Integer9; - case (10): + case(10): return Integer10; - case (11): + case(11): return Integer11; - case (12): + case(12): return Integer12; - case (13): + case(13): return Integer13; - case (14): + case(14): return Integer14; - case (15): + case(15): return Integer15; - case (16): + case(16): return Integer16; - case (17): + case(17): return Integer17; - case (18): + case(18): return Integer18; - case (19): + case(19): return Integer19; - case (20): + case(20): return Integer20; - case (21): + case(21): return Integer21; - case (22): + case(22): return Integer22; - case (23): + case(23): return Integer23; - case (24): + case(24): return Integer24; - case (25): + case(25): return Integer25; - case (26): + case(26): return Integer26; - case (27): + case(27): return Integer27; - case (28): + case(28): return Integer28; - case (29): + case(29): return Integer29; - case (30): + case(30): return Integer30; - case (31): + case(31): return Integer31; - case (32): + case(32): return Integer32; - case (33): + case(33): return Integer33; - case (34): + case(34): return Integer34; - case (35): + case(35): return Integer35; - case (36): + case(36): return Integer36; - case (37): + case(37): return Integer37; - case (38): + case(38): return Integer38; - case (39): + case(39): return Integer39; - case (40): + case(40): return Integer40; - case (41): + case(41): return Integer41; - case (42): + case(42): return Integer42; - case (43): + case(43): return Integer43; - case (44): + case(44): return Integer44; - case (45): + case(45): return Integer45; - case (46): + case(46): return Integer46; - case (47): + case(47): return Integer47; - case (48): + case(48): return Integer48; - case (49): + case(49): return Integer49; - case (50): + case(50): return Integer50; - case (51): + case(51): return Integer51; - case (52): + case(52): return Integer52; - case (53): + case(53): return Integer53; - case (54): + case(54): return Integer54; - case (55): + case(55): return Integer55; - case (56): + case(56): return Integer56; - case (57): + case(57): return Integer57; - case (58): + case(58): return Integer58; - case (59): + case(59): return Integer59; - case (60): + case(60): return Integer60; - case (61): + case(61): return Integer61; - case (62): + case(62): return Integer62; - case (63): + case(63): return Integer63; - case (64): + case(64): return Integer64; - case (65): + case(65): return Integer65; - case (66): + case(66): return Integer66; - case (67): + case(67): return Integer67; - case (68): + case(68): return Integer68; - case (69): + case(69): return Integer69; - case (70): + case(70): return Integer70; - case (71): + case(71): return Integer71; - case (72): + case(72): return Integer72; - case (73): + case(73): return Integer73; - case (74): + case(74): return Integer74; - case (75): + case(75): return Integer75; - case (76): + case(76): return Integer76; - case (77): + case(77): return Integer77; - case (78): + case(78): return Integer78; - case (79): + case(79): return Integer79; - case (80): + case(80): return Integer80; - case (81): + case(81): return Integer81; - case (82): + case(82): return Integer82; - case (83): + case(83): return Integer83; - case (84): + case(84): return Integer84; - case (85): + case(85): return Integer85; - case (86): + case(86): return Integer86; - case (87): + case(87): return Integer87; - case (88): + case(88): return Integer88; - case (89): + case(89): return Integer89; - case (90): + case(90): return Integer90; - case (91): + case(91): return Integer91; - case (92): + case(92): return Integer92; - case (93): + case(93): return Integer93; - case (94): + case(94): return Integer94; - case (95): + case(95): return Integer95; - case (96): + case(96): return Integer96; - case (97): + case(97): return Integer97; - case (98): + case(98): return Integer98; - case (99): + case(99): return Integer99; - case (100): + case(100): return Integer100; - case (101): + case(101): return Integer101; - case (102): + case(102): return Integer102; - case (103): + case(103): return Integer103; - case (104): + case(104): return Integer104; - case (105): + case(105): return Integer105; - case (106): + case(106): return Integer106; - case (107): + case(107): return Integer107; - case (108): + case(108): return Integer108; - case (109): + case(109): return Integer109; - case (110): + case(110): return Integer110; - case (111): + case(111): return Integer111; - case (112): + case(112): return Integer112; - case (113): + case(113): return Integer113; - case (114): + case(114): return Integer114; - case (115): + case(115): return Integer115; - case (116): + case(116): return Integer116; - case (117): + case(117): return Integer117; - case (118): + case(118): return Integer118; - case (119): + case(119): return Integer119; - case (120): + case(120): return Integer120; - case (121): + case(121): return Integer121; - case (122): + case(122): return Integer122; - case (123): + case(123): return Integer123; - case (124): + case(124): return Integer124; - case (125): + case(125): return Integer125; - case (126): + case(126): return Integer126; - case (127): + case(127): return Integer127; - case (128): + case(128): return Integer128; - case (129): + case(129): return Integer129; - case (130): + case(130): return Integer130; - case (131): + case(131): return Integer131; - case (132): + case(132): return Integer132; - case (133): + case(133): return Integer133; - case (134): + case(134): return Integer134; - case (135): + case(135): return Integer135; - case (136): + case(136): return Integer136; - case (137): + case(137): return Integer137; - case (138): + case(138): return Integer138; - case (139): + case(139): return Integer139; - case (140): + case(140): return Integer140; - case (141): + case(141): return Integer141; - case (142): + case(142): return Integer142; - case (143): + case(143): return Integer143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, Integer value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - Integer0 = value; - break; - case (1): - Integer1 = value; - break; - case (2): - Integer2 = value; - break; - case (3): - Integer3 = value; - break; - case (4): - Integer4 = value; - break; - case (5): - Integer5 = value; - break; - case (6): - Integer6 = value; - break; - case (7): - Integer7 = value; - break; - case (8): - Integer8 = value; - break; - case (9): - Integer9 = value; - break; - case (10): - Integer10 = value; - break; - case (11): - Integer11 = value; - break; - case (12): - Integer12 = value; - break; - case (13): - Integer13 = value; - break; - case (14): - Integer14 = value; - break; - case (16): - Integer16 = value; - break; - case (17): - Integer17 = value; - break; - case (18): - Integer18 = value; - break; - case (19): - Integer19 = value; - break; - case (20): - Integer20 = value; - break; - case (21): - Integer21 = value; - break; - case (22): - Integer22 = value; - break; - case (23): - Integer23 = value; - break; - case (24): - Integer24 = value; - break; - case (26): - Integer26 = value; - break; - case (28): - Integer28 = value; - break; - case (29): - Integer29 = value; - break; - case (30): - Integer30 = value; - break; - case (31): - Integer31 = value; - break; - case (32): - Integer32 = value; - break; - case (33): - Integer33 = value; - break; - case (35): - Integer35 = value; - break; - case (36): - Integer36 = value; - break; - case (37): - Integer37 = value; - break; - case (38): - Integer38 = value; - break; - case (39): - Integer39 = value; - break; - case (40): - Integer40 = value; - break; - case (41): - Integer41 = value; - break; - case (42): - Integer42 = value; - break; - case (43): - Integer43 = value; - break; - case (44): - Integer44 = value; - break; - case (45): - Integer45 = value; - break; - case (46): - Integer46 = value; - break; - case (47): - Integer47 = value; - break; - case (48): - Integer48 = value; - break; - case (49): - Integer49 = value; - break; - case (50): - Integer50 = value; - break; - case (52): - Integer52 = value; - break; - case (53): - Integer53 = value; - break; - case (54): - Integer54 = value; - break; - case (55): - Integer55 = value; - break; - case (56): - Integer56 = value; - break; - case (57): - Integer57 = value; - break; - case (58): - Integer58 = value; - break; - case (59): - Integer59 = value; - break; - case (60): - Integer60 = value; - break; - case (62): - Integer62 = value; - break; - case (64): - Integer64 = value; - break; - case (65): - Integer65 = value; - break; - case (66): - Integer66 = value; - break; - case (67): - Integer67 = value; - break; - case (68): - Integer68 = value; - break; - case (69): - Integer69 = value; - break; - case (71): - Integer71 = value; - break; - case (72): - Integer72 = value; - break; - case (73): - Integer73 = value; - break; - case (74): - Integer74 = value; - break; - case (75): - Integer75 = value; - break; - case (76): - Integer76 = value; - break; - case (77): - Integer77 = value; - break; - case (78): - Integer78 = value; - break; - case (79): - Integer79 = value; - break; - case (80): - Integer80 = value; - break; - case (81): - Integer81 = value; - break; - case (82): - Integer82 = value; - break; - case (83): - Integer83 = value; - break; - case (84): - Integer84 = value; - break; - case (85): - Integer85 = value; - break; - case (86): - Integer86 = value; - break; - case (88): - Integer88 = value; - break; - case (89): - Integer89 = value; - break; - case (90): - Integer90 = value; - break; - case (91): - Integer91 = value; - break; - case (92): - Integer92 = value; - break; - case (93): - Integer93 = value; - break; - case (94): - Integer94 = value; - break; - case (95): - Integer95 = value; - break; - case (96): - Integer96 = value; - break; - case (98): - Integer98 = value; - break; - case (100): - Integer100 = value; - break; - case (101): - Integer101 = value; - break; - case (102): - Integer102 = value; - break; - case (103): - Integer103 = value; - break; - case (104): - Integer104 = value; - break; - case (105): - Integer105 = value; - break; - case (107): - Integer107 = value; - break; - case (108): - Integer108 = value; - break; - case (109): - Integer109 = value; - break; - case (110): - Integer110 = value; - break; - case (111): - Integer111 = value; - break; - case (112): - Integer112 = value; - break; - case (113): - Integer113 = value; - break; - case (114): - Integer114 = value; - break; - case (115): - Integer115 = value; - break; - case (116): - Integer116 = value; - break; - case (117): - Integer117 = value; - break; - case (118): - Integer118 = value; - break; - case (119): - Integer119 = value; - break; - case (120): - Integer120 = value; - break; - case (121): - Integer121 = value; - break; - case (122): - Integer122 = value; - break; - case (124): - Integer124 = value; - break; - case (125): - Integer125 = value; - break; - case (126): - Integer126 = value; - break; - case (127): - Integer127 = value; - break; - case (128): - Integer128 = value; - break; - case (129): - Integer129 = value; - break; - case (130): - Integer130 = value; - break; - case (131): - Integer131 = value; - break; - case (132): - Integer132 = value; - break; - case (134): - Integer134 = value; - break; - case (136): - Integer136 = value; - break; - case (137): - Integer137 = value; - break; - case (138): - Integer138 = value; - break; - case (139): - Integer139 = value; - break; - case (140): - Integer140 = value; - break; - case (141): - Integer141 = value; - break; - case (143): - Integer143 = value; - break; + public boolean set(int index,Integer value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + Integer0= value; + break; + case(1): + Integer1= value; + break; + case(2): + Integer2= value; + break; + case(3): + Integer3= value; + break; + case(4): + Integer4= value; + break; + case(5): + Integer5= value; + break; + case(6): + Integer6= value; + break; + case(7): + Integer7= value; + break; + case(8): + Integer8= value; + break; + case(9): + Integer9= value; + break; + case(10): + Integer10= value; + break; + case(11): + Integer11= value; + break; + case(12): + Integer12= value; + break; + case(13): + Integer13= value; + break; + case(14): + Integer14= value; + break; + case(16): + Integer16= value; + break; + case(17): + Integer17= value; + break; + case(18): + Integer18= value; + break; + case(19): + Integer19= value; + break; + case(20): + Integer20= value; + break; + case(21): + Integer21= value; + break; + case(22): + Integer22= value; + break; + case(23): + Integer23= value; + break; + case(24): + Integer24= value; + break; + case(26): + Integer26= value; + break; + case(28): + Integer28= value; + break; + case(29): + Integer29= value; + break; + case(30): + Integer30= value; + break; + case(31): + Integer31= value; + break; + case(32): + Integer32= value; + break; + case(33): + Integer33= value; + break; + case(35): + Integer35= value; + break; + case(36): + Integer36= value; + break; + case(37): + Integer37= value; + break; + case(38): + Integer38= value; + break; + case(39): + Integer39= value; + break; + case(40): + Integer40= value; + break; + case(41): + Integer41= value; + break; + case(42): + Integer42= value; + break; + case(43): + Integer43= value; + break; + case(44): + Integer44= value; + break; + case(45): + Integer45= value; + break; + case(46): + Integer46= value; + break; + case(47): + Integer47= value; + break; + case(48): + Integer48= value; + break; + case(49): + Integer49= value; + break; + case(50): + Integer50= value; + break; + case(52): + Integer52= value; + break; + case(53): + Integer53= value; + break; + case(54): + Integer54= value; + break; + case(55): + Integer55= value; + break; + case(56): + Integer56= value; + break; + case(57): + Integer57= value; + break; + case(58): + Integer58= value; + break; + case(59): + Integer59= value; + break; + case(60): + Integer60= value; + break; + case(62): + Integer62= value; + break; + case(64): + Integer64= value; + break; + case(65): + Integer65= value; + break; + case(66): + Integer66= value; + break; + case(67): + Integer67= value; + break; + case(68): + Integer68= value; + break; + case(69): + Integer69= value; + break; + case(71): + Integer71= value; + break; + case(72): + Integer72= value; + break; + case(73): + Integer73= value; + break; + case(74): + Integer74= value; + break; + case(75): + Integer75= value; + break; + case(76): + Integer76= value; + break; + case(77): + Integer77= value; + break; + case(78): + Integer78= value; + break; + case(79): + Integer79= value; + break; + case(80): + Integer80= value; + break; + case(81): + Integer81= value; + break; + case(82): + Integer82= value; + break; + case(83): + Integer83= value; + break; + case(84): + Integer84= value; + break; + case(85): + Integer85= value; + break; + case(86): + Integer86= value; + break; + case(88): + Integer88= value; + break; + case(89): + Integer89= value; + break; + case(90): + Integer90= value; + break; + case(91): + Integer91= value; + break; + case(92): + Integer92= value; + break; + case(93): + Integer93= value; + break; + case(94): + Integer94= value; + break; + case(95): + Integer95= value; + break; + case(96): + Integer96= value; + break; + case(98): + Integer98= value; + break; + case(100): + Integer100= value; + break; + case(101): + Integer101= value; + break; + case(102): + Integer102= value; + break; + case(103): + Integer103= value; + break; + case(104): + Integer104= value; + break; + case(105): + Integer105= value; + break; + case(107): + Integer107= value; + break; + case(108): + Integer108= value; + break; + case(109): + Integer109= value; + break; + case(110): + Integer110= value; + break; + case(111): + Integer111= value; + break; + case(112): + Integer112= value; + break; + case(113): + Integer113= value; + break; + case(114): + Integer114= value; + break; + case(115): + Integer115= value; + break; + case(116): + Integer116= value; + break; + case(117): + Integer117= value; + break; + case(118): + Integer118= value; + break; + case(119): + Integer119= value; + break; + case(120): + Integer120= value; + break; + case(121): + Integer121= value; + break; + case(122): + Integer122= value; + break; + case(124): + Integer124= value; + break; + case(125): + Integer125= value; + break; + case(126): + Integer126= value; + break; + case(127): + Integer127= value; + break; + case(128): + Integer128= value; + break; + case(129): + Integer129= value; + break; + case(130): + Integer130= value; + break; + case(131): + Integer131= value; + break; + case(132): + Integer132= value; + break; + case(134): + Integer134= value; + break; + case(136): + Integer136= value; + break; + case(137): + Integer137= value; + break; + case(138): + Integer138= value; + break; + case(139): + Integer139= value; + break; + case(140): + Integer140= value; + break; + case(141): + Integer141= value; + break; + case(143): + Integer143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } - - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public int hashCode() { - return (int) identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public int hashCode() { return (int)identifier ; } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfLocale.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfLocale.java index 86e914633..5d21c4747 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfLocale.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfLocale.java @@ -5,22 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -import java.util.Locale; -public class FieldsOfLocale { +import java.util.*; +public class FieldsOfLocale { public int identifier; private Locale Locale0; private Locale Locale1; @@ -49,14 +49,14 @@ public class FieldsOfLocale { private static transient Locale Locale24; private static final Locale Locale25 = Locale.US; private static volatile Locale Locale26; - private final transient Locale Locale27 = Locale.US; + private transient final Locale Locale27 = Locale.US; private transient volatile Locale Locale28; private transient volatile Locale Locale29; private transient volatile Locale Locale30; private transient volatile Locale Locale31; private transient volatile Locale Locale32; private transient volatile Locale Locale33; - private static final transient Locale Locale34 = Locale.US; + private static transient final Locale Locale34 = Locale.US; private static transient volatile Locale Locale35; public Locale Locale36; public Locale Locale37; @@ -85,14 +85,14 @@ public class FieldsOfLocale { public static transient Locale Locale60; public static final Locale Locale61 = Locale.US; public static volatile Locale Locale62; - public final transient Locale Locale63 = Locale.US; + public transient final Locale Locale63 = Locale.US; public transient volatile Locale Locale64; public transient volatile Locale Locale65; public transient volatile Locale Locale66; public transient volatile Locale Locale67; public transient volatile Locale Locale68; public transient volatile Locale Locale69; - public static final transient Locale Locale70 = Locale.US; + public static transient final Locale Locale70 = Locale.US; public static transient volatile Locale Locale71; protected Locale Locale72; protected Locale Locale73; @@ -121,14 +121,14 @@ public class FieldsOfLocale { protected static transient Locale Locale96; protected static final Locale Locale97 = Locale.US; protected static volatile Locale Locale98; - protected final transient Locale Locale99 = Locale.US; + protected transient final Locale Locale99 = Locale.US; protected transient volatile Locale Locale100; protected transient volatile Locale Locale101; protected transient volatile Locale Locale102; protected transient volatile Locale Locale103; protected transient volatile Locale Locale104; protected transient volatile Locale Locale105; - protected static final transient Locale Locale106 = Locale.US; + protected static transient final Locale Locale106 = Locale.US; protected static transient volatile Locale Locale107; Locale Locale108; Locale Locale109; @@ -157,936 +157,935 @@ public class FieldsOfLocale { static transient Locale Locale132; static final Locale Locale133 = Locale.US; static volatile Locale Locale134; - final transient Locale Locale135 = Locale.US; + transient final Locale Locale135 = Locale.US; transient volatile Locale Locale136; transient volatile Locale Locale137; transient volatile Locale Locale138; transient volatile Locale Locale139; transient volatile Locale Locale140; transient volatile Locale Locale141; - static final transient Locale Locale142 = Locale.US; + static transient final Locale Locale142 = Locale.US; static transient volatile Locale Locale143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private Locale Locale0", - "embedded= true private Locale Locale1", - "embedded= false private Locale Locale2", - "persistence-modifier= none private Locale Locale3", - "persistence-modifier= persistent private Locale Locale4", - "persistence-modifier= persistent embedded= true private Locale Locale5", - "persistence-modifier= persistent embedded= false private Locale Locale6", - "persistence-modifier= transactional private Locale Locale7", - "private static Locale Locale8", - "private transient Locale Locale9", - "persistence-modifier= none private transient Locale Locale10", - "persistence-modifier= persistent private transient Locale Locale11", - "persistence-modifier= persistent embedded= true private transient Locale Locale12", - "persistence-modifier= persistent embedded= false private transient Locale Locale13", - "persistence-modifier= transactional private transient Locale Locale14", - "private final Locale Locale15", - "private volatile Locale Locale16", - "embedded= true private volatile Locale Locale17", - "embedded= false private volatile Locale Locale18", - "persistence-modifier= none private volatile Locale Locale19", - "persistence-modifier= persistent private volatile Locale Locale20", - "persistence-modifier= persistent embedded= true private volatile Locale Locale21", - "persistence-modifier= persistent embedded= false private volatile Locale Locale22", - "persistence-modifier= transactional private volatile Locale Locale23", - "private static transient Locale Locale24", - "private static final Locale Locale25", - "private static volatile Locale Locale26", - "private transient final Locale Locale27", - "private transient volatile Locale Locale28", - "persistence-modifier= none private transient volatile Locale Locale29", - "persistence-modifier= persistent private transient volatile Locale Locale30", - "persistence-modifier= persistent embedded= true private transient volatile Locale Locale31", - "persistence-modifier= persistent embedded= false private transient volatile Locale Locale32", - "persistence-modifier= transactional private transient volatile Locale Locale33", - "private static transient final Locale Locale34", - "private static transient volatile Locale Locale35", - "public Locale Locale36", - "embedded= true public Locale Locale37", - "embedded= false public Locale Locale38", - "persistence-modifier= none public Locale Locale39", - "persistence-modifier= persistent public Locale Locale40", - "persistence-modifier= persistent embedded= true public Locale Locale41", - "persistence-modifier= persistent embedded= false public Locale Locale42", - "persistence-modifier= transactional public Locale Locale43", - "public static Locale Locale44", - "public transient Locale Locale45", - "persistence-modifier= none public transient Locale Locale46", - "persistence-modifier= persistent public transient Locale Locale47", - "persistence-modifier= persistent embedded= true public transient Locale Locale48", - "persistence-modifier= persistent embedded= false public transient Locale Locale49", - "persistence-modifier= transactional public transient Locale Locale50", - "public final Locale Locale51", - "public volatile Locale Locale52", - "embedded= true public volatile Locale Locale53", - "embedded= false public volatile Locale Locale54", - "persistence-modifier= none public volatile Locale Locale55", - "persistence-modifier= persistent public volatile Locale Locale56", - "persistence-modifier= persistent embedded= true public volatile Locale Locale57", - "persistence-modifier= persistent embedded= false public volatile Locale Locale58", - "persistence-modifier= transactional public volatile Locale Locale59", - "public static transient Locale Locale60", - "public static final Locale Locale61", - "public static volatile Locale Locale62", - "public transient final Locale Locale63", - "public transient volatile Locale Locale64", - "persistence-modifier= none public transient volatile Locale Locale65", - "persistence-modifier= persistent public transient volatile Locale Locale66", - "persistence-modifier= persistent embedded= true public transient volatile Locale Locale67", - "persistence-modifier= persistent embedded= false public transient volatile Locale Locale68", - "persistence-modifier= transactional public transient volatile Locale Locale69", - "public static transient final Locale Locale70", - "public static transient volatile Locale Locale71", - "protected Locale Locale72", - "embedded= true protected Locale Locale73", - "embedded= false protected Locale Locale74", - "persistence-modifier= none protected Locale Locale75", - "persistence-modifier= persistent protected Locale Locale76", - "persistence-modifier= persistent embedded= true protected Locale Locale77", - "persistence-modifier= persistent embedded= false protected Locale Locale78", - "persistence-modifier= transactional protected Locale Locale79", - "protected static Locale Locale80", - "protected transient Locale Locale81", - "persistence-modifier= none protected transient Locale Locale82", - "persistence-modifier= persistent protected transient Locale Locale83", - "persistence-modifier= persistent embedded= true protected transient Locale Locale84", - "persistence-modifier= persistent embedded= false protected transient Locale Locale85", - "persistence-modifier= transactional protected transient Locale Locale86", - "protected final Locale Locale87", - "protected volatile Locale Locale88", - "embedded= true protected volatile Locale Locale89", - "embedded= false protected volatile Locale Locale90", - "persistence-modifier= none protected volatile Locale Locale91", - "persistence-modifier= persistent protected volatile Locale Locale92", - "persistence-modifier= persistent embedded= true protected volatile Locale Locale93", - "persistence-modifier= persistent embedded= false protected volatile Locale Locale94", - "persistence-modifier= transactional protected volatile Locale Locale95", - "protected static transient Locale Locale96", - "protected static final Locale Locale97", - "protected static volatile Locale Locale98", - "protected transient final Locale Locale99", - "protected transient volatile Locale Locale100", - "persistence-modifier= none protected transient volatile Locale Locale101", - "persistence-modifier= persistent protected transient volatile Locale Locale102", - "persistence-modifier= persistent embedded= true protected transient volatile Locale Locale103", - "persistence-modifier= persistent embedded= false protected transient volatile Locale Locale104", - "persistence-modifier= transactional protected transient volatile Locale Locale105", - "protected static transient final Locale Locale106", - "protected static transient volatile Locale Locale107", - "Locale Locale108", - "embedded= true Locale Locale109", - "embedded= false Locale Locale110", - "persistence-modifier= none Locale Locale111", - "persistence-modifier= persistent Locale Locale112", - "persistence-modifier= persistent embedded= true Locale Locale113", - "persistence-modifier= persistent embedded= false Locale Locale114", - "persistence-modifier= transactional Locale Locale115", - "static Locale Locale116", - "transient Locale Locale117", - "persistence-modifier= none transient Locale Locale118", - "persistence-modifier= persistent transient Locale Locale119", - "persistence-modifier= persistent embedded= true transient Locale Locale120", - "persistence-modifier= persistent embedded= false transient Locale Locale121", - "persistence-modifier= transactional transient Locale Locale122", - "final Locale Locale123", - "volatile Locale Locale124", - "embedded= true volatile Locale Locale125", - "embedded= false volatile Locale Locale126", - "persistence-modifier= none volatile Locale Locale127", - "persistence-modifier= persistent volatile Locale Locale128", - "persistence-modifier= persistent embedded= true volatile Locale Locale129", - "persistence-modifier= persistent embedded= false volatile Locale Locale130", - "persistence-modifier= transactional volatile Locale Locale131", - "static transient Locale Locale132", - "static final Locale Locale133", - "static volatile Locale Locale134", - "transient final Locale Locale135", - "transient volatile Locale Locale136", - "persistence-modifier= none transient volatile Locale Locale137", - "persistence-modifier= persistent transient volatile Locale Locale138", - "persistence-modifier= persistent embedded= true transient volatile Locale Locale139", - "persistence-modifier= persistent embedded= false transient volatile Locale Locale140", - "persistence-modifier= transactional transient volatile Locale Locale141", - "static transient final Locale Locale142", - "static transient volatile Locale Locale143" + public static final String [] fieldSpecs = { + "private Locale Locale0", + "embedded= true private Locale Locale1", + "embedded= false private Locale Locale2", + "persistence-modifier= none private Locale Locale3", + "persistence-modifier= persistent private Locale Locale4", + "persistence-modifier= persistent embedded= true private Locale Locale5", + "persistence-modifier= persistent embedded= false private Locale Locale6", + "persistence-modifier= transactional private Locale Locale7", + "private static Locale Locale8", + "private transient Locale Locale9", + "persistence-modifier= none private transient Locale Locale10", + "persistence-modifier= persistent private transient Locale Locale11", + "persistence-modifier= persistent embedded= true private transient Locale Locale12", + "persistence-modifier= persistent embedded= false private transient Locale Locale13", + "persistence-modifier= transactional private transient Locale Locale14", + "private final Locale Locale15", + "private volatile Locale Locale16", + "embedded= true private volatile Locale Locale17", + "embedded= false private volatile Locale Locale18", + "persistence-modifier= none private volatile Locale Locale19", + "persistence-modifier= persistent private volatile Locale Locale20", + "persistence-modifier= persistent embedded= true private volatile Locale Locale21", + "persistence-modifier= persistent embedded= false private volatile Locale Locale22", + "persistence-modifier= transactional private volatile Locale Locale23", + "private static transient Locale Locale24", + "private static final Locale Locale25", + "private static volatile Locale Locale26", + "private transient final Locale Locale27", + "private transient volatile Locale Locale28", + "persistence-modifier= none private transient volatile Locale Locale29", + "persistence-modifier= persistent private transient volatile Locale Locale30", + "persistence-modifier= persistent embedded= true private transient volatile Locale Locale31", + "persistence-modifier= persistent embedded= false private transient volatile Locale Locale32", + "persistence-modifier= transactional private transient volatile Locale Locale33", + "private static transient final Locale Locale34", + "private static transient volatile Locale Locale35", + "public Locale Locale36", + "embedded= true public Locale Locale37", + "embedded= false public Locale Locale38", + "persistence-modifier= none public Locale Locale39", + "persistence-modifier= persistent public Locale Locale40", + "persistence-modifier= persistent embedded= true public Locale Locale41", + "persistence-modifier= persistent embedded= false public Locale Locale42", + "persistence-modifier= transactional public Locale Locale43", + "public static Locale Locale44", + "public transient Locale Locale45", + "persistence-modifier= none public transient Locale Locale46", + "persistence-modifier= persistent public transient Locale Locale47", + "persistence-modifier= persistent embedded= true public transient Locale Locale48", + "persistence-modifier= persistent embedded= false public transient Locale Locale49", + "persistence-modifier= transactional public transient Locale Locale50", + "public final Locale Locale51", + "public volatile Locale Locale52", + "embedded= true public volatile Locale Locale53", + "embedded= false public volatile Locale Locale54", + "persistence-modifier= none public volatile Locale Locale55", + "persistence-modifier= persistent public volatile Locale Locale56", + "persistence-modifier= persistent embedded= true public volatile Locale Locale57", + "persistence-modifier= persistent embedded= false public volatile Locale Locale58", + "persistence-modifier= transactional public volatile Locale Locale59", + "public static transient Locale Locale60", + "public static final Locale Locale61", + "public static volatile Locale Locale62", + "public transient final Locale Locale63", + "public transient volatile Locale Locale64", + "persistence-modifier= none public transient volatile Locale Locale65", + "persistence-modifier= persistent public transient volatile Locale Locale66", + "persistence-modifier= persistent embedded= true public transient volatile Locale Locale67", + "persistence-modifier= persistent embedded= false public transient volatile Locale Locale68", + "persistence-modifier= transactional public transient volatile Locale Locale69", + "public static transient final Locale Locale70", + "public static transient volatile Locale Locale71", + "protected Locale Locale72", + "embedded= true protected Locale Locale73", + "embedded= false protected Locale Locale74", + "persistence-modifier= none protected Locale Locale75", + "persistence-modifier= persistent protected Locale Locale76", + "persistence-modifier= persistent embedded= true protected Locale Locale77", + "persistence-modifier= persistent embedded= false protected Locale Locale78", + "persistence-modifier= transactional protected Locale Locale79", + "protected static Locale Locale80", + "protected transient Locale Locale81", + "persistence-modifier= none protected transient Locale Locale82", + "persistence-modifier= persistent protected transient Locale Locale83", + "persistence-modifier= persistent embedded= true protected transient Locale Locale84", + "persistence-modifier= persistent embedded= false protected transient Locale Locale85", + "persistence-modifier= transactional protected transient Locale Locale86", + "protected final Locale Locale87", + "protected volatile Locale Locale88", + "embedded= true protected volatile Locale Locale89", + "embedded= false protected volatile Locale Locale90", + "persistence-modifier= none protected volatile Locale Locale91", + "persistence-modifier= persistent protected volatile Locale Locale92", + "persistence-modifier= persistent embedded= true protected volatile Locale Locale93", + "persistence-modifier= persistent embedded= false protected volatile Locale Locale94", + "persistence-modifier= transactional protected volatile Locale Locale95", + "protected static transient Locale Locale96", + "protected static final Locale Locale97", + "protected static volatile Locale Locale98", + "protected transient final Locale Locale99", + "protected transient volatile Locale Locale100", + "persistence-modifier= none protected transient volatile Locale Locale101", + "persistence-modifier= persistent protected transient volatile Locale Locale102", + "persistence-modifier= persistent embedded= true protected transient volatile Locale Locale103", + "persistence-modifier= persistent embedded= false protected transient volatile Locale Locale104", + "persistence-modifier= transactional protected transient volatile Locale Locale105", + "protected static transient final Locale Locale106", + "protected static transient volatile Locale Locale107", + "Locale Locale108", + "embedded= true Locale Locale109", + "embedded= false Locale Locale110", + "persistence-modifier= none Locale Locale111", + "persistence-modifier= persistent Locale Locale112", + "persistence-modifier= persistent embedded= true Locale Locale113", + "persistence-modifier= persistent embedded= false Locale Locale114", + "persistence-modifier= transactional Locale Locale115", + "static Locale Locale116", + "transient Locale Locale117", + "persistence-modifier= none transient Locale Locale118", + "persistence-modifier= persistent transient Locale Locale119", + "persistence-modifier= persistent embedded= true transient Locale Locale120", + "persistence-modifier= persistent embedded= false transient Locale Locale121", + "persistence-modifier= transactional transient Locale Locale122", + "final Locale Locale123", + "volatile Locale Locale124", + "embedded= true volatile Locale Locale125", + "embedded= false volatile Locale Locale126", + "persistence-modifier= none volatile Locale Locale127", + "persistence-modifier= persistent volatile Locale Locale128", + "persistence-modifier= persistent embedded= true volatile Locale Locale129", + "persistence-modifier= persistent embedded= false volatile Locale Locale130", + "persistence-modifier= transactional volatile Locale Locale131", + "static transient Locale Locale132", + "static final Locale Locale133", + "static volatile Locale Locale134", + "transient final Locale Locale135", + "transient volatile Locale Locale136", + "persistence-modifier= none transient volatile Locale Locale137", + "persistence-modifier= persistent transient volatile Locale Locale138", + "persistence-modifier= persistent embedded= true transient volatile Locale Locale139", + "persistence-modifier= persistent embedded= false transient volatile Locale Locale140", + "persistence-modifier= transactional transient volatile Locale Locale141", + "static transient final Locale Locale142", + "static transient volatile Locale Locale143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public Locale get(int index) { - switch (index) { - case (0): + public Locale get(int index) + { + switch (index) + { + case(0): return Locale0; - case (1): + case(1): return Locale1; - case (2): + case(2): return Locale2; - case (3): + case(3): return Locale3; - case (4): + case(4): return Locale4; - case (5): + case(5): return Locale5; - case (6): + case(6): return Locale6; - case (7): + case(7): return Locale7; - case (8): + case(8): return Locale8; - case (9): + case(9): return Locale9; - case (10): + case(10): return Locale10; - case (11): + case(11): return Locale11; - case (12): + case(12): return Locale12; - case (13): + case(13): return Locale13; - case (14): + case(14): return Locale14; - case (15): + case(15): return Locale15; - case (16): + case(16): return Locale16; - case (17): + case(17): return Locale17; - case (18): + case(18): return Locale18; - case (19): + case(19): return Locale19; - case (20): + case(20): return Locale20; - case (21): + case(21): return Locale21; - case (22): + case(22): return Locale22; - case (23): + case(23): return Locale23; - case (24): + case(24): return Locale24; - case (25): + case(25): return Locale25; - case (26): + case(26): return Locale26; - case (27): + case(27): return Locale27; - case (28): + case(28): return Locale28; - case (29): + case(29): return Locale29; - case (30): + case(30): return Locale30; - case (31): + case(31): return Locale31; - case (32): + case(32): return Locale32; - case (33): + case(33): return Locale33; - case (34): + case(34): return Locale34; - case (35): + case(35): return Locale35; - case (36): + case(36): return Locale36; - case (37): + case(37): return Locale37; - case (38): + case(38): return Locale38; - case (39): + case(39): return Locale39; - case (40): + case(40): return Locale40; - case (41): + case(41): return Locale41; - case (42): + case(42): return Locale42; - case (43): + case(43): return Locale43; - case (44): + case(44): return Locale44; - case (45): + case(45): return Locale45; - case (46): + case(46): return Locale46; - case (47): + case(47): return Locale47; - case (48): + case(48): return Locale48; - case (49): + case(49): return Locale49; - case (50): + case(50): return Locale50; - case (51): + case(51): return Locale51; - case (52): + case(52): return Locale52; - case (53): + case(53): return Locale53; - case (54): + case(54): return Locale54; - case (55): + case(55): return Locale55; - case (56): + case(56): return Locale56; - case (57): + case(57): return Locale57; - case (58): + case(58): return Locale58; - case (59): + case(59): return Locale59; - case (60): + case(60): return Locale60; - case (61): + case(61): return Locale61; - case (62): + case(62): return Locale62; - case (63): + case(63): return Locale63; - case (64): + case(64): return Locale64; - case (65): + case(65): return Locale65; - case (66): + case(66): return Locale66; - case (67): + case(67): return Locale67; - case (68): + case(68): return Locale68; - case (69): + case(69): return Locale69; - case (70): + case(70): return Locale70; - case (71): + case(71): return Locale71; - case (72): + case(72): return Locale72; - case (73): + case(73): return Locale73; - case (74): + case(74): return Locale74; - case (75): + case(75): return Locale75; - case (76): + case(76): return Locale76; - case (77): + case(77): return Locale77; - case (78): + case(78): return Locale78; - case (79): + case(79): return Locale79; - case (80): + case(80): return Locale80; - case (81): + case(81): return Locale81; - case (82): + case(82): return Locale82; - case (83): + case(83): return Locale83; - case (84): + case(84): return Locale84; - case (85): + case(85): return Locale85; - case (86): + case(86): return Locale86; - case (87): + case(87): return Locale87; - case (88): + case(88): return Locale88; - case (89): + case(89): return Locale89; - case (90): + case(90): return Locale90; - case (91): + case(91): return Locale91; - case (92): + case(92): return Locale92; - case (93): + case(93): return Locale93; - case (94): + case(94): return Locale94; - case (95): + case(95): return Locale95; - case (96): + case(96): return Locale96; - case (97): + case(97): return Locale97; - case (98): + case(98): return Locale98; - case (99): + case(99): return Locale99; - case (100): + case(100): return Locale100; - case (101): + case(101): return Locale101; - case (102): + case(102): return Locale102; - case (103): + case(103): return Locale103; - case (104): + case(104): return Locale104; - case (105): + case(105): return Locale105; - case (106): + case(106): return Locale106; - case (107): + case(107): return Locale107; - case (108): + case(108): return Locale108; - case (109): + case(109): return Locale109; - case (110): + case(110): return Locale110; - case (111): + case(111): return Locale111; - case (112): + case(112): return Locale112; - case (113): + case(113): return Locale113; - case (114): + case(114): return Locale114; - case (115): + case(115): return Locale115; - case (116): + case(116): return Locale116; - case (117): + case(117): return Locale117; - case (118): + case(118): return Locale118; - case (119): + case(119): return Locale119; - case (120): + case(120): return Locale120; - case (121): + case(121): return Locale121; - case (122): + case(122): return Locale122; - case (123): + case(123): return Locale123; - case (124): + case(124): return Locale124; - case (125): + case(125): return Locale125; - case (126): + case(126): return Locale126; - case (127): + case(127): return Locale127; - case (128): + case(128): return Locale128; - case (129): + case(129): return Locale129; - case (130): + case(130): return Locale130; - case (131): + case(131): return Locale131; - case (132): + case(132): return Locale132; - case (133): + case(133): return Locale133; - case (134): + case(134): return Locale134; - case (135): + case(135): return Locale135; - case (136): + case(136): return Locale136; - case (137): + case(137): return Locale137; - case (138): + case(138): return Locale138; - case (139): + case(139): return Locale139; - case (140): + case(140): return Locale140; - case (141): + case(141): return Locale141; - case (142): + case(142): return Locale142; - case (143): + case(143): return Locale143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, Locale value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - Locale0 = value; - break; - case (1): - Locale1 = value; - break; - case (2): - Locale2 = value; - break; - case (3): - Locale3 = value; - break; - case (4): - Locale4 = value; - break; - case (5): - Locale5 = value; - break; - case (6): - Locale6 = value; - break; - case (7): - Locale7 = value; - break; - case (8): - Locale8 = value; - break; - case (9): - Locale9 = value; - break; - case (10): - Locale10 = value; - break; - case (11): - Locale11 = value; - break; - case (12): - Locale12 = value; - break; - case (13): - Locale13 = value; - break; - case (14): - Locale14 = value; - break; - case (16): - Locale16 = value; - break; - case (17): - Locale17 = value; - break; - case (18): - Locale18 = value; - break; - case (19): - Locale19 = value; - break; - case (20): - Locale20 = value; - break; - case (21): - Locale21 = value; - break; - case (22): - Locale22 = value; - break; - case (23): - Locale23 = value; - break; - case (24): - Locale24 = value; - break; - case (26): - Locale26 = value; - break; - case (28): - Locale28 = value; - break; - case (29): - Locale29 = value; - break; - case (30): - Locale30 = value; - break; - case (31): - Locale31 = value; - break; - case (32): - Locale32 = value; - break; - case (33): - Locale33 = value; - break; - case (35): - Locale35 = value; - break; - case (36): - Locale36 = value; - break; - case (37): - Locale37 = value; - break; - case (38): - Locale38 = value; - break; - case (39): - Locale39 = value; - break; - case (40): - Locale40 = value; - break; - case (41): - Locale41 = value; - break; - case (42): - Locale42 = value; - break; - case (43): - Locale43 = value; - break; - case (44): - Locale44 = value; - break; - case (45): - Locale45 = value; - break; - case (46): - Locale46 = value; - break; - case (47): - Locale47 = value; - break; - case (48): - Locale48 = value; - break; - case (49): - Locale49 = value; - break; - case (50): - Locale50 = value; - break; - case (52): - Locale52 = value; - break; - case (53): - Locale53 = value; - break; - case (54): - Locale54 = value; - break; - case (55): - Locale55 = value; - break; - case (56): - Locale56 = value; - break; - case (57): - Locale57 = value; - break; - case (58): - Locale58 = value; - break; - case (59): - Locale59 = value; - break; - case (60): - Locale60 = value; - break; - case (62): - Locale62 = value; - break; - case (64): - Locale64 = value; - break; - case (65): - Locale65 = value; - break; - case (66): - Locale66 = value; - break; - case (67): - Locale67 = value; - break; - case (68): - Locale68 = value; - break; - case (69): - Locale69 = value; - break; - case (71): - Locale71 = value; - break; - case (72): - Locale72 = value; - break; - case (73): - Locale73 = value; - break; - case (74): - Locale74 = value; - break; - case (75): - Locale75 = value; - break; - case (76): - Locale76 = value; - break; - case (77): - Locale77 = value; - break; - case (78): - Locale78 = value; - break; - case (79): - Locale79 = value; - break; - case (80): - Locale80 = value; - break; - case (81): - Locale81 = value; - break; - case (82): - Locale82 = value; - break; - case (83): - Locale83 = value; - break; - case (84): - Locale84 = value; - break; - case (85): - Locale85 = value; - break; - case (86): - Locale86 = value; - break; - case (88): - Locale88 = value; - break; - case (89): - Locale89 = value; - break; - case (90): - Locale90 = value; - break; - case (91): - Locale91 = value; - break; - case (92): - Locale92 = value; - break; - case (93): - Locale93 = value; - break; - case (94): - Locale94 = value; - break; - case (95): - Locale95 = value; - break; - case (96): - Locale96 = value; - break; - case (98): - Locale98 = value; - break; - case (100): - Locale100 = value; - break; - case (101): - Locale101 = value; - break; - case (102): - Locale102 = value; - break; - case (103): - Locale103 = value; - break; - case (104): - Locale104 = value; - break; - case (105): - Locale105 = value; - break; - case (107): - Locale107 = value; - break; - case (108): - Locale108 = value; - break; - case (109): - Locale109 = value; - break; - case (110): - Locale110 = value; - break; - case (111): - Locale111 = value; - break; - case (112): - Locale112 = value; - break; - case (113): - Locale113 = value; - break; - case (114): - Locale114 = value; - break; - case (115): - Locale115 = value; - break; - case (116): - Locale116 = value; - break; - case (117): - Locale117 = value; - break; - case (118): - Locale118 = value; - break; - case (119): - Locale119 = value; - break; - case (120): - Locale120 = value; - break; - case (121): - Locale121 = value; - break; - case (122): - Locale122 = value; - break; - case (124): - Locale124 = value; - break; - case (125): - Locale125 = value; - break; - case (126): - Locale126 = value; - break; - case (127): - Locale127 = value; - break; - case (128): - Locale128 = value; - break; - case (129): - Locale129 = value; - break; - case (130): - Locale130 = value; - break; - case (131): - Locale131 = value; - break; - case (132): - Locale132 = value; - break; - case (134): - Locale134 = value; - break; - case (136): - Locale136 = value; - break; - case (137): - Locale137 = value; - break; - case (138): - Locale138 = value; - break; - case (139): - Locale139 = value; - break; - case (140): - Locale140 = value; - break; - case (141): - Locale141 = value; - break; - case (143): - Locale143 = value; - break; + public boolean set(int index,Locale value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + Locale0= value; + break; + case(1): + Locale1= value; + break; + case(2): + Locale2= value; + break; + case(3): + Locale3= value; + break; + case(4): + Locale4= value; + break; + case(5): + Locale5= value; + break; + case(6): + Locale6= value; + break; + case(7): + Locale7= value; + break; + case(8): + Locale8= value; + break; + case(9): + Locale9= value; + break; + case(10): + Locale10= value; + break; + case(11): + Locale11= value; + break; + case(12): + Locale12= value; + break; + case(13): + Locale13= value; + break; + case(14): + Locale14= value; + break; + case(16): + Locale16= value; + break; + case(17): + Locale17= value; + break; + case(18): + Locale18= value; + break; + case(19): + Locale19= value; + break; + case(20): + Locale20= value; + break; + case(21): + Locale21= value; + break; + case(22): + Locale22= value; + break; + case(23): + Locale23= value; + break; + case(24): + Locale24= value; + break; + case(26): + Locale26= value; + break; + case(28): + Locale28= value; + break; + case(29): + Locale29= value; + break; + case(30): + Locale30= value; + break; + case(31): + Locale31= value; + break; + case(32): + Locale32= value; + break; + case(33): + Locale33= value; + break; + case(35): + Locale35= value; + break; + case(36): + Locale36= value; + break; + case(37): + Locale37= value; + break; + case(38): + Locale38= value; + break; + case(39): + Locale39= value; + break; + case(40): + Locale40= value; + break; + case(41): + Locale41= value; + break; + case(42): + Locale42= value; + break; + case(43): + Locale43= value; + break; + case(44): + Locale44= value; + break; + case(45): + Locale45= value; + break; + case(46): + Locale46= value; + break; + case(47): + Locale47= value; + break; + case(48): + Locale48= value; + break; + case(49): + Locale49= value; + break; + case(50): + Locale50= value; + break; + case(52): + Locale52= value; + break; + case(53): + Locale53= value; + break; + case(54): + Locale54= value; + break; + case(55): + Locale55= value; + break; + case(56): + Locale56= value; + break; + case(57): + Locale57= value; + break; + case(58): + Locale58= value; + break; + case(59): + Locale59= value; + break; + case(60): + Locale60= value; + break; + case(62): + Locale62= value; + break; + case(64): + Locale64= value; + break; + case(65): + Locale65= value; + break; + case(66): + Locale66= value; + break; + case(67): + Locale67= value; + break; + case(68): + Locale68= value; + break; + case(69): + Locale69= value; + break; + case(71): + Locale71= value; + break; + case(72): + Locale72= value; + break; + case(73): + Locale73= value; + break; + case(74): + Locale74= value; + break; + case(75): + Locale75= value; + break; + case(76): + Locale76= value; + break; + case(77): + Locale77= value; + break; + case(78): + Locale78= value; + break; + case(79): + Locale79= value; + break; + case(80): + Locale80= value; + break; + case(81): + Locale81= value; + break; + case(82): + Locale82= value; + break; + case(83): + Locale83= value; + break; + case(84): + Locale84= value; + break; + case(85): + Locale85= value; + break; + case(86): + Locale86= value; + break; + case(88): + Locale88= value; + break; + case(89): + Locale89= value; + break; + case(90): + Locale90= value; + break; + case(91): + Locale91= value; + break; + case(92): + Locale92= value; + break; + case(93): + Locale93= value; + break; + case(94): + Locale94= value; + break; + case(95): + Locale95= value; + break; + case(96): + Locale96= value; + break; + case(98): + Locale98= value; + break; + case(100): + Locale100= value; + break; + case(101): + Locale101= value; + break; + case(102): + Locale102= value; + break; + case(103): + Locale103= value; + break; + case(104): + Locale104= value; + break; + case(105): + Locale105= value; + break; + case(107): + Locale107= value; + break; + case(108): + Locale108= value; + break; + case(109): + Locale109= value; + break; + case(110): + Locale110= value; + break; + case(111): + Locale111= value; + break; + case(112): + Locale112= value; + break; + case(113): + Locale113= value; + break; + case(114): + Locale114= value; + break; + case(115): + Locale115= value; + break; + case(116): + Locale116= value; + break; + case(117): + Locale117= value; + break; + case(118): + Locale118= value; + break; + case(119): + Locale119= value; + break; + case(120): + Locale120= value; + break; + case(121): + Locale121= value; + break; + case(122): + Locale122= value; + break; + case(124): + Locale124= value; + break; + case(125): + Locale125= value; + break; + case(126): + Locale126= value; + break; + case(127): + Locale127= value; + break; + case(128): + Locale128= value; + break; + case(129): + Locale129= value; + break; + case(130): + Locale130= value; + break; + case(131): + Locale131= value; + break; + case(132): + Locale132= value; + break; + case(134): + Locale134= value; + break; + case(136): + Locale136= value; + break; + case(137): + Locale137= value; + break; + case(138): + Locale138= value; + break; + case(139): + Locale139= value; + break; + case(140): + Locale140= value; + break; + case(141): + Locale141= value; + break; + case(143): + Locale143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfLong.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfLong.java index cf9b7ce60..caa087a4b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfLong.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfLong.java @@ -5,21 +5,21 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -public class FieldsOfLong { +public class FieldsOfLong { public int identifier; private Long Long0; private Long Long1; @@ -36,7 +36,7 @@ public class FieldsOfLong { private transient Long Long12; private transient Long Long13; private transient Long Long14; - private final Long Long15 = Long.valueOf((long) 5); + private final Long Long15 = Long.valueOf((long)5); private volatile Long Long16; private volatile Long Long17; private volatile Long Long18; @@ -46,16 +46,16 @@ public class FieldsOfLong { private volatile Long Long22; private volatile Long Long23; private static transient Long Long24; - private static final Long Long25 = Long.valueOf((long) 5); + private static final Long Long25 = Long.valueOf((long)5); private static volatile Long Long26; - private final transient Long Long27 = Long.valueOf((long) 5); + private transient final Long Long27 = Long.valueOf((long)5); private transient volatile Long Long28; private transient volatile Long Long29; private transient volatile Long Long30; private transient volatile Long Long31; private transient volatile Long Long32; private transient volatile Long Long33; - private static final transient Long Long34 = Long.valueOf((long) 5); + private static transient final Long Long34 = Long.valueOf((long)5); private static transient volatile Long Long35; public Long Long36; public Long Long37; @@ -72,7 +72,7 @@ public class FieldsOfLong { public transient Long Long48; public transient Long Long49; public transient Long Long50; - public final Long Long51 = Long.valueOf((long) 5); + public final Long Long51 = Long.valueOf((long)5); public volatile Long Long52; public volatile Long Long53; public volatile Long Long54; @@ -82,16 +82,16 @@ public class FieldsOfLong { public volatile Long Long58; public volatile Long Long59; public static transient Long Long60; - public static final Long Long61 = Long.valueOf((long) 5); + public static final Long Long61 = Long.valueOf((long)5); public static volatile Long Long62; - public final transient Long Long63 = Long.valueOf((long) 5); + public transient final Long Long63 = Long.valueOf((long)5); public transient volatile Long Long64; public transient volatile Long Long65; public transient volatile Long Long66; public transient volatile Long Long67; public transient volatile Long Long68; public transient volatile Long Long69; - public static final transient Long Long70 = Long.valueOf((long) 5); + public static transient final Long Long70 = Long.valueOf((long)5); public static transient volatile Long Long71; protected Long Long72; protected Long Long73; @@ -108,7 +108,7 @@ public class FieldsOfLong { protected transient Long Long84; protected transient Long Long85; protected transient Long Long86; - protected final Long Long87 = Long.valueOf((long) 5); + protected final Long Long87 = Long.valueOf((long)5); protected volatile Long Long88; protected volatile Long Long89; protected volatile Long Long90; @@ -118,16 +118,16 @@ public class FieldsOfLong { protected volatile Long Long94; protected volatile Long Long95; protected static transient Long Long96; - protected static final Long Long97 = Long.valueOf((long) 5); + protected static final Long Long97 = Long.valueOf((long)5); protected static volatile Long Long98; - protected final transient Long Long99 = Long.valueOf((long) 5); + protected transient final Long Long99 = Long.valueOf((long)5); protected transient volatile Long Long100; protected transient volatile Long Long101; protected transient volatile Long Long102; protected transient volatile Long Long103; protected transient volatile Long Long104; protected transient volatile Long Long105; - protected static final transient Long Long106 = Long.valueOf((long) 5); + protected static transient final Long Long106 = Long.valueOf((long)5); protected static transient volatile Long Long107; Long Long108; Long Long109; @@ -144,7 +144,7 @@ public class FieldsOfLong { transient Long Long120; transient Long Long121; transient Long Long122; - final Long Long123 = Long.valueOf((long) 5); + final Long Long123 = Long.valueOf((long)5); volatile Long Long124; volatile Long Long125; volatile Long Long126; @@ -154,938 +154,937 @@ public class FieldsOfLong { volatile Long Long130; volatile Long Long131; static transient Long Long132; - static final Long Long133 = Long.valueOf((long) 5); + static final Long Long133 = Long.valueOf((long)5); static volatile Long Long134; - final transient Long Long135 = Long.valueOf((long) 5); + transient final Long Long135 = Long.valueOf((long)5); transient volatile Long Long136; transient volatile Long Long137; transient volatile Long Long138; transient volatile Long Long139; transient volatile Long Long140; transient volatile Long Long141; - static final transient Long Long142 = Long.valueOf((long) 5); + static transient final Long Long142 = Long.valueOf((long)5); static transient volatile Long Long143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private Long Long0", - "embedded= true private Long Long1", - "embedded= false private Long Long2", - "persistence-modifier= none private Long Long3", - "persistence-modifier= persistent private Long Long4", - "persistence-modifier= persistent embedded= true private Long Long5", - "persistence-modifier= persistent embedded= false private Long Long6", - "persistence-modifier= transactional private Long Long7", - "private static Long Long8", - "private transient Long Long9", - "persistence-modifier= none private transient Long Long10", - "persistence-modifier= persistent private transient Long Long11", - "persistence-modifier= persistent embedded= true private transient Long Long12", - "persistence-modifier= persistent embedded= false private transient Long Long13", - "persistence-modifier= transactional private transient Long Long14", - "private final Long Long15", - "private volatile Long Long16", - "embedded= true private volatile Long Long17", - "embedded= false private volatile Long Long18", - "persistence-modifier= none private volatile Long Long19", - "persistence-modifier= persistent private volatile Long Long20", - "persistence-modifier= persistent embedded= true private volatile Long Long21", - "persistence-modifier= persistent embedded= false private volatile Long Long22", - "persistence-modifier= transactional private volatile Long Long23", - "private static transient Long Long24", - "private static final Long Long25", - "private static volatile Long Long26", - "private transient final Long Long27", - "private transient volatile Long Long28", - "persistence-modifier= none private transient volatile Long Long29", - "persistence-modifier= persistent private transient volatile Long Long30", - "persistence-modifier= persistent embedded= true private transient volatile Long Long31", - "persistence-modifier= persistent embedded= false private transient volatile Long Long32", - "persistence-modifier= transactional private transient volatile Long Long33", - "private static transient final Long Long34", - "private static transient volatile Long Long35", - "public Long Long36", - "embedded= true public Long Long37", - "embedded= false public Long Long38", - "persistence-modifier= none public Long Long39", - "persistence-modifier= persistent public Long Long40", - "persistence-modifier= persistent embedded= true public Long Long41", - "persistence-modifier= persistent embedded= false public Long Long42", - "persistence-modifier= transactional public Long Long43", - "public static Long Long44", - "public transient Long Long45", - "persistence-modifier= none public transient Long Long46", - "persistence-modifier= persistent public transient Long Long47", - "persistence-modifier= persistent embedded= true public transient Long Long48", - "persistence-modifier= persistent embedded= false public transient Long Long49", - "persistence-modifier= transactional public transient Long Long50", - "public final Long Long51", - "public volatile Long Long52", - "embedded= true public volatile Long Long53", - "embedded= false public volatile Long Long54", - "persistence-modifier= none public volatile Long Long55", - "persistence-modifier= persistent public volatile Long Long56", - "persistence-modifier= persistent embedded= true public volatile Long Long57", - "persistence-modifier= persistent embedded= false public volatile Long Long58", - "persistence-modifier= transactional public volatile Long Long59", - "public static transient Long Long60", - "public static final Long Long61", - "public static volatile Long Long62", - "public transient final Long Long63", - "public transient volatile Long Long64", - "persistence-modifier= none public transient volatile Long Long65", - "persistence-modifier= persistent public transient volatile Long Long66", - "persistence-modifier= persistent embedded= true public transient volatile Long Long67", - "persistence-modifier= persistent embedded= false public transient volatile Long Long68", - "persistence-modifier= transactional public transient volatile Long Long69", - "public static transient final Long Long70", - "public static transient volatile Long Long71", - "protected Long Long72", - "embedded= true protected Long Long73", - "embedded= false protected Long Long74", - "persistence-modifier= none protected Long Long75", - "persistence-modifier= persistent protected Long Long76", - "persistence-modifier= persistent embedded= true protected Long Long77", - "persistence-modifier= persistent embedded= false protected Long Long78", - "persistence-modifier= transactional protected Long Long79", - "protected static Long Long80", - "protected transient Long Long81", - "persistence-modifier= none protected transient Long Long82", - "persistence-modifier= persistent protected transient Long Long83", - "persistence-modifier= persistent embedded= true protected transient Long Long84", - "persistence-modifier= persistent embedded= false protected transient Long Long85", - "persistence-modifier= transactional protected transient Long Long86", - "protected final Long Long87", - "protected volatile Long Long88", - "embedded= true protected volatile Long Long89", - "embedded= false protected volatile Long Long90", - "persistence-modifier= none protected volatile Long Long91", - "persistence-modifier= persistent protected volatile Long Long92", - "persistence-modifier= persistent embedded= true protected volatile Long Long93", - "persistence-modifier= persistent embedded= false protected volatile Long Long94", - "persistence-modifier= transactional protected volatile Long Long95", - "protected static transient Long Long96", - "protected static final Long Long97", - "protected static volatile Long Long98", - "protected transient final Long Long99", - "protected transient volatile Long Long100", - "persistence-modifier= none protected transient volatile Long Long101", - "persistence-modifier= persistent protected transient volatile Long Long102", - "persistence-modifier= persistent embedded= true protected transient volatile Long Long103", - "persistence-modifier= persistent embedded= false protected transient volatile Long Long104", - "persistence-modifier= transactional protected transient volatile Long Long105", - "protected static transient final Long Long106", - "protected static transient volatile Long Long107", - "Long Long108", - "embedded= true Long Long109", - "embedded= false Long Long110", - "persistence-modifier= none Long Long111", - "persistence-modifier= persistent Long Long112", - "persistence-modifier= persistent embedded= true Long Long113", - "persistence-modifier= persistent embedded= false Long Long114", - "persistence-modifier= transactional Long Long115", - "static Long Long116", - "transient Long Long117", - "persistence-modifier= none transient Long Long118", - "persistence-modifier= persistent transient Long Long119", - "persistence-modifier= persistent embedded= true transient Long Long120", - "persistence-modifier= persistent embedded= false transient Long Long121", - "persistence-modifier= transactional transient Long Long122", - "final Long Long123", - "volatile Long Long124", - "embedded= true volatile Long Long125", - "embedded= false volatile Long Long126", - "persistence-modifier= none volatile Long Long127", - "persistence-modifier= persistent volatile Long Long128", - "persistence-modifier= persistent embedded= true volatile Long Long129", - "persistence-modifier= persistent embedded= false volatile Long Long130", - "persistence-modifier= transactional volatile Long Long131", - "static transient Long Long132", - "static final Long Long133", - "static volatile Long Long134", - "transient final Long Long135", - "transient volatile Long Long136", - "persistence-modifier= none transient volatile Long Long137", - "persistence-modifier= persistent transient volatile Long Long138", - "persistence-modifier= persistent embedded= true transient volatile Long Long139", - "persistence-modifier= persistent embedded= false transient volatile Long Long140", - "persistence-modifier= transactional transient volatile Long Long141", - "static transient final Long Long142", - "static transient volatile Long Long143" + public static final String [] fieldSpecs = { + "private Long Long0", + "embedded= true private Long Long1", + "embedded= false private Long Long2", + "persistence-modifier= none private Long Long3", + "persistence-modifier= persistent private Long Long4", + "persistence-modifier= persistent embedded= true private Long Long5", + "persistence-modifier= persistent embedded= false private Long Long6", + "persistence-modifier= transactional private Long Long7", + "private static Long Long8", + "private transient Long Long9", + "persistence-modifier= none private transient Long Long10", + "persistence-modifier= persistent private transient Long Long11", + "persistence-modifier= persistent embedded= true private transient Long Long12", + "persistence-modifier= persistent embedded= false private transient Long Long13", + "persistence-modifier= transactional private transient Long Long14", + "private final Long Long15", + "private volatile Long Long16", + "embedded= true private volatile Long Long17", + "embedded= false private volatile Long Long18", + "persistence-modifier= none private volatile Long Long19", + "persistence-modifier= persistent private volatile Long Long20", + "persistence-modifier= persistent embedded= true private volatile Long Long21", + "persistence-modifier= persistent embedded= false private volatile Long Long22", + "persistence-modifier= transactional private volatile Long Long23", + "private static transient Long Long24", + "private static final Long Long25", + "private static volatile Long Long26", + "private transient final Long Long27", + "private transient volatile Long Long28", + "persistence-modifier= none private transient volatile Long Long29", + "persistence-modifier= persistent private transient volatile Long Long30", + "persistence-modifier= persistent embedded= true private transient volatile Long Long31", + "persistence-modifier= persistent embedded= false private transient volatile Long Long32", + "persistence-modifier= transactional private transient volatile Long Long33", + "private static transient final Long Long34", + "private static transient volatile Long Long35", + "public Long Long36", + "embedded= true public Long Long37", + "embedded= false public Long Long38", + "persistence-modifier= none public Long Long39", + "persistence-modifier= persistent public Long Long40", + "persistence-modifier= persistent embedded= true public Long Long41", + "persistence-modifier= persistent embedded= false public Long Long42", + "persistence-modifier= transactional public Long Long43", + "public static Long Long44", + "public transient Long Long45", + "persistence-modifier= none public transient Long Long46", + "persistence-modifier= persistent public transient Long Long47", + "persistence-modifier= persistent embedded= true public transient Long Long48", + "persistence-modifier= persistent embedded= false public transient Long Long49", + "persistence-modifier= transactional public transient Long Long50", + "public final Long Long51", + "public volatile Long Long52", + "embedded= true public volatile Long Long53", + "embedded= false public volatile Long Long54", + "persistence-modifier= none public volatile Long Long55", + "persistence-modifier= persistent public volatile Long Long56", + "persistence-modifier= persistent embedded= true public volatile Long Long57", + "persistence-modifier= persistent embedded= false public volatile Long Long58", + "persistence-modifier= transactional public volatile Long Long59", + "public static transient Long Long60", + "public static final Long Long61", + "public static volatile Long Long62", + "public transient final Long Long63", + "public transient volatile Long Long64", + "persistence-modifier= none public transient volatile Long Long65", + "persistence-modifier= persistent public transient volatile Long Long66", + "persistence-modifier= persistent embedded= true public transient volatile Long Long67", + "persistence-modifier= persistent embedded= false public transient volatile Long Long68", + "persistence-modifier= transactional public transient volatile Long Long69", + "public static transient final Long Long70", + "public static transient volatile Long Long71", + "protected Long Long72", + "embedded= true protected Long Long73", + "embedded= false protected Long Long74", + "persistence-modifier= none protected Long Long75", + "persistence-modifier= persistent protected Long Long76", + "persistence-modifier= persistent embedded= true protected Long Long77", + "persistence-modifier= persistent embedded= false protected Long Long78", + "persistence-modifier= transactional protected Long Long79", + "protected static Long Long80", + "protected transient Long Long81", + "persistence-modifier= none protected transient Long Long82", + "persistence-modifier= persistent protected transient Long Long83", + "persistence-modifier= persistent embedded= true protected transient Long Long84", + "persistence-modifier= persistent embedded= false protected transient Long Long85", + "persistence-modifier= transactional protected transient Long Long86", + "protected final Long Long87", + "protected volatile Long Long88", + "embedded= true protected volatile Long Long89", + "embedded= false protected volatile Long Long90", + "persistence-modifier= none protected volatile Long Long91", + "persistence-modifier= persistent protected volatile Long Long92", + "persistence-modifier= persistent embedded= true protected volatile Long Long93", + "persistence-modifier= persistent embedded= false protected volatile Long Long94", + "persistence-modifier= transactional protected volatile Long Long95", + "protected static transient Long Long96", + "protected static final Long Long97", + "protected static volatile Long Long98", + "protected transient final Long Long99", + "protected transient volatile Long Long100", + "persistence-modifier= none protected transient volatile Long Long101", + "persistence-modifier= persistent protected transient volatile Long Long102", + "persistence-modifier= persistent embedded= true protected transient volatile Long Long103", + "persistence-modifier= persistent embedded= false protected transient volatile Long Long104", + "persistence-modifier= transactional protected transient volatile Long Long105", + "protected static transient final Long Long106", + "protected static transient volatile Long Long107", + "Long Long108", + "embedded= true Long Long109", + "embedded= false Long Long110", + "persistence-modifier= none Long Long111", + "persistence-modifier= persistent Long Long112", + "persistence-modifier= persistent embedded= true Long Long113", + "persistence-modifier= persistent embedded= false Long Long114", + "persistence-modifier= transactional Long Long115", + "static Long Long116", + "transient Long Long117", + "persistence-modifier= none transient Long Long118", + "persistence-modifier= persistent transient Long Long119", + "persistence-modifier= persistent embedded= true transient Long Long120", + "persistence-modifier= persistent embedded= false transient Long Long121", + "persistence-modifier= transactional transient Long Long122", + "final Long Long123", + "volatile Long Long124", + "embedded= true volatile Long Long125", + "embedded= false volatile Long Long126", + "persistence-modifier= none volatile Long Long127", + "persistence-modifier= persistent volatile Long Long128", + "persistence-modifier= persistent embedded= true volatile Long Long129", + "persistence-modifier= persistent embedded= false volatile Long Long130", + "persistence-modifier= transactional volatile Long Long131", + "static transient Long Long132", + "static final Long Long133", + "static volatile Long Long134", + "transient final Long Long135", + "transient volatile Long Long136", + "persistence-modifier= none transient volatile Long Long137", + "persistence-modifier= persistent transient volatile Long Long138", + "persistence-modifier= persistent embedded= true transient volatile Long Long139", + "persistence-modifier= persistent embedded= false transient volatile Long Long140", + "persistence-modifier= transactional transient volatile Long Long141", + "static transient final Long Long142", + "static transient volatile Long Long143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public Long get(int index) { - switch (index) { - case (0): + public Long get(int index) + { + switch (index) + { + case(0): return Long0; - case (1): + case(1): return Long1; - case (2): + case(2): return Long2; - case (3): + case(3): return Long3; - case (4): + case(4): return Long4; - case (5): + case(5): return Long5; - case (6): + case(6): return Long6; - case (7): + case(7): return Long7; - case (8): + case(8): return Long8; - case (9): + case(9): return Long9; - case (10): + case(10): return Long10; - case (11): + case(11): return Long11; - case (12): + case(12): return Long12; - case (13): + case(13): return Long13; - case (14): + case(14): return Long14; - case (15): + case(15): return Long15; - case (16): + case(16): return Long16; - case (17): + case(17): return Long17; - case (18): + case(18): return Long18; - case (19): + case(19): return Long19; - case (20): + case(20): return Long20; - case (21): + case(21): return Long21; - case (22): + case(22): return Long22; - case (23): + case(23): return Long23; - case (24): + case(24): return Long24; - case (25): + case(25): return Long25; - case (26): + case(26): return Long26; - case (27): + case(27): return Long27; - case (28): + case(28): return Long28; - case (29): + case(29): return Long29; - case (30): + case(30): return Long30; - case (31): + case(31): return Long31; - case (32): + case(32): return Long32; - case (33): + case(33): return Long33; - case (34): + case(34): return Long34; - case (35): + case(35): return Long35; - case (36): + case(36): return Long36; - case (37): + case(37): return Long37; - case (38): + case(38): return Long38; - case (39): + case(39): return Long39; - case (40): + case(40): return Long40; - case (41): + case(41): return Long41; - case (42): + case(42): return Long42; - case (43): + case(43): return Long43; - case (44): + case(44): return Long44; - case (45): + case(45): return Long45; - case (46): + case(46): return Long46; - case (47): + case(47): return Long47; - case (48): + case(48): return Long48; - case (49): + case(49): return Long49; - case (50): + case(50): return Long50; - case (51): + case(51): return Long51; - case (52): + case(52): return Long52; - case (53): + case(53): return Long53; - case (54): + case(54): return Long54; - case (55): + case(55): return Long55; - case (56): + case(56): return Long56; - case (57): + case(57): return Long57; - case (58): + case(58): return Long58; - case (59): + case(59): return Long59; - case (60): + case(60): return Long60; - case (61): + case(61): return Long61; - case (62): + case(62): return Long62; - case (63): + case(63): return Long63; - case (64): + case(64): return Long64; - case (65): + case(65): return Long65; - case (66): + case(66): return Long66; - case (67): + case(67): return Long67; - case (68): + case(68): return Long68; - case (69): + case(69): return Long69; - case (70): + case(70): return Long70; - case (71): + case(71): return Long71; - case (72): + case(72): return Long72; - case (73): + case(73): return Long73; - case (74): + case(74): return Long74; - case (75): + case(75): return Long75; - case (76): + case(76): return Long76; - case (77): + case(77): return Long77; - case (78): + case(78): return Long78; - case (79): + case(79): return Long79; - case (80): + case(80): return Long80; - case (81): + case(81): return Long81; - case (82): + case(82): return Long82; - case (83): + case(83): return Long83; - case (84): + case(84): return Long84; - case (85): + case(85): return Long85; - case (86): + case(86): return Long86; - case (87): + case(87): return Long87; - case (88): + case(88): return Long88; - case (89): + case(89): return Long89; - case (90): + case(90): return Long90; - case (91): + case(91): return Long91; - case (92): + case(92): return Long92; - case (93): + case(93): return Long93; - case (94): + case(94): return Long94; - case (95): + case(95): return Long95; - case (96): + case(96): return Long96; - case (97): + case(97): return Long97; - case (98): + case(98): return Long98; - case (99): + case(99): return Long99; - case (100): + case(100): return Long100; - case (101): + case(101): return Long101; - case (102): + case(102): return Long102; - case (103): + case(103): return Long103; - case (104): + case(104): return Long104; - case (105): + case(105): return Long105; - case (106): + case(106): return Long106; - case (107): + case(107): return Long107; - case (108): + case(108): return Long108; - case (109): + case(109): return Long109; - case (110): + case(110): return Long110; - case (111): + case(111): return Long111; - case (112): + case(112): return Long112; - case (113): + case(113): return Long113; - case (114): + case(114): return Long114; - case (115): + case(115): return Long115; - case (116): + case(116): return Long116; - case (117): + case(117): return Long117; - case (118): + case(118): return Long118; - case (119): + case(119): return Long119; - case (120): + case(120): return Long120; - case (121): + case(121): return Long121; - case (122): + case(122): return Long122; - case (123): + case(123): return Long123; - case (124): + case(124): return Long124; - case (125): + case(125): return Long125; - case (126): + case(126): return Long126; - case (127): + case(127): return Long127; - case (128): + case(128): return Long128; - case (129): + case(129): return Long129; - case (130): + case(130): return Long130; - case (131): + case(131): return Long131; - case (132): + case(132): return Long132; - case (133): + case(133): return Long133; - case (134): + case(134): return Long134; - case (135): + case(135): return Long135; - case (136): + case(136): return Long136; - case (137): + case(137): return Long137; - case (138): + case(138): return Long138; - case (139): + case(139): return Long139; - case (140): + case(140): return Long140; - case (141): + case(141): return Long141; - case (142): + case(142): return Long142; - case (143): + case(143): return Long143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, Long value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - Long0 = value; - break; - case (1): - Long1 = value; - break; - case (2): - Long2 = value; - break; - case (3): - Long3 = value; - break; - case (4): - Long4 = value; - break; - case (5): - Long5 = value; - break; - case (6): - Long6 = value; - break; - case (7): - Long7 = value; - break; - case (8): - Long8 = value; - break; - case (9): - Long9 = value; - break; - case (10): - Long10 = value; - break; - case (11): - Long11 = value; - break; - case (12): - Long12 = value; - break; - case (13): - Long13 = value; - break; - case (14): - Long14 = value; - break; - case (16): - Long16 = value; - break; - case (17): - Long17 = value; - break; - case (18): - Long18 = value; - break; - case (19): - Long19 = value; - break; - case (20): - Long20 = value; - break; - case (21): - Long21 = value; - break; - case (22): - Long22 = value; - break; - case (23): - Long23 = value; - break; - case (24): - Long24 = value; - break; - case (26): - Long26 = value; - break; - case (28): - Long28 = value; - break; - case (29): - Long29 = value; - break; - case (30): - Long30 = value; - break; - case (31): - Long31 = value; - break; - case (32): - Long32 = value; - break; - case (33): - Long33 = value; - break; - case (35): - Long35 = value; - break; - case (36): - Long36 = value; - break; - case (37): - Long37 = value; - break; - case (38): - Long38 = value; - break; - case (39): - Long39 = value; - break; - case (40): - Long40 = value; - break; - case (41): - Long41 = value; - break; - case (42): - Long42 = value; - break; - case (43): - Long43 = value; - break; - case (44): - Long44 = value; - break; - case (45): - Long45 = value; - break; - case (46): - Long46 = value; - break; - case (47): - Long47 = value; - break; - case (48): - Long48 = value; - break; - case (49): - Long49 = value; - break; - case (50): - Long50 = value; - break; - case (52): - Long52 = value; - break; - case (53): - Long53 = value; - break; - case (54): - Long54 = value; - break; - case (55): - Long55 = value; - break; - case (56): - Long56 = value; - break; - case (57): - Long57 = value; - break; - case (58): - Long58 = value; - break; - case (59): - Long59 = value; - break; - case (60): - Long60 = value; - break; - case (62): - Long62 = value; - break; - case (64): - Long64 = value; - break; - case (65): - Long65 = value; - break; - case (66): - Long66 = value; - break; - case (67): - Long67 = value; - break; - case (68): - Long68 = value; - break; - case (69): - Long69 = value; - break; - case (71): - Long71 = value; - break; - case (72): - Long72 = value; - break; - case (73): - Long73 = value; - break; - case (74): - Long74 = value; - break; - case (75): - Long75 = value; - break; - case (76): - Long76 = value; - break; - case (77): - Long77 = value; - break; - case (78): - Long78 = value; - break; - case (79): - Long79 = value; - break; - case (80): - Long80 = value; - break; - case (81): - Long81 = value; - break; - case (82): - Long82 = value; - break; - case (83): - Long83 = value; - break; - case (84): - Long84 = value; - break; - case (85): - Long85 = value; - break; - case (86): - Long86 = value; - break; - case (88): - Long88 = value; - break; - case (89): - Long89 = value; - break; - case (90): - Long90 = value; - break; - case (91): - Long91 = value; - break; - case (92): - Long92 = value; - break; - case (93): - Long93 = value; - break; - case (94): - Long94 = value; - break; - case (95): - Long95 = value; - break; - case (96): - Long96 = value; - break; - case (98): - Long98 = value; - break; - case (100): - Long100 = value; - break; - case (101): - Long101 = value; - break; - case (102): - Long102 = value; - break; - case (103): - Long103 = value; - break; - case (104): - Long104 = value; - break; - case (105): - Long105 = value; - break; - case (107): - Long107 = value; - break; - case (108): - Long108 = value; - break; - case (109): - Long109 = value; - break; - case (110): - Long110 = value; - break; - case (111): - Long111 = value; - break; - case (112): - Long112 = value; - break; - case (113): - Long113 = value; - break; - case (114): - Long114 = value; - break; - case (115): - Long115 = value; - break; - case (116): - Long116 = value; - break; - case (117): - Long117 = value; - break; - case (118): - Long118 = value; - break; - case (119): - Long119 = value; - break; - case (120): - Long120 = value; - break; - case (121): - Long121 = value; - break; - case (122): - Long122 = value; - break; - case (124): - Long124 = value; - break; - case (125): - Long125 = value; - break; - case (126): - Long126 = value; - break; - case (127): - Long127 = value; - break; - case (128): - Long128 = value; - break; - case (129): - Long129 = value; - break; - case (130): - Long130 = value; - break; - case (131): - Long131 = value; - break; - case (132): - Long132 = value; - break; - case (134): - Long134 = value; - break; - case (136): - Long136 = value; - break; - case (137): - Long137 = value; - break; - case (138): - Long138 = value; - break; - case (139): - Long139 = value; - break; - case (140): - Long140 = value; - break; - case (141): - Long141 = value; - break; - case (143): - Long143 = value; - break; + public boolean set(int index,Long value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + Long0= value; + break; + case(1): + Long1= value; + break; + case(2): + Long2= value; + break; + case(3): + Long3= value; + break; + case(4): + Long4= value; + break; + case(5): + Long5= value; + break; + case(6): + Long6= value; + break; + case(7): + Long7= value; + break; + case(8): + Long8= value; + break; + case(9): + Long9= value; + break; + case(10): + Long10= value; + break; + case(11): + Long11= value; + break; + case(12): + Long12= value; + break; + case(13): + Long13= value; + break; + case(14): + Long14= value; + break; + case(16): + Long16= value; + break; + case(17): + Long17= value; + break; + case(18): + Long18= value; + break; + case(19): + Long19= value; + break; + case(20): + Long20= value; + break; + case(21): + Long21= value; + break; + case(22): + Long22= value; + break; + case(23): + Long23= value; + break; + case(24): + Long24= value; + break; + case(26): + Long26= value; + break; + case(28): + Long28= value; + break; + case(29): + Long29= value; + break; + case(30): + Long30= value; + break; + case(31): + Long31= value; + break; + case(32): + Long32= value; + break; + case(33): + Long33= value; + break; + case(35): + Long35= value; + break; + case(36): + Long36= value; + break; + case(37): + Long37= value; + break; + case(38): + Long38= value; + break; + case(39): + Long39= value; + break; + case(40): + Long40= value; + break; + case(41): + Long41= value; + break; + case(42): + Long42= value; + break; + case(43): + Long43= value; + break; + case(44): + Long44= value; + break; + case(45): + Long45= value; + break; + case(46): + Long46= value; + break; + case(47): + Long47= value; + break; + case(48): + Long48= value; + break; + case(49): + Long49= value; + break; + case(50): + Long50= value; + break; + case(52): + Long52= value; + break; + case(53): + Long53= value; + break; + case(54): + Long54= value; + break; + case(55): + Long55= value; + break; + case(56): + Long56= value; + break; + case(57): + Long57= value; + break; + case(58): + Long58= value; + break; + case(59): + Long59= value; + break; + case(60): + Long60= value; + break; + case(62): + Long62= value; + break; + case(64): + Long64= value; + break; + case(65): + Long65= value; + break; + case(66): + Long66= value; + break; + case(67): + Long67= value; + break; + case(68): + Long68= value; + break; + case(69): + Long69= value; + break; + case(71): + Long71= value; + break; + case(72): + Long72= value; + break; + case(73): + Long73= value; + break; + case(74): + Long74= value; + break; + case(75): + Long75= value; + break; + case(76): + Long76= value; + break; + case(77): + Long77= value; + break; + case(78): + Long78= value; + break; + case(79): + Long79= value; + break; + case(80): + Long80= value; + break; + case(81): + Long81= value; + break; + case(82): + Long82= value; + break; + case(83): + Long83= value; + break; + case(84): + Long84= value; + break; + case(85): + Long85= value; + break; + case(86): + Long86= value; + break; + case(88): + Long88= value; + break; + case(89): + Long89= value; + break; + case(90): + Long90= value; + break; + case(91): + Long91= value; + break; + case(92): + Long92= value; + break; + case(93): + Long93= value; + break; + case(94): + Long94= value; + break; + case(95): + Long95= value; + break; + case(96): + Long96= value; + break; + case(98): + Long98= value; + break; + case(100): + Long100= value; + break; + case(101): + Long101= value; + break; + case(102): + Long102= value; + break; + case(103): + Long103= value; + break; + case(104): + Long104= value; + break; + case(105): + Long105= value; + break; + case(107): + Long107= value; + break; + case(108): + Long108= value; + break; + case(109): + Long109= value; + break; + case(110): + Long110= value; + break; + case(111): + Long111= value; + break; + case(112): + Long112= value; + break; + case(113): + Long113= value; + break; + case(114): + Long114= value; + break; + case(115): + Long115= value; + break; + case(116): + Long116= value; + break; + case(117): + Long117= value; + break; + case(118): + Long118= value; + break; + case(119): + Long119= value; + break; + case(120): + Long120= value; + break; + case(121): + Long121= value; + break; + case(122): + Long122= value; + break; + case(124): + Long124= value; + break; + case(125): + Long125= value; + break; + case(126): + Long126= value; + break; + case(127): + Long127= value; + break; + case(128): + Long128= value; + break; + case(129): + Long129= value; + break; + case(130): + Long130= value; + break; + case(131): + Long131= value; + break; + case(132): + Long132= value; + break; + case(134): + Long134= value; + break; + case(136): + Long136= value; + break; + case(137): + Long137= value; + break; + case(138): + Long138= value; + break; + case(139): + Long139= value; + break; + case(140): + Long140= value; + break; + case(141): + Long141= value; + break; + case(143): + Long143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfObject.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfObject.java index afa2605e4..195d4509d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfObject.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfObject.java @@ -5,21 +5,21 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -public class FieldsOfObject { +public class FieldsOfObject { public int identifier; private Object Object0; private Object Object1; @@ -48,14 +48,14 @@ public class FieldsOfObject { private static transient Object Object24; private static final Object Object25 = new Object(); private static volatile Object Object26; - private final transient Object Object27 = new Object(); + private transient final Object Object27 = new Object(); private transient volatile Object Object28; private transient volatile Object Object29; private transient volatile Object Object30; private transient volatile Object Object31; private transient volatile Object Object32; private transient volatile Object Object33; - private static final transient Object Object34 = new Object(); + private static transient final Object Object34 = new Object(); private static transient volatile Object Object35; public Object Object36; public Object Object37; @@ -84,14 +84,14 @@ public class FieldsOfObject { public static transient Object Object60; public static final Object Object61 = new Object(); public static volatile Object Object62; - public final transient Object Object63 = new Object(); + public transient final Object Object63 = new Object(); public transient volatile Object Object64; public transient volatile Object Object65; public transient volatile Object Object66; public transient volatile Object Object67; public transient volatile Object Object68; public transient volatile Object Object69; - public static final transient Object Object70 = new Object(); + public static transient final Object Object70 = new Object(); public static transient volatile Object Object71; protected Object Object72; protected Object Object73; @@ -120,14 +120,14 @@ public class FieldsOfObject { protected static transient Object Object96; protected static final Object Object97 = new Object(); protected static volatile Object Object98; - protected final transient Object Object99 = new Object(); + protected transient final Object Object99 = new Object(); protected transient volatile Object Object100; protected transient volatile Object Object101; protected transient volatile Object Object102; protected transient volatile Object Object103; protected transient volatile Object Object104; protected transient volatile Object Object105; - protected static final transient Object Object106 = new Object(); + protected static transient final Object Object106 = new Object(); protected static transient volatile Object Object107; Object Object108; Object Object109; @@ -156,936 +156,935 @@ public class FieldsOfObject { static transient Object Object132; static final Object Object133 = new Object(); static volatile Object Object134; - final transient Object Object135 = new Object(); + transient final Object Object135 = new Object(); transient volatile Object Object136; transient volatile Object Object137; transient volatile Object Object138; transient volatile Object Object139; transient volatile Object Object140; transient volatile Object Object141; - static final transient Object Object142 = new Object(); + static transient final Object Object142 = new Object(); static transient volatile Object Object143; - public static final boolean[] isPersistent = { - false, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, false, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, false, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, false, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, false, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +false,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,false,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,false,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,false,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,false,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private Object Object0", - "serialized= true private Object Object1", - "embedded= false private Object Object2", - "persistence-modifier= none private Object Object3", - "persistence-modifier= persistent private Object Object4", - "persistence-modifier= persistent serialized= true private Object Object5", - "persistence-modifier= persistent embedded= false private Object Object6", - "persistence-modifier= transactional private Object Object7", - "private static Object Object8", - "private transient Object Object9", - "persistence-modifier= none private transient Object Object10", - "persistence-modifier= persistent private transient Object Object11", - "persistence-modifier= persistent serialized= true private transient Object Object12", - "persistence-modifier= persistent embedded= false private transient Object Object13", - "persistence-modifier= transactional private transient Object Object14", - "private final Object Object15", - "private volatile Object Object16", - "serialized= true private volatile Object Object17", - "embedded= false private volatile Object Object18", - "persistence-modifier= none private volatile Object Object19", - "persistence-modifier= persistent private volatile Object Object20", - "persistence-modifier= persistent serialized= true private volatile Object Object21", - "persistence-modifier= persistent embedded= false private volatile Object Object22", - "persistence-modifier= transactional private volatile Object Object23", - "private static transient Object Object24", - "private static final Object Object25", - "private static volatile Object Object26", - "private transient final Object Object27", - "private transient volatile Object Object28", - "persistence-modifier= none private transient volatile Object Object29", - "persistence-modifier= persistent private transient volatile Object Object30", - "persistence-modifier= persistent serialized= true private transient volatile Object Object31", - "persistence-modifier= persistent embedded= false private transient volatile Object Object32", - "persistence-modifier= transactional private transient volatile Object Object33", - "private static transient final Object Object34", - "private static transient volatile Object Object35", - "public Object Object36", - "serialized= true public Object Object37", - "embedded= false public Object Object38", - "persistence-modifier= none public Object Object39", - "persistence-modifier= persistent public Object Object40", - "persistence-modifier= persistent serialized= true public Object Object41", - "persistence-modifier= persistent embedded= false public Object Object42", - "persistence-modifier= transactional public Object Object43", - "public static Object Object44", - "public transient Object Object45", - "persistence-modifier= none public transient Object Object46", - "persistence-modifier= persistent public transient Object Object47", - "persistence-modifier= persistent serialized= true public transient Object Object48", - "persistence-modifier= persistent embedded= false public transient Object Object49", - "persistence-modifier= transactional public transient Object Object50", - "public final Object Object51", - "public volatile Object Object52", - "serialized= true public volatile Object Object53", - "embedded= false public volatile Object Object54", - "persistence-modifier= none public volatile Object Object55", - "persistence-modifier= persistent public volatile Object Object56", - "persistence-modifier= persistent serialized= true public volatile Object Object57", - "persistence-modifier= persistent embedded= false public volatile Object Object58", - "persistence-modifier= transactional public volatile Object Object59", - "public static transient Object Object60", - "public static final Object Object61", - "public static volatile Object Object62", - "public transient final Object Object63", - "public transient volatile Object Object64", - "persistence-modifier= none public transient volatile Object Object65", - "persistence-modifier= persistent public transient volatile Object Object66", - "persistence-modifier= persistent serialized= true public transient volatile Object Object67", - "persistence-modifier= persistent embedded= false public transient volatile Object Object68", - "persistence-modifier= transactional public transient volatile Object Object69", - "public static transient final Object Object70", - "public static transient volatile Object Object71", - "protected Object Object72", - "serialized= true protected Object Object73", - "embedded= false protected Object Object74", - "persistence-modifier= none protected Object Object75", - "persistence-modifier= persistent protected Object Object76", - "persistence-modifier= persistent serialized= true protected Object Object77", - "persistence-modifier= persistent embedded= false protected Object Object78", - "persistence-modifier= transactional protected Object Object79", - "protected static Object Object80", - "protected transient Object Object81", - "persistence-modifier= none protected transient Object Object82", - "persistence-modifier= persistent protected transient Object Object83", - "persistence-modifier= persistent serialized= true protected transient Object Object84", - "persistence-modifier= persistent embedded= false protected transient Object Object85", - "persistence-modifier= transactional protected transient Object Object86", - "protected final Object Object87", - "protected volatile Object Object88", - "serialized= true protected volatile Object Object89", - "embedded= false protected volatile Object Object90", - "persistence-modifier= none protected volatile Object Object91", - "persistence-modifier= persistent protected volatile Object Object92", - "persistence-modifier= persistent serialized= true protected volatile Object Object93", - "persistence-modifier= persistent embedded= false protected volatile Object Object94", - "persistence-modifier= transactional protected volatile Object Object95", - "protected static transient Object Object96", - "protected static final Object Object97", - "protected static volatile Object Object98", - "protected transient final Object Object99", - "protected transient volatile Object Object100", - "persistence-modifier= none protected transient volatile Object Object101", - "persistence-modifier= persistent protected transient volatile Object Object102", - "persistence-modifier= persistent serialized= true protected transient volatile Object Object103", - "persistence-modifier= persistent embedded= false protected transient volatile Object Object104", - "persistence-modifier= transactional protected transient volatile Object Object105", - "protected static transient final Object Object106", - "protected static transient volatile Object Object107", - "Object Object108", - "serialized= true Object Object109", - "embedded= false Object Object110", - "persistence-modifier= none Object Object111", - "persistence-modifier= persistent Object Object112", - "persistence-modifier= persistent serialized= true Object Object113", - "persistence-modifier= persistent embedded= false Object Object114", - "persistence-modifier= transactional Object Object115", - "static Object Object116", - "transient Object Object117", - "persistence-modifier= none transient Object Object118", - "persistence-modifier= persistent transient Object Object119", - "persistence-modifier= persistent serialized= true transient Object Object120", - "persistence-modifier= persistent embedded= false transient Object Object121", - "persistence-modifier= transactional transient Object Object122", - "final Object Object123", - "volatile Object Object124", - "serialized= true volatile Object Object125", - "embedded= false volatile Object Object126", - "persistence-modifier= none volatile Object Object127", - "persistence-modifier= persistent volatile Object Object128", - "persistence-modifier= persistent serialized= true volatile Object Object129", - "persistence-modifier= persistent embedded= false volatile Object Object130", - "persistence-modifier= transactional volatile Object Object131", - "static transient Object Object132", - "static final Object Object133", - "static volatile Object Object134", - "transient final Object Object135", - "transient volatile Object Object136", - "persistence-modifier= none transient volatile Object Object137", - "persistence-modifier= persistent transient volatile Object Object138", - "persistence-modifier= persistent serialized= true transient volatile Object Object139", - "persistence-modifier= persistent embedded= false transient volatile Object Object140", - "persistence-modifier= transactional transient volatile Object Object141", - "static transient final Object Object142", - "static transient volatile Object Object143" + public static final String [] fieldSpecs = { + "private Object Object0", + "serialized= true private Object Object1", + "embedded= false private Object Object2", + "persistence-modifier= none private Object Object3", + "persistence-modifier= persistent private Object Object4", + "persistence-modifier= persistent serialized= true private Object Object5", + "persistence-modifier= persistent embedded= false private Object Object6", + "persistence-modifier= transactional private Object Object7", + "private static Object Object8", + "private transient Object Object9", + "persistence-modifier= none private transient Object Object10", + "persistence-modifier= persistent private transient Object Object11", + "persistence-modifier= persistent serialized= true private transient Object Object12", + "persistence-modifier= persistent embedded= false private transient Object Object13", + "persistence-modifier= transactional private transient Object Object14", + "private final Object Object15", + "private volatile Object Object16", + "serialized= true private volatile Object Object17", + "embedded= false private volatile Object Object18", + "persistence-modifier= none private volatile Object Object19", + "persistence-modifier= persistent private volatile Object Object20", + "persistence-modifier= persistent serialized= true private volatile Object Object21", + "persistence-modifier= persistent embedded= false private volatile Object Object22", + "persistence-modifier= transactional private volatile Object Object23", + "private static transient Object Object24", + "private static final Object Object25", + "private static volatile Object Object26", + "private transient final Object Object27", + "private transient volatile Object Object28", + "persistence-modifier= none private transient volatile Object Object29", + "persistence-modifier= persistent private transient volatile Object Object30", + "persistence-modifier= persistent serialized= true private transient volatile Object Object31", + "persistence-modifier= persistent embedded= false private transient volatile Object Object32", + "persistence-modifier= transactional private transient volatile Object Object33", + "private static transient final Object Object34", + "private static transient volatile Object Object35", + "public Object Object36", + "serialized= true public Object Object37", + "embedded= false public Object Object38", + "persistence-modifier= none public Object Object39", + "persistence-modifier= persistent public Object Object40", + "persistence-modifier= persistent serialized= true public Object Object41", + "persistence-modifier= persistent embedded= false public Object Object42", + "persistence-modifier= transactional public Object Object43", + "public static Object Object44", + "public transient Object Object45", + "persistence-modifier= none public transient Object Object46", + "persistence-modifier= persistent public transient Object Object47", + "persistence-modifier= persistent serialized= true public transient Object Object48", + "persistence-modifier= persistent embedded= false public transient Object Object49", + "persistence-modifier= transactional public transient Object Object50", + "public final Object Object51", + "public volatile Object Object52", + "serialized= true public volatile Object Object53", + "embedded= false public volatile Object Object54", + "persistence-modifier= none public volatile Object Object55", + "persistence-modifier= persistent public volatile Object Object56", + "persistence-modifier= persistent serialized= true public volatile Object Object57", + "persistence-modifier= persistent embedded= false public volatile Object Object58", + "persistence-modifier= transactional public volatile Object Object59", + "public static transient Object Object60", + "public static final Object Object61", + "public static volatile Object Object62", + "public transient final Object Object63", + "public transient volatile Object Object64", + "persistence-modifier= none public transient volatile Object Object65", + "persistence-modifier= persistent public transient volatile Object Object66", + "persistence-modifier= persistent serialized= true public transient volatile Object Object67", + "persistence-modifier= persistent embedded= false public transient volatile Object Object68", + "persistence-modifier= transactional public transient volatile Object Object69", + "public static transient final Object Object70", + "public static transient volatile Object Object71", + "protected Object Object72", + "serialized= true protected Object Object73", + "embedded= false protected Object Object74", + "persistence-modifier= none protected Object Object75", + "persistence-modifier= persistent protected Object Object76", + "persistence-modifier= persistent serialized= true protected Object Object77", + "persistence-modifier= persistent embedded= false protected Object Object78", + "persistence-modifier= transactional protected Object Object79", + "protected static Object Object80", + "protected transient Object Object81", + "persistence-modifier= none protected transient Object Object82", + "persistence-modifier= persistent protected transient Object Object83", + "persistence-modifier= persistent serialized= true protected transient Object Object84", + "persistence-modifier= persistent embedded= false protected transient Object Object85", + "persistence-modifier= transactional protected transient Object Object86", + "protected final Object Object87", + "protected volatile Object Object88", + "serialized= true protected volatile Object Object89", + "embedded= false protected volatile Object Object90", + "persistence-modifier= none protected volatile Object Object91", + "persistence-modifier= persistent protected volatile Object Object92", + "persistence-modifier= persistent serialized= true protected volatile Object Object93", + "persistence-modifier= persistent embedded= false protected volatile Object Object94", + "persistence-modifier= transactional protected volatile Object Object95", + "protected static transient Object Object96", + "protected static final Object Object97", + "protected static volatile Object Object98", + "protected transient final Object Object99", + "protected transient volatile Object Object100", + "persistence-modifier= none protected transient volatile Object Object101", + "persistence-modifier= persistent protected transient volatile Object Object102", + "persistence-modifier= persistent serialized= true protected transient volatile Object Object103", + "persistence-modifier= persistent embedded= false protected transient volatile Object Object104", + "persistence-modifier= transactional protected transient volatile Object Object105", + "protected static transient final Object Object106", + "protected static transient volatile Object Object107", + "Object Object108", + "serialized= true Object Object109", + "embedded= false Object Object110", + "persistence-modifier= none Object Object111", + "persistence-modifier= persistent Object Object112", + "persistence-modifier= persistent serialized= true Object Object113", + "persistence-modifier= persistent embedded= false Object Object114", + "persistence-modifier= transactional Object Object115", + "static Object Object116", + "transient Object Object117", + "persistence-modifier= none transient Object Object118", + "persistence-modifier= persistent transient Object Object119", + "persistence-modifier= persistent serialized= true transient Object Object120", + "persistence-modifier= persistent embedded= false transient Object Object121", + "persistence-modifier= transactional transient Object Object122", + "final Object Object123", + "volatile Object Object124", + "serialized= true volatile Object Object125", + "embedded= false volatile Object Object126", + "persistence-modifier= none volatile Object Object127", + "persistence-modifier= persistent volatile Object Object128", + "persistence-modifier= persistent serialized= true volatile Object Object129", + "persistence-modifier= persistent embedded= false volatile Object Object130", + "persistence-modifier= transactional volatile Object Object131", + "static transient Object Object132", + "static final Object Object133", + "static volatile Object Object134", + "transient final Object Object135", + "transient volatile Object Object136", + "persistence-modifier= none transient volatile Object Object137", + "persistence-modifier= persistent transient volatile Object Object138", + "persistence-modifier= persistent serialized= true transient volatile Object Object139", + "persistence-modifier= persistent embedded= false transient volatile Object Object140", + "persistence-modifier= transactional transient volatile Object Object141", + "static transient final Object Object142", + "static transient volatile Object Object143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public Object get(int index) { - switch (index) { - case (0): + public Object get(int index) + { + switch (index) + { + case(0): return Object0; - case (1): + case(1): return Object1; - case (2): + case(2): return Object2; - case (3): + case(3): return Object3; - case (4): + case(4): return Object4; - case (5): + case(5): return Object5; - case (6): + case(6): return Object6; - case (7): + case(7): return Object7; - case (8): + case(8): return Object8; - case (9): + case(9): return Object9; - case (10): + case(10): return Object10; - case (11): + case(11): return Object11; - case (12): + case(12): return Object12; - case (13): + case(13): return Object13; - case (14): + case(14): return Object14; - case (15): + case(15): return Object15; - case (16): + case(16): return Object16; - case (17): + case(17): return Object17; - case (18): + case(18): return Object18; - case (19): + case(19): return Object19; - case (20): + case(20): return Object20; - case (21): + case(21): return Object21; - case (22): + case(22): return Object22; - case (23): + case(23): return Object23; - case (24): + case(24): return Object24; - case (25): + case(25): return Object25; - case (26): + case(26): return Object26; - case (27): + case(27): return Object27; - case (28): + case(28): return Object28; - case (29): + case(29): return Object29; - case (30): + case(30): return Object30; - case (31): + case(31): return Object31; - case (32): + case(32): return Object32; - case (33): + case(33): return Object33; - case (34): + case(34): return Object34; - case (35): + case(35): return Object35; - case (36): + case(36): return Object36; - case (37): + case(37): return Object37; - case (38): + case(38): return Object38; - case (39): + case(39): return Object39; - case (40): + case(40): return Object40; - case (41): + case(41): return Object41; - case (42): + case(42): return Object42; - case (43): + case(43): return Object43; - case (44): + case(44): return Object44; - case (45): + case(45): return Object45; - case (46): + case(46): return Object46; - case (47): + case(47): return Object47; - case (48): + case(48): return Object48; - case (49): + case(49): return Object49; - case (50): + case(50): return Object50; - case (51): + case(51): return Object51; - case (52): + case(52): return Object52; - case (53): + case(53): return Object53; - case (54): + case(54): return Object54; - case (55): + case(55): return Object55; - case (56): + case(56): return Object56; - case (57): + case(57): return Object57; - case (58): + case(58): return Object58; - case (59): + case(59): return Object59; - case (60): + case(60): return Object60; - case (61): + case(61): return Object61; - case (62): + case(62): return Object62; - case (63): + case(63): return Object63; - case (64): + case(64): return Object64; - case (65): + case(65): return Object65; - case (66): + case(66): return Object66; - case (67): + case(67): return Object67; - case (68): + case(68): return Object68; - case (69): + case(69): return Object69; - case (70): + case(70): return Object70; - case (71): + case(71): return Object71; - case (72): + case(72): return Object72; - case (73): + case(73): return Object73; - case (74): + case(74): return Object74; - case (75): + case(75): return Object75; - case (76): + case(76): return Object76; - case (77): + case(77): return Object77; - case (78): + case(78): return Object78; - case (79): + case(79): return Object79; - case (80): + case(80): return Object80; - case (81): + case(81): return Object81; - case (82): + case(82): return Object82; - case (83): + case(83): return Object83; - case (84): + case(84): return Object84; - case (85): + case(85): return Object85; - case (86): + case(86): return Object86; - case (87): + case(87): return Object87; - case (88): + case(88): return Object88; - case (89): + case(89): return Object89; - case (90): + case(90): return Object90; - case (91): + case(91): return Object91; - case (92): + case(92): return Object92; - case (93): + case(93): return Object93; - case (94): + case(94): return Object94; - case (95): + case(95): return Object95; - case (96): + case(96): return Object96; - case (97): + case(97): return Object97; - case (98): + case(98): return Object98; - case (99): + case(99): return Object99; - case (100): + case(100): return Object100; - case (101): + case(101): return Object101; - case (102): + case(102): return Object102; - case (103): + case(103): return Object103; - case (104): + case(104): return Object104; - case (105): + case(105): return Object105; - case (106): + case(106): return Object106; - case (107): + case(107): return Object107; - case (108): + case(108): return Object108; - case (109): + case(109): return Object109; - case (110): + case(110): return Object110; - case (111): + case(111): return Object111; - case (112): + case(112): return Object112; - case (113): + case(113): return Object113; - case (114): + case(114): return Object114; - case (115): + case(115): return Object115; - case (116): + case(116): return Object116; - case (117): + case(117): return Object117; - case (118): + case(118): return Object118; - case (119): + case(119): return Object119; - case (120): + case(120): return Object120; - case (121): + case(121): return Object121; - case (122): + case(122): return Object122; - case (123): + case(123): return Object123; - case (124): + case(124): return Object124; - case (125): + case(125): return Object125; - case (126): + case(126): return Object126; - case (127): + case(127): return Object127; - case (128): + case(128): return Object128; - case (129): + case(129): return Object129; - case (130): + case(130): return Object130; - case (131): + case(131): return Object131; - case (132): + case(132): return Object132; - case (133): + case(133): return Object133; - case (134): + case(134): return Object134; - case (135): + case(135): return Object135; - case (136): + case(136): return Object136; - case (137): + case(137): return Object137; - case (138): + case(138): return Object138; - case (139): + case(139): return Object139; - case (140): + case(140): return Object140; - case (141): + case(141): return Object141; - case (142): + case(142): return Object142; - case (143): + case(143): return Object143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, Object value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - Object0 = value; - break; - case (1): - Object1 = value; - break; - case (2): - Object2 = value; - break; - case (3): - Object3 = value; - break; - case (4): - Object4 = value; - break; - case (5): - Object5 = value; - break; - case (6): - Object6 = value; - break; - case (7): - Object7 = value; - break; - case (8): - Object8 = value; - break; - case (9): - Object9 = value; - break; - case (10): - Object10 = value; - break; - case (11): - Object11 = value; - break; - case (12): - Object12 = value; - break; - case (13): - Object13 = value; - break; - case (14): - Object14 = value; - break; - case (16): - Object16 = value; - break; - case (17): - Object17 = value; - break; - case (18): - Object18 = value; - break; - case (19): - Object19 = value; - break; - case (20): - Object20 = value; - break; - case (21): - Object21 = value; - break; - case (22): - Object22 = value; - break; - case (23): - Object23 = value; - break; - case (24): - Object24 = value; - break; - case (26): - Object26 = value; - break; - case (28): - Object28 = value; - break; - case (29): - Object29 = value; - break; - case (30): - Object30 = value; - break; - case (31): - Object31 = value; - break; - case (32): - Object32 = value; - break; - case (33): - Object33 = value; - break; - case (35): - Object35 = value; - break; - case (36): - Object36 = value; - break; - case (37): - Object37 = value; - break; - case (38): - Object38 = value; - break; - case (39): - Object39 = value; - break; - case (40): - Object40 = value; - break; - case (41): - Object41 = value; - break; - case (42): - Object42 = value; - break; - case (43): - Object43 = value; - break; - case (44): - Object44 = value; - break; - case (45): - Object45 = value; - break; - case (46): - Object46 = value; - break; - case (47): - Object47 = value; - break; - case (48): - Object48 = value; - break; - case (49): - Object49 = value; - break; - case (50): - Object50 = value; - break; - case (52): - Object52 = value; - break; - case (53): - Object53 = value; - break; - case (54): - Object54 = value; - break; - case (55): - Object55 = value; - break; - case (56): - Object56 = value; - break; - case (57): - Object57 = value; - break; - case (58): - Object58 = value; - break; - case (59): - Object59 = value; - break; - case (60): - Object60 = value; - break; - case (62): - Object62 = value; - break; - case (64): - Object64 = value; - break; - case (65): - Object65 = value; - break; - case (66): - Object66 = value; - break; - case (67): - Object67 = value; - break; - case (68): - Object68 = value; - break; - case (69): - Object69 = value; - break; - case (71): - Object71 = value; - break; - case (72): - Object72 = value; - break; - case (73): - Object73 = value; - break; - case (74): - Object74 = value; - break; - case (75): - Object75 = value; - break; - case (76): - Object76 = value; - break; - case (77): - Object77 = value; - break; - case (78): - Object78 = value; - break; - case (79): - Object79 = value; - break; - case (80): - Object80 = value; - break; - case (81): - Object81 = value; - break; - case (82): - Object82 = value; - break; - case (83): - Object83 = value; - break; - case (84): - Object84 = value; - break; - case (85): - Object85 = value; - break; - case (86): - Object86 = value; - break; - case (88): - Object88 = value; - break; - case (89): - Object89 = value; - break; - case (90): - Object90 = value; - break; - case (91): - Object91 = value; - break; - case (92): - Object92 = value; - break; - case (93): - Object93 = value; - break; - case (94): - Object94 = value; - break; - case (95): - Object95 = value; - break; - case (96): - Object96 = value; - break; - case (98): - Object98 = value; - break; - case (100): - Object100 = value; - break; - case (101): - Object101 = value; - break; - case (102): - Object102 = value; - break; - case (103): - Object103 = value; - break; - case (104): - Object104 = value; - break; - case (105): - Object105 = value; - break; - case (107): - Object107 = value; - break; - case (108): - Object108 = value; - break; - case (109): - Object109 = value; - break; - case (110): - Object110 = value; - break; - case (111): - Object111 = value; - break; - case (112): - Object112 = value; - break; - case (113): - Object113 = value; - break; - case (114): - Object114 = value; - break; - case (115): - Object115 = value; - break; - case (116): - Object116 = value; - break; - case (117): - Object117 = value; - break; - case (118): - Object118 = value; - break; - case (119): - Object119 = value; - break; - case (120): - Object120 = value; - break; - case (121): - Object121 = value; - break; - case (122): - Object122 = value; - break; - case (124): - Object124 = value; - break; - case (125): - Object125 = value; - break; - case (126): - Object126 = value; - break; - case (127): - Object127 = value; - break; - case (128): - Object128 = value; - break; - case (129): - Object129 = value; - break; - case (130): - Object130 = value; - break; - case (131): - Object131 = value; - break; - case (132): - Object132 = value; - break; - case (134): - Object134 = value; - break; - case (136): - Object136 = value; - break; - case (137): - Object137 = value; - break; - case (138): - Object138 = value; - break; - case (139): - Object139 = value; - break; - case (140): - Object140 = value; - break; - case (141): - Object141 = value; - break; - case (143): - Object143 = value; - break; + public boolean set(int index,Object value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + Object0= value; + break; + case(1): + Object1= value; + break; + case(2): + Object2= value; + break; + case(3): + Object3= value; + break; + case(4): + Object4= value; + break; + case(5): + Object5= value; + break; + case(6): + Object6= value; + break; + case(7): + Object7= value; + break; + case(8): + Object8= value; + break; + case(9): + Object9= value; + break; + case(10): + Object10= value; + break; + case(11): + Object11= value; + break; + case(12): + Object12= value; + break; + case(13): + Object13= value; + break; + case(14): + Object14= value; + break; + case(16): + Object16= value; + break; + case(17): + Object17= value; + break; + case(18): + Object18= value; + break; + case(19): + Object19= value; + break; + case(20): + Object20= value; + break; + case(21): + Object21= value; + break; + case(22): + Object22= value; + break; + case(23): + Object23= value; + break; + case(24): + Object24= value; + break; + case(26): + Object26= value; + break; + case(28): + Object28= value; + break; + case(29): + Object29= value; + break; + case(30): + Object30= value; + break; + case(31): + Object31= value; + break; + case(32): + Object32= value; + break; + case(33): + Object33= value; + break; + case(35): + Object35= value; + break; + case(36): + Object36= value; + break; + case(37): + Object37= value; + break; + case(38): + Object38= value; + break; + case(39): + Object39= value; + break; + case(40): + Object40= value; + break; + case(41): + Object41= value; + break; + case(42): + Object42= value; + break; + case(43): + Object43= value; + break; + case(44): + Object44= value; + break; + case(45): + Object45= value; + break; + case(46): + Object46= value; + break; + case(47): + Object47= value; + break; + case(48): + Object48= value; + break; + case(49): + Object49= value; + break; + case(50): + Object50= value; + break; + case(52): + Object52= value; + break; + case(53): + Object53= value; + break; + case(54): + Object54= value; + break; + case(55): + Object55= value; + break; + case(56): + Object56= value; + break; + case(57): + Object57= value; + break; + case(58): + Object58= value; + break; + case(59): + Object59= value; + break; + case(60): + Object60= value; + break; + case(62): + Object62= value; + break; + case(64): + Object64= value; + break; + case(65): + Object65= value; + break; + case(66): + Object66= value; + break; + case(67): + Object67= value; + break; + case(68): + Object68= value; + break; + case(69): + Object69= value; + break; + case(71): + Object71= value; + break; + case(72): + Object72= value; + break; + case(73): + Object73= value; + break; + case(74): + Object74= value; + break; + case(75): + Object75= value; + break; + case(76): + Object76= value; + break; + case(77): + Object77= value; + break; + case(78): + Object78= value; + break; + case(79): + Object79= value; + break; + case(80): + Object80= value; + break; + case(81): + Object81= value; + break; + case(82): + Object82= value; + break; + case(83): + Object83= value; + break; + case(84): + Object84= value; + break; + case(85): + Object85= value; + break; + case(86): + Object86= value; + break; + case(88): + Object88= value; + break; + case(89): + Object89= value; + break; + case(90): + Object90= value; + break; + case(91): + Object91= value; + break; + case(92): + Object92= value; + break; + case(93): + Object93= value; + break; + case(94): + Object94= value; + break; + case(95): + Object95= value; + break; + case(96): + Object96= value; + break; + case(98): + Object98= value; + break; + case(100): + Object100= value; + break; + case(101): + Object101= value; + break; + case(102): + Object102= value; + break; + case(103): + Object103= value; + break; + case(104): + Object104= value; + break; + case(105): + Object105= value; + break; + case(107): + Object107= value; + break; + case(108): + Object108= value; + break; + case(109): + Object109= value; + break; + case(110): + Object110= value; + break; + case(111): + Object111= value; + break; + case(112): + Object112= value; + break; + case(113): + Object113= value; + break; + case(114): + Object114= value; + break; + case(115): + Object115= value; + break; + case(116): + Object116= value; + break; + case(117): + Object117= value; + break; + case(118): + Object118= value; + break; + case(119): + Object119= value; + break; + case(120): + Object120= value; + break; + case(121): + Object121= value; + break; + case(122): + Object122= value; + break; + case(124): + Object124= value; + break; + case(125): + Object125= value; + break; + case(126): + Object126= value; + break; + case(127): + Object127= value; + break; + case(128): + Object128= value; + break; + case(129): + Object129= value; + break; + case(130): + Object130= value; + break; + case(131): + Object131= value; + break; + case(132): + Object132= value; + break; + case(134): + Object134= value; + break; + case(136): + Object136= value; + break; + case(137): + Object137= value; + break; + case(138): + Object138= value; + break; + case(139): + Object139= value; + break; + case(140): + Object140= value; + break; + case(141): + Object141= value; + break; + case(143): + Object143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitiveboolean.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitiveboolean.java index 4b931f4ec..0f579b6f4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitiveboolean.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitiveboolean.java @@ -5,21 +5,21 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -public class FieldsOfPrimitiveboolean { +public class FieldsOfPrimitiveboolean { public int identifier; private boolean boolean0; private boolean boolean1; @@ -48,14 +48,14 @@ public class FieldsOfPrimitiveboolean { private static transient boolean boolean24; private static final boolean boolean25 = false; private static volatile boolean boolean26; - private final transient boolean boolean27 = false; + private transient final boolean boolean27 = false; private transient volatile boolean boolean28; private transient volatile boolean boolean29; private transient volatile boolean boolean30; private transient volatile boolean boolean31; private transient volatile boolean boolean32; private transient volatile boolean boolean33; - private static final transient boolean boolean34 = false; + private static transient final boolean boolean34 = false; private static transient volatile boolean boolean35; public boolean boolean36; public boolean boolean37; @@ -84,14 +84,14 @@ public class FieldsOfPrimitiveboolean { public static transient boolean boolean60; public static final boolean boolean61 = false; public static volatile boolean boolean62; - public final transient boolean boolean63 = false; + public transient final boolean boolean63 = false; public transient volatile boolean boolean64; public transient volatile boolean boolean65; public transient volatile boolean boolean66; public transient volatile boolean boolean67; public transient volatile boolean boolean68; public transient volatile boolean boolean69; - public static final transient boolean boolean70 = false; + public static transient final boolean boolean70 = false; public static transient volatile boolean boolean71; protected boolean boolean72; protected boolean boolean73; @@ -120,14 +120,14 @@ public class FieldsOfPrimitiveboolean { protected static transient boolean boolean96; protected static final boolean boolean97 = false; protected static volatile boolean boolean98; - protected final transient boolean boolean99 = false; + protected transient final boolean boolean99 = false; protected transient volatile boolean boolean100; protected transient volatile boolean boolean101; protected transient volatile boolean boolean102; protected transient volatile boolean boolean103; protected transient volatile boolean boolean104; protected transient volatile boolean boolean105; - protected static final transient boolean boolean106 = false; + protected static transient final boolean boolean106 = false; protected static transient volatile boolean boolean107; boolean boolean108; boolean boolean109; @@ -156,936 +156,935 @@ public class FieldsOfPrimitiveboolean { static transient boolean boolean132; static final boolean boolean133 = false; static volatile boolean boolean134; - final transient boolean boolean135 = false; + transient final boolean boolean135 = false; transient volatile boolean boolean136; transient volatile boolean boolean137; transient volatile boolean boolean138; transient volatile boolean boolean139; transient volatile boolean boolean140; transient volatile boolean boolean141; - static final transient boolean boolean142 = false; + static transient final boolean boolean142 = false; static transient volatile boolean boolean143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private boolean boolean0", - "embedded= true private boolean boolean1", - "embedded= false private boolean boolean2", - "persistence-modifier= none private boolean boolean3", - "persistence-modifier= persistent private boolean boolean4", - "persistence-modifier= persistent embedded= true private boolean boolean5", - "persistence-modifier= persistent embedded= false private boolean boolean6", - "persistence-modifier= transactional private boolean boolean7", - "private static boolean boolean8", - "private transient boolean boolean9", - "persistence-modifier= none private transient boolean boolean10", - "persistence-modifier= persistent private transient boolean boolean11", - "persistence-modifier= persistent embedded= true private transient boolean boolean12", - "persistence-modifier= persistent embedded= false private transient boolean boolean13", - "persistence-modifier= transactional private transient boolean boolean14", - "private final boolean boolean15", - "private volatile boolean boolean16", - "embedded= true private volatile boolean boolean17", - "embedded= false private volatile boolean boolean18", - "persistence-modifier= none private volatile boolean boolean19", - "persistence-modifier= persistent private volatile boolean boolean20", - "persistence-modifier= persistent embedded= true private volatile boolean boolean21", - "persistence-modifier= persistent embedded= false private volatile boolean boolean22", - "persistence-modifier= transactional private volatile boolean boolean23", - "private static transient boolean boolean24", - "private static final boolean boolean25", - "private static volatile boolean boolean26", - "private transient final boolean boolean27", - "private transient volatile boolean boolean28", - "persistence-modifier= none private transient volatile boolean boolean29", - "persistence-modifier= persistent private transient volatile boolean boolean30", - "persistence-modifier= persistent embedded= true private transient volatile boolean boolean31", - "persistence-modifier= persistent embedded= false private transient volatile boolean boolean32", - "persistence-modifier= transactional private transient volatile boolean boolean33", - "private static transient final boolean boolean34", - "private static transient volatile boolean boolean35", - "public boolean boolean36", - "embedded= true public boolean boolean37", - "embedded= false public boolean boolean38", - "persistence-modifier= none public boolean boolean39", - "persistence-modifier= persistent public boolean boolean40", - "persistence-modifier= persistent embedded= true public boolean boolean41", - "persistence-modifier= persistent embedded= false public boolean boolean42", - "persistence-modifier= transactional public boolean boolean43", - "public static boolean boolean44", - "public transient boolean boolean45", - "persistence-modifier= none public transient boolean boolean46", - "persistence-modifier= persistent public transient boolean boolean47", - "persistence-modifier= persistent embedded= true public transient boolean boolean48", - "persistence-modifier= persistent embedded= false public transient boolean boolean49", - "persistence-modifier= transactional public transient boolean boolean50", - "public final boolean boolean51", - "public volatile boolean boolean52", - "embedded= true public volatile boolean boolean53", - "embedded= false public volatile boolean boolean54", - "persistence-modifier= none public volatile boolean boolean55", - "persistence-modifier= persistent public volatile boolean boolean56", - "persistence-modifier= persistent embedded= true public volatile boolean boolean57", - "persistence-modifier= persistent embedded= false public volatile boolean boolean58", - "persistence-modifier= transactional public volatile boolean boolean59", - "public static transient boolean boolean60", - "public static final boolean boolean61", - "public static volatile boolean boolean62", - "public transient final boolean boolean63", - "public transient volatile boolean boolean64", - "persistence-modifier= none public transient volatile boolean boolean65", - "persistence-modifier= persistent public transient volatile boolean boolean66", - "persistence-modifier= persistent embedded= true public transient volatile boolean boolean67", - "persistence-modifier= persistent embedded= false public transient volatile boolean boolean68", - "persistence-modifier= transactional public transient volatile boolean boolean69", - "public static transient final boolean boolean70", - "public static transient volatile boolean boolean71", - "protected boolean boolean72", - "embedded= true protected boolean boolean73", - "embedded= false protected boolean boolean74", - "persistence-modifier= none protected boolean boolean75", - "persistence-modifier= persistent protected boolean boolean76", - "persistence-modifier= persistent embedded= true protected boolean boolean77", - "persistence-modifier= persistent embedded= false protected boolean boolean78", - "persistence-modifier= transactional protected boolean boolean79", - "protected static boolean boolean80", - "protected transient boolean boolean81", - "persistence-modifier= none protected transient boolean boolean82", - "persistence-modifier= persistent protected transient boolean boolean83", - "persistence-modifier= persistent embedded= true protected transient boolean boolean84", - "persistence-modifier= persistent embedded= false protected transient boolean boolean85", - "persistence-modifier= transactional protected transient boolean boolean86", - "protected final boolean boolean87", - "protected volatile boolean boolean88", - "embedded= true protected volatile boolean boolean89", - "embedded= false protected volatile boolean boolean90", - "persistence-modifier= none protected volatile boolean boolean91", - "persistence-modifier= persistent protected volatile boolean boolean92", - "persistence-modifier= persistent embedded= true protected volatile boolean boolean93", - "persistence-modifier= persistent embedded= false protected volatile boolean boolean94", - "persistence-modifier= transactional protected volatile boolean boolean95", - "protected static transient boolean boolean96", - "protected static final boolean boolean97", - "protected static volatile boolean boolean98", - "protected transient final boolean boolean99", - "protected transient volatile boolean boolean100", - "persistence-modifier= none protected transient volatile boolean boolean101", - "persistence-modifier= persistent protected transient volatile boolean boolean102", - "persistence-modifier= persistent embedded= true protected transient volatile boolean boolean103", - "persistence-modifier= persistent embedded= false protected transient volatile boolean boolean104", - "persistence-modifier= transactional protected transient volatile boolean boolean105", - "protected static transient final boolean boolean106", - "protected static transient volatile boolean boolean107", - "boolean boolean108", - "embedded= true boolean boolean109", - "embedded= false boolean boolean110", - "persistence-modifier= none boolean boolean111", - "persistence-modifier= persistent boolean boolean112", - "persistence-modifier= persistent embedded= true boolean boolean113", - "persistence-modifier= persistent embedded= false boolean boolean114", - "persistence-modifier= transactional boolean boolean115", - "static boolean boolean116", - "transient boolean boolean117", - "persistence-modifier= none transient boolean boolean118", - "persistence-modifier= persistent transient boolean boolean119", - "persistence-modifier= persistent embedded= true transient boolean boolean120", - "persistence-modifier= persistent embedded= false transient boolean boolean121", - "persistence-modifier= transactional transient boolean boolean122", - "final boolean boolean123", - "volatile boolean boolean124", - "embedded= true volatile boolean boolean125", - "embedded= false volatile boolean boolean126", - "persistence-modifier= none volatile boolean boolean127", - "persistence-modifier= persistent volatile boolean boolean128", - "persistence-modifier= persistent embedded= true volatile boolean boolean129", - "persistence-modifier= persistent embedded= false volatile boolean boolean130", - "persistence-modifier= transactional volatile boolean boolean131", - "static transient boolean boolean132", - "static final boolean boolean133", - "static volatile boolean boolean134", - "transient final boolean boolean135", - "transient volatile boolean boolean136", - "persistence-modifier= none transient volatile boolean boolean137", - "persistence-modifier= persistent transient volatile boolean boolean138", - "persistence-modifier= persistent embedded= true transient volatile boolean boolean139", - "persistence-modifier= persistent embedded= false transient volatile boolean boolean140", - "persistence-modifier= transactional transient volatile boolean boolean141", - "static transient final boolean boolean142", - "static transient volatile boolean boolean143" + public static final String [] fieldSpecs = { + "private boolean boolean0", + "embedded= true private boolean boolean1", + "embedded= false private boolean boolean2", + "persistence-modifier= none private boolean boolean3", + "persistence-modifier= persistent private boolean boolean4", + "persistence-modifier= persistent embedded= true private boolean boolean5", + "persistence-modifier= persistent embedded= false private boolean boolean6", + "persistence-modifier= transactional private boolean boolean7", + "private static boolean boolean8", + "private transient boolean boolean9", + "persistence-modifier= none private transient boolean boolean10", + "persistence-modifier= persistent private transient boolean boolean11", + "persistence-modifier= persistent embedded= true private transient boolean boolean12", + "persistence-modifier= persistent embedded= false private transient boolean boolean13", + "persistence-modifier= transactional private transient boolean boolean14", + "private final boolean boolean15", + "private volatile boolean boolean16", + "embedded= true private volatile boolean boolean17", + "embedded= false private volatile boolean boolean18", + "persistence-modifier= none private volatile boolean boolean19", + "persistence-modifier= persistent private volatile boolean boolean20", + "persistence-modifier= persistent embedded= true private volatile boolean boolean21", + "persistence-modifier= persistent embedded= false private volatile boolean boolean22", + "persistence-modifier= transactional private volatile boolean boolean23", + "private static transient boolean boolean24", + "private static final boolean boolean25", + "private static volatile boolean boolean26", + "private transient final boolean boolean27", + "private transient volatile boolean boolean28", + "persistence-modifier= none private transient volatile boolean boolean29", + "persistence-modifier= persistent private transient volatile boolean boolean30", + "persistence-modifier= persistent embedded= true private transient volatile boolean boolean31", + "persistence-modifier= persistent embedded= false private transient volatile boolean boolean32", + "persistence-modifier= transactional private transient volatile boolean boolean33", + "private static transient final boolean boolean34", + "private static transient volatile boolean boolean35", + "public boolean boolean36", + "embedded= true public boolean boolean37", + "embedded= false public boolean boolean38", + "persistence-modifier= none public boolean boolean39", + "persistence-modifier= persistent public boolean boolean40", + "persistence-modifier= persistent embedded= true public boolean boolean41", + "persistence-modifier= persistent embedded= false public boolean boolean42", + "persistence-modifier= transactional public boolean boolean43", + "public static boolean boolean44", + "public transient boolean boolean45", + "persistence-modifier= none public transient boolean boolean46", + "persistence-modifier= persistent public transient boolean boolean47", + "persistence-modifier= persistent embedded= true public transient boolean boolean48", + "persistence-modifier= persistent embedded= false public transient boolean boolean49", + "persistence-modifier= transactional public transient boolean boolean50", + "public final boolean boolean51", + "public volatile boolean boolean52", + "embedded= true public volatile boolean boolean53", + "embedded= false public volatile boolean boolean54", + "persistence-modifier= none public volatile boolean boolean55", + "persistence-modifier= persistent public volatile boolean boolean56", + "persistence-modifier= persistent embedded= true public volatile boolean boolean57", + "persistence-modifier= persistent embedded= false public volatile boolean boolean58", + "persistence-modifier= transactional public volatile boolean boolean59", + "public static transient boolean boolean60", + "public static final boolean boolean61", + "public static volatile boolean boolean62", + "public transient final boolean boolean63", + "public transient volatile boolean boolean64", + "persistence-modifier= none public transient volatile boolean boolean65", + "persistence-modifier= persistent public transient volatile boolean boolean66", + "persistence-modifier= persistent embedded= true public transient volatile boolean boolean67", + "persistence-modifier= persistent embedded= false public transient volatile boolean boolean68", + "persistence-modifier= transactional public transient volatile boolean boolean69", + "public static transient final boolean boolean70", + "public static transient volatile boolean boolean71", + "protected boolean boolean72", + "embedded= true protected boolean boolean73", + "embedded= false protected boolean boolean74", + "persistence-modifier= none protected boolean boolean75", + "persistence-modifier= persistent protected boolean boolean76", + "persistence-modifier= persistent embedded= true protected boolean boolean77", + "persistence-modifier= persistent embedded= false protected boolean boolean78", + "persistence-modifier= transactional protected boolean boolean79", + "protected static boolean boolean80", + "protected transient boolean boolean81", + "persistence-modifier= none protected transient boolean boolean82", + "persistence-modifier= persistent protected transient boolean boolean83", + "persistence-modifier= persistent embedded= true protected transient boolean boolean84", + "persistence-modifier= persistent embedded= false protected transient boolean boolean85", + "persistence-modifier= transactional protected transient boolean boolean86", + "protected final boolean boolean87", + "protected volatile boolean boolean88", + "embedded= true protected volatile boolean boolean89", + "embedded= false protected volatile boolean boolean90", + "persistence-modifier= none protected volatile boolean boolean91", + "persistence-modifier= persistent protected volatile boolean boolean92", + "persistence-modifier= persistent embedded= true protected volatile boolean boolean93", + "persistence-modifier= persistent embedded= false protected volatile boolean boolean94", + "persistence-modifier= transactional protected volatile boolean boolean95", + "protected static transient boolean boolean96", + "protected static final boolean boolean97", + "protected static volatile boolean boolean98", + "protected transient final boolean boolean99", + "protected transient volatile boolean boolean100", + "persistence-modifier= none protected transient volatile boolean boolean101", + "persistence-modifier= persistent protected transient volatile boolean boolean102", + "persistence-modifier= persistent embedded= true protected transient volatile boolean boolean103", + "persistence-modifier= persistent embedded= false protected transient volatile boolean boolean104", + "persistence-modifier= transactional protected transient volatile boolean boolean105", + "protected static transient final boolean boolean106", + "protected static transient volatile boolean boolean107", + "boolean boolean108", + "embedded= true boolean boolean109", + "embedded= false boolean boolean110", + "persistence-modifier= none boolean boolean111", + "persistence-modifier= persistent boolean boolean112", + "persistence-modifier= persistent embedded= true boolean boolean113", + "persistence-modifier= persistent embedded= false boolean boolean114", + "persistence-modifier= transactional boolean boolean115", + "static boolean boolean116", + "transient boolean boolean117", + "persistence-modifier= none transient boolean boolean118", + "persistence-modifier= persistent transient boolean boolean119", + "persistence-modifier= persistent embedded= true transient boolean boolean120", + "persistence-modifier= persistent embedded= false transient boolean boolean121", + "persistence-modifier= transactional transient boolean boolean122", + "final boolean boolean123", + "volatile boolean boolean124", + "embedded= true volatile boolean boolean125", + "embedded= false volatile boolean boolean126", + "persistence-modifier= none volatile boolean boolean127", + "persistence-modifier= persistent volatile boolean boolean128", + "persistence-modifier= persistent embedded= true volatile boolean boolean129", + "persistence-modifier= persistent embedded= false volatile boolean boolean130", + "persistence-modifier= transactional volatile boolean boolean131", + "static transient boolean boolean132", + "static final boolean boolean133", + "static volatile boolean boolean134", + "transient final boolean boolean135", + "transient volatile boolean boolean136", + "persistence-modifier= none transient volatile boolean boolean137", + "persistence-modifier= persistent transient volatile boolean boolean138", + "persistence-modifier= persistent embedded= true transient volatile boolean boolean139", + "persistence-modifier= persistent embedded= false transient volatile boolean boolean140", + "persistence-modifier= transactional transient volatile boolean boolean141", + "static transient final boolean boolean142", + "static transient volatile boolean boolean143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public boolean get(int index) { - switch (index) { - case (0): + public boolean get(int index) + { + switch (index) + { + case(0): return boolean0; - case (1): + case(1): return boolean1; - case (2): + case(2): return boolean2; - case (3): + case(3): return boolean3; - case (4): + case(4): return boolean4; - case (5): + case(5): return boolean5; - case (6): + case(6): return boolean6; - case (7): + case(7): return boolean7; - case (8): + case(8): return boolean8; - case (9): + case(9): return boolean9; - case (10): + case(10): return boolean10; - case (11): + case(11): return boolean11; - case (12): + case(12): return boolean12; - case (13): + case(13): return boolean13; - case (14): + case(14): return boolean14; - case (15): + case(15): return boolean15; - case (16): + case(16): return boolean16; - case (17): + case(17): return boolean17; - case (18): + case(18): return boolean18; - case (19): + case(19): return boolean19; - case (20): + case(20): return boolean20; - case (21): + case(21): return boolean21; - case (22): + case(22): return boolean22; - case (23): + case(23): return boolean23; - case (24): + case(24): return boolean24; - case (25): + case(25): return boolean25; - case (26): + case(26): return boolean26; - case (27): + case(27): return boolean27; - case (28): + case(28): return boolean28; - case (29): + case(29): return boolean29; - case (30): + case(30): return boolean30; - case (31): + case(31): return boolean31; - case (32): + case(32): return boolean32; - case (33): + case(33): return boolean33; - case (34): + case(34): return boolean34; - case (35): + case(35): return boolean35; - case (36): + case(36): return boolean36; - case (37): + case(37): return boolean37; - case (38): + case(38): return boolean38; - case (39): + case(39): return boolean39; - case (40): + case(40): return boolean40; - case (41): + case(41): return boolean41; - case (42): + case(42): return boolean42; - case (43): + case(43): return boolean43; - case (44): + case(44): return boolean44; - case (45): + case(45): return boolean45; - case (46): + case(46): return boolean46; - case (47): + case(47): return boolean47; - case (48): + case(48): return boolean48; - case (49): + case(49): return boolean49; - case (50): + case(50): return boolean50; - case (51): + case(51): return boolean51; - case (52): + case(52): return boolean52; - case (53): + case(53): return boolean53; - case (54): + case(54): return boolean54; - case (55): + case(55): return boolean55; - case (56): + case(56): return boolean56; - case (57): + case(57): return boolean57; - case (58): + case(58): return boolean58; - case (59): + case(59): return boolean59; - case (60): + case(60): return boolean60; - case (61): + case(61): return boolean61; - case (62): + case(62): return boolean62; - case (63): + case(63): return boolean63; - case (64): + case(64): return boolean64; - case (65): + case(65): return boolean65; - case (66): + case(66): return boolean66; - case (67): + case(67): return boolean67; - case (68): + case(68): return boolean68; - case (69): + case(69): return boolean69; - case (70): + case(70): return boolean70; - case (71): + case(71): return boolean71; - case (72): + case(72): return boolean72; - case (73): + case(73): return boolean73; - case (74): + case(74): return boolean74; - case (75): + case(75): return boolean75; - case (76): + case(76): return boolean76; - case (77): + case(77): return boolean77; - case (78): + case(78): return boolean78; - case (79): + case(79): return boolean79; - case (80): + case(80): return boolean80; - case (81): + case(81): return boolean81; - case (82): + case(82): return boolean82; - case (83): + case(83): return boolean83; - case (84): + case(84): return boolean84; - case (85): + case(85): return boolean85; - case (86): + case(86): return boolean86; - case (87): + case(87): return boolean87; - case (88): + case(88): return boolean88; - case (89): + case(89): return boolean89; - case (90): + case(90): return boolean90; - case (91): + case(91): return boolean91; - case (92): + case(92): return boolean92; - case (93): + case(93): return boolean93; - case (94): + case(94): return boolean94; - case (95): + case(95): return boolean95; - case (96): + case(96): return boolean96; - case (97): + case(97): return boolean97; - case (98): + case(98): return boolean98; - case (99): + case(99): return boolean99; - case (100): + case(100): return boolean100; - case (101): + case(101): return boolean101; - case (102): + case(102): return boolean102; - case (103): + case(103): return boolean103; - case (104): + case(104): return boolean104; - case (105): + case(105): return boolean105; - case (106): + case(106): return boolean106; - case (107): + case(107): return boolean107; - case (108): + case(108): return boolean108; - case (109): + case(109): return boolean109; - case (110): + case(110): return boolean110; - case (111): + case(111): return boolean111; - case (112): + case(112): return boolean112; - case (113): + case(113): return boolean113; - case (114): + case(114): return boolean114; - case (115): + case(115): return boolean115; - case (116): + case(116): return boolean116; - case (117): + case(117): return boolean117; - case (118): + case(118): return boolean118; - case (119): + case(119): return boolean119; - case (120): + case(120): return boolean120; - case (121): + case(121): return boolean121; - case (122): + case(122): return boolean122; - case (123): + case(123): return boolean123; - case (124): + case(124): return boolean124; - case (125): + case(125): return boolean125; - case (126): + case(126): return boolean126; - case (127): + case(127): return boolean127; - case (128): + case(128): return boolean128; - case (129): + case(129): return boolean129; - case (130): + case(130): return boolean130; - case (131): + case(131): return boolean131; - case (132): + case(132): return boolean132; - case (133): + case(133): return boolean133; - case (134): + case(134): return boolean134; - case (135): + case(135): return boolean135; - case (136): + case(136): return boolean136; - case (137): + case(137): return boolean137; - case (138): + case(138): return boolean138; - case (139): + case(139): return boolean139; - case (140): + case(140): return boolean140; - case (141): + case(141): return boolean141; - case (142): + case(142): return boolean142; - case (143): + case(143): return boolean143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, boolean value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - boolean0 = value; - break; - case (1): - boolean1 = value; - break; - case (2): - boolean2 = value; - break; - case (3): - boolean3 = value; - break; - case (4): - boolean4 = value; - break; - case (5): - boolean5 = value; - break; - case (6): - boolean6 = value; - break; - case (7): - boolean7 = value; - break; - case (8): - boolean8 = value; - break; - case (9): - boolean9 = value; - break; - case (10): - boolean10 = value; - break; - case (11): - boolean11 = value; - break; - case (12): - boolean12 = value; - break; - case (13): - boolean13 = value; - break; - case (14): - boolean14 = value; - break; - case (16): - boolean16 = value; - break; - case (17): - boolean17 = value; - break; - case (18): - boolean18 = value; - break; - case (19): - boolean19 = value; - break; - case (20): - boolean20 = value; - break; - case (21): - boolean21 = value; - break; - case (22): - boolean22 = value; - break; - case (23): - boolean23 = value; - break; - case (24): - boolean24 = value; - break; - case (26): - boolean26 = value; - break; - case (28): - boolean28 = value; - break; - case (29): - boolean29 = value; - break; - case (30): - boolean30 = value; - break; - case (31): - boolean31 = value; - break; - case (32): - boolean32 = value; - break; - case (33): - boolean33 = value; - break; - case (35): - boolean35 = value; - break; - case (36): - boolean36 = value; - break; - case (37): - boolean37 = value; - break; - case (38): - boolean38 = value; - break; - case (39): - boolean39 = value; - break; - case (40): - boolean40 = value; - break; - case (41): - boolean41 = value; - break; - case (42): - boolean42 = value; - break; - case (43): - boolean43 = value; - break; - case (44): - boolean44 = value; - break; - case (45): - boolean45 = value; - break; - case (46): - boolean46 = value; - break; - case (47): - boolean47 = value; - break; - case (48): - boolean48 = value; - break; - case (49): - boolean49 = value; - break; - case (50): - boolean50 = value; - break; - case (52): - boolean52 = value; - break; - case (53): - boolean53 = value; - break; - case (54): - boolean54 = value; - break; - case (55): - boolean55 = value; - break; - case (56): - boolean56 = value; - break; - case (57): - boolean57 = value; - break; - case (58): - boolean58 = value; - break; - case (59): - boolean59 = value; - break; - case (60): - boolean60 = value; - break; - case (62): - boolean62 = value; - break; - case (64): - boolean64 = value; - break; - case (65): - boolean65 = value; - break; - case (66): - boolean66 = value; - break; - case (67): - boolean67 = value; - break; - case (68): - boolean68 = value; - break; - case (69): - boolean69 = value; - break; - case (71): - boolean71 = value; - break; - case (72): - boolean72 = value; - break; - case (73): - boolean73 = value; - break; - case (74): - boolean74 = value; - break; - case (75): - boolean75 = value; - break; - case (76): - boolean76 = value; - break; - case (77): - boolean77 = value; - break; - case (78): - boolean78 = value; - break; - case (79): - boolean79 = value; - break; - case (80): - boolean80 = value; - break; - case (81): - boolean81 = value; - break; - case (82): - boolean82 = value; - break; - case (83): - boolean83 = value; - break; - case (84): - boolean84 = value; - break; - case (85): - boolean85 = value; - break; - case (86): - boolean86 = value; - break; - case (88): - boolean88 = value; - break; - case (89): - boolean89 = value; - break; - case (90): - boolean90 = value; - break; - case (91): - boolean91 = value; - break; - case (92): - boolean92 = value; - break; - case (93): - boolean93 = value; - break; - case (94): - boolean94 = value; - break; - case (95): - boolean95 = value; - break; - case (96): - boolean96 = value; - break; - case (98): - boolean98 = value; - break; - case (100): - boolean100 = value; - break; - case (101): - boolean101 = value; - break; - case (102): - boolean102 = value; - break; - case (103): - boolean103 = value; - break; - case (104): - boolean104 = value; - break; - case (105): - boolean105 = value; - break; - case (107): - boolean107 = value; - break; - case (108): - boolean108 = value; - break; - case (109): - boolean109 = value; - break; - case (110): - boolean110 = value; - break; - case (111): - boolean111 = value; - break; - case (112): - boolean112 = value; - break; - case (113): - boolean113 = value; - break; - case (114): - boolean114 = value; - break; - case (115): - boolean115 = value; - break; - case (116): - boolean116 = value; - break; - case (117): - boolean117 = value; - break; - case (118): - boolean118 = value; - break; - case (119): - boolean119 = value; - break; - case (120): - boolean120 = value; - break; - case (121): - boolean121 = value; - break; - case (122): - boolean122 = value; - break; - case (124): - boolean124 = value; - break; - case (125): - boolean125 = value; - break; - case (126): - boolean126 = value; - break; - case (127): - boolean127 = value; - break; - case (128): - boolean128 = value; - break; - case (129): - boolean129 = value; - break; - case (130): - boolean130 = value; - break; - case (131): - boolean131 = value; - break; - case (132): - boolean132 = value; - break; - case (134): - boolean134 = value; - break; - case (136): - boolean136 = value; - break; - case (137): - boolean137 = value; - break; - case (138): - boolean138 = value; - break; - case (139): - boolean139 = value; - break; - case (140): - boolean140 = value; - break; - case (141): - boolean141 = value; - break; - case (143): - boolean143 = value; - break; + public boolean set(int index,boolean value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + boolean0= value; + break; + case(1): + boolean1= value; + break; + case(2): + boolean2= value; + break; + case(3): + boolean3= value; + break; + case(4): + boolean4= value; + break; + case(5): + boolean5= value; + break; + case(6): + boolean6= value; + break; + case(7): + boolean7= value; + break; + case(8): + boolean8= value; + break; + case(9): + boolean9= value; + break; + case(10): + boolean10= value; + break; + case(11): + boolean11= value; + break; + case(12): + boolean12= value; + break; + case(13): + boolean13= value; + break; + case(14): + boolean14= value; + break; + case(16): + boolean16= value; + break; + case(17): + boolean17= value; + break; + case(18): + boolean18= value; + break; + case(19): + boolean19= value; + break; + case(20): + boolean20= value; + break; + case(21): + boolean21= value; + break; + case(22): + boolean22= value; + break; + case(23): + boolean23= value; + break; + case(24): + boolean24= value; + break; + case(26): + boolean26= value; + break; + case(28): + boolean28= value; + break; + case(29): + boolean29= value; + break; + case(30): + boolean30= value; + break; + case(31): + boolean31= value; + break; + case(32): + boolean32= value; + break; + case(33): + boolean33= value; + break; + case(35): + boolean35= value; + break; + case(36): + boolean36= value; + break; + case(37): + boolean37= value; + break; + case(38): + boolean38= value; + break; + case(39): + boolean39= value; + break; + case(40): + boolean40= value; + break; + case(41): + boolean41= value; + break; + case(42): + boolean42= value; + break; + case(43): + boolean43= value; + break; + case(44): + boolean44= value; + break; + case(45): + boolean45= value; + break; + case(46): + boolean46= value; + break; + case(47): + boolean47= value; + break; + case(48): + boolean48= value; + break; + case(49): + boolean49= value; + break; + case(50): + boolean50= value; + break; + case(52): + boolean52= value; + break; + case(53): + boolean53= value; + break; + case(54): + boolean54= value; + break; + case(55): + boolean55= value; + break; + case(56): + boolean56= value; + break; + case(57): + boolean57= value; + break; + case(58): + boolean58= value; + break; + case(59): + boolean59= value; + break; + case(60): + boolean60= value; + break; + case(62): + boolean62= value; + break; + case(64): + boolean64= value; + break; + case(65): + boolean65= value; + break; + case(66): + boolean66= value; + break; + case(67): + boolean67= value; + break; + case(68): + boolean68= value; + break; + case(69): + boolean69= value; + break; + case(71): + boolean71= value; + break; + case(72): + boolean72= value; + break; + case(73): + boolean73= value; + break; + case(74): + boolean74= value; + break; + case(75): + boolean75= value; + break; + case(76): + boolean76= value; + break; + case(77): + boolean77= value; + break; + case(78): + boolean78= value; + break; + case(79): + boolean79= value; + break; + case(80): + boolean80= value; + break; + case(81): + boolean81= value; + break; + case(82): + boolean82= value; + break; + case(83): + boolean83= value; + break; + case(84): + boolean84= value; + break; + case(85): + boolean85= value; + break; + case(86): + boolean86= value; + break; + case(88): + boolean88= value; + break; + case(89): + boolean89= value; + break; + case(90): + boolean90= value; + break; + case(91): + boolean91= value; + break; + case(92): + boolean92= value; + break; + case(93): + boolean93= value; + break; + case(94): + boolean94= value; + break; + case(95): + boolean95= value; + break; + case(96): + boolean96= value; + break; + case(98): + boolean98= value; + break; + case(100): + boolean100= value; + break; + case(101): + boolean101= value; + break; + case(102): + boolean102= value; + break; + case(103): + boolean103= value; + break; + case(104): + boolean104= value; + break; + case(105): + boolean105= value; + break; + case(107): + boolean107= value; + break; + case(108): + boolean108= value; + break; + case(109): + boolean109= value; + break; + case(110): + boolean110= value; + break; + case(111): + boolean111= value; + break; + case(112): + boolean112= value; + break; + case(113): + boolean113= value; + break; + case(114): + boolean114= value; + break; + case(115): + boolean115= value; + break; + case(116): + boolean116= value; + break; + case(117): + boolean117= value; + break; + case(118): + boolean118= value; + break; + case(119): + boolean119= value; + break; + case(120): + boolean120= value; + break; + case(121): + boolean121= value; + break; + case(122): + boolean122= value; + break; + case(124): + boolean124= value; + break; + case(125): + boolean125= value; + break; + case(126): + boolean126= value; + break; + case(127): + boolean127= value; + break; + case(128): + boolean128= value; + break; + case(129): + boolean129= value; + break; + case(130): + boolean130= value; + break; + case(131): + boolean131= value; + break; + case(132): + boolean132= value; + break; + case(134): + boolean134= value; + break; + case(136): + boolean136= value; + break; + case(137): + boolean137= value; + break; + case(138): + boolean138= value; + break; + case(139): + boolean139= value; + break; + case(140): + boolean140= value; + break; + case(141): + boolean141= value; + break; + case(143): + boolean143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitivebyte.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitivebyte.java index 0c6cc202e..71a1a8c52 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitivebyte.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitivebyte.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -19,7 +19,7 @@ import java.io.Serializable; -public class FieldsOfPrimitivebyte { +public class FieldsOfPrimitivebyte { public int identifier; private byte byte0; private byte byte1; @@ -48,14 +48,14 @@ public class FieldsOfPrimitivebyte { private static transient byte byte24; private static final byte byte25 = 5; private static volatile byte byte26; - private final transient byte byte27 = 5; + private transient final byte byte27 = 5; private transient volatile byte byte28; private transient volatile byte byte29; private transient volatile byte byte30; private transient volatile byte byte31; private transient volatile byte byte32; private transient volatile byte byte33; - private static final transient byte byte34 = 5; + private static transient final byte byte34 = 5; private static transient volatile byte byte35; public byte byte36; public byte byte37; @@ -84,14 +84,14 @@ public class FieldsOfPrimitivebyte { public static transient byte byte60; public static final byte byte61 = 5; public static volatile byte byte62; - public final transient byte byte63 = 5; + public transient final byte byte63 = 5; public transient volatile byte byte64; public transient volatile byte byte65; public transient volatile byte byte66; public transient volatile byte byte67; public transient volatile byte byte68; public transient volatile byte byte69; - public static final transient byte byte70 = 5; + public static transient final byte byte70 = 5; public static transient volatile byte byte71; protected byte byte72; protected byte byte73; @@ -120,14 +120,14 @@ public class FieldsOfPrimitivebyte { protected static transient byte byte96; protected static final byte byte97 = 5; protected static volatile byte byte98; - protected final transient byte byte99 = 5; + protected transient final byte byte99 = 5; protected transient volatile byte byte100; protected transient volatile byte byte101; protected transient volatile byte byte102; protected transient volatile byte byte103; protected transient volatile byte byte104; protected transient volatile byte byte105; - protected static final transient byte byte106 = 5; + protected static transient final byte byte106 = 5; protected static transient volatile byte byte107; byte byte108; byte byte109; @@ -156,936 +156,934 @@ public class FieldsOfPrimitivebyte { static transient byte byte132; static final byte byte133 = 5; static volatile byte byte134; - final transient byte byte135 = 5; + transient final byte byte135 = 5; transient volatile byte byte136; transient volatile byte byte137; transient volatile byte byte138; transient volatile byte byte139; transient volatile byte byte140; transient volatile byte byte141; - static final transient byte byte142 = 5; + static transient final byte byte142 = 5; static transient volatile byte byte143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private byte byte0", - "embedded= true private byte byte1", - "embedded= false private byte byte2", - "persistence-modifier= none private byte byte3", - "persistence-modifier= persistent private byte byte4", - "persistence-modifier= persistent embedded= true private byte byte5", - "persistence-modifier= persistent embedded= false private byte byte6", - "persistence-modifier= transactional private byte byte7", - "private static byte byte8", - "private transient byte byte9", - "persistence-modifier= none private transient byte byte10", - "persistence-modifier= persistent private transient byte byte11", - "persistence-modifier= persistent embedded= true private transient byte byte12", - "persistence-modifier= persistent embedded= false private transient byte byte13", - "persistence-modifier= transactional private transient byte byte14", - "private final byte byte15", - "private volatile byte byte16", - "embedded= true private volatile byte byte17", - "embedded= false private volatile byte byte18", - "persistence-modifier= none private volatile byte byte19", - "persistence-modifier= persistent private volatile byte byte20", - "persistence-modifier= persistent embedded= true private volatile byte byte21", - "persistence-modifier= persistent embedded= false private volatile byte byte22", - "persistence-modifier= transactional private volatile byte byte23", - "private static transient byte byte24", - "private static final byte byte25", - "private static volatile byte byte26", - "private transient final byte byte27", - "private transient volatile byte byte28", - "persistence-modifier= none private transient volatile byte byte29", - "persistence-modifier= persistent private transient volatile byte byte30", - "persistence-modifier= persistent embedded= true private transient volatile byte byte31", - "persistence-modifier= persistent embedded= false private transient volatile byte byte32", - "persistence-modifier= transactional private transient volatile byte byte33", - "private static transient final byte byte34", - "private static transient volatile byte byte35", - "public byte byte36", - "embedded= true public byte byte37", - "embedded= false public byte byte38", - "persistence-modifier= none public byte byte39", - "persistence-modifier= persistent public byte byte40", - "persistence-modifier= persistent embedded= true public byte byte41", - "persistence-modifier= persistent embedded= false public byte byte42", - "persistence-modifier= transactional public byte byte43", - "public static byte byte44", - "public transient byte byte45", - "persistence-modifier= none public transient byte byte46", - "persistence-modifier= persistent public transient byte byte47", - "persistence-modifier= persistent embedded= true public transient byte byte48", - "persistence-modifier= persistent embedded= false public transient byte byte49", - "persistence-modifier= transactional public transient byte byte50", - "public final byte byte51", - "public volatile byte byte52", - "embedded= true public volatile byte byte53", - "embedded= false public volatile byte byte54", - "persistence-modifier= none public volatile byte byte55", - "persistence-modifier= persistent public volatile byte byte56", - "persistence-modifier= persistent embedded= true public volatile byte byte57", - "persistence-modifier= persistent embedded= false public volatile byte byte58", - "persistence-modifier= transactional public volatile byte byte59", - "public static transient byte byte60", - "public static final byte byte61", - "public static volatile byte byte62", - "public transient final byte byte63", - "public transient volatile byte byte64", - "persistence-modifier= none public transient volatile byte byte65", - "persistence-modifier= persistent public transient volatile byte byte66", - "persistence-modifier= persistent embedded= true public transient volatile byte byte67", - "persistence-modifier= persistent embedded= false public transient volatile byte byte68", - "persistence-modifier= transactional public transient volatile byte byte69", - "public static transient final byte byte70", - "public static transient volatile byte byte71", - "protected byte byte72", - "embedded= true protected byte byte73", - "embedded= false protected byte byte74", - "persistence-modifier= none protected byte byte75", - "persistence-modifier= persistent protected byte byte76", - "persistence-modifier= persistent embedded= true protected byte byte77", - "persistence-modifier= persistent embedded= false protected byte byte78", - "persistence-modifier= transactional protected byte byte79", - "protected static byte byte80", - "protected transient byte byte81", - "persistence-modifier= none protected transient byte byte82", - "persistence-modifier= persistent protected transient byte byte83", - "persistence-modifier= persistent embedded= true protected transient byte byte84", - "persistence-modifier= persistent embedded= false protected transient byte byte85", - "persistence-modifier= transactional protected transient byte byte86", - "protected final byte byte87", - "protected volatile byte byte88", - "embedded= true protected volatile byte byte89", - "embedded= false protected volatile byte byte90", - "persistence-modifier= none protected volatile byte byte91", - "persistence-modifier= persistent protected volatile byte byte92", - "persistence-modifier= persistent embedded= true protected volatile byte byte93", - "persistence-modifier= persistent embedded= false protected volatile byte byte94", - "persistence-modifier= transactional protected volatile byte byte95", - "protected static transient byte byte96", - "protected static final byte byte97", - "protected static volatile byte byte98", - "protected transient final byte byte99", - "protected transient volatile byte byte100", - "persistence-modifier= none protected transient volatile byte byte101", - "persistence-modifier= persistent protected transient volatile byte byte102", - "persistence-modifier= persistent embedded= true protected transient volatile byte byte103", - "persistence-modifier= persistent embedded= false protected transient volatile byte byte104", - "persistence-modifier= transactional protected transient volatile byte byte105", - "protected static transient final byte byte106", - "protected static transient volatile byte byte107", - "byte byte108", - "embedded= true byte byte109", - "embedded= false byte byte110", - "persistence-modifier= none byte byte111", - "persistence-modifier= persistent byte byte112", - "persistence-modifier= persistent embedded= true byte byte113", - "persistence-modifier= persistent embedded= false byte byte114", - "persistence-modifier= transactional byte byte115", - "static byte byte116", - "transient byte byte117", - "persistence-modifier= none transient byte byte118", - "persistence-modifier= persistent transient byte byte119", - "persistence-modifier= persistent embedded= true transient byte byte120", - "persistence-modifier= persistent embedded= false transient byte byte121", - "persistence-modifier= transactional transient byte byte122", - "final byte byte123", - "volatile byte byte124", - "embedded= true volatile byte byte125", - "embedded= false volatile byte byte126", - "persistence-modifier= none volatile byte byte127", - "persistence-modifier= persistent volatile byte byte128", - "persistence-modifier= persistent embedded= true volatile byte byte129", - "persistence-modifier= persistent embedded= false volatile byte byte130", - "persistence-modifier= transactional volatile byte byte131", - "static transient byte byte132", - "static final byte byte133", - "static volatile byte byte134", - "transient final byte byte135", - "transient volatile byte byte136", - "persistence-modifier= none transient volatile byte byte137", - "persistence-modifier= persistent transient volatile byte byte138", - "persistence-modifier= persistent embedded= true transient volatile byte byte139", - "persistence-modifier= persistent embedded= false transient volatile byte byte140", - "persistence-modifier= transactional transient volatile byte byte141", - "static transient final byte byte142", - "static transient volatile byte byte143" + public static final String [] fieldSpecs = { + "private byte byte0", + "embedded= true private byte byte1", + "embedded= false private byte byte2", + "persistence-modifier= none private byte byte3", + "persistence-modifier= persistent private byte byte4", + "persistence-modifier= persistent embedded= true private byte byte5", + "persistence-modifier= persistent embedded= false private byte byte6", + "persistence-modifier= transactional private byte byte7", + "private static byte byte8", + "private transient byte byte9", + "persistence-modifier= none private transient byte byte10", + "persistence-modifier= persistent private transient byte byte11", + "persistence-modifier= persistent embedded= true private transient byte byte12", + "persistence-modifier= persistent embedded= false private transient byte byte13", + "persistence-modifier= transactional private transient byte byte14", + "private final byte byte15", + "private volatile byte byte16", + "embedded= true private volatile byte byte17", + "embedded= false private volatile byte byte18", + "persistence-modifier= none private volatile byte byte19", + "persistence-modifier= persistent private volatile byte byte20", + "persistence-modifier= persistent embedded= true private volatile byte byte21", + "persistence-modifier= persistent embedded= false private volatile byte byte22", + "persistence-modifier= transactional private volatile byte byte23", + "private static transient byte byte24", + "private static final byte byte25", + "private static volatile byte byte26", + "private transient final byte byte27", + "private transient volatile byte byte28", + "persistence-modifier= none private transient volatile byte byte29", + "persistence-modifier= persistent private transient volatile byte byte30", + "persistence-modifier= persistent embedded= true private transient volatile byte byte31", + "persistence-modifier= persistent embedded= false private transient volatile byte byte32", + "persistence-modifier= transactional private transient volatile byte byte33", + "private static transient final byte byte34", + "private static transient volatile byte byte35", + "public byte byte36", + "embedded= true public byte byte37", + "embedded= false public byte byte38", + "persistence-modifier= none public byte byte39", + "persistence-modifier= persistent public byte byte40", + "persistence-modifier= persistent embedded= true public byte byte41", + "persistence-modifier= persistent embedded= false public byte byte42", + "persistence-modifier= transactional public byte byte43", + "public static byte byte44", + "public transient byte byte45", + "persistence-modifier= none public transient byte byte46", + "persistence-modifier= persistent public transient byte byte47", + "persistence-modifier= persistent embedded= true public transient byte byte48", + "persistence-modifier= persistent embedded= false public transient byte byte49", + "persistence-modifier= transactional public transient byte byte50", + "public final byte byte51", + "public volatile byte byte52", + "embedded= true public volatile byte byte53", + "embedded= false public volatile byte byte54", + "persistence-modifier= none public volatile byte byte55", + "persistence-modifier= persistent public volatile byte byte56", + "persistence-modifier= persistent embedded= true public volatile byte byte57", + "persistence-modifier= persistent embedded= false public volatile byte byte58", + "persistence-modifier= transactional public volatile byte byte59", + "public static transient byte byte60", + "public static final byte byte61", + "public static volatile byte byte62", + "public transient final byte byte63", + "public transient volatile byte byte64", + "persistence-modifier= none public transient volatile byte byte65", + "persistence-modifier= persistent public transient volatile byte byte66", + "persistence-modifier= persistent embedded= true public transient volatile byte byte67", + "persistence-modifier= persistent embedded= false public transient volatile byte byte68", + "persistence-modifier= transactional public transient volatile byte byte69", + "public static transient final byte byte70", + "public static transient volatile byte byte71", + "protected byte byte72", + "embedded= true protected byte byte73", + "embedded= false protected byte byte74", + "persistence-modifier= none protected byte byte75", + "persistence-modifier= persistent protected byte byte76", + "persistence-modifier= persistent embedded= true protected byte byte77", + "persistence-modifier= persistent embedded= false protected byte byte78", + "persistence-modifier= transactional protected byte byte79", + "protected static byte byte80", + "protected transient byte byte81", + "persistence-modifier= none protected transient byte byte82", + "persistence-modifier= persistent protected transient byte byte83", + "persistence-modifier= persistent embedded= true protected transient byte byte84", + "persistence-modifier= persistent embedded= false protected transient byte byte85", + "persistence-modifier= transactional protected transient byte byte86", + "protected final byte byte87", + "protected volatile byte byte88", + "embedded= true protected volatile byte byte89", + "embedded= false protected volatile byte byte90", + "persistence-modifier= none protected volatile byte byte91", + "persistence-modifier= persistent protected volatile byte byte92", + "persistence-modifier= persistent embedded= true protected volatile byte byte93", + "persistence-modifier= persistent embedded= false protected volatile byte byte94", + "persistence-modifier= transactional protected volatile byte byte95", + "protected static transient byte byte96", + "protected static final byte byte97", + "protected static volatile byte byte98", + "protected transient final byte byte99", + "protected transient volatile byte byte100", + "persistence-modifier= none protected transient volatile byte byte101", + "persistence-modifier= persistent protected transient volatile byte byte102", + "persistence-modifier= persistent embedded= true protected transient volatile byte byte103", + "persistence-modifier= persistent embedded= false protected transient volatile byte byte104", + "persistence-modifier= transactional protected transient volatile byte byte105", + "protected static transient final byte byte106", + "protected static transient volatile byte byte107", + "byte byte108", + "embedded= true byte byte109", + "embedded= false byte byte110", + "persistence-modifier= none byte byte111", + "persistence-modifier= persistent byte byte112", + "persistence-modifier= persistent embedded= true byte byte113", + "persistence-modifier= persistent embedded= false byte byte114", + "persistence-modifier= transactional byte byte115", + "static byte byte116", + "transient byte byte117", + "persistence-modifier= none transient byte byte118", + "persistence-modifier= persistent transient byte byte119", + "persistence-modifier= persistent embedded= true transient byte byte120", + "persistence-modifier= persistent embedded= false transient byte byte121", + "persistence-modifier= transactional transient byte byte122", + "final byte byte123", + "volatile byte byte124", + "embedded= true volatile byte byte125", + "embedded= false volatile byte byte126", + "persistence-modifier= none volatile byte byte127", + "persistence-modifier= persistent volatile byte byte128", + "persistence-modifier= persistent embedded= true volatile byte byte129", + "persistence-modifier= persistent embedded= false volatile byte byte130", + "persistence-modifier= transactional volatile byte byte131", + "static transient byte byte132", + "static final byte byte133", + "static volatile byte byte134", + "transient final byte byte135", + "transient volatile byte byte136", + "persistence-modifier= none transient volatile byte byte137", + "persistence-modifier= persistent transient volatile byte byte138", + "persistence-modifier= persistent embedded= true transient volatile byte byte139", + "persistence-modifier= persistent embedded= false transient volatile byte byte140", + "persistence-modifier= transactional transient volatile byte byte141", + "static transient final byte byte142", + "static transient volatile byte byte143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public byte get(int index) { - switch (index) { - case (0): + public byte get(int index) + { + switch (index) + { + case(0): return byte0; - case (1): + case(1): return byte1; - case (2): + case(2): return byte2; - case (3): + case(3): return byte3; - case (4): + case(4): return byte4; - case (5): + case(5): return byte5; - case (6): + case(6): return byte6; - case (7): + case(7): return byte7; - case (8): + case(8): return byte8; - case (9): + case(9): return byte9; - case (10): + case(10): return byte10; - case (11): + case(11): return byte11; - case (12): + case(12): return byte12; - case (13): + case(13): return byte13; - case (14): + case(14): return byte14; - case (15): + case(15): return byte15; - case (16): + case(16): return byte16; - case (17): + case(17): return byte17; - case (18): + case(18): return byte18; - case (19): + case(19): return byte19; - case (20): + case(20): return byte20; - case (21): + case(21): return byte21; - case (22): + case(22): return byte22; - case (23): + case(23): return byte23; - case (24): + case(24): return byte24; - case (25): + case(25): return byte25; - case (26): + case(26): return byte26; - case (27): + case(27): return byte27; - case (28): + case(28): return byte28; - case (29): + case(29): return byte29; - case (30): + case(30): return byte30; - case (31): + case(31): return byte31; - case (32): + case(32): return byte32; - case (33): + case(33): return byte33; - case (34): + case(34): return byte34; - case (35): + case(35): return byte35; - case (36): + case(36): return byte36; - case (37): + case(37): return byte37; - case (38): + case(38): return byte38; - case (39): + case(39): return byte39; - case (40): + case(40): return byte40; - case (41): + case(41): return byte41; - case (42): + case(42): return byte42; - case (43): + case(43): return byte43; - case (44): + case(44): return byte44; - case (45): + case(45): return byte45; - case (46): + case(46): return byte46; - case (47): + case(47): return byte47; - case (48): + case(48): return byte48; - case (49): + case(49): return byte49; - case (50): + case(50): return byte50; - case (51): + case(51): return byte51; - case (52): + case(52): return byte52; - case (53): + case(53): return byte53; - case (54): + case(54): return byte54; - case (55): + case(55): return byte55; - case (56): + case(56): return byte56; - case (57): + case(57): return byte57; - case (58): + case(58): return byte58; - case (59): + case(59): return byte59; - case (60): + case(60): return byte60; - case (61): + case(61): return byte61; - case (62): + case(62): return byte62; - case (63): + case(63): return byte63; - case (64): + case(64): return byte64; - case (65): + case(65): return byte65; - case (66): + case(66): return byte66; - case (67): + case(67): return byte67; - case (68): + case(68): return byte68; - case (69): + case(69): return byte69; - case (70): + case(70): return byte70; - case (71): + case(71): return byte71; - case (72): + case(72): return byte72; - case (73): + case(73): return byte73; - case (74): + case(74): return byte74; - case (75): + case(75): return byte75; - case (76): + case(76): return byte76; - case (77): + case(77): return byte77; - case (78): + case(78): return byte78; - case (79): + case(79): return byte79; - case (80): + case(80): return byte80; - case (81): + case(81): return byte81; - case (82): + case(82): return byte82; - case (83): + case(83): return byte83; - case (84): + case(84): return byte84; - case (85): + case(85): return byte85; - case (86): + case(86): return byte86; - case (87): + case(87): return byte87; - case (88): + case(88): return byte88; - case (89): + case(89): return byte89; - case (90): + case(90): return byte90; - case (91): + case(91): return byte91; - case (92): + case(92): return byte92; - case (93): + case(93): return byte93; - case (94): + case(94): return byte94; - case (95): + case(95): return byte95; - case (96): + case(96): return byte96; - case (97): + case(97): return byte97; - case (98): + case(98): return byte98; - case (99): + case(99): return byte99; - case (100): + case(100): return byte100; - case (101): + case(101): return byte101; - case (102): + case(102): return byte102; - case (103): + case(103): return byte103; - case (104): + case(104): return byte104; - case (105): + case(105): return byte105; - case (106): + case(106): return byte106; - case (107): + case(107): return byte107; - case (108): + case(108): return byte108; - case (109): + case(109): return byte109; - case (110): + case(110): return byte110; - case (111): + case(111): return byte111; - case (112): + case(112): return byte112; - case (113): + case(113): return byte113; - case (114): + case(114): return byte114; - case (115): + case(115): return byte115; - case (116): + case(116): return byte116; - case (117): + case(117): return byte117; - case (118): + case(118): return byte118; - case (119): + case(119): return byte119; - case (120): + case(120): return byte120; - case (121): + case(121): return byte121; - case (122): + case(122): return byte122; - case (123): + case(123): return byte123; - case (124): + case(124): return byte124; - case (125): + case(125): return byte125; - case (126): + case(126): return byte126; - case (127): + case(127): return byte127; - case (128): + case(128): return byte128; - case (129): + case(129): return byte129; - case (130): + case(130): return byte130; - case (131): + case(131): return byte131; - case (132): + case(132): return byte132; - case (133): + case(133): return byte133; - case (134): + case(134): return byte134; - case (135): + case(135): return byte135; - case (136): + case(136): return byte136; - case (137): + case(137): return byte137; - case (138): + case(138): return byte138; - case (139): + case(139): return byte139; - case (140): + case(140): return byte140; - case (141): + case(141): return byte141; - case (142): + case(142): return byte142; - case (143): + case(143): return byte143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, byte value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - byte0 = value; - break; - case (1): - byte1 = value; - break; - case (2): - byte2 = value; - break; - case (3): - byte3 = value; - break; - case (4): - byte4 = value; - break; - case (5): - byte5 = value; - break; - case (6): - byte6 = value; - break; - case (7): - byte7 = value; - break; - case (8): - byte8 = value; - break; - case (9): - byte9 = value; - break; - case (10): - byte10 = value; - break; - case (11): - byte11 = value; - break; - case (12): - byte12 = value; - break; - case (13): - byte13 = value; - break; - case (14): - byte14 = value; - break; - case (16): - byte16 = value; - break; - case (17): - byte17 = value; - break; - case (18): - byte18 = value; - break; - case (19): - byte19 = value; - break; - case (20): - byte20 = value; - break; - case (21): - byte21 = value; - break; - case (22): - byte22 = value; - break; - case (23): - byte23 = value; - break; - case (24): - byte24 = value; - break; - case (26): - byte26 = value; - break; - case (28): - byte28 = value; - break; - case (29): - byte29 = value; - break; - case (30): - byte30 = value; - break; - case (31): - byte31 = value; - break; - case (32): - byte32 = value; - break; - case (33): - byte33 = value; - break; - case (35): - byte35 = value; - break; - case (36): - byte36 = value; - break; - case (37): - byte37 = value; - break; - case (38): - byte38 = value; - break; - case (39): - byte39 = value; - break; - case (40): - byte40 = value; - break; - case (41): - byte41 = value; - break; - case (42): - byte42 = value; - break; - case (43): - byte43 = value; - break; - case (44): - byte44 = value; - break; - case (45): - byte45 = value; - break; - case (46): - byte46 = value; - break; - case (47): - byte47 = value; - break; - case (48): - byte48 = value; - break; - case (49): - byte49 = value; - break; - case (50): - byte50 = value; - break; - case (52): - byte52 = value; - break; - case (53): - byte53 = value; - break; - case (54): - byte54 = value; - break; - case (55): - byte55 = value; - break; - case (56): - byte56 = value; - break; - case (57): - byte57 = value; - break; - case (58): - byte58 = value; - break; - case (59): - byte59 = value; - break; - case (60): - byte60 = value; - break; - case (62): - byte62 = value; - break; - case (64): - byte64 = value; - break; - case (65): - byte65 = value; - break; - case (66): - byte66 = value; - break; - case (67): - byte67 = value; - break; - case (68): - byte68 = value; - break; - case (69): - byte69 = value; - break; - case (71): - byte71 = value; - break; - case (72): - byte72 = value; - break; - case (73): - byte73 = value; - break; - case (74): - byte74 = value; - break; - case (75): - byte75 = value; - break; - case (76): - byte76 = value; - break; - case (77): - byte77 = value; - break; - case (78): - byte78 = value; - break; - case (79): - byte79 = value; - break; - case (80): - byte80 = value; - break; - case (81): - byte81 = value; - break; - case (82): - byte82 = value; - break; - case (83): - byte83 = value; - break; - case (84): - byte84 = value; - break; - case (85): - byte85 = value; - break; - case (86): - byte86 = value; - break; - case (88): - byte88 = value; - break; - case (89): - byte89 = value; - break; - case (90): - byte90 = value; - break; - case (91): - byte91 = value; - break; - case (92): - byte92 = value; - break; - case (93): - byte93 = value; - break; - case (94): - byte94 = value; - break; - case (95): - byte95 = value; - break; - case (96): - byte96 = value; - break; - case (98): - byte98 = value; - break; - case (100): - byte100 = value; - break; - case (101): - byte101 = value; - break; - case (102): - byte102 = value; - break; - case (103): - byte103 = value; - break; - case (104): - byte104 = value; - break; - case (105): - byte105 = value; - break; - case (107): - byte107 = value; - break; - case (108): - byte108 = value; - break; - case (109): - byte109 = value; - break; - case (110): - byte110 = value; - break; - case (111): - byte111 = value; - break; - case (112): - byte112 = value; - break; - case (113): - byte113 = value; - break; - case (114): - byte114 = value; - break; - case (115): - byte115 = value; - break; - case (116): - byte116 = value; - break; - case (117): - byte117 = value; - break; - case (118): - byte118 = value; - break; - case (119): - byte119 = value; - break; - case (120): - byte120 = value; - break; - case (121): - byte121 = value; - break; - case (122): - byte122 = value; - break; - case (124): - byte124 = value; - break; - case (125): - byte125 = value; - break; - case (126): - byte126 = value; - break; - case (127): - byte127 = value; - break; - case (128): - byte128 = value; - break; - case (129): - byte129 = value; - break; - case (130): - byte130 = value; - break; - case (131): - byte131 = value; - break; - case (132): - byte132 = value; - break; - case (134): - byte134 = value; - break; - case (136): - byte136 = value; - break; - case (137): - byte137 = value; - break; - case (138): - byte138 = value; - break; - case (139): - byte139 = value; - break; - case (140): - byte140 = value; - break; - case (141): - byte141 = value; - break; - case (143): - byte143 = value; - break; + public boolean set(int index,byte value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + byte0= value; + break; + case(1): + byte1= value; + break; + case(2): + byte2= value; + break; + case(3): + byte3= value; + break; + case(4): + byte4= value; + break; + case(5): + byte5= value; + break; + case(6): + byte6= value; + break; + case(7): + byte7= value; + break; + case(8): + byte8= value; + break; + case(9): + byte9= value; + break; + case(10): + byte10= value; + break; + case(11): + byte11= value; + break; + case(12): + byte12= value; + break; + case(13): + byte13= value; + break; + case(14): + byte14= value; + break; + case(16): + byte16= value; + break; + case(17): + byte17= value; + break; + case(18): + byte18= value; + break; + case(19): + byte19= value; + break; + case(20): + byte20= value; + break; + case(21): + byte21= value; + break; + case(22): + byte22= value; + break; + case(23): + byte23= value; + break; + case(24): + byte24= value; + break; + case(26): + byte26= value; + break; + case(28): + byte28= value; + break; + case(29): + byte29= value; + break; + case(30): + byte30= value; + break; + case(31): + byte31= value; + break; + case(32): + byte32= value; + break; + case(33): + byte33= value; + break; + case(35): + byte35= value; + break; + case(36): + byte36= value; + break; + case(37): + byte37= value; + break; + case(38): + byte38= value; + break; + case(39): + byte39= value; + break; + case(40): + byte40= value; + break; + case(41): + byte41= value; + break; + case(42): + byte42= value; + break; + case(43): + byte43= value; + break; + case(44): + byte44= value; + break; + case(45): + byte45= value; + break; + case(46): + byte46= value; + break; + case(47): + byte47= value; + break; + case(48): + byte48= value; + break; + case(49): + byte49= value; + break; + case(50): + byte50= value; + break; + case(52): + byte52= value; + break; + case(53): + byte53= value; + break; + case(54): + byte54= value; + break; + case(55): + byte55= value; + break; + case(56): + byte56= value; + break; + case(57): + byte57= value; + break; + case(58): + byte58= value; + break; + case(59): + byte59= value; + break; + case(60): + byte60= value; + break; + case(62): + byte62= value; + break; + case(64): + byte64= value; + break; + case(65): + byte65= value; + break; + case(66): + byte66= value; + break; + case(67): + byte67= value; + break; + case(68): + byte68= value; + break; + case(69): + byte69= value; + break; + case(71): + byte71= value; + break; + case(72): + byte72= value; + break; + case(73): + byte73= value; + break; + case(74): + byte74= value; + break; + case(75): + byte75= value; + break; + case(76): + byte76= value; + break; + case(77): + byte77= value; + break; + case(78): + byte78= value; + break; + case(79): + byte79= value; + break; + case(80): + byte80= value; + break; + case(81): + byte81= value; + break; + case(82): + byte82= value; + break; + case(83): + byte83= value; + break; + case(84): + byte84= value; + break; + case(85): + byte85= value; + break; + case(86): + byte86= value; + break; + case(88): + byte88= value; + break; + case(89): + byte89= value; + break; + case(90): + byte90= value; + break; + case(91): + byte91= value; + break; + case(92): + byte92= value; + break; + case(93): + byte93= value; + break; + case(94): + byte94= value; + break; + case(95): + byte95= value; + break; + case(96): + byte96= value; + break; + case(98): + byte98= value; + break; + case(100): + byte100= value; + break; + case(101): + byte101= value; + break; + case(102): + byte102= value; + break; + case(103): + byte103= value; + break; + case(104): + byte104= value; + break; + case(105): + byte105= value; + break; + case(107): + byte107= value; + break; + case(108): + byte108= value; + break; + case(109): + byte109= value; + break; + case(110): + byte110= value; + break; + case(111): + byte111= value; + break; + case(112): + byte112= value; + break; + case(113): + byte113= value; + break; + case(114): + byte114= value; + break; + case(115): + byte115= value; + break; + case(116): + byte116= value; + break; + case(117): + byte117= value; + break; + case(118): + byte118= value; + break; + case(119): + byte119= value; + break; + case(120): + byte120= value; + break; + case(121): + byte121= value; + break; + case(122): + byte122= value; + break; + case(124): + byte124= value; + break; + case(125): + byte125= value; + break; + case(126): + byte126= value; + break; + case(127): + byte127= value; + break; + case(128): + byte128= value; + break; + case(129): + byte129= value; + break; + case(130): + byte130= value; + break; + case(131): + byte131= value; + break; + case(132): + byte132= value; + break; + case(134): + byte134= value; + break; + case(136): + byte136= value; + break; + case(137): + byte137= value; + break; + case(138): + byte138= value; + break; + case(139): + byte139= value; + break; + case(140): + byte140= value; + break; + case(141): + byte141= value; + break; + case(143): + byte143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } - - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitivechar.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitivechar.java index 4a6e7f3c5..7bb90bc71 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitivechar.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitivechar.java @@ -5,21 +5,21 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -public class FieldsOfPrimitivechar { +public class FieldsOfPrimitivechar { public int identifier; private char char0; private char char1; @@ -48,14 +48,14 @@ public class FieldsOfPrimitivechar { private static transient char char24; private static final char char25 = 'a'; private static volatile char char26; - private final transient char char27 = 'a'; + private transient final char char27 = 'a'; private transient volatile char char28; private transient volatile char char29; private transient volatile char char30; private transient volatile char char31; private transient volatile char char32; private transient volatile char char33; - private static final transient char char34 = 'a'; + private static transient final char char34 = 'a'; private static transient volatile char char35; public char char36; public char char37; @@ -84,14 +84,14 @@ public class FieldsOfPrimitivechar { public static transient char char60; public static final char char61 = 'a'; public static volatile char char62; - public final transient char char63 = 'a'; + public transient final char char63 = 'a'; public transient volatile char char64; public transient volatile char char65; public transient volatile char char66; public transient volatile char char67; public transient volatile char char68; public transient volatile char char69; - public static final transient char char70 = 'a'; + public static transient final char char70 = 'a'; public static transient volatile char char71; protected char char72; protected char char73; @@ -120,14 +120,14 @@ public class FieldsOfPrimitivechar { protected static transient char char96; protected static final char char97 = 'a'; protected static volatile char char98; - protected final transient char char99 = 'a'; + protected transient final char char99 = 'a'; protected transient volatile char char100; protected transient volatile char char101; protected transient volatile char char102; protected transient volatile char char103; protected transient volatile char char104; protected transient volatile char char105; - protected static final transient char char106 = 'a'; + protected static transient final char char106 = 'a'; protected static transient volatile char char107; char char108; char char109; @@ -156,936 +156,935 @@ public class FieldsOfPrimitivechar { static transient char char132; static final char char133 = 'a'; static volatile char char134; - final transient char char135 = 'a'; + transient final char char135 = 'a'; transient volatile char char136; transient volatile char char137; transient volatile char char138; transient volatile char char139; transient volatile char char140; transient volatile char char141; - static final transient char char142 = 'a'; + static transient final char char142 = 'a'; static transient volatile char char143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private char char0", - "embedded= true private char char1", - "embedded= false private char char2", - "persistence-modifier= none private char char3", - "persistence-modifier= persistent private char char4", - "persistence-modifier= persistent embedded= true private char char5", - "persistence-modifier= persistent embedded= false private char char6", - "persistence-modifier= transactional private char char7", - "private static char char8", - "private transient char char9", - "persistence-modifier= none private transient char char10", - "persistence-modifier= persistent private transient char char11", - "persistence-modifier= persistent embedded= true private transient char char12", - "persistence-modifier= persistent embedded= false private transient char char13", - "persistence-modifier= transactional private transient char char14", - "private final char char15", - "private volatile char char16", - "embedded= true private volatile char char17", - "embedded= false private volatile char char18", - "persistence-modifier= none private volatile char char19", - "persistence-modifier= persistent private volatile char char20", - "persistence-modifier= persistent embedded= true private volatile char char21", - "persistence-modifier= persistent embedded= false private volatile char char22", - "persistence-modifier= transactional private volatile char char23", - "private static transient char char24", - "private static final char char25", - "private static volatile char char26", - "private transient final char char27", - "private transient volatile char char28", - "persistence-modifier= none private transient volatile char char29", - "persistence-modifier= persistent private transient volatile char char30", - "persistence-modifier= persistent embedded= true private transient volatile char char31", - "persistence-modifier= persistent embedded= false private transient volatile char char32", - "persistence-modifier= transactional private transient volatile char char33", - "private static transient final char char34", - "private static transient volatile char char35", - "public char char36", - "embedded= true public char char37", - "embedded= false public char char38", - "persistence-modifier= none public char char39", - "persistence-modifier= persistent public char char40", - "persistence-modifier= persistent embedded= true public char char41", - "persistence-modifier= persistent embedded= false public char char42", - "persistence-modifier= transactional public char char43", - "public static char char44", - "public transient char char45", - "persistence-modifier= none public transient char char46", - "persistence-modifier= persistent public transient char char47", - "persistence-modifier= persistent embedded= true public transient char char48", - "persistence-modifier= persistent embedded= false public transient char char49", - "persistence-modifier= transactional public transient char char50", - "public final char char51", - "public volatile char char52", - "embedded= true public volatile char char53", - "embedded= false public volatile char char54", - "persistence-modifier= none public volatile char char55", - "persistence-modifier= persistent public volatile char char56", - "persistence-modifier= persistent embedded= true public volatile char char57", - "persistence-modifier= persistent embedded= false public volatile char char58", - "persistence-modifier= transactional public volatile char char59", - "public static transient char char60", - "public static final char char61", - "public static volatile char char62", - "public transient final char char63", - "public transient volatile char char64", - "persistence-modifier= none public transient volatile char char65", - "persistence-modifier= persistent public transient volatile char char66", - "persistence-modifier= persistent embedded= true public transient volatile char char67", - "persistence-modifier= persistent embedded= false public transient volatile char char68", - "persistence-modifier= transactional public transient volatile char char69", - "public static transient final char char70", - "public static transient volatile char char71", - "protected char char72", - "embedded= true protected char char73", - "embedded= false protected char char74", - "persistence-modifier= none protected char char75", - "persistence-modifier= persistent protected char char76", - "persistence-modifier= persistent embedded= true protected char char77", - "persistence-modifier= persistent embedded= false protected char char78", - "persistence-modifier= transactional protected char char79", - "protected static char char80", - "protected transient char char81", - "persistence-modifier= none protected transient char char82", - "persistence-modifier= persistent protected transient char char83", - "persistence-modifier= persistent embedded= true protected transient char char84", - "persistence-modifier= persistent embedded= false protected transient char char85", - "persistence-modifier= transactional protected transient char char86", - "protected final char char87", - "protected volatile char char88", - "embedded= true protected volatile char char89", - "embedded= false protected volatile char char90", - "persistence-modifier= none protected volatile char char91", - "persistence-modifier= persistent protected volatile char char92", - "persistence-modifier= persistent embedded= true protected volatile char char93", - "persistence-modifier= persistent embedded= false protected volatile char char94", - "persistence-modifier= transactional protected volatile char char95", - "protected static transient char char96", - "protected static final char char97", - "protected static volatile char char98", - "protected transient final char char99", - "protected transient volatile char char100", - "persistence-modifier= none protected transient volatile char char101", - "persistence-modifier= persistent protected transient volatile char char102", - "persistence-modifier= persistent embedded= true protected transient volatile char char103", - "persistence-modifier= persistent embedded= false protected transient volatile char char104", - "persistence-modifier= transactional protected transient volatile char char105", - "protected static transient final char char106", - "protected static transient volatile char char107", - "char char108", - "embedded= true char char109", - "embedded= false char char110", - "persistence-modifier= none char char111", - "persistence-modifier= persistent char char112", - "persistence-modifier= persistent embedded= true char char113", - "persistence-modifier= persistent embedded= false char char114", - "persistence-modifier= transactional char char115", - "static char char116", - "transient char char117", - "persistence-modifier= none transient char char118", - "persistence-modifier= persistent transient char char119", - "persistence-modifier= persistent embedded= true transient char char120", - "persistence-modifier= persistent embedded= false transient char char121", - "persistence-modifier= transactional transient char char122", - "final char char123", - "volatile char char124", - "embedded= true volatile char char125", - "embedded= false volatile char char126", - "persistence-modifier= none volatile char char127", - "persistence-modifier= persistent volatile char char128", - "persistence-modifier= persistent embedded= true volatile char char129", - "persistence-modifier= persistent embedded= false volatile char char130", - "persistence-modifier= transactional volatile char char131", - "static transient char char132", - "static final char char133", - "static volatile char char134", - "transient final char char135", - "transient volatile char char136", - "persistence-modifier= none transient volatile char char137", - "persistence-modifier= persistent transient volatile char char138", - "persistence-modifier= persistent embedded= true transient volatile char char139", - "persistence-modifier= persistent embedded= false transient volatile char char140", - "persistence-modifier= transactional transient volatile char char141", - "static transient final char char142", - "static transient volatile char char143" + public static final String [] fieldSpecs = { + "private char char0", + "embedded= true private char char1", + "embedded= false private char char2", + "persistence-modifier= none private char char3", + "persistence-modifier= persistent private char char4", + "persistence-modifier= persistent embedded= true private char char5", + "persistence-modifier= persistent embedded= false private char char6", + "persistence-modifier= transactional private char char7", + "private static char char8", + "private transient char char9", + "persistence-modifier= none private transient char char10", + "persistence-modifier= persistent private transient char char11", + "persistence-modifier= persistent embedded= true private transient char char12", + "persistence-modifier= persistent embedded= false private transient char char13", + "persistence-modifier= transactional private transient char char14", + "private final char char15", + "private volatile char char16", + "embedded= true private volatile char char17", + "embedded= false private volatile char char18", + "persistence-modifier= none private volatile char char19", + "persistence-modifier= persistent private volatile char char20", + "persistence-modifier= persistent embedded= true private volatile char char21", + "persistence-modifier= persistent embedded= false private volatile char char22", + "persistence-modifier= transactional private volatile char char23", + "private static transient char char24", + "private static final char char25", + "private static volatile char char26", + "private transient final char char27", + "private transient volatile char char28", + "persistence-modifier= none private transient volatile char char29", + "persistence-modifier= persistent private transient volatile char char30", + "persistence-modifier= persistent embedded= true private transient volatile char char31", + "persistence-modifier= persistent embedded= false private transient volatile char char32", + "persistence-modifier= transactional private transient volatile char char33", + "private static transient final char char34", + "private static transient volatile char char35", + "public char char36", + "embedded= true public char char37", + "embedded= false public char char38", + "persistence-modifier= none public char char39", + "persistence-modifier= persistent public char char40", + "persistence-modifier= persistent embedded= true public char char41", + "persistence-modifier= persistent embedded= false public char char42", + "persistence-modifier= transactional public char char43", + "public static char char44", + "public transient char char45", + "persistence-modifier= none public transient char char46", + "persistence-modifier= persistent public transient char char47", + "persistence-modifier= persistent embedded= true public transient char char48", + "persistence-modifier= persistent embedded= false public transient char char49", + "persistence-modifier= transactional public transient char char50", + "public final char char51", + "public volatile char char52", + "embedded= true public volatile char char53", + "embedded= false public volatile char char54", + "persistence-modifier= none public volatile char char55", + "persistence-modifier= persistent public volatile char char56", + "persistence-modifier= persistent embedded= true public volatile char char57", + "persistence-modifier= persistent embedded= false public volatile char char58", + "persistence-modifier= transactional public volatile char char59", + "public static transient char char60", + "public static final char char61", + "public static volatile char char62", + "public transient final char char63", + "public transient volatile char char64", + "persistence-modifier= none public transient volatile char char65", + "persistence-modifier= persistent public transient volatile char char66", + "persistence-modifier= persistent embedded= true public transient volatile char char67", + "persistence-modifier= persistent embedded= false public transient volatile char char68", + "persistence-modifier= transactional public transient volatile char char69", + "public static transient final char char70", + "public static transient volatile char char71", + "protected char char72", + "embedded= true protected char char73", + "embedded= false protected char char74", + "persistence-modifier= none protected char char75", + "persistence-modifier= persistent protected char char76", + "persistence-modifier= persistent embedded= true protected char char77", + "persistence-modifier= persistent embedded= false protected char char78", + "persistence-modifier= transactional protected char char79", + "protected static char char80", + "protected transient char char81", + "persistence-modifier= none protected transient char char82", + "persistence-modifier= persistent protected transient char char83", + "persistence-modifier= persistent embedded= true protected transient char char84", + "persistence-modifier= persistent embedded= false protected transient char char85", + "persistence-modifier= transactional protected transient char char86", + "protected final char char87", + "protected volatile char char88", + "embedded= true protected volatile char char89", + "embedded= false protected volatile char char90", + "persistence-modifier= none protected volatile char char91", + "persistence-modifier= persistent protected volatile char char92", + "persistence-modifier= persistent embedded= true protected volatile char char93", + "persistence-modifier= persistent embedded= false protected volatile char char94", + "persistence-modifier= transactional protected volatile char char95", + "protected static transient char char96", + "protected static final char char97", + "protected static volatile char char98", + "protected transient final char char99", + "protected transient volatile char char100", + "persistence-modifier= none protected transient volatile char char101", + "persistence-modifier= persistent protected transient volatile char char102", + "persistence-modifier= persistent embedded= true protected transient volatile char char103", + "persistence-modifier= persistent embedded= false protected transient volatile char char104", + "persistence-modifier= transactional protected transient volatile char char105", + "protected static transient final char char106", + "protected static transient volatile char char107", + "char char108", + "embedded= true char char109", + "embedded= false char char110", + "persistence-modifier= none char char111", + "persistence-modifier= persistent char char112", + "persistence-modifier= persistent embedded= true char char113", + "persistence-modifier= persistent embedded= false char char114", + "persistence-modifier= transactional char char115", + "static char char116", + "transient char char117", + "persistence-modifier= none transient char char118", + "persistence-modifier= persistent transient char char119", + "persistence-modifier= persistent embedded= true transient char char120", + "persistence-modifier= persistent embedded= false transient char char121", + "persistence-modifier= transactional transient char char122", + "final char char123", + "volatile char char124", + "embedded= true volatile char char125", + "embedded= false volatile char char126", + "persistence-modifier= none volatile char char127", + "persistence-modifier= persistent volatile char char128", + "persistence-modifier= persistent embedded= true volatile char char129", + "persistence-modifier= persistent embedded= false volatile char char130", + "persistence-modifier= transactional volatile char char131", + "static transient char char132", + "static final char char133", + "static volatile char char134", + "transient final char char135", + "transient volatile char char136", + "persistence-modifier= none transient volatile char char137", + "persistence-modifier= persistent transient volatile char char138", + "persistence-modifier= persistent embedded= true transient volatile char char139", + "persistence-modifier= persistent embedded= false transient volatile char char140", + "persistence-modifier= transactional transient volatile char char141", + "static transient final char char142", + "static transient volatile char char143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public char get(int index) { - switch (index) { - case (0): + public char get(int index) + { + switch (index) + { + case(0): return char0; - case (1): + case(1): return char1; - case (2): + case(2): return char2; - case (3): + case(3): return char3; - case (4): + case(4): return char4; - case (5): + case(5): return char5; - case (6): + case(6): return char6; - case (7): + case(7): return char7; - case (8): + case(8): return char8; - case (9): + case(9): return char9; - case (10): + case(10): return char10; - case (11): + case(11): return char11; - case (12): + case(12): return char12; - case (13): + case(13): return char13; - case (14): + case(14): return char14; - case (15): + case(15): return char15; - case (16): + case(16): return char16; - case (17): + case(17): return char17; - case (18): + case(18): return char18; - case (19): + case(19): return char19; - case (20): + case(20): return char20; - case (21): + case(21): return char21; - case (22): + case(22): return char22; - case (23): + case(23): return char23; - case (24): + case(24): return char24; - case (25): + case(25): return char25; - case (26): + case(26): return char26; - case (27): + case(27): return char27; - case (28): + case(28): return char28; - case (29): + case(29): return char29; - case (30): + case(30): return char30; - case (31): + case(31): return char31; - case (32): + case(32): return char32; - case (33): + case(33): return char33; - case (34): + case(34): return char34; - case (35): + case(35): return char35; - case (36): + case(36): return char36; - case (37): + case(37): return char37; - case (38): + case(38): return char38; - case (39): + case(39): return char39; - case (40): + case(40): return char40; - case (41): + case(41): return char41; - case (42): + case(42): return char42; - case (43): + case(43): return char43; - case (44): + case(44): return char44; - case (45): + case(45): return char45; - case (46): + case(46): return char46; - case (47): + case(47): return char47; - case (48): + case(48): return char48; - case (49): + case(49): return char49; - case (50): + case(50): return char50; - case (51): + case(51): return char51; - case (52): + case(52): return char52; - case (53): + case(53): return char53; - case (54): + case(54): return char54; - case (55): + case(55): return char55; - case (56): + case(56): return char56; - case (57): + case(57): return char57; - case (58): + case(58): return char58; - case (59): + case(59): return char59; - case (60): + case(60): return char60; - case (61): + case(61): return char61; - case (62): + case(62): return char62; - case (63): + case(63): return char63; - case (64): + case(64): return char64; - case (65): + case(65): return char65; - case (66): + case(66): return char66; - case (67): + case(67): return char67; - case (68): + case(68): return char68; - case (69): + case(69): return char69; - case (70): + case(70): return char70; - case (71): + case(71): return char71; - case (72): + case(72): return char72; - case (73): + case(73): return char73; - case (74): + case(74): return char74; - case (75): + case(75): return char75; - case (76): + case(76): return char76; - case (77): + case(77): return char77; - case (78): + case(78): return char78; - case (79): + case(79): return char79; - case (80): + case(80): return char80; - case (81): + case(81): return char81; - case (82): + case(82): return char82; - case (83): + case(83): return char83; - case (84): + case(84): return char84; - case (85): + case(85): return char85; - case (86): + case(86): return char86; - case (87): + case(87): return char87; - case (88): + case(88): return char88; - case (89): + case(89): return char89; - case (90): + case(90): return char90; - case (91): + case(91): return char91; - case (92): + case(92): return char92; - case (93): + case(93): return char93; - case (94): + case(94): return char94; - case (95): + case(95): return char95; - case (96): + case(96): return char96; - case (97): + case(97): return char97; - case (98): + case(98): return char98; - case (99): + case(99): return char99; - case (100): + case(100): return char100; - case (101): + case(101): return char101; - case (102): + case(102): return char102; - case (103): + case(103): return char103; - case (104): + case(104): return char104; - case (105): + case(105): return char105; - case (106): + case(106): return char106; - case (107): + case(107): return char107; - case (108): + case(108): return char108; - case (109): + case(109): return char109; - case (110): + case(110): return char110; - case (111): + case(111): return char111; - case (112): + case(112): return char112; - case (113): + case(113): return char113; - case (114): + case(114): return char114; - case (115): + case(115): return char115; - case (116): + case(116): return char116; - case (117): + case(117): return char117; - case (118): + case(118): return char118; - case (119): + case(119): return char119; - case (120): + case(120): return char120; - case (121): + case(121): return char121; - case (122): + case(122): return char122; - case (123): + case(123): return char123; - case (124): + case(124): return char124; - case (125): + case(125): return char125; - case (126): + case(126): return char126; - case (127): + case(127): return char127; - case (128): + case(128): return char128; - case (129): + case(129): return char129; - case (130): + case(130): return char130; - case (131): + case(131): return char131; - case (132): + case(132): return char132; - case (133): + case(133): return char133; - case (134): + case(134): return char134; - case (135): + case(135): return char135; - case (136): + case(136): return char136; - case (137): + case(137): return char137; - case (138): + case(138): return char138; - case (139): + case(139): return char139; - case (140): + case(140): return char140; - case (141): + case(141): return char141; - case (142): + case(142): return char142; - case (143): + case(143): return char143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, char value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - char0 = value; - break; - case (1): - char1 = value; - break; - case (2): - char2 = value; - break; - case (3): - char3 = value; - break; - case (4): - char4 = value; - break; - case (5): - char5 = value; - break; - case (6): - char6 = value; - break; - case (7): - char7 = value; - break; - case (8): - char8 = value; - break; - case (9): - char9 = value; - break; - case (10): - char10 = value; - break; - case (11): - char11 = value; - break; - case (12): - char12 = value; - break; - case (13): - char13 = value; - break; - case (14): - char14 = value; - break; - case (16): - char16 = value; - break; - case (17): - char17 = value; - break; - case (18): - char18 = value; - break; - case (19): - char19 = value; - break; - case (20): - char20 = value; - break; - case (21): - char21 = value; - break; - case (22): - char22 = value; - break; - case (23): - char23 = value; - break; - case (24): - char24 = value; - break; - case (26): - char26 = value; - break; - case (28): - char28 = value; - break; - case (29): - char29 = value; - break; - case (30): - char30 = value; - break; - case (31): - char31 = value; - break; - case (32): - char32 = value; - break; - case (33): - char33 = value; - break; - case (35): - char35 = value; - break; - case (36): - char36 = value; - break; - case (37): - char37 = value; - break; - case (38): - char38 = value; - break; - case (39): - char39 = value; - break; - case (40): - char40 = value; - break; - case (41): - char41 = value; - break; - case (42): - char42 = value; - break; - case (43): - char43 = value; - break; - case (44): - char44 = value; - break; - case (45): - char45 = value; - break; - case (46): - char46 = value; - break; - case (47): - char47 = value; - break; - case (48): - char48 = value; - break; - case (49): - char49 = value; - break; - case (50): - char50 = value; - break; - case (52): - char52 = value; - break; - case (53): - char53 = value; - break; - case (54): - char54 = value; - break; - case (55): - char55 = value; - break; - case (56): - char56 = value; - break; - case (57): - char57 = value; - break; - case (58): - char58 = value; - break; - case (59): - char59 = value; - break; - case (60): - char60 = value; - break; - case (62): - char62 = value; - break; - case (64): - char64 = value; - break; - case (65): - char65 = value; - break; - case (66): - char66 = value; - break; - case (67): - char67 = value; - break; - case (68): - char68 = value; - break; - case (69): - char69 = value; - break; - case (71): - char71 = value; - break; - case (72): - char72 = value; - break; - case (73): - char73 = value; - break; - case (74): - char74 = value; - break; - case (75): - char75 = value; - break; - case (76): - char76 = value; - break; - case (77): - char77 = value; - break; - case (78): - char78 = value; - break; - case (79): - char79 = value; - break; - case (80): - char80 = value; - break; - case (81): - char81 = value; - break; - case (82): - char82 = value; - break; - case (83): - char83 = value; - break; - case (84): - char84 = value; - break; - case (85): - char85 = value; - break; - case (86): - char86 = value; - break; - case (88): - char88 = value; - break; - case (89): - char89 = value; - break; - case (90): - char90 = value; - break; - case (91): - char91 = value; - break; - case (92): - char92 = value; - break; - case (93): - char93 = value; - break; - case (94): - char94 = value; - break; - case (95): - char95 = value; - break; - case (96): - char96 = value; - break; - case (98): - char98 = value; - break; - case (100): - char100 = value; - break; - case (101): - char101 = value; - break; - case (102): - char102 = value; - break; - case (103): - char103 = value; - break; - case (104): - char104 = value; - break; - case (105): - char105 = value; - break; - case (107): - char107 = value; - break; - case (108): - char108 = value; - break; - case (109): - char109 = value; - break; - case (110): - char110 = value; - break; - case (111): - char111 = value; - break; - case (112): - char112 = value; - break; - case (113): - char113 = value; - break; - case (114): - char114 = value; - break; - case (115): - char115 = value; - break; - case (116): - char116 = value; - break; - case (117): - char117 = value; - break; - case (118): - char118 = value; - break; - case (119): - char119 = value; - break; - case (120): - char120 = value; - break; - case (121): - char121 = value; - break; - case (122): - char122 = value; - break; - case (124): - char124 = value; - break; - case (125): - char125 = value; - break; - case (126): - char126 = value; - break; - case (127): - char127 = value; - break; - case (128): - char128 = value; - break; - case (129): - char129 = value; - break; - case (130): - char130 = value; - break; - case (131): - char131 = value; - break; - case (132): - char132 = value; - break; - case (134): - char134 = value; - break; - case (136): - char136 = value; - break; - case (137): - char137 = value; - break; - case (138): - char138 = value; - break; - case (139): - char139 = value; - break; - case (140): - char140 = value; - break; - case (141): - char141 = value; - break; - case (143): - char143 = value; - break; + public boolean set(int index,char value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + char0= value; + break; + case(1): + char1= value; + break; + case(2): + char2= value; + break; + case(3): + char3= value; + break; + case(4): + char4= value; + break; + case(5): + char5= value; + break; + case(6): + char6= value; + break; + case(7): + char7= value; + break; + case(8): + char8= value; + break; + case(9): + char9= value; + break; + case(10): + char10= value; + break; + case(11): + char11= value; + break; + case(12): + char12= value; + break; + case(13): + char13= value; + break; + case(14): + char14= value; + break; + case(16): + char16= value; + break; + case(17): + char17= value; + break; + case(18): + char18= value; + break; + case(19): + char19= value; + break; + case(20): + char20= value; + break; + case(21): + char21= value; + break; + case(22): + char22= value; + break; + case(23): + char23= value; + break; + case(24): + char24= value; + break; + case(26): + char26= value; + break; + case(28): + char28= value; + break; + case(29): + char29= value; + break; + case(30): + char30= value; + break; + case(31): + char31= value; + break; + case(32): + char32= value; + break; + case(33): + char33= value; + break; + case(35): + char35= value; + break; + case(36): + char36= value; + break; + case(37): + char37= value; + break; + case(38): + char38= value; + break; + case(39): + char39= value; + break; + case(40): + char40= value; + break; + case(41): + char41= value; + break; + case(42): + char42= value; + break; + case(43): + char43= value; + break; + case(44): + char44= value; + break; + case(45): + char45= value; + break; + case(46): + char46= value; + break; + case(47): + char47= value; + break; + case(48): + char48= value; + break; + case(49): + char49= value; + break; + case(50): + char50= value; + break; + case(52): + char52= value; + break; + case(53): + char53= value; + break; + case(54): + char54= value; + break; + case(55): + char55= value; + break; + case(56): + char56= value; + break; + case(57): + char57= value; + break; + case(58): + char58= value; + break; + case(59): + char59= value; + break; + case(60): + char60= value; + break; + case(62): + char62= value; + break; + case(64): + char64= value; + break; + case(65): + char65= value; + break; + case(66): + char66= value; + break; + case(67): + char67= value; + break; + case(68): + char68= value; + break; + case(69): + char69= value; + break; + case(71): + char71= value; + break; + case(72): + char72= value; + break; + case(73): + char73= value; + break; + case(74): + char74= value; + break; + case(75): + char75= value; + break; + case(76): + char76= value; + break; + case(77): + char77= value; + break; + case(78): + char78= value; + break; + case(79): + char79= value; + break; + case(80): + char80= value; + break; + case(81): + char81= value; + break; + case(82): + char82= value; + break; + case(83): + char83= value; + break; + case(84): + char84= value; + break; + case(85): + char85= value; + break; + case(86): + char86= value; + break; + case(88): + char88= value; + break; + case(89): + char89= value; + break; + case(90): + char90= value; + break; + case(91): + char91= value; + break; + case(92): + char92= value; + break; + case(93): + char93= value; + break; + case(94): + char94= value; + break; + case(95): + char95= value; + break; + case(96): + char96= value; + break; + case(98): + char98= value; + break; + case(100): + char100= value; + break; + case(101): + char101= value; + break; + case(102): + char102= value; + break; + case(103): + char103= value; + break; + case(104): + char104= value; + break; + case(105): + char105= value; + break; + case(107): + char107= value; + break; + case(108): + char108= value; + break; + case(109): + char109= value; + break; + case(110): + char110= value; + break; + case(111): + char111= value; + break; + case(112): + char112= value; + break; + case(113): + char113= value; + break; + case(114): + char114= value; + break; + case(115): + char115= value; + break; + case(116): + char116= value; + break; + case(117): + char117= value; + break; + case(118): + char118= value; + break; + case(119): + char119= value; + break; + case(120): + char120= value; + break; + case(121): + char121= value; + break; + case(122): + char122= value; + break; + case(124): + char124= value; + break; + case(125): + char125= value; + break; + case(126): + char126= value; + break; + case(127): + char127= value; + break; + case(128): + char128= value; + break; + case(129): + char129= value; + break; + case(130): + char130= value; + break; + case(131): + char131= value; + break; + case(132): + char132= value; + break; + case(134): + char134= value; + break; + case(136): + char136= value; + break; + case(137): + char137= value; + break; + case(138): + char138= value; + break; + case(139): + char139= value; + break; + case(140): + char140= value; + break; + case(141): + char141= value; + break; + case(143): + char143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitivedouble.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitivedouble.java index 2ea35b3bc..920f16c02 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitivedouble.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitivedouble.java @@ -5,21 +5,21 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -public class FieldsOfPrimitivedouble { +public class FieldsOfPrimitivedouble { public int identifier; private double double0; private double double1; @@ -48,14 +48,14 @@ public class FieldsOfPrimitivedouble { private static transient double double24; private static final double double25 = 5; private static volatile double double26; - private final transient double double27 = 5; + private transient final double double27 = 5; private transient volatile double double28; private transient volatile double double29; private transient volatile double double30; private transient volatile double double31; private transient volatile double double32; private transient volatile double double33; - private static final transient double double34 = 5; + private static transient final double double34 = 5; private static transient volatile double double35; public double double36; public double double37; @@ -84,14 +84,14 @@ public class FieldsOfPrimitivedouble { public static transient double double60; public static final double double61 = 5; public static volatile double double62; - public final transient double double63 = 5; + public transient final double double63 = 5; public transient volatile double double64; public transient volatile double double65; public transient volatile double double66; public transient volatile double double67; public transient volatile double double68; public transient volatile double double69; - public static final transient double double70 = 5; + public static transient final double double70 = 5; public static transient volatile double double71; protected double double72; protected double double73; @@ -120,14 +120,14 @@ public class FieldsOfPrimitivedouble { protected static transient double double96; protected static final double double97 = 5; protected static volatile double double98; - protected final transient double double99 = 5; + protected transient final double double99 = 5; protected transient volatile double double100; protected transient volatile double double101; protected transient volatile double double102; protected transient volatile double double103; protected transient volatile double double104; protected transient volatile double double105; - protected static final transient double double106 = 5; + protected static transient final double double106 = 5; protected static transient volatile double double107; double double108; double double109; @@ -156,936 +156,934 @@ public class FieldsOfPrimitivedouble { static transient double double132; static final double double133 = 5; static volatile double double134; - final transient double double135 = 5; + transient final double double135 = 5; transient volatile double double136; transient volatile double double137; transient volatile double double138; transient volatile double double139; transient volatile double double140; transient volatile double double141; - static final transient double double142 = 5; + static transient final double double142 = 5; static transient volatile double double143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private double double0", - "embedded= true private double double1", - "embedded= false private double double2", - "persistence-modifier= none private double double3", - "persistence-modifier= persistent private double double4", - "persistence-modifier= persistent embedded= true private double double5", - "persistence-modifier= persistent embedded= false private double double6", - "persistence-modifier= transactional private double double7", - "private static double double8", - "private transient double double9", - "persistence-modifier= none private transient double double10", - "persistence-modifier= persistent private transient double double11", - "persistence-modifier= persistent embedded= true private transient double double12", - "persistence-modifier= persistent embedded= false private transient double double13", - "persistence-modifier= transactional private transient double double14", - "private final double double15", - "private volatile double double16", - "embedded= true private volatile double double17", - "embedded= false private volatile double double18", - "persistence-modifier= none private volatile double double19", - "persistence-modifier= persistent private volatile double double20", - "persistence-modifier= persistent embedded= true private volatile double double21", - "persistence-modifier= persistent embedded= false private volatile double double22", - "persistence-modifier= transactional private volatile double double23", - "private static transient double double24", - "private static final double double25", - "private static volatile double double26", - "private transient final double double27", - "private transient volatile double double28", - "persistence-modifier= none private transient volatile double double29", - "persistence-modifier= persistent private transient volatile double double30", - "persistence-modifier= persistent embedded= true private transient volatile double double31", - "persistence-modifier= persistent embedded= false private transient volatile double double32", - "persistence-modifier= transactional private transient volatile double double33", - "private static transient final double double34", - "private static transient volatile double double35", - "public double double36", - "embedded= true public double double37", - "embedded= false public double double38", - "persistence-modifier= none public double double39", - "persistence-modifier= persistent public double double40", - "persistence-modifier= persistent embedded= true public double double41", - "persistence-modifier= persistent embedded= false public double double42", - "persistence-modifier= transactional public double double43", - "public static double double44", - "public transient double double45", - "persistence-modifier= none public transient double double46", - "persistence-modifier= persistent public transient double double47", - "persistence-modifier= persistent embedded= true public transient double double48", - "persistence-modifier= persistent embedded= false public transient double double49", - "persistence-modifier= transactional public transient double double50", - "public final double double51", - "public volatile double double52", - "embedded= true public volatile double double53", - "embedded= false public volatile double double54", - "persistence-modifier= none public volatile double double55", - "persistence-modifier= persistent public volatile double double56", - "persistence-modifier= persistent embedded= true public volatile double double57", - "persistence-modifier= persistent embedded= false public volatile double double58", - "persistence-modifier= transactional public volatile double double59", - "public static transient double double60", - "public static final double double61", - "public static volatile double double62", - "public transient final double double63", - "public transient volatile double double64", - "persistence-modifier= none public transient volatile double double65", - "persistence-modifier= persistent public transient volatile double double66", - "persistence-modifier= persistent embedded= true public transient volatile double double67", - "persistence-modifier= persistent embedded= false public transient volatile double double68", - "persistence-modifier= transactional public transient volatile double double69", - "public static transient final double double70", - "public static transient volatile double double71", - "protected double double72", - "embedded= true protected double double73", - "embedded= false protected double double74", - "persistence-modifier= none protected double double75", - "persistence-modifier= persistent protected double double76", - "persistence-modifier= persistent embedded= true protected double double77", - "persistence-modifier= persistent embedded= false protected double double78", - "persistence-modifier= transactional protected double double79", - "protected static double double80", - "protected transient double double81", - "persistence-modifier= none protected transient double double82", - "persistence-modifier= persistent protected transient double double83", - "persistence-modifier= persistent embedded= true protected transient double double84", - "persistence-modifier= persistent embedded= false protected transient double double85", - "persistence-modifier= transactional protected transient double double86", - "protected final double double87", - "protected volatile double double88", - "embedded= true protected volatile double double89", - "embedded= false protected volatile double double90", - "persistence-modifier= none protected volatile double double91", - "persistence-modifier= persistent protected volatile double double92", - "persistence-modifier= persistent embedded= true protected volatile double double93", - "persistence-modifier= persistent embedded= false protected volatile double double94", - "persistence-modifier= transactional protected volatile double double95", - "protected static transient double double96", - "protected static final double double97", - "protected static volatile double double98", - "protected transient final double double99", - "protected transient volatile double double100", - "persistence-modifier= none protected transient volatile double double101", - "persistence-modifier= persistent protected transient volatile double double102", - "persistence-modifier= persistent embedded= true protected transient volatile double double103", - "persistence-modifier= persistent embedded= false protected transient volatile double double104", - "persistence-modifier= transactional protected transient volatile double double105", - "protected static transient final double double106", - "protected static transient volatile double double107", - "double double108", - "embedded= true double double109", - "embedded= false double double110", - "persistence-modifier= none double double111", - "persistence-modifier= persistent double double112", - "persistence-modifier= persistent embedded= true double double113", - "persistence-modifier= persistent embedded= false double double114", - "persistence-modifier= transactional double double115", - "static double double116", - "transient double double117", - "persistence-modifier= none transient double double118", - "persistence-modifier= persistent transient double double119", - "persistence-modifier= persistent embedded= true transient double double120", - "persistence-modifier= persistent embedded= false transient double double121", - "persistence-modifier= transactional transient double double122", - "final double double123", - "volatile double double124", - "embedded= true volatile double double125", - "embedded= false volatile double double126", - "persistence-modifier= none volatile double double127", - "persistence-modifier= persistent volatile double double128", - "persistence-modifier= persistent embedded= true volatile double double129", - "persistence-modifier= persistent embedded= false volatile double double130", - "persistence-modifier= transactional volatile double double131", - "static transient double double132", - "static final double double133", - "static volatile double double134", - "transient final double double135", - "transient volatile double double136", - "persistence-modifier= none transient volatile double double137", - "persistence-modifier= persistent transient volatile double double138", - "persistence-modifier= persistent embedded= true transient volatile double double139", - "persistence-modifier= persistent embedded= false transient volatile double double140", - "persistence-modifier= transactional transient volatile double double141", - "static transient final double double142", - "static transient volatile double double143" + public static final String [] fieldSpecs = { + "private double double0", + "embedded= true private double double1", + "embedded= false private double double2", + "persistence-modifier= none private double double3", + "persistence-modifier= persistent private double double4", + "persistence-modifier= persistent embedded= true private double double5", + "persistence-modifier= persistent embedded= false private double double6", + "persistence-modifier= transactional private double double7", + "private static double double8", + "private transient double double9", + "persistence-modifier= none private transient double double10", + "persistence-modifier= persistent private transient double double11", + "persistence-modifier= persistent embedded= true private transient double double12", + "persistence-modifier= persistent embedded= false private transient double double13", + "persistence-modifier= transactional private transient double double14", + "private final double double15", + "private volatile double double16", + "embedded= true private volatile double double17", + "embedded= false private volatile double double18", + "persistence-modifier= none private volatile double double19", + "persistence-modifier= persistent private volatile double double20", + "persistence-modifier= persistent embedded= true private volatile double double21", + "persistence-modifier= persistent embedded= false private volatile double double22", + "persistence-modifier= transactional private volatile double double23", + "private static transient double double24", + "private static final double double25", + "private static volatile double double26", + "private transient final double double27", + "private transient volatile double double28", + "persistence-modifier= none private transient volatile double double29", + "persistence-modifier= persistent private transient volatile double double30", + "persistence-modifier= persistent embedded= true private transient volatile double double31", + "persistence-modifier= persistent embedded= false private transient volatile double double32", + "persistence-modifier= transactional private transient volatile double double33", + "private static transient final double double34", + "private static transient volatile double double35", + "public double double36", + "embedded= true public double double37", + "embedded= false public double double38", + "persistence-modifier= none public double double39", + "persistence-modifier= persistent public double double40", + "persistence-modifier= persistent embedded= true public double double41", + "persistence-modifier= persistent embedded= false public double double42", + "persistence-modifier= transactional public double double43", + "public static double double44", + "public transient double double45", + "persistence-modifier= none public transient double double46", + "persistence-modifier= persistent public transient double double47", + "persistence-modifier= persistent embedded= true public transient double double48", + "persistence-modifier= persistent embedded= false public transient double double49", + "persistence-modifier= transactional public transient double double50", + "public final double double51", + "public volatile double double52", + "embedded= true public volatile double double53", + "embedded= false public volatile double double54", + "persistence-modifier= none public volatile double double55", + "persistence-modifier= persistent public volatile double double56", + "persistence-modifier= persistent embedded= true public volatile double double57", + "persistence-modifier= persistent embedded= false public volatile double double58", + "persistence-modifier= transactional public volatile double double59", + "public static transient double double60", + "public static final double double61", + "public static volatile double double62", + "public transient final double double63", + "public transient volatile double double64", + "persistence-modifier= none public transient volatile double double65", + "persistence-modifier= persistent public transient volatile double double66", + "persistence-modifier= persistent embedded= true public transient volatile double double67", + "persistence-modifier= persistent embedded= false public transient volatile double double68", + "persistence-modifier= transactional public transient volatile double double69", + "public static transient final double double70", + "public static transient volatile double double71", + "protected double double72", + "embedded= true protected double double73", + "embedded= false protected double double74", + "persistence-modifier= none protected double double75", + "persistence-modifier= persistent protected double double76", + "persistence-modifier= persistent embedded= true protected double double77", + "persistence-modifier= persistent embedded= false protected double double78", + "persistence-modifier= transactional protected double double79", + "protected static double double80", + "protected transient double double81", + "persistence-modifier= none protected transient double double82", + "persistence-modifier= persistent protected transient double double83", + "persistence-modifier= persistent embedded= true protected transient double double84", + "persistence-modifier= persistent embedded= false protected transient double double85", + "persistence-modifier= transactional protected transient double double86", + "protected final double double87", + "protected volatile double double88", + "embedded= true protected volatile double double89", + "embedded= false protected volatile double double90", + "persistence-modifier= none protected volatile double double91", + "persistence-modifier= persistent protected volatile double double92", + "persistence-modifier= persistent embedded= true protected volatile double double93", + "persistence-modifier= persistent embedded= false protected volatile double double94", + "persistence-modifier= transactional protected volatile double double95", + "protected static transient double double96", + "protected static final double double97", + "protected static volatile double double98", + "protected transient final double double99", + "protected transient volatile double double100", + "persistence-modifier= none protected transient volatile double double101", + "persistence-modifier= persistent protected transient volatile double double102", + "persistence-modifier= persistent embedded= true protected transient volatile double double103", + "persistence-modifier= persistent embedded= false protected transient volatile double double104", + "persistence-modifier= transactional protected transient volatile double double105", + "protected static transient final double double106", + "protected static transient volatile double double107", + "double double108", + "embedded= true double double109", + "embedded= false double double110", + "persistence-modifier= none double double111", + "persistence-modifier= persistent double double112", + "persistence-modifier= persistent embedded= true double double113", + "persistence-modifier= persistent embedded= false double double114", + "persistence-modifier= transactional double double115", + "static double double116", + "transient double double117", + "persistence-modifier= none transient double double118", + "persistence-modifier= persistent transient double double119", + "persistence-modifier= persistent embedded= true transient double double120", + "persistence-modifier= persistent embedded= false transient double double121", + "persistence-modifier= transactional transient double double122", + "final double double123", + "volatile double double124", + "embedded= true volatile double double125", + "embedded= false volatile double double126", + "persistence-modifier= none volatile double double127", + "persistence-modifier= persistent volatile double double128", + "persistence-modifier= persistent embedded= true volatile double double129", + "persistence-modifier= persistent embedded= false volatile double double130", + "persistence-modifier= transactional volatile double double131", + "static transient double double132", + "static final double double133", + "static volatile double double134", + "transient final double double135", + "transient volatile double double136", + "persistence-modifier= none transient volatile double double137", + "persistence-modifier= persistent transient volatile double double138", + "persistence-modifier= persistent embedded= true transient volatile double double139", + "persistence-modifier= persistent embedded= false transient volatile double double140", + "persistence-modifier= transactional transient volatile double double141", + "static transient final double double142", + "static transient volatile double double143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public double get(int index) { - switch (index) { - case (0): + public double get(int index) + { + switch (index) + { + case(0): return double0; - case (1): + case(1): return double1; - case (2): + case(2): return double2; - case (3): + case(3): return double3; - case (4): + case(4): return double4; - case (5): + case(5): return double5; - case (6): + case(6): return double6; - case (7): + case(7): return double7; - case (8): + case(8): return double8; - case (9): + case(9): return double9; - case (10): + case(10): return double10; - case (11): + case(11): return double11; - case (12): + case(12): return double12; - case (13): + case(13): return double13; - case (14): + case(14): return double14; - case (15): + case(15): return double15; - case (16): + case(16): return double16; - case (17): + case(17): return double17; - case (18): + case(18): return double18; - case (19): + case(19): return double19; - case (20): + case(20): return double20; - case (21): + case(21): return double21; - case (22): + case(22): return double22; - case (23): + case(23): return double23; - case (24): + case(24): return double24; - case (25): + case(25): return double25; - case (26): + case(26): return double26; - case (27): + case(27): return double27; - case (28): + case(28): return double28; - case (29): + case(29): return double29; - case (30): + case(30): return double30; - case (31): + case(31): return double31; - case (32): + case(32): return double32; - case (33): + case(33): return double33; - case (34): + case(34): return double34; - case (35): + case(35): return double35; - case (36): + case(36): return double36; - case (37): + case(37): return double37; - case (38): + case(38): return double38; - case (39): + case(39): return double39; - case (40): + case(40): return double40; - case (41): + case(41): return double41; - case (42): + case(42): return double42; - case (43): + case(43): return double43; - case (44): + case(44): return double44; - case (45): + case(45): return double45; - case (46): + case(46): return double46; - case (47): + case(47): return double47; - case (48): + case(48): return double48; - case (49): + case(49): return double49; - case (50): + case(50): return double50; - case (51): + case(51): return double51; - case (52): + case(52): return double52; - case (53): + case(53): return double53; - case (54): + case(54): return double54; - case (55): + case(55): return double55; - case (56): + case(56): return double56; - case (57): + case(57): return double57; - case (58): + case(58): return double58; - case (59): + case(59): return double59; - case (60): + case(60): return double60; - case (61): + case(61): return double61; - case (62): + case(62): return double62; - case (63): + case(63): return double63; - case (64): + case(64): return double64; - case (65): + case(65): return double65; - case (66): + case(66): return double66; - case (67): + case(67): return double67; - case (68): + case(68): return double68; - case (69): + case(69): return double69; - case (70): + case(70): return double70; - case (71): + case(71): return double71; - case (72): + case(72): return double72; - case (73): + case(73): return double73; - case (74): + case(74): return double74; - case (75): + case(75): return double75; - case (76): + case(76): return double76; - case (77): + case(77): return double77; - case (78): + case(78): return double78; - case (79): + case(79): return double79; - case (80): + case(80): return double80; - case (81): + case(81): return double81; - case (82): + case(82): return double82; - case (83): + case(83): return double83; - case (84): + case(84): return double84; - case (85): + case(85): return double85; - case (86): + case(86): return double86; - case (87): + case(87): return double87; - case (88): + case(88): return double88; - case (89): + case(89): return double89; - case (90): + case(90): return double90; - case (91): + case(91): return double91; - case (92): + case(92): return double92; - case (93): + case(93): return double93; - case (94): + case(94): return double94; - case (95): + case(95): return double95; - case (96): + case(96): return double96; - case (97): + case(97): return double97; - case (98): + case(98): return double98; - case (99): + case(99): return double99; - case (100): + case(100): return double100; - case (101): + case(101): return double101; - case (102): + case(102): return double102; - case (103): + case(103): return double103; - case (104): + case(104): return double104; - case (105): + case(105): return double105; - case (106): + case(106): return double106; - case (107): + case(107): return double107; - case (108): + case(108): return double108; - case (109): + case(109): return double109; - case (110): + case(110): return double110; - case (111): + case(111): return double111; - case (112): + case(112): return double112; - case (113): + case(113): return double113; - case (114): + case(114): return double114; - case (115): + case(115): return double115; - case (116): + case(116): return double116; - case (117): + case(117): return double117; - case (118): + case(118): return double118; - case (119): + case(119): return double119; - case (120): + case(120): return double120; - case (121): + case(121): return double121; - case (122): + case(122): return double122; - case (123): + case(123): return double123; - case (124): + case(124): return double124; - case (125): + case(125): return double125; - case (126): + case(126): return double126; - case (127): + case(127): return double127; - case (128): + case(128): return double128; - case (129): + case(129): return double129; - case (130): + case(130): return double130; - case (131): + case(131): return double131; - case (132): + case(132): return double132; - case (133): + case(133): return double133; - case (134): + case(134): return double134; - case (135): + case(135): return double135; - case (136): + case(136): return double136; - case (137): + case(137): return double137; - case (138): + case(138): return double138; - case (139): + case(139): return double139; - case (140): + case(140): return double140; - case (141): + case(141): return double141; - case (142): + case(142): return double142; - case (143): + case(143): return double143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, double value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - double0 = value; - break; - case (1): - double1 = value; - break; - case (2): - double2 = value; - break; - case (3): - double3 = value; - break; - case (4): - double4 = value; - break; - case (5): - double5 = value; - break; - case (6): - double6 = value; - break; - case (7): - double7 = value; - break; - case (8): - double8 = value; - break; - case (9): - double9 = value; - break; - case (10): - double10 = value; - break; - case (11): - double11 = value; - break; - case (12): - double12 = value; - break; - case (13): - double13 = value; - break; - case (14): - double14 = value; - break; - case (16): - double16 = value; - break; - case (17): - double17 = value; - break; - case (18): - double18 = value; - break; - case (19): - double19 = value; - break; - case (20): - double20 = value; - break; - case (21): - double21 = value; - break; - case (22): - double22 = value; - break; - case (23): - double23 = value; - break; - case (24): - double24 = value; - break; - case (26): - double26 = value; - break; - case (28): - double28 = value; - break; - case (29): - double29 = value; - break; - case (30): - double30 = value; - break; - case (31): - double31 = value; - break; - case (32): - double32 = value; - break; - case (33): - double33 = value; - break; - case (35): - double35 = value; - break; - case (36): - double36 = value; - break; - case (37): - double37 = value; - break; - case (38): - double38 = value; - break; - case (39): - double39 = value; - break; - case (40): - double40 = value; - break; - case (41): - double41 = value; - break; - case (42): - double42 = value; - break; - case (43): - double43 = value; - break; - case (44): - double44 = value; - break; - case (45): - double45 = value; - break; - case (46): - double46 = value; - break; - case (47): - double47 = value; - break; - case (48): - double48 = value; - break; - case (49): - double49 = value; - break; - case (50): - double50 = value; - break; - case (52): - double52 = value; - break; - case (53): - double53 = value; - break; - case (54): - double54 = value; - break; - case (55): - double55 = value; - break; - case (56): - double56 = value; - break; - case (57): - double57 = value; - break; - case (58): - double58 = value; - break; - case (59): - double59 = value; - break; - case (60): - double60 = value; - break; - case (62): - double62 = value; - break; - case (64): - double64 = value; - break; - case (65): - double65 = value; - break; - case (66): - double66 = value; - break; - case (67): - double67 = value; - break; - case (68): - double68 = value; - break; - case (69): - double69 = value; - break; - case (71): - double71 = value; - break; - case (72): - double72 = value; - break; - case (73): - double73 = value; - break; - case (74): - double74 = value; - break; - case (75): - double75 = value; - break; - case (76): - double76 = value; - break; - case (77): - double77 = value; - break; - case (78): - double78 = value; - break; - case (79): - double79 = value; - break; - case (80): - double80 = value; - break; - case (81): - double81 = value; - break; - case (82): - double82 = value; - break; - case (83): - double83 = value; - break; - case (84): - double84 = value; - break; - case (85): - double85 = value; - break; - case (86): - double86 = value; - break; - case (88): - double88 = value; - break; - case (89): - double89 = value; - break; - case (90): - double90 = value; - break; - case (91): - double91 = value; - break; - case (92): - double92 = value; - break; - case (93): - double93 = value; - break; - case (94): - double94 = value; - break; - case (95): - double95 = value; - break; - case (96): - double96 = value; - break; - case (98): - double98 = value; - break; - case (100): - double100 = value; - break; - case (101): - double101 = value; - break; - case (102): - double102 = value; - break; - case (103): - double103 = value; - break; - case (104): - double104 = value; - break; - case (105): - double105 = value; - break; - case (107): - double107 = value; - break; - case (108): - double108 = value; - break; - case (109): - double109 = value; - break; - case (110): - double110 = value; - break; - case (111): - double111 = value; - break; - case (112): - double112 = value; - break; - case (113): - double113 = value; - break; - case (114): - double114 = value; - break; - case (115): - double115 = value; - break; - case (116): - double116 = value; - break; - case (117): - double117 = value; - break; - case (118): - double118 = value; - break; - case (119): - double119 = value; - break; - case (120): - double120 = value; - break; - case (121): - double121 = value; - break; - case (122): - double122 = value; - break; - case (124): - double124 = value; - break; - case (125): - double125 = value; - break; - case (126): - double126 = value; - break; - case (127): - double127 = value; - break; - case (128): - double128 = value; - break; - case (129): - double129 = value; - break; - case (130): - double130 = value; - break; - case (131): - double131 = value; - break; - case (132): - double132 = value; - break; - case (134): - double134 = value; - break; - case (136): - double136 = value; - break; - case (137): - double137 = value; - break; - case (138): - double138 = value; - break; - case (139): - double139 = value; - break; - case (140): - double140 = value; - break; - case (141): - double141 = value; - break; - case (143): - double143 = value; - break; + public boolean set(int index,double value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + double0= value; + break; + case(1): + double1= value; + break; + case(2): + double2= value; + break; + case(3): + double3= value; + break; + case(4): + double4= value; + break; + case(5): + double5= value; + break; + case(6): + double6= value; + break; + case(7): + double7= value; + break; + case(8): + double8= value; + break; + case(9): + double9= value; + break; + case(10): + double10= value; + break; + case(11): + double11= value; + break; + case(12): + double12= value; + break; + case(13): + double13= value; + break; + case(14): + double14= value; + break; + case(16): + double16= value; + break; + case(17): + double17= value; + break; + case(18): + double18= value; + break; + case(19): + double19= value; + break; + case(20): + double20= value; + break; + case(21): + double21= value; + break; + case(22): + double22= value; + break; + case(23): + double23= value; + break; + case(24): + double24= value; + break; + case(26): + double26= value; + break; + case(28): + double28= value; + break; + case(29): + double29= value; + break; + case(30): + double30= value; + break; + case(31): + double31= value; + break; + case(32): + double32= value; + break; + case(33): + double33= value; + break; + case(35): + double35= value; + break; + case(36): + double36= value; + break; + case(37): + double37= value; + break; + case(38): + double38= value; + break; + case(39): + double39= value; + break; + case(40): + double40= value; + break; + case(41): + double41= value; + break; + case(42): + double42= value; + break; + case(43): + double43= value; + break; + case(44): + double44= value; + break; + case(45): + double45= value; + break; + case(46): + double46= value; + break; + case(47): + double47= value; + break; + case(48): + double48= value; + break; + case(49): + double49= value; + break; + case(50): + double50= value; + break; + case(52): + double52= value; + break; + case(53): + double53= value; + break; + case(54): + double54= value; + break; + case(55): + double55= value; + break; + case(56): + double56= value; + break; + case(57): + double57= value; + break; + case(58): + double58= value; + break; + case(59): + double59= value; + break; + case(60): + double60= value; + break; + case(62): + double62= value; + break; + case(64): + double64= value; + break; + case(65): + double65= value; + break; + case(66): + double66= value; + break; + case(67): + double67= value; + break; + case(68): + double68= value; + break; + case(69): + double69= value; + break; + case(71): + double71= value; + break; + case(72): + double72= value; + break; + case(73): + double73= value; + break; + case(74): + double74= value; + break; + case(75): + double75= value; + break; + case(76): + double76= value; + break; + case(77): + double77= value; + break; + case(78): + double78= value; + break; + case(79): + double79= value; + break; + case(80): + double80= value; + break; + case(81): + double81= value; + break; + case(82): + double82= value; + break; + case(83): + double83= value; + break; + case(84): + double84= value; + break; + case(85): + double85= value; + break; + case(86): + double86= value; + break; + case(88): + double88= value; + break; + case(89): + double89= value; + break; + case(90): + double90= value; + break; + case(91): + double91= value; + break; + case(92): + double92= value; + break; + case(93): + double93= value; + break; + case(94): + double94= value; + break; + case(95): + double95= value; + break; + case(96): + double96= value; + break; + case(98): + double98= value; + break; + case(100): + double100= value; + break; + case(101): + double101= value; + break; + case(102): + double102= value; + break; + case(103): + double103= value; + break; + case(104): + double104= value; + break; + case(105): + double105= value; + break; + case(107): + double107= value; + break; + case(108): + double108= value; + break; + case(109): + double109= value; + break; + case(110): + double110= value; + break; + case(111): + double111= value; + break; + case(112): + double112= value; + break; + case(113): + double113= value; + break; + case(114): + double114= value; + break; + case(115): + double115= value; + break; + case(116): + double116= value; + break; + case(117): + double117= value; + break; + case(118): + double118= value; + break; + case(119): + double119= value; + break; + case(120): + double120= value; + break; + case(121): + double121= value; + break; + case(122): + double122= value; + break; + case(124): + double124= value; + break; + case(125): + double125= value; + break; + case(126): + double126= value; + break; + case(127): + double127= value; + break; + case(128): + double128= value; + break; + case(129): + double129= value; + break; + case(130): + double130= value; + break; + case(131): + double131= value; + break; + case(132): + double132= value; + break; + case(134): + double134= value; + break; + case(136): + double136= value; + break; + case(137): + double137= value; + break; + case(138): + double138= value; + break; + case(139): + double139= value; + break; + case(140): + double140= value; + break; + case(141): + double141= value; + break; + case(143): + double143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } - - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public int hashCode() { - return (int) identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public int hashCode() { return (int)identifier ; } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitivefloat.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitivefloat.java index 22df709f2..65bdeb381 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitivefloat.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitivefloat.java @@ -5,21 +5,21 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -public class FieldsOfPrimitivefloat { +public class FieldsOfPrimitivefloat { public int identifier; private float float0; private float float1; @@ -48,14 +48,14 @@ public class FieldsOfPrimitivefloat { private static transient float float24; private static final float float25 = 5; private static volatile float float26; - private final transient float float27 = 5; + private transient final float float27 = 5; private transient volatile float float28; private transient volatile float float29; private transient volatile float float30; private transient volatile float float31; private transient volatile float float32; private transient volatile float float33; - private static final transient float float34 = 5; + private static transient final float float34 = 5; private static transient volatile float float35; public float float36; public float float37; @@ -84,14 +84,14 @@ public class FieldsOfPrimitivefloat { public static transient float float60; public static final float float61 = 5; public static volatile float float62; - public final transient float float63 = 5; + public transient final float float63 = 5; public transient volatile float float64; public transient volatile float float65; public transient volatile float float66; public transient volatile float float67; public transient volatile float float68; public transient volatile float float69; - public static final transient float float70 = 5; + public static transient final float float70 = 5; public static transient volatile float float71; protected float float72; protected float float73; @@ -120,14 +120,14 @@ public class FieldsOfPrimitivefloat { protected static transient float float96; protected static final float float97 = 5; protected static volatile float float98; - protected final transient float float99 = 5; + protected transient final float float99 = 5; protected transient volatile float float100; protected transient volatile float float101; protected transient volatile float float102; protected transient volatile float float103; protected transient volatile float float104; protected transient volatile float float105; - protected static final transient float float106 = 5; + protected static transient final float float106 = 5; protected static transient volatile float float107; float float108; float float109; @@ -156,936 +156,935 @@ public class FieldsOfPrimitivefloat { static transient float float132; static final float float133 = 5; static volatile float float134; - final transient float float135 = 5; + transient final float float135 = 5; transient volatile float float136; transient volatile float float137; transient volatile float float138; transient volatile float float139; transient volatile float float140; transient volatile float float141; - static final transient float float142 = 5; + static transient final float float142 = 5; static transient volatile float float143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private float float0", - "embedded= true private float float1", - "embedded= false private float float2", - "persistence-modifier= none private float float3", - "persistence-modifier= persistent private float float4", - "persistence-modifier= persistent embedded= true private float float5", - "persistence-modifier= persistent embedded= false private float float6", - "persistence-modifier= transactional private float float7", - "private static float float8", - "private transient float float9", - "persistence-modifier= none private transient float float10", - "persistence-modifier= persistent private transient float float11", - "persistence-modifier= persistent embedded= true private transient float float12", - "persistence-modifier= persistent embedded= false private transient float float13", - "persistence-modifier= transactional private transient float float14", - "private final float float15", - "private volatile float float16", - "embedded= true private volatile float float17", - "embedded= false private volatile float float18", - "persistence-modifier= none private volatile float float19", - "persistence-modifier= persistent private volatile float float20", - "persistence-modifier= persistent embedded= true private volatile float float21", - "persistence-modifier= persistent embedded= false private volatile float float22", - "persistence-modifier= transactional private volatile float float23", - "private static transient float float24", - "private static final float float25", - "private static volatile float float26", - "private transient final float float27", - "private transient volatile float float28", - "persistence-modifier= none private transient volatile float float29", - "persistence-modifier= persistent private transient volatile float float30", - "persistence-modifier= persistent embedded= true private transient volatile float float31", - "persistence-modifier= persistent embedded= false private transient volatile float float32", - "persistence-modifier= transactional private transient volatile float float33", - "private static transient final float float34", - "private static transient volatile float float35", - "public float float36", - "embedded= true public float float37", - "embedded= false public float float38", - "persistence-modifier= none public float float39", - "persistence-modifier= persistent public float float40", - "persistence-modifier= persistent embedded= true public float float41", - "persistence-modifier= persistent embedded= false public float float42", - "persistence-modifier= transactional public float float43", - "public static float float44", - "public transient float float45", - "persistence-modifier= none public transient float float46", - "persistence-modifier= persistent public transient float float47", - "persistence-modifier= persistent embedded= true public transient float float48", - "persistence-modifier= persistent embedded= false public transient float float49", - "persistence-modifier= transactional public transient float float50", - "public final float float51", - "public volatile float float52", - "embedded= true public volatile float float53", - "embedded= false public volatile float float54", - "persistence-modifier= none public volatile float float55", - "persistence-modifier= persistent public volatile float float56", - "persistence-modifier= persistent embedded= true public volatile float float57", - "persistence-modifier= persistent embedded= false public volatile float float58", - "persistence-modifier= transactional public volatile float float59", - "public static transient float float60", - "public static final float float61", - "public static volatile float float62", - "public transient final float float63", - "public transient volatile float float64", - "persistence-modifier= none public transient volatile float float65", - "persistence-modifier= persistent public transient volatile float float66", - "persistence-modifier= persistent embedded= true public transient volatile float float67", - "persistence-modifier= persistent embedded= false public transient volatile float float68", - "persistence-modifier= transactional public transient volatile float float69", - "public static transient final float float70", - "public static transient volatile float float71", - "protected float float72", - "embedded= true protected float float73", - "embedded= false protected float float74", - "persistence-modifier= none protected float float75", - "persistence-modifier= persistent protected float float76", - "persistence-modifier= persistent embedded= true protected float float77", - "persistence-modifier= persistent embedded= false protected float float78", - "persistence-modifier= transactional protected float float79", - "protected static float float80", - "protected transient float float81", - "persistence-modifier= none protected transient float float82", - "persistence-modifier= persistent protected transient float float83", - "persistence-modifier= persistent embedded= true protected transient float float84", - "persistence-modifier= persistent embedded= false protected transient float float85", - "persistence-modifier= transactional protected transient float float86", - "protected final float float87", - "protected volatile float float88", - "embedded= true protected volatile float float89", - "embedded= false protected volatile float float90", - "persistence-modifier= none protected volatile float float91", - "persistence-modifier= persistent protected volatile float float92", - "persistence-modifier= persistent embedded= true protected volatile float float93", - "persistence-modifier= persistent embedded= false protected volatile float float94", - "persistence-modifier= transactional protected volatile float float95", - "protected static transient float float96", - "protected static final float float97", - "protected static volatile float float98", - "protected transient final float float99", - "protected transient volatile float float100", - "persistence-modifier= none protected transient volatile float float101", - "persistence-modifier= persistent protected transient volatile float float102", - "persistence-modifier= persistent embedded= true protected transient volatile float float103", - "persistence-modifier= persistent embedded= false protected transient volatile float float104", - "persistence-modifier= transactional protected transient volatile float float105", - "protected static transient final float float106", - "protected static transient volatile float float107", - "float float108", - "embedded= true float float109", - "embedded= false float float110", - "persistence-modifier= none float float111", - "persistence-modifier= persistent float float112", - "persistence-modifier= persistent embedded= true float float113", - "persistence-modifier= persistent embedded= false float float114", - "persistence-modifier= transactional float float115", - "static float float116", - "transient float float117", - "persistence-modifier= none transient float float118", - "persistence-modifier= persistent transient float float119", - "persistence-modifier= persistent embedded= true transient float float120", - "persistence-modifier= persistent embedded= false transient float float121", - "persistence-modifier= transactional transient float float122", - "final float float123", - "volatile float float124", - "embedded= true volatile float float125", - "embedded= false volatile float float126", - "persistence-modifier= none volatile float float127", - "persistence-modifier= persistent volatile float float128", - "persistence-modifier= persistent embedded= true volatile float float129", - "persistence-modifier= persistent embedded= false volatile float float130", - "persistence-modifier= transactional volatile float float131", - "static transient float float132", - "static final float float133", - "static volatile float float134", - "transient final float float135", - "transient volatile float float136", - "persistence-modifier= none transient volatile float float137", - "persistence-modifier= persistent transient volatile float float138", - "persistence-modifier= persistent embedded= true transient volatile float float139", - "persistence-modifier= persistent embedded= false transient volatile float float140", - "persistence-modifier= transactional transient volatile float float141", - "static transient final float float142", - "static transient volatile float float143" + public static final String [] fieldSpecs = { + "private float float0", + "embedded= true private float float1", + "embedded= false private float float2", + "persistence-modifier= none private float float3", + "persistence-modifier= persistent private float float4", + "persistence-modifier= persistent embedded= true private float float5", + "persistence-modifier= persistent embedded= false private float float6", + "persistence-modifier= transactional private float float7", + "private static float float8", + "private transient float float9", + "persistence-modifier= none private transient float float10", + "persistence-modifier= persistent private transient float float11", + "persistence-modifier= persistent embedded= true private transient float float12", + "persistence-modifier= persistent embedded= false private transient float float13", + "persistence-modifier= transactional private transient float float14", + "private final float float15", + "private volatile float float16", + "embedded= true private volatile float float17", + "embedded= false private volatile float float18", + "persistence-modifier= none private volatile float float19", + "persistence-modifier= persistent private volatile float float20", + "persistence-modifier= persistent embedded= true private volatile float float21", + "persistence-modifier= persistent embedded= false private volatile float float22", + "persistence-modifier= transactional private volatile float float23", + "private static transient float float24", + "private static final float float25", + "private static volatile float float26", + "private transient final float float27", + "private transient volatile float float28", + "persistence-modifier= none private transient volatile float float29", + "persistence-modifier= persistent private transient volatile float float30", + "persistence-modifier= persistent embedded= true private transient volatile float float31", + "persistence-modifier= persistent embedded= false private transient volatile float float32", + "persistence-modifier= transactional private transient volatile float float33", + "private static transient final float float34", + "private static transient volatile float float35", + "public float float36", + "embedded= true public float float37", + "embedded= false public float float38", + "persistence-modifier= none public float float39", + "persistence-modifier= persistent public float float40", + "persistence-modifier= persistent embedded= true public float float41", + "persistence-modifier= persistent embedded= false public float float42", + "persistence-modifier= transactional public float float43", + "public static float float44", + "public transient float float45", + "persistence-modifier= none public transient float float46", + "persistence-modifier= persistent public transient float float47", + "persistence-modifier= persistent embedded= true public transient float float48", + "persistence-modifier= persistent embedded= false public transient float float49", + "persistence-modifier= transactional public transient float float50", + "public final float float51", + "public volatile float float52", + "embedded= true public volatile float float53", + "embedded= false public volatile float float54", + "persistence-modifier= none public volatile float float55", + "persistence-modifier= persistent public volatile float float56", + "persistence-modifier= persistent embedded= true public volatile float float57", + "persistence-modifier= persistent embedded= false public volatile float float58", + "persistence-modifier= transactional public volatile float float59", + "public static transient float float60", + "public static final float float61", + "public static volatile float float62", + "public transient final float float63", + "public transient volatile float float64", + "persistence-modifier= none public transient volatile float float65", + "persistence-modifier= persistent public transient volatile float float66", + "persistence-modifier= persistent embedded= true public transient volatile float float67", + "persistence-modifier= persistent embedded= false public transient volatile float float68", + "persistence-modifier= transactional public transient volatile float float69", + "public static transient final float float70", + "public static transient volatile float float71", + "protected float float72", + "embedded= true protected float float73", + "embedded= false protected float float74", + "persistence-modifier= none protected float float75", + "persistence-modifier= persistent protected float float76", + "persistence-modifier= persistent embedded= true protected float float77", + "persistence-modifier= persistent embedded= false protected float float78", + "persistence-modifier= transactional protected float float79", + "protected static float float80", + "protected transient float float81", + "persistence-modifier= none protected transient float float82", + "persistence-modifier= persistent protected transient float float83", + "persistence-modifier= persistent embedded= true protected transient float float84", + "persistence-modifier= persistent embedded= false protected transient float float85", + "persistence-modifier= transactional protected transient float float86", + "protected final float float87", + "protected volatile float float88", + "embedded= true protected volatile float float89", + "embedded= false protected volatile float float90", + "persistence-modifier= none protected volatile float float91", + "persistence-modifier= persistent protected volatile float float92", + "persistence-modifier= persistent embedded= true protected volatile float float93", + "persistence-modifier= persistent embedded= false protected volatile float float94", + "persistence-modifier= transactional protected volatile float float95", + "protected static transient float float96", + "protected static final float float97", + "protected static volatile float float98", + "protected transient final float float99", + "protected transient volatile float float100", + "persistence-modifier= none protected transient volatile float float101", + "persistence-modifier= persistent protected transient volatile float float102", + "persistence-modifier= persistent embedded= true protected transient volatile float float103", + "persistence-modifier= persistent embedded= false protected transient volatile float float104", + "persistence-modifier= transactional protected transient volatile float float105", + "protected static transient final float float106", + "protected static transient volatile float float107", + "float float108", + "embedded= true float float109", + "embedded= false float float110", + "persistence-modifier= none float float111", + "persistence-modifier= persistent float float112", + "persistence-modifier= persistent embedded= true float float113", + "persistence-modifier= persistent embedded= false float float114", + "persistence-modifier= transactional float float115", + "static float float116", + "transient float float117", + "persistence-modifier= none transient float float118", + "persistence-modifier= persistent transient float float119", + "persistence-modifier= persistent embedded= true transient float float120", + "persistence-modifier= persistent embedded= false transient float float121", + "persistence-modifier= transactional transient float float122", + "final float float123", + "volatile float float124", + "embedded= true volatile float float125", + "embedded= false volatile float float126", + "persistence-modifier= none volatile float float127", + "persistence-modifier= persistent volatile float float128", + "persistence-modifier= persistent embedded= true volatile float float129", + "persistence-modifier= persistent embedded= false volatile float float130", + "persistence-modifier= transactional volatile float float131", + "static transient float float132", + "static final float float133", + "static volatile float float134", + "transient final float float135", + "transient volatile float float136", + "persistence-modifier= none transient volatile float float137", + "persistence-modifier= persistent transient volatile float float138", + "persistence-modifier= persistent embedded= true transient volatile float float139", + "persistence-modifier= persistent embedded= false transient volatile float float140", + "persistence-modifier= transactional transient volatile float float141", + "static transient final float float142", + "static transient volatile float float143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public float get(int index) { - switch (index) { - case (0): + public float get(int index) + { + switch (index) + { + case(0): return float0; - case (1): + case(1): return float1; - case (2): + case(2): return float2; - case (3): + case(3): return float3; - case (4): + case(4): return float4; - case (5): + case(5): return float5; - case (6): + case(6): return float6; - case (7): + case(7): return float7; - case (8): + case(8): return float8; - case (9): + case(9): return float9; - case (10): + case(10): return float10; - case (11): + case(11): return float11; - case (12): + case(12): return float12; - case (13): + case(13): return float13; - case (14): + case(14): return float14; - case (15): + case(15): return float15; - case (16): + case(16): return float16; - case (17): + case(17): return float17; - case (18): + case(18): return float18; - case (19): + case(19): return float19; - case (20): + case(20): return float20; - case (21): + case(21): return float21; - case (22): + case(22): return float22; - case (23): + case(23): return float23; - case (24): + case(24): return float24; - case (25): + case(25): return float25; - case (26): + case(26): return float26; - case (27): + case(27): return float27; - case (28): + case(28): return float28; - case (29): + case(29): return float29; - case (30): + case(30): return float30; - case (31): + case(31): return float31; - case (32): + case(32): return float32; - case (33): + case(33): return float33; - case (34): + case(34): return float34; - case (35): + case(35): return float35; - case (36): + case(36): return float36; - case (37): + case(37): return float37; - case (38): + case(38): return float38; - case (39): + case(39): return float39; - case (40): + case(40): return float40; - case (41): + case(41): return float41; - case (42): + case(42): return float42; - case (43): + case(43): return float43; - case (44): + case(44): return float44; - case (45): + case(45): return float45; - case (46): + case(46): return float46; - case (47): + case(47): return float47; - case (48): + case(48): return float48; - case (49): + case(49): return float49; - case (50): + case(50): return float50; - case (51): + case(51): return float51; - case (52): + case(52): return float52; - case (53): + case(53): return float53; - case (54): + case(54): return float54; - case (55): + case(55): return float55; - case (56): + case(56): return float56; - case (57): + case(57): return float57; - case (58): + case(58): return float58; - case (59): + case(59): return float59; - case (60): + case(60): return float60; - case (61): + case(61): return float61; - case (62): + case(62): return float62; - case (63): + case(63): return float63; - case (64): + case(64): return float64; - case (65): + case(65): return float65; - case (66): + case(66): return float66; - case (67): + case(67): return float67; - case (68): + case(68): return float68; - case (69): + case(69): return float69; - case (70): + case(70): return float70; - case (71): + case(71): return float71; - case (72): + case(72): return float72; - case (73): + case(73): return float73; - case (74): + case(74): return float74; - case (75): + case(75): return float75; - case (76): + case(76): return float76; - case (77): + case(77): return float77; - case (78): + case(78): return float78; - case (79): + case(79): return float79; - case (80): + case(80): return float80; - case (81): + case(81): return float81; - case (82): + case(82): return float82; - case (83): + case(83): return float83; - case (84): + case(84): return float84; - case (85): + case(85): return float85; - case (86): + case(86): return float86; - case (87): + case(87): return float87; - case (88): + case(88): return float88; - case (89): + case(89): return float89; - case (90): + case(90): return float90; - case (91): + case(91): return float91; - case (92): + case(92): return float92; - case (93): + case(93): return float93; - case (94): + case(94): return float94; - case (95): + case(95): return float95; - case (96): + case(96): return float96; - case (97): + case(97): return float97; - case (98): + case(98): return float98; - case (99): + case(99): return float99; - case (100): + case(100): return float100; - case (101): + case(101): return float101; - case (102): + case(102): return float102; - case (103): + case(103): return float103; - case (104): + case(104): return float104; - case (105): + case(105): return float105; - case (106): + case(106): return float106; - case (107): + case(107): return float107; - case (108): + case(108): return float108; - case (109): + case(109): return float109; - case (110): + case(110): return float110; - case (111): + case(111): return float111; - case (112): + case(112): return float112; - case (113): + case(113): return float113; - case (114): + case(114): return float114; - case (115): + case(115): return float115; - case (116): + case(116): return float116; - case (117): + case(117): return float117; - case (118): + case(118): return float118; - case (119): + case(119): return float119; - case (120): + case(120): return float120; - case (121): + case(121): return float121; - case (122): + case(122): return float122; - case (123): + case(123): return float123; - case (124): + case(124): return float124; - case (125): + case(125): return float125; - case (126): + case(126): return float126; - case (127): + case(127): return float127; - case (128): + case(128): return float128; - case (129): + case(129): return float129; - case (130): + case(130): return float130; - case (131): + case(131): return float131; - case (132): + case(132): return float132; - case (133): + case(133): return float133; - case (134): + case(134): return float134; - case (135): + case(135): return float135; - case (136): + case(136): return float136; - case (137): + case(137): return float137; - case (138): + case(138): return float138; - case (139): + case(139): return float139; - case (140): + case(140): return float140; - case (141): + case(141): return float141; - case (142): + case(142): return float142; - case (143): + case(143): return float143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, float value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - float0 = value; - break; - case (1): - float1 = value; - break; - case (2): - float2 = value; - break; - case (3): - float3 = value; - break; - case (4): - float4 = value; - break; - case (5): - float5 = value; - break; - case (6): - float6 = value; - break; - case (7): - float7 = value; - break; - case (8): - float8 = value; - break; - case (9): - float9 = value; - break; - case (10): - float10 = value; - break; - case (11): - float11 = value; - break; - case (12): - float12 = value; - break; - case (13): - float13 = value; - break; - case (14): - float14 = value; - break; - case (16): - float16 = value; - break; - case (17): - float17 = value; - break; - case (18): - float18 = value; - break; - case (19): - float19 = value; - break; - case (20): - float20 = value; - break; - case (21): - float21 = value; - break; - case (22): - float22 = value; - break; - case (23): - float23 = value; - break; - case (24): - float24 = value; - break; - case (26): - float26 = value; - break; - case (28): - float28 = value; - break; - case (29): - float29 = value; - break; - case (30): - float30 = value; - break; - case (31): - float31 = value; - break; - case (32): - float32 = value; - break; - case (33): - float33 = value; - break; - case (35): - float35 = value; - break; - case (36): - float36 = value; - break; - case (37): - float37 = value; - break; - case (38): - float38 = value; - break; - case (39): - float39 = value; - break; - case (40): - float40 = value; - break; - case (41): - float41 = value; - break; - case (42): - float42 = value; - break; - case (43): - float43 = value; - break; - case (44): - float44 = value; - break; - case (45): - float45 = value; - break; - case (46): - float46 = value; - break; - case (47): - float47 = value; - break; - case (48): - float48 = value; - break; - case (49): - float49 = value; - break; - case (50): - float50 = value; - break; - case (52): - float52 = value; - break; - case (53): - float53 = value; - break; - case (54): - float54 = value; - break; - case (55): - float55 = value; - break; - case (56): - float56 = value; - break; - case (57): - float57 = value; - break; - case (58): - float58 = value; - break; - case (59): - float59 = value; - break; - case (60): - float60 = value; - break; - case (62): - float62 = value; - break; - case (64): - float64 = value; - break; - case (65): - float65 = value; - break; - case (66): - float66 = value; - break; - case (67): - float67 = value; - break; - case (68): - float68 = value; - break; - case (69): - float69 = value; - break; - case (71): - float71 = value; - break; - case (72): - float72 = value; - break; - case (73): - float73 = value; - break; - case (74): - float74 = value; - break; - case (75): - float75 = value; - break; - case (76): - float76 = value; - break; - case (77): - float77 = value; - break; - case (78): - float78 = value; - break; - case (79): - float79 = value; - break; - case (80): - float80 = value; - break; - case (81): - float81 = value; - break; - case (82): - float82 = value; - break; - case (83): - float83 = value; - break; - case (84): - float84 = value; - break; - case (85): - float85 = value; - break; - case (86): - float86 = value; - break; - case (88): - float88 = value; - break; - case (89): - float89 = value; - break; - case (90): - float90 = value; - break; - case (91): - float91 = value; - break; - case (92): - float92 = value; - break; - case (93): - float93 = value; - break; - case (94): - float94 = value; - break; - case (95): - float95 = value; - break; - case (96): - float96 = value; - break; - case (98): - float98 = value; - break; - case (100): - float100 = value; - break; - case (101): - float101 = value; - break; - case (102): - float102 = value; - break; - case (103): - float103 = value; - break; - case (104): - float104 = value; - break; - case (105): - float105 = value; - break; - case (107): - float107 = value; - break; - case (108): - float108 = value; - break; - case (109): - float109 = value; - break; - case (110): - float110 = value; - break; - case (111): - float111 = value; - break; - case (112): - float112 = value; - break; - case (113): - float113 = value; - break; - case (114): - float114 = value; - break; - case (115): - float115 = value; - break; - case (116): - float116 = value; - break; - case (117): - float117 = value; - break; - case (118): - float118 = value; - break; - case (119): - float119 = value; - break; - case (120): - float120 = value; - break; - case (121): - float121 = value; - break; - case (122): - float122 = value; - break; - case (124): - float124 = value; - break; - case (125): - float125 = value; - break; - case (126): - float126 = value; - break; - case (127): - float127 = value; - break; - case (128): - float128 = value; - break; - case (129): - float129 = value; - break; - case (130): - float130 = value; - break; - case (131): - float131 = value; - break; - case (132): - float132 = value; - break; - case (134): - float134 = value; - break; - case (136): - float136 = value; - break; - case (137): - float137 = value; - break; - case (138): - float138 = value; - break; - case (139): - float139 = value; - break; - case (140): - float140 = value; - break; - case (141): - float141 = value; - break; - case (143): - float143 = value; - break; + public boolean set(int index,float value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + float0= value; + break; + case(1): + float1= value; + break; + case(2): + float2= value; + break; + case(3): + float3= value; + break; + case(4): + float4= value; + break; + case(5): + float5= value; + break; + case(6): + float6= value; + break; + case(7): + float7= value; + break; + case(8): + float8= value; + break; + case(9): + float9= value; + break; + case(10): + float10= value; + break; + case(11): + float11= value; + break; + case(12): + float12= value; + break; + case(13): + float13= value; + break; + case(14): + float14= value; + break; + case(16): + float16= value; + break; + case(17): + float17= value; + break; + case(18): + float18= value; + break; + case(19): + float19= value; + break; + case(20): + float20= value; + break; + case(21): + float21= value; + break; + case(22): + float22= value; + break; + case(23): + float23= value; + break; + case(24): + float24= value; + break; + case(26): + float26= value; + break; + case(28): + float28= value; + break; + case(29): + float29= value; + break; + case(30): + float30= value; + break; + case(31): + float31= value; + break; + case(32): + float32= value; + break; + case(33): + float33= value; + break; + case(35): + float35= value; + break; + case(36): + float36= value; + break; + case(37): + float37= value; + break; + case(38): + float38= value; + break; + case(39): + float39= value; + break; + case(40): + float40= value; + break; + case(41): + float41= value; + break; + case(42): + float42= value; + break; + case(43): + float43= value; + break; + case(44): + float44= value; + break; + case(45): + float45= value; + break; + case(46): + float46= value; + break; + case(47): + float47= value; + break; + case(48): + float48= value; + break; + case(49): + float49= value; + break; + case(50): + float50= value; + break; + case(52): + float52= value; + break; + case(53): + float53= value; + break; + case(54): + float54= value; + break; + case(55): + float55= value; + break; + case(56): + float56= value; + break; + case(57): + float57= value; + break; + case(58): + float58= value; + break; + case(59): + float59= value; + break; + case(60): + float60= value; + break; + case(62): + float62= value; + break; + case(64): + float64= value; + break; + case(65): + float65= value; + break; + case(66): + float66= value; + break; + case(67): + float67= value; + break; + case(68): + float68= value; + break; + case(69): + float69= value; + break; + case(71): + float71= value; + break; + case(72): + float72= value; + break; + case(73): + float73= value; + break; + case(74): + float74= value; + break; + case(75): + float75= value; + break; + case(76): + float76= value; + break; + case(77): + float77= value; + break; + case(78): + float78= value; + break; + case(79): + float79= value; + break; + case(80): + float80= value; + break; + case(81): + float81= value; + break; + case(82): + float82= value; + break; + case(83): + float83= value; + break; + case(84): + float84= value; + break; + case(85): + float85= value; + break; + case(86): + float86= value; + break; + case(88): + float88= value; + break; + case(89): + float89= value; + break; + case(90): + float90= value; + break; + case(91): + float91= value; + break; + case(92): + float92= value; + break; + case(93): + float93= value; + break; + case(94): + float94= value; + break; + case(95): + float95= value; + break; + case(96): + float96= value; + break; + case(98): + float98= value; + break; + case(100): + float100= value; + break; + case(101): + float101= value; + break; + case(102): + float102= value; + break; + case(103): + float103= value; + break; + case(104): + float104= value; + break; + case(105): + float105= value; + break; + case(107): + float107= value; + break; + case(108): + float108= value; + break; + case(109): + float109= value; + break; + case(110): + float110= value; + break; + case(111): + float111= value; + break; + case(112): + float112= value; + break; + case(113): + float113= value; + break; + case(114): + float114= value; + break; + case(115): + float115= value; + break; + case(116): + float116= value; + break; + case(117): + float117= value; + break; + case(118): + float118= value; + break; + case(119): + float119= value; + break; + case(120): + float120= value; + break; + case(121): + float121= value; + break; + case(122): + float122= value; + break; + case(124): + float124= value; + break; + case(125): + float125= value; + break; + case(126): + float126= value; + break; + case(127): + float127= value; + break; + case(128): + float128= value; + break; + case(129): + float129= value; + break; + case(130): + float130= value; + break; + case(131): + float131= value; + break; + case(132): + float132= value; + break; + case(134): + float134= value; + break; + case(136): + float136= value; + break; + case(137): + float137= value; + break; + case(138): + float138= value; + break; + case(139): + float139= value; + break; + case(140): + float140= value; + break; + case(141): + float141= value; + break; + case(143): + float143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitiveint.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitiveint.java index f5251180f..b61a2cfce 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitiveint.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitiveint.java @@ -5,21 +5,21 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -public class FieldsOfPrimitiveint { +public class FieldsOfPrimitiveint { public int identifier; private int int0; private int int1; @@ -48,14 +48,14 @@ public class FieldsOfPrimitiveint { private static transient int int24; private static final int int25 = 5; private static volatile int int26; - private final transient int int27 = 5; + private transient final int int27 = 5; private transient volatile int int28; private transient volatile int int29; private transient volatile int int30; private transient volatile int int31; private transient volatile int int32; private transient volatile int int33; - private static final transient int int34 = 5; + private static transient final int int34 = 5; private static transient volatile int int35; public int int36; public int int37; @@ -84,14 +84,14 @@ public class FieldsOfPrimitiveint { public static transient int int60; public static final int int61 = 5; public static volatile int int62; - public final transient int int63 = 5; + public transient final int int63 = 5; public transient volatile int int64; public transient volatile int int65; public transient volatile int int66; public transient volatile int int67; public transient volatile int int68; public transient volatile int int69; - public static final transient int int70 = 5; + public static transient final int int70 = 5; public static transient volatile int int71; protected int int72; protected int int73; @@ -120,14 +120,14 @@ public class FieldsOfPrimitiveint { protected static transient int int96; protected static final int int97 = 5; protected static volatile int int98; - protected final transient int int99 = 5; + protected transient final int int99 = 5; protected transient volatile int int100; protected transient volatile int int101; protected transient volatile int int102; protected transient volatile int int103; protected transient volatile int int104; protected transient volatile int int105; - protected static final transient int int106 = 5; + protected static transient final int int106 = 5; protected static transient volatile int int107; int int108; int int109; @@ -156,936 +156,935 @@ public class FieldsOfPrimitiveint { static transient int int132; static final int int133 = 5; static volatile int int134; - final transient int int135 = 5; + transient final int int135 = 5; transient volatile int int136; transient volatile int int137; transient volatile int int138; transient volatile int int139; transient volatile int int140; transient volatile int int141; - static final transient int int142 = 5; + static transient final int int142 = 5; static transient volatile int int143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private int int0", - "embedded= true private int int1", - "embedded= false private int int2", - "persistence-modifier= none private int int3", - "persistence-modifier= persistent private int int4", - "persistence-modifier= persistent embedded= true private int int5", - "persistence-modifier= persistent embedded= false private int int6", - "persistence-modifier= transactional private int int7", - "private static int int8", - "private transient int int9", - "persistence-modifier= none private transient int int10", - "persistence-modifier= persistent private transient int int11", - "persistence-modifier= persistent embedded= true private transient int int12", - "persistence-modifier= persistent embedded= false private transient int int13", - "persistence-modifier= transactional private transient int int14", - "private final int int15", - "private volatile int int16", - "embedded= true private volatile int int17", - "embedded= false private volatile int int18", - "persistence-modifier= none private volatile int int19", - "persistence-modifier= persistent private volatile int int20", - "persistence-modifier= persistent embedded= true private volatile int int21", - "persistence-modifier= persistent embedded= false private volatile int int22", - "persistence-modifier= transactional private volatile int int23", - "private static transient int int24", - "private static final int int25", - "private static volatile int int26", - "private transient final int int27", - "private transient volatile int int28", - "persistence-modifier= none private transient volatile int int29", - "persistence-modifier= persistent private transient volatile int int30", - "persistence-modifier= persistent embedded= true private transient volatile int int31", - "persistence-modifier= persistent embedded= false private transient volatile int int32", - "persistence-modifier= transactional private transient volatile int int33", - "private static transient final int int34", - "private static transient volatile int int35", - "public int int36", - "embedded= true public int int37", - "embedded= false public int int38", - "persistence-modifier= none public int int39", - "persistence-modifier= persistent public int int40", - "persistence-modifier= persistent embedded= true public int int41", - "persistence-modifier= persistent embedded= false public int int42", - "persistence-modifier= transactional public int int43", - "public static int int44", - "public transient int int45", - "persistence-modifier= none public transient int int46", - "persistence-modifier= persistent public transient int int47", - "persistence-modifier= persistent embedded= true public transient int int48", - "persistence-modifier= persistent embedded= false public transient int int49", - "persistence-modifier= transactional public transient int int50", - "public final int int51", - "public volatile int int52", - "embedded= true public volatile int int53", - "embedded= false public volatile int int54", - "persistence-modifier= none public volatile int int55", - "persistence-modifier= persistent public volatile int int56", - "persistence-modifier= persistent embedded= true public volatile int int57", - "persistence-modifier= persistent embedded= false public volatile int int58", - "persistence-modifier= transactional public volatile int int59", - "public static transient int int60", - "public static final int int61", - "public static volatile int int62", - "public transient final int int63", - "public transient volatile int int64", - "persistence-modifier= none public transient volatile int int65", - "persistence-modifier= persistent public transient volatile int int66", - "persistence-modifier= persistent embedded= true public transient volatile int int67", - "persistence-modifier= persistent embedded= false public transient volatile int int68", - "persistence-modifier= transactional public transient volatile int int69", - "public static transient final int int70", - "public static transient volatile int int71", - "protected int int72", - "embedded= true protected int int73", - "embedded= false protected int int74", - "persistence-modifier= none protected int int75", - "persistence-modifier= persistent protected int int76", - "persistence-modifier= persistent embedded= true protected int int77", - "persistence-modifier= persistent embedded= false protected int int78", - "persistence-modifier= transactional protected int int79", - "protected static int int80", - "protected transient int int81", - "persistence-modifier= none protected transient int int82", - "persistence-modifier= persistent protected transient int int83", - "persistence-modifier= persistent embedded= true protected transient int int84", - "persistence-modifier= persistent embedded= false protected transient int int85", - "persistence-modifier= transactional protected transient int int86", - "protected final int int87", - "protected volatile int int88", - "embedded= true protected volatile int int89", - "embedded= false protected volatile int int90", - "persistence-modifier= none protected volatile int int91", - "persistence-modifier= persistent protected volatile int int92", - "persistence-modifier= persistent embedded= true protected volatile int int93", - "persistence-modifier= persistent embedded= false protected volatile int int94", - "persistence-modifier= transactional protected volatile int int95", - "protected static transient int int96", - "protected static final int int97", - "protected static volatile int int98", - "protected transient final int int99", - "protected transient volatile int int100", - "persistence-modifier= none protected transient volatile int int101", - "persistence-modifier= persistent protected transient volatile int int102", - "persistence-modifier= persistent embedded= true protected transient volatile int int103", - "persistence-modifier= persistent embedded= false protected transient volatile int int104", - "persistence-modifier= transactional protected transient volatile int int105", - "protected static transient final int int106", - "protected static transient volatile int int107", - "int int108", - "embedded= true int int109", - "embedded= false int int110", - "persistence-modifier= none int int111", - "persistence-modifier= persistent int int112", - "persistence-modifier= persistent embedded= true int int113", - "persistence-modifier= persistent embedded= false int int114", - "persistence-modifier= transactional int int115", - "static int int116", - "transient int int117", - "persistence-modifier= none transient int int118", - "persistence-modifier= persistent transient int int119", - "persistence-modifier= persistent embedded= true transient int int120", - "persistence-modifier= persistent embedded= false transient int int121", - "persistence-modifier= transactional transient int int122", - "final int int123", - "volatile int int124", - "embedded= true volatile int int125", - "embedded= false volatile int int126", - "persistence-modifier= none volatile int int127", - "persistence-modifier= persistent volatile int int128", - "persistence-modifier= persistent embedded= true volatile int int129", - "persistence-modifier= persistent embedded= false volatile int int130", - "persistence-modifier= transactional volatile int int131", - "static transient int int132", - "static final int int133", - "static volatile int int134", - "transient final int int135", - "transient volatile int int136", - "persistence-modifier= none transient volatile int int137", - "persistence-modifier= persistent transient volatile int int138", - "persistence-modifier= persistent embedded= true transient volatile int int139", - "persistence-modifier= persistent embedded= false transient volatile int int140", - "persistence-modifier= transactional transient volatile int int141", - "static transient final int int142", - "static transient volatile int int143" + public static final String [] fieldSpecs = { + "private int int0", + "embedded= true private int int1", + "embedded= false private int int2", + "persistence-modifier= none private int int3", + "persistence-modifier= persistent private int int4", + "persistence-modifier= persistent embedded= true private int int5", + "persistence-modifier= persistent embedded= false private int int6", + "persistence-modifier= transactional private int int7", + "private static int int8", + "private transient int int9", + "persistence-modifier= none private transient int int10", + "persistence-modifier= persistent private transient int int11", + "persistence-modifier= persistent embedded= true private transient int int12", + "persistence-modifier= persistent embedded= false private transient int int13", + "persistence-modifier= transactional private transient int int14", + "private final int int15", + "private volatile int int16", + "embedded= true private volatile int int17", + "embedded= false private volatile int int18", + "persistence-modifier= none private volatile int int19", + "persistence-modifier= persistent private volatile int int20", + "persistence-modifier= persistent embedded= true private volatile int int21", + "persistence-modifier= persistent embedded= false private volatile int int22", + "persistence-modifier= transactional private volatile int int23", + "private static transient int int24", + "private static final int int25", + "private static volatile int int26", + "private transient final int int27", + "private transient volatile int int28", + "persistence-modifier= none private transient volatile int int29", + "persistence-modifier= persistent private transient volatile int int30", + "persistence-modifier= persistent embedded= true private transient volatile int int31", + "persistence-modifier= persistent embedded= false private transient volatile int int32", + "persistence-modifier= transactional private transient volatile int int33", + "private static transient final int int34", + "private static transient volatile int int35", + "public int int36", + "embedded= true public int int37", + "embedded= false public int int38", + "persistence-modifier= none public int int39", + "persistence-modifier= persistent public int int40", + "persistence-modifier= persistent embedded= true public int int41", + "persistence-modifier= persistent embedded= false public int int42", + "persistence-modifier= transactional public int int43", + "public static int int44", + "public transient int int45", + "persistence-modifier= none public transient int int46", + "persistence-modifier= persistent public transient int int47", + "persistence-modifier= persistent embedded= true public transient int int48", + "persistence-modifier= persistent embedded= false public transient int int49", + "persistence-modifier= transactional public transient int int50", + "public final int int51", + "public volatile int int52", + "embedded= true public volatile int int53", + "embedded= false public volatile int int54", + "persistence-modifier= none public volatile int int55", + "persistence-modifier= persistent public volatile int int56", + "persistence-modifier= persistent embedded= true public volatile int int57", + "persistence-modifier= persistent embedded= false public volatile int int58", + "persistence-modifier= transactional public volatile int int59", + "public static transient int int60", + "public static final int int61", + "public static volatile int int62", + "public transient final int int63", + "public transient volatile int int64", + "persistence-modifier= none public transient volatile int int65", + "persistence-modifier= persistent public transient volatile int int66", + "persistence-modifier= persistent embedded= true public transient volatile int int67", + "persistence-modifier= persistent embedded= false public transient volatile int int68", + "persistence-modifier= transactional public transient volatile int int69", + "public static transient final int int70", + "public static transient volatile int int71", + "protected int int72", + "embedded= true protected int int73", + "embedded= false protected int int74", + "persistence-modifier= none protected int int75", + "persistence-modifier= persistent protected int int76", + "persistence-modifier= persistent embedded= true protected int int77", + "persistence-modifier= persistent embedded= false protected int int78", + "persistence-modifier= transactional protected int int79", + "protected static int int80", + "protected transient int int81", + "persistence-modifier= none protected transient int int82", + "persistence-modifier= persistent protected transient int int83", + "persistence-modifier= persistent embedded= true protected transient int int84", + "persistence-modifier= persistent embedded= false protected transient int int85", + "persistence-modifier= transactional protected transient int int86", + "protected final int int87", + "protected volatile int int88", + "embedded= true protected volatile int int89", + "embedded= false protected volatile int int90", + "persistence-modifier= none protected volatile int int91", + "persistence-modifier= persistent protected volatile int int92", + "persistence-modifier= persistent embedded= true protected volatile int int93", + "persistence-modifier= persistent embedded= false protected volatile int int94", + "persistence-modifier= transactional protected volatile int int95", + "protected static transient int int96", + "protected static final int int97", + "protected static volatile int int98", + "protected transient final int int99", + "protected transient volatile int int100", + "persistence-modifier= none protected transient volatile int int101", + "persistence-modifier= persistent protected transient volatile int int102", + "persistence-modifier= persistent embedded= true protected transient volatile int int103", + "persistence-modifier= persistent embedded= false protected transient volatile int int104", + "persistence-modifier= transactional protected transient volatile int int105", + "protected static transient final int int106", + "protected static transient volatile int int107", + "int int108", + "embedded= true int int109", + "embedded= false int int110", + "persistence-modifier= none int int111", + "persistence-modifier= persistent int int112", + "persistence-modifier= persistent embedded= true int int113", + "persistence-modifier= persistent embedded= false int int114", + "persistence-modifier= transactional int int115", + "static int int116", + "transient int int117", + "persistence-modifier= none transient int int118", + "persistence-modifier= persistent transient int int119", + "persistence-modifier= persistent embedded= true transient int int120", + "persistence-modifier= persistent embedded= false transient int int121", + "persistence-modifier= transactional transient int int122", + "final int int123", + "volatile int int124", + "embedded= true volatile int int125", + "embedded= false volatile int int126", + "persistence-modifier= none volatile int int127", + "persistence-modifier= persistent volatile int int128", + "persistence-modifier= persistent embedded= true volatile int int129", + "persistence-modifier= persistent embedded= false volatile int int130", + "persistence-modifier= transactional volatile int int131", + "static transient int int132", + "static final int int133", + "static volatile int int134", + "transient final int int135", + "transient volatile int int136", + "persistence-modifier= none transient volatile int int137", + "persistence-modifier= persistent transient volatile int int138", + "persistence-modifier= persistent embedded= true transient volatile int int139", + "persistence-modifier= persistent embedded= false transient volatile int int140", + "persistence-modifier= transactional transient volatile int int141", + "static transient final int int142", + "static transient volatile int int143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public int get(int index) { - switch (index) { - case (0): + public int get(int index) + { + switch (index) + { + case(0): return int0; - case (1): + case(1): return int1; - case (2): + case(2): return int2; - case (3): + case(3): return int3; - case (4): + case(4): return int4; - case (5): + case(5): return int5; - case (6): + case(6): return int6; - case (7): + case(7): return int7; - case (8): + case(8): return int8; - case (9): + case(9): return int9; - case (10): + case(10): return int10; - case (11): + case(11): return int11; - case (12): + case(12): return int12; - case (13): + case(13): return int13; - case (14): + case(14): return int14; - case (15): + case(15): return int15; - case (16): + case(16): return int16; - case (17): + case(17): return int17; - case (18): + case(18): return int18; - case (19): + case(19): return int19; - case (20): + case(20): return int20; - case (21): + case(21): return int21; - case (22): + case(22): return int22; - case (23): + case(23): return int23; - case (24): + case(24): return int24; - case (25): + case(25): return int25; - case (26): + case(26): return int26; - case (27): + case(27): return int27; - case (28): + case(28): return int28; - case (29): + case(29): return int29; - case (30): + case(30): return int30; - case (31): + case(31): return int31; - case (32): + case(32): return int32; - case (33): + case(33): return int33; - case (34): + case(34): return int34; - case (35): + case(35): return int35; - case (36): + case(36): return int36; - case (37): + case(37): return int37; - case (38): + case(38): return int38; - case (39): + case(39): return int39; - case (40): + case(40): return int40; - case (41): + case(41): return int41; - case (42): + case(42): return int42; - case (43): + case(43): return int43; - case (44): + case(44): return int44; - case (45): + case(45): return int45; - case (46): + case(46): return int46; - case (47): + case(47): return int47; - case (48): + case(48): return int48; - case (49): + case(49): return int49; - case (50): + case(50): return int50; - case (51): + case(51): return int51; - case (52): + case(52): return int52; - case (53): + case(53): return int53; - case (54): + case(54): return int54; - case (55): + case(55): return int55; - case (56): + case(56): return int56; - case (57): + case(57): return int57; - case (58): + case(58): return int58; - case (59): + case(59): return int59; - case (60): + case(60): return int60; - case (61): + case(61): return int61; - case (62): + case(62): return int62; - case (63): + case(63): return int63; - case (64): + case(64): return int64; - case (65): + case(65): return int65; - case (66): + case(66): return int66; - case (67): + case(67): return int67; - case (68): + case(68): return int68; - case (69): + case(69): return int69; - case (70): + case(70): return int70; - case (71): + case(71): return int71; - case (72): + case(72): return int72; - case (73): + case(73): return int73; - case (74): + case(74): return int74; - case (75): + case(75): return int75; - case (76): + case(76): return int76; - case (77): + case(77): return int77; - case (78): + case(78): return int78; - case (79): + case(79): return int79; - case (80): + case(80): return int80; - case (81): + case(81): return int81; - case (82): + case(82): return int82; - case (83): + case(83): return int83; - case (84): + case(84): return int84; - case (85): + case(85): return int85; - case (86): + case(86): return int86; - case (87): + case(87): return int87; - case (88): + case(88): return int88; - case (89): + case(89): return int89; - case (90): + case(90): return int90; - case (91): + case(91): return int91; - case (92): + case(92): return int92; - case (93): + case(93): return int93; - case (94): + case(94): return int94; - case (95): + case(95): return int95; - case (96): + case(96): return int96; - case (97): + case(97): return int97; - case (98): + case(98): return int98; - case (99): + case(99): return int99; - case (100): + case(100): return int100; - case (101): + case(101): return int101; - case (102): + case(102): return int102; - case (103): + case(103): return int103; - case (104): + case(104): return int104; - case (105): + case(105): return int105; - case (106): + case(106): return int106; - case (107): + case(107): return int107; - case (108): + case(108): return int108; - case (109): + case(109): return int109; - case (110): + case(110): return int110; - case (111): + case(111): return int111; - case (112): + case(112): return int112; - case (113): + case(113): return int113; - case (114): + case(114): return int114; - case (115): + case(115): return int115; - case (116): + case(116): return int116; - case (117): + case(117): return int117; - case (118): + case(118): return int118; - case (119): + case(119): return int119; - case (120): + case(120): return int120; - case (121): + case(121): return int121; - case (122): + case(122): return int122; - case (123): + case(123): return int123; - case (124): + case(124): return int124; - case (125): + case(125): return int125; - case (126): + case(126): return int126; - case (127): + case(127): return int127; - case (128): + case(128): return int128; - case (129): + case(129): return int129; - case (130): + case(130): return int130; - case (131): + case(131): return int131; - case (132): + case(132): return int132; - case (133): + case(133): return int133; - case (134): + case(134): return int134; - case (135): + case(135): return int135; - case (136): + case(136): return int136; - case (137): + case(137): return int137; - case (138): + case(138): return int138; - case (139): + case(139): return int139; - case (140): + case(140): return int140; - case (141): + case(141): return int141; - case (142): + case(142): return int142; - case (143): + case(143): return int143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, int value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - int0 = value; - break; - case (1): - int1 = value; - break; - case (2): - int2 = value; - break; - case (3): - int3 = value; - break; - case (4): - int4 = value; - break; - case (5): - int5 = value; - break; - case (6): - int6 = value; - break; - case (7): - int7 = value; - break; - case (8): - int8 = value; - break; - case (9): - int9 = value; - break; - case (10): - int10 = value; - break; - case (11): - int11 = value; - break; - case (12): - int12 = value; - break; - case (13): - int13 = value; - break; - case (14): - int14 = value; - break; - case (16): - int16 = value; - break; - case (17): - int17 = value; - break; - case (18): - int18 = value; - break; - case (19): - int19 = value; - break; - case (20): - int20 = value; - break; - case (21): - int21 = value; - break; - case (22): - int22 = value; - break; - case (23): - int23 = value; - break; - case (24): - int24 = value; - break; - case (26): - int26 = value; - break; - case (28): - int28 = value; - break; - case (29): - int29 = value; - break; - case (30): - int30 = value; - break; - case (31): - int31 = value; - break; - case (32): - int32 = value; - break; - case (33): - int33 = value; - break; - case (35): - int35 = value; - break; - case (36): - int36 = value; - break; - case (37): - int37 = value; - break; - case (38): - int38 = value; - break; - case (39): - int39 = value; - break; - case (40): - int40 = value; - break; - case (41): - int41 = value; - break; - case (42): - int42 = value; - break; - case (43): - int43 = value; - break; - case (44): - int44 = value; - break; - case (45): - int45 = value; - break; - case (46): - int46 = value; - break; - case (47): - int47 = value; - break; - case (48): - int48 = value; - break; - case (49): - int49 = value; - break; - case (50): - int50 = value; - break; - case (52): - int52 = value; - break; - case (53): - int53 = value; - break; - case (54): - int54 = value; - break; - case (55): - int55 = value; - break; - case (56): - int56 = value; - break; - case (57): - int57 = value; - break; - case (58): - int58 = value; - break; - case (59): - int59 = value; - break; - case (60): - int60 = value; - break; - case (62): - int62 = value; - break; - case (64): - int64 = value; - break; - case (65): - int65 = value; - break; - case (66): - int66 = value; - break; - case (67): - int67 = value; - break; - case (68): - int68 = value; - break; - case (69): - int69 = value; - break; - case (71): - int71 = value; - break; - case (72): - int72 = value; - break; - case (73): - int73 = value; - break; - case (74): - int74 = value; - break; - case (75): - int75 = value; - break; - case (76): - int76 = value; - break; - case (77): - int77 = value; - break; - case (78): - int78 = value; - break; - case (79): - int79 = value; - break; - case (80): - int80 = value; - break; - case (81): - int81 = value; - break; - case (82): - int82 = value; - break; - case (83): - int83 = value; - break; - case (84): - int84 = value; - break; - case (85): - int85 = value; - break; - case (86): - int86 = value; - break; - case (88): - int88 = value; - break; - case (89): - int89 = value; - break; - case (90): - int90 = value; - break; - case (91): - int91 = value; - break; - case (92): - int92 = value; - break; - case (93): - int93 = value; - break; - case (94): - int94 = value; - break; - case (95): - int95 = value; - break; - case (96): - int96 = value; - break; - case (98): - int98 = value; - break; - case (100): - int100 = value; - break; - case (101): - int101 = value; - break; - case (102): - int102 = value; - break; - case (103): - int103 = value; - break; - case (104): - int104 = value; - break; - case (105): - int105 = value; - break; - case (107): - int107 = value; - break; - case (108): - int108 = value; - break; - case (109): - int109 = value; - break; - case (110): - int110 = value; - break; - case (111): - int111 = value; - break; - case (112): - int112 = value; - break; - case (113): - int113 = value; - break; - case (114): - int114 = value; - break; - case (115): - int115 = value; - break; - case (116): - int116 = value; - break; - case (117): - int117 = value; - break; - case (118): - int118 = value; - break; - case (119): - int119 = value; - break; - case (120): - int120 = value; - break; - case (121): - int121 = value; - break; - case (122): - int122 = value; - break; - case (124): - int124 = value; - break; - case (125): - int125 = value; - break; - case (126): - int126 = value; - break; - case (127): - int127 = value; - break; - case (128): - int128 = value; - break; - case (129): - int129 = value; - break; - case (130): - int130 = value; - break; - case (131): - int131 = value; - break; - case (132): - int132 = value; - break; - case (134): - int134 = value; - break; - case (136): - int136 = value; - break; - case (137): - int137 = value; - break; - case (138): - int138 = value; - break; - case (139): - int139 = value; - break; - case (140): - int140 = value; - break; - case (141): - int141 = value; - break; - case (143): - int143 = value; - break; + public boolean set(int index,int value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + int0= value; + break; + case(1): + int1= value; + break; + case(2): + int2= value; + break; + case(3): + int3= value; + break; + case(4): + int4= value; + break; + case(5): + int5= value; + break; + case(6): + int6= value; + break; + case(7): + int7= value; + break; + case(8): + int8= value; + break; + case(9): + int9= value; + break; + case(10): + int10= value; + break; + case(11): + int11= value; + break; + case(12): + int12= value; + break; + case(13): + int13= value; + break; + case(14): + int14= value; + break; + case(16): + int16= value; + break; + case(17): + int17= value; + break; + case(18): + int18= value; + break; + case(19): + int19= value; + break; + case(20): + int20= value; + break; + case(21): + int21= value; + break; + case(22): + int22= value; + break; + case(23): + int23= value; + break; + case(24): + int24= value; + break; + case(26): + int26= value; + break; + case(28): + int28= value; + break; + case(29): + int29= value; + break; + case(30): + int30= value; + break; + case(31): + int31= value; + break; + case(32): + int32= value; + break; + case(33): + int33= value; + break; + case(35): + int35= value; + break; + case(36): + int36= value; + break; + case(37): + int37= value; + break; + case(38): + int38= value; + break; + case(39): + int39= value; + break; + case(40): + int40= value; + break; + case(41): + int41= value; + break; + case(42): + int42= value; + break; + case(43): + int43= value; + break; + case(44): + int44= value; + break; + case(45): + int45= value; + break; + case(46): + int46= value; + break; + case(47): + int47= value; + break; + case(48): + int48= value; + break; + case(49): + int49= value; + break; + case(50): + int50= value; + break; + case(52): + int52= value; + break; + case(53): + int53= value; + break; + case(54): + int54= value; + break; + case(55): + int55= value; + break; + case(56): + int56= value; + break; + case(57): + int57= value; + break; + case(58): + int58= value; + break; + case(59): + int59= value; + break; + case(60): + int60= value; + break; + case(62): + int62= value; + break; + case(64): + int64= value; + break; + case(65): + int65= value; + break; + case(66): + int66= value; + break; + case(67): + int67= value; + break; + case(68): + int68= value; + break; + case(69): + int69= value; + break; + case(71): + int71= value; + break; + case(72): + int72= value; + break; + case(73): + int73= value; + break; + case(74): + int74= value; + break; + case(75): + int75= value; + break; + case(76): + int76= value; + break; + case(77): + int77= value; + break; + case(78): + int78= value; + break; + case(79): + int79= value; + break; + case(80): + int80= value; + break; + case(81): + int81= value; + break; + case(82): + int82= value; + break; + case(83): + int83= value; + break; + case(84): + int84= value; + break; + case(85): + int85= value; + break; + case(86): + int86= value; + break; + case(88): + int88= value; + break; + case(89): + int89= value; + break; + case(90): + int90= value; + break; + case(91): + int91= value; + break; + case(92): + int92= value; + break; + case(93): + int93= value; + break; + case(94): + int94= value; + break; + case(95): + int95= value; + break; + case(96): + int96= value; + break; + case(98): + int98= value; + break; + case(100): + int100= value; + break; + case(101): + int101= value; + break; + case(102): + int102= value; + break; + case(103): + int103= value; + break; + case(104): + int104= value; + break; + case(105): + int105= value; + break; + case(107): + int107= value; + break; + case(108): + int108= value; + break; + case(109): + int109= value; + break; + case(110): + int110= value; + break; + case(111): + int111= value; + break; + case(112): + int112= value; + break; + case(113): + int113= value; + break; + case(114): + int114= value; + break; + case(115): + int115= value; + break; + case(116): + int116= value; + break; + case(117): + int117= value; + break; + case(118): + int118= value; + break; + case(119): + int119= value; + break; + case(120): + int120= value; + break; + case(121): + int121= value; + break; + case(122): + int122= value; + break; + case(124): + int124= value; + break; + case(125): + int125= value; + break; + case(126): + int126= value; + break; + case(127): + int127= value; + break; + case(128): + int128= value; + break; + case(129): + int129= value; + break; + case(130): + int130= value; + break; + case(131): + int131= value; + break; + case(132): + int132= value; + break; + case(134): + int134= value; + break; + case(136): + int136= value; + break; + case(137): + int137= value; + break; + case(138): + int138= value; + break; + case(139): + int139= value; + break; + case(140): + int140= value; + break; + case(141): + int141= value; + break; + case(143): + int143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitivelong.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitivelong.java index 16c640087..0c5330fcd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitivelong.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitivelong.java @@ -5,21 +5,21 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -public class FieldsOfPrimitivelong { +public class FieldsOfPrimitivelong { public int identifier; private long long0; private long long1; @@ -48,14 +48,14 @@ public class FieldsOfPrimitivelong { private static transient long long24; private static final long long25 = 5; private static volatile long long26; - private final transient long long27 = 5; + private transient final long long27 = 5; private transient volatile long long28; private transient volatile long long29; private transient volatile long long30; private transient volatile long long31; private transient volatile long long32; private transient volatile long long33; - private static final transient long long34 = 5; + private static transient final long long34 = 5; private static transient volatile long long35; public long long36; public long long37; @@ -84,14 +84,14 @@ public class FieldsOfPrimitivelong { public static transient long long60; public static final long long61 = 5; public static volatile long long62; - public final transient long long63 = 5; + public transient final long long63 = 5; public transient volatile long long64; public transient volatile long long65; public transient volatile long long66; public transient volatile long long67; public transient volatile long long68; public transient volatile long long69; - public static final transient long long70 = 5; + public static transient final long long70 = 5; public static transient volatile long long71; protected long long72; protected long long73; @@ -120,14 +120,14 @@ public class FieldsOfPrimitivelong { protected static transient long long96; protected static final long long97 = 5; protected static volatile long long98; - protected final transient long long99 = 5; + protected transient final long long99 = 5; protected transient volatile long long100; protected transient volatile long long101; protected transient volatile long long102; protected transient volatile long long103; protected transient volatile long long104; protected transient volatile long long105; - protected static final transient long long106 = 5; + protected static transient final long long106 = 5; protected static transient volatile long long107; long long108; long long109; @@ -156,936 +156,934 @@ public class FieldsOfPrimitivelong { static transient long long132; static final long long133 = 5; static volatile long long134; - final transient long long135 = 5; + transient final long long135 = 5; transient volatile long long136; transient volatile long long137; transient volatile long long138; transient volatile long long139; transient volatile long long140; transient volatile long long141; - static final transient long long142 = 5; + static transient final long long142 = 5; static transient volatile long long143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private long long0", - "embedded= true private long long1", - "embedded= false private long long2", - "persistence-modifier= none private long long3", - "persistence-modifier= persistent private long long4", - "persistence-modifier= persistent embedded= true private long long5", - "persistence-modifier= persistent embedded= false private long long6", - "persistence-modifier= transactional private long long7", - "private static long long8", - "private transient long long9", - "persistence-modifier= none private transient long long10", - "persistence-modifier= persistent private transient long long11", - "persistence-modifier= persistent embedded= true private transient long long12", - "persistence-modifier= persistent embedded= false private transient long long13", - "persistence-modifier= transactional private transient long long14", - "private final long long15", - "private volatile long long16", - "embedded= true private volatile long long17", - "embedded= false private volatile long long18", - "persistence-modifier= none private volatile long long19", - "persistence-modifier= persistent private volatile long long20", - "persistence-modifier= persistent embedded= true private volatile long long21", - "persistence-modifier= persistent embedded= false private volatile long long22", - "persistence-modifier= transactional private volatile long long23", - "private static transient long long24", - "private static final long long25", - "private static volatile long long26", - "private transient final long long27", - "private transient volatile long long28", - "persistence-modifier= none private transient volatile long long29", - "persistence-modifier= persistent private transient volatile long long30", - "persistence-modifier= persistent embedded= true private transient volatile long long31", - "persistence-modifier= persistent embedded= false private transient volatile long long32", - "persistence-modifier= transactional private transient volatile long long33", - "private static transient final long long34", - "private static transient volatile long long35", - "public long long36", - "embedded= true public long long37", - "embedded= false public long long38", - "persistence-modifier= none public long long39", - "persistence-modifier= persistent public long long40", - "persistence-modifier= persistent embedded= true public long long41", - "persistence-modifier= persistent embedded= false public long long42", - "persistence-modifier= transactional public long long43", - "public static long long44", - "public transient long long45", - "persistence-modifier= none public transient long long46", - "persistence-modifier= persistent public transient long long47", - "persistence-modifier= persistent embedded= true public transient long long48", - "persistence-modifier= persistent embedded= false public transient long long49", - "persistence-modifier= transactional public transient long long50", - "public final long long51", - "public volatile long long52", - "embedded= true public volatile long long53", - "embedded= false public volatile long long54", - "persistence-modifier= none public volatile long long55", - "persistence-modifier= persistent public volatile long long56", - "persistence-modifier= persistent embedded= true public volatile long long57", - "persistence-modifier= persistent embedded= false public volatile long long58", - "persistence-modifier= transactional public volatile long long59", - "public static transient long long60", - "public static final long long61", - "public static volatile long long62", - "public transient final long long63", - "public transient volatile long long64", - "persistence-modifier= none public transient volatile long long65", - "persistence-modifier= persistent public transient volatile long long66", - "persistence-modifier= persistent embedded= true public transient volatile long long67", - "persistence-modifier= persistent embedded= false public transient volatile long long68", - "persistence-modifier= transactional public transient volatile long long69", - "public static transient final long long70", - "public static transient volatile long long71", - "protected long long72", - "embedded= true protected long long73", - "embedded= false protected long long74", - "persistence-modifier= none protected long long75", - "persistence-modifier= persistent protected long long76", - "persistence-modifier= persistent embedded= true protected long long77", - "persistence-modifier= persistent embedded= false protected long long78", - "persistence-modifier= transactional protected long long79", - "protected static long long80", - "protected transient long long81", - "persistence-modifier= none protected transient long long82", - "persistence-modifier= persistent protected transient long long83", - "persistence-modifier= persistent embedded= true protected transient long long84", - "persistence-modifier= persistent embedded= false protected transient long long85", - "persistence-modifier= transactional protected transient long long86", - "protected final long long87", - "protected volatile long long88", - "embedded= true protected volatile long long89", - "embedded= false protected volatile long long90", - "persistence-modifier= none protected volatile long long91", - "persistence-modifier= persistent protected volatile long long92", - "persistence-modifier= persistent embedded= true protected volatile long long93", - "persistence-modifier= persistent embedded= false protected volatile long long94", - "persistence-modifier= transactional protected volatile long long95", - "protected static transient long long96", - "protected static final long long97", - "protected static volatile long long98", - "protected transient final long long99", - "protected transient volatile long long100", - "persistence-modifier= none protected transient volatile long long101", - "persistence-modifier= persistent protected transient volatile long long102", - "persistence-modifier= persistent embedded= true protected transient volatile long long103", - "persistence-modifier= persistent embedded= false protected transient volatile long long104", - "persistence-modifier= transactional protected transient volatile long long105", - "protected static transient final long long106", - "protected static transient volatile long long107", - "long long108", - "embedded= true long long109", - "embedded= false long long110", - "persistence-modifier= none long long111", - "persistence-modifier= persistent long long112", - "persistence-modifier= persistent embedded= true long long113", - "persistence-modifier= persistent embedded= false long long114", - "persistence-modifier= transactional long long115", - "static long long116", - "transient long long117", - "persistence-modifier= none transient long long118", - "persistence-modifier= persistent transient long long119", - "persistence-modifier= persistent embedded= true transient long long120", - "persistence-modifier= persistent embedded= false transient long long121", - "persistence-modifier= transactional transient long long122", - "final long long123", - "volatile long long124", - "embedded= true volatile long long125", - "embedded= false volatile long long126", - "persistence-modifier= none volatile long long127", - "persistence-modifier= persistent volatile long long128", - "persistence-modifier= persistent embedded= true volatile long long129", - "persistence-modifier= persistent embedded= false volatile long long130", - "persistence-modifier= transactional volatile long long131", - "static transient long long132", - "static final long long133", - "static volatile long long134", - "transient final long long135", - "transient volatile long long136", - "persistence-modifier= none transient volatile long long137", - "persistence-modifier= persistent transient volatile long long138", - "persistence-modifier= persistent embedded= true transient volatile long long139", - "persistence-modifier= persistent embedded= false transient volatile long long140", - "persistence-modifier= transactional transient volatile long long141", - "static transient final long long142", - "static transient volatile long long143" + public static final String [] fieldSpecs = { + "private long long0", + "embedded= true private long long1", + "embedded= false private long long2", + "persistence-modifier= none private long long3", + "persistence-modifier= persistent private long long4", + "persistence-modifier= persistent embedded= true private long long5", + "persistence-modifier= persistent embedded= false private long long6", + "persistence-modifier= transactional private long long7", + "private static long long8", + "private transient long long9", + "persistence-modifier= none private transient long long10", + "persistence-modifier= persistent private transient long long11", + "persistence-modifier= persistent embedded= true private transient long long12", + "persistence-modifier= persistent embedded= false private transient long long13", + "persistence-modifier= transactional private transient long long14", + "private final long long15", + "private volatile long long16", + "embedded= true private volatile long long17", + "embedded= false private volatile long long18", + "persistence-modifier= none private volatile long long19", + "persistence-modifier= persistent private volatile long long20", + "persistence-modifier= persistent embedded= true private volatile long long21", + "persistence-modifier= persistent embedded= false private volatile long long22", + "persistence-modifier= transactional private volatile long long23", + "private static transient long long24", + "private static final long long25", + "private static volatile long long26", + "private transient final long long27", + "private transient volatile long long28", + "persistence-modifier= none private transient volatile long long29", + "persistence-modifier= persistent private transient volatile long long30", + "persistence-modifier= persistent embedded= true private transient volatile long long31", + "persistence-modifier= persistent embedded= false private transient volatile long long32", + "persistence-modifier= transactional private transient volatile long long33", + "private static transient final long long34", + "private static transient volatile long long35", + "public long long36", + "embedded= true public long long37", + "embedded= false public long long38", + "persistence-modifier= none public long long39", + "persistence-modifier= persistent public long long40", + "persistence-modifier= persistent embedded= true public long long41", + "persistence-modifier= persistent embedded= false public long long42", + "persistence-modifier= transactional public long long43", + "public static long long44", + "public transient long long45", + "persistence-modifier= none public transient long long46", + "persistence-modifier= persistent public transient long long47", + "persistence-modifier= persistent embedded= true public transient long long48", + "persistence-modifier= persistent embedded= false public transient long long49", + "persistence-modifier= transactional public transient long long50", + "public final long long51", + "public volatile long long52", + "embedded= true public volatile long long53", + "embedded= false public volatile long long54", + "persistence-modifier= none public volatile long long55", + "persistence-modifier= persistent public volatile long long56", + "persistence-modifier= persistent embedded= true public volatile long long57", + "persistence-modifier= persistent embedded= false public volatile long long58", + "persistence-modifier= transactional public volatile long long59", + "public static transient long long60", + "public static final long long61", + "public static volatile long long62", + "public transient final long long63", + "public transient volatile long long64", + "persistence-modifier= none public transient volatile long long65", + "persistence-modifier= persistent public transient volatile long long66", + "persistence-modifier= persistent embedded= true public transient volatile long long67", + "persistence-modifier= persistent embedded= false public transient volatile long long68", + "persistence-modifier= transactional public transient volatile long long69", + "public static transient final long long70", + "public static transient volatile long long71", + "protected long long72", + "embedded= true protected long long73", + "embedded= false protected long long74", + "persistence-modifier= none protected long long75", + "persistence-modifier= persistent protected long long76", + "persistence-modifier= persistent embedded= true protected long long77", + "persistence-modifier= persistent embedded= false protected long long78", + "persistence-modifier= transactional protected long long79", + "protected static long long80", + "protected transient long long81", + "persistence-modifier= none protected transient long long82", + "persistence-modifier= persistent protected transient long long83", + "persistence-modifier= persistent embedded= true protected transient long long84", + "persistence-modifier= persistent embedded= false protected transient long long85", + "persistence-modifier= transactional protected transient long long86", + "protected final long long87", + "protected volatile long long88", + "embedded= true protected volatile long long89", + "embedded= false protected volatile long long90", + "persistence-modifier= none protected volatile long long91", + "persistence-modifier= persistent protected volatile long long92", + "persistence-modifier= persistent embedded= true protected volatile long long93", + "persistence-modifier= persistent embedded= false protected volatile long long94", + "persistence-modifier= transactional protected volatile long long95", + "protected static transient long long96", + "protected static final long long97", + "protected static volatile long long98", + "protected transient final long long99", + "protected transient volatile long long100", + "persistence-modifier= none protected transient volatile long long101", + "persistence-modifier= persistent protected transient volatile long long102", + "persistence-modifier= persistent embedded= true protected transient volatile long long103", + "persistence-modifier= persistent embedded= false protected transient volatile long long104", + "persistence-modifier= transactional protected transient volatile long long105", + "protected static transient final long long106", + "protected static transient volatile long long107", + "long long108", + "embedded= true long long109", + "embedded= false long long110", + "persistence-modifier= none long long111", + "persistence-modifier= persistent long long112", + "persistence-modifier= persistent embedded= true long long113", + "persistence-modifier= persistent embedded= false long long114", + "persistence-modifier= transactional long long115", + "static long long116", + "transient long long117", + "persistence-modifier= none transient long long118", + "persistence-modifier= persistent transient long long119", + "persistence-modifier= persistent embedded= true transient long long120", + "persistence-modifier= persistent embedded= false transient long long121", + "persistence-modifier= transactional transient long long122", + "final long long123", + "volatile long long124", + "embedded= true volatile long long125", + "embedded= false volatile long long126", + "persistence-modifier= none volatile long long127", + "persistence-modifier= persistent volatile long long128", + "persistence-modifier= persistent embedded= true volatile long long129", + "persistence-modifier= persistent embedded= false volatile long long130", + "persistence-modifier= transactional volatile long long131", + "static transient long long132", + "static final long long133", + "static volatile long long134", + "transient final long long135", + "transient volatile long long136", + "persistence-modifier= none transient volatile long long137", + "persistence-modifier= persistent transient volatile long long138", + "persistence-modifier= persistent embedded= true transient volatile long long139", + "persistence-modifier= persistent embedded= false transient volatile long long140", + "persistence-modifier= transactional transient volatile long long141", + "static transient final long long142", + "static transient volatile long long143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public long get(int index) { - switch (index) { - case (0): + public long get(int index) + { + switch (index) + { + case(0): return long0; - case (1): + case(1): return long1; - case (2): + case(2): return long2; - case (3): + case(3): return long3; - case (4): + case(4): return long4; - case (5): + case(5): return long5; - case (6): + case(6): return long6; - case (7): + case(7): return long7; - case (8): + case(8): return long8; - case (9): + case(9): return long9; - case (10): + case(10): return long10; - case (11): + case(11): return long11; - case (12): + case(12): return long12; - case (13): + case(13): return long13; - case (14): + case(14): return long14; - case (15): + case(15): return long15; - case (16): + case(16): return long16; - case (17): + case(17): return long17; - case (18): + case(18): return long18; - case (19): + case(19): return long19; - case (20): + case(20): return long20; - case (21): + case(21): return long21; - case (22): + case(22): return long22; - case (23): + case(23): return long23; - case (24): + case(24): return long24; - case (25): + case(25): return long25; - case (26): + case(26): return long26; - case (27): + case(27): return long27; - case (28): + case(28): return long28; - case (29): + case(29): return long29; - case (30): + case(30): return long30; - case (31): + case(31): return long31; - case (32): + case(32): return long32; - case (33): + case(33): return long33; - case (34): + case(34): return long34; - case (35): + case(35): return long35; - case (36): + case(36): return long36; - case (37): + case(37): return long37; - case (38): + case(38): return long38; - case (39): + case(39): return long39; - case (40): + case(40): return long40; - case (41): + case(41): return long41; - case (42): + case(42): return long42; - case (43): + case(43): return long43; - case (44): + case(44): return long44; - case (45): + case(45): return long45; - case (46): + case(46): return long46; - case (47): + case(47): return long47; - case (48): + case(48): return long48; - case (49): + case(49): return long49; - case (50): + case(50): return long50; - case (51): + case(51): return long51; - case (52): + case(52): return long52; - case (53): + case(53): return long53; - case (54): + case(54): return long54; - case (55): + case(55): return long55; - case (56): + case(56): return long56; - case (57): + case(57): return long57; - case (58): + case(58): return long58; - case (59): + case(59): return long59; - case (60): + case(60): return long60; - case (61): + case(61): return long61; - case (62): + case(62): return long62; - case (63): + case(63): return long63; - case (64): + case(64): return long64; - case (65): + case(65): return long65; - case (66): + case(66): return long66; - case (67): + case(67): return long67; - case (68): + case(68): return long68; - case (69): + case(69): return long69; - case (70): + case(70): return long70; - case (71): + case(71): return long71; - case (72): + case(72): return long72; - case (73): + case(73): return long73; - case (74): + case(74): return long74; - case (75): + case(75): return long75; - case (76): + case(76): return long76; - case (77): + case(77): return long77; - case (78): + case(78): return long78; - case (79): + case(79): return long79; - case (80): + case(80): return long80; - case (81): + case(81): return long81; - case (82): + case(82): return long82; - case (83): + case(83): return long83; - case (84): + case(84): return long84; - case (85): + case(85): return long85; - case (86): + case(86): return long86; - case (87): + case(87): return long87; - case (88): + case(88): return long88; - case (89): + case(89): return long89; - case (90): + case(90): return long90; - case (91): + case(91): return long91; - case (92): + case(92): return long92; - case (93): + case(93): return long93; - case (94): + case(94): return long94; - case (95): + case(95): return long95; - case (96): + case(96): return long96; - case (97): + case(97): return long97; - case (98): + case(98): return long98; - case (99): + case(99): return long99; - case (100): + case(100): return long100; - case (101): + case(101): return long101; - case (102): + case(102): return long102; - case (103): + case(103): return long103; - case (104): + case(104): return long104; - case (105): + case(105): return long105; - case (106): + case(106): return long106; - case (107): + case(107): return long107; - case (108): + case(108): return long108; - case (109): + case(109): return long109; - case (110): + case(110): return long110; - case (111): + case(111): return long111; - case (112): + case(112): return long112; - case (113): + case(113): return long113; - case (114): + case(114): return long114; - case (115): + case(115): return long115; - case (116): + case(116): return long116; - case (117): + case(117): return long117; - case (118): + case(118): return long118; - case (119): + case(119): return long119; - case (120): + case(120): return long120; - case (121): + case(121): return long121; - case (122): + case(122): return long122; - case (123): + case(123): return long123; - case (124): + case(124): return long124; - case (125): + case(125): return long125; - case (126): + case(126): return long126; - case (127): + case(127): return long127; - case (128): + case(128): return long128; - case (129): + case(129): return long129; - case (130): + case(130): return long130; - case (131): + case(131): return long131; - case (132): + case(132): return long132; - case (133): + case(133): return long133; - case (134): + case(134): return long134; - case (135): + case(135): return long135; - case (136): + case(136): return long136; - case (137): + case(137): return long137; - case (138): + case(138): return long138; - case (139): + case(139): return long139; - case (140): + case(140): return long140; - case (141): + case(141): return long141; - case (142): + case(142): return long142; - case (143): + case(143): return long143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, long value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - long0 = value; - break; - case (1): - long1 = value; - break; - case (2): - long2 = value; - break; - case (3): - long3 = value; - break; - case (4): - long4 = value; - break; - case (5): - long5 = value; - break; - case (6): - long6 = value; - break; - case (7): - long7 = value; - break; - case (8): - long8 = value; - break; - case (9): - long9 = value; - break; - case (10): - long10 = value; - break; - case (11): - long11 = value; - break; - case (12): - long12 = value; - break; - case (13): - long13 = value; - break; - case (14): - long14 = value; - break; - case (16): - long16 = value; - break; - case (17): - long17 = value; - break; - case (18): - long18 = value; - break; - case (19): - long19 = value; - break; - case (20): - long20 = value; - break; - case (21): - long21 = value; - break; - case (22): - long22 = value; - break; - case (23): - long23 = value; - break; - case (24): - long24 = value; - break; - case (26): - long26 = value; - break; - case (28): - long28 = value; - break; - case (29): - long29 = value; - break; - case (30): - long30 = value; - break; - case (31): - long31 = value; - break; - case (32): - long32 = value; - break; - case (33): - long33 = value; - break; - case (35): - long35 = value; - break; - case (36): - long36 = value; - break; - case (37): - long37 = value; - break; - case (38): - long38 = value; - break; - case (39): - long39 = value; - break; - case (40): - long40 = value; - break; - case (41): - long41 = value; - break; - case (42): - long42 = value; - break; - case (43): - long43 = value; - break; - case (44): - long44 = value; - break; - case (45): - long45 = value; - break; - case (46): - long46 = value; - break; - case (47): - long47 = value; - break; - case (48): - long48 = value; - break; - case (49): - long49 = value; - break; - case (50): - long50 = value; - break; - case (52): - long52 = value; - break; - case (53): - long53 = value; - break; - case (54): - long54 = value; - break; - case (55): - long55 = value; - break; - case (56): - long56 = value; - break; - case (57): - long57 = value; - break; - case (58): - long58 = value; - break; - case (59): - long59 = value; - break; - case (60): - long60 = value; - break; - case (62): - long62 = value; - break; - case (64): - long64 = value; - break; - case (65): - long65 = value; - break; - case (66): - long66 = value; - break; - case (67): - long67 = value; - break; - case (68): - long68 = value; - break; - case (69): - long69 = value; - break; - case (71): - long71 = value; - break; - case (72): - long72 = value; - break; - case (73): - long73 = value; - break; - case (74): - long74 = value; - break; - case (75): - long75 = value; - break; - case (76): - long76 = value; - break; - case (77): - long77 = value; - break; - case (78): - long78 = value; - break; - case (79): - long79 = value; - break; - case (80): - long80 = value; - break; - case (81): - long81 = value; - break; - case (82): - long82 = value; - break; - case (83): - long83 = value; - break; - case (84): - long84 = value; - break; - case (85): - long85 = value; - break; - case (86): - long86 = value; - break; - case (88): - long88 = value; - break; - case (89): - long89 = value; - break; - case (90): - long90 = value; - break; - case (91): - long91 = value; - break; - case (92): - long92 = value; - break; - case (93): - long93 = value; - break; - case (94): - long94 = value; - break; - case (95): - long95 = value; - break; - case (96): - long96 = value; - break; - case (98): - long98 = value; - break; - case (100): - long100 = value; - break; - case (101): - long101 = value; - break; - case (102): - long102 = value; - break; - case (103): - long103 = value; - break; - case (104): - long104 = value; - break; - case (105): - long105 = value; - break; - case (107): - long107 = value; - break; - case (108): - long108 = value; - break; - case (109): - long109 = value; - break; - case (110): - long110 = value; - break; - case (111): - long111 = value; - break; - case (112): - long112 = value; - break; - case (113): - long113 = value; - break; - case (114): - long114 = value; - break; - case (115): - long115 = value; - break; - case (116): - long116 = value; - break; - case (117): - long117 = value; - break; - case (118): - long118 = value; - break; - case (119): - long119 = value; - break; - case (120): - long120 = value; - break; - case (121): - long121 = value; - break; - case (122): - long122 = value; - break; - case (124): - long124 = value; - break; - case (125): - long125 = value; - break; - case (126): - long126 = value; - break; - case (127): - long127 = value; - break; - case (128): - long128 = value; - break; - case (129): - long129 = value; - break; - case (130): - long130 = value; - break; - case (131): - long131 = value; - break; - case (132): - long132 = value; - break; - case (134): - long134 = value; - break; - case (136): - long136 = value; - break; - case (137): - long137 = value; - break; - case (138): - long138 = value; - break; - case (139): - long139 = value; - break; - case (140): - long140 = value; - break; - case (141): - long141 = value; - break; - case (143): - long143 = value; - break; + public boolean set(int index,long value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + long0= value; + break; + case(1): + long1= value; + break; + case(2): + long2= value; + break; + case(3): + long3= value; + break; + case(4): + long4= value; + break; + case(5): + long5= value; + break; + case(6): + long6= value; + break; + case(7): + long7= value; + break; + case(8): + long8= value; + break; + case(9): + long9= value; + break; + case(10): + long10= value; + break; + case(11): + long11= value; + break; + case(12): + long12= value; + break; + case(13): + long13= value; + break; + case(14): + long14= value; + break; + case(16): + long16= value; + break; + case(17): + long17= value; + break; + case(18): + long18= value; + break; + case(19): + long19= value; + break; + case(20): + long20= value; + break; + case(21): + long21= value; + break; + case(22): + long22= value; + break; + case(23): + long23= value; + break; + case(24): + long24= value; + break; + case(26): + long26= value; + break; + case(28): + long28= value; + break; + case(29): + long29= value; + break; + case(30): + long30= value; + break; + case(31): + long31= value; + break; + case(32): + long32= value; + break; + case(33): + long33= value; + break; + case(35): + long35= value; + break; + case(36): + long36= value; + break; + case(37): + long37= value; + break; + case(38): + long38= value; + break; + case(39): + long39= value; + break; + case(40): + long40= value; + break; + case(41): + long41= value; + break; + case(42): + long42= value; + break; + case(43): + long43= value; + break; + case(44): + long44= value; + break; + case(45): + long45= value; + break; + case(46): + long46= value; + break; + case(47): + long47= value; + break; + case(48): + long48= value; + break; + case(49): + long49= value; + break; + case(50): + long50= value; + break; + case(52): + long52= value; + break; + case(53): + long53= value; + break; + case(54): + long54= value; + break; + case(55): + long55= value; + break; + case(56): + long56= value; + break; + case(57): + long57= value; + break; + case(58): + long58= value; + break; + case(59): + long59= value; + break; + case(60): + long60= value; + break; + case(62): + long62= value; + break; + case(64): + long64= value; + break; + case(65): + long65= value; + break; + case(66): + long66= value; + break; + case(67): + long67= value; + break; + case(68): + long68= value; + break; + case(69): + long69= value; + break; + case(71): + long71= value; + break; + case(72): + long72= value; + break; + case(73): + long73= value; + break; + case(74): + long74= value; + break; + case(75): + long75= value; + break; + case(76): + long76= value; + break; + case(77): + long77= value; + break; + case(78): + long78= value; + break; + case(79): + long79= value; + break; + case(80): + long80= value; + break; + case(81): + long81= value; + break; + case(82): + long82= value; + break; + case(83): + long83= value; + break; + case(84): + long84= value; + break; + case(85): + long85= value; + break; + case(86): + long86= value; + break; + case(88): + long88= value; + break; + case(89): + long89= value; + break; + case(90): + long90= value; + break; + case(91): + long91= value; + break; + case(92): + long92= value; + break; + case(93): + long93= value; + break; + case(94): + long94= value; + break; + case(95): + long95= value; + break; + case(96): + long96= value; + break; + case(98): + long98= value; + break; + case(100): + long100= value; + break; + case(101): + long101= value; + break; + case(102): + long102= value; + break; + case(103): + long103= value; + break; + case(104): + long104= value; + break; + case(105): + long105= value; + break; + case(107): + long107= value; + break; + case(108): + long108= value; + break; + case(109): + long109= value; + break; + case(110): + long110= value; + break; + case(111): + long111= value; + break; + case(112): + long112= value; + break; + case(113): + long113= value; + break; + case(114): + long114= value; + break; + case(115): + long115= value; + break; + case(116): + long116= value; + break; + case(117): + long117= value; + break; + case(118): + long118= value; + break; + case(119): + long119= value; + break; + case(120): + long120= value; + break; + case(121): + long121= value; + break; + case(122): + long122= value; + break; + case(124): + long124= value; + break; + case(125): + long125= value; + break; + case(126): + long126= value; + break; + case(127): + long127= value; + break; + case(128): + long128= value; + break; + case(129): + long129= value; + break; + case(130): + long130= value; + break; + case(131): + long131= value; + break; + case(132): + long132= value; + break; + case(134): + long134= value; + break; + case(136): + long136= value; + break; + case(137): + long137= value; + break; + case(138): + long138= value; + break; + case(139): + long139= value; + break; + case(140): + long140= value; + break; + case(141): + long141= value; + break; + case(143): + long143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } - - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public int hashCode() { - return (int) identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public int hashCode() { return (int)identifier ; } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitiveshort.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitiveshort.java index 312b6cd3d..98320b169 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitiveshort.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfPrimitiveshort.java @@ -5,21 +5,21 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -public class FieldsOfPrimitiveshort { +public class FieldsOfPrimitiveshort { public int identifier; private short short0; private short short1; @@ -48,14 +48,14 @@ public class FieldsOfPrimitiveshort { private static transient short short24; private static final short short25 = 5; private static volatile short short26; - private final transient short short27 = 5; + private transient final short short27 = 5; private transient volatile short short28; private transient volatile short short29; private transient volatile short short30; private transient volatile short short31; private transient volatile short short32; private transient volatile short short33; - private static final transient short short34 = 5; + private static transient final short short34 = 5; private static transient volatile short short35; public short short36; public short short37; @@ -84,14 +84,14 @@ public class FieldsOfPrimitiveshort { public static transient short short60; public static final short short61 = 5; public static volatile short short62; - public final transient short short63 = 5; + public transient final short short63 = 5; public transient volatile short short64; public transient volatile short short65; public transient volatile short short66; public transient volatile short short67; public transient volatile short short68; public transient volatile short short69; - public static final transient short short70 = 5; + public static transient final short short70 = 5; public static transient volatile short short71; protected short short72; protected short short73; @@ -120,14 +120,14 @@ public class FieldsOfPrimitiveshort { protected static transient short short96; protected static final short short97 = 5; protected static volatile short short98; - protected final transient short short99 = 5; + protected transient final short short99 = 5; protected transient volatile short short100; protected transient volatile short short101; protected transient volatile short short102; protected transient volatile short short103; protected transient volatile short short104; protected transient volatile short short105; - protected static final transient short short106 = 5; + protected static transient final short short106 = 5; protected static transient volatile short short107; short short108; short short109; @@ -156,936 +156,935 @@ public class FieldsOfPrimitiveshort { static transient short short132; static final short short133 = 5; static volatile short short134; - final transient short short135 = 5; + transient final short short135 = 5; transient volatile short short136; transient volatile short short137; transient volatile short short138; transient volatile short short139; transient volatile short short140; transient volatile short short141; - static final transient short short142 = 5; + static transient final short short142 = 5; static transient volatile short short143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private short short0", - "embedded= true private short short1", - "embedded= false private short short2", - "persistence-modifier= none private short short3", - "persistence-modifier= persistent private short short4", - "persistence-modifier= persistent embedded= true private short short5", - "persistence-modifier= persistent embedded= false private short short6", - "persistence-modifier= transactional private short short7", - "private static short short8", - "private transient short short9", - "persistence-modifier= none private transient short short10", - "persistence-modifier= persistent private transient short short11", - "persistence-modifier= persistent embedded= true private transient short short12", - "persistence-modifier= persistent embedded= false private transient short short13", - "persistence-modifier= transactional private transient short short14", - "private final short short15", - "private volatile short short16", - "embedded= true private volatile short short17", - "embedded= false private volatile short short18", - "persistence-modifier= none private volatile short short19", - "persistence-modifier= persistent private volatile short short20", - "persistence-modifier= persistent embedded= true private volatile short short21", - "persistence-modifier= persistent embedded= false private volatile short short22", - "persistence-modifier= transactional private volatile short short23", - "private static transient short short24", - "private static final short short25", - "private static volatile short short26", - "private transient final short short27", - "private transient volatile short short28", - "persistence-modifier= none private transient volatile short short29", - "persistence-modifier= persistent private transient volatile short short30", - "persistence-modifier= persistent embedded= true private transient volatile short short31", - "persistence-modifier= persistent embedded= false private transient volatile short short32", - "persistence-modifier= transactional private transient volatile short short33", - "private static transient final short short34", - "private static transient volatile short short35", - "public short short36", - "embedded= true public short short37", - "embedded= false public short short38", - "persistence-modifier= none public short short39", - "persistence-modifier= persistent public short short40", - "persistence-modifier= persistent embedded= true public short short41", - "persistence-modifier= persistent embedded= false public short short42", - "persistence-modifier= transactional public short short43", - "public static short short44", - "public transient short short45", - "persistence-modifier= none public transient short short46", - "persistence-modifier= persistent public transient short short47", - "persistence-modifier= persistent embedded= true public transient short short48", - "persistence-modifier= persistent embedded= false public transient short short49", - "persistence-modifier= transactional public transient short short50", - "public final short short51", - "public volatile short short52", - "embedded= true public volatile short short53", - "embedded= false public volatile short short54", - "persistence-modifier= none public volatile short short55", - "persistence-modifier= persistent public volatile short short56", - "persistence-modifier= persistent embedded= true public volatile short short57", - "persistence-modifier= persistent embedded= false public volatile short short58", - "persistence-modifier= transactional public volatile short short59", - "public static transient short short60", - "public static final short short61", - "public static volatile short short62", - "public transient final short short63", - "public transient volatile short short64", - "persistence-modifier= none public transient volatile short short65", - "persistence-modifier= persistent public transient volatile short short66", - "persistence-modifier= persistent embedded= true public transient volatile short short67", - "persistence-modifier= persistent embedded= false public transient volatile short short68", - "persistence-modifier= transactional public transient volatile short short69", - "public static transient final short short70", - "public static transient volatile short short71", - "protected short short72", - "embedded= true protected short short73", - "embedded= false protected short short74", - "persistence-modifier= none protected short short75", - "persistence-modifier= persistent protected short short76", - "persistence-modifier= persistent embedded= true protected short short77", - "persistence-modifier= persistent embedded= false protected short short78", - "persistence-modifier= transactional protected short short79", - "protected static short short80", - "protected transient short short81", - "persistence-modifier= none protected transient short short82", - "persistence-modifier= persistent protected transient short short83", - "persistence-modifier= persistent embedded= true protected transient short short84", - "persistence-modifier= persistent embedded= false protected transient short short85", - "persistence-modifier= transactional protected transient short short86", - "protected final short short87", - "protected volatile short short88", - "embedded= true protected volatile short short89", - "embedded= false protected volatile short short90", - "persistence-modifier= none protected volatile short short91", - "persistence-modifier= persistent protected volatile short short92", - "persistence-modifier= persistent embedded= true protected volatile short short93", - "persistence-modifier= persistent embedded= false protected volatile short short94", - "persistence-modifier= transactional protected volatile short short95", - "protected static transient short short96", - "protected static final short short97", - "protected static volatile short short98", - "protected transient final short short99", - "protected transient volatile short short100", - "persistence-modifier= none protected transient volatile short short101", - "persistence-modifier= persistent protected transient volatile short short102", - "persistence-modifier= persistent embedded= true protected transient volatile short short103", - "persistence-modifier= persistent embedded= false protected transient volatile short short104", - "persistence-modifier= transactional protected transient volatile short short105", - "protected static transient final short short106", - "protected static transient volatile short short107", - "short short108", - "embedded= true short short109", - "embedded= false short short110", - "persistence-modifier= none short short111", - "persistence-modifier= persistent short short112", - "persistence-modifier= persistent embedded= true short short113", - "persistence-modifier= persistent embedded= false short short114", - "persistence-modifier= transactional short short115", - "static short short116", - "transient short short117", - "persistence-modifier= none transient short short118", - "persistence-modifier= persistent transient short short119", - "persistence-modifier= persistent embedded= true transient short short120", - "persistence-modifier= persistent embedded= false transient short short121", - "persistence-modifier= transactional transient short short122", - "final short short123", - "volatile short short124", - "embedded= true volatile short short125", - "embedded= false volatile short short126", - "persistence-modifier= none volatile short short127", - "persistence-modifier= persistent volatile short short128", - "persistence-modifier= persistent embedded= true volatile short short129", - "persistence-modifier= persistent embedded= false volatile short short130", - "persistence-modifier= transactional volatile short short131", - "static transient short short132", - "static final short short133", - "static volatile short short134", - "transient final short short135", - "transient volatile short short136", - "persistence-modifier= none transient volatile short short137", - "persistence-modifier= persistent transient volatile short short138", - "persistence-modifier= persistent embedded= true transient volatile short short139", - "persistence-modifier= persistent embedded= false transient volatile short short140", - "persistence-modifier= transactional transient volatile short short141", - "static transient final short short142", - "static transient volatile short short143" + public static final String [] fieldSpecs = { + "private short short0", + "embedded= true private short short1", + "embedded= false private short short2", + "persistence-modifier= none private short short3", + "persistence-modifier= persistent private short short4", + "persistence-modifier= persistent embedded= true private short short5", + "persistence-modifier= persistent embedded= false private short short6", + "persistence-modifier= transactional private short short7", + "private static short short8", + "private transient short short9", + "persistence-modifier= none private transient short short10", + "persistence-modifier= persistent private transient short short11", + "persistence-modifier= persistent embedded= true private transient short short12", + "persistence-modifier= persistent embedded= false private transient short short13", + "persistence-modifier= transactional private transient short short14", + "private final short short15", + "private volatile short short16", + "embedded= true private volatile short short17", + "embedded= false private volatile short short18", + "persistence-modifier= none private volatile short short19", + "persistence-modifier= persistent private volatile short short20", + "persistence-modifier= persistent embedded= true private volatile short short21", + "persistence-modifier= persistent embedded= false private volatile short short22", + "persistence-modifier= transactional private volatile short short23", + "private static transient short short24", + "private static final short short25", + "private static volatile short short26", + "private transient final short short27", + "private transient volatile short short28", + "persistence-modifier= none private transient volatile short short29", + "persistence-modifier= persistent private transient volatile short short30", + "persistence-modifier= persistent embedded= true private transient volatile short short31", + "persistence-modifier= persistent embedded= false private transient volatile short short32", + "persistence-modifier= transactional private transient volatile short short33", + "private static transient final short short34", + "private static transient volatile short short35", + "public short short36", + "embedded= true public short short37", + "embedded= false public short short38", + "persistence-modifier= none public short short39", + "persistence-modifier= persistent public short short40", + "persistence-modifier= persistent embedded= true public short short41", + "persistence-modifier= persistent embedded= false public short short42", + "persistence-modifier= transactional public short short43", + "public static short short44", + "public transient short short45", + "persistence-modifier= none public transient short short46", + "persistence-modifier= persistent public transient short short47", + "persistence-modifier= persistent embedded= true public transient short short48", + "persistence-modifier= persistent embedded= false public transient short short49", + "persistence-modifier= transactional public transient short short50", + "public final short short51", + "public volatile short short52", + "embedded= true public volatile short short53", + "embedded= false public volatile short short54", + "persistence-modifier= none public volatile short short55", + "persistence-modifier= persistent public volatile short short56", + "persistence-modifier= persistent embedded= true public volatile short short57", + "persistence-modifier= persistent embedded= false public volatile short short58", + "persistence-modifier= transactional public volatile short short59", + "public static transient short short60", + "public static final short short61", + "public static volatile short short62", + "public transient final short short63", + "public transient volatile short short64", + "persistence-modifier= none public transient volatile short short65", + "persistence-modifier= persistent public transient volatile short short66", + "persistence-modifier= persistent embedded= true public transient volatile short short67", + "persistence-modifier= persistent embedded= false public transient volatile short short68", + "persistence-modifier= transactional public transient volatile short short69", + "public static transient final short short70", + "public static transient volatile short short71", + "protected short short72", + "embedded= true protected short short73", + "embedded= false protected short short74", + "persistence-modifier= none protected short short75", + "persistence-modifier= persistent protected short short76", + "persistence-modifier= persistent embedded= true protected short short77", + "persistence-modifier= persistent embedded= false protected short short78", + "persistence-modifier= transactional protected short short79", + "protected static short short80", + "protected transient short short81", + "persistence-modifier= none protected transient short short82", + "persistence-modifier= persistent protected transient short short83", + "persistence-modifier= persistent embedded= true protected transient short short84", + "persistence-modifier= persistent embedded= false protected transient short short85", + "persistence-modifier= transactional protected transient short short86", + "protected final short short87", + "protected volatile short short88", + "embedded= true protected volatile short short89", + "embedded= false protected volatile short short90", + "persistence-modifier= none protected volatile short short91", + "persistence-modifier= persistent protected volatile short short92", + "persistence-modifier= persistent embedded= true protected volatile short short93", + "persistence-modifier= persistent embedded= false protected volatile short short94", + "persistence-modifier= transactional protected volatile short short95", + "protected static transient short short96", + "protected static final short short97", + "protected static volatile short short98", + "protected transient final short short99", + "protected transient volatile short short100", + "persistence-modifier= none protected transient volatile short short101", + "persistence-modifier= persistent protected transient volatile short short102", + "persistence-modifier= persistent embedded= true protected transient volatile short short103", + "persistence-modifier= persistent embedded= false protected transient volatile short short104", + "persistence-modifier= transactional protected transient volatile short short105", + "protected static transient final short short106", + "protected static transient volatile short short107", + "short short108", + "embedded= true short short109", + "embedded= false short short110", + "persistence-modifier= none short short111", + "persistence-modifier= persistent short short112", + "persistence-modifier= persistent embedded= true short short113", + "persistence-modifier= persistent embedded= false short short114", + "persistence-modifier= transactional short short115", + "static short short116", + "transient short short117", + "persistence-modifier= none transient short short118", + "persistence-modifier= persistent transient short short119", + "persistence-modifier= persistent embedded= true transient short short120", + "persistence-modifier= persistent embedded= false transient short short121", + "persistence-modifier= transactional transient short short122", + "final short short123", + "volatile short short124", + "embedded= true volatile short short125", + "embedded= false volatile short short126", + "persistence-modifier= none volatile short short127", + "persistence-modifier= persistent volatile short short128", + "persistence-modifier= persistent embedded= true volatile short short129", + "persistence-modifier= persistent embedded= false volatile short short130", + "persistence-modifier= transactional volatile short short131", + "static transient short short132", + "static final short short133", + "static volatile short short134", + "transient final short short135", + "transient volatile short short136", + "persistence-modifier= none transient volatile short short137", + "persistence-modifier= persistent transient volatile short short138", + "persistence-modifier= persistent embedded= true transient volatile short short139", + "persistence-modifier= persistent embedded= false transient volatile short short140", + "persistence-modifier= transactional transient volatile short short141", + "static transient final short short142", + "static transient volatile short short143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public short get(int index) { - switch (index) { - case (0): + public short get(int index) + { + switch (index) + { + case(0): return short0; - case (1): + case(1): return short1; - case (2): + case(2): return short2; - case (3): + case(3): return short3; - case (4): + case(4): return short4; - case (5): + case(5): return short5; - case (6): + case(6): return short6; - case (7): + case(7): return short7; - case (8): + case(8): return short8; - case (9): + case(9): return short9; - case (10): + case(10): return short10; - case (11): + case(11): return short11; - case (12): + case(12): return short12; - case (13): + case(13): return short13; - case (14): + case(14): return short14; - case (15): + case(15): return short15; - case (16): + case(16): return short16; - case (17): + case(17): return short17; - case (18): + case(18): return short18; - case (19): + case(19): return short19; - case (20): + case(20): return short20; - case (21): + case(21): return short21; - case (22): + case(22): return short22; - case (23): + case(23): return short23; - case (24): + case(24): return short24; - case (25): + case(25): return short25; - case (26): + case(26): return short26; - case (27): + case(27): return short27; - case (28): + case(28): return short28; - case (29): + case(29): return short29; - case (30): + case(30): return short30; - case (31): + case(31): return short31; - case (32): + case(32): return short32; - case (33): + case(33): return short33; - case (34): + case(34): return short34; - case (35): + case(35): return short35; - case (36): + case(36): return short36; - case (37): + case(37): return short37; - case (38): + case(38): return short38; - case (39): + case(39): return short39; - case (40): + case(40): return short40; - case (41): + case(41): return short41; - case (42): + case(42): return short42; - case (43): + case(43): return short43; - case (44): + case(44): return short44; - case (45): + case(45): return short45; - case (46): + case(46): return short46; - case (47): + case(47): return short47; - case (48): + case(48): return short48; - case (49): + case(49): return short49; - case (50): + case(50): return short50; - case (51): + case(51): return short51; - case (52): + case(52): return short52; - case (53): + case(53): return short53; - case (54): + case(54): return short54; - case (55): + case(55): return short55; - case (56): + case(56): return short56; - case (57): + case(57): return short57; - case (58): + case(58): return short58; - case (59): + case(59): return short59; - case (60): + case(60): return short60; - case (61): + case(61): return short61; - case (62): + case(62): return short62; - case (63): + case(63): return short63; - case (64): + case(64): return short64; - case (65): + case(65): return short65; - case (66): + case(66): return short66; - case (67): + case(67): return short67; - case (68): + case(68): return short68; - case (69): + case(69): return short69; - case (70): + case(70): return short70; - case (71): + case(71): return short71; - case (72): + case(72): return short72; - case (73): + case(73): return short73; - case (74): + case(74): return short74; - case (75): + case(75): return short75; - case (76): + case(76): return short76; - case (77): + case(77): return short77; - case (78): + case(78): return short78; - case (79): + case(79): return short79; - case (80): + case(80): return short80; - case (81): + case(81): return short81; - case (82): + case(82): return short82; - case (83): + case(83): return short83; - case (84): + case(84): return short84; - case (85): + case(85): return short85; - case (86): + case(86): return short86; - case (87): + case(87): return short87; - case (88): + case(88): return short88; - case (89): + case(89): return short89; - case (90): + case(90): return short90; - case (91): + case(91): return short91; - case (92): + case(92): return short92; - case (93): + case(93): return short93; - case (94): + case(94): return short94; - case (95): + case(95): return short95; - case (96): + case(96): return short96; - case (97): + case(97): return short97; - case (98): + case(98): return short98; - case (99): + case(99): return short99; - case (100): + case(100): return short100; - case (101): + case(101): return short101; - case (102): + case(102): return short102; - case (103): + case(103): return short103; - case (104): + case(104): return short104; - case (105): + case(105): return short105; - case (106): + case(106): return short106; - case (107): + case(107): return short107; - case (108): + case(108): return short108; - case (109): + case(109): return short109; - case (110): + case(110): return short110; - case (111): + case(111): return short111; - case (112): + case(112): return short112; - case (113): + case(113): return short113; - case (114): + case(114): return short114; - case (115): + case(115): return short115; - case (116): + case(116): return short116; - case (117): + case(117): return short117; - case (118): + case(118): return short118; - case (119): + case(119): return short119; - case (120): + case(120): return short120; - case (121): + case(121): return short121; - case (122): + case(122): return short122; - case (123): + case(123): return short123; - case (124): + case(124): return short124; - case (125): + case(125): return short125; - case (126): + case(126): return short126; - case (127): + case(127): return short127; - case (128): + case(128): return short128; - case (129): + case(129): return short129; - case (130): + case(130): return short130; - case (131): + case(131): return short131; - case (132): + case(132): return short132; - case (133): + case(133): return short133; - case (134): + case(134): return short134; - case (135): + case(135): return short135; - case (136): + case(136): return short136; - case (137): + case(137): return short137; - case (138): + case(138): return short138; - case (139): + case(139): return short139; - case (140): + case(140): return short140; - case (141): + case(141): return short141; - case (142): + case(142): return short142; - case (143): + case(143): return short143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, short value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - short0 = value; - break; - case (1): - short1 = value; - break; - case (2): - short2 = value; - break; - case (3): - short3 = value; - break; - case (4): - short4 = value; - break; - case (5): - short5 = value; - break; - case (6): - short6 = value; - break; - case (7): - short7 = value; - break; - case (8): - short8 = value; - break; - case (9): - short9 = value; - break; - case (10): - short10 = value; - break; - case (11): - short11 = value; - break; - case (12): - short12 = value; - break; - case (13): - short13 = value; - break; - case (14): - short14 = value; - break; - case (16): - short16 = value; - break; - case (17): - short17 = value; - break; - case (18): - short18 = value; - break; - case (19): - short19 = value; - break; - case (20): - short20 = value; - break; - case (21): - short21 = value; - break; - case (22): - short22 = value; - break; - case (23): - short23 = value; - break; - case (24): - short24 = value; - break; - case (26): - short26 = value; - break; - case (28): - short28 = value; - break; - case (29): - short29 = value; - break; - case (30): - short30 = value; - break; - case (31): - short31 = value; - break; - case (32): - short32 = value; - break; - case (33): - short33 = value; - break; - case (35): - short35 = value; - break; - case (36): - short36 = value; - break; - case (37): - short37 = value; - break; - case (38): - short38 = value; - break; - case (39): - short39 = value; - break; - case (40): - short40 = value; - break; - case (41): - short41 = value; - break; - case (42): - short42 = value; - break; - case (43): - short43 = value; - break; - case (44): - short44 = value; - break; - case (45): - short45 = value; - break; - case (46): - short46 = value; - break; - case (47): - short47 = value; - break; - case (48): - short48 = value; - break; - case (49): - short49 = value; - break; - case (50): - short50 = value; - break; - case (52): - short52 = value; - break; - case (53): - short53 = value; - break; - case (54): - short54 = value; - break; - case (55): - short55 = value; - break; - case (56): - short56 = value; - break; - case (57): - short57 = value; - break; - case (58): - short58 = value; - break; - case (59): - short59 = value; - break; - case (60): - short60 = value; - break; - case (62): - short62 = value; - break; - case (64): - short64 = value; - break; - case (65): - short65 = value; - break; - case (66): - short66 = value; - break; - case (67): - short67 = value; - break; - case (68): - short68 = value; - break; - case (69): - short69 = value; - break; - case (71): - short71 = value; - break; - case (72): - short72 = value; - break; - case (73): - short73 = value; - break; - case (74): - short74 = value; - break; - case (75): - short75 = value; - break; - case (76): - short76 = value; - break; - case (77): - short77 = value; - break; - case (78): - short78 = value; - break; - case (79): - short79 = value; - break; - case (80): - short80 = value; - break; - case (81): - short81 = value; - break; - case (82): - short82 = value; - break; - case (83): - short83 = value; - break; - case (84): - short84 = value; - break; - case (85): - short85 = value; - break; - case (86): - short86 = value; - break; - case (88): - short88 = value; - break; - case (89): - short89 = value; - break; - case (90): - short90 = value; - break; - case (91): - short91 = value; - break; - case (92): - short92 = value; - break; - case (93): - short93 = value; - break; - case (94): - short94 = value; - break; - case (95): - short95 = value; - break; - case (96): - short96 = value; - break; - case (98): - short98 = value; - break; - case (100): - short100 = value; - break; - case (101): - short101 = value; - break; - case (102): - short102 = value; - break; - case (103): - short103 = value; - break; - case (104): - short104 = value; - break; - case (105): - short105 = value; - break; - case (107): - short107 = value; - break; - case (108): - short108 = value; - break; - case (109): - short109 = value; - break; - case (110): - short110 = value; - break; - case (111): - short111 = value; - break; - case (112): - short112 = value; - break; - case (113): - short113 = value; - break; - case (114): - short114 = value; - break; - case (115): - short115 = value; - break; - case (116): - short116 = value; - break; - case (117): - short117 = value; - break; - case (118): - short118 = value; - break; - case (119): - short119 = value; - break; - case (120): - short120 = value; - break; - case (121): - short121 = value; - break; - case (122): - short122 = value; - break; - case (124): - short124 = value; - break; - case (125): - short125 = value; - break; - case (126): - short126 = value; - break; - case (127): - short127 = value; - break; - case (128): - short128 = value; - break; - case (129): - short129 = value; - break; - case (130): - short130 = value; - break; - case (131): - short131 = value; - break; - case (132): - short132 = value; - break; - case (134): - short134 = value; - break; - case (136): - short136 = value; - break; - case (137): - short137 = value; - break; - case (138): - short138 = value; - break; - case (139): - short139 = value; - break; - case (140): - short140 = value; - break; - case (141): - short141 = value; - break; - case (143): - short143 = value; - break; + public boolean set(int index,short value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + short0= value; + break; + case(1): + short1= value; + break; + case(2): + short2= value; + break; + case(3): + short3= value; + break; + case(4): + short4= value; + break; + case(5): + short5= value; + break; + case(6): + short6= value; + break; + case(7): + short7= value; + break; + case(8): + short8= value; + break; + case(9): + short9= value; + break; + case(10): + short10= value; + break; + case(11): + short11= value; + break; + case(12): + short12= value; + break; + case(13): + short13= value; + break; + case(14): + short14= value; + break; + case(16): + short16= value; + break; + case(17): + short17= value; + break; + case(18): + short18= value; + break; + case(19): + short19= value; + break; + case(20): + short20= value; + break; + case(21): + short21= value; + break; + case(22): + short22= value; + break; + case(23): + short23= value; + break; + case(24): + short24= value; + break; + case(26): + short26= value; + break; + case(28): + short28= value; + break; + case(29): + short29= value; + break; + case(30): + short30= value; + break; + case(31): + short31= value; + break; + case(32): + short32= value; + break; + case(33): + short33= value; + break; + case(35): + short35= value; + break; + case(36): + short36= value; + break; + case(37): + short37= value; + break; + case(38): + short38= value; + break; + case(39): + short39= value; + break; + case(40): + short40= value; + break; + case(41): + short41= value; + break; + case(42): + short42= value; + break; + case(43): + short43= value; + break; + case(44): + short44= value; + break; + case(45): + short45= value; + break; + case(46): + short46= value; + break; + case(47): + short47= value; + break; + case(48): + short48= value; + break; + case(49): + short49= value; + break; + case(50): + short50= value; + break; + case(52): + short52= value; + break; + case(53): + short53= value; + break; + case(54): + short54= value; + break; + case(55): + short55= value; + break; + case(56): + short56= value; + break; + case(57): + short57= value; + break; + case(58): + short58= value; + break; + case(59): + short59= value; + break; + case(60): + short60= value; + break; + case(62): + short62= value; + break; + case(64): + short64= value; + break; + case(65): + short65= value; + break; + case(66): + short66= value; + break; + case(67): + short67= value; + break; + case(68): + short68= value; + break; + case(69): + short69= value; + break; + case(71): + short71= value; + break; + case(72): + short72= value; + break; + case(73): + short73= value; + break; + case(74): + short74= value; + break; + case(75): + short75= value; + break; + case(76): + short76= value; + break; + case(77): + short77= value; + break; + case(78): + short78= value; + break; + case(79): + short79= value; + break; + case(80): + short80= value; + break; + case(81): + short81= value; + break; + case(82): + short82= value; + break; + case(83): + short83= value; + break; + case(84): + short84= value; + break; + case(85): + short85= value; + break; + case(86): + short86= value; + break; + case(88): + short88= value; + break; + case(89): + short89= value; + break; + case(90): + short90= value; + break; + case(91): + short91= value; + break; + case(92): + short92= value; + break; + case(93): + short93= value; + break; + case(94): + short94= value; + break; + case(95): + short95= value; + break; + case(96): + short96= value; + break; + case(98): + short98= value; + break; + case(100): + short100= value; + break; + case(101): + short101= value; + break; + case(102): + short102= value; + break; + case(103): + short103= value; + break; + case(104): + short104= value; + break; + case(105): + short105= value; + break; + case(107): + short107= value; + break; + case(108): + short108= value; + break; + case(109): + short109= value; + break; + case(110): + short110= value; + break; + case(111): + short111= value; + break; + case(112): + short112= value; + break; + case(113): + short113= value; + break; + case(114): + short114= value; + break; + case(115): + short115= value; + break; + case(116): + short116= value; + break; + case(117): + short117= value; + break; + case(118): + short118= value; + break; + case(119): + short119= value; + break; + case(120): + short120= value; + break; + case(121): + short121= value; + break; + case(122): + short122= value; + break; + case(124): + short124= value; + break; + case(125): + short125= value; + break; + case(126): + short126= value; + break; + case(127): + short127= value; + break; + case(128): + short128= value; + break; + case(129): + short129= value; + break; + case(130): + short130= value; + break; + case(131): + short131= value; + break; + case(132): + short132= value; + break; + case(134): + short134= value; + break; + case(136): + short136= value; + break; + case(137): + short137= value; + break; + case(138): + short138= value; + break; + case(139): + short139= value; + break; + case(140): + short140= value; + break; + case(141): + short141= value; + break; + case(143): + short143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfShort.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfShort.java index dce4acb99..9e7b2c574 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfShort.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfShort.java @@ -5,21 +5,21 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -public class FieldsOfShort { +public class FieldsOfShort { public int identifier; private Short Short0; private Short Short1; @@ -36,7 +36,7 @@ public class FieldsOfShort { private transient Short Short12; private transient Short Short13; private transient Short Short14; - private final Short Short15 = Short.valueOf((short) 5); + private final Short Short15 = Short.valueOf((short)5); private volatile Short Short16; private volatile Short Short17; private volatile Short Short18; @@ -46,16 +46,16 @@ public class FieldsOfShort { private volatile Short Short22; private volatile Short Short23; private static transient Short Short24; - private static final Short Short25 = Short.valueOf((short) 5); + private static final Short Short25 = Short.valueOf((short)5); private static volatile Short Short26; - private final transient Short Short27 = Short.valueOf((short) 5); + private transient final Short Short27 = Short.valueOf((short)5); private transient volatile Short Short28; private transient volatile Short Short29; private transient volatile Short Short30; private transient volatile Short Short31; private transient volatile Short Short32; private transient volatile Short Short33; - private static final transient Short Short34 = Short.valueOf((short) 5); + private static transient final Short Short34 = Short.valueOf((short)5); private static transient volatile Short Short35; public Short Short36; public Short Short37; @@ -72,7 +72,7 @@ public class FieldsOfShort { public transient Short Short48; public transient Short Short49; public transient Short Short50; - public final Short Short51 = Short.valueOf((short) 5); + public final Short Short51 = Short.valueOf((short)5); public volatile Short Short52; public volatile Short Short53; public volatile Short Short54; @@ -82,16 +82,16 @@ public class FieldsOfShort { public volatile Short Short58; public volatile Short Short59; public static transient Short Short60; - public static final Short Short61 = Short.valueOf((short) 5); + public static final Short Short61 = Short.valueOf((short)5); public static volatile Short Short62; - public final transient Short Short63 = Short.valueOf((short) 5); + public transient final Short Short63 = Short.valueOf((short)5); public transient volatile Short Short64; public transient volatile Short Short65; public transient volatile Short Short66; public transient volatile Short Short67; public transient volatile Short Short68; public transient volatile Short Short69; - public static final transient Short Short70 = Short.valueOf((short) 5); + public static transient final Short Short70 = Short.valueOf((short)5); public static transient volatile Short Short71; protected Short Short72; protected Short Short73; @@ -108,7 +108,7 @@ public class FieldsOfShort { protected transient Short Short84; protected transient Short Short85; protected transient Short Short86; - protected final Short Short87 = Short.valueOf((short) 5); + protected final Short Short87 = Short.valueOf((short)5); protected volatile Short Short88; protected volatile Short Short89; protected volatile Short Short90; @@ -118,16 +118,16 @@ public class FieldsOfShort { protected volatile Short Short94; protected volatile Short Short95; protected static transient Short Short96; - protected static final Short Short97 = Short.valueOf((short) 5); + protected static final Short Short97 = Short.valueOf((short)5); protected static volatile Short Short98; - protected final transient Short Short99 = Short.valueOf((short) 5); + protected transient final Short Short99 = Short.valueOf((short)5); protected transient volatile Short Short100; protected transient volatile Short Short101; protected transient volatile Short Short102; protected transient volatile Short Short103; protected transient volatile Short Short104; protected transient volatile Short Short105; - protected static final transient Short Short106 = Short.valueOf((short) 5); + protected static transient final Short Short106 = Short.valueOf((short)5); protected static transient volatile Short Short107; Short Short108; Short Short109; @@ -144,7 +144,7 @@ public class FieldsOfShort { transient Short Short120; transient Short Short121; transient Short Short122; - final Short Short123 = Short.valueOf((short) 5); + final Short Short123 = Short.valueOf((short)5); volatile Short Short124; volatile Short Short125; volatile Short Short126; @@ -154,938 +154,937 @@ public class FieldsOfShort { volatile Short Short130; volatile Short Short131; static transient Short Short132; - static final Short Short133 = Short.valueOf((short) 5); + static final Short Short133 = Short.valueOf((short)5); static volatile Short Short134; - final transient Short Short135 = Short.valueOf((short) 5); + transient final Short Short135 = Short.valueOf((short)5); transient volatile Short Short136; transient volatile Short Short137; transient volatile Short Short138; transient volatile Short Short139; transient volatile Short Short140; transient volatile Short Short141; - static final transient Short Short142 = Short.valueOf((short) 5); + static transient final Short Short142 = Short.valueOf((short)5); static transient volatile Short Short143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private Short Short0", - "embedded= true private Short Short1", - "embedded= false private Short Short2", - "persistence-modifier= none private Short Short3", - "persistence-modifier= persistent private Short Short4", - "persistence-modifier= persistent embedded= true private Short Short5", - "persistence-modifier= persistent embedded= false private Short Short6", - "persistence-modifier= transactional private Short Short7", - "private static Short Short8", - "private transient Short Short9", - "persistence-modifier= none private transient Short Short10", - "persistence-modifier= persistent private transient Short Short11", - "persistence-modifier= persistent embedded= true private transient Short Short12", - "persistence-modifier= persistent embedded= false private transient Short Short13", - "persistence-modifier= transactional private transient Short Short14", - "private final Short Short15", - "private volatile Short Short16", - "embedded= true private volatile Short Short17", - "embedded= false private volatile Short Short18", - "persistence-modifier= none private volatile Short Short19", - "persistence-modifier= persistent private volatile Short Short20", - "persistence-modifier= persistent embedded= true private volatile Short Short21", - "persistence-modifier= persistent embedded= false private volatile Short Short22", - "persistence-modifier= transactional private volatile Short Short23", - "private static transient Short Short24", - "private static final Short Short25", - "private static volatile Short Short26", - "private transient final Short Short27", - "private transient volatile Short Short28", - "persistence-modifier= none private transient volatile Short Short29", - "persistence-modifier= persistent private transient volatile Short Short30", - "persistence-modifier= persistent embedded= true private transient volatile Short Short31", - "persistence-modifier= persistent embedded= false private transient volatile Short Short32", - "persistence-modifier= transactional private transient volatile Short Short33", - "private static transient final Short Short34", - "private static transient volatile Short Short35", - "public Short Short36", - "embedded= true public Short Short37", - "embedded= false public Short Short38", - "persistence-modifier= none public Short Short39", - "persistence-modifier= persistent public Short Short40", - "persistence-modifier= persistent embedded= true public Short Short41", - "persistence-modifier= persistent embedded= false public Short Short42", - "persistence-modifier= transactional public Short Short43", - "public static Short Short44", - "public transient Short Short45", - "persistence-modifier= none public transient Short Short46", - "persistence-modifier= persistent public transient Short Short47", - "persistence-modifier= persistent embedded= true public transient Short Short48", - "persistence-modifier= persistent embedded= false public transient Short Short49", - "persistence-modifier= transactional public transient Short Short50", - "public final Short Short51", - "public volatile Short Short52", - "embedded= true public volatile Short Short53", - "embedded= false public volatile Short Short54", - "persistence-modifier= none public volatile Short Short55", - "persistence-modifier= persistent public volatile Short Short56", - "persistence-modifier= persistent embedded= true public volatile Short Short57", - "persistence-modifier= persistent embedded= false public volatile Short Short58", - "persistence-modifier= transactional public volatile Short Short59", - "public static transient Short Short60", - "public static final Short Short61", - "public static volatile Short Short62", - "public transient final Short Short63", - "public transient volatile Short Short64", - "persistence-modifier= none public transient volatile Short Short65", - "persistence-modifier= persistent public transient volatile Short Short66", - "persistence-modifier= persistent embedded= true public transient volatile Short Short67", - "persistence-modifier= persistent embedded= false public transient volatile Short Short68", - "persistence-modifier= transactional public transient volatile Short Short69", - "public static transient final Short Short70", - "public static transient volatile Short Short71", - "protected Short Short72", - "embedded= true protected Short Short73", - "embedded= false protected Short Short74", - "persistence-modifier= none protected Short Short75", - "persistence-modifier= persistent protected Short Short76", - "persistence-modifier= persistent embedded= true protected Short Short77", - "persistence-modifier= persistent embedded= false protected Short Short78", - "persistence-modifier= transactional protected Short Short79", - "protected static Short Short80", - "protected transient Short Short81", - "persistence-modifier= none protected transient Short Short82", - "persistence-modifier= persistent protected transient Short Short83", - "persistence-modifier= persistent embedded= true protected transient Short Short84", - "persistence-modifier= persistent embedded= false protected transient Short Short85", - "persistence-modifier= transactional protected transient Short Short86", - "protected final Short Short87", - "protected volatile Short Short88", - "embedded= true protected volatile Short Short89", - "embedded= false protected volatile Short Short90", - "persistence-modifier= none protected volatile Short Short91", - "persistence-modifier= persistent protected volatile Short Short92", - "persistence-modifier= persistent embedded= true protected volatile Short Short93", - "persistence-modifier= persistent embedded= false protected volatile Short Short94", - "persistence-modifier= transactional protected volatile Short Short95", - "protected static transient Short Short96", - "protected static final Short Short97", - "protected static volatile Short Short98", - "protected transient final Short Short99", - "protected transient volatile Short Short100", - "persistence-modifier= none protected transient volatile Short Short101", - "persistence-modifier= persistent protected transient volatile Short Short102", - "persistence-modifier= persistent embedded= true protected transient volatile Short Short103", - "persistence-modifier= persistent embedded= false protected transient volatile Short Short104", - "persistence-modifier= transactional protected transient volatile Short Short105", - "protected static transient final Short Short106", - "protected static transient volatile Short Short107", - "Short Short108", - "embedded= true Short Short109", - "embedded= false Short Short110", - "persistence-modifier= none Short Short111", - "persistence-modifier= persistent Short Short112", - "persistence-modifier= persistent embedded= true Short Short113", - "persistence-modifier= persistent embedded= false Short Short114", - "persistence-modifier= transactional Short Short115", - "static Short Short116", - "transient Short Short117", - "persistence-modifier= none transient Short Short118", - "persistence-modifier= persistent transient Short Short119", - "persistence-modifier= persistent embedded= true transient Short Short120", - "persistence-modifier= persistent embedded= false transient Short Short121", - "persistence-modifier= transactional transient Short Short122", - "final Short Short123", - "volatile Short Short124", - "embedded= true volatile Short Short125", - "embedded= false volatile Short Short126", - "persistence-modifier= none volatile Short Short127", - "persistence-modifier= persistent volatile Short Short128", - "persistence-modifier= persistent embedded= true volatile Short Short129", - "persistence-modifier= persistent embedded= false volatile Short Short130", - "persistence-modifier= transactional volatile Short Short131", - "static transient Short Short132", - "static final Short Short133", - "static volatile Short Short134", - "transient final Short Short135", - "transient volatile Short Short136", - "persistence-modifier= none transient volatile Short Short137", - "persistence-modifier= persistent transient volatile Short Short138", - "persistence-modifier= persistent embedded= true transient volatile Short Short139", - "persistence-modifier= persistent embedded= false transient volatile Short Short140", - "persistence-modifier= transactional transient volatile Short Short141", - "static transient final Short Short142", - "static transient volatile Short Short143" + public static final String [] fieldSpecs = { + "private Short Short0", + "embedded= true private Short Short1", + "embedded= false private Short Short2", + "persistence-modifier= none private Short Short3", + "persistence-modifier= persistent private Short Short4", + "persistence-modifier= persistent embedded= true private Short Short5", + "persistence-modifier= persistent embedded= false private Short Short6", + "persistence-modifier= transactional private Short Short7", + "private static Short Short8", + "private transient Short Short9", + "persistence-modifier= none private transient Short Short10", + "persistence-modifier= persistent private transient Short Short11", + "persistence-modifier= persistent embedded= true private transient Short Short12", + "persistence-modifier= persistent embedded= false private transient Short Short13", + "persistence-modifier= transactional private transient Short Short14", + "private final Short Short15", + "private volatile Short Short16", + "embedded= true private volatile Short Short17", + "embedded= false private volatile Short Short18", + "persistence-modifier= none private volatile Short Short19", + "persistence-modifier= persistent private volatile Short Short20", + "persistence-modifier= persistent embedded= true private volatile Short Short21", + "persistence-modifier= persistent embedded= false private volatile Short Short22", + "persistence-modifier= transactional private volatile Short Short23", + "private static transient Short Short24", + "private static final Short Short25", + "private static volatile Short Short26", + "private transient final Short Short27", + "private transient volatile Short Short28", + "persistence-modifier= none private transient volatile Short Short29", + "persistence-modifier= persistent private transient volatile Short Short30", + "persistence-modifier= persistent embedded= true private transient volatile Short Short31", + "persistence-modifier= persistent embedded= false private transient volatile Short Short32", + "persistence-modifier= transactional private transient volatile Short Short33", + "private static transient final Short Short34", + "private static transient volatile Short Short35", + "public Short Short36", + "embedded= true public Short Short37", + "embedded= false public Short Short38", + "persistence-modifier= none public Short Short39", + "persistence-modifier= persistent public Short Short40", + "persistence-modifier= persistent embedded= true public Short Short41", + "persistence-modifier= persistent embedded= false public Short Short42", + "persistence-modifier= transactional public Short Short43", + "public static Short Short44", + "public transient Short Short45", + "persistence-modifier= none public transient Short Short46", + "persistence-modifier= persistent public transient Short Short47", + "persistence-modifier= persistent embedded= true public transient Short Short48", + "persistence-modifier= persistent embedded= false public transient Short Short49", + "persistence-modifier= transactional public transient Short Short50", + "public final Short Short51", + "public volatile Short Short52", + "embedded= true public volatile Short Short53", + "embedded= false public volatile Short Short54", + "persistence-modifier= none public volatile Short Short55", + "persistence-modifier= persistent public volatile Short Short56", + "persistence-modifier= persistent embedded= true public volatile Short Short57", + "persistence-modifier= persistent embedded= false public volatile Short Short58", + "persistence-modifier= transactional public volatile Short Short59", + "public static transient Short Short60", + "public static final Short Short61", + "public static volatile Short Short62", + "public transient final Short Short63", + "public transient volatile Short Short64", + "persistence-modifier= none public transient volatile Short Short65", + "persistence-modifier= persistent public transient volatile Short Short66", + "persistence-modifier= persistent embedded= true public transient volatile Short Short67", + "persistence-modifier= persistent embedded= false public transient volatile Short Short68", + "persistence-modifier= transactional public transient volatile Short Short69", + "public static transient final Short Short70", + "public static transient volatile Short Short71", + "protected Short Short72", + "embedded= true protected Short Short73", + "embedded= false protected Short Short74", + "persistence-modifier= none protected Short Short75", + "persistence-modifier= persistent protected Short Short76", + "persistence-modifier= persistent embedded= true protected Short Short77", + "persistence-modifier= persistent embedded= false protected Short Short78", + "persistence-modifier= transactional protected Short Short79", + "protected static Short Short80", + "protected transient Short Short81", + "persistence-modifier= none protected transient Short Short82", + "persistence-modifier= persistent protected transient Short Short83", + "persistence-modifier= persistent embedded= true protected transient Short Short84", + "persistence-modifier= persistent embedded= false protected transient Short Short85", + "persistence-modifier= transactional protected transient Short Short86", + "protected final Short Short87", + "protected volatile Short Short88", + "embedded= true protected volatile Short Short89", + "embedded= false protected volatile Short Short90", + "persistence-modifier= none protected volatile Short Short91", + "persistence-modifier= persistent protected volatile Short Short92", + "persistence-modifier= persistent embedded= true protected volatile Short Short93", + "persistence-modifier= persistent embedded= false protected volatile Short Short94", + "persistence-modifier= transactional protected volatile Short Short95", + "protected static transient Short Short96", + "protected static final Short Short97", + "protected static volatile Short Short98", + "protected transient final Short Short99", + "protected transient volatile Short Short100", + "persistence-modifier= none protected transient volatile Short Short101", + "persistence-modifier= persistent protected transient volatile Short Short102", + "persistence-modifier= persistent embedded= true protected transient volatile Short Short103", + "persistence-modifier= persistent embedded= false protected transient volatile Short Short104", + "persistence-modifier= transactional protected transient volatile Short Short105", + "protected static transient final Short Short106", + "protected static transient volatile Short Short107", + "Short Short108", + "embedded= true Short Short109", + "embedded= false Short Short110", + "persistence-modifier= none Short Short111", + "persistence-modifier= persistent Short Short112", + "persistence-modifier= persistent embedded= true Short Short113", + "persistence-modifier= persistent embedded= false Short Short114", + "persistence-modifier= transactional Short Short115", + "static Short Short116", + "transient Short Short117", + "persistence-modifier= none transient Short Short118", + "persistence-modifier= persistent transient Short Short119", + "persistence-modifier= persistent embedded= true transient Short Short120", + "persistence-modifier= persistent embedded= false transient Short Short121", + "persistence-modifier= transactional transient Short Short122", + "final Short Short123", + "volatile Short Short124", + "embedded= true volatile Short Short125", + "embedded= false volatile Short Short126", + "persistence-modifier= none volatile Short Short127", + "persistence-modifier= persistent volatile Short Short128", + "persistence-modifier= persistent embedded= true volatile Short Short129", + "persistence-modifier= persistent embedded= false volatile Short Short130", + "persistence-modifier= transactional volatile Short Short131", + "static transient Short Short132", + "static final Short Short133", + "static volatile Short Short134", + "transient final Short Short135", + "transient volatile Short Short136", + "persistence-modifier= none transient volatile Short Short137", + "persistence-modifier= persistent transient volatile Short Short138", + "persistence-modifier= persistent embedded= true transient volatile Short Short139", + "persistence-modifier= persistent embedded= false transient volatile Short Short140", + "persistence-modifier= transactional transient volatile Short Short141", + "static transient final Short Short142", + "static transient volatile Short Short143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public Short get(int index) { - switch (index) { - case (0): + public Short get(int index) + { + switch (index) + { + case(0): return Short0; - case (1): + case(1): return Short1; - case (2): + case(2): return Short2; - case (3): + case(3): return Short3; - case (4): + case(4): return Short4; - case (5): + case(5): return Short5; - case (6): + case(6): return Short6; - case (7): + case(7): return Short7; - case (8): + case(8): return Short8; - case (9): + case(9): return Short9; - case (10): + case(10): return Short10; - case (11): + case(11): return Short11; - case (12): + case(12): return Short12; - case (13): + case(13): return Short13; - case (14): + case(14): return Short14; - case (15): + case(15): return Short15; - case (16): + case(16): return Short16; - case (17): + case(17): return Short17; - case (18): + case(18): return Short18; - case (19): + case(19): return Short19; - case (20): + case(20): return Short20; - case (21): + case(21): return Short21; - case (22): + case(22): return Short22; - case (23): + case(23): return Short23; - case (24): + case(24): return Short24; - case (25): + case(25): return Short25; - case (26): + case(26): return Short26; - case (27): + case(27): return Short27; - case (28): + case(28): return Short28; - case (29): + case(29): return Short29; - case (30): + case(30): return Short30; - case (31): + case(31): return Short31; - case (32): + case(32): return Short32; - case (33): + case(33): return Short33; - case (34): + case(34): return Short34; - case (35): + case(35): return Short35; - case (36): + case(36): return Short36; - case (37): + case(37): return Short37; - case (38): + case(38): return Short38; - case (39): + case(39): return Short39; - case (40): + case(40): return Short40; - case (41): + case(41): return Short41; - case (42): + case(42): return Short42; - case (43): + case(43): return Short43; - case (44): + case(44): return Short44; - case (45): + case(45): return Short45; - case (46): + case(46): return Short46; - case (47): + case(47): return Short47; - case (48): + case(48): return Short48; - case (49): + case(49): return Short49; - case (50): + case(50): return Short50; - case (51): + case(51): return Short51; - case (52): + case(52): return Short52; - case (53): + case(53): return Short53; - case (54): + case(54): return Short54; - case (55): + case(55): return Short55; - case (56): + case(56): return Short56; - case (57): + case(57): return Short57; - case (58): + case(58): return Short58; - case (59): + case(59): return Short59; - case (60): + case(60): return Short60; - case (61): + case(61): return Short61; - case (62): + case(62): return Short62; - case (63): + case(63): return Short63; - case (64): + case(64): return Short64; - case (65): + case(65): return Short65; - case (66): + case(66): return Short66; - case (67): + case(67): return Short67; - case (68): + case(68): return Short68; - case (69): + case(69): return Short69; - case (70): + case(70): return Short70; - case (71): + case(71): return Short71; - case (72): + case(72): return Short72; - case (73): + case(73): return Short73; - case (74): + case(74): return Short74; - case (75): + case(75): return Short75; - case (76): + case(76): return Short76; - case (77): + case(77): return Short77; - case (78): + case(78): return Short78; - case (79): + case(79): return Short79; - case (80): + case(80): return Short80; - case (81): + case(81): return Short81; - case (82): + case(82): return Short82; - case (83): + case(83): return Short83; - case (84): + case(84): return Short84; - case (85): + case(85): return Short85; - case (86): + case(86): return Short86; - case (87): + case(87): return Short87; - case (88): + case(88): return Short88; - case (89): + case(89): return Short89; - case (90): + case(90): return Short90; - case (91): + case(91): return Short91; - case (92): + case(92): return Short92; - case (93): + case(93): return Short93; - case (94): + case(94): return Short94; - case (95): + case(95): return Short95; - case (96): + case(96): return Short96; - case (97): + case(97): return Short97; - case (98): + case(98): return Short98; - case (99): + case(99): return Short99; - case (100): + case(100): return Short100; - case (101): + case(101): return Short101; - case (102): + case(102): return Short102; - case (103): + case(103): return Short103; - case (104): + case(104): return Short104; - case (105): + case(105): return Short105; - case (106): + case(106): return Short106; - case (107): + case(107): return Short107; - case (108): + case(108): return Short108; - case (109): + case(109): return Short109; - case (110): + case(110): return Short110; - case (111): + case(111): return Short111; - case (112): + case(112): return Short112; - case (113): + case(113): return Short113; - case (114): + case(114): return Short114; - case (115): + case(115): return Short115; - case (116): + case(116): return Short116; - case (117): + case(117): return Short117; - case (118): + case(118): return Short118; - case (119): + case(119): return Short119; - case (120): + case(120): return Short120; - case (121): + case(121): return Short121; - case (122): + case(122): return Short122; - case (123): + case(123): return Short123; - case (124): + case(124): return Short124; - case (125): + case(125): return Short125; - case (126): + case(126): return Short126; - case (127): + case(127): return Short127; - case (128): + case(128): return Short128; - case (129): + case(129): return Short129; - case (130): + case(130): return Short130; - case (131): + case(131): return Short131; - case (132): + case(132): return Short132; - case (133): + case(133): return Short133; - case (134): + case(134): return Short134; - case (135): + case(135): return Short135; - case (136): + case(136): return Short136; - case (137): + case(137): return Short137; - case (138): + case(138): return Short138; - case (139): + case(139): return Short139; - case (140): + case(140): return Short140; - case (141): + case(141): return Short141; - case (142): + case(142): return Short142; - case (143): + case(143): return Short143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, Short value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - Short0 = value; - break; - case (1): - Short1 = value; - break; - case (2): - Short2 = value; - break; - case (3): - Short3 = value; - break; - case (4): - Short4 = value; - break; - case (5): - Short5 = value; - break; - case (6): - Short6 = value; - break; - case (7): - Short7 = value; - break; - case (8): - Short8 = value; - break; - case (9): - Short9 = value; - break; - case (10): - Short10 = value; - break; - case (11): - Short11 = value; - break; - case (12): - Short12 = value; - break; - case (13): - Short13 = value; - break; - case (14): - Short14 = value; - break; - case (16): - Short16 = value; - break; - case (17): - Short17 = value; - break; - case (18): - Short18 = value; - break; - case (19): - Short19 = value; - break; - case (20): - Short20 = value; - break; - case (21): - Short21 = value; - break; - case (22): - Short22 = value; - break; - case (23): - Short23 = value; - break; - case (24): - Short24 = value; - break; - case (26): - Short26 = value; - break; - case (28): - Short28 = value; - break; - case (29): - Short29 = value; - break; - case (30): - Short30 = value; - break; - case (31): - Short31 = value; - break; - case (32): - Short32 = value; - break; - case (33): - Short33 = value; - break; - case (35): - Short35 = value; - break; - case (36): - Short36 = value; - break; - case (37): - Short37 = value; - break; - case (38): - Short38 = value; - break; - case (39): - Short39 = value; - break; - case (40): - Short40 = value; - break; - case (41): - Short41 = value; - break; - case (42): - Short42 = value; - break; - case (43): - Short43 = value; - break; - case (44): - Short44 = value; - break; - case (45): - Short45 = value; - break; - case (46): - Short46 = value; - break; - case (47): - Short47 = value; - break; - case (48): - Short48 = value; - break; - case (49): - Short49 = value; - break; - case (50): - Short50 = value; - break; - case (52): - Short52 = value; - break; - case (53): - Short53 = value; - break; - case (54): - Short54 = value; - break; - case (55): - Short55 = value; - break; - case (56): - Short56 = value; - break; - case (57): - Short57 = value; - break; - case (58): - Short58 = value; - break; - case (59): - Short59 = value; - break; - case (60): - Short60 = value; - break; - case (62): - Short62 = value; - break; - case (64): - Short64 = value; - break; - case (65): - Short65 = value; - break; - case (66): - Short66 = value; - break; - case (67): - Short67 = value; - break; - case (68): - Short68 = value; - break; - case (69): - Short69 = value; - break; - case (71): - Short71 = value; - break; - case (72): - Short72 = value; - break; - case (73): - Short73 = value; - break; - case (74): - Short74 = value; - break; - case (75): - Short75 = value; - break; - case (76): - Short76 = value; - break; - case (77): - Short77 = value; - break; - case (78): - Short78 = value; - break; - case (79): - Short79 = value; - break; - case (80): - Short80 = value; - break; - case (81): - Short81 = value; - break; - case (82): - Short82 = value; - break; - case (83): - Short83 = value; - break; - case (84): - Short84 = value; - break; - case (85): - Short85 = value; - break; - case (86): - Short86 = value; - break; - case (88): - Short88 = value; - break; - case (89): - Short89 = value; - break; - case (90): - Short90 = value; - break; - case (91): - Short91 = value; - break; - case (92): - Short92 = value; - break; - case (93): - Short93 = value; - break; - case (94): - Short94 = value; - break; - case (95): - Short95 = value; - break; - case (96): - Short96 = value; - break; - case (98): - Short98 = value; - break; - case (100): - Short100 = value; - break; - case (101): - Short101 = value; - break; - case (102): - Short102 = value; - break; - case (103): - Short103 = value; - break; - case (104): - Short104 = value; - break; - case (105): - Short105 = value; - break; - case (107): - Short107 = value; - break; - case (108): - Short108 = value; - break; - case (109): - Short109 = value; - break; - case (110): - Short110 = value; - break; - case (111): - Short111 = value; - break; - case (112): - Short112 = value; - break; - case (113): - Short113 = value; - break; - case (114): - Short114 = value; - break; - case (115): - Short115 = value; - break; - case (116): - Short116 = value; - break; - case (117): - Short117 = value; - break; - case (118): - Short118 = value; - break; - case (119): - Short119 = value; - break; - case (120): - Short120 = value; - break; - case (121): - Short121 = value; - break; - case (122): - Short122 = value; - break; - case (124): - Short124 = value; - break; - case (125): - Short125 = value; - break; - case (126): - Short126 = value; - break; - case (127): - Short127 = value; - break; - case (128): - Short128 = value; - break; - case (129): - Short129 = value; - break; - case (130): - Short130 = value; - break; - case (131): - Short131 = value; - break; - case (132): - Short132 = value; - break; - case (134): - Short134 = value; - break; - case (136): - Short136 = value; - break; - case (137): - Short137 = value; - break; - case (138): - Short138 = value; - break; - case (139): - Short139 = value; - break; - case (140): - Short140 = value; - break; - case (141): - Short141 = value; - break; - case (143): - Short143 = value; - break; + public boolean set(int index,Short value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + Short0= value; + break; + case(1): + Short1= value; + break; + case(2): + Short2= value; + break; + case(3): + Short3= value; + break; + case(4): + Short4= value; + break; + case(5): + Short5= value; + break; + case(6): + Short6= value; + break; + case(7): + Short7= value; + break; + case(8): + Short8= value; + break; + case(9): + Short9= value; + break; + case(10): + Short10= value; + break; + case(11): + Short11= value; + break; + case(12): + Short12= value; + break; + case(13): + Short13= value; + break; + case(14): + Short14= value; + break; + case(16): + Short16= value; + break; + case(17): + Short17= value; + break; + case(18): + Short18= value; + break; + case(19): + Short19= value; + break; + case(20): + Short20= value; + break; + case(21): + Short21= value; + break; + case(22): + Short22= value; + break; + case(23): + Short23= value; + break; + case(24): + Short24= value; + break; + case(26): + Short26= value; + break; + case(28): + Short28= value; + break; + case(29): + Short29= value; + break; + case(30): + Short30= value; + break; + case(31): + Short31= value; + break; + case(32): + Short32= value; + break; + case(33): + Short33= value; + break; + case(35): + Short35= value; + break; + case(36): + Short36= value; + break; + case(37): + Short37= value; + break; + case(38): + Short38= value; + break; + case(39): + Short39= value; + break; + case(40): + Short40= value; + break; + case(41): + Short41= value; + break; + case(42): + Short42= value; + break; + case(43): + Short43= value; + break; + case(44): + Short44= value; + break; + case(45): + Short45= value; + break; + case(46): + Short46= value; + break; + case(47): + Short47= value; + break; + case(48): + Short48= value; + break; + case(49): + Short49= value; + break; + case(50): + Short50= value; + break; + case(52): + Short52= value; + break; + case(53): + Short53= value; + break; + case(54): + Short54= value; + break; + case(55): + Short55= value; + break; + case(56): + Short56= value; + break; + case(57): + Short57= value; + break; + case(58): + Short58= value; + break; + case(59): + Short59= value; + break; + case(60): + Short60= value; + break; + case(62): + Short62= value; + break; + case(64): + Short64= value; + break; + case(65): + Short65= value; + break; + case(66): + Short66= value; + break; + case(67): + Short67= value; + break; + case(68): + Short68= value; + break; + case(69): + Short69= value; + break; + case(71): + Short71= value; + break; + case(72): + Short72= value; + break; + case(73): + Short73= value; + break; + case(74): + Short74= value; + break; + case(75): + Short75= value; + break; + case(76): + Short76= value; + break; + case(77): + Short77= value; + break; + case(78): + Short78= value; + break; + case(79): + Short79= value; + break; + case(80): + Short80= value; + break; + case(81): + Short81= value; + break; + case(82): + Short82= value; + break; + case(83): + Short83= value; + break; + case(84): + Short84= value; + break; + case(85): + Short85= value; + break; + case(86): + Short86= value; + break; + case(88): + Short88= value; + break; + case(89): + Short89= value; + break; + case(90): + Short90= value; + break; + case(91): + Short91= value; + break; + case(92): + Short92= value; + break; + case(93): + Short93= value; + break; + case(94): + Short94= value; + break; + case(95): + Short95= value; + break; + case(96): + Short96= value; + break; + case(98): + Short98= value; + break; + case(100): + Short100= value; + break; + case(101): + Short101= value; + break; + case(102): + Short102= value; + break; + case(103): + Short103= value; + break; + case(104): + Short104= value; + break; + case(105): + Short105= value; + break; + case(107): + Short107= value; + break; + case(108): + Short108= value; + break; + case(109): + Short109= value; + break; + case(110): + Short110= value; + break; + case(111): + Short111= value; + break; + case(112): + Short112= value; + break; + case(113): + Short113= value; + break; + case(114): + Short114= value; + break; + case(115): + Short115= value; + break; + case(116): + Short116= value; + break; + case(117): + Short117= value; + break; + case(118): + Short118= value; + break; + case(119): + Short119= value; + break; + case(120): + Short120= value; + break; + case(121): + Short121= value; + break; + case(122): + Short122= value; + break; + case(124): + Short124= value; + break; + case(125): + Short125= value; + break; + case(126): + Short126= value; + break; + case(127): + Short127= value; + break; + case(128): + Short128= value; + break; + case(129): + Short129= value; + break; + case(130): + Short130= value; + break; + case(131): + Short131= value; + break; + case(132): + Short132= value; + break; + case(134): + Short134= value; + break; + case(136): + Short136= value; + break; + case(137): + Short137= value; + break; + case(138): + Short138= value; + break; + case(139): + Short139= value; + break; + case(140): + Short140= value; + break; + case(141): + Short141= value; + break; + case(143): + Short143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfSimpleClass.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfSimpleClass.java index c3075f837..dbd54a4b7 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfSimpleClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfSimpleClass.java @@ -5,21 +5,21 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -public class FieldsOfSimpleClass { +public class FieldsOfSimpleClass { public int identifier; private SimpleClass SimpleClass0; private SimpleClass SimpleClass1; @@ -48,14 +48,14 @@ public class FieldsOfSimpleClass { private static transient SimpleClass SimpleClass24; private static final SimpleClass SimpleClass25 = new SimpleClass(); private static volatile SimpleClass SimpleClass26; - private final transient SimpleClass SimpleClass27 = new SimpleClass(); + private transient final SimpleClass SimpleClass27 = new SimpleClass(); private transient volatile SimpleClass SimpleClass28; private transient volatile SimpleClass SimpleClass29; private transient volatile SimpleClass SimpleClass30; private transient volatile SimpleClass SimpleClass31; private transient volatile SimpleClass SimpleClass32; private transient volatile SimpleClass SimpleClass33; - private static final transient SimpleClass SimpleClass34 = new SimpleClass(); + private static transient final SimpleClass SimpleClass34 = new SimpleClass(); private static transient volatile SimpleClass SimpleClass35; public SimpleClass SimpleClass36; public SimpleClass SimpleClass37; @@ -84,14 +84,14 @@ public class FieldsOfSimpleClass { public static transient SimpleClass SimpleClass60; public static final SimpleClass SimpleClass61 = new SimpleClass(); public static volatile SimpleClass SimpleClass62; - public final transient SimpleClass SimpleClass63 = new SimpleClass(); + public transient final SimpleClass SimpleClass63 = new SimpleClass(); public transient volatile SimpleClass SimpleClass64; public transient volatile SimpleClass SimpleClass65; public transient volatile SimpleClass SimpleClass66; public transient volatile SimpleClass SimpleClass67; public transient volatile SimpleClass SimpleClass68; public transient volatile SimpleClass SimpleClass69; - public static final transient SimpleClass SimpleClass70 = new SimpleClass(); + public static transient final SimpleClass SimpleClass70 = new SimpleClass(); public static transient volatile SimpleClass SimpleClass71; protected SimpleClass SimpleClass72; protected SimpleClass SimpleClass73; @@ -120,14 +120,14 @@ public class FieldsOfSimpleClass { protected static transient SimpleClass SimpleClass96; protected static final SimpleClass SimpleClass97 = new SimpleClass(); protected static volatile SimpleClass SimpleClass98; - protected final transient SimpleClass SimpleClass99 = new SimpleClass(); + protected transient final SimpleClass SimpleClass99 = new SimpleClass(); protected transient volatile SimpleClass SimpleClass100; protected transient volatile SimpleClass SimpleClass101; protected transient volatile SimpleClass SimpleClass102; protected transient volatile SimpleClass SimpleClass103; protected transient volatile SimpleClass SimpleClass104; protected transient volatile SimpleClass SimpleClass105; - protected static final transient SimpleClass SimpleClass106 = new SimpleClass(); + protected static transient final SimpleClass SimpleClass106 = new SimpleClass(); protected static transient volatile SimpleClass SimpleClass107; SimpleClass SimpleClass108; SimpleClass SimpleClass109; @@ -156,14 +156,14 @@ public class FieldsOfSimpleClass { static transient SimpleClass SimpleClass132; static final SimpleClass SimpleClass133 = new SimpleClass(); static volatile SimpleClass SimpleClass134; - final transient SimpleClass SimpleClass135 = new SimpleClass(); + transient final SimpleClass SimpleClass135 = new SimpleClass(); transient volatile SimpleClass SimpleClass136; transient volatile SimpleClass SimpleClass137; transient volatile SimpleClass SimpleClass138; transient volatile SimpleClass SimpleClass139; transient volatile SimpleClass SimpleClass140; transient volatile SimpleClass SimpleClass141; - static final transient SimpleClass SimpleClass142 = new SimpleClass(); + static transient final SimpleClass SimpleClass142 = new SimpleClass(); static transient volatile SimpleClass SimpleClass143; private SimpleClass SimpleClass144; private SimpleClass SimpleClass145; @@ -190,1076 +190,1076 @@ public class FieldsOfSimpleClass { volatile SimpleClass SimpleClass166; transient volatile SimpleClass SimpleClass167; - public static final boolean[] isPersistent = { - false, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false, true, true, true, true, true, true, - true, true, true, true, true, true, true, true, true, true, - true, true, true, true, true, true, true, true - }; +public static final boolean [] isPersistent = { +false, true, true, false, true, true, true, false, false, false, +false, true, true, true, false, false, true, true, true, false, +true, true, true, false, false, false, false, false, false, false, +true, true, true, false, false, false, false, true, true, false, +true, true, true, false, false, false, false, true, true, true, +false, false, true, true, true, false, true, true, true, false, +false, false, false, false, false, false, true, true, true, false, +false, false, false, true, true, false, true, true, true, false, +false, false, false, true, true, true, false, false, true, true, +true, false, true, true, true, false, false, false, false, false, +false, false, true, true, true, false, false, false, false, true, +true, false, true, true, true, false, false, false, false, true, +true, true, false, false, true, true, true, false, true, true, +true, false, false, false, false, false, false, false, true, true, +true, false, false, false, true, true, true, true, true, true, +true, true, true, true, true, true, true, true, true, true, +true, true, true, true, true, true, true, true + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true,false,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,false + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,false + }; - public static final String[] fieldSpecs = { - "private SimpleClass SimpleClass0", - "embedded= true private SimpleClass SimpleClass1", - "embedded= false private SimpleClass SimpleClass2", - "persistence-modifier= none private SimpleClass SimpleClass3", - "persistence-modifier= persistent private SimpleClass SimpleClass4", - "persistence-modifier= persistent embedded= true private SimpleClass SimpleClass5", - "persistence-modifier= persistent embedded= false private SimpleClass SimpleClass6", - "persistence-modifier= transactional private SimpleClass SimpleClass7", - "private static SimpleClass SimpleClass8", - "private transient SimpleClass SimpleClass9", - "persistence-modifier= none private transient SimpleClass SimpleClass10", - "persistence-modifier= persistent private transient SimpleClass SimpleClass11", - "persistence-modifier= persistent embedded= true private transient SimpleClass SimpleClass12", - "persistence-modifier= persistent embedded= false private transient SimpleClass SimpleClass13", - "persistence-modifier= transactional private transient SimpleClass SimpleClass14", - "private final SimpleClass SimpleClass15", - "private volatile SimpleClass SimpleClass16", - "embedded= true private volatile SimpleClass SimpleClass17", - "embedded= false private volatile SimpleClass SimpleClass18", - "persistence-modifier= none private volatile SimpleClass SimpleClass19", - "persistence-modifier= persistent private volatile SimpleClass SimpleClass20", - "persistence-modifier= persistent embedded= true private volatile SimpleClass SimpleClass21", - "persistence-modifier= persistent embedded= false private volatile SimpleClass SimpleClass22", - "persistence-modifier= transactional private volatile SimpleClass SimpleClass23", - "private static transient SimpleClass SimpleClass24", - "private static final SimpleClass SimpleClass25", - "private static volatile SimpleClass SimpleClass26", - "private transient final SimpleClass SimpleClass27", - "private transient volatile SimpleClass SimpleClass28", - "persistence-modifier= none private transient volatile SimpleClass SimpleClass29", - "persistence-modifier= persistent private transient volatile SimpleClass SimpleClass30", - "persistence-modifier= persistent embedded= true private transient volatile SimpleClass SimpleClass31", - "persistence-modifier= persistent embedded= false private transient volatile SimpleClass SimpleClass32", - "persistence-modifier= transactional private transient volatile SimpleClass SimpleClass33", - "private static transient final SimpleClass SimpleClass34", - "private static transient volatile SimpleClass SimpleClass35", - "public SimpleClass SimpleClass36", - "embedded= true public SimpleClass SimpleClass37", - "embedded= false public SimpleClass SimpleClass38", - "persistence-modifier= none public SimpleClass SimpleClass39", - "persistence-modifier= persistent public SimpleClass SimpleClass40", - "persistence-modifier= persistent embedded= true public SimpleClass SimpleClass41", - "persistence-modifier= persistent embedded= false public SimpleClass SimpleClass42", - "persistence-modifier= transactional public SimpleClass SimpleClass43", - "public static SimpleClass SimpleClass44", - "public transient SimpleClass SimpleClass45", - "persistence-modifier= none public transient SimpleClass SimpleClass46", - "persistence-modifier= persistent public transient SimpleClass SimpleClass47", - "persistence-modifier= persistent embedded= true public transient SimpleClass SimpleClass48", - "persistence-modifier= persistent embedded= false public transient SimpleClass SimpleClass49", - "persistence-modifier= transactional public transient SimpleClass SimpleClass50", - "public final SimpleClass SimpleClass51", - "public volatile SimpleClass SimpleClass52", - "embedded= true public volatile SimpleClass SimpleClass53", - "embedded= false public volatile SimpleClass SimpleClass54", - "persistence-modifier= none public volatile SimpleClass SimpleClass55", - "persistence-modifier= persistent public volatile SimpleClass SimpleClass56", - "persistence-modifier= persistent embedded= true public volatile SimpleClass SimpleClass57", - "persistence-modifier= persistent embedded= false public volatile SimpleClass SimpleClass58", - "persistence-modifier= transactional public volatile SimpleClass SimpleClass59", - "public static transient SimpleClass SimpleClass60", - "public static final SimpleClass SimpleClass61", - "public static volatile SimpleClass SimpleClass62", - "public transient final SimpleClass SimpleClass63", - "public transient volatile SimpleClass SimpleClass64", - "persistence-modifier= none public transient volatile SimpleClass SimpleClass65", - "persistence-modifier= persistent public transient volatile SimpleClass SimpleClass66", - "persistence-modifier= persistent embedded= true public transient volatile SimpleClass SimpleClass67", - "persistence-modifier= persistent embedded= false public transient volatile SimpleClass SimpleClass68", - "persistence-modifier= transactional public transient volatile SimpleClass SimpleClass69", - "public static transient final SimpleClass SimpleClass70", - "public static transient volatile SimpleClass SimpleClass71", - "protected SimpleClass SimpleClass72", - "embedded= true protected SimpleClass SimpleClass73", - "embedded= false protected SimpleClass SimpleClass74", - "persistence-modifier= none protected SimpleClass SimpleClass75", - "persistence-modifier= persistent protected SimpleClass SimpleClass76", - "persistence-modifier= persistent embedded= true protected SimpleClass SimpleClass77", - "persistence-modifier= persistent embedded= false protected SimpleClass SimpleClass78", - "persistence-modifier= transactional protected SimpleClass SimpleClass79", - "protected static SimpleClass SimpleClass80", - "protected transient SimpleClass SimpleClass81", - "persistence-modifier= none protected transient SimpleClass SimpleClass82", - "persistence-modifier= persistent protected transient SimpleClass SimpleClass83", - "persistence-modifier= persistent embedded= true protected transient SimpleClass SimpleClass84", - "persistence-modifier= persistent embedded= false protected transient SimpleClass SimpleClass85", - "persistence-modifier= transactional protected transient SimpleClass SimpleClass86", - "protected final SimpleClass SimpleClass87", - "protected volatile SimpleClass SimpleClass88", - "embedded= true protected volatile SimpleClass SimpleClass89", - "embedded= false protected volatile SimpleClass SimpleClass90", - "persistence-modifier= none protected volatile SimpleClass SimpleClass91", - "persistence-modifier= persistent protected volatile SimpleClass SimpleClass92", - "persistence-modifier= persistent embedded= true protected volatile SimpleClass SimpleClass93", - "persistence-modifier= persistent embedded= false protected volatile SimpleClass SimpleClass94", - "persistence-modifier= transactional protected volatile SimpleClass SimpleClass95", - "protected static transient SimpleClass SimpleClass96", - "protected static final SimpleClass SimpleClass97", - "protected static volatile SimpleClass SimpleClass98", - "protected transient final SimpleClass SimpleClass99", - "protected transient volatile SimpleClass SimpleClass100", - "persistence-modifier= none protected transient volatile SimpleClass SimpleClass101", - "persistence-modifier= persistent protected transient volatile SimpleClass SimpleClass102", - "persistence-modifier= persistent embedded= true protected transient volatile SimpleClass SimpleClass103", - "persistence-modifier= persistent embedded= false protected transient volatile SimpleClass SimpleClass104", - "persistence-modifier= transactional protected transient volatile SimpleClass SimpleClass105", - "protected static transient final SimpleClass SimpleClass106", - "protected static transient volatile SimpleClass SimpleClass107", - "SimpleClass SimpleClass108", - "embedded= true SimpleClass SimpleClass109", - "embedded= false SimpleClass SimpleClass110", - "persistence-modifier= none SimpleClass SimpleClass111", - "persistence-modifier= persistent SimpleClass SimpleClass112", - "persistence-modifier= persistent embedded= true SimpleClass SimpleClass113", - "persistence-modifier= persistent embedded= false SimpleClass SimpleClass114", - "persistence-modifier= transactional SimpleClass SimpleClass115", - "static SimpleClass SimpleClass116", - "transient SimpleClass SimpleClass117", - "persistence-modifier= none transient SimpleClass SimpleClass118", - "persistence-modifier= persistent transient SimpleClass SimpleClass119", - "persistence-modifier= persistent embedded= true transient SimpleClass SimpleClass120", - "persistence-modifier= persistent embedded= false transient SimpleClass SimpleClass121", - "persistence-modifier= transactional transient SimpleClass SimpleClass122", - "final SimpleClass SimpleClass123", - "volatile SimpleClass SimpleClass124", - "embedded= true volatile SimpleClass SimpleClass125", - "embedded= false volatile SimpleClass SimpleClass126", - "persistence-modifier= none volatile SimpleClass SimpleClass127", - "persistence-modifier= persistent volatile SimpleClass SimpleClass128", - "persistence-modifier= persistent embedded= true volatile SimpleClass SimpleClass129", - "persistence-modifier= persistent embedded= false volatile SimpleClass SimpleClass130", - "persistence-modifier= transactional volatile SimpleClass SimpleClass131", - "static transient SimpleClass SimpleClass132", - "static final SimpleClass SimpleClass133", - "static volatile SimpleClass SimpleClass134", - "transient final SimpleClass SimpleClass135", - "transient volatile SimpleClass SimpleClass136", - "persistence-modifier= none transient volatile SimpleClass SimpleClass137", - "persistence-modifier= persistent transient volatile SimpleClass SimpleClass138", - "persistence-modifier= persistent embedded= true transient volatile SimpleClass SimpleClass139", - "persistence-modifier= persistent embedded= false transient volatile SimpleClass SimpleClass140", - "persistence-modifier= transactional transient volatile SimpleClass SimpleClass141", - "static transient final SimpleClass SimpleClass142", - "static transient volatile SimpleClass SimpleClass143", - "serialized= true private SimpleClass SimpleClass144", - "persistence-modifier= persistent serialized= true private SimpleClass SimpleClass145", - "persistence-modifier= persistent serialized= true private transient SimpleClass SimpleClass146", - "serialized= true private volatile SimpleClass SimpleClass147", - "persistence-modifier= persistent serialized= true private volatile SimpleClass SimpleClass148", - "persistence-modifier= persistent serialized= true private transient volatile SimpleClass SimpleClass149", - "serialized= true public SimpleClass SimpleClass150", - "persistence-modifier= persistent serialized= true public SimpleClass SimpleClass151", - "persistence-modifier= persistent serialized= true public transient SimpleClass SimpleClass152", - "serialized= true public volatile SimpleClass SimpleClass153", - "persistence-modifier= persistent serialized= true public volatile SimpleClass SimpleClass154", - "persistence-modifier= persistent serialized= true public transient volatile SimpleClass SimpleClass155", - "serialized= true protected SimpleClass SimpleClass156", - "persistence-modifier= persistent serialized= true protected SimpleClass SimpleClass157", - "persistence-modifier= persistent serialized= true protected transient SimpleClass SimpleClass158", - "serialized= true protected volatile SimpleClass SimpleClass159", - "persistence-modifier= persistent serialized= true protected volatile SimpleClass SimpleClass160", - "persistence-modifier= persistent serialized= true protected transient volatile SimpleClass SimpleClass161", - "serialized= true SimpleClass SimpleClass162", - "persistence-modifier= persistent serialized= true SimpleClass SimpleClass163", - "persistence-modifier= persistent serialized= true transient SimpleClass SimpleClass164", - "serialized= true volatile SimpleClass SimpleClass165", - "persistence-modifier= persistent serialized= true volatile SimpleClass SimpleClass166", - "persistence-modifier= persistent serialized= true transient volatile SimpleClass SimpleClass167" + public static final String [] fieldSpecs = { + "private SimpleClass SimpleClass0", + "embedded= true private SimpleClass SimpleClass1", + "embedded= false private SimpleClass SimpleClass2", + "persistence-modifier= none private SimpleClass SimpleClass3", + "persistence-modifier= persistent private SimpleClass SimpleClass4", + "persistence-modifier= persistent embedded= true private SimpleClass SimpleClass5", + "persistence-modifier= persistent embedded= false private SimpleClass SimpleClass6", + "persistence-modifier= transactional private SimpleClass SimpleClass7", + "private static SimpleClass SimpleClass8", + "private transient SimpleClass SimpleClass9", + "persistence-modifier= none private transient SimpleClass SimpleClass10", + "persistence-modifier= persistent private transient SimpleClass SimpleClass11", + "persistence-modifier= persistent embedded= true private transient SimpleClass SimpleClass12", + "persistence-modifier= persistent embedded= false private transient SimpleClass SimpleClass13", + "persistence-modifier= transactional private transient SimpleClass SimpleClass14", + "private final SimpleClass SimpleClass15", + "private volatile SimpleClass SimpleClass16", + "embedded= true private volatile SimpleClass SimpleClass17", + "embedded= false private volatile SimpleClass SimpleClass18", + "persistence-modifier= none private volatile SimpleClass SimpleClass19", + "persistence-modifier= persistent private volatile SimpleClass SimpleClass20", + "persistence-modifier= persistent embedded= true private volatile SimpleClass SimpleClass21", + "persistence-modifier= persistent embedded= false private volatile SimpleClass SimpleClass22", + "persistence-modifier= transactional private volatile SimpleClass SimpleClass23", + "private static transient SimpleClass SimpleClass24", + "private static final SimpleClass SimpleClass25", + "private static volatile SimpleClass SimpleClass26", + "private transient final SimpleClass SimpleClass27", + "private transient volatile SimpleClass SimpleClass28", + "persistence-modifier= none private transient volatile SimpleClass SimpleClass29", + "persistence-modifier= persistent private transient volatile SimpleClass SimpleClass30", + "persistence-modifier= persistent embedded= true private transient volatile SimpleClass SimpleClass31", + "persistence-modifier= persistent embedded= false private transient volatile SimpleClass SimpleClass32", + "persistence-modifier= transactional private transient volatile SimpleClass SimpleClass33", + "private static transient final SimpleClass SimpleClass34", + "private static transient volatile SimpleClass SimpleClass35", + "public SimpleClass SimpleClass36", + "embedded= true public SimpleClass SimpleClass37", + "embedded= false public SimpleClass SimpleClass38", + "persistence-modifier= none public SimpleClass SimpleClass39", + "persistence-modifier= persistent public SimpleClass SimpleClass40", + "persistence-modifier= persistent embedded= true public SimpleClass SimpleClass41", + "persistence-modifier= persistent embedded= false public SimpleClass SimpleClass42", + "persistence-modifier= transactional public SimpleClass SimpleClass43", + "public static SimpleClass SimpleClass44", + "public transient SimpleClass SimpleClass45", + "persistence-modifier= none public transient SimpleClass SimpleClass46", + "persistence-modifier= persistent public transient SimpleClass SimpleClass47", + "persistence-modifier= persistent embedded= true public transient SimpleClass SimpleClass48", + "persistence-modifier= persistent embedded= false public transient SimpleClass SimpleClass49", + "persistence-modifier= transactional public transient SimpleClass SimpleClass50", + "public final SimpleClass SimpleClass51", + "public volatile SimpleClass SimpleClass52", + "embedded= true public volatile SimpleClass SimpleClass53", + "embedded= false public volatile SimpleClass SimpleClass54", + "persistence-modifier= none public volatile SimpleClass SimpleClass55", + "persistence-modifier= persistent public volatile SimpleClass SimpleClass56", + "persistence-modifier= persistent embedded= true public volatile SimpleClass SimpleClass57", + "persistence-modifier= persistent embedded= false public volatile SimpleClass SimpleClass58", + "persistence-modifier= transactional public volatile SimpleClass SimpleClass59", + "public static transient SimpleClass SimpleClass60", + "public static final SimpleClass SimpleClass61", + "public static volatile SimpleClass SimpleClass62", + "public transient final SimpleClass SimpleClass63", + "public transient volatile SimpleClass SimpleClass64", + "persistence-modifier= none public transient volatile SimpleClass SimpleClass65", + "persistence-modifier= persistent public transient volatile SimpleClass SimpleClass66", + "persistence-modifier= persistent embedded= true public transient volatile SimpleClass SimpleClass67", + "persistence-modifier= persistent embedded= false public transient volatile SimpleClass SimpleClass68", + "persistence-modifier= transactional public transient volatile SimpleClass SimpleClass69", + "public static transient final SimpleClass SimpleClass70", + "public static transient volatile SimpleClass SimpleClass71", + "protected SimpleClass SimpleClass72", + "embedded= true protected SimpleClass SimpleClass73", + "embedded= false protected SimpleClass SimpleClass74", + "persistence-modifier= none protected SimpleClass SimpleClass75", + "persistence-modifier= persistent protected SimpleClass SimpleClass76", + "persistence-modifier= persistent embedded= true protected SimpleClass SimpleClass77", + "persistence-modifier= persistent embedded= false protected SimpleClass SimpleClass78", + "persistence-modifier= transactional protected SimpleClass SimpleClass79", + "protected static SimpleClass SimpleClass80", + "protected transient SimpleClass SimpleClass81", + "persistence-modifier= none protected transient SimpleClass SimpleClass82", + "persistence-modifier= persistent protected transient SimpleClass SimpleClass83", + "persistence-modifier= persistent embedded= true protected transient SimpleClass SimpleClass84", + "persistence-modifier= persistent embedded= false protected transient SimpleClass SimpleClass85", + "persistence-modifier= transactional protected transient SimpleClass SimpleClass86", + "protected final SimpleClass SimpleClass87", + "protected volatile SimpleClass SimpleClass88", + "embedded= true protected volatile SimpleClass SimpleClass89", + "embedded= false protected volatile SimpleClass SimpleClass90", + "persistence-modifier= none protected volatile SimpleClass SimpleClass91", + "persistence-modifier= persistent protected volatile SimpleClass SimpleClass92", + "persistence-modifier= persistent embedded= true protected volatile SimpleClass SimpleClass93", + "persistence-modifier= persistent embedded= false protected volatile SimpleClass SimpleClass94", + "persistence-modifier= transactional protected volatile SimpleClass SimpleClass95", + "protected static transient SimpleClass SimpleClass96", + "protected static final SimpleClass SimpleClass97", + "protected static volatile SimpleClass SimpleClass98", + "protected transient final SimpleClass SimpleClass99", + "protected transient volatile SimpleClass SimpleClass100", + "persistence-modifier= none protected transient volatile SimpleClass SimpleClass101", + "persistence-modifier= persistent protected transient volatile SimpleClass SimpleClass102", + "persistence-modifier= persistent embedded= true protected transient volatile SimpleClass SimpleClass103", + "persistence-modifier= persistent embedded= false protected transient volatile SimpleClass SimpleClass104", + "persistence-modifier= transactional protected transient volatile SimpleClass SimpleClass105", + "protected static transient final SimpleClass SimpleClass106", + "protected static transient volatile SimpleClass SimpleClass107", + "SimpleClass SimpleClass108", + "embedded= true SimpleClass SimpleClass109", + "embedded= false SimpleClass SimpleClass110", + "persistence-modifier= none SimpleClass SimpleClass111", + "persistence-modifier= persistent SimpleClass SimpleClass112", + "persistence-modifier= persistent embedded= true SimpleClass SimpleClass113", + "persistence-modifier= persistent embedded= false SimpleClass SimpleClass114", + "persistence-modifier= transactional SimpleClass SimpleClass115", + "static SimpleClass SimpleClass116", + "transient SimpleClass SimpleClass117", + "persistence-modifier= none transient SimpleClass SimpleClass118", + "persistence-modifier= persistent transient SimpleClass SimpleClass119", + "persistence-modifier= persistent embedded= true transient SimpleClass SimpleClass120", + "persistence-modifier= persistent embedded= false transient SimpleClass SimpleClass121", + "persistence-modifier= transactional transient SimpleClass SimpleClass122", + "final SimpleClass SimpleClass123", + "volatile SimpleClass SimpleClass124", + "embedded= true volatile SimpleClass SimpleClass125", + "embedded= false volatile SimpleClass SimpleClass126", + "persistence-modifier= none volatile SimpleClass SimpleClass127", + "persistence-modifier= persistent volatile SimpleClass SimpleClass128", + "persistence-modifier= persistent embedded= true volatile SimpleClass SimpleClass129", + "persistence-modifier= persistent embedded= false volatile SimpleClass SimpleClass130", + "persistence-modifier= transactional volatile SimpleClass SimpleClass131", + "static transient SimpleClass SimpleClass132", + "static final SimpleClass SimpleClass133", + "static volatile SimpleClass SimpleClass134", + "transient final SimpleClass SimpleClass135", + "transient volatile SimpleClass SimpleClass136", + "persistence-modifier= none transient volatile SimpleClass SimpleClass137", + "persistence-modifier= persistent transient volatile SimpleClass SimpleClass138", + "persistence-modifier= persistent embedded= true transient volatile SimpleClass SimpleClass139", + "persistence-modifier= persistent embedded= false transient volatile SimpleClass SimpleClass140", + "persistence-modifier= transactional transient volatile SimpleClass SimpleClass141", + "static transient final SimpleClass SimpleClass142", + "static transient volatile SimpleClass SimpleClass143", + "serialized= true private SimpleClass SimpleClass144", + "persistence-modifier= persistent serialized= true private SimpleClass SimpleClass145", + "persistence-modifier= persistent serialized= true private transient SimpleClass SimpleClass146", + "serialized= true private volatile SimpleClass SimpleClass147", + "persistence-modifier= persistent serialized= true private volatile SimpleClass SimpleClass148", + "persistence-modifier= persistent serialized= true private transient volatile SimpleClass SimpleClass149", + "serialized= true public SimpleClass SimpleClass150", + "persistence-modifier= persistent serialized= true public SimpleClass SimpleClass151", + "persistence-modifier= persistent serialized= true public transient SimpleClass SimpleClass152", + "serialized= true public volatile SimpleClass SimpleClass153", + "persistence-modifier= persistent serialized= true public volatile SimpleClass SimpleClass154", + "persistence-modifier= persistent serialized= true public transient volatile SimpleClass SimpleClass155", + "serialized= true protected SimpleClass SimpleClass156", + "persistence-modifier= persistent serialized= true protected SimpleClass SimpleClass157", + "persistence-modifier= persistent serialized= true protected transient SimpleClass SimpleClass158", + "serialized= true protected volatile SimpleClass SimpleClass159", + "persistence-modifier= persistent serialized= true protected volatile SimpleClass SimpleClass160", + "persistence-modifier= persistent serialized= true protected transient volatile SimpleClass SimpleClass161", + "serialized= true SimpleClass SimpleClass162", + "persistence-modifier= persistent serialized= true SimpleClass SimpleClass163", + "persistence-modifier= persistent serialized= true transient SimpleClass SimpleClass164", + "serialized= true volatile SimpleClass SimpleClass165", + "persistence-modifier= persistent serialized= true volatile SimpleClass SimpleClass166", + "persistence-modifier= persistent serialized= true transient volatile SimpleClass SimpleClass167" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public SimpleClass get(int index) { - switch (index) { - case (0): + public SimpleClass get(int index) + { + switch (index) + { + case(0): return SimpleClass0; - case (1): + case(1): return SimpleClass1; - case (2): + case(2): return SimpleClass2; - case (3): + case(3): return SimpleClass3; - case (4): + case(4): return SimpleClass4; - case (5): + case(5): return SimpleClass5; - case (6): + case(6): return SimpleClass6; - case (7): + case(7): return SimpleClass7; - case (8): + case(8): return SimpleClass8; - case (9): + case(9): return SimpleClass9; - case (10): + case(10): return SimpleClass10; - case (11): + case(11): return SimpleClass11; - case (12): + case(12): return SimpleClass12; - case (13): + case(13): return SimpleClass13; - case (14): + case(14): return SimpleClass14; - case (15): + case(15): return SimpleClass15; - case (16): + case(16): return SimpleClass16; - case (17): + case(17): return SimpleClass17; - case (18): + case(18): return SimpleClass18; - case (19): + case(19): return SimpleClass19; - case (20): + case(20): return SimpleClass20; - case (21): + case(21): return SimpleClass21; - case (22): + case(22): return SimpleClass22; - case (23): + case(23): return SimpleClass23; - case (24): + case(24): return SimpleClass24; - case (25): + case(25): return SimpleClass25; - case (26): + case(26): return SimpleClass26; - case (27): + case(27): return SimpleClass27; - case (28): + case(28): return SimpleClass28; - case (29): + case(29): return SimpleClass29; - case (30): + case(30): return SimpleClass30; - case (31): + case(31): return SimpleClass31; - case (32): + case(32): return SimpleClass32; - case (33): + case(33): return SimpleClass33; - case (34): + case(34): return SimpleClass34; - case (35): + case(35): return SimpleClass35; - case (36): + case(36): return SimpleClass36; - case (37): + case(37): return SimpleClass37; - case (38): + case(38): return SimpleClass38; - case (39): + case(39): return SimpleClass39; - case (40): + case(40): return SimpleClass40; - case (41): + case(41): return SimpleClass41; - case (42): + case(42): return SimpleClass42; - case (43): + case(43): return SimpleClass43; - case (44): + case(44): return SimpleClass44; - case (45): + case(45): return SimpleClass45; - case (46): + case(46): return SimpleClass46; - case (47): + case(47): return SimpleClass47; - case (48): + case(48): return SimpleClass48; - case (49): + case(49): return SimpleClass49; - case (50): + case(50): return SimpleClass50; - case (51): + case(51): return SimpleClass51; - case (52): + case(52): return SimpleClass52; - case (53): + case(53): return SimpleClass53; - case (54): + case(54): return SimpleClass54; - case (55): + case(55): return SimpleClass55; - case (56): + case(56): return SimpleClass56; - case (57): + case(57): return SimpleClass57; - case (58): + case(58): return SimpleClass58; - case (59): + case(59): return SimpleClass59; - case (60): + case(60): return SimpleClass60; - case (61): + case(61): return SimpleClass61; - case (62): + case(62): return SimpleClass62; - case (63): + case(63): return SimpleClass63; - case (64): + case(64): return SimpleClass64; - case (65): + case(65): return SimpleClass65; - case (66): + case(66): return SimpleClass66; - case (67): + case(67): return SimpleClass67; - case (68): + case(68): return SimpleClass68; - case (69): + case(69): return SimpleClass69; - case (70): + case(70): return SimpleClass70; - case (71): + case(71): return SimpleClass71; - case (72): + case(72): return SimpleClass72; - case (73): + case(73): return SimpleClass73; - case (74): + case(74): return SimpleClass74; - case (75): + case(75): return SimpleClass75; - case (76): + case(76): return SimpleClass76; - case (77): + case(77): return SimpleClass77; - case (78): + case(78): return SimpleClass78; - case (79): + case(79): return SimpleClass79; - case (80): + case(80): return SimpleClass80; - case (81): + case(81): return SimpleClass81; - case (82): + case(82): return SimpleClass82; - case (83): + case(83): return SimpleClass83; - case (84): + case(84): return SimpleClass84; - case (85): + case(85): return SimpleClass85; - case (86): + case(86): return SimpleClass86; - case (87): + case(87): return SimpleClass87; - case (88): + case(88): return SimpleClass88; - case (89): + case(89): return SimpleClass89; - case (90): + case(90): return SimpleClass90; - case (91): + case(91): return SimpleClass91; - case (92): + case(92): return SimpleClass92; - case (93): + case(93): return SimpleClass93; - case (94): + case(94): return SimpleClass94; - case (95): + case(95): return SimpleClass95; - case (96): + case(96): return SimpleClass96; - case (97): + case(97): return SimpleClass97; - case (98): + case(98): return SimpleClass98; - case (99): + case(99): return SimpleClass99; - case (100): + case(100): return SimpleClass100; - case (101): + case(101): return SimpleClass101; - case (102): + case(102): return SimpleClass102; - case (103): + case(103): return SimpleClass103; - case (104): + case(104): return SimpleClass104; - case (105): + case(105): return SimpleClass105; - case (106): + case(106): return SimpleClass106; - case (107): + case(107): return SimpleClass107; - case (108): + case(108): return SimpleClass108; - case (109): + case(109): return SimpleClass109; - case (110): + case(110): return SimpleClass110; - case (111): + case(111): return SimpleClass111; - case (112): + case(112): return SimpleClass112; - case (113): + case(113): return SimpleClass113; - case (114): + case(114): return SimpleClass114; - case (115): + case(115): return SimpleClass115; - case (116): + case(116): return SimpleClass116; - case (117): + case(117): return SimpleClass117; - case (118): + case(118): return SimpleClass118; - case (119): + case(119): return SimpleClass119; - case (120): + case(120): return SimpleClass120; - case (121): + case(121): return SimpleClass121; - case (122): + case(122): return SimpleClass122; - case (123): + case(123): return SimpleClass123; - case (124): + case(124): return SimpleClass124; - case (125): + case(125): return SimpleClass125; - case (126): + case(126): return SimpleClass126; - case (127): + case(127): return SimpleClass127; - case (128): + case(128): return SimpleClass128; - case (129): + case(129): return SimpleClass129; - case (130): + case(130): return SimpleClass130; - case (131): + case(131): return SimpleClass131; - case (132): + case(132): return SimpleClass132; - case (133): + case(133): return SimpleClass133; - case (134): + case(134): return SimpleClass134; - case (135): + case(135): return SimpleClass135; - case (136): + case(136): return SimpleClass136; - case (137): + case(137): return SimpleClass137; - case (138): + case(138): return SimpleClass138; - case (139): + case(139): return SimpleClass139; - case (140): + case(140): return SimpleClass140; - case (141): + case(141): return SimpleClass141; - case (142): + case(142): return SimpleClass142; - case (143): + case(143): return SimpleClass143; - case (144): + case(144): return SimpleClass144; - case (145): + case(145): return SimpleClass145; - case (146): + case(146): return SimpleClass146; - case (147): + case(147): return SimpleClass147; - case (148): + case(148): return SimpleClass148; - case (149): + case(149): return SimpleClass149; - case (150): + case(150): return SimpleClass150; - case (151): + case(151): return SimpleClass151; - case (152): + case(152): return SimpleClass152; - case (153): + case(153): return SimpleClass153; - case (154): + case(154): return SimpleClass154; - case (155): + case(155): return SimpleClass155; - case (156): + case(156): return SimpleClass156; - case (157): + case(157): return SimpleClass157; - case (158): + case(158): return SimpleClass158; - case (159): + case(159): return SimpleClass159; - case (160): + case(160): return SimpleClass160; - case (161): + case(161): return SimpleClass161; - case (162): + case(162): return SimpleClass162; - case (163): + case(163): return SimpleClass163; - case (164): + case(164): return SimpleClass164; - case (165): + case(165): return SimpleClass165; - case (166): + case(166): return SimpleClass166; - case (167): + case(167): return SimpleClass167; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, SimpleClass value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - SimpleClass0 = value; - break; - case (1): - SimpleClass1 = value; - break; - case (2): - SimpleClass2 = value; - break; - case (3): - SimpleClass3 = value; - break; - case (4): - SimpleClass4 = value; - break; - case (5): - SimpleClass5 = value; - break; - case (6): - SimpleClass6 = value; - break; - case (7): - SimpleClass7 = value; - break; - case (8): - SimpleClass8 = value; - break; - case (9): - SimpleClass9 = value; - break; - case (10): - SimpleClass10 = value; - break; - case (11): - SimpleClass11 = value; - break; - case (12): - SimpleClass12 = value; - break; - case (13): - SimpleClass13 = value; - break; - case (14): - SimpleClass14 = value; - break; - case (16): - SimpleClass16 = value; - break; - case (17): - SimpleClass17 = value; - break; - case (18): - SimpleClass18 = value; - break; - case (19): - SimpleClass19 = value; - break; - case (20): - SimpleClass20 = value; - break; - case (21): - SimpleClass21 = value; - break; - case (22): - SimpleClass22 = value; - break; - case (23): - SimpleClass23 = value; - break; - case (24): - SimpleClass24 = value; - break; - case (26): - SimpleClass26 = value; - break; - case (28): - SimpleClass28 = value; - break; - case (29): - SimpleClass29 = value; - break; - case (30): - SimpleClass30 = value; - break; - case (31): - SimpleClass31 = value; - break; - case (32): - SimpleClass32 = value; - break; - case (33): - SimpleClass33 = value; - break; - case (35): - SimpleClass35 = value; - break; - case (36): - SimpleClass36 = value; - break; - case (37): - SimpleClass37 = value; - break; - case (38): - SimpleClass38 = value; - break; - case (39): - SimpleClass39 = value; - break; - case (40): - SimpleClass40 = value; - break; - case (41): - SimpleClass41 = value; - break; - case (42): - SimpleClass42 = value; - break; - case (43): - SimpleClass43 = value; - break; - case (44): - SimpleClass44 = value; - break; - case (45): - SimpleClass45 = value; - break; - case (46): - SimpleClass46 = value; - break; - case (47): - SimpleClass47 = value; - break; - case (48): - SimpleClass48 = value; - break; - case (49): - SimpleClass49 = value; - break; - case (50): - SimpleClass50 = value; - break; - case (52): - SimpleClass52 = value; - break; - case (53): - SimpleClass53 = value; - break; - case (54): - SimpleClass54 = value; - break; - case (55): - SimpleClass55 = value; - break; - case (56): - SimpleClass56 = value; - break; - case (57): - SimpleClass57 = value; - break; - case (58): - SimpleClass58 = value; - break; - case (59): - SimpleClass59 = value; - break; - case (60): - SimpleClass60 = value; - break; - case (62): - SimpleClass62 = value; - break; - case (64): - SimpleClass64 = value; - break; - case (65): - SimpleClass65 = value; - break; - case (66): - SimpleClass66 = value; - break; - case (67): - SimpleClass67 = value; - break; - case (68): - SimpleClass68 = value; - break; - case (69): - SimpleClass69 = value; - break; - case (71): - SimpleClass71 = value; - break; - case (72): - SimpleClass72 = value; - break; - case (73): - SimpleClass73 = value; - break; - case (74): - SimpleClass74 = value; - break; - case (75): - SimpleClass75 = value; - break; - case (76): - SimpleClass76 = value; - break; - case (77): - SimpleClass77 = value; - break; - case (78): - SimpleClass78 = value; - break; - case (79): - SimpleClass79 = value; - break; - case (80): - SimpleClass80 = value; - break; - case (81): - SimpleClass81 = value; - break; - case (82): - SimpleClass82 = value; - break; - case (83): - SimpleClass83 = value; - break; - case (84): - SimpleClass84 = value; - break; - case (85): - SimpleClass85 = value; - break; - case (86): - SimpleClass86 = value; - break; - case (88): - SimpleClass88 = value; - break; - case (89): - SimpleClass89 = value; - break; - case (90): - SimpleClass90 = value; - break; - case (91): - SimpleClass91 = value; - break; - case (92): - SimpleClass92 = value; - break; - case (93): - SimpleClass93 = value; - break; - case (94): - SimpleClass94 = value; - break; - case (95): - SimpleClass95 = value; - break; - case (96): - SimpleClass96 = value; - break; - case (98): - SimpleClass98 = value; - break; - case (100): - SimpleClass100 = value; - break; - case (101): - SimpleClass101 = value; - break; - case (102): - SimpleClass102 = value; - break; - case (103): - SimpleClass103 = value; - break; - case (104): - SimpleClass104 = value; - break; - case (105): - SimpleClass105 = value; - break; - case (107): - SimpleClass107 = value; - break; - case (108): - SimpleClass108 = value; - break; - case (109): - SimpleClass109 = value; - break; - case (110): - SimpleClass110 = value; - break; - case (111): - SimpleClass111 = value; - break; - case (112): - SimpleClass112 = value; - break; - case (113): - SimpleClass113 = value; - break; - case (114): - SimpleClass114 = value; - break; - case (115): - SimpleClass115 = value; - break; - case (116): - SimpleClass116 = value; - break; - case (117): - SimpleClass117 = value; - break; - case (118): - SimpleClass118 = value; - break; - case (119): - SimpleClass119 = value; - break; - case (120): - SimpleClass120 = value; - break; - case (121): - SimpleClass121 = value; - break; - case (122): - SimpleClass122 = value; - break; - case (124): - SimpleClass124 = value; - break; - case (125): - SimpleClass125 = value; - break; - case (126): - SimpleClass126 = value; - break; - case (127): - SimpleClass127 = value; - break; - case (128): - SimpleClass128 = value; - break; - case (129): - SimpleClass129 = value; - break; - case (130): - SimpleClass130 = value; - break; - case (131): - SimpleClass131 = value; - break; - case (132): - SimpleClass132 = value; - break; - case (134): - SimpleClass134 = value; - break; - case (136): - SimpleClass136 = value; - break; - case (137): - SimpleClass137 = value; - break; - case (138): - SimpleClass138 = value; - break; - case (139): - SimpleClass139 = value; - break; - case (140): - SimpleClass140 = value; - break; - case (141): - SimpleClass141 = value; - break; - case (143): - SimpleClass143 = value; - break; - case (144): - SimpleClass144 = value; - break; - case (145): - SimpleClass145 = value; - break; - case (146): - SimpleClass146 = value; - break; - case (147): - SimpleClass147 = value; - break; - case (148): - SimpleClass148 = value; - break; - case (149): - SimpleClass149 = value; - break; - case (150): - SimpleClass150 = value; - break; - case (151): - SimpleClass151 = value; - break; - case (152): - SimpleClass152 = value; - break; - case (153): - SimpleClass153 = value; - break; - case (154): - SimpleClass154 = value; - break; - case (155): - SimpleClass155 = value; - break; - case (156): - SimpleClass156 = value; - break; - case (157): - SimpleClass157 = value; - break; - case (158): - SimpleClass158 = value; - break; - case (159): - SimpleClass159 = value; - break; - case (160): - SimpleClass160 = value; - break; - case (161): - SimpleClass161 = value; - break; - case (162): - SimpleClass162 = value; - break; - case (163): - SimpleClass163 = value; - break; - case (164): - SimpleClass164 = value; - break; - case (165): - SimpleClass165 = value; - break; - case (166): - SimpleClass166 = value; - break; - case (167): - SimpleClass167 = value; - break; + public boolean set(int index,SimpleClass value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + SimpleClass0= value; + break; + case(1): + SimpleClass1= value; + break; + case(2): + SimpleClass2= value; + break; + case(3): + SimpleClass3= value; + break; + case(4): + SimpleClass4= value; + break; + case(5): + SimpleClass5= value; + break; + case(6): + SimpleClass6= value; + break; + case(7): + SimpleClass7= value; + break; + case(8): + SimpleClass8= value; + break; + case(9): + SimpleClass9= value; + break; + case(10): + SimpleClass10= value; + break; + case(11): + SimpleClass11= value; + break; + case(12): + SimpleClass12= value; + break; + case(13): + SimpleClass13= value; + break; + case(14): + SimpleClass14= value; + break; + case(16): + SimpleClass16= value; + break; + case(17): + SimpleClass17= value; + break; + case(18): + SimpleClass18= value; + break; + case(19): + SimpleClass19= value; + break; + case(20): + SimpleClass20= value; + break; + case(21): + SimpleClass21= value; + break; + case(22): + SimpleClass22= value; + break; + case(23): + SimpleClass23= value; + break; + case(24): + SimpleClass24= value; + break; + case(26): + SimpleClass26= value; + break; + case(28): + SimpleClass28= value; + break; + case(29): + SimpleClass29= value; + break; + case(30): + SimpleClass30= value; + break; + case(31): + SimpleClass31= value; + break; + case(32): + SimpleClass32= value; + break; + case(33): + SimpleClass33= value; + break; + case(35): + SimpleClass35= value; + break; + case(36): + SimpleClass36= value; + break; + case(37): + SimpleClass37= value; + break; + case(38): + SimpleClass38= value; + break; + case(39): + SimpleClass39= value; + break; + case(40): + SimpleClass40= value; + break; + case(41): + SimpleClass41= value; + break; + case(42): + SimpleClass42= value; + break; + case(43): + SimpleClass43= value; + break; + case(44): + SimpleClass44= value; + break; + case(45): + SimpleClass45= value; + break; + case(46): + SimpleClass46= value; + break; + case(47): + SimpleClass47= value; + break; + case(48): + SimpleClass48= value; + break; + case(49): + SimpleClass49= value; + break; + case(50): + SimpleClass50= value; + break; + case(52): + SimpleClass52= value; + break; + case(53): + SimpleClass53= value; + break; + case(54): + SimpleClass54= value; + break; + case(55): + SimpleClass55= value; + break; + case(56): + SimpleClass56= value; + break; + case(57): + SimpleClass57= value; + break; + case(58): + SimpleClass58= value; + break; + case(59): + SimpleClass59= value; + break; + case(60): + SimpleClass60= value; + break; + case(62): + SimpleClass62= value; + break; + case(64): + SimpleClass64= value; + break; + case(65): + SimpleClass65= value; + break; + case(66): + SimpleClass66= value; + break; + case(67): + SimpleClass67= value; + break; + case(68): + SimpleClass68= value; + break; + case(69): + SimpleClass69= value; + break; + case(71): + SimpleClass71= value; + break; + case(72): + SimpleClass72= value; + break; + case(73): + SimpleClass73= value; + break; + case(74): + SimpleClass74= value; + break; + case(75): + SimpleClass75= value; + break; + case(76): + SimpleClass76= value; + break; + case(77): + SimpleClass77= value; + break; + case(78): + SimpleClass78= value; + break; + case(79): + SimpleClass79= value; + break; + case(80): + SimpleClass80= value; + break; + case(81): + SimpleClass81= value; + break; + case(82): + SimpleClass82= value; + break; + case(83): + SimpleClass83= value; + break; + case(84): + SimpleClass84= value; + break; + case(85): + SimpleClass85= value; + break; + case(86): + SimpleClass86= value; + break; + case(88): + SimpleClass88= value; + break; + case(89): + SimpleClass89= value; + break; + case(90): + SimpleClass90= value; + break; + case(91): + SimpleClass91= value; + break; + case(92): + SimpleClass92= value; + break; + case(93): + SimpleClass93= value; + break; + case(94): + SimpleClass94= value; + break; + case(95): + SimpleClass95= value; + break; + case(96): + SimpleClass96= value; + break; + case(98): + SimpleClass98= value; + break; + case(100): + SimpleClass100= value; + break; + case(101): + SimpleClass101= value; + break; + case(102): + SimpleClass102= value; + break; + case(103): + SimpleClass103= value; + break; + case(104): + SimpleClass104= value; + break; + case(105): + SimpleClass105= value; + break; + case(107): + SimpleClass107= value; + break; + case(108): + SimpleClass108= value; + break; + case(109): + SimpleClass109= value; + break; + case(110): + SimpleClass110= value; + break; + case(111): + SimpleClass111= value; + break; + case(112): + SimpleClass112= value; + break; + case(113): + SimpleClass113= value; + break; + case(114): + SimpleClass114= value; + break; + case(115): + SimpleClass115= value; + break; + case(116): + SimpleClass116= value; + break; + case(117): + SimpleClass117= value; + break; + case(118): + SimpleClass118= value; + break; + case(119): + SimpleClass119= value; + break; + case(120): + SimpleClass120= value; + break; + case(121): + SimpleClass121= value; + break; + case(122): + SimpleClass122= value; + break; + case(124): + SimpleClass124= value; + break; + case(125): + SimpleClass125= value; + break; + case(126): + SimpleClass126= value; + break; + case(127): + SimpleClass127= value; + break; + case(128): + SimpleClass128= value; + break; + case(129): + SimpleClass129= value; + break; + case(130): + SimpleClass130= value; + break; + case(131): + SimpleClass131= value; + break; + case(132): + SimpleClass132= value; + break; + case(134): + SimpleClass134= value; + break; + case(136): + SimpleClass136= value; + break; + case(137): + SimpleClass137= value; + break; + case(138): + SimpleClass138= value; + break; + case(139): + SimpleClass139= value; + break; + case(140): + SimpleClass140= value; + break; + case(141): + SimpleClass141= value; + break; + case(143): + SimpleClass143= value; + break; + case(144): + SimpleClass144= value; + break; + case(145): + SimpleClass145= value; + break; + case(146): + SimpleClass146= value; + break; + case(147): + SimpleClass147= value; + break; + case(148): + SimpleClass148= value; + break; + case(149): + SimpleClass149= value; + break; + case(150): + SimpleClass150= value; + break; + case(151): + SimpleClass151= value; + break; + case(152): + SimpleClass152= value; + break; + case(153): + SimpleClass153= value; + break; + case(154): + SimpleClass154= value; + break; + case(155): + SimpleClass155= value; + break; + case(156): + SimpleClass156= value; + break; + case(157): + SimpleClass157= value; + break; + case(158): + SimpleClass158= value; + break; + case(159): + SimpleClass159= value; + break; + case(160): + SimpleClass160= value; + break; + case(161): + SimpleClass161= value; + break; + case(162): + SimpleClass162= value; + break; + case(163): + SimpleClass163= value; + break; + case(164): + SimpleClass164= value; + break; + case(165): + SimpleClass165= value; + break; + case(166): + SimpleClass166= value; + break; + case(167): + SimpleClass167= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfSimpleEnum.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfSimpleEnum.java index 511bd0eca..6201ed6f9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfSimpleEnum.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfSimpleEnum.java @@ -5,21 +5,21 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -public class FieldsOfSimpleEnum { +public class FieldsOfSimpleEnum { public int identifier; private SimpleEnum SimpleEnum0; private SimpleEnum SimpleEnum1; @@ -48,14 +48,14 @@ public class FieldsOfSimpleEnum { private static transient SimpleEnum SimpleEnum24; private static final SimpleEnum SimpleEnum25 = SimpleEnum.AL; private static volatile SimpleEnum SimpleEnum26; - private final transient SimpleEnum SimpleEnum27 = SimpleEnum.AL; + private transient final SimpleEnum SimpleEnum27 = SimpleEnum.AL; private transient volatile SimpleEnum SimpleEnum28; private transient volatile SimpleEnum SimpleEnum29; private transient volatile SimpleEnum SimpleEnum30; private transient volatile SimpleEnum SimpleEnum31; private transient volatile SimpleEnum SimpleEnum32; private transient volatile SimpleEnum SimpleEnum33; - private static final transient SimpleEnum SimpleEnum34 = SimpleEnum.AL; + private static transient final SimpleEnum SimpleEnum34 = SimpleEnum.AL; private static transient volatile SimpleEnum SimpleEnum35; public SimpleEnum SimpleEnum36; public SimpleEnum SimpleEnum37; @@ -84,14 +84,14 @@ public class FieldsOfSimpleEnum { public static transient SimpleEnum SimpleEnum60; public static final SimpleEnum SimpleEnum61 = SimpleEnum.AL; public static volatile SimpleEnum SimpleEnum62; - public final transient SimpleEnum SimpleEnum63 = SimpleEnum.AL; + public transient final SimpleEnum SimpleEnum63 = SimpleEnum.AL; public transient volatile SimpleEnum SimpleEnum64; public transient volatile SimpleEnum SimpleEnum65; public transient volatile SimpleEnum SimpleEnum66; public transient volatile SimpleEnum SimpleEnum67; public transient volatile SimpleEnum SimpleEnum68; public transient volatile SimpleEnum SimpleEnum69; - public static final transient SimpleEnum SimpleEnum70 = SimpleEnum.AL; + public static transient final SimpleEnum SimpleEnum70 = SimpleEnum.AL; public static transient volatile SimpleEnum SimpleEnum71; protected SimpleEnum SimpleEnum72; protected SimpleEnum SimpleEnum73; @@ -120,14 +120,14 @@ public class FieldsOfSimpleEnum { protected static transient SimpleEnum SimpleEnum96; protected static final SimpleEnum SimpleEnum97 = SimpleEnum.AL; protected static volatile SimpleEnum SimpleEnum98; - protected final transient SimpleEnum SimpleEnum99 = SimpleEnum.AL; + protected transient final SimpleEnum SimpleEnum99 = SimpleEnum.AL; protected transient volatile SimpleEnum SimpleEnum100; protected transient volatile SimpleEnum SimpleEnum101; protected transient volatile SimpleEnum SimpleEnum102; protected transient volatile SimpleEnum SimpleEnum103; protected transient volatile SimpleEnum SimpleEnum104; protected transient volatile SimpleEnum SimpleEnum105; - protected static final transient SimpleEnum SimpleEnum106 = SimpleEnum.AL; + protected static transient final SimpleEnum SimpleEnum106 = SimpleEnum.AL; protected static transient volatile SimpleEnum SimpleEnum107; SimpleEnum SimpleEnum108; SimpleEnum SimpleEnum109; @@ -156,936 +156,934 @@ public class FieldsOfSimpleEnum { static transient SimpleEnum SimpleEnum132; static final SimpleEnum SimpleEnum133 = SimpleEnum.AL; static volatile SimpleEnum SimpleEnum134; - final transient SimpleEnum SimpleEnum135 = SimpleEnum.AL; + transient final SimpleEnum SimpleEnum135 = SimpleEnum.AL; transient volatile SimpleEnum SimpleEnum136; transient volatile SimpleEnum SimpleEnum137; transient volatile SimpleEnum SimpleEnum138; transient volatile SimpleEnum SimpleEnum139; transient volatile SimpleEnum SimpleEnum140; transient volatile SimpleEnum SimpleEnum141; - static final transient SimpleEnum SimpleEnum142 = SimpleEnum.AL; + static transient final SimpleEnum SimpleEnum142 = SimpleEnum.AL; static transient volatile SimpleEnum SimpleEnum143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private SimpleEnum SimpleEnum0", - "embedded= true private SimpleEnum SimpleEnum1", - "embedded= false private SimpleEnum SimpleEnum2", - "persistence-modifier= none private SimpleEnum SimpleEnum3", - "persistence-modifier= persistent private SimpleEnum SimpleEnum4", - "persistence-modifier= persistent embedded= true private SimpleEnum SimpleEnum5", - "persistence-modifier= persistent embedded= false private SimpleEnum SimpleEnum6", - "persistence-modifier= transactional private SimpleEnum SimpleEnum7", - "private static SimpleEnum SimpleEnum8", - "private transient SimpleEnum SimpleEnum9", - "persistence-modifier= none private transient SimpleEnum SimpleEnum10", - "persistence-modifier= persistent private transient SimpleEnum SimpleEnum11", - "persistence-modifier= persistent embedded= true private transient SimpleEnum SimpleEnum12", - "persistence-modifier= persistent embedded= false private transient SimpleEnum SimpleEnum13", - "persistence-modifier= transactional private transient SimpleEnum SimpleEnum14", - "private final SimpleEnum SimpleEnum15", - "private volatile SimpleEnum SimpleEnum16", - "embedded= true private volatile SimpleEnum SimpleEnum17", - "embedded= false private volatile SimpleEnum SimpleEnum18", - "persistence-modifier= none private volatile SimpleEnum SimpleEnum19", - "persistence-modifier= persistent private volatile SimpleEnum SimpleEnum20", - "persistence-modifier= persistent embedded= true private volatile SimpleEnum SimpleEnum21", - "persistence-modifier= persistent embedded= false private volatile SimpleEnum SimpleEnum22", - "persistence-modifier= transactional private volatile SimpleEnum SimpleEnum23", - "private static transient SimpleEnum SimpleEnum24", - "private static final SimpleEnum SimpleEnum25", - "private static volatile SimpleEnum SimpleEnum26", - "private transient final SimpleEnum SimpleEnum27", - "private transient volatile SimpleEnum SimpleEnum28", - "persistence-modifier= none private transient volatile SimpleEnum SimpleEnum29", - "persistence-modifier= persistent private transient volatile SimpleEnum SimpleEnum30", - "persistence-modifier= persistent embedded= true private transient volatile SimpleEnum SimpleEnum31", - "persistence-modifier= persistent embedded= false private transient volatile SimpleEnum SimpleEnum32", - "persistence-modifier= transactional private transient volatile SimpleEnum SimpleEnum33", - "private static transient final SimpleEnum SimpleEnum34", - "private static transient volatile SimpleEnum SimpleEnum35", - "public SimpleEnum SimpleEnum36", - "embedded= true public SimpleEnum SimpleEnum37", - "embedded= false public SimpleEnum SimpleEnum38", - "persistence-modifier= none public SimpleEnum SimpleEnum39", - "persistence-modifier= persistent public SimpleEnum SimpleEnum40", - "persistence-modifier= persistent embedded= true public SimpleEnum SimpleEnum41", - "persistence-modifier= persistent embedded= false public SimpleEnum SimpleEnum42", - "persistence-modifier= transactional public SimpleEnum SimpleEnum43", - "public static SimpleEnum SimpleEnum44", - "public transient SimpleEnum SimpleEnum45", - "persistence-modifier= none public transient SimpleEnum SimpleEnum46", - "persistence-modifier= persistent public transient SimpleEnum SimpleEnum47", - "persistence-modifier= persistent embedded= true public transient SimpleEnum SimpleEnum48", - "persistence-modifier= persistent embedded= false public transient SimpleEnum SimpleEnum49", - "persistence-modifier= transactional public transient SimpleEnum SimpleEnum50", - "public final SimpleEnum SimpleEnum51", - "public volatile SimpleEnum SimpleEnum52", - "embedded= true public volatile SimpleEnum SimpleEnum53", - "embedded= false public volatile SimpleEnum SimpleEnum54", - "persistence-modifier= none public volatile SimpleEnum SimpleEnum55", - "persistence-modifier= persistent public volatile SimpleEnum SimpleEnum56", - "persistence-modifier= persistent embedded= true public volatile SimpleEnum SimpleEnum57", - "persistence-modifier= persistent embedded= false public volatile SimpleEnum SimpleEnum58", - "persistence-modifier= transactional public volatile SimpleEnum SimpleEnum59", - "public static transient SimpleEnum SimpleEnum60", - "public static final SimpleEnum SimpleEnum61", - "public static volatile SimpleEnum SimpleEnum62", - "public transient final SimpleEnum SimpleEnum63", - "public transient volatile SimpleEnum SimpleEnum64", - "persistence-modifier= none public transient volatile SimpleEnum SimpleEnum65", - "persistence-modifier= persistent public transient volatile SimpleEnum SimpleEnum66", - "persistence-modifier= persistent embedded= true public transient volatile SimpleEnum SimpleEnum67", - "persistence-modifier= persistent embedded= false public transient volatile SimpleEnum SimpleEnum68", - "persistence-modifier= transactional public transient volatile SimpleEnum SimpleEnum69", - "public static transient final SimpleEnum SimpleEnum70", - "public static transient volatile SimpleEnum SimpleEnum71", - "protected SimpleEnum SimpleEnum72", - "embedded= true protected SimpleEnum SimpleEnum73", - "embedded= false protected SimpleEnum SimpleEnum74", - "persistence-modifier= none protected SimpleEnum SimpleEnum75", - "persistence-modifier= persistent protected SimpleEnum SimpleEnum76", - "persistence-modifier= persistent embedded= true protected SimpleEnum SimpleEnum77", - "persistence-modifier= persistent embedded= false protected SimpleEnum SimpleEnum78", - "persistence-modifier= transactional protected SimpleEnum SimpleEnum79", - "protected static SimpleEnum SimpleEnum80", - "protected transient SimpleEnum SimpleEnum81", - "persistence-modifier= none protected transient SimpleEnum SimpleEnum82", - "persistence-modifier= persistent protected transient SimpleEnum SimpleEnum83", - "persistence-modifier= persistent embedded= true protected transient SimpleEnum SimpleEnum84", - "persistence-modifier= persistent embedded= false protected transient SimpleEnum SimpleEnum85", - "persistence-modifier= transactional protected transient SimpleEnum SimpleEnum86", - "protected final SimpleEnum SimpleEnum87", - "protected volatile SimpleEnum SimpleEnum88", - "embedded= true protected volatile SimpleEnum SimpleEnum89", - "embedded= false protected volatile SimpleEnum SimpleEnum90", - "persistence-modifier= none protected volatile SimpleEnum SimpleEnum91", - "persistence-modifier= persistent protected volatile SimpleEnum SimpleEnum92", - "persistence-modifier= persistent embedded= true protected volatile SimpleEnum SimpleEnum93", - "persistence-modifier= persistent embedded= false protected volatile SimpleEnum SimpleEnum94", - "persistence-modifier= transactional protected volatile SimpleEnum SimpleEnum95", - "protected static transient SimpleEnum SimpleEnum96", - "protected static final SimpleEnum SimpleEnum97", - "protected static volatile SimpleEnum SimpleEnum98", - "protected transient final SimpleEnum SimpleEnum99", - "protected transient volatile SimpleEnum SimpleEnum100", - "persistence-modifier= none protected transient volatile SimpleEnum SimpleEnum101", - "persistence-modifier= persistent protected transient volatile SimpleEnum SimpleEnum102", - "persistence-modifier= persistent embedded= true protected transient volatile SimpleEnum SimpleEnum103", - "persistence-modifier= persistent embedded= false protected transient volatile SimpleEnum SimpleEnum104", - "persistence-modifier= transactional protected transient volatile SimpleEnum SimpleEnum105", - "protected static transient final SimpleEnum SimpleEnum106", - "protected static transient volatile SimpleEnum SimpleEnum107", - "SimpleEnum SimpleEnum108", - "embedded= true SimpleEnum SimpleEnum109", - "embedded= false SimpleEnum SimpleEnum110", - "persistence-modifier= none SimpleEnum SimpleEnum111", - "persistence-modifier= persistent SimpleEnum SimpleEnum112", - "persistence-modifier= persistent embedded= true SimpleEnum SimpleEnum113", - "persistence-modifier= persistent embedded= false SimpleEnum SimpleEnum114", - "persistence-modifier= transactional SimpleEnum SimpleEnum115", - "static SimpleEnum SimpleEnum116", - "transient SimpleEnum SimpleEnum117", - "persistence-modifier= none transient SimpleEnum SimpleEnum118", - "persistence-modifier= persistent transient SimpleEnum SimpleEnum119", - "persistence-modifier= persistent embedded= true transient SimpleEnum SimpleEnum120", - "persistence-modifier= persistent embedded= false transient SimpleEnum SimpleEnum121", - "persistence-modifier= transactional transient SimpleEnum SimpleEnum122", - "final SimpleEnum SimpleEnum123", - "volatile SimpleEnum SimpleEnum124", - "embedded= true volatile SimpleEnum SimpleEnum125", - "embedded= false volatile SimpleEnum SimpleEnum126", - "persistence-modifier= none volatile SimpleEnum SimpleEnum127", - "persistence-modifier= persistent volatile SimpleEnum SimpleEnum128", - "persistence-modifier= persistent embedded= true volatile SimpleEnum SimpleEnum129", - "persistence-modifier= persistent embedded= false volatile SimpleEnum SimpleEnum130", - "persistence-modifier= transactional volatile SimpleEnum SimpleEnum131", - "static transient SimpleEnum SimpleEnum132", - "static final SimpleEnum SimpleEnum133", - "static volatile SimpleEnum SimpleEnum134", - "transient final SimpleEnum SimpleEnum135", - "transient volatile SimpleEnum SimpleEnum136", - "persistence-modifier= none transient volatile SimpleEnum SimpleEnum137", - "persistence-modifier= persistent transient volatile SimpleEnum SimpleEnum138", - "persistence-modifier= persistent embedded= true transient volatile SimpleEnum SimpleEnum139", - "persistence-modifier= persistent embedded= false transient volatile SimpleEnum SimpleEnum140", - "persistence-modifier= transactional transient volatile SimpleEnum SimpleEnum141", - "static transient final SimpleEnum SimpleEnum142", - "static transient volatile SimpleEnum SimpleEnum143" + public static final String [] fieldSpecs = { + "private SimpleEnum SimpleEnum0", + "embedded= true private SimpleEnum SimpleEnum1", + "embedded= false private SimpleEnum SimpleEnum2", + "persistence-modifier= none private SimpleEnum SimpleEnum3", + "persistence-modifier= persistent private SimpleEnum SimpleEnum4", + "persistence-modifier= persistent embedded= true private SimpleEnum SimpleEnum5", + "persistence-modifier= persistent embedded= false private SimpleEnum SimpleEnum6", + "persistence-modifier= transactional private SimpleEnum SimpleEnum7", + "private static SimpleEnum SimpleEnum8", + "private transient SimpleEnum SimpleEnum9", + "persistence-modifier= none private transient SimpleEnum SimpleEnum10", + "persistence-modifier= persistent private transient SimpleEnum SimpleEnum11", + "persistence-modifier= persistent embedded= true private transient SimpleEnum SimpleEnum12", + "persistence-modifier= persistent embedded= false private transient SimpleEnum SimpleEnum13", + "persistence-modifier= transactional private transient SimpleEnum SimpleEnum14", + "private final SimpleEnum SimpleEnum15", + "private volatile SimpleEnum SimpleEnum16", + "embedded= true private volatile SimpleEnum SimpleEnum17", + "embedded= false private volatile SimpleEnum SimpleEnum18", + "persistence-modifier= none private volatile SimpleEnum SimpleEnum19", + "persistence-modifier= persistent private volatile SimpleEnum SimpleEnum20", + "persistence-modifier= persistent embedded= true private volatile SimpleEnum SimpleEnum21", + "persistence-modifier= persistent embedded= false private volatile SimpleEnum SimpleEnum22", + "persistence-modifier= transactional private volatile SimpleEnum SimpleEnum23", + "private static transient SimpleEnum SimpleEnum24", + "private static final SimpleEnum SimpleEnum25", + "private static volatile SimpleEnum SimpleEnum26", + "private transient final SimpleEnum SimpleEnum27", + "private transient volatile SimpleEnum SimpleEnum28", + "persistence-modifier= none private transient volatile SimpleEnum SimpleEnum29", + "persistence-modifier= persistent private transient volatile SimpleEnum SimpleEnum30", + "persistence-modifier= persistent embedded= true private transient volatile SimpleEnum SimpleEnum31", + "persistence-modifier= persistent embedded= false private transient volatile SimpleEnum SimpleEnum32", + "persistence-modifier= transactional private transient volatile SimpleEnum SimpleEnum33", + "private static transient final SimpleEnum SimpleEnum34", + "private static transient volatile SimpleEnum SimpleEnum35", + "public SimpleEnum SimpleEnum36", + "embedded= true public SimpleEnum SimpleEnum37", + "embedded= false public SimpleEnum SimpleEnum38", + "persistence-modifier= none public SimpleEnum SimpleEnum39", + "persistence-modifier= persistent public SimpleEnum SimpleEnum40", + "persistence-modifier= persistent embedded= true public SimpleEnum SimpleEnum41", + "persistence-modifier= persistent embedded= false public SimpleEnum SimpleEnum42", + "persistence-modifier= transactional public SimpleEnum SimpleEnum43", + "public static SimpleEnum SimpleEnum44", + "public transient SimpleEnum SimpleEnum45", + "persistence-modifier= none public transient SimpleEnum SimpleEnum46", + "persistence-modifier= persistent public transient SimpleEnum SimpleEnum47", + "persistence-modifier= persistent embedded= true public transient SimpleEnum SimpleEnum48", + "persistence-modifier= persistent embedded= false public transient SimpleEnum SimpleEnum49", + "persistence-modifier= transactional public transient SimpleEnum SimpleEnum50", + "public final SimpleEnum SimpleEnum51", + "public volatile SimpleEnum SimpleEnum52", + "embedded= true public volatile SimpleEnum SimpleEnum53", + "embedded= false public volatile SimpleEnum SimpleEnum54", + "persistence-modifier= none public volatile SimpleEnum SimpleEnum55", + "persistence-modifier= persistent public volatile SimpleEnum SimpleEnum56", + "persistence-modifier= persistent embedded= true public volatile SimpleEnum SimpleEnum57", + "persistence-modifier= persistent embedded= false public volatile SimpleEnum SimpleEnum58", + "persistence-modifier= transactional public volatile SimpleEnum SimpleEnum59", + "public static transient SimpleEnum SimpleEnum60", + "public static final SimpleEnum SimpleEnum61", + "public static volatile SimpleEnum SimpleEnum62", + "public transient final SimpleEnum SimpleEnum63", + "public transient volatile SimpleEnum SimpleEnum64", + "persistence-modifier= none public transient volatile SimpleEnum SimpleEnum65", + "persistence-modifier= persistent public transient volatile SimpleEnum SimpleEnum66", + "persistence-modifier= persistent embedded= true public transient volatile SimpleEnum SimpleEnum67", + "persistence-modifier= persistent embedded= false public transient volatile SimpleEnum SimpleEnum68", + "persistence-modifier= transactional public transient volatile SimpleEnum SimpleEnum69", + "public static transient final SimpleEnum SimpleEnum70", + "public static transient volatile SimpleEnum SimpleEnum71", + "protected SimpleEnum SimpleEnum72", + "embedded= true protected SimpleEnum SimpleEnum73", + "embedded= false protected SimpleEnum SimpleEnum74", + "persistence-modifier= none protected SimpleEnum SimpleEnum75", + "persistence-modifier= persistent protected SimpleEnum SimpleEnum76", + "persistence-modifier= persistent embedded= true protected SimpleEnum SimpleEnum77", + "persistence-modifier= persistent embedded= false protected SimpleEnum SimpleEnum78", + "persistence-modifier= transactional protected SimpleEnum SimpleEnum79", + "protected static SimpleEnum SimpleEnum80", + "protected transient SimpleEnum SimpleEnum81", + "persistence-modifier= none protected transient SimpleEnum SimpleEnum82", + "persistence-modifier= persistent protected transient SimpleEnum SimpleEnum83", + "persistence-modifier= persistent embedded= true protected transient SimpleEnum SimpleEnum84", + "persistence-modifier= persistent embedded= false protected transient SimpleEnum SimpleEnum85", + "persistence-modifier= transactional protected transient SimpleEnum SimpleEnum86", + "protected final SimpleEnum SimpleEnum87", + "protected volatile SimpleEnum SimpleEnum88", + "embedded= true protected volatile SimpleEnum SimpleEnum89", + "embedded= false protected volatile SimpleEnum SimpleEnum90", + "persistence-modifier= none protected volatile SimpleEnum SimpleEnum91", + "persistence-modifier= persistent protected volatile SimpleEnum SimpleEnum92", + "persistence-modifier= persistent embedded= true protected volatile SimpleEnum SimpleEnum93", + "persistence-modifier= persistent embedded= false protected volatile SimpleEnum SimpleEnum94", + "persistence-modifier= transactional protected volatile SimpleEnum SimpleEnum95", + "protected static transient SimpleEnum SimpleEnum96", + "protected static final SimpleEnum SimpleEnum97", + "protected static volatile SimpleEnum SimpleEnum98", + "protected transient final SimpleEnum SimpleEnum99", + "protected transient volatile SimpleEnum SimpleEnum100", + "persistence-modifier= none protected transient volatile SimpleEnum SimpleEnum101", + "persistence-modifier= persistent protected transient volatile SimpleEnum SimpleEnum102", + "persistence-modifier= persistent embedded= true protected transient volatile SimpleEnum SimpleEnum103", + "persistence-modifier= persistent embedded= false protected transient volatile SimpleEnum SimpleEnum104", + "persistence-modifier= transactional protected transient volatile SimpleEnum SimpleEnum105", + "protected static transient final SimpleEnum SimpleEnum106", + "protected static transient volatile SimpleEnum SimpleEnum107", + "SimpleEnum SimpleEnum108", + "embedded= true SimpleEnum SimpleEnum109", + "embedded= false SimpleEnum SimpleEnum110", + "persistence-modifier= none SimpleEnum SimpleEnum111", + "persistence-modifier= persistent SimpleEnum SimpleEnum112", + "persistence-modifier= persistent embedded= true SimpleEnum SimpleEnum113", + "persistence-modifier= persistent embedded= false SimpleEnum SimpleEnum114", + "persistence-modifier= transactional SimpleEnum SimpleEnum115", + "static SimpleEnum SimpleEnum116", + "transient SimpleEnum SimpleEnum117", + "persistence-modifier= none transient SimpleEnum SimpleEnum118", + "persistence-modifier= persistent transient SimpleEnum SimpleEnum119", + "persistence-modifier= persistent embedded= true transient SimpleEnum SimpleEnum120", + "persistence-modifier= persistent embedded= false transient SimpleEnum SimpleEnum121", + "persistence-modifier= transactional transient SimpleEnum SimpleEnum122", + "final SimpleEnum SimpleEnum123", + "volatile SimpleEnum SimpleEnum124", + "embedded= true volatile SimpleEnum SimpleEnum125", + "embedded= false volatile SimpleEnum SimpleEnum126", + "persistence-modifier= none volatile SimpleEnum SimpleEnum127", + "persistence-modifier= persistent volatile SimpleEnum SimpleEnum128", + "persistence-modifier= persistent embedded= true volatile SimpleEnum SimpleEnum129", + "persistence-modifier= persistent embedded= false volatile SimpleEnum SimpleEnum130", + "persistence-modifier= transactional volatile SimpleEnum SimpleEnum131", + "static transient SimpleEnum SimpleEnum132", + "static final SimpleEnum SimpleEnum133", + "static volatile SimpleEnum SimpleEnum134", + "transient final SimpleEnum SimpleEnum135", + "transient volatile SimpleEnum SimpleEnum136", + "persistence-modifier= none transient volatile SimpleEnum SimpleEnum137", + "persistence-modifier= persistent transient volatile SimpleEnum SimpleEnum138", + "persistence-modifier= persistent embedded= true transient volatile SimpleEnum SimpleEnum139", + "persistence-modifier= persistent embedded= false transient volatile SimpleEnum SimpleEnum140", + "persistence-modifier= transactional transient volatile SimpleEnum SimpleEnum141", + "static transient final SimpleEnum SimpleEnum142", + "static transient volatile SimpleEnum SimpleEnum143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public SimpleEnum get(int index) { - switch (index) { - case (0): + public SimpleEnum get(int index) + { + switch (index) + { + case(0): return SimpleEnum0; - case (1): + case(1): return SimpleEnum1; - case (2): + case(2): return SimpleEnum2; - case (3): + case(3): return SimpleEnum3; - case (4): + case(4): return SimpleEnum4; - case (5): + case(5): return SimpleEnum5; - case (6): + case(6): return SimpleEnum6; - case (7): + case(7): return SimpleEnum7; - case (8): + case(8): return SimpleEnum8; - case (9): + case(9): return SimpleEnum9; - case (10): + case(10): return SimpleEnum10; - case (11): + case(11): return SimpleEnum11; - case (12): + case(12): return SimpleEnum12; - case (13): + case(13): return SimpleEnum13; - case (14): + case(14): return SimpleEnum14; - case (15): + case(15): return SimpleEnum15; - case (16): + case(16): return SimpleEnum16; - case (17): + case(17): return SimpleEnum17; - case (18): + case(18): return SimpleEnum18; - case (19): + case(19): return SimpleEnum19; - case (20): + case(20): return SimpleEnum20; - case (21): + case(21): return SimpleEnum21; - case (22): + case(22): return SimpleEnum22; - case (23): + case(23): return SimpleEnum23; - case (24): + case(24): return SimpleEnum24; - case (25): + case(25): return SimpleEnum25; - case (26): + case(26): return SimpleEnum26; - case (27): + case(27): return SimpleEnum27; - case (28): + case(28): return SimpleEnum28; - case (29): + case(29): return SimpleEnum29; - case (30): + case(30): return SimpleEnum30; - case (31): + case(31): return SimpleEnum31; - case (32): + case(32): return SimpleEnum32; - case (33): + case(33): return SimpleEnum33; - case (34): + case(34): return SimpleEnum34; - case (35): + case(35): return SimpleEnum35; - case (36): + case(36): return SimpleEnum36; - case (37): + case(37): return SimpleEnum37; - case (38): + case(38): return SimpleEnum38; - case (39): + case(39): return SimpleEnum39; - case (40): + case(40): return SimpleEnum40; - case (41): + case(41): return SimpleEnum41; - case (42): + case(42): return SimpleEnum42; - case (43): + case(43): return SimpleEnum43; - case (44): + case(44): return SimpleEnum44; - case (45): + case(45): return SimpleEnum45; - case (46): + case(46): return SimpleEnum46; - case (47): + case(47): return SimpleEnum47; - case (48): + case(48): return SimpleEnum48; - case (49): + case(49): return SimpleEnum49; - case (50): + case(50): return SimpleEnum50; - case (51): + case(51): return SimpleEnum51; - case (52): + case(52): return SimpleEnum52; - case (53): + case(53): return SimpleEnum53; - case (54): + case(54): return SimpleEnum54; - case (55): + case(55): return SimpleEnum55; - case (56): + case(56): return SimpleEnum56; - case (57): + case(57): return SimpleEnum57; - case (58): + case(58): return SimpleEnum58; - case (59): + case(59): return SimpleEnum59; - case (60): + case(60): return SimpleEnum60; - case (61): + case(61): return SimpleEnum61; - case (62): + case(62): return SimpleEnum62; - case (63): + case(63): return SimpleEnum63; - case (64): + case(64): return SimpleEnum64; - case (65): + case(65): return SimpleEnum65; - case (66): + case(66): return SimpleEnum66; - case (67): + case(67): return SimpleEnum67; - case (68): + case(68): return SimpleEnum68; - case (69): + case(69): return SimpleEnum69; - case (70): + case(70): return SimpleEnum70; - case (71): + case(71): return SimpleEnum71; - case (72): + case(72): return SimpleEnum72; - case (73): + case(73): return SimpleEnum73; - case (74): + case(74): return SimpleEnum74; - case (75): + case(75): return SimpleEnum75; - case (76): + case(76): return SimpleEnum76; - case (77): + case(77): return SimpleEnum77; - case (78): + case(78): return SimpleEnum78; - case (79): + case(79): return SimpleEnum79; - case (80): + case(80): return SimpleEnum80; - case (81): + case(81): return SimpleEnum81; - case (82): + case(82): return SimpleEnum82; - case (83): + case(83): return SimpleEnum83; - case (84): + case(84): return SimpleEnum84; - case (85): + case(85): return SimpleEnum85; - case (86): + case(86): return SimpleEnum86; - case (87): + case(87): return SimpleEnum87; - case (88): + case(88): return SimpleEnum88; - case (89): + case(89): return SimpleEnum89; - case (90): + case(90): return SimpleEnum90; - case (91): + case(91): return SimpleEnum91; - case (92): + case(92): return SimpleEnum92; - case (93): + case(93): return SimpleEnum93; - case (94): + case(94): return SimpleEnum94; - case (95): + case(95): return SimpleEnum95; - case (96): + case(96): return SimpleEnum96; - case (97): + case(97): return SimpleEnum97; - case (98): + case(98): return SimpleEnum98; - case (99): + case(99): return SimpleEnum99; - case (100): + case(100): return SimpleEnum100; - case (101): + case(101): return SimpleEnum101; - case (102): + case(102): return SimpleEnum102; - case (103): + case(103): return SimpleEnum103; - case (104): + case(104): return SimpleEnum104; - case (105): + case(105): return SimpleEnum105; - case (106): + case(106): return SimpleEnum106; - case (107): + case(107): return SimpleEnum107; - case (108): + case(108): return SimpleEnum108; - case (109): + case(109): return SimpleEnum109; - case (110): + case(110): return SimpleEnum110; - case (111): + case(111): return SimpleEnum111; - case (112): + case(112): return SimpleEnum112; - case (113): + case(113): return SimpleEnum113; - case (114): + case(114): return SimpleEnum114; - case (115): + case(115): return SimpleEnum115; - case (116): + case(116): return SimpleEnum116; - case (117): + case(117): return SimpleEnum117; - case (118): + case(118): return SimpleEnum118; - case (119): + case(119): return SimpleEnum119; - case (120): + case(120): return SimpleEnum120; - case (121): + case(121): return SimpleEnum121; - case (122): + case(122): return SimpleEnum122; - case (123): + case(123): return SimpleEnum123; - case (124): + case(124): return SimpleEnum124; - case (125): + case(125): return SimpleEnum125; - case (126): + case(126): return SimpleEnum126; - case (127): + case(127): return SimpleEnum127; - case (128): + case(128): return SimpleEnum128; - case (129): + case(129): return SimpleEnum129; - case (130): + case(130): return SimpleEnum130; - case (131): + case(131): return SimpleEnum131; - case (132): + case(132): return SimpleEnum132; - case (133): + case(133): return SimpleEnum133; - case (134): + case(134): return SimpleEnum134; - case (135): + case(135): return SimpleEnum135; - case (136): + case(136): return SimpleEnum136; - case (137): + case(137): return SimpleEnum137; - case (138): + case(138): return SimpleEnum138; - case (139): + case(139): return SimpleEnum139; - case (140): + case(140): return SimpleEnum140; - case (141): + case(141): return SimpleEnum141; - case (142): + case(142): return SimpleEnum142; - case (143): + case(143): return SimpleEnum143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, SimpleEnum value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - SimpleEnum0 = value; - break; - case (1): - SimpleEnum1 = value; - break; - case (2): - SimpleEnum2 = value; - break; - case (3): - SimpleEnum3 = value; - break; - case (4): - SimpleEnum4 = value; - break; - case (5): - SimpleEnum5 = value; - break; - case (6): - SimpleEnum6 = value; - break; - case (7): - SimpleEnum7 = value; - break; - case (8): - SimpleEnum8 = value; - break; - case (9): - SimpleEnum9 = value; - break; - case (10): - SimpleEnum10 = value; - break; - case (11): - SimpleEnum11 = value; - break; - case (12): - SimpleEnum12 = value; - break; - case (13): - SimpleEnum13 = value; - break; - case (14): - SimpleEnum14 = value; - break; - case (16): - SimpleEnum16 = value; - break; - case (17): - SimpleEnum17 = value; - break; - case (18): - SimpleEnum18 = value; - break; - case (19): - SimpleEnum19 = value; - break; - case (20): - SimpleEnum20 = value; - break; - case (21): - SimpleEnum21 = value; - break; - case (22): - SimpleEnum22 = value; - break; - case (23): - SimpleEnum23 = value; - break; - case (24): - SimpleEnum24 = value; - break; - case (26): - SimpleEnum26 = value; - break; - case (28): - SimpleEnum28 = value; - break; - case (29): - SimpleEnum29 = value; - break; - case (30): - SimpleEnum30 = value; - break; - case (31): - SimpleEnum31 = value; - break; - case (32): - SimpleEnum32 = value; - break; - case (33): - SimpleEnum33 = value; - break; - case (35): - SimpleEnum35 = value; - break; - case (36): - SimpleEnum36 = value; - break; - case (37): - SimpleEnum37 = value; - break; - case (38): - SimpleEnum38 = value; - break; - case (39): - SimpleEnum39 = value; - break; - case (40): - SimpleEnum40 = value; - break; - case (41): - SimpleEnum41 = value; - break; - case (42): - SimpleEnum42 = value; - break; - case (43): - SimpleEnum43 = value; - break; - case (44): - SimpleEnum44 = value; - break; - case (45): - SimpleEnum45 = value; - break; - case (46): - SimpleEnum46 = value; - break; - case (47): - SimpleEnum47 = value; - break; - case (48): - SimpleEnum48 = value; - break; - case (49): - SimpleEnum49 = value; - break; - case (50): - SimpleEnum50 = value; - break; - case (52): - SimpleEnum52 = value; - break; - case (53): - SimpleEnum53 = value; - break; - case (54): - SimpleEnum54 = value; - break; - case (55): - SimpleEnum55 = value; - break; - case (56): - SimpleEnum56 = value; - break; - case (57): - SimpleEnum57 = value; - break; - case (58): - SimpleEnum58 = value; - break; - case (59): - SimpleEnum59 = value; - break; - case (60): - SimpleEnum60 = value; - break; - case (62): - SimpleEnum62 = value; - break; - case (64): - SimpleEnum64 = value; - break; - case (65): - SimpleEnum65 = value; - break; - case (66): - SimpleEnum66 = value; - break; - case (67): - SimpleEnum67 = value; - break; - case (68): - SimpleEnum68 = value; - break; - case (69): - SimpleEnum69 = value; - break; - case (71): - SimpleEnum71 = value; - break; - case (72): - SimpleEnum72 = value; - break; - case (73): - SimpleEnum73 = value; - break; - case (74): - SimpleEnum74 = value; - break; - case (75): - SimpleEnum75 = value; - break; - case (76): - SimpleEnum76 = value; - break; - case (77): - SimpleEnum77 = value; - break; - case (78): - SimpleEnum78 = value; - break; - case (79): - SimpleEnum79 = value; - break; - case (80): - SimpleEnum80 = value; - break; - case (81): - SimpleEnum81 = value; - break; - case (82): - SimpleEnum82 = value; - break; - case (83): - SimpleEnum83 = value; - break; - case (84): - SimpleEnum84 = value; - break; - case (85): - SimpleEnum85 = value; - break; - case (86): - SimpleEnum86 = value; - break; - case (88): - SimpleEnum88 = value; - break; - case (89): - SimpleEnum89 = value; - break; - case (90): - SimpleEnum90 = value; - break; - case (91): - SimpleEnum91 = value; - break; - case (92): - SimpleEnum92 = value; - break; - case (93): - SimpleEnum93 = value; - break; - case (94): - SimpleEnum94 = value; - break; - case (95): - SimpleEnum95 = value; - break; - case (96): - SimpleEnum96 = value; - break; - case (98): - SimpleEnum98 = value; - break; - case (100): - SimpleEnum100 = value; - break; - case (101): - SimpleEnum101 = value; - break; - case (102): - SimpleEnum102 = value; - break; - case (103): - SimpleEnum103 = value; - break; - case (104): - SimpleEnum104 = value; - break; - case (105): - SimpleEnum105 = value; - break; - case (107): - SimpleEnum107 = value; - break; - case (108): - SimpleEnum108 = value; - break; - case (109): - SimpleEnum109 = value; - break; - case (110): - SimpleEnum110 = value; - break; - case (111): - SimpleEnum111 = value; - break; - case (112): - SimpleEnum112 = value; - break; - case (113): - SimpleEnum113 = value; - break; - case (114): - SimpleEnum114 = value; - break; - case (115): - SimpleEnum115 = value; - break; - case (116): - SimpleEnum116 = value; - break; - case (117): - SimpleEnum117 = value; - break; - case (118): - SimpleEnum118 = value; - break; - case (119): - SimpleEnum119 = value; - break; - case (120): - SimpleEnum120 = value; - break; - case (121): - SimpleEnum121 = value; - break; - case (122): - SimpleEnum122 = value; - break; - case (124): - SimpleEnum124 = value; - break; - case (125): - SimpleEnum125 = value; - break; - case (126): - SimpleEnum126 = value; - break; - case (127): - SimpleEnum127 = value; - break; - case (128): - SimpleEnum128 = value; - break; - case (129): - SimpleEnum129 = value; - break; - case (130): - SimpleEnum130 = value; - break; - case (131): - SimpleEnum131 = value; - break; - case (132): - SimpleEnum132 = value; - break; - case (134): - SimpleEnum134 = value; - break; - case (136): - SimpleEnum136 = value; - break; - case (137): - SimpleEnum137 = value; - break; - case (138): - SimpleEnum138 = value; - break; - case (139): - SimpleEnum139 = value; - break; - case (140): - SimpleEnum140 = value; - break; - case (141): - SimpleEnum141 = value; - break; - case (143): - SimpleEnum143 = value; - break; + public boolean set(int index,SimpleEnum value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + SimpleEnum0= value; + break; + case(1): + SimpleEnum1= value; + break; + case(2): + SimpleEnum2= value; + break; + case(3): + SimpleEnum3= value; + break; + case(4): + SimpleEnum4= value; + break; + case(5): + SimpleEnum5= value; + break; + case(6): + SimpleEnum6= value; + break; + case(7): + SimpleEnum7= value; + break; + case(8): + SimpleEnum8= value; + break; + case(9): + SimpleEnum9= value; + break; + case(10): + SimpleEnum10= value; + break; + case(11): + SimpleEnum11= value; + break; + case(12): + SimpleEnum12= value; + break; + case(13): + SimpleEnum13= value; + break; + case(14): + SimpleEnum14= value; + break; + case(16): + SimpleEnum16= value; + break; + case(17): + SimpleEnum17= value; + break; + case(18): + SimpleEnum18= value; + break; + case(19): + SimpleEnum19= value; + break; + case(20): + SimpleEnum20= value; + break; + case(21): + SimpleEnum21= value; + break; + case(22): + SimpleEnum22= value; + break; + case(23): + SimpleEnum23= value; + break; + case(24): + SimpleEnum24= value; + break; + case(26): + SimpleEnum26= value; + break; + case(28): + SimpleEnum28= value; + break; + case(29): + SimpleEnum29= value; + break; + case(30): + SimpleEnum30= value; + break; + case(31): + SimpleEnum31= value; + break; + case(32): + SimpleEnum32= value; + break; + case(33): + SimpleEnum33= value; + break; + case(35): + SimpleEnum35= value; + break; + case(36): + SimpleEnum36= value; + break; + case(37): + SimpleEnum37= value; + break; + case(38): + SimpleEnum38= value; + break; + case(39): + SimpleEnum39= value; + break; + case(40): + SimpleEnum40= value; + break; + case(41): + SimpleEnum41= value; + break; + case(42): + SimpleEnum42= value; + break; + case(43): + SimpleEnum43= value; + break; + case(44): + SimpleEnum44= value; + break; + case(45): + SimpleEnum45= value; + break; + case(46): + SimpleEnum46= value; + break; + case(47): + SimpleEnum47= value; + break; + case(48): + SimpleEnum48= value; + break; + case(49): + SimpleEnum49= value; + break; + case(50): + SimpleEnum50= value; + break; + case(52): + SimpleEnum52= value; + break; + case(53): + SimpleEnum53= value; + break; + case(54): + SimpleEnum54= value; + break; + case(55): + SimpleEnum55= value; + break; + case(56): + SimpleEnum56= value; + break; + case(57): + SimpleEnum57= value; + break; + case(58): + SimpleEnum58= value; + break; + case(59): + SimpleEnum59= value; + break; + case(60): + SimpleEnum60= value; + break; + case(62): + SimpleEnum62= value; + break; + case(64): + SimpleEnum64= value; + break; + case(65): + SimpleEnum65= value; + break; + case(66): + SimpleEnum66= value; + break; + case(67): + SimpleEnum67= value; + break; + case(68): + SimpleEnum68= value; + break; + case(69): + SimpleEnum69= value; + break; + case(71): + SimpleEnum71= value; + break; + case(72): + SimpleEnum72= value; + break; + case(73): + SimpleEnum73= value; + break; + case(74): + SimpleEnum74= value; + break; + case(75): + SimpleEnum75= value; + break; + case(76): + SimpleEnum76= value; + break; + case(77): + SimpleEnum77= value; + break; + case(78): + SimpleEnum78= value; + break; + case(79): + SimpleEnum79= value; + break; + case(80): + SimpleEnum80= value; + break; + case(81): + SimpleEnum81= value; + break; + case(82): + SimpleEnum82= value; + break; + case(83): + SimpleEnum83= value; + break; + case(84): + SimpleEnum84= value; + break; + case(85): + SimpleEnum85= value; + break; + case(86): + SimpleEnum86= value; + break; + case(88): + SimpleEnum88= value; + break; + case(89): + SimpleEnum89= value; + break; + case(90): + SimpleEnum90= value; + break; + case(91): + SimpleEnum91= value; + break; + case(92): + SimpleEnum92= value; + break; + case(93): + SimpleEnum93= value; + break; + case(94): + SimpleEnum94= value; + break; + case(95): + SimpleEnum95= value; + break; + case(96): + SimpleEnum96= value; + break; + case(98): + SimpleEnum98= value; + break; + case(100): + SimpleEnum100= value; + break; + case(101): + SimpleEnum101= value; + break; + case(102): + SimpleEnum102= value; + break; + case(103): + SimpleEnum103= value; + break; + case(104): + SimpleEnum104= value; + break; + case(105): + SimpleEnum105= value; + break; + case(107): + SimpleEnum107= value; + break; + case(108): + SimpleEnum108= value; + break; + case(109): + SimpleEnum109= value; + break; + case(110): + SimpleEnum110= value; + break; + case(111): + SimpleEnum111= value; + break; + case(112): + SimpleEnum112= value; + break; + case(113): + SimpleEnum113= value; + break; + case(114): + SimpleEnum114= value; + break; + case(115): + SimpleEnum115= value; + break; + case(116): + SimpleEnum116= value; + break; + case(117): + SimpleEnum117= value; + break; + case(118): + SimpleEnum118= value; + break; + case(119): + SimpleEnum119= value; + break; + case(120): + SimpleEnum120= value; + break; + case(121): + SimpleEnum121= value; + break; + case(122): + SimpleEnum122= value; + break; + case(124): + SimpleEnum124= value; + break; + case(125): + SimpleEnum125= value; + break; + case(126): + SimpleEnum126= value; + break; + case(127): + SimpleEnum127= value; + break; + case(128): + SimpleEnum128= value; + break; + case(129): + SimpleEnum129= value; + break; + case(130): + SimpleEnum130= value; + break; + case(131): + SimpleEnum131= value; + break; + case(132): + SimpleEnum132= value; + break; + case(134): + SimpleEnum134= value; + break; + case(136): + SimpleEnum136= value; + break; + case(137): + SimpleEnum137= value; + break; + case(138): + SimpleEnum138= value; + break; + case(139): + SimpleEnum139= value; + break; + case(140): + SimpleEnum140= value; + break; + case(141): + SimpleEnum141= value; + break; + case(143): + SimpleEnum143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } - - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public int hashCode() { - return (int) identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public int hashCode() { return (int)identifier ; } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfSimpleInterface.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfSimpleInterface.java index 7b088a5c5..20c076674 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfSimpleInterface.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfSimpleInterface.java @@ -5,21 +5,21 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -public class FieldsOfSimpleInterface { +public class FieldsOfSimpleInterface { public int identifier; private SimpleInterface SimpleInterface0; private SimpleInterface SimpleInterface1; @@ -48,14 +48,14 @@ public class FieldsOfSimpleInterface { private static transient SimpleInterface SimpleInterface24; private static final SimpleInterface SimpleInterface25 = new SimpleClass(); private static volatile SimpleInterface SimpleInterface26; - private final transient SimpleInterface SimpleInterface27 = new SimpleClass(); + private transient final SimpleInterface SimpleInterface27 = new SimpleClass(); private transient volatile SimpleInterface SimpleInterface28; private transient volatile SimpleInterface SimpleInterface29; private transient volatile SimpleInterface SimpleInterface30; private transient volatile SimpleInterface SimpleInterface31; private transient volatile SimpleInterface SimpleInterface32; private transient volatile SimpleInterface SimpleInterface33; - private static final transient SimpleInterface SimpleInterface34 = new SimpleClass(); + private static transient final SimpleInterface SimpleInterface34 = new SimpleClass(); private static transient volatile SimpleInterface SimpleInterface35; public SimpleInterface SimpleInterface36; public SimpleInterface SimpleInterface37; @@ -84,14 +84,14 @@ public class FieldsOfSimpleInterface { public static transient SimpleInterface SimpleInterface60; public static final SimpleInterface SimpleInterface61 = new SimpleClass(); public static volatile SimpleInterface SimpleInterface62; - public final transient SimpleInterface SimpleInterface63 = new SimpleClass(); + public transient final SimpleInterface SimpleInterface63 = new SimpleClass(); public transient volatile SimpleInterface SimpleInterface64; public transient volatile SimpleInterface SimpleInterface65; public transient volatile SimpleInterface SimpleInterface66; public transient volatile SimpleInterface SimpleInterface67; public transient volatile SimpleInterface SimpleInterface68; public transient volatile SimpleInterface SimpleInterface69; - public static final transient SimpleInterface SimpleInterface70 = new SimpleClass(); + public static transient final SimpleInterface SimpleInterface70 = new SimpleClass(); public static transient volatile SimpleInterface SimpleInterface71; protected SimpleInterface SimpleInterface72; protected SimpleInterface SimpleInterface73; @@ -120,14 +120,14 @@ public class FieldsOfSimpleInterface { protected static transient SimpleInterface SimpleInterface96; protected static final SimpleInterface SimpleInterface97 = new SimpleClass(); protected static volatile SimpleInterface SimpleInterface98; - protected final transient SimpleInterface SimpleInterface99 = new SimpleClass(); + protected transient final SimpleInterface SimpleInterface99 = new SimpleClass(); protected transient volatile SimpleInterface SimpleInterface100; protected transient volatile SimpleInterface SimpleInterface101; protected transient volatile SimpleInterface SimpleInterface102; protected transient volatile SimpleInterface SimpleInterface103; protected transient volatile SimpleInterface SimpleInterface104; protected transient volatile SimpleInterface SimpleInterface105; - protected static final transient SimpleInterface SimpleInterface106 = new SimpleClass(); + protected static transient final SimpleInterface SimpleInterface106 = new SimpleClass(); protected static transient volatile SimpleInterface SimpleInterface107; SimpleInterface SimpleInterface108; SimpleInterface SimpleInterface109; @@ -156,936 +156,935 @@ public class FieldsOfSimpleInterface { static transient SimpleInterface SimpleInterface132; static final SimpleInterface SimpleInterface133 = new SimpleClass(); static volatile SimpleInterface SimpleInterface134; - final transient SimpleInterface SimpleInterface135 = new SimpleClass(); + transient final SimpleInterface SimpleInterface135 = new SimpleClass(); transient volatile SimpleInterface SimpleInterface136; transient volatile SimpleInterface SimpleInterface137; transient volatile SimpleInterface SimpleInterface138; transient volatile SimpleInterface SimpleInterface139; transient volatile SimpleInterface SimpleInterface140; transient volatile SimpleInterface SimpleInterface141; - static final transient SimpleInterface SimpleInterface142 = new SimpleClass(); + static transient final SimpleInterface SimpleInterface142 = new SimpleClass(); static transient volatile SimpleInterface SimpleInterface143; - public static final boolean[] isPersistent = { - false, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, false, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, false, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, false, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, false, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +false,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,false,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,false,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,false,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,false,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private SimpleInterface SimpleInterface0", - "serialized= true private SimpleInterface SimpleInterface1", - "embedded= false private SimpleInterface SimpleInterface2", - "persistence-modifier= none private SimpleInterface SimpleInterface3", - "persistence-modifier= persistent private SimpleInterface SimpleInterface4", - "persistence-modifier= persistent serialized= true private SimpleInterface SimpleInterface5", - "persistence-modifier= persistent embedded= false private SimpleInterface SimpleInterface6", - "persistence-modifier= transactional private SimpleInterface SimpleInterface7", - "private static SimpleInterface SimpleInterface8", - "private transient SimpleInterface SimpleInterface9", - "persistence-modifier= none private transient SimpleInterface SimpleInterface10", - "persistence-modifier= persistent private transient SimpleInterface SimpleInterface11", - "persistence-modifier= persistent serialized= true private transient SimpleInterface SimpleInterface12", - "persistence-modifier= persistent embedded= false private transient SimpleInterface SimpleInterface13", - "persistence-modifier= transactional private transient SimpleInterface SimpleInterface14", - "private final SimpleInterface SimpleInterface15", - "private volatile SimpleInterface SimpleInterface16", - "serialized= true private volatile SimpleInterface SimpleInterface17", - "embedded= false private volatile SimpleInterface SimpleInterface18", - "persistence-modifier= none private volatile SimpleInterface SimpleInterface19", - "persistence-modifier= persistent private volatile SimpleInterface SimpleInterface20", - "persistence-modifier= persistent serialized= true private volatile SimpleInterface SimpleInterface21", - "persistence-modifier= persistent embedded= false private volatile SimpleInterface SimpleInterface22", - "persistence-modifier= transactional private volatile SimpleInterface SimpleInterface23", - "private static transient SimpleInterface SimpleInterface24", - "private static final SimpleInterface SimpleInterface25", - "private static volatile SimpleInterface SimpleInterface26", - "private transient final SimpleInterface SimpleInterface27", - "private transient volatile SimpleInterface SimpleInterface28", - "persistence-modifier= none private transient volatile SimpleInterface SimpleInterface29", - "persistence-modifier= persistent private transient volatile SimpleInterface SimpleInterface30", - "persistence-modifier= persistent serialized= true private transient volatile SimpleInterface SimpleInterface31", - "persistence-modifier= persistent embedded= false private transient volatile SimpleInterface SimpleInterface32", - "persistence-modifier= transactional private transient volatile SimpleInterface SimpleInterface33", - "private static transient final SimpleInterface SimpleInterface34", - "private static transient volatile SimpleInterface SimpleInterface35", - "public SimpleInterface SimpleInterface36", - "serialized= true public SimpleInterface SimpleInterface37", - "embedded= false public SimpleInterface SimpleInterface38", - "persistence-modifier= none public SimpleInterface SimpleInterface39", - "persistence-modifier= persistent public SimpleInterface SimpleInterface40", - "persistence-modifier= persistent serialized= true public SimpleInterface SimpleInterface41", - "persistence-modifier= persistent embedded= false public SimpleInterface SimpleInterface42", - "persistence-modifier= transactional public SimpleInterface SimpleInterface43", - "public static SimpleInterface SimpleInterface44", - "public transient SimpleInterface SimpleInterface45", - "persistence-modifier= none public transient SimpleInterface SimpleInterface46", - "persistence-modifier= persistent public transient SimpleInterface SimpleInterface47", - "persistence-modifier= persistent serialized= true public transient SimpleInterface SimpleInterface48", - "persistence-modifier= persistent embedded= false public transient SimpleInterface SimpleInterface49", - "persistence-modifier= transactional public transient SimpleInterface SimpleInterface50", - "public final SimpleInterface SimpleInterface51", - "public volatile SimpleInterface SimpleInterface52", - "serialized= true public volatile SimpleInterface SimpleInterface53", - "embedded= false public volatile SimpleInterface SimpleInterface54", - "persistence-modifier= none public volatile SimpleInterface SimpleInterface55", - "persistence-modifier= persistent public volatile SimpleInterface SimpleInterface56", - "persistence-modifier= persistent serialized= true public volatile SimpleInterface SimpleInterface57", - "persistence-modifier= persistent embedded= false public volatile SimpleInterface SimpleInterface58", - "persistence-modifier= transactional public volatile SimpleInterface SimpleInterface59", - "public static transient SimpleInterface SimpleInterface60", - "public static final SimpleInterface SimpleInterface61", - "public static volatile SimpleInterface SimpleInterface62", - "public transient final SimpleInterface SimpleInterface63", - "public transient volatile SimpleInterface SimpleInterface64", - "persistence-modifier= none public transient volatile SimpleInterface SimpleInterface65", - "persistence-modifier= persistent public transient volatile SimpleInterface SimpleInterface66", - "persistence-modifier= persistent serialized= true public transient volatile SimpleInterface SimpleInterface67", - "persistence-modifier= persistent embedded= false public transient volatile SimpleInterface SimpleInterface68", - "persistence-modifier= transactional public transient volatile SimpleInterface SimpleInterface69", - "public static transient final SimpleInterface SimpleInterface70", - "public static transient volatile SimpleInterface SimpleInterface71", - "protected SimpleInterface SimpleInterface72", - "serialized= true protected SimpleInterface SimpleInterface73", - "embedded= false protected SimpleInterface SimpleInterface74", - "persistence-modifier= none protected SimpleInterface SimpleInterface75", - "persistence-modifier= persistent protected SimpleInterface SimpleInterface76", - "persistence-modifier= persistent serialized= true protected SimpleInterface SimpleInterface77", - "persistence-modifier= persistent embedded= false protected SimpleInterface SimpleInterface78", - "persistence-modifier= transactional protected SimpleInterface SimpleInterface79", - "protected static SimpleInterface SimpleInterface80", - "protected transient SimpleInterface SimpleInterface81", - "persistence-modifier= none protected transient SimpleInterface SimpleInterface82", - "persistence-modifier= persistent protected transient SimpleInterface SimpleInterface83", - "persistence-modifier= persistent serialized= true protected transient SimpleInterface SimpleInterface84", - "persistence-modifier= persistent embedded= false protected transient SimpleInterface SimpleInterface85", - "persistence-modifier= transactional protected transient SimpleInterface SimpleInterface86", - "protected final SimpleInterface SimpleInterface87", - "protected volatile SimpleInterface SimpleInterface88", - "serialized= true protected volatile SimpleInterface SimpleInterface89", - "embedded= false protected volatile SimpleInterface SimpleInterface90", - "persistence-modifier= none protected volatile SimpleInterface SimpleInterface91", - "persistence-modifier= persistent protected volatile SimpleInterface SimpleInterface92", - "persistence-modifier= persistent serialized= true protected volatile SimpleInterface SimpleInterface93", - "persistence-modifier= persistent embedded= false protected volatile SimpleInterface SimpleInterface94", - "persistence-modifier= transactional protected volatile SimpleInterface SimpleInterface95", - "protected static transient SimpleInterface SimpleInterface96", - "protected static final SimpleInterface SimpleInterface97", - "protected static volatile SimpleInterface SimpleInterface98", - "protected transient final SimpleInterface SimpleInterface99", - "protected transient volatile SimpleInterface SimpleInterface100", - "persistence-modifier= none protected transient volatile SimpleInterface SimpleInterface101", - "persistence-modifier= persistent protected transient volatile SimpleInterface SimpleInterface102", - "persistence-modifier= persistent serialized= true protected transient volatile SimpleInterface SimpleInterface103", - "persistence-modifier= persistent embedded= false protected transient volatile SimpleInterface SimpleInterface104", - "persistence-modifier= transactional protected transient volatile SimpleInterface SimpleInterface105", - "protected static transient final SimpleInterface SimpleInterface106", - "protected static transient volatile SimpleInterface SimpleInterface107", - "SimpleInterface SimpleInterface108", - "serialized= true SimpleInterface SimpleInterface109", - "embedded= false SimpleInterface SimpleInterface110", - "persistence-modifier= none SimpleInterface SimpleInterface111", - "persistence-modifier= persistent SimpleInterface SimpleInterface112", - "persistence-modifier= persistent serialized= true SimpleInterface SimpleInterface113", - "persistence-modifier= persistent embedded= false SimpleInterface SimpleInterface114", - "persistence-modifier= transactional SimpleInterface SimpleInterface115", - "static SimpleInterface SimpleInterface116", - "transient SimpleInterface SimpleInterface117", - "persistence-modifier= none transient SimpleInterface SimpleInterface118", - "persistence-modifier= persistent transient SimpleInterface SimpleInterface119", - "persistence-modifier= persistent serialized= true transient SimpleInterface SimpleInterface120", - "persistence-modifier= persistent embedded= false transient SimpleInterface SimpleInterface121", - "persistence-modifier= transactional transient SimpleInterface SimpleInterface122", - "final SimpleInterface SimpleInterface123", - "volatile SimpleInterface SimpleInterface124", - "serialized= true volatile SimpleInterface SimpleInterface125", - "embedded= false volatile SimpleInterface SimpleInterface126", - "persistence-modifier= none volatile SimpleInterface SimpleInterface127", - "persistence-modifier= persistent volatile SimpleInterface SimpleInterface128", - "persistence-modifier= persistent serialized= true volatile SimpleInterface SimpleInterface129", - "persistence-modifier= persistent embedded= false volatile SimpleInterface SimpleInterface130", - "persistence-modifier= transactional volatile SimpleInterface SimpleInterface131", - "static transient SimpleInterface SimpleInterface132", - "static final SimpleInterface SimpleInterface133", - "static volatile SimpleInterface SimpleInterface134", - "transient final SimpleInterface SimpleInterface135", - "transient volatile SimpleInterface SimpleInterface136", - "persistence-modifier= none transient volatile SimpleInterface SimpleInterface137", - "persistence-modifier= persistent transient volatile SimpleInterface SimpleInterface138", - "persistence-modifier= persistent serialized= true transient volatile SimpleInterface SimpleInterface139", - "persistence-modifier= persistent embedded= false transient volatile SimpleInterface SimpleInterface140", - "persistence-modifier= transactional transient volatile SimpleInterface SimpleInterface141", - "static transient final SimpleInterface SimpleInterface142", - "static transient volatile SimpleInterface SimpleInterface143" + public static final String [] fieldSpecs = { + "private SimpleInterface SimpleInterface0", + "serialized= true private SimpleInterface SimpleInterface1", + "embedded= false private SimpleInterface SimpleInterface2", + "persistence-modifier= none private SimpleInterface SimpleInterface3", + "persistence-modifier= persistent private SimpleInterface SimpleInterface4", + "persistence-modifier= persistent serialized= true private SimpleInterface SimpleInterface5", + "persistence-modifier= persistent embedded= false private SimpleInterface SimpleInterface6", + "persistence-modifier= transactional private SimpleInterface SimpleInterface7", + "private static SimpleInterface SimpleInterface8", + "private transient SimpleInterface SimpleInterface9", + "persistence-modifier= none private transient SimpleInterface SimpleInterface10", + "persistence-modifier= persistent private transient SimpleInterface SimpleInterface11", + "persistence-modifier= persistent serialized= true private transient SimpleInterface SimpleInterface12", + "persistence-modifier= persistent embedded= false private transient SimpleInterface SimpleInterface13", + "persistence-modifier= transactional private transient SimpleInterface SimpleInterface14", + "private final SimpleInterface SimpleInterface15", + "private volatile SimpleInterface SimpleInterface16", + "serialized= true private volatile SimpleInterface SimpleInterface17", + "embedded= false private volatile SimpleInterface SimpleInterface18", + "persistence-modifier= none private volatile SimpleInterface SimpleInterface19", + "persistence-modifier= persistent private volatile SimpleInterface SimpleInterface20", + "persistence-modifier= persistent serialized= true private volatile SimpleInterface SimpleInterface21", + "persistence-modifier= persistent embedded= false private volatile SimpleInterface SimpleInterface22", + "persistence-modifier= transactional private volatile SimpleInterface SimpleInterface23", + "private static transient SimpleInterface SimpleInterface24", + "private static final SimpleInterface SimpleInterface25", + "private static volatile SimpleInterface SimpleInterface26", + "private transient final SimpleInterface SimpleInterface27", + "private transient volatile SimpleInterface SimpleInterface28", + "persistence-modifier= none private transient volatile SimpleInterface SimpleInterface29", + "persistence-modifier= persistent private transient volatile SimpleInterface SimpleInterface30", + "persistence-modifier= persistent serialized= true private transient volatile SimpleInterface SimpleInterface31", + "persistence-modifier= persistent embedded= false private transient volatile SimpleInterface SimpleInterface32", + "persistence-modifier= transactional private transient volatile SimpleInterface SimpleInterface33", + "private static transient final SimpleInterface SimpleInterface34", + "private static transient volatile SimpleInterface SimpleInterface35", + "public SimpleInterface SimpleInterface36", + "serialized= true public SimpleInterface SimpleInterface37", + "embedded= false public SimpleInterface SimpleInterface38", + "persistence-modifier= none public SimpleInterface SimpleInterface39", + "persistence-modifier= persistent public SimpleInterface SimpleInterface40", + "persistence-modifier= persistent serialized= true public SimpleInterface SimpleInterface41", + "persistence-modifier= persistent embedded= false public SimpleInterface SimpleInterface42", + "persistence-modifier= transactional public SimpleInterface SimpleInterface43", + "public static SimpleInterface SimpleInterface44", + "public transient SimpleInterface SimpleInterface45", + "persistence-modifier= none public transient SimpleInterface SimpleInterface46", + "persistence-modifier= persistent public transient SimpleInterface SimpleInterface47", + "persistence-modifier= persistent serialized= true public transient SimpleInterface SimpleInterface48", + "persistence-modifier= persistent embedded= false public transient SimpleInterface SimpleInterface49", + "persistence-modifier= transactional public transient SimpleInterface SimpleInterface50", + "public final SimpleInterface SimpleInterface51", + "public volatile SimpleInterface SimpleInterface52", + "serialized= true public volatile SimpleInterface SimpleInterface53", + "embedded= false public volatile SimpleInterface SimpleInterface54", + "persistence-modifier= none public volatile SimpleInterface SimpleInterface55", + "persistence-modifier= persistent public volatile SimpleInterface SimpleInterface56", + "persistence-modifier= persistent serialized= true public volatile SimpleInterface SimpleInterface57", + "persistence-modifier= persistent embedded= false public volatile SimpleInterface SimpleInterface58", + "persistence-modifier= transactional public volatile SimpleInterface SimpleInterface59", + "public static transient SimpleInterface SimpleInterface60", + "public static final SimpleInterface SimpleInterface61", + "public static volatile SimpleInterface SimpleInterface62", + "public transient final SimpleInterface SimpleInterface63", + "public transient volatile SimpleInterface SimpleInterface64", + "persistence-modifier= none public transient volatile SimpleInterface SimpleInterface65", + "persistence-modifier= persistent public transient volatile SimpleInterface SimpleInterface66", + "persistence-modifier= persistent serialized= true public transient volatile SimpleInterface SimpleInterface67", + "persistence-modifier= persistent embedded= false public transient volatile SimpleInterface SimpleInterface68", + "persistence-modifier= transactional public transient volatile SimpleInterface SimpleInterface69", + "public static transient final SimpleInterface SimpleInterface70", + "public static transient volatile SimpleInterface SimpleInterface71", + "protected SimpleInterface SimpleInterface72", + "serialized= true protected SimpleInterface SimpleInterface73", + "embedded= false protected SimpleInterface SimpleInterface74", + "persistence-modifier= none protected SimpleInterface SimpleInterface75", + "persistence-modifier= persistent protected SimpleInterface SimpleInterface76", + "persistence-modifier= persistent serialized= true protected SimpleInterface SimpleInterface77", + "persistence-modifier= persistent embedded= false protected SimpleInterface SimpleInterface78", + "persistence-modifier= transactional protected SimpleInterface SimpleInterface79", + "protected static SimpleInterface SimpleInterface80", + "protected transient SimpleInterface SimpleInterface81", + "persistence-modifier= none protected transient SimpleInterface SimpleInterface82", + "persistence-modifier= persistent protected transient SimpleInterface SimpleInterface83", + "persistence-modifier= persistent serialized= true protected transient SimpleInterface SimpleInterface84", + "persistence-modifier= persistent embedded= false protected transient SimpleInterface SimpleInterface85", + "persistence-modifier= transactional protected transient SimpleInterface SimpleInterface86", + "protected final SimpleInterface SimpleInterface87", + "protected volatile SimpleInterface SimpleInterface88", + "serialized= true protected volatile SimpleInterface SimpleInterface89", + "embedded= false protected volatile SimpleInterface SimpleInterface90", + "persistence-modifier= none protected volatile SimpleInterface SimpleInterface91", + "persistence-modifier= persistent protected volatile SimpleInterface SimpleInterface92", + "persistence-modifier= persistent serialized= true protected volatile SimpleInterface SimpleInterface93", + "persistence-modifier= persistent embedded= false protected volatile SimpleInterface SimpleInterface94", + "persistence-modifier= transactional protected volatile SimpleInterface SimpleInterface95", + "protected static transient SimpleInterface SimpleInterface96", + "protected static final SimpleInterface SimpleInterface97", + "protected static volatile SimpleInterface SimpleInterface98", + "protected transient final SimpleInterface SimpleInterface99", + "protected transient volatile SimpleInterface SimpleInterface100", + "persistence-modifier= none protected transient volatile SimpleInterface SimpleInterface101", + "persistence-modifier= persistent protected transient volatile SimpleInterface SimpleInterface102", + "persistence-modifier= persistent serialized= true protected transient volatile SimpleInterface SimpleInterface103", + "persistence-modifier= persistent embedded= false protected transient volatile SimpleInterface SimpleInterface104", + "persistence-modifier= transactional protected transient volatile SimpleInterface SimpleInterface105", + "protected static transient final SimpleInterface SimpleInterface106", + "protected static transient volatile SimpleInterface SimpleInterface107", + "SimpleInterface SimpleInterface108", + "serialized= true SimpleInterface SimpleInterface109", + "embedded= false SimpleInterface SimpleInterface110", + "persistence-modifier= none SimpleInterface SimpleInterface111", + "persistence-modifier= persistent SimpleInterface SimpleInterface112", + "persistence-modifier= persistent serialized= true SimpleInterface SimpleInterface113", + "persistence-modifier= persistent embedded= false SimpleInterface SimpleInterface114", + "persistence-modifier= transactional SimpleInterface SimpleInterface115", + "static SimpleInterface SimpleInterface116", + "transient SimpleInterface SimpleInterface117", + "persistence-modifier= none transient SimpleInterface SimpleInterface118", + "persistence-modifier= persistent transient SimpleInterface SimpleInterface119", + "persistence-modifier= persistent serialized= true transient SimpleInterface SimpleInterface120", + "persistence-modifier= persistent embedded= false transient SimpleInterface SimpleInterface121", + "persistence-modifier= transactional transient SimpleInterface SimpleInterface122", + "final SimpleInterface SimpleInterface123", + "volatile SimpleInterface SimpleInterface124", + "serialized= true volatile SimpleInterface SimpleInterface125", + "embedded= false volatile SimpleInterface SimpleInterface126", + "persistence-modifier= none volatile SimpleInterface SimpleInterface127", + "persistence-modifier= persistent volatile SimpleInterface SimpleInterface128", + "persistence-modifier= persistent serialized= true volatile SimpleInterface SimpleInterface129", + "persistence-modifier= persistent embedded= false volatile SimpleInterface SimpleInterface130", + "persistence-modifier= transactional volatile SimpleInterface SimpleInterface131", + "static transient SimpleInterface SimpleInterface132", + "static final SimpleInterface SimpleInterface133", + "static volatile SimpleInterface SimpleInterface134", + "transient final SimpleInterface SimpleInterface135", + "transient volatile SimpleInterface SimpleInterface136", + "persistence-modifier= none transient volatile SimpleInterface SimpleInterface137", + "persistence-modifier= persistent transient volatile SimpleInterface SimpleInterface138", + "persistence-modifier= persistent serialized= true transient volatile SimpleInterface SimpleInterface139", + "persistence-modifier= persistent embedded= false transient volatile SimpleInterface SimpleInterface140", + "persistence-modifier= transactional transient volatile SimpleInterface SimpleInterface141", + "static transient final SimpleInterface SimpleInterface142", + "static transient volatile SimpleInterface SimpleInterface143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public SimpleInterface get(int index) { - switch (index) { - case (0): + public SimpleInterface get(int index) + { + switch (index) + { + case(0): return SimpleInterface0; - case (1): + case(1): return SimpleInterface1; - case (2): + case(2): return SimpleInterface2; - case (3): + case(3): return SimpleInterface3; - case (4): + case(4): return SimpleInterface4; - case (5): + case(5): return SimpleInterface5; - case (6): + case(6): return SimpleInterface6; - case (7): + case(7): return SimpleInterface7; - case (8): + case(8): return SimpleInterface8; - case (9): + case(9): return SimpleInterface9; - case (10): + case(10): return SimpleInterface10; - case (11): + case(11): return SimpleInterface11; - case (12): + case(12): return SimpleInterface12; - case (13): + case(13): return SimpleInterface13; - case (14): + case(14): return SimpleInterface14; - case (15): + case(15): return SimpleInterface15; - case (16): + case(16): return SimpleInterface16; - case (17): + case(17): return SimpleInterface17; - case (18): + case(18): return SimpleInterface18; - case (19): + case(19): return SimpleInterface19; - case (20): + case(20): return SimpleInterface20; - case (21): + case(21): return SimpleInterface21; - case (22): + case(22): return SimpleInterface22; - case (23): + case(23): return SimpleInterface23; - case (24): + case(24): return SimpleInterface24; - case (25): + case(25): return SimpleInterface25; - case (26): + case(26): return SimpleInterface26; - case (27): + case(27): return SimpleInterface27; - case (28): + case(28): return SimpleInterface28; - case (29): + case(29): return SimpleInterface29; - case (30): + case(30): return SimpleInterface30; - case (31): + case(31): return SimpleInterface31; - case (32): + case(32): return SimpleInterface32; - case (33): + case(33): return SimpleInterface33; - case (34): + case(34): return SimpleInterface34; - case (35): + case(35): return SimpleInterface35; - case (36): + case(36): return SimpleInterface36; - case (37): + case(37): return SimpleInterface37; - case (38): + case(38): return SimpleInterface38; - case (39): + case(39): return SimpleInterface39; - case (40): + case(40): return SimpleInterface40; - case (41): + case(41): return SimpleInterface41; - case (42): + case(42): return SimpleInterface42; - case (43): + case(43): return SimpleInterface43; - case (44): + case(44): return SimpleInterface44; - case (45): + case(45): return SimpleInterface45; - case (46): + case(46): return SimpleInterface46; - case (47): + case(47): return SimpleInterface47; - case (48): + case(48): return SimpleInterface48; - case (49): + case(49): return SimpleInterface49; - case (50): + case(50): return SimpleInterface50; - case (51): + case(51): return SimpleInterface51; - case (52): + case(52): return SimpleInterface52; - case (53): + case(53): return SimpleInterface53; - case (54): + case(54): return SimpleInterface54; - case (55): + case(55): return SimpleInterface55; - case (56): + case(56): return SimpleInterface56; - case (57): + case(57): return SimpleInterface57; - case (58): + case(58): return SimpleInterface58; - case (59): + case(59): return SimpleInterface59; - case (60): + case(60): return SimpleInterface60; - case (61): + case(61): return SimpleInterface61; - case (62): + case(62): return SimpleInterface62; - case (63): + case(63): return SimpleInterface63; - case (64): + case(64): return SimpleInterface64; - case (65): + case(65): return SimpleInterface65; - case (66): + case(66): return SimpleInterface66; - case (67): + case(67): return SimpleInterface67; - case (68): + case(68): return SimpleInterface68; - case (69): + case(69): return SimpleInterface69; - case (70): + case(70): return SimpleInterface70; - case (71): + case(71): return SimpleInterface71; - case (72): + case(72): return SimpleInterface72; - case (73): + case(73): return SimpleInterface73; - case (74): + case(74): return SimpleInterface74; - case (75): + case(75): return SimpleInterface75; - case (76): + case(76): return SimpleInterface76; - case (77): + case(77): return SimpleInterface77; - case (78): + case(78): return SimpleInterface78; - case (79): + case(79): return SimpleInterface79; - case (80): + case(80): return SimpleInterface80; - case (81): + case(81): return SimpleInterface81; - case (82): + case(82): return SimpleInterface82; - case (83): + case(83): return SimpleInterface83; - case (84): + case(84): return SimpleInterface84; - case (85): + case(85): return SimpleInterface85; - case (86): + case(86): return SimpleInterface86; - case (87): + case(87): return SimpleInterface87; - case (88): + case(88): return SimpleInterface88; - case (89): + case(89): return SimpleInterface89; - case (90): + case(90): return SimpleInterface90; - case (91): + case(91): return SimpleInterface91; - case (92): + case(92): return SimpleInterface92; - case (93): + case(93): return SimpleInterface93; - case (94): + case(94): return SimpleInterface94; - case (95): + case(95): return SimpleInterface95; - case (96): + case(96): return SimpleInterface96; - case (97): + case(97): return SimpleInterface97; - case (98): + case(98): return SimpleInterface98; - case (99): + case(99): return SimpleInterface99; - case (100): + case(100): return SimpleInterface100; - case (101): + case(101): return SimpleInterface101; - case (102): + case(102): return SimpleInterface102; - case (103): + case(103): return SimpleInterface103; - case (104): + case(104): return SimpleInterface104; - case (105): + case(105): return SimpleInterface105; - case (106): + case(106): return SimpleInterface106; - case (107): + case(107): return SimpleInterface107; - case (108): + case(108): return SimpleInterface108; - case (109): + case(109): return SimpleInterface109; - case (110): + case(110): return SimpleInterface110; - case (111): + case(111): return SimpleInterface111; - case (112): + case(112): return SimpleInterface112; - case (113): + case(113): return SimpleInterface113; - case (114): + case(114): return SimpleInterface114; - case (115): + case(115): return SimpleInterface115; - case (116): + case(116): return SimpleInterface116; - case (117): + case(117): return SimpleInterface117; - case (118): + case(118): return SimpleInterface118; - case (119): + case(119): return SimpleInterface119; - case (120): + case(120): return SimpleInterface120; - case (121): + case(121): return SimpleInterface121; - case (122): + case(122): return SimpleInterface122; - case (123): + case(123): return SimpleInterface123; - case (124): + case(124): return SimpleInterface124; - case (125): + case(125): return SimpleInterface125; - case (126): + case(126): return SimpleInterface126; - case (127): + case(127): return SimpleInterface127; - case (128): + case(128): return SimpleInterface128; - case (129): + case(129): return SimpleInterface129; - case (130): + case(130): return SimpleInterface130; - case (131): + case(131): return SimpleInterface131; - case (132): + case(132): return SimpleInterface132; - case (133): + case(133): return SimpleInterface133; - case (134): + case(134): return SimpleInterface134; - case (135): + case(135): return SimpleInterface135; - case (136): + case(136): return SimpleInterface136; - case (137): + case(137): return SimpleInterface137; - case (138): + case(138): return SimpleInterface138; - case (139): + case(139): return SimpleInterface139; - case (140): + case(140): return SimpleInterface140; - case (141): + case(141): return SimpleInterface141; - case (142): + case(142): return SimpleInterface142; - case (143): + case(143): return SimpleInterface143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, SimpleInterface value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - SimpleInterface0 = value; - break; - case (1): - SimpleInterface1 = value; - break; - case (2): - SimpleInterface2 = value; - break; - case (3): - SimpleInterface3 = value; - break; - case (4): - SimpleInterface4 = value; - break; - case (5): - SimpleInterface5 = value; - break; - case (6): - SimpleInterface6 = value; - break; - case (7): - SimpleInterface7 = value; - break; - case (8): - SimpleInterface8 = value; - break; - case (9): - SimpleInterface9 = value; - break; - case (10): - SimpleInterface10 = value; - break; - case (11): - SimpleInterface11 = value; - break; - case (12): - SimpleInterface12 = value; - break; - case (13): - SimpleInterface13 = value; - break; - case (14): - SimpleInterface14 = value; - break; - case (16): - SimpleInterface16 = value; - break; - case (17): - SimpleInterface17 = value; - break; - case (18): - SimpleInterface18 = value; - break; - case (19): - SimpleInterface19 = value; - break; - case (20): - SimpleInterface20 = value; - break; - case (21): - SimpleInterface21 = value; - break; - case (22): - SimpleInterface22 = value; - break; - case (23): - SimpleInterface23 = value; - break; - case (24): - SimpleInterface24 = value; - break; - case (26): - SimpleInterface26 = value; - break; - case (28): - SimpleInterface28 = value; - break; - case (29): - SimpleInterface29 = value; - break; - case (30): - SimpleInterface30 = value; - break; - case (31): - SimpleInterface31 = value; - break; - case (32): - SimpleInterface32 = value; - break; - case (33): - SimpleInterface33 = value; - break; - case (35): - SimpleInterface35 = value; - break; - case (36): - SimpleInterface36 = value; - break; - case (37): - SimpleInterface37 = value; - break; - case (38): - SimpleInterface38 = value; - break; - case (39): - SimpleInterface39 = value; - break; - case (40): - SimpleInterface40 = value; - break; - case (41): - SimpleInterface41 = value; - break; - case (42): - SimpleInterface42 = value; - break; - case (43): - SimpleInterface43 = value; - break; - case (44): - SimpleInterface44 = value; - break; - case (45): - SimpleInterface45 = value; - break; - case (46): - SimpleInterface46 = value; - break; - case (47): - SimpleInterface47 = value; - break; - case (48): - SimpleInterface48 = value; - break; - case (49): - SimpleInterface49 = value; - break; - case (50): - SimpleInterface50 = value; - break; - case (52): - SimpleInterface52 = value; - break; - case (53): - SimpleInterface53 = value; - break; - case (54): - SimpleInterface54 = value; - break; - case (55): - SimpleInterface55 = value; - break; - case (56): - SimpleInterface56 = value; - break; - case (57): - SimpleInterface57 = value; - break; - case (58): - SimpleInterface58 = value; - break; - case (59): - SimpleInterface59 = value; - break; - case (60): - SimpleInterface60 = value; - break; - case (62): - SimpleInterface62 = value; - break; - case (64): - SimpleInterface64 = value; - break; - case (65): - SimpleInterface65 = value; - break; - case (66): - SimpleInterface66 = value; - break; - case (67): - SimpleInterface67 = value; - break; - case (68): - SimpleInterface68 = value; - break; - case (69): - SimpleInterface69 = value; - break; - case (71): - SimpleInterface71 = value; - break; - case (72): - SimpleInterface72 = value; - break; - case (73): - SimpleInterface73 = value; - break; - case (74): - SimpleInterface74 = value; - break; - case (75): - SimpleInterface75 = value; - break; - case (76): - SimpleInterface76 = value; - break; - case (77): - SimpleInterface77 = value; - break; - case (78): - SimpleInterface78 = value; - break; - case (79): - SimpleInterface79 = value; - break; - case (80): - SimpleInterface80 = value; - break; - case (81): - SimpleInterface81 = value; - break; - case (82): - SimpleInterface82 = value; - break; - case (83): - SimpleInterface83 = value; - break; - case (84): - SimpleInterface84 = value; - break; - case (85): - SimpleInterface85 = value; - break; - case (86): - SimpleInterface86 = value; - break; - case (88): - SimpleInterface88 = value; - break; - case (89): - SimpleInterface89 = value; - break; - case (90): - SimpleInterface90 = value; - break; - case (91): - SimpleInterface91 = value; - break; - case (92): - SimpleInterface92 = value; - break; - case (93): - SimpleInterface93 = value; - break; - case (94): - SimpleInterface94 = value; - break; - case (95): - SimpleInterface95 = value; - break; - case (96): - SimpleInterface96 = value; - break; - case (98): - SimpleInterface98 = value; - break; - case (100): - SimpleInterface100 = value; - break; - case (101): - SimpleInterface101 = value; - break; - case (102): - SimpleInterface102 = value; - break; - case (103): - SimpleInterface103 = value; - break; - case (104): - SimpleInterface104 = value; - break; - case (105): - SimpleInterface105 = value; - break; - case (107): - SimpleInterface107 = value; - break; - case (108): - SimpleInterface108 = value; - break; - case (109): - SimpleInterface109 = value; - break; - case (110): - SimpleInterface110 = value; - break; - case (111): - SimpleInterface111 = value; - break; - case (112): - SimpleInterface112 = value; - break; - case (113): - SimpleInterface113 = value; - break; - case (114): - SimpleInterface114 = value; - break; - case (115): - SimpleInterface115 = value; - break; - case (116): - SimpleInterface116 = value; - break; - case (117): - SimpleInterface117 = value; - break; - case (118): - SimpleInterface118 = value; - break; - case (119): - SimpleInterface119 = value; - break; - case (120): - SimpleInterface120 = value; - break; - case (121): - SimpleInterface121 = value; - break; - case (122): - SimpleInterface122 = value; - break; - case (124): - SimpleInterface124 = value; - break; - case (125): - SimpleInterface125 = value; - break; - case (126): - SimpleInterface126 = value; - break; - case (127): - SimpleInterface127 = value; - break; - case (128): - SimpleInterface128 = value; - break; - case (129): - SimpleInterface129 = value; - break; - case (130): - SimpleInterface130 = value; - break; - case (131): - SimpleInterface131 = value; - break; - case (132): - SimpleInterface132 = value; - break; - case (134): - SimpleInterface134 = value; - break; - case (136): - SimpleInterface136 = value; - break; - case (137): - SimpleInterface137 = value; - break; - case (138): - SimpleInterface138 = value; - break; - case (139): - SimpleInterface139 = value; - break; - case (140): - SimpleInterface140 = value; - break; - case (141): - SimpleInterface141 = value; - break; - case (143): - SimpleInterface143 = value; - break; + public boolean set(int index,SimpleInterface value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + SimpleInterface0= value; + break; + case(1): + SimpleInterface1= value; + break; + case(2): + SimpleInterface2= value; + break; + case(3): + SimpleInterface3= value; + break; + case(4): + SimpleInterface4= value; + break; + case(5): + SimpleInterface5= value; + break; + case(6): + SimpleInterface6= value; + break; + case(7): + SimpleInterface7= value; + break; + case(8): + SimpleInterface8= value; + break; + case(9): + SimpleInterface9= value; + break; + case(10): + SimpleInterface10= value; + break; + case(11): + SimpleInterface11= value; + break; + case(12): + SimpleInterface12= value; + break; + case(13): + SimpleInterface13= value; + break; + case(14): + SimpleInterface14= value; + break; + case(16): + SimpleInterface16= value; + break; + case(17): + SimpleInterface17= value; + break; + case(18): + SimpleInterface18= value; + break; + case(19): + SimpleInterface19= value; + break; + case(20): + SimpleInterface20= value; + break; + case(21): + SimpleInterface21= value; + break; + case(22): + SimpleInterface22= value; + break; + case(23): + SimpleInterface23= value; + break; + case(24): + SimpleInterface24= value; + break; + case(26): + SimpleInterface26= value; + break; + case(28): + SimpleInterface28= value; + break; + case(29): + SimpleInterface29= value; + break; + case(30): + SimpleInterface30= value; + break; + case(31): + SimpleInterface31= value; + break; + case(32): + SimpleInterface32= value; + break; + case(33): + SimpleInterface33= value; + break; + case(35): + SimpleInterface35= value; + break; + case(36): + SimpleInterface36= value; + break; + case(37): + SimpleInterface37= value; + break; + case(38): + SimpleInterface38= value; + break; + case(39): + SimpleInterface39= value; + break; + case(40): + SimpleInterface40= value; + break; + case(41): + SimpleInterface41= value; + break; + case(42): + SimpleInterface42= value; + break; + case(43): + SimpleInterface43= value; + break; + case(44): + SimpleInterface44= value; + break; + case(45): + SimpleInterface45= value; + break; + case(46): + SimpleInterface46= value; + break; + case(47): + SimpleInterface47= value; + break; + case(48): + SimpleInterface48= value; + break; + case(49): + SimpleInterface49= value; + break; + case(50): + SimpleInterface50= value; + break; + case(52): + SimpleInterface52= value; + break; + case(53): + SimpleInterface53= value; + break; + case(54): + SimpleInterface54= value; + break; + case(55): + SimpleInterface55= value; + break; + case(56): + SimpleInterface56= value; + break; + case(57): + SimpleInterface57= value; + break; + case(58): + SimpleInterface58= value; + break; + case(59): + SimpleInterface59= value; + break; + case(60): + SimpleInterface60= value; + break; + case(62): + SimpleInterface62= value; + break; + case(64): + SimpleInterface64= value; + break; + case(65): + SimpleInterface65= value; + break; + case(66): + SimpleInterface66= value; + break; + case(67): + SimpleInterface67= value; + break; + case(68): + SimpleInterface68= value; + break; + case(69): + SimpleInterface69= value; + break; + case(71): + SimpleInterface71= value; + break; + case(72): + SimpleInterface72= value; + break; + case(73): + SimpleInterface73= value; + break; + case(74): + SimpleInterface74= value; + break; + case(75): + SimpleInterface75= value; + break; + case(76): + SimpleInterface76= value; + break; + case(77): + SimpleInterface77= value; + break; + case(78): + SimpleInterface78= value; + break; + case(79): + SimpleInterface79= value; + break; + case(80): + SimpleInterface80= value; + break; + case(81): + SimpleInterface81= value; + break; + case(82): + SimpleInterface82= value; + break; + case(83): + SimpleInterface83= value; + break; + case(84): + SimpleInterface84= value; + break; + case(85): + SimpleInterface85= value; + break; + case(86): + SimpleInterface86= value; + break; + case(88): + SimpleInterface88= value; + break; + case(89): + SimpleInterface89= value; + break; + case(90): + SimpleInterface90= value; + break; + case(91): + SimpleInterface91= value; + break; + case(92): + SimpleInterface92= value; + break; + case(93): + SimpleInterface93= value; + break; + case(94): + SimpleInterface94= value; + break; + case(95): + SimpleInterface95= value; + break; + case(96): + SimpleInterface96= value; + break; + case(98): + SimpleInterface98= value; + break; + case(100): + SimpleInterface100= value; + break; + case(101): + SimpleInterface101= value; + break; + case(102): + SimpleInterface102= value; + break; + case(103): + SimpleInterface103= value; + break; + case(104): + SimpleInterface104= value; + break; + case(105): + SimpleInterface105= value; + break; + case(107): + SimpleInterface107= value; + break; + case(108): + SimpleInterface108= value; + break; + case(109): + SimpleInterface109= value; + break; + case(110): + SimpleInterface110= value; + break; + case(111): + SimpleInterface111= value; + break; + case(112): + SimpleInterface112= value; + break; + case(113): + SimpleInterface113= value; + break; + case(114): + SimpleInterface114= value; + break; + case(115): + SimpleInterface115= value; + break; + case(116): + SimpleInterface116= value; + break; + case(117): + SimpleInterface117= value; + break; + case(118): + SimpleInterface118= value; + break; + case(119): + SimpleInterface119= value; + break; + case(120): + SimpleInterface120= value; + break; + case(121): + SimpleInterface121= value; + break; + case(122): + SimpleInterface122= value; + break; + case(124): + SimpleInterface124= value; + break; + case(125): + SimpleInterface125= value; + break; + case(126): + SimpleInterface126= value; + break; + case(127): + SimpleInterface127= value; + break; + case(128): + SimpleInterface128= value; + break; + case(129): + SimpleInterface129= value; + break; + case(130): + SimpleInterface130= value; + break; + case(131): + SimpleInterface131= value; + break; + case(132): + SimpleInterface132= value; + break; + case(134): + SimpleInterface134= value; + break; + case(136): + SimpleInterface136= value; + break; + case(137): + SimpleInterface137= value; + break; + case(138): + SimpleInterface138= value; + break; + case(139): + SimpleInterface139= value; + break; + case(140): + SimpleInterface140= value; + break; + case(141): + SimpleInterface141= value; + break; + case(143): + SimpleInterface143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfString.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfString.java index d6271988a..4b3be84af 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfString.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/FieldsOfString.java @@ -5,21 +5,21 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; -public class FieldsOfString { +public class FieldsOfString { public int identifier; private String String0; private String String1; @@ -48,14 +48,14 @@ public class FieldsOfString { private static transient String String24; private static final String String25 = new String("JDO TCK"); private static volatile String String26; - private final transient String String27 = new String("JDO TCK"); + private transient final String String27 = new String("JDO TCK"); private transient volatile String String28; private transient volatile String String29; private transient volatile String String30; private transient volatile String String31; private transient volatile String String32; private transient volatile String String33; - private static final transient String String34 = new String("JDO TCK"); + private static transient final String String34 = new String("JDO TCK"); private static transient volatile String String35; public String String36; public String String37; @@ -84,14 +84,14 @@ public class FieldsOfString { public static transient String String60; public static final String String61 = new String("JDO TCK"); public static volatile String String62; - public final transient String String63 = new String("JDO TCK"); + public transient final String String63 = new String("JDO TCK"); public transient volatile String String64; public transient volatile String String65; public transient volatile String String66; public transient volatile String String67; public transient volatile String String68; public transient volatile String String69; - public static final transient String String70 = new String("JDO TCK"); + public static transient final String String70 = new String("JDO TCK"); public static transient volatile String String71; protected String String72; protected String String73; @@ -120,14 +120,14 @@ public class FieldsOfString { protected static transient String String96; protected static final String String97 = new String("JDO TCK"); protected static volatile String String98; - protected final transient String String99 = new String("JDO TCK"); + protected transient final String String99 = new String("JDO TCK"); protected transient volatile String String100; protected transient volatile String String101; protected transient volatile String String102; protected transient volatile String String103; protected transient volatile String String104; protected transient volatile String String105; - protected static final transient String String106 = new String("JDO TCK"); + protected static transient final String String106 = new String("JDO TCK"); protected static transient volatile String String107; String String108; String String109; @@ -156,936 +156,935 @@ public class FieldsOfString { static transient String String132; static final String String133 = new String("JDO TCK"); static volatile String String134; - final transient String String135 = new String("JDO TCK"); + transient final String String135 = new String("JDO TCK"); transient volatile String String136; transient volatile String String137; transient volatile String String138; transient volatile String String139; transient volatile String String140; transient volatile String String141; - static final transient String String142 = new String("JDO TCK"); + static transient final String String142 = new String("JDO TCK"); static transient volatile String String143; - public static final boolean[] isPersistent = { - true, true, true, false, true, true, true, false, false, false, - false, true, true, true, false, false, true, true, true, false, - true, true, true, false, false, false, false, false, false, false, - true, true, true, false, false, false, true, true, true, false, - true, true, true, false, false, false, false, true, true, true, - false, false, true, true, true, false, true, true, true, false, - false, false, false, false, false, false, true, true, true, false, - false, false, true, true, true, false, true, true, true, false, - false, false, false, true, true, true, false, false, true, true, - true, false, true, true, true, false, false, false, false, false, - false, false, true, true, true, false, false, false, true, true, - true, false, true, true, true, false, false, false, false, true, - true, true, false, false, true, true, true, false, true, true, - true, false, false, false, false, false, false, false, true, true, - true, false, false, false - }; +public static final boolean [] isPersistent = { +true,true,true,false,true,true,true,false,false,false, +false,true,true,true,false,false,true,true,true,false, +true,true,true,false,false,false,false,false,false,false, +true,true,true,false,false,false,true,true,true,false, +true,true,true,false,false,false,false,true,true,true, +false,false,true,true,true,false,true,true,true,false, +false,false,false,false,false,false,true,true,true,false, +false,false,true,true,true,false,true,true,true,false, +false,false,false,true,true,true,false,false,true,true, +true,false,true,true,true,false,false,false,false,false, +false,false,true,true,true,false,false,false,true,true, +true,false,true,true,true,false,false,false,false,true, +true,true,false,false,true,true,true,false,true,true, +true,false,false,false,false,false,false,false,true,true, +true,false,false,false + }; - public static final boolean[] isStatic = { - false, false, false, false, false, false, false, false, true, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, false, false, - false, false, false, false, true, true, false, false, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - true, true, true, false, false, false, false, false, false, false, - true, true, false, false, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, true, true, true, false, - false, false, false, false, false, false, true, true, false, false, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, true, true, true, false, false, false, false, false, - false, false, true, true - }; +public static final boolean [] isStatic = { +false,false,false,false,false,false,false,false,true,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,true,true,true,false,false,false, +false,false,false,false,true,true,false,false,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +true,true,true,false,false,false,false,false,false,false, +true,true,false,false,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,true,true,true,false, +false,false,false,false,false,false,true,true,false,false, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,true,true,true,false,false,false,false,false, +false,false,true,true + }; - public static final boolean[] isFinal = { - false, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, true, false, false, false, false, - false, false, false, false, false, true, false, true, false, false, - false, false, false, false, true, false, false, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, true, false, false, false, false, false, false, false, false, - false, true, false, true, false, false, false, false, false, false, - true, false, false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, true, false, false, - false, false, false, false, false, false, false, true, false, true, - false, false, false, false, false, false, true, false, false, false, - false, false, false, false, false, false, false, false, false, false, - false, false, false, true, false, false, false, false, false, false, - false, false, false, true, false, true, false, false, false, false, - false, false, true, false - }; +public static final boolean [] isFinal = { +false,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,true,false,false,false,false, +false,false,false,false,false,true,false,true,false,false, +false,false,false,false,true,false,false,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,true,false,false,false,false,false,false,false,false, +false,true,false,true,false,false,false,false,false,false, +true,false,false,false,false,false,false,false,false,false, +false,false,false,false,false,false,false,true,false,false, +false,false,false,false,false,false,false,true,false,true, +false,false,false,false,false,false,true,false,false,false, +false,false,false,false,false,false,false,false,false,false, +false,false,false,true,false,false,false,false,false,false, +false,false,false,true,false,true,false,false,false,false, +false,false,true,false + }; - public static final String[] fieldSpecs = { - "private String String0", - "embedded= true private String String1", - "embedded= false private String String2", - "persistence-modifier= none private String String3", - "persistence-modifier= persistent private String String4", - "persistence-modifier= persistent embedded= true private String String5", - "persistence-modifier= persistent embedded= false private String String6", - "persistence-modifier= transactional private String String7", - "private static String String8", - "private transient String String9", - "persistence-modifier= none private transient String String10", - "persistence-modifier= persistent private transient String String11", - "persistence-modifier= persistent embedded= true private transient String String12", - "persistence-modifier= persistent embedded= false private transient String String13", - "persistence-modifier= transactional private transient String String14", - "private final String String15", - "private volatile String String16", - "embedded= true private volatile String String17", - "embedded= false private volatile String String18", - "persistence-modifier= none private volatile String String19", - "persistence-modifier= persistent private volatile String String20", - "persistence-modifier= persistent embedded= true private volatile String String21", - "persistence-modifier= persistent embedded= false private volatile String String22", - "persistence-modifier= transactional private volatile String String23", - "private static transient String String24", - "private static final String String25", - "private static volatile String String26", - "private transient final String String27", - "private transient volatile String String28", - "persistence-modifier= none private transient volatile String String29", - "persistence-modifier= persistent private transient volatile String String30", - "persistence-modifier= persistent embedded= true private transient volatile String String31", - "persistence-modifier= persistent embedded= false private transient volatile String String32", - "persistence-modifier= transactional private transient volatile String String33", - "private static transient final String String34", - "private static transient volatile String String35", - "public String String36", - "embedded= true public String String37", - "embedded= false public String String38", - "persistence-modifier= none public String String39", - "persistence-modifier= persistent public String String40", - "persistence-modifier= persistent embedded= true public String String41", - "persistence-modifier= persistent embedded= false public String String42", - "persistence-modifier= transactional public String String43", - "public static String String44", - "public transient String String45", - "persistence-modifier= none public transient String String46", - "persistence-modifier= persistent public transient String String47", - "persistence-modifier= persistent embedded= true public transient String String48", - "persistence-modifier= persistent embedded= false public transient String String49", - "persistence-modifier= transactional public transient String String50", - "public final String String51", - "public volatile String String52", - "embedded= true public volatile String String53", - "embedded= false public volatile String String54", - "persistence-modifier= none public volatile String String55", - "persistence-modifier= persistent public volatile String String56", - "persistence-modifier= persistent embedded= true public volatile String String57", - "persistence-modifier= persistent embedded= false public volatile String String58", - "persistence-modifier= transactional public volatile String String59", - "public static transient String String60", - "public static final String String61", - "public static volatile String String62", - "public transient final String String63", - "public transient volatile String String64", - "persistence-modifier= none public transient volatile String String65", - "persistence-modifier= persistent public transient volatile String String66", - "persistence-modifier= persistent embedded= true public transient volatile String String67", - "persistence-modifier= persistent embedded= false public transient volatile String String68", - "persistence-modifier= transactional public transient volatile String String69", - "public static transient final String String70", - "public static transient volatile String String71", - "protected String String72", - "embedded= true protected String String73", - "embedded= false protected String String74", - "persistence-modifier= none protected String String75", - "persistence-modifier= persistent protected String String76", - "persistence-modifier= persistent embedded= true protected String String77", - "persistence-modifier= persistent embedded= false protected String String78", - "persistence-modifier= transactional protected String String79", - "protected static String String80", - "protected transient String String81", - "persistence-modifier= none protected transient String String82", - "persistence-modifier= persistent protected transient String String83", - "persistence-modifier= persistent embedded= true protected transient String String84", - "persistence-modifier= persistent embedded= false protected transient String String85", - "persistence-modifier= transactional protected transient String String86", - "protected final String String87", - "protected volatile String String88", - "embedded= true protected volatile String String89", - "embedded= false protected volatile String String90", - "persistence-modifier= none protected volatile String String91", - "persistence-modifier= persistent protected volatile String String92", - "persistence-modifier= persistent embedded= true protected volatile String String93", - "persistence-modifier= persistent embedded= false protected volatile String String94", - "persistence-modifier= transactional protected volatile String String95", - "protected static transient String String96", - "protected static final String String97", - "protected static volatile String String98", - "protected transient final String String99", - "protected transient volatile String String100", - "persistence-modifier= none protected transient volatile String String101", - "persistence-modifier= persistent protected transient volatile String String102", - "persistence-modifier= persistent embedded= true protected transient volatile String String103", - "persistence-modifier= persistent embedded= false protected transient volatile String String104", - "persistence-modifier= transactional protected transient volatile String String105", - "protected static transient final String String106", - "protected static transient volatile String String107", - "String String108", - "embedded= true String String109", - "embedded= false String String110", - "persistence-modifier= none String String111", - "persistence-modifier= persistent String String112", - "persistence-modifier= persistent embedded= true String String113", - "persistence-modifier= persistent embedded= false String String114", - "persistence-modifier= transactional String String115", - "static String String116", - "transient String String117", - "persistence-modifier= none transient String String118", - "persistence-modifier= persistent transient String String119", - "persistence-modifier= persistent embedded= true transient String String120", - "persistence-modifier= persistent embedded= false transient String String121", - "persistence-modifier= transactional transient String String122", - "final String String123", - "volatile String String124", - "embedded= true volatile String String125", - "embedded= false volatile String String126", - "persistence-modifier= none volatile String String127", - "persistence-modifier= persistent volatile String String128", - "persistence-modifier= persistent embedded= true volatile String String129", - "persistence-modifier= persistent embedded= false volatile String String130", - "persistence-modifier= transactional volatile String String131", - "static transient String String132", - "static final String String133", - "static volatile String String134", - "transient final String String135", - "transient volatile String String136", - "persistence-modifier= none transient volatile String String137", - "persistence-modifier= persistent transient volatile String String138", - "persistence-modifier= persistent embedded= true transient volatile String String139", - "persistence-modifier= persistent embedded= false transient volatile String String140", - "persistence-modifier= transactional transient volatile String String141", - "static transient final String String142", - "static transient volatile String String143" + public static final String [] fieldSpecs = { + "private String String0", + "embedded= true private String String1", + "embedded= false private String String2", + "persistence-modifier= none private String String3", + "persistence-modifier= persistent private String String4", + "persistence-modifier= persistent embedded= true private String String5", + "persistence-modifier= persistent embedded= false private String String6", + "persistence-modifier= transactional private String String7", + "private static String String8", + "private transient String String9", + "persistence-modifier= none private transient String String10", + "persistence-modifier= persistent private transient String String11", + "persistence-modifier= persistent embedded= true private transient String String12", + "persistence-modifier= persistent embedded= false private transient String String13", + "persistence-modifier= transactional private transient String String14", + "private final String String15", + "private volatile String String16", + "embedded= true private volatile String String17", + "embedded= false private volatile String String18", + "persistence-modifier= none private volatile String String19", + "persistence-modifier= persistent private volatile String String20", + "persistence-modifier= persistent embedded= true private volatile String String21", + "persistence-modifier= persistent embedded= false private volatile String String22", + "persistence-modifier= transactional private volatile String String23", + "private static transient String String24", + "private static final String String25", + "private static volatile String String26", + "private transient final String String27", + "private transient volatile String String28", + "persistence-modifier= none private transient volatile String String29", + "persistence-modifier= persistent private transient volatile String String30", + "persistence-modifier= persistent embedded= true private transient volatile String String31", + "persistence-modifier= persistent embedded= false private transient volatile String String32", + "persistence-modifier= transactional private transient volatile String String33", + "private static transient final String String34", + "private static transient volatile String String35", + "public String String36", + "embedded= true public String String37", + "embedded= false public String String38", + "persistence-modifier= none public String String39", + "persistence-modifier= persistent public String String40", + "persistence-modifier= persistent embedded= true public String String41", + "persistence-modifier= persistent embedded= false public String String42", + "persistence-modifier= transactional public String String43", + "public static String String44", + "public transient String String45", + "persistence-modifier= none public transient String String46", + "persistence-modifier= persistent public transient String String47", + "persistence-modifier= persistent embedded= true public transient String String48", + "persistence-modifier= persistent embedded= false public transient String String49", + "persistence-modifier= transactional public transient String String50", + "public final String String51", + "public volatile String String52", + "embedded= true public volatile String String53", + "embedded= false public volatile String String54", + "persistence-modifier= none public volatile String String55", + "persistence-modifier= persistent public volatile String String56", + "persistence-modifier= persistent embedded= true public volatile String String57", + "persistence-modifier= persistent embedded= false public volatile String String58", + "persistence-modifier= transactional public volatile String String59", + "public static transient String String60", + "public static final String String61", + "public static volatile String String62", + "public transient final String String63", + "public transient volatile String String64", + "persistence-modifier= none public transient volatile String String65", + "persistence-modifier= persistent public transient volatile String String66", + "persistence-modifier= persistent embedded= true public transient volatile String String67", + "persistence-modifier= persistent embedded= false public transient volatile String String68", + "persistence-modifier= transactional public transient volatile String String69", + "public static transient final String String70", + "public static transient volatile String String71", + "protected String String72", + "embedded= true protected String String73", + "embedded= false protected String String74", + "persistence-modifier= none protected String String75", + "persistence-modifier= persistent protected String String76", + "persistence-modifier= persistent embedded= true protected String String77", + "persistence-modifier= persistent embedded= false protected String String78", + "persistence-modifier= transactional protected String String79", + "protected static String String80", + "protected transient String String81", + "persistence-modifier= none protected transient String String82", + "persistence-modifier= persistent protected transient String String83", + "persistence-modifier= persistent embedded= true protected transient String String84", + "persistence-modifier= persistent embedded= false protected transient String String85", + "persistence-modifier= transactional protected transient String String86", + "protected final String String87", + "protected volatile String String88", + "embedded= true protected volatile String String89", + "embedded= false protected volatile String String90", + "persistence-modifier= none protected volatile String String91", + "persistence-modifier= persistent protected volatile String String92", + "persistence-modifier= persistent embedded= true protected volatile String String93", + "persistence-modifier= persistent embedded= false protected volatile String String94", + "persistence-modifier= transactional protected volatile String String95", + "protected static transient String String96", + "protected static final String String97", + "protected static volatile String String98", + "protected transient final String String99", + "protected transient volatile String String100", + "persistence-modifier= none protected transient volatile String String101", + "persistence-modifier= persistent protected transient volatile String String102", + "persistence-modifier= persistent embedded= true protected transient volatile String String103", + "persistence-modifier= persistent embedded= false protected transient volatile String String104", + "persistence-modifier= transactional protected transient volatile String String105", + "protected static transient final String String106", + "protected static transient volatile String String107", + "String String108", + "embedded= true String String109", + "embedded= false String String110", + "persistence-modifier= none String String111", + "persistence-modifier= persistent String String112", + "persistence-modifier= persistent embedded= true String String113", + "persistence-modifier= persistent embedded= false String String114", + "persistence-modifier= transactional String String115", + "static String String116", + "transient String String117", + "persistence-modifier= none transient String String118", + "persistence-modifier= persistent transient String String119", + "persistence-modifier= persistent embedded= true transient String String120", + "persistence-modifier= persistent embedded= false transient String String121", + "persistence-modifier= transactional transient String String122", + "final String String123", + "volatile String String124", + "embedded= true volatile String String125", + "embedded= false volatile String String126", + "persistence-modifier= none volatile String String127", + "persistence-modifier= persistent volatile String String128", + "persistence-modifier= persistent embedded= true volatile String String129", + "persistence-modifier= persistent embedded= false volatile String String130", + "persistence-modifier= transactional volatile String String131", + "static transient String String132", + "static final String String133", + "static volatile String String134", + "transient final String String135", + "transient volatile String String136", + "persistence-modifier= none transient volatile String String137", + "persistence-modifier= persistent transient volatile String String138", + "persistence-modifier= persistent embedded= true transient volatile String String139", + "persistence-modifier= persistent embedded= false transient volatile String String140", + "persistence-modifier= transactional transient volatile String String141", + "static transient final String String142", + "static transient volatile String String143" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public String get(int index) { - switch (index) { - case (0): + public String get(int index) + { + switch (index) + { + case(0): return String0; - case (1): + case(1): return String1; - case (2): + case(2): return String2; - case (3): + case(3): return String3; - case (4): + case(4): return String4; - case (5): + case(5): return String5; - case (6): + case(6): return String6; - case (7): + case(7): return String7; - case (8): + case(8): return String8; - case (9): + case(9): return String9; - case (10): + case(10): return String10; - case (11): + case(11): return String11; - case (12): + case(12): return String12; - case (13): + case(13): return String13; - case (14): + case(14): return String14; - case (15): + case(15): return String15; - case (16): + case(16): return String16; - case (17): + case(17): return String17; - case (18): + case(18): return String18; - case (19): + case(19): return String19; - case (20): + case(20): return String20; - case (21): + case(21): return String21; - case (22): + case(22): return String22; - case (23): + case(23): return String23; - case (24): + case(24): return String24; - case (25): + case(25): return String25; - case (26): + case(26): return String26; - case (27): + case(27): return String27; - case (28): + case(28): return String28; - case (29): + case(29): return String29; - case (30): + case(30): return String30; - case (31): + case(31): return String31; - case (32): + case(32): return String32; - case (33): + case(33): return String33; - case (34): + case(34): return String34; - case (35): + case(35): return String35; - case (36): + case(36): return String36; - case (37): + case(37): return String37; - case (38): + case(38): return String38; - case (39): + case(39): return String39; - case (40): + case(40): return String40; - case (41): + case(41): return String41; - case (42): + case(42): return String42; - case (43): + case(43): return String43; - case (44): + case(44): return String44; - case (45): + case(45): return String45; - case (46): + case(46): return String46; - case (47): + case(47): return String47; - case (48): + case(48): return String48; - case (49): + case(49): return String49; - case (50): + case(50): return String50; - case (51): + case(51): return String51; - case (52): + case(52): return String52; - case (53): + case(53): return String53; - case (54): + case(54): return String54; - case (55): + case(55): return String55; - case (56): + case(56): return String56; - case (57): + case(57): return String57; - case (58): + case(58): return String58; - case (59): + case(59): return String59; - case (60): + case(60): return String60; - case (61): + case(61): return String61; - case (62): + case(62): return String62; - case (63): + case(63): return String63; - case (64): + case(64): return String64; - case (65): + case(65): return String65; - case (66): + case(66): return String66; - case (67): + case(67): return String67; - case (68): + case(68): return String68; - case (69): + case(69): return String69; - case (70): + case(70): return String70; - case (71): + case(71): return String71; - case (72): + case(72): return String72; - case (73): + case(73): return String73; - case (74): + case(74): return String74; - case (75): + case(75): return String75; - case (76): + case(76): return String76; - case (77): + case(77): return String77; - case (78): + case(78): return String78; - case (79): + case(79): return String79; - case (80): + case(80): return String80; - case (81): + case(81): return String81; - case (82): + case(82): return String82; - case (83): + case(83): return String83; - case (84): + case(84): return String84; - case (85): + case(85): return String85; - case (86): + case(86): return String86; - case (87): + case(87): return String87; - case (88): + case(88): return String88; - case (89): + case(89): return String89; - case (90): + case(90): return String90; - case (91): + case(91): return String91; - case (92): + case(92): return String92; - case (93): + case(93): return String93; - case (94): + case(94): return String94; - case (95): + case(95): return String95; - case (96): + case(96): return String96; - case (97): + case(97): return String97; - case (98): + case(98): return String98; - case (99): + case(99): return String99; - case (100): + case(100): return String100; - case (101): + case(101): return String101; - case (102): + case(102): return String102; - case (103): + case(103): return String103; - case (104): + case(104): return String104; - case (105): + case(105): return String105; - case (106): + case(106): return String106; - case (107): + case(107): return String107; - case (108): + case(108): return String108; - case (109): + case(109): return String109; - case (110): + case(110): return String110; - case (111): + case(111): return String111; - case (112): + case(112): return String112; - case (113): + case(113): return String113; - case (114): + case(114): return String114; - case (115): + case(115): return String115; - case (116): + case(116): return String116; - case (117): + case(117): return String117; - case (118): + case(118): return String118; - case (119): + case(119): return String119; - case (120): + case(120): return String120; - case (121): + case(121): return String121; - case (122): + case(122): return String122; - case (123): + case(123): return String123; - case (124): + case(124): return String124; - case (125): + case(125): return String125; - case (126): + case(126): return String126; - case (127): + case(127): return String127; - case (128): + case(128): return String128; - case (129): + case(129): return String129; - case (130): + case(130): return String130; - case (131): + case(131): return String131; - case (132): + case(132): return String132; - case (133): + case(133): return String133; - case (134): + case(134): return String134; - case (135): + case(135): return String135; - case (136): + case(136): return String136; - case (137): + case(137): return String137; - case (138): + case(138): return String138; - case (139): + case(139): return String139; - case (140): + case(140): return String140; - case (141): + case(141): return String141; - case (142): + case(142): return String142; - case (143): + case(143): return String143; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, String value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - String0 = value; - break; - case (1): - String1 = value; - break; - case (2): - String2 = value; - break; - case (3): - String3 = value; - break; - case (4): - String4 = value; - break; - case (5): - String5 = value; - break; - case (6): - String6 = value; - break; - case (7): - String7 = value; - break; - case (8): - String8 = value; - break; - case (9): - String9 = value; - break; - case (10): - String10 = value; - break; - case (11): - String11 = value; - break; - case (12): - String12 = value; - break; - case (13): - String13 = value; - break; - case (14): - String14 = value; - break; - case (16): - String16 = value; - break; - case (17): - String17 = value; - break; - case (18): - String18 = value; - break; - case (19): - String19 = value; - break; - case (20): - String20 = value; - break; - case (21): - String21 = value; - break; - case (22): - String22 = value; - break; - case (23): - String23 = value; - break; - case (24): - String24 = value; - break; - case (26): - String26 = value; - break; - case (28): - String28 = value; - break; - case (29): - String29 = value; - break; - case (30): - String30 = value; - break; - case (31): - String31 = value; - break; - case (32): - String32 = value; - break; - case (33): - String33 = value; - break; - case (35): - String35 = value; - break; - case (36): - String36 = value; - break; - case (37): - String37 = value; - break; - case (38): - String38 = value; - break; - case (39): - String39 = value; - break; - case (40): - String40 = value; - break; - case (41): - String41 = value; - break; - case (42): - String42 = value; - break; - case (43): - String43 = value; - break; - case (44): - String44 = value; - break; - case (45): - String45 = value; - break; - case (46): - String46 = value; - break; - case (47): - String47 = value; - break; - case (48): - String48 = value; - break; - case (49): - String49 = value; - break; - case (50): - String50 = value; - break; - case (52): - String52 = value; - break; - case (53): - String53 = value; - break; - case (54): - String54 = value; - break; - case (55): - String55 = value; - break; - case (56): - String56 = value; - break; - case (57): - String57 = value; - break; - case (58): - String58 = value; - break; - case (59): - String59 = value; - break; - case (60): - String60 = value; - break; - case (62): - String62 = value; - break; - case (64): - String64 = value; - break; - case (65): - String65 = value; - break; - case (66): - String66 = value; - break; - case (67): - String67 = value; - break; - case (68): - String68 = value; - break; - case (69): - String69 = value; - break; - case (71): - String71 = value; - break; - case (72): - String72 = value; - break; - case (73): - String73 = value; - break; - case (74): - String74 = value; - break; - case (75): - String75 = value; - break; - case (76): - String76 = value; - break; - case (77): - String77 = value; - break; - case (78): - String78 = value; - break; - case (79): - String79 = value; - break; - case (80): - String80 = value; - break; - case (81): - String81 = value; - break; - case (82): - String82 = value; - break; - case (83): - String83 = value; - break; - case (84): - String84 = value; - break; - case (85): - String85 = value; - break; - case (86): - String86 = value; - break; - case (88): - String88 = value; - break; - case (89): - String89 = value; - break; - case (90): - String90 = value; - break; - case (91): - String91 = value; - break; - case (92): - String92 = value; - break; - case (93): - String93 = value; - break; - case (94): - String94 = value; - break; - case (95): - String95 = value; - break; - case (96): - String96 = value; - break; - case (98): - String98 = value; - break; - case (100): - String100 = value; - break; - case (101): - String101 = value; - break; - case (102): - String102 = value; - break; - case (103): - String103 = value; - break; - case (104): - String104 = value; - break; - case (105): - String105 = value; - break; - case (107): - String107 = value; - break; - case (108): - String108 = value; - break; - case (109): - String109 = value; - break; - case (110): - String110 = value; - break; - case (111): - String111 = value; - break; - case (112): - String112 = value; - break; - case (113): - String113 = value; - break; - case (114): - String114 = value; - break; - case (115): - String115 = value; - break; - case (116): - String116 = value; - break; - case (117): - String117 = value; - break; - case (118): - String118 = value; - break; - case (119): - String119 = value; - break; - case (120): - String120 = value; - break; - case (121): - String121 = value; - break; - case (122): - String122 = value; - break; - case (124): - String124 = value; - break; - case (125): - String125 = value; - break; - case (126): - String126 = value; - break; - case (127): - String127 = value; - break; - case (128): - String128 = value; - break; - case (129): - String129 = value; - break; - case (130): - String130 = value; - break; - case (131): - String131 = value; - break; - case (132): - String132 = value; - break; - case (134): - String134 = value; - break; - case (136): - String136 = value; - break; - case (137): - String137 = value; - break; - case (138): - String138 = value; - break; - case (139): - String139 = value; - break; - case (140): - String140 = value; - break; - case (141): - String141 = value; - break; - case (143): - String143 = value; - break; + public boolean set(int index,String value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + String0= value; + break; + case(1): + String1= value; + break; + case(2): + String2= value; + break; + case(3): + String3= value; + break; + case(4): + String4= value; + break; + case(5): + String5= value; + break; + case(6): + String6= value; + break; + case(7): + String7= value; + break; + case(8): + String8= value; + break; + case(9): + String9= value; + break; + case(10): + String10= value; + break; + case(11): + String11= value; + break; + case(12): + String12= value; + break; + case(13): + String13= value; + break; + case(14): + String14= value; + break; + case(16): + String16= value; + break; + case(17): + String17= value; + break; + case(18): + String18= value; + break; + case(19): + String19= value; + break; + case(20): + String20= value; + break; + case(21): + String21= value; + break; + case(22): + String22= value; + break; + case(23): + String23= value; + break; + case(24): + String24= value; + break; + case(26): + String26= value; + break; + case(28): + String28= value; + break; + case(29): + String29= value; + break; + case(30): + String30= value; + break; + case(31): + String31= value; + break; + case(32): + String32= value; + break; + case(33): + String33= value; + break; + case(35): + String35= value; + break; + case(36): + String36= value; + break; + case(37): + String37= value; + break; + case(38): + String38= value; + break; + case(39): + String39= value; + break; + case(40): + String40= value; + break; + case(41): + String41= value; + break; + case(42): + String42= value; + break; + case(43): + String43= value; + break; + case(44): + String44= value; + break; + case(45): + String45= value; + break; + case(46): + String46= value; + break; + case(47): + String47= value; + break; + case(48): + String48= value; + break; + case(49): + String49= value; + break; + case(50): + String50= value; + break; + case(52): + String52= value; + break; + case(53): + String53= value; + break; + case(54): + String54= value; + break; + case(55): + String55= value; + break; + case(56): + String56= value; + break; + case(57): + String57= value; + break; + case(58): + String58= value; + break; + case(59): + String59= value; + break; + case(60): + String60= value; + break; + case(62): + String62= value; + break; + case(64): + String64= value; + break; + case(65): + String65= value; + break; + case(66): + String66= value; + break; + case(67): + String67= value; + break; + case(68): + String68= value; + break; + case(69): + String69= value; + break; + case(71): + String71= value; + break; + case(72): + String72= value; + break; + case(73): + String73= value; + break; + case(74): + String74= value; + break; + case(75): + String75= value; + break; + case(76): + String76= value; + break; + case(77): + String77= value; + break; + case(78): + String78= value; + break; + case(79): + String79= value; + break; + case(80): + String80= value; + break; + case(81): + String81= value; + break; + case(82): + String82= value; + break; + case(83): + String83= value; + break; + case(84): + String84= value; + break; + case(85): + String85= value; + break; + case(86): + String86= value; + break; + case(88): + String88= value; + break; + case(89): + String89= value; + break; + case(90): + String90= value; + break; + case(91): + String91= value; + break; + case(92): + String92= value; + break; + case(93): + String93= value; + break; + case(94): + String94= value; + break; + case(95): + String95= value; + break; + case(96): + String96= value; + break; + case(98): + String98= value; + break; + case(100): + String100= value; + break; + case(101): + String101= value; + break; + case(102): + String102= value; + break; + case(103): + String103= value; + break; + case(104): + String104= value; + break; + case(105): + String105= value; + break; + case(107): + String107= value; + break; + case(108): + String108= value; + break; + case(109): + String109= value; + break; + case(110): + String110= value; + break; + case(111): + String111= value; + break; + case(112): + String112= value; + break; + case(113): + String113= value; + break; + case(114): + String114= value; + break; + case(115): + String115= value; + break; + case(116): + String116= value; + break; + case(117): + String117= value; + break; + case(118): + String118= value; + break; + case(119): + String119= value; + break; + case(120): + String120= value; + break; + case(121): + String121= value; + break; + case(122): + String122= value; + break; + case(124): + String124= value; + break; + case(125): + String125= value; + break; + case(126): + String126= value; + break; + case(127): + String127= value; + break; + case(128): + String128= value; + break; + case(129): + String129= value; + break; + case(130): + String130= value; + break; + case(131): + String131= value; + break; + case(132): + String132= value; + break; + case(134): + String134= value; + break; + case(136): + String136= value; + break; + case(137): + String137= value; + break; + case(138): + String138= value; + break; + case(139): + String139= value; + break; + case(140): + String140= value; + break; + case(141): + String141= value; + break; + case(143): + String143= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/HashMapStringKeyCollections.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/HashMapStringKeyCollections.java index 5ab7570b5..dee0322b5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/HashMapStringKeyCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/HashMapStringKeyCollections.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -20,7 +20,7 @@ import java.io.Serializable; import java.util.HashMap; -public class HashMapStringKeyCollections { +public class HashMapStringKeyCollections { public int identifier; public HashMap HashMapOfString_Object0; public HashMap HashMapOfString_Object1; @@ -121,644 +121,643 @@ public class HashMapStringKeyCollections { public HashMap HashMapOfString_Short123; public HashMap HashMapOfString_Short125; - public static final String[] fieldSpecs = { - "public HashMap HashMapOfString_Object0", - "embedded-value=true public HashMap HashMapOfString_Object1", - "embedded-value=false public HashMap HashMapOfString_Object2", - "public HashMap HashMapOfString_SimpleClass3", - "embedded-value=true public HashMap HashMapOfString_SimpleClass4", - "embedded-value=false public HashMap HashMapOfString_SimpleClass5", - "public HashMap HashMapOfString_SimpleInterface6", - "embedded-value=true public HashMap HashMapOfString_SimpleInterface7", - "embedded-value=false public HashMap HashMapOfString_SimpleInterface8", - "public HashMap HashMapOfString_String9", - "embedded-value=true public HashMap HashMapOfString_String10", - "embedded-value=false public HashMap HashMapOfString_String11", - "public HashMap HashMapOfString_Date12", - "embedded-value=true public HashMap HashMapOfString_Date13", - "embedded-value=false public HashMap HashMapOfString_Date14", - "public HashMap HashMapOfString_Locale15", - "embedded-value=true public HashMap HashMapOfString_Locale16", - "embedded-value=false public HashMap HashMapOfString_Locale17", - "public HashMap HashMapOfString_BigDecimal18", - "embedded-value=true public HashMap HashMapOfString_BigDecimal19", - "embedded-value=false public HashMap HashMapOfString_BigDecimal20", - "public HashMap HashMapOfString_BigInteger21", - "embedded-value=true public HashMap HashMapOfString_BigInteger22", - "embedded-value=false public HashMap HashMapOfString_BigInteger23", - "public HashMap HashMapOfString_Byte24", - "embedded-value=true public HashMap HashMapOfString_Byte25", - "embedded-value=false public HashMap HashMapOfString_Byte26", - "public HashMap HashMapOfString_Double27", - "embedded-value=true public HashMap HashMapOfString_Double28", - "embedded-value=false public HashMap HashMapOfString_Double29", - "public HashMap HashMapOfString_Float30", - "embedded-value=true public HashMap HashMapOfString_Float31", - "embedded-value=false public HashMap HashMapOfString_Float32", - "public HashMap HashMapOfString_Integer33", - "embedded-value=true public HashMap HashMapOfString_Integer34", - "embedded-value=false public HashMap HashMapOfString_Integer35", - "public HashMap HashMapOfString_Long36", - "embedded-value=true public HashMap HashMapOfString_Long37", - "embedded-value=false public HashMap HashMapOfString_Long38", - "public HashMap HashMapOfString_Short39", - "embedded-value=true public HashMap HashMapOfString_Short40", - "embedded-value=false public HashMap HashMapOfString_Short41", - "embedded-key=true public HashMap HashMapOfString_Object42", - "embedded-key=true embedded-value=true public HashMap HashMapOfString_Object43", - "embedded-key=true public HashMap HashMapOfString_SimpleClass45", - "embedded-key=true embedded-value=true public HashMap HashMapOfString_SimpleClass46", - "embedded-key=true public HashMap HashMapOfString_SimpleInterface48", - "embedded-key=true embedded-value=true public HashMap HashMapOfString_SimpleInterface49", - "embedded-key=true public HashMap HashMapOfString_String51", - "embedded-key=true embedded-value=true public HashMap HashMapOfString_String52", - "embedded-key=true public HashMap HashMapOfString_Date54", - "embedded-key=true embedded-value=true public HashMap HashMapOfString_Date55", - "embedded-key=true public HashMap HashMapOfString_Locale57", - "embedded-key=true embedded-value=true public HashMap HashMapOfString_Locale58", - "embedded-key=true public HashMap HashMapOfString_BigDecimal60", - "embedded-key=true embedded-value=true public HashMap HashMapOfString_BigDecimal61", - "embedded-key=true public HashMap HashMapOfString_BigInteger63", - "embedded-key=true embedded-value=true public HashMap HashMapOfString_BigInteger64", - "embedded-key=true public HashMap HashMapOfString_Byte66", - "embedded-key=true embedded-value=true public HashMap HashMapOfString_Byte67", - "embedded-key=true public HashMap HashMapOfString_Double69", - "embedded-key=true embedded-value=true public HashMap HashMapOfString_Double70", - "embedded-key=true public HashMap HashMapOfString_Float72", - "embedded-key=true embedded-value=true public HashMap HashMapOfString_Float73", - "embedded-key=true public HashMap HashMapOfString_Integer75", - "embedded-key=true embedded-value=true public HashMap HashMapOfString_Integer76", - "embedded-key=true public HashMap HashMapOfString_Long78", - "embedded-key=true embedded-value=true public HashMap HashMapOfString_Long79", - "embedded-key=true public HashMap HashMapOfString_Short81", - "embedded-key=true embedded-value=true public HashMap HashMapOfString_Short82", - "embedded-key=false public HashMap HashMapOfString_Object84", - "embedded-key=false embedded-value=false public HashMap HashMapOfString_Object86", - "embedded-key=false public HashMap HashMapOfString_SimpleClass87", - "embedded-key=false embedded-value=false public HashMap HashMapOfString_SimpleClass89", - "embedded-key=false public HashMap HashMapOfString_SimpleInterface90", - "embedded-key=false embedded-value=false public HashMap HashMapOfString_SimpleInterface92", - "embedded-key=false public HashMap HashMapOfString_String93", - "embedded-key=false embedded-value=false public HashMap HashMapOfString_String95", - "embedded-key=false public HashMap HashMapOfString_Date96", - "embedded-key=false embedded-value=false public HashMap HashMapOfString_Date98", - "embedded-key=false public HashMap HashMapOfString_Locale99", - "embedded-key=false embedded-value=false public HashMap HashMapOfString_Locale101", - "embedded-key=false public HashMap HashMapOfString_BigDecimal102", - "embedded-key=false embedded-value=false public HashMap HashMapOfString_BigDecimal104", - "embedded-key=false public HashMap HashMapOfString_BigInteger105", - "embedded-key=false embedded-value=false public HashMap HashMapOfString_BigInteger107", - "embedded-key=false public HashMap HashMapOfString_Byte108", - "embedded-key=false embedded-value=false public HashMap HashMapOfString_Byte110", - "embedded-key=false public HashMap HashMapOfString_Double111", - "embedded-key=false embedded-value=false public HashMap HashMapOfString_Double113", - "embedded-key=false public HashMap HashMapOfString_Float114", - "embedded-key=false embedded-value=false public HashMap HashMapOfString_Float116", - "embedded-key=false public HashMap HashMapOfString_Integer117", - "embedded-key=false embedded-value=false public HashMap HashMapOfString_Integer119", - "embedded-key=false public HashMap HashMapOfString_Long120", - "embedded-key=false embedded-value=false public HashMap HashMapOfString_Long122", - "embedded-key=false public HashMap HashMapOfString_Short123", - "embedded-key=false embedded-value=false public HashMap HashMapOfString_Short125" + public static final String [] fieldSpecs = { + "public HashMap HashMapOfString_Object0", + "embedded-value=true public HashMap HashMapOfString_Object1", + "embedded-value=false public HashMap HashMapOfString_Object2", + "public HashMap HashMapOfString_SimpleClass3", + "embedded-value=true public HashMap HashMapOfString_SimpleClass4", + "embedded-value=false public HashMap HashMapOfString_SimpleClass5", + "public HashMap HashMapOfString_SimpleInterface6", + "embedded-value=true public HashMap HashMapOfString_SimpleInterface7", + "embedded-value=false public HashMap HashMapOfString_SimpleInterface8", + "public HashMap HashMapOfString_String9", + "embedded-value=true public HashMap HashMapOfString_String10", + "embedded-value=false public HashMap HashMapOfString_String11", + "public HashMap HashMapOfString_Date12", + "embedded-value=true public HashMap HashMapOfString_Date13", + "embedded-value=false public HashMap HashMapOfString_Date14", + "public HashMap HashMapOfString_Locale15", + "embedded-value=true public HashMap HashMapOfString_Locale16", + "embedded-value=false public HashMap HashMapOfString_Locale17", + "public HashMap HashMapOfString_BigDecimal18", + "embedded-value=true public HashMap HashMapOfString_BigDecimal19", + "embedded-value=false public HashMap HashMapOfString_BigDecimal20", + "public HashMap HashMapOfString_BigInteger21", + "embedded-value=true public HashMap HashMapOfString_BigInteger22", + "embedded-value=false public HashMap HashMapOfString_BigInteger23", + "public HashMap HashMapOfString_Byte24", + "embedded-value=true public HashMap HashMapOfString_Byte25", + "embedded-value=false public HashMap HashMapOfString_Byte26", + "public HashMap HashMapOfString_Double27", + "embedded-value=true public HashMap HashMapOfString_Double28", + "embedded-value=false public HashMap HashMapOfString_Double29", + "public HashMap HashMapOfString_Float30", + "embedded-value=true public HashMap HashMapOfString_Float31", + "embedded-value=false public HashMap HashMapOfString_Float32", + "public HashMap HashMapOfString_Integer33", + "embedded-value=true public HashMap HashMapOfString_Integer34", + "embedded-value=false public HashMap HashMapOfString_Integer35", + "public HashMap HashMapOfString_Long36", + "embedded-value=true public HashMap HashMapOfString_Long37", + "embedded-value=false public HashMap HashMapOfString_Long38", + "public HashMap HashMapOfString_Short39", + "embedded-value=true public HashMap HashMapOfString_Short40", + "embedded-value=false public HashMap HashMapOfString_Short41", + "embedded-key=true public HashMap HashMapOfString_Object42", + "embedded-key=true embedded-value=true public HashMap HashMapOfString_Object43", + "embedded-key=true public HashMap HashMapOfString_SimpleClass45", + "embedded-key=true embedded-value=true public HashMap HashMapOfString_SimpleClass46", + "embedded-key=true public HashMap HashMapOfString_SimpleInterface48", + "embedded-key=true embedded-value=true public HashMap HashMapOfString_SimpleInterface49", + "embedded-key=true public HashMap HashMapOfString_String51", + "embedded-key=true embedded-value=true public HashMap HashMapOfString_String52", + "embedded-key=true public HashMap HashMapOfString_Date54", + "embedded-key=true embedded-value=true public HashMap HashMapOfString_Date55", + "embedded-key=true public HashMap HashMapOfString_Locale57", + "embedded-key=true embedded-value=true public HashMap HashMapOfString_Locale58", + "embedded-key=true public HashMap HashMapOfString_BigDecimal60", + "embedded-key=true embedded-value=true public HashMap HashMapOfString_BigDecimal61", + "embedded-key=true public HashMap HashMapOfString_BigInteger63", + "embedded-key=true embedded-value=true public HashMap HashMapOfString_BigInteger64", + "embedded-key=true public HashMap HashMapOfString_Byte66", + "embedded-key=true embedded-value=true public HashMap HashMapOfString_Byte67", + "embedded-key=true public HashMap HashMapOfString_Double69", + "embedded-key=true embedded-value=true public HashMap HashMapOfString_Double70", + "embedded-key=true public HashMap HashMapOfString_Float72", + "embedded-key=true embedded-value=true public HashMap HashMapOfString_Float73", + "embedded-key=true public HashMap HashMapOfString_Integer75", + "embedded-key=true embedded-value=true public HashMap HashMapOfString_Integer76", + "embedded-key=true public HashMap HashMapOfString_Long78", + "embedded-key=true embedded-value=true public HashMap HashMapOfString_Long79", + "embedded-key=true public HashMap HashMapOfString_Short81", + "embedded-key=true embedded-value=true public HashMap HashMapOfString_Short82", + "embedded-key=false public HashMap HashMapOfString_Object84", + "embedded-key=false embedded-value=false public HashMap HashMapOfString_Object86", + "embedded-key=false public HashMap HashMapOfString_SimpleClass87", + "embedded-key=false embedded-value=false public HashMap HashMapOfString_SimpleClass89", + "embedded-key=false public HashMap HashMapOfString_SimpleInterface90", + "embedded-key=false embedded-value=false public HashMap HashMapOfString_SimpleInterface92", + "embedded-key=false public HashMap HashMapOfString_String93", + "embedded-key=false embedded-value=false public HashMap HashMapOfString_String95", + "embedded-key=false public HashMap HashMapOfString_Date96", + "embedded-key=false embedded-value=false public HashMap HashMapOfString_Date98", + "embedded-key=false public HashMap HashMapOfString_Locale99", + "embedded-key=false embedded-value=false public HashMap HashMapOfString_Locale101", + "embedded-key=false public HashMap HashMapOfString_BigDecimal102", + "embedded-key=false embedded-value=false public HashMap HashMapOfString_BigDecimal104", + "embedded-key=false public HashMap HashMapOfString_BigInteger105", + "embedded-key=false embedded-value=false public HashMap HashMapOfString_BigInteger107", + "embedded-key=false public HashMap HashMapOfString_Byte108", + "embedded-key=false embedded-value=false public HashMap HashMapOfString_Byte110", + "embedded-key=false public HashMap HashMapOfString_Double111", + "embedded-key=false embedded-value=false public HashMap HashMapOfString_Double113", + "embedded-key=false public HashMap HashMapOfString_Float114", + "embedded-key=false embedded-value=false public HashMap HashMapOfString_Float116", + "embedded-key=false public HashMap HashMapOfString_Integer117", + "embedded-key=false embedded-value=false public HashMap HashMapOfString_Integer119", + "embedded-key=false public HashMap HashMapOfString_Long120", + "embedded-key=false embedded-value=false public HashMap HashMapOfString_Long122", + "embedded-key=false public HashMap HashMapOfString_Short123", + "embedded-key=false embedded-value=false public HashMap HashMapOfString_Short125" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public HashMap get(int index) { - switch (index) { - case (0): + public HashMap get(int index) + { + switch (index) + { + case(0): return HashMapOfString_Object0; - case (1): + case(1): return HashMapOfString_Object1; - case (2): + case(2): return HashMapOfString_Object2; - case (3): + case(3): return HashMapOfString_SimpleClass3; - case (4): + case(4): return HashMapOfString_SimpleClass4; - case (5): + case(5): return HashMapOfString_SimpleClass5; - case (6): + case(6): return HashMapOfString_SimpleInterface6; - case (7): + case(7): return HashMapOfString_SimpleInterface7; - case (8): + case(8): return HashMapOfString_SimpleInterface8; - case (9): + case(9): return HashMapOfString_String9; - case (10): + case(10): return HashMapOfString_String10; - case (11): + case(11): return HashMapOfString_String11; - case (12): + case(12): return HashMapOfString_Date12; - case (13): + case(13): return HashMapOfString_Date13; - case (14): + case(14): return HashMapOfString_Date14; - case (15): + case(15): return HashMapOfString_Locale15; - case (16): + case(16): return HashMapOfString_Locale16; - case (17): + case(17): return HashMapOfString_Locale17; - case (18): + case(18): return HashMapOfString_BigDecimal18; - case (19): + case(19): return HashMapOfString_BigDecimal19; - case (20): + case(20): return HashMapOfString_BigDecimal20; - case (21): + case(21): return HashMapOfString_BigInteger21; - case (22): + case(22): return HashMapOfString_BigInteger22; - case (23): + case(23): return HashMapOfString_BigInteger23; - case (24): + case(24): return HashMapOfString_Byte24; - case (25): + case(25): return HashMapOfString_Byte25; - case (26): + case(26): return HashMapOfString_Byte26; - case (27): + case(27): return HashMapOfString_Double27; - case (28): + case(28): return HashMapOfString_Double28; - case (29): + case(29): return HashMapOfString_Double29; - case (30): + case(30): return HashMapOfString_Float30; - case (31): + case(31): return HashMapOfString_Float31; - case (32): + case(32): return HashMapOfString_Float32; - case (33): + case(33): return HashMapOfString_Integer33; - case (34): + case(34): return HashMapOfString_Integer34; - case (35): + case(35): return HashMapOfString_Integer35; - case (36): + case(36): return HashMapOfString_Long36; - case (37): + case(37): return HashMapOfString_Long37; - case (38): + case(38): return HashMapOfString_Long38; - case (39): + case(39): return HashMapOfString_Short39; - case (40): + case(40): return HashMapOfString_Short40; - case (41): + case(41): return HashMapOfString_Short41; - case (42): + case(42): return HashMapOfString_Object42; - case (43): + case(43): return HashMapOfString_Object43; - case (44): + case(44): return HashMapOfString_SimpleClass45; - case (45): + case(45): return HashMapOfString_SimpleClass46; - case (46): + case(46): return HashMapOfString_SimpleInterface48; - case (47): + case(47): return HashMapOfString_SimpleInterface49; - case (48): + case(48): return HashMapOfString_String51; - case (49): + case(49): return HashMapOfString_String52; - case (50): + case(50): return HashMapOfString_Date54; - case (51): + case(51): return HashMapOfString_Date55; - case (52): + case(52): return HashMapOfString_Locale57; - case (53): + case(53): return HashMapOfString_Locale58; - case (54): + case(54): return HashMapOfString_BigDecimal60; - case (55): + case(55): return HashMapOfString_BigDecimal61; - case (56): + case(56): return HashMapOfString_BigInteger63; - case (57): + case(57): return HashMapOfString_BigInteger64; - case (58): + case(58): return HashMapOfString_Byte66; - case (59): + case(59): return HashMapOfString_Byte67; - case (60): + case(60): return HashMapOfString_Double69; - case (61): + case(61): return HashMapOfString_Double70; - case (62): + case(62): return HashMapOfString_Float72; - case (63): + case(63): return HashMapOfString_Float73; - case (64): + case(64): return HashMapOfString_Integer75; - case (65): + case(65): return HashMapOfString_Integer76; - case (66): + case(66): return HashMapOfString_Long78; - case (67): + case(67): return HashMapOfString_Long79; - case (68): + case(68): return HashMapOfString_Short81; - case (69): + case(69): return HashMapOfString_Short82; - case (70): + case(70): return HashMapOfString_Object84; - case (71): + case(71): return HashMapOfString_Object86; - case (72): + case(72): return HashMapOfString_SimpleClass87; - case (73): + case(73): return HashMapOfString_SimpleClass89; - case (74): + case(74): return HashMapOfString_SimpleInterface90; - case (75): + case(75): return HashMapOfString_SimpleInterface92; - case (76): + case(76): return HashMapOfString_String93; - case (77): + case(77): return HashMapOfString_String95; - case (78): + case(78): return HashMapOfString_Date96; - case (79): + case(79): return HashMapOfString_Date98; - case (80): + case(80): return HashMapOfString_Locale99; - case (81): + case(81): return HashMapOfString_Locale101; - case (82): + case(82): return HashMapOfString_BigDecimal102; - case (83): + case(83): return HashMapOfString_BigDecimal104; - case (84): + case(84): return HashMapOfString_BigInteger105; - case (85): + case(85): return HashMapOfString_BigInteger107; - case (86): + case(86): return HashMapOfString_Byte108; - case (87): + case(87): return HashMapOfString_Byte110; - case (88): + case(88): return HashMapOfString_Double111; - case (89): + case(89): return HashMapOfString_Double113; - case (90): + case(90): return HashMapOfString_Float114; - case (91): + case(91): return HashMapOfString_Float116; - case (92): + case(92): return HashMapOfString_Integer117; - case (93): + case(93): return HashMapOfString_Integer119; - case (94): + case(94): return HashMapOfString_Long120; - case (95): + case(95): return HashMapOfString_Long122; - case (96): + case(96): return HashMapOfString_Short123; - case (97): + case(97): return HashMapOfString_Short125; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, HashMap value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - HashMapOfString_Object0 = value; - break; - case (1): - HashMapOfString_Object1 = value; - break; - case (2): - HashMapOfString_Object2 = value; - break; - case (3): - HashMapOfString_SimpleClass3 = value; - break; - case (4): - HashMapOfString_SimpleClass4 = value; - break; - case (5): - HashMapOfString_SimpleClass5 = value; - break; - case (6): - HashMapOfString_SimpleInterface6 = value; - break; - case (7): - HashMapOfString_SimpleInterface7 = value; - break; - case (8): - HashMapOfString_SimpleInterface8 = value; - break; - case (9): - HashMapOfString_String9 = value; - break; - case (10): - HashMapOfString_String10 = value; - break; - case (11): - HashMapOfString_String11 = value; - break; - case (12): - HashMapOfString_Date12 = value; - break; - case (13): - HashMapOfString_Date13 = value; - break; - case (14): - HashMapOfString_Date14 = value; - break; - case (15): - HashMapOfString_Locale15 = value; - break; - case (16): - HashMapOfString_Locale16 = value; - break; - case (17): - HashMapOfString_Locale17 = value; - break; - case (18): - HashMapOfString_BigDecimal18 = value; - break; - case (19): - HashMapOfString_BigDecimal19 = value; - break; - case (20): - HashMapOfString_BigDecimal20 = value; - break; - case (21): - HashMapOfString_BigInteger21 = value; - break; - case (22): - HashMapOfString_BigInteger22 = value; - break; - case (23): - HashMapOfString_BigInteger23 = value; - break; - case (24): - HashMapOfString_Byte24 = value; - break; - case (25): - HashMapOfString_Byte25 = value; - break; - case (26): - HashMapOfString_Byte26 = value; - break; - case (27): - HashMapOfString_Double27 = value; - break; - case (28): - HashMapOfString_Double28 = value; - break; - case (29): - HashMapOfString_Double29 = value; - break; - case (30): - HashMapOfString_Float30 = value; - break; - case (31): - HashMapOfString_Float31 = value; - break; - case (32): - HashMapOfString_Float32 = value; - break; - case (33): - HashMapOfString_Integer33 = value; - break; - case (34): - HashMapOfString_Integer34 = value; - break; - case (35): - HashMapOfString_Integer35 = value; - break; - case (36): - HashMapOfString_Long36 = value; - break; - case (37): - HashMapOfString_Long37 = value; - break; - case (38): - HashMapOfString_Long38 = value; - break; - case (39): - HashMapOfString_Short39 = value; - break; - case (40): - HashMapOfString_Short40 = value; - break; - case (41): - HashMapOfString_Short41 = value; - break; - case (42): - HashMapOfString_Object42 = value; - break; - case (43): - HashMapOfString_Object43 = value; - break; - case (44): - HashMapOfString_SimpleClass45 = value; - break; - case (45): - HashMapOfString_SimpleClass46 = value; - break; - case (46): - HashMapOfString_SimpleInterface48 = value; - break; - case (47): - HashMapOfString_SimpleInterface49 = value; - break; - case (48): - HashMapOfString_String51 = value; - break; - case (49): - HashMapOfString_String52 = value; - break; - case (50): - HashMapOfString_Date54 = value; - break; - case (51): - HashMapOfString_Date55 = value; - break; - case (52): - HashMapOfString_Locale57 = value; - break; - case (53): - HashMapOfString_Locale58 = value; - break; - case (54): - HashMapOfString_BigDecimal60 = value; - break; - case (55): - HashMapOfString_BigDecimal61 = value; - break; - case (56): - HashMapOfString_BigInteger63 = value; - break; - case (57): - HashMapOfString_BigInteger64 = value; - break; - case (58): - HashMapOfString_Byte66 = value; - break; - case (59): - HashMapOfString_Byte67 = value; - break; - case (60): - HashMapOfString_Double69 = value; - break; - case (61): - HashMapOfString_Double70 = value; - break; - case (62): - HashMapOfString_Float72 = value; - break; - case (63): - HashMapOfString_Float73 = value; - break; - case (64): - HashMapOfString_Integer75 = value; - break; - case (65): - HashMapOfString_Integer76 = value; - break; - case (66): - HashMapOfString_Long78 = value; - break; - case (67): - HashMapOfString_Long79 = value; - break; - case (68): - HashMapOfString_Short81 = value; - break; - case (69): - HashMapOfString_Short82 = value; - break; - case (70): - HashMapOfString_Object84 = value; - break; - case (71): - HashMapOfString_Object86 = value; - break; - case (72): - HashMapOfString_SimpleClass87 = value; - break; - case (73): - HashMapOfString_SimpleClass89 = value; - break; - case (74): - HashMapOfString_SimpleInterface90 = value; - break; - case (75): - HashMapOfString_SimpleInterface92 = value; - break; - case (76): - HashMapOfString_String93 = value; - break; - case (77): - HashMapOfString_String95 = value; - break; - case (78): - HashMapOfString_Date96 = value; - break; - case (79): - HashMapOfString_Date98 = value; - break; - case (80): - HashMapOfString_Locale99 = value; - break; - case (81): - HashMapOfString_Locale101 = value; - break; - case (82): - HashMapOfString_BigDecimal102 = value; - break; - case (83): - HashMapOfString_BigDecimal104 = value; - break; - case (84): - HashMapOfString_BigInteger105 = value; - break; - case (85): - HashMapOfString_BigInteger107 = value; - break; - case (86): - HashMapOfString_Byte108 = value; - break; - case (87): - HashMapOfString_Byte110 = value; - break; - case (88): - HashMapOfString_Double111 = value; - break; - case (89): - HashMapOfString_Double113 = value; - break; - case (90): - HashMapOfString_Float114 = value; - break; - case (91): - HashMapOfString_Float116 = value; - break; - case (92): - HashMapOfString_Integer117 = value; - break; - case (93): - HashMapOfString_Integer119 = value; - break; - case (94): - HashMapOfString_Long120 = value; - break; - case (95): - HashMapOfString_Long122 = value; - break; - case (96): - HashMapOfString_Short123 = value; - break; - case (97): - HashMapOfString_Short125 = value; - break; + public boolean set(int index,HashMap value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + HashMapOfString_Object0= value; + break; + case(1): + HashMapOfString_Object1= value; + break; + case(2): + HashMapOfString_Object2= value; + break; + case(3): + HashMapOfString_SimpleClass3= value; + break; + case(4): + HashMapOfString_SimpleClass4= value; + break; + case(5): + HashMapOfString_SimpleClass5= value; + break; + case(6): + HashMapOfString_SimpleInterface6= value; + break; + case(7): + HashMapOfString_SimpleInterface7= value; + break; + case(8): + HashMapOfString_SimpleInterface8= value; + break; + case(9): + HashMapOfString_String9= value; + break; + case(10): + HashMapOfString_String10= value; + break; + case(11): + HashMapOfString_String11= value; + break; + case(12): + HashMapOfString_Date12= value; + break; + case(13): + HashMapOfString_Date13= value; + break; + case(14): + HashMapOfString_Date14= value; + break; + case(15): + HashMapOfString_Locale15= value; + break; + case(16): + HashMapOfString_Locale16= value; + break; + case(17): + HashMapOfString_Locale17= value; + break; + case(18): + HashMapOfString_BigDecimal18= value; + break; + case(19): + HashMapOfString_BigDecimal19= value; + break; + case(20): + HashMapOfString_BigDecimal20= value; + break; + case(21): + HashMapOfString_BigInteger21= value; + break; + case(22): + HashMapOfString_BigInteger22= value; + break; + case(23): + HashMapOfString_BigInteger23= value; + break; + case(24): + HashMapOfString_Byte24= value; + break; + case(25): + HashMapOfString_Byte25= value; + break; + case(26): + HashMapOfString_Byte26= value; + break; + case(27): + HashMapOfString_Double27= value; + break; + case(28): + HashMapOfString_Double28= value; + break; + case(29): + HashMapOfString_Double29= value; + break; + case(30): + HashMapOfString_Float30= value; + break; + case(31): + HashMapOfString_Float31= value; + break; + case(32): + HashMapOfString_Float32= value; + break; + case(33): + HashMapOfString_Integer33= value; + break; + case(34): + HashMapOfString_Integer34= value; + break; + case(35): + HashMapOfString_Integer35= value; + break; + case(36): + HashMapOfString_Long36= value; + break; + case(37): + HashMapOfString_Long37= value; + break; + case(38): + HashMapOfString_Long38= value; + break; + case(39): + HashMapOfString_Short39= value; + break; + case(40): + HashMapOfString_Short40= value; + break; + case(41): + HashMapOfString_Short41= value; + break; + case(42): + HashMapOfString_Object42= value; + break; + case(43): + HashMapOfString_Object43= value; + break; + case(44): + HashMapOfString_SimpleClass45= value; + break; + case(45): + HashMapOfString_SimpleClass46= value; + break; + case(46): + HashMapOfString_SimpleInterface48= value; + break; + case(47): + HashMapOfString_SimpleInterface49= value; + break; + case(48): + HashMapOfString_String51= value; + break; + case(49): + HashMapOfString_String52= value; + break; + case(50): + HashMapOfString_Date54= value; + break; + case(51): + HashMapOfString_Date55= value; + break; + case(52): + HashMapOfString_Locale57= value; + break; + case(53): + HashMapOfString_Locale58= value; + break; + case(54): + HashMapOfString_BigDecimal60= value; + break; + case(55): + HashMapOfString_BigDecimal61= value; + break; + case(56): + HashMapOfString_BigInteger63= value; + break; + case(57): + HashMapOfString_BigInteger64= value; + break; + case(58): + HashMapOfString_Byte66= value; + break; + case(59): + HashMapOfString_Byte67= value; + break; + case(60): + HashMapOfString_Double69= value; + break; + case(61): + HashMapOfString_Double70= value; + break; + case(62): + HashMapOfString_Float72= value; + break; + case(63): + HashMapOfString_Float73= value; + break; + case(64): + HashMapOfString_Integer75= value; + break; + case(65): + HashMapOfString_Integer76= value; + break; + case(66): + HashMapOfString_Long78= value; + break; + case(67): + HashMapOfString_Long79= value; + break; + case(68): + HashMapOfString_Short81= value; + break; + case(69): + HashMapOfString_Short82= value; + break; + case(70): + HashMapOfString_Object84= value; + break; + case(71): + HashMapOfString_Object86= value; + break; + case(72): + HashMapOfString_SimpleClass87= value; + break; + case(73): + HashMapOfString_SimpleClass89= value; + break; + case(74): + HashMapOfString_SimpleInterface90= value; + break; + case(75): + HashMapOfString_SimpleInterface92= value; + break; + case(76): + HashMapOfString_String93= value; + break; + case(77): + HashMapOfString_String95= value; + break; + case(78): + HashMapOfString_Date96= value; + break; + case(79): + HashMapOfString_Date98= value; + break; + case(80): + HashMapOfString_Locale99= value; + break; + case(81): + HashMapOfString_Locale101= value; + break; + case(82): + HashMapOfString_BigDecimal102= value; + break; + case(83): + HashMapOfString_BigDecimal104= value; + break; + case(84): + HashMapOfString_BigInteger105= value; + break; + case(85): + HashMapOfString_BigInteger107= value; + break; + case(86): + HashMapOfString_Byte108= value; + break; + case(87): + HashMapOfString_Byte110= value; + break; + case(88): + HashMapOfString_Double111= value; + break; + case(89): + HashMapOfString_Double113= value; + break; + case(90): + HashMapOfString_Float114= value; + break; + case(91): + HashMapOfString_Float116= value; + break; + case(92): + HashMapOfString_Integer117= value; + break; + case(93): + HashMapOfString_Integer119= value; + break; + case(94): + HashMapOfString_Long120= value; + break; + case(95): + HashMapOfString_Long122= value; + break; + case(96): + HashMapOfString_Short123= value; + break; + case(97): + HashMapOfString_Short125= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/HashMapStringValueCollections.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/HashMapStringValueCollections.java index 87f6f4f35..25bb82eae 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/HashMapStringValueCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/HashMapStringValueCollections.java @@ -5,22 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; import java.util.HashMap; -public class HashMapStringValueCollections { +public class HashMapStringValueCollections { public int identifier; public HashMap HashMapOfObject_String0; public HashMap HashMapOfObject_String1; @@ -114,602 +114,602 @@ public class HashMapStringValueCollections { public HashMap HashMapOfShort_String114; public HashMap HashMapOfShort_String116; - public static final String[] fieldSpecs = { - "public HashMap HashMapOfObject_String0", - "embedded-value=true public HashMap HashMapOfObject_String1", - "embedded-value=false public HashMap HashMapOfObject_String2", - "embedded-key=true public HashMap HashMapOfObject_String3", - "embedded-key=true embedded-value=true public HashMap HashMapOfObject_String4", - "embedded-key=false public HashMap HashMapOfObject_String6", - "embedded-key=false embedded-value=false public HashMap HashMapOfObject_String8", - "public HashMap HashMapOfSimpleClass_String9", - "embedded-value=true public HashMap HashMapOfSimpleClass_String10", - "embedded-value=false public HashMap HashMapOfSimpleClass_String11", - "embedded-key=true public HashMap HashMapOfSimpleClass_String12", - "embedded-key=true embedded-value=true public HashMap HashMapOfSimpleClass_String13", - "embedded-key=false public HashMap HashMapOfSimpleClass_String15", - "embedded-key=false embedded-value=false public HashMap HashMapOfSimpleClass_String17", - "public HashMap HashMapOfSimpleInterface_String18", - "embedded-value=true public HashMap HashMapOfSimpleInterface_String19", - "embedded-value=false public HashMap HashMapOfSimpleInterface_String20", - "embedded-key=true public HashMap HashMapOfSimpleInterface_String21", - "embedded-key=true embedded-value=true public HashMap HashMapOfSimpleInterface_String22", - "embedded-key=false public HashMap HashMapOfSimpleInterface_String24", - "embedded-key=false embedded-value=false public HashMap HashMapOfSimpleInterface_String26", - "public HashMap HashMapOfString_String27", - "embedded-value=true public HashMap HashMapOfString_String28", - "embedded-value=false public HashMap HashMapOfString_String29", - "embedded-key=true public HashMap HashMapOfString_String30", - "embedded-key=true embedded-value=true public HashMap HashMapOfString_String31", - "embedded-key=false public HashMap HashMapOfString_String33", - "embedded-key=false embedded-value=false public HashMap HashMapOfString_String35", - "public HashMap HashMapOfDate_String36", - "embedded-value=true public HashMap HashMapOfDate_String37", - "embedded-value=false public HashMap HashMapOfDate_String38", - "embedded-key=true public HashMap HashMapOfDate_String39", - "embedded-key=true embedded-value=true public HashMap HashMapOfDate_String40", - "embedded-key=false public HashMap HashMapOfDate_String42", - "embedded-key=false embedded-value=false public HashMap HashMapOfDate_String44", - "public HashMap HashMapOfBigDecimal_String45", - "embedded-value=true public HashMap HashMapOfBigDecimal_String46", - "embedded-value=false public HashMap HashMapOfBigDecimal_String47", - "embedded-key=true public HashMap HashMapOfBigDecimal_String48", - "embedded-key=true embedded-value=true public HashMap HashMapOfBigDecimal_String49", - "embedded-key=false public HashMap HashMapOfBigDecimal_String51", - "embedded-key=false embedded-value=false public HashMap HashMapOfBigDecimal_String53", - "public HashMap HashMapOfBigInteger_String54", - "embedded-value=true public HashMap HashMapOfBigInteger_String55", - "embedded-value=false public HashMap HashMapOfBigInteger_String56", - "embedded-key=true public HashMap HashMapOfBigInteger_String57", - "embedded-key=true embedded-value=true public HashMap HashMapOfBigInteger_String58", - "embedded-key=false public HashMap HashMapOfBigInteger_String60", - "embedded-key=false embedded-value=false public HashMap HashMapOfBigInteger_String62", - "public HashMap HashMapOfByte_String63", - "embedded-value=true public HashMap HashMapOfByte_String64", - "embedded-value=false public HashMap HashMapOfByte_String65", - "embedded-key=true public HashMap HashMapOfByte_String66", - "embedded-key=true embedded-value=true public HashMap HashMapOfByte_String67", - "embedded-key=false public HashMap HashMapOfByte_String69", - "embedded-key=false embedded-value=false public HashMap HashMapOfByte_String71", - "public HashMap HashMapOfDouble_String72", - "embedded-value=true public HashMap HashMapOfDouble_String73", - "embedded-value=false public HashMap HashMapOfDouble_String74", - "embedded-key=true public HashMap HashMapOfDouble_String75", - "embedded-key=true embedded-value=true public HashMap HashMapOfDouble_String76", - "embedded-key=false public HashMap HashMapOfDouble_String78", - "embedded-key=false embedded-value=false public HashMap HashMapOfDouble_String80", - "public HashMap HashMapOfFloat_String81", - "embedded-value=true public HashMap HashMapOfFloat_String82", - "embedded-value=false public HashMap HashMapOfFloat_String83", - "embedded-key=true public HashMap HashMapOfFloat_String84", - "embedded-key=true embedded-value=true public HashMap HashMapOfFloat_String85", - "embedded-key=false public HashMap HashMapOfFloat_String87", - "embedded-key=false embedded-value=false public HashMap HashMapOfFloat_String89", - "public HashMap HashMapOfInteger_String90", - "embedded-value=true public HashMap HashMapOfInteger_String91", - "embedded-value=false public HashMap HashMapOfInteger_String92", - "embedded-key=true public HashMap HashMapOfInteger_String93", - "embedded-key=true embedded-value=true public HashMap HashMapOfInteger_String94", - "embedded-key=false public HashMap HashMapOfInteger_String96", - "embedded-key=false embedded-value=false public HashMap HashMapOfInteger_String98", - "public HashMap HashMapOfLong_String99", - "embedded-value=true public HashMap HashMapOfLong_String100", - "embedded-value=false public HashMap HashMapOfLong_String101", - "embedded-key=true public HashMap HashMapOfLong_String102", - "embedded-key=true embedded-value=true public HashMap HashMapOfLong_String103", - "embedded-key=false public HashMap HashMapOfLong_String105", - "embedded-key=false embedded-value=false public HashMap HashMapOfLong_String107", - "public HashMap HashMapOfShort_String108", - "embedded-value=true public HashMap HashMapOfShort_String109", - "embedded-value=false public HashMap HashMapOfShort_String110", - "embedded-key=true public HashMap HashMapOfShort_String111", - "embedded-key=true embedded-value=true public HashMap HashMapOfShort_String112", - "embedded-key=false public HashMap HashMapOfShort_String114", - "embedded-key=false embedded-value=false public HashMap HashMapOfShort_String116" + public static final String [] fieldSpecs = { + "public HashMap HashMapOfObject_String0", + "embedded-value=true public HashMap HashMapOfObject_String1", + "embedded-value=false public HashMap HashMapOfObject_String2", + "embedded-key=true public HashMap HashMapOfObject_String3", + "embedded-key=true embedded-value=true public HashMap HashMapOfObject_String4", + "embedded-key=false public HashMap HashMapOfObject_String6", + "embedded-key=false embedded-value=false public HashMap HashMapOfObject_String8", + "public HashMap HashMapOfSimpleClass_String9", + "embedded-value=true public HashMap HashMapOfSimpleClass_String10", + "embedded-value=false public HashMap HashMapOfSimpleClass_String11", + "embedded-key=true public HashMap HashMapOfSimpleClass_String12", + "embedded-key=true embedded-value=true public HashMap HashMapOfSimpleClass_String13", + "embedded-key=false public HashMap HashMapOfSimpleClass_String15", + "embedded-key=false embedded-value=false public HashMap HashMapOfSimpleClass_String17", + "public HashMap HashMapOfSimpleInterface_String18", + "embedded-value=true public HashMap HashMapOfSimpleInterface_String19", + "embedded-value=false public HashMap HashMapOfSimpleInterface_String20", + "embedded-key=true public HashMap HashMapOfSimpleInterface_String21", + "embedded-key=true embedded-value=true public HashMap HashMapOfSimpleInterface_String22", + "embedded-key=false public HashMap HashMapOfSimpleInterface_String24", + "embedded-key=false embedded-value=false public HashMap HashMapOfSimpleInterface_String26", + "public HashMap HashMapOfString_String27", + "embedded-value=true public HashMap HashMapOfString_String28", + "embedded-value=false public HashMap HashMapOfString_String29", + "embedded-key=true public HashMap HashMapOfString_String30", + "embedded-key=true embedded-value=true public HashMap HashMapOfString_String31", + "embedded-key=false public HashMap HashMapOfString_String33", + "embedded-key=false embedded-value=false public HashMap HashMapOfString_String35", + "public HashMap HashMapOfDate_String36", + "embedded-value=true public HashMap HashMapOfDate_String37", + "embedded-value=false public HashMap HashMapOfDate_String38", + "embedded-key=true public HashMap HashMapOfDate_String39", + "embedded-key=true embedded-value=true public HashMap HashMapOfDate_String40", + "embedded-key=false public HashMap HashMapOfDate_String42", + "embedded-key=false embedded-value=false public HashMap HashMapOfDate_String44", + "public HashMap HashMapOfBigDecimal_String45", + "embedded-value=true public HashMap HashMapOfBigDecimal_String46", + "embedded-value=false public HashMap HashMapOfBigDecimal_String47", + "embedded-key=true public HashMap HashMapOfBigDecimal_String48", + "embedded-key=true embedded-value=true public HashMap HashMapOfBigDecimal_String49", + "embedded-key=false public HashMap HashMapOfBigDecimal_String51", + "embedded-key=false embedded-value=false public HashMap HashMapOfBigDecimal_String53", + "public HashMap HashMapOfBigInteger_String54", + "embedded-value=true public HashMap HashMapOfBigInteger_String55", + "embedded-value=false public HashMap HashMapOfBigInteger_String56", + "embedded-key=true public HashMap HashMapOfBigInteger_String57", + "embedded-key=true embedded-value=true public HashMap HashMapOfBigInteger_String58", + "embedded-key=false public HashMap HashMapOfBigInteger_String60", + "embedded-key=false embedded-value=false public HashMap HashMapOfBigInteger_String62", + "public HashMap HashMapOfByte_String63", + "embedded-value=true public HashMap HashMapOfByte_String64", + "embedded-value=false public HashMap HashMapOfByte_String65", + "embedded-key=true public HashMap HashMapOfByte_String66", + "embedded-key=true embedded-value=true public HashMap HashMapOfByte_String67", + "embedded-key=false public HashMap HashMapOfByte_String69", + "embedded-key=false embedded-value=false public HashMap HashMapOfByte_String71", + "public HashMap HashMapOfDouble_String72", + "embedded-value=true public HashMap HashMapOfDouble_String73", + "embedded-value=false public HashMap HashMapOfDouble_String74", + "embedded-key=true public HashMap HashMapOfDouble_String75", + "embedded-key=true embedded-value=true public HashMap HashMapOfDouble_String76", + "embedded-key=false public HashMap HashMapOfDouble_String78", + "embedded-key=false embedded-value=false public HashMap HashMapOfDouble_String80", + "public HashMap HashMapOfFloat_String81", + "embedded-value=true public HashMap HashMapOfFloat_String82", + "embedded-value=false public HashMap HashMapOfFloat_String83", + "embedded-key=true public HashMap HashMapOfFloat_String84", + "embedded-key=true embedded-value=true public HashMap HashMapOfFloat_String85", + "embedded-key=false public HashMap HashMapOfFloat_String87", + "embedded-key=false embedded-value=false public HashMap HashMapOfFloat_String89", + "public HashMap HashMapOfInteger_String90", + "embedded-value=true public HashMap HashMapOfInteger_String91", + "embedded-value=false public HashMap HashMapOfInteger_String92", + "embedded-key=true public HashMap HashMapOfInteger_String93", + "embedded-key=true embedded-value=true public HashMap HashMapOfInteger_String94", + "embedded-key=false public HashMap HashMapOfInteger_String96", + "embedded-key=false embedded-value=false public HashMap HashMapOfInteger_String98", + "public HashMap HashMapOfLong_String99", + "embedded-value=true public HashMap HashMapOfLong_String100", + "embedded-value=false public HashMap HashMapOfLong_String101", + "embedded-key=true public HashMap HashMapOfLong_String102", + "embedded-key=true embedded-value=true public HashMap HashMapOfLong_String103", + "embedded-key=false public HashMap HashMapOfLong_String105", + "embedded-key=false embedded-value=false public HashMap HashMapOfLong_String107", + "public HashMap HashMapOfShort_String108", + "embedded-value=true public HashMap HashMapOfShort_String109", + "embedded-value=false public HashMap HashMapOfShort_String110", + "embedded-key=true public HashMap HashMapOfShort_String111", + "embedded-key=true embedded-value=true public HashMap HashMapOfShort_String112", + "embedded-key=false public HashMap HashMapOfShort_String114", + "embedded-key=false embedded-value=false public HashMap HashMapOfShort_String116" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public HashMap get(int index) { - switch (index) { - case (0): + public HashMap get(int index) + { + switch (index) + { + case(0): return HashMapOfObject_String0; - case (1): + case(1): return HashMapOfObject_String1; - case (2): + case(2): return HashMapOfObject_String2; - case (3): + case(3): return HashMapOfObject_String3; - case (4): + case(4): return HashMapOfObject_String4; - case (5): + case(5): return HashMapOfObject_String6; - case (6): + case(6): return HashMapOfObject_String8; - case (7): + case(7): return HashMapOfSimpleClass_String9; - case (8): + case(8): return HashMapOfSimpleClass_String10; - case (9): + case(9): return HashMapOfSimpleClass_String11; - case (10): + case(10): return HashMapOfSimpleClass_String12; - case (11): + case(11): return HashMapOfSimpleClass_String13; - case (12): + case(12): return HashMapOfSimpleClass_String15; - case (13): + case(13): return HashMapOfSimpleClass_String17; - case (14): + case(14): return HashMapOfSimpleInterface_String18; - case (15): + case(15): return HashMapOfSimpleInterface_String19; - case (16): + case(16): return HashMapOfSimpleInterface_String20; - case (17): + case(17): return HashMapOfSimpleInterface_String21; - case (18): + case(18): return HashMapOfSimpleInterface_String22; - case (19): + case(19): return HashMapOfSimpleInterface_String24; - case (20): + case(20): return HashMapOfSimpleInterface_String26; - case (21): + case(21): return HashMapOfString_String27; - case (22): + case(22): return HashMapOfString_String28; - case (23): + case(23): return HashMapOfString_String29; - case (24): + case(24): return HashMapOfString_String30; - case (25): + case(25): return HashMapOfString_String31; - case (26): + case(26): return HashMapOfString_String33; - case (27): + case(27): return HashMapOfString_String35; - case (28): + case(28): return HashMapOfDate_String36; - case (29): + case(29): return HashMapOfDate_String37; - case (30): + case(30): return HashMapOfDate_String38; - case (31): + case(31): return HashMapOfDate_String39; - case (32): + case(32): return HashMapOfDate_String40; - case (33): + case(33): return HashMapOfDate_String42; - case (34): + case(34): return HashMapOfDate_String44; - case (35): + case(35): return HashMapOfBigDecimal_String45; - case (36): + case(36): return HashMapOfBigDecimal_String46; - case (37): + case(37): return HashMapOfBigDecimal_String47; - case (38): + case(38): return HashMapOfBigDecimal_String48; - case (39): + case(39): return HashMapOfBigDecimal_String49; - case (40): + case(40): return HashMapOfBigDecimal_String51; - case (41): + case(41): return HashMapOfBigDecimal_String53; - case (42): + case(42): return HashMapOfBigInteger_String54; - case (43): + case(43): return HashMapOfBigInteger_String55; - case (44): + case(44): return HashMapOfBigInteger_String56; - case (45): + case(45): return HashMapOfBigInteger_String57; - case (46): + case(46): return HashMapOfBigInteger_String58; - case (47): + case(47): return HashMapOfBigInteger_String60; - case (48): + case(48): return HashMapOfBigInteger_String62; - case (49): + case(49): return HashMapOfByte_String63; - case (50): + case(50): return HashMapOfByte_String64; - case (51): + case(51): return HashMapOfByte_String65; - case (52): + case(52): return HashMapOfByte_String66; - case (53): + case(53): return HashMapOfByte_String67; - case (54): + case(54): return HashMapOfByte_String69; - case (55): + case(55): return HashMapOfByte_String71; - case (56): + case(56): return HashMapOfDouble_String72; - case (57): + case(57): return HashMapOfDouble_String73; - case (58): + case(58): return HashMapOfDouble_String74; - case (59): + case(59): return HashMapOfDouble_String75; - case (60): + case(60): return HashMapOfDouble_String76; - case (61): + case(61): return HashMapOfDouble_String78; - case (62): + case(62): return HashMapOfDouble_String80; - case (63): + case(63): return HashMapOfFloat_String81; - case (64): + case(64): return HashMapOfFloat_String82; - case (65): + case(65): return HashMapOfFloat_String83; - case (66): + case(66): return HashMapOfFloat_String84; - case (67): + case(67): return HashMapOfFloat_String85; - case (68): + case(68): return HashMapOfFloat_String87; - case (69): + case(69): return HashMapOfFloat_String89; - case (70): + case(70): return HashMapOfInteger_String90; - case (71): + case(71): return HashMapOfInteger_String91; - case (72): + case(72): return HashMapOfInteger_String92; - case (73): + case(73): return HashMapOfInteger_String93; - case (74): + case(74): return HashMapOfInteger_String94; - case (75): + case(75): return HashMapOfInteger_String96; - case (76): + case(76): return HashMapOfInteger_String98; - case (77): + case(77): return HashMapOfLong_String99; - case (78): + case(78): return HashMapOfLong_String100; - case (79): + case(79): return HashMapOfLong_String101; - case (80): + case(80): return HashMapOfLong_String102; - case (81): + case(81): return HashMapOfLong_String103; - case (82): + case(82): return HashMapOfLong_String105; - case (83): + case(83): return HashMapOfLong_String107; - case (84): + case(84): return HashMapOfShort_String108; - case (85): + case(85): return HashMapOfShort_String109; - case (86): + case(86): return HashMapOfShort_String110; - case (87): + case(87): return HashMapOfShort_String111; - case (88): + case(88): return HashMapOfShort_String112; - case (89): + case(89): return HashMapOfShort_String114; - case (90): + case(90): return HashMapOfShort_String116; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, HashMap value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - HashMapOfObject_String0 = value; - break; - case (1): - HashMapOfObject_String1 = value; - break; - case (2): - HashMapOfObject_String2 = value; - break; - case (3): - HashMapOfObject_String3 = value; - break; - case (4): - HashMapOfObject_String4 = value; - break; - case (5): - HashMapOfObject_String6 = value; - break; - case (6): - HashMapOfObject_String8 = value; - break; - case (7): - HashMapOfSimpleClass_String9 = value; - break; - case (8): - HashMapOfSimpleClass_String10 = value; - break; - case (9): - HashMapOfSimpleClass_String11 = value; - break; - case (10): - HashMapOfSimpleClass_String12 = value; - break; - case (11): - HashMapOfSimpleClass_String13 = value; - break; - case (12): - HashMapOfSimpleClass_String15 = value; - break; - case (13): - HashMapOfSimpleClass_String17 = value; - break; - case (14): - HashMapOfSimpleInterface_String18 = value; - break; - case (15): - HashMapOfSimpleInterface_String19 = value; - break; - case (16): - HashMapOfSimpleInterface_String20 = value; - break; - case (17): - HashMapOfSimpleInterface_String21 = value; - break; - case (18): - HashMapOfSimpleInterface_String22 = value; - break; - case (19): - HashMapOfSimpleInterface_String24 = value; - break; - case (20): - HashMapOfSimpleInterface_String26 = value; - break; - case (21): - HashMapOfString_String27 = value; - break; - case (22): - HashMapOfString_String28 = value; - break; - case (23): - HashMapOfString_String29 = value; - break; - case (24): - HashMapOfString_String30 = value; - break; - case (25): - HashMapOfString_String31 = value; - break; - case (26): - HashMapOfString_String33 = value; - break; - case (27): - HashMapOfString_String35 = value; - break; - case (28): - HashMapOfDate_String36 = value; - break; - case (29): - HashMapOfDate_String37 = value; - break; - case (30): - HashMapOfDate_String38 = value; - break; - case (31): - HashMapOfDate_String39 = value; - break; - case (32): - HashMapOfDate_String40 = value; - break; - case (33): - HashMapOfDate_String42 = value; - break; - case (34): - HashMapOfDate_String44 = value; - break; - case (35): - HashMapOfBigDecimal_String45 = value; - break; - case (36): - HashMapOfBigDecimal_String46 = value; - break; - case (37): - HashMapOfBigDecimal_String47 = value; - break; - case (38): - HashMapOfBigDecimal_String48 = value; - break; - case (39): - HashMapOfBigDecimal_String49 = value; - break; - case (40): - HashMapOfBigDecimal_String51 = value; - break; - case (41): - HashMapOfBigDecimal_String53 = value; - break; - case (42): - HashMapOfBigInteger_String54 = value; - break; - case (43): - HashMapOfBigInteger_String55 = value; - break; - case (44): - HashMapOfBigInteger_String56 = value; - break; - case (45): - HashMapOfBigInteger_String57 = value; - break; - case (46): - HashMapOfBigInteger_String58 = value; - break; - case (47): - HashMapOfBigInteger_String60 = value; - break; - case (48): - HashMapOfBigInteger_String62 = value; - break; - case (49): - HashMapOfByte_String63 = value; - break; - case (50): - HashMapOfByte_String64 = value; - break; - case (51): - HashMapOfByte_String65 = value; - break; - case (52): - HashMapOfByte_String66 = value; - break; - case (53): - HashMapOfByte_String67 = value; - break; - case (54): - HashMapOfByte_String69 = value; - break; - case (55): - HashMapOfByte_String71 = value; - break; - case (56): - HashMapOfDouble_String72 = value; - break; - case (57): - HashMapOfDouble_String73 = value; - break; - case (58): - HashMapOfDouble_String74 = value; - break; - case (59): - HashMapOfDouble_String75 = value; - break; - case (60): - HashMapOfDouble_String76 = value; - break; - case (61): - HashMapOfDouble_String78 = value; - break; - case (62): - HashMapOfDouble_String80 = value; - break; - case (63): - HashMapOfFloat_String81 = value; - break; - case (64): - HashMapOfFloat_String82 = value; - break; - case (65): - HashMapOfFloat_String83 = value; - break; - case (66): - HashMapOfFloat_String84 = value; - break; - case (67): - HashMapOfFloat_String85 = value; - break; - case (68): - HashMapOfFloat_String87 = value; - break; - case (69): - HashMapOfFloat_String89 = value; - break; - case (70): - HashMapOfInteger_String90 = value; - break; - case (71): - HashMapOfInteger_String91 = value; - break; - case (72): - HashMapOfInteger_String92 = value; - break; - case (73): - HashMapOfInteger_String93 = value; - break; - case (74): - HashMapOfInteger_String94 = value; - break; - case (75): - HashMapOfInteger_String96 = value; - break; - case (76): - HashMapOfInteger_String98 = value; - break; - case (77): - HashMapOfLong_String99 = value; - break; - case (78): - HashMapOfLong_String100 = value; - break; - case (79): - HashMapOfLong_String101 = value; - break; - case (80): - HashMapOfLong_String102 = value; - break; - case (81): - HashMapOfLong_String103 = value; - break; - case (82): - HashMapOfLong_String105 = value; - break; - case (83): - HashMapOfLong_String107 = value; - break; - case (84): - HashMapOfShort_String108 = value; - break; - case (85): - HashMapOfShort_String109 = value; - break; - case (86): - HashMapOfShort_String110 = value; - break; - case (87): - HashMapOfShort_String111 = value; - break; - case (88): - HashMapOfShort_String112 = value; - break; - case (89): - HashMapOfShort_String114 = value; - break; - case (90): - HashMapOfShort_String116 = value; - break; + public boolean set(int index,HashMap value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + HashMapOfObject_String0= value; + break; + case(1): + HashMapOfObject_String1= value; + break; + case(2): + HashMapOfObject_String2= value; + break; + case(3): + HashMapOfObject_String3= value; + break; + case(4): + HashMapOfObject_String4= value; + break; + case(5): + HashMapOfObject_String6= value; + break; + case(6): + HashMapOfObject_String8= value; + break; + case(7): + HashMapOfSimpleClass_String9= value; + break; + case(8): + HashMapOfSimpleClass_String10= value; + break; + case(9): + HashMapOfSimpleClass_String11= value; + break; + case(10): + HashMapOfSimpleClass_String12= value; + break; + case(11): + HashMapOfSimpleClass_String13= value; + break; + case(12): + HashMapOfSimpleClass_String15= value; + break; + case(13): + HashMapOfSimpleClass_String17= value; + break; + case(14): + HashMapOfSimpleInterface_String18= value; + break; + case(15): + HashMapOfSimpleInterface_String19= value; + break; + case(16): + HashMapOfSimpleInterface_String20= value; + break; + case(17): + HashMapOfSimpleInterface_String21= value; + break; + case(18): + HashMapOfSimpleInterface_String22= value; + break; + case(19): + HashMapOfSimpleInterface_String24= value; + break; + case(20): + HashMapOfSimpleInterface_String26= value; + break; + case(21): + HashMapOfString_String27= value; + break; + case(22): + HashMapOfString_String28= value; + break; + case(23): + HashMapOfString_String29= value; + break; + case(24): + HashMapOfString_String30= value; + break; + case(25): + HashMapOfString_String31= value; + break; + case(26): + HashMapOfString_String33= value; + break; + case(27): + HashMapOfString_String35= value; + break; + case(28): + HashMapOfDate_String36= value; + break; + case(29): + HashMapOfDate_String37= value; + break; + case(30): + HashMapOfDate_String38= value; + break; + case(31): + HashMapOfDate_String39= value; + break; + case(32): + HashMapOfDate_String40= value; + break; + case(33): + HashMapOfDate_String42= value; + break; + case(34): + HashMapOfDate_String44= value; + break; + case(35): + HashMapOfBigDecimal_String45= value; + break; + case(36): + HashMapOfBigDecimal_String46= value; + break; + case(37): + HashMapOfBigDecimal_String47= value; + break; + case(38): + HashMapOfBigDecimal_String48= value; + break; + case(39): + HashMapOfBigDecimal_String49= value; + break; + case(40): + HashMapOfBigDecimal_String51= value; + break; + case(41): + HashMapOfBigDecimal_String53= value; + break; + case(42): + HashMapOfBigInteger_String54= value; + break; + case(43): + HashMapOfBigInteger_String55= value; + break; + case(44): + HashMapOfBigInteger_String56= value; + break; + case(45): + HashMapOfBigInteger_String57= value; + break; + case(46): + HashMapOfBigInteger_String58= value; + break; + case(47): + HashMapOfBigInteger_String60= value; + break; + case(48): + HashMapOfBigInteger_String62= value; + break; + case(49): + HashMapOfByte_String63= value; + break; + case(50): + HashMapOfByte_String64= value; + break; + case(51): + HashMapOfByte_String65= value; + break; + case(52): + HashMapOfByte_String66= value; + break; + case(53): + HashMapOfByte_String67= value; + break; + case(54): + HashMapOfByte_String69= value; + break; + case(55): + HashMapOfByte_String71= value; + break; + case(56): + HashMapOfDouble_String72= value; + break; + case(57): + HashMapOfDouble_String73= value; + break; + case(58): + HashMapOfDouble_String74= value; + break; + case(59): + HashMapOfDouble_String75= value; + break; + case(60): + HashMapOfDouble_String76= value; + break; + case(61): + HashMapOfDouble_String78= value; + break; + case(62): + HashMapOfDouble_String80= value; + break; + case(63): + HashMapOfFloat_String81= value; + break; + case(64): + HashMapOfFloat_String82= value; + break; + case(65): + HashMapOfFloat_String83= value; + break; + case(66): + HashMapOfFloat_String84= value; + break; + case(67): + HashMapOfFloat_String85= value; + break; + case(68): + HashMapOfFloat_String87= value; + break; + case(69): + HashMapOfFloat_String89= value; + break; + case(70): + HashMapOfInteger_String90= value; + break; + case(71): + HashMapOfInteger_String91= value; + break; + case(72): + HashMapOfInteger_String92= value; + break; + case(73): + HashMapOfInteger_String93= value; + break; + case(74): + HashMapOfInteger_String94= value; + break; + case(75): + HashMapOfInteger_String96= value; + break; + case(76): + HashMapOfInteger_String98= value; + break; + case(77): + HashMapOfLong_String99= value; + break; + case(78): + HashMapOfLong_String100= value; + break; + case(79): + HashMapOfLong_String101= value; + break; + case(80): + HashMapOfLong_String102= value; + break; + case(81): + HashMapOfLong_String103= value; + break; + case(82): + HashMapOfLong_String105= value; + break; + case(83): + HashMapOfLong_String107= value; + break; + case(84): + HashMapOfShort_String108= value; + break; + case(85): + HashMapOfShort_String109= value; + break; + case(86): + HashMapOfShort_String110= value; + break; + case(87): + HashMapOfShort_String111= value; + break; + case(88): + HashMapOfShort_String112= value; + break; + case(89): + HashMapOfShort_String114= value; + break; + case(90): + HashMapOfShort_String116= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/HashSetCollections.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/HashSetCollections.java index 0e842bd64..7228ae793 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/HashSetCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/HashSetCollections.java @@ -5,22 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; import java.util.HashSet; -public class HashSetCollections { +public class HashSetCollections { public int identifier; public HashSet HashSetOfObject0; public HashSet HashSetOfObject1; @@ -66,314 +66,313 @@ public class HashSetCollections { public HashSet HashSetOfShort41; public HashSet HashSetOfSimpleClass42; - public static final String[] fieldSpecs = { - "public HashSet HashSetOfObject0", - "embedded-element=true public HashSet HashSetOfObject1", - "embedded-element=false public HashSet HashSetOfObject2", - "public HashSet HashSetOfSimpleClass3", - "embedded-element=true public HashSet HashSetOfSimpleClass4", - "embedded-element=false public HashSet HashSetOfSimpleClass5", - "public HashSet HashSetOfSimpleInterface6", - "embedded-element=true public HashSet HashSetOfSimpleInterface7", - "embedded-element=false public HashSet HashSetOfSimpleInterface8", - "public HashSet HashSetOfString9", - "embedded-element=true public HashSet HashSetOfString10", - "embedded-element=false public HashSet HashSetOfString11", - "public HashSet HashSetOfDate12", - "embedded-element=true public HashSet HashSetOfDate13", - "embedded-element=false public HashSet HashSetOfDate14", - "public HashSet HashSetOfLocale15", - "embedded-element=true public HashSet HashSetOfLocale16", - "embedded-element=false public HashSet HashSetOfLocale17", - "public HashSet HashSetOfBigDecimal18", - "embedded-element=true public HashSet HashSetOfBigDecimal19", - "embedded-element=false public HashSet HashSetOfBigDecimal20", - "public HashSet HashSetOfBigInteger21", - "embedded-element=true public HashSet HashSetOfBigInteger22", - "embedded-element=false public HashSet HashSetOfBigInteger23", - "public HashSet HashSetOfByte24", - "embedded-element=true public HashSet HashSetOfByte25", - "embedded-element=false public HashSet HashSetOfByte26", - "public HashSet HashSetOfDouble27", - "embedded-element=true public HashSet HashSetOfDouble28", - "embedded-element=false public HashSet HashSetOfDouble29", - "public HashSet HashSetOfFloat30", - "embedded-element=true public HashSet HashSetOfFloat31", - "embedded-element=false public HashSet HashSetOfFloat32", - "public HashSet HashSetOfInteger33", - "embedded-element=true public HashSet HashSetOfInteger34", - "embedded-element=false public HashSet HashSetOfInteger35", - "public HashSet HashSetOfLong36", - "embedded-element=true public HashSet HashSetOfLong37", - "embedded-element=false public HashSet HashSetOfLong38", - "public HashSet HashSetOfShort39", - "embedded-element=true public HashSet HashSetOfShort40", - "embedded-element=false public HashSet HashSetOfShort41", - "serialized=true public HashSet HashSetOfSimpleClass42" + public static final String [] fieldSpecs = { + "public HashSet HashSetOfObject0", + "embedded-element=true public HashSet HashSetOfObject1", + "embedded-element=false public HashSet HashSetOfObject2", + "public HashSet HashSetOfSimpleClass3", + "embedded-element=true public HashSet HashSetOfSimpleClass4", + "embedded-element=false public HashSet HashSetOfSimpleClass5", + "public HashSet HashSetOfSimpleInterface6", + "embedded-element=true public HashSet HashSetOfSimpleInterface7", + "embedded-element=false public HashSet HashSetOfSimpleInterface8", + "public HashSet HashSetOfString9", + "embedded-element=true public HashSet HashSetOfString10", + "embedded-element=false public HashSet HashSetOfString11", + "public HashSet HashSetOfDate12", + "embedded-element=true public HashSet HashSetOfDate13", + "embedded-element=false public HashSet HashSetOfDate14", + "public HashSet HashSetOfLocale15", + "embedded-element=true public HashSet HashSetOfLocale16", + "embedded-element=false public HashSet HashSetOfLocale17", + "public HashSet HashSetOfBigDecimal18", + "embedded-element=true public HashSet HashSetOfBigDecimal19", + "embedded-element=false public HashSet HashSetOfBigDecimal20", + "public HashSet HashSetOfBigInteger21", + "embedded-element=true public HashSet HashSetOfBigInteger22", + "embedded-element=false public HashSet HashSetOfBigInteger23", + "public HashSet HashSetOfByte24", + "embedded-element=true public HashSet HashSetOfByte25", + "embedded-element=false public HashSet HashSetOfByte26", + "public HashSet HashSetOfDouble27", + "embedded-element=true public HashSet HashSetOfDouble28", + "embedded-element=false public HashSet HashSetOfDouble29", + "public HashSet HashSetOfFloat30", + "embedded-element=true public HashSet HashSetOfFloat31", + "embedded-element=false public HashSet HashSetOfFloat32", + "public HashSet HashSetOfInteger33", + "embedded-element=true public HashSet HashSetOfInteger34", + "embedded-element=false public HashSet HashSetOfInteger35", + "public HashSet HashSetOfLong36", + "embedded-element=true public HashSet HashSetOfLong37", + "embedded-element=false public HashSet HashSetOfLong38", + "public HashSet HashSetOfShort39", + "embedded-element=true public HashSet HashSetOfShort40", + "embedded-element=false public HashSet HashSetOfShort41", + "serialized=true public HashSet HashSetOfSimpleClass42" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public HashSet get(int index) { - switch (index) { - case (0): + public HashSet get(int index) + { + switch (index) + { + case(0): return HashSetOfObject0; - case (1): + case(1): return HashSetOfObject1; - case (2): + case(2): return HashSetOfObject2; - case (3): + case(3): return HashSetOfSimpleClass3; - case (4): + case(4): return HashSetOfSimpleClass4; - case (5): + case(5): return HashSetOfSimpleClass5; - case (6): + case(6): return HashSetOfSimpleInterface6; - case (7): + case(7): return HashSetOfSimpleInterface7; - case (8): + case(8): return HashSetOfSimpleInterface8; - case (9): + case(9): return HashSetOfString9; - case (10): + case(10): return HashSetOfString10; - case (11): + case(11): return HashSetOfString11; - case (12): + case(12): return HashSetOfDate12; - case (13): + case(13): return HashSetOfDate13; - case (14): + case(14): return HashSetOfDate14; - case (15): + case(15): return HashSetOfLocale15; - case (16): + case(16): return HashSetOfLocale16; - case (17): + case(17): return HashSetOfLocale17; - case (18): + case(18): return HashSetOfBigDecimal18; - case (19): + case(19): return HashSetOfBigDecimal19; - case (20): + case(20): return HashSetOfBigDecimal20; - case (21): + case(21): return HashSetOfBigInteger21; - case (22): + case(22): return HashSetOfBigInteger22; - case (23): + case(23): return HashSetOfBigInteger23; - case (24): + case(24): return HashSetOfByte24; - case (25): + case(25): return HashSetOfByte25; - case (26): + case(26): return HashSetOfByte26; - case (27): + case(27): return HashSetOfDouble27; - case (28): + case(28): return HashSetOfDouble28; - case (29): + case(29): return HashSetOfDouble29; - case (30): + case(30): return HashSetOfFloat30; - case (31): + case(31): return HashSetOfFloat31; - case (32): + case(32): return HashSetOfFloat32; - case (33): + case(33): return HashSetOfInteger33; - case (34): + case(34): return HashSetOfInteger34; - case (35): + case(35): return HashSetOfInteger35; - case (36): + case(36): return HashSetOfLong36; - case (37): + case(37): return HashSetOfLong37; - case (38): + case(38): return HashSetOfLong38; - case (39): + case(39): return HashSetOfShort39; - case (40): + case(40): return HashSetOfShort40; - case (41): + case(41): return HashSetOfShort41; - case (42): + case(42): return HashSetOfSimpleClass42; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, HashSet value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - HashSetOfObject0 = value; - break; - case (1): - HashSetOfObject1 = value; - break; - case (2): - HashSetOfObject2 = value; - break; - case (3): - HashSetOfSimpleClass3 = value; - break; - case (4): - HashSetOfSimpleClass4 = value; - break; - case (5): - HashSetOfSimpleClass5 = value; - break; - case (6): - HashSetOfSimpleInterface6 = value; - break; - case (7): - HashSetOfSimpleInterface7 = value; - break; - case (8): - HashSetOfSimpleInterface8 = value; - break; - case (9): - HashSetOfString9 = value; - break; - case (10): - HashSetOfString10 = value; - break; - case (11): - HashSetOfString11 = value; - break; - case (12): - HashSetOfDate12 = value; - break; - case (13): - HashSetOfDate13 = value; - break; - case (14): - HashSetOfDate14 = value; - break; - case (15): - HashSetOfLocale15 = value; - break; - case (16): - HashSetOfLocale16 = value; - break; - case (17): - HashSetOfLocale17 = value; - break; - case (18): - HashSetOfBigDecimal18 = value; - break; - case (19): - HashSetOfBigDecimal19 = value; - break; - case (20): - HashSetOfBigDecimal20 = value; - break; - case (21): - HashSetOfBigInteger21 = value; - break; - case (22): - HashSetOfBigInteger22 = value; - break; - case (23): - HashSetOfBigInteger23 = value; - break; - case (24): - HashSetOfByte24 = value; - break; - case (25): - HashSetOfByte25 = value; - break; - case (26): - HashSetOfByte26 = value; - break; - case (27): - HashSetOfDouble27 = value; - break; - case (28): - HashSetOfDouble28 = value; - break; - case (29): - HashSetOfDouble29 = value; - break; - case (30): - HashSetOfFloat30 = value; - break; - case (31): - HashSetOfFloat31 = value; - break; - case (32): - HashSetOfFloat32 = value; - break; - case (33): - HashSetOfInteger33 = value; - break; - case (34): - HashSetOfInteger34 = value; - break; - case (35): - HashSetOfInteger35 = value; - break; - case (36): - HashSetOfLong36 = value; - break; - case (37): - HashSetOfLong37 = value; - break; - case (38): - HashSetOfLong38 = value; - break; - case (39): - HashSetOfShort39 = value; - break; - case (40): - HashSetOfShort40 = value; - break; - case (41): - HashSetOfShort41 = value; - break; - case (42): - HashSetOfSimpleClass42 = value; - break; + public boolean set(int index,HashSet value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + HashSetOfObject0= value; + break; + case(1): + HashSetOfObject1= value; + break; + case(2): + HashSetOfObject2= value; + break; + case(3): + HashSetOfSimpleClass3= value; + break; + case(4): + HashSetOfSimpleClass4= value; + break; + case(5): + HashSetOfSimpleClass5= value; + break; + case(6): + HashSetOfSimpleInterface6= value; + break; + case(7): + HashSetOfSimpleInterface7= value; + break; + case(8): + HashSetOfSimpleInterface8= value; + break; + case(9): + HashSetOfString9= value; + break; + case(10): + HashSetOfString10= value; + break; + case(11): + HashSetOfString11= value; + break; + case(12): + HashSetOfDate12= value; + break; + case(13): + HashSetOfDate13= value; + break; + case(14): + HashSetOfDate14= value; + break; + case(15): + HashSetOfLocale15= value; + break; + case(16): + HashSetOfLocale16= value; + break; + case(17): + HashSetOfLocale17= value; + break; + case(18): + HashSetOfBigDecimal18= value; + break; + case(19): + HashSetOfBigDecimal19= value; + break; + case(20): + HashSetOfBigDecimal20= value; + break; + case(21): + HashSetOfBigInteger21= value; + break; + case(22): + HashSetOfBigInteger22= value; + break; + case(23): + HashSetOfBigInteger23= value; + break; + case(24): + HashSetOfByte24= value; + break; + case(25): + HashSetOfByte25= value; + break; + case(26): + HashSetOfByte26= value; + break; + case(27): + HashSetOfDouble27= value; + break; + case(28): + HashSetOfDouble28= value; + break; + case(29): + HashSetOfDouble29= value; + break; + case(30): + HashSetOfFloat30= value; + break; + case(31): + HashSetOfFloat31= value; + break; + case(32): + HashSetOfFloat32= value; + break; + case(33): + HashSetOfInteger33= value; + break; + case(34): + HashSetOfInteger34= value; + break; + case(35): + HashSetOfInteger35= value; + break; + case(36): + HashSetOfLong36= value; + break; + case(37): + HashSetOfLong37= value; + break; + case(38): + HashSetOfLong38= value; + break; + case(39): + HashSetOfShort39= value; + break; + case(40): + HashSetOfShort40= value; + break; + case(41): + HashSetOfShort41= value; + break; + case(42): + HashSetOfSimpleClass42= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/HashtableStringKeyCollections.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/HashtableStringKeyCollections.java index fa30bb67b..a611d4302 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/HashtableStringKeyCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/HashtableStringKeyCollections.java @@ -5,22 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; import java.util.Hashtable; -public class HashtableStringKeyCollections { +public class HashtableStringKeyCollections { public int identifier; public Hashtable HashtableOfString_Object0; public Hashtable HashtableOfString_Object1; @@ -121,644 +121,643 @@ public class HashtableStringKeyCollections { public Hashtable HashtableOfString_Short123; public Hashtable HashtableOfString_Short125; - public static final String[] fieldSpecs = { - "public Hashtable HashtableOfString_Object0", - "embedded-value=true public Hashtable HashtableOfString_Object1", - "embedded-value=false public Hashtable HashtableOfString_Object2", - "public Hashtable HashtableOfString_SimpleClass3", - "embedded-value=true public Hashtable HashtableOfString_SimpleClass4", - "embedded-value=false public Hashtable HashtableOfString_SimpleClass5", - "public Hashtable HashtableOfString_SimpleInterface6", - "embedded-value=true public Hashtable HashtableOfString_SimpleInterface7", - "embedded-value=false public Hashtable HashtableOfString_SimpleInterface8", - "public Hashtable HashtableOfString_String9", - "embedded-value=true public Hashtable HashtableOfString_String10", - "embedded-value=false public Hashtable HashtableOfString_String11", - "public Hashtable HashtableOfString_Date12", - "embedded-value=true public Hashtable HashtableOfString_Date13", - "embedded-value=false public Hashtable HashtableOfString_Date14", - "public Hashtable HashtableOfString_Locale15", - "embedded-value=true public Hashtable HashtableOfString_Locale16", - "embedded-value=false public Hashtable HashtableOfString_Locale17", - "public Hashtable HashtableOfString_BigDecimal18", - "embedded-value=true public Hashtable HashtableOfString_BigDecimal19", - "embedded-value=false public Hashtable HashtableOfString_BigDecimal20", - "public Hashtable HashtableOfString_BigInteger21", - "embedded-value=true public Hashtable HashtableOfString_BigInteger22", - "embedded-value=false public Hashtable HashtableOfString_BigInteger23", - "public Hashtable HashtableOfString_Byte24", - "embedded-value=true public Hashtable HashtableOfString_Byte25", - "embedded-value=false public Hashtable HashtableOfString_Byte26", - "public Hashtable HashtableOfString_Double27", - "embedded-value=true public Hashtable HashtableOfString_Double28", - "embedded-value=false public Hashtable HashtableOfString_Double29", - "public Hashtable HashtableOfString_Float30", - "embedded-value=true public Hashtable HashtableOfString_Float31", - "embedded-value=false public Hashtable HashtableOfString_Float32", - "public Hashtable HashtableOfString_Integer33", - "embedded-value=true public Hashtable HashtableOfString_Integer34", - "embedded-value=false public Hashtable HashtableOfString_Integer35", - "public Hashtable HashtableOfString_Long36", - "embedded-value=true public Hashtable HashtableOfString_Long37", - "embedded-value=false public Hashtable HashtableOfString_Long38", - "public Hashtable HashtableOfString_Short39", - "embedded-value=true public Hashtable HashtableOfString_Short40", - "embedded-value=false public Hashtable HashtableOfString_Short41", - "embedded-key=true public Hashtable HashtableOfString_Object42", - "embedded-key=true embedded-value=true public Hashtable HashtableOfString_Object43", - "embedded-key=true public Hashtable HashtableOfString_SimpleClass45", - "embedded-key=true embedded-value=true public Hashtable HashtableOfString_SimpleClass46", - "embedded-key=true public Hashtable HashtableOfString_SimpleInterface48", - "embedded-key=true embedded-value=true public Hashtable HashtableOfString_SimpleInterface49", - "embedded-key=true public Hashtable HashtableOfString_String51", - "embedded-key=true embedded-value=true public Hashtable HashtableOfString_String52", - "embedded-key=true public Hashtable HashtableOfString_Date54", - "embedded-key=true embedded-value=true public Hashtable HashtableOfString_Date55", - "embedded-key=true public Hashtable HashtableOfString_Locale57", - "embedded-key=true embedded-value=true public Hashtable HashtableOfString_Locale58", - "embedded-key=true public Hashtable HashtableOfString_BigDecimal60", - "embedded-key=true embedded-value=true public Hashtable HashtableOfString_BigDecimal61", - "embedded-key=true public Hashtable HashtableOfString_BigInteger63", - "embedded-key=true embedded-value=true public Hashtable HashtableOfString_BigInteger64", - "embedded-key=true public Hashtable HashtableOfString_Byte66", - "embedded-key=true embedded-value=true public Hashtable HashtableOfString_Byte67", - "embedded-key=true public Hashtable HashtableOfString_Double69", - "embedded-key=true embedded-value=true public Hashtable HashtableOfString_Double70", - "embedded-key=true public Hashtable HashtableOfString_Float72", - "embedded-key=true embedded-value=true public Hashtable HashtableOfString_Float73", - "embedded-key=true public Hashtable HashtableOfString_Integer75", - "embedded-key=true embedded-value=true public Hashtable HashtableOfString_Integer76", - "embedded-key=true public Hashtable HashtableOfString_Long78", - "embedded-key=true embedded-value=true public Hashtable HashtableOfString_Long79", - "embedded-key=true public Hashtable HashtableOfString_Short81", - "embedded-key=true embedded-value=true public Hashtable HashtableOfString_Short82", - "embedded-key=false public Hashtable HashtableOfString_Object84", - "embedded-key=false embedded-value=false public Hashtable HashtableOfString_Object86", - "embedded-key=false public Hashtable HashtableOfString_SimpleClass87", - "embedded-key=false embedded-value=false public Hashtable HashtableOfString_SimpleClass89", - "embedded-key=false public Hashtable HashtableOfString_SimpleInterface90", - "embedded-key=false embedded-value=false public Hashtable HashtableOfString_SimpleInterface92", - "embedded-key=false public Hashtable HashtableOfString_String93", - "embedded-key=false embedded-value=false public Hashtable HashtableOfString_String95", - "embedded-key=false public Hashtable HashtableOfString_Date96", - "embedded-key=false embedded-value=false public Hashtable HashtableOfString_Date98", - "embedded-key=false public Hashtable HashtableOfString_Locale99", - "embedded-key=false embedded-value=false public Hashtable HashtableOfString_Locale101", - "embedded-key=false public Hashtable HashtableOfString_BigDecimal102", - "embedded-key=false embedded-value=false public Hashtable HashtableOfString_BigDecimal104", - "embedded-key=false public Hashtable HashtableOfString_BigInteger105", - "embedded-key=false embedded-value=false public Hashtable HashtableOfString_BigInteger107", - "embedded-key=false public Hashtable HashtableOfString_Byte108", - "embedded-key=false embedded-value=false public Hashtable HashtableOfString_Byte110", - "embedded-key=false public Hashtable HashtableOfString_Double111", - "embedded-key=false embedded-value=false public Hashtable HashtableOfString_Double113", - "embedded-key=false public Hashtable HashtableOfString_Float114", - "embedded-key=false embedded-value=false public Hashtable HashtableOfString_Float116", - "embedded-key=false public Hashtable HashtableOfString_Integer117", - "embedded-key=false embedded-value=false public Hashtable HashtableOfString_Integer119", - "embedded-key=false public Hashtable HashtableOfString_Long120", - "embedded-key=false embedded-value=false public Hashtable HashtableOfString_Long122", - "embedded-key=false public Hashtable HashtableOfString_Short123", - "embedded-key=false embedded-value=false public Hashtable HashtableOfString_Short125" + public static final String [] fieldSpecs = { + "public Hashtable HashtableOfString_Object0", + "embedded-value=true public Hashtable HashtableOfString_Object1", + "embedded-value=false public Hashtable HashtableOfString_Object2", + "public Hashtable HashtableOfString_SimpleClass3", + "embedded-value=true public Hashtable HashtableOfString_SimpleClass4", + "embedded-value=false public Hashtable HashtableOfString_SimpleClass5", + "public Hashtable HashtableOfString_SimpleInterface6", + "embedded-value=true public Hashtable HashtableOfString_SimpleInterface7", + "embedded-value=false public Hashtable HashtableOfString_SimpleInterface8", + "public Hashtable HashtableOfString_String9", + "embedded-value=true public Hashtable HashtableOfString_String10", + "embedded-value=false public Hashtable HashtableOfString_String11", + "public Hashtable HashtableOfString_Date12", + "embedded-value=true public Hashtable HashtableOfString_Date13", + "embedded-value=false public Hashtable HashtableOfString_Date14", + "public Hashtable HashtableOfString_Locale15", + "embedded-value=true public Hashtable HashtableOfString_Locale16", + "embedded-value=false public Hashtable HashtableOfString_Locale17", + "public Hashtable HashtableOfString_BigDecimal18", + "embedded-value=true public Hashtable HashtableOfString_BigDecimal19", + "embedded-value=false public Hashtable HashtableOfString_BigDecimal20", + "public Hashtable HashtableOfString_BigInteger21", + "embedded-value=true public Hashtable HashtableOfString_BigInteger22", + "embedded-value=false public Hashtable HashtableOfString_BigInteger23", + "public Hashtable HashtableOfString_Byte24", + "embedded-value=true public Hashtable HashtableOfString_Byte25", + "embedded-value=false public Hashtable HashtableOfString_Byte26", + "public Hashtable HashtableOfString_Double27", + "embedded-value=true public Hashtable HashtableOfString_Double28", + "embedded-value=false public Hashtable HashtableOfString_Double29", + "public Hashtable HashtableOfString_Float30", + "embedded-value=true public Hashtable HashtableOfString_Float31", + "embedded-value=false public Hashtable HashtableOfString_Float32", + "public Hashtable HashtableOfString_Integer33", + "embedded-value=true public Hashtable HashtableOfString_Integer34", + "embedded-value=false public Hashtable HashtableOfString_Integer35", + "public Hashtable HashtableOfString_Long36", + "embedded-value=true public Hashtable HashtableOfString_Long37", + "embedded-value=false public Hashtable HashtableOfString_Long38", + "public Hashtable HashtableOfString_Short39", + "embedded-value=true public Hashtable HashtableOfString_Short40", + "embedded-value=false public Hashtable HashtableOfString_Short41", + "embedded-key=true public Hashtable HashtableOfString_Object42", + "embedded-key=true embedded-value=true public Hashtable HashtableOfString_Object43", + "embedded-key=true public Hashtable HashtableOfString_SimpleClass45", + "embedded-key=true embedded-value=true public Hashtable HashtableOfString_SimpleClass46", + "embedded-key=true public Hashtable HashtableOfString_SimpleInterface48", + "embedded-key=true embedded-value=true public Hashtable HashtableOfString_SimpleInterface49", + "embedded-key=true public Hashtable HashtableOfString_String51", + "embedded-key=true embedded-value=true public Hashtable HashtableOfString_String52", + "embedded-key=true public Hashtable HashtableOfString_Date54", + "embedded-key=true embedded-value=true public Hashtable HashtableOfString_Date55", + "embedded-key=true public Hashtable HashtableOfString_Locale57", + "embedded-key=true embedded-value=true public Hashtable HashtableOfString_Locale58", + "embedded-key=true public Hashtable HashtableOfString_BigDecimal60", + "embedded-key=true embedded-value=true public Hashtable HashtableOfString_BigDecimal61", + "embedded-key=true public Hashtable HashtableOfString_BigInteger63", + "embedded-key=true embedded-value=true public Hashtable HashtableOfString_BigInteger64", + "embedded-key=true public Hashtable HashtableOfString_Byte66", + "embedded-key=true embedded-value=true public Hashtable HashtableOfString_Byte67", + "embedded-key=true public Hashtable HashtableOfString_Double69", + "embedded-key=true embedded-value=true public Hashtable HashtableOfString_Double70", + "embedded-key=true public Hashtable HashtableOfString_Float72", + "embedded-key=true embedded-value=true public Hashtable HashtableOfString_Float73", + "embedded-key=true public Hashtable HashtableOfString_Integer75", + "embedded-key=true embedded-value=true public Hashtable HashtableOfString_Integer76", + "embedded-key=true public Hashtable HashtableOfString_Long78", + "embedded-key=true embedded-value=true public Hashtable HashtableOfString_Long79", + "embedded-key=true public Hashtable HashtableOfString_Short81", + "embedded-key=true embedded-value=true public Hashtable HashtableOfString_Short82", + "embedded-key=false public Hashtable HashtableOfString_Object84", + "embedded-key=false embedded-value=false public Hashtable HashtableOfString_Object86", + "embedded-key=false public Hashtable HashtableOfString_SimpleClass87", + "embedded-key=false embedded-value=false public Hashtable HashtableOfString_SimpleClass89", + "embedded-key=false public Hashtable HashtableOfString_SimpleInterface90", + "embedded-key=false embedded-value=false public Hashtable HashtableOfString_SimpleInterface92", + "embedded-key=false public Hashtable HashtableOfString_String93", + "embedded-key=false embedded-value=false public Hashtable HashtableOfString_String95", + "embedded-key=false public Hashtable HashtableOfString_Date96", + "embedded-key=false embedded-value=false public Hashtable HashtableOfString_Date98", + "embedded-key=false public Hashtable HashtableOfString_Locale99", + "embedded-key=false embedded-value=false public Hashtable HashtableOfString_Locale101", + "embedded-key=false public Hashtable HashtableOfString_BigDecimal102", + "embedded-key=false embedded-value=false public Hashtable HashtableOfString_BigDecimal104", + "embedded-key=false public Hashtable HashtableOfString_BigInteger105", + "embedded-key=false embedded-value=false public Hashtable HashtableOfString_BigInteger107", + "embedded-key=false public Hashtable HashtableOfString_Byte108", + "embedded-key=false embedded-value=false public Hashtable HashtableOfString_Byte110", + "embedded-key=false public Hashtable HashtableOfString_Double111", + "embedded-key=false embedded-value=false public Hashtable HashtableOfString_Double113", + "embedded-key=false public Hashtable HashtableOfString_Float114", + "embedded-key=false embedded-value=false public Hashtable HashtableOfString_Float116", + "embedded-key=false public Hashtable HashtableOfString_Integer117", + "embedded-key=false embedded-value=false public Hashtable HashtableOfString_Integer119", + "embedded-key=false public Hashtable HashtableOfString_Long120", + "embedded-key=false embedded-value=false public Hashtable HashtableOfString_Long122", + "embedded-key=false public Hashtable HashtableOfString_Short123", + "embedded-key=false embedded-value=false public Hashtable HashtableOfString_Short125" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public Hashtable get(int index) { - switch (index) { - case (0): + public Hashtable get(int index) + { + switch (index) + { + case(0): return HashtableOfString_Object0; - case (1): + case(1): return HashtableOfString_Object1; - case (2): + case(2): return HashtableOfString_Object2; - case (3): + case(3): return HashtableOfString_SimpleClass3; - case (4): + case(4): return HashtableOfString_SimpleClass4; - case (5): + case(5): return HashtableOfString_SimpleClass5; - case (6): + case(6): return HashtableOfString_SimpleInterface6; - case (7): + case(7): return HashtableOfString_SimpleInterface7; - case (8): + case(8): return HashtableOfString_SimpleInterface8; - case (9): + case(9): return HashtableOfString_String9; - case (10): + case(10): return HashtableOfString_String10; - case (11): + case(11): return HashtableOfString_String11; - case (12): + case(12): return HashtableOfString_Date12; - case (13): + case(13): return HashtableOfString_Date13; - case (14): + case(14): return HashtableOfString_Date14; - case (15): + case(15): return HashtableOfString_Locale15; - case (16): + case(16): return HashtableOfString_Locale16; - case (17): + case(17): return HashtableOfString_Locale17; - case (18): + case(18): return HashtableOfString_BigDecimal18; - case (19): + case(19): return HashtableOfString_BigDecimal19; - case (20): + case(20): return HashtableOfString_BigDecimal20; - case (21): + case(21): return HashtableOfString_BigInteger21; - case (22): + case(22): return HashtableOfString_BigInteger22; - case (23): + case(23): return HashtableOfString_BigInteger23; - case (24): + case(24): return HashtableOfString_Byte24; - case (25): + case(25): return HashtableOfString_Byte25; - case (26): + case(26): return HashtableOfString_Byte26; - case (27): + case(27): return HashtableOfString_Double27; - case (28): + case(28): return HashtableOfString_Double28; - case (29): + case(29): return HashtableOfString_Double29; - case (30): + case(30): return HashtableOfString_Float30; - case (31): + case(31): return HashtableOfString_Float31; - case (32): + case(32): return HashtableOfString_Float32; - case (33): + case(33): return HashtableOfString_Integer33; - case (34): + case(34): return HashtableOfString_Integer34; - case (35): + case(35): return HashtableOfString_Integer35; - case (36): + case(36): return HashtableOfString_Long36; - case (37): + case(37): return HashtableOfString_Long37; - case (38): + case(38): return HashtableOfString_Long38; - case (39): + case(39): return HashtableOfString_Short39; - case (40): + case(40): return HashtableOfString_Short40; - case (41): + case(41): return HashtableOfString_Short41; - case (42): + case(42): return HashtableOfString_Object42; - case (43): + case(43): return HashtableOfString_Object43; - case (44): + case(44): return HashtableOfString_SimpleClass45; - case (45): + case(45): return HashtableOfString_SimpleClass46; - case (46): + case(46): return HashtableOfString_SimpleInterface48; - case (47): + case(47): return HashtableOfString_SimpleInterface49; - case (48): + case(48): return HashtableOfString_String51; - case (49): + case(49): return HashtableOfString_String52; - case (50): + case(50): return HashtableOfString_Date54; - case (51): + case(51): return HashtableOfString_Date55; - case (52): + case(52): return HashtableOfString_Locale57; - case (53): + case(53): return HashtableOfString_Locale58; - case (54): + case(54): return HashtableOfString_BigDecimal60; - case (55): + case(55): return HashtableOfString_BigDecimal61; - case (56): + case(56): return HashtableOfString_BigInteger63; - case (57): + case(57): return HashtableOfString_BigInteger64; - case (58): + case(58): return HashtableOfString_Byte66; - case (59): + case(59): return HashtableOfString_Byte67; - case (60): + case(60): return HashtableOfString_Double69; - case (61): + case(61): return HashtableOfString_Double70; - case (62): + case(62): return HashtableOfString_Float72; - case (63): + case(63): return HashtableOfString_Float73; - case (64): + case(64): return HashtableOfString_Integer75; - case (65): + case(65): return HashtableOfString_Integer76; - case (66): + case(66): return HashtableOfString_Long78; - case (67): + case(67): return HashtableOfString_Long79; - case (68): + case(68): return HashtableOfString_Short81; - case (69): + case(69): return HashtableOfString_Short82; - case (70): + case(70): return HashtableOfString_Object84; - case (71): + case(71): return HashtableOfString_Object86; - case (72): + case(72): return HashtableOfString_SimpleClass87; - case (73): + case(73): return HashtableOfString_SimpleClass89; - case (74): + case(74): return HashtableOfString_SimpleInterface90; - case (75): + case(75): return HashtableOfString_SimpleInterface92; - case (76): + case(76): return HashtableOfString_String93; - case (77): + case(77): return HashtableOfString_String95; - case (78): + case(78): return HashtableOfString_Date96; - case (79): + case(79): return HashtableOfString_Date98; - case (80): + case(80): return HashtableOfString_Locale99; - case (81): + case(81): return HashtableOfString_Locale101; - case (82): + case(82): return HashtableOfString_BigDecimal102; - case (83): + case(83): return HashtableOfString_BigDecimal104; - case (84): + case(84): return HashtableOfString_BigInteger105; - case (85): + case(85): return HashtableOfString_BigInteger107; - case (86): + case(86): return HashtableOfString_Byte108; - case (87): + case(87): return HashtableOfString_Byte110; - case (88): + case(88): return HashtableOfString_Double111; - case (89): + case(89): return HashtableOfString_Double113; - case (90): + case(90): return HashtableOfString_Float114; - case (91): + case(91): return HashtableOfString_Float116; - case (92): + case(92): return HashtableOfString_Integer117; - case (93): + case(93): return HashtableOfString_Integer119; - case (94): + case(94): return HashtableOfString_Long120; - case (95): + case(95): return HashtableOfString_Long122; - case (96): + case(96): return HashtableOfString_Short123; - case (97): + case(97): return HashtableOfString_Short125; default: throw new IndexOutOfBoundsException("Bad index " + index); } } - - public boolean set(int index, Hashtable value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - HashtableOfString_Object0 = value; - break; - case (1): - HashtableOfString_Object1 = value; - break; - case (2): - HashtableOfString_Object2 = value; - break; - case (3): - HashtableOfString_SimpleClass3 = value; - break; - case (4): - HashtableOfString_SimpleClass4 = value; - break; - case (5): - HashtableOfString_SimpleClass5 = value; - break; - case (6): - HashtableOfString_SimpleInterface6 = value; - break; - case (7): - HashtableOfString_SimpleInterface7 = value; - break; - case (8): - HashtableOfString_SimpleInterface8 = value; - break; - case (9): - HashtableOfString_String9 = value; - break; - case (10): - HashtableOfString_String10 = value; - break; - case (11): - HashtableOfString_String11 = value; - break; - case (12): - HashtableOfString_Date12 = value; - break; - case (13): - HashtableOfString_Date13 = value; - break; - case (14): - HashtableOfString_Date14 = value; - break; - case (15): - HashtableOfString_Locale15 = value; - break; - case (16): - HashtableOfString_Locale16 = value; - break; - case (17): - HashtableOfString_Locale17 = value; - break; - case (18): - HashtableOfString_BigDecimal18 = value; - break; - case (19): - HashtableOfString_BigDecimal19 = value; - break; - case (20): - HashtableOfString_BigDecimal20 = value; - break; - case (21): - HashtableOfString_BigInteger21 = value; - break; - case (22): - HashtableOfString_BigInteger22 = value; - break; - case (23): - HashtableOfString_BigInteger23 = value; - break; - case (24): - HashtableOfString_Byte24 = value; - break; - case (25): - HashtableOfString_Byte25 = value; - break; - case (26): - HashtableOfString_Byte26 = value; - break; - case (27): - HashtableOfString_Double27 = value; - break; - case (28): - HashtableOfString_Double28 = value; - break; - case (29): - HashtableOfString_Double29 = value; - break; - case (30): - HashtableOfString_Float30 = value; - break; - case (31): - HashtableOfString_Float31 = value; - break; - case (32): - HashtableOfString_Float32 = value; - break; - case (33): - HashtableOfString_Integer33 = value; - break; - case (34): - HashtableOfString_Integer34 = value; - break; - case (35): - HashtableOfString_Integer35 = value; - break; - case (36): - HashtableOfString_Long36 = value; - break; - case (37): - HashtableOfString_Long37 = value; - break; - case (38): - HashtableOfString_Long38 = value; - break; - case (39): - HashtableOfString_Short39 = value; - break; - case (40): - HashtableOfString_Short40 = value; - break; - case (41): - HashtableOfString_Short41 = value; - break; - case (42): - HashtableOfString_Object42 = value; - break; - case (43): - HashtableOfString_Object43 = value; - break; - case (44): - HashtableOfString_SimpleClass45 = value; - break; - case (45): - HashtableOfString_SimpleClass46 = value; - break; - case (46): - HashtableOfString_SimpleInterface48 = value; - break; - case (47): - HashtableOfString_SimpleInterface49 = value; - break; - case (48): - HashtableOfString_String51 = value; - break; - case (49): - HashtableOfString_String52 = value; - break; - case (50): - HashtableOfString_Date54 = value; - break; - case (51): - HashtableOfString_Date55 = value; - break; - case (52): - HashtableOfString_Locale57 = value; - break; - case (53): - HashtableOfString_Locale58 = value; - break; - case (54): - HashtableOfString_BigDecimal60 = value; - break; - case (55): - HashtableOfString_BigDecimal61 = value; - break; - case (56): - HashtableOfString_BigInteger63 = value; - break; - case (57): - HashtableOfString_BigInteger64 = value; - break; - case (58): - HashtableOfString_Byte66 = value; - break; - case (59): - HashtableOfString_Byte67 = value; - break; - case (60): - HashtableOfString_Double69 = value; - break; - case (61): - HashtableOfString_Double70 = value; - break; - case (62): - HashtableOfString_Float72 = value; - break; - case (63): - HashtableOfString_Float73 = value; - break; - case (64): - HashtableOfString_Integer75 = value; - break; - case (65): - HashtableOfString_Integer76 = value; - break; - case (66): - HashtableOfString_Long78 = value; - break; - case (67): - HashtableOfString_Long79 = value; - break; - case (68): - HashtableOfString_Short81 = value; - break; - case (69): - HashtableOfString_Short82 = value; - break; - case (70): - HashtableOfString_Object84 = value; - break; - case (71): - HashtableOfString_Object86 = value; - break; - case (72): - HashtableOfString_SimpleClass87 = value; - break; - case (73): - HashtableOfString_SimpleClass89 = value; - break; - case (74): - HashtableOfString_SimpleInterface90 = value; - break; - case (75): - HashtableOfString_SimpleInterface92 = value; - break; - case (76): - HashtableOfString_String93 = value; - break; - case (77): - HashtableOfString_String95 = value; - break; - case (78): - HashtableOfString_Date96 = value; - break; - case (79): - HashtableOfString_Date98 = value; - break; - case (80): - HashtableOfString_Locale99 = value; - break; - case (81): - HashtableOfString_Locale101 = value; - break; - case (82): - HashtableOfString_BigDecimal102 = value; - break; - case (83): - HashtableOfString_BigDecimal104 = value; - break; - case (84): - HashtableOfString_BigInteger105 = value; - break; - case (85): - HashtableOfString_BigInteger107 = value; - break; - case (86): - HashtableOfString_Byte108 = value; - break; - case (87): - HashtableOfString_Byte110 = value; - break; - case (88): - HashtableOfString_Double111 = value; - break; - case (89): - HashtableOfString_Double113 = value; - break; - case (90): - HashtableOfString_Float114 = value; - break; - case (91): - HashtableOfString_Float116 = value; - break; - case (92): - HashtableOfString_Integer117 = value; - break; - case (93): - HashtableOfString_Integer119 = value; - break; - case (94): - HashtableOfString_Long120 = value; - break; - case (95): - HashtableOfString_Long122 = value; - break; - case (96): - HashtableOfString_Short123 = value; - break; - case (97): - HashtableOfString_Short125 = value; - break; + public boolean set(int index,Hashtable value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + HashtableOfString_Object0= value; + break; + case(1): + HashtableOfString_Object1= value; + break; + case(2): + HashtableOfString_Object2= value; + break; + case(3): + HashtableOfString_SimpleClass3= value; + break; + case(4): + HashtableOfString_SimpleClass4= value; + break; + case(5): + HashtableOfString_SimpleClass5= value; + break; + case(6): + HashtableOfString_SimpleInterface6= value; + break; + case(7): + HashtableOfString_SimpleInterface7= value; + break; + case(8): + HashtableOfString_SimpleInterface8= value; + break; + case(9): + HashtableOfString_String9= value; + break; + case(10): + HashtableOfString_String10= value; + break; + case(11): + HashtableOfString_String11= value; + break; + case(12): + HashtableOfString_Date12= value; + break; + case(13): + HashtableOfString_Date13= value; + break; + case(14): + HashtableOfString_Date14= value; + break; + case(15): + HashtableOfString_Locale15= value; + break; + case(16): + HashtableOfString_Locale16= value; + break; + case(17): + HashtableOfString_Locale17= value; + break; + case(18): + HashtableOfString_BigDecimal18= value; + break; + case(19): + HashtableOfString_BigDecimal19= value; + break; + case(20): + HashtableOfString_BigDecimal20= value; + break; + case(21): + HashtableOfString_BigInteger21= value; + break; + case(22): + HashtableOfString_BigInteger22= value; + break; + case(23): + HashtableOfString_BigInteger23= value; + break; + case(24): + HashtableOfString_Byte24= value; + break; + case(25): + HashtableOfString_Byte25= value; + break; + case(26): + HashtableOfString_Byte26= value; + break; + case(27): + HashtableOfString_Double27= value; + break; + case(28): + HashtableOfString_Double28= value; + break; + case(29): + HashtableOfString_Double29= value; + break; + case(30): + HashtableOfString_Float30= value; + break; + case(31): + HashtableOfString_Float31= value; + break; + case(32): + HashtableOfString_Float32= value; + break; + case(33): + HashtableOfString_Integer33= value; + break; + case(34): + HashtableOfString_Integer34= value; + break; + case(35): + HashtableOfString_Integer35= value; + break; + case(36): + HashtableOfString_Long36= value; + break; + case(37): + HashtableOfString_Long37= value; + break; + case(38): + HashtableOfString_Long38= value; + break; + case(39): + HashtableOfString_Short39= value; + break; + case(40): + HashtableOfString_Short40= value; + break; + case(41): + HashtableOfString_Short41= value; + break; + case(42): + HashtableOfString_Object42= value; + break; + case(43): + HashtableOfString_Object43= value; + break; + case(44): + HashtableOfString_SimpleClass45= value; + break; + case(45): + HashtableOfString_SimpleClass46= value; + break; + case(46): + HashtableOfString_SimpleInterface48= value; + break; + case(47): + HashtableOfString_SimpleInterface49= value; + break; + case(48): + HashtableOfString_String51= value; + break; + case(49): + HashtableOfString_String52= value; + break; + case(50): + HashtableOfString_Date54= value; + break; + case(51): + HashtableOfString_Date55= value; + break; + case(52): + HashtableOfString_Locale57= value; + break; + case(53): + HashtableOfString_Locale58= value; + break; + case(54): + HashtableOfString_BigDecimal60= value; + break; + case(55): + HashtableOfString_BigDecimal61= value; + break; + case(56): + HashtableOfString_BigInteger63= value; + break; + case(57): + HashtableOfString_BigInteger64= value; + break; + case(58): + HashtableOfString_Byte66= value; + break; + case(59): + HashtableOfString_Byte67= value; + break; + case(60): + HashtableOfString_Double69= value; + break; + case(61): + HashtableOfString_Double70= value; + break; + case(62): + HashtableOfString_Float72= value; + break; + case(63): + HashtableOfString_Float73= value; + break; + case(64): + HashtableOfString_Integer75= value; + break; + case(65): + HashtableOfString_Integer76= value; + break; + case(66): + HashtableOfString_Long78= value; + break; + case(67): + HashtableOfString_Long79= value; + break; + case(68): + HashtableOfString_Short81= value; + break; + case(69): + HashtableOfString_Short82= value; + break; + case(70): + HashtableOfString_Object84= value; + break; + case(71): + HashtableOfString_Object86= value; + break; + case(72): + HashtableOfString_SimpleClass87= value; + break; + case(73): + HashtableOfString_SimpleClass89= value; + break; + case(74): + HashtableOfString_SimpleInterface90= value; + break; + case(75): + HashtableOfString_SimpleInterface92= value; + break; + case(76): + HashtableOfString_String93= value; + break; + case(77): + HashtableOfString_String95= value; + break; + case(78): + HashtableOfString_Date96= value; + break; + case(79): + HashtableOfString_Date98= value; + break; + case(80): + HashtableOfString_Locale99= value; + break; + case(81): + HashtableOfString_Locale101= value; + break; + case(82): + HashtableOfString_BigDecimal102= value; + break; + case(83): + HashtableOfString_BigDecimal104= value; + break; + case(84): + HashtableOfString_BigInteger105= value; + break; + case(85): + HashtableOfString_BigInteger107= value; + break; + case(86): + HashtableOfString_Byte108= value; + break; + case(87): + HashtableOfString_Byte110= value; + break; + case(88): + HashtableOfString_Double111= value; + break; + case(89): + HashtableOfString_Double113= value; + break; + case(90): + HashtableOfString_Float114= value; + break; + case(91): + HashtableOfString_Float116= value; + break; + case(92): + HashtableOfString_Integer117= value; + break; + case(93): + HashtableOfString_Integer119= value; + break; + case(94): + HashtableOfString_Long120= value; + break; + case(95): + HashtableOfString_Long122= value; + break; + case(96): + HashtableOfString_Short123= value; + break; + case(97): + HashtableOfString_Short125= value; + break; default: throw new IndexOutOfBoundsException("Bad index " + index); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/HashtableStringValueCollections.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/HashtableStringValueCollections.java index d872e418f..7be3c2ec4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/HashtableStringValueCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/HashtableStringValueCollections.java @@ -5,22 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; import java.util.Hashtable; -public class HashtableStringValueCollections { +public class HashtableStringValueCollections { public int identifier; public Hashtable HashtableOfObject_String0; public Hashtable HashtableOfObject_String1; @@ -114,602 +114,601 @@ public class HashtableStringValueCollections { public Hashtable HashtableOfShort_String114; public Hashtable HashtableOfShort_String116; - public static final String[] fieldSpecs = { - "public Hashtable HashtableOfObject_String0", - "embedded-value=true public Hashtable HashtableOfObject_String1", - "embedded-value=false public Hashtable HashtableOfObject_String2", - "embedded-key=true public Hashtable HashtableOfObject_String3", - "embedded-key=true embedded-value=true public Hashtable HashtableOfObject_String4", - "embedded-key=false public Hashtable HashtableOfObject_String6", - "embedded-key=false embedded-value=false public Hashtable HashtableOfObject_String8", - "public Hashtable HashtableOfSimpleClass_String9", - "embedded-value=true public Hashtable HashtableOfSimpleClass_String10", - "embedded-value=false public Hashtable HashtableOfSimpleClass_String11", - "embedded-key=true public Hashtable HashtableOfSimpleClass_String12", - "embedded-key=true embedded-value=true public Hashtable HashtableOfSimpleClass_String13", - "embedded-key=false public Hashtable HashtableOfSimpleClass_String15", - "embedded-key=false embedded-value=false public Hashtable HashtableOfSimpleClass_String17", - "public Hashtable HashtableOfSimpleInterface_String18", - "embedded-value=true public Hashtable HashtableOfSimpleInterface_String19", - "embedded-value=false public Hashtable HashtableOfSimpleInterface_String20", - "embedded-key=true public Hashtable HashtableOfSimpleInterface_String21", - "embedded-key=true embedded-value=true public Hashtable HashtableOfSimpleInterface_String22", - "embedded-key=false public Hashtable HashtableOfSimpleInterface_String24", - "embedded-key=false embedded-value=false public Hashtable HashtableOfSimpleInterface_String26", - "public Hashtable HashtableOfString_String27", - "embedded-value=true public Hashtable HashtableOfString_String28", - "embedded-value=false public Hashtable HashtableOfString_String29", - "embedded-key=true public Hashtable HashtableOfString_String30", - "embedded-key=true embedded-value=true public Hashtable HashtableOfString_String31", - "embedded-key=false public Hashtable HashtableOfString_String33", - "embedded-key=false embedded-value=false public Hashtable HashtableOfString_String35", - "public Hashtable HashtableOfDate_String36", - "embedded-value=true public Hashtable HashtableOfDate_String37", - "embedded-value=false public Hashtable HashtableOfDate_String38", - "embedded-key=true public Hashtable HashtableOfDate_String39", - "embedded-key=true embedded-value=true public Hashtable HashtableOfDate_String40", - "embedded-key=false public Hashtable HashtableOfDate_String42", - "embedded-key=false embedded-value=false public Hashtable HashtableOfDate_String44", - "public Hashtable HashtableOfBigDecimal_String45", - "embedded-value=true public Hashtable HashtableOfBigDecimal_String46", - "embedded-value=false public Hashtable HashtableOfBigDecimal_String47", - "embedded-key=true public Hashtable HashtableOfBigDecimal_String48", - "embedded-key=true embedded-value=true public Hashtable HashtableOfBigDecimal_String49", - "embedded-key=false public Hashtable HashtableOfBigDecimal_String51", - "embedded-key=false embedded-value=false public Hashtable HashtableOfBigDecimal_String53", - "public Hashtable HashtableOfBigInteger_String54", - "embedded-value=true public Hashtable HashtableOfBigInteger_String55", - "embedded-value=false public Hashtable HashtableOfBigInteger_String56", - "embedded-key=true public Hashtable HashtableOfBigInteger_String57", - "embedded-key=true embedded-value=true public Hashtable HashtableOfBigInteger_String58", - "embedded-key=false public Hashtable HashtableOfBigInteger_String60", - "embedded-key=false embedded-value=false public Hashtable HashtableOfBigInteger_String62", - "public Hashtable HashtableOfByte_String63", - "embedded-value=true public Hashtable HashtableOfByte_String64", - "embedded-value=false public Hashtable HashtableOfByte_String65", - "embedded-key=true public Hashtable HashtableOfByte_String66", - "embedded-key=true embedded-value=true public Hashtable HashtableOfByte_String67", - "embedded-key=false public Hashtable HashtableOfByte_String69", - "embedded-key=false embedded-value=false public Hashtable HashtableOfByte_String71", - "public Hashtable HashtableOfDouble_String72", - "embedded-value=true public Hashtable HashtableOfDouble_String73", - "embedded-value=false public Hashtable HashtableOfDouble_String74", - "embedded-key=true public Hashtable HashtableOfDouble_String75", - "embedded-key=true embedded-value=true public Hashtable HashtableOfDouble_String76", - "embedded-key=false public Hashtable HashtableOfDouble_String78", - "embedded-key=false embedded-value=false public Hashtable HashtableOfDouble_String80", - "public Hashtable HashtableOfFloat_String81", - "embedded-value=true public Hashtable HashtableOfFloat_String82", - "embedded-value=false public Hashtable HashtableOfFloat_String83", - "embedded-key=true public Hashtable HashtableOfFloat_String84", - "embedded-key=true embedded-value=true public Hashtable HashtableOfFloat_String85", - "embedded-key=false public Hashtable HashtableOfFloat_String87", - "embedded-key=false embedded-value=false public Hashtable HashtableOfFloat_String89", - "public Hashtable HashtableOfInteger_String90", - "embedded-value=true public Hashtable HashtableOfInteger_String91", - "embedded-value=false public Hashtable HashtableOfInteger_String92", - "embedded-key=true public Hashtable HashtableOfInteger_String93", - "embedded-key=true embedded-value=true public Hashtable HashtableOfInteger_String94", - "embedded-key=false public Hashtable HashtableOfInteger_String96", - "embedded-key=false embedded-value=false public Hashtable HashtableOfInteger_String98", - "public Hashtable HashtableOfLong_String99", - "embedded-value=true public Hashtable HashtableOfLong_String100", - "embedded-value=false public Hashtable HashtableOfLong_String101", - "embedded-key=true public Hashtable HashtableOfLong_String102", - "embedded-key=true embedded-value=true public Hashtable HashtableOfLong_String103", - "embedded-key=false public Hashtable HashtableOfLong_String105", - "embedded-key=false embedded-value=false public Hashtable HashtableOfLong_String107", - "public Hashtable HashtableOfShort_String108", - "embedded-value=true public Hashtable HashtableOfShort_String109", - "embedded-value=false public Hashtable HashtableOfShort_String110", - "embedded-key=true public Hashtable HashtableOfShort_String111", - "embedded-key=true embedded-value=true public Hashtable HashtableOfShort_String112", - "embedded-key=false public Hashtable HashtableOfShort_String114", - "embedded-key=false embedded-value=false public Hashtable HashtableOfShort_String116" + public static final String [] fieldSpecs = { + "public Hashtable HashtableOfObject_String0", + "embedded-value=true public Hashtable HashtableOfObject_String1", + "embedded-value=false public Hashtable HashtableOfObject_String2", + "embedded-key=true public Hashtable HashtableOfObject_String3", + "embedded-key=true embedded-value=true public Hashtable HashtableOfObject_String4", + "embedded-key=false public Hashtable HashtableOfObject_String6", + "embedded-key=false embedded-value=false public Hashtable HashtableOfObject_String8", + "public Hashtable HashtableOfSimpleClass_String9", + "embedded-value=true public Hashtable HashtableOfSimpleClass_String10", + "embedded-value=false public Hashtable HashtableOfSimpleClass_String11", + "embedded-key=true public Hashtable HashtableOfSimpleClass_String12", + "embedded-key=true embedded-value=true public Hashtable HashtableOfSimpleClass_String13", + "embedded-key=false public Hashtable HashtableOfSimpleClass_String15", + "embedded-key=false embedded-value=false public Hashtable HashtableOfSimpleClass_String17", + "public Hashtable HashtableOfSimpleInterface_String18", + "embedded-value=true public Hashtable HashtableOfSimpleInterface_String19", + "embedded-value=false public Hashtable HashtableOfSimpleInterface_String20", + "embedded-key=true public Hashtable HashtableOfSimpleInterface_String21", + "embedded-key=true embedded-value=true public Hashtable HashtableOfSimpleInterface_String22", + "embedded-key=false public Hashtable HashtableOfSimpleInterface_String24", + "embedded-key=false embedded-value=false public Hashtable HashtableOfSimpleInterface_String26", + "public Hashtable HashtableOfString_String27", + "embedded-value=true public Hashtable HashtableOfString_String28", + "embedded-value=false public Hashtable HashtableOfString_String29", + "embedded-key=true public Hashtable HashtableOfString_String30", + "embedded-key=true embedded-value=true public Hashtable HashtableOfString_String31", + "embedded-key=false public Hashtable HashtableOfString_String33", + "embedded-key=false embedded-value=false public Hashtable HashtableOfString_String35", + "public Hashtable HashtableOfDate_String36", + "embedded-value=true public Hashtable HashtableOfDate_String37", + "embedded-value=false public Hashtable HashtableOfDate_String38", + "embedded-key=true public Hashtable HashtableOfDate_String39", + "embedded-key=true embedded-value=true public Hashtable HashtableOfDate_String40", + "embedded-key=false public Hashtable HashtableOfDate_String42", + "embedded-key=false embedded-value=false public Hashtable HashtableOfDate_String44", + "public Hashtable HashtableOfBigDecimal_String45", + "embedded-value=true public Hashtable HashtableOfBigDecimal_String46", + "embedded-value=false public Hashtable HashtableOfBigDecimal_String47", + "embedded-key=true public Hashtable HashtableOfBigDecimal_String48", + "embedded-key=true embedded-value=true public Hashtable HashtableOfBigDecimal_String49", + "embedded-key=false public Hashtable HashtableOfBigDecimal_String51", + "embedded-key=false embedded-value=false public Hashtable HashtableOfBigDecimal_String53", + "public Hashtable HashtableOfBigInteger_String54", + "embedded-value=true public Hashtable HashtableOfBigInteger_String55", + "embedded-value=false public Hashtable HashtableOfBigInteger_String56", + "embedded-key=true public Hashtable HashtableOfBigInteger_String57", + "embedded-key=true embedded-value=true public Hashtable HashtableOfBigInteger_String58", + "embedded-key=false public Hashtable HashtableOfBigInteger_String60", + "embedded-key=false embedded-value=false public Hashtable HashtableOfBigInteger_String62", + "public Hashtable HashtableOfByte_String63", + "embedded-value=true public Hashtable HashtableOfByte_String64", + "embedded-value=false public Hashtable HashtableOfByte_String65", + "embedded-key=true public Hashtable HashtableOfByte_String66", + "embedded-key=true embedded-value=true public Hashtable HashtableOfByte_String67", + "embedded-key=false public Hashtable HashtableOfByte_String69", + "embedded-key=false embedded-value=false public Hashtable HashtableOfByte_String71", + "public Hashtable HashtableOfDouble_String72", + "embedded-value=true public Hashtable HashtableOfDouble_String73", + "embedded-value=false public Hashtable HashtableOfDouble_String74", + "embedded-key=true public Hashtable HashtableOfDouble_String75", + "embedded-key=true embedded-value=true public Hashtable HashtableOfDouble_String76", + "embedded-key=false public Hashtable HashtableOfDouble_String78", + "embedded-key=false embedded-value=false public Hashtable HashtableOfDouble_String80", + "public Hashtable HashtableOfFloat_String81", + "embedded-value=true public Hashtable HashtableOfFloat_String82", + "embedded-value=false public Hashtable HashtableOfFloat_String83", + "embedded-key=true public Hashtable HashtableOfFloat_String84", + "embedded-key=true embedded-value=true public Hashtable HashtableOfFloat_String85", + "embedded-key=false public Hashtable HashtableOfFloat_String87", + "embedded-key=false embedded-value=false public Hashtable HashtableOfFloat_String89", + "public Hashtable HashtableOfInteger_String90", + "embedded-value=true public Hashtable HashtableOfInteger_String91", + "embedded-value=false public Hashtable HashtableOfInteger_String92", + "embedded-key=true public Hashtable HashtableOfInteger_String93", + "embedded-key=true embedded-value=true public Hashtable HashtableOfInteger_String94", + "embedded-key=false public Hashtable HashtableOfInteger_String96", + "embedded-key=false embedded-value=false public Hashtable HashtableOfInteger_String98", + "public Hashtable HashtableOfLong_String99", + "embedded-value=true public Hashtable HashtableOfLong_String100", + "embedded-value=false public Hashtable HashtableOfLong_String101", + "embedded-key=true public Hashtable HashtableOfLong_String102", + "embedded-key=true embedded-value=true public Hashtable HashtableOfLong_String103", + "embedded-key=false public Hashtable HashtableOfLong_String105", + "embedded-key=false embedded-value=false public Hashtable HashtableOfLong_String107", + "public Hashtable HashtableOfShort_String108", + "embedded-value=true public Hashtable HashtableOfShort_String109", + "embedded-value=false public Hashtable HashtableOfShort_String110", + "embedded-key=true public Hashtable HashtableOfShort_String111", + "embedded-key=true embedded-value=true public Hashtable HashtableOfShort_String112", + "embedded-key=false public Hashtable HashtableOfShort_String114", + "embedded-key=false embedded-value=false public Hashtable HashtableOfShort_String116" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public Hashtable get(int index) { - switch (index) { - case (0): + public Hashtable get(int index) + { + switch (index) + { + case(0): return HashtableOfObject_String0; - case (1): + case(1): return HashtableOfObject_String1; - case (2): + case(2): return HashtableOfObject_String2; - case (3): + case(3): return HashtableOfObject_String3; - case (4): + case(4): return HashtableOfObject_String4; - case (5): + case(5): return HashtableOfObject_String6; - case (6): + case(6): return HashtableOfObject_String8; - case (7): + case(7): return HashtableOfSimpleClass_String9; - case (8): + case(8): return HashtableOfSimpleClass_String10; - case (9): + case(9): return HashtableOfSimpleClass_String11; - case (10): + case(10): return HashtableOfSimpleClass_String12; - case (11): + case(11): return HashtableOfSimpleClass_String13; - case (12): + case(12): return HashtableOfSimpleClass_String15; - case (13): + case(13): return HashtableOfSimpleClass_String17; - case (14): + case(14): return HashtableOfSimpleInterface_String18; - case (15): + case(15): return HashtableOfSimpleInterface_String19; - case (16): + case(16): return HashtableOfSimpleInterface_String20; - case (17): + case(17): return HashtableOfSimpleInterface_String21; - case (18): + case(18): return HashtableOfSimpleInterface_String22; - case (19): + case(19): return HashtableOfSimpleInterface_String24; - case (20): + case(20): return HashtableOfSimpleInterface_String26; - case (21): + case(21): return HashtableOfString_String27; - case (22): + case(22): return HashtableOfString_String28; - case (23): + case(23): return HashtableOfString_String29; - case (24): + case(24): return HashtableOfString_String30; - case (25): + case(25): return HashtableOfString_String31; - case (26): + case(26): return HashtableOfString_String33; - case (27): + case(27): return HashtableOfString_String35; - case (28): + case(28): return HashtableOfDate_String36; - case (29): + case(29): return HashtableOfDate_String37; - case (30): + case(30): return HashtableOfDate_String38; - case (31): + case(31): return HashtableOfDate_String39; - case (32): + case(32): return HashtableOfDate_String40; - case (33): + case(33): return HashtableOfDate_String42; - case (34): + case(34): return HashtableOfDate_String44; - case (35): + case(35): return HashtableOfBigDecimal_String45; - case (36): + case(36): return HashtableOfBigDecimal_String46; - case (37): + case(37): return HashtableOfBigDecimal_String47; - case (38): + case(38): return HashtableOfBigDecimal_String48; - case (39): + case(39): return HashtableOfBigDecimal_String49; - case (40): + case(40): return HashtableOfBigDecimal_String51; - case (41): + case(41): return HashtableOfBigDecimal_String53; - case (42): + case(42): return HashtableOfBigInteger_String54; - case (43): + case(43): return HashtableOfBigInteger_String55; - case (44): + case(44): return HashtableOfBigInteger_String56; - case (45): + case(45): return HashtableOfBigInteger_String57; - case (46): + case(46): return HashtableOfBigInteger_String58; - case (47): + case(47): return HashtableOfBigInteger_String60; - case (48): + case(48): return HashtableOfBigInteger_String62; - case (49): + case(49): return HashtableOfByte_String63; - case (50): + case(50): return HashtableOfByte_String64; - case (51): + case(51): return HashtableOfByte_String65; - case (52): + case(52): return HashtableOfByte_String66; - case (53): + case(53): return HashtableOfByte_String67; - case (54): + case(54): return HashtableOfByte_String69; - case (55): + case(55): return HashtableOfByte_String71; - case (56): + case(56): return HashtableOfDouble_String72; - case (57): + case(57): return HashtableOfDouble_String73; - case (58): + case(58): return HashtableOfDouble_String74; - case (59): + case(59): return HashtableOfDouble_String75; - case (60): + case(60): return HashtableOfDouble_String76; - case (61): + case(61): return HashtableOfDouble_String78; - case (62): + case(62): return HashtableOfDouble_String80; - case (63): + case(63): return HashtableOfFloat_String81; - case (64): + case(64): return HashtableOfFloat_String82; - case (65): + case(65): return HashtableOfFloat_String83; - case (66): + case(66): return HashtableOfFloat_String84; - case (67): + case(67): return HashtableOfFloat_String85; - case (68): + case(68): return HashtableOfFloat_String87; - case (69): + case(69): return HashtableOfFloat_String89; - case (70): + case(70): return HashtableOfInteger_String90; - case (71): + case(71): return HashtableOfInteger_String91; - case (72): + case(72): return HashtableOfInteger_String92; - case (73): + case(73): return HashtableOfInteger_String93; - case (74): + case(74): return HashtableOfInteger_String94; - case (75): + case(75): return HashtableOfInteger_String96; - case (76): + case(76): return HashtableOfInteger_String98; - case (77): + case(77): return HashtableOfLong_String99; - case (78): + case(78): return HashtableOfLong_String100; - case (79): + case(79): return HashtableOfLong_String101; - case (80): + case(80): return HashtableOfLong_String102; - case (81): + case(81): return HashtableOfLong_String103; - case (82): + case(82): return HashtableOfLong_String105; - case (83): + case(83): return HashtableOfLong_String107; - case (84): + case(84): return HashtableOfShort_String108; - case (85): + case(85): return HashtableOfShort_String109; - case (86): + case(86): return HashtableOfShort_String110; - case (87): + case(87): return HashtableOfShort_String111; - case (88): + case(88): return HashtableOfShort_String112; - case (89): + case(89): return HashtableOfShort_String114; - case (90): + case(90): return HashtableOfShort_String116; default: throw new IndexOutOfBoundsException("Bad index " + index); } } - - public boolean set(int index, Hashtable value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - HashtableOfObject_String0 = value; - break; - case (1): - HashtableOfObject_String1 = value; - break; - case (2): - HashtableOfObject_String2 = value; - break; - case (3): - HashtableOfObject_String3 = value; - break; - case (4): - HashtableOfObject_String4 = value; - break; - case (5): - HashtableOfObject_String6 = value; - break; - case (6): - HashtableOfObject_String8 = value; - break; - case (7): - HashtableOfSimpleClass_String9 = value; - break; - case (8): - HashtableOfSimpleClass_String10 = value; - break; - case (9): - HashtableOfSimpleClass_String11 = value; - break; - case (10): - HashtableOfSimpleClass_String12 = value; - break; - case (11): - HashtableOfSimpleClass_String13 = value; - break; - case (12): - HashtableOfSimpleClass_String15 = value; - break; - case (13): - HashtableOfSimpleClass_String17 = value; - break; - case (14): - HashtableOfSimpleInterface_String18 = value; - break; - case (15): - HashtableOfSimpleInterface_String19 = value; - break; - case (16): - HashtableOfSimpleInterface_String20 = value; - break; - case (17): - HashtableOfSimpleInterface_String21 = value; - break; - case (18): - HashtableOfSimpleInterface_String22 = value; - break; - case (19): - HashtableOfSimpleInterface_String24 = value; - break; - case (20): - HashtableOfSimpleInterface_String26 = value; - break; - case (21): - HashtableOfString_String27 = value; - break; - case (22): - HashtableOfString_String28 = value; - break; - case (23): - HashtableOfString_String29 = value; - break; - case (24): - HashtableOfString_String30 = value; - break; - case (25): - HashtableOfString_String31 = value; - break; - case (26): - HashtableOfString_String33 = value; - break; - case (27): - HashtableOfString_String35 = value; - break; - case (28): - HashtableOfDate_String36 = value; - break; - case (29): - HashtableOfDate_String37 = value; - break; - case (30): - HashtableOfDate_String38 = value; - break; - case (31): - HashtableOfDate_String39 = value; - break; - case (32): - HashtableOfDate_String40 = value; - break; - case (33): - HashtableOfDate_String42 = value; - break; - case (34): - HashtableOfDate_String44 = value; - break; - case (35): - HashtableOfBigDecimal_String45 = value; - break; - case (36): - HashtableOfBigDecimal_String46 = value; - break; - case (37): - HashtableOfBigDecimal_String47 = value; - break; - case (38): - HashtableOfBigDecimal_String48 = value; - break; - case (39): - HashtableOfBigDecimal_String49 = value; - break; - case (40): - HashtableOfBigDecimal_String51 = value; - break; - case (41): - HashtableOfBigDecimal_String53 = value; - break; - case (42): - HashtableOfBigInteger_String54 = value; - break; - case (43): - HashtableOfBigInteger_String55 = value; - break; - case (44): - HashtableOfBigInteger_String56 = value; - break; - case (45): - HashtableOfBigInteger_String57 = value; - break; - case (46): - HashtableOfBigInteger_String58 = value; - break; - case (47): - HashtableOfBigInteger_String60 = value; - break; - case (48): - HashtableOfBigInteger_String62 = value; - break; - case (49): - HashtableOfByte_String63 = value; - break; - case (50): - HashtableOfByte_String64 = value; - break; - case (51): - HashtableOfByte_String65 = value; - break; - case (52): - HashtableOfByte_String66 = value; - break; - case (53): - HashtableOfByte_String67 = value; - break; - case (54): - HashtableOfByte_String69 = value; - break; - case (55): - HashtableOfByte_String71 = value; - break; - case (56): - HashtableOfDouble_String72 = value; - break; - case (57): - HashtableOfDouble_String73 = value; - break; - case (58): - HashtableOfDouble_String74 = value; - break; - case (59): - HashtableOfDouble_String75 = value; - break; - case (60): - HashtableOfDouble_String76 = value; - break; - case (61): - HashtableOfDouble_String78 = value; - break; - case (62): - HashtableOfDouble_String80 = value; - break; - case (63): - HashtableOfFloat_String81 = value; - break; - case (64): - HashtableOfFloat_String82 = value; - break; - case (65): - HashtableOfFloat_String83 = value; - break; - case (66): - HashtableOfFloat_String84 = value; - break; - case (67): - HashtableOfFloat_String85 = value; - break; - case (68): - HashtableOfFloat_String87 = value; - break; - case (69): - HashtableOfFloat_String89 = value; - break; - case (70): - HashtableOfInteger_String90 = value; - break; - case (71): - HashtableOfInteger_String91 = value; - break; - case (72): - HashtableOfInteger_String92 = value; - break; - case (73): - HashtableOfInteger_String93 = value; - break; - case (74): - HashtableOfInteger_String94 = value; - break; - case (75): - HashtableOfInteger_String96 = value; - break; - case (76): - HashtableOfInteger_String98 = value; - break; - case (77): - HashtableOfLong_String99 = value; - break; - case (78): - HashtableOfLong_String100 = value; - break; - case (79): - HashtableOfLong_String101 = value; - break; - case (80): - HashtableOfLong_String102 = value; - break; - case (81): - HashtableOfLong_String103 = value; - break; - case (82): - HashtableOfLong_String105 = value; - break; - case (83): - HashtableOfLong_String107 = value; - break; - case (84): - HashtableOfShort_String108 = value; - break; - case (85): - HashtableOfShort_String109 = value; - break; - case (86): - HashtableOfShort_String110 = value; - break; - case (87): - HashtableOfShort_String111 = value; - break; - case (88): - HashtableOfShort_String112 = value; - break; - case (89): - HashtableOfShort_String114 = value; - break; - case (90): - HashtableOfShort_String116 = value; - break; + public boolean set(int index,Hashtable value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + HashtableOfObject_String0= value; + break; + case(1): + HashtableOfObject_String1= value; + break; + case(2): + HashtableOfObject_String2= value; + break; + case(3): + HashtableOfObject_String3= value; + break; + case(4): + HashtableOfObject_String4= value; + break; + case(5): + HashtableOfObject_String6= value; + break; + case(6): + HashtableOfObject_String8= value; + break; + case(7): + HashtableOfSimpleClass_String9= value; + break; + case(8): + HashtableOfSimpleClass_String10= value; + break; + case(9): + HashtableOfSimpleClass_String11= value; + break; + case(10): + HashtableOfSimpleClass_String12= value; + break; + case(11): + HashtableOfSimpleClass_String13= value; + break; + case(12): + HashtableOfSimpleClass_String15= value; + break; + case(13): + HashtableOfSimpleClass_String17= value; + break; + case(14): + HashtableOfSimpleInterface_String18= value; + break; + case(15): + HashtableOfSimpleInterface_String19= value; + break; + case(16): + HashtableOfSimpleInterface_String20= value; + break; + case(17): + HashtableOfSimpleInterface_String21= value; + break; + case(18): + HashtableOfSimpleInterface_String22= value; + break; + case(19): + HashtableOfSimpleInterface_String24= value; + break; + case(20): + HashtableOfSimpleInterface_String26= value; + break; + case(21): + HashtableOfString_String27= value; + break; + case(22): + HashtableOfString_String28= value; + break; + case(23): + HashtableOfString_String29= value; + break; + case(24): + HashtableOfString_String30= value; + break; + case(25): + HashtableOfString_String31= value; + break; + case(26): + HashtableOfString_String33= value; + break; + case(27): + HashtableOfString_String35= value; + break; + case(28): + HashtableOfDate_String36= value; + break; + case(29): + HashtableOfDate_String37= value; + break; + case(30): + HashtableOfDate_String38= value; + break; + case(31): + HashtableOfDate_String39= value; + break; + case(32): + HashtableOfDate_String40= value; + break; + case(33): + HashtableOfDate_String42= value; + break; + case(34): + HashtableOfDate_String44= value; + break; + case(35): + HashtableOfBigDecimal_String45= value; + break; + case(36): + HashtableOfBigDecimal_String46= value; + break; + case(37): + HashtableOfBigDecimal_String47= value; + break; + case(38): + HashtableOfBigDecimal_String48= value; + break; + case(39): + HashtableOfBigDecimal_String49= value; + break; + case(40): + HashtableOfBigDecimal_String51= value; + break; + case(41): + HashtableOfBigDecimal_String53= value; + break; + case(42): + HashtableOfBigInteger_String54= value; + break; + case(43): + HashtableOfBigInteger_String55= value; + break; + case(44): + HashtableOfBigInteger_String56= value; + break; + case(45): + HashtableOfBigInteger_String57= value; + break; + case(46): + HashtableOfBigInteger_String58= value; + break; + case(47): + HashtableOfBigInteger_String60= value; + break; + case(48): + HashtableOfBigInteger_String62= value; + break; + case(49): + HashtableOfByte_String63= value; + break; + case(50): + HashtableOfByte_String64= value; + break; + case(51): + HashtableOfByte_String65= value; + break; + case(52): + HashtableOfByte_String66= value; + break; + case(53): + HashtableOfByte_String67= value; + break; + case(54): + HashtableOfByte_String69= value; + break; + case(55): + HashtableOfByte_String71= value; + break; + case(56): + HashtableOfDouble_String72= value; + break; + case(57): + HashtableOfDouble_String73= value; + break; + case(58): + HashtableOfDouble_String74= value; + break; + case(59): + HashtableOfDouble_String75= value; + break; + case(60): + HashtableOfDouble_String76= value; + break; + case(61): + HashtableOfDouble_String78= value; + break; + case(62): + HashtableOfDouble_String80= value; + break; + case(63): + HashtableOfFloat_String81= value; + break; + case(64): + HashtableOfFloat_String82= value; + break; + case(65): + HashtableOfFloat_String83= value; + break; + case(66): + HashtableOfFloat_String84= value; + break; + case(67): + HashtableOfFloat_String85= value; + break; + case(68): + HashtableOfFloat_String87= value; + break; + case(69): + HashtableOfFloat_String89= value; + break; + case(70): + HashtableOfInteger_String90= value; + break; + case(71): + HashtableOfInteger_String91= value; + break; + case(72): + HashtableOfInteger_String92= value; + break; + case(73): + HashtableOfInteger_String93= value; + break; + case(74): + HashtableOfInteger_String94= value; + break; + case(75): + HashtableOfInteger_String96= value; + break; + case(76): + HashtableOfInteger_String98= value; + break; + case(77): + HashtableOfLong_String99= value; + break; + case(78): + HashtableOfLong_String100= value; + break; + case(79): + HashtableOfLong_String101= value; + break; + case(80): + HashtableOfLong_String102= value; + break; + case(81): + HashtableOfLong_String103= value; + break; + case(82): + HashtableOfLong_String105= value; + break; + case(83): + HashtableOfLong_String107= value; + break; + case(84): + HashtableOfShort_String108= value; + break; + case(85): + HashtableOfShort_String109= value; + break; + case(86): + HashtableOfShort_String110= value; + break; + case(87): + HashtableOfShort_String111= value; + break; + case(88): + HashtableOfShort_String112= value; + break; + case(89): + HashtableOfShort_String114= value; + break; + case(90): + HashtableOfShort_String116= value; + break; default: throw new IndexOutOfBoundsException("Bad index " + index); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/LinkedListCollections.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/LinkedListCollections.java index 8c3363d59..ff18a5772 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/LinkedListCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/LinkedListCollections.java @@ -5,22 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; import java.util.LinkedList; -public class LinkedListCollections { +public class LinkedListCollections { public int identifier; public LinkedList LinkedListOfObject0; public LinkedList LinkedListOfObject1; @@ -66,314 +66,312 @@ public class LinkedListCollections { public LinkedList LinkedListOfShort41; public LinkedList LinkedListOfSimpleClass42; - public static final String[] fieldSpecs = { - "public LinkedList LinkedListOfObject0", - "embedded-element=true public LinkedList LinkedListOfObject1", - "embedded-element=false public LinkedList LinkedListOfObject2", - "public LinkedList LinkedListOfSimpleClass3", - "embedded-element=true public LinkedList LinkedListOfSimpleClass4", - "embedded-element=false public LinkedList LinkedListOfSimpleClass5", - "public LinkedList LinkedListOfSimpleInterface6", - "embedded-element=true public LinkedList LinkedListOfSimpleInterface7", - "embedded-element=false public LinkedList LinkedListOfSimpleInterface8", - "public LinkedList LinkedListOfString9", - "embedded-element=true public LinkedList LinkedListOfString10", - "embedded-element=false public LinkedList LinkedListOfString11", - "public LinkedList LinkedListOfDate12", - "embedded-element=true public LinkedList LinkedListOfDate13", - "embedded-element=false public LinkedList LinkedListOfDate14", - "public LinkedList LinkedListOfLocale15", - "embedded-element=true public LinkedList LinkedListOfLocale16", - "embedded-element=false public LinkedList LinkedListOfLocale17", - "public LinkedList LinkedListOfBigDecimal18", - "embedded-element=true public LinkedList LinkedListOfBigDecimal19", - "embedded-element=false public LinkedList LinkedListOfBigDecimal20", - "public LinkedList LinkedListOfBigInteger21", - "embedded-element=true public LinkedList LinkedListOfBigInteger22", - "embedded-element=false public LinkedList LinkedListOfBigInteger23", - "public LinkedList LinkedListOfByte24", - "embedded-element=true public LinkedList LinkedListOfByte25", - "embedded-element=false public LinkedList LinkedListOfByte26", - "public LinkedList LinkedListOfDouble27", - "embedded-element=true public LinkedList LinkedListOfDouble28", - "embedded-element=false public LinkedList LinkedListOfDouble29", - "public LinkedList LinkedListOfFloat30", - "embedded-element=true public LinkedList LinkedListOfFloat31", - "embedded-element=false public LinkedList LinkedListOfFloat32", - "public LinkedList LinkedListOfInteger33", - "embedded-element=true public LinkedList LinkedListOfInteger34", - "embedded-element=false public LinkedList LinkedListOfInteger35", - "public LinkedList LinkedListOfLong36", - "embedded-element=true public LinkedList LinkedListOfLong37", - "embedded-element=false public LinkedList LinkedListOfLong38", - "public LinkedList LinkedListOfShort39", - "embedded-element=true public LinkedList LinkedListOfShort40", - "embedded-element=false public LinkedList LinkedListOfShort41", - "serialized=true public LinkedList LinkedListOfSimpleClass42" + public static final String [] fieldSpecs = { + "public LinkedList LinkedListOfObject0", + "embedded-element=true public LinkedList LinkedListOfObject1", + "embedded-element=false public LinkedList LinkedListOfObject2", + "public LinkedList LinkedListOfSimpleClass3", + "embedded-element=true public LinkedList LinkedListOfSimpleClass4", + "embedded-element=false public LinkedList LinkedListOfSimpleClass5", + "public LinkedList LinkedListOfSimpleInterface6", + "embedded-element=true public LinkedList LinkedListOfSimpleInterface7", + "embedded-element=false public LinkedList LinkedListOfSimpleInterface8", + "public LinkedList LinkedListOfString9", + "embedded-element=true public LinkedList LinkedListOfString10", + "embedded-element=false public LinkedList LinkedListOfString11", + "public LinkedList LinkedListOfDate12", + "embedded-element=true public LinkedList LinkedListOfDate13", + "embedded-element=false public LinkedList LinkedListOfDate14", + "public LinkedList LinkedListOfLocale15", + "embedded-element=true public LinkedList LinkedListOfLocale16", + "embedded-element=false public LinkedList LinkedListOfLocale17", + "public LinkedList LinkedListOfBigDecimal18", + "embedded-element=true public LinkedList LinkedListOfBigDecimal19", + "embedded-element=false public LinkedList LinkedListOfBigDecimal20", + "public LinkedList LinkedListOfBigInteger21", + "embedded-element=true public LinkedList LinkedListOfBigInteger22", + "embedded-element=false public LinkedList LinkedListOfBigInteger23", + "public LinkedList LinkedListOfByte24", + "embedded-element=true public LinkedList LinkedListOfByte25", + "embedded-element=false public LinkedList LinkedListOfByte26", + "public LinkedList LinkedListOfDouble27", + "embedded-element=true public LinkedList LinkedListOfDouble28", + "embedded-element=false public LinkedList LinkedListOfDouble29", + "public LinkedList LinkedListOfFloat30", + "embedded-element=true public LinkedList LinkedListOfFloat31", + "embedded-element=false public LinkedList LinkedListOfFloat32", + "public LinkedList LinkedListOfInteger33", + "embedded-element=true public LinkedList LinkedListOfInteger34", + "embedded-element=false public LinkedList LinkedListOfInteger35", + "public LinkedList LinkedListOfLong36", + "embedded-element=true public LinkedList LinkedListOfLong37", + "embedded-element=false public LinkedList LinkedListOfLong38", + "public LinkedList LinkedListOfShort39", + "embedded-element=true public LinkedList LinkedListOfShort40", + "embedded-element=false public LinkedList LinkedListOfShort41", + "serialized=true public LinkedList LinkedListOfSimpleClass42" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public LinkedList get(int index) { - switch (index) { - case (0): + public LinkedList get(int index) + { + switch (index) + { + case(0): return LinkedListOfObject0; - case (1): + case(1): return LinkedListOfObject1; - case (2): + case(2): return LinkedListOfObject2; - case (3): + case(3): return LinkedListOfSimpleClass3; - case (4): + case(4): return LinkedListOfSimpleClass4; - case (5): + case(5): return LinkedListOfSimpleClass5; - case (6): + case(6): return LinkedListOfSimpleInterface6; - case (7): + case(7): return LinkedListOfSimpleInterface7; - case (8): + case(8): return LinkedListOfSimpleInterface8; - case (9): + case(9): return LinkedListOfString9; - case (10): + case(10): return LinkedListOfString10; - case (11): + case(11): return LinkedListOfString11; - case (12): + case(12): return LinkedListOfDate12; - case (13): + case(13): return LinkedListOfDate13; - case (14): + case(14): return LinkedListOfDate14; - case (15): + case(15): return LinkedListOfLocale15; - case (16): + case(16): return LinkedListOfLocale16; - case (17): + case(17): return LinkedListOfLocale17; - case (18): + case(18): return LinkedListOfBigDecimal18; - case (19): + case(19): return LinkedListOfBigDecimal19; - case (20): + case(20): return LinkedListOfBigDecimal20; - case (21): + case(21): return LinkedListOfBigInteger21; - case (22): + case(22): return LinkedListOfBigInteger22; - case (23): + case(23): return LinkedListOfBigInteger23; - case (24): + case(24): return LinkedListOfByte24; - case (25): + case(25): return LinkedListOfByte25; - case (26): + case(26): return LinkedListOfByte26; - case (27): + case(27): return LinkedListOfDouble27; - case (28): + case(28): return LinkedListOfDouble28; - case (29): + case(29): return LinkedListOfDouble29; - case (30): + case(30): return LinkedListOfFloat30; - case (31): + case(31): return LinkedListOfFloat31; - case (32): + case(32): return LinkedListOfFloat32; - case (33): + case(33): return LinkedListOfInteger33; - case (34): + case(34): return LinkedListOfInteger34; - case (35): + case(35): return LinkedListOfInteger35; - case (36): + case(36): return LinkedListOfLong36; - case (37): + case(37): return LinkedListOfLong37; - case (38): + case(38): return LinkedListOfLong38; - case (39): + case(39): return LinkedListOfShort39; - case (40): + case(40): return LinkedListOfShort40; - case (41): + case(41): return LinkedListOfShort41; - case (42): + case(42): return LinkedListOfSimpleClass42; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, LinkedList value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - LinkedListOfObject0 = value; - break; - case (1): - LinkedListOfObject1 = value; - break; - case (2): - LinkedListOfObject2 = value; - break; - case (3): - LinkedListOfSimpleClass3 = value; - break; - case (4): - LinkedListOfSimpleClass4 = value; - break; - case (5): - LinkedListOfSimpleClass5 = value; - break; - case (6): - LinkedListOfSimpleInterface6 = value; - break; - case (7): - LinkedListOfSimpleInterface7 = value; - break; - case (8): - LinkedListOfSimpleInterface8 = value; - break; - case (9): - LinkedListOfString9 = value; - break; - case (10): - LinkedListOfString10 = value; - break; - case (11): - LinkedListOfString11 = value; - break; - case (12): - LinkedListOfDate12 = value; - break; - case (13): - LinkedListOfDate13 = value; - break; - case (14): - LinkedListOfDate14 = value; - break; - case (15): - LinkedListOfLocale15 = value; - break; - case (16): - LinkedListOfLocale16 = value; - break; - case (17): - LinkedListOfLocale17 = value; - break; - case (18): - LinkedListOfBigDecimal18 = value; - break; - case (19): - LinkedListOfBigDecimal19 = value; - break; - case (20): - LinkedListOfBigDecimal20 = value; - break; - case (21): - LinkedListOfBigInteger21 = value; - break; - case (22): - LinkedListOfBigInteger22 = value; - break; - case (23): - LinkedListOfBigInteger23 = value; - break; - case (24): - LinkedListOfByte24 = value; - break; - case (25): - LinkedListOfByte25 = value; - break; - case (26): - LinkedListOfByte26 = value; - break; - case (27): - LinkedListOfDouble27 = value; - break; - case (28): - LinkedListOfDouble28 = value; - break; - case (29): - LinkedListOfDouble29 = value; - break; - case (30): - LinkedListOfFloat30 = value; - break; - case (31): - LinkedListOfFloat31 = value; - break; - case (32): - LinkedListOfFloat32 = value; - break; - case (33): - LinkedListOfInteger33 = value; - break; - case (34): - LinkedListOfInteger34 = value; - break; - case (35): - LinkedListOfInteger35 = value; - break; - case (36): - LinkedListOfLong36 = value; - break; - case (37): - LinkedListOfLong37 = value; - break; - case (38): - LinkedListOfLong38 = value; - break; - case (39): - LinkedListOfShort39 = value; - break; - case (40): - LinkedListOfShort40 = value; - break; - case (41): - LinkedListOfShort41 = value; - break; - case (42): - LinkedListOfSimpleClass42 = value; - break; + public boolean set(int index,LinkedList value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + LinkedListOfObject0= value; + break; + case(1): + LinkedListOfObject1= value; + break; + case(2): + LinkedListOfObject2= value; + break; + case(3): + LinkedListOfSimpleClass3= value; + break; + case(4): + LinkedListOfSimpleClass4= value; + break; + case(5): + LinkedListOfSimpleClass5= value; + break; + case(6): + LinkedListOfSimpleInterface6= value; + break; + case(7): + LinkedListOfSimpleInterface7= value; + break; + case(8): + LinkedListOfSimpleInterface8= value; + break; + case(9): + LinkedListOfString9= value; + break; + case(10): + LinkedListOfString10= value; + break; + case(11): + LinkedListOfString11= value; + break; + case(12): + LinkedListOfDate12= value; + break; + case(13): + LinkedListOfDate13= value; + break; + case(14): + LinkedListOfDate14= value; + break; + case(15): + LinkedListOfLocale15= value; + break; + case(16): + LinkedListOfLocale16= value; + break; + case(17): + LinkedListOfLocale17= value; + break; + case(18): + LinkedListOfBigDecimal18= value; + break; + case(19): + LinkedListOfBigDecimal19= value; + break; + case(20): + LinkedListOfBigDecimal20= value; + break; + case(21): + LinkedListOfBigInteger21= value; + break; + case(22): + LinkedListOfBigInteger22= value; + break; + case(23): + LinkedListOfBigInteger23= value; + break; + case(24): + LinkedListOfByte24= value; + break; + case(25): + LinkedListOfByte25= value; + break; + case(26): + LinkedListOfByte26= value; + break; + case(27): + LinkedListOfDouble27= value; + break; + case(28): + LinkedListOfDouble28= value; + break; + case(29): + LinkedListOfDouble29= value; + break; + case(30): + LinkedListOfFloat30= value; + break; + case(31): + LinkedListOfFloat31= value; + break; + case(32): + LinkedListOfFloat32= value; + break; + case(33): + LinkedListOfInteger33= value; + break; + case(34): + LinkedListOfInteger34= value; + break; + case(35): + LinkedListOfInteger35= value; + break; + case(36): + LinkedListOfLong36= value; + break; + case(37): + LinkedListOfLong37= value; + break; + case(38): + LinkedListOfLong38= value; + break; + case(39): + LinkedListOfShort39= value; + break; + case(40): + LinkedListOfShort40= value; + break; + case(41): + LinkedListOfShort41= value; + break; + case(42): + LinkedListOfSimpleClass42= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } - - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public int hashCode() { return (int)identifier ; } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/ListCollections.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/ListCollections.java index c478834b7..d9123fb6a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/ListCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/ListCollections.java @@ -5,22 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; import java.util.List; -public class ListCollections { +public class ListCollections { public int identifier; public List ListOfObject0; public List ListOfObject1; @@ -66,314 +66,313 @@ public class ListCollections { public List ListOfShort41; public List ListOfSimpleClass42; - public static final String[] fieldSpecs = { - "public List ListOfObject0", - "embedded-element=true public List ListOfObject1", - "embedded-element=false public List ListOfObject2", - "public List ListOfSimpleClass3", - "embedded-element=true public List ListOfSimpleClass4", - "embedded-element=false public List ListOfSimpleClass5", - "public List ListOfSimpleInterface6", - "embedded-element=true public List ListOfSimpleInterface7", - "embedded-element=false public List ListOfSimpleInterface8", - "public List ListOfString9", - "embedded-element=true public List ListOfString10", - "embedded-element=false public List ListOfString11", - "public List ListOfDate12", - "embedded-element=true public List ListOfDate13", - "embedded-element=false public List ListOfDate14", - "public List ListOfLocale15", - "embedded-element=true public List ListOfLocale16", - "embedded-element=false public List ListOfLocale17", - "public List ListOfBigDecimal18", - "embedded-element=true public List ListOfBigDecimal19", - "embedded-element=false public List ListOfBigDecimal20", - "public List ListOfBigInteger21", - "embedded-element=true public List ListOfBigInteger22", - "embedded-element=false public List ListOfBigInteger23", - "public List ListOfByte24", - "embedded-element=true public List ListOfByte25", - "embedded-element=false public List ListOfByte26", - "public List ListOfDouble27", - "embedded-element=true public List ListOfDouble28", - "embedded-element=false public List ListOfDouble29", - "public List ListOfFloat30", - "embedded-element=true public List ListOfFloat31", - "embedded-element=false public List ListOfFloat32", - "public List ListOfInteger33", - "embedded-element=true public List ListOfInteger34", - "embedded-element=false public List ListOfInteger35", - "public List ListOfLong36", - "embedded-element=true public List ListOfLong37", - "embedded-element=false public List ListOfLong38", - "public List ListOfShort39", - "embedded-element=true public List ListOfShort40", - "embedded-element=false public List ListOfShort41", - "serialized=true public List ListOfSimpleClass42" + public static final String [] fieldSpecs = { + "public List ListOfObject0", + "embedded-element=true public List ListOfObject1", + "embedded-element=false public List ListOfObject2", + "public List ListOfSimpleClass3", + "embedded-element=true public List ListOfSimpleClass4", + "embedded-element=false public List ListOfSimpleClass5", + "public List ListOfSimpleInterface6", + "embedded-element=true public List ListOfSimpleInterface7", + "embedded-element=false public List ListOfSimpleInterface8", + "public List ListOfString9", + "embedded-element=true public List ListOfString10", + "embedded-element=false public List ListOfString11", + "public List ListOfDate12", + "embedded-element=true public List ListOfDate13", + "embedded-element=false public List ListOfDate14", + "public List ListOfLocale15", + "embedded-element=true public List ListOfLocale16", + "embedded-element=false public List ListOfLocale17", + "public List ListOfBigDecimal18", + "embedded-element=true public List ListOfBigDecimal19", + "embedded-element=false public List ListOfBigDecimal20", + "public List ListOfBigInteger21", + "embedded-element=true public List ListOfBigInteger22", + "embedded-element=false public List ListOfBigInteger23", + "public List ListOfByte24", + "embedded-element=true public List ListOfByte25", + "embedded-element=false public List ListOfByte26", + "public List ListOfDouble27", + "embedded-element=true public List ListOfDouble28", + "embedded-element=false public List ListOfDouble29", + "public List ListOfFloat30", + "embedded-element=true public List ListOfFloat31", + "embedded-element=false public List ListOfFloat32", + "public List ListOfInteger33", + "embedded-element=true public List ListOfInteger34", + "embedded-element=false public List ListOfInteger35", + "public List ListOfLong36", + "embedded-element=true public List ListOfLong37", + "embedded-element=false public List ListOfLong38", + "public List ListOfShort39", + "embedded-element=true public List ListOfShort40", + "embedded-element=false public List ListOfShort41", + "serialized=true public List ListOfSimpleClass42" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public List get(int index) { - switch (index) { - case (0): + public List get(int index) + { + switch (index) + { + case(0): return ListOfObject0; - case (1): + case(1): return ListOfObject1; - case (2): + case(2): return ListOfObject2; - case (3): + case(3): return ListOfSimpleClass3; - case (4): + case(4): return ListOfSimpleClass4; - case (5): + case(5): return ListOfSimpleClass5; - case (6): + case(6): return ListOfSimpleInterface6; - case (7): + case(7): return ListOfSimpleInterface7; - case (8): + case(8): return ListOfSimpleInterface8; - case (9): + case(9): return ListOfString9; - case (10): + case(10): return ListOfString10; - case (11): + case(11): return ListOfString11; - case (12): + case(12): return ListOfDate12; - case (13): + case(13): return ListOfDate13; - case (14): + case(14): return ListOfDate14; - case (15): + case(15): return ListOfLocale15; - case (16): + case(16): return ListOfLocale16; - case (17): + case(17): return ListOfLocale17; - case (18): + case(18): return ListOfBigDecimal18; - case (19): + case(19): return ListOfBigDecimal19; - case (20): + case(20): return ListOfBigDecimal20; - case (21): + case(21): return ListOfBigInteger21; - case (22): + case(22): return ListOfBigInteger22; - case (23): + case(23): return ListOfBigInteger23; - case (24): + case(24): return ListOfByte24; - case (25): + case(25): return ListOfByte25; - case (26): + case(26): return ListOfByte26; - case (27): + case(27): return ListOfDouble27; - case (28): + case(28): return ListOfDouble28; - case (29): + case(29): return ListOfDouble29; - case (30): + case(30): return ListOfFloat30; - case (31): + case(31): return ListOfFloat31; - case (32): + case(32): return ListOfFloat32; - case (33): + case(33): return ListOfInteger33; - case (34): + case(34): return ListOfInteger34; - case (35): + case(35): return ListOfInteger35; - case (36): + case(36): return ListOfLong36; - case (37): + case(37): return ListOfLong37; - case (38): + case(38): return ListOfLong38; - case (39): + case(39): return ListOfShort39; - case (40): + case(40): return ListOfShort40; - case (41): + case(41): return ListOfShort41; - case (42): + case(42): return ListOfSimpleClass42; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, List value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - ListOfObject0 = value; - break; - case (1): - ListOfObject1 = value; - break; - case (2): - ListOfObject2 = value; - break; - case (3): - ListOfSimpleClass3 = value; - break; - case (4): - ListOfSimpleClass4 = value; - break; - case (5): - ListOfSimpleClass5 = value; - break; - case (6): - ListOfSimpleInterface6 = value; - break; - case (7): - ListOfSimpleInterface7 = value; - break; - case (8): - ListOfSimpleInterface8 = value; - break; - case (9): - ListOfString9 = value; - break; - case (10): - ListOfString10 = value; - break; - case (11): - ListOfString11 = value; - break; - case (12): - ListOfDate12 = value; - break; - case (13): - ListOfDate13 = value; - break; - case (14): - ListOfDate14 = value; - break; - case (15): - ListOfLocale15 = value; - break; - case (16): - ListOfLocale16 = value; - break; - case (17): - ListOfLocale17 = value; - break; - case (18): - ListOfBigDecimal18 = value; - break; - case (19): - ListOfBigDecimal19 = value; - break; - case (20): - ListOfBigDecimal20 = value; - break; - case (21): - ListOfBigInteger21 = value; - break; - case (22): - ListOfBigInteger22 = value; - break; - case (23): - ListOfBigInteger23 = value; - break; - case (24): - ListOfByte24 = value; - break; - case (25): - ListOfByte25 = value; - break; - case (26): - ListOfByte26 = value; - break; - case (27): - ListOfDouble27 = value; - break; - case (28): - ListOfDouble28 = value; - break; - case (29): - ListOfDouble29 = value; - break; - case (30): - ListOfFloat30 = value; - break; - case (31): - ListOfFloat31 = value; - break; - case (32): - ListOfFloat32 = value; - break; - case (33): - ListOfInteger33 = value; - break; - case (34): - ListOfInteger34 = value; - break; - case (35): - ListOfInteger35 = value; - break; - case (36): - ListOfLong36 = value; - break; - case (37): - ListOfLong37 = value; - break; - case (38): - ListOfLong38 = value; - break; - case (39): - ListOfShort39 = value; - break; - case (40): - ListOfShort40 = value; - break; - case (41): - ListOfShort41 = value; - break; - case (42): - ListOfSimpleClass42 = value; - break; + public boolean set(int index, List value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + ListOfObject0= value; + break; + case(1): + ListOfObject1= value; + break; + case(2): + ListOfObject2= value; + break; + case(3): + ListOfSimpleClass3= value; + break; + case(4): + ListOfSimpleClass4= value; + break; + case(5): + ListOfSimpleClass5= value; + break; + case(6): + ListOfSimpleInterface6= value; + break; + case(7): + ListOfSimpleInterface7= value; + break; + case(8): + ListOfSimpleInterface8= value; + break; + case(9): + ListOfString9= value; + break; + case(10): + ListOfString10= value; + break; + case(11): + ListOfString11= value; + break; + case(12): + ListOfDate12= value; + break; + case(13): + ListOfDate13= value; + break; + case(14): + ListOfDate14= value; + break; + case(15): + ListOfLocale15= value; + break; + case(16): + ListOfLocale16= value; + break; + case(17): + ListOfLocale17= value; + break; + case(18): + ListOfBigDecimal18= value; + break; + case(19): + ListOfBigDecimal19= value; + break; + case(20): + ListOfBigDecimal20= value; + break; + case(21): + ListOfBigInteger21= value; + break; + case(22): + ListOfBigInteger22= value; + break; + case(23): + ListOfBigInteger23= value; + break; + case(24): + ListOfByte24= value; + break; + case(25): + ListOfByte25= value; + break; + case(26): + ListOfByte26= value; + break; + case(27): + ListOfDouble27= value; + break; + case(28): + ListOfDouble28= value; + break; + case(29): + ListOfDouble29= value; + break; + case(30): + ListOfFloat30= value; + break; + case(31): + ListOfFloat31= value; + break; + case(32): + ListOfFloat32= value; + break; + case(33): + ListOfInteger33= value; + break; + case(34): + ListOfInteger34= value; + break; + case(35): + ListOfInteger35= value; + break; + case(36): + ListOfLong36= value; + break; + case(37): + ListOfLong37= value; + break; + case(38): + ListOfLong38= value; + break; + case(39): + ListOfShort39= value; + break; + case(40): + ListOfShort40= value; + break; + case(41): + ListOfShort41= value; + break; + case(42): + ListOfSimpleClass42= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/MapStringKeyCollections.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/MapStringKeyCollections.java index f4171afff..7d1ae6ac6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/MapStringKeyCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/MapStringKeyCollections.java @@ -5,22 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; import java.util.Map; -public class MapStringKeyCollections { +public class MapStringKeyCollections { public int identifier; public Map MapOfString_Object0; public Map MapOfString_Object1; @@ -134,722 +134,721 @@ public class MapStringKeyCollections { public Map MapOfString_SimpleEnum137; public Map MapOfString_SimpleEnum138; - public static final String[] fieldSpecs = { - "public Map MapOfString_Object0", - "embedded-value=true public Map MapOfString_Object1", - "embedded-value=false public Map MapOfString_Object2", - "public Map MapOfString_SimpleClass3", - "embedded-value=true public Map MapOfString_SimpleClass4", - "embedded-value=false public Map MapOfString_SimpleClass5", - "public Map MapOfString_SimpleInterface6", - "embedded-value=true public Map MapOfString_SimpleInterface7", - "embedded-value=false public Map MapOfString_SimpleInterface8", - "public Map MapOfString_String9", - "embedded-value=true public Map MapOfString_String10", - "embedded-value=false public Map MapOfString_String11", - "public Map MapOfString_Date12", - "embedded-value=true public Map MapOfString_Date13", - "embedded-value=false public Map MapOfString_Date14", - "public Map MapOfString_Locale15", - "embedded-value=true public Map MapOfString_Locale16", - "embedded-value=false public Map MapOfString_Locale17", - "public Map MapOfString_BigDecimal18", - "embedded-value=true public Map MapOfString_BigDecimal19", - "embedded-value=false public Map MapOfString_BigDecimal20", - "public Map MapOfString_BigInteger21", - "embedded-value=true public Map MapOfString_BigInteger22", - "embedded-value=false public Map MapOfString_BigInteger23", - "public Map MapOfString_Byte24", - "embedded-value=true public Map MapOfString_Byte25", - "embedded-value=false public Map MapOfString_Byte26", - "public Map MapOfString_Double27", - "embedded-value=true public Map MapOfString_Double28", - "embedded-value=false public Map MapOfString_Double29", - "public Map MapOfString_Float30", - "embedded-value=true public Map MapOfString_Float31", - "embedded-value=false public Map MapOfString_Float32", - "public Map MapOfString_Integer33", - "embedded-value=true public Map MapOfString_Integer34", - "embedded-value=false public Map MapOfString_Integer35", - "public Map MapOfString_Long36", - "embedded-value=true public Map MapOfString_Long37", - "embedded-value=false public Map MapOfString_Long38", - "public Map MapOfString_Short39", - "embedded-value=true public Map MapOfString_Short40", - "embedded-value=false public Map MapOfString_Short41", - "embedded-key=true public Map MapOfString_Object42", - "embedded-key=true embedded-value=true public Map MapOfString_Object43", - "embedded-key=true public Map MapOfString_SimpleClass45", - "embedded-key=true embedded-value=true public Map MapOfString_SimpleClass46", - "embedded-key=true public Map MapOfString_SimpleInterface48", - "embedded-key=true embedded-value=true public Map MapOfString_SimpleInterface49", - "embedded-key=true public Map MapOfString_String51", - "embedded-key=true embedded-value=true public Map MapOfString_String52", - "embedded-key=true public Map MapOfString_Date54", - "embedded-key=true embedded-value=true public Map MapOfString_Date55", - "embedded-key=true public Map MapOfString_Locale57", - "embedded-key=true embedded-value=true public Map MapOfString_Locale58", - "embedded-key=true public Map MapOfString_BigDecimal60", - "embedded-key=true embedded-value=true public Map MapOfString_BigDecimal61", - "embedded-key=true public Map MapOfString_BigInteger63", - "embedded-key=true embedded-value=true public Map MapOfString_BigInteger64", - "embedded-key=true public Map MapOfString_Byte66", - "embedded-key=true embedded-value=true public Map MapOfString_Byte67", - "embedded-key=true public Map MapOfString_Double69", - "embedded-key=true embedded-value=true public Map MapOfString_Double70", - "embedded-key=true public Map MapOfString_Float72", - "embedded-key=true embedded-value=true public Map MapOfString_Float73", - "embedded-key=true public Map MapOfString_Integer75", - "embedded-key=true embedded-value=true public Map MapOfString_Integer76", - "embedded-key=true public Map MapOfString_Long78", - "embedded-key=true embedded-value=true public Map MapOfString_Long79", - "embedded-key=true public Map MapOfString_Short81", - "embedded-key=true embedded-value=true public Map MapOfString_Short82", - "embedded-key=false public Map MapOfString_Object84", - "embedded-key=false embedded-value=false public Map MapOfString_Object86", - "embedded-key=false public Map MapOfString_SimpleClass87", - "embedded-key=false embedded-value=false public Map MapOfString_SimpleClass89", - "embedded-key=false public Map MapOfString_SimpleInterface90", - "embedded-key=false embedded-value=false public Map MapOfString_SimpleInterface92", - "embedded-key=false public Map MapOfString_String93", - "embedded-key=false embedded-value=false public Map MapOfString_String95", - "embedded-key=false public Map MapOfString_Date96", - "embedded-key=false embedded-value=false public Map MapOfString_Date98", - "embedded-key=false public Map MapOfString_Locale99", - "embedded-key=false embedded-value=false public Map MapOfString_Locale101", - "embedded-key=false public Map MapOfString_BigDecimal102", - "embedded-key=false embedded-value=false public Map MapOfString_BigDecimal104", - "embedded-key=false public Map MapOfString_BigInteger105", - "embedded-key=false embedded-value=false public Map MapOfString_BigInteger107", - "embedded-key=false public Map MapOfString_Byte108", - "embedded-key=false embedded-value=false public Map MapOfString_Byte110", - "embedded-key=false public Map MapOfString_Double111", - "embedded-key=false embedded-value=false public Map MapOfString_Double113", - "embedded-key=false public Map MapOfString_Float114", - "embedded-key=false embedded-value=false public Map MapOfString_Float116", - "embedded-key=false public Map MapOfString_Integer117", - "embedded-key=false embedded-value=false public Map MapOfString_Integer119", - "embedded-key=false public Map MapOfString_Long120", - "embedded-key=false embedded-value=false public Map MapOfString_Long122", - "embedded-key=false public Map MapOfString_Short123", - "embedded-key=false embedded-value=false public Map MapOfString_Short125", - "public Map MapOfString_SimpleEnum126", - "embedded-value=true public Map MapOfString_SimpleEnum127", - "embedded-value=false public Map MapOfString_SimpleEnum128", - "embedded-key=true public Map MapOfString_SimpleEnum129", - "embedded-key=true embedded-value=true public Map MapOfString_SimpleEnum130", - "embedded-key=false public Map MapOfString_SimpleEnum131", - "embedded-key=false embedded-value=false public Map MapOfString_SimpleEnum132", - "public Map MapOfString_SimpleEnum133", - "embedded-value=true public Map MapOfString_SimpleEnum134", - "embedded-value=false public Map MapOfString_SimpleEnum135", - "embedded-key=true public Map MapOfString_SimpleEnum136", - "embedded-key=true embedded-value=true public Map MapOfString_SimpleEnum137", - "embedded-key=false public Map MapOfString_SimpleEnum138" + public static final String [] fieldSpecs = { + "public Map MapOfString_Object0", + "embedded-value=true public Map MapOfString_Object1", + "embedded-value=false public Map MapOfString_Object2", + "public Map MapOfString_SimpleClass3", + "embedded-value=true public Map MapOfString_SimpleClass4", + "embedded-value=false public Map MapOfString_SimpleClass5", + "public Map MapOfString_SimpleInterface6", + "embedded-value=true public Map MapOfString_SimpleInterface7", + "embedded-value=false public Map MapOfString_SimpleInterface8", + "public Map MapOfString_String9", + "embedded-value=true public Map MapOfString_String10", + "embedded-value=false public Map MapOfString_String11", + "public Map MapOfString_Date12", + "embedded-value=true public Map MapOfString_Date13", + "embedded-value=false public Map MapOfString_Date14", + "public Map MapOfString_Locale15", + "embedded-value=true public Map MapOfString_Locale16", + "embedded-value=false public Map MapOfString_Locale17", + "public Map MapOfString_BigDecimal18", + "embedded-value=true public Map MapOfString_BigDecimal19", + "embedded-value=false public Map MapOfString_BigDecimal20", + "public Map MapOfString_BigInteger21", + "embedded-value=true public Map MapOfString_BigInteger22", + "embedded-value=false public Map MapOfString_BigInteger23", + "public Map MapOfString_Byte24", + "embedded-value=true public Map MapOfString_Byte25", + "embedded-value=false public Map MapOfString_Byte26", + "public Map MapOfString_Double27", + "embedded-value=true public Map MapOfString_Double28", + "embedded-value=false public Map MapOfString_Double29", + "public Map MapOfString_Float30", + "embedded-value=true public Map MapOfString_Float31", + "embedded-value=false public Map MapOfString_Float32", + "public Map MapOfString_Integer33", + "embedded-value=true public Map MapOfString_Integer34", + "embedded-value=false public Map MapOfString_Integer35", + "public Map MapOfString_Long36", + "embedded-value=true public Map MapOfString_Long37", + "embedded-value=false public Map MapOfString_Long38", + "public Map MapOfString_Short39", + "embedded-value=true public Map MapOfString_Short40", + "embedded-value=false public Map MapOfString_Short41", + "embedded-key=true public Map MapOfString_Object42", + "embedded-key=true embedded-value=true public Map MapOfString_Object43", + "embedded-key=true public Map MapOfString_SimpleClass45", + "embedded-key=true embedded-value=true public Map MapOfString_SimpleClass46", + "embedded-key=true public Map MapOfString_SimpleInterface48", + "embedded-key=true embedded-value=true public Map MapOfString_SimpleInterface49", + "embedded-key=true public Map MapOfString_String51", + "embedded-key=true embedded-value=true public Map MapOfString_String52", + "embedded-key=true public Map MapOfString_Date54", + "embedded-key=true embedded-value=true public Map MapOfString_Date55", + "embedded-key=true public Map MapOfString_Locale57", + "embedded-key=true embedded-value=true public Map MapOfString_Locale58", + "embedded-key=true public Map MapOfString_BigDecimal60", + "embedded-key=true embedded-value=true public Map MapOfString_BigDecimal61", + "embedded-key=true public Map MapOfString_BigInteger63", + "embedded-key=true embedded-value=true public Map MapOfString_BigInteger64", + "embedded-key=true public Map MapOfString_Byte66", + "embedded-key=true embedded-value=true public Map MapOfString_Byte67", + "embedded-key=true public Map MapOfString_Double69", + "embedded-key=true embedded-value=true public Map MapOfString_Double70", + "embedded-key=true public Map MapOfString_Float72", + "embedded-key=true embedded-value=true public Map MapOfString_Float73", + "embedded-key=true public Map MapOfString_Integer75", + "embedded-key=true embedded-value=true public Map MapOfString_Integer76", + "embedded-key=true public Map MapOfString_Long78", + "embedded-key=true embedded-value=true public Map MapOfString_Long79", + "embedded-key=true public Map MapOfString_Short81", + "embedded-key=true embedded-value=true public Map MapOfString_Short82", + "embedded-key=false public Map MapOfString_Object84", + "embedded-key=false embedded-value=false public Map MapOfString_Object86", + "embedded-key=false public Map MapOfString_SimpleClass87", + "embedded-key=false embedded-value=false public Map MapOfString_SimpleClass89", + "embedded-key=false public Map MapOfString_SimpleInterface90", + "embedded-key=false embedded-value=false public Map MapOfString_SimpleInterface92", + "embedded-key=false public Map MapOfString_String93", + "embedded-key=false embedded-value=false public Map MapOfString_String95", + "embedded-key=false public Map MapOfString_Date96", + "embedded-key=false embedded-value=false public Map MapOfString_Date98", + "embedded-key=false public Map MapOfString_Locale99", + "embedded-key=false embedded-value=false public Map MapOfString_Locale101", + "embedded-key=false public Map MapOfString_BigDecimal102", + "embedded-key=false embedded-value=false public Map MapOfString_BigDecimal104", + "embedded-key=false public Map MapOfString_BigInteger105", + "embedded-key=false embedded-value=false public Map MapOfString_BigInteger107", + "embedded-key=false public Map MapOfString_Byte108", + "embedded-key=false embedded-value=false public Map MapOfString_Byte110", + "embedded-key=false public Map MapOfString_Double111", + "embedded-key=false embedded-value=false public Map MapOfString_Double113", + "embedded-key=false public Map MapOfString_Float114", + "embedded-key=false embedded-value=false public Map MapOfString_Float116", + "embedded-key=false public Map MapOfString_Integer117", + "embedded-key=false embedded-value=false public Map MapOfString_Integer119", + "embedded-key=false public Map MapOfString_Long120", + "embedded-key=false embedded-value=false public Map MapOfString_Long122", + "embedded-key=false public Map MapOfString_Short123", + "embedded-key=false embedded-value=false public Map MapOfString_Short125", + "public Map MapOfString_SimpleEnum126", + "embedded-value=true public Map MapOfString_SimpleEnum127", + "embedded-value=false public Map MapOfString_SimpleEnum128", + "embedded-key=true public Map MapOfString_SimpleEnum129", + "embedded-key=true embedded-value=true public Map MapOfString_SimpleEnum130", + "embedded-key=false public Map MapOfString_SimpleEnum131", + "embedded-key=false embedded-value=false public Map MapOfString_SimpleEnum132", + "public Map MapOfString_SimpleEnum133", + "embedded-value=true public Map MapOfString_SimpleEnum134", + "embedded-value=false public Map MapOfString_SimpleEnum135", + "embedded-key=true public Map MapOfString_SimpleEnum136", + "embedded-key=true embedded-value=true public Map MapOfString_SimpleEnum137", + "embedded-key=false public Map MapOfString_SimpleEnum138" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public Map get(int index) { - switch (index) { - case (0): + public Map get(int index) + { + switch (index) + { + case(0): return MapOfString_Object0; - case (1): + case(1): return MapOfString_Object1; - case (2): + case(2): return MapOfString_Object2; - case (3): + case(3): return MapOfString_SimpleClass3; - case (4): + case(4): return MapOfString_SimpleClass4; - case (5): + case(5): return MapOfString_SimpleClass5; - case (6): + case(6): return MapOfString_SimpleInterface6; - case (7): + case(7): return MapOfString_SimpleInterface7; - case (8): + case(8): return MapOfString_SimpleInterface8; - case (9): + case(9): return MapOfString_String9; - case (10): + case(10): return MapOfString_String10; - case (11): + case(11): return MapOfString_String11; - case (12): + case(12): return MapOfString_Date12; - case (13): + case(13): return MapOfString_Date13; - case (14): + case(14): return MapOfString_Date14; - case (15): + case(15): return MapOfString_Locale15; - case (16): + case(16): return MapOfString_Locale16; - case (17): + case(17): return MapOfString_Locale17; - case (18): + case(18): return MapOfString_BigDecimal18; - case (19): + case(19): return MapOfString_BigDecimal19; - case (20): + case(20): return MapOfString_BigDecimal20; - case (21): + case(21): return MapOfString_BigInteger21; - case (22): + case(22): return MapOfString_BigInteger22; - case (23): + case(23): return MapOfString_BigInteger23; - case (24): + case(24): return MapOfString_Byte24; - case (25): + case(25): return MapOfString_Byte25; - case (26): + case(26): return MapOfString_Byte26; - case (27): + case(27): return MapOfString_Double27; - case (28): + case(28): return MapOfString_Double28; - case (29): + case(29): return MapOfString_Double29; - case (30): + case(30): return MapOfString_Float30; - case (31): + case(31): return MapOfString_Float31; - case (32): + case(32): return MapOfString_Float32; - case (33): + case(33): return MapOfString_Integer33; - case (34): + case(34): return MapOfString_Integer34; - case (35): + case(35): return MapOfString_Integer35; - case (36): + case(36): return MapOfString_Long36; - case (37): + case(37): return MapOfString_Long37; - case (38): + case(38): return MapOfString_Long38; - case (39): + case(39): return MapOfString_Short39; - case (40): + case(40): return MapOfString_Short40; - case (41): + case(41): return MapOfString_Short41; - case (42): + case(42): return MapOfString_Object42; - case (43): + case(43): return MapOfString_Object43; - case (44): + case(44): return MapOfString_SimpleClass45; - case (45): + case(45): return MapOfString_SimpleClass46; - case (46): + case(46): return MapOfString_SimpleInterface48; - case (47): + case(47): return MapOfString_SimpleInterface49; - case (48): + case(48): return MapOfString_String51; - case (49): + case(49): return MapOfString_String52; - case (50): + case(50): return MapOfString_Date54; - case (51): + case(51): return MapOfString_Date55; - case (52): + case(52): return MapOfString_Locale57; - case (53): + case(53): return MapOfString_Locale58; - case (54): + case(54): return MapOfString_BigDecimal60; - case (55): + case(55): return MapOfString_BigDecimal61; - case (56): + case(56): return MapOfString_BigInteger63; - case (57): + case(57): return MapOfString_BigInteger64; - case (58): + case(58): return MapOfString_Byte66; - case (59): + case(59): return MapOfString_Byte67; - case (60): + case(60): return MapOfString_Double69; - case (61): + case(61): return MapOfString_Double70; - case (62): + case(62): return MapOfString_Float72; - case (63): + case(63): return MapOfString_Float73; - case (64): + case(64): return MapOfString_Integer75; - case (65): + case(65): return MapOfString_Integer76; - case (66): + case(66): return MapOfString_Long78; - case (67): + case(67): return MapOfString_Long79; - case (68): + case(68): return MapOfString_Short81; - case (69): + case(69): return MapOfString_Short82; - case (70): + case(70): return MapOfString_Object84; - case (71): + case(71): return MapOfString_Object86; - case (72): + case(72): return MapOfString_SimpleClass87; - case (73): + case(73): return MapOfString_SimpleClass89; - case (74): + case(74): return MapOfString_SimpleInterface90; - case (75): + case(75): return MapOfString_SimpleInterface92; - case (76): + case(76): return MapOfString_String93; - case (77): + case(77): return MapOfString_String95; - case (78): + case(78): return MapOfString_Date96; - case (79): + case(79): return MapOfString_Date98; - case (80): + case(80): return MapOfString_Locale99; - case (81): + case(81): return MapOfString_Locale101; - case (82): + case(82): return MapOfString_BigDecimal102; - case (83): + case(83): return MapOfString_BigDecimal104; - case (84): + case(84): return MapOfString_BigInteger105; - case (85): + case(85): return MapOfString_BigInteger107; - case (86): + case(86): return MapOfString_Byte108; - case (87): + case(87): return MapOfString_Byte110; - case (88): + case(88): return MapOfString_Double111; - case (89): + case(89): return MapOfString_Double113; - case (90): + case(90): return MapOfString_Float114; - case (91): + case(91): return MapOfString_Float116; - case (92): + case(92): return MapOfString_Integer117; - case (93): + case(93): return MapOfString_Integer119; - case (94): + case(94): return MapOfString_Long120; - case (95): + case(95): return MapOfString_Long122; - case (96): + case(96): return MapOfString_Short123; - case (97): + case(97): return MapOfString_Short125; - case (98): + case(98): return MapOfString_SimpleEnum126; - case (99): + case(99): return MapOfString_SimpleEnum127; - case (100): + case(100): return MapOfString_SimpleEnum128; - case (101): + case(101): return MapOfString_SimpleEnum129; - case (102): + case(102): return MapOfString_SimpleEnum130; - case (103): + case(103): return MapOfString_SimpleEnum131; - case (104): + case(104): return MapOfString_SimpleEnum132; - case (105): + case(105): return MapOfString_SimpleEnum133; - case (106): + case(106): return MapOfString_SimpleEnum134; - case (107): + case(107): return MapOfString_SimpleEnum135; - case (108): + case(108): return MapOfString_SimpleEnum136; - case (109): + case(109): return MapOfString_SimpleEnum137; - case (110): + case(110): return MapOfString_SimpleEnum138; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, Map value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - MapOfString_Object0 = value; - break; - case (1): - MapOfString_Object1 = value; - break; - case (2): - MapOfString_Object2 = value; - break; - case (3): - MapOfString_SimpleClass3 = value; - break; - case (4): - MapOfString_SimpleClass4 = value; - break; - case (5): - MapOfString_SimpleClass5 = value; - break; - case (6): - MapOfString_SimpleInterface6 = value; - break; - case (7): - MapOfString_SimpleInterface7 = value; - break; - case (8): - MapOfString_SimpleInterface8 = value; - break; - case (9): - MapOfString_String9 = value; - break; - case (10): - MapOfString_String10 = value; - break; - case (11): - MapOfString_String11 = value; - break; - case (12): - MapOfString_Date12 = value; - break; - case (13): - MapOfString_Date13 = value; - break; - case (14): - MapOfString_Date14 = value; - break; - case (15): - MapOfString_Locale15 = value; - break; - case (16): - MapOfString_Locale16 = value; - break; - case (17): - MapOfString_Locale17 = value; - break; - case (18): - MapOfString_BigDecimal18 = value; - break; - case (19): - MapOfString_BigDecimal19 = value; - break; - case (20): - MapOfString_BigDecimal20 = value; - break; - case (21): - MapOfString_BigInteger21 = value; - break; - case (22): - MapOfString_BigInteger22 = value; - break; - case (23): - MapOfString_BigInteger23 = value; - break; - case (24): - MapOfString_Byte24 = value; - break; - case (25): - MapOfString_Byte25 = value; - break; - case (26): - MapOfString_Byte26 = value; - break; - case (27): - MapOfString_Double27 = value; - break; - case (28): - MapOfString_Double28 = value; - break; - case (29): - MapOfString_Double29 = value; - break; - case (30): - MapOfString_Float30 = value; - break; - case (31): - MapOfString_Float31 = value; - break; - case (32): - MapOfString_Float32 = value; - break; - case (33): - MapOfString_Integer33 = value; - break; - case (34): - MapOfString_Integer34 = value; - break; - case (35): - MapOfString_Integer35 = value; - break; - case (36): - MapOfString_Long36 = value; - break; - case (37): - MapOfString_Long37 = value; - break; - case (38): - MapOfString_Long38 = value; - break; - case (39): - MapOfString_Short39 = value; - break; - case (40): - MapOfString_Short40 = value; - break; - case (41): - MapOfString_Short41 = value; - break; - case (42): - MapOfString_Object42 = value; - break; - case (43): - MapOfString_Object43 = value; - break; - case (44): - MapOfString_SimpleClass45 = value; - break; - case (45): - MapOfString_SimpleClass46 = value; - break; - case (46): - MapOfString_SimpleInterface48 = value; - break; - case (47): - MapOfString_SimpleInterface49 = value; - break; - case (48): - MapOfString_String51 = value; - break; - case (49): - MapOfString_String52 = value; - break; - case (50): - MapOfString_Date54 = value; - break; - case (51): - MapOfString_Date55 = value; - break; - case (52): - MapOfString_Locale57 = value; - break; - case (53): - MapOfString_Locale58 = value; - break; - case (54): - MapOfString_BigDecimal60 = value; - break; - case (55): - MapOfString_BigDecimal61 = value; - break; - case (56): - MapOfString_BigInteger63 = value; - break; - case (57): - MapOfString_BigInteger64 = value; - break; - case (58): - MapOfString_Byte66 = value; - break; - case (59): - MapOfString_Byte67 = value; - break; - case (60): - MapOfString_Double69 = value; - break; - case (61): - MapOfString_Double70 = value; - break; - case (62): - MapOfString_Float72 = value; - break; - case (63): - MapOfString_Float73 = value; - break; - case (64): - MapOfString_Integer75 = value; - break; - case (65): - MapOfString_Integer76 = value; - break; - case (66): - MapOfString_Long78 = value; - break; - case (67): - MapOfString_Long79 = value; - break; - case (68): - MapOfString_Short81 = value; - break; - case (69): - MapOfString_Short82 = value; - break; - case (70): - MapOfString_Object84 = value; - break; - case (71): - MapOfString_Object86 = value; - break; - case (72): - MapOfString_SimpleClass87 = value; - break; - case (73): - MapOfString_SimpleClass89 = value; - break; - case (74): - MapOfString_SimpleInterface90 = value; - break; - case (75): - MapOfString_SimpleInterface92 = value; - break; - case (76): - MapOfString_String93 = value; - break; - case (77): - MapOfString_String95 = value; - break; - case (78): - MapOfString_Date96 = value; - break; - case (79): - MapOfString_Date98 = value; - break; - case (80): - MapOfString_Locale99 = value; - break; - case (81): - MapOfString_Locale101 = value; - break; - case (82): - MapOfString_BigDecimal102 = value; - break; - case (83): - MapOfString_BigDecimal104 = value; - break; - case (84): - MapOfString_BigInteger105 = value; - break; - case (85): - MapOfString_BigInteger107 = value; - break; - case (86): - MapOfString_Byte108 = value; - break; - case (87): - MapOfString_Byte110 = value; - break; - case (88): - MapOfString_Double111 = value; - break; - case (89): - MapOfString_Double113 = value; - break; - case (90): - MapOfString_Float114 = value; - break; - case (91): - MapOfString_Float116 = value; - break; - case (92): - MapOfString_Integer117 = value; - break; - case (93): - MapOfString_Integer119 = value; - break; - case (94): - MapOfString_Long120 = value; - break; - case (95): - MapOfString_Long122 = value; - break; - case (96): - MapOfString_Short123 = value; - break; - case (97): - MapOfString_Short125 = value; - break; - case (98): - MapOfString_SimpleEnum126 = value; - break; - case (99): - MapOfString_SimpleEnum127 = value; - break; - case (100): - MapOfString_SimpleEnum128 = value; - break; - case (101): - MapOfString_SimpleEnum129 = value; - break; - case (102): - MapOfString_SimpleEnum130 = value; - break; - case (103): - MapOfString_SimpleEnum131 = value; - break; - case (104): - MapOfString_SimpleEnum132 = value; - break; - case (105): - MapOfString_SimpleEnum133 = value; - break; - case (106): - MapOfString_SimpleEnum134 = value; - break; - case (107): - MapOfString_SimpleEnum135 = value; - break; - case (108): - MapOfString_SimpleEnum136 = value; - break; - case (109): - MapOfString_SimpleEnum137 = value; - break; - case (110): - MapOfString_SimpleEnum138 = value; - break; + public boolean set(int index,Map value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + MapOfString_Object0= value; + break; + case(1): + MapOfString_Object1= value; + break; + case(2): + MapOfString_Object2= value; + break; + case(3): + MapOfString_SimpleClass3= value; + break; + case(4): + MapOfString_SimpleClass4= value; + break; + case(5): + MapOfString_SimpleClass5= value; + break; + case(6): + MapOfString_SimpleInterface6= value; + break; + case(7): + MapOfString_SimpleInterface7= value; + break; + case(8): + MapOfString_SimpleInterface8= value; + break; + case(9): + MapOfString_String9= value; + break; + case(10): + MapOfString_String10= value; + break; + case(11): + MapOfString_String11= value; + break; + case(12): + MapOfString_Date12= value; + break; + case(13): + MapOfString_Date13= value; + break; + case(14): + MapOfString_Date14= value; + break; + case(15): + MapOfString_Locale15= value; + break; + case(16): + MapOfString_Locale16= value; + break; + case(17): + MapOfString_Locale17= value; + break; + case(18): + MapOfString_BigDecimal18= value; + break; + case(19): + MapOfString_BigDecimal19= value; + break; + case(20): + MapOfString_BigDecimal20= value; + break; + case(21): + MapOfString_BigInteger21= value; + break; + case(22): + MapOfString_BigInteger22= value; + break; + case(23): + MapOfString_BigInteger23= value; + break; + case(24): + MapOfString_Byte24= value; + break; + case(25): + MapOfString_Byte25= value; + break; + case(26): + MapOfString_Byte26= value; + break; + case(27): + MapOfString_Double27= value; + break; + case(28): + MapOfString_Double28= value; + break; + case(29): + MapOfString_Double29= value; + break; + case(30): + MapOfString_Float30= value; + break; + case(31): + MapOfString_Float31= value; + break; + case(32): + MapOfString_Float32= value; + break; + case(33): + MapOfString_Integer33= value; + break; + case(34): + MapOfString_Integer34= value; + break; + case(35): + MapOfString_Integer35= value; + break; + case(36): + MapOfString_Long36= value; + break; + case(37): + MapOfString_Long37= value; + break; + case(38): + MapOfString_Long38= value; + break; + case(39): + MapOfString_Short39= value; + break; + case(40): + MapOfString_Short40= value; + break; + case(41): + MapOfString_Short41= value; + break; + case(42): + MapOfString_Object42= value; + break; + case(43): + MapOfString_Object43= value; + break; + case(44): + MapOfString_SimpleClass45= value; + break; + case(45): + MapOfString_SimpleClass46= value; + break; + case(46): + MapOfString_SimpleInterface48= value; + break; + case(47): + MapOfString_SimpleInterface49= value; + break; + case(48): + MapOfString_String51= value; + break; + case(49): + MapOfString_String52= value; + break; + case(50): + MapOfString_Date54= value; + break; + case(51): + MapOfString_Date55= value; + break; + case(52): + MapOfString_Locale57= value; + break; + case(53): + MapOfString_Locale58= value; + break; + case(54): + MapOfString_BigDecimal60= value; + break; + case(55): + MapOfString_BigDecimal61= value; + break; + case(56): + MapOfString_BigInteger63= value; + break; + case(57): + MapOfString_BigInteger64= value; + break; + case(58): + MapOfString_Byte66= value; + break; + case(59): + MapOfString_Byte67= value; + break; + case(60): + MapOfString_Double69= value; + break; + case(61): + MapOfString_Double70= value; + break; + case(62): + MapOfString_Float72= value; + break; + case(63): + MapOfString_Float73= value; + break; + case(64): + MapOfString_Integer75= value; + break; + case(65): + MapOfString_Integer76= value; + break; + case(66): + MapOfString_Long78= value; + break; + case(67): + MapOfString_Long79= value; + break; + case(68): + MapOfString_Short81= value; + break; + case(69): + MapOfString_Short82= value; + break; + case(70): + MapOfString_Object84= value; + break; + case(71): + MapOfString_Object86= value; + break; + case(72): + MapOfString_SimpleClass87= value; + break; + case(73): + MapOfString_SimpleClass89= value; + break; + case(74): + MapOfString_SimpleInterface90= value; + break; + case(75): + MapOfString_SimpleInterface92= value; + break; + case(76): + MapOfString_String93= value; + break; + case(77): + MapOfString_String95= value; + break; + case(78): + MapOfString_Date96= value; + break; + case(79): + MapOfString_Date98= value; + break; + case(80): + MapOfString_Locale99= value; + break; + case(81): + MapOfString_Locale101= value; + break; + case(82): + MapOfString_BigDecimal102= value; + break; + case(83): + MapOfString_BigDecimal104= value; + break; + case(84): + MapOfString_BigInteger105= value; + break; + case(85): + MapOfString_BigInteger107= value; + break; + case(86): + MapOfString_Byte108= value; + break; + case(87): + MapOfString_Byte110= value; + break; + case(88): + MapOfString_Double111= value; + break; + case(89): + MapOfString_Double113= value; + break; + case(90): + MapOfString_Float114= value; + break; + case(91): + MapOfString_Float116= value; + break; + case(92): + MapOfString_Integer117= value; + break; + case(93): + MapOfString_Integer119= value; + break; + case(94): + MapOfString_Long120= value; + break; + case(95): + MapOfString_Long122= value; + break; + case(96): + MapOfString_Short123= value; + break; + case(97): + MapOfString_Short125= value; + break; + case(98): + MapOfString_SimpleEnum126= value; + break; + case(99): + MapOfString_SimpleEnum127= value; + break; + case(100): + MapOfString_SimpleEnum128= value; + break; + case(101): + MapOfString_SimpleEnum129= value; + break; + case(102): + MapOfString_SimpleEnum130= value; + break; + case(103): + MapOfString_SimpleEnum131= value; + break; + case(104): + MapOfString_SimpleEnum132= value; + break; + case(105): + MapOfString_SimpleEnum133= value; + break; + case(106): + MapOfString_SimpleEnum134= value; + break; + case(107): + MapOfString_SimpleEnum135= value; + break; + case(108): + MapOfString_SimpleEnum136= value; + break; + case(109): + MapOfString_SimpleEnum137= value; + break; + case(110): + MapOfString_SimpleEnum138= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/MapStringValueCollections.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/MapStringValueCollections.java index 188a9867b..322fcf742 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/MapStringValueCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/MapStringValueCollections.java @@ -5,22 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; import java.util.Map; -public class MapStringValueCollections { +public class MapStringValueCollections { public int identifier; public Map MapOfObject_String0; public Map MapOfObject_String1; @@ -127,680 +127,679 @@ public class MapStringValueCollections { public Map MapOfSimpleEnum_String128; public Map MapOfSimpleEnum_String129; - public static final String[] fieldSpecs = { - "public Map MapOfObject_String0", - "embedded-value=true public Map MapOfObject_String1", - "embedded-value=false public Map MapOfObject_String2", - "embedded-key=true public Map MapOfObject_String3", - "embedded-key=true embedded-value=true public Map MapOfObject_String4", - "embedded-key=false public Map MapOfObject_String6", - "embedded-key=false embedded-value=false public Map MapOfObject_String8", - "public Map MapOfSimpleClass_String9", - "embedded-value=true public Map MapOfSimpleClass_String10", - "embedded-value=false public Map MapOfSimpleClass_String11", - "embedded-key=true public Map MapOfSimpleClass_String12", - "embedded-key=true embedded-value=true public Map MapOfSimpleClass_String13", - "embedded-key=false public Map MapOfSimpleClass_String15", - "embedded-key=false embedded-value=false public Map MapOfSimpleClass_String17", - "public Map MapOfSimpleInterface_String18", - "embedded-value=true public Map MapOfSimpleInterface_String19", - "embedded-value=false public Map MapOfSimpleInterface_String20", - "embedded-key=true public Map MapOfSimpleInterface_String21", - "embedded-key=true embedded-value=true public Map MapOfSimpleInterface_String22", - "embedded-key=false public Map MapOfSimpleInterface_String24", - "embedded-key=false embedded-value=false public Map MapOfSimpleInterface_String26", - "public Map MapOfString_String27", - "embedded-value=true public Map MapOfString_String28", - "embedded-value=false public Map MapOfString_String29", - "embedded-key=true public Map MapOfString_String30", - "embedded-key=true embedded-value=true public Map MapOfString_String31", - "embedded-key=false public Map MapOfString_String33", - "embedded-key=false embedded-value=false public Map MapOfString_String35", - "public Map MapOfDate_String36", - "embedded-value=true public Map MapOfDate_String37", - "embedded-value=false public Map MapOfDate_String38", - "embedded-key=true public Map MapOfDate_String39", - "embedded-key=true embedded-value=true public Map MapOfDate_String40", - "embedded-key=false public Map MapOfDate_String42", - "embedded-key=false embedded-value=false public Map MapOfDate_String44", - "public Map MapOfBigDecimal_String45", - "embedded-value=true public Map MapOfBigDecimal_String46", - "embedded-value=false public Map MapOfBigDecimal_String47", - "embedded-key=true public Map MapOfBigDecimal_String48", - "embedded-key=true embedded-value=true public Map MapOfBigDecimal_String49", - "embedded-key=false public Map MapOfBigDecimal_String51", - "embedded-key=false embedded-value=false public Map MapOfBigDecimal_String53", - "public Map MapOfBigInteger_String54", - "embedded-value=true public Map MapOfBigInteger_String55", - "embedded-value=false public Map MapOfBigInteger_String56", - "embedded-key=true public Map MapOfBigInteger_String57", - "embedded-key=true embedded-value=true public Map MapOfBigInteger_String58", - "embedded-key=false public Map MapOfBigInteger_String60", - "embedded-key=false embedded-value=false public Map MapOfBigInteger_String62", - "public Map MapOfByte_String63", - "embedded-value=true public Map MapOfByte_String64", - "embedded-value=false public Map MapOfByte_String65", - "embedded-key=true public Map MapOfByte_String66", - "embedded-key=true embedded-value=true public Map MapOfByte_String67", - "embedded-key=false public Map MapOfByte_String69", - "embedded-key=false embedded-value=false public Map MapOfByte_String71", - "public Map MapOfDouble_String72", - "embedded-value=true public Map MapOfDouble_String73", - "embedded-value=false public Map MapOfDouble_String74", - "embedded-key=true public Map MapOfDouble_String75", - "embedded-key=true embedded-value=true public Map MapOfDouble_String76", - "embedded-key=false public Map MapOfDouble_String78", - "embedded-key=false embedded-value=false public Map MapOfDouble_String80", - "public Map MapOfFloat_String81", - "embedded-value=true public Map MapOfFloat_String82", - "embedded-value=false public Map MapOfFloat_String83", - "embedded-key=true public Map MapOfFloat_String84", - "embedded-key=true embedded-value=true public Map MapOfFloat_String85", - "embedded-key=false public Map MapOfFloat_String87", - "embedded-key=false embedded-value=false public Map MapOfFloat_String89", - "public Map MapOfInteger_String90", - "embedded-value=true public Map MapOfInteger_String91", - "embedded-value=false public Map MapOfInteger_String92", - "embedded-key=true public Map MapOfInteger_String93", - "embedded-key=true embedded-value=true public Map MapOfInteger_String94", - "embedded-key=false public Map MapOfInteger_String96", - "embedded-key=false embedded-value=false public Map MapOfInteger_String98", - "public Map MapOfLong_String99", - "embedded-value=true public Map MapOfLong_String100", - "embedded-value=false public Map MapOfLong_String101", - "embedded-key=true public Map MapOfLong_String102", - "embedded-key=true embedded-value=true public Map MapOfLong_String103", - "embedded-key=false public Map MapOfLong_String105", - "embedded-key=false embedded-value=false public Map MapOfLong_String107", - "public Map MapOfShort_String108", - "embedded-value=true public Map MapOfShort_String109", - "embedded-value=false public Map MapOfShort_String110", - "embedded-key=true public Map MapOfShort_String111", - "embedded-key=true embedded-value=true public Map MapOfShort_String112", - "embedded-key=false public Map MapOfShort_String114", - "embedded-key=false embedded-value=false public Map MapOfShort_String116", - "public Map MapOfSimpleEnum_String117", - "embedded-value=true public Map MapOfSimpleEnum_String118", - "embedded-value=false public Map MapOfSimpleEnum_String119", - "embedded-key=true public Map MapOfSimpleEnum_String120", - "embedded-key=true embedded-value=true public Map MapOfSimpleEnum_String121", - "embedded-key=false public Map MapOfSimpleEnum_String122", - "embedded-key=false embedded-value=false public Map MapOfSimpleEnum_String123", - "public Map MapOfSimpleEnum_String124", - "embedded-value=true public Map MapOfSimpleEnum_String124", - "embedded-value=false public Map MapOfSimpleEnum_String126", - "embedded-key=true public Map MapOfSimpleEnum_String127", - "embedded-key=true embedded-value=true public Map MapOfSimpleEnum_String128", - "embedded-key=false public Map MapOfSimpleEnum_String129" + public static final String [] fieldSpecs = { + "public Map MapOfObject_String0", + "embedded-value=true public Map MapOfObject_String1", + "embedded-value=false public Map MapOfObject_String2", + "embedded-key=true public Map MapOfObject_String3", + "embedded-key=true embedded-value=true public Map MapOfObject_String4", + "embedded-key=false public Map MapOfObject_String6", + "embedded-key=false embedded-value=false public Map MapOfObject_String8", + "public Map MapOfSimpleClass_String9", + "embedded-value=true public Map MapOfSimpleClass_String10", + "embedded-value=false public Map MapOfSimpleClass_String11", + "embedded-key=true public Map MapOfSimpleClass_String12", + "embedded-key=true embedded-value=true public Map MapOfSimpleClass_String13", + "embedded-key=false public Map MapOfSimpleClass_String15", + "embedded-key=false embedded-value=false public Map MapOfSimpleClass_String17", + "public Map MapOfSimpleInterface_String18", + "embedded-value=true public Map MapOfSimpleInterface_String19", + "embedded-value=false public Map MapOfSimpleInterface_String20", + "embedded-key=true public Map MapOfSimpleInterface_String21", + "embedded-key=true embedded-value=true public Map MapOfSimpleInterface_String22", + "embedded-key=false public Map MapOfSimpleInterface_String24", + "embedded-key=false embedded-value=false public Map MapOfSimpleInterface_String26", + "public Map MapOfString_String27", + "embedded-value=true public Map MapOfString_String28", + "embedded-value=false public Map MapOfString_String29", + "embedded-key=true public Map MapOfString_String30", + "embedded-key=true embedded-value=true public Map MapOfString_String31", + "embedded-key=false public Map MapOfString_String33", + "embedded-key=false embedded-value=false public Map MapOfString_String35", + "public Map MapOfDate_String36", + "embedded-value=true public Map MapOfDate_String37", + "embedded-value=false public Map MapOfDate_String38", + "embedded-key=true public Map MapOfDate_String39", + "embedded-key=true embedded-value=true public Map MapOfDate_String40", + "embedded-key=false public Map MapOfDate_String42", + "embedded-key=false embedded-value=false public Map MapOfDate_String44", + "public Map MapOfBigDecimal_String45", + "embedded-value=true public Map MapOfBigDecimal_String46", + "embedded-value=false public Map MapOfBigDecimal_String47", + "embedded-key=true public Map MapOfBigDecimal_String48", + "embedded-key=true embedded-value=true public Map MapOfBigDecimal_String49", + "embedded-key=false public Map MapOfBigDecimal_String51", + "embedded-key=false embedded-value=false public Map MapOfBigDecimal_String53", + "public Map MapOfBigInteger_String54", + "embedded-value=true public Map MapOfBigInteger_String55", + "embedded-value=false public Map MapOfBigInteger_String56", + "embedded-key=true public Map MapOfBigInteger_String57", + "embedded-key=true embedded-value=true public Map MapOfBigInteger_String58", + "embedded-key=false public Map MapOfBigInteger_String60", + "embedded-key=false embedded-value=false public Map MapOfBigInteger_String62", + "public Map MapOfByte_String63", + "embedded-value=true public Map MapOfByte_String64", + "embedded-value=false public Map MapOfByte_String65", + "embedded-key=true public Map MapOfByte_String66", + "embedded-key=true embedded-value=true public Map MapOfByte_String67", + "embedded-key=false public Map MapOfByte_String69", + "embedded-key=false embedded-value=false public Map MapOfByte_String71", + "public Map MapOfDouble_String72", + "embedded-value=true public Map MapOfDouble_String73", + "embedded-value=false public Map MapOfDouble_String74", + "embedded-key=true public Map MapOfDouble_String75", + "embedded-key=true embedded-value=true public Map MapOfDouble_String76", + "embedded-key=false public Map MapOfDouble_String78", + "embedded-key=false embedded-value=false public Map MapOfDouble_String80", + "public Map MapOfFloat_String81", + "embedded-value=true public Map MapOfFloat_String82", + "embedded-value=false public Map MapOfFloat_String83", + "embedded-key=true public Map MapOfFloat_String84", + "embedded-key=true embedded-value=true public Map MapOfFloat_String85", + "embedded-key=false public Map MapOfFloat_String87", + "embedded-key=false embedded-value=false public Map MapOfFloat_String89", + "public Map MapOfInteger_String90", + "embedded-value=true public Map MapOfInteger_String91", + "embedded-value=false public Map MapOfInteger_String92", + "embedded-key=true public Map MapOfInteger_String93", + "embedded-key=true embedded-value=true public Map MapOfInteger_String94", + "embedded-key=false public Map MapOfInteger_String96", + "embedded-key=false embedded-value=false public Map MapOfInteger_String98", + "public Map MapOfLong_String99", + "embedded-value=true public Map MapOfLong_String100", + "embedded-value=false public Map MapOfLong_String101", + "embedded-key=true public Map MapOfLong_String102", + "embedded-key=true embedded-value=true public Map MapOfLong_String103", + "embedded-key=false public Map MapOfLong_String105", + "embedded-key=false embedded-value=false public Map MapOfLong_String107", + "public Map MapOfShort_String108", + "embedded-value=true public Map MapOfShort_String109", + "embedded-value=false public Map MapOfShort_String110", + "embedded-key=true public Map MapOfShort_String111", + "embedded-key=true embedded-value=true public Map MapOfShort_String112", + "embedded-key=false public Map MapOfShort_String114", + "embedded-key=false embedded-value=false public Map MapOfShort_String116", + "public Map MapOfSimpleEnum_String117", + "embedded-value=true public Map MapOfSimpleEnum_String118", + "embedded-value=false public Map MapOfSimpleEnum_String119", + "embedded-key=true public Map MapOfSimpleEnum_String120", + "embedded-key=true embedded-value=true public Map MapOfSimpleEnum_String121", + "embedded-key=false public Map MapOfSimpleEnum_String122", + "embedded-key=false embedded-value=false public Map MapOfSimpleEnum_String123", + "public Map MapOfSimpleEnum_String124", + "embedded-value=true public Map MapOfSimpleEnum_String124", + "embedded-value=false public Map MapOfSimpleEnum_String126", + "embedded-key=true public Map MapOfSimpleEnum_String127", + "embedded-key=true embedded-value=true public Map MapOfSimpleEnum_String128", + "embedded-key=false public Map MapOfSimpleEnum_String129" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public Map get(int index) { - switch (index) { - case (0): + public Map get(int index) + { + switch (index) + { + case(0): return MapOfObject_String0; - case (1): + case(1): return MapOfObject_String1; - case (2): + case(2): return MapOfObject_String2; - case (3): + case(3): return MapOfObject_String3; - case (4): + case(4): return MapOfObject_String4; - case (5): + case(5): return MapOfObject_String6; - case (6): + case(6): return MapOfObject_String8; - case (7): + case(7): return MapOfSimpleClass_String9; - case (8): + case(8): return MapOfSimpleClass_String10; - case (9): + case(9): return MapOfSimpleClass_String11; - case (10): + case(10): return MapOfSimpleClass_String12; - case (11): + case(11): return MapOfSimpleClass_String13; - case (12): + case(12): return MapOfSimpleClass_String15; - case (13): + case(13): return MapOfSimpleClass_String17; - case (14): + case(14): return MapOfSimpleInterface_String18; - case (15): + case(15): return MapOfSimpleInterface_String19; - case (16): + case(16): return MapOfSimpleInterface_String20; - case (17): + case(17): return MapOfSimpleInterface_String21; - case (18): + case(18): return MapOfSimpleInterface_String22; - case (19): + case(19): return MapOfSimpleInterface_String24; - case (20): + case(20): return MapOfSimpleInterface_String26; - case (21): + case(21): return MapOfString_String27; - case (22): + case(22): return MapOfString_String28; - case (23): + case(23): return MapOfString_String29; - case (24): + case(24): return MapOfString_String30; - case (25): + case(25): return MapOfString_String31; - case (26): + case(26): return MapOfString_String33; - case (27): + case(27): return MapOfString_String35; - case (28): + case(28): return MapOfDate_String36; - case (29): + case(29): return MapOfDate_String37; - case (30): + case(30): return MapOfDate_String38; - case (31): + case(31): return MapOfDate_String39; - case (32): + case(32): return MapOfDate_String40; - case (33): + case(33): return MapOfDate_String42; - case (34): + case(34): return MapOfDate_String44; - case (35): + case(35): return MapOfBigDecimal_String45; - case (36): + case(36): return MapOfBigDecimal_String46; - case (37): + case(37): return MapOfBigDecimal_String47; - case (38): + case(38): return MapOfBigDecimal_String48; - case (39): + case(39): return MapOfBigDecimal_String49; - case (40): + case(40): return MapOfBigDecimal_String51; - case (41): + case(41): return MapOfBigDecimal_String53; - case (42): + case(42): return MapOfBigInteger_String54; - case (43): + case(43): return MapOfBigInteger_String55; - case (44): + case(44): return MapOfBigInteger_String56; - case (45): + case(45): return MapOfBigInteger_String57; - case (46): + case(46): return MapOfBigInteger_String58; - case (47): + case(47): return MapOfBigInteger_String60; - case (48): + case(48): return MapOfBigInteger_String62; - case (49): + case(49): return MapOfByte_String63; - case (50): + case(50): return MapOfByte_String64; - case (51): + case(51): return MapOfByte_String65; - case (52): + case(52): return MapOfByte_String66; - case (53): + case(53): return MapOfByte_String67; - case (54): + case(54): return MapOfByte_String69; - case (55): + case(55): return MapOfByte_String71; - case (56): + case(56): return MapOfDouble_String72; - case (57): + case(57): return MapOfDouble_String73; - case (58): + case(58): return MapOfDouble_String74; - case (59): + case(59): return MapOfDouble_String75; - case (60): + case(60): return MapOfDouble_String76; - case (61): + case(61): return MapOfDouble_String78; - case (62): + case(62): return MapOfDouble_String80; - case (63): + case(63): return MapOfFloat_String81; - case (64): + case(64): return MapOfFloat_String82; - case (65): + case(65): return MapOfFloat_String83; - case (66): + case(66): return MapOfFloat_String84; - case (67): + case(67): return MapOfFloat_String85; - case (68): + case(68): return MapOfFloat_String87; - case (69): + case(69): return MapOfFloat_String89; - case (70): + case(70): return MapOfInteger_String90; - case (71): + case(71): return MapOfInteger_String91; - case (72): + case(72): return MapOfInteger_String92; - case (73): + case(73): return MapOfInteger_String93; - case (74): + case(74): return MapOfInteger_String94; - case (75): + case(75): return MapOfInteger_String96; - case (76): + case(76): return MapOfInteger_String98; - case (77): + case(77): return MapOfLong_String99; - case (78): + case(78): return MapOfLong_String100; - case (79): + case(79): return MapOfLong_String101; - case (80): + case(80): return MapOfLong_String102; - case (81): + case(81): return MapOfLong_String103; - case (82): + case(82): return MapOfLong_String105; - case (83): + case(83): return MapOfLong_String107; - case (84): + case(84): return MapOfShort_String108; - case (85): + case(85): return MapOfShort_String109; - case (86): + case(86): return MapOfShort_String110; - case (87): + case(87): return MapOfShort_String111; - case (88): + case(88): return MapOfShort_String112; - case (89): + case(89): return MapOfShort_String114; - case (90): + case(90): return MapOfShort_String116; - case (91): + case(91): return MapOfSimpleEnum_String117; - case (92): + case(92): return MapOfSimpleEnum_String118; - case (93): + case(93): return MapOfSimpleEnum_String119; - case (94): + case(94): return MapOfSimpleEnum_String120; - case (95): + case(95): return MapOfSimpleEnum_String121; - case (96): + case(96): return MapOfSimpleEnum_String122; - case (97): + case(97): return MapOfSimpleEnum_String123; - case (98): + case(98): return MapOfSimpleEnum_String124; - case (99): + case(99): return MapOfSimpleEnum_String125; - case (100): + case(100): return MapOfSimpleEnum_String126; - case (101): + case(101): return MapOfSimpleEnum_String127; - case (102): + case(102): return MapOfSimpleEnum_String128; - case (103): + case(103): return MapOfSimpleEnum_String129; default: throw new IndexOutOfBoundsException("Bad index " + index); } } - - public boolean set(int index, Map value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - MapOfObject_String0 = value; - break; - case (1): - MapOfObject_String1 = value; - break; - case (2): - MapOfObject_String2 = value; - break; - case (3): - MapOfObject_String3 = value; - break; - case (4): - MapOfObject_String4 = value; - break; - case (5): - MapOfObject_String6 = value; - break; - case (6): - MapOfObject_String8 = value; - break; - case (7): - MapOfSimpleClass_String9 = value; - break; - case (8): - MapOfSimpleClass_String10 = value; - break; - case (9): - MapOfSimpleClass_String11 = value; - break; - case (10): - MapOfSimpleClass_String12 = value; - break; - case (11): - MapOfSimpleClass_String13 = value; - break; - case (12): - MapOfSimpleClass_String15 = value; - break; - case (13): - MapOfSimpleClass_String17 = value; - break; - case (14): - MapOfSimpleInterface_String18 = value; - break; - case (15): - MapOfSimpleInterface_String19 = value; - break; - case (16): - MapOfSimpleInterface_String20 = value; - break; - case (17): - MapOfSimpleInterface_String21 = value; - break; - case (18): - MapOfSimpleInterface_String22 = value; - break; - case (19): - MapOfSimpleInterface_String24 = value; - break; - case (20): - MapOfSimpleInterface_String26 = value; - break; - case (21): - MapOfString_String27 = value; - break; - case (22): - MapOfString_String28 = value; - break; - case (23): - MapOfString_String29 = value; - break; - case (24): - MapOfString_String30 = value; - break; - case (25): - MapOfString_String31 = value; - break; - case (26): - MapOfString_String33 = value; - break; - case (27): - MapOfString_String35 = value; - break; - case (28): - MapOfDate_String36 = value; - break; - case (29): - MapOfDate_String37 = value; - break; - case (30): - MapOfDate_String38 = value; - break; - case (31): - MapOfDate_String39 = value; - break; - case (32): - MapOfDate_String40 = value; - break; - case (33): - MapOfDate_String42 = value; - break; - case (34): - MapOfDate_String44 = value; - break; - case (35): - MapOfBigDecimal_String45 = value; - break; - case (36): - MapOfBigDecimal_String46 = value; - break; - case (37): - MapOfBigDecimal_String47 = value; - break; - case (38): - MapOfBigDecimal_String48 = value; - break; - case (39): - MapOfBigDecimal_String49 = value; - break; - case (40): - MapOfBigDecimal_String51 = value; - break; - case (41): - MapOfBigDecimal_String53 = value; - break; - case (42): - MapOfBigInteger_String54 = value; - break; - case (43): - MapOfBigInteger_String55 = value; - break; - case (44): - MapOfBigInteger_String56 = value; - break; - case (45): - MapOfBigInteger_String57 = value; - break; - case (46): - MapOfBigInteger_String58 = value; - break; - case (47): - MapOfBigInteger_String60 = value; - break; - case (48): - MapOfBigInteger_String62 = value; - break; - case (49): - MapOfByte_String63 = value; - break; - case (50): - MapOfByte_String64 = value; - break; - case (51): - MapOfByte_String65 = value; - break; - case (52): - MapOfByte_String66 = value; - break; - case (53): - MapOfByte_String67 = value; - break; - case (54): - MapOfByte_String69 = value; - break; - case (55): - MapOfByte_String71 = value; - break; - case (56): - MapOfDouble_String72 = value; - break; - case (57): - MapOfDouble_String73 = value; - break; - case (58): - MapOfDouble_String74 = value; - break; - case (59): - MapOfDouble_String75 = value; - break; - case (60): - MapOfDouble_String76 = value; - break; - case (61): - MapOfDouble_String78 = value; - break; - case (62): - MapOfDouble_String80 = value; - break; - case (63): - MapOfFloat_String81 = value; - break; - case (64): - MapOfFloat_String82 = value; - break; - case (65): - MapOfFloat_String83 = value; - break; - case (66): - MapOfFloat_String84 = value; - break; - case (67): - MapOfFloat_String85 = value; - break; - case (68): - MapOfFloat_String87 = value; - break; - case (69): - MapOfFloat_String89 = value; - break; - case (70): - MapOfInteger_String90 = value; - break; - case (71): - MapOfInteger_String91 = value; - break; - case (72): - MapOfInteger_String92 = value; - break; - case (73): - MapOfInteger_String93 = value; - break; - case (74): - MapOfInteger_String94 = value; - break; - case (75): - MapOfInteger_String96 = value; - break; - case (76): - MapOfInteger_String98 = value; - break; - case (77): - MapOfLong_String99 = value; - break; - case (78): - MapOfLong_String100 = value; - break; - case (79): - MapOfLong_String101 = value; - break; - case (80): - MapOfLong_String102 = value; - break; - case (81): - MapOfLong_String103 = value; - break; - case (82): - MapOfLong_String105 = value; - break; - case (83): - MapOfLong_String107 = value; - break; - case (84): - MapOfShort_String108 = value; - break; - case (85): - MapOfShort_String109 = value; - break; - case (86): - MapOfShort_String110 = value; - break; - case (87): - MapOfShort_String111 = value; - break; - case (88): - MapOfShort_String112 = value; - break; - case (89): - MapOfShort_String114 = value; - break; - case (90): - MapOfShort_String116 = value; - break; - case (91): - MapOfSimpleEnum_String117 = value; - break; - case (92): - MapOfSimpleEnum_String118 = value; - break; - case (93): - MapOfSimpleEnum_String119 = value; - break; - case (94): - MapOfSimpleEnum_String120 = value; - break; - case (95): - MapOfSimpleEnum_String121 = value; - break; - case (96): - MapOfSimpleEnum_String122 = value; - break; - case (97): - MapOfSimpleEnum_String123 = value; - break; - case (98): - MapOfSimpleEnum_String124 = value; - break; - case (99): - MapOfSimpleEnum_String125 = value; - break; - case (100): - MapOfSimpleEnum_String126 = value; - break; - case (101): - MapOfSimpleEnum_String127 = value; - break; - case (102): - MapOfSimpleEnum_String128 = value; - break; - case (103): - MapOfSimpleEnum_String129 = value; - break; + public boolean set(int index,Map value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + MapOfObject_String0= value; + break; + case(1): + MapOfObject_String1= value; + break; + case(2): + MapOfObject_String2= value; + break; + case(3): + MapOfObject_String3= value; + break; + case(4): + MapOfObject_String4= value; + break; + case(5): + MapOfObject_String6= value; + break; + case(6): + MapOfObject_String8= value; + break; + case(7): + MapOfSimpleClass_String9= value; + break; + case(8): + MapOfSimpleClass_String10= value; + break; + case(9): + MapOfSimpleClass_String11= value; + break; + case(10): + MapOfSimpleClass_String12= value; + break; + case(11): + MapOfSimpleClass_String13= value; + break; + case(12): + MapOfSimpleClass_String15= value; + break; + case(13): + MapOfSimpleClass_String17= value; + break; + case(14): + MapOfSimpleInterface_String18= value; + break; + case(15): + MapOfSimpleInterface_String19= value; + break; + case(16): + MapOfSimpleInterface_String20= value; + break; + case(17): + MapOfSimpleInterface_String21= value; + break; + case(18): + MapOfSimpleInterface_String22= value; + break; + case(19): + MapOfSimpleInterface_String24= value; + break; + case(20): + MapOfSimpleInterface_String26= value; + break; + case(21): + MapOfString_String27= value; + break; + case(22): + MapOfString_String28= value; + break; + case(23): + MapOfString_String29= value; + break; + case(24): + MapOfString_String30= value; + break; + case(25): + MapOfString_String31= value; + break; + case(26): + MapOfString_String33= value; + break; + case(27): + MapOfString_String35= value; + break; + case(28): + MapOfDate_String36= value; + break; + case(29): + MapOfDate_String37= value; + break; + case(30): + MapOfDate_String38= value; + break; + case(31): + MapOfDate_String39= value; + break; + case(32): + MapOfDate_String40= value; + break; + case(33): + MapOfDate_String42= value; + break; + case(34): + MapOfDate_String44= value; + break; + case(35): + MapOfBigDecimal_String45= value; + break; + case(36): + MapOfBigDecimal_String46= value; + break; + case(37): + MapOfBigDecimal_String47= value; + break; + case(38): + MapOfBigDecimal_String48= value; + break; + case(39): + MapOfBigDecimal_String49= value; + break; + case(40): + MapOfBigDecimal_String51= value; + break; + case(41): + MapOfBigDecimal_String53= value; + break; + case(42): + MapOfBigInteger_String54= value; + break; + case(43): + MapOfBigInteger_String55= value; + break; + case(44): + MapOfBigInteger_String56= value; + break; + case(45): + MapOfBigInteger_String57= value; + break; + case(46): + MapOfBigInteger_String58= value; + break; + case(47): + MapOfBigInteger_String60= value; + break; + case(48): + MapOfBigInteger_String62= value; + break; + case(49): + MapOfByte_String63= value; + break; + case(50): + MapOfByte_String64= value; + break; + case(51): + MapOfByte_String65= value; + break; + case(52): + MapOfByte_String66= value; + break; + case(53): + MapOfByte_String67= value; + break; + case(54): + MapOfByte_String69= value; + break; + case(55): + MapOfByte_String71= value; + break; + case(56): + MapOfDouble_String72= value; + break; + case(57): + MapOfDouble_String73= value; + break; + case(58): + MapOfDouble_String74= value; + break; + case(59): + MapOfDouble_String75= value; + break; + case(60): + MapOfDouble_String76= value; + break; + case(61): + MapOfDouble_String78= value; + break; + case(62): + MapOfDouble_String80= value; + break; + case(63): + MapOfFloat_String81= value; + break; + case(64): + MapOfFloat_String82= value; + break; + case(65): + MapOfFloat_String83= value; + break; + case(66): + MapOfFloat_String84= value; + break; + case(67): + MapOfFloat_String85= value; + break; + case(68): + MapOfFloat_String87= value; + break; + case(69): + MapOfFloat_String89= value; + break; + case(70): + MapOfInteger_String90= value; + break; + case(71): + MapOfInteger_String91= value; + break; + case(72): + MapOfInteger_String92= value; + break; + case(73): + MapOfInteger_String93= value; + break; + case(74): + MapOfInteger_String94= value; + break; + case(75): + MapOfInteger_String96= value; + break; + case(76): + MapOfInteger_String98= value; + break; + case(77): + MapOfLong_String99= value; + break; + case(78): + MapOfLong_String100= value; + break; + case(79): + MapOfLong_String101= value; + break; + case(80): + MapOfLong_String102= value; + break; + case(81): + MapOfLong_String103= value; + break; + case(82): + MapOfLong_String105= value; + break; + case(83): + MapOfLong_String107= value; + break; + case(84): + MapOfShort_String108= value; + break; + case(85): + MapOfShort_String109= value; + break; + case(86): + MapOfShort_String110= value; + break; + case(87): + MapOfShort_String111= value; + break; + case(88): + MapOfShort_String112= value; + break; + case(89): + MapOfShort_String114= value; + break; + case(90): + MapOfShort_String116= value; + break; + case(91): + MapOfSimpleEnum_String117= value; + break; + case(92): + MapOfSimpleEnum_String118= value; + break; + case(93): + MapOfSimpleEnum_String119= value; + break; + case(94): + MapOfSimpleEnum_String120= value; + break; + case(95): + MapOfSimpleEnum_String121= value; + break; + case(96): + MapOfSimpleEnum_String122= value; + break; + case(97): + MapOfSimpleEnum_String123= value; + break; + case(98): + MapOfSimpleEnum_String124= value; + break; + case(99): + MapOfSimpleEnum_String125= value; + break; + case(100): + MapOfSimpleEnum_String126= value; + break; + case(101): + MapOfSimpleEnum_String127= value; + break; + case(102): + MapOfSimpleEnum_String128= value; + break; + case(103): + MapOfSimpleEnum_String129= value; + break; default: throw new IndexOutOfBoundsException("Bad index " + index); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/SetCollections.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/SetCollections.java index 50c5e44e3..0d4cee6d5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/SetCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/SetCollections.java @@ -5,22 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; import java.util.Set; -public class SetCollections { +public class SetCollections { public int identifier; public Set SetOfObject0; public Set SetOfObject1; @@ -66,314 +66,313 @@ public class SetCollections { public Set SetOfShort41; public Set SetOfSimpleClass42; - public static final String[] fieldSpecs = { - "public Set SetOfObject0", - "embedded-element=true public Set SetOfObject1", - "embedded-element=false public Set SetOfObject2", - "public Set SetOfSimpleClass3", - "embedded-element=true public Set SetOfSimpleClass4", - "embedded-element=false public Set SetOfSimpleClass5", - "public Set SetOfSimpleInterface6", - "embedded-element=true public Set SetOfSimpleInterface7", - "embedded-element=false public Set SetOfSimpleInterface8", - "public Set SetOfString9", - "embedded-element=true public Set SetOfString10", - "embedded-element=false public Set SetOfString11", - "public Set SetOfDate12", - "embedded-element=true public Set SetOfDate13", - "embedded-element=false public Set SetOfDate14", - "public Set SetOfLocale15", - "embedded-element=true public Set SetOfLocale16", - "embedded-element=false public Set SetOfLocale17", - "public Set SetOfBigDecimal18", - "embedded-element=true public Set SetOfBigDecimal19", - "embedded-element=false public Set SetOfBigDecimal20", - "public Set SetOfBigInteger21", - "embedded-element=true public Set SetOfBigInteger22", - "embedded-element=false public Set SetOfBigInteger23", - "public Set SetOfByte24", - "embedded-element=true public Set SetOfByte25", - "embedded-element=false public Set SetOfByte26", - "public Set SetOfDouble27", - "embedded-element=true public Set SetOfDouble28", - "embedded-element=false public Set SetOfDouble29", - "public Set SetOfFloat30", - "embedded-element=true public Set SetOfFloat31", - "embedded-element=false public Set SetOfFloat32", - "public Set SetOfInteger33", - "embedded-element=true public Set SetOfInteger34", - "embedded-element=false public Set SetOfInteger35", - "public Set SetOfLong36", - "embedded-element=true public Set SetOfLong37", - "embedded-element=false public Set SetOfLong38", - "public Set SetOfShort39", - "embedded-element=true public Set SetOfShort40", - "embedded-element=false public Set SetOfShort41", - "serialized=true public Set SetOfSimpleClass42" + public static final String [] fieldSpecs = { + "public Set SetOfObject0", + "embedded-element=true public Set SetOfObject1", + "embedded-element=false public Set SetOfObject2", + "public Set SetOfSimpleClass3", + "embedded-element=true public Set SetOfSimpleClass4", + "embedded-element=false public Set SetOfSimpleClass5", + "public Set SetOfSimpleInterface6", + "embedded-element=true public Set SetOfSimpleInterface7", + "embedded-element=false public Set SetOfSimpleInterface8", + "public Set SetOfString9", + "embedded-element=true public Set SetOfString10", + "embedded-element=false public Set SetOfString11", + "public Set SetOfDate12", + "embedded-element=true public Set SetOfDate13", + "embedded-element=false public Set SetOfDate14", + "public Set SetOfLocale15", + "embedded-element=true public Set SetOfLocale16", + "embedded-element=false public Set SetOfLocale17", + "public Set SetOfBigDecimal18", + "embedded-element=true public Set SetOfBigDecimal19", + "embedded-element=false public Set SetOfBigDecimal20", + "public Set SetOfBigInteger21", + "embedded-element=true public Set SetOfBigInteger22", + "embedded-element=false public Set SetOfBigInteger23", + "public Set SetOfByte24", + "embedded-element=true public Set SetOfByte25", + "embedded-element=false public Set SetOfByte26", + "public Set SetOfDouble27", + "embedded-element=true public Set SetOfDouble28", + "embedded-element=false public Set SetOfDouble29", + "public Set SetOfFloat30", + "embedded-element=true public Set SetOfFloat31", + "embedded-element=false public Set SetOfFloat32", + "public Set SetOfInteger33", + "embedded-element=true public Set SetOfInteger34", + "embedded-element=false public Set SetOfInteger35", + "public Set SetOfLong36", + "embedded-element=true public Set SetOfLong37", + "embedded-element=false public Set SetOfLong38", + "public Set SetOfShort39", + "embedded-element=true public Set SetOfShort40", + "embedded-element=false public Set SetOfShort41", + "serialized=true public Set SetOfSimpleClass42" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public Set get(int index) { - switch (index) { - case (0): + public Set get(int index) + { + switch (index) + { + case(0): return SetOfObject0; - case (1): + case(1): return SetOfObject1; - case (2): + case(2): return SetOfObject2; - case (3): + case(3): return SetOfSimpleClass3; - case (4): + case(4): return SetOfSimpleClass4; - case (5): + case(5): return SetOfSimpleClass5; - case (6): + case(6): return SetOfSimpleInterface6; - case (7): + case(7): return SetOfSimpleInterface7; - case (8): + case(8): return SetOfSimpleInterface8; - case (9): + case(9): return SetOfString9; - case (10): + case(10): return SetOfString10; - case (11): + case(11): return SetOfString11; - case (12): + case(12): return SetOfDate12; - case (13): + case(13): return SetOfDate13; - case (14): + case(14): return SetOfDate14; - case (15): + case(15): return SetOfLocale15; - case (16): + case(16): return SetOfLocale16; - case (17): + case(17): return SetOfLocale17; - case (18): + case(18): return SetOfBigDecimal18; - case (19): + case(19): return SetOfBigDecimal19; - case (20): + case(20): return SetOfBigDecimal20; - case (21): + case(21): return SetOfBigInteger21; - case (22): + case(22): return SetOfBigInteger22; - case (23): + case(23): return SetOfBigInteger23; - case (24): + case(24): return SetOfByte24; - case (25): + case(25): return SetOfByte25; - case (26): + case(26): return SetOfByte26; - case (27): + case(27): return SetOfDouble27; - case (28): + case(28): return SetOfDouble28; - case (29): + case(29): return SetOfDouble29; - case (30): + case(30): return SetOfFloat30; - case (31): + case(31): return SetOfFloat31; - case (32): + case(32): return SetOfFloat32; - case (33): + case(33): return SetOfInteger33; - case (34): + case(34): return SetOfInteger34; - case (35): + case(35): return SetOfInteger35; - case (36): + case(36): return SetOfLong36; - case (37): + case(37): return SetOfLong37; - case (38): + case(38): return SetOfLong38; - case (39): + case(39): return SetOfShort39; - case (40): + case(40): return SetOfShort40; - case (41): + case(41): return SetOfShort41; - case (42): + case(42): return SetOfSimpleClass42; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, Set value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - SetOfObject0 = value; - break; - case (1): - SetOfObject1 = value; - break; - case (2): - SetOfObject2 = value; - break; - case (3): - SetOfSimpleClass3 = value; - break; - case (4): - SetOfSimpleClass4 = value; - break; - case (5): - SetOfSimpleClass5 = value; - break; - case (6): - SetOfSimpleInterface6 = value; - break; - case (7): - SetOfSimpleInterface7 = value; - break; - case (8): - SetOfSimpleInterface8 = value; - break; - case (9): - SetOfString9 = value; - break; - case (10): - SetOfString10 = value; - break; - case (11): - SetOfString11 = value; - break; - case (12): - SetOfDate12 = value; - break; - case (13): - SetOfDate13 = value; - break; - case (14): - SetOfDate14 = value; - break; - case (15): - SetOfLocale15 = value; - break; - case (16): - SetOfLocale16 = value; - break; - case (17): - SetOfLocale17 = value; - break; - case (18): - SetOfBigDecimal18 = value; - break; - case (19): - SetOfBigDecimal19 = value; - break; - case (20): - SetOfBigDecimal20 = value; - break; - case (21): - SetOfBigInteger21 = value; - break; - case (22): - SetOfBigInteger22 = value; - break; - case (23): - SetOfBigInteger23 = value; - break; - case (24): - SetOfByte24 = value; - break; - case (25): - SetOfByte25 = value; - break; - case (26): - SetOfByte26 = value; - break; - case (27): - SetOfDouble27 = value; - break; - case (28): - SetOfDouble28 = value; - break; - case (29): - SetOfDouble29 = value; - break; - case (30): - SetOfFloat30 = value; - break; - case (31): - SetOfFloat31 = value; - break; - case (32): - SetOfFloat32 = value; - break; - case (33): - SetOfInteger33 = value; - break; - case (34): - SetOfInteger34 = value; - break; - case (35): - SetOfInteger35 = value; - break; - case (36): - SetOfLong36 = value; - break; - case (37): - SetOfLong37 = value; - break; - case (38): - SetOfLong38 = value; - break; - case (39): - SetOfShort39 = value; - break; - case (40): - SetOfShort40 = value; - break; - case (41): - SetOfShort41 = value; - break; - case (42): - SetOfSimpleClass42 = value; - break; + public boolean set(int index,Set value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + SetOfObject0= value; + break; + case(1): + SetOfObject1= value; + break; + case(2): + SetOfObject2= value; + break; + case(3): + SetOfSimpleClass3= value; + break; + case(4): + SetOfSimpleClass4= value; + break; + case(5): + SetOfSimpleClass5= value; + break; + case(6): + SetOfSimpleInterface6= value; + break; + case(7): + SetOfSimpleInterface7= value; + break; + case(8): + SetOfSimpleInterface8= value; + break; + case(9): + SetOfString9= value; + break; + case(10): + SetOfString10= value; + break; + case(11): + SetOfString11= value; + break; + case(12): + SetOfDate12= value; + break; + case(13): + SetOfDate13= value; + break; + case(14): + SetOfDate14= value; + break; + case(15): + SetOfLocale15= value; + break; + case(16): + SetOfLocale16= value; + break; + case(17): + SetOfLocale17= value; + break; + case(18): + SetOfBigDecimal18= value; + break; + case(19): + SetOfBigDecimal19= value; + break; + case(20): + SetOfBigDecimal20= value; + break; + case(21): + SetOfBigInteger21= value; + break; + case(22): + SetOfBigInteger22= value; + break; + case(23): + SetOfBigInteger23= value; + break; + case(24): + SetOfByte24= value; + break; + case(25): + SetOfByte25= value; + break; + case(26): + SetOfByte26= value; + break; + case(27): + SetOfDouble27= value; + break; + case(28): + SetOfDouble28= value; + break; + case(29): + SetOfDouble29= value; + break; + case(30): + SetOfFloat30= value; + break; + case(31): + SetOfFloat31= value; + break; + case(32): + SetOfFloat32= value; + break; + case(33): + SetOfInteger33= value; + break; + case(34): + SetOfInteger34= value; + break; + case(35): + SetOfInteger35= value; + break; + case(36): + SetOfLong36= value; + break; + case(37): + SetOfLong37= value; + break; + case(38): + SetOfLong38= value; + break; + case(39): + SetOfShort39= value; + break; + case(40): + SetOfShort40= value; + break; + case(41): + SetOfShort41= value; + break; + case(42): + SetOfSimpleClass42= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/SimpleClass.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/SimpleClass.java index c8fed1995..75d2d7343 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/SimpleClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/SimpleClass.java @@ -5,113 +5,117 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; -import java.io.Serializable; import java.util.Date; +import java.io.Serializable; public class SimpleClass implements Serializable, SimpleInterface, Comparable { - private static long counter = new Date().getTime(); - - private static long newId() { - synchronized (SimpleClass.class) { - return counter++; + private static long counter = new Date().getTime(); + private static long newId() { + synchronized (SimpleClass.class) { + return counter++; + } } - } - - private long id = newId(); - private int intField = 0; + private long id = newId(); + private int intField=0; private String stringField = new String("Test"); - - public SimpleClass() {} - ; - - public SimpleClass(int intField, String stringField) { + public SimpleClass(){}; + public SimpleClass(int intField, String stringField) + { this.intField = intField; this.stringField = stringField; } - public void setIntValue(int intField) { + public void setIntValue(int intField) + { this.intField = intField; } - public int getIntValue() { + public int getIntValue() + { return intField; } - public void setStringValue(String stringField) { + public void setStringValue(String stringField) + { this.stringField = stringField; } - public String getStringValue() { + public String getStringValue() + { return stringField; } - public boolean equals(Object obj) { - if (!(obj instanceof SimpleClass)) return false; + public boolean equals(Object obj) + { + if(!(obj instanceof SimpleClass)) + return false; - if (intField == ((SimpleClass) obj).getIntValue() - && stringField.equals(((SimpleClass) obj).getStringValue())) return true; - else return false; + if (intField == ((SimpleClass)obj).getIntValue() + && stringField.equals(((SimpleClass)obj).getStringValue())) + return true; + else + return false; } - public int hashCode() { + public int hashCode() + { return intField ^ stringField.hashCode(); } - public int compareTo(Object p) { - SimpleClass sc = (SimpleClass) p; - if (intField < sc.intField) return -1; - if (intField > sc.intField) return 1; - return stringField.compareTo(sc.stringField); - } - - public static class Oid implements Serializable, Comparable { - public long id; - - public Oid() {} - - public Oid(String s) { - id = Integer.parseInt(justTheId(s)); - } - - public String toString() { - return this.getClass().getName() + ": " + id; - } - - public int hashCode() { - return (int) id; - } - - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.id == this.id; - } - return false; - } - - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - - public int compareTo(Object p) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) p; - if (id < other.id) return -1; - if (id > other.id) return 1; - return 0; - } + public int compareTo(Object p) + { + SimpleClass sc = (SimpleClass) p; + if( intField < sc.intField ) return -1; + if( intField > sc.intField ) return 1; + return stringField.compareTo(sc.stringField); } + + public static class Oid implements Serializable, Comparable { + public long id; + + public Oid() { + } + + public Oid(String s) { id = Integer.parseInt(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + id;} + + public int hashCode() { return (int)id ; } + + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.id == this.id; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + public int compareTo(Object p){ + // may throw ClassCastException which the user must handle + Oid other = (Oid) p; + if( id < other.id ) return -1; + if( id > other.id ) return 1; + return 0; + } + + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/SimpleEnum.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/SimpleEnum.java index 61e7d7ec2..e59eaf2d2 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/SimpleEnum.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/SimpleEnum.java @@ -15,117 +15,116 @@ * limitations under the License. */ + + package org.apache.jdo.tck.pc.fieldtypes; +import java.util.Date; import java.io.Serializable; public enum SimpleEnum { - AL("ALABAMA"), - AK("ALASKA"), - AS("AMERICAN SAMOA"), - AZ("ARIZONA"), - AR("ARKANSAS"), - CA("CALIFORNIA"), - CO("COLORADO"), - CT("CONNECTICUT"), - DE("DELAWARE"), - DC("DISTRICT OF COLUMBIA"), - FM("FEDERATED STATES OF MICRONESIA"), - FL("FLORIDA"), - GA("GEORGIA"), - GU("GUAM"), - HI("HAWAII"), - ID("IDAHO"), - IL("ILLINOIS"), - IN("INDIANA"), - IA("IOWA"), - KS("KANSAS"), - KY("KENTUCKY"), - LA("LOUISIANA"), - ME("MAINE"), - MH("MARSHALL ISLANDS"), - MD("MARYLAND"), - MA("MASSACHUSETTS"), - MI("MICHIGAN"), - MN("MINNESOTA"), - MS("MISSISSIPPI"), - MO("MISSOURI"), - MT("MONTANA"), - NE("NEBRASKA"), - NV("NEVADA"), - NH("NEW HAMPSHIRE"), - NJ("NEW JERSEY"), - NM("NEW MEXICO"), - NY("NEW YORK"), - NC("NORTH CAROLINA"), - ND("NORTH DAKOTA"), - MP("NORTHERN MARIANA ISLANDS"), - OH("OHIO"), - OK("OKLAHOMA"), - OR("OREGON"), - PW("PALAU"), - PA("PENNSYLVANIA"), - PR("PUERTO RICO"), - RI("RHODE ISLAND"), - SC("SOUTH CAROLINA"), - SD("SOUTH DAKOTA"), - TN("TENNESSEE"), - TX("TEXAS"), - UT("UTAH"), - VT("VERMONT"), - VI("VIRGIN ISLANDS"), - VA("VIRGINIA"), - WA("WASHINGTON"), - WV("WEST VIRGINIA"), - WI("WISCONSIN"), - WY("WYOMING"); - - String sname; - - SimpleEnum(String s) { - sname = s; - } - - public String toString() { - return sname; - } - ; - - public static class Oid implements Serializable, Comparable { - public long id; - - public Oid() {} - - public Oid(String s) { - id = Integer.parseInt(justTheId(s)); + +AL("ALABAMA"), +AK("ALASKA"), +AS("AMERICAN SAMOA"), +AZ("ARIZONA"), +AR("ARKANSAS"), +CA("CALIFORNIA"), +CO("COLORADO"), +CT("CONNECTICUT"), +DE("DELAWARE"), +DC("DISTRICT OF COLUMBIA"), +FM("FEDERATED STATES OF MICRONESIA"), +FL("FLORIDA"), +GA("GEORGIA"), +GU("GUAM"), +HI("HAWAII"), +ID("IDAHO"), +IL("ILLINOIS"), +IN("INDIANA"), +IA("IOWA"), +KS("KANSAS"), +KY("KENTUCKY"), +LA("LOUISIANA"), +ME("MAINE"), +MH("MARSHALL ISLANDS"), +MD("MARYLAND"), +MA("MASSACHUSETTS"), +MI("MICHIGAN"), +MN("MINNESOTA"), +MS("MISSISSIPPI"), +MO("MISSOURI"), +MT("MONTANA"), +NE("NEBRASKA"), +NV("NEVADA"), +NH("NEW HAMPSHIRE"), +NJ("NEW JERSEY"), +NM("NEW MEXICO"), +NY("NEW YORK"), +NC("NORTH CAROLINA"), +ND("NORTH DAKOTA"), +MP("NORTHERN MARIANA ISLANDS"), +OH("OHIO"), +OK("OKLAHOMA"), +OR("OREGON"), +PW("PALAU"), +PA("PENNSYLVANIA"), +PR("PUERTO RICO"), +RI("RHODE ISLAND"), +SC("SOUTH CAROLINA"), +SD("SOUTH DAKOTA"), +TN("TENNESSEE"), +TX("TEXAS"), +UT("UTAH"), +VT("VERMONT"), +VI("VIRGIN ISLANDS"), +VA("VIRGINIA"), +WA("WASHINGTON"), +WV("WEST VIRGINIA"), +WI("WISCONSIN"), +WY("WYOMING"); + + String sname; + + SimpleEnum(String s) { + sname = s; } - + public String toString() { - return this.getClass().getName() + ": " + id; - } - - public int hashCode() { - return (int) id; - } - - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.id == this.id; - } - return false; - } - - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } + return sname; + }; - public int compareTo(Object p) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) p; - if (id < other.id) return -1; - if (id > other.id) return 1; - return 0; + public static class Oid implements Serializable, Comparable { + public long id; + + public Oid() { + } + + public Oid(String s) { id = Integer.parseInt(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + id;} + + public int hashCode() { return (int)id ; } + + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.id == this.id; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + public int compareTo(Object p){ + // may throw ClassCastException which the user must handle + Oid other = (Oid) p; + if( id < other.id ) return -1; + if( id > other.id ) return 1; + return 0; + } + } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/SimpleInterface.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/SimpleInterface.java index fde652afa..707d6b5d4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/SimpleInterface.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/SimpleInterface.java @@ -5,19 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; -public interface SimpleInterface { +public interface SimpleInterface +{ public void setIntValue(int intField); public int getIntValue(); @@ -25,4 +28,5 @@ public interface SimpleInterface { public void setStringValue(String stringField); public String getStringValue(); + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/TreeMapStringKeyCollections.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/TreeMapStringKeyCollections.java index 4723fb8be..d3fa934f1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/TreeMapStringKeyCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/TreeMapStringKeyCollections.java @@ -5,22 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; import java.util.TreeMap; -public class TreeMapStringKeyCollections { +public class TreeMapStringKeyCollections { public int identifier; public TreeMap TreeMapOfString_Object0; public TreeMap TreeMapOfString_Object1; @@ -121,644 +121,642 @@ public class TreeMapStringKeyCollections { public TreeMap TreeMapOfString_Short123; public TreeMap TreeMapOfString_Short125; - public static final String[] fieldSpecs = { - "public TreeMap TreeMapOfString_Object0", - "embedded-value=true public TreeMap TreeMapOfString_Object1", - "embedded-value=false public TreeMap TreeMapOfString_Object2", - "public TreeMap TreeMapOfString_SimpleClass3", - "embedded-value=true public TreeMap TreeMapOfString_SimpleClass4", - "embedded-value=false public TreeMap TreeMapOfString_SimpleClass5", - "public TreeMap TreeMapOfString_SimpleInterface6", - "embedded-value=true public TreeMap TreeMapOfString_SimpleInterface7", - "embedded-value=false public TreeMap TreeMapOfString_SimpleInterface8", - "public TreeMap TreeMapOfString_String9", - "embedded-value=true public TreeMap TreeMapOfString_String10", - "embedded-value=false public TreeMap TreeMapOfString_String11", - "public TreeMap TreeMapOfString_Date12", - "embedded-value=true public TreeMap TreeMapOfString_Date13", - "embedded-value=false public TreeMap TreeMapOfString_Date14", - "public TreeMap TreeMapOfString_Locale15", - "embedded-value=true public TreeMap TreeMapOfString_Locale16", - "embedded-value=false public TreeMap TreeMapOfString_Locale17", - "public TreeMap TreeMapOfString_BigDecimal18", - "embedded-value=true public TreeMap TreeMapOfString_BigDecimal19", - "embedded-value=false public TreeMap TreeMapOfString_BigDecimal20", - "public TreeMap TreeMapOfString_BigInteger21", - "embedded-value=true public TreeMap TreeMapOfString_BigInteger22", - "embedded-value=false public TreeMap TreeMapOfString_BigInteger23", - "public TreeMap TreeMapOfString_Byte24", - "embedded-value=true public TreeMap TreeMapOfString_Byte25", - "embedded-value=false public TreeMap TreeMapOfString_Byte26", - "public TreeMap TreeMapOfString_Double27", - "embedded-value=true public TreeMap TreeMapOfString_Double28", - "embedded-value=false public TreeMap TreeMapOfString_Double29", - "public TreeMap TreeMapOfString_Float30", - "embedded-value=true public TreeMap TreeMapOfString_Float31", - "embedded-value=false public TreeMap TreeMapOfString_Float32", - "public TreeMap TreeMapOfString_Integer33", - "embedded-value=true public TreeMap TreeMapOfString_Integer34", - "embedded-value=false public TreeMap TreeMapOfString_Integer35", - "public TreeMap TreeMapOfString_Long36", - "embedded-value=true public TreeMap TreeMapOfString_Long37", - "embedded-value=false public TreeMap TreeMapOfString_Long38", - "public TreeMap TreeMapOfString_Short39", - "embedded-value=true public TreeMap TreeMapOfString_Short40", - "embedded-value=false public TreeMap TreeMapOfString_Short41", - "embedded-key=true public TreeMap TreeMapOfString_Object42", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_Object43", - "embedded-key=true public TreeMap TreeMapOfString_SimpleClass45", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_SimpleClass46", - "embedded-key=true public TreeMap TreeMapOfString_SimpleInterface48", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_SimpleInterface49", - "embedded-key=true public TreeMap TreeMapOfString_String51", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_String52", - "embedded-key=true public TreeMap TreeMapOfString_Date54", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_Date55", - "embedded-key=true public TreeMap TreeMapOfString_Locale57", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_Locale58", - "embedded-key=true public TreeMap TreeMapOfString_BigDecimal60", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_BigDecimal61", - "embedded-key=true public TreeMap TreeMapOfString_BigInteger63", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_BigInteger64", - "embedded-key=true public TreeMap TreeMapOfString_Byte66", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_Byte67", - "embedded-key=true public TreeMap TreeMapOfString_Double69", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_Double70", - "embedded-key=true public TreeMap TreeMapOfString_Float72", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_Float73", - "embedded-key=true public TreeMap TreeMapOfString_Integer75", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_Integer76", - "embedded-key=true public TreeMap TreeMapOfString_Long78", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_Long79", - "embedded-key=true public TreeMap TreeMapOfString_Short81", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_Short82", - "embedded-key=false public TreeMap TreeMapOfString_Object84", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_Object86", - "embedded-key=false public TreeMap TreeMapOfString_SimpleClass87", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_SimpleClass89", - "embedded-key=false public TreeMap TreeMapOfString_SimpleInterface90", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_SimpleInterface92", - "embedded-key=false public TreeMap TreeMapOfString_String93", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_String95", - "embedded-key=false public TreeMap TreeMapOfString_Date96", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_Date98", - "embedded-key=false public TreeMap TreeMapOfString_Locale99", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_Locale101", - "embedded-key=false public TreeMap TreeMapOfString_BigDecimal102", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_BigDecimal104", - "embedded-key=false public TreeMap TreeMapOfString_BigInteger105", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_BigInteger107", - "embedded-key=false public TreeMap TreeMapOfString_Byte108", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_Byte110", - "embedded-key=false public TreeMap TreeMapOfString_Double111", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_Double113", - "embedded-key=false public TreeMap TreeMapOfString_Float114", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_Float116", - "embedded-key=false public TreeMap TreeMapOfString_Integer117", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_Integer119", - "embedded-key=false public TreeMap TreeMapOfString_Long120", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_Long122", - "embedded-key=false public TreeMap TreeMapOfString_Short123", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_Short125" + public static final String [] fieldSpecs = { + "public TreeMap TreeMapOfString_Object0", + "embedded-value=true public TreeMap TreeMapOfString_Object1", + "embedded-value=false public TreeMap TreeMapOfString_Object2", + "public TreeMap TreeMapOfString_SimpleClass3", + "embedded-value=true public TreeMap TreeMapOfString_SimpleClass4", + "embedded-value=false public TreeMap TreeMapOfString_SimpleClass5", + "public TreeMap TreeMapOfString_SimpleInterface6", + "embedded-value=true public TreeMap TreeMapOfString_SimpleInterface7", + "embedded-value=false public TreeMap TreeMapOfString_SimpleInterface8", + "public TreeMap TreeMapOfString_String9", + "embedded-value=true public TreeMap TreeMapOfString_String10", + "embedded-value=false public TreeMap TreeMapOfString_String11", + "public TreeMap TreeMapOfString_Date12", + "embedded-value=true public TreeMap TreeMapOfString_Date13", + "embedded-value=false public TreeMap TreeMapOfString_Date14", + "public TreeMap TreeMapOfString_Locale15", + "embedded-value=true public TreeMap TreeMapOfString_Locale16", + "embedded-value=false public TreeMap TreeMapOfString_Locale17", + "public TreeMap TreeMapOfString_BigDecimal18", + "embedded-value=true public TreeMap TreeMapOfString_BigDecimal19", + "embedded-value=false public TreeMap TreeMapOfString_BigDecimal20", + "public TreeMap TreeMapOfString_BigInteger21", + "embedded-value=true public TreeMap TreeMapOfString_BigInteger22", + "embedded-value=false public TreeMap TreeMapOfString_BigInteger23", + "public TreeMap TreeMapOfString_Byte24", + "embedded-value=true public TreeMap TreeMapOfString_Byte25", + "embedded-value=false public TreeMap TreeMapOfString_Byte26", + "public TreeMap TreeMapOfString_Double27", + "embedded-value=true public TreeMap TreeMapOfString_Double28", + "embedded-value=false public TreeMap TreeMapOfString_Double29", + "public TreeMap TreeMapOfString_Float30", + "embedded-value=true public TreeMap TreeMapOfString_Float31", + "embedded-value=false public TreeMap TreeMapOfString_Float32", + "public TreeMap TreeMapOfString_Integer33", + "embedded-value=true public TreeMap TreeMapOfString_Integer34", + "embedded-value=false public TreeMap TreeMapOfString_Integer35", + "public TreeMap TreeMapOfString_Long36", + "embedded-value=true public TreeMap TreeMapOfString_Long37", + "embedded-value=false public TreeMap TreeMapOfString_Long38", + "public TreeMap TreeMapOfString_Short39", + "embedded-value=true public TreeMap TreeMapOfString_Short40", + "embedded-value=false public TreeMap TreeMapOfString_Short41", + "embedded-key=true public TreeMap TreeMapOfString_Object42", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_Object43", + "embedded-key=true public TreeMap TreeMapOfString_SimpleClass45", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_SimpleClass46", + "embedded-key=true public TreeMap TreeMapOfString_SimpleInterface48", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_SimpleInterface49", + "embedded-key=true public TreeMap TreeMapOfString_String51", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_String52", + "embedded-key=true public TreeMap TreeMapOfString_Date54", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_Date55", + "embedded-key=true public TreeMap TreeMapOfString_Locale57", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_Locale58", + "embedded-key=true public TreeMap TreeMapOfString_BigDecimal60", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_BigDecimal61", + "embedded-key=true public TreeMap TreeMapOfString_BigInteger63", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_BigInteger64", + "embedded-key=true public TreeMap TreeMapOfString_Byte66", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_Byte67", + "embedded-key=true public TreeMap TreeMapOfString_Double69", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_Double70", + "embedded-key=true public TreeMap TreeMapOfString_Float72", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_Float73", + "embedded-key=true public TreeMap TreeMapOfString_Integer75", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_Integer76", + "embedded-key=true public TreeMap TreeMapOfString_Long78", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_Long79", + "embedded-key=true public TreeMap TreeMapOfString_Short81", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_Short82", + "embedded-key=false public TreeMap TreeMapOfString_Object84", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_Object86", + "embedded-key=false public TreeMap TreeMapOfString_SimpleClass87", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_SimpleClass89", + "embedded-key=false public TreeMap TreeMapOfString_SimpleInterface90", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_SimpleInterface92", + "embedded-key=false public TreeMap TreeMapOfString_String93", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_String95", + "embedded-key=false public TreeMap TreeMapOfString_Date96", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_Date98", + "embedded-key=false public TreeMap TreeMapOfString_Locale99", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_Locale101", + "embedded-key=false public TreeMap TreeMapOfString_BigDecimal102", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_BigDecimal104", + "embedded-key=false public TreeMap TreeMapOfString_BigInteger105", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_BigInteger107", + "embedded-key=false public TreeMap TreeMapOfString_Byte108", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_Byte110", + "embedded-key=false public TreeMap TreeMapOfString_Double111", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_Double113", + "embedded-key=false public TreeMap TreeMapOfString_Float114", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_Float116", + "embedded-key=false public TreeMap TreeMapOfString_Integer117", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_Integer119", + "embedded-key=false public TreeMap TreeMapOfString_Long120", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_Long122", + "embedded-key=false public TreeMap TreeMapOfString_Short123", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_Short125" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public TreeMap get(int index) { - switch (index) { - case (0): + public TreeMap get(int index) + { + switch (index) + { + case(0): return TreeMapOfString_Object0; - case (1): + case(1): return TreeMapOfString_Object1; - case (2): + case(2): return TreeMapOfString_Object2; - case (3): + case(3): return TreeMapOfString_SimpleClass3; - case (4): + case(4): return TreeMapOfString_SimpleClass4; - case (5): + case(5): return TreeMapOfString_SimpleClass5; - case (6): + case(6): return TreeMapOfString_SimpleInterface6; - case (7): + case(7): return TreeMapOfString_SimpleInterface7; - case (8): + case(8): return TreeMapOfString_SimpleInterface8; - case (9): + case(9): return TreeMapOfString_String9; - case (10): + case(10): return TreeMapOfString_String10; - case (11): + case(11): return TreeMapOfString_String11; - case (12): + case(12): return TreeMapOfString_Date12; - case (13): + case(13): return TreeMapOfString_Date13; - case (14): + case(14): return TreeMapOfString_Date14; - case (15): + case(15): return TreeMapOfString_Locale15; - case (16): + case(16): return TreeMapOfString_Locale16; - case (17): + case(17): return TreeMapOfString_Locale17; - case (18): + case(18): return TreeMapOfString_BigDecimal18; - case (19): + case(19): return TreeMapOfString_BigDecimal19; - case (20): + case(20): return TreeMapOfString_BigDecimal20; - case (21): + case(21): return TreeMapOfString_BigInteger21; - case (22): + case(22): return TreeMapOfString_BigInteger22; - case (23): + case(23): return TreeMapOfString_BigInteger23; - case (24): + case(24): return TreeMapOfString_Byte24; - case (25): + case(25): return TreeMapOfString_Byte25; - case (26): + case(26): return TreeMapOfString_Byte26; - case (27): + case(27): return TreeMapOfString_Double27; - case (28): + case(28): return TreeMapOfString_Double28; - case (29): + case(29): return TreeMapOfString_Double29; - case (30): + case(30): return TreeMapOfString_Float30; - case (31): + case(31): return TreeMapOfString_Float31; - case (32): + case(32): return TreeMapOfString_Float32; - case (33): + case(33): return TreeMapOfString_Integer33; - case (34): + case(34): return TreeMapOfString_Integer34; - case (35): + case(35): return TreeMapOfString_Integer35; - case (36): + case(36): return TreeMapOfString_Long36; - case (37): + case(37): return TreeMapOfString_Long37; - case (38): + case(38): return TreeMapOfString_Long38; - case (39): + case(39): return TreeMapOfString_Short39; - case (40): + case(40): return TreeMapOfString_Short40; - case (41): + case(41): return TreeMapOfString_Short41; - case (42): + case(42): return TreeMapOfString_Object42; - case (43): + case(43): return TreeMapOfString_Object43; - case (44): + case(44): return TreeMapOfString_SimpleClass45; - case (45): + case(45): return TreeMapOfString_SimpleClass46; - case (46): + case(46): return TreeMapOfString_SimpleInterface48; - case (47): + case(47): return TreeMapOfString_SimpleInterface49; - case (48): + case(48): return TreeMapOfString_String51; - case (49): + case(49): return TreeMapOfString_String52; - case (50): + case(50): return TreeMapOfString_Date54; - case (51): + case(51): return TreeMapOfString_Date55; - case (52): + case(52): return TreeMapOfString_Locale57; - case (53): + case(53): return TreeMapOfString_Locale58; - case (54): + case(54): return TreeMapOfString_BigDecimal60; - case (55): + case(55): return TreeMapOfString_BigDecimal61; - case (56): + case(56): return TreeMapOfString_BigInteger63; - case (57): + case(57): return TreeMapOfString_BigInteger64; - case (58): + case(58): return TreeMapOfString_Byte66; - case (59): + case(59): return TreeMapOfString_Byte67; - case (60): + case(60): return TreeMapOfString_Double69; - case (61): + case(61): return TreeMapOfString_Double70; - case (62): + case(62): return TreeMapOfString_Float72; - case (63): + case(63): return TreeMapOfString_Float73; - case (64): + case(64): return TreeMapOfString_Integer75; - case (65): + case(65): return TreeMapOfString_Integer76; - case (66): + case(66): return TreeMapOfString_Long78; - case (67): + case(67): return TreeMapOfString_Long79; - case (68): + case(68): return TreeMapOfString_Short81; - case (69): + case(69): return TreeMapOfString_Short82; - case (70): + case(70): return TreeMapOfString_Object84; - case (71): + case(71): return TreeMapOfString_Object86; - case (72): + case(72): return TreeMapOfString_SimpleClass87; - case (73): + case(73): return TreeMapOfString_SimpleClass89; - case (74): + case(74): return TreeMapOfString_SimpleInterface90; - case (75): + case(75): return TreeMapOfString_SimpleInterface92; - case (76): + case(76): return TreeMapOfString_String93; - case (77): + case(77): return TreeMapOfString_String95; - case (78): + case(78): return TreeMapOfString_Date96; - case (79): + case(79): return TreeMapOfString_Date98; - case (80): + case(80): return TreeMapOfString_Locale99; - case (81): + case(81): return TreeMapOfString_Locale101; - case (82): + case(82): return TreeMapOfString_BigDecimal102; - case (83): + case(83): return TreeMapOfString_BigDecimal104; - case (84): + case(84): return TreeMapOfString_BigInteger105; - case (85): + case(85): return TreeMapOfString_BigInteger107; - case (86): + case(86): return TreeMapOfString_Byte108; - case (87): + case(87): return TreeMapOfString_Byte110; - case (88): + case(88): return TreeMapOfString_Double111; - case (89): + case(89): return TreeMapOfString_Double113; - case (90): + case(90): return TreeMapOfString_Float114; - case (91): + case(91): return TreeMapOfString_Float116; - case (92): + case(92): return TreeMapOfString_Integer117; - case (93): + case(93): return TreeMapOfString_Integer119; - case (94): + case(94): return TreeMapOfString_Long120; - case (95): + case(95): return TreeMapOfString_Long122; - case (96): + case(96): return TreeMapOfString_Short123; - case (97): + case(97): return TreeMapOfString_Short125; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, TreeMap value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - TreeMapOfString_Object0 = value; - break; - case (1): - TreeMapOfString_Object1 = value; - break; - case (2): - TreeMapOfString_Object2 = value; - break; - case (3): - TreeMapOfString_SimpleClass3 = value; - break; - case (4): - TreeMapOfString_SimpleClass4 = value; - break; - case (5): - TreeMapOfString_SimpleClass5 = value; - break; - case (6): - TreeMapOfString_SimpleInterface6 = value; - break; - case (7): - TreeMapOfString_SimpleInterface7 = value; - break; - case (8): - TreeMapOfString_SimpleInterface8 = value; - break; - case (9): - TreeMapOfString_String9 = value; - break; - case (10): - TreeMapOfString_String10 = value; - break; - case (11): - TreeMapOfString_String11 = value; - break; - case (12): - TreeMapOfString_Date12 = value; - break; - case (13): - TreeMapOfString_Date13 = value; - break; - case (14): - TreeMapOfString_Date14 = value; - break; - case (15): - TreeMapOfString_Locale15 = value; - break; - case (16): - TreeMapOfString_Locale16 = value; - break; - case (17): - TreeMapOfString_Locale17 = value; - break; - case (18): - TreeMapOfString_BigDecimal18 = value; - break; - case (19): - TreeMapOfString_BigDecimal19 = value; - break; - case (20): - TreeMapOfString_BigDecimal20 = value; - break; - case (21): - TreeMapOfString_BigInteger21 = value; - break; - case (22): - TreeMapOfString_BigInteger22 = value; - break; - case (23): - TreeMapOfString_BigInteger23 = value; - break; - case (24): - TreeMapOfString_Byte24 = value; - break; - case (25): - TreeMapOfString_Byte25 = value; - break; - case (26): - TreeMapOfString_Byte26 = value; - break; - case (27): - TreeMapOfString_Double27 = value; - break; - case (28): - TreeMapOfString_Double28 = value; - break; - case (29): - TreeMapOfString_Double29 = value; - break; - case (30): - TreeMapOfString_Float30 = value; - break; - case (31): - TreeMapOfString_Float31 = value; - break; - case (32): - TreeMapOfString_Float32 = value; - break; - case (33): - TreeMapOfString_Integer33 = value; - break; - case (34): - TreeMapOfString_Integer34 = value; - break; - case (35): - TreeMapOfString_Integer35 = value; - break; - case (36): - TreeMapOfString_Long36 = value; - break; - case (37): - TreeMapOfString_Long37 = value; - break; - case (38): - TreeMapOfString_Long38 = value; - break; - case (39): - TreeMapOfString_Short39 = value; - break; - case (40): - TreeMapOfString_Short40 = value; - break; - case (41): - TreeMapOfString_Short41 = value; - break; - case (42): - TreeMapOfString_Object42 = value; - break; - case (43): - TreeMapOfString_Object43 = value; - break; - case (44): - TreeMapOfString_SimpleClass45 = value; - break; - case (45): - TreeMapOfString_SimpleClass46 = value; - break; - case (46): - TreeMapOfString_SimpleInterface48 = value; - break; - case (47): - TreeMapOfString_SimpleInterface49 = value; - break; - case (48): - TreeMapOfString_String51 = value; - break; - case (49): - TreeMapOfString_String52 = value; - break; - case (50): - TreeMapOfString_Date54 = value; - break; - case (51): - TreeMapOfString_Date55 = value; - break; - case (52): - TreeMapOfString_Locale57 = value; - break; - case (53): - TreeMapOfString_Locale58 = value; - break; - case (54): - TreeMapOfString_BigDecimal60 = value; - break; - case (55): - TreeMapOfString_BigDecimal61 = value; - break; - case (56): - TreeMapOfString_BigInteger63 = value; - break; - case (57): - TreeMapOfString_BigInteger64 = value; - break; - case (58): - TreeMapOfString_Byte66 = value; - break; - case (59): - TreeMapOfString_Byte67 = value; - break; - case (60): - TreeMapOfString_Double69 = value; - break; - case (61): - TreeMapOfString_Double70 = value; - break; - case (62): - TreeMapOfString_Float72 = value; - break; - case (63): - TreeMapOfString_Float73 = value; - break; - case (64): - TreeMapOfString_Integer75 = value; - break; - case (65): - TreeMapOfString_Integer76 = value; - break; - case (66): - TreeMapOfString_Long78 = value; - break; - case (67): - TreeMapOfString_Long79 = value; - break; - case (68): - TreeMapOfString_Short81 = value; - break; - case (69): - TreeMapOfString_Short82 = value; - break; - case (70): - TreeMapOfString_Object84 = value; - break; - case (71): - TreeMapOfString_Object86 = value; - break; - case (72): - TreeMapOfString_SimpleClass87 = value; - break; - case (73): - TreeMapOfString_SimpleClass89 = value; - break; - case (74): - TreeMapOfString_SimpleInterface90 = value; - break; - case (75): - TreeMapOfString_SimpleInterface92 = value; - break; - case (76): - TreeMapOfString_String93 = value; - break; - case (77): - TreeMapOfString_String95 = value; - break; - case (78): - TreeMapOfString_Date96 = value; - break; - case (79): - TreeMapOfString_Date98 = value; - break; - case (80): - TreeMapOfString_Locale99 = value; - break; - case (81): - TreeMapOfString_Locale101 = value; - break; - case (82): - TreeMapOfString_BigDecimal102 = value; - break; - case (83): - TreeMapOfString_BigDecimal104 = value; - break; - case (84): - TreeMapOfString_BigInteger105 = value; - break; - case (85): - TreeMapOfString_BigInteger107 = value; - break; - case (86): - TreeMapOfString_Byte108 = value; - break; - case (87): - TreeMapOfString_Byte110 = value; - break; - case (88): - TreeMapOfString_Double111 = value; - break; - case (89): - TreeMapOfString_Double113 = value; - break; - case (90): - TreeMapOfString_Float114 = value; - break; - case (91): - TreeMapOfString_Float116 = value; - break; - case (92): - TreeMapOfString_Integer117 = value; - break; - case (93): - TreeMapOfString_Integer119 = value; - break; - case (94): - TreeMapOfString_Long120 = value; - break; - case (95): - TreeMapOfString_Long122 = value; - break; - case (96): - TreeMapOfString_Short123 = value; - break; - case (97): - TreeMapOfString_Short125 = value; - break; + public boolean set(int index,TreeMap value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + TreeMapOfString_Object0= value; + break; + case(1): + TreeMapOfString_Object1= value; + break; + case(2): + TreeMapOfString_Object2= value; + break; + case(3): + TreeMapOfString_SimpleClass3= value; + break; + case(4): + TreeMapOfString_SimpleClass4= value; + break; + case(5): + TreeMapOfString_SimpleClass5= value; + break; + case(6): + TreeMapOfString_SimpleInterface6= value; + break; + case(7): + TreeMapOfString_SimpleInterface7= value; + break; + case(8): + TreeMapOfString_SimpleInterface8= value; + break; + case(9): + TreeMapOfString_String9= value; + break; + case(10): + TreeMapOfString_String10= value; + break; + case(11): + TreeMapOfString_String11= value; + break; + case(12): + TreeMapOfString_Date12= value; + break; + case(13): + TreeMapOfString_Date13= value; + break; + case(14): + TreeMapOfString_Date14= value; + break; + case(15): + TreeMapOfString_Locale15= value; + break; + case(16): + TreeMapOfString_Locale16= value; + break; + case(17): + TreeMapOfString_Locale17= value; + break; + case(18): + TreeMapOfString_BigDecimal18= value; + break; + case(19): + TreeMapOfString_BigDecimal19= value; + break; + case(20): + TreeMapOfString_BigDecimal20= value; + break; + case(21): + TreeMapOfString_BigInteger21= value; + break; + case(22): + TreeMapOfString_BigInteger22= value; + break; + case(23): + TreeMapOfString_BigInteger23= value; + break; + case(24): + TreeMapOfString_Byte24= value; + break; + case(25): + TreeMapOfString_Byte25= value; + break; + case(26): + TreeMapOfString_Byte26= value; + break; + case(27): + TreeMapOfString_Double27= value; + break; + case(28): + TreeMapOfString_Double28= value; + break; + case(29): + TreeMapOfString_Double29= value; + break; + case(30): + TreeMapOfString_Float30= value; + break; + case(31): + TreeMapOfString_Float31= value; + break; + case(32): + TreeMapOfString_Float32= value; + break; + case(33): + TreeMapOfString_Integer33= value; + break; + case(34): + TreeMapOfString_Integer34= value; + break; + case(35): + TreeMapOfString_Integer35= value; + break; + case(36): + TreeMapOfString_Long36= value; + break; + case(37): + TreeMapOfString_Long37= value; + break; + case(38): + TreeMapOfString_Long38= value; + break; + case(39): + TreeMapOfString_Short39= value; + break; + case(40): + TreeMapOfString_Short40= value; + break; + case(41): + TreeMapOfString_Short41= value; + break; + case(42): + TreeMapOfString_Object42= value; + break; + case(43): + TreeMapOfString_Object43= value; + break; + case(44): + TreeMapOfString_SimpleClass45= value; + break; + case(45): + TreeMapOfString_SimpleClass46= value; + break; + case(46): + TreeMapOfString_SimpleInterface48= value; + break; + case(47): + TreeMapOfString_SimpleInterface49= value; + break; + case(48): + TreeMapOfString_String51= value; + break; + case(49): + TreeMapOfString_String52= value; + break; + case(50): + TreeMapOfString_Date54= value; + break; + case(51): + TreeMapOfString_Date55= value; + break; + case(52): + TreeMapOfString_Locale57= value; + break; + case(53): + TreeMapOfString_Locale58= value; + break; + case(54): + TreeMapOfString_BigDecimal60= value; + break; + case(55): + TreeMapOfString_BigDecimal61= value; + break; + case(56): + TreeMapOfString_BigInteger63= value; + break; + case(57): + TreeMapOfString_BigInteger64= value; + break; + case(58): + TreeMapOfString_Byte66= value; + break; + case(59): + TreeMapOfString_Byte67= value; + break; + case(60): + TreeMapOfString_Double69= value; + break; + case(61): + TreeMapOfString_Double70= value; + break; + case(62): + TreeMapOfString_Float72= value; + break; + case(63): + TreeMapOfString_Float73= value; + break; + case(64): + TreeMapOfString_Integer75= value; + break; + case(65): + TreeMapOfString_Integer76= value; + break; + case(66): + TreeMapOfString_Long78= value; + break; + case(67): + TreeMapOfString_Long79= value; + break; + case(68): + TreeMapOfString_Short81= value; + break; + case(69): + TreeMapOfString_Short82= value; + break; + case(70): + TreeMapOfString_Object84= value; + break; + case(71): + TreeMapOfString_Object86= value; + break; + case(72): + TreeMapOfString_SimpleClass87= value; + break; + case(73): + TreeMapOfString_SimpleClass89= value; + break; + case(74): + TreeMapOfString_SimpleInterface90= value; + break; + case(75): + TreeMapOfString_SimpleInterface92= value; + break; + case(76): + TreeMapOfString_String93= value; + break; + case(77): + TreeMapOfString_String95= value; + break; + case(78): + TreeMapOfString_Date96= value; + break; + case(79): + TreeMapOfString_Date98= value; + break; + case(80): + TreeMapOfString_Locale99= value; + break; + case(81): + TreeMapOfString_Locale101= value; + break; + case(82): + TreeMapOfString_BigDecimal102= value; + break; + case(83): + TreeMapOfString_BigDecimal104= value; + break; + case(84): + TreeMapOfString_BigInteger105= value; + break; + case(85): + TreeMapOfString_BigInteger107= value; + break; + case(86): + TreeMapOfString_Byte108= value; + break; + case(87): + TreeMapOfString_Byte110= value; + break; + case(88): + TreeMapOfString_Double111= value; + break; + case(89): + TreeMapOfString_Double113= value; + break; + case(90): + TreeMapOfString_Float114= value; + break; + case(91): + TreeMapOfString_Float116= value; + break; + case(92): + TreeMapOfString_Integer117= value; + break; + case(93): + TreeMapOfString_Integer119= value; + break; + case(94): + TreeMapOfString_Long120= value; + break; + case(95): + TreeMapOfString_Long122= value; + break; + case(96): + TreeMapOfString_Short123= value; + break; + case(97): + TreeMapOfString_Short125= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } - - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public int hashCode() { return (int)identifier ; } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/TreeMapStringValueCollections.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/TreeMapStringValueCollections.java index 99b4686fc..ce0add9d9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/TreeMapStringValueCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/TreeMapStringValueCollections.java @@ -5,22 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; import java.util.TreeMap; -public class TreeMapStringValueCollections { +public class TreeMapStringValueCollections { public int identifier; public TreeMap TreeMapOfObject_String0; public TreeMap TreeMapOfObject_String1; @@ -114,602 +114,601 @@ public class TreeMapStringValueCollections { public TreeMap TreeMapOfShort_String114; public TreeMap TreeMapOfShort_String116; - public static final String[] fieldSpecs = { - "public TreeMap TreeMapOfObject_String0", - "embedded-value=true public TreeMap TreeMapOfObject_String1", - "embedded-value=false public TreeMap TreeMapOfObject_String2", - "embedded-key=true public TreeMap TreeMapOfObject_String3", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfObject_String4", - "embedded-key=false public TreeMap TreeMapOfObject_String6", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfObject_String8", - "public TreeMap TreeMapOfSimpleClass_String9", - "embedded-value=true public TreeMap TreeMapOfSimpleClass_String10", - "embedded-value=false public TreeMap TreeMapOfSimpleClass_String11", - "embedded-key=true public TreeMap TreeMapOfSimpleClass_String12", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfSimpleClass_String13", - "embedded-key=false public TreeMap TreeMapOfSimpleClass_String15", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfSimpleClass_String17", - "public TreeMap TreeMapOfSimpleInterface_String18", - "embedded-value=true public TreeMap TreeMapOfSimpleInterface_String19", - "embedded-value=false public TreeMap TreeMapOfSimpleInterface_String20", - "embedded-key=true public TreeMap TreeMapOfSimpleInterface_String21", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfSimpleInterface_String22", - "embedded-key=false public TreeMap TreeMapOfSimpleInterface_String24", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfSimpleInterface_String26", - "public TreeMap TreeMapOfString_String27", - "embedded-value=true public TreeMap TreeMapOfString_String28", - "embedded-value=false public TreeMap TreeMapOfString_String29", - "embedded-key=true public TreeMap TreeMapOfString_String30", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_String31", - "embedded-key=false public TreeMap TreeMapOfString_String33", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_String35", - "public TreeMap TreeMapOfDate_String36", - "embedded-value=true public TreeMap TreeMapOfDate_String37", - "embedded-value=false public TreeMap TreeMapOfDate_String38", - "embedded-key=true public TreeMap TreeMapOfDate_String39", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfDate_String40", - "embedded-key=false public TreeMap TreeMapOfDate_String42", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfDate_String44", - "public TreeMap TreeMapOfBigDecimal_String45", - "embedded-value=true public TreeMap TreeMapOfBigDecimal_String46", - "embedded-value=false public TreeMap TreeMapOfBigDecimal_String47", - "embedded-key=true public TreeMap TreeMapOfBigDecimal_String48", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfBigDecimal_String49", - "embedded-key=false public TreeMap TreeMapOfBigDecimal_String51", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfBigDecimal_String53", - "public TreeMap TreeMapOfBigInteger_String54", - "embedded-value=true public TreeMap TreeMapOfBigInteger_String55", - "embedded-value=false public TreeMap TreeMapOfBigInteger_String56", - "embedded-key=true public TreeMap TreeMapOfBigInteger_String57", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfBigInteger_String58", - "embedded-key=false public TreeMap TreeMapOfBigInteger_String60", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfBigInteger_String62", - "public TreeMap TreeMapOfByte_String63", - "embedded-value=true public TreeMap TreeMapOfByte_String64", - "embedded-value=false public TreeMap TreeMapOfByte_String65", - "embedded-key=true public TreeMap TreeMapOfByte_String66", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfByte_String67", - "embedded-key=false public TreeMap TreeMapOfByte_String69", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfByte_String71", - "public TreeMap TreeMapOfDouble_String72", - "embedded-value=true public TreeMap TreeMapOfDouble_String73", - "embedded-value=false public TreeMap TreeMapOfDouble_String74", - "embedded-key=true public TreeMap TreeMapOfDouble_String75", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfDouble_String76", - "embedded-key=false public TreeMap TreeMapOfDouble_String78", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfDouble_String80", - "public TreeMap TreeMapOfFloat_String81", - "embedded-value=true public TreeMap TreeMapOfFloat_String82", - "embedded-value=false public TreeMap TreeMapOfFloat_String83", - "embedded-key=true public TreeMap TreeMapOfFloat_String84", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfFloat_String85", - "embedded-key=false public TreeMap TreeMapOfFloat_String87", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfFloat_String89", - "public TreeMap TreeMapOfInteger_String90", - "embedded-value=true public TreeMap TreeMapOfInteger_String91", - "embedded-value=false public TreeMap TreeMapOfInteger_String92", - "embedded-key=true public TreeMap TreeMapOfInteger_String93", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfInteger_String94", - "embedded-key=false public TreeMap TreeMapOfInteger_String96", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfInteger_String98", - "public TreeMap TreeMapOfLong_String99", - "embedded-value=true public TreeMap TreeMapOfLong_String100", - "embedded-value=false public TreeMap TreeMapOfLong_String101", - "embedded-key=true public TreeMap TreeMapOfLong_String102", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfLong_String103", - "embedded-key=false public TreeMap TreeMapOfLong_String105", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfLong_String107", - "public TreeMap TreeMapOfShort_String108", - "embedded-value=true public TreeMap TreeMapOfShort_String109", - "embedded-value=false public TreeMap TreeMapOfShort_String110", - "embedded-key=true public TreeMap TreeMapOfShort_String111", - "embedded-key=true embedded-value=true public TreeMap TreeMapOfShort_String112", - "embedded-key=false public TreeMap TreeMapOfShort_String114", - "embedded-key=false embedded-value=false public TreeMap TreeMapOfShort_String116" + public static final String [] fieldSpecs = { + "public TreeMap TreeMapOfObject_String0", + "embedded-value=true public TreeMap TreeMapOfObject_String1", + "embedded-value=false public TreeMap TreeMapOfObject_String2", + "embedded-key=true public TreeMap TreeMapOfObject_String3", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfObject_String4", + "embedded-key=false public TreeMap TreeMapOfObject_String6", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfObject_String8", + "public TreeMap TreeMapOfSimpleClass_String9", + "embedded-value=true public TreeMap TreeMapOfSimpleClass_String10", + "embedded-value=false public TreeMap TreeMapOfSimpleClass_String11", + "embedded-key=true public TreeMap TreeMapOfSimpleClass_String12", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfSimpleClass_String13", + "embedded-key=false public TreeMap TreeMapOfSimpleClass_String15", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfSimpleClass_String17", + "public TreeMap TreeMapOfSimpleInterface_String18", + "embedded-value=true public TreeMap TreeMapOfSimpleInterface_String19", + "embedded-value=false public TreeMap TreeMapOfSimpleInterface_String20", + "embedded-key=true public TreeMap TreeMapOfSimpleInterface_String21", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfSimpleInterface_String22", + "embedded-key=false public TreeMap TreeMapOfSimpleInterface_String24", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfSimpleInterface_String26", + "public TreeMap TreeMapOfString_String27", + "embedded-value=true public TreeMap TreeMapOfString_String28", + "embedded-value=false public TreeMap TreeMapOfString_String29", + "embedded-key=true public TreeMap TreeMapOfString_String30", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfString_String31", + "embedded-key=false public TreeMap TreeMapOfString_String33", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfString_String35", + "public TreeMap TreeMapOfDate_String36", + "embedded-value=true public TreeMap TreeMapOfDate_String37", + "embedded-value=false public TreeMap TreeMapOfDate_String38", + "embedded-key=true public TreeMap TreeMapOfDate_String39", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfDate_String40", + "embedded-key=false public TreeMap TreeMapOfDate_String42", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfDate_String44", + "public TreeMap TreeMapOfBigDecimal_String45", + "embedded-value=true public TreeMap TreeMapOfBigDecimal_String46", + "embedded-value=false public TreeMap TreeMapOfBigDecimal_String47", + "embedded-key=true public TreeMap TreeMapOfBigDecimal_String48", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfBigDecimal_String49", + "embedded-key=false public TreeMap TreeMapOfBigDecimal_String51", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfBigDecimal_String53", + "public TreeMap TreeMapOfBigInteger_String54", + "embedded-value=true public TreeMap TreeMapOfBigInteger_String55", + "embedded-value=false public TreeMap TreeMapOfBigInteger_String56", + "embedded-key=true public TreeMap TreeMapOfBigInteger_String57", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfBigInteger_String58", + "embedded-key=false public TreeMap TreeMapOfBigInteger_String60", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfBigInteger_String62", + "public TreeMap TreeMapOfByte_String63", + "embedded-value=true public TreeMap TreeMapOfByte_String64", + "embedded-value=false public TreeMap TreeMapOfByte_String65", + "embedded-key=true public TreeMap TreeMapOfByte_String66", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfByte_String67", + "embedded-key=false public TreeMap TreeMapOfByte_String69", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfByte_String71", + "public TreeMap TreeMapOfDouble_String72", + "embedded-value=true public TreeMap TreeMapOfDouble_String73", + "embedded-value=false public TreeMap TreeMapOfDouble_String74", + "embedded-key=true public TreeMap TreeMapOfDouble_String75", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfDouble_String76", + "embedded-key=false public TreeMap TreeMapOfDouble_String78", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfDouble_String80", + "public TreeMap TreeMapOfFloat_String81", + "embedded-value=true public TreeMap TreeMapOfFloat_String82", + "embedded-value=false public TreeMap TreeMapOfFloat_String83", + "embedded-key=true public TreeMap TreeMapOfFloat_String84", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfFloat_String85", + "embedded-key=false public TreeMap TreeMapOfFloat_String87", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfFloat_String89", + "public TreeMap TreeMapOfInteger_String90", + "embedded-value=true public TreeMap TreeMapOfInteger_String91", + "embedded-value=false public TreeMap TreeMapOfInteger_String92", + "embedded-key=true public TreeMap TreeMapOfInteger_String93", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfInteger_String94", + "embedded-key=false public TreeMap TreeMapOfInteger_String96", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfInteger_String98", + "public TreeMap TreeMapOfLong_String99", + "embedded-value=true public TreeMap TreeMapOfLong_String100", + "embedded-value=false public TreeMap TreeMapOfLong_String101", + "embedded-key=true public TreeMap TreeMapOfLong_String102", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfLong_String103", + "embedded-key=false public TreeMap TreeMapOfLong_String105", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfLong_String107", + "public TreeMap TreeMapOfShort_String108", + "embedded-value=true public TreeMap TreeMapOfShort_String109", + "embedded-value=false public TreeMap TreeMapOfShort_String110", + "embedded-key=true public TreeMap TreeMapOfShort_String111", + "embedded-key=true embedded-value=true public TreeMap TreeMapOfShort_String112", + "embedded-key=false public TreeMap TreeMapOfShort_String114", + "embedded-key=false embedded-value=false public TreeMap TreeMapOfShort_String116" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public TreeMap get(int index) { - switch (index) { - case (0): + public TreeMap get(int index) + { + switch (index) + { + case(0): return TreeMapOfObject_String0; - case (1): + case(1): return TreeMapOfObject_String1; - case (2): + case(2): return TreeMapOfObject_String2; - case (3): + case(3): return TreeMapOfObject_String3; - case (4): + case(4): return TreeMapOfObject_String4; - case (5): + case(5): return TreeMapOfObject_String6; - case (6): + case(6): return TreeMapOfObject_String8; - case (7): + case(7): return TreeMapOfSimpleClass_String9; - case (8): + case(8): return TreeMapOfSimpleClass_String10; - case (9): + case(9): return TreeMapOfSimpleClass_String11; - case (10): + case(10): return TreeMapOfSimpleClass_String12; - case (11): + case(11): return TreeMapOfSimpleClass_String13; - case (12): + case(12): return TreeMapOfSimpleClass_String15; - case (13): + case(13): return TreeMapOfSimpleClass_String17; - case (14): + case(14): return TreeMapOfSimpleInterface_String18; - case (15): + case(15): return TreeMapOfSimpleInterface_String19; - case (16): + case(16): return TreeMapOfSimpleInterface_String20; - case (17): + case(17): return TreeMapOfSimpleInterface_String21; - case (18): + case(18): return TreeMapOfSimpleInterface_String22; - case (19): + case(19): return TreeMapOfSimpleInterface_String24; - case (20): + case(20): return TreeMapOfSimpleInterface_String26; - case (21): + case(21): return TreeMapOfString_String27; - case (22): + case(22): return TreeMapOfString_String28; - case (23): + case(23): return TreeMapOfString_String29; - case (24): + case(24): return TreeMapOfString_String30; - case (25): + case(25): return TreeMapOfString_String31; - case (26): + case(26): return TreeMapOfString_String33; - case (27): + case(27): return TreeMapOfString_String35; - case (28): + case(28): return TreeMapOfDate_String36; - case (29): + case(29): return TreeMapOfDate_String37; - case (30): + case(30): return TreeMapOfDate_String38; - case (31): + case(31): return TreeMapOfDate_String39; - case (32): + case(32): return TreeMapOfDate_String40; - case (33): + case(33): return TreeMapOfDate_String42; - case (34): + case(34): return TreeMapOfDate_String44; - case (35): + case(35): return TreeMapOfBigDecimal_String45; - case (36): + case(36): return TreeMapOfBigDecimal_String46; - case (37): + case(37): return TreeMapOfBigDecimal_String47; - case (38): + case(38): return TreeMapOfBigDecimal_String48; - case (39): + case(39): return TreeMapOfBigDecimal_String49; - case (40): + case(40): return TreeMapOfBigDecimal_String51; - case (41): + case(41): return TreeMapOfBigDecimal_String53; - case (42): + case(42): return TreeMapOfBigInteger_String54; - case (43): + case(43): return TreeMapOfBigInteger_String55; - case (44): + case(44): return TreeMapOfBigInteger_String56; - case (45): + case(45): return TreeMapOfBigInteger_String57; - case (46): + case(46): return TreeMapOfBigInteger_String58; - case (47): + case(47): return TreeMapOfBigInteger_String60; - case (48): + case(48): return TreeMapOfBigInteger_String62; - case (49): + case(49): return TreeMapOfByte_String63; - case (50): + case(50): return TreeMapOfByte_String64; - case (51): + case(51): return TreeMapOfByte_String65; - case (52): + case(52): return TreeMapOfByte_String66; - case (53): + case(53): return TreeMapOfByte_String67; - case (54): + case(54): return TreeMapOfByte_String69; - case (55): + case(55): return TreeMapOfByte_String71; - case (56): + case(56): return TreeMapOfDouble_String72; - case (57): + case(57): return TreeMapOfDouble_String73; - case (58): + case(58): return TreeMapOfDouble_String74; - case (59): + case(59): return TreeMapOfDouble_String75; - case (60): + case(60): return TreeMapOfDouble_String76; - case (61): + case(61): return TreeMapOfDouble_String78; - case (62): + case(62): return TreeMapOfDouble_String80; - case (63): + case(63): return TreeMapOfFloat_String81; - case (64): + case(64): return TreeMapOfFloat_String82; - case (65): + case(65): return TreeMapOfFloat_String83; - case (66): + case(66): return TreeMapOfFloat_String84; - case (67): + case(67): return TreeMapOfFloat_String85; - case (68): + case(68): return TreeMapOfFloat_String87; - case (69): + case(69): return TreeMapOfFloat_String89; - case (70): + case(70): return TreeMapOfInteger_String90; - case (71): + case(71): return TreeMapOfInteger_String91; - case (72): + case(72): return TreeMapOfInteger_String92; - case (73): + case(73): return TreeMapOfInteger_String93; - case (74): + case(74): return TreeMapOfInteger_String94; - case (75): + case(75): return TreeMapOfInteger_String96; - case (76): + case(76): return TreeMapOfInteger_String98; - case (77): + case(77): return TreeMapOfLong_String99; - case (78): + case(78): return TreeMapOfLong_String100; - case (79): + case(79): return TreeMapOfLong_String101; - case (80): + case(80): return TreeMapOfLong_String102; - case (81): + case(81): return TreeMapOfLong_String103; - case (82): + case(82): return TreeMapOfLong_String105; - case (83): + case(83): return TreeMapOfLong_String107; - case (84): + case(84): return TreeMapOfShort_String108; - case (85): + case(85): return TreeMapOfShort_String109; - case (86): + case(86): return TreeMapOfShort_String110; - case (87): + case(87): return TreeMapOfShort_String111; - case (88): + case(88): return TreeMapOfShort_String112; - case (89): + case(89): return TreeMapOfShort_String114; - case (90): + case(90): return TreeMapOfShort_String116; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, TreeMap value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - TreeMapOfObject_String0 = value; - break; - case (1): - TreeMapOfObject_String1 = value; - break; - case (2): - TreeMapOfObject_String2 = value; - break; - case (3): - TreeMapOfObject_String3 = value; - break; - case (4): - TreeMapOfObject_String4 = value; - break; - case (5): - TreeMapOfObject_String6 = value; - break; - case (6): - TreeMapOfObject_String8 = value; - break; - case (7): - TreeMapOfSimpleClass_String9 = value; - break; - case (8): - TreeMapOfSimpleClass_String10 = value; - break; - case (9): - TreeMapOfSimpleClass_String11 = value; - break; - case (10): - TreeMapOfSimpleClass_String12 = value; - break; - case (11): - TreeMapOfSimpleClass_String13 = value; - break; - case (12): - TreeMapOfSimpleClass_String15 = value; - break; - case (13): - TreeMapOfSimpleClass_String17 = value; - break; - case (14): - TreeMapOfSimpleInterface_String18 = value; - break; - case (15): - TreeMapOfSimpleInterface_String19 = value; - break; - case (16): - TreeMapOfSimpleInterface_String20 = value; - break; - case (17): - TreeMapOfSimpleInterface_String21 = value; - break; - case (18): - TreeMapOfSimpleInterface_String22 = value; - break; - case (19): - TreeMapOfSimpleInterface_String24 = value; - break; - case (20): - TreeMapOfSimpleInterface_String26 = value; - break; - case (21): - TreeMapOfString_String27 = value; - break; - case (22): - TreeMapOfString_String28 = value; - break; - case (23): - TreeMapOfString_String29 = value; - break; - case (24): - TreeMapOfString_String30 = value; - break; - case (25): - TreeMapOfString_String31 = value; - break; - case (26): - TreeMapOfString_String33 = value; - break; - case (27): - TreeMapOfString_String35 = value; - break; - case (28): - TreeMapOfDate_String36 = value; - break; - case (29): - TreeMapOfDate_String37 = value; - break; - case (30): - TreeMapOfDate_String38 = value; - break; - case (31): - TreeMapOfDate_String39 = value; - break; - case (32): - TreeMapOfDate_String40 = value; - break; - case (33): - TreeMapOfDate_String42 = value; - break; - case (34): - TreeMapOfDate_String44 = value; - break; - case (35): - TreeMapOfBigDecimal_String45 = value; - break; - case (36): - TreeMapOfBigDecimal_String46 = value; - break; - case (37): - TreeMapOfBigDecimal_String47 = value; - break; - case (38): - TreeMapOfBigDecimal_String48 = value; - break; - case (39): - TreeMapOfBigDecimal_String49 = value; - break; - case (40): - TreeMapOfBigDecimal_String51 = value; - break; - case (41): - TreeMapOfBigDecimal_String53 = value; - break; - case (42): - TreeMapOfBigInteger_String54 = value; - break; - case (43): - TreeMapOfBigInteger_String55 = value; - break; - case (44): - TreeMapOfBigInteger_String56 = value; - break; - case (45): - TreeMapOfBigInteger_String57 = value; - break; - case (46): - TreeMapOfBigInteger_String58 = value; - break; - case (47): - TreeMapOfBigInteger_String60 = value; - break; - case (48): - TreeMapOfBigInteger_String62 = value; - break; - case (49): - TreeMapOfByte_String63 = value; - break; - case (50): - TreeMapOfByte_String64 = value; - break; - case (51): - TreeMapOfByte_String65 = value; - break; - case (52): - TreeMapOfByte_String66 = value; - break; - case (53): - TreeMapOfByte_String67 = value; - break; - case (54): - TreeMapOfByte_String69 = value; - break; - case (55): - TreeMapOfByte_String71 = value; - break; - case (56): - TreeMapOfDouble_String72 = value; - break; - case (57): - TreeMapOfDouble_String73 = value; - break; - case (58): - TreeMapOfDouble_String74 = value; - break; - case (59): - TreeMapOfDouble_String75 = value; - break; - case (60): - TreeMapOfDouble_String76 = value; - break; - case (61): - TreeMapOfDouble_String78 = value; - break; - case (62): - TreeMapOfDouble_String80 = value; - break; - case (63): - TreeMapOfFloat_String81 = value; - break; - case (64): - TreeMapOfFloat_String82 = value; - break; - case (65): - TreeMapOfFloat_String83 = value; - break; - case (66): - TreeMapOfFloat_String84 = value; - break; - case (67): - TreeMapOfFloat_String85 = value; - break; - case (68): - TreeMapOfFloat_String87 = value; - break; - case (69): - TreeMapOfFloat_String89 = value; - break; - case (70): - TreeMapOfInteger_String90 = value; - break; - case (71): - TreeMapOfInteger_String91 = value; - break; - case (72): - TreeMapOfInteger_String92 = value; - break; - case (73): - TreeMapOfInteger_String93 = value; - break; - case (74): - TreeMapOfInteger_String94 = value; - break; - case (75): - TreeMapOfInteger_String96 = value; - break; - case (76): - TreeMapOfInteger_String98 = value; - break; - case (77): - TreeMapOfLong_String99 = value; - break; - case (78): - TreeMapOfLong_String100 = value; - break; - case (79): - TreeMapOfLong_String101 = value; - break; - case (80): - TreeMapOfLong_String102 = value; - break; - case (81): - TreeMapOfLong_String103 = value; - break; - case (82): - TreeMapOfLong_String105 = value; - break; - case (83): - TreeMapOfLong_String107 = value; - break; - case (84): - TreeMapOfShort_String108 = value; - break; - case (85): - TreeMapOfShort_String109 = value; - break; - case (86): - TreeMapOfShort_String110 = value; - break; - case (87): - TreeMapOfShort_String111 = value; - break; - case (88): - TreeMapOfShort_String112 = value; - break; - case (89): - TreeMapOfShort_String114 = value; - break; - case (90): - TreeMapOfShort_String116 = value; - break; + public boolean set(int index,TreeMap value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + TreeMapOfObject_String0= value; + break; + case(1): + TreeMapOfObject_String1= value; + break; + case(2): + TreeMapOfObject_String2= value; + break; + case(3): + TreeMapOfObject_String3= value; + break; + case(4): + TreeMapOfObject_String4= value; + break; + case(5): + TreeMapOfObject_String6= value; + break; + case(6): + TreeMapOfObject_String8= value; + break; + case(7): + TreeMapOfSimpleClass_String9= value; + break; + case(8): + TreeMapOfSimpleClass_String10= value; + break; + case(9): + TreeMapOfSimpleClass_String11= value; + break; + case(10): + TreeMapOfSimpleClass_String12= value; + break; + case(11): + TreeMapOfSimpleClass_String13= value; + break; + case(12): + TreeMapOfSimpleClass_String15= value; + break; + case(13): + TreeMapOfSimpleClass_String17= value; + break; + case(14): + TreeMapOfSimpleInterface_String18= value; + break; + case(15): + TreeMapOfSimpleInterface_String19= value; + break; + case(16): + TreeMapOfSimpleInterface_String20= value; + break; + case(17): + TreeMapOfSimpleInterface_String21= value; + break; + case(18): + TreeMapOfSimpleInterface_String22= value; + break; + case(19): + TreeMapOfSimpleInterface_String24= value; + break; + case(20): + TreeMapOfSimpleInterface_String26= value; + break; + case(21): + TreeMapOfString_String27= value; + break; + case(22): + TreeMapOfString_String28= value; + break; + case(23): + TreeMapOfString_String29= value; + break; + case(24): + TreeMapOfString_String30= value; + break; + case(25): + TreeMapOfString_String31= value; + break; + case(26): + TreeMapOfString_String33= value; + break; + case(27): + TreeMapOfString_String35= value; + break; + case(28): + TreeMapOfDate_String36= value; + break; + case(29): + TreeMapOfDate_String37= value; + break; + case(30): + TreeMapOfDate_String38= value; + break; + case(31): + TreeMapOfDate_String39= value; + break; + case(32): + TreeMapOfDate_String40= value; + break; + case(33): + TreeMapOfDate_String42= value; + break; + case(34): + TreeMapOfDate_String44= value; + break; + case(35): + TreeMapOfBigDecimal_String45= value; + break; + case(36): + TreeMapOfBigDecimal_String46= value; + break; + case(37): + TreeMapOfBigDecimal_String47= value; + break; + case(38): + TreeMapOfBigDecimal_String48= value; + break; + case(39): + TreeMapOfBigDecimal_String49= value; + break; + case(40): + TreeMapOfBigDecimal_String51= value; + break; + case(41): + TreeMapOfBigDecimal_String53= value; + break; + case(42): + TreeMapOfBigInteger_String54= value; + break; + case(43): + TreeMapOfBigInteger_String55= value; + break; + case(44): + TreeMapOfBigInteger_String56= value; + break; + case(45): + TreeMapOfBigInteger_String57= value; + break; + case(46): + TreeMapOfBigInteger_String58= value; + break; + case(47): + TreeMapOfBigInteger_String60= value; + break; + case(48): + TreeMapOfBigInteger_String62= value; + break; + case(49): + TreeMapOfByte_String63= value; + break; + case(50): + TreeMapOfByte_String64= value; + break; + case(51): + TreeMapOfByte_String65= value; + break; + case(52): + TreeMapOfByte_String66= value; + break; + case(53): + TreeMapOfByte_String67= value; + break; + case(54): + TreeMapOfByte_String69= value; + break; + case(55): + TreeMapOfByte_String71= value; + break; + case(56): + TreeMapOfDouble_String72= value; + break; + case(57): + TreeMapOfDouble_String73= value; + break; + case(58): + TreeMapOfDouble_String74= value; + break; + case(59): + TreeMapOfDouble_String75= value; + break; + case(60): + TreeMapOfDouble_String76= value; + break; + case(61): + TreeMapOfDouble_String78= value; + break; + case(62): + TreeMapOfDouble_String80= value; + break; + case(63): + TreeMapOfFloat_String81= value; + break; + case(64): + TreeMapOfFloat_String82= value; + break; + case(65): + TreeMapOfFloat_String83= value; + break; + case(66): + TreeMapOfFloat_String84= value; + break; + case(67): + TreeMapOfFloat_String85= value; + break; + case(68): + TreeMapOfFloat_String87= value; + break; + case(69): + TreeMapOfFloat_String89= value; + break; + case(70): + TreeMapOfInteger_String90= value; + break; + case(71): + TreeMapOfInteger_String91= value; + break; + case(72): + TreeMapOfInteger_String92= value; + break; + case(73): + TreeMapOfInteger_String93= value; + break; + case(74): + TreeMapOfInteger_String94= value; + break; + case(75): + TreeMapOfInteger_String96= value; + break; + case(76): + TreeMapOfInteger_String98= value; + break; + case(77): + TreeMapOfLong_String99= value; + break; + case(78): + TreeMapOfLong_String100= value; + break; + case(79): + TreeMapOfLong_String101= value; + break; + case(80): + TreeMapOfLong_String102= value; + break; + case(81): + TreeMapOfLong_String103= value; + break; + case(82): + TreeMapOfLong_String105= value; + break; + case(83): + TreeMapOfLong_String107= value; + break; + case(84): + TreeMapOfShort_String108= value; + break; + case(85): + TreeMapOfShort_String109= value; + break; + case(86): + TreeMapOfShort_String110= value; + break; + case(87): + TreeMapOfShort_String111= value; + break; + case(88): + TreeMapOfShort_String112= value; + break; + case(89): + TreeMapOfShort_String114= value; + break; + case(90): + TreeMapOfShort_String116= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/TreeSetCollections.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/TreeSetCollections.java index 92c8a2778..ea29b32f3 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/TreeSetCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/TreeSetCollections.java @@ -5,22 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; import java.util.TreeSet; -public class TreeSetCollections { +public class TreeSetCollections { public int identifier; public TreeSet TreeSetOfObject0; public TreeSet TreeSetOfObject1; @@ -62,290 +62,289 @@ public class TreeSetCollections { public TreeSet TreeSetOfShort37; public TreeSet TreeSetOfShort38; - public static final String[] fieldSpecs = { - "public TreeSet TreeSetOfObject0", - "embedded-element=true public TreeSet TreeSetOfObject1", - "embedded-element=false public TreeSet TreeSetOfObject2", - "public TreeSet TreeSetOfSimpleClass3", - "embedded-element=true public TreeSet TreeSetOfSimpleClass4", - "embedded-element=false public TreeSet TreeSetOfSimpleClass5", - "public TreeSet TreeSetOfSimpleInterface6", - "embedded-element=true public TreeSet TreeSetOfSimpleInterface7", - "embedded-element=false public TreeSet TreeSetOfSimpleInterface8", - "public TreeSet TreeSetOfString9", - "embedded-element=true public TreeSet TreeSetOfString10", - "embedded-element=false public TreeSet TreeSetOfString11", - "public TreeSet TreeSetOfDate12", - "embedded-element=true public TreeSet TreeSetOfDate13", - "embedded-element=false public TreeSet TreeSetOfDate14", - "public TreeSet TreeSetOfBigDecimal15", - "embedded-element=true public TreeSet TreeSetOfBigDecimal16", - "embedded-element=false public TreeSet TreeSetOfBigDecimal17", - "public TreeSet TreeSetOfBigInteger18", - "embedded-element=true public TreeSet TreeSetOfBigInteger19", - "embedded-element=false public TreeSet TreeSetOfBigInteger20", - "public TreeSet TreeSetOfByte21", - "embedded-element=true public TreeSet TreeSetOfByte22", - "embedded-element=false public TreeSet TreeSetOfByte23", - "public TreeSet TreeSetOfDouble24", - "embedded-element=true public TreeSet TreeSetOfDouble25", - "embedded-element=false public TreeSet TreeSetOfDouble26", - "public TreeSet TreeSetOfFloat27", - "embedded-element=true public TreeSet TreeSetOfFloat28", - "embedded-element=false public TreeSet TreeSetOfFloat29", - "public TreeSet TreeSetOfInteger30", - "embedded-element=true public TreeSet TreeSetOfInteger31", - "embedded-element=false public TreeSet TreeSetOfInteger32", - "public TreeSet TreeSetOfLong33", - "embedded-element=true public TreeSet TreeSetOfLong34", - "embedded-element=false public TreeSet TreeSetOfLong35", - "public TreeSet TreeSetOfShort36", - "embedded-element=true public TreeSet TreeSetOfShort37", - "embedded-element=false public TreeSet TreeSetOfShort38" + public static final String [] fieldSpecs = { + "public TreeSet TreeSetOfObject0", + "embedded-element=true public TreeSet TreeSetOfObject1", + "embedded-element=false public TreeSet TreeSetOfObject2", + "public TreeSet TreeSetOfSimpleClass3", + "embedded-element=true public TreeSet TreeSetOfSimpleClass4", + "embedded-element=false public TreeSet TreeSetOfSimpleClass5", + "public TreeSet TreeSetOfSimpleInterface6", + "embedded-element=true public TreeSet TreeSetOfSimpleInterface7", + "embedded-element=false public TreeSet TreeSetOfSimpleInterface8", + "public TreeSet TreeSetOfString9", + "embedded-element=true public TreeSet TreeSetOfString10", + "embedded-element=false public TreeSet TreeSetOfString11", + "public TreeSet TreeSetOfDate12", + "embedded-element=true public TreeSet TreeSetOfDate13", + "embedded-element=false public TreeSet TreeSetOfDate14", + "public TreeSet TreeSetOfBigDecimal15", + "embedded-element=true public TreeSet TreeSetOfBigDecimal16", + "embedded-element=false public TreeSet TreeSetOfBigDecimal17", + "public TreeSet TreeSetOfBigInteger18", + "embedded-element=true public TreeSet TreeSetOfBigInteger19", + "embedded-element=false public TreeSet TreeSetOfBigInteger20", + "public TreeSet TreeSetOfByte21", + "embedded-element=true public TreeSet TreeSetOfByte22", + "embedded-element=false public TreeSet TreeSetOfByte23", + "public TreeSet TreeSetOfDouble24", + "embedded-element=true public TreeSet TreeSetOfDouble25", + "embedded-element=false public TreeSet TreeSetOfDouble26", + "public TreeSet TreeSetOfFloat27", + "embedded-element=true public TreeSet TreeSetOfFloat28", + "embedded-element=false public TreeSet TreeSetOfFloat29", + "public TreeSet TreeSetOfInteger30", + "embedded-element=true public TreeSet TreeSetOfInteger31", + "embedded-element=false public TreeSet TreeSetOfInteger32", + "public TreeSet TreeSetOfLong33", + "embedded-element=true public TreeSet TreeSetOfLong34", + "embedded-element=false public TreeSet TreeSetOfLong35", + "public TreeSet TreeSetOfShort36", + "embedded-element=true public TreeSet TreeSetOfShort37", + "embedded-element=false public TreeSet TreeSetOfShort38" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public TreeSet get(int index) { - switch (index) { - case (0): + public TreeSet get(int index) + { + switch (index) + { + case(0): return TreeSetOfObject0; - case (1): + case(1): return TreeSetOfObject1; - case (2): + case(2): return TreeSetOfObject2; - case (3): + case(3): return TreeSetOfSimpleClass3; - case (4): + case(4): return TreeSetOfSimpleClass4; - case (5): + case(5): return TreeSetOfSimpleClass5; - case (6): + case(6): return TreeSetOfSimpleInterface6; - case (7): + case(7): return TreeSetOfSimpleInterface7; - case (8): + case(8): return TreeSetOfSimpleInterface8; - case (9): + case(9): return TreeSetOfString9; - case (10): + case(10): return TreeSetOfString10; - case (11): + case(11): return TreeSetOfString11; - case (12): + case(12): return TreeSetOfDate12; - case (13): + case(13): return TreeSetOfDate13; - case (14): + case(14): return TreeSetOfDate14; - case (15): + case(15): return TreeSetOfBigDecimal15; - case (16): + case(16): return TreeSetOfBigDecimal16; - case (17): + case(17): return TreeSetOfBigDecimal17; - case (18): + case(18): return TreeSetOfBigInteger18; - case (19): + case(19): return TreeSetOfBigInteger19; - case (20): + case(20): return TreeSetOfBigInteger20; - case (21): + case(21): return TreeSetOfByte21; - case (22): + case(22): return TreeSetOfByte22; - case (23): + case(23): return TreeSetOfByte23; - case (24): + case(24): return TreeSetOfDouble24; - case (25): + case(25): return TreeSetOfDouble25; - case (26): + case(26): return TreeSetOfDouble26; - case (27): + case(27): return TreeSetOfFloat27; - case (28): + case(28): return TreeSetOfFloat28; - case (29): + case(29): return TreeSetOfFloat29; - case (30): + case(30): return TreeSetOfInteger30; - case (31): + case(31): return TreeSetOfInteger31; - case (32): + case(32): return TreeSetOfInteger32; - case (33): + case(33): return TreeSetOfLong33; - case (34): + case(34): return TreeSetOfLong34; - case (35): + case(35): return TreeSetOfLong35; - case (36): + case(36): return TreeSetOfShort36; - case (37): + case(37): return TreeSetOfShort37; - case (38): + case(38): return TreeSetOfShort38; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, TreeSet value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - TreeSetOfObject0 = value; - break; - case (1): - TreeSetOfObject1 = value; - break; - case (2): - TreeSetOfObject2 = value; - break; - case (3): - TreeSetOfSimpleClass3 = value; - break; - case (4): - TreeSetOfSimpleClass4 = value; - break; - case (5): - TreeSetOfSimpleClass5 = value; - break; - case (6): - TreeSetOfSimpleInterface6 = value; - break; - case (7): - TreeSetOfSimpleInterface7 = value; - break; - case (8): - TreeSetOfSimpleInterface8 = value; - break; - case (9): - TreeSetOfString9 = value; - break; - case (10): - TreeSetOfString10 = value; - break; - case (11): - TreeSetOfString11 = value; - break; - case (12): - TreeSetOfDate12 = value; - break; - case (13): - TreeSetOfDate13 = value; - break; - case (14): - TreeSetOfDate14 = value; - break; - case (15): - TreeSetOfBigDecimal15 = value; - break; - case (16): - TreeSetOfBigDecimal16 = value; - break; - case (17): - TreeSetOfBigDecimal17 = value; - break; - case (18): - TreeSetOfBigInteger18 = value; - break; - case (19): - TreeSetOfBigInteger19 = value; - break; - case (20): - TreeSetOfBigInteger20 = value; - break; - case (21): - TreeSetOfByte21 = value; - break; - case (22): - TreeSetOfByte22 = value; - break; - case (23): - TreeSetOfByte23 = value; - break; - case (24): - TreeSetOfDouble24 = value; - break; - case (25): - TreeSetOfDouble25 = value; - break; - case (26): - TreeSetOfDouble26 = value; - break; - case (27): - TreeSetOfFloat27 = value; - break; - case (28): - TreeSetOfFloat28 = value; - break; - case (29): - TreeSetOfFloat29 = value; - break; - case (30): - TreeSetOfInteger30 = value; - break; - case (31): - TreeSetOfInteger31 = value; - break; - case (32): - TreeSetOfInteger32 = value; - break; - case (33): - TreeSetOfLong33 = value; - break; - case (34): - TreeSetOfLong34 = value; - break; - case (35): - TreeSetOfLong35 = value; - break; - case (36): - TreeSetOfShort36 = value; - break; - case (37): - TreeSetOfShort37 = value; - break; - case (38): - TreeSetOfShort38 = value; - break; + public boolean set(int index,TreeSet value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + TreeSetOfObject0= value; + break; + case(1): + TreeSetOfObject1= value; + break; + case(2): + TreeSetOfObject2= value; + break; + case(3): + TreeSetOfSimpleClass3= value; + break; + case(4): + TreeSetOfSimpleClass4= value; + break; + case(5): + TreeSetOfSimpleClass5= value; + break; + case(6): + TreeSetOfSimpleInterface6= value; + break; + case(7): + TreeSetOfSimpleInterface7= value; + break; + case(8): + TreeSetOfSimpleInterface8= value; + break; + case(9): + TreeSetOfString9= value; + break; + case(10): + TreeSetOfString10= value; + break; + case(11): + TreeSetOfString11= value; + break; + case(12): + TreeSetOfDate12= value; + break; + case(13): + TreeSetOfDate13= value; + break; + case(14): + TreeSetOfDate14= value; + break; + case(15): + TreeSetOfBigDecimal15= value; + break; + case(16): + TreeSetOfBigDecimal16= value; + break; + case(17): + TreeSetOfBigDecimal17= value; + break; + case(18): + TreeSetOfBigInteger18= value; + break; + case(19): + TreeSetOfBigInteger19= value; + break; + case(20): + TreeSetOfBigInteger20= value; + break; + case(21): + TreeSetOfByte21= value; + break; + case(22): + TreeSetOfByte22= value; + break; + case(23): + TreeSetOfByte23= value; + break; + case(24): + TreeSetOfDouble24= value; + break; + case(25): + TreeSetOfDouble25= value; + break; + case(26): + TreeSetOfDouble26= value; + break; + case(27): + TreeSetOfFloat27= value; + break; + case(28): + TreeSetOfFloat28= value; + break; + case(29): + TreeSetOfFloat29= value; + break; + case(30): + TreeSetOfInteger30= value; + break; + case(31): + TreeSetOfInteger31= value; + break; + case(32): + TreeSetOfInteger32= value; + break; + case(33): + TreeSetOfLong33= value; + break; + case(34): + TreeSetOfLong34= value; + break; + case(35): + TreeSetOfLong35= value; + break; + case(36): + TreeSetOfShort36= value; + break; + case(37): + TreeSetOfShort37= value; + break; + case(38): + TreeSetOfShort38= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/VectorCollections.java b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/VectorCollections.java index e4b0acd75..10156302a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/VectorCollections.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/fieldtypes/VectorCollections.java @@ -5,22 +5,22 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.fieldtypes; import java.io.Serializable; import java.util.Vector; -public class VectorCollections { +public class VectorCollections { public int identifier; public Vector VectorOfObject0; public Vector VectorOfObject1; @@ -66,314 +66,314 @@ public class VectorCollections { public Vector VectorOfShort41; public Vector VectorOfSimpleClass42; - public static final String[] fieldSpecs = { - "public Vector VectorOfObject0", - "embedded-element=true public Vector VectorOfObject1", - "embedded-element=false public Vector VectorOfObject2", - "public Vector VectorOfSimpleClass3", - "embedded-element=true public Vector VectorOfSimpleClass4", - "embedded-element=false public Vector VectorOfSimpleClass5", - "public Vector VectorOfSimpleInterface6", - "embedded-element=true public Vector VectorOfSimpleInterface7", - "embedded-element=false public Vector VectorOfSimpleInterface8", - "public Vector VectorOfString9", - "embedded-element=true public Vector VectorOfString10", - "embedded-element=false public Vector VectorOfString11", - "public Vector VectorOfDate12", - "embedded-element=true public Vector VectorOfDate13", - "embedded-element=false public Vector VectorOfDate14", - "public Vector VectorOfLocale15", - "embedded-element=true public Vector VectorOfLocale16", - "embedded-element=false public Vector VectorOfLocale17", - "public Vector VectorOfBigDecimal18", - "embedded-element=true public Vector VectorOfBigDecimal19", - "embedded-element=false public Vector VectorOfBigDecimal20", - "public Vector VectorOfBigInteger21", - "embedded-element=true public Vector VectorOfBigInteger22", - "embedded-element=false public Vector VectorOfBigInteger23", - "public Vector VectorOfByte24", - "embedded-element=true public Vector VectorOfByte25", - "embedded-element=false public Vector VectorOfByte26", - "public Vector VectorOfDouble27", - "embedded-element=true public Vector VectorOfDouble28", - "embedded-element=false public Vector VectorOfDouble29", - "public Vector VectorOfFloat30", - "embedded-element=true public Vector VectorOfFloat31", - "embedded-element=false public Vector VectorOfFloat32", - "public Vector VectorOfInteger33", - "embedded-element=true public Vector VectorOfInteger34", - "embedded-element=false public Vector VectorOfInteger35", - "public Vector VectorOfLong36", - "embedded-element=true public Vector VectorOfLong37", - "embedded-element=false public Vector VectorOfLong38", - "public Vector VectorOfShort39", - "embedded-element=true public Vector VectorOfShort40", - "embedded-element=false public Vector VectorOfShort41", - "serialized=true public Vector VectorOfSimpleClass42" + public static final String [] fieldSpecs = { + "public Vector VectorOfObject0", + "embedded-element=true public Vector VectorOfObject1", + "embedded-element=false public Vector VectorOfObject2", + "public Vector VectorOfSimpleClass3", + "embedded-element=true public Vector VectorOfSimpleClass4", + "embedded-element=false public Vector VectorOfSimpleClass5", + "public Vector VectorOfSimpleInterface6", + "embedded-element=true public Vector VectorOfSimpleInterface7", + "embedded-element=false public Vector VectorOfSimpleInterface8", + "public Vector VectorOfString9", + "embedded-element=true public Vector VectorOfString10", + "embedded-element=false public Vector VectorOfString11", + "public Vector VectorOfDate12", + "embedded-element=true public Vector VectorOfDate13", + "embedded-element=false public Vector VectorOfDate14", + "public Vector VectorOfLocale15", + "embedded-element=true public Vector VectorOfLocale16", + "embedded-element=false public Vector VectorOfLocale17", + "public Vector VectorOfBigDecimal18", + "embedded-element=true public Vector VectorOfBigDecimal19", + "embedded-element=false public Vector VectorOfBigDecimal20", + "public Vector VectorOfBigInteger21", + "embedded-element=true public Vector VectorOfBigInteger22", + "embedded-element=false public Vector VectorOfBigInteger23", + "public Vector VectorOfByte24", + "embedded-element=true public Vector VectorOfByte25", + "embedded-element=false public Vector VectorOfByte26", + "public Vector VectorOfDouble27", + "embedded-element=true public Vector VectorOfDouble28", + "embedded-element=false public Vector VectorOfDouble29", + "public Vector VectorOfFloat30", + "embedded-element=true public Vector VectorOfFloat31", + "embedded-element=false public Vector VectorOfFloat32", + "public Vector VectorOfInteger33", + "embedded-element=true public Vector VectorOfInteger34", + "embedded-element=false public Vector VectorOfInteger35", + "public Vector VectorOfLong36", + "embedded-element=true public Vector VectorOfLong37", + "embedded-element=false public Vector VectorOfLong38", + "public Vector VectorOfShort39", + "embedded-element=true public Vector VectorOfShort40", + "embedded-element=false public Vector VectorOfShort41", + "serialized=true public Vector VectorOfSimpleClass42" }; - - public int getLength() { + public int getLength() + { return fieldSpecs.length; } - - public Vector get(int index) { - switch (index) { - case (0): + public Vector get(int index) + { + switch (index) + { + case(0): return VectorOfObject0; - case (1): + case(1): return VectorOfObject1; - case (2): + case(2): return VectorOfObject2; - case (3): + case(3): return VectorOfSimpleClass3; - case (4): + case(4): return VectorOfSimpleClass4; - case (5): + case(5): return VectorOfSimpleClass5; - case (6): + case(6): return VectorOfSimpleInterface6; - case (7): + case(7): return VectorOfSimpleInterface7; - case (8): + case(8): return VectorOfSimpleInterface8; - case (9): + case(9): return VectorOfString9; - case (10): + case(10): return VectorOfString10; - case (11): + case(11): return VectorOfString11; - case (12): + case(12): return VectorOfDate12; - case (13): + case(13): return VectorOfDate13; - case (14): + case(14): return VectorOfDate14; - case (15): + case(15): return VectorOfLocale15; - case (16): + case(16): return VectorOfLocale16; - case (17): + case(17): return VectorOfLocale17; - case (18): + case(18): return VectorOfBigDecimal18; - case (19): + case(19): return VectorOfBigDecimal19; - case (20): + case(20): return VectorOfBigDecimal20; - case (21): + case(21): return VectorOfBigInteger21; - case (22): + case(22): return VectorOfBigInteger22; - case (23): + case(23): return VectorOfBigInteger23; - case (24): + case(24): return VectorOfByte24; - case (25): + case(25): return VectorOfByte25; - case (26): + case(26): return VectorOfByte26; - case (27): + case(27): return VectorOfDouble27; - case (28): + case(28): return VectorOfDouble28; - case (29): + case(29): return VectorOfDouble29; - case (30): + case(30): return VectorOfFloat30; - case (31): + case(31): return VectorOfFloat31; - case (32): + case(32): return VectorOfFloat32; - case (33): + case(33): return VectorOfInteger33; - case (34): + case(34): return VectorOfInteger34; - case (35): + case(35): return VectorOfInteger35; - case (36): + case(36): return VectorOfLong36; - case (37): + case(37): return VectorOfLong37; - case (38): + case(38): return VectorOfLong38; - case (39): + case(39): return VectorOfShort39; - case (40): + case(40): return VectorOfShort40; - case (41): + case(41): return VectorOfShort41; - case (42): + case(42): return VectorOfSimpleClass42; default: throw new IndexOutOfBoundsException(); } } - - public boolean set(int index, Vector value) { - if (fieldSpecs[index].indexOf("final") != -1) return false; - switch (index) { - case (0): - VectorOfObject0 = value; - break; - case (1): - VectorOfObject1 = value; - break; - case (2): - VectorOfObject2 = value; - break; - case (3): - VectorOfSimpleClass3 = value; - break; - case (4): - VectorOfSimpleClass4 = value; - break; - case (5): - VectorOfSimpleClass5 = value; - break; - case (6): - VectorOfSimpleInterface6 = value; - break; - case (7): - VectorOfSimpleInterface7 = value; - break; - case (8): - VectorOfSimpleInterface8 = value; - break; - case (9): - VectorOfString9 = value; - break; - case (10): - VectorOfString10 = value; - break; - case (11): - VectorOfString11 = value; - break; - case (12): - VectorOfDate12 = value; - break; - case (13): - VectorOfDate13 = value; - break; - case (14): - VectorOfDate14 = value; - break; - case (15): - VectorOfLocale15 = value; - break; - case (16): - VectorOfLocale16 = value; - break; - case (17): - VectorOfLocale17 = value; - break; - case (18): - VectorOfBigDecimal18 = value; - break; - case (19): - VectorOfBigDecimal19 = value; - break; - case (20): - VectorOfBigDecimal20 = value; - break; - case (21): - VectorOfBigInteger21 = value; - break; - case (22): - VectorOfBigInteger22 = value; - break; - case (23): - VectorOfBigInteger23 = value; - break; - case (24): - VectorOfByte24 = value; - break; - case (25): - VectorOfByte25 = value; - break; - case (26): - VectorOfByte26 = value; - break; - case (27): - VectorOfDouble27 = value; - break; - case (28): - VectorOfDouble28 = value; - break; - case (29): - VectorOfDouble29 = value; - break; - case (30): - VectorOfFloat30 = value; - break; - case (31): - VectorOfFloat31 = value; - break; - case (32): - VectorOfFloat32 = value; - break; - case (33): - VectorOfInteger33 = value; - break; - case (34): - VectorOfInteger34 = value; - break; - case (35): - VectorOfInteger35 = value; - break; - case (36): - VectorOfLong36 = value; - break; - case (37): - VectorOfLong37 = value; - break; - case (38): - VectorOfLong38 = value; - break; - case (39): - VectorOfShort39 = value; - break; - case (40): - VectorOfShort40 = value; - break; - case (41): - VectorOfShort41 = value; - break; - case (42): - VectorOfSimpleClass42 = value; - break; + public boolean set(int index,Vector value) + { + if(fieldSpecs[index].indexOf("final") != -1) + return false; + switch (index) + { + case(0): + VectorOfObject0= value; + break; + case(1): + VectorOfObject1= value; + break; + case(2): + VectorOfObject2= value; + break; + case(3): + VectorOfSimpleClass3= value; + break; + case(4): + VectorOfSimpleClass4= value; + break; + case(5): + VectorOfSimpleClass5= value; + break; + case(6): + VectorOfSimpleInterface6= value; + break; + case(7): + VectorOfSimpleInterface7= value; + break; + case(8): + VectorOfSimpleInterface8= value; + break; + case(9): + VectorOfString9= value; + break; + case(10): + VectorOfString10= value; + break; + case(11): + VectorOfString11= value; + break; + case(12): + VectorOfDate12= value; + break; + case(13): + VectorOfDate13= value; + break; + case(14): + VectorOfDate14= value; + break; + case(15): + VectorOfLocale15= value; + break; + case(16): + VectorOfLocale16= value; + break; + case(17): + VectorOfLocale17= value; + break; + case(18): + VectorOfBigDecimal18= value; + break; + case(19): + VectorOfBigDecimal19= value; + break; + case(20): + VectorOfBigDecimal20= value; + break; + case(21): + VectorOfBigInteger21= value; + break; + case(22): + VectorOfBigInteger22= value; + break; + case(23): + VectorOfBigInteger23= value; + break; + case(24): + VectorOfByte24= value; + break; + case(25): + VectorOfByte25= value; + break; + case(26): + VectorOfByte26= value; + break; + case(27): + VectorOfDouble27= value; + break; + case(28): + VectorOfDouble28= value; + break; + case(29): + VectorOfDouble29= value; + break; + case(30): + VectorOfFloat30= value; + break; + case(31): + VectorOfFloat31= value; + break; + case(32): + VectorOfFloat32= value; + break; + case(33): + VectorOfInteger33= value; + break; + case(34): + VectorOfInteger34= value; + break; + case(35): + VectorOfInteger35= value; + break; + case(36): + VectorOfLong36= value; + break; + case(37): + VectorOfLong37= value; + break; + case(38): + VectorOfLong38= value; + break; + case(39): + VectorOfShort39= value; + break; + case(40): + VectorOfShort40= value; + break; + case(41): + VectorOfShort41= value; + break; + case(42): + VectorOfSimpleClass42= value; + break; default: throw new IndexOutOfBoundsException(); } return true; } - public static class Oid implements Serializable { - public int identifier; + public static class Oid implements Serializable { + public int identifier; - public Oid() {} + public Oid() { + } - public Oid(String s) { - identifier = Integer.parseInt(justTheId(s)); - } + public Oid(String s) { identifier = Integer.parseInt(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + identifier; - } + public String toString() { return this.getClass().getName() + + ": " + identifier;} - public int hashCode() { - return (int) identifier; - } + public int hashCode() { return (int)identifier ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.identifier == this.identifier; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.identifier == this.identifier; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/AllPersist.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/AllPersist.java index 0eb10a239..bffd43c4f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/AllPersist.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/AllPersist.java @@ -5,15 +5,16 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; @@ -22,63 +23,64 @@ /** */ public class AllPersist { - public int intA; // not managed - public double doubleB; // persistent - public int intB; // persistent - - private int keyValue; // persistent--used as key field in application identity - private static int nextKeyValue = 1; - - public int hashCode() { - return keyValue; - } - - public boolean equals(Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return false; - else return keyValue == ((Id) obj).keyValue; - } - - public AllPersist() { - intA = -1; - doubleB = 2.0; - intB = -5; - } - - public AllPersist(int intA, double doubleVal, int intB) { - keyValue = nextKeyValue++; - this.intA = intA; - doubleB = doubleVal; - this.intB = intB; - } - - public static class Id implements Serializable { - public int keyValue; - - public Id() {} - - public Id(int keyValue) { - this.keyValue = keyValue; - } - - public Id(String s) { - try { - keyValue = Integer.parseInt(s); - } catch (NumberFormatException e) { - keyValue = 0; - } + public int intA; // not managed + public double doubleB; // persistent + public int intB; // persistent + + private int keyValue; // persistent--used as key field in application identity + private static int nextKeyValue = 1; + + public int hashCode() { + return keyValue; } - + public boolean equals(Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return false; - else return keyValue == ((Id) obj).keyValue; + if( obj == null || !this.getClass().equals(obj.getClass()) ) return false; + else return keyValue == ((Id)obj).keyValue; } - - public int hashCode() { - return keyValue; + + public AllPersist() { + intA = -1; + doubleB = 2.0; + intB = -5; } - - public String toString() { - return Integer.toString(keyValue); + + public AllPersist(int intA, double doubleVal, int intB) { + keyValue = nextKeyValue++; + this.intA = intA; + doubleB = doubleVal; + this.intB = intB; + } + + public static class Id implements Serializable { + public int keyValue; + + public Id() { + } + + public Id(int keyValue) { + this.keyValue = keyValue; + } + + public Id(String s) { + try { + keyValue = Integer.parseInt(s);} + catch(NumberFormatException e){ + keyValue = 0; + } + } + + public boolean equals(Object obj) { + if( obj == null || !this.getClass().equals(obj.getClass()) ) return false; + else return keyValue == ((Id)obj).keyValue; + } + + public int hashCode() { + return keyValue; + } + + public String toString() { + return Integer.toString(keyValue); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/AllPersist2.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/AllPersist2.java index e6ed0a428..650ae60c6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/AllPersist2.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/AllPersist2.java @@ -5,36 +5,36 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; /** */ public class AllPersist2 extends AllPersist { - public char charC; // not managed - public boolean booleanD; // not managed - public float floatE; // transactional - - public AllPersist2() { - charC = '3'; - booleanD = false; - floatE = -4.4f; - } - - public AllPersist2( - int intA, double doubleB, int intB, char charC, boolean booleanVal, float floatE) { - super(intA, doubleB, intB); - this.charC = charC; - booleanD = booleanVal; - this.floatE = floatE; - } + public char charC; // not managed + public boolean booleanD; // not managed + public float floatE; // transactional + + public AllPersist2() { + charC = '3'; + booleanD = false; + floatE = -4.4f; + } + + public AllPersist2 (int intA, double doubleB, int intB, char charC, boolean booleanVal, float floatE) { + super(intA, doubleB, intB); + this.charC = charC; + booleanD = booleanVal; + this.floatE = floatE; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/AllPersist3.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/AllPersist3.java index 849098963..c5ec989bd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/AllPersist3.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/AllPersist3.java @@ -5,38 +5,32 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; /** */ public class AllPersist3 extends AllPersist2 { - public short shortF; // persistent - public AllPersist4 secondObj; // transactional - public AllPersist4 thirdObj; // persistent - - public AllPersist3() { - shortF = 1238; - } - - public AllPersist3( - int intA, - double doubleB, - int intB, - char charC, - boolean booleanD, - float floatE, - short shortVal) { - super(intA, doubleB, intB, charC, booleanD, floatE); - shortF = shortVal; - } + public short shortF; // persistent + public AllPersist4 secondObj; // transactional + public AllPersist4 thirdObj; // persistent + + public AllPersist3() { + shortF = 1238; + } + + public AllPersist3 (int intA, double doubleB, int intB, char charC, boolean booleanD, float floatE, short shortVal) { + super(intA, doubleB, intB, charC, booleanD, floatE); + shortF = shortVal; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/AllPersist4.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/AllPersist4.java index d612f036e..1ac715d4b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/AllPersist4.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/AllPersist4.java @@ -5,42 +5,36 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; /** */ public class AllPersist4 extends AllPersist3 { - public short shortG; // not managed - public AllPersist4 fourthObj; // not managed - public int intH; // persistent - - public AllPersist4() { - shortG = -360; - intH = -6; - } - - public AllPersist4( - int intA, - double doubleB, - int intB, - char charC, - boolean booleanD, - float floatE, - short shortF, - short shortG, - int intVal) { - super(intA, doubleB, intB, charC, booleanD, floatE, shortF); - this.shortG = shortG; - intH = intVal; - } + public short shortG; // not managed + public AllPersist4 fourthObj; // not managed + public int intH; // persistent + + public AllPersist4() { + shortG = -360; + intH = -6; + } + + public AllPersist4 (int intA, double doubleB, int intB, char charC, boolean booleanD, + float floatE, short shortF, short shortG, int intVal) { + super(intA, doubleB, intB, charC, booleanD, floatE, shortF); + this.shortG = shortG; + intH = intVal; + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/Constants.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/Constants.java index f6009267e..d4f5b96e6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/Constants.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/Constants.java @@ -5,41 +5,34 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; /** * @author Michael Bouschen - *

    Defines constants used by the inheritance pc classes and the inheritance tck test cases. + * + * Defines constants used by the inheritance pc classes and the inheritance tck + * test cases. */ -public class Constants { - // 0 1 2 3 4 5 6 - // 7 8 9 10 11 - public static final int[] intA_V = {-1, 350, 43, 336, -447, 1, 337, 10, 43, -447, 20, 30}; - public static final double[] doubleB_V = { - 2.0, 9.8, 94.5, -7.2, -13., 4.0, -8.2, -13, 94.5, -13, 23, 33 - }; - public static final int[] intB_V = {-5, 3334, -76, 28, 12497, 5, 38, 14, -76, 12497, 24, 34}; - public static final char[] charC_V = {'3', 'D', 'J', 'L', 'N', 'w', '1', 'x', 'J', 'P', 'y', 'z'}; - public static final boolean[] booleanD_V = { - false, true, true, true, true, false, true, true, true, true, true, false - }; - public static final float[] floatE_V = { - -4.4f, -32.7f, -21.5f, -3266f, -3.6f, 3.0f, -4266f, 12f, -21.5f, -3.6f, 22f, 32f - }; - public static final short[] shortF_V = {1238, 258, 394, 8, 21, 6, 9, 15, 394, 21, 25, 35}; - public static final short[] shortG_V = { - -360, -1000, -4321, -6, -44, 2, -7, 11, 4321, -44, 21, 31 - }; - public static final int[] intH_V = { - -6, -25, -347600, -603, -7613, 7, -703, 16, -347600, -7613, 26, 36 - }; +public class Constants +{ + // 0 1 2 3 4 5 6 7 8 9 10 11 + public static final int[] intA_V = { -1, 350, 43, 336, -447, 1, 337, 10, 43, -447, 20, 30}; + public static final double[] doubleB_V = { 2.0, 9.8, 94.5, -7.2, -13., 4.0, -8.2, -13, 94.5, -13, 23, 33}; + public static final int[] intB_V = { -5 , 3334, -76, 28, 12497, 5, 38, 14, -76, 12497, 24, 34}; + public static final char[] charC_V = { '3', 'D', 'J', 'L', 'N', 'w', '1', 'x', 'J', 'P', 'y', 'z'}; + public static final boolean[] booleanD_V ={false, true, true, true, true, false, true, true, true, true, true, false}; + public static final float[] floatE_V = {-4.4f, -32.7f, -21.5f, -3266f, -3.6f, 3.0f, -4266f, 12f, -21.5f, -3.6f, 22f, 32f}; + public static final short[] shortF_V = { 1238, 258, 394, 8, 21, 6, 9, 15, 394, 21, 25, 35}; + public static final short[] shortG_V = { -360, -1000, -4321, -6, -44, 2, -7, 11, 4321, -44, 21, 31}; + public static final int[] intH_V = { -6, -25, -347600, -603, -7613, 7, -703, 16, -347600, -7613, 26, 36}; + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/FieldSameName.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/FieldSameName.java index 8fe6c6ab7..a856bdcab 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/FieldSameName.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/FieldSameName.java @@ -5,15 +5,16 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; @@ -21,78 +22,77 @@ /** */ public class FieldSameName { - int n1; // not managed - double n2; // persistent - int n3; // persistent - - private int keyValue; // persistent--used as key field in application identity - private static int nextKeyValue = 1; - - public FieldSameName() { - n1 = -1; - n2 = 2.0; - n3 = -5; - } - - public FieldSameName(int intA, double doubleVal, int intB) { - keyValue = nextKeyValue++; - n1 = intA; - n2 = doubleVal; - n3 = intB; - } - - public void setIntA(int intA) { - n1 = intA; - } - - public int getIntA() { - return n1; - } - - public void setDoubleB(double doubleB) { - n2 = doubleB; - } - - public double getDoubleB() { - return n2; - } - - public void setIntB(int intB) { - n3 = intB; - } - - public int getIntB() { - return n3; - } - - public static class Id implements Serializable { - public int keyValue; - - public Id() {} - - public Id(int keyValue) { - this.keyValue = keyValue; + int n1; // not managed + double n2; // persistent + int n3; // persistent + + private int keyValue; // persistent--used as key field in application identity + private static int nextKeyValue = 1; + + public FieldSameName() { + n1 = -1; + n2 = 2.0; + n3 = -5; } - - public Id(String s) { - try { - keyValue = Integer.parseInt(s); - } catch (NumberFormatException e) { - keyValue = 0; - } + + public FieldSameName(int intA, double doubleVal, int intB) { + keyValue = nextKeyValue++; + n1 = intA; + n2 = doubleVal; + n3 = intB; } - - public boolean equals(Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return false; - else return keyValue == ((Id) obj).keyValue; + + public void setIntA(int intA) { + n1 = intA; } - - public int hashCode() { - return keyValue; + + public int getIntA() { + return n1; } - public String toString() { - return Integer.toString(keyValue); + public void setDoubleB(double doubleB) { + n2 = doubleB; + } + + public double getDoubleB() { + return n2; + } + + public void setIntB(int intB) { + n3 = intB; + } + + public int getIntB() { + return n3; + } + + public static class Id implements Serializable { + public int keyValue; + + public Id() { + } + + public Id(int keyValue) { + this.keyValue = keyValue; + } + + public Id(String s) { + try{ keyValue = Integer.parseInt(s);} + catch(NumberFormatException e){ + keyValue = 0;} + } + + public boolean equals(Object obj) { + if( obj == null || !this.getClass().equals(obj.getClass()) ) return false; + else return keyValue == ((Id)obj).keyValue; + } + + public int hashCode() { + return keyValue; + } + + public String toString() { + return Integer.toString(keyValue); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/FieldSameName2.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/FieldSameName2.java index 1360af57c..8c16a147c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/FieldSameName2.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/FieldSameName2.java @@ -5,59 +5,59 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; /** */ public class FieldSameName2 extends FieldSameName { - char n1; // not managed - boolean n2; // not managed - float n3; // transactional - - public FieldSameName2() { - n1 = '3'; - n2 = false; - n3 = -4.4f; - } - - public FieldSameName2( - int intA, double doubleB, int intB, char charC, boolean booleanVal, float floatE) { - super(intA, doubleB, intB); - n1 = charC; - n2 = booleanVal; - n3 = floatE; - } - - public void setCharC(char charC) { - n1 = charC; - } - - public char getCharC() { - return n1; - } - - public void setBooleanD(boolean booleanD) { - n2 = booleanD; - } - - public boolean getBooleanD() { - return n2; - } - - public void setFloatE(float floatE) { - n3 = floatE; - } - - public float getFloatE() { - return n3; - } + char n1; // not managed + boolean n2; // not managed + float n3; // transactional + + public FieldSameName2() { + n1 = '3'; + n2 = false; + n3 = -4.4f; + } + + public FieldSameName2 (int intA, double doubleB, int intB, char charC, boolean booleanVal, float floatE) { + super(intA, doubleB, intB); + n1 = charC; + n2 = booleanVal; + n3 = floatE; + } + + public void setCharC(char charC) { + n1 = charC; + } + + public char getCharC() { + return n1; + } + + public void setBooleanD(boolean booleanD) { + n2 = booleanD; + } + + public boolean getBooleanD() { + return n2; + } + + public void setFloatE(float floatE) { + n3 = floatE; + } + + public float getFloatE() { + return n3; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/FieldSameName3.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/FieldSameName3.java index d008d71e0..409ce6acc 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/FieldSameName3.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/FieldSameName3.java @@ -5,61 +5,55 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; /** */ public class FieldSameName3 extends FieldSameName2 { - short n1; // persistent - FieldSameName4 n2; // transactional - FieldSameName4 n3; // persistent - - public FieldSameName3() { - n1 = 1238; - } - - public FieldSameName3( - int intA, - double doubleB, - int intB, - char charC, - boolean booleanD, - float floatE, - short shortVal) { - super(intA, doubleB, intB, charC, booleanD, floatE); - n1 = shortVal; - } - - public void setShortF(short shortF) { - n1 = shortF; - } - - public short getShortF() { - return n1; - } - - public void setSecondObj(FieldSameName4 secondObj) { - n2 = secondObj; - } - - public FieldSameName4 getSecondObj() { - return n2; - } - - public void setThirdObj(FieldSameName4 thirdObj) { - n3 = thirdObj; - } - - public FieldSameName4 getThirdObj() { - return n3; - } + short n1; // persistent + FieldSameName4 n2; // transactional + FieldSameName4 n3; // persistent + + public FieldSameName3() { + n1 = 1238; + } + + public FieldSameName3 (int intA, double doubleB, int intB, char charC, boolean booleanD, float floatE, short shortVal) { + super(intA, doubleB, intB, charC, booleanD, floatE); + n1 = shortVal; + } + + public void setShortF(short shortF) { + n1 = shortF; + } + + public short getShortF() { + return n1; + } + + public void setSecondObj(FieldSameName4 secondObj) { + n2 = secondObj; + } + + public FieldSameName4 getSecondObj() { + return n2; + } + + public void setThirdObj(FieldSameName4 thirdObj) { + n3 = thirdObj; + } + + public FieldSameName4 getThirdObj() { + return n3; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/FieldSameName4.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/FieldSameName4.java index e820593b5..161bc7774 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/FieldSameName4.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/FieldSameName4.java @@ -5,65 +5,59 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; /** */ public class FieldSameName4 extends FieldSameName3 { - short n1; // not managed - FieldSameName4 n2; // not managed - int n3; // persistent - - public FieldSameName4() { - n1 = -360; - n3 = -6; - } - - public FieldSameName4( - int intA, - double doubleB, - int intB, - char charC, - boolean booleanD, - float floatE, - short shortF, - short shortG, - int intVal) { - super(intA, doubleB, intB, charC, booleanD, floatE, shortF); - n1 = shortG; - n3 = intVal; - } - - public void setShortG(short shortG) { - n1 = shortG; - } - - public short getShortG() { - return n1; - } - - public void setFourthObj(FieldSameName4 fourthObj) { - n2 = fourthObj; - } - - public FieldSameName4 getFourthObj() { - return n2; - } - - public void setIntH(int intH) { - n3 = intH; - } - - public int getIntH() { - return n3; - } + short n1; // not managed + FieldSameName4 n2; // not managed + int n3; // persistent + + public FieldSameName4() { + n1 = -360; + n3 = -6; + } + + public FieldSameName4 (int intA, double doubleB, int intB, char charC, boolean booleanD, + float floatE, short shortF, short shortG, int intVal) { + super(intA, doubleB, intB, charC, booleanD, floatE, shortF); + n1 = shortG; + n3 = intVal; + } + + public void setShortG(short shortG) { + n1 = shortG; + } + + public short getShortG() { + return n1; + } + + public void setFourthObj(FieldSameName4 fourthObj) { + n2 = fourthObj; + } + + public FieldSameName4 getFourthObj() { + return n2; + } + + public void setIntH(int intH) { + n3 = intH; + } + + public int getIntH() { + return n3; + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersist.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersist.java index 025366140..d67dd72bd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersist.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersist.java @@ -5,28 +5,30 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; /** */ -public class TopNonPersist { // not persistent +public class TopNonPersist { // not persistent + + public int intA; - public int intA; + public TopNonPersist() { + intA = -1; + } + + public TopNonPersist(int intA) { + this.intA = intA; + } - public TopNonPersist() { - intA = -1; - } - - public TopNonPersist(int intA) { - this.intA = intA; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistB.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistB.java index f64d62bcf..141721cb6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistB.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistB.java @@ -5,69 +5,69 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; import java.io.Serializable; /** */ -public class TopNonPersistB extends TopNonPersist { // persistent - - public double doubleB; // persistent - public int intB; // persistent - - private int keyValue; // persistent--used as key field in application identity - private static int nextKeyValue = 1; - - public TopNonPersistB() { - doubleB = 2.0; - intB = -5; - } - - public TopNonPersistB(int intA, double doubleVal, int intB) { - super(intA); - keyValue = nextKeyValue++; - doubleB = doubleVal; - this.intB = intB; - } - - public static class Id implements Serializable { - public int keyValue; - - public Id() {} - - public Id(int keyValue) { - this.keyValue = keyValue; - } - - public Id(String s) { - try { - keyValue = Integer.parseInt(s); - } catch (NumberFormatException e) { - keyValue = 0; - } +public class TopNonPersistB extends TopNonPersist { // persistent + + public double doubleB; // persistent + public int intB; // persistent + + private int keyValue; // persistent--used as key field in application identity + static private int nextKeyValue = 1; + + public TopNonPersistB() { + doubleB = 2.0; + intB = -5; } - - public boolean equals(Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return false; - else return keyValue == ((Id) obj).keyValue; - } - - public int hashCode() { - return keyValue; + + public TopNonPersistB (int intA, double doubleVal, int intB) { + super(intA); + keyValue = nextKeyValue++; + doubleB = doubleVal; + this.intB = intB; } + + public static class Id implements Serializable { + public int keyValue; - public String toString() { - return Integer.toString(keyValue); + public Id() { + } + + public Id(int keyValue) { + this.keyValue = keyValue; + } + + public Id(String s) { + try{ keyValue = Integer.parseInt(s);} + catch(NumberFormatException e){ + keyValue = 0;} + } + + public boolean equals(Object obj) { + if( obj == null || !this.getClass().equals(obj.getClass()) ) return false; + else return keyValue == ((Id)obj).keyValue; + } + + public int hashCode() { + return keyValue; + } + + public String toString() { + return Integer.toString(keyValue); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistC.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistC.java index 3d0882d6e..1e6e2ec09 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistC.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistC.java @@ -5,29 +5,30 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; /** */ public class TopNonPersistC extends TopNonPersistB { // not persistent - - public char charC; - - public TopNonPersistC() { - charC = '3'; - } - - public TopNonPersistC(int intA, double doubleB, int intB, char charC) { - super(intA, doubleB, intB); - this.charC = charC; - } + + public char charC; + + public TopNonPersistC() { + charC = '3'; + } + + public TopNonPersistC (int intA, double doubleB, int intB, char charC) { + super(intA, doubleB, intB); + this.charC = charC; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistD.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistD.java index 344b3f302..ad2f6618e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistD.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistD.java @@ -5,29 +5,30 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; /** */ public class TopNonPersistD extends TopNonPersistC { // not persistent - - public boolean booleanD; - - public TopNonPersistD() { - booleanD = false; - } - - public TopNonPersistD(int int1, double doubleB, int intB, char charC, boolean booleanVal) { - super(int1, doubleB, intB, charC); - booleanD = booleanVal; - } + + public boolean booleanD; + + public TopNonPersistD() { + booleanD = false; + } + + public TopNonPersistD (int int1, double doubleB, int intB, char charC, boolean booleanVal) { + super(int1, doubleB, intB,charC); + booleanD = booleanVal; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistE.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistE.java index fe6dba583..c703ab7f3 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistE.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistE.java @@ -5,30 +5,30 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; /** */ -public class TopNonPersistE extends TopNonPersistD { // persistent - - public float floatE; // transactional - - public TopNonPersistE() { - floatE = -4.4f; - } - - public TopNonPersistE( - int intA, double doubleB, int intB, char charC, boolean booleanD, float floatE) { - super(intA, doubleB, intB, charC, booleanD); - this.floatE = floatE; - } +public class TopNonPersistE extends TopNonPersistD { // persistent + + public float floatE; // transactional + + public TopNonPersistE () { + floatE = -4.4f; + } + + public TopNonPersistE (int intA, double doubleB, int intB, char charC, boolean booleanD, float floatE) { + super(intA, doubleB, intB, charC, booleanD); + this.floatE = floatE; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistF.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistF.java index eadf4e22b..35d85a3e1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistF.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistF.java @@ -5,38 +5,32 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; /** */ -public class TopNonPersistF extends TopNonPersistE { // persistent +public class TopNonPersistF extends TopNonPersistE { // persistent - public short shortF; // persistent - public TopNonPersistH secondObj; // transactional - public TopNonPersistH thirdObj; // persistent - - public TopNonPersistF() { - shortF = 1238; - } - - public TopNonPersistF( - int intA, - double doubleB, - int intB, - char charC, - boolean booleanD, - float floatE, - short shortVal) { - super(intA, doubleB, intB, charC, booleanD, floatE); - shortF = shortVal; - } + public short shortF; // persistent + public TopNonPersistH secondObj; // transactional + public TopNonPersistH thirdObj; // persistent + + public TopNonPersistF() { + shortF = 1238; + } + + public TopNonPersistF (int intA, double doubleB, int intB, char charC, boolean booleanD, float floatE, short shortVal) { + super(intA, doubleB, intB, charC, booleanD, floatE); + shortF = shortVal; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistG.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistG.java index 45a409a6c..0d9699a86 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistG.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistG.java @@ -5,38 +5,32 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; /** */ public class TopNonPersistG extends TopNonPersistF { // not persistent - - public short shortG; - public TopNonPersistH fourthObj; - - public TopNonPersistG() { - shortG = -360; - } - - public TopNonPersistG( - int intA, - double doubleB, - int intB, - char charC, - boolean booleanD, - float floatE, - short shortF, - short shortG) { - super(intA, doubleB, intB, charC, booleanD, floatE, shortF); - this.shortG = shortG; - } + + public short shortG; + public TopNonPersistH fourthObj; + + public TopNonPersistG() { + shortG = -360; + } + + public TopNonPersistG (int intA, double doubleB, int intB, char charC, boolean booleanD, + float floatE, short shortF, short shortG) { + super(intA, doubleB, intB, charC, booleanD, floatE, shortF); + this.shortG = shortG; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistH.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistH.java index 1dd5e6156..cccbcb5ff 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistH.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopNonPersistH.java @@ -5,38 +5,32 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; /** */ public class TopNonPersistH extends TopNonPersistG { // persistent - - public int intH; // persistent - - public TopNonPersistH() { - intH = -6; - } - - public TopNonPersistH( - int intA, - double doubleB, - int intB, - char charC, - boolean booleanD, - float floatE, - short shortF, - short shortG, - int intVal) { - super(intA, doubleB, intB, charC, booleanD, floatE, shortF, shortG); - intH = intVal; - } + + public int intH; // persistent + + public TopNonPersistH() { + intH = -6; + } + + public TopNonPersistH (int intA, double doubleB, int intB, char charC, boolean booleanD, + float floatE, short shortF, short shortG, int intVal) { + super(intA, doubleB, intB, charC, booleanD, floatE, shortF, shortG); + intH = intVal; + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersist.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersist.java index bcd6a5d43..dd0445a02 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersist.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersist.java @@ -5,71 +5,71 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; import java.io.Serializable; /** */ -public class TopPersist { // persistent +public class TopPersist { // persistent - public int intA; // not managed - public double doubleB; // persistent - public int intB; // persistent - - private int keyValue; // persistent--used as key field in application identity - private static int nextKeyValue = 1; - - public TopPersist() { - intA = Constants.intA_V[0]; - doubleB = Constants.doubleB_V[0]; - intB = Constants.intB_V[0]; - } - - public TopPersist(int intA, double doubleVal, int intB) { - keyValue = nextKeyValue++; - this.intA = intA; - doubleB = doubleVal; - this.intB = intB; - } - - public static class Id implements Serializable { - public int keyValue; - - public Id() {} - - public Id(int keyValue) { - this.keyValue = keyValue; + public int intA; // not managed + public double doubleB; // persistent + public int intB; // persistent + + private int keyValue; // persistent--used as key field in application identity + static private int nextKeyValue = 1; + + public TopPersist() { + intA = Constants.intA_V[0]; + doubleB = Constants.doubleB_V[0]; + intB = Constants.intB_V[0]; } - - public Id(String s) { - try { - keyValue = Integer.parseInt(s); - } catch (NumberFormatException e) { - keyValue = 0; - } - } - - public boolean equals(Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return false; - else return keyValue == ((Id) obj).keyValue; - } - - public int hashCode() { - return keyValue; + + public TopPersist (int intA, double doubleVal, int intB) { + keyValue = nextKeyValue++; + this.intA = intA; + doubleB = doubleVal; + this.intB = intB; } + + public static class Id implements Serializable { + public int keyValue; - public String toString() { - return Integer.toString(keyValue); + public Id() { + } + + public Id(int keyValue) { + this.keyValue = keyValue; + } + + public Id(String s) { + try{ keyValue = Integer.parseInt(s);} + catch(NumberFormatException e){ + keyValue = 0;} + } + + public boolean equals(Object obj) { + if( obj == null || !this.getClass().equals(obj.getClass()) ) return false; + else return keyValue == ((Id)obj).keyValue; + } + + public int hashCode() { + return keyValue; + } + + public String toString() { + return Integer.toString(keyValue); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistC.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistC.java index c3dcb1657..69d077687 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistC.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistC.java @@ -5,29 +5,30 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; /** */ public class TopPersistC extends TopPersist { // not persistent - public char charC; - - public TopPersistC() { - charC = Constants.charC_V[0]; - } - - public TopPersistC(int intA, double doubleB, int intB, char charC) { - super(intA, doubleB, intB); - this.charC = charC; - } + public char charC; + + public TopPersistC() { + charC = Constants.charC_V[0]; + } + + public TopPersistC (int intA, double doubleB, int intB, char charC) { + super(intA, doubleB, intB); + this.charC = charC; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistD.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistD.java index 966e6cda4..b8f6f1970 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistD.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistD.java @@ -5,29 +5,30 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; /** */ public class TopPersistD extends TopPersistC { // not persistent - public boolean booleanD; - - public TopPersistD() { - booleanD = Constants.booleanD_V[0]; - } - - public TopPersistD(int int1, double doubleB, int intB, char charC, boolean booleanVal) { - super(int1, doubleB, intB, charC); - booleanD = booleanVal; - } + public boolean booleanD; + + public TopPersistD() { + booleanD = Constants.booleanD_V[0]; + } + + public TopPersistD (int int1, double doubleB, int intB, char charC, boolean booleanVal) { + super(int1, doubleB, intB,charC); + booleanD = booleanVal; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistE.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistE.java index 746c2f380..5ecb6a199 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistE.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistE.java @@ -5,30 +5,30 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; /** */ -public class TopPersistE extends TopPersistD { // persistent +public class TopPersistE extends TopPersistD { // persistent - public float floatE; // transactional - - public TopPersistE() { - floatE = Constants.floatE_V[0]; - } - - public TopPersistE( - int intA, double doubleB, int intB, char charC, boolean booleanD, float floatE) { - super(intA, doubleB, intB, charC, booleanD); - this.floatE = floatE; - } + public float floatE; // transactional + + public TopPersistE () { + floatE = Constants.floatE_V[0]; + } + + public TopPersistE (int intA, double doubleB, int intB, char charC, boolean booleanD, float floatE) { + super(intA, doubleB, intB, charC, booleanD); + this.floatE = floatE; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistF.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistF.java index 6aa49a8f4..bbae07ee0 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistF.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistF.java @@ -5,38 +5,32 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; /** */ -public class TopPersistF extends TopPersistE { // persistent +public class TopPersistF extends TopPersistE { // persistent - public short shortF; // persistent - public TopPersistH secondObj; // transactional - public TopPersistH thirdObj; // persistent - - public TopPersistF() { - shortF = Constants.shortF_V[0]; - } - - public TopPersistF( - int intA, - double doubleB, - int intB, - char charC, - boolean booleanD, - float floatE, - short shortVal) { - super(intA, doubleB, intB, charC, booleanD, floatE); - shortF = shortVal; - } + public short shortF; // persistent + public TopPersistH secondObj; // transactional + public TopPersistH thirdObj; // persistent + + public TopPersistF() { + shortF = Constants.shortF_V[0]; + } + + public TopPersistF (int intA, double doubleB, int intB, char charC, boolean booleanD, float floatE, short shortVal) { + super(intA, doubleB, intB, charC, booleanD, floatE); + shortF = shortVal; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistG.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistG.java index 9b5d72dd4..179a288ed 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistG.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistG.java @@ -5,38 +5,32 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; /** */ public class TopPersistG extends TopPersistF { // not persistent - public short shortG; - public TopPersistH fourthObj; - - public TopPersistG() { - shortG = Constants.shortG_V[0]; - } - - public TopPersistG( - int intA, - double doubleB, - int intB, - char charC, - boolean booleanD, - float floatE, - short shortF, - short shortG) { - super(intA, doubleB, intB, charC, booleanD, floatE, shortF); - this.shortG = shortG; - } + public short shortG; + public TopPersistH fourthObj; + + public TopPersistG() { + shortG = Constants.shortG_V[0]; + } + + public TopPersistG (int intA, double doubleB, int intB, char charC, boolean booleanD, + float floatE, short shortF, short shortG) { + super(intA, doubleB, intB, charC, booleanD, floatE, shortF); + this.shortG = shortG; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistH.java b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistH.java index 41aba4349..f348880dc 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistH.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/inheritance/TopPersistH.java @@ -5,38 +5,31 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.inheritance; /** */ public class TopPersistH extends TopPersistG { // persistent - public int intH; // persistent - - public TopPersistH() { - intH = Constants.intH_V[0]; - } - - public TopPersistH( - int intA, - double doubleB, - int intB, - char charC, - boolean booleanD, - float floatE, - short shortF, - short shortG, - int intVal) { - super(intA, doubleB, intB, charC, booleanD, floatE, shortF, shortG); - intH = intVal; - } + public int intH; // persistent + + public TopPersistH() { + intH = Constants.intH_V[0]; + } + + public TopPersistH (int intA, double doubleB, int intB, char charC, boolean booleanD, + float floatE, short shortF, short shortG, int intVal) { + super(intA, doubleB, intB, charC, booleanD, floatE, shortF, shortG); + intH = intVal; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/instancecallbacks/InstanceCallbackClass.java b/tck/src/main/java/org/apache/jdo/tck/pc/instancecallbacks/InstanceCallbackClass.java index 748cc816c..9f264104c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/instancecallbacks/InstanceCallbackClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/instancecallbacks/InstanceCallbackClass.java @@ -5,15 +5,16 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.instancecallbacks; @@ -21,227 +22,218 @@ import java.util.Date; import java.util.HashSet; import java.util.Iterator; + import javax.jdo.Extent; import javax.jdo.InstanceCallbacks; import javax.jdo.JDOHelper; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; public class InstanceCallbackClass implements InstanceCallbacks { - public static boolean performPreClearTests; - public static boolean performPreDeleteTests; - public static boolean performPreStoreTests; - - // The following two variables used in CallingJdoPreDelete tests - public static boolean preDeleteCalled; - public static int objectState; - - // The rest of these variables used in FieldsInPredelete tests, except to set a variable to make - // object dirty. - public static int arraySize = 5; - public static String[] capturedName = new String[arraySize]; - public static Date[] capturedTimeStamp = new Date[arraySize]; - public static double[] capturedDoubleValue = new double[arraySize]; - public static short[] capturedChildToDelete = new short[arraySize]; - public static char[] capturedCharValue = new char[arraySize]; - public static String[] capturedNextObjName = new String[arraySize]; - public static int[] numberOfChildren = new int[arraySize]; - public static int[] sumOfChildrenIntValue = new int[arraySize]; - public static boolean[] processedIndex = new boolean[arraySize]; - - public static boolean[] transactionActive = new boolean[arraySize]; - - private static int nextKeyValue = 1; - private int keyValue; // persistent--used as key field in application identity - public String name; - public Date timeStamp; - public InstanceCallbackClass nextObj; - public HashSet children; - public int intValue; - public double doubleValue; - public short childToDelete; - public char charValue; - - public static void initializeStaticsForTest() { - performPreClearTests = false; - performPreDeleteTests = false; - performPreStoreTests = false; - preDeleteCalled = false; - for (int i = 0; i < arraySize; ++i) { - processedIndex[i] = false; - transactionActive[i] = false; - } - } - - public static void removeAllInstances(PersistenceManager pm) { - Extent e = pm.getExtent(InstanceCallbackClass.class, true); - Iterator i = e.iterator(); - while (i.hasNext()) { - pm.deletePersistent(i.next()); + public static boolean performPreClearTests; + public static boolean performPreDeleteTests; + public static boolean performPreStoreTests; + + // The following two variables used in CallingJdoPreDelete tests + public static boolean preDeleteCalled; + public static int objectState; + + // The rest of these variables used in FieldsInPredelete tests, except to set a variable to make object dirty. + public static int arraySize = 5; + public static String[] capturedName = new String[arraySize]; + public static Date[] capturedTimeStamp = new Date[arraySize]; + public static double[] capturedDoubleValue = new double[arraySize]; + public static short[] capturedChildToDelete = new short[arraySize]; + public static char[] capturedCharValue = new char[arraySize]; + public static String[] capturedNextObjName = new String[arraySize]; + public static int[] numberOfChildren = new int[arraySize]; + public static int[] sumOfChildrenIntValue = new int[arraySize]; + public static boolean[] processedIndex = new boolean[arraySize]; + + public static boolean[] transactionActive = new boolean[arraySize]; + + private static int nextKeyValue = 1; + private int keyValue; // persistent--used as key field in application identity + public String name; + public Date timeStamp; + public InstanceCallbackClass nextObj; + public HashSet children; + public int intValue; + public double doubleValue; + public short childToDelete; + public char charValue; + + public static void initializeStaticsForTest() + { + performPreClearTests = false; + performPreDeleteTests = false; + performPreStoreTests = false; + preDeleteCalled = false; + for( int i = 0; i < arraySize; ++i){ + processedIndex[i] = false; + transactionActive[i] = false; + } } - } - - public InstanceCallbackClass() { // not used by application - } - - public InstanceCallbackClass( - String label, - Date createTime, - int intValue, - double doubleValue, - short childToDelete, - char charValue, - InstanceCallbackClass obj) { - keyValue = nextKeyValue++; - name = label; - timeStamp = createTime; - nextObj = obj; - children = new HashSet(); - this.intValue = intValue; - this.doubleValue = doubleValue; - this.childToDelete = childToDelete; - this.charValue = charValue; - } - public void addChild(InstanceCallbackClass child) { - children.add(child); - } - - public void jdoPreStore() { - if (!performPreStoreTests) { - return; - } - captureValues(); - PersistenceManager pm = JDOHelper.getPersistenceManager(this); - usePM(pm); - } - - public void jdoPreDelete() { - if (!performPreDeleteTests) { - return; + public static void removeAllInstances(PersistenceManager pm) + { + Extent e = pm.getExtent(InstanceCallbackClass.class, true); + Iterator i = e.iterator(); + while( i.hasNext() ){ + pm.deletePersistent(i.next()); + } } - // The following two variables set for CallingJdoPreDelete tests - preDeleteCalled = true; - objectState = JDO_Test.currentState(this); - - captureValues(); - - // The rest of this routine used for Accessing FieldsInPredelete tests - // check that intValue is a valid index - if (intValue >= 0 & intValue < arraySize) { - PersistenceManager pm = JDOHelper.getPersistenceManager(this); - usePM(pm); - if (nextObj != null) { - pm.deletePersistent(nextObj); // delete referenced object - - // delete designated child - for (Iterator i = children.iterator(); i.hasNext(); ) { - InstanceCallbackClass obj = (InstanceCallbackClass) i.next(); - if (obj.intValue == childToDelete) { - pm.deletePersistent(obj); - break; - } + + public InstanceCallbackClass() { // not used by application + } + + public InstanceCallbackClass(String label,Date createTime,int intValue,double doubleValue,short childToDelete,char charValue,InstanceCallbackClass obj) { + keyValue = nextKeyValue++; + name = label; + timeStamp = createTime; + nextObj = obj; + children = new HashSet(); + this.intValue = intValue; + this.doubleValue = doubleValue; + this.childToDelete = childToDelete; + this.charValue = charValue; + } + + public void addChild(InstanceCallbackClass child) { + children.add(child); + } + + public void jdoPreStore() { + if(!performPreStoreTests) { return; } + captureValues(); + PersistenceManager pm = JDOHelper.getPersistenceManager(this); + usePM(pm); + } + + public void jdoPreDelete() { + if(!performPreDeleteTests) { return; } + // The following two variables set for CallingJdoPreDelete tests + preDeleteCalled = true; + objectState = JDO_Test.currentState(this); + + captureValues(); + + // The rest of this routine used for Accessing FieldsInPredelete tests + // check that intValue is a valid index + if(intValue >= 0 & intValue < arraySize) { + PersistenceManager pm = JDOHelper.getPersistenceManager(this); + usePM(pm); + if(nextObj != null) { + pm.deletePersistent(nextObj); // delete referenced object + + // delete designated child + for(Iterator i = children.iterator(); i.hasNext();) { + InstanceCallbackClass obj = (InstanceCallbackClass)i.next(); + if( obj.intValue == childToDelete) { + pm.deletePersistent(obj); + break; + } + } + } } - } } - } - - public void jdoPostLoad() {} - - public void jdoPreClear() { - if (!performPreClearTests) { - return; - } - // the following code is copied from captureValues, because it must - // not be enhanced for execution during jdoPreClear. - // check that intValue is a valid index - if (intValue >= 0 & intValue < arraySize) { - processedIndex[intValue] = true; - - // capture values of the attributes - capturedName[intValue] = name; - capturedTimeStamp[intValue] = timeStamp; - capturedDoubleValue[intValue] = doubleValue; - numberOfChildren[intValue] = children.size(); - sumOfChildrenIntValue[intValue] = 0; - for (Iterator i = children.iterator(); i.hasNext(); ) { - InstanceCallbackClass o = (InstanceCallbackClass) i.next(); - sumOfChildrenIntValue[intValue] += o.intValue; - } - capturedChildToDelete[intValue] = childToDelete; - capturedCharValue[intValue] = charValue; - if (nextObj != null) { - capturedNextObjName[intValue] = nextObj.name; - } else { - capturedNextObjName[intValue] = null; - } - } - } - - void captureValues() { - // check that intValue is a valid index - if (intValue >= 0 & intValue < arraySize) { - processedIndex[intValue] = true; - - // capture values of the attributes - capturedName[intValue] = name; - capturedTimeStamp[intValue] = timeStamp; - capturedDoubleValue[intValue] = doubleValue; - numberOfChildren[intValue] = children.size(); - sumOfChildrenIntValue[intValue] = 0; - for (Iterator i = children.iterator(); i.hasNext(); ) { - InstanceCallbackClass o = (InstanceCallbackClass) i.next(); - sumOfChildrenIntValue[intValue] += o.intValue; - } - capturedChildToDelete[intValue] = childToDelete; - capturedCharValue[intValue] = charValue; - if (nextObj != null) { - capturedNextObjName[intValue] = nextObj.name; - } else { - capturedNextObjName[intValue] = null; - } - } - } - - void usePM(PersistenceManager pm) { - if (intValue >= 0 & intValue < arraySize) { - Transaction t = pm.currentTransaction(); - if (t.isActive()) { - transactionActive[intValue] = true; - } - } - } - - public static class KeyClass implements Serializable, Comparable { + + public void jdoPostLoad() { + } + + public void jdoPreClear() { + if(!performPreClearTests) { return; } + // the following code is copied from captureValues, because it must + // not be enhanced for execution during jdoPreClear. + // check that intValue is a valid index + if(intValue >= 0 & intValue < arraySize) { + processedIndex[intValue] = true; + + // capture values of the attributes + capturedName[intValue] = name; + capturedTimeStamp[intValue] = timeStamp; + capturedDoubleValue[intValue] = doubleValue; + numberOfChildren[intValue] = children.size(); + sumOfChildrenIntValue[intValue] = 0; + for(Iterator i = children.iterator(); i.hasNext();) { + InstanceCallbackClass o = (InstanceCallbackClass)i.next(); + sumOfChildrenIntValue[intValue] += o.intValue; + } + capturedChildToDelete[intValue] = childToDelete; + capturedCharValue[intValue] = charValue; + if(nextObj != null) { + capturedNextObjName[intValue] = nextObj.name; + } else { + capturedNextObjName[intValue] = null; + } + } + } + + void captureValues() { + // check that intValue is a valid index + if(intValue >= 0 & intValue < arraySize) { + processedIndex[intValue] = true; + + // capture values of the attributes + capturedName[intValue] = name; + capturedTimeStamp[intValue] = timeStamp; + capturedDoubleValue[intValue] = doubleValue; + numberOfChildren[intValue] = children.size(); + sumOfChildrenIntValue[intValue] = 0; + for(Iterator i = children.iterator(); i.hasNext();) { + InstanceCallbackClass o = (InstanceCallbackClass)i.next(); + sumOfChildrenIntValue[intValue] += o.intValue; + } + capturedChildToDelete[intValue] = childToDelete; + capturedCharValue[intValue] = charValue; + if(nextObj != null) { + capturedNextObjName[intValue] = nextObj.name; + } else { + capturedNextObjName[intValue] = null; + } + } + } + + void usePM(PersistenceManager pm) { + if(intValue >= 0 & intValue < arraySize) { + Transaction t = pm.currentTransaction(); + if(t.isActive()) { + transactionActive[intValue] = true; + } + } + } + +public static class KeyClass implements Serializable, Comparable { public int keyValue; - public KeyClass() {} + public KeyClass() { + } public KeyClass(String s) { - try { - keyValue = Integer.parseInt(s); - } catch (NumberFormatException e) { - keyValue = 0; - } + try{ keyValue = Integer.parseInt(s);} + catch(NumberFormatException e){ + keyValue = 0;} } - + public boolean equals(Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return false; - else return keyValue == ((KeyClass) obj).keyValue; + if( obj == null || !this.getClass().equals(obj.getClass()) ) return false; + else return keyValue == ((KeyClass)obj).keyValue; } - + public int hashCode() { - return keyValue; + return keyValue; } - + public String toString() { - return Integer.toString(keyValue); - } - + return Integer.toString(keyValue); + } + public int compareTo(Object obj) { - // may throw ClassCastException to be handled by user. - return keyValue - ((KeyClass) obj).keyValue; + // may throw ClassCastException to be handled by user. + return keyValue - ((KeyClass)obj).keyValue; } - } + +} } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/instancecallbacks/InstanceCallbackNonPersistFdsClass.java b/tck/src/main/java/org/apache/jdo/tck/pc/instancecallbacks/InstanceCallbackNonPersistFdsClass.java index 9a6a9ae88..12c9bc0f7 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/instancecallbacks/InstanceCallbackNonPersistFdsClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/instancecallbacks/InstanceCallbackNonPersistFdsClass.java @@ -5,307 +5,304 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.instancecallbacks; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.Iterator; -import javax.jdo.Extent; -import javax.jdo.InstanceCallbacks; -import javax.jdo.PersistenceManager; +import java.io.*; +import java.util.*; +import javax.jdo.*; public class InstanceCallbackNonPersistFdsClass implements InstanceCallbacks { - public int i; // non-managed - public char c; // non-managed - public double d; // transactional - public short s; // transactional - public HashSet children; // non-managed - public Date loadTime; // non-managed + public int i; // non-managed + public char c; // non-managed + public double d; // transactional + public short s; // transactional + public HashSet children; // non-managed + public Date loadTime; // non-managed + + private int keyValue; // persistent--used as key field in application identity + public float floatValue; // persistent + public int intValue; // persistent --primary key field + + private static int nextKeyValue = 1; + + public static int savedIntValue; + public static float savedFloatValue; + + public static Date savedLoadTime; + public static String member1 = "one"; + public static String member2 = "two"; + public static String member3 = "three"; + + public static boolean preClearCalled = false; + public static boolean preStoreCalled = false; + public static boolean preDeleteCalled = false; + public static boolean postloadCalled = false; + public static boolean postloadCalledMultipleTimes = false; + + // used in CallingJdoPostload test + public static int beforeGetObjectById = 1; + public static int afterGetObjectById = 2; + public static int savedApplicationStep; + public static int applicationStep; // values are 0, beforeGetObjectById and afterGetObjectById + + // used in ModificationOfNontransactionalNonpersistentFields test + public static ArrayList exceptions = new ArrayList(); + public static ArrayList callbackCalled = new ArrayList(); + public static ArrayList attributeOpCausingExceptions = new ArrayList(); - private int keyValue; // persistent--used as key field in application identity - public float floatValue; // persistent - public int intValue; // persistent --primary key field + public static void initializeStaticsForTest() + { + savedIntValue = 0; + savedFloatValue = 0.0f; + savedLoadTime = null; + preClearCalled = false; + preStoreCalled = false; + preDeleteCalled = false; + postloadCalled = false; + postloadCalledMultipleTimes = false; + savedApplicationStep = 0; + applicationStep = 0; + + exceptions = new ArrayList(); + callbackCalled = new ArrayList(); + attributeOpCausingExceptions = new ArrayList(); + } - private static int nextKeyValue = 1; - - public static int savedIntValue; - public static float savedFloatValue; - - public static Date savedLoadTime; - public static String member1 = "one"; - public static String member2 = "two"; - public static String member3 = "three"; - - public static boolean preClearCalled = false; - public static boolean preStoreCalled = false; - public static boolean preDeleteCalled = false; - public static boolean postloadCalled = false; - public static boolean postloadCalledMultipleTimes = false; - - // used in CallingJdoPostload test - public static int beforeGetObjectById = 1; - public static int afterGetObjectById = 2; - public static int savedApplicationStep; - public static int applicationStep; // values are 0, beforeGetObjectById and afterGetObjectById - - // used in ModificationOfNontransactionalNonpersistentFields test - public static ArrayList exceptions = new ArrayList(); - public static ArrayList callbackCalled = new ArrayList(); - public static ArrayList attributeOpCausingExceptions = new ArrayList(); - - public static void initializeStaticsForTest() { - savedIntValue = 0; - savedFloatValue = 0.0f; - savedLoadTime = null; - preClearCalled = false; - preStoreCalled = false; - preDeleteCalled = false; - postloadCalled = false; - postloadCalledMultipleTimes = false; - savedApplicationStep = 0; - applicationStep = 0; - - exceptions = new ArrayList(); - callbackCalled = new ArrayList(); - attributeOpCausingExceptions = new ArrayList(); - } - - public static void removeAllInstances(PersistenceManager pm) { - Extent e = - pm.getExtent( - org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackNonPersistFdsClass.class, true); - Iterator i = e.iterator(); - while (i.hasNext()) { - pm.deletePersistent(i.next()); - } - } - - public InstanceCallbackNonPersistFdsClass() {} - - public InstanceCallbackNonPersistFdsClass(float floatValue, int intValue) { - keyValue = nextKeyValue++; - this.floatValue = floatValue; - this.intValue = intValue; - } - - public void setNonPersist(int i, char c, double d, short s) { - this.i = i; - this.c = c; - this.d = d; - this.s = s; - } - - public void setNonManaged(int i, char c) { - this.i = i; - this.c = c; - } - - public int calcIntValue() { - return i * c; - } - - public float calcFloatValue() { - return (float) (d * s); - } - - public void incrementIntValue() { - intValue++; - } - - public void jdoPreStore() { - preStoreCalled = true; - intValue = calcIntValue(); - floatValue = calcFloatValue(); - - try { - i = -30; - } catch (Exception e) { - callbackCalled.add("jdoPreStore "); - exceptions.add(e); - attributeOpCausingExceptions.add("i = -30;"); - } - try { - c = '\u0000'; - } catch (Exception e) { - callbackCalled.add("jdoPreStore "); - exceptions.add(e); - attributeOpCausingExceptions.add("c = '\u0000';"); - } - try { - d = 362.5; - } catch (Exception e) { - callbackCalled.add("jdoPreStore "); - exceptions.add(e); - attributeOpCausingExceptions.add("d = 362.5;"); + public static void removeAllInstances(PersistenceManager pm) + { + Extent e = pm.getExtent(org.apache.jdo.tck.pc.instancecallbacks.InstanceCallbackNonPersistFdsClass.class, true); + Iterator i = e.iterator(); + while( i.hasNext() ){ + pm.deletePersistent(i.next()); + } } - try { - s = 0; - } catch (Exception e) { - callbackCalled.add("jdoPreStore "); - exceptions.add(e); - attributeOpCausingExceptions.add("s = 0;"); - } - try { - loadTime = null; - } catch (Exception e) { - callbackCalled.add("jdoPreStore "); - exceptions.add(e); - attributeOpCausingExceptions.add("loadTime = null;"); - } - try { - children = null; - } catch (Exception e) { - callbackCalled.add("jdoPreStore "); - exceptions.add(e); - attributeOpCausingExceptions.add("children = null;"); - } - } - public void jdoPreDelete() { - preDeleteCalled = true; - try { - i = 0; - } catch (Exception e) { - callbackCalled.add("jdoPreDelete "); - exceptions.add(e); - attributeOpCausingExceptions.add("i = 0;"); - } - try { - c = 'x'; - } catch (Exception e) { - callbackCalled.add("jdoPreDelete "); - exceptions.add(e); - attributeOpCausingExceptions.add("c = 'x';"); + public InstanceCallbackNonPersistFdsClass() + { } - try { - d = 0.0; - } catch (Exception e) { - callbackCalled.add("jdoPreDelete "); - exceptions.add(e); - attributeOpCausingExceptions.add("d = 0.0;"); + + public InstanceCallbackNonPersistFdsClass(float floatValue,int intValue) { + keyValue = nextKeyValue++; + this.floatValue = floatValue; + this.intValue = intValue; } - try { - s = -5; - } catch (Exception e) { - callbackCalled.add("jdoPreDelete "); - exceptions.add(e); - attributeOpCausingExceptions.add("s = -5;"); + + public void setNonPersist(int i, char c, double d, short s) { + this.i = i; + this.c = c; + this.d = d; + this.s = s; } - try { - loadTime = null; - } catch (Exception e) { - callbackCalled.add("jdoPreDelete "); - exceptions.add(e); - attributeOpCausingExceptions.add("loadTime = null;"); + + public void setNonManaged(int i, char c) { + this.i = i; + this.c = c; } - try { - children = null; - } catch (Exception e) { - callbackCalled.add("jdoPreDelete "); - exceptions.add(e); - attributeOpCausingExceptions.add("children = null;"); + + public int calcIntValue() { + return i * c; } - } - - public void jdoPostLoad() { - postloadCalled = true; - savedApplicationStep = applicationStep; - i = -10; - c = '2'; - d = 30.0; - s = 40; - savedIntValue = intValue; - savedFloatValue = floatValue; - loadTime = new Date(); - savedLoadTime = loadTime; - children = new HashSet(); - children.add(member1); - children.add(member2); - children.add(member3); - } - - public void jdoPreClear() { - preClearCalled = true; - try { - i = 1; - } catch (Exception e) { - callbackCalled.add("jdoPreClear "); - exceptions.add(e); - attributeOpCausingExceptions.add("i = 1;"); + + public float calcFloatValue () { + return (float)(d * s); } - try { - c = '2'; - } catch (Exception e) { - callbackCalled.add("jdoPreClear "); - exceptions.add(e); - attributeOpCausingExceptions.add("c = '2';"); + + public void incrementIntValue() { + intValue++; } - try { - d = 3.0; - } catch (Exception e) { - callbackCalled.add("jdoPreClear "); - exceptions.add(e); - attributeOpCausingExceptions.add("d = 3.0;"); + + public void jdoPreStore() { + preStoreCalled = true; + intValue = calcIntValue(); + floatValue = calcFloatValue(); + + try { + i = -30; + }catch(Exception e) { + callbackCalled.add("jdoPreStore "); + exceptions.add(e); + attributeOpCausingExceptions.add("i = -30;"); + } + try { + c = '\u0000'; + }catch(Exception e) { + callbackCalled.add("jdoPreStore "); + exceptions.add(e); + attributeOpCausingExceptions.add("c = '\u0000';"); + } + try { + d = 362.5; + }catch(Exception e) { + callbackCalled.add("jdoPreStore "); + exceptions.add(e); + attributeOpCausingExceptions.add("d = 362.5;"); + } + try { + s = 0; + }catch(Exception e) { + callbackCalled.add("jdoPreStore "); + exceptions.add(e); + attributeOpCausingExceptions.add("s = 0;"); + } + try { + loadTime = null; + }catch(Exception e) { + callbackCalled.add("jdoPreStore "); + exceptions.add(e); + attributeOpCausingExceptions.add("loadTime = null;"); + } + try { + children = null; + }catch(Exception e) { + callbackCalled.add("jdoPreStore "); + exceptions.add(e); + attributeOpCausingExceptions.add("children = null;"); + } } - try { - s = 4; - } catch (Exception e) { - callbackCalled.add("jdoPreClear "); - exceptions.add(e); - attributeOpCausingExceptions.add("s = 4;"); + + public void jdoPreDelete() { + preDeleteCalled = true; + try { + i = 0; + }catch(Exception e) { + callbackCalled.add("jdoPreDelete "); + exceptions.add(e); + attributeOpCausingExceptions.add("i = 0;"); + } + try { + c = 'x'; + }catch(Exception e) { + callbackCalled.add("jdoPreDelete "); + exceptions.add(e); + attributeOpCausingExceptions.add("c = 'x';"); + } + try { + d = 0.0; + }catch(Exception e) { + callbackCalled.add("jdoPreDelete "); + exceptions.add(e); + attributeOpCausingExceptions.add("d = 0.0;"); + } + try { + s = -5; + }catch(Exception e) { + callbackCalled.add("jdoPreDelete "); + exceptions.add(e); + attributeOpCausingExceptions.add("s = -5;"); + } + try { + loadTime = null; + }catch(Exception e) { + callbackCalled.add("jdoPreDelete "); + exceptions.add(e); + attributeOpCausingExceptions.add("loadTime = null;"); + } + try { + children = null; + }catch(Exception e) { + callbackCalled.add("jdoPreDelete "); + exceptions.add(e); + attributeOpCausingExceptions.add("children = null;"); + } } - try { - loadTime = null; - } catch (Exception e) { - callbackCalled.add("jdoPreClear "); - exceptions.add(e); - attributeOpCausingExceptions.add("loadTime = null;"); + + public void jdoPostLoad() { + postloadCalled = true; + savedApplicationStep = applicationStep; + i = -10; + c = '2'; + d = 30.0; + s = 40; + savedIntValue = intValue; + savedFloatValue = floatValue; + loadTime = new Date(); + savedLoadTime = loadTime; + children = new HashSet(); + children.add(member1); + children.add(member2); + children.add(member3); } - try { - children = null; - } catch (Exception e) { - callbackCalled.add("jdoPreClear "); - exceptions.add(e); - attributeOpCausingExceptions.add("children = null;"); + + public void jdoPreClear() { + preClearCalled = true; + try { + i = 1; + }catch(Exception e) { + callbackCalled.add("jdoPreClear "); + exceptions.add(e); + attributeOpCausingExceptions.add("i = 1;"); + } + try { + c = '2'; + }catch(Exception e) { + callbackCalled.add("jdoPreClear "); + exceptions.add(e); + attributeOpCausingExceptions.add("c = '2';"); + } + try { + d = 3.0; + }catch(Exception e) { + callbackCalled.add("jdoPreClear "); + exceptions.add(e); + attributeOpCausingExceptions.add("d = 3.0;"); + } + try { + s = 4; + }catch(Exception e) { + callbackCalled.add("jdoPreClear "); + exceptions.add(e); + attributeOpCausingExceptions.add("s = 4;"); + } + try { + loadTime = null; + }catch(Exception e) { + callbackCalled.add("jdoPreClear "); + exceptions.add(e); + attributeOpCausingExceptions.add("loadTime = null;"); + } + try { + children = null; + }catch(Exception e) { + callbackCalled.add("jdoPreClear "); + exceptions.add(e); + attributeOpCausingExceptions.add("children = null;"); + } } - } - - public static class KeyClass implements Serializable { + +public static class KeyClass implements Serializable { public int keyValue; - public KeyClass() {} - - public KeyClass(String s) { - try { - keyValue = Integer.parseInt(s); - } catch (NumberFormatException e) { - keyValue = 0; - } + public KeyClass() { } + public KeyClass(String s) { + try{ keyValue = Integer.parseInt(s);} + catch(NumberFormatException e){ + keyValue = 0;} + } + public boolean equals(Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return false; - else return keyValue == ((KeyClass) obj).keyValue; + if( obj == null || !this.getClass().equals(obj.getClass()) ) return false; + else return keyValue == ((KeyClass)obj).keyValue; } - + public int hashCode() { - return keyValue; + return keyValue; } public String toString() { - return Integer.toString(keyValue); + return Integer.toString(keyValue); } - } +} } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.java b/tck/src/main/java/org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.java index 3c821879c..72aad5b01 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.java @@ -5,120 +5,122 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.lifecycle; import java.io.Serializable; public class StateTransitionObj implements Serializable { - private static int counter = 0; - - private int id; - private int int_field; - private transient int nonmanaged_field; - - public StateTransitionObj() { - id = ++counter; - int_field = 0; - } - - public StateTransitionObj(int v) { - this(); - int_field = v; - } - - public int readField() { - int value = int_field; - return value; - } - - public void writeField(int value) { - int_field = value; - } - - public int readNonmanagedField() { - return nonmanaged_field; - } - - public void writeNonmanagedField(int value) { - nonmanaged_field = value; - } - /** - * @return Returns the id. - */ - public int getId() { - return id; - } - /** - * @param id The id to set. - */ - public void setId(int id) { - this.id = id; - } - - /** - * The class to be used as the application identifier for the StateTransitionObj - * class. - */ - public static class Oid implements Serializable, Comparable { - - /** - * This field is part of the identifier and should match in name and type with a field in the - * StateTransitionObj class. - */ - public int id; - - /** The required public no-arg constructor. */ - public Oid() {} - - /** - * Initialize the identifier. - * - * @param id the id. - */ - public Oid(int id) { - this.id = id; + private static int counter = 0; + + private int id; + private int int_field; + private transient int nonmanaged_field; + + public StateTransitionObj() + { + id = ++counter; + int_field = 0; } - - public Oid(String s) { - id = Integer.parseInt(justTheId(s)); + public StateTransitionObj(int v) + { + this(); + int_field = v; } - - public String toString() { - return this.getClass().getName() + ": " + id; + public int readField() + { + int value = int_field; + return value; + } + public void writeField(int value) + { + int_field = value; } - - /** */ - public boolean equals(Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return false; - Oid o = (Oid) obj; - if (this.id != o.id) return false; - return true; + public int readNonmanagedField() + { + return nonmanaged_field; } - - /** */ - public int hashCode() { - return id; + public void writeNonmanagedField(int value) + { + nonmanaged_field = value; } - - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * @return Returns the id. + */ + public int getId() { + return id; + } + /** + * @param id The id to set. + */ + public void setId(int id) { + this.id = id; } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - return id - other.id; + /** + * The class to be used as the application identifier + * for the StateTransitionObj class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This field is part of the identifier and should match in name + * and type with a field in the StateTransitionObj class. + */ + public int id; + + /** The required public no-arg constructor. */ + public Oid() { } + + /** + * Initialize the identifier. + * @param id the id. + */ + public Oid(int id) { + this.id = id; + } + + public Oid(String s) { id = Integer.parseInt(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + id;} + + + /** */ + public boolean equals(Object obj) { + if (obj==null || !this.getClass().equals(obj.getClass())) + return false; + Oid o = (Oid) obj; + if (this.id != o.id) + return false; + return true; + } + + /** */ + public int hashCode() { + return id; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + return id - other.id; + } + } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/MylibReader.java b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/MylibReader.java index 176714942..1c0fa2378 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/MylibReader.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/MylibReader.java @@ -5,95 +5,102 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.mylib; import java.util.Date; import java.util.List; + import org.apache.jdo.tck.util.JDOCustomDateEditor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.core.io.ClassPathResource; -/** Utility class to create a mylib instances from an xml representation. */ +/** + * Utility class to create a mylib instances from an xml + * representation. + */ public class MylibReader extends DefaultListableBeanFactory { - /** The name of the root list bean. */ - public static final String ROOT_LIST_NAME = "root"; + /** The name of the root list bean. */ + public static final String ROOT_LIST_NAME = "root"; - /** Teardown classes */ - private static final Class[] tearDownClasses = new Class[] {PrimitiveTypes.class, PCClass.class}; + /** Teardown classes + */ + private static final Class[] tearDownClasses = new Class[] { + PrimitiveTypes.class, PCClass.class + }; - /** Bean definition reader */ - private final XmlBeanDefinitionReader reader; + /** Bean definition reader */ + private final XmlBeanDefinitionReader reader; - /** - * Create a MylibReader for the specified resourceName. - * - * @param resourceName the name of the resource - */ - public MylibReader(String resourceName) { - // Use the class loader of the PrimitiveTypes class to find the resource - this(resourceName, PrimitiveTypes.class.getClassLoader()); - } + /** + * Create a MylibReader for the specified resourceName. + * @param resourceName the name of the resource + */ + public MylibReader(String resourceName) { + // Use the class loader of the PrimitiveTypes class to find the resource + this(resourceName, PrimitiveTypes.class.getClassLoader()); + } - /** - * Create a MylibReader for the specified resourceName. - * - * @param resourceName the name of the resource - * @param classLoader the ClassLoader for the lookup - */ - public MylibReader(String resourceName, ClassLoader classLoader) { - super(); - configureFactory(); - this.reader = new XmlBeanDefinitionReader(this); - this.reader.loadBeanDefinitions(new ClassPathResource(resourceName, classLoader)); - } + /** + * Create a MylibReader for the specified resourceName. + * @param resourceName the name of the resource + * @param classLoader the ClassLoader for the lookup + */ + public MylibReader(String resourceName, ClassLoader classLoader) { + super(); + configureFactory(); + this.reader = new XmlBeanDefinitionReader(this); + this.reader.loadBeanDefinitions(new ClassPathResource(resourceName, classLoader)); + } - /** - * Returns a list of root objects. The method expects to find a bean called "root" of type list in - * the xml and returns it. - * - * @return a list of root instances - */ - public List getRootList() { - return (List) getBean(ROOT_LIST_NAME); - } + /** + * Returns a list of root objects. The method expects to find a bean + * called "root" of type list in the xml and returns it. + * @return a list of root instances + */ + public List getRootList() { + return (List)getBean(ROOT_LIST_NAME); + } + + /** + * Configure the MylibReader, e.g. register CustomEditor classes + * to convert the string representation of a property into an instance + * of the right type. + */ + private void configureFactory() { + registerCustomEditor(Date.class, JDOCustomDateEditor.class); + } + + // Convenience methods - /** - * Configure the MylibReader, e.g. register CustomEditor classes to convert the string - * representation of a property into an instance of the right type. - */ - private void configureFactory() { - registerCustomEditor(Date.class, JDOCustomDateEditor.class); - } + /** + * Convenience method returning an Address instance for the specified + * name. The method returns null if there is no Address + * bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * Address bean. + */ + public PrimitiveTypes getPrimitiveTypes(String name) { + return (PrimitiveTypes)getBean(name, PrimitiveTypes.class); + } - // Convenience methods - - /** - * Convenience method returning an Address instance for the specified name. The method returns - * null if there is no Address bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no Address bean. - */ - public PrimitiveTypes getPrimitiveTypes(String name) { - return (PrimitiveTypes) getBean(name, PrimitiveTypes.class); - } - - /** - * @return Returns the tearDownClasses. - */ - public static Class[] getTearDownClasses() { - return tearDownClasses; - } + /** + * @return Returns the tearDownClasses. + */ + public static Class[] getTearDownClasses() { + return tearDownClasses; + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCClass.java b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCClass.java index d6101abc6..4b5bff427 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCClass.java @@ -5,173 +5,175 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.mylib; import java.io.Serializable; + import javax.jdo.listener.LoadCallback; public class PCClass implements LoadCallback { - private long id; - private int number1; - private int number2; - - private int transientNumber1; - private int transientNumber2; - - public PCClass() {} - - /** - * @see LoadCallback#jdoPostLoad() - */ - public void jdoPostLoad() { - transientNumber1 = number1; - transientNumber2 = number2; - } - - /** - * @see Object#toString() - */ - public String toString() { - return "PCClass(" + id + ")"; - } - - /** - * @see Object#hashCode() - */ - public int hashCode() { - return (int) id; - } - - /** - * @see Object#equals(java.lang.Object) - */ - public boolean equals(Object other) { - if (other != null && (other instanceof PCClass)) { - PCClass k = (PCClass) other; - return k.id == this.id; - } - return false; - } - - /** - * @return Returns the id. - */ - public long getId() { - return id; - } - - /** - * @param id The id to set. - */ - public void setId(long id) { - this.id = id; - } - - /** - * @return Returns the number. - */ - public int getNumber1() { - return number1; - } - - /** - * @param number The number to set. - */ - public void setNumber1(int number) { - this.number1 = number; - } - - /** - * @return Returns the number2. - */ - public int getNumber2() { - return number2; - } - - /** - * @param number2 The number2 to set. - */ - public void setNumber2(int number2) { - this.number2 = number2; - } - - /** - * @return Returns the transientNumber1. - */ - public int getTransientNumber1() { - return transientNumber1; - } - - /** - * @param transientNumber1 The transientNumber1 to set. - */ - public void setTransientNumber1(int transientNumber1) { - this.transientNumber1 = transientNumber1; - } - - /** - * @return Returns the transientNumber2. - */ - public int getTransientNumber2() { - return transientNumber2; - } - - /** - * @param transientNumber2 The transientNumber2 to set. - */ - public void setTransientNumber2(int transientNumber2) { - this.transientNumber2 = transientNumber2; - } - - /** The objectid class for this class in case of application identity. */ - public static class Oid implements Serializable, Comparable { - - public long id; - - public Oid() {} - - public Oid(String s) { - id = Long.parseLong(justTheId(s)); + private long id; + private int number1; + private int number2; + + private int transientNumber1; + private int transientNumber2; + + public PCClass() { } - public String toString() { - return this.getClass().getName() + ": " + id; + /** + * @see LoadCallback#jdoPostLoad() + */ + public void jdoPostLoad() { + transientNumber1 = number1; + transientNumber2 = number2; } - public int hashCode() { - return (int) id; + /** + * @see Object#toString() + */ + public String toString() { + return "PCClass(" + id + ")"; } + /** + * @see Object#hashCode() + */ + public int hashCode() { return (int)id ; } + + /** + * @see Object#equals(java.lang.Object) + */ public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.id == this.id; - } - return false; + if (other != null && (other instanceof PCClass)) { + PCClass k = (PCClass)other; + return k.id == this.id; + } + return false; + } + + /** + * @return Returns the id. + */ + public long getId() { + return id; + } + + /** + * @param id The id to set. + */ + public void setId(long id) { + this.id = id; + } + + /** + * @return Returns the number. + */ + public int getNumber1() { + return number1; + } + + /** + * @param number The number to set. + */ + public void setNumber1(int number) { + this.number1 = number; } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * @return Returns the number2. + */ + public int getNumber2() { + return number2; } - public int compareTo(Object o) { - if (o == null) throw new ClassCastException(); - if (o == this) return 0; - long otherId = ((Oid) o).id; - if (id == otherId) return 0; - else if (id < otherId) return -1; - return 1; + /** + * @param number2 The number2 to set. + */ + public void setNumber2(int number2) { + this.number2 = number2; + } + + /** + * @return Returns the transientNumber1. + */ + public int getTransientNumber1() { + return transientNumber1; + } + + /** + * @param transientNumber1 The transientNumber1 to set. + */ + public void setTransientNumber1(int transientNumber1) { + this.transientNumber1 = transientNumber1; + } + + /** + * @return Returns the transientNumber2. + */ + public int getTransientNumber2() { + return transientNumber2; + } + + /** + * @param transientNumber2 The transientNumber2 to set. + */ + public void setTransientNumber2(int transientNumber2) { + this.transientNumber2 = transientNumber2; + } + + /** + * The objectid class for this class in case of application identity. + */ + public static class Oid implements Serializable, Comparable { + + public long id; + + public Oid() { + } + + public Oid(String s) { id = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + id;} + + public int hashCode() { return (int)id ; } + + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.id == this.id; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + public int compareTo(Object o) { + if (o == null) + throw new ClassCastException(); + if (o == this) + return 0; + long otherId = ((Oid)o).id; + if (id == otherId) + return 0; + else if (id < otherId) + return -1; + return 1; + } } - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCPoint.java b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCPoint.java index 03db362f9..02b8644ec 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCPoint.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCPoint.java @@ -5,111 +5,107 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.mylib; import java.io.Serializable; import java.util.Date; /** - * A simple class with two fields for application identity - * - * @author Marina Vatkina - */ +* A simple class with two fields for application identity +* +* @author Marina Vatkina +*/ public class PCPoint implements Serializable { + + + private static long counter = new Date().getTime(); + private static long newId() { + synchronized (PCPoint.class) { + return counter++; + } + } + private long id = newId(); + public int x; + public Integer y; - private static long counter = new Date().getTime(); + public PCPoint() { + } - private static long newId() { - synchronized (PCPoint.class) { - return counter++; + public PCPoint(int x, int y) { + this.x = x; + this.y = Integer.valueOf(y); } - } - - private long id = newId(); - public int x; - public Integer y; - - public PCPoint() {} - - public PCPoint(int x, int y) { - this.x = x; - this.y = Integer.valueOf(y); - } - - public PCPoint(int x, Integer y) { - this.x = x; - this.y = y; - } - - public String toString() { - String rc = null; - Object obj = this; - try { - rc = obj.getClass().getName(); - // rc = Util.getClassName(this) + name(); - } catch (NullPointerException ex) { - rc = "NPE getting PCPoint's values"; + + public PCPoint(int x, Integer y) { + this.x = x; + this.y = y; } - return rc; - } - public void setX(int x) { - this.x = x; - } + public String toString() { + String rc = null; + Object obj = this; + try { + rc = obj.getClass().getName(); + //rc = Util.getClassName(this) + name(); + } catch (NullPointerException ex) { + rc = "NPE getting PCPoint's values"; + } + return rc; + } - public int getX() { - return x; - } + public void setX(int x) { + this.x = x; + } - public void setY(Integer y) { - this.y = y; - } + public int getX() { + return x; + } - public Integer getY() { - return y; - } + public void setY(Integer y) { + this.y = y; + } - public String name() { - return " x: " + getX() + ", y: " + getY().intValue(); - } + public Integer getY() { + return y; + } + + public String name() { + return " x: " + getX() + ", y: " + getY().intValue(); + } - public static class Oid implements Serializable { - public long id; + public static class Oid implements Serializable { + public long id; - public Oid() {} + public Oid() { + } - public Oid(String s) { - id = Long.parseLong(justTheId(s)); - } + public Oid(String s) { id = Long.parseLong(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + id; - } + public String toString() { return this.getClass().getName() + ": " + id;} - public int hashCode() { - return (int) id; - } + public int hashCode() { return (int)id ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.id == this.id; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.id == this.id; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCPoint2.java b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCPoint2.java index 2340ac8f0..2bc5b3ac7 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCPoint2.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCPoint2.java @@ -5,149 +5,145 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.mylib; import java.io.Serializable; import java.util.Date; + import javax.jdo.InstanceCallbacks; /** - * A simple class with two fields for application identity - * - * @author Marina Vatkina - */ +* A simple class with two fields for application identity +* +* @author Marina Vatkina +*/ public class PCPoint2 implements Serializable, InstanceCallbacks { - - private static long counter = new Date().getTime(); - - private static long newId() { - synchronized (PCPoint2.class) { - return counter++; + + private static long counter = new Date().getTime(); + private static long newId() { + synchronized (PCPoint2.class) { + return counter++; + } } - } - - private long id = newId(); - public int x; - public Integer y; + private long id = newId(); + public int x; + public Integer y; - private boolean clearCalled = false; - private boolean loadCalled = false; - private boolean storeCalled = false; - private boolean deleteCalled = false; + private boolean clearCalled = false; + private boolean loadCalled = false; + private boolean storeCalled = false; + private boolean deleteCalled = false; - public void jdoPreClear() { - clearCalled = true; - } - - public void jdoPostLoad() { - loadCalled = true; - } + public void jdoPreClear() { + clearCalled = true; + } - public void jdoPreStore() { - storeCalled = true; - } + public void jdoPostLoad() { + loadCalled = true; + } - public void jdoPreDelete() { - deleteCalled = true; - } + public void jdoPreStore() { + storeCalled = true; + } - public boolean wasClearCalled() { - return clearCalled; - } + public void jdoPreDelete() { + deleteCalled = true; + } - public boolean wasPostLoadCalled() { - return loadCalled; - } + public boolean wasClearCalled() { + return clearCalled; + } - public boolean wasPreStoreCalled() { - return storeCalled; - } + public boolean wasPostLoadCalled() { + return loadCalled; + } - public boolean wasPreDeleteCalled() { - return deleteCalled; - } + public boolean wasPreStoreCalled() { + return storeCalled; + } - public PCPoint2() {} + public boolean wasPreDeleteCalled() { + return deleteCalled; + } - public PCPoint2(int x, int y) { - this.x = x; - this.y = Integer.valueOf(y); - } + public PCPoint2() { + } - public PCPoint2(int x, Integer y) { - this.x = x; - this.y = y; - } + public PCPoint2(int x, int y) { + this.x = x; + this.y = Integer.valueOf(y); + } - public String toString() { - String rc = null; - Object obj = this; - try { - rc = obj.getClass().getName(); - // rc = Util.getClassName(this) + name(); - } catch (NullPointerException ex) { - rc = "NPE getting PCPoint2's values"; + public PCPoint2(int x, Integer y) { + this.x = x; + this.y = y; } - return rc; - } - public void setX(int x) { - this.x = x; - } + public String toString() { + String rc = null; + Object obj = this; + try { + rc = obj.getClass().getName(); + //rc = Util.getClassName(this) + name(); + } catch (NullPointerException ex) { + rc = "NPE getting PCPoint2's values"; + } + return rc; + } - public int getX() { - return x; - } + public void setX(int x) { + this.x = x; + } - public void setY(Integer y) { - this.y = y; - } + public int getX() { + return x; + } - public Integer getY() { - return y; - } + public void setY(Integer y) { + this.y = y; + } - public String name() { - return " x: " + getX() + ", y: " + getY().intValue(); - } + public Integer getY() { + return y; + } + + public String name() { + return " x: " + getX() + ", y: " + getY().intValue(); + } - public static class Oid implements Serializable { - public long id; + public static class Oid implements Serializable { + public long id; - public Oid() {} + public Oid() { + } - public Oid(String s) { - id = Long.parseLong(justTheId(s)); - } + public Oid(String s) { id = Long.parseLong(justTheId(s)); } - public String toString() { - return this.getClass().getName() + ": " + id; - } + public String toString() { return this.getClass().getName() + ": " + id;} - public int hashCode() { - return (int) id; - } + public int hashCode() { return (int)id ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.id == this.id; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.id == this.id; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCRect.java b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCRect.java index 8ab3f1e71..5cda16e96 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCRect.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PCRect.java @@ -5,113 +5,107 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.mylib; import java.io.Serializable; import java.util.Date; /** - * Test for instances with application identity containing instances of a user-defined class. - * - * @author Marina Vatkina - */ +* Test for instances with application identity containing instances of +* a user-defined class. +* +* @author Marina Vatkina +*/ public class PCRect { + + private static long counter = new Date().getTime(); + private static long newId() { + synchronized (PCRect.class) { + return counter++; + } + } - private static long counter = new Date().getTime(); + public long id = newId(); - private static long newId() { - synchronized (PCRect.class) { - return counter++; - } - } - - public long id = newId(); - - public PCPoint upperLeft; - public PCPoint lowerRight; - - public PCRect() {} - - public PCRect(long id, PCPoint ul, PCPoint lr) { - upperLeft = ul; - lowerRight = lr; - } - - public PCRect(PCPoint ul, PCPoint lr) { - upperLeft = ul; - lowerRight = lr; - } - - public PCPoint getUpperLeft() { - return upperLeft; - } - - public PCPoint getLowerRight() { - return lowerRight; - } - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String toString() { - String rc = null; - Object obj = this; - try { - // rc = Util.getClassName(this) - rc = - obj.getClass().getName() - + " ul: " - + getUpperLeft().name() - + " lr: " - + getLowerRight().name(); - } catch (NullPointerException ex) { - rc = "NPE getting PCRect's values"; + public PCPoint upperLeft; + public PCPoint lowerRight; + + public PCRect() { } + + public PCRect(long id, PCPoint ul, PCPoint lr) { + upperLeft = ul; + lowerRight = lr; } - return rc; - } - public static class Oid implements Serializable { - public long id; + public PCRect(PCPoint ul, PCPoint lr) { + upperLeft = ul; + lowerRight = lr; + } - public Oid() {} + public PCPoint getUpperLeft() { + return upperLeft; + } - public Oid(String s) { - id = Long.parseLong(justTheId(s)); + public PCPoint getLowerRight() { + return lowerRight; } - public String toString() { - return this.getClass().getName() + ": " + id; + public long getId() { + return id; } - public int hashCode() { - return (int) id; + public void setId(long id) { + this.id = id; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.id == this.id; - } - return false; + public String toString() { + String rc = null; + Object obj = this; + try { + //rc = Util.getClassName(this) + rc = obj.getClass().getName() + + " ul: " + getUpperLeft().name() + + " lr: " + getLowerRight().name(); + } catch (NullPointerException ex) { + rc = "NPE getting PCRect's values"; + } + return rc; } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + public static class Oid implements Serializable { + public long id; + + public Oid() { + } + + public Oid(String s) { id = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + id;} + + public int hashCode() { return (int)id ; } + + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.id == this.id; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/Point.java b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/Point.java index bb618359c..65e2f3bbf 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/Point.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/Point.java @@ -5,60 +5,61 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.mylib; /** - * A simple class with two fields - * - * @author Dave Bristor - */ +* A simple class with two fields +* +* @author Dave Bristor +*/ public class Point { - public int x; - public Integer y; + public int x; + public Integer y; - public Point() {} + public Point() { } - public Point(int x, int y) { - this.x = x; - this.y = Integer.valueOf(y); - } + public Point(int x, int y) { + this.x = x; + this.y = Integer.valueOf(y); + } - public Point(int x, Integer y) { - this.x = x; - this.y = y; - } + public Point(int x, Integer y) { + this.x = x; + this.y = y; + } - public String toString() { - String rc = null; - try { - rc = "Point(" + name() + ")"; - } catch (NullPointerException ex) { - rc = "NPE getting Point's values"; + public String toString() { + String rc = null; + try { + rc = "Point(" + name() + ")"; + } catch (NullPointerException ex) { + rc = "NPE getting Point's values"; + } + return rc; } - return rc; - } - public int getX() { - System.out.println("Hello from Point.getX"); - return x; - } + public int getX() { + System.out.println("Hello from Point.getX"); + return x; + } - public Integer getY() { - System.out.println("Hello from Point.getY"); - return y; - } + public Integer getY() { + System.out.println("Hello from Point.getY"); + return y; + } + + public String name() { + return "x: " + getX() + ", y: " + getY().intValue(); + } - public String name() { - return "x: " + getX() + ", y: " + getY().intValue(); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PrimitiveTypes.java b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PrimitiveTypes.java index 37d83fab9..d198cef03 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PrimitiveTypes.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/PrimitiveTypes.java @@ -5,397 +5,397 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.mylib; +import javax.jdo.annotations.PersistenceCapable; import java.io.Serializable; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Date; -import javax.jdo.annotations.PersistenceCapable; @PersistenceCapable public class PrimitiveTypes implements Serializable { - private static long counter = new Date().getTime(); - - private static long newId() { - synchronized (PrimitiveTypes.class) { - return counter++; - } - } - - private long id = newId(); - private boolean booleanNotNull; - private Boolean booleanNull; - private byte byteNotNull; - private Byte byteNull; - private short shortNotNull; - private Short shortNull; - private int intNotNull; - private Integer intNull; - private long longNotNull; - private Long longNull; - private float floatNotNull; - private Float floatNull; - private double doubleNotNull; - private Double doubleNull; - private char charNotNull; - private Character charNull; - private Date dateNull; - private String stringNull; - private BigDecimal bigDecimal; - private BigInteger bigInteger; - private Long PrimitiveTypes; - - public Object getOid() { - Oid oid = new Oid(); - oid.id = this.id; - return oid; - } - - public String toString() { - return "PrimitiveTypes(" + id + ")"; - } - - public int hashCode() { - int hashCode = 0; - hashCode += id; - hashCode += booleanNotNull ? Boolean.TRUE.hashCode() : Boolean.FALSE.hashCode(); - hashCode += booleanNull != null ? booleanNull.hashCode() : 0; - hashCode += byteNotNull; - hashCode += byteNull != null ? byteNull.hashCode() : 0; - hashCode += shortNotNull; - hashCode += shortNull != null ? shortNull.hashCode() : 0; - hashCode += intNotNull; - hashCode += intNull != null ? intNull.hashCode() : 0; - hashCode += longNotNull; - hashCode += longNull != null ? longNull.hashCode() : 0; - hashCode += floatNotNull; - hashCode += floatNull != null ? floatNull.hashCode() : 0; - hashCode += doubleNotNull; - hashCode += doubleNull != null ? doubleNull.hashCode() : 0; - hashCode += charNotNull; - hashCode += charNull != null ? charNull.hashCode() : 0; - hashCode += dateNull != null ? dateNull.hashCode() : 0; - hashCode += stringNull != null ? stringNull.hashCode() : 0; - hashCode += bigDecimal != null ? bigDecimal.hashCode() : 0; - hashCode += bigInteger != null ? bigDecimal.hashCode() : 0; - hashCode += PrimitiveTypes != null ? PrimitiveTypes.hashCode() : 0; - return hashCode; - } - - public boolean equals(Object o) { - PrimitiveTypes p = (PrimitiveTypes) o; - if (id != p.id) return false; - if (booleanNotNull != p.booleanNotNull) return false; - if (booleanNull != null) return booleanNull.equals(p.booleanNull); - else if (p.booleanNull != null) return false; - if (byteNotNull != p.byteNotNull) return false; - if (byteNull != null) return byteNull.equals(p.byteNull); - else if (p.byteNull != null) return false; - if (shortNotNull != p.shortNotNull) return false; - if (shortNull != null) return shortNull.equals(p.shortNull); - else if (p.shortNull != null) return false; - if (intNotNull != p.intNotNull) return false; - if (intNull != null) return intNull.equals(p.intNull); - else if (p.intNull != null) return false; - if (longNotNull != p.longNotNull) return false; - if (longNull != null) return longNull.equals(p.longNull); - else if (p.longNull != null) return false; - if (floatNotNull != p.floatNotNull) return false; - if (floatNull != null) return floatNull.equals(p.floatNull); - else if (p.floatNull != null) return false; - if (doubleNotNull != p.doubleNotNull) return false; - if (doubleNull != null) return doubleNull.equals(p.doubleNull); - else if (p.doubleNull != null) return false; - if (charNotNull != p.charNotNull) return false; - if (charNull != null) return charNull.equals(p.charNull); - else if (p.charNull != null) return false; - if (dateNull != null) return dateNull.equals(p.dateNull); - else if (p.dateNull != null) return false; - if (stringNull != null) return stringNull.equals(p.stringNull); - else if (p.stringNull != null) return false; - if (bigDecimal != null) return bigDecimal.equals(p.bigDecimal); - else if (p.bigDecimal != null) return false; - if (bigInteger != null) return bigInteger.equals(p.bigInteger); - else if (p.bigInteger != null) return false; - if (PrimitiveTypes != null) return PrimitiveTypes.equals(p.PrimitiveTypes); - else if (p.PrimitiveTypes != null) return false; - return true; - } - - public PrimitiveTypes() {} - - public PrimitiveTypes( - long id, - boolean booleanNotNull, - Boolean booleanNull, - byte byteNotNull, - Byte byteNull, - short shortNotNull, - Short shortNull, - int intNotNull, - Integer intNull, - long longNotNull, - Long longNull, - float floatNotNull, - Float floatNull, - double doubleNotNull, - Double doubleNull, - char charNotNull, - Character charNull, - Date dateNull, - String stringNull, - BigDecimal bigDecimal, - BigInteger bigInteger, - Long PrimitiveTypes) { - this.id = id; - this.booleanNotNull = booleanNotNull; - this.booleanNull = booleanNull; - this.byteNotNull = byteNotNull; - this.byteNull = byteNull; - this.shortNotNull = shortNotNull; - this.shortNull = shortNull; - this.intNotNull = intNotNull; - this.intNull = intNull; - this.longNotNull = longNotNull; - this.longNull = longNull; - this.floatNotNull = floatNotNull; - this.floatNull = floatNull; - this.doubleNotNull = doubleNotNull; - this.doubleNull = doubleNull; - this.charNotNull = charNotNull; - this.charNull = charNull; - this.dateNull = dateNull; - this.stringNull = stringNull; - this.bigDecimal = bigDecimal; - this.bigInteger = bigInteger; - this.PrimitiveTypes = PrimitiveTypes; - } - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public boolean getBooleanNotNull() { - return booleanNotNull; - } - - public void setBooleanNotNull(boolean booleanNotNull) { - this.booleanNotNull = booleanNotNull; - } - - public Boolean getBooleanNull() { - return booleanNull; - } - - public void setBooleanNull(Boolean booleanNull) { - this.booleanNull = booleanNull; - } - - public byte getByteNotNull() { - return byteNotNull; - } - - public void setByteNotNull(byte byteNotNull) { - this.byteNotNull = byteNotNull; - } - - public Byte getByteNull() { - return byteNull; - } - - public void setByteNull(Byte byteNull) { - this.byteNull = byteNull; - } - - public short getShortNotNull() { - return shortNotNull; - } - - public void setShortNotNull(short shortNotNull) { - this.shortNotNull = shortNotNull; - } - - public Short getShortNull() { - return shortNull; - } - - public void setShortNull(Short shortNull) { - this.shortNull = shortNull; - } - - public int getIntNotNull() { - return intNotNull; - } - - public void setIntNotNull(int intNotNull) { - this.intNotNull = intNotNull; - } - - public Integer getIntNull() { - return intNull; - } - - public void setIntNull(Integer intNull) { - this.intNull = intNull; - } - - public long getLongNotNull() { - return longNotNull; - } - - public void setLongNotNull(long longNotNull) { - this.longNotNull = longNotNull; - } - - public Long getLongNull() { - return longNull; - } - - public void setLongNull(Long longNull) { - this.longNull = longNull; - } + private static long counter = new Date().getTime(); + private static long newId() { + synchronized (PrimitiveTypes.class) { + return counter++; + } + } + private long id = newId(); + private boolean booleanNotNull; + private Boolean booleanNull; + private byte byteNotNull; + private Byte byteNull; + private short shortNotNull; + private Short shortNull; + private int intNotNull; + private Integer intNull; + private long longNotNull; + private Long longNull; + private float floatNotNull; + private Float floatNull; + private double doubleNotNull; + private Double doubleNull; + private char charNotNull; + private Character charNull; + private Date dateNull; + private String stringNull; + private BigDecimal bigDecimal; + private BigInteger bigInteger; + private Long PrimitiveTypes; + + public Object getOid() { + Oid oid = new Oid(); + oid.id = this.id; + return oid; + } - public float getFloatNotNull() { - return floatNotNull; - } + public String toString() { + return "PrimitiveTypes(" + id + ")"; + } + + public int hashCode() { + int hashCode = 0; + hashCode += id; + hashCode += booleanNotNull ? + Boolean.TRUE.hashCode() : Boolean.FALSE.hashCode(); + hashCode += booleanNull != null ? booleanNull.hashCode() : 0; + hashCode += byteNotNull; + hashCode += byteNull != null ? byteNull.hashCode() : 0; + hashCode += shortNotNull; + hashCode += shortNull != null ? shortNull.hashCode() : 0; + hashCode += intNotNull; + hashCode += intNull != null ? intNull.hashCode() : 0; + hashCode += longNotNull; + hashCode += longNull != null ? longNull.hashCode() : 0; + hashCode += floatNotNull; + hashCode += floatNull != null ? floatNull.hashCode() : 0; + hashCode += doubleNotNull; + hashCode += doubleNull != null ? doubleNull.hashCode() : 0; + hashCode += charNotNull; + hashCode += charNull != null ? charNull.hashCode() : 0; + hashCode += dateNull != null ? dateNull.hashCode() : 0; + hashCode += stringNull != null ? stringNull.hashCode() : 0; + hashCode += bigDecimal != null ? bigDecimal.hashCode() : 0; + hashCode += bigInteger != null ? bigDecimal.hashCode() : 0; + hashCode += PrimitiveTypes != null ? PrimitiveTypes.hashCode() : 0; + return hashCode; + } - public void setFloatNotNull(float floatNotNull) { - this.floatNotNull = floatNotNull; - } + public boolean equals(Object o) { + PrimitiveTypes p = (PrimitiveTypes) o; + if (id != p.id) return false; + if (booleanNotNull != p.booleanNotNull) return false; + if (booleanNull != null) return booleanNull.equals(p.booleanNull); + else if (p.booleanNull != null) return false; + if (byteNotNull != p.byteNotNull) return false; + if (byteNull != null) return byteNull.equals(p.byteNull); + else if (p.byteNull != null) return false; + if (shortNotNull != p.shortNotNull) return false; + if (shortNull != null) return shortNull.equals(p.shortNull); + else if (p.shortNull != null) return false; + if (intNotNull != p.intNotNull) return false; + if (intNull != null) return intNull.equals(p.intNull); + else if (p.intNull != null) return false; + if (longNotNull != p.longNotNull) return false; + if (longNull != null) return longNull.equals(p.longNull); + else if (p.longNull != null) return false; + if (floatNotNull != p.floatNotNull) return false; + if (floatNull != null) return floatNull.equals(p.floatNull); + else if (p.floatNull != null) return false; + if (doubleNotNull != p.doubleNotNull) return false; + if (doubleNull != null) return doubleNull.equals(p.doubleNull); + else if (p.doubleNull != null) return false; + if (charNotNull != p.charNotNull) return false; + if (charNull != null) return charNull.equals(p.charNull); + else if (p.charNull != null) return false; + if (dateNull != null) return dateNull.equals(p.dateNull); + else if (p.dateNull != null) return false; + if (stringNull != null) return stringNull.equals(p.stringNull); + else if (p.stringNull != null) return false; + if (bigDecimal != null) return bigDecimal.equals(p.bigDecimal); + else if (p.bigDecimal != null) return false; + if (bigInteger != null) return bigInteger.equals(p.bigInteger); + else if (p.bigInteger != null) return false; + if (PrimitiveTypes != null) return PrimitiveTypes.equals(p.PrimitiveTypes); + else if (p.PrimitiveTypes != null) return false; + return true; + } - public Float getFloatNull() { - return floatNull; - } + public PrimitiveTypes() { + } - public void setFloatNull(Float floatNull) { - this.floatNull = floatNull; - } + public PrimitiveTypes(long id, + boolean booleanNotNull, + Boolean booleanNull, + byte byteNotNull, + Byte byteNull, + short shortNotNull, + Short shortNull, + int intNotNull, + Integer intNull, + long longNotNull, + Long longNull, + float floatNotNull, + Float floatNull, + double doubleNotNull, + Double doubleNull, + char charNotNull, + Character charNull, + Date dateNull, + String stringNull, + BigDecimal bigDecimal, + BigInteger bigInteger, + Long PrimitiveTypes) { + this.id = id; + this.booleanNotNull = booleanNotNull; + this.booleanNull = booleanNull; + this.byteNotNull = byteNotNull; + this.byteNull = byteNull; + this.shortNotNull = shortNotNull; + this.shortNull = shortNull; + this.intNotNull = intNotNull; + this.intNull = intNull; + this.longNotNull = longNotNull; + this.longNull =longNull; + this.floatNotNull = floatNotNull; + this.floatNull =floatNull; + this.doubleNotNull = doubleNotNull; + this.doubleNull = doubleNull; + this.charNotNull = charNotNull; + this.charNull = charNull; + this.dateNull = dateNull; + this.stringNull = stringNull; + this.bigDecimal = bigDecimal; + this.bigInteger = bigInteger; + this.PrimitiveTypes = PrimitiveTypes; + } - public double getDoubleNotNull() { - return doubleNotNull; - } + public long getId() { + return id; + } - public void setDoubleNotNull(double doubleNotNull) { - this.doubleNotNull = doubleNotNull; - } + public void setId(long id) { + this.id = id; + } - public Double getDoubleNull() { - return doubleNull; - } + public boolean getBooleanNotNull() { + return booleanNotNull; + } - public void setDoubleNull(Double doubleNull) { - this.doubleNull = doubleNull; - } + public void setBooleanNotNull(boolean booleanNotNull) { + this.booleanNotNull = booleanNotNull; + } - public char getCharNotNull() { - return charNotNull; - } + public Boolean getBooleanNull() { + return booleanNull; + } - public void setCharNotNull(char charNotNull) { - this.charNotNull = charNotNull; - } + public void setBooleanNull(Boolean booleanNull) { + this.booleanNull = booleanNull; + } - public Character getCharNull() { - return charNull; - } + public byte getByteNotNull() { + return byteNotNull; + } - public void setCharNull(Character charNull) { - this.charNull = charNull; - } + public void setByteNotNull(byte byteNotNull) { + this.byteNotNull = byteNotNull; + } - public Date getDateNull() { - return dateNull; - } + public Byte getByteNull() { + return byteNull; + } - public void setDateNull(Date dateNull) { - this.dateNull = dateNull; - } + public void setByteNull(Byte byteNull) { + this.byteNull = byteNull; + } - public String getStringNull() { - return stringNull; - } + public short getShortNotNull() { + return shortNotNull; + } - public void setStringNull(String stringNull) { - this.stringNull = stringNull; - } + public void setShortNotNull(short shortNotNull) { + this.shortNotNull = shortNotNull; + } - public BigDecimal getBigDecimal() { - return bigDecimal; - } + public Short getShortNull() { + return shortNull; + } - public void setBigDecimal(BigDecimal bigDecimal) { - this.bigDecimal = bigDecimal; - } + public void setShortNull(Short shortNull) { + this.shortNull = shortNull; + } - public BigInteger getBigInteger() { - return bigInteger; - } + public int getIntNotNull() { + return intNotNull; + } - public void setBigInteger(BigInteger bigInteger) { - this.bigInteger = bigInteger; - } + public void setIntNotNull(int intNotNull) { + this.intNotNull = intNotNull; + } - public Long getPrimitiveTypes() { - return PrimitiveTypes; - } + public Integer getIntNull() { + return intNull; + } + + public void setIntNull(Integer intNull) { + this.intNull = intNull; + } - public void setPrimitiveTypes(Long primitiveTypes) { - this.PrimitiveTypes = primitiveTypes; - } + public long getLongNotNull() { + return longNotNull; + } - public static class Oid implements Serializable, Comparable { + public void setLongNotNull(long longNotNull) { + this.longNotNull = longNotNull; + } - public long id; + public Long getLongNull() { + return longNull; + } - public Oid() {} + public void setLongNull(Long longNull) { + this.longNull = longNull; + } - public Oid(String s) { - id = Long.parseLong(justTheId(s)); + public float getFloatNotNull() { + return floatNotNull; } - public String toString() { - return this.getClass().getName() + ": " + id; + public void setFloatNotNull(float floatNotNull) { + this.floatNotNull = floatNotNull; } - public int hashCode() { - return (int) id; + public Float getFloatNull() { + return floatNull; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.id == this.id; - } - return false; + public void setFloatNull(Float floatNull) { + this.floatNull = floatNull; } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + public double getDoubleNotNull() { + return doubleNotNull; } - public int compareTo(Object o) { - if (o == null) throw new ClassCastException(); - if (o == this) return 0; - long otherId = ((Oid) o).id; - if (id == otherId) return 0; - else if (id < otherId) return -1; - return 1; + public void setDoubleNotNull(double doubleNotNull) { + this.doubleNotNull = doubleNotNull; } - } + + public Double getDoubleNull() { + return doubleNull; + } + + public void setDoubleNull(Double doubleNull) { + this.doubleNull = doubleNull; + } + + public char getCharNotNull() { + return charNotNull; + } + + public void setCharNotNull(char charNotNull) { + this.charNotNull = charNotNull; + } + + public Character getCharNull() { + return charNull; + } + + public void setCharNull(Character charNull) { + this.charNull = charNull; + } + + public Date getDateNull() { + return dateNull; + } + + public void setDateNull(Date dateNull) { + this.dateNull = dateNull; + } + + public String getStringNull() { + return stringNull; + } + + public void setStringNull(String stringNull) { + this.stringNull = stringNull; + } + + public BigDecimal getBigDecimal() { + return bigDecimal; + } + + public void setBigDecimal(BigDecimal bigDecimal) { + this.bigDecimal = bigDecimal; + } + + public BigInteger getBigInteger() { + return bigInteger; + } + + public void setBigInteger(BigInteger bigInteger) { + this.bigInteger = bigInteger; + } + + public Long getPrimitiveTypes() { + return PrimitiveTypes; + } + + public void setPrimitiveTypes(Long primitiveTypes) { + this.PrimitiveTypes = primitiveTypes; + } + + public static class Oid implements Serializable, Comparable { + + public long id; + + public Oid() { + } + + public Oid(String s) { id = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + id;} + + public int hashCode() { return (int)id ; } + + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.id == this.id; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + public int compareTo(Object o) { + if (o == null) + throw new ClassCastException(); + if (o == this) + return 0; + long otherId = ((Oid)o).id; + if (id == otherId) + return 0; + else if (id < otherId) + return -1; + return 1; + } + } + } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/VersionedPCPoint.java b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/VersionedPCPoint.java index 84072867b..80fa4df1c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/mylib/VersionedPCPoint.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/mylib/VersionedPCPoint.java @@ -5,125 +5,121 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.mylib; +import javax.jdo.annotations.PersistenceCapable; import java.io.Serializable; import java.util.Date; -import javax.jdo.annotations.PersistenceCapable; /** - * A simple class with two fields for application identity - * - * @author Marina Vatkina - */ +* A simple class with two fields for application identity +* +* @author Marina Vatkina +*/ @PersistenceCapable public class VersionedPCPoint implements Serializable { + + + private static long counter = new Date().getTime(); + private static long newId() { + synchronized (PCPoint.class) { + return counter++; + } + } + private long id = newId(); + public int x; + public Integer y; - private static long counter = new Date().getTime(); + public VersionedPCPoint() { + } - private static long newId() { - synchronized (PCPoint.class) { - return counter++; + public VersionedPCPoint(int x, int y) { + this.x = x; + this.y = Integer.valueOf(y); } - } - - private long id = newId(); - public int x; - public Integer y; - - public VersionedPCPoint() {} - - public VersionedPCPoint(int x, int y) { - this.x = x; - this.y = Integer.valueOf(y); - } - - public VersionedPCPoint(int x, Integer y) { - this.x = x; - this.y = y; - } - - public String toString() { - String rc = null; - Object obj = this; - try { - rc = obj.getClass().getName(); - // rc = Util.getClassName(this) + name(); - } catch (NullPointerException ex) { - rc = "NPE getting PCPoint's values"; + + public VersionedPCPoint(int x, Integer y) { + this.x = x; + this.y = y; } - return rc; - } - public void setX(int x) { - this.x = x; - } + public String toString() { + String rc = null; + Object obj = this; + try { + rc = obj.getClass().getName(); + //rc = Util.getClassName(this) + name(); + } catch (NullPointerException ex) { + rc = "NPE getting PCPoint's values"; + } + return rc; + } - public int getX() { - return x; - } + public void setX(int x) { + this.x = x; + } - public void setY(Integer y) { - this.y = y; - } + public int getX() { + return x; + } - public Integer getY() { - return y; - } + public void setY(Integer y) { + this.y = y; + } - public String name() { - return " x: " + getX() + ", y: " + getY().intValue(); - } + public Integer getY() { + return y; + } + + public String name() { + return " x: " + getX() + ", y: " + getY().intValue(); + } - public static class Oid implements Serializable { - public long id; + public static class Oid implements Serializable { + public long id; - /** The name of the class of the target object. */ - public static String targetClassName = "org.apache.jdo.tck.pc.mylib.VersionedPCPoint"; + /** The name of the class of the target object. + */ + public static String targetClassName = + "org.apache.jdo.tck.pc.mylib.VersionedPCPoint"; - public Oid() {} + public Oid() { + } - public Oid(String s) { - id = Long.parseLong(justTheId(s)); - } + public Oid(String s) { id = Long.parseLong(justTheId(s)); } - public String toString() { - return getTargetClassName() + ": " + id; - } + public String toString() { return getTargetClassName() + ": " + id;} - public int hashCode() { - return (int) id; - } + public int hashCode() { return (int)id ; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid k = (Oid) other; - return k.id == this.id; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid k = (Oid)other; + return k.id == this.id; + } + return false; + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); - } + /** Return the target class name. + * @return the target class name. + */ + public String getTargetClassName() { + return targetClassName; + } - /** - * Return the target class name. - * - * @return the target class name. - */ - public String getTargetClassName() { - return targetClassName; - } - } + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/AAddress.java b/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/AAddress.java index 6ebfee2ef..764316b8d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/AAddress.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/AAddress.java @@ -5,45 +5,36 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.newInstance; /** - * This interface represents the persistent state of Address. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Address. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public abstract class AAddress implements IAddress { - public abstract long getAddrid(); - - public abstract String getStreet(); - - public abstract String getCity(); - - public abstract String getState(); - - public abstract String getZipcode(); - - public abstract String getCountry(); - - public abstract void setAddrid(long addrid); - - public abstract void setStreet(String street); - - public abstract void setCity(String city); - - public abstract void setState(String state); - - public abstract void setZipcode(String zipcode); - - public abstract void setCountry(String country); + public abstract long getAddrid(); + public abstract String getStreet(); + public abstract String getCity(); + public abstract String getState(); + public abstract String getZipcode(); + public abstract String getCountry(); + + public abstract void setAddrid(long addrid); + public abstract void setStreet(String street); + public abstract void setCity(String city); + public abstract void setState(String state); + public abstract void setZipcode(String zipcode); + public abstract void setCountry(String country); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/AAddress_bad.java b/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/AAddress_bad.java index 57dbecd64..e19589a22 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/AAddress_bad.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/AAddress_bad.java @@ -5,49 +5,40 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.newInstance; /** - * This interface represents the persistent state of Address. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Address. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public abstract class AAddress_bad implements IAddress { - public abstract long getAddrid(); - - public abstract String getStreet(); - - public abstract String getCity(); - - public abstract String getState(); - - public abstract String getZipcode(); - - public abstract String getCountry(); - - // Lacks setter, so not a persistent property - // Expect JDOUserException on pm.newInstance(this) - public abstract String getAString(); - - public abstract void setAddrid(long addrid); - - public abstract void setStreet(String street); - - public abstract void setCity(String city); - - public abstract void setState(String state); - - public abstract void setZipcode(String zipcode); - - public abstract void setCountry(String country); + public abstract long getAddrid(); + public abstract String getStreet(); + public abstract String getCity(); + public abstract String getState(); + public abstract String getZipcode(); + public abstract String getCountry(); + + // Lacks setter, so not a persistent property + // Expect JDOUserException on pm.newInstance(this) + public abstract String getAString(); + + public abstract void setAddrid(long addrid); + public abstract void setStreet(String street); + public abstract void setCity(String city); + public abstract void setState(String state); + public abstract void setZipcode(String zipcode); + public abstract void setCountry(String country); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/Address.java b/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/Address.java index c63b6c8e4..d6fefccde 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/Address.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/Address.java @@ -5,343 +5,334 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.newInstance; import java.io.Serializable; -/** This class represents a postal address. */ -public class Address implements IAddress + +/** + * This class represents a postal address. + */ +public class Address + implements IAddress // , Serializable, Comparable, Comparator, DeepEquality { - private long addrid; - private String street; - private String city; - private String state; - private String zipcode; - private String country; - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public Address() {} - - /** - * This constructor initializes the Address components. - * - * @param addrid The address ID. - * @param street The street address. - * @param city The city. - * @param state The state. - * @param zipcode The zip code. - * @param country The zip country. - */ - public Address( - long addrid, String street, String city, String state, String zipcode, String country) { - this.addrid = addrid; - this.street = street; - this.city = city; - this.state = state; - this.zipcode = zipcode; - this.country = country; - } - - /** - * Get the addrid associated with this object. - * - * @return the addrid. - */ - public long getAddrid() { - return addrid; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setAddrid(long id) { - if (this.addrid != 0) throw new IllegalStateException("Id is already set."); - this.addrid = id; - } + private long addrid; + private String street; + private String city; + private String state; + private String zipcode; + private String country; - /** - * Get the street component of the address. - * - * @return The street component of the address. - */ - public String getStreet() { - return street; - } - - /** - * Set the street component of the address. - * - * @param street The street component. - */ - public void setStreet(String street) { - this.street = street; - } - - /** - * Get the city. - * - * @return The city component of the address. - */ - public String getCity() { - return city; - } - - /** - * Set the city component of the address. - * - * @param city The city. - */ - public void setCity(String city) { - this.city = city; - } - - /** - * Get the state component of the address. - * - * @return The state. - */ - public String getState() { - return state; - } - - /** - * Set the state component of the address. - * - * @param state The state. - */ - public void setState(String state) { - this.state = state; - } - - /** - * Get the zipcode component of the address. - * - * @return The zipcode. - */ - public String getZipcode() { - return zipcode; - } + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public Address() {} - /** - * Set the zip code component of the address. - * - * @param zipcode The zipcode. - */ - public void setZipcode(String zipcode) { - this.zipcode = zipcode; - } + /** + * This constructor initializes the Address components. + * @param addrid The address ID. + * @param street The street address. + * @param city The city. + * @param state The state. + * @param zipcode The zip code. + * @param country The zip country. + */ + public Address(long addrid, String street, String city, + String state, String zipcode, String country) + { + this.addrid = addrid; + this.street = street; + this.city = city; + this.state = state; + this.zipcode = zipcode; + this.country = country; + } - /** - * Get the country component of the address. - * - * @return The country. - */ - public String getCountry() { - return country; - } + /** + * Get the addrid associated with this object. + * @return the addrid. + */ + public long getAddrid() { + return addrid; + } - /** - * Set the country component of the address. - * - * @param country The country. - */ - public void setCountry(String country) { - this.country = country; - } + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setAddrid(long id) { + if (this.addrid != 0) + throw new IllegalStateException("Id is already set."); + this.addrid = id; + } - /** - * Returns a String representation of a Address object. - * - * @return a String representation of a Address object. - */ - public String toString() { - return "Address(" + getFieldRepr() + ")"; - } + /** + * Get the street component of the address. + * @return The street component of the address. + */ + public String getStreet() { + return street; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(addrid); - rc.append(", street ").append(street); - rc.append(", city ").append(city); - rc.append(", state ").append(state); - rc.append(", zipcode ").append(zipcode); - rc.append(", country ").append(country); - return rc.toString(); - } + /** + * Set the street component of the address. + * @param street The street component. + */ + public void setStreet(String street) { + this.street = street; + } - // /** - // * Returns true if all the fields of this instance are - // * deep equal to the coresponding fields of the specified Person. - // * @param other the object with which to compare. - // * @param helper EqualityHelper to keep track of instances that have - // * already been processed. - // * @return true if all the fields are deep equal; - // * false otherwise. - // * @throws ClassCastException if the specified instances' type prevents - // * it from being compared to this instance. - // */ - // public boolean deepCompareFields(Object other, - // EqualityHelper helper) { - // IAddress otherAddress = (IAddress)other; - // String where = "Address<" + addrid + ">"; - // return - // helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") & - // helper.equals(street, otherAddress.getStreet(), where + ".street") & - // helper.equals(city, otherAddress.getCity(), where + ".city") & - // helper.equals(state, otherAddress.getState(), where + ".state") & - // helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") & - // helper.equals(country, otherAddress.getCountry(), where + ".country"); - // } - // - // /** - // * Compares this object with the specified object for order. Returns a - // * negative integer, zero, or a positive integer as this object is less - // * than, equal to, or greater than the specified object. - // * @param o The Object to be compared. - // * @return a negative integer, zero, or a positive integer as this - // * object is less than, equal to, or greater than the specified object. - // * @throws ClassCastException - if the specified object's type prevents - // * it from being compared to this Object. - // */ - // public int compareTo(Object o) { - // return compareTo((IAddress)o); - // } - // - // /** - // * Compare two instances. This is a method in Comparator. - // */ - // public int compare(Object o1, Object o2) { - // return compare((IAddress)o1, (IAddress)o2); - // } - // - // /** - // * Compares this object with the specified Address object for - // * order. Returns a negative integer, zero, or a positive integer as - // * this object is less than, equal to, or greater than the specified - // * object. - // * @param other The Address object to be compared. - // * @return a negative integer, zero, or a positive integer as this - // * object is less than, equal to, or greater than the specified Address - // * object. - // */ - // public int compareTo(IAddress other) { - // return compare(this, other); - // } - // - // /** - // * Compares its two IAddress arguments for order. Returns a negative - // * integer, zero, or a positive integer as the first argument is less - // * than, equal to, or greater than the second. - // * @param o1 the first IAddress object to be compared. - // * @param o2 the second IAddress object to be compared. - // * @return a negative integer, zero, or a positive integer as the first - // * object is less than, equal to, or greater than the second object. - // */ - // public static int compare(IAddress o1, IAddress o2) { - // return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); - // } - // - // /** - // * Indicates whether some other object is "equal to" this one. - // * @param obj the object with which to compare. - // * @return true if this object is the same as the obj - // * argument; false otherwise. - // */ - // public boolean equals(Object obj) { - // if (obj instanceof IAddress) { - // return compareTo((IAddress)obj) == 0; - // } - // return false; - // } + /** + * Get the city. + * @return The city component of the address. + */ + public String getCity() { + return city; + } - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) addrid; - } + /** + * Set the city component of the address. + * @param city The city. + */ + public void setCity(String city) { + this.city = city; + } + + /** + * Get the state component of the address. + * @return The state. + */ + public String getState() { + return state; + } - /** - * This class is used to represent the application identifier for the Address class. - */ - public static class Oid implements Serializable, Comparable { + /** + * Set the state component of the address. + * @param state The state. + */ + public void setState(String state) { + this.state = state; + } /** - * This is the identifier field for Address and must correspond in type and name to - * the field in Address. + * Get the zipcode component of the address. + * @return The zipcode. */ - public long addrid; + public String getZipcode() { + return zipcode; + } - /** The required public, no-arg constructor. */ - public Oid() { - addrid = 0; + /** + * Set the zip code component of the address. + * @param zipcode The zipcode. + */ + public void setZipcode(String zipcode) { + this.zipcode = zipcode; } /** - * A constructor to initialize the identifier field. - * - * @param addrid the id of the Address. + * Get the country component of the address. + * @return The country. */ - public Oid(long addrid) { - this.addrid = addrid; + public String getCountry() { + return country; } - public Oid(String s) { - addrid = Long.parseLong(justTheId(s)); + /** + * Set the country component of the address. + * @param country The country. + */ + public void setCountry(String country) { + this.country = country; } + /** + * Returns a String representation of a Address object. + * @return a String representation of a Address object. + */ public String toString() { - return this.getClass().getName() + ": " + addrid; + return "Address(" + getFieldRepr() + ")"; } - - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.addrid != o.addrid) return (false); - return (true); + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(addrid); + rc.append(", street ").append(street); + rc.append(", city ").append(city); + rc.append(", state ").append(state); + rc.append(", zipcode ").append(zipcode); + rc.append(", country ").append(country); + return rc.toString(); } - /** */ +// /** +// * Returns true if all the fields of this instance are +// * deep equal to the coresponding fields of the specified Person. +// * @param other the object with which to compare. +// * @param helper EqualityHelper to keep track of instances that have +// * already been processed. +// * @return true if all the fields are deep equal; +// * false otherwise. +// * @throws ClassCastException if the specified instances' type prevents +// * it from being compared to this instance. +// */ +// public boolean deepCompareFields(Object other, +// EqualityHelper helper) { +// IAddress otherAddress = (IAddress)other; +// String where = "Address<" + addrid + ">"; +// return +// helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") & +// helper.equals(street, otherAddress.getStreet(), where + ".street") & +// helper.equals(city, otherAddress.getCity(), where + ".city") & +// helper.equals(state, otherAddress.getState(), where + ".state") & +// helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") & +// helper.equals(country, otherAddress.getCountry(), where + ".country"); +// } +// +// /** +// * Compares this object with the specified object for order. Returns a +// * negative integer, zero, or a positive integer as this object is less +// * than, equal to, or greater than the specified object. +// * @param o The Object to be compared. +// * @return a negative integer, zero, or a positive integer as this +// * object is less than, equal to, or greater than the specified object. +// * @throws ClassCastException - if the specified object's type prevents +// * it from being compared to this Object. +// */ +// public int compareTo(Object o) { +// return compareTo((IAddress)o); +// } +// +// /** +// * Compare two instances. This is a method in Comparator. +// */ +// public int compare(Object o1, Object o2) { +// return compare((IAddress)o1, (IAddress)o2); +// } +// +// /** +// * Compares this object with the specified Address object for +// * order. Returns a negative integer, zero, or a positive integer as +// * this object is less than, equal to, or greater than the specified +// * object. +// * @param other The Address object to be compared. +// * @return a negative integer, zero, or a positive integer as this +// * object is less than, equal to, or greater than the specified Address +// * object. +// */ +// public int compareTo(IAddress other) { +// return compare(this, other); +// } +// +// /** +// * Compares its two IAddress arguments for order. Returns a negative +// * integer, zero, or a positive integer as the first argument is less +// * than, equal to, or greater than the second. +// * @param o1 the first IAddress object to be compared. +// * @param o2 the second IAddress object to be compared. +// * @return a negative integer, zero, or a positive integer as the first +// * object is less than, equal to, or greater than the second object. +// */ +// public static int compare(IAddress o1, IAddress o2) { +// return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); +// } +// +// /** +// * Indicates whether some other object is "equal to" this one. +// * @param obj the object with which to compare. +// * @return true if this object is the same as the obj +// * argument; false otherwise. +// */ +// public boolean equals(Object obj) { +// if (obj instanceof IAddress) { +// return compareTo((IAddress)obj) == 0; +// } +// return false; +// } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ public int hashCode() { - return ((int) addrid); + return (int)addrid; } + + /** + * This class is used to represent the application identifier + * for the Address class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This is the identifier field for Address and must + * correspond in type and name to the field in + * Address. + */ + public long addrid; + + /** The required public, no-arg constructor. */ + public Oid() + { + addrid = 0; + } + + /** + * A constructor to initialize the identifier field. + * @param addrid the id of the Address. + */ + public Oid(long addrid) { + this.addrid = addrid; + } + + public Oid(String s) { addrid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + addrid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.addrid != o.addrid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) addrid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( addrid < other.addrid ) return -1; + if( addrid > other.addrid ) return 1; + return 0; + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (addrid < other.addrid) return -1; - if (addrid > other.addrid) return 1; - return 0; - } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/Address_bad.java b/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/Address_bad.java index 014551fe5..79e11dbcd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/Address_bad.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/Address_bad.java @@ -5,343 +5,336 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.newInstance; import java.io.Serializable; -/** This class represents a postal address. */ -public class Address_bad implements IAddress { - - private long addrid; - private String street; - private String city; - private String state; - private String zipcode; - private String country; - - // Expect JDOUserException on pm.newInstance(this) - // with non-public constructor - private Address_bad() {} - - /** - * This constructor initializes the Address components. - * - * @param addrid The address ID. - * @param street The street address. - * @param city The city. - * @param state The state. - * @param zipcode The zip code. - * @param country The zip country. - */ - public Address_bad( - long addrid, String street, String city, String state, String zipcode, String country) { - this.addrid = addrid; - this.street = street; - this.city = city; - this.state = state; - this.zipcode = zipcode; - this.country = country; - } - - public String getAString() { - return "A String"; - } - - /** - * Get the addrid associated with this object. - * - * @return the addrid. - */ - public long getAddrid() { - return addrid; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setAddrid(long id) { - if (this.addrid != 0) throw new IllegalStateException("Id is already set."); - this.addrid = id; - } - /** - * Get the street component of the address. - * - * @return The street component of the address. - */ - public String getStreet() { - return street; - } - - /** - * Set the street component of the address. - * - * @param street The street component. - */ - public void setStreet(String street) { - this.street = street; - } - - /** - * Get the city. - * - * @return The city component of the address. - */ - public String getCity() { - return city; - } - - /** - * Set the city component of the address. - * - * @param city The city. - */ - public void setCity(String city) { - this.city = city; - } +/** + * This class represents a postal address. + */ +public class Address_bad + implements IAddress +{ - /** - * Get the state component of the address. - * - * @return The state. - */ - public String getState() { - return state; - } + private long addrid; + private String street; + private String city; + private String state; + private String zipcode; + private String country; - /** - * Set the state component of the address. - * - * @param state The state. - */ - public void setState(String state) { - this.state = state; - } + // Expect JDOUserException on pm.newInstance(this) + // with non-public constructor + private Address_bad() {} - /** - * Get the zipcode component of the address. - * - * @return The zipcode. - */ - public String getZipcode() { - return zipcode; - } + /** + * This constructor initializes the Address components. + * @param addrid The address ID. + * @param street The street address. + * @param city The city. + * @param state The state. + * @param zipcode The zip code. + * @param country The zip country. + */ + public Address_bad(long addrid, String street, String city, + String state, String zipcode, String country) + { + this.addrid = addrid; + this.street = street; + this.city = city; + this.state = state; + this.zipcode = zipcode; + this.country = country; + } - /** - * Set the zip code component of the address. - * - * @param zipcode The zipcode. - */ - public void setZipcode(String zipcode) { - this.zipcode = zipcode; - } + public String getAString() { + return "A String"; + } - /** - * Get the country component of the address. - * - * @return The country. - */ - public String getCountry() { - return country; - } + /** + * Get the addrid associated with this object. + * @return the addrid. + */ + public long getAddrid() { + return addrid; + } - /** - * Set the country component of the address. - * - * @param country The country. - */ - public void setCountry(String country) { - this.country = country; - } + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setAddrid(long id) { + if (this.addrid != 0) + throw new IllegalStateException("Id is already set."); + this.addrid = id; + } - /** - * Returns a String representation of a Address object. - * - * @return a String representation of a Address object. - */ - public String toString() { - return "Address(" + getFieldRepr() + ")"; - } + /** + * Get the street component of the address. + * @return The street component of the address. + */ + public String getStreet() { + return street; + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(addrid); - rc.append(", street ").append(street); - rc.append(", city ").append(city); - rc.append(", state ").append(state); - rc.append(", zipcode ").append(zipcode); - rc.append(", country ").append(country); - return rc.toString(); - } + /** + * Set the street component of the address. + * @param street The street component. + */ + public void setStreet(String street) { + this.street = street; + } - // /** - // * Returns true if all the fields of this instance are - // * deep equal to the coresponding fields of the specified Person. - // * @param other the object with which to compare. - // * @param helper EqualityHelper to keep track of instances that have - // * already been processed. - // * @return true if all the fields are deep equal; - // * false otherwise. - // * @throws ClassCastException if the specified instances' type prevents - // * it from being compared to this instance. - // */ - // public boolean deepCompareFields(Object other, - // EqualityHelper helper) { - // IAddress otherAddress = (IAddress)other; - // String where = "Address<" + addrid + ">"; - // return - // helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") & - // helper.equals(street, otherAddress.getStreet(), where + ".street") & - // helper.equals(city, otherAddress.getCity(), where + ".city") & - // helper.equals(state, otherAddress.getState(), where + ".state") & - // helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") & - // helper.equals(country, otherAddress.getCountry(), where + ".country"); - // } - // - // /** - // * Compares this object with the specified object for order. Returns a - // * negative integer, zero, or a positive integer as this object is less - // * than, equal to, or greater than the specified object. - // * @param o The Object to be compared. - // * @return a negative integer, zero, or a positive integer as this - // * object is less than, equal to, or greater than the specified object. - // * @throws ClassCastException - if the specified object's type prevents - // * it from being compared to this Object. - // */ - // public int compareTo(Object o) { - // return compareTo((IAddress)o); - // } - // - // /** - // * Compare two instances. This is a method in Comparator. - // */ - // public int compare(Object o1, Object o2) { - // return compare((IAddress)o1, (IAddress)o2); - // } - // - // /** - // * Compares this object with the specified Address object for - // * order. Returns a negative integer, zero, or a positive integer as - // * this object is less than, equal to, or greater than the specified - // * object. - // * @param other The Address object to be compared. - // * @return a negative integer, zero, or a positive integer as this - // * object is less than, equal to, or greater than the specified Address - // * object. - // */ - // public int compareTo(IAddress other) { - // return compare(this, other); - // } - // - // /** - // * Compares its two IAddress arguments for order. Returns a negative - // * integer, zero, or a positive integer as the first argument is less - // * than, equal to, or greater than the second. - // * @param o1 the first IAddress object to be compared. - // * @param o2 the second IAddress object to be compared. - // * @return a negative integer, zero, or a positive integer as the first - // * object is less than, equal to, or greater than the second object. - // */ - // public static int compare(IAddress o1, IAddress o2) { - // return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); - // } - // - // /** - // * Indicates whether some other object is "equal to" this one. - // * @param obj the object with which to compare. - // * @return true if this object is the same as the obj - // * argument; false otherwise. - // */ - // public boolean equals(Object obj) { - // if (obj instanceof IAddress) { - // return compareTo((IAddress)obj) == 0; - // } - // return false; - // } + /** + * Get the city. + * @return The city component of the address. + */ + public String getCity() { + return city; + } - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) addrid; - } + /** + * Set the city component of the address. + * @param city The city. + */ + public void setCity(String city) { + this.city = city; + } + + /** + * Get the state component of the address. + * @return The state. + */ + public String getState() { + return state; + } - /** - * This class is used to represent the application identifier for the Address class. - */ - public static class Oid implements Serializable, Comparable { + /** + * Set the state component of the address. + * @param state The state. + */ + public void setState(String state) { + this.state = state; + } /** - * This is the identifier field for Address and must correspond in type and name to - * the field in Address. + * Get the zipcode component of the address. + * @return The zipcode. */ - public long addrid; + public String getZipcode() { + return zipcode; + } - /** The required public, no-arg constructor. */ - public Oid() { - addrid = 0; + /** + * Set the zip code component of the address. + * @param zipcode The zipcode. + */ + public void setZipcode(String zipcode) { + this.zipcode = zipcode; } /** - * A constructor to initialize the identifier field. - * - * @param addrid the id of the Address. + * Get the country component of the address. + * @return The country. */ - public Oid(long addrid) { - this.addrid = addrid; + public String getCountry() { + return country; } - public Oid(String s) { - addrid = Long.parseLong(justTheId(s)); + /** + * Set the country component of the address. + * @param country The country. + */ + public void setCountry(String country) { + this.country = country; } + /** + * Returns a String representation of a Address object. + * @return a String representation of a Address object. + */ public String toString() { - return this.getClass().getName() + ": " + addrid; + return "Address(" + getFieldRepr() + ")"; } - - /** */ - public boolean equals(java.lang.Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return (false); - Oid o = (Oid) obj; - if (this.addrid != o.addrid) return (false); - return (true); + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(addrid); + rc.append(", street ").append(street); + rc.append(", city ").append(city); + rc.append(", state ").append(state); + rc.append(", zipcode ").append(zipcode); + rc.append(", country ").append(country); + return rc.toString(); } - /** */ +// /** +// * Returns true if all the fields of this instance are +// * deep equal to the coresponding fields of the specified Person. +// * @param other the object with which to compare. +// * @param helper EqualityHelper to keep track of instances that have +// * already been processed. +// * @return true if all the fields are deep equal; +// * false otherwise. +// * @throws ClassCastException if the specified instances' type prevents +// * it from being compared to this instance. +// */ +// public boolean deepCompareFields(Object other, +// EqualityHelper helper) { +// IAddress otherAddress = (IAddress)other; +// String where = "Address<" + addrid + ">"; +// return +// helper.equals(addrid, otherAddress.getAddrid(), where + ".addrid") & +// helper.equals(street, otherAddress.getStreet(), where + ".street") & +// helper.equals(city, otherAddress.getCity(), where + ".city") & +// helper.equals(state, otherAddress.getState(), where + ".state") & +// helper.equals(zipcode, otherAddress.getZipcode(), where + ".zipcode") & +// helper.equals(country, otherAddress.getCountry(), where + ".country"); +// } +// +// /** +// * Compares this object with the specified object for order. Returns a +// * negative integer, zero, or a positive integer as this object is less +// * than, equal to, or greater than the specified object. +// * @param o The Object to be compared. +// * @return a negative integer, zero, or a positive integer as this +// * object is less than, equal to, or greater than the specified object. +// * @throws ClassCastException - if the specified object's type prevents +// * it from being compared to this Object. +// */ +// public int compareTo(Object o) { +// return compareTo((IAddress)o); +// } +// +// /** +// * Compare two instances. This is a method in Comparator. +// */ +// public int compare(Object o1, Object o2) { +// return compare((IAddress)o1, (IAddress)o2); +// } +// +// /** +// * Compares this object with the specified Address object for +// * order. Returns a negative integer, zero, or a positive integer as +// * this object is less than, equal to, or greater than the specified +// * object. +// * @param other The Address object to be compared. +// * @return a negative integer, zero, or a positive integer as this +// * object is less than, equal to, or greater than the specified Address +// * object. +// */ +// public int compareTo(IAddress other) { +// return compare(this, other); +// } +// +// /** +// * Compares its two IAddress arguments for order. Returns a negative +// * integer, zero, or a positive integer as the first argument is less +// * than, equal to, or greater than the second. +// * @param o1 the first IAddress object to be compared. +// * @param o2 the second IAddress object to be compared. +// * @return a negative integer, zero, or a positive integer as the first +// * object is less than, equal to, or greater than the second object. +// */ +// public static int compare(IAddress o1, IAddress o2) { +// return EqualityHelper.compare(o1.getAddrid(), o2.getAddrid()); +// } +// +// /** +// * Indicates whether some other object is "equal to" this one. +// * @param obj the object with which to compare. +// * @return true if this object is the same as the obj +// * argument; false otherwise. +// */ +// public boolean equals(Object obj) { +// if (obj instanceof IAddress) { +// return compareTo((IAddress)obj) == 0; +// } +// return false; +// } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ public int hashCode() { - return ((int) addrid); + return (int)addrid; } + + /** + * This class is used to represent the application identifier + * for the Address class. + */ + public static class Oid implements Serializable, Comparable { + + /** + * This is the identifier field for Address and must + * correspond in type and name to the field in + * Address. + */ + public long addrid; + + /** The required public, no-arg constructor. */ + public Oid() + { + addrid = 0; + } + + /** + * A constructor to initialize the identifier field. + * @param addrid the id of the Address. + */ + public Oid(long addrid) { + this.addrid = addrid; + } + + public Oid(String s) { addrid = Long.parseLong(justTheId(s)); } + + public String toString() { return this.getClass().getName() + ": " + addrid;} + + + /** */ + public boolean equals(java.lang.Object obj) { + if( obj==null || !this.getClass().equals(obj.getClass()) ) + return( false ); + Oid o = (Oid) obj; + if( this.addrid != o.addrid ) return( false ); + return( true ); + } + + /** */ + public int hashCode() { + return( (int) addrid ); + } + + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + Oid other = (Oid) obj; + if( addrid < other.addrid ) return -1; + if( addrid > other.addrid ) return 1; + return 0; + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - Oid other = (Oid) obj; - if (addrid < other.addrid) return -1; - if (addrid > other.addrid) return 1; - return 0; - } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/IAddress.java b/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/IAddress.java index 83c1089e2..ccd2ea92c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/IAddress.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/IAddress.java @@ -5,45 +5,36 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.newInstance; /** - * This interface represents the persistent state of Address. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Address. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IAddress { - long getAddrid(); - - String getStreet(); - - String getCity(); - - String getState(); - - String getZipcode(); - - String getCountry(); - - void setAddrid(long addrid); - - void setStreet(String street); - - void setCity(String city); - - void setState(String state); - - void setZipcode(String zipcode); - - void setCountry(String country); + long getAddrid(); + String getStreet(); + String getCity(); + String getState(); + String getZipcode(); + String getCountry(); + + void setAddrid(long addrid); + void setStreet(String street); + void setCity(String city); + void setState(String state); + void setZipcode(String zipcode); + void setCountry(String country); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/IAddress_bad.java b/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/IAddress_bad.java index 3d90db6bf..5e55cb9ed 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/IAddress_bad.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/newInstance/IAddress_bad.java @@ -5,49 +5,40 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.newInstance; /** - * This interface represents the persistent state of Address. Javadoc was deliberately omitted - * because it would distract from the purpose of the interface. + * This interface represents the persistent state of Address. + * Javadoc was deliberately omitted because it would distract from + * the purpose of the interface. */ public interface IAddress_bad { - long getAddrid(); - - String getStreet(); - - String getCity(); - - String getState(); - - String getZipcode(); - - String getCountry(); - - // Lacks setter, so not a persistent property - // Expect JDOUserException on pm.newInstance(this) - String getAString(); - - void setAddrid(long addrid); - - void setStreet(String street); - - void setCity(String city); - - void setState(String state); - - void setZipcode(String zipcode); - - void setCountry(String country); + long getAddrid(); + String getStreet(); + String getCity(); + String getState(); + String getZipcode(); + String getCountry(); + + // Lacks setter, so not a persistent property + // Expect JDOUserException on pm.newInstance(this) + String getAString(); + + void setAddrid(long addrid); + void setStreet(String street); + void setCity(String city); + void setState(String state); + void setZipcode(String zipcode); + void setCountry(String country); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/order/Order.java b/tck/src/main/java/org/apache/jdo/tck/pc/order/Order.java index ced827937..63f313015 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/order/Order.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/order/Order.java @@ -5,187 +5,199 @@ * 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 + * + * 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.jdo.tck.pc.order; import java.io.Serializable; import java.util.Comparator; import java.util.Set; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; public class Order implements Serializable, Comparable, Comparator, DeepEquality { - long orderId; - Set items; - long customerId; - - public Order() {} - - public Order(long orderId, long customerId) { - this.orderId = orderId; - this.customerId = customerId; - } - - public Order(long orderId, Set items, long customerId) { - this.orderId = orderId; - this.items = items; - this.customerId = customerId; - } - - public long getOrderId() { - return orderId; - } - - public void setOrderId(long orderId) { - this.orderId = orderId; - } - - public Set getItems() { - return items; - } - - public void setItems(Set items) { - this.items = items; - } - - public long getCustomerId() { - return customerId; - } - - public void setCustomerId(long customerId) { - this.customerId = customerId; - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - Order otherOrder = (Order) other; - String where = "Order<" + orderId + ">"; - return helper.equals(orderId, otherOrder.getOrderId(), where + ".order") - & helper.equals(items, otherOrder.getItems(), where + ".items") - & helper.equals(customerId, otherOrder.getCustomerId(), where + ".customerId"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((Order) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((Order) o1, (Order) o2); - } - - /** - * Compares this object with the specified Company object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Company object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Company object. - */ - public int compareTo(Order other) { - return compare(this, other); - } - - /** - * Compares its two Order arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first Order object to be compared. - * @param o2 the second Order object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(Order o1, Order o2) { - return EqualityHelper.compare(o1.getOrderId(), o2.getOrderId()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof Order) { - return compareTo((Order) obj) == 0; - } - return false; - } + long orderId; + Set items; + long customerId; - /** - * The class to be used as the application identifier for the Order class. It - * consists of both the orderId field. - */ - public static class OrderOid implements Serializable, Comparable { - public long orderId; + public Order() {} - /** The required public no-arg constructor. */ - public OrderOid() {} + public Order(long orderId, long customerId) { + this.orderId = orderId; + this.customerId = customerId; + } - public OrderOid(String s) { - orderId = Long.parseLong(justTheOrder(s)); + public Order(long orderId, Set items, long customerId) { + this.orderId = orderId; + this.items = items; + this.customerId = customerId; } - public String toString() { - return this.getClass().getName() + "order:" + String.valueOf(orderId); + public long getOrderId() { + return orderId; + } + + public void setOrderId(long orderId) { + this.orderId = orderId; + } + + public Set getItems() { + return items; + } + + public void setItems(Set items) { + this.items = items; } - /** */ - public boolean equals(Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return false; - OrderOid o = (OrderOid) obj; - if (this.orderId != o.orderId) { - return false; - } - return true; + public long getCustomerId() { + return customerId; + } + + public void setCustomerId(long customerId) { + this.customerId = customerId; + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + Order otherOrder = (Order)other; + String where = "Order<" + orderId + ">"; + return + helper.equals(orderId, otherOrder.getOrderId(), where + ".order") & + helper.equals(items, otherOrder.getItems(), where + ".items") & + helper.equals(customerId, otherOrder.getCustomerId(), + where + ".customerId"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((Order)o); } - /** */ - public int hashCode() { - return (int) orderId; + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((Order)o1, (Order)o2); } - protected static String justTheOrder(String str) { - return str.substring(str.indexOf(':') + 1); + /** + * Compares this object with the specified Company object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Company object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Company + * object. + */ + public int compareTo(Order other) { + return compare(this, other); } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - OrderOid other = (OrderOid) obj; - if (orderId < other.orderId) return -1; - if (orderId > other.orderId) return 1; - return 0; + /** + * Compares its two Order arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first Order object to be compared. + * @param o2 the second Order object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(Order o1, Order o2) { + return EqualityHelper.compare(o1.getOrderId(), o2.getOrderId()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof Order) { + return compareTo((Order)obj) == 0; + } + return false; + } + + /** + * The class to be used as the application identifier + * for the Order class. It consists of both the orderId + * field. + */ + public static class OrderOid implements Serializable, Comparable { + public long orderId; + + /** The required public no-arg constructor. */ + public OrderOid() { } + + public OrderOid(String s) { + orderId = Long.parseLong(justTheOrder(s)); + } + + public String toString() { + return this.getClass().getName() + "order:" + + String.valueOf(orderId); + } + + /** */ + public boolean equals(Object obj) { + if (obj == null || !this.getClass().equals(obj.getClass())) + return false; + OrderOid o = (OrderOid) obj; + if (this.orderId != o.orderId) { + return false; + } + return true; + } + + /** */ + public int hashCode() { + return (int)orderId; + } + + protected static String justTheOrder(String str) { + return str.substring(str.indexOf(':') + 1); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + OrderOid other = (OrderOid) obj; + if( orderId < other.orderId ) return -1; + if( orderId > other.orderId ) return 1; + return 0; + } + } - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactory.java b/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactory.java index 6e16c8f5c..bbb9c0163 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactory.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactory.java @@ -5,16 +5,16 @@ * 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 + * + * 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. */ - + /* * OrderFactory.java * @@ -22,18 +22,21 @@ package org.apache.jdo.tck.pc.order; +import java.math.BigDecimal; + +import java.util.Date; import java.util.Set; /** - * This interface is implemented by a factory class that can create Order model instances. The - * factory instance is registered with OrderFactoryRegistry. + * This interface is implemented by a factory class that can create + * Order model instances. The factory instance is registered with + * OrderFactoryRegistry. */ public interface OrderFactory { - Order newOrder(long orderId, Set items, long customerId); - - Order newOrder(long orderId, long customerId); - - OrderItem newOrderItem(Order order, long item, String description, int quantity); + Order newOrder(long orderId, Set items, long customerId); + Order newOrder(long orderId, long customerId); + OrderItem newOrderItem(Order order, long item, String description, + int quantity); - Class[] getTearDownClasses(); + Class[] getTearDownClasses(); } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactoryAbstractImpl.java b/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactoryAbstractImpl.java index b429e0cf2..99a362d4f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactoryAbstractImpl.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactoryAbstractImpl.java @@ -17,8 +17,10 @@ package org.apache.jdo.tck.pc.order; -import java.util.Set; import javax.jdo.PersistenceManager; + +import java.util.Set; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -29,52 +31,52 @@ * classes that implement only the methods to construct the instance. */ public abstract class OrderFactoryAbstractImpl implements OrderFactory { + + protected PersistenceManager pm; + + /** Logger */ + protected Log logger = + LogFactory.getFactory().getInstance("org.apache.jdo.tck"); - protected PersistenceManager pm; - - /** Logger */ - protected Log logger = LogFactory.getFactory().getInstance("org.apache.jdo.tck"); - - /** true if debug logging is enabled. */ - protected boolean debug = logger.isDebugEnabled(); - - /** - * Creates a new instance of OrderFactoryAbstractImpl - * - * @param pm the PersistnceManager - */ - public OrderFactoryAbstractImpl(PersistenceManager pm) { - this.pm = pm; - } - - abstract Order newOrder(); + /** true if debug logging is enabled. */ + protected boolean debug = logger.isDebugEnabled(); + + /** + * Creates a new instance of OrderFactoryAbstractImpl + * @param pm the PersistnceManager + */ + public OrderFactoryAbstractImpl(PersistenceManager pm) { + this.pm = pm; + } - abstract OrderItem newOrderItem(); + abstract Order newOrder(); + abstract OrderItem newOrderItem(); - public Order newOrder(long orderId, long customerId) { - Order result = newOrder(); - result.setOrderId(orderId); - result.setCustomerId(customerId); - if (debug) logger.debug("newOrder returned" + result); - return result; - } + public Order newOrder(long orderId, long customerId) { + Order result = newOrder(); + result.setOrderId(orderId); + result.setCustomerId(customerId); + if (debug) logger.debug("newOrder returned" + result); + return result; + } - public Order newOrder(long orderId, Set items, long customerId) { - Order result = newOrder(); - result.setOrderId(orderId); - result.setItems(items); - result.setCustomerId(customerId); - if (debug) logger.debug("newOrder returned" + result); - return result; - } + public Order newOrder(long orderId, Set items, long customerId) { + Order result = newOrder(); + result.setOrderId(orderId); + result.setItems(items); + result.setCustomerId(customerId); + if (debug) logger.debug("newOrder returned" + result); + return result; + } - public OrderItem newOrderItem(Order order, long item, String description, int quantity) { - OrderItem result = newOrderItem(); - result.setOrder(order); - result.setItem(item); - result.setDescription(description); - result.setQuantity(quantity); - if (debug) logger.debug("newOrderItem returned" + result); - return result; - } + public OrderItem newOrderItem(Order order, long item, String description, + int quantity) { + OrderItem result = newOrderItem(); + result.setOrder(order); + result.setItem(item); + result.setDescription(description); + result.setQuantity(quantity); + if (debug) logger.debug("newOrderItem returned" + result); + return result; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactoryConcreteClass.java b/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactoryConcreteClass.java index bb2156a90..174200f34 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactoryConcreteClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactoryConcreteClass.java @@ -18,39 +18,44 @@ package org.apache.jdo.tck.pc.order; import java.util.Set; + import javax.jdo.PersistenceManager; /* * This class is the order factory that uses constructors of the * concrete classes. */ -public class OrderFactoryConcreteClass implements OrderFactory { - - /** */ - public static final Class[] tearDownClasses = new Class[] {Order.class, OrderItem.class}; - - /** - * Creates a new instance of OrderFactoryConcreteClass - * - * @param pm the PersistnceManager - */ - public OrderFactoryConcreteClass(PersistenceManager pm) {} - - public OrderFactoryConcreteClass() {} - - public Order newOrder(long orderId, long customerId) { - return new Order(orderId, customerId); - } - - public Order newOrder(long orderId, Set items, long customerId) { - return new Order(orderId, items, customerId); - } - - public OrderItem newOrderItem(Order order, long item, String description, int quantity) { - return new OrderItem(order, item, description, quantity); - } - - public Class[] getTearDownClasses() { - return tearDownClasses; - } +public class OrderFactoryConcreteClass implements OrderFactory { + + /** */ + public static final Class[] tearDownClasses = new Class[] { + Order.class, OrderItem.class + }; + + /** + * Creates a new instance of OrderFactoryConcreteClass + * @param pm the PersistnceManager + */ + public OrderFactoryConcreteClass(PersistenceManager pm) { + } + + public OrderFactoryConcreteClass() { + } + + public Order newOrder(long orderId, long customerId) { + return new Order(orderId, customerId); + } + + public Order newOrder(long orderId, Set items, long customerId) { + return new Order(orderId, items, customerId); + } + + public OrderItem newOrderItem(Order order, long item, String description, + int quantity) { + return new OrderItem(order, item, description, quantity); + } + + public Class[] getTearDownClasses() { + return tearDownClasses; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactoryPMClass.java b/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactoryPMClass.java index ba5b1e364..ce1cb0b8a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactoryPMClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactoryPMClass.java @@ -23,31 +23,33 @@ * OrderFactoryPMClass.java * * This class uses the PersistenceManager.newInstance method with the concrete - * class as a parameter. + * class as a parameter. */ -public class OrderFactoryPMClass extends OrderFactoryAbstractImpl { - - /** */ - public static final Class[] tearDownClasses = new Class[] {Order.class, OrderItem.class}; - - /** - * Creates a new instance of OrderFactoryPMClass - * - * @param pm the PersistnceManager - */ - public OrderFactoryPMClass(PersistenceManager pm) { - super(pm); - } - - public Order newOrder() { - return (Order) pm.newInstance(Order.class); - } - - public OrderItem newOrderItem() { - return (OrderItem) pm.newInstance(OrderItem.class); - } - - public Class[] getTearDownClasses() { - return tearDownClasses; - } +public class OrderFactoryPMClass + extends OrderFactoryAbstractImpl { + + /** */ + public static final Class[] tearDownClasses = new Class[] { + Order.class, OrderItem.class + }; + + /** + * Creates a new instance of OrderFactoryPMClass + * @param pm the PersistnceManager + */ + public OrderFactoryPMClass(PersistenceManager pm) { + super(pm); + } + + public Order newOrder() { + return (Order)pm.newInstance(Order.class); + } + + public OrderItem newOrderItem() { + return (OrderItem)pm.newInstance(OrderItem.class); + } + + public Class[] getTearDownClasses() { + return tearDownClasses; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactoryPMInterface.java b/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactoryPMInterface.java index 9e76edfbc..1c65fcb43 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactoryPMInterface.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactoryPMInterface.java @@ -23,29 +23,31 @@ * OrderFactoryPMInterface.java * */ -public class OrderFactoryPMInterface extends OrderFactoryAbstractImpl { - - /** */ - public static final Class[] tearDownClasses = new Class[] {Order.class, OrderItem.class}; - - /** - * Creates a new instance of OrderFactoryPMInterface - * - * @param pm the PersistnceManager - */ - public OrderFactoryPMInterface(PersistenceManager pm) { - super(pm); - } - - Order newOrder() { - return (Order) pm.newInstance(Order.class); - } - - OrderItem newOrderItem() { - return (OrderItem) pm.newInstance(OrderItem.class); - } - - public Class[] getTearDownClasses() { - return tearDownClasses; - } +public class OrderFactoryPMInterface + extends OrderFactoryAbstractImpl { + + /** */ + public static final Class[] tearDownClasses = new Class[] { + Order.class, OrderItem.class + }; + + /** + * Creates a new instance of OrderFactoryPMInterface + * @param pm the PersistnceManager + */ + public OrderFactoryPMInterface(PersistenceManager pm) { + super(pm); + } + + Order newOrder() { + return (Order)pm.newInstance(Order.class); + } + + OrderItem newOrderItem() { + return (OrderItem)pm.newInstance(OrderItem.class); + } + + public Class[] getTearDownClasses() { + return tearDownClasses; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactoryRegistry.java b/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactoryRegistry.java index 5c441bdcc..53a110fa0 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactoryRegistry.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderFactoryRegistry.java @@ -5,25 +5,26 @@ * 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 + * + * 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.jdo.tck.pc.order; import java.lang.reflect.Constructor; + import javax.jdo.PersistenceManager; /* * This is the registry for order factories. It is used for the * CompletenessTest to create instances from input xml test data files. - * Factory instances that implement OrderFactory interface are + * Factory instances that implement OrderFactory interface are * registered (using the singleton pattern). *

    Several registration methods are available. The default factory, * which creates instances by construction, is automatically @@ -37,91 +38,101 @@ */ public class OrderFactoryRegistry { - /** - * The system property for factory name - * - *

    NOTE: SHOULD BE RENAMED!! - */ - static final String FACTORY_PROPERTY_NAME = "jdo.tck.mapping.companyfactory"; - - /** The factory name if the system property is not set. */ - static final String DEFAULT_FACTORY_CLASS_NAME = - "org.apache.jdo.tck.pc.order.OrderFactoryConcreteClass"; + /** The system property for factory name + * + * NOTE: SHOULD BE RENAMED!! + */ + final static String FACTORY_PROPERTY_NAME = + "jdo.tck.mapping.companyfactory"; - /** The default factory class name */ - static final String FACTORY_CLASS_NAME; + /** The factory name if the system property is not set. + */ + final static String DEFAULT_FACTORY_CLASS_NAME = + "org.apache.jdo.tck.pc.order.OrderFactoryConcreteClass"; - static { - String prop = System.getProperty(FACTORY_PROPERTY_NAME); - if ((prop == null) || (prop.length() == 0)) prop = DEFAULT_FACTORY_CLASS_NAME; - FACTORY_CLASS_NAME = prop; - } + /** + * The default factory class name + */ + final static String FACTORY_CLASS_NAME; - /** - * This is the default order factory singleton. This is statically loaded regardless of the - * setting of the system property. - */ - static final OrderFactory SINGLETON = new OrderFactoryConcreteClass(); + static { + String prop = System.getProperty(FACTORY_PROPERTY_NAME); + if ((prop == null) || (prop.length() == 0)) + prop = DEFAULT_FACTORY_CLASS_NAME; + FACTORY_CLASS_NAME = prop; + } - /** This is the currently registered factory. */ - static OrderFactory instance = SINGLETON; + /** + * This is the default order factory singleton. This is statically + * loaded regardless of the setting of the system property. + */ + final static OrderFactory SINGLETON = new OrderFactoryConcreteClass(); + + /** + * This is the currently registered factory. + */ + static OrderFactory instance = SINGLETON; + + /** + * Creates a new instance of OrderFactoryRegistry + */ + private OrderFactoryRegistry() { + } - /** Creates a new instance of OrderFactoryRegistry */ - private OrderFactoryRegistry() {} + /** + * Get the currently registered factory. + * @return the factory + */ + public static OrderFactory getInstance() { + return instance; + } - /** - * Get the currently registered factory. - * - * @return the factory - */ - public static OrderFactory getInstance() { - return instance; - } + /** Register the default factory. + */ + public static void registerFactory() { + instance = SINGLETON; + } - /** Register the default factory. */ - public static void registerFactory() { - instance = SINGLETON; - } + /** Register a factory using the default factory name from the + * system property. The factory must be available in the current + * class path and have a public constructor + * taking a PersistenceManager as a parameter. + * @param pm the PersistenceManager + */ + public static void registerFactory(PersistenceManager pm) { + registerFactory(FACTORY_CLASS_NAME, pm); + } - /** - * Register a factory using the default factory name from the system property. The factory must be - * available in the current class path and have a public constructor taking a PersistenceManager - * as a parameter. - * - * @param pm the PersistenceManager - */ - public static void registerFactory(PersistenceManager pm) { - registerFactory(FACTORY_CLASS_NAME, pm); - } + /** Register a factory using the specified factoryName + * parameter. The factory class must be loadable by the current context + * classloader and have a public constructor + * taking a PersistenceManager as a parameter. + * @param factoryClassName the fully-qualified class name of the factory + * @param pm the PersistenceManager + */ + public static void registerFactory(String factoryClassName, + PersistenceManager pm) { + OrderFactory factory = null; + try { + if (factoryClassName != null) { + Class factoryClass = Class.forName(factoryClassName); + Constructor ctor = factoryClass.getConstructor(new Class[] + {PersistenceManager.class}); + factory = (OrderFactory) + ctor.newInstance(new Object[]{pm}); + } + registerFactory(factory); + } catch (Exception ex) { + throw new RuntimeException ("Unable to construct OrderFactory " + + factoryClassName, ex); + } + } - /** - * Register a factory using the specified factoryName parameter. The factory class must be - * loadable by the current context classloader and have a public constructor taking a - * PersistenceManager as a parameter. - * - * @param factoryClassName the fully-qualified class name of the factory - * @param pm the PersistenceManager - */ - public static void registerFactory(String factoryClassName, PersistenceManager pm) { - OrderFactory factory = null; - try { - if (factoryClassName != null) { - Class factoryClass = Class.forName(factoryClassName); - Constructor ctor = factoryClass.getConstructor(new Class[] {PersistenceManager.class}); - factory = (OrderFactory) ctor.newInstance(new Object[] {pm}); - } - registerFactory(factory); - } catch (Exception ex) { - throw new RuntimeException("Unable to construct OrderFactory " + factoryClassName, ex); + /** Register the factory. + * @param factory the factory + */ + public static void registerFactory(OrderFactory factory) { + instance = factory!=null?factory:SINGLETON; } - } - /** - * Register the factory. - * - * @param factory the factory - */ - public static void registerFactory(OrderFactory factory) { - instance = factory != null ? factory : SINGLETON; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderItem.java b/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderItem.java index 73d46622f..943a06694 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderItem.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderItem.java @@ -5,213 +5,224 @@ * 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 + * + * 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.jdo.tck.pc.order; import java.io.Serializable; import java.util.Comparator; + import org.apache.jdo.tck.util.DeepEquality; import org.apache.jdo.tck.util.EqualityHelper; public class OrderItem implements Serializable, Comparable, Comparator, DeepEquality { - Order order; - long item; - String description; - int quantity; - - public OrderItem() {} - - public OrderItem(Order order, long item, String description, int quantity) { - this.order = order; - this.item = item; - this.description = description; - this.quantity = quantity; - } - - public Order getOrder() { - return order; - } - - public void setOrder(Order order) { - this.order = order; - } - - public long getItem() { - return item; - } - - public void setItem(long item) { - this.item = item; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public int getQuantity() { - return quantity; - } - - public void setQuantity(int quantity) { - this.quantity = quantity; - } - - /** - * Returns true if all the fields of this instance are deep equal to the coresponding - * fields of the specified Person. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper) { - OrderItem otherOrderItem = (OrderItem) other; - String where = "OrderItem<" + order.getOrderId() + "," + item + ">"; - return helper.equals(order, otherOrderItem.getOrder(), where + ".order") - & helper.equals(item, otherOrderItem.getItem(), where + ".item"); - } - - /** - * Compares this object with the specified object for order. Returns a negative integer, zero, or - * a positive integer as this object is less than, equal to, or greater than the specified object. - * - * @param o The Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified object. - * @throws ClassCastException - if the specified object's type prevents it from being compared to - * this Object. - */ - public int compareTo(Object o) { - return compareTo((OrderItem) o); - } - - /** Compare two instances. This is a method in Comparator. */ - public int compare(Object o1, Object o2) { - return compare((OrderItem) o1, (OrderItem) o2); - } - - /** - * Compares this object with the specified Company object for order. Returns a negative integer, - * zero, or a positive integer as this object is less than, equal to, or greater than the - * specified object. - * - * @param other The Company object to be compared. - * @return a negative integer, zero, or a positive integer as this object is less than, equal to, - * or greater than the specified Company object. - */ - public int compareTo(OrderItem other) { - return compare(this, other); - } - - /** - * Compares its two OrderItem arguments for order. Returns a negative integer, zero, or a positive - * integer as the first argument is less than, equal to, or greater than the second. - * - * @param o1 the first OrderItem object to be compared. - * @param o2 the second OrderItem object to be compared. - * @return a negative integer, zero, or a positive integer as the first object is less than, equal - * to, or greater than the second object. - */ - public static int compare(OrderItem o1, OrderItem o2) { - int retval = o1.getOrder().compareTo(o2.getOrder()); - if (retval != 0) { - return retval; - } - return EqualityHelper.compare(o1.getItem(), o2.getItem()); - } - - /** - * Indicates whether some other object is "equal to" this one. - * - * @param obj the object with which to compare. - * @return true if this object is the same as the obj argument; false - * otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof OrderItem) { - return compareTo((OrderItem) obj) == 0; - } - return false; - } - - /** - * Returns a hash code value for the object. - * - * @return a hash code value for this object. - */ - public int hashCode() { - return (int) (order.orderId + item); - } - - /** - * The class to be used as the application identifier for the OrderItem class. It - * consists of both the order and the item fields. - */ - public static class OrderItemOid implements Serializable, Comparable { - public Order.OrderOid order; // matches order field name and OrderId type - public long item; // matches item field name and type - - /** The required public no-arg constructor. */ - public OrderItemOid() {} - - public OrderItemOid(String s) { - order = new Order.OrderOid(); - order.orderId = Long.parseLong(justTheOrder(s)); - item = Long.parseLong(justTheItem(s)); - } - - public String toString() { - return this.getClass().getName() + "order:" + order.orderId + ",item:" + item; - } - - /** */ - public boolean equals(Object obj) { - if (obj == null || !this.getClass().equals(obj.getClass())) return false; - OrderItemOid o = (OrderItemOid) obj; - if (!this.order.equals(o.order) || (this.item != o.item)) { - return false; - } - return true; + Order order; + long item; + String description; + int quantity; + + public OrderItem() { } - /** */ - public int hashCode() { - return (int) (item + order.orderId); + public OrderItem(Order order, long item, String description, int quantity) { + this.order = order; + this.item = item; + this.description = description; + this.quantity = quantity; + } + + public Order getOrder() { + return order; } - protected static String justTheOrder(String str) { - return str.substring(str.indexOf("order:") + 6, str.indexOf(",item:")); + public void setOrder (Order order) { + this.order = order; } - protected static String justTheItem(String str) { - return str.substring(str.indexOf("item:") + 5); + public long getItem() { + return item; } - /** */ - public int compareTo(Object obj) { - // may throw ClassCastException which the user must handle - OrderItemOid other = (OrderItemOid) obj; - if (order.orderId < other.order.orderId) return -1; - if (order.orderId > other.order.orderId) return 1; - if (item < other.item) return -1; - if (item > other.item) return 1; - return 0; + public void setItem (long item) { + this.item = item; + } + + public String getDescription() { + return description; + } + + public void setDescription (String description) { + this.description = description; + } + + public int getQuantity() { + return quantity; + } + + public void setQuantity (int quantity) { + this.quantity = quantity; + } + + /** + * Returns true if all the fields of this instance are + * deep equal to the coresponding fields of the specified Person. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, + EqualityHelper helper) { + OrderItem otherOrderItem = (OrderItem)other; + String where = "OrderItem<" + order.getOrderId() + "," + item + ">"; + return + helper.equals(order, otherOrderItem.getOrder(), where + ".order") & + helper.equals(item, otherOrderItem.getItem(), where + ".item"); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * @param o The Object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified object. + * @throws ClassCastException - if the specified object's type prevents + * it from being compared to this Object. + */ + public int compareTo(Object o) { + return compareTo((OrderItem)o); + } + + /** + * Compare two instances. This is a method in Comparator. + */ + public int compare(Object o1, Object o2) { + return compare((OrderItem)o1, (OrderItem)o2); + } + + /** + * Compares this object with the specified Company object for + * order. Returns a negative integer, zero, or a positive integer as + * this object is less than, equal to, or greater than the specified + * object. + * @param other The Company object to be compared. + * @return a negative integer, zero, or a positive integer as this + * object is less than, equal to, or greater than the specified Company + * object. + */ + public int compareTo(OrderItem other) { + return compare(this, other); + } + + /** + * Compares its two OrderItem arguments for order. Returns a negative + * integer, zero, or a positive integer as the first argument is less + * than, equal to, or greater than the second. + * @param o1 the first OrderItem object to be compared. + * @param o2 the second OrderItem object to be compared. + * @return a negative integer, zero, or a positive integer as the first + * object is less than, equal to, or greater than the second object. + */ + public static int compare(OrderItem o1, OrderItem o2) { + int retval = o1.getOrder().compareTo(o2.getOrder()); + if (retval != 0) { + return retval; + } + return EqualityHelper.compare(o1.getItem(), o2.getItem()); + } + + /** + * Indicates whether some other object is "equal to" this one. + * @param obj the object with which to compare. + * @return true if this object is the same as the obj + * argument; false otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof OrderItem) { + return compareTo((OrderItem)obj) == 0; + } + return false; + } + + /** + * Returns a hash code value for the object. + * @return a hash code value for this object. + */ + public int hashCode() { + return (int)(order.orderId + item); + } + + /** + * The class to be used as the application identifier + * for the OrderItem class. It consists of both the order + * and the item fields. + */ + public static class OrderItemOid implements Serializable, Comparable { + public Order.OrderOid order; //matches order field name and OrderId type + public long item; // matches item field name and type + + /** The required public no-arg constructor. */ + public OrderItemOid() { } + + public OrderItemOid(String s) { + order = new Order.OrderOid(); + order.orderId = Long.parseLong(justTheOrder(s)); + item = Long.parseLong(justTheItem(s)); + } + + public String toString() { + return this.getClass().getName() + "order:" + + order.orderId + ",item:" + item; + } + + /** */ + public boolean equals(Object obj) { + if (obj==null || !this.getClass().equals(obj.getClass())) + return false; + OrderItemOid o = (OrderItemOid) obj; + if (!this.order.equals(o.order) || (this.item != o.item)) { + return false; + } + return true; + } + + /** */ + public int hashCode() { + return (int)(item + order.orderId); + } + + protected static String justTheOrder(String str) { + return str.substring(str.indexOf("order:") + 6, + str.indexOf(",item:")); + } + + protected static String justTheItem(String str) { + return str.substring(str.indexOf("item:") + 5); + } + + /** */ + public int compareTo(Object obj) { + // may throw ClassCastException which the user must handle + OrderItemOid other = (OrderItemOid) obj; + if( order.orderId < other.order.orderId ) return -1; + if( order.orderId > other.order.orderId ) return 1; + if( item < other.item ) return -1; + if( item > other.item ) return 1; + return 0; + } } - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderModelReader.java b/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderModelReader.java index 2335ac31f..6e12520c2 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderModelReader.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/order/OrderModelReader.java @@ -5,124 +5,131 @@ * 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 + * + * 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.jdo.tck.pc.order; import java.util.Date; import java.util.List; import java.util.Locale; + import org.apache.jdo.tck.util.ConversionHelper; import org.apache.jdo.tck.util.JDOCustomDateEditor; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.core.io.ClassPathResource; -/** Utility class to create a graph of order model instances from an xml representation. */ +/** + * Utility class to create a graph of order model instances from an xml + * representation. + * + */ public class OrderModelReader extends DefaultListableBeanFactory { - /** The name of the root list bean. */ - public static final String ROOT_LIST_NAME = "root"; - - /** The bean-factory name in the xml input files. */ - public static final String BEAN_FACTORY_NAME = "orderFactory"; - - /** The order factory instance. */ - private OrderFactory orderFactory; - - /** Bean definition reader */ - private final XmlBeanDefinitionReader reader; - - /** - * Create a OrderModelReader for the specified resourceName. - * - * @param resourceName the name of the resource - */ - public OrderModelReader(String resourceName) { - // Use the class loader of the Order class to find the resource - this(resourceName, Order.class.getClassLoader()); - } - - /** - * Create a OrderModelReader for the specified resourceName. - * - * @param resourceName the name of the resource - * @param classLoader the ClassLOader for the lookup - */ - public OrderModelReader(String resourceName, ClassLoader classLoader) { - super(); - configureFactory(); - this.reader = new XmlBeanDefinitionReader(this); - this.reader.loadBeanDefinitions(new ClassPathResource(resourceName, classLoader)); - } - - /** - * Returns a list of root objects. The method expects to find a bean called "root" of type list in - * the xml and returns it. - * - * @return a list of root instances - */ - public List getRootList() { - return (List) getBean(ROOT_LIST_NAME); - } - - /** - * Configure the OrderModelReader, e.g. register CustomEditor classes to convert the string - * representation of a property into an instance of the right type. - */ - private void configureFactory() { - registerCustomEditor(Date.class, JDOCustomDateEditor.class); - orderFactory = OrderFactoryRegistry.getInstance(); - addSingleton(BEAN_FACTORY_NAME, orderFactory); - } - - // Convenience methods - - /** - * Convenience method returning a Order instance for the specified name. The method returns - * null if there is no Order bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no Order bean. - */ - public Order getOrder(String name) { - return (Order) getBean(name, Order.class); - } - - /** - * Convenience method returning a OrderItem instance for the specified name. The method returns - * null if there is no Department bean with the specified name. - * - * @param name the name of the bean to return. - * @return the instance of the bean or null if there no Department bean. - */ - public OrderItem getOrderItem(String name) { - return (OrderItem) getBean(name, OrderItem.class); - } - - /** - * @return Returns the tearDownClasses. - */ - public Class[] getTearDownClassesFromFactory() { - return orderFactory.getTearDownClasses(); - } - - /** - * @return Returns the tearDownClasses. - */ - public static Class[] getTearDownClasses() { - return OrderFactoryConcreteClass.tearDownClasses; - } - - public static Date stringToUtilDate(String value) { - return ConversionHelper.toUtilDate(JDOCustomDateEditor.DATE_PATTERN, Locale.US, value); - } + /** The name of the root list bean. */ + public static final String ROOT_LIST_NAME = "root"; + + /** The bean-factory name in the xml input files. + */ + public static final String BEAN_FACTORY_NAME = "orderFactory"; + + /** The order factory instance. */ + private OrderFactory orderFactory; + + /** Bean definition reader */ + private final XmlBeanDefinitionReader reader; + + /** + * Create a OrderModelReader for the specified resourceName. + * @param resourceName the name of the resource + */ + public OrderModelReader(String resourceName) { + // Use the class loader of the Order class to find the resource + this(resourceName, Order.class.getClassLoader()); + } + + /** + * Create a OrderModelReader for the specified resourceName. + * @param resourceName the name of the resource + * @param classLoader the ClassLOader for the lookup + */ + public OrderModelReader(String resourceName, ClassLoader classLoader) { + super(); + configureFactory(); + this.reader = new XmlBeanDefinitionReader(this); + this.reader.loadBeanDefinitions(new ClassPathResource(resourceName, classLoader)); + } + + /** + * Returns a list of root objects. The method expects to find a bean + * called "root" of type list in the xml and returns it. + * @return a list of root instances + */ + public List getRootList() { + return (List)getBean(ROOT_LIST_NAME); + } + + /** + * Configure the OrderModelReader, e.g. register CustomEditor classes + * to convert the string representation of a property into an instance + * of the right type. + */ + private void configureFactory() { + registerCustomEditor(Date.class, JDOCustomDateEditor.class); + orderFactory = OrderFactoryRegistry.getInstance(); + addSingleton(BEAN_FACTORY_NAME, orderFactory); + } + + // Convenience methods + + /** + * Convenience method returning a Order instance for the specified + * name. The method returns null if there is no Order + * bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * Order bean. + */ + public Order getOrder(String name) { + return (Order)getBean(name, Order.class); + } + + /** + * Convenience method returning a OrderItem instance for the specified + * name. The method returns null if there is no Department + * bean with the specified name. + * @param name the name of the bean to return. + * @return the instance of the bean or null if there no + * Department bean. + */ + public OrderItem getOrderItem(String name) { + return (OrderItem)getBean(name, OrderItem.class); + } + + /** + * @return Returns the tearDownClasses. + */ + public Class[] getTearDownClassesFromFactory() { + return orderFactory.getTearDownClasses(); + } + + /** + * @return Returns the tearDownClasses. + */ + public static Class[] getTearDownClasses() { + return OrderFactoryConcreteClass.tearDownClasses; + } + + public static Date stringToUtilDate(String value) { + return ConversionHelper.toUtilDate(JDOCustomDateEditor.DATE_PATTERN, Locale.US, value); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/query/JDOQLKeywordsAsFieldNames.java b/tck/src/main/java/org/apache/jdo/tck/pc/query/JDOQLKeywordsAsFieldNames.java index a65d9de00..3f85500f7 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/query/JDOQLKeywordsAsFieldNames.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/query/JDOQLKeywordsAsFieldNames.java @@ -5,29 +5,33 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.query; -/** The PC class for testing JDOQL queries. */ +/** + * The PC class for testing JDOQL queries. + */ public class JDOQLKeywordsAsFieldNames { + + /** + * The primary key field. + */ + private String select; - /** The primary key field. */ - private String select; - - public void setSelect(String select) { - this.select = select; - } + public void setSelect(String select) { + this.select = select; + } - public String getSelect() { - return this.select; - } + public String getSelect() { + return this.select; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/query/LocalDateSample.java b/tck/src/main/java/org/apache/jdo/tck/pc/query/LocalDateSample.java index 46467df01..0c3fe13e2 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/query/LocalDateSample.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/query/LocalDateSample.java @@ -21,44 +21,50 @@ public class LocalDateSample implements Serializable { - private long id; - private LocalDate localDate; + private long id; + private LocalDate localDate; - public long getId() { - return id; - } + public long getId() { + return id; + } - public void setId(long id) { - this.id = id; - } + public void setId(long id) { + this.id = id; + } - public LocalDate getLocalDate() { - return localDate; - } + public LocalDate getLocalDate() { + return localDate; + } - public void setLocalDate(LocalDate localDate) { - this.localDate = localDate; - } + public void setLocalDate(LocalDate localDate) { + this.localDate = localDate; + } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + ((localDate == null) ? 0 : localDate.hashCode()); - return result; - } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + ((localDate == null) ? 0 : localDate.hashCode()); + return result; + } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - LocalDateSample other = (LocalDateSample) obj; - if (id != other.id) return false; - if (localDate == null) { - if (other.localDate != null) return false; - } else if (!localDate.equals(other.localDate)) return false; - return true; - } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + LocalDateSample other = (LocalDateSample) obj; + if (id != other.id) + return false; + if (localDate == null) { + if (other.localDate != null) + return false; + } else if (!localDate.equals(other.localDate)) + return false; + return true; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/query/LocalDateTimeSample.java b/tck/src/main/java/org/apache/jdo/tck/pc/query/LocalDateTimeSample.java index 597c92751..9573b17b8 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/query/LocalDateTimeSample.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/query/LocalDateTimeSample.java @@ -21,44 +21,50 @@ public class LocalDateTimeSample implements Serializable { - private long id; - private LocalDateTime localDateTime; + private long id; + private LocalDateTime localDateTime; - public long getId() { - return id; - } + public long getId() { + return id; + } - public void setId(long id) { - this.id = id; - } + public void setId(long id) { + this.id = id; + } - public LocalDateTime getLocalDateTime() { - return localDateTime; - } + public LocalDateTime getLocalDateTime() { + return localDateTime; + } - public void setLocalDateTime(LocalDateTime localDateTime) { - this.localDateTime = localDateTime; - } + public void setLocalDateTime(LocalDateTime localDateTime) { + this.localDateTime = localDateTime; + } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + ((localDateTime == null) ? 0 : localDateTime.hashCode()); - return result; - } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + ((localDateTime == null) ? 0 : localDateTime.hashCode()); + return result; + } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - LocalDateTimeSample other = (LocalDateTimeSample) obj; - if (id != other.id) return false; - if (localDateTime == null) { - if (other.localDateTime != null) return false; - } else if (!localDateTime.equals(other.localDateTime)) return false; - return true; - } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + LocalDateTimeSample other = (LocalDateTimeSample) obj; + if (id != other.id) + return false; + if (localDateTime == null) { + if (other.localDateTime != null) + return false; + } else if (!localDateTime.equals(other.localDateTime)) + return false; + return true; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/query/LocalTimeSample.java b/tck/src/main/java/org/apache/jdo/tck/pc/query/LocalTimeSample.java index 709835d01..bfd4f7904 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/query/LocalTimeSample.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/query/LocalTimeSample.java @@ -21,44 +21,50 @@ public class LocalTimeSample implements Serializable { - private long id; - private LocalTime localTime; + private long id; + private LocalTime localTime; - public long getId() { - return id; - } + public long getId() { + return id; + } - public void setId(long id) { - this.id = id; - } + public void setId(long id) { + this.id = id; + } - public LocalTime getLocalTime() { - return localTime; - } + public LocalTime getLocalTime() { + return localTime; + } - public void setLocalTime(LocalTime localTime) { - this.localTime = localTime; - } + public void setLocalTime(LocalTime localTime) { + this.localTime = localTime; + } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + ((localTime == null) ? 0 : localTime.hashCode()); - return result; - } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + ((localTime == null) ? 0 : localTime.hashCode()); + return result; + } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - LocalTimeSample other = (LocalTimeSample) obj; - if (id != other.id) return false; - if (localTime == null) { - if (other.localTime != null) return false; - } else if (!localTime.equals(other.localTime)) return false; - return true; - } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + LocalTimeSample other = (LocalTimeSample) obj; + if (id != other.id) + return false; + if (localTime == null) { + if (other.localTime != null) + return false; + } else if (!localTime.equals(other.localTime)) + return false; + return true; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/query/MathSample.java b/tck/src/main/java/org/apache/jdo/tck/pc/query/MathSample.java index 16af45bb7..c05250912 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/query/MathSample.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/query/MathSample.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.query; @@ -20,105 +20,114 @@ import java.math.BigDecimal; public class MathSample implements Serializable { - long id; - - /** Angle in radians. */ - BigDecimal angle; - - BigDecimal trigValue; - Double doubleValue; - Float floatValue; - Integer intValue; - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public BigDecimal getAngle() { - return angle; - } - - public void setAngle(BigDecimal angle) { - this.angle = angle; - } - - public BigDecimal getTrigValue() { - return trigValue; - } - - public void setTrigValue(BigDecimal val) { - this.trigValue = val; - } - - public Double getDoubleValue() { - return doubleValue; - } - - public void setDoubleValue(Double val) { - this.doubleValue = val; - } - - public Float getFloatValue() { - return floatValue; - } - - public void setFloatValue(Float val) { - this.floatValue = val; - } - - public Integer getIntValue() { - return intValue; - } - - public void setIntValue(Integer val) { - this.intValue = val; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((intValue == null) ? 0 : intValue.hashCode()); - result = prime * result + ((floatValue == null) ? 0 : floatValue.hashCode()); - result = prime * result + ((doubleValue == null) ? 0 : doubleValue.hashCode()); - result = prime * result + ((trigValue == null) ? 0 : trigValue.hashCode()); - result = prime * result + ((angle == null) ? 0 : angle.hashCode()); - result = prime * result + (int) (id ^ (id >>> 32)); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - MathSample other = (MathSample) obj; - - if (intValue == null) { - if (other.intValue != null) return false; - } else if (!intValue.equals(other.intValue)) return false; - - if (floatValue == null) { - if (other.floatValue != null) return false; - } else if (!floatValue.equals(other.floatValue)) return false; - - if (doubleValue == null) { - if (other.doubleValue != null) return false; - } else if (!doubleValue.equals(other.doubleValue)) return false; - - if (trigValue == null) { - if (other.trigValue != null) return false; - } else if (!trigValue.equals(other.trigValue)) return false; - - if (angle == null) { - if (other.angle != null) return false; - } else if (!angle.equals(other.angle)) return false; - - if (id != other.id) return false; - return true; - } + long id; + + /** Angle in radians. */ + BigDecimal angle; + + BigDecimal trigValue; + Double doubleValue; + Float floatValue; + Integer intValue; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public BigDecimal getAngle() { + return angle; + } + public void setAngle(BigDecimal angle) { + this.angle = angle; + } + + public BigDecimal getTrigValue() { + return trigValue; + } + public void setTrigValue(BigDecimal val) { + this.trigValue = val; + } + + public Double getDoubleValue() { + return doubleValue; + } + public void setDoubleValue(Double val) { + this.doubleValue = val; + } + + public Float getFloatValue() { + return floatValue; + } + public void setFloatValue(Float val) { + this.floatValue = val; + } + + public Integer getIntValue() { + return intValue; + } + public void setIntValue(Integer val) { + this.intValue = val; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((intValue == null) ? 0 : intValue.hashCode()); + result = prime * result + ((floatValue == null) ? 0 : floatValue.hashCode()); + result = prime * result + ((doubleValue == null) ? 0 : doubleValue.hashCode()); + result = prime * result + ((trigValue == null) ? 0 : trigValue.hashCode()); + result = prime * result + ((angle == null) ? 0 : angle.hashCode()); + result = prime * result + (int) (id ^ (id >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + MathSample other = (MathSample) obj; + + if (intValue == null) { + if (other.intValue != null) + return false; + } else if (!intValue.equals(other.intValue)) + return false; + + if (floatValue == null) { + if (other.floatValue != null) + return false; + } else if (!floatValue.equals(other.floatValue)) + return false; + + if (doubleValue == null) { + if (other.doubleValue != null) + return false; + } else if (!doubleValue.equals(other.doubleValue)) + return false; + + if (trigValue == null) { + if (other.trigValue != null) + return false; + } else if (!trigValue.equals(other.trigValue)) + return false; + + if (angle == null) { + if (other.angle != null) + return false; + } else if (!angle.equals(other.angle)) + return false; + + if (id != other.id) + return false; + return true; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/query/NamedQueriesSample.java b/tck/src/main/java/org/apache/jdo/tck/pc/query/NamedQueriesSample.java index 063f3994a..69049a1ed 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/query/NamedQueriesSample.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/query/NamedQueriesSample.java @@ -5,51 +5,49 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.query; -import java.io.Serializable; +import javax.jdo.annotations.Query; import javax.jdo.annotations.PersistenceCapable; import javax.jdo.annotations.PrimaryKey; -import javax.jdo.annotations.Query; + +import java.io.Serializable; /** - * Test for use of annotations, where we are relying on the Repeatable nature of the @Query - * annotation (java 8). + * Test for use of annotations, where we are relying on the Repeatable + * nature of the @Query annotation (java 8). */ @PersistenceCapable -@Query( - name = "NameIsJohn", - value = "SELECT FROM org.apache.jdo.tck.pc.query.NamedQueriesSample WHERE name == 'John'") -@Query( - name = "NameIsFred", - value = "SELECT FROM org.apache.jdo.tck.pc.query.NamedQueriesSample WHERE name == 'Fred'") +@Query(name="NameIsJohn", value="SELECT FROM org.apache.jdo.tck.pc.query.NamedQueriesSample WHERE name == 'John'") +@Query(name="NameIsFred", value="SELECT FROM org.apache.jdo.tck.pc.query.NamedQueriesSample WHERE name == 'Fred'") public class NamedQueriesSample implements Serializable { - @PrimaryKey long id; + @PrimaryKey + long id; - String name; + String name; - public long getId() { - return id; - } + public long getId() { + return id; + } - public void setId(long id) { - this.id = id; - } + public void setId(long id) { + this.id = id; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/query/NoExtent.java b/tck/src/main/java/org/apache/jdo/tck/pc/query/NoExtent.java index 4d429424d..6fb98f710 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/query/NoExtent.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/query/NoExtent.java @@ -5,31 +5,35 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.query; -/** The PC class for testing JDOQL queries. */ +/** + * The PC class for testing JDOQL queries. + */ public class NoExtent { + + /** + * The primary key field. + */ + private int id; - /** The primary key field. */ - private int id; - - public NoExtent() {} - - public NoExtent(int id) { - this.id = id; - } + public NoExtent() {} - public int getId() { - return this.id; - } + public NoExtent(int id) { + this.id = id; + } + + public int getId() { + return this.id; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/query/OptionalSample.java b/tck/src/main/java/org/apache/jdo/tck/pc/query/OptionalSample.java index 73f74fd35..bf301cb71 100755 --- a/tck/src/main/java/org/apache/jdo/tck/pc/query/OptionalSample.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/query/OptionalSample.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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. */ @@ -21,95 +21,108 @@ import java.util.Optional; public class OptionalSample { - long id; - - Optional optionalPC; - - Optional optionalDate; - Optional optionalInteger; - Optional optionalString; - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public Optional getOptionalPC() { - return optionalPC; - } - - public void setOptionalPC(Optional opt) { - this.optionalPC = opt; - } - - public Optional getOptionalDate() { - return optionalDate; - } - - public void setOptionalDate(Optional opt) { - this.optionalDate = opt; - } - - public Optional getOptionalInteger() { - return optionalInteger; - } - - public void setOptionalInteger(Optional opt) { - this.optionalInteger = opt; - } - - public Optional getOptionalString() { - return optionalString; - } - - public void setOptionalString(Optional opt) { - this.optionalString = opt; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((optionalPC == null) ? 0 : optionalPC.hashCode()); - result = prime * result + ((optionalString == null) ? 0 : optionalString.hashCode()); - result = prime * result + ((optionalInteger == null) ? 0 : optionalInteger.hashCode()); - result = prime * result + ((optionalDate == null) ? 0 : optionalDate.hashCode()); - result = prime * result + (int) (id ^ (id >>> 32)); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - OptionalSample other = (OptionalSample) obj; - if (id != other.id) return false; - - if (optionalPC == null) { - if (other.optionalPC != null) return false; - } else if (!optionalPC.equals(other.optionalPC)) return false; - - if (optionalDate == null) { - if (other.optionalDate != null) return false; - } else if (!optionalDate.equals(other.optionalDate)) return false; - - if (optionalInteger == null) { - if (other.optionalInteger != null) return false; - } else if (!optionalInteger.equals(other.optionalInteger)) return false; - - if (optionalString == null) { - if (other.optionalString != null) return false; - } else if (!optionalString.equals(other.optionalString)) return false; - - return true; - } - - @Override - public String toString() { - return "id=" + id + " " + super.toString(); - } + long id; + + Optional optionalPC; + + Optional optionalDate; + Optional optionalInteger; + Optional optionalString; + + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public Optional getOptionalPC() { + return optionalPC; + } + + public void setOptionalPC(Optional opt) { + this.optionalPC = opt; + } + + public Optional getOptionalDate() { + return optionalDate; + } + + public void setOptionalDate(Optional opt) { + this.optionalDate = opt; + } + + public Optional getOptionalInteger() { + return optionalInteger; + } + + public void setOptionalInteger(Optional opt) { + this.optionalInteger = opt; + } + + public Optional getOptionalString() { + return optionalString; + } + + public void setOptionalString(Optional opt) { + this.optionalString = opt; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((optionalPC == null) ? 0 : optionalPC.hashCode()); + result = prime * result + ((optionalString == null) ? 0 : optionalString.hashCode()); + result = prime * result + ((optionalInteger == null) ? 0 : optionalInteger.hashCode()); + result = prime * result + ((optionalDate == null) ? 0 : optionalDate.hashCode()); + result = prime * result + (int) (id ^ (id >>> 32)); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + OptionalSample other = (OptionalSample) obj; + if (id != other.id) + return false; + + if (optionalPC == null) { + if (other.optionalPC != null) + return false; + } else if (!optionalPC.equals(other.optionalPC)) + return false; + + if (optionalDate == null) { + if (other.optionalDate != null) + return false; + } else if (!optionalDate.equals(other.optionalDate)) + return false; + + if (optionalInteger == null) { + if (other.optionalInteger != null) + return false; + } else if (!optionalInteger.equals(other.optionalInteger)) + return false; + + if (optionalString == null) { + if (other.optionalString != null) + return false; + } else if (!optionalString.equals(other.optionalString)) + return false; + + return true; + } + + @Override + public String toString() { + return "id=" + id + " " + super.toString(); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/query/TimeSample.java b/tck/src/main/java/org/apache/jdo/tck/pc/query/TimeSample.java index e326b96d5..005f12ded 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/query/TimeSample.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/query/TimeSample.java @@ -5,61 +5,68 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.query; import java.io.Serializable; import java.sql.Time; public class TimeSample implements Serializable { - long id; + long id; + + Time time; - Time time; + public long getId() { + return id; + } - public long getId() { - return id; - } + public void setId(long id) { + this.id = id; + } - public void setId(long id) { - this.id = id; - } + public Time getTime() { + return time; + } - public Time getTime() { - return time; - } + public void setTime(Time time) { + this.time = time; + } - public void setTime(Time time) { - this.time = time; - } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + ((time == null) ? 0 : time.hashCode()); + return result; + } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (int) (id ^ (id >>> 32)); - result = prime * result + ((time == null) ? 0 : time.hashCode()); - return result; - } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TimeSample other = (TimeSample) obj; + if (id != other.id) + return false; + if (time == null) { + if (other.time != null) + return false; + } else if (!time.equals(other.time)) + return false; + return true; + } - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - TimeSample other = (TimeSample) obj; - if (id != other.id) return false; - if (time == null) { - if (other.time != null) return false; - } else if (!time.equals(other.time)) return false; - return true; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/shoppingcart/Cart.java b/tck/src/main/java/org/apache/jdo/tck/pc/shoppingcart/Cart.java index feb9f3655..ec09f021a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/shoppingcart/Cart.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/shoppingcart/Cart.java @@ -5,140 +5,141 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.shoppingcart; import java.io.Serializable; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; +import java.util.*; -/** This class represents an online shopping cart. It has a list of entries of type CartEntry. */ +/** This class represents an online shopping cart. It has a list of entries of + * type CartEntry. + */ public class Cart implements Serializable { - protected static long nextId = System.currentTimeMillis(); - - public static synchronized long nextId() { - return nextId++; - } - - /** Identity field for use with application identity */ - protected long id; + protected static long nextId = System.currentTimeMillis(); - /** The identity of the customer whose shopping cart this is. */ - protected String customerId; - - /** The list of entries in this cart */ - protected Set entries = new HashSet(); // element-type CartEntry + public synchronized static long nextId() { + return nextId++; + } - /** For JDO compliance only; not for public consumption. */ - protected Cart() {} + /** Identity field for use with application identity */ + protected long id; - public Cart(String customerId) { - this(nextId(), customerId); - } + /** The identity of the customer whose shopping cart this is. */ + protected String customerId; - protected Cart(long id, String customerId) { - setId(id); - setCustomerId(customerId); - } + /** The list of entries in this cart */ + protected Set entries = new HashSet(); // element-type CartEntry - public long getId() { - return id; - } + /** For JDO compliance only; not for public consumption. */ + protected Cart() {} - protected void setId(long id) { - this.id = id; - } + public Cart(String customerId) { + this(nextId(), customerId); + } - public CartEntry newCartEntry(Product product, int quantity) { - CartEntry ce = new CartEntry(this, CartEntry.nextId(), product, quantity); - entries.add(ce); - return ce; - } + protected Cart(long id, String customerId) { + setId(id); + setCustomerId(customerId); + } - public void addCartEntry(CartEntry ce) { - if (ce == null) { - throw new IllegalArgumentException("no CartEntry given"); + public long getId() { + return id; } - ce.setCart(this); - entries.add(ce); - } - public Iterator getEntries() { - return entries.iterator(); - } + protected void setId(long id) { + this.id = id; + } - public String getCustomerId() { - return customerId; - } + public CartEntry newCartEntry(Product product, int quantity) { + CartEntry ce = new CartEntry(this, CartEntry.nextId(), product, quantity); + entries.add(ce); + return ce; + } - public void setCustomerId(String customerId) { - this.customerId = customerId; - } + public void addCartEntry(CartEntry ce) { + if (ce == null) { + throw new IllegalArgumentException("no CartEntry given"); + } + ce.setCart(this); + entries.add(ce); + } - public boolean equals(Object that) { - if (this == that) { - return true; + public Iterator getEntries() { + return entries.iterator(); } - if (that == null) { - return false; + + public String getCustomerId() { + return customerId; } - if (!(that instanceof Cart)) { - return false; + + public void setCustomerId(String customerId) { + this.customerId = customerId; } - return equals((Cart) that); - } - public boolean equals(Cart that) { - if (this == that) { - return true; + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (!(that instanceof Cart)) { + return false; + } + return equals((Cart) that); } - if (that == null) { - return false; + + public boolean equals(Cart that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + return this.id == that.id; } - return this.id == that.id; - } - public int hashCode() { - return (int) id; - } + public int hashCode() { + return (int) id; + } - public static class Oid implements Serializable { - public long id; + public static class Oid implements Serializable { + public long id; - public Oid() {} + public Oid() { + } - public Oid(String s) { - id = Long.parseLong(justTheId(s)); - } + public Oid(String s) { + id = Long.parseLong(justTheId(s)); + } - public String toString() { - return this.getClass().getName() + ":" + id; - } + public String toString() { + return this.getClass().getName() + ":" + id; + } - public int hashCode() { - return (int) id; - } + public int hashCode() { + return (int) id; + } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid that = (Oid) other; - return that.id == this.id; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid that = (Oid) other; + return that.id == this.id; + } + return false; + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/shoppingcart/CartEntry.java b/tck/src/main/java/org/apache/jdo/tck/pc/shoppingcart/CartEntry.java index d9b04ae12..70a4cee0b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/shoppingcart/CartEntry.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/shoppingcart/CartEntry.java @@ -5,145 +5,145 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.shoppingcart; import java.io.Serializable; -/** This class represents an entry in an online shopping cart that has a quantity of a product. */ +/** This class represents an entry in an online shopping cart that has a + * quantity of a product. + */ public class CartEntry implements Serializable { - protected static long nextId = System.currentTimeMillis(); + protected static long nextId = System.currentTimeMillis(); - public static synchronized long nextId() { - return nextId++; - } - - /** Identity field for use with application identity */ - protected long id; - - protected Cart cart; - protected Product product; - protected int quantity = 1; - - /** No-arg constructor required by JDO; not for public consumption */ - protected CartEntry() {} - - public CartEntry(Cart cart, Product product) { - this(cart, nextId(), product); - } - - public CartEntry(Cart cart, long id, Product product) { - this(cart, id, product, 1); - } - - public CartEntry(Cart cart, long id, Product product, int quantity) { - setId(id); - setProduct(product); - setQuantity(quantity); - cart.addCartEntry(this); - } + public synchronized static long nextId() { + return nextId++; + } - public long getId() { - return id; - } + /** Identity field for use with application identity */ + protected long id; + protected Cart cart; + protected Product product; + protected int quantity = 1; - protected void setId(long id) { - this.id = id; - } + /** No-arg constructor required by JDO; not for public consumption */ + protected CartEntry() {} - public Cart getCart() { - return cart; - } + public CartEntry(Cart cart, Product product) { + this(cart, nextId(), product); + } + public CartEntry(Cart cart, long id, Product product) { + this(cart, id, product, 1); + } + public CartEntry(Cart cart, long id, Product product, int quantity) { + setId(id); + setProduct(product); + setQuantity(quantity); + cart.addCartEntry(this); + } - protected void setCart(Cart cart) { - if (this.cart != null) { - throw new IllegalStateException("Cart already set"); + public long getId() { + return id; } - this.cart = cart; - } - public Product getProduct() { - return product; - } + protected void setId(long id) { + this.id = id; + } - public void setProduct(Product product) { - this.product = product; - } + public Cart getCart() { + return cart; + } - public int getQuantity() { - return quantity; - } + protected void setCart(Cart cart) { + if (this.cart != null) { + throw new IllegalStateException("Cart already set"); + } + this.cart = cart; + } - public void setQuantity(int quantity) { - if (quantity < 1) { - throw new IllegalArgumentException("quantity can't be less than one"); + public Product getProduct() { + return product; } - this.quantity = quantity; - } - public boolean equals(Object that) { - if (this == that) { - return true; + public void setProduct(Product product) { + this.product = product; } - if (that == null) { - return false; + + public int getQuantity() { + return quantity; } - if (!(that instanceof CartEntry)) { - return false; + + public void setQuantity(int quantity) { + if (quantity < 1) { + throw new IllegalArgumentException("quantity can't be less than one"); + } + this.quantity = quantity; } - return equals((CartEntry) that); - } - public boolean equals(CartEntry that) { - if (this == that) { - return true; + public boolean equals(Object that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + if (!(that instanceof CartEntry)) { + return false; + } + return equals((CartEntry) that); } - if (that == null) { - return false; + + public boolean equals(CartEntry that) { + if (this == that) { + return true; + } + if (that == null) { + return false; + } + return this.id == that.id; + } + + public int hashCode() { + return (int) id; } - return this.id == that.id; - } - public int hashCode() { - return (int) id; - } + public static class Oid implements Serializable { + public long id; - public static class Oid implements Serializable { - public long id; + public Oid() { + } - public Oid() {} + public Oid(String s) { + id = Long.parseLong(justTheId(s)); + } - public Oid(String s) { - id = Long.parseLong(justTheId(s)); - } + public String toString() { + return this.getClass().getName() + ":" + id; + } - public String toString() { - return this.getClass().getName() + ":" + id; - } + public int hashCode() { + return (int) id; + } - public int hashCode() { - return (int) id; - } - - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid that = (Oid) other; - return that.id == this.id; - } - return false; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid that = (Oid) other; + return that.id == this.id; + } + return false; + } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/shoppingcart/Product.java b/tck/src/main/java/org/apache/jdo/tck/pc/shoppingcart/Product.java index 547705870..39c11d7b5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/shoppingcart/Product.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/shoppingcart/Product.java @@ -5,96 +5,96 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.shoppingcart; import java.io.Serializable; -/** This class represents a product that you would buy from an online store. */ +/** This class represents a product that you would buy from an online store. + */ public class Product implements Serializable { - /** Identity field when used with application identity */ - protected String sku; - - protected String description; - - /** No-arg constructor required by JDO; not for public consumption */ - protected Product() {} - - /** - * Domain model constructor - * - * @param sku identity field - */ - public Product(String sku) { - setSku(sku); - } - - /** - * Constructor with sku and description - * - * @param sku identity field - * @param description description - */ - public Product(String sku, String description) { - this(sku); - setDescription(description); - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getSku() { - return sku; - } - - public void setSku(String sku) { - if (sku == null || (sku = sku.trim()).length() == 0) { - throw new IllegalArgumentException("no sku given"); - } - this.sku = sku.toUpperCase(); - } + /** Identity field when used with application identity */ + protected String sku; + + protected String description; - public static class Oid implements Serializable { - public String sku; + /** No-arg constructor required by JDO; not for public consumption */ + protected Product() {} - public Oid() {} + /** + * Domain model constructor + * @param sku identity field + */ + public Product(String sku) { + setSku(sku); + } + + /** + * Constructor with sku and description + * @param sku identity field + * @param description description + */ + public Product(String sku, String description) { + this(sku); + setDescription(description); + } - public Oid(String s) { - sku = justTheSku(s); + public String getDescription() { + return description; } - public String toString() { - return this.getClass().getName() + ":" + sku; + public void setDescription(String description) { + this.description = description; } - public int hashCode() { - return sku.hashCode(); + public String getSku() { + return sku; } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid that = (Oid) other; - return that.sku.equals(this.sku); - } - return false; + public void setSku(String sku) { + if (sku == null || (sku = sku.trim()).length() == 0) { + throw new IllegalArgumentException("no sku given"); + } + this.sku = sku.toUpperCase(); } - protected static String justTheSku(String str) { - return str.substring(str.indexOf(':') + 1); + public static class Oid implements Serializable { + public String sku; + + public Oid() { + } + + public Oid(String s) { + sku = justTheSku(s); + } + + public String toString() { + return this.getClass().getName() + ":" + sku; + } + + public int hashCode() { + return sku.hashCode(); + } + + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid that = (Oid) other; + return that.sku.equals(this.sku); + } + return false; + } + + protected static String justTheSku(String str) { + return str.substring(str.indexOf(':') + 1); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/shoppingcart/Undetachable.java b/tck/src/main/java/org/apache/jdo/tck/pc/shoppingcart/Undetachable.java index b3dca2d2e..d360b1f16 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/shoppingcart/Undetachable.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/shoppingcart/Undetachable.java @@ -5,13 +5,13 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.shoppingcart; @@ -19,74 +19,75 @@ import java.io.Serializable; /** - * This class is a token undetachable class. It is only present to be persistence-capable but not - * detachable so as to test that a detachable class must be declared so. + * This class is a token undetachable class. It is only present to be + * persistence-capable but not detachable so as to test that a detachable class + * must be declared so. */ public class Undetachable implements Serializable { - protected static long nextId = System.currentTimeMillis(); + protected static long nextId = System.currentTimeMillis(); - public static synchronized long nextId() { - return nextId++; - } + public synchronized static long nextId() { + return nextId++; + } - /** Identity field for use with application identity */ - protected long id; + /** Identity field for use with application identity */ + protected long id; + protected int foo; + protected int bar; - protected int foo; - protected int bar; + public Undetachable() { + this(nextId()); + } - public Undetachable() { - this(nextId()); - } + public Undetachable(long id) { + this.id = id; + } - public Undetachable(long id) { - this.id = id; - } + public static class Oid implements Serializable { + public long id; - public static class Oid implements Serializable { - public long id; + public Oid() { + } - public Oid() {} + public Oid(String s) { + id = Long.parseLong(justTheId(s)); + } - public Oid(String s) { - id = Long.parseLong(justTheId(s)); - } + public String toString() { + return this.getClass().getName() + ":" + id; + } - public String toString() { - return this.getClass().getName() + ":" + id; - } + public int hashCode() { + return (int) id; + } - public int hashCode() { - return (int) id; - } + public boolean equals(Object other) { + if (other != null && (other instanceof Oid)) { + Oid that = (Oid) other; + return that.id == this.id; + } + return false; + } - public boolean equals(Object other) { - if (other != null && (other instanceof Oid)) { - Oid that = (Oid) other; - return that.id == this.id; - } - return false; + protected static String justTheId(String str) { + return str.substring(str.indexOf(':') + 1); + } } - protected static String justTheId(String str) { - return str.substring(str.indexOf(':') + 1); + public int getFoo() { + return foo; } - } - - public int getFoo() { - return foo; - } - public void setFoo(int foo) { - this.foo = foo; - } + public void setFoo(int foo) { + this.foo = foo; + } - public int getBar() { - return bar; - } + public int getBar() { + return bar; + } - public void setBar(int bar) { - this.bar = bar; - } + public void setBar(int bar) { + this.bar = bar; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/AbstractPCPointSingleField.java b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/AbstractPCPointSingleField.java index f47224409..a7a51c92a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/AbstractPCPointSingleField.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/AbstractPCPointSingleField.java @@ -5,45 +5,50 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.singlefieldidentity; import java.io.Serializable; import java.util.Date; + import javax.jdo.identity.SingleFieldIdentity; /** - * This is the super class for all PCPoint single indentity classes. It defines an abstract method - * equals(SingleFieldIdentity). That method ensures that all single identity test cases - * have a common implementation. - * + * This is the super class for all PCPoint single indentity classes. + * It defines an abstract method equals(SingleFieldIdentity). + * That method ensures that all single identity test cases have a common + * implementation. * @author Michael Watzek */ -public abstract class AbstractPCPointSingleField implements Serializable { - - /** This field is used by subclasses to compute the value of the primary key field. */ - static long counter = new Date().getTime(); +abstract public class AbstractPCPointSingleField implements Serializable { + + /** + * This field is used by subclasses + * to compute the value of the primary key field. + */ + static long counter = new Date().getTime(); - /** - * Returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - * - * @param singleFieldIdentity the single field identity to check. - * @return returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - */ - public abstract boolean equalsPKField(SingleFieldIdentity singleFieldIdentity); + /** + * Returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + * @param singleFieldIdentity the single field identity to check. + * @return returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + */ + abstract public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity); - public String toString() { - return '(' + getClass().getName() + ')'; - } + public String toString() { + return '(' + getClass().getName() + ')'; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/Employee.java b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/Employee.java index 147fd70e2..f8cfd1d82 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/Employee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/Employee.java @@ -5,107 +5,102 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.singlefieldidentity; import java.util.Date; -/** This class represents an employee. */ +/** + * This class represents an employee. + */ public abstract class Employee extends Person { - private Date hiredate; - private double weeklyhours; + private Date hiredate; + private double weeklyhours; - /** This is the JDO-required no-args constructor */ - protected Employee() {} + /** This is the JDO-required no-args constructor */ + protected Employee() {} - /** - * Construct an Employee instance. - * - * @param personid The identifier for the person. - * @param firstname The first name of the employee. - * @param lastname The last name of the employee. - * @param middlename The middle name of the employee. - * @param birthdate The birth date of the employee. - * @param hiredate The date that the employee was hired. - */ - public Employee( - long personid, - String firstname, - String lastname, - String middlename, - Date birthdate, - Date hiredate) { - super(personid, firstname, lastname, middlename, birthdate); - this.hiredate = hiredate; - } + /** + * Construct an Employee instance. + * @param personid The identifier for the person. + * @param firstname The first name of the employee. + * @param lastname The last name of the employee. + * @param middlename The middle name of the employee. + * @param birthdate The birth date of the employee. + * @param hiredate The date that the employee was hired. + */ + public Employee(long personid, String firstname, String lastname, + String middlename, Date birthdate, + Date hiredate) { + super(personid, firstname, lastname, middlename, birthdate); + this.hiredate = hiredate; + } - /** - * Get the date that the employee was hired. - * - * @return The date the employee was hired. - */ - public Date getHiredate() { - return hiredate; - } + /** + * Get the date that the employee was hired. + * @return The date the employee was hired. + */ + public Date getHiredate() { + return hiredate; + } - /** - * Set the date that the employee was hired. - * - * @param hiredate The date the employee was hired. - */ - public void setHiredate(Date hiredate) { - this.hiredate = hiredate; - } + /** + * Set the date that the employee was hired. + * @param hiredate The date the employee was hired. + */ + public void setHiredate(Date hiredate) { + this.hiredate = hiredate; + } - /** - * Get the weekly hours of the employee. - * - * @return The number of hours per week that the employee works. - */ - public double getWeeklyhours() { - return weeklyhours; - } + /** + * Get the weekly hours of the employee. + * @return The number of hours per week that the employee works. + */ + public double getWeeklyhours() { + return weeklyhours; + } - /** - * Set the number of hours per week that the employee works. - * - * @param weeklyhours The number of hours per week that the employee works. - */ - public void setWeeklyhours(double weeklyhours) { - this.weeklyhours = weeklyhours; - } + /** + * Set the number of hours per week that the employee works. + * @param weeklyhours The number of hours per week that the employee + * works. + */ + public void setWeeklyhours(double weeklyhours) { + this.weeklyhours = weeklyhours; + } - /** - * Return a String representation of a Employee object. - * - * @return a String representation of a Employee object. - */ - @Override - public String toString() { - return "Employee(" + getFieldRepr() + ")"; - } + /** + * Return a String representation of a Employee object. + * @return a String representation of a Employee object. + */ + @Override + public String toString() { + return "Employee(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + @Override + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", hired ").append( + hiredate==null ? "null" : formatter.format(hiredate)); + rc.append(", weeklyhours ").append(weeklyhours); + return rc.toString(); + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - @Override - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", hired ").append(hiredate == null ? "null" : formatter.format(hiredate)); - rc.append(", weeklyhours ").append(weeklyhours); - return rc.toString(); - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/FullTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/FullTimeEmployee.java index 2649012c8..443394723 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/FullTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/FullTimeEmployee.java @@ -5,86 +5,84 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.singlefieldidentity; import java.util.Date; -/** This class represents a full-time employee. */ +/** + * This class represents a full-time employee. + */ public class FullTimeEmployee extends Employee { - private double salary; - - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public FullTimeEmployee() {} + private double salary; - /** - * Construct a full-time employee. - * - * @param personid The person identifier. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param hired The date that the person was hired. - * @param sal The salary of the full-time employee. - */ - public FullTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double sal) { - super(personid, first, last, middle, born, hired); - salary = sal; - } + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public FullTimeEmployee() {} - /** - * Get the salary of the full time employee. - * - * @return The salary of the full time employee. - */ - public double getSalary() { - return salary; - } + /** + * Construct a full-time employee. + * @param personid The person identifier. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param hired The date that the person was hired. + * @param sal The salary of the full-time employee. + */ + public FullTimeEmployee(long personid, String first, String last, + String middle, Date born, + Date hired, double sal) { + super(personid, first, last, middle, born, hired); + salary = sal; + } - /** - * Set the salary for the full-time employee. - * - * @param salary The salary to set for the full-time employee. - */ - public void setSalary(double salary) { - this.salary = salary; - } + /** + * Get the salary of the full time employee. + * @return The salary of the full time employee. + */ + public double getSalary() { + return salary; + } + + /** + * Set the salary for the full-time employee. + * @param salary The salary to set for the full-time employee. + */ + public void setSalary(double salary) { + this.salary = salary; + } + + /** + * Return a String representation of a FullTimeEmployee object. + * @return a String representation of a FullTimeEmployee object. + */ + @Override + public String toString() { + return "FullTimeEmployee(" + getFieldRepr() + ")"; + } - /** - * Return a String representation of a FullTimeEmployee object. - * - * @return a String representation of a FullTimeEmployee object. - */ - @Override - public String toString() { - return "FullTimeEmployee(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + @Override + public String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", $").append(salary); + return rc.toString(); + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - @Override - public String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", $").append(salary); - return rc.toString(); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldByte.java b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldByte.java index 90c7fc330..db8a40d7b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldByte.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldByte.java @@ -5,16 +5,16 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.singlefieldidentity; import javax.jdo.identity.ByteIdentity; @@ -22,84 +22,85 @@ /** * The PC class for testing ByteIdentity. - * * @author Michael Watzek */ public class PCPointSingleFieldByte extends AbstractPCPointSingleField { - - /** - * Returns a unique value, used for primary key field initialization. - * - * @return a unique value - */ - private static byte newId() { - synchronized (PCPointSingleFieldByte.class) { - return (byte) ((counter++) % Byte.MAX_VALUE); + + /** + * Returns a unique value, used for primary key field initialization. + * @return a unique value + */ + private static byte newId() { + synchronized (PCPointSingleFieldByte.class) { + return (byte) ((counter++) % Byte.MAX_VALUE); + } } - } - - /** The primary key field. */ - private Byte id = Byte.valueOf(newId()); - - public int x; - public Integer y; - /** - * This constructor is used by test cases checking assertion A7.12-38:
    - * For classes using single field identity method PersistenceCapable.newObjectIdInstance() - * must be called on a persistent instance with its primary key field initialized, or a - * JDOFatalInternalException is thrown. - */ - public PCPointSingleFieldByte() { - this.id = null; - } + /** + * The primary key field. + */ + private Byte id = Byte.valueOf(newId()); - /** - * This constructor is used by test cases checking assertion A7.12-39:
    - * The instance returned is initialized with the value of the primary key field of the instance on - * which the method is called. - * - * @param x the x coordinate - * @param y the y coordinate - */ - public PCPointSingleFieldByte(int x, int y) { - this.x = x; - this.y = Integer.valueOf(y); - } + public int x; + public Integer y; - public void setX(int x) { - this.x = x; - } + /** + * This constructor is used by test cases checking assertion A7.12-38:
    + * For classes using single field identity method + * PersistenceCapable.newObjectIdInstance() must be called + * on a persistent instance with its primary key field initialized, + * or a JDOFatalInternalException is thrown. + */ + public PCPointSingleFieldByte() { + this.id = null; + } - public int getX() { - return x; - } + /** + * This constructor is used by test cases checking assertion A7.12-39:
    + * The instance returned is initialized with the value of the primary key + * field of the instance on which the method is called. + * @param x the x coordinate + * @param y the y coordinate + */ + public PCPointSingleFieldByte(int x, int y) { + this.x = x; + this.y = Integer.valueOf(y); + } - public void setY(Integer y) { - this.y = y; - } + public void setX(int x) { + this.x = x; + } - public Integer getY() { - return y; - } + public int getX() { + return x; + } - public String name() { - return " x: " + getX() + ", y: " + getY().intValue(); - } + public void setY(Integer y) { + this.y = y; + } - /** - * Returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - * - * @param singleFieldIdentity the single field identity to check. - * @return returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - */ - public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { - return this.id.byteValue() == ((ByteIdentity) singleFieldIdentity).getKey(); - } + public Integer getY() { + return y; + } + + public String name() { + return " x: " + getX() + ", y: " + getY().intValue(); + } - public String toString() { - return super.toString() + this.id; - } + /** + * Returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + * @param singleFieldIdentity the single field identity to check. + * @return returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + */ + public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { + return this.id.byteValue()==((ByteIdentity)singleFieldIdentity).getKey(); + } + + public String toString() { + return super.toString() + this.id; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldCharacter.java b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldCharacter.java index 5542ae079..1ab91c721 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldCharacter.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldCharacter.java @@ -5,16 +5,16 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.singlefieldidentity; import javax.jdo.identity.CharIdentity; @@ -22,84 +22,85 @@ /** * The PC class for testing CharIdentity. - * * @author Michael Watzek */ public class PCPointSingleFieldCharacter extends AbstractPCPointSingleField { - - /** - * Returns a unique value, used for primary key field initialization. - * - * @return a unique value - */ - private static char newId() { - synchronized (PCPointSingleFieldCharacter.class) { - return (char) ((counter++) % Character.MAX_VALUE); + + /** + * Returns a unique value, used for primary key field initialization. + * @return a unique value + */ + private static char newId() { + synchronized (PCPointSingleFieldCharacter.class) { + return (char) ((counter++) % Character.MAX_VALUE); + } } - } - - /** The primary key field. */ - private Character id = Character.valueOf(newId()); - - public int x; - public Integer y; - /** - * This constructor is used by test cases checking assertion A7.12-38:
    - * For classes using single field identity method PersistenceCapable.newObjectIdInstance() - * must be called on a persistent instance with its primary key field initialized, or a - * JDOFatalInternalException is thrown. - */ - public PCPointSingleFieldCharacter() { - this.id = null; - } + /** + * The primary key field. + */ + private Character id = Character.valueOf(newId()); - /** - * This constructor is used by test cases checking assertion A7.12-39:
    - * The instance returned is initialized with the value of the primary key field of the instance on - * which the method is called. - * - * @param x the x coordinate - * @param y the y coordinate - */ - public PCPointSingleFieldCharacter(int x, int y) { - this.x = x; - this.y = Integer.valueOf(y); - } + public int x; + public Integer y; - public void setX(int x) { - this.x = x; - } + /** + * This constructor is used by test cases checking assertion A7.12-38:
    + * For classes using single field identity method + * PersistenceCapable.newObjectIdInstance() must be called + * on a persistent instance with its primary key field initialized, + * or a JDOFatalInternalException is thrown. + */ + public PCPointSingleFieldCharacter() { + this.id = null; + } - public int getX() { - return x; - } + /** + * This constructor is used by test cases checking assertion A7.12-39:
    + * The instance returned is initialized with the value of the primary key + * field of the instance on which the method is called. + * @param x the x coordinate + * @param y the y coordinate + */ + public PCPointSingleFieldCharacter(int x, int y) { + this.x = x; + this.y = Integer.valueOf(y); + } - public void setY(Integer y) { - this.y = y; - } + public void setX(int x) { + this.x = x; + } - public Integer getY() { - return y; - } + public int getX() { + return x; + } - public String name() { - return " x: " + getX() + ", y: " + getY().intValue(); - } + public void setY(Integer y) { + this.y = y; + } - /** - * Returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - * - * @param singleFieldIdentity the single field identity to check. - * @return returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - */ - public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { - return this.id.charValue() == ((CharIdentity) singleFieldIdentity).getKey(); - } + public Integer getY() { + return y; + } + + public String name() { + return " x: " + getX() + ", y: " + getY().intValue(); + } - public String toString() { - return super.toString() + this.id; - } + /** + * Returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + * @param singleFieldIdentity the single field identity to check. + * @return returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + */ + public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { + return this.id.charValue()==((CharIdentity)singleFieldIdentity).getKey(); + } + + public String toString() { + return super.toString() + this.id; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldDate.java b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldDate.java index 0717534d8..e5e9abb7d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldDate.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldDate.java @@ -5,102 +5,104 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.singlefieldidentity; import java.util.Date; + import javax.jdo.identity.ObjectIdentity; import javax.jdo.identity.SingleFieldIdentity; /** * The PC class for testing ObjectIdentity. - * * @author Michael Watzek */ public class PCPointSingleFieldDate extends AbstractPCPointSingleField { - - /** - * Returns a unique value, used for primary key field initialization. - * - * @return a unique value - */ - private static long newId() { - synchronized (PCPointSingleFieldDate.class) { - return counter++; + + /** + * Returns a unique value, used for primary key field initialization. + * @return a unique value + */ + private static long newId() { + synchronized (PCPointSingleFieldDate.class) { + return counter++; + } } - } - - /** The primary key field. */ - private Date id = new Date(newId()); - public int x; - public Integer y; + /** + * The primary key field. + */ + private Date id = new Date(newId()); - /** - * This constructor is used by test cases checking assertion A7.12-38:
    - * For classes using single field identity method PersistenceCapable.newObjectIdInstance() - * must be called on a persistent instance with its primary key field initialized, or a - * JDOFatalInternalException is thrown. - */ - public PCPointSingleFieldDate() { - this.id = null; - } + public int x; + public Integer y; - /** - * This constructor is used by test cases checking assertion A7.12-39:
    - * The instance returned is initialized with the value of the primary key field of the instance on - * which the method is called. - * - * @param x the x coordinate - * @param y the y coordinate - */ - public PCPointSingleFieldDate(int x, int y) { - this.x = x; - this.y = Integer.valueOf(y); - } - - public void setX(int x) { - this.x = x; - } + /** + * This constructor is used by test cases checking assertion A7.12-38:
    + * For classes using single field identity method + * PersistenceCapable.newObjectIdInstance() must be called + * on a persistent instance with its primary key field initialized, + * or a JDOFatalInternalException is thrown. + */ + public PCPointSingleFieldDate() { + this.id = null; + } - public int getX() { - return x; - } + /** + * This constructor is used by test cases checking assertion A7.12-39:
    + * The instance returned is initialized with the value of the primary key + * field of the instance on which the method is called. + * @param x the x coordinate + * @param y the y coordinate + */ + public PCPointSingleFieldDate(int x, int y) { + this.x = x; + this.y = Integer.valueOf(y); + } - public void setY(Integer y) { - this.y = y; - } + public void setX(int x) { + this.x = x; + } - public Integer getY() { - return y; - } + public int getX() { + return x; + } - public String name() { - return " x: " + getX() + ", y: " + getY().intValue(); - } + public void setY(Integer y) { + this.y = y; + } - /** - * Returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - * - * @param singleFieldIdentity the single field identity to check. - * @return returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - */ - public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { - return this.id.equals(((ObjectIdentity) singleFieldIdentity).getKey()); - } + public Integer getY() { + return y; + } + + public String name() { + return " x: " + getX() + ", y: " + getY().intValue(); + } - public String toString() { - return super.toString() + this.id; - } + /** + * Returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + * @param singleFieldIdentity the single field identity to check. + * @return returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + */ + public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { + return this.id.equals(((ObjectIdentity)singleFieldIdentity).getKey()); + } + + public String toString() { + return super.toString() + this.id; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldInteger.java b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldInteger.java index 7af369c5a..4dac5260e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldInteger.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldInteger.java @@ -5,16 +5,16 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.singlefieldidentity; import javax.jdo.identity.IntIdentity; @@ -22,84 +22,85 @@ /** * The PC class for testing IntIdentity. - * * @author Michael Watzek */ public class PCPointSingleFieldInteger extends AbstractPCPointSingleField { - - /** - * Returns a unique value, used for primary key field initialization. - * - * @return a unique value - */ - private static int newId() { - synchronized (PCPointSingleFieldInteger.class) { - return (int) ((counter++) % Integer.MAX_VALUE); + + /** + * Returns a unique value, used for primary key field initialization. + * @return a unique value + */ + private static int newId() { + synchronized (PCPointSingleFieldInteger.class) { + return (int) ((counter++) % Integer.MAX_VALUE); + } } - } - - /** The primary key field. */ - private Integer id = Integer.valueOf(newId()); - - public int x; - public Integer y; - /** - * This constructor is used by test cases checking assertion A7.12-38:
    - * For classes using single field identity method PersistenceCapable.newObjectIdInstance() - * must be called on a persistent instance with its primary key field initialized, or a - * JDOFatalInternalException is thrown. - */ - public PCPointSingleFieldInteger() { - this.id = null; - } + /** + * The primary key field. + */ + private Integer id = Integer.valueOf(newId()); - /** - * This constructor is used by test cases checking assertion A7.12-39:
    - * The instance returned is initialized with the value of the primary key field of the instance on - * which the method is called. - * - * @param x the x coordinate - * @param y the y coordinate - */ - public PCPointSingleFieldInteger(int x, int y) { - this.x = x; - this.y = Integer.valueOf(y); - } + public int x; + public Integer y; - public void setX(int x) { - this.x = x; - } + /** + * This constructor is used by test cases checking assertion A7.12-38:
    + * For classes using single field identity method + * PersistenceCapable.newObjectIdInstance() must be called + * on a persistent instance with its primary key field initialized, + * or a JDOFatalInternalException is thrown. + */ + public PCPointSingleFieldInteger() { + this.id = null; + } - public int getX() { - return x; - } + /** + * This constructor is used by test cases checking assertion A7.12-39:
    + * The instance returned is initialized with the value of the primary key + * field of the instance on which the method is called. + * @param x the x coordinate + * @param y the y coordinate + */ + public PCPointSingleFieldInteger(int x, int y) { + this.x = x; + this.y = Integer.valueOf(y); + } - public void setY(Integer y) { - this.y = y; - } + public void setX(int x) { + this.x = x; + } - public Integer getY() { - return y; - } + public int getX() { + return x; + } - public String name() { - return " x: " + getX() + ", y: " + getY().intValue(); - } + public void setY(Integer y) { + this.y = y; + } - /** - * Returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - * - * @param singleFieldIdentity the single field identity to check. - * @return returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - */ - public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { - return this.id.intValue() == ((IntIdentity) singleFieldIdentity).getKey(); - } + public Integer getY() { + return y; + } + + public String name() { + return " x: " + getX() + ", y: " + getY().intValue(); + } - public String toString() { - return super.toString() + this.id; - } + /** + * Returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + * @param singleFieldIdentity the single field identity to check. + * @return returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + */ + public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { + return this.id.intValue()==((IntIdentity)singleFieldIdentity).getKey(); + } + + public String toString() { + return super.toString() + this.id; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldLong.java b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldLong.java index fbdc6d884..a3c5c95fd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldLong.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldLong.java @@ -5,16 +5,16 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.singlefieldidentity; import javax.jdo.identity.LongIdentity; @@ -22,84 +22,85 @@ /** * The PC class for testing LongIdentity. - * * @author Michael Watzek */ public class PCPointSingleFieldLong extends AbstractPCPointSingleField { - - /** - * Returns a unique value, used for primary key field initialization. - * - * @return a unique value - */ - private static long newId() { - synchronized (PCPointSingleFieldLong.class) { - return counter++; + + /** + * Returns a unique value, used for primary key field initialization. + * @return a unique value + */ + private static long newId() { + synchronized (PCPointSingleFieldLong.class) { + return counter++; + } } - } - - /** The primary key field. */ - private Long id = Long.valueOf(newId()); - - public int x; - public Integer y; - /** - * This constructor is used by test cases checking assertion A7.12-38:
    - * For classes using single field identity method PersistenceCapable.newObjectIdInstance() - * must be called on a persistent instance with its primary key field initialized, or a - * JDOFatalInternalException is thrown. - */ - public PCPointSingleFieldLong() { - this.id = null; - } + /** + * The primary key field. + */ + private Long id = Long.valueOf(newId()); - /** - * This constructor is used by test cases checking assertion A7.12-39:
    - * The instance returned is initialized with the value of the primary key field of the instance on - * which the method is called. - * - * @param x the x coordinate - * @param y the y coordinate - */ - public PCPointSingleFieldLong(int x, int y) { - this.x = x; - this.y = Integer.valueOf(y); - } + public int x; + public Integer y; - public void setX(int x) { - this.x = x; - } + /** + * This constructor is used by test cases checking assertion A7.12-38:
    + * For classes using single field identity method + * PersistenceCapable.newObjectIdInstance() must be called + * on a persistent instance with its primary key field initialized, + * or a JDOFatalInternalException is thrown. + */ + public PCPointSingleFieldLong() { + this.id = null; + } - public int getX() { - return x; - } + /** + * This constructor is used by test cases checking assertion A7.12-39:
    + * The instance returned is initialized with the value of the primary key + * field of the instance on which the method is called. + * @param x the x coordinate + * @param y the y coordinate + */ + public PCPointSingleFieldLong(int x, int y) { + this.x = x; + this.y = Integer.valueOf(y); + } - public void setY(Integer y) { - this.y = y; - } + public void setX(int x) { + this.x = x; + } - public Integer getY() { - return y; - } + public int getX() { + return x; + } - public String name() { - return " x: " + getX() + ", y: " + getY().intValue(); - } + public void setY(Integer y) { + this.y = y; + } - /** - * Returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - * - * @param singleFieldIdentity the single field identity to check. - * @return returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - */ - public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { - return this.id.longValue() == ((LongIdentity) singleFieldIdentity).getKey(); - } + public Integer getY() { + return y; + } + + public String name() { + return " x: " + getX() + ", y: " + getY().intValue(); + } - public String toString() { - return super.toString() + this.id; - } + /** + * Returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + * @param singleFieldIdentity the single field identity to check. + * @return returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + */ + public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { + return this.id.longValue()==((LongIdentity)singleFieldIdentity).getKey(); + } + + public String toString() { + return super.toString() + this.id; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitivebyte.java b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitivebyte.java index 2bc6bded2..d02e9f449 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitivebyte.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitivebyte.java @@ -5,16 +5,16 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.singlefieldidentity; import javax.jdo.identity.ByteIdentity; @@ -22,74 +22,74 @@ /** * The PC class for testing ByteIdentity. - * * @author Michael Watzek */ public class PCPointSingleFieldPrimitivebyte extends AbstractPCPointSingleField { - - /** - * Returns a unique value, used for primary key field initialization. - * - * @return a unique value - */ - private static byte newId() { - synchronized (PCPointSingleFieldPrimitivebyte.class) { - return (byte) ((counter++) % Byte.MAX_VALUE); + + /** + * Returns a unique value, used for primary key field initialization. + * @return a unique value + */ + private static byte newId() { + synchronized (PCPointSingleFieldPrimitivebyte.class) { + return (byte) ((counter++) % Byte.MAX_VALUE); + } } - } - - /** The primary key field. */ - private byte id = newId(); - public int x; - public Integer y; + /** + * The primary key field. + */ + private byte id = newId(); - /** - * This constructor is used by test cases checking assertion A7.12-39:
    - * The instance returned is initialized with the value of the primary key field of the instance on - * which the method is called. - * - * @param x the x coordinate - * @param y the y coordinate - */ - public PCPointSingleFieldPrimitivebyte(int x, int y) { - this.x = x; - this.y = Integer.valueOf(y); - } + public int x; + public Integer y; - public void setX(int x) { - this.x = x; - } - - public int getX() { - return x; - } + /** + * This constructor is used by test cases checking assertion A7.12-39:
    + * The instance returned is initialized with the value of the primary key + * field of the instance on which the method is called. + * @param x the x coordinate + * @param y the y coordinate + */ + public PCPointSingleFieldPrimitivebyte(int x, int y) { + this.x = x; + this.y = Integer.valueOf(y); + } - public void setY(Integer y) { - this.y = y; - } + public void setX(int x) { + this.x = x; + } - public Integer getY() { - return y; - } + public int getX() { + return x; + } - public String name() { - return " x: " + getX() + ", y: " + getY().intValue(); - } + public void setY(Integer y) { + this.y = y; + } - /** - * Returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - * - * @param singleFieldIdentity the single field identity to check. - * @return returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - */ - public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { - return this.id == ((ByteIdentity) singleFieldIdentity).getKey(); - } + public Integer getY() { + return y; + } + + public String name() { + return " x: " + getX() + ", y: " + getY().intValue(); + } - public String toString() { - return super.toString() + this.id; - } + /** + * Returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + * @param singleFieldIdentity the single field identity to check. + * @return returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + */ + public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { + return this.id==((ByteIdentity)singleFieldIdentity).getKey(); + } + + public String toString() { + return super.toString() + this.id; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitivechar.java b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitivechar.java index f76745e9d..09a4a44e3 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitivechar.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitivechar.java @@ -5,16 +5,16 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.singlefieldidentity; import javax.jdo.identity.CharIdentity; @@ -22,74 +22,74 @@ /** * The PC class for testing CharIdentity. - * * @author Michael Watzek */ public class PCPointSingleFieldPrimitivechar extends AbstractPCPointSingleField { - - /** - * Returns a unique value, used for primary key field initialization. - * - * @return a unique value - */ - private static char newId() { - synchronized (PCPointSingleFieldPrimitivechar.class) { - return (char) ((counter++) % Character.MAX_VALUE); + + /** + * Returns a unique value, used for primary key field initialization. + * @return a unique value + */ + private static char newId() { + synchronized (PCPointSingleFieldPrimitivechar.class) { + return (char) ((counter++) % Character.MAX_VALUE); + } } - } - - /** The primary key field. */ - private char id = newId(); - public int x; - public Integer y; + /** + * The primary key field. + */ + private char id = newId(); - /** - * This constructor is used by test cases checking assertion A7.12-39:
    - * The instance returned is initialized with the value of the primary key field of the instance on - * which the method is called. - * - * @param x the x coordinate - * @param y the y coordinate - */ - public PCPointSingleFieldPrimitivechar(int x, int y) { - this.x = x; - this.y = Integer.valueOf(y); - } + public int x; + public Integer y; - public void setX(int x) { - this.x = x; - } - - public int getX() { - return x; - } + /** + * This constructor is used by test cases checking assertion A7.12-39:
    + * The instance returned is initialized with the value of the primary key + * field of the instance on which the method is called. + * @param x the x coordinate + * @param y the y coordinate + */ + public PCPointSingleFieldPrimitivechar(int x, int y) { + this.x = x; + this.y = Integer.valueOf(y); + } - public void setY(Integer y) { - this.y = y; - } + public void setX(int x) { + this.x = x; + } - public Integer getY() { - return y; - } + public int getX() { + return x; + } - public String name() { - return " x: " + getX() + ", y: " + getY().intValue(); - } + public void setY(Integer y) { + this.y = y; + } - /** - * Returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - * - * @param singleFieldIdentity the single field identity to check. - * @return returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - */ - public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { - return this.id == ((CharIdentity) singleFieldIdentity).getKey(); - } + public Integer getY() { + return y; + } + + public String name() { + return " x: " + getX() + ", y: " + getY().intValue(); + } - public String toString() { - return super.toString() + this.id; - } + /** + * Returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + * @param singleFieldIdentity the single field identity to check. + * @return returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + */ + public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { + return this.id==((CharIdentity)singleFieldIdentity).getKey(); + } + + public String toString() { + return super.toString() + this.id; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitiveint.java b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitiveint.java index ee83a892a..061b0f6ea 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitiveint.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitiveint.java @@ -5,16 +5,16 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.singlefieldidentity; import javax.jdo.identity.IntIdentity; @@ -22,74 +22,74 @@ /** * The PC class for testing IntIdentity. - * * @author Michael Watzek */ public class PCPointSingleFieldPrimitiveint extends AbstractPCPointSingleField { - - /** - * Returns a unique value, used for primary key field initialization. - * - * @return a unique value - */ - private static int newId() { - synchronized (PCPointSingleFieldPrimitiveint.class) { - return (int) ((counter++) % Integer.MAX_VALUE); + + /** + * Returns a unique value, used for primary key field initialization. + * @return a unique value + */ + private static int newId() { + synchronized (PCPointSingleFieldPrimitiveint.class) { + return (int) ((counter++) % Integer.MAX_VALUE); + } } - } - - /** The primary key field. */ - private int id = newId(); - public int x; - public Integer y; + /** + * The primary key field. + */ + private int id = newId(); - /** - * This constructor is used by test cases checking assertion A7.12-39:
    - * The instance returned is initialized with the value of the primary key field of the instance on - * which the method is called. - * - * @param x the x coordinate - * @param y the y coordinate - */ - public PCPointSingleFieldPrimitiveint(int x, int y) { - this.x = x; - this.y = Integer.valueOf(y); - } + public int x; + public Integer y; - public void setX(int x) { - this.x = x; - } - - public int getX() { - return x; - } + /** + * This constructor is used by test cases checking assertion A7.12-39:
    + * The instance returned is initialized with the value of the primary key + * field of the instance on which the method is called. + * @param x the x coordinate + * @param y the y coordinate + */ + public PCPointSingleFieldPrimitiveint(int x, int y) { + this.x = x; + this.y = Integer.valueOf(y); + } - public void setY(Integer y) { - this.y = y; - } + public void setX(int x) { + this.x = x; + } - public Integer getY() { - return y; - } + public int getX() { + return x; + } - public String name() { - return " x: " + getX() + ", y: " + getY().intValue(); - } + public void setY(Integer y) { + this.y = y; + } - /** - * Returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - * - * @param singleFieldIdentity the single field identity to check. - * @return returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - */ - public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { - return this.id == ((IntIdentity) singleFieldIdentity).getKey(); - } + public Integer getY() { + return y; + } + + public String name() { + return " x: " + getX() + ", y: " + getY().intValue(); + } - public String toString() { - return super.toString() + this.id; - } + /** + * Returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + * @param singleFieldIdentity the single field identity to check. + * @return returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + */ + public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { + return this.id==((IntIdentity)singleFieldIdentity).getKey(); + } + + public String toString() { + return super.toString() + this.id; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitivelong.java b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitivelong.java index 02d931ff9..c5c71ca51 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitivelong.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitivelong.java @@ -5,16 +5,16 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.singlefieldidentity; import javax.jdo.identity.LongIdentity; @@ -22,74 +22,74 @@ /** * The PC class for testing LongIdentity. - * * @author Michael Watzek */ public class PCPointSingleFieldPrimitivelong extends AbstractPCPointSingleField { - - /** - * Returns a unique value, used for primary key field initialization. - * - * @return a unique value - */ - private static long newId() { - synchronized (PCPointSingleFieldPrimitivelong.class) { - return counter++; + + /** + * Returns a unique value, used for primary key field initialization. + * @return a unique value + */ + private static long newId() { + synchronized (PCPointSingleFieldPrimitivelong.class) { + return counter++; + } } - } - - /** The primary key field. */ - private long id = newId(); - public int x; - public Integer y; + /** + * The primary key field. + */ + private long id = newId(); - /** - * This constructor is used by test cases checking assertion A7.12-39:
    - * The instance returned is initialized with the value of the primary key field of the instance on - * which the method is called. - * - * @param x the x coordinate - * @param y the y coordinate - */ - public PCPointSingleFieldPrimitivelong(int x, int y) { - this.x = x; - this.y = Integer.valueOf(y); - } + public int x; + public Integer y; - public void setX(int x) { - this.x = x; - } - - public int getX() { - return x; - } + /** + * This constructor is used by test cases checking assertion A7.12-39:
    + * The instance returned is initialized with the value of the primary key + * field of the instance on which the method is called. + * @param x the x coordinate + * @param y the y coordinate + */ + public PCPointSingleFieldPrimitivelong(int x, int y) { + this.x = x; + this.y = Integer.valueOf(y); + } - public void setY(Integer y) { - this.y = y; - } + public void setX(int x) { + this.x = x; + } - public Integer getY() { - return y; - } + public int getX() { + return x; + } - public String name() { - return " x: " + getX() + ", y: " + getY().intValue(); - } + public void setY(Integer y) { + this.y = y; + } - /** - * Returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - * - * @param singleFieldIdentity the single field identity to check. - * @return returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - */ - public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { - return this.id == ((LongIdentity) singleFieldIdentity).getKey(); - } + public Integer getY() { + return y; + } + + public String name() { + return " x: " + getX() + ", y: " + getY().intValue(); + } - public String toString() { - return super.toString() + this.id; - } + /** + * Returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + * @param singleFieldIdentity the single field identity to check. + * @return returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + */ + public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { + return this.id==((LongIdentity)singleFieldIdentity).getKey(); + } + + public String toString() { + return super.toString() + this.id; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitiveshort.java b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitiveshort.java index 9d9e0c52e..052941f94 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitiveshort.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitiveshort.java @@ -5,16 +5,16 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.singlefieldidentity; import javax.jdo.identity.ShortIdentity; @@ -22,74 +22,74 @@ /** * The PC class for testing ShortIdentity. - * * @author Michael Watzek */ public class PCPointSingleFieldPrimitiveshort extends AbstractPCPointSingleField { - - /** - * Returns a unique value, used for primary key field initialization. - * - * @return a unique value - */ - private static short newId() { - synchronized (PCPointSingleFieldPrimitiveshort.class) { - return (short) ((counter++) % Short.MAX_VALUE); + + /** + * Returns a unique value, used for primary key field initialization. + * @return a unique value + */ + private static short newId() { + synchronized (PCPointSingleFieldPrimitiveshort.class) { + return (short) ((counter++) % Short.MAX_VALUE); + } } - } - - /** The primary key field. */ - private short id = newId(); - public int x; - public Integer y; + /** + * The primary key field. + */ + private short id = newId(); - /** - * This constructor is used by test cases checking assertion A7.12-39:
    - * The instance returned is initialized with the value of the primary key field of the instance on - * which the method is called. - * - * @param x the x coordinate - * @param y the y coordinate - */ - public PCPointSingleFieldPrimitiveshort(int x, int y) { - this.x = x; - this.y = Integer.valueOf(y); - } + public int x; + public Integer y; - public void setX(int x) { - this.x = x; - } - - public int getX() { - return x; - } + /** + * This constructor is used by test cases checking assertion A7.12-39:
    + * The instance returned is initialized with the value of the primary key + * field of the instance on which the method is called. + * @param x the x coordinate + * @param y the y coordinate + */ + public PCPointSingleFieldPrimitiveshort(int x, int y) { + this.x = x; + this.y = Integer.valueOf(y); + } - public void setY(Integer y) { - this.y = y; - } + public void setX(int x) { + this.x = x; + } - public Integer getY() { - return y; - } + public int getX() { + return x; + } - public String name() { - return " x: " + getX() + ", y: " + getY().intValue(); - } + public void setY(Integer y) { + this.y = y; + } - /** - * Returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - * - * @param singleFieldIdentity the single field identity to check. - * @return returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - */ - public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { - return this.id == ((ShortIdentity) singleFieldIdentity).getKey(); - } + public Integer getY() { + return y; + } + + public String name() { + return " x: " + getX() + ", y: " + getY().intValue(); + } - public String toString() { - return super.toString() + this.id; - } + /** + * Returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + * @param singleFieldIdentity the single field identity to check. + * @return returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + */ + public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { + return this.id==((ShortIdentity)singleFieldIdentity).getKey(); + } + + public String toString() { + return super.toString() + this.id; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldShort.java b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldShort.java index 7ff467d52..6b5d3269f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldShort.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldShort.java @@ -5,16 +5,16 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.singlefieldidentity; import javax.jdo.identity.ShortIdentity; @@ -22,84 +22,85 @@ /** * The PC class for testing ShortIdentity. - * * @author Michael Watzek */ public class PCPointSingleFieldShort extends AbstractPCPointSingleField { - - /** - * Returns a unique value, used for primary key field initialization. - * - * @return a unique value - */ - private static short newId() { - synchronized (PCPointSingleFieldShort.class) { - return (short) ((counter++) % Short.MAX_VALUE); + + /** + * Returns a unique value, used for primary key field initialization. + * @return a unique value + */ + private static short newId() { + synchronized (PCPointSingleFieldShort.class) { + return (short) ((counter++) % Short.MAX_VALUE); + } } - } - - /** The primary key field. */ - private Short id = Short.valueOf(newId()); - - public int x; - public Integer y; - /** - * This constructor is used by test cases checking assertion A7.12-38:
    - * For classes using single field identity method PersistenceCapable.newObjectIdInstance() - * must be called on a persistent instance with its primary key field initialized, or a - * JDOFatalInternalException is thrown. - */ - public PCPointSingleFieldShort() { - this.id = null; - } + /** + * The primary key field. + */ + private Short id = Short.valueOf(newId()); - /** - * This constructor is used by test cases checking assertion A7.12-39:
    - * The instance returned is initialized with the value of the primary key field of the instance on - * which the method is called. - * - * @param x the x coordinate - * @param y the y coordinate - */ - public PCPointSingleFieldShort(int x, int y) { - this.x = x; - this.y = Integer.valueOf(y); - } + public int x; + public Integer y; - public void setX(int x) { - this.x = x; - } + /** + * This constructor is used by test cases checking assertion A7.12-38:
    + * For classes using single field identity method + * PersistenceCapable.newObjectIdInstance() must be called + * on a persistent instance with its primary key field initialized, + * or a JDOFatalInternalException is thrown. + */ + public PCPointSingleFieldShort() { + this.id = null; + } - public int getX() { - return x; - } + /** + * This constructor is used by test cases checking assertion A7.12-39:
    + * The instance returned is initialized with the value of the primary key + * field of the instance on which the method is called. + * @param x the x coordinate + * @param y the y coordinate + */ + public PCPointSingleFieldShort(int x, int y) { + this.x = x; + this.y = Integer.valueOf(y); + } - public void setY(Integer y) { - this.y = y; - } + public void setX(int x) { + this.x = x; + } - public Integer getY() { - return y; - } + public int getX() { + return x; + } - public String name() { - return " x: " + getX() + ", y: " + getY().intValue(); - } + public void setY(Integer y) { + this.y = y; + } - /** - * Returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - * - * @param singleFieldIdentity the single field identity to check. - * @return returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - */ - public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { - return this.id.shortValue() == ((ShortIdentity) singleFieldIdentity).getKey(); - } + public Integer getY() { + return y; + } + + public String name() { + return " x: " + getX() + ", y: " + getY().intValue(); + } - public String toString() { - return super.toString() + this.id; - } + /** + * Returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + * @param singleFieldIdentity the single field identity to check. + * @return returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + */ + public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { + return this.id.shortValue()==((ShortIdentity)singleFieldIdentity).getKey(); + } + + public String toString() { + return super.toString() + this.id; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldString.java b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldString.java index 68071547b..2aa42b18a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldString.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldString.java @@ -5,16 +5,16 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.singlefieldidentity; import javax.jdo.identity.SingleFieldIdentity; @@ -22,84 +22,85 @@ /** * The PC class for testing StringIdentity. - * * @author Michael Watzek */ public class PCPointSingleFieldString extends AbstractPCPointSingleField { - - /** - * Returns a unique value, used for primary key field initialization. - * - * @return a unique value - */ - private static long newId() { - synchronized (PCPointSingleFieldString.class) { - return counter++; + + /** + * Returns a unique value, used for primary key field initialization. + * @return a unique value + */ + private static long newId() { + synchronized (PCPointSingleFieldString.class) { + return counter++; + } } - } - - /** The primary key field. */ - private String id = Long.toString(newId()); - - public int x; - public Integer y; - /** - * This constructor is used by test cases checking assertion A7.12-38:
    - * For classes using single field identity method PersistenceCapable.newObjectIdInstance() - * must be called on a persistent instance with its primary key field initialized, or a - * JDOFatalInternalException is thrown. - */ - public PCPointSingleFieldString() { - this.id = null; - } + /** + * The primary key field. + */ + private String id = Long.toString(newId()); - /** - * This constructor is used by test cases checking assertion A7.12-39:
    - * The instance returned is initialized with the value of the primary key field of the instance on - * which the method is called. - * - * @param x the x coordinate - * @param y the y coordinate - */ - public PCPointSingleFieldString(int x, int y) { - this.x = x; - this.y = Integer.valueOf(y); - } + public int x; + public Integer y; - public void setX(int x) { - this.x = x; - } + /** + * This constructor is used by test cases checking assertion A7.12-38:
    + * For classes using single field identity method + * PersistenceCapable.newObjectIdInstance() must be called + * on a persistent instance with its primary key field initialized, + * or a JDOFatalInternalException is thrown. + */ + public PCPointSingleFieldString() { + this.id = null; + } - public int getX() { - return x; - } + /** + * This constructor is used by test cases checking assertion A7.12-39:
    + * The instance returned is initialized with the value of the primary key + * field of the instance on which the method is called. + * @param x the x coordinate + * @param y the y coordinate + */ + public PCPointSingleFieldString(int x, int y) { + this.x = x; + this.y = Integer.valueOf(y); + } - public void setY(Integer y) { - this.y = y; - } + public void setX(int x) { + this.x = x; + } - public Integer getY() { - return y; - } + public int getX() { + return x; + } - public String name() { - return " x: " + getX() + ", y: " + getY().intValue(); - } + public void setY(Integer y) { + this.y = y; + } - /** - * Returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - * - * @param singleFieldIdentity the single field identity to check. - * @return returns true if the given the key of the given SingleFieldIdentity - * instance equals the key in the subclass of this class. - */ - public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { - return this.id.equals(((StringIdentity) singleFieldIdentity).getKey()); - } + public Integer getY() { + return y; + } + + public String name() { + return " x: " + getX() + ", y: " + getY().intValue(); + } - public String toString() { - return super.toString() + this.id; - } + /** + * Returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + * @param singleFieldIdentity the single field identity to check. + * @return returns true if the given the key of the given + * SingleFieldIdentity instance equals the key in the subclass + * of this class. + */ + public boolean equalsPKField(SingleFieldIdentity singleFieldIdentity) { + return this.id.equals(((StringIdentity)singleFieldIdentity).getKey()); + } + + public String toString() { + return super.toString() + this.id; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PartTimeEmployee.java b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PartTimeEmployee.java index b5890ff85..64f5e35d9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PartTimeEmployee.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/PartTimeEmployee.java @@ -5,85 +5,83 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.singlefieldidentity; import java.util.Date; -/** This class represents a part-time employee. */ +/** + * This class represents a part-time employee. + */ public class PartTimeEmployee extends Employee { - private double wage; + private double wage; + + /** This is the JDO-required no-args constructor. The TCK relies on + * this constructor for testing PersistenceManager.newInstance(PCClass). + */ + public PartTimeEmployee() {} - /** - * This is the JDO-required no-args constructor. The TCK relies on this constructor for testing - * PersistenceManager.newInstance(PCClass). - */ - public PartTimeEmployee() {} + /** + * Construct a part-time employee. + * @param personid The identifier for the person. + * @param first The person's first name. + * @param last The person's last name. + * @param middle The person's middle name. + * @param born The person's birthdate. + * @param hired The date the person was hired. + * @param wage The person's wage. + */ + public PartTimeEmployee(long personid, String first, String last, + String middle, Date born, + Date hired, double wage ) { + super(personid, first, last, middle, born, hired); + this.wage = wage; + } - /** - * Construct a part-time employee. - * - * @param personid The identifier for the person. - * @param first The person's first name. - * @param last The person's last name. - * @param middle The person's middle name. - * @param born The person's birthdate. - * @param hired The date the person was hired. - * @param wage The person's wage. - */ - public PartTimeEmployee( - long personid, String first, String last, String middle, Date born, Date hired, double wage) { - super(personid, first, last, middle, born, hired); - this.wage = wage; - } + /** + * Get the wage of the part-time employee. + * @return The wage of the part-time employee. + */ + public double getWage() { + return wage; + } - /** - * Get the wage of the part-time employee. - * - * @return The wage of the part-time employee. - */ - public double getWage() { - return wage; - } + /** + * Set the wage of the part-time employee. + * @param wage The wage of the part-time employee. + */ + public void setWage(double wage) { + this.wage = wage; + } - /** - * Set the wage of the part-time employee. - * - * @param wage The wage of the part-time employee. - */ - public void setWage(double wage) { - this.wage = wage; - } + /** + * Returns a String representation of a PartTimeEmployee object. + * @return a String representation of a PartTimeEmployee object. + */ + @Override + public String toString() { + return "PartTimeEmployee(" + getFieldRepr() + ")"; + } - /** - * Returns a String representation of a PartTimeEmployee object. - * - * @return a String representation of a PartTimeEmployee object. - */ - @Override - public String toString() { - return "PartTimeEmployee(" + getFieldRepr() + ")"; - } + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + @Override + public String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(super.getFieldRepr()); + rc.append(", $" + wage); + return rc.toString(); + } - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - @Override - public String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(super.getFieldRepr()); - rc.append(", $" + wage); - return rc.toString(); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/Person.java b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/Person.java index 2a71804e3..994a84bcd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/Person.java +++ b/tck/src/main/java/org/apache/jdo/tck/pc/singlefieldidentity/Person.java @@ -5,166 +5,163 @@ * 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 - * + * * https://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 + * + * 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.jdo.tck.pc.singlefieldidentity; import java.io.Serializable; + import java.text.SimpleDateFormat; + import java.util.Date; -/** This class represents a person. */ -public class Person implements Serializable { - - private long id; - private String firstname; - private String lastname; - private String middlename; - private Date birthdate; - - protected static SimpleDateFormat formatter = new SimpleDateFormat("d/MMM/yyyy"); - - /** This is the JDO-required no-args constructor. */ - protected Person() {} - - /** - * Construct a Person instance. - * - * @param personid The person identifier. - * @param firstname The person's first name. - * @param lastname The person's last name. - * @param middlename The person's middle name. - * @param birthdate The person's birthdate. - */ - public Person( - long personid, String firstname, String lastname, String middlename, Date birthdate) { - this.id = personid; - this.firstname = firstname; - this.lastname = lastname; - this.middlename = middlename; - this.birthdate = birthdate; - } - - /** - * Set the id associated with this object. - * - * @param id the id. - */ - public void setPersonid(long id) { - if (this.id != 0) throw new IllegalStateException("Id is already set."); - this.id = id; - } - - /** - * Get the person's id. - * - * @return The id. - */ - public long getPersonid() { - return id; - } - - /** - * Get the person's last name. - * - * @return The last name. - */ - public String getLastname() { - return lastname; - } - - /** - * Set the person's last name. - * - * @param lastname The last name. - */ - public void setLastname(String lastname) { - this.lastname = lastname; - } - - /** - * Get the person's first name. - * - * @return The first name. - */ - public String getFirstname() { - return firstname; - } - - /** - * Set the person's first name. - * - * @param firstname The first name. - */ - public void setFirstname(String firstname) { - this.firstname = firstname; - } - - /** - * Get the person's middle name. - * - * @return The middle name. - */ - public String getMiddlename() { - return middlename; - } - - /** - * Set the person's middle name. - * - * @param middlename The middle name. - */ - public void setMiddlename(String middlename) { - this.middlename = middlename; - } - - /** - * Get the person's birthdate. - * - * @return The person's birthdate. - */ - public Date getBirthdate() { - return birthdate; - } - - /** - * Set the person's birthdate. - * - * @param birthdate The person's birthdate. - */ - public void setBirthdate(Date birthdate) { - this.birthdate = birthdate; - } - - /** - * Returns a String representation of a Person object. - * - * @return a string representation of a Person object. - */ - @Override - public String toString() { - return "Person(" + getFieldRepr() + ")"; - } - - /** - * Returns a String representation of the non-relationship fields. - * - * @return a String representation of the non-relationship fields. - */ - protected String getFieldRepr() { - StringBuffer rc = new StringBuffer(); - rc.append(id); - rc.append(", ").append(lastname); - rc.append(", ").append(firstname); - rc.append(", born ").append(birthdate == null ? "null" : formatter.format(birthdate)); - return rc.toString(); - } +/** + * This class represents a person. + */ +public class Person + implements Serializable { + + private long id; + private String firstname; + private String lastname; + private String middlename; + private Date birthdate; + + protected static SimpleDateFormat formatter = + new SimpleDateFormat("d/MMM/yyyy"); + + /** This is the JDO-required no-args constructor. */ + protected Person() {} + + /** + * Construct a Person instance. + * @param personid The person identifier. + * @param firstname The person's first name. + * @param lastname The person's last name. + * @param middlename The person's middle name. + * @param birthdate The person's birthdate. + */ + public Person(long personid, String firstname, String lastname, + String middlename, Date birthdate) { + this.id = personid; + this.firstname = firstname; + this.lastname = lastname; + this.middlename = middlename; + this.birthdate = birthdate; + } + + /** + * Set the id associated with this object. + * @param id the id. + */ + public void setPersonid(long id) { + if (this.id != 0) + throw new IllegalStateException("Id is already set."); + this.id = id; + } + + /** + * Get the person's id. + * @return The id. + */ + public long getPersonid() { + return id; + } + + /** + * Get the person's last name. + * @return The last name. + */ + public String getLastname() { + return lastname; + } + + /** + * Set the person's last name. + * @param lastname The last name. + */ + public void setLastname(String lastname) { + this.lastname = lastname; + } + + /** + * Get the person's first name. + * @return The first name. + */ + public String getFirstname() { + return firstname; + } + + /** + * Set the person's first name. + * @param firstname The first name. + */ + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + /** + * Get the person's middle name. + * @return The middle name. + */ + public String getMiddlename() { + return middlename; + } + + /** + * Set the person's middle name. + * @param middlename The middle name. + */ + public void setMiddlename(String middlename) { + this.middlename = middlename; + } + + /** + * Get the person's birthdate. + * @return The person's birthdate. + */ + public Date getBirthdate() { + return birthdate; + } + + /** + * Set the person's birthdate. + * @param birthdate The person's birthdate. + */ + public void setBirthdate(Date birthdate) { + this. birthdate = birthdate; + } + + /** + * Returns a String representation of a Person object. + * @return a string representation of a Person object. + */ + @Override + public String toString() { + return "Person(" + getFieldRepr() + ")"; + } + + /** + * Returns a String representation of the non-relationship fields. + * @return a String representation of the non-relationship fields. + */ + protected String getFieldRepr() { + StringBuffer rc = new StringBuffer(); + rc.append(id); + rc.append(", ").append(lastname); + rc.append(", ").append(firstname); + rc.append(", born ").append( + birthdate==null ? "null" : formatter.format(birthdate)); + return rc.toString(); + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/QueryElementHolder.java b/tck/src/main/java/org/apache/jdo/tck/query/QueryElementHolder.java index dc69d4062..76cbd1f0f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/QueryElementHolder.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/QueryElementHolder.java @@ -5,448 +5,428 @@ * 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 + * + * 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.jdo.tck.query; -import java.util.Map; import javax.jdo.Extent; import javax.jdo.JDOQLTypedQuery; import javax.jdo.PersistenceManager; import javax.jdo.Query; +import java.util.Map; /** - * This class is an abstraction of a JDOQL query, which may be represented as a single string (e.g. - * SELECT FROM Person WHERE personid == 1) or as an API query using methods on class - * {@link Query}. - * - *

    The class may be used as the factory of a JDO {@link Query} instance using method {@link - * QueryElementHolder#getAPIQuery(PersistenceManager)} or method {@link - * QueryElementHolder#getSingleStringQuery(PersistenceManager)}. - * - *

    Instances of this class are capable to hold all elements of a JDOQL query, e.g. the candidate - * class, the filter, etc. These elements are passed calling the constructor. It is valid to pass - * null as a value for JDOQL querys elements. Such elements are not transfered into a - * JDO {@link javax.jdo.Query} instance. Instead, the default of JDO {@link javax.jdo.Query} - * instance is taken. + * This class is an abstraction of a JDOQL query, + * which may be represented as a single string + * (e.g. SELECT FROM Person WHERE personid == 1) or + * as an API query using methods on class {@link Query}.

    + * + * The class may be used as the factory of a JDO {@link Query} instance + * using method {@link QueryElementHolder#getAPIQuery(PersistenceManager)} or + * method {@link QueryElementHolder#getSingleStringQuery(PersistenceManager)}.

    + * + * Instances of this class are capable to hold all elements of a JDOQL query, + * e.g. the candidate class, the filter, etc. These elements are passed + * calling the constructor. It is valid to pass null as a value + * for JDOQL querys elements. Such elements are not transfered into a + * JDO {@link javax.jdo.Query} instance. + * Instead, the default of JDO {@link javax.jdo.Query} instance is taken. */ public class QueryElementHolder { - // fields holding JDOQL query elements - private Boolean unique; - private String result; - private Class resultClass; - private Class candidateClass; - private Boolean excludeSubClasses; - private String filter; - private String variables; - private String parameters; - private String imports; - private String grouping; - private String ordering; - private String fromString; - private String toString; - private Long fromLong; - private Long toLong; - private JDOQLTypedQuery jdoqlTypedQuery; - private Map paramValues; - - /** - * Returns an instance of this class holding the given arguments such as the candidate class, the - * filter, etc. The given arguments represent JDOQL query elements. It is valid to pass null - * as a value for JDOQL querys elements. Such elements are not transfered into a JDO - * {@link javax.jdo.Query} instance. Instead, the default of JDO {@link javax.jdo.Query} instance - * is taken. - * - * @param unique the JDOQL unique query element - * @param result the JDOQL result query element - * @param resultClass the JDOQL result class query element - * @param candidateClass the JDOQL candidate class query element - * @param excludeSubClasses the JDOQL exclude subclasses query element - * @param filter the JDOQL filter query element - * @param variables the JDOQL variables query element - * @param parameters the JDOQL parameters query element - * @param imports the JDOQL imports query element - * @param grouping the JDOQL grouping query element - * @param ordering the JDOQL ordering query element - * @param from the JDOQL range from query element - * @param to the JDOQL range to query element - */ - public QueryElementHolder( - Boolean unique, - String result, - Class resultClass, - Class candidateClass, - Boolean excludeSubClasses, - String filter, - String variables, - String parameters, - String imports, - String grouping, - String ordering, - String from, - String to) { - if (from == null ^ to == null) { - throw new IllegalArgumentException( - "Arguments from and to must both be null, " + "or must not be null both."); + // fields holding JDOQL query elements + private Boolean unique; + private String result; + private Class resultClass; + private Class candidateClass; + private Boolean excludeSubClasses; + private String filter; + private String variables; + private String parameters; + private String imports; + private String grouping; + private String ordering; + private String fromString; + private String toString; + private Long fromLong; + private Long toLong; + private JDOQLTypedQuery jdoqlTypedQuery; + private Map paramValues; + + /** + * Returns an instance of this class holding the given arguments + * such as the candidate class, the filter, etc. + * The given arguments represent JDOQL query elements. + * It is valid to pass null as a value + * for JDOQL querys elements. Such elements are not transfered into a + * JDO {@link javax.jdo.Query} instance. + * Instead, the default of JDO {@link javax.jdo.Query} instance is taken. + * @param unique the JDOQL unique query element + * @param result the JDOQL result query element + * @param resultClass the JDOQL result class query element + * @param candidateClass the JDOQL candidate class query element + * @param excludeSubClasses the JDOQL exclude subclasses query element + * @param filter the JDOQL filter query element + * @param variables the JDOQL variables query element + * @param parameters the JDOQL parameters query element + * @param imports the JDOQL imports query element + * @param grouping the JDOQL grouping query element + * @param ordering the JDOQL ordering query element + * @param from the JDOQL range from query element + * @param to the JDOQL range to query element + */ + public QueryElementHolder(Boolean unique, String result, + Class resultClass, Class candidateClass, + Boolean excludeSubClasses, String filter, + String variables, String parameters, String imports, + String grouping, String ordering, String from, String to) { + if (from == null ^ to == null) { + throw new IllegalArgumentException( + "Arguments from and to must both be null, " + + "or must not be null both."); + } + this.unique = unique; + this.result = result; + this.resultClass = resultClass; + this.candidateClass = candidateClass; + this.excludeSubClasses = excludeSubClasses; + this.filter = filter; + this.variables = variables; + this.parameters = parameters; + this.imports = imports; + this.grouping = grouping; + this.ordering = ordering; + this.fromString = from; + this.toString = to; } - this.unique = unique; - this.result = result; - this.resultClass = resultClass; - this.candidateClass = candidateClass; - this.excludeSubClasses = excludeSubClasses; - this.filter = filter; - this.variables = variables; - this.parameters = parameters; - this.imports = imports; - this.grouping = grouping; - this.ordering = ordering; - this.fromString = from; - this.toString = to; - } - /** - * Returns an instance of this class holding the given arguments such as the candidate class, the - * filter, etc. The given arguments represent JDOQL query elements. It is valid to pass null - * as a value for JDOQL querys elements. Such elements are not transfered into a JDO - * {@link javax.jdo.Query} instance. Instead, the default of JDO {@link javax.jdo.Query} instance - * is taken. - * - * @param unique the JDOQL unique query element - * @param result the JDOQL result query element - * @param resultClass the JDOQL result class query element - * @param candidateClass the JDOQL candidate class query element - * @param excludeSubClasses the JDOQL exclude subclasses query element - * @param filter the JDOQL filter query element - * @param variables the JDOQL variables query element - * @param parameters the JDOQL parameters query element - * @param imports the JDOQL imports query element - * @param grouping the JDOQL grouping query element - * @param ordering the JDOQL ordering query element - * @param from the JDOQL range from query element - * @param to the JDOQL range to query element - * @param jdoqlTypedQuery the query instance - * @param paramValues the parameter values - */ - public QueryElementHolder( - Boolean unique, - String result, - Class resultClass, - Class candidateClass, - Boolean excludeSubClasses, - String filter, - String variables, - String parameters, - String imports, - String grouping, - String ordering, - String from, - String to, - JDOQLTypedQuery jdoqlTypedQuery, - Map paramValues) { - if (from == null ^ to == null) { - throw new IllegalArgumentException( - "Arguments from and to must both be null, " + "or must not be null both."); + /** + * Returns an instance of this class holding the given arguments + * such as the candidate class, the filter, etc. + * The given arguments represent JDOQL query elements. + * It is valid to pass null as a value + * for JDOQL querys elements. Such elements are not transfered into a + * JDO {@link javax.jdo.Query} instance. + * Instead, the default of JDO {@link javax.jdo.Query} instance is taken. + * @param unique the JDOQL unique query element + * @param result the JDOQL result query element + * @param resultClass the JDOQL result class query element + * @param candidateClass the JDOQL candidate class query element + * @param excludeSubClasses the JDOQL exclude subclasses query element + * @param filter the JDOQL filter query element + * @param variables the JDOQL variables query element + * @param parameters the JDOQL parameters query element + * @param imports the JDOQL imports query element + * @param grouping the JDOQL grouping query element + * @param ordering the JDOQL ordering query element + * @param from the JDOQL range from query element + * @param to the JDOQL range to query element + * @param jdoqlTypedQuery the query instance + * @param paramValues the parameter values + */ + public QueryElementHolder(Boolean unique, String result, + Class resultClass, Class candidateClass, + Boolean excludeSubClasses, String filter, + String variables, String parameters, String imports, + String grouping, String ordering, String from, String to, + JDOQLTypedQuery jdoqlTypedQuery, + Map paramValues) { + if (from == null ^ to == null) { + throw new IllegalArgumentException( + "Arguments from and to must both be null, " + + "or must not be null both."); + } + this.unique = unique; + this.result = result; + this.resultClass = resultClass; + this.candidateClass = candidateClass; + this.excludeSubClasses = excludeSubClasses; + this.filter = filter; + this.variables = variables; + this.parameters = parameters; + this.imports = imports; + this.grouping = grouping; + this.ordering = ordering; + this.fromString = from; + this.toString = to; + this.jdoqlTypedQuery = jdoqlTypedQuery; + this.paramValues = paramValues; } - this.unique = unique; - this.result = result; - this.resultClass = resultClass; - this.candidateClass = candidateClass; - this.excludeSubClasses = excludeSubClasses; - this.filter = filter; - this.variables = variables; - this.parameters = parameters; - this.imports = imports; - this.grouping = grouping; - this.ordering = ordering; - this.fromString = from; - this.toString = to; - this.jdoqlTypedQuery = jdoqlTypedQuery; - this.paramValues = paramValues; - } - - /** - * Returns an instance of this class holding the given arguments such as the candidate class, the - * filter, etc. The given arguments represent JDOQL query elements. It is valid to pass null - * as a value for JDOQL querys elements. Such elements are not transfered into a JDO - * {@link javax.jdo.Query} instance. Instead, the default of JDO {@link javax.jdo.Query} instance - * is taken. - * - * @param unique the JDOQL unique query element - * @param result the JDOQL result query element - * @param resultClass the JDOQL result class query element - * @param candidateClass the JDOQL candidate class query element - * @param excludeSubClasses the JDOQL exclude subclasses query element - * @param filter the JDOQL filter query element - * @param variables the JDOQL variables query element - * @param parameters the JDOQL parameters query element - * @param imports the JDOQL imports query element - * @param grouping the JDOQL grouping query element - * @param ordering the JDOQL ordering query element - * @param from the JDOQL from query element - * @param to the JDOQL to query element - * @param jdoqlTypedQuery the query instance - * @param paramValues the parameter values - */ - public QueryElementHolder( - Boolean unique, - String result, - Class resultClass, - Class candidateClass, - Boolean excludeSubClasses, - String filter, - String variables, - String parameters, - String imports, - String grouping, - String ordering, - long from, - long to, - JDOQLTypedQuery jdoqlTypedQuery, - Map paramValues) { - this.unique = unique; - this.result = result; - this.resultClass = resultClass; - this.candidateClass = candidateClass; - this.excludeSubClasses = excludeSubClasses; - this.filter = filter; - this.variables = variables; - this.parameters = parameters; - this.imports = imports; - this.grouping = grouping; - this.ordering = ordering; - this.fromLong = Long.valueOf(from); - this.toLong = Long.valueOf(to); - this.jdoqlTypedQuery = jdoqlTypedQuery; - this.paramValues = paramValues; - } - - /** - * Returns the single string JDOQL representation. - * - * @see Object#toString() - */ - public String toString() { - return "SELECT " - + toString("UNIQUE", this.unique) - + toString(this.result) - + toString("INTO", this.resultClass) - + toString("FROM", this.candidateClass) - + toString("EXCLUDE SUBCLASSES", this.excludeSubClasses) - + toString("WHERE", this.filter) - + toString("VARIABLES", this.variables) - + toString("PARAMETERS", this.parameters) - + toString(this.imports) - + toString("GROUP BY", this.grouping) - + toString("ORDER BY", this.ordering) - + rangeToString(); - } - /** - * Creates a JDO {@link javax.jdo.Query} instance using the JDOQL query elements of this instance. - * The returned instance is created calling {@link PersistenceManager#newQuery(String)}. The - * passed {@link String} instance is the single string representation of this, e.g. - * SELECT FROM Person WHERE personid == 1. - * - * @param pm the persistence manager - * @return the JDO query instance - */ - public Query getSingleStringQuery(PersistenceManager pm) { - return pm.newQuery(toString()); - } - - /** - * Creates a JDO {@link javax.jdo.Query} instance using the JDOQL query elements of this instance. - * The returned instance is created calling {@link PersistenceManager#newQuery(Extent)}. - * Afterwards, all query elements of this are transfered into that instance using API methods like - * {@link javax.jdo.Query#setFilter(java.lang.String)} etc. - * - * @param pm the persistence manager - * @return the JDO query instance - */ - public Query getAPIQuery(PersistenceManager pm) { - Extent extent = - this.excludeSubClasses != null - ? pm.getExtent(this.candidateClass, !this.excludeSubClasses.booleanValue()) - : pm.getExtent(this.candidateClass); - Query query = pm.newQuery(extent); - if (this.unique != null) { - query.setUnique(this.unique.booleanValue()); - } - if (this.result != null) { - query.setResult(this.result); + /** + * Returns an instance of this class holding the given arguments + * such as the candidate class, the filter, etc. + * The given arguments represent JDOQL query elements. + * It is valid to pass null as a value + * for JDOQL querys elements. Such elements are not transfered into a + * JDO {@link javax.jdo.Query} instance. + * Instead, the default of JDO {@link javax.jdo.Query} instance is taken. + * @param unique the JDOQL unique query element + * @param result the JDOQL result query element + * @param resultClass the JDOQL result class query element + * @param candidateClass the JDOQL candidate class query element + * @param excludeSubClasses the JDOQL exclude subclasses query element + * @param filter the JDOQL filter query element + * @param variables the JDOQL variables query element + * @param parameters the JDOQL parameters query element + * @param imports the JDOQL imports query element + * @param grouping the JDOQL grouping query element + * @param ordering the JDOQL ordering query element + * @param from the JDOQL from query element + * @param to the JDOQL to query element + * @param jdoqlTypedQuery the query instance + * @param paramValues the parameter values + */ + public QueryElementHolder(Boolean unique, String result, + Class resultClass, Class candidateClass, + Boolean excludeSubClasses, String filter, + String variables, String parameters, String imports, + String grouping, String ordering, long from, long to, + JDOQLTypedQuery jdoqlTypedQuery, + Map paramValues) { + this.unique = unique; + this.result = result; + this.resultClass = resultClass; + this.candidateClass = candidateClass; + this.excludeSubClasses = excludeSubClasses; + this.filter = filter; + this.variables = variables; + this.parameters = parameters; + this.imports = imports; + this.grouping = grouping; + this.ordering = ordering; + this.fromLong = Long.valueOf(from); + this.toLong = Long.valueOf(to); + this.jdoqlTypedQuery = jdoqlTypedQuery; + this.paramValues = paramValues; } - if (this.resultClass != null) { - query.setResultClass(this.resultClass); + + /** + * Returns the single string JDOQL representation. + * @see Object#toString() + */ + public String toString() { + return "SELECT " + + toString("UNIQUE", this.unique) + + toString(this.result) + + toString("INTO", this.resultClass) + + toString("FROM", this.candidateClass) + + toString("EXCLUDE SUBCLASSES", this.excludeSubClasses) + + toString("WHERE", this.filter) + + toString("VARIABLES", this.variables) + + toString("PARAMETERS", this.parameters) + + toString(this.imports) + + toString("GROUP BY", this.grouping) + + toString("ORDER BY", this.ordering) + + rangeToString(); } - if (this.filter != null) { - query.setFilter(this.filter); + + /** + * Creates a JDO {@link javax.jdo.Query} instance using the JDOQL query elements + * of this instance. The returned instance is created calling + * {@link PersistenceManager#newQuery(String)}. + * The passed {@link String} instance is the + * single string representation of this, + * e.g. SELECT FROM Person WHERE personid == 1. + * @param pm the persistence manager + * @return the JDO query instance + */ + public Query getSingleStringQuery(PersistenceManager pm) { + return pm.newQuery(toString()); } - if (this.variables != null) { - query.declareVariables(this.variables); + + /** + * Creates a JDO {@link javax.jdo.Query} instance using the JDOQL query elements + * of this instance. The returned instance is created calling + * {@link PersistenceManager#newQuery(Extent)}. + * Afterwards, all query elements of this are transfered + * into that instance using API methods like + * {@link javax.jdo.Query#setFilter(java.lang.String)} etc. + * @param pm the persistence manager + * @return the JDO query instance + */ + public Query getAPIQuery(PersistenceManager pm) { + Extent extent = this.excludeSubClasses != null ? + pm.getExtent(this.candidateClass, + !this.excludeSubClasses.booleanValue()) : + pm.getExtent(this.candidateClass); + Query query = pm.newQuery(extent); + if (this.unique != null) { + query.setUnique(this.unique.booleanValue()); + } + if (this.result != null ) { + query.setResult(this.result); + } + if (this.resultClass != null) { + query.setResultClass(this.resultClass); + } + if (this.filter != null) { + query.setFilter(this.filter); + } + if (this.variables != null) { + query.declareVariables(this.variables); + } + if (this.parameters != null) { + query.declareParameters(this.parameters); + } + if (this.imports != null ) { + query.declareImports(this.imports); + } + if (this.grouping != null) { + query.setGrouping(this.grouping); + } + if (this.ordering != null) { + query.setOrdering(this.ordering); + } + rangeToAPI(query); + return query; } - if (this.parameters != null) { - query.declareParameters(this.parameters); + + /** + * Returns the JDOQLTypedQuery instance. + * @return the JDOQLTypedQuery instance + */ + public JDOQLTypedQuery getJDOQLTypedQuery() { + if (this.jdoqlTypedQuery != null) { + this.rangeToJDOQLTypedQuery(this.jdoqlTypedQuery); + } + return this.jdoqlTypedQuery; } - if (this.imports != null) { - query.declareImports(this.imports); + + /** + * Returns the unique JDOQL query element. + * @return the unique JDOQL query element. + */ + public boolean isUnique() { + return this.unique != null && this.unique.booleanValue(); } - if (this.grouping != null) { - query.setGrouping(this.grouping); + + /** + * Returns the unique JDOQL query element. + * @return the unique JDOQL query element. + */ + public boolean hasOrdering() { + return this.ordering != null; } - if (this.ordering != null) { - query.setOrdering(this.ordering); + + /** + * Returns the candtidate class JDOQL query element. + * @return the candtidate class JDOQL query element. + */ + public Class getCandidateClass() { + return this.candidateClass; } - rangeToAPI(query); - return query; - } - /** - * Returns the JDOQLTypedQuery instance. - * - * @return the JDOQLTypedQuery instance - */ - public JDOQLTypedQuery getJDOQLTypedQuery() { - if (this.jdoqlTypedQuery != null) { - this.rangeToJDOQLTypedQuery(this.jdoqlTypedQuery); + /** + * Returns the map of parameter values. + * @return the map of parameter values + */ + public Map getParamValues() { + return this.paramValues; } - return this.jdoqlTypedQuery; - } - - /** - * Returns the unique JDOQL query element. - * - * @return the unique JDOQL query element. - */ - public boolean isUnique() { - return this.unique != null && this.unique.booleanValue(); - } - - /** - * Returns the unique JDOQL query element. - * - * @return the unique JDOQL query element. - */ - public boolean hasOrdering() { - return this.ordering != null; - } - - /** - * Returns the candtidate class JDOQL query element. - * - * @return the candtidate class JDOQL query element. - */ - public Class getCandidateClass() { - return this.candidateClass; - } - - /** - * Returns the map of parameter values. - * - * @return the map of parameter values - */ - public Map getParamValues() { - return this.paramValues; - } - /** - * Delegates to {@link QueryElementHolder#toString(String, String) - * if argument clazz does not equal null, - * otherwise returns an empty string. - * @param prefix the prefix of the returned string. - * @param clazz the returned string has the class name as a suffix. - * @return the string. - */ - private String toString(String prefix, Class clazz) { - return (clazz != null ? toString(prefix, clazz.getName()) : ""); - } - - /** - * Returns a string prefixed by argument prefix and suffixed by the string - * representation of argument bool, if argument bool does not equal - * null. Otherwise, an empty string is returned. - * - * @param prefix the prefix of the returned string. - * @param bool the returned string has the string representation of the value as a suffix. - * @return the string. - */ - private String toString(String prefix, Boolean bool) { - return bool != null && bool.booleanValue() ? prefix + ' ' : ""; - } + /** + * Delegates to {@link QueryElementHolder#toString(String, String) + * if argument clazz does not equal null, + * otherwise returns an empty string. + * @param prefix the prefix of the returned string. + * @param clazz the returned string has the class name as a suffix. + * @return the string. + */ + private String toString(String prefix, Class clazz) { + return (clazz != null? toString(prefix, clazz.getName()) : ""); + } - /** - * Returns a string prefixed by argument prefix and suffixed by argument suffix - * , if argument suffix does not equal null. Otherwise, an empty - * string is returned. - * - * @param prefix the prefix of the returned string. - * @param suffix the suffix of the returned string. - * @return the string. - */ - private String toString(String prefix, String suffix) { - return (suffix != null ? prefix + ' ' + suffix + ' ' : ""); - } + /** + * Returns a string prefixed by argument prefix and + * suffixed by the string representation of argument bool, + * if argument bool does not equal null. + * Otherwise, an empty string is returned. + * @param prefix the prefix of the returned string. + * @param bool the returned string has the string representation + * of the value as a suffix. + * @return the string. + */ + private String toString(String prefix, Boolean bool) { + return bool!=null && bool.booleanValue() ? prefix + ' ' : ""; + } - /** - * Returns a string prefixed by argument prefix, if argument prefix does - * not equal null. Otherwise, an empty string is returned. - * - * @param prefix the prefix of the returned string. - * @return the string. - */ - private String toString(String prefix) { - return (prefix != null ? prefix + ' ' : ""); - } + /** + * Returns a string prefixed by argument prefix and + * suffixed by argument suffix, + * if argument suffix does not equal null. + * Otherwise, an empty string is returned. + * @param prefix the prefix of the returned string. + * @param suffix the suffix of the returned string. + * @return the string. + */ + private String toString(String prefix, String suffix) { + return (suffix != null ? prefix + ' ' + suffix + ' ' : ""); + } - /** - * Returns the single string representation of the JDOQL query element range. If that - * element is null, then an empty string is returned. - * - * @return the single string representation of the JDOQL query element range or null - * , - */ - private String rangeToString() { - String result = ""; - if (this.fromString != null && this.toString != null) { - result = "RANGE " + this.fromString + ',' + this.toString; - } else if (this.fromLong != null && this.toLong != null) { - result = "RANGE " + this.fromLong + ',' + this.toLong; + /** + * Returns a string prefixed by argument prefix, + * if argument prefix does not equal null. + * Otherwise, an empty string is returned. + * @param prefix the prefix of the returned string. + * @return the string. + */ + private String toString(String prefix) { + return (prefix != null ? prefix + ' ' : ""); } - return result; - } - /** - * Calls API method {@link javax.jdo.Query#setRange(String)} or {@link - * javax.jdo.Query#setRange(long, long)} depending on which of the from/to fields are set. - * - * @param query the query instance - */ - private void rangeToAPI(Query query) { - if (this.fromString != null && this.toString != null) { - query.setRange(this.fromString + ',' + this.toString); - } else if (this.fromLong != null && this.toLong != null) { - query.setRange(this.fromLong.longValue(), this.toLong.longValue()); + /** + * Returns the single string representation + * of the JDOQL query element range. + * If that element is null, + * then an empty string is returned. + * @return the single string representation + * of the JDOQL query element range or null, + */ + private String rangeToString() { + String result = ""; + if (this.fromString != null && this.toString != null) { + result = "RANGE " + this.fromString + ',' + this.toString; + } + else if (this.fromLong != null && this.toLong != null) { + result = "RANGE " + this.fromLong + ',' + this.toLong; + } + return result; + } + + /** + * Calls API method {@link javax.jdo.Query#setRange(String)} or + * {@link javax.jdo.Query#setRange(long, long)} depending on + * which of the from/to fields are set. + * @param query the query instance + */ + private void rangeToAPI(Query query) { + if (this.fromString != null && this.toString != null) { + query.setRange(this.fromString + ',' + this.toString); + } + else if (this.fromLong != null && this.toLong != null) { + query.setRange(this.fromLong.longValue(), this.toLong.longValue()); + } } - } - /** - * Call JDOQLTypedQuery API method {@link javax.jdo.JDOQLTypedQuery#range(long, long)}. - * - * @param query the JDOQLTypedQuery instance - */ - private void rangeToJDOQLTypedQuery(JDOQLTypedQuery query) { - if (this.fromString != null && this.toString != null) { - query.range(Long.parseLong(this.fromString), Long.parseLong(this.toString)); - } else if (this.fromLong != null && this.toLong != null) { - query.range(this.fromLong.longValue(), this.toLong.longValue()); + /** + * Call JDOQLTypedQuery API method {@link javax.jdo.JDOQLTypedQuery#range(long, long)}. + * @param query the JDOQLTypedQuery instance + */ + private void rangeToJDOQLTypedQuery(JDOQLTypedQuery query) { + if (this.fromString != null && this.toString != null) { + query.range(Long.parseLong(this.fromString), Long.parseLong(this.toString)); + } + else if (this.fromLong != null && this.toLong != null) { + query.range(this.fromLong.longValue(), this.toLong.longValue()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/QueryTest.java b/tck/src/main/java/org/apache/jdo/tck/query/QueryTest.java index 66b1805a5..2ab6a59d3 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/QueryTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/QueryTest.java @@ -5,16 +5,16 @@ * 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 + * + * 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.jdo.tck.query; import java.math.BigDecimal; @@ -27,6 +27,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; + import javax.jdo.JDOException; import javax.jdo.JDOFatalInternalException; import javax.jdo.JDOQLTypedQuery; @@ -34,6 +35,7 @@ import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + import org.apache.jdo.tck.AbstractReaderTest; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.mylib.MylibReader; @@ -44,1523 +46,1544 @@ public abstract class QueryTest extends AbstractReaderTest { - /** */ - public static final String SERIALZED_QUERY = "query.ser"; - - /** */ - public static final String COMPANY_TESTDATA = - "org/apache/jdo/tck/pc/company/companyForQueryTests.xml"; - - /** */ - public static final String MYLIB_TESTDATA = "org/apache/jdo/tck/pc/mylib/mylibForQueryTests.xml"; - - /** List of inserted instances (see methods insertPCPoints and getFromInserted). */ - protected List inserted = new ArrayList(); - - /** - * The company model reader is used to read company model instances from an XML file. Instances - * refered by this reader are made persistent by {@link - * QueryTest#loadAndPersistCompanyModel(PersistenceManager)}. - */ - private CompanyModelReader companyModelReaderForPersistentInstances; - - /** - * The company model reader is used to read company model instances from an XML file. Instances - * refered by this reader remain transient. - */ - private CompanyModelReader companyModelReaderForTransientInstances; - - /** - * The mylib reader is used to read mylib instances from an XML file. Instances refered by this - * reader are made persistent by {@link QueryTest#loadAndPersistMylib(PersistenceManager)}. - */ - private MylibReader mylibReaderForPersistentInstances; - - /** - * The mylib reader is used to read mylib instances from an XML file. Instances refered by this - * reader are made persistent by - */ - private MylibReader mylibReaderForTransientInstances; - - // Helper methods to create persistent PCPoint instances - - /** - * @param pm the PersistenceManager - */ - public void loadAndPersistPCPoints(PersistenceManager pm) { - insertPCPoints(pm, 5); - } - - /** - * @param pm the PersistenceManager - * @param numInsert number of instances to be inserted - */ - protected void insertPCPoints(PersistenceManager pm, int numInsert) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - for (int i = 0; i < numInsert; i++) { - Object pc = new PCPoint(i, i); - pm.makePersistent(pc); - inserted.add(pc); - } - tx.commit(); - tx = null; - if (debug) logger.debug("Total objects inserted : " + numInsert); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + public static final String SERIALZED_QUERY = "query.ser"; + + /** */ + public static final String COMPANY_TESTDATA = + "org/apache/jdo/tck/pc/company/companyForQueryTests.xml"; + + /** */ + public static final String MYLIB_TESTDATA = + "org/apache/jdo/tck/pc/mylib/mylibForQueryTests.xml"; + + /** + * List of inserted instances (see methods insertPCPoints and + * getFromInserted). + */ + protected List inserted = new ArrayList(); + + /** + * The company model reader is used + * to read company model instances from an XML file. + * Instances refered by this reader are made persistent by + * {@link QueryTest#loadAndPersistCompanyModel(PersistenceManager)}. + */ + private CompanyModelReader companyModelReaderForPersistentInstances; + + /** + * The company model reader is used + * to read company model instances from an XML file. + * Instances refered by this reader remain transient. + */ + private CompanyModelReader companyModelReaderForTransientInstances; + + /** + * The mylib reader is used to read mylib instances from an XML file. + * Instances refered by this reader are made persistent by + * {@link QueryTest#loadAndPersistMylib(PersistenceManager)}. + */ + private MylibReader mylibReaderForPersistentInstances; + + /** + * The mylib reader is used to read mylib instances from an XML file. + * Instances refered by this reader are made persistent by + */ + private MylibReader mylibReaderForTransientInstances; + + // Helper methods to create persistent PCPoint instances + + /** + * + * @param pm the PersistenceManager + */ + public void loadAndPersistPCPoints(PersistenceManager pm) { + insertPCPoints(pm, 5); } - } - - /** - * @param list list - * @return list - */ - public List getFromInserted(List list) { - if (list == null) return null; - List result = new ArrayList(); - for (Iterator iter = list.iterator(); iter.hasNext(); ) { - Object pc = iter.next(); - for (Iterator iteri = inserted.iterator(); iteri.hasNext(); ) { - Object pci = iteri.next(); - if (((PCPoint) pc).getX() == ((PCPoint) pci).getX()) { - result.add(pci); - break; + /** + * + * @param pm the PersistenceManager + * @param numInsert number of instances to be inserted + */ + protected void insertPCPoints(PersistenceManager pm, int numInsert) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + for(int i = 0; itrue if o1 and o2 equal. This method is capable - * to compare object arrays, collections of object arrays, maps of object arrays. This method - * implements a narrowing in case of floating point values. In case of big decimals it calls - * {@link BigDecimal#compareTo(java.math.BigDecimal)}. It allows o1 and/or o2 - * to be null. - * - * @param o1 the first object - * @param o2 the second object - * @return true if o1 and o2 equal. - */ - protected boolean equals(Object o1, Object o2) { - boolean result; - if (o1 == o2) { - result = true; - } else if ((o1 instanceof Object[]) && (o2 instanceof Object[])) { - result = equalsObjectArray((Object[]) o1, (Object[]) o2); - } else if ((o1 instanceof List) && (o2 instanceof List)) { - result = equalsList((List) o1, (List) o2); - } else if ((o1 instanceof Collection) && (o2 instanceof Collection)) { - result = equalsCollection((Collection) o1, (Collection) o2); - } else if ((o1 instanceof Map) && (o2 instanceof Map)) { - result = equalsMap((Map) o1, (Map) o2); - } else if ((o1 instanceof Float) && (o2 instanceof Float)) { - result = closeEnough(((Float) o1).floatValue(), ((Float) o2).floatValue()); - } else if ((o1 instanceof Double) && (o2 instanceof Double)) { - result = closeEnough(((Double) o1).floatValue(), ((Double) o2).floatValue()); - } else if ((o1 instanceof BigDecimal) && (o2 instanceof BigDecimal)) { - result = ((BigDecimal) o1).compareTo((BigDecimal) o2) == 0; - } else if (o1 != null) { - result = o1.equals(o2); - } else { - // Due to the first if and due to the last if, we have: - // o1 == null && o2 != null - result = false; + + /** + * Returns a transient mylib instance for the given bean name. + * @param beanName the bean name. + * @return the transient mylib instance. + */ + protected Object getTransientMylibInstance(String beanName) { + return beanName == null ? + null : getBean(getMylibReaderForTransientInstances(),beanName); } - return result; - } - - /** - * Returns true if o1 and o2 equal. This method iterates - * over both object arrays and calls {@link QueryTest#equals(Object, Object)} passing - * corresponding instances. {@link QueryTest#equals(Object, Object)} is called rather than {@link - * Object#equals(java.lang.Object)} because object arrays having equal elements cannot be compared - * calling {@link Object#equals(java.lang.Object)}. This method does not allow o1 and - * o2 to be null both. - * - * @param o1 the first object array - * @param o2 the second object array - * @return true if o1 and o2 equal. - */ - protected boolean equalsObjectArray(Object[] o1, Object[] o2) { - boolean result = true; - if (o1 != o2) { - if (o1.length != o2.length) { - result = false; - } else { - for (int i = 0; i < o1.length; i++) { - if (!equals(o1[i], o2[i])) { - result = false; - break; - } + + /** + * Returns an array of persistent mylib instances for beans names + * in the given argument. + * @param beanNames the bean names of mylib instances. + * @return the array of persistent mylib instances. + */ + protected Object[] getPersistentMylibInstances(String[] beanNames) { + Object[] result = new Object[beanNames.length]; + for (int i = 0; i < beanNames.length; i++) { + result[i] = getPersistentMylibInstance(beanNames[i]); } - } + return result; } - return result; - } - - /** - * Returns true if o1 and o2 equal. This method iterates - * both lists and calls {@link QueryTest#equals(Object, Object)} on corresponding elements. {@link - * QueryTest#equals(Object, Object)} is called rather than {@link Object#equals(java.lang.Object)} - * because object arrays having equal elements cannot be compared calling {@link - * Object#equals(java.lang.Object)}. This method does not allow o1 and o2 - * to be null both. - * - * @param o1 the first list - * @param o2 the second list - * @return true if o1 and o2 equal. - */ - protected boolean equalsList(List o1, List o2) { - boolean result = true; - if (o1 != o2) { - if (o1.size() != o2.size()) { - result = false; - } else { - Iterator i = o1.iterator(); - Iterator ii = o2.iterator(); - while (i.hasNext()) { - Object firstObject = i.next(); - Object secondObject = ii.next(); - if (!equals(firstObject, secondObject)) { - result = false; - break; - } + + /** + * Returns an array of transient mylib instances for beans names + * in the given argument. + * @param beanNames the bean names of mylib instances. + * @return the array of transient mylib instances. + */ + protected Object[] getTransientMylibInstances(String[] beanNames) { + Object[] result = new Object[beanNames.length]; + for (int i = 0; i < beanNames.length; i++) { + result[i] = getTransientMylibInstance(beanNames[i]); } - } + return result; } - return result; - } - - /** - * Returns true if o1 and o2 equal. This method iterates - * over the first collection and checks if each instance is contained in the second collection by - * calling remove(Collection, Object). This guarantees that the cardinality of each instance in - * the first collection matches the cardinality of each instance in the second collection. This - * method does not allow o1 and o2 to be null both. - * - * @param o1 the first collection - * @param o2 the second collection - * @return true if o1 and o2 equal. - */ - protected boolean equalsCollection(Collection o1, Collection o2) { - // make a copy of o2 so we can destroy it - Collection o2copy = new ArrayList(); - Iterator i2 = o2.iterator(); - while (i2.hasNext()) { - o2copy.add(i2.next()); + + /** + * Returns a list of persistent mylib instances for beans names + * in the given argument. + * @param beanNames the bean names of mylib instances. + * @return the list of persistent mylib instances. + */ + protected List getPersistentMylibInstancesAsList(String[] beanNames) { + return Arrays.asList(getPersistentMylibInstances(beanNames)); } - boolean result = true; - if (o1 != o2) { - if (o1.size() != o2.size()) { - result = false; - } else { - for (Iterator i = o1.iterator(); i.hasNext(); ) { - Object oo1 = i.next(); - if (!remove(o2copy, oo1)) { - result = false; - break; - } - } - } + + /** + * Returns a list of transient mylib instances for beans names + * in the given argument. + * @param beanNames the bean names of mylib instances. + * @return the list of transient mylib instances. + */ + protected List getTransientMylibInstancesAsList(String[] beanNames) { + return Arrays.asList(getTransientMylibInstances(beanNames)); + } + + // PrimitiveTypes helper methods (creation and query) + + /** + * + * @param pm the PersistenceManager + */ + public void loadAndPersistPrimitiveTypes(PersistenceManager pm) { + insertPrimitiveTypes(pm); } - return result; - } - /** - * Returns true if o1 and o2 equal. This method checks if - * the key sets and the value sets of both maps equal calling equalsCollection(Collection, - * Collection). This method does not allow o1 and o2 to be null - * both. - * - * @param o1 the first map - * @param o2 the second map - * @return true if o1 and o2 equal. - */ - protected boolean equalsMap(Map o1, Map o2) { - boolean result = true; - if (o1 != o2) { - if (o1.size() != o2.size()) { - result = false; - } else { - for (Iterator i = o1.entrySet().iterator(); i.hasNext(); ) { - Map.Entry entry = (Map.Entry) i.next(); - Object key = entry.getKey(); - Object value = entry.getValue(); - Object value2 = o2.get(key); - if (!equals(value, value2)) { - result = false; - break; - } + /** + * + * @param pm the PersistenceManager + */ + protected void insertPrimitiveTypes(PersistenceManager pm) { + boolean bFlag = false; + String strValue = ""; + char charValue = '\u0000'; + int numInsert = 10; + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + for (int i = 1; i <= numInsert; i++ ) { + if (i%2 == 1) { + bFlag = true; + strValue = "Odd" + i; + charValue = 'O'; + } + else { + bFlag = false; + strValue = "Even" + i; + charValue = 'E'; + } + PrimitiveTypes primitiveObject = new PrimitiveTypes( + (long)i, bFlag, Boolean.valueOf(bFlag), (byte)i, Byte.valueOf((byte)i), + (short)i, Short.valueOf((short)i), (int) i, Integer.valueOf(i), + (long)i, Long.valueOf(i), (float)i, Float.valueOf((float)i), + (double)i, Double.valueOf(i), charValue, Character.valueOf(charValue), + Calendar.getInstance().getTime(), strValue, + new BigDecimal(String.valueOf(i)), + new BigInteger(String.valueOf(i)), + Long.valueOf(i)); + pm.makePersistent(primitiveObject); + } + tx.commit(); + tx = null; + if (debug) logger.debug("Total objects inserted : " + numInsert); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } } - return result; - } - /** - * Returns true if o is contained in the given collection. This method - * iterates the given collection and calls {@link QueryTest#equals(Object, Object)} for each - * instance. {@link QueryTest#equals(Object, Object)} is called rather than {@link - * Object#equals(java.lang.Object)} because object arrays having equal elements cannot be compared - * calling {@link Object#equals(java.lang.Object)}. - * - * @param col the collection - * @param o the object - * @return true if o is contained in the given collection. - */ - private boolean contains(Collection col, Object o) { - for (Iterator i = col.iterator(); i.hasNext(); ) { - if (equals(o, i.next())) { - return true; - } + /** + * Creates and executes a PrimitiveTypes query with the specified filter. + * The method checks whether the query returns the expected result. + * @param filter the filter + * @param pm the PersistenceManager + * @param expected expected + * @param assertion assertion + */ + protected void runSimplePrimitiveTypesQuery(String filter, + PersistenceManager pm, + Collection expected, + String assertion) { + Query q = pm.newQuery(); + q.setClass(PrimitiveTypes.class); + q.setFilter(filter); + Collection results = (Collection)q.execute(); + if (debug) + logger.debug("execute '" + filter + "' returns " + results.size() + + " instance(s)"); + checkQueryResultWithoutOrder(assertion, filter, results, expected); } - return false; - } - /** - * Returns true if o is contained in the given collection and was - * removed. This method iterates the given collection and calls {@link QueryTest#equals(Object, - * Object)} for each instance. {@link QueryTest#equals(Object, Object)} is called rather than - * {@link Object#equals(java.lang.Object)} because object arrays having equal elements cannot be - * compared calling {@link Object#equals(java.lang.Object)}. - * - * @param col the collection - * @param o the object - * @return true if o is contained in the given collection and was - * removed. - */ - private boolean remove(Collection col, Object o) { - for (Iterator i = col.iterator(); i.hasNext(); ) { - if (equals(o, i.next())) { - i.remove(); - return true; - } + /** + * Creates and executes a PrimitiveTypes query with the specified filter, + * parameter declarations and parameter values. The method checks whether + * the query returns the expected result. + * @param filter the filter + * @param paramDecl the parameter declaration + * @param paramValue the parameter values + * @param pm the PersistenceManager + * @param expected expected + * @param assertion assertion + */ + protected void runParameterPrimitiveTypesQuery(String filter, + String paramDecl, + Object paramValue, + PersistenceManager pm, + Collection expected, + String assertion) { + Query q = pm.newQuery(); + q.setClass(PrimitiveTypes.class); + q.setFilter(filter); + q.declareParameters(paramDecl); + Collection results = (Collection)q.execute(paramValue); + if (debug) + logger.debug("execute '" + filter + "' with param '" + paramValue + + "' returns " + results.size() + " instance(s)"); + checkQueryResultWithoutOrder(assertion, filter, results, expected); } - return false; - } - - /** - * Returns true if the specified float values are close enough to be considered to be - * equal for a deep equals comparison. Floating point values are not exact, so comparing them - * using == might not return useful results. This method checks that both double - * values are within some percent of each other. - * - * @param d1 one double to be tested for close enough - * @param d2 the other double to be tested for close enough - * @return true if the specified values are close enough. - */ - public boolean closeEnough(double d1, double d2) { - if (d1 == d2) return true; - - double diff = Math.abs(d1 - d2); - return diff < Math.abs((d1 + d2) * EqualityHelper.DOUBLE_EPSILON); - } - - /** - * Returns true if the specified float values are close enough to be considered to be - * equal for a deep equals comparison. Floating point values are not exact, so comparing them - * using == might not return useful results. This method checks that both float - * values are within some percent of each other. - * - * @param f1 one float to be tested for close enough - * @param f2 the other float to be tested for close enough - * @return true if the specified values are close enough. - */ - public boolean closeEnough(float f1, float f2) { - if (f1 == f2) return true; - float diff = Math.abs(f1 - f2); - return diff < Math.abs((f1 + f2) * EqualityHelper.FLOAT_EPSILON); - } - - /** - * Returns the size of the object. If it is a multivalued object (Collection, Map, or array) - * return the number of elements. If not, return 1. - * - * @param o the object - * @return size - */ - protected int size(Object o) { - if (o instanceof Collection) { - return ((Collection) o).size(); + // Helper methods to check query result + + /** + * Verify that expected equals result, including the order of the elements. + * If not equal, fail the test. + * If there is a filter != null, do not use this method. Use the method + * of the same name that takes a String as the second argument. + * @param assertion assertion + * @param result the result + * @param expected the expected + */ + protected void checkQueryResultWithOrder(String assertion, + Object result, + Object expected) { + if (!equals(result, expected)) { + queryFailed(assertion, "null", result, expected); + } } - if (o instanceof Object[]) { - return ((Object[]) o).length; + + /** + * Verify that expected equals result, ignoring the order of the elements. + * If not equal, fail the test. + * If there is a filter != null, do not use this method. Use the method + * of the same name that takes a String as the second argument. + * @param assertion assertion + * @param result the result + * @param expected the expected + */ + protected void checkQueryResultWithoutOrder(String assertion, + Object result, + Object expected) { + // We need to explicitly check on collections passed as parameters + // because equals(Object, Object) checks on lists and afterwards + // on collections. This ensures, lists are compared without order + // for queries without an ordering specification. + if (result instanceof Collection && expected instanceof Collection) { + if (!equalsCollection((Collection)result, (Collection)expected)) { + queryFailed(assertion, "null", result, expected); + } + } else { + if (!equals(result, expected)) { + queryFailed(assertion, "null", result, expected); + } + } } - if (o instanceof Map) { - return ((Map) o).size(); + + private void queryFailed(String assertion, String query, Object result, Object expected) { + String lf = System.getProperty("line.separator"); + result = + ConversionHelper.convertObjectArrayElements(result); + expected = + ConversionHelper.convertObjectArrayElements(expected); + fail(assertion, + "Wrong query result: " + lf + + "query: " + query + lf + + "expected: " + expected.getClass().getName() + + " of size " + size(expected) + lf + expected + lf + + "got: " + result.getClass().getName() + + " of size " + size(result) + lf + result); } - return 1; - } - - // Debugging helper methods - /** - * @param results the results - * @param expected expected values - */ - protected void printOutput(Object results, Collection expected) { - if (!debug) return; + /** + * + * @param assertion assertion + * @param query the query + * @param result the result + * @param expected expected + */ + protected void checkQueryResultWithOrder(String assertion, + String query, + Object result, + Object expected) { + if (!equals(result, expected)) { + queryFailed(assertion, query, result, expected); + } + } - Iterator iter = null; - PCPoint pcp = null; - if (results == null) { - logger.debug("Query returns null"); + /** + * + * @param assertion assertion + * @param query the query + * @param result the result + * @param expected expected + */ + protected void checkQueryResultWithoutOrder(String assertion, + String query, + Object result, + Object expected) { + // We need to explicitly check on collections passed as parameters + // because equals(Object, Object) checks on lists and afterwards + // on collections. This ensures, lists are compared without order + // for queries without an ordering specification. + if (result instanceof Collection && expected instanceof Collection) { + if (!equalsCollection((Collection)result, (Collection)expected)) { + queryFailed(assertion, query, result, expected); + } + } else { + if (!equals(result, expected)) { + queryFailed(assertion, query, result, expected); + } + } } - if (!(results instanceof Collection)) { - logger.debug("Query result is not a collection: " + results.getClass().getName()); + + /** + * Returns true + * if o1 and o2 equal. + * This method is capable to compare object arrays, + * collections of object arrays, maps of object arrays. + * This method implements a narrowing in case of floating point values. + * In case of big decimals it calls + * {@link BigDecimal#compareTo(java.math.BigDecimal)}. + * It allows o1 and/or o2 + * to be null. + * @param o1 the first object + * @param o2 the second object + * @return true if o1 and o2 equal. + */ + protected boolean equals(Object o1, Object o2) { + boolean result; + if (o1 == o2) { + result = true; + } else if ((o1 instanceof Object[]) && (o2 instanceof Object[])) { + result = equalsObjectArray((Object[])o1, (Object[])o2); + } else if ((o1 instanceof List) && (o2 instanceof List)) { + result = equalsList((List)o1, (List)o2); + } else if ((o1 instanceof Collection) && (o2 instanceof Collection)) { + result = equalsCollection((Collection)o1, (Collection)o2); + } else if ((o1 instanceof Map) && (o2 instanceof Map)) { + result = equalsMap((Map)o1, (Map)o2); + } else if ((o1 instanceof Float) && (o2 instanceof Float)) { + result = closeEnough(((Float)o1).floatValue(), + ((Float)o2).floatValue()); + } else if ((o1 instanceof Double) && (o2 instanceof Double)) { + result = closeEnough(((Double)o1).floatValue(), + ((Double)o2).floatValue()); + } else if ((o1 instanceof BigDecimal) && (o2 instanceof BigDecimal)) { + result = ((BigDecimal)o1).compareTo((BigDecimal)o2) == 0; + } else if (o1 != null) { + result = o1.equals(o2); + } else { + // Due to the first if and due to the last if, we have: + // o1 == null && o2 != null + result = false; + } + return result; } - logger.debug("Retrived Objects are:"); - iter = ((Collection) results).iterator(); - while (iter.hasNext()) { - pcp = (PCPoint) iter.next(); - logger.debug("X = " + pcp.getX() + "\tY = " + pcp.getY()); + + /** + * Returns true + * if o1 and o2 equal. + * This method iterates over both object arrays and calls + * {@link QueryTest#equals(Object, Object)} passing + * corresponding instances. + * {@link QueryTest#equals(Object, Object)} is called rather than + * {@link Object#equals(java.lang.Object)} because object arrays + * having equal elements cannot be compared calling + * {@link Object#equals(java.lang.Object)}. + * This method does not allow o1 and o2 + * to be null both. + * @param o1 the first object array + * @param o2 the second object array + * @return true if o1 and o2 equal. + */ + protected boolean equalsObjectArray(Object[] o1, Object[] o2) { + boolean result = true; + if (o1 != o2) { + if (o1.length != o2.length) { + result = false; + } else { + for (int i = 0; i < o1.length; i++ ) { + if (!equals(o1[i], o2[i])) { + result = false; + break; + } + } + } + } + return result; } - logger.debug("Expected Objects are:"); - iter = ((Collection) expected).iterator(); - while (iter.hasNext()) { - pcp = (PCPoint) iter.next(); - logger.debug("X = " + pcp.getX() + "\tY = " + pcp.getY()); + /** + * Returns true + * if o1 and o2 equal. + * This method iterates both lists and + * calls {@link QueryTest#equals(Object, Object)} on corresponding elements. + * {@link QueryTest#equals(Object, Object)} is called rather than + * {@link Object#equals(java.lang.Object)} because object arrays + * having equal elements cannot be compared calling + * {@link Object#equals(java.lang.Object)}. + * This method does not allow o1 and o2 + * to be null both. + * @param o1 the first list + * @param o2 the second list + * @return true if o1 and o2 equal. + */ + protected boolean equalsList(List o1, List o2) { + boolean result = true; + if (o1 != o2) { + if (o1.size() != o2.size()) { + result = false; + } else { + Iterator i = o1.iterator(); + Iterator ii = o2.iterator(); + while (i.hasNext()) { + Object firstObject = i.next(); + Object secondObject = ii.next(); + if (!equals(firstObject, secondObject)) { + result = false; + break; + } + } + } + } + return result; } - } - - // compile query methods - - /** - * Compiles the given query element holder instance as a JDO API query. Argument positive - * determines if the compilation is supposed to succeed or to fail. If true - * and the compilation fails, then the test case fails prompting argument assertion. - * If false and the compilation succeeds, then the test case fails prompting argument - * assertion. Otherwise the test case succeeds. - * - * @param assertion the assertion to prompt if the test case fails. - * @param queryElementHolder the query to execute. - * @param positive determines if the compilation is supposed to succeed or to fail. - */ - protected void compileAPIQuery( - String assertion, QueryElementHolder queryElementHolder, boolean positive) { - if (logger.isDebugEnabled()) { - logger.debug("Compiling API query: " + queryElementHolder); + + /** + * Returns true + * if o1 and o2 equal. + * This method iterates over the first collection and + * checks if each instance is contained in the second collection + * by calling remove(Collection, Object). This guarantees that + * the cardinality of each instance in the first collection matches + * the cardinality of each instance in the second collection. + * This method does not allow o1 and o2 + * to be null both. + * @param o1 the first collection + * @param o2 the second collection + * @return true if o1 and o2 equal. + */ + protected boolean equalsCollection(Collection o1, Collection o2) { + // make a copy of o2 so we can destroy it + Collection o2copy = new ArrayList(); + Iterator i2 = o2.iterator(); + while (i2.hasNext()) { + o2copy.add(i2.next()); + } + boolean result = true; + if (o1 != o2) { + if (o1.size() != o2.size()) { + result = false; + } else { + for (Iterator i = o1.iterator(); i.hasNext(); ) { + Object oo1 = i.next(); + if (!remove(o2copy, oo1)) { + result = false; + break; + } + } + } + } + return result; } - compile(assertion, queryElementHolder, false, queryElementHolder.toString(), positive); - } - - /** - * Compiles the given query element holder instance as a JDO single string query. Argument - * positive determines if the compilation is supposed to succeed or to fail. If true - * and the compilation fails, then the test case fails prompting argument assertion - * . If false and the compilation succeeds, then the test case fails prompting - * argument assertion. Otherwise the test case succeeds. - * - * @param assertion the assertion to prompt if the test case fails. - * @param queryElementHolder the query to execute. - * @param positive determines if the compilation is supposed to succeed or to fail. - */ - protected void compileSingleStringQuery( - String assertion, QueryElementHolder queryElementHolder, boolean positive) { - if (logger.isDebugEnabled()) - logger.debug("Compiling single string query: " + queryElementHolder); - compile(assertion, queryElementHolder, true, queryElementHolder.toString(), positive); - } - - /** - * Compiles the given single string query. Argument positive determines if the - * compilation is supposed to succeed or to fail. If true and the compilation fails, - * then the test case fails prompting argument assertion. If false and - * the compilation succeeds, then the test case fails prompting argument assertion. - * Otherwise the test case succeeds. - * - * @param assertion the assertion to prompt if the test case fails. - * @param singleStringQuery the single string query - * @param positive determines if the compilation is supposed to succeed or to fail. - */ - protected void compileSingleStringQuery( - String assertion, String singleStringQuery, boolean positive) { - if (logger.isDebugEnabled()) - logger.debug("Compiling single string query: " + singleStringQuery); - compile(assertion, null, true, singleStringQuery, positive); - } - - /** - * Compiles the given query element holder instance as a JDO API query or single string query, - * depending on argument asSingleString. Argument singleStringQuery is - * used to support queries which cannot be expressed as query element holder instances. That - * argument is ignored if argument queryElementHolder is set. Argument positive - * determines if the compilation is supposed to succeed or to fail. If true - * and the compilation fails, then the test case fails prompting argument assertion. - * If false and the compilation succeeds, then the test case fails prompting argument - * assertion. Otherwise the test case succeeds. - * - * @param assertion the assertion to prompt if the test case fails. - * @param queryElementHolder the query to compile. - * @param asSingleString determines if the query specified by queryElementHolder is - * compiled as single string query or as API query. - * @param singleStringQuery the query to compile as a JDO single string query if there is no query - * element holder. - * @param positive determines if the compilation is supposed to succeed or to fail. - */ - private void compile( - String assertion, - QueryElementHolder queryElementHolder, - boolean asSingleString, - String singleStringQuery, - boolean positive) { - getPM(); - try { - Query query; - if (queryElementHolder != null) { - if (asSingleString) { - query = queryElementHolder.getSingleStringQuery(pm); - } else { - query = queryElementHolder.getAPIQuery(pm); + + /** + * Returns true + * if o1 and o2 equal. + * This method checks if the key sets and the value sets of both + * maps equal calling equalsCollection(Collection, Collection). + * This method does not allow o1 and o2 + * to be null both. + * @param o1 the first map + * @param o2 the second map + * @return true if o1 and o2 equal. + */ + protected boolean equalsMap(Map o1, Map o2) { + boolean result = true; + if (o1 != o2) { + if (o1.size() != o2.size()) { + result = false; + } else { + for (Iterator i = o1.entrySet().iterator(); i.hasNext(); ) { + Map.Entry entry = (Map.Entry) i.next(); + Object key = entry.getKey(); + Object value = entry.getValue(); + Object value2 = o2.get(key); + if (!equals(value, value2)) { + result = false; + break; + } + } + } } - } else { - query = getPM().newQuery(singleStringQuery); - } - compile(assertion, query, singleStringQuery, positive); - } catch (JDOUserException e) { - // This exception handler considers a JDOUserException - // to be thrown in newQuery methods. - // A JDOUserException may be expected in case of negative tests. - if (positive) { - fail( - assertion - + "Query '" - + queryElementHolder - + "' must be compilable. The exception message is: " - + e.getMessage()); - } + return result; } - } - - /** - * Compiles the given query instance. Argument positive determines if the compilation - * is supposed to succeed or to fail. If true and the compilation fails, then the - * test case fails prompting arguments assertion and queryText. If - * false and the compilation succeeds, then the test case fails prompting argument - * assertion and queryText. Otherwise the test case succeeds. - * - * @param assertion asserting text - * @param query the query instance - * @param queryText the text representation of the query - * @param positive positive test - */ - protected void compile(String assertion, Query query, String queryText, boolean positive) { - getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - try { - query.compile(); - if (!positive) { - fail(assertion, "Query compilation must throw JDOUserException: " + queryText); - } - } catch (JDOUserException e) { - if (positive) { - fail( - assertion, - "Query '" - + queryText - + "' must be compilable. The exception message is: " - + e.getMessage()); - } - } finally { - if (tx.isActive()) { - tx.rollback(); - } + + /** + * Returns true if o is contained + * in the given collection. + * This method iterates the given collection and calls + * {@link QueryTest#equals(Object, Object)} for each instance. + * {@link QueryTest#equals(Object, Object)} is called rather than + * {@link Object#equals(java.lang.Object)} because object arrays + * having equal elements cannot be compared calling + * {@link Object#equals(java.lang.Object)}. + * @param col the collection + * @param o the object + * @return true if o is contained + * in the given collection. + */ + private boolean contains(Collection col, Object o) { + for (Iterator i = col.iterator(); i.hasNext(); ) { + if (equals(o, i.next())) { + return true; + } + } + return false; } - } - // execute query methods + /** + * Returns true if o is contained + * in the given collection and was removed. + * This method iterates the given collection and calls + * {@link QueryTest#equals(Object, Object)} for each instance. + * {@link QueryTest#equals(Object, Object)} is called rather than + * {@link Object#equals(java.lang.Object)} because object arrays + * having equal elements cannot be compared calling + * {@link Object#equals(java.lang.Object)}. + * @param col the collection + * @param o the object + * @return true if o is contained + * in the given collection and was removed. + */ + private boolean remove(Collection col, Object o) { + for (Iterator i = col.iterator(); i.hasNext(); ) { + if (equals(o, i.next())) { + i.remove(); + return true; + } + } + return false; + } - /** - * Executes the given query element holder instance as a JDO API query. The result of that query - * is compared against the given argument expectedResult. If the expected result does - * not match the returned query result, then the test case fails prompting argument - * assertion. - * - * @param assertion the assertion to prompt if the test case fails. - * @param queryElementHolder the query to execute. - * @param expectedResult the expected query result. - */ - protected void executeAPIQuery( - String assertion, QueryElementHolder queryElementHolder, Object expectedResult) { - if (logger.isDebugEnabled()) { - logger.debug("Executing API query: " + queryElementHolder); + /** Returns true if the specified float values are close + * enough to be considered to be equal for a deep equals + * comparison. Floating point values are not exact, so comparing them + * using == might not return useful results. This method + * checks that both double values are within some percent of each + * other. + * @param d1 one double to be tested for close enough + * @param d2 the other double to be tested for close enough + * @return true if the specified values are close enough. + */ + public boolean closeEnough(double d1, double d2) { + if (d1 == d2) + return true; + + double diff = Math.abs(d1 - d2); + return diff < Math.abs((d1 + d2) * EqualityHelper.DOUBLE_EPSILON); } - execute(assertion, queryElementHolder, false, expectedResult); - } - /** - * Executes the given query element holder instance as a JDO single string query. The result of - * that query is compared against the given argument expectedResult. If the expected - * result does not match the returned query result, then the test case fails prompting argument - * assertion. - * - * @param assertion the assertion to prompt if the test case fails. - * @param queryElementHolder the query to execute. - * @param expectedResult the expected query result. - */ - protected void executeSingleStringQuery( - String assertion, QueryElementHolder queryElementHolder, Object expectedResult) { - if (logger.isDebugEnabled()) - logger.debug("Executing single string query: " + queryElementHolder); - execute(assertion, queryElementHolder, true, expectedResult); - } + /** + * Returns true if the specified float values are close + * enough to be considered to be equal for a deep equals + * comparison. Floating point values are not exact, so comparing them + * using == might not return useful results. This method + * checks that both float values are within some percent of each + * other. + * @param f1 one float to be tested for close enough + * @param f2 the other float to be tested for close enough + * @return true if the specified values are close enough. + */ + public boolean closeEnough(float f1, float f2) { + if (f1 == f2) + return true; + + float diff = Math.abs(f1 - f2); + return diff < Math.abs((f1 + f2) * EqualityHelper.FLOAT_EPSILON); + } - /** - * @param assertion assertion text - * @param queryElementHolder query elements - * @param expectedResult expected query result - */ - protected void executeJDOQLTypedQuery( - String assertion, QueryElementHolder queryElementHolder, Object expectedResult) { - executeJDOQLTypedQuery(assertion, queryElementHolder, null, false, expectedResult); - } - /** - * @param assertion assertion text - * @param queryElementHolder query elements - * @param resultClass result class object - * @param resultClauseSpecified flag whether result clause is specified - * @param expectedResult the expected query result - */ - protected void executeJDOQLTypedQuery( - String assertion, - QueryElementHolder queryElementHolder, - Class resultClass, - boolean resultClauseSpecified, - Object expectedResult) { - String singleStringQuery = queryElementHolder.toString(); - getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - try { - JDOQLTypedQuery query = queryElementHolder.getJDOQLTypedQuery(); - if (query == null) { - throw new JDOFatalInternalException("Missing JDOQLTyped instance"); - } - Object result = null; - try { - Map paramValues = queryElementHolder.getParamValues(); - if (paramValues != null) { - query.setParameters(paramValues); + /** + * Returns the size of the object. If it is a multivalued object + * (Collection, Map, or array) return the number of elements. If not, + * return 1. + * @param o the object + * @return size + */ + protected int size(Object o) { + if (o instanceof Collection) { + return ((Collection)o).size(); } - - if (resultClass != null) { - if (queryElementHolder.isUnique()) { - // result class specified and unique result - result = query.executeResultUnique(resultClass); - } else { - // result class specified and list result - result = query.executeResultList(resultClass); - } - } else if (resultClauseSpecified) { - if (queryElementHolder.isUnique()) { - // result class specified and unique result - result = query.executeResultUnique(); - } else { - // result class specified and list result - result = query.executeResultList(); - } - } else { - if (queryElementHolder.isUnique()) { - // no result class and unique result - result = query.executeUnique(); - } else { - // no result class and list result - result = query.executeList(); - } + if (o instanceof Object[]) { + return ((Object[])o).length; } - - if (logger.isDebugEnabled()) { - logger.debug("Query result: " + ConversionHelper.convertObjectArrayElements(result)); + if (o instanceof Map) { + return ((Map)o).size(); } - - checkResult( - assertion, - singleStringQuery, - queryElementHolder.hasOrdering(), - result, - expectedResult, - true); - } finally { - query.close(result); - } - } catch (JDOUserException e) { - String msg = "JDOUserException thrown while executing query:\n" + singleStringQuery; - throw new JDOException(msg, e); - } catch (JDOException e) { - String msg = "JDOException thrown while executing query:\n" + singleStringQuery; - throw new JDOException(msg, e); - } finally { - if (tx.isActive()) { - tx.rollback(); - } + return 1; } - } - /** - * Converts the given query element holder instance to a JDO query instance, based on argument - * asSingleString. Afterwards, delegates to method {@link QueryTest#execute(String, - * Query, String, boolean, Object, Object, boolean)}. - * - * @param assertion the assertion to prompt if the test case fails. - * @param queryElementHolder the query to execute. - * @param asSingleString determines if the query is executed as single string query or as API - * query. - * @param expectedResult the expected query result. - * @return the query result - */ - private Object execute( - String assertion, - QueryElementHolder queryElementHolder, - boolean asSingleString, - Object expectedResult) { - getPM(); - Query query = - asSingleString - ? queryElementHolder.getSingleStringQuery(pm) - : queryElementHolder.getAPIQuery(pm); - Object result = - execute( - assertion, - query, - queryElementHolder.toString(), - queryElementHolder.hasOrdering(), - queryElementHolder.getParamValues(), - expectedResult, - true); - return result; - } - - /** - * Executes the given query instance delegating to execute(String, Query, String, boolean, Object, - * Object, boolean). Logs argument singleStringQuery if debug logging is enabled. - * - * @param assertion the assertion to prompt if the test case fails. - * @param query the query to execute. - * @param singleStringQuery the single string representation of the query. This parameter is only - * used as part of the falure message. - * @param hasOrdering indicates if the query has an ordering clause. - * @param parameters the parmaters of the query. - * @param expectedResult the expected query result. - * @param positive indicates if query execution is supposed to fail - * @return the query result - */ - protected Object executeJDOQuery( - String assertion, - Query query, - String singleStringQuery, - boolean hasOrdering, - Object[] parameters, - Object expectedResult, - boolean positive) { - if (logger.isDebugEnabled()) { - logger.debug("Executing JDO query: " + singleStringQuery); + // Debugging helper methods + + /** + * + * @param results the results + * @param expected expected values + */ + protected void printOutput(Object results, Collection expected) { + if (!debug) + return; + + Iterator iter = null; + PCPoint pcp = null; + if (results == null) { + logger.debug("Query returns null"); + } + if (!(results instanceof Collection)) { + logger.debug("Query result is not a collection: " + + results.getClass().getName()); + } + logger.debug("Retrived Objects are:"); + iter = ((Collection)results).iterator(); + while (iter.hasNext()) { + pcp = (PCPoint)iter.next(); + logger.debug("X = " + pcp.getX() + "\tY = " + pcp.getY()); + } + + logger.debug("Expected Objects are:"); + iter = ((Collection)expected).iterator(); + while (iter.hasNext()) { + pcp = (PCPoint)iter.next(); + logger.debug("X = " + pcp.getX() + "\tY = " + pcp.getY()); + } } - return execute( - assertion, query, singleStringQuery, hasOrdering, parameters, expectedResult, positive); - } - - /** - * Executes the given SQL string as a JDO SQL query. The result of that query is compared against - * the given argument expectedResult. If the expected result does not match the - * returned query result, then the test case fails prompting argument assertion. - * Argument unique indicates, if the query is supposed to return a single result. - * Argument sql may contain the substring "{0}". All occurences of this - * substring are replaced by the value of PMF property "javax.jdo.mapping.Schema". - * - * @param assertion the assertion to prompt if the test case fails. - * @param sql the SQL string. - * @param candidateClass the candidate class. - * @param resultClass the result class. - * @param positive positive option - * @param parameters the parameters of the query. - * @param expectedResult the expected query result. - * @param unique indicates, if the query is supposed to return a single result. - */ - protected void executeSQLQuery( - String assertion, - String sql, - Class candidateClass, - Class resultClass, - boolean positive, - Object parameters, - Object expectedResult, - boolean unique) { - String schema = getPMFProperty("javax.jdo.mapping.Schema"); - sql = MessageFormat.format(sql, new Object[] {schema}); - if (logger.isDebugEnabled()) logger.debug("Executing SQL query: " + sql); - Query query = getPM().newQuery("javax.jdo.query.SQL", sql); - if (unique) { - query.setUnique(unique); + + // compile query methods + + /** + * Compiles the given query element holder instance as a JDO API query. + * Argument positive determines if the compilation is supposed + * to succeed or to fail. If true and the compilation fails, + * then the test case fails prompting argument assertion. + * If false and the compilation succeeds, + * then the test case fails prompting argument assertion. + * Otherwise the test case succeeds. + * @param assertion the assertion to prompt if the test case fails. + * @param queryElementHolder the query to execute. + * @param positive determines if the compilation is supposed + * to succeed or to fail. + */ + protected void compileAPIQuery(String assertion, + QueryElementHolder queryElementHolder, boolean positive) { + if (logger.isDebugEnabled()) { + logger.debug("Compiling API query: " + queryElementHolder); + } + compile(assertion, queryElementHolder, false, + queryElementHolder.toString(), positive); } - if (candidateClass != null) { - query.setClass(candidateClass); + + /** + * Compiles the given query element holder instance + * as a JDO single string query. + * Argument positive determines if the compilation is supposed + * to succeed or to fail. If true and the compilation fails, + * then the test case fails prompting argument assertion. + * If false and the compilation succeeds, + * then the test case fails prompting argument assertion. + * Otherwise the test case succeeds. + * @param assertion the assertion to prompt if the test case fails. + * @param queryElementHolder the query to execute. + * @param positive determines if the compilation is supposed + * to succeed or to fail. + */ + protected void compileSingleStringQuery(String assertion, + QueryElementHolder queryElementHolder, boolean positive) { + if (logger.isDebugEnabled()) + logger.debug("Compiling single string query: " + + queryElementHolder); + compile(assertion, queryElementHolder, true, + queryElementHolder.toString(), positive); } - if (resultClass != null) { - query.setResultClass(resultClass); + + /** + * Compiles the given single string query. + * Argument positive determines if the compilation is supposed + * to succeed or to fail. If true and the compilation fails, + * then the test case fails prompting argument assertion. + * If false and the compilation succeeds, + * then the test case fails prompting argument assertion. + * Otherwise the test case succeeds. + * @param assertion the assertion to prompt if the test case fails. + * @param singleStringQuery the single string query + * @param positive determines if the compilation is supposed + * to succeed or to fail. + */ + protected void compileSingleStringQuery(String assertion, + String singleStringQuery, boolean positive) { + if (logger.isDebugEnabled()) + logger.debug("Compiling single string query: " + + singleStringQuery); + compile(assertion, null, true, singleStringQuery, positive); } - execute(assertion, query, sql, false, parameters, expectedResult, positive); - } - /** - * Executes the given query instance. If argument parameters is an object array, then - * it is passed as an argument to the method {@link Query#executeWithArray(java.lang.Object[])}. - * If argument parameters is a map, then it is passed as an argument to the method - * {@link Query#executeWithMap(java.util.Map)}. If argument parameters is a list, - * then the list elements are passed as arguments to the execute methods taking actual parameter - * values. If argument parameters is null, then method {@link - * Query#execute()} is called on the given query instance instead. - * - *

    The result of query execution is compared against the argument expectedResult. - * If the two values differ, then this method throws an {@link - * junit.framework.AssertionFailedError} and the calling test case fails prompting argument - * assertion. - * - *

    If argument positive is false, then the test case invoking this - * method is considered to be a negative test case. Then, query execution is expected to throw a - * {@link JDOUserException}. If query execution succeeds in this case, then this method throws an - * {@link junit.framework.AssertionFailedError} and the calling test case fails prompting argument - * assertion. - * - *

    - * - * @param assertion the assertion to prompt if the test case fails. - * @param query the query to execute. - * @param singleStringQuery the single string representation of the query. This parameter is only - * used as part of the falure message. - * @param hasOrdering indicates if the query has an ordering clause. - * @param parameters the parmaters of the query. - * @param expectedResult the expected query result. - * @param positive indicates if query execution is supposed to fail - * @return the query result - */ - private Object execute( - String assertion, - Query query, - String singleStringQuery, - boolean hasOrdering, - Object parameters, - Object expectedResult, - boolean positive) { - Object result = null; - getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - try { - try { - if (parameters == null) { - result = query.execute(); - } else if (parameters instanceof Object[]) { - result = query.executeWithArray((Object[]) parameters); - } else if (parameters instanceof Map) { - result = query.executeWithMap((Map) parameters); - } else if (parameters instanceof List) { - List list = (List) parameters; - switch (list.size()) { - case 1: - result = query.execute(list.get(0)); - break; - case 2: - result = query.execute(list.get(0), list.get(1)); - break; - case 3: - result = query.execute(list.get(0), list.get(1), list.get(2)); - break; - default: - throw new IllegalArgumentException( - "Argument parameters is a list " + "and must have 1, 2, or 3 elements."); - } - } else { - throw new IllegalArgumentException( - "Argument parameters " + "must be instance of List, Map, Object[], or null."); + /** + * Compiles the given query element holder instance + * as a JDO API query or single string query, + * depending on argument asSingleString. + * Argument singleStringQuery is used to support queries + * which cannot be expressed as query element holder instances. + * That argument is ignored if argument queryElementHolder + * is set. + * Argument positive determines if the compilation is supposed + * to succeed or to fail. If true and the compilation fails, + * then the test case fails prompting argument assertion. + * If false and the compilation succeeds, + * then the test case fails prompting argument assertion. + * Otherwise the test case succeeds. + * @param assertion the assertion to prompt if the test case fails. + * @param queryElementHolder the query to compile. + * @param asSingleString determines if the query specified by + * queryElementHolder is compiled as single string query + * or as API query. + * @param singleStringQuery the query to compile + * as a JDO single string query if there is no query element holder. + * @param positive determines if the compilation is supposed + * to succeed or to fail. + */ + private void compile(String assertion, + QueryElementHolder queryElementHolder, boolean asSingleString, + String singleStringQuery, boolean positive) { + getPM(); + try { + Query query; + if (queryElementHolder != null) { + if (asSingleString) { + query = queryElementHolder.getSingleStringQuery(pm); + } else { + query = queryElementHolder.getAPIQuery(pm); + } + } else { + query = getPM().newQuery(singleStringQuery); + } + compile(assertion, query, singleStringQuery, positive); + } catch (JDOUserException e) { + // This exception handler considers a JDOUserException + // to be thrown in newQuery methods. + // A JDOUserException may be expected in case of negative tests. + if (positive) { + fail(assertion + "Query '" + queryElementHolder + + "' must be compilable. The exception message is: " + + e.getMessage()); + } } - + } + + /** + * Compiles the given query instance. + * Argument positive determines if the compilation is supposed + * to succeed or to fail. + * If true and the compilation fails, + * then the test case fails prompting arguments assertion + * and queryText. + * If false and the compilation succeeds, + * then the test case fails prompting argument assertion + * and queryText. + * Otherwise the test case succeeds. + * @param assertion asserting text + * @param query the query instance + * @param queryText the text representation of the query + * @param positive positive test + */ + protected void compile(String assertion, + Query query, String queryText, boolean positive) { + getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + try { + query.compile(); + if (!positive) { + fail(assertion, + "Query compilation must throw JDOUserException: " + + queryText); + } + } catch (JDOUserException e) { + if (positive) { + fail(assertion, "Query '" + queryText + + "' must be compilable. The exception message is: " + + e.getMessage()); + } + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + // execute query methods + + /** + * Executes the given query element holder instance as a JDO API query. + * The result of that query is compared against the given argument + * expectedResult. + * If the expected result does not match the returned query result, + * then the test case fails prompting argument assertion. + * @param assertion the assertion to prompt if the test case fails. + * @param queryElementHolder the query to execute. + * @param expectedResult the expected query result. + */ + protected void executeAPIQuery(String assertion, + QueryElementHolder queryElementHolder, Object expectedResult) { if (logger.isDebugEnabled()) { - logger.debug("Query result: " + ConversionHelper.convertObjectArrayElements(result)); + logger.debug("Executing API query: " + queryElementHolder); } + execute(assertion, queryElementHolder, false, expectedResult); + } + + /** + * Executes the given query element holder instance + * as a JDO single string query. + * The result of that query is compared against the given argument + * expectedResult. + * If the expected result does not match the returned query result, + * then the test case fails prompting argument assertion. + * @param assertion the assertion to prompt if the test case fails. + * @param queryElementHolder the query to execute. + * @param expectedResult the expected query result. + */ + protected void executeSingleStringQuery(String assertion, + QueryElementHolder queryElementHolder, Object expectedResult) { + if (logger.isDebugEnabled()) + logger.debug("Executing single string query: " + + queryElementHolder); + execute(assertion, queryElementHolder, true, expectedResult); + } - checkResult(assertion, singleStringQuery, hasOrdering, result, expectedResult, positive); + /** + * + * @param assertion assertion text + * @param queryElementHolder query elements + * @param expectedResult expected query result + */ + protected void executeJDOQLTypedQuery(String assertion, QueryElementHolder queryElementHolder, + Object expectedResult) { + executeJDOQLTypedQuery(assertion, queryElementHolder, null, false, expectedResult); + } - } finally { - query.close(result); - } - } catch (JDOUserException e) { - if (positive) { - String msg = "JDOUserException thrown while executing query:\n" + singleStringQuery; - throw new JDOException(msg, e); - } - } catch (JDOException e) { - String msg = "JDOException thrown while executing query:\n" + singleStringQuery; - throw new JDOException(msg, e); - } finally { - if (tx.isActive()) { - tx.rollback(); - } + /** + * + * @param assertion assertion text + * @param queryElementHolder query elements + * @param resultClass result class object + * @param resultClauseSpecified flag whether result clause is specified + * @param expectedResult the expected query result + */ + protected void executeJDOQLTypedQuery(String assertion, QueryElementHolder queryElementHolder, + Class resultClass, boolean resultClauseSpecified, + Object expectedResult) { + String singleStringQuery = queryElementHolder.toString(); + getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + try { + JDOQLTypedQuery query = queryElementHolder.getJDOQLTypedQuery(); + if (query == null) { + throw new JDOFatalInternalException("Missing JDOQLTyped instance"); + } + Object result = null; + try { + Map paramValues = queryElementHolder.getParamValues(); + if (paramValues != null) { + query.setParameters(paramValues); + } + + if (resultClass != null) { + if (queryElementHolder.isUnique()) { + // result class specified and unique result + result = query.executeResultUnique(resultClass); + } else { + // result class specified and list result + result = query.executeResultList(resultClass); + } + } else if (resultClauseSpecified) { + if (queryElementHolder.isUnique()) { + // result class specified and unique result + result = query.executeResultUnique(); + } else { + // result class specified and list result + result = query.executeResultList(); + } + } else { + if (queryElementHolder.isUnique()) { + // no result class and unique result + result = query.executeUnique(); + } else { + // no result class and list result + result = query.executeList(); + } + } + + if (logger.isDebugEnabled()) { + logger.debug("Query result: " + ConversionHelper. + convertObjectArrayElements(result)); + } + + checkResult(assertion, singleStringQuery, queryElementHolder.hasOrdering(), + result, expectedResult, true); + } finally { + query.close(result); + } + } catch (JDOUserException e) { + String msg = "JDOUserException thrown while executing query:\n" + singleStringQuery; + throw new JDOException(msg, e); + } catch (JDOException e) { + String msg = "JDOException thrown while executing query:\n" + singleStringQuery; + throw new JDOException(msg, e); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } } - return result; - } - /** - * @param assertion the assertion to prompt if the test case fails. - * @param singleStringQuery the single string representation of the query. This parameter is only - * used as part of the falure message. - * @param hasOrdering indicates if the query has an ordering clause. - * @param positive indicates if query execution is supposed to fail - * @param result the query result. - * @param expectedResult the expected query result. - */ - private void checkResult( - String assertion, - String singleStringQuery, - boolean hasOrdering, - Object result, - Object expectedResult, - boolean positive) { - if (positive) { - if (hasOrdering) { - checkQueryResultWithOrder(assertion, singleStringQuery, result, expectedResult); - } else { - checkQueryResultWithoutOrder(assertion, singleStringQuery, result, expectedResult); - } - } else { - fail(assertion, "Query must throw JDOUserException: " + singleStringQuery); + /** + * Converts the given query element holder instance + * to a JDO query instance, + * based on argument asSingleString. + * Afterwards, delegates to method + * {@link QueryTest#execute(String, Query, String, boolean, Object, Object, boolean)}. + * @param assertion the assertion to prompt if the test case fails. + * @param queryElementHolder the query to execute. + * @param asSingleString determines if the query is executed as + * single string query or as API query. + * @param expectedResult the expected query result. + * @return the query result + */ + private Object execute(String assertion, QueryElementHolder queryElementHolder, + boolean asSingleString, Object expectedResult) { + getPM(); + Query query = asSingleString ? + queryElementHolder.getSingleStringQuery(pm) : + queryElementHolder.getAPIQuery(pm); + Object result = execute(assertion, query, + queryElementHolder.toString(), + queryElementHolder.hasOrdering(), queryElementHolder.getParamValues(), + expectedResult, true); + return result; } - } - /** - * Converts the given query element holder instance to a JDO query instance. Calls {@link - * Query#deletePersistentAll()}, or {@link Query#deletePersistentAll(java.util.Map)}, or {@link - * Query#deletePersistentAll(java.lang.Object[])} depending on the type of argument - * parameters. If the number of deleted objects does not match - * expectedNrOfDeletedObjects, then the test case fails prompting argument assertion - * . - * - * @param assertion the assertion to prompt if the test case fails. - * @param queryElementHolder the query to execute. - * @param expectedNrOfDeletedObjects the expected number of deleted objects. - */ - protected void deletePersistentAllByAPIQuery( - String assertion, QueryElementHolder queryElementHolder, long expectedNrOfDeletedObjects) { - if (logger.isDebugEnabled()) { - logger.debug("Deleting persistent by API query: " + queryElementHolder); + /** + * Executes the given query instance delegating to + * execute(String, Query, String, boolean, Object, Object, boolean). + * Logs argument singleStringQuery + * if debug logging is enabled. + * @param assertion the assertion to prompt if the test case fails. + * @param query the query to execute. + * @param singleStringQuery the single string representation of the query. + * This parameter is only used as part of the falure message. + * @param hasOrdering indicates if the query has an ordering clause. + * @param parameters the parmaters of the query. + * @param expectedResult the expected query result. + * @param positive indicates if query execution is supposed to fail + * @return the query result + */ + protected Object executeJDOQuery(String assertion, Query query, + String singleStringQuery, boolean hasOrdering, + Object[] parameters, Object expectedResult, boolean positive) { + if (logger.isDebugEnabled()) { + logger.debug("Executing JDO query: " + singleStringQuery); + } + return execute(assertion, query, singleStringQuery, hasOrdering, + parameters, expectedResult, positive); } - delete(assertion, queryElementHolder, false, expectedNrOfDeletedObjects); - } - /** - * Converts the given query element holder instance to a JDO query instance. Calls {@link - * Query#deletePersistentAll()}, or {@link Query#deletePersistentAll(java.util.Map)}, or {@link - * Query#deletePersistentAll(java.lang.Object[])} depending on the type of argument - * parameters. If the number of deleted objects does not match - * expectedNrOfDeletedObjects, then the test case fails prompting argument assertion - * . - * - * @param assertion the assertion to prompt if the test case fails. - * @param queryElementHolder the query to execute. - * @param expectedNrOfDeletedObjects the expected number of deleted objects. - */ - protected void deletePersistentAllBySingleStringQuery( - String assertion, QueryElementHolder queryElementHolder, long expectedNrOfDeletedObjects) { - if (logger.isDebugEnabled()) { - logger.debug("Deleting persistent by single string query: " + queryElementHolder); + /** + * Executes the given SQL string as a JDO SQL query. + * The result of that query is compared against the given argument + * expectedResult. + * If the expected result does not match the returned query result, + * then the test case fails prompting argument assertion. + * Argument unique indicates, if the query is supposed + * to return a single result. + * Argument sql may contain the substring "{0}". + * All occurences of this substring are replaced + * by the value of PMF property "javax.jdo.mapping.Schema". + * @param assertion the assertion to prompt if the test case fails. + * @param sql the SQL string. + * @param candidateClass the candidate class. + * @param resultClass the result class. + * @param positive positive option + * @param parameters the parameters of the query. + * @param expectedResult the expected query result. + * @param unique indicates, if the query is supposed + * to return a single result. + */ + protected void executeSQLQuery(String assertion, String sql, + Class candidateClass, Class resultClass, boolean positive, + Object parameters, Object expectedResult, boolean unique) { + String schema = getPMFProperty("javax.jdo.mapping.Schema"); + sql = MessageFormat.format(sql, new Object[]{schema}); + if (logger.isDebugEnabled()) + logger.debug("Executing SQL query: " + sql); + Query query = getPM().newQuery("javax.jdo.query.SQL", sql); + if (unique) { + query.setUnique(unique); + } + if (candidateClass != null) { + query.setClass(candidateClass); + } + if (resultClass != null) { + query.setResultClass(resultClass); + } + execute(assertion, query, sql, false, + parameters, expectedResult, positive); } - delete(assertion, queryElementHolder, true, expectedNrOfDeletedObjects); - } - /** - * Converts the given query element holder instance to a - * JDO query based on argument asSingleString. - * Calls {@link Query#deletePersistentAll()}, or - * {@link Query#deletePersistentAll(java.util.Map), or - * {@link Query#deletePersistentAll(java.lang.Object[]) - * depending on the type of argument parameters. - * If the number of deleted objects does not - * match expectedNrOfDeletedObjects, - * then the test case fails prompting argument assertion. - * @param assertion the assertion to prompt if the test case fails. - * @param queryElementHolder the query to execute. - * @param asSingleString determines if the query is executed as - * single string query or as API query. - * @param parameters the parmaters of the query. - * @param expectedNrOfDeletedObjects the expected number of deleted objects. - */ - private void delete( - String assertion, - QueryElementHolder queryElementHolder, - boolean asSingleString, - long expectedNrOfDeletedObjects) { - getPM(); - Query query = - asSingleString - ? queryElementHolder.getSingleStringQuery(pm) - : queryElementHolder.getAPIQuery(pm); - delete( - assertion, - query, - queryElementHolder.toString(), - queryElementHolder.getParamValues(), - expectedNrOfDeletedObjects); - boolean positive = expectedNrOfDeletedObjects >= 0; - if (positive) { - execute( - assertion, - queryElementHolder, - asSingleString, - queryElementHolder.isUnique() ? null : new ArrayList()); + /** + * Executes the given query instance. + * If argument parameters is an object array, + * then it is passed as an argument + * to the method {@link Query#executeWithArray(java.lang.Object[])}. + * If argument parameters is a map, + * then it is passed as an argument + * to the method {@link Query#executeWithMap(java.util.Map)}. + * If argument parameters is a list, + * then the list elements are passed as arguments + * to the execute methods taking actual parameter values. + * If argument parameters is null, + * then method {@link Query#execute()} is called + * on the given query instance instead.

    + * + * The result of query execution is compared against the argument + * expectedResult. If the two values differ, + * then this method throws an {@link junit.framework.AssertionFailedError} and + * the calling test case fails prompting argument + * assertion.

    + * + * If argument positive is false, + * then the test case invoking this method is considered to be + * a negative test case. + * Then, query execution is expected to throw a {@link JDOUserException}. + * If query execution succeeds in this case, then this method throws + * an {@link junit.framework.AssertionFailedError} and the calling test case fails + * prompting argument assertion.

    + * + * @param assertion the assertion to prompt if the test case fails. + * @param query the query to execute. + * @param singleStringQuery the single string representation of the query. + * This parameter is only used as part of the falure message. + * @param hasOrdering indicates if the query has an ordering clause. + * @param parameters the parmaters of the query. + * @param expectedResult the expected query result. + * @param positive indicates if query execution is supposed to fail + * @return the query result + */ + private Object execute(String assertion, Query query, + String singleStringQuery, boolean hasOrdering, + Object parameters, Object expectedResult, boolean positive) { + Object result = null; + getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + try { + try { + if (parameters == null) { + result = query.execute(); + } else if (parameters instanceof Object[]) { + result = query.executeWithArray((Object[])parameters); + } else if (parameters instanceof Map) { + result = query.executeWithMap((Map)parameters); + } else if (parameters instanceof List) { + List list = (List) parameters; + switch (list.size()) { + case 1: + result = query.execute(list.get(0)); + break; + case 2: + result = query.execute(list.get(0), list.get(1)); + break; + case 3: + result = query.execute( + list.get(0), list.get(1), list.get(2)); + break; + default: + throw new IllegalArgumentException( + "Argument parameters is a list " + + "and must have 1, 2, or 3 elements."); + } + } else { + throw new IllegalArgumentException("Argument parameters " + + "must be instance of List, Map, Object[], or null."); + } + + if (logger.isDebugEnabled()) { + logger.debug("Query result: " + ConversionHelper. + convertObjectArrayElements(result)); + } + + checkResult(assertion, singleStringQuery, hasOrdering, result, expectedResult, positive); + + } finally { + query.close(result); + } + } catch (JDOUserException e) { + if (positive) { + String msg = "JDOUserException thrown while executing query:\n" + + singleStringQuery; + throw new JDOException(msg, e); + } + } catch (JDOException e) { + String msg = "JDOException thrown while executing query:\n" + + singleStringQuery; + throw new JDOException(msg, e); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + return result; } - } - /** - * Calls {@link Query#deletePersistentAll()}, or - * {@link Query#deletePersistentAll(java.util.Map), or - * {@link Query#deletePersistentAll(java.lang.Object[]) - * depending on the type of argument parameters. - * If the number of deleted objects does not - * match expectedNrOfDeletedObjects, - * then the test case fails prompting argument assertion. - * Argument singleStringQuery is only used as part - * of the failure message. - * @param assertion the assertion to prompt if the test case fails. - * @param query the query to execute. - * @param singleStringQuery the single string representation of the query. - * @param parameters the parmaters of the query. - * @param expectedNrOfDeletedObjects the expected number of deleted objects. - */ - private void delete( - String assertion, - Query query, - String singleStringQuery, - Object parameters, - long expectedNrOfDeletedObjects) { - boolean positive = expectedNrOfDeletedObjects >= 0; - getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - try { - try { - long nr; - if (parameters == null) { - nr = query.deletePersistentAll(); - } else if (parameters instanceof Object[]) { - nr = query.deletePersistentAll((Object[]) parameters); - } else if (parameters instanceof Map) { - nr = query.deletePersistentAll((Map) parameters); + /** + * @param assertion the assertion to prompt if the test case fails. + * @param singleStringQuery the single string representation of the query. + * This parameter is only used as part of the falure message. + * @param hasOrdering indicates if the query has an ordering clause. + * @param positive indicates if query execution is supposed to fail + * @param result the query result. + * @param expectedResult the expected query result. + */ + private void checkResult(String assertion, String singleStringQuery, boolean hasOrdering, + Object result, Object expectedResult, boolean positive) { + if (positive) { + if (hasOrdering) { + checkQueryResultWithOrder(assertion, singleStringQuery, result, + expectedResult); + } else { + checkQueryResultWithoutOrder(assertion, singleStringQuery, result, + expectedResult); + } } else { - throw new IllegalArgumentException( - "Argument parameters " + "must be instance of Object[], Map, or null."); + fail(assertion, "Query must throw JDOUserException: " + + singleStringQuery); } + } + + /** + * Converts the given query element holder instance to a + * JDO query instance. + * Calls {@link Query#deletePersistentAll()}, or + * {@link Query#deletePersistentAll(java.util.Map)}, or + * {@link Query#deletePersistentAll(java.lang.Object[])} + * depending on the type of argument parameters. + * If the number of deleted objects does not + * match expectedNrOfDeletedObjects, + * then the test case fails prompting argument assertion. + * @param assertion the assertion to prompt if the test case fails. + * @param queryElementHolder the query to execute. + * @param expectedNrOfDeletedObjects the expected number of deleted objects. + */ + protected void deletePersistentAllByAPIQuery(String assertion, + QueryElementHolder queryElementHolder, + long expectedNrOfDeletedObjects) { if (logger.isDebugEnabled()) { - logger.debug(nr + " objects deleted."); + logger.debug("Deleting persistent by API query: " + + queryElementHolder); } + delete(assertion, queryElementHolder, false, expectedNrOfDeletedObjects); + } + + /** + * Converts the given query element holder instance to a + * JDO query instance. + * Calls {@link Query#deletePersistentAll()}, or + * {@link Query#deletePersistentAll(java.util.Map)}, or + * {@link Query#deletePersistentAll(java.lang.Object[])} + * depending on the type of argument parameters. + * If the number of deleted objects does not + * match expectedNrOfDeletedObjects, + * then the test case fails prompting argument assertion. + * @param assertion the assertion to prompt if the test case fails. + * @param queryElementHolder the query to execute. + * @param expectedNrOfDeletedObjects the expected number of deleted objects. + */ + protected void deletePersistentAllBySingleStringQuery(String assertion, + QueryElementHolder queryElementHolder, long expectedNrOfDeletedObjects) { + if (logger.isDebugEnabled()) { + logger.debug("Deleting persistent by single string query: " + + queryElementHolder); + } + delete(assertion, queryElementHolder, true, expectedNrOfDeletedObjects); + } + /** + * Converts the given query element holder instance to a + * JDO query based on argument asSingleString. + * Calls {@link Query#deletePersistentAll()}, or + * {@link Query#deletePersistentAll(java.util.Map), or + * {@link Query#deletePersistentAll(java.lang.Object[]) + * depending on the type of argument parameters. + * If the number of deleted objects does not + * match expectedNrOfDeletedObjects, + * then the test case fails prompting argument assertion. + * @param assertion the assertion to prompt if the test case fails. + * @param queryElementHolder the query to execute. + * @param asSingleString determines if the query is executed as + * single string query or as API query. + * @param parameters the parmaters of the query. + * @param expectedNrOfDeletedObjects the expected number of deleted objects. + */ + private void delete(String assertion, + QueryElementHolder queryElementHolder, boolean asSingleString, long expectedNrOfDeletedObjects) { + getPM(); + Query query = asSingleString ? + queryElementHolder.getSingleStringQuery(pm) : + queryElementHolder.getAPIQuery(pm); + delete(assertion, query, queryElementHolder.toString(), + queryElementHolder.getParamValues(), expectedNrOfDeletedObjects); + boolean positive = expectedNrOfDeletedObjects >= 0; if (positive) { - if (nr != expectedNrOfDeletedObjects) { - fail( - assertion, - "deletePersistentAll returned " - + nr - + ", expected is " - + expectedNrOfDeletedObjects - + ". Query: " - + singleStringQuery); - } - } else { - fail(assertion, "deletePersistentAll must throw JDOUserException: " + singleStringQuery); + execute(assertion, queryElementHolder, asSingleString, + queryElementHolder.isUnique() ? null : new ArrayList()); + } + } + + /** + * Calls {@link Query#deletePersistentAll()}, or + * {@link Query#deletePersistentAll(java.util.Map), or + * {@link Query#deletePersistentAll(java.lang.Object[]) + * depending on the type of argument parameters. + * If the number of deleted objects does not + * match expectedNrOfDeletedObjects, + * then the test case fails prompting argument assertion. + * Argument singleStringQuery is only used as part + * of the failure message. + * @param assertion the assertion to prompt if the test case fails. + * @param query the query to execute. + * @param singleStringQuery the single string representation of the query. + * @param parameters the parmaters of the query. + * @param expectedNrOfDeletedObjects the expected number of deleted objects. + */ + private void delete(String assertion, Query query, + String singleStringQuery, Object parameters, + long expectedNrOfDeletedObjects) { + boolean positive = expectedNrOfDeletedObjects >= 0; + getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + try { + try { + long nr; + if (parameters == null) { + nr = query.deletePersistentAll(); + } else if (parameters instanceof Object[]) { + nr = query.deletePersistentAll((Object[])parameters); + } else if (parameters instanceof Map) { + nr = query.deletePersistentAll((Map)parameters); + } else { + throw new IllegalArgumentException("Argument parameters " + + "must be instance of Object[], Map, or null."); + } + if (logger.isDebugEnabled()) { + logger.debug(nr + " objects deleted."); + } + + if (positive) { + if (nr != expectedNrOfDeletedObjects) { + fail(assertion, "deletePersistentAll returned " + nr + + ", expected is " + expectedNrOfDeletedObjects + + ". Query: " + singleStringQuery); + } + } else { + fail(assertion, "deletePersistentAll must throw JDOUserException: " + + singleStringQuery); + } + } finally { + query.closeAll(); + } + tx.commit(); + } catch (JDOUserException e) { + if (positive) { + String msg = "JDOUserException thrown while executing query:\n" + + singleStringQuery; + throw new JDOException(msg, e); + } + } catch (JDOException e) { + String msg = "JDOException thrown while executing query:\n" + + singleStringQuery; + throw new JDOException(msg, e); + } finally { + if (tx.isActive()) { + tx.rollback(); + } } - } finally { - query.closeAll(); - } - tx.commit(); - } catch (JDOUserException e) { - if (positive) { - String msg = "JDOUserException thrown while executing query:\n" + singleStringQuery; - throw new JDOException(msg, e); - } - } catch (JDOException e) { - String msg = "JDOException thrown while executing query:\n" + singleStringQuery; - throw new JDOException(msg, e); - } finally { - if (tx.isActive()) { - tx.rollback(); - } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/AutoCloseable.java b/tck/src/main/java/org/apache/jdo/tck/query/api/AutoCloseable.java index 836261a08..44bdf59ad 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/AutoCloseable.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/AutoCloseable.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,233 +20,233 @@ import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; + import javax.jdo.JDOUserException; -import javax.jdo.PersistenceManager; import javax.jdo.Query; +import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.pc.mylib.PCPoint; + import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.pc.mylib.PCPoint; /** - * Title: AutoCloseable
    - * Keywords: query close
    - * Assertion IDs: A14.6.7-3.
    - * Assertion Description: In a non-managed environment, if the query is created with - * try-with-resources all results of execute(...) methods on this query instance are automatically + *Title: AutoCloseable + *
    + *Keywords: query close + *
    + *Assertion IDs: A14.6.7-3. + *
    + *Assertion Description: + * In a non-managed environment, if the query is created with try-with-resources + * all results of execute(...) methods on this query instance are automatically * closed at the end of that block and all resources associated with it are released. */ public class AutoCloseable extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.7-3 (AutoCloseable) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(AutoCloseable.class); + } - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.7-3 (AutoCloseable) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(AutoCloseable.class); - } - - /** - * This methods creates a query instance with try-with-resources and checks that an iterator for - * the query result is not accessible after the block. - */ - public void testTryWithResource() { - - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - - try { - tx.begin(); - - Query query = null; - List queryResult = null; - Iterator iterator = null; - try (Query query1 = pm.newQuery(PCPoint.class)) { - query = query1; - queryResult = (List) query1.execute(); - iterator = queryResult.iterator(); - if (!iterator.hasNext()) { - fail(ASSERTION_FAILED, "(1) Iterator of open query result should have elements."); + /** + * This methods creates a query instance with try-with-resources and + * checks that an iterator for the query result is not accessible after the block. + */ + public void testTryWithResource() { + + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + + try { + tx.begin(); + + Query query = null; + List queryResult = null; + Iterator iterator = null; + try (Query query1 = pm.newQuery(PCPoint.class)) { + query = query1; + queryResult = (List) query1.execute(); + iterator = queryResult.iterator(); + if (!iterator.hasNext()) { + fail(ASSERTION_FAILED, "(1) Iterator of open query result should have elements."); + } + } catch (Exception ex) { + fail(ASSERTION_FAILED, "(2) Unexpected exception " + ex); + } + + // check iterator retrieved in try-with-resource block + if (iterator.hasNext()) { + fail(ASSERTION_FAILED, + "(3) Iterator of closed query result should return false on hasNext()."); + } + try { + PCPoint next = iterator.next(); + fail(ASSERTION_FAILED, + "(4) Iterator of closed query result should throw NoSuchElementException on next()."); + } catch (NoSuchElementException ex) { + // expected exception + } + + // create new Iterator and check its behaviour + Iterator iterator2 = queryResult.iterator(); + if (iterator2.hasNext()) { + fail(ASSERTION_FAILED, + "(5) Iterator of closed query result should return false on hasNext()."); + } + try { + PCPoint next = iterator2.next(); + fail(ASSERTION_FAILED, + "(6) Iterator of closed query result should throw NoSuchElementException on next()."); + } catch (NoSuchElementException ex) { + // expected exception + } + + // check query result itself + try { + int size = queryResult.size(); + fail(ASSERTION_FAILED, "(7) closed query result should not be accessible."); + } catch (JDOUserException ex) { + // expected exception when accessing closed query result + } + try { + PCPoint elem = queryResult.get(0); + fail(ASSERTION_FAILED, "(8) closed query result should not be accessible."); + } catch (JDOUserException ex) { + // expected exception when accessing closed query result + } + try { + boolean empty = queryResult.isEmpty(); + fail(ASSERTION_FAILED, "(9) closed query result should not be accessible."); + } catch (JDOUserException ex) { + // expected exception when accessing closed query result + } + // Check query instance is still usable + queryResult = (List) query.execute(); + if (queryResult.isEmpty()) { + fail(ASSERTION_FAILED, + "(10) query instance should be usable and execution should return a non empty result."); + } + + tx.commit(); + } finally { + if (tx != null && tx.isActive()) { + tx.rollback(); + } } - } catch (Exception ex) { - fail(ASSERTION_FAILED, "(2) Unexpected exception " + ex); - } - - // check iterator retrieved in try-with-resource block - if (iterator.hasNext()) { - fail( - ASSERTION_FAILED, - "(3) Iterator of closed query result should return false on hasNext()."); - } - try { - PCPoint next = iterator.next(); - fail( - ASSERTION_FAILED, - "(4) Iterator of closed query result should throw NoSuchElementException on next()."); - } catch (NoSuchElementException ex) { - // expected exception - } - - // create new Iterator and check its behaviour - Iterator iterator2 = queryResult.iterator(); - if (iterator2.hasNext()) { - fail( - ASSERTION_FAILED, - "(5) Iterator of closed query result should return false on hasNext()."); - } - try { - PCPoint next = iterator2.next(); - fail( - ASSERTION_FAILED, - "(6) Iterator of closed query result should throw NoSuchElementException on next()."); - } catch (NoSuchElementException ex) { - // expected exception - } - - // check query result itself - try { - int size = queryResult.size(); - fail(ASSERTION_FAILED, "(7) closed query result should not be accessible."); - } catch (JDOUserException ex) { - // expected exception when accessing closed query result - } - try { - PCPoint elem = queryResult.get(0); - fail(ASSERTION_FAILED, "(8) closed query result should not be accessible."); - } catch (JDOUserException ex) { - // expected exception when accessing closed query result - } - try { - boolean empty = queryResult.isEmpty(); - fail(ASSERTION_FAILED, "(9) closed query result should not be accessible."); - } catch (JDOUserException ex) { - // expected exception when accessing closed query result - } - // Check query instance is still usable - queryResult = (List) query.execute(); - if (queryResult.isEmpty()) { - fail( - ASSERTION_FAILED, - "(10) query instance should be usable and execution should return a non empty result."); - } - - tx.commit(); - } finally { - if (tx != null && tx.isActive()) { - tx.rollback(); - } } - } - - /** - * This methods creates a query instance with try-with-resources and checks that an iterator for - * the query result is not accessible after the block, if the block is ended with an exception. - */ - public void testTryWithResourceThrowingException() { - - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - - try { - tx.begin(); - - Query query = null; - List queryResult = null; - Iterator iterator = null; - try (Query query1 = pm.newQuery(PCPoint.class)) { - query = query1; - queryResult = (List) query1.execute(); - iterator = queryResult.iterator(); - if (!iterator.hasNext()) { - fail(ASSERTION_FAILED, "(1) Iterator of open query result should have elements."); + + /** + * This methods creates a query instance with try-with-resources and + * checks that an iterator for the query result is not accessible after the block, + * if the block is ended with an exception. + */ + public void testTryWithResourceThrowingException() { + + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + + try { + tx.begin(); + + Query query = null; + List queryResult = null; + Iterator iterator = null; + try (Query query1 = pm.newQuery(PCPoint.class)) { + query = query1; + queryResult = (List) query1.execute(); + iterator = queryResult.iterator(); + if (!iterator.hasNext()) { + fail(ASSERTION_FAILED, "(1) Iterator of open query result should have elements."); + } + throw new DummyException(); + } catch (DummyException ex) { + // expected exception + } catch (Exception ex) { + fail(ASSERTION_FAILED, "(2) Unexpected exception " + ex); + } + + // check iterator retrieved in try-with-resource block + if (iterator.hasNext()) { + fail(ASSERTION_FAILED, + "(3) Iterator of closed query result should return false on hasNext()."); + } + try { + PCPoint next = iterator.next(); + fail(ASSERTION_FAILED, + "(4) Iterator of closed query result should throw NoSuchElementException on next()."); + } catch (NoSuchElementException ex) { + // expected exception + } + + // create new Iterator and check its behaviour + Iterator iterator2 = queryResult.iterator(); + if (iterator2.hasNext()) { + fail(ASSERTION_FAILED, + "(5) Iterator of closed query result should return false on hasNext()."); + } + try { + PCPoint next = iterator2.next(); + fail(ASSERTION_FAILED, + "(6) Iterator of closed query result should throw NoSuchElementException on next()."); + } catch (NoSuchElementException ex) { + // expected exception + } + + // check query result itself + try { + int size = queryResult.size(); + fail(ASSERTION_FAILED, "(7) closed query result should not be accessible."); + } catch (JDOUserException ex) { + // expected exception when accessing closed query result + } + try { + PCPoint elem = queryResult.get(0); + fail(ASSERTION_FAILED, "(8) closed query result should not be accessible."); + } catch (JDOUserException ex) { + // expected exception when accessing closed query result + } + try { + boolean empty = queryResult.isEmpty(); + fail(ASSERTION_FAILED, "(9) closed query result should not be accessible."); + } catch (JDOUserException ex) { + // expected exception when accessing closed query result + } + + // Check query instance is still usable + queryResult = (List) query.execute(); + if (queryResult.isEmpty()) { + fail(ASSERTION_FAILED, + "(10) query instance should be usable and execution should return a non empty result."); + } + + tx.commit(); + } finally { + if (tx != null && tx.isActive()) { + tx.rollback(); + } } - throw new DummyException(); - } catch (DummyException ex) { - // expected exception - } catch (Exception ex) { - fail(ASSERTION_FAILED, "(2) Unexpected exception " + ex); - } - - // check iterator retrieved in try-with-resource block - if (iterator.hasNext()) { - fail( - ASSERTION_FAILED, - "(3) Iterator of closed query result should return false on hasNext()."); - } - try { - PCPoint next = iterator.next(); - fail( - ASSERTION_FAILED, - "(4) Iterator of closed query result should throw NoSuchElementException on next()."); - } catch (NoSuchElementException ex) { - // expected exception - } - - // create new Iterator and check its behaviour - Iterator iterator2 = queryResult.iterator(); - if (iterator2.hasNext()) { - fail( - ASSERTION_FAILED, - "(5) Iterator of closed query result should return false on hasNext()."); - } - try { - PCPoint next = iterator2.next(); - fail( - ASSERTION_FAILED, - "(6) Iterator of closed query result should throw NoSuchElementException on next()."); - } catch (NoSuchElementException ex) { - // expected exception - } - - // check query result itself - try { - int size = queryResult.size(); - fail(ASSERTION_FAILED, "(7) closed query result should not be accessible."); - } catch (JDOUserException ex) { - // expected exception when accessing closed query result - } - try { - PCPoint elem = queryResult.get(0); - fail(ASSERTION_FAILED, "(8) closed query result should not be accessible."); - } catch (JDOUserException ex) { - // expected exception when accessing closed query result - } - try { - boolean empty = queryResult.isEmpty(); - fail(ASSERTION_FAILED, "(9) closed query result should not be accessible."); - } catch (JDOUserException ex) { - // expected exception when accessing closed query result - } - - // Check query instance is still usable - queryResult = (List) query.execute(); - if (queryResult.isEmpty()) { - fail( - ASSERTION_FAILED, - "(10) query instance should be usable and execution should return a non empty result."); - } - - tx.commit(); - } finally { - if (tx != null && tx.isActive()) { - tx.rollback(); - } } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } - - /** DummyException used in method testTryWithResourceThrowingException. */ - private static final class DummyException extends Exception {} + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); + } + + /** + * DummyException used in method testTryWithResourceThrowingException. + */ + private static final class DummyException extends Exception {} } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/ChangeQuery.java b/tck/src/main/java/org/apache/jdo/tck/query/api/ChangeQuery.java index d07ad49d5..877a1cd84 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/ChangeQuery.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/ChangeQuery.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,7 +20,10 @@ import java.math.BigDecimal; import java.util.Arrays; import java.util.List; + import javax.jdo.Query; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.FullTimeEmployee; import org.apache.jdo.tck.pc.company.Person; @@ -29,73 +32,76 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Change Query.
    - * Keywords: query
    - * Assertion ID: A14.5-15.
    - * Assertion Description: The Query instance returned from this method can be modified by - * the application, just like any other Query instance. + *Title: Change Query. + *
    + *Keywords: query + *
    + *Assertion ID: A14.5-15. + *
    + *Assertion Description: + * The Query instance returned from this method can be modified + * by the application, just like any other Query instance. */ public class ChangeQuery extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.5-15 (ChangeQuery) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ChangeQuery.class); - } - - /** */ - public void testPositive() { - Query query = getPM().newNamedQuery(Person.class, "changeQuery"); - - // change query - query.setResult("DISTINCT firstname, lastname"); - query.setResultClass(FullName.class); - query.setClass(FullTimeEmployee.class); - String filter = "salary > 1000 & projects.contains(p) & " + "p.budget > limit"; - query.setFilter(filter); - String imports = - "import org.apache.jdo.tck.pc.company.Project; " + "import java.math.BigDecimal;"; - query.declareImports(imports); - query.declareVariables("Project p"); - query.declareParameters("BigDecimal limit"); - query.setOrdering("firstname ASCENDING, lastname ASCENDING"); - query.setRange(0, 5); - String singleStringQuery = - "SELECT DISTINCT firstname, lastname " - + "INTO FullName FROM FullTimeEmployee " - + "WHERE salary > 1000 & projects.contains(p) & " - + "p.budget > limit " - + "VARIABLES Project p PARAMETERS BigDecimal limit " - + "ORDER BY firstname ASCENDING, lastname ASCENDING RANGE 0, 5"; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.5-15 (ChangeQuery) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ChangeQuery.class); + } + + /** */ + public void testPositive() { + Query query = getPM().newNamedQuery(Person.class, "changeQuery"); + + // change query + query.setResult("DISTINCT firstname, lastname"); + query.setResultClass(FullName.class); + query.setClass(FullTimeEmployee.class); + String filter = "salary > 1000 & projects.contains(p) & " + + "p.budget > limit"; + query.setFilter(filter); + String imports = "import org.apache.jdo.tck.pc.company.Project; " + + "import java.math.BigDecimal;"; + query.declareImports(imports); + query.declareVariables("Project p"); + query.declareParameters("BigDecimal limit"); + query.setOrdering("firstname ASCENDING, lastname ASCENDING"); + query.setRange(0, 5); + String singleStringQuery = + "SELECT DISTINCT firstname, lastname " + + "INTO FullName FROM FullTimeEmployee " + + "WHERE salary > 1000 & projects.contains(p) & " + + "p.budget > limit " + + "VARIABLES Project p PARAMETERS BigDecimal limit " + + "ORDER BY firstname ASCENDING, lastname ASCENDING RANGE 0, 5"; - // query parameters - Object[] parameters = {new BigDecimal("2000")}; - // expected result - List expectedResult = - Arrays.asList( - new Object[] { - new FullName("emp1First", "emp1Last"), - new FullName("emp2First", "emp2Last"), - new FullName("emp5First", "emp5Last") - }); + // query parameters + Object[] parameters = {new BigDecimal("2000")}; + // expected result + List expectedResult = Arrays.asList(new Object[] { + new FullName("emp1First", "emp1Last"), + new FullName("emp2First", "emp2Last"), + new FullName("emp5First", "emp5Last")}); - // execute query - executeJDOQuery( - ASSERTION_FAILED, query, singleStringQuery, true, parameters, expectedResult, true); - } + // execute query + executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery, true, + parameters, expectedResult, true); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/Close.java b/tck/src/main/java/org/apache/jdo/tck/query/api/Close.java index df01fa171..1b1ea71c7 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/Close.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/Close.java @@ -5,16 +5,16 @@ * 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 + * + * 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.jdo.tck.query.api; import java.util.ArrayList; @@ -22,104 +22,116 @@ import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Close
    - * Keywords: query
    - * Assertion ID: A14.6.7-1.
    - * Assertion Description: Query.close(Object) closes the result of one - * execute(...) method, and releases resources associated with it. After this method - * completes, the query result can no longer be used, for example to iterate the returned elements. - * Any elements returned previously by iteration of the results remain in their current state. Any - * iterators acquired from the queryResult will return false to hasNext() - * and will throw NoSuchElementException to next(). + *Title: Close + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.7-1. + *
    + *Assertion Description: Query.close(Object) closes the + *result of one execute(...) method, and releases resources + *associated with it. After this method completes, the query result can no + *longer be used, for example to iterate the returned elements. Any elements + *returned previously by iteration of the results remain in their current state. + *Any iterators acquired from the queryResult will return false to + *hasNext() and will throw NoSuchElementException to + *next(). */ -public class Close extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.7-1 (Close) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Close.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - - if (debug) logger.debug("\nExecuting test Close()..."); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - Object results = query.execute(); - - // check query result - List expected = new ArrayList(); - Object p1 = new PCPoint(0, 0); - Object p2 = new PCPoint(1, 1); - Object p3 = new PCPoint(2, 2); - Object p4 = new PCPoint(3, 3); - Object p5 = new PCPoint(4, 4); - - expected.add(p1); - expected.add(p2); - expected.add(p3); - expected.add(p4); - expected.add(p5); - - expected = getFromInserted(expected); - - // printOutput(results); - - checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected); - if (debug) - logger.debug("Test Close: Results are as expected and accessible before query is closed"); - - Iterator resIterator = ((Collection) results).iterator(); - query.close(results); +public class Close extends QueryTest { - if (resIterator.hasNext()) { - fail( - ASSERTION_FAILED, - "Iterator.hasNext() should return false after closing the query result."); - } - try { - resIterator.next(); - fail( - ASSERTION_FAILED, - "Iterator.hasNext() should throw NoSuchElementException after closing the query result."); - } catch (NoSuchElementException ex) { - // expected exception - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.7-1 (Close) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Close.class); + } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + + if (debug) logger.debug("\nExecuting test Close()..."); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + Object results = query.execute(); + + // check query result + List expected = new ArrayList(); + + Object p1 = new PCPoint(0, 0); + Object p2 = new PCPoint(1, 1); + Object p3 = new PCPoint(2, 2); + Object p4 = new PCPoint(3, 3); + Object p5 = new PCPoint(4, 4); + + expected.add(p1); + expected.add(p2); + expected.add(p3); + expected.add(p4); + expected.add(p5); + + expected = getFromInserted(expected); + + // printOutput(results); + + checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected); + if (debug) + logger.debug("Test Close: Results are as expected and accessible before query is closed"); + + Iterator resIterator = ((Collection)results).iterator(); + query.close(results); + + if(resIterator.hasNext()) { + fail(ASSERTION_FAILED, + "Iterator.hasNext() should return false after closing the query result."); + } + try { + resIterator.next(); + fail(ASSERTION_FAILED, + "Iterator.hasNext() should throw NoSuchElementException after closing the query result."); + } + catch (NoSuchElementException ex) { + // expected exception + } + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/CloseAll.java b/tck/src/main/java/org/apache/jdo/tck/query/api/CloseAll.java index b810d83ca..b4f1bad8e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/CloseAll.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/CloseAll.java @@ -5,94 +5,103 @@ * 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 + * + * 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.jdo.tck.query.api; + import java.util.Collection; import java.util.Iterator; import java.util.NoSuchElementException; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Close All
    - * Keywords: query
    - * Assertion ID: A14.6.7-2.
    - * Assertion Description: Query.closeAll() closes all results of - * execute(...) methods on this Query instance, as in A14.6.7-1. The Query - * instance is still valid and can still be used. + *Title: Close All + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.7-2. + *
    + *Assertion Description: Query.closeAll() closes all results of execute(...) methods on this Query instance, as in A14.6.7-1. The Query instance is still valid and can still be used. */ -public class CloseAll extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.7-2 (CloseAll) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CloseAll.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); +public class CloseAll extends QueryTest { - if (debug) logger.debug("\nExecuting test CloseAll()..."); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.7-2 (CloseAll) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CloseAll.class); + } - Collection results = (Collection) query.execute(); - Iterator resIterator = results.iterator(); + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); - query.closeAll(); + if (debug) logger.debug("\nExecuting test CloseAll()..."); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + + Collection results = (Collection)query.execute(); + Iterator resIterator = results.iterator(); - if (resIterator.hasNext()) { - fail( - ASSERTION_FAILED, - "Iterator.hasNext() should return false after closing all query results."); - } + query.closeAll(); - try { - resIterator.next(); - fail( - ASSERTION_FAILED, - "Iterator.hasNext() should throw NoSuchElementException after closing all query results."); - } catch (NoSuchElementException ex) { - // expected exception - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + if (resIterator.hasNext()) { + fail(ASSERTION_FAILED, + "Iterator.hasNext() should return false after closing all query results."); + } + + try { + resIterator.next(); + fail(ASSERTION_FAILED, + "Iterator.hasNext() should throw NoSuchElementException after closing all query results."); + } + catch (NoSuchElementException ex) { + // expected exception + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/CompileQuery.java b/tck/src/main/java/org/apache/jdo/tck/query/api/CompileQuery.java index 292221b27..2cc3249b2 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/CompileQuery.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/CompileQuery.java @@ -5,89 +5,97 @@ * 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 + * + * 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.jdo.tck.query.api; + import java.util.ArrayList; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Compile Query
    - * Keywords: query
    - * Assertion ID: A14.6-14.
    - * Assertion Description: Query.compile() requires the Query - * instance to validate any elements bound to the query instance and report any inconsistencies by - * throwing a JDOUserException. It is only a hint to the Query instance to - * prepare and optimize an execution plan for the query, implementations are not required to support - * query compilation. + *Title: Compile Query + *
    + *Keywords: query + *
    + *Assertion ID: A14.6-14. + *
    + *Assertion Description: Query.compile() requires the Query instance to validate any elements bound to the query instance and report any inconsistencies by throwing a JDOUserException. It is only a hint to the Query instance to prepare and optimize an execution plan for the query, implementations are not required to support query compilation. */ -public class CompileQuery extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6-14 (CompileQuery) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CompileQuery.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); +public class CompileQuery extends QueryTest { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - String params = "Integer param"; - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.declareParameters(params); - query.setFilter("x == param"); - query.compile(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-14 (CompileQuery) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CompileQuery.class); + } - Object results = query.execute(Integer.valueOf(4)); + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); - // check query result - List expected = new ArrayList(); - Object p5 = new PCPoint(4, 4); - expected.add(p5); - expected = getFromInserted(expected); - printOutput(results, expected); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + String params = "Integer param"; + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.declareParameters(params); + query.setFilter("x == param"); + query.compile(); + + Object results = query.execute(Integer.valueOf(4)); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == param", results, expected); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + // check query result + List expected = new ArrayList(); + Object p5 = new PCPoint(4, 4); + expected.add(p5); + expected = getFromInserted(expected); + printOutput(results, expected); + + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == param", + results, expected); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/DeclareImports.java b/tck/src/main/java/org/apache/jdo/tck/query/api/DeclareImports.java index ed205fd7d..a7f20ae43 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/DeclareImports.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/DeclareImports.java @@ -5,145 +5,158 @@ * 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 + * + * 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.jdo.tck.query.api; + import java.util.ArrayList; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; -import org.apache.jdo.tck.pc.company.Company; -import org.apache.jdo.tck.pc.company.Department; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.pc.company.Department; +import org.apache.jdo.tck.pc.company.Company; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.util.ConversionHelper; /** - * Title: Declare Imports
    - * Keywords: query
    - * Assertion ID: A14.6-8.
    - * Assertion Description: Query.declareImports(String imports) binds the import - * statements to the query instance. All imports must be declared in the same method call, and the - * imports must be separated by semicolons. + *Title: Declare Imports + *
    + *Keywords: query + *
    + *Assertion ID: A14.6-8. + *
    + *Assertion Description: Query.declareImports(String imports) binds the import statements to the query instance. All imports must be declared in the same method call, and the imports must be separated by semicolons. */ + public class DeclareImports extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6-8 (DeclareImports) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DeclareImports.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTestDeclareImports01(pm); - runTestDeclareImports02(pm); - runTestDeclareImports03(pm); - - pm.close(); - pm = null; - } - - private void runTestDeclareImports01(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.declareImports("import java.lang.Integer"); - query.declareParameters("Integer param"); - query.setFilter("y == param"); - Object results = query.execute(Integer.valueOf(2)); - - // check query result - List expected = new ArrayList(); - Object p3 = new PCPoint(2, 2); - expected.add(p3); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "y == param", results, expected); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-8 (DeclareImports) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DeclareImports.class); } - } - - /** */ - private void runTestDeclareImports02(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(Department.class); - query.setCandidates(pm.getExtent(Department.class, false)); - query.declareImports("import org.apache.jdo.tck.pc.company.Employee"); - query.declareVariables("Employee e"); - query.setFilter("employees.contains(e) && e.firstname==\"Michael\""); - Object results = query.execute(); - - // Just check whether query with import declaration compiles - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void test() { + pm = getPM(); + + runTestDeclareImports01(pm); + runTestDeclareImports02(pm); + runTestDeclareImports03(pm); + + pm.close(); + pm = null; } - } - - /** */ - private void runTestDeclareImports03(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(Company.class); - query.setCandidates(pm.getExtent(Company.class, false)); - query.declareImports( - "import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.Department"); - query.declareVariables("Department d; Employee e"); - query.setFilter( - "departments.contains(d) && (d.employees.contains(e) && e.firstname==\"Michael\")"); - Object results = query.execute(); - - // Just check whether query with import declarations compiles - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + private void runTestDeclareImports01(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.declareImports("import java.lang.Integer"); + query.declareParameters("Integer param"); + query.setFilter("y == param"); + Object results = query.execute(Integer.valueOf(2)); + + // check query result + List expected = new ArrayList(); + Object p3 = new PCPoint(2, 2); + expected.add(p3); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "y == param", + results, expected); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void runTestDeclareImports02(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(Department.class); + query.setCandidates(pm.getExtent(Department.class, false)); + query.declareImports("import org.apache.jdo.tck.pc.company.Employee"); + query.declareVariables("Employee e" ); + query.setFilter("employees.contains(e) && e.firstname==\"Michael\"" ); + Object results = query.execute(); + + // Just check whether query with import declaration compiles + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void runTestDeclareImports03(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(Company.class); + query.setCandidates(pm.getExtent(Company.class, false)); + query.declareImports("import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.Department"); + query.declareVariables("Department d; Employee e" ); + query.setFilter("departments.contains(d) && (d.employees.contains(e) && e.firstname==\"Michael\")"); + Object results = query.execute(); + + // Just check whether query with import declarations compiles + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/DeclareParameters.java b/tck/src/main/java/org/apache/jdo/tck/query/api/DeclareParameters.java index 7c806ddee..757d42bc2 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/DeclareParameters.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/DeclareParameters.java @@ -5,146 +5,164 @@ * 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 + * + * 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.jdo.tck.query.api; + import java.util.ArrayList; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Declare Parameters
    - * Keywords: query
    - * Assertion ID: A14.6-10.
    - * Assertion Description: Query.declareParameters(String parameters) binds the - * parameter statements to the query instance. This method defines the parameter types and names - * which will be used by a subsequent execute method. + *Title: Declare Parameters + *
    + *Keywords: query + *
    + *Assertion ID: A14.6-10. + *
    + *Assertion Description: Query.declareParameters(String parameters) binds the parameter statements to the query instance. This method defines the parameter types and names which will be used by a subsequent execute method. */ + public class DeclareParameters extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6-10 (DeclareParameters) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DeclareParameters.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - - runTestDeclareParameters01(pm); - runTestDeclareParameters02(pm); - runTestDeclareParameters03(pm); - } - - /** */ - private void runTestDeclareParameters01(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.declareParameters("Integer param"); - query.setFilter("x == param"); - Object results = query.execute(Integer.valueOf(2)); - - // check query result - List expected = new ArrayList(); - Object p3 = new PCPoint(2, 2); - expected.add(p3); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == param", results, expected); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-10 (DeclareParameters) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DeclareParameters.class); } - } - - /** */ - private void runTestDeclareParameters02(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.declareParameters("Integer param1, Integer param2"); - query.setFilter("x == param1 && y == param2"); - Object results = query.execute(Integer.valueOf(2), Integer.valueOf(2)); - - // check query result - List expected = new ArrayList(); - Object p3 = new PCPoint(2, 2); - expected.add(p3); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, "x == param1 && y == param2", results, expected); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + + runTestDeclareParameters01(pm); + runTestDeclareParameters02(pm); + runTestDeclareParameters03(pm); } - } - - /** */ - void runTestDeclareParameters03(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.declareParameters("int a, int b"); - query.setFilter("x == a && y == b"); - Object results = query.execute(Integer.valueOf(1), Integer.valueOf(1)); - - // check query result - List expected = new ArrayList(); - Object p = new PCPoint(1, 1); - expected.add(p); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == a && y == b", results, expected); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + private void runTestDeclareParameters01(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.declareParameters("Integer param"); + query.setFilter("x == param"); + Object results = query.execute(Integer.valueOf(2)); + + // check query result + List expected = new ArrayList(); + Object p3 = new PCPoint(2, 2); + expected.add(p3); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == param", + results, expected); + tx.commit(); + tx = null; + } + + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void runTestDeclareParameters02(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.declareParameters("Integer param1, Integer param2"); + query.setFilter("x == param1 && y == param2"); + Object results = query.execute(Integer.valueOf(2), Integer.valueOf(2)); + + // check query result + List expected = new ArrayList(); + Object p3 = new PCPoint(2, 2); + expected.add(p3); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, + "x == param1 && y == param2", + results, expected); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + void runTestDeclareParameters03(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.declareParameters("int a, int b"); + query.setFilter("x == a && y == b"); + Object results = query.execute(Integer.valueOf(1), Integer.valueOf(1)); + + // check query result + List expected = new ArrayList(); + Object p = new PCPoint(1, 1); + expected.add(p); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == a && y == b", + results, expected); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/DeclareVariables.java b/tck/src/main/java/org/apache/jdo/tck/query/api/DeclareVariables.java index 6cad8f35b..226bd423a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/DeclareVariables.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/DeclareVariables.java @@ -5,101 +5,112 @@ * 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 + * + * 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.jdo.tck.query.api; + +import java.util.ArrayList; +import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Declare Variables
    - * Keywords: query
    - * Assertion ID: A14.6-9.
    - * Assertion Description: Query.declareVariables(String variables) binds the - * unbound variable statements to the query instance. This method defines the types and names of - * variables that will be used in the filter but not provided as values by the execute - * method. + *Title: Declare Variables + *
    + *Keywords: query + *
    + *Assertion ID: A14.6-9. + *
    + *Assertion Description: Query.declareVariables(String variables) binds the unbound variable statements to the query instance. This method defines the types and names of variables that will be used in the filter but not provided as values by the execute method. */ + public class DeclareVariables extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6-9 (DeclareVariables) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DeclareVariables.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTestDeclareVariables01(pm); - runTestDeclareVariables02(pm); - - pm.close(); - pm = null; - } - - /** */ - private void runTestDeclareVariables01(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(Department.class); - query.setCandidates(pm.getExtent(Department.class, false)); - query.declareVariables("org.apache.jdo.tck.pc.company.Employee e"); - query.setFilter("employees.contains(e) && e.firstname==\"Michael\""); - Object results = query.execute(); - - // Just check whether query compiles - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-9 (DeclareVariables) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DeclareVariables.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTestDeclareVariables01(pm); + runTestDeclareVariables02(pm); + + pm.close(); + pm = null; + } + + /** */ + private void runTestDeclareVariables01(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(Department.class); + query.setCandidates(pm.getExtent(Department.class, false)); + query.declareVariables("org.apache.jdo.tck.pc.company.Employee e" ); + query.setFilter("employees.contains(e) && e.firstname==\"Michael\"" ); + Object results = query.execute(); + + // Just check whether query compiles + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - private void runTestDeclareVariables02(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(Department.class); - query.setCandidates(pm.getExtent(Department.class, false)); - query.declareVariables( - "org.apache.jdo.tck.pc.company.Employee e; org.apache.jdo.tck.pc.company.Project p;"); - query.setFilter("employees.contains(e) && (e.projects.contains(p) && p.projid == 1)"); - Object results = query.execute(); - - // Just check whether query compiles - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + private void runTestDeclareVariables02(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(Department.class); + query.setCandidates(pm.getExtent(Department.class, false)); + query.declareVariables("org.apache.jdo.tck.pc.company.Employee e; org.apache.jdo.tck.pc.company.Project p;"); + query.setFilter("employees.contains(e) && (e.projects.contains(p) && p.projid == 1)"); + Object results = query.execute(); + + // Just check whether query compiles + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/ExecuteQuery.java b/tck/src/main/java/org/apache/jdo/tck/query/api/ExecuteQuery.java index 025c19b47..9da5a5557 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/ExecuteQuery.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/ExecuteQuery.java @@ -5,149 +5,169 @@ * 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 + * + * 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.jdo.tck.query.api; + import java.util.ArrayList; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Execute Query
    - * Keywords: query
    - * Assertion ID: A14.6.1-3.
    - * Assertion Description: The Query.execute methods execute the query using the - * parameters and return the result, which is a collection of instances that satisfy the boolean - * filter. Each parameter of the execute method(s) is an object which is either the - * value of the corresponding parameter or the wrapped value of a primitive parameter. + *Title: Execute Query + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.1-3. + *
    + *Assertion Description: The Query.execute methods execute + * the query using the parameters and return the result, which is a collection + * of instances that satisfy the boolean filter. Each parameter of the + * execute method(s) is an object which is either the value of the + * corresponding parameter or the wrapped value of a primitive parameter. */ + public class ExecuteQuery extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.1-3 (ExecuteQuery) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ExecuteQuery.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - - runTestExecuteQuery01(pm); - runTestExecuteQuery02(pm); - runTestExecuteQuery03(pm); - } - - /** */ - private void runTestExecuteQuery01(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.setFilter("x == 4"); - Object results = query.execute(); - - // check query result - List expected = new ArrayList(); - Object p5 = new PCPoint(4, 4); - expected.add(p5); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 4", results, expected); - tx.commit(); - tx = null; - if (debug) logger.debug("Test ExecuteQuery01 - Passed\n"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.1-3 (ExecuteQuery) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ExecuteQuery.class); } - } - - /** */ - private void runTestExecuteQuery02(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.declareParameters("Integer param"); - query.setFilter("x == param"); - Object results = query.execute(new java.lang.Integer(2)); - - // check query result - List expected = new ArrayList(); - Object p3 = new PCPoint(2, 2); - expected.add(p3); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == param", results, expected); - tx.commit(); - tx = null; - if (debug) logger.debug("Test ExecuteQuery02 - Passed\n"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + + runTestExecuteQuery01(pm); + runTestExecuteQuery02(pm); + runTestExecuteQuery03(pm); } - } - - /** */ - private void runTestExecuteQuery03(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.declareParameters("Integer param1, Integer param2"); - query.setFilter("x == param1 && y == param2"); - Object results = query.execute(Integer.valueOf(2), Integer.valueOf(2)); - - // check query result - List expected = new ArrayList(); - Object p3 = new PCPoint(2, 2); - expected.add(p3); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, "x == param1 && y == param2", results, expected); - tx.commit(); - tx = null; - if (debug) logger.debug("Test ExecuteQuery03 - Passed\n"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + private void runTestExecuteQuery01(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.setFilter("x == 4"); + Object results = query.execute(); + + // check query result + List expected = new ArrayList(); + Object p5 = new PCPoint(4, 4); + expected.add(p5); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 4", + results, expected); + tx.commit(); + tx = null; + if (debug) logger.debug ("Test ExecuteQuery01 - Passed\n"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void runTestExecuteQuery02(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.declareParameters("Integer param"); + query.setFilter("x == param"); + Object results = query.execute(new java.lang.Integer(2)); + + // check query result + List expected = new ArrayList(); + Object p3 = new PCPoint(2, 2); + expected.add(p3); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == param", + results, expected); + tx.commit(); + tx = null; + if (debug) logger.debug("Test ExecuteQuery02 - Passed\n"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void runTestExecuteQuery03(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.declareParameters("Integer param1, Integer param2"); + query.setFilter("x == param1 && y == param2"); + Object results = query.execute(Integer.valueOf(2), Integer.valueOf(2)); + + // check query result + List expected = new ArrayList(); + Object p3 = new PCPoint(2, 2); + expected.add(p3); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, + "x == param1 && y == param2", + results, expected); + tx.commit(); + tx = null; + if (debug) logger.debug("Test ExecuteQuery03 - Passed\n"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/ExecuteQueryWithArray.java b/tck/src/main/java/org/apache/jdo/tck/query/api/ExecuteQueryWithArray.java index 04dcbcc74..d328c29bd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/ExecuteQueryWithArray.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/ExecuteQueryWithArray.java @@ -5,128 +5,144 @@ * 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 + * + * 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.jdo.tck.query.api; + import java.util.ArrayList; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Execute Query with Array
    - * Keywords: query
    - * Assertion ID: A14.6.1-6.
    - * Assertion Description: The executeWithArray method is similar to the - * execute method, but takes its parameters from an array instance. The array contains - * Objects, in which the positional Object is the value to use in the query for - * that parameter. Unlike execute, there is no limit on the number of parameters. + *Title: Execute Query with Array + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.1-6. + *
    + *Assertion Description: The executeWithArray method is + *similar to the execute method, but takes its parameters from an + *array instance. The array contains Objects, in which the + *positional Object is the value to use in the query for that + *parameter. Unlike execute, there is no limit on the number of + *parameters. */ + public class ExecuteQueryWithArray extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.1-6 (ExecuteQueryWithArray) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ExecuteQueryWithArray.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - - runTestExecuteQueryWithArray01(pm); - runTestExecuteQueryWithArray02(pm); - } - - /** */ - private void runTestExecuteQueryWithArray01(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.declareParameters("Integer param"); - query.setFilter("x == param"); - - Object[] actualParams = {Integer.valueOf(2)}; - Object results = query.executeWithArray(actualParams); - - // check query result - List expected = new ArrayList(); - Object p3 = new PCPoint(2, 2); - expected.add(p3); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == param", results, expected); - - tx.commit(); - tx = null; - if (debug) logger.debug("Test ExecuteQueryWithArray01 - Passed\n"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.1-6 (ExecuteQueryWithArray) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ExecuteQueryWithArray.class); + } + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + + runTestExecuteQueryWithArray01(pm); + runTestExecuteQueryWithArray02(pm); + } + + /** */ + private void runTestExecuteQueryWithArray01(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.declareParameters("Integer param"); + query.setFilter("x == param"); + + Object[] actualParams = { Integer.valueOf(2) }; + Object results = query.executeWithArray(actualParams); + + // check query result + List expected = new ArrayList(); + Object p3 = new PCPoint(2, 2); + expected.add(p3); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == param", results, expected); + + tx.commit(); + tx = null; + if (debug) logger.debug ("Test ExecuteQueryWithArray01 - Passed\n"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - private void runTestExecuteQueryWithArray02(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.declareParameters("Integer param1, Integer param2"); - query.setFilter("x == param1 && y == param2"); - - Object[] actualParams = {Integer.valueOf(2), Integer.valueOf(2)}; - Object results = query.executeWithArray(actualParams); - - // check query result - List expected = new ArrayList(); - Object p3 = new PCPoint(2, 2); - expected.add(p3); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, "x == param1 && y == param2", results, expected); - tx.commit(); - tx = null; - if (debug) logger.debug("Test ExecuteQueryWithArray02 - Passed\n"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + private void runTestExecuteQueryWithArray02(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.declareParameters("Integer param1, Integer param2"); + query.setFilter("x == param1 && y == param2"); + + Object[] actualParams = { Integer.valueOf(2), Integer.valueOf(2) }; + Object results = query.executeWithArray(actualParams); + + // check query result + List expected = new ArrayList(); + Object p3 = new PCPoint(2, 2); + expected.add(p3); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, + "x == param1 && y == param2", + results, expected); + tx.commit(); + tx = null; + if (debug) logger.debug ("Test ExecuteQueryWithArray02 - Passed\n"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/ExecuteQueryWithMap.java b/tck/src/main/java/org/apache/jdo/tck/query/api/ExecuteQueryWithMap.java index fdbcd142b..df3b5bcbe 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/ExecuteQueryWithMap.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/ExecuteQueryWithMap.java @@ -5,131 +5,147 @@ * 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 + * + * 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.jdo.tck.query.api; + import java.util.ArrayList; import java.util.List; import java.util.Map; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Execute Query with Map
    - * Keywords: query
    - * Assertion ID: A14.6.1-5.
    - * Assertion Description: The Query.executeWithMap method is similar to the - * execute method, but takes its parameters from a Map instance. The - * Map contains key/value pairs, in which the key is the declared parameter name, and - * the value is the value to use in the query for that parameter. Unlike execute, there - * is no limit on the number of parameters. + *Title: Execute Query with Map + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.1-5. + *
    + *Assertion Description: The Query.executeWithMap method is + *similar to the execute method, but takes its parameters from a + *Map instance. The Map contains key/value pairs, + *in which the key is the declared parameter name, and the value is the value + *to use in the query for that parameter. Unlike execute, there is + *no limit on the number of parameters. */ + public class ExecuteQueryWithMap extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.1-5 (ExecuteQueryWithMap) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ExecuteQueryWithMap.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - - runTestExecuteQueryWithMap01(pm); - runTestExecuteQueryWithMap02(pm); - } - - /** */ - private void runTestExecuteQueryWithMap01(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.declareParameters("Integer param"); - query.setFilter("x == param"); - - Map actualParams = new java.util.HashMap(); - actualParams.put("param", Integer.valueOf(2)); - Object results = query.executeWithMap(actualParams); - - // check query result - List expected = new ArrayList(); - Object p3 = new PCPoint(2, 2); - expected.add(p3); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == param", results, expected); - tx.commit(); - tx = null; - if (debug) logger.debug("Test ExecuteQueryWithMap01 - Passed\n"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.1-5 (ExecuteQueryWithMap) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ExecuteQueryWithMap.class); + } + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + + runTestExecuteQueryWithMap01(pm); + runTestExecuteQueryWithMap02(pm); + } + + /** */ + private void runTestExecuteQueryWithMap01(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.declareParameters("Integer param"); + query.setFilter("x == param"); + + Map actualParams = new java.util.HashMap(); + actualParams.put("param", Integer.valueOf(2) ); + Object results = query.executeWithMap(actualParams); + + // check query result + List expected = new ArrayList(); + Object p3 = new PCPoint(2, 2); + expected.add(p3); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == param", + results, expected); + tx.commit(); + tx = null; + if (debug) logger.debug("Test ExecuteQueryWithMap01 - Passed\n"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - private void runTestExecuteQueryWithMap02(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.declareParameters("Integer param1, Integer param2"); - query.setFilter("x == param1 && y == param2"); - - Map actualParams = new java.util.HashMap(); - actualParams.put("param1", Integer.valueOf(2)); - actualParams.put("param2", Integer.valueOf(2)); - Object results = query.executeWithMap(actualParams); - - // check query result - List expected = new ArrayList(); - Object p3 = new PCPoint(2, 2); - expected.add(p3); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, "x == param1 && y == param2", results, expected); - tx.commit(); - tx = null; - if (debug) logger.debug("Test ExecuteQueryWithMap02 - Passed\n"); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + private void runTestExecuteQueryWithMap02(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.declareParameters("Integer param1, Integer param2"); + query.setFilter("x == param1 && y == param2"); + + Map actualParams = new java.util.HashMap(); + actualParams.put("param1", Integer.valueOf(2) ); + actualParams.put("param2", Integer.valueOf(2) ); + Object results = query.executeWithMap(actualParams); + + // check query result + List expected = new ArrayList(); + Object p3 = new PCPoint(2, 2); + expected.add(p3); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, + "x == param1 && y == param2", + results, expected); + tx.commit(); + tx = null; + if (debug) logger.debug("Test ExecuteQueryWithMap02 - Passed\n"); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/GetFetchPlan.java b/tck/src/main/java/org/apache/jdo/tck/query/api/GetFetchPlan.java index cc5a1b9f9..37e111ed3 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/GetFetchPlan.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/GetFetchPlan.java @@ -5,115 +5,121 @@ * 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 + * + * 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.jdo.tck.query.api; import java.util.Collection; + import javax.jdo.FetchPlan; import javax.jdo.Query; + import org.apache.jdo.tck.pc.mylib.PCClass; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get Fetch Plan.
    - * Keywords: query
    - * Assertion ID: A14.6-21.
    - * Assertion Description: This method retrieves the fetch plan associated with the Query. It - * always returns the identical instance for the same Query instance. Any change made to the fetch - * plan affects subsequent query execution. + *Title: Get Fetch Plan. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6-21. + *
    + *Assertion Description: + * This method retrieves the fetch plan associated with the Query. + * It always returns the identical instance for the same Query instance. + * Any change made to the fetch plan affects subsequent query execution. */ public class GetFetchPlan extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6-21 (FetchPan) failed: "; - - private String FETCH_GROUP_1 = "fetchGroup1"; - private String FETCH_GROUP_2 = "fetchGroup2"; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-21 (FetchPan) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetFetchPlan.class); - } + private String FETCH_GROUP_1 = "fetchGroup1"; + private String FETCH_GROUP_2 = "fetchGroup2"; - /** */ - private Query createQuery() { - Query query = getPM().newQuery(PCClass.class, "true"); - query.getFetchPlan().setGroup(FETCH_GROUP_1); - return query; - } - - /** */ - public void testFetchGroup1() { - // localSetUp closes the PM - Query query = createQuery(); - checkSameFetchPlanInstances(query); - checkFetchGroup1(query); - cleanupPM(); - } + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetFetchPlan.class); + } - public void testFetchGroup2() { - // localSetUp closes the PM - Query query = createQuery(); - checkFetchGroup2(query); - checkFetchGroup1(query); - } + /** */ + private Query createQuery() { + Query query = getPM().newQuery(PCClass.class, "true"); + query.getFetchPlan().setGroup(FETCH_GROUP_1); + return query; + } - private void checkSameFetchPlanInstances(Query query) { - FetchPlan fetchPlan1 = query.getFetchPlan(); - FetchPlan fetchPlan2 = query.getFetchPlan(); - if (fetchPlan1 != fetchPlan2) { - fail( - ASSERTION_FAILED - + "Calling getFetchPlan twice on the same " - + "query instance results in two different fetch plan instances."); + /** */ + public void testFetchGroup1() { + // localSetUp closes the PM + Query query = createQuery(); + checkSameFetchPlanInstances(query); + checkFetchGroup1(query); + cleanupPM(); } - } - /** - * Checks if the given query loads fields assigned to fetchGroup1 - * - * @param query the query - */ - private void checkFetchGroup1(Query query) { - FetchPlan fetchplan = query.getFetchPlan(); - Collection fetchgroups = fetchplan.getGroups(); - assertTrue( - "FetchPlan should include fetchGroup1 and not fetchGroup2", - fetchgroups.contains(FETCH_GROUP_1) && !fetchgroups.contains(FETCH_GROUP_2)); - } + public void testFetchGroup2() { + // localSetUp closes the PM + Query query = createQuery(); + checkFetchGroup2(query); + checkFetchGroup1(query); + } - /** - * Checks if the given query loads fields assigned to "fetchGroup1" plus fetch group - * "fetchGroup2". For this purpose, the method temporarily adds fetch group "fetchGroup2" to the - * fetch plan of the given query instance. That fetch group loads field number2. Finally, that - * fetch group is removed from the fetch plan again. - * - * @param query the query - */ - private void checkFetchGroup2(Query query) { - FetchPlan fetchplan = query.getFetchPlan(); - fetchplan.addGroup(FETCH_GROUP_2); - Collection fetchgroups = fetchplan.getGroups(); - try { - assertTrue( - "FetchPlan should include fetchGroup1 and fetchGroup2", - fetchgroups.contains(FETCH_GROUP_1) && fetchgroups.contains(FETCH_GROUP_2)); - } finally { - query.getFetchPlan().removeGroup(FETCH_GROUP_2); + private void checkSameFetchPlanInstances(Query query) { + FetchPlan fetchPlan1 = query.getFetchPlan(); + FetchPlan fetchPlan2 = query.getFetchPlan(); + if (fetchPlan1 != fetchPlan2) { + fail(ASSERTION_FAILED + "Calling getFetchPlan twice on the same " + + "query instance results in two different fetch plan instances."); + } + } + + /** + * Checks if the given query loads fields + * assigned to fetchGroup1 + * @param query the query + */ + private void checkFetchGroup1(Query query) { + FetchPlan fetchplan = query.getFetchPlan(); + Collection fetchgroups = fetchplan.getGroups(); + assertTrue("FetchPlan should include fetchGroup1 and not fetchGroup2", + fetchgroups.contains(FETCH_GROUP_1) && + !fetchgroups.contains(FETCH_GROUP_2)); + } + + /** + * Checks if the given query loads fields assigned + * to "fetchGroup1" plus fetch group "fetchGroup2". + * For this purpose, the method temporarily adds fetch group "fetchGroup2" + * to the fetch plan of the given query instance. + * That fetch group loads field number2. + * Finally, that fetch group is removed from the fetch plan again. + * @param query the query + */ + private void checkFetchGroup2(Query query) { + FetchPlan fetchplan = query.getFetchPlan(); + fetchplan.addGroup(FETCH_GROUP_2); + Collection fetchgroups = fetchplan.getGroups(); + try { + assertTrue("FetchPlan should include fetchGroup1 and fetchGroup2", + fetchgroups.contains(FETCH_GROUP_1) && + fetchgroups.contains(FETCH_GROUP_2)); + } finally { + query.getFetchPlan().removeGroup(FETCH_GROUP_2); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/GetIgnoreCache.java b/tck/src/main/java/org/apache/jdo/tck/query/api/GetIgnoreCache.java index a7e9d5f95..0cee24ba4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/GetIgnoreCache.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/GetIgnoreCache.java @@ -5,114 +5,137 @@ * 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 + * + * 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.jdo.tck.query.api; import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get IgnoreCache
    - * Keywords: query
    - * Assertion ID: A14.6-13.
    - * Assertion Description: Query.getIgnoreCache returns the current setting of - * the IgnoreCache option. + *Title: Get IgnoreCache + *
    + *Keywords: query + *
    + *Assertion ID: A14.6-13. + *
    + *Assertion Description: Query.getIgnoreCache returns the + *current setting of the IgnoreCache option. */ -public class GetIgnoreCache extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6-13 (GetIgnoreCache) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetIgnoreCache.class); - } - - /** */ - public void test() { - pmf = getPMF(); - pm = getPM(); - - runTestGetIgnoreCache01(pm); - runTestGetIgnoreCache02(pm); - pm.close(); - pm = null; - } - - /** */ - void runTestGetIgnoreCache01(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Query query = pm.newQuery(); - - // the ignoreCache flag of PM must default to the PMF setting - if (pm.getIgnoreCache() == pmf.getIgnoreCache()) { - if (debug) logger.debug("PM ignoreCache defaults to the PMF setting."); - } else { - fail(ASSERTION_FAILED, "PM ignoreCache does NOT default to the PMF setting."); - } - // the ignoreCache flag of Query must default to the setting in PM - if (query.getIgnoreCache() == pm.getIgnoreCache()) { - if (debug) logger.debug("Query ignoreCache defaults to the PM setting."); - } else { - fail(ASSERTION_FAILED, "Query ignoreCache does NOT default to the PM setting."); - } +public class GetIgnoreCache extends QueryTest { - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-13 (GetIgnoreCache) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetIgnoreCache.class); } - } - - /** */ - void runTestGetIgnoreCache02(PersistenceManager pm) { - boolean ignoreCacheDefault = pmf.getIgnoreCache(); - // set PM's ignoreCache to a different value - pm.setIgnoreCache(!ignoreCacheDefault); + /** */ + public void test() { + pmf = getPMF(); + pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Query query = pm.newQuery(); + runTestGetIgnoreCache01(pm); + runTestGetIgnoreCache02(pm); - // Query.ignoreCache must be equal to the new value in PM - if (query.getIgnoreCache() == !ignoreCacheDefault) { - if (debug) logger.debug("Query ignoreCache flag is equal to new PM setting."); - } else { - fail(ASSERTION_FAILED, "Query ignoreCache flag is NOT equal to new PM setting."); - } + pm.close(); + pm = null; + } + + /** */ + void runTestGetIgnoreCache01(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Query query = pm.newQuery(); + + // the ignoreCache flag of PM must default to the PMF setting + if (pm.getIgnoreCache() == pmf.getIgnoreCache()) { + if (debug) + logger.debug("PM ignoreCache defaults to the PMF setting."); + } + else { + fail(ASSERTION_FAILED, + "PM ignoreCache does NOT default to the PMF setting."); + } + // the ignoreCache flag of Query must default to the setting in PM + if (query.getIgnoreCache() == pm.getIgnoreCache()) { + if (debug) + logger.debug("Query ignoreCache defaults to the PM setting."); + } + else { + fail(ASSERTION_FAILED, + "Query ignoreCache does NOT default to the PM setting."); + } + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } - // change the Query's ignoreCache flag - query.setIgnoreCache(ignoreCacheDefault); - if (query.getIgnoreCache() == ignoreCacheDefault) { - if (debug) logger.debug("Query ignoreCache flag successfully changed"); - } else { - fail(ASSERTION_FAILED, "Could NOT change the Query's ignoreCache flag."); - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + void runTestGetIgnoreCache02(PersistenceManager pm) { + + boolean ignoreCacheDefault = pmf.getIgnoreCache(); + // set PM's ignoreCache to a different value + pm.setIgnoreCache(!ignoreCacheDefault); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Query query = pm.newQuery(); + + // Query.ignoreCache must be equal to the new value in PM + if (query.getIgnoreCache() == !ignoreCacheDefault) { + if (debug) + logger.debug("Query ignoreCache flag is equal to new PM setting."); + } + else { + fail(ASSERTION_FAILED, + "Query ignoreCache flag is NOT equal to new PM setting."); + } + + // change the Query's ignoreCache flag + query.setIgnoreCache(ignoreCacheDefault); + if (query.getIgnoreCache() == ignoreCacheDefault) { + if (debug) + logger.debug("Query ignoreCache flag successfully changed"); + } + else { + fail(ASSERTION_FAILED, + "Could NOT change the Query's ignoreCache flag."); + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/GetPersistenceManager.java b/tck/src/main/java/org/apache/jdo/tck/query/api/GetPersistenceManager.java index eb4e74e03..d90866e79 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/GetPersistenceManager.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/GetPersistenceManager.java @@ -5,113 +5,126 @@ * 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 + * + * 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.jdo.tck.query.api; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get PersistenceManager
    - * Keywords: query
    - * Assertion ID: A14.6-2.
    - * Assertion Description: Query.getPersistenceManager() returns the associated - * PersistenceManager instance. + *Title: Get PersistenceManager + *
    + *Keywords: query + *
    + *Assertion ID: A14.6-2. + *
    + *Assertion Description: Query.getPersistenceManager() + *returns the associated PersistenceManager instance. */ + public class GetPersistenceManager extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6-2 (GetPersistenceManager) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPersistenceManager.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTestGetPersistenceManager01(pm); - runTestGetPersistenceManager02(pm); - - pm.close(); - pm = null; - } - - /** */ - void runTestGetPersistenceManager01(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.setOptimistic(false); - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - - PersistenceManager pm1 = query.getPersistenceManager(); - if (pm.equals(pm1)) { - if (debug) logger.debug("Pessimistic: GetPersistenceManager Test: Passed."); - } else { - fail( - ASSERTION_FAILED, - "Pessimistic: query.getPersistenceManager() returned different pm than the one it was created from."); - } - - query.compile(); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-2 (GetPersistenceManager) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPersistenceManager.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTestGetPersistenceManager01(pm); + runTestGetPersistenceManager02(pm); + + pm.close(); + pm = null; + } + + /** */ + void runTestGetPersistenceManager01(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.setOptimistic(false); + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + + PersistenceManager pm1 = query.getPersistenceManager(); + if(pm.equals(pm1)) { + if (debug) + logger.debug("Pessimistic: GetPersistenceManager Test: Passed."); + } + else { + fail(ASSERTION_FAILED, + "Pessimistic: query.getPersistenceManager() returned different pm than the one it was created from."); + } + + query.compile(); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - void runTestGetPersistenceManager02(PersistenceManager pm) { - if (!isOptimisticSupported()) return; - - Transaction tx = pm.currentTransaction(); - try { - tx.setOptimistic(true); - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - - PersistenceManager pm1 = query.getPersistenceManager(); - if (pm.equals(pm1)) { - if (debug) logger.debug("Optimistic: GetPersistenceManager Test: Passed"); - } else { - fail( - ASSERTION_FAILED, - "Optimistic: query.getPersistenceManager() returned different pm than the one it was created from."); - } - - query.compile(); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + void runTestGetPersistenceManager02(PersistenceManager pm) { + if (!isOptimisticSupported()) + return; + + Transaction tx = pm.currentTransaction(); + try { + tx.setOptimistic(true); + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + + PersistenceManager pm1 = query.getPersistenceManager(); + if(pm.equals(pm1)) { + if (debug) + logger.debug("Optimistic: GetPersistenceManager Test: Passed"); + } + else { + fail(ASSERTION_FAILED, + "Optimistic: query.getPersistenceManager() returned different pm than the one it was created from."); + } + + query.compile(); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/GetPersistenceManagerFromRestoredSerializedQuery.java b/tck/src/main/java/org/apache/jdo/tck/query/api/GetPersistenceManagerFromRestoredSerializedQuery.java index ae22280a9..67558d98a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/GetPersistenceManagerFromRestoredSerializedQuery.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/GetPersistenceManagerFromRestoredSerializedQuery.java @@ -5,121 +5,130 @@ * 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 + * + * 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.jdo.tck.query.api; + import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; + import javax.jdo.PersistenceManager; import javax.jdo.Query; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Get PersistenceManager From Restored Serialized Query
    - * Keywords: query
    - * Assertion ID: A14.6-3.
    - * Assertion Description: If a Query instance has been restored from a - * serialized form, Query.getPersistenceManager() returns null. + *Title: Get PersistenceManager From Restored Serialized Query + *
    + *Keywords: query + *
    + *Assertion ID: A14.6-3. + *
    + *Assertion Description: If a Query instance has been restored from a serialized form, Query.getPersistenceManager() returns null. */ -public class GetPersistenceManagerFromRestoredSerializedQuery extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6-3 (GetPersistenceManagerFromRestoredSerializedQuery) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPersistenceManagerFromRestoredSerializedQuery.class); - } - - /** - * @throws Exception exception - */ - public void test() throws Exception { - pm = getPM(); - - // initDatabase(pm, PCPoint.class); - runTestGetPersistenceManagerFromRestoredSerializedQuery(pm); - - pm.close(); - pm = null; - } - - /** */ - void serializeQuery(PersistenceManager pm) throws Exception { - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.setFilter("x == 3"); - query.compile(); - - ObjectOutputStream oos = null; - try { - if (debug) logger.debug("Attempting to serialize Query object."); - oos = new ObjectOutputStream(new FileOutputStream(SERIALZED_QUERY)); - oos.writeObject(query); - if (debug) logger.debug("Query object serialized."); - } finally { - if (oos != null) { + +public class GetPersistenceManagerFromRestoredSerializedQuery + extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-3 (GetPersistenceManagerFromRestoredSerializedQuery) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPersistenceManagerFromRestoredSerializedQuery.class); + } + + + /** + * + * @throws Exception exception + */ + public void test() throws Exception { + pm = getPM(); + + // initDatabase(pm, PCPoint.class); + runTestGetPersistenceManagerFromRestoredSerializedQuery(pm); + + pm.close(); + pm = null; + } + + /** */ + void serializeQuery(PersistenceManager pm) throws Exception { + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.setFilter("x == 3"); + query.compile(); + + ObjectOutputStream oos = null; try { - oos.close(); - } catch (Exception ex) { + if (debug) logger.debug("Attempting to serialize Query object."); + oos = new ObjectOutputStream(new FileOutputStream(SERIALZED_QUERY)); + oos.writeObject(query); + if (debug) logger.debug("Query object serialized."); + } + finally { + if (oos != null) { + try { oos.close();} catch(Exception ex) {} + } } - } } - } - - /** */ - void runTestGetPersistenceManagerFromRestoredSerializedQuery(PersistenceManager pm) - throws Exception { - if (debug) - logger.debug("\nExecuting test GetPersistenceManagerFromRestoredSerializedQuery() ..."); - - Query restoredQuery = null; - ObjectInputStream ois = null; - PersistenceManager pm1 = null; - - serializeQuery(pm); - - try { - if (debug) logger.debug("Attempting to de-serialize Query object."); - ois = new ObjectInputStream(new FileInputStream(SERIALZED_QUERY)); - restoredQuery = (Query) ois.readObject(); - if (restoredQuery == null) { - fail(ASSERTION_FAILED, "Deserialzed query is null"); - } - if (debug) logger.debug("Query object restored."); - } finally { - if (ois != null) { + + /** */ + void runTestGetPersistenceManagerFromRestoredSerializedQuery( + PersistenceManager pm) throws Exception { + if (debug) + logger.debug("\nExecuting test GetPersistenceManagerFromRestoredSerializedQuery() ..."); + + Query restoredQuery = null; + ObjectInputStream ois = null; + PersistenceManager pm1 = null; + + serializeQuery(pm); + try { - ois.close(); - } catch (Exception ex) { + if (debug) logger.debug("Attempting to de-serialize Query object."); + ois = new ObjectInputStream(new FileInputStream(SERIALZED_QUERY)); + restoredQuery = (Query)ois.readObject(); + if (restoredQuery == null) { + fail(ASSERTION_FAILED, + "Deserialzed query is null"); + } + if (debug) logger.debug("Query object restored."); + } + finally { + if (ois != null) { + try { ois.close(); } catch(Exception ex) {} + } } - } - } - pm1 = restoredQuery.getPersistenceManager(); - if (pm1 == null) { - if (debug) logger.debug("Test GetPersistenceManagerFromRestoredSerializedQuery(): Passed"); - } else { - fail(ASSERTION_FAILED, "Deserialzed query instance should not have a pm associated"); + pm1 = restoredQuery.getPersistenceManager(); + if (pm1 == null) { + if (debug) + logger.debug("Test GetPersistenceManagerFromRestoredSerializedQuery(): Passed"); + } + else { + fail(ASSERTION_FAILED, + "Deserialzed query instance should not have a pm associated"); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/InvalidNamedQuery.java b/tck/src/main/java/org/apache/jdo/tck/query/api/InvalidNamedQuery.java index 3ef8e5185..16e1930cd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/InvalidNamedQuery.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/InvalidNamedQuery.java @@ -5,53 +5,57 @@ * 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 + * + * 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.jdo.tck.query.api; import javax.jdo.JDOUserException; + import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Invalid Named Query.
    - * Keywords: query
    - * Assertion ID: A14.5-16.
    - * Assertion Description: Named queries must be compilable. Attempts to get a named query + *Title: Invalid Named Query. + *
    + *Keywords: query + *
    + *Assertion ID: A14.5-16. + *
    + *Assertion Description: + * Named queries must be compilable. Attempts to get a named query * that cannot be compiled result in JDOUserException. */ public class InvalidNamedQuery extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.5-16 (InvalidNamedQuery) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(InvalidNamedQuery.class); - } - - /** */ - public void testNegative() { - try { - getPM().newNamedQuery(Person.class, "invalidQuery"); - fail( - ASSERTION_FAILED - + "Lookup of named query 'invalidQuery' " - + " succeeded, though the query is not compilable."); - } catch (JDOUserException e) { + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.5-16 (InvalidNamedQuery) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(InvalidNamedQuery.class); + } + + /** */ + public void testNegative() { + try { + getPM().newNamedQuery(Person.class, "invalidQuery"); + fail(ASSERTION_FAILED + "Lookup of named query 'invalidQuery' " + + " succeeded, though the query is not compilable."); + } catch (JDOUserException e) { + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/MetadataSearchOrder.java b/tck/src/main/java/org/apache/jdo/tck/query/api/MetadataSearchOrder.java index a3afa9ffe..92bd646c9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/MetadataSearchOrder.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/MetadataSearchOrder.java @@ -5,19 +5,21 @@ * 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 + * + * 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.jdo.tck.query.api; import javax.jdo.Query; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.pc.mylib.MylibReader; @@ -26,82 +28,100 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Metadata Search Order.
    - * Keywords: query
    - * Assertion ID: A14.5-13.
    - * Assertion Description: If the named query is not found in already-loaded metadata, the - * query is searched for using an algorithm. Files containing metadata are examined in turn until - * the query is found. The order is based on the metadata search order for class metadata, but - * includes files named based on the query name. + *Title: Metadata Search Order. + *
    + *Keywords: query + *
    + *Assertion ID: A14.5-13. + *
    + *Assertion Description: + * If the named query is not found in already-loaded metadata, + * the query is searched for using an algorithm. + * Files containing metadata are examined in turn until the query is found. + * The order is based on the metadata search order for class metadata, + * but includes files named based on the query name. */ public class MetadataSearchOrder extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.5-13 (MetadataSearchOrder) failed: "; - - /** The expected results of valid queries. */ - private Object[] expectedResult = { - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}), - getTransientCompanyModelInstancesAsList(new String[] {"emp2", "emp3", "emp4", "emp5"}), - getTransientMylibInstancesAsList(new String[] {"pcClass1", "pcClass2"}), - getTransientCompanyModelInstancesAsList(new String[] {"emp3", "emp4", "emp5"}), - getTransientCompanyModelInstancesAsList(new String[] {"emp4", "emp5"}) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MetadataSearchOrder.class); - } - - /** */ - public void testPackageJDOInDefaultPackage() { - int index = 0; - executeNamedQuery(null, "packageJDOInDefaultPackage", expectedResult[index]); - } - - /** */ - public void testPackageJDO() { - int index = 1; - executeNamedQuery(Person.class, "packageJDO", expectedResult[index]); - } - - /** */ - public void testClassJDO() { - int index = 2; - executeNamedQuery(PCClass.class, "classJDO", expectedResult[index]); - } - - /** */ - public void testPackageORM() { - int index = 3; - executeNamedQuery(Person.class, "packageORM", expectedResult[index]); - } - - /** */ - public void testClassJDOQuery() { - int index = 4; - executeNamedQuery(Person.class, "classJDOQuery", expectedResult[index]); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.5-13 (MetadataSearchOrder) failed: "; + + /** + * The expected results of valid queries. + */ + private Object[] expectedResult = { + getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}), + getTransientCompanyModelInstancesAsList(new String[]{ + "emp2", "emp3", "emp4", "emp5"}), + getTransientMylibInstancesAsList(new String[]{ + "pcClass1", "pcClass2"}), + getTransientCompanyModelInstancesAsList(new String[]{ + "emp3", "emp4", "emp5"}), + getTransientCompanyModelInstancesAsList(new String[]{ + "emp4", "emp5"}) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MetadataSearchOrder.class); + } + + /** */ + public void testPackageJDOInDefaultPackage() { + int index = 0; + executeNamedQuery(null, "packageJDOInDefaultPackage", + expectedResult[index]); + } + + /** */ + public void testPackageJDO() { + int index = 1; + executeNamedQuery(Person.class, "packageJDO", + expectedResult[index]); + } + + /** */ + public void testClassJDO() { + int index = 2; + executeNamedQuery(PCClass.class, "classJDO", + expectedResult[index]); + } + + /** */ + public void testPackageORM() { + int index = 3; + executeNamedQuery(Person.class, "packageORM", + expectedResult[index]); + } + + /** */ + public void testClassJDOQuery() { + int index = 4; + executeNamedQuery(Person.class, "classJDOQuery", + expectedResult[index]); + } - private void executeNamedQuery(Class candidateClass, String namedQuery, Object expectedResult) { - Query query = getPM().newNamedQuery(candidateClass, namedQuery); - executeJDOQuery( - ASSERTION_FAILED, query, "Named query " + namedQuery, false, null, expectedResult, true); - } + private void executeNamedQuery(Class candidateClass, String namedQuery, + Object expectedResult) { + Query query = getPM().newNamedQuery(candidateClass, namedQuery); + executeJDOQuery(ASSERTION_FAILED, query, "Named query " + namedQuery, + false, null, expectedResult, true); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - addTearDownClass(MylibReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - loadAndPersistMylib(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + addTearDownClass(MylibReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + loadAndPersistMylib(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/NamedQueryNotFound.java b/tck/src/main/java/org/apache/jdo/tck/query/api/NamedQueryNotFound.java index 2109445ab..40c3ad20b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/NamedQueryNotFound.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/NamedQueryNotFound.java @@ -5,53 +5,57 @@ * 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 + * + * 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.jdo.tck.query.api; import javax.jdo.JDOUserException; + import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Named Query not Found.
    - * Keywords: query
    - * Assertion ID: A14.5-14.
    - * Assertion Description: If the metadata is not found in the above, a JDOUserException is - * thrown. + *Title: Named Query not Found. + *
    + *Keywords: query + *
    + *Assertion ID: A14.5-14. + *
    + *Assertion Description: + * If the metadata is not found in the above, a JDOUserException is thrown. */ public class NamedQueryNotFound extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.5-14 (NamedQueryNotFound) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NamedQueryNotFound.class); - } - - /** */ - public void testNegative() { - try { - getPM().newNamedQuery(Person.class, "nonExistingNamedQuery"); - fail( - ASSERTION_FAILED - + "The lookup of named query 'nonExistingNamedQuery' " - + "is successful, though that named query is undefined."); - } catch (JDOUserException e) { + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.5-14 (NamedQueryNotFound) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NamedQueryNotFound.class); + } + + /** */ + public void testNegative() { + try { + getPM().newNamedQuery(Person.class, "nonExistingNamedQuery"); + fail(ASSERTION_FAILED + + "The lookup of named query 'nonExistingNamedQuery' " + + "is successful, though that named query is undefined."); + } catch (JDOUserException e) { + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/NamedQueryRepeatableAnnotations.java b/tck/src/main/java/org/apache/jdo/tck/query/api/NamedQueryRepeatableAnnotations.java index fef58c0de..59c07cd21 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/NamedQueryRepeatableAnnotations.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/NamedQueryRepeatableAnnotations.java @@ -5,55 +5,60 @@ * 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 + * + * 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.jdo.tck.query.api; -import javax.jdo.JDOUserException; import javax.jdo.Query; +import javax.jdo.JDOUserException; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.query.NamedQueriesSample; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: NamedQueryRepeatableAnnotations
    - * Keywords: query
    - * Assertion ID: Unknown
    - * Assertion Description: We test use of @Query where multiple have been defined in a class, - * so reliant on Java 8 @Repeatable. + *Title: NamedQueryRepeatableAnnotations + *
    + *Keywords: query + *
    + *Assertion ID: Unknown + *
    + *Assertion Description: + * We test use of @Query where multiple have been defined in a class, so reliant on Java 8 @Repeatable. */ public class NamedQueryRepeatableAnnotations extends QueryTest { - private static final String ASSERTION_FAILED = - "Assertion A19.?? (NamedQueryRepeatableAnnotations) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NamedQueryRepeatableAnnotations.class); - } - - /** */ - public void testPositive() { - try { - Query query = getPM().newNamedQuery(NamedQueriesSample.class, "NameIsJohn"); - } catch (JDOUserException e) { - fail(ASSERTION_FAILED + "Lookup of query failed but should have been found"); + private static final String ASSERTION_FAILED = + "Assertion A19.?? (NamedQueryRepeatableAnnotations) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NamedQueryRepeatableAnnotations.class); } - try { - Query query = getPM().newNamedQuery(NamedQueriesSample.class, "NameIsFred"); - } catch (JDOUserException e) { - fail(ASSERTION_FAILED + "Lookup of query failed but should have been found"); + + /** */ + public void testPositive() { + try { + Query query = getPM().newNamedQuery(NamedQueriesSample.class, "NameIsJohn"); + } catch (JDOUserException e) { + fail(ASSERTION_FAILED + "Lookup of query failed but should have been found"); + } + try { + Query query = getPM().newNamedQuery(NamedQueriesSample.class, "NameIsFred"); + } catch (JDOUserException e) { + fail(ASSERTION_FAILED + "Lookup of query failed but should have been found"); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/NewNamedQuery.java b/tck/src/main/java/org/apache/jdo/tck/query/api/NewNamedQuery.java index 70ed49f58..1d5a9dd88 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/NewNamedQuery.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/NewNamedQuery.java @@ -5,20 +5,23 @@ * 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 + * + * 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.jdo.tck.query.api; import java.util.Arrays; + import javax.jdo.Query; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.query.QueryTest; @@ -26,72 +29,73 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: New Named Query.
    - * Keywords: query
    - * Assertion ID: A14.5-12.
    - * Assertion Description: Construct a new query instance with the given candidate class from - * a named query. + *Title: New Named Query. + *
    + *Keywords: query + *
    + *Assertion ID: A14.5-12. + *
    + *Assertion Description: + * Construct a new query instance + * with the given candidate class from a named query. */ public class NewNamedQuery extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.5-12 (NewNamedQuery) failed: "; - - /** The expected results of valid queries. */ - private Object[] expectedResult = { - Arrays.asList( - new Object[] { - new FullName("emp1First", "emp1Last"), - new FullName("emp2First", "emp2Last"), - new FullName("emp3First", "emp3Last"), - new FullName("emp4First", "emp4Last"), - new FullName("emp5First", "emp5Last") - }), - new FullName("emp1First", "emp1Last") - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NewNamedQuery.class); - } - - /** */ - public void testPositive() { - int index = 0; - executeNamedQuery(Person.class, "validNotUnique", expectedResult[index], true); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.5-12 (NewNamedQuery) failed: "; + + /** + * The expected results of valid queries. + */ + private Object[] expectedResult = { + Arrays.asList(new Object[] { + new FullName("emp1First", "emp1Last"), + new FullName("emp2First", "emp2Last"), + new FullName("emp3First", "emp3Last"), + new FullName("emp4First", "emp4Last"), + new FullName("emp5First", "emp5Last")}), + new FullName("emp1First", "emp1Last") + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NewNamedQuery.class); + } + + /** */ + public void testPositive() { + int index = 0; + executeNamedQuery(Person.class, "validNotUnique", + expectedResult[index], true); - index = 1; - executeNamedQuery(Person.class, "validUnique", expectedResult[index], true); - } + index = 1; + executeNamedQuery(Person.class, "validUnique", + expectedResult[index], true); + } - /** */ - public void testNegative() { - executeNamedQuery(Person.class, "invalidUnique", null, false); - } + /** */ + public void testNegative() { + executeNamedQuery(Person.class, "invalidUnique", null, false); + } - private void executeNamedQuery( - Class candidateClass, String namedQuery, Object expectedResult, boolean positive) { - Query query = getPM().newNamedQuery(candidateClass, namedQuery); - executeJDOQuery( - ASSERTION_FAILED, - query, - "Named query " + namedQuery, - false, - null, - expectedResult, - positive); - } + private void executeNamedQuery(Class candidateClass, String namedQuery, + Object expectedResult, boolean positive) { + Query query = getPM().newNamedQuery(candidateClass, namedQuery); + executeJDOQuery(ASSERTION_FAILED, query, "Named query " + namedQuery, + false, null, expectedResult, positive); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryFromExistingQueryBoundToPMFromSameVendor.java b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryFromExistingQueryBoundToPMFromSameVendor.java index 085517148..6d84ff4ab 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryFromExistingQueryBoundToPMFromSameVendor.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryFromExistingQueryBoundToPMFromSameVendor.java @@ -5,149 +5,161 @@ * 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 + * + * 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.jdo.tck.query.api; import java.util.ArrayList; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: New Query From Existing Query Bound to PersistenceManag er From Same Vendor
    - * Keywords: query
    - * Assertion ID: A14.5-3.
    - * Assertion Description: PersistenceManager.newQuery(Object query) constructs - * a Query instance from another query, where the parameter is currently bound to a - * PersistenceManager from the same JDO vendor. Any of the elements Class, Filter, - * Import declarations, Variable declarations, Parameter declarations, and Ordering from the - * parameter Query are copied to the new Query instance, but a candidate - * Collection or Extent element is discarded. + *Title: New Query From Existing Query Bound to PersistenceManag +er From Same Vendor + *
    + *Keywords: query + *
    + *Assertion ID: A14.5-3. + *
    + *Assertion Description: PersistenceManager.newQuery(Object query) constructs a Query instance from another query, where the parameter is currently bound to a PersistenceManager from the same JDO vendor. Any of the elements Class, Filter, Import declarations, Variable declarations, Parameter declarations, and Ordering from the parameter Query are copied to the new Query instance, but a candidate Collection or Extent element is discarded. + */ + public class NewQueryFromExistingQueryBoundToPMFromSameVendor extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.5-3 (NewQueryFromExistingQueryBoundToPMFromSameVendor) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NewQueryFromExistingQueryBoundToPMFromSameVendor.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - - runTestNewQueryFromExistingQueryBoundToPMFromSameVendor01(pm); - runTestNewQueryFromExistingQueryBoundToPMFromSameVendor02(pm); - } - - /** */ - void runTestNewQueryFromExistingQueryBoundToPMFromSameVendor01(PersistenceManager pm) { - if (debug) - logger.debug("\nExecuting test NewQueryFromExistingQueryBoundToPMFromSameVendor01()..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - - Query query1 = pm.newQuery(query); - query1.compile(); - - Object results = query1.execute(); - List expected = new ArrayList(); - Object p1 = new PCPoint(0, 0); - Object p2 = new PCPoint(1, 1); - Object p3 = new PCPoint(2, 2); - Object p4 = new PCPoint(3, 3); - Object p5 = new PCPoint(4, 4); - expected.add(p1); - expected.add(p2); - expected.add(p3); - expected.add(p4); - expected.add(p5); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected); - if (debug) - logger.debug("Test NewQueryFromExistingQueryBoundToPMFromSameVendor01() - Passed\n"); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.5-3 (NewQueryFromExistingQueryBoundToPMFromSameVendor) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NewQueryFromExistingQueryBoundToPMFromSameVendor.class); + } + + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + + runTestNewQueryFromExistingQueryBoundToPMFromSameVendor01(pm); + runTestNewQueryFromExistingQueryBoundToPMFromSameVendor02(pm); + } + + /** */ + void runTestNewQueryFromExistingQueryBoundToPMFromSameVendor01( + PersistenceManager pm) { + if (debug) + logger.debug("\nExecuting test NewQueryFromExistingQueryBoundToPMFromSameVendor01()..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + + Query query1 = pm.newQuery(query); + query1.compile(); + + Object results = query1.execute(); + List expected = new ArrayList(); + Object p1 = new PCPoint(0, 0); + Object p2 = new PCPoint(1, 1); + Object p3 = new PCPoint(2, 2); + Object p4 = new PCPoint(3, 3); + Object p5 = new PCPoint(4, 4); + expected.add(p1); + expected.add(p2); + expected.add(p3); + expected.add(p4); + expected.add(p5); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected); + if (debug) + logger.debug("Test NewQueryFromExistingQueryBoundToPMFromSameVendor01() - Passed\n"); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - void runTestNewQueryFromExistingQueryBoundToPMFromSameVendor02(PersistenceManager pm) { - if (debug) - logger.debug("\nExecuting test NewQueryFromExistingQueryBoundToPMFromSameVendor02()..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - - Query query1 = pm.newQuery(query); - query1.setCandidates(pm.getExtent(PCPoint.class, true)); - query1.compile(); - - Object results = query1.execute(); - - // check query result - List expected = new ArrayList(); - Object p1 = new PCPoint(0, 0); - Object p2 = new PCPoint(1, 1); - Object p3 = new PCPoint(2, 2); - Object p4 = new PCPoint(3, 3); - Object p5 = new PCPoint(4, 4); - expected.add(p1); - expected.add(p2); - expected.add(p3); - expected.add(p4); - expected.add(p5); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected); - if (debug) - logger.debug("Test NewQueryFromExistingQueryBoundToPMFromSameVendor02() - Passed\n"); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + void runTestNewQueryFromExistingQueryBoundToPMFromSameVendor02( + PersistenceManager pm) { + if (debug) + logger.debug("\nExecuting test NewQueryFromExistingQueryBoundToPMFromSameVendor02()..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + + Query query1 = pm.newQuery(query); + query1.setCandidates(pm.getExtent(PCPoint.class, true)); + query1.compile(); + + Object results = query1.execute(); + + // check query result + List expected = new ArrayList(); + Object p1 = new PCPoint(0, 0); + Object p2 = new PCPoint(1, 1); + Object p3 = new PCPoint(2, 2); + Object p4 = new PCPoint(3, 3); + Object p5 = new PCPoint(4, 4); + expected.add(p1); + expected.add(p2); + expected.add(p3); + expected.add(p4); + expected.add(p5); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected); + if (debug) + logger.debug("Test NewQueryFromExistingQueryBoundToPMFromSameVendor02() - Passed\n"); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryFromRestoredSerializedQuery.java b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryFromRestoredSerializedQuery.java index f332e456f..a95ea7366 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryFromRestoredSerializedQuery.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryFromRestoredSerializedQuery.java @@ -5,124 +5,130 @@ * 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 + * + * 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.jdo.tck.query.api; + import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.ArrayList; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: New Query From Existing Serialized Query
    - * Keywords: query
    - * Assertion ID: A14.5-2.
    - * Assertion Description: PersistenceManager.newQuery(Object query) constructs - * a Query instance from another query, where the parameter is a serialized/re-stored - * Query instance from the same JDO vendor but a different execution environment. Any - * of the elements Class, Filter, Import declarations, Variable declarations, Parameter - * declarations, and Ordering from the parameter Query are copied to the new - * Query instance, but a candidate Collection or Extent element is - * discarded. + *Title: New Query From Existing Serialized Query + *
    + *Keywords: query + *
    + *Assertion ID: A14.5-2. + *
    + *Assertion Description: PersistenceManager.newQuery(Object query) constructs a Query instance from another query, where the parameter is a serialized/re-stored Query instance from the same JDO vendor but a different execution environment. Any of the elements Class, Filter, Import declarations, Variable declarations, Parameter declarations, and Ordering from the parameter Query are copied to the new Query instance, but a candidate Collection or Extent element is discarded. */ + public class NewQueryFromRestoredSerializedQuery extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.5-2 (NewQueryFromRestoredSerializedQuery) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NewQueryFromRestoredSerializedQuery.class); - } - - /** - * @throws Exception exception - */ - public void testPositive() throws Exception { - PersistenceManager pm = getPM(); - if (debug) logger.debug("\nExecuting test NewQueryFromRestoredSerializedQuery01() ..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.setFilter("x == 3"); - query.compile(); - - ObjectOutputStream oos = null; - try { - if (debug) logger.debug("Attempting to serialize Query object."); - oos = new ObjectOutputStream(new FileOutputStream(SERIALZED_QUERY)); - oos.writeObject(query); - if (debug) logger.debug("Query object serialized."); - } finally { - if (oos != null) { - try { - oos.flush(); - } catch (Exception ex) { - } - try { - oos.close(); - } catch (Exception ex) { - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.5-2 (NewQueryFromRestoredSerializedQuery) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NewQueryFromRestoredSerializedQuery.class); + } + + /** + * + * @throws Exception exception + */ + public void testPositive() throws Exception { + PersistenceManager pm = getPM(); + if (debug) + logger.debug("\nExecuting test NewQueryFromRestoredSerializedQuery01() ..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.setFilter("x == 3"); + query.compile(); + + ObjectOutputStream oos = null; + try { + if (debug) + logger.debug("Attempting to serialize Query object."); + oos = new ObjectOutputStream( new FileOutputStream(SERIALZED_QUERY)); + oos.writeObject(query); + if (debug) logger.debug("Query object serialized."); + } + finally { + if (oos != null) { + try { oos.flush();} catch(Exception ex) {} + try { oos.close();} catch(Exception ex) {} + } + } + + ObjectInputStream in = + new ObjectInputStream(new FileInputStream(SERIALZED_QUERY)); + Query query1 = (Query)in.readObject(); + + // init and execute query + query = pm.newQuery(query1); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + Object results = query.execute(); + + // check query result + List expected = new ArrayList(); + Object p4 = new PCPoint(3, 3); + expected.add(p4); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 3", + results, expected); + if (debug) + logger.debug("Test NewQueryFromRestoredSerializedQuery01(): Passed"); + + tx.commit(); + tx = null; } - } - - ObjectInputStream in = new ObjectInputStream(new FileInputStream(SERIALZED_QUERY)); - Query query1 = (Query) in.readObject(); - - // init and execute query - query = pm.newQuery(query1); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - Object results = query.execute(); - - // check query result - List expected = new ArrayList(); - Object p4 = new PCPoint(3, 3); - expected.add(p4); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 3", results, expected); - if (debug) logger.debug("Test NewQueryFromRestoredSerializedQuery01(): Passed"); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQuerySingleString.java b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQuerySingleString.java index 9fba7e67c..d23de8cf3 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQuerySingleString.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQuerySingleString.java @@ -5,18 +5,19 @@ * 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 + * + * 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.jdo.tck.query.api; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.query.QueryElementHolder; @@ -24,65 +25,74 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Single String Query.
    - * Keywords: query
    - * Assertion ID: A14.5-11.
    - * Assertion Description: Construct a new query instance using the specified String as the - * single-string representation of the query. + *Title: Single String Query. + *
    + *Keywords: query + *
    + *Assertion ID: A14.5-11. + *
    + *Assertion Description: + * Construct a new query instance using the specified String + * as the single-string representation of the query. */ public class NewQuerySingleString extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.5-11 (NewQuerySingleString) failed: "; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.5-11 (NewQuerySingleString) failed: "; + + /** + * The array of valid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] VALID_QUERIES = { + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; - /** - * The array of valid queries which may be executed as single string queries and as API queries. - */ - private static final QueryElementHolder[] VALID_QUERIES = { - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null) - }; - - /** The expected results of valid queries. */ - private Object[] expectedResult = { - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NewQuerySingleString.class); - } - - /** */ - public void testPositive() { - for (int i = 0; i < VALID_QUERIES.length; i++) { - executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], expectedResult[i]); + /** + * The expected results of valid queries. + */ + private Object[] expectedResult = { + getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NewQuerySingleString.class); + } + + /** */ + public void testPositive() { + for (int i = 0; i < VALID_QUERIES.length; i++) { + executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], + expectedResult[i]); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithCandidateClass.java b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithCandidateClass.java index ca79decc4..0d0eec4cc 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithCandidateClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithCandidateClass.java @@ -5,75 +5,84 @@ * 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 + * + * 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.jdo.tck.query.api; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: New Query with Candidate Class
    - * Keywords: query
    - * Assertion ID: A14.5-5.
    - * Assertion Description: PersistenceManager.newQuery(Class cls) constructs a - * query instance with the candidate class specified. + *Title: New Query with Candidate Class + *
    + *Keywords: query + *
    + *Assertion ID: A14.5-5. + *
    + *Assertion Description: PersistenceManager.newQuery(Class cls) constructs a query instance with the candidate class specified. */ -public class NewQueryWithCandidateClass extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.5-5 (NewQueryWithCandidateClass) failed: "; +public class NewQueryWithCandidateClass extends QueryTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NewQueryWithCandidateClass.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.5-5 (NewQueryWithCandidateClass) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NewQueryWithCandidateClass.class); + } - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); - Query query = pm.newQuery(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - Object results = query.execute(); + Query query = pm.newQuery(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + Object results = query.execute(); - // check query result - printOutput(results, inserted); - checkQueryResultWithoutOrder(ASSERTION_FAILED, results, inserted); + // check query result + printOutput(results, inserted); + checkQueryResultWithoutOrder(ASSERTION_FAILED, results, inserted); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithCandidateClassAndCollection.java b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithCandidateClassAndCollection.java index 0bc1b88d1..806362df4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithCandidateClassAndCollection.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithCandidateClassAndCollection.java @@ -5,75 +5,83 @@ * 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 + * + * 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.jdo.tck.query.api; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: New Query with Candidate Class and Collection
    - * Keywords: query extent
    - * Assertion ID: A14.5-7.
    - * Assertion Description: PersistenceManager.newQuery(Class cls, Collection cln) - * constructs a query instance with the candidate class and candidate Collection - * specified. + *Title: New Query with Candidate Class and Collection + *
    + *Keywords: query extent + *
    + *Assertion ID: A14.5-7. + *
    + *Assertion Description: PersistenceManager.newQuery(Class cls, Collection cln) constructs a query instance with the candidate class and candidate Collection specified. */ -public class NewQueryWithCandidateClassAndCollection extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.5-7 (NewQueryWithCandidateClassAndCollection) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NewQueryWithCandidateClassAndCollection.class); - } +public class NewQueryWithCandidateClassAndCollection extends QueryTest { - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.5-7 (NewQueryWithCandidateClassAndCollection) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NewQueryWithCandidateClassAndCollection.class); + } - Query query = pm.newQuery(PCPoint.class, inserted); - Object results = query.execute(); + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); - // check query result - printOutput(results, inserted); - checkQueryResultWithoutOrder(ASSERTION_FAILED, results, inserted); + Query query = pm.newQuery(PCPoint.class, inserted); + Object results = query.execute(); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + // check query result + printOutput(results, inserted); + checkQueryResultWithoutOrder(ASSERTION_FAILED, results, inserted); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithCandidateClassAndExtent.java b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithCandidateClassAndExtent.java index 32f5d976f..898d209e6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithCandidateClassAndExtent.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithCandidateClassAndExtent.java @@ -5,79 +5,91 @@ * 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 + * + * 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.jdo.tck.query.api; import javax.jdo.Extent; import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: New Query with Candidate Class and Extent
    - * Keywords: query extent
    - * Assertion ID: A14.5-6.
    - * Assertion Description: PersistenceManager.newQuery(Class cls, Extent cln) - * constructs a query instance with the candidate class and candidate Extent specified. + *Title: New Query with Candidate Class and Extent + *
    + *Keywords: query extent + *
    + *Assertion ID: A14.5-6. + *
    + *Assertion Description: +PersistenceManager.newQuery(Class cls, Extent cln) +constructs a query instance with the candidate class and candidate +Extent specified. + */ -public class NewQueryWithCandidateClassAndExtent extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.5-6 (NewQueryWithCandidateClassAndExtent) failed: "; +public class NewQueryWithCandidateClassAndExtent extends QueryTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NewQueryWithCandidateClassAndExtent.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.5-6 (NewQueryWithCandidateClassAndExtent) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NewQueryWithCandidateClassAndExtent.class); + } - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - Class clazz = PCPoint.class; - try { - Extent extent = pm.getExtent(clazz, true); - tx.begin(); + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + Class clazz = PCPoint.class; + try { + Extent extent = pm.getExtent(clazz, true); + tx.begin(); - Query query = pm.newQuery(); - query.setClass(clazz); - query.setCandidates(extent); - Object results = query.execute(); + Query query = pm.newQuery(); + query.setClass(clazz); + query.setCandidates(extent); + Object results = query.execute(); - // check query result - printOutput(results, inserted); - checkQueryResultWithoutOrder(ASSERTION_FAILED, results, inserted); + // check query result + printOutput(results, inserted); + checkQueryResultWithoutOrder(ASSERTION_FAILED, results, inserted); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithCandidateClassAndFilter.java b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithCandidateClassAndFilter.java index b45239c4d..4c2ec8ebd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithCandidateClassAndFilter.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithCandidateClassAndFilter.java @@ -5,82 +5,93 @@ * 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 + * + * 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.jdo.tck.query.api; + import java.util.ArrayList; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: New Query with Candidate Class and Filter
    - * Keywords: query
    - * Assertion ID: A14.5-8.
    - * Assertion Description: PersistenceManager.newQuery(Class cls, String filter) - * constructs a query instance with the candidate class and filter specified. + *Title: New Query with Candidate Class and Filter + *
    + *Keywords: query + *
    + *Assertion ID: A14.5-8. + *
    + *Assertion Description: PersistenceManager.newQuery(Class cls, String filter) constructs a query instance with the candidate class and filter specified. */ -public class NewQueryWithCandidateClassAndFilter extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.5-8 (NewQueryWithCandidateClassAndFilter) failed: "; +public class NewQueryWithCandidateClassAndFilter extends QueryTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NewQueryWithCandidateClassAndFilter.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.5-8 (NewQueryWithCandidateClassAndFilter) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NewQueryWithCandidateClassAndFilter.class); + } - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); - Query query = pm.newQuery(PCPoint.class, "x == 1"); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - Object results = query.execute(); + Query query = pm.newQuery(PCPoint.class, "x == 1"); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + Object results = query.execute(); - // check query result - List expected = new ArrayList(); - Object pcp1 = new PCPoint(1, 1); - expected.add(pcp1); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 1", results, expected); + // check query result + List expected = new ArrayList(); + Object pcp1 = new PCPoint(1, 1); + expected.add(pcp1); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 1", + results, expected); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithCandidateClassCollectionFilter.java b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithCandidateClassCollectionFilter.java index b42d5f870..be0398a83 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithCandidateClassCollectionFilter.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithCandidateClassCollectionFilter.java @@ -5,81 +5,91 @@ * 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 + * + * 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.jdo.tck.query.api; + import java.util.ArrayList; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: New Query with Candidate Class, Collection, and Filter
    - * Keywords: query
    - * Assertion ID: A14.5-9.
    - * Assertion Description: - * PersistenceManager.newQuery(Class cls, Collection cln, String filter) constructs a query - * instance with the candidate class, the candidate Collection, and filter specified. + *Title: New Query with Candidate Class, Collection, and Filter + *
    + *Keywords: query + *
    + *Assertion ID: A14.5-9. + *
    + *Assertion Description: PersistenceManager.newQuery(Class cls, Collection cln, String filter) constructs a query instance with the candidate class, the candidate Collection, and filter specified. */ -public class NewQueryWithCandidateClassCollectionFilter extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.5-9 (NewQueryWithCandidateClassCollectionFilter) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NewQueryWithCandidateClassCollectionFilter.class); - } +public class NewQueryWithCandidateClassCollectionFilter extends QueryTest { - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.5-9 (NewQueryWithCandidateClassCollectionFilter) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NewQueryWithCandidateClassCollectionFilter.class); + } - Query query = pm.newQuery(PCPoint.class, inserted, "x ==2"); - Object results = query.execute(); + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); - // check query result - List expected = new ArrayList(); - PCPoint pc1 = new PCPoint(2, 2); - expected.add(pc1); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x ==2", results, expected); + Query query = pm.newQuery(PCPoint.class, inserted, "x ==2"); + Object results = query.execute(); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + // check query result + List expected = new ArrayList(); + PCPoint pc1 = new PCPoint(2, 2); + expected.add(pc1); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x ==2", + results, expected); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithExtent.java b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithExtent.java index 9b3c5f1b5..6d4f1dfbe 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithExtent.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithExtent.java @@ -5,74 +5,85 @@ * 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 + * + * 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.jdo.tck.query.api; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: New Query
    - * Keywords: query
    - * Assertion IDs: A14.5-1.
    - * Assertion Description: PersistenceManagerFactory.newQuery() constructs and empty Query - * instance. + *Title: New Query + *
    + *Keywords: query + *
    + *Assertion IDs: A14.5-1. + *
    + *Assertion Description: + PersistenceManagerFactory.newQuery() constructs and empty Query instance. + */ -public class NewQueryWithExtent extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.5-1 (NewQueryWithExtent) failed: "; +public class NewQueryWithExtent extends QueryTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NewQueryWithExtent.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.5-1 (NewQueryWithExtent) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NewQueryWithExtent.class); + } - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); - Query query = pm.newQuery(pm.getExtent(PCPoint.class, false)); - query.setClass(PCPoint.class); - Object results = query.execute(); + Query query = pm.newQuery(pm.getExtent(PCPoint.class, false)); + query.setClass(PCPoint.class); + Object results = query.execute(); - // check query result - printOutput(results, inserted); - checkQueryResultWithoutOrder(ASSERTION_FAILED, results, inserted); + // check query result + printOutput(results, inserted); + checkQueryResultWithoutOrder(ASSERTION_FAILED, results, inserted); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithExtentAndFilter.java b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithExtentAndFilter.java index 7c71eaede..38b3dd411 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithExtentAndFilter.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithExtentAndFilter.java @@ -5,79 +5,92 @@ * 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 + * + * 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.jdo.tck.query.api; + import java.util.ArrayList; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: New Query
    - * Keywords: query
    - * Assertion IDs: A14.5-10.
    - * Assertion Description: Construct a new query instance with the candidate Extent and - * filter specified; the candidate class is taken from the Extent. + *Title: New Query + *
    + *Keywords: query + *
    + *Assertion IDs: A14.5-10. + *
    + *Assertion Description: +Construct a new query instance with the candidate Extent and filter +specified; the candidate class is taken from the Extent. */ -public class NewQueryWithExtentAndFilter extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.5-1 (NewQueryWithExtentAndFilter) failed: "; +public class NewQueryWithExtentAndFilter extends QueryTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NewQueryWithExtentAndFilter.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.5-1 (NewQueryWithExtentAndFilter) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NewQueryWithExtentAndFilter.class); + } - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - try { - Query query = pm.newQuery(pm.getExtent(PCPoint.class, false), "x == 1"); - Object results = query.execute(); + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + try { + Query query = pm.newQuery(pm.getExtent(PCPoint.class, false), "x == 1"); + Object results = query.execute(); - // check query result - List expected = new ArrayList(); - Object pcp1 = new PCPoint(1, 1); - expected.add(pcp1); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 1", results, expected); + // check query result + List expected = new ArrayList(); + Object pcp1 = new PCPoint(1, 1); + expected.add(pcp1); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 1", + results, expected); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithSpecifiedLanguageAndQuery.java b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithSpecifiedLanguageAndQuery.java index d529cfad5..b313810ca 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithSpecifiedLanguageAndQuery.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/NewQueryWithSpecifiedLanguageAndQuery.java @@ -5,99 +5,108 @@ * 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 + * + * 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.jdo.tck.query.api; + import java.util.ArrayList; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: New Query With Specified Language and Query
    - * Keywords: query
    - * Assertion ID: A14.5-4.
    - * Assertion Description: PersistenceManager.newQuery(String language, Object query) - * constructs a query instance using the specified language and the specified query . The - * query instance returned will be of a class defined by the query language. The language parameter - * for the JDO Query language as herein documented is "javax.jdo.query.JDOQL". + *Title: New Query With Specified Language and Query + *
    + *Keywords: query + *
    + *Assertion ID: A14.5-4. + *
    + *Assertion Description: PersistenceManager.newQuery(String language, Object query) constructs a query instance using the specified language and the specified query . The query instance returned will be of a class defined by the query language. The language parameter for the JDO Query language as herein documented is "javax.jdo.query.JDOQL". */ -public class NewQueryWithSpecifiedLanguageAndQuery extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.5-4 (NewQueryWithSpecifiedLanguageAndQuery) failed: "; +public class NewQueryWithSpecifiedLanguageAndQuery extends QueryTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NewQueryWithSpecifiedLanguageAndQuery.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.5-4 (NewQueryWithSpecifiedLanguageAndQuery) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NewQueryWithSpecifiedLanguageAndQuery.class); + } - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - if (debug) logger.debug("\nExecuting test NewQueryWithSpecifiedLanguageAndQuery()..."); + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + if (debug) + logger.debug("\nExecuting test NewQueryWithSpecifiedLanguageAndQuery()..."); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); - Query query1 = pm.newQuery("javax.jdo.query.JDOQL", query); - query1.setCandidates(pm.getExtent(PCPoint.class, false)); - query1.compile(); - Object results = query1.execute(); + Query query1 = pm.newQuery("javax.jdo.query.JDOQL", query); + query1.setCandidates(pm.getExtent(PCPoint.class, false)); + query1.compile(); + Object results = query1.execute(); - // check query result - List expected = new ArrayList(); - Object p1 = new PCPoint(0, 0); - Object p2 = new PCPoint(1, 1); - Object p3 = new PCPoint(2, 2); - Object p4 = new PCPoint(3, 3); - Object p5 = new PCPoint(4, 4); - expected.add(p1); - expected.add(p2); - expected.add(p3); - expected.add(p4); - expected.add(p5); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected); - if (debug) logger.debug("Test NewQueryWithSpecifiedLanguageAndQuery() - Passed\n"); + // check query result + List expected = new ArrayList(); + Object p1 = new PCPoint(0, 0); + Object p2 = new PCPoint(1, 1); + Object p3 = new PCPoint(2, 2); + Object p4 = new PCPoint(3, 3); + Object p5 = new PCPoint(4, 4); + expected.add(p1); + expected.add(p2); + expected.add(p3); + expected.add(p4); + expected.add(p5); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected); + if (debug) + logger.debug("Test NewQueryWithSpecifiedLanguageAndQuery() - Passed\n"); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/QueryCancel.java b/tck/src/main/java/org/apache/jdo/tck/query/api/QueryCancel.java index 49c307499..9e34f8c7e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/QueryCancel.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/QueryCancel.java @@ -5,26 +5,30 @@ * 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 + * + * 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.jdo.tck.query.api; import java.util.concurrent.CyclicBarrier; + +import junit.framework.AssertionFailedError; + import javax.jdo.JDOFatalException; import javax.jdo.JDOQueryInterruptedException; import javax.jdo.JDOUnsupportedOptionException; import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; -import junit.framework.AssertionFailedError; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.pc.mylib.PCPoint2; import org.apache.jdo.tck.query.QueryTest; @@ -32,215 +36,233 @@ import org.apache.jdo.tck.util.ThreadExceptionHandler; /** - * Title: QueryCancel
    - * Keywords: query
    - * Assertion ID: A14.6.1-8
    - * Assertion Description: These methods cancel a running query (or queries). The thread that - * has its query canceled will throw a JDOQueryInterruptedException. If cancel is not supported - * (most likely due to the underlying implementation not supporting cancel) then - * JDOUnsupportedOptionException is thrown to the caller. - * - *

    REMARK: This assertion seems to be untestable with the current TCK, thus I drop it from the - * query.conf configuration. - * - *

    Looks like Derby is evaluating the query on ResultSet.next() and thus the actual query - * execution is too fast to be canceled. + *Title: QueryCancel + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.1-8 + *
    + *Assertion Description: +These methods cancel a running query (or queries). The thread that has its query +canceled will throw a JDOQueryInterruptedException. +If cancel is not supported (most likely due to the underlying implementation not +supporting cancel) then JDOUnsupportedOptionException is thrown to the caller. + +REMARK: +This assertion seems to be untestable with the current TCK, thus +I drop it from the query.conf configuration. + +Looks like Derby is evaluating the query on ResultSet.next() and +thus the actual query execution is too fast to be canceled. */ + public class QueryCancel extends QueryTest { - /** Time for the main thread to sleep after starting a parallel thread. */ - private static int MAIN_SLEEP_MILLIS = 40; - - /** Number of instances to be created. */ - private static int NO_OF_INSTANCES = 5000; - - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.1-8 (QueryCancel) failed: "; - - /** Single String JDOQL Query to be canceled. */ - private static String SSJDOQL = - "select avg (this.x + point2.y) " - + "from PCPoint " - + "where this.y >= 0 && point2.x >= 0 " - + "variables PCPoint2 point2 " - + "import org.apache.jdo.tck.pc.mylib.PCPoint; " - + "import org.apache.jdo.tck.pc.mylib.PCPoint2; "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(QueryCancel.class); - } - - /** - * @throws Exception exception - */ - public void testCancel() throws Exception { - PersistenceManager pm = getPM(); - // Test query - Query query = pm.newQuery(SSJDOQL); - query.compile(); - - // Thread executing the query - CyclicBarrier barrier = new CyclicBarrier(2); - ThreadExceptionHandler group = new ThreadExceptionHandler(); - QueryExecutor runnable = new QueryExecutor(pm, query, barrier); - Thread t = new Thread(group, runnable, "Query Executor"); - t.start(); - - try { - // Wait for the other thread - barrier.await(); - - // Wait a couple of millis such that the other thread can start query execution - Thread.sleep(MAIN_SLEEP_MILLIS); - - // cancel query - query.cancel(t); - if (!isQueryCancelSupported()) { - fail( - ASSERTION_FAILED, - "Query.cancel should throw a JDOQueryInterruptedException, " - + "if query canceling is not supported "); - } - } catch (JDOUnsupportedOptionException ex) { - if (isQueryCancelSupported()) { - fail( - ASSERTION_FAILED, - "Query.cancel should not result in a JDOQueryInterruptedException, " - + "if query canceling is supported "); - } - } + /** Time for the main thread to sleep after starting a parallel thread. */ + private static int MAIN_SLEEP_MILLIS = 40; - t.join(); - Throwable problem = group.getUncaughtException(t); - if (problem != null) { - if (problem instanceof AssertionFailedError) throw (AssertionFailedError) problem; - else throw new JDOFatalException("Thread " + t.getName() + " results in exception ", problem); - } - } - - /** - * @throws Exception exception - */ - public void testCancelAll() throws Exception { - PersistenceManager pm = getPM(); - // Test query - Query query = pm.newQuery(SSJDOQL); - query.compile(); - - // Thread executing the query - CyclicBarrier barrier = new CyclicBarrier(2); - ThreadExceptionHandler group = new ThreadExceptionHandler(); - QueryExecutor runnable = new QueryExecutor(pm, query, barrier); - Thread t = new Thread(group, runnable, "Query Executor"); - t.start(); - - try { - // cancel query - // Wait for the other thread - barrier.await(); - - // Wait a couple of millis such that the other thread can start query execution - Thread.sleep(MAIN_SLEEP_MILLIS); - - query.cancelAll(); - if (!isQueryCancelSupported()) { - fail( - ASSERTION_FAILED, - "Query.cancel should throw a JDOQueryInterruptedException, " - + "if query canceling is not supported "); - } - } catch (JDOUnsupportedOptionException ex) { - if (isQueryCancelSupported()) { - fail( - ASSERTION_FAILED, - "Query.cancel should not result in a JDOQueryInterruptedException, " - + "if query canceling is supported "); - } + /** Number of instances to be created. */ + private static int NO_OF_INSTANCES = 5000; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.1-8 (QueryCancel) failed: "; + + /** Single String JDOQL Query to be canceled. */ + private static String SSJDOQL = + "select avg (this.x + point2.y) " + + "from PCPoint " + + "where this.y >= 0 && point2.x >= 0 " + + "variables PCPoint2 point2 " + + "import org.apache.jdo.tck.pc.mylib.PCPoint; " + + "import org.apache.jdo.tck.pc.mylib.PCPoint2; "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(QueryCancel.class); } - t.join(); - Throwable problem = group.getUncaughtException(t); - if (problem != null) { - if (problem instanceof AssertionFailedError) throw (AssertionFailedError) problem; - else throw new JDOFatalException("Thread " + t.getName() + " results in exception ", problem); + /** + * + * @throws Exception exception + */ + public void testCancel() throws Exception { + PersistenceManager pm = getPM(); + // Test query + Query query = pm.newQuery(SSJDOQL); + query.compile(); + + // Thread executing the query + CyclicBarrier barrier = new CyclicBarrier(2); + ThreadExceptionHandler group = new ThreadExceptionHandler(); + QueryExecutor runnable = new QueryExecutor(pm, query, barrier); + Thread t = new Thread(group, runnable, "Query Executor"); + t.start(); + + try { + // Wait for the other thread + barrier.await(); + + // Wait a couple of millis such that the other thread can start query execution + Thread.sleep(MAIN_SLEEP_MILLIS); + + // cancel query + query.cancel(t); + if (!isQueryCancelSupported()) { + fail(ASSERTION_FAILED, + "Query.cancel should throw a JDOQueryInterruptedException, " + + "if query canceling is not supported "); + } + } + catch (JDOUnsupportedOptionException ex) { + if (isQueryCancelSupported()) { + fail(ASSERTION_FAILED, + "Query.cancel should not result in a JDOQueryInterruptedException, " + + "if query canceling is supported "); + } + } + + t.join(); + Throwable problem = group.getUncaughtException(t); + if (problem != null) { + if (problem instanceof AssertionFailedError) + throw (AssertionFailedError)problem; + else + throw new JDOFatalException( "Thread " + t.getName()+ + " results in exception ", problem); + } } - } - /** Runnable class executing the query. */ - class QueryExecutor implements Runnable { + /** + * + * @throws Exception exception + */ + public void testCancelAll() throws Exception { + PersistenceManager pm = getPM(); + // Test query + Query query = pm.newQuery(SSJDOQL); + query.compile(); + + // Thread executing the query + CyclicBarrier barrier = new CyclicBarrier(2); + ThreadExceptionHandler group = new ThreadExceptionHandler(); + QueryExecutor runnable = new QueryExecutor(pm, query, barrier); + Thread t = new Thread(group, runnable, "Query Executor"); + t.start(); + + try { + // cancel query + // Wait for the other thread + barrier.await(); - PersistenceManager pm; - CyclicBarrier barrier; - Query query; + // Wait a couple of millis such that the other thread can start query execution + Thread.sleep(MAIN_SLEEP_MILLIS); - QueryExecutor(PersistenceManager pm, Query query, CyclicBarrier barrier) { - this.pm = pm; - this.query = query; - this.barrier = barrier; + query.cancelAll(); + if (!isQueryCancelSupported()) { + fail(ASSERTION_FAILED, + "Query.cancel should throw a JDOQueryInterruptedException, " + + "if query canceling is not supported "); + } + } + catch (JDOUnsupportedOptionException ex) { + if (isQueryCancelSupported()) { + fail(ASSERTION_FAILED, + "Query.cancel should not result in a JDOQueryInterruptedException, " + + "if query canceling is supported "); + } + } + + t.join(); + Throwable problem = group.getUncaughtException(t); + if (problem != null) { + if (problem instanceof AssertionFailedError) + throw (AssertionFailedError)problem; + else + throw new JDOFatalException( "Thread " + t.getName()+ + " results in exception ", problem); + } } - public void run() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - // wait for the other thread - barrier.await(); - - Object result = query.execute(); - tx.commit(); - tx = null; - if (isQueryCancelSupported()) { - fail( - ASSERTION_FAILED, - "Query.execute should result in a JDOQueryInterruptedException, " - + "if query canceling is supported."); + /** Runnable class executing the query. */ + class QueryExecutor implements Runnable { + + PersistenceManager pm; + CyclicBarrier barrier; + Query query; + + QueryExecutor(PersistenceManager pm, Query query, CyclicBarrier barrier) { + this.pm = pm; + this.query = query; + this.barrier = barrier; } - } catch (JDOQueryInterruptedException ex) { - if (!isQueryCancelSupported()) { - fail( - ASSERTION_FAILED, - "Query.execute should not result in a JDOQueryInterruptedException, " - + "if query canceling is not supported."); + + public void run() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + // wait for the other thread + barrier.await(); + + Object result = query.execute(); + tx.commit(); + tx = null; + if (isQueryCancelSupported()) { + fail(ASSERTION_FAILED, + "Query.execute should result in a JDOQueryInterruptedException, " + + "if query canceling is supported."); + } + } + catch (JDOQueryInterruptedException ex) { + if (!isQueryCancelSupported()) { + fail(ASSERTION_FAILED, + "Query.execute should not result in a JDOQueryInterruptedException, " + + "if query canceling is not supported."); + } + } + catch (Exception ex) { + throw new RuntimeException(ex); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } catch (Exception ex) { - throw new RuntimeException(ex); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); - } } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - addTearDownClass(PCPoint2.class); - - // create PCPoint and PCPoint2 instances - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - for (int i = 0; i < NO_OF_INSTANCES; i++) { - PCPoint obj = new PCPoint(i, i); - pm.makePersistent(obj); - } - for (int i = 0; i < NO_OF_INSTANCES; i++) { - PCPoint2 obj = new PCPoint2(i, i); - pm.makePersistent(obj); - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + addTearDownClass(PCPoint2.class); + + // create PCPoint and PCPoint2 instances + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + for (int i = 0; i < NO_OF_INSTANCES; i++) { + PCPoint obj = new PCPoint(i, i); + pm.makePersistent(obj); + } + for (int i = 0; i < NO_OF_INSTANCES; i++) { + PCPoint2 obj = new PCPoint2(i, i); + pm.makePersistent(obj); + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/QueryExtentions.java b/tck/src/main/java/org/apache/jdo/tck/query/api/QueryExtentions.java index 231ccbf9d..20be68ee4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/QueryExtentions.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/QueryExtentions.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,58 +19,70 @@ import java.util.HashMap; import java.util.Map; + import javax.jdo.Query; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Query Extentions.
    - * Keywords: query
    - * Assertion ID: A14.9-1.
    - * Assertion Description: Some JDO vendors provide extensions to the query, and these - * extensions must be set in the query instance prior to execution. + *Title: Query Extentions. + *
    + *Keywords: query + *
    + *Assertion ID: A14.9-1. + *
    + *Assertion Description: + * Some JDO vendors provide extensions to the query, + * and these extensions must be set in the query instance prior to execution. */ public class QueryExtentions extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.9-1 (QueryExtentions) failed: "; - - private static String singleStringQuery = "SELECT FROM " + Person.class.getName(); - - /** The expected results of valid queries. */ - private Object[] expectedResult = { - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(QueryExtentions.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.9-1 (QueryExtentions) failed: "; + + private static String singleStringQuery = + "SELECT FROM " + Person.class.getName(); - /** */ - public void testPositive() { - int index = 0; - Query query = getPM().newQuery(singleStringQuery); - Map extentions = new HashMap(); - extentions.put("unknown key 1", "unknown value 1"); - query.setExtensions(extentions); - query.addExtension("unknown key 2", "unknown value 2"); - executeJDOQuery( - ASSERTION_FAILED, query, singleStringQuery, false, null, expectedResult[index], true); - } + /** + * The expected results of valid queries. + */ + private Object[] expectedResult = { + getTransientCompanyModelInstancesAsList( + new String[]{"emp1", "emp2", "emp3", "emp4", "emp5"}) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(QueryExtentions.class); + } + + /** */ + public void testPositive() { + int index = 0; + Query query = getPM().newQuery(singleStringQuery); + Map extentions = new HashMap(); + extentions.put("unknown key 1", "unknown value 1"); + query.setExtensions(extentions); + query.addExtension("unknown key 2", "unknown value 2"); + executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery, + false, null, expectedResult[index], true); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/SampleQueries.java b/tck/src/main/java/org/apache/jdo/tck/query/api/SampleQueries.java index 308018452..e67da54e8 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/SampleQueries.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/SampleQueries.java @@ -5,29 +5,18 @@ * 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 + * + * 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.jdo.tck.query.api; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.jdo.JDOQLTypedQuery; -import javax.jdo.JDOQLTypedSubquery; -import javax.jdo.Query; -import javax.jdo.Transaction; -import javax.jdo.query.CollectionExpression; -import javax.jdo.query.NumericExpression; -import javax.jdo.query.StringExpression; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.Employee; @@ -40,3045 +29,3027 @@ import org.apache.jdo.tck.util.BatchTestRunner; import org.apache.jdo.tck.util.EqualityHelper; +import javax.jdo.JDOQLTypedQuery; +import javax.jdo.JDOQLTypedSubquery; +import javax.jdo.Query; +import javax.jdo.Transaction; +import javax.jdo.query.CollectionExpression; +import javax.jdo.query.NumericExpression; +import javax.jdo.query.StringExpression; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + /** - * Title: SampleQueries
    - * Keywords: query
    - * Assertion IDs:
    - * Assertion Description: This test class runs the example queries from the JDO - * specification. + *Title: SampleQueries + *
    + *Keywords: query + *
    + *Assertion IDs: + *
    + *Assertion Description: + * This test class runs the example queries from the JDO specification. * - *

    There are up to six test methods per test case: testQueryxxa: runtime constructed JDO query - * using execute to run the query testQueryxxb: runtime constructed JDO query using - * setNamedParameters to specify the parameter values and - * executeList/executeResultList/executeResultUnique to run the query testQueryxxc: runtime - * constructed JDO query using setParameters to specify the parameter values and - * executeList/executeResultList/executeResultUnique to run the query testQueryxxd: single string - * version of the JDO query testQueryxxe: named query version of the JDO query testQueryxxf: - * JDOQLTypedQuery version + * There are up to six test methods per test case: + * testQueryxxa: runtime constructed JDO query using execute to run the query + * testQueryxxb: runtime constructed JDO query using setNamedParameters to specify the parameter values and + * executeList/executeResultList/executeResultUnique to run the query + * testQueryxxc: runtime constructed JDO query using setParameters to specify the parameter values and + * executeList/executeResultList/executeResultUnique to run the query + * testQueryxxd: single string version of the JDO query + * testQueryxxe: named query version of the JDO query + * testQueryxxf: JDOQLTypedQuery version */ public class SampleQueries extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion (SampleQueries) failed: "; - - /** */ - private static final String SAMPLE_QUERIES_TEST_COMPANY_TESTDATA = - "org/apache/jdo/tck/pc/company/companyForSampleQueriesTest.xml"; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SampleQueries.class); - } - - private static final String SINGLE_STRING_QUERY_01 = - "select from org.apache.jdo.tck.pc.company.FullTimeEmployee where salary > 30000"; - - private static final String SINGLE_STRING_QUERY_02 = - "select from org.apache.jdo.tck.pc.company.FullTimeEmployee " - + "where salary > 30000 order by salary ascending"; - - private static final String SINGLE_STRING_QUERY_03 = - "select from org.apache.jdo.tck.pc.company.FullTimeEmployee " - + "where salary > :sal && firstname.startsWith(:begin)"; - - private static final String SINGLE_STRING_QUERY_04 = - "select from org.apache.jdo.tck.pc.company.Employee where department.name == :dep"; - - private static final String SINGLE_STRING_QUERY_05 = - "select from org.apache.jdo.tck.pc.company.Department " - + "where employees.contains(emp) && emp.weeklyhours > :hours variables Employee emp"; - - private static final String SINGLE_STRING_QUERY_06 = - "select from org.apache.jdo.tck.pc.company.Department where :depts.contains(name)"; - - private static final String SINGLE_STRING_QUERY_07 = - "select firstname from org.apache.jdo.tck.pc.company.Employee where department.name == :deptName"; - - private static final String SINGLE_STRING_QUERY_08 = - "select firstname, salary, manager as reportsTo into org.apache.jdo.tck.query.api.SampleQueries$Info " - + "from org.apache.jdo.tck.pc.company.FullTimeEmployee where department.name == :deptName"; - - private static final String SINGLE_STRING_QUERY_09 = - "select new org.apache.jdo.tck.query.api.SampleQueries$Info (firstname, salary, manager) " - + "from org.apache.jdo.tck.pc.company.FullTimeEmployee where department.name == :deptName"; - - private static final String SINGLE_STRING_QUERY_10 = - "select avg(salary) from org.apache.jdo.tck.pc.company.FullTimeEmployee " - + "where department.name == :deptName"; - - private static final String SINGLE_STRING_QUERY_11 = - "select avg(salary), sum(salary) from org.apache.jdo.tck.pc.company.FullTimeEmployee " - + "where department.name == :deptName"; - - private static final String SINGLE_STRING_QUERY_12 = - "select avg(salary), sum(salary), department.name " - + "from org.apache.jdo.tck.pc.company.FullTimeEmployee " - + "group by department.name having count(department.name) > 1"; - - private static final String SINGLE_STRING_QUERY_13 = - "select unique this from org.apache.jdo.tck.pc.company.Employee where firstname == :empName"; - - private static final String SINGLE_STRING_QUERY_14 = - "select unique salary from org.apache.jdo.tck.pc.company.FullTimeEmployee " - + "where firstname == :empName"; - - private static final String SINGLE_STRING_QUERY_15 = - "select into org.apache.jdo.tck.query.api.SampleQueries$EmpWrapper " - + "from org.apache.jdo.tck.pc.company.FullTimeEmployee where salary > :sal"; - - private static final String SINGLE_STRING_QUERY_16 = - "select into org.apache.jdo.tck.query.api.SampleQueries$EmpInfo " - + "from org.apache.jdo.tck.pc.company.FullTimeEmployee where salary > :sal"; - - private static final String SINGLE_STRING_QUERY_17 = - "select e.firstname from org.apache.jdo.tck.pc.company.Department " - + "where name.startsWith('R&D') && employees.contains(e) " - + "variables org.apache.jdo.tck.pc.company.Employee e"; - - private static final String SINGLE_STRING_QUERY_18 = - "select firstname from org.apache.jdo.tck.pc.company.Employee " - + "where this.weeklyhours > (select avg(e.weeklyhours) from org.apache.jdo.tck.pc.company.Employee e)"; - - private static final String SINGLE_STRING_QUERY_19 = - "select firstname from org.apache.jdo.tck.pc.company.Employee " - + "where this.weeklyhours > " - + " (select AVG(e.weeklyhours) from this.department.employees e where e.manager == this.manager)"; - - /** - * Basic query. - * - *

    This query selects all Employee instances from the candidate collection where the salary is - * greater than the constant 30000. Note that the float value for salary is unwrapped for the - * comparison with the literal int value, which is promoted to float using numeric promotion. If - * the value for the salary field in a candidate instance isnull, then it cannot be unwrapped for - * the comparison, and the candidate instance is rejected. - */ - public void testQuery01a() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp5"}); - try (Query q = pm.newQuery(FullTimeEmployee.class, "salary > 30000")) { - List emps = (List) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_01, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Basic query. - * - *

    This query selects all Employee instances from the candidate collection where the salary is - * greater than the constant 30000. Note that the float value for salary is unwrapped for the - * comparison with the literal int value, which is promoted to float using numeric promotion. If - * the value for the salary field in a candidate instance isnull, then it cannot be unwrapped for - * the comparison, and the candidate instance is rejected. - */ - public void testQuery01b() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp5"}); - try (Query q = pm.newQuery(FullTimeEmployee.class, "salary > 30000")) { - List emps = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_01, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Basic query. - * - *

    This query selects all Employee instances from the candidate collection where the salary is - * greater than the constant 30000. Note that the float value for salary is unwrapped for the - * comparison with the literal int value, which is promoted to float using numeric promotion. If - * the value for the salary field in a candidate instance isnull, then it cannot be unwrapped for - * the comparison, and the candidate instance is rejected. - */ - public void testQuery01d() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp5"}); - try (Query q = pm.newQuery(SINGLE_STRING_QUERY_01)) { - List emps = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_01, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Basic query. - * - *

    This query selects all Employee instances from the candidate collection where the salary is - * greater than the constant 30000. Note that the float value for salary is unwrapped for the - * comparison with the literal int value, which is promoted to float using numeric promotion. If - * the value for the salary field in a candidate instance isnull, then it cannot be unwrapped for - * the comparison, and the candidate instance is rejected. - */ - public void testQuery01f() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp5"}); - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - q.filter(cand.salary.gt(30000.)); - List emps = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_01, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Basic query with ordering. - * - *

    This query selects all Employee instances from the candidate collection where the salary is - * greater than the constant 30000, and returns a Collection ordered based on employee salary. - */ - public void testQuery02a() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp5", "emp2"}); - try (Query q = pm.newQuery(FullTimeEmployee.class, "salary > 30000")) { - q.setOrdering("salary ascending"); - List emps = (List) q.execute(); - checkQueryResultWithOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_02, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Basic query with ordering. - * - *

    This query selects all Employee instances from the candidate collection where the salary is - * greater than the constant 30000, and returns a Collection ordered based on employee salary. - */ - public void testQuery02b() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp5", "emp2"}); - try (Query q = pm.newQuery(FullTimeEmployee.class, "salary > 30000")) { - q.setOrdering("salary ascending"); - List emps = q.executeList(); - checkQueryResultWithOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_02, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Basic query with ordering. - * - *

    This query selects all Employee instances from the candidate collection where the salary is - * greater than the constant 30000, and returns a Collection ordered based on employee salary. - */ - public void testQuery02d() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp5", "emp2"}); - try (Query q = pm.newQuery(SINGLE_STRING_QUERY_02)) { - List emps = q.executeList(); - checkQueryResultWithOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_02, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Basic query with ordering. - * - *

    This query selects all Employee instances from the candidate collection where the salary is - * greater than the constant 30000, and returns a Collection ordered based on employee salary. - */ - public void testQuery02f() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp5", "emp2"}); - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - q.filter(cand.salary.gt(30000.)).orderBy(cand.salary.asc()); - List emps = q.executeList(); - checkQueryResultWithOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_02, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Parameter passing. - * - *

    This query selects all Employee instances from the candidate collection where the salary is - * greater than the value passed as a parameter and the name starts with the value passed as a - * second parameter. If the value for the salary field in a candidate instance is null, then it - * cannot be unwrapped for the comparison, and the candidate instance is rejected. - */ - public void testQuery03a() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - try (Query q = - pm.newQuery(FullTimeEmployee.class, "salary > sal && firstname.startsWith(begin)")) { - q.declareParameters("Double sal, String begin"); - List emps = (List) q.execute(30000., "M"); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_03, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Parameter passing. - * - *

    This query selects all Employee instances from the candidate collection where the salary is - * greater than the value passed as a parameter and the name starts with the value passed as a - * second parameter. If the value for the salary field in a candidate instance is null, then it - * cannot be unwrapped for the comparison, and the candidate instance is rejected. - */ - public void testQuery03b() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - try (Query q = - pm.newQuery(FullTimeEmployee.class, "salary > sal && firstname.startsWith(begin)")) { - q.declareParameters("Double sal, String begin"); - Map paramValues = new HashMap<>(); - paramValues.put("sal", 30000.); - paramValues.put("begin", "M"); - q.setNamedParameters(paramValues); - List emps = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_03, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Parameter passing. - * - *

    This query selects all Employee instances from the candidate collection where the salary is - * greater than the value passed as a parameter and the name starts with the value passed as a - * second parameter. If the value for the salary field in a candidate instance is null, then it - * cannot be unwrapped for the comparison, and the candidate instance is rejected. - */ - public void testQuery03c() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - try (Query q = - pm.newQuery(FullTimeEmployee.class, "salary > sal && firstname.startsWith(begin)")) { - q.declareParameters("Double sal, String begin"); - q.setParameters(30000., "M"); - List emps = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_03, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Parameter passing. - * - *

    This query selects all Employee instances from the candidate collection where the salary is - * greater than the value passed as a parameter and the name starts with the value passed as a - * second parameter. If the value for the salary field in a candidate instance is null, then it - * cannot be unwrapped for the comparison, and the candidate instance is rejected. - */ - public void testQuery03d() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - try (Query q = pm.newQuery(SINGLE_STRING_QUERY_03)) { - List emps = (List) q.execute(30000., "M"); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_03, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Parameter passing. - * - *

    This query selects all Employee instances from the candidate collection where the salary is - * greater than the value passed as a parameter and the name starts with the value passed as a - * second parameter. If the value for the salary field in a candidate instance is null, then it - * cannot be unwrapped for the comparison, and the candidate instance is rejected. - */ - public void testQuery03f() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - NumericExpression sal = q.numericParameter("sal", Double.class); - StringExpression begin = q.stringParameter("begin"); - q.filter(cand.salary.gt(sal).and(cand.firstname.startsWith(begin))); - Map paramValues = new HashMap<>(); - paramValues.put("sal", 30000.); - paramValues.put("begin", "M"); - q.setParameters(paramValues); - List emps = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_03, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Navigation through single-valued field. - * - *

    This query selects all Employee instances from the candidate collection where the value of - * the name field in the Department instance associated with the Employee instance is equal to the - * value passed as a parameter. If the value for the dept field in a candidate instance is null, - * then it cannot be navigated for the comparison, and the candidate instance is rejected. - */ - public void testQuery04a() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3"}); - try (Query q = pm.newQuery(Employee.class, "department.name == dep")) { - q.declareParameters("String dep"); - List emps = (List) q.execute("R&D"); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_04, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Navigation through single-valued field. - * - *

    This query selects all Employee instances from the candidate collection where the value of - * the name field in the Department instance associated with the Employee instance is equal to the - * value passed as a parameter. If the value for the dept field in a candidate instance is null, - * then it cannot be navigated for the comparison, and the candidate instance is rejected. - */ - public void testQuery04b() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3"}); - try (Query q = pm.newQuery(Employee.class, "department.name == dep")) { - q.declareParameters("String dep"); - Map paramValues = new HashMap<>(); - paramValues.put("dep", "R&D"); - q.setNamedParameters(paramValues); - List emps = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_04, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Navigation through single-valued field. - * - *

    This query selects all Employee instances from the candidate collection where the value of - * the name field in the Department instance associated with the Employee instance is equal to the - * value passed as a parameter. If the value for the dept field in a candidate instance is null, - * then it cannot be navigated for the comparison, and the candidate instance is rejected. - */ - public void testQuery04c() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3"}); - try (Query q = pm.newQuery(Employee.class, "department.name == dep")) { - q.declareParameters("String dep"); - q.setParameters("R&D"); - List emps = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_04, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Navigation through single-valued field. - * - *

    This query selects all Employee instances from the candidate collection where the value of - * the name field in the Department instance associated with the Employee instance is equal to the - * value passed as a parameter. If the value for the dept field in a candidate instance is null, - * then it cannot be navigated for the comparison, and the candidate instance is rejected. - */ - public void testQuery04d() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3"}); - try (Query q = pm.newQuery(SINGLE_STRING_QUERY_04)) { - Map paramValues = new HashMap<>(); - paramValues.put("dep", "R&D"); - q.setNamedParameters(paramValues); - List emps = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_04, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Navigation through single-valued field. - * - *

    This query selects all Employee instances from the candidate collection where the value of - * the name field in the Department instance associated with the Employee instance is equal to the - * value passed as a parameter. If the value for the dept field in a candidate instance is null, - * then it cannot be navigated for the comparison, and the candidate instance is rejected. - */ - public void testQuery04f() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3"}); - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(Employee.class)) { - QEmployee cand = QEmployee.candidate(); - StringExpression dep = q.stringParameter("dep"); - q.filter(cand.department.name.eq(dep)); - Map paramValues = new HashMap<>(); - paramValues.put("dep", "R&D"); - q.setParameters(paramValues); - List emps = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_04, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Navigation through multi-valued field. - * - *

    This query selects all Department instances from the candidate collection where the - * collection of Employee instances contains at least one Employee instance having a salary - * greater than the value passed as a parameter. - */ - public void testQuery05a() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); - try (Query q = - pm.newQuery(Department.class, "employees.contains (emp) && emp.weeklyhours > hours")) { - q.declareVariables("Employee emp"); - q.declareParameters("double hours"); - List deps = (List) q.execute(30.); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_05, deps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Navigation through multi-valued field. - * - *

    This query selects all Department instances from the candidate collection where the - * collection of Employee instances contains at least one Employee instance having a salary - * greater than the value passed as a parameter. - */ - public void testQuery05b() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); - try (Query q = - pm.newQuery(Department.class, "employees.contains (emp) && emp.weeklyhours > hours")) { - q.declareVariables("Employee emp"); - q.declareParameters("double hours"); - Map paramValues = new HashMap<>(); - paramValues.put("hours", 30.); - q.setNamedParameters(paramValues); - List deps = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_05, deps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Navigation through multi-valued field. - * - *

    This query selects all Department instances from the candidate collection where the - * collection of Employee instances contains at least one Employee instance having a salary - * greater than the value passed as a parameter. - */ - public void testQuery05c() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); - try (Query q = - pm.newQuery(Department.class, "employees.contains (emp) && emp.weeklyhours > hours")) { - q.declareVariables("Employee emp"); - q.declareParameters("double hours"); - q.setParameters(30.); - List deps = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_05, deps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Navigation through multi-valued field. - * - *

    This query selects all Department instances from the candidate collection where the - * collection of Employee instances contains at least one Employee instance having a salary - * greater than the value passed as a parameter. - */ - public void testQuery05d() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); - try (Query q = pm.newQuery(SINGLE_STRING_QUERY_05)) { - List deps = (List) q.execute(30.); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_05, deps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Navigation through multi-valued field. - * - *

    This query selects all Department instances from the candidate collection where the - * collection of Employee instances contains at least one Employee instance having a salary - * greater than the value passed as a parameter. - */ - public void testQuery05f() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(Department.class)) { - QDepartment cand = QDepartment.candidate(); - QEmployee emp = QEmployee.variable("emp"); - NumericExpression hours = q.numericParameter("hours", double.class); - q.filter(cand.employees.contains(emp).and(emp.weeklyhours.gt(hours))); - Map paramValues = new HashMap<>(); - paramValues.put("hours", 30.); - q.setParameters(paramValues); - List deps = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_05, deps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Membership in a collection. - * - *

    This query selects all Department instances where the name field is contained in a parameter - * collection, which in this example consists of three department names. - */ - public void testQuery06a() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"dept1", "dept2", "dept3"}); - try (Query q = pm.newQuery(Department.class, "depts.contains(name)")) { - q.declareParameters("java.util.Collection depts"); - List deptNames = Arrays.asList("R&D", "Sales", "Marketing"); - List result = (List) q.execute(deptNames); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_06, result, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Membership in a collection. - * - *

    This query selects all Department instances where the name field is contained in a parameter - * collection, which in this example consists of three department names. - */ - public void testQuery06b() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"dept1", "dept2", "dept3"}); - try (Query q = pm.newQuery(Department.class, "depts.contains(name)")) { - q.declareParameters("java.util.Collection depts"); - Map paramValues = new HashMap<>(); - paramValues.put("depts", Arrays.asList("R&D", "Sales", "Marketing")); - q.setNamedParameters(paramValues); - List result = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_06, result, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Membership in a collection. - * - *

    This query selects all Department instances where the name field is contained in a parameter - * collection, which in this example consists of three department names. - */ - public void testQuery06c() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"dept1", "dept2", "dept3"}); - try (Query q = pm.newQuery(Department.class, "depts.contains(name)")) { - q.declareParameters("java.util.Collection depts"); - q.setParameters(Arrays.asList("R&D", "Sales", "Marketing")); - List result = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_06, result, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Membership in a collection. - * - *

    This query selects all Department instances where the name field is contained in a parameter - * collection, which in this example consists of three department names. - */ - public void testQuery06d() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"dept1", "dept2", "dept3"}); - try (Query q = pm.newQuery(SINGLE_STRING_QUERY_06)) { - Map paramValues = new HashMap<>(); - paramValues.put("depts", Arrays.asList("R&D", "Sales", "Marketing")); - q.setNamedParameters(paramValues); - List result = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_06, result, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Membership in a collection. - * - *

    This query selects all Department instances where the name field is contained in a parameter - * collection, which in this example consists of three department names. - */ - public void testQuery06f() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"dept1", "dept2", "dept3"}); - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(Department.class)) { - QDepartment cand = QDepartment.candidate(); - CollectionExpression, String> depts = - q.collectionParameter("depts", String.class); - q.filter(depts.contains(cand.name)); - Map paramValues = new HashMap<>(); - paramValues.put("depts", Arrays.asList("R&D", "Sales", "Marketing")); - q.setParameters(paramValues); - List result = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_06, result, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of a Single Field. - * - *

    This query selects names of all Employees who work in the parameter department. - */ - public void testQuery07a() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = Arrays.asList("Joe", "Craig", "Michael"); - try (Query q = pm.newQuery(Employee.class, "department.name == deptName")) { - q.setResult("firstname"); - q.declareParameters("String deptName"); - List names = (List) q.execute("R&D"); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_07, names, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of a Single Field. - * - *

    This query selects names of all Employees who work in the parameter department. - */ - public void testQuery07b() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = Arrays.asList("Joe", "Craig", "Michael"); - try (Query q = pm.newQuery(Employee.class, "department.name == deptName")) { - q.setResult("firstname"); - q.declareParameters("String deptName"); - Map paramValues = new HashMap<>(); - paramValues.put("deptName", "R&D"); - q.setNamedParameters(paramValues); - List names = q.executeResultList(String.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_07, names, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of a Single Field. - * - *

    This query selects names of all Employees who work in the parameter department. - */ - public void testQuery07c() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = Arrays.asList("Joe", "Craig", "Michael"); - try (Query q = pm.newQuery(Employee.class, "department.name == deptName")) { - q.setResult("firstname"); - q.declareParameters("String deptName"); - q.setParameters("R&D"); - List names = q.executeResultList(String.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_07, names, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of a Single Field. - * - *

    This query selects names of all Employees who work in the parameter department. - */ - public void testQuery07d() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = Arrays.asList("Joe", "Craig", "Michael"); - try (Query q = pm.newQuery(SINGLE_STRING_QUERY_07)) { - Map paramValues = new HashMap<>(); - paramValues.put("deptName", "R&D"); - q.setNamedParameters(paramValues); - List names = q.executeResultList(String.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_07, names, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of a Single Field. - * - *

    This query selects names of all Employees who work in the parameter department. - */ - public void testQuery07f() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = Arrays.asList("Joe", "Craig", "Michael"); - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(Employee.class)) { - QEmployee cand = QEmployee.candidate(); - StringExpression deptName = q.stringParameter("deptName"); - q.filter(cand.department.name.eq(deptName)).result(false, cand.firstname); - Map paramValues = new HashMap<>(); - paramValues.put("deptName", "R&D"); - q.setParameters(paramValues); - List names = q.executeResultList(String.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_07, names, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of Multiple Fields and Expressions. - * - *

    This query selects names, salaries, and bosses of Employees who work in the parameter - * department. - */ - public void testQuery08a() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = testQuery08Helper(); - try (Query q = - pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { - q.setResult("firstname, salary, manager as reportsTo"); - q.setResultClass(Info.class); - q.declareParameters("String deptName"); - List infos = (List) q.execute("R&D"); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_08, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of Multiple Fields and Expressions. - * - *

    This query selects names, salaries, and bosses of Employees who work in the parameter - * department. - */ - public void testQuery08b() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = testQuery08Helper(); - try (Query q = - pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { - q.setResult("firstname, salary, manager as reportsTo"); - q.setResultClass(Info.class); - q.declareParameters("String deptName"); - Map paramValues = new HashMap<>(); - paramValues.put("deptName", "R&D"); - q.setNamedParameters(paramValues); - List infos = q.executeResultList(Info.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_08, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of Multiple Fields and Expressions. - * - *

    This query selects names, salaries, and bosses of Employees who work in the parameter - * department. - */ - public void testQuery08c() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = testQuery08Helper(); - try (Query q = - pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { - q.setResult("firstname, salary, manager as reportsTo"); - q.setResultClass(Info.class); - q.declareParameters("String deptName"); - q.setParameters("R&D"); - List infos = q.executeResultList(Info.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_08, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of Multiple Fields and Expressions. - * - *

    This query selects names, salaries, and bosses of Employees who work in the parameter - * department. - */ - public void testQuery08d() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = testQuery08Helper(); - try (Query q = pm.newQuery(SINGLE_STRING_QUERY_08)) { - q.setParameters("R&D"); - List infos = q.executeResultList(Info.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_08, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of Multiple Fields and Expressions. - * - *

    This query selects names, salaries, and bosses of Employees who work in the parameter - * department. - */ - public void testQuery08f() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = testQuery08Helper(); - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - StringExpression deptName = q.stringParameter("deptName"); - q.result(false, cand.firstname, cand.salary, cand.manager.as("reportsTo")) - .filter(cand.department.name.eq(deptName)); - Map paramValues = new HashMap<>(); - paramValues.put("deptName", "R&D"); - q.setParameters(paramValues); - List infos = q.executeResultList(Info.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_08, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of Multiple Fields and Expressions into a Constructed instance. - * - *

    This query selects names, salaries, and bosses of Employees who work in the parameter - * department, and uses the constructor for the result class. - */ - public void testQuery09a() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - Arrays.asList( - new Info("Michael", 40000., (Employee) getTransientCompanyModelInstance("emp2")), - new Info("Craig", 50000., null)); - try (Query q = - pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { - q.setResult( - "new org.apache.jdo.tck.query.api.SampleQueries$Info(firstname, salary, manager)"); - q.declareParameters("String deptName"); - List infos = (List) q.execute("R&D"); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_09, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of Multiple Fields and Expressions into a Constructed instance. - * - *

    This query selects names, salaries, and bosses of Employees who work in the parameter - * department, and uses the constructor for the result class. - */ - public void testQuery09b() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - Arrays.asList( - new Info("Michael", 40000., (Employee) getTransientCompanyModelInstance("emp2")), - new Info("Craig", 50000., null)); - try (Query q = - pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { - q.setResult( - "new org.apache.jdo.tck.query.api.SampleQueries$Info(firstname, salary, manager)"); - q.declareParameters("String deptName"); - Map paramValues = new HashMap<>(); - paramValues.put("deptName", "R&D"); - q.setNamedParameters(paramValues); - List infos = q.executeResultList(Info.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_09, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of Multiple Fields and Expressions into a Constructed instance. - * - *

    This query selects names, salaries, and bosses of Employees who work in the parameter - * department, and uses the constructor for the result class. - */ - public void testQuery09c() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - Arrays.asList( - new Info("Michael", 40000., (Employee) getTransientCompanyModelInstance("emp2")), - new Info("Craig", 50000., null)); - try (Query q = - pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { - q.setResult( - "new org.apache.jdo.tck.query.api.SampleQueries$Info(firstname, salary, manager)"); - q.declareParameters("String deptName"); - q.setParameters("R&D"); - List infos = q.executeResultList(Info.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_09, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of Multiple Fields and Expressions into a Constructed instance. - * - *

    This query selects names, salaries, and bosses of Employees who work in the parameter - * department, and uses the constructor for the result class. - */ - public void testQuery09d() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - Arrays.asList( - new Info("Michael", 40000., (Employee) getTransientCompanyModelInstance("emp2")), - new Info("Craig", 50000., null)); - try (Query q = pm.newQuery(SINGLE_STRING_QUERY_09)) { - q.setParameters("R&D"); - List infos = q.executeResultList(Info.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_09, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of Multiple Fields and Expressions into a Constructed instance. - * - *

    This query selects names, salaries, and bosses of Employees who work in the parameter - * department, and uses the constructor for the result class. - */ - public void testQuery09e() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - Arrays.asList( - new Info("Michael", 40000., (Employee) getTransientCompanyModelInstance("emp2")), - new Info("Craig", 50000., null)); - try (Query q = pm.newNamedQuery(FullTimeEmployee.class, "constructor")) { - q.setParameters("R&D"); - List infos = q.executeResultList(Info.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_09, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of Multiple Fields and Expressions into a Constructed instance. - * - *

    This query selects names, salaries, and bosses of Employees who work in the parameter - * department, and uses the constructor for the result class. - */ - public void testQuery09f() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - Arrays.asList( - new Info("Michael", 40000., (Employee) getTransientCompanyModelInstance("emp2")), - new Info("Craig", 50000., null)); - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - StringExpression deptName = q.stringParameter("deptName"); - q.result(false, cand.firstname, cand.salary, cand.manager) - .filter(cand.department.name.eq(deptName)); - Map paramValues = new HashMap<>(); - paramValues.put("deptName", "R&D"); - q.setParameters(paramValues); - List infos = q.executeResultList(Info.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_09, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Aggregation of a single Field. - * - *

    This query averages the salaries of Employees who work in the parameter department and - * returns a single value. - */ - public void testQuery10a() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Double expected = 45000.; - try (Query q = - pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { - q.setResult("avg(salary)"); - q.declareParameters("String deptName"); - Double avgSalary = (Double) q.execute("R&D"); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_10, avgSalary, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Aggregation of a single Field. - * - *

    This query averages the salaries of Employees who work in the parameter department and - * returns a single value. - */ - public void testQuery10b() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Double expected = 45000.; - try (Query q = - pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { - q.setResult("avg(salary)"); - q.declareParameters("String deptName"); - Map paramValues = new HashMap<>(); - paramValues.put("deptName", "R&D"); - q.setNamedParameters(paramValues); - Double avgSalary = q.executeResultUnique(Double.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_10, avgSalary, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Aggregation of a single Field. - * - *

    This query averages the salaries of Employees who work in the parameter department and - * returns a single value. - */ - public void testQuery10c() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Double expected = 45000.; - try (Query q = - pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { - q.setResult("avg(salary)"); - q.declareParameters("String deptName"); - q.setParameters("R&D"); - Double avgSalary = q.executeResultUnique(Double.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_10, avgSalary, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Aggregation of a single Field. - * - *

    This query averages the salaries of Employees who work in the parameter department and - * returns a single value. - */ - public void testQuery10d() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Double expected = 45000.; - try (Query q = pm.newQuery(SINGLE_STRING_QUERY_10)) { - q.setParameters("R&D"); - Double avgSalary = q.executeResultUnique(Double.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_10, avgSalary, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Aggregation of a single Field. - * - *

    This query averages the salaries of Employees who work in the parameter department and - * returns a single value. - */ - public void testQuery10f() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Double expected = 45000.; - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - StringExpression deptName = q.stringParameter("deptName"); - q.result(false, cand.salary.avg()).filter(cand.department.name.eq(deptName)); - Map paramValues = new HashMap<>(); - paramValues.put("deptName", "R&D"); - q.setParameters(paramValues); - Double avgSalary = q.executeResultUnique(Double.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_10, avgSalary, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Aggregation of Multiple Fields and Expressions. - * - *

    This query averages and sums the salaries of Employees who work in the parameter department. - */ - public void testQuery11a() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Double[] expected = new Double[] {45000., 90000.}; - try (Query q = - pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { - q.setResult("avg(salary), sum(salary)"); - q.declareParameters("String deptName"); - Object[] avgSum = (Object[]) q.execute("R&D"); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_11, avgSum, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Aggregation of Multiple Fields and Expressions. - * - *

    This query averages and sums the salaries of Employees who work in the parameter department. - */ - public void testQuery11b() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Double[] expected = new Double[] {45000., 90000.}; - try (Query q = - pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { - q.setResult("avg(salary), sum(salary)"); - q.declareParameters("String deptName"); - Map paramValues = new HashMap<>(); - paramValues.put("deptName", "R&D"); - q.setNamedParameters(paramValues); - Object[] avgSum = q.executeResultUnique(Object[].class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_11, avgSum, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Aggregation of Multiple Fields and Expressions. - * - *

    This query averages and sums the salaries of Employees who work in the parameter department. - */ - public void testQuery11c() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Double[] expected = new Double[] {45000., 90000.}; - try (Query q = - pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { - q.setResult("avg(salary), sum(salary)"); - q.declareParameters("String deptName"); - q.setParameters("R&D"); - Object[] avgSum = q.executeResultUnique(Object[].class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_11, avgSum, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Aggregation of Multiple Fields and Expressions. - * - *

    This query averages and sums the salaries of Employees who work in the parameter department. - */ - public void testQuery11d() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Double[] expected = new Double[] {45000., 90000.}; - try (Query q = pm.newQuery(SINGLE_STRING_QUERY_11)) { - q.setParameters("R&D"); - Object[] avgSum = q.executeResultUnique(Object[].class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_11, avgSum, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Aggregation of Multiple Fields and Expressions. - * - *

    This query averages and sums the salaries of Employees who work in the parameter department. - */ - public void testQuery11f() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Double[] expected = new Double[] {45000., 90000.}; - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - StringExpression deptName = q.stringParameter("deptName"); - q.result(false, cand.salary.avg(), cand.salary.sum()) - .filter(cand.department.name.eq(deptName)); - Map paramValues = new HashMap<>(); - paramValues.put("deptName", "R&D"); - q.setParameters(paramValues); - Object[] avgSum = q.executeResultUnique(Object[].class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_11, avgSum, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Aggregation of Multiple fields with Grouping. - * - *

    This query averages and sums the salaries of Employees who work in all departments having - * more than one employee and aggregates by department name. - */ - public void testQuery12a() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Object[] expectedRow = new Object[] {45000., 90000., "R&D"}; - try (Query q = pm.newQuery(FullTimeEmployee.class)) { - q.setResult("avg(salary), sum(salary), department.name"); - q.setGrouping("department.name having count(department.name) > 1"); - List results = (List) q.execute(); - if (results.size() != 1) { - fail( - ASSERTION_FAILED, - "Query result has size " + results.size() + ", expected query result of size 1"); - } - Object[] row = results.get(0); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_12, row, expectedRow); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Aggregation of Multiple fields with Grouping. - * - *

    This query averages and sums the salaries of Employees who work in all departments having - * more than one employee and aggregates by department name. - */ - public void testQuery12b() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Object[] expectedRow = new Object[] {45000., 90000., "R&D"}; - try (Query q = pm.newQuery(FullTimeEmployee.class)) { - q.setResult("avg(salary), sum(salary), department.name"); - q.setGrouping("department.name having count(department.name) > 1"); - List results = q.executeResultList(Object[].class); - if (results.size() != 1) { - fail( - ASSERTION_FAILED, - "Query result has size " + results.size() + ", expected query result of size 1"); - } - Object[] row = results.get(0); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_12, row, expectedRow); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Aggregation of Multiple fields with Grouping. - * - *

    This query averages and sums the salaries of Employees who work in all departments having - * more than one employee and aggregates by department name. - */ - public void testQuery12d() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Object[] expectedRow = new Object[] {45000., 90000., "R&D"}; - try (Query q = pm.newQuery(SINGLE_STRING_QUERY_12)) { - List results = q.executeResultList(Object[].class); - if (results.size() != 1) { - fail( - ASSERTION_FAILED, - "Query result has size " + results.size() + ", expected query result of size 1"); - } - Object[] row = results.get(0); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_12, row, expectedRow); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Aggregation of Multiple fields with Grouping. - * - *

    This query averages and sums the salaries of Employees who work in all departments having - * more than one employee and aggregates by department name. - */ - public void testQuery12e() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Object[] expectedRow = new Object[] {45000., 90000., "R&D"}; - try (Query q = pm.newNamedQuery(FullTimeEmployee.class, "grouping")) { - List results = q.executeResultList(Object[].class); - if (results.size() != 1) { - fail( - ASSERTION_FAILED, - "Query result has size " + results.size() + ", expected query result of size 1"); - } - Object[] row = results.get(0); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_12, row, expectedRow); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Aggregation of Multiple fields with Grouping. - * - *

    This query averages and sums the salaries of Employees who work in all departments having - * more than one employee and aggregates by department name. - */ - public void testQuery12f() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Object[] expectedRow = new Object[] {45000., 90000., "R&D"}; - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - q.result(false, cand.salary.avg(), cand.salary.sum(), cand.department.name) - .groupBy(cand.department.name) - .having(cand.department.name.count().gt(1L)); - List results = q.executeResultList(Object[].class); - if (results.size() != 1) { - fail( - ASSERTION_FAILED, - "Query result has size " + results.size() + ", expected query result of size 1"); - } - Object[] row = results.get(0); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_12, row, expectedRow); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Selection of a Single Instance. - * - *

    This query returns a single instance of Employee. - */ - public void testQuery13a() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Employee expectedEmp = (Employee) getTransientCompanyModelInstance("emp1"); - try (Query q = pm.newQuery(Employee.class, "firstname == empName")) { - q.setUnique(true); - q.declareParameters("String empName"); - Employee emp = (Employee) q.execute("Michael"); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_13, emp, expectedEmp); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Selection of a Single Instance. - * - *

    This query returns a single instance of Employee. - */ - public void testQuery13b() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Employee expectedEmp = (Employee) getTransientCompanyModelInstance("emp1"); - try (Query q = pm.newQuery(Employee.class, "firstname == empName")) { - q.setUnique(true); - q.declareParameters("String empName"); - Map paramValues = new HashMap<>(); - paramValues.put("empName", "Michael"); - q.setNamedParameters(paramValues); - Employee emp = q.executeUnique(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_13, emp, expectedEmp); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Selection of a Single Instance. - * - *

    This query returns a single instance of Employee. - */ - public void testQuery13c() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Employee expectedEmp = (Employee) getTransientCompanyModelInstance("emp1"); - try (Query q = pm.newQuery(Employee.class, "firstname == empName")) { - q.setUnique(true); - q.declareParameters("String empName"); - q.setParameters("Michael"); - Employee emp = q.executeUnique(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_13, emp, expectedEmp); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Selection of a Single Instance. - * - *

    This query returns a single instance of Employee. - */ - public void testQuery13d() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Employee expectedEmp = (Employee) getTransientCompanyModelInstance("emp1"); - try (Query q = pm.newQuery(SINGLE_STRING_QUERY_13)) { - q.setParameters("Michael"); - Employee emp = q.executeResultUnique(Employee.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_13, emp, expectedEmp); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Selection of a Single Instance. - * - *

    This query returns a single instance of Employee. - */ - public void testQuery13f() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Employee expectedEmp = (Employee) getTransientCompanyModelInstance("emp1"); - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(Employee.class)) { - QEmployee cand = QEmployee.candidate(); - StringExpression empName = q.stringParameter("empName"); - q.filter(cand.firstname.eq(empName)); - Map paramValues = new HashMap<>(); - paramValues.put("empName", "Michael"); - q.setParameters(paramValues); - Employee emp = q.executeUnique(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_13, emp, expectedEmp); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Selection of a Single Field. - * - *

    This query returns a single field of a single Employee. - */ - public void testQuery14a() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Double expectedSalary = 40000.; - try (Query q = - pm.newQuery(FullTimeEmployee.class, "firstname == empName")) { - q.setResult("salary"); - q.setResultClass(Double.class); - q.setUnique(true); - q.declareParameters("String empName"); - Double salary = (Double) q.execute("Michael"); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, SINGLE_STRING_QUERY_14, salary, expectedSalary); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Selection of a Single Field. - * - *

    This query returns a single field of a single Employee. - */ - public void testQuery14b() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Double expectedSalary = 40000.; - try (Query q = - pm.newQuery(FullTimeEmployee.class, "firstname == empName")) { - q.setResult("salary"); - q.setResultClass(Double.class); - q.declareParameters("String empName"); - Map paramValues = new HashMap<>(); - paramValues.put("empName", "Michael"); - q.setNamedParameters(paramValues); - Double salary = q.executeResultUnique(Double.class); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, SINGLE_STRING_QUERY_14, salary, expectedSalary); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Selection of a Single Field. - * - *

    This query returns a single field of a single Employee. - */ - public void testQuery14c() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Double expectedSalary = 40000.; - try (Query q = - pm.newQuery(FullTimeEmployee.class, "firstname == empName")) { - q.setResult("salary"); - q.setResultClass(Double.class); - q.declareParameters("String empName"); - q.setParameters("Michael"); - Double salary = q.executeResultUnique(Double.class); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, SINGLE_STRING_QUERY_14, salary, expectedSalary); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Selection of a Single Field. - * - *

    This query returns a single field of a single Employee. - */ - public void testQuery14d() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Double expectedSalary = 40000.; - try (Query q = pm.newQuery(SINGLE_STRING_QUERY_14)) { - q.setParameters("Michael"); - Double salary = q.executeResultUnique(Double.class); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, SINGLE_STRING_QUERY_14, salary, expectedSalary); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Selection of a Single Field. - * - *

    This query returns a single field of a single Employee. - */ - public void testQuery14f() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Double expectedSalary = 40000.; - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - StringExpression empName = q.stringParameter("empName"); - q.result(false, cand.salary).filter(cand.firstname.eq(empName)); - Map paramValues = new HashMap<>(); - paramValues.put("empName", "Michael"); - q.setParameters(paramValues); - Double salary = q.executeResultUnique(Double.class); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, SINGLE_STRING_QUERY_14, salary, expectedSalary); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of "this" to User-defined Result Class with Matching Field. - * - *

    This query selects instances of Employee who make more than the parameter salary and stores - * the result in a user-defined class. Since the default is "distinct this as FullTimeEmployee", - * the field must be named FullTimeEmployee and be of type FullTimeEmployee. - */ - public void testQuery15a() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = testQuery15Helper(); - try (Query q = pm.newQuery(FullTimeEmployee.class, "salary > sal")) { - q.setResultClass(EmpWrapper.class); - q.declareParameters("Double sal"); - List infos = (List) q.execute(30000.); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_15, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of "this" to User-defined Result Class with Matching Field. - * - *

    This query selects instances of Employee who make more than the parameter salary and stores - * the result in a user-defined class. Since the default is "distinct this as FullTimeEmployee", - * the field must be named FullTimeEmployee and be of type FullTimeEmployee. - */ - public void testQuery15b() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = testQuery15Helper(); - try (Query q = pm.newQuery(FullTimeEmployee.class, "salary > sal")) { - q.setResultClass(EmpWrapper.class); - q.declareParameters("Double sal"); - Map paramValues = new HashMap<>(); - paramValues.put("sal", 30000.); - q.setNamedParameters(paramValues); - List infos = q.executeResultList(EmpWrapper.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_15, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of "this" to User-defined Result Class with Matching Field. - * - *

    This query selects instances of Employee who make more than the parameter salary and stores - * the result in a user-defined class. Since the default is "distinct this as FullTimeEmployee", - * the field must be named FullTimeEmployee and be of type FullTimeEmployee. - */ - public void testQuery15c() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = testQuery15Helper(); - try (Query q = pm.newQuery(FullTimeEmployee.class, "salary > sal")) { - q.setResultClass(EmpWrapper.class); - q.declareParameters("Double sal"); - q.setParameters(30000.); - List infos = q.executeResultList(EmpWrapper.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_15, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of "this" to User-defined Result Class with Matching Field. - * - *

    This query selects instances of Employee who make more than the parameter salary and stores - * the result in a user-defined class. Since the default is "distinct this as FullTimeEmployee", - * the field must be named FullTimeEmployee and be of type FullTimeEmployee. - */ - public void testQuery15d() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = testQuery15Helper(); - try (Query q = pm.newQuery(SINGLE_STRING_QUERY_15)) { - q.setParameters(30000.); - List infos = q.executeResultList(EmpWrapper.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_15, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of "this" to User-defined Result Class with Matching Field. - * - *

    This query selects instances of Employee who make more than the parameter salary and stores - * the result in a user-defined class. Since the default is "distinct this as FullTimeEmployee", - * the field must be named FullTimeEmployee and be of type FullTimeEmployee. - */ - public void testQuery15f() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = testQuery15Helper(); - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - NumericExpression sal = q.numericParameter("sal", Double.class); - q.result(true, cand.as("FullTimeEmployee")).filter(cand.salary.gt(sal)); - Map paramValues = new HashMap<>(); - paramValues.put("sal", 30000.); - q.setParameters(paramValues); - List infos = q.executeResultList(EmpWrapper.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_15, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of "this" to User-defined Result Class with Matching Method - * - *

    This query selects instances of FullTimeEmployee who make more than the parameter salary and - * stores the result in a user-defined class. - */ - public void testQuery16a() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = testQuery16Helper(); - try (Query q = pm.newQuery(FullTimeEmployee.class, "salary > sal")) { - q.setResultClass(EmpInfo.class); - q.declareParameters("Double sal"); - List infos = (List) q.execute(30000.); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_16, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of "this" to User-defined Result Class with Matching Method - * - *

    This query selects instances of FullTimeEmployee who make more than the parameter salary and - * stores the result in a user-defined class. - */ - public void testQuery16b() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = testQuery16Helper(); - try (Query q = pm.newQuery(FullTimeEmployee.class, "salary > sal")) { - q.setResultClass(EmpInfo.class); - q.declareParameters("Double sal"); - Map paramValues = new HashMap<>(); - paramValues.put("sal", 30000.); - q.setNamedParameters(paramValues); - List infos = q.executeResultList(EmpInfo.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_16, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of "this" to User-defined Result Class with Matching Method - * - *

    This query selects instances of FullTimeEmployee who make more than the parameter salary and - * stores the result in a user-defined class. - */ - public void testQuery16c() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = testQuery16Helper(); - try (Query q = pm.newQuery(FullTimeEmployee.class, "salary > sal")) { - q.setResultClass(EmpInfo.class); - q.declareParameters("Double sal"); - q.setParameters(30000.); - List infos = q.executeResultList(EmpInfo.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_16, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of "this" to User-defined Result Class with Matching Method - * - *

    This query selects instances of FullTimeEmployee who make more than the parameter salary and - * stores the result in a user-defined class. - */ - public void testQuery16d() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = testQuery16Helper(); - try (Query q = pm.newQuery(SINGLE_STRING_QUERY_16)) { - q.setParameters(30000.); - List infos = q.executeResultList(EmpInfo.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_16, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of "this" to User-defined Result Class with Matching Method - * - *

    This query selects instances of FullTimeEmployee who make more than the parameter salary and - * stores the result in a user-defined class. - */ - public void testQuery16f() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = testQuery16Helper(); - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - NumericExpression sal = q.numericParameter("sal", Double.class); - q.result(true, cand.as("FullTimeEmployee")).filter(cand.salary.gt(sal)); - Map paramValues = new HashMap<>(); - paramValues.put("sal", 30000.); - q.setParameters(paramValues); - List infos = q.executeResultList(EmpInfo.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_16, infos, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of variables. - * - *

    This query returns the names of all Employees of all "Research" departments. - */ - public void testQuery17a() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = Arrays.asList("Michael", "Craig", "Joe"); - try (Query q = pm.newQuery(Department.class)) { - q.declareVariables("org.apache.jdo.tck.pc.company.Employee e"); - q.setFilter("name.startsWith('R&D') && employees.contains(e)"); - q.setResult("e.firstname"); - List names = (List) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_17, names, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of variables. - * - *

    This query returns the names of all Employees of all "Research" departments. - */ - public void testQuery17b() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = Arrays.asList("Michael", "Craig", "Joe"); - try (Query q = pm.newQuery(Department.class)) { - q.declareVariables("org.apache.jdo.tck.pc.company.Employee e"); - q.setFilter("name.startsWith('R&D') && employees.contains(e)"); - q.setResult("e.firstname"); - List names = q.executeResultList(String.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_17, names, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of variables. - * - *

    This query returns the names of all Employees of all "Research" departments. - */ - public void testQuery17d() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = Arrays.asList("Michael", "Craig", "Joe"); - try (Query q = pm.newQuery(SINGLE_STRING_QUERY_17)) { - List names = q.executeResultList(String.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_17, names, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of variables. - * - *

    This query returns the names of all Employees of all "Research" departments. - */ - public void testQuery17e() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = Arrays.asList("Michael", "Craig", "Joe"); - try (Query q = pm.newNamedQuery(Department.class, "projectingVariables")) { - List names = q.executeResultList(String.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_17, names, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Projection of variables. - * - *

    This query returns the names of all Employees of all "Research" departments. - */ - public void testQuery17f() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = Arrays.asList("Michael", "Craig", "Joe"); - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(Department.class)) { - QDepartment cand = QDepartment.candidate(); - QEmployee e = QEmployee.variable("e"); - q.filter(cand.name.startsWith("R&D").and(cand.employees.contains(e))) - .result(false, e.firstname); - List names = q.executeResultList(String.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_17, names, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Non-correlated subquery - * - *

    This query returns names of employees who work more than the average of all employees. - */ - public void testQuery18a() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = Arrays.asList("Michael", "Craig"); - try (Query q = pm.newQuery(Employee.class)) { - Query subq = pm.newQuery(Employee.class); - subq.setResult("avg(weeklyhours)"); - q.setFilter("this.weeklyhours > average_hours"); - q.setResult("this.firstname"); - q.addSubquery(subq, "double average_hours", null); - List names = (List) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_18, names, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Non-correlated subquery - * - *

    This query returns names of employees who work more than the average of all employees. - */ - public void testQuery18b() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = Arrays.asList("Michael", "Craig"); - try (Query q = pm.newQuery(Employee.class)) { - Query subq = pm.newQuery(Employee.class); - subq.setResult("avg(weeklyhours)"); - q.setFilter("this.weeklyhours > average_hours"); - q.setResult("this.firstname"); - q.addSubquery(subq, "double average_hours", null); - List names = q.executeResultList(String.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_18, names, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Non-correlated subquery - * - *

    This query returns names of employees who work more than the average of all employees. - */ - public void testQuery18d() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = Arrays.asList("Michael", "Craig"); - try (Query q = pm.newQuery(SINGLE_STRING_QUERY_18)) { - List names = q.executeResultList(String.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_18, names, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Non-correlated subquery - * - *

    This query returns names of employees who work more than the average of all employees. - */ - public void testQuery18f() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = Arrays.asList("Michael", "Craig"); - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(Employee.class)) { - QEmployee cand = QEmployee.candidate(); - JDOQLTypedSubquery subquery = q.subquery("e"); - QEmployee candsub = QEmployee.candidate("e"); - q.result(false, cand.firstname) - .filter(cand.weeklyhours.gt(subquery.selectUnique(candsub.weeklyhours.avg()))); - List names = q.executeResultList(String.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_18, names, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Correlated subquery. - * - *

    This query returns names of employees who work more than the average of employees in the - * same department having the same manager. The candidate collection of the subquery is the - * collection of employees in the department of the candidate employee and the parameter passed to - * the subquery is the manager of the candidate employee. - */ - public void testQuery19a() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = Arrays.asList("Michael"); - try (Query q = pm.newQuery(Employee.class)) { - Query subq = pm.newQuery(Employee.class); - subq.setFilter("this.manager == :manager"); - subq.setResult("avg(weeklyhours)"); - q.setFilter("this.weeklyhours > average_hours"); - q.setResult("firstname"); - q.addSubquery(subq, "double average_hours", "this.department.employees", "this.manager"); - List names = (List) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_19, names, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Correlated subquery. - * - *

    This query returns names of employees who work more than the average of employees in the - * same department having the same manager. The candidate collection of the subquery is the - * collection of employees in the department of the candidate employee and the parameter passed to - * the subquery is the manager of the candidate employee. - */ - public void testQuery19b() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = Arrays.asList("Michael"); - try (Query q = pm.newQuery(Employee.class)) { - Query subq = pm.newQuery(Employee.class); - subq.setFilter("this.manager == :manager"); - subq.setResult("avg(weeklyhours)"); - q.setFilter("this.weeklyhours > average_hours"); - q.setResult("firstname"); - q.addSubquery(subq, "double average_hours", "this.department.employees", "this.manager"); - List names = q.executeResultList(String.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_19, names, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Correlated subquery. - * - *

    This query returns names of employees who work more than the average of employees in the - * same department having the same manager. The candidate collection of the subquery is the - * collection of employees in the department of the candidate employee and the parameter passed to - * the subquery is the manager of the candidate employee. - */ - public void testQuery19d() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = Arrays.asList("Michael"); - try (Query q = pm.newQuery(SINGLE_STRING_QUERY_19)) { - List names = q.executeResultList(String.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_19, names, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Correlated subquery. - * - *

    This query returns names of employees who work more than the average of employees in the - * same department having the same manager. The candidate collection of the subquery is the - * collection of employees in the department of the candidate employee and the parameter passed to - * the subquery is the manager of the candidate employee. - */ - public void testQuery19f() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = Arrays.asList("Michael"); - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(Employee.class)) { - QEmployee cand = QEmployee.candidate(); - JDOQLTypedSubquery subquery = - q.subquery(cand.department.employees, Employee.class, "e"); - QEmployee candsub = QEmployee.candidate("e"); - subquery.filter(candsub.manager.eq(cand.manager)); - q.result(false, cand.firstname) - .filter(cand.weeklyhours.gt(subquery.selectUnique(candsub.weeklyhours.avg()))); - List names = q.executeResultList(String.class); - checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_19, names, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - /** - * Deleting Multiple Instances. - * - *

    This query deletes all Employees who make more than the parameter salary. - */ - public void testQuery20() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Query empQuery = pm.newQuery(FullTimeEmployee.class, "personid == 5"); - empQuery.setUnique(true); - FullTimeEmployee emp5 = empQuery.executeUnique(); - Object emp5Oid = pm.getObjectId(emp5); - Query q = pm.newQuery(FullTimeEmployee.class, "salary > sal"); - q.declareParameters("Double sal"); - q.deletePersistentAll(30000.); - tx.commit(); - - tx.begin(); - Query allQuery = pm.newQuery(FullTimeEmployee.class); - List allFTE = allQuery.executeList(); - if (!allFTE.isEmpty()) { - fail( - ASSERTION_FAILED, - "All FullTimeEmployee instances should have been deleted," - + " there are still " - + allFTE.size() - + " instances left."); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } - } - } - - private List testQuery08Helper() { - Info info1 = new Info(); - info1.firstname = "Michael"; - info1.salary = 40000.; - info1.reportsTo = (Employee) getTransientCompanyModelInstance("emp2"); - Info info2 = new Info(); - info2.firstname = "Craig"; - info2.salary = 50000.; - info2.reportsTo = null; - return Arrays.asList(info1, info2); - } - - private List testQuery15Helper() { - EmpWrapper wrapper1 = new EmpWrapper(); - wrapper1.FullTimeEmployee = (FullTimeEmployee) getTransientCompanyModelInstance("emp1"); - EmpWrapper wrapper2 = new EmpWrapper(); - wrapper2.FullTimeEmployee = (FullTimeEmployee) getTransientCompanyModelInstance("emp2"); - EmpWrapper wrapper3 = new EmpWrapper(); - wrapper3.FullTimeEmployee = (FullTimeEmployee) getTransientCompanyModelInstance("emp5"); - return Arrays.asList(wrapper1, wrapper2, wrapper3); - } - - private List testQuery16Helper() { - EmpInfo info1 = new EmpInfo(); - info1.setFullTimeEmployee((FullTimeEmployee) getTransientCompanyModelInstance("emp1")); - EmpInfo info2 = new EmpInfo(); - info2.setFullTimeEmployee((FullTimeEmployee) getTransientCompanyModelInstance("emp2")); - EmpInfo info3 = new EmpInfo(); - info3.setFullTimeEmployee((FullTimeEmployee) getTransientCompanyModelInstance("emp5")); - return Arrays.asList(info1, info2, info3); - } - - public static class Info { - public String firstname; - public Double salary; - public Person reportsTo; - - public Info() {} - - public Info(String firstname, Double salary, Person reportsTo) { - this.firstname = firstname; - this.salary = salary; - this.reportsTo = reportsTo; - } - - public boolean equals(Object obj) { - if (!(obj instanceof Info)) { - return false; - } - Info other = (Info) obj; - if (!EqualityHelper.equals(firstname, other.firstname)) { - return false; - } - if (!EqualityHelper.equals(salary, other.salary)) { - return false; - } - if (!EqualityHelper.equals(reportsTo, other.reportsTo)) { - return false; - } - return true; - } - - public int hashCode() { - int hashCode = 0; - hashCode += firstname == null ? 0 : firstname.hashCode(); - hashCode += salary == null ? 0 : salary.hashCode(); - hashCode += reportsTo == null ? 0 : reportsTo.hashCode(); - return hashCode; - } - - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("Info("); - builder.append("firstname:").append(firstname); - builder.append(", salary:").append(salary); - builder.append(", reportsTo:").append(reportsTo == null ? "null" : reportsTo.getFirstname()); - builder.append(")"); - return builder.toString(); - } - } - - public static class EmpWrapper { - public FullTimeEmployee FullTimeEmployee; - - public EmpWrapper() {} - // Need constructor to prevent - // java.lang.NullPointerException - // at - // org.datanucleus.query.QueryUtils.createResultObjectUsingDefaultConstructorAndSetters(QueryUtils.java:293) - public EmpWrapper(FullTimeEmployee FullTimeEmployee) { - this.FullTimeEmployee = FullTimeEmployee; - } - - public boolean equals(Object obj) { - if (!(obj instanceof EmpWrapper)) { - return false; - } - EmpWrapper other = (EmpWrapper) obj; - if (!EqualityHelper.equals(FullTimeEmployee, other.FullTimeEmployee)) { - return false; - } - return true; - } - - public int hashCode() { - int hashCode = 0; - hashCode += FullTimeEmployee == null ? 0 : FullTimeEmployee.hashCode(); - return hashCode; - } - - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("EmpWrapper("); - builder - .append("FullTimeEmployee:") - .append(FullTimeEmployee == null ? "null" : FullTimeEmployee.getFirstname()); - builder.append(")"); - return builder.toString(); - } - } - - public static class EmpInfo { - private FullTimeEmployee worker; - - public EmpInfo() {} - // Need constructor to prevent - // java.lang.NullPointerException - // at - // org.datanucleus.query.QueryUtils.createResultObjectUsingDefaultConstructorAndSetters(QueryUtils.java:293) - public EmpInfo(FullTimeEmployee worker) { - this.worker = worker; - } - - public FullTimeEmployee getWorker() { - return worker; - } - - public void setFullTimeEmployee(FullTimeEmployee e) { - worker = e; - } - - public boolean equals(Object obj) { - if (!(obj instanceof EmpInfo)) { - return false; - } - EmpInfo other = (EmpInfo) obj; - if (!EqualityHelper.equals(worker, other.worker)) { - return false; - } - return true; - } - - public int hashCode() { - int hashCode = 0; - hashCode += worker == null ? 0 : worker.hashCode(); - return hashCode; - } - - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("EmpInfo("); - builder.append("worker:").append(worker == null ? "null" : worker.getFirstname()); - builder.append(")"); - return builder.toString(); - } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } - - /** - * Returns the name of the company test data resource. - * - * @return name of the company test data resource. - */ - protected String getCompanyTestDataResource() { - return SAMPLE_QUERIES_TEST_COMPANY_TESTDATA; - } + /** */ + private static final String ASSERTION_FAILED = "Assertion (SampleQueries) failed: "; + + /** */ + private static final String SAMPLE_QUERIES_TEST_COMPANY_TESTDATA = + "org/apache/jdo/tck/pc/company/companyForSampleQueriesTest.xml"; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SampleQueries.class); + } + + private static final String SINGLE_STRING_QUERY_01 = + "select from org.apache.jdo.tck.pc.company.FullTimeEmployee where salary > 30000"; + + private static final String SINGLE_STRING_QUERY_02 = + "select from org.apache.jdo.tck.pc.company.FullTimeEmployee " + + "where salary > 30000 order by salary ascending"; + + private static final String SINGLE_STRING_QUERY_03 = + "select from org.apache.jdo.tck.pc.company.FullTimeEmployee " + + "where salary > :sal && firstname.startsWith(:begin)"; + + private static final String SINGLE_STRING_QUERY_04 = + "select from org.apache.jdo.tck.pc.company.Employee where department.name == :dep"; + + private static final String SINGLE_STRING_QUERY_05 = + "select from org.apache.jdo.tck.pc.company.Department " + + "where employees.contains(emp) && emp.weeklyhours > :hours variables Employee emp"; + + private static final String SINGLE_STRING_QUERY_06 = + "select from org.apache.jdo.tck.pc.company.Department where :depts.contains(name)"; + + private static final String SINGLE_STRING_QUERY_07 = + "select firstname from org.apache.jdo.tck.pc.company.Employee where department.name == :deptName"; + + private static final String SINGLE_STRING_QUERY_08 = + "select firstname, salary, manager as reportsTo into org.apache.jdo.tck.query.api.SampleQueries$Info " + + "from org.apache.jdo.tck.pc.company.FullTimeEmployee where department.name == :deptName"; + + private static final String SINGLE_STRING_QUERY_09 = + "select new org.apache.jdo.tck.query.api.SampleQueries$Info (firstname, salary, manager) " + + "from org.apache.jdo.tck.pc.company.FullTimeEmployee where department.name == :deptName"; + + private static final String SINGLE_STRING_QUERY_10 = + "select avg(salary) from org.apache.jdo.tck.pc.company.FullTimeEmployee " + + "where department.name == :deptName"; + + private static final String SINGLE_STRING_QUERY_11 = + "select avg(salary), sum(salary) from org.apache.jdo.tck.pc.company.FullTimeEmployee " + + "where department.name == :deptName"; + + private static final String SINGLE_STRING_QUERY_12 = + "select avg(salary), sum(salary), department.name " + + "from org.apache.jdo.tck.pc.company.FullTimeEmployee " + + "group by department.name having count(department.name) > 1"; + + private static final String SINGLE_STRING_QUERY_13 = + "select unique this from org.apache.jdo.tck.pc.company.Employee where firstname == :empName"; + + private static final String SINGLE_STRING_QUERY_14 = + "select unique salary from org.apache.jdo.tck.pc.company.FullTimeEmployee " + + "where firstname == :empName"; + + private static final String SINGLE_STRING_QUERY_15 = + "select into org.apache.jdo.tck.query.api.SampleQueries$EmpWrapper " + + "from org.apache.jdo.tck.pc.company.FullTimeEmployee where salary > :sal"; + + private static final String SINGLE_STRING_QUERY_16 = + "select into org.apache.jdo.tck.query.api.SampleQueries$EmpInfo " + + "from org.apache.jdo.tck.pc.company.FullTimeEmployee where salary > :sal"; + + private static final String SINGLE_STRING_QUERY_17 = + "select e.firstname from org.apache.jdo.tck.pc.company.Department " + + "where name.startsWith('R&D') && employees.contains(e) " + + "variables org.apache.jdo.tck.pc.company.Employee e"; + + private static final String SINGLE_STRING_QUERY_18 = + "select firstname from org.apache.jdo.tck.pc.company.Employee " + + "where this.weeklyhours > (select avg(e.weeklyhours) from org.apache.jdo.tck.pc.company.Employee e)"; + + private static final String SINGLE_STRING_QUERY_19 = + "select firstname from org.apache.jdo.tck.pc.company.Employee " + + "where this.weeklyhours > " + + " (select AVG(e.weeklyhours) from this.department.employees e where e.manager == this.manager)"; + + /** + * Basic query. + * + * This query selects all Employee instances from the candidate collection where + * the salary is greater than the constant 30000. + * Note that the float value for salary is unwrapped for the comparison with the + * literal int value, which is promoted to float using numeric promotion. + * If the value for the salary field in a candidate instance isnull, then it cannot + * be unwrapped for the comparison, and the candidate instance is rejected. + */ + public void testQuery01a() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = + getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp2", "emp5"}); + try (Query q = pm.newQuery(FullTimeEmployee.class, "salary > 30000")) { + List emps = (List)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_01, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Basic query. + * + * This query selects all Employee instances from the candidate collection where + * the salary is greater than the constant 30000. + * Note that the float value for salary is unwrapped for the comparison with the + * literal int value, which is promoted to float using numeric promotion. + * If the value for the salary field in a candidate instance isnull, then it cannot + * be unwrapped for the comparison, and the candidate instance is rejected. + */ + public void testQuery01b() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = + getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp5"}); + try (Query q = pm.newQuery(FullTimeEmployee.class, "salary > 30000")) { + List emps = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_01, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Basic query. + * + * This query selects all Employee instances from the candidate collection where + * the salary is greater than the constant 30000. + * Note that the float value for salary is unwrapped for the comparison with the + * literal int value, which is promoted to float using numeric promotion. + * If the value for the salary field in a candidate instance isnull, then it cannot + * be unwrapped for the comparison, and the candidate instance is rejected. + */ + public void testQuery01d() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = + getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp5"}); + try (Query q = pm.newQuery(SINGLE_STRING_QUERY_01)) { + List emps = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_01, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Basic query. + * + * This query selects all Employee instances from the candidate collection where + * the salary is greater than the constant 30000. + * Note that the float value for salary is unwrapped for the comparison with the + * literal int value, which is promoted to float using numeric promotion. + * If the value for the salary field in a candidate instance isnull, then it cannot + * be unwrapped for the comparison, and the candidate instance is rejected. + */ + public void testQuery01f() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = + getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp5"}); + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + q.filter(cand.salary.gt(30000.)); + List emps = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_01, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Basic query with ordering. + * + * This query selects all Employee instances from the candidate collection where the salary + * is greater than the constant 30000, and returns a Collection ordered based on employee salary. + */ + public void testQuery02a() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = + getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp5", "emp2"}); + try (Query q = pm.newQuery(FullTimeEmployee.class, "salary > 30000")) { + q.setOrdering ("salary ascending"); + List emps = (List)q.execute(); + checkQueryResultWithOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_02, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Basic query with ordering. + * + * This query selects all Employee instances from the candidate collection where the salary + * is greater than the constant 30000, and returns a Collection ordered based on employee salary. + */ + public void testQuery02b() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = + getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp5", "emp2"}); + try (Query q = pm.newQuery(FullTimeEmployee.class, "salary > 30000")) { + q.setOrdering ("salary ascending"); + List emps = q.executeList(); + checkQueryResultWithOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_02, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Basic query with ordering. + * + * This query selects all Employee instances from the candidate collection where the salary + * is greater than the constant 30000, and returns a Collection ordered based on employee salary. + */ + public void testQuery02d() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = + getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp5", "emp2"}); + try (Query q = pm.newQuery(SINGLE_STRING_QUERY_02)) { + List emps = q.executeList(); + checkQueryResultWithOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_02, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Basic query with ordering. + * + * This query selects all Employee instances from the candidate collection where the salary + * is greater than the constant 30000, and returns a Collection ordered based on employee salary. + */ + public void testQuery02f() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = + getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp5", "emp2"}); + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + q.filter(cand.salary.gt(30000.)) + .orderBy(cand.salary.asc()); + List emps = q.executeList(); + checkQueryResultWithOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_02, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Parameter passing. + * + * This query selects all Employee instances from the candidate collection where the salary + * is greater than the value passed as a parameter and the name starts with the value passed + * as a second parameter. + * If the value for the salary field in a candidate instance is null, then it cannot be + * unwrapped for the comparison, and the candidate instance is rejected. + */ + public void testQuery03a() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); + try (Query q = + pm.newQuery(FullTimeEmployee.class,"salary > sal && firstname.startsWith(begin)")) { + q.declareParameters("Double sal, String begin"); + List emps = (List)q.execute(30000., "M"); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_03, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Parameter passing. + * + * This query selects all Employee instances from the candidate collection where the salary + * is greater than the value passed as a parameter and the name starts with the value passed + * as a second parameter. + * If the value for the salary field in a candidate instance is null, then it cannot be + * unwrapped for the comparison, and the candidate instance is rejected. + */ + public void testQuery03b() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); + try (Query q = + pm.newQuery(FullTimeEmployee.class,"salary > sal && firstname.startsWith(begin)")) { + q.declareParameters("Double sal, String begin"); + Map paramValues = new HashMap<>(); + paramValues.put("sal", 30000.); + paramValues.put("begin", "M"); + q.setNamedParameters(paramValues); + List emps = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_03, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Parameter passing. + * + * This query selects all Employee instances from the candidate collection where the salary + * is greater than the value passed as a parameter and the name starts with the value passed + * as a second parameter. + * If the value for the salary field in a candidate instance is null, then it cannot be + * unwrapped for the comparison, and the candidate instance is rejected. + */ + public void testQuery03c() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); + try (Query q = + pm.newQuery(FullTimeEmployee.class,"salary > sal && firstname.startsWith(begin)")) { + q.declareParameters("Double sal, String begin"); + q.setParameters(30000., "M"); + List emps = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_03, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Parameter passing. + * + * This query selects all Employee instances from the candidate collection where the salary + * is greater than the value passed as a parameter and the name starts with the value passed + * as a second parameter. + * If the value for the salary field in a candidate instance is null, then it cannot be + * unwrapped for the comparison, and the candidate instance is rejected. + */ + public void testQuery03d() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); + try (Query q = pm.newQuery(SINGLE_STRING_QUERY_03)) { + List emps = (List)q.execute(30000., "M"); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_03, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Parameter passing. + * + * This query selects all Employee instances from the candidate collection where the salary + * is greater than the value passed as a parameter and the name starts with the value passed + * as a second parameter. + * If the value for the salary field in a candidate instance is null, then it cannot be + * unwrapped for the comparison, and the candidate instance is rejected. + */ + public void testQuery03f() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + NumericExpression sal = q.numericParameter("sal", Double.class); + StringExpression begin = q.stringParameter("begin"); + q.filter(cand.salary.gt(sal).and(cand.firstname.startsWith(begin))); + Map paramValues = new HashMap<>(); + paramValues.put("sal", 30000.); + paramValues.put("begin", "M"); + q.setParameters(paramValues); + List emps = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_03, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Navigation through single-valued field. + * + * This query selects all Employee instances from the candidate collection where the value + * of the name field in the Department instance associated with the Employee instance + * is equal to the value passed as a parameter. + * If the value for the dept field in a candidate instance is null, then it cannot be + * navigated for the comparison, and the candidate instance is rejected. + */ + public void testQuery04a() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3"}); + try (Query q = pm.newQuery(Employee.class, "department.name == dep")) { + q.declareParameters("String dep"); + List emps = (List)q.execute ("R&D"); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_04, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Navigation through single-valued field. + * + * This query selects all Employee instances from the candidate collection where the value + * of the name field in the Department instance associated with the Employee instance + * is equal to the value passed as a parameter. + * If the value for the dept field in a candidate instance is null, then it cannot be + * navigated for the comparison, and the candidate instance is rejected. + */ + public void testQuery04b() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3"}); + try (Query q = pm.newQuery (Employee.class, "department.name == dep")) { + q.declareParameters ("String dep"); + Map paramValues = new HashMap<>(); + paramValues.put("dep", "R&D"); + q.setNamedParameters(paramValues); + List emps = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_04, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Navigation through single-valued field. + * + * This query selects all Employee instances from the candidate collection where the value + * of the name field in the Department instance associated with the Employee instance + * is equal to the value passed as a parameter. + * If the value for the dept field in a candidate instance is null, then it cannot be + * navigated for the comparison, and the candidate instance is rejected. + */ + public void testQuery04c() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3"}); + try (Query q = pm.newQuery (Employee.class, "department.name == dep")) { + q.declareParameters ("String dep"); + q.setParameters("R&D"); + List emps = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_04, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Navigation through single-valued field. + * + * This query selects all Employee instances from the candidate collection where the value + * of the name field in the Department instance associated with the Employee instance + * is equal to the value passed as a parameter. + * If the value for the dept field in a candidate instance is null, then it cannot be + * navigated for the comparison, and the candidate instance is rejected. + */ + public void testQuery04d() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3"}); + try (Query q = pm.newQuery (SINGLE_STRING_QUERY_04)) { + Map paramValues = new HashMap<>(); + paramValues.put("dep", "R&D"); + q.setNamedParameters(paramValues); + List emps = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_04, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Navigation through single-valued field. + * + * This query selects all Employee instances from the candidate collection where the value + * of the name field in the Department instance associated with the Employee instance + * is equal to the value passed as a parameter. + * If the value for the dept field in a candidate instance is null, then it cannot be + * navigated for the comparison, and the candidate instance is rejected. + */ + public void testQuery04f() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3"}); + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(Employee.class)) { + QEmployee cand = QEmployee.candidate(); + StringExpression dep = q.stringParameter("dep"); + q.filter(cand.department.name.eq(dep)); + Map paramValues = new HashMap<>(); + paramValues.put("dep", "R&D"); + q.setParameters(paramValues); + List emps = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_04, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Navigation through multi-valued field. + * + * This query selects all Department instances from the candidate collection where + * the collection of Employee instances contains at least one Employee instance + * having a salary greater than the value passed as a parameter. + */ + public void testQuery05a() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); + try (Query q = + pm.newQuery(Department.class, "employees.contains (emp) && emp.weeklyhours > hours")) { + q.declareVariables("Employee emp"); + q.declareParameters("double hours"); + List deps = (List)q.execute (30.); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_05, deps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Navigation through multi-valued field. + * + * This query selects all Department instances from the candidate collection where + * the collection of Employee instances contains at least one Employee instance + * having a salary greater than the value passed as a parameter. + */ + public void testQuery05b() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); + try (Query q = + pm.newQuery(Department.class, "employees.contains (emp) && emp.weeklyhours > hours")) { + q.declareVariables("Employee emp"); + q.declareParameters("double hours"); + Map paramValues = new HashMap<>(); + paramValues.put("hours", 30.); + q.setNamedParameters(paramValues); + List deps = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_05, deps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Navigation through multi-valued field. + * + * This query selects all Department instances from the candidate collection where + * the collection of Employee instances contains at least one Employee instance + * having a salary greater than the value passed as a parameter. + */ + public void testQuery05c() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); + try (Query q = + pm.newQuery(Department.class, "employees.contains (emp) && emp.weeklyhours > hours")) { + q.declareVariables("Employee emp"); + q.declareParameters("double hours"); + q.setParameters(30.); + List deps = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_05, deps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Navigation through multi-valued field. + * + * This query selects all Department instances from the candidate collection where + * the collection of Employee instances contains at least one Employee instance + * having a salary greater than the value passed as a parameter. + */ + public void testQuery05d() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); + try (Query q = pm.newQuery(SINGLE_STRING_QUERY_05)) { + List deps = (List)q.execute (30.); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_05, deps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Navigation through multi-valued field. + * + * This query selects all Department instances from the candidate collection where + * the collection of Employee instances contains at least one Employee instance + * having a salary greater than the value passed as a parameter. + */ + public void testQuery05f() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(Department.class)) { + QDepartment cand = QDepartment.candidate(); + QEmployee emp = QEmployee.variable("emp"); + NumericExpression hours = q.numericParameter("hours", double.class); + q.filter(cand.employees.contains(emp).and(emp.weeklyhours.gt(hours))); + Map paramValues = new HashMap<>(); + paramValues.put("hours", 30.); + q.setParameters(paramValues); + List deps = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_05, deps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Membership in a collection. + * + * This query selects all Department instances where the name field is contained in + * a parameter collection, which in this example consists of three department names. + */ + public void testQuery06a() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = + getTransientCompanyModelInstancesAsList(new String[] {"dept1", "dept2", "dept3"}); + try (Query q = pm.newQuery(Department.class, "depts.contains(name)")) { + q.declareParameters("java.util.Collection depts"); + List deptNames = Arrays.asList("R&D", "Sales", "Marketing"); + List result = (List)q.execute(deptNames); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_06, result, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Membership in a collection. + * + * This query selects all Department instances where the name field is contained in + * a parameter collection, which in this example consists of three department names. + */ + public void testQuery06b() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = + getTransientCompanyModelInstancesAsList(new String[] {"dept1", "dept2", "dept3"}); + try (Query q = pm.newQuery(Department.class, "depts.contains(name)")) { + q.declareParameters("java.util.Collection depts"); + Map paramValues = new HashMap<>(); + paramValues.put("depts", Arrays.asList("R&D", "Sales", "Marketing")); + q.setNamedParameters(paramValues); + List result = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_06, result, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Membership in a collection. + * + * This query selects all Department instances where the name field is contained in + * a parameter collection, which in this example consists of three department names. + */ + public void testQuery06c() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = + getTransientCompanyModelInstancesAsList(new String[] {"dept1", "dept2", "dept3"}); + try (Query q = pm.newQuery(Department.class, "depts.contains(name)")) { + q.declareParameters("java.util.Collection depts"); + q.setParameters(Arrays.asList("R&D", "Sales", "Marketing")); + List result = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_06, result, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Membership in a collection. + * + * This query selects all Department instances where the name field is contained in + * a parameter collection, which in this example consists of three department names. + */ + public void testQuery06d() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = + getTransientCompanyModelInstancesAsList(new String[] {"dept1", "dept2", "dept3"}); + try (Query q = pm.newQuery(SINGLE_STRING_QUERY_06)) { + Map paramValues = new HashMap<>(); + paramValues.put("depts", Arrays.asList("R&D", "Sales", "Marketing")); + q.setNamedParameters(paramValues); + List result = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_06, result, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Membership in a collection. + * + * This query selects all Department instances where the name field is contained in + * a parameter collection, which in this example consists of three department names. + */ + public void testQuery06f() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = + getTransientCompanyModelInstancesAsList(new String[] {"dept1", "dept2", "dept3"}); + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(Department.class)) { + QDepartment cand = QDepartment.candidate(); + CollectionExpression, String> depts = + q.collectionParameter("depts", String.class); + q.filter(depts.contains(cand.name)); + Map paramValues = new HashMap<>(); + paramValues.put("depts", Arrays.asList("R&D", "Sales", "Marketing")); + q.setParameters(paramValues); + List result = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_06, result, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of a Single Field. + * + * This query selects names of all Employees who work in the parameter department. + */ + public void testQuery07a() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList("Joe", "Craig", "Michael"); + try (Query q = pm.newQuery(Employee.class, "department.name == deptName")) { + q.setResult("firstname"); + q.declareParameters("String deptName"); + List names = (List)q.execute("R&D"); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_07, names, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of a Single Field. + * + * This query selects names of all Employees who work in the parameter department. + */ + public void testQuery07b() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList("Joe", "Craig", "Michael"); + try (Query q = pm.newQuery(Employee.class, "department.name == deptName")) { + q.setResult("firstname"); + q.declareParameters("String deptName"); + Map paramValues = new HashMap<>(); + paramValues.put("deptName", "R&D"); + q.setNamedParameters(paramValues); + List names = q.executeResultList(String.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_07, names, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of a Single Field. + * + * This query selects names of all Employees who work in the parameter department. + */ + public void testQuery07c() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList("Joe", "Craig", "Michael"); + try (Query q = pm.newQuery(Employee.class, "department.name == deptName")) { + q.setResult("firstname"); + q.declareParameters("String deptName"); + q.setParameters("R&D"); + List names = q.executeResultList(String.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_07, names, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of a Single Field. + * + * This query selects names of all Employees who work in the parameter department. + */ + public void testQuery07d() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList("Joe", "Craig", "Michael"); + try (Query q = pm.newQuery(SINGLE_STRING_QUERY_07)) { + Map paramValues = new HashMap<>(); + paramValues.put("deptName", "R&D"); + q.setNamedParameters(paramValues); + List names = q.executeResultList(String.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_07, names, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of a Single Field. + * + * This query selects names of all Employees who work in the parameter department. + */ + public void testQuery07f() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList("Joe", "Craig", "Michael"); + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(Employee.class)) { + QEmployee cand = QEmployee.candidate(); + StringExpression deptName = q.stringParameter("deptName"); + q.filter(cand.department.name.eq(deptName)) + .result(false, cand.firstname); + Map paramValues = new HashMap<>(); + paramValues.put("deptName", "R&D"); + q.setParameters(paramValues); + List names = q.executeResultList(String.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_07, names, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + + + /** + * Projection of Multiple Fields and Expressions. + * + * This query selects names, salaries, and bosses of Employees who work in the parameter department. + */ + public void testQuery08a() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = testQuery08Helper(); + try (Query q = pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { + q.setResult("firstname, salary, manager as reportsTo"); + q.setResultClass(Info.class); + q.declareParameters("String deptName"); + List infos = (List) q.execute("R&D"); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_08, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of Multiple Fields and Expressions. + * + * This query selects names, salaries, and bosses of Employees who work in the parameter department. + */ + public void testQuery08b() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = testQuery08Helper(); + try (Query q = + pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { + q.setResult("firstname, salary, manager as reportsTo"); + q.setResultClass(Info.class); + q.declareParameters("String deptName"); + Map paramValues = new HashMap<>(); + paramValues.put("deptName", "R&D"); + q.setNamedParameters(paramValues); + List infos = q.executeResultList(Info.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_08, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of Multiple Fields and Expressions. + * + * This query selects names, salaries, and bosses of Employees who work in the parameter department. + */ + public void testQuery08c() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = testQuery08Helper(); + try (Query q = + pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { + q.setResult("firstname, salary, manager as reportsTo"); + q.setResultClass(Info.class); + q.declareParameters("String deptName"); + q.setParameters("R&D"); + List infos = q.executeResultList(Info.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_08, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of Multiple Fields and Expressions. + * + * This query selects names, salaries, and bosses of Employees who work in the parameter department. + */ + public void testQuery08d() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = testQuery08Helper(); + try (Query q = pm.newQuery(SINGLE_STRING_QUERY_08)) { + q.setParameters("R&D"); + List infos = q.executeResultList(Info.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_08, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of Multiple Fields and Expressions. + * + * This query selects names, salaries, and bosses of Employees who work in the parameter department. + */ + public void testQuery08f() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = testQuery08Helper(); + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + StringExpression deptName = q.stringParameter("deptName"); + q.result(false, cand.firstname, cand.salary, cand.manager.as("reportsTo")) + .filter(cand.department.name.eq(deptName)); + Map paramValues = new HashMap<>(); + paramValues.put("deptName", "R&D"); + q.setParameters(paramValues); + List infos = q.executeResultList(Info.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_08, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of Multiple Fields and Expressions into a Constructed instance. + * + * This query selects names, salaries, and bosses of Employees who work in the parameter department, + * and uses the constructor for the result class. + */ + public void testQuery09a() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList( + new Info("Michael", 40000., (Employee)getTransientCompanyModelInstance("emp2")), + new Info("Craig", 50000., null) + ); + try (Query q = + pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { + q.setResult("new org.apache.jdo.tck.query.api.SampleQueries$Info(firstname, salary, manager)"); + q.declareParameters("String deptName"); + List infos = (List)q.execute("R&D"); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_09, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of Multiple Fields and Expressions into a Constructed instance. + * + * This query selects names, salaries, and bosses of Employees who work in the parameter department, + * and uses the constructor for the result class. + */ + public void testQuery09b() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList( + new Info("Michael", 40000., (Employee)getTransientCompanyModelInstance("emp2")), + new Info("Craig", 50000., null) + ); + try (Query q = + pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { + q.setResult("new org.apache.jdo.tck.query.api.SampleQueries$Info(firstname, salary, manager)"); + q.declareParameters("String deptName"); + Map paramValues = new HashMap<>(); + paramValues.put("deptName", "R&D"); + q.setNamedParameters(paramValues); + List infos = q.executeResultList(Info.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_09, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of Multiple Fields and Expressions into a Constructed instance. + * + * This query selects names, salaries, and bosses of Employees who work in the parameter department, + * and uses the constructor for the result class. + */ + public void testQuery09c() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList( + new Info("Michael", 40000., (Employee)getTransientCompanyModelInstance("emp2")), + new Info("Craig", 50000., null) + ); + try (Query q = + pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { + q.setResult("new org.apache.jdo.tck.query.api.SampleQueries$Info(firstname, salary, manager)"); + q.declareParameters("String deptName"); + q.setParameters("R&D"); + List infos = q.executeResultList(Info.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_09, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of Multiple Fields and Expressions into a Constructed instance. + * + * This query selects names, salaries, and bosses of Employees who work in the parameter department, + * and uses the constructor for the result class. + */ + public void testQuery09d() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList( + new Info("Michael", 40000., (Employee)getTransientCompanyModelInstance("emp2")), + new Info("Craig", 50000., null) + ); + try (Query q = pm.newQuery(SINGLE_STRING_QUERY_09)) { + q.setParameters("R&D"); + List infos = q.executeResultList(Info.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_09, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of Multiple Fields and Expressions into a Constructed instance. + * + * This query selects names, salaries, and bosses of Employees who work in the parameter department, + * and uses the constructor for the result class. + */ + public void testQuery09e() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList( + new Info("Michael", 40000., (Employee)getTransientCompanyModelInstance("emp2")), + new Info("Craig", 50000., null) + ); + try (Query q = pm.newNamedQuery(FullTimeEmployee.class, "constructor")) { + q.setParameters("R&D"); + List infos = q.executeResultList(Info.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_09, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of Multiple Fields and Expressions into a Constructed instance. + * + * This query selects names, salaries, and bosses of Employees who work in the parameter department, + * and uses the constructor for the result class. + */ + public void testQuery09f() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList( + new Info("Michael", 40000., (Employee)getTransientCompanyModelInstance("emp2")), + new Info("Craig", 50000., null) + ); + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + StringExpression deptName = q.stringParameter("deptName"); + q.result(false, cand.firstname, cand.salary, cand.manager) + .filter(cand.department.name.eq(deptName)); + Map paramValues = new HashMap<>(); + paramValues.put("deptName", "R&D"); + q.setParameters(paramValues); + List infos = q.executeResultList(Info.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_09, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Aggregation of a single Field. + * + * This query averages the salaries of Employees who work in the parameter department + * and returns a single value. + */ + public void testQuery10a() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Double expected = 45000.; + try (Query q = + pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { + q.setResult("avg(salary)"); + q.declareParameters("String deptName"); + Double avgSalary = (Double) q.execute("R&D"); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_10, avgSalary, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Aggregation of a single Field. + * + * This query averages the salaries of Employees who work in the parameter department + * and returns a single value. + */ + public void testQuery10b() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Double expected = 45000.; + try (Query q = + pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { + q.setResult("avg(salary)"); + q.declareParameters("String deptName"); + Map paramValues = new HashMap<>(); + paramValues.put("deptName", "R&D"); + q.setNamedParameters(paramValues); + Double avgSalary = q.executeResultUnique(Double.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_10, avgSalary, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Aggregation of a single Field. + * + * This query averages the salaries of Employees who work in the parameter department + * and returns a single value. + */ + public void testQuery10c() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Double expected = 45000.; + try (Query q = + pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { + q.setResult("avg(salary)"); + q.declareParameters("String deptName"); + q.setParameters("R&D"); + Double avgSalary = q.executeResultUnique(Double.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_10, avgSalary, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Aggregation of a single Field. + * + * This query averages the salaries of Employees who work in the parameter department + * and returns a single value. + */ + public void testQuery10d() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Double expected = 45000.; + try (Query q = pm.newQuery(SINGLE_STRING_QUERY_10)) { + q.setParameters("R&D"); + Double avgSalary = q.executeResultUnique(Double.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_10, avgSalary, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Aggregation of a single Field. + * + * This query averages the salaries of Employees who work in the parameter department + * and returns a single value. + */ + public void testQuery10f() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Double expected = 45000.; + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + StringExpression deptName = q.stringParameter("deptName"); + q.result(false, cand.salary.avg()) + .filter(cand.department.name.eq(deptName)); + Map paramValues = new HashMap<>(); + paramValues.put("deptName", "R&D"); + q.setParameters(paramValues); + Double avgSalary = q.executeResultUnique(Double.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_10, avgSalary, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Aggregation of Multiple Fields and Expressions. + * + * This query averages and sums the salaries of Employees who work in the parameter department. + */ + public void testQuery11a() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Double[] expected = new Double[] {45000., 90000.}; + try (Query q = + pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { + q.setResult("avg(salary), sum(salary)"); + q.declareParameters("String deptName"); + Object[] avgSum = (Object[]) q.execute("R&D"); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_11, avgSum, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Aggregation of Multiple Fields and Expressions. + * + * This query averages and sums the salaries of Employees who work in the parameter department. + */ + public void testQuery11b() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Double[] expected = new Double[] {45000., 90000.}; + try (Query q = + pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { + q.setResult("avg(salary), sum(salary)"); + q.declareParameters("String deptName"); + Map paramValues = new HashMap<>(); + paramValues.put("deptName", "R&D"); + q.setNamedParameters(paramValues); + Object[] avgSum = q.executeResultUnique(Object[].class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_11, avgSum, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Aggregation of Multiple Fields and Expressions. + * + * This query averages and sums the salaries of Employees who work in the parameter department. + */ + public void testQuery11c() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Double[] expected = new Double[] {45000., 90000.}; + try (Query q = + pm.newQuery(FullTimeEmployee.class, "department.name == deptName")) { + q.setResult("avg(salary), sum(salary)"); + q.declareParameters("String deptName"); + q.setParameters("R&D"); + Object[] avgSum = q.executeResultUnique(Object[].class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_11, avgSum, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Aggregation of Multiple Fields and Expressions. + * + * This query averages and sums the salaries of Employees who work in the parameter department. + */ + public void testQuery11d() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Double[] expected = new Double[] {45000., 90000.}; + try (Query q = pm.newQuery(SINGLE_STRING_QUERY_11)) { + q.setParameters("R&D"); + Object[] avgSum = q.executeResultUnique(Object[].class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_11, avgSum, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Aggregation of Multiple Fields and Expressions. + * + * This query averages and sums the salaries of Employees who work in the parameter department. + */ + public void testQuery11f() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Double[] expected = new Double[] {45000., 90000.}; + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + StringExpression deptName = q.stringParameter("deptName"); + q.result(false, cand.salary.avg(), cand.salary.sum()) + .filter(cand.department.name.eq(deptName)); + Map paramValues = new HashMap<>(); + paramValues.put("deptName", "R&D"); + q.setParameters(paramValues); + Object[] avgSum = q.executeResultUnique(Object[].class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_11, avgSum, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Aggregation of Multiple fields with Grouping. + * + * This query averages and sums the salaries of Employees who work in all departments having + * more than one employee and aggregates by department name. + */ + public void testQuery12a() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Object[] expectedRow = new Object[]{45000., 90000., "R&D"}; + try (Query q = pm.newQuery(FullTimeEmployee.class)) { + q.setResult("avg(salary), sum(salary), department.name"); + q.setGrouping("department.name having count(department.name) > 1"); + List results = (List)q.execute(); + if (results.size() != 1) { + fail(ASSERTION_FAILED, + "Query result has size " + results.size() + ", expected query result of size 1"); + } + Object[] row = results.get(0); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_12, row, expectedRow); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Aggregation of Multiple fields with Grouping. + * + * This query averages and sums the salaries of Employees who work in all departments having + * more than one employee and aggregates by department name. + */ + public void testQuery12b() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Object[] expectedRow = new Object[]{45000., 90000., "R&D"}; + try (Query q = pm.newQuery(FullTimeEmployee.class)) { + q.setResult("avg(salary), sum(salary), department.name"); + q.setGrouping("department.name having count(department.name) > 1"); + List results = q.executeResultList(Object[].class); + if (results.size() != 1) { + fail(ASSERTION_FAILED, + "Query result has size " + results.size() + ", expected query result of size 1"); + } + Object[] row = results.get(0); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_12, row, expectedRow); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Aggregation of Multiple fields with Grouping. + * + * This query averages and sums the salaries of Employees who work in all departments having + * more than one employee and aggregates by department name. + */ + public void testQuery12d() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Object[] expectedRow = new Object[]{45000., 90000., "R&D"}; + try (Query q = pm.newQuery(SINGLE_STRING_QUERY_12)) { + List results = q.executeResultList(Object[].class); + if (results.size() != 1) { + fail(ASSERTION_FAILED, + "Query result has size " + results.size() + ", expected query result of size 1"); + } + Object[] row = results.get(0); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_12, row, expectedRow); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Aggregation of Multiple fields with Grouping. + * + * This query averages and sums the salaries of Employees who work in all departments having + * more than one employee and aggregates by department name. + */ + public void testQuery12e() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Object[] expectedRow = new Object[]{45000., 90000., "R&D"}; + try (Query q = pm.newNamedQuery(FullTimeEmployee.class, "grouping")) { + List results = q.executeResultList(Object[].class); + if (results.size() != 1) { + fail(ASSERTION_FAILED, + "Query result has size " + results.size() + ", expected query result of size 1"); + } + Object[] row = results.get(0); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_12, row, expectedRow); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Aggregation of Multiple fields with Grouping. + * + * This query averages and sums the salaries of Employees who work in all departments having + * more than one employee and aggregates by department name. + */ + public void testQuery12f() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Object[] expectedRow = new Object[]{45000., 90000., "R&D"}; + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + q.result(false, cand.salary.avg(), cand.salary.sum(), cand.department.name) + .groupBy(cand.department.name) + .having(cand.department.name.count().gt(1L)); + List results = q.executeResultList(Object[].class); + if (results.size() != 1) { + fail(ASSERTION_FAILED, + "Query result has size " + results.size() + ", expected query result of size 1"); + } + Object[] row = results.get(0); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_12, row, expectedRow); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Selection of a Single Instance. + * + * This query returns a single instance of Employee. + */ + public void testQuery13a() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Employee expectedEmp = (Employee)getTransientCompanyModelInstance("emp1"); + try (Query q = pm.newQuery(Employee.class, "firstname == empName")) { + q.setUnique(true); + q.declareParameters ("String empName"); + Employee emp = (Employee)q.execute("Michael"); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_13, emp, expectedEmp); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Selection of a Single Instance. + * + * This query returns a single instance of Employee. + */ + public void testQuery13b() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Employee expectedEmp = (Employee)getTransientCompanyModelInstance("emp1"); + try (Query q = pm.newQuery (Employee.class, "firstname == empName")) { + q.setUnique(true); + q.declareParameters ("String empName"); + Map paramValues = new HashMap<>(); + paramValues.put("empName", "Michael"); + q.setNamedParameters(paramValues); + Employee emp = q.executeUnique(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_13, emp, expectedEmp); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Selection of a Single Instance. + * + * This query returns a single instance of Employee. + */ + public void testQuery13c() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Employee expectedEmp = (Employee)getTransientCompanyModelInstance("emp1"); + try (Query q = pm.newQuery (Employee.class, "firstname == empName")) { + q.setUnique(true); + q.declareParameters ("String empName"); + q.setParameters("Michael"); + Employee emp = q.executeUnique(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_13, emp, expectedEmp); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Selection of a Single Instance. + * + * This query returns a single instance of Employee. + */ + public void testQuery13d() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Employee expectedEmp = (Employee)getTransientCompanyModelInstance("emp1"); + try (Query q = pm.newQuery (SINGLE_STRING_QUERY_13)) { + q.setParameters("Michael"); + Employee emp = q.executeResultUnique(Employee.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_13, emp, expectedEmp); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Selection of a Single Instance. + * + * This query returns a single instance of Employee. + */ + public void testQuery13f() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Employee expectedEmp = (Employee)getTransientCompanyModelInstance("emp1"); + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(Employee.class)) { + QEmployee cand = QEmployee.candidate(); + StringExpression empName = q.stringParameter("empName"); + q.filter(cand.firstname.eq(empName)); + Map paramValues = new HashMap<>(); + paramValues.put("empName", "Michael"); + q.setParameters(paramValues); + Employee emp = q.executeUnique(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_13, emp, expectedEmp); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Selection of a Single Field. + * + * This query returns a single field of a single Employee. + */ + public void testQuery14a() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Double expectedSalary = 40000.; + try (Query q = pm.newQuery(FullTimeEmployee.class, "firstname == empName")) { + q.setResult("salary"); + q.setResultClass(Double.class); + q.setUnique(true); + q.declareParameters("String empName"); + Double salary = (Double) q.execute ("Michael"); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_14, salary, expectedSalary); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Selection of a Single Field. + * + * This query returns a single field of a single Employee. + */ + public void testQuery14b() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Double expectedSalary = 40000.; + try (Query q = pm.newQuery(FullTimeEmployee.class, "firstname == empName")) { + q.setResult("salary"); + q.setResultClass(Double.class); + q.declareParameters("String empName"); + Map paramValues = new HashMap<>(); + paramValues.put("empName", "Michael"); + q.setNamedParameters(paramValues); + Double salary = q.executeResultUnique(Double.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_14, salary, expectedSalary); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Selection of a Single Field. + * + * This query returns a single field of a single Employee. + */ + public void testQuery14c() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Double expectedSalary = 40000.; + try (Query q = pm.newQuery(FullTimeEmployee.class, "firstname == empName")) { + q.setResult("salary"); + q.setResultClass(Double.class); + q.declareParameters("String empName"); + q.setParameters("Michael"); + Double salary = q.executeResultUnique(Double.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_14, salary, expectedSalary); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Selection of a Single Field. + * + * This query returns a single field of a single Employee. + */ + public void testQuery14d() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Double expectedSalary = 40000.; + try (Query q = pm.newQuery(SINGLE_STRING_QUERY_14)) { + q.setParameters("Michael"); + Double salary = q.executeResultUnique(Double.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_14, salary, expectedSalary); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Selection of a Single Field. + * + * This query returns a single field of a single Employee. + */ + public void testQuery14f() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Double expectedSalary = 40000.; + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + StringExpression empName = q.stringParameter("empName"); + q.result(false, cand.salary) + .filter(cand.firstname.eq(empName)); + Map paramValues = new HashMap<>(); + paramValues.put("empName", "Michael"); + q.setParameters(paramValues); + Double salary = q.executeResultUnique(Double.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_14, salary, expectedSalary); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of "this" to User-defined Result Class with Matching Field. + * + * This query selects instances of Employee who make more than the parameter salary and + * stores the result in a user-defined class. Since the default is "distinct this as FullTimeEmployee", + * the field must be named FullTimeEmployee and be of type FullTimeEmployee. + */ + public void testQuery15a() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = testQuery15Helper(); + try (Query q = pm.newQuery(FullTimeEmployee.class, "salary > sal")) { + q.setResultClass(EmpWrapper.class); + q.declareParameters("Double sal"); + List infos = (List)q.execute(30000.); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_15, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of "this" to User-defined Result Class with Matching Field. + * + * This query selects instances of Employee who make more than the parameter salary and + * stores the result in a user-defined class. Since the default is "distinct this as FullTimeEmployee", + * the field must be named FullTimeEmployee and be of type FullTimeEmployee. + */ + public void testQuery15b() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = testQuery15Helper(); + try (Query q = pm.newQuery(FullTimeEmployee.class, "salary > sal")) { + q.setResultClass(EmpWrapper.class); + q.declareParameters ("Double sal"); + Map paramValues = new HashMap<>(); + paramValues.put("sal", 30000.); + q.setNamedParameters(paramValues); + List infos = q.executeResultList(EmpWrapper.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_15, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of "this" to User-defined Result Class with Matching Field. + * + * This query selects instances of Employee who make more than the parameter salary and + * stores the result in a user-defined class. Since the default is "distinct this as FullTimeEmployee", + * the field must be named FullTimeEmployee and be of type FullTimeEmployee. + */ + public void testQuery15c() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = testQuery15Helper(); + try (Query q = pm.newQuery(FullTimeEmployee.class, "salary > sal")) { + q.setResultClass(EmpWrapper.class); + q.declareParameters ("Double sal"); + q.setParameters(30000.); + List infos = q.executeResultList(EmpWrapper.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_15, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of "this" to User-defined Result Class with Matching Field. + * + * This query selects instances of Employee who make more than the parameter salary and + * stores the result in a user-defined class. Since the default is "distinct this as FullTimeEmployee", + * the field must be named FullTimeEmployee and be of type FullTimeEmployee. + */ + public void testQuery15d() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = testQuery15Helper(); + try (Query q = pm.newQuery(SINGLE_STRING_QUERY_15)) { + q.setParameters(30000.); + List infos = q.executeResultList(EmpWrapper.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_15, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of "this" to User-defined Result Class with Matching Field. + * + * This query selects instances of Employee who make more than the parameter salary and + * stores the result in a user-defined class. Since the default is "distinct this as FullTimeEmployee", + * the field must be named FullTimeEmployee and be of type FullTimeEmployee. + */ + public void testQuery15f() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = testQuery15Helper(); + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + NumericExpression sal = q.numericParameter("sal", Double.class); + q.result(true, cand.as("FullTimeEmployee")) + .filter(cand.salary.gt(sal)); + Map paramValues = new HashMap<>(); + paramValues.put("sal", 30000.); + q.setParameters(paramValues); + List infos = q.executeResultList(EmpWrapper.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_15, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of "this" to User-defined Result Class with Matching Method + * + * This query selects instances of FullTimeEmployee who make more than the parameter salary and + * stores the result in a user-defined class. + */ + public void testQuery16a() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = testQuery16Helper(); + try (Query q = pm.newQuery(FullTimeEmployee.class, "salary > sal")) { + q.setResultClass(EmpInfo.class); + q.declareParameters("Double sal"); + List infos = (List)q.execute(30000.); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_16, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of "this" to User-defined Result Class with Matching Method + * + * This query selects instances of FullTimeEmployee who make more than the parameter salary and + * stores the result in a user-defined class. + */ + public void testQuery16b() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = testQuery16Helper(); + try (Query q = pm.newQuery(FullTimeEmployee.class, "salary > sal")) { + q.setResultClass(EmpInfo.class); + q.declareParameters("Double sal"); + Map paramValues = new HashMap<>(); + paramValues.put("sal", 30000.); + q.setNamedParameters(paramValues); + List infos = q.executeResultList(EmpInfo.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_16, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of "this" to User-defined Result Class with Matching Method + * + * This query selects instances of FullTimeEmployee who make more than the parameter salary and + * stores the result in a user-defined class. + */ + public void testQuery16c() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = testQuery16Helper(); + try (Query q = pm.newQuery(FullTimeEmployee.class, "salary > sal")) { + q.setResultClass(EmpInfo.class); + q.declareParameters("Double sal"); + q.setParameters(30000.); + List infos = q.executeResultList(EmpInfo.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_16, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of "this" to User-defined Result Class with Matching Method + * + * This query selects instances of FullTimeEmployee who make more than the parameter salary and + * stores the result in a user-defined class. + */ + public void testQuery16d() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = testQuery16Helper(); + try (Query q = pm.newQuery(SINGLE_STRING_QUERY_16)) { + q.setParameters(30000.); + List infos = q.executeResultList(EmpInfo.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_16, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of "this" to User-defined Result Class with Matching Method + * + * This query selects instances of FullTimeEmployee who make more than the parameter salary and + * stores the result in a user-defined class. + */ + public void testQuery16f() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = testQuery16Helper(); + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) { + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + NumericExpression sal = q.numericParameter("sal", Double.class); + q.result(true, cand.as("FullTimeEmployee")) + .filter(cand.salary.gt(sal)); + Map paramValues = new HashMap<>(); + paramValues.put("sal", 30000.); + q.setParameters(paramValues); + List infos = q.executeResultList(EmpInfo.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_16, infos, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of variables. + * + * This query returns the names of all Employees of all "Research" departments. + */ + public void testQuery17a() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList("Michael", "Craig", "Joe"); + try (Query q = pm.newQuery(Department.class)) { + q.declareVariables("org.apache.jdo.tck.pc.company.Employee e"); + q.setFilter("name.startsWith('R&D') && employees.contains(e)"); + q.setResult("e.firstname"); + List names = (List) q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_17, names, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of variables. + * + * This query returns the names of all Employees of all "Research" departments. + */ + public void testQuery17b() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList("Michael", "Craig", "Joe"); + try (Query q = pm.newQuery(Department.class)) { + q.declareVariables("org.apache.jdo.tck.pc.company.Employee e"); + q.setFilter("name.startsWith('R&D') && employees.contains(e)"); + q.setResult("e.firstname"); + List names = q.executeResultList(String.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_17, names, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of variables. + * + * This query returns the names of all Employees of all "Research" departments. + */ + public void testQuery17d() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList("Michael", "Craig", "Joe"); + try (Query q = pm.newQuery(SINGLE_STRING_QUERY_17)) { + List names = q.executeResultList(String.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_17, names, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of variables. + * + * This query returns the names of all Employees of all "Research" departments. + */ + public void testQuery17e() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList("Michael", "Craig", "Joe"); + try (Query q = pm.newNamedQuery(Department.class, "projectingVariables")) { + List names = q.executeResultList(String.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_17, names, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Projection of variables. + * + * This query returns the names of all Employees of all "Research" departments. + */ + public void testQuery17f() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList("Michael", "Craig", "Joe"); + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(Department.class)) { + QDepartment cand = QDepartment.candidate(); + QEmployee e = QEmployee.variable("e"); + q.filter(cand.name.startsWith("R&D").and(cand.employees.contains(e))) + .result(false, e.firstname); + List names = q.executeResultList(String.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_17, names, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Non-correlated subquery + * + * This query returns names of employees who work more than the average of all employees. + */ + public void testQuery18a() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList("Michael", "Craig"); + try (Query q = pm.newQuery(Employee.class)) { + Query subq = pm.newQuery(Employee.class); + subq.setResult("avg(weeklyhours)"); + q.setFilter("this.weeklyhours > average_hours"); + q.setResult("this.firstname"); + q.addSubquery(subq, "double average_hours", null); + List names = (List)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_18, names, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Non-correlated subquery + * + * This query returns names of employees who work more than the average of all employees. + */ + public void testQuery18b() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList("Michael", "Craig"); + try (Query q = pm.newQuery(Employee.class)) { + Query subq = pm.newQuery(Employee.class); + subq.setResult("avg(weeklyhours)"); + q.setFilter("this.weeklyhours > average_hours"); + q.setResult("this.firstname"); + q.addSubquery(subq, "double average_hours", null); + List names = q.executeResultList(String.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_18, names, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Non-correlated subquery + * + * This query returns names of employees who work more than the average of all employees. + */ + public void testQuery18d() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList("Michael", "Craig"); + try (Query q = pm.newQuery(SINGLE_STRING_QUERY_18)) { + List names = q.executeResultList(String.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_18, names, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Non-correlated subquery + * + * This query returns names of employees who work more than the average of all employees. + */ + public void testQuery18f() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList("Michael", "Craig"); + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(Employee.class)) { + QEmployee cand = QEmployee.candidate(); + JDOQLTypedSubquery subquery = q.subquery("e"); + QEmployee candsub = QEmployee.candidate("e"); + q.result(false, cand.firstname) + .filter(cand.weeklyhours.gt(subquery.selectUnique(candsub.weeklyhours.avg()))); + List names = q.executeResultList(String.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_18, names, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Correlated subquery. + * + * This query returns names of employees who work more than the average of employees + * in the same department having the same manager. The candidate collection of the + * subquery is the collection of employees in the department of the candidate employee + * and the parameter passed to the subquery is the manager of the candidate employee. + */ + public void testQuery19a() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList("Michael"); + try (Query q = pm.newQuery(Employee.class)) { + Query subq = pm.newQuery(Employee.class); + subq.setFilter("this.manager == :manager"); + subq.setResult("avg(weeklyhours)"); + q.setFilter("this.weeklyhours > average_hours"); + q.setResult("firstname"); + q.addSubquery(subq, "double average_hours","this.department.employees", + "this.manager"); + List names = (List)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_19, names, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Correlated subquery. + * + * This query returns names of employees who work more than the average of employees + * in the same department having the same manager. The candidate collection of the + * subquery is the collection of employees in the department of the candidate employee + * and the parameter passed to the subquery is the manager of the candidate employee. + */ + public void testQuery19b() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList("Michael"); + try (Query q = pm.newQuery(Employee.class)) { + Query subq = pm.newQuery(Employee.class); + subq.setFilter("this.manager == :manager"); + subq.setResult("avg(weeklyhours)"); + q.setFilter("this.weeklyhours > average_hours"); + q.setResult("firstname"); + q.addSubquery(subq, "double average_hours","this.department.employees", + "this.manager"); + List names = q.executeResultList(String.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_19, names, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Correlated subquery. + * + * This query returns names of employees who work more than the average of employees + * in the same department having the same manager. The candidate collection of the + * subquery is the collection of employees in the department of the candidate employee + * and the parameter passed to the subquery is the manager of the candidate employee. + */ + public void testQuery19d() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList("Michael"); + try (Query q = pm.newQuery(SINGLE_STRING_QUERY_19)) { + List names = q.executeResultList(String.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_19, names, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Correlated subquery. + * + * This query returns names of employees who work more than the average of employees + * in the same department having the same manager. The candidate collection of the + * subquery is the collection of employees in the department of the candidate employee + * and the parameter passed to the subquery is the manager of the candidate employee. + */ + public void testQuery19f() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = Arrays.asList("Michael"); + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(Employee.class)) { + QEmployee cand = QEmployee.candidate(); + JDOQLTypedSubquery subquery = q.subquery(cand.department.employees, Employee.class,"e"); + QEmployee candsub = QEmployee.candidate("e"); + subquery.filter(candsub.manager.eq(cand.manager)); + q.result(false, cand.firstname) + .filter(cand.weeklyhours.gt(subquery.selectUnique(candsub.weeklyhours.avg()))); + List names = q.executeResultList(String.class); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_19, names, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * Deleting Multiple Instances. + * + * This query deletes all Employees who make more than the parameter salary. + */ + public void testQuery20() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Query empQuery = pm.newQuery (FullTimeEmployee.class, "personid == 5"); + empQuery.setUnique(true); + FullTimeEmployee emp5 = empQuery.executeUnique(); + Object emp5Oid = pm.getObjectId(emp5); + Query q = pm.newQuery (FullTimeEmployee.class, "salary > sal"); + q.declareParameters ("Double sal"); + q.deletePersistentAll(30000.); + tx.commit(); + + tx.begin(); + Query allQuery = pm.newQuery(FullTimeEmployee.class); + List allFTE = allQuery.executeList(); + if (!allFTE.isEmpty()) { + fail(ASSERTION_FAILED, "All FullTimeEmployee instances should have been deleted," + + " there are still " + allFTE.size() + " instances left."); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + private List testQuery08Helper() { + Info info1 = new Info(); + info1.firstname = "Michael"; + info1.salary = 40000.; + info1.reportsTo = (Employee)getTransientCompanyModelInstance("emp2"); + Info info2 = new Info(); + info2.firstname = "Craig"; + info2.salary = 50000.; + info2.reportsTo = null; + return Arrays.asList(info1, info2); + } + + private List testQuery15Helper() { + EmpWrapper wrapper1 = new EmpWrapper(); + wrapper1.FullTimeEmployee = (FullTimeEmployee)getTransientCompanyModelInstance("emp1"); + EmpWrapper wrapper2 = new EmpWrapper(); + wrapper2.FullTimeEmployee = (FullTimeEmployee)getTransientCompanyModelInstance("emp2"); + EmpWrapper wrapper3 = new EmpWrapper(); + wrapper3.FullTimeEmployee = (FullTimeEmployee)getTransientCompanyModelInstance("emp5"); + return Arrays.asList(wrapper1, wrapper2, wrapper3); + } + + private List testQuery16Helper() { + EmpInfo info1 = new EmpInfo(); + info1.setFullTimeEmployee((FullTimeEmployee) getTransientCompanyModelInstance("emp1")); + EmpInfo info2 = new EmpInfo(); + info2.setFullTimeEmployee((FullTimeEmployee) getTransientCompanyModelInstance("emp2")); + EmpInfo info3 = new EmpInfo(); + info3.setFullTimeEmployee((FullTimeEmployee) getTransientCompanyModelInstance("emp5")); + return Arrays.asList(info1, info2, info3); + } + + public static class Info { + public String firstname; + public Double salary; + public Person reportsTo; + public Info () {} + public Info (String firstname, Double salary, Person reportsTo) { + this.firstname = firstname; + this.salary = salary; + this.reportsTo = reportsTo; + } + public boolean equals(Object obj) { + if (!(obj instanceof Info)) { + return false; + } + Info other = (Info)obj; + if (!EqualityHelper.equals(firstname, other.firstname)) { + return false; + } + if (!EqualityHelper.equals(salary, other.salary)) { + return false; + } + if (!EqualityHelper.equals(reportsTo, other.reportsTo)) { + return false; + } + return true; + } + public int hashCode () { + int hashCode = 0; + hashCode += firstname == null ? 0 : firstname.hashCode(); + hashCode += salary == null ? 0 : salary.hashCode(); + hashCode += reportsTo == null ? 0 : reportsTo.hashCode(); + return hashCode; + } + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Info("); + builder.append("firstname:").append(firstname); + builder.append(", salary:").append(salary); + builder.append(", reportsTo:").append(reportsTo == null ? "null" : reportsTo.getFirstname()); + builder.append(")"); + return builder.toString(); + } + } + + public static class EmpWrapper { + public FullTimeEmployee FullTimeEmployee; + public EmpWrapper () {} + // Need constructor to prevent + // java.lang.NullPointerException + // at org.datanucleus.query.QueryUtils.createResultObjectUsingDefaultConstructorAndSetters(QueryUtils.java:293) + public EmpWrapper (FullTimeEmployee FullTimeEmployee) { + this.FullTimeEmployee = FullTimeEmployee; + } + public boolean equals(Object obj) { + if (!(obj instanceof EmpWrapper)) { + return false; + } + EmpWrapper other = (EmpWrapper)obj; + if (!EqualityHelper.equals(FullTimeEmployee, other.FullTimeEmployee)) { + return false; + } + return true; + } + public int hashCode () { + int hashCode = 0; + hashCode += FullTimeEmployee == null ? 0 : FullTimeEmployee.hashCode(); + return hashCode; + } + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("EmpWrapper("); + builder.append("FullTimeEmployee:").append(FullTimeEmployee == null ? "null" : FullTimeEmployee.getFirstname()); + builder.append(")"); + return builder.toString(); + } + } + + public static class EmpInfo { + private FullTimeEmployee worker; + public EmpInfo () {} + // Need constructor to prevent + // java.lang.NullPointerException + // at org.datanucleus.query.QueryUtils.createResultObjectUsingDefaultConstructorAndSetters(QueryUtils.java:293) + public EmpInfo (FullTimeEmployee worker) { + this.worker = worker; + } + public FullTimeEmployee getWorker() {return worker;} + public void setFullTimeEmployee(FullTimeEmployee e) { + worker = e; + } + public boolean equals(Object obj) { + if (!(obj instanceof EmpInfo)) { + return false; + } + EmpInfo other = (EmpInfo)obj; + if (!EqualityHelper.equals(worker, other.worker)) { + return false; + } + return true; + } + public int hashCode () { + int hashCode = 0; + hashCode += worker == null ? 0 : worker.hashCode(); + return hashCode; + } + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("EmpInfo("); + builder.append("worker:").append(worker == null ? "null" : worker.getFirstname()); + builder.append(")"); + return builder.toString(); + } + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } + + /** + * Returns the name of the company test data resource. + * @return name of the company test data resource. + */ + protected String getCompanyTestDataResource() { + return SAMPLE_QUERIES_TEST_COMPANY_TESTDATA; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/SaveAsNamedQuery.java b/tck/src/main/java/org/apache/jdo/tck/query/api/SaveAsNamedQuery.java index 5db019ac3..44cd9364d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/SaveAsNamedQuery.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/SaveAsNamedQuery.java @@ -5,19 +5,22 @@ * 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 + * + * 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.jdo.tck.query.api; import java.util.Arrays; + import javax.jdo.Query; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.query.QueryTest; @@ -25,70 +28,72 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: SaveAsNamedQuery.
    - * Keywords: query
    - * Assertion ID: A14.6-22.
    - * Assertion Description: The method "saveAsNamedQuery" allows a query to be saved as a - * named query for later execution. + *Title: SaveAsNamedQuery. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6-22. + *
    + *Assertion Description: + * The method "saveAsNamedQuery" allows a query to be saved as a named query for later execution. */ public class SaveAsNamedQuery extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6-22 (SaveAsNamedQuery) failed: "; - - private static String singleStringQuery = - "SELECT firstname, lastname FROM org.apache.jdo.tck.pc.company.Person"; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-22 (SaveAsNamedQuery) failed: "; + + private static String singleStringQuery = + "SELECT firstname, lastname FROM org.apache.jdo.tck.pc.company.Person"; - /** The expected results of valid queries. */ - private Object[] expectedResult = { - Arrays.asList( - new Object[] { - new FullName("emp1First", "emp1Last"), - new FullName("emp2First", "emp2Last"), - new FullName("emp3First", "emp3Last"), - new FullName("emp4First", "emp4Last"), - new FullName("emp5First", "emp5Last") - }) - }; + /** + * The expected results of valid queries. + */ + private Object[] expectedResult = { + Arrays.asList(new Object[] { + new FullName("emp1First", "emp1Last"), + new FullName("emp2First", "emp2Last"), + new FullName("emp3First", "emp3Last"), + new FullName("emp4First", "emp4Last"), + new FullName("emp5First", "emp5Last")}) + }; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SaveAsNamedQuery.class); - } + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SaveAsNamedQuery.class); + } - /** */ - public void testSave() { - int index = 0; - Query query = getPM().newQuery(singleStringQuery); - query.setResultClass(FullName.class); - query.setRange(0, 5); - query.setIgnoreCache(true); - executeJDOQuery( - ASSERTION_FAILED, query, singleStringQuery, false, null, expectedResult[index], true); + /** */ + public void testSave() { + int index = 0; + Query query = getPM().newQuery(singleStringQuery); + query.setResultClass(FullName.class); + query.setRange(0, 5); + query.setIgnoreCache(true); + executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery, false, null, expectedResult[index], true); - // Save query under this name - String savedName = "MySavedName"; - query.saveAsNamedQuery(savedName); - query.closeAll(); + // Save query under this name + String savedName = "MySavedName"; + query.saveAsNamedQuery(savedName); + query.closeAll(); - // Retrieve via the name, and execute - Query namedQuery = getPM().newNamedQuery(Person.class, savedName); - assertNotNull(namedQuery); - executeJDOQuery( - ASSERTION_FAILED, namedQuery, singleStringQuery, false, null, expectedResult[index], true); - namedQuery.closeAll(); - } + // Retrieve via the name, and execute + Query namedQuery = getPM().newNamedQuery(Person.class, savedName); + assertNotNull(namedQuery); + executeJDOQuery(ASSERTION_FAILED, namedQuery, singleStringQuery, false, null, expectedResult[index], true); + namedQuery.closeAll(); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/SetCandidateCollection.java b/tck/src/main/java/org/apache/jdo/tck/query/api/SetCandidateCollection.java index 2c8862420..156f3bba4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/SetCandidateCollection.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/SetCandidateCollection.java @@ -5,93 +5,105 @@ * 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 + * + * 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.jdo.tck.query.api; + import java.util.ArrayList; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Set Candidate Collection
    - * Keywords: query
    - * Assertion ID: A14.6-5.
    - * Assertion Description: Query.setCandidates(Collection - * candidateCollection) binds the candidate Collection to the query instance. + *Title: Set Candidate Collection + *
    + *Keywords: query + *
    + *Assertion ID: A14.6-5. + *
    + *Assertion Description: Query.setCandidates(Collection + *candidateCollection) binds the candidate Collection + *to the query instance. */ -public class SetCandidateCollection extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6-5 (SetCandidateCollection) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetCandidateCollection.class); - } +public class SetCandidateCollection extends QueryTest { - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - if (debug) logger.debug("\nExecuting test SetCandidateCollection()..."); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-5 (SetCandidateCollection) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetCandidateCollection.class); + } - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + if (debug) logger.debug("\nExecuting test SetCandidateCollection()..."); - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(inserted); - Object results = query.execute(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); - // check query result - List expected = new ArrayList(); - Object p1 = new PCPoint(0, 0); - Object p2 = new PCPoint(1, 1); - Object p3 = new PCPoint(2, 2); - Object p4 = new PCPoint(3, 3); - Object p5 = new PCPoint(4, 4); - expected.add(p1); - expected.add(p2); - expected.add(p3); - expected.add(p4); - expected.add(p5); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected); - if (debug) logger.debug("Test SetCandidateCollection: Passed"); + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(inserted); + Object results = query.execute(); + + // check query result + List expected = new ArrayList(); + Object p1 = new PCPoint(0, 0); + Object p2 = new PCPoint(1, 1); + Object p3 = new PCPoint(2, 2); + Object p4 = new PCPoint(3, 3); + Object p5 = new PCPoint(4, 4); + expected.add(p1); + expected.add(p2); + expected.add(p3); + expected.add(p4); + expected.add(p5); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected); + if (debug) logger.debug("Test SetCandidateCollection: Passed"); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/SetCandidateExtent.java b/tck/src/main/java/org/apache/jdo/tck/query/api/SetCandidateExtent.java index 71fd05de2..6d56bf151 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/SetCandidateExtent.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/SetCandidateExtent.java @@ -5,91 +5,103 @@ * 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 + * + * 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.jdo.tck.query.api; + import java.util.ArrayList; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Set Candidate Extent
    - * Keywords: query extent
    - * Assertion ID: A14.6-6.
    - * Assertion Description: Query.setCandidates(Extent - * candidateExtent) binds the candidate Extent to the query instance. + *Title: Set Candidate Extent + *
    + *Keywords: query extent + *
    + *Assertion ID: A14.6-6. + *
    + *Assertion Description: Query.setCandidates(Extent + *candidateExtent) binds the candidate Extent to the query + *instance. */ -public class SetCandidateExtent extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6-6 (SetCandidateExtent) failed: "; +public class SetCandidateExtent extends QueryTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetCandidateExtent.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-6 (SetCandidateExtent) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetCandidateExtent.class); + } - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - if (debug) logger.debug("\nExecuting test SetCandidateExtent()..."); + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + if (debug) logger.debug("\nExecuting test SetCandidateExtent()..."); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - Object results = query.execute(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + Object results = query.execute(); - // check query result - List expected = new ArrayList(); - Object p1 = new PCPoint(0, 0); - Object p2 = new PCPoint(1, 1); - Object p3 = new PCPoint(2, 2); - Object p4 = new PCPoint(3, 3); - Object p5 = new PCPoint(4, 4); - expected.add(p1); - expected.add(p2); - expected.add(p3); - expected.add(p4); - expected.add(p5); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected); - if (debug) logger.debug("Test SetCandidateExtent: Passed"); + // check query result + List expected = new ArrayList(); + Object p1 = new PCPoint(0, 0); + Object p2 = new PCPoint(1, 1); + Object p3 = new PCPoint(2, 2); + Object p4 = new PCPoint(3, 3); + Object p5 = new PCPoint(4, 4); + expected.add(p1); + expected.add(p2); + expected.add(p3); + expected.add(p4); + expected.add(p5); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected); + if (debug) logger.debug("Test SetCandidateExtent: Passed"); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/SetFilter.java b/tck/src/main/java/org/apache/jdo/tck/query/api/SetFilter.java index c8f715366..71c69a248 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/SetFilter.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/SetFilter.java @@ -5,83 +5,98 @@ * 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 + * + * 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.jdo.tck.query.api; import java.util.ArrayList; import java.util.List; + import javax.jdo.Extent; import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Set Filter
    - * Keywords: query
    - * Assertion ID: A14.6-7.
    - * Assertion Description: Query.setFilter(String filter) binds the query filter - * to the query instance. - */ -public class SetFilter extends QueryTest { + *Title: Set Filter + *
    + *Keywords: query + *
    + *Assertion ID: A14.6-7. + *
    + *Assertion Description: +Query.setFilter(String filter) binds the query filter +to the query instance. - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6-7 (SetFilter) failed: "; + */ - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetFilter.class); - } +public class SetFilter extends QueryTest { - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - Class clazz = PCPoint.class; - try { - Extent extent = pm.getExtent(clazz, true); - tx.begin(); - Query query = pm.newQuery(); - query.setClass(clazz); - query.setCandidates(extent); - query.setFilter("x == 2"); - Object results = query.execute(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-7 (SetFilter) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetFilter.class); + } - // check query result - List expected = new ArrayList(); - expected.add(new PCPoint(2, 2)); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 2", results, expected); + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + Class clazz = PCPoint.class; + try { + Extent extent = pm.getExtent(clazz, true); + tx.begin(); + Query query = pm.newQuery(); + query.setClass(clazz); + query.setCandidates(extent); + query.setFilter("x == 2"); + Object results = query.execute(); + + // check query result + List expected = new ArrayList(); + expected.add(new PCPoint(2, 2)); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 2", + results, expected); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/SetGrouping.java b/tck/src/main/java/org/apache/jdo/tck/query/api/SetGrouping.java index e2ac8bd32..993f21860 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/SetGrouping.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/SetGrouping.java @@ -5,68 +5,79 @@ * 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 + * + * 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.jdo.tck.query.api; import java.util.Arrays; + import javax.jdo.Query; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Set Grouping.
    - * Keywords: query
    - * Assertion ID: A14.6-17.
    - * Assertion Description: void setGrouping (String grouping); Specify the grouping of - * results for aggregates. + *Title: Set Grouping. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6-17. + *
    + *Assertion Description: + * void setGrouping (String grouping); + * Specify the grouping of results for aggregates. */ public class SetGrouping extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6-17 (SetGrouping) failed: "; - - /** The expected results of valid queries. */ - private Object[] expectedResult = { - Arrays.asList(new Object[] {"emp1Last", "emp2Last", "emp3Last", "emp4Last", "emp5Last"}) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetGrouping.class); - } - - /** */ - public void testPositive() { - int index = 0; - Query query = getPM().newQuery(Person.class); - query.setResult("lastname"); - query.setGrouping("lastname"); - String singleStringQuery = "SELECT lastname FROM Person GROUP BY lastname"; - executeJDOQuery( - ASSERTION_FAILED, query, singleStringQuery, false, null, expectedResult[index], true); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-17 (SetGrouping) failed: "; + + /** + * The expected results of valid queries. + */ + private Object[] expectedResult = { + Arrays.asList(new Object[] { + "emp1Last", "emp2Last", "emp3Last", "emp4Last", "emp5Last"}) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetGrouping.class); + } + + /** */ + public void testPositive() { + int index = 0; + Query query = getPM().newQuery(Person.class); + query.setResult("lastname"); + query.setGrouping("lastname"); + String singleStringQuery = "SELECT lastname FROM Person GROUP BY lastname"; + executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery, + false, null, expectedResult[index], true); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/SetIgnoreCache.java b/tck/src/main/java/org/apache/jdo/tck/query/api/SetIgnoreCache.java index c3f650aef..5d384e85f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/SetIgnoreCache.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/SetIgnoreCache.java @@ -5,138 +5,161 @@ * 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 + * + * 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.jdo.tck.query.api; import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Set IgnoreCache
    - * Keywords: query
    - * Assertion ID: A14.6-12.
    - * Assertion Description: Query.setIgnoreCache(boolean flag) sets the - * IgnoreCache option for queries. + *Title: Set IgnoreCache + *
    + *Keywords: query + *
    + *Assertion ID: A14.6-12. + *
    + *Assertion Description: Query.setIgnoreCache(boolean flag) + *sets the IgnoreCache option for queries. */ + public class SetIgnoreCache extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6-12 (SetIgnoreCache) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetIgnoreCache.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTestSetIgnoreCache01(pm); - runTestSetIgnoreCache02(pm); - - pm.close(); - pm = null; - } - - /** */ - void runTestSetIgnoreCache01(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - tx.setOptimistic(false); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - - if (debug) logger.debug("Pessimistic: IgnoreCache - Setting value = true"); - query.setIgnoreCache(true); - if (query.getIgnoreCache()) { - if (debug) logger.debug("Pessimistic: IgnoreCache - value = " + query.getIgnoreCache()); - } else { - fail( - ASSERTION_FAILED, - "query.getIgnoreCache() returns false after setting the flag to true"); - } - - if (debug) logger.debug("Pessimistic: IgnoreCache - Setting value = false"); - query.setIgnoreCache(false); - if (!query.getIgnoreCache()) { - if (debug) logger.debug("Pessimistic: IgnoreCache - value = " + query.getIgnoreCache()); - } else { - fail( - ASSERTION_FAILED, - "query.getIgnoreCache() returns true after setting the flag to false"); - } - query.compile(); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-12 (SetIgnoreCache) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetIgnoreCache.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTestSetIgnoreCache01(pm); + runTestSetIgnoreCache02(pm); + + pm.close(); + pm = null; } - } - /** */ - void runTestSetIgnoreCache02(PersistenceManager pm) { - if (!isOptimisticSupported()) { - if (debug) logger.debug("Optimistic tx not supported"); - return; + /** */ + void runTestSetIgnoreCache01(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + tx.setOptimistic(false); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + + if (debug) + logger.debug("Pessimistic: IgnoreCache - Setting value = true"); + query.setIgnoreCache(true); + if(query.getIgnoreCache()) { + if (debug) + logger.debug("Pessimistic: IgnoreCache - value = " + + query.getIgnoreCache()); + } + else { + fail(ASSERTION_FAILED, + "query.getIgnoreCache() returns false after setting the flag to true"); + } + + if (debug) + logger.debug("Pessimistic: IgnoreCache - Setting value = false"); + query.setIgnoreCache(false); + if(!query.getIgnoreCache()) { + if (debug) + logger.debug("Pessimistic: IgnoreCache - value = " + + query.getIgnoreCache()); + } + else { + fail(ASSERTION_FAILED, + "query.getIgnoreCache() returns true after setting the flag to false"); + } + query.compile(); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - Transaction tx = pm.currentTransaction(); - try { - tx.setOptimistic(true); - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - - if (debug) logger.debug("Optimistic: IgnoreCache - Setting value = true"); - query.setIgnoreCache(true); - if (query.getIgnoreCache()) { - if (debug) logger.debug("Optimistic: IgnoreCache - value = " + query.getIgnoreCache()); - } else { - fail( - ASSERTION_FAILED, - "query.getIgnoreCache() returns false after setting the flag to true"); - } - - if (debug) logger.debug("Optimistic: IgnoreCache - Setting value = false"); - query.setIgnoreCache(false); - if (!query.getIgnoreCache()) { - if (debug) logger.debug("Optimistic: IgnoreCache - value = " + query.getIgnoreCache()); - } else { - fail( - ASSERTION_FAILED, - "query.getIgnoreCache() returns true after setting the flag to false"); - } - - query.compile(); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + void runTestSetIgnoreCache02(PersistenceManager pm) { + if (!isOptimisticSupported()) { + if (debug) logger.debug("Optimistic tx not supported"); + return; + } + + Transaction tx = pm.currentTransaction(); + try { + tx.setOptimistic(true); + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + + if (debug) + logger.debug("Optimistic: IgnoreCache - Setting value = true"); + query.setIgnoreCache(true); + if(query.getIgnoreCache()) { + if (debug) + logger.debug("Optimistic: IgnoreCache - value = " + + query.getIgnoreCache()); + } + else { + fail(ASSERTION_FAILED, + "query.getIgnoreCache() returns false after setting the flag to true"); + } + + if (debug) + logger.debug("Optimistic: IgnoreCache - Setting value = false"); + query.setIgnoreCache(false); + if(!query.getIgnoreCache()) { + if (debug) + logger.debug("Optimistic: IgnoreCache - value = " + + query.getIgnoreCache()); + } + else { + fail(ASSERTION_FAILED, + "query.getIgnoreCache() returns true after setting the flag to false"); + } + + query.compile(); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/SetOrdering.java b/tck/src/main/java/org/apache/jdo/tck/query/api/SetOrdering.java index e53cb2c12..c5ca42182 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/SetOrdering.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/SetOrdering.java @@ -5,120 +5,136 @@ * 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 + * + * 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.jdo.tck.query.api; import java.util.ArrayList; import java.util.List; import java.util.ListIterator; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Set Ordering
    - * Keywords: query
    - * Assertion ID: A14.6-11.
    - * Assertion Description: Query.setOrdering(String ordering) binds the ordering - * statements to the query instance. + *Title: Set Ordering + *
    + *Keywords: query + *
    + *Assertion ID: A14.6-11. + *
    + *Assertion Description: +Query.setOrdering(String ordering) binds the ordering statements +to the query instance. + */ + public class SetOrdering extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6-11 (SetOrdering) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetOrdering.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - - runTestAscending(pm); - runTestDescending(pm); - } - - /** */ - void runTestAscending(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - // ascending - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.setOrdering("x ascending"); - Object results = query.execute(); - - // check result - printOutput(results, inserted); - checkQueryResultWithOrder(ASSERTION_FAILED, results, inserted); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-11 (SetOrdering) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetOrdering.class); + } + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + + runTestAscending(pm); + runTestDescending(pm); + } + + /** */ + void runTestAscending(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + //ascending + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.setOrdering("x ascending"); + Object results = query.execute(); + + // check result + printOutput(results, inserted); + checkQueryResultWithOrder(ASSERTION_FAILED, results, inserted); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + + /** */ + void runTestDescending(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + Class clazz = PCPoint.class; + try { + tx.begin(); + + //descending + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.setOrdering("x descending"); + Object results = query.execute(); + + // check result + List expected = new ArrayList(); + ListIterator li = inserted.listIterator(inserted.size()); + // construct expected results by iterating inserted objects backwards + while (li.hasPrevious()) { + Object obj = li.previous(); + expected.add(obj); + } + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithOrder(ASSERTION_FAILED, results, expected); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - void runTestDescending(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - Class clazz = PCPoint.class; - try { - tx.begin(); - - // descending - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.setOrdering("x descending"); - Object results = query.execute(); - - // check result - List expected = new ArrayList(); - ListIterator li = inserted.listIterator(inserted.size()); - // construct expected results by iterating inserted objects backwards - while (li.hasPrevious()) { - Object obj = li.previous(); - expected.add(obj); - } - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithOrder(ASSERTION_FAILED, results, expected); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/SetRange.java b/tck/src/main/java/org/apache/jdo/tck/query/api/SetRange.java index b3221d8ea..a47b45ac6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/SetRange.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/SetRange.java @@ -5,66 +5,78 @@ * 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 + * + * 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.jdo.tck.query.api; import javax.jdo.Query; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Set Range.
    - * Keywords: query
    - * Assertion ID: A14.6-20.
    - * Assertion Description: setRange(int fromIncl, int toExcl); Specify the number of - * instances to skip over and the maximum number of result instances to return. + *Title: Set Range. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6-20. + *
    + *Assertion Description: + * setRange(int fromIncl, int toExcl); + * Specify the number of instances to skip over + * and the maximum number of result instances to return. */ public class SetRange extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6-20 (SetRange) failed: "; - - /** The expected results of valid queries. */ - private Object[] expectedResult = { - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetRange.class); - } - - /** */ - public void testPositive() { - int index = 0; - Query query = getPM().newQuery(Person.class); - query.setRange(0, 5); - String singleStringQuery = "SELECT FROM Person RANGE 0, 5"; - executeJDOQuery( - ASSERTION_FAILED, query, singleStringQuery, false, null, expectedResult[index], true); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-20 (SetRange) failed: "; + + /** + * The expected results of valid queries. + */ + private Object[] expectedResult = { + getTransientCompanyModelInstancesAsList( + new String[]{"emp1", "emp2", "emp3", "emp4", "emp5"}) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetRange.class); + } + + /** */ + public void testPositive() { + int index = 0; + Query query = getPM().newQuery(Person.class); + query.setRange(0, 5); + String singleStringQuery = + "SELECT FROM Person RANGE 0, 5"; + executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery, + false, null, expectedResult[index], true); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/SetResult.java b/tck/src/main/java/org/apache/jdo/tck/query/api/SetResult.java index 06237a0d9..bcd83ad73 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/SetResult.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/SetResult.java @@ -5,83 +5,92 @@ * 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 + * + * 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.jdo.tck.query.api; import java.util.Arrays; + import javax.jdo.JDOUserException; import javax.jdo.Query; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Set Result.
    - * Keywords: query
    - * Assertion ID: A14.6-16.
    - * Assertion Description: void setResult (String result); Specify the results of the query + *Title: Set Result. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6-16. + *
    + *Assertion Description: + * void setResult (String result); Specify the results of the query * if not instances of the candidate class. */ public class SetResult extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6-16 (SetResult) failed: "; - - /** The expected results of valid queries. */ - private Object[] expectedResult = { - Arrays.asList(new Object[] {"emp1Last", "emp2Last", "emp3Last", "emp4Last", "emp5Last"}) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetResult.class); - } - - /** */ - public void testPositive() { - int index = 0; - Query query = getPM().newQuery(Person.class); - query.setResult("lastname"); - String singleStringQuery = "SELECT lastname FROM Person"; - executeJDOQuery( - ASSERTION_FAILED, query, singleStringQuery, false, null, expectedResult[index], true); - } - - /** */ - public void testNegative() { - Query query = getPM().newQuery(Person.class); - try { - query.setResult("noname"); - query.compile(); - fail( - ASSERTION_FAILED - + "Compilation for query " - + "'SELECT noname FROM Person' " - + "succeeded, though the result clause is invalid."); - } catch (JDOUserException e) { + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-16 (SetResult) failed: "; + + /** + * The expected results of valid queries. + */ + private Object[] expectedResult = { + Arrays.asList(new Object[] { + "emp1Last", "emp2Last", "emp3Last", "emp4Last", "emp5Last"}) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetResult.class); + } + + /** */ + public void testPositive() { + int index = 0; + Query query = getPM().newQuery(Person.class); + query.setResult("lastname"); + String singleStringQuery = "SELECT lastname FROM Person"; + executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery, + false, null, expectedResult[index], true); + } + + /** */ + public void testNegative() { + Query query = getPM().newQuery(Person.class); + try { + query.setResult("noname"); + query.compile(); + fail(ASSERTION_FAILED + "Compilation for query " + + "'SELECT noname FROM Person' " + + "succeeded, though the result clause is invalid."); + } catch (JDOUserException e) { + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/SetResultClass.java b/tck/src/main/java/org/apache/jdo/tck/query/api/SetResultClass.java index 4bbe2bd0b..1279c5eeb 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/SetResultClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/SetResultClass.java @@ -5,20 +5,23 @@ * 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 + * + * 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.jdo.tck.query.api; import java.util.Arrays; + import javax.jdo.Query; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.query.QueryTest; @@ -26,55 +29,61 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Set Result Class.
    - * Keywords: query
    - * Assertion ID: A14.6-19.
    - * Assertion Description: void setResultClass (Class resultClass); Specify the class to be - * used to return result instances. + *Title: Set Result Class. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6-19. + *
    + *Assertion Description: + * void setResultClass (Class resultClass); + * Specify the class to be used to return result instances. */ public class SetResultClass extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6-19 (SetResultClass) failed: "; - - /** The expected results of valid queries. */ - private Object[] expectedResult = { - Arrays.asList( - new Object[] { - new FullName("emp1First", "emp1Last"), - new FullName("emp2First", "emp2Last"), - new FullName("emp3First", "emp3Last"), - new FullName("emp4First", "emp4Last"), - new FullName("emp5First", "emp5Last") - }) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetResultClass.class); - } - - /** */ - public void testPositive() { - int index = 0; - Query query = getPM().newQuery(Person.class); - query.setResultClass(FullName.class); - query.setResult("firstname, lastname"); - String singleStringQuery = "SELECT firstname, lastname INTO FullName FROM Person"; - executeJDOQuery( - ASSERTION_FAILED, query, singleStringQuery, false, null, expectedResult[index], true); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-19 (SetResultClass) failed: "; + + /** + * The expected results of valid queries. + */ + private Object[] expectedResult = { + Arrays.asList(new Object[] { + new FullName("emp1First", "emp1Last"), + new FullName("emp2First", "emp2Last"), + new FullName("emp3First", "emp3Last"), + new FullName("emp4First", "emp4Last"), + new FullName("emp5First", "emp5Last")}) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetResultClass.class); + } + + /** */ + public void testPositive() { + int index = 0; + Query query = getPM().newQuery(Person.class); + query.setResultClass(FullName.class); + query.setResult("firstname, lastname"); + String singleStringQuery = + "SELECT firstname, lastname INTO FullName FROM Person"; + executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery, + false, null, expectedResult[index], true); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/SetUnique.java b/tck/src/main/java/org/apache/jdo/tck/query/api/SetUnique.java index 1405cb065..6bb32609c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/SetUnique.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/SetUnique.java @@ -5,75 +5,86 @@ * 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 + * + * 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.jdo.tck.query.api; import javax.jdo.Query; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Set Unique.
    - * Keywords: query
    - * Assertion ID: A14.6-18.
    - * Assertion Description: void setUnique (boolean unique); Specify that there is a single - * result of the query. + *Title: Set Unique. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6-18. + *
    + *Assertion Description: + * void setUnique (boolean unique); + * Specify that there is a single result of the query. */ public class SetUnique extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6-18 (SetUnique) failed: "; - - /** The expected results of valid queries. */ - private Object[] expectedResult = { - getTransientCompanyModelInstance("emp1"), - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetUnique.class); - } - - /** */ - public void testPositive() { - int index = 0; - Query query = getPM().newQuery(Person.class); - query.setUnique(true); - query.setFilter("lastname == 'emp1Last'"); - String singleStringQuery = "SELECT FROM Person WHERE lastname == 'emp1Last'"; - executeJDOQuery( - ASSERTION_FAILED, query, singleStringQuery, false, null, expectedResult[index], true); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-18 (SetUnique) failed: "; + + /** + * The expected results of valid queries. + */ + private Object[] expectedResult = { + getTransientCompanyModelInstance("emp1"), + getTransientCompanyModelInstancesAsList( + new String[]{"emp1", "emp2", "emp3", "emp4", "emp5"}) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetUnique.class); + } + + /** */ + public void testPositive() { + int index = 0; + Query query = getPM().newQuery(Person.class); + query.setUnique(true); + query.setFilter("lastname == 'emp1Last'"); + String singleStringQuery = + "SELECT FROM Person WHERE lastname == 'emp1Last'"; + executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery, + false, null, expectedResult[index], true); - index = 1; - query = getPM().newQuery(Person.class); - query.setUnique(false); - singleStringQuery = "SELECT FROM Person"; - executeJDOQuery( - ASSERTION_FAILED, query, singleStringQuery, false, null, expectedResult[index], true); - } + index = 1; + query = getPM().newQuery(Person.class); + query.setUnique(false); + singleStringQuery = "SELECT FROM Person"; + executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery, + false, null, expectedResult[index], true); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/SetterReplacePreviousValues.java b/tck/src/main/java/org/apache/jdo/tck/query/api/SetterReplacePreviousValues.java index 18780eaa8..78e08c2ef 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/SetterReplacePreviousValues.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/SetterReplacePreviousValues.java @@ -5,19 +5,21 @@ * 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 + * + * 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.jdo.tck.query.api; import javax.jdo.Query; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.Employee; @@ -26,167 +28,139 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Setter replace previous values.
    - * Keywords: query
    - * Assertion ID: A14.6.15.
    - * Assertion Description: All of these methods replace the previously set query element, by - * the parameter. [The methods are not additive]. + *Title: Setter replace previous values. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.15. + *
    + *Assertion Description: + * All of these methods replace the previously set query element, by the + * parameter. [The methods are not additive]. */ -public class SetterReplacePreviousValues extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.15 (SetterReplacePreviousValues) failed: "; - - /** - * The array of valid queries which may be executed as single string queries and as API queries. - */ - private static final QueryElementHolder[] VALID_QUERIES = { - // replace parameter declaration - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "deptid == param", - /*VARIABLES*/ null, - /*PARAMETERS*/ "String x", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - // replace filter setting - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "personid == 1L", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - // replace variable declaration - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employees.contains(e) && e.personid == 1", - /*VARIABLES*/ "Employee e1; Employee e2", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null) - }; - /** The expected results of valid queries. */ - private Object[] expectedResult = { - // replace parameter declaration - getTransientCompanyModelInstancesAsList(new String[] {"dept1"}), - // replace filter setting - getTransientCompanyModelInstancesAsList(new String[] {"emp2"}), - // replace variable declaration - getTransientCompanyModelInstancesAsList(new String[] {"dept1"}) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetterReplacePreviousValues.class); - } - - /** */ - public void testPositive() { - // replace parameter declaration - int index = 0; - Query query = VALID_QUERIES[index].getAPIQuery(getPM()); - query.declareParameters("long param"); - Object[] parameters = new Object[] {Long.valueOf(1)}; - executeJDOQuery( - ASSERTION_FAILED, - query, - VALID_QUERIES[index].toString(), - false, - parameters, - expectedResult[index], - true); - query = VALID_QUERIES[index].getSingleStringQuery(getPM()); - query.declareParameters("long param"); - executeJDOQuery( - ASSERTION_FAILED, - query, - VALID_QUERIES[index].toString(), - false, - parameters, - expectedResult[index], - true); - - // replace filter setting - index++; - query = VALID_QUERIES[index].getAPIQuery(getPM()); - query.setFilter("personid == 2L"); - executeJDOQuery( - ASSERTION_FAILED, - query, - VALID_QUERIES[index].toString(), - false, - null, - expectedResult[index], - true); - query = VALID_QUERIES[index].getSingleStringQuery(getPM()); - query.setFilter("personid == 2L"); - executeJDOQuery( - ASSERTION_FAILED, - query, - VALID_QUERIES[index].toString(), - false, - null, - expectedResult[index], - true); +public class SetterReplacePreviousValues extends QueryTest { - // replace variable declaration - index++; - query = VALID_QUERIES[index].getAPIQuery(getPM()); - query.declareVariables("Employee e"); - executeJDOQuery( - ASSERTION_FAILED, - query, - VALID_QUERIES[index].toString(), - false, - null, - expectedResult[index], - true); - query = VALID_QUERIES[index].getSingleStringQuery(getPM()); - query.declareVariables("Employee e"); - executeJDOQuery( - ASSERTION_FAILED, - query, - VALID_QUERIES[index].toString(), - false, - null, - expectedResult[index], - true); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.15 (SetterReplacePreviousValues) failed: "; + + /** + * The array of valid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] VALID_QUERIES = { + // replace parameter declaration + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "deptid == param", + /*VARIABLES*/ null, + /*PARAMETERS*/ "String x", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + // replace filter setting + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "personid == 1L", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + // replace variable declaration + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.contains(e) && e.personid == 1", + /*VARIABLES*/ "Employee e1; Employee e2", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** + * The expected results of valid queries. + */ + private Object[] expectedResult = { + // replace parameter declaration + getTransientCompanyModelInstancesAsList(new String[]{"dept1"}), + // replace filter setting + getTransientCompanyModelInstancesAsList(new String[]{"emp2"}), + // replace variable declaration + getTransientCompanyModelInstancesAsList(new String[]{"dept1"}) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetterReplacePreviousValues.class); + } + + /** */ + public void testPositive() { + // replace parameter declaration + int index = 0; + Query query = VALID_QUERIES[index].getAPIQuery(getPM()); + query.declareParameters("long param"); + Object[] parameters = new Object[] {Long.valueOf(1)}; + executeJDOQuery(ASSERTION_FAILED, query, VALID_QUERIES[index].toString(), false, + parameters, expectedResult[index], true); + query = VALID_QUERIES[index].getSingleStringQuery(getPM()); + query.declareParameters("long param"); + executeJDOQuery(ASSERTION_FAILED, query, VALID_QUERIES[index].toString(), false, + parameters, expectedResult[index], true); + + // replace filter setting + index++; + query = VALID_QUERIES[index].getAPIQuery(getPM()); + query.setFilter("personid == 2L"); + executeJDOQuery(ASSERTION_FAILED, query, VALID_QUERIES[index].toString(), false, + null, expectedResult[index], true); + query = VALID_QUERIES[index].getSingleStringQuery(getPM()); + query.setFilter("personid == 2L"); + executeJDOQuery(ASSERTION_FAILED, query, VALID_QUERIES[index].toString(), false, + null, expectedResult[index], true); + + // replace variable declaration + index++; + query = VALID_QUERIES[index].getAPIQuery(getPM()); + query.declareVariables("Employee e"); + executeJDOQuery(ASSERTION_FAILED, query, VALID_QUERIES[index].toString(), false, + null, expectedResult[index], true); + query = VALID_QUERIES[index].getSingleStringQuery(getPM()); + query.declareVariables("Employee e"); + executeJDOQuery(ASSERTION_FAILED, query, VALID_QUERIES[index].toString(), false, + null, expectedResult[index], true); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/SingleStringQuery.java b/tck/src/main/java/org/apache/jdo/tck/query/api/SingleStringQuery.java index 7a5a95783..77cca23dd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/SingleStringQuery.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/SingleStringQuery.java @@ -5,20 +5,23 @@ * 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 + * + * 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.jdo.tck.query.api; import java.math.BigDecimal; + import javax.jdo.Query; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.FullTimeEmployee; import org.apache.jdo.tck.query.QueryTest; @@ -26,91 +29,96 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Single String Query.
    - * Keywords: query
    - * Assertion ID: A14.6-23.
    - * Assertion Description: The single string query is first parsed to yield the result, - * result class, filter, variable list, parameter list, import list, grouping, ordering, and range. - * Then, the values specified in APIs setResult, setResultClass, setFilter, declareVariables, - * declareParamters, declareImports, setGrouping, setOrdering, and setRange override the - * corresponding settings from the single string query. + *Title: Single String Query. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6-23. + *
    + *Assertion Description: + * The single string query is first parsed to yield the result, + * result class, filter, variable list, parameter list, import list, + * grouping, ordering, and range. + * Then, the values specified in APIs setResult, setResultClass, + * setFilter, declareVariables, declareParamters, declareImports, + * setGrouping, setOrdering, and setRange + * override the corresponding settings from the single string query. */ public class SingleStringQuery extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6-23 (SingleStringQuery) failed: "; - - private static String singleStringQuery = - "SELECT UNIQUE firstname, lastname " - + "INTO FullName " - + "FROM FullTimeEmployee " - + "WHERE salary > 1000 & " - + " projects.contains(p) & p.budget > limit & " - + " firstname == 'emp1First' " - + "VARIABLES Project p " - + "PARAMETERS BigDecimal limit " - + "import org.apache.jdo.tck.query.result.classes.FullName; " - + "import org.apache.jdo.tck.pc.company.FullTimeEmployee; " - + "import org.apache.jdo.tck.pc.company.Project; " - + "import java.math.BigDecimal; " - + "GROUP BY firstname, lastname " - + "ORDER BY lastname ASCENDING " - + "RANGE 0,5"; - - /** The expected results of valid queries. */ - private Object[] expectedResult = { - new FullName("emp1First", "emp1Last"), - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp5"}) - }; - - /** Parameters of valid queries. */ - private Object[][] parameters = {{new BigDecimal("2000")}}; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SingleStringQuery.class); - } - - /** */ - public void testPositive() { - int index = 0; - Query query = getPM().newQuery(singleStringQuery); - executeJDOQuery( - ASSERTION_FAILED, - query, - singleStringQuery, - true, - parameters[index], - expectedResult[index], - true); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-23 (SingleStringQuery) failed: "; + + private static String singleStringQuery = + "SELECT UNIQUE firstname, lastname " + + "INTO FullName " + + "FROM FullTimeEmployee " + + "WHERE salary > 1000 & " + + " projects.contains(p) & p.budget > limit & " + + " firstname == 'emp1First' " + + "VARIABLES Project p " + + "PARAMETERS BigDecimal limit " + + "import org.apache.jdo.tck.query.result.classes.FullName; " + + "import org.apache.jdo.tck.pc.company.FullTimeEmployee; " + + "import org.apache.jdo.tck.pc.company.Project; " + + "import java.math.BigDecimal; " + + "GROUP BY firstname, lastname " + + "ORDER BY lastname ASCENDING " + + "RANGE 0,5"; - index = 1; - String singleStringQuery = "SELECT FROM FullTimeEmployee"; - query.setUnique(false); - query.setResult(null); - query.setResultClass(null); - query.setClass(FullTimeEmployee.class); - query.setFilter(null); - query.declareVariables(null); - query.declareParameters(null); - query.declareImports(null); - query.setGrouping(null); - query.setOrdering(null); - query.setRange(null); - executeJDOQuery( - ASSERTION_FAILED, query, singleStringQuery, false, null, expectedResult[index], true); - } + /** + * The expected results of valid queries. + */ + private Object[] expectedResult = { + new FullName("emp1First", "emp1Last"), + getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp2", "emp5"}) + }; + + /** Parameters of valid queries. */ + private Object[][] parameters = { + {new BigDecimal("2000")} + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SingleStringQuery.class); + } + + /** */ + public void testPositive() { + int index = 0; + Query query = getPM().newQuery(singleStringQuery); + executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery, + true, parameters[index], expectedResult[index], true); + + index = 1; + String singleStringQuery = "SELECT FROM FullTimeEmployee"; + query.setUnique(false); + query.setResult(null); + query.setResultClass(null); + query.setClass(FullTimeEmployee.class); + query.setFilter(null); + query.declareVariables(null); + query.declareParameters(null); + query.declareImports(null); + query.setGrouping(null); + query.setOrdering(null); + query.setRange(null); + executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery, false, null, + expectedResult[index], true); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/UnmodifiableQuery.java b/tck/src/main/java/org/apache/jdo/tck/query/api/UnmodifiableQuery.java index 2f65d9ac8..5c9f72ceb 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/api/UnmodifiableQuery.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/api/UnmodifiableQuery.java @@ -5,21 +5,24 @@ * 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 + * + * 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.jdo.tck.query.api; import java.util.Arrays; + import javax.jdo.JDOUserException; import javax.jdo.Query; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.Person; @@ -28,157 +31,163 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Unmodifiable Query.
    - * Keywords: query
    - * Assertion ID: A14.6-22.
    - * Assertion Description: The Unmodifiable option, when set to true, disallows further - * modification of the query, except for specifying the range and result class and ignoreCache - * option. + *Title: Unmodifiable Query. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6-22. + *
    + *Assertion Description: + * The Unmodifiable option, when set to true, + * disallows further modification of the query, + * except for specifying the range and result class and ignoreCache option. */ public class UnmodifiableQuery extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6-22 (UnmodifiableQuery) failed: "; - - private static String singleStringQuery = - "SELECT firstname, lastname FROM org.apache.jdo.tck.pc.company.Person"; - - /** The expected results of valid queries. */ - private Object[] expectedResult = { - Arrays.asList( - new Object[] { - new FullName("emp1First", "emp1Last"), - new FullName("emp2First", "emp2Last"), - new FullName("emp3First", "emp3Last"), - new FullName("emp4First", "emp4Last"), - new FullName("emp5First", "emp5Last") - }) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(UnmodifiableQuery.class); - } - - /** */ - public void testPositive() { - int index = 0; - Query query = getPM().newQuery(singleStringQuery); - query.setUnmodifiable(); - query.setResultClass(FullName.class); - query.setRange(0, 5); - query.setIgnoreCache(true); - executeJDOQuery( - ASSERTION_FAILED, query, singleStringQuery, false, null, expectedResult[index], true); - - query = getPM().newNamedQuery(Person.class, "unmodifiable"); - query.setResultClass(FullName.class); - query.setRange(0, 5); - query.setIgnoreCache(true); - executeJDOQuery( - ASSERTION_FAILED, query, singleStringQuery, false, null, expectedResult[index], true); - } - - /** */ - public void testNegative() { - Query query = getPM().newQuery(singleStringQuery); - query.setUnmodifiable(); - checkSetters(query); - - query = getPM().newNamedQuery(Person.class, "unmodifiable"); - checkSetters(query); - } - - private void checkSetters(Query query) { - checkSetResult(query); - checkSetClass(query); - checkSetFilter(query); - checkDeclareVariables(query); - checkDeclareParameters(query); - checkDeclareImports(query); - checkSetOrdering(query); - checkSetGrouping(query); - checkSetOrdering(query); - } - - private void checkSetResult(Query query) { - try { - query.setResult("firstname, lastname"); - methodFailed("setResult()"); - } catch (JDOUserException e) { + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6-22 (UnmodifiableQuery) failed: "; + + private static String singleStringQuery = + "SELECT firstname, lastname FROM org.apache.jdo.tck.pc.company.Person"; + + /** + * The expected results of valid queries. + */ + private Object[] expectedResult = { + Arrays.asList(new Object[] { + new FullName("emp1First", "emp1Last"), + new FullName("emp2First", "emp2Last"), + new FullName("emp3First", "emp3Last"), + new FullName("emp4First", "emp4Last"), + new FullName("emp5First", "emp5Last")}) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(UnmodifiableQuery.class); } - } - - private void checkSetClass(Query query) { - try { - query.setClass(Employee.class); - methodFailed("setClass()"); - } catch (JDOUserException e) { + + /** */ + public void testPositive() { + int index = 0; + Query query = getPM().newQuery(singleStringQuery); + query.setUnmodifiable(); + query.setResultClass(FullName.class); + query.setRange(0, 5); + query.setIgnoreCache(true); + executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery, + false, null, expectedResult[index], true); + + query = getPM().newNamedQuery(Person.class, "unmodifiable"); + query.setResultClass(FullName.class); + query.setRange(0, 5); + query.setIgnoreCache(true); + executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery, + false, null, expectedResult[index], true); } - } - - private void checkSetFilter(Query query) { - try { - query.setFilter("firstname == 'emp1First'"); - methodFailed("setFilter()"); - } catch (JDOUserException e) { + + /** */ + public void testNegative() { + Query query = getPM().newQuery(singleStringQuery); + query.setUnmodifiable(); + checkSetters(query); + + query = getPM().newNamedQuery(Person.class, "unmodifiable"); + checkSetters(query); } - } - - private void checkDeclareVariables(Query query) { - try { - query.declareVariables("Employee emp"); - methodFailed("declareVariables()"); - } catch (JDOUserException e) { + + private void checkSetters(Query query) { + checkSetResult(query); + checkSetClass(query); + checkSetFilter(query); + checkDeclareVariables(query); + checkDeclareParameters(query); + checkDeclareImports(query); + checkSetOrdering(query); + checkSetGrouping(query); + checkSetOrdering(query); } - } - - private void checkDeclareParameters(Query query) { - try { - query.declareParameters("Employee emp"); - methodFailed("declareParameters()"); - } catch (JDOUserException e) { + + private void checkSetResult(Query query) { + try { + query.setResult("firstname, lastname"); + methodFailed("setResult()"); + } catch (JDOUserException e) { + } } - } - - private void checkDeclareImports(Query query) { - try { - query.declareImports("import org.apache.jdo.tck.pc.company.Employee"); - methodFailed("declareImports()"); - } catch (JDOUserException e) { + + private void checkSetClass(Query query) { + try { + query.setClass(Employee.class); + methodFailed("setClass()"); + } catch (JDOUserException e) { + } } - } - - private void checkSetGrouping(Query query) { - try { - query.setGrouping("firstname"); - methodFailed("setGrouping()"); - } catch (JDOUserException e) { + + private void checkSetFilter(Query query) { + try { + query.setFilter("firstname == 'emp1First'"); + methodFailed("setFilter()"); + } catch (JDOUserException e) { + } } - } - - private void checkSetOrdering(Query query) { - try { - query.setOrdering("firstname ASCENDING"); - methodFailed("setOrdering()"); - } catch (JDOUserException e) { + + private void checkDeclareVariables(Query query) { + try { + query.declareVariables("Employee emp"); + methodFailed("declareVariables()"); + } catch (JDOUserException e) { + } + } + + private void checkDeclareParameters(Query query) { + try { + query.declareParameters("Employee emp"); + methodFailed("declareParameters()"); + } catch (JDOUserException e) { + } + } + + private void checkDeclareImports(Query query) { + try { + query.declareImports("import org.apache.jdo.tck.pc.company.Employee"); + methodFailed("declareImports()"); + } catch (JDOUserException e) { + } + } + + private void checkSetGrouping(Query query) { + try { + query.setGrouping("firstname"); + methodFailed("setGrouping()"); + } catch (JDOUserException e) { + } + } + + private void checkSetOrdering(Query query) { + try { + query.setOrdering("firstname ASCENDING"); + methodFailed("setOrdering()"); + } catch (JDOUserException e) { + } + } + + private void methodFailed(String method) { + fail(ASSERTION_FAILED + method + + " on an unmodifiable query must throw JDOUserException." ); } - } - - private void methodFailed(String method) { - fail(ASSERTION_FAILED + method + " on an unmodifiable query must throw JDOUserException."); - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/delete/DeleteCallback.java b/tck/src/main/java/org/apache/jdo/tck/query/delete/DeleteCallback.java index bbefb0710..bd0383c71 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/delete/DeleteCallback.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/delete/DeleteCallback.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -22,6 +22,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; + import javax.jdo.JDOHelper; import javax.jdo.PersistenceManager; import javax.jdo.Query; @@ -29,6 +30,8 @@ import javax.jdo.listener.DeleteLifecycleListener; import javax.jdo.listener.InstanceLifecycleEvent; import javax.jdo.listener.StoreLifecycleListener; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.Employee; @@ -42,436 +45,457 @@ import org.apache.jdo.tck.util.ConversionHelper; /** - * Title: Delete Persistent All.
    - * Keywords: query
    - * Assertion ID: A14.8-4
    - * Assertion Description: Dirty instances of affected classes are first flushed to the - * datastore. Instances already in the cache when deleted via these methods or brought into the - * cache as a result of these methods undergo the life cycle transitions as if deletePersistent had - * been called on them. That is, if an affected class implements the DeleteCallback interface, the - * instances to be deleted are instantiated in memory and the jdoPreDelete method is called prior to - * deleting the instance in the datastore. If any LifecycleListener instances are registered with - * affected classes, these listeners are called for each deleted instance. Before returning control - * to the application, instances of affected classes in the cache are refreshed by the - * implementation so their status in the cache reflects whether they were deleted from the - * datastore. + *Title: Delete Persistent All. + *
    + *Keywords: query + *
    + *Assertion ID: A14.8-4 + *
    + *Assertion Description: + * Dirty instances of affected classes are first flushed to the datastore. + * Instances already in the cache when deleted via these methods + * or brought into the cache as a result of these methods + * undergo the life cycle transitions as if deletePersistent + * had been called on them. + * That is, if an affected class implements the DeleteCallback interface, + * the instances to be deleted are instantiated in memory and + * the jdoPreDelete method is called prior + * to deleting the instance in the datastore. + * If any LifecycleListener instances are registered with affected classes, + * these listeners are called for each deleted instance. + * Before returning control to the application, + * instances of affected classes in the cache are refreshed + * by the implementation so their status in the cache reflects + * whether they were deleted from the datastore. */ public class DeleteCallback extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.8-4 (DeleteCallback) failed: "; - - /** - * The array of valid queries which may be executed as single string queries and as API queries. - */ - private static final QueryElementHolder[] VALID_QUERIES = { - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ PrimitiveTypes.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null) - }; - - /** The expected results of valid queries. */ - private List[] expectedResult = { - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}), - getTransientMylibInstancesAsList( - new String[] { - "primitiveTypesPositive", - "primitiveTypesNegative", - "primitiveTypesCharacterStringLiterals" - }) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DeleteCallback.class); - } - - /** */ - public void testRelationshipsAPI() { - queryUpdateDeleteVerify(0, false, "middlename"); - } - - /** */ - public void testRelationshipsSingleString() { - queryUpdateDeleteVerify(0, true, "middlename"); - } - - /** */ - public void testNoRelationshipsAPI() { - queryUpdateDeleteVerify(1, false, "stringNull"); - } - - /** */ - public void testNoRelationshipsSingleString() { - queryUpdateDeleteVerify(1, true, "stringNull"); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - addTearDownClass(MylibReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - loadAndPersistMylib(getPM()); - } - - /** - * Adds a lifecycle listener to the persistence manager. - * Converts the query element holder instance refered to by argument - * index to a JDO query instance based on argument - * asSingleString. - * Executes the query instance and marks all queried pc instances as dirty - * by calling {@link JDOHelper#makeDirty(java.lang.Object, java.lang.String)}. - * Passes argument fieldName to that call. - * Afterwards, calls {@link Query#deletePersistentAll()}, and - * verifies the lifecycle callbacks and the lifecycle states. - * @param index the index of the query element holder instance - * @param fieldName the field name passed as argument to - * {@link JDOHelper#makeDirty(java.lang.Object, java.lang.String) - * @param asSingleString determines if the query is executed as - * single string query or as API query. - */ - private void queryUpdateDeleteVerify(int index, boolean asSingleString, String fieldName) { - PersistenceManager pm = getPM(); - Transaction transaction = pm.currentTransaction(); - transaction.begin(); - try { - LifecycleVerifier lifecycleVerifier; - Query query = - asSingleString - ? VALID_QUERIES[index].getSingleStringQuery(pm) - : VALID_QUERIES[index].getAPIQuery(pm); - - Collection result = executeQuery(query, index, asSingleString); - try { - lifecycleVerifier = new LifecycleVerifier(result); - pm.addInstanceLifecycleListener( - lifecycleVerifier, new Class[] {VALID_QUERIES[index].getCandidateClass()}); - updateInstances(result, fieldName); - deleteInstances(query, index, asSingleString, result.size()); - } finally { - query.close(result); - } - - lifecycleVerifier.verifyCallbacksAndStates(); - } finally { - if (transaction.isActive()) { - transaction.rollback(); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.8-4 (DeleteCallback) failed: "; + + /** + * The array of valid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] VALID_QUERIES = { + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ PrimitiveTypes.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** + * The expected results of valid queries. + */ + private List[] expectedResult = { + getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}), + getTransientMylibInstancesAsList(new String[]{ + "primitiveTypesPositive", + "primitiveTypesNegative", + "primitiveTypesCharacterStringLiterals"}) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DeleteCallback.class); } - } - - /** - * Executes the given query, checks and returns the query result. Note: This mthod does not close - * the query result. - * - * @param query the query. - * @param index the index of the query element holder instance which was used to created the given - * query. - * @param asSingleString indicates if the given query was created using API methods or if it was - * created by a single string. - * @return the query result. - */ - private Collection executeQuery(Query query, int index, boolean asSingleString) { - if (logger.isDebugEnabled()) { - if (asSingleString) { - logger.debug("Executing single string query: " + VALID_QUERIES[index]); - } else { - logger.debug("Executing API query: " + VALID_QUERIES[index]); - } + + /** */ + public void testRelationshipsAPI() { + queryUpdateDeleteVerify(0, false, "middlename"); } - - Collection result = (Collection) query.execute(); - - if (logger.isDebugEnabled()) { - logger.debug("Query result: " + ConversionHelper.convertObjectArrayElements(result)); + + /** */ + public void testRelationshipsSingleString() { + queryUpdateDeleteVerify(0, true, "middlename"); } - - checkQueryResultWithoutOrder(ASSERTION_FAILED, result, expectedResult[index]); - return result; - } - - /** - * Makes all instances in the given collection dirty. - * If instances are employees, then all relationships are cleared. - * @param instances the instances - * @param fieldName the field name passed as argument to - * {@link JDOHelper#makeDirty(java.lang.Object, java.lang.String) - */ - private void updateInstances(Collection instances, String fieldName) { - for (Iterator i = instances.iterator(); i.hasNext(); ) { - Object pc = i.next(); - - // clear employee relationships - if (pc instanceof Employee) { - Employee employee = (Employee) pc; - if (employee.getDentalInsurance() != null) { - employee.getDentalInsurance().setEmployee(null); - } - if (employee.getMedicalInsurance() != null) { - employee.getMedicalInsurance().setEmployee(null); - } - if (employee.getDepartment() != null) { - ((Department) employee.getDepartment()).removeEmployee(employee); - } - if (employee.getFundingDept() != null) { - ((Department) employee.getFundingDept()).removeEmployee(employee); - } - if (employee.getManager() != null) { - ((Employee) employee.getManager()).removeFromTeam(employee); - } - if (employee.getMentor() != null) { - employee.getMentor().setProtege(null); - } - if (employee.getProtege() != null) { - employee.getProtege().setMentor(null); - } - if (employee.getHradvisor() != null) { - ((Employee) employee.getHradvisor()).removeAdvisee(employee); - } - if (employee.getReviewedProjects() != null) { - for (Iterator it = employee.getReviewedProjects().iterator(); it.hasNext(); ) { - Project other = (Project) it.next(); - other.removeReviewer(employee); - } - } - if (employee.getProjects() != null) { - for (Iterator it = employee.getProjects().iterator(); it.hasNext(); ) { - Project other = (Project) it.next(); - other.removeMember(employee); - } - } - if (employee.getTeam() != null) { - for (Iterator it = employee.getTeam().iterator(); it.hasNext(); ) { - Employee other = (Employee) it.next(); - other.setManager(null); - } - } - if (employee.getHradvisees() != null) { - for (Iterator it = employee.getHradvisees().iterator(); it.hasNext(); ) { - Employee other = (Employee) it.next(); - other.setHradvisor(employee); - } - } - } - - // make the instance dirty. - if (logger.isDebugEnabled()) { - logger.debug("Calling JDOHelper.makeDirty(" + pc + ", \"" + fieldName + "\")"); - } - JDOHelper.makeDirty(pc, fieldName); + + /** */ + public void testNoRelationshipsAPI() { + queryUpdateDeleteVerify(1, false, "stringNull"); } - } - - /** - * Calls {@link Query#deletePersistentAll()} on the given query. - * - * @param query the query. - * @param index the index of the query element holder instance which was used to created the given - * query. - * @param asSingleString indicates if the given query was created using API methods or if it was - * created by a single string. - * @param expectedNumberOfDeletedInstances the expected number of deleted instances. - */ - private void deleteInstances( - Query query, int index, boolean asSingleString, int expectedNumberOfDeletedInstances) { - if (logger.isDebugEnabled()) { - if (asSingleString) { - logger.debug("Deleting persistent by single string query: " + VALID_QUERIES[index]); - } else { - logger.debug("Deleting persistent by API query: " + VALID_QUERIES[index]); - } + + /** */ + public void testNoRelationshipsSingleString() { + queryUpdateDeleteVerify(1, true, "stringNull"); } - long nr = query.deletePersistentAll(); - - if (logger.isDebugEnabled()) { - logger.debug(nr + " objects deleted."); - } - - if (nr != expectedNumberOfDeletedInstances) { - fail( - ASSERTION_FAILED, - "deletePersistentAll returned " - + nr - + ", expected is " - + expectedNumberOfDeletedInstances - + ". Query: " - + VALID_QUERIES[index]); - } - } - - /** - * A lifecycle listener which may be added to persistence managers. - * Gathers delete events and store events and keeps those - * in a list. - * Method {@link LifecycleVerifier#verifyCallbacksAndStates()} - * may be called to check if the right events have been called - * on all expected instances. - * The expected instances are passed through - * {@link LifecycleVerifier#LifecycleVerifier(Collection). - */ - private class LifecycleVerifier implements DeleteLifecycleListener, StoreLifecycleListener { - - /** The oids of expected pc instances. */ - private Collection expectedOids = new HashSet(); - - /** The list of events. */ - private List events = new ArrayList(); - /** - * Argument expectedPCInstances holds pc instances which are expected to be sources - * of events. - * - * @param expectedPCInstances the pc instances which are expected to be sources of events. + * @see org.apache.jdo.tck.JDO_Test#localSetUp() */ - public LifecycleVerifier(Collection expectedPCInstances) { - for (Iterator i = expectedPCInstances.iterator(); i.hasNext(); ) { - this.expectedOids.add(JDOHelper.getObjectId(i.next())); - } + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + addTearDownClass(MylibReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + loadAndPersistMylib(getPM()); } - + /** - * Verifies if the right events have been called for all expected pc instances. All store events - * must have been fired before the first delete event has been fired. Furthermore, checks if pc - * instances kept in delete events have state persistent-deleted. The test case fails if one of - * these conditions is violated. + * Adds a lifecycle listener to the persistence manager. + * Converts the query element holder instance refered to by argument + * index to a JDO query instance based on argument + * asSingleString. + * Executes the query instance and marks all queried pc instances as dirty + * by calling {@link JDOHelper#makeDirty(java.lang.Object, java.lang.String)}. + * Passes argument fieldName to that call. + * Afterwards, calls {@link Query#deletePersistentAll()}, and + * verifies the lifecycle callbacks and the lifecycle states. + * @param index the index of the query element holder instance + * @param fieldName the field name passed as argument to + * {@link JDOHelper#makeDirty(java.lang.Object, java.lang.String) + * @param asSingleString determines if the query is executed as + * single string query or as API query. */ - public void verifyCallbacksAndStates() { - if (logger.isDebugEnabled()) { - logger.debug("Verifying callbacks and states."); - } - // The two collections are filled iterating through the list of - // events. Finally, they are compared against field expectedOids. - // Note: Set implementations are used instead of list - // implementations to eliminate duplicates. Duplicates may occur - // if multiple updates or deletions are executed for the same - // pc instances. - Collection oidsOfDeletedInstances = new HashSet(); - Collection oidsOfUpdateInstances = new HashSet(); - - boolean hasDeleteEventBeenPassed = false; - int size = events.size(); - for (int i = 0; i < size; i++) { - InstanceLifecycleEvent event = (InstanceLifecycleEvent) this.events.get(i); - Object source = event.getSource(); - int eventType = event.getEventType(); - if (eventType == InstanceLifecycleEvent.DELETE) { - if (logger.isDebugEnabled()) { - logger.debug("Verifying delete event on " + JDOHelper.getObjectId(source)); - } - hasDeleteEventBeenPassed = true; - if (!JDOHelper.isDeleted(source)) { - fail( - ASSERTION_FAILED, "PC instance must have persistent deleted " + "state: " + source); - } - oidsOfDeletedInstances.add(JDOHelper.getObjectId(source)); - } else if (eventType == InstanceLifecycleEvent.STORE) { - if (logger.isDebugEnabled()) { - logger.debug("Verifying store event on " + JDOHelper.getObjectId(source)); - } - - if (hasDeleteEventBeenPassed) { - fail( - ASSERTION_FAILED, - "PC instances must not be flushed " + "after delete has been executed."); - } - oidsOfUpdateInstances.add(JDOHelper.getObjectId(source)); + private void queryUpdateDeleteVerify(int index, + boolean asSingleString, String fieldName) { + PersistenceManager pm = getPM(); + Transaction transaction = pm.currentTransaction(); + transaction.begin(); + try + { + LifecycleVerifier lifecycleVerifier; + Query query = asSingleString ? + VALID_QUERIES[index].getSingleStringQuery(pm) : + VALID_QUERIES[index].getAPIQuery(pm); + + Collection result = executeQuery(query, index, asSingleString); + try { + lifecycleVerifier = new LifecycleVerifier(result); + pm.addInstanceLifecycleListener(lifecycleVerifier, + new Class[]{VALID_QUERIES[index].getCandidateClass()}); + updateInstances(result, fieldName); + deleteInstances(query, index, asSingleString, result.size()); + } finally + { + query.close(result); + } + + lifecycleVerifier.verifyCallbacksAndStates(); + } finally { + if (transaction.isActive()) { + transaction.rollback(); + } } - } - - if (!equalsCollection(oidsOfDeletedInstances, this.expectedOids)) { - String lf = System.getProperty("line.separator"); - fail( - ASSERTION_FAILED, - "Got delete events for oids " - + oidsOfDeletedInstances - + '.' - + lf - + "Expected deleted events for oids " - + this.expectedOids - + '.'); - } else if (!oidsOfUpdateInstances.containsAll(this.expectedOids)) { - String lf = System.getProperty("line.separator"); - fail( - ASSERTION_FAILED, - "Got store events for oids " - + oidsOfUpdateInstances - + '.' - + lf - + "Expected store events for oids " - + this.expectedOids - + '.'); - } } - + /** - * @see DeleteLifecycleListener#preDelete(javax.jdo.listener.InstanceLifecycleEvent) + * Executes the given query, checks and returns the query result. + * Note: This mthod does not close the query result. + * @param query the query. + * @param index the index of the query element holder instance + * which was used to created the given query. + * @param asSingleString indicates if the given query was created + * using API methods or if it was created by a single string. + * @return the query result. */ - public void preDelete(InstanceLifecycleEvent event) { - if (logger.isDebugEnabled()) { - logger.debug("preDelete event: " + JDOHelper.getObjectId(event.getSource())); - } + private Collection executeQuery(Query query, + int index, boolean asSingleString) { + if (logger.isDebugEnabled()) { + if (asSingleString) { + logger.debug("Executing single string query: " + + VALID_QUERIES[index]); + } else { + logger.debug("Executing API query: " + + VALID_QUERIES[index]); + } + } + + Collection result = (Collection) query.execute(); + + if (logger.isDebugEnabled()) { + logger.debug("Query result: " + ConversionHelper. + convertObjectArrayElements(result)); + } + + checkQueryResultWithoutOrder(ASSERTION_FAILED, result, expectedResult[index]); + return result; } - + /** - * @see DeleteLifecycleListener#postDelete(javax.jdo.listener.InstanceLifecycleEvent) + * Makes all instances in the given collection dirty. + * If instances are employees, then all relationships are cleared. + * @param instances the instances + * @param fieldName the field name passed as argument to + * {@link JDOHelper#makeDirty(java.lang.Object, java.lang.String) */ - public void postDelete(InstanceLifecycleEvent event) { - this.events.add(event); - if (logger.isDebugEnabled()) { - logger.debug("postDelete event: " + JDOHelper.getObjectId(event.getSource())); - } + private void updateInstances(Collection instances, String fieldName) { + for (Iterator i = instances.iterator(); i.hasNext(); ) { + Object pc = i.next(); + + // clear employee relationships + if (pc instanceof Employee) { + Employee employee = (Employee) pc; + if (employee.getDentalInsurance() != null) { + employee.getDentalInsurance().setEmployee(null); + } + if (employee.getMedicalInsurance() != null) { + employee.getMedicalInsurance().setEmployee(null); + } + if (employee.getDepartment() != null) { + ((Department)employee.getDepartment()).removeEmployee(employee); + } + if (employee.getFundingDept() != null) { + ((Department)employee.getFundingDept()).removeEmployee(employee); + } + if (employee.getManager() != null) { + ((Employee)employee.getManager()).removeFromTeam(employee); + } + if (employee.getMentor() != null) { + employee.getMentor().setProtege(null); + } + if (employee.getProtege() != null) { + employee.getProtege().setMentor(null); + } + if (employee.getHradvisor() != null) { + ((Employee)employee.getHradvisor()).removeAdvisee(employee); + } + if (employee.getReviewedProjects() != null) { + for (Iterator it=employee.getReviewedProjects().iterator(); + it.hasNext(); ) { + Project other = (Project) it.next(); + other.removeReviewer(employee); + } + } + if (employee.getProjects() != null) { + for (Iterator it=employee.getProjects().iterator(); + it.hasNext(); ) { + Project other = (Project) it.next(); + other.removeMember(employee); + } + } + if (employee.getTeam() != null) { + for (Iterator it=employee.getTeam().iterator(); it.hasNext(); ) { + Employee other = (Employee) it.next(); + other.setManager(null); + } + } + if (employee.getHradvisees() != null) { + for (Iterator it=employee.getHradvisees().iterator(); it.hasNext(); ) { + Employee other = (Employee) it.next(); + other.setHradvisor(employee); + } + } + } + + // make the instance dirty. + if (logger.isDebugEnabled()) { + logger.debug("Calling JDOHelper.makeDirty(" + + pc + ", \"" + fieldName + "\")"); + } + JDOHelper.makeDirty(pc, fieldName); + } } /** - * @see StoreLifecycleListener#preStore(javax.jdo.listener.InstanceLifecycleEvent) + * Calls {@link Query#deletePersistentAll()} on the given query. + * @param query the query. + * @param index the index of the query element holder instance + * which was used to created the given query. + * @param asSingleString indicates if the given query was created + * using API methods or if it was created by a single string. + * @param expectedNumberOfDeletedInstances the expected number + * of deleted instances. */ - public void preStore(InstanceLifecycleEvent event) { - if (logger.isDebugEnabled()) { - logger.debug("preStore event: " + JDOHelper.getObjectId(event.getSource())); - } - } + private void deleteInstances(Query query, int index, + boolean asSingleString, int expectedNumberOfDeletedInstances) { + if (logger.isDebugEnabled()) { + if (asSingleString) { + logger.debug("Deleting persistent by single string query: " + + VALID_QUERIES[index]); + } else { + logger.debug("Deleting persistent by API query: " + + VALID_QUERIES[index]); + } + } + long nr = query.deletePersistentAll(); + + if (logger.isDebugEnabled()) { + logger.debug(nr + " objects deleted."); + } + + if (nr != expectedNumberOfDeletedInstances) { + fail(ASSERTION_FAILED, "deletePersistentAll returned " + nr + + ", expected is " + expectedNumberOfDeletedInstances + + ". Query: " + VALID_QUERIES[index]); + } + } + /** - * @see StoreLifecycleListener#postStore(javax.jdo.listener.InstanceLifecycleEvent) + * A lifecycle listener which may be added to persistence managers. + * Gathers delete events and store events and keeps those + * in a list. + * Method {@link LifecycleVerifier#verifyCallbacksAndStates()} + * may be called to check if the right events have been called + * on all expected instances. + * The expected instances are passed through + * {@link LifecycleVerifier#LifecycleVerifier(Collection). */ - public void postStore(InstanceLifecycleEvent event) { - this.events.add(event); - if (logger.isDebugEnabled()) { - logger.debug("postStore event: " + JDOHelper.getObjectId(event.getSource())); - } + private class LifecycleVerifier + implements DeleteLifecycleListener, StoreLifecycleListener { + + /** The oids of expected pc instances. */ + private Collection expectedOids = new HashSet(); + + /** The list of events. */ + private List events = new ArrayList(); + + /** + * Argument expectedPCInstances holds pc instances + * which are expected to be sources of events. + * @param expectedPCInstances the pc instances + * which are expected to be sources of events. + */ + public LifecycleVerifier(Collection expectedPCInstances) { + for (Iterator i = expectedPCInstances.iterator(); i.hasNext(); ) { + this.expectedOids.add(JDOHelper.getObjectId(i.next())); + } + } + + /** + * Verifies if the right events have been called for all + * expected pc instances. + * All store events must have been fired before the + * first delete event has been fired. + * Furthermore, checks if pc instances kept in + * delete events have state persistent-deleted. + * The test case fails if one of these conditions + * is violated. + */ + public void verifyCallbacksAndStates() { + if (logger.isDebugEnabled()) { + logger.debug("Verifying callbacks and states."); + } + // The two collections are filled iterating through the list of + // events. Finally, they are compared against field expectedOids. + // Note: Set implementations are used instead of list + // implementations to eliminate duplicates. Duplicates may occur + // if multiple updates or deletions are executed for the same + // pc instances. + Collection oidsOfDeletedInstances = new HashSet(); + Collection oidsOfUpdateInstances = new HashSet(); + + boolean hasDeleteEventBeenPassed = false; + int size = events.size(); + for (int i = 0; i < size; i++) { + InstanceLifecycleEvent event = + (InstanceLifecycleEvent) this.events.get(i); + Object source = event.getSource(); + int eventType = event.getEventType(); + if (eventType == InstanceLifecycleEvent.DELETE) { + if (logger.isDebugEnabled()) { + logger.debug("Verifying delete event on " + + JDOHelper.getObjectId(source)); + } + hasDeleteEventBeenPassed = true; + if (!JDOHelper.isDeleted(source)) { + fail(ASSERTION_FAILED, + "PC instance must have persistent deleted " + + "state: " + source); + } + oidsOfDeletedInstances.add(JDOHelper.getObjectId(source)); + } else if (eventType == InstanceLifecycleEvent.STORE) { + if (logger.isDebugEnabled()) { + logger.debug("Verifying store event on " + + JDOHelper.getObjectId(source)); + } + + if (hasDeleteEventBeenPassed) { + fail(ASSERTION_FAILED, + "PC instances must not be flushed " + + "after delete has been executed."); + } + oidsOfUpdateInstances.add(JDOHelper.getObjectId(source)); + } + } + + if (!equalsCollection(oidsOfDeletedInstances, + this.expectedOids)) { + String lf = System.getProperty("line.separator"); + fail(ASSERTION_FAILED, "Got delete events for oids " + + oidsOfDeletedInstances + '.' + lf + + "Expected deleted events for oids " + + this.expectedOids + '.'); + } else if (!oidsOfUpdateInstances.containsAll(this.expectedOids)) { + String lf = System.getProperty("line.separator"); + fail(ASSERTION_FAILED, "Got store events for oids " + + oidsOfUpdateInstances + '.' + lf + + "Expected store events for oids " + + this.expectedOids + '.'); + } + } + + /** + * @see DeleteLifecycleListener#preDelete(javax.jdo.listener.InstanceLifecycleEvent) + */ + public void preDelete(InstanceLifecycleEvent event) { + if (logger.isDebugEnabled()) { + logger.debug("preDelete event: " + + JDOHelper.getObjectId(event.getSource())); + } + } + + /** + * @see DeleteLifecycleListener#postDelete(javax.jdo.listener.InstanceLifecycleEvent) + */ + public void postDelete(InstanceLifecycleEvent event) { + this.events.add(event); + if (logger.isDebugEnabled()) { + logger.debug("postDelete event: " + + JDOHelper.getObjectId(event.getSource())); + } + } + + /** + * @see StoreLifecycleListener#preStore(javax.jdo.listener.InstanceLifecycleEvent) + */ + public void preStore(InstanceLifecycleEvent event) { + if (logger.isDebugEnabled()) { + logger.debug("preStore event: " + + JDOHelper.getObjectId(event.getSource())); + } + } + + /** + * @see StoreLifecycleListener#postStore(javax.jdo.listener.InstanceLifecycleEvent) + */ + public void postStore(InstanceLifecycleEvent event) { + this.events.add(event); + if (logger.isDebugEnabled()) { + logger.debug("postStore event: " + + JDOHelper.getObjectId(event.getSource())); + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/delete/DeletePersistentAll.java b/tck/src/main/java/org/apache/jdo/tck/query/delete/DeletePersistentAll.java index a43cca308..68749b5fe 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/delete/DeletePersistentAll.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/delete/DeletePersistentAll.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,252 +19,228 @@ import java.util.HashMap; import java.util.Map; -import javax.jdo.Query; -import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Insurance; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.Query; +import javax.jdo.Transaction; + /** - * Title: Delete Persistent All.
    - * Keywords: query
    - * Assertion ID: A14.8-1, A14.8-2
    - * Assertion Description: These methods delete the instances of affected classes that pass - * the filter, and all dependent instances. Affected classes are the candidate class and its - * persistence-capable subclasses. - * - *

    The number of instances of affected classes that were deleted is returned. Embedded instances - * and dependent instances are not counted in the return value. + *Title: Delete Persistent All. + *
    + *Keywords: query + *
    + *Assertion ID: A14.8-1, A14.8-2 + *
    + *Assertion Description: + * These methods delete the instances of affected classes + * that pass the filter, and all dependent instances. + * Affected classes are the candidate class and + * its persistence-capable subclasses. + * + * The number of instances of affected classes that were deleted is returned. + * Embedded instances and dependent instances are not counted + * in the return value. */ public class DeletePersistentAll extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.8-1 (DeletePersistentAll) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DeletePersistentAll.class); - } - - /** */ - public void testNoParametersAPI() { - Transaction tx = pm.currentTransaction(); - Query query = null; - Object result = null; - try { - tx.begin(); - String singleStringQuery = "SELECT FROM org.apache.jdo.tck.pc.company.Insurance"; - query = pm.newQuery(Insurance.class); - long expectedNrOfDeletedObjects = 11; - long nr = query.deletePersistentAll(); - if (nr != expectedNrOfDeletedObjects) { - fail( - ASSERTION_FAILED, - "deletePersistentAll returned " - + nr - + ", expected is " - + expectedNrOfDeletedObjects - + ". Query: " - + singleStringQuery); - } - tx.commit(); - } finally { - if (query != null) { - query.close(result); - } - if (tx.isActive()) { - tx.rollback(); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.8-1 (DeletePersistentAll) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DeletePersistentAll.class); } - } - /** */ - public void testNoParametersSingleString() { - Transaction tx = pm.currentTransaction(); - Query query = null; - Object result = null; - try { - tx.begin(); - String singleStringQuery = "SELECT FROM org.apache.jdo.tck.pc.company.Insurance"; - query = pm.newQuery(singleStringQuery); - long expectedNrOfDeletedObjects = 11; - long nr = query.deletePersistentAll(); - if (nr != expectedNrOfDeletedObjects) { - fail( - ASSERTION_FAILED, - "deletePersistentAll returned " - + nr - + ", expected is " - + expectedNrOfDeletedObjects - + ". Query: " - + singleStringQuery); - } - tx.commit(); - } finally { - if (query != null) { - query.close(result); - } - if (tx.isActive()) { - tx.rollback(); - } + /** */ + public void testNoParametersAPI() { + Transaction tx = pm.currentTransaction(); + Query query = null; + Object result = null; + try { + tx.begin(); + String singleStringQuery = "SELECT FROM org.apache.jdo.tck.pc.company.Insurance"; + query = pm.newQuery(Insurance.class); + long expectedNrOfDeletedObjects = 11; + long nr = query.deletePersistentAll(); + if (nr != expectedNrOfDeletedObjects) { + fail(ASSERTION_FAILED, "deletePersistentAll returned " + nr + + ", expected is " + expectedNrOfDeletedObjects + + ". Query: " + singleStringQuery); + } + tx.commit(); + } finally { + if (query != null) { + query.close(result); + } + if (tx.isActive()) { + tx.rollback(); + } + } } - } - - /** */ - public void testObjectArrayParametersAPI() { - Transaction tx = pm.currentTransaction(); - Query query = null; - Object result = null; - try { - tx.begin(); - String singleStringQuery = - "SELECT FROM org.apache.jdo.tck.pc.company.Insurance " - + "WHERE carrier == param PARAMETERS String param"; - query = pm.newQuery(Insurance.class, "carrier == param"); - query.declareParameters("String param"); - Object[] parameters = new Object[] {"Carrier1"}; - long expectedNrOfDeletedObjects = 2; - long nr = query.deletePersistentAll(parameters); - if (nr != expectedNrOfDeletedObjects) { - fail( - ASSERTION_FAILED, - "deletePersistentAll returned " - + nr - + ", expected is " - + expectedNrOfDeletedObjects - + ". Query: " - + singleStringQuery); - } - tx.commit(); - } finally { - if (query != null) { - query.close(result); - } - if (tx.isActive()) { - tx.rollback(); - } + + /** */ + public void testNoParametersSingleString() { + Transaction tx = pm.currentTransaction(); + Query query = null; + Object result = null; + try { + tx.begin(); + String singleStringQuery = "SELECT FROM org.apache.jdo.tck.pc.company.Insurance"; + query = pm.newQuery(singleStringQuery); + long expectedNrOfDeletedObjects = 11; + long nr = query.deletePersistentAll(); + if (nr != expectedNrOfDeletedObjects) { + fail(ASSERTION_FAILED, "deletePersistentAll returned " + nr + + ", expected is " + expectedNrOfDeletedObjects + + ". Query: " + singleStringQuery); + } + tx.commit(); + } finally { + if (query != null) { + query.close(result); + } + if (tx.isActive()) { + tx.rollback(); + } + } } - } - - /** */ - public void testObjectArrayParametersSingleString() { - Transaction tx = pm.currentTransaction(); - Query query = null; - Object result = null; - try { - tx.begin(); - String singleStringQuery = - "SELECT FROM org.apache.jdo.tck.pc.company.Insurance " - + "WHERE carrier == param PARAMETERS String param"; - query = pm.newQuery(singleStringQuery); - Object[] parameters = new Object[] {"Carrier1"}; - long expectedNrOfDeletedObjects = 2; - long nr = query.deletePersistentAll(parameters); - if (nr != expectedNrOfDeletedObjects) { - fail( - ASSERTION_FAILED, - "deletePersistentAll returned " - + nr - + ", expected is " - + expectedNrOfDeletedObjects - + ". Query: " - + singleStringQuery); - } - tx.commit(); - } finally { - if (query != null) { - query.close(result); - } - if (tx.isActive()) { - tx.rollback(); - } + + /** */ + public void testObjectArrayParametersAPI() { + Transaction tx = pm.currentTransaction(); + Query query = null; + Object result = null; + try { + tx.begin(); + String singleStringQuery = "SELECT FROM org.apache.jdo.tck.pc.company.Insurance " + + "WHERE carrier == param PARAMETERS String param"; + query = pm.newQuery(Insurance.class, "carrier == param"); + query.declareParameters("String param"); + Object[] parameters = new Object[] {"Carrier1"}; + long expectedNrOfDeletedObjects = 2; + long nr = query.deletePersistentAll(parameters); + if (nr != expectedNrOfDeletedObjects) { + fail(ASSERTION_FAILED, "deletePersistentAll returned " + nr + + ", expected is " + expectedNrOfDeletedObjects + + ". Query: " + singleStringQuery); + } + tx.commit(); + } finally { + if (query != null) { + query.close(result); + } + if (tx.isActive()) { + tx.rollback(); + } + } } - } - - /** */ - public void testMapParametersAPI() { - Transaction tx = pm.currentTransaction(); - Query query = null; - Object result = null; - try { - tx.begin(); - String singleStringQuery = - "SELECT FROM org.apache.jdo.tck.pc.company.Insurance " - + "WHERE carrier == param PARAMETERS String param"; - query = pm.newQuery(Insurance.class, "carrier == param"); - query.declareParameters("String param"); - Map parameters = new HashMap(); - parameters.put("param", "Carrier1"); - long expectedNrOfDeletedObjects = 2; - long nr = query.deletePersistentAll(parameters); - if (nr != expectedNrOfDeletedObjects) { - fail( - ASSERTION_FAILED, - "deletePersistentAll returned " - + nr - + ", expected is " - + expectedNrOfDeletedObjects - + ". Query: " - + singleStringQuery); - } - tx.commit(); - } finally { - if (query != null) { - query.close(result); - } - if (tx.isActive()) { - tx.rollback(); - } + + /** */ + public void testObjectArrayParametersSingleString() { + Transaction tx = pm.currentTransaction(); + Query query = null; + Object result = null; + try { + tx.begin(); + String singleStringQuery = "SELECT FROM org.apache.jdo.tck.pc.company.Insurance " + + "WHERE carrier == param PARAMETERS String param"; + query = pm.newQuery(singleStringQuery); + Object[] parameters = new Object[] {"Carrier1"}; + long expectedNrOfDeletedObjects = 2; + long nr = query.deletePersistentAll(parameters); + if (nr != expectedNrOfDeletedObjects) { + fail(ASSERTION_FAILED, "deletePersistentAll returned " + nr + + ", expected is " + expectedNrOfDeletedObjects + + ". Query: " + singleStringQuery); + } + tx.commit(); + } finally { + if (query != null) { + query.close(result); + } + if (tx.isActive()) { + tx.rollback(); + } + } } - } - - /** */ - public void testMapParametersSingleString() { - Transaction tx = pm.currentTransaction(); - Query query = null; - Object result = null; - try { - tx.begin(); - String singleStringQuery = - "SELECT FROM org.apache.jdo.tck.pc.company.Insurance " - + "WHERE carrier == param PARAMETERS String param"; - query = pm.newQuery(singleStringQuery); - Map parameters = new HashMap(); - parameters.put("param", "Carrier1"); - long expectedNrOfDeletedObjects = 2; - long nr = query.deletePersistentAll(parameters); - if (nr != expectedNrOfDeletedObjects) { - fail( - ASSERTION_FAILED, - "deletePersistentAll returned " - + nr - + ", expected is " - + expectedNrOfDeletedObjects - + ". Query: " - + singleStringQuery); - } - tx.commit(); - } finally { - if (query != null) { - query.close(result); - } - if (tx.isActive()) { - tx.rollback(); - } + + /** */ + public void testMapParametersAPI() { + Transaction tx = pm.currentTransaction(); + Query query = null; + Object result = null; + try { + tx.begin(); + String singleStringQuery = "SELECT FROM org.apache.jdo.tck.pc.company.Insurance " + + "WHERE carrier == param PARAMETERS String param"; + query = pm.newQuery(Insurance.class, "carrier == param"); + query.declareParameters("String param"); + Map parameters = new HashMap(); + parameters.put("param", "Carrier1"); + long expectedNrOfDeletedObjects = 2; + long nr = query.deletePersistentAll(parameters); + if (nr != expectedNrOfDeletedObjects) { + fail(ASSERTION_FAILED, "deletePersistentAll returned " + nr + + ", expected is " + expectedNrOfDeletedObjects + + ". Query: " + singleStringQuery); + } + tx.commit(); + } finally { + if (query != null) { + query.close(result); + } + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** */ + public void testMapParametersSingleString() { + Transaction tx = pm.currentTransaction(); + Query query = null; + Object result = null; + try { + tx.begin(); + String singleStringQuery = "SELECT FROM org.apache.jdo.tck.pc.company.Insurance " + + "WHERE carrier == param PARAMETERS String param"; + query = pm.newQuery(singleStringQuery); + Map parameters = new HashMap(); + parameters.put("param", "Carrier1"); + long expectedNrOfDeletedObjects = 2; + long nr = query.deletePersistentAll(parameters); + if (nr != expectedNrOfDeletedObjects) { + fail(ASSERTION_FAILED, "deletePersistentAll returned " + nr + + ", expected is " + expectedNrOfDeletedObjects + + ". Query: " + singleStringQuery); + } + tx.commit(); + } finally { + if (query != null) { + query.close(result); + } + if (tx.isActive()) { + tx.rollback(); + } + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/delete/DeleteQueryElements.java b/tck/src/main/java/org/apache/jdo/tck/query/delete/DeleteQueryElements.java index 796356571..e394cc0eb 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/delete/DeleteQueryElements.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/delete/DeleteQueryElements.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,6 +20,8 @@ import java.math.BigDecimal; import java.util.HashMap; import java.util.Map; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.DentalInsurance; import org.apache.jdo.tck.pc.company.Insurance; @@ -28,231 +30,239 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Delete Query Elements.
    - * Keywords: query
    - * Assertion ID: A14.8-3
    - * Assertion Description: Query elements filter, parameters, imports, variables, and unique - * are valid in queries used for delete. Elements result, result class, range, grouping, and - * ordering are invalid. If any of these elements is set to its non-default value when one of the - * deletePersistentAll methods is called, a JDOUserException is thrown and no instances are deleted. + *Title: Delete Query Elements. + *
    + *Keywords: query + *
    + *Assertion ID: A14.8-3 + *
    + *Assertion Description: + * Query elements filter, parameters, imports, variables, + * and unique are valid in queries used for delete. + * Elements result, result class, range, grouping, and ordering are invalid. + * If any of these elements is set to its non-default value + * when one of the deletePersistentAll methods is called, + * a JDOUserException is thrown and no instances are deleted. */ public class DeleteQueryElements extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.8-1 (DeleteQueryElements) failed: "; - - /** - * The array of invalid queries which may be executed as single string queries and as API queries. - */ - private static final QueryElementHolder[] INVALID_QUERIES = { - // The query is invalid because it defines a result clause. - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "carrier", - /*INTO*/ null, - /*FROM*/ Insurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - // The query is invalid because it defines a result class. - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ String.class, - /*FROM*/ Insurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - // The query is invalid because it defines a result clause - // and a result class. - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "carrier", - /*INTO*/ String.class, - /*FROM*/ Insurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - // The query is invalid because it defines a grouping clause. - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Insurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ "carrier", - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - // The query is invalid because it defines a result clause - // and a grouping clause - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "carrier", - /*INTO*/ null, - /*FROM*/ Insurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ "carrier", - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - // The query is invalid because it defines an ordering clause. - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Insurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "carrier", - /*FROM*/ null, - /*TO*/ null), - // The query is invalid because it defines a range clause. - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Insurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ "0", - /*TO*/ "5"), - // The query is valid but deletePersistentAll is expected - // to throw a JDOUserException because it defines a - // unique clause but it affects multiple rows in the database. - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Insurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null) - }; - - /** Parameters of valid queries. */ - private Object[][] parameters = {{new BigDecimal("2500000")}}; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DeleteQueryElements.class); - } - - /** */ - public void testAPI() { - Map paramValues = new HashMap<>(); - paramValues.put("limit", new BigDecimal("2500000")); - - QueryElementHolder holder = + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.8-1 (DeleteQueryElements) failed: "; + + /** + * The array of invalid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] INVALID_QUERIES = { + // The query is invalid because it defines a result clause. new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ DentalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ "((FullTimeEmployee)employee).salary > 10000 & " - + "employee.projects.contains(p) & p.budget > limit", - /*VARIABLES*/ "Project p", - /*PARAMETERS*/ "BigDecimal limit", - /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.Project; " - + "import java.math.BigDecimal;", - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ null, - /*paramValues*/ paramValues); - - deletePersistentAllByAPIQuery(ASSERTION_FAILED, holder, 1); - } + /*UNIQUE*/ null, + /*RESULT*/ "carrier", + /*INTO*/ null, + /*FROM*/ Insurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + // The query is invalid because it defines a result class. + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ String.class, + /*FROM*/ Insurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + // The query is invalid because it defines a result clause + // and a result class. + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "carrier", + /*INTO*/ String.class, + /*FROM*/ Insurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + // The query is invalid because it defines a grouping clause. + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Insurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ "carrier", + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + // The query is invalid because it defines a result clause + // and a grouping clause + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "carrier", + /*INTO*/ null, + /*FROM*/ Insurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ "carrier", + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + // The query is invalid because it defines an ordering clause. + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Insurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "carrier", + /*FROM*/ null, + /*TO*/ null), + // The query is invalid because it defines a range clause. + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Insurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ "0", + /*TO*/ "5"), + // The query is valid but deletePersistentAll is expected + // to throw a JDOUserException because it defines a + // unique clause but it affects multiple rows in the database. + new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Insurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** Parameters of valid queries. */ + private Object[][] parameters = { + {new BigDecimal("2500000")} + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DeleteQueryElements.class); + } + + /** */ + public void testAPI() { + Map paramValues = new HashMap<>(); + paramValues.put("limit", new BigDecimal("2500000")); - /** */ - public void testSingleString() { - Map paramValues = new HashMap<>(); - paramValues.put("limit", new BigDecimal("2500000")); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ DentalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ "((FullTimeEmployee)employee).salary > 10000 & " + + "employee.projects.contains(p) & p.budget > limit", + /*VARIABLES*/ "Project p", + /*PARAMETERS*/ "BigDecimal limit", + /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.Project; " + + "import java.math.BigDecimal;", + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ null, + /*paramValues*/ paramValues); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ DentalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ "((FullTimeEmployee)employee).salary > 10000 & " - + "employee.projects.contains(p) & p.budget > limit", - /*VARIABLES*/ "Project p", - /*PARAMETERS*/ "BigDecimal limit", - /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.Project; " - + "import java.math.BigDecimal;", - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ null, - /*paramValues*/ paramValues); + deletePersistentAllByAPIQuery(ASSERTION_FAILED, holder, 1); + } + + /** */ + public void testSingleString() { + Map paramValues = new HashMap<>(); + paramValues.put("limit", new BigDecimal("2500000")); - deletePersistentAllBySingleStringQuery(ASSERTION_FAILED, holder, 1); - } + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ DentalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ "((FullTimeEmployee)employee).salary > 10000 & " + + "employee.projects.contains(p) & p.budget > limit", + /*VARIABLES*/ "Project p", + /*PARAMETERS*/ "BigDecimal limit", + /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.Project; " + + "import java.math.BigDecimal;", + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ null, + /*paramValues*/ paramValues); - /** */ - public void testNegative() { - for (int i = 0; i < INVALID_QUERIES.length; i++) { - deletePersistentAllByAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], -1); - deletePersistentAllBySingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], -1); + deletePersistentAllBySingleStringQuery(ASSERTION_FAILED, holder,1); + } + + /** */ + public void testNegative() { + for (int i = 0; i < INVALID_QUERIES.length; i++) { + deletePersistentAllByAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], -1); + deletePersistentAllBySingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], -1); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/AssignmentPrePostIncrementDecrementNotSupported.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/AssignmentPrePostIncrementDecrementNotSupported.java index dcacbd5eb..c20bcbdef 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/AssignmentPrePostIncrementDecrementNotSupported.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/AssignmentPrePostIncrementDecrementNotSupported.java @@ -5,130 +5,136 @@ * 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 + * + * 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.jdo.tck.query.jdoql; + import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Query; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Assignment, Pre- and Post-Increment and Decrement Operators are not supported
    - * Keywords: query
    - * Assertion IDs: A14.6.2-7.
    - * Assertion Description: The assignment operators =, +=, etc. and pre- and post-increment - * and -decrement are not supported in a Query filter. - */ -public class AssignmentPrePostIncrementDecrementNotSupported extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-7 (AssignmentPrePostIncrementDecrementNotSupported) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(AssignmentPrePostIncrementDecrementNotSupported.class); - } - - /** */ - public void testNegative() { - PersistenceManager pm = getPM(); - - runTestUnsupportedOperators01(pm, "x = 1"); - runTestUnsupportedOperators01(pm, "x += 1"); - runTestUnsupportedOperators01(pm, "x -= 1"); - runTestUnsupportedOperators01(pm, "x *= 1"); - runTestUnsupportedOperators01(pm, "x /= 1"); - runTestUnsupportedOperators01(pm, "x &= 1"); - runTestUnsupportedOperators01(pm, "x |= 1"); - runTestUnsupportedOperators01(pm, "x ^= 1"); - runTestUnsupportedOperators01(pm, "x %= 1"); - runTestUnsupportedOperators01(pm, "x++ == 1"); - runTestUnsupportedOperators01(pm, "x-- == 1"); - runTestUnsupportedOperators01(pm, "++x == 1"); - runTestUnsupportedOperators01(pm, "--x == 1"); - runTestUnsupportedOperators02(pm, "x == ++param", Integer.valueOf(1)); - runTestUnsupportedOperators02(pm, "x == --param", Integer.valueOf(1)); - runTestUnsupportedOperators02(pm, "x == param++", Integer.valueOf(1)); - runTestUnsupportedOperators02(pm, "x == param--", Integer.valueOf(1)); - - pm.close(); - pm = null; - } + *Title: Assignment, Pre- and Post-Increment and Decrement Operators + *are not supported + *
    + *Keywords: query + *
    + *Assertion IDs: A14.6.2-7. + *
    + *Assertion Description: +The assignment operators =, +=, etc. and pre- and post-increment and -decrement +are not supported in a Query filter. - /** */ - void runTestUnsupportedOperators01(PersistenceManager pm, String filter) { - - Query query = pm.newQuery(); - String expectedMsg = "setFilter: Syntax error unexpected token ..."; + */ - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); +public class AssignmentPrePostIncrementDecrementNotSupported extends QueryTest { - try { - query.setFilter(filter); - query.compile(); - fail( - ASSERTION_FAILED, - "Test UnsupportedOperators01(" - + filter - + ") - " - + "Missing JDOUserException(" - + expectedMsg - + ")"); - } catch (JDOUserException ex) { - // expected exception - if (debug) { - logger.debug("expected exception: " + ex); - logger.debug("Test UnsupportedOperators01(\"" + filter + "\") - Passed\n"); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-7 (AssignmentPrePostIncrementDecrementNotSupported) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(AssignmentPrePostIncrementDecrementNotSupported.class); } - } - - /** */ - void runTestUnsupportedOperators02(PersistenceManager pm, String filter, Integer param) { - - Query query = pm.newQuery(); - String params = "Integer param"; - String expectedMsg = "setFilter: Syntax error unexpected token ..."; - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.declareParameters(params); - - try { - query.setFilter(filter); - query.compile(); + /** */ + public void testNegative() { + PersistenceManager pm = getPM(); + + runTestUnsupportedOperators01(pm, "x = 1"); + runTestUnsupportedOperators01(pm, "x += 1"); + runTestUnsupportedOperators01(pm, "x -= 1"); + runTestUnsupportedOperators01(pm, "x *= 1"); + runTestUnsupportedOperators01(pm, "x /= 1"); + runTestUnsupportedOperators01(pm, "x &= 1"); + runTestUnsupportedOperators01(pm, "x |= 1"); + runTestUnsupportedOperators01(pm, "x ^= 1"); + runTestUnsupportedOperators01(pm, "x %= 1"); + runTestUnsupportedOperators01(pm, "x++ == 1"); + runTestUnsupportedOperators01(pm, "x-- == 1"); + runTestUnsupportedOperators01(pm, "++x == 1"); + runTestUnsupportedOperators01(pm, "--x == 1"); + runTestUnsupportedOperators02(pm, "x == ++param", Integer.valueOf(1)); + runTestUnsupportedOperators02(pm, "x == --param", Integer.valueOf(1)); + runTestUnsupportedOperators02(pm, "x == param++", Integer.valueOf(1)); + runTestUnsupportedOperators02(pm, "x == param--", Integer.valueOf(1)); + + pm.close(); + pm = null; + } - fail( - ASSERTION_FAILED, - "Test UnsupportedOperators02(" - + filter - + ") - " - + "Missing JDOUserException(" - + expectedMsg - + ")"); - } catch (JDOUserException ex) { - if (debug) { - logger.debug("expected exception: " + ex); - logger.debug("Test UnsupportedOperators02(\"" + filter + "\") - Passed\n"); - } + /** */ + void runTestUnsupportedOperators01(PersistenceManager pm, String filter) { + + Query query = pm.newQuery(); + String expectedMsg = "setFilter: Syntax error unexpected token ..."; + + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + + try { + query.setFilter(filter); + query.compile(); + fail(ASSERTION_FAILED, + "Test UnsupportedOperators01(" + filter + ") - " + + "Missing JDOUserException(" + expectedMsg + ")"); + } + catch (JDOUserException ex) { + // expected exception + if (debug) { + logger.debug("expected exception: " + ex); + logger.debug("Test UnsupportedOperators01(\"" + filter + + "\") - Passed\n"); + } + } + } + + /** */ + void runTestUnsupportedOperators02(PersistenceManager pm, + String filter, + Integer param) { + + Query query = pm.newQuery(); + String params = "Integer param"; + String expectedMsg = "setFilter: Syntax error unexpected token ..."; + + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.declareParameters(params); + + try { + query.setFilter(filter); + query.compile(); + + fail(ASSERTION_FAILED, + "Test UnsupportedOperators02(" + filter + ") - " + + "Missing JDOUserException(" + expectedMsg + ")"); + } + catch (JDOUserException ex) { + if (debug) { + logger.debug("expected exception: " + ex); + logger.debug("Test UnsupportedOperators02(\"" + filter + + "\") - Passed\n"); + } + } } - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/Cast.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/Cast.java index ad7906497..982fb4311 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/Cast.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/Cast.java @@ -5,19 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql; -import javax.jdo.JDOQLTypedQuery; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.Employee; @@ -29,103 +29,109 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; +import javax.jdo.query.Expression; + /** - * Title: Cast Query Operator
    - * Keywords: query
    - * Assertion ID: A14.6.2-38.
    - * Assertion Description: The cast operator can be used for type conversions on classes. - */ -public class Cast extends QueryTest { + *Title: Cast Query Operator + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-38. + *
    + *Assertion Description: +The cast operator can be used for type conversions on classes. - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.2-38 (Cast) failed: "; + */ - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Cast.class); - } +public class Cast extends QueryTest { - /** */ - public void testPositive0() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp5"}); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-38 (Cast) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Cast.class); + } + + /** */ + public void testPositive0() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp5"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - // DataNucleus: java.lang.ClassCastException: - // org.datanucleus.api.jdo.query.PersistableExpressionImpl - // cannot be cast to org.apache.jdo.tck.pc.company.QFullTimeEmployee - QFullTimeEmployee cast = (QFullTimeEmployee) cand.cast(FullTimeEmployee.class); - query.filter(cast.salary.gt(15000.0)); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + // DataNucleus: java.lang.ClassCastException: org.datanucleus.api.jdo.query.PersistableExpressionImpl + // cannot be cast to org.apache.jdo.tck.pc.company.QFullTimeEmployee + QFullTimeEmployee cast = (QFullTimeEmployee)cand.cast(FullTimeEmployee.class); + query.filter(cast.salary.gt(15000.0)); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "((FullTimeEmployee)this).salary > 15000.0", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.FullTimeEmployee", - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "((FullTimeEmployee)this).salary > 15000.0", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.FullTimeEmployee", + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } - /** */ - public void testPositive1() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1", "dept2"}); + /** */ + public void testPositive1() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"dept1", "dept2"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - QEmployee e = QEmployee.variable("e"); - // DataNucleus: java.lang.ClassCastException: - // org.datanucleus.api.jdo.query.PersistableExpressionImpl - // cannot be cast to org.apache.jdo.tck.pc.company.QFullTimeEmployee - QFullTimeEmployee cast = (QFullTimeEmployee) e.cast(FullTimeEmployee.class); - query.filter(cand.employees.contains(e).and(cast.salary.gt(15000.0))); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + QEmployee e = QEmployee.variable("e"); + // DataNucleus: java.lang.ClassCastException: org.datanucleus.api.jdo.query.PersistableExpressionImpl + // cannot be cast to org.apache.jdo.tck.pc.company.QFullTimeEmployee + QFullTimeEmployee cast = (QFullTimeEmployee)e.cast(FullTimeEmployee.class); + query.filter(cand.employees.contains(e).and(cast.salary.gt(15000.0))); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employees.contains(e) && ((FullTimeEmployee)e).salary > 15000.0", - /*VARIABLES*/ "Employee e", - /*PARAMETERS*/ null, - /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.FullTimeEmployee", - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.contains(e) && ((FullTimeEmployee)e).salary > 15000.0", + /*VARIABLES*/ "Employee e", + /*PARAMETERS*/ null, + /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.FullTimeEmployee", + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/CharacterAndStringLiterals.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/CharacterAndStringLiterals.java index e9543cae4..578e9c9ce 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/CharacterAndStringLiterals.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/CharacterAndStringLiterals.java @@ -5,19 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql; -import javax.jdo.JDOQLTypedQuery; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.MylibReader; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.pc.mylib.QPrimitiveTypes; @@ -25,142 +25,154 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Character and String Literals.
    - * Keywords: query
    - * Assertion ID: A14.6.2-42.
    - * Assertion Description: There is no distinction made between character literals and String - * literals. Single character String literals can be used wherever character literals are permitted. - * String literals are allowed to be delimited by single quote marks or double quote marks. This - * allows String literal filters to use single quote marks instead of escaped double quote marks. + *Title: Character and String Literals. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-42. + *
    + *Assertion Description: + * There is no distinction made between character literals and + * String literals. Single character String literals can be used + * wherever character literals are permitted. + * String literals are allowed to be delimited by single quote marks + * or double quote marks. This allows String literal filters + * to use single quote marks instead of escaped double quote marks. */ public class CharacterAndStringLiterals extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-42 (CharacterAndStringLiterals) failed: "; - - /** - * The array of invalid queries which may be executed as single string queries and as API queries. - */ - private static final QueryElementHolder[] INVALID_QUERIES = { - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ PrimitiveTypes.class, - /*EXCLUDE*/ null, - /*WHERE*/ "charNotNull == 'O.'", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ PrimitiveTypes.class, - /*EXCLUDE*/ null, - /*WHERE*/ "charNotNull == \"O.\"", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CharacterAndStringLiterals.class); - } - - /** */ - public void testPositive1() { - Object expected = - getTransientMylibInstancesAsList(new String[] {"primitiveTypesCharacterStringLiterals"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); - QPrimitiveTypes cand = QPrimitiveTypes.candidate(); - query.filter(cand.stringNull.startsWith("Even").or(cand.charNotNull.eq('0'))); - - QueryElementHolder holder = + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-42 (CharacterAndStringLiterals) failed: "; + + /** + * The array of invalid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] INVALID_QUERIES = { new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ PrimitiveTypes.class, - /*EXCLUDE*/ null, - /*WHERE*/ "stringNull.startsWith('Even') || charNotNull == 'O'", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testPositive2() { - Object expected = - getTransientMylibInstancesAsList(new String[] {"primitiveTypesCharacterStringLiterals"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); - QPrimitiveTypes cand = QPrimitiveTypes.candidate(); - query.filter(cand.stringNull.startsWith("Even").or(cand.charNotNull.eq('0'))); - - QueryElementHolder holder = + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ PrimitiveTypes.class, + /*EXCLUDE*/ null, + /*WHERE*/ "charNotNull == 'O.'", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ PrimitiveTypes.class, - /*EXCLUDE*/ null, - /*WHERE*/ "stringNull.startsWith(\"Even\") || charNotNull == \"O\"", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ PrimitiveTypes.class, + /*EXCLUDE*/ null, + /*WHERE*/ "charNotNull == \"O.\"", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CharacterAndStringLiterals.class); + } - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } + /** + * + */ + public void testPositive1() { + Object expected = getTransientMylibInstancesAsList(new String[]{ + "primitiveTypesCharacterStringLiterals"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); + QPrimitiveTypes cand = QPrimitiveTypes.candidate(); + query.filter(cand.stringNull.startsWith("Even").or(cand.charNotNull.eq('0'))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ PrimitiveTypes.class, + /*EXCLUDE*/ null, + /*WHERE*/ "stringNull.startsWith('Even') || charNotNull == 'O'", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * + */ + public void testPositive2() { + Object expected = getTransientMylibInstancesAsList(new String[]{ + "primitiveTypesCharacterStringLiterals"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); + QPrimitiveTypes cand = QPrimitiveTypes.candidate(); + query.filter(cand.stringNull.startsWith("Even").or(cand.charNotNull.eq('0'))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ PrimitiveTypes.class, + /*EXCLUDE*/ null, + /*WHERE*/ "stringNull.startsWith(\"Even\") || charNotNull == \"O\"", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } - /** */ - public void testNegative() { - for (int i = 0; i < INVALID_QUERIES.length; i++) { - compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); - compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + /** */ + public void testNegative() { + for (int i = 0; i < INVALID_QUERIES.length; i++) { + compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], + false); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(MylibReader.getTearDownClasses()); - loadAndPersistMylib(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(MylibReader.getTearDownClasses()); + loadAndPersistMylib(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ComparingCollectionFieldToNull.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ComparingCollectionFieldToNull.java index 4ff7e725f..20ffc94a5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ComparingCollectionFieldToNull.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ComparingCollectionFieldToNull.java @@ -5,20 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql; -import java.util.List; -import javax.jdo.JDOQLTypedQuery; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.QEmployee; @@ -26,79 +25,91 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; +import java.util.ArrayList; +import java.util.List; + /** - * Title: Comparing a Collection Field to Null
    - * Keywords: query nullcollection
    - * Assertion ID: A14.6.2-36.
    - * Assertion Description: For datastores that support null values for - * Collection types, it is valid to compare the field to null. Datastores that - * do not support null values for Collection types will return false - * if the query compares the field to null. + *Title: Comparing a Collection Field to Null + *
    + *Keywords: query nullcollection + *
    + *Assertion ID: A14.6.2-36. + *
    + *Assertion Description: + * For datastores that support null values for + * Collection types, it is valid to compare the field to + * null. Datastores that do not support null values + * for Collection types will return false if the query + * compares the field to null. */ -public class ComparingCollectionFieldToNull extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-36 (ComparingCollectionFieldToNull) failed: "; - - /** The expected results of valid queries. */ - private List expectedResult; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ComparingCollectionFieldToNull.class); - } +public class ComparingCollectionFieldToNull extends QueryTest { - /** */ - public void testPositive() { - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.filter(cand.personid.eq(1L).and(cand.projects.eq(null))); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-36 (ComparingCollectionFieldToNull) failed: "; + + /** + * The expected results of valid queries. + */ + private List expectedResult; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ComparingCollectionFieldToNull.class); + } + + /** */ + public void testPositive() { + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.filter(cand.personid.eq(1L).and(cand.projects.eq(null))); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "personid == 1 && projects == null", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "personid == 1 && projects == null", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expectedResult); - } + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expectedResult); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - Employee employee = (Employee) getPersistentCompanyModelInstance("emp1"); - expectedResult = - // emp1 should be in the query result set, - // if the JDO Implentation supports null values for Collections - getTransientCompanyModelInstancesAsList( - isNullCollectionSupported() ? new String[] {"emp1"} : new String[] {}); - if (isNullCollectionSupported()) { - getPM().currentTransaction().begin(); - employee.setProjects(null); - getPM().currentTransaction().commit(); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + Employee employee = (Employee) getPersistentCompanyModelInstance("emp1"); + expectedResult = + // emp1 should be in the query result set, + // if the JDO Implentation supports null values for Collections + getTransientCompanyModelInstancesAsList( + isNullCollectionSupported() ? + new String[]{"emp1"} : new String[]{}); + if (isNullCollectionSupported()) { + getPM().currentTransaction().begin(); + employee.setProjects(null); + getPM().currentTransaction().commit(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ComparingPersistentAndNonPersistentInstance.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ComparingPersistentAndNonPersistentInstance.java index caf100bf5..653c1a2f2 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ComparingPersistentAndNonPersistentInstance.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ComparingPersistentAndNonPersistentInstance.java @@ -5,22 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql; -import java.util.HashMap; -import java.util.Map; -import javax.jdo.JDOQLTypedQuery; -import javax.jdo.query.Expression; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.QEmployee; @@ -28,105 +25,114 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; +import javax.jdo.query.Expression; +import java.util.HashMap; +import java.util.Map; + /** - * Title: Comparing persistent and non-persistent instance
    - * Keywords: query
    - * Assertion ID: A14.6.2-44.
    - * Assertion Description: Comparisons between persistent and non-persistent instances return - * not equal. + *Title: Comparing persistent and non-persistent instance + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-44. + *
    + *Assertion Description: + * Comparisons between persistent and non-persistent instances return + * not equal. */ -public class ComparingPersistentAndNonPersistentInstance extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-44 (ComparingPersistentAndNonPersistentInstance) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ComparingPersistentAndNonPersistentInstance.class); - } - - /** */ - public void testPositive0() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - Expression empParam = query.parameter("param", Employee.class); - query.filter(cand.eq(empParam)); - - Map paramValues = new HashMap<>(); - paramValues.put("param", getTransientCompanyModelInstance("emp1")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this == param", - /*VARIABLES*/ null, - /*PARAMETERS*/ "Employee param", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testPositive1() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - Expression empParamExpression = query.parameter("param", Employee.class); - QEmployee empParam = QEmployee.parameter("param"); - query.filter(cand.personid.eq(empParam.personid)); - - Map paramValues = new HashMap<>(); - paramValues.put("param", getTransientCompanyModelInstance("emp1")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this.personid == param.personid", - /*VARIABLES*/ null, - /*PARAMETERS*/ "Employee param", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + +public class ComparingPersistentAndNonPersistentInstance + extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-44 (ComparingPersistentAndNonPersistentInstance) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ComparingPersistentAndNonPersistentInstance.class); + } + + /** */ + public void testPositive0() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + Expression empParam = query.parameter("param", Employee.class); + query.filter(cand.eq(empParam)); + + Map paramValues = new HashMap<>(); + paramValues.put("param", getTransientCompanyModelInstance("emp1")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this == param", + /*VARIABLES*/ null, + /*PARAMETERS*/ "Employee param", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testPositive1() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + Expression empParamExpression = query.parameter("param", Employee.class); + QEmployee empParam = QEmployee.parameter("param"); + query.filter(cand.personid.eq(empParam.personid)); + + Map paramValues = new HashMap<>(); + paramValues.put("param", getTransientCompanyModelInstance("emp1")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this.personid == param.personid", + /*VARIABLES*/ null, + /*PARAMETERS*/ "Employee param", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/DenoteUniquenessInFilter.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/DenoteUniquenessInFilter.java index 52d4ae4ca..d4f8cae85 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/DenoteUniquenessInFilter.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/DenoteUniquenessInFilter.java @@ -5,19 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql; -import javax.jdo.JDOQLTypedQuery; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.QDepartment; @@ -26,171 +26,163 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Element Returned in Query Result
    - * Keywords: query
    - * Assertion ID: A14.6.2-2.
    - * Assertion Description: An element of the candidate collection is returned in the result - * if: - * - *

      - *
    • it is assignment compatible to the candidate Class of the Query; - * and - *
    • for all variables there exists a value for which the filter expression evaluates to - * true. The user may denote uniqueness in the filter expression by explicitly - * declaring an expression (for example, e1 != e2). - *
    + *Title: Element Returned in Query Result + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-2. + *
    + *Assertion Description: +An element of the candidate collection is returned in the result if: +
      +
    • it is assignment compatible to the candidate Class of the +Query; and
    • +
    • for all variables there exists a value for which the filter expression +evaluates to true. +The user may denote uniqueness in the filter expression +by explicitly declaring an expression +(for example, e1 != e2).
    • +
    */ + public class DenoteUniquenessInFilter extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-2 (DenoteUniquenessInFilter) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DenoteUniquenessInFilter.class); - } - - /** */ - public void testPositive0() { - // Uniqueness not specified. - // emp1 qualifies for both contains clause => result is dept1 - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - QEmployee e1 = QEmployee.variable("e1"); - QEmployee e2 = QEmployee.variable("e2"); - query.filter( - cand.employees - .contains(e1) - .and(e1.personid.eq(1l).and(cand.employees.contains(e2).and(e2.weeklyhours.eq(40d))))); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employees.contains(e1) && (e1.personid == 1 && " - + "(employees.contains(e2) && (e2.weeklyhours == 40)))", - /*VARIABLES*/ "Employee e1; Employee e2", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testPositive1() { - // Uniqueness specified. - // Only emp3 qualifies for both contains clause. - // Condition e1 != e2 violated => result is empty - Object expected = getTransientCompanyModelInstancesAsList(new String[] {}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - QEmployee e1 = QEmployee.variable("e1"); - QEmployee e2 = QEmployee.variable("e2"); - query.filter( - cand.employees - .contains(e1) - .and( - e1.personid - .eq(3l) - .and(cand.employees.contains(e2).and(e2.weeklyhours.eq(19d).and(e1.ne(e2)))))); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employees.contains(e1) && (e1.personid == 3 && " - + "(employees.contains(e2) && (e2.weeklyhours == 19 && " - + "e1 != e2)))", - /*VARIABLES*/ "Employee e1; Employee e2", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testPositive2() { - // Uniqueness specified. - // Only emp1 matches the first contains clause. - // emp1 and emp2 match the second contains clause. - // Thus, there are two different values for e1 and e2 - // satifying the entire filter => result is dept1 - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - QEmployee e1 = QEmployee.variable("e1"); - QEmployee e2 = QEmployee.variable("e2"); - query.filter( - cand.employees - .contains(e1) - .and( - e1.personid - .eq(1l) - .and(cand.employees.contains(e2).and(e2.weeklyhours.eq(40d).and(e1.ne(e2)))))); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employees.contains(e1) && (e1.personid == 1 && " - + "(employees.contains(e2) && (e2.weeklyhours == 40 && " - + "e1 != e2)))", - /*VARIABLES*/ "Employee e1; Employee e2", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-2 (DenoteUniquenessInFilter) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DenoteUniquenessInFilter.class); + } + + /** */ + public void testPositive0() { + // Uniqueness not specified. + // emp1 qualifies for both contains clause => result is dept1 + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"dept1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + QEmployee e1 = QEmployee.variable("e1"); + QEmployee e2 = QEmployee.variable("e2"); + query.filter(cand.employees.contains(e1).and(e1.personid.eq(1l).and( + cand.employees.contains(e2).and(e2.weeklyhours.eq(40d))))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.contains(e1) && (e1.personid == 1 && " + + "(employees.contains(e2) && (e2.weeklyhours == 40)))", + /*VARIABLES*/ "Employee e1; Employee e2", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testPositive1() { + // Uniqueness specified. + // Only emp3 qualifies for both contains clause. + // Condition e1 != e2 violated => result is empty + Object expected = getTransientCompanyModelInstancesAsList(new String[]{}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + QEmployee e1 = QEmployee.variable("e1"); + QEmployee e2 = QEmployee.variable("e2"); + query.filter(cand.employees.contains(e1).and(e1.personid.eq(3l).and( + cand.employees.contains(e2).and(e2.weeklyhours.eq(19d).and(e1.ne(e2)))))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.contains(e1) && (e1.personid == 3 && " + + "(employees.contains(e2) && (e2.weeklyhours == 19 && " + + "e1 != e2)))", + /*VARIABLES*/ "Employee e1; Employee e2", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testPositive2() { + // Uniqueness specified. + // Only emp1 matches the first contains clause. + // emp1 and emp2 match the second contains clause. + // Thus, there are two different values for e1 and e2 + // satifying the entire filter => result is dept1 + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"dept1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + QEmployee e1 = QEmployee.variable("e1"); + QEmployee e2 = QEmployee.variable("e2"); + query.filter(cand.employees.contains(e1).and(e1.personid.eq(1l).and( + cand.employees.contains(e2).and(e2.weeklyhours.eq(40d).and(e1.ne(e2)))))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.contains(e1) && (e1.personid == 1 && " + + "(employees.contains(e2) && (e2.weeklyhours == 40 && " + + "e1 != e2)))", + /*VARIABLES*/ "Employee e1; Employee e2", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ExecuteQueryWhenPersistenceManagerIsClosed.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ExecuteQueryWhenPersistenceManagerIsClosed.java index dd71e0190..a68a6c64e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ExecuteQueryWhenPersistenceManagerIsClosed.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ExecuteQueryWhenPersistenceManagerIsClosed.java @@ -5,84 +5,93 @@ * 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 + * + * 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.jdo.tck.query.jdoql; + import javax.jdo.JDOFatalUserException; import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Execute Query when Persistence Manager is Closed
    - * Keywords: query
    - * Assertion ID: A14.6.1-1.
    - * Assertion Description: If the PersistenceManager which constructed the - * Query is closed, then the Query.execute methods throw - * JDOFatalUserException. + *Title: Execute Query when Persistence Manager is Closed + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.1-1. + *
    + *Assertion Description: If the PersistenceManager which constructed the Query is closed, then the Query.execute methods throw JDOFatalUserException. */ -public class ExecuteQueryWhenPersistenceManagerIsClosed extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.1-1 (ExecuteQueryWhenPersistenceManagerIsClosed) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ExecuteQueryWhenPersistenceManagerIsClosed.class); - } - - /** */ - public void test() { - pm = getPM(); +public class ExecuteQueryWhenPersistenceManagerIsClosed extends QueryTest { - runTestExecuteQueryWhenPersistenceManagerIsClosed(pm); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.1-1 (ExecuteQueryWhenPersistenceManagerIsClosed) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ExecuteQueryWhenPersistenceManagerIsClosed.class); + } - // pm.close(); - pm = null; - } + /** */ + public void test() { + pm = getPM(); + + runTestExecuteQueryWhenPersistenceManagerIsClosed(pm); + + //pm.close(); + pm = null; + } - /** */ - void runTestExecuteQueryWhenPersistenceManagerIsClosed(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); + /** */ + void runTestExecuteQueryWhenPersistenceManagerIsClosed(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.setFilter("x == 4"); - query.compile(); - Object results = query.execute(); - tx.commit(); - tx = null; - pm.close(); + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.setFilter("x == 4"); + query.compile(); + Object results = query.execute(); + tx.commit(); + tx = null; + pm.close(); - try { - Object result = query.execute(); - fail(ASSERTION_FAILED, "Query.execute after pm is closed should throw JDOUserException."); - } catch (JDOFatalUserException ex) { - // expected exception - if (debug) logger.debug("expected exception " + ex); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + try { + Object result = query.execute(); + fail(ASSERTION_FAILED, + "Query.execute after pm is closed should throw JDOUserException."); + } + catch (JDOFatalUserException ex) { + // expected exception + if (debug) logger.debug("expected exception " + ex); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ExecutingMultipleQueriesSimultaneouslyIsThreadSafe.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ExecutingMultipleQueriesSimultaneouslyIsThreadSafe.java index a0ddb965e..04040fbbe 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ExecutingMultipleQueriesSimultaneouslyIsThreadSafe.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ExecutingMultipleQueriesSimultaneouslyIsThreadSafe.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -21,151 +21,169 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; import org.apache.jdo.tck.util.ThreadExceptionHandler; /** - * Title: Executing Multiple Queries Simultaneously is ThreadSafe
    - * Keywords: query concurrency
    - * Assertion ID: A14.3-2.
    - * Assertion Description: Multiple queries might be executed simultaneously by different - * threads (but the implementation might choose to execute them serially). In either case, the - * execution must be thread safe. + *Title: Executing Multiple Queries Simultaneously is ThreadSafe + *
    + *Keywords: query concurrency + *
    + *Assertion ID: A14.3-2. + *
    + *Assertion Description: +Multiple queries might be executed simultaneously by different threads +(but the implementation might choose to execute them serially). +In either case, the execution must be thread safe. + */ + public class ExecutingMultipleQueriesSimultaneouslyIsThreadSafe extends MultipleActiveQueryInstanceInSamePersistenceManager { + + static int nrOfThreads = 20; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.3-2 (ExecutingMultipleQueriesSimultaneouslyIsThreadSafe) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ExecutingMultipleQueriesSimultaneouslyIsThreadSafe.class); + } - static int nrOfThreads = 20; - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.3-2 (ExecutingMultipleQueriesSimultaneouslyIsThreadSafe) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ExecutingMultipleQueriesSimultaneouslyIsThreadSafe.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - if (debug) - logger.debug(getThreadName() + ": Starting " + nrOfThreads + " concurrent threads."); - ThreadExceptionHandler group = new ThreadExceptionHandler(); - Thread[] threads = new Thread[nrOfThreads]; - for (int i = 0; i < nrOfThreads; i++) { - // Runnable r = new QueryExecuter(pm); - Runnable r = new ExecutingMultipleQueriesSimultaneouslyIsThreadSafe().getQueryExecuter(pm); - Thread t = new Thread(group, r); - t.setName("ThreadID-" + i); - threads[i] = t; - if (debug) logger.debug(getThreadName() + ": Running"); - t.start(); - } - - if (debug) logger.debug(getThreadName() + ": Waiting for threads to join..."); - for (int i = 0; i < nrOfThreads; i++) { + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); try { - threads[i].join(); - } catch (InterruptedException e) { + tx.begin(); + + if (debug) + logger.debug(getThreadName() + ": Starting " + + nrOfThreads + " concurrent threads."); + ThreadExceptionHandler group = new ThreadExceptionHandler(); + Thread[] threads = new Thread[nrOfThreads]; + for (int i = 0; i < nrOfThreads; i++) { + // Runnable r = new QueryExecuter(pm); + Runnable r = + new ExecutingMultipleQueriesSimultaneouslyIsThreadSafe(). + getQueryExecuter(pm); + Thread t = new Thread(group, r); + t.setName("ThreadID-" + i); + threads[i] = t; + if (debug) logger.debug(getThreadName() + ": Running"); + t.start(); + } + + if (debug) + logger.debug(getThreadName() + + ": Waiting for threads to join..."); + for (int i = 0; i < nrOfThreads; i++) { + try { threads[i].join(); } + catch (InterruptedException e) { } + } + if (debug) logger.debug(getThreadName() + ": All threads joined."); + + tx.commit(); + tx = null; + + // check unhandled exceptions + Set uncaught = group.getAllUncaughtExceptions(); + if ((uncaught != null) && !uncaught.isEmpty()) { + for (Iterator i = uncaught.iterator(); i.hasNext();) { + Map.Entry next = (Map.Entry)i.next(); + Thread thread = (Thread)next.getKey(); + Throwable problem = (Throwable)next.getValue(); + if (debug) { + logger.debug("uncaught exception in thread " + thread + + " stacktrace:"); + problem.printStackTrace(); + } + fail(ASSERTION_FAILED, + "Thread " + thread + ": uncaught exception " + problem); + } + } } - } - if (debug) logger.debug(getThreadName() + ": All threads joined."); - - tx.commit(); - tx = null; - - // check unhandled exceptions - Set uncaught = group.getAllUncaughtExceptions(); - if ((uncaught != null) && !uncaught.isEmpty()) { - for (Iterator i = uncaught.iterator(); i.hasNext(); ) { - Map.Entry next = (Map.Entry) i.next(); - Thread thread = (Thread) next.getKey(); - Throwable problem = (Throwable) next.getValue(); - if (debug) { - logger.debug("uncaught exception in thread " + thread + " stacktrace:"); - problem.printStackTrace(); - } - fail(ASSERTION_FAILED, "Thread " + thread + ": uncaught exception " + problem); + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } - - /** */ - String getThreadName() { - return "[" + Thread.currentThread().getName() + "]"; - } - - /** Will be removed. */ - Runnable getQueryExecuter(PersistenceManager pm) { - return new QueryExecuter(pm); - } - - /** Will be removed. */ - void executeQueries(PersistenceManager ignore) { - pm = getPM(); - setInsertedObjects(pm); - super.executeQueries(pm); - pm.close(); - pm = null; - } - - /** Will be removed. */ - void setInsertedObjects(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - Object results = query.execute(); - for (Iterator i = ((Collection) results).iterator(); i.hasNext(); ) { - inserted.add(i.next()); - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + String getThreadName() { + return "[" + Thread.currentThread().getName() + "]"; } - } - /** */ - class QueryExecuter implements Runnable { + /** Will be removed. */ + Runnable getQueryExecuter(PersistenceManager pm) { + return new QueryExecuter(pm); + } - final PersistenceManager pm; + /** Will be removed. */ + void executeQueries(PersistenceManager ignore) { + pm = getPM(); + setInsertedObjects(pm); + super.executeQueries(pm); + pm.close(); + pm = null; + } + + /** Will be removed. */ + void setInsertedObjects(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + Object results = query.execute(); + for (Iterator i=((Collection)results).iterator(); i.hasNext();) { + inserted.add(i.next()); + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } /** */ - public QueryExecuter(PersistenceManager pm) { - this.pm = pm; + class QueryExecuter implements Runnable { + + final PersistenceManager pm; + + /** */ + public QueryExecuter(PersistenceManager pm) { + this.pm = pm; + } + + /** */ + public void run() { + ExecutingMultipleQueriesSimultaneouslyIsThreadSafe.this.executeQueries(pm); + } } - /** */ - public void run() { - ExecutingMultipleQueriesSimultaneouslyIsThreadSafe.this.executeQueries(pm); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ExecutingQueryWhenNoTransactionNoNontransactionalRead.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ExecutingQueryWhenNoTransactionNoNontransactionalRead.java index 2a82337af..d6fc06539 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ExecutingQueryWhenNoTransactionNoNontransactionalRead.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ExecutingQueryWhenNoTransactionNoNontransactionalRead.java @@ -5,72 +5,81 @@ * 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 + * + * 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.jdo.tck.query.jdoql; import javax.jdo.Extent; import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Query; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Executing Query when no Transaction, no NontransactionalRead
    - * Keywords: query
    - * Assertion ID: A14.6.1-2.
    - * Assertion Description: If the NontransactionalRead property is false - * , and a transaction is not active, then the execute methods throw - * JDOUserException. - */ -public class ExecutingQueryWhenNoTransactionNoNontransactionalRead extends QueryTest { + *Title: Executing Query when no Transaction, no NontransactionalRead + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.1-2. + *
    + *Assertion Description: +If the NontransactionalRead property is false, +and a transaction is not active, then the execute methods throw +JDOUserException. - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.1-2 (ExecutingQueryWhenNoTransactionNoNontransactionalRead) failed: "; + */ - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ExecutingQueryWhenNoTransactionNoNontransactionalRead.class); - } +public class ExecutingQueryWhenNoTransactionNoNontransactionalRead + extends QueryTest { - /** */ - public void testNegative() { - PersistenceManager pm = getPM(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.1-2 (ExecutingQueryWhenNoTransactionNoNontransactionalRead) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ExecutingQueryWhenNoTransactionNoNontransactionalRead.class); + } - pm.currentTransaction().setNontransactionalRead(false); - runTestNewQuery(pm); - } + /** */ + public void testNegative() { + PersistenceManager pm = getPM(); + + pm.currentTransaction().setNontransactionalRead(false); + runTestNewQuery(pm); + } - /** */ - void runTestNewQuery(PersistenceManager pm) { - Class clazz = PCPoint.class; - Extent extent = pm.getExtent(clazz, true); - Query query = pm.newQuery(); - query.setClass(clazz); - query.setCandidates(extent); - try { - Object results = query.execute(); - fail( - ASSERTION_FAILED, - "Querying outside transactions should throw exception with non transactional read set to false"); - } catch (JDOUserException ex) { - // expected exception - if (debug) logger.debug("expected exception " + ex); + /** */ + void runTestNewQuery(PersistenceManager pm) { + Class clazz = PCPoint.class; + Extent extent = pm.getExtent(clazz, true); + Query query = pm.newQuery(); + query.setClass(clazz); + query.setCandidates(extent); + try { + Object results = query.execute(); + fail(ASSERTION_FAILED, + "Querying outside transactions should throw exception with non transactional read set to false"); + } + catch (JDOUserException ex) { + // expected exception + if (debug) logger.debug("expected exception " + ex); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/Having.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/Having.java index e5ac01aaf..0d25ee36f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/Having.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/Having.java @@ -5,20 +5,21 @@ * 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 + * + * 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.jdo.tck.query.jdoql; import java.util.Arrays; -import javax.jdo.JDOQLTypedQuery; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.QEmployee; @@ -26,152 +27,161 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Having.
    - * Keywords: query
    - * Assertion ID: A14.6.10-2.
    - * Assertion Description: When having is specified, the having expression consists of + *Title: Having. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.10-2. + *
    + *Assertion Description: + * When having is specified, the having expression consists of * arithmetic and boolean expressions containing aggregate expressions. */ public class Having extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.10-2 (Having) failed: "; - - /** - * The array of invalid queries which may be executed as single string queries and as API queries. - */ - private static final QueryElementHolder[] INVALID_QUERIES = { - // HAVING clause is not a boolean expression - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "department, AVG(weeklyhours)", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ "department HAVING firstname", - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - // HAVING clause is a non-aggregate expression using a non-grouping field - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "department, AVG(weeklyhours)", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ "department HAVING firstname == 'emp1First'", - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Having.class); - } - - /** */ - public void testPositive0() { - Object expected = - Arrays.asList( - new Object[] { - new Object[] {getTransientCompanyModelInstance("dept1"), Double.valueOf(33.0)}, - new Object[] {getTransientCompanyModelInstance("dept2"), Double.valueOf(0.0)} - }); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.groupBy(cand.department).having(cand.department.count().gt(0L)); - query.result(false, cand.department, cand.weeklyhours.avg()); - - QueryElementHolder holder = + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.10-2 (Having) failed: "; + + /** + * The array of invalid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] INVALID_QUERIES = { + // HAVING clause is not a boolean expression new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "department, AVG(weeklyhours)", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ "department HAVING COUNT(department) > 0", - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testPositive1() { - // HAVING clause uses field that isn't contained in the SELECT clause. - Object expected = - Arrays.asList( - new Object[] { - new Object[] {getTransientCompanyModelInstance("dept1"), Double.valueOf(33.0)}, - new Object[] {getTransientCompanyModelInstance("dept2"), Double.valueOf(0.0)} - }); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.groupBy(cand.department).having(cand.personid.count().gt(1L)); - query.result(false, cand.department, cand.weeklyhours.avg()); - - QueryElementHolder holder = + /*UNIQUE*/ null, + /*RESULT*/ "department, AVG(weeklyhours)", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ "department HAVING firstname", + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + // HAVING clause is a non-aggregate expression using a non-grouping field new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "department, AVG(weeklyhours)", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ "department HAVING COUNT(personid) > 1", - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testNegative() { - for (int i = 0; i < INVALID_QUERIES.length; i++) { - compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); - compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + /*UNIQUE*/ null, + /*RESULT*/ "department, AVG(weeklyhours)", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ "department HAVING firstname == 'emp1First'", + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Having.class); + } + + /** */ + public void testPositive0() { + Object expected = Arrays.asList(new Object[] { + new Object[] { + getTransientCompanyModelInstance("dept1"), + Double.valueOf(33.0)}, + new Object[] { + getTransientCompanyModelInstance("dept2"), + Double.valueOf(0.0)}}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.groupBy(cand.department).having(cand.department.count().gt(0L)); + query.result(false, cand.department, cand.weeklyhours.avg()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "department, AVG(weeklyhours)", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ "department HAVING COUNT(department) > 0", + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testPositive1() { + // HAVING clause uses field that isn't contained in the SELECT clause. + Object expected = Arrays.asList(new Object[] { + new Object[] { + getTransientCompanyModelInstance("dept1"), + Double.valueOf(33.0)}, + new Object[] { + getTransientCompanyModelInstance("dept2"), + Double.valueOf(0.0)}}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.groupBy(cand.department).having(cand.personid.count().gt(1L)); + query.result(false, cand.department, cand.weeklyhours.avg()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "department, AVG(weeklyhours)", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ "department HAVING COUNT(personid) > 1", + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null , + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testNegative() { + for (int i = 0; i < INVALID_QUERIES.length; i++) { + compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], + false); + } + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/IdentifiersEqualFieldNames.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/IdentifiersEqualFieldNames.java index ce89e8790..804cacecd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/IdentifiersEqualFieldNames.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/IdentifiersEqualFieldNames.java @@ -5,214 +5,215 @@ * 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 + * + * 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.jdo.tck.query.jdoql; -import javax.jdo.JDOQLTypedQuery; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.Person; -import org.apache.jdo.tck.pc.company.QDepartment; -import org.apache.jdo.tck.pc.company.QPerson; import org.apache.jdo.tck.query.QueryElementHolder; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.pc.company.QDepartment; +import org.apache.jdo.tck.pc.company.QPerson; + +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Identifiers Equal Field Names.
    - * Keywords: query
    - * Assertion ID: A14.6.2-43.
    - * Assertion Description: Identifiers that are persistent field names or public final static - * field names are required to be supported by JDO implementations. + *Title: Identifiers Equal Field Names. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-43. + *
    + *Assertion Description: + * Identifiers that are persistent field names or + * public final static field names are required + * to be supported by JDO implementations. */ public class IdentifiersEqualFieldNames extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-43 (IdentifiersEqualFieldNames) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IdentifiersEqualFieldNames.class); - } - - /** */ - public void testPositive0() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.firstname.eq("emp1First")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this.firstname == 'emp1First'", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testPositive1() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.personid.lt((long) Byte.MAX_VALUE)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this.personid < Byte.MAX_VALUE", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testPositive2() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - query.filter( - cand.employees.size().gt(org.apache.jdo.tck.pc.company.Department.RECOMMENDED_NO_OF_EMPS)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employees.size() > org.apache.jdo.tck.pc.company.Department.RECOMMENDED_NO_OF_EMPS", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testPositive3() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - query.filter(cand.employees.size().gt(Department.RECOMMENDED_NO_OF_EMPS)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employees.size() > Department.RECOMMENDED_NO_OF_EMPS", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testPositive4() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - query.filter(cand.employees.size().gt(Department.RECOMMENDED_NO_OF_EMPS)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employees.size() > RECOMMENDED_NO_OF_EMPS", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-43 (IdentifiersEqualFieldNames) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IdentifiersEqualFieldNames.class); + } + + /** */ + public void testPositive0() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.firstname.eq("emp1First")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this.firstname == 'emp1First'", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testPositive1() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.personid.lt((long)Byte.MAX_VALUE)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this.personid < Byte.MAX_VALUE", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testPositive2() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"dept1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + query.filter(cand.employees.size().gt(org.apache.jdo.tck.pc.company.Department.RECOMMENDED_NO_OF_EMPS)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.size() > org.apache.jdo.tck.pc.company.Department.RECOMMENDED_NO_OF_EMPS", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testPositive3() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"dept1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + query.filter(cand.employees.size().gt(Department.RECOMMENDED_NO_OF_EMPS)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.size() > Department.RECOMMENDED_NO_OF_EMPS", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testPositive4() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"dept1"}) ; + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + query.filter(cand.employees.size().gt(Department.RECOMMENDED_NO_OF_EMPS)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.size() > RECOMMENDED_NO_OF_EMPS", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/IfElseInFilter.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/IfElseInFilter.java index ec5d651ea..3ae2ad439 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/IfElseInFilter.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/IfElseInFilter.java @@ -5,21 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql; -import javax.jdo.JDOQLTypedQuery; -import javax.jdo.query.BooleanExpression; -import javax.jdo.query.IfThenElseExpression; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.DentalInsurance; import org.apache.jdo.tck.pc.company.Employee; @@ -30,241 +28,244 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; +import javax.jdo.query.BooleanExpression; +import javax.jdo.query.IfThenElseExpression; +import javax.jdo.query.NumericExpression; + /** - * Title: Use of If Else expression in filter
    - * Keywords: query
    - * Assertion ID: A14.6.x
    - * Assertion Description: + *Title: Use of If Else expression in filter + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.x + *
    + *Assertion Description: */ -public class IfElseInFilter extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.x (IfElseInFilter) failed: "; +public class IfElseInFilter extends QueryTest { - /** - * The array of invalid queries which may be executed as single string queries and as API queries. - */ - private static final QueryElementHolder[] INVALID_QUERIES = { - // Invalid type of condition expression - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "(IF (this.firstname) 0 ELSE 1) == 0", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - // missing ELSE - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ DentalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ "(IF (this.employee == null) 15000) == 15000", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - // type of THEN expr must be the same as type of ELSE expr - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ DentalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ "(IF (this.employee == null) 'Michael' ELSE this.employee) == 'Michael'", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null) - }; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.x (IfElseInFilter) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IfElseInFilter.class); - } + /** + * The array of invalid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] INVALID_QUERIES = { + // Invalid type of condition expression + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "(IF (this.firstname) 0 ELSE 1) == 0", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + // missing ELSE + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ DentalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ "(IF (this.employee == null) 15000) == 15000", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + // type of THEN expr must be the same as type of ELSE expr + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ DentalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ "(IF (this.employee == null) 'Michael' ELSE this.employee) == 'Michael'", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IfElseInFilter.class); + } - /** */ - public void testPositive0() { - // simple If/Else using literals - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp5"}); + /** */ + public void testPositive0() { + // simple If/Else using literals + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp5"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - IfThenElseExpression ifExpr = - query.ifThenElse(cand.department.name.eq("Development"), 15000.0, 25000.0); - query.filter(cand.salary.gt(ifExpr)); - query.orderBy(cand.personid.asc()); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + IfThenElseExpression ifExpr = + query.ifThenElse(cand.department.name.eq("Development"), 15000.0,25000.0); + query.filter(cand.salary.gt(ifExpr)); + query.orderBy(cand.personid.asc()); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this.salary > (IF (this.department.name == 'Development') 15000 ELSE 25000)", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "this.personid", - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this.salary > (IF (this.department.name == 'Development') 15000 ELSE 25000)", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "this.personid", + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - /** */ - public void testPositive1() { - // simple If/Else using relationships - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3"}); + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + /** */ + public void testPositive1() { + // simple If/Else using relationships + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp2", "emp3"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - IfThenElseExpression ifExpr = - query.ifThenElse( - Long.class, - cand.manager.eq((Employee) null), - cand.mentor.department.deptid, - cand.manager.department.deptid); - query.filter(ifExpr.eq(cand.department.deptid)); - query.orderBy(cand.personid.asc()); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + IfThenElseExpression ifExpr = query.ifThenElse(Long.class, + cand.manager.eq((Employee)null), cand.mentor.department.deptid, cand.manager.department.deptid); + query.filter(ifExpr.eq(cand.department.deptid)); + query.orderBy(cand.personid.asc()); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "(IF (this.manager == null) this.mentor.department.deptid ELSE this.manager.department.deptid) == this.department.deptid", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "this.personid", - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "(IF (this.manager == null) this.mentor.department.deptid ELSE this.manager.department.deptid) == this.department.deptid", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "this.personid", + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - /** */ - public void testPositive2() { - // multiple If/Else with distinct conditions - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + /** */ + public void testPositive2() { + // multiple If/Else with distinct conditions + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - BooleanExpression cond1 = cand.salary.gt(0.0).and(cand.salary.lt(10000.1)); - BooleanExpression cond2 = cand.salary.gt(10000.1).and(cand.salary.lt(20000.1)); - BooleanExpression cond3 = cand.salary.gt(20000.1).and(cand.salary.lt(30000.1)); - IfThenElseExpression ifExpr = - query.ifThen(cond1, 1).ifThen(cond2, 2).ifThen(cond3, 3).elseEnd(4); - query.filter(ifExpr.eq(2)); - query.orderBy(cand.personid.asc()); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + BooleanExpression cond1 = cand.salary.gt(0.0).and(cand.salary.lt(10000.1)); + BooleanExpression cond2 = cand.salary.gt(10000.1).and(cand.salary.lt(20000.1)); + BooleanExpression cond3 = cand.salary.gt(20000.1).and(cand.salary.lt(30000.1)); + IfThenElseExpression ifExpr = + query.ifThen(cond1, 1).ifThen(cond2, 2).ifThen(cond3, 3).elseEnd(4); + query.filter(ifExpr.eq(2)); + query.orderBy(cand.personid.asc()); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "(IF (0.0 <= this.salary && this.salary < 10000.1) 1 ELSE " - + "IF (10000.1 <= this.salary && this.salary < 20000.1) 2 ELSE " - + "IF (20000.1 <= this.salary && this.salary < 30000.1) 3 ELSE 4) == 2", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "this.personid", - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "(IF (0.0 <= this.salary && this.salary < 10000.1) 1 ELSE " + + "IF (10000.1 <= this.salary && this.salary < 20000.1) 2 ELSE " + + "IF (20000.1 <= this.salary && this.salary < 30000.1) 3 ELSE 4) == 2", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "this.personid", + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - /** */ - public void testPositive3() { - // multiple If/Else with overlapping conditions - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + /** */ + public void testPositive3() { + // multiple If/Else with overlapping conditions + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - BooleanExpression cond1 = cand.salary.lt(10000.1); - BooleanExpression cond2 = cand.salary.lt(20000.1); - BooleanExpression cond3 = cand.salary.lt(30000.1); - IfThenElseExpression ifExpr = - query.ifThen(cond1, 1).ifThen(cond2, 2).ifThen(cond3, 3).elseEnd(4); - query.filter(ifExpr.eq(2)); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + BooleanExpression cond1 = cand.salary.lt(10000.1); + BooleanExpression cond2 = cand.salary.lt(20000.1); + BooleanExpression cond3 = cand.salary.lt(30000.1); + IfThenElseExpression ifExpr = + query.ifThen(cond1, 1).ifThen(cond2, 2).ifThen(cond3, 3).elseEnd(4); + query.filter(ifExpr.eq(2)); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "(IF (this.salary < 10000.1) 1 ELSE " - + "IF (this.salary < 20000.1) 2 ELSE IF (this.salary < 30000.1) 3 ELSE 4) == 2", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "this.personid", - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "(IF (this.salary < 10000.1) 1 ELSE " + + "IF (this.salary < 20000.1) 2 ELSE IF (this.salary < 30000.1) 3 ELSE 4) == 2", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "this.personid", + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } - /** */ - public void testNegative() { - for (int i = 0; i < INVALID_QUERIES.length; i++) { - compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); - compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + /** */ + public void testNegative() { + for (int i = 0; i < INVALID_QUERIES.length; i++) { + compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], + false); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/IgnoreCacheFalse.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/IgnoreCacheFalse.java index b7aeeef49..5dc2bb176 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/IgnoreCacheFalse.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/IgnoreCacheFalse.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,144 +19,172 @@ import java.util.Collection; import java.util.Iterator; + import javax.jdo.JDOHelper; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Query with ignoreCache=false.
    - * Keywords: query
    - * Assertion ID: A14.6.1-7.
    - * Assertion Description: With ignoreCache set to false: - * + *Title: Query with ignoreCache=false. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.1-7. + *
    + *Assertion Description: + * With ignoreCache set to false: *
      - *
    • if instances were made persistent in the current transaction, the instances will be - * considered part of the candidate instances. - *
    • if instances were deleted in the current transaction, the instances will not be considered - * part of the candidate instances. - *
    • modified instances will be evaluated using their current transactional values. + *
    • if instances were made persistent in the current transaction, + * the instances will be considered part of the candidate instances.
    • + *
    • if instances were deleted in the current transaction, the instances + * will not be considered part of the candidate instances.
    • + *
    • modified instances will be evaluated using their current transactional + * values.
    • *
    */ -public class IgnoreCacheFalse extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.1-7 (IgnoreCacheFalse) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IgnoreCacheFalse.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PrimitiveTypes.class); - super.localSetUp(); - loadAndPersistPrimitiveTypes(getPM()); - } - /** */ - public void test() { - pm = getPM(); +public class IgnoreCacheFalse extends QueryTest { - try { - // set ignoreCache flag - pm.setIgnoreCache(false); - runTestNewInstance(pm); - runTestDeletedInstance(pm); - runTestModifiedInstance(pm); - } finally { - pm.close(); - pm = null; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.1-7 (IgnoreCacheFalse) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IgnoreCacheFalse.class); } - } - - /** */ - void runTestNewInstance(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - tx.begin(); - - // create new instance - PrimitiveTypes newInstance = new PrimitiveTypes(); - newInstance.setId(98L); - newInstance.setIntNotNull(98); - pm.makePersistent(newInstance); - - Collection result = - (Collection) pm.newQuery(PrimitiveTypes.class, "intNotNull == 98").execute(); - // check result - if (result.isEmpty()) - fail(ASSERTION_FAILED, "Query should find new instance, but query result is empty"); - Iterator i = result.iterator(); - PrimitiveTypes p = (PrimitiveTypes) i.next(); - if (p.getId() != 98L) - fail(ASSERTION_FAILED, "Query returned wrong instance with id " + p.getId()); - if (i.hasNext()) fail(ASSERTION_FAILED, "Query returned more than one instance"); - - if (debug) logger.debug("New instance is part of query result"); - tx.rollback(); - } - - /** */ - void runTestDeletedInstance(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - tx.begin(); - - Collection tmp = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 3").execute(); - PrimitiveTypes instance3 = (PrimitiveTypes) tmp.iterator().next(); - pm.deletePersistent(instance3); - - Collection result = (Collection) pm.newQuery(PrimitiveTypes.class, "intNotNull == 3").execute(); - // check result - if (result.isEmpty()) { - if (debug) logger.debug("deleted instance not part of query result."); - } else { - // query result not empty => problem - PrimitiveTypes p = (PrimitiveTypes) result.iterator().next(); - if (JDOHelper.isDeleted(p)) - fail(ASSERTION_FAILED, "query result should not include deleted instance"); - else fail(ASSERTION_FAILED, "query returns suspicious isntance " + p); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PrimitiveTypes.class); + super.localSetUp(); + loadAndPersistPrimitiveTypes(getPM()); } - tx.rollback(); - } - - /** */ - void runTestModifiedInstance(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - tx.begin(); - - Collection tmp = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 5").execute(); - PrimitiveTypes instance5 = (PrimitiveTypes) tmp.iterator().next(); - instance5.setIntNotNull(99); - - Collection result = - (Collection) pm.newQuery(PrimitiveTypes.class, "intNotNull == 99").execute(); - // check result - if (result.isEmpty()) { - fail(ASSERTION_FAILED, "Query should find modified instance, but query result is empty"); + + /** */ + public void test() { + pm = getPM(); + + try { + // set ignoreCache flag + pm.setIgnoreCache(false); + runTestNewInstance(pm); + runTestDeletedInstance(pm); + runTestModifiedInstance(pm); + } + finally { + pm.close(); + pm = null; + } + } + + /** */ + void runTestNewInstance(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + tx.begin(); + + // create new instance + PrimitiveTypes newInstance = new PrimitiveTypes(); + newInstance.setId(98L); + newInstance.setIntNotNull(98); + pm.makePersistent(newInstance); + + Collection result = (Collection)pm.newQuery( + PrimitiveTypes.class, "intNotNull == 98").execute(); + // check result + if (result.isEmpty()) + fail(ASSERTION_FAILED, + "Query should find new instance, but query result is empty"); + Iterator i = result.iterator(); + PrimitiveTypes p = (PrimitiveTypes)i.next(); + if (p.getId() != 98L) + fail(ASSERTION_FAILED, + "Query returned wrong instance with id " + p.getId()); + if (i.hasNext()) + fail(ASSERTION_FAILED, + "Query returned more than one instance"); + + if (debug) + logger.debug("New instance is part of query result"); + + tx.rollback(); + } + + /** */ + void runTestDeletedInstance(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + tx.begin(); + + Collection tmp = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 3").execute(); + PrimitiveTypes instance3 = (PrimitiveTypes)tmp.iterator().next(); + pm.deletePersistent(instance3); + + Collection result = (Collection)pm.newQuery( + PrimitiveTypes.class, "intNotNull == 3").execute(); + // check result + if (result.isEmpty()) { + if (debug) + logger.debug("deleted instance not part of query result."); + } + else { + // query result not empty => problem + PrimitiveTypes p = (PrimitiveTypes)result.iterator().next(); + if (JDOHelper.isDeleted(p)) + fail(ASSERTION_FAILED, + "query result should not include deleted instance"); + else + fail(ASSERTION_FAILED, + "query returns suspicious isntance " + p); + } + tx.rollback(); + } + + /** */ + void runTestModifiedInstance(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + tx.begin(); + + Collection tmp = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 5").execute(); + PrimitiveTypes instance5 = (PrimitiveTypes)tmp.iterator().next(); + instance5.setIntNotNull(99); + + Collection result = (Collection)pm.newQuery( + PrimitiveTypes.class, "intNotNull == 99").execute(); + // check result + if (result.isEmpty()) { + fail(ASSERTION_FAILED, + "Query should find modified instance, but query result is empty"); + } + Iterator i = result.iterator(); + PrimitiveTypes p = (PrimitiveTypes)i.next(); + if (p.getId() != 5L) + fail(ASSERTION_FAILED, + "Query returned wrong instance with id " + p.getId()); + if (p.getIntNotNull() != 99) + fail(ASSERTION_FAILED, + "Query returned instance with wrong intNotNull field value " + + p.getIntNotNull()); + if (i.hasNext()) + fail(ASSERTION_FAILED, + "Query returned more than one instance"); + + if (debug) + logger.debug("Modified instance is part of query result"); + + tx.rollback(); } - Iterator i = result.iterator(); - PrimitiveTypes p = (PrimitiveTypes) i.next(); - if (p.getId() != 5L) - fail(ASSERTION_FAILED, "Query returned wrong instance with id " + p.getId()); - if (p.getIntNotNull() != 99) - fail( - ASSERTION_FAILED, - "Query returned instance with wrong intNotNull field value " + p.getIntNotNull()); - if (i.hasNext()) fail(ASSERTION_FAILED, "Query returned more than one instance"); - - if (debug) logger.debug("Modified instance is part of query result"); - - tx.rollback(); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/MultipleActiveQueryInstanceInSamePersistenceManager.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/MultipleActiveQueryInstanceInSamePersistenceManager.java index 55459ab71..bbbb9c174 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/MultipleActiveQueryInstanceInSamePersistenceManager.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/MultipleActiveQueryInstanceInSamePersistenceManager.java @@ -5,102 +5,116 @@ * 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 + * + * 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.jdo.tck.query.jdoql; + import java.util.ArrayList; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Multiple Active Query Instances in Same PersistenceMana ger
    - * Keywords: query concurrency
    - * Assertion ID: A14.3-1.
    - * Assertion Description: Multiple JDO Query instances might be active - * simultaneously in the same JDO PersistenceManager instance. + *Title: Multiple Active Query Instances in Same PersistenceMana +ger + *
    + *Keywords: query concurrency + *
    + *Assertion ID: A14.3-1. + *
    + *Assertion Description: Multiple JDO Query instances might + *be active simultaneously in the same JDO PersistenceManager + *instance. */ -public class MultipleActiveQueryInstanceInSamePersistenceManager extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.3-1 (MultipleActiveQueryInstanceInSamePersistenceManager) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MultipleActiveQueryInstanceInSamePersistenceManager.class); - } - public void testPositive() { - PersistenceManager pm = getPM(); - if (debug) - logger.debug("\nExecuting test MultipleActiveQueryInstanceInSamePersistenceManager()..."); - - executeQueries(pm); - - if (debug) logger.debug("Test MultipleActiveQueryInstanceInSamePersistenceManager: Passed"); - } - - /** */ - void executeQueries(PersistenceManager pm) { - // query selecting all point instances - pm.currentTransaction().begin(); - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); +public class MultipleActiveQueryInstanceInSamePersistenceManager extends QueryTest { - // query selecting point with x value 0 - Query query2 = pm.newQuery(); - query2.setClass(PCPoint.class); - query2.setCandidates(pm.getExtent(PCPoint.class, false)); - query2.setFilter("x == 0"); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.3-1 (MultipleActiveQueryInstanceInSamePersistenceManager) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MultipleActiveQueryInstanceInSamePersistenceManager.class); + } - // execute first query - Object results = query.execute(); + public void testPositive() { + PersistenceManager pm = getPM(); + if (debug) + logger.debug("\nExecuting test MultipleActiveQueryInstanceInSamePersistenceManager()..."); - // check query result of first query - List expected = new ArrayList(); - expected.add(new PCPoint(0, 0)); - expected.add(new PCPoint(1, 1)); - expected.add(new PCPoint(2, 2)); - expected.add(new PCPoint(3, 3)); - expected.add(new PCPoint(4, 4)); - expected = getFromInserted(expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 0", results, expected); + executeQueries(pm); - // execute second query - Object results2 = query2.execute(); + if (debug) + logger.debug("Test MultipleActiveQueryInstanceInSamePersistenceManager: Passed"); + } - // check query result of second query - List expected2 = new ArrayList(); - expected2.add(new PCPoint(0, 0)); - expected2 = getFromInserted(expected2); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 0", results2, expected2); - pm.currentTransaction().commit(); - } + /** */ + void executeQueries(PersistenceManager pm) { + // query selecting all point instances + pm.currentTransaction().begin(); + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + + // query selecting point with x value 0 + Query query2 = pm.newQuery(); + query2.setClass(PCPoint.class); + query2.setCandidates(pm.getExtent(PCPoint.class, false)); + query2.setFilter("x == 0"); + + // execute first query + Object results = query.execute(); + + // check query result of first query + List expected = new ArrayList(); + expected.add(new PCPoint(0, 0)); + expected.add(new PCPoint(1, 1)); + expected.add(new PCPoint(2, 2)); + expected.add(new PCPoint(3, 3)); + expected.add(new PCPoint(4, 4)); + expected = getFromInserted(expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 0", + results, expected); + + // execute second query + Object results2 = query2.execute(); + + // check query result of second query + List expected2 = new ArrayList(); + expected2.add(new PCPoint(0, 0)); + expected2 = getFromInserted(expected2); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 0", + results2, expected2); + pm.currentTransaction().commit(); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/MultipleIdenticalImports.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/MultipleIdenticalImports.java index 5206307e0..f52416d8b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/MultipleIdenticalImports.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/MultipleIdenticalImports.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,8 +19,11 @@ import java.util.HashMap; import java.util.Map; + import javax.jdo.JDOQLTypedQuery; import javax.jdo.query.Expression; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.Employee; @@ -30,146 +33,151 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Multiple identical imports
    - * Keywords: query
    - * Assertion ID: A14.4-5.
    - * Assertion Description: It is valid to specify the same import multiple times. + *Title: Multiple identical imports + *
    + *Keywords: query + *
    + *Assertion ID: A14.4-5. + *
    + *Assertion Description: + * It is valid to specify the same import multiple times. */ + public class MultipleIdenticalImports extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.4-5 (MultipleIdenticalImports) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MultipleIdenticalImports.class); - } - - /** */ - public void testImportDepartmentTwice() { - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - Expression empParam = query.parameter("d", Department.class); - query.filter(cand.department.eq(empParam)); - - Map paramValues = new HashMap<>(); - paramValues.put("d", getPersistentCompanyModelInstance("dept1")); - - // Import Department twice - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "department == d", - /*VARIABLES*/ null, - /*PARAMETERS*/ "Department d", - /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.Department; " - + "import org.apache.jdo.tck.pc.company.Department;", - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testImportDepartmentExplicitlyAndPerTypeImportOnDemand() { - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - Expression empParam = query.parameter("d", Department.class); - query.filter(cand.department.eq(empParam)); - - Map paramValues = new HashMap<>(); - paramValues.put("d", getPersistentCompanyModelInstance("dept1")); - - // Import Department explictly and per type-import-on-demand - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "department == d", - /*VARIABLES*/ null, - /*PARAMETERS*/ "Department d", - /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.Department; " - + "import org.apache.jdo.tck.pc.company.*", - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testTypeImportOnDemandTwice() { - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - Expression empParam = query.parameter("d", Department.class); - query.filter(cand.department.eq(empParam)); - - Map paramValues = new HashMap<>(); - paramValues.put("d", getPersistentCompanyModelInstance("dept1")); - - // type-import-on-demand twice - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "department == d", - /*VARIABLES*/ null, - /*PARAMETERS*/ "Department d", - /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.*; " - + "import org.apache.jdo.tck.pc.company.*", - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.4-5 (MultipleIdenticalImports) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MultipleIdenticalImports.class); + } + + /** + * + */ + public void testImportDepartmentTwice() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp2", "emp3"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + Expression empParam = query.parameter("d", Department.class); + query.filter(cand.department.eq(empParam)); + + Map paramValues = new HashMap<>(); + paramValues.put("d", getPersistentCompanyModelInstance("dept1")); + + // Import Department twice + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "department == d", + /*VARIABLES*/ null, + /*PARAMETERS*/ "Department d", + /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.Department; " + + "import org.apache.jdo.tck.pc.company.Department;", + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * + */ + public void testImportDepartmentExplicitlyAndPerTypeImportOnDemand() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp2", "emp3"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + Expression empParam = query.parameter("d", Department.class); + query.filter(cand.department.eq(empParam)); + + Map paramValues = new HashMap<>(); + paramValues.put("d", getPersistentCompanyModelInstance("dept1")); + + // Import Department explictly and per type-import-on-demand + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "department == d", + /*VARIABLES*/ null, + /*PARAMETERS*/ "Department d", + /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.Department; " + + "import org.apache.jdo.tck.pc.company.*", + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * + */ + public void testTypeImportOnDemandTwice() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp2", "emp3"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + Expression empParam = query.parameter("d", Department.class); + query.filter(cand.department.eq(empParam)); + + Map paramValues = new HashMap<>(); + paramValues.put("d", getPersistentCompanyModelInstance("dept1")); + + // type-import-on-demand twice + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "department == d", + /*VARIABLES*/ null, + /*PARAMETERS*/ "Department d", + /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.*; " + + "import org.apache.jdo.tck.pc.company.*", + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NamespaceOfIdentifiers.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NamespaceOfIdentifiers.java index 6a525e0bd..463f0e429 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NamespaceOfIdentifiers.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NamespaceOfIdentifiers.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,74 +19,78 @@ import java.util.Collection; import java.util.HashSet; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Namespace of Identifiers
    - * Keywords: query
    - * Assertion ID: A14.6.2-11.
    - * Assertion Description: Identifiers in the expression are considered to be in the name - * space of the specified class, with the addition of declared imports, parameters and variables. + *Title: Namespace of Identifiers + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-11. + *
    + *Assertion Description: + * Identifiers in the expression are considered to be in the name + * space of the specified class, with the addition of declared + * imports, parameters and variables. */ -public class NamespaceOfIdentifiers extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-11 (NamespaceOfIdentifiers) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NamespaceOfIdentifiers.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - - Collection instance9 = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 9").execute(); - Collection allInstances = (Collection) pm.newQuery(PrimitiveTypes.class, "true").execute(); - Collection empty = new HashSet(); - - // use of field names - runSimplePrimitiveTypesQuery("intNotNull == intNotNull", pm, allInstances, ASSERTION_FAILED); +public class NamespaceOfIdentifiers extends QueryTest { - // use of parameter names - runParameterPrimitiveTypesQuery( - "intNotNull == intNotNull", - "String intNotNull", - "Michael", - pm, - allInstances, - ASSERTION_FAILED); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-11 (NamespaceOfIdentifiers) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NamespaceOfIdentifiers.class); + } + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); - // use of field/parameter names - runParameterPrimitiveTypesQuery( - "this.intNotNull == intNotNull", - "int intNotNull", - Integer.valueOf(9), - pm, - instance9, - ASSERTION_FAILED); + Collection instance9 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 9").execute(); + Collection allInstances = (Collection)pm.newQuery( + PrimitiveTypes.class, "true").execute(); + Collection empty = new HashSet(); + + // use of field names + runSimplePrimitiveTypesQuery("intNotNull == intNotNull", + pm, allInstances, ASSERTION_FAILED); + + // use of parameter names + runParameterPrimitiveTypesQuery( + "intNotNull == intNotNull", "String intNotNull", "Michael", + pm, allInstances, ASSERTION_FAILED); + + // use of field/parameter names + runParameterPrimitiveTypesQuery( + "this.intNotNull == intNotNull", "int intNotNull", Integer.valueOf(9), + pm, instance9, ASSERTION_FAILED); - tx.commit(); - } + tx.commit(); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PrimitiveTypes.class); - loadAndPersistPrimitiveTypes(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PrimitiveTypes.class); + loadAndPersistPrimitiveTypes(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationComparisonWithNull.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationComparisonWithNull.java index 79b1e2e1b..bde01e697 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationComparisonWithNull.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationComparisonWithNull.java @@ -5,21 +5,22 @@ * 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 + * + * 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.jdo.tck.query.jdoql; -import javax.jdo.JDOQLTypedQuery; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; +import org.apache.jdo.tck.pc.company.FullTimeEmployee; import org.apache.jdo.tck.pc.company.MedicalInsurance; import org.apache.jdo.tck.pc.company.QEmployee; import org.apache.jdo.tck.pc.company.QMedicalInsurance; @@ -27,434 +28,449 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; + /** - * Title: Navigation Through a Reference and comparing a Relationship with null
    - * Keywords: query
    - * Assertion ID: A14.6.2-13.
    - * Assertion Description: Navigation through single-valued fields is specified by the Java - * language syntax of field_name.field_name....field_name. + *Title: Navigation Through a Reference and comparing a Relationship with null + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-13. + *
    + *Assertion Description: + * Navigation through single-valued fields is specified by the Java language + * syntax of field_name.field_name....field_name. */ + public class NavigationComparisonWithNull extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-13 (NavigationComparisonWithNull) failed: "; - - /** */ - public static final String NAVIGATION_TEST_COMPANY_TESTDATA = - "org/apache/jdo/tck/pc/company/companyForNavigationTests.xml"; - - /** - * Returns the name of the company test data resource. - * - * @return name of the company test data resource. - */ - protected String getCompanyTestDataResource() { - return NAVIGATION_TEST_COMPANY_TESTDATA; - } - - /* - * Manager relationship: - * emp0 - * emp1 - * emp2 - * emp3 - * emp10 - * emp4 - * emp5 - * emp6 - * emp7 - * emp8 - * emp9 - */ - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NavigationThroughReferencesUsesDotOperator.class); - } - - /** this.manager == null */ - public void testPositive0() { - // 0: simple manager check being null - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp0", "emp4", "emp7"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.filter(cand.manager.eq((Employee) null)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this.manager == null", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** this.manager != null */ - public void testPositive1() { - // 1: simple manager check being not null - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp5", "emp6", "emp8", "emp9", "emp10"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.filter(cand.manager.ne((Employee) null)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this.manager != null", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** !(this.manager == null) */ - public void testPositive2() { - // 2: simple manager check being not null using not operator - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp5", "emp6", "emp8", "emp9", "emp10"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.filter(cand.manager.eq((Employee) null).not()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "!(this.manager == null)", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** this.manager.manager == null Disabled, because it currently fails on the RI. */ - public void testPositive3() { - // 3: manager's manager check - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp0", "emp1", "emp4", "emp5", "emp6", "emp7", "emp8", "emp9"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.filter(cand.manager.manager.eq((Employee) null)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this.manager.manager == null", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** this.manager != null AND this.manager.manager == null */ - public void testPositive4() { - // 4: manager's manager check with extra check on first level manager - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp5", "emp6", "emp8", "emp9"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.filter(cand.manager.ne((Employee) null).and(cand.manager.manager.eq((Employee) null))); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this.manager != null && this.manager.manager == null", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** this.manager.manager != null */ - public void testPositive5() { - // 5 : manager's manager check not being null - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp2", "emp3", "emp10"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.filter(cand.manager.manager.ne((Employee) null)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this.manager.manager != null", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** !(this.manager.manager == null) */ - public void testPositive6() { - // 6 : manager's manager check not being null using not operator - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp2", "emp3", "emp10"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - QEmployee e = QEmployee.variable("e"); - query.filter(cand.manager.manager.eq((Employee) null).not()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "!(this.manager.manager == null)", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** this.employee.manager.manager == null Disabled, because it currently fails on the RI. */ - public void testPositive7() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"medicalIns1", "medicalIns4", "medicalIns5", "medicalIns98"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(MedicalInsurance.class); - QMedicalInsurance cand = QMedicalInsurance.candidate(); - query.filter(cand.employee.manager.manager.eq((Employee) null)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ MedicalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this.employee.manager.manager == null", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** - * this.employee != null AND this.employee.manager != null AND this.employee.manager.manager == - * null - */ - public void testPositive8() { - // 8 : multiple relationships - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"medicalIns1", "medicalIns5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(MedicalInsurance.class); - QMedicalInsurance cand = QMedicalInsurance.candidate(); - query.filter( - cand.employee - .ne((Employee) null) - .and(cand.employee.manager.ne((Employee) null)) - .and(cand.employee.manager.manager.eq((Employee) null))); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ MedicalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this.employee != null && this.employee.manager != null && " - + "this.employee.manager.manager == null", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** this.employee.manager.manager != null */ - public void testPositive9() { - // 9 : multiple relationships - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"medicalIns2", "medicalIns3"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(MedicalInsurance.class); - QMedicalInsurance cand = QMedicalInsurance.candidate(); - query.filter(cand.employee.manager.manager.ne((Employee) null)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ MedicalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this.employee.manager.manager != null", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** !(this.employee.manager.manager == null) */ - public void testPositive10() { - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"medicalIns2", "medicalIns3"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(MedicalInsurance.class); - QMedicalInsurance cand = QMedicalInsurance.candidate(); - query.filter(cand.employee.manager.manager.eq((Employee) null).not()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ MedicalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ "!(this.employee.manager.manager == null)", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-13 (NavigationComparisonWithNull) failed: "; + + /** */ + public static final String NAVIGATION_TEST_COMPANY_TESTDATA = + "org/apache/jdo/tck/pc/company/companyForNavigationTests.xml"; + + /** + * Returns the name of the company test data resource. + * @return name of the company test data resource. + */ + protected String getCompanyTestDataResource() { + return NAVIGATION_TEST_COMPANY_TESTDATA; + } + + /* + * Manager relationship: + * emp0 + * emp1 + * emp2 + * emp3 + * emp10 + * emp4 + * emp5 + * emp6 + * emp7 + * emp8 + * emp9 + */ + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NavigationThroughReferencesUsesDotOperator.class); + } + + /** + * this.manager == null + */ + public void testPositive0() { + // 0: simple manager check being null + Object expected = getTransientCompanyModelInstancesAsList( + new String[]{"emp0", "emp4", "emp7"}); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.filter(cand.manager.eq((Employee)null)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this.manager == null", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * this.manager != null + */ + public void testPositive1() { + // 1: simple manager check being not null + Object expected = getTransientCompanyModelInstancesAsList( + new String[]{"emp1", "emp2", "emp3", "emp5", "emp6", "emp8", "emp9", "emp10"}); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.filter(cand.manager.ne((Employee)null)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this.manager != null", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * !(this.manager == null) + */ + public void testPositive2() { + // 2: simple manager check being not null using not operator + Object expected = getTransientCompanyModelInstancesAsList( + new String[]{"emp1", "emp2", "emp3", "emp5", "emp6", "emp8", "emp9", "emp10"}); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.filter(cand.manager.eq((Employee)null).not()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "!(this.manager == null)", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * this.manager.manager == null + * Disabled, because it currently fails on the RI. + */ + public void testPositive3() { + // 3: manager's manager check + Object expected = getTransientCompanyModelInstancesAsList( + new String[]{"emp0", "emp1", "emp4", "emp5", "emp6", "emp7", "emp8", "emp9"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.filter(cand.manager.manager.eq((Employee)null)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this.manager.manager == null", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * this.manager != null AND this.manager.manager == null + */ + public void testPositive4() { + // 4: manager's manager check with extra check on first level manager + Object expected = getTransientCompanyModelInstancesAsList( + new String[]{"emp1", "emp5", "emp6", "emp8", "emp9"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.filter(cand.manager.ne((Employee)null).and(cand.manager.manager.eq((Employee)null))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this.manager != null && this.manager.manager == null", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * this.manager.manager != null + */ + public void testPositive5() { + // 5 : manager's manager check not being null + Object expected = getTransientCompanyModelInstancesAsList( + new String[]{"emp2", "emp3", "emp10"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.filter(cand.manager.manager.ne((Employee)null)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this.manager.manager != null", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * !(this.manager.manager == null) + */ + public void testPositive6() { + // 6 : manager's manager check not being null using not operator + Object expected = getTransientCompanyModelInstancesAsList( + new String[]{"emp2", "emp3", "emp10"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + QEmployee e = QEmployee.variable("e"); + query.filter(cand.manager.manager.eq((Employee)null).not()); + + QueryElementHolder holder =new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "!(this.manager.manager == null)", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * this.employee.manager.manager == null + * Disabled, because it currently fails on the RI. + */ + public void testPositive7() { + Object expected = getTransientCompanyModelInstancesAsList( + new String[]{"medicalIns1", "medicalIns4", "medicalIns5", "medicalIns98"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(MedicalInsurance.class); + QMedicalInsurance cand = QMedicalInsurance.candidate(); + query.filter(cand.employee.manager.manager.eq((Employee)null)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ MedicalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this.employee.manager.manager == null", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * this.employee != null AND this.employee.manager != null AND this.employee.manager.manager == null + */ + public void testPositive8() { + // 8 : multiple relationships + Object expected = getTransientCompanyModelInstancesAsList( + new String[]{"medicalIns1", "medicalIns5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(MedicalInsurance.class); + QMedicalInsurance cand = QMedicalInsurance.candidate(); + query.filter(cand.employee.ne((Employee)null).and(cand.employee.manager.ne((Employee)null)) + .and(cand.employee.manager.manager.eq((Employee)null))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ MedicalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this.employee != null && this.employee.manager != null && " + + "this.employee.manager.manager == null", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * this.employee.manager.manager != null + */ + public void testPositive9() { + // 9 : multiple relationships + Object expected = getTransientCompanyModelInstancesAsList( + new String[]{"medicalIns2", "medicalIns3"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(MedicalInsurance.class); + QMedicalInsurance cand = QMedicalInsurance.candidate(); + query.filter(cand.employee.manager.manager.ne((Employee)null)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ MedicalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this.employee.manager.manager != null", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * !(this.employee.manager.manager == null) + */ + public void testPositive10() { + Object expected = getTransientCompanyModelInstancesAsList( + new String[]{"medicalIns2", "medicalIns3"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(MedicalInsurance.class); + QMedicalInsurance cand = QMedicalInsurance.candidate(); + query.filter(cand.employee.manager.manager.eq((Employee)null).not()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ MedicalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ "!(this.employee.manager.manager == null)", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationThroughACollectionField.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationThroughACollectionField.java index 7a51fea30..224c78845 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationThroughACollectionField.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationThroughACollectionField.java @@ -5,19 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql; -import javax.jdo.JDOQLTypedQuery; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.QDepartment; @@ -26,80 +26,85 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Navigation Through a Collection Field
    - * Keywords: query
    - * Assertion ID: A14.6.2-10.
    - * Assertion Description: Navigation through multi-valued fields (Collection - * types) is specified using a variable declaration and the Collection.contains(Object o) - * method. + *Title: Navigation Through a Collection Field + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-10. + *
    + *Assertion Description: + * Navigation through multi-valued fields (Collection types) is + * specified using a variable declaration and the + * Collection.contains(Object o) method. */ -public class NavigationThroughACollectionField extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-10 (NavigationThroughACollectionField) failed: "; - - /** */ - public static final String NAVIGATION_TEST_COMPANY_TESTDATA = - "org/apache/jdo/tck/pc/company/companyForNavigationTests.xml"; - - /** - * Returns the name of the company test data resource. - * - * @return name of the company test data resource. - */ - protected String getCompanyTestDataResource() { - return NAVIGATION_TEST_COMPANY_TESTDATA; - } +public class NavigationThroughACollectionField extends QueryTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NavigationThroughACollectionField.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-10 (NavigationThroughACollectionField) failed: "; + + /** */ + public static final String NAVIGATION_TEST_COMPANY_TESTDATA = + "org/apache/jdo/tck/pc/company/companyForNavigationTests.xml"; - /** */ - public void testPositive() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); + /** + * Returns the name of the company test data resource. + * @return name of the company test data resource. + */ + protected String getCompanyTestDataResource() { + return NAVIGATION_TEST_COMPANY_TESTDATA; + } + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NavigationThroughACollectionField.class); + } + + /** */ + public void testPositive() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"dept1"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - QEmployee e = QEmployee.variable("e"); - query.filter(cand.employees.contains(e).and(e.firstname.eq("emp1First"))); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + QEmployee e = QEmployee.variable("e"); + query.filter(cand.employees.contains(e).and(e.firstname.eq("emp1First"))); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employees.contains(e) && e.firstname == \"emp1First\"", - /*VARIABLES*/ "Employee e", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.contains(e) && e.firstname == \"emp1First\"", + /*VARIABLES*/ "Employee e", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationThroughANullValuedField.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationThroughANullValuedField.java index 17a83097c..efd2ffbda 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationThroughANullValuedField.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationThroughANullValuedField.java @@ -5,19 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql; -import javax.jdo.JDOQLTypedQuery; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.Employee; @@ -27,181 +27,181 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Navigation Through a Null-Valued Field
    - * Keywords: query
    - * Assertion ID: A14.6.2-9.
    - * Assertion Description: Navigation through a null-valued field, which would throw - * NullPointerException, is treated as if the filter expression returned false - * for the evaluation of the current set of variable values. Other values for variables might still - * qualify the candidate instance for inclusion in the result set. + *Title: Navigation Through a Null-Valued Field + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-9. + *
    + *Assertion Description: + * Navigation through a null-valued field, which would throw + * NullPointerException, is treated as if the filter expression + * returned false for the evaluation of the current set of variable + * values. Other values for variables might still qualify the candidate instance + * for inclusion in the result set. */ + public class NavigationThroughANullValuedField extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-9 (NavigationThroughANullValuedField) failed: "; - - /** */ - public static final String NAVIGATION_TEST_COMPANY_TESTDATA = - "org/apache/jdo/tck/pc/company/companyForNavigationTests.xml"; - - /** - * Returns the name of the company test data resource. - * - * @return name of the company test data resource. - */ - protected String getCompanyTestDataResource() { - return NAVIGATION_TEST_COMPANY_TESTDATA; - } - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NavigationThroughANullValuedField.class); - } - - public void testPositive1() { - // navigation through reference relationship field - // the relationship medicalInsurance is not set for emp2 and emp3 => - // they should not be part of the result - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.filter(cand.medicalInsurance.carrier.eq("Carrier1")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this.medicalInsurance.carrier == \"Carrier1\"", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - public void testPositive2() { - // navigation through reference relationship field - // emp5 and emp6 have have emp4 as manager - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp5", "emp6"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.filter(cand.manager.lastname.eq("emp4Last")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this.manager.lastname == \"emp4Last\"", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - public void testPositive3() { - // multiple navigation through reference relationship field - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp2", "emp3", "emp10"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.filter(cand.manager.manager.lastname.eq("emp0Last")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this.manager.manager.lastname == \"emp0Last\"", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - public void testPositive4() { - // navigation through collection relationship field - // employees emp2 and emp3 do not have a medicalInsurance, but emp1 - // matches the filter such that dept1 qualifies for inclusion in the - // result set. - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - QEmployee e = QEmployee.variable("e"); - query.filter(cand.employees.contains(e).and(e.medicalInsurance.carrier.eq("Carrier1"))); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employees.contains(e) && e.medicalInsurance.carrier == \"Carrier1\"", - /*VARIABLES*/ "Employee e", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-9 (NavigationThroughANullValuedField) failed: "; + + /** */ + public static final String NAVIGATION_TEST_COMPANY_TESTDATA = + "org/apache/jdo/tck/pc/company/companyForNavigationTests.xml"; + + /** + * Returns the name of the company test data resource. + * @return name of the company test data resource. + */ + protected String getCompanyTestDataResource() { + return NAVIGATION_TEST_COMPANY_TESTDATA; + } + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NavigationThroughANullValuedField.class); + } + + public void testPositive1() { + // navigation through reference relationship field + // the relationship medicalInsurance is not set for emp2 and emp3 => + // they should not be part of the result + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.filter(cand.medicalInsurance.carrier.eq("Carrier1")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this.medicalInsurance.carrier == \"Carrier1\"", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + + } + public void testPositive2() { + // navigation through reference relationship field + // emp5 and emp6 have have emp4 as manager + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp5", "emp6"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.filter(cand.manager.lastname.eq("emp4Last")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this.manager.lastname == \"emp4Last\"", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + public void testPositive3() { + // multiple navigation through reference relationship field + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp2", "emp3", "emp10"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.filter(cand.manager.manager.lastname.eq("emp0Last")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this.manager.manager.lastname == \"emp0Last\"", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + public void testPositive4() { + // navigation through collection relationship field + // employees emp2 and emp3 do not have a medicalInsurance, but emp1 + // matches the filter such that dept1 qualifies for inclusion in the + // result set. + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"dept1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + QEmployee e = QEmployee.variable("e"); + query.filter(cand.employees.contains(e).and(e.medicalInsurance.carrier.eq("Carrier1"))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.contains(e) && e.medicalInsurance.carrier == \"Carrier1\"", + /*VARIABLES*/ "Employee e", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationThroughReferencesUsesDotOperator.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationThroughReferencesUsesDotOperator.java index f2ac2030c..503a6f9b6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationThroughReferencesUsesDotOperator.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationThroughReferencesUsesDotOperator.java @@ -5,19 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql; -import javax.jdo.JDOQLTypedQuery; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.MedicalInsurance; @@ -27,177 +27,176 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Navigation Through a References uses Dot Operator
    - * Keywords: query
    - * Assertion ID: A14.6.2-13.
    - * Assertion Description: Navigation through single-valued fields is specified by the Java - * language syntax of field_name.field_name....field_name. + *Title: Navigation Through a References uses Dot Operator + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-13. + *
    + *Assertion Description: + * Navigation through single-valued fields is specified by the Java language + * syntax of field_name.field_name....field_name. */ + public class NavigationThroughReferencesUsesDotOperator extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-13 (NavigationThroughReferencesUsesDotOperator) failed: "; - - /** */ - public static final String NAVIGATION_TEST_COMPANY_TESTDATA = - "org/apache/jdo/tck/pc/company/companyForNavigationTests.xml"; - - /** - * Returns the name of the company test data resource. - * - * @return name of the company test data resource. - */ - protected String getCompanyTestDataResource() { - return NAVIGATION_TEST_COMPANY_TESTDATA; - } - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NavigationThroughReferencesUsesDotOperator.class); - } - - public void testPositive0() { - // navigation through one relationship - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.filter(cand.medicalInsurance.carrier.eq("Carrier1")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "medicalInsurance.carrier == \"Carrier1\"", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - public void testPositive1() { - // navigation through multiple relationships - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] { - "medicalIns1", "medicalIns2", "medicalIns3", "medicalIns4", "medicalIns5" - }); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(MedicalInsurance.class); - QMedicalInsurance cand = QMedicalInsurance.candidate(); - query.filter(cand.employee.department.name.eq("Development")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ MedicalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this.employee.department.name == \"Development\"", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - public void testPositive2() { - // navigation through a self referencing relationship - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"medicalIns2", "medicalIns3"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(MedicalInsurance.class); - QMedicalInsurance cand = QMedicalInsurance.candidate(); - query.filter(cand.employee.manager.firstname.eq("emp1First")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ MedicalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this.employee.manager.firstname == \"emp1First\"", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - public void testPositive3() { - // navigation through a self referencing relationship multiple times - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"medicalIns2", "medicalIns3"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(MedicalInsurance.class); - QMedicalInsurance cand = QMedicalInsurance.candidate(); - query.filter(cand.employee.manager.manager.firstname.eq("emp0First")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ MedicalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this.employee.manager.manager.firstname == \"emp0First\"", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-13 (NavigationThroughReferencesUsesDotOperator) failed: "; + + /** */ + public static final String NAVIGATION_TEST_COMPANY_TESTDATA = + "org/apache/jdo/tck/pc/company/companyForNavigationTests.xml"; + + /** + * Returns the name of the company test data resource. + * @return name of the company test data resource. + */ + protected String getCompanyTestDataResource() { + return NAVIGATION_TEST_COMPANY_TESTDATA; + } + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NavigationThroughReferencesUsesDotOperator.class); + } + + public void testPositive0() { + // navigation through one relationship + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.filter(cand.medicalInsurance.carrier.eq("Carrier1")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "medicalInsurance.carrier == \"Carrier1\"", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + public void testPositive1() { + // navigation through multiple relationships + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "medicalIns1", "medicalIns2", "medicalIns3", "medicalIns4", "medicalIns5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(MedicalInsurance.class); + QMedicalInsurance cand = QMedicalInsurance.candidate(); + query.filter(cand.employee.department.name.eq("Development")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ MedicalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this.employee.department.name == \"Development\"", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + public void testPositive2() { + // navigation through a self referencing relationship + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "medicalIns2", "medicalIns3"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(MedicalInsurance.class); + QMedicalInsurance cand = QMedicalInsurance.candidate(); + query.filter(cand.employee.manager.firstname.eq("emp1First")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ MedicalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this.employee.manager.firstname == \"emp1First\"", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + public void testPositive3() { + // navigation through a self referencing relationship multiple times + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "medicalIns2", "medicalIns3"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(MedicalInsurance.class); + QMedicalInsurance cand = QMedicalInsurance.candidate(); + query.filter(cand.employee.manager.manager.firstname.eq("emp0First")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ MedicalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this.employee.manager.manager.firstname == \"emp0First\"", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NegativeRange.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NegativeRange.java index d37a5e93d..e14acae2e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NegativeRange.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NegativeRange.java @@ -5,167 +5,172 @@ * 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 + * + * 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.jdo.tck.query.jdoql; import java.util.Arrays; -import javax.jdo.JDOQLTypedQuery; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.query.QueryElementHolder; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Negative Range.
    - * Keywords: query
    - * Assertion ID: A14.6.8-2.
    - * Assertion Description: If ((toExcl - fromIncl) LESS THAN EQUAL 0) evaluates to true, if - * the result of the query execution is a List, the returned List contains no instances, and an - * Iterator obtained from the List returns false to hasNext(). If the result of the query execution - * is a single instance (setUnique(true)), it will have a value of null. + *Title: Negative Range. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.8-2. + *
    + *Assertion Description: + * If ((toExcl - fromIncl) LESS THAN EQUAL 0) evaluates to true, if the result of the query + * execution is a List, the returned List contains no instances, + * and an Iterator obtained from the List returns false to hasNext(). + * If the result of the query execution is a single instance (setUnique(true)), + * it will have a value of null. */ public class NegativeRange extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.8-2 (NegativeRange) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NegativeRange.class); - } - - public void testNonUnique0() { - Object expected = Arrays.asList(); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ 4, - /*TO*/ 4, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - public void testNonUnique1() { - Object expected = Arrays.asList(); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ 4, - /*TO*/ 3, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - public void testUnique0() { - Object expected = null; - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ 4, - /*TO*/ 4, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - public void testUnique1() { - Object expected = null; - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ 4, - /*TO*/ 3, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.8-2 (NegativeRange) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NegativeRange.class); + } + + public void testNonUnique0() { + Object expected = Arrays.asList(); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ 4, + /*TO*/ 4, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + public void testNonUnique1() { + Object expected = Arrays.asList(); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ 4, + /*TO*/ 3, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + public void testUnique0() { + Object expected = null; + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ 4, + /*TO*/ 4, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + public void testUnique1() { + Object expected = null; + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ 4, + /*TO*/ 3, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NullCollectionsAndContainsMethod.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NullCollectionsAndContainsMethod.java index 4d778db92..1555b7cb0 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NullCollectionsAndContainsMethod.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NullCollectionsAndContainsMethod.java @@ -5,22 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql; -import java.util.HashMap; -import java.util.Map; -import javax.jdo.JDOQLTypedQuery; -import javax.jdo.query.Expression; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.Project; @@ -29,111 +26,123 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; +import javax.jdo.query.Expression; +import java.util.HashMap; +import java.util.Map; + /** - * Title: Null Collections and Contains Method
    - * Keywords: query nullcollection
    - * Assertion ID: A14.6.2-35.
    - * Assertion Description: null-valued fields of Collection types - * are treated as if they were empty and all contains methods return false - * . + *Title: Null Collections and Contains Method + *
    + *Keywords: query nullcollection + *
    + *Assertion ID: A14.6.2-35. + *
    + *Assertion Description: + * null-valued fields of Collection types are treated + * as if they were empty and all contains methods return + * false. */ + public class NullCollectionsAndContainsMethod extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-35 (NullCollectionsAndContainsMethod) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NullCollectionsAndContainsMethod.class); - } - - /** */ - public void testContains1() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - Expression empParam = query.parameter("p", Project.class); - query.filter(cand.personid.eq(1L).and(cand.projects.contains(empParam))); - - Map paramValues = new HashMap<>(); - paramValues.put("p", getPersistentCompanyModelInstance("proj1")); - - // contains - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "personid == 1 && projects.contains(p)", - /*VARIABLES*/ null, - /*PARAMETERS*/ "org.apache.jdo.tck.pc.company.Project p", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testContains2() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp2", "emp3"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - Expression empParam = query.parameter("p", Project.class); - query.filter(cand.projects.contains(empParam)); - - Map paramValues = new HashMap<>(); - paramValues.put("p", getPersistentCompanyModelInstance("proj1")); - - // contains - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "projects.contains(p)", - /*VARIABLES*/ null, - /*PARAMETERS*/ "org.apache.jdo.tck.pc.company.Project p", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - getPM().currentTransaction().begin(); - Employee emp1 = (Employee) getPersistentCompanyModelInstance("emp1"); - emp1.setProjects(null); - getPM().currentTransaction().commit(); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-35 (NullCollectionsAndContainsMethod) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NullCollectionsAndContainsMethod.class); + } + + /** + * + */ + public void testContains1() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + Expression empParam = query.parameter("p", Project.class); + query.filter(cand.personid.eq(1L).and(cand.projects.contains(empParam))); + + Map paramValues = new HashMap<>(); + paramValues.put("p", getPersistentCompanyModelInstance("proj1")); + + // contains + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "personid == 1 && projects.contains(p)", + /*VARIABLES*/ null, + /*PARAMETERS*/ "org.apache.jdo.tck.pc.company.Project p", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * + */ + public void testContains2() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp2", "emp3"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + Expression empParam = query.parameter("p", Project.class); + query.filter(cand.projects.contains(empParam)); + + Map paramValues = new HashMap<>(); + paramValues.put("p", getPersistentCompanyModelInstance("proj1")); + + // contains + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "projects.contains(p)", + /*VARIABLES*/ null, + /*PARAMETERS*/ "org.apache.jdo.tck.pc.company.Project p", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + getPM().currentTransaction().begin(); + Employee emp1 = (Employee) getPersistentCompanyModelInstance("emp1"); + emp1.setProjects(null); + getPM().currentTransaction().commit(); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NullCollectionsAndIsEmpty.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NullCollectionsAndIsEmpty.java index 96dcc1fea..5050db5b1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NullCollectionsAndIsEmpty.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NullCollectionsAndIsEmpty.java @@ -5,19 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql; -import javax.jdo.JDOQLTypedQuery; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.QEmployee; @@ -25,70 +25,76 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Handling of Null Collections and isEmpty in Queries
    - * Keywords: query nullcollection
    - * Assertion ID: A14.6.2-34.
    - * Assertion Description: null-valued fields of Collection types - * are treated as if they were empty and isEmpty returns true. + *Title: Handling of Null Collections and isEmpty in Queries + *
    + *Keywords: query nullcollection + *
    + *Assertion ID: A14.6.2-34. + *
    + *Assertion Description: + * null-valued fields of Collection types are treated + * as if they were empty and isEmpty returns true. */ -public class NullCollectionsAndIsEmpty extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-34 (NullCollectionsAndIsEmpty) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NullCollectionsAndIsEmpty.class); - } +public class NullCollectionsAndIsEmpty extends QueryTest { - /** */ - public void testPositive() { - // isEmpty - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-34 (NullCollectionsAndIsEmpty) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NullCollectionsAndIsEmpty.class); + } + + /** */ + public void testPositive() { + // isEmpty + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.filter(cand.personid.eq(1L).and(cand.projects.isEmpty())); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.filter(cand.personid.eq(1L).and(cand.projects.isEmpty())); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "personid == 1 && projects.isEmpty()", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "personid == 1 && projects.isEmpty()", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - getPM().currentTransaction().begin(); - Employee emp1 = (Employee) getPersistentCompanyModelInstance("emp1"); - emp1.setProjects(null); - getPM().currentTransaction().commit(); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + getPM().currentTransaction().begin(); + Employee emp1 = (Employee) getPersistentCompanyModelInstance("emp1"); + emp1.setProjects(null); + getPM().currentTransaction().commit(); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/OrderingSpecification.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/OrderingSpecification.java index 961bf9afa..6099e0836 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/OrderingSpecification.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/OrderingSpecification.java @@ -5,25 +5,29 @@ * 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 + * + * 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.jdo.tck.query.jdoql; + import java.util.ArrayList; import java.util.List; import java.util.ListIterator; + import javax.jdo.JDOQLTypedQuery; import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.DentalInsurance; import org.apache.jdo.tck.pc.company.QDentalInsurance; @@ -34,234 +38,233 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Ordering Specification
    - * Keywords: query
    - * Assertion ID: A14.6.6-1.
    - * Assertion Description: The Query ordering specification includes a list of - * one or more ordering declarations separated by commas. Each ordering declaration includes an - * expression whose type is one of: - * - *
      - *
    • primitive types except boolean - *
    • wrapper types except Boolean - *
    • BigDecimal - *
    • BigInteger - *
    • String - *
    • Date - *
    - * - * followed by one of the following words: "ascending" or - * "descending" which indicates the ordering of the values for that expression. - * Ordering might be specified including navigation. The name of the field to be used in ordering - * via navigation through single-valued fields is specified by the Java language syntax of - * field_name.field_name....field_name. + *Title: Ordering Specification + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.6-1. + *
    + *Assertion Description: The Query ordering specification includes a list of one or more ordering declarations separated by commas. Each ordering declaration includes an expression whose type is one of: +
      +
    • primitive types except boolean
    • +
    • wrapper types except Boolean
    • +
    • BigDecimal
    • +
    • BigInteger
    • +
    • String
    • +
    • Date
    • +
    +followed by one of the following words: "ascending" or + *"descending" which indicates the ordering of the values for that expression. Ordering might be specified including navigation. The name of the field to be used in ordering via navigation through single-valued fields is specified by the Java language syntax of field_name.field_name....field_name. */ + public class OrderingSpecification extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.6-1 (OrderingSpecification) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(OrderingSpecification.class); - } - - /** */ - public void testPositiveCompanyQueries0() { - // nulls first - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] { - "dentalIns99", "dentalIns1", "dentalIns2", "dentalIns3", "dentalIns4", "dentalIns5" - }); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(DentalInsurance.class); - QDentalInsurance cand = QDentalInsurance.candidate(); - query.orderBy(cand.lifetimeOrthoBenefit.asc().nullsFirst()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ DentalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "this.lifetimeOrthoBenefit ascending nulls first", - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testPositiveCompanyQueries1() { - // nulls last - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] { - "dentalIns1", "dentalIns2", "dentalIns3", "dentalIns4", "dentalIns5", "dentalIns99" - }); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(DentalInsurance.class); - QDentalInsurance cand = QDentalInsurance.candidate(); - query.orderBy(cand.lifetimeOrthoBenefit.asc().nullsLast()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ DentalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "this.lifetimeOrthoBenefit ascending nulls last", - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - - runTestOrderingSpecification01(pm); - runTestOrderingSpecification02(pm); - checkOrderingTypes(pm); - } - - /** */ - void runTestOrderingSpecification01(PersistenceManager pm) { - if (debug) logger.debug("\nExecuting test OrderingSpecification01() ..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.setOrdering("x ascending"); - Object results = query.execute(); - - // check query result - printOutput(results, inserted); - checkQueryResultWithOrder(ASSERTION_FAILED, "null", results, inserted); - if (debug) logger.debug("Test OrderingSpecification01(): Passed"); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.6-1 (OrderingSpecification) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(OrderingSpecification.class); + } + + /** */ + public void testPositiveCompanyQueries0() { + // nulls first + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "dentalIns99", "dentalIns1", "dentalIns2", "dentalIns3", "dentalIns4", "dentalIns5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(DentalInsurance.class); + QDentalInsurance cand = QDentalInsurance.candidate(); + query.orderBy(cand.lifetimeOrthoBenefit.asc().nullsFirst()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ DentalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "this.lifetimeOrthoBenefit ascending nulls first", + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); } - } - - /** */ - void runTestOrderingSpecification02(PersistenceManager pm) { - if (debug) logger.debug("\nExecuting test OrderingSpecification02() ..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.setOrdering("x descending"); - Object results = query.execute(); - - // check query result - List expected = new ArrayList(); - ListIterator li = inserted.listIterator(inserted.size()); - // construct expected results by iterating inserted objects backwards - while (li.hasPrevious()) { - Object obj = li.previous(); - expected.add(obj); - } - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithOrder(ASSERTION_FAILED, "null", results, expected); - if (debug) logger.debug("Test OrderingSpecification02(): Passed"); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void testPositiveCompanyQueries1() { + // nulls last + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "dentalIns1", "dentalIns2", "dentalIns3", "dentalIns4", "dentalIns5", "dentalIns99"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(DentalInsurance.class); + QDentalInsurance cand = QDentalInsurance.candidate(); + query.orderBy(cand.lifetimeOrthoBenefit.asc().nullsLast()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ DentalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "this.lifetimeOrthoBenefit ascending nulls last", + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + + runTestOrderingSpecification01(pm); + runTestOrderingSpecification02(pm); + checkOrderingTypes(pm); } - } - - /** */ - void checkOrderingTypes(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - Class clazz = PCPoint.class; - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(AllTypes.class); - query.setCandidates(pm.getExtent(AllTypes.class, false)); - - StringBuffer buffer = new StringBuffer(); - buffer.append(" fld_byte ascending"); - buffer.append(", fld_char ascending"); - buffer.append(", fld_double ascending"); - buffer.append(", fld_float ascending"); - buffer.append(", fld_int ascending"); - buffer.append(", fld_long ascending"); - buffer.append(", fld_short ascending"); - buffer.append(", fld_Byte descending"); - buffer.append(", fld_Character descending"); - buffer.append(", fld_Double descending"); - buffer.append(", fld_Float ascending"); - buffer.append(", fld_Integer descending"); - buffer.append(", fld_Long descending"); - buffer.append(", fld_Short descending"); - buffer.append(", fld_String descending"); - buffer.append(", fld_Date descending"); - buffer.append(", fld_BigDecimal descending"); - buffer.append(", fld_BigInteger ascending"); - query.setOrdering(buffer.toString()); - Object results = query.execute(); - - // Just check whether query compiles - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + void runTestOrderingSpecification01(PersistenceManager pm) { + if (debug) + logger.debug("\nExecuting test OrderingSpecification01() ..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.setOrdering("x ascending"); + Object results = query.execute(); + + // check query result + printOutput(results, inserted); + checkQueryResultWithOrder(ASSERTION_FAILED, "null", results, inserted); + if(debug) + logger.debug("Test OrderingSpecification01(): Passed"); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + void runTestOrderingSpecification02(PersistenceManager pm) { + if(debug) + logger.debug("\nExecuting test OrderingSpecification02() ..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.setOrdering("x descending"); + Object results = query.execute(); + + // check query result + List expected = new ArrayList(); + ListIterator li = inserted.listIterator(inserted.size()); + // construct expected results by iterating inserted objects backwards + while (li.hasPrevious()) { + Object obj = li.previous(); + expected.add(obj); + } + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithOrder(ASSERTION_FAILED, "null", results, expected); + if(debug) + logger.debug("Test OrderingSpecification02(): Passed"); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + void checkOrderingTypes(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + Class clazz = PCPoint.class; + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(AllTypes.class); + query.setCandidates(pm.getExtent(AllTypes.class, false)); + + StringBuffer buffer = new StringBuffer(); + buffer.append(" fld_byte ascending"); + buffer.append(", fld_char ascending"); + buffer.append(", fld_double ascending"); + buffer.append(", fld_float ascending"); + buffer.append(", fld_int ascending"); + buffer.append(", fld_long ascending"); + buffer.append(", fld_short ascending"); + buffer.append(", fld_Byte descending"); + buffer.append(", fld_Character descending"); + buffer.append(", fld_Double descending"); + buffer.append(", fld_Float ascending"); + buffer.append(", fld_Integer descending"); + buffer.append(", fld_Long descending"); + buffer.append(", fld_Short descending"); + buffer.append(", fld_String descending"); + buffer.append(", fld_Date descending"); + buffer.append(", fld_BigDecimal descending"); + buffer.append(", fld_BigInteger ascending"); + query.setOrdering(buffer.toString()); + Object results = query.execute(); + + // Just check whether query compiles + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ParenthesesMarkOperatorPrecedence.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ParenthesesMarkOperatorPrecedence.java index 6c70ae3fd..3864ad687 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ParenthesesMarkOperatorPrecedence.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/ParenthesesMarkOperatorPrecedence.java @@ -5,344 +5,394 @@ * 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 + * + * 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.jdo.tck.query.jdoql; + import java.util.ArrayList; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Parentheses Mark Operator Precedence
    - * Keywords: query
    - * Assertion ID: A14.6.2-37.
    - * Assertion Description: Parentheses can be used to explicitly mark operator precedence. + *Title: Parentheses Mark Operator Precedence + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-37. + *
    + *Assertion Description: Parentheses can be used to explicitly mark operator precedence. + */ + public class ParenthesesMarkOperatorPrecedence extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-37 (ParenthesesMarkOperatorPrecedence) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ParenthesesMarkOperatorPrecedence.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - - runTestParenthesesMarkOperatorPrecedence01(pm); - runTestParenthesesMarkOperatorPrecedence02(pm); - runTestParenthesesMarkOperatorPrecedence03(pm); - runTestParenthesesMarkOperatorPrecedence04(pm); - runTestParenthesesMarkOperatorPrecedence05(pm); - runTestParenthesesMarkOperatorPrecedence06(pm); - runTestParenthesesMarkOperatorPrecedence07(pm); - runTestParenthesesMarkOperatorPrecedence08(pm); - runTestParenthesesMarkOperatorPrecedence09(pm); - } - - /** */ - void runTestParenthesesMarkOperatorPrecedence01(PersistenceManager pm) { - if (debug) logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence01..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.setFilter("x == (1 + 1)"); - Object results = query.execute(); - - // check query result - List expected = new ArrayList(); - Object p3 = new PCPoint(2, 2); - expected.add(p3); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == (1 + 1)", results, expected); - if (debug) logger.debug("Test ParenthesesMarkOperatorPrecedence01 - Passed"); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-37 (ParenthesesMarkOperatorPrecedence) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ParenthesesMarkOperatorPrecedence.class); } - } - - /** */ - void runTestParenthesesMarkOperatorPrecedence02(PersistenceManager pm) { - if (debug) logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence01..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.setFilter("x == (1 + 1) * 2"); - Object results = query.execute(); - - // check query result - List expected = new ArrayList(); - Object p5 = new PCPoint(4, 4); - expected.add(p5); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == (1 + 1) * 2", results, expected); - if (debug) logger.debug("Test ParenthesesMarkOperatorPrecedence02 - Passed"); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + + runTestParenthesesMarkOperatorPrecedence01(pm); + runTestParenthesesMarkOperatorPrecedence02(pm); + runTestParenthesesMarkOperatorPrecedence03(pm); + runTestParenthesesMarkOperatorPrecedence04(pm); + runTestParenthesesMarkOperatorPrecedence05(pm); + runTestParenthesesMarkOperatorPrecedence06(pm); + runTestParenthesesMarkOperatorPrecedence07(pm); + runTestParenthesesMarkOperatorPrecedence08(pm); + runTestParenthesesMarkOperatorPrecedence09(pm); } - } - - /** */ - void runTestParenthesesMarkOperatorPrecedence03(PersistenceManager pm) { - if (debug) logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence03..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.setFilter("x == (9 - 1) * (3 + 5) / 32"); - Object results = query.execute(); - - // check query result - List expected = new ArrayList(); - Object p3 = new PCPoint(2, 2); - expected.add(p3); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, "x == (9 - 1) * (3 + 5) / 32", results, expected); - if (debug) logger.debug("Test ParenthesesMarkOperatorPrecedence03 - Passed"); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + void runTestParenthesesMarkOperatorPrecedence01(PersistenceManager pm) { + if(debug) + logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence01..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.setFilter("x == (1 + 1)"); + Object results = query.execute(); + + // check query result + List expected = new ArrayList(); + Object p3 = new PCPoint(2, 2); + expected.add(p3); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == (1 + 1)", + results, expected); + if(debug) + logger.debug("Test ParenthesesMarkOperatorPrecedence01 - Passed"); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - void runTestParenthesesMarkOperatorPrecedence04(PersistenceManager pm) { - if (debug) logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence04..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.setFilter("x == 2 && y == 2"); - Object results = query.execute(); - - // check query result - List expected = new ArrayList(); - Object p3 = new PCPoint(2, 2); - expected.add(p3); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 2 && y == 2", results, expected); - if (debug) logger.debug("Test ParenthesesMarkOperatorPrecedence04 - Passed"); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + void runTestParenthesesMarkOperatorPrecedence02(PersistenceManager pm) { + if(debug) + logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence01..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.setFilter("x == (1 + 1) * 2"); + Object results = query.execute(); + + // check query result + List expected = new ArrayList(); + Object p5 = new PCPoint(4, 4); + expected.add(p5); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == (1 + 1) * 2", + results, expected); + if(debug) + logger.debug("Test ParenthesesMarkOperatorPrecedence02 - Passed"); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - void runTestParenthesesMarkOperatorPrecedence05(PersistenceManager pm) { - if (debug) logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence05..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.setFilter("x == (1 + 1) || y == (1002 - 1000)"); - - Object results = query.execute(); - - // check query result - List expected = new ArrayList(); - Object p3 = new PCPoint(2, 2); - expected.add(p3); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, "x == (1 + 1) || y == (1002 - 1000)", results, expected); - if (debug) logger.debug("Test ParenthesesMarkOperatorPrecedence05 - Passed"); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + void runTestParenthesesMarkOperatorPrecedence03(PersistenceManager pm) { + if(debug) + logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence03..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.setFilter("x == (9 - 1) * (3 + 5) / 32"); + Object results = query.execute(); + + // check query result + List expected = new ArrayList(); + Object p3 = new PCPoint(2, 2); + expected.add(p3); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, + "x == (9 - 1) * (3 + 5) / 32", + results, expected); + if(debug) + logger.debug("Test ParenthesesMarkOperatorPrecedence03 - Passed"); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - void runTestParenthesesMarkOperatorPrecedence06(PersistenceManager pm) { - if (debug) logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence06..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.setFilter("x == (1 * 2) && true"); - Object results = query.execute(); - - // check query result - List expected = new ArrayList(); - Object p3 = new PCPoint(2, 2); - expected.add(p3); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == (1 * 2) && true", results, expected); - if (debug) logger.debug("Test ParenthesesMarkOperatorPrecedence06 - Passed"); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + void runTestParenthesesMarkOperatorPrecedence04(PersistenceManager pm) { + if(debug) + logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence04..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.setFilter("x == 2 && y == 2"); + Object results = query.execute(); + + // check query result + List expected = new ArrayList(); + Object p3 = new PCPoint(2, 2); + expected.add(p3); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 2 && y == 2", + results, expected); + if(debug) + logger.debug("Test ParenthesesMarkOperatorPrecedence04 - Passed"); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - void runTestParenthesesMarkOperatorPrecedence07(PersistenceManager pm) { - if (debug) logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence07..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.setFilter("x == (10000 / 5000) || false"); - Object results = query.execute(); - - // check query result - List expected = new ArrayList(); - Object p3 = new PCPoint(2, 2); - expected.add(p3); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, "x == (10000 / 5000) || false", results, expected); - if (debug) logger.debug("Test ParenthesesMarkOperatorPrecedence07 - Passed"); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + void runTestParenthesesMarkOperatorPrecedence05(PersistenceManager pm) { + if(debug) + logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence05..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.setFilter("x == (1 + 1) || y == (1002 - 1000)"); + + Object results = query.execute(); + + // check query result + List expected = new ArrayList(); + Object p3 = new PCPoint(2, 2); + expected.add(p3); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, + "x == (1 + 1) || y == (1002 - 1000)", results, expected); + if(debug) + logger.debug("Test ParenthesesMarkOperatorPrecedence05 - Passed"); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - void runTestParenthesesMarkOperatorPrecedence08(PersistenceManager pm) { - if (debug) logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence08..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.setFilter("(x == 2) == true"); - Object results = query.execute(); - - // check query result - List expected = new ArrayList(); - Object p3 = new PCPoint(2, 2); - expected.add(p3); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "(x == 2) == true", results, expected); - if (debug) logger.debug("Test ParenthesesMarkOperatorPrecedence08 - Passed"); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + void runTestParenthesesMarkOperatorPrecedence06(PersistenceManager pm) { + if(debug) + logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence06..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.setFilter("x == (1 * 2) && true"); + Object results = query.execute(); + + // check query result + List expected = new ArrayList(); + Object p3 = new PCPoint(2, 2); + expected.add(p3); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, + "x == (1 * 2) && true", results, expected); + if(debug) + logger.debug("Test ParenthesesMarkOperatorPrecedence06 - Passed"); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - void runTestParenthesesMarkOperatorPrecedence09(PersistenceManager pm) { - if (debug) logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence09..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.setFilter("(x == ((21 - 1/1)/10 + 1)) | (false && true)"); - Object results = query.execute(); - - // check query result - List expected = new ArrayList(); - Object p4 = new PCPoint(3, 3); - expected.add(p4); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, "(x == ((21 - 1/1)/10 + 1)) | (false && true)", results, expected); - if (debug) logger.debug("Test ParenthesesMarkOperatorPrecedence09 - Passed"); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + void runTestParenthesesMarkOperatorPrecedence07(PersistenceManager pm) { + if(debug) logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence07..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.setFilter("x == (10000 / 5000) || false"); + Object results = query.execute(); + + // check query result + List expected = new ArrayList(); + Object p3 = new PCPoint(2, 2); + expected.add(p3); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, + "x == (10000 / 5000) || false", results, expected); + if(debug) logger.debug("Test ParenthesesMarkOperatorPrecedence07 - Passed"); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + void runTestParenthesesMarkOperatorPrecedence08(PersistenceManager pm) { + if(debug) + logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence08..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.setFilter("(x == 2) == true"); + Object results = query.execute(); + + // check query result + List expected = new ArrayList(); + Object p3 = new PCPoint(2, 2); + expected.add(p3); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "(x == 2) == true", + results, expected); + if(debug) logger.debug("Test ParenthesesMarkOperatorPrecedence08 - Passed"); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + void runTestParenthesesMarkOperatorPrecedence09(PersistenceManager pm) { + if(debug) + logger.debug("\nExecuting Test ParenthesesMarkOperatorPrecedence09..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.setFilter("(x == ((21 - 1/1)/10 + 1)) | (false && true)"); + Object results = query.execute(); + + // check query result + List expected = new ArrayList(); + Object p4 = new PCPoint(3, 3); + expected.add(p4); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, + "(x == ((21 - 1/1)/10 + 1)) | (false && true)", + results, expected); + if(debug) + logger.debug("Test ParenthesesMarkOperatorPrecedence09 - Passed"); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/PositiveRange.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/PositiveRange.java index a914de02f..0b086de6c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/PositiveRange.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/PositiveRange.java @@ -5,19 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql; -import javax.jdo.JDOQLTypedQuery; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.pc.company.QPerson; @@ -25,157 +25,159 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Positive Range.
    - * Keywords: query
    - * Assertion ID: A14.6.8-1.
    - * Assertion Description: setRange(long fromIncl, long toExcl) + *Title: Positive Range. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.8-1. + *
    + *Assertion Description: + * setRange(long fromIncl, long toExcl) */ public class PositiveRange extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.8-1 (PositiveRange) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(PositiveRange.class); - } - - public void testPositive0() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.orderBy(cand.personid.asc()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "personid ASCENDING", - /*FROM*/ 0, - /*TO*/ 5, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - public void testPositive1() { - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3", "emp4"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.orderBy(cand.personid.asc()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "personid ASCENDING", - /*FROM*/ 0, - /*TO*/ 4, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - public void testPositive2() { - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.orderBy(cand.personid.asc()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "personid ASCENDING", - /*FROM*/ 1, - /*TO*/ 5, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - public void testPositive3() { - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp2", "emp3", "emp4"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.orderBy(cand.personid.asc()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "personid ASCENDING", - /*FROM*/ 1, - /*TO*/ 4, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.8-1 (PositiveRange) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(PositiveRange.class); + } + + public void testPositive0() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.orderBy(cand.personid.asc()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "personid ASCENDING", + /*FROM*/ 0, + /*TO*/ 5, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + public void testPositive1() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.orderBy(cand.personid.asc()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "personid ASCENDING", + /*FROM*/ 0, + /*TO*/ 4, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + public void testPositive2() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp2", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.orderBy(cand.personid.asc()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "personid ASCENDING", + /*FROM*/ 1, + /*TO*/ 5, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + public void testPositive3() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp2", "emp3", "emp4"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.orderBy(cand.personid.asc()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "personid ASCENDING", + /*FROM*/ 1, + /*TO*/ 4, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/QueryIsSerializable.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/QueryIsSerializable.java index b4c60153d..e573b59fc 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/QueryIsSerializable.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/QueryIsSerializable.java @@ -5,16 +5,16 @@ * 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 + * + * 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.jdo.tck.query.jdoql; import java.io.FileInputStream; @@ -24,162 +24,174 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Query is Serializable
    - * Keywords: query
    - * Assertion ID: A14.3-7 A14.6-1.
    - * Assertion Description: The class implementing the Query interface must be - * serializable. The serialized fields include the candidate class, the filter, parameter - * declarations, variable declarations, imports, and ordering specification. + *Title: Query is Serializable + *
    + *Keywords: query + *
    + *Assertion ID: A14.3-7 A14.6-1. + *
    + *Assertion Description: The class implementing the Query + *interface must be serializable. The serialized fields include the candidate + *class, the filter, parameter declarations, variable declarations, imports, + *and ordering specification. */ + public class QueryIsSerializable extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.3-7 A14.6-1 (QueryIsSerializable) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(QueryIsSerializable.class); - } - - /** - * @throws Exception exception - */ - public void testPositive() throws Exception { - PersistenceManager pm = getPM(); - - runTestQueryIsSerializable01(pm); - runTestQueryIsSerializable02(pm); - runTestQueryIsSerializable03(pm); - } - - /** */ - void runTestQueryIsSerializable01(PersistenceManager pm) { - if (debug) logger.debug("\nExecuting test QueryIsSerializable01() ..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - if (query instanceof Serializable) { - if (debug) { - logger.debug("Query extends serializable interface."); - } - } else { - fail(ASSERTION_FAILED, "Query does not extends serializable interface."); - } - - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.3-7 A14.6-1 (QueryIsSerializable) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(QueryIsSerializable.class); } - } - - /** */ - void runTestQueryIsSerializable02(PersistenceManager pm) throws Exception { - if (debug) logger.debug("\nExecuting test QueryIsSerializable02() ..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.setFilter("x == 3"); - query.compile(); - - ObjectOutputStream oos = null; - try { - if (debug) logger.debug("Attempting to serialize Query object."); - oos = new ObjectOutputStream(new FileOutputStream(SERIALZED_QUERY)); - oos.writeObject(query); - if (debug) logger.debug("Query object serialized."); - } finally { - if (oos != null) { - try { - oos.flush(); - } catch (Exception ex) { - } - try { - oos.close(); - } catch (Exception ex) { - } + + /** + * + * @throws Exception exception + */ + public void testPositive() throws Exception { + PersistenceManager pm = getPM(); + + runTestQueryIsSerializable01(pm); + runTestQueryIsSerializable02(pm); + runTestQueryIsSerializable03(pm); + } + + /** */ + void runTestQueryIsSerializable01(PersistenceManager pm) { + if (debug) logger.debug("\nExecuting test QueryIsSerializable01() ..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + if (query instanceof Serializable) { + if (debug) { + logger.debug("Query extends serializable interface."); + } + } + else { + fail(ASSERTION_FAILED, + "Query does not extends serializable interface."); + } + + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } + } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + void runTestQueryIsSerializable02(PersistenceManager pm) throws Exception { + if (debug) logger.debug("\nExecuting test QueryIsSerializable02() ..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.setFilter("x == 3"); + query.compile(); + + ObjectOutputStream oos = null; + try { + if (debug) logger.debug("Attempting to serialize Query object."); + oos = new ObjectOutputStream( + new FileOutputStream(SERIALZED_QUERY)); + oos.writeObject(query); + if (debug) logger.debug("Query object serialized."); + } + finally { + if (oos != null) { + try { oos.flush();} catch(Exception ex) {} + try { oos.close();} catch(Exception ex) {} + } + } + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - void runTestQueryIsSerializable03(PersistenceManager pm) throws Exception { - if (debug) logger.debug("\nExecuting test QueryIsSerializable03() ..."); - Object restoredQuery = null; - ObjectInputStream ois = null; - - try { - if (debug) logger.debug("Attempting to de-serialize Query object."); - ois = new ObjectInputStream(new FileInputStream("query.ser")); - restoredQuery = ois.readObject(); - if (debug) logger.debug("Query object restored."); - } finally { - if (ois != null) { + + /** */ + void runTestQueryIsSerializable03(PersistenceManager pm) throws Exception { + if (debug) logger.debug("\nExecuting test QueryIsSerializable03() ..."); + Object restoredQuery = null; + ObjectInputStream ois = null; + try { - ois.close(); - } catch (Exception ex) { + if (debug) logger.debug("Attempting to de-serialize Query object."); + ois = new ObjectInputStream( new FileInputStream("query.ser")); + restoredQuery = ois.readObject(); + if (debug) logger.debug("Query object restored."); + } finally { + if (ois != null) { + try { ois.close();} catch(Exception ex) {} + } + } + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(restoredQuery); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.compile(); + Object results = query.execute(); + + // check query result + List expected = new ArrayList(); + Object p4 = new PCPoint(3, 3); + expected.add(p4); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected); + if (debug) logger.debug("Test QueryIsSerializable03(): Passed"); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } } - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(restoredQuery); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.compile(); - Object results = query.execute(); - - // check query result - List expected = new ArrayList(); - Object p4 = new PCPoint(3, 3); - expected.add(p4); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected); - if (debug) logger.debug("Test QueryIsSerializable03(): Passed"); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } } + + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/QueryResultPassedToAnotherQuery.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/QueryResultPassedToAnotherQuery.java index b79275e53..d27c5ef07 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/QueryResultPassedToAnotherQuery.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/QueryResultPassedToAnotherQuery.java @@ -5,178 +5,203 @@ * 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 + * + * 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.jdo.tck.query.jdoql; + import java.util.ArrayList; import java.util.Collection; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Query Result Passed to Another Query
    - * Keywords: query
    - * Assertion ID: A14.6.1-4.
    - * Assertion Description: The collection returned by Query.execute can be - * passed to another Query. + *Title: Query Result Passed to Another Query + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.1-4. + *
    + *Assertion Description: The collection returned by + *Query.execute can be passed to another Query. */ + public class QueryResultPassedToAnotherQuery extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.1-4 (QueryResultPassedToAnotherQuery) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(QueryResultPassedToAnotherQuery.class); - } - - Collection resultCln; - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - - setResultCollection(pm); - runTestQueryResultPassedToAnotherQuery01(pm); - runTestQueryResultPassedToAnotherQuery02(pm); - runTestQueryResultPassedToAnotherQuery03(pm); - - pm.close(); - pm = null; - } - - /** */ - void setResultCollection(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - resultCln = (Collection) query.execute(); - // Create a new collection for the result collection. - // This ensures that the result collection may be iterated - // outside of the scope of the current transaction. - resultCln = new ArrayList(resultCln); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.1-4 (QueryResultPassedToAnotherQuery) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(QueryResultPassedToAnotherQuery.class); } - } - - /** */ - void runTestQueryResultPassedToAnotherQuery01(PersistenceManager pm) { - if (debug) logger.debug("\nExecuting test QueryResultPassedToAnotherQuery01()..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(resultCln); - query.setFilter("x == 1"); - Object results = query.execute(); - - // check query result - List expected = new ArrayList(); - Object p2 = new PCPoint(1, 1); - expected.add(p2); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 1", results, expected); - if (debug) logger.debug("Test QueryResultPassedToAnotherQuery01: Passed"); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + Collection resultCln; + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + + setResultCollection(pm); + runTestQueryResultPassedToAnotherQuery01(pm); + runTestQueryResultPassedToAnotherQuery02(pm); + runTestQueryResultPassedToAnotherQuery03(pm); + + pm.close(); + pm = null; } - } - - /** */ - void runTestQueryResultPassedToAnotherQuery02(PersistenceManager pm) { - if (debug) logger.debug("\nExecuting test QueryResultPassedToAnotherQuery02()..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(PCPoint.class, resultCln); - query.setFilter("x == 1"); - Object results = query.execute(); - - // check query result - List expected = new ArrayList(); - Object p2 = new PCPoint(1, 1); - expected.add(p2); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 1", results, expected); - if (debug) logger.debug("Test QueryResultPassedToAnotherQuery02: Passed"); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + void setResultCollection(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + resultCln = (Collection)query.execute(); + // Create a new collection for the result collection. + // This ensures that the result collection may be iterated + // outside of the scope of the current transaction. + resultCln = new ArrayList(resultCln); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + void runTestQueryResultPassedToAnotherQuery01(PersistenceManager pm) { + if (debug) + logger.debug("\nExecuting test QueryResultPassedToAnotherQuery01()..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(resultCln); + query.setFilter("x == 1"); + Object results = query.execute(); + + // check query result + List expected = new ArrayList(); + Object p2 = new PCPoint(1, 1); + expected.add(p2); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 1", + results, expected); + if (debug) + logger.debug("Test QueryResultPassedToAnotherQuery01: Passed"); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + void runTestQueryResultPassedToAnotherQuery02(PersistenceManager pm) { + if (debug) + logger.debug("\nExecuting test QueryResultPassedToAnotherQuery02()..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(PCPoint.class, resultCln); + query.setFilter("x == 1"); + Object results = query.execute(); + + // check query result + List expected = new ArrayList(); + Object p2 = new PCPoint(1, 1); + expected.add(p2); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 1", + results, expected); + if (debug) + logger.debug("Test QueryResultPassedToAnotherQuery02: Passed"); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + void runTestQueryResultPassedToAnotherQuery03(PersistenceManager pm) { + if (debug) + logger.debug("\nExecuting test QueryResultPassedToAnotherQuery03()..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(PCPoint.class, resultCln, "x == 1"); + Object results = query.execute(); + + // check query result + List expected = new ArrayList(); + Object p2 = new PCPoint(1, 1); + expected.add(p2); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 1", + results, expected); + if (debug) + logger.debug("Test QueryResultPassedToAnotherQuery03: Passed"); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - void runTestQueryResultPassedToAnotherQuery03(PersistenceManager pm) { - if (debug) logger.debug("\nExecuting test QueryResultPassedToAnotherQuery03()..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(PCPoint.class, resultCln, "x == 1"); - Object results = query.execute(); - - // check query result - List expected = new ArrayList(); - Object p2 = new PCPoint(1, 1); - expected.add(p2); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == 1", results, expected); - if (debug) logger.debug("Test QueryResultPassedToAnotherQuery03: Passed"); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/QueryWithNoFilter.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/QueryWithNoFilter.java index 12acc2193..66a6d7378 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/QueryWithNoFilter.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/QueryWithNoFilter.java @@ -5,92 +5,103 @@ * 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 + * + * 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.jdo.tck.query.jdoql; + import java.util.ArrayList; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Query with no Filter
    - * Keywords: query
    - * Assertion ID: A14.6.2-1.
    - * Assertion Description: If the Query filter is not specified, then it - * defaults to true, which has the effect of filtering the input Collection - * only for class type. + *Title: Query with no Filter + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-1. + *
    + *Assertion Description: If the Query filter is not + *specified, then it defaults to true, which has the effect of + *filtering the input Collection only for class type. */ -public class QueryWithNoFilter extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.2-1 (QueryWithNoFilter) failed: "; +public class QueryWithNoFilter extends QueryTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(QueryWithNoFilter.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-1 (QueryWithNoFilter) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(QueryWithNoFilter.class); + } - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - if (debug) logger.debug("\nExecuting test QueryWithNoFilter() ..."); + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + if(debug) logger.debug("\nExecuting test QueryWithNoFilter() ..."); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - Object results = query.execute(); + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + Object results = query.execute(); - // check query result - List expected = new ArrayList(); - Object p1 = new PCPoint(0, 0); - Object p2 = new PCPoint(1, 1); - Object p3 = new PCPoint(2, 2); - Object p4 = new PCPoint(3, 3); - Object p5 = new PCPoint(4, 4); - expected.add(p1); - expected.add(p2); - expected.add(p3); - expected.add(p4); - expected.add(p5); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected); + // check query result + List expected = new ArrayList(); + Object p1 = new PCPoint(0, 0); + Object p2 = new PCPoint(1, 1); + Object p3 = new PCPoint(2, 2); + Object p4 = new PCPoint(3, 3); + Object p5 = new PCPoint(4, 4); + expected.add(p1); + expected.add(p2); + expected.add(p3); + expected.add(p4); + expected.add(p5); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/RangeAsString.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/RangeAsString.java index f059b2617..f056ec8b2 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/RangeAsString.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/RangeAsString.java @@ -5,19 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql; -import javax.jdo.JDOQLTypedQuery; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.pc.company.QPerson; @@ -25,158 +25,160 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Range as String.
    - * Keywords: query
    - * Assertion ID: A14.6.8-3.
    - * Assertion Description: setRange(String range); + *Title: Range as String. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.8-3. + *
    + *Assertion Description: + * setRange(String range); */ public class RangeAsString extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.8-3 (RangeAsString) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(RangeAsString.class); - } - - /** */ - public void testPositive0() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.orderBy(cand.personid.asc()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "personid ASCENDING", - /*FROM*/ "0", - /*TO*/ "5", - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - /** */ - public void testPositive1() { - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3", "emp4"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.orderBy(cand.personid.asc()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "personid ASCENDING", - /*FROM*/ "0", - /*TO*/ "4", - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - /** */ - public void testPositive2() { - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.orderBy(cand.personid.asc()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "personid ASCENDING", - /*FROM*/ "1", - /*TO*/ "5", - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - /** */ - public void testPositive3() { - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp2", "emp3", "emp4"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.orderBy(cand.personid.asc()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "personid ASCENDING", - /*FROM*/ "1", - /*TO*/ "4", - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.8-3 (RangeAsString) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(RangeAsString.class); + } + + /** */ + public void testPositive0() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.orderBy(cand.personid.asc()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "personid ASCENDING", + /*FROM*/ "0", + /*TO*/ "5", + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + + } /** */ + public void testPositive1() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.orderBy(cand.personid.asc()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "personid ASCENDING", + /*FROM*/ "0", + /*TO*/ "4", + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + + } /** */ + public void testPositive2() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp2", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.orderBy(cand.personid.asc()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "personid ASCENDING", + /*FROM*/ "1", + /*TO*/ "5", + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + + } /** */ + public void testPositive3() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp2", "emp3", "emp4"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.orderBy(cand.personid.asc()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "personid ASCENDING", + /*FROM*/ "1", + /*TO*/ "4", + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/RestoredSerializedQueryInstanceLosesAssociationWithPM.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/RestoredSerializedQueryInstanceLosesAssociationWithPM.java index bda382ccc..ee98445df 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/RestoredSerializedQueryInstanceLosesAssociationWithPM.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/RestoredSerializedQueryInstanceLosesAssociationWithPM.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -21,76 +21,88 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; + import javax.jdo.JDOException; import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Restored Serialized Query Instance Loses Association With PM
    - * Keywords: query
    - * Assertion ID: A14.3-8.
    - * Assertion Description: If a serialized instance is restored, it loses its association - * with its former PersistenceManager. - */ -public class RestoredSerializedQueryInstanceLosesAssociationWithPM extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.3-8 (RestoredSerializedQueryInstanceLosesAssociationWithPM) failed: "; + *Title: Restored Serialized Query Instance Loses Association With PM + *
    + *Keywords: query + *
    + *Assertion ID: A14.3-8. + *
    + *Assertion Description: +If a serialized instance is restored, it loses its association with its former +PersistenceManager. - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(RestoredSerializedQueryInstanceLosesAssociationWithPM.class); - } + */ - /** - * @throws Exception exception - */ - public void test() throws Exception { - pm = getPM(); +public class RestoredSerializedQueryInstanceLosesAssociationWithPM + extends QueryTest { - checkRestoredQueryInstance(pm); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.3-8 (RestoredSerializedQueryInstanceLosesAssociationWithPM) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(RestoredSerializedQueryInstanceLosesAssociationWithPM.class); + } - pm.close(); - pm = null; - } + /** + * + * @throws Exception exception + */ + public void test() throws Exception { + pm = getPM(); - /** */ - void checkRestoredQueryInstance(PersistenceManager pm) throws Exception { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Query query = pm.newQuery(); - Class clazz = org.apache.jdo.tck.pc.company.Project.class; - query.setClass(clazz); - query.setCandidates(pm.getExtent(clazz, false)); - query.declareVariables( - "org.apache.jdo.tck.pc.company.Person a; org.apache.jdo.tck.pc.company.Person b"); - query.setFilter( - "reviewers.contains(a) && a.firstname==\"brazil\" || reviewers.contains(b) && b.firstname==\"brazil\""); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(baos); - oos.writeObject(query); - ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())); - query = (Query) ois.readObject(); + checkRestoredQueryInstance(pm); + + pm.close(); + pm = null; + } - try { - Object results = query.execute(); - fail( - ASSERTION_FAILED, - "A deserialized query instance should not execute successfully without associating that instance to a persistence manager"); - } catch (JDOException e) { - if (debug) logger.debug("Caught expected " + e); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + void checkRestoredQueryInstance(PersistenceManager pm) throws Exception { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Query query = pm.newQuery(); + Class clazz = org.apache.jdo.tck.pc.company.Project.class; + query.setClass(clazz); + query.setCandidates(pm.getExtent(clazz, false)); + query.declareVariables("org.apache.jdo.tck.pc.company.Person a; org.apache.jdo.tck.pc.company.Person b" ); + query.setFilter("reviewers.contains(a) && a.firstname==\"brazil\" || reviewers.contains(b) && b.firstname==\"brazil\"" ); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(query); + ObjectInputStream ois = + new ObjectInputStream( + new ByteArrayInputStream(baos.toByteArray())); + query = (Query) ois.readObject(); + + try { + Object results = query.execute(); + fail(ASSERTION_FAILED, + "A deserialized query instance should not execute successfully without associating that instance to a persistence manager"); + } + catch (JDOException e) { + if (debug) logger.debug("Caught expected " + e); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/SeparateNamespaceForTypeNames.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/SeparateNamespaceForTypeNames.java index 14a45271b..9b18e1dc7 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/SeparateNamespaceForTypeNames.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/SeparateNamespaceForTypeNames.java @@ -5,127 +5,138 @@ * 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 + * + * 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.jdo.tck.query.jdoql; -import java.util.HashMap; -import java.util.Map; -import javax.jdo.JDOQLTypedQuery; -import javax.jdo.query.Expression; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.Employee; +import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.pc.company.QDepartment; import org.apache.jdo.tck.pc.company.QEmployee; +import org.apache.jdo.tck.pc.company.QPerson; import org.apache.jdo.tck.query.QueryElementHolder; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; +import javax.jdo.query.Expression; +import java.util.HashMap; +import java.util.Map; + /** - * Title: Namespace of Type Names Separate From Fields, Variables, Parameters
    - * Keywords: query
    - * Assertion ID: A14.4-1.
    - * Assertion Description: Type names have their own namespace that is separate from the - * namespace for fields, variables and parameters. + *Title: Namespace of Type Names Separate From Fields, Variables, Parameters + *
    + *Keywords: query + *
    + *Assertion ID: A14.4-1. + *
    + *Assertion Description: +Type names have their own namespace that is separate +from the namespace for fields, variables and parameters. + */ + public class SeparateNamespaceForTypeNames extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.4-1 (SeparateNamespaceForTypeNames) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SeparateNamespaceForTypeNames.class); - } - - /** */ - public void testParameterName() { - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - Expression empParam = query.parameter("Department", Department.class); - query.filter(cand.department.eq(empParam)); - - Map paramValues = new HashMap<>(); - paramValues.put("Department", getPersistentCompanyModelInstance("dept1")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "department == Department", - /*VARIABLES*/ null, - /*PARAMETERS*/ "Department Department", - /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.Department", - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testVaiableName() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - QEmployee variable = QEmployee.variable("Employee"); - query.filter(cand.employees.contains(variable).and(variable.firstname.eq("emp1First"))); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employees.contains(Employee) && Employee.firstname == \"emp1First\"", - /*VARIABLES*/ "Employee Employee", - /*PARAMETERS*/ null, - /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.Employee", - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.4-1 (SeparateNamespaceForTypeNames) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SeparateNamespaceForTypeNames.class); + } + + /** + * + */ + public void testParameterName() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp2", "emp3"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + Expression empParam = query.parameter("Department", Department.class); + query.filter(cand.department.eq(empParam)); + + Map paramValues = new HashMap<>(); + paramValues.put("Department", getPersistentCompanyModelInstance("dept1")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "department == Department", + /*VARIABLES*/ null, + /*PARAMETERS*/ "Department Department", + /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.Department", + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * + */ + public void testVaiableName() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"dept1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + QEmployee variable = QEmployee.variable("Employee"); + query.filter(cand.employees.contains(variable).and(variable.firstname.eq("emp1First"))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.contains(Employee) && Employee.firstname == \"emp1First\"", + /*VARIABLES*/ "Employee Employee", + /*PARAMETERS*/ null, + /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.Employee", + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/WhiteSpaceIsACharacterAndIgnored.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/WhiteSpaceIsACharacterAndIgnored.java index 3fec479d0..016c31705 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/WhiteSpaceIsACharacterAndIgnored.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/WhiteSpaceIsACharacterAndIgnored.java @@ -5,131 +5,146 @@ * 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 + * + * 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.jdo.tck.query.jdoql; import java.util.ArrayList; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: White Space is a Character and is Ignored
    - * Keywords: query
    - * Assertion ID: A14.6.2-6.
    - * Assertion Description: White space (non-printing characters space, tab, carriage return, - * and line feed) is a separator and is otherwise ignored in a Query filter. + *Title: White Space is a Character and is Ignored + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-6. + *
    + *Assertion Description: White space (non-printing characters space, + *tab, carriage return, and line feed) is a separator and is otherwise ignored + *in a Query filter. */ -public class WhiteSpaceIsACharacterAndIgnored extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-6 (WhiteSpaceIsACharacterAndIgnored) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(WhiteSpaceIsACharacterAndIgnored.class); - } - - Collection expected = null; - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - - initExpectedResult(pm, "x == 0"); - // Escape Sequence - runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\t == 0"); - runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\n == 0"); - runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\f == 0"); - runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\r == 0"); - runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\n == \t 0 \r"); - // Unicode - runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\u0009 == 0"); - runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\u000c == 0"); - runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\u0020 == 0"); - // Octal Escape - runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\11 == 0"); - runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\12 == 0"); - runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\14 == 0"); - runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\15 == 0"); - runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\40 == 0"); - - pm.close(); - pm = null; - } - - /** */ - void initExpectedResult(PersistenceManager pm, String filter) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.setFilter(filter); - expected = (Collection) query.execute(); - // Create a new collection for the expected result. - // This ensures that the expected result may be iterated - // outside of the scope of the current transaction. - expected = new ArrayList(expected); +public class WhiteSpaceIsACharacterAndIgnored extends QueryTest { - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-6 (WhiteSpaceIsACharacterAndIgnored) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(WhiteSpaceIsACharacterAndIgnored.class); } - } - /** */ - void runTestWhiteSpaceIsACharacterAndIgnored01(PersistenceManager pm, String filter) { - Transaction tx = pm.currentTransaction(); - Collection results = null; - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.setFilter(filter); - results = (Collection) query.execute(); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expected); - if (debug) - logger.debug("Test WhiteSpaceIsACharacterAndIgnored01(\"" + filter + "\"): Passed"); + Collection expected = null; + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + + initExpectedResult(pm, "x == 0"); + + // Escape Sequence + runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\t == 0"); + runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\n == 0"); + runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\f == 0"); + runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\r == 0"); + runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\n == \t 0 \r"); + // Unicode + runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\u0009 == 0"); + runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\u000c == 0"); + runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\u0020 == 0"); + // Octal Escape + runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\11 == 0"); + runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\12 == 0"); + runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\14 == 0"); + runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\15 == 0"); + runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\40 == 0"); + + pm.close(); + pm = null; + } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + void initExpectedResult(PersistenceManager pm, String filter) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.setFilter(filter); + expected = (Collection) query.execute(); + // Create a new collection for the expected result. + // This ensures that the expected result may be iterated + // outside of the scope of the current transaction. + expected = new ArrayList(expected); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + void runTestWhiteSpaceIsACharacterAndIgnored01(PersistenceManager pm, + String filter) { + Transaction tx = pm.currentTransaction(); + Collection results = null; + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.setFilter(filter); + results = (Collection) query.execute(); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, + results, expected); + if (debug) + logger.debug("Test WhiteSpaceIsACharacterAndIgnored01(\"" + + filter + "\"): Passed"); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/InvalidUseOfKeywords.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/InvalidUseOfKeywords.java index 66a3461df..664a26c4c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/InvalidUseOfKeywords.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/InvalidUseOfKeywords.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -23,80 +23,88 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Invalid uses of keywords.
    - * Keywords: query
    - * Assertion ID: A14.4-6.
    - * Assertion Description: Keywords must not be used as package names, class names, parameter - * names, or variable names in queries. + *Title: Invalid uses of keywords. + *
    + *Keywords: query + *
    + *Assertion ID: A14.4-6. + *
    + *Assertion Description: + * Keywords must not be used as package names, class names, + * parameter names, or variable names in queries. */ public class InvalidUseOfKeywords extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.4-6 (InvalidUseOfKeywords) failed: "; - - /** The array of invalid single string queries. */ - private static final String[] INVALID_SINGLE_STRING_QUERIES = { - "SELECT INTO range.PersonResult FROM org.apache.jdo.tck.pc.company.Person", - "SELECT INTO range FROM org.apache.jdo.tck.pc.company.Person", - "SELECT FROM select.Person", - "SELECT FROM select", - "SELECT FROM org.apache.jdo.tck.pc.company.Person PARAMETERS int this", - "SELECT FROM org.apache.jdo.tck.pc.company.Person VARIABLES long this" - }; - - /** - * The array of invalid queries which may be executed as single string queries and as API queries. - */ - private static final QueryElementHolder[] INVALID_QUERIES = { - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ "int this", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ "long this", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(InvalidUseOfKeywords.class); - } - - /** */ - public void testNegative() { - for (int i = 0; i < INVALID_SINGLE_STRING_QUERIES.length; i++) { - compileSingleStringQuery(ASSERTION_FAILED, INVALID_SINGLE_STRING_QUERIES[i], false); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.4-6 (InvalidUseOfKeywords) failed: "; + + /** The array of invalid single string queries. */ + private static final String[] INVALID_SINGLE_STRING_QUERIES = { + "SELECT INTO range.PersonResult FROM org.apache.jdo.tck.pc.company.Person", + "SELECT INTO range FROM org.apache.jdo.tck.pc.company.Person", + "SELECT FROM select.Person", + "SELECT FROM select", + "SELECT FROM org.apache.jdo.tck.pc.company.Person PARAMETERS int this", + "SELECT FROM org.apache.jdo.tck.pc.company.Person VARIABLES long this" + }; + + /** + * The array of invalid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] INVALID_QUERIES = { + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ "int this", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ "long this", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(InvalidUseOfKeywords.class); } - - for (int i = 0; i < INVALID_QUERIES.length; i++) { - compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); - compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + + /** */ + public void testNegative() { + for (int i = 0; i < INVALID_SINGLE_STRING_QUERIES.length; i++) { + compileSingleStringQuery(ASSERTION_FAILED, + INVALID_SINGLE_STRING_QUERIES[i], false); + } + + for (int i = 0; i < INVALID_QUERIES.length; i++) { + compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], + false); + } } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/KeywordsAsFieldNames.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/KeywordsAsFieldNames.java index d09268a76..8ae51b2b1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/KeywordsAsFieldNames.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/KeywordsAsFieldNames.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -23,79 +23,86 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Keywords as field names.
    - * Keywords: query
    - * Assertion ID: A14.4-7.
    - * Assertion Description: Keywords are permitted as field names only if they are on the - * right side of the "." in field access expressions. + *Title: Keywords as field names. + *
    + *Keywords: query + *
    + *Assertion ID: A14.4-7. + *
    + *Assertion Description: + * Keywords are permitted as field names only + * if they are on the right side of the "." in field access expressions. */ public class KeywordsAsFieldNames extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.4-7 (KeywordsAsFieldNames) failed: "; - - /** - * The array of invalid queries which may be executed as single string queries and as API queries. - */ - private static final QueryElementHolder[] INVALID_QUERIES = { - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "select", - /*INTO*/ null, - /*FROM*/ JDOQLKeywordsAsFieldNames.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null) - }; - - /** - * The array of valid queries which may be executed as single string queries and as API queries. - */ - private static final QueryElementHolder[] VALID_QUERIES = { - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "this.select", - /*INTO*/ null, - /*FROM*/ JDOQLKeywordsAsFieldNames.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(KeywordsAsFieldNames.class); - } - - /** */ - public void testPositive() { - for (int i = 0; i < VALID_QUERIES.length; i++) { - compileAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], true); - compileSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], true); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.4-7 (KeywordsAsFieldNames) failed: "; + + /** + * The array of invalid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] INVALID_QUERIES = { + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "select", + /*INTO*/ null, + /*FROM*/ JDOQLKeywordsAsFieldNames.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** + * The array of valid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] VALID_QUERIES = { + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "this.select", + /*INTO*/ null, + /*FROM*/ JDOQLKeywordsAsFieldNames.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(KeywordsAsFieldNames.class); + } + + /** */ + public void testPositive() { + for (int i = 0; i < VALID_QUERIES.length; i++) { + compileAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], true); + compileSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], true); + } } - } - public void testNegative() { - for (int i = 0; i < INVALID_QUERIES.length; i++) { - compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); - compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + public void testNegative() { + for (int i = 0; i < INVALID_QUERIES.length; i++) { + compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], + false); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/SingleString.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/SingleString.java index 34dc40d48..ed1737a26 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/SingleString.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/SingleString.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -21,6 +21,8 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.FullTimeEmployee; import org.apache.jdo.tck.query.QueryElementHolder; @@ -29,66 +31,68 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Single string query.
    - * Keywords: query
    - * Assertion ID: A14.6.13-1.
    - * Assertion Description: The String version of Query represents all query elements using a - * single string. The string contains the following structure: + *Title: Single string query. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.13-1. + *
    + *Assertion Description: + * The String version of Query represents all query elements + * using a single string. The string contains the following structure: */ public class SingleString extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.13-1 (SingleString) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SingleString.class); - } - - /** */ - public void testPositive() { - Object expected = - Arrays.asList( - new FullName("emp1First", "emp1Last"), - new FullName("emp2First", "emp2Last"), - new FullName("emp5First", "emp5Last")); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.13-1 (SingleString) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SingleString.class); + } + + /** */ + public void testPositive() { + Object expected = Arrays.asList(new FullName("emp1First", "emp1Last"), + new FullName("emp2First", "emp2Last"), + new FullName("emp5First", "emp5Last")); - Map paramValues = new HashMap<>(); - paramValues.put("limit", new BigDecimal("2000")); + Map paramValues = new HashMap<>(); + paramValues.put("limit", new BigDecimal("2000")); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.FALSE, - /*RESULT*/ "firstname AS firstName, lastname AS lastName", - /*INTO*/ FullName.class, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ Boolean.TRUE, - /*WHERE*/ "salary > 1000 & projects.contains(p) & p.budget > limit", - /*VARIABLES*/ "Project p", - /*PARAMETERS*/ "BigDecimal limit", - /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.Project; " - + "import java.math.BigDecimal", - /*GROUP BY*/ "firstname, lastname HAVING lastname.startsWith('emp')", - /*ORDER BY*/ "lastname ASCENDING", - /*FROM*/ 0, - /*TO*/ 3, - /*JDOQLTyped*/ null, - /*paramValues*/ paramValues); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.FALSE, + /*RESULT*/ "firstname AS firstName, lastname AS lastName", + /*INTO*/ FullName.class, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ Boolean.TRUE, + /*WHERE*/ "salary > 1000 & projects.contains(p) & p.budget > limit", + /*VARIABLES*/ "Project p", + /*PARAMETERS*/ "BigDecimal limit", + /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.Project; " + + "import java.math.BigDecimal", + /*GROUP BY*/ "firstname, lastname HAVING lastname.startsWith('emp')", + /*ORDER BY*/ "lastname ASCENDING", + /*FROM*/ 0, + /*TO*/ 3, + /*JDOQLTyped*/ null, + /*paramValues*/ paramValues); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/ThisIsReservedWordForElementOfCollection.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/ThisIsReservedWordForElementOfCollection.java index 2808517a5..826483477 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/ThisIsReservedWordForElementOfCollection.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/ThisIsReservedWordForElementOfCollection.java @@ -5,80 +5,81 @@ * 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 + * + * 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.jdo.tck.query.jdoql.keywords; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: This is Reserved Word for Element of Collection
    - * Keywords: query
    - * Assertion ID: A14.6.2-12.
    - * Assertion Description: this is a reserved word which means the element of - * the candidate collection being evaluated. + *Title: This is Reserved Word for Element of Collection + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-12. + *
    + *Assertion Description: + * this is a reserved word which means the element of the + * candidate collection being evaluated. */ -public class ThisIsReservedWordForElementOfCollection extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-12 (ThisIsReservedWordForElementOfCollection) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ThisIsReservedWordForElementOfCollection.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); +public class ThisIsReservedWordForElementOfCollection extends QueryTest { - Collection instance9 = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 9").execute(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-12 (ThisIsReservedWordForElementOfCollection) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ThisIsReservedWordForElementOfCollection.class); + } + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); - // compare this with a parameter - runParameterPrimitiveTypesQuery( - "this == param", - "PrimitiveTypes param", - instance9.iterator().next(), - pm, - instance9, - ASSERTION_FAILED); + Collection instance9 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 9").execute(); + + // compare this with a parameter + runParameterPrimitiveTypesQuery( + "this == param", "PrimitiveTypes param", instance9.iterator().next(), + pm, instance9, ASSERTION_FAILED); - // use this to access a field - runParameterPrimitiveTypesQuery( - "this.intNotNull == intNotNull", - "int intNotNull", - Integer.valueOf(9), - pm, - instance9, - ASSERTION_FAILED); - } + // use this to access a field + runParameterPrimitiveTypesQuery( + "this.intNotNull == intNotNull", "int intNotNull", Integer.valueOf(9), + pm, instance9, ASSERTION_FAILED); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PrimitiveTypes.class); - loadAndPersistPrimitiveTypes(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PrimitiveTypes.class); + loadAndPersistPrimitiveTypes(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/UppercaseLowercase.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/UppercaseLowercase.java index 26bab5cfa..99952e130 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/UppercaseLowercase.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/UppercaseLowercase.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -21,49 +21,55 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Keywords in uppercase and lowercase.
    - * Keywords: query
    - * Assertion ID: A14.6.13-2.
    - * Assertion Description: Keywords, identified above in bold, are either all upper-case or - * all lower-case. Keywords cannot be mixed case. + *Title: Keywords in uppercase and lowercase. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.13-2. + *
    + *Assertion Description: + * Keywords, identified above in bold, are either all upper-case + * or all lower-case. Keywords cannot be mixed case. */ public class UppercaseLowercase extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.13-2 (UppercaseLowercase) failed: "; - - /** The array of valid single string queries. */ - private static final String[] VALID_SINGLE_STRING_QUERIES = { - "SELECT FROM org.apache.jdo.tck.pc.company.Person", - "select from org.apache.jdo.tck.pc.company.Person", - "select FROM org.apache.jdo.tck.pc.company.Person", - }; - - /** The array of invalid single string queries. */ - private static final String[] INVALID_SINGLE_STRING_QUERIES = { - "SeLeCt FrOm org.apache.jdo.tck.pc.company.Person" - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(UppercaseLowercase.class); - } - - /** */ - public void testPositive() { - for (int i = 0; i < VALID_SINGLE_STRING_QUERIES.length; i++) { - compileSingleStringQuery(ASSERTION_FAILED, VALID_SINGLE_STRING_QUERIES[i], true); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.13-2 (UppercaseLowercase) failed: "; + + /** The array of valid single string queries. */ + private static final String[] VALID_SINGLE_STRING_QUERIES = { + "SELECT FROM org.apache.jdo.tck.pc.company.Person", + "select from org.apache.jdo.tck.pc.company.Person", + "select FROM org.apache.jdo.tck.pc.company.Person", + }; + + /** The array of invalid single string queries. */ + private static final String[] INVALID_SINGLE_STRING_QUERIES = { + "SeLeCt FrOm org.apache.jdo.tck.pc.company.Person" + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(UppercaseLowercase.class); } - } - - public void testNegitve() { - for (int i = 0; i < INVALID_SINGLE_STRING_QUERIES.length; i++) { - compileSingleStringQuery(ASSERTION_FAILED, INVALID_SINGLE_STRING_QUERIES[i], false); + + /** */ + public void testPositive() { + for (int i = 0; i < VALID_SINGLE_STRING_QUERIES.length; i++) { + compileSingleStringQuery(ASSERTION_FAILED, + VALID_SINGLE_STRING_QUERIES[i], true); + } + } + + public void testNegitve() { + for (int i = 0; i < INVALID_SINGLE_STRING_QUERIES.length; i++) { + compileSingleStringQuery(ASSERTION_FAILED, + INVALID_SINGLE_STRING_QUERIES[i], false); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/UseOfThisToAcessHiddenField.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/UseOfThisToAcessHiddenField.java index 56fc924a0..bf5742fdc 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/UseOfThisToAcessHiddenField.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/keywords/UseOfThisToAcessHiddenField.java @@ -5,125 +5,143 @@ * 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 + * + * 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.jdo.tck.query.jdoql.keywords; import java.util.ArrayList; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Use of this to Access Hidden Field
    - * Keywords: query
    - * Assertion ID: A14.4-4.
    - * Assertion Description: A hidden field may be accessed using the 'this' - * qualifier: this.fieldName. + *Title: Use of this to Access Hidden Field + *
    + *Keywords: query + *
    + *Assertion ID: A14.4-4. + *
    + *Assertion Description: A hidden field may be accessed using the + *'this' qualifier: this.fieldName. */ + public class UseOfThisToAcessHiddenField extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.4-4 (UseOfThisToAcessHiddenField) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(UseOfThisToAcessHiddenField.class); - } - - /** */ - public void testPositve() { - PersistenceManager pm = getPM(); - - runTestUseOfThisToAcessHiddenField01(pm); - runTestUseOfThisToAcessHiddenField02(pm); - } - - /** */ - void runTestUseOfThisToAcessHiddenField01(PersistenceManager pm) { - if (debug) logger.debug("\nExecuting test UseOfThisToAcessHiddenField01() ..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.declareParameters("Integer x"); - query.setFilter("this.x == x"); - Object results = query.execute(new java.lang.Integer(2)); - - // check query result - List expected = new ArrayList(); - Object p3 = new PCPoint(2, 2); - expected.add(p3); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "this.x == x", results, expected); - if (debug) logger.debug("Test UseOfThisToAcessHiddenField01(): Passed"); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.4-4 (UseOfThisToAcessHiddenField) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(UseOfThisToAcessHiddenField.class); } - } - - /** */ - void runTestUseOfThisToAcessHiddenField02(PersistenceManager pm) { - if (debug) logger.debug("\nExecuting test UseOfThisToAcessHiddenField02() ..."); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.declareParameters("Integer y"); - query.setFilter("this.y == y"); - Object results = query.execute(new java.lang.Integer(3)); - - // check query result - List expected = new ArrayList(); - Object p4 = new PCPoint(3, 3); - expected.add(p4); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "this.y == y", results, expected); - if (debug) logger.debug("Test UseOfThisToAcessHiddenField02(): Passed"); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void testPositve() { + PersistenceManager pm = getPM(); + + runTestUseOfThisToAcessHiddenField01(pm); + runTestUseOfThisToAcessHiddenField02(pm); + } + + /** */ + void runTestUseOfThisToAcessHiddenField01(PersistenceManager pm) { + if (debug) + logger.debug("\nExecuting test UseOfThisToAcessHiddenField01() ..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.declareParameters("Integer x"); + query.setFilter("this.x == x"); + Object results = query.execute(new java.lang.Integer(2)); + + // check query result + List expected = new ArrayList(); + Object p3 = new PCPoint(2, 2); + expected.add(p3); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "this.x == x", + results, expected); + if (debug) + logger.debug("Test UseOfThisToAcessHiddenField01(): Passed"); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + void runTestUseOfThisToAcessHiddenField02(PersistenceManager pm) { + if (debug) + logger.debug("\nExecuting test UseOfThisToAcessHiddenField02() ..."); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.declareParameters("Integer y"); + query.setFilter("this.y == y"); + Object results = query.execute(new java.lang.Integer(3)); + + // check query result + List expected = new ArrayList(); + Object p4 = new PCPoint(3, 3); + expected.add(p4); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "this.y == y", + results, expected); + if (debug) + logger.debug("Test UseOfThisToAcessHiddenField02(): Passed"); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/EnumMethodOrdinal.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/EnumMethodOrdinal.java index 5ef67bb79..8bbbe4939 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/EnumMethodOrdinal.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/EnumMethodOrdinal.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,96 +19,106 @@ import java.util.ArrayList; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfSimpleEnum; import org.apache.jdo.tck.pc.fieldtypes.SimpleEnum; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Supported Enum methods.
    - * Keywords: query
    - * Assertion ID: A14.6.2-59.
    - * Assertion Description: New supported Enum methods: - * + *Title: Supported Enum methods. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-59. + *
    + *Assertion Description: + * New supported Enum methods: *
      - *
    • ordinal() - *
    • toString() + *
    • ordinal() + *
    • toString() *
    */ public class EnumMethodOrdinal extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-59 (EnumMethodOrdinal) failed: "; - - /** */ - private Object oidOfExpectedResult; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-59 (EnumMethodOrdinal) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(EnumMethodOrdinal.class); - } + /** */ + private Object oidOfExpectedResult; - /** */ - public void testOrdinal() { - final String filter = "SimpleEnum0.ordinal() == 5"; - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Collection expectedResult = new ArrayList(); - expectedResult.add(pm.getObjectById(oidOfExpectedResult)); + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(EnumMethodOrdinal.class); + } + + /** */ + public void testOrdinal() { + final String filter = "SimpleEnum0.ordinal() == 5"; + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Collection expectedResult = new ArrayList(); + expectedResult.add(pm.getObjectById(oidOfExpectedResult)); - Query q = pm.newQuery(); - q.setClass(FieldsOfSimpleEnum.class); - q.setFilter(filter); - Collection results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + Query q = pm.newQuery(); + q.setClass(FieldsOfSimpleEnum.class); + q.setFilter(filter); + Collection results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfSimpleEnum.class); - insertFieldsOfSimpleEnums(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfSimpleEnum.class); + insertFieldsOfSimpleEnums(getPM()); + } - /** */ - private void insertFieldsOfSimpleEnums(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - FieldsOfSimpleEnum f1 = new FieldsOfSimpleEnum(); - f1.set(0, SimpleEnum.CA); - f1.identifier = 1; - pm.makePersistent(f1); - FieldsOfSimpleEnum f2 = new FieldsOfSimpleEnum(); - f2.set(0, SimpleEnum.HI); - f2.identifier = 2; - pm.makePersistent(f2); - FieldsOfSimpleEnum f3 = new FieldsOfSimpleEnum(); - f3.set(0, SimpleEnum.DC); - f3.identifier = 3; - pm.makePersistent(f3); - oidOfExpectedResult = pm.getObjectId(f1); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private void insertFieldsOfSimpleEnums(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + FieldsOfSimpleEnum f1 = new FieldsOfSimpleEnum(); + f1.set(0, SimpleEnum.CA); + f1.identifier = 1; + pm.makePersistent(f1); + FieldsOfSimpleEnum f2 = new FieldsOfSimpleEnum(); + f2.set(0, SimpleEnum.HI); + f2.identifier = 2; + pm.makePersistent(f2); + FieldsOfSimpleEnum f3 = new FieldsOfSimpleEnum(); + f3.set(0, SimpleEnum.DC); + f3.identifier = 3; + pm.makePersistent(f3); + oidOfExpectedResult = pm.getObjectId(f1); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/EnumMethodToString.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/EnumMethodToString.java index 92d1b7bc5..b7530a75f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/EnumMethodToString.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/EnumMethodToString.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,96 +19,106 @@ import java.util.ArrayList; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.FieldsOfSimpleEnum; import org.apache.jdo.tck.pc.fieldtypes.SimpleEnum; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Supported Enum methods.
    - * Keywords: query
    - * Assertion ID: A14.6.2-59.
    - * Assertion Description: New supported Enum methods: - * + *Title: Supported Enum methods. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-59. + *
    + *Assertion Description: + * New supported Enum methods: *
      - *
    • ordinal() - *
    • toString() + *
    • ordinal() + *
    • toString() *
    */ public class EnumMethodToString extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-59 (EnumMethodToString) failed: "; - - /** */ - private Object oidOfExpectedResult; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-59 (EnumMethodToString) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(EnumMethodToString.class); - } + /** */ + private Object oidOfExpectedResult; - /** */ - public void testToString() { - final String filter = "SimpleEnum0.toString() == 'CA'"; - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Collection expectedResult = new ArrayList(); - expectedResult.add(pm.getObjectById(oidOfExpectedResult)); + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(EnumMethodToString.class); + } + + /** */ + public void testToString() { + final String filter = "SimpleEnum0.toString() == 'CA'"; + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Collection expectedResult = new ArrayList(); + expectedResult.add(pm.getObjectById(oidOfExpectedResult)); - Query q = pm.newQuery(); - q.setClass(FieldsOfSimpleEnum.class); - q.setFilter(filter); - Collection results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + Query q = pm.newQuery(); + q.setClass(FieldsOfSimpleEnum.class); + q.setFilter(filter); + Collection results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(FieldsOfSimpleEnum.class); - insertFieldsOfSimpleEnums(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(FieldsOfSimpleEnum.class); + insertFieldsOfSimpleEnums(getPM()); + } - /** */ - private void insertFieldsOfSimpleEnums(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - FieldsOfSimpleEnum f1 = new FieldsOfSimpleEnum(); - f1.set(0, SimpleEnum.CA); - f1.identifier = 1; - pm.makePersistent(f1); - FieldsOfSimpleEnum f2 = new FieldsOfSimpleEnum(); - f2.set(0, SimpleEnum.HI); - f2.identifier = 2; - pm.makePersistent(f2); - FieldsOfSimpleEnum f3 = new FieldsOfSimpleEnum(); - f3.set(0, SimpleEnum.DC); - f3.identifier = 3; - pm.makePersistent(f3); - oidOfExpectedResult = pm.getObjectId(f1); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private void insertFieldsOfSimpleEnums(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + FieldsOfSimpleEnum f1 = new FieldsOfSimpleEnum(); + f1.set(0, SimpleEnum.CA); + f1.identifier = 1; + pm.makePersistent(f1); + FieldsOfSimpleEnum f2 = new FieldsOfSimpleEnum(); + f2.set(0, SimpleEnum.HI); + f2.identifier = 2; + pm.makePersistent(f2); + FieldsOfSimpleEnum f3 = new FieldsOfSimpleEnum(); + f3.set(0, SimpleEnum.DC); + f3.identifier = 3; + pm.makePersistent(f3); + oidOfExpectedResult = pm.getObjectId(f1); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/MethodsAndObjectConstructionNotSupported.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/MethodsAndObjectConstructionNotSupported.java index f03f45632..614b8348e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/MethodsAndObjectConstructionNotSupported.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/MethodsAndObjectConstructionNotSupported.java @@ -5,70 +5,80 @@ * 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 + * + * 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.jdo.tck.query.jdoql.methods; + import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Query; + import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Methods and Object Construction not Supported
    - * Keywords: query
    - * Assertion ID: A14.6.2-8.
    - * Assertion Description: Methods, including object construction, are not supported in a - * Query filter. + *Title: Methods and Object Construction not Supported + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-8. + *
    + *Assertion Description: Methods, including object construction, are not + *supported in a Query filter. */ -public class MethodsAndObjectConstructionNotSupported extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-8 (MethodsAndObjectConstructionNotSupported) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MethodsAndObjectConstructionNotSupported.class); - } - - /** */ - public void testNegative() { - PersistenceManager pm = getPM(); +public class MethodsAndObjectConstructionNotSupported extends QueryTest { - runTestUnsupportedOperators01(pm, Employee.class, "this.team.add(this)"); - runTestUnsupportedOperators01(pm, Employee.class, "this.team.remove(this)"); - runTestUnsupportedOperators01(pm, PCPoint.class, "y == Integer.valueOf(1)"); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-8 (MethodsAndObjectConstructionNotSupported) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MethodsAndObjectConstructionNotSupported.class); + } - /** */ - void runTestUnsupportedOperators01(PersistenceManager pm, Class candidateClass, String filter) { - String expectedMsg = "setFilter: Invalid method call ...."; - Query query = pm.newQuery(); - query.setClass(candidateClass); + /** */ + public void testNegative() { + PersistenceManager pm = getPM(); - try { - query.setFilter(filter); - query.compile(); + runTestUnsupportedOperators01(pm, Employee.class, "this.team.add(this)"); + runTestUnsupportedOperators01(pm, Employee.class, "this.team.remove(this)"); + runTestUnsupportedOperators01(pm, PCPoint.class, "y == Integer.valueOf(1)"); + } - fail(ASSERTION_FAILED, "Missing JDOUserException(" + expectedMsg + ") for filter " + filter); - } catch (JDOUserException ex) { - if (debug) logger.debug("expected exception " + ex); + /** */ + void runTestUnsupportedOperators01(PersistenceManager pm, + Class candidateClass, String filter) { + String expectedMsg = "setFilter: Invalid method call ...."; + Query query = pm.newQuery(); + query.setClass(candidateClass); + + try { + query.setFilter(filter); + query.compile(); + + fail(ASSERTION_FAILED, "Missing JDOUserException(" + expectedMsg + + ") for filter " + filter); + } + catch (JDOUserException ex) { + if (debug) logger.debug("expected exception " + ex); + } } - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/StartsWithAndEndsWith.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/StartsWithAndEndsWith.java index 667de7ee1..a3b60160e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/StartsWithAndEndsWith.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/StartsWithAndEndsWith.java @@ -5,19 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql.methods; -import javax.jdo.JDOQLTypedQuery; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.QEmployee; @@ -25,99 +25,106 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: StartsWith and EndsWith Query Operators
    - * Keywords: query
    - * Assertion ID: A14.6.2-33.
    - * Assertion Description: String methods startsWith and - * endsWith support wild card queries. JDO does not define any special semantic to the - * argument passed to the method; in particular, it does not define any wild card characters. - */ -public class StartsWithAndEndsWith extends QueryTest { + *Title: StartsWith and EndsWith Query Operators + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-33. + *
    + *Assertion Description: +String methods startsWith and endsWith +support wild card queries. JDO does not define any special semantic to the +argument passed to the method; in particular, +it does not define any wild card characters. - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-33 (StartsWithAndEndsWith) failed: "; + */ - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(StartsWithAndEndsWith.class); - } +public class StartsWithAndEndsWith extends QueryTest { - /** */ - public void testPositive0() { - // startsWith - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-33 (StartsWithAndEndsWith) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(StartsWithAndEndsWith.class); + } + + /** */ + public void testPositive0() { + // startsWith + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.filter(cand.firstname.startsWith("emp1")); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.filter(cand.firstname.startsWith("emp1")); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname.startsWith(\"emp1\")", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname.startsWith(\"emp1\")", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } - /** */ - public void testPositive1() { - // endsWith - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); + /** */ + public void testPositive1() { + // endsWith + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.filter(cand.firstname.endsWith("1First")); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.filter(cand.firstname.endsWith("1First")); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname.endsWith(\"1First\")", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname.endsWith(\"1First\")", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedCollectionMethods.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedCollectionMethods.java index 0a865edd0..51d4c7642 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedCollectionMethods.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedCollectionMethods.java @@ -5,22 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql.methods; -import java.util.HashMap; -import java.util.Map; -import javax.jdo.JDOQLTypedQuery; -import javax.jdo.query.Expression; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.Employee; @@ -30,204 +27,208 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; +import javax.jdo.query.Expression; +import java.util.HashMap; +import java.util.Map; + /** - * Title:Supported collection methods
    - * Keywords: query collection
    - * Assertion ID: A14.6.2-45.
    - * Assertion Description: Supported collection methods: - * + *Title:Supported collection methods + *
    + *Keywords: query collection + *
    + *Assertion ID: A14.6.2-45. + *
    + *Assertion Description: + * Supported collection methods: *
      - *
    • isEmpty - *
    • contains - *
    • size + *
    • isEmpty
    • + *
    • contains
    • + *
    • size
    • *
    */ + public class SupportedCollectionMethods extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-45 (SupportedCollectionMethods) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SupportedCollectionMethods.class); - } - - /** */ - public void testContains() { - // contains(VARIABLE) - Object expectedResult = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - QEmployee eVariable = QEmployee.variable("e"); - query.filter(cand.employees.contains(eVariable).and(eVariable.personid.eq(1L))); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employees.contains(e) && e.personid == 1", - /*VARIABLES*/ "Employee e", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expectedResult); - - // contains(PARAMETER) - - expectedResult = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); - - getPM().currentTransaction().begin(); - Map paramValues = new HashMap<>(); - paramValues.put("e", getPersistentCompanyModelInstance("emp1")); - getPM().currentTransaction().commit(); - - query = getPM().newJDOQLTypedQuery(Department.class); - cand = QDepartment.candidate(); - Expression paramExpression = query.parameter("e", Employee.class); - query.filter(cand.employees.contains(paramExpression)); - - holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employees.contains(e)", - /*VARIABLES*/ null, - /*PARAMETERS*/ "Employee e", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expectedResult); - } - - /** */ - public void testIsEmpty() { - - // !isEmpty - Object expectedResult = - getTransientCompanyModelInstancesAsList(new String[] {"dept1", "dept2"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - query.filter(cand.employees.isEmpty().not()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "!employees.isEmpty()", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expectedResult); - - // isEmpty - expectedResult = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query2 = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee empCand = QEmployee.candidate(); - query2.filter(empCand.team.isEmpty()); - - holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "team.isEmpty()", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query2, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expectedResult); - } - - /** */ - public void testSize() { - // size - Object expectedResult = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - query.filter(cand.employees.size().eq(3)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employees.size() == 3", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expectedResult); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-45 (SupportedCollectionMethods) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SupportedCollectionMethods.class); + } + + /** */ + public void testContains() { + // contains(VARIABLE) + Object expectedResult = getTransientCompanyModelInstancesAsList(new String[]{"dept1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + QEmployee eVariable = QEmployee.variable("e"); + query.filter(cand.employees.contains(eVariable).and(eVariable.personid.eq(1L))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.contains(e) && e.personid == 1", + /*VARIABLES*/ "Employee e", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expectedResult); + + // contains(PARAMETER) + + expectedResult = getTransientCompanyModelInstancesAsList(new String[]{"dept1"}); + + getPM().currentTransaction().begin(); + Map paramValues = new HashMap<>(); + paramValues.put("e", getPersistentCompanyModelInstance("emp1")); + getPM().currentTransaction().commit(); + + query = getPM().newJDOQLTypedQuery(Department.class); + cand = QDepartment.candidate(); + Expression paramExpression = query.parameter("e", Employee.class); + query.filter(cand.employees.contains(paramExpression)); + + holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.contains(e)", + /*VARIABLES*/ null, + /*PARAMETERS*/ "Employee e", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expectedResult); + } + + /** */ + public void testIsEmpty() { + + // !isEmpty + Object expectedResult = getTransientCompanyModelInstancesAsList(new String[]{"dept1", "dept2"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + query.filter(cand.employees.isEmpty().not()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "!employees.isEmpty()", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expectedResult); + + // isEmpty + expectedResult = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query2 = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee empCand = QEmployee.candidate(); + query2.filter(empCand.team.isEmpty()); + + holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "team.isEmpty()", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query2, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expectedResult); + } + + /** */ + public void testSize() { + // size + Object expectedResult = getTransientCompanyModelInstancesAsList(new String[]{"dept1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + query.filter(cand.employees.size().eq(3)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.size() == 3", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expectedResult); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedDateMethods.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedDateMethods.java index 83038bfa9..4a6d79d66 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedDateMethods.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedDateMethods.java @@ -5,19 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql.methods; -import javax.jdo.JDOQLTypedQuery; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.pc.company.QPerson; @@ -25,132 +25,135 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Supported Date methods.
    - * Keywords: query
    - * Assertion ID: A14.6.2-60.
    - * Assertion Description: New supported Date methods: - * + *Title: Supported Date methods. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-60. + *
    + *Assertion Description: + * New supported Date methods: *
      - *
    • getDate() - *
    • getMonth() - *
    • getYear() + *
    • getDate()
    • + *
    • getMonth()
    • + *
    • getYear()
    • *
    */ public class SupportedDateMethods extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-60 (SupportedDateMethods) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SupportedDateMethods.class); - } - - /** */ - public void testGetDate() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.birthdate.getDay().eq(10)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "birthdate.getDate() == 10", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testGetMonth() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.birthdate.getMonth().eq(5)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "birthdate.getMonth() == 5", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testGetYear() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.birthdate.getYear().eq(1970)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "birthdate.getYear() == 1970", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-60 (SupportedDateMethods) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SupportedDateMethods.class); + } + + /** */ + public void testGetDate() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.birthdate.getDay().eq(10)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "birthdate.getDate() == 10", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testGetMonth() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.birthdate.getMonth().eq(5)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "birthdate.getMonth() == 5", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testGetYear() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.birthdate.getYear().eq(1970)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "birthdate.getYear() == 1970", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedJDOHelperMethods.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedJDOHelperMethods.java index f090960f2..6165f3041 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedJDOHelperMethods.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedJDOHelperMethods.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -24,12 +24,15 @@ import java.util.Iterator; import java.util.List; import java.util.Map; + import javax.jdo.JDOHelper; import javax.jdo.JDOQLTypedQuery; import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; import javax.jdo.query.Expression; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.pc.company.QPerson; @@ -40,220 +43,221 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Supported JDOHelper methods.
    - * Keywords: query
    - * Assertion ID: A14.6.2-49.
    - * Assertion Description: Supported JDOHelper methods: - * + *Title: Supported JDOHelper methods. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-49. + *
    + *Assertion Description: + * Supported JDOHelper methods: *
      - *
    • JDOHelper.getObjectId(Object) - *
    • JDOHelper.getVersion(Object) + *
    • JDOHelper.getObjectId(Object) + *
    • JDOHelper.getVersion(Object) *
    */ public class SupportedJDOHelperMethods extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-49 (SupportedJDOHelperMethods) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SupportedJDOHelperMethods.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-49 (SupportedJDOHelperMethods) failed: "; - /** */ - public void testGetObjectById1() { - Class oidClass = getPM().getObjectIdClass(Person.class); - List expectedResult = getExpectedResult(true, Person.class); + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SupportedJDOHelperMethods.class); + } + + /** */ + public void testGetObjectById1() { + Class oidClass = getPM().getObjectIdClass(Person.class); + List expectedResult = getExpectedResult(true, Person.class); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.result(false, cand.jdoObjectId()); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.result(false, cand.jdoObjectId()); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "JDOHelper.getObjectId(this)", - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "JDOHelper.getObjectId(this)", + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); - } + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); + } - /** */ - public void testGetObjectById2() { - List expectedResult = getExpectedResult(false, Person.class, "personid == 1"); + /** */ + public void testGetObjectById2() { + List expectedResult = getExpectedResult(false, Person.class, "personid == 1"); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - Expression oid = query.parameter("oid", Object.class); - query.filter(cand.jdoObjectId().eq(oid)); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + Expression oid = query.parameter("oid", Object.class); + query.filter(cand.jdoObjectId().eq(oid)); - // The query above returns a collection of size 1. The collection element is a - // pc instance whose oid is the parameter of the query below. - Map paramValues = new HashMap<>(); - paramValues.put("oid", JDOHelper.getObjectId(expectedResult.get(0))); + // The query above returns a collection of size 1. The collection element is a + // pc instance whose oid is the parameter of the query below. + Map paramValues = new HashMap<>(); + paramValues.put("oid", JDOHelper.getObjectId(expectedResult.get(0))); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "JDOHelper.getObjectId(this) == oid", - /*VARIABLES*/ null, - /*PARAMETERS*/ "Object oid", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "JDOHelper.getObjectId(this) == oid", + /*VARIABLES*/ null, + /*PARAMETERS*/ "Object oid", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expectedResult); - } + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expectedResult); + } - /** Test for JDOHelper.getVersion() in queries. */ - public void testGetVersion() { - // create some sample data - pm.currentTransaction().begin(); - VersionedPCPoint pt1 = new VersionedPCPoint(1, 2); - pm.makePersistent(pt1); - pm.currentTransaction().commit(); - Object id = pm.getObjectId(pt1); + /** Test for JDOHelper.getVersion() in queries. */ + public void testGetVersion() { + // create some sample data + pm.currentTransaction().begin(); + VersionedPCPoint pt1 = new VersionedPCPoint(1, 2); + pm.makePersistent(pt1); + pm.currentTransaction().commit(); + Object id = pm.getObjectId(pt1); - try { - // query 1 - List expectedResult = Arrays.asList(Long.valueOf(1)); + try { + // query 1 + List expectedResult = Arrays.asList(Long.valueOf(1)); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(VersionedPCPoint.class); - QVersionedPCPoint cand = QVersionedPCPoint.candidate(); - query.result(false, cand.jdoVersion()); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(VersionedPCPoint.class); + QVersionedPCPoint cand = QVersionedPCPoint.candidate(); + query.result(false, cand.jdoVersion()); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "JDOHelper.getVersion(this)", - /*INTO*/ null, - /*FROM*/ VersionedPCPoint.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "JDOHelper.getVersion(this)", + /*INTO*/ null, + /*FROM*/ VersionedPCPoint.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - // executeJDOQLTypedQuery(ASSERTION_FAILED, holder, Long.class, expectedResult); + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + //executeJDOQLTypedQuery(ASSERTION_FAILED, holder, Long.class, expectedResult); - // query 2 - expectedResult = getExpectedResult(false, VersionedPCPoint.class, "x == 1"); + // query 2 + expectedResult = getExpectedResult(false, VersionedPCPoint.class, "x == 1"); - query = getPM().newJDOQLTypedQuery(VersionedPCPoint.class); - cand = QVersionedPCPoint.candidate(); - Expression ver = query.parameter("ver", Object.class); - query.filter(cand.jdoVersion().eq(ver)); + query = getPM().newJDOQLTypedQuery(VersionedPCPoint.class); + cand = QVersionedPCPoint.candidate(); + Expression ver = query.parameter("ver", Object.class); + query.filter(cand.jdoVersion().eq(ver)); - Map paramValues = new HashMap<>(); - paramValues.put("ver", Long.valueOf(1)); + Map paramValues = new HashMap<>(); + paramValues.put("ver", Long.valueOf(1)); - holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ VersionedPCPoint.class, - /*EXCLUDE*/ null, - /*WHERE*/ "JDOHelper.getVersion(this) == ver", - /*VARIABLES*/ null, - /*PARAMETERS*/ "Long ver", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); + holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ VersionedPCPoint.class, + /*EXCLUDE*/ null, + /*WHERE*/ "JDOHelper.getVersion(this) == ver", + /*VARIABLES*/ null, + /*PARAMETERS*/ "Long ver", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expectedResult); + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expectedResult); - } finally { - pm.currentTransaction().begin(); - pm.deletePersistent(pm.getObjectById(id)); - pm.currentTransaction().commit(); + } finally { + pm.currentTransaction().begin(); + pm.deletePersistent(pm.getObjectById(id)); + pm.currentTransaction().commit(); + } } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } - /** */ - private List getExpectedResult(boolean oidsWanted, Class candidateClass) { - return getExpectedResult(oidsWanted, candidateClass, null); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } - /** */ - private List getExpectedResult(boolean oidsWanted, Class candidateClass, String filter) { - List expectedResult; - PersistenceManager pm = getPM(); - Transaction transaction = pm.currentTransaction(); - transaction.begin(); - try { - Query query = - filter == null ? pm.newQuery(candidateClass) : pm.newQuery(candidateClass, filter); - try { - Collection result = (Collection) query.execute(); - if (oidsWanted) { - expectedResult = new ArrayList(); - for (Iterator i = result.iterator(); i.hasNext(); ) { - expectedResult.add(JDOHelper.getObjectId(i.next())); - } - } else { - expectedResult = new ArrayList(result); + /** */ + private List getExpectedResult(boolean oidsWanted, Class candidateClass) { + return getExpectedResult(oidsWanted, candidateClass, null); + } + + /** */ + private List getExpectedResult(boolean oidsWanted, + Class candidateClass, String filter) { + List expectedResult; + PersistenceManager pm = getPM(); + Transaction transaction = pm.currentTransaction(); + transaction.begin(); + try { + Query query = filter == null ? pm.newQuery(candidateClass) : + pm.newQuery(candidateClass, filter); + try { + Collection result = (Collection) query.execute(); + if (oidsWanted) { + expectedResult = new ArrayList(); + for (Iterator i = result.iterator(); i.hasNext(); ) { + expectedResult.add(JDOHelper.getObjectId(i.next())); + } + } else { + expectedResult = new ArrayList(result); + } + } finally { + query.closeAll(); + } + } finally { + if (transaction.isActive()) { + transaction.rollback(); + } } - } finally { - query.closeAll(); - } - } finally { - if (transaction.isActive()) { - transaction.rollback(); - } + return expectedResult; } - return expectedResult; - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedListMethods.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedListMethods.java index 0702796f4..b965972bb 100755 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedListMethods.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedListMethods.java @@ -5,23 +5,23 @@ * 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 + * + * 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.jdo.tck.query.jdoql.methods; -import java.util.HashMap; -import java.util.Map; import javax.jdo.JDOQLTypedQuery; import javax.jdo.query.Expression; import javax.jdo.query.NumericExpression; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.MeetingRoom; @@ -30,110 +30,116 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import java.util.HashMap; +import java.util.Map; + /** - * Title:Supported list methods
    - * Keywords: query list
    - * Assertion ID: A14.6.2-58.
    - * Assertion Description: Supported list methods: - * + *Title:Supported list methods + *
    + *Keywords: query list + *
    + *Assertion ID: A14.6.2-58. + *
    + *Assertion Description: + * Supported list methods: *
      - *
    • get(int) + *
    • get(int)
    • *
    */ + public class SupportedListMethods extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-58 (SupportedListMethods) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SupportedListMethods.class); - } - - /** */ - public void testGetInFilter() { - // get(PARAMETER) in filter - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - Expression roomParam = query.parameter("room1", MeetingRoom.class); - NumericExpression posParam = query.numericParameter("pos"); - query.filter(cand.meetingRooms.get(posParam).eq(roomParam)); - - getPM().currentTransaction().begin(); - Map paramValues = new HashMap<>(); - paramValues.put("pos", Integer.valueOf(1)); - paramValues.put("room1", getPersistentCompanyModelInstance("room2")); - getPM().currentTransaction().commit(); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "meetingRooms.get(pos) == room1", - /*VARIABLES*/ null, - /*PARAMETERS*/ "int pos, MeetingRoom room1", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testGetInResult() { - // get(LITERAL) in result - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"room2"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - query.result(false, cand.meetingRooms.get(1)); - query.filter(cand.deptid.eq(1L)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "meetingRooms.get(1)", - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "deptid == 1", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-58 (SupportedListMethods) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SupportedListMethods.class); + } + + /** */ + public void testGetInFilter() { + // get(PARAMETER) in filter + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"dept1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + Expression roomParam = query.parameter("room1", MeetingRoom.class); + NumericExpression posParam = query.numericParameter("pos"); + query.filter(cand.meetingRooms.get(posParam).eq(roomParam)); + + getPM().currentTransaction().begin(); + Map paramValues = new HashMap<>(); + paramValues.put("pos", Integer.valueOf(1)); + paramValues.put("room1", getPersistentCompanyModelInstance("room2")); + getPM().currentTransaction().commit(); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "meetingRooms.get(pos) == room1", + /*VARIABLES*/ null, + /*PARAMETERS*/ "int pos, MeetingRoom room1", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testGetInResult() { + // get(LITERAL) in result + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"room2"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + query.result(false, cand.meetingRooms.get(1)); + query.filter(cand.deptid.eq(1L)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "meetingRooms.get(1)", + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "deptid == 1", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalDateMethods.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalDateMethods.java index 84db8a353..4a2bcf7bc 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalDateMethods.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalDateMethods.java @@ -16,141 +16,154 @@ */ package org.apache.jdo.tck.query.jdoql.methods; +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.query.LocalDateSample; +import org.apache.jdo.tck.query.QueryTest; +import org.apache.jdo.tck.util.BatchTestRunner; + +import javax.jdo.PersistenceManager; +import javax.jdo.Query; +import javax.jdo.Transaction; import java.time.LocalDate; import java.time.Month; import java.util.ArrayList; import java.util.List; -import javax.jdo.PersistenceManager; -import javax.jdo.Query; -import javax.jdo.Transaction; -import org.apache.jdo.tck.pc.query.LocalDateSample; -import org.apache.jdo.tck.query.QueryTest; -import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Supported LocalDate methods.
    - * Keywords: query
    - * Assertion ID: A14.6.2-60.
    - * Assertion Description: New supported LocalDate methods: - * + *Title: Supported LocalDate methods. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-60. + *
    + *Assertion Description: + * New supported LocalDate methods: *
      - *
    • getDayOfMonth() - *
    • getMonthValue() - *
    • getYear() + *
    • getDayOfMonth()
    • + *
    • getMonthValue()
    • + *
    • getYear()
    • *
    */ public class SupportedLocalDateMethods extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-60 (SupportedLocalDateMethods) failed: "; - - /** */ - private Object oidOfLocalDate1; - - /** */ - private Object oidOfLocalDate2; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SupportedLocalDateMethods.class); - } - - /** */ - public void testDayOfMonth() { - final String filter = "localDate.getDayOfMonth() == 12"; - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expectedResult = new ArrayList<>(); - expectedResult.add((LocalDateSample) pm.getObjectById(oidOfLocalDate1)); - - Query q = pm.newQuery(LocalDateSample.class, filter); - List results = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - tx.commit(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-60 (SupportedLocalDateMethods) failed: "; + + /** */ + private Object oidOfLocalDate1; + + /** */ + private Object oidOfLocalDate2; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SupportedLocalDateMethods.class); + } + + /** */ + public void testDayOfMonth() { + final String filter = "localDate.getDayOfMonth() == 12"; + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expectedResult = new ArrayList<>(); + expectedResult.add((LocalDateSample)pm.getObjectById(oidOfLocalDate1)); + + Query q = pm.newQuery(LocalDateSample.class, filter); + List results = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + tx.commit(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + public void testMonthValue() { + final String filter = "localDate.getMonthValue() == 8"; + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expectedResult = new ArrayList<>(); + expectedResult.add((LocalDateSample)pm.getObjectById(oidOfLocalDate2)); + + Query q = pm.newQuery(LocalDateSample.class, filter); + List results = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + tx.commit(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - public void testMonthValue() { - final String filter = "localDate.getMonthValue() == 8"; - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expectedResult = new ArrayList<>(); - expectedResult.add((LocalDateSample) pm.getObjectById(oidOfLocalDate2)); - - Query q = pm.newQuery(LocalDateSample.class, filter); - List results = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - tx.commit(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void testYear() { + final String filter = "localDate.getYear() == 2017"; + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expectedResult = new ArrayList<>(); + expectedResult.add((LocalDateSample)pm.getObjectById(oidOfLocalDate1)); + expectedResult.add((LocalDateSample)pm.getObjectById(oidOfLocalDate2)); + + Query q = pm.newQuery(LocalDateSample.class, filter); + List results = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + tx.commit(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - public void testYear() { - final String filter = "localDate.getYear() == 2017"; - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expectedResult = new ArrayList<>(); - expectedResult.add((LocalDateSample) pm.getObjectById(oidOfLocalDate1)); - expectedResult.add((LocalDateSample) pm.getObjectById(oidOfLocalDate2)); - - Query q = pm.newQuery(LocalDateSample.class, filter); - List results = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - tx.commit(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(LocalDateSample.class); + insertLocalDateSampleData(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(LocalDateSample.class); - insertLocalDateSampleData(getPM()); - } - - /** */ - private void insertLocalDateSampleData(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - LocalDateSample lds1 = new LocalDateSample(); - lds1.setId(1); - LocalDate localDate1 = LocalDate.of(2017, Month.SEPTEMBER, 12); - lds1.setLocalDate(localDate1); - pm.makePersistent(lds1); - - LocalDateSample lds2 = new LocalDateSample(); - lds2.setId(2); - LocalDate localDate2 = LocalDate.of(2017, Month.AUGUST, 20); - lds2.setLocalDate(localDate2); - pm.makePersistent(lds2); - - tx.commit(); - oidOfLocalDate1 = pm.getObjectId(lds1); - oidOfLocalDate2 = pm.getObjectId(lds2); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + private void insertLocalDateSampleData(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + LocalDateSample lds1 = new LocalDateSample(); + lds1.setId(1); + LocalDate localDate1 = LocalDate.of(2017, Month.SEPTEMBER, 12); + lds1.setLocalDate(localDate1); + pm.makePersistent(lds1); + + LocalDateSample lds2 = new LocalDateSample(); + lds2.setId(2); + LocalDate localDate2 = LocalDate.of(2017, Month.AUGUST, 20); + lds2.setLocalDate(localDate2); + pm.makePersistent(lds2); + + tx.commit(); + oidOfLocalDate1 = pm.getObjectId(lds1); + oidOfLocalDate2 = pm.getObjectId(lds2); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalDateTimeMethods.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalDateTimeMethods.java index 5fd361e44..6a2ea49f6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalDateTimeMethods.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalDateTimeMethods.java @@ -16,202 +16,221 @@ */ package org.apache.jdo.tck.query.jdoql.methods; +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.query.LocalDateTimeSample; +import org.apache.jdo.tck.query.QueryTest; +import org.apache.jdo.tck.util.BatchTestRunner; + +import javax.jdo.PersistenceManager; +import javax.jdo.Query; +import javax.jdo.Transaction; import java.time.LocalDateTime; import java.time.Month; import java.util.ArrayList; import java.util.List; -import javax.jdo.PersistenceManager; -import javax.jdo.Query; -import javax.jdo.Transaction; -import org.apache.jdo.tck.pc.query.LocalDateTimeSample; -import org.apache.jdo.tck.query.QueryTest; -import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Supported LocalDateTime methods.
    - * Keywords: query
    - * Assertion ID: A14.6.2-60.
    - * Assertion Description: New supported LocalDateTime methods: - * + *Title: Supported LocalDateTime methods. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-60. + *
    + *Assertion Description: + * New supported LocalDateTime methods: *
      - *
    • getDayOfMonth() - *
    • getMonthValue() - *
    • getYear() - *
    • getHour() - *
    • getMinute() - *
    • getSecond() + *
    • getDayOfMonth()
    • + *
    • getMonthValue()
    • + *
    • getYear()
    • + *
    • getHour()
    • + *
    • getMinute()
    • + *
    • getSecond()
    • *
    */ public class SupportedLocalDateTimeMethods extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-60 (SupportedLocalDateTimeMethods) failed: "; - - /** */ - private Object oidOfLocalDateTime1; - - /** */ - private Object oidOfLocalDateTime2; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SupportedLocalDateTimeMethods.class); - } - - /** */ - public void testDayOfMonth() { - final String filter = "localDateTime.getDayOfMonth() == 12"; - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expectedResult = new ArrayList<>(); - expectedResult.add((LocalDateTimeSample) pm.getObjectById(oidOfLocalDateTime1)); - - Query q = pm.newQuery(LocalDateTimeSample.class, filter); - List results = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - tx.commit(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-60 (SupportedLocalDateTimeMethods) failed: "; + + /** */ + private Object oidOfLocalDateTime1; + + /** */ + private Object oidOfLocalDateTime2; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SupportedLocalDateTimeMethods.class); } - } - - /** */ - public void testMonthValue() { - final String filter = "localDateTime.getMonthValue() == 8"; - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expectedResult = new ArrayList<>(); - expectedResult.add((LocalDateTimeSample) pm.getObjectById(oidOfLocalDateTime2)); - - Query q = pm.newQuery(LocalDateTimeSample.class, filter); - List results = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - tx.commit(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void testDayOfMonth() { + final String filter = "localDateTime.getDayOfMonth() == 12"; + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expectedResult = new ArrayList<>(); + expectedResult.add((LocalDateTimeSample)pm.getObjectById(oidOfLocalDateTime1)); + + Query q = pm.newQuery(LocalDateTimeSample.class, filter); + List results = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + tx.commit(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - public void testYear() { - final String filter = "localDateTime.getYear() == 2017"; - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expectedResult = new ArrayList<>(); - expectedResult.add((LocalDateTimeSample) pm.getObjectById(oidOfLocalDateTime1)); - expectedResult.add((LocalDateTimeSample) pm.getObjectById(oidOfLocalDateTime2)); - - Query q = pm.newQuery(LocalDateTimeSample.class, filter); - List results = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - tx.commit(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void testMonthValue() { + final String filter = "localDateTime.getMonthValue() == 8"; + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expectedResult = new ArrayList<>(); + expectedResult.add((LocalDateTimeSample)pm.getObjectById(oidOfLocalDateTime2)); + + Query q = pm.newQuery(LocalDateTimeSample.class, filter); + List results = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + tx.commit(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - public void testHour() { - final String filter = "localDateTime.getHour() == 14"; - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expectedResult = new ArrayList<>(); - expectedResult.add((LocalDateTimeSample) pm.getObjectById(oidOfLocalDateTime1)); - - Query q = pm.newQuery(LocalDateTimeSample.class, filter); - List results = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - tx.commit(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void testYear() { + final String filter = "localDateTime.getYear() == 2017"; + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expectedResult = new ArrayList<>(); + expectedResult.add((LocalDateTimeSample)pm.getObjectById(oidOfLocalDateTime1)); + expectedResult.add((LocalDateTimeSample)pm.getObjectById(oidOfLocalDateTime2)); + + Query q = pm.newQuery(LocalDateTimeSample.class, filter); + List results = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + tx.commit(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - public void testMinute() { - final String filter = "localDateTime.getMinute() == 22"; - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expectedResult = new ArrayList<>(); - expectedResult.add((LocalDateTimeSample) pm.getObjectById(oidOfLocalDateTime2)); - - Query q = pm.newQuery(LocalDateTimeSample.class, filter); - List results = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - tx.commit(); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void testHour() { + final String filter = "localDateTime.getHour() == 14"; + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expectedResult = new ArrayList<>(); + expectedResult.add((LocalDateTimeSample)pm.getObjectById(oidOfLocalDateTime1)); + + Query q = pm.newQuery(LocalDateTimeSample.class, filter); + List results = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + tx.commit(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - public void testSecond() { - final String filter = "localDateTime.getSecond() == 25"; - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expectedResult = new ArrayList<>(); - expectedResult.add((LocalDateTimeSample) pm.getObjectById(oidOfLocalDateTime1)); - - Query q = pm.newQuery(LocalDateTimeSample.class, filter); - List results = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void testMinute() { + final String filter = "localDateTime.getMinute() == 22"; + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expectedResult = new ArrayList<>(); + expectedResult.add((LocalDateTimeSample)pm.getObjectById(oidOfLocalDateTime2)); + + Query q = pm.newQuery(LocalDateTimeSample.class, filter); + List results = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + tx.commit(); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + public void testSecond() { + final String filter = "localDateTime.getSecond() == 25"; + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expectedResult = new ArrayList<>(); + expectedResult.add((LocalDateTimeSample)pm.getObjectById(oidOfLocalDateTime1)); + + Query q = pm.newQuery(LocalDateTimeSample.class, filter); + List results = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(LocalDateTimeSample.class); - insertLocalDateTimeSampleData(getPM()); - } - - /** */ - private void insertLocalDateTimeSampleData(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - LocalDateTimeSample lds1 = new LocalDateTimeSample(); - lds1.setId(1); - LocalDateTime localDateTime1 = LocalDateTime.of(2017, Month.SEPTEMBER, 12, 14, 10, 25); - lds1.setLocalDateTime(localDateTime1); - pm.makePersistent(lds1); - - LocalDateTimeSample lds2 = new LocalDateTimeSample(); - lds2.setId(2); - LocalDateTime localDateTime2 = LocalDateTime.of(2017, Month.AUGUST, 20, 9, 22, 12); - lds2.setLocalDateTime(localDateTime2); - pm.makePersistent(lds2); - - tx.commit(); - oidOfLocalDateTime1 = pm.getObjectId(lds1); - oidOfLocalDateTime2 = pm.getObjectId(lds2); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(LocalDateTimeSample.class); + insertLocalDateTimeSampleData(getPM()); + } + + /** */ + private void insertLocalDateTimeSampleData(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + LocalDateTimeSample lds1 = new LocalDateTimeSample(); + lds1.setId(1); + LocalDateTime localDateTime1 = LocalDateTime.of(2017, Month.SEPTEMBER, 12, 14, 10, 25); + lds1.setLocalDateTime(localDateTime1); + pm.makePersistent(lds1); + + LocalDateTimeSample lds2 = new LocalDateTimeSample(); + lds2.setId(2); + LocalDateTime localDateTime2 = LocalDateTime.of(2017, Month.AUGUST, 20, 9, 22, 12); + lds2.setLocalDateTime(localDateTime2); + pm.makePersistent(lds2); + + tx.commit(); + oidOfLocalDateTime1 = pm.getObjectId(lds1); + oidOfLocalDateTime2 = pm.getObjectId(lds2); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalTimeMethods.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalTimeMethods.java index 5095759a5..cefe93e84 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalTimeMethods.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalTimeMethods.java @@ -16,142 +16,155 @@ */ package org.apache.jdo.tck.query.jdoql.methods; -import java.time.LocalTime; -import java.util.ArrayList; -import java.util.List; -import javax.jdo.PersistenceManager; -import javax.jdo.Query; -import javax.jdo.Transaction; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.query.LocalTimeSample; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.PersistenceManager; +import javax.jdo.Query; +import javax.jdo.Transaction; +import java.time.LocalTime; +import java.util.ArrayList; +import java.util.List; + /** - * Title: Supported LocalTime methods.
    - * Keywords: query
    - * Assertion ID: A14.6.2-60.
    - * Assertion Description: New supported LocalTime methods: - * + *Title: Supported LocalTime methods. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-60. + *
    + *Assertion Description: + * New supported LocalTime methods: *
      - *
    • getHour() - *
    • getMinute() - *
    • getSecond() + *
    • getHour()
    • + *
    • getMinute()
    • + *
    • getSecond()
    • *
    */ public class SupportedLocalTimeMethods extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-60 (SupportedLocalTimeMethods) failed: "; - - /** */ - private Object oidOfLocalTime1; - - /** */ - private Object oidOfLocalTime2; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SupportedLocalTimeMethods.class); - } - - /** */ - public void testHour() { - final String filter = "localTime.getHour() == 14"; - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expectedResult = new ArrayList(); - expectedResult.add((LocalTimeSample) pm.getObjectById(oidOfLocalTime1)); - - Query q = pm.newQuery(LocalTimeSample.class, filter); - List results = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-60 (SupportedLocalTimeMethods) failed: "; + + /** */ + private Object oidOfLocalTime1; + + /** */ + private Object oidOfLocalTime2; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SupportedLocalTimeMethods.class); + } + + /** */ + public void testHour() { + final String filter = "localTime.getHour() == 14"; + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expectedResult = new ArrayList(); + expectedResult.add((LocalTimeSample)pm.getObjectById(oidOfLocalTime1)); + + Query q = pm.newQuery(LocalTimeSample.class, filter); + List results = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + public void testMinute() { + final String filter = "localTime.getMinute() == 22"; + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expectedResult = new ArrayList(); + expectedResult.add((LocalTimeSample)pm.getObjectById(oidOfLocalTime2)); + + Query q = pm.newQuery(LocalTimeSample.class, filter); + List results = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - public void testMinute() { - final String filter = "localTime.getMinute() == 22"; - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expectedResult = new ArrayList(); - expectedResult.add((LocalTimeSample) pm.getObjectById(oidOfLocalTime2)); - - Query q = pm.newQuery(LocalTimeSample.class, filter); - List results = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void testSecond() { + final String filter = "localTime.getSecond() == 25"; + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expectedResult = new ArrayList(); + expectedResult.add((LocalTimeSample)pm.getObjectById(oidOfLocalTime1)); + + Query q = pm.newQuery(LocalTimeSample.class, filter); + List results = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - public void testSecond() { - final String filter = "localTime.getSecond() == 25"; - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expectedResult = new ArrayList(); - expectedResult.add((LocalTimeSample) pm.getObjectById(oidOfLocalTime1)); - - Query q = pm.newQuery(LocalTimeSample.class, filter); - List results = q.executeList(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(LocalTimeSample.class); + insertLocalTimeSampleData(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(LocalTimeSample.class); - insertLocalTimeSampleData(getPM()); - } - - /** */ - private void insertLocalTimeSampleData(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - LocalTimeSample lds1 = new LocalTimeSample(); - lds1.setId(1); - LocalTime localTime1 = LocalTime.of(14, 10, 25); - lds1.setLocalTime(localTime1); - pm.makePersistent(lds1); - - LocalTimeSample lds2 = new LocalTimeSample(); - lds2.setId(2); - LocalTime localTime2 = LocalTime.of(9, 22, 12); - lds2.setLocalTime(localTime2); - pm.makePersistent(lds2); - - tx.commit(); - oidOfLocalTime1 = pm.getObjectId(lds1); - oidOfLocalTime2 = pm.getObjectId(lds2); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + private void insertLocalTimeSampleData(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + LocalTimeSample lds1 = new LocalTimeSample(); + lds1.setId(1); + LocalTime localTime1 = LocalTime.of(14, 10, 25); + lds1.setLocalTime(localTime1); + pm.makePersistent(lds1); + + LocalTimeSample lds2 = new LocalTimeSample(); + lds2.setId(2); + LocalTime localTime2 = LocalTime.of(9, 22, 12); + lds2.setLocalTime(localTime2); + pm.makePersistent(lds2); + + tx.commit(); + oidOfLocalTime1 = pm.getObjectId(lds1); + oidOfLocalTime2 = pm.getObjectId(lds2); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMapMethods.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMapMethods.java index e26cfd0e0..2a69a2345 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMapMethods.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMapMethods.java @@ -5,20 +5,21 @@ * 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 + * + * 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.jdo.tck.query.jdoql.methods; import java.util.ArrayList; -import javax.jdo.JDOQLTypedQuery; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.pc.company.QPerson; @@ -26,200 +27,198 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Supported Map methods.
    - * Keywords: query
    - * Assertion ID: A14.6.2-46.
    - * Assertion Description: Supported Map methods: - * + *Title: Supported Map methods. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-46. + *
    + *Assertion Description: + * Supported Map methods: *
      - *
    • get(Object) - *
    • containsKey(Object) - *
    • containsValue(Object) - *
    • isEmpty() - *
    • size() + *
    • get(Object) + *
    • containsKey(Object) + *
    • containsValue(Object) + *
    • isEmpty() + *
    • size() *
    */ public class SupportedMapMethods extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-46 (SupportedMapMethods) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SupportedMapMethods.class); - } - - /** */ - public void testGet() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.phoneNumbers.get("home").eq("1111")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "phoneNumbers.get('home') == '1111'", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testContainsKey() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.phoneNumbers.containsKey("home")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "phoneNumbers.containsKey('home')", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testContainsValue() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.phoneNumbers.containsValue("1111")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "phoneNumbers.containsValue('1111')", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testIsEmpty() { - Object expected = new ArrayList(); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.phoneNumbers.isEmpty()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "phoneNumbers.isEmpty()", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testSize() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.phoneNumbers.size().eq(2)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "phoneNumbers.size() == 2", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-46 (SupportedMapMethods) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SupportedMapMethods.class); + } + + /** */ + public void testGet() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.phoneNumbers.get("home").eq("1111")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "phoneNumbers.get('home') == '1111'", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testContainsKey() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.phoneNumbers.containsKey("home")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "phoneNumbers.containsKey('home')", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testContainsValue() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.phoneNumbers.containsValue("1111")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "phoneNumbers.containsValue('1111')", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testIsEmpty() { + Object expected = new ArrayList(); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.phoneNumbers.isEmpty()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "phoneNumbers.isEmpty()", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testSize() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.phoneNumbers.size().eq(2)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "phoneNumbers.size() == 2", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMathMethods.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMathMethods.java index 068ec6d4e..2c06858f2 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMathMethods.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMathMethods.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,10 +20,13 @@ import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collection; + import javax.jdo.JDOQLTypedQuery; import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.MylibReader; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.pc.mylib.QPrimitiveTypes; @@ -33,876 +36,903 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Supported Math methods.
    - * Keywords: query
    - * Assertion ID: A14.6.2-48.
    - * Assertion Description: Supported Math methods: - * + *Title: Supported Math methods. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-48. + *
    + *Assertion Description: + * Supported Math methods: *
      - *
    • Math.abs(numeric) - *
    • Math.sqrt(numeric) - *
    • Math.sin(numeric) - *
    • Math.cos(numeric) - *
    • Math.tan(numeric) - *
    • Math.asin(numeric) - *
    • Math.acos(numeric) - *
    • Math.atan(numeric) + *
    • Math.abs(numeric)
    • + *
    • Math.sqrt(numeric)
    • + *
    • Math.sin(numeric)
    • + *
    • Math.cos(numeric)
    • + *
    • Math.tan(numeric)
    • + *
    • Math.asin(numeric)
    • + *
    • Math.acos(numeric)
    • + *
    • Math.atan(numeric)
    • *
    */ public class SupportedMathMethods extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-48 (SupportedMathMethods) failed: "; - - /** */ - private Object oidOfMath1; - - /** */ - private Object oidOfMath2; - - /** */ - private Object oidOfMath3; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SupportedMathMethods.class); - } - - /** */ - public void testAbs0() { - Object expected = - getTransientMylibInstancesAsList( - new String[] {"primitiveTypesPositive", "primitiveTypesNegative"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); - QPrimitiveTypes cand = QPrimitiveTypes.candidate(); - query.filter(cand.intNotNull.abs().eq(4)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ PrimitiveTypes.class, - /*EXCLUDE*/ null, - /*WHERE*/ "Math.abs(intNotNull) == 4", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testAbs1() { - Object expected = - getTransientMylibInstancesAsList( - new String[] {"primitiveTypesPositive", "primitiveTypesNegative"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); - QPrimitiveTypes cand = QPrimitiveTypes.candidate(); - query.filter(cand.intNull.abs().eq(4)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ PrimitiveTypes.class, - /*EXCLUDE*/ null, - /*WHERE*/ "Math.abs(intNull) == 4", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testAbs2() { - Object expected = - getTransientMylibInstancesAsList( - new String[] {"primitiveTypesPositive", "primitiveTypesNegative"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); - QPrimitiveTypes cand = QPrimitiveTypes.candidate(); - query.filter(cand.longNotNull.abs().eq(4L)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ PrimitiveTypes.class, - /*EXCLUDE*/ null, - /*WHERE*/ "Math.abs(longNotNull) == 4", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testAbs3() { - Object expected = - getTransientMylibInstancesAsList( - new String[] {"primitiveTypesPositive", "primitiveTypesNegative"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); - QPrimitiveTypes cand = QPrimitiveTypes.candidate(); - query.filter(cand.longNull.abs().eq(4L)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ PrimitiveTypes.class, - /*EXCLUDE*/ null, - /*WHERE*/ "Math.abs(longNull) == 4", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testAbs4() { - Object expected = - getTransientMylibInstancesAsList( - new String[] {"primitiveTypesPositive", "primitiveTypesNegative"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); - QPrimitiveTypes cand = QPrimitiveTypes.candidate(); - query.filter(cand.floatNotNull.abs().lt(4.1f).and(cand.floatNotNull.abs().gt(3.9f))); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ PrimitiveTypes.class, - /*EXCLUDE*/ null, - /*WHERE*/ "Math.abs(floatNotNull) < 4.1 &&" + "Math.abs(floatNotNull) > 3.9", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testAbs5() { - Object expected = - getTransientMylibInstancesAsList( - new String[] {"primitiveTypesPositive", "primitiveTypesNegative"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); - QPrimitiveTypes cand = QPrimitiveTypes.candidate(); - query.filter(cand.floatNull.abs().lt(4.1f).and(cand.floatNull.abs().gt(3.9f))); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ PrimitiveTypes.class, - /*EXCLUDE*/ null, - /*WHERE*/ "Math.abs(floatNull) < 4.1 &&" + "Math.abs(floatNull) > 3.9", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testAbs6() { - Object expected = - getTransientMylibInstancesAsList( - new String[] {"primitiveTypesPositive", "primitiveTypesNegative"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); - QPrimitiveTypes cand = QPrimitiveTypes.candidate(); - query.filter(cand.doubleNotNull.abs().lt(4.1).and(cand.doubleNotNull.abs().gt(3.9))); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ PrimitiveTypes.class, - /*EXCLUDE*/ null, - /*WHERE*/ "Math.abs(doubleNotNull) < 4.1 &&" + "Math.abs(doubleNotNull) > 3.9", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testAbs7() { - Object expected = - getTransientMylibInstancesAsList( - new String[] {"primitiveTypesPositive", "primitiveTypesNegative"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); - QPrimitiveTypes cand = QPrimitiveTypes.candidate(); - query.filter(cand.doubleNull.abs().lt(4.1).and(cand.doubleNull.abs().gt(3.9))); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ PrimitiveTypes.class, - /*EXCLUDE*/ null, - /*WHERE*/ "Math.abs(doubleNull) < 4.1 &&" + "Math.abs(doubleNull) > 3.9", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testSqrt0() { - Object expected = getTransientMylibInstancesAsList(new String[] {"primitiveTypesPositive"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); - QPrimitiveTypes cand = QPrimitiveTypes.candidate(); - query.filter( - cand.doubleNotNull - .gt(0d) - .and(cand.doubleNotNull.sqrt().lt(2.1).and(cand.doubleNotNull.sqrt().gt(1.9)))); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ PrimitiveTypes.class, - /*EXCLUDE*/ null, - /*WHERE*/ "doubleNotNull > 0 && " - + "Math.sqrt(doubleNotNull) < 2.1 && " - + "Math.sqrt(doubleNotNull) > 1.9", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testSqrt1() { - Object expected = getTransientMylibInstancesAsList(new String[] {"primitiveTypesPositive"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); - QPrimitiveTypes cand = QPrimitiveTypes.candidate(); - query.filter( - cand.doubleNull - .gt(0d) - .and(cand.doubleNull.sqrt().lt(2.1).and(cand.doubleNull.sqrt().gt(1.9)))); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ PrimitiveTypes.class, - /*EXCLUDE*/ null, - /*WHERE*/ "doubleNull > 0 && " - + "Math.sqrt(doubleNull) < 2.1 && " - + "Math.sqrt(doubleNull) > 1.9", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testSqrt2() { - Object expected = getTransientMylibInstancesAsList(new String[] {"primitiveTypesPositive"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); - QPrimitiveTypes cand = QPrimitiveTypes.candidate(); - query.filter( - cand.intNotNull - .gt(0) - .and(cand.intNotNull.sqrt().lt(2.1).and(cand.intNotNull.sqrt().gt(1.9)))); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ PrimitiveTypes.class, - /*EXCLUDE*/ null, - /*WHERE*/ "intNotNull > 0 && " - + "Math.sqrt(intNotNull) < 2.1 && " - + "Math.sqrt(intNotNull) > 1.9", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testSqrt3() { - Object expected = getTransientMylibInstancesAsList(new String[] {"primitiveTypesPositive"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); - QPrimitiveTypes cand = QPrimitiveTypes.candidate(); - query.filter( - cand.intNull.gt(0).and(cand.intNull.sqrt().lt(2.1).and(cand.intNull.sqrt().gt(1.9)))); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ PrimitiveTypes.class, - /*EXCLUDE*/ null, - /*WHERE*/ "intNull > 0 && " - + "Math.sqrt(intNull) < 2.1 && " - + "Math.sqrt(intNull) > 1.9", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** Tests for Math.sin() */ - @SuppressWarnings("unchecked") - public void testSin() { - insertMathSampleData(getPM()); - - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - String filter = "Math.sin(angle) < 0.02 && Math.sin(angle) > -0.02"; - Collection expectedResult = new ArrayList(); - expectedResult.add(pm.getObjectById(oidOfMath1)); - expectedResult.add(pm.getObjectById(oidOfMath3)); - Query q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - Collection results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - filter = "Math.sin(angle) < 1.02 && Math.sin(angle) > 0.98"; - expectedResult.clear(); - expectedResult.add(pm.getObjectById(oidOfMath2)); - q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - filter = "Math.sin(angle) < -0.98 && Math.sin(angle) > -1.02"; - expectedResult.clear(); - q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-48 (SupportedMathMethods) failed: "; + + /** */ + private Object oidOfMath1; + + /** */ + private Object oidOfMath2; + + /** */ + private Object oidOfMath3; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SupportedMathMethods.class); + } + + /** */ + public void testAbs0() { + Object expected = getTransientMylibInstancesAsList(new String[]{ + "primitiveTypesPositive", "primitiveTypesNegative"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); + QPrimitiveTypes cand = QPrimitiveTypes.candidate(); + query.filter(cand.intNotNull.abs().eq(4)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ PrimitiveTypes.class, + /*EXCLUDE*/ null, + /*WHERE*/ "Math.abs(intNotNull) == 4", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testAbs1() { + Object expected = getTransientMylibInstancesAsList(new String[]{ + "primitiveTypesPositive", "primitiveTypesNegative"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); + QPrimitiveTypes cand = QPrimitiveTypes.candidate(); + query.filter(cand.intNull.abs().eq(4)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ PrimitiveTypes.class, + /*EXCLUDE*/ null, + /*WHERE*/ "Math.abs(intNull) == 4", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testAbs2() { + Object expected = getTransientMylibInstancesAsList(new String[]{ + "primitiveTypesPositive", "primitiveTypesNegative"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); + QPrimitiveTypes cand = QPrimitiveTypes.candidate(); + query.filter(cand.longNotNull.abs().eq(4L)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ PrimitiveTypes.class, + /*EXCLUDE*/ null, + /*WHERE*/ "Math.abs(longNotNull) == 4", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testAbs3() { + Object expected = getTransientMylibInstancesAsList(new String[]{ + "primitiveTypesPositive", "primitiveTypesNegative"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); + QPrimitiveTypes cand = QPrimitiveTypes.candidate(); + query.filter(cand.longNull.abs().eq(4L)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ PrimitiveTypes.class, + /*EXCLUDE*/ null, + /*WHERE*/ "Math.abs(longNull) == 4", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testAbs4() { + Object expected = getTransientMylibInstancesAsList(new String[]{ + "primitiveTypesPositive", "primitiveTypesNegative"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); + QPrimitiveTypes cand = QPrimitiveTypes.candidate(); + query.filter(cand.floatNotNull.abs().lt(4.1f). + and(cand.floatNotNull.abs().gt(3.9f))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ PrimitiveTypes.class, + /*EXCLUDE*/ null, + /*WHERE*/ "Math.abs(floatNotNull) < 4.1 &&" + + "Math.abs(floatNotNull) > 3.9", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testAbs5() { + Object expected = getTransientMylibInstancesAsList(new String[]{ + "primitiveTypesPositive", "primitiveTypesNegative"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); + QPrimitiveTypes cand = QPrimitiveTypes.candidate(); + query.filter(cand.floatNull.abs().lt(4.1f). + and(cand.floatNull.abs().gt(3.9f))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ PrimitiveTypes.class, + /*EXCLUDE*/ null, + /*WHERE*/ "Math.abs(floatNull) < 4.1 &&" + + "Math.abs(floatNull) > 3.9", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testAbs6() { + Object expected = getTransientMylibInstancesAsList(new String[]{ + "primitiveTypesPositive", "primitiveTypesNegative"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); + QPrimitiveTypes cand = QPrimitiveTypes.candidate(); + query.filter(cand.doubleNotNull.abs().lt(4.1). + and(cand.doubleNotNull.abs().gt(3.9))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ PrimitiveTypes.class, + /*EXCLUDE*/ null, + /*WHERE*/ "Math.abs(doubleNotNull) < 4.1 &&" + + "Math.abs(doubleNotNull) > 3.9", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testAbs7() { + Object expected = getTransientMylibInstancesAsList(new String[]{ + "primitiveTypesPositive", "primitiveTypesNegative"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); + QPrimitiveTypes cand = QPrimitiveTypes.candidate(); + query.filter(cand.doubleNull.abs().lt(4.1). + and(cand.doubleNull.abs().gt(3.9))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ PrimitiveTypes.class, + /*EXCLUDE*/ null, + /*WHERE*/ "Math.abs(doubleNull) < 4.1 &&" + + "Math.abs(doubleNull) > 3.9", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testSqrt0() { + Object expected = getTransientMylibInstancesAsList(new String[]{"primitiveTypesPositive"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); + QPrimitiveTypes cand = QPrimitiveTypes.candidate(); + query.filter(cand.doubleNotNull.gt(0d).and(cand.doubleNotNull.sqrt().lt(2.1). + and(cand.doubleNotNull.sqrt().gt(1.9)))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ PrimitiveTypes.class, + /*EXCLUDE*/ null, + /*WHERE*/ "doubleNotNull > 0 && " + + "Math.sqrt(doubleNotNull) < 2.1 && " + + "Math.sqrt(doubleNotNull) > 1.9", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); } - } - - /** Tests for Math.cos() */ - @SuppressWarnings("unchecked") - public void testCos() { - insertMathSampleData(getPM()); - - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - String filter = "Math.cos(angle) < 0.02 && Math.cos(angle) > -0.02"; - Collection expectedResult = new ArrayList(); - expectedResult.add(pm.getObjectById(oidOfMath2)); - Query q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - Collection results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - filter = "Math.cos(angle) < -0.98 && Math.cos(angle) > -1.02"; - expectedResult.clear(); - expectedResult.add(pm.getObjectById(oidOfMath1)); - q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - filter = "Math.cos(angle) < 1.02 && Math.cos(angle) > 0.98"; - expectedResult.clear(); - expectedResult.add(pm.getObjectById(oidOfMath3)); - q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void testSqrt1() { + Object expected = getTransientMylibInstancesAsList(new String[]{"primitiveTypesPositive"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); + QPrimitiveTypes cand = QPrimitiveTypes.candidate(); + query.filter(cand.doubleNull.gt(0d).and(cand.doubleNull.sqrt().lt(2.1). + and(cand.doubleNull.sqrt().gt(1.9)))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ PrimitiveTypes.class, + /*EXCLUDE*/ null, + /*WHERE*/ "doubleNull > 0 && " + + "Math.sqrt(doubleNull) < 2.1 && " + + "Math.sqrt(doubleNull) > 1.9", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testSqrt2() { + Object expected = getTransientMylibInstancesAsList(new String[]{"primitiveTypesPositive"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); + QPrimitiveTypes cand = QPrimitiveTypes.candidate(); + query.filter(cand.intNotNull.gt(0).and(cand.intNotNull.sqrt().lt(2.1). + and(cand.intNotNull.sqrt().gt(1.9)))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ PrimitiveTypes.class, + /*EXCLUDE*/ null, + /*WHERE*/ "intNotNull > 0 && " + + "Math.sqrt(intNotNull) < 2.1 && " + + "Math.sqrt(intNotNull) > 1.9", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testSqrt3() { + Object expected = getTransientMylibInstancesAsList(new String[]{"primitiveTypesPositive"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class); + QPrimitiveTypes cand = QPrimitiveTypes.candidate(); + query.filter(cand.intNull.gt(0).and(cand.intNull.sqrt().lt(2.1). + and(cand.intNull.sqrt().gt(1.9)))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ PrimitiveTypes.class, + /*EXCLUDE*/ null, + /*WHERE*/ "intNull > 0 && " + + "Math.sqrt(intNull) < 2.1 && " + + "Math.sqrt(intNull) > 1.9", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * Tests for Math.sin() + */ + @SuppressWarnings("unchecked") + public void testSin() { + insertMathSampleData(getPM()); + + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + String filter = "Math.sin(angle) < 0.02 && Math.sin(angle) > -0.02"; + Collection expectedResult = new ArrayList(); + expectedResult.add(pm.getObjectById(oidOfMath1)); + expectedResult.add(pm.getObjectById(oidOfMath3)); + Query q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + Collection results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + filter = "Math.sin(angle) < 1.02 && Math.sin(angle) > 0.98"; + expectedResult.clear(); + expectedResult.add(pm.getObjectById(oidOfMath2)); + q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + filter = "Math.sin(angle) < -0.98 && Math.sin(angle) > -1.02"; + expectedResult.clear(); + q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** + * Tests for Math.cos() + */ + @SuppressWarnings("unchecked") + public void testCos() { + insertMathSampleData(getPM()); + + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + String filter = "Math.cos(angle) < 0.02 && Math.cos(angle) > -0.02"; + Collection expectedResult = new ArrayList(); + expectedResult.add(pm.getObjectById(oidOfMath2)); + Query q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + Collection results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + filter = "Math.cos(angle) < -0.98 && Math.cos(angle) > -1.02"; + expectedResult.clear(); + expectedResult.add(pm.getObjectById(oidOfMath1)); + q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + filter = "Math.cos(angle) < 1.02 && Math.cos(angle) > 0.98"; + expectedResult.clear(); + expectedResult.add(pm.getObjectById(oidOfMath3)); + q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** + * Tests for Math.tan() + */ + @SuppressWarnings("unchecked") + public void testTan() { + insertMathSampleData(getPM()); + + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + String filter = "Math.tan(angle) < 0.02 && Math.tan(angle) > -0.02"; + Collection expectedResult = new ArrayList(); + expectedResult.add(pm.getObjectById(oidOfMath1)); + expectedResult.add(pm.getObjectById(oidOfMath3)); + Query q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + Collection results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** Tests for Math.tan() */ - @SuppressWarnings("unchecked") - public void testTan() { - insertMathSampleData(getPM()); - - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - String filter = "Math.tan(angle) < 0.02 && Math.tan(angle) > -0.02"; - Collection expectedResult = new ArrayList(); - expectedResult.add(pm.getObjectById(oidOfMath1)); - expectedResult.add(pm.getObjectById(oidOfMath3)); - Query q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - Collection results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** + * Tests for Math.asin() + */ + @SuppressWarnings("unchecked") + public void testArcSin() { + insertMathSampleData(getPM()); + + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + String filter = "Math.asin(trigValue) < 0.1 && Math.asin(trigValue) > -0.1"; + Collection expectedResult = new ArrayList(); + expectedResult.add(pm.getObjectById(oidOfMath1)); + Query q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + Collection results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + filter = "Math.asin(trigValue) < 1.5714 && Math.asin(trigValue) > 1.570"; + expectedResult.clear(); + expectedResult.add(pm.getObjectById(oidOfMath2)); + q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + filter = "Math.asin(trigValue) < -1.570 && Math.asin(trigValue) > -1.5714"; + expectedResult.clear(); + expectedResult.add(pm.getObjectById(oidOfMath3)); + q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** Tests for Math.asin() */ - @SuppressWarnings("unchecked") - public void testArcSin() { - insertMathSampleData(getPM()); - - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - String filter = "Math.asin(trigValue) < 0.1 && Math.asin(trigValue) > -0.1"; - Collection expectedResult = new ArrayList(); - expectedResult.add(pm.getObjectById(oidOfMath1)); - Query q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - Collection results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - filter = "Math.asin(trigValue) < 1.5714 && Math.asin(trigValue) > 1.570"; - expectedResult.clear(); - expectedResult.add(pm.getObjectById(oidOfMath2)); - q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - filter = "Math.asin(trigValue) < -1.570 && Math.asin(trigValue) > -1.5714"; - expectedResult.clear(); - expectedResult.add(pm.getObjectById(oidOfMath3)); - q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** + * Tests for Math.acos() + */ + @SuppressWarnings("unchecked") + public void testArcCos() { + insertMathSampleData(getPM()); + + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + String filter = "Math.acos(trigValue) < 1.5714 && Math.acos(trigValue) > 1.570"; + Collection expectedResult = new ArrayList(); + expectedResult.add(pm.getObjectById(oidOfMath1)); + Query q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + Collection results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + filter = "Math.acos(trigValue) < 0.1 && Math.acos(trigValue) > -0.1"; + expectedResult.clear(); + expectedResult.add(pm.getObjectById(oidOfMath2)); + q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + filter = "Math.acos(trigValue) < 3.147 && Math.acos(trigValue) > 3.14"; + expectedResult.clear(); + expectedResult.add(pm.getObjectById(oidOfMath3)); + q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** Tests for Math.acos() */ - @SuppressWarnings("unchecked") - public void testArcCos() { - insertMathSampleData(getPM()); - - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - String filter = "Math.acos(trigValue) < 1.5714 && Math.acos(trigValue) > 1.570"; - Collection expectedResult = new ArrayList(); - expectedResult.add(pm.getObjectById(oidOfMath1)); - Query q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - Collection results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - filter = "Math.acos(trigValue) < 0.1 && Math.acos(trigValue) > -0.1"; - expectedResult.clear(); - expectedResult.add(pm.getObjectById(oidOfMath2)); - q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - filter = "Math.acos(trigValue) < 3.147 && Math.acos(trigValue) > 3.14"; - expectedResult.clear(); - expectedResult.add(pm.getObjectById(oidOfMath3)); - q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** + * Tests for Math.atan() + */ + @SuppressWarnings("unchecked") + public void testArcTan() { + insertMathSampleData(getPM()); + + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + String filter = "Math.atan(trigValue) < 0.5 && Math.atan(trigValue) > -0.5"; + Collection expectedResult = new ArrayList(); + expectedResult.add(pm.getObjectById(oidOfMath1)); + Query q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + Collection results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** Tests for Math.atan() */ - @SuppressWarnings("unchecked") - public void testArcTan() { - insertMathSampleData(getPM()); - - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - String filter = "Math.atan(trigValue) < 0.5 && Math.atan(trigValue) > -0.5"; - Collection expectedResult = new ArrayList(); - expectedResult.add(pm.getObjectById(oidOfMath1)); - Query q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - Collection results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** + * Tests for Math.ceil() + */ + @SuppressWarnings("unchecked") + public void testCeil() { + insertMathSampleData(getPM()); + + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + String filter = "Math.ceil(doubleValue) == 5"; + Collection expectedResult = new ArrayList(); + expectedResult.add(pm.getObjectById(oidOfMath1)); + expectedResult.add(pm.getObjectById(oidOfMath2)); + Query q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + Collection results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + filter = "Math.ceil(floatValue) == 3"; + expectedResult.clear(); + expectedResult.add(pm.getObjectById(oidOfMath3)); + q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + filter = "Math.ceil(intValue) == 5"; + expectedResult.clear(); + expectedResult.add(pm.getObjectById(oidOfMath1)); + q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** Tests for Math.ceil() */ - @SuppressWarnings("unchecked") - public void testCeil() { - insertMathSampleData(getPM()); - - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - String filter = "Math.ceil(doubleValue) == 5"; - Collection expectedResult = new ArrayList(); - expectedResult.add(pm.getObjectById(oidOfMath1)); - expectedResult.add(pm.getObjectById(oidOfMath2)); - Query q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - Collection results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - filter = "Math.ceil(floatValue) == 3"; - expectedResult.clear(); - expectedResult.add(pm.getObjectById(oidOfMath3)); - q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - filter = "Math.ceil(intValue) == 5"; - expectedResult.clear(); - expectedResult.add(pm.getObjectById(oidOfMath1)); - q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** + * Tests for Math.floor() + */ + @SuppressWarnings("unchecked") + public void testFloor() { + insertMathSampleData(getPM()); + + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + String filter = "Math.floor(doubleValue) == 4"; + Collection expectedResult = new ArrayList(); + expectedResult.add(pm.getObjectById(oidOfMath1)); + expectedResult.add(pm.getObjectById(oidOfMath2)); + Query q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + Collection results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + filter = "Math.floor(floatValue) == 2"; + expectedResult.clear(); + expectedResult.add(pm.getObjectById(oidOfMath3)); + q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + filter = "Math.floor(intValue) == 4"; + expectedResult.clear(); + expectedResult.add(pm.getObjectById(oidOfMath2)); + q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** Tests for Math.floor() */ - @SuppressWarnings("unchecked") - public void testFloor() { - insertMathSampleData(getPM()); - - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - String filter = "Math.floor(doubleValue) == 4"; - Collection expectedResult = new ArrayList(); - expectedResult.add(pm.getObjectById(oidOfMath1)); - expectedResult.add(pm.getObjectById(oidOfMath2)); - Query q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - Collection results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - filter = "Math.floor(floatValue) == 2"; - expectedResult.clear(); - expectedResult.add(pm.getObjectById(oidOfMath3)); - q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - filter = "Math.floor(intValue) == 4"; - expectedResult.clear(); - expectedResult.add(pm.getObjectById(oidOfMath2)); - q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** + * Tests for Math.exp() + */ + @SuppressWarnings("unchecked") + public void testExp() { + insertMathSampleData(getPM()); + + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + String filter = "Math.exp(doubleValue) < 85.63 && Math.exp(doubleValue) > 85.62"; + Collection expectedResult = new ArrayList(); + expectedResult.add(pm.getObjectById(oidOfMath2)); + Query q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + Collection results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** Tests for Math.exp() */ - @SuppressWarnings("unchecked") - public void testExp() { - insertMathSampleData(getPM()); - - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - String filter = "Math.exp(doubleValue) < 85.63 && Math.exp(doubleValue) > 85.62"; - Collection expectedResult = new ArrayList(); - expectedResult.add(pm.getObjectById(oidOfMath2)); - Query q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - Collection results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** + * Tests for Math.log() + */ + @SuppressWarnings("unchecked") + public void testLog() { + insertMathSampleData(getPM()); + + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + String filter = "Math.log(doubleValue) < 1.4935 && Math.log(doubleValue) > 1.491"; + Collection expectedResult = new ArrayList(); + expectedResult.add(pm.getObjectById(oidOfMath2)); + Query q = pm.newQuery(); + q.setClass(MathSample.class); + q.setFilter(filter); + Collection results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** Tests for Math.log() */ - @SuppressWarnings("unchecked") - public void testLog() { - insertMathSampleData(getPM()); - - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - String filter = "Math.log(doubleValue) < 1.4935 && Math.log(doubleValue) > 1.491"; - Collection expectedResult = new ArrayList(); - expectedResult.add(pm.getObjectById(oidOfMath2)); - Query q = pm.newQuery(); - q.setClass(MathSample.class); - q.setFilter(filter); - Collection results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(MylibReader.getTearDownClasses()); + addTearDownClass(MathSample.class); + loadAndPersistMylib(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(MylibReader.getTearDownClasses()); - addTearDownClass(MathSample.class); - loadAndPersistMylib(getPM()); - } - - /** */ - private void insertMathSampleData(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - // Sample 1 : angle=PI (180 degrees) - MathSample ms1 = new MathSample(); - ms1.setId(1); - ms1.setAngle(new BigDecimal(Math.PI)); - ms1.setTrigValue(new BigDecimal(0.0)); - ms1.setDoubleValue(Double.valueOf(4.55)); - ms1.setFloatValue(Float.valueOf(4.55f)); - ms1.setIntValue(Integer.valueOf(5)); - pm.makePersistent(ms1); - - // Sample 2 : angle=PI/2 (90 degrees) - MathSample ms2 = new MathSample(); - ms2.setId(2); - ms2.setAngle(new BigDecimal(Math.PI / 2.0)); - ms2.setTrigValue(new BigDecimal(1.0)); - ms2.setDoubleValue(Double.valueOf(4.45)); - ms2.setFloatValue(Float.valueOf((float) 4.45)); - ms2.setIntValue(Integer.valueOf(4)); - pm.makePersistent(ms2); - - // Sample 3 : angle=0 (0 degrees) - MathSample ms3 = new MathSample(); - ms3.setId(3); - ms3.setAngle(new BigDecimal(0)); - ms3.setTrigValue(new BigDecimal(-1.0)); - ms3.setDoubleValue(Double.valueOf(2.49)); - ms3.setFloatValue(Float.valueOf((float) 2.49)); - ms3.setIntValue(Integer.valueOf(3)); - pm.makePersistent(ms3); - - tx.commit(); - oidOfMath1 = pm.getObjectId(ms1); - oidOfMath2 = pm.getObjectId(ms2); - oidOfMath3 = pm.getObjectId(ms3); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + private void insertMathSampleData(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + // Sample 1 : angle=PI (180 degrees) + MathSample ms1 = new MathSample(); + ms1.setId(1); + ms1.setAngle(new BigDecimal(Math.PI)); + ms1.setTrigValue(new BigDecimal(0.0)); + ms1.setDoubleValue(Double.valueOf(4.55)); + ms1.setFloatValue(Float.valueOf(4.55f)); + ms1.setIntValue(Integer.valueOf(5)); + pm.makePersistent(ms1); + + // Sample 2 : angle=PI/2 (90 degrees) + MathSample ms2 = new MathSample(); + ms2.setId(2); + ms2.setAngle(new BigDecimal(Math.PI/2.0)); + ms2.setTrigValue(new BigDecimal(1.0)); + ms2.setDoubleValue(Double.valueOf(4.45)); + ms2.setFloatValue(Float.valueOf((float)4.45)); + ms2.setIntValue(Integer.valueOf(4)); + pm.makePersistent(ms2); + + // Sample 3 : angle=0 (0 degrees) + MathSample ms3 = new MathSample(); + ms3.setId(3); + ms3.setAngle(new BigDecimal(0)); + ms3.setTrigValue(new BigDecimal(-1.0)); + ms3.setDoubleValue(Double.valueOf(2.49)); + ms3.setFloatValue(Float.valueOf((float)2.49)); + ms3.setIntValue(Integer.valueOf(3)); + pm.makePersistent(ms3); + + tx.commit(); + oidOfMath1 = pm.getObjectId(ms1); + oidOfMath2 = pm.getObjectId(ms2); + oidOfMath3 = pm.getObjectId(ms3); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedOptionalMethods.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedOptionalMethods.java index 3ed89a887..913d16f5b 100755 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedOptionalMethods.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedOptionalMethods.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -23,602 +23,574 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.query.OptionalSample; import org.apache.jdo.tck.query.QueryElementHolder; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Optional Fields.
    - * Keywords: query
    - * Assertion ID: A14.6.2-9
    - * Assertion Description: Queries on fields of type java.util.Optional . + *Title: Optional Fields. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-9 + *
    + *Assertion Description: + *Queries on fields of type java.util.Optional . */ public class SupportedOptionalMethods extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.2-9 (OptionalFields) failed: "; - - private static final int PC_ID = 1; - private static final int PC_EMPTY_ID = 3; - private static final int PC_NULL_ID = 4; - private static final int REFERENCED_PC1_ID = 88; - private static final int REFERENCED_PC2_ID = 99; - private static final String STRING = "Hello JDO"; - private static final Integer INTEGER = 2016; - private static final Date DATE = new Date(1000000000); - private Object oidReferencedPC1; - private Object oidReferencedPC2; - private Object oidPC; - private Object oidEmpty; - private Object oidNull; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SupportedOptionalMethods.class); - } - - /** */ - public void testQueriesWithPresence() { - // Matches 'optionalPC.isPresent() == true' - checkQuery("optionalPC != null", oidPC, oidReferencedPC1); - - // matches !isPresent() but does NOT match Java 'optionalPC==null' - checkQuery("optionalPC == null", oidEmpty, oidNull, oidReferencedPC2); - - // matches isPresent() - checkQuery("!(optionalPC == null)", oidReferencedPC1, oidPC); - - // matches !isPresent() - checkQuery("!(optionalPC != null)", oidReferencedPC2, oidEmpty, oidNull); - - checkQuery("optionalPC.get() != null", oidPC, oidReferencedPC1); - checkQuery("optionalPC.get() == null", oidEmpty, oidNull, oidReferencedPC2); - checkQuery("optionalPC.isPresent()", oidPC, oidReferencedPC1); - checkQuery("!optionalPC.isPresent()", oidReferencedPC2, oidEmpty, oidNull); - - // querying non-PC 'Optional' fields - checkOptionalForPresence("optionalString"); - checkOptionalForPresence("optionalDate"); - checkOptionalForPresence("optionalInteger"); - } - - private void checkOptionalForPresence(String fieldName) { - checkQuery(fieldName + " != null", oidPC); - checkQuery(fieldName + " == null", oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2); - checkQuery("!(" + fieldName + " == null)", oidPC); - checkQuery( - "!(" + fieldName + " != null)", oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2); - - checkQuery(fieldName + ".get() != null", oidPC); - checkQuery(fieldName + ".get() == null", oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2); - checkQuery(fieldName + ".isPresent()", oidPC); - checkQuery( - "!" + fieldName + ".isPresent()", oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2); - } - - public void testQueriesWithNavigation() { - checkQuery("optionalPC.id == " + REFERENCED_PC1_ID, oidPC); - checkQuery("optionalPC.id != " + REFERENCED_PC1_ID, oidReferencedPC1); - checkQuery("!(optionalPC.id == " + REFERENCED_PC1_ID + ")", oidReferencedPC1); - checkQuery("optionalPC.get().id == " + REFERENCED_PC1_ID, oidPC); - checkQuery("optionalPC.get().id != " + REFERENCED_PC1_ID, oidReferencedPC1); - checkQuery("!(optionalPC.get().id == " + REFERENCED_PC1_ID + ")", oidReferencedPC1); - checkQuery("optionalPC.optionalPC.isPresent()", oidPC); - - // The following reflects the changed behavior in JDO 3.2 in the sense that - // all instances are returned where either 'optionalPC.optionalPC==null' (not present) - // or 'optionalPC==null' (the 'null' evaluates to 'null', which is followed until it is - // evaluated in the 'isPresent()'). In other words, the query also returns all - // objects that match '!(optionalPC.isPresent())'. - checkQuery( - "!(optionalPC.optionalPC.isPresent())", - oidReferencedPC1, - oidReferencedPC2, - oidEmpty, - oidNull); - - // A query where 'optionalPC!=null' and 'optionalPC.optionalPC==null; - // can be done as follows: - checkQuery("optionalPC.isPresent() && !(optionalPC.optionalPC.isPresent())", oidReferencedPC1); - - checkQuery("optionalPC.optionalPC.id == " + REFERENCED_PC2_ID, oidPC); - checkQuery("optionalPC.get().optionalPC.get().id == " + REFERENCED_PC2_ID, oidPC); - - // test with && operator - checkQuery( - "!(optionalPC.isPresent() && optionalPC.id == " + REFERENCED_PC1_ID + ")", - oidReferencedPC1, - oidReferencedPC2, - oidEmpty, - oidNull); - } - - private void checkQuery(String filter, Object... resultOids) { - QueryElementHolder qeh = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ OptionalSample.class, - /*EXCLUDE*/ null, - /*WHERE*/ filter, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ null, - /*paramValues*/ null); - - ArrayList expectedResults = new ArrayList<>(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - for (int i = 0; i < resultOids.length; i++) { - expectedResults.add(pm.getObjectById(resultOids[i])); - } - } finally { - if (tx.isActive()) { - tx.rollback(); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-9 (OptionalFields) failed: "; + + private static final int PC_ID = 1; + private static final int PC_EMPTY_ID = 3; + private static final int PC_NULL_ID = 4; + private static final int REFERENCED_PC1_ID = 88; + private static final int REFERENCED_PC2_ID = 99; + private static final String STRING = "Hello JDO"; + private static final Integer INTEGER = 2016; + private static final Date DATE = new Date(1000000000); + private Object oidReferencedPC1; + private Object oidReferencedPC2; + private Object oidPC; + private Object oidEmpty; + private Object oidNull; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SupportedOptionalMethods.class); + } + + /** */ + public void testQueriesWithPresence() { + //Matches 'optionalPC.isPresent() == true' + checkQuery("optionalPC != null", oidPC, oidReferencedPC1); + + //matches !isPresent() but does NOT match Java 'optionalPC==null' + checkQuery("optionalPC == null", oidEmpty, oidNull, oidReferencedPC2); + + //matches isPresent() + checkQuery("!(optionalPC == null)", oidReferencedPC1, oidPC); + + //matches !isPresent() + checkQuery("!(optionalPC != null)", oidReferencedPC2, oidEmpty, oidNull); + + checkQuery("optionalPC.get() != null", oidPC, oidReferencedPC1); + checkQuery("optionalPC.get() == null", oidEmpty, oidNull, oidReferencedPC2); + checkQuery("optionalPC.isPresent()", oidPC, oidReferencedPC1); + checkQuery("!optionalPC.isPresent()", oidReferencedPC2, oidEmpty, oidNull); + + //querying non-PC 'Optional' fields + checkOptionalForPresence("optionalString"); + checkOptionalForPresence("optionalDate"); + checkOptionalForPresence("optionalInteger"); + } + + private void checkOptionalForPresence(String fieldName) { + checkQuery(fieldName + " != null", oidPC); + checkQuery(fieldName + " == null", + oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2); + checkQuery("!(" + fieldName + " == null)", oidPC); + checkQuery("!("+ fieldName + " != null)", + oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2); + + checkQuery(fieldName + ".get() != null", oidPC); + checkQuery(fieldName + ".get() == null", + oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2); + checkQuery(fieldName + ".isPresent()", oidPC); + checkQuery("!"+ fieldName + ".isPresent()", + oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2); + } + + public void testQueriesWithNavigation() { + checkQuery("optionalPC.id == " + REFERENCED_PC1_ID, oidPC); + checkQuery("optionalPC.id != " + REFERENCED_PC1_ID, oidReferencedPC1); + checkQuery("!(optionalPC.id == " + REFERENCED_PC1_ID + ")", oidReferencedPC1); + checkQuery("optionalPC.get().id == " + REFERENCED_PC1_ID, oidPC); + checkQuery("optionalPC.get().id != " + REFERENCED_PC1_ID, oidReferencedPC1); + checkQuery("!(optionalPC.get().id == " + REFERENCED_PC1_ID + ")", oidReferencedPC1); + checkQuery("optionalPC.optionalPC.isPresent()", oidPC); + + //The following reflects the changed behavior in JDO 3.2 in the sense that + //all instances are returned where either 'optionalPC.optionalPC==null' (not present) + //or 'optionalPC==null' (the 'null' evaluates to 'null', which is followed until it is + //evaluated in the 'isPresent()'). In other words, the query also returns all + //objects that match '!(optionalPC.isPresent())'. + checkQuery("!(optionalPC.optionalPC.isPresent())", + oidReferencedPC1, oidReferencedPC2, oidEmpty, oidNull); + + //A query where 'optionalPC!=null' and 'optionalPC.optionalPC==null; + //can be done as follows: + checkQuery("optionalPC.isPresent() && !(optionalPC.optionalPC.isPresent())", + oidReferencedPC1); + + checkQuery("optionalPC.optionalPC.id == " + REFERENCED_PC2_ID, oidPC); + checkQuery("optionalPC.get().optionalPC.get().id == " + REFERENCED_PC2_ID, oidPC); + + //test with && operator + checkQuery("!(optionalPC.isPresent() && optionalPC.id == " + REFERENCED_PC1_ID + ")", + oidReferencedPC1, oidReferencedPC2, oidEmpty, oidNull); + } + + private void checkQuery(String filter, Object ... resultOids) { + QueryElementHolder qeh = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ OptionalSample.class, + /*EXCLUDE*/ null, + /*WHERE*/ filter, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ null, + /*paramValues*/ null); + + ArrayList expectedResults = new ArrayList<>(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + for (int i = 0; i < resultOids.length; i++) { + expectedResults.add(pm.getObjectById(resultOids[i])); + } + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + + executeAPIQuery(ASSERTION_FAILED, qeh, expectedResults); + executeSingleStringQuery(ASSERTION_FAILED, qeh, expectedResults); + } + + /** + * This methods tests Optional fields and parameters. + */ + public void testParameterOptional() { + OptionalSample osReferencedPC1 = getOptionalSampleById(oidReferencedPC1); + String paramDecl = "java.util.Optional op"; + Map paramValues = new HashMap<>(); + + paramValues.put("op", Optional.of(osReferencedPC1)); + checkQuery("this.optionalPC == op", paramDecl, + paramValues, new Object[]{oidPC}); + + paramValues.put("op", Optional.of(DATE)); + checkQuery("this.optionalDate == op", paramDecl, + paramValues, new Object[]{oidPC}); + + paramValues.put("op", Optional.of(INTEGER)); + checkQuery("this.optionalInteger == op", paramDecl, + paramValues, new Object[]{oidPC}); + + paramValues.put("op", Optional.of(STRING)); + checkQuery("this.optionalString == op", paramDecl, + paramValues, new Object[]{oidPC}); + } + + /** + * This methods tests Optional fields and parameters with auto + * de-referencing. + */ + public void testParameterOptionalAutoDeref() { + OptionalSample osReferencedPC1 = getOptionalSampleById(oidReferencedPC1); + Map paramValues = new HashMap<>(); + + paramValues.put("op", osReferencedPC1); + checkQuery("this.optionalPC == op", + OptionalSample.class.getName() + " op", + paramValues, new Object[]{oidPC}); + + paramValues.put("op", DATE); + checkQuery("this.optionalDate == op", + "java.util.Date op", + paramValues, new Object[]{oidPC}); + + paramValues.put("op", INTEGER); + checkQuery("this.optionalInteger == op", + "Integer op", + paramValues, new Object[]{oidPC}); + + paramValues.put("op", STRING); + checkQuery("this.optionalString == op", + "String op", + paramValues, new Object[]{oidPC}); + } + + private OptionalSample getOptionalSampleById(Object id) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + return (OptionalSample) pm.getObjectById(id); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** + * This methods tests that empty Optional fields and parameters matches with + * Optional.empty(). + */ + public void testParameterOptionalWithEmptyFields() { + String paramDecl = "java.util.Optional op"; + Map paramValues = new HashMap<>(); + paramValues.put("op", Optional.empty()); + checkQuery("this.optionalPC == op", paramDecl, paramValues, + new Object[]{oidEmpty, oidNull, oidReferencedPC2}); + checkQuery("this.optionalDate == op", paramDecl, paramValues, + new Object[]{oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2}); + checkQuery("this.optionalInteger == op", paramDecl, paramValues, + new Object[]{oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2}); + checkQuery("this.optionalString == op", paramDecl, paramValues, + new Object[]{oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2}); + } + + /** + * This methods tests that Optional fields and parameters matches with + * (Optional)null. + */ + public void testParameterOptionalWithNull() { + String paramDecl = "java.util.Optional op"; + Map paramValues = new HashMap<>(); + paramValues.put("op", null); + checkQuery("this.optionalPC == op", paramDecl, paramValues, + new Object[]{oidEmpty, oidNull, oidReferencedPC2}); + checkQuery("this.optionalDate == op", paramDecl, paramValues, + new Object[]{oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2}); + checkQuery("this.optionalInteger == op", paramDecl, paramValues, + new Object[]{oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2}); + checkQuery("this.optionalString == op", paramDecl, paramValues, + new Object[]{oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2}); + } + + /** + * This methods tests that Optional fields and parameters matches with + * (Object)null. + */ + public void testParameterOptionalNull() { + Map paramValues = new HashMap<>(); + paramValues.put("op", null); + checkQuery("this.optionalPC == op", OptionalSample.class.getName() + " op", paramValues, + new Object[]{oidEmpty, oidNull, oidReferencedPC2}); + checkQuery("this.optionalDate == op", "java.util.Date op", paramValues, + new Object[]{oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2}); + checkQuery("this.optionalInteger == op", "java.lang.Integer op", paramValues, + new Object[]{oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2}); + checkQuery("this.optionalString == op", "java.lang.String op", paramValues, + new Object[]{oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2}); + + } + + /** + * This methods tests that Optional fields can be accessed in subqueries. + */ + public void testSubqueries() { + String queryStr1 = + "SELECT FROM " + OptionalSample.class.getName() + " WHERE " + + "(select max(a.id) from " + OptionalSample.class.getName() + " a " + + "where a.optionalPC.isPresent() ) == id"; + Object[] expectedResult1 = new Object[]{oidReferencedPC1}; + checkSingleStringQuery(queryStr1, expectedResult1); + + String queryStr2 = + "SELECT FROM " + OptionalSample.class.getName() + " WHERE " + + "(select max(a.id) from " + OptionalSample.class.getName() + " a " + + "where a.optionalPC.get() != null) == id"; + Object[] expectedResult2 = new Object[]{oidReferencedPC1}; + checkSingleStringQuery(queryStr2, expectedResult2); } - executeAPIQuery(ASSERTION_FAILED, qeh, expectedResults); - executeSingleStringQuery(ASSERTION_FAILED, qeh, expectedResults); - } - - /** This methods tests Optional fields and parameters. */ - public void testParameterOptional() { - OptionalSample osReferencedPC1 = getOptionalSampleById(oidReferencedPC1); - String paramDecl = "java.util.Optional op"; - Map paramValues = new HashMap<>(); - - paramValues.put("op", Optional.of(osReferencedPC1)); - checkQuery("this.optionalPC == op", paramDecl, paramValues, new Object[] {oidPC}); - - paramValues.put("op", Optional.of(DATE)); - checkQuery("this.optionalDate == op", paramDecl, paramValues, new Object[] {oidPC}); - - paramValues.put("op", Optional.of(INTEGER)); - checkQuery("this.optionalInteger == op", paramDecl, paramValues, new Object[] {oidPC}); - - paramValues.put("op", Optional.of(STRING)); - checkQuery("this.optionalString == op", paramDecl, paramValues, new Object[] {oidPC}); - } - - /** This methods tests Optional fields and parameters with auto de-referencing. */ - public void testParameterOptionalAutoDeref() { - OptionalSample osReferencedPC1 = getOptionalSampleById(oidReferencedPC1); - Map paramValues = new HashMap<>(); - - paramValues.put("op", osReferencedPC1); - checkQuery( - "this.optionalPC == op", - OptionalSample.class.getName() + " op", - paramValues, - new Object[] {oidPC}); - - paramValues.put("op", DATE); - checkQuery("this.optionalDate == op", "java.util.Date op", paramValues, new Object[] {oidPC}); - - paramValues.put("op", INTEGER); - checkQuery("this.optionalInteger == op", "Integer op", paramValues, new Object[] {oidPC}); - - paramValues.put("op", STRING); - checkQuery("this.optionalString == op", "String op", paramValues, new Object[] {oidPC}); - } - - private OptionalSample getOptionalSampleById(Object id) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - return (OptionalSample) pm.getObjectById(id); - } finally { - if (tx.isActive()) { - tx.rollback(); - } + /** + * This methods tests that Optional fields can be accessed in subqueries. + */ + public void testOptionalAggregation() { + String clsName = OptionalSample.class.getName(); + + String queryStr1 = "SELECT AVG(optionalInteger) FROM " + clsName; + Query q1 = pm.newQuery(queryStr1); + executeJDOQuery(ASSERTION_FAILED, q1, queryStr1, false, null, (double)INTEGER, true); + + String queryStr2 = "SELECT AVG(optionalInteger.get()) FROM " + clsName; + Query q2 = pm.newQuery(queryStr2); + executeJDOQuery(ASSERTION_FAILED, q2, queryStr2, false, null, (double)INTEGER, true); + + //return the object whose Integer is the same as the AVG of all + //objects that have the Integer present. + String queryStrSub1 = "SELECT FROM " + clsName + " WHERE " + + "(select avg(a.optionalInteger) from " + clsName + " a " + + "where a.optionalInteger.isPresent() ) == optionalInteger"; + Object[] expectedResult1 = new Object[]{oidPC}; + checkSingleStringQuery(queryStrSub1, expectedResult1); + + String queryStrSub2 = "SELECT FROM " + clsName + " WHERE " + + "(select avg(a.optionalInteger.get()) from " + clsName + " a " + + "where a.optionalInteger.isPresent() ) == optionalInteger"; + Object[] expectedResult2 = new Object[]{oidPC}; + checkSingleStringQuery(queryStrSub2, expectedResult2); + + //Find all where the average is the same as the integer value itself. + //This returns ALL objects!!! + String queryStrSub3 = "SELECT FROM " + clsName + " WHERE " + + "(select avg(a.optionalInteger) from " + clsName + " a " + + " ) == optionalInteger"; + Object[] expectedResult3 = new Object[]{oidPC}; + checkSingleStringQuery(queryStrSub3, expectedResult3); } - } - - /** This methods tests that empty Optional fields and parameters matches with Optional.empty(). */ - public void testParameterOptionalWithEmptyFields() { - String paramDecl = "java.util.Optional op"; - Map paramValues = new HashMap<>(); - paramValues.put("op", Optional.empty()); - checkQuery( - "this.optionalPC == op", - paramDecl, - paramValues, - new Object[] {oidEmpty, oidNull, oidReferencedPC2}); - checkQuery( - "this.optionalDate == op", - paramDecl, - paramValues, - new Object[] {oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2}); - checkQuery( - "this.optionalInteger == op", - paramDecl, - paramValues, - new Object[] {oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2}); - checkQuery( - "this.optionalString == op", - paramDecl, - paramValues, - new Object[] {oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2}); - } - - /** This methods tests that Optional fields and parameters matches with (Optional)null. */ - public void testParameterOptionalWithNull() { - String paramDecl = "java.util.Optional op"; - Map paramValues = new HashMap<>(); - paramValues.put("op", null); - checkQuery( - "this.optionalPC == op", - paramDecl, - paramValues, - new Object[] {oidEmpty, oidNull, oidReferencedPC2}); - checkQuery( - "this.optionalDate == op", - paramDecl, - paramValues, - new Object[] {oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2}); - checkQuery( - "this.optionalInteger == op", - paramDecl, - paramValues, - new Object[] {oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2}); - checkQuery( - "this.optionalString == op", - paramDecl, - paramValues, - new Object[] {oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2}); - } - - /** This methods tests that Optional fields and parameters matches with (Object)null. */ - public void testParameterOptionalNull() { - Map paramValues = new HashMap<>(); - paramValues.put("op", null); - checkQuery( - "this.optionalPC == op", - OptionalSample.class.getName() + " op", - paramValues, - new Object[] {oidEmpty, oidNull, oidReferencedPC2}); - checkQuery( - "this.optionalDate == op", - "java.util.Date op", - paramValues, - new Object[] {oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2}); - checkQuery( - "this.optionalInteger == op", - "java.lang.Integer op", - paramValues, - new Object[] {oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2}); - checkQuery( - "this.optionalString == op", - "java.lang.String op", - paramValues, - new Object[] {oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2}); - } - - /** This methods tests that Optional fields can be accessed in subqueries. */ - public void testSubqueries() { - String queryStr1 = - "SELECT FROM " - + OptionalSample.class.getName() - + " WHERE " - + "(select max(a.id) from " - + OptionalSample.class.getName() - + " a " - + "where a.optionalPC.isPresent() ) == id"; - Object[] expectedResult1 = new Object[] {oidReferencedPC1}; - checkSingleStringQuery(queryStr1, expectedResult1); - - String queryStr2 = - "SELECT FROM " - + OptionalSample.class.getName() - + " WHERE " - + "(select max(a.id) from " - + OptionalSample.class.getName() - + " a " - + "where a.optionalPC.get() != null) == id"; - Object[] expectedResult2 = new Object[] {oidReferencedPC1}; - checkSingleStringQuery(queryStr2, expectedResult2); - } - - /** This methods tests that Optional fields can be accessed in subqueries. */ - public void testOptionalAggregation() { - String clsName = OptionalSample.class.getName(); - - String queryStr1 = "SELECT AVG(optionalInteger) FROM " + clsName; - Query q1 = pm.newQuery(queryStr1); - executeJDOQuery(ASSERTION_FAILED, q1, queryStr1, false, null, (double) INTEGER, true); - - String queryStr2 = "SELECT AVG(optionalInteger.get()) FROM " + clsName; - Query q2 = pm.newQuery(queryStr2); - executeJDOQuery(ASSERTION_FAILED, q2, queryStr2, false, null, (double) INTEGER, true); - - // return the object whose Integer is the same as the AVG of all - // objects that have the Integer present. - String queryStrSub1 = - "SELECT FROM " - + clsName - + " WHERE " - + "(select avg(a.optionalInteger) from " - + clsName - + " a " - + "where a.optionalInteger.isPresent() ) == optionalInteger"; - Object[] expectedResult1 = new Object[] {oidPC}; - checkSingleStringQuery(queryStrSub1, expectedResult1); - - String queryStrSub2 = - "SELECT FROM " - + clsName - + " WHERE " - + "(select avg(a.optionalInteger.get()) from " - + clsName - + " a " - + "where a.optionalInteger.isPresent() ) == optionalInteger"; - Object[] expectedResult2 = new Object[] {oidPC}; - checkSingleStringQuery(queryStrSub2, expectedResult2); - - // Find all where the average is the same as the integer value itself. - // This returns ALL objects!!! - String queryStrSub3 = - "SELECT FROM " - + clsName - + " WHERE " - + "(select avg(a.optionalInteger) from " - + clsName - + " a " - + " ) == optionalInteger"; - Object[] expectedResult3 = new Object[] {oidPC}; - checkSingleStringQuery(queryStrSub3, expectedResult3); - } - - private void checkSingleStringQuery(String singleStringJDOQL, Object... resultOids) { - ArrayList expectedResults = new ArrayList<>(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - for (int i = 0; i < resultOids.length; i++) { - expectedResults.add(pm.getObjectById(resultOids[i])); - } - } finally { - if (tx.isActive()) tx.rollback(); + + private void checkSingleStringQuery(String singleStringJDOQL, Object ... resultOids) { + ArrayList expectedResults = new ArrayList<>(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + for (int i = 0; i < resultOids.length; i++) { + expectedResults.add(pm.getObjectById(resultOids[i])); + } + } finally { + if (tx.isActive()) + tx.rollback(); + } + + Query singleStringQuery = pm.newQuery(singleStringJDOQL); + executeJDOQuery(ASSERTION_FAILED, singleStringQuery, singleStringJDOQL, + false, null, expectedResults, true); } - Query singleStringQuery = pm.newQuery(singleStringJDOQL); - executeJDOQuery( - ASSERTION_FAILED, singleStringQuery, singleStringJDOQL, false, null, expectedResults, true); - } - - private void checkQuery( - String filter, String paramDecl, Map paramValues, Object[] result) { - QueryElementHolder qeh = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ OptionalSample.class, - /*EXCLUDE*/ null, - /*WHERE*/ filter, - /*VARIABLES*/ null, - /*PARAMETERS*/ paramDecl, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ null, - /*paramValues*/ paramValues); - - ArrayList expectedResults = new ArrayList<>(); - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - for (int i = 0; i < result.length; i++) { - Object o = result[i]; - if (o instanceof String || o instanceof Date || o instanceof Integer) { - expectedResults.add(o); - } else { - expectedResults.add(pm.getObjectById(result[i])); + private void checkQuery(String filter, String paramDecl, Map paramValues, Object[] result) { + QueryElementHolder qeh = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ OptionalSample.class, + /*EXCLUDE*/ null, + /*WHERE*/ filter, + /*VARIABLES*/ null, + /*PARAMETERS*/ paramDecl, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ null, + /*paramValues*/ paramValues); + + ArrayList expectedResults = new ArrayList<>(); + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + for (int i = 0; i < result.length; i++) { + Object o = result[i]; + if (o instanceof String || o instanceof Date || o instanceof Integer) { + expectedResults.add(o); + } else { + expectedResults.add(pm.getObjectById(result[i])); + } + } + } finally { + if (tx.isActive()) { + tx.rollback(); + } } - } - } finally { - if (tx.isActive()) { - tx.rollback(); - } + + executeAPIQuery(ASSERTION_FAILED, qeh, expectedResults); + executeSingleStringQuery(ASSERTION_FAILED, qeh, expectedResults); } - executeAPIQuery(ASSERTION_FAILED, qeh, expectedResults); - executeSingleStringQuery(ASSERTION_FAILED, qeh, expectedResults); - } - /** Result class for queries on OptionalSample. */ - public static class ResultInfo { - public long id; - public String optionalString; + /** + * Result class for queries on OptionalSample. + */ + public static class ResultInfo { + public long id; + public String optionalString; + public ResultInfo() {}; + public ResultInfo(long id, String optionalString) { + this.id = id; + this.optionalString = optionalString; + } + } - public ResultInfo() {} - ; - public ResultInfo(long id, String optionalString) { - this.id = id; - this.optionalString = optionalString; + /** + * Test Optional.orElse() in the SELECT clause of JDOQL queries. + */ + @SuppressWarnings("unchecked") + public void testOrElseInSELECT() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Query q = pm.newQuery("SELECT id, optionalString.orElse('NotPresent') FROM " + + OptionalSample.class.getName()); + q.setResultClass(ResultInfo.class); + Collection c = (Collection) q.execute(); + if (c.size() != 5) { + fail(ASSERTION_FAILED, "Wrong result count: " + c.size()); + } + for (ResultInfo i: c) { + switch ((int)i.id) { + case PC_ID: + if (!STRING.equals(i.optionalString)) { + fail(ASSERTION_FAILED, "Wrong string value: " + i.optionalString); + } + break; + case PC_EMPTY_ID: + case PC_NULL_ID: + case REFERENCED_PC1_ID: + case REFERENCED_PC2_ID: + assertEquals("NotPresent", i.optionalString); + break; + default: fail(ASSERTION_FAILED, "Wrong object id: " + i.id); + } + } + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } } - } - - /** Test Optional.orElse() in the SELECT clause of JDOQL queries. */ - @SuppressWarnings("unchecked") - public void testOrElseInSELECT() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Query q = - pm.newQuery( - "SELECT id, optionalString.orElse('NotPresent') FROM " - + OptionalSample.class.getName()); - q.setResultClass(ResultInfo.class); - Collection c = (Collection) q.execute(); - if (c.size() != 5) { - fail(ASSERTION_FAILED, "Wrong result count: " + c.size()); - } - for (ResultInfo i : c) { - switch ((int) i.id) { - case PC_ID: - if (!STRING.equals(i.optionalString)) { - fail(ASSERTION_FAILED, "Wrong string value: " + i.optionalString); + + + /** + * This test assert that null-references are converted to Optional.empty() when + * loaded from the database. + */ + public void testPersistenceNotNull() { + OptionalSample osNotNull = getOptionalSampleById(oidNull); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + if (osNotNull.getOptionalDate() == null) { + fail(ASSERTION_FAILED, "Date field was 'null'"); + } + if (osNotNull.getOptionalInteger() == null) { + fail(ASSERTION_FAILED, "Integer field was 'null'"); + } + if (osNotNull.getOptionalPC() == null) { + fail(ASSERTION_FAILED, "optionalPC field was 'null'"); + } + if (osNotNull.getOptionalString() == null) { + fail(ASSERTION_FAILED, "String field was 'null'"); + } + + if (osNotNull.getOptionalDate().isPresent()) { + fail(ASSERTION_FAILED, "Date field was present"); + } + if (osNotNull.getOptionalInteger().isPresent()) { + fail(ASSERTION_FAILED, "Integer field was present"); + } + if (osNotNull.getOptionalPC().isPresent()) { + fail(ASSERTION_FAILED, "optionalPC field was present"); + } + if (osNotNull.getOptionalString().isPresent()) { + fail(ASSERTION_FAILED, "String field was present"); + } + } finally { + if (tx.isActive()) { + tx.rollback(); } - break; - case PC_EMPTY_ID: - case PC_NULL_ID: - case REFERENCED_PC1_ID: - case REFERENCED_PC2_ID: - assertEquals("NotPresent", i.optionalString); - break; - default: - fail(ASSERTION_FAILED, "Wrong object id: " + i.id); } - } - } finally { - if (tx.isActive()) { - tx.rollback(); - } } - } - - /** - * This test assert that null-references are converted to Optional.empty() when loaded from the - * database. - */ - public void testPersistenceNotNull() { - OptionalSample osNotNull = getOptionalSampleById(oidNull); - - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - if (osNotNull.getOptionalDate() == null) { - fail(ASSERTION_FAILED, "Date field was 'null'"); - } - if (osNotNull.getOptionalInteger() == null) { - fail(ASSERTION_FAILED, "Integer field was 'null'"); - } - if (osNotNull.getOptionalPC() == null) { - fail(ASSERTION_FAILED, "optionalPC field was 'null'"); - } - if (osNotNull.getOptionalString() == null) { - fail(ASSERTION_FAILED, "String field was 'null'"); - } - - if (osNotNull.getOptionalDate().isPresent()) { - fail(ASSERTION_FAILED, "Date field was present"); - } - if (osNotNull.getOptionalInteger().isPresent()) { - fail(ASSERTION_FAILED, "Integer field was present"); - } - if (osNotNull.getOptionalPC().isPresent()) { - fail(ASSERTION_FAILED, "optionalPC field was present"); - } - if (osNotNull.getOptionalString().isPresent()) { - fail(ASSERTION_FAILED, "String field was present"); - } - } finally { - if (tx.isActive()) { - tx.rollback(); - } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(OptionalSample.class); + insertOptionalSample(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(OptionalSample.class); - insertOptionalSample(getPM()); - } - - private void insertOptionalSample(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - // Create two objects that are referenced by other objects, this allows - // testing of navigation in queries. - // The referencedPC1 will be referenced by 'osPC', - // The referencedPC2 will be referenced by referencedPC1. - OptionalSample referencedPC1 = new OptionalSample(); - referencedPC1.setId(REFERENCED_PC1_ID); - pm.makePersistent(referencedPC1); - oidReferencedPC1 = pm.getObjectId(referencedPC1); - - OptionalSample referencedPC2 = new OptionalSample(); - referencedPC2.setId(REFERENCED_PC2_ID); - pm.makePersistent(referencedPC2); - oidReferencedPC2 = pm.getObjectId(referencedPC2); - - referencedPC1.setOptionalPC(Optional.of(referencedPC2)); - - OptionalSample osPC = new OptionalSample(); - osPC.setId(PC_ID); - osPC.setOptionalPC(Optional.of(referencedPC1)); - osPC.setOptionalDate(Optional.of(DATE)); - osPC.setOptionalInteger(Optional.of(INTEGER)); - osPC.setOptionalString(Optional.of(STRING)); - pm.makePersistent(osPC); - oidPC = pm.getObjectId(osPC); - - // use empty optionals - OptionalSample osEmpty = new OptionalSample(); - osEmpty.setId(PC_EMPTY_ID); - osEmpty.setOptionalPC(Optional.empty()); - osEmpty.setOptionalDate(Optional.empty()); - osEmpty.setOptionalInteger(Optional.empty()); - osEmpty.setOptionalString(Optional.empty()); - pm.makePersistent(osEmpty); - oidEmpty = pm.getObjectId(osEmpty); - - // use null for optional fields - OptionalSample osNull = new OptionalSample(); - osNull.setId(PC_NULL_ID); - osNull.setOptionalPC(null); - osNull.setOptionalDate(null); - osNull.setOptionalInteger(null); - osNull.setOptionalString(null); - pm.makePersistent(osNull); - oidNull = pm.getObjectId(osNull); - - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } + + + private void insertOptionalSample(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + //Create two objects that are referenced by other objects, this allows + //testing of navigation in queries. + //The referencedPC1 will be referenced by 'osPC', + //The referencedPC2 will be referenced by referencedPC1. + OptionalSample referencedPC1 = new OptionalSample(); + referencedPC1.setId(REFERENCED_PC1_ID); + pm.makePersistent(referencedPC1); + oidReferencedPC1 = pm.getObjectId(referencedPC1); + + OptionalSample referencedPC2 = new OptionalSample(); + referencedPC2.setId(REFERENCED_PC2_ID); + pm.makePersistent(referencedPC2); + oidReferencedPC2 = pm.getObjectId(referencedPC2); + + referencedPC1.setOptionalPC(Optional.of(referencedPC2)); + + OptionalSample osPC = new OptionalSample(); + osPC.setId(PC_ID); + osPC.setOptionalPC(Optional.of(referencedPC1)); + osPC.setOptionalDate(Optional.of(DATE)); + osPC.setOptionalInteger(Optional.of(INTEGER)); + osPC.setOptionalString(Optional.of(STRING)); + pm.makePersistent(osPC); + oidPC = pm.getObjectId(osPC); + + //use empty optionals + OptionalSample osEmpty = new OptionalSample(); + osEmpty.setId(PC_EMPTY_ID); + osEmpty.setOptionalPC(Optional.empty()); + osEmpty.setOptionalDate(Optional.empty()); + osEmpty.setOptionalInteger(Optional.empty()); + osEmpty.setOptionalString(Optional.empty()); + pm.makePersistent(osEmpty); + oidEmpty = pm.getObjectId(osEmpty); + + //use null for optional fields + OptionalSample osNull = new OptionalSample(); + osNull.setId(PC_NULL_ID); + osNull.setOptionalPC(null); + osNull.setOptionalDate(null); + osNull.setOptionalInteger(null); + osNull.setOptionalString(null); + pm.makePersistent(osNull); + oidNull = pm.getObjectId(osNull); + + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } } - } - - @Override - protected void localTearDown() { - // set all references to null to allow deletion of (otherwise) referenced objects - Transaction tx = getPM().currentTransaction(); - tx.begin(); - Query q = pm.newQuery(OptionalSample.class); - for (OptionalSample os : q.executeList()) { - os.setOptionalPC(Optional.empty()); + + @Override + protected void localTearDown() { + //set all references to null to allow deletion of (otherwise) referenced objects + Transaction tx = getPM().currentTransaction(); + tx.begin(); + Query q = pm.newQuery(OptionalSample.class); + for (OptionalSample os: q.executeList()) { + os.setOptionalPC(Optional.empty()); + } + tx.commit(); + + super.localTearDown(); } - tx.commit(); - super.localTearDown(); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedStringMethods.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedStringMethods.java index 6cfab2f5f..4364311e6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedStringMethods.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedStringMethods.java @@ -5,19 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql.methods; -import javax.jdo.JDOQLTypedQuery; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.Person; @@ -27,529 +27,511 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Supported String methods.
    - * Keywords: query
    - * Assertion ID: A14.6.2-47.
    - * Assertion Description: New supported String methods: - * + *Title: Supported String methods. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-47. + *
    + *Assertion Description: + * New supported String methods: *
      - *
    • toLowerCase() - *
    • toUpperCase() - *
    • indexOf(String) - *
    • indexOf(String, int) - *
    • matches(String) - *
    • substring(int) - *
    • substring(int, int) - *
    • startsWith(String) - *
    • endsWith(String) - *
    • charAt(int) - *
    • startsWith(String, int) - *
    • length() - *
    • trim() + *
    • toLowerCase() + *
    • toUpperCase() + *
    • indexOf(String) + *
    • indexOf(String, int) + *
    • matches(String) + *
    • substring(int) + *
    • substring(int, int) + *
    • startsWith(String) + *
    • endsWith(String) + *
    • charAt(int) + *
    • startsWith(String, int) + *
    • length() + *
    • trim() *
    */ public class SupportedStringMethods extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-47 (SupportedStringMethods) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SupportedStringMethods.class); - } - - /** */ - public void testToLowerCase() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.firstname.toLowerCase().eq("emp1first")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname.toLowerCase() == 'emp1first'", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testToUpperCase() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.firstname.toUpperCase().eq("EMP1FIRST")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname.toUpperCase() == 'EMP1FIRST'", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testIndexOfString() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - query.filter(cand.name.indexOf("e").eq(1)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "name.indexOf('e') == 1", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testIndexOfStringInt() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - query.filter(cand.name.indexOf("e", 2).eq(3)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "name.indexOf('e', 2) == 3", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testMatches1() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.firstname.matches(".*First")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname.matches('.*First')", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testMatches2() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.firstname.matches("emp.First")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname.matches('emp.First')", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - /** */ - public void testMatches3() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.firstname.matches("(?i)EMP1FIRST")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname.matches('(?i)EMP1FIRST')", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testSubstringInt() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.firstname.substring(4).eq("First")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname.substring(4) == 'First'", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testSubstringIntInt() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.firstname.substring(4, 9).eq("First")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname.substring(4,9) == 'First'", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testStartsWith() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.firstname.startsWith("emp")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname.startsWith('emp')", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testEndsWith() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.firstname.endsWith("First")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname.endsWith('First')", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testStartsWithIndexed() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.firstname.startsWith("mp", 1)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname.startsWith('mp', 1)", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testLength() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.firstname.length().eq(9)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname.length() == 9", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testCharAt() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.firstname.charAt(3).eq('1')); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname.charAt(3) == '1'", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testTrim() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.firstname.trim().eq("emp1First")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname.trim() == 'emp1First'", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-47 (SupportedStringMethods) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SupportedStringMethods.class); + } + + /** */ + public void testToLowerCase() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.firstname.toLowerCase().eq("emp1first")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname.toLowerCase() == 'emp1first'", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testToUpperCase() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.firstname.toUpperCase().eq("EMP1FIRST")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname.toUpperCase() == 'EMP1FIRST'", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testIndexOfString() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"dept1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + query.filter(cand.name.indexOf("e").eq(1)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "name.indexOf('e') == 1", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testIndexOfStringInt() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"dept1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + query.filter(cand.name.indexOf("e", 2).eq(3)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "name.indexOf('e', 2) == 3", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testMatches1() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.firstname.matches(".*First")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname.matches('.*First')", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testMatches2() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.firstname.matches("emp.First")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname.matches('emp.First')", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + /** */ + public void testMatches3() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.firstname.matches("(?i)EMP1FIRST")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname.matches('(?i)EMP1FIRST')", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testSubstringInt() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.firstname.substring(4).eq("First")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname.substring(4) == 'First'", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testSubstringIntInt() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.firstname.substring(4,9).eq("First")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname.substring(4,9) == 'First'", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testStartsWith() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.firstname.startsWith("emp")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname.startsWith('emp')", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testEndsWith() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.firstname.endsWith("First")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname.endsWith('First')", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testStartsWithIndexed() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.firstname.startsWith("mp", 1)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname.startsWith('mp', 1)", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testLength() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.firstname.length().eq(9)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname.length() == 9", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testCharAt() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.firstname.charAt(3).eq('1')); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname.charAt(3) == '1'", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testTrim() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.firstname.trim().eq("emp1First")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname.trim() == 'emp1First'", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedTimeMethods.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedTimeMethods.java index 42871a9f6..17ca63a0f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedTimeMethods.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedTimeMethods.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,153 +20,167 @@ import java.sql.Time; import java.util.ArrayList; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.query.TimeSample; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Supported Time methods.
    - * Keywords: query
    - * Assertion ID: A14.6.2-47.
    - * Assertion Description: New supported Time methods: - * + *Title: Supported Time methods. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-47. + *
    + *Assertion Description: + * New supported Time methods: *
      - *
    • getHour() - *
    • getMinute() - *
    • getSecond() + *
    • getHour()
    • + *
    • getMinute()
    • + *
    • getSecond()
    • *
    */ public class SupportedTimeMethods extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-47 (SupportedTimeMethods) failed: "; - - /** */ - private Object oidOfTime1; - - /** */ - private Object oidOfTime2; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SupportedTimeMethods.class); - } - - /** */ - @SuppressWarnings("unchecked") - public void testHour() { - final String filter = "time.getHour() == 10"; - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Collection expectedResult = new ArrayList(); - expectedResult.add(pm.getObjectById(oidOfTime1)); - - Query q = pm.newQuery(); - q.setClass(TimeSample.class); - q.setFilter(filter); - Collection results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-47 (SupportedTimeMethods) failed: "; + + /** */ + private Object oidOfTime1; + + /** */ + private Object oidOfTime2; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SupportedTimeMethods.class); + } + + /** */ + @SuppressWarnings("unchecked") + public void testHour() { + final String filter = "time.getHour() == 10"; + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Collection expectedResult = new ArrayList(); + expectedResult.add(pm.getObjectById(oidOfTime1)); + + Query q = pm.newQuery(); + q.setClass(TimeSample.class); + q.setFilter(filter); + Collection results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** */ + @SuppressWarnings("unchecked") + public void testMinute() { + final String filter = "time.getMinute() == 15"; + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Collection expectedResult = new ArrayList(); + expectedResult.add(pm.getObjectById(oidOfTime2)); + + Query q = pm.newQuery(); + q.setClass(TimeSample.class); + q.setFilter(filter); + Collection results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - @SuppressWarnings("unchecked") - public void testMinute() { - final String filter = "time.getMinute() == 15"; - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Collection expectedResult = new ArrayList(); - expectedResult.add(pm.getObjectById(oidOfTime2)); - - Query q = pm.newQuery(); - q.setClass(TimeSample.class); - q.setFilter(filter); - Collection results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + @SuppressWarnings("unchecked") + public void testSecond() { + final String filter = "time.getSecond() == 45"; + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Collection expectedResult = new ArrayList(); + expectedResult.add(pm.getObjectById(oidOfTime2)); + + Query q = pm.newQuery(); + q.setClass(TimeSample.class); + q.setFilter(filter); + Collection results = (Collection)q.execute(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - @SuppressWarnings("unchecked") - public void testSecond() { - final String filter = "time.getSecond() == 45"; - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Collection expectedResult = new ArrayList(); - expectedResult.add(pm.getObjectById(oidOfTime2)); - - Query q = pm.newQuery(); - q.setClass(TimeSample.class); - q.setFilter(filter); - Collection results = (Collection) q.execute(); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(TimeSample.class); + insertTimeSampleData(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(TimeSample.class); - insertTimeSampleData(getPM()); - } - - /** */ - @SuppressWarnings("deprecation") - private void insertTimeSampleData(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - TimeSample ts1 = new TimeSample(); - ts1.setId(1); - Time time = new Time(0); - time.setHours(10); - time.setMinutes(0); - time.setSeconds(0); - ts1.setTime(time); - pm.makePersistent(ts1); - - TimeSample ts2 = new TimeSample(); - ts2.setId(2); - Time time2 = new Time(0); - time2.setHours(16); - time2.setMinutes(15); - time2.setSeconds(45); - ts2.setTime(time2); - pm.makePersistent(ts2); - tx.commit(); - oidOfTime1 = pm.getObjectId(ts1); - oidOfTime2 = pm.getObjectId(ts2); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + @SuppressWarnings("deprecation") + private void insertTimeSampleData(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + TimeSample ts1 = new TimeSample(); + ts1.setId(1); + Time time = new Time(0); + time.setHours(10); + time.setMinutes(0); + time.setSeconds(0); + ts1.setTime(time); + pm.makePersistent(ts1); + + TimeSample ts2 = new TimeSample(); + ts2.setId(2); + Time time2 = new Time(0); + time2.setHours(16); + time2.setMinutes(15); + time2.setSeconds(45); + ts2.setTime(time2); + pm.makePersistent(ts2); + tx.commit(); + oidOfTime1 = pm.getObjectId(ts1); + oidOfTime2 = pm.getObjectId(ts2); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BinaryAddition.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BinaryAddition.java index 3b7c12993..e407ef5a0 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BinaryAddition.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BinaryAddition.java @@ -5,96 +5,118 @@ * 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 + * + * 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.jdo.tck.query.jdoql.operators; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Binary Addition Query Operator
    - * Keywords: query
    - * Assertion ID: A14.6.2-26.
    - * Assertion Description: The binary addition operator (+) is supported for all - * types as they are defined in the Java language. This includes the following types: - * - *
      - *
    • byte, short, int, long, char, Byte, Short Integer, Long, Character - *
    • float, double, Float, Double - *
    • BigDecimal, BigInteger - *
    - * - * The operation on object-valued fields of wrapper types ( - * Boolean, Byte, Short, Integer, Long, Float, and Double), and numeric types ( - * BigDecimal and BigInteger) use the wrapped values as operands. + *Title: Binary Addition Query Operator + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-26. + *
    + *Assertion Description: The binary addition operator (+) is supported for all types as they are defined in the Java language. This includes the following types: +
      +
    • byte, short, int, long, char, Byte, Short Integer, Long, Character
    • +
    • float, double, Float, Double
    • +
    • BigDecimal, BigInteger
    • +
    +The operation on object-valued fields of wrapper types (Boolean, Byte, Short, Integer, Long, Float, and Double), and numeric types (BigDecimal and BigInteger) use the wrapped values as operands. */ -public class BinaryAddition extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.2-26 (BinaryAddition) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(BinaryAddition.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - if (debug) logger.debug("\nExecuting test BinaryAddition() ..."); +public class BinaryAddition extends QueryTest { - Transaction tx = pm.currentTransaction(); - tx.begin(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-26 (BinaryAddition) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(BinaryAddition.class); + } - Collection instance9 = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 9").execute(); - Collection allOddInstances = - (Collection) pm.newQuery(PrimitiveTypes.class, "booleanNull").execute(); + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + if (debug) logger.debug("\nExecuting test BinaryAddition() ..."); - runSimplePrimitiveTypesQuery("id + 1 == 10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("byteNotNull + 1 == 10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("shortNotNull + 1 == 10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("intNotNull + 1 == 10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("longNotNull + 1 == 10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("floatNotNull + 1 == 10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("doubleNotNull + 1 == 10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("byteNull + 1 == 10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("shortNull + 1 == 10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("intNull + 1 == 10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("longNull + 1 == 10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("floatNull + 1 == 10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("doubleNull + 1 == 10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("bigDecimal + 1 == 10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("bigInteger + 1 == 10", pm, instance9, ASSERTION_FAILED); + Transaction tx = pm.currentTransaction(); + tx.begin(); + + Collection instance9 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 9").execute(); + Collection allOddInstances = (Collection)pm.newQuery( + PrimitiveTypes.class, "booleanNull").execute(); + + runSimplePrimitiveTypesQuery("id + 1 == 10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("byteNotNull + 1 == 10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("shortNotNull + 1 == 10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("intNotNull + 1 == 10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("longNotNull + 1 == 10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("floatNotNull + 1 == 10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("doubleNotNull + 1 == 10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("byteNull + 1 == 10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("shortNull + 1 == 10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("intNull + 1 == 10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("longNull + 1 == 10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("floatNull + 1 == 10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("doubleNull + 1 == 10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("bigDecimal + 1 == 10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("bigInteger + 1 == 10", + pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("charNull + 1 == 'P'", pm, allOddInstances, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("charNotNull + 1 == 'P'", pm, allOddInstances, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("charNull + 1 == 'P'", + pm, allOddInstances, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("charNotNull + 1 == 'P'", + pm, allOddInstances, ASSERTION_FAILED); - tx.commit(); - } + tx.commit(); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PrimitiveTypes.class); - loadAndPersistPrimitiveTypes(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PrimitiveTypes.class); + loadAndPersistPrimitiveTypes(getPM()); + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BinarySubtraction.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BinarySubtraction.java index 6a18baaa9..75861d0a4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BinarySubtraction.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BinarySubtraction.java @@ -5,97 +5,123 @@ * 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 + * + * 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.jdo.tck.query.jdoql.operators; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Binary Subtraction Query Operator
    - * Keywords: query
    - * Assertion ID: A14.6.2-28.
    - * Assertion Description: The binary subtraction operator (-) is supported for - * all types as they are defined in the Java language. This includes the following types: - * - *
      - *
    • byte, short, int, long, char, Byte, Short Integer, Long, Character - *
    • float, double, Float, Double - *
    • BigDecimal, BigInteger - *
    - * - * The operation on object-valued fields of wrapper types (Boolean, Byte, - * Short, Integer, Long, Float, and Double), and numeric types (BigDecimal - * and BigInteger) use the wrapped values as operands. - */ -public class BinarySubtraction extends QueryTest { + *Title: Binary Subtraction Query Operator + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-28. + *
    + *Assertion Description: +The binary subtraction operator (-) is supported for all types as +they are defined in the Java language. This includes the following types: +
      +
    • byte, short, int, long, char, Byte, Short Integer, Long, Character
    • +
    • float, double, Float, Double
    • +
    • BigDecimal, BigInteger
    • +
    +The operation on object-valued fields of wrapper types (Boolean, Byte, +Short, Integer, Long, Float, and Double), and numeric types +(BigDecimal and BigInteger) +use the wrapped values as operands. - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-28 (BinarySubtraction) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(BinarySubtraction.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - if (debug) logger.debug("\nExecuting test BinarySubtraction() ..."); + */ - Transaction tx = pm.currentTransaction(); - tx.begin(); +public class BinarySubtraction extends QueryTest { - Collection instance9 = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 9").execute(); - Collection allOddInstances = - (Collection) pm.newQuery(PrimitiveTypes.class, "booleanNull").execute(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-28 (BinarySubtraction) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(BinarySubtraction.class); + } + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + if (debug) logger.debug("\nExecuting test BinarySubtraction() ..."); - runSimplePrimitiveTypesQuery("id - 1 == 8", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("byteNotNull - 1 == 8", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("shortNotNull - 1 == 8", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("intNotNull - 1 == 8", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("longNotNull - 1 == 8", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("floatNotNull - 1 == 8", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("doubleNotNull - 1 == 8", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("byteNull - 1 == 8", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("shortNull - 1 == 8", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("intNull - 1 == 8", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("longNull - 1 == 8", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("floatNull - 1 == 8", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("doubleNull - 1 == 8", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("bigDecimal - 1 == 8", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("bigInteger - 1 == 8", pm, instance9, ASSERTION_FAILED); + Transaction tx = pm.currentTransaction(); + tx.begin(); + + Collection instance9 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 9").execute(); + Collection allOddInstances = (Collection)pm.newQuery( + PrimitiveTypes.class, "booleanNull").execute(); + + runSimplePrimitiveTypesQuery("id - 1 == 8", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("byteNotNull - 1 == 8", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("shortNotNull - 1 == 8", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("intNotNull - 1 == 8", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("longNotNull - 1 == 8", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("floatNotNull - 1 == 8", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("doubleNotNull - 1 == 8", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("byteNull - 1 == 8", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("shortNull - 1 == 8", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("intNull - 1 == 8", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("longNull - 1 == 8", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("floatNull - 1 == 8", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("doubleNull - 1 == 8", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("bigDecimal - 1 == 8", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("bigInteger - 1 == 8", + pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("charNull - 1 == 'N'", pm, allOddInstances, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("charNotNull - 1 == 'N'", pm, allOddInstances, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("charNull - 1 == 'N'", + pm, allOddInstances, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("charNotNull - 1 == 'N'", + pm, allOddInstances, ASSERTION_FAILED); - tx.commit(); - } + tx.commit(); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PrimitiveTypes.class); - loadAndPersistPrimitiveTypes(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PrimitiveTypes.class); + loadAndPersistPrimitiveTypes(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BitwiseBinaryOperators.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BitwiseBinaryOperators.java index ee2c6ad56..e4cc83510 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BitwiseBinaryOperators.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BitwiseBinaryOperators.java @@ -17,246 +17,261 @@ package org.apache.jdo.tck.query.jdoql.operators; -import java.util.List; +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; +import org.apache.jdo.tck.query.QueryTest; +import org.apache.jdo.tck.util.BatchTestRunner; + import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; -import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; -import org.apache.jdo.tck.query.QueryTest; -import org.apache.jdo.tck.util.BatchTestRunner; +import java.util.List; /** - * Title: Bitwise Binary Query Operators
    - * Keywords: query
    - * Assertion ID: A14.6.2-20 and A14.6.2-22.
    - * Assertion Description: A JDO implementation including - * javax.jdo.query.JDOQL.bitwiseOperations in the result of PMF.supportedOptions() supports JDOQL - * queries that contain bitwise operations. Then the integral binary bitwise operators ( - * ampersand and | and ^) are supported for the following types: - * - *
      - *
    • byte, short, int, long, Byte, Short Integer, Long - *
    + *Title: Bitwise Binary Query Operators + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-20 and A14.6.2-22. + *
    + *Assertion Description: + A JDO implementation including javax.jdo.query.JDOQL.bitwiseOperations in the result of + PMF.supportedOptions() supports JDOQL queries that contain bitwise operations. + Then the integral binary bitwise operators (ampersand and | and ^) are supported + for the following types: +
      +
    • byte, short, int, long, Byte, Short Integer, Long
    • +
    */ public class BitwiseBinaryOperators extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-20 and A14.6.2-22 (BitwiseBinaryOperators) failed: "; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-20 and A14.6.2-22 (BitwiseBinaryOperators) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(BitwiseBinaryOperators.class); - } + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(BitwiseBinaryOperators.class); + } - /** Testing bitwise AND */ - public void testBitwiseAndPositive() { - if (isBitwiseOperationsSupported()) { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); + /** + * Testing bitwise AND + */ + public void testBitwiseAndPositive() { + if (isBitwiseOperationsSupported()) { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); - // Expected result - List expected = - pm.newQuery(PrimitiveTypes.class, "4 <= id && id <= 7").executeList(); + // Expected result + List expected = pm.newQuery(PrimitiveTypes.class, "4 <= id && id <= 7").executeList(); - runSimplePrimitiveTypesQuery("(byteNotNull & 4) != 0", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(byteNull & 4) != 0", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(shortNotNull & 4) != 0", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(shortNull & 4) != 0", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(intNotNull & 4) != 0", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(intNull & 4) != 0", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(longNotNull & 4) != 0", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(longNull & 4) != 0", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(byteNotNull & 4) != 0", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(byteNull & 4) != 0", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(shortNotNull & 4) != 0", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(shortNull & 4) != 0", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(intNotNull & 4) != 0", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(intNull & 4) != 0", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(longNotNull & 4) != 0", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(longNull & 4) != 0", pm, expected, ASSERTION_FAILED); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); - } + tx.commit(); + tx = null; + } finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } } - } - /** Testing bitwise OR */ - public void testBitwiseOrPositive() { - if (isBitwiseOperationsSupported()) { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); + /** + * Testing bitwise OR + */ + public void testBitwiseOrPositive() { + if (isBitwiseOperationsSupported()) { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); - // Expected result - List expected = - pm.newQuery(PrimitiveTypes.class, "4 <= id && id <= 7").executeList(); + // Expected result + List expected = pm.newQuery(PrimitiveTypes.class, "4 <= id && id <= 7").executeList(); - runSimplePrimitiveTypesQuery("(byteNotNull | 3) == 7", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(byteNull | 3) == 7", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(shortNotNull | 3) == 7", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(shortNull | 3) == 7", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(intNotNull | 3) == 7", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(intNull | 3) == 7", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(longNotNull | 3) == 7", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(longNull | 3) == 7", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(byteNotNull | 3) == 7", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(byteNull | 3) == 7", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(shortNotNull | 3) == 7", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(shortNull | 3) == 7", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(intNotNull | 3) == 7", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(intNull | 3) == 7", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(longNotNull | 3) == 7", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(longNull | 3) == 7", pm, expected, ASSERTION_FAILED); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); - } + tx.commit(); + tx = null; + } finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } } - } + + /** + * Testing bitwise XOR + */ + public void testBitwiseXOrPositive() { + if (isBitwiseOperationsSupported()) { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); - /** Testing bitwise XOR */ - public void testBitwiseXOrPositive() { - if (isBitwiseOperationsSupported()) { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - // Expected result - List expected = pm.newQuery(PrimitiveTypes.class, "id == 1").executeList(); + // Expected result + List expected = pm.newQuery(PrimitiveTypes.class, "id == 1").executeList(); - runSimplePrimitiveTypesQuery("(byteNotNull ^ 1) == 0", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(byteNull ^ 1) == 0", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(shortNotNull ^ 1) == 0", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(shortNull ^ 1) == 0", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(intNotNull ^ 1) == 0", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(intNull ^ 1) == 0", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(longNotNull ^ 1) == 0", pm, expected, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("(longNull ^ 1) == 0", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(byteNotNull ^ 1) == 0", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(byteNull ^ 1) == 0", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(shortNotNull ^ 1) == 0", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(shortNull ^ 1) == 0", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(intNotNull ^ 1) == 0", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(intNull ^ 1) == 0", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(longNotNull ^ 1) == 0", pm, expected, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("(longNull ^ 1) == 0", pm, expected, ASSERTION_FAILED); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); - } + tx.commit(); + tx = null; + } finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } } - } - /** Queries using bitwise AND that should result in a JDOException. */ - public void testBitwiseAndNegative() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); + /** + * Queries using bitwise AND that should result in a JDOException. + */ + public void testBitwiseAndNegative() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); - try { - Query q = pm.newQuery(PrimitiveTypes.class, "stringNull & stringNull == stringNull"); - Object result = q.execute(); - fail( - ASSERTION_FAILED, - "Query using & operator for non-supported types should throw JDOUserException."); - } catch (JDOUserException ex) { - // expected exception - if (debug) { - logger.debug("expected exception: " + ex); - } - } + try { + Query q = pm.newQuery(PrimitiveTypes.class, "stringNull & stringNull == stringNull"); + Object result = q.execute(); + fail(ASSERTION_FAILED, + "Query using & operator for non-supported types should throw JDOUserException."); + } + catch (JDOUserException ex) { + // expected exception + if (debug) { + logger.debug("expected exception: " + ex); + } + } - if (!isBitwiseOperationsSupported()) { - try { - Query q = pm.newQuery(PrimitiveTypes.class, "(intNotNull & 4) > 0"); - Object result = q.execute(); - fail( - ASSERTION_FAILED, - "Query using & operator for non-supported types should throw JDOUserException."); - } catch (JDOUserException ex) { - // expected exception - if (debug) { - logger.debug("expected exception: " + ex); + if (!isBitwiseOperationsSupported()) { + try { + Query q = pm.newQuery(PrimitiveTypes.class, "(intNotNull & 4) > 0"); + Object result = q.execute(); + fail(ASSERTION_FAILED, + "Query using & operator for non-supported types should throw JDOUserException."); + } catch (JDOUserException ex) { + // expected exception + if (debug) { + logger.debug("expected exception: " + ex); + } + } } - } - } - tx.commit(); - } + tx.commit(); + } - /** Queries using bitwise AND that should result in a JDOException. */ - public void testBitwiseOrNegative() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); + /** + * Queries using bitwise AND that should result in a JDOException. + */ + public void testBitwiseOrNegative() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); - try { - Query q = pm.newQuery(PrimitiveTypes.class, "stringNull | stringNull == stringNull"); - Object result = q.execute(); - fail( - ASSERTION_FAILED, - "Query using | operator for non-supported types should throw JDOUserException."); - } catch (JDOUserException ex) { - // expected exception - if (debug) { - logger.debug("expected exception: " + ex); - } - } + try { + Query q = pm.newQuery(PrimitiveTypes.class, "stringNull | stringNull == stringNull"); + Object result = q.execute(); + fail(ASSERTION_FAILED, + "Query using | operator for non-supported types should throw JDOUserException."); + } + catch (JDOUserException ex) { + // expected exception + if (debug) { + logger.debug("expected exception: " + ex); + } + } - if (!isBitwiseOperationsSupported()) { - try { - Query q = pm.newQuery(PrimitiveTypes.class, "(intNotNull | 3) == 7"); - Object result = q.execute(); - fail( - ASSERTION_FAILED, - "Query using & operator for non-supported types should throw JDOUserException."); - } catch (JDOUserException ex) { - // expected exception - if (debug) { - logger.debug("expected exception: " + ex); + if (!isBitwiseOperationsSupported()) { + try { + Query q = pm.newQuery(PrimitiveTypes.class, "(intNotNull | 3) == 7"); + Object result = q.execute(); + fail(ASSERTION_FAILED, + "Query using & operator for non-supported types should throw JDOUserException."); + } catch (JDOUserException ex) { + // expected exception + if (debug) { + logger.debug("expected exception: " + ex); + } + } } - } - } - tx.commit(); - } + tx.commit(); + } - /** Queries using bitwise AND that should result in a JDOException. */ - public void testBitwiseXOrNegative() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); + /** + * Queries using bitwise AND that should result in a JDOException. + */ + public void testBitwiseXOrNegative() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); - try { - Query q = pm.newQuery(PrimitiveTypes.class, "stringNull ^ stringNul == stringNull"); - Object result = q.execute(); - fail( - ASSERTION_FAILED, - "Query using & operator for non-supported types should throw JDOUserException."); - } catch (JDOUserException ex) { - // expected exception - if (debug) { - logger.debug("expected exception: " + ex); - } - } + try { + Query q = pm.newQuery(PrimitiveTypes.class, "stringNull ^ stringNul == stringNull"); + Object result = q.execute(); + fail(ASSERTION_FAILED, + "Query using & operator for non-supported types should throw JDOUserException."); + } + catch (JDOUserException ex) { + // expected exception + if (debug) { + logger.debug("expected exception: " + ex); + } + } - if (!isBitwiseOperationsSupported()) { - try { - Query q = pm.newQuery(PrimitiveTypes.class, "(intNotNull ^ 1) == 0"); - Object result = q.execute(); - fail( - ASSERTION_FAILED, - "Query using & operator for non-supported types should throw JDOUserException."); - } catch (JDOUserException ex) { - // expected exception - if (debug) { - logger.debug("expected exception: " + ex); + if (!isBitwiseOperationsSupported()) { + try { + Query q = pm.newQuery(PrimitiveTypes.class, "(intNotNull ^ 1) == 0"); + Object result = q.execute(); + fail(ASSERTION_FAILED, + "Query using & operator for non-supported types should throw JDOUserException."); + } catch (JDOUserException ex) { + // expected exception + if (debug) { + logger.debug("expected exception: " + ex); + } + } } - } - } - tx.commit(); - } + tx.commit(); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PrimitiveTypes.class); - loadAndPersistPrimitiveTypes(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PrimitiveTypes.class); + loadAndPersistPrimitiveTypes(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BitwiseComplement.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BitwiseComplement.java index 1ae75be99..98af4d816 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BitwiseComplement.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BitwiseComplement.java @@ -5,83 +5,104 @@ * 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 + * + * 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.jdo.tck.query.jdoql.operators; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Bitwise Complement Query Operator
    - * Keywords: query
    - * Assertion ID: A14.6.2-24.
    - * Assertion Description: The integral unary bitwise complement operator (~) is - * supported for all types as they are defined in the Java language. This includes the following - * types: - * - *
      - *
    • byte, short, int, long, char, Byte, Short Integer, Long, Character - *
    - */ -public class BitwiseComplement extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-24 (BitwiseComplement) failed: "; + *Title: Bitwise Complement Query Operator + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-24. + *
    + *Assertion Description: +The integral unary bitwise complement operator (~) is supported +for all types as they are defined in the Java language. +This includes the following types: +
      +
    • byte, short, int, long, char, Byte, Short Integer, Long, Character
    • +
    - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(BitwiseComplement.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - - Collection instance9 = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 9").execute(); - Collection allOddInstances = - (Collection) pm.newQuery(PrimitiveTypes.class, "booleanNull").execute(); + */ - runSimplePrimitiveTypesQuery("~id == -10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("~byteNotNull == -10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("~shortNotNull == -10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("~intNotNull == -10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("~longNotNull == -10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("~byteNull == -10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("~shortNull == -10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("~intNull == -10", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("~longNull == -10", pm, instance9, ASSERTION_FAILED); +public class BitwiseComplement extends QueryTest { - runSimplePrimitiveTypesQuery("~charNull == -80", pm, allOddInstances, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("~charNotNull == -80", pm, allOddInstances, ASSERTION_FAILED); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-24 (BitwiseComplement) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(BitwiseComplement.class); + } + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + + Collection instance9 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 9").execute(); + Collection allOddInstances = (Collection)pm.newQuery( + PrimitiveTypes.class, "booleanNull").execute(); + + runSimplePrimitiveTypesQuery("~id == -10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("~byteNotNull == -10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("~shortNotNull == -10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("~intNotNull == -10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("~longNotNull == -10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("~byteNull == -10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("~shortNull == -10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("~intNull == -10", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("~longNull == -10", + pm, instance9, ASSERTION_FAILED); + - tx.commit(); - } + runSimplePrimitiveTypesQuery("~charNull == -80", + pm, allOddInstances, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("~charNotNull == -80", + pm, allOddInstances, ASSERTION_FAILED); + + tx.commit(); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PrimitiveTypes.class); - loadAndPersistPrimitiveTypes(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PrimitiveTypes.class); + loadAndPersistPrimitiveTypes(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BooleanLogicalAND.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BooleanLogicalAND.java index a8467a545..656edcc69 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BooleanLogicalAND.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BooleanLogicalAND.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,98 +19,119 @@ import java.util.Collection; import java.util.HashSet; + +import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; +import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Boolean Logical AND Query Operator
    - * Keywords: query
    - * Assertion ID: A14.6.2-20.
    - * Assertion Description: The Boolean logical AND (not bitwise) operator (& - * ) is supported for all types as they are defined in the Java language. This includes the - * following types: - * - *
      - *
    • Boolean, boolean - *
    + *Title: Boolean Logical AND Query Operator + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-20. + *
    + *Assertion Description: +The Boolean logical AND (not bitwise) operator (&) is supported +for all types as they are defined in the Java language. +This includes the following types: +
      +
    • Boolean, boolean
    • +
    */ + public class BooleanLogicalAND extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-20 (BooleanLogicalAND) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(BooleanLogicalAND.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - if (debug) logger.debug("\nExecuting positive test BooleanLogicalAND() ..."); - - Transaction tx = pm.currentTransaction(); - tx.begin(); - - Collection instance9 = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 9").execute(); - Collection allOddInstances = - (Collection) pm.newQuery(PrimitiveTypes.class, "booleanNull").execute(); - Collection allInstances = (Collection) pm.newQuery(PrimitiveTypes.class, "true").execute(); - Collection empty = new HashSet(); - - // case true & true - runSimplePrimitiveTypesQuery("true & true", pm, allInstances, ASSERTION_FAILED); - - // case true & false - runSimplePrimitiveTypesQuery("true & false", pm, empty, ASSERTION_FAILED); - - // case false & true - runSimplePrimitiveTypesQuery("false & true", pm, empty, ASSERTION_FAILED); - - // case false & false - runSimplePrimitiveTypesQuery("false & false", pm, empty, ASSERTION_FAILED); - - // case boolean & boolean - runSimplePrimitiveTypesQuery( - "intNotNull == 9 & booleanNotNull", pm, instance9, ASSERTION_FAILED); - - // case boolean & Boolean - runSimplePrimitiveTypesQuery("intNotNull == 9 & booleanNull", pm, instance9, ASSERTION_FAILED); - // case Boolean & boolean - runSimplePrimitiveTypesQuery("booleanNull & intNotNull == 9", pm, instance9, ASSERTION_FAILED); - // case Boolean & Boolean - runSimplePrimitiveTypesQuery( - "booleanNull & booleanNull", pm, allOddInstances, ASSERTION_FAILED); - - // case Boolean parameter - runParameterPrimitiveTypesQuery( - "param & id == 9", "Boolean param", Boolean.TRUE, pm, instance9, ASSERTION_FAILED); - runParameterPrimitiveTypesQuery( - "param & id == 9", "Boolean param", Boolean.FALSE, pm, empty, ASSERTION_FAILED); - - // case boolean parameter - runParameterPrimitiveTypesQuery( - "param & id == 9", "boolean param", Boolean.TRUE, pm, instance9, ASSERTION_FAILED); - runParameterPrimitiveTypesQuery( - "param & id == 9", "boolean param", Boolean.FALSE, pm, empty, ASSERTION_FAILED); - - tx.commit(); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PrimitiveTypes.class); - loadAndPersistPrimitiveTypes(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-20 (BooleanLogicalAND) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(BooleanLogicalAND.class); + } + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + if (debug) logger.debug("\nExecuting positive test BooleanLogicalAND() ..."); + + Transaction tx = pm.currentTransaction(); + tx.begin(); + + Collection instance9 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 9").execute(); + Collection allOddInstances = (Collection)pm.newQuery( + PrimitiveTypes.class, "booleanNull").execute(); + Collection allInstances = (Collection)pm.newQuery( + PrimitiveTypes.class, "true").execute(); + Collection empty = new HashSet(); + + // case true & true + runSimplePrimitiveTypesQuery("true & true", + pm, allInstances, ASSERTION_FAILED); + + // case true & false + runSimplePrimitiveTypesQuery("true & false", + pm, empty, ASSERTION_FAILED); + + // case false & true + runSimplePrimitiveTypesQuery("false & true", + pm, empty, ASSERTION_FAILED); + + // case false & false + runSimplePrimitiveTypesQuery("false & false", + pm, empty, ASSERTION_FAILED); + + // case boolean & boolean + runSimplePrimitiveTypesQuery("intNotNull == 9 & booleanNotNull", + pm, instance9, ASSERTION_FAILED); + + // case boolean & Boolean + runSimplePrimitiveTypesQuery("intNotNull == 9 & booleanNull", + pm, instance9, ASSERTION_FAILED); + // case Boolean & boolean + runSimplePrimitiveTypesQuery("booleanNull & intNotNull == 9", + pm, instance9, ASSERTION_FAILED); + // case Boolean & Boolean + runSimplePrimitiveTypesQuery("booleanNull & booleanNull", + pm, allOddInstances, ASSERTION_FAILED); + + // case Boolean parameter + runParameterPrimitiveTypesQuery("param & id == 9", + "Boolean param", Boolean.TRUE, + pm, instance9, ASSERTION_FAILED); + runParameterPrimitiveTypesQuery("param & id == 9", + "Boolean param", Boolean.FALSE, + pm, empty, ASSERTION_FAILED); + + // case boolean parameter + runParameterPrimitiveTypesQuery("param & id == 9", + "boolean param", Boolean.TRUE, + pm, instance9, ASSERTION_FAILED); + runParameterPrimitiveTypesQuery("param & id == 9", + "boolean param", Boolean.FALSE, + pm, empty, ASSERTION_FAILED); + + tx.commit(); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PrimitiveTypes.class); + loadAndPersistPrimitiveTypes(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BooleanLogicalOR.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BooleanLogicalOR.java index d49228e12..539314e9e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BooleanLogicalOR.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/BooleanLogicalOR.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,124 +19,146 @@ import java.util.Collection; import java.util.HashSet; + import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Boolean Logical OR Query Operator
    - * Keywords: query
    - * Assertion ID: A14.6.2-22.
    - * Assertion Description: The Boolean logical OR (not bitwise) operator (|) is - * supported for all types as they are defined in the Java language. This includes the following - * types: - * - *
      - *
    • Boolean, boolean - *
    + *Title: Boolean Logical OR Query Operator + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-22. + *
    + *Assertion Description: +The Boolean logical OR (not bitwise) operator (|) is supported for +all types as they are defined in the Java language. +This includes the following types: +
      +
    • Boolean, boolean
    • +
    */ + public class BooleanLogicalOR extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.2-22 (BooleanLogicalOR) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(BooleanLogicalOR.class); - } - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - if (debug) logger.debug("\nExecuting positive test BooleanLogicalOR() ..."); - - Transaction tx = pm.currentTransaction(); - tx.begin(); - - Collection instance9 = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 9").execute(); - Collection instancesLess3 = (Collection) pm.newQuery(PrimitiveTypes.class, "id < 3").execute(); - Collection allOddInstances = - (Collection) pm.newQuery(PrimitiveTypes.class, "booleanNull").execute(); - Collection allInstances = (Collection) pm.newQuery(PrimitiveTypes.class, "true").execute(); - Collection empty = new HashSet(); - - // case true | true - runSimplePrimitiveTypesQuery("true | true", pm, allInstances, ASSERTION_FAILED); - - // case true | false - runSimplePrimitiveTypesQuery("true | false", pm, allInstances, ASSERTION_FAILED); - - // case false | true - runSimplePrimitiveTypesQuery("false | true", pm, allInstances, ASSERTION_FAILED); - - // case false | false - runSimplePrimitiveTypesQuery("false | false", pm, empty, ASSERTION_FAILED); - - // case boolean | boolean - runSimplePrimitiveTypesQuery( - "intNotNull == 9 | booleanNotNull", pm, allOddInstances, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("id == 1 | id == 2", pm, instancesLess3, ASSERTION_FAILED); - - // case boolean | Boolean - runSimplePrimitiveTypesQuery( - "intNotNull == 9 | booleanNull", pm, allOddInstances, ASSERTION_FAILED); - // case Boolean | boolean - runSimplePrimitiveTypesQuery( - "booleanNull | intNotNull == 9", pm, allOddInstances, ASSERTION_FAILED); - // case Boolean | Boolean - runSimplePrimitiveTypesQuery( - "booleanNull | booleanNull", pm, allOddInstances, ASSERTION_FAILED); - - // case Boolean parameter - runParameterPrimitiveTypesQuery( - "param | id == 9", "Boolean param", Boolean.TRUE, pm, allInstances, ASSERTION_FAILED); - runParameterPrimitiveTypesQuery( - "param | id == 9", "Boolean param", Boolean.FALSE, pm, instance9, ASSERTION_FAILED); - - // case boolean parameter - runParameterPrimitiveTypesQuery( - "param | id == 9", "boolean param", Boolean.TRUE, pm, allInstances, ASSERTION_FAILED); - runParameterPrimitiveTypesQuery( - "param | id == 9", "boolean param", Boolean.FALSE, pm, instance9, ASSERTION_FAILED); - tx.commit(); - } - - /** */ - public void testNegative() { - PersistenceManager pm = getPM(); - if (debug) logger.debug("\nExecuting positive test BooleanLogicalAND() ..."); - - Transaction tx = pm.currentTransaction(); - tx.begin(); - - try { - Query q = pm.newQuery(PrimitiveTypes.class, "stringNull | stringNull"); - Object result = q.execute(); - fail( - ASSERTION_FAILED, - "Query using | operator for non-supported types should throw JDOUserException."); - } catch (JDOUserException ex) { - // expected exception - if (debug) { - logger.debug("expected exception: " + ex); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-22 (BooleanLogicalOR) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(BooleanLogicalOR.class); + } + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + if (debug) logger.debug("\nExecuting positive test BooleanLogicalOR() ..."); + + Transaction tx = pm.currentTransaction(); + tx.begin(); + + Collection instance9 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 9").execute(); + Collection instancesLess3 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id < 3").execute(); + Collection allOddInstances = (Collection)pm.newQuery( + PrimitiveTypes.class, "booleanNull").execute(); + Collection allInstances = (Collection)pm.newQuery( + PrimitiveTypes.class, "true").execute(); + Collection empty = new HashSet(); + + // case true | true + runSimplePrimitiveTypesQuery("true | true", + pm, allInstances, ASSERTION_FAILED); + + // case true | false + runSimplePrimitiveTypesQuery("true | false", + pm, allInstances, ASSERTION_FAILED); + + // case false | true + runSimplePrimitiveTypesQuery("false | true", + pm, allInstances, ASSERTION_FAILED); + + // case false | false + runSimplePrimitiveTypesQuery("false | false", + pm, empty, ASSERTION_FAILED); + + // case boolean | boolean + runSimplePrimitiveTypesQuery("intNotNull == 9 | booleanNotNull", + pm, allOddInstances, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("id == 1 | id == 2", + pm, instancesLess3, ASSERTION_FAILED); + + // case boolean | Boolean + runSimplePrimitiveTypesQuery("intNotNull == 9 | booleanNull", + pm, allOddInstances, ASSERTION_FAILED); + // case Boolean | boolean + runSimplePrimitiveTypesQuery("booleanNull | intNotNull == 9", + pm, allOddInstances, ASSERTION_FAILED); + // case Boolean | Boolean + runSimplePrimitiveTypesQuery("booleanNull | booleanNull", + pm, allOddInstances, ASSERTION_FAILED); + + // case Boolean parameter + runParameterPrimitiveTypesQuery("param | id == 9", + "Boolean param", Boolean.TRUE, + pm, allInstances, ASSERTION_FAILED); + runParameterPrimitiveTypesQuery("param | id == 9", + "Boolean param", Boolean.FALSE, + pm, instance9, ASSERTION_FAILED); + + // case boolean parameter + runParameterPrimitiveTypesQuery("param | id == 9", + "boolean param", Boolean.TRUE, + pm, allInstances, ASSERTION_FAILED); + runParameterPrimitiveTypesQuery("param | id == 9", + "boolean param", Boolean.FALSE, + pm, instance9, ASSERTION_FAILED); + tx.commit(); + } + + /** */ + public void testNegative() { + PersistenceManager pm = getPM(); + if (debug) logger.debug("\nExecuting positive test BooleanLogicalAND() ..."); + + Transaction tx = pm.currentTransaction(); + tx.begin(); + + try { + Query q = pm.newQuery(PrimitiveTypes.class, + "stringNull | stringNull"); + Object result = q.execute(); + fail(ASSERTION_FAILED, + "Query using | operator for non-supported types should throw JDOUserException."); + } + catch (JDOUserException ex) { + // expected exception + if (debug) { + logger.debug("expected exception: " + ex); + } + } + tx.commit(); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PrimitiveTypes.class); + loadAndPersistPrimitiveTypes(getPM()); } - tx.commit(); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PrimitiveTypes.class); - loadAndPersistPrimitiveTypes(getPM()); - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/ComparisonTests.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/ComparisonTests.java index 74ae663bf..e8dd35d8d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/ComparisonTests.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/ComparisonTests.java @@ -5,106 +5,116 @@ * 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 + * + * 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.jdo.tck.query.jdoql.operators; import java.util.Collection; +import java.util.Iterator; + import javax.jdo.Extent; import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.fieldtypes.AllTypes; -public abstract class ComparisonTests extends JDO_Test { - protected Query query; - protected Transaction tx; - protected Collection query_result; - - protected static String BooleanParameter = "Boolean value"; - protected static String booleanParameter = "boolean value"; - protected static String ByteParameter = "Byte value"; - protected static String byteParameter = "byte value"; - protected static String CharacterParameter = "Character value"; - protected static String charParameter = "char value"; - protected static String DoubleParameter = "Double value"; - protected static String doubleParameter = "double value"; - protected static String FloatParameter = "Float value"; - protected static String floatParameter = "float value"; - protected static String IntegerParameter = "Integer value"; - protected static String intParameter = "int value"; - protected static String LongParameter = "Long value"; - protected static String longParameter = "long value"; - protected static String ShortParameter = "Short value"; - protected static String shortParameter = "short value"; - protected static String StringParameter = "String value"; - protected static String LocaleParameter = "java.util.Locale value"; - protected static String BigDecimalParameter = "java.math.BigDecimal value"; - protected static String BigIntegerParameter = "java.math.BigInteger value"; - protected static String DateParameter = "java.util.Date value"; - protected static String AllTypesParameter = "org.apache.jdo.tck.pc.fieldtypes.AllTypes value"; +public abstract class ComparisonTests extends JDO_Test { + protected Query query; + protected Transaction tx; + protected Collection query_result; + + protected static String BooleanParameter = "Boolean value"; + protected static String booleanParameter = "boolean value"; + protected static String ByteParameter = "Byte value"; + protected static String byteParameter = "byte value"; + protected static String CharacterParameter = "Character value"; + protected static String charParameter = "char value"; + protected static String DoubleParameter = "Double value"; + protected static String doubleParameter = "double value"; + protected static String FloatParameter = "Float value"; + protected static String floatParameter = "float value"; + protected static String IntegerParameter = "Integer value"; + protected static String intParameter = "int value"; + protected static String LongParameter = "Long value"; + protected static String longParameter = "long value"; + protected static String ShortParameter = "Short value"; + protected static String shortParameter = "short value"; + protected static String StringParameter = "String value"; + protected static String LocaleParameter = "java.util.Locale value"; + protected static String BigDecimalParameter = "java.math.BigDecimal value"; + protected static String BigIntegerParameter = "java.math.BigInteger value"; + protected static String DateParameter = "java.util.Date value"; + protected static String AllTypesParameter = "org.apache.jdo.tck.pc.fieldtypes.AllTypes value"; - /** - * @param assertion assertion - * @param message the message - * @param filter the filter - * @param parameter the parameter - */ - protected void fail(String assertion, String message, String filter, String parameter) { - StringBuffer buf = new StringBuffer(); - buf.append(message); - buf.append("("); - buf.append(" filter \"").append(filter).append("\""); - if (parameter != null) { - buf.append(" , parameter \"").append(parameter).append("\""); + /** + * + * @param assertion assertion + * @param message the message + * @param filter the filter + * @param parameter the parameter + */ + protected void fail(String assertion, String message, String filter, String parameter) + { + StringBuffer buf = new StringBuffer(); + buf.append(message); + buf.append("("); + buf.append(" filter \"").append(filter).append("\""); + if (parameter != null) { + buf.append(" , parameter \"").append(parameter).append("\""); + } + buf.append(")"); + + fail(assertion, buf.toString()); } - buf.append(")"); - fail(assertion, buf.toString()); - } - - /** - * @param pm the PersistenceManager - * @param filter the filter - * @param parameter the parameter declaration - * @param parameterValue the parameter value - * @param assertion assertion - */ - protected void runQuery( - PersistenceManager pm, - String filter, - String parameter, - Object parameterValue, - String assertion) { - Extent e = pm.getExtent(AllTypes.class, false); - query = pm.newQuery(e, filter); - query_result = null; - try { - if (parameter != null) { - query.declareParameters(parameter); - query_result = (Collection) query.execute(parameterValue); - } else { - query_result = (Collection) query.execute(); - } - } catch (Throwable throwable) { - if (debug) throwable.printStackTrace(); - fail(assertion, "Exception on Query.execute " + throwable, filter, parameter); - query_result = null; - if (tx.isActive()) tx.rollback(); - return; - } - if (query_result == null) { - fail(assertion, "Query.execute returned a null", filter, parameter); - if (tx.isActive()) tx.rollback(); - } - } + /** + * + * @param pm the PersistenceManager + * @param filter the filter + * @param parameter the parameter declaration + * @param parameterValue the parameter value + * @param assertion assertion + */ + protected void runQuery(PersistenceManager pm, + String filter, String parameter, Object parameterValue, + String assertion) + { + Extent e = pm.getExtent(AllTypes.class, false); + query = pm.newQuery(e, filter); + query_result = null; + try { + if (parameter != null) { + query.declareParameters(parameter); + query_result = (Collection) query.execute(parameterValue); + } + else { + query_result = (Collection) query.execute(); + } + } + catch (Throwable throwable) { + if (debug) + throwable.printStackTrace(); + fail(assertion, "Exception on Query.execute " + throwable, filter, parameter); + query_result = null; + if (tx.isActive()) + tx.rollback(); + return; + } + if (query_result == null) { + fail(assertion, "Query.execute returned a null", filter, parameter); + if (tx.isActive()) + tx.rollback(); + } + } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/ConditionalAND.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/ConditionalAND.java index ce0a3c0b5..9311d5037 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/ConditionalAND.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/ConditionalAND.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,97 +19,118 @@ import java.util.Collection; import java.util.HashSet; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Conditional AND Query Operator
    - * Keywords: query
    - * Assertion ID: A14.6.2-21.
    - * Assertion Description: The conditional AND operator (&&) is - * supported for all types as they are defined in the Java language. This includes the following - * types: - * - *
      - *
    • Boolean, boolean - *
    - */ + *Title: Conditional AND Query Operator + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-21. + *
    + *Assertion Description: +The conditional AND operator (&&) is supported for all +types as they are defined in the Java language. +This includes the following types: +
      +
    • Boolean, boolean
    • +
    +*/ + public class ConditionalAND extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.2-21 (ConditionalAND) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ConditionalAND.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - if (debug) logger.debug("\nExecuting test ConditionalAND() ..."); - - Transaction tx = pm.currentTransaction(); - tx.begin(); - - Collection instance9 = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 9").execute(); - Collection allOddInstances = - (Collection) pm.newQuery(PrimitiveTypes.class, "booleanNull").execute(); - Collection allInstances = (Collection) pm.newQuery(PrimitiveTypes.class, "true").execute(); - Collection empty = new HashSet(); - - // case true && true - runSimplePrimitiveTypesQuery("true && true", pm, allInstances, ASSERTION_FAILED); - - // case true && false - runSimplePrimitiveTypesQuery("true && false", pm, empty, ASSERTION_FAILED); - - // case false && true - runSimplePrimitiveTypesQuery("false && true", pm, empty, ASSERTION_FAILED); - - // case false && false - runSimplePrimitiveTypesQuery("false && false", pm, empty, ASSERTION_FAILED); - - // case boolean && boolean - runSimplePrimitiveTypesQuery( - "intNotNull == 9 && booleanNotNull", pm, instance9, ASSERTION_FAILED); - - // case boolean && Boolean - runSimplePrimitiveTypesQuery("intNotNull == 9 && booleanNull", pm, instance9, ASSERTION_FAILED); - // case Boolean && boolean - runSimplePrimitiveTypesQuery("booleanNull && intNotNull == 9", pm, instance9, ASSERTION_FAILED); - // case Boolean && Boolean - runSimplePrimitiveTypesQuery( - "booleanNull && booleanNull", pm, allOddInstances, ASSERTION_FAILED); - - // case Boolean parameter - runParameterPrimitiveTypesQuery( - "param && id == 9", "Boolean param", Boolean.TRUE, pm, instance9, ASSERTION_FAILED); - runParameterPrimitiveTypesQuery( - "param && id == 9", "Boolean param", Boolean.FALSE, pm, empty, ASSERTION_FAILED); - - // case boolean parameter - runParameterPrimitiveTypesQuery( - "param && id == 9", "boolean param", Boolean.TRUE, pm, instance9, ASSERTION_FAILED); - runParameterPrimitiveTypesQuery( - "param && id == 9", "boolean param", Boolean.FALSE, pm, empty, ASSERTION_FAILED); - - tx.commit(); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PrimitiveTypes.class); - loadAndPersistPrimitiveTypes(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-21 (ConditionalAND) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ConditionalAND.class); + } + + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + if (debug) logger.debug("\nExecuting test ConditionalAND() ..."); + + Transaction tx = pm.currentTransaction(); + tx.begin(); + + Collection instance9 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 9").execute(); + Collection allOddInstances = (Collection)pm.newQuery( + PrimitiveTypes.class, "booleanNull").execute(); + Collection allInstances = (Collection)pm.newQuery( + PrimitiveTypes.class, "true").execute(); + Collection empty = new HashSet(); + + // case true && true + runSimplePrimitiveTypesQuery("true && true", + pm, allInstances, ASSERTION_FAILED); + + // case true && false + runSimplePrimitiveTypesQuery("true && false", + pm, empty, ASSERTION_FAILED); + + // case false && true + runSimplePrimitiveTypesQuery("false && true", + pm, empty, ASSERTION_FAILED); + + // case false && false + runSimplePrimitiveTypesQuery("false && false", + pm, empty, ASSERTION_FAILED); + + // case boolean && boolean + runSimplePrimitiveTypesQuery("intNotNull == 9 && booleanNotNull", + pm, instance9, ASSERTION_FAILED); + + // case boolean && Boolean + runSimplePrimitiveTypesQuery("intNotNull == 9 && booleanNull", + pm, instance9, ASSERTION_FAILED); + // case Boolean && boolean + runSimplePrimitiveTypesQuery("booleanNull && intNotNull == 9", + pm, instance9, ASSERTION_FAILED); + // case Boolean && Boolean + runSimplePrimitiveTypesQuery("booleanNull && booleanNull", + pm, allOddInstances, ASSERTION_FAILED); + + // case Boolean parameter + runParameterPrimitiveTypesQuery("param && id == 9", + "Boolean param", Boolean.TRUE, + pm, instance9, ASSERTION_FAILED); + runParameterPrimitiveTypesQuery("param && id == 9", + "Boolean param", Boolean.FALSE, + pm, empty, ASSERTION_FAILED); + + // case boolean parameter + runParameterPrimitiveTypesQuery("param && id == 9", + "boolean param", Boolean.TRUE, + pm, instance9, ASSERTION_FAILED); + runParameterPrimitiveTypesQuery("param && id == 9", + "boolean param", Boolean.FALSE, + pm, empty, ASSERTION_FAILED); + + tx.commit(); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PrimitiveTypes.class); + loadAndPersistPrimitiveTypes(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/ConditionalOR.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/ConditionalOR.java index 8748b184c..25d8a698e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/ConditionalOR.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/ConditionalOR.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,99 +19,119 @@ import java.util.Collection; import java.util.HashSet; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Conditional OR Query Operator
    - * Keywords: query
    - * Assertion ID: A14.6.2-23.
    - * Assertion Description: The conditional OR operator (||) is supported for all - * types as they are defined in the Java language. This includes the following types: - * - *
      - *
    • Boolean, boolean - *
    + *Title: Conditional OR Query Operator + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-23. + *
    + *Assertion Description: +The conditional OR operator (||) is supported for all types +as they are defined in the Java language. This includes the following types: +
      +
    • Boolean, boolean
    • +
    */ + public class ConditionalOR extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.2-23 (ConditionalOR) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ConditionalOR.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - if (debug) logger.debug("\nExecuting test ConditionalOR() ..."); - - Transaction tx = pm.currentTransaction(); - tx.begin(); - - Collection instance9 = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 9").execute(); - Collection instancesLess3 = (Collection) pm.newQuery(PrimitiveTypes.class, "id < 3").execute(); - Collection allOddInstances = - (Collection) pm.newQuery(PrimitiveTypes.class, "booleanNull").execute(); - Collection allInstances = (Collection) pm.newQuery(PrimitiveTypes.class, "true").execute(); - Collection empty = new HashSet(); - - // case true || true - runSimplePrimitiveTypesQuery("true || true", pm, allInstances, ASSERTION_FAILED); - - // case true || false - runSimplePrimitiveTypesQuery("true || false", pm, allInstances, ASSERTION_FAILED); - - // case false || true - runSimplePrimitiveTypesQuery("false || true", pm, allInstances, ASSERTION_FAILED); - - // case false || false - runSimplePrimitiveTypesQuery("false || false", pm, empty, ASSERTION_FAILED); - - // case boolean || boolean - runSimplePrimitiveTypesQuery( - "intNotNull == 9 || booleanNotNull", pm, allOddInstances, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("id == 1 || id == 2", pm, instancesLess3, ASSERTION_FAILED); - - // case boolean || Boolean - runSimplePrimitiveTypesQuery( - "intNotNull == 9 || booleanNull", pm, allOddInstances, ASSERTION_FAILED); - // case Boolean || boolean - runSimplePrimitiveTypesQuery( - "booleanNull || intNotNull == 9", pm, allOddInstances, ASSERTION_FAILED); - // case Boolean || Boolean - runSimplePrimitiveTypesQuery( - "booleanNull || booleanNull", pm, allOddInstances, ASSERTION_FAILED); - - // case Boolean parameter - runParameterPrimitiveTypesQuery( - "param || id == 9", "Boolean param", Boolean.TRUE, pm, allInstances, ASSERTION_FAILED); - runParameterPrimitiveTypesQuery( - "param || id == 9", "Boolean param", Boolean.FALSE, pm, instance9, ASSERTION_FAILED); - - // case boolean parameter - runParameterPrimitiveTypesQuery( - "param || id == 9", "boolean param", Boolean.TRUE, pm, allInstances, ASSERTION_FAILED); - runParameterPrimitiveTypesQuery( - "param || id == 9", "boolean param", Boolean.FALSE, pm, instance9, ASSERTION_FAILED); - tx.commit(); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PrimitiveTypes.class); - loadAndPersistPrimitiveTypes(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-23 (ConditionalOR) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ConditionalOR.class); + } + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + if (debug) logger.debug("\nExecuting test ConditionalOR() ..."); + + Transaction tx = pm.currentTransaction(); + tx.begin(); + + Collection instance9 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 9").execute(); + Collection instancesLess3 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id < 3").execute(); + Collection allOddInstances = (Collection)pm.newQuery( + PrimitiveTypes.class, "booleanNull").execute(); + Collection allInstances = (Collection)pm.newQuery( + PrimitiveTypes.class, "true").execute(); + Collection empty = new HashSet(); + + // case true || true + runSimplePrimitiveTypesQuery("true || true", + pm, allInstances, ASSERTION_FAILED); + + // case true || false + runSimplePrimitiveTypesQuery("true || false", + pm, allInstances, ASSERTION_FAILED); + + // case false || true + runSimplePrimitiveTypesQuery("false || true", + pm, allInstances, ASSERTION_FAILED); + + // case false || false + runSimplePrimitiveTypesQuery("false || false", + pm, empty, ASSERTION_FAILED); + + // case boolean || boolean + runSimplePrimitiveTypesQuery("intNotNull == 9 || booleanNotNull", + pm, allOddInstances, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("id == 1 || id == 2", + pm, instancesLess3, ASSERTION_FAILED); + + // case boolean || Boolean + runSimplePrimitiveTypesQuery("intNotNull == 9 || booleanNull", + pm, allOddInstances, ASSERTION_FAILED); + // case Boolean || boolean + runSimplePrimitiveTypesQuery("booleanNull || intNotNull == 9", + pm, allOddInstances, ASSERTION_FAILED); + // case Boolean || Boolean + runSimplePrimitiveTypesQuery("booleanNull || booleanNull", + pm, allOddInstances, ASSERTION_FAILED); + + // case Boolean parameter + runParameterPrimitiveTypesQuery("param || id == 9", + "Boolean param", Boolean.TRUE, + pm, allInstances, ASSERTION_FAILED); + runParameterPrimitiveTypesQuery("param || id == 9", + "Boolean param", Boolean.FALSE, + pm, instance9, ASSERTION_FAILED); + + // case boolean parameter + runParameterPrimitiveTypesQuery("param || id == 9", + "boolean param", Boolean.TRUE, + pm, allInstances, ASSERTION_FAILED); + runParameterPrimitiveTypesQuery("param || id == 9", + "boolean param", Boolean.FALSE, + pm, instance9, ASSERTION_FAILED); + tx.commit(); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PrimitiveTypes.class); + loadAndPersistPrimitiveTypes(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/Division.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/Division.java index b15d09f58..bf1aac29b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/Division.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/Division.java @@ -5,104 +5,124 @@ * 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 + * + * 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.jdo.tck.query.jdoql.operators; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Division Query Operator
    - * Keywords: query
    - * Assertion ID: A14.6.2-31.
    - * Assertion Description: The division operator (/) is supported for all types - * as they are defined in the Java language. This includes the following types: - * - *
      - *
    • byte, short, int, long, char, Byte, Short Integer, Long, Character - *
    • float, double, Float, Double - *
    • BigDecimal, BigInteger - *
    - * - * The operation on object-valued fields of wrapper types (Boolean, Byte, - * Short, Integer, Long, Float, and Double), and numeric types (BigDecimal - * and BigInteger) use the wrapped values as operands. + *Title: Division Query Operator + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-31. + *
    + *Assertion Description: +The division operator (/) is supported for all types as they are +defined in the Java language. This includes the following types: +
      +
    • byte, short, int, long, char, Byte, Short Integer, Long, Character
    • +
    • float, double, Float, Double
    • +
    • BigDecimal, BigInteger
    • +
    +The operation on object-valued fields of wrapper types (Boolean, Byte, +Short, Integer, Long, Float, and Double), and numeric types +(BigDecimal and BigInteger) +use the wrapped values as operands. */ -public class Division extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.2-31 (Division) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Division.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - if (debug) logger.debug("\nExecuting test Division() ..."); - - Transaction tx = pm.currentTransaction(); - tx.begin(); - - Collection instance8 = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 8").execute(); +public class Division extends QueryTest { - Collection instances8And9 = - (Collection) pm.newQuery(PrimitiveTypes.class, "id == 8 || id == 9").execute(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-31 (Division) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Division.class); + } + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + if (debug) logger.debug("\nExecuting test Division() ..."); - runSimplePrimitiveTypesQuery("id / 2 == 4", pm, instances8And9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("byteNotNull / 2 == 4", pm, instances8And9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("shortNotNull / 2 == 4", pm, instances8And9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("intNotNull / 2 == 4", pm, instances8And9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("longNotNull / 2 == 4", pm, instances8And9, ASSERTION_FAILED); - /* testing float division? - runSimplePrimitiveTypesQuery("floatNotNull / 2 == 4", - pm, instance8, ASSERTION_FAILED);*/ - /* testing double division? - runSimplePrimitiveTypesQuery("doubleNotNull / 2 == 4", - pm, instance8, ASSERTION_FAILED);*/ - runSimplePrimitiveTypesQuery("byteNull / 2 == 4", pm, instances8And9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("shortNull / 2 == 4", pm, instances8And9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("intNull / 2 == 4", pm, instances8And9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("longNull / 2 == 4", pm, instances8And9, ASSERTION_FAILED); - /* testing float division? - runSimplePrimitiveTypesQuery("floatNull / 2 == 4", - pm, instance8, ASSERTION_FAILED);*/ - /* testing double division? - runSimplePrimitiveTypesQuery("doubleNull / 2 == 4", - pm, instance8, ASSERTION_FAILED);*/ - /* testing BigDecimal division? Scaling issue! - runSimplePrimitiveTypesQuery("bigDecimal / 2 == 4", - pm, instances8And9, ASSERTION_FAILED);*/ - runSimplePrimitiveTypesQuery("bigInteger / 2 == 4", pm, instances8And9, ASSERTION_FAILED); + Transaction tx = pm.currentTransaction(); + tx.begin(); + + Collection instance8 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 8").execute(); + + Collection instances8And9 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 8 || id == 9").execute(); + + runSimplePrimitiveTypesQuery("id / 2 == 4", + pm, instances8And9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("byteNotNull / 2 == 4", + pm, instances8And9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("shortNotNull / 2 == 4", + pm, instances8And9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("intNotNull / 2 == 4", + pm, instances8And9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("longNotNull / 2 == 4", + pm, instances8And9, ASSERTION_FAILED); + /* testing float division? + runSimplePrimitiveTypesQuery("floatNotNull / 2 == 4", + pm, instance8, ASSERTION_FAILED);*/ + /* testing double division? + runSimplePrimitiveTypesQuery("doubleNotNull / 2 == 4", + pm, instance8, ASSERTION_FAILED);*/ + runSimplePrimitiveTypesQuery("byteNull / 2 == 4", + pm, instances8And9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("shortNull / 2 == 4", + pm, instances8And9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("intNull / 2 == 4", + pm, instances8And9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("longNull / 2 == 4", + pm, instances8And9, ASSERTION_FAILED); + /* testing float division? + runSimplePrimitiveTypesQuery("floatNull / 2 == 4", + pm, instance8, ASSERTION_FAILED);*/ + /* testing double division? + runSimplePrimitiveTypesQuery("doubleNull / 2 == 4", + pm, instance8, ASSERTION_FAILED);*/ + /* testing BigDecimal division? Scaling issue! + runSimplePrimitiveTypesQuery("bigDecimal / 2 == 4", + pm, instances8And9, ASSERTION_FAILED);*/ + runSimplePrimitiveTypesQuery("bigInteger / 2 == 4", + pm, instances8And9, ASSERTION_FAILED); - tx.commit(); - } + tx.commit(); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PrimitiveTypes.class); - loadAndPersistPrimitiveTypes(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PrimitiveTypes.class); + loadAndPersistPrimitiveTypes(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/Equality.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/Equality.java index 7c682fbe2..ef66e81e9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/Equality.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/Equality.java @@ -5,16 +5,16 @@ * 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 + * + * 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.jdo.tck.query.jdoql.operators; import java.math.BigDecimal; @@ -25,1903 +25,1263 @@ import java.util.Iterator; import java.util.Locale; import java.util.TimeZone; + import org.apache.jdo.tck.pc.fieldtypes.AllTypes; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Equality Operator Support
    - * Keywords: query
    - * Assertion ID: A14.6.2-14.
    - * Assertion Description: The equal operator (==) is supported for the - * following types: - * - *
      - *
    • byte, short, int, long, char, Byte, Short Integer, Long, Character - *
    • float, double, Float, Double - *
    • BigDecimal, BigInteger - *
    • Boolean, boolean - *
    • any class instance or array - *
    • Date, String - *
    - * - * The operation on object-valued fields of wrapper types (Boolean, Byte, - * Short, Integer, Long, Float, and Double), and numeric types (BigDecimal and - * BigInteger) use the wrapped values as operands. Equality comparison of object-valued - * fields of PersistenceCapable types use the JDO Identity comparison of the - * references. Thus, two objects will compare equal if they have the same JDO Identity. Equality - * comparison of object-valued fields of non-PersistenceCapable types uses the - * equals method of the field type. - */ -public class Equality extends ComparisonTests { - - private static String boolean_filterL = "value == fld_boolean"; - private static String boolean_filterR = "fld_boolean == value"; - private static String boolean_filterT = "fld_boolean == true"; - private static String boolean_filterF = "false == fld_boolean"; - private static String boolean_filterObj = "value.fld_boolean == fld_boolean"; - - private static String byte_filterL = "value == fld_byte"; - private static String byte_filterR = "fld_byte == value"; - private static String byte_filterObj = "value.fld_byte == fld_byte"; - private static String byte_filterVal = "fld_byte == 100"; - - private static String char_filterL = "value == fld_char"; - private static String char_filterR = "fld_char == value"; - private static String char_filterObj = "value.fld_char == fld_char"; - private static String char_filterVal = "'M' == fld_char"; - - private static String double_filterL = "value == fld_double"; - private static String double_filterR = "fld_double == value"; - private static String double_filterObj = "value.fld_double == fld_double"; - private static String double_filterVal = "fld_double == 100.0"; - - private static String float_filterL = "value == fld_float"; - private static String float_filterR = "fld_float == value"; - private static String float_filterObj = "fld_float == value.fld_float"; - private static String float_filterVal = "fld_float == 100.0"; - - private static String int_filterL = "value == fld_int"; - private static String int_filterR = "fld_int == value"; - private static String int_filterObj = "value.fld_int == fld_int"; - private static String int_filterVal = "fld_int == 1000"; - - private static String long_filterL = "value == fld_long"; - private static String long_filterR = "fld_long == value"; - private static String long_filterObj = "fld_long == value.fld_long"; - private static String long_filterVal = "fld_long == 1000000"; - - private static String short_filterL = "value == fld_short"; - private static String short_filterR = "fld_short == value"; - private static String short_filterObj = "value.fld_short == fld_short"; - private static String short_filterVal = "1000 == fld_short"; - - private static String Boolean_filterL = "value == fld_Boolean"; - private static String Boolean_filterR = "fld_Boolean == value"; - private static String Boolean_filterT = "fld_Boolean == true"; - private static String Boolean_filterF = "false == fld_Boolean"; - private static String Boolean_filterObj = "value.fld_Boolean == fld_Boolean"; - private static String Boolean_filterVal = "fld_Boolean == false"; - - private static String Byte_filterL = "value == fld_Byte"; - private static String Byte_filterR = "fld_Byte == value"; - private static String Byte_filterObj = "fld_Byte == value.fld_Byte"; - private static String Byte_filterVal = "100 == fld_Byte"; - - private static String Character_filterL = "value == fld_Character"; - private static String Character_filterR = "fld_Character == value"; - private static String Character_filterObj = "value.fld_Character == fld_Character"; - private static String Character_filterVal = "fld_Character == 'z'"; - - private static String Double_filterL = "value == fld_Double"; - private static String Double_filterR = "fld_Double == value"; - private static String Double_filterObj = "value.fld_Double == fld_Double"; - private static String Double_filterVal = "fld_Double == -25.5"; - - private static String Float_filterL = "value == fld_Float"; - private static String Float_filterR = "fld_Float == value"; - private static String Float_filterObj = "fld_Float == value.fld_Float"; - private static String Float_filterVal = "100.0f == fld_Float"; - - private static String Integer_filterL = "value == fld_Integer"; - private static String Integer_filterR = "fld_Integer == value"; - private static String Integer_filterObj = "fld_Integer == value.fld_Integer"; - private static String Integer_filterVal = "fld_Integer == 100"; - - private static String Long_filterL = "value == fld_Long"; - private static String Long_filterR = "fld_Long == value"; - private static String Long_filterObj = "value.fld_Long == fld_Long"; - private static String Long_filterVal = "-1000 == fld_Long"; - - private static String Short_filterL = "value == fld_Short"; - private static String Short_filterR = "fld_Short == value"; - private static String Short_filterObj = "fld_Short == value.fld_Short"; - private static String Short_filterVal = "-1000 == fld_Short"; - - private static String String_filterL = "value == fld_String"; - private static String String_filterR = "fld_String == value"; - private static String String_filterObj = "value.fld_String == fld_String"; - private static String String_filterVal1 = "fld_String == \"Java\""; - private static String String_filterVal2 = "fld_String == \"\""; - - private static String Locale_filterL = "value == fld_Locale"; - private static String Locale_filterR = "fld_Locale == value"; - private static String Locale_filterObj = "value.fld_Locale == fld_Locale"; - - private static String Date_filterL = "value == fld_Date"; - private static String Date_filterR = "fld_Date == value"; - private static String Date_filterObj = "fld_Date == value.fld_Date"; - - private static String BigDecimal_filterL = "value == fld_BigDecimal"; - private static String BigDecimal_filterR = "fld_BigDecimal == value"; - private static String BigDecimal_filterObj = "value.fld_BigDecimal == fld_BigDecimal"; - - private static String BigInteger_filterL = "value == fld_BigInteger"; - private static String BigInteger_filterR = "fld_BigInteger == value"; - private static String BigInteger_filterObj = "fld_BigInteger == value.fld_BigInteger"; - - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.2-14 (Equality) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Equality.class); - } - - /** */ - public void test() { - pm = getPM(); - tx = pm.currentTransaction(); - runQueries(); - } - - /** */ - private void runQueries() { - run_booleanQuery(boolean_filterL, booleanParameter, Boolean.TRUE, true, 4); - run_booleanQuery(boolean_filterL, booleanParameter, Boolean.FALSE, false, 6); - run_booleanQuery(boolean_filterR, booleanParameter, Boolean.TRUE, true, 4); - run_booleanQuery(boolean_filterR, booleanParameter, Boolean.FALSE, false, 6); - run_booleanQuery(boolean_filterL, BooleanParameter, Boolean.TRUE, true, 4); - run_booleanQuery(boolean_filterL, BooleanParameter, Boolean.FALSE, false, 6); - run_booleanQuery(boolean_filterR, BooleanParameter, Boolean.TRUE, true, 4); - run_booleanQuery(boolean_filterR, BooleanParameter, Boolean.FALSE, false, 6); - run_booleanQuery(boolean_filterT, null, null, true, 4); - run_booleanQuery(boolean_filterF, null, null, false, 6); - AllTypes alltypes = new AllTypes(); - alltypes.setboolean(true); - run_booleanQuery(boolean_filterObj, AllTypesParameter, alltypes, true, 4); - alltypes.setboolean(false); - run_booleanQuery(boolean_filterObj, AllTypesParameter, alltypes, false, 6); - - run_byteQuery(byte_filterL, byteParameter, Byte.valueOf((byte) 50), (byte) 50, 2); - run_byteQuery(byte_filterR, byteParameter, Byte.valueOf(Byte.MIN_VALUE), Byte.MIN_VALUE, 1); - run_byteQuery(byte_filterL, ByteParameter, Byte.valueOf((byte) 20), (byte) 20, 0); - run_byteQuery(byte_filterR, ByteParameter, Byte.valueOf(Byte.MAX_VALUE), Byte.MAX_VALUE, 1); - run_byteQuery(byte_filterL, shortParameter, Short.valueOf((short) 50), (byte) 50, 2); - run_byteQuery(byte_filterR, shortParameter, Short.valueOf((short) 50), (byte) 50, 2); - run_byteQuery(byte_filterL, ShortParameter, Short.valueOf((short) -100), (byte) -100, 1); - run_byteQuery(byte_filterR, ShortParameter, Short.valueOf((short) -100), (byte) -100, 1); - run_byteQuery(byte_filterL, charParameter, Character.valueOf((char) 50), (byte) 50, 2); - run_byteQuery(byte_filterR, charParameter, Character.valueOf((char) 50), (byte) 50, 2); - run_byteQuery(byte_filterL, CharacterParameter, Character.valueOf((char) 50), (byte) 50, 2); - run_byteQuery(byte_filterR, CharacterParameter, Character.valueOf((char) 100), (byte) 100, 1); - run_byteQuery(byte_filterL, intParameter, Integer.valueOf(50), (byte) 50, 2); - run_byteQuery(byte_filterR, intParameter, Integer.valueOf(50), (byte) 50, 2); - run_byteQuery(byte_filterL, IntegerParameter, Integer.valueOf(-100), (byte) -100, 1); - run_byteQuery(byte_filterR, IntegerParameter, Integer.valueOf(-100), (byte) -100, 1); - run_byteQuery(byte_filterL, longParameter, Long.valueOf(50), (byte) 50, 2); - run_byteQuery(byte_filterR, longParameter, Long.valueOf(50), (byte) 50, 2); - run_byteQuery(byte_filterL, LongParameter, Long.valueOf(-100), (byte) -100, 1); - run_byteQuery(byte_filterR, LongParameter, Long.valueOf(-100), (byte) -100, 1); - run_byteQuery(byte_filterL, floatParameter, Float.valueOf(50.0f), (byte) 50, 2); - run_byteQuery(byte_filterR, floatParameter, Float.valueOf(50.0f), (byte) 50, 2); - run_byteQuery(byte_filterL, FloatParameter, Float.valueOf(-100.0f), (byte) -100, 1); - run_byteQuery(byte_filterR, FloatParameter, Float.valueOf(-100.0f), (byte) -100, 1); - run_byteQuery(byte_filterL, doubleParameter, Double.valueOf(50.0), (byte) 50, 2); - run_byteQuery(byte_filterR, doubleParameter, Double.valueOf(50.0), (byte) 50, 2); - run_byteQuery(byte_filterL, DoubleParameter, Double.valueOf(-100.0), (byte) -100, 1); - run_byteQuery(byte_filterR, DoubleParameter, Double.valueOf(-100.0), (byte) -100, 1); - run_byteQuery(byte_filterL, BigIntegerParameter, new BigInteger("50"), (byte) 50, 2); - run_byteQuery(byte_filterR, BigIntegerParameter, new BigInteger("-100"), (byte) -100, 1); - run_byteQuery(byte_filterL, BigDecimalParameter, new BigDecimal("100.0"), (byte) 100, 1); - run_byteQuery(byte_filterR, BigDecimalParameter, new BigDecimal("10.0"), (byte) 10, 1); - alltypes.setbyte((byte) 50); - run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte) 50, 2); - alltypes.setbyte((byte) 45); - run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte) 45, 0); - run_byteQuery(byte_filterVal, null, null, (byte) 100, 1); - - run_shortQuery(short_filterL, shortParameter, Short.valueOf((short) 100), (short) 100, 2); - run_shortQuery(short_filterR, shortParameter, Short.valueOf((short) 100), (short) 100, 2); - run_shortQuery( - short_filterL, ShortParameter, Short.valueOf(Short.MIN_VALUE), Short.MIN_VALUE, 1); - run_shortQuery(short_filterR, ShortParameter, Short.valueOf((short) 253), (short) 253, 0); - run_shortQuery(short_filterR, shortParameter, Short.valueOf((short) 1000), (short) 1000, 1); - run_shortQuery(short_filterL, byteParameter, Byte.valueOf((byte) 75), (short) 75, 0); - run_shortQuery(short_filterR, byteParameter, Byte.valueOf((byte) 75), (short) 75, 0); - run_shortQuery(short_filterL, ByteParameter, Byte.valueOf((byte) 100), (short) 100, 2); - run_shortQuery(short_filterR, ByteParameter, Byte.valueOf((byte) 100), (short) 100, 2); - run_shortQuery(short_filterL, charParameter, Character.valueOf((char) 75), (short) 75, 0); - run_shortQuery(short_filterR, charParameter, Character.valueOf((char) 75), (short) 75, 0); - run_shortQuery( - short_filterL, CharacterParameter, Character.valueOf((char) 100), (short) 100, 2); - run_shortQuery( - short_filterR, CharacterParameter, Character.valueOf((char) 100), (short) 100, 2); - run_shortQuery(short_filterL, intParameter, Integer.valueOf(-10000), (short) -10000, 1); - run_shortQuery(short_filterR, intParameter, Integer.valueOf(-10000), (short) -10000, 1); - run_shortQuery(short_filterL, IntegerParameter, Integer.valueOf(10000), (short) 10000, 1); - run_shortQuery(short_filterR, IntegerParameter, Integer.valueOf(10000), (short) 10000, 1); - run_shortQuery(short_filterL, longParameter, Long.valueOf(10000), (short) 10000, 1); - run_shortQuery(short_filterR, longParameter, Long.valueOf(10000), (short) 10000, 1); - run_shortQuery(short_filterL, LongParameter, Long.valueOf(100), (short) 100, 2); - run_shortQuery(short_filterR, LongParameter, Long.valueOf(100), (short) 100, 2); - run_shortQuery(short_filterL, floatParameter, Float.valueOf((float) 23000), (short) 23000, 0); - run_shortQuery(short_filterR, floatParameter, Float.valueOf((float) 23000), (short) 23000, 0); - run_shortQuery(short_filterL, FloatParameter, Float.valueOf((float) 100), (short) 100, 2); - run_shortQuery(short_filterR, FloatParameter, Float.valueOf((float) 100), (short) 100, 2); - run_shortQuery(short_filterL, doubleParameter, Double.valueOf(-10000), (short) -10000, 1); - run_shortQuery(short_filterR, doubleParameter, Double.valueOf(-10000), (short) -10000, 1); - run_shortQuery(short_filterL, DoubleParameter, Double.valueOf(23), (short) 23, 0); - run_shortQuery(short_filterR, DoubleParameter, Double.valueOf(23), (short) 23, 0); - run_shortQuery(short_filterL, BigIntegerParameter, new BigInteger("999"), (short) 999, 0); - run_shortQuery(short_filterR, BigIntegerParameter, new BigInteger("-1000"), (short) -1000, 1); - run_shortQuery(short_filterL, BigDecimalParameter, new BigDecimal("100.0"), (short) 100, 2); - run_shortQuery(short_filterR, BigDecimalParameter, new BigDecimal("100.0001"), (short) 100, 0); - alltypes.setshort((short) 100); - run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short) 100, 2); - alltypes.setshort((short) 23); - run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short) 23, 0); - run_shortQuery(short_filterVal, null, null, (short) 1000, 1); - - run_charQuery( - char_filterL, - charParameter, - Character.valueOf(Character.MIN_VALUE), - Character.MIN_VALUE, - 1); - run_charQuery( - char_filterR, - charParameter, - Character.valueOf(Character.MAX_VALUE), - Character.MAX_VALUE, - 1); - run_charQuery(char_filterL, charParameter, Character.valueOf('C'), 'C', 0); - run_charQuery(char_filterR, charParameter, Character.valueOf('z'), 'z', 2); - run_charQuery(char_filterL, CharacterParameter, Character.valueOf(' '), ' ', 1); - run_charQuery(char_filterR, CharacterParameter, Character.valueOf('f'), 'f', 0); - run_charQuery( - char_filterL, - byteParameter, - Byte.valueOf((byte) Character.MIN_VALUE), - (char) Character.MIN_VALUE, - 1); - run_charQuery(char_filterR, byteParameter, Byte.valueOf((byte) 122), 'z', 2); - run_charQuery(char_filterL, ByteParameter, Byte.valueOf((byte) 'a'), 'a', 0); - run_charQuery(char_filterR, ByteParameter, Byte.valueOf((byte) 'a'), 'a', 0); - run_charQuery(char_filterL, shortParameter, Short.valueOf((short) 'M'), 'M', 2); - run_charQuery(char_filterR, shortParameter, Short.valueOf((short) 'M'), 'M', 2); - run_charQuery(char_filterL, ShortParameter, Short.valueOf((short) 'A'), 'A', 1); - run_charQuery(char_filterR, ShortParameter, Short.valueOf((short) 'A'), 'A', 1); - run_charQuery(char_filterL, intParameter, Integer.valueOf('z'), 'z', 2); - run_charQuery(char_filterR, intParameter, Integer.valueOf('z'), 'z', 2); - run_charQuery(char_filterL, IntegerParameter, Integer.valueOf('B'), 'B', 1); - run_charQuery(char_filterR, IntegerParameter, Integer.valueOf('B'), 'B', 1); - run_charQuery(char_filterL, longParameter, Long.valueOf('z'), 'z', 2); - run_charQuery(char_filterR, longParameter, Long.valueOf('z'), 'z', 2); - run_charQuery(char_filterL, LongParameter, Long.valueOf('B'), 'B', 1); - run_charQuery(char_filterR, LongParameter, Long.valueOf('B'), 'B', 1); - run_charQuery(char_filterL, floatParameter, Float.valueOf((float) 123.222), 'x', 0); - run_charQuery(char_filterR, floatParameter, Float.valueOf((float) 123.222), 'x', 0); - run_charQuery(char_filterL, FloatParameter, Float.valueOf((float) 'z'), 'z', 2); - run_charQuery(char_filterR, FloatParameter, Float.valueOf((float) 'z'), 'z', 2); - run_charQuery(char_filterL, doubleParameter, Double.valueOf('B'), 'B', 1); - run_charQuery(char_filterR, doubleParameter, Double.valueOf('B'), 'B', 1); - run_charQuery(char_filterL, DoubleParameter, Double.valueOf('A'), 'A', 1); - run_charQuery(char_filterR, DoubleParameter, Double.valueOf('A'), 'A', 1); - run_charQuery(char_filterL, BigIntegerParameter, new BigInteger("65"), 'A', 1); // 'A' == 65 - run_charQuery(char_filterR, BigIntegerParameter, new BigInteger("122"), 'z', 2); // 'z' == 122 - run_charQuery(char_filterL, BigDecimalParameter, new BigDecimal("65.0"), 'A', 1); - run_charQuery(char_filterR, BigDecimalParameter, new BigDecimal("77.0"), 'M', 2); // 'M' == 77 - alltypes.setchar('A'); - run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'A', 1); - alltypes.setchar('b'); - run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'b', 0); - run_charQuery(char_filterVal, null, null, 'M', 2); - - run_intQuery( - int_filterL, - intParameter, - Integer.valueOf(AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - 1); - run_intQuery( - int_filterR, - intParameter, - Integer.valueOf(AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - 1); - run_intQuery(int_filterR, intParameter, Integer.valueOf(23), 23, 0); - run_intQuery(int_filterL, IntegerParameter, Integer.valueOf(1000000), 1000000, 1); - run_intQuery(int_filterR, IntegerParameter, Integer.valueOf(1000), 1000, 1); - run_intQuery(int_filterL, byteParameter, Byte.valueOf((byte) 100), 100, 2); - run_intQuery(int_filterR, byteParameter, Byte.valueOf((byte) 0), 0, 1); - run_intQuery(int_filterL, ByteParameter, Byte.valueOf((byte) 100), 100, 2); - run_intQuery(int_filterR, ByteParameter, Byte.valueOf((byte) 0), 0, 1); - run_intQuery(int_filterL, shortParameter, Short.valueOf((short) 10000), 10000, 1); - run_intQuery(int_filterR, shortParameter, Short.valueOf((short) -1000), -1000, 1); - run_intQuery(int_filterL, ShortParameter, Short.valueOf((short) -1000), -1000, 1); - run_intQuery(int_filterR, ShortParameter, Short.valueOf((short) 10000), 10000, 1); - run_intQuery(int_filterL, charParameter, Character.valueOf((char) 10000), 10000, 1); - run_intQuery(int_filterR, charParameter, Character.valueOf((char) 0), 0, 1); - run_intQuery(int_filterL, CharacterParameter, Character.valueOf((char) 100), 100, 2); - run_intQuery(int_filterR, CharacterParameter, Character.valueOf((char) 10000), 10000, 1); - run_intQuery( - int_filterL, - longParameter, - Long.valueOf(AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - 1); - run_intQuery( - int_filterR, - longParameter, - Long.valueOf(AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - 1); - run_intQuery(int_filterL, LongParameter, Long.valueOf(10000), 10000, 1); - run_intQuery(int_filterR, LongParameter, Long.valueOf(43), 43, 0); - run_intQuery( - int_filterL, - floatParameter, - Float.valueOf((float) AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - 1); - run_intQuery( - int_filterR, - floatParameter, - Float.valueOf((float) AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - 1); - run_intQuery(int_filterL, FloatParameter, Float.valueOf((float) 10000), 10000, 1); - run_intQuery(int_filterR, FloatParameter, Float.valueOf((float) 43), 43, 0); - run_intQuery( - int_filterL, - doubleParameter, - Double.valueOf(AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - 1); - run_intQuery( - int_filterR, - doubleParameter, - Double.valueOf(AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - 1); - run_intQuery(int_filterL, DoubleParameter, Double.valueOf(10000), 10000, 1); - run_intQuery(int_filterR, DoubleParameter, Double.valueOf(43), 43, 0); - run_intQuery(int_filterL, BigIntegerParameter, new BigInteger("1000000"), 1000000, 1); - run_intQuery(int_filterR, BigIntegerParameter, new BigInteger("-1000000"), -1000000, 1); - run_intQuery(int_filterL, BigDecimalParameter, new BigDecimal("1000000.0"), 1000000, 1); - run_intQuery(int_filterR, BigDecimalParameter, new BigDecimal("-1000000.00001"), -1000000, 0); - alltypes.setint(100); - run_intQuery(int_filterObj, AllTypesParameter, alltypes, 100, 2); - run_intQuery(int_filterVal, null, null, 1000, 1); - - run_longQuery(long_filterL, longParameter, Long.valueOf(Long.MIN_VALUE), Long.MIN_VALUE, 1); - run_longQuery(long_filterR, longParameter, Long.valueOf(Long.MAX_VALUE), Long.MAX_VALUE, 1); - run_longQuery(long_filterL, LongParameter, Long.valueOf(100), 100, 2); - run_longQuery(long_filterR, LongParameter, Long.valueOf(23), 23, 0); - run_longQuery(long_filterL, byteParameter, Byte.valueOf((byte) 100), 100, 2); - run_longQuery(long_filterR, byteParameter, Byte.valueOf((byte) 0), 0, 1); - run_longQuery(long_filterL, ByteParameter, Byte.valueOf((byte) 100), 100, 2); - run_longQuery(long_filterR, ByteParameter, Byte.valueOf((byte) 0), 0, 1); - run_longQuery(long_filterL, shortParameter, Short.valueOf((short) -1000), -1000, 2); - run_longQuery(long_filterR, shortParameter, Short.valueOf((short) 1000), 1000, 1); - run_longQuery(long_filterL, ShortParameter, Short.valueOf((short) 100), 100, 2); - run_longQuery(long_filterR, ShortParameter, Short.valueOf((short) 32), 32, 0); - run_longQuery(long_filterL, charParameter, Character.valueOf((char) 0), 0, 1); - run_longQuery(long_filterR, charParameter, Character.valueOf((char) 100), 100, 2); - run_longQuery(long_filterL, CharacterParameter, Character.valueOf((char) 23), 23, 0); - run_longQuery(long_filterR, CharacterParameter, Character.valueOf((char) 0), 0, 1); - run_longQuery(long_filterL, intParameter, Integer.valueOf(100), 100, 2); - run_longQuery(long_filterR, intParameter, Integer.valueOf(0), 0, 1); - run_longQuery(long_filterL, IntegerParameter, Integer.valueOf(23), 23, 0); - run_longQuery(long_filterR, IntegerParameter, Integer.valueOf(1000000), 1000000, 1); - run_longQuery(long_filterL, floatParameter, Float.valueOf((float) -1000000.0), -1000000, 1); - // run_longQuery(long_filterR, floatParameter, Float.valueOf((float)Long.MAX_VALUE), - // Long.MAX_VALUE, 1); - run_longQuery(long_filterL, FloatParameter, Float.valueOf((float) 100), 100, 2); - run_longQuery(long_filterR, FloatParameter, Float.valueOf((float) 32), 32, 0); - run_longQuery(long_filterL, doubleParameter, Double.valueOf(-1000000.0), -1000000, 1); - // run_longQuery(long_filterR, doubleParameter, Double.valueOf((double)Long.MAX_VALUE), - // Long.MAX_VALUE, 1); - run_longQuery(long_filterL, DoubleParameter, Double.valueOf(100.0), 100, 2); - run_longQuery(long_filterR, DoubleParameter, Double.valueOf(32.0), 32, 0); - run_longQuery(long_filterL, BigIntegerParameter, new BigInteger("1000000"), 1000000, 1); - run_longQuery(long_filterR, BigIntegerParameter, new BigInteger("-1000000"), -1000000, 1); - run_longQuery(long_filterL, BigDecimalParameter, new BigDecimal("100.0"), 100, 2); - run_longQuery(long_filterR, BigDecimalParameter, new BigDecimal("-1000000.0001"), -1000000, 0); - alltypes.setlong(100); - run_longQuery(long_filterObj, AllTypesParameter, alltypes, 100, 2); - run_longQuery(long_filterVal, null, null, 1000000, 1); - - run_floatQuery(float_filterL, floatParameter, Float.valueOf(-234.23f), -234.23f, 1); - run_floatQuery(float_filterR, floatParameter, Float.valueOf(-234.23f), -234.23f, 1); - run_floatQuery(float_filterL, FloatParameter, Float.valueOf((float) 0.0), 0.0f, 1); - run_floatQuery(float_filterR, FloatParameter, Float.valueOf((float) 4.0), 4.0f, 0); - run_floatQuery(float_filterL, byteParameter, Byte.valueOf((byte) 0), 0.0f, 1); - run_floatQuery(float_filterR, byteParameter, Byte.valueOf((byte) 23), 23.0f, 0); - run_floatQuery(float_filterL, ByteParameter, Byte.valueOf((byte) 34), 34.0f, 0); - run_floatQuery(float_filterR, ByteParameter, Byte.valueOf((byte) 100), 100.0f, 2); - run_floatQuery(float_filterL, shortParameter, Short.valueOf((short) 0), 0.0f, 1); - run_floatQuery(float_filterR, shortParameter, Short.valueOf((short) 23), 23.0f, 0); - run_floatQuery(float_filterL, ShortParameter, Short.valueOf((short) 34), 34.0f, 0); - run_floatQuery(float_filterR, ShortParameter, Short.valueOf((short) 100), 100.0f, 2); - run_floatQuery(float_filterL, charParameter, Character.valueOf((char) 0), 0.0f, 1); - run_floatQuery(float_filterR, charParameter, Character.valueOf((char) 23), 23.0f, 0); - run_floatQuery(float_filterL, CharacterParameter, Character.valueOf((char) 34), 34.0f, 0); - run_floatQuery(float_filterR, CharacterParameter, Character.valueOf((char) 100), 100.0f, 2); - run_floatQuery(float_filterL, intParameter, Integer.valueOf(50000000), 50000000.0f, 1); - run_floatQuery(float_filterR, intParameter, Integer.valueOf(23), 23.0f, 0); - run_floatQuery(float_filterL, IntegerParameter, Integer.valueOf(34), 34.0f, 0); - run_floatQuery(float_filterR, IntegerParameter, Integer.valueOf(100), 100.0f, 2); - run_floatQuery(float_filterL, longParameter, Long.valueOf(50000000), 50000000.0f, 1); - run_floatQuery(float_filterR, longParameter, Long.valueOf(23), 23.0f, 0); - run_floatQuery(float_filterL, LongParameter, Long.valueOf(34), 34.0f, 0); - run_floatQuery(float_filterR, LongParameter, Long.valueOf(100), 100.0f, 2); - run_floatQuery(float_filterL, doubleParameter, Double.valueOf(50000000.0), 50000000.0f, 1); - run_floatQuery(float_filterR, doubleParameter, Double.valueOf(-25.5), -25.5f, 1); - run_floatQuery(float_filterL, DoubleParameter, Double.valueOf(0.0), 0.0f, 1); - run_floatQuery(float_filterR, DoubleParameter, Double.valueOf(100.0), 100.0f, 2); - run_floatQuery(float_filterL, BigIntegerParameter, new BigInteger("0"), 0.0f, 1); - run_floatQuery( - float_filterR, BigIntegerParameter, new BigInteger("1000000000"), 1000000000.0f, 1); - run_floatQuery(float_filterL, BigDecimalParameter, new BigDecimal("350.5"), 350.5f, 1); - run_floatQuery( - float_filterR, BigDecimalParameter, new BigDecimal("50000000.0"), 50000000.0f, 1); - alltypes.setfloat(23.23f); - run_floatQuery(float_filterObj, AllTypesParameter, alltypes, 23.23f, 0); - run_floatQuery(float_filterVal, null, null, 100.0f, 2); - - run_doubleQuery(double_filterL, doubleParameter, Double.valueOf(-234234.234), -234234.234, 1); - run_doubleQuery(double_filterR, doubleParameter, Double.valueOf(-234234.234), -234234.234, 1); - run_doubleQuery(double_filterL, DoubleParameter, Double.valueOf(0.0), 0.0, 1); - run_doubleQuery(double_filterR, DoubleParameter, Double.valueOf(23.34), 23.34, 0); - run_doubleQuery(double_filterL, byteParameter, Byte.valueOf((byte) 100), 100.0, 2); - run_doubleQuery(double_filterR, byteParameter, Byte.valueOf((byte) 0), 0.0, 1); - run_doubleQuery(double_filterL, ByteParameter, Byte.valueOf((byte) 23), 23.0, 0); - run_doubleQuery(double_filterR, ByteParameter, Byte.valueOf((byte) 100), 100.0, 2); - run_doubleQuery(double_filterL, shortParameter, Short.valueOf((short) 100), 100.0, 2); - run_doubleQuery(double_filterR, shortParameter, Short.valueOf((short) 0), 0.0, 1); - run_doubleQuery(double_filterL, ShortParameter, Short.valueOf((short) 23), 23.0, 0); - run_doubleQuery(double_filterR, ShortParameter, Short.valueOf((short) 100), 100.0, 2); - run_doubleQuery(double_filterL, intParameter, Integer.valueOf(100), 100.0, 2); - run_doubleQuery(double_filterR, intParameter, Integer.valueOf(0), 0.0, 1); - run_doubleQuery(double_filterL, IntegerParameter, Integer.valueOf(23), 23.0, 0); - run_doubleQuery(double_filterR, IntegerParameter, Integer.valueOf(100), 100.0, 2); - run_doubleQuery(double_filterL, longParameter, Long.valueOf(100), 100.0, 2); - run_doubleQuery(double_filterR, longParameter, Long.valueOf(0), 0.0, 1); - run_doubleQuery(double_filterL, LongParameter, Long.valueOf(23), 23.0, 0); - run_doubleQuery(double_filterR, LongParameter, Long.valueOf(100), 100.0, 2); - run_doubleQuery(double_filterL, floatParameter, Float.valueOf(0.0f), 0.0f, 1); - run_doubleQuery(double_filterR, floatParameter, Float.valueOf(100.0f), 100.0f, 2); - run_doubleQuery(double_filterL, FloatParameter, Float.valueOf(100.0f), 100.0, 2); - run_doubleQuery(double_filterR, FloatParameter, Float.valueOf(69.96f), 69.96, 0); - run_doubleQuery( - double_filterL, BigIntegerParameter, new BigInteger("50000000"), 50000000.0f, 1); - run_doubleQuery( - double_filterR, BigIntegerParameter, new BigInteger("1000000000"), 1000000000.0f, 1); - run_doubleQuery(double_filterL, BigDecimalParameter, new BigDecimal("350.5"), 350.5f, 1); - run_doubleQuery( - double_filterR, BigDecimalParameter, new BigDecimal("50000000.0"), 50000000.0f, 1); - alltypes.setdouble(-25.5); - run_doubleQuery(double_filterObj, AllTypesParameter, alltypes, -25.5, 1); - run_doubleQuery(double_filterVal, null, null, 100.0, 2); + *Title: Equality Operator Support + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-14. + *
    + *Assertion Description: +The equal operator (==) is supported for the following types: +
      +
    • byte, short, int, long, char, Byte, Short Integer, Long, Character
    • +
    • float, double, Float, Double
    • +
    • BigDecimal, BigInteger
    • +
    • Boolean, boolean
    • +
    • any class instance or array
    • +
    • Date, String
    • +
    +The operation on object-valued fields of wrapper types (Boolean, Byte, +Short, Integer, Long, Float, and Double), and numeric types +(BigDecimal and BigInteger) use the wrapped values +as operands. Equality comparison of object-valued fields of +PersistenceCapable types use the JDO Identity comparison +of the references. Thus, two objects will compare equal if they have the same +JDO Identity. Equality comparison of object-valued fields of +non-PersistenceCapable types uses the equals +method of the field type. - run_BooleanQuery(Boolean_filterL, booleanParameter, Boolean.TRUE, Boolean.TRUE, 4); - run_BooleanQuery(Boolean_filterL, booleanParameter, Boolean.FALSE, Boolean.FALSE, 6); - run_BooleanQuery(Boolean_filterR, booleanParameter, Boolean.TRUE, Boolean.TRUE, 4); - run_BooleanQuery(Boolean_filterR, booleanParameter, Boolean.FALSE, Boolean.FALSE, 6); - run_BooleanQuery(Boolean_filterL, BooleanParameter, Boolean.TRUE, Boolean.TRUE, 4); - run_BooleanQuery(Boolean_filterL, BooleanParameter, Boolean.FALSE, Boolean.FALSE, 6); - run_BooleanQuery(Boolean_filterR, BooleanParameter, Boolean.TRUE, Boolean.TRUE, 4); - run_BooleanQuery(Boolean_filterR, BooleanParameter, Boolean.FALSE, Boolean.FALSE, 6); - run_BooleanQuery(Boolean_filterT, null, Boolean.TRUE, Boolean.TRUE, 4); - run_BooleanQuery(Boolean_filterF, null, Boolean.FALSE, Boolean.FALSE, 6); - alltypes.setBoolean(Boolean.TRUE); - run_BooleanQuery(Boolean_filterObj, AllTypesParameter, alltypes, Boolean.TRUE, 4); - alltypes.setBoolean(Boolean.FALSE); - run_BooleanQuery(Boolean_filterObj, AllTypesParameter, alltypes, Boolean.FALSE, 6); - - run_ByteQuery(Byte_filterL, byteParameter, Byte.valueOf((byte) 50), Byte.valueOf((byte) 50), 2); - run_ByteQuery( - Byte_filterR, byteParameter, Byte.valueOf(Byte.MIN_VALUE), Byte.valueOf(Byte.MIN_VALUE), 1); - run_ByteQuery(Byte_filterL, ByteParameter, Byte.valueOf((byte) 20), Byte.valueOf((byte) 20), 0); - run_ByteQuery( - Byte_filterR, ByteParameter, Byte.valueOf(Byte.MAX_VALUE), Byte.valueOf(Byte.MAX_VALUE), 1); - run_ByteQuery( - Byte_filterL, shortParameter, Short.valueOf((short) 50), Byte.valueOf((byte) 50), 2); - run_ByteQuery( - Byte_filterR, shortParameter, Short.valueOf((short) 50), Byte.valueOf((byte) 50), 2); - run_ByteQuery( - Byte_filterL, ShortParameter, Short.valueOf((short) -100), Byte.valueOf((byte) -100), 1); - run_ByteQuery( - Byte_filterR, ShortParameter, Short.valueOf((short) -100), Byte.valueOf((byte) -100), 1); - run_ByteQuery( - Byte_filterL, charParameter, Character.valueOf((char) 50), Byte.valueOf((byte) 50), 2); - run_ByteQuery( - Byte_filterR, charParameter, Character.valueOf((char) 50), Byte.valueOf((byte) 50), 2); - run_ByteQuery( - Byte_filterL, CharacterParameter, Character.valueOf((char) 50), Byte.valueOf((byte) 50), 2); - run_ByteQuery( - Byte_filterR, CharacterParameter, Character.valueOf((char) 75), Byte.valueOf((byte) 75), 1); - run_ByteQuery(Byte_filterL, intParameter, Integer.valueOf(50), Byte.valueOf((byte) 50), 2); - run_ByteQuery(Byte_filterR, intParameter, Integer.valueOf(50), Byte.valueOf((byte) 50), 2); - run_ByteQuery(Byte_filterL, IntegerParameter, Integer.valueOf(50), Byte.valueOf((byte) 50), 2); - run_ByteQuery(Byte_filterR, IntegerParameter, Integer.valueOf(75), Byte.valueOf((byte) 75), 1); - run_ByteQuery(Byte_filterL, longParameter, Long.valueOf(50), Byte.valueOf((byte) 50), 2); - run_ByteQuery(Byte_filterR, longParameter, Long.valueOf(50), Byte.valueOf((byte) 50), 2); - run_ByteQuery(Byte_filterL, LongParameter, Long.valueOf(-100), Byte.valueOf((byte) -100), 1); - run_ByteQuery(Byte_filterR, LongParameter, Long.valueOf(-100), Byte.valueOf((byte) -100), 1); - run_ByteQuery( - Byte_filterL, floatParameter, Float.valueOf((float) 50), Byte.valueOf((byte) 50), 2); - run_ByteQuery( - Byte_filterR, floatParameter, Float.valueOf((float) 50), Byte.valueOf((byte) 50), 2); - run_ByteQuery( - Byte_filterL, FloatParameter, Float.valueOf((float) -100), Byte.valueOf((byte) -100), 1); - run_ByteQuery( - Byte_filterR, FloatParameter, Float.valueOf((float) -100), Byte.valueOf((byte) -100), 1); - run_ByteQuery(Byte_filterL, doubleParameter, Double.valueOf(50), Byte.valueOf((byte) 50), 2); - run_ByteQuery(Byte_filterR, doubleParameter, Double.valueOf(50), Byte.valueOf((byte) 50), 2); - run_ByteQuery( - Byte_filterL, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte) -100), 1); - run_ByteQuery( - Byte_filterR, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte) -100), 1); - run_ByteQuery( - Byte_filterL, BigIntegerParameter, new BigInteger("50"), Byte.valueOf((byte) 50), 2); - run_ByteQuery( - Byte_filterR, BigIntegerParameter, new BigInteger("-100"), Byte.valueOf((byte) -100), 1); - run_ByteQuery( - Byte_filterL, BigDecimalParameter, new BigDecimal("100.0"), Byte.valueOf((byte) 100), 1); - run_ByteQuery( - Byte_filterR, BigDecimalParameter, new BigDecimal("10.0001"), Byte.valueOf((byte) 10), 0); - Byte val = Byte.valueOf((byte) 50); - alltypes.setByte(val); - run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, 2); - val = Byte.valueOf((byte) 45); - alltypes.setByte(val); - run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, 0); - run_ByteQuery(Byte_filterVal, null, null, Byte.valueOf((byte) 100), 1); - - run_ShortQuery( - Short_filterL, shortParameter, Short.valueOf((short) 100), Short.valueOf((short) 100), 2); - run_ShortQuery( - Short_filterR, shortParameter, Short.valueOf((short) 100), Short.valueOf((short) 100), 2); - run_ShortQuery( - Short_filterL, - ShortParameter, - Short.valueOf(Short.MIN_VALUE), - Short.valueOf(Short.MIN_VALUE), - 1); - run_ShortQuery( - Short_filterR, ShortParameter, Short.valueOf((short) 253), Short.valueOf((short) 253), 0); - run_ShortQuery( - Short_filterR, shortParameter, Short.valueOf((short) 1000), Short.valueOf((short) 1000), 1); - run_ShortQuery( - Short_filterL, byteParameter, Byte.valueOf((byte) 75), Short.valueOf((short) 75), 0); - run_ShortQuery( - Short_filterR, byteParameter, Byte.valueOf((byte) 75), Short.valueOf((short) 75), 0); - run_ShortQuery( - Short_filterL, ByteParameter, Byte.valueOf((byte) 100), Short.valueOf((short) 100), 2); - run_ShortQuery( - Short_filterR, ByteParameter, Byte.valueOf((byte) 100), Short.valueOf((short) 100), 2); - run_ShortQuery( - Short_filterL, charParameter, Character.valueOf((char) 75), Short.valueOf((short) 75), 0); - run_ShortQuery( - Short_filterR, charParameter, Character.valueOf((char) 75), Short.valueOf((short) 75), 0); - run_ShortQuery( - Short_filterL, - CharacterParameter, - Character.valueOf((char) 100), - Short.valueOf((short) 100), - 2); - run_ShortQuery( - Short_filterR, - CharacterParameter, - Character.valueOf((char) 100), - Short.valueOf((short) 100), - 2); - run_ShortQuery( - Short_filterL, intParameter, Integer.valueOf(-10000), Short.valueOf((short) -10000), 1); - run_ShortQuery( - Short_filterR, intParameter, Integer.valueOf(-10000), Short.valueOf((short) -10000), 1); - run_ShortQuery( - Short_filterL, IntegerParameter, Integer.valueOf(10000), Short.valueOf((short) 10000), 1); - run_ShortQuery( - Short_filterR, IntegerParameter, Integer.valueOf(10000), Short.valueOf((short) 10000), 1); - run_ShortQuery( - Short_filterL, longParameter, Long.valueOf(10000), Short.valueOf((short) 10000), 1); - run_ShortQuery( - Short_filterR, longParameter, Long.valueOf(10000), Short.valueOf((short) 10000), 1); - run_ShortQuery(Short_filterL, LongParameter, Long.valueOf(100), Short.valueOf((short) 100), 2); - run_ShortQuery(Short_filterR, LongParameter, Long.valueOf(100), Short.valueOf((short) 100), 2); - run_ShortQuery( - Short_filterL, - floatParameter, - Float.valueOf((float) 23000), - Short.valueOf((short) 23000), - 0); - run_ShortQuery( - Short_filterR, - floatParameter, - Float.valueOf((float) 23000), - Short.valueOf((short) 23000), - 0); - run_ShortQuery( - Short_filterL, FloatParameter, Float.valueOf((float) 100), Short.valueOf((short) 100), 2); - run_ShortQuery( - Short_filterR, FloatParameter, Float.valueOf((float) 100), Short.valueOf((short) 100), 2); - run_ShortQuery( - Short_filterL, doubleParameter, Double.valueOf(-10000), Short.valueOf((short) -10000), 1); - run_ShortQuery( - Short_filterR, doubleParameter, Double.valueOf(-10000), Short.valueOf((short) -10000), 1); - run_ShortQuery( - Short_filterL, DoubleParameter, Double.valueOf(23), Short.valueOf((short) 23), 0); - run_ShortQuery( - Short_filterR, DoubleParameter, Double.valueOf(23), Short.valueOf((short) 23), 0); - run_ShortQuery( - Short_filterL, BigIntegerParameter, new BigInteger("999"), Short.valueOf((short) 999), 0); - run_ShortQuery( - Short_filterR, - BigIntegerParameter, - new BigInteger("-1000"), - Short.valueOf((short) -1000), - 1); - run_ShortQuery( - Short_filterL, BigDecimalParameter, new BigDecimal("100.0"), Short.valueOf((short) 100), 2); - run_ShortQuery( - Short_filterR, BigDecimalParameter, new BigDecimal("101.0"), Short.valueOf((short) 100), 0); - Short sval = Short.valueOf((short) 100); - alltypes.setShort(sval); - run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, 2); - sval = Short.valueOf((short) 23); - alltypes.setShort(sval); - run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, 0); - run_ShortQuery(Short_filterVal, null, null, Short.valueOf((short) -1000), 1); - - run_CharacterQuery( - Character_filterL, - charParameter, - Character.valueOf(Character.MIN_VALUE), - Character.valueOf(Character.MIN_VALUE), - 1); - run_CharacterQuery( - Character_filterR, - charParameter, - Character.valueOf(Character.MAX_VALUE), - Character.valueOf(Character.MAX_VALUE), - 1); - run_CharacterQuery( - Character_filterL, charParameter, Character.valueOf('C'), Character.valueOf('C'), 0); - run_CharacterQuery( - Character_filterR, charParameter, Character.valueOf('z'), Character.valueOf('z'), 2); - run_CharacterQuery( - Character_filterL, CharacterParameter, Character.valueOf(' '), Character.valueOf(' '), 1); - run_CharacterQuery( - Character_filterR, CharacterParameter, Character.valueOf('f'), Character.valueOf('f'), 0); - run_CharacterQuery( - Character_filterL, - byteParameter, - Byte.valueOf((byte) Character.MIN_VALUE), - Character.valueOf((char) Character.MIN_VALUE), - 1); - run_CharacterQuery( - Character_filterR, ByteParameter, Byte.valueOf((byte) 'a'), Character.valueOf('a'), 0); - run_CharacterQuery( - Character_filterL, shortParameter, Short.valueOf((short) 'M'), Character.valueOf('M'), 2); - run_CharacterQuery( - Character_filterR, shortParameter, Short.valueOf((short) 'F'), Character.valueOf('F'), 1); - run_CharacterQuery( - Character_filterL, ShortParameter, Short.valueOf((short) 'A'), Character.valueOf('A'), 1); - run_CharacterQuery( - Character_filterR, ShortParameter, Short.valueOf((short) 'A'), Character.valueOf('A'), 1); - run_CharacterQuery( - Character_filterL, intParameter, Integer.valueOf('z'), Character.valueOf('z'), 2); - run_CharacterQuery( - Character_filterR, intParameter, Integer.valueOf('z'), Character.valueOf('z'), 2); - run_CharacterQuery( - Character_filterL, IntegerParameter, Integer.valueOf('B'), Character.valueOf('B'), 1); - run_CharacterQuery( - Character_filterR, IntegerParameter, Integer.valueOf('B'), Character.valueOf('B'), 1); - run_CharacterQuery( - Character_filterL, longParameter, Long.valueOf('z'), Character.valueOf('z'), 2); - run_CharacterQuery( - Character_filterR, longParameter, Long.valueOf('z'), Character.valueOf('z'), 2); - run_CharacterQuery( - Character_filterL, LongParameter, Long.valueOf('B'), Character.valueOf('B'), 1); - run_CharacterQuery( - Character_filterR, LongParameter, Long.valueOf('B'), Character.valueOf('B'), 1); - run_CharacterQuery( - Character_filterL, - floatParameter, - Float.valueOf((float) 123.222), - Character.valueOf('x'), - 0); - run_CharacterQuery( - Character_filterR, - floatParameter, - Float.valueOf((float) 123.222), - Character.valueOf('x'), - 0); - run_CharacterQuery( - Character_filterL, FloatParameter, Float.valueOf((float) 'z'), Character.valueOf('z'), 2); - run_CharacterQuery( - Character_filterR, FloatParameter, Float.valueOf((float) 'z'), Character.valueOf('z'), 2); - run_CharacterQuery( - Character_filterL, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), 1); - run_CharacterQuery( - Character_filterR, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), 1); - run_CharacterQuery( - Character_filterL, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), 1); - run_CharacterQuery( - Character_filterR, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), 1); - run_CharacterQuery( - Character_filterL, - BigIntegerParameter, - new BigInteger("65"), - Character.valueOf('A'), - 1); // 'A' == 65 - run_CharacterQuery( - Character_filterR, - BigIntegerParameter, - new BigInteger("122"), - Character.valueOf('z'), - 2); // 'z' == 122 - run_CharacterQuery( - Character_filterL, BigDecimalParameter, new BigDecimal("65.0"), Character.valueOf('A'), 1); - run_CharacterQuery( - Character_filterR, - BigDecimalParameter, - new BigDecimal("77.0"), - Character.valueOf('M'), - 2); // 'M' == 77 - alltypes.setCharacter(Character.valueOf('A')); - run_CharacterQuery(Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('A'), 1); - alltypes.setCharacter(Character.valueOf('b')); - run_CharacterQuery(Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('b'), 0); - run_CharacterQuery(Character_filterVal, null, null, Character.valueOf('z'), 2); - - run_IntegerQuery( - Integer_filterL, - intParameter, - Integer.valueOf(AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - 1); - run_IntegerQuery( - Integer_filterR, - intParameter, - Integer.valueOf(AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - 1); - run_IntegerQuery(Integer_filterR, intParameter, Integer.valueOf(23), Integer.valueOf(23), 0); - run_IntegerQuery( - Integer_filterL, IntegerParameter, Integer.valueOf(1000000), Integer.valueOf(1000000), 1); - run_IntegerQuery( - Integer_filterR, IntegerParameter, Integer.valueOf(1000), Integer.valueOf(1000), 1); - run_IntegerQuery( - Integer_filterL, byteParameter, Byte.valueOf((byte) 100), Integer.valueOf(100), 2); - run_IntegerQuery(Integer_filterR, byteParameter, Byte.valueOf((byte) 0), Integer.valueOf(0), 1); - run_IntegerQuery( - Integer_filterL, ByteParameter, Byte.valueOf((byte) 100), Integer.valueOf(100), 2); - run_IntegerQuery(Integer_filterR, ByteParameter, Byte.valueOf((byte) 0), Integer.valueOf(0), 1); - run_IntegerQuery( - Integer_filterL, shortParameter, Short.valueOf((short) 10000), Integer.valueOf(10000), 1); - run_IntegerQuery( - Integer_filterR, shortParameter, Short.valueOf((short) -1000), Integer.valueOf(-1000), 1); - run_IntegerQuery( - Integer_filterL, ShortParameter, Short.valueOf((short) -1000), Integer.valueOf(-1000), 1); - run_IntegerQuery( - Integer_filterL, charParameter, Character.valueOf((char) 10000), Integer.valueOf(10000), 1); - run_IntegerQuery( - Integer_filterR, charParameter, Character.valueOf((char) 10000), Integer.valueOf(10000), 1); - run_IntegerQuery( - Integer_filterL, - CharacterParameter, - Character.valueOf((char) 100), - Integer.valueOf(100), - 2); - run_IntegerQuery( - Integer_filterR, - CharacterParameter, - Character.valueOf((char) 10000), - Integer.valueOf(10000), - 1); - run_IntegerQuery( - Integer_filterL, - longParameter, - Long.valueOf(AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - 1); - run_IntegerQuery( - Integer_filterR, - longParameter, - Long.valueOf(AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - 1); - run_IntegerQuery( - Integer_filterL, LongParameter, Long.valueOf(10000), Integer.valueOf(10000), 1); - run_IntegerQuery(Integer_filterR, LongParameter, Long.valueOf(43), Integer.valueOf(43), 0); - run_IntegerQuery( - Integer_filterL, - floatParameter, - Float.valueOf((float) AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - 1); - run_IntegerQuery( - Integer_filterR, - floatParameter, - Float.valueOf((float) AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - 1); - run_IntegerQuery( - Integer_filterL, FloatParameter, Float.valueOf((float) 10000), Integer.valueOf(10000), 1); - run_IntegerQuery( - Integer_filterR, FloatParameter, Float.valueOf((float) 43), Integer.valueOf(43), 0); - run_IntegerQuery( - Integer_filterL, - doubleParameter, - Double.valueOf(AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - 1); - run_IntegerQuery( - Integer_filterR, - doubleParameter, - Double.valueOf(AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - 1); - run_IntegerQuery( - Integer_filterL, DoubleParameter, Double.valueOf(10000), Integer.valueOf(10000), 1); - run_IntegerQuery(Integer_filterR, DoubleParameter, Double.valueOf(43), Integer.valueOf(43), 0); - run_IntegerQuery( - Integer_filterL, - BigIntegerParameter, - new BigInteger("1000000"), - Integer.valueOf(1000000), - 1); - run_IntegerQuery( - Integer_filterR, - BigIntegerParameter, - new BigInteger("-1000000"), - Integer.valueOf(-1000000), - 1); - run_IntegerQuery( - Integer_filterL, - BigDecimalParameter, - new BigDecimal("1000000.0"), - Integer.valueOf(1000000), - 1); - run_IntegerQuery( - Integer_filterR, - BigDecimalParameter, - new BigDecimal("-1000000.01"), - Integer.valueOf(-1000000), - 0); - alltypes.setInteger(Integer.valueOf(100)); - run_IntegerQuery(Integer_filterObj, AllTypesParameter, alltypes, Integer.valueOf(100), 2); - run_IntegerQuery(Integer_filterVal, null, null, Integer.valueOf(100), 2); - - run_LongQuery( - Long_filterL, longParameter, Long.valueOf(Long.MIN_VALUE), Long.valueOf(Long.MIN_VALUE), 1); - run_LongQuery( - Long_filterR, longParameter, Long.valueOf(Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE), 1); - run_LongQuery(Long_filterL, LongParameter, Long.valueOf(100), Long.valueOf(100), 2); - run_LongQuery(Long_filterR, LongParameter, Long.valueOf(23), Long.valueOf(23), 0); - run_LongQuery(Long_filterL, byteParameter, Byte.valueOf((byte) 100), Long.valueOf(100), 2); - run_LongQuery(Long_filterR, byteParameter, Byte.valueOf((byte) 0), Long.valueOf(0), 1); - run_LongQuery(Long_filterL, ByteParameter, Byte.valueOf((byte) 100), Long.valueOf(100), 2); - run_LongQuery(Long_filterR, ByteParameter, Byte.valueOf((byte) 0), Long.valueOf(0), 1); - run_LongQuery( - Long_filterL, shortParameter, Short.valueOf((short) -1000), Long.valueOf(-1000), 2); - run_LongQuery(Long_filterR, shortParameter, Short.valueOf((short) 1000), Long.valueOf(1000), 1); - run_LongQuery(Long_filterL, ShortParameter, Short.valueOf((short) 100), Long.valueOf(100), 2); - run_LongQuery(Long_filterR, ShortParameter, Short.valueOf((short) 32), Long.valueOf(32), 0); - run_LongQuery(Long_filterL, charParameter, Character.valueOf((char) 0), Long.valueOf(0), 1); - run_LongQuery(Long_filterR, charParameter, Character.valueOf((char) 100), Long.valueOf(100), 2); - run_LongQuery( - Long_filterL, CharacterParameter, Character.valueOf((char) 23), Long.valueOf(23), 0); - run_LongQuery( - Long_filterR, CharacterParameter, Character.valueOf((char) 0), Long.valueOf(0), 1); - run_LongQuery(Long_filterL, intParameter, Integer.valueOf(100), Long.valueOf(100), 2); - run_LongQuery(Long_filterR, intParameter, Integer.valueOf(0), Long.valueOf(0), 1); - run_LongQuery(Long_filterL, IntegerParameter, Integer.valueOf(23), Long.valueOf(23), 0); - run_LongQuery( - Long_filterR, IntegerParameter, Integer.valueOf(1000000), Long.valueOf(1000000), 1); - run_LongQuery(Long_filterL, longParameter, Long.valueOf(100), Long.valueOf(100), 2); - run_LongQuery(Long_filterR, longParameter, Long.valueOf(0), Long.valueOf(0), 1); - run_LongQuery(Long_filterL, LongParameter, Long.valueOf(23), Long.valueOf(23), 0); - run_LongQuery(Long_filterR, LongParameter, Long.valueOf(1000000), Long.valueOf(1000000), 1); - run_LongQuery( - Long_filterL, floatParameter, Float.valueOf((float) -1000000.0), Long.valueOf(-1000000), 1); - // run_LongQuery(Long_filterR, floatParameter, Float.valueOf((float)Long.MAX_VALUE), - // Long.valueOf(Long.MAX_VALUE), 1); - run_LongQuery(Long_filterL, FloatParameter, Float.valueOf((float) 100), Long.valueOf(100), 2); - run_LongQuery(Long_filterR, FloatParameter, Float.valueOf((float) 32), Long.valueOf(32), 0); - run_LongQuery( - Long_filterL, doubleParameter, Double.valueOf(-1000000.0), Long.valueOf(-1000000), 1); - // run_LongQuery(Long_filterR, doubleParameter, Double.valueOf((double)Long.MAX_VALUE), - // Long.valueOf(Long.MAX_VALUE), 1); - run_LongQuery(Long_filterL, DoubleParameter, Double.valueOf(100), Long.valueOf(100), 2); - run_LongQuery(Long_filterR, DoubleParameter, Double.valueOf(32), Long.valueOf(32), 0); - run_LongQuery( - Long_filterL, BigIntegerParameter, new BigInteger("1000000"), Long.valueOf(1000000), 1); - run_LongQuery( - Long_filterR, BigIntegerParameter, new BigInteger("-1000000"), Long.valueOf(-1000000), 1); - run_LongQuery( - Long_filterL, BigDecimalParameter, new BigDecimal("1000000.0"), Long.valueOf(1000000), 1); - run_LongQuery( - Long_filterR, - BigDecimalParameter, - new BigDecimal("-1000000.0001"), - Long.valueOf(-1000000), - 0); - alltypes.setLong(Long.valueOf(100)); - run_LongQuery(Long_filterObj, AllTypesParameter, alltypes, Long.valueOf(100), 2); - run_LongQuery(Long_filterVal, null, null, Long.valueOf(-1000), 2); - - run_FloatQuery(Float_filterL, floatParameter, Float.valueOf(350.5f), Float.valueOf(350.5f), 1); - run_FloatQuery(Float_filterR, floatParameter, Float.valueOf(350.5f), Float.valueOf(350.5f), 1); - run_FloatQuery( - Float_filterL, FloatParameter, Float.valueOf((float) 0.0), Float.valueOf(0.0f), 1); - run_FloatQuery( - Float_filterR, FloatParameter, Float.valueOf((float) 4.0), Float.valueOf(4.0f), 0); - run_FloatQuery(Float_filterL, byteParameter, Byte.valueOf((byte) 0), Float.valueOf(0.0f), 1); - run_FloatQuery(Float_filterR, byteParameter, Byte.valueOf((byte) 23), Float.valueOf(23.0f), 0); - run_FloatQuery(Float_filterL, ByteParameter, Byte.valueOf((byte) 34), Float.valueOf(34.0f), 0); - run_FloatQuery( - Float_filterR, ByteParameter, Byte.valueOf((byte) 100), Float.valueOf(100.0f), 2); - run_FloatQuery(Float_filterL, shortParameter, Short.valueOf((short) 0), Float.valueOf(0.0f), 1); - run_FloatQuery( - Float_filterR, shortParameter, Short.valueOf((short) 23), Float.valueOf(23.0f), 0); - run_FloatQuery( - Float_filterL, ShortParameter, Short.valueOf((short) 34), Float.valueOf(34.0f), 0); - run_FloatQuery( - Float_filterR, ShortParameter, Short.valueOf((short) 100), Float.valueOf(100.0f), 2); - run_FloatQuery( - Float_filterL, charParameter, Character.valueOf((char) 0), Float.valueOf(0.0f), 1); - run_FloatQuery( - Float_filterR, charParameter, Character.valueOf((char) 23), Float.valueOf(23.0f), 0); - run_FloatQuery( - Float_filterL, CharacterParameter, Character.valueOf((char) 34), Float.valueOf(34.0f), 0); - run_FloatQuery( - Float_filterR, CharacterParameter, Character.valueOf((char) 100), Float.valueOf(100.0f), 2); - run_FloatQuery( - Float_filterL, intParameter, Integer.valueOf(50000000), Float.valueOf(50000000.0f), 1); - run_FloatQuery(Float_filterR, intParameter, Integer.valueOf(23), Float.valueOf(23.0f), 0); - run_FloatQuery(Float_filterL, IntegerParameter, Integer.valueOf(34), Float.valueOf(34.0f), 0); - run_FloatQuery(Float_filterR, IntegerParameter, Integer.valueOf(100), Float.valueOf(100.0f), 2); - run_FloatQuery( - Float_filterL, longParameter, Long.valueOf(50000000), Float.valueOf(50000000.0f), 1); - run_FloatQuery(Float_filterR, longParameter, Long.valueOf(23), Float.valueOf(23.0f), 0); - run_FloatQuery(Float_filterL, LongParameter, Long.valueOf(34), Float.valueOf(34.0f), 0); - run_FloatQuery(Float_filterR, LongParameter, Long.valueOf(100), Float.valueOf(100.0f), 2); - run_FloatQuery( - Float_filterL, doubleParameter, Double.valueOf(50000000.0f), Float.valueOf(50000000.0f), 1); - run_FloatQuery( - Float_filterR, doubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), 2); - run_FloatQuery(Float_filterL, DoubleParameter, Double.valueOf(0.0f), Float.valueOf(0.0f), 1); - run_FloatQuery( - Float_filterR, DoubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), 2); - run_FloatQuery( - Float_filterL, - BigIntegerParameter, - new BigInteger("50000000"), - Float.valueOf(50000000.0f), - 1); - run_FloatQuery( - Float_filterR, - BigIntegerParameter, - new BigInteger("1000000000"), - Float.valueOf(1000000000.0f), - 1); - run_FloatQuery( - Float_filterL, BigDecimalParameter, new BigDecimal("350.5"), Float.valueOf(350.5f), 1); - run_FloatQuery( - Float_filterR, - BigDecimalParameter, - new BigDecimal("50000000.0"), - Float.valueOf(50000000.0f), - 1); - alltypes.setFloat(Float.valueOf(23.23f)); - run_FloatQuery(Float_filterObj, AllTypesParameter, alltypes, Float.valueOf(23.23f), 0); - run_FloatQuery(Float_filterVal, null, null, Float.valueOf(100.0f), 2); - - run_DoubleQuery( - Double_filterL, doubleParameter, Double.valueOf(350.5), Double.valueOf(350.5), 1); - run_DoubleQuery( - Double_filterR, doubleParameter, Double.valueOf(350.5), Double.valueOf(350.5), 1); - run_DoubleQuery(Double_filterL, DoubleParameter, Double.valueOf(0.0), Double.valueOf(0.0), 1); - run_DoubleQuery( - Double_filterR, DoubleParameter, Double.valueOf(23.34), Double.valueOf(23.34), 0); - run_DoubleQuery( - Double_filterL, byteParameter, Byte.valueOf((byte) 100), Double.valueOf(100.0), 2); - run_DoubleQuery(Double_filterR, byteParameter, Byte.valueOf((byte) 0), Double.valueOf(0.0), 1); - run_DoubleQuery( - Double_filterL, ByteParameter, Byte.valueOf((byte) 23), Double.valueOf(23.0), 0); - run_DoubleQuery( - Double_filterR, ByteParameter, Byte.valueOf((byte) 100), Double.valueOf(100.0), 2); - run_DoubleQuery( - Double_filterL, shortParameter, Short.valueOf((short) 100), Double.valueOf(100.0), 2); - run_DoubleQuery( - Double_filterR, shortParameter, Short.valueOf((short) 0), Double.valueOf(0.0), 1); - run_DoubleQuery( - Double_filterL, ShortParameter, Short.valueOf((short) 23), Double.valueOf(23.0), 0); - run_DoubleQuery( - Double_filterR, ShortParameter, Short.valueOf((short) 100), Double.valueOf(100.0), 2); - run_DoubleQuery( - Double_filterL, charParameter, Character.valueOf((char) 100), Double.valueOf(100.0), 2); - run_DoubleQuery( - Double_filterR, charParameter, Character.valueOf((char) 0), Double.valueOf(0.0), 1); - run_DoubleQuery( - Double_filterL, CharacterParameter, Character.valueOf((char) 23), Double.valueOf(23.0), 0); - run_DoubleQuery( - Double_filterR, - CharacterParameter, - Character.valueOf((char) 100), - Double.valueOf(100.0), - 2); - run_DoubleQuery(Double_filterL, intParameter, Integer.valueOf(100), Double.valueOf(100.0), 2); - run_DoubleQuery(Double_filterR, intParameter, Integer.valueOf(0), Double.valueOf(0.0), 1); - run_DoubleQuery(Double_filterL, IntegerParameter, Integer.valueOf(23), Double.valueOf(23.0), 0); - run_DoubleQuery( - Double_filterR, IntegerParameter, Integer.valueOf(100), Double.valueOf(100.0), 2); - run_DoubleQuery(Double_filterL, longParameter, Long.valueOf(100), Double.valueOf(100.0), 2); - run_DoubleQuery(Double_filterR, longParameter, Long.valueOf(0), Double.valueOf(0.0), 1); - run_DoubleQuery(Double_filterL, LongParameter, Long.valueOf(23), Double.valueOf(23.0), 0); - run_DoubleQuery(Double_filterR, LongParameter, Long.valueOf(100), Double.valueOf(100.0), 2); - run_DoubleQuery(Double_filterL, floatParameter, Float.valueOf(0.0f), Double.valueOf(0.0f), 1); - run_DoubleQuery( - Double_filterR, floatParameter, Float.valueOf(100.0f), Double.valueOf(100.0f), 2); - run_DoubleQuery( - Double_filterL, FloatParameter, Float.valueOf(100.0f), Double.valueOf(100.0f), 2); - run_DoubleQuery( - Double_filterR, FloatParameter, Float.valueOf(69.96f), Double.valueOf(69.96), 0); - run_DoubleQuery( - Double_filterL, - BigIntegerParameter, - new BigInteger("50000000"), - Double.valueOf(50000000.0f), - 1); - run_DoubleQuery( - Double_filterR, - BigIntegerParameter, - new BigInteger("1000000000"), - Double.valueOf(1000000000.0f), - 1); - run_DoubleQuery( - Double_filterL, BigDecimalParameter, new BigDecimal("350.5"), Double.valueOf(350.5f), 1); - run_DoubleQuery( - Double_filterR, - BigDecimalParameter, - new BigDecimal("50000000.0"), - Double.valueOf(50000000.0f), - 1); - alltypes.setDouble(Double.valueOf(-25.5)); - run_DoubleQuery(Double_filterObj, AllTypesParameter, alltypes, Double.valueOf(-25.5), 1); - run_DoubleQuery(Double_filterVal, null, null, Double.valueOf(-25.5), 1); - - run_StringQuery(String_filterL, StringParameter, new String("JDO"), new String("JDO"), 1); - run_StringQuery(String_filterR, StringParameter, new String("JDBC"), new String("JDBC"), 0); - alltypes.setString(new String("abcde")); - run_StringQuery(String_filterObj, AllTypesParameter, alltypes, new String("abcde"), 1); - run_StringQuery(String_filterVal1, null, null, new String("Java"), 2); - run_StringQuery(String_filterVal2, null, null, new String(""), 1); - - run_LocaleQuery(Locale_filterL, LocaleParameter, Locale.CANADA_FRENCH, Locale.CANADA_FRENCH, 0); - run_LocaleQuery(Locale_filterR, LocaleParameter, Locale.US, Locale.US, 1); - alltypes.setLocale(Locale.UK); - run_LocaleQuery(Locale_filterObj, AllTypesParameter, alltypes, Locale.UK, 1); - - BigDecimal bd = new BigDecimal("100.0"); - run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, 2); - bd = new BigDecimal("-234234.23333"); - run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, 1); - bd = new BigDecimal("989899.33304953"); - run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, 0); - bd = new BigDecimal("-1123123.22"); - run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, 1); - alltypes.setBigDecimal(bd); - run_BigDecimalQuery(BigDecimal_filterObj, AllTypesParameter, alltypes, bd, 1); - - BigInteger bi = new BigInteger("987034534985043985"); - run_BigIntegerQuery(BigInteger_filterL, BigIntegerParameter, bi, bi, 1); - bi = new BigInteger("-999999999999999999"); - run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, 1); - bi = new BigInteger("-99999999999999999"); - run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, 0); - bi = new BigInteger("1333330"); - alltypes.setBigInteger(bi); - run_BigIntegerQuery(BigInteger_filterObj, AllTypesParameter, alltypes, bi, 1); + */ - GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.UK); - gc.clear(); - gc.set(1999, Calendar.DECEMBER, 31, 9, 0, 0); - Date d = gc.getTime(); - run_DateQuery(Date_filterL, DateParameter, d, d, 1); - gc.set(1992, Calendar.NOVEMBER, 22, 9, 0, 0); - d = gc.getTime(); - run_DateQuery(Date_filterR, DateParameter, d, d, 1); - gc.set(1959, Calendar.OCTOBER, 9, 9, 0, 0); - d = gc.getTime(); - run_DateQuery(Date_filterR, DateParameter, d, d, 0); - gc.set(1995, Calendar.JUNE, 14, 9, 0, 0); - d = gc.getTime(); - alltypes.setDate(d); - run_DateQuery(Date_filterObj, AllTypesParameter, alltypes, d, 1); - } +public class Equality extends ComparisonTests { - private void run_booleanQuery( - String filter, String parameter, Object parameterValue, boolean value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - boolean val = obj.getboolean(); - if (val != value) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns object with incorrect value, retrieved value: " - + val - + ", expected value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private static String boolean_filterL = "value == fld_boolean"; + private static String boolean_filterR = "fld_boolean == value"; + private static String boolean_filterT = "fld_boolean == true"; + private static String boolean_filterF = "false == fld_boolean"; + private static String boolean_filterObj = "value.fld_boolean == fld_boolean"; + + private static String byte_filterL = "value == fld_byte"; + private static String byte_filterR = "fld_byte == value"; + private static String byte_filterObj = "value.fld_byte == fld_byte"; + private static String byte_filterVal = "fld_byte == 100"; + + private static String char_filterL = "value == fld_char"; + private static String char_filterR = "fld_char == value"; + private static String char_filterObj = "value.fld_char == fld_char"; + private static String char_filterVal = "'M' == fld_char"; + + private static String double_filterL = "value == fld_double"; + private static String double_filterR = "fld_double == value"; + private static String double_filterObj = "value.fld_double == fld_double"; + private static String double_filterVal = "fld_double == 100.0"; + + private static String float_filterL = "value == fld_float"; + private static String float_filterR = "fld_float == value"; + private static String float_filterObj = "fld_float == value.fld_float"; + private static String float_filterVal = "fld_float == 100.0"; + + private static String int_filterL = "value == fld_int"; + private static String int_filterR = "fld_int == value"; + private static String int_filterObj = "value.fld_int == fld_int"; + private static String int_filterVal = "fld_int == 1000"; + + private static String long_filterL = "value == fld_long"; + private static String long_filterR = "fld_long == value"; + private static String long_filterObj = "fld_long == value.fld_long"; + private static String long_filterVal = "fld_long == 1000000"; + + private static String short_filterL = "value == fld_short"; + private static String short_filterR = "fld_short == value"; + private static String short_filterObj = "value.fld_short == fld_short"; + private static String short_filterVal = "1000 == fld_short"; + + private static String Boolean_filterL = "value == fld_Boolean"; + private static String Boolean_filterR = "fld_Boolean == value"; + private static String Boolean_filterT = "fld_Boolean == true"; + private static String Boolean_filterF = "false == fld_Boolean"; + private static String Boolean_filterObj = "value.fld_Boolean == fld_Boolean"; + private static String Boolean_filterVal = "fld_Boolean == false"; + + private static String Byte_filterL = "value == fld_Byte"; + private static String Byte_filterR = "fld_Byte == value"; + private static String Byte_filterObj = "fld_Byte == value.fld_Byte"; + private static String Byte_filterVal = "100 == fld_Byte"; + + private static String Character_filterL = "value == fld_Character"; + private static String Character_filterR = "fld_Character == value"; + private static String Character_filterObj = "value.fld_Character == fld_Character"; + private static String Character_filterVal = "fld_Character == 'z'"; + + private static String Double_filterL = "value == fld_Double"; + private static String Double_filterR = "fld_Double == value"; + private static String Double_filterObj = "value.fld_Double == fld_Double"; + private static String Double_filterVal = "fld_Double == -25.5"; + + private static String Float_filterL = "value == fld_Float"; + private static String Float_filterR = "fld_Float == value"; + private static String Float_filterObj = "fld_Float == value.fld_Float"; + private static String Float_filterVal = "100.0f == fld_Float"; + + private static String Integer_filterL = "value == fld_Integer"; + private static String Integer_filterR = "fld_Integer == value"; + private static String Integer_filterObj = "fld_Integer == value.fld_Integer"; + private static String Integer_filterVal = "fld_Integer == 100"; + + private static String Long_filterL = "value == fld_Long"; + private static String Long_filterR = "fld_Long == value"; + private static String Long_filterObj = "value.fld_Long == fld_Long"; + private static String Long_filterVal = "-1000 == fld_Long"; + + private static String Short_filterL = "value == fld_Short"; + private static String Short_filterR = "fld_Short == value"; + private static String Short_filterObj = "fld_Short == value.fld_Short"; + private static String Short_filterVal = "-1000 == fld_Short"; + + private static String String_filterL = "value == fld_String"; + private static String String_filterR = "fld_String == value"; + private static String String_filterObj = "value.fld_String == fld_String"; + private static String String_filterVal1 = "fld_String == \"Java\""; + private static String String_filterVal2 = "fld_String == \"\""; + + private static String Locale_filterL = "value == fld_Locale"; + private static String Locale_filterR = "fld_Locale == value"; + private static String Locale_filterObj = "value.fld_Locale == fld_Locale"; + + private static String Date_filterL = "value == fld_Date"; + private static String Date_filterR = "fld_Date == value"; + private static String Date_filterObj = "fld_Date == value.fld_Date"; + + private static String BigDecimal_filterL = "value == fld_BigDecimal"; + private static String BigDecimal_filterR = "fld_BigDecimal == value"; + private static String BigDecimal_filterObj = "value.fld_BigDecimal == fld_BigDecimal"; + + private static String BigInteger_filterL = "value == fld_BigInteger"; + private static String BigInteger_filterR = "fld_BigInteger == value"; + private static String BigInteger_filterObj = "fld_BigInteger == value.fld_BigInteger"; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-14 (Equality) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Equality.class); } - query.close(query_result); - tx.rollback(); - } - private void run_byteQuery( - String filter, String parameter, Object parameterValue, byte value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - byte val = obj.getbyte(); - if (val != value) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + /** */ + public void test() { + pm = getPM(); + tx = pm.currentTransaction(); + runQueries(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_shortQuery( - String filter, String parameter, Object parameterValue, short value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - short val = obj.getshort(); - if (val != value) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + /** */ + private void runQueries() + { + run_booleanQuery(boolean_filterL, booleanParameter, Boolean.TRUE, true, 4); + run_booleanQuery(boolean_filterL, booleanParameter, Boolean.FALSE, false, 6); + run_booleanQuery(boolean_filterR, booleanParameter, Boolean.TRUE, true, 4); + run_booleanQuery(boolean_filterR, booleanParameter, Boolean.FALSE, false, 6); + run_booleanQuery(boolean_filterL, BooleanParameter, Boolean.TRUE, true, 4); + run_booleanQuery(boolean_filterL, BooleanParameter, Boolean.FALSE, false, 6); + run_booleanQuery(boolean_filterR, BooleanParameter, Boolean.TRUE, true, 4); + run_booleanQuery(boolean_filterR, BooleanParameter, Boolean.FALSE, false, 6); + run_booleanQuery(boolean_filterT, null, null, true, 4); + run_booleanQuery(boolean_filterF, null, null, false, 6); + AllTypes alltypes = new AllTypes(); + alltypes.setboolean(true); + run_booleanQuery(boolean_filterObj, AllTypesParameter, alltypes, true, 4); + alltypes.setboolean(false); + run_booleanQuery(boolean_filterObj, AllTypesParameter, alltypes, false, 6); + + run_byteQuery(byte_filterL, byteParameter, Byte.valueOf((byte)50), (byte)50, 2); + run_byteQuery(byte_filterR, byteParameter, Byte.valueOf(Byte.MIN_VALUE), Byte.MIN_VALUE, 1); + run_byteQuery(byte_filterL, ByteParameter, Byte.valueOf((byte)20), (byte)20, 0); + run_byteQuery(byte_filterR, ByteParameter, Byte.valueOf(Byte.MAX_VALUE), Byte.MAX_VALUE, 1); + run_byteQuery(byte_filterL, shortParameter, Short.valueOf((short)50), (byte)50, 2); + run_byteQuery(byte_filterR, shortParameter, Short.valueOf((short)50), (byte)50, 2); + run_byteQuery(byte_filterL, ShortParameter, Short.valueOf((short)-100), (byte)-100, 1); + run_byteQuery(byte_filterR, ShortParameter, Short.valueOf((short)-100), (byte)-100, 1); + run_byteQuery(byte_filterL, charParameter, Character.valueOf((char)50), (byte)50, 2); + run_byteQuery(byte_filterR, charParameter, Character.valueOf((char)50), (byte)50, 2); + run_byteQuery(byte_filterL, CharacterParameter, Character.valueOf((char)50), (byte)50, 2); + run_byteQuery(byte_filterR, CharacterParameter, Character.valueOf((char)100), (byte)100, 1); + run_byteQuery(byte_filterL, intParameter, Integer.valueOf(50), (byte)50, 2); + run_byteQuery(byte_filterR, intParameter, Integer.valueOf(50), (byte)50, 2); + run_byteQuery(byte_filterL, IntegerParameter, Integer.valueOf(-100), (byte)-100, 1); + run_byteQuery(byte_filterR, IntegerParameter, Integer.valueOf(-100), (byte)-100, 1); + run_byteQuery(byte_filterL, longParameter, Long.valueOf(50), (byte)50, 2); + run_byteQuery(byte_filterR, longParameter, Long.valueOf(50), (byte)50, 2); + run_byteQuery(byte_filterL, LongParameter, Long.valueOf(-100), (byte)-100, 1); + run_byteQuery(byte_filterR, LongParameter, Long.valueOf(-100), (byte)-100, 1); + run_byteQuery(byte_filterL, floatParameter, Float.valueOf(50.0f), (byte)50, 2); + run_byteQuery(byte_filterR, floatParameter, Float.valueOf(50.0f), (byte)50, 2); + run_byteQuery(byte_filterL, FloatParameter, Float.valueOf(-100.0f), (byte)-100, 1); + run_byteQuery(byte_filterR, FloatParameter, Float.valueOf(-100.0f), (byte)-100, 1); + run_byteQuery(byte_filterL, doubleParameter, Double.valueOf(50.0), (byte)50, 2); + run_byteQuery(byte_filterR, doubleParameter, Double.valueOf(50.0), (byte)50, 2); + run_byteQuery(byte_filterL, DoubleParameter, Double.valueOf(-100.0), (byte)-100, 1); + run_byteQuery(byte_filterR, DoubleParameter, Double.valueOf(-100.0), (byte)-100, 1); + run_byteQuery(byte_filterL, BigIntegerParameter, new BigInteger("50"), (byte)50, 2); + run_byteQuery(byte_filterR, BigIntegerParameter, new BigInteger("-100"), (byte)-100, 1); + run_byteQuery(byte_filterL, BigDecimalParameter, new BigDecimal("100.0"), (byte)100, 1); + run_byteQuery(byte_filterR, BigDecimalParameter, new BigDecimal("10.0"), (byte)10, 1); + alltypes.setbyte((byte)50); + run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte)50, 2); + alltypes.setbyte((byte)45); + run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte)45, 0); + run_byteQuery(byte_filterVal, null, null, (byte)100, 1); + + run_shortQuery(short_filterL, shortParameter, Short.valueOf((short)100), (short)100, 2); + run_shortQuery(short_filterR, shortParameter, Short.valueOf((short)100), (short)100, 2); + run_shortQuery(short_filterL, ShortParameter, Short.valueOf(Short.MIN_VALUE), Short.MIN_VALUE, 1); + run_shortQuery(short_filterR, ShortParameter, Short.valueOf((short)253), (short)253, 0); + run_shortQuery(short_filterR, shortParameter, Short.valueOf((short)1000), (short)1000, 1); + run_shortQuery(short_filterL, byteParameter, Byte.valueOf((byte)75), (short)75, 0); + run_shortQuery(short_filterR, byteParameter, Byte.valueOf((byte)75), (short)75, 0); + run_shortQuery(short_filterL, ByteParameter, Byte.valueOf((byte)100), (short)100, 2); + run_shortQuery(short_filterR, ByteParameter, Byte.valueOf((byte)100), (short)100, 2); + run_shortQuery(short_filterL, charParameter, Character.valueOf((char)75), (short)75, 0); + run_shortQuery(short_filterR, charParameter, Character.valueOf((char)75), (short)75, 0); + run_shortQuery(short_filterL, CharacterParameter, Character.valueOf((char)100), (short)100, 2); + run_shortQuery(short_filterR, CharacterParameter, Character.valueOf((char)100), (short)100, 2); + run_shortQuery(short_filterL, intParameter, Integer.valueOf(-10000), (short)-10000, 1); + run_shortQuery(short_filterR, intParameter, Integer.valueOf(-10000), (short)-10000, 1); + run_shortQuery(short_filterL, IntegerParameter, Integer.valueOf(10000), (short)10000, 1); + run_shortQuery(short_filterR, IntegerParameter, Integer.valueOf(10000), (short)10000, 1); + run_shortQuery(short_filterL, longParameter, Long.valueOf(10000), (short) 10000, 1); + run_shortQuery(short_filterR, longParameter, Long.valueOf(10000), (short) 10000, 1); + run_shortQuery(short_filterL, LongParameter, Long.valueOf(100), (short)100, 2); + run_shortQuery(short_filterR, LongParameter, Long.valueOf(100), (short)100, 2); + run_shortQuery(short_filterL, floatParameter, Float.valueOf((float)23000), (short)23000, 0); + run_shortQuery(short_filterR, floatParameter, Float.valueOf((float)23000), (short)23000, 0); + run_shortQuery(short_filterL, FloatParameter, Float.valueOf((float)100), (short)100, 2); + run_shortQuery(short_filterR, FloatParameter, Float.valueOf((float)100), (short)100, 2); + run_shortQuery(short_filterL, doubleParameter, Double.valueOf(-10000), (short)-10000, 1); + run_shortQuery(short_filterR, doubleParameter, Double.valueOf(-10000), (short)-10000, 1); + run_shortQuery(short_filterL, DoubleParameter, Double.valueOf(23), (short)23, 0); + run_shortQuery(short_filterR, DoubleParameter, Double.valueOf(23), (short)23, 0); + run_shortQuery(short_filterL, BigIntegerParameter, new BigInteger("999"), (short)999, 0); + run_shortQuery(short_filterR, BigIntegerParameter, new BigInteger("-1000"), (short)-1000, 1); + run_shortQuery(short_filterL, BigDecimalParameter, new BigDecimal("100.0"), (short)100, 2); + run_shortQuery(short_filterR, BigDecimalParameter, new BigDecimal("100.0001"), (short)100, 0); + alltypes.setshort((short)100); + run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short)100, 2); + alltypes.setshort((short)23); + run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short)23, 0); + run_shortQuery(short_filterVal, null, null, (short)1000, 1); + + run_charQuery(char_filterL, charParameter, Character.valueOf(Character.MIN_VALUE), Character.MIN_VALUE, 1); + run_charQuery(char_filterR, charParameter, Character.valueOf(Character.MAX_VALUE), Character.MAX_VALUE, 1); + run_charQuery(char_filterL, charParameter, Character.valueOf('C'), 'C', 0); + run_charQuery(char_filterR, charParameter, Character.valueOf('z'), 'z', 2); + run_charQuery(char_filterL, CharacterParameter, Character.valueOf(' '), ' ', 1); + run_charQuery(char_filterR, CharacterParameter, Character.valueOf('f'), 'f', 0); + run_charQuery(char_filterL, byteParameter, Byte.valueOf((byte)Character.MIN_VALUE), (char)Character.MIN_VALUE, 1); + run_charQuery(char_filterR, byteParameter, Byte.valueOf((byte)122), 'z', 2); + run_charQuery(char_filterL, ByteParameter, Byte.valueOf((byte)'a'), 'a', 0); + run_charQuery(char_filterR, ByteParameter, Byte.valueOf((byte)'a'), 'a', 0); + run_charQuery(char_filterL, shortParameter, Short.valueOf((short)'M'), 'M', 2); + run_charQuery(char_filterR, shortParameter, Short.valueOf((short)'M'), 'M', 2); + run_charQuery(char_filterL, ShortParameter, Short.valueOf((short)'A'), 'A', 1); + run_charQuery(char_filterR, ShortParameter, Short.valueOf((short)'A'), 'A', 1); + run_charQuery(char_filterL, intParameter, Integer.valueOf('z'), 'z', 2); + run_charQuery(char_filterR, intParameter, Integer.valueOf('z'), 'z', 2); + run_charQuery(char_filterL, IntegerParameter, Integer.valueOf('B'), 'B', 1); + run_charQuery(char_filterR, IntegerParameter, Integer.valueOf('B'), 'B', 1); + run_charQuery(char_filterL, longParameter, Long.valueOf('z'), 'z', 2); + run_charQuery(char_filterR, longParameter, Long.valueOf('z'), 'z', 2); + run_charQuery(char_filterL, LongParameter, Long.valueOf('B'), 'B', 1); + run_charQuery(char_filterR, LongParameter, Long.valueOf('B'), 'B', 1); + run_charQuery(char_filterL, floatParameter, Float.valueOf((float)123.222), 'x', 0); + run_charQuery(char_filterR, floatParameter, Float.valueOf((float)123.222), 'x', 0); + run_charQuery(char_filterL, FloatParameter, Float.valueOf((float)'z'), 'z', 2); + run_charQuery(char_filterR, FloatParameter, Float.valueOf((float)'z'), 'z', 2); + run_charQuery(char_filterL, doubleParameter, Double.valueOf('B'), 'B', 1); + run_charQuery(char_filterR, doubleParameter, Double.valueOf('B'), 'B', 1); + run_charQuery(char_filterL, DoubleParameter, Double.valueOf('A'), 'A', 1); + run_charQuery(char_filterR, DoubleParameter, Double.valueOf('A'), 'A', 1); + run_charQuery(char_filterL, BigIntegerParameter, new BigInteger("65"), 'A', 1); // 'A' == 65 + run_charQuery(char_filterR, BigIntegerParameter, new BigInteger("122"), 'z', 2); // 'z' == 122 + run_charQuery(char_filterL, BigDecimalParameter, new BigDecimal("65.0"), 'A', 1); + run_charQuery(char_filterR, BigDecimalParameter, new BigDecimal("77.0"), 'M', 2); // 'M' == 77 + alltypes.setchar('A'); + run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'A', 1); + alltypes.setchar('b'); + run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'b', 0); + run_charQuery(char_filterVal, null, null, 'M', 2); + + run_intQuery(int_filterL, intParameter, Integer.valueOf(AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, 1); + run_intQuery(int_filterR, intParameter, Integer.valueOf(AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, 1); + run_intQuery(int_filterR, intParameter, Integer.valueOf(23), 23, 0); + run_intQuery(int_filterL, IntegerParameter, Integer.valueOf(1000000), 1000000, 1); + run_intQuery(int_filterR, IntegerParameter, Integer.valueOf(1000), 1000, 1); + run_intQuery(int_filterL, byteParameter, Byte.valueOf((byte)100), 100, 2); + run_intQuery(int_filterR, byteParameter, Byte.valueOf((byte)0), 0, 1); + run_intQuery(int_filterL, ByteParameter, Byte.valueOf((byte)100), 100, 2); + run_intQuery(int_filterR, ByteParameter, Byte.valueOf((byte)0), 0, 1); + run_intQuery(int_filterL, shortParameter, Short.valueOf((short)10000), 10000, 1); + run_intQuery(int_filterR, shortParameter, Short.valueOf((short)-1000), -1000, 1); + run_intQuery(int_filterL, ShortParameter, Short.valueOf((short)-1000), -1000, 1); + run_intQuery(int_filterR, ShortParameter, Short.valueOf((short)10000), 10000, 1); + run_intQuery(int_filterL, charParameter, Character.valueOf((char)10000), 10000, 1); + run_intQuery(int_filterR, charParameter, Character.valueOf((char)0), 0, 1); + run_intQuery(int_filterL, CharacterParameter, Character.valueOf((char)100), 100, 2); + run_intQuery(int_filterR, CharacterParameter, Character.valueOf((char)10000), 10000, 1); + run_intQuery(int_filterL, longParameter, Long.valueOf(AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, 1); + run_intQuery(int_filterR, longParameter, Long.valueOf(AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, 1); + run_intQuery(int_filterL, LongParameter, Long.valueOf(10000), 10000, 1); + run_intQuery(int_filterR, LongParameter, Long.valueOf(43), 43, 0); + run_intQuery(int_filterL, floatParameter, Float.valueOf((float)AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, 1); + run_intQuery(int_filterR, floatParameter, Float.valueOf((float)AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, 1); + run_intQuery(int_filterL, FloatParameter, Float.valueOf((float)10000), 10000, 1); + run_intQuery(int_filterR, FloatParameter, Float.valueOf((float)43), 43, 0); + run_intQuery(int_filterL, doubleParameter, Double.valueOf(AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, 1); + run_intQuery(int_filterR, doubleParameter, Double.valueOf(AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, 1); + run_intQuery(int_filterL, DoubleParameter, Double.valueOf(10000), 10000, 1); + run_intQuery(int_filterR, DoubleParameter, Double.valueOf(43), 43, 0); + run_intQuery(int_filterL, BigIntegerParameter, new BigInteger("1000000"), 1000000, 1); + run_intQuery(int_filterR, BigIntegerParameter, new BigInteger("-1000000"), -1000000, 1); + run_intQuery(int_filterL, BigDecimalParameter, new BigDecimal("1000000.0"), 1000000, 1); + run_intQuery(int_filterR, BigDecimalParameter, new BigDecimal("-1000000.00001"), -1000000, 0); + alltypes.setint(100); + run_intQuery(int_filterObj, AllTypesParameter, alltypes, 100, 2); + run_intQuery(int_filterVal, null, null, 1000, 1); + + run_longQuery(long_filterL, longParameter, Long.valueOf(Long.MIN_VALUE), Long.MIN_VALUE, 1); + run_longQuery(long_filterR, longParameter, Long.valueOf(Long.MAX_VALUE), Long.MAX_VALUE, 1); + run_longQuery(long_filterL, LongParameter, Long.valueOf(100), 100, 2); + run_longQuery(long_filterR, LongParameter, Long.valueOf(23), 23, 0); + run_longQuery(long_filterL, byteParameter, Byte.valueOf((byte)100), 100, 2); + run_longQuery(long_filterR, byteParameter, Byte.valueOf((byte)0), 0, 1); + run_longQuery(long_filterL, ByteParameter, Byte.valueOf((byte)100), 100, 2); + run_longQuery(long_filterR, ByteParameter, Byte.valueOf((byte)0), 0, 1); + run_longQuery(long_filterL, shortParameter, Short.valueOf((short)-1000 ), -1000, 2); + run_longQuery(long_filterR, shortParameter, Short.valueOf((short)1000), 1000, 1); + run_longQuery(long_filterL, ShortParameter, Short.valueOf((short)100), 100, 2); + run_longQuery(long_filterR, ShortParameter, Short.valueOf((short)32), 32, 0); + run_longQuery(long_filterL, charParameter, Character.valueOf((char)0), 0, 1); + run_longQuery(long_filterR, charParameter, Character.valueOf((char)100), 100, 2); + run_longQuery(long_filterL, CharacterParameter, Character.valueOf((char)23), 23, 0); + run_longQuery(long_filterR, CharacterParameter, Character.valueOf((char)0), 0, 1); + run_longQuery(long_filterL, intParameter, Integer.valueOf(100), 100, 2); + run_longQuery(long_filterR, intParameter, Integer.valueOf(0), 0, 1); + run_longQuery(long_filterL, IntegerParameter, Integer.valueOf(23), 23, 0); + run_longQuery(long_filterR, IntegerParameter, Integer.valueOf(1000000), 1000000, 1); + run_longQuery(long_filterL, floatParameter, Float.valueOf((float)-1000000.0), -1000000, 1); +// run_longQuery(long_filterR, floatParameter, Float.valueOf((float)Long.MAX_VALUE), Long.MAX_VALUE, 1); + run_longQuery(long_filterL, FloatParameter, Float.valueOf((float)100), 100, 2); + run_longQuery(long_filterR, FloatParameter, Float.valueOf((float)32), 32, 0); + run_longQuery(long_filterL, doubleParameter, Double.valueOf(-1000000.0), -1000000, 1); +// run_longQuery(long_filterR, doubleParameter, Double.valueOf((double)Long.MAX_VALUE), Long.MAX_VALUE, 1); + run_longQuery(long_filterL, DoubleParameter, Double.valueOf(100.0), 100, 2); + run_longQuery(long_filterR, DoubleParameter, Double.valueOf(32.0), 32, 0); + run_longQuery(long_filterL, BigIntegerParameter, new BigInteger("1000000"), 1000000, 1); + run_longQuery(long_filterR, BigIntegerParameter, new BigInteger("-1000000"), -1000000, 1); + run_longQuery(long_filterL, BigDecimalParameter, new BigDecimal("100.0"), 100, 2); + run_longQuery(long_filterR, BigDecimalParameter, new BigDecimal("-1000000.0001"), -1000000, 0); + alltypes.setlong(100); + run_longQuery(long_filterObj, AllTypesParameter, alltypes, 100, 2); + run_longQuery(long_filterVal, null, null, 1000000, 1); + + run_floatQuery(float_filterL, floatParameter, Float.valueOf(-234.23f), -234.23f, 1); + run_floatQuery(float_filterR, floatParameter, Float.valueOf(-234.23f), -234.23f, 1); + run_floatQuery(float_filterL, FloatParameter, Float.valueOf((float)0.0), 0.0f, 1); + run_floatQuery(float_filterR, FloatParameter, Float.valueOf((float)4.0), 4.0f, 0); + run_floatQuery(float_filterL, byteParameter, Byte.valueOf((byte)0), 0.0f, 1); + run_floatQuery(float_filterR, byteParameter, Byte.valueOf((byte)23), 23.0f, 0); + run_floatQuery(float_filterL, ByteParameter, Byte.valueOf((byte)34), 34.0f, 0); + run_floatQuery(float_filterR, ByteParameter, Byte.valueOf((byte)100), 100.0f, 2); + run_floatQuery(float_filterL, shortParameter, Short.valueOf((short)0), 0.0f, 1); + run_floatQuery(float_filterR, shortParameter, Short.valueOf((short)23), 23.0f, 0); + run_floatQuery(float_filterL, ShortParameter, Short.valueOf((short)34), 34.0f, 0); + run_floatQuery(float_filterR, ShortParameter, Short.valueOf((short)100), 100.0f, 2); + run_floatQuery(float_filterL, charParameter, Character.valueOf((char)0), 0.0f, 1); + run_floatQuery(float_filterR, charParameter, Character.valueOf((char)23), 23.0f, 0); + run_floatQuery(float_filterL, CharacterParameter, Character.valueOf((char)34), 34.0f, 0); + run_floatQuery(float_filterR, CharacterParameter, Character.valueOf((char)100), 100.0f, 2); + run_floatQuery(float_filterL, intParameter, Integer.valueOf(50000000), 50000000.0f, 1); + run_floatQuery(float_filterR, intParameter, Integer.valueOf(23), 23.0f, 0); + run_floatQuery(float_filterL, IntegerParameter, Integer.valueOf(34), 34.0f, 0); + run_floatQuery(float_filterR, IntegerParameter, Integer.valueOf(100), 100.0f, 2); + run_floatQuery(float_filterL, longParameter, Long.valueOf(50000000), 50000000.0f, 1); + run_floatQuery(float_filterR, longParameter, Long.valueOf(23), 23.0f, 0); + run_floatQuery(float_filterL, LongParameter, Long.valueOf(34), 34.0f, 0); + run_floatQuery(float_filterR, LongParameter, Long.valueOf(100), 100.0f, 2); + run_floatQuery(float_filterL, doubleParameter, Double.valueOf(50000000.0), 50000000.0f, 1); + run_floatQuery(float_filterR, doubleParameter, Double.valueOf(-25.5), -25.5f, 1); + run_floatQuery(float_filterL, DoubleParameter, Double.valueOf(0.0), 0.0f, 1); + run_floatQuery(float_filterR, DoubleParameter, Double.valueOf(100.0), 100.0f, 2); + run_floatQuery(float_filterL, BigIntegerParameter, new BigInteger("0"), 0.0f, 1); + run_floatQuery(float_filterR, BigIntegerParameter, new BigInteger("1000000000"), 1000000000.0f, 1); + run_floatQuery(float_filterL, BigDecimalParameter, new BigDecimal("350.5"), 350.5f, 1); + run_floatQuery(float_filterR, BigDecimalParameter, new BigDecimal("50000000.0"), 50000000.0f, 1); + alltypes.setfloat(23.23f); + run_floatQuery(float_filterObj, AllTypesParameter, alltypes, 23.23f, 0); + run_floatQuery(float_filterVal, null, null, 100.0f, 2); + + run_doubleQuery(double_filterL, doubleParameter, Double.valueOf(-234234.234), -234234.234, 1); + run_doubleQuery(double_filterR, doubleParameter, Double.valueOf(-234234.234), -234234.234, 1); + run_doubleQuery(double_filterL, DoubleParameter, Double.valueOf(0.0), 0.0, 1); + run_doubleQuery(double_filterR, DoubleParameter, Double.valueOf(23.34), 23.34, 0); + run_doubleQuery(double_filterL, byteParameter, Byte.valueOf((byte)100), 100.0, 2); + run_doubleQuery(double_filterR, byteParameter, Byte.valueOf((byte)0), 0.0, 1); + run_doubleQuery(double_filterL, ByteParameter, Byte.valueOf((byte)23), 23.0, 0); + run_doubleQuery(double_filterR, ByteParameter, Byte.valueOf((byte)100), 100.0, 2); + run_doubleQuery(double_filterL, shortParameter, Short.valueOf((short)100), 100.0, 2); + run_doubleQuery(double_filterR, shortParameter, Short.valueOf((short)0), 0.0, 1); + run_doubleQuery(double_filterL, ShortParameter, Short.valueOf((short)23), 23.0, 0); + run_doubleQuery(double_filterR, ShortParameter, Short.valueOf((short)100), 100.0, 2); + run_doubleQuery(double_filterL, intParameter, Integer.valueOf(100), 100.0, 2); + run_doubleQuery(double_filterR, intParameter, Integer.valueOf(0), 0.0, 1); + run_doubleQuery(double_filterL, IntegerParameter, Integer.valueOf(23), 23.0, 0); + run_doubleQuery(double_filterR, IntegerParameter, Integer.valueOf(100), 100.0, 2); + run_doubleQuery(double_filterL, longParameter, Long.valueOf(100), 100.0, 2); + run_doubleQuery(double_filterR, longParameter, Long.valueOf(0), 0.0, 1); + run_doubleQuery(double_filterL, LongParameter, Long.valueOf(23), 23.0, 0); + run_doubleQuery(double_filterR, LongParameter, Long.valueOf(100), 100.0, 2); + run_doubleQuery(double_filterL, floatParameter, Float.valueOf(0.0f),0.0f, 1); + run_doubleQuery(double_filterR, floatParameter, Float.valueOf(100.0f), 100.0f, 2); + run_doubleQuery(double_filterL, FloatParameter, Float.valueOf(100.0f), 100.0, 2); + run_doubleQuery(double_filterR, FloatParameter, Float.valueOf(69.96f), 69.96, 0); + run_doubleQuery(double_filterL, BigIntegerParameter, new BigInteger("50000000"), 50000000.0f, 1); + run_doubleQuery(double_filterR, BigIntegerParameter, new BigInteger("1000000000"), 1000000000.0f, 1); + run_doubleQuery(double_filterL, BigDecimalParameter, new BigDecimal("350.5"), 350.5f, 1); + run_doubleQuery(double_filterR, BigDecimalParameter, new BigDecimal("50000000.0"), 50000000.0f, 1); + alltypes.setdouble(-25.5); + run_doubleQuery(double_filterObj, AllTypesParameter, alltypes, -25.5, 1); + run_doubleQuery(double_filterVal, null, null, 100.0, 2); + + run_BooleanQuery(Boolean_filterL, booleanParameter, Boolean.TRUE, Boolean.TRUE, 4); + run_BooleanQuery(Boolean_filterL, booleanParameter, Boolean.FALSE, Boolean.FALSE, 6); + run_BooleanQuery(Boolean_filterR, booleanParameter, Boolean.TRUE, Boolean.TRUE, 4); + run_BooleanQuery(Boolean_filterR, booleanParameter, Boolean.FALSE, Boolean.FALSE, 6); + run_BooleanQuery(Boolean_filterL, BooleanParameter, Boolean.TRUE, Boolean.TRUE, 4); + run_BooleanQuery(Boolean_filterL, BooleanParameter, Boolean.FALSE, Boolean.FALSE, 6); + run_BooleanQuery(Boolean_filterR, BooleanParameter, Boolean.TRUE, Boolean.TRUE, 4); + run_BooleanQuery(Boolean_filterR, BooleanParameter, Boolean.FALSE, Boolean.FALSE, 6); + run_BooleanQuery(Boolean_filterT, null, Boolean.TRUE, Boolean.TRUE, 4); + run_BooleanQuery(Boolean_filterF, null, Boolean.FALSE, Boolean.FALSE, 6); + alltypes.setBoolean(Boolean.TRUE); + run_BooleanQuery(Boolean_filterObj, AllTypesParameter, alltypes, Boolean.TRUE, 4); + alltypes.setBoolean(Boolean.FALSE); + run_BooleanQuery(Boolean_filterObj, AllTypesParameter, alltypes, Boolean.FALSE, 6); + + run_ByteQuery(Byte_filterL, byteParameter, Byte.valueOf((byte)50), Byte.valueOf((byte)50), 2); + run_ByteQuery(Byte_filterR, byteParameter, Byte.valueOf(Byte.MIN_VALUE), Byte.valueOf(Byte.MIN_VALUE), 1); + run_ByteQuery(Byte_filterL, ByteParameter, Byte.valueOf((byte)20), Byte.valueOf((byte)20), 0); + run_ByteQuery(Byte_filterR, ByteParameter, Byte.valueOf(Byte.MAX_VALUE), Byte.valueOf(Byte.MAX_VALUE), 1); + run_ByteQuery(Byte_filterL, shortParameter, Short.valueOf((short)50), Byte.valueOf((byte)50), 2); + run_ByteQuery(Byte_filterR, shortParameter, Short.valueOf((short)50), Byte.valueOf((byte)50), 2); + run_ByteQuery(Byte_filterL, ShortParameter, Short.valueOf((short)-100), Byte.valueOf((byte)-100), 1); + run_ByteQuery(Byte_filterR, ShortParameter, Short.valueOf((short)-100), Byte.valueOf((byte)-100), 1); + run_ByteQuery(Byte_filterL, charParameter, Character.valueOf((char)50), Byte.valueOf((byte)50), 2); + run_ByteQuery(Byte_filterR, charParameter, Character.valueOf((char)50), Byte.valueOf((byte)50), 2); + run_ByteQuery(Byte_filterL, CharacterParameter, Character.valueOf((char)50), Byte.valueOf((byte)50), 2); + run_ByteQuery(Byte_filterR, CharacterParameter, Character.valueOf((char)75), Byte.valueOf((byte)75), 1); + run_ByteQuery(Byte_filterL, intParameter, Integer.valueOf(50), Byte.valueOf((byte)50), 2); + run_ByteQuery(Byte_filterR, intParameter, Integer.valueOf(50), Byte.valueOf((byte)50), 2); + run_ByteQuery(Byte_filterL, IntegerParameter, Integer.valueOf(50), Byte.valueOf((byte)50), 2); + run_ByteQuery(Byte_filterR, IntegerParameter, Integer.valueOf(75), Byte.valueOf((byte)75), 1); + run_ByteQuery(Byte_filterL, longParameter, Long.valueOf(50), Byte.valueOf((byte)50), 2); + run_ByteQuery(Byte_filterR, longParameter, Long.valueOf(50), Byte.valueOf((byte)50), 2); + run_ByteQuery(Byte_filterL, LongParameter, Long.valueOf(-100), Byte.valueOf((byte)-100), 1); + run_ByteQuery(Byte_filterR, LongParameter, Long.valueOf(-100), Byte.valueOf((byte)-100), 1); + run_ByteQuery(Byte_filterL, floatParameter, Float.valueOf((float)50), Byte.valueOf((byte)50), 2); + run_ByteQuery(Byte_filterR, floatParameter, Float.valueOf((float)50), Byte.valueOf((byte)50), 2); + run_ByteQuery(Byte_filterL, FloatParameter, Float.valueOf((float)-100), Byte.valueOf((byte)-100), 1); + run_ByteQuery(Byte_filterR, FloatParameter, Float.valueOf((float)-100), Byte.valueOf((byte)-100), 1); + run_ByteQuery(Byte_filterL, doubleParameter, Double.valueOf(50), Byte.valueOf((byte)50), 2); + run_ByteQuery(Byte_filterR, doubleParameter, Double.valueOf(50), Byte.valueOf((byte)50), 2); + run_ByteQuery(Byte_filterL, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte)-100), 1); + run_ByteQuery(Byte_filterR, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte)-100), 1); + run_ByteQuery(Byte_filterL, BigIntegerParameter, new BigInteger("50"), Byte.valueOf((byte)50), 2); + run_ByteQuery(Byte_filterR, BigIntegerParameter, new BigInteger("-100"), Byte.valueOf((byte)-100), 1); + run_ByteQuery(Byte_filterL, BigDecimalParameter, new BigDecimal("100.0"), Byte.valueOf((byte)100), 1); + run_ByteQuery(Byte_filterR, BigDecimalParameter, new BigDecimal("10.0001"), Byte.valueOf((byte)10), 0); + Byte val = Byte.valueOf((byte)50); + alltypes.setByte(val); + run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, 2); + val = Byte.valueOf((byte)45); + alltypes.setByte(val); + run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, 0); + run_ByteQuery(Byte_filterVal, null, null, Byte.valueOf((byte)100), 1); + + run_ShortQuery(Short_filterL, shortParameter, Short.valueOf((short)100), Short.valueOf((short)100), 2); + run_ShortQuery(Short_filterR, shortParameter, Short.valueOf((short)100), Short.valueOf((short)100), 2); + run_ShortQuery(Short_filterL, ShortParameter, Short.valueOf(Short.MIN_VALUE), Short.valueOf(Short.MIN_VALUE), 1); + run_ShortQuery(Short_filterR, ShortParameter, Short.valueOf((short)253), Short.valueOf((short)253), 0); + run_ShortQuery(Short_filterR, shortParameter, Short.valueOf((short)1000), Short.valueOf((short)1000), 1); + run_ShortQuery(Short_filterL, byteParameter, Byte.valueOf((byte)75), Short.valueOf((short)75), 0); + run_ShortQuery(Short_filterR, byteParameter, Byte.valueOf((byte)75), Short.valueOf((short)75), 0); + run_ShortQuery(Short_filterL, ByteParameter, Byte.valueOf((byte)100), Short.valueOf((short)100), 2); + run_ShortQuery(Short_filterR, ByteParameter, Byte.valueOf((byte)100), Short.valueOf((short)100), 2); + run_ShortQuery(Short_filterL, charParameter, Character.valueOf((char)75), Short.valueOf((short)75), 0); + run_ShortQuery(Short_filterR, charParameter, Character.valueOf((char)75), Short.valueOf((short)75), 0); + run_ShortQuery(Short_filterL, CharacterParameter, Character.valueOf((char)100), Short.valueOf((short)100), 2); + run_ShortQuery(Short_filterR, CharacterParameter, Character.valueOf((char)100), Short.valueOf((short)100), 2); + run_ShortQuery(Short_filterL, intParameter, Integer.valueOf(-10000), Short.valueOf((short)-10000), 1); + run_ShortQuery(Short_filterR, intParameter, Integer.valueOf(-10000), Short.valueOf((short)-10000), 1); + run_ShortQuery(Short_filterL, IntegerParameter, Integer.valueOf(10000), Short.valueOf((short)10000), 1); + run_ShortQuery(Short_filterR, IntegerParameter, Integer.valueOf(10000), Short.valueOf((short)10000), 1); + run_ShortQuery(Short_filterL, longParameter, Long.valueOf(10000), Short.valueOf((short) 10000), 1); + run_ShortQuery(Short_filterR, longParameter, Long.valueOf(10000), Short.valueOf((short) 10000), 1); + run_ShortQuery(Short_filterL, LongParameter, Long.valueOf(100), Short.valueOf((short)100), 2); + run_ShortQuery(Short_filterR, LongParameter, Long.valueOf(100), Short.valueOf((short)100), 2); + run_ShortQuery(Short_filterL, floatParameter, Float.valueOf((float)23000), Short.valueOf((short)23000), 0); + run_ShortQuery(Short_filterR, floatParameter, Float.valueOf((float)23000), Short.valueOf((short)23000), 0); + run_ShortQuery(Short_filterL, FloatParameter, Float.valueOf((float)100), Short.valueOf((short)100), 2); + run_ShortQuery(Short_filterR, FloatParameter, Float.valueOf((float)100), Short.valueOf((short)100), 2); + run_ShortQuery(Short_filterL, doubleParameter, Double.valueOf(-10000), Short.valueOf((short)-10000), 1); + run_ShortQuery(Short_filterR, doubleParameter, Double.valueOf(-10000), Short.valueOf((short)-10000), 1); + run_ShortQuery(Short_filterL, DoubleParameter, Double.valueOf(23), Short.valueOf((short)23), 0); + run_ShortQuery(Short_filterR, DoubleParameter, Double.valueOf(23), Short.valueOf((short)23), 0); + run_ShortQuery(Short_filterL, BigIntegerParameter, new BigInteger("999"), Short.valueOf((short)999), 0); + run_ShortQuery(Short_filterR, BigIntegerParameter, new BigInteger("-1000"), Short.valueOf((short)-1000), 1); + run_ShortQuery(Short_filterL, BigDecimalParameter, new BigDecimal("100.0"), Short.valueOf((short)100), 2); + run_ShortQuery(Short_filterR, BigDecimalParameter, new BigDecimal("101.0"), Short.valueOf((short)100), 0); + Short sval = Short.valueOf((short)100); + alltypes.setShort(sval); + run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, 2); + sval = Short.valueOf((short)23); + alltypes.setShort(sval); + run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, 0); + run_ShortQuery(Short_filterVal, null, null, Short.valueOf((short)-1000), 1); + + run_CharacterQuery(Character_filterL, charParameter, Character.valueOf(Character.MIN_VALUE), Character.valueOf(Character.MIN_VALUE), 1); + run_CharacterQuery(Character_filterR, charParameter, Character.valueOf(Character.MAX_VALUE), Character.valueOf(Character.MAX_VALUE), 1); + run_CharacterQuery(Character_filterL, charParameter, Character.valueOf('C'), Character.valueOf('C'), 0); + run_CharacterQuery(Character_filterR, charParameter, Character.valueOf('z'), Character.valueOf('z'), 2); + run_CharacterQuery(Character_filterL, CharacterParameter, Character.valueOf(' '), Character.valueOf(' '), 1); + run_CharacterQuery(Character_filterR, CharacterParameter, Character.valueOf('f'), Character.valueOf('f'), 0); + run_CharacterQuery(Character_filterL, byteParameter, Byte.valueOf((byte)Character.MIN_VALUE), Character.valueOf((char)Character.MIN_VALUE), 1); + run_CharacterQuery(Character_filterR, ByteParameter, Byte.valueOf((byte)'a'), Character.valueOf('a'), 0); + run_CharacterQuery(Character_filterL, shortParameter, Short.valueOf((short)'M'), Character.valueOf('M'), 2); + run_CharacterQuery(Character_filterR, shortParameter, Short.valueOf((short)'F'), Character.valueOf('F'), 1); + run_CharacterQuery(Character_filterL, ShortParameter, Short.valueOf((short)'A'), Character.valueOf('A'), 1); + run_CharacterQuery(Character_filterR, ShortParameter, Short.valueOf((short)'A'), Character.valueOf('A'), 1); + run_CharacterQuery(Character_filterL, intParameter, Integer.valueOf('z'), Character.valueOf('z'), 2); + run_CharacterQuery(Character_filterR, intParameter, Integer.valueOf('z'), Character.valueOf('z'), 2); + run_CharacterQuery(Character_filterL, IntegerParameter, Integer.valueOf('B'), Character.valueOf('B'), 1); + run_CharacterQuery(Character_filterR, IntegerParameter, Integer.valueOf('B'), Character.valueOf('B'), 1); + run_CharacterQuery(Character_filterL, longParameter, Long.valueOf('z'), Character.valueOf('z'), 2); + run_CharacterQuery(Character_filterR, longParameter, Long.valueOf('z'), Character.valueOf('z'), 2); + run_CharacterQuery(Character_filterL, LongParameter, Long.valueOf('B'), Character.valueOf('B'), 1); + run_CharacterQuery(Character_filterR, LongParameter, Long.valueOf('B'), Character.valueOf('B'), 1); + run_CharacterQuery(Character_filterL, floatParameter, Float.valueOf((float)123.222), Character.valueOf('x'), 0); + run_CharacterQuery(Character_filterR, floatParameter, Float.valueOf((float)123.222), Character.valueOf('x'), 0); + run_CharacterQuery(Character_filterL, FloatParameter, Float.valueOf((float)'z'), Character.valueOf('z'), 2); + run_CharacterQuery(Character_filterR, FloatParameter, Float.valueOf((float)'z'), Character.valueOf('z'), 2); + run_CharacterQuery(Character_filterL, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), 1); + run_CharacterQuery(Character_filterR, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), 1); + run_CharacterQuery(Character_filterL, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), 1); + run_CharacterQuery(Character_filterR, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), 1); + run_CharacterQuery(Character_filterL, BigIntegerParameter, new BigInteger("65"), Character.valueOf('A'), 1); // 'A' == 65 + run_CharacterQuery(Character_filterR, BigIntegerParameter, new BigInteger("122"), Character.valueOf('z'), 2); // 'z' == 122 + run_CharacterQuery(Character_filterL, BigDecimalParameter, new BigDecimal("65.0"), Character.valueOf('A'), 1); + run_CharacterQuery(Character_filterR, BigDecimalParameter, new BigDecimal("77.0"), Character.valueOf('M'), 2); // 'M' == 77 + alltypes.setCharacter(Character.valueOf('A')); + run_CharacterQuery(Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('A'), 1); + alltypes.setCharacter(Character.valueOf('b')); + run_CharacterQuery(Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('b'), 0); + run_CharacterQuery(Character_filterVal, null, null, Character.valueOf('z'), 2); + + run_IntegerQuery(Integer_filterL, intParameter, Integer.valueOf(AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), 1); + run_IntegerQuery(Integer_filterR, intParameter, Integer.valueOf(AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), 1); + run_IntegerQuery(Integer_filterR, intParameter, Integer.valueOf(23), Integer.valueOf(23), 0); + run_IntegerQuery(Integer_filterL, IntegerParameter, Integer.valueOf(1000000), Integer.valueOf(1000000), 1); + run_IntegerQuery(Integer_filterR, IntegerParameter, Integer.valueOf(1000), Integer.valueOf(1000), 1); + run_IntegerQuery(Integer_filterL, byteParameter, Byte.valueOf((byte)100), Integer.valueOf(100), 2); + run_IntegerQuery(Integer_filterR, byteParameter, Byte.valueOf((byte)0), Integer.valueOf(0), 1); + run_IntegerQuery(Integer_filterL, ByteParameter, Byte.valueOf((byte)100), Integer.valueOf(100), 2); + run_IntegerQuery(Integer_filterR, ByteParameter, Byte.valueOf((byte)0), Integer.valueOf(0), 1); + run_IntegerQuery(Integer_filterL, shortParameter, Short.valueOf((short)10000), Integer.valueOf(10000), 1); + run_IntegerQuery(Integer_filterR, shortParameter, Short.valueOf((short)-1000), Integer.valueOf(-1000), 1); + run_IntegerQuery(Integer_filterL, ShortParameter, Short.valueOf((short)-1000), Integer.valueOf(-1000), 1); + run_IntegerQuery(Integer_filterL, charParameter, Character.valueOf((char)10000), Integer.valueOf(10000), 1); + run_IntegerQuery(Integer_filterR, charParameter, Character.valueOf((char)10000), Integer.valueOf(10000), 1); + run_IntegerQuery(Integer_filterL, CharacterParameter, Character.valueOf((char)100), Integer.valueOf(100), 2); + run_IntegerQuery(Integer_filterR, CharacterParameter, Character.valueOf((char)10000), Integer.valueOf(10000), 1); + run_IntegerQuery(Integer_filterL, longParameter, Long.valueOf(AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), 1); + run_IntegerQuery(Integer_filterR, longParameter, Long.valueOf(AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), 1); + run_IntegerQuery(Integer_filterL, LongParameter, Long.valueOf(10000), Integer.valueOf(10000), 1); + run_IntegerQuery(Integer_filterR, LongParameter, Long.valueOf(43), Integer.valueOf(43), 0); + run_IntegerQuery(Integer_filterL, floatParameter, Float.valueOf((float)AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), 1); + run_IntegerQuery(Integer_filterR, floatParameter, Float.valueOf((float)AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), 1); + run_IntegerQuery(Integer_filterL, FloatParameter, Float.valueOf((float)10000), Integer.valueOf(10000), 1); + run_IntegerQuery(Integer_filterR, FloatParameter, Float.valueOf((float)43), Integer.valueOf(43), 0); + run_IntegerQuery(Integer_filterL, doubleParameter, Double.valueOf(AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), 1); + run_IntegerQuery(Integer_filterR, doubleParameter, Double.valueOf(AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), 1); + run_IntegerQuery(Integer_filterL, DoubleParameter, Double.valueOf(10000), Integer.valueOf(10000), 1); + run_IntegerQuery(Integer_filterR, DoubleParameter, Double.valueOf(43), Integer.valueOf(43), 0); + run_IntegerQuery(Integer_filterL, BigIntegerParameter, new BigInteger("1000000"), Integer.valueOf(1000000), 1); + run_IntegerQuery(Integer_filterR, BigIntegerParameter, new BigInteger("-1000000"), Integer.valueOf(-1000000), 1); + run_IntegerQuery(Integer_filterL, BigDecimalParameter, new BigDecimal("1000000.0"), Integer.valueOf(1000000), 1); + run_IntegerQuery(Integer_filterR, BigDecimalParameter, new BigDecimal("-1000000.01"), Integer.valueOf(-1000000), 0); + alltypes.setInteger(Integer.valueOf(100)); + run_IntegerQuery(Integer_filterObj, AllTypesParameter, alltypes, Integer.valueOf(100), 2); + run_IntegerQuery(Integer_filterVal, null, null, Integer.valueOf(100), 2); + + run_LongQuery(Long_filterL, longParameter, Long.valueOf(Long.MIN_VALUE), Long.valueOf(Long.MIN_VALUE), 1); + run_LongQuery(Long_filterR, longParameter, Long.valueOf(Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE), 1); + run_LongQuery(Long_filterL, LongParameter, Long.valueOf(100), Long.valueOf(100), 2); + run_LongQuery(Long_filterR, LongParameter, Long.valueOf(23), Long.valueOf(23), 0); + run_LongQuery(Long_filterL, byteParameter, Byte.valueOf((byte)100), Long.valueOf(100), 2); + run_LongQuery(Long_filterR, byteParameter, Byte.valueOf((byte)0), Long.valueOf(0), 1); + run_LongQuery(Long_filterL, ByteParameter, Byte.valueOf((byte)100), Long.valueOf(100), 2); + run_LongQuery(Long_filterR, ByteParameter, Byte.valueOf((byte)0), Long.valueOf(0), 1); + run_LongQuery(Long_filterL, shortParameter, Short.valueOf((short)-1000 ), Long.valueOf(-1000), 2); + run_LongQuery(Long_filterR, shortParameter, Short.valueOf((short)1000), Long.valueOf(1000), 1); + run_LongQuery(Long_filterL, ShortParameter, Short.valueOf((short)100), Long.valueOf(100), 2); + run_LongQuery(Long_filterR, ShortParameter, Short.valueOf((short)32), Long.valueOf(32), 0); + run_LongQuery(Long_filterL, charParameter, Character.valueOf((char)0), Long.valueOf(0), 1); + run_LongQuery(Long_filterR, charParameter, Character.valueOf((char)100), Long.valueOf(100), 2); + run_LongQuery(Long_filterL, CharacterParameter, Character.valueOf((char)23), Long.valueOf(23), 0); + run_LongQuery(Long_filterR, CharacterParameter, Character.valueOf((char)0), Long.valueOf(0), 1); + run_LongQuery(Long_filterL, intParameter, Integer.valueOf(100), Long.valueOf(100), 2); + run_LongQuery(Long_filterR, intParameter, Integer.valueOf(0), Long.valueOf(0), 1); + run_LongQuery(Long_filterL, IntegerParameter, Integer.valueOf(23), Long.valueOf(23), 0); + run_LongQuery(Long_filterR, IntegerParameter, Integer.valueOf(1000000), Long.valueOf(1000000), 1); + run_LongQuery(Long_filterL, longParameter, Long.valueOf(100), Long.valueOf(100), 2); + run_LongQuery(Long_filterR, longParameter, Long.valueOf(0), Long.valueOf(0), 1); + run_LongQuery(Long_filterL, LongParameter, Long.valueOf(23), Long.valueOf(23), 0); + run_LongQuery(Long_filterR, LongParameter, Long.valueOf(1000000), Long.valueOf(1000000), 1); + run_LongQuery(Long_filterL, floatParameter, Float.valueOf((float)-1000000.0), Long.valueOf(-1000000), 1); +// run_LongQuery(Long_filterR, floatParameter, Float.valueOf((float)Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE), 1); + run_LongQuery(Long_filterL, FloatParameter, Float.valueOf((float)100), Long.valueOf(100), 2); + run_LongQuery(Long_filterR, FloatParameter, Float.valueOf((float)32), Long.valueOf(32), 0); + run_LongQuery(Long_filterL, doubleParameter, Double.valueOf(-1000000.0), Long.valueOf(-1000000), 1); +// run_LongQuery(Long_filterR, doubleParameter, Double.valueOf((double)Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE), 1); + run_LongQuery(Long_filterL, DoubleParameter, Double.valueOf(100), Long.valueOf(100), 2); + run_LongQuery(Long_filterR, DoubleParameter, Double.valueOf(32), Long.valueOf(32), 0); + run_LongQuery(Long_filterL, BigIntegerParameter, new BigInteger("1000000"), Long.valueOf(1000000), 1); + run_LongQuery(Long_filterR, BigIntegerParameter, new BigInteger("-1000000"), Long.valueOf(-1000000), 1); + run_LongQuery(Long_filterL, BigDecimalParameter, new BigDecimal("1000000.0"), Long.valueOf(1000000), 1); + run_LongQuery(Long_filterR, BigDecimalParameter, new BigDecimal("-1000000.0001"), Long.valueOf(-1000000), 0); + alltypes.setLong(Long.valueOf(100)); + run_LongQuery(Long_filterObj, AllTypesParameter, alltypes, Long.valueOf(100), 2); + run_LongQuery(Long_filterVal, null, null, Long.valueOf(-1000), 2); + + run_FloatQuery(Float_filterL, floatParameter, Float.valueOf(350.5f), Float.valueOf(350.5f), 1); + run_FloatQuery(Float_filterR, floatParameter, Float.valueOf(350.5f), Float.valueOf(350.5f), 1); + run_FloatQuery(Float_filterL, FloatParameter, Float.valueOf((float)0.0), Float.valueOf(0.0f), 1); + run_FloatQuery(Float_filterR, FloatParameter, Float.valueOf((float)4.0), Float.valueOf(4.0f), 0); + run_FloatQuery(Float_filterL, byteParameter, Byte.valueOf((byte)0), Float.valueOf(0.0f), 1); + run_FloatQuery(Float_filterR, byteParameter, Byte.valueOf((byte)23), Float.valueOf(23.0f), 0); + run_FloatQuery(Float_filterL, ByteParameter, Byte.valueOf((byte)34), Float.valueOf(34.0f), 0); + run_FloatQuery(Float_filterR, ByteParameter, Byte.valueOf((byte)100), Float.valueOf(100.0f), 2); + run_FloatQuery(Float_filterL, shortParameter, Short.valueOf((short)0), Float.valueOf(0.0f), 1); + run_FloatQuery(Float_filterR, shortParameter, Short.valueOf((short)23), Float.valueOf(23.0f), 0); + run_FloatQuery(Float_filterL, ShortParameter, Short.valueOf((short)34), Float.valueOf(34.0f), 0); + run_FloatQuery(Float_filterR, ShortParameter, Short.valueOf((short)100), Float.valueOf(100.0f), 2); + run_FloatQuery(Float_filterL, charParameter, Character.valueOf((char)0), Float.valueOf(0.0f), 1); + run_FloatQuery(Float_filterR, charParameter, Character.valueOf((char)23), Float.valueOf(23.0f), 0); + run_FloatQuery(Float_filterL, CharacterParameter, Character.valueOf((char)34), Float.valueOf(34.0f), 0); + run_FloatQuery(Float_filterR, CharacterParameter, Character.valueOf((char)100), Float.valueOf(100.0f), 2); + run_FloatQuery(Float_filterL, intParameter, Integer.valueOf(50000000), Float.valueOf(50000000.0f), 1); + run_FloatQuery(Float_filterR, intParameter, Integer.valueOf(23), Float.valueOf(23.0f), 0); + run_FloatQuery(Float_filterL, IntegerParameter, Integer.valueOf(34), Float.valueOf(34.0f), 0); + run_FloatQuery(Float_filterR, IntegerParameter, Integer.valueOf(100), Float.valueOf(100.0f), 2); + run_FloatQuery(Float_filterL, longParameter, Long.valueOf(50000000), Float.valueOf(50000000.0f), 1); + run_FloatQuery(Float_filterR, longParameter, Long.valueOf(23), Float.valueOf(23.0f), 0); + run_FloatQuery(Float_filterL, LongParameter, Long.valueOf(34), Float.valueOf(34.0f), 0); + run_FloatQuery(Float_filterR, LongParameter, Long.valueOf(100), Float.valueOf(100.0f), 2); + run_FloatQuery(Float_filterL, doubleParameter, Double.valueOf(50000000.0f), Float.valueOf(50000000.0f), 1); + run_FloatQuery(Float_filterR, doubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), 2); + run_FloatQuery(Float_filterL, DoubleParameter, Double.valueOf(0.0f), Float.valueOf(0.0f), 1); + run_FloatQuery(Float_filterR, DoubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), 2); + run_FloatQuery(Float_filterL, BigIntegerParameter, new BigInteger("50000000"), Float.valueOf(50000000.0f), 1); + run_FloatQuery(Float_filterR, BigIntegerParameter, new BigInteger("1000000000"), Float.valueOf(1000000000.0f), 1); + run_FloatQuery(Float_filterL, BigDecimalParameter, new BigDecimal("350.5"), Float.valueOf(350.5f), 1); + run_FloatQuery(Float_filterR, BigDecimalParameter, new BigDecimal("50000000.0"), Float.valueOf(50000000.0f), 1); + alltypes.setFloat(Float.valueOf(23.23f)); + run_FloatQuery(Float_filterObj, AllTypesParameter, alltypes, Float.valueOf(23.23f), 0); + run_FloatQuery(Float_filterVal, null, null, Float.valueOf(100.0f), 2); + + run_DoubleQuery(Double_filterL, doubleParameter, Double.valueOf(350.5), Double.valueOf(350.5), 1); + run_DoubleQuery(Double_filterR, doubleParameter, Double.valueOf(350.5), Double.valueOf(350.5), 1); + run_DoubleQuery(Double_filterL, DoubleParameter, Double.valueOf(0.0), Double.valueOf(0.0), 1); + run_DoubleQuery(Double_filterR, DoubleParameter, Double.valueOf(23.34), Double.valueOf(23.34), 0); + run_DoubleQuery(Double_filterL, byteParameter, Byte.valueOf((byte)100), Double.valueOf(100.0), 2); + run_DoubleQuery(Double_filterR, byteParameter, Byte.valueOf((byte)0), Double.valueOf(0.0), 1); + run_DoubleQuery(Double_filterL, ByteParameter, Byte.valueOf((byte)23), Double.valueOf(23.0), 0); + run_DoubleQuery(Double_filterR, ByteParameter, Byte.valueOf((byte)100), Double.valueOf(100.0), 2); + run_DoubleQuery(Double_filterL, shortParameter, Short.valueOf((short)100), Double.valueOf(100.0), 2); + run_DoubleQuery(Double_filterR, shortParameter, Short.valueOf((short)0), Double.valueOf(0.0), 1); + run_DoubleQuery(Double_filterL, ShortParameter, Short.valueOf((short)23), Double.valueOf(23.0), 0); + run_DoubleQuery(Double_filterR, ShortParameter, Short.valueOf((short)100), Double.valueOf(100.0), 2); + run_DoubleQuery(Double_filterL, charParameter, Character.valueOf((char)100), Double.valueOf(100.0), 2); + run_DoubleQuery(Double_filterR, charParameter, Character.valueOf((char)0), Double.valueOf(0.0), 1); + run_DoubleQuery(Double_filterL, CharacterParameter, Character.valueOf((char)23), Double.valueOf(23.0), 0); + run_DoubleQuery(Double_filterR, CharacterParameter, Character.valueOf((char)100), Double.valueOf(100.0), 2); + run_DoubleQuery(Double_filterL, intParameter, Integer.valueOf(100), Double.valueOf(100.0), 2); + run_DoubleQuery(Double_filterR, intParameter, Integer.valueOf(0), Double.valueOf(0.0), 1); + run_DoubleQuery(Double_filterL, IntegerParameter, Integer.valueOf(23), Double.valueOf(23.0), 0); + run_DoubleQuery(Double_filterR, IntegerParameter, Integer.valueOf(100), Double.valueOf(100.0), 2); + run_DoubleQuery(Double_filterL, longParameter, Long.valueOf(100), Double.valueOf(100.0), 2); + run_DoubleQuery(Double_filterR, longParameter, Long.valueOf(0), Double.valueOf(0.0), 1); + run_DoubleQuery(Double_filterL, LongParameter, Long.valueOf(23), Double.valueOf(23.0), 0); + run_DoubleQuery(Double_filterR, LongParameter, Long.valueOf(100), Double.valueOf(100.0), 2); + run_DoubleQuery(Double_filterL, floatParameter, Float.valueOf(0.0f), Double.valueOf(0.0f), 1); + run_DoubleQuery(Double_filterR, floatParameter, Float.valueOf(100.0f), Double.valueOf(100.0f), 2); + run_DoubleQuery(Double_filterL, FloatParameter, Float.valueOf(100.0f), Double.valueOf(100.0f), 2); + run_DoubleQuery(Double_filterR, FloatParameter, Float.valueOf(69.96f), Double.valueOf(69.96), 0); + run_DoubleQuery(Double_filterL, BigIntegerParameter, new BigInteger("50000000"), Double.valueOf(50000000.0f), 1); + run_DoubleQuery(Double_filterR, BigIntegerParameter, new BigInteger("1000000000"), Double.valueOf(1000000000.0f), 1); + run_DoubleQuery(Double_filterL, BigDecimalParameter, new BigDecimal("350.5"), Double.valueOf(350.5f), 1); + run_DoubleQuery(Double_filterR, BigDecimalParameter, new BigDecimal("50000000.0"), Double.valueOf(50000000.0f), 1); + alltypes.setDouble(Double.valueOf(-25.5)); + run_DoubleQuery(Double_filterObj, AllTypesParameter, alltypes, Double.valueOf(-25.5), 1); + run_DoubleQuery(Double_filterVal, null, null, Double.valueOf(-25.5), 1); + + run_StringQuery(String_filterL, StringParameter, new String("JDO"), new String("JDO"), 1); + run_StringQuery(String_filterR, StringParameter, new String("JDBC"), new String("JDBC"), 0); + alltypes.setString(new String("abcde")); + run_StringQuery(String_filterObj, AllTypesParameter, alltypes, new String("abcde"), 1); + run_StringQuery(String_filterVal1, null, null, new String("Java"), 2); + run_StringQuery(String_filterVal2, null, null, new String(""), 1); + + run_LocaleQuery(Locale_filterL, LocaleParameter, Locale.CANADA_FRENCH, Locale.CANADA_FRENCH, 0); + run_LocaleQuery(Locale_filterR, LocaleParameter, Locale.US, Locale.US, 1); + alltypes.setLocale(Locale.UK); + run_LocaleQuery(Locale_filterObj, AllTypesParameter, alltypes, Locale.UK, 1); + + BigDecimal bd = new BigDecimal("100.0"); + run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, 2); + bd = new BigDecimal("-234234.23333"); + run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, 1); + bd = new BigDecimal("989899.33304953"); + run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, 0); + bd = new BigDecimal("-1123123.22"); + run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, 1); + alltypes.setBigDecimal(bd); + run_BigDecimalQuery(BigDecimal_filterObj, AllTypesParameter, alltypes, bd, 1); + + BigInteger bi = new BigInteger("987034534985043985"); + run_BigIntegerQuery(BigInteger_filterL, BigIntegerParameter, bi, bi, 1); + bi = new BigInteger("-999999999999999999"); + run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, 1); + bi = new BigInteger("-99999999999999999"); + run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, 0); + bi = new BigInteger("1333330"); + alltypes.setBigInteger(bi); + run_BigIntegerQuery(BigInteger_filterObj, AllTypesParameter, alltypes, bi, 1); + + GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.UK); + gc.clear(); + gc.set(1999, Calendar.DECEMBER, 31, 9, 0, 0); + Date d = gc.getTime(); + run_DateQuery(Date_filterL, DateParameter, d, d, 1); + gc.set(1992, Calendar.NOVEMBER, 22, 9, 0, 0); + d = gc.getTime(); + run_DateQuery(Date_filterR, DateParameter, d, d, 1); + gc.set(1959, Calendar.OCTOBER, 9, 9, 0, 0); + d = gc.getTime(); + run_DateQuery(Date_filterR, DateParameter, d, d, 0); + gc.set(1995, Calendar.JUNE, 14, 9, 0, 0); + d = gc.getTime(); + alltypes.setDate(d); + run_DateQuery(Date_filterObj, AllTypesParameter, alltypes, d, 1); } - query.close(query_result); - tx.rollback(); - } - private void run_charQuery( - String filter, String parameter, Object parameterValue, char value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - char val = obj.getchar(); - if (val != value) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_booleanQuery(String filter, String parameter, Object parameterValue, boolean value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while(iter.hasNext()){ + AllTypes obj = (AllTypes) iter.next(); + boolean val = obj.getboolean(); + if (val != value) { + fail(ASSERTION_FAILED, "JDOQL Equality test returns object with incorrect value, retrieved value: " + val + ", expected value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_intQuery( - String filter, String parameter, Object parameterValue, int value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - int val = obj.getint(); - if (val != value) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_byteQuery(String filter, String parameter, Object parameterValue, byte value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + byte val = obj.getbyte(); + if( val != value ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_longQuery( - String filter, String parameter, Object parameterValue, long value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - long val = obj.getlong(); - if (val != value) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_shortQuery(String filter, String parameter, Object parameterValue, short value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + short val = obj.getshort(); + if( val != value ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_floatQuery( - String filter, String parameter, Object parameterValue, float value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - float val = obj.getfloat(); - if (val != value) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_charQuery(String filter, String parameter, Object parameterValue, char value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + char val = obj.getchar(); + if( val != value ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_doubleQuery( - String filter, String parameter, Object parameterValue, double value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - double val = obj.getdouble(); - if (val != value) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_intQuery(String filter, String parameter, Object parameterValue, int value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + int val = obj.getint(); + if( val != value ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_BooleanQuery( - String filter, String parameter, Object parameterValue, Boolean value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Boolean val = obj.getBoolean(); - if (!val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns object with incorrect value", - filter, - parameter); - } - cnt++; + private void run_longQuery(String filter, String parameter, Object parameterValue, long value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + long val = obj.getlong(); + if( val != value ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_ByteQuery( - String filter, String parameter, Object parameterValue, Byte value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Byte val = obj.getByte(); - if (!val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_floatQuery(String filter, String parameter, Object parameterValue, float value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + float val = obj.getfloat(); + if( val != value ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_ShortQuery( - String filter, String parameter, Object parameterValue, Short value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Short val = obj.getShort(); - if (!val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_doubleQuery(String filter, String parameter, Object parameterValue, double value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + double val = obj.getdouble(); + if( val != value ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_CharacterQuery( - String filter, String parameter, Object parameterValue, Character value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Character val = obj.getCharacter(); - if (!val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_BooleanQuery(String filter, String parameter, Object parameterValue, Boolean value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while(iter.hasNext()){ + AllTypes obj = (AllTypes) iter.next(); + Boolean val = obj.getBoolean(); + if( !val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns object with incorrect value", filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_IntegerQuery( - String filter, String parameter, Object parameterValue, Integer value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Integer val = obj.getInteger(); - if (!val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_ByteQuery(String filter, String parameter, Object parameterValue, Byte value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Byte val = obj.getByte(); + if( !val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_LongQuery( - String filter, String parameter, Object parameterValue, Long value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Long val = obj.getLong(); - if (!val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_ShortQuery(String filter, String parameter, Object parameterValue, Short value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Short val = obj.getShort(); + if( !val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_FloatQuery( - String filter, String parameter, Object parameterValue, Float value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Float val = obj.getFloat(); - if (!val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_CharacterQuery(String filter, String parameter, Object parameterValue, Character value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Character val = obj.getCharacter(); + if( !val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_DoubleQuery( - String filter, String parameter, Object parameterValue, Double value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Double val = obj.getDouble(); - if (!val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_IntegerQuery(String filter, String parameter, Object parameterValue, Integer value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Integer val = obj.getInteger(); + if( !val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_StringQuery( - String filter, String parameter, Object parameterValue, String value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - String val = obj.getString(); - if (!val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_LongQuery(String filter, String parameter, Object parameterValue, Long value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Long val = obj.getLong(); + if( !val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_LocaleQuery( - String filter, String parameter, Object parameterValue, Locale value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Locale val = obj.getLocale(); - if (!val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_FloatQuery(String filter, String parameter, Object parameterValue, Float value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Float val = obj.getFloat(); + if( !val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_BigDecimalQuery( - String filter, - String parameter, - Object parameterValue, - BigDecimal value, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - BigDecimal val = obj.getBigDecimal(); - // if( !val.equals(value) ){ - if (val.compareTo(value) != 0) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_DoubleQuery(String filter, String parameter, Object parameterValue, Double value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Double val = obj.getDouble(); + if( !val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + + private void run_StringQuery(String filter, String parameter, Object parameterValue, String value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + String val = obj.getString(); + if( !val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_BigIntegerQuery( - String filter, - String parameter, - Object parameterValue, - BigInteger value, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - BigInteger val = obj.getBigInteger(); - if (!val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_LocaleQuery(String filter, String parameter, Object parameterValue, Locale value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Locale val = obj.getLocale(); + if( !val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + + private void run_BigDecimalQuery(String filter, String parameter, Object parameterValue, BigDecimal value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + BigDecimal val = obj.getBigDecimal(); +// if( !val.equals(value) ){ + if( val.compareTo(value) != 0 ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_DateQuery( - String filter, String parameter, Object parameterValue, Date value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Date val = obj.getDate(); - if (!val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_BigIntegerQuery(String filter, String parameter, Object parameterValue, BigInteger value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + BigInteger val = obj.getBigInteger(); + if( !val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Equality test returns wrong number of instances", - filter, - parameter); + + private void run_DateQuery(String filter, String parameter, Object parameterValue, Date value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Date val = obj.getDate(); + if( !val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Equality test returns wrong number of instances", filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - /** */ - protected void localSetUp() { - addTearDownClass(AllTypes.class); - AllTypes.load(getPM()); - } + /** */ + protected void localSetUp() { + addTearDownClass(AllTypes.class); + AllTypes.load(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/EqualityAndComparisonsBetweenDateFieldsAndParameters.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/EqualityAndComparisonsBetweenDateFieldsAndParameters.java index f7702353f..589be33e5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/EqualityAndComparisonsBetweenDateFieldsAndParameters.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/EqualityAndComparisonsBetweenDateFieldsAndParameters.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -22,8 +22,8 @@ import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Map; -import javax.jdo.JDOQLTypedQuery; -import javax.jdo.query.DateTimeExpression; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.QEmployee; @@ -31,164 +31,176 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; +import javax.jdo.query.DateTimeExpression; + /** - * Title: Equality and Comparisons Between Date Fields and Parameters
    - * Keywords: query
    - * Assertion ID: A14.6.2-4.
    - * Assertion Description: Equality and ordering comparisons of Date fields and - * Date parameters are valid in a Query filter. + *Title: Equality and Comparisons Between Date Fields and Parameters + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-4. + *
    + *Assertion Description: +Equality and ordering comparisons of Date fields and +Date parameters are valid in a Query filter. */ -public class EqualityAndComparisonsBetweenDateFieldsAndParameters extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-4 (EqualityAndComparisonsBetweenDateFieldsAndParameters) failed: "; - - /** */ - private static final Date FIRST_OF_JAN_1999; - - static { - // initialize static field FIRST_OF_JAN_1999 - Calendar cal = new GregorianCalendar(); - cal.set(1999, GregorianCalendar.JANUARY, 1, 0, 0, 0); - cal.set(GregorianCalendar.MILLISECOND, 0); - FIRST_OF_JAN_1999 = cal.getTime(); - } - - /** Parameters of valid queries. */ - private Object[][] parameters = { - // date field == date parameter - {FIRST_OF_JAN_1999}, - // date field >= date parameter - {FIRST_OF_JAN_1999}, - // date field >= date parameter - {FIRST_OF_JAN_1999} - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(EqualityAndComparisonsBetweenDateFieldsAndParameters.class); - } - - /** */ - public void testFieldEqualsParameter() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - DateTimeExpression param = query.datetimeParameter("param"); - query.filter(cand.hiredate.eq(param)); - - Map paramValues = new HashMap<>(); - paramValues.put("param", FIRST_OF_JAN_1999); - - // date field == date parameter - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "hiredate == param", - /*VARIABLES*/ null, - /*PARAMETERS*/ "java.util.Date param", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testFieldGEParameter() { - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3", "emp4"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - DateTimeExpression param = query.datetimeParameter("param"); - query.filter(cand.hiredate.gteq(param)); - - Map paramValues = new HashMap<>(); - paramValues.put("param", FIRST_OF_JAN_1999); - - // date field >= date parameter - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "hiredate >= param", - /*VARIABLES*/ null, - /*PARAMETERS*/ "java.util.Date param", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testParameterLTField() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - DateTimeExpression param = query.datetimeParameter("param"); - query.filter(param.lt(cand.birthdate)); - - Map paramValues = new HashMap<>(); - paramValues.put("param", FIRST_OF_JAN_1999); - - // Import Department twice - QueryElementHolder holder = // date parameter < date field - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "param < birthdate", - /*VARIABLES*/ null, - /*PARAMETERS*/ "java.util.Date param", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + +public class EqualityAndComparisonsBetweenDateFieldsAndParameters + extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-4 (EqualityAndComparisonsBetweenDateFieldsAndParameters) failed: "; + + /** */ + private static final Date FIRST_OF_JAN_1999; + static { + // initialize static field FIRST_OF_JAN_1999 + Calendar cal = new GregorianCalendar(); + cal.set(1999, GregorianCalendar.JANUARY, 1, 0, 0, 0); + cal.set(GregorianCalendar.MILLISECOND, 0); + FIRST_OF_JAN_1999 = cal.getTime(); + } + + /** Parameters of valid queries. */ + private Object[][] parameters = { + // date field == date parameter + {FIRST_OF_JAN_1999}, + // date field >= date parameter + {FIRST_OF_JAN_1999}, + // date field >= date parameter + {FIRST_OF_JAN_1999} + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(EqualityAndComparisonsBetweenDateFieldsAndParameters.class); + } + + /** + * + */ + public void testFieldEqualsParameter() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + DateTimeExpression param = query.datetimeParameter("param"); + query.filter(cand.hiredate.eq(param)); + + Map paramValues = new HashMap<>(); + paramValues.put("param", FIRST_OF_JAN_1999); + + // date field == date parameter + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "hiredate == param", + /*VARIABLES*/ null, + /*PARAMETERS*/ "java.util.Date param", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * + */ + public void testFieldGEParameter() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + DateTimeExpression param = query.datetimeParameter("param"); + query.filter(cand.hiredate.gteq(param)); + + Map paramValues = new HashMap<>(); + paramValues.put("param", FIRST_OF_JAN_1999); + + // date field >= date parameter + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "hiredate >= param", + /*VARIABLES*/ null, + /*PARAMETERS*/ "java.util.Date param", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * + */ + public void testParameterLTField() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + DateTimeExpression param = query.datetimeParameter("param"); + query.filter(param.lt(cand.birthdate)); + + Map paramValues = new HashMap<>(); + paramValues.put("param", FIRST_OF_JAN_1999); + + // Import Department twice + QueryElementHolder holder = // date parameter < date field + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "param < birthdate", + /*VARIABLES*/ null, + /*PARAMETERS*/ "java.util.Date param", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/EqualityAndComparisonsBetweenPrimitivesAndWrapperInstances.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/EqualityAndComparisonsBetweenPrimitivesAndWrapperInstances.java index f27eddfdb..6822c9337 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/EqualityAndComparisonsBetweenPrimitivesAndWrapperInstances.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/EqualityAndComparisonsBetweenPrimitivesAndWrapperInstances.java @@ -5,91 +5,104 @@ * 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 + * + * 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.jdo.tck.query.jdoql.operators; import java.util.Collection; import java.util.HashSet; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Equality and Comparisons Between Primitives and Wrapper Instances
    - * Keywords: query
    - * Assertion ID: A14.6.2-3.
    - * Assertion Description: Equality and ordering comparisons between primitives and instances - * of wrapper classes are valid in a Query filter. + *Title: Equality and Comparisons Between Primitives and Wrapper + Instances + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-3. + *
    + *Assertion Description: Equality and ordering comparisons between + * primitives and instances of wrapper classes are valid in a Query + * filter. */ -public class EqualityAndComparisonsBetweenPrimitivesAndWrapperInstances extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-3 (EqualityAndComparisonsBetweenPrimitivesAndWrapperInstances) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(EqualityAndComparisonsBetweenPrimitivesAndWrapperInstances.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - - Collection instance9 = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 9").execute(); - Collection instancesLess3 = (Collection) pm.newQuery(PrimitiveTypes.class, "id < 3").execute(); - Collection allOddInstances = - (Collection) pm.newQuery(PrimitiveTypes.class, "booleanNull").execute(); - Collection allInstances = (Collection) pm.newQuery(PrimitiveTypes.class, "true").execute(); - Collection empty = new HashSet(); - - // case Integer == int - runSimplePrimitiveTypesQuery("intNull == 9", pm, instance9, ASSERTION_FAILED); - - // case Integer == long - runSimplePrimitiveTypesQuery("intNull == 9L", pm, instance9, ASSERTION_FAILED); - // case char == Character - runSimplePrimitiveTypesQuery("'O' == charNull", pm, allOddInstances, ASSERTION_FAILED); +public class EqualityAndComparisonsBetweenPrimitivesAndWrapperInstances + extends QueryTest { - // case int <= Integer - runParameterPrimitiveTypesQuery( - "intNotNull <= param", - "java.lang.Integer param", - Integer.valueOf(2), - pm, - instancesLess3, - ASSERTION_FAILED); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-3 (EqualityAndComparisonsBetweenPrimitivesAndWrapperInstances) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(EqualityAndComparisonsBetweenPrimitivesAndWrapperInstances.class); + } - // case Double > double - runSimplePrimitiveTypesQuery("doubleNull > 0.0", pm, allInstances, ASSERTION_FAILED); + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); - tx.commit(); - } + Collection instance9 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 9").execute(); + Collection instancesLess3 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id < 3").execute(); + Collection allOddInstances = (Collection)pm.newQuery( + PrimitiveTypes.class, "booleanNull").execute(); + Collection allInstances = (Collection)pm.newQuery( + PrimitiveTypes.class, "true").execute(); + Collection empty = new HashSet(); + + // case Integer == int + runSimplePrimitiveTypesQuery("intNull == 9", + pm, instance9, ASSERTION_FAILED); + + // case Integer == long + runSimplePrimitiveTypesQuery("intNull == 9L", + pm, instance9, ASSERTION_FAILED); + + // case char == Character + runSimplePrimitiveTypesQuery("'O' == charNull", + pm, allOddInstances, ASSERTION_FAILED); + + // case int <= Integer + runParameterPrimitiveTypesQuery( + "intNotNull <= param", "java.lang.Integer param", Integer.valueOf(2), + pm, instancesLess3, ASSERTION_FAILED); + + // case Double > double + runSimplePrimitiveTypesQuery("doubleNull > 0.0", + pm, allInstances, ASSERTION_FAILED); + + tx.commit(); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PrimitiveTypes.class); - loadAndPersistPrimitiveTypes(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PrimitiveTypes.class); + loadAndPersistPrimitiveTypes(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/EqualityAndComparisonsBetweenStringFieldsAndParameters.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/EqualityAndComparisonsBetweenStringFieldsAndParameters.java index 763669c6d..ed54e130f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/EqualityAndComparisonsBetweenStringFieldsAndParameters.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/EqualityAndComparisonsBetweenStringFieldsAndParameters.java @@ -5,22 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql.operators; -import java.util.HashMap; -import java.util.Map; -import javax.jdo.JDOQLTypedQuery; -import javax.jdo.query.StringExpression; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.QEmployee; @@ -28,139 +25,147 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; +import javax.jdo.query.StringExpression; +import java.util.HashMap; +import java.util.Map; + /** - * Title: Equality and Comparisons Between String Fields and Parameters
    - * Keywords: query
    - * Assertion ID: A14.6.2-5.
    - * Assertion Description: Equality and ordering comparisons of String fields - * and String parameters are valid. The comparison is done lexicographically. + *Title: Equality and Comparisons Between String Fields and Parameters + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-5. + *
    + *Assertion Description: +Equality and ordering comparisons of String fields and +String parameters are valid. +The comparison is done lexicographically. */ -public class EqualityAndComparisonsBetweenStringFieldsAndParameters extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-5 (EqualityAndComparisonsBetweenStringFieldsAndParameters) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(EqualityAndComparisonsBetweenStringFieldsAndParameters.class); - } - - public void testStringFieldEqualsStringParameter() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - StringExpression paramVariable = query.stringParameter("param"); - query.filter(cand.firstname.eq(paramVariable)); - - Map paramValues = new HashMap<>(); - paramValues.put("param", "emp1First"); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname == param", - /*VARIABLES*/ null, - /*PARAMETERS*/ "java.lang.String param", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - public void testStringFieldGEStringParameter() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - StringExpression paramVariable = query.stringParameter("param"); - query.filter(cand.firstname.gteq(paramVariable)); - - Map paramValues = new HashMap<>(); - paramValues.put("param", "emp1First"); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname >= param", - /*VARIABLES*/ null, - /*PARAMETERS*/ "java.lang.String param", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - public void testStringParameterLTStringField() { - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - StringExpression paramVariable = query.stringParameter("param"); - query.filter(paramVariable.lt(cand.firstname)); - - Map paramValues = new HashMap<>(); - paramValues.put("param", "emp2First"); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "param < firstname", - /*VARIABLES*/ null, - /*PARAMETERS*/ "java.lang.String param", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + +public class EqualityAndComparisonsBetweenStringFieldsAndParameters + extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-5 (EqualityAndComparisonsBetweenStringFieldsAndParameters) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(EqualityAndComparisonsBetweenStringFieldsAndParameters.class); + } + + public void testStringFieldEqualsStringParameter() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + StringExpression paramVariable = query.stringParameter("param"); + query.filter(cand.firstname.eq(paramVariable)); + + Map paramValues = new HashMap<>(); + paramValues.put("param", "emp1First"); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname == param", + /*VARIABLES*/ null, + /*PARAMETERS*/ "java.lang.String param", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + public void testStringFieldGEStringParameter() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + StringExpression paramVariable = query.stringParameter("param"); + query.filter(cand.firstname.gteq(paramVariable)); + + Map paramValues = new HashMap<>(); + paramValues.put("param", "emp1First"); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname >= param", + /*VARIABLES*/ null, + /*PARAMETERS*/ "java.lang.String param", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + public void testStringParameterLTStringField() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + StringExpression paramVariable = query.stringParameter("param"); + query.filter(paramVariable.lt(cand.firstname)); + + Map paramValues = new HashMap<>(); + paramValues.put("param", "emp2First"); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "param < firstname", + /*VARIABLES*/ null, + /*PARAMETERS*/ "java.lang.String param", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/GreaterThan.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/GreaterThan.java index b0c220275..1bf8e2f33 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/GreaterThan.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/GreaterThan.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -25,2352 +25,1172 @@ import java.util.Iterator; import java.util.Locale; import java.util.TimeZone; + import org.apache.jdo.tck.pc.fieldtypes.AllTypes; import org.apache.jdo.tck.util.BatchTestRunner; -/** - * Title: Greater Than Query Operator
    - * Keywords: query
    - * Assertion ID: A14.6.2-16.
    - * Assertion Description: The greater than operator (>) is supported for all - * types as they are defined in the Java language. This includes the following types: - * - *
      - *
    • byte, short, int, long, char, Byte, Short Integer, Long, Character - *
    • float, double, Float, Double - *
    • BigDecimal, BigInteger - *
    • Date, String - *
    - * - * The operation on object-valued fields of wrapper types (Boolean, Byte, - * Short, Integer, Long, Float, and Double), and numeric types (BigDecimal - * and BigInteger) use the wrapped values as operands. - */ -public class GreaterThan extends ComparisonTests { - private static String boolean_filterL = "value > fld_boolean"; - private static String boolean_filterR = "fld_boolean > value"; - private static String boolean_filterT = "fld_boolean > true"; - private static String boolean_filterF = "false > fld_boolean"; - private static String boolean_filterObj = "value.fld_boolean > fld_boolean"; - - private static String byte_filterL = "value > fld_byte"; - private static String byte_filterR = "fld_byte > value"; - private static String byte_filterObj = "value.fld_byte > fld_byte"; - private static String byte_filterVal = "fld_byte > 100"; - - private static String char_filterL = "value > fld_char"; - private static String char_filterR = "fld_char > value"; - private static String char_filterObj = "value.fld_char > fld_char"; - private static String char_filterVal = "'M' > fld_char"; - - private static String double_filterL = "value > fld_double"; - private static String double_filterR = "fld_double > value"; - private static String double_filterObj = "value.fld_double > fld_double"; - private static String double_filterVal = "fld_double > 100.0"; - - private static String float_filterL = "value > fld_float"; - private static String float_filterR = "fld_float > value"; - private static String float_filterObj = "fld_float > value.fld_float"; - private static String float_filterVal = "fld_float > 100.0"; - - private static String int_filterL = "value > fld_int"; - private static String int_filterR = "fld_int > value"; - private static String int_filterObj = "value.fld_int > fld_int"; - private static String int_filterVal = "fld_int > 1000"; - - private static String long_filterL = "value > fld_long"; - private static String long_filterR = "fld_long > value"; - private static String long_filterObj = "fld_long > value.fld_long"; - private static String long_filterVal = "fld_long > 1000000"; - - private static String short_filterL = "value > fld_short"; - private static String short_filterR = "fld_short > value"; - private static String short_filterObj = "value.fld_short > fld_short"; - private static String short_filterVal = "1000 > fld_short"; - - private static String Boolean_filterL = "value > fld_Boolean"; - private static String Boolean_filterR = "fld_Boolean > value"; - private static String Boolean_filterT = "fld_Boolean > true"; - private static String Boolean_filterF = "false > fld_Boolean"; - private static String Boolean_filterObj = "value.fld_Boolean > fld_Boolean"; - private static String Boolean_filterVal = "fld_Boolean > false"; - - private static String Byte_filterL = "value > fld_Byte"; - private static String Byte_filterR = "fld_Byte > value"; - private static String Byte_filterObj = "fld_Byte > value.fld_Byte"; - private static String Byte_filterVal = "100 > fld_Byte"; - - private static String Character_filterL = "value > fld_Character"; - private static String Character_filterR = "fld_Character > value"; - private static String Character_filterObj = "value.fld_Character > fld_Character"; - private static String Character_filterVal = "fld_Character > 'z'"; - - private static String Double_filterL = "value > fld_Double"; - private static String Double_filterR = "fld_Double > value"; - private static String Double_filterObj = "value.fld_Double > fld_Double"; - private static String Double_filterVal = "fld_Double > 100.0"; - - private static String Float_filterL = "value > fld_Float"; - private static String Float_filterR = "fld_Float > value"; - private static String Float_filterObj = "fld_Float > value.fld_Float"; - private static String Float_filterVal = "100.0f > fld_Float"; - - private static String Integer_filterL = "value > fld_Integer"; - private static String Integer_filterR = "fld_Integer > value"; - private static String Integer_filterObj = "fld_Integer > value.fld_Integer"; - private static String Integer_filterVal = "fld_Integer > 100"; - - private static String Long_filterL = "value > fld_Long"; - private static String Long_filterR = "fld_Long > value"; - private static String Long_filterObj = "value.fld_Long > fld_Long"; - private static String Long_filterVal = "-1000 > fld_Long"; - - private static String Short_filterL = "value > fld_Short"; - private static String Short_filterR = "fld_Short > value"; - private static String Short_filterObj = "fld_Short > value.fld_Short"; - private static String Short_filterVal = "-1000 > fld_Short"; - - private static String String_filterL = "value > fld_String"; - private static String String_filterR = "fld_String > value"; - private static String String_filterObj = "value.fld_String > fld_String"; - private static String String_filterVal1 = "fld_String > \"Java\""; - private static String String_filterVal2 = "fld_String > \"\""; - - private static String Date_filterL = "value > fld_Date"; - private static String Date_filterR = "fld_Date > value"; - private static String Date_filterObj = "fld_Date > value.fld_Date"; - - private static String BigDecimal_filterL = "value > fld_BigDecimal"; - private static String BigDecimal_filterR = "fld_BigDecimal > value"; - private static String BigDecimal_filterObj = "value.fld_BigDecimal > fld_BigDecimal"; - - private static String BigInteger_filterL = "value > fld_BigInteger"; - private static String BigInteger_filterR = "fld_BigInteger > value"; - private static String BigInteger_filterObj = "fld_BigInteger > value.fld_BigInteger"; - - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.2-16 (GreaterThan) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GreaterThan.class); - } - - /** */ - public void test() { - pm = getPM(); - tx = pm.currentTransaction(); - runQueries(); - } - - /** */ - private void runQueries() { - AllTypes alltypes = new AllTypes(); - run_byteQuery(byte_filterL, byteParameter, Byte.valueOf((byte) 0), (byte) 0, true, 3); - run_byteQuery( - byte_filterR, byteParameter, Byte.valueOf(Byte.MIN_VALUE), Byte.MIN_VALUE, false, 9); - run_byteQuery(byte_filterL, ByteParameter, Byte.valueOf((byte) 50), (byte) 50, true, 5); - run_byteQuery( - byte_filterR, ByteParameter, Byte.valueOf(Byte.MAX_VALUE), Byte.MAX_VALUE, false, 0); - run_byteQuery(byte_filterL, shortParameter, Short.valueOf((short) 75), (byte) 75, true, 7); - run_byteQuery(byte_filterR, shortParameter, Short.valueOf((short) 75), (byte) 75, false, 2); - run_byteQuery(byte_filterL, ShortParameter, Short.valueOf((short) 10), (byte) 10, true, 4); - run_byteQuery(byte_filterR, ShortParameter, Short.valueOf((short) 25), (byte) 25, false, 5); - run_byteQuery(byte_filterL, charParameter, Character.valueOf((char) 101), (byte) 101, true, 9); - run_byteQuery(byte_filterR, charParameter, Character.valueOf((char) 50), (byte) 50, false, 3); - run_byteQuery(byte_filterL, CharacterParameter, Character.valueOf((char) 0), (byte) 0, true, 3); - run_byteQuery( - byte_filterR, CharacterParameter, Character.valueOf((char) 0), (byte) 0, false, 6); - run_byteQuery(byte_filterL, intParameter, Integer.valueOf(25), (byte) 25, true, 5); - run_byteQuery(byte_filterR, intParameter, Integer.valueOf(50), (byte) 50, false, 3); - run_byteQuery(byte_filterL, IntegerParameter, Integer.valueOf(-10), (byte) -10, true, 2); - run_byteQuery(byte_filterR, IntegerParameter, Integer.valueOf(-100), (byte) -100, false, 8); - run_byteQuery(byte_filterL, longParameter, Long.valueOf(50), (byte) 50, true, 5); - run_byteQuery(byte_filterR, longParameter, Long.valueOf(60), (byte) 60, false, 3); - run_byteQuery(byte_filterL, LongParameter, Long.valueOf(-100), (byte) -100, true, 1); - run_byteQuery(byte_filterR, LongParameter, Long.valueOf(-100), (byte) -100, false, 8); - run_byteQuery(byte_filterL, floatParameter, Float.valueOf((float) 51), (byte) 51, true, 7); - run_byteQuery(byte_filterR, floatParameter, Float.valueOf((float) -20), (byte) -20, false, 8); - run_byteQuery(byte_filterL, FloatParameter, Float.valueOf((float) -99), (byte) -99, true, 2); - run_byteQuery(byte_filterR, FloatParameter, Float.valueOf((float) -100), (byte) -100, false, 8); - run_byteQuery(byte_filterL, doubleParameter, Double.valueOf(50), (byte) 50, true, 5); - run_byteQuery(byte_filterR, doubleParameter, Double.valueOf(60), (byte) 60, false, 3); - run_byteQuery( - byte_filterL, DoubleParameter, Double.valueOf(Byte.MAX_VALUE), Byte.MAX_VALUE, true, 9); - run_byteQuery(byte_filterR, DoubleParameter, Double.valueOf(25), (byte) 25, false, 5); - run_byteQuery(byte_filterL, BigIntegerParameter, new BigInteger("50"), (byte) 50, true, 5); - run_byteQuery(byte_filterR, BigIntegerParameter, new BigInteger("-100"), (byte) -100, false, 8); - run_byteQuery( - byte_filterL, BigDecimalParameter, new BigDecimal("50.000000"), (byte) 50, true, 5); - run_byteQuery( - byte_filterR, BigDecimalParameter, new BigDecimal("10.00000"), (byte) 10, false, 5); - alltypes.setbyte((byte) 50); - run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte) 50, true, 5); - alltypes.setbyte((byte) 55); - run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte) 55, true, 7); - run_byteQuery(byte_filterVal, null, null, (byte) 100, false, 1); - - run_shortQuery(short_filterL, shortParameter, Short.valueOf((short) 100), (short) 100, true, 5); - run_shortQuery( - short_filterR, shortParameter, Short.valueOf((short) 100), (short) 100, false, 3); - run_shortQuery( - short_filterL, ShortParameter, Short.valueOf(Short.MIN_VALUE), Short.MIN_VALUE, true, 0); - run_shortQuery( - short_filterR, ShortParameter, Short.valueOf((short) 253), (short) 253, false, 3); - run_shortQuery( - short_filterR, shortParameter, Short.valueOf((short) 1000), (short) 1000, false, 2); - run_shortQuery(short_filterL, byteParameter, Byte.valueOf((byte) 75), (short) 75, true, 5); - run_shortQuery(short_filterR, byteParameter, Byte.valueOf((byte) -75), (short) -75, false, 6); - run_shortQuery(short_filterL, ByteParameter, Byte.valueOf((byte) 100), (short) 100, true, 5); - run_shortQuery(short_filterR, ByteParameter, Byte.valueOf((byte) 100), (short) 100, false, 3); - run_shortQuery(short_filterL, charParameter, Character.valueOf((char) 75), (short) 75, true, 5); - run_shortQuery( - short_filterR, charParameter, Character.valueOf((char) 9999), (short) 9999, false, 2); - run_shortQuery( - short_filterL, CharacterParameter, Character.valueOf((char) 1000), (short) 1000, true, 7); - run_shortQuery( - short_filterR, - CharacterParameter, - Character.valueOf((char) 10000), - (short) 10000, - false, - 1); - run_shortQuery(short_filterL, intParameter, Integer.valueOf(-10000), (short) -10000, true, 1); - run_shortQuery(short_filterR, intParameter, Integer.valueOf(-10000), (short) -10000, false, 8); - run_shortQuery(short_filterL, IntegerParameter, Integer.valueOf(10000), (short) 10000, true, 8); - run_shortQuery( - short_filterR, IntegerParameter, Integer.valueOf(30000), (short) 30000, false, 1); - run_shortQuery(short_filterL, longParameter, Long.valueOf(10000), (short) 10000, true, 8); - run_shortQuery( - short_filterR, longParameter, Long.valueOf(Short.MAX_VALUE), Short.MAX_VALUE, false, 0); - run_shortQuery( - short_filterL, LongParameter, Long.valueOf(Short.MAX_VALUE), Short.MAX_VALUE, true, 9); - run_shortQuery(short_filterR, LongParameter, Long.valueOf(100), (short) 100, false, 3); - run_shortQuery( - short_filterL, floatParameter, Float.valueOf((float) 23000), (short) 23000, true, 9); - run_shortQuery( - short_filterR, floatParameter, Float.valueOf((float) 23000), (short) 23000, false, 1); - run_shortQuery( - short_filterL, FloatParameter, Float.valueOf((float) -1000), (short) -1000, true, 2); - run_shortQuery( - short_filterR, FloatParameter, Float.valueOf((float) 100), (short) 100, false, 3); - run_shortQuery( - short_filterL, doubleParameter, Double.valueOf(-10000.0), (short) -10000, true, 1); - run_shortQuery(short_filterR, doubleParameter, Double.valueOf(9999.0), (short) 9999, false, 2); - run_shortQuery(short_filterL, DoubleParameter, Double.valueOf(23.0), (short) 23, true, 5); - run_shortQuery(short_filterR, DoubleParameter, Double.valueOf(23.0), (short) 23, false, 5); - run_shortQuery( - short_filterL, BigIntegerParameter, new BigInteger("10000"), (short) 10000, true, 8); - run_shortQuery( - short_filterR, BigIntegerParameter, new BigInteger("30000"), (short) 30000, false, 1); - run_shortQuery(short_filterL, BigDecimalParameter, new BigDecimal("23.0"), (short) 23, true, 5); - run_shortQuery( - short_filterR, BigDecimalParameter, new BigDecimal("23.0"), (short) 23, false, 5); - alltypes.setshort((short) 100); - run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short) 100, true, 5); - alltypes.setshort((short) 23); - run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short) 23, true, 5); - run_shortQuery(short_filterVal, null, null, (short) 1000, true, 7); - - run_charQuery( - char_filterL, - charParameter, - Character.valueOf(Character.MIN_VALUE), - Character.MIN_VALUE, - true, - 0); - run_charQuery( - char_filterR, - charParameter, - Character.valueOf(Character.MAX_VALUE), - Character.MAX_VALUE, - false, - 0); - run_charQuery(char_filterL, charParameter, Character.valueOf('C'), 'C', true, 4); - run_charQuery(char_filterR, charParameter, Character.valueOf('z'), 'z', false, 1); - run_charQuery(char_filterL, CharacterParameter, Character.valueOf(' '), ' ', true, 1); - run_charQuery(char_filterR, CharacterParameter, Character.valueOf('f'), 'f', false, 3); - run_charQuery( - char_filterL, - byteParameter, - Byte.valueOf((byte) Character.MIN_VALUE), - (char) Character.MIN_VALUE, - true, - 0); - run_charQuery(char_filterR, ByteParameter, Byte.valueOf((byte) 'a'), 'a', false, 3); - run_charQuery(char_filterL, shortParameter, Short.valueOf((short) 'M'), 'M', true, 5); - run_charQuery(char_filterR, shortParameter, Short.valueOf((short) 'M'), 'M', false, 3); - run_charQuery(char_filterL, ShortParameter, Short.valueOf((short) 'A'), 'A', true, 2); - run_charQuery(char_filterR, ShortParameter, Short.valueOf((short) 'A'), 'A', false, 7); - run_charQuery(char_filterL, intParameter, Integer.valueOf('z'), 'z', true, 7); - run_charQuery(char_filterR, intParameter, Integer.valueOf('z'), 'z', false, 1); - run_charQuery(char_filterL, IntegerParameter, Integer.valueOf('B'), 'B', true, 3); - run_charQuery(char_filterR, IntegerParameter, Integer.valueOf('B'), 'B', false, 6); - run_charQuery(char_filterL, floatParameter, Float.valueOf((float) 'f'), 'f', true, 7); - run_charQuery(char_filterR, floatParameter, Float.valueOf((float) ' '), ' ', false, 8); - run_charQuery(char_filterL, FloatParameter, Float.valueOf((float) 'z'), 'z', true, 7); - run_charQuery(char_filterR, FloatParameter, Float.valueOf((float) 'z'), 'z', false, 1); - run_charQuery(char_filterL, doubleParameter, Double.valueOf('B'), 'B', true, 3); - run_charQuery(char_filterR, doubleParameter, Double.valueOf('B'), 'B', false, 6); - run_charQuery(char_filterL, DoubleParameter, Double.valueOf('A'), 'A', true, 2); - run_charQuery(char_filterR, DoubleParameter, Double.valueOf('A'), 'A', false, 7); - run_charQuery( - char_filterL, BigIntegerParameter, new BigInteger("65"), 'A', true, 2); // 'A' == 65 - run_charQuery( - char_filterR, BigIntegerParameter, new BigInteger("122"), 'z', false, 1); // 'z' == 122 - run_charQuery(char_filterL, BigDecimalParameter, new BigDecimal("65.00000"), 'A', true, 2); - run_charQuery( - char_filterR, BigDecimalParameter, new BigDecimal("77.0000"), 'M', false, 3); // 'M' == 77 - alltypes.setchar('A'); - run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'A', true, 2); - alltypes.setchar('b'); - run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'b', true, 7); - run_charQuery(char_filterVal, null, null, 'M', true, 5); - run_intQuery( - int_filterL, - intParameter, - Integer.valueOf(AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - true, - 0); - run_intQuery( - int_filterR, - intParameter, - Integer.valueOf(AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - false, - 0); - run_intQuery(int_filterR, intParameter, Integer.valueOf(23), 23, false, 6); - run_intQuery(int_filterL, IntegerParameter, Integer.valueOf(1000000), 1000000, true, 8); - run_intQuery(int_filterR, IntegerParameter, Integer.valueOf(1000), 1000, false, 3); - run_intQuery(int_filterL, byteParameter, Byte.valueOf((byte) 100), 100, true, 4); - run_intQuery(int_filterR, byteParameter, Byte.valueOf((byte) 0), 0, false, 6); - run_intQuery(int_filterL, ByteParameter, Byte.valueOf((byte) 100), 100, true, 4); - run_intQuery(int_filterR, ByteParameter, Byte.valueOf((byte) 0), 0, false, 6); - run_intQuery(int_filterL, shortParameter, Short.valueOf((short) 10000), 10000, true, 7); - run_intQuery(int_filterR, shortParameter, Short.valueOf((short) -1000), -1000, false, 7); - run_intQuery(int_filterL, ShortParameter, Short.valueOf((short) -1000), -1000, true, 2); - run_intQuery(int_filterR, ShortParameter, Short.valueOf((short) 10000), 10000, false, 2); - run_intQuery(int_filterL, charParameter, Character.valueOf((char) 100), 100, true, 4); - run_intQuery(int_filterR, charParameter, Character.valueOf((char) 0), 0, false, 6); - run_intQuery(int_filterL, CharacterParameter, Character.valueOf((char) 100), 100, true, 4); - run_intQuery(int_filterR, CharacterParameter, Character.valueOf((char) 10000), 10000, false, 2); - run_intQuery( - int_filterL, - longParameter, - Long.valueOf(AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - true, - 9); - run_intQuery( - int_filterR, - longParameter, - Long.valueOf(AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - false, - 9); - run_intQuery(int_filterL, LongParameter, Long.valueOf(10000), 10000, true, 7); - run_intQuery(int_filterR, LongParameter, Long.valueOf(43), 43, false, 6); - run_intQuery( - int_filterL, - floatParameter, - Float.valueOf((float) AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - true, - 9); - run_intQuery( - int_filterR, - floatParameter, - Float.valueOf((float) AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - false, - 9); - run_intQuery(int_filterL, FloatParameter, Float.valueOf((float) 10000), 10000, true, 7); - run_intQuery(int_filterR, FloatParameter, Float.valueOf((float) 43), 43, false, 6); - run_intQuery( - int_filterL, - doubleParameter, - Double.valueOf(AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - true, - 9); - run_intQuery( - int_filterR, - doubleParameter, - Double.valueOf(AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - false, - 9); - run_intQuery(int_filterL, DoubleParameter, Double.valueOf(10000.0), 10000, true, 7); - run_intQuery(int_filterR, DoubleParameter, Double.valueOf(43.0), 43, false, 6); - run_intQuery(int_filterL, BigIntegerParameter, new BigInteger("1000000"), 1000000, true, 8); - run_intQuery(int_filterR, BigIntegerParameter, new BigInteger("1000"), 1000, false, 3); - run_intQuery(int_filterL, BigDecimalParameter, new BigDecimal("10000.0"), 10000, true, 7); - run_intQuery(int_filterR, BigDecimalParameter, new BigDecimal("43.0"), 43, false, 6); - alltypes.setint(100); - run_intQuery(int_filterObj, AllTypesParameter, alltypes, 100, true, 4); - run_intQuery(int_filterVal, null, null, 1000, false, 3); - - run_longQuery( - long_filterL, longParameter, Long.valueOf(Long.MIN_VALUE), Long.MIN_VALUE, true, 0); - run_longQuery( - long_filterR, longParameter, Long.valueOf(Long.MAX_VALUE), Long.MAX_VALUE, false, 0); - run_longQuery(long_filterL, LongParameter, Long.valueOf(100), 100, true, 5); - run_longQuery(long_filterR, LongParameter, Long.valueOf(23), 23, false, 5); - run_longQuery(long_filterL, byteParameter, Byte.valueOf((byte) 100), 100, true, 5); - run_longQuery(long_filterR, byteParameter, Byte.valueOf((byte) 0), 0, false, 5); - run_longQuery(long_filterL, ByteParameter, Byte.valueOf((byte) 100), 100, true, 5); - run_longQuery(long_filterR, ByteParameter, Byte.valueOf((byte) 0), 0, false, 5); - run_longQuery(long_filterL, shortParameter, Short.valueOf((short) -1000), -1000, true, 2); - run_longQuery(long_filterR, shortParameter, Short.valueOf((short) 1000), 1000, false, 2); - run_longQuery(long_filterL, ShortParameter, Short.valueOf((short) 100), 100, true, 5); - run_longQuery(long_filterR, ShortParameter, Short.valueOf((short) 32), 32, false, 5); - run_longQuery(long_filterL, charParameter, Character.valueOf((char) 0), 0, true, 4); - run_longQuery(long_filterR, charParameter, Character.valueOf((char) 100), 100, false, 3); - run_longQuery(long_filterL, CharacterParameter, Character.valueOf((char) 23), 23, true, 5); - run_longQuery(long_filterR, CharacterParameter, Character.valueOf((char) 0), 0, false, 5); - run_longQuery(long_filterL, intParameter, Integer.valueOf(100), 100, true, 5); - run_longQuery(long_filterR, intParameter, Integer.valueOf(0), 0, false, 5); - run_longQuery(long_filterL, IntegerParameter, Integer.valueOf(23), 23, true, 5); - run_longQuery(long_filterR, IntegerParameter, Integer.valueOf(1000000), 1000000, false, 1); - run_longQuery( - long_filterL, floatParameter, Float.valueOf((float) -1000000.0), -1000000, true, 1); - run_longQuery( - long_filterR, - floatParameter, - Float.valueOf((float) Long.MAX_VALUE), - Long.MAX_VALUE, - false, - 0); - run_longQuery(long_filterL, FloatParameter, Float.valueOf((float) 100.0), 100, true, 5); - run_longQuery(long_filterR, FloatParameter, Float.valueOf((float) 32.0), 32, false, 5); - run_longQuery(long_filterL, doubleParameter, Double.valueOf(-1000000.0), -1000000, true, 1); - run_longQuery( - long_filterR, - doubleParameter, - Double.valueOf((double) Long.MAX_VALUE), - Long.MAX_VALUE, - false, - 0); - run_longQuery(long_filterL, DoubleParameter, Double.valueOf(100.0), 100, true, 5); - run_longQuery(long_filterR, DoubleParameter, Double.valueOf(32.0), 32, false, 5); - run_longQuery(long_filterL, BigIntegerParameter, new BigInteger("23"), 23, true, 5); - run_longQuery(long_filterR, BigIntegerParameter, new BigInteger("1000000"), 1000000, false, 1); - run_longQuery(long_filterL, BigDecimalParameter, new BigDecimal("100.0"), 100, true, 5); - run_longQuery(long_filterR, BigDecimalParameter, new BigDecimal("32.0"), 32, false, 5); - alltypes.setlong(100); - run_longQuery(long_filterObj, AllTypesParameter, alltypes, 100, false, 3); - run_longQuery(long_filterVal, null, null, 1000000, false, 1); - - run_floatQuery( - float_filterL, - floatParameter, - Float.valueOf((float) AllTypes.FLOAT_SMALLEST), - AllTypes.FLOAT_SMALLEST, - true, - 0); - run_floatQuery( - float_filterR, - floatParameter, - Float.valueOf((float) AllTypes.FLOAT_LARGEST), - AllTypes.FLOAT_LARGEST, - false, - 0); - run_floatQuery(float_filterL, FloatParameter, Float.valueOf(4.0f), 4.0f, true, 4); - run_floatQuery(float_filterR, FloatParameter, Float.valueOf(400.0f), 400.0f, false, 3); - run_floatQuery(float_filterL, byteParameter, Byte.valueOf((byte) 4), 4.0f, true, 4); - run_floatQuery(float_filterR, byteParameter, Byte.valueOf((byte) 23), 23.0f, false, 6); - run_floatQuery(float_filterL, ByteParameter, Byte.valueOf((byte) 34), 34.0f, true, 4); - run_floatQuery(float_filterR, ByteParameter, Byte.valueOf((byte) 100), 100.0f, false, 4); - run_floatQuery(float_filterL, shortParameter, Short.valueOf((short) 10), 10.0f, true, 4); - run_floatQuery(float_filterR, shortParameter, Short.valueOf((short) 23), 23.0f, false, 6); - run_floatQuery(float_filterL, ShortParameter, Short.valueOf((short) 34), 34.0f, true, 4); - run_floatQuery(float_filterR, ShortParameter, Short.valueOf((short) 100), 100.0f, false, 4); - run_floatQuery(float_filterL, charParameter, Character.valueOf((char) 20), 20.0f, true, 4); - run_floatQuery(float_filterR, charParameter, Character.valueOf((char) 23), 23.0f, false, 6); - run_floatQuery(float_filterL, CharacterParameter, Character.valueOf((char) 34), 34.0f, true, 4); - run_floatQuery( - float_filterR, CharacterParameter, Character.valueOf((char) 100), 100.0f, false, 4); - run_floatQuery(float_filterL, intParameter, Integer.valueOf(55000000), 55000000.0f, true, 8); - run_floatQuery(float_filterR, intParameter, Integer.valueOf(23), 23.0f, false, 6); - run_floatQuery(float_filterL, IntegerParameter, Integer.valueOf(34), 34.0f, true, 4); - run_floatQuery(float_filterR, IntegerParameter, Integer.valueOf(100), 100.0f, false, 4); - run_floatQuery(float_filterL, longParameter, Long.valueOf(55000000), 55000000.0f, true, 8); - run_floatQuery(float_filterR, longParameter, Long.valueOf(23), 23.0f, false, 6); - run_floatQuery(float_filterL, LongParameter, Long.valueOf(34), 34.0f, true, 4); - run_floatQuery(float_filterR, LongParameter, Long.valueOf(100), 100.0f, false, 4); - run_floatQuery( - float_filterL, doubleParameter, Double.valueOf(55000000.0), 55000000.0f, true, 8); - run_floatQuery(float_filterR, doubleParameter, Double.valueOf(-20.5), -20.5f, false, 7); - run_floatQuery(float_filterL, DoubleParameter, Double.valueOf(2.0), 2.0f, true, 4); - run_floatQuery(float_filterR, DoubleParameter, Double.valueOf(100.0), 100.0f, false, 4); - run_floatQuery( - float_filterL, BigIntegerParameter, new BigInteger("55000000"), 55000000.0f, true, 8); - run_floatQuery(float_filterR, BigIntegerParameter, new BigInteger("23"), 23.0f, false, 6); - run_floatQuery( - float_filterL, BigDecimalParameter, new BigDecimal("55000000.0"), 55000000.0f, true, 8); - run_floatQuery(float_filterR, BigDecimalParameter, new BigDecimal("-20.5"), -20.5f, false, 7); - alltypes.setfloat(23.23f); - run_floatQuery(float_filterObj, AllTypesParameter, alltypes, 23.23f, false, 6); - run_floatQuery(float_filterVal, null, null, 100.0f, false, 4); - - run_doubleQuery( - double_filterL, - doubleParameter, - Double.valueOf(AllTypes.DOUBLE_SMALLEST), - AllTypes.DOUBLE_SMALLEST, - true, - 0); - run_doubleQuery( - double_filterR, - doubleParameter, - Double.valueOf(AllTypes.DOUBLE_LARGEST), - AllTypes.DOUBLE_LARGEST, - false, - 0); - run_doubleQuery(double_filterL, DoubleParameter, Double.valueOf(0.0), 0.0, true, 3); - run_doubleQuery(double_filterR, DoubleParameter, Double.valueOf(23.34), 23.34, false, 6); - run_doubleQuery(double_filterL, byteParameter, Byte.valueOf((byte) 100), 100.0, true, 4); - run_doubleQuery(double_filterR, byteParameter, Byte.valueOf((byte) 0), 0.0, false, 6); - run_doubleQuery(double_filterL, ByteParameter, Byte.valueOf((byte) 23), 23.0, true, 4); - run_doubleQuery(double_filterR, ByteParameter, Byte.valueOf((byte) 100), 100.0, false, 4); - run_doubleQuery(double_filterL, charParameter, Character.valueOf((char) 100), 100.0, true, 4); - run_doubleQuery(double_filterR, charParameter, Character.valueOf((char) 0), 0.0, false, 6); - run_doubleQuery( - double_filterL, CharacterParameter, Character.valueOf((char) 23), 23.0, true, 4); - run_doubleQuery( - double_filterR, CharacterParameter, Character.valueOf((char) 100), 100.0, false, 4); - run_doubleQuery(double_filterL, shortParameter, Short.valueOf((short) 100), 100.0, true, 4); - run_doubleQuery(double_filterR, shortParameter, Short.valueOf((short) 0), 0.0, false, 6); - run_doubleQuery(double_filterL, ShortParameter, Short.valueOf((short) 23), 23.0, true, 4); - run_doubleQuery(double_filterR, ShortParameter, Short.valueOf((short) 100), 100.0, false, 4); - run_doubleQuery(double_filterL, intParameter, Integer.valueOf(100), 100.0, true, 4); - run_doubleQuery(double_filterR, intParameter, Integer.valueOf(0), 0.0, false, 6); - run_doubleQuery(double_filterL, IntegerParameter, Integer.valueOf(5000), 5000.0, true, 7); - run_doubleQuery(double_filterR, IntegerParameter, Integer.valueOf(-20), -20.0, false, 7); - run_doubleQuery(double_filterL, longParameter, Long.valueOf(100), 100.0, true, 4); - run_doubleQuery(double_filterR, longParameter, Long.valueOf(0), 0.0, false, 6); - run_doubleQuery(double_filterL, LongParameter, Long.valueOf(5000), 5000.0, true, 7); - run_doubleQuery(double_filterR, LongParameter, Long.valueOf(-20), -20.0, false, 7); - run_doubleQuery(double_filterL, floatParameter, Float.valueOf(0.0f), 0.0f, true, 3); - run_doubleQuery(double_filterR, floatParameter, Float.valueOf(100.0f), 100.0f, false, 4); - run_doubleQuery(double_filterL, FloatParameter, Float.valueOf(100.0f), 100.0, true, 4); - run_doubleQuery(double_filterR, FloatParameter, Float.valueOf(69.96f), 69.96, false, 6); - run_doubleQuery(double_filterL, BigIntegerParameter, new BigInteger("5000"), 5000.0, true, 7); - run_doubleQuery(double_filterR, BigIntegerParameter, new BigInteger("-20"), -20.0, false, 7); - run_doubleQuery(double_filterL, BigDecimalParameter, new BigDecimal("100.0"), 100.0, true, 4); - run_doubleQuery(double_filterR, BigDecimalParameter, new BigDecimal("69.96"), 69.96, false, 6); - alltypes.setdouble(-25.5); - run_doubleQuery(double_filterObj, AllTypesParameter, alltypes, -25.5, true, 2); - run_doubleQuery(double_filterVal, null, null, 100.0, false, 4); - - run_ByteQuery( - Byte_filterL, byteParameter, Byte.valueOf((byte) 50), Byte.valueOf((byte) 50), true, 5); - run_ByteQuery( - Byte_filterR, - byteParameter, - Byte.valueOf(Byte.MIN_VALUE), - Byte.valueOf(Byte.MIN_VALUE), - false, - 9); - run_ByteQuery( - Byte_filterL, ByteParameter, Byte.valueOf((byte) 20), Byte.valueOf((byte) 20), true, 5); - run_ByteQuery( - Byte_filterR, - ByteParameter, - Byte.valueOf(Byte.MAX_VALUE), - Byte.valueOf(Byte.MAX_VALUE), - false, - 0); - run_ByteQuery( - Byte_filterL, shortParameter, Short.valueOf((short) 60), Byte.valueOf((byte) 60), true, 7); - run_ByteQuery( - Byte_filterR, shortParameter, Short.valueOf((short) 51), Byte.valueOf((byte) 51), false, 3); - run_ByteQuery( - Byte_filterL, - ShortParameter, - Short.valueOf((short) -100), - Byte.valueOf((byte) -100), - true, - 1); - run_ByteQuery( - Byte_filterR, - ShortParameter, - Short.valueOf((short) -100), - Byte.valueOf((byte) -100), - false, - 8); - run_ByteQuery( - Byte_filterL, - charParameter, - Character.valueOf((char) 101), - Byte.valueOf((byte) 101), - true, - 9); - run_ByteQuery( - Byte_filterR, - charParameter, - Character.valueOf((char) 10), - Byte.valueOf((byte) 10), - false, - 5); - run_ByteQuery( - Byte_filterL, - CharacterParameter, - Character.valueOf((char) 50), - Byte.valueOf((byte) 50), - true, - 5); - run_ByteQuery( - Byte_filterR, - CharacterParameter, - Character.valueOf((char) 75), - Byte.valueOf((byte) 75), - false, - 2); - run_ByteQuery( - Byte_filterL, intParameter, Integer.valueOf(77), Byte.valueOf((byte) 77), true, 8); - run_ByteQuery( - Byte_filterR, intParameter, Integer.valueOf(60), Byte.valueOf((byte) 60), false, 3); - run_ByteQuery( - Byte_filterL, IntegerParameter, Integer.valueOf(40), Byte.valueOf((byte) 40), true, 5); - run_ByteQuery( - Byte_filterR, IntegerParameter, Integer.valueOf(75), Byte.valueOf((byte) 75), false, 2); - run_ByteQuery(Byte_filterL, longParameter, Long.valueOf(50), Byte.valueOf((byte) 50), true, 5); - run_ByteQuery(Byte_filterR, longParameter, Long.valueOf(50), Byte.valueOf((byte) 50), false, 3); - run_ByteQuery( - Byte_filterL, LongParameter, Long.valueOf(-100), Byte.valueOf((byte) -100), true, 1); - run_ByteQuery( - Byte_filterR, LongParameter, Long.valueOf(-100), Byte.valueOf((byte) -100), false, 8); - run_ByteQuery( - Byte_filterL, floatParameter, Float.valueOf((float) 50), Byte.valueOf((byte) 50), true, 5); - run_ByteQuery( - Byte_filterR, floatParameter, Float.valueOf((float) 50), Byte.valueOf((byte) 50), false, 3); - run_ByteQuery( - Byte_filterL, - FloatParameter, - Float.valueOf((float) -100), - Byte.valueOf((byte) -100), - true, - 1); - run_ByteQuery( - Byte_filterR, - FloatParameter, - Float.valueOf((float) -100), - Byte.valueOf((byte) -100), - false, - 8); - run_ByteQuery( - Byte_filterL, doubleParameter, Double.valueOf(50), Byte.valueOf((byte) 50), true, 5); - run_ByteQuery( - Byte_filterR, doubleParameter, Double.valueOf(50), Byte.valueOf((byte) 50), false, 3); - run_ByteQuery( - Byte_filterL, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte) -100), true, 1); - run_ByteQuery( - Byte_filterR, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte) -100), false, 8); - run_ByteQuery( - Byte_filterL, BigIntegerParameter, new BigInteger("50"), Byte.valueOf((byte) 50), true, 5); - run_ByteQuery( - Byte_filterR, - BigIntegerParameter, - new BigInteger("-100"), - Byte.valueOf((byte) -100), - false, - 8); - run_ByteQuery( - Byte_filterL, - BigDecimalParameter, - new BigDecimal("50.000000"), - Byte.valueOf((byte) 50), - true, - 5); - run_ByteQuery( - Byte_filterR, - BigDecimalParameter, - new BigDecimal("10.00000"), - Byte.valueOf((byte) 10), - false, - 5); - Byte val = Byte.valueOf((byte) 50); - alltypes.setByte(val); - run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, false, 3); - val = Byte.valueOf((byte) 51); - alltypes.setByte(val); - run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, false, 3); - run_ByteQuery(Byte_filterVal, null, null, Byte.valueOf((byte) 100), true, 8); - - run_ShortQuery( - Short_filterL, - shortParameter, - Short.valueOf((short) 100), - Short.valueOf((short) 100), - true, - 5); - run_ShortQuery( - Short_filterR, - shortParameter, - Short.valueOf((short) 100), - Short.valueOf((short) 100), - false, - 3); - run_ShortQuery( - Short_filterL, - ShortParameter, - Short.valueOf(Short.MIN_VALUE), - Short.valueOf(Short.MIN_VALUE), - true, - 0); - run_ShortQuery( - Short_filterR, - ShortParameter, - Short.valueOf((short) 253), - Short.valueOf((short) 253), - false, - 3); - run_ShortQuery( - Short_filterR, - shortParameter, - Short.valueOf((short) 1000), - Short.valueOf((short) 1000), - false, - 2); - run_ShortQuery( - Short_filterL, byteParameter, Byte.valueOf((byte) 75), Short.valueOf((short) 75), true, 5); - run_ShortQuery( - Short_filterR, byteParameter, Byte.valueOf((byte) 75), Short.valueOf((short) 75), false, 5); - run_ShortQuery( - Short_filterL, - ByteParameter, - Byte.valueOf((byte) 100), - Short.valueOf((short) 100), - true, - 5); - run_ShortQuery( - Short_filterR, - ByteParameter, - Byte.valueOf((byte) 100), - Short.valueOf((short) 100), - false, - 3); - run_ShortQuery( - Short_filterL, - charParameter, - Character.valueOf((char) 75), - Short.valueOf((short) 75), - true, - 5); - run_ShortQuery( - Short_filterR, - charParameter, - Character.valueOf((char) 75), - Short.valueOf((short) 75), - false, - 5); - run_ShortQuery( - Short_filterL, - CharacterParameter, - Character.valueOf((char) 100), - Short.valueOf((short) 100), - true, - 5); - run_ShortQuery( - Short_filterR, - CharacterParameter, - Character.valueOf((char) 200), - Short.valueOf((short) 200), - false, - 3); - run_ShortQuery( - Short_filterL, - intParameter, - Integer.valueOf(-10000), - Short.valueOf((short) -10000), - true, - 1); - run_ShortQuery( - Short_filterR, - intParameter, - Integer.valueOf(-10000), - Short.valueOf((short) -10000), - false, - 8); - run_ShortQuery( - Short_filterL, - IntegerParameter, - Integer.valueOf(10000), - Short.valueOf((short) 10000), - true, - 8); - run_ShortQuery( - Short_filterR, - IntegerParameter, - Integer.valueOf(10000), - Short.valueOf((short) 10000), - false, - 1); - run_ShortQuery( - Short_filterL, longParameter, Long.valueOf(20000), Short.valueOf((short) 20000), true, 9); - run_ShortQuery( - Short_filterR, longParameter, Long.valueOf(5000), Short.valueOf((short) 5000), false, 2); - run_ShortQuery( - Short_filterL, LongParameter, Long.valueOf(200), Short.valueOf((short) 200), true, 7); - run_ShortQuery( - Short_filterR, LongParameter, Long.valueOf(500), Short.valueOf((short) 500), false, 3); - run_ShortQuery( - Short_filterL, - floatParameter, - Float.valueOf(23000.0f), - Short.valueOf((short) 23000), - true, - 9); - run_ShortQuery( - Short_filterR, - floatParameter, - Float.valueOf(23000.0f), - Short.valueOf((short) 23000), - false, - 1); - run_ShortQuery( - Short_filterL, FloatParameter, Float.valueOf(10.0f), Short.valueOf((short) 10), true, 5); - run_ShortQuery( - Short_filterR, FloatParameter, Float.valueOf(101.0f), Short.valueOf((short) 101), false, 3); - run_ShortQuery( - Short_filterL, - doubleParameter, - Double.valueOf(-10000.0), - Short.valueOf((short) -10000), - true, - 1); - run_ShortQuery( - Short_filterR, - doubleParameter, - Double.valueOf(-10000.0), - Short.valueOf((short) -10000), - false, - 8); - run_ShortQuery( - Short_filterL, DoubleParameter, Double.valueOf(101.0), Short.valueOf((short) 101), true, 7); - run_ShortQuery( - Short_filterR, DoubleParameter, Double.valueOf(23.0), Short.valueOf((short) 23), false, 5); - run_ShortQuery( - Short_filterL, - BigIntegerParameter, - new BigInteger("10000"), - Short.valueOf((short) 10000), - true, - 8); - run_ShortQuery( - Short_filterR, - BigIntegerParameter, - new BigInteger("30000"), - Short.valueOf((short) 30000), - false, - 1); - run_ShortQuery( - Short_filterL, - BigDecimalParameter, - new BigDecimal("23.0"), - Short.valueOf((short) 23), - true, - 5); - run_ShortQuery( - Short_filterR, - BigDecimalParameter, - new BigDecimal("23.0"), - Short.valueOf((short) 23), - false, - 5); - Short sval = Short.valueOf((short) 100); - alltypes.setShort(sval); - run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, false, 3); - sval = Short.valueOf((short) 23); - alltypes.setShort(sval); - run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, false, 5); - run_ShortQuery(Short_filterVal, null, null, Short.valueOf((short) -1000), true, 2); +/** + *Title: Greater Than Query Operator + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-16. + *
    + *Assertion Description: +The greater than operator (>) is supported for all types as +they are defined in the Java language. This includes the following types: +
      +
    • byte, short, int, long, char, Byte, Short Integer, Long, Character
    • +
    • float, double, Float, Double
    • +
    • BigDecimal, BigInteger
    • +
    • Date, String
    • +
    +The operation on object-valued fields of wrapper types (Boolean, Byte, +Short, Integer, Long, Float, and Double), and numeric types +(BigDecimal and BigInteger) use the wrapped +values as operands. - run_CharacterQuery( - Character_filterL, - charParameter, - Character.valueOf(Character.MIN_VALUE), - Character.valueOf(Character.MIN_VALUE), - true, - 0); - run_CharacterQuery( - Character_filterR, - charParameter, - Character.valueOf(Character.MAX_VALUE), - Character.valueOf(Character.MAX_VALUE), - false, - 0); - run_CharacterQuery( - Character_filterL, charParameter, Character.valueOf('C'), Character.valueOf('C'), true, 4); - run_CharacterQuery( - Character_filterR, charParameter, Character.valueOf('z'), Character.valueOf('z'), false, 1); - run_CharacterQuery( - Character_filterL, - CharacterParameter, - Character.valueOf(' '), - Character.valueOf(' '), - true, - 1); - run_CharacterQuery( - Character_filterR, - CharacterParameter, - Character.valueOf('f'), - Character.valueOf('f'), - false, - 3); - run_CharacterQuery( - Character_filterL, - byteParameter, - Byte.valueOf((byte) Character.MIN_VALUE), - Character.valueOf((char) Character.MIN_VALUE), - true, - 0); - run_CharacterQuery( - Character_filterR, - ByteParameter, - Byte.valueOf((byte) 'a'), - Character.valueOf('a'), - false, - 3); - run_CharacterQuery( - Character_filterL, - shortParameter, - Short.valueOf((short) 'M'), - Character.valueOf('M'), - true, - 5); - run_CharacterQuery( - Character_filterR, - shortParameter, - Short.valueOf((short) 'F'), - Character.valueOf('F'), - false, - 5); - run_CharacterQuery( - Character_filterL, - ShortParameter, - Short.valueOf((short) 'A'), - Character.valueOf('A'), - true, - 2); - run_CharacterQuery( - Character_filterR, - ShortParameter, - Short.valueOf((short) 'A'), - Character.valueOf('A'), - false, - 7); - run_CharacterQuery( - Character_filterL, intParameter, Integer.valueOf('z'), Character.valueOf('z'), true, 7); - run_CharacterQuery( - Character_filterR, intParameter, Integer.valueOf('z'), Character.valueOf('z'), false, 1); - run_CharacterQuery( - Character_filterL, IntegerParameter, Integer.valueOf('B'), Character.valueOf('B'), true, 3); - run_CharacterQuery( - Character_filterR, - IntegerParameter, - Integer.valueOf('B'), - Character.valueOf('B'), - false, - 6); - run_CharacterQuery( - Character_filterL, longParameter, Long.valueOf('z'), Character.valueOf('z'), true, 7); - run_CharacterQuery( - Character_filterR, longParameter, Long.valueOf('z'), Character.valueOf('z'), false, 1); - run_CharacterQuery( - Character_filterL, LongParameter, Long.valueOf('B'), Character.valueOf('B'), true, 3); - run_CharacterQuery( - Character_filterR, LongParameter, Long.valueOf('B'), Character.valueOf('B'), false, 6); - run_CharacterQuery( - Character_filterL, - floatParameter, - Float.valueOf((float) 'z'), - Character.valueOf('z'), - true, - 7); - run_CharacterQuery( - Character_filterR, - floatParameter, - Float.valueOf((float) 'z'), - Character.valueOf('z'), - false, - 1); - run_CharacterQuery( - Character_filterL, - FloatParameter, - Float.valueOf((float) 'M'), - Character.valueOf('M'), - true, - 5); - run_CharacterQuery( - Character_filterR, - FloatParameter, - Float.valueOf((float) 'X'), - Character.valueOf('X'), - false, - 3); - run_CharacterQuery( - Character_filterL, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), true, 3); - run_CharacterQuery( - Character_filterR, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), false, 6); - run_CharacterQuery( - Character_filterL, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), true, 2); - run_CharacterQuery( - Character_filterR, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), false, 7); - run_CharacterQuery( - Character_filterL, - BigIntegerParameter, - new BigInteger("65"), - Character.valueOf('A'), - true, - 2); // 'A' == 65 - run_CharacterQuery( - Character_filterR, - BigIntegerParameter, - new BigInteger("122"), - Character.valueOf('z'), - false, - 1); // 'z' == 122 - run_CharacterQuery( - Character_filterL, - BigDecimalParameter, - new BigDecimal("65.00000"), - Character.valueOf('A'), - true, - 2); - run_CharacterQuery( - Character_filterR, - BigDecimalParameter, - new BigDecimal("77.0000"), - Character.valueOf('M'), - false, - 3); // 'M' == 77 - alltypes.setCharacter(Character.valueOf('A')); - run_CharacterQuery( - Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('A'), true, 2); - alltypes.setCharacter(Character.valueOf('b')); - run_CharacterQuery( - Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('b'), true, 7); - run_CharacterQuery(Character_filterVal, null, null, Character.valueOf('z'), false, 1); + */ - run_IntegerQuery( - Integer_filterL, - intParameter, - Integer.valueOf(AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - true, - 0); - run_IntegerQuery( - Integer_filterR, - intParameter, - Integer.valueOf(AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - false, - 0); - run_IntegerQuery( - Integer_filterR, intParameter, Integer.valueOf(23), Integer.valueOf(23), false, 6); - run_IntegerQuery( - Integer_filterL, - IntegerParameter, - Integer.valueOf(1000000), - Integer.valueOf(1000000), - true, - 8); - run_IntegerQuery( - Integer_filterR, IntegerParameter, Integer.valueOf(1000), Integer.valueOf(1000), false, 3); - run_IntegerQuery( - Integer_filterL, byteParameter, Byte.valueOf((byte) 100), Integer.valueOf(100), true, 4); - run_IntegerQuery( - Integer_filterR, byteParameter, Byte.valueOf((byte) 0), Integer.valueOf(0), false, 6); - run_IntegerQuery( - Integer_filterL, ByteParameter, Byte.valueOf((byte) 100), Integer.valueOf(100), true, 4); - run_IntegerQuery( - Integer_filterR, ByteParameter, Byte.valueOf((byte) 0), Integer.valueOf(0), false, 6); - run_IntegerQuery( - Integer_filterL, - shortParameter, - Short.valueOf((short) 10000), - Integer.valueOf(10000), - true, - 7); - run_IntegerQuery( - Integer_filterR, - shortParameter, - Short.valueOf((short) -1000), - Integer.valueOf(-1000), - false, - 7); - run_IntegerQuery( - Integer_filterL, - ShortParameter, - Short.valueOf((short) -1000), - Integer.valueOf(-1000), - true, - 2); - run_IntegerQuery( - Integer_filterR, - ShortParameter, - Short.valueOf((short) -999), - Integer.valueOf(-999), - false, - 7); - run_IntegerQuery( - Integer_filterL, - charParameter, - Character.valueOf((char) 10000), - Integer.valueOf(10000), - true, - 7); - run_IntegerQuery( - Integer_filterR, - charParameter, - Character.valueOf((char) 10000), - Integer.valueOf(10000), - false, - 2); - run_IntegerQuery( - Integer_filterL, - CharacterParameter, - Character.valueOf((char) 100), - Integer.valueOf(100), - true, - 4); - run_IntegerQuery( - Integer_filterR, - CharacterParameter, - Character.valueOf((char) 10000), - Integer.valueOf(10000), - false, - 2); - run_IntegerQuery( - Integer_filterL, - longParameter, - Long.valueOf(AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - true, - 9); - run_IntegerQuery( - Integer_filterR, - longParameter, - Long.valueOf(AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - false, - 9); - run_IntegerQuery( - Integer_filterL, LongParameter, Long.valueOf(10000), Integer.valueOf(10000), true, 7); - run_IntegerQuery( - Integer_filterR, LongParameter, Long.valueOf(43), Integer.valueOf(43), false, 6); - run_IntegerQuery( - Integer_filterL, - floatParameter, - Float.valueOf((float) AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - true, - 9); - run_IntegerQuery( - Integer_filterR, - floatParameter, - Float.valueOf((float) AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - false, - 9); - run_IntegerQuery( - Integer_filterL, - FloatParameter, - Float.valueOf((float) 10000), - Integer.valueOf(10000), - true, - 7); - run_IntegerQuery( - Integer_filterR, FloatParameter, Float.valueOf((float) 43), Integer.valueOf(43), false, 6); - run_IntegerQuery( - Integer_filterL, - doubleParameter, - Double.valueOf(AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - true, - 9); - run_IntegerQuery( - Integer_filterR, - doubleParameter, - Double.valueOf(AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - false, - 9); - run_IntegerQuery( - Integer_filterL, DoubleParameter, Double.valueOf(10000), Integer.valueOf(10000), true, 7); - run_IntegerQuery( - Integer_filterR, - DoubleParameter, - Double.valueOf(1000001.0), - Integer.valueOf(1000001), - false, - 1); - run_IntegerQuery( - Integer_filterL, - BigIntegerParameter, - new BigInteger("1000000"), - Integer.valueOf(1000000), - true, - 8); - run_IntegerQuery( - Integer_filterR, - BigIntegerParameter, - new BigInteger("1000"), - Integer.valueOf(1000), - false, - 3); - run_IntegerQuery( - Integer_filterL, - BigDecimalParameter, - new BigDecimal("10000.0"), - Integer.valueOf(10000), - true, - 7); - run_IntegerQuery( - Integer_filterR, - BigDecimalParameter, - new BigDecimal("43.0"), - Integer.valueOf(43), - false, - 6); - alltypes.setInteger(Integer.valueOf(100)); - run_IntegerQuery( - Integer_filterObj, AllTypesParameter, alltypes, Integer.valueOf(100), false, 4); - run_IntegerQuery(Integer_filterVal, null, null, Integer.valueOf(100), false, 4); +public class GreaterThan extends ComparisonTests { + private static String boolean_filterL = "value > fld_boolean"; + private static String boolean_filterR = "fld_boolean > value"; + private static String boolean_filterT = "fld_boolean > true"; + private static String boolean_filterF = "false > fld_boolean"; + private static String boolean_filterObj = "value.fld_boolean > fld_boolean"; + + private static String byte_filterL = "value > fld_byte"; + private static String byte_filterR = "fld_byte > value"; + private static String byte_filterObj = "value.fld_byte > fld_byte"; + private static String byte_filterVal = "fld_byte > 100"; + + private static String char_filterL = "value > fld_char"; + private static String char_filterR = "fld_char > value"; + private static String char_filterObj = "value.fld_char > fld_char"; + private static String char_filterVal = "'M' > fld_char"; + + private static String double_filterL = "value > fld_double"; + private static String double_filterR = "fld_double > value"; + private static String double_filterObj = "value.fld_double > fld_double"; + private static String double_filterVal = "fld_double > 100.0"; + + private static String float_filterL = "value > fld_float"; + private static String float_filterR = "fld_float > value"; + private static String float_filterObj = "fld_float > value.fld_float"; + private static String float_filterVal = "fld_float > 100.0"; + + private static String int_filterL = "value > fld_int"; + private static String int_filterR = "fld_int > value"; + private static String int_filterObj = "value.fld_int > fld_int"; + private static String int_filterVal = "fld_int > 1000"; + + private static String long_filterL = "value > fld_long"; + private static String long_filterR = "fld_long > value"; + private static String long_filterObj = "fld_long > value.fld_long"; + private static String long_filterVal = "fld_long > 1000000"; + + private static String short_filterL = "value > fld_short"; + private static String short_filterR = "fld_short > value"; + private static String short_filterObj = "value.fld_short > fld_short"; + private static String short_filterVal = "1000 > fld_short"; + + private static String Boolean_filterL = "value > fld_Boolean"; + private static String Boolean_filterR = "fld_Boolean > value"; + private static String Boolean_filterT = "fld_Boolean > true"; + private static String Boolean_filterF = "false > fld_Boolean"; + private static String Boolean_filterObj = "value.fld_Boolean > fld_Boolean"; + private static String Boolean_filterVal = "fld_Boolean > false"; + + private static String Byte_filterL = "value > fld_Byte"; + private static String Byte_filterR = "fld_Byte > value"; + private static String Byte_filterObj = "fld_Byte > value.fld_Byte"; + private static String Byte_filterVal = "100 > fld_Byte"; + + private static String Character_filterL = "value > fld_Character"; + private static String Character_filterR = "fld_Character > value"; + private static String Character_filterObj = "value.fld_Character > fld_Character"; + private static String Character_filterVal = "fld_Character > 'z'"; + + private static String Double_filterL = "value > fld_Double"; + private static String Double_filterR = "fld_Double > value"; + private static String Double_filterObj = "value.fld_Double > fld_Double"; + private static String Double_filterVal = "fld_Double > 100.0"; + + private static String Float_filterL = "value > fld_Float"; + private static String Float_filterR = "fld_Float > value"; + private static String Float_filterObj = "fld_Float > value.fld_Float"; + private static String Float_filterVal = "100.0f > fld_Float"; + + private static String Integer_filterL = "value > fld_Integer"; + private static String Integer_filterR = "fld_Integer > value"; + private static String Integer_filterObj = "fld_Integer > value.fld_Integer"; + private static String Integer_filterVal = "fld_Integer > 100"; + + private static String Long_filterL = "value > fld_Long"; + private static String Long_filterR = "fld_Long > value"; + private static String Long_filterObj = "value.fld_Long > fld_Long"; + private static String Long_filterVal = "-1000 > fld_Long"; + + private static String Short_filterL = "value > fld_Short"; + private static String Short_filterR = "fld_Short > value"; + private static String Short_filterObj = "fld_Short > value.fld_Short"; + private static String Short_filterVal = "-1000 > fld_Short"; + + private static String String_filterL = "value > fld_String"; + private static String String_filterR = "fld_String > value"; + private static String String_filterObj = "value.fld_String > fld_String"; + private static String String_filterVal1 = "fld_String > \"Java\""; + private static String String_filterVal2 = "fld_String > \"\""; + + private static String Date_filterL = "value > fld_Date"; + private static String Date_filterR = "fld_Date > value"; + private static String Date_filterObj = "fld_Date > value.fld_Date"; + + private static String BigDecimal_filterL = "value > fld_BigDecimal"; + private static String BigDecimal_filterR = "fld_BigDecimal > value"; + private static String BigDecimal_filterObj = "value.fld_BigDecimal > fld_BigDecimal"; + + private static String BigInteger_filterL = "value > fld_BigInteger"; + private static String BigInteger_filterR = "fld_BigInteger > value"; + private static String BigInteger_filterObj = "fld_BigInteger > value.fld_BigInteger"; - run_LongQuery( - Long_filterL, - longParameter, - Long.valueOf(Long.MIN_VALUE), - Long.valueOf(Long.MIN_VALUE), - true, - 0); - run_LongQuery( - Long_filterR, - longParameter, - Long.valueOf(Long.MAX_VALUE), - Long.valueOf(Long.MAX_VALUE), - false, - 0); - run_LongQuery(Long_filterL, LongParameter, Long.valueOf(100), Long.valueOf(100), true, 5); - run_LongQuery(Long_filterR, LongParameter, Long.valueOf(23), Long.valueOf(23), false, 5); - run_LongQuery( - Long_filterL, byteParameter, Byte.valueOf((byte) 100), Long.valueOf(100), true, 5); - run_LongQuery(Long_filterR, byteParameter, Byte.valueOf((byte) 0), Long.valueOf(0), false, 5); - run_LongQuery( - Long_filterL, ByteParameter, Byte.valueOf((byte) 100), Long.valueOf(100), true, 5); - run_LongQuery(Long_filterR, ByteParameter, Byte.valueOf((byte) 0), Long.valueOf(0), false, 5); - run_LongQuery( - Long_filterL, shortParameter, Short.valueOf((short) -1000), Long.valueOf(-1000), true, 2); - run_LongQuery( - Long_filterR, shortParameter, Short.valueOf((short) 1000), Long.valueOf(1000), false, 2); - run_LongQuery( - Long_filterL, ShortParameter, Short.valueOf((short) 101), Long.valueOf(101), true, 7); - run_LongQuery( - Long_filterR, ShortParameter, Short.valueOf((short) 32), Long.valueOf(32), false, 5); - run_LongQuery( - Long_filterL, charParameter, Character.valueOf((char) 0), Long.valueOf(0), true, 4); - run_LongQuery( - Long_filterR, charParameter, Character.valueOf((char) 100), Long.valueOf(100), false, 3); - run_LongQuery( - Long_filterL, CharacterParameter, Character.valueOf((char) 23), Long.valueOf(23), true, 5); - run_LongQuery( - Long_filterR, - CharacterParameter, - Character.valueOf((char) 1110), - Long.valueOf(1110), - false, - 2); - run_LongQuery(Long_filterL, intParameter, Integer.valueOf(100), Long.valueOf(100), true, 5); - run_LongQuery(Long_filterR, intParameter, Integer.valueOf(0), Long.valueOf(0), false, 5); - run_LongQuery(Long_filterL, IntegerParameter, Integer.valueOf(23), Long.valueOf(23), true, 5); - run_LongQuery( - Long_filterR, IntegerParameter, Integer.valueOf(1000000), Long.valueOf(1000000), false, 1); - run_LongQuery( - Long_filterL, - floatParameter, - Float.valueOf((float) -1000000.0), - Long.valueOf(-1000000), - true, - 1); - run_LongQuery( - Long_filterR, - floatParameter, - Float.valueOf((float) Long.MAX_VALUE), - Long.valueOf(Long.MAX_VALUE), - false, - 0); - run_LongQuery(Long_filterL, FloatParameter, Float.valueOf(100.0f), Long.valueOf(100), true, 5); - run_LongQuery(Long_filterR, FloatParameter, Float.valueOf(32.0f), Long.valueOf(32), false, 5); - run_LongQuery( - Long_filterL, doubleParameter, Double.valueOf(-1000000.0), Long.valueOf(-1000000), true, 1); - run_LongQuery( - Long_filterR, - doubleParameter, - Double.valueOf((double) Long.MAX_VALUE), - Long.valueOf(Long.MAX_VALUE), - false, - 0); - run_LongQuery(Long_filterL, DoubleParameter, Double.valueOf(100.0), Long.valueOf(100), true, 5); - run_LongQuery(Long_filterR, DoubleParameter, Double.valueOf(32.0), Long.valueOf(32), false, 5); - run_LongQuery( - Long_filterL, BigIntegerParameter, new BigInteger("23"), Long.valueOf(23), true, 5); - run_LongQuery( - Long_filterR, - BigIntegerParameter, - new BigInteger("1000000"), - Long.valueOf(1000000), - false, - 1); - run_LongQuery( - Long_filterL, BigDecimalParameter, new BigDecimal("100.0"), Long.valueOf(100), true, 5); - run_LongQuery( - Long_filterR, BigDecimalParameter, new BigDecimal("32.0"), Long.valueOf(32), false, 5); - alltypes.setLong(Long.valueOf(100)); - run_LongQuery(Long_filterObj, AllTypesParameter, alltypes, Long.valueOf(100), true, 5); - run_LongQuery(Long_filterVal, null, null, Long.valueOf(-1000), true, 2); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-16 (GreaterThan) failed: "; - run_FloatQuery( - Float_filterL, - floatParameter, - Float.valueOf(-1000000000.0f), - Float.valueOf(-1000000000.0f), - true, - 1); - run_FloatQuery( - Float_filterR, - floatParameter, - Float.valueOf(9000000000.0f), - Float.valueOf(9000000000.0f), - false, - 1); - run_FloatQuery( - Float_filterL, FloatParameter, Float.valueOf((float) 0.0), Float.valueOf(0.0f), true, 2); - run_FloatQuery( - Float_filterR, FloatParameter, Float.valueOf((float) 4.0), Float.valueOf(4.0f), false, 7); - run_FloatQuery( - Float_filterL, byteParameter, Byte.valueOf((byte) 0), Float.valueOf(0.0f), true, 2); - run_FloatQuery( - Float_filterR, byteParameter, Byte.valueOf((byte) 23), Float.valueOf(23.0f), false, 7); - run_FloatQuery( - Float_filterL, ByteParameter, Byte.valueOf((byte) 34), Float.valueOf(34.0f), true, 3); - run_FloatQuery( - Float_filterR, ByteParameter, Byte.valueOf((byte) 100), Float.valueOf(100.0f), false, 5); - run_FloatQuery( - Float_filterL, shortParameter, Short.valueOf((short) 0), Float.valueOf(0.0f), true, 2); - run_FloatQuery( - Float_filterR, shortParameter, Short.valueOf((short) 23), Float.valueOf(23.0f), false, 7); - run_FloatQuery( - Float_filterL, ShortParameter, Short.valueOf((short) 34), Float.valueOf(34.0f), true, 3); - run_FloatQuery( - Float_filterR, ShortParameter, Short.valueOf((short) 100), Float.valueOf(100.0f), false, 5); - run_FloatQuery( - Float_filterL, charParameter, Character.valueOf((char) 0), Float.valueOf(0.0f), true, 2); - run_FloatQuery( - Float_filterR, charParameter, Character.valueOf((char) 23), Float.valueOf(23.0f), false, 7); - run_FloatQuery( - Float_filterL, - CharacterParameter, - Character.valueOf((char) 34), - Float.valueOf(34.0f), - true, - 3); - run_FloatQuery( - Float_filterR, - CharacterParameter, - Character.valueOf((char) 100), - Float.valueOf(100.0f), - false, - 5); - run_FloatQuery( - Float_filterL, - intParameter, - Integer.valueOf(50000000), - Float.valueOf(50000000.0f), - true, - 7); - run_FloatQuery( - Float_filterR, intParameter, Integer.valueOf(23), Float.valueOf(23.0f), false, 7); - run_FloatQuery( - Float_filterL, IntegerParameter, Integer.valueOf(34), Float.valueOf(34.0f), true, 3); - run_FloatQuery( - Float_filterR, IntegerParameter, Integer.valueOf(100), Float.valueOf(100.0f), false, 5); - run_FloatQuery( - Float_filterL, longParameter, Long.valueOf(50000000), Float.valueOf(50000000.0f), true, 7); - run_FloatQuery(Float_filterR, longParameter, Long.valueOf(23), Float.valueOf(23.0f), false, 7); - run_FloatQuery(Float_filterL, LongParameter, Long.valueOf(34), Float.valueOf(34.0f), true, 3); - run_FloatQuery( - Float_filterR, LongParameter, Long.valueOf(100), Float.valueOf(100.0f), false, 5); - run_FloatQuery( - Float_filterL, - doubleParameter, - Double.valueOf(50000000.0f), - Float.valueOf(50000000.0f), - true, - 7); - run_FloatQuery( - Float_filterR, doubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), false, 5); - run_FloatQuery( - Float_filterL, DoubleParameter, Double.valueOf(0.0f), Float.valueOf(0.0f), true, 2); - run_FloatQuery( - Float_filterR, DoubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), false, 5); - run_FloatQuery( - Float_filterL, - BigIntegerParameter, - new BigInteger("55000000"), - Float.valueOf(55000000.0f), - true, - 8); - run_FloatQuery( - Float_filterR, BigIntegerParameter, new BigInteger("23"), Float.valueOf(23.0f), false, 7); - run_FloatQuery( - Float_filterL, - BigDecimalParameter, - new BigDecimal("55000000.0"), - Float.valueOf(55000000.0f), - true, - 8); - run_FloatQuery( - Float_filterR, - BigDecimalParameter, - new BigDecimal("-20.5"), - Float.valueOf(-20.5f), - false, - 8); - alltypes.setFloat(Float.valueOf(23.23f)); - run_FloatQuery(Float_filterObj, AllTypesParameter, alltypes, Float.valueOf(23.23f), false, 7); - run_FloatQuery(Float_filterVal, null, null, Float.valueOf(100.0f), true, 3); + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GreaterThan.class); + } + + /** */ + public void test() { + pm = getPM(); + tx = pm.currentTransaction(); + runQueries(); + } - run_DoubleQuery( - Double_filterL, - doubleParameter, - Double.valueOf(-999999999999.0), - Double.valueOf(-999999999999.0), - true, - 1); - run_DoubleQuery( - Double_filterR, - doubleParameter, - Double.valueOf(9999999999999.0), - Double.valueOf(9999999999999.0), - false, - 1); - run_DoubleQuery( - Double_filterL, DoubleParameter, Double.valueOf(0.0), Double.valueOf(0.0), true, 3); - run_DoubleQuery( - Double_filterR, DoubleParameter, Double.valueOf(23.34), Double.valueOf(23.34), false, 6); - run_DoubleQuery( - Double_filterL, byteParameter, Byte.valueOf((byte) 100), Double.valueOf(100.0), true, 4); - run_DoubleQuery( - Double_filterR, byteParameter, Byte.valueOf((byte) 0), Double.valueOf(0.0), false, 6); - run_DoubleQuery( - Double_filterL, ByteParameter, Byte.valueOf((byte) -23), Double.valueOf(-23.0), true, 3); - run_DoubleQuery( - Double_filterR, ByteParameter, Byte.valueOf((byte) 100), Double.valueOf(100.0), false, 4); - run_DoubleQuery( - Double_filterL, shortParameter, Short.valueOf((short) 100), Double.valueOf(100.0), true, 4); - run_DoubleQuery( - Double_filterR, shortParameter, Short.valueOf((short) 0), Double.valueOf(0.0), false, 6); - run_DoubleQuery( - Double_filterL, ShortParameter, Short.valueOf((short) 23), Double.valueOf(23.0), true, 4); - run_DoubleQuery( - Double_filterR, - ShortParameter, - Short.valueOf((short) 400), - Double.valueOf(400.0), - false, - 3); - run_DoubleQuery( - Double_filterL, - charParameter, - Character.valueOf((char) 100), - Double.valueOf(100.0), - true, - 4); - run_DoubleQuery( - Double_filterR, charParameter, Character.valueOf((char) 0), Double.valueOf(0.0), false, 6); - run_DoubleQuery( - Double_filterL, - CharacterParameter, - Character.valueOf((char) 23), - Double.valueOf(23.0), - true, - 4); - run_DoubleQuery( - Double_filterR, - CharacterParameter, - Character.valueOf((char) 400), - Double.valueOf(400.0), - false, - 3); - run_DoubleQuery( - Double_filterL, intParameter, Integer.valueOf(100), Double.valueOf(100.0), true, 4); - run_DoubleQuery( - Double_filterR, intParameter, Integer.valueOf(0), Double.valueOf(0.0), false, 6); - run_DoubleQuery( - Double_filterL, IntegerParameter, Integer.valueOf(23), Double.valueOf(23.0), true, 4); - run_DoubleQuery( - Double_filterR, IntegerParameter, Integer.valueOf(100), Double.valueOf(100.0), false, 4); - run_DoubleQuery( - Double_filterL, longParameter, Long.valueOf(100), Double.valueOf(100.0), true, 4); - run_DoubleQuery(Double_filterR, longParameter, Long.valueOf(0), Double.valueOf(0.0), false, 6); - run_DoubleQuery(Double_filterL, LongParameter, Long.valueOf(23), Double.valueOf(23.0), true, 4); - run_DoubleQuery( - Double_filterR, LongParameter, Long.valueOf(100), Double.valueOf(100.0), false, 4); - run_DoubleQuery( - Double_filterL, floatParameter, Float.valueOf(0.0f), Double.valueOf(0.0f), true, 3); - run_DoubleQuery( - Double_filterR, floatParameter, Float.valueOf(100.0f), Double.valueOf(100.0f), false, 4); - run_DoubleQuery( - Double_filterL, FloatParameter, Float.valueOf(100.0f), Double.valueOf(100.0f), true, 4); - run_DoubleQuery( - Double_filterR, FloatParameter, Float.valueOf(69.96f), Double.valueOf(69.96), false, 6); - run_DoubleQuery( - Double_filterL, - BigIntegerParameter, - new BigInteger("5000"), - Double.valueOf(5000.0), - true, - 7); - run_DoubleQuery( - Double_filterR, - BigIntegerParameter, - new BigInteger("-20"), - Double.valueOf(-20.0), - false, - 7); - run_DoubleQuery( - Double_filterL, - BigDecimalParameter, - new BigDecimal("100.0"), - Double.valueOf(100.0), - true, - 4); - run_DoubleQuery( - Double_filterR, - BigDecimalParameter, - new BigDecimal("69.96"), - Double.valueOf(69.96), - false, - 6); - alltypes.setDouble(Double.valueOf(-999999999999.0)); - run_DoubleQuery( - Double_filterObj, AllTypesParameter, alltypes, Double.valueOf(-999999999999.0), true, 1); - run_DoubleQuery(Double_filterVal, null, null, Double.valueOf(100.0), false, 4); + /** */ + private void runQueries() + { + AllTypes alltypes = new AllTypes(); + run_byteQuery(byte_filterL, byteParameter, Byte.valueOf((byte)0), (byte)0, true, 3); + run_byteQuery(byte_filterR, byteParameter, Byte.valueOf(Byte.MIN_VALUE), Byte.MIN_VALUE, false, 9); + run_byteQuery(byte_filterL, ByteParameter, Byte.valueOf((byte)50), (byte)50, true, 5); + run_byteQuery(byte_filterR, ByteParameter, Byte.valueOf(Byte.MAX_VALUE), Byte.MAX_VALUE, false, 0); + run_byteQuery(byte_filterL, shortParameter, Short.valueOf((short)75), (byte)75, true, 7); + run_byteQuery(byte_filterR, shortParameter, Short.valueOf((short)75), (byte)75, false, 2); + run_byteQuery(byte_filterL, ShortParameter, Short.valueOf((short)10), (byte)10, true, 4); + run_byteQuery(byte_filterR, ShortParameter, Short.valueOf((short)25), (byte)25, false, 5); + run_byteQuery(byte_filterL, charParameter, Character.valueOf((char)101), (byte)101, true, 9); + run_byteQuery(byte_filterR, charParameter, Character.valueOf((char)50), (byte)50, false, 3); + run_byteQuery(byte_filterL, CharacterParameter, Character.valueOf((char)0), (byte)0, true, 3); + run_byteQuery(byte_filterR, CharacterParameter, Character.valueOf((char)0), (byte)0, false, 6); + run_byteQuery(byte_filterL, intParameter, Integer.valueOf(25), (byte)25, true, 5); + run_byteQuery(byte_filterR, intParameter, Integer.valueOf(50), (byte)50, false, 3); + run_byteQuery(byte_filterL, IntegerParameter, Integer.valueOf(-10), (byte)-10, true, 2); + run_byteQuery(byte_filterR, IntegerParameter, Integer.valueOf(-100), (byte)-100, false, 8); + run_byteQuery(byte_filterL, longParameter, Long.valueOf(50), (byte)50, true, 5); + run_byteQuery(byte_filterR, longParameter, Long.valueOf(60), (byte)60, false, 3); + run_byteQuery(byte_filterL, LongParameter, Long.valueOf(-100), (byte)-100, true, 1); + run_byteQuery(byte_filterR, LongParameter, Long.valueOf(-100), (byte)-100, false, 8); + run_byteQuery(byte_filterL, floatParameter, Float.valueOf((float)51), (byte)51, true, 7); + run_byteQuery(byte_filterR, floatParameter, Float.valueOf((float)-20), (byte)-20, false, 8); + run_byteQuery(byte_filterL, FloatParameter, Float.valueOf((float)-99), (byte)-99, true, 2); + run_byteQuery(byte_filterR, FloatParameter, Float.valueOf((float)-100), (byte)-100, false, 8); + run_byteQuery(byte_filterL, doubleParameter, Double.valueOf(50), (byte)50, true, 5); + run_byteQuery(byte_filterR, doubleParameter, Double.valueOf(60), (byte)60, false, 3); + run_byteQuery(byte_filterL, DoubleParameter, Double.valueOf(Byte.MAX_VALUE), Byte.MAX_VALUE, true, 9); + run_byteQuery(byte_filterR, DoubleParameter, Double.valueOf(25), (byte)25, false, 5); + run_byteQuery(byte_filterL, BigIntegerParameter, new BigInteger("50"), (byte)50, true, 5); + run_byteQuery(byte_filterR, BigIntegerParameter, new BigInteger("-100"), (byte)-100, false, 8); + run_byteQuery(byte_filterL, BigDecimalParameter, new BigDecimal("50.000000"), (byte)50, true, 5); + run_byteQuery(byte_filterR, BigDecimalParameter, new BigDecimal("10.00000"), (byte)10, false, 5); + alltypes.setbyte((byte)50); + run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte)50, true, 5); + alltypes.setbyte((byte)55); + run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte)55, true, 7); + run_byteQuery(byte_filterVal, null, null, (byte)100, false, 1); - run_StringQuery(String_filterL, StringParameter, new String("JDO"), new String("JDO"), true, 1); - run_StringQuery( - String_filterR, StringParameter, new String("JDBC"), new String("JDBC"), false, 9); - alltypes.setString(new String("abcde")); - run_StringQuery(String_filterObj, AllTypesParameter, alltypes, new String("abcde"), true, 7); - run_StringQuery(String_filterVal1, null, null, new String("Java"), false, 4); - run_StringQuery(String_filterVal2, null, null, new String(""), false, 9); + run_shortQuery(short_filterL, shortParameter, Short.valueOf((short)100), (short)100, true, 5); + run_shortQuery(short_filterR, shortParameter, Short.valueOf((short)100), (short)100, false, 3); + run_shortQuery(short_filterL, ShortParameter, Short.valueOf(Short.MIN_VALUE), Short.MIN_VALUE, true, 0); + run_shortQuery(short_filterR, ShortParameter, Short.valueOf((short)253), (short)253, false, 3); + run_shortQuery(short_filterR, shortParameter, Short.valueOf((short)1000), (short)1000, false, 2); + run_shortQuery(short_filterL, byteParameter, Byte.valueOf((byte)75), (short)75, true, 5); + run_shortQuery(short_filterR, byteParameter, Byte.valueOf((byte)-75), (short)-75, false, 6); + run_shortQuery(short_filterL, ByteParameter, Byte.valueOf((byte)100), (short)100, true, 5); + run_shortQuery(short_filterR, ByteParameter, Byte.valueOf((byte)100), (short)100, false, 3); + run_shortQuery(short_filterL, charParameter, Character.valueOf((char)75), (short)75, true, 5); + run_shortQuery(short_filterR, charParameter, Character.valueOf((char)9999), (short)9999, false, 2); + run_shortQuery(short_filterL, CharacterParameter, Character.valueOf((char)1000), (short)1000, true, 7); + run_shortQuery(short_filterR, CharacterParameter, Character.valueOf((char)10000), (short)10000, false, 1); + run_shortQuery(short_filterL, intParameter, Integer.valueOf(-10000), (short)-10000, true, 1); + run_shortQuery(short_filterR, intParameter, Integer.valueOf(-10000), (short)-10000, false, 8); + run_shortQuery(short_filterL, IntegerParameter, Integer.valueOf(10000), (short)10000, true, 8); + run_shortQuery(short_filterR, IntegerParameter, Integer.valueOf(30000), (short)30000, false, 1); + run_shortQuery(short_filterL, longParameter, Long.valueOf(10000), (short) 10000, true, 8); + run_shortQuery(short_filterR, longParameter, Long.valueOf(Short.MAX_VALUE), Short.MAX_VALUE, false, 0); + run_shortQuery(short_filterL, LongParameter, Long.valueOf(Short.MAX_VALUE), Short.MAX_VALUE, true, 9); + run_shortQuery(short_filterR, LongParameter, Long.valueOf(100), (short)100, false, 3); + run_shortQuery(short_filterL, floatParameter, Float.valueOf((float)23000), (short)23000, true, 9); + run_shortQuery(short_filterR, floatParameter, Float.valueOf((float)23000), (short)23000, false, 1); + run_shortQuery(short_filterL, FloatParameter, Float.valueOf((float)-1000), (short)-1000, true, 2); + run_shortQuery(short_filterR, FloatParameter, Float.valueOf((float)100), (short)100, false, 3); + run_shortQuery(short_filterL, doubleParameter, Double.valueOf(-10000.0), (short)-10000, true, 1); + run_shortQuery(short_filterR, doubleParameter, Double.valueOf(9999.0), (short)9999, false, 2); + run_shortQuery(short_filterL, DoubleParameter, Double.valueOf(23.0), (short)23, true, 5); + run_shortQuery(short_filterR, DoubleParameter, Double.valueOf(23.0), (short)23, false, 5); + run_shortQuery(short_filterL, BigIntegerParameter, new BigInteger("10000"), (short)10000, true, 8); + run_shortQuery(short_filterR, BigIntegerParameter, new BigInteger("30000"), (short)30000, false, 1); + run_shortQuery(short_filterL, BigDecimalParameter, new BigDecimal("23.0"), (short)23, true, 5); + run_shortQuery(short_filterR, BigDecimalParameter, new BigDecimal("23.0"), (short)23, false, 5); + alltypes.setshort((short)100); + run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short)100, true, 5); + alltypes.setshort((short)23); + run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short)23, true, 5); + run_shortQuery(short_filterVal, null, null, (short)1000, true, 7); + + run_charQuery(char_filterL, charParameter, Character.valueOf(Character.MIN_VALUE), Character.MIN_VALUE, true, 0); + run_charQuery(char_filterR, charParameter, Character.valueOf(Character.MAX_VALUE), Character.MAX_VALUE, false, 0); + run_charQuery(char_filterL, charParameter, Character.valueOf('C'), 'C', true, 4); + run_charQuery(char_filterR, charParameter, Character.valueOf('z'), 'z', false, 1); + run_charQuery(char_filterL, CharacterParameter, Character.valueOf(' '), ' ', true, 1); + run_charQuery(char_filterR, CharacterParameter, Character.valueOf('f'), 'f', false, 3); + run_charQuery(char_filterL, byteParameter, Byte.valueOf((byte)Character.MIN_VALUE), (char)Character.MIN_VALUE, true, 0); + run_charQuery(char_filterR, ByteParameter, Byte.valueOf((byte)'a'), 'a', false, 3); + run_charQuery(char_filterL, shortParameter, Short.valueOf((short)'M'), 'M', true, 5); + run_charQuery(char_filterR, shortParameter, Short.valueOf((short)'M'), 'M', false, 3); + run_charQuery(char_filterL, ShortParameter, Short.valueOf((short)'A'), 'A', true, 2); + run_charQuery(char_filterR, ShortParameter, Short.valueOf((short)'A'), 'A', false, 7); + run_charQuery(char_filterL, intParameter, Integer.valueOf('z'), 'z', true, 7); + run_charQuery(char_filterR, intParameter, Integer.valueOf('z'), 'z', false, 1); + run_charQuery(char_filterL, IntegerParameter, Integer.valueOf('B'), 'B', true, 3); + run_charQuery(char_filterR, IntegerParameter, Integer.valueOf('B'), 'B', false, 6); + run_charQuery(char_filterL, floatParameter, Float.valueOf((float)'f'), 'f', true, 7); + run_charQuery(char_filterR, floatParameter, Float.valueOf((float)' '), ' ', false, 8); + run_charQuery(char_filterL, FloatParameter, Float.valueOf((float)'z'), 'z', true, 7); + run_charQuery(char_filterR, FloatParameter, Float.valueOf((float)'z'), 'z', false, 1); + run_charQuery(char_filterL, doubleParameter, Double.valueOf('B'), 'B', true, 3); + run_charQuery(char_filterR, doubleParameter, Double.valueOf('B'), 'B', false, 6); + run_charQuery(char_filterL, DoubleParameter, Double.valueOf('A'), 'A', true, 2); + run_charQuery(char_filterR, DoubleParameter, Double.valueOf('A'), 'A', false, 7); + run_charQuery(char_filterL, BigIntegerParameter, new BigInteger("65"), 'A', true, 2); // 'A' == 65 + run_charQuery(char_filterR, BigIntegerParameter, new BigInteger("122"), 'z', false, 1); // 'z' == 122 + run_charQuery(char_filterL, BigDecimalParameter, new BigDecimal("65.00000"), 'A', true, 2); + run_charQuery(char_filterR, BigDecimalParameter, new BigDecimal("77.0000"), 'M', false, 3); // 'M' == 77 + alltypes.setchar('A'); + run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'A', true, 2); + alltypes.setchar('b'); + run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'b', true, 7); + run_charQuery(char_filterVal, null, null, 'M', true, 5); + + run_intQuery(int_filterL, intParameter, Integer.valueOf(AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, true, 0); + run_intQuery(int_filterR, intParameter, Integer.valueOf(AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, false, 0); + run_intQuery(int_filterR, intParameter, Integer.valueOf(23), 23, false, 6); + run_intQuery(int_filterL, IntegerParameter, Integer.valueOf(1000000), 1000000, true, 8); + run_intQuery(int_filterR, IntegerParameter, Integer.valueOf(1000), 1000, false, 3); + run_intQuery(int_filterL, byteParameter, Byte.valueOf((byte)100), 100, true, 4); + run_intQuery(int_filterR, byteParameter, Byte.valueOf((byte)0), 0, false, 6); + run_intQuery(int_filterL, ByteParameter, Byte.valueOf((byte)100), 100, true, 4); + run_intQuery(int_filterR, ByteParameter, Byte.valueOf((byte)0), 0, false, 6); + run_intQuery(int_filterL, shortParameter, Short.valueOf((short)10000), 10000, true, 7); + run_intQuery(int_filterR, shortParameter, Short.valueOf((short)-1000), -1000, false, 7); + run_intQuery(int_filterL, ShortParameter, Short.valueOf((short)-1000), -1000, true, 2); + run_intQuery(int_filterR, ShortParameter, Short.valueOf((short)10000), 10000, false, 2); + run_intQuery(int_filterL, charParameter, Character.valueOf((char)100), 100, true, 4); + run_intQuery(int_filterR, charParameter, Character.valueOf((char)0), 0, false, 6); + run_intQuery(int_filterL, CharacterParameter, Character.valueOf((char)100), 100, true, 4); + run_intQuery(int_filterR, CharacterParameter, Character.valueOf((char)10000), 10000, false, 2); + run_intQuery(int_filterL, longParameter, Long.valueOf(AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, true, 9); + run_intQuery(int_filterR, longParameter, Long.valueOf(AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, false, 9); + run_intQuery(int_filterL, LongParameter, Long.valueOf(10000), 10000, true, 7); + run_intQuery(int_filterR, LongParameter, Long.valueOf(43), 43, false, 6); + run_intQuery(int_filterL, floatParameter, Float.valueOf((float)AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, true, 9); + run_intQuery(int_filterR, floatParameter, Float.valueOf((float)AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, false, 9); + run_intQuery(int_filterL, FloatParameter, Float.valueOf((float)10000), 10000, true, 7); + run_intQuery(int_filterR, FloatParameter, Float.valueOf((float)43), 43, false, 6); + run_intQuery(int_filterL, doubleParameter, Double.valueOf(AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, true, 9); + run_intQuery(int_filterR, doubleParameter, Double.valueOf(AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, false, 9); + run_intQuery(int_filterL, DoubleParameter, Double.valueOf(10000.0), 10000, true, 7); + run_intQuery(int_filterR, DoubleParameter, Double.valueOf(43.0), 43, false, 6); + run_intQuery(int_filterL, BigIntegerParameter, new BigInteger("1000000"), 1000000, true, 8); + run_intQuery(int_filterR, BigIntegerParameter, new BigInteger("1000"), 1000, false, 3); + run_intQuery(int_filterL, BigDecimalParameter, new BigDecimal("10000.0"), 10000, true, 7); + run_intQuery(int_filterR, BigDecimalParameter, new BigDecimal("43.0"), 43, false, 6); + alltypes.setint(100); + run_intQuery(int_filterObj, AllTypesParameter, alltypes, 100, true, 4); + run_intQuery(int_filterVal, null, null, 1000, false, 3); + + run_longQuery(long_filterL, longParameter, Long.valueOf(Long.MIN_VALUE), Long.MIN_VALUE, true, 0); + run_longQuery(long_filterR, longParameter, Long.valueOf(Long.MAX_VALUE), Long.MAX_VALUE, false, 0); + run_longQuery(long_filterL, LongParameter, Long.valueOf(100), 100, true, 5); + run_longQuery(long_filterR, LongParameter, Long.valueOf(23), 23, false, 5); + run_longQuery(long_filterL, byteParameter, Byte.valueOf((byte)100), 100, true, 5); + run_longQuery(long_filterR, byteParameter, Byte.valueOf((byte)0), 0, false, 5); + run_longQuery(long_filterL, ByteParameter, Byte.valueOf((byte)100), 100, true, 5); + run_longQuery(long_filterR, ByteParameter, Byte.valueOf((byte)0), 0, false, 5); + run_longQuery(long_filterL, shortParameter, Short.valueOf((short)-1000), -1000, true, 2); + run_longQuery(long_filterR, shortParameter, Short.valueOf((short)1000), 1000, false, 2); + run_longQuery(long_filterL, ShortParameter, Short.valueOf((short)100), 100, true, 5); + run_longQuery(long_filterR, ShortParameter, Short.valueOf((short)32), 32, false, 5); + run_longQuery(long_filterL, charParameter, Character.valueOf((char)0), 0, true, 4); + run_longQuery(long_filterR, charParameter, Character.valueOf((char)100), 100, false, 3); + run_longQuery(long_filterL, CharacterParameter, Character.valueOf((char)23), 23, true, 5); + run_longQuery(long_filterR, CharacterParameter, Character.valueOf((char)0), 0, false, 5); + run_longQuery(long_filterL, intParameter, Integer.valueOf(100), 100, true, 5); + run_longQuery(long_filterR, intParameter, Integer.valueOf(0), 0, false, 5); + run_longQuery(long_filterL, IntegerParameter, Integer.valueOf(23), 23, true, 5); + run_longQuery(long_filterR, IntegerParameter, Integer.valueOf(1000000), 1000000, false, 1); + run_longQuery(long_filterL, floatParameter, Float.valueOf((float)-1000000.0), -1000000, true, 1); + run_longQuery(long_filterR, floatParameter, Float.valueOf((float)Long.MAX_VALUE), Long.MAX_VALUE, false, 0); + run_longQuery(long_filterL, FloatParameter, Float.valueOf((float)100.0), 100, true, 5); + run_longQuery(long_filterR, FloatParameter, Float.valueOf((float)32.0), 32, false, 5); + run_longQuery(long_filterL, doubleParameter, Double.valueOf(-1000000.0), -1000000, true, 1); + run_longQuery(long_filterR, doubleParameter, Double.valueOf((double)Long.MAX_VALUE), Long.MAX_VALUE, false, 0); + run_longQuery(long_filterL, DoubleParameter, Double.valueOf(100.0), 100, true, 5); + run_longQuery(long_filterR, DoubleParameter, Double.valueOf(32.0), 32, false, 5); + run_longQuery(long_filterL, BigIntegerParameter, new BigInteger("23"), 23, true, 5); + run_longQuery(long_filterR, BigIntegerParameter, new BigInteger("1000000"), 1000000, false, 1); + run_longQuery(long_filterL, BigDecimalParameter, new BigDecimal("100.0"), 100, true, 5); + run_longQuery(long_filterR, BigDecimalParameter, new BigDecimal("32.0"), 32, false, 5); + alltypes.setlong(100); + run_longQuery(long_filterObj, AllTypesParameter, alltypes, 100, false, 3); + run_longQuery(long_filterVal, null, null, 1000000, false, 1); + + run_floatQuery(float_filterL, floatParameter, Float.valueOf((float)AllTypes.FLOAT_SMALLEST), AllTypes.FLOAT_SMALLEST, true, 0); + run_floatQuery(float_filterR, floatParameter, Float.valueOf((float)AllTypes.FLOAT_LARGEST), AllTypes.FLOAT_LARGEST, false, 0); + run_floatQuery(float_filterL, FloatParameter, Float.valueOf(4.0f), 4.0f, true, 4); + run_floatQuery(float_filterR, FloatParameter, Float.valueOf(400.0f), 400.0f, false, 3); + run_floatQuery(float_filterL, byteParameter, Byte.valueOf((byte)4), 4.0f, true, 4); + run_floatQuery(float_filterR, byteParameter, Byte.valueOf((byte)23), 23.0f, false, 6); + run_floatQuery(float_filterL, ByteParameter, Byte.valueOf((byte)34), 34.0f, true, 4); + run_floatQuery(float_filterR, ByteParameter, Byte.valueOf((byte)100), 100.0f, false, 4); + run_floatQuery(float_filterL, shortParameter, Short.valueOf((short)10), 10.0f, true, 4); + run_floatQuery(float_filterR, shortParameter, Short.valueOf((short)23), 23.0f, false, 6); + run_floatQuery(float_filterL, ShortParameter, Short.valueOf((short)34), 34.0f, true, 4); + run_floatQuery(float_filterR, ShortParameter, Short.valueOf((short)100), 100.0f, false, 4); + run_floatQuery(float_filterL, charParameter, Character.valueOf((char)20), 20.0f, true, 4); + run_floatQuery(float_filterR, charParameter, Character.valueOf((char)23), 23.0f, false, 6); + run_floatQuery(float_filterL, CharacterParameter, Character.valueOf((char)34), 34.0f, true, 4); + run_floatQuery(float_filterR, CharacterParameter, Character.valueOf((char)100), 100.0f, false, 4); + run_floatQuery(float_filterL, intParameter, Integer.valueOf(55000000), 55000000.0f, true, 8); + run_floatQuery(float_filterR, intParameter, Integer.valueOf(23), 23.0f, false, 6); + run_floatQuery(float_filterL, IntegerParameter, Integer.valueOf(34), 34.0f, true, 4); + run_floatQuery(float_filterR, IntegerParameter, Integer.valueOf(100), 100.0f, false, 4); + run_floatQuery(float_filterL, longParameter, Long.valueOf(55000000), 55000000.0f, true, 8); + run_floatQuery(float_filterR, longParameter, Long.valueOf(23), 23.0f, false, 6); + run_floatQuery(float_filterL, LongParameter, Long.valueOf(34), 34.0f, true, 4); + run_floatQuery(float_filterR, LongParameter, Long.valueOf(100), 100.0f, false, 4); + run_floatQuery(float_filterL, doubleParameter, Double.valueOf(55000000.0), 55000000.0f, true, 8); + run_floatQuery(float_filterR, doubleParameter, Double.valueOf(-20.5), -20.5f, false, 7); + run_floatQuery(float_filterL, DoubleParameter, Double.valueOf(2.0), 2.0f, true, 4); + run_floatQuery(float_filterR, DoubleParameter, Double.valueOf(100.0), 100.0f, false, 4); + run_floatQuery(float_filterL, BigIntegerParameter, new BigInteger("55000000"), 55000000.0f, true, 8); + run_floatQuery(float_filterR, BigIntegerParameter, new BigInteger("23"), 23.0f, false, 6); + run_floatQuery(float_filterL, BigDecimalParameter, new BigDecimal("55000000.0"), 55000000.0f, true, 8); + run_floatQuery(float_filterR, BigDecimalParameter, new BigDecimal("-20.5"), -20.5f, false, 7); + alltypes.setfloat(23.23f); + run_floatQuery(float_filterObj, AllTypesParameter, alltypes, 23.23f, false, 6); + run_floatQuery(float_filterVal, null, null, 100.0f, false, 4); + + run_doubleQuery(double_filterL, doubleParameter, Double.valueOf(AllTypes.DOUBLE_SMALLEST), AllTypes.DOUBLE_SMALLEST, true, 0); + run_doubleQuery(double_filterR, doubleParameter, Double.valueOf(AllTypes.DOUBLE_LARGEST), AllTypes.DOUBLE_LARGEST, false, 0); + run_doubleQuery(double_filterL, DoubleParameter, Double.valueOf(0.0), 0.0, true, 3); + run_doubleQuery(double_filterR, DoubleParameter, Double.valueOf(23.34), 23.34, false, 6); + run_doubleQuery(double_filterL, byteParameter, Byte.valueOf((byte)100), 100.0, true, 4); + run_doubleQuery(double_filterR, byteParameter, Byte.valueOf((byte)0), 0.0, false, 6); + run_doubleQuery(double_filterL, ByteParameter, Byte.valueOf((byte)23), 23.0, true, 4); + run_doubleQuery(double_filterR, ByteParameter, Byte.valueOf((byte)100), 100.0, false, 4); + run_doubleQuery(double_filterL, charParameter, Character.valueOf((char)100), 100.0, true, 4); + run_doubleQuery(double_filterR, charParameter, Character.valueOf((char)0), 0.0, false, 6); + run_doubleQuery(double_filterL, CharacterParameter, Character.valueOf((char)23), 23.0, true, 4); + run_doubleQuery(double_filterR, CharacterParameter, Character.valueOf((char)100), 100.0, false, 4); + run_doubleQuery(double_filterL, shortParameter, Short.valueOf((short)100), 100.0, true, 4); + run_doubleQuery(double_filterR, shortParameter, Short.valueOf((short)0), 0.0, false, 6); + run_doubleQuery(double_filterL, ShortParameter, Short.valueOf((short)23), 23.0, true, 4); + run_doubleQuery(double_filterR, ShortParameter, Short.valueOf((short)100), 100.0, false, 4); + run_doubleQuery(double_filterL, intParameter, Integer.valueOf(100), 100.0, true, 4); + run_doubleQuery(double_filterR, intParameter, Integer.valueOf(0), 0.0, false, 6); + run_doubleQuery(double_filterL, IntegerParameter, Integer.valueOf(5000), 5000.0, true, 7); + run_doubleQuery(double_filterR, IntegerParameter, Integer.valueOf(-20), -20.0, false, 7); + run_doubleQuery(double_filterL, longParameter, Long.valueOf(100), 100.0, true, 4); + run_doubleQuery(double_filterR, longParameter, Long.valueOf(0), 0.0, false, 6); + run_doubleQuery(double_filterL, LongParameter, Long.valueOf(5000), 5000.0, true, 7); + run_doubleQuery(double_filterR, LongParameter, Long.valueOf(-20), -20.0, false, 7); + run_doubleQuery(double_filterL, floatParameter, Float.valueOf(0.0f), 0.0f, true, 3); + run_doubleQuery(double_filterR, floatParameter, Float.valueOf(100.0f), 100.0f, false, 4); + run_doubleQuery(double_filterL, FloatParameter, Float.valueOf(100.0f), 100.0, true, 4); + run_doubleQuery(double_filterR, FloatParameter, Float.valueOf(69.96f), 69.96, false, 6); + run_doubleQuery(double_filterL, BigIntegerParameter, new BigInteger("5000"), 5000.0, true, 7); + run_doubleQuery(double_filterR, BigIntegerParameter, new BigInteger("-20"), -20.0, false, 7); + run_doubleQuery(double_filterL, BigDecimalParameter, new BigDecimal("100.0"), 100.0, true, 4); + run_doubleQuery(double_filterR, BigDecimalParameter, new BigDecimal("69.96"), 69.96, false, 6); + alltypes.setdouble(-25.5); + run_doubleQuery(double_filterObj, AllTypesParameter, alltypes, -25.5, true, 2); + run_doubleQuery(double_filterVal, null, null, 100.0, false, 4); + + run_ByteQuery(Byte_filterL, byteParameter, Byte.valueOf((byte)50), Byte.valueOf((byte)50), true, 5); + run_ByteQuery(Byte_filterR, byteParameter, Byte.valueOf(Byte.MIN_VALUE), Byte.valueOf(Byte.MIN_VALUE), false, 9); + run_ByteQuery(Byte_filterL, ByteParameter, Byte.valueOf((byte)20), Byte.valueOf((byte)20), true, 5); + run_ByteQuery(Byte_filterR, ByteParameter, Byte.valueOf(Byte.MAX_VALUE), Byte.valueOf(Byte.MAX_VALUE), false, 0); + run_ByteQuery(Byte_filterL, shortParameter, Short.valueOf((short)60), Byte.valueOf((byte)60), true, 7); + run_ByteQuery(Byte_filterR, shortParameter, Short.valueOf((short)51), Byte.valueOf((byte)51), false, 3); + run_ByteQuery(Byte_filterL, ShortParameter, Short.valueOf((short)-100), Byte.valueOf((byte)-100), true, 1); + run_ByteQuery(Byte_filterR, ShortParameter, Short.valueOf((short)-100), Byte.valueOf((byte)-100), false, 8); + run_ByteQuery(Byte_filterL, charParameter, Character.valueOf((char)101), Byte.valueOf((byte)101), true, 9); + run_ByteQuery(Byte_filterR, charParameter, Character.valueOf((char)10), Byte.valueOf((byte)10), false, 5); + run_ByteQuery(Byte_filterL, CharacterParameter, Character.valueOf((char)50), Byte.valueOf((byte)50), true, 5); + run_ByteQuery(Byte_filterR, CharacterParameter, Character.valueOf((char)75), Byte.valueOf((byte)75), false, 2); + run_ByteQuery(Byte_filterL, intParameter, Integer.valueOf(77), Byte.valueOf((byte)77), true, 8); + run_ByteQuery(Byte_filterR, intParameter, Integer.valueOf(60), Byte.valueOf((byte)60), false, 3); + run_ByteQuery(Byte_filterL, IntegerParameter, Integer.valueOf(40), Byte.valueOf((byte)40), true, 5); + run_ByteQuery(Byte_filterR, IntegerParameter, Integer.valueOf(75), Byte.valueOf((byte)75), false, 2); + run_ByteQuery(Byte_filterL, longParameter, Long.valueOf(50), Byte.valueOf((byte)50), true, 5); + run_ByteQuery(Byte_filterR, longParameter, Long.valueOf(50), Byte.valueOf((byte)50), false, 3); + run_ByteQuery(Byte_filterL, LongParameter, Long.valueOf(-100), Byte.valueOf((byte)-100), true, 1); + run_ByteQuery(Byte_filterR, LongParameter, Long.valueOf(-100), Byte.valueOf((byte)-100), false, 8); + run_ByteQuery(Byte_filterL, floatParameter, Float.valueOf((float)50), Byte.valueOf((byte)50), true, 5); + run_ByteQuery(Byte_filterR, floatParameter, Float.valueOf((float)50), Byte.valueOf((byte)50), false, 3); + run_ByteQuery(Byte_filterL, FloatParameter, Float.valueOf((float)-100), Byte.valueOf((byte)-100), true, 1); + run_ByteQuery(Byte_filterR, FloatParameter, Float.valueOf((float)-100), Byte.valueOf((byte)-100), false, 8); + run_ByteQuery(Byte_filterL, doubleParameter, Double.valueOf(50), Byte.valueOf((byte)50), true, 5); + run_ByteQuery(Byte_filterR, doubleParameter, Double.valueOf(50), Byte.valueOf((byte)50), false, 3); + run_ByteQuery(Byte_filterL, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte)-100), true, 1); + run_ByteQuery(Byte_filterR, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte)-100), false, 8); + run_ByteQuery(Byte_filterL, BigIntegerParameter, new BigInteger("50"), Byte.valueOf((byte)50), true, 5); + run_ByteQuery(Byte_filterR, BigIntegerParameter, new BigInteger("-100"), Byte.valueOf((byte)-100), false, 8); + run_ByteQuery(Byte_filterL, BigDecimalParameter, new BigDecimal("50.000000"), Byte.valueOf((byte)50), true, 5); + run_ByteQuery(Byte_filterR, BigDecimalParameter, new BigDecimal("10.00000"), Byte.valueOf((byte)10), false, 5); + Byte val = Byte.valueOf((byte)50); + alltypes.setByte(val); + run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, false, 3); + val = Byte.valueOf((byte)51); + alltypes.setByte(val); + run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, false, 3); + run_ByteQuery(Byte_filterVal, null, null, Byte.valueOf((byte)100), true, 8); + + run_ShortQuery(Short_filterL, shortParameter, Short.valueOf((short)100), Short.valueOf((short)100), true, 5); + run_ShortQuery(Short_filterR, shortParameter, Short.valueOf((short)100), Short.valueOf((short)100), false, 3); + run_ShortQuery(Short_filterL, ShortParameter, Short.valueOf(Short.MIN_VALUE), Short.valueOf(Short.MIN_VALUE), true, 0); + run_ShortQuery(Short_filterR, ShortParameter, Short.valueOf((short)253), Short.valueOf((short)253), false, 3); + run_ShortQuery(Short_filterR, shortParameter, Short.valueOf((short)1000), Short.valueOf((short)1000), false, 2); + run_ShortQuery(Short_filterL, byteParameter, Byte.valueOf((byte)75), Short.valueOf((short)75), true, 5); + run_ShortQuery(Short_filterR, byteParameter, Byte.valueOf((byte)75), Short.valueOf((short)75), false, 5); + run_ShortQuery(Short_filterL, ByteParameter, Byte.valueOf((byte)100), Short.valueOf((short)100), true, 5); + run_ShortQuery(Short_filterR, ByteParameter, Byte.valueOf((byte)100), Short.valueOf((short)100), false, 3); + run_ShortQuery(Short_filterL, charParameter, Character.valueOf((char)75), Short.valueOf((short)75), true, 5); + run_ShortQuery(Short_filterR, charParameter, Character.valueOf((char)75), Short.valueOf((short)75), false, 5); + run_ShortQuery(Short_filterL, CharacterParameter, Character.valueOf((char)100), Short.valueOf((short)100), true, 5); + run_ShortQuery(Short_filterR, CharacterParameter, Character.valueOf((char)200), Short.valueOf((short)200), false, 3); + run_ShortQuery(Short_filterL, intParameter, Integer.valueOf(-10000), Short.valueOf((short)-10000), true, 1); + run_ShortQuery(Short_filterR, intParameter, Integer.valueOf(-10000), Short.valueOf((short)-10000), false, 8); + run_ShortQuery(Short_filterL, IntegerParameter, Integer.valueOf(10000), Short.valueOf((short)10000), true, 8); + run_ShortQuery(Short_filterR, IntegerParameter, Integer.valueOf(10000), Short.valueOf((short)10000), false, 1); + run_ShortQuery(Short_filterL, longParameter, Long.valueOf(20000), Short.valueOf((short) 20000), true, 9); + run_ShortQuery(Short_filterR, longParameter, Long.valueOf(5000), Short.valueOf((short) 5000), false, 2); + run_ShortQuery(Short_filterL, LongParameter, Long.valueOf(200), Short.valueOf((short)200), true, 7); + run_ShortQuery(Short_filterR, LongParameter, Long.valueOf(500), Short.valueOf((short)500), false, 3); + run_ShortQuery(Short_filterL, floatParameter, Float.valueOf(23000.0f), Short.valueOf((short)23000), true, 9); + run_ShortQuery(Short_filterR, floatParameter, Float.valueOf(23000.0f), Short.valueOf((short)23000), false, 1); + run_ShortQuery(Short_filterL, FloatParameter, Float.valueOf(10.0f), Short.valueOf((short)10), true, 5); + run_ShortQuery(Short_filterR, FloatParameter, Float.valueOf(101.0f), Short.valueOf((short)101), false, 3); + run_ShortQuery(Short_filterL, doubleParameter, Double.valueOf(-10000.0), Short.valueOf((short)-10000), true, 1); + run_ShortQuery(Short_filterR, doubleParameter, Double.valueOf(-10000.0), Short.valueOf((short)-10000), false, 8); + run_ShortQuery(Short_filterL, DoubleParameter, Double.valueOf(101.0), Short.valueOf((short)101), true, 7); + run_ShortQuery(Short_filterR, DoubleParameter, Double.valueOf(23.0), Short.valueOf((short)23), false, 5); + run_ShortQuery(Short_filterL, BigIntegerParameter, new BigInteger("10000"), Short.valueOf((short)10000), true, 8); + run_ShortQuery(Short_filterR, BigIntegerParameter, new BigInteger("30000"), Short.valueOf((short)30000), false, 1); + run_ShortQuery(Short_filterL, BigDecimalParameter, new BigDecimal("23.0"), Short.valueOf((short)23), true, 5); + run_ShortQuery(Short_filterR, BigDecimalParameter, new BigDecimal("23.0"), Short.valueOf((short)23), false, 5); + Short sval = Short.valueOf((short)100); + alltypes.setShort(sval); + run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, false, 3); + sval = Short.valueOf((short)23); + alltypes.setShort(sval); + run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, false, 5); + run_ShortQuery(Short_filterVal, null, null, Short.valueOf((short)-1000), true, 2); + + run_CharacterQuery(Character_filterL, charParameter, Character.valueOf(Character.MIN_VALUE), Character.valueOf(Character.MIN_VALUE), true, 0); + run_CharacterQuery(Character_filterR, charParameter, Character.valueOf(Character.MAX_VALUE), Character.valueOf(Character.MAX_VALUE), false, 0); + run_CharacterQuery(Character_filterL, charParameter, Character.valueOf('C'), Character.valueOf('C'), true, 4); + run_CharacterQuery(Character_filterR, charParameter, Character.valueOf('z'), Character.valueOf('z'), false, 1); + run_CharacterQuery(Character_filterL, CharacterParameter, Character.valueOf(' '), Character.valueOf(' '), true, 1); + run_CharacterQuery(Character_filterR, CharacterParameter, Character.valueOf('f'), Character.valueOf('f'), false, 3); + run_CharacterQuery(Character_filterL, byteParameter, Byte.valueOf((byte)Character.MIN_VALUE), Character.valueOf((char)Character.MIN_VALUE), true, 0); + run_CharacterQuery(Character_filterR, ByteParameter, Byte.valueOf((byte)'a'), Character.valueOf('a'), false, 3); + run_CharacterQuery(Character_filterL, shortParameter, Short.valueOf((short)'M'), Character.valueOf('M'), true, 5); + run_CharacterQuery(Character_filterR, shortParameter, Short.valueOf((short)'F'), Character.valueOf('F'), false, 5); + run_CharacterQuery(Character_filterL, ShortParameter, Short.valueOf((short)'A'), Character.valueOf('A'), true, 2); + run_CharacterQuery(Character_filterR, ShortParameter, Short.valueOf((short)'A'), Character.valueOf('A'), false, 7); + run_CharacterQuery(Character_filterL, intParameter, Integer.valueOf('z'), Character.valueOf('z'), true, 7); + run_CharacterQuery(Character_filterR, intParameter, Integer.valueOf('z'), Character.valueOf('z'), false, 1); + run_CharacterQuery(Character_filterL, IntegerParameter, Integer.valueOf('B'), Character.valueOf('B'), true, 3); + run_CharacterQuery(Character_filterR, IntegerParameter, Integer.valueOf('B'), Character.valueOf('B'), false, 6); + run_CharacterQuery(Character_filterL, longParameter, Long.valueOf('z'), Character.valueOf('z'), true, 7); + run_CharacterQuery(Character_filterR, longParameter, Long.valueOf('z'), Character.valueOf('z'), false, 1); + run_CharacterQuery(Character_filterL, LongParameter, Long.valueOf('B'), Character.valueOf('B'), true, 3); + run_CharacterQuery(Character_filterR, LongParameter, Long.valueOf('B'), Character.valueOf('B'), false, 6); + run_CharacterQuery(Character_filterL, floatParameter, Float.valueOf((float)'z'), Character.valueOf('z'), true, 7); + run_CharacterQuery(Character_filterR, floatParameter, Float.valueOf((float)'z'), Character.valueOf('z'), false, 1); + run_CharacterQuery(Character_filterL, FloatParameter, Float.valueOf((float)'M'), Character.valueOf('M'), true, 5); + run_CharacterQuery(Character_filterR, FloatParameter, Float.valueOf((float)'X'), Character.valueOf('X'), false, 3); + run_CharacterQuery(Character_filterL, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), true, 3); + run_CharacterQuery(Character_filterR, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), false, 6); + run_CharacterQuery(Character_filterL, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), true, 2); + run_CharacterQuery(Character_filterR, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), false, 7); + run_CharacterQuery(Character_filterL, BigIntegerParameter, new BigInteger("65"), Character.valueOf('A'), true, 2); // 'A' == 65 + run_CharacterQuery(Character_filterR, BigIntegerParameter, new BigInteger("122"), Character.valueOf('z'), false, 1); // 'z' == 122 + run_CharacterQuery(Character_filterL, BigDecimalParameter, new BigDecimal("65.00000"), Character.valueOf('A'), true, 2); + run_CharacterQuery(Character_filterR, BigDecimalParameter, new BigDecimal("77.0000"), Character.valueOf('M'), false, 3); // 'M' == 77 + alltypes.setCharacter(Character.valueOf('A')); + run_CharacterQuery(Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('A'), true, 2); + alltypes.setCharacter(Character.valueOf('b')); + run_CharacterQuery(Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('b'), true, 7); + run_CharacterQuery(Character_filterVal, null, null, Character.valueOf('z'), false, 1); + + run_IntegerQuery(Integer_filterL, intParameter, Integer.valueOf(AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), true, 0); + run_IntegerQuery(Integer_filterR, intParameter, Integer.valueOf(AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), false, 0); + run_IntegerQuery(Integer_filterR, intParameter, Integer.valueOf(23), Integer.valueOf(23), false, 6); + run_IntegerQuery(Integer_filterL, IntegerParameter, Integer.valueOf(1000000), Integer.valueOf(1000000), true, 8); + run_IntegerQuery(Integer_filterR, IntegerParameter, Integer.valueOf(1000), Integer.valueOf(1000), false, 3); + run_IntegerQuery(Integer_filterL, byteParameter, Byte.valueOf((byte)100), Integer.valueOf(100), true, 4); + run_IntegerQuery(Integer_filterR, byteParameter, Byte.valueOf((byte)0), Integer.valueOf(0), false, 6); + run_IntegerQuery(Integer_filterL, ByteParameter, Byte.valueOf((byte)100), Integer.valueOf(100), true, 4); + run_IntegerQuery(Integer_filterR, ByteParameter, Byte.valueOf((byte)0), Integer.valueOf(0), false, 6); + run_IntegerQuery(Integer_filterL, shortParameter, Short.valueOf((short)10000), Integer.valueOf(10000), true, 7); + run_IntegerQuery(Integer_filterR, shortParameter, Short.valueOf((short)-1000), Integer.valueOf(-1000), false, 7); + run_IntegerQuery(Integer_filterL, ShortParameter, Short.valueOf((short)-1000), Integer.valueOf(-1000), true, 2); + run_IntegerQuery(Integer_filterR, ShortParameter, Short.valueOf((short)-999), Integer.valueOf(-999), false, 7); + run_IntegerQuery(Integer_filterL, charParameter, Character.valueOf((char)10000), Integer.valueOf(10000), true, 7); + run_IntegerQuery(Integer_filterR, charParameter, Character.valueOf((char)10000), Integer.valueOf(10000), false, 2); + run_IntegerQuery(Integer_filterL, CharacterParameter, Character.valueOf((char)100), Integer.valueOf(100), true, 4); + run_IntegerQuery(Integer_filterR, CharacterParameter, Character.valueOf((char)10000), Integer.valueOf(10000), false, 2); + run_IntegerQuery(Integer_filterL, longParameter, Long.valueOf(AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), true, 9); + run_IntegerQuery(Integer_filterR, longParameter, Long.valueOf(AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), false, 9); + run_IntegerQuery(Integer_filterL, LongParameter, Long.valueOf(10000), Integer.valueOf(10000), true, 7); + run_IntegerQuery(Integer_filterR, LongParameter, Long.valueOf(43), Integer.valueOf(43), false, 6); + run_IntegerQuery(Integer_filterL, floatParameter, Float.valueOf((float)AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), true, 9); + run_IntegerQuery(Integer_filterR, floatParameter, Float.valueOf((float)AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), false, 9); + run_IntegerQuery(Integer_filterL, FloatParameter, Float.valueOf((float)10000), Integer.valueOf(10000), true, 7); + run_IntegerQuery(Integer_filterR, FloatParameter, Float.valueOf((float)43), Integer.valueOf(43), false, 6); + run_IntegerQuery(Integer_filterL, doubleParameter, Double.valueOf(AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), true, 9); + run_IntegerQuery(Integer_filterR, doubleParameter, Double.valueOf(AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), false, 9); + run_IntegerQuery(Integer_filterL, DoubleParameter, Double.valueOf(10000), Integer.valueOf(10000), true, 7); + run_IntegerQuery(Integer_filterR, DoubleParameter, Double.valueOf(1000001.0), Integer.valueOf(1000001), false, 1); + run_IntegerQuery(Integer_filterL, BigIntegerParameter, new BigInteger("1000000"), Integer.valueOf(1000000), true, 8); + run_IntegerQuery(Integer_filterR, BigIntegerParameter, new BigInteger("1000"), Integer.valueOf(1000), false, 3); + run_IntegerQuery(Integer_filterL, BigDecimalParameter, new BigDecimal("10000.0"), Integer.valueOf(10000), true, 7); + run_IntegerQuery(Integer_filterR, BigDecimalParameter, new BigDecimal("43.0"), Integer.valueOf(43), false, 6); + alltypes.setInteger(Integer.valueOf(100)); + run_IntegerQuery(Integer_filterObj, AllTypesParameter, alltypes, Integer.valueOf(100), false, 4); + run_IntegerQuery(Integer_filterVal, null, null, Integer.valueOf(100), false, 4); + + run_LongQuery(Long_filterL, longParameter, Long.valueOf(Long.MIN_VALUE), Long.valueOf(Long.MIN_VALUE), true, 0); + run_LongQuery(Long_filterR, longParameter, Long.valueOf(Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE), false, 0); + run_LongQuery(Long_filterL, LongParameter, Long.valueOf(100), Long.valueOf(100), true, 5); + run_LongQuery(Long_filterR, LongParameter, Long.valueOf(23), Long.valueOf(23), false, 5); + run_LongQuery(Long_filterL, byteParameter, Byte.valueOf((byte)100), Long.valueOf(100), true, 5); + run_LongQuery(Long_filterR, byteParameter, Byte.valueOf((byte)0), Long.valueOf(0), false, 5); + run_LongQuery(Long_filterL, ByteParameter, Byte.valueOf((byte)100), Long.valueOf(100), true, 5); + run_LongQuery(Long_filterR, ByteParameter, Byte.valueOf((byte)0), Long.valueOf(0), false, 5); + run_LongQuery(Long_filterL, shortParameter, Short.valueOf((short)-1000 ), Long.valueOf(-1000), true, 2); + run_LongQuery(Long_filterR, shortParameter, Short.valueOf((short)1000), Long.valueOf(1000), false, 2); + run_LongQuery(Long_filterL, ShortParameter, Short.valueOf((short)101), Long.valueOf(101), true, 7); + run_LongQuery(Long_filterR, ShortParameter, Short.valueOf((short)32), Long.valueOf(32), false, 5); + run_LongQuery(Long_filterL, charParameter, Character.valueOf((char)0), Long.valueOf(0), true, 4); + run_LongQuery(Long_filterR, charParameter, Character.valueOf((char)100), Long.valueOf(100), false, 3); + run_LongQuery(Long_filterL, CharacterParameter, Character.valueOf((char)23), Long.valueOf(23), true, 5); + run_LongQuery(Long_filterR, CharacterParameter, Character.valueOf((char)1110), Long.valueOf(1110), false, 2); + run_LongQuery(Long_filterL, intParameter, Integer.valueOf(100), Long.valueOf(100), true, 5); + run_LongQuery(Long_filterR, intParameter, Integer.valueOf(0), Long.valueOf(0), false, 5); + run_LongQuery(Long_filterL, IntegerParameter, Integer.valueOf(23), Long.valueOf(23), true, 5); + run_LongQuery(Long_filterR, IntegerParameter, Integer.valueOf(1000000), Long.valueOf(1000000), false, 1); + run_LongQuery(Long_filterL, floatParameter, Float.valueOf((float)-1000000.0), Long.valueOf(-1000000), true, 1); + run_LongQuery(Long_filterR, floatParameter, Float.valueOf((float)Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE), false, 0); + run_LongQuery(Long_filterL, FloatParameter, Float.valueOf(100.0f), Long.valueOf(100), true, 5); + run_LongQuery(Long_filterR, FloatParameter, Float.valueOf(32.0f), Long.valueOf(32), false, 5); + run_LongQuery(Long_filterL, doubleParameter, Double.valueOf(-1000000.0), Long.valueOf(-1000000), true, 1); + run_LongQuery(Long_filterR, doubleParameter, Double.valueOf((double)Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE), false, 0); + run_LongQuery(Long_filterL, DoubleParameter, Double.valueOf(100.0), Long.valueOf(100), true, 5); + run_LongQuery(Long_filterR, DoubleParameter, Double.valueOf(32.0), Long.valueOf(32), false, 5); + run_LongQuery(Long_filterL, BigIntegerParameter, new BigInteger("23"), Long.valueOf(23), true, 5); + run_LongQuery(Long_filterR, BigIntegerParameter, new BigInteger("1000000"), Long.valueOf(1000000), false, 1); + run_LongQuery(Long_filterL, BigDecimalParameter, new BigDecimal("100.0"), Long.valueOf(100), true, 5); + run_LongQuery(Long_filterR, BigDecimalParameter, new BigDecimal("32.0"), Long.valueOf(32), false, 5); + alltypes.setLong(Long.valueOf(100)); + run_LongQuery(Long_filterObj, AllTypesParameter, alltypes, Long.valueOf(100), true, 5); + run_LongQuery(Long_filterVal, null, null, Long.valueOf(-1000), true, 2); + + run_FloatQuery(Float_filterL, floatParameter, Float.valueOf(-1000000000.0f), Float.valueOf(-1000000000.0f), true, 1); + run_FloatQuery(Float_filterR, floatParameter, Float.valueOf(9000000000.0f), Float.valueOf(9000000000.0f), false, 1); + run_FloatQuery(Float_filterL, FloatParameter, Float.valueOf((float)0.0), Float.valueOf(0.0f), true, 2); + run_FloatQuery(Float_filterR, FloatParameter, Float.valueOf((float)4.0), Float.valueOf(4.0f), false, 7); + run_FloatQuery(Float_filterL, byteParameter, Byte.valueOf((byte)0), Float.valueOf(0.0f), true, 2); + run_FloatQuery(Float_filterR, byteParameter, Byte.valueOf((byte)23), Float.valueOf(23.0f), false, 7); + run_FloatQuery(Float_filterL, ByteParameter, Byte.valueOf((byte)34), Float.valueOf(34.0f), true, 3); + run_FloatQuery(Float_filterR, ByteParameter, Byte.valueOf((byte)100), Float.valueOf(100.0f), false, 5); + run_FloatQuery(Float_filterL, shortParameter, Short.valueOf((short)0), Float.valueOf(0.0f), true, 2); + run_FloatQuery(Float_filterR, shortParameter, Short.valueOf((short)23), Float.valueOf(23.0f), false, 7); + run_FloatQuery(Float_filterL, ShortParameter, Short.valueOf((short)34), Float.valueOf(34.0f), true, 3); + run_FloatQuery(Float_filterR, ShortParameter, Short.valueOf((short)100), Float.valueOf(100.0f), false, 5); + run_FloatQuery(Float_filterL, charParameter, Character.valueOf((char)0), Float.valueOf(0.0f), true, 2); + run_FloatQuery(Float_filterR, charParameter, Character.valueOf((char)23), Float.valueOf(23.0f), false, 7); + run_FloatQuery(Float_filterL, CharacterParameter, Character.valueOf((char)34), Float.valueOf(34.0f), true, 3); + run_FloatQuery(Float_filterR, CharacterParameter, Character.valueOf((char)100), Float.valueOf(100.0f), false, 5); + run_FloatQuery(Float_filterL, intParameter, Integer.valueOf(50000000), Float.valueOf(50000000.0f), true, 7); + run_FloatQuery(Float_filterR, intParameter, Integer.valueOf(23), Float.valueOf(23.0f), false, 7); + run_FloatQuery(Float_filterL, IntegerParameter, Integer.valueOf(34), Float.valueOf(34.0f), true, 3); + run_FloatQuery(Float_filterR, IntegerParameter, Integer.valueOf(100), Float.valueOf(100.0f), false, 5); + run_FloatQuery(Float_filterL, longParameter, Long.valueOf(50000000), Float.valueOf(50000000.0f), true, 7); + run_FloatQuery(Float_filterR, longParameter, Long.valueOf(23), Float.valueOf(23.0f), false, 7); + run_FloatQuery(Float_filterL, LongParameter, Long.valueOf(34), Float.valueOf(34.0f), true, 3); + run_FloatQuery(Float_filterR, LongParameter, Long.valueOf(100), Float.valueOf(100.0f), false, 5); + run_FloatQuery(Float_filterL, doubleParameter, Double.valueOf(50000000.0f), Float.valueOf(50000000.0f), true, 7); + run_FloatQuery(Float_filterR, doubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), false, 5); + run_FloatQuery(Float_filterL, DoubleParameter, Double.valueOf(0.0f), Float.valueOf(0.0f), true, 2); + run_FloatQuery(Float_filterR, DoubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), false, 5); + run_FloatQuery(Float_filterL, BigIntegerParameter, new BigInteger("55000000"), Float.valueOf(55000000.0f), true, 8); + run_FloatQuery(Float_filterR, BigIntegerParameter, new BigInteger("23"), Float.valueOf(23.0f), false, 7); + run_FloatQuery(Float_filterL, BigDecimalParameter, new BigDecimal("55000000.0"), Float.valueOf(55000000.0f), true, 8); + run_FloatQuery(Float_filterR, BigDecimalParameter, new BigDecimal("-20.5"), Float.valueOf(-20.5f), false, 8); + alltypes.setFloat(Float.valueOf(23.23f)); + run_FloatQuery(Float_filterObj, AllTypesParameter, alltypes, Float.valueOf(23.23f), false, 7); + run_FloatQuery(Float_filterVal, null, null, Float.valueOf(100.0f), true, 3); + + run_DoubleQuery(Double_filterL, doubleParameter, Double.valueOf(-999999999999.0), Double.valueOf(-999999999999.0), true, 1); + run_DoubleQuery(Double_filterR, doubleParameter, Double.valueOf(9999999999999.0), Double.valueOf(9999999999999.0), false, 1); + run_DoubleQuery(Double_filterL, DoubleParameter, Double.valueOf(0.0), Double.valueOf(0.0), true, 3); + run_DoubleQuery(Double_filterR, DoubleParameter, Double.valueOf(23.34), Double.valueOf(23.34), false, 6); + run_DoubleQuery(Double_filterL, byteParameter, Byte.valueOf((byte)100), Double.valueOf(100.0), true, 4); + run_DoubleQuery(Double_filterR, byteParameter, Byte.valueOf((byte)0), Double.valueOf(0.0), false, 6); + run_DoubleQuery(Double_filterL, ByteParameter, Byte.valueOf((byte)-23), Double.valueOf(-23.0), true, 3); + run_DoubleQuery(Double_filterR, ByteParameter, Byte.valueOf((byte)100), Double.valueOf(100.0), false, 4); + run_DoubleQuery(Double_filterL, shortParameter, Short.valueOf((short)100), Double.valueOf(100.0), true, 4); + run_DoubleQuery(Double_filterR, shortParameter, Short.valueOf((short)0), Double.valueOf(0.0), false, 6); + run_DoubleQuery(Double_filterL, ShortParameter, Short.valueOf((short)23), Double.valueOf(23.0), true, 4); + run_DoubleQuery(Double_filterR, ShortParameter, Short.valueOf((short)400), Double.valueOf(400.0), false, 3); + run_DoubleQuery(Double_filterL, charParameter, Character.valueOf((char)100), Double.valueOf(100.0), true, 4); + run_DoubleQuery(Double_filterR, charParameter, Character.valueOf((char)0), Double.valueOf(0.0), false, 6); + run_DoubleQuery(Double_filterL, CharacterParameter, Character.valueOf((char)23), Double.valueOf(23.0), true, 4); + run_DoubleQuery(Double_filterR, CharacterParameter, Character.valueOf((char)400), Double.valueOf(400.0), false, 3); + run_DoubleQuery(Double_filterL, intParameter, Integer.valueOf(100), Double.valueOf(100.0), true, 4); + run_DoubleQuery(Double_filterR, intParameter, Integer.valueOf(0), Double.valueOf(0.0), false, 6); + run_DoubleQuery(Double_filterL, IntegerParameter, Integer.valueOf(23), Double.valueOf(23.0), true, 4); + run_DoubleQuery(Double_filterR, IntegerParameter, Integer.valueOf(100), Double.valueOf(100.0), false, 4); + run_DoubleQuery(Double_filterL, longParameter, Long.valueOf(100), Double.valueOf(100.0), true, 4); + run_DoubleQuery(Double_filterR, longParameter, Long.valueOf(0), Double.valueOf(0.0), false, 6); + run_DoubleQuery(Double_filterL, LongParameter, Long.valueOf(23), Double.valueOf(23.0), true, 4); + run_DoubleQuery(Double_filterR, LongParameter, Long.valueOf(100), Double.valueOf(100.0), false, 4); + run_DoubleQuery(Double_filterL, floatParameter, Float.valueOf(0.0f), Double.valueOf(0.0f), true, 3); + run_DoubleQuery(Double_filterR, floatParameter, Float.valueOf(100.0f), Double.valueOf(100.0f), false, 4); + run_DoubleQuery(Double_filterL, FloatParameter, Float.valueOf(100.0f), Double.valueOf(100.0f), true, 4); + run_DoubleQuery(Double_filterR, FloatParameter, Float.valueOf(69.96f), Double.valueOf(69.96), false, 6); + run_DoubleQuery(Double_filterL, BigIntegerParameter, new BigInteger("5000"), Double.valueOf(5000.0), true, 7); + run_DoubleQuery(Double_filterR, BigIntegerParameter, new BigInteger("-20"), Double.valueOf(-20.0), false, 7); + run_DoubleQuery(Double_filterL, BigDecimalParameter, new BigDecimal("100.0"), Double.valueOf(100.0), true, 4); + run_DoubleQuery(Double_filterR, BigDecimalParameter, new BigDecimal("69.96"), Double.valueOf(69.96), false, 6); + alltypes.setDouble(Double.valueOf(-999999999999.0)); + run_DoubleQuery(Double_filterObj, AllTypesParameter, alltypes, Double.valueOf(-999999999999.0), true, 1); + run_DoubleQuery(Double_filterVal, null, null, Double.valueOf(100.0), false, 4); - BigDecimal bd = new BigDecimal("100.0"); - run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, true, 4); - bd = new BigDecimal("-234234.23333"); - run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, false, 8); - bd = new BigDecimal("989899.33304953"); - run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, true, 7); - bd = new BigDecimal("-1123123.22"); - run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, false, 9); - alltypes.setBigDecimal(bd); - run_BigDecimalQuery(BigDecimal_filterObj, AllTypesParameter, alltypes, bd, true, 0); + run_StringQuery(String_filterL, StringParameter, new String("JDO"), new String("JDO"), true, 1); + run_StringQuery(String_filterR, StringParameter, new String("JDBC"), new String("JDBC"), false, 9); + alltypes.setString(new String("abcde")); + run_StringQuery(String_filterObj, AllTypesParameter, alltypes, new String("abcde"), true, 7); + run_StringQuery(String_filterVal1, null, null, new String("Java"), false, 4); + run_StringQuery(String_filterVal2, null, null, new String(""), false, 9); - BigInteger bi = new BigInteger("987034534985043985"); - run_BigIntegerQuery(BigInteger_filterL, BigIntegerParameter, bi, bi, true, 9); - bi = new BigInteger("-999999999999999999"); - run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, false, 9); - bi = new BigInteger("-9999999999999999999"); - run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, false, 10); - bi = new BigInteger("1333330"); - alltypes.setBigInteger(bi); - run_BigIntegerQuery(BigInteger_filterObj, AllTypesParameter, alltypes, bi, false, 2); + BigDecimal bd = new BigDecimal("100.0"); + run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, true, 4); + bd = new BigDecimal("-234234.23333"); + run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, false, 8); + bd = new BigDecimal("989899.33304953"); + run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, true, 7); + bd = new BigDecimal("-1123123.22"); + run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, false, 9); + alltypes.setBigDecimal(bd); + run_BigDecimalQuery(BigDecimal_filterObj, AllTypesParameter, alltypes, bd, true, 0); - GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.UK); - gc.clear(); - gc.set(1999, Calendar.DECEMBER, 31, 9, 0, 0); - Date d = gc.getTime(); - run_DateQuery(Date_filterL, DateParameter, d, d, true, 7); - gc.set(1992, Calendar.NOVEMBER, 22, 9, 0, 0); - d = gc.getTime(); - run_DateQuery(Date_filterR, DateParameter, d, d, false, 4); - gc.set(1959, Calendar.OCTOBER, 9, 9, 0, 0); - d = gc.getTime(); - run_DateQuery(Date_filterR, DateParameter, d, d, false, 7); - gc.set(1995, Calendar.JUNE, 14, 9, 0, 0); - d = gc.getTime(); - alltypes.setDate(d); - run_DateQuery(Date_filterObj, AllTypesParameter, alltypes, d, false, 3); - } + BigInteger bi = new BigInteger("987034534985043985"); + run_BigIntegerQuery(BigInteger_filterL, BigIntegerParameter, bi, bi, true, 9); + bi = new BigInteger("-999999999999999999"); + run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, false, 9); + bi = new BigInteger("-9999999999999999999"); + run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, false, 10); + bi = new BigInteger("1333330"); + alltypes.setBigInteger(bi); + run_BigIntegerQuery(BigInteger_filterObj, AllTypesParameter, alltypes, bi, false, 2); + + GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.UK); + gc.clear(); + gc.set(1999, Calendar.DECEMBER, 31, 9, 0, 0); + Date d = gc.getTime(); + run_DateQuery(Date_filterL, DateParameter, d, d, true, 7); + gc.set(1992, Calendar.NOVEMBER, 22, 9, 0, 0); + d = gc.getTime(); + run_DateQuery(Date_filterR, DateParameter, d, d, false, 4); + gc.set(1959, Calendar.OCTOBER, 9, 9, 0, 0); + d = gc.getTime(); + run_DateQuery(Date_filterR, DateParameter, d, d, false, 7); + gc.set(1995, Calendar.JUNE, 14, 9, 0, 0); + d = gc.getTime(); + alltypes.setDate(d); + run_DateQuery(Date_filterObj, AllTypesParameter, alltypes, d, false, 3); - private void run_byteQuery( - String filter, - String parameter, - Object parameterValue, - byte value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - byte val = obj.getbyte(); - boolean correct_value = valueOnLeft ? value > val : val > value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_shortQuery( - String filter, - String parameter, - Object parameterValue, - short value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - short val = obj.getshort(); - boolean correct_value = valueOnLeft ? value > val : val > value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_byteQuery(String filter, String parameter, Object parameterValue, byte value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + byte val = obj.getbyte(); + boolean correct_value = valueOnLeft ? value > val : val > value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_charQuery( - String filter, - String parameter, - Object parameterValue, - char value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - char val = obj.getchar(); - boolean correct_value = valueOnLeft ? value > val : val > value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_shortQuery(String filter, String parameter, Object parameterValue, short value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + short val = obj.getshort(); + boolean correct_value = valueOnLeft ? value > val : val > value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_intQuery( - String filter, - String parameter, - Object parameterValue, - int value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - int val = obj.getint(); - boolean correct_value = valueOnLeft ? value > val : val > value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_charQuery(String filter, String parameter, Object parameterValue, char value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + char val = obj.getchar(); + boolean correct_value = valueOnLeft ? value > val : val > value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_longQuery( - String filter, - String parameter, - Object parameterValue, - long value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - long val = obj.getlong(); - boolean correct_value = valueOnLeft ? value > val : val > value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_intQuery(String filter, String parameter, Object parameterValue, int value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + int val = obj.getint(); + boolean correct_value = valueOnLeft ? value > val : val > value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_floatQuery( - String filter, - String parameter, - Object parameterValue, - float value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - float val = obj.getfloat(); - boolean correct_value = valueOnLeft ? value > val : val > value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_longQuery(String filter, String parameter, Object parameterValue, long value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + long val = obj.getlong(); + boolean correct_value = valueOnLeft ? value > val : val > value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_doubleQuery( - String filter, - String parameter, - Object parameterValue, - double value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - double val = obj.getdouble(); - boolean correct_value = valueOnLeft ? value > val : val > value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_floatQuery(String filter, String parameter, Object parameterValue, float value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + float val = obj.getfloat(); + boolean correct_value = valueOnLeft ? value > val : val > value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_ByteQuery( - String filter, - String parameter, - Object parameterValue, - Byte value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Byte val = obj.getByte(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_doubleQuery(String filter, String parameter, Object parameterValue, double value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + double val = obj.getdouble(); + boolean correct_value = valueOnLeft ? value > val : val > value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_ShortQuery( - String filter, - String parameter, - Object parameterValue, - Short value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Short val = obj.getShort(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_ByteQuery(String filter, String parameter, Object parameterValue, + Byte value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Byte val = obj.getByte(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_CharacterQuery( - String filter, - String parameter, - Object parameterValue, - Character value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Character val = obj.getCharacter(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_ShortQuery(String filter, String parameter, Object parameterValue, + Short value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Short val = obj.getShort(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_IntegerQuery( - String filter, - String parameter, - Object parameterValue, - Integer value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Integer val = obj.getInteger(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_CharacterQuery(String filter, String parameter, Object parameterValue, + Character value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Character val = obj.getCharacter(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_LongQuery( - String filter, - String parameter, - Object parameterValue, - Long value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Long val = obj.getLong(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_IntegerQuery(String filter, String parameter, Object parameterValue, + Integer value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Integer val = obj.getInteger(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_FloatQuery( - String filter, - String parameter, - Object parameterValue, - Float value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Float val = obj.getFloat(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_LongQuery(String filter, String parameter, Object parameterValue, + Long value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Long val = obj.getLong(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_DoubleQuery( - String filter, - String parameter, - Object parameterValue, - Double value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Double val = obj.getDouble(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_FloatQuery(String filter, String parameter, Object parameterValue, + Float value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Float val = obj.getFloat(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_StringQuery( - String filter, - String parameter, - Object parameterValue, - String value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - String val = obj.getString(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_DoubleQuery(String filter, String parameter, Object parameterValue, + Double value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Double val = obj.getDouble(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_BigDecimalQuery( - String filter, - String parameter, - Object parameterValue, - BigDecimal value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - BigDecimal val = obj.getBigDecimal(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_StringQuery(String filter, String parameter, Object parameterValue, + String value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + String val = obj.getString(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_BigIntegerQuery( - String filter, - String parameter, - Object parameterValue, - BigInteger value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - BigInteger val = obj.getBigInteger(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_BigDecimalQuery(String filter, String parameter, Object parameterValue, + BigDecimal value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + BigDecimal val = obj.getBigDecimal(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_DateQuery( - String filter, - String parameter, - Object parameterValue, - Date value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Date val = obj.getDate(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_BigIntegerQuery(String filter, String parameter, Object parameterValue, + BigInteger value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + BigInteger val = obj.getBigInteger(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL Greater Than test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + + private void run_DateQuery(String filter, String parameter, Object parameterValue, + Date value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Date val = obj.getDate(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) > 0) : (val.compareTo(value) > 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL Greater Than test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - /** */ - protected void localSetUp() { - addTearDownClass(AllTypes.class); - AllTypes.load(getPM()); - } + /** */ + protected void localSetUp() { + addTearDownClass(AllTypes.class); + AllTypes.load(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/GreaterThanOrEqual.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/GreaterThanOrEqual.java index e6c082306..1c07f6b14 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/GreaterThanOrEqual.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/GreaterThanOrEqual.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -25,2365 +25,1177 @@ import java.util.Iterator; import java.util.Locale; import java.util.TimeZone; + import org.apache.jdo.tck.pc.fieldtypes.AllTypes; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Greater Than or Equal Query Operator
    - * Keywords: query
    - * Assertion ID: A14.6.2-18.
    - * Assertion Description: The greater than or equal operator (>=) is - * supported for all types as they are defined in the Java language. This includes the following - * types: - * - *
      - *
    • byte, short, int, long, char, Byte, Short Integer, Long, Character - *
    • float, double, Float, Double - *
    • BigDecimal, BigInteger - *
    • Date, String - *
    - * - * The operation on object-valued fields of wrapper types (Boolean, Byte, - * Short, Integer, Long, Float, and Double), and numeric types (BigDecimal - * and BigInteger) use the wrapped values as operands. - */ -public class GreaterThanOrEqual extends ComparisonTests { - private static String boolean_filterL = "value >= fld_boolean"; - private static String boolean_filterR = "fld_boolean >= value"; - private static String boolean_filterT = "fld_boolean >= true"; - private static String boolean_filterF = "false >= fld_boolean"; - private static String boolean_filterObj = "value.fld_boolean >= fld_boolean"; - - private static String byte_filterL = "value >= fld_byte"; - private static String byte_filterR = "fld_byte >= value"; - private static String byte_filterObj = "value.fld_byte >= fld_byte"; - private static String byte_filterVal = "fld_byte >= 100"; - - private static String char_filterL = "value >= fld_char"; - private static String char_filterR = "fld_char >= value"; - private static String char_filterObj = "value.fld_char >= fld_char"; - private static String char_filterVal = "'M' >= fld_char"; - - private static String double_filterL = "value >= fld_double"; - private static String double_filterR = "fld_double >= value"; - private static String double_filterObj = "value.fld_double >= fld_double"; - private static String double_filterVal = "fld_double >= 100.0"; - - private static String float_filterL = "value >= fld_float"; - private static String float_filterR = "fld_float >= value"; - private static String float_filterObj = "fld_float >= value.fld_float"; - private static String float_filterVal = "fld_float >= 100.0"; - - private static String int_filterL = "value >= fld_int"; - private static String int_filterR = "fld_int >= value"; - private static String int_filterObj = "value.fld_int >= fld_int"; - private static String int_filterVal = "fld_int >= 1000"; - - private static String long_filterL = "value >= fld_long"; - private static String long_filterR = "fld_long >= value"; - private static String long_filterObj = "fld_long >= value.fld_long"; - private static String long_filterVal = "fld_long >= 1000000"; - - private static String short_filterL = "value >= fld_short"; - private static String short_filterR = "fld_short >= value"; - private static String short_filterObj = "value.fld_short >= fld_short"; - private static String short_filterVal = "1000 >= fld_short"; - - private static String Boolean_filterL = "value >= fld_Boolean"; - private static String Boolean_filterR = "fld_Boolean >= value"; - private static String Boolean_filterT = "fld_Boolean >= true"; - private static String Boolean_filterF = "false >= fld_Boolean"; - private static String Boolean_filterObj = "value.fld_Boolean >= fld_Boolean"; - private static String Boolean_filterVal = "fld_Boolean >= false"; - - private static String Byte_filterL = "value >= fld_Byte"; - private static String Byte_filterR = "fld_Byte >= value"; - private static String Byte_filterObj = "fld_Byte >= value.fld_Byte"; - private static String Byte_filterVal = "100 >= fld_Byte"; - - private static String Character_filterL = "value >= fld_Character"; - private static String Character_filterR = "fld_Character >= value"; - private static String Character_filterObj = "value.fld_Character >= fld_Character"; - private static String Character_filterVal = "fld_Character >= 'z'"; - - private static String Double_filterL = "value >= fld_Double"; - private static String Double_filterR = "fld_Double >= value"; - private static String Double_filterObj = "value.fld_Double >= fld_Double"; - private static String Double_filterVal = "fld_Double >= 100.0"; - - private static String Float_filterL = "value >= fld_Float"; - private static String Float_filterR = "fld_Float >= value"; - private static String Float_filterObj = "fld_Float >= value.fld_Float"; - private static String Float_filterVal = "100.0f >= fld_Float"; - - private static String Integer_filterL = "value >= fld_Integer"; - private static String Integer_filterR = "fld_Integer >= value"; - private static String Integer_filterObj = "fld_Integer >= value.fld_Integer"; - private static String Integer_filterVal = "fld_Integer >= 100"; - - private static String Long_filterL = "value >= fld_Long"; - private static String Long_filterR = "fld_Long >= value"; - private static String Long_filterObj = "value.fld_Long >= fld_Long"; - private static String Long_filterVal = "-1000 >= fld_Long"; - - private static String Short_filterL = "value >= fld_Short"; - private static String Short_filterR = "fld_Short >= value"; - private static String Short_filterObj = "fld_Short >= value.fld_Short"; - private static String Short_filterVal = "-1000 >= fld_Short"; - - private static String String_filterL = "value >= fld_String"; - private static String String_filterR = "fld_String >= value"; - private static String String_filterObj = "value.fld_String >= fld_String"; - private static String String_filterVal1 = "fld_String >= \"Java\""; - private static String String_filterVal2 = "fld_String >= \"\""; - - private static String Date_filterL = "value >= fld_Date"; - private static String Date_filterR = "fld_Date >= value"; - private static String Date_filterObj = "fld_Date >= value.fld_Date"; - - private static String BigDecimal_filterL = "value >= fld_BigDecimal"; - private static String BigDecimal_filterR = "fld_BigDecimal >= value"; - private static String BigDecimal_filterObj = "value.fld_BigDecimal >= fld_BigDecimal"; - - private static String BigInteger_filterL = "value >= fld_BigInteger"; - private static String BigInteger_filterR = "fld_BigInteger >= value"; - private static String BigInteger_filterObj = "fld_BigInteger >= value.fld_BigInteger"; - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-18 (GreaterThanOrEqual) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GreaterThanOrEqual.class); - } - - /** */ - public void test() { - pm = getPM(); - tx = pm.currentTransaction(); - runQueries(); - } - - /** */ - private void runQueries() { - AllTypes alltypes = new AllTypes(); - run_byteQuery(byte_filterL, byteParameter, Byte.valueOf((byte) 0), (byte) 0, true, 4); - run_byteQuery( - byte_filterR, byteParameter, Byte.valueOf(Byte.MIN_VALUE), Byte.MIN_VALUE, false, 10); - run_byteQuery(byte_filterL, ByteParameter, Byte.valueOf((byte) 50), (byte) 50, true, 7); - run_byteQuery( - byte_filterR, ByteParameter, Byte.valueOf(Byte.MAX_VALUE), Byte.MAX_VALUE, false, 1); - run_byteQuery(byte_filterL, shortParameter, Short.valueOf((short) 75), (byte) 75, true, 8); - run_byteQuery(byte_filterR, shortParameter, Short.valueOf((short) 75), (byte) 75, false, 3); - run_byteQuery(byte_filterL, ShortParameter, Short.valueOf((short) 10), (byte) 10, true, 5); - run_byteQuery(byte_filterR, ShortParameter, Short.valueOf((short) 25), (byte) 25, false, 5); - run_byteQuery(byte_filterL, charParameter, Character.valueOf((char) 101), (byte) 101, true, 9); - run_byteQuery(byte_filterR, charParameter, Character.valueOf((char) 50), (byte) 50, false, 5); - run_byteQuery(byte_filterL, CharacterParameter, Character.valueOf((char) 0), (byte) 0, true, 4); - run_byteQuery( - byte_filterR, CharacterParameter, Character.valueOf((char) 0), (byte) 0, false, 7); - run_byteQuery(byte_filterL, intParameter, Integer.valueOf(25), (byte) 25, true, 5); - run_byteQuery(byte_filterR, intParameter, Integer.valueOf(50), (byte) 50, false, 5); - run_byteQuery(byte_filterL, IntegerParameter, Integer.valueOf(-10), (byte) -10, true, 3); - run_byteQuery(byte_filterR, IntegerParameter, Integer.valueOf(-100), (byte) -100, false, 9); - run_byteQuery(byte_filterL, longParameter, Long.valueOf(50), (byte) 50, true, 7); - run_byteQuery(byte_filterR, longParameter, Long.valueOf(60), (byte) 60, false, 3); - run_byteQuery(byte_filterL, LongParameter, Long.valueOf(-100), (byte) -100, true, 2); - run_byteQuery(byte_filterR, LongParameter, Long.valueOf(-100), (byte) -100, false, 9); - run_byteQuery(byte_filterL, floatParameter, Float.valueOf((float) 51), (byte) 51, true, 7); - run_byteQuery(byte_filterR, floatParameter, Float.valueOf((float) -20), (byte) -20, false, 8); - run_byteQuery(byte_filterL, FloatParameter, Float.valueOf((float) -99), (byte) -99, true, 2); - run_byteQuery(byte_filterR, FloatParameter, Float.valueOf((float) -100), (byte) -100, false, 9); - run_byteQuery(byte_filterL, doubleParameter, Double.valueOf(50), (byte) 50, true, 7); - run_byteQuery(byte_filterR, doubleParameter, Double.valueOf(60), (byte) 60, false, 3); - run_byteQuery( - byte_filterL, DoubleParameter, Double.valueOf(Byte.MAX_VALUE), Byte.MAX_VALUE, true, 10); - run_byteQuery(byte_filterR, DoubleParameter, Double.valueOf(25), (byte) 25, false, 5); - run_byteQuery(byte_filterL, BigIntegerParameter, new BigInteger("50"), (byte) 50, true, 7); - run_byteQuery(byte_filterR, BigIntegerParameter, new BigInteger("-100"), (byte) -100, false, 9); - run_byteQuery( - byte_filterL, BigDecimalParameter, new BigDecimal("50.000000"), (byte) 50, true, 7); - run_byteQuery( - byte_filterR, BigDecimalParameter, new BigDecimal("10.00000"), (byte) 10, false, 6); - alltypes.setbyte((byte) 50); - run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte) 50, true, 7); - alltypes.setbyte((byte) 55); - run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte) 55, true, 7); - run_byteQuery(byte_filterVal, null, null, (byte) 100, false, 2); - - run_shortQuery(short_filterL, shortParameter, Short.valueOf((short) 100), (short) 100, true, 7); - run_shortQuery( - short_filterR, shortParameter, Short.valueOf((short) 100), (short) 100, false, 5); - run_shortQuery( - short_filterL, ShortParameter, Short.valueOf(Short.MIN_VALUE), Short.MIN_VALUE, true, 1); - run_shortQuery( - short_filterR, ShortParameter, Short.valueOf((short) 253), (short) 253, false, 3); - run_shortQuery( - short_filterR, shortParameter, Short.valueOf((short) 1000), (short) 1000, false, 3); - run_shortQuery(short_filterL, byteParameter, Byte.valueOf((byte) 75), (short) 75, true, 5); - run_shortQuery(short_filterR, byteParameter, Byte.valueOf((byte) -75), (short) -75, false, 6); - run_shortQuery(short_filterL, ByteParameter, Byte.valueOf((byte) 100), (short) 100, true, 7); - run_shortQuery(short_filterR, ByteParameter, Byte.valueOf((byte) 100), (short) 100, false, 5); - run_shortQuery(short_filterL, charParameter, Character.valueOf((char) 75), (short) 75, true, 5); - run_shortQuery( - short_filterR, charParameter, Character.valueOf((char) 9999), (short) 9999, false, 2); - run_shortQuery( - short_filterL, CharacterParameter, Character.valueOf((char) 1000), (short) 1000, true, 8); - run_shortQuery( - short_filterR, - CharacterParameter, - Character.valueOf((char) 10000), - (short) 10000, - false, - 2); - run_shortQuery(short_filterL, intParameter, Integer.valueOf(-10000), (short) -10000, true, 2); - run_shortQuery(short_filterR, intParameter, Integer.valueOf(-10000), (short) -10000, false, 9); - run_shortQuery(short_filterL, IntegerParameter, Integer.valueOf(10000), (short) 10000, true, 9); - run_shortQuery( - short_filterR, IntegerParameter, Integer.valueOf(30000), (short) 30000, false, 1); - run_shortQuery(short_filterL, longParameter, Long.valueOf(10000), (short) 10000, true, 9); - run_shortQuery( - short_filterR, longParameter, Long.valueOf(Short.MAX_VALUE), Short.MAX_VALUE, false, 1); - run_shortQuery( - short_filterL, LongParameter, Long.valueOf(Short.MAX_VALUE), Short.MAX_VALUE, true, 10); - run_shortQuery(short_filterR, LongParameter, Long.valueOf(100), (short) 100, false, 5); - run_shortQuery( - short_filterL, floatParameter, Float.valueOf((float) 23000), (short) 23000, true, 9); - run_shortQuery( - short_filterR, floatParameter, Float.valueOf((float) 23000), (short) 23000, false, 1); - run_shortQuery( - short_filterL, FloatParameter, Float.valueOf((float) -1000), (short) -1000, true, 3); - run_shortQuery( - short_filterR, FloatParameter, Float.valueOf((float) 100), (short) 100, false, 5); - run_shortQuery( - short_filterL, doubleParameter, Double.valueOf(-10000.0), (short) -10000, true, 2); - run_shortQuery(short_filterR, doubleParameter, Double.valueOf(9999.0), (short) 9999, false, 2); - run_shortQuery(short_filterL, DoubleParameter, Double.valueOf(23.0), (short) 23, true, 5); - run_shortQuery(short_filterR, DoubleParameter, Double.valueOf(23.0), (short) 23, false, 5); - run_shortQuery( - short_filterL, BigIntegerParameter, new BigInteger("10000"), (short) 10000, true, 9); - run_shortQuery( - short_filterR, BigIntegerParameter, new BigInteger("30000"), (short) 30000, false, 1); - run_shortQuery(short_filterL, BigDecimalParameter, new BigDecimal("23.0"), (short) 23, true, 5); - run_shortQuery( - short_filterR, BigDecimalParameter, new BigDecimal("23.0"), (short) 23, false, 5); - alltypes.setshort((short) 100); - run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short) 100, true, 7); - alltypes.setshort((short) 23); - run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short) 23, true, 5); - run_shortQuery(short_filterVal, null, null, (short) 1000, true, 8); - - run_charQuery( - char_filterL, - charParameter, - Character.valueOf(Character.MIN_VALUE), - Character.MIN_VALUE, - true, - 1); - run_charQuery( - char_filterR, - charParameter, - Character.valueOf(Character.MAX_VALUE), - Character.MAX_VALUE, - false, - 1); - run_charQuery(char_filterL, charParameter, Character.valueOf('C'), 'C', true, 4); - run_charQuery(char_filterR, charParameter, Character.valueOf('z'), 'z', false, 3); - run_charQuery(char_filterL, CharacterParameter, Character.valueOf(' '), ' ', true, 2); - run_charQuery(char_filterR, CharacterParameter, Character.valueOf('f'), 'f', false, 3); - run_charQuery( - char_filterL, - byteParameter, - Byte.valueOf((byte) Character.MIN_VALUE), - (char) Character.MIN_VALUE, - true, - 1); - run_charQuery(char_filterR, ByteParameter, Byte.valueOf((byte) 'a'), 'a', false, 3); - run_charQuery(char_filterL, shortParameter, Short.valueOf((short) 'M'), 'M', true, 7); - run_charQuery(char_filterR, shortParameter, Short.valueOf((short) 'M'), 'M', false, 5); - run_charQuery(char_filterL, ShortParameter, Short.valueOf((short) 'A'), 'A', true, 3); - run_charQuery(char_filterR, ShortParameter, Short.valueOf((short) 'A'), 'A', false, 8); - run_charQuery(char_filterL, intParameter, Integer.valueOf('z'), 'z', true, 9); - run_charQuery(char_filterR, intParameter, Integer.valueOf('z'), 'z', false, 3); - run_charQuery(char_filterL, IntegerParameter, Integer.valueOf('B'), 'B', true, 4); - run_charQuery(char_filterR, IntegerParameter, Integer.valueOf('B'), 'B', false, 7); - run_charQuery(char_filterL, floatParameter, Float.valueOf((float) 'f'), 'f', true, 7); - run_charQuery(char_filterR, floatParameter, Float.valueOf((float) ' '), ' ', false, 9); - run_charQuery(char_filterL, FloatParameter, Float.valueOf((float) 'z'), 'z', true, 9); - run_charQuery(char_filterR, FloatParameter, Float.valueOf((float) 'z'), 'z', false, 3); - run_charQuery(char_filterL, doubleParameter, Double.valueOf('B'), 'B', true, 4); - run_charQuery(char_filterR, doubleParameter, Double.valueOf('B'), 'B', false, 7); - run_charQuery(char_filterL, DoubleParameter, Double.valueOf('A'), 'A', true, 3); - run_charQuery(char_filterR, DoubleParameter, Double.valueOf('A'), 'A', false, 8); - run_charQuery( - char_filterL, BigIntegerParameter, new BigInteger("65"), 'A', true, 3); // 'A' == 65 - run_charQuery( - char_filterR, BigIntegerParameter, new BigInteger("122"), 'z', false, 3); // 'z' == 122 - run_charQuery(char_filterL, BigDecimalParameter, new BigDecimal("65.00000"), 'A', true, 3); - run_charQuery( - char_filterR, BigDecimalParameter, new BigDecimal("77.0000"), 'M', false, 5); // 'M' == 77 - alltypes.setchar('A'); - run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'A', true, 3); - alltypes.setchar('b'); - run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'b', true, 7); - run_charQuery(char_filterVal, null, null, 'M', true, 7); - - run_intQuery( - int_filterL, - intParameter, - Integer.valueOf(AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - true, - 1); - run_intQuery( - int_filterR, - intParameter, - Integer.valueOf(AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - false, - 1); - run_intQuery(int_filterR, intParameter, Integer.valueOf(23), 23, false, 6); - run_intQuery(int_filterL, IntegerParameter, Integer.valueOf(1000000), 1000000, true, 9); - run_intQuery(int_filterR, IntegerParameter, Integer.valueOf(1000), 1000, false, 4); - run_intQuery(int_filterL, byteParameter, Byte.valueOf((byte) 100), 100, true, 6); - run_intQuery(int_filterR, byteParameter, Byte.valueOf((byte) 0), 0, false, 7); - run_intQuery(int_filterL, ByteParameter, Byte.valueOf((byte) 100), 100, true, 6); - run_intQuery(int_filterR, ByteParameter, Byte.valueOf((byte) 0), 0, false, 7); - run_intQuery(int_filterL, shortParameter, Short.valueOf((short) 10000), 10000, true, 8); - run_intQuery(int_filterR, shortParameter, Short.valueOf((short) -1000), -1000, false, 8); - run_intQuery(int_filterL, ShortParameter, Short.valueOf((short) -1000), -1000, true, 3); - run_intQuery(int_filterR, ShortParameter, Short.valueOf((short) 10000), 10000, false, 3); - run_intQuery(int_filterL, charParameter, Character.valueOf((char) 100), 100, true, 6); - run_intQuery(int_filterR, charParameter, Character.valueOf((char) 0), 0, false, 7); - run_intQuery(int_filterL, CharacterParameter, Character.valueOf((char) 100), 100, true, 6); - run_intQuery(int_filterR, CharacterParameter, Character.valueOf((char) 10000), 10000, false, 3); - run_intQuery( - int_filterL, - longParameter, - Long.valueOf(AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - true, - 10); - run_intQuery( - int_filterR, - longParameter, - Long.valueOf(AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - false, - 10); - run_intQuery(int_filterL, LongParameter, Long.valueOf(10000), 10000, true, 8); - run_intQuery(int_filterR, LongParameter, Long.valueOf(43), 43, false, 6); - run_intQuery( - int_filterL, - floatParameter, - Float.valueOf((float) AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - true, - 10); - run_intQuery( - int_filterR, - floatParameter, - Float.valueOf((float) AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - false, - 10); - run_intQuery(int_filterL, FloatParameter, Float.valueOf((float) 10000), 10000, true, 8); - run_intQuery(int_filterR, FloatParameter, Float.valueOf((float) 43), 43, false, 6); - run_intQuery( - int_filterL, - doubleParameter, - Double.valueOf(AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - true, - 10); - run_intQuery( - int_filterR, - doubleParameter, - Double.valueOf(AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - false, - 10); - run_intQuery(int_filterL, DoubleParameter, Double.valueOf(10000), 10000, true, 8); - run_intQuery(int_filterR, DoubleParameter, Double.valueOf(43), 43, false, 6); - run_intQuery(int_filterL, BigIntegerParameter, new BigInteger("1000000"), 1000000, true, 9); - run_intQuery(int_filterR, BigIntegerParameter, new BigInteger("1000"), 1000, false, 4); - run_intQuery(int_filterL, BigDecimalParameter, new BigDecimal("10000.0"), 10000, true, 8); - run_intQuery(int_filterR, BigDecimalParameter, new BigDecimal("43.0"), 43, false, 6); - alltypes.setint(100); - run_intQuery(int_filterObj, AllTypesParameter, alltypes, 100, true, 6); - run_intQuery(int_filterVal, null, null, 1000, false, 4); + *Title: Greater Than or Equal Query Operator + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-18. + *
    + *Assertion Description: +The greater than or equal operator (>=) is supported for all +types as they are defined in the Java language. This includes the following types: +
      +
    • byte, short, int, long, char, Byte, Short Integer, Long, Character
    • +
    • float, double, Float, Double
    • +
    • BigDecimal, BigInteger
    • +
    • Date, String
    • +
    +The operation on object-valued fields of wrapper types (Boolean, Byte, +Short, Integer, Long, Float, and Double), and numeric types +(BigDecimal and BigInteger) +use the wrapped values as operands. - run_longQuery( - long_filterL, longParameter, Long.valueOf(Long.MIN_VALUE), Long.MIN_VALUE, true, 1); - run_longQuery( - long_filterR, longParameter, Long.valueOf(Long.MAX_VALUE), Long.MAX_VALUE, false, 1); - run_longQuery(long_filterL, LongParameter, Long.valueOf(100), 100, true, 7); - run_longQuery(long_filterR, LongParameter, Long.valueOf(23), 23, false, 5); - run_longQuery(long_filterL, byteParameter, Byte.valueOf((byte) 100), 100, true, 7); - run_longQuery(long_filterR, byteParameter, Byte.valueOf((byte) 0), 0, false, 6); - run_longQuery(long_filterL, ByteParameter, Byte.valueOf((byte) 100), 100, true, 7); - run_longQuery(long_filterR, ByteParameter, Byte.valueOf((byte) 0), 0, false, 6); - run_longQuery(long_filterL, shortParameter, Short.valueOf((short) -1000), -1000, true, 4); - run_longQuery(long_filterR, shortParameter, Short.valueOf((short) 1000), 1000, false, 3); - run_longQuery(long_filterL, ShortParameter, Short.valueOf((short) 100), 100, true, 7); - run_longQuery(long_filterR, ShortParameter, Short.valueOf((short) 32), 32, false, 5); - run_longQuery(long_filterL, charParameter, Character.valueOf((char) 0), 0, true, 5); - run_longQuery(long_filterR, charParameter, Character.valueOf((char) 100), 100, false, 5); - run_longQuery(long_filterL, CharacterParameter, Character.valueOf((char) 23), 23, true, 5); - run_longQuery(long_filterR, CharacterParameter, Character.valueOf((char) 0), 0, false, 6); - run_longQuery(long_filterL, intParameter, Integer.valueOf(100), 100, true, 7); - run_longQuery(long_filterR, intParameter, Integer.valueOf(0), 0, false, 6); - run_longQuery(long_filterL, IntegerParameter, Integer.valueOf(23), 23, true, 5); - run_longQuery(long_filterR, IntegerParameter, Integer.valueOf(1000000), 1000000, false, 2); - run_longQuery( - long_filterL, floatParameter, Float.valueOf((float) -1000000.0), -1000000, true, 2); - run_longQuery( - long_filterR, - floatParameter, - Float.valueOf((float) Long.MAX_VALUE), - Long.MAX_VALUE, - false, - 1); - run_longQuery(long_filterL, FloatParameter, Float.valueOf((float) 100.0), 100, true, 7); - run_longQuery(long_filterR, FloatParameter, Float.valueOf((float) 32.0), 32, false, 5); - run_longQuery(long_filterL, doubleParameter, Double.valueOf(-1000000.0), -1000000, true, 2); - run_longQuery( - long_filterR, - doubleParameter, - Double.valueOf((double) Long.MAX_VALUE), - Long.MAX_VALUE, - false, - 1); - run_longQuery(long_filterL, DoubleParameter, Double.valueOf(100.0), 100, true, 7); - run_longQuery(long_filterR, DoubleParameter, Double.valueOf(32.0), 32, false, 5); - run_longQuery(long_filterL, BigIntegerParameter, new BigInteger("23"), 23, true, 5); - run_longQuery(long_filterR, BigIntegerParameter, new BigInteger("1000000"), 1000000, false, 2); - run_longQuery(long_filterL, BigDecimalParameter, new BigDecimal("100.0"), 100, true, 7); - run_longQuery(long_filterR, BigDecimalParameter, new BigDecimal("32.0"), 32, false, 5); - alltypes.setlong(100); - run_longQuery(long_filterObj, AllTypesParameter, alltypes, 100, false, 5); - run_longQuery(long_filterVal, null, null, 1000000, false, 2); - - run_floatQuery( - float_filterL, - floatParameter, - Float.valueOf((float) AllTypes.FLOAT_SMALLEST), - AllTypes.FLOAT_SMALLEST, - true, - 1); - run_floatQuery( - float_filterR, - floatParameter, - Float.valueOf((float) AllTypes.FLOAT_LARGEST), - AllTypes.FLOAT_LARGEST, - false, - 1); - run_floatQuery(float_filterL, FloatParameter, Float.valueOf((float) 4.0f), 4.0f, true, 4); - run_floatQuery(float_filterR, FloatParameter, Float.valueOf((float) 400.0f), 400.0f, false, 3); - run_floatQuery(float_filterL, byteParameter, Byte.valueOf((byte) 4), 4.0f, true, 4); - run_floatQuery(float_filterR, byteParameter, Byte.valueOf((byte) 23), 23.0f, false, 6); - run_floatQuery(float_filterL, ByteParameter, Byte.valueOf((byte) 34), 34.0f, true, 4); - run_floatQuery(float_filterR, ByteParameter, Byte.valueOf((byte) 100), 100.0f, false, 6); - run_floatQuery(float_filterL, shortParameter, Short.valueOf((short) 10), 10.0f, true, 4); - run_floatQuery(float_filterR, shortParameter, Short.valueOf((short) 23), 23.0f, false, 6); - run_floatQuery(float_filterL, ShortParameter, Short.valueOf((short) 34), 34.0f, true, 4); - run_floatQuery(float_filterR, ShortParameter, Short.valueOf((short) 100), 100.0f, false, 6); - run_floatQuery(float_filterL, charParameter, Character.valueOf((char) 20), 20.0f, true, 4); - run_floatQuery(float_filterR, charParameter, Character.valueOf((char) 23), 23.0f, false, 6); - run_floatQuery(float_filterL, CharacterParameter, Character.valueOf((char) 34), 34.0f, true, 4); - run_floatQuery( - float_filterR, CharacterParameter, Character.valueOf((char) 100), 100.0f, false, 6); - run_floatQuery(float_filterL, intParameter, Integer.valueOf(55000000), 55000000.0f, true, 8); - run_floatQuery(float_filterR, intParameter, Integer.valueOf(23), 23.0f, false, 6); - run_floatQuery(float_filterL, IntegerParameter, Integer.valueOf(34), 34.0f, true, 4); - run_floatQuery(float_filterR, IntegerParameter, Integer.valueOf(100), 100.0f, false, 6); - run_floatQuery(float_filterL, longParameter, Long.valueOf(55000000), 55000000.0f, true, 8); - run_floatQuery(float_filterR, longParameter, Long.valueOf(23), 23.0f, false, 6); - run_floatQuery(float_filterL, LongParameter, Long.valueOf(34), 34.0f, true, 4); - run_floatQuery(float_filterR, LongParameter, Long.valueOf(100), 100.0f, false, 6); - run_floatQuery( - float_filterL, doubleParameter, Double.valueOf(55000000.0), 55000000.0f, true, 8); - run_floatQuery(float_filterR, doubleParameter, Double.valueOf(-20.5), -20.5f, false, 7); - run_floatQuery(float_filterL, DoubleParameter, Double.valueOf(2.0), 2.0f, true, 4); - run_floatQuery(float_filterR, DoubleParameter, Double.valueOf(100.0), 100.0f, false, 6); - run_floatQuery( - float_filterL, BigIntegerParameter, new BigInteger("55000000"), 55000000.0f, true, 8); - run_floatQuery(float_filterR, BigIntegerParameter, new BigInteger("23"), 23.0f, false, 6); - run_floatQuery( - float_filterL, BigDecimalParameter, new BigDecimal("55000000.0"), 55000000.0f, true, 8); - run_floatQuery(float_filterR, BigDecimalParameter, new BigDecimal("-20.5"), -20.5f, false, 7); - alltypes.setfloat(23.23f); - run_floatQuery(float_filterObj, AllTypesParameter, alltypes, 23.23f, false, 6); - run_floatQuery(float_filterVal, null, null, 100.0f, false, 6); - - run_doubleQuery( - double_filterL, - doubleParameter, - Double.valueOf(AllTypes.DOUBLE_SMALLEST), - AllTypes.DOUBLE_SMALLEST, - true, - 1); - run_doubleQuery( - double_filterR, - doubleParameter, - Double.valueOf(AllTypes.DOUBLE_LARGEST), - AllTypes.DOUBLE_LARGEST, - false, - 1); - run_doubleQuery(double_filterL, DoubleParameter, Double.valueOf(0.0), 0.0, true, 4); - run_doubleQuery(double_filterR, DoubleParameter, Double.valueOf(23.34), 23.34, false, 6); - run_doubleQuery(double_filterL, byteParameter, Byte.valueOf((byte) 100), 100.0, true, 6); - run_doubleQuery(double_filterR, byteParameter, Byte.valueOf((byte) 0), 0.0, false, 7); - run_doubleQuery(double_filterL, ByteParameter, Byte.valueOf((byte) 23), 23.0, true, 4); - run_doubleQuery(double_filterR, ByteParameter, Byte.valueOf((byte) 100), 100.0, false, 6); - run_doubleQuery(double_filterL, charParameter, Character.valueOf((char) 100), 100.0, true, 6); - run_doubleQuery(double_filterR, charParameter, Character.valueOf((char) 0), 0.0, false, 7); - run_doubleQuery( - double_filterL, CharacterParameter, Character.valueOf((char) 23), 23.0, true, 4); - run_doubleQuery( - double_filterR, CharacterParameter, Character.valueOf((char) 100), 100.0, false, 6); - run_doubleQuery(double_filterL, shortParameter, Short.valueOf((short) 100), 100.0, true, 6); - run_doubleQuery(double_filterR, shortParameter, Short.valueOf((short) 0), 0.0, false, 7); - run_doubleQuery(double_filterL, ShortParameter, Short.valueOf((short) 23), 23.0, true, 4); - run_doubleQuery(double_filterR, ShortParameter, Short.valueOf((short) 100), 100.0, false, 6); - run_doubleQuery(double_filterL, intParameter, Integer.valueOf(100), 100.0, true, 6); - run_doubleQuery(double_filterR, intParameter, Integer.valueOf(0), 0.0, false, 7); - run_doubleQuery(double_filterL, IntegerParameter, Integer.valueOf(5000), 5000.0, true, 7); - run_doubleQuery(double_filterR, IntegerParameter, Integer.valueOf(-20), -20.0, false, 7); - run_doubleQuery(double_filterL, longParameter, Long.valueOf(100), 100.0, true, 6); - run_doubleQuery(double_filterR, longParameter, Long.valueOf(0), 0.0, false, 7); - run_doubleQuery(double_filterL, LongParameter, Long.valueOf(5000), 5000.0, true, 7); - run_doubleQuery(double_filterR, LongParameter, Long.valueOf(-20), -20.0, false, 7); - run_doubleQuery(double_filterL, floatParameter, Float.valueOf(0.0f), 0.0f, true, 4); - run_doubleQuery(double_filterR, floatParameter, Float.valueOf(100.0f), 100.0f, false, 6); - run_doubleQuery(double_filterL, FloatParameter, Float.valueOf(100.0f), 100.0, true, 6); - run_doubleQuery(double_filterR, FloatParameter, Float.valueOf(69.96f), 69.96, false, 6); - run_doubleQuery(double_filterL, BigIntegerParameter, new BigInteger("5000"), 5000.0, true, 7); - run_doubleQuery(double_filterR, BigIntegerParameter, new BigInteger("-20"), -20.0, false, 7); - run_doubleQuery(double_filterL, BigDecimalParameter, new BigDecimal("100.0"), 100.0, true, 6); - run_doubleQuery(double_filterR, BigDecimalParameter, new BigDecimal("69.96"), 69.96, false, 6); - alltypes.setdouble(-25.5); - run_doubleQuery(double_filterObj, AllTypesParameter, alltypes, -25.5, true, 3); - run_doubleQuery(double_filterVal, null, null, 100.0, false, 6); - - run_ByteQuery( - Byte_filterL, byteParameter, Byte.valueOf((byte) 50), Byte.valueOf((byte) 50), true, 7); - run_ByteQuery( - Byte_filterR, - byteParameter, - Byte.valueOf(Byte.MIN_VALUE), - Byte.valueOf(Byte.MIN_VALUE), - false, - 10); - run_ByteQuery( - Byte_filterL, ByteParameter, Byte.valueOf((byte) 20), Byte.valueOf((byte) 20), true, 5); - run_ByteQuery( - Byte_filterR, - ByteParameter, - Byte.valueOf(Byte.MAX_VALUE), - Byte.valueOf(Byte.MAX_VALUE), - false, - 1); - run_ByteQuery( - Byte_filterL, shortParameter, Short.valueOf((short) 60), Byte.valueOf((byte) 60), true, 7); - run_ByteQuery( - Byte_filterR, shortParameter, Short.valueOf((short) 51), Byte.valueOf((byte) 51), false, 3); - run_ByteQuery( - Byte_filterL, - ShortParameter, - Short.valueOf((short) -100), - Byte.valueOf((byte) -100), - true, - 2); - run_ByteQuery( - Byte_filterR, - ShortParameter, - Short.valueOf((short) -100), - Byte.valueOf((byte) -100), - false, - 9); - run_ByteQuery( - Byte_filterL, - charParameter, - Character.valueOf((char) 101), - Byte.valueOf((byte) 101), - true, - 9); - run_ByteQuery( - Byte_filterR, - charParameter, - Character.valueOf((char) 10), - Byte.valueOf((byte) 10), - false, - 6); - run_ByteQuery( - Byte_filterL, - CharacterParameter, - Character.valueOf((char) 50), - Byte.valueOf((byte) 50), - true, - 7); - run_ByteQuery( - Byte_filterR, - CharacterParameter, - Character.valueOf((char) 75), - Byte.valueOf((byte) 75), - false, - 3); - run_ByteQuery( - Byte_filterL, intParameter, Integer.valueOf(77), Byte.valueOf((byte) 77), true, 8); - run_ByteQuery( - Byte_filterR, intParameter, Integer.valueOf(60), Byte.valueOf((byte) 60), false, 3); - run_ByteQuery( - Byte_filterL, IntegerParameter, Integer.valueOf(40), Byte.valueOf((byte) 40), true, 5); - run_ByteQuery( - Byte_filterR, IntegerParameter, Integer.valueOf(75), Byte.valueOf((byte) 75), false, 3); - run_ByteQuery(Byte_filterL, longParameter, Long.valueOf(50), Byte.valueOf((byte) 50), true, 7); - run_ByteQuery(Byte_filterR, longParameter, Long.valueOf(50), Byte.valueOf((byte) 50), false, 5); - run_ByteQuery( - Byte_filterL, LongParameter, Long.valueOf(-100), Byte.valueOf((byte) -100), true, 2); - run_ByteQuery( - Byte_filterR, LongParameter, Long.valueOf(-100), Byte.valueOf((byte) -100), false, 9); - run_ByteQuery( - Byte_filterL, floatParameter, Float.valueOf((float) 50), Byte.valueOf((byte) 50), true, 7); - run_ByteQuery( - Byte_filterR, floatParameter, Float.valueOf((float) 50), Byte.valueOf((byte) 50), false, 5); - run_ByteQuery( - Byte_filterL, - FloatParameter, - Float.valueOf((float) -100), - Byte.valueOf((byte) -100), - true, - 2); - run_ByteQuery( - Byte_filterR, - FloatParameter, - Float.valueOf((float) -100), - Byte.valueOf((byte) -100), - false, - 9); - run_ByteQuery( - Byte_filterL, doubleParameter, Double.valueOf(50), Byte.valueOf((byte) 50), true, 7); - run_ByteQuery( - Byte_filterR, doubleParameter, Double.valueOf(50), Byte.valueOf((byte) 50), false, 5); - run_ByteQuery( - Byte_filterL, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte) -100), true, 2); - run_ByteQuery( - Byte_filterR, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte) -100), false, 9); - run_ByteQuery( - Byte_filterL, BigIntegerParameter, new BigInteger("50"), Byte.valueOf((byte) 50), true, 7); - run_ByteQuery( - Byte_filterR, - BigIntegerParameter, - new BigInteger("-100"), - Byte.valueOf((byte) -100), - false, - 9); - run_ByteQuery( - Byte_filterL, - BigDecimalParameter, - new BigDecimal("50.000000"), - Byte.valueOf((byte) 50), - true, - 7); - run_ByteQuery( - Byte_filterR, - BigDecimalParameter, - new BigDecimal("10.00000"), - Byte.valueOf((byte) 10), - false, - 6); - Byte val = Byte.valueOf((byte) 50); - alltypes.setByte(val); - run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, false, 5); - val = Byte.valueOf((byte) 51); - alltypes.setByte(val); - run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, false, 3); - run_ByteQuery(Byte_filterVal, null, null, Byte.valueOf((byte) 100), true, 9); - - run_ShortQuery( - Short_filterL, - shortParameter, - Short.valueOf((short) 100), - Short.valueOf((short) 100), - true, - 7); - run_ShortQuery( - Short_filterR, - shortParameter, - Short.valueOf((short) 100), - Short.valueOf((short) 100), - false, - 5); - run_ShortQuery( - Short_filterL, - ShortParameter, - Short.valueOf(Short.MIN_VALUE), - Short.valueOf(Short.MIN_VALUE), - true, - 1); - run_ShortQuery( - Short_filterR, - ShortParameter, - Short.valueOf((short) 253), - Short.valueOf((short) 253), - false, - 3); - run_ShortQuery( - Short_filterR, - shortParameter, - Short.valueOf((short) 1000), - Short.valueOf((short) 1000), - false, - 3); - run_ShortQuery( - Short_filterL, byteParameter, Byte.valueOf((byte) 75), Short.valueOf((short) 75), true, 5); - run_ShortQuery( - Short_filterR, byteParameter, Byte.valueOf((byte) 75), Short.valueOf((short) 75), false, 5); - run_ShortQuery( - Short_filterL, - ByteParameter, - Byte.valueOf((byte) 100), - Short.valueOf((short) 100), - true, - 7); - run_ShortQuery( - Short_filterR, - ByteParameter, - Byte.valueOf((byte) 100), - Short.valueOf((short) 100), - false, - 5); - run_ShortQuery( - Short_filterL, - charParameter, - Character.valueOf((char) 75), - Short.valueOf((short) 75), - true, - 5); - run_ShortQuery( - Short_filterR, - charParameter, - Character.valueOf((char) 75), - Short.valueOf((short) 75), - false, - 5); - run_ShortQuery( - Short_filterL, - CharacterParameter, - Character.valueOf((char) 100), - Short.valueOf((short) 100), - true, - 7); - run_ShortQuery( - Short_filterR, - CharacterParameter, - Character.valueOf((char) 200), - Short.valueOf((short) 200), - false, - 3); - run_ShortQuery( - Short_filterL, - intParameter, - Integer.valueOf(-10000), - Short.valueOf((short) -10000), - true, - 2); - run_ShortQuery( - Short_filterR, - intParameter, - Integer.valueOf(-10000), - Short.valueOf((short) -10000), - false, - 9); - run_ShortQuery( - Short_filterL, - IntegerParameter, - Integer.valueOf(10000), - Short.valueOf((short) 10000), - true, - 9); - run_ShortQuery( - Short_filterR, - IntegerParameter, - Integer.valueOf(10000), - Short.valueOf((short) 10000), - false, - 2); - run_ShortQuery( - Short_filterL, longParameter, Long.valueOf(20000), Short.valueOf((short) 20000), true, 9); - run_ShortQuery( - Short_filterR, longParameter, Long.valueOf(5000), Short.valueOf((short) 5000), false, 2); - run_ShortQuery( - Short_filterL, LongParameter, Long.valueOf(200), Short.valueOf((short) 200), true, 7); - run_ShortQuery( - Short_filterR, LongParameter, Long.valueOf(500), Short.valueOf((short) 500), false, 3); - run_ShortQuery( - Short_filterL, - floatParameter, - Float.valueOf(23000.0f), - Short.valueOf((short) 23000), - true, - 9); - run_ShortQuery( - Short_filterR, - floatParameter, - Float.valueOf(23000.0f), - Short.valueOf((short) 23000), - false, - 1); - run_ShortQuery( - Short_filterL, FloatParameter, Float.valueOf(10.0f), Short.valueOf((short) 10), true, 5); - run_ShortQuery( - Short_filterR, FloatParameter, Float.valueOf(101.0f), Short.valueOf((short) 101), false, 3); - run_ShortQuery( - Short_filterL, - doubleParameter, - Double.valueOf(-10000.0), - Short.valueOf((short) -10000), - true, - 2); - run_ShortQuery( - Short_filterR, - doubleParameter, - Double.valueOf(-10000.0), - Short.valueOf((short) -10000), - false, - 9); - run_ShortQuery( - Short_filterL, DoubleParameter, Double.valueOf(101.0), Short.valueOf((short) 101), true, 7); - run_ShortQuery( - Short_filterR, DoubleParameter, Double.valueOf(23.0), Short.valueOf((short) 23), false, 5); - run_ShortQuery( - Short_filterL, - BigIntegerParameter, - new BigInteger("10000"), - Short.valueOf((short) 10000), - true, - 9); - run_ShortQuery( - Short_filterR, - BigIntegerParameter, - new BigInteger("30000"), - Short.valueOf((short) 30000), - false, - 1); - run_ShortQuery( - Short_filterL, - BigDecimalParameter, - new BigDecimal("23.0"), - Short.valueOf((short) 23), - true, - 5); - run_ShortQuery( - Short_filterR, - BigDecimalParameter, - new BigDecimal("23.0"), - Short.valueOf((short) 23), - false, - 5); - Short sval = Short.valueOf((short) 100); - alltypes.setShort(sval); - run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, false, 5); - sval = Short.valueOf((short) 23); - alltypes.setShort(sval); - run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, false, 5); - run_ShortQuery(Short_filterVal, null, null, Short.valueOf((short) -1000), true, 3); - - run_CharacterQuery( - Character_filterL, - charParameter, - Character.valueOf(Character.MIN_VALUE), - Character.valueOf(Character.MIN_VALUE), - true, - 1); - run_CharacterQuery( - Character_filterR, - charParameter, - Character.valueOf(Character.MAX_VALUE), - Character.valueOf(Character.MAX_VALUE), - false, - 1); - run_CharacterQuery( - Character_filterL, charParameter, Character.valueOf('C'), Character.valueOf('C'), true, 4); - run_CharacterQuery( - Character_filterR, charParameter, Character.valueOf('z'), Character.valueOf('z'), false, 3); - run_CharacterQuery( - Character_filterL, - CharacterParameter, - Character.valueOf(' '), - Character.valueOf(' '), - true, - 2); - run_CharacterQuery( - Character_filterR, - CharacterParameter, - Character.valueOf('f'), - Character.valueOf('f'), - false, - 3); - run_CharacterQuery( - Character_filterL, - byteParameter, - Byte.valueOf((byte) Character.MIN_VALUE), - Character.valueOf((char) Character.MIN_VALUE), - true, - 1); - run_CharacterQuery( - Character_filterR, - ByteParameter, - Byte.valueOf((byte) 'a'), - Character.valueOf('a'), - false, - 3); - run_CharacterQuery( - Character_filterL, - shortParameter, - Short.valueOf((short) 'M'), - Character.valueOf('M'), - true, - 7); - run_CharacterQuery( - Character_filterR, - shortParameter, - Short.valueOf((short) 'F'), - Character.valueOf('F'), - false, - 6); - run_CharacterQuery( - Character_filterL, - ShortParameter, - Short.valueOf((short) 'A'), - Character.valueOf('A'), - true, - 3); - run_CharacterQuery( - Character_filterR, - ShortParameter, - Short.valueOf((short) 'A'), - Character.valueOf('A'), - false, - 8); - run_CharacterQuery( - Character_filterL, intParameter, Integer.valueOf('z'), Character.valueOf('z'), true, 9); - run_CharacterQuery( - Character_filterR, intParameter, Integer.valueOf('z'), Character.valueOf('z'), false, 3); - run_CharacterQuery( - Character_filterL, IntegerParameter, Integer.valueOf('B'), Character.valueOf('B'), true, 4); - run_CharacterQuery( - Character_filterR, - IntegerParameter, - Integer.valueOf('B'), - Character.valueOf('B'), - false, - 7); - run_CharacterQuery( - Character_filterL, longParameter, Long.valueOf('z'), Character.valueOf('z'), true, 9); - run_CharacterQuery( - Character_filterR, longParameter, Long.valueOf('z'), Character.valueOf('z'), false, 3); - run_CharacterQuery( - Character_filterL, LongParameter, Long.valueOf('B'), Character.valueOf('B'), true, 4); - run_CharacterQuery( - Character_filterR, LongParameter, Long.valueOf('B'), Character.valueOf('B'), false, 7); - run_CharacterQuery( - Character_filterL, - floatParameter, - Float.valueOf((float) 'z'), - Character.valueOf('z'), - true, - 9); - run_CharacterQuery( - Character_filterR, - floatParameter, - Float.valueOf((float) 'z'), - Character.valueOf('z'), - false, - 3); - run_CharacterQuery( - Character_filterL, - FloatParameter, - Float.valueOf((float) 'M'), - Character.valueOf('M'), - true, - 7); - run_CharacterQuery( - Character_filterR, - FloatParameter, - Float.valueOf((float) 'X'), - Character.valueOf('X'), - false, - 3); - run_CharacterQuery( - Character_filterL, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), true, 4); - run_CharacterQuery( - Character_filterR, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), false, 7); - run_CharacterQuery( - Character_filterL, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), true, 3); - run_CharacterQuery( - Character_filterR, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), false, 8); - run_CharacterQuery( - Character_filterL, - BigIntegerParameter, - new BigInteger("65"), - Character.valueOf('A'), - true, - 3); // 'A' == 65 - run_CharacterQuery( - Character_filterR, - BigIntegerParameter, - new BigInteger("122"), - Character.valueOf('z'), - false, - 3); // 'z' == 122 - run_CharacterQuery( - Character_filterL, - BigDecimalParameter, - new BigDecimal("65.00000"), - Character.valueOf('A'), - true, - 3); - run_CharacterQuery( - Character_filterR, - BigDecimalParameter, - new BigDecimal("77.0000"), - Character.valueOf('M'), - false, - 5); // 'M' == 77 - alltypes.setCharacter(Character.valueOf('A')); - run_CharacterQuery( - Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('A'), true, 3); - alltypes.setCharacter(Character.valueOf('b')); - run_CharacterQuery( - Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('b'), true, 7); - run_CharacterQuery(Character_filterVal, null, null, Character.valueOf('z'), false, 3); + */ - run_IntegerQuery( - Integer_filterL, - intParameter, - Integer.valueOf(AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - true, - 1); - run_IntegerQuery( - Integer_filterR, - intParameter, - Integer.valueOf(AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - false, - 1); - run_IntegerQuery( - Integer_filterR, intParameter, Integer.valueOf(23), Integer.valueOf(23), false, 6); - run_IntegerQuery( - Integer_filterL, - IntegerParameter, - Integer.valueOf(1000000), - Integer.valueOf(1000000), - true, - 9); - run_IntegerQuery( - Integer_filterR, IntegerParameter, Integer.valueOf(1000), Integer.valueOf(1000), false, 4); - run_IntegerQuery( - Integer_filterL, byteParameter, Byte.valueOf((byte) 100), Integer.valueOf(100), true, 6); - run_IntegerQuery( - Integer_filterR, byteParameter, Byte.valueOf((byte) 0), Integer.valueOf(0), false, 7); - run_IntegerQuery( - Integer_filterL, ByteParameter, Byte.valueOf((byte) 100), Integer.valueOf(100), true, 6); - run_IntegerQuery( - Integer_filterR, ByteParameter, Byte.valueOf((byte) 0), Integer.valueOf(0), false, 7); - run_IntegerQuery( - Integer_filterL, - shortParameter, - Short.valueOf((short) 10000), - Integer.valueOf(10000), - true, - 8); - run_IntegerQuery( - Integer_filterR, - shortParameter, - Short.valueOf((short) -1000), - Integer.valueOf(-1000), - false, - 8); - run_IntegerQuery( - Integer_filterL, - ShortParameter, - Short.valueOf((short) -1000), - Integer.valueOf(-1000), - true, - 3); - run_IntegerQuery( - Integer_filterR, - ShortParameter, - Short.valueOf((short) -999), - Integer.valueOf(-999), - false, - 7); - run_IntegerQuery( - Integer_filterL, - charParameter, - Character.valueOf((char) 10000), - Integer.valueOf(10000), - true, - 8); - run_IntegerQuery( - Integer_filterR, - charParameter, - Character.valueOf((char) 10000), - Integer.valueOf(10000), - false, - 3); - run_IntegerQuery( - Integer_filterL, - CharacterParameter, - Character.valueOf((char) 100), - Integer.valueOf(100), - true, - 6); - run_IntegerQuery( - Integer_filterR, - CharacterParameter, - Character.valueOf((char) 10000), - Integer.valueOf(10000), - false, - 3); - run_IntegerQuery( - Integer_filterL, - longParameter, - Long.valueOf(AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - true, - 10); - run_IntegerQuery( - Integer_filterR, - longParameter, - Long.valueOf(AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - false, - 10); - run_IntegerQuery( - Integer_filterL, LongParameter, Long.valueOf(10000), Integer.valueOf(10000), true, 8); - run_IntegerQuery( - Integer_filterR, LongParameter, Long.valueOf(43), Integer.valueOf(43), false, 6); - run_IntegerQuery( - Integer_filterL, - floatParameter, - Float.valueOf((float) AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - true, - 10); - run_IntegerQuery( - Integer_filterR, - floatParameter, - Float.valueOf((float) AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - false, - 10); - run_IntegerQuery( - Integer_filterL, - FloatParameter, - Float.valueOf((float) 10000), - Integer.valueOf(10000), - true, - 8); - run_IntegerQuery( - Integer_filterR, FloatParameter, Float.valueOf((float) 43), Integer.valueOf(43), false, 6); - run_IntegerQuery( - Integer_filterL, - doubleParameter, - Double.valueOf(AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - true, - 10); - run_IntegerQuery( - Integer_filterR, - doubleParameter, - Double.valueOf(AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - false, - 10); - run_IntegerQuery( - Integer_filterL, DoubleParameter, Double.valueOf(10000), Integer.valueOf(10000), true, 8); - run_IntegerQuery( - Integer_filterR, - DoubleParameter, - Double.valueOf(1000001.0), - Integer.valueOf(1000001), - false, - 1); - run_IntegerQuery( - Integer_filterL, - BigIntegerParameter, - new BigInteger("1000000"), - Integer.valueOf(1000000), - true, - 9); - run_IntegerQuery( - Integer_filterR, - BigIntegerParameter, - new BigInteger("1000"), - Integer.valueOf(1000), - false, - 4); - run_IntegerQuery( - Integer_filterL, - BigDecimalParameter, - new BigDecimal("10000.0"), - Integer.valueOf(10000), - true, - 8); - run_IntegerQuery( - Integer_filterR, - BigDecimalParameter, - new BigDecimal("43.0"), - Integer.valueOf(43), - false, - 6); - alltypes.setInteger(Integer.valueOf(100)); - run_IntegerQuery( - Integer_filterObj, AllTypesParameter, alltypes, Integer.valueOf(100), false, 6); - run_IntegerQuery(Integer_filterVal, null, null, Integer.valueOf(100), false, 6); +public class GreaterThanOrEqual extends ComparisonTests { + private static String boolean_filterL = "value >= fld_boolean"; + private static String boolean_filterR = "fld_boolean >= value"; + private static String boolean_filterT = "fld_boolean >= true"; + private static String boolean_filterF = "false >= fld_boolean"; + private static String boolean_filterObj = "value.fld_boolean >= fld_boolean"; + + private static String byte_filterL = "value >= fld_byte"; + private static String byte_filterR = "fld_byte >= value"; + private static String byte_filterObj = "value.fld_byte >= fld_byte"; + private static String byte_filterVal = "fld_byte >= 100"; + + private static String char_filterL = "value >= fld_char"; + private static String char_filterR = "fld_char >= value"; + private static String char_filterObj = "value.fld_char >= fld_char"; + private static String char_filterVal = "'M' >= fld_char"; + + private static String double_filterL = "value >= fld_double"; + private static String double_filterR = "fld_double >= value"; + private static String double_filterObj = "value.fld_double >= fld_double"; + private static String double_filterVal = "fld_double >= 100.0"; + + private static String float_filterL = "value >= fld_float"; + private static String float_filterR = "fld_float >= value"; + private static String float_filterObj = "fld_float >= value.fld_float"; + private static String float_filterVal = "fld_float >= 100.0"; + + private static String int_filterL = "value >= fld_int"; + private static String int_filterR = "fld_int >= value"; + private static String int_filterObj = "value.fld_int >= fld_int"; + private static String int_filterVal = "fld_int >= 1000"; + + private static String long_filterL = "value >= fld_long"; + private static String long_filterR = "fld_long >= value"; + private static String long_filterObj = "fld_long >= value.fld_long"; + private static String long_filterVal = "fld_long >= 1000000"; + + private static String short_filterL = "value >= fld_short"; + private static String short_filterR = "fld_short >= value"; + private static String short_filterObj = "value.fld_short >= fld_short"; + private static String short_filterVal = "1000 >= fld_short"; + + private static String Boolean_filterL = "value >= fld_Boolean"; + private static String Boolean_filterR = "fld_Boolean >= value"; + private static String Boolean_filterT = "fld_Boolean >= true"; + private static String Boolean_filterF = "false >= fld_Boolean"; + private static String Boolean_filterObj = "value.fld_Boolean >= fld_Boolean"; + private static String Boolean_filterVal = "fld_Boolean >= false"; + + private static String Byte_filterL = "value >= fld_Byte"; + private static String Byte_filterR = "fld_Byte >= value"; + private static String Byte_filterObj = "fld_Byte >= value.fld_Byte"; + private static String Byte_filterVal = "100 >= fld_Byte"; + + private static String Character_filterL = "value >= fld_Character"; + private static String Character_filterR = "fld_Character >= value"; + private static String Character_filterObj = "value.fld_Character >= fld_Character"; + private static String Character_filterVal = "fld_Character >= 'z'"; + + private static String Double_filterL = "value >= fld_Double"; + private static String Double_filterR = "fld_Double >= value"; + private static String Double_filterObj = "value.fld_Double >= fld_Double"; + private static String Double_filterVal = "fld_Double >= 100.0"; + + private static String Float_filterL = "value >= fld_Float"; + private static String Float_filterR = "fld_Float >= value"; + private static String Float_filterObj = "fld_Float >= value.fld_Float"; + private static String Float_filterVal = "100.0f >= fld_Float"; + + private static String Integer_filterL = "value >= fld_Integer"; + private static String Integer_filterR = "fld_Integer >= value"; + private static String Integer_filterObj = "fld_Integer >= value.fld_Integer"; + private static String Integer_filterVal = "fld_Integer >= 100"; + + private static String Long_filterL = "value >= fld_Long"; + private static String Long_filterR = "fld_Long >= value"; + private static String Long_filterObj = "value.fld_Long >= fld_Long"; + private static String Long_filterVal = "-1000 >= fld_Long"; + + private static String Short_filterL = "value >= fld_Short"; + private static String Short_filterR = "fld_Short >= value"; + private static String Short_filterObj = "fld_Short >= value.fld_Short"; + private static String Short_filterVal = "-1000 >= fld_Short"; + + private static String String_filterL = "value >= fld_String"; + private static String String_filterR = "fld_String >= value"; + private static String String_filterObj = "value.fld_String >= fld_String"; + private static String String_filterVal1 = "fld_String >= \"Java\""; + private static String String_filterVal2 = "fld_String >= \"\""; + + private static String Date_filterL = "value >= fld_Date"; + private static String Date_filterR = "fld_Date >= value"; + private static String Date_filterObj = "fld_Date >= value.fld_Date"; + + private static String BigDecimal_filterL = "value >= fld_BigDecimal"; + private static String BigDecimal_filterR = "fld_BigDecimal >= value"; + private static String BigDecimal_filterObj = "value.fld_BigDecimal >= fld_BigDecimal"; + + private static String BigInteger_filterL = "value >= fld_BigInteger"; + private static String BigInteger_filterR = "fld_BigInteger >= value"; + private static String BigInteger_filterObj = "fld_BigInteger >= value.fld_BigInteger"; - run_LongQuery( - Long_filterL, - longParameter, - Long.valueOf(Long.MIN_VALUE), - Long.valueOf(Long.MIN_VALUE), - true, - 1); - run_LongQuery( - Long_filterR, - longParameter, - Long.valueOf(Long.MAX_VALUE), - Long.valueOf(Long.MAX_VALUE), - false, - 1); - run_LongQuery(Long_filterL, LongParameter, Long.valueOf(100), Long.valueOf(100), true, 7); - run_LongQuery(Long_filterR, LongParameter, Long.valueOf(23), Long.valueOf(23), false, 5); - run_LongQuery( - Long_filterL, byteParameter, Byte.valueOf((byte) 100), Long.valueOf(100), true, 7); - run_LongQuery(Long_filterR, byteParameter, Byte.valueOf((byte) 0), Long.valueOf(0), false, 6); - run_LongQuery( - Long_filterL, ByteParameter, Byte.valueOf((byte) 100), Long.valueOf(100), true, 7); - run_LongQuery(Long_filterR, ByteParameter, Byte.valueOf((byte) 0), Long.valueOf(0), false, 6); - run_LongQuery( - Long_filterL, shortParameter, Short.valueOf((short) -1000), Long.valueOf(-1000), true, 4); - run_LongQuery( - Long_filterR, shortParameter, Short.valueOf((short) 1000), Long.valueOf(1000), false, 3); - run_LongQuery( - Long_filterL, ShortParameter, Short.valueOf((short) 101), Long.valueOf(101), true, 7); - run_LongQuery( - Long_filterR, ShortParameter, Short.valueOf((short) 32), Long.valueOf(32), false, 5); - run_LongQuery( - Long_filterL, charParameter, Character.valueOf((char) 0), Long.valueOf(0), true, 5); - run_LongQuery( - Long_filterR, charParameter, Character.valueOf((char) 100), Long.valueOf(100), false, 5); - run_LongQuery( - Long_filterL, CharacterParameter, Character.valueOf((char) 23), Long.valueOf(23), true, 5); - run_LongQuery( - Long_filterR, - CharacterParameter, - Character.valueOf((char) 1110), - Long.valueOf(1110), - false, - 2); - run_LongQuery(Long_filterL, intParameter, Integer.valueOf(100), Long.valueOf(100), true, 7); - run_LongQuery(Long_filterR, intParameter, Integer.valueOf(0), Long.valueOf(0), false, 6); - run_LongQuery(Long_filterL, IntegerParameter, Integer.valueOf(23), Long.valueOf(23), true, 5); - run_LongQuery( - Long_filterR, IntegerParameter, Integer.valueOf(1000000), Long.valueOf(1000000), false, 2); - run_LongQuery( - Long_filterL, - floatParameter, - Float.valueOf((float) -1000000.0), - Long.valueOf(-1000000), - true, - 2); - run_LongQuery( - Long_filterR, - floatParameter, - Float.valueOf((float) Long.MAX_VALUE), - Long.valueOf(Long.MAX_VALUE), - false, - 1); - run_LongQuery(Long_filterL, FloatParameter, Float.valueOf(100.0f), Long.valueOf(100), true, 7); - run_LongQuery(Long_filterR, FloatParameter, Float.valueOf(32.0f), Long.valueOf(32), false, 5); - run_LongQuery( - Long_filterL, doubleParameter, Double.valueOf(-1000000.0), Long.valueOf(-1000000), true, 2); - run_LongQuery( - Long_filterR, - doubleParameter, - Double.valueOf((double) Long.MAX_VALUE), - Long.valueOf(Long.MAX_VALUE), - false, - 1); - run_LongQuery(Long_filterL, DoubleParameter, Double.valueOf(100.0), Long.valueOf(100), true, 7); - run_LongQuery(Long_filterR, DoubleParameter, Double.valueOf(32.0), Long.valueOf(32), false, 5); - run_LongQuery( - Long_filterL, BigIntegerParameter, new BigInteger("23"), Long.valueOf(23), true, 5); - run_LongQuery( - Long_filterR, - BigIntegerParameter, - new BigInteger("1000000"), - Long.valueOf(1000000), - false, - 2); - run_LongQuery( - Long_filterL, BigDecimalParameter, new BigDecimal("100.0"), Long.valueOf(100), true, 7); - run_LongQuery( - Long_filterR, BigDecimalParameter, new BigDecimal("32.0"), Long.valueOf(32), false, 5); - alltypes.setLong(Long.valueOf(100)); - run_LongQuery(Long_filterObj, AllTypesParameter, alltypes, Long.valueOf(100), true, 7); - run_LongQuery(Long_filterVal, null, null, Long.valueOf(-1000), true, 4); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-18 (GreaterThanOrEqual) failed: "; - run_FloatQuery( - Float_filterL, - floatParameter, - Float.valueOf(-10000000000.0f), - Float.valueOf(-10000000000.0f), - true, - 1); - run_FloatQuery( - Float_filterR, - floatParameter, - Float.valueOf(9000000000.0f), - Float.valueOf(9000000000.0f), - false, - 1); - run_FloatQuery( - Float_filterL, FloatParameter, Float.valueOf((float) 0.0), Float.valueOf(0.0f), true, 3); - run_FloatQuery( - Float_filterR, FloatParameter, Float.valueOf((float) 4.0), Float.valueOf(4.0f), false, 7); - run_FloatQuery( - Float_filterL, byteParameter, Byte.valueOf((byte) 0), Float.valueOf(0.0f), true, 3); - run_FloatQuery( - Float_filterR, byteParameter, Byte.valueOf((byte) 23), Float.valueOf(23.0f), false, 7); - run_FloatQuery( - Float_filterL, ByteParameter, Byte.valueOf((byte) 34), Float.valueOf(34.0f), true, 3); - run_FloatQuery( - Float_filterR, ByteParameter, Byte.valueOf((byte) 100), Float.valueOf(100.0f), false, 7); - run_FloatQuery( - Float_filterL, shortParameter, Short.valueOf((short) 0), Float.valueOf(0.0f), true, 3); - run_FloatQuery( - Float_filterR, shortParameter, Short.valueOf((short) 23), Float.valueOf(23.0f), false, 7); - run_FloatQuery( - Float_filterL, ShortParameter, Short.valueOf((short) 34), Float.valueOf(34.0f), true, 3); - run_FloatQuery( - Float_filterR, ShortParameter, Short.valueOf((short) 100), Float.valueOf(100.0f), false, 7); - run_FloatQuery( - Float_filterL, charParameter, Character.valueOf((char) 0), Float.valueOf(0.0f), true, 3); - run_FloatQuery( - Float_filterR, charParameter, Character.valueOf((char) 23), Float.valueOf(23.0f), false, 7); - run_FloatQuery( - Float_filterL, - CharacterParameter, - Character.valueOf((char) 34), - Float.valueOf(34.0f), - true, - 3); - run_FloatQuery( - Float_filterR, - CharacterParameter, - Character.valueOf((char) 100), - Float.valueOf(100.0f), - false, - 7); - run_FloatQuery( - Float_filterL, - intParameter, - Integer.valueOf(50000000), - Float.valueOf(50000000.0f), - true, - 8); - run_FloatQuery( - Float_filterR, intParameter, Integer.valueOf(23), Float.valueOf(23.0f), false, 7); - run_FloatQuery( - Float_filterL, IntegerParameter, Integer.valueOf(34), Float.valueOf(34.0f), true, 3); - run_FloatQuery( - Float_filterR, IntegerParameter, Integer.valueOf(100), Float.valueOf(100.0f), false, 7); - run_FloatQuery( - Float_filterL, longParameter, Long.valueOf(50000000), Float.valueOf(50000000.0f), true, 8); - run_FloatQuery(Float_filterR, longParameter, Long.valueOf(23), Float.valueOf(23.0f), false, 7); - run_FloatQuery(Float_filterL, LongParameter, Long.valueOf(34), Float.valueOf(34.0f), true, 3); - run_FloatQuery( - Float_filterR, LongParameter, Long.valueOf(100), Float.valueOf(100.0f), false, 7); - run_FloatQuery( - Float_filterL, - doubleParameter, - Double.valueOf(50000000.0f), - Float.valueOf(50000000.0f), - true, - 8); - run_FloatQuery( - Float_filterR, doubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), false, 7); - run_FloatQuery( - Float_filterL, DoubleParameter, Double.valueOf(0.0f), Float.valueOf(0.0f), true, 3); - run_FloatQuery( - Float_filterR, DoubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), false, 7); - run_FloatQuery( - Float_filterL, - BigIntegerParameter, - new BigInteger("55000000"), - Float.valueOf(55000000.0f), - true, - 8); - run_FloatQuery( - Float_filterR, BigIntegerParameter, new BigInteger("23"), Float.valueOf(23.0f), false, 7); - run_FloatQuery( - Float_filterL, - BigDecimalParameter, - new BigDecimal("55000000.0"), - Float.valueOf(55000000.0f), - true, - 8); - run_FloatQuery( - Float_filterR, - BigDecimalParameter, - new BigDecimal("-20.5"), - Float.valueOf(-20.5f), - false, - 8); - alltypes.setFloat(Float.valueOf(23.23f)); - run_FloatQuery(Float_filterObj, AllTypesParameter, alltypes, Float.valueOf(23.23f), false, 7); - run_FloatQuery(Float_filterVal, null, null, Float.valueOf(100.0f), true, 5); + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GreaterThanOrEqual.class); + } - run_DoubleQuery( - Double_filterL, - doubleParameter, - Double.valueOf(-999999999999.0), - Double.valueOf(-999999999999.0), - true, - 1); - run_DoubleQuery( - Double_filterR, - doubleParameter, - Double.valueOf(9999999999999.0), - Double.valueOf(9999999999999.0), - false, - 1); - run_DoubleQuery( - Double_filterL, DoubleParameter, Double.valueOf(0.0), Double.valueOf(0.0), true, 4); - run_DoubleQuery( - Double_filterR, DoubleParameter, Double.valueOf(23.34), Double.valueOf(23.34), false, 6); - run_DoubleQuery( - Double_filterL, byteParameter, Byte.valueOf((byte) 100), Double.valueOf(100.0), true, 6); - run_DoubleQuery( - Double_filterR, byteParameter, Byte.valueOf((byte) 0), Double.valueOf(0.0), false, 7); - run_DoubleQuery( - Double_filterL, ByteParameter, Byte.valueOf((byte) -23), Double.valueOf(-23.0), true, 3); - run_DoubleQuery( - Double_filterR, ByteParameter, Byte.valueOf((byte) 100), Double.valueOf(100.0), false, 6); - run_DoubleQuery( - Double_filterL, shortParameter, Short.valueOf((short) 100), Double.valueOf(100.0), true, 6); - run_DoubleQuery( - Double_filterR, shortParameter, Short.valueOf((short) 0), Double.valueOf(0.0), false, 7); - run_DoubleQuery( - Double_filterL, ShortParameter, Short.valueOf((short) 23), Double.valueOf(23.0), true, 4); - run_DoubleQuery( - Double_filterR, - ShortParameter, - Short.valueOf((short) 400), - Double.valueOf(400.0), - false, - 3); - run_DoubleQuery( - Double_filterL, - charParameter, - Character.valueOf((char) 100), - Double.valueOf(100.0), - true, - 6); - run_DoubleQuery( - Double_filterR, charParameter, Character.valueOf((char) 0), Double.valueOf(0.0), false, 7); - run_DoubleQuery( - Double_filterL, - CharacterParameter, - Character.valueOf((char) 23), - Double.valueOf(23.0), - true, - 4); - run_DoubleQuery( - Double_filterR, - CharacterParameter, - Character.valueOf((char) 400), - Double.valueOf(400.0), - false, - 3); - run_DoubleQuery( - Double_filterL, intParameter, Integer.valueOf(100), Double.valueOf(100.0), true, 6); - run_DoubleQuery( - Double_filterR, intParameter, Integer.valueOf(0), Double.valueOf(0.0), false, 7); - run_DoubleQuery( - Double_filterL, IntegerParameter, Integer.valueOf(23), Double.valueOf(23.0), true, 4); - run_DoubleQuery( - Double_filterR, IntegerParameter, Integer.valueOf(100), Double.valueOf(100.0), false, 6); - run_DoubleQuery( - Double_filterL, longParameter, Long.valueOf(100), Double.valueOf(100.0), true, 6); - run_DoubleQuery(Double_filterR, longParameter, Long.valueOf(0), Double.valueOf(0.0), false, 7); - run_DoubleQuery(Double_filterL, LongParameter, Long.valueOf(23), Double.valueOf(23.0), true, 4); - run_DoubleQuery( - Double_filterR, LongParameter, Long.valueOf(100), Double.valueOf(100.0), false, 6); - run_DoubleQuery( - Double_filterL, floatParameter, Float.valueOf(0.0f), Double.valueOf(0.0f), true, 4); - run_DoubleQuery( - Double_filterR, floatParameter, Float.valueOf(100.0f), Double.valueOf(100.0f), false, 6); - run_DoubleQuery( - Double_filterL, FloatParameter, Float.valueOf(100.0f), Double.valueOf(100.0f), true, 6); - run_DoubleQuery( - Double_filterR, FloatParameter, Float.valueOf(69.96f), Double.valueOf(69.96), false, 6); - run_DoubleQuery( - Double_filterL, - BigIntegerParameter, - new BigInteger("5000"), - Double.valueOf(5000.0), - true, - 7); - run_DoubleQuery( - Double_filterR, - BigIntegerParameter, - new BigInteger("-20"), - Double.valueOf(-20.0), - false, - 7); - run_DoubleQuery( - Double_filterL, - BigDecimalParameter, - new BigDecimal("100.0"), - Double.valueOf(100.0), - true, - 6); - run_DoubleQuery( - Double_filterR, - BigDecimalParameter, - new BigDecimal("69.96"), - Double.valueOf(69.96), - false, - 6); - alltypes.setDouble(Double.valueOf(-999999999999.0)); - run_DoubleQuery( - Double_filterObj, AllTypesParameter, alltypes, Double.valueOf(-999999999999.0), true, 1); - run_DoubleQuery(Double_filterVal, null, null, Double.valueOf(100.0), false, 6); + /** */ + public void test() { + pm = getPM(); + tx = pm.currentTransaction(); + runQueries(); + } - run_StringQuery(String_filterL, StringParameter, new String("JDO"), new String("JDO"), true, 2); - run_StringQuery( - String_filterR, StringParameter, new String("JDBC"), new String("JDBC"), false, 9); - alltypes.setString(new String("abcde")); - run_StringQuery(String_filterObj, AllTypesParameter, alltypes, new String("abcde"), true, 8); - run_StringQuery(String_filterVal1, null, null, new String("Java"), false, 6); - run_StringQuery(String_filterVal2, null, null, new String(""), false, 10); + /** */ + private void runQueries() + { + AllTypes alltypes = new AllTypes(); + run_byteQuery(byte_filterL, byteParameter, Byte.valueOf((byte)0), (byte)0, true, 4); + run_byteQuery(byte_filterR, byteParameter, Byte.valueOf(Byte.MIN_VALUE), Byte.MIN_VALUE, false, 10); + run_byteQuery(byte_filterL, ByteParameter, Byte.valueOf((byte)50), (byte)50, true, 7); + run_byteQuery(byte_filterR, ByteParameter, Byte.valueOf(Byte.MAX_VALUE), Byte.MAX_VALUE, false, 1); + run_byteQuery(byte_filterL, shortParameter, Short.valueOf((short)75), (byte)75, true, 8); + run_byteQuery(byte_filterR, shortParameter, Short.valueOf((short)75), (byte)75, false, 3); + run_byteQuery(byte_filterL, ShortParameter, Short.valueOf((short)10), (byte)10, true, 5); + run_byteQuery(byte_filterR, ShortParameter, Short.valueOf((short)25), (byte)25, false, 5); + run_byteQuery(byte_filterL, charParameter, Character.valueOf((char)101), (byte)101, true, 9); + run_byteQuery(byte_filterR, charParameter, Character.valueOf((char)50), (byte)50, false, 5); + run_byteQuery(byte_filterL, CharacterParameter, Character.valueOf((char)0), (byte)0, true, 4); + run_byteQuery(byte_filterR, CharacterParameter, Character.valueOf((char)0), (byte)0, false, 7); + run_byteQuery(byte_filterL, intParameter, Integer.valueOf(25), (byte)25, true, 5); + run_byteQuery(byte_filterR, intParameter, Integer.valueOf(50), (byte)50, false, 5); + run_byteQuery(byte_filterL, IntegerParameter, Integer.valueOf(-10), (byte)-10, true, 3); + run_byteQuery(byte_filterR, IntegerParameter, Integer.valueOf(-100), (byte)-100, false, 9); + run_byteQuery(byte_filterL, longParameter, Long.valueOf(50), (byte)50, true, 7); + run_byteQuery(byte_filterR, longParameter, Long.valueOf(60), (byte)60, false, 3); + run_byteQuery(byte_filterL, LongParameter, Long.valueOf(-100), (byte)-100, true, 2); + run_byteQuery(byte_filterR, LongParameter, Long.valueOf(-100), (byte)-100, false, 9); + run_byteQuery(byte_filterL, floatParameter, Float.valueOf((float)51), (byte)51, true, 7); + run_byteQuery(byte_filterR, floatParameter, Float.valueOf((float)-20), (byte)-20, false, 8); + run_byteQuery(byte_filterL, FloatParameter, Float.valueOf((float)-99), (byte)-99, true, 2); + run_byteQuery(byte_filterR, FloatParameter, Float.valueOf((float)-100), (byte)-100, false, 9); + run_byteQuery(byte_filterL, doubleParameter, Double.valueOf(50), (byte)50, true, 7); + run_byteQuery(byte_filterR, doubleParameter, Double.valueOf(60), (byte)60, false, 3); + run_byteQuery(byte_filterL, DoubleParameter, Double.valueOf(Byte.MAX_VALUE), Byte.MAX_VALUE, true, 10); + run_byteQuery(byte_filterR, DoubleParameter, Double.valueOf(25), (byte)25, false, 5); + run_byteQuery(byte_filterL, BigIntegerParameter, new BigInteger("50"), (byte)50, true, 7); + run_byteQuery(byte_filterR, BigIntegerParameter, new BigInteger("-100"), (byte)-100, false, 9); + run_byteQuery(byte_filterL, BigDecimalParameter, new BigDecimal("50.000000"), (byte)50, true, 7); + run_byteQuery(byte_filterR, BigDecimalParameter, new BigDecimal("10.00000"), (byte)10, false, 6); + alltypes.setbyte((byte)50); + run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte)50, true, 7); + alltypes.setbyte((byte)55); + run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte)55, true, 7); + run_byteQuery(byte_filterVal, null, null, (byte)100, false, 2); - BigDecimal bd = new BigDecimal("100.0"); - run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, true, 6); - bd = new BigDecimal("-234234.23333"); - run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, false, 9); - bd = new BigDecimal("989899.33304953"); - run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, true, 7); - bd = new BigDecimal("-1123123.22"); - run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, false, 10); - alltypes.setBigDecimal(bd); - run_BigDecimalQuery(BigDecimal_filterObj, AllTypesParameter, alltypes, bd, true, 1); + run_shortQuery(short_filterL, shortParameter, Short.valueOf((short)100), (short)100, true, 7); + run_shortQuery(short_filterR, shortParameter, Short.valueOf((short)100), (short)100, false, 5); + run_shortQuery(short_filterL, ShortParameter, Short.valueOf(Short.MIN_VALUE), Short.MIN_VALUE, true, 1); + run_shortQuery(short_filterR, ShortParameter, Short.valueOf((short)253), (short)253, false, 3); + run_shortQuery(short_filterR, shortParameter, Short.valueOf((short)1000), (short)1000, false, 3); + run_shortQuery(short_filterL, byteParameter, Byte.valueOf((byte)75), (short)75, true, 5); + run_shortQuery(short_filterR, byteParameter, Byte.valueOf((byte)-75), (short)-75, false, 6); + run_shortQuery(short_filterL, ByteParameter, Byte.valueOf((byte)100), (short)100, true, 7); + run_shortQuery(short_filterR, ByteParameter, Byte.valueOf((byte)100), (short)100, false, 5); + run_shortQuery(short_filterL, charParameter, Character.valueOf((char)75), (short)75, true, 5); + run_shortQuery(short_filterR, charParameter, Character.valueOf((char)9999), (short)9999, false, 2); + run_shortQuery(short_filterL, CharacterParameter, Character.valueOf((char)1000), (short)1000, true, 8); + run_shortQuery(short_filterR, CharacterParameter, Character.valueOf((char)10000), (short)10000, false, 2); + run_shortQuery(short_filterL, intParameter, Integer.valueOf(-10000), (short)-10000, true, 2); + run_shortQuery(short_filterR, intParameter, Integer.valueOf(-10000), (short)-10000, false, 9); + run_shortQuery(short_filterL, IntegerParameter, Integer.valueOf(10000), (short)10000, true, 9); + run_shortQuery(short_filterR, IntegerParameter, Integer.valueOf(30000), (short)30000, false, 1); + run_shortQuery(short_filterL, longParameter, Long.valueOf(10000), (short) 10000, true, 9); + run_shortQuery(short_filterR, longParameter, Long.valueOf(Short.MAX_VALUE), Short.MAX_VALUE, false, 1); + run_shortQuery(short_filterL, LongParameter, Long.valueOf(Short.MAX_VALUE), Short.MAX_VALUE, true, 10); + run_shortQuery(short_filterR, LongParameter, Long.valueOf(100), (short)100, false, 5); + run_shortQuery(short_filterL, floatParameter, Float.valueOf((float)23000), (short)23000, true, 9); + run_shortQuery(short_filterR, floatParameter, Float.valueOf((float)23000), (short)23000, false, 1); + run_shortQuery(short_filterL, FloatParameter, Float.valueOf((float)-1000), (short)-1000, true, 3); + run_shortQuery(short_filterR, FloatParameter, Float.valueOf((float)100), (short)100, false, 5); + run_shortQuery(short_filterL, doubleParameter, Double.valueOf(-10000.0), (short)-10000, true, 2); + run_shortQuery(short_filterR, doubleParameter, Double.valueOf(9999.0), (short)9999, false, 2); + run_shortQuery(short_filterL, DoubleParameter, Double.valueOf(23.0), (short)23, true, 5); + run_shortQuery(short_filterR, DoubleParameter, Double.valueOf(23.0), (short)23, false, 5); + run_shortQuery(short_filterL, BigIntegerParameter, new BigInteger("10000"), (short)10000, true, 9); + run_shortQuery(short_filterR, BigIntegerParameter, new BigInteger("30000"), (short)30000, false, 1); + run_shortQuery(short_filterL, BigDecimalParameter, new BigDecimal("23.0"), (short)23, true, 5); + run_shortQuery(short_filterR, BigDecimalParameter, new BigDecimal("23.0"), (short)23, false, 5); + alltypes.setshort((short)100); + run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short)100, true, 7); + alltypes.setshort((short)23); + run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short)23, true, 5); + run_shortQuery(short_filterVal, null, null, (short)1000, true, 8); + + run_charQuery(char_filterL, charParameter, Character.valueOf(Character.MIN_VALUE), Character.MIN_VALUE, true, 1); + run_charQuery(char_filterR, charParameter, Character.valueOf(Character.MAX_VALUE), Character.MAX_VALUE, false, 1); + run_charQuery(char_filterL, charParameter, Character.valueOf('C'), 'C', true, 4); + run_charQuery(char_filterR, charParameter, Character.valueOf('z'), 'z', false, 3); + run_charQuery(char_filterL, CharacterParameter, Character.valueOf(' '), ' ', true, 2); + run_charQuery(char_filterR, CharacterParameter, Character.valueOf('f'), 'f', false, 3); + run_charQuery(char_filterL, byteParameter, Byte.valueOf((byte)Character.MIN_VALUE), (char)Character.MIN_VALUE, true, 1); + run_charQuery(char_filterR, ByteParameter, Byte.valueOf((byte)'a'), 'a', false, 3); + run_charQuery(char_filterL, shortParameter, Short.valueOf((short)'M'), 'M', true, 7); + run_charQuery(char_filterR, shortParameter, Short.valueOf((short)'M'), 'M', false, 5); + run_charQuery(char_filterL, ShortParameter, Short.valueOf((short)'A'), 'A', true, 3); + run_charQuery(char_filterR, ShortParameter, Short.valueOf((short)'A'), 'A', false, 8); + run_charQuery(char_filterL, intParameter, Integer.valueOf('z'), 'z', true, 9); + run_charQuery(char_filterR, intParameter, Integer.valueOf('z'), 'z', false, 3); + run_charQuery(char_filterL, IntegerParameter, Integer.valueOf('B'), 'B', true, 4); + run_charQuery(char_filterR, IntegerParameter, Integer.valueOf('B'), 'B', false, 7); + run_charQuery(char_filterL, floatParameter, Float.valueOf((float)'f'), 'f', true, 7); + run_charQuery(char_filterR, floatParameter, Float.valueOf((float)' '), ' ', false, 9); + run_charQuery(char_filterL, FloatParameter, Float.valueOf((float)'z'), 'z', true, 9); + run_charQuery(char_filterR, FloatParameter, Float.valueOf((float)'z'), 'z', false, 3); + run_charQuery(char_filterL, doubleParameter, Double.valueOf('B'), 'B', true, 4); + run_charQuery(char_filterR, doubleParameter, Double.valueOf('B'), 'B', false, 7); + run_charQuery(char_filterL, DoubleParameter, Double.valueOf('A'), 'A', true, 3); + run_charQuery(char_filterR, DoubleParameter, Double.valueOf('A'), 'A', false, 8); + run_charQuery(char_filterL, BigIntegerParameter, new BigInteger("65"), 'A', true, 3); // 'A' == 65 + run_charQuery(char_filterR, BigIntegerParameter, new BigInteger("122"), 'z', false, 3); // 'z' == 122 + run_charQuery(char_filterL, BigDecimalParameter, new BigDecimal("65.00000"), 'A', true, 3); + run_charQuery(char_filterR, BigDecimalParameter, new BigDecimal("77.0000"), 'M', false, 5); // 'M' == 77 + alltypes.setchar('A'); + run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'A', true, 3); + alltypes.setchar('b'); + run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'b', true, 7); + run_charQuery(char_filterVal, null, null, 'M', true, 7); + + run_intQuery(int_filterL, intParameter, Integer.valueOf(AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, true, 1); + run_intQuery(int_filterR, intParameter, Integer.valueOf(AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, false, 1); + run_intQuery(int_filterR, intParameter, Integer.valueOf(23), 23, false, 6); + run_intQuery(int_filterL, IntegerParameter, Integer.valueOf(1000000), 1000000, true, 9); + run_intQuery(int_filterR, IntegerParameter, Integer.valueOf(1000), 1000, false, 4); + run_intQuery(int_filterL, byteParameter, Byte.valueOf((byte)100), 100, true, 6); + run_intQuery(int_filterR, byteParameter, Byte.valueOf((byte)0), 0, false, 7); + run_intQuery(int_filterL, ByteParameter, Byte.valueOf((byte)100), 100, true, 6); + run_intQuery(int_filterR, ByteParameter, Byte.valueOf((byte)0), 0, false, 7); + run_intQuery(int_filterL, shortParameter, Short.valueOf((short)10000), 10000, true, 8); + run_intQuery(int_filterR, shortParameter, Short.valueOf((short)-1000), -1000, false, 8); + run_intQuery(int_filterL, ShortParameter, Short.valueOf((short)-1000), -1000, true, 3); + run_intQuery(int_filterR, ShortParameter, Short.valueOf((short)10000), 10000, false, 3); + run_intQuery(int_filterL, charParameter, Character.valueOf((char)100), 100, true, 6); + run_intQuery(int_filterR, charParameter, Character.valueOf((char)0), 0, false, 7); + run_intQuery(int_filterL, CharacterParameter, Character.valueOf((char)100), 100, true, 6); + run_intQuery(int_filterR, CharacterParameter, Character.valueOf((char)10000), 10000, false, 3); + run_intQuery(int_filterL, longParameter, Long.valueOf(AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, true, 10); + run_intQuery(int_filterR, longParameter, Long.valueOf(AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, false, 10); + run_intQuery(int_filterL, LongParameter, Long.valueOf(10000), 10000, true, 8); + run_intQuery(int_filterR, LongParameter, Long.valueOf(43), 43, false, 6); + run_intQuery(int_filterL, floatParameter, Float.valueOf((float)AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, true, 10); + run_intQuery(int_filterR, floatParameter, Float.valueOf((float)AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, false, 10); + run_intQuery(int_filterL, FloatParameter, Float.valueOf((float)10000), 10000, true, 8); + run_intQuery(int_filterR, FloatParameter, Float.valueOf((float)43), 43, false, 6); + run_intQuery(int_filterL, doubleParameter, Double.valueOf(AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, true, 10); + run_intQuery(int_filterR, doubleParameter, Double.valueOf(AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, false, 10); + run_intQuery(int_filterL, DoubleParameter, Double.valueOf(10000), 10000, true, 8); + run_intQuery(int_filterR, DoubleParameter, Double.valueOf(43), 43, false, 6); + run_intQuery(int_filterL, BigIntegerParameter, new BigInteger("1000000"), 1000000, true, 9); + run_intQuery(int_filterR, BigIntegerParameter, new BigInteger("1000"), 1000, false, 4); + run_intQuery(int_filterL, BigDecimalParameter, new BigDecimal("10000.0"), 10000, true, 8); + run_intQuery(int_filterR, BigDecimalParameter, new BigDecimal("43.0"), 43, false, 6); + alltypes.setint(100); + run_intQuery(int_filterObj, AllTypesParameter, alltypes, 100, true, 6); + run_intQuery(int_filterVal, null, null, 1000, false, 4); + + run_longQuery(long_filterL, longParameter, Long.valueOf(Long.MIN_VALUE), Long.MIN_VALUE, true, 1); + run_longQuery(long_filterR, longParameter, Long.valueOf(Long.MAX_VALUE), Long.MAX_VALUE, false, 1); + run_longQuery(long_filterL, LongParameter, Long.valueOf(100), 100, true, 7); + run_longQuery(long_filterR, LongParameter, Long.valueOf(23), 23, false, 5); + run_longQuery(long_filterL, byteParameter, Byte.valueOf((byte)100), 100, true, 7); + run_longQuery(long_filterR, byteParameter, Byte.valueOf((byte)0), 0, false, 6); + run_longQuery(long_filterL, ByteParameter, Byte.valueOf((byte)100), 100, true, 7); + run_longQuery(long_filterR, ByteParameter, Byte.valueOf((byte)0), 0, false, 6); + run_longQuery(long_filterL, shortParameter, Short.valueOf((short)-1000), -1000, true, 4); + run_longQuery(long_filterR, shortParameter, Short.valueOf((short)1000), 1000, false, 3); + run_longQuery(long_filterL, ShortParameter, Short.valueOf((short)100), 100, true, 7); + run_longQuery(long_filterR, ShortParameter, Short.valueOf((short)32), 32, false, 5); + run_longQuery(long_filterL, charParameter, Character.valueOf((char)0), 0, true, 5); + run_longQuery(long_filterR, charParameter, Character.valueOf((char)100), 100, false, 5); + run_longQuery(long_filterL, CharacterParameter, Character.valueOf((char)23), 23, true, 5); + run_longQuery(long_filterR, CharacterParameter, Character.valueOf((char)0), 0, false, 6); + run_longQuery(long_filterL, intParameter, Integer.valueOf(100), 100, true, 7); + run_longQuery(long_filterR, intParameter, Integer.valueOf(0), 0, false, 6); + run_longQuery(long_filterL, IntegerParameter, Integer.valueOf(23), 23, true, 5); + run_longQuery(long_filterR, IntegerParameter, Integer.valueOf(1000000), 1000000, false, 2); + run_longQuery(long_filterL, floatParameter, Float.valueOf((float)-1000000.0), -1000000, true, 2); + run_longQuery(long_filterR, floatParameter, Float.valueOf((float)Long.MAX_VALUE), Long.MAX_VALUE, false, 1); + run_longQuery(long_filterL, FloatParameter, Float.valueOf((float)100.0), 100, true, 7); + run_longQuery(long_filterR, FloatParameter, Float.valueOf((float)32.0), 32, false, 5); + run_longQuery(long_filterL, doubleParameter, Double.valueOf(-1000000.0), -1000000, true, 2); + run_longQuery(long_filterR, doubleParameter, Double.valueOf((double)Long.MAX_VALUE), Long.MAX_VALUE, false, 1); + run_longQuery(long_filterL, DoubleParameter, Double.valueOf(100.0), 100, true, 7); + run_longQuery(long_filterR, DoubleParameter, Double.valueOf(32.0), 32, false, 5); + run_longQuery(long_filterL, BigIntegerParameter, new BigInteger("23"), 23, true, 5); + run_longQuery(long_filterR, BigIntegerParameter, new BigInteger("1000000"), 1000000, false, 2); + run_longQuery(long_filterL, BigDecimalParameter, new BigDecimal("100.0"), 100, true, 7); + run_longQuery(long_filterR, BigDecimalParameter, new BigDecimal("32.0"), 32, false, 5); + alltypes.setlong(100); + run_longQuery(long_filterObj, AllTypesParameter, alltypes, 100, false, 5); + run_longQuery(long_filterVal, null, null, 1000000, false, 2); + + run_floatQuery(float_filterL, floatParameter, Float.valueOf((float)AllTypes.FLOAT_SMALLEST), AllTypes.FLOAT_SMALLEST, true, 1); + run_floatQuery(float_filterR, floatParameter, Float.valueOf((float)AllTypes.FLOAT_LARGEST), AllTypes.FLOAT_LARGEST, false, 1); + run_floatQuery(float_filterL, FloatParameter, Float.valueOf((float)4.0f), 4.0f, true, 4); + run_floatQuery(float_filterR, FloatParameter, Float.valueOf((float)400.0f), 400.0f, false, 3); + run_floatQuery(float_filterL, byteParameter, Byte.valueOf((byte)4), 4.0f, true, 4); + run_floatQuery(float_filterR, byteParameter, Byte.valueOf((byte)23), 23.0f, false, 6); + run_floatQuery(float_filterL, ByteParameter, Byte.valueOf((byte)34), 34.0f, true, 4); + run_floatQuery(float_filterR, ByteParameter, Byte.valueOf((byte)100), 100.0f, false, 6); + run_floatQuery(float_filterL, shortParameter, Short.valueOf((short)10), 10.0f, true, 4); + run_floatQuery(float_filterR, shortParameter, Short.valueOf((short)23), 23.0f, false, 6); + run_floatQuery(float_filterL, ShortParameter, Short.valueOf((short)34), 34.0f, true, 4); + run_floatQuery(float_filterR, ShortParameter, Short.valueOf((short)100), 100.0f, false, 6); + run_floatQuery(float_filterL, charParameter, Character.valueOf((char)20), 20.0f, true, 4); + run_floatQuery(float_filterR, charParameter, Character.valueOf((char)23), 23.0f, false, 6); + run_floatQuery(float_filterL, CharacterParameter, Character.valueOf((char)34), 34.0f, true, 4); + run_floatQuery(float_filterR, CharacterParameter, Character.valueOf((char)100), 100.0f, false, 6); + run_floatQuery(float_filterL, intParameter, Integer.valueOf(55000000), 55000000.0f, true, 8); + run_floatQuery(float_filterR, intParameter, Integer.valueOf(23), 23.0f, false, 6); + run_floatQuery(float_filterL, IntegerParameter, Integer.valueOf(34), 34.0f, true, 4); + run_floatQuery(float_filterR, IntegerParameter, Integer.valueOf(100), 100.0f, false, 6); + run_floatQuery(float_filterL, longParameter, Long.valueOf(55000000), 55000000.0f, true, 8); + run_floatQuery(float_filterR, longParameter, Long.valueOf(23), 23.0f, false, 6); + run_floatQuery(float_filterL, LongParameter, Long.valueOf(34), 34.0f, true, 4); + run_floatQuery(float_filterR, LongParameter, Long.valueOf(100), 100.0f, false, 6); + run_floatQuery(float_filterL, doubleParameter, Double.valueOf(55000000.0), 55000000.0f, true, 8); + run_floatQuery(float_filterR, doubleParameter, Double.valueOf(-20.5), -20.5f, false, 7); + run_floatQuery(float_filterL, DoubleParameter, Double.valueOf(2.0), 2.0f, true, 4); + run_floatQuery(float_filterR, DoubleParameter, Double.valueOf(100.0), 100.0f, false, 6); + run_floatQuery(float_filterL, BigIntegerParameter, new BigInteger("55000000"), 55000000.0f, true, 8); + run_floatQuery(float_filterR, BigIntegerParameter, new BigInteger("23"), 23.0f, false, 6); + run_floatQuery(float_filterL, BigDecimalParameter, new BigDecimal("55000000.0"), 55000000.0f, true, 8); + run_floatQuery(float_filterR, BigDecimalParameter, new BigDecimal("-20.5"), -20.5f, false, 7); + alltypes.setfloat(23.23f); + run_floatQuery(float_filterObj, AllTypesParameter, alltypes, 23.23f, false, 6); + run_floatQuery(float_filterVal, null, null, 100.0f, false, 6); + + run_doubleQuery(double_filterL, doubleParameter, Double.valueOf(AllTypes.DOUBLE_SMALLEST), AllTypes.DOUBLE_SMALLEST, true, 1); + run_doubleQuery(double_filterR, doubleParameter, Double.valueOf(AllTypes.DOUBLE_LARGEST), AllTypes.DOUBLE_LARGEST, false, 1); + run_doubleQuery(double_filterL, DoubleParameter, Double.valueOf(0.0), 0.0, true, 4); + run_doubleQuery(double_filterR, DoubleParameter, Double.valueOf(23.34), 23.34, false, 6); + run_doubleQuery(double_filterL, byteParameter, Byte.valueOf((byte)100), 100.0, true, 6); + run_doubleQuery(double_filterR, byteParameter, Byte.valueOf((byte)0), 0.0, false, 7); + run_doubleQuery(double_filterL, ByteParameter, Byte.valueOf((byte)23), 23.0, true, 4); + run_doubleQuery(double_filterR, ByteParameter, Byte.valueOf((byte)100), 100.0, false, 6); + run_doubleQuery(double_filterL, charParameter, Character.valueOf((char)100), 100.0, true, 6); + run_doubleQuery(double_filterR, charParameter, Character.valueOf((char)0), 0.0, false, 7); + run_doubleQuery(double_filterL, CharacterParameter, Character.valueOf((char)23), 23.0, true, 4); + run_doubleQuery(double_filterR, CharacterParameter, Character.valueOf((char)100), 100.0, false, 6); + run_doubleQuery(double_filterL, shortParameter, Short.valueOf((short)100), 100.0, true, 6); + run_doubleQuery(double_filterR, shortParameter, Short.valueOf((short)0), 0.0, false, 7); + run_doubleQuery(double_filterL, ShortParameter, Short.valueOf((short)23), 23.0, true, 4); + run_doubleQuery(double_filterR, ShortParameter, Short.valueOf((short)100), 100.0, false, 6); + run_doubleQuery(double_filterL, intParameter, Integer.valueOf(100), 100.0, true, 6); + run_doubleQuery(double_filterR, intParameter, Integer.valueOf(0), 0.0, false, 7); + run_doubleQuery(double_filterL, IntegerParameter, Integer.valueOf(5000), 5000.0, true, 7); + run_doubleQuery(double_filterR, IntegerParameter, Integer.valueOf(-20), -20.0, false, 7); + run_doubleQuery(double_filterL, longParameter, Long.valueOf(100), 100.0, true, 6); + run_doubleQuery(double_filterR, longParameter, Long.valueOf(0), 0.0, false, 7); + run_doubleQuery(double_filterL, LongParameter, Long.valueOf(5000), 5000.0, true, 7); + run_doubleQuery(double_filterR, LongParameter, Long.valueOf(-20), -20.0, false, 7); + run_doubleQuery(double_filterL, floatParameter, Float.valueOf(0.0f), 0.0f, true, 4); + run_doubleQuery(double_filterR, floatParameter, Float.valueOf(100.0f), 100.0f, false, 6); + run_doubleQuery(double_filterL, FloatParameter, Float.valueOf(100.0f), 100.0, true, 6); + run_doubleQuery(double_filterR, FloatParameter, Float.valueOf(69.96f), 69.96, false, 6); + run_doubleQuery(double_filterL, BigIntegerParameter, new BigInteger("5000"), 5000.0, true, 7); + run_doubleQuery(double_filterR, BigIntegerParameter, new BigInteger("-20"), -20.0, false, 7); + run_doubleQuery(double_filterL, BigDecimalParameter, new BigDecimal("100.0"), 100.0, true, 6); + run_doubleQuery(double_filterR, BigDecimalParameter, new BigDecimal("69.96"), 69.96, false, 6); + alltypes.setdouble(-25.5); + run_doubleQuery(double_filterObj, AllTypesParameter, alltypes, -25.5, true, 3); + run_doubleQuery(double_filterVal, null, null, 100.0, false, 6); + + run_ByteQuery(Byte_filterL, byteParameter, Byte.valueOf((byte)50), Byte.valueOf((byte)50), true, 7); + run_ByteQuery(Byte_filterR, byteParameter, Byte.valueOf(Byte.MIN_VALUE), Byte.valueOf(Byte.MIN_VALUE), false, 10); + run_ByteQuery(Byte_filterL, ByteParameter, Byte.valueOf((byte)20), Byte.valueOf((byte)20), true, 5); + run_ByteQuery(Byte_filterR, ByteParameter, Byte.valueOf(Byte.MAX_VALUE), Byte.valueOf(Byte.MAX_VALUE), false, 1); + run_ByteQuery(Byte_filterL, shortParameter, Short.valueOf((short)60), Byte.valueOf((byte)60), true, 7); + run_ByteQuery(Byte_filterR, shortParameter, Short.valueOf((short)51), Byte.valueOf((byte)51), false, 3); + run_ByteQuery(Byte_filterL, ShortParameter, Short.valueOf((short)-100), Byte.valueOf((byte)-100), true, 2); + run_ByteQuery(Byte_filterR, ShortParameter, Short.valueOf((short)-100), Byte.valueOf((byte)-100), false, 9); + run_ByteQuery(Byte_filterL, charParameter, Character.valueOf((char)101), Byte.valueOf((byte)101), true, 9); + run_ByteQuery(Byte_filterR, charParameter, Character.valueOf((char)10), Byte.valueOf((byte)10), false, 6); + run_ByteQuery(Byte_filterL, CharacterParameter, Character.valueOf((char)50), Byte.valueOf((byte)50), true, 7); + run_ByteQuery(Byte_filterR, CharacterParameter, Character.valueOf((char)75), Byte.valueOf((byte)75), false, 3); + run_ByteQuery(Byte_filterL, intParameter, Integer.valueOf(77), Byte.valueOf((byte)77), true, 8); + run_ByteQuery(Byte_filterR, intParameter, Integer.valueOf(60), Byte.valueOf((byte)60), false, 3); + run_ByteQuery(Byte_filterL, IntegerParameter, Integer.valueOf(40), Byte.valueOf((byte)40), true, 5); + run_ByteQuery(Byte_filterR, IntegerParameter, Integer.valueOf(75), Byte.valueOf((byte)75), false, 3); + run_ByteQuery(Byte_filterL, longParameter, Long.valueOf(50), Byte.valueOf((byte)50), true, 7); + run_ByteQuery(Byte_filterR, longParameter, Long.valueOf(50), Byte.valueOf((byte)50), false, 5); + run_ByteQuery(Byte_filterL, LongParameter, Long.valueOf(-100), Byte.valueOf((byte)-100), true, 2); + run_ByteQuery(Byte_filterR, LongParameter, Long.valueOf(-100), Byte.valueOf((byte)-100), false, 9); + run_ByteQuery(Byte_filterL, floatParameter, Float.valueOf((float)50), Byte.valueOf((byte)50), true, 7); + run_ByteQuery(Byte_filterR, floatParameter, Float.valueOf((float)50), Byte.valueOf((byte)50), false, 5); + run_ByteQuery(Byte_filterL, FloatParameter, Float.valueOf((float)-100), Byte.valueOf((byte)-100), true, 2); + run_ByteQuery(Byte_filterR, FloatParameter, Float.valueOf((float)-100), Byte.valueOf((byte)-100), false, 9); + run_ByteQuery(Byte_filterL, doubleParameter, Double.valueOf(50), Byte.valueOf((byte)50), true, 7); + run_ByteQuery(Byte_filterR, doubleParameter, Double.valueOf(50), Byte.valueOf((byte)50), false, 5); + run_ByteQuery(Byte_filterL, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte)-100), true, 2); + run_ByteQuery(Byte_filterR, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte)-100), false, 9); + run_ByteQuery(Byte_filterL, BigIntegerParameter, new BigInteger("50"), Byte.valueOf((byte)50), true, 7); + run_ByteQuery(Byte_filterR, BigIntegerParameter, new BigInteger("-100"), Byte.valueOf((byte)-100), false, 9); + run_ByteQuery(Byte_filterL, BigDecimalParameter, new BigDecimal("50.000000"), Byte.valueOf((byte)50), true, 7); + run_ByteQuery(Byte_filterR, BigDecimalParameter, new BigDecimal("10.00000"), Byte.valueOf((byte)10), false, 6); + Byte val = Byte.valueOf((byte)50); + alltypes.setByte(val); + run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, false, 5); + val = Byte.valueOf((byte)51); + alltypes.setByte(val); + run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, false, 3); + run_ByteQuery(Byte_filterVal, null, null, Byte.valueOf((byte)100), true, 9); + + run_ShortQuery(Short_filterL, shortParameter, Short.valueOf((short)100), Short.valueOf((short)100), true, 7); + run_ShortQuery(Short_filterR, shortParameter, Short.valueOf((short)100), Short.valueOf((short)100), false, 5); + run_ShortQuery(Short_filterL, ShortParameter, Short.valueOf(Short.MIN_VALUE), Short.valueOf(Short.MIN_VALUE), true, 1); + run_ShortQuery(Short_filterR, ShortParameter, Short.valueOf((short)253), Short.valueOf((short)253), false, 3); + run_ShortQuery(Short_filterR, shortParameter, Short.valueOf((short)1000), Short.valueOf((short)1000), false, 3); + run_ShortQuery(Short_filterL, byteParameter, Byte.valueOf((byte)75), Short.valueOf((short)75), true, 5); + run_ShortQuery(Short_filterR, byteParameter, Byte.valueOf((byte)75), Short.valueOf((short)75), false, 5); + run_ShortQuery(Short_filterL, ByteParameter, Byte.valueOf((byte)100), Short.valueOf((short)100), true, 7); + run_ShortQuery(Short_filterR, ByteParameter, Byte.valueOf((byte)100), Short.valueOf((short)100), false, 5); + run_ShortQuery(Short_filterL, charParameter, Character.valueOf((char)75), Short.valueOf((short)75), true, 5); + run_ShortQuery(Short_filterR, charParameter, Character.valueOf((char)75), Short.valueOf((short)75), false, 5); + run_ShortQuery(Short_filterL, CharacterParameter, Character.valueOf((char)100), Short.valueOf((short)100), true, 7); + run_ShortQuery(Short_filterR, CharacterParameter, Character.valueOf((char)200), Short.valueOf((short)200), false, 3); + run_ShortQuery(Short_filterL, intParameter, Integer.valueOf(-10000), Short.valueOf((short)-10000), true, 2); + run_ShortQuery(Short_filterR, intParameter, Integer.valueOf(-10000), Short.valueOf((short)-10000), false, 9); + run_ShortQuery(Short_filterL, IntegerParameter, Integer.valueOf(10000), Short.valueOf((short)10000), true, 9); + run_ShortQuery(Short_filterR, IntegerParameter, Integer.valueOf(10000), Short.valueOf((short)10000), false, 2); + run_ShortQuery(Short_filterL, longParameter, Long.valueOf(20000), Short.valueOf((short) 20000), true, 9); + run_ShortQuery(Short_filterR, longParameter, Long.valueOf(5000), Short.valueOf((short) 5000), false, 2); + run_ShortQuery(Short_filterL, LongParameter, Long.valueOf(200), Short.valueOf((short)200), true, 7); + run_ShortQuery(Short_filterR, LongParameter, Long.valueOf(500), Short.valueOf((short)500), false, 3); + run_ShortQuery(Short_filterL, floatParameter, Float.valueOf(23000.0f), Short.valueOf((short)23000), true, 9); + run_ShortQuery(Short_filterR, floatParameter, Float.valueOf(23000.0f), Short.valueOf((short)23000), false, 1); + run_ShortQuery(Short_filterL, FloatParameter, Float.valueOf(10.0f), Short.valueOf((short)10), true, 5); + run_ShortQuery(Short_filterR, FloatParameter, Float.valueOf(101.0f), Short.valueOf((short)101), false, 3); + run_ShortQuery(Short_filterL, doubleParameter, Double.valueOf(-10000.0), Short.valueOf((short)-10000), true, 2); + run_ShortQuery(Short_filterR, doubleParameter, Double.valueOf(-10000.0), Short.valueOf((short)-10000), false, 9); + run_ShortQuery(Short_filterL, DoubleParameter, Double.valueOf(101.0), Short.valueOf((short)101), true, 7); + run_ShortQuery(Short_filterR, DoubleParameter, Double.valueOf(23.0), Short.valueOf((short)23), false, 5); + run_ShortQuery(Short_filterL, BigIntegerParameter, new BigInteger("10000"), Short.valueOf((short)10000), true, 9); + run_ShortQuery(Short_filterR, BigIntegerParameter, new BigInteger("30000"), Short.valueOf((short)30000), false, 1); + run_ShortQuery(Short_filterL, BigDecimalParameter, new BigDecimal("23.0"), Short.valueOf((short)23), true, 5); + run_ShortQuery(Short_filterR, BigDecimalParameter, new BigDecimal("23.0"), Short.valueOf((short)23), false, 5); + Short sval = Short.valueOf((short)100); + alltypes.setShort(sval); + run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, false, 5); + sval = Short.valueOf((short)23); + alltypes.setShort(sval); + run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, false, 5); + run_ShortQuery(Short_filterVal, null, null, Short.valueOf((short)-1000), true, 3); + + run_CharacterQuery(Character_filterL, charParameter, Character.valueOf(Character.MIN_VALUE), Character.valueOf(Character.MIN_VALUE), true, 1); + run_CharacterQuery(Character_filterR, charParameter, Character.valueOf(Character.MAX_VALUE), Character.valueOf(Character.MAX_VALUE), false, 1); + run_CharacterQuery(Character_filterL, charParameter, Character.valueOf('C'), Character.valueOf('C'), true, 4); + run_CharacterQuery(Character_filterR, charParameter, Character.valueOf('z'), Character.valueOf('z'), false, 3); + run_CharacterQuery(Character_filterL, CharacterParameter, Character.valueOf(' '), Character.valueOf(' '), true, 2); + run_CharacterQuery(Character_filterR, CharacterParameter, Character.valueOf('f'), Character.valueOf('f'), false, 3); + run_CharacterQuery(Character_filterL, byteParameter, Byte.valueOf((byte)Character.MIN_VALUE), Character.valueOf((char)Character.MIN_VALUE), true, 1); + run_CharacterQuery(Character_filterR, ByteParameter, Byte.valueOf((byte)'a'), Character.valueOf('a'), false, 3); + run_CharacterQuery(Character_filterL, shortParameter, Short.valueOf((short)'M'), Character.valueOf('M'), true, 7); + run_CharacterQuery(Character_filterR, shortParameter, Short.valueOf((short)'F'), Character.valueOf('F'), false, 6); + run_CharacterQuery(Character_filterL, ShortParameter, Short.valueOf((short)'A'), Character.valueOf('A'), true, 3); + run_CharacterQuery(Character_filterR, ShortParameter, Short.valueOf((short)'A'), Character.valueOf('A'), false, 8); + run_CharacterQuery(Character_filterL, intParameter, Integer.valueOf('z'), Character.valueOf('z'), true, 9); + run_CharacterQuery(Character_filterR, intParameter, Integer.valueOf('z'), Character.valueOf('z'), false, 3); + run_CharacterQuery(Character_filterL, IntegerParameter, Integer.valueOf('B'), Character.valueOf('B'), true, 4); + run_CharacterQuery(Character_filterR, IntegerParameter, Integer.valueOf('B'), Character.valueOf('B'), false, 7); + run_CharacterQuery(Character_filterL, longParameter, Long.valueOf('z'), Character.valueOf('z'), true, 9); + run_CharacterQuery(Character_filterR, longParameter, Long.valueOf('z'), Character.valueOf('z'), false, 3); + run_CharacterQuery(Character_filterL, LongParameter, Long.valueOf('B'), Character.valueOf('B'), true, 4); + run_CharacterQuery(Character_filterR, LongParameter, Long.valueOf('B'), Character.valueOf('B'), false, 7); + run_CharacterQuery(Character_filterL, floatParameter, Float.valueOf((float)'z'), Character.valueOf('z'), true, 9); + run_CharacterQuery(Character_filterR, floatParameter, Float.valueOf((float)'z'), Character.valueOf('z'), false, 3); + run_CharacterQuery(Character_filterL, FloatParameter, Float.valueOf((float)'M'), Character.valueOf('M'), true, 7); + run_CharacterQuery(Character_filterR, FloatParameter, Float.valueOf((float)'X'), Character.valueOf('X'), false, 3); + run_CharacterQuery(Character_filterL, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), true, 4); + run_CharacterQuery(Character_filterR, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), false, 7); + run_CharacterQuery(Character_filterL, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), true, 3); + run_CharacterQuery(Character_filterR, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), false, 8); + run_CharacterQuery(Character_filterL, BigIntegerParameter, new BigInteger("65"), Character.valueOf('A'), true, 3); // 'A' == 65 + run_CharacterQuery(Character_filterR, BigIntegerParameter, new BigInteger("122"), Character.valueOf('z'), false, 3); // 'z' == 122 + run_CharacterQuery(Character_filterL, BigDecimalParameter, new BigDecimal("65.00000"), Character.valueOf('A'), true, 3); + run_CharacterQuery(Character_filterR, BigDecimalParameter, new BigDecimal("77.0000"), Character.valueOf('M'), false, 5); // 'M' == 77 + alltypes.setCharacter(Character.valueOf('A')); + run_CharacterQuery(Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('A'), true, 3); + alltypes.setCharacter(Character.valueOf('b')); + run_CharacterQuery(Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('b'), true, 7); + run_CharacterQuery(Character_filterVal, null, null, Character.valueOf('z'), false, 3); + + run_IntegerQuery(Integer_filterL, intParameter, Integer.valueOf(AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), true, 1); + run_IntegerQuery(Integer_filterR, intParameter, Integer.valueOf(AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), false, 1); + run_IntegerQuery(Integer_filterR, intParameter, Integer.valueOf(23), Integer.valueOf(23), false, 6); + run_IntegerQuery(Integer_filterL, IntegerParameter, Integer.valueOf(1000000), Integer.valueOf(1000000), true, 9); + run_IntegerQuery(Integer_filterR, IntegerParameter, Integer.valueOf(1000), Integer.valueOf(1000), false, 4); + run_IntegerQuery(Integer_filterL, byteParameter, Byte.valueOf((byte)100), Integer.valueOf(100), true, 6); + run_IntegerQuery(Integer_filterR, byteParameter, Byte.valueOf((byte)0), Integer.valueOf(0), false, 7); + run_IntegerQuery(Integer_filterL, ByteParameter, Byte.valueOf((byte)100), Integer.valueOf(100), true, 6); + run_IntegerQuery(Integer_filterR, ByteParameter, Byte.valueOf((byte)0), Integer.valueOf(0), false, 7); + run_IntegerQuery(Integer_filterL, shortParameter, Short.valueOf((short)10000), Integer.valueOf(10000), true, 8); + run_IntegerQuery(Integer_filterR, shortParameter, Short.valueOf((short)-1000), Integer.valueOf(-1000), false, 8); + run_IntegerQuery(Integer_filterL, ShortParameter, Short.valueOf((short)-1000), Integer.valueOf(-1000), true, 3); + run_IntegerQuery(Integer_filterR, ShortParameter, Short.valueOf((short)-999), Integer.valueOf(-999), false, 7); + run_IntegerQuery(Integer_filterL, charParameter, Character.valueOf((char)10000), Integer.valueOf(10000), true, 8); + run_IntegerQuery(Integer_filterR, charParameter, Character.valueOf((char)10000), Integer.valueOf(10000), false, 3); + run_IntegerQuery(Integer_filterL, CharacterParameter, Character.valueOf((char)100), Integer.valueOf(100), true, 6); + run_IntegerQuery(Integer_filterR, CharacterParameter, Character.valueOf((char)10000), Integer.valueOf(10000), false, 3); + run_IntegerQuery(Integer_filterL, longParameter, Long.valueOf(AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), true, 10); + run_IntegerQuery(Integer_filterR, longParameter, Long.valueOf(AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), false, 10); + run_IntegerQuery(Integer_filterL, LongParameter, Long.valueOf(10000), Integer.valueOf(10000), true, 8); + run_IntegerQuery(Integer_filterR, LongParameter, Long.valueOf(43), Integer.valueOf(43), false, 6); + run_IntegerQuery(Integer_filterL, floatParameter, Float.valueOf((float)AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), true, 10); + run_IntegerQuery(Integer_filterR, floatParameter, Float.valueOf((float)AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), false, 10); + run_IntegerQuery(Integer_filterL, FloatParameter, Float.valueOf((float)10000), Integer.valueOf(10000), true, 8); + run_IntegerQuery(Integer_filterR, FloatParameter, Float.valueOf((float)43), Integer.valueOf(43), false, 6); + run_IntegerQuery(Integer_filterL, doubleParameter, Double.valueOf(AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), true, 10); + run_IntegerQuery(Integer_filterR, doubleParameter, Double.valueOf(AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), false, 10); + run_IntegerQuery(Integer_filterL, DoubleParameter, Double.valueOf(10000), Integer.valueOf(10000), true, 8); + run_IntegerQuery(Integer_filterR, DoubleParameter, Double.valueOf(1000001.0), Integer.valueOf(1000001), false, 1); + run_IntegerQuery(Integer_filterL, BigIntegerParameter, new BigInteger("1000000"), Integer.valueOf(1000000), true, 9); + run_IntegerQuery(Integer_filterR, BigIntegerParameter, new BigInteger("1000"), Integer.valueOf(1000), false, 4); + run_IntegerQuery(Integer_filterL, BigDecimalParameter, new BigDecimal("10000.0"), Integer.valueOf(10000), true, 8); + run_IntegerQuery(Integer_filterR, BigDecimalParameter, new BigDecimal("43.0"), Integer.valueOf(43), false, 6); + alltypes.setInteger(Integer.valueOf(100)); + run_IntegerQuery(Integer_filterObj, AllTypesParameter, alltypes, Integer.valueOf(100), false, 6); + run_IntegerQuery(Integer_filterVal, null, null, Integer.valueOf(100), false, 6); + + run_LongQuery(Long_filterL, longParameter, Long.valueOf(Long.MIN_VALUE), Long.valueOf(Long.MIN_VALUE), true, 1); + run_LongQuery(Long_filterR, longParameter, Long.valueOf(Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE), false, 1); + run_LongQuery(Long_filterL, LongParameter, Long.valueOf(100), Long.valueOf(100), true, 7); + run_LongQuery(Long_filterR, LongParameter, Long.valueOf(23), Long.valueOf(23), false, 5); + run_LongQuery(Long_filterL, byteParameter, Byte.valueOf((byte)100), Long.valueOf(100), true, 7); + run_LongQuery(Long_filterR, byteParameter, Byte.valueOf((byte)0), Long.valueOf(0), false, 6); + run_LongQuery(Long_filterL, ByteParameter, Byte.valueOf((byte)100), Long.valueOf(100), true, 7); + run_LongQuery(Long_filterR, ByteParameter, Byte.valueOf((byte)0), Long.valueOf(0), false, 6); + run_LongQuery(Long_filterL, shortParameter, Short.valueOf((short)-1000 ), Long.valueOf(-1000), true, 4); + run_LongQuery(Long_filterR, shortParameter, Short.valueOf((short)1000), Long.valueOf(1000), false, 3); + run_LongQuery(Long_filterL, ShortParameter, Short.valueOf((short)101), Long.valueOf(101), true, 7); + run_LongQuery(Long_filterR, ShortParameter, Short.valueOf((short)32), Long.valueOf(32), false, 5); + run_LongQuery(Long_filterL, charParameter, Character.valueOf((char)0), Long.valueOf(0), true, 5); + run_LongQuery(Long_filterR, charParameter, Character.valueOf((char)100), Long.valueOf(100), false, 5); + run_LongQuery(Long_filterL, CharacterParameter, Character.valueOf((char)23), Long.valueOf(23), true, 5); + run_LongQuery(Long_filterR, CharacterParameter, Character.valueOf((char)1110), Long.valueOf(1110), false, 2); + run_LongQuery(Long_filterL, intParameter, Integer.valueOf(100), Long.valueOf(100), true, 7); + run_LongQuery(Long_filterR, intParameter, Integer.valueOf(0), Long.valueOf(0), false, 6); + run_LongQuery(Long_filterL, IntegerParameter, Integer.valueOf(23), Long.valueOf(23), true, 5); + run_LongQuery(Long_filterR, IntegerParameter, Integer.valueOf(1000000), Long.valueOf(1000000), false, 2); + run_LongQuery(Long_filterL, floatParameter, Float.valueOf((float)-1000000.0), Long.valueOf(-1000000), true, 2); + run_LongQuery(Long_filterR, floatParameter, Float.valueOf((float)Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE), false, 1); + run_LongQuery(Long_filterL, FloatParameter, Float.valueOf(100.0f), Long.valueOf(100), true, 7); + run_LongQuery(Long_filterR, FloatParameter, Float.valueOf(32.0f), Long.valueOf(32), false, 5); + run_LongQuery(Long_filterL, doubleParameter, Double.valueOf(-1000000.0), Long.valueOf(-1000000), true, 2); + run_LongQuery(Long_filterR, doubleParameter, Double.valueOf((double)Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE), false, 1); + run_LongQuery(Long_filterL, DoubleParameter, Double.valueOf(100.0), Long.valueOf(100), true, 7); + run_LongQuery(Long_filterR, DoubleParameter, Double.valueOf(32.0), Long.valueOf(32), false, 5); + run_LongQuery(Long_filterL, BigIntegerParameter, new BigInteger("23"), Long.valueOf(23), true, 5); + run_LongQuery(Long_filterR, BigIntegerParameter, new BigInteger("1000000"), Long.valueOf(1000000), false, 2); + run_LongQuery(Long_filterL, BigDecimalParameter, new BigDecimal("100.0"), Long.valueOf(100), true, 7); + run_LongQuery(Long_filterR, BigDecimalParameter, new BigDecimal("32.0"), Long.valueOf(32), false, 5); + alltypes.setLong(Long.valueOf(100)); + run_LongQuery(Long_filterObj, AllTypesParameter, alltypes, Long.valueOf(100), true, 7); + run_LongQuery(Long_filterVal, null, null, Long.valueOf(-1000), true, 4); + + run_FloatQuery(Float_filterL, floatParameter, Float.valueOf(-10000000000.0f), Float.valueOf(-10000000000.0f), true, 1); + run_FloatQuery(Float_filterR, floatParameter, Float.valueOf(9000000000.0f), Float.valueOf(9000000000.0f), false, 1); + run_FloatQuery(Float_filterL, FloatParameter, Float.valueOf((float)0.0), Float.valueOf(0.0f), true, 3); + run_FloatQuery(Float_filterR, FloatParameter, Float.valueOf((float)4.0), Float.valueOf(4.0f), false, 7); + run_FloatQuery(Float_filterL, byteParameter, Byte.valueOf((byte)0), Float.valueOf(0.0f), true, 3); + run_FloatQuery(Float_filterR, byteParameter, Byte.valueOf((byte)23), Float.valueOf(23.0f), false, 7); + run_FloatQuery(Float_filterL, ByteParameter, Byte.valueOf((byte)34), Float.valueOf(34.0f), true, 3); + run_FloatQuery(Float_filterR, ByteParameter, Byte.valueOf((byte)100), Float.valueOf(100.0f), false, 7); + run_FloatQuery(Float_filterL, shortParameter, Short.valueOf((short)0), Float.valueOf(0.0f), true, 3); + run_FloatQuery(Float_filterR, shortParameter, Short.valueOf((short)23), Float.valueOf(23.0f), false, 7); + run_FloatQuery(Float_filterL, ShortParameter, Short.valueOf((short)34), Float.valueOf(34.0f), true, 3); + run_FloatQuery(Float_filterR, ShortParameter, Short.valueOf((short)100), Float.valueOf(100.0f), false, 7); + run_FloatQuery(Float_filterL, charParameter, Character.valueOf((char)0), Float.valueOf(0.0f), true, 3); + run_FloatQuery(Float_filterR, charParameter, Character.valueOf((char)23), Float.valueOf(23.0f), false, 7); + run_FloatQuery(Float_filterL, CharacterParameter, Character.valueOf((char)34), Float.valueOf(34.0f), true, 3); + run_FloatQuery(Float_filterR, CharacterParameter, Character.valueOf((char)100), Float.valueOf(100.0f), false, 7); + run_FloatQuery(Float_filterL, intParameter, Integer.valueOf(50000000), Float.valueOf(50000000.0f), true, 8); + run_FloatQuery(Float_filterR, intParameter, Integer.valueOf(23), Float.valueOf(23.0f), false, 7); + run_FloatQuery(Float_filterL, IntegerParameter, Integer.valueOf(34), Float.valueOf(34.0f), true, 3); + run_FloatQuery(Float_filterR, IntegerParameter, Integer.valueOf(100), Float.valueOf(100.0f), false, 7); + run_FloatQuery(Float_filterL, longParameter, Long.valueOf(50000000), Float.valueOf(50000000.0f), true, 8); + run_FloatQuery(Float_filterR, longParameter, Long.valueOf(23), Float.valueOf(23.0f), false, 7); + run_FloatQuery(Float_filterL, LongParameter, Long.valueOf(34), Float.valueOf(34.0f), true, 3); + run_FloatQuery(Float_filterR, LongParameter, Long.valueOf(100), Float.valueOf(100.0f), false, 7); + run_FloatQuery(Float_filterL, doubleParameter, Double.valueOf(50000000.0f), Float.valueOf(50000000.0f), true, 8); + run_FloatQuery(Float_filterR, doubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), false, 7); + run_FloatQuery(Float_filterL, DoubleParameter, Double.valueOf(0.0f), Float.valueOf(0.0f), true, 3); + run_FloatQuery(Float_filterR, DoubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), false, 7); + run_FloatQuery(Float_filterL, BigIntegerParameter, new BigInteger("55000000"), Float.valueOf(55000000.0f), true, 8); + run_FloatQuery(Float_filterR, BigIntegerParameter, new BigInteger("23"), Float.valueOf(23.0f), false, 7); + run_FloatQuery(Float_filterL, BigDecimalParameter, new BigDecimal("55000000.0"), Float.valueOf(55000000.0f), true, 8); + run_FloatQuery(Float_filterR, BigDecimalParameter, new BigDecimal("-20.5"), Float.valueOf(-20.5f), false, 8); + alltypes.setFloat(Float.valueOf(23.23f)); + run_FloatQuery(Float_filterObj, AllTypesParameter, alltypes, Float.valueOf(23.23f), false, 7); + run_FloatQuery(Float_filterVal, null, null, Float.valueOf(100.0f), true, 5); + + run_DoubleQuery(Double_filterL, doubleParameter, Double.valueOf(-999999999999.0), Double.valueOf(-999999999999.0), true, 1); + run_DoubleQuery(Double_filterR, doubleParameter, Double.valueOf(9999999999999.0), Double.valueOf(9999999999999.0), false, 1); + run_DoubleQuery(Double_filterL, DoubleParameter, Double.valueOf(0.0), Double.valueOf(0.0), true, 4); + run_DoubleQuery(Double_filterR, DoubleParameter, Double.valueOf(23.34), Double.valueOf(23.34), false, 6); + run_DoubleQuery(Double_filterL, byteParameter, Byte.valueOf((byte)100), Double.valueOf(100.0), true, 6); + run_DoubleQuery(Double_filterR, byteParameter, Byte.valueOf((byte)0), Double.valueOf(0.0), false, 7); + run_DoubleQuery(Double_filterL, ByteParameter, Byte.valueOf((byte)-23), Double.valueOf(-23.0), true, 3); + run_DoubleQuery(Double_filterR, ByteParameter, Byte.valueOf((byte)100), Double.valueOf(100.0), false, 6); + run_DoubleQuery(Double_filterL, shortParameter, Short.valueOf((short)100), Double.valueOf(100.0), true, 6); + run_DoubleQuery(Double_filterR, shortParameter, Short.valueOf((short)0), Double.valueOf(0.0), false, 7); + run_DoubleQuery(Double_filterL, ShortParameter, Short.valueOf((short)23), Double.valueOf(23.0), true, 4); + run_DoubleQuery(Double_filterR, ShortParameter, Short.valueOf((short)400), Double.valueOf(400.0), false, 3); + run_DoubleQuery(Double_filterL, charParameter, Character.valueOf((char)100), Double.valueOf(100.0), true, 6); + run_DoubleQuery(Double_filterR, charParameter, Character.valueOf((char)0), Double.valueOf(0.0), false, 7); + run_DoubleQuery(Double_filterL, CharacterParameter, Character.valueOf((char)23), Double.valueOf(23.0), true, 4); + run_DoubleQuery(Double_filterR, CharacterParameter, Character.valueOf((char)400), Double.valueOf(400.0), false, 3); + run_DoubleQuery(Double_filterL, intParameter, Integer.valueOf(100), Double.valueOf(100.0), true, 6); + run_DoubleQuery(Double_filterR, intParameter, Integer.valueOf(0), Double.valueOf(0.0), false, 7); + run_DoubleQuery(Double_filterL, IntegerParameter, Integer.valueOf(23), Double.valueOf(23.0), true, 4); + run_DoubleQuery(Double_filterR, IntegerParameter, Integer.valueOf(100), Double.valueOf(100.0), false, 6); + run_DoubleQuery(Double_filterL, longParameter, Long.valueOf(100), Double.valueOf(100.0), true, 6); + run_DoubleQuery(Double_filterR, longParameter, Long.valueOf(0), Double.valueOf(0.0), false, 7); + run_DoubleQuery(Double_filterL, LongParameter, Long.valueOf(23), Double.valueOf(23.0), true, 4); + run_DoubleQuery(Double_filterR, LongParameter, Long.valueOf(100), Double.valueOf(100.0), false, 6); + run_DoubleQuery(Double_filterL, floatParameter, Float.valueOf(0.0f), Double.valueOf(0.0f), true, 4); + run_DoubleQuery(Double_filterR, floatParameter, Float.valueOf(100.0f), Double.valueOf(100.0f), false, 6); + run_DoubleQuery(Double_filterL, FloatParameter, Float.valueOf(100.0f), Double.valueOf(100.0f), true, 6); + run_DoubleQuery(Double_filterR, FloatParameter, Float.valueOf(69.96f), Double.valueOf(69.96), false, 6); + run_DoubleQuery(Double_filterL, BigIntegerParameter, new BigInteger("5000"), Double.valueOf(5000.0), true, 7); + run_DoubleQuery(Double_filterR, BigIntegerParameter, new BigInteger("-20"), Double.valueOf(-20.0), false, 7); + run_DoubleQuery(Double_filterL, BigDecimalParameter, new BigDecimal("100.0"), Double.valueOf(100.0), true, 6); + run_DoubleQuery(Double_filterR, BigDecimalParameter, new BigDecimal("69.96"), Double.valueOf(69.96), false, 6); + alltypes.setDouble(Double.valueOf(-999999999999.0)); + run_DoubleQuery(Double_filterObj, AllTypesParameter, alltypes, Double.valueOf(-999999999999.0), true, 1); + run_DoubleQuery(Double_filterVal, null, null, Double.valueOf(100.0), false, 6); - BigInteger bi = new BigInteger("987034534985043985"); - run_BigIntegerQuery(BigInteger_filterL, BigIntegerParameter, bi, bi, true, 10); - bi = new BigInteger("-999999999999999999"); - run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, false, 10); - bi = new BigInteger("-9999999999999999999"); - run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, false, 10); - bi = new BigInteger("1333330"); - alltypes.setBigInteger(bi); - run_BigIntegerQuery(BigInteger_filterObj, AllTypesParameter, alltypes, bi, false, 3); + run_StringQuery(String_filterL, StringParameter, new String("JDO"), new String("JDO"), true, 2); + run_StringQuery(String_filterR, StringParameter, new String("JDBC"), new String("JDBC"), false, 9); + alltypes.setString(new String("abcde")); + run_StringQuery(String_filterObj, AllTypesParameter, alltypes, new String("abcde"), true, 8); + run_StringQuery(String_filterVal1, null, null, new String("Java"), false, 6); + run_StringQuery(String_filterVal2, null, null, new String(""), false, 10); - GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.UK); - gc.clear(); - gc.set(1999, Calendar.DECEMBER, 31, 9, 0, 0); - Date d = gc.getTime(); - run_DateQuery(Date_filterL, DateParameter, d, d, true, 8); - gc.set(1992, Calendar.NOVEMBER, 22, 9, 0, 0); - d = gc.getTime(); - run_DateQuery(Date_filterR, DateParameter, d, d, false, 5); - gc.set(1959, Calendar.OCTOBER, 9, 9, 0, 0); - d = gc.getTime(); - run_DateQuery(Date_filterR, DateParameter, d, d, false, 7); - gc.set(1995, Calendar.JUNE, 14, 9, 0, 0); - d = gc.getTime(); - alltypes.setDate(d); - run_DateQuery(Date_filterObj, AllTypesParameter, alltypes, d, false, 4); - } + BigDecimal bd = new BigDecimal("100.0"); + run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, true, 6); + bd = new BigDecimal("-234234.23333"); + run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, false, 9); + bd = new BigDecimal("989899.33304953"); + run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, true, 7); + bd = new BigDecimal("-1123123.22"); + run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, false, 10); + alltypes.setBigDecimal(bd); + run_BigDecimalQuery(BigDecimal_filterObj, AllTypesParameter, alltypes, bd, true, 1); - private void run_byteQuery( - String filter, - String parameter, - Object parameterValue, - byte value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - byte val = obj.getbyte(); - boolean correct_value = valueOnLeft ? value >= val : val >= value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + BigInteger bi = new BigInteger("987034534985043985"); + run_BigIntegerQuery(BigInteger_filterL, BigIntegerParameter, bi, bi, true, 10); + bi = new BigInteger("-999999999999999999"); + run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, false, 10); + bi = new BigInteger("-9999999999999999999"); + run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, false, 10); + bi = new BigInteger("1333330"); + alltypes.setBigInteger(bi); + run_BigIntegerQuery(BigInteger_filterObj, AllTypesParameter, alltypes, bi, false, 3); + + GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.UK); + gc.clear(); + gc.set(1999, Calendar.DECEMBER, 31, 9, 0, 0); + Date d = gc.getTime(); + run_DateQuery(Date_filterL, DateParameter, d, d, true, 8); + gc.set(1992, Calendar.NOVEMBER, 22, 9, 0, 0); + d = gc.getTime(); + run_DateQuery(Date_filterR, DateParameter, d, d, false, 5); + gc.set(1959, Calendar.OCTOBER, 9, 9, 0, 0); + d = gc.getTime(); + run_DateQuery(Date_filterR, DateParameter, d, d, false, 7); + gc.set(1995, Calendar.JUNE, 14, 9, 0, 0); + d = gc.getTime(); + alltypes.setDate(d); + run_DateQuery(Date_filterObj, AllTypesParameter, alltypes, d, false, 4); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_shortQuery( - String filter, - String parameter, - Object parameterValue, - short value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - short val = obj.getshort(); - boolean correct_value = valueOnLeft ? value >= val : val >= value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_byteQuery(String filter, String parameter, Object parameterValue, + byte value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + byte val = obj.getbyte(); + boolean correct_value = valueOnLeft ? value >= val : val >= value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_charQuery( - String filter, - String parameter, - Object parameterValue, - char value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - char val = obj.getchar(); - boolean correct_value = valueOnLeft ? value >= val : val >= value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_shortQuery(String filter, String parameter, Object parameterValue, + short value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + short val = obj.getshort(); + boolean correct_value = valueOnLeft ? value >= val : val >= value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_intQuery( - String filter, - String parameter, - Object parameterValue, - int value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - int val = obj.getint(); - boolean correct_value = valueOnLeft ? value >= val : val >= value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_charQuery(String filter, String parameter, Object parameterValue, + char value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + char val = obj.getchar(); + boolean correct_value = valueOnLeft ? value >= val : val >= value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_longQuery( - String filter, - String parameter, - Object parameterValue, - long value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - long val = obj.getlong(); - boolean correct_value = valueOnLeft ? value >= val : val >= value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_intQuery(String filter, String parameter, Object parameterValue, + int value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + int val = obj.getint(); + boolean correct_value = valueOnLeft ? value >= val : val >= value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_floatQuery( - String filter, - String parameter, - Object parameterValue, - float value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - float val = obj.getfloat(); - boolean correct_value = valueOnLeft ? value >= val : val >= value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_longQuery(String filter, String parameter, Object parameterValue, + long value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + long val = obj.getlong(); + boolean correct_value = valueOnLeft ? value >= val : val >= value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_doubleQuery( - String filter, - String parameter, - Object parameterValue, - double value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - double val = obj.getdouble(); - boolean correct_value = valueOnLeft ? value >= val : val >= value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_floatQuery(String filter, String parameter, Object parameterValue, + float value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + float val = obj.getfloat(); + boolean correct_value = valueOnLeft ? value >= val : val >= value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_ByteQuery( - String filter, - String parameter, - Object parameterValue, - Byte value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Byte val = obj.getByte(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_doubleQuery(String filter, String parameter, Object parameterValue, + double value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + double val = obj.getdouble(); + boolean correct_value = valueOnLeft ? value >= val : val >= value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_ShortQuery( - String filter, - String parameter, - Object parameterValue, - Short value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Short val = obj.getShort(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_ByteQuery(String filter, String parameter, Object parameterValue, + Byte value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Byte val = obj.getByte(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_CharacterQuery( - String filter, - String parameter, - Object parameterValue, - Character value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Character val = obj.getCharacter(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_ShortQuery(String filter, String parameter, Object parameterValue, + Short value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Short val = obj.getShort(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_IntegerQuery( - String filter, - String parameter, - Object parameterValue, - Integer value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Integer val = obj.getInteger(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_CharacterQuery(String filter, String parameter, Object parameterValue, + Character value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Character val = obj.getCharacter(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_LongQuery( - String filter, - String parameter, - Object parameterValue, - Long value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Long val = obj.getLong(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_IntegerQuery(String filter, String parameter, Object parameterValue, + Integer value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Integer val = obj.getInteger(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_FloatQuery( - String filter, - String parameter, - Object parameterValue, - Float value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Float val = obj.getFloat(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_LongQuery(String filter, String parameter, Object parameterValue, + Long value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Long val = obj.getLong(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_DoubleQuery( - String filter, - String parameter, - Object parameterValue, - Double value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Double val = obj.getDouble(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_FloatQuery(String filter, String parameter, Object parameterValue, + Float value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Float val = obj.getFloat(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_StringQuery( - String filter, - String parameter, - Object parameterValue, - String value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - String val = obj.getString(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_DoubleQuery(String filter, String parameter, Object parameterValue, + Double value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Double val = obj.getDouble(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_BigDecimalQuery( - String filter, - String parameter, - Object parameterValue, - BigDecimal value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - BigDecimal val = obj.getBigDecimal(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_StringQuery(String filter, String parameter, Object parameterValue, + String value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + String val = obj.getString(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_BigIntegerQuery( - String filter, - String parameter, - Object parameterValue, - BigInteger value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - BigInteger val = obj.getBigInteger(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_BigDecimalQuery(String filter, String parameter, Object parameterValue, + BigDecimal value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + BigDecimal val = obj.getBigDecimal(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_DateQuery( - String filter, - String parameter, - Object parameterValue, - Date value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Date val = obj.getDate(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_BigIntegerQuery(String filter, String parameter, Object parameterValue, + BigInteger value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + BigInteger val = obj.getBigInteger(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + + private void run_DateQuery(String filter, String parameter, Object parameterValue, + Date value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Date val = obj.getDate(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) >= 0) : (val.compareTo(value) >= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL GreaterThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - /** */ - protected void localSetUp() { - addTearDownClass(AllTypes.class); - AllTypes.load(getPM()); - } + /** */ + protected void localSetUp() { + addTearDownClass(AllTypes.class); + AllTypes.load(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/Instanceof.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/Instanceof.java index a060fb935..b31d8e069 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/Instanceof.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/Instanceof.java @@ -5,19 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql.operators; -import javax.jdo.JDOQLTypedQuery; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.PartTimeEmployee; @@ -26,94 +26,99 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Instanceof operator.
    - * Keywords: query
    - * Assertion ID: A14.6.2-41.
    - * Assertion Description: instanceof operator + *Title: Instanceof operator. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-41. + *
    + *Assertion Description: + * instanceof operator */ public class Instanceof extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.2-41 (Instanceof) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Instanceof.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-41 (Instanceof) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Instanceof.class); + } - public void testPositive1() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp2", "emp3"}); + public void testPositive1() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp2", "emp3"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.filter(cand.mentor.instanceOf(PartTimeEmployee.class)); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.filter(cand.mentor.instanceOf(PartTimeEmployee.class)); - // Import Department twice - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "mentor instanceof org.apache.jdo.tck.pc.company.PartTimeEmployee", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + // Import Department twice + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "mentor instanceof org.apache.jdo.tck.pc.company.PartTimeEmployee", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } - public void testPositive2() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp2", "emp3"}); + public void testPositive2() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp2", "emp3"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.filter(cand.mentor.instanceOf(PartTimeEmployee.class)); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.filter(cand.mentor.instanceOf(PartTimeEmployee.class)); - // Import Department twice - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "mentor instanceof PartTimeEmployee", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.PartTimeEmployee", - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + // Import Department twice + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "mentor instanceof PartTimeEmployee", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ "import org.apache.jdo.tck.pc.company.PartTimeEmployee", + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/LessThan.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/LessThan.java index 7493509cf..d29205eba 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/LessThan.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/LessThan.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -25,2352 +25,1177 @@ import java.util.Iterator; import java.util.Locale; import java.util.TimeZone; + import org.apache.jdo.tck.pc.fieldtypes.AllTypes; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Less Than Query Operator
    - * Keywords: query
    - * Assertion ID: A14.6.2-17.
    - * Assertion Description: The less than operator (<) is supported for all - * types as they are defined in the Java language. This includes the following types: - * - *
      - *
    • byte, short, int, long, char, Byte, Short Integer, Long, Character - *
    • float, double, Float, Double - *
    • BigDecimal, BigInteger - *
    • Date, String - *
    - * - * The operation on object-valued fields of wrapper types (Boolean, Byte, - * Short, Integer, Long, Float, and Double), and numeric types (BigDecimal - * and BigInteger) use the wrapped values as operands. - */ -public class LessThan extends ComparisonTests { - private static String boolean_filterL = "value < fld_boolean"; - private static String boolean_filterR = "fld_boolean < value"; - private static String boolean_filterT = "fld_boolean < true"; - private static String boolean_filterF = "false < fld_boolean"; - private static String boolean_filterObj = "value.fld_boolean < fld_boolean"; - - private static String byte_filterL = "value < fld_byte"; - private static String byte_filterR = "fld_byte < value"; - private static String byte_filterObj = "value.fld_byte < fld_byte"; - private static String byte_filterVal = "fld_byte < 100"; - - private static String char_filterL = "value < fld_char"; - private static String char_filterR = "fld_char < value"; - private static String char_filterObj = "value.fld_char < fld_char"; - private static String char_filterVal = "'M' < fld_char"; - - private static String double_filterL = "value < fld_double"; - private static String double_filterR = "fld_double < value"; - private static String double_filterObj = "value.fld_double < fld_double"; - private static String double_filterVal = "fld_double < 100.0"; - - private static String float_filterL = "value < fld_float"; - private static String float_filterR = "fld_float < value"; - private static String float_filterObj = "fld_float < value.fld_float"; - private static String float_filterVal = "fld_float < 100.0"; - - private static String int_filterL = "value < fld_int"; - private static String int_filterR = "fld_int < value"; - private static String int_filterObj = "value.fld_int < fld_int"; - private static String int_filterVal = "fld_int < 1000"; - - private static String long_filterL = "value < fld_long"; - private static String long_filterR = "fld_long < value"; - private static String long_filterObj = "fld_long < value.fld_long"; - private static String long_filterVal = "fld_long < 1000000"; - - private static String short_filterL = "value < fld_short"; - private static String short_filterR = "fld_short < value"; - private static String short_filterObj = "value.fld_short < fld_short"; - private static String short_filterVal = "1000 < fld_short"; - - private static String Boolean_filterL = "value < fld_Boolean"; - private static String Boolean_filterR = "fld_Boolean < value"; - private static String Boolean_filterT = "fld_Boolean < true"; - private static String Boolean_filterF = "false < fld_Boolean"; - private static String Boolean_filterObj = "value.fld_Boolean < fld_Boolean"; - private static String Boolean_filterVal = "fld_Boolean < false"; - - private static String Byte_filterL = "value < fld_Byte"; - private static String Byte_filterR = "fld_Byte < value"; - private static String Byte_filterObj = "fld_Byte < value.fld_Byte"; - private static String Byte_filterVal = "100 < fld_Byte"; - - private static String Character_filterL = "value < fld_Character"; - private static String Character_filterR = "fld_Character < value"; - private static String Character_filterObj = "value.fld_Character < fld_Character"; - private static String Character_filterVal = "fld_Character < 'z'"; - - private static String Double_filterL = "value < fld_Double"; - private static String Double_filterR = "fld_Double < value"; - private static String Double_filterObj = "value.fld_Double < fld_Double"; - private static String Double_filterVal = "fld_Double < 100.0"; - - private static String Float_filterL = "value < fld_Float"; - private static String Float_filterR = "fld_Float < value"; - private static String Float_filterObj = "fld_Float < value.fld_Float"; - private static String Float_filterVal = "100.0f < fld_Float"; - - private static String Integer_filterL = "value < fld_Integer"; - private static String Integer_filterR = "fld_Integer < value"; - private static String Integer_filterObj = "fld_Integer < value.fld_Integer"; - private static String Integer_filterVal = "fld_Integer < 100"; - - private static String Long_filterL = "value < fld_Long"; - private static String Long_filterR = "fld_Long < value"; - private static String Long_filterObj = "value.fld_Long < fld_Long"; - private static String Long_filterVal = "-1000 < fld_Long"; - - private static String Short_filterL = "value < fld_Short"; - private static String Short_filterR = "fld_Short < value"; - private static String Short_filterObj = "fld_Short < value.fld_Short"; - private static String Short_filterVal = "-1000 < fld_Short"; - - private static String String_filterL = "value < fld_String"; - private static String String_filterR = "fld_String < value"; - private static String String_filterObj = "value.fld_String < fld_String"; - private static String String_filterVal1 = "fld_String < \"Java\""; - private static String String_filterVal2 = "fld_String < \"\""; - - private static String Date_filterL = "value < fld_Date"; - private static String Date_filterR = "fld_Date < value"; - private static String Date_filterObj = "fld_Date < value.fld_Date"; - - private static String BigDecimal_filterL = "value < fld_BigDecimal"; - private static String BigDecimal_filterR = "fld_BigDecimal < value"; - private static String BigDecimal_filterObj = "value.fld_BigDecimal < fld_BigDecimal"; - - private static String BigInteger_filterL = "value < fld_BigInteger"; - private static String BigInteger_filterR = "fld_BigInteger < value"; - private static String BigInteger_filterObj = "fld_BigInteger < value.fld_BigInteger"; - - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.2-17 (LessThan) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(LessThan.class); - } - - /** */ - public void test() { - pm = getPM(); - tx = pm.currentTransaction(); - runQueries(); - } - - /** */ - private void runQueries() { - AllTypes alltypes = new AllTypes(); - run_byteQuery(byte_filterL, byteParameter, Byte.valueOf((byte) 0), (byte) 0, true, 6); - run_byteQuery( - byte_filterR, byteParameter, Byte.valueOf(Byte.MIN_VALUE), Byte.MIN_VALUE, false, 0); - run_byteQuery(byte_filterL, ByteParameter, Byte.valueOf((byte) 50), (byte) 50, true, 3); - run_byteQuery( - byte_filterR, ByteParameter, Byte.valueOf(Byte.MAX_VALUE), Byte.MAX_VALUE, false, 9); - run_byteQuery(byte_filterL, shortParameter, Short.valueOf((short) 75), (byte) 75, true, 2); - run_byteQuery(byte_filterR, shortParameter, Short.valueOf((short) 75), (byte) 75, false, 7); - run_byteQuery(byte_filterL, ShortParameter, Short.valueOf((short) 10), (byte) 10, true, 5); - run_byteQuery(byte_filterR, ShortParameter, Short.valueOf((short) 25), (byte) 25, false, 5); - run_byteQuery(byte_filterL, charParameter, Character.valueOf((char) 101), (byte) 101, true, 1); - run_byteQuery(byte_filterR, charParameter, Character.valueOf((char) 50), (byte) 50, false, 5); - run_byteQuery(byte_filterL, CharacterParameter, Character.valueOf((char) 0), (byte) 0, true, 6); - run_byteQuery( - byte_filterR, CharacterParameter, Character.valueOf((char) 0), (byte) 0, false, 3); - run_byteQuery(byte_filterL, intParameter, Integer.valueOf(25), (byte) 25, true, 5); - run_byteQuery(byte_filterR, intParameter, Integer.valueOf(50), (byte) 50, false, 5); - run_byteQuery(byte_filterL, IntegerParameter, Integer.valueOf(-10), (byte) -10, true, 7); - run_byteQuery(byte_filterR, IntegerParameter, Integer.valueOf(-100), (byte) -100, false, 1); - run_byteQuery(byte_filterL, longParameter, Long.valueOf(50), (byte) 50, true, 3); - run_byteQuery(byte_filterR, longParameter, Long.valueOf(60), (byte) 60, false, 7); - run_byteQuery(byte_filterL, LongParameter, Long.valueOf(-100), (byte) -100, true, 8); - run_byteQuery(byte_filterR, LongParameter, Long.valueOf(-100), (byte) -100, false, 1); - run_byteQuery(byte_filterL, floatParameter, Float.valueOf((float) 51), (byte) 51, true, 3); - run_byteQuery(byte_filterR, floatParameter, Float.valueOf((float) -20), (byte) -20, false, 2); - run_byteQuery(byte_filterL, FloatParameter, Float.valueOf((float) -99), (byte) -99, true, 8); - run_byteQuery(byte_filterR, FloatParameter, Float.valueOf((float) -100), (byte) -100, false, 1); - run_byteQuery(byte_filterL, doubleParameter, Double.valueOf(50), (byte) 50, true, 3); - run_byteQuery(byte_filterR, doubleParameter, Double.valueOf(60), (byte) 60, false, 7); - run_byteQuery( - byte_filterL, DoubleParameter, Double.valueOf(Byte.MAX_VALUE), Byte.MAX_VALUE, true, 0); - run_byteQuery(byte_filterR, DoubleParameter, Double.valueOf(25), (byte) 25, false, 5); - run_byteQuery(byte_filterL, BigIntegerParameter, new BigInteger("50"), (byte) 50, true, 3); - run_byteQuery(byte_filterR, BigIntegerParameter, new BigInteger("-100"), (byte) -100, false, 1); - run_byteQuery( - byte_filterL, BigDecimalParameter, new BigDecimal("50.000000"), (byte) 50, true, 3); - run_byteQuery( - byte_filterR, BigDecimalParameter, new BigDecimal("10.00000"), (byte) 10, false, 4); - alltypes.setbyte((byte) 50); - run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte) 50, true, 3); - alltypes.setbyte((byte) 55); - run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte) 55, true, 3); - run_byteQuery(byte_filterVal, null, null, (byte) 100, false, 8); - - run_shortQuery(short_filterL, shortParameter, Short.valueOf((short) 100), (short) 100, true, 3); - run_shortQuery( - short_filterR, shortParameter, Short.valueOf((short) 100), (short) 100, false, 5); - run_shortQuery( - short_filterL, ShortParameter, Short.valueOf(Short.MIN_VALUE), Short.MIN_VALUE, true, 9); - run_shortQuery( - short_filterR, ShortParameter, Short.valueOf((short) 253), (short) 253, false, 7); - run_shortQuery( - short_filterR, shortParameter, Short.valueOf((short) 1000), (short) 1000, false, 7); - run_shortQuery(short_filterL, byteParameter, Byte.valueOf((byte) 75), (short) 75, true, 5); - run_shortQuery(short_filterR, byteParameter, Byte.valueOf((byte) -75), (short) -75, false, 4); - run_shortQuery(short_filterL, ByteParameter, Byte.valueOf((byte) 100), (short) 100, true, 3); - run_shortQuery(short_filterR, ByteParameter, Byte.valueOf((byte) 100), (short) 100, false, 5); - run_shortQuery(short_filterL, charParameter, Character.valueOf((char) 75), (short) 75, true, 5); - run_shortQuery( - short_filterR, charParameter, Character.valueOf((char) 9999), (short) 9999, false, 8); - run_shortQuery( - short_filterL, CharacterParameter, Character.valueOf((char) 1000), (short) 1000, true, 2); - run_shortQuery( - short_filterR, - CharacterParameter, - Character.valueOf((char) 10000), - (short) 10000, - false, - 8); - run_shortQuery(short_filterL, intParameter, Integer.valueOf(-10000), (short) -10000, true, 8); - run_shortQuery(short_filterR, intParameter, Integer.valueOf(-10000), (short) -10000, false, 1); - run_shortQuery(short_filterL, IntegerParameter, Integer.valueOf(10000), (short) 10000, true, 1); - run_shortQuery( - short_filterR, IntegerParameter, Integer.valueOf(30000), (short) 30000, false, 9); - run_shortQuery(short_filterL, longParameter, Long.valueOf(10000), (short) 10000, true, 1); - run_shortQuery( - short_filterR, longParameter, Long.valueOf(Short.MAX_VALUE), Short.MAX_VALUE, false, 9); - run_shortQuery( - short_filterL, LongParameter, Long.valueOf(Short.MAX_VALUE), Short.MAX_VALUE, true, 0); - run_shortQuery(short_filterR, LongParameter, Long.valueOf(100), (short) 100, false, 5); - run_shortQuery( - short_filterL, floatParameter, Float.valueOf((float) 23000), (short) 23000, true, 1); - run_shortQuery( - short_filterR, floatParameter, Float.valueOf((float) 23000), (short) 23000, false, 9); - run_shortQuery( - short_filterL, FloatParameter, Float.valueOf((float) -1000), (short) -1000, true, 7); - run_shortQuery( - short_filterR, FloatParameter, Float.valueOf((float) 100), (short) 100, false, 5); - run_shortQuery( - short_filterL, doubleParameter, Double.valueOf(-10000.0), (short) -10000, true, 8); - run_shortQuery(short_filterR, doubleParameter, Double.valueOf(9999.0), (short) 9999, false, 8); - run_shortQuery(short_filterL, DoubleParameter, Double.valueOf(23.0), (short) 23, true, 5); - run_shortQuery(short_filterR, DoubleParameter, Double.valueOf(23.0), (short) 23, false, 5); - run_shortQuery( - short_filterL, BigIntegerParameter, new BigInteger("10000"), (short) 10000, true, 1); - run_shortQuery( - short_filterR, BigIntegerParameter, new BigInteger("30000"), (short) 30000, false, 9); - run_shortQuery(short_filterL, BigDecimalParameter, new BigDecimal("23.0"), (short) 23, true, 5); - run_shortQuery( - short_filterR, BigDecimalParameter, new BigDecimal("23.0"), (short) 23, false, 5); - alltypes.setshort((short) 100); - run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short) 100, true, 3); - alltypes.setshort((short) 23); - run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short) 23, true, 5); - run_shortQuery(short_filterVal, null, null, (short) 1000, true, 2); - - run_charQuery( - char_filterL, - charParameter, - Character.valueOf(Character.MIN_VALUE), - Character.MIN_VALUE, - true, - 9); - run_charQuery( - char_filterR, - charParameter, - Character.valueOf(Character.MAX_VALUE), - Character.MAX_VALUE, - false, - 9); - run_charQuery(char_filterL, charParameter, Character.valueOf('C'), 'C', true, 6); - run_charQuery(char_filterR, charParameter, Character.valueOf('z'), 'z', false, 7); - run_charQuery(char_filterL, CharacterParameter, Character.valueOf(' '), ' ', true, 8); - run_charQuery(char_filterR, CharacterParameter, Character.valueOf('f'), 'f', false, 7); - run_charQuery( - char_filterL, - byteParameter, - Byte.valueOf((byte) Character.MIN_VALUE), - (char) Character.MIN_VALUE, - true, - 9); - run_charQuery(char_filterR, ByteParameter, Byte.valueOf((byte) 'a'), 'a', false, 7); - run_charQuery(char_filterL, shortParameter, Short.valueOf((short) 'M'), 'M', true, 3); - run_charQuery(char_filterR, shortParameter, Short.valueOf((short) 'M'), 'M', false, 5); - run_charQuery(char_filterL, ShortParameter, Short.valueOf((short) 'A'), 'A', true, 7); - run_charQuery(char_filterR, ShortParameter, Short.valueOf((short) 'A'), 'A', false, 2); - run_charQuery(char_filterL, intParameter, Integer.valueOf('z'), 'z', true, 1); - run_charQuery(char_filterR, intParameter, Integer.valueOf('z'), 'z', false, 7); - run_charQuery(char_filterL, IntegerParameter, Integer.valueOf('B'), 'B', true, 6); - run_charQuery(char_filterR, IntegerParameter, Integer.valueOf('B'), 'B', false, 3); - run_charQuery(char_filterL, floatParameter, Float.valueOf((float) 'f'), 'f', true, 3); - run_charQuery(char_filterR, floatParameter, Float.valueOf((float) ' '), ' ', false, 1); - run_charQuery(char_filterL, FloatParameter, Float.valueOf((float) 'z'), 'z', true, 1); - run_charQuery(char_filterR, FloatParameter, Float.valueOf((float) 'z'), 'z', false, 7); - run_charQuery(char_filterL, doubleParameter, Double.valueOf('B'), 'B', true, 6); - run_charQuery(char_filterR, doubleParameter, Double.valueOf('B'), 'B', false, 3); - run_charQuery(char_filterL, DoubleParameter, Double.valueOf('A'), 'A', true, 7); - run_charQuery(char_filterR, DoubleParameter, Double.valueOf('A'), 'A', false, 2); - run_charQuery( - char_filterL, BigIntegerParameter, new BigInteger("65"), 'A', true, 7); // 'A' == 65 - run_charQuery( - char_filterR, BigIntegerParameter, new BigInteger("122"), 'z', false, 7); // 'z' == 122 - run_charQuery(char_filterL, BigDecimalParameter, new BigDecimal("65.00000"), 'A', true, 7); - run_charQuery( - char_filterR, BigDecimalParameter, new BigDecimal("77.0000"), 'M', false, 5); // 'M' == 77 - alltypes.setchar('A'); - run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'A', true, 7); - alltypes.setchar('b'); - run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'b', true, 3); - run_charQuery(char_filterVal, null, null, 'M', true, 3); - - run_intQuery( - int_filterL, - intParameter, - Integer.valueOf(AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - true, - 9); - run_intQuery( - int_filterR, - intParameter, - Integer.valueOf(AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - false, - 9); - run_intQuery(int_filterR, intParameter, Integer.valueOf(23), 23, false, 4); - run_intQuery(int_filterL, IntegerParameter, Integer.valueOf(1000000), 1000000, true, 1); - run_intQuery(int_filterR, IntegerParameter, Integer.valueOf(1000), 1000, false, 6); - run_intQuery(int_filterL, byteParameter, Byte.valueOf((byte) 100), 100, true, 4); - run_intQuery(int_filterR, byteParameter, Byte.valueOf((byte) 0), 0, false, 3); - run_intQuery(int_filterL, ByteParameter, Byte.valueOf((byte) 100), 100, true, 4); - run_intQuery(int_filterR, ByteParameter, Byte.valueOf((byte) 0), 0, false, 3); - run_intQuery(int_filterL, shortParameter, Short.valueOf((short) 10000), 10000, true, 2); - run_intQuery(int_filterR, shortParameter, Short.valueOf((short) -1000), -1000, false, 2); - run_intQuery(int_filterL, ShortParameter, Short.valueOf((short) -1000), -1000, true, 7); - run_intQuery(int_filterR, ShortParameter, Short.valueOf((short) 10000), 10000, false, 7); - run_intQuery(int_filterL, charParameter, Character.valueOf((char) 100), 100, true, 4); - run_intQuery(int_filterR, charParameter, Character.valueOf((char) 0), 0, false, 3); - run_intQuery(int_filterL, CharacterParameter, Character.valueOf((char) 100), 100, true, 4); - run_intQuery(int_filterR, CharacterParameter, Character.valueOf((char) 10000), 10000, false, 7); - run_intQuery( - int_filterL, - longParameter, - Long.valueOf(AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - true, - 0); - run_intQuery( - int_filterR, - longParameter, - Long.valueOf(AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - false, - 0); - run_intQuery(int_filterL, LongParameter, Long.valueOf(10000), 10000, true, 2); - run_intQuery(int_filterR, LongParameter, Long.valueOf(43), 43, false, 4); - run_intQuery( - int_filterL, - floatParameter, - Float.valueOf((float) AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - true, - 0); - run_intQuery( - int_filterR, - floatParameter, - Float.valueOf((float) AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - false, - 0); - run_intQuery(int_filterL, FloatParameter, Float.valueOf((float) 10000), 10000, true, 2); - run_intQuery(int_filterR, FloatParameter, Float.valueOf((float) 43), 43, false, 4); - run_intQuery( - int_filterL, - doubleParameter, - Double.valueOf(AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - true, - 0); - run_intQuery( - int_filterR, - doubleParameter, - Double.valueOf(AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - false, - 0); - run_intQuery(int_filterL, DoubleParameter, Double.valueOf(10000), 10000, true, 2); - run_intQuery(int_filterR, DoubleParameter, Double.valueOf(43), 43, false, 4); - run_intQuery(int_filterL, BigIntegerParameter, new BigInteger("1000000"), 1000000, true, 1); - run_intQuery(int_filterR, BigIntegerParameter, new BigInteger("1000"), 1000, false, 6); - run_intQuery(int_filterL, BigDecimalParameter, new BigDecimal("10000.0"), 10000, true, 2); - run_intQuery(int_filterR, BigDecimalParameter, new BigDecimal("43.0"), 43, false, 4); - alltypes.setint(100); - run_intQuery(int_filterObj, AllTypesParameter, alltypes, 100, true, 4); - run_intQuery(int_filterVal, null, null, 1000, false, 6); + *Title: Less Than Query Operator + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-17. + *
    + *Assertion Description: +The less than operator (<) is supported for all types as they +are defined in the Java language. This includes the following types: +
      +
    • byte, short, int, long, char, Byte, Short Integer, Long, Character
    • +
    • float, double, Float, Double
    • +
    • BigDecimal, BigInteger
    • +
    • Date, String
    • +
    +The operation on object-valued fields of wrapper types (Boolean, Byte, +Short, Integer, Long, Float, and Double), and numeric types +(BigDecimal and BigInteger) +use the wrapped values as operands. - run_longQuery( - long_filterL, longParameter, Long.valueOf(Long.MIN_VALUE), Long.MIN_VALUE, true, 9); - run_longQuery( - long_filterR, longParameter, Long.valueOf(Long.MAX_VALUE), Long.MAX_VALUE, false, 9); - run_longQuery(long_filterL, LongParameter, Long.valueOf(100), 100, true, 3); - run_longQuery(long_filterR, LongParameter, Long.valueOf(23), 23, false, 5); - run_longQuery(long_filterL, byteParameter, Byte.valueOf((byte) 100), 100, true, 3); - run_longQuery(long_filterR, byteParameter, Byte.valueOf((byte) 0), 0, false, 4); - run_longQuery(long_filterL, ByteParameter, Byte.valueOf((byte) 100), 100, true, 3); - run_longQuery(long_filterR, ByteParameter, Byte.valueOf((byte) 0), 0, false, 4); - run_longQuery(long_filterL, shortParameter, Short.valueOf((short) -1000), -1000, true, 6); - run_longQuery(long_filterR, shortParameter, Short.valueOf((short) 1000), 1000, false, 7); - run_longQuery(long_filterL, ShortParameter, Short.valueOf((short) 100), 100, true, 3); - run_longQuery(long_filterR, ShortParameter, Short.valueOf((short) 32), 32, false, 5); - run_longQuery(long_filterL, charParameter, Character.valueOf((char) 0), 0, true, 5); - run_longQuery(long_filterR, charParameter, Character.valueOf((char) 100), 100, false, 5); - run_longQuery(long_filterL, CharacterParameter, Character.valueOf((char) 23), 23, true, 5); - run_longQuery(long_filterR, CharacterParameter, Character.valueOf((char) 0), 0, false, 4); - run_longQuery(long_filterL, intParameter, Integer.valueOf(100), 100, true, 3); - run_longQuery(long_filterR, intParameter, Integer.valueOf(0), 0, false, 4); - run_longQuery(long_filterL, IntegerParameter, Integer.valueOf(23), 23, true, 5); - run_longQuery(long_filterR, IntegerParameter, Integer.valueOf(1000000), 1000000, false, 8); - run_longQuery( - long_filterL, floatParameter, Float.valueOf((float) -1000000.0), -1000000, true, 8); - run_longQuery( - long_filterR, - floatParameter, - Float.valueOf((float) Long.MAX_VALUE), - Long.MAX_VALUE, - false, - 9); - run_longQuery(long_filterL, FloatParameter, Float.valueOf((float) 100.0), 100, true, 3); - run_longQuery(long_filterR, FloatParameter, Float.valueOf((float) 32.0), 32, false, 5); - run_longQuery(long_filterL, doubleParameter, Double.valueOf(-1000000.0), -1000000, true, 8); - run_longQuery( - long_filterR, - doubleParameter, - Double.valueOf((double) Long.MAX_VALUE), - Long.MAX_VALUE, - false, - 9); - run_longQuery(long_filterL, DoubleParameter, Double.valueOf(100.0), 100, true, 3); - run_longQuery(long_filterR, DoubleParameter, Double.valueOf(32.0), 32, false, 5); - run_longQuery(long_filterL, BigIntegerParameter, new BigInteger("23"), 23, true, 5); - run_longQuery(long_filterR, BigIntegerParameter, new BigInteger("1000000"), 1000000, false, 8); - run_longQuery(long_filterL, BigDecimalParameter, new BigDecimal("100.0"), 100, true, 3); - run_longQuery(long_filterR, BigDecimalParameter, new BigDecimal("32.0"), 32, false, 5); - alltypes.setlong(100); - run_longQuery(long_filterObj, AllTypesParameter, alltypes, 100, false, 5); - run_longQuery(long_filterVal, null, null, 1000000, false, 8); - - run_floatQuery( - float_filterL, - floatParameter, - Float.valueOf((float) AllTypes.FLOAT_SMALLEST), - AllTypes.FLOAT_SMALLEST, - true, - 9); - run_floatQuery( - float_filterR, - floatParameter, - Float.valueOf((float) AllTypes.FLOAT_LARGEST), - AllTypes.FLOAT_LARGEST, - false, - 9); - run_floatQuery(float_filterL, FloatParameter, Float.valueOf(4.0f), 4.0f, true, 6); - run_floatQuery(float_filterR, FloatParameter, Float.valueOf(400.0f), 400.0f, false, 7); - run_floatQuery(float_filterL, byteParameter, Byte.valueOf((byte) 4), 4.0f, true, 6); - run_floatQuery(float_filterR, byteParameter, Byte.valueOf((byte) 23), 23.0f, false, 4); - run_floatQuery(float_filterL, ByteParameter, Byte.valueOf((byte) 34), 34.0f, true, 6); - run_floatQuery(float_filterR, ByteParameter, Byte.valueOf((byte) 100), 100.0f, false, 4); - run_floatQuery(float_filterL, shortParameter, Short.valueOf((short) 10), 10.0f, true, 6); - run_floatQuery(float_filterR, shortParameter, Short.valueOf((short) 23), 23.0f, false, 4); - run_floatQuery(float_filterL, ShortParameter, Short.valueOf((short) 34), 34.0f, true, 6); - run_floatQuery(float_filterR, ShortParameter, Short.valueOf((short) 100), 100.0f, false, 4); - run_floatQuery(float_filterL, charParameter, Character.valueOf((char) 20), 20.0f, true, 6); - run_floatQuery(float_filterR, charParameter, Character.valueOf((char) 23), 23.0f, false, 4); - run_floatQuery(float_filterL, CharacterParameter, Character.valueOf((char) 34), 34.0f, true, 6); - run_floatQuery( - float_filterR, CharacterParameter, Character.valueOf((char) 100), 100.0f, false, 4); - run_floatQuery(float_filterL, intParameter, Integer.valueOf(55000000), 55000000.0f, true, 2); - run_floatQuery(float_filterR, intParameter, Integer.valueOf(23), 23.0f, false, 4); - run_floatQuery(float_filterL, IntegerParameter, Integer.valueOf(34), 34.0f, true, 6); - run_floatQuery(float_filterR, IntegerParameter, Integer.valueOf(100), 100.0f, false, 4); - run_floatQuery(float_filterL, longParameter, Long.valueOf(55000000), 55000000.0f, true, 2); - run_floatQuery(float_filterR, longParameter, Long.valueOf(23), 23.0f, false, 4); - run_floatQuery(float_filterL, LongParameter, Long.valueOf(34), 34.0f, true, 6); - run_floatQuery(float_filterR, LongParameter, Long.valueOf(100), 100.0f, false, 4); - run_floatQuery( - float_filterL, doubleParameter, Double.valueOf(55000000.0), 55000000.0f, true, 2); - run_floatQuery(float_filterR, doubleParameter, Double.valueOf(-20.5), -20.5f, false, 3); - run_floatQuery(float_filterL, DoubleParameter, Double.valueOf(2.0), 2.0f, true, 6); - run_floatQuery(float_filterR, DoubleParameter, Double.valueOf(100.0), 100.0f, false, 4); - run_floatQuery( - float_filterL, BigIntegerParameter, new BigInteger("55000000"), 55000000.0f, true, 2); - run_floatQuery(float_filterR, BigIntegerParameter, new BigInteger("23"), 23.0f, false, 4); - run_floatQuery( - float_filterL, BigDecimalParameter, new BigDecimal("55000000.0"), 55000000.0f, true, 2); - run_floatQuery(float_filterR, BigDecimalParameter, new BigDecimal("-20.5"), -20.5f, false, 3); - alltypes.setfloat(23.23f); - run_floatQuery(float_filterObj, AllTypesParameter, alltypes, 23.23f, false, 4); - run_floatQuery(float_filterVal, null, null, 100.0f, false, 4); - - run_doubleQuery( - double_filterL, - doubleParameter, - Double.valueOf(AllTypes.DOUBLE_SMALLEST), - AllTypes.DOUBLE_SMALLEST, - true, - 9); - run_doubleQuery( - double_filterR, - doubleParameter, - Double.valueOf(AllTypes.DOUBLE_LARGEST), - AllTypes.DOUBLE_LARGEST, - false, - 9); - run_doubleQuery(double_filterL, DoubleParameter, Double.valueOf(0.0), 0.0, true, 6); - run_doubleQuery(double_filterR, DoubleParameter, Double.valueOf(23.34), 23.34, false, 4); - run_doubleQuery(double_filterL, byteParameter, Byte.valueOf((byte) 100), 100.0, true, 4); - run_doubleQuery(double_filterR, byteParameter, Byte.valueOf((byte) 0), 0.0, false, 3); - run_doubleQuery(double_filterL, ByteParameter, Byte.valueOf((byte) 23), 23.0, true, 6); - run_doubleQuery(double_filterR, ByteParameter, Byte.valueOf((byte) 100), 100.0, false, 4); - run_doubleQuery(double_filterL, charParameter, Character.valueOf((char) 100), 100.0, true, 4); - run_doubleQuery(double_filterR, charParameter, Character.valueOf((char) 0), 0.0, false, 3); - run_doubleQuery( - double_filterL, CharacterParameter, Character.valueOf((char) 23), 23.0, true, 6); - run_doubleQuery( - double_filterR, CharacterParameter, Character.valueOf((char) 100), 100.0, false, 4); - run_doubleQuery(double_filterL, shortParameter, Short.valueOf((short) 100), 100.0, true, 4); - run_doubleQuery(double_filterR, shortParameter, Short.valueOf((short) 0), 0.0, false, 3); - run_doubleQuery(double_filterL, ShortParameter, Short.valueOf((short) 23), 23.0, true, 6); - run_doubleQuery(double_filterR, ShortParameter, Short.valueOf((short) 100), 100.0, false, 4); - run_doubleQuery(double_filterL, intParameter, Integer.valueOf(100), 100.0, true, 4); - run_doubleQuery(double_filterR, intParameter, Integer.valueOf(0), 0.0, false, 3); - run_doubleQuery(double_filterL, IntegerParameter, Integer.valueOf(5000), 5000.0, true, 3); - run_doubleQuery(double_filterR, IntegerParameter, Integer.valueOf(-20), -20.0, false, 3); - run_doubleQuery(double_filterL, longParameter, Long.valueOf(100), 100.0, true, 4); - run_doubleQuery(double_filterR, longParameter, Long.valueOf(0), 0.0, false, 3); - run_doubleQuery(double_filterL, LongParameter, Long.valueOf(5000), 5000.0, true, 3); - run_doubleQuery(double_filterR, LongParameter, Long.valueOf(-20), -20.0, false, 3); - run_doubleQuery(double_filterL, floatParameter, Float.valueOf(0.0f), 0.0f, true, 6); - run_doubleQuery(double_filterR, floatParameter, Float.valueOf(100.0f), 100.0f, false, 4); - run_doubleQuery(double_filterL, FloatParameter, Float.valueOf(100.0f), 100.0, true, 4); - run_doubleQuery(double_filterR, FloatParameter, Float.valueOf(69.96f), 69.96, false, 4); - run_doubleQuery(double_filterL, BigIntegerParameter, new BigInteger("5000"), 5000.0, true, 3); - run_doubleQuery(double_filterR, BigIntegerParameter, new BigInteger("-20"), -20.0, false, 3); - run_doubleQuery(double_filterL, BigDecimalParameter, new BigDecimal("100.0"), 100.0, true, 4); - run_doubleQuery(double_filterR, BigDecimalParameter, new BigDecimal("69.96"), 69.96, false, 4); - alltypes.setdouble(-25.5); - run_doubleQuery(double_filterObj, AllTypesParameter, alltypes, -25.5, true, 7); - run_doubleQuery(double_filterVal, null, null, 100.0, false, 4); - - run_ByteQuery( - Byte_filterL, byteParameter, Byte.valueOf((byte) 50), Byte.valueOf((byte) 50), true, 3); - run_ByteQuery( - Byte_filterR, - byteParameter, - Byte.valueOf(Byte.MIN_VALUE), - Byte.valueOf(Byte.MIN_VALUE), - false, - 0); - run_ByteQuery( - Byte_filterL, ByteParameter, Byte.valueOf((byte) 20), Byte.valueOf((byte) 20), true, 5); - run_ByteQuery( - Byte_filterR, - ByteParameter, - Byte.valueOf(Byte.MAX_VALUE), - Byte.valueOf(Byte.MAX_VALUE), - false, - 9); - run_ByteQuery( - Byte_filterL, shortParameter, Short.valueOf((short) 60), Byte.valueOf((byte) 60), true, 3); - run_ByteQuery( - Byte_filterR, shortParameter, Short.valueOf((short) 51), Byte.valueOf((byte) 51), false, 7); - run_ByteQuery( - Byte_filterL, - ShortParameter, - Short.valueOf((short) -100), - Byte.valueOf((byte) -100), - true, - 8); - run_ByteQuery( - Byte_filterR, - ShortParameter, - Short.valueOf((short) -100), - Byte.valueOf((byte) -100), - false, - 1); - run_ByteQuery( - Byte_filterL, - charParameter, - Character.valueOf((char) 101), - Byte.valueOf((byte) 101), - true, - 1); - run_ByteQuery( - Byte_filterR, - charParameter, - Character.valueOf((char) 10), - Byte.valueOf((byte) 10), - false, - 4); - run_ByteQuery( - Byte_filterL, - CharacterParameter, - Character.valueOf((char) 50), - Byte.valueOf((byte) 50), - true, - 3); - run_ByteQuery( - Byte_filterR, - CharacterParameter, - Character.valueOf((char) 75), - Byte.valueOf((byte) 75), - false, - 7); - run_ByteQuery( - Byte_filterL, intParameter, Integer.valueOf(77), Byte.valueOf((byte) 77), true, 2); - run_ByteQuery( - Byte_filterR, intParameter, Integer.valueOf(60), Byte.valueOf((byte) 60), false, 7); - run_ByteQuery( - Byte_filterL, IntegerParameter, Integer.valueOf(40), Byte.valueOf((byte) 40), true, 5); - run_ByteQuery( - Byte_filterR, IntegerParameter, Integer.valueOf(75), Byte.valueOf((byte) 75), false, 7); - run_ByteQuery(Byte_filterL, longParameter, Long.valueOf(50), Byte.valueOf((byte) 50), true, 3); - run_ByteQuery(Byte_filterR, longParameter, Long.valueOf(50), Byte.valueOf((byte) 50), false, 5); - run_ByteQuery( - Byte_filterL, LongParameter, Long.valueOf(-100), Byte.valueOf((byte) -100), true, 8); - run_ByteQuery( - Byte_filterR, LongParameter, Long.valueOf(-100), Byte.valueOf((byte) -100), false, 1); - run_ByteQuery( - Byte_filterL, floatParameter, Float.valueOf((float) 50), Byte.valueOf((byte) 50), true, 3); - run_ByteQuery( - Byte_filterR, floatParameter, Float.valueOf((float) 50), Byte.valueOf((byte) 50), false, 5); - run_ByteQuery( - Byte_filterL, - FloatParameter, - Float.valueOf((float) -100), - Byte.valueOf((byte) -100), - true, - 8); - run_ByteQuery( - Byte_filterR, - FloatParameter, - Float.valueOf((float) -100), - Byte.valueOf((byte) -100), - false, - 1); - run_ByteQuery( - Byte_filterL, doubleParameter, Double.valueOf(50), Byte.valueOf((byte) 50), true, 3); - run_ByteQuery( - Byte_filterR, doubleParameter, Double.valueOf(50), Byte.valueOf((byte) 50), false, 5); - run_ByteQuery( - Byte_filterL, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte) -100), true, 8); - run_ByteQuery( - Byte_filterR, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte) -100), false, 1); - run_ByteQuery( - Byte_filterL, BigIntegerParameter, new BigInteger("50"), Byte.valueOf((byte) 50), true, 3); - run_ByteQuery( - Byte_filterR, - BigIntegerParameter, - new BigInteger("-100"), - Byte.valueOf((byte) -100), - false, - 1); - run_ByteQuery( - Byte_filterL, - BigDecimalParameter, - new BigDecimal("50.000000"), - Byte.valueOf((byte) 50), - true, - 3); - run_ByteQuery( - Byte_filterR, - BigDecimalParameter, - new BigDecimal("10.000000"), - Byte.valueOf((byte) 10), - false, - 4); - Byte val = Byte.valueOf((byte) 50); - alltypes.setByte(val); - run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, false, 5); - val = Byte.valueOf((byte) 51); - alltypes.setByte(val); - run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, false, 7); - run_ByteQuery(Byte_filterVal, null, null, Byte.valueOf((byte) 100), true, 1); - - run_ShortQuery( - Short_filterL, - shortParameter, - Short.valueOf((short) 100), - Short.valueOf((short) 100), - true, - 3); - run_ShortQuery( - Short_filterR, - shortParameter, - Short.valueOf((short) 100), - Short.valueOf((short) 100), - false, - 5); - run_ShortQuery( - Short_filterL, - ShortParameter, - Short.valueOf(Short.MIN_VALUE), - Short.valueOf(Short.MIN_VALUE), - true, - 9); - run_ShortQuery( - Short_filterR, - ShortParameter, - Short.valueOf((short) 253), - Short.valueOf((short) 253), - false, - 7); - run_ShortQuery( - Short_filterR, - shortParameter, - Short.valueOf((short) 1000), - Short.valueOf((short) 1000), - false, - 7); - run_ShortQuery( - Short_filterL, byteParameter, Byte.valueOf((byte) 75), Short.valueOf((short) 75), true, 5); - run_ShortQuery( - Short_filterR, byteParameter, Byte.valueOf((byte) 75), Short.valueOf((short) 75), false, 5); - run_ShortQuery( - Short_filterL, - ByteParameter, - Byte.valueOf((byte) 100), - Short.valueOf((short) 100), - true, - 3); - run_ShortQuery( - Short_filterR, - ByteParameter, - Byte.valueOf((byte) 100), - Short.valueOf((short) 100), - false, - 5); - run_ShortQuery( - Short_filterL, - charParameter, - Character.valueOf((char) 75), - Short.valueOf((short) 75), - true, - 5); - run_ShortQuery( - Short_filterR, - charParameter, - Character.valueOf((char) 75), - Short.valueOf((short) 75), - false, - 5); - run_ShortQuery( - Short_filterL, - CharacterParameter, - Character.valueOf((char) 100), - Short.valueOf((short) 100), - true, - 3); - run_ShortQuery( - Short_filterR, - CharacterParameter, - Character.valueOf((char) 200), - Short.valueOf((short) 200), - false, - 7); - run_ShortQuery( - Short_filterL, - intParameter, - Integer.valueOf(-10000), - Short.valueOf((short) -10000), - true, - 8); - run_ShortQuery( - Short_filterR, - intParameter, - Integer.valueOf(-10000), - Short.valueOf((short) -10000), - false, - 1); - run_ShortQuery( - Short_filterL, - IntegerParameter, - Integer.valueOf(10000), - Short.valueOf((short) 10000), - true, - 1); - run_ShortQuery( - Short_filterR, - IntegerParameter, - Integer.valueOf(10000), - Short.valueOf((short) 10000), - false, - 8); - run_ShortQuery( - Short_filterL, longParameter, Long.valueOf(20000), Short.valueOf((short) 20000), true, 1); - run_ShortQuery( - Short_filterR, longParameter, Long.valueOf(5000), Short.valueOf((short) 5000), false, 8); - run_ShortQuery( - Short_filterL, LongParameter, Long.valueOf(200), Short.valueOf((short) 200), true, 3); - run_ShortQuery( - Short_filterR, LongParameter, Long.valueOf(500), Short.valueOf((short) 500), false, 7); - run_ShortQuery( - Short_filterL, - floatParameter, - Float.valueOf(23000.0f), - Short.valueOf((short) 23000), - true, - 1); - run_ShortQuery( - Short_filterR, - floatParameter, - Float.valueOf(23000.0f), - Short.valueOf((short) 23000), - false, - 9); - run_ShortQuery( - Short_filterL, FloatParameter, Float.valueOf(10.0f), Short.valueOf((short) 10), true, 5); - run_ShortQuery( - Short_filterR, FloatParameter, Float.valueOf(101.0f), Short.valueOf((short) 101), false, 7); - run_ShortQuery( - Short_filterL, - doubleParameter, - Double.valueOf(-10000.0), - Short.valueOf((short) -10000), - true, - 8); - run_ShortQuery( - Short_filterR, - doubleParameter, - Double.valueOf(-10000.0), - Short.valueOf((short) -10000), - false, - 1); - run_ShortQuery( - Short_filterL, DoubleParameter, Double.valueOf(101.0), Short.valueOf((short) 101), true, 3); - run_ShortQuery( - Short_filterR, DoubleParameter, Double.valueOf(23.0), Short.valueOf((short) 23), false, 5); - run_ShortQuery( - Short_filterL, - BigIntegerParameter, - new BigInteger("10000"), - Short.valueOf((short) 10000), - true, - 1); - run_ShortQuery( - Short_filterR, - BigIntegerParameter, - new BigInteger("30000"), - Short.valueOf((short) 30000), - false, - 9); - run_ShortQuery( - Short_filterL, - BigDecimalParameter, - new BigDecimal("23.0"), - Short.valueOf((short) 23), - true, - 5); - run_ShortQuery( - Short_filterR, - BigDecimalParameter, - new BigDecimal("23.0"), - Short.valueOf((short) 23), - false, - 5); - Short sval = Short.valueOf((short) 100); - alltypes.setShort(sval); - run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, false, 5); - sval = Short.valueOf((short) 23); - alltypes.setShort(sval); - run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, false, 5); - run_ShortQuery(Short_filterVal, null, null, Short.valueOf((short) -1000), true, 7); - - run_CharacterQuery( - Character_filterL, - charParameter, - Character.valueOf(Character.MIN_VALUE), - Character.valueOf(Character.MIN_VALUE), - true, - 9); - run_CharacterQuery( - Character_filterR, - charParameter, - Character.valueOf(Character.MAX_VALUE), - Character.valueOf(Character.MAX_VALUE), - false, - 9); - run_CharacterQuery( - Character_filterL, charParameter, Character.valueOf('C'), Character.valueOf('C'), true, 6); - run_CharacterQuery( - Character_filterR, charParameter, Character.valueOf('z'), Character.valueOf('z'), false, 7); - run_CharacterQuery( - Character_filterL, - CharacterParameter, - Character.valueOf(' '), - Character.valueOf(' '), - true, - 8); - run_CharacterQuery( - Character_filterR, - CharacterParameter, - Character.valueOf('f'), - Character.valueOf('f'), - false, - 7); - run_CharacterQuery( - Character_filterL, - byteParameter, - Byte.valueOf((byte) Character.MIN_VALUE), - Character.valueOf((char) Character.MIN_VALUE), - true, - 9); - run_CharacterQuery( - Character_filterR, - ByteParameter, - Byte.valueOf((byte) 'a'), - Character.valueOf('a'), - false, - 7); - run_CharacterQuery( - Character_filterL, - shortParameter, - Short.valueOf((short) 'M'), - Character.valueOf('M'), - true, - 3); - run_CharacterQuery( - Character_filterR, - shortParameter, - Short.valueOf((short) 'F'), - Character.valueOf('F'), - false, - 4); - run_CharacterQuery( - Character_filterL, - ShortParameter, - Short.valueOf((short) 'A'), - Character.valueOf('A'), - true, - 7); - run_CharacterQuery( - Character_filterR, - ShortParameter, - Short.valueOf((short) 'A'), - Character.valueOf('A'), - false, - 2); - run_CharacterQuery( - Character_filterL, intParameter, Integer.valueOf('z'), Character.valueOf('z'), true, 1); - run_CharacterQuery( - Character_filterR, intParameter, Integer.valueOf('z'), Character.valueOf('z'), false, 7); - run_CharacterQuery( - Character_filterL, IntegerParameter, Integer.valueOf('B'), Character.valueOf('B'), true, 6); - run_CharacterQuery( - Character_filterR, - IntegerParameter, - Integer.valueOf('B'), - Character.valueOf('B'), - false, - 3); - run_CharacterQuery( - Character_filterL, longParameter, Long.valueOf('z'), Character.valueOf('z'), true, 1); - run_CharacterQuery( - Character_filterR, longParameter, Long.valueOf('z'), Character.valueOf('z'), false, 7); - run_CharacterQuery( - Character_filterL, LongParameter, Long.valueOf('B'), Character.valueOf('B'), true, 6); - run_CharacterQuery( - Character_filterR, LongParameter, Long.valueOf('B'), Character.valueOf('B'), false, 3); - run_CharacterQuery( - Character_filterL, - floatParameter, - Float.valueOf((float) 'z'), - Character.valueOf('z'), - true, - 1); - run_CharacterQuery( - Character_filterR, - floatParameter, - Float.valueOf((float) 'z'), - Character.valueOf('z'), - false, - 7); - run_CharacterQuery( - Character_filterL, - FloatParameter, - Float.valueOf((float) 'M'), - Character.valueOf('M'), - true, - 3); - run_CharacterQuery( - Character_filterR, - FloatParameter, - Float.valueOf((float) 'X'), - Character.valueOf('X'), - false, - 7); - run_CharacterQuery( - Character_filterL, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), true, 6); - run_CharacterQuery( - Character_filterR, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), false, 3); - run_CharacterQuery( - Character_filterL, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), true, 7); - run_CharacterQuery( - Character_filterR, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), false, 2); - run_CharacterQuery( - Character_filterL, - BigIntegerParameter, - new BigInteger("65"), - Character.valueOf('A'), - true, - 7); // 'A' == 65 - run_CharacterQuery( - Character_filterR, - BigIntegerParameter, - new BigInteger("122"), - Character.valueOf('z'), - false, - 7); // 'z' == 122 - run_CharacterQuery( - Character_filterL, - BigDecimalParameter, - new BigDecimal("65.00000"), - Character.valueOf('A'), - true, - 7); - run_CharacterQuery( - Character_filterR, - BigDecimalParameter, - new BigDecimal("77.0000"), - Character.valueOf('M'), - false, - 5); // 'M' == 77 - alltypes.setCharacter(Character.valueOf('A')); - run_CharacterQuery( - Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('A'), true, 7); - alltypes.setCharacter(Character.valueOf('b')); - run_CharacterQuery( - Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('b'), true, 3); - run_CharacterQuery(Character_filterVal, null, null, Character.valueOf('z'), false, 7); + */ - run_IntegerQuery( - Integer_filterL, - intParameter, - Integer.valueOf(AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - true, - 9); - run_IntegerQuery( - Integer_filterR, - intParameter, - Integer.valueOf(AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - false, - 9); - run_IntegerQuery( - Integer_filterR, intParameter, Integer.valueOf(23), Integer.valueOf(23), false, 4); - run_IntegerQuery( - Integer_filterL, - IntegerParameter, - Integer.valueOf(1000000), - Integer.valueOf(1000000), - true, - 1); - run_IntegerQuery( - Integer_filterR, IntegerParameter, Integer.valueOf(1000), Integer.valueOf(1000), false, 6); - run_IntegerQuery( - Integer_filterL, byteParameter, Byte.valueOf((byte) 100), Integer.valueOf(100), true, 4); - run_IntegerQuery( - Integer_filterR, byteParameter, Byte.valueOf((byte) 0), Integer.valueOf(0), false, 3); - run_IntegerQuery( - Integer_filterL, ByteParameter, Byte.valueOf((byte) 100), Integer.valueOf(100), true, 4); - run_IntegerQuery( - Integer_filterR, ByteParameter, Byte.valueOf((byte) 0), Integer.valueOf(0), false, 3); - run_IntegerQuery( - Integer_filterL, - shortParameter, - Short.valueOf((short) 10000), - Integer.valueOf(10000), - true, - 2); - run_IntegerQuery( - Integer_filterR, - shortParameter, - Short.valueOf((short) -1000), - Integer.valueOf(-1000), - false, - 2); - run_IntegerQuery( - Integer_filterL, - ShortParameter, - Short.valueOf((short) -1000), - Integer.valueOf(-1000), - true, - 7); - run_IntegerQuery( - Integer_filterR, - ShortParameter, - Short.valueOf((short) -999), - Integer.valueOf(-999), - false, - 3); - run_IntegerQuery( - Integer_filterL, - charParameter, - Character.valueOf((char) 10000), - Integer.valueOf(10000), - true, - 2); - run_IntegerQuery( - Integer_filterR, - charParameter, - Character.valueOf((char) 10000), - Integer.valueOf(10000), - false, - 7); - run_IntegerQuery( - Integer_filterL, - CharacterParameter, - Character.valueOf((char) 100), - Integer.valueOf(100), - true, - 4); - run_IntegerQuery( - Integer_filterR, - CharacterParameter, - Character.valueOf((char) 10000), - Integer.valueOf(10000), - false, - 7); - run_IntegerQuery( - Integer_filterL, - longParameter, - Long.valueOf(AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - true, - 0); - run_IntegerQuery( - Integer_filterR, - longParameter, - Long.valueOf(AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - false, - 0); - run_IntegerQuery( - Integer_filterL, LongParameter, Long.valueOf(10000), Integer.valueOf(10000), true, 2); - run_IntegerQuery( - Integer_filterR, LongParameter, Long.valueOf(43), Integer.valueOf(43), false, 4); - run_IntegerQuery( - Integer_filterL, - floatParameter, - Float.valueOf((float) AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - true, - 0); - run_IntegerQuery( - Integer_filterR, - floatParameter, - Float.valueOf((float) AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - false, - 0); - run_IntegerQuery( - Integer_filterL, - FloatParameter, - Float.valueOf((float) 10000), - Integer.valueOf(10000), - true, - 2); - run_IntegerQuery( - Integer_filterR, FloatParameter, Float.valueOf((float) 43), Integer.valueOf(43), false, 4); - run_IntegerQuery( - Integer_filterL, - doubleParameter, - Double.valueOf(AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - true, - 0); - run_IntegerQuery( - Integer_filterR, - doubleParameter, - Double.valueOf(AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - false, - 0); - run_IntegerQuery( - Integer_filterL, DoubleParameter, Double.valueOf(10000), Integer.valueOf(10000), true, 2); - run_IntegerQuery( - Integer_filterR, - DoubleParameter, - Double.valueOf(1000001.0), - Integer.valueOf(1000001), - false, - 9); - run_IntegerQuery( - Integer_filterL, - BigIntegerParameter, - new BigInteger("1000000"), - Integer.valueOf(1000000), - true, - 1); - run_IntegerQuery( - Integer_filterR, - BigIntegerParameter, - new BigInteger("1000"), - Integer.valueOf(1000), - false, - 6); - run_IntegerQuery( - Integer_filterL, - BigDecimalParameter, - new BigDecimal("10000.0"), - Integer.valueOf(10000), - true, - 2); - run_IntegerQuery( - Integer_filterR, - BigDecimalParameter, - new BigDecimal("43.0"), - Integer.valueOf(43), - false, - 4); - alltypes.setInteger(Integer.valueOf(100)); - run_IntegerQuery( - Integer_filterObj, AllTypesParameter, alltypes, Integer.valueOf(100), false, 4); - run_IntegerQuery(Integer_filterVal, null, null, Integer.valueOf(100), false, 4); +public class LessThan extends ComparisonTests { + private static String boolean_filterL = "value < fld_boolean"; + private static String boolean_filterR = "fld_boolean < value"; + private static String boolean_filterT = "fld_boolean < true"; + private static String boolean_filterF = "false < fld_boolean"; + private static String boolean_filterObj = "value.fld_boolean < fld_boolean"; + + private static String byte_filterL = "value < fld_byte"; + private static String byte_filterR = "fld_byte < value"; + private static String byte_filterObj = "value.fld_byte < fld_byte"; + private static String byte_filterVal = "fld_byte < 100"; + + private static String char_filterL = "value < fld_char"; + private static String char_filterR = "fld_char < value"; + private static String char_filterObj = "value.fld_char < fld_char"; + private static String char_filterVal = "'M' < fld_char"; + + private static String double_filterL = "value < fld_double"; + private static String double_filterR = "fld_double < value"; + private static String double_filterObj = "value.fld_double < fld_double"; + private static String double_filterVal = "fld_double < 100.0"; + + private static String float_filterL = "value < fld_float"; + private static String float_filterR = "fld_float < value"; + private static String float_filterObj = "fld_float < value.fld_float"; + private static String float_filterVal = "fld_float < 100.0"; + + private static String int_filterL = "value < fld_int"; + private static String int_filterR = "fld_int < value"; + private static String int_filterObj = "value.fld_int < fld_int"; + private static String int_filterVal = "fld_int < 1000"; + + private static String long_filterL = "value < fld_long"; + private static String long_filterR = "fld_long < value"; + private static String long_filterObj = "fld_long < value.fld_long"; + private static String long_filterVal = "fld_long < 1000000"; + + private static String short_filterL = "value < fld_short"; + private static String short_filterR = "fld_short < value"; + private static String short_filterObj = "value.fld_short < fld_short"; + private static String short_filterVal = "1000 < fld_short"; + + private static String Boolean_filterL = "value < fld_Boolean"; + private static String Boolean_filterR = "fld_Boolean < value"; + private static String Boolean_filterT = "fld_Boolean < true"; + private static String Boolean_filterF = "false < fld_Boolean"; + private static String Boolean_filterObj = "value.fld_Boolean < fld_Boolean"; + private static String Boolean_filterVal = "fld_Boolean < false"; + + private static String Byte_filterL = "value < fld_Byte"; + private static String Byte_filterR = "fld_Byte < value"; + private static String Byte_filterObj = "fld_Byte < value.fld_Byte"; + private static String Byte_filterVal = "100 < fld_Byte"; + + private static String Character_filterL = "value < fld_Character"; + private static String Character_filterR = "fld_Character < value"; + private static String Character_filterObj = "value.fld_Character < fld_Character"; + private static String Character_filterVal = "fld_Character < 'z'"; + + private static String Double_filterL = "value < fld_Double"; + private static String Double_filterR = "fld_Double < value"; + private static String Double_filterObj = "value.fld_Double < fld_Double"; + private static String Double_filterVal = "fld_Double < 100.0"; + + private static String Float_filterL = "value < fld_Float"; + private static String Float_filterR = "fld_Float < value"; + private static String Float_filterObj = "fld_Float < value.fld_Float"; + private static String Float_filterVal = "100.0f < fld_Float"; + + private static String Integer_filterL = "value < fld_Integer"; + private static String Integer_filterR = "fld_Integer < value"; + private static String Integer_filterObj = "fld_Integer < value.fld_Integer"; + private static String Integer_filterVal = "fld_Integer < 100"; + + private static String Long_filterL = "value < fld_Long"; + private static String Long_filterR = "fld_Long < value"; + private static String Long_filterObj = "value.fld_Long < fld_Long"; + private static String Long_filterVal = "-1000 < fld_Long"; + + private static String Short_filterL = "value < fld_Short"; + private static String Short_filterR = "fld_Short < value"; + private static String Short_filterObj = "fld_Short < value.fld_Short"; + private static String Short_filterVal = "-1000 < fld_Short"; + + private static String String_filterL = "value < fld_String"; + private static String String_filterR = "fld_String < value"; + private static String String_filterObj = "value.fld_String < fld_String"; + private static String String_filterVal1 = "fld_String < \"Java\""; + private static String String_filterVal2 = "fld_String < \"\""; + + private static String Date_filterL = "value < fld_Date"; + private static String Date_filterR = "fld_Date < value"; + private static String Date_filterObj = "fld_Date < value.fld_Date"; + + private static String BigDecimal_filterL = "value < fld_BigDecimal"; + private static String BigDecimal_filterR = "fld_BigDecimal < value"; + private static String BigDecimal_filterObj = "value.fld_BigDecimal < fld_BigDecimal"; + + private static String BigInteger_filterL = "value < fld_BigInteger"; + private static String BigInteger_filterR = "fld_BigInteger < value"; + private static String BigInteger_filterObj = "fld_BigInteger < value.fld_BigInteger"; - run_LongQuery( - Long_filterL, - longParameter, - Long.valueOf(Long.MIN_VALUE), - Long.valueOf(Long.MIN_VALUE), - true, - 9); - run_LongQuery( - Long_filterR, - longParameter, - Long.valueOf(Long.MAX_VALUE), - Long.valueOf(Long.MAX_VALUE), - false, - 9); - run_LongQuery(Long_filterL, LongParameter, Long.valueOf(100), Long.valueOf(100), true, 3); - run_LongQuery(Long_filterR, LongParameter, Long.valueOf(23), Long.valueOf(23), false, 5); - run_LongQuery( - Long_filterL, byteParameter, Byte.valueOf((byte) 100), Long.valueOf(100), true, 3); - run_LongQuery(Long_filterR, byteParameter, Byte.valueOf((byte) 0), Long.valueOf(0), false, 4); - run_LongQuery( - Long_filterL, ByteParameter, Byte.valueOf((byte) 100), Long.valueOf(100), true, 3); - run_LongQuery(Long_filterR, ByteParameter, Byte.valueOf((byte) 0), Long.valueOf(0), false, 4); - run_LongQuery( - Long_filterL, shortParameter, Short.valueOf((short) -1000), Long.valueOf(-1000), true, 6); - run_LongQuery( - Long_filterR, shortParameter, Short.valueOf((short) 1000), Long.valueOf(1000), false, 7); - run_LongQuery( - Long_filterL, ShortParameter, Short.valueOf((short) 101), Long.valueOf(101), true, 3); - run_LongQuery( - Long_filterR, ShortParameter, Short.valueOf((short) 32), Long.valueOf(32), false, 5); - run_LongQuery( - Long_filterL, charParameter, Character.valueOf((char) 0), Long.valueOf(0), true, 5); - run_LongQuery( - Long_filterR, charParameter, Character.valueOf((char) 100), Long.valueOf(100), false, 5); - run_LongQuery( - Long_filterL, CharacterParameter, Character.valueOf((char) 23), Long.valueOf(23), true, 5); - run_LongQuery( - Long_filterR, - CharacterParameter, - Character.valueOf((char) 1110), - Long.valueOf(1110), - false, - 8); - run_LongQuery(Long_filterL, intParameter, Integer.valueOf(100), Long.valueOf(100), true, 3); - run_LongQuery(Long_filterR, intParameter, Integer.valueOf(0), Long.valueOf(0), false, 4); - run_LongQuery(Long_filterL, IntegerParameter, Integer.valueOf(23), Long.valueOf(23), true, 5); - run_LongQuery( - Long_filterR, IntegerParameter, Integer.valueOf(1000000), Long.valueOf(1000000), false, 8); - run_LongQuery( - Long_filterL, - floatParameter, - Float.valueOf((float) -1000000.0), - Long.valueOf(-1000000), - true, - 8); - run_LongQuery( - Long_filterR, - floatParameter, - Float.valueOf((float) Long.MAX_VALUE), - Long.valueOf(Long.MAX_VALUE), - false, - 9); - run_LongQuery(Long_filterL, FloatParameter, Float.valueOf(100.0f), Long.valueOf(100), true, 3); - run_LongQuery(Long_filterR, FloatParameter, Float.valueOf(32.0f), Long.valueOf(32), false, 5); - run_LongQuery( - Long_filterL, doubleParameter, Double.valueOf(-1000000.0), Long.valueOf(-1000000), true, 8); - run_LongQuery( - Long_filterR, - doubleParameter, - Double.valueOf((double) Long.MAX_VALUE), - Long.valueOf(Long.MAX_VALUE), - false, - 9); - run_LongQuery(Long_filterL, DoubleParameter, Double.valueOf(100.0), Long.valueOf(100), true, 3); - run_LongQuery(Long_filterR, DoubleParameter, Double.valueOf(32.0), Long.valueOf(32), false, 5); - run_LongQuery( - Long_filterL, BigIntegerParameter, new BigInteger("23"), Long.valueOf(23), true, 5); - run_LongQuery( - Long_filterR, - BigIntegerParameter, - new BigInteger("1000000"), - Long.valueOf(1000000), - false, - 8); - run_LongQuery( - Long_filterL, BigDecimalParameter, new BigDecimal("100.0"), Long.valueOf(100), true, 3); - run_LongQuery( - Long_filterR, BigDecimalParameter, new BigDecimal("32.0"), Long.valueOf(32), false, 5); - alltypes.setLong(Long.valueOf(100)); - run_LongQuery(Long_filterObj, AllTypesParameter, alltypes, Long.valueOf(100), true, 3); - run_LongQuery(Long_filterVal, null, null, Long.valueOf(-1000), true, 6); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-17 (LessThan) failed: "; - run_FloatQuery( - Float_filterL, - floatParameter, - Float.valueOf(-10000000000.0f), - Float.valueOf(-10000000000.0f), - true, - 9); - run_FloatQuery( - Float_filterR, - floatParameter, - Float.valueOf(9000000000.0f), - Float.valueOf(9000000000.0f), - false, - 9); - run_FloatQuery( - Float_filterL, FloatParameter, Float.valueOf((float) 0.0), Float.valueOf(0.0f), true, 7); - run_FloatQuery( - Float_filterR, FloatParameter, Float.valueOf((float) 4.0), Float.valueOf(4.0f), false, 3); - run_FloatQuery( - Float_filterL, byteParameter, Byte.valueOf((byte) 0), Float.valueOf(0.0f), true, 7); - run_FloatQuery( - Float_filterR, byteParameter, Byte.valueOf((byte) 23), Float.valueOf(23.0f), false, 3); - run_FloatQuery( - Float_filterL, ByteParameter, Byte.valueOf((byte) 34), Float.valueOf(34.0f), true, 7); - run_FloatQuery( - Float_filterR, ByteParameter, Byte.valueOf((byte) 100), Float.valueOf(100.0f), false, 3); - run_FloatQuery( - Float_filterL, shortParameter, Short.valueOf((short) 0), Float.valueOf(0.0f), true, 7); - run_FloatQuery( - Float_filterR, shortParameter, Short.valueOf((short) 23), Float.valueOf(23.0f), false, 3); - run_FloatQuery( - Float_filterL, ShortParameter, Short.valueOf((short) 34), Float.valueOf(34.0f), true, 7); - run_FloatQuery( - Float_filterR, ShortParameter, Short.valueOf((short) 100), Float.valueOf(100.0f), false, 3); - run_FloatQuery( - Float_filterL, charParameter, Character.valueOf((char) 0), Float.valueOf(0.0f), true, 7); - run_FloatQuery( - Float_filterR, charParameter, Character.valueOf((char) 23), Float.valueOf(23.0f), false, 3); - run_FloatQuery( - Float_filterL, - CharacterParameter, - Character.valueOf((char) 34), - Float.valueOf(34.0f), - true, - 7); - run_FloatQuery( - Float_filterR, - CharacterParameter, - Character.valueOf((char) 100), - Float.valueOf(100.0f), - false, - 3); - run_FloatQuery( - Float_filterL, - intParameter, - Integer.valueOf(50000000), - Float.valueOf(50000000.0f), - true, - 2); - run_FloatQuery( - Float_filterR, intParameter, Integer.valueOf(23), Float.valueOf(23.0f), false, 3); - run_FloatQuery( - Float_filterL, IntegerParameter, Integer.valueOf(34), Float.valueOf(34.0f), true, 7); - run_FloatQuery( - Float_filterR, IntegerParameter, Integer.valueOf(100), Float.valueOf(100.0f), false, 3); - run_FloatQuery( - Float_filterL, longParameter, Long.valueOf(50000000), Float.valueOf(50000000.0f), true, 2); - run_FloatQuery(Float_filterR, longParameter, Long.valueOf(23), Float.valueOf(23.0f), false, 3); - run_FloatQuery(Float_filterL, LongParameter, Long.valueOf(34), Float.valueOf(34.0f), true, 7); - run_FloatQuery( - Float_filterR, LongParameter, Long.valueOf(100), Float.valueOf(100.0f), false, 3); - run_FloatQuery( - Float_filterL, - doubleParameter, - Double.valueOf(50000000.0f), - Float.valueOf(50000000.0f), - true, - 2); - run_FloatQuery( - Float_filterR, doubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), false, 3); - run_FloatQuery( - Float_filterL, DoubleParameter, Double.valueOf(0.0f), Float.valueOf(0.0f), true, 7); - run_FloatQuery( - Float_filterR, DoubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), false, 3); - run_FloatQuery( - Float_filterL, - BigIntegerParameter, - new BigInteger("55000000"), - Float.valueOf(55000000.0f), - true, - 2); - run_FloatQuery( - Float_filterR, BigIntegerParameter, new BigInteger("23"), Float.valueOf(23.0f), false, 3); - run_FloatQuery( - Float_filterL, - BigDecimalParameter, - new BigDecimal("55000000.0"), - Float.valueOf(55000000.0f), - true, - 2); - run_FloatQuery( - Float_filterR, - BigDecimalParameter, - new BigDecimal("-25.5"), - Float.valueOf(-25.5f), - false, - 1); - alltypes.setFloat(Float.valueOf(23.23f)); - run_FloatQuery(Float_filterObj, AllTypesParameter, alltypes, Float.valueOf(23.23f), false, 3); - run_FloatQuery(Float_filterVal, null, null, Float.valueOf(100.0f), true, 5); + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(LessThan.class); + } - run_DoubleQuery( - Double_filterL, - doubleParameter, - Double.valueOf(-999999999999.0), - Double.valueOf(-999999999999.0), - true, - 9); - run_DoubleQuery( - Double_filterR, - doubleParameter, - Double.valueOf(9999999999999.0), - Double.valueOf(9999999999999.0), - false, - 9); - run_DoubleQuery( - Double_filterL, DoubleParameter, Double.valueOf(0.0), Double.valueOf(0.0), true, 6); - run_DoubleQuery( - Double_filterR, DoubleParameter, Double.valueOf(23.34), Double.valueOf(23.34), false, 4); - run_DoubleQuery( - Double_filterL, byteParameter, Byte.valueOf((byte) 100), Double.valueOf(100.0), true, 4); - run_DoubleQuery( - Double_filterR, byteParameter, Byte.valueOf((byte) 0), Double.valueOf(0.0), false, 3); - run_DoubleQuery( - Double_filterL, ByteParameter, Byte.valueOf((byte) -23), Double.valueOf(-23.0), true, 7); - run_DoubleQuery( - Double_filterR, ByteParameter, Byte.valueOf((byte) 100), Double.valueOf(100.0), false, 4); - run_DoubleQuery( - Double_filterL, shortParameter, Short.valueOf((short) 100), Double.valueOf(100.0), true, 4); - run_DoubleQuery( - Double_filterR, shortParameter, Short.valueOf((short) 0), Double.valueOf(0.0), false, 3); - run_DoubleQuery( - Double_filterL, ShortParameter, Short.valueOf((short) 23), Double.valueOf(23.0), true, 6); - run_DoubleQuery( - Double_filterR, - ShortParameter, - Short.valueOf((short) 400), - Double.valueOf(400.0), - false, - 7); - run_DoubleQuery( - Double_filterL, - charParameter, - Character.valueOf((char) 100), - Double.valueOf(100.0), - true, - 4); - run_DoubleQuery( - Double_filterR, charParameter, Character.valueOf((char) 0), Double.valueOf(0.0), false, 3); - run_DoubleQuery( - Double_filterL, - CharacterParameter, - Character.valueOf((char) 23), - Double.valueOf(23.0), - true, - 6); - run_DoubleQuery( - Double_filterR, - CharacterParameter, - Character.valueOf((char) 400), - Double.valueOf(400.0), - false, - 7); - run_DoubleQuery( - Double_filterL, intParameter, Integer.valueOf(100), Double.valueOf(100.0), true, 4); - run_DoubleQuery( - Double_filterR, intParameter, Integer.valueOf(0), Double.valueOf(0.0), false, 3); - run_DoubleQuery( - Double_filterL, IntegerParameter, Integer.valueOf(23), Double.valueOf(23.0), true, 6); - run_DoubleQuery( - Double_filterR, IntegerParameter, Integer.valueOf(100), Double.valueOf(100.0), false, 4); - run_DoubleQuery( - Double_filterL, longParameter, Long.valueOf(100), Double.valueOf(100.0), true, 4); - run_DoubleQuery(Double_filterR, longParameter, Long.valueOf(0), Double.valueOf(0.0), false, 3); - run_DoubleQuery(Double_filterL, LongParameter, Long.valueOf(23), Double.valueOf(23.0), true, 6); - run_DoubleQuery( - Double_filterR, LongParameter, Long.valueOf(100), Double.valueOf(100.0), false, 4); - run_DoubleQuery( - Double_filterL, floatParameter, Float.valueOf(0.0f), Double.valueOf(0.0f), true, 6); - run_DoubleQuery( - Double_filterR, floatParameter, Float.valueOf(100.0f), Double.valueOf(100.0f), false, 4); - run_DoubleQuery( - Double_filterL, FloatParameter, Float.valueOf(100.0f), Double.valueOf(100.0f), true, 4); - run_DoubleQuery( - Double_filterR, FloatParameter, Float.valueOf(69.96f), Double.valueOf(69.96), false, 4); - run_DoubleQuery( - Double_filterL, - BigIntegerParameter, - new BigInteger("5000"), - Double.valueOf(5000.0), - true, - 3); - run_DoubleQuery( - Double_filterR, - BigIntegerParameter, - new BigInteger("-20"), - Double.valueOf(-20.0), - false, - 3); - run_DoubleQuery( - Double_filterL, - BigDecimalParameter, - new BigDecimal("100.0"), - Double.valueOf(100.0), - true, - 4); - run_DoubleQuery( - Double_filterR, - BigDecimalParameter, - new BigDecimal("69.96"), - Double.valueOf(69.96), - false, - 4); - alltypes.setDouble(Double.valueOf(-999999999999.0)); - run_DoubleQuery( - Double_filterObj, AllTypesParameter, alltypes, Double.valueOf(-999999999999.0), true, 9); - run_DoubleQuery(Double_filterVal, null, null, Double.valueOf(100.0), false, 4); + /** */ + public void test() { + pm = getPM(); + tx = pm.currentTransaction(); + runQueries(); + } - run_StringQuery(String_filterL, StringParameter, new String("JDO"), new String("JDO"), true, 8); - run_StringQuery( - String_filterR, StringParameter, new String("JDBC"), new String("JDBC"), false, 1); - alltypes.setString(new String("abcde")); - run_StringQuery(String_filterObj, AllTypesParameter, alltypes, new String("abcde"), true, 2); - run_StringQuery(String_filterVal1, null, null, new String("Java"), false, 4); - run_StringQuery(String_filterVal2, null, null, new String(""), false, 0); + /** */ + private void runQueries() + { + AllTypes alltypes = new AllTypes(); + run_byteQuery(byte_filterL, byteParameter, Byte.valueOf((byte)0), (byte)0, true, 6); + run_byteQuery(byte_filterR, byteParameter, Byte.valueOf(Byte.MIN_VALUE), Byte.MIN_VALUE, false, 0); + run_byteQuery(byte_filterL, ByteParameter, Byte.valueOf((byte)50), (byte)50, true, 3); + run_byteQuery(byte_filterR, ByteParameter, Byte.valueOf(Byte.MAX_VALUE), Byte.MAX_VALUE, false, 9); + run_byteQuery(byte_filterL, shortParameter, Short.valueOf((short)75), (byte)75, true, 2); + run_byteQuery(byte_filterR, shortParameter, Short.valueOf((short)75), (byte)75, false, 7); + run_byteQuery(byte_filterL, ShortParameter, Short.valueOf((short)10), (byte)10, true, 5); + run_byteQuery(byte_filterR, ShortParameter, Short.valueOf((short)25), (byte)25, false, 5); + run_byteQuery(byte_filterL, charParameter, Character.valueOf((char)101), (byte)101, true, 1); + run_byteQuery(byte_filterR, charParameter, Character.valueOf((char)50), (byte)50, false, 5); + run_byteQuery(byte_filterL, CharacterParameter, Character.valueOf((char)0), (byte)0, true, 6); + run_byteQuery(byte_filterR, CharacterParameter, Character.valueOf((char)0), (byte)0, false, 3); + run_byteQuery(byte_filterL, intParameter, Integer.valueOf(25), (byte)25, true, 5); + run_byteQuery(byte_filterR, intParameter, Integer.valueOf(50), (byte)50, false, 5); + run_byteQuery(byte_filterL, IntegerParameter, Integer.valueOf(-10), (byte)-10, true, 7); + run_byteQuery(byte_filterR, IntegerParameter, Integer.valueOf(-100), (byte)-100, false, 1); + run_byteQuery(byte_filterL, longParameter, Long.valueOf(50), (byte)50, true, 3); + run_byteQuery(byte_filterR, longParameter, Long.valueOf(60), (byte)60, false, 7); + run_byteQuery(byte_filterL, LongParameter, Long.valueOf(-100), (byte)-100, true, 8); + run_byteQuery(byte_filterR, LongParameter, Long.valueOf(-100), (byte)-100, false, 1); + run_byteQuery(byte_filterL, floatParameter, Float.valueOf((float)51), (byte)51, true, 3); + run_byteQuery(byte_filterR, floatParameter, Float.valueOf((float)-20), (byte)-20, false, 2); + run_byteQuery(byte_filterL, FloatParameter, Float.valueOf((float)-99), (byte)-99, true, 8); + run_byteQuery(byte_filterR, FloatParameter, Float.valueOf((float)-100), (byte)-100, false, 1); + run_byteQuery(byte_filterL, doubleParameter, Double.valueOf(50), (byte)50, true, 3); + run_byteQuery(byte_filterR, doubleParameter, Double.valueOf(60), (byte)60, false, 7); + run_byteQuery(byte_filterL, DoubleParameter, Double.valueOf(Byte.MAX_VALUE), Byte.MAX_VALUE, true, 0); + run_byteQuery(byte_filterR, DoubleParameter, Double.valueOf(25), (byte)25, false, 5); + run_byteQuery(byte_filterL, BigIntegerParameter, new BigInteger("50"), (byte)50, true, 3); + run_byteQuery(byte_filterR, BigIntegerParameter, new BigInteger("-100"), (byte)-100, false, 1); + run_byteQuery(byte_filterL, BigDecimalParameter, new BigDecimal("50.000000"), (byte)50, true, 3); + run_byteQuery(byte_filterR, BigDecimalParameter, new BigDecimal("10.00000"), (byte)10, false, 4); + alltypes.setbyte((byte)50); + run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte)50, true, 3); + alltypes.setbyte((byte)55); + run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte)55, true, 3); + run_byteQuery(byte_filterVal, null, null, (byte)100, false, 8); - BigDecimal bd = new BigDecimal("100.0"); - run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, true, 4); - bd = new BigDecimal("-234234.23333"); - run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, false, 1); - bd = new BigDecimal("989899.33304953"); - run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, true, 3); - bd = new BigDecimal("-1123123.22"); - run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, false, 0); - alltypes.setBigDecimal(bd); - run_BigDecimalQuery(BigDecimal_filterObj, AllTypesParameter, alltypes, bd, true, 9); + run_shortQuery(short_filterL, shortParameter, Short.valueOf((short)100), (short)100, true, 3); + run_shortQuery(short_filterR, shortParameter, Short.valueOf((short)100), (short)100, false, 5); + run_shortQuery(short_filterL, ShortParameter, Short.valueOf(Short.MIN_VALUE), Short.MIN_VALUE, true, 9); + run_shortQuery(short_filterR, ShortParameter, Short.valueOf((short)253), (short)253, false, 7); + run_shortQuery(short_filterR, shortParameter, Short.valueOf((short)1000), (short)1000, false, 7); + run_shortQuery(short_filterL, byteParameter, Byte.valueOf((byte)75), (short)75, true, 5); + run_shortQuery(short_filterR, byteParameter, Byte.valueOf((byte)-75), (short)-75, false, 4); + run_shortQuery(short_filterL, ByteParameter, Byte.valueOf((byte)100), (short)100, true, 3); + run_shortQuery(short_filterR, ByteParameter, Byte.valueOf((byte)100), (short)100, false, 5); + run_shortQuery(short_filterL, charParameter, Character.valueOf((char)75), (short)75, true, 5); + run_shortQuery(short_filterR, charParameter, Character.valueOf((char)9999), (short)9999, false, 8); + run_shortQuery(short_filterL, CharacterParameter, Character.valueOf((char)1000), (short)1000, true, 2); + run_shortQuery(short_filterR, CharacterParameter, Character.valueOf((char)10000), (short)10000, false, 8); + run_shortQuery(short_filterL, intParameter, Integer.valueOf(-10000), (short)-10000, true, 8); + run_shortQuery(short_filterR, intParameter, Integer.valueOf(-10000), (short)-10000, false, 1); + run_shortQuery(short_filterL, IntegerParameter, Integer.valueOf(10000), (short)10000, true, 1); + run_shortQuery(short_filterR, IntegerParameter, Integer.valueOf(30000), (short)30000, false, 9); + run_shortQuery(short_filterL, longParameter, Long.valueOf(10000), (short) 10000, true, 1); + run_shortQuery(short_filterR, longParameter, Long.valueOf(Short.MAX_VALUE), Short.MAX_VALUE, false, 9); + run_shortQuery(short_filterL, LongParameter, Long.valueOf(Short.MAX_VALUE), Short.MAX_VALUE, true, 0); + run_shortQuery(short_filterR, LongParameter, Long.valueOf(100), (short)100, false, 5); + run_shortQuery(short_filterL, floatParameter, Float.valueOf((float)23000), (short)23000, true, 1); + run_shortQuery(short_filterR, floatParameter, Float.valueOf((float)23000), (short)23000, false, 9); + run_shortQuery(short_filterL, FloatParameter, Float.valueOf((float)-1000), (short)-1000, true, 7); + run_shortQuery(short_filterR, FloatParameter, Float.valueOf((float)100), (short)100, false, 5); + run_shortQuery(short_filterL, doubleParameter, Double.valueOf(-10000.0), (short)-10000, true, 8); + run_shortQuery(short_filterR, doubleParameter, Double.valueOf(9999.0), (short)9999, false, 8); + run_shortQuery(short_filterL, DoubleParameter, Double.valueOf(23.0), (short)23, true, 5); + run_shortQuery(short_filterR, DoubleParameter, Double.valueOf(23.0), (short)23, false, 5); + run_shortQuery(short_filterL, BigIntegerParameter, new BigInteger("10000"), (short)10000, true, 1); + run_shortQuery(short_filterR, BigIntegerParameter, new BigInteger("30000"), (short)30000, false, 9); + run_shortQuery(short_filterL, BigDecimalParameter, new BigDecimal("23.0"), (short)23, true, 5); + run_shortQuery(short_filterR, BigDecimalParameter, new BigDecimal("23.0"), (short)23, false, 5); + alltypes.setshort((short)100); + run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short)100, true, 3); + alltypes.setshort((short)23); + run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short)23, true, 5); + run_shortQuery(short_filterVal, null, null, (short)1000, true, 2); + + run_charQuery(char_filterL, charParameter, Character.valueOf(Character.MIN_VALUE), Character.MIN_VALUE, true, 9); + run_charQuery(char_filterR, charParameter, Character.valueOf(Character.MAX_VALUE), Character.MAX_VALUE, false, 9); + run_charQuery(char_filterL, charParameter, Character.valueOf('C'), 'C', true, 6); + run_charQuery(char_filterR, charParameter, Character.valueOf('z'), 'z', false, 7); + run_charQuery(char_filterL, CharacterParameter, Character.valueOf(' '), ' ', true, 8); + run_charQuery(char_filterR, CharacterParameter, Character.valueOf('f'), 'f', false, 7); + run_charQuery(char_filterL, byteParameter, Byte.valueOf((byte)Character.MIN_VALUE), (char)Character.MIN_VALUE, true, 9); + run_charQuery(char_filterR, ByteParameter, Byte.valueOf((byte)'a'), 'a', false, 7); + run_charQuery(char_filterL, shortParameter, Short.valueOf((short)'M'), 'M', true, 3); + run_charQuery(char_filterR, shortParameter, Short.valueOf((short)'M'), 'M', false, 5); + run_charQuery(char_filterL, ShortParameter, Short.valueOf((short)'A'), 'A', true, 7); + run_charQuery(char_filterR, ShortParameter, Short.valueOf((short)'A'), 'A', false, 2); + run_charQuery(char_filterL, intParameter, Integer.valueOf('z'), 'z', true, 1); + run_charQuery(char_filterR, intParameter, Integer.valueOf('z'), 'z', false, 7); + run_charQuery(char_filterL, IntegerParameter, Integer.valueOf('B'), 'B', true, 6); + run_charQuery(char_filterR, IntegerParameter, Integer.valueOf('B'), 'B', false, 3); + run_charQuery(char_filterL, floatParameter, Float.valueOf((float)'f'), 'f', true, 3); + run_charQuery(char_filterR, floatParameter, Float.valueOf((float)' '), ' ', false, 1); + run_charQuery(char_filterL, FloatParameter, Float.valueOf((float)'z'), 'z', true, 1); + run_charQuery(char_filterR, FloatParameter, Float.valueOf((float)'z'), 'z', false, 7); + run_charQuery(char_filterL, doubleParameter, Double.valueOf('B'), 'B', true, 6); + run_charQuery(char_filterR, doubleParameter, Double.valueOf('B'), 'B', false, 3); + run_charQuery(char_filterL, DoubleParameter, Double.valueOf('A'), 'A', true, 7); + run_charQuery(char_filterR, DoubleParameter, Double.valueOf('A'), 'A', false, 2); + run_charQuery(char_filterL, BigIntegerParameter, new BigInteger("65"), 'A', true, 7); // 'A' == 65 + run_charQuery(char_filterR, BigIntegerParameter, new BigInteger("122"), 'z', false, 7); // 'z' == 122 + run_charQuery(char_filterL, BigDecimalParameter, new BigDecimal("65.00000"), 'A', true, 7); + run_charQuery(char_filterR, BigDecimalParameter, new BigDecimal("77.0000"), 'M', false, 5); // 'M' == 77 + alltypes.setchar('A'); + run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'A', true, 7); + alltypes.setchar('b'); + run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'b', true, 3); + run_charQuery(char_filterVal, null, null, 'M', true, 3); + + run_intQuery(int_filterL, intParameter, Integer.valueOf(AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, true, 9); + run_intQuery(int_filterR, intParameter, Integer.valueOf(AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, false, 9); + run_intQuery(int_filterR, intParameter, Integer.valueOf(23), 23, false, 4); + run_intQuery(int_filterL, IntegerParameter, Integer.valueOf(1000000), 1000000, true, 1); + run_intQuery(int_filterR, IntegerParameter, Integer.valueOf(1000), 1000, false, 6); + run_intQuery(int_filterL, byteParameter, Byte.valueOf((byte)100), 100, true, 4); + run_intQuery(int_filterR, byteParameter, Byte.valueOf((byte)0), 0, false, 3); + run_intQuery(int_filterL, ByteParameter, Byte.valueOf((byte)100), 100, true, 4); + run_intQuery(int_filterR, ByteParameter, Byte.valueOf((byte)0), 0, false, 3); + run_intQuery(int_filterL, shortParameter, Short.valueOf((short)10000), 10000, true, 2); + run_intQuery(int_filterR, shortParameter, Short.valueOf((short)-1000), -1000, false, 2); + run_intQuery(int_filterL, ShortParameter, Short.valueOf((short)-1000), -1000, true, 7); + run_intQuery(int_filterR, ShortParameter, Short.valueOf((short)10000), 10000, false, 7); + run_intQuery(int_filterL, charParameter, Character.valueOf((char)100), 100, true, 4); + run_intQuery(int_filterR, charParameter, Character.valueOf((char)0), 0, false, 3); + run_intQuery(int_filterL, CharacterParameter, Character.valueOf((char)100), 100, true, 4); + run_intQuery(int_filterR, CharacterParameter, Character.valueOf((char)10000), 10000, false, 7); + run_intQuery(int_filterL, longParameter, Long.valueOf(AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, true, 0); + run_intQuery(int_filterR, longParameter, Long.valueOf(AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, false, 0); + run_intQuery(int_filterL, LongParameter, Long.valueOf(10000), 10000, true, 2); + run_intQuery(int_filterR, LongParameter, Long.valueOf(43), 43, false, 4); + run_intQuery(int_filterL, floatParameter, Float.valueOf((float)AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, true, 0); + run_intQuery(int_filterR, floatParameter, Float.valueOf((float)AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, false, 0); + run_intQuery(int_filterL, FloatParameter, Float.valueOf((float)10000), 10000, true, 2); + run_intQuery(int_filterR, FloatParameter, Float.valueOf((float)43), 43, false, 4); + run_intQuery(int_filterL, doubleParameter, Double.valueOf(AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, true, 0); + run_intQuery(int_filterR, doubleParameter, Double.valueOf(AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, false, 0); + run_intQuery(int_filterL, DoubleParameter, Double.valueOf(10000), 10000, true, 2); + run_intQuery(int_filterR, DoubleParameter, Double.valueOf(43), 43, false, 4); + run_intQuery(int_filterL, BigIntegerParameter, new BigInteger("1000000"), 1000000, true, 1); + run_intQuery(int_filterR, BigIntegerParameter, new BigInteger("1000"), 1000, false, 6); + run_intQuery(int_filterL, BigDecimalParameter, new BigDecimal("10000.0"), 10000, true, 2); + run_intQuery(int_filterR, BigDecimalParameter, new BigDecimal("43.0"), 43, false, 4); + alltypes.setint(100); + run_intQuery(int_filterObj, AllTypesParameter, alltypes, 100, true, 4); + run_intQuery(int_filterVal, null, null, 1000, false, 6); + + run_longQuery(long_filterL, longParameter, Long.valueOf(Long.MIN_VALUE), Long.MIN_VALUE, true, 9); + run_longQuery(long_filterR, longParameter, Long.valueOf(Long.MAX_VALUE), Long.MAX_VALUE, false, 9); + run_longQuery(long_filterL, LongParameter, Long.valueOf(100), 100, true, 3); + run_longQuery(long_filterR, LongParameter, Long.valueOf(23), 23, false, 5); + run_longQuery(long_filterL, byteParameter, Byte.valueOf((byte)100), 100, true, 3); + run_longQuery(long_filterR, byteParameter, Byte.valueOf((byte)0), 0, false, 4); + run_longQuery(long_filterL, ByteParameter, Byte.valueOf((byte)100), 100, true, 3); + run_longQuery(long_filterR, ByteParameter, Byte.valueOf((byte)0), 0, false, 4); + run_longQuery(long_filterL, shortParameter, Short.valueOf((short)-1000), -1000, true, 6); + run_longQuery(long_filterR, shortParameter, Short.valueOf((short)1000), 1000, false, 7); + run_longQuery(long_filterL, ShortParameter, Short.valueOf((short)100), 100, true, 3); + run_longQuery(long_filterR, ShortParameter, Short.valueOf((short)32), 32, false, 5); + run_longQuery(long_filterL, charParameter, Character.valueOf((char)0), 0, true, 5); + run_longQuery(long_filterR, charParameter, Character.valueOf((char)100), 100, false, 5); + run_longQuery(long_filterL, CharacterParameter, Character.valueOf((char)23), 23, true, 5); + run_longQuery(long_filterR, CharacterParameter, Character.valueOf((char)0), 0, false, 4); + run_longQuery(long_filterL, intParameter, Integer.valueOf(100), 100, true, 3); + run_longQuery(long_filterR, intParameter, Integer.valueOf(0), 0, false, 4); + run_longQuery(long_filterL, IntegerParameter, Integer.valueOf(23), 23, true, 5); + run_longQuery(long_filterR, IntegerParameter, Integer.valueOf(1000000), 1000000, false, 8); + run_longQuery(long_filterL, floatParameter, Float.valueOf((float)-1000000.0), -1000000, true, 8); + run_longQuery(long_filterR, floatParameter, Float.valueOf((float)Long.MAX_VALUE), Long.MAX_VALUE, false, 9); + run_longQuery(long_filterL, FloatParameter, Float.valueOf((float)100.0), 100, true, 3); + run_longQuery(long_filterR, FloatParameter, Float.valueOf((float)32.0), 32, false, 5); + run_longQuery(long_filterL, doubleParameter, Double.valueOf(-1000000.0), -1000000, true, 8); + run_longQuery(long_filterR, doubleParameter, Double.valueOf((double)Long.MAX_VALUE), Long.MAX_VALUE, false, 9); + run_longQuery(long_filterL, DoubleParameter, Double.valueOf(100.0), 100, true, 3); + run_longQuery(long_filterR, DoubleParameter, Double.valueOf(32.0), 32, false, 5); + run_longQuery(long_filterL, BigIntegerParameter, new BigInteger("23"), 23, true, 5); + run_longQuery(long_filterR, BigIntegerParameter, new BigInteger("1000000"), 1000000, false, 8); + run_longQuery(long_filterL, BigDecimalParameter, new BigDecimal("100.0"), 100, true, 3); + run_longQuery(long_filterR, BigDecimalParameter, new BigDecimal("32.0"), 32, false, 5); + alltypes.setlong(100); + run_longQuery(long_filterObj, AllTypesParameter, alltypes, 100, false, 5); + run_longQuery(long_filterVal, null, null, 1000000, false, 8); + + run_floatQuery(float_filterL, floatParameter, Float.valueOf((float)AllTypes.FLOAT_SMALLEST), AllTypes.FLOAT_SMALLEST, true, 9); + run_floatQuery(float_filterR, floatParameter, Float.valueOf((float)AllTypes.FLOAT_LARGEST), AllTypes.FLOAT_LARGEST, false, 9); + run_floatQuery(float_filterL, FloatParameter, Float.valueOf(4.0f), 4.0f, true, 6); + run_floatQuery(float_filterR, FloatParameter, Float.valueOf(400.0f), 400.0f, false, 7); + run_floatQuery(float_filterL, byteParameter, Byte.valueOf((byte)4), 4.0f, true, 6); + run_floatQuery(float_filterR, byteParameter, Byte.valueOf((byte)23), 23.0f, false, 4); + run_floatQuery(float_filterL, ByteParameter, Byte.valueOf((byte)34), 34.0f, true, 6); + run_floatQuery(float_filterR, ByteParameter, Byte.valueOf((byte)100), 100.0f, false, 4); + run_floatQuery(float_filterL, shortParameter, Short.valueOf((short)10), 10.0f, true, 6); + run_floatQuery(float_filterR, shortParameter, Short.valueOf((short)23), 23.0f, false, 4); + run_floatQuery(float_filterL, ShortParameter, Short.valueOf((short)34), 34.0f, true, 6); + run_floatQuery(float_filterR, ShortParameter, Short.valueOf((short)100), 100.0f, false, 4); + run_floatQuery(float_filterL, charParameter, Character.valueOf((char)20), 20.0f, true, 6); + run_floatQuery(float_filterR, charParameter, Character.valueOf((char)23), 23.0f, false, 4); + run_floatQuery(float_filterL, CharacterParameter, Character.valueOf((char)34), 34.0f, true, 6); + run_floatQuery(float_filterR, CharacterParameter, Character.valueOf((char)100), 100.0f, false, 4); + run_floatQuery(float_filterL, intParameter, Integer.valueOf(55000000), 55000000.0f, true, 2); + run_floatQuery(float_filterR, intParameter, Integer.valueOf(23), 23.0f, false, 4); + run_floatQuery(float_filterL, IntegerParameter, Integer.valueOf(34), 34.0f, true, 6); + run_floatQuery(float_filterR, IntegerParameter, Integer.valueOf(100), 100.0f, false, 4); + run_floatQuery(float_filterL, longParameter, Long.valueOf(55000000), 55000000.0f, true, 2); + run_floatQuery(float_filterR, longParameter, Long.valueOf(23), 23.0f, false, 4); + run_floatQuery(float_filterL, LongParameter, Long.valueOf(34), 34.0f, true, 6); + run_floatQuery(float_filterR, LongParameter, Long.valueOf(100), 100.0f, false, 4); + run_floatQuery(float_filterL, doubleParameter, Double.valueOf(55000000.0), 55000000.0f, true, 2); + run_floatQuery(float_filterR, doubleParameter, Double.valueOf(-20.5), -20.5f, false, 3); + run_floatQuery(float_filterL, DoubleParameter, Double.valueOf(2.0), 2.0f, true, 6); + run_floatQuery(float_filterR, DoubleParameter, Double.valueOf(100.0), 100.0f, false, 4); + run_floatQuery(float_filterL, BigIntegerParameter, new BigInteger("55000000"), 55000000.0f, true, 2); + run_floatQuery(float_filterR, BigIntegerParameter, new BigInteger("23"), 23.0f, false, 4); + run_floatQuery(float_filterL, BigDecimalParameter, new BigDecimal("55000000.0"), 55000000.0f, true, 2); + run_floatQuery(float_filterR, BigDecimalParameter, new BigDecimal("-20.5"), -20.5f, false, 3); + alltypes.setfloat(23.23f); + run_floatQuery(float_filterObj, AllTypesParameter, alltypes, 23.23f, false, 4); + run_floatQuery(float_filterVal, null, null, 100.0f, false, 4); + + run_doubleQuery(double_filterL, doubleParameter, Double.valueOf(AllTypes.DOUBLE_SMALLEST), AllTypes.DOUBLE_SMALLEST, true, 9); + run_doubleQuery(double_filterR, doubleParameter, Double.valueOf(AllTypes.DOUBLE_LARGEST), AllTypes.DOUBLE_LARGEST, false, 9); + run_doubleQuery(double_filterL, DoubleParameter, Double.valueOf(0.0), 0.0, true, 6); + run_doubleQuery(double_filterR, DoubleParameter, Double.valueOf(23.34), 23.34, false, 4); + run_doubleQuery(double_filterL, byteParameter, Byte.valueOf((byte)100), 100.0, true, 4); + run_doubleQuery(double_filterR, byteParameter, Byte.valueOf((byte)0), 0.0, false, 3); + run_doubleQuery(double_filterL, ByteParameter, Byte.valueOf((byte)23), 23.0, true, 6); + run_doubleQuery(double_filterR, ByteParameter, Byte.valueOf((byte)100), 100.0, false, 4); + run_doubleQuery(double_filterL, charParameter, Character.valueOf((char)100), 100.0, true, 4); + run_doubleQuery(double_filterR, charParameter, Character.valueOf((char)0), 0.0, false, 3); + run_doubleQuery(double_filterL, CharacterParameter, Character.valueOf((char)23), 23.0, true, 6); + run_doubleQuery(double_filterR, CharacterParameter, Character.valueOf((char)100), 100.0, false, 4); + run_doubleQuery(double_filterL, shortParameter, Short.valueOf((short)100), 100.0, true, 4); + run_doubleQuery(double_filterR, shortParameter, Short.valueOf((short)0), 0.0, false, 3); + run_doubleQuery(double_filterL, ShortParameter, Short.valueOf((short)23), 23.0, true, 6); + run_doubleQuery(double_filterR, ShortParameter, Short.valueOf((short)100), 100.0, false, 4); + run_doubleQuery(double_filterL, intParameter, Integer.valueOf(100), 100.0, true, 4); + run_doubleQuery(double_filterR, intParameter, Integer.valueOf(0), 0.0, false, 3); + run_doubleQuery(double_filterL, IntegerParameter, Integer.valueOf(5000), 5000.0, true, 3); + run_doubleQuery(double_filterR, IntegerParameter, Integer.valueOf(-20), -20.0, false, 3); + run_doubleQuery(double_filterL, longParameter, Long.valueOf(100), 100.0, true, 4); + run_doubleQuery(double_filterR, longParameter, Long.valueOf(0), 0.0, false, 3); + run_doubleQuery(double_filterL, LongParameter, Long.valueOf(5000), 5000.0, true, 3); + run_doubleQuery(double_filterR, LongParameter, Long.valueOf(-20), -20.0, false, 3); + run_doubleQuery(double_filterL, floatParameter, Float.valueOf(0.0f), 0.0f, true, 6); + run_doubleQuery(double_filterR, floatParameter, Float.valueOf(100.0f), 100.0f, false, 4); + run_doubleQuery(double_filterL, FloatParameter, Float.valueOf(100.0f), 100.0, true, 4); + run_doubleQuery(double_filterR, FloatParameter, Float.valueOf(69.96f), 69.96, false, 4); + run_doubleQuery(double_filterL, BigIntegerParameter, new BigInteger("5000"), 5000.0, true, 3); + run_doubleQuery(double_filterR, BigIntegerParameter, new BigInteger("-20"), -20.0, false, 3); + run_doubleQuery(double_filterL, BigDecimalParameter, new BigDecimal("100.0"), 100.0, true, 4); + run_doubleQuery(double_filterR, BigDecimalParameter, new BigDecimal("69.96"), 69.96, false, 4); + alltypes.setdouble(-25.5); + run_doubleQuery(double_filterObj, AllTypesParameter, alltypes, -25.5, true, 7); + run_doubleQuery(double_filterVal, null, null, 100.0, false, 4); + + run_ByteQuery(Byte_filterL, byteParameter, Byte.valueOf((byte)50), Byte.valueOf((byte)50), true, 3); + run_ByteQuery(Byte_filterR, byteParameter, Byte.valueOf(Byte.MIN_VALUE), Byte.valueOf(Byte.MIN_VALUE), false, 0); + run_ByteQuery(Byte_filterL, ByteParameter, Byte.valueOf((byte)20), Byte.valueOf((byte)20), true, 5); + run_ByteQuery(Byte_filterR, ByteParameter, Byte.valueOf(Byte.MAX_VALUE), Byte.valueOf(Byte.MAX_VALUE), false, 9); + run_ByteQuery(Byte_filterL, shortParameter, Short.valueOf((short)60), Byte.valueOf((byte)60), true, 3); + run_ByteQuery(Byte_filterR, shortParameter, Short.valueOf((short)51), Byte.valueOf((byte)51), false, 7); + run_ByteQuery(Byte_filterL, ShortParameter, Short.valueOf((short)-100), Byte.valueOf((byte)-100), true, 8); + run_ByteQuery(Byte_filterR, ShortParameter, Short.valueOf((short)-100), Byte.valueOf((byte)-100), false, 1); + run_ByteQuery(Byte_filterL, charParameter, Character.valueOf((char)101), Byte.valueOf((byte)101), true, 1); + run_ByteQuery(Byte_filterR, charParameter, Character.valueOf((char)10), Byte.valueOf((byte)10), false, 4); + run_ByteQuery(Byte_filterL, CharacterParameter, Character.valueOf((char)50), Byte.valueOf((byte)50), true, 3); + run_ByteQuery(Byte_filterR, CharacterParameter, Character.valueOf((char)75), Byte.valueOf((byte)75), false, 7); + run_ByteQuery(Byte_filterL, intParameter, Integer.valueOf(77), Byte.valueOf((byte)77), true, 2); + run_ByteQuery(Byte_filterR, intParameter, Integer.valueOf(60), Byte.valueOf((byte)60), false, 7); + run_ByteQuery(Byte_filterL, IntegerParameter, Integer.valueOf(40), Byte.valueOf((byte)40), true, 5); + run_ByteQuery(Byte_filterR, IntegerParameter, Integer.valueOf(75), Byte.valueOf((byte)75), false, 7); + run_ByteQuery(Byte_filterL, longParameter, Long.valueOf(50), Byte.valueOf((byte)50), true, 3); + run_ByteQuery(Byte_filterR, longParameter, Long.valueOf(50), Byte.valueOf((byte)50), false, 5); + run_ByteQuery(Byte_filterL, LongParameter, Long.valueOf(-100), Byte.valueOf((byte)-100), true, 8); + run_ByteQuery(Byte_filterR, LongParameter, Long.valueOf(-100), Byte.valueOf((byte)-100), false, 1); + run_ByteQuery(Byte_filterL, floatParameter, Float.valueOf((float)50), Byte.valueOf((byte)50), true, 3); + run_ByteQuery(Byte_filterR, floatParameter, Float.valueOf((float)50), Byte.valueOf((byte)50), false, 5); + run_ByteQuery(Byte_filterL, FloatParameter, Float.valueOf((float)-100), Byte.valueOf((byte)-100), true, 8); + run_ByteQuery(Byte_filterR, FloatParameter, Float.valueOf((float)-100), Byte.valueOf((byte)-100), false, 1); + run_ByteQuery(Byte_filterL, doubleParameter, Double.valueOf(50), Byte.valueOf((byte)50), true, 3); + run_ByteQuery(Byte_filterR, doubleParameter, Double.valueOf(50), Byte.valueOf((byte)50), false, 5); + run_ByteQuery(Byte_filterL, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte)-100), true, 8); + run_ByteQuery(Byte_filterR, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte)-100), false, 1); + run_ByteQuery(Byte_filterL, BigIntegerParameter, new BigInteger("50"), Byte.valueOf((byte)50), true, 3); + run_ByteQuery(Byte_filterR, BigIntegerParameter, new BigInteger("-100"), Byte.valueOf((byte)-100), false, 1); + run_ByteQuery(Byte_filterL, BigDecimalParameter, new BigDecimal("50.000000"), Byte.valueOf((byte)50), true, 3); + run_ByteQuery(Byte_filterR, BigDecimalParameter, new BigDecimal("10.000000"), Byte.valueOf((byte)10), false, 4); + Byte val = Byte.valueOf((byte)50); + alltypes.setByte(val); + run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, false, 5); + val = Byte.valueOf((byte)51); + alltypes.setByte(val); + run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, false, 7); + run_ByteQuery(Byte_filterVal, null, null, Byte.valueOf((byte)100), true, 1); + + run_ShortQuery(Short_filterL, shortParameter, Short.valueOf((short)100), Short.valueOf((short)100), true, 3); + run_ShortQuery(Short_filterR, shortParameter, Short.valueOf((short)100), Short.valueOf((short)100), false, 5); + run_ShortQuery(Short_filterL, ShortParameter, Short.valueOf(Short.MIN_VALUE), Short.valueOf(Short.MIN_VALUE), true, 9); + run_ShortQuery(Short_filterR, ShortParameter, Short.valueOf((short)253), Short.valueOf((short)253), false, 7); + run_ShortQuery(Short_filterR, shortParameter, Short.valueOf((short)1000), Short.valueOf((short)1000), false, 7); + run_ShortQuery(Short_filterL, byteParameter, Byte.valueOf((byte)75), Short.valueOf((short)75), true, 5); + run_ShortQuery(Short_filterR, byteParameter, Byte.valueOf((byte)75), Short.valueOf((short)75), false, 5); + run_ShortQuery(Short_filterL, ByteParameter, Byte.valueOf((byte)100), Short.valueOf((short)100), true, 3); + run_ShortQuery(Short_filterR, ByteParameter, Byte.valueOf((byte)100), Short.valueOf((short)100), false, 5); + run_ShortQuery(Short_filterL, charParameter, Character.valueOf((char)75), Short.valueOf((short)75), true, 5); + run_ShortQuery(Short_filterR, charParameter, Character.valueOf((char)75), Short.valueOf((short)75), false, 5); + run_ShortQuery(Short_filterL, CharacterParameter, Character.valueOf((char)100), Short.valueOf((short)100), true, 3); + run_ShortQuery(Short_filterR, CharacterParameter, Character.valueOf((char)200), Short.valueOf((short)200), false, 7); + run_ShortQuery(Short_filterL, intParameter, Integer.valueOf(-10000), Short.valueOf((short)-10000), true, 8); + run_ShortQuery(Short_filterR, intParameter, Integer.valueOf(-10000), Short.valueOf((short)-10000), false, 1); + run_ShortQuery(Short_filterL, IntegerParameter, Integer.valueOf(10000), Short.valueOf((short)10000), true, 1); + run_ShortQuery(Short_filterR, IntegerParameter, Integer.valueOf(10000), Short.valueOf((short)10000), false, 8); + run_ShortQuery(Short_filterL, longParameter, Long.valueOf(20000), Short.valueOf((short) 20000), true, 1); + run_ShortQuery(Short_filterR, longParameter, Long.valueOf(5000), Short.valueOf((short) 5000), false, 8); + run_ShortQuery(Short_filterL, LongParameter, Long.valueOf(200), Short.valueOf((short)200), true, 3); + run_ShortQuery(Short_filterR, LongParameter, Long.valueOf(500), Short.valueOf((short)500), false, 7); + run_ShortQuery(Short_filterL, floatParameter, Float.valueOf(23000.0f), Short.valueOf((short)23000), true, 1); + run_ShortQuery(Short_filterR, floatParameter, Float.valueOf(23000.0f), Short.valueOf((short)23000), false, 9); + run_ShortQuery(Short_filterL, FloatParameter, Float.valueOf(10.0f), Short.valueOf((short)10), true, 5); + run_ShortQuery(Short_filterR, FloatParameter, Float.valueOf(101.0f), Short.valueOf((short)101), false, 7); + run_ShortQuery(Short_filterL, doubleParameter, Double.valueOf(-10000.0), Short.valueOf((short)-10000), true, 8); + run_ShortQuery(Short_filterR, doubleParameter, Double.valueOf(-10000.0), Short.valueOf((short)-10000), false, 1); + run_ShortQuery(Short_filterL, DoubleParameter, Double.valueOf(101.0), Short.valueOf((short)101), true, 3); + run_ShortQuery(Short_filterR, DoubleParameter, Double.valueOf(23.0), Short.valueOf((short)23), false, 5); + run_ShortQuery(Short_filterL, BigIntegerParameter, new BigInteger("10000"), Short.valueOf((short)10000), true, 1); + run_ShortQuery(Short_filterR, BigIntegerParameter, new BigInteger("30000"), Short.valueOf((short)30000), false, 9); + run_ShortQuery(Short_filterL, BigDecimalParameter, new BigDecimal("23.0"), Short.valueOf((short)23), true, 5); + run_ShortQuery(Short_filterR, BigDecimalParameter, new BigDecimal("23.0"), Short.valueOf((short)23), false, 5); + Short sval = Short.valueOf((short)100); + alltypes.setShort(sval); + run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, false, 5); + sval = Short.valueOf((short)23); + alltypes.setShort(sval); + run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, false, 5); + run_ShortQuery(Short_filterVal, null, null, Short.valueOf((short)-1000), true, 7); + + run_CharacterQuery(Character_filterL, charParameter, Character.valueOf(Character.MIN_VALUE), Character.valueOf(Character.MIN_VALUE), true, 9); + run_CharacterQuery(Character_filterR, charParameter, Character.valueOf(Character.MAX_VALUE), Character.valueOf(Character.MAX_VALUE), false, 9); + run_CharacterQuery(Character_filterL, charParameter, Character.valueOf('C'), Character.valueOf('C'), true, 6); + run_CharacterQuery(Character_filterR, charParameter, Character.valueOf('z'), Character.valueOf('z'), false, 7); + run_CharacterQuery(Character_filterL, CharacterParameter, Character.valueOf(' '), Character.valueOf(' '), true, 8); + run_CharacterQuery(Character_filterR, CharacterParameter, Character.valueOf('f'), Character.valueOf('f'), false, 7); + run_CharacterQuery(Character_filterL, byteParameter, Byte.valueOf((byte)Character.MIN_VALUE), Character.valueOf((char)Character.MIN_VALUE), true, 9); + run_CharacterQuery(Character_filterR, ByteParameter, Byte.valueOf((byte)'a'), Character.valueOf('a'), false, 7); + run_CharacterQuery(Character_filterL, shortParameter, Short.valueOf((short)'M'), Character.valueOf('M'), true, 3); + run_CharacterQuery(Character_filterR, shortParameter, Short.valueOf((short)'F'), Character.valueOf('F'), false, 4); + run_CharacterQuery(Character_filterL, ShortParameter, Short.valueOf((short)'A'), Character.valueOf('A'), true, 7); + run_CharacterQuery(Character_filterR, ShortParameter, Short.valueOf((short)'A'), Character.valueOf('A'), false, 2); + run_CharacterQuery(Character_filterL, intParameter, Integer.valueOf('z'), Character.valueOf('z'), true, 1); + run_CharacterQuery(Character_filterR, intParameter, Integer.valueOf('z'), Character.valueOf('z'), false, 7); + run_CharacterQuery(Character_filterL, IntegerParameter, Integer.valueOf('B'), Character.valueOf('B'), true, 6); + run_CharacterQuery(Character_filterR, IntegerParameter, Integer.valueOf('B'), Character.valueOf('B'), false, 3); + run_CharacterQuery(Character_filterL, longParameter, Long.valueOf('z'), Character.valueOf('z'), true, 1); + run_CharacterQuery(Character_filterR, longParameter, Long.valueOf('z'), Character.valueOf('z'), false, 7); + run_CharacterQuery(Character_filterL, LongParameter, Long.valueOf('B'), Character.valueOf('B'), true, 6); + run_CharacterQuery(Character_filterR, LongParameter, Long.valueOf('B'), Character.valueOf('B'), false, 3); + run_CharacterQuery(Character_filterL, floatParameter, Float.valueOf((float)'z'), Character.valueOf('z'), true, 1); + run_CharacterQuery(Character_filterR, floatParameter, Float.valueOf((float)'z'), Character.valueOf('z'), false, 7); + run_CharacterQuery(Character_filterL, FloatParameter, Float.valueOf((float)'M'), Character.valueOf('M'), true, 3); + run_CharacterQuery(Character_filterR, FloatParameter, Float.valueOf((float)'X'), Character.valueOf('X'), false, 7); + run_CharacterQuery(Character_filterL, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), true, 6); + run_CharacterQuery(Character_filterR, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), false, 3); + run_CharacterQuery(Character_filterL, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), true, 7); + run_CharacterQuery(Character_filterR, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), false, 2); + run_CharacterQuery(Character_filterL, BigIntegerParameter, new BigInteger("65"), Character.valueOf('A'), true, 7); // 'A' == 65 + run_CharacterQuery(Character_filterR, BigIntegerParameter, new BigInteger("122"), Character.valueOf('z'), false, 7); // 'z' == 122 + run_CharacterQuery(Character_filterL, BigDecimalParameter, new BigDecimal("65.00000"), Character.valueOf('A'), true, 7); + run_CharacterQuery(Character_filterR, BigDecimalParameter, new BigDecimal("77.0000"), Character.valueOf('M'), false, 5); // 'M' == 77 + alltypes.setCharacter(Character.valueOf('A')); + run_CharacterQuery(Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('A'), true, 7); + alltypes.setCharacter(Character.valueOf('b')); + run_CharacterQuery(Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('b'), true, 3); + run_CharacterQuery(Character_filterVal, null, null, Character.valueOf('z'), false, 7); + + run_IntegerQuery(Integer_filterL, intParameter, Integer.valueOf(AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), true, 9); + run_IntegerQuery(Integer_filterR, intParameter, Integer.valueOf(AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), false, 9); + run_IntegerQuery(Integer_filterR, intParameter, Integer.valueOf(23), Integer.valueOf(23), false, 4); + run_IntegerQuery(Integer_filterL, IntegerParameter, Integer.valueOf(1000000), Integer.valueOf(1000000), true, 1); + run_IntegerQuery(Integer_filterR, IntegerParameter, Integer.valueOf(1000), Integer.valueOf(1000), false, 6); + run_IntegerQuery(Integer_filterL, byteParameter, Byte.valueOf((byte)100), Integer.valueOf(100), true, 4); + run_IntegerQuery(Integer_filterR, byteParameter, Byte.valueOf((byte)0), Integer.valueOf(0), false, 3); + run_IntegerQuery(Integer_filterL, ByteParameter, Byte.valueOf((byte)100), Integer.valueOf(100), true, 4); + run_IntegerQuery(Integer_filterR, ByteParameter, Byte.valueOf((byte)0), Integer.valueOf(0), false, 3); + run_IntegerQuery(Integer_filterL, shortParameter, Short.valueOf((short)10000), Integer.valueOf(10000), true, 2); + run_IntegerQuery(Integer_filterR, shortParameter, Short.valueOf((short)-1000), Integer.valueOf(-1000), false, 2); + run_IntegerQuery(Integer_filterL, ShortParameter, Short.valueOf((short)-1000), Integer.valueOf(-1000), true, 7); + run_IntegerQuery(Integer_filterR, ShortParameter, Short.valueOf((short)-999), Integer.valueOf(-999), false, 3); + run_IntegerQuery(Integer_filterL, charParameter, Character.valueOf((char)10000), Integer.valueOf(10000), true, 2); + run_IntegerQuery(Integer_filterR, charParameter, Character.valueOf((char)10000), Integer.valueOf(10000), false, 7); + run_IntegerQuery(Integer_filterL, CharacterParameter, Character.valueOf((char)100), Integer.valueOf(100), true, 4); + run_IntegerQuery(Integer_filterR, CharacterParameter, Character.valueOf((char)10000), Integer.valueOf(10000), false, 7); + run_IntegerQuery(Integer_filterL, longParameter, Long.valueOf(AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), true, 0); + run_IntegerQuery(Integer_filterR, longParameter, Long.valueOf(AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), false, 0); + run_IntegerQuery(Integer_filterL, LongParameter, Long.valueOf(10000), Integer.valueOf(10000), true, 2); + run_IntegerQuery(Integer_filterR, LongParameter, Long.valueOf(43), Integer.valueOf(43), false, 4); + run_IntegerQuery(Integer_filterL, floatParameter, Float.valueOf((float)AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), true, 0); + run_IntegerQuery(Integer_filterR, floatParameter, Float.valueOf((float)AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), false, 0); + run_IntegerQuery(Integer_filterL, FloatParameter, Float.valueOf((float)10000), Integer.valueOf(10000), true, 2); + run_IntegerQuery(Integer_filterR, FloatParameter, Float.valueOf((float)43), Integer.valueOf(43), false, 4); + run_IntegerQuery(Integer_filterL, doubleParameter, Double.valueOf(AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), true, 0); + run_IntegerQuery(Integer_filterR, doubleParameter, Double.valueOf(AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), false, 0); + run_IntegerQuery(Integer_filterL, DoubleParameter, Double.valueOf(10000), Integer.valueOf(10000), true, 2); + run_IntegerQuery(Integer_filterR, DoubleParameter, Double.valueOf(1000001.0), Integer.valueOf(1000001), false, 9); + run_IntegerQuery(Integer_filterL, BigIntegerParameter, new BigInteger("1000000"), Integer.valueOf(1000000), true, 1); + run_IntegerQuery(Integer_filterR, BigIntegerParameter, new BigInteger("1000"), Integer.valueOf(1000), false, 6); + run_IntegerQuery(Integer_filterL, BigDecimalParameter, new BigDecimal("10000.0"), Integer.valueOf(10000), true, 2); + run_IntegerQuery(Integer_filterR, BigDecimalParameter, new BigDecimal("43.0"), Integer.valueOf(43), false, 4); + alltypes.setInteger(Integer.valueOf(100)); + run_IntegerQuery(Integer_filterObj, AllTypesParameter, alltypes, Integer.valueOf(100), false, 4); + run_IntegerQuery(Integer_filterVal, null, null, Integer.valueOf(100), false, 4); + + run_LongQuery(Long_filterL, longParameter, Long.valueOf(Long.MIN_VALUE), Long.valueOf(Long.MIN_VALUE), true, 9); + run_LongQuery(Long_filterR, longParameter, Long.valueOf(Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE), false, 9); + run_LongQuery(Long_filterL, LongParameter, Long.valueOf(100), Long.valueOf(100), true, 3); + run_LongQuery(Long_filterR, LongParameter, Long.valueOf(23), Long.valueOf(23), false, 5); + run_LongQuery(Long_filterL, byteParameter, Byte.valueOf((byte)100), Long.valueOf(100), true, 3); + run_LongQuery(Long_filterR, byteParameter, Byte.valueOf((byte)0), Long.valueOf(0), false, 4); + run_LongQuery(Long_filterL, ByteParameter, Byte.valueOf((byte)100), Long.valueOf(100), true, 3); + run_LongQuery(Long_filterR, ByteParameter, Byte.valueOf((byte)0), Long.valueOf(0), false, 4); + run_LongQuery(Long_filterL, shortParameter, Short.valueOf((short)-1000 ), Long.valueOf(-1000), true, 6); + run_LongQuery(Long_filterR, shortParameter, Short.valueOf((short)1000), Long.valueOf(1000), false, 7); + run_LongQuery(Long_filterL, ShortParameter, Short.valueOf((short)101), Long.valueOf(101), true, 3); + run_LongQuery(Long_filterR, ShortParameter, Short.valueOf((short)32), Long.valueOf(32), false, 5); + run_LongQuery(Long_filterL, charParameter, Character.valueOf((char)0), Long.valueOf(0), true, 5); + run_LongQuery(Long_filterR, charParameter, Character.valueOf((char)100), Long.valueOf(100), false, 5); + run_LongQuery(Long_filterL, CharacterParameter, Character.valueOf((char)23), Long.valueOf(23), true, 5); + run_LongQuery(Long_filterR, CharacterParameter, Character.valueOf((char)1110), Long.valueOf(1110), false, 8); + run_LongQuery(Long_filterL, intParameter, Integer.valueOf(100), Long.valueOf(100), true, 3); + run_LongQuery(Long_filterR, intParameter, Integer.valueOf(0), Long.valueOf(0), false, 4); + run_LongQuery(Long_filterL, IntegerParameter, Integer.valueOf(23), Long.valueOf(23), true, 5); + run_LongQuery(Long_filterR, IntegerParameter, Integer.valueOf(1000000), Long.valueOf(1000000), false, 8); + run_LongQuery(Long_filterL, floatParameter, Float.valueOf((float)-1000000.0), Long.valueOf(-1000000), true, 8); + run_LongQuery(Long_filterR, floatParameter, Float.valueOf((float)Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE), false, 9); + run_LongQuery(Long_filterL, FloatParameter, Float.valueOf(100.0f), Long.valueOf(100), true, 3); + run_LongQuery(Long_filterR, FloatParameter, Float.valueOf(32.0f), Long.valueOf(32), false, 5); + run_LongQuery(Long_filterL, doubleParameter, Double.valueOf(-1000000.0), Long.valueOf(-1000000), true, 8); + run_LongQuery(Long_filterR, doubleParameter, Double.valueOf((double)Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE), false, 9); + run_LongQuery(Long_filterL, DoubleParameter, Double.valueOf(100.0), Long.valueOf(100), true, 3); + run_LongQuery(Long_filterR, DoubleParameter, Double.valueOf(32.0), Long.valueOf(32), false, 5); + run_LongQuery(Long_filterL, BigIntegerParameter, new BigInteger("23"), Long.valueOf(23), true, 5); + run_LongQuery(Long_filterR, BigIntegerParameter, new BigInteger("1000000"), Long.valueOf(1000000), false, 8); + run_LongQuery(Long_filterL, BigDecimalParameter, new BigDecimal("100.0"), Long.valueOf(100), true, 3); + run_LongQuery(Long_filterR, BigDecimalParameter, new BigDecimal("32.0"), Long.valueOf(32), false, 5); + alltypes.setLong(Long.valueOf(100)); + run_LongQuery(Long_filterObj, AllTypesParameter, alltypes, Long.valueOf(100), true, 3); + run_LongQuery(Long_filterVal, null, null, Long.valueOf(-1000), true, 6); + + run_FloatQuery(Float_filterL, floatParameter, Float.valueOf(-10000000000.0f), Float.valueOf(-10000000000.0f), true, 9); + run_FloatQuery(Float_filterR, floatParameter, Float.valueOf(9000000000.0f), Float.valueOf(9000000000.0f), false, 9); + run_FloatQuery(Float_filterL, FloatParameter, Float.valueOf((float)0.0), Float.valueOf(0.0f), true, 7); + run_FloatQuery(Float_filterR, FloatParameter, Float.valueOf((float)4.0), Float.valueOf(4.0f), false, 3); + run_FloatQuery(Float_filterL, byteParameter, Byte.valueOf((byte)0), Float.valueOf(0.0f), true, 7); + run_FloatQuery(Float_filterR, byteParameter, Byte.valueOf((byte)23), Float.valueOf(23.0f), false, 3); + run_FloatQuery(Float_filterL, ByteParameter, Byte.valueOf((byte)34), Float.valueOf(34.0f), true, 7); + run_FloatQuery(Float_filterR, ByteParameter, Byte.valueOf((byte)100), Float.valueOf(100.0f), false, 3); + run_FloatQuery(Float_filterL, shortParameter, Short.valueOf((short)0), Float.valueOf(0.0f), true, 7); + run_FloatQuery(Float_filterR, shortParameter, Short.valueOf((short)23), Float.valueOf(23.0f), false, 3); + run_FloatQuery(Float_filterL, ShortParameter, Short.valueOf((short)34), Float.valueOf(34.0f), true, 7); + run_FloatQuery(Float_filterR, ShortParameter, Short.valueOf((short)100), Float.valueOf(100.0f), false, 3); + run_FloatQuery(Float_filterL, charParameter, Character.valueOf((char)0), Float.valueOf(0.0f), true, 7); + run_FloatQuery(Float_filterR, charParameter, Character.valueOf((char)23), Float.valueOf(23.0f), false, 3); + run_FloatQuery(Float_filterL, CharacterParameter, Character.valueOf((char)34), Float.valueOf(34.0f), true, 7); + run_FloatQuery(Float_filterR, CharacterParameter, Character.valueOf((char)100), Float.valueOf(100.0f), false, 3); + run_FloatQuery(Float_filterL, intParameter, Integer.valueOf(50000000), Float.valueOf(50000000.0f), true, 2); + run_FloatQuery(Float_filterR, intParameter, Integer.valueOf(23), Float.valueOf(23.0f), false, 3); + run_FloatQuery(Float_filterL, IntegerParameter, Integer.valueOf(34), Float.valueOf(34.0f), true, 7); + run_FloatQuery(Float_filterR, IntegerParameter, Integer.valueOf(100), Float.valueOf(100.0f), false, 3); + run_FloatQuery(Float_filterL, longParameter, Long.valueOf(50000000), Float.valueOf(50000000.0f), true, 2); + run_FloatQuery(Float_filterR, longParameter, Long.valueOf(23), Float.valueOf(23.0f), false, 3); + run_FloatQuery(Float_filterL, LongParameter, Long.valueOf(34), Float.valueOf(34.0f), true, 7); + run_FloatQuery(Float_filterR, LongParameter, Long.valueOf(100), Float.valueOf(100.0f), false, 3); + run_FloatQuery(Float_filterL, doubleParameter, Double.valueOf(50000000.0f), Float.valueOf(50000000.0f), true, 2); + run_FloatQuery(Float_filterR, doubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), false, 3); + run_FloatQuery(Float_filterL, DoubleParameter, Double.valueOf(0.0f), Float.valueOf(0.0f), true, 7); + run_FloatQuery(Float_filterR, DoubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), false, 3); + run_FloatQuery(Float_filterL, BigIntegerParameter, new BigInteger("55000000"), Float.valueOf(55000000.0f), true, 2); + run_FloatQuery(Float_filterR, BigIntegerParameter, new BigInteger("23"), Float.valueOf(23.0f), false, 3); + run_FloatQuery(Float_filterL, BigDecimalParameter, new BigDecimal("55000000.0"), Float.valueOf(55000000.0f), true, 2); + run_FloatQuery(Float_filterR, BigDecimalParameter, new BigDecimal("-25.5"), Float.valueOf(-25.5f), false, 1); + alltypes.setFloat(Float.valueOf(23.23f)); + run_FloatQuery(Float_filterObj, AllTypesParameter, alltypes, Float.valueOf(23.23f), false, 3); + run_FloatQuery(Float_filterVal, null, null, Float.valueOf(100.0f), true, 5); + + run_DoubleQuery(Double_filterL, doubleParameter, Double.valueOf(-999999999999.0), Double.valueOf(-999999999999.0), true, 9); + run_DoubleQuery(Double_filterR, doubleParameter, Double.valueOf(9999999999999.0), Double.valueOf(9999999999999.0), false, 9); + run_DoubleQuery(Double_filterL, DoubleParameter, Double.valueOf(0.0), Double.valueOf(0.0), true, 6); + run_DoubleQuery(Double_filterR, DoubleParameter, Double.valueOf(23.34), Double.valueOf(23.34), false, 4); + run_DoubleQuery(Double_filterL, byteParameter, Byte.valueOf((byte)100), Double.valueOf(100.0), true, 4); + run_DoubleQuery(Double_filterR, byteParameter, Byte.valueOf((byte)0), Double.valueOf(0.0), false, 3); + run_DoubleQuery(Double_filterL, ByteParameter, Byte.valueOf((byte)-23), Double.valueOf(-23.0), true, 7); + run_DoubleQuery(Double_filterR, ByteParameter, Byte.valueOf((byte)100), Double.valueOf(100.0), false, 4); + run_DoubleQuery(Double_filterL, shortParameter, Short.valueOf((short)100), Double.valueOf(100.0), true, 4); + run_DoubleQuery(Double_filterR, shortParameter, Short.valueOf((short)0), Double.valueOf(0.0), false, 3); + run_DoubleQuery(Double_filterL, ShortParameter, Short.valueOf((short)23), Double.valueOf(23.0), true, 6); + run_DoubleQuery(Double_filterR, ShortParameter, Short.valueOf((short)400), Double.valueOf(400.0), false, 7); + run_DoubleQuery(Double_filterL, charParameter, Character.valueOf((char)100), Double.valueOf(100.0), true, 4); + run_DoubleQuery(Double_filterR, charParameter, Character.valueOf((char)0), Double.valueOf(0.0), false, 3); + run_DoubleQuery(Double_filterL, CharacterParameter, Character.valueOf((char)23), Double.valueOf(23.0), true, 6); + run_DoubleQuery(Double_filterR, CharacterParameter, Character.valueOf((char)400), Double.valueOf(400.0), false, 7); + run_DoubleQuery(Double_filterL, intParameter, Integer.valueOf(100), Double.valueOf(100.0), true, 4); + run_DoubleQuery(Double_filterR, intParameter, Integer.valueOf(0), Double.valueOf(0.0), false, 3); + run_DoubleQuery(Double_filterL, IntegerParameter, Integer.valueOf(23), Double.valueOf(23.0), true, 6); + run_DoubleQuery(Double_filterR, IntegerParameter, Integer.valueOf(100), Double.valueOf(100.0), false, 4); + run_DoubleQuery(Double_filterL, longParameter, Long.valueOf(100), Double.valueOf(100.0), true, 4); + run_DoubleQuery(Double_filterR, longParameter, Long.valueOf(0), Double.valueOf(0.0), false, 3); + run_DoubleQuery(Double_filterL, LongParameter, Long.valueOf(23), Double.valueOf(23.0), true, 6); + run_DoubleQuery(Double_filterR, LongParameter, Long.valueOf(100), Double.valueOf(100.0), false, 4); + run_DoubleQuery(Double_filterL, floatParameter, Float.valueOf(0.0f), Double.valueOf(0.0f), true, 6); + run_DoubleQuery(Double_filterR, floatParameter, Float.valueOf(100.0f), Double.valueOf(100.0f), false, 4); + run_DoubleQuery(Double_filterL, FloatParameter, Float.valueOf(100.0f), Double.valueOf(100.0f), true, 4); + run_DoubleQuery(Double_filterR, FloatParameter, Float.valueOf(69.96f), Double.valueOf(69.96), false, 4); + run_DoubleQuery(Double_filterL, BigIntegerParameter, new BigInteger("5000"), Double.valueOf(5000.0), true, 3); + run_DoubleQuery(Double_filterR, BigIntegerParameter, new BigInteger("-20"), Double.valueOf(-20.0), false, 3); + run_DoubleQuery(Double_filterL, BigDecimalParameter, new BigDecimal("100.0"), Double.valueOf(100.0), true, 4); + run_DoubleQuery(Double_filterR, BigDecimalParameter, new BigDecimal("69.96"), Double.valueOf(69.96), false, 4); + alltypes.setDouble(Double.valueOf(-999999999999.0)); + run_DoubleQuery(Double_filterObj, AllTypesParameter, alltypes, Double.valueOf(-999999999999.0), true, 9); + run_DoubleQuery(Double_filterVal, null, null, Double.valueOf(100.0), false, 4); - BigInteger bi = new BigInteger("987034534985043985"); - run_BigIntegerQuery(BigInteger_filterL, BigIntegerParameter, bi, bi, true, 0); - bi = new BigInteger("-999999999999999999"); - run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, false, 0); - bi = new BigInteger("-9999999999999999999"); - run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, false, 0); - bi = new BigInteger("1333330"); - alltypes.setBigInteger(bi); - run_BigIntegerQuery(BigInteger_filterObj, AllTypesParameter, alltypes, bi, false, 7); + run_StringQuery(String_filterL, StringParameter, new String("JDO"), new String("JDO"), true, 8); + run_StringQuery(String_filterR, StringParameter, new String("JDBC"), new String("JDBC"), false, 1); + alltypes.setString(new String("abcde")); + run_StringQuery(String_filterObj, AllTypesParameter, alltypes, new String("abcde"), true, 2); + run_StringQuery(String_filterVal1, null, null, new String("Java"), false, 4); + run_StringQuery(String_filterVal2, null, null, new String(""), false, 0); - GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.UK); - gc.clear(); - gc.set(1999, Calendar.DECEMBER, 31, 9, 0, 0); - Date d = gc.getTime(); - run_DateQuery(Date_filterL, DateParameter, d, d, true, 2); - gc.set(1992, Calendar.NOVEMBER, 22, 9, 0, 0); - d = gc.getTime(); - run_DateQuery(Date_filterR, DateParameter, d, d, false, 5); - gc.set(1959, Calendar.OCTOBER, 9, 9, 0, 0); - d = gc.getTime(); - run_DateQuery(Date_filterR, DateParameter, d, d, false, 3); - gc.set(1995, Calendar.JUNE, 14, 9, 0, 0); - d = gc.getTime(); - alltypes.setDate(d); - run_DateQuery(Date_filterObj, AllTypesParameter, alltypes, d, false, 6); - } + BigDecimal bd = new BigDecimal("100.0"); + run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, true, 4); + bd = new BigDecimal("-234234.23333"); + run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, false, 1); + bd = new BigDecimal("989899.33304953"); + run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, true, 3); + bd = new BigDecimal("-1123123.22"); + run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, false, 0); + alltypes.setBigDecimal(bd); + run_BigDecimalQuery(BigDecimal_filterObj, AllTypesParameter, alltypes, bd, true, 9); - private void run_byteQuery( - String filter, - String parameter, - Object parameterValue, - byte value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - byte val = obj.getbyte(); - boolean correct_value = valueOnLeft ? value < val : val < value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + BigInteger bi = new BigInteger("987034534985043985"); + run_BigIntegerQuery(BigInteger_filterL, BigIntegerParameter, bi, bi, true, 0); + bi = new BigInteger("-999999999999999999"); + run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, false, 0); + bi = new BigInteger("-9999999999999999999"); + run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, false, 0); + bi = new BigInteger("1333330"); + alltypes.setBigInteger(bi); + run_BigIntegerQuery(BigInteger_filterObj, AllTypesParameter, alltypes, bi, false, 7); + + GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.UK); + gc.clear(); + gc.set(1999, Calendar.DECEMBER, 31, 9, 0, 0); + Date d = gc.getTime(); + run_DateQuery(Date_filterL, DateParameter, d, d, true, 2); + gc.set(1992, Calendar.NOVEMBER, 22, 9, 0, 0); + d = gc.getTime(); + run_DateQuery(Date_filterR, DateParameter, d, d, false, 5); + gc.set(1959, Calendar.OCTOBER, 9, 9, 0, 0); + d = gc.getTime(); + run_DateQuery(Date_filterR, DateParameter, d, d, false, 3); + gc.set(1995, Calendar.JUNE, 14, 9, 0, 0); + d = gc.getTime(); + alltypes.setDate(d); + run_DateQuery(Date_filterObj, AllTypesParameter, alltypes, d, false, 6); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_shortQuery( - String filter, - String parameter, - Object parameterValue, - short value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - short val = obj.getshort(); - boolean correct_value = valueOnLeft ? value < val : val < value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_byteQuery(String filter, String parameter, Object parameterValue, + byte value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + byte val = obj.getbyte(); + boolean correct_value = valueOnLeft ? value < val : val < value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_charQuery( - String filter, - String parameter, - Object parameterValue, - char value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - char val = obj.getchar(); - boolean correct_value = valueOnLeft ? value < val : val < value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_shortQuery(String filter, String parameter, Object parameterValue, + short value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + short val = obj.getshort(); + boolean correct_value = valueOnLeft ? value < val : val < value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_intQuery( - String filter, - String parameter, - Object parameterValue, - int value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - int val = obj.getint(); - boolean correct_value = valueOnLeft ? value < val : val < value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_charQuery(String filter, String parameter, Object parameterValue, + char value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + char val = obj.getchar(); + boolean correct_value = valueOnLeft ? value < val : val < value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_longQuery( - String filter, - String parameter, - Object parameterValue, - long value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - long val = obj.getlong(); - boolean correct_value = valueOnLeft ? value < val : val < value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_intQuery(String filter, String parameter, Object parameterValue, + int value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + int val = obj.getint(); + boolean correct_value = valueOnLeft ? value < val : val < value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_floatQuery( - String filter, - String parameter, - Object parameterValue, - float value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - float val = obj.getfloat(); - boolean correct_value = valueOnLeft ? value < val : val < value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_longQuery(String filter, String parameter, Object parameterValue, + long value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + long val = obj.getlong(); + boolean correct_value = valueOnLeft ? value < val : val < value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_doubleQuery( - String filter, - String parameter, - Object parameterValue, - double value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - double val = obj.getdouble(); - boolean correct_value = valueOnLeft ? value < val : val < value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_floatQuery(String filter, String parameter, Object parameterValue, + float value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + float val = obj.getfloat(); + boolean correct_value = valueOnLeft ? value < val : val < value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_ByteQuery( - String filter, - String parameter, - Object parameterValue, - Byte value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Byte val = obj.getByte(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_doubleQuery(String filter, String parameter, Object parameterValue, + double value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + double val = obj.getdouble(); + boolean correct_value = valueOnLeft ? value < val : val < value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_ShortQuery( - String filter, - String parameter, - Object parameterValue, - Short value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Short val = obj.getShort(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_ByteQuery(String filter, String parameter, Object parameterValue, + Byte value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Byte val = obj.getByte(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_CharacterQuery( - String filter, - String parameter, - Object parameterValue, - Character value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Character val = obj.getCharacter(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_ShortQuery(String filter, String parameter, Object parameterValue, + Short value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Short val = obj.getShort(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_IntegerQuery( - String filter, - String parameter, - Object parameterValue, - Integer value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Integer val = obj.getInteger(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_CharacterQuery(String filter, String parameter, Object parameterValue, + Character value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Character val = obj.getCharacter(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_LongQuery( - String filter, - String parameter, - Object parameterValue, - Long value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Long val = obj.getLong(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_IntegerQuery(String filter, String parameter, Object parameterValue, + Integer value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Integer val = obj.getInteger(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_FloatQuery( - String filter, - String parameter, - Object parameterValue, - Float value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Float val = obj.getFloat(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_LongQuery(String filter, String parameter, Object parameterValue, + Long value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Long val = obj.getLong(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_DoubleQuery( - String filter, - String parameter, - Object parameterValue, - Double value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Double val = obj.getDouble(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_FloatQuery(String filter, String parameter, Object parameterValue, + Float value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Float val = obj.getFloat(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_StringQuery( - String filter, - String parameter, - Object parameterValue, - String value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - String val = obj.getString(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_DoubleQuery(String filter, String parameter, Object parameterValue, + Double value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Double val = obj.getDouble(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_BigDecimalQuery( - String filter, - String parameter, - Object parameterValue, - BigDecimal value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - BigDecimal val = obj.getBigDecimal(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_StringQuery(String filter, String parameter, Object parameterValue, + String value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + String val = obj.getString(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_BigIntegerQuery( - String filter, - String parameter, - Object parameterValue, - BigInteger value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - BigInteger val = obj.getBigInteger(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_BigDecimalQuery(String filter, String parameter, Object parameterValue, + BigDecimal value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + BigDecimal val = obj.getBigDecimal(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_DateQuery( - String filter, - String parameter, - Object parameterValue, - Date value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Date val = obj.getDate(); - boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_BigIntegerQuery(String filter, String parameter, Object parameterValue, + BigInteger value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + BigInteger val = obj.getBigInteger(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThan test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + + private void run_DateQuery(String filter, String parameter, Object parameterValue, + Date value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Date val = obj.getDate(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) < 0) : (val.compareTo(value) < 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThan test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - /** */ - protected void localSetUp() { - addTearDownClass(AllTypes.class); - AllTypes.load(getPM()); - } + /** */ + protected void localSetUp() { + addTearDownClass(AllTypes.class); + AllTypes.load(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/LessThanOrEqual.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/LessThanOrEqual.java index d07cf6d8d..68ec0e1fd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/LessThanOrEqual.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/LessThanOrEqual.java @@ -5,16 +5,16 @@ * 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 + * + * 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.jdo.tck.query.jdoql.operators; import java.math.BigDecimal; @@ -25,2362 +25,1183 @@ import java.util.Iterator; import java.util.Locale; import java.util.TimeZone; + import org.apache.jdo.tck.pc.fieldtypes.AllTypes; import org.apache.jdo.tck.util.BatchTestRunner; -/** - * Title: Less Than or Equal Query Operator
    - * Keywords: query
    - * Assertion ID: A14.6.2-19.
    - * Assertion Description: The less than or equal operator (<=) is supported - * for all types as they are defined in the Java language. This includes the following types: - * - *
      - *
    • byte, short, int, long, char, Byte, Short Integer, Long, Character - *
    • float, double, Float, Double - *
    • BigDecimal, BigInteger - *
    • Date, String - *
    - * - * The operation on object-valued fields of wrapper types (Boolean, Byte, - * Short, Integer, Long, Float, and Double), and numeric types (BigDecimal - * and BigInteger) use the wrapped values as operands. - */ -public class LessThanOrEqual extends ComparisonTests { - private static String boolean_filterL = "value <= fld_boolean"; - private static String boolean_filterR = "fld_boolean <= value"; - private static String boolean_filterT = "fld_boolean <= true"; - private static String boolean_filterF = "false <= fld_boolean"; - private static String boolean_filterObj = "value.fld_boolean <= fld_boolean"; - - private static String byte_filterL = "value <= fld_byte"; - private static String byte_filterR = "fld_byte <= value"; - private static String byte_filterObj = "value.fld_byte <= fld_byte"; - private static String byte_filterVal = "fld_byte <= 100"; - - private static String char_filterL = "value <= fld_char"; - private static String char_filterR = "fld_char <= value"; - private static String char_filterObj = "value.fld_char <= fld_char"; - private static String char_filterVal = "'M' <= fld_char"; - - private static String double_filterL = "value <= fld_double"; - private static String double_filterR = "fld_double <= value"; - private static String double_filterObj = "value.fld_double <= fld_double"; - private static String double_filterVal = "fld_double <= 100.0"; - - private static String float_filterL = "value <= fld_float"; - private static String float_filterR = "fld_float <= value"; - private static String float_filterObj = "fld_float <= value.fld_float"; - private static String float_filterVal = "fld_float <= 100.0"; - - private static String int_filterL = "value <= fld_int"; - private static String int_filterR = "fld_int <= value"; - private static String int_filterObj = "value.fld_int <= fld_int"; - private static String int_filterVal = "fld_int <= 1000"; - - private static String long_filterL = "value <= fld_long"; - private static String long_filterR = "fld_long <= value"; - private static String long_filterObj = "fld_long <= value.fld_long"; - private static String long_filterVal = "fld_long <= 1000000"; - - private static String short_filterL = "value <= fld_short"; - private static String short_filterR = "fld_short <= value"; - private static String short_filterObj = "value.fld_short <= fld_short"; - private static String short_filterVal = "1000 <= fld_short"; - - private static String Boolean_filterL = "value <= fld_Boolean"; - private static String Boolean_filterR = "fld_Boolean <= value"; - private static String Boolean_filterT = "fld_Boolean <= true"; - private static String Boolean_filterF = "false <= fld_Boolean"; - private static String Boolean_filterObj = "value.fld_Boolean <= fld_Boolean"; - private static String Boolean_filterVal = "fld_Boolean <= false"; - - private static String Byte_filterL = "value <= fld_Byte"; - private static String Byte_filterR = "fld_Byte <= value"; - private static String Byte_filterObj = "fld_Byte <= value.fld_Byte"; - private static String Byte_filterVal = "100 <= fld_Byte"; - - private static String Character_filterL = "value <= fld_Character"; - private static String Character_filterR = "fld_Character <= value"; - private static String Character_filterObj = "value.fld_Character <= fld_Character"; - private static String Character_filterVal = "fld_Character <= 'z'"; - - private static String Double_filterL = "value <= fld_Double"; - private static String Double_filterR = "fld_Double <= value"; - private static String Double_filterObj = "value.fld_Double <= fld_Double"; - private static String Double_filterVal = "fld_Double <= 100.0"; - - private static String Float_filterL = "value <= fld_Float"; - private static String Float_filterR = "fld_Float <= value"; - private static String Float_filterObj = "fld_Float <= value.fld_Float"; - private static String Float_filterVal = "100.0f <= fld_Float"; - - private static String Integer_filterL = "value <= fld_Integer"; - private static String Integer_filterR = "fld_Integer <= value"; - private static String Integer_filterObj = "fld_Integer <= value.fld_Integer"; - private static String Integer_filterVal = "fld_Integer <= 100"; - - private static String Long_filterL = "value <= fld_Long"; - private static String Long_filterR = "fld_Long <= value"; - private static String Long_filterObj = "value.fld_Long <= fld_Long"; - private static String Long_filterVal = "-1000 <= fld_Long"; - - private static String Short_filterL = "value <= fld_Short"; - private static String Short_filterR = "fld_Short <= value"; - private static String Short_filterObj = "fld_Short <= value.fld_Short"; - private static String Short_filterVal = "-1000 <= fld_Short"; - - private static String String_filterL = "value <= fld_String"; - private static String String_filterR = "fld_String <= value"; - private static String String_filterObj = "value.fld_String <= fld_String"; - private static String String_filterVal1 = "fld_String <= \"Java\""; - private static String String_filterVal2 = "fld_String <= \"\""; - - private static String Date_filterL = "value <= fld_Date"; - private static String Date_filterR = "fld_Date <= value"; - private static String Date_filterObj = "fld_Date <= value.fld_Date"; - - private static String BigDecimal_filterL = "value <= fld_BigDecimal"; - private static String BigDecimal_filterR = "fld_BigDecimal <= value"; - private static String BigDecimal_filterObj = "value.fld_BigDecimal <= fld_BigDecimal"; - - private static String BigInteger_filterL = "value <= fld_BigInteger"; - private static String BigInteger_filterR = "fld_BigInteger <= value"; - private static String BigInteger_filterObj = "fld_BigInteger <= value.fld_BigInteger"; - - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.2-19 (LessThanOrEqual) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(LessThanOrEqual.class); - } - - /** */ - public void test() { - pm = getPM(); - tx = pm.currentTransaction(); - runQueries(); - } - - /** */ - private void runQueries() { - AllTypes alltypes = new AllTypes(); - run_byteQuery(byte_filterL, byteParameter, Byte.valueOf((byte) 0), (byte) 0, true, 7); - run_byteQuery( - byte_filterR, byteParameter, Byte.valueOf(Byte.MIN_VALUE), Byte.MIN_VALUE, false, 1); - run_byteQuery(byte_filterL, ByteParameter, Byte.valueOf((byte) 50), (byte) 50, true, 5); - run_byteQuery( - byte_filterR, ByteParameter, Byte.valueOf(Byte.MAX_VALUE), Byte.MAX_VALUE, false, 10); - run_byteQuery(byte_filterL, shortParameter, Short.valueOf((short) 75), (byte) 75, true, 3); - run_byteQuery(byte_filterR, shortParameter, Short.valueOf((short) 75), (byte) 75, false, 8); - run_byteQuery(byte_filterL, ShortParameter, Short.valueOf((short) 10), (byte) 10, true, 6); - run_byteQuery(byte_filterR, ShortParameter, Short.valueOf((short) 25), (byte) 25, false, 5); - run_byteQuery(byte_filterL, charParameter, Character.valueOf((char) 101), (byte) 101, true, 1); - run_byteQuery(byte_filterR, charParameter, Character.valueOf((char) 50), (byte) 50, false, 7); - run_byteQuery(byte_filterL, CharacterParameter, Character.valueOf((char) 0), (byte) 0, true, 7); - run_byteQuery( - byte_filterR, CharacterParameter, Character.valueOf((char) 0), (byte) 0, false, 4); - run_byteQuery(byte_filterL, intParameter, Integer.valueOf(25), (byte) 25, true, 5); - run_byteQuery(byte_filterR, intParameter, Integer.valueOf(50), (byte) 50, false, 7); - run_byteQuery(byte_filterL, IntegerParameter, Integer.valueOf(-10), (byte) -10, true, 8); - run_byteQuery(byte_filterR, IntegerParameter, Integer.valueOf(-100), (byte) -100, false, 2); - run_byteQuery(byte_filterL, longParameter, Long.valueOf(50), (byte) 50, true, 5); - run_byteQuery(byte_filterR, longParameter, Long.valueOf(60), (byte) 60, false, 7); - run_byteQuery(byte_filterL, LongParameter, Long.valueOf(-100), (byte) -100, true, 9); - run_byteQuery(byte_filterR, LongParameter, Long.valueOf(-100), (byte) -100, false, 2); - run_byteQuery(byte_filterL, floatParameter, Float.valueOf((float) 51), (byte) 51, true, 3); - run_byteQuery(byte_filterR, floatParameter, Float.valueOf((float) -20), (byte) -20, false, 2); - run_byteQuery(byte_filterL, FloatParameter, Float.valueOf((float) -99), (byte) -99, true, 8); - run_byteQuery(byte_filterR, FloatParameter, Float.valueOf((float) -100), (byte) -100, false, 2); - run_byteQuery(byte_filterL, doubleParameter, Double.valueOf(50), (byte) 50, true, 5); - run_byteQuery(byte_filterR, doubleParameter, Double.valueOf(60), (byte) 60, false, 7); - run_byteQuery( - byte_filterL, DoubleParameter, Double.valueOf(Byte.MAX_VALUE), Byte.MAX_VALUE, true, 1); - run_byteQuery(byte_filterR, DoubleParameter, Double.valueOf(25), (byte) 25, false, 5); - run_byteQuery(byte_filterL, BigIntegerParameter, new BigInteger("50"), (byte) 50, true, 5); - run_byteQuery(byte_filterR, BigIntegerParameter, new BigInteger("-100"), (byte) -100, false, 2); - run_byteQuery( - byte_filterL, BigDecimalParameter, new BigDecimal("50.000000"), (byte) 50, true, 5); - run_byteQuery( - byte_filterR, BigDecimalParameter, new BigDecimal("10.00000"), (byte) 10, false, 5); - alltypes.setbyte((byte) 50); - run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte) 50, true, 5); - alltypes.setbyte((byte) 55); - run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte) 55, true, 3); - run_byteQuery(byte_filterVal, null, null, (byte) 100, false, 9); - - run_shortQuery(short_filterL, shortParameter, Short.valueOf((short) 100), (short) 100, true, 5); - run_shortQuery( - short_filterR, shortParameter, Short.valueOf((short) 100), (short) 100, false, 7); - run_shortQuery( - short_filterL, ShortParameter, Short.valueOf(Short.MIN_VALUE), Short.MIN_VALUE, true, 10); - run_shortQuery( - short_filterR, ShortParameter, Short.valueOf((short) 253), (short) 253, false, 7); - run_shortQuery( - short_filterR, shortParameter, Short.valueOf((short) 1000), (short) 1000, false, 8); - run_shortQuery(short_filterL, byteParameter, Byte.valueOf((byte) 75), (short) 75, true, 5); - run_shortQuery(short_filterR, byteParameter, Byte.valueOf((byte) -75), (short) -75, false, 4); - run_shortQuery(short_filterL, ByteParameter, Byte.valueOf((byte) 100), (short) 100, true, 5); - run_shortQuery(short_filterR, ByteParameter, Byte.valueOf((byte) 100), (short) 100, false, 7); - run_shortQuery(short_filterL, charParameter, Character.valueOf((char) 75), (short) 75, true, 5); - run_shortQuery( - short_filterR, charParameter, Character.valueOf((char) 9999), (short) 9999, false, 8); - run_shortQuery( - short_filterL, CharacterParameter, Character.valueOf((char) 1000), (short) 1000, true, 3); - run_shortQuery( - short_filterR, - CharacterParameter, - Character.valueOf((char) 10000), - (short) 10000, - false, - 9); - run_shortQuery(short_filterL, intParameter, Integer.valueOf(-10000), (short) -10000, true, 9); - run_shortQuery(short_filterR, intParameter, Integer.valueOf(-10000), (short) -10000, false, 2); - run_shortQuery(short_filterL, IntegerParameter, Integer.valueOf(10000), (short) 10000, true, 2); - run_shortQuery( - short_filterR, IntegerParameter, Integer.valueOf(30000), (short) 30000, false, 9); - run_shortQuery(short_filterL, longParameter, Long.valueOf(10000), (short) 10000, true, 2); - run_shortQuery( - short_filterR, longParameter, Long.valueOf(Short.MAX_VALUE), Short.MAX_VALUE, false, 10); - run_shortQuery( - short_filterL, LongParameter, Long.valueOf(Short.MAX_VALUE), Short.MAX_VALUE, true, 1); - run_shortQuery(short_filterR, LongParameter, Long.valueOf(100), (short) 100, false, 7); - run_shortQuery( - short_filterL, floatParameter, Float.valueOf((float) 23000), (short) 23000, true, 1); - run_shortQuery( - short_filterR, floatParameter, Float.valueOf((float) 23000), (short) 23000, false, 9); - run_shortQuery( - short_filterL, FloatParameter, Float.valueOf((float) -1000), (short) -1000, true, 8); - run_shortQuery( - short_filterR, FloatParameter, Float.valueOf((float) 100), (short) 100, false, 7); - run_shortQuery( - short_filterL, doubleParameter, Double.valueOf(-10000.0), (short) -10000, true, 9); - run_shortQuery(short_filterR, doubleParameter, Double.valueOf(9999.0), (short) 9999, false, 8); - run_shortQuery(short_filterL, DoubleParameter, Double.valueOf(23.0), (short) 23, true, 5); - run_shortQuery(short_filterR, DoubleParameter, Double.valueOf(23.0), (short) 23, false, 5); - run_shortQuery( - short_filterL, BigIntegerParameter, new BigInteger("10000"), (short) 10000, true, 2); - run_shortQuery( - short_filterR, BigIntegerParameter, new BigInteger("30000"), (short) 30000, false, 9); - run_shortQuery(short_filterL, BigDecimalParameter, new BigDecimal("23.0"), (short) 23, true, 5); - run_shortQuery( - short_filterR, BigDecimalParameter, new BigDecimal("23.0"), (short) 23, false, 5); - alltypes.setshort((short) 100); - run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short) 100, true, 5); - alltypes.setshort((short) 23); - run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short) 23, true, 5); - run_shortQuery(short_filterVal, null, null, (short) 1000, true, 3); - run_charQuery( - char_filterL, - charParameter, - Character.valueOf(Character.MIN_VALUE), - Character.MIN_VALUE, - true, - 10); - run_charQuery( - char_filterR, - charParameter, - Character.valueOf(Character.MAX_VALUE), - Character.MAX_VALUE, - false, - 10); - run_charQuery(char_filterL, charParameter, Character.valueOf('C'), 'C', true, 6); - run_charQuery(char_filterR, charParameter, Character.valueOf('z'), 'z', false, 9); - run_charQuery(char_filterL, CharacterParameter, Character.valueOf(' '), ' ', true, 9); - run_charQuery(char_filterR, CharacterParameter, Character.valueOf('f'), 'f', false, 7); - run_charQuery( - char_filterL, - byteParameter, - Byte.valueOf((byte) Character.MIN_VALUE), - (char) Character.MIN_VALUE, - true, - 10); - run_charQuery(char_filterR, ByteParameter, Byte.valueOf((byte) 'a'), 'a', false, 7); - run_charQuery(char_filterL, shortParameter, Short.valueOf((short) 'M'), 'M', true, 5); - run_charQuery(char_filterR, shortParameter, Short.valueOf((short) 'M'), 'M', false, 7); - run_charQuery(char_filterL, ShortParameter, Short.valueOf((short) 'A'), 'A', true, 8); - run_charQuery(char_filterR, ShortParameter, Short.valueOf((short) 'A'), 'A', false, 3); - run_charQuery(char_filterL, intParameter, Integer.valueOf('z'), 'z', true, 3); - run_charQuery(char_filterR, intParameter, Integer.valueOf('z'), 'z', false, 9); - run_charQuery(char_filterL, IntegerParameter, Integer.valueOf('B'), 'B', true, 7); - run_charQuery(char_filterR, IntegerParameter, Integer.valueOf('B'), 'B', false, 4); - run_charQuery(char_filterL, longParameter, Long.valueOf('z'), 'z', true, 3); - run_charQuery(char_filterR, longParameter, Long.valueOf('z'), 'z', false, 9); - run_charQuery(char_filterL, LongParameter, Long.valueOf('B'), 'B', true, 7); - run_charQuery(char_filterR, LongParameter, Long.valueOf('B'), 'B', false, 4); - run_charQuery(char_filterL, floatParameter, Float.valueOf((float) 'f'), 'f', true, 3); - run_charQuery(char_filterR, floatParameter, Float.valueOf((float) ' '), ' ', false, 2); - run_charQuery(char_filterL, FloatParameter, Float.valueOf((float) 'z'), 'z', true, 3); - run_charQuery(char_filterR, FloatParameter, Float.valueOf((float) 'z'), 'z', false, 9); - run_charQuery(char_filterL, doubleParameter, Double.valueOf('B'), 'B', true, 7); - run_charQuery(char_filterR, doubleParameter, Double.valueOf('B'), 'B', false, 4); - run_charQuery(char_filterL, DoubleParameter, Double.valueOf('A'), 'A', true, 8); - run_charQuery(char_filterR, DoubleParameter, Double.valueOf('A'), 'A', false, 3); - run_charQuery( - char_filterL, BigIntegerParameter, new BigInteger("65"), 'A', true, 8); // 'A' == 65 - run_charQuery( - char_filterR, BigIntegerParameter, new BigInteger("122"), 'z', false, 9); // 'z' == 122 - run_charQuery(char_filterL, BigDecimalParameter, new BigDecimal("65.00000"), 'A', true, 8); - run_charQuery( - char_filterR, BigDecimalParameter, new BigDecimal("77.0000"), 'M', false, 7); // 'M' == 77 - alltypes.setchar('A'); - run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'A', true, 8); - alltypes.setchar('b'); - run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'b', true, 3); - run_charQuery(char_filterVal, null, null, 'M', true, 5); - - run_intQuery( - int_filterL, - intParameter, - Integer.valueOf(AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - true, - 10); - run_intQuery( - int_filterR, - intParameter, - Integer.valueOf(AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - false, - 10); - run_intQuery(int_filterR, intParameter, Integer.valueOf(23), 23, false, 4); - run_intQuery(int_filterL, IntegerParameter, Integer.valueOf(1000000), 1000000, true, 2); - run_intQuery(int_filterR, IntegerParameter, Integer.valueOf(1000), 1000, false, 7); - run_intQuery(int_filterL, byteParameter, Byte.valueOf((byte) 100), 100, true, 6); - run_intQuery(int_filterR, byteParameter, Byte.valueOf((byte) 0), 0, false, 4); - run_intQuery(int_filterL, ByteParameter, Byte.valueOf((byte) 100), 100, true, 6); - run_intQuery(int_filterR, ByteParameter, Byte.valueOf((byte) 0), 0, false, 4); - run_intQuery(int_filterL, shortParameter, Short.valueOf((short) 10000), 10000, true, 3); - run_intQuery(int_filterR, shortParameter, Short.valueOf((short) -1000), -1000, false, 3); - run_intQuery(int_filterL, ShortParameter, Short.valueOf((short) -1000), -1000, true, 8); - run_intQuery(int_filterR, ShortParameter, Short.valueOf((short) 10000), 10000, false, 8); - run_intQuery(int_filterL, charParameter, Character.valueOf((char) 100), 100, true, 6); - run_intQuery(int_filterR, charParameter, Character.valueOf((char) 0), 0, false, 4); - run_intQuery(int_filterL, CharacterParameter, Character.valueOf((char) 100), 100, true, 6); - run_intQuery(int_filterR, CharacterParameter, Character.valueOf((char) 10000), 10000, false, 8); - run_intQuery( - int_filterL, - longParameter, - Long.valueOf(AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - true, - 1); - run_intQuery( - int_filterR, - longParameter, - Long.valueOf(AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - false, - 1); - run_intQuery(int_filterL, LongParameter, Long.valueOf(10000), 10000, true, 3); - run_intQuery(int_filterR, LongParameter, Long.valueOf(43), 43, false, 4); - run_intQuery( - int_filterL, - floatParameter, - Float.valueOf((float) AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - true, - 1); - run_intQuery( - int_filterR, - floatParameter, - Float.valueOf((float) AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - false, - 1); - run_intQuery(int_filterL, FloatParameter, Float.valueOf((float) 10000), 10000, true, 3); - run_intQuery(int_filterR, FloatParameter, Float.valueOf((float) 43), 43, false, 4); - run_intQuery( - int_filterL, - doubleParameter, - Double.valueOf(AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - true, - 1); - run_intQuery( - int_filterR, - doubleParameter, - Double.valueOf(AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - false, - 1); - run_intQuery(int_filterL, DoubleParameter, Double.valueOf(10000), 10000, true, 3); - run_intQuery(int_filterR, DoubleParameter, Double.valueOf(43), 43, false, 4); - run_intQuery(int_filterL, BigIntegerParameter, new BigInteger("1000000"), 1000000, true, 2); - run_intQuery(int_filterR, BigIntegerParameter, new BigInteger("1000"), 1000, false, 7); - run_intQuery(int_filterL, BigDecimalParameter, new BigDecimal("10000.0"), 10000, true, 3); - run_intQuery(int_filterR, BigDecimalParameter, new BigDecimal("43.0"), 43, false, 4); - alltypes.setint(100); - run_intQuery(int_filterObj, AllTypesParameter, alltypes, 100, true, 6); - run_intQuery(int_filterVal, null, null, 1000, false, 7); - - run_longQuery( - long_filterL, longParameter, Long.valueOf(Long.MIN_VALUE), Long.MIN_VALUE, true, 10); - run_longQuery( - long_filterR, longParameter, Long.valueOf(Long.MAX_VALUE), Long.MAX_VALUE, false, 10); - run_longQuery(long_filterL, LongParameter, Long.valueOf(100), 100, true, 5); - run_longQuery(long_filterR, LongParameter, Long.valueOf(23), 23, false, 5); - run_longQuery(long_filterL, byteParameter, Byte.valueOf((byte) 100), 100, true, 5); - run_longQuery(long_filterR, byteParameter, Byte.valueOf((byte) 0), 0, false, 5); - run_longQuery(long_filterL, ByteParameter, Byte.valueOf((byte) 100), 100, true, 5); - run_longQuery(long_filterR, ByteParameter, Byte.valueOf((byte) 0), 0, false, 5); - run_longQuery(long_filterL, shortParameter, Short.valueOf((short) -1000), -1000, true, 8); - run_longQuery(long_filterR, shortParameter, Short.valueOf((short) 1000), 1000, false, 8); - run_longQuery(long_filterL, ShortParameter, Short.valueOf((short) 100), 100, true, 5); - run_longQuery(long_filterR, ShortParameter, Short.valueOf((short) 32), 32, false, 5); - run_longQuery(long_filterL, charParameter, Character.valueOf((char) 0), 0, true, 6); - run_longQuery(long_filterR, charParameter, Character.valueOf((char) 100), 100, false, 7); - run_longQuery(long_filterL, CharacterParameter, Character.valueOf((char) 23), 23, true, 5); - run_longQuery(long_filterR, CharacterParameter, Character.valueOf((char) 0), 0, false, 5); - run_longQuery(long_filterL, intParameter, Integer.valueOf(100), 100, true, 5); - run_longQuery(long_filterR, intParameter, Integer.valueOf(0), 0, false, 5); - run_longQuery(long_filterL, IntegerParameter, Integer.valueOf(23), 23, true, 5); - run_longQuery(long_filterR, IntegerParameter, Integer.valueOf(1000000), 1000000, false, 9); - run_longQuery( - long_filterL, floatParameter, Float.valueOf((float) -1000000.0), -1000000, true, 9); - run_longQuery( - long_filterR, - floatParameter, - Float.valueOf((float) Long.MAX_VALUE), - Long.MAX_VALUE, - false, - 10); - run_longQuery(long_filterL, FloatParameter, Float.valueOf((float) 100.0), 100, true, 5); - run_longQuery(long_filterR, FloatParameter, Float.valueOf((float) 32.0), 32, false, 5); - run_longQuery(long_filterL, doubleParameter, Double.valueOf(-1000000.0), -1000000, true, 9); - run_longQuery( - long_filterR, - doubleParameter, - Double.valueOf((double) Long.MAX_VALUE), - Long.MAX_VALUE, - false, - 10); - run_longQuery(long_filterL, DoubleParameter, Double.valueOf(100.0), 100, true, 5); - run_longQuery(long_filterR, DoubleParameter, Double.valueOf(32.0), 32, false, 5); - run_longQuery(long_filterL, BigIntegerParameter, new BigInteger("23"), 23, true, 5); - run_longQuery(long_filterR, BigIntegerParameter, new BigInteger("1000000"), 1000000, false, 9); - run_longQuery(long_filterL, BigDecimalParameter, new BigDecimal("100.0"), 100, true, 5); - run_longQuery(long_filterR, BigDecimalParameter, new BigDecimal("32.0"), 32, false, 5); - alltypes.setlong(100); - run_longQuery(long_filterObj, AllTypesParameter, alltypes, 100, false, 7); - run_longQuery(long_filterVal, null, null, 1000000, false, 9); - - run_floatQuery( - float_filterL, - floatParameter, - Float.valueOf((float) AllTypes.FLOAT_SMALLEST), - AllTypes.FLOAT_SMALLEST, - true, - 10); - run_floatQuery( - float_filterR, - floatParameter, - Float.valueOf((float) AllTypes.FLOAT_LARGEST), - AllTypes.FLOAT_LARGEST, - false, - 10); - run_floatQuery(float_filterL, FloatParameter, Float.valueOf(4.0f), 4.0f, true, 6); - run_floatQuery(float_filterR, FloatParameter, Float.valueOf(400.0f), 400.0f, false, 7); - run_floatQuery(float_filterL, byteParameter, Byte.valueOf((byte) 4), 4.0f, true, 6); - run_floatQuery(float_filterR, byteParameter, Byte.valueOf((byte) 23), 23.0f, false, 4); - run_floatQuery(float_filterL, ByteParameter, Byte.valueOf((byte) 34), 34.0f, true, 6); - run_floatQuery(float_filterR, ByteParameter, Byte.valueOf((byte) 100), 100.0f, false, 6); - run_floatQuery(float_filterL, shortParameter, Short.valueOf((short) 10), 10.0f, true, 6); - run_floatQuery(float_filterR, shortParameter, Short.valueOf((short) 23), 23.0f, false, 4); - run_floatQuery(float_filterL, ShortParameter, Short.valueOf((short) 34), 34.0f, true, 6); - run_floatQuery(float_filterR, ShortParameter, Short.valueOf((short) 100), 100.0f, false, 6); - run_floatQuery(float_filterL, charParameter, Character.valueOf((char) 20), 20.0f, true, 6); - run_floatQuery(float_filterR, charParameter, Character.valueOf((char) 23), 23.0f, false, 4); - run_floatQuery(float_filterL, CharacterParameter, Character.valueOf((char) 34), 34.0f, true, 6); - run_floatQuery( - float_filterR, CharacterParameter, Character.valueOf((char) 100), 100.0f, false, 6); - run_floatQuery(float_filterL, intParameter, Integer.valueOf(55000000), 55000000.0f, true, 2); - run_floatQuery(float_filterR, intParameter, Integer.valueOf(23), 23.0f, false, 4); - run_floatQuery(float_filterL, IntegerParameter, Integer.valueOf(34), 34.0f, true, 6); - run_floatQuery(float_filterR, IntegerParameter, Integer.valueOf(100), 100.0f, false, 6); - run_floatQuery(float_filterL, longParameter, Long.valueOf(55000000), 55000000.0f, true, 2); - run_floatQuery(float_filterR, longParameter, Long.valueOf(23), 23.0f, false, 4); - run_floatQuery(float_filterL, LongParameter, Long.valueOf(34), 34.0f, true, 6); - run_floatQuery(float_filterR, LongParameter, Long.valueOf(100), 100.0f, false, 6); - run_floatQuery( - float_filterL, doubleParameter, Double.valueOf(55000000.0), 55000000.0f, true, 2); - run_floatQuery(float_filterR, doubleParameter, Double.valueOf(-20.5), -20.5f, false, 3); - run_floatQuery(float_filterL, DoubleParameter, Double.valueOf(2.0), 2.0f, true, 6); - run_floatQuery(float_filterR, DoubleParameter, Double.valueOf(100.0), 100.0f, false, 6); - run_floatQuery( - float_filterL, BigIntegerParameter, new BigInteger("55000000"), 55000000.0f, true, 2); - run_floatQuery(float_filterR, BigIntegerParameter, new BigInteger("23"), 23.0f, false, 4); - run_floatQuery( - float_filterL, BigDecimalParameter, new BigDecimal("55000000.0"), 55000000.0f, true, 2); - run_floatQuery(float_filterR, BigDecimalParameter, new BigDecimal("-20.5"), -20.5f, false, 3); - alltypes.setfloat(23.23f); - run_floatQuery(float_filterObj, AllTypesParameter, alltypes, 23.23f, false, 4); - run_floatQuery(float_filterVal, null, null, 100.0f, false, 6); - - run_doubleQuery( - double_filterL, - doubleParameter, - Double.valueOf(AllTypes.DOUBLE_SMALLEST), - AllTypes.DOUBLE_SMALLEST, - true, - 10); - run_doubleQuery( - double_filterR, - doubleParameter, - Double.valueOf(AllTypes.DOUBLE_LARGEST), - AllTypes.DOUBLE_LARGEST, - false, - 10); - run_doubleQuery(double_filterL, DoubleParameter, Double.valueOf(0.0), 0.0, true, 7); - run_doubleQuery(double_filterR, DoubleParameter, Double.valueOf(23.34), 23.34, false, 4); - run_doubleQuery(double_filterL, byteParameter, Byte.valueOf((byte) 100), 100.0, true, 6); - run_doubleQuery(double_filterR, byteParameter, Byte.valueOf((byte) 0), 0.0, false, 4); - run_doubleQuery(double_filterL, ByteParameter, Byte.valueOf((byte) 23), 23.0, true, 6); - run_doubleQuery(double_filterR, ByteParameter, Byte.valueOf((byte) 100), 100.0, false, 6); - run_doubleQuery(double_filterL, charParameter, Character.valueOf((char) 100), 100.0, true, 6); - run_doubleQuery(double_filterR, charParameter, Character.valueOf((char) 0), 0.0, false, 4); - run_doubleQuery( - double_filterL, CharacterParameter, Character.valueOf((char) 23), 23.0, true, 6); - run_doubleQuery( - double_filterR, CharacterParameter, Character.valueOf((char) 100), 100.0, false, 6); - run_doubleQuery(double_filterL, shortParameter, Short.valueOf((short) 100), 100.0, true, 6); - run_doubleQuery(double_filterR, shortParameter, Short.valueOf((short) 0), 0.0, false, 4); - run_doubleQuery(double_filterL, ShortParameter, Short.valueOf((short) 23), 23.0, true, 6); - run_doubleQuery(double_filterR, ShortParameter, Short.valueOf((short) 100), 100.0, false, 6); - run_doubleQuery(double_filterL, intParameter, Integer.valueOf(100), 100.0, true, 6); - run_doubleQuery(double_filterR, intParameter, Integer.valueOf(0), 0.0, false, 4); - run_doubleQuery(double_filterL, IntegerParameter, Integer.valueOf(5000), 5000.0, true, 3); - run_doubleQuery(double_filterR, IntegerParameter, Integer.valueOf(-20), -20.0, false, 3); - run_doubleQuery(double_filterL, longParameter, Long.valueOf(100), 100.0, true, 6); - run_doubleQuery(double_filterR, longParameter, Long.valueOf(0), 0.0, false, 4); - run_doubleQuery(double_filterL, LongParameter, Long.valueOf(5000), 5000.0, true, 3); - run_doubleQuery(double_filterR, LongParameter, Long.valueOf(-20), -20.0, false, 3); - run_doubleQuery(double_filterL, floatParameter, Float.valueOf(0.0f), 0.0f, true, 7); - run_doubleQuery(double_filterR, floatParameter, Float.valueOf(100.0f), 100.0f, false, 6); - run_doubleQuery(double_filterL, FloatParameter, Float.valueOf(100.0f), 100.0, true, 6); - run_doubleQuery(double_filterR, FloatParameter, Float.valueOf(69.96f), 69.96, false, 4); - run_doubleQuery(double_filterL, BigIntegerParameter, new BigInteger("5000"), 5000.0, true, 3); - run_doubleQuery(double_filterR, BigIntegerParameter, new BigInteger("-20"), -20.0, false, 3); - run_doubleQuery(double_filterL, BigDecimalParameter, new BigDecimal("100.0"), 100.0, true, 6); - run_doubleQuery(double_filterR, BigDecimalParameter, new BigDecimal("69.96"), 69.96, false, 4); - alltypes.setdouble(-25.5); - run_doubleQuery(double_filterObj, AllTypesParameter, alltypes, -25.5, true, 8); - run_doubleQuery(double_filterVal, null, null, 100.0, false, 6); - - run_ByteQuery( - Byte_filterL, byteParameter, Byte.valueOf((byte) 50), Byte.valueOf((byte) 50), true, 5); - run_ByteQuery( - Byte_filterR, - byteParameter, - Byte.valueOf(Byte.MIN_VALUE), - Byte.valueOf(Byte.MIN_VALUE), - false, - 1); - run_ByteQuery( - Byte_filterL, ByteParameter, Byte.valueOf((byte) 20), Byte.valueOf((byte) 20), true, 5); - run_ByteQuery( - Byte_filterR, - ByteParameter, - Byte.valueOf(Byte.MAX_VALUE), - Byte.valueOf(Byte.MAX_VALUE), - false, - 10); - run_ByteQuery( - Byte_filterL, shortParameter, Short.valueOf((short) 60), Byte.valueOf((byte) 60), true, 3); - run_ByteQuery( - Byte_filterR, shortParameter, Short.valueOf((short) 51), Byte.valueOf((byte) 51), false, 7); - run_ByteQuery( - Byte_filterL, - ShortParameter, - Short.valueOf((short) -100), - Byte.valueOf((byte) -100), - true, - 9); - run_ByteQuery( - Byte_filterR, - ShortParameter, - Short.valueOf((short) -100), - Byte.valueOf((byte) -100), - false, - 2); - run_ByteQuery( - Byte_filterL, - charParameter, - Character.valueOf((char) 101), - Byte.valueOf((byte) 101), - true, - 1); - run_ByteQuery( - Byte_filterR, - charParameter, - Character.valueOf((char) 10), - Byte.valueOf((byte) 10), - false, - 5); - run_ByteQuery( - Byte_filterL, - CharacterParameter, - Character.valueOf((char) 50), - Byte.valueOf((byte) 50), - true, - 5); - run_ByteQuery( - Byte_filterR, - CharacterParameter, - Character.valueOf((char) 75), - Byte.valueOf((byte) 75), - false, - 8); - run_ByteQuery( - Byte_filterL, intParameter, Integer.valueOf(77), Byte.valueOf((byte) 77), true, 2); - run_ByteQuery( - Byte_filterR, intParameter, Integer.valueOf(60), Byte.valueOf((byte) 60), false, 7); - run_ByteQuery( - Byte_filterL, IntegerParameter, Integer.valueOf(40), Byte.valueOf((byte) 40), true, 5); - run_ByteQuery( - Byte_filterR, IntegerParameter, Integer.valueOf(75), Byte.valueOf((byte) 75), false, 8); - run_ByteQuery(Byte_filterL, longParameter, Long.valueOf(50), Byte.valueOf((byte) 50), true, 5); - run_ByteQuery(Byte_filterR, longParameter, Long.valueOf(50), Byte.valueOf((byte) 50), false, 7); - run_ByteQuery( - Byte_filterL, LongParameter, Long.valueOf(-100), Byte.valueOf((byte) -100), true, 9); - run_ByteQuery( - Byte_filterR, LongParameter, Long.valueOf(-100), Byte.valueOf((byte) -100), false, 2); - run_ByteQuery( - Byte_filterL, floatParameter, Float.valueOf((float) 50), Byte.valueOf((byte) 50), true, 5); - run_ByteQuery( - Byte_filterR, floatParameter, Float.valueOf((float) 50), Byte.valueOf((byte) 50), false, 7); - run_ByteQuery( - Byte_filterL, - FloatParameter, - Float.valueOf((float) -100), - Byte.valueOf((byte) -100), - true, - 9); - run_ByteQuery( - Byte_filterR, - FloatParameter, - Float.valueOf((float) -100), - Byte.valueOf((byte) -100), - false, - 2); - run_ByteQuery( - Byte_filterL, doubleParameter, Double.valueOf(50), Byte.valueOf((byte) 50), true, 5); - run_ByteQuery( - Byte_filterR, doubleParameter, Double.valueOf(50), Byte.valueOf((byte) 50), false, 7); - run_ByteQuery( - Byte_filterL, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte) -100), true, 9); - run_ByteQuery( - Byte_filterR, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte) -100), false, 2); - run_ByteQuery( - Byte_filterL, BigIntegerParameter, new BigInteger("50"), Byte.valueOf((byte) 50), true, 5); - run_ByteQuery( - Byte_filterR, - BigIntegerParameter, - new BigInteger("-100"), - Byte.valueOf((byte) -100), - false, - 2); - run_ByteQuery( - Byte_filterL, - BigDecimalParameter, - new BigDecimal("50.000000"), - Byte.valueOf((byte) 50), - true, - 5); - run_ByteQuery( - Byte_filterR, - BigDecimalParameter, - new BigDecimal("10.00000"), - Byte.valueOf((byte) 10), - false, - 5); - Byte val = Byte.valueOf((byte) 50); - alltypes.setByte(val); - run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, false, 7); - val = Byte.valueOf((byte) 51); - alltypes.setByte(val); - run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, false, 7); - run_ByteQuery(Byte_filterVal, null, null, Byte.valueOf((byte) 100), true, 2); +/** + *Title: Less Than or Equal Query Operator + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-19. + *
    + *Assertion Description: +The less than or equal operator (<=) is supported for all types +as they are defined in the Java language. This includes the following types: +
      +
    • byte, short, int, long, char, Byte, Short Integer, Long, Character
    • +
    • float, double, Float, Double
    • +
    • BigDecimal, BigInteger
    • +
    • Date, String
    • +
    +The operation on object-valued fields of wrapper types (Boolean, Byte, +Short, Integer, Long, Float, and Double), and numeric types +(BigDecimal and BigInteger) +use the wrapped values as operands. - run_ShortQuery( - Short_filterL, - shortParameter, - Short.valueOf((short) 100), - Short.valueOf((short) 100), - true, - 5); - run_ShortQuery( - Short_filterR, - shortParameter, - Short.valueOf((short) 100), - Short.valueOf((short) 100), - false, - 7); - run_ShortQuery( - Short_filterL, - ShortParameter, - Short.valueOf(Short.MIN_VALUE), - Short.valueOf(Short.MIN_VALUE), - true, - 10); - run_ShortQuery( - Short_filterR, - ShortParameter, - Short.valueOf((short) 253), - Short.valueOf((short) 253), - false, - 7); - run_ShortQuery( - Short_filterR, - shortParameter, - Short.valueOf((short) 1000), - Short.valueOf((short) 1000), - false, - 8); - run_ShortQuery( - Short_filterL, byteParameter, Byte.valueOf((byte) 75), Short.valueOf((short) 75), true, 5); - run_ShortQuery( - Short_filterR, byteParameter, Byte.valueOf((byte) 75), Short.valueOf((short) 75), false, 5); - run_ShortQuery( - Short_filterL, - ByteParameter, - Byte.valueOf((byte) 100), - Short.valueOf((short) 100), - true, - 5); - run_ShortQuery( - Short_filterR, - ByteParameter, - Byte.valueOf((byte) 100), - Short.valueOf((short) 100), - false, - 7); - run_ShortQuery( - Short_filterL, - charParameter, - Character.valueOf((char) 75), - Short.valueOf((short) 75), - true, - 5); - run_ShortQuery( - Short_filterR, - charParameter, - Character.valueOf((char) 75), - Short.valueOf((short) 75), - false, - 5); - run_ShortQuery( - Short_filterL, - CharacterParameter, - Character.valueOf((char) 100), - Short.valueOf((short) 100), - true, - 5); - run_ShortQuery( - Short_filterR, - CharacterParameter, - Character.valueOf((char) 200), - Short.valueOf((short) 200), - false, - 7); - run_ShortQuery( - Short_filterL, - intParameter, - Integer.valueOf(-10000), - Short.valueOf((short) -10000), - true, - 9); - run_ShortQuery( - Short_filterR, - intParameter, - Integer.valueOf(-10000), - Short.valueOf((short) -10000), - false, - 2); - run_ShortQuery( - Short_filterL, - IntegerParameter, - Integer.valueOf(10000), - Short.valueOf((short) 10000), - true, - 2); - run_ShortQuery( - Short_filterR, - IntegerParameter, - Integer.valueOf(10000), - Short.valueOf((short) 10000), - false, - 9); - run_ShortQuery( - Short_filterL, longParameter, Long.valueOf(20000), Short.valueOf((short) 20000), true, 1); - run_ShortQuery( - Short_filterR, longParameter, Long.valueOf(5000), Short.valueOf((short) 5000), false, 8); - run_ShortQuery( - Short_filterL, LongParameter, Long.valueOf(200), Short.valueOf((short) 200), true, 3); - run_ShortQuery( - Short_filterR, LongParameter, Long.valueOf(500), Short.valueOf((short) 500), false, 7); - run_ShortQuery( - Short_filterL, - floatParameter, - Float.valueOf(23000.0f), - Short.valueOf((short) 23000), - true, - 1); - run_ShortQuery( - Short_filterR, - floatParameter, - Float.valueOf(23000.0f), - Short.valueOf((short) 23000), - false, - 9); - run_ShortQuery( - Short_filterL, FloatParameter, Float.valueOf(10.0f), Short.valueOf((short) 10), true, 5); - run_ShortQuery( - Short_filterR, FloatParameter, Float.valueOf(101.0f), Short.valueOf((short) 101), false, 7); - run_ShortQuery( - Short_filterL, - doubleParameter, - Double.valueOf(-10000.0), - Short.valueOf((short) -10000), - true, - 9); - run_ShortQuery( - Short_filterR, - doubleParameter, - Double.valueOf(-10000.0), - Short.valueOf((short) -10000), - false, - 2); - run_ShortQuery( - Short_filterL, DoubleParameter, Double.valueOf(101.0), Short.valueOf((short) 101), true, 3); - run_ShortQuery( - Short_filterR, DoubleParameter, Double.valueOf(23.0), Short.valueOf((short) 23), false, 5); - run_ShortQuery( - Short_filterL, - BigIntegerParameter, - new BigInteger("10000"), - Short.valueOf((short) 10000), - true, - 2); - run_ShortQuery( - Short_filterR, - BigIntegerParameter, - new BigInteger("30000"), - Short.valueOf((short) 30000), - false, - 9); - run_ShortQuery( - Short_filterL, - BigDecimalParameter, - new BigDecimal("23.0"), - Short.valueOf((short) 23), - true, - 5); - run_ShortQuery( - Short_filterR, - BigDecimalParameter, - new BigDecimal("23.0"), - Short.valueOf((short) 23), - false, - 5); - Short sval = Short.valueOf((short) 100); - alltypes.setShort(sval); - run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, false, 7); - sval = Short.valueOf((short) 23); - alltypes.setShort(sval); - run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, false, 5); - run_ShortQuery(Short_filterVal, null, null, Short.valueOf((short) -1000), true, 8); + */ - run_CharacterQuery( - Character_filterL, - charParameter, - Character.valueOf(Character.MIN_VALUE), - Character.valueOf(Character.MIN_VALUE), - true, - 10); - run_CharacterQuery( - Character_filterR, - charParameter, - Character.valueOf(Character.MAX_VALUE), - Character.valueOf(Character.MAX_VALUE), - false, - 10); - run_CharacterQuery( - Character_filterL, charParameter, Character.valueOf('C'), Character.valueOf('C'), true, 6); - run_CharacterQuery( - Character_filterR, charParameter, Character.valueOf('z'), Character.valueOf('z'), false, 9); - run_CharacterQuery( - Character_filterL, - CharacterParameter, - Character.valueOf(' '), - Character.valueOf(' '), - true, - 9); - run_CharacterQuery( - Character_filterR, - CharacterParameter, - Character.valueOf('f'), - Character.valueOf('f'), - false, - 7); - run_CharacterQuery( - Character_filterL, - byteParameter, - Byte.valueOf((byte) Character.MIN_VALUE), - Character.valueOf((char) Character.MIN_VALUE), - true, - 10); - run_CharacterQuery( - Character_filterR, - ByteParameter, - Byte.valueOf((byte) 'a'), - Character.valueOf('a'), - false, - 7); - run_CharacterQuery( - Character_filterL, - shortParameter, - Short.valueOf((short) 'M'), - Character.valueOf('M'), - true, - 5); - run_CharacterQuery( - Character_filterR, - shortParameter, - Short.valueOf((short) 'F'), - Character.valueOf('F'), - false, - 5); - run_CharacterQuery( - Character_filterL, - ShortParameter, - Short.valueOf((short) 'A'), - Character.valueOf('A'), - true, - 8); - run_CharacterQuery( - Character_filterR, - ShortParameter, - Short.valueOf((short) 'A'), - Character.valueOf('A'), - false, - 3); - run_CharacterQuery( - Character_filterL, intParameter, Integer.valueOf('z'), Character.valueOf('z'), true, 3); - run_CharacterQuery( - Character_filterR, intParameter, Integer.valueOf('z'), Character.valueOf('z'), false, 9); - run_CharacterQuery( - Character_filterL, IntegerParameter, Integer.valueOf('B'), Character.valueOf('B'), true, 7); - run_CharacterQuery( - Character_filterR, - IntegerParameter, - Integer.valueOf('B'), - Character.valueOf('B'), - false, - 4); - run_CharacterQuery( - Character_filterL, longParameter, Long.valueOf('z'), Character.valueOf('z'), true, 3); - run_CharacterQuery( - Character_filterR, longParameter, Long.valueOf('z'), Character.valueOf('z'), false, 9); - run_CharacterQuery( - Character_filterL, LongParameter, Long.valueOf('B'), Character.valueOf('B'), true, 7); - run_CharacterQuery( - Character_filterR, LongParameter, Long.valueOf('B'), Character.valueOf('B'), false, 4); - run_CharacterQuery( - Character_filterL, - floatParameter, - Float.valueOf((float) 'z'), - Character.valueOf('z'), - true, - 3); - run_CharacterQuery( - Character_filterR, - floatParameter, - Float.valueOf((float) 'z'), - Character.valueOf('z'), - false, - 9); - run_CharacterQuery( - Character_filterL, - FloatParameter, - Float.valueOf((float) 'M'), - Character.valueOf('M'), - true, - 5); - run_CharacterQuery( - Character_filterR, - FloatParameter, - Float.valueOf((float) 'X'), - Character.valueOf('X'), - false, - 7); - run_CharacterQuery( - Character_filterL, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), true, 7); - run_CharacterQuery( - Character_filterR, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), false, 4); - run_CharacterQuery( - Character_filterL, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), true, 8); - run_CharacterQuery( - Character_filterR, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), false, 3); - run_CharacterQuery( - Character_filterL, - BigIntegerParameter, - new BigInteger("65"), - Character.valueOf('A'), - true, - 8); // 'A' == 65 - run_CharacterQuery( - Character_filterR, - BigIntegerParameter, - new BigInteger("122"), - Character.valueOf('z'), - false, - 9); // 'z' == 122 - run_CharacterQuery( - Character_filterL, - BigDecimalParameter, - new BigDecimal("65.00000"), - Character.valueOf('A'), - true, - 8); - run_CharacterQuery( - Character_filterR, - BigDecimalParameter, - new BigDecimal("77.0000"), - Character.valueOf('M'), - false, - 7); // 'M' == 77 - alltypes.setCharacter(Character.valueOf('A')); - run_CharacterQuery( - Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('A'), true, 8); - alltypes.setCharacter(Character.valueOf('b')); - run_CharacterQuery( - Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('b'), true, 3); - run_CharacterQuery(Character_filterVal, null, null, Character.valueOf('z'), false, 9); +public class LessThanOrEqual extends ComparisonTests { + private static String boolean_filterL = "value <= fld_boolean"; + private static String boolean_filterR = "fld_boolean <= value"; + private static String boolean_filterT = "fld_boolean <= true"; + private static String boolean_filterF = "false <= fld_boolean"; + private static String boolean_filterObj = "value.fld_boolean <= fld_boolean"; + + private static String byte_filterL = "value <= fld_byte"; + private static String byte_filterR = "fld_byte <= value"; + private static String byte_filterObj = "value.fld_byte <= fld_byte"; + private static String byte_filterVal = "fld_byte <= 100"; + + private static String char_filterL = "value <= fld_char"; + private static String char_filterR = "fld_char <= value"; + private static String char_filterObj = "value.fld_char <= fld_char"; + private static String char_filterVal = "'M' <= fld_char"; + + private static String double_filterL = "value <= fld_double"; + private static String double_filterR = "fld_double <= value"; + private static String double_filterObj = "value.fld_double <= fld_double"; + private static String double_filterVal = "fld_double <= 100.0"; + + private static String float_filterL = "value <= fld_float"; + private static String float_filterR = "fld_float <= value"; + private static String float_filterObj = "fld_float <= value.fld_float"; + private static String float_filterVal = "fld_float <= 100.0"; + + private static String int_filterL = "value <= fld_int"; + private static String int_filterR = "fld_int <= value"; + private static String int_filterObj = "value.fld_int <= fld_int"; + private static String int_filterVal = "fld_int <= 1000"; + + private static String long_filterL = "value <= fld_long"; + private static String long_filterR = "fld_long <= value"; + private static String long_filterObj = "fld_long <= value.fld_long"; + private static String long_filterVal = "fld_long <= 1000000"; + + private static String short_filterL = "value <= fld_short"; + private static String short_filterR = "fld_short <= value"; + private static String short_filterObj = "value.fld_short <= fld_short"; + private static String short_filterVal = "1000 <= fld_short"; + + private static String Boolean_filterL = "value <= fld_Boolean"; + private static String Boolean_filterR = "fld_Boolean <= value"; + private static String Boolean_filterT = "fld_Boolean <= true"; + private static String Boolean_filterF = "false <= fld_Boolean"; + private static String Boolean_filterObj = "value.fld_Boolean <= fld_Boolean"; + private static String Boolean_filterVal = "fld_Boolean <= false"; + + private static String Byte_filterL = "value <= fld_Byte"; + private static String Byte_filterR = "fld_Byte <= value"; + private static String Byte_filterObj = "fld_Byte <= value.fld_Byte"; + private static String Byte_filterVal = "100 <= fld_Byte"; + + private static String Character_filterL = "value <= fld_Character"; + private static String Character_filterR = "fld_Character <= value"; + private static String Character_filterObj = "value.fld_Character <= fld_Character"; + private static String Character_filterVal = "fld_Character <= 'z'"; + + private static String Double_filterL = "value <= fld_Double"; + private static String Double_filterR = "fld_Double <= value"; + private static String Double_filterObj = "value.fld_Double <= fld_Double"; + private static String Double_filterVal = "fld_Double <= 100.0"; + + private static String Float_filterL = "value <= fld_Float"; + private static String Float_filterR = "fld_Float <= value"; + private static String Float_filterObj = "fld_Float <= value.fld_Float"; + private static String Float_filterVal = "100.0f <= fld_Float"; + + private static String Integer_filterL = "value <= fld_Integer"; + private static String Integer_filterR = "fld_Integer <= value"; + private static String Integer_filterObj = "fld_Integer <= value.fld_Integer"; + private static String Integer_filterVal = "fld_Integer <= 100"; + + private static String Long_filterL = "value <= fld_Long"; + private static String Long_filterR = "fld_Long <= value"; + private static String Long_filterObj = "value.fld_Long <= fld_Long"; + private static String Long_filterVal = "-1000 <= fld_Long"; + + private static String Short_filterL = "value <= fld_Short"; + private static String Short_filterR = "fld_Short <= value"; + private static String Short_filterObj = "fld_Short <= value.fld_Short"; + private static String Short_filterVal = "-1000 <= fld_Short"; + + private static String String_filterL = "value <= fld_String"; + private static String String_filterR = "fld_String <= value"; + private static String String_filterObj = "value.fld_String <= fld_String"; + private static String String_filterVal1 = "fld_String <= \"Java\""; + private static String String_filterVal2 = "fld_String <= \"\""; + + private static String Date_filterL = "value <= fld_Date"; + private static String Date_filterR = "fld_Date <= value"; + private static String Date_filterObj = "fld_Date <= value.fld_Date"; + + private static String BigDecimal_filterL = "value <= fld_BigDecimal"; + private static String BigDecimal_filterR = "fld_BigDecimal <= value"; + private static String BigDecimal_filterObj = "value.fld_BigDecimal <= fld_BigDecimal"; + + private static String BigInteger_filterL = "value <= fld_BigInteger"; + private static String BigInteger_filterR = "fld_BigInteger <= value"; + private static String BigInteger_filterObj = "fld_BigInteger <= value.fld_BigInteger"; - run_IntegerQuery( - Integer_filterL, - intParameter, - Integer.valueOf(AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - true, - 10); - run_IntegerQuery( - Integer_filterR, - intParameter, - Integer.valueOf(AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - false, - 10); - run_IntegerQuery( - Integer_filterR, intParameter, Integer.valueOf(23), Integer.valueOf(23), false, 4); - run_IntegerQuery( - Integer_filterL, - IntegerParameter, - Integer.valueOf(1000000), - Integer.valueOf(1000000), - true, - 2); - run_IntegerQuery( - Integer_filterR, IntegerParameter, Integer.valueOf(1000), Integer.valueOf(1000), false, 7); - run_IntegerQuery( - Integer_filterL, byteParameter, Byte.valueOf((byte) 100), Integer.valueOf(100), true, 6); - run_IntegerQuery( - Integer_filterR, byteParameter, Byte.valueOf((byte) 0), Integer.valueOf(0), false, 4); - run_IntegerQuery( - Integer_filterL, ByteParameter, Byte.valueOf((byte) 100), Integer.valueOf(100), true, 6); - run_IntegerQuery( - Integer_filterR, ByteParameter, Byte.valueOf((byte) 0), Integer.valueOf(0), false, 4); - run_IntegerQuery( - Integer_filterL, - shortParameter, - Short.valueOf((short) 10000), - Integer.valueOf(10000), - true, - 3); - run_IntegerQuery( - Integer_filterR, - shortParameter, - Short.valueOf((short) -1000), - Integer.valueOf(-1000), - false, - 3); - run_IntegerQuery( - Integer_filterL, - ShortParameter, - Short.valueOf((short) -1000), - Integer.valueOf(-1000), - true, - 8); - run_IntegerQuery( - Integer_filterR, - ShortParameter, - Short.valueOf((short) -999), - Integer.valueOf(-999), - false, - 3); - run_IntegerQuery( - Integer_filterL, - charParameter, - Character.valueOf((char) 10000), - Integer.valueOf(10000), - true, - 3); - run_IntegerQuery( - Integer_filterR, - charParameter, - Character.valueOf((char) 10000), - Integer.valueOf(10000), - false, - 8); - run_IntegerQuery( - Integer_filterL, - CharacterParameter, - Character.valueOf((char) 100), - Integer.valueOf(100), - true, - 6); - run_IntegerQuery( - Integer_filterR, - CharacterParameter, - Character.valueOf((char) 10000), - Integer.valueOf(10000), - false, - 8); - run_IntegerQuery( - Integer_filterL, - longParameter, - Long.valueOf(AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - true, - 1); - run_IntegerQuery( - Integer_filterR, - longParameter, - Long.valueOf(AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - false, - 1); - run_IntegerQuery( - Integer_filterL, LongParameter, Long.valueOf(10000), Integer.valueOf(10000), true, 3); - run_IntegerQuery( - Integer_filterR, LongParameter, Long.valueOf(43), Integer.valueOf(43), false, 4); - run_IntegerQuery( - Integer_filterL, - floatParameter, - Float.valueOf((float) AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - true, - 1); - run_IntegerQuery( - Integer_filterR, - floatParameter, - Float.valueOf((float) AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - false, - 1); - run_IntegerQuery( - Integer_filterL, - FloatParameter, - Float.valueOf((float) 10000), - Integer.valueOf(10000), - true, - 3); - run_IntegerQuery( - Integer_filterR, FloatParameter, Float.valueOf((float) 43), Integer.valueOf(43), false, 4); - run_IntegerQuery( - Integer_filterL, - doubleParameter, - Double.valueOf(AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - true, - 1); - run_IntegerQuery( - Integer_filterR, - doubleParameter, - Double.valueOf(AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - false, - 1); - run_IntegerQuery( - Integer_filterL, DoubleParameter, Double.valueOf(10000), Integer.valueOf(10000), true, 3); - run_IntegerQuery( - Integer_filterR, - DoubleParameter, - Double.valueOf(1000001.0), - Integer.valueOf(1000001), - false, - 9); - run_IntegerQuery( - Integer_filterL, - BigIntegerParameter, - new BigInteger("1000000"), - Integer.valueOf(1000000), - true, - 2); - run_IntegerQuery( - Integer_filterR, - BigIntegerParameter, - new BigInteger("1000"), - Integer.valueOf(1000), - false, - 7); - run_IntegerQuery( - Integer_filterL, - BigDecimalParameter, - new BigDecimal("10000.0"), - Integer.valueOf(10000), - true, - 3); - run_IntegerQuery( - Integer_filterR, - BigDecimalParameter, - new BigDecimal("43.0"), - Integer.valueOf(43), - false, - 4); - alltypes.setInteger(Integer.valueOf(100)); - run_IntegerQuery( - Integer_filterObj, AllTypesParameter, alltypes, Integer.valueOf(100), false, 6); - run_IntegerQuery(Integer_filterVal, null, null, Integer.valueOf(100), false, 6); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-19 (LessThanOrEqual) failed: "; - run_LongQuery( - Long_filterL, - longParameter, - Long.valueOf(Long.MIN_VALUE), - Long.valueOf(Long.MIN_VALUE), - true, - 10); - run_LongQuery( - Long_filterR, - longParameter, - Long.valueOf(Long.MAX_VALUE), - Long.valueOf(Long.MAX_VALUE), - false, - 10); - run_LongQuery(Long_filterL, LongParameter, Long.valueOf(100), Long.valueOf(100), true, 5); - run_LongQuery(Long_filterR, LongParameter, Long.valueOf(23), Long.valueOf(23), false, 5); - run_LongQuery( - Long_filterL, byteParameter, Byte.valueOf((byte) 100), Long.valueOf(100), true, 5); - run_LongQuery(Long_filterR, byteParameter, Byte.valueOf((byte) 0), Long.valueOf(0), false, 5); - run_LongQuery( - Long_filterL, ByteParameter, Byte.valueOf((byte) 100), Long.valueOf(100), true, 5); - run_LongQuery(Long_filterR, ByteParameter, Byte.valueOf((byte) 0), Long.valueOf(0), false, 5); - run_LongQuery( - Long_filterL, shortParameter, Short.valueOf((short) -1000), Long.valueOf(-1000), true, 8); - run_LongQuery( - Long_filterR, shortParameter, Short.valueOf((short) 1000), Long.valueOf(1000), false, 8); - run_LongQuery( - Long_filterL, ShortParameter, Short.valueOf((short) 101), Long.valueOf(101), true, 3); - run_LongQuery( - Long_filterR, ShortParameter, Short.valueOf((short) 32), Long.valueOf(32), false, 5); - run_LongQuery( - Long_filterL, charParameter, Character.valueOf((char) 0), Long.valueOf(0), true, 6); - run_LongQuery( - Long_filterR, charParameter, Character.valueOf((char) 100), Long.valueOf(100), false, 7); - run_LongQuery( - Long_filterL, CharacterParameter, Character.valueOf((char) 23), Long.valueOf(23), true, 5); - run_LongQuery( - Long_filterR, - CharacterParameter, - Character.valueOf((char) 1110), - Long.valueOf(1110), - false, - 8); - run_LongQuery(Long_filterL, intParameter, Integer.valueOf(100), Long.valueOf(100), true, 5); - run_LongQuery(Long_filterR, intParameter, Integer.valueOf(0), Long.valueOf(0), false, 5); - run_LongQuery(Long_filterL, IntegerParameter, Integer.valueOf(23), Long.valueOf(23), true, 5); - run_LongQuery( - Long_filterR, IntegerParameter, Integer.valueOf(1000000), Long.valueOf(1000000), false, 9); - run_LongQuery( - Long_filterL, - floatParameter, - Float.valueOf((float) -1000000.0), - Long.valueOf(-1000000), - true, - 9); - run_LongQuery( - Long_filterR, - floatParameter, - Float.valueOf((float) Long.MAX_VALUE), - Long.valueOf(Long.MAX_VALUE), - false, - 10); - run_LongQuery(Long_filterL, FloatParameter, Float.valueOf(100.0f), Long.valueOf(100), true, 5); - run_LongQuery(Long_filterR, FloatParameter, Float.valueOf(32.0f), Long.valueOf(32), false, 5); - run_LongQuery( - Long_filterL, doubleParameter, Double.valueOf(-1000000.0), Long.valueOf(-1000000), true, 9); - run_LongQuery( - Long_filterR, - doubleParameter, - Double.valueOf((double) Long.MAX_VALUE), - Long.valueOf(Long.MAX_VALUE), - false, - 10); - run_LongQuery(Long_filterL, DoubleParameter, Double.valueOf(100.0), Long.valueOf(100), true, 5); - run_LongQuery(Long_filterR, DoubleParameter, Double.valueOf(32.0), Long.valueOf(32), false, 5); - run_LongQuery( - Long_filterL, BigIntegerParameter, new BigInteger("23"), Long.valueOf(23), true, 5); - run_LongQuery( - Long_filterR, - BigIntegerParameter, - new BigInteger("1000000"), - Long.valueOf(1000000), - false, - 9); - run_LongQuery( - Long_filterL, BigDecimalParameter, new BigDecimal("100.0"), Long.valueOf(100), true, 5); - run_LongQuery( - Long_filterR, BigDecimalParameter, new BigDecimal("32.0"), Long.valueOf(32), false, 5); - alltypes.setLong(Long.valueOf(100)); - run_LongQuery(Long_filterObj, AllTypesParameter, alltypes, Long.valueOf(100), true, 5); - run_LongQuery(Long_filterVal, null, null, Long.valueOf(-1000), true, 8); + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(LessThanOrEqual.class); + } - run_FloatQuery( - Float_filterL, - floatParameter, - Float.valueOf(-1000000000.0f), - Float.valueOf(-1000000000.0f), - true, - 9); - run_FloatQuery( - Float_filterR, floatParameter, Float.valueOf(100.0f), Float.valueOf(100.0f), false, 5); - run_FloatQuery( - Float_filterL, FloatParameter, Float.valueOf((float) 0.0), Float.valueOf(0.0f), true, 8); - run_FloatQuery( - Float_filterR, FloatParameter, Float.valueOf((float) 4.0), Float.valueOf(4.0f), false, 3); - run_FloatQuery( - Float_filterL, byteParameter, Byte.valueOf((byte) 0), Float.valueOf(0.0f), true, 8); - run_FloatQuery( - Float_filterR, byteParameter, Byte.valueOf((byte) 23), Float.valueOf(23.0f), false, 3); - run_FloatQuery( - Float_filterL, ByteParameter, Byte.valueOf((byte) 34), Float.valueOf(34.0f), true, 7); - run_FloatQuery( - Float_filterR, ByteParameter, Byte.valueOf((byte) 100), Float.valueOf(100.0f), false, 5); - run_FloatQuery( - Float_filterL, shortParameter, Short.valueOf((short) 0), Float.valueOf(0.0f), true, 8); - run_FloatQuery( - Float_filterR, shortParameter, Short.valueOf((short) 23), Float.valueOf(23.0f), false, 3); - run_FloatQuery( - Float_filterL, ShortParameter, Short.valueOf((short) 34), Float.valueOf(34.0f), true, 7); - run_FloatQuery( - Float_filterR, ShortParameter, Short.valueOf((short) 100), Float.valueOf(100.0f), false, 5); - run_FloatQuery( - Float_filterL, charParameter, Character.valueOf((char) 0), Float.valueOf(0.0f), true, 8); - run_FloatQuery( - Float_filterR, charParameter, Character.valueOf((char) 23), Float.valueOf(23.0f), false, 3); - run_FloatQuery( - Float_filterL, - CharacterParameter, - Character.valueOf((char) 34), - Float.valueOf(34.0f), - true, - 7); - run_FloatQuery( - Float_filterR, - CharacterParameter, - Character.valueOf((char) 100), - Float.valueOf(100.0f), - false, - 5); - run_FloatQuery( - Float_filterL, - intParameter, - Integer.valueOf(50000000), - Float.valueOf(50000000.0f), - true, - 3); - run_FloatQuery( - Float_filterR, intParameter, Integer.valueOf(23), Float.valueOf(23.0f), false, 3); - run_FloatQuery( - Float_filterL, IntegerParameter, Integer.valueOf(34), Float.valueOf(34.0f), true, 7); - run_FloatQuery( - Float_filterR, IntegerParameter, Integer.valueOf(100), Float.valueOf(100.0f), false, 5); - run_FloatQuery( - Float_filterL, longParameter, Long.valueOf(50000000), Float.valueOf(50000000.0f), true, 3); - run_FloatQuery(Float_filterR, longParameter, Long.valueOf(23), Float.valueOf(23.0f), false, 3); - run_FloatQuery(Float_filterL, LongParameter, Long.valueOf(34), Float.valueOf(34.0f), true, 7); - run_FloatQuery( - Float_filterR, LongParameter, Long.valueOf(100), Float.valueOf(100.0f), false, 5); - run_FloatQuery( - Float_filterL, - doubleParameter, - Double.valueOf(50000000.0f), - Float.valueOf(50000000.0f), - true, - 3); - run_FloatQuery( - Float_filterR, doubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), false, 5); - run_FloatQuery( - Float_filterL, DoubleParameter, Double.valueOf(0.0f), Float.valueOf(0.0f), true, 8); - run_FloatQuery( - Float_filterR, DoubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), false, 5); - run_FloatQuery( - Float_filterL, - BigIntegerParameter, - new BigInteger("55000000"), - Float.valueOf(55000000.0f), - true, - 2); - run_FloatQuery( - Float_filterR, BigIntegerParameter, new BigInteger("23"), Float.valueOf(23.0f), false, 3); - run_FloatQuery( - Float_filterL, - BigDecimalParameter, - new BigDecimal("55000000.0"), - Float.valueOf(55000000.0f), - true, - 2); - run_FloatQuery( - Float_filterR, - BigDecimalParameter, - new BigDecimal("-20.5"), - Float.valueOf(-20.5f), - false, - 2); - alltypes.setFloat(Float.valueOf(23.23f)); - run_FloatQuery(Float_filterObj, AllTypesParameter, alltypes, Float.valueOf(23.23f), false, 3); - run_FloatQuery(Float_filterVal, null, null, Float.valueOf(100.0f), true, 7); + /** */ + public void test() { + pm = getPM(); + tx = pm.currentTransaction(); + runQueries(); + } - run_DoubleQuery( - Double_filterL, - doubleParameter, - Double.valueOf(-999999999999.0), - Double.valueOf(-999999999999.0), - true, - 9); - run_DoubleQuery( - Double_filterR, - doubleParameter, - Double.valueOf(9999999999999.0), - Double.valueOf(9999999999999.0), - false, - 9); - run_DoubleQuery( - Double_filterL, DoubleParameter, Double.valueOf(0.0), Double.valueOf(0.0), true, 7); - run_DoubleQuery( - Double_filterR, DoubleParameter, Double.valueOf(23.34), Double.valueOf(23.34), false, 4); - run_DoubleQuery( - Double_filterL, byteParameter, Byte.valueOf((byte) 100), Double.valueOf(100.0), true, 6); - run_DoubleQuery( - Double_filterR, byteParameter, Byte.valueOf((byte) 0), Double.valueOf(0.0), false, 4); - run_DoubleQuery( - Double_filterL, ByteParameter, Byte.valueOf((byte) -23), Double.valueOf(-23.0), true, 7); - run_DoubleQuery( - Double_filterR, ByteParameter, Byte.valueOf((byte) 100), Double.valueOf(100.0), false, 6); - run_DoubleQuery( - Double_filterL, shortParameter, Short.valueOf((short) 100), Double.valueOf(100.0), true, 6); - run_DoubleQuery( - Double_filterR, shortParameter, Short.valueOf((short) 0), Double.valueOf(0.0), false, 4); - run_DoubleQuery( - Double_filterL, ShortParameter, Short.valueOf((short) 23), Double.valueOf(23.0), true, 6); - run_DoubleQuery( - Double_filterR, - ShortParameter, - Short.valueOf((short) 400), - Double.valueOf(400.0), - false, - 7); - run_DoubleQuery( - Double_filterL, - charParameter, - Character.valueOf((char) 100), - Double.valueOf(100.0), - true, - 6); - run_DoubleQuery( - Double_filterR, charParameter, Character.valueOf((char) 0), Double.valueOf(0.0), false, 4); - run_DoubleQuery( - Double_filterL, - CharacterParameter, - Character.valueOf((char) 23), - Double.valueOf(23.0), - true, - 6); - run_DoubleQuery( - Double_filterR, - CharacterParameter, - Character.valueOf((char) 400), - Double.valueOf(400.0), - false, - 7); - run_DoubleQuery( - Double_filterL, intParameter, Integer.valueOf(100), Double.valueOf(100.0), true, 6); - run_DoubleQuery( - Double_filterR, intParameter, Integer.valueOf(0), Double.valueOf(0.0), false, 4); - run_DoubleQuery( - Double_filterL, IntegerParameter, Integer.valueOf(23), Double.valueOf(23.0), true, 6); - run_DoubleQuery( - Double_filterR, IntegerParameter, Integer.valueOf(100), Double.valueOf(100.0), false, 6); - run_DoubleQuery( - Double_filterL, longParameter, Long.valueOf(100), Double.valueOf(100.0), true, 6); - run_DoubleQuery(Double_filterR, longParameter, Long.valueOf(0), Double.valueOf(0.0), false, 4); - run_DoubleQuery(Double_filterL, LongParameter, Long.valueOf(23), Double.valueOf(23.0), true, 6); - run_DoubleQuery( - Double_filterR, LongParameter, Long.valueOf(100), Double.valueOf(100.0), false, 6); - run_DoubleQuery( - Double_filterL, floatParameter, Float.valueOf(0.0f), Double.valueOf(0.0f), true, 7); - run_DoubleQuery( - Double_filterR, floatParameter, Float.valueOf(100.0f), Double.valueOf(100.0f), false, 6); - run_DoubleQuery( - Double_filterL, FloatParameter, Float.valueOf(100.0f), Double.valueOf(100.0f), true, 6); - run_DoubleQuery( - Double_filterR, FloatParameter, Float.valueOf(69.96f), Double.valueOf(69.96), false, 4); - run_DoubleQuery( - Double_filterL, - BigIntegerParameter, - new BigInteger("5000"), - Double.valueOf(5000.0), - true, - 3); - run_DoubleQuery( - Double_filterR, - BigIntegerParameter, - new BigInteger("-20"), - Double.valueOf(-20.0), - false, - 3); - run_DoubleQuery( - Double_filterL, - BigDecimalParameter, - new BigDecimal("100.0"), - Double.valueOf(100.0), - true, - 6); - run_DoubleQuery( - Double_filterR, - BigDecimalParameter, - new BigDecimal("69.96"), - Double.valueOf(69.96), - false, - 4); - alltypes.setDouble(Double.valueOf(-999999999999.0)); - run_DoubleQuery( - Double_filterObj, AllTypesParameter, alltypes, Double.valueOf(-999999999999.0), true, 9); - run_DoubleQuery(Double_filterVal, null, null, Double.valueOf(100.0), false, 6); + /** */ + private void runQueries() + { + AllTypes alltypes = new AllTypes(); + run_byteQuery(byte_filterL, byteParameter, Byte.valueOf((byte)0), (byte)0, true, 7); + run_byteQuery(byte_filterR, byteParameter, Byte.valueOf(Byte.MIN_VALUE), Byte.MIN_VALUE, false, 1); + run_byteQuery(byte_filterL, ByteParameter, Byte.valueOf((byte)50), (byte)50, true, 5); + run_byteQuery(byte_filterR, ByteParameter, Byte.valueOf(Byte.MAX_VALUE), Byte.MAX_VALUE, false, 10); + run_byteQuery(byte_filterL, shortParameter, Short.valueOf((short)75), (byte)75, true, 3); + run_byteQuery(byte_filterR, shortParameter, Short.valueOf((short)75), (byte)75, false, 8); + run_byteQuery(byte_filterL, ShortParameter, Short.valueOf((short)10), (byte)10, true, 6); + run_byteQuery(byte_filterR, ShortParameter, Short.valueOf((short)25), (byte)25, false, 5); + run_byteQuery(byte_filterL, charParameter, Character.valueOf((char)101), (byte)101, true, 1); + run_byteQuery(byte_filterR, charParameter, Character.valueOf((char)50), (byte)50, false, 7); + run_byteQuery(byte_filterL, CharacterParameter, Character.valueOf((char)0), (byte)0, true, 7); + run_byteQuery(byte_filterR, CharacterParameter, Character.valueOf((char)0), (byte)0, false, 4); + run_byteQuery(byte_filterL, intParameter, Integer.valueOf(25), (byte)25, true, 5); + run_byteQuery(byte_filterR, intParameter, Integer.valueOf(50), (byte)50, false, 7); + run_byteQuery(byte_filterL, IntegerParameter, Integer.valueOf(-10), (byte)-10, true, 8); + run_byteQuery(byte_filterR, IntegerParameter, Integer.valueOf(-100), (byte)-100, false, 2); + run_byteQuery(byte_filterL, longParameter, Long.valueOf(50), (byte)50, true, 5); + run_byteQuery(byte_filterR, longParameter, Long.valueOf(60), (byte)60, false, 7); + run_byteQuery(byte_filterL, LongParameter, Long.valueOf(-100), (byte)-100, true, 9); + run_byteQuery(byte_filterR, LongParameter, Long.valueOf(-100), (byte)-100, false, 2); + run_byteQuery(byte_filterL, floatParameter, Float.valueOf((float)51), (byte)51, true, 3); + run_byteQuery(byte_filterR, floatParameter, Float.valueOf((float)-20), (byte)-20, false, 2); + run_byteQuery(byte_filterL, FloatParameter, Float.valueOf((float)-99), (byte)-99, true, 8); + run_byteQuery(byte_filterR, FloatParameter, Float.valueOf((float)-100), (byte)-100, false, 2); + run_byteQuery(byte_filterL, doubleParameter, Double.valueOf(50), (byte)50, true, 5); + run_byteQuery(byte_filterR, doubleParameter, Double.valueOf(60), (byte)60, false, 7); + run_byteQuery(byte_filterL, DoubleParameter, Double.valueOf(Byte.MAX_VALUE), Byte.MAX_VALUE, true, 1); + run_byteQuery(byte_filterR, DoubleParameter, Double.valueOf(25), (byte)25, false, 5); + run_byteQuery(byte_filterL, BigIntegerParameter, new BigInteger("50"), (byte)50, true, 5); + run_byteQuery(byte_filterR, BigIntegerParameter, new BigInteger("-100"), (byte)-100, false, 2); + run_byteQuery(byte_filterL, BigDecimalParameter, new BigDecimal("50.000000"), (byte)50, true, 5); + run_byteQuery(byte_filterR, BigDecimalParameter, new BigDecimal("10.00000"), (byte)10, false, 5); + alltypes.setbyte((byte)50); + run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte)50, true, 5); + alltypes.setbyte((byte)55); + run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte)55, true, 3); + run_byteQuery(byte_filterVal, null, null, (byte)100, false, 9); - run_StringQuery(String_filterL, StringParameter, new String("JDO"), new String("JDO"), true, 9); - run_StringQuery( - String_filterR, StringParameter, new String("JDBC"), new String("JDBC"), false, 1); - alltypes.setString(new String("abcde")); - run_StringQuery(String_filterObj, AllTypesParameter, alltypes, new String("abcde"), true, 3); - run_StringQuery(String_filterVal1, null, null, new String("Java"), false, 6); - run_StringQuery(String_filterVal2, null, null, new String(""), false, 1); + run_shortQuery(short_filterL, shortParameter, Short.valueOf((short)100), (short)100, true, 5); + run_shortQuery(short_filterR, shortParameter, Short.valueOf((short)100), (short)100, false, 7); + run_shortQuery(short_filterL, ShortParameter, Short.valueOf(Short.MIN_VALUE), Short.MIN_VALUE, true, 10); + run_shortQuery(short_filterR, ShortParameter, Short.valueOf((short)253), (short)253, false, 7); + run_shortQuery(short_filterR, shortParameter, Short.valueOf((short)1000), (short)1000, false, 8); + run_shortQuery(short_filterL, byteParameter, Byte.valueOf((byte)75), (short)75, true, 5); + run_shortQuery(short_filterR, byteParameter, Byte.valueOf((byte)-75), (short)-75, false, 4); + run_shortQuery(short_filterL, ByteParameter, Byte.valueOf((byte)100), (short)100, true, 5); + run_shortQuery(short_filterR, ByteParameter, Byte.valueOf((byte)100), (short)100, false, 7); + run_shortQuery(short_filterL, charParameter, Character.valueOf((char)75), (short)75, true, 5); + run_shortQuery(short_filterR, charParameter, Character.valueOf((char)9999), (short)9999, false, 8); + run_shortQuery(short_filterL, CharacterParameter, Character.valueOf((char)1000), (short)1000, true, 3); + run_shortQuery(short_filterR, CharacterParameter, Character.valueOf((char)10000), (short)10000, false, 9); + run_shortQuery(short_filterL, intParameter, Integer.valueOf(-10000), (short)-10000, true, 9); + run_shortQuery(short_filterR, intParameter, Integer.valueOf(-10000), (short)-10000, false, 2); + run_shortQuery(short_filterL, IntegerParameter, Integer.valueOf(10000), (short)10000, true, 2); + run_shortQuery(short_filterR, IntegerParameter, Integer.valueOf(30000), (short)30000, false, 9); + run_shortQuery(short_filterL, longParameter, Long.valueOf(10000), (short) 10000, true, 2); + run_shortQuery(short_filterR, longParameter, Long.valueOf(Short.MAX_VALUE), Short.MAX_VALUE, false, 10); + run_shortQuery(short_filterL, LongParameter, Long.valueOf(Short.MAX_VALUE), Short.MAX_VALUE, true, 1); + run_shortQuery(short_filterR, LongParameter, Long.valueOf(100), (short)100, false, 7); + run_shortQuery(short_filterL, floatParameter, Float.valueOf((float)23000), (short)23000, true, 1); + run_shortQuery(short_filterR, floatParameter, Float.valueOf((float)23000), (short)23000, false, 9); + run_shortQuery(short_filterL, FloatParameter, Float.valueOf((float)-1000), (short)-1000, true, 8); + run_shortQuery(short_filterR, FloatParameter, Float.valueOf((float)100), (short)100, false, 7); + run_shortQuery(short_filterL, doubleParameter, Double.valueOf(-10000.0), (short)-10000, true, 9); + run_shortQuery(short_filterR, doubleParameter, Double.valueOf(9999.0), (short)9999, false, 8); + run_shortQuery(short_filterL, DoubleParameter, Double.valueOf(23.0), (short)23, true, 5); + run_shortQuery(short_filterR, DoubleParameter, Double.valueOf(23.0), (short)23, false, 5); + run_shortQuery(short_filterL, BigIntegerParameter, new BigInteger("10000"), (short)10000, true, 2); + run_shortQuery(short_filterR, BigIntegerParameter, new BigInteger("30000"), (short)30000, false, 9); + run_shortQuery(short_filterL, BigDecimalParameter, new BigDecimal("23.0"), (short)23, true, 5); + run_shortQuery(short_filterR, BigDecimalParameter, new BigDecimal("23.0"), (short)23, false, 5); + alltypes.setshort((short)100); + run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short)100, true, 5); + alltypes.setshort((short)23); + run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short)23, true, 5); + run_shortQuery(short_filterVal, null, null, (short)1000, true, 3); + + run_charQuery(char_filterL, charParameter, Character.valueOf(Character.MIN_VALUE), Character.MIN_VALUE, true, 10); + run_charQuery(char_filterR, charParameter, Character.valueOf(Character.MAX_VALUE), Character.MAX_VALUE, false, 10); + run_charQuery(char_filterL, charParameter, Character.valueOf('C'), 'C', true, 6); + run_charQuery(char_filterR, charParameter, Character.valueOf('z'), 'z', false, 9); + run_charQuery(char_filterL, CharacterParameter, Character.valueOf(' '), ' ', true, 9); + run_charQuery(char_filterR, CharacterParameter, Character.valueOf('f'), 'f', false, 7); + run_charQuery(char_filterL, byteParameter, Byte.valueOf((byte)Character.MIN_VALUE), (char)Character.MIN_VALUE, true, 10); + run_charQuery(char_filterR, ByteParameter, Byte.valueOf((byte)'a'), 'a', false, 7); + run_charQuery(char_filterL, shortParameter, Short.valueOf((short)'M'), 'M', true, 5); + run_charQuery(char_filterR, shortParameter, Short.valueOf((short)'M'), 'M', false, 7); + run_charQuery(char_filterL, ShortParameter, Short.valueOf((short)'A'), 'A', true, 8); + run_charQuery(char_filterR, ShortParameter, Short.valueOf((short)'A'), 'A', false, 3); + run_charQuery(char_filterL, intParameter, Integer.valueOf('z'), 'z', true, 3); + run_charQuery(char_filterR, intParameter, Integer.valueOf('z'), 'z', false, 9); + run_charQuery(char_filterL, IntegerParameter, Integer.valueOf('B'), 'B', true, 7); + run_charQuery(char_filterR, IntegerParameter, Integer.valueOf('B'), 'B', false, 4); + run_charQuery(char_filterL, longParameter, Long.valueOf('z'), 'z', true, 3); + run_charQuery(char_filterR, longParameter, Long.valueOf('z'), 'z', false, 9); + run_charQuery(char_filterL, LongParameter, Long.valueOf('B'), 'B', true, 7); + run_charQuery(char_filterR, LongParameter, Long.valueOf('B'), 'B', false, 4); + run_charQuery(char_filterL, floatParameter, Float.valueOf((float)'f'), 'f', true, 3); + run_charQuery(char_filterR, floatParameter, Float.valueOf((float)' '), ' ', false, 2); + run_charQuery(char_filterL, FloatParameter, Float.valueOf((float)'z'), 'z', true, 3); + run_charQuery(char_filterR, FloatParameter, Float.valueOf((float)'z'), 'z', false, 9); + run_charQuery(char_filterL, doubleParameter, Double.valueOf('B'), 'B', true, 7); + run_charQuery(char_filterR, doubleParameter, Double.valueOf('B'), 'B', false, 4); + run_charQuery(char_filterL, DoubleParameter, Double.valueOf('A'), 'A', true, 8); + run_charQuery(char_filterR, DoubleParameter, Double.valueOf('A'), 'A', false, 3); + run_charQuery(char_filterL, BigIntegerParameter, new BigInteger("65"), 'A', true, 8); // 'A' == 65 + run_charQuery(char_filterR, BigIntegerParameter, new BigInteger("122"), 'z', false, 9); // 'z' == 122 + run_charQuery(char_filterL, BigDecimalParameter, new BigDecimal("65.00000"), 'A', true, 8); + run_charQuery(char_filterR, BigDecimalParameter, new BigDecimal("77.0000"), 'M', false, 7); // 'M' == 77 + alltypes.setchar('A'); + run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'A', true, 8); + alltypes.setchar('b'); + run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'b', true, 3); + run_charQuery(char_filterVal, null, null, 'M', true, 5); + + run_intQuery(int_filterL, intParameter, Integer.valueOf(AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, true, 10); + run_intQuery(int_filterR, intParameter, Integer.valueOf(AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, false, 10); + run_intQuery(int_filterR, intParameter, Integer.valueOf(23), 23, false, 4); + run_intQuery(int_filterL, IntegerParameter, Integer.valueOf(1000000), 1000000, true, 2); + run_intQuery(int_filterR, IntegerParameter, Integer.valueOf(1000), 1000, false, 7); + run_intQuery(int_filterL, byteParameter, Byte.valueOf((byte)100), 100, true, 6); + run_intQuery(int_filterR, byteParameter, Byte.valueOf((byte)0), 0, false, 4); + run_intQuery(int_filterL, ByteParameter, Byte.valueOf((byte)100), 100, true, 6); + run_intQuery(int_filterR, ByteParameter, Byte.valueOf((byte)0), 0, false, 4); + run_intQuery(int_filterL, shortParameter, Short.valueOf((short)10000), 10000, true, 3); + run_intQuery(int_filterR, shortParameter, Short.valueOf((short)-1000), -1000, false, 3); + run_intQuery(int_filterL, ShortParameter, Short.valueOf((short)-1000), -1000, true, 8); + run_intQuery(int_filterR, ShortParameter, Short.valueOf((short)10000), 10000, false, 8); + run_intQuery(int_filterL, charParameter, Character.valueOf((char)100), 100, true, 6); + run_intQuery(int_filterR, charParameter, Character.valueOf((char)0), 0, false, 4); + run_intQuery(int_filterL, CharacterParameter, Character.valueOf((char)100), 100, true, 6); + run_intQuery(int_filterR, CharacterParameter, Character.valueOf((char)10000), 10000, false, 8); + run_intQuery(int_filterL, longParameter, Long.valueOf(AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, true, 1); + run_intQuery(int_filterR, longParameter, Long.valueOf(AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, false, 1); + run_intQuery(int_filterL, LongParameter, Long.valueOf(10000), 10000, true, 3); + run_intQuery(int_filterR, LongParameter, Long.valueOf(43), 43, false, 4); + run_intQuery(int_filterL, floatParameter, Float.valueOf((float)AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, true, 1); + run_intQuery(int_filterR, floatParameter, Float.valueOf((float)AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, false, 1); + run_intQuery(int_filterL, FloatParameter, Float.valueOf((float)10000), 10000, true, 3); + run_intQuery(int_filterR, FloatParameter, Float.valueOf((float)43), 43, false, 4); + run_intQuery(int_filterL, doubleParameter, Double.valueOf(AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, true, 1); + run_intQuery(int_filterR, doubleParameter, Double.valueOf(AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, false, 1); + run_intQuery(int_filterL, DoubleParameter, Double.valueOf(10000), 10000, true, 3); + run_intQuery(int_filterR, DoubleParameter, Double.valueOf(43), 43, false, 4); + run_intQuery(int_filterL, BigIntegerParameter, new BigInteger("1000000"), 1000000, true, 2); + run_intQuery(int_filterR, BigIntegerParameter, new BigInteger("1000"), 1000, false, 7); + run_intQuery(int_filterL, BigDecimalParameter, new BigDecimal("10000.0"), 10000, true, 3); + run_intQuery(int_filterR, BigDecimalParameter, new BigDecimal("43.0"), 43, false, 4); + alltypes.setint(100); + run_intQuery(int_filterObj, AllTypesParameter, alltypes, 100, true, 6); + run_intQuery(int_filterVal, null, null, 1000, false, 7); + + run_longQuery(long_filterL, longParameter, Long.valueOf(Long.MIN_VALUE), Long.MIN_VALUE, true, 10); + run_longQuery(long_filterR, longParameter, Long.valueOf(Long.MAX_VALUE), Long.MAX_VALUE, false, 10); + run_longQuery(long_filterL, LongParameter, Long.valueOf(100), 100, true, 5); + run_longQuery(long_filterR, LongParameter, Long.valueOf(23), 23, false, 5); + run_longQuery(long_filterL, byteParameter, Byte.valueOf((byte)100), 100, true, 5); + run_longQuery(long_filterR, byteParameter, Byte.valueOf((byte)0), 0, false, 5); + run_longQuery(long_filterL, ByteParameter, Byte.valueOf((byte)100), 100, true, 5); + run_longQuery(long_filterR, ByteParameter, Byte.valueOf((byte)0), 0, false, 5); + run_longQuery(long_filterL, shortParameter, Short.valueOf((short)-1000), -1000, true, 8); + run_longQuery(long_filterR, shortParameter, Short.valueOf((short)1000), 1000, false, 8); + run_longQuery(long_filterL, ShortParameter, Short.valueOf((short)100), 100, true, 5); + run_longQuery(long_filterR, ShortParameter, Short.valueOf((short)32), 32, false, 5); + run_longQuery(long_filterL, charParameter, Character.valueOf((char)0), 0, true, 6); + run_longQuery(long_filterR, charParameter, Character.valueOf((char)100), 100, false, 7); + run_longQuery(long_filterL, CharacterParameter, Character.valueOf((char)23), 23, true, 5); + run_longQuery(long_filterR, CharacterParameter, Character.valueOf((char)0), 0, false, 5); + run_longQuery(long_filterL, intParameter, Integer.valueOf(100), 100, true, 5); + run_longQuery(long_filterR, intParameter, Integer.valueOf(0), 0, false, 5); + run_longQuery(long_filterL, IntegerParameter, Integer.valueOf(23), 23, true, 5); + run_longQuery(long_filterR, IntegerParameter, Integer.valueOf(1000000), 1000000, false, 9); + run_longQuery(long_filterL, floatParameter, Float.valueOf((float)-1000000.0), -1000000, true, 9); + run_longQuery(long_filterR, floatParameter, Float.valueOf((float)Long.MAX_VALUE), Long.MAX_VALUE, false, 10); + run_longQuery(long_filterL, FloatParameter, Float.valueOf((float)100.0), 100, true, 5); + run_longQuery(long_filterR, FloatParameter, Float.valueOf((float)32.0), 32, false, 5); + run_longQuery(long_filterL, doubleParameter, Double.valueOf(-1000000.0), -1000000, true, 9); + run_longQuery(long_filterR, doubleParameter, Double.valueOf((double)Long.MAX_VALUE), Long.MAX_VALUE, false, 10); + run_longQuery(long_filterL, DoubleParameter, Double.valueOf(100.0), 100, true, 5); + run_longQuery(long_filterR, DoubleParameter, Double.valueOf(32.0), 32, false, 5); + run_longQuery(long_filterL, BigIntegerParameter, new BigInteger("23"), 23, true, 5); + run_longQuery(long_filterR, BigIntegerParameter, new BigInteger("1000000"), 1000000, false, 9); + run_longQuery(long_filterL, BigDecimalParameter, new BigDecimal("100.0"), 100, true, 5); + run_longQuery(long_filterR, BigDecimalParameter, new BigDecimal("32.0"), 32, false, 5); + alltypes.setlong(100); + run_longQuery(long_filterObj, AllTypesParameter, alltypes, 100, false, 7); + run_longQuery(long_filterVal, null, null, 1000000, false, 9); + + run_floatQuery(float_filterL, floatParameter, Float.valueOf((float)AllTypes.FLOAT_SMALLEST), AllTypes.FLOAT_SMALLEST, true, 10); + run_floatQuery(float_filterR, floatParameter, Float.valueOf((float)AllTypes.FLOAT_LARGEST), AllTypes.FLOAT_LARGEST, false, 10); + run_floatQuery(float_filterL, FloatParameter, Float.valueOf(4.0f), 4.0f, true, 6); + run_floatQuery(float_filterR, FloatParameter, Float.valueOf(400.0f), 400.0f, false, 7); + run_floatQuery(float_filterL, byteParameter, Byte.valueOf((byte)4), 4.0f, true, 6); + run_floatQuery(float_filterR, byteParameter, Byte.valueOf((byte)23), 23.0f, false, 4); + run_floatQuery(float_filterL, ByteParameter, Byte.valueOf((byte)34), 34.0f, true, 6); + run_floatQuery(float_filterR, ByteParameter, Byte.valueOf((byte)100), 100.0f, false, 6); + run_floatQuery(float_filterL, shortParameter, Short.valueOf((short)10), 10.0f, true, 6); + run_floatQuery(float_filterR, shortParameter, Short.valueOf((short)23), 23.0f, false, 4); + run_floatQuery(float_filterL, ShortParameter, Short.valueOf((short)34), 34.0f, true, 6); + run_floatQuery(float_filterR, ShortParameter, Short.valueOf((short)100), 100.0f, false, 6); + run_floatQuery(float_filterL, charParameter, Character.valueOf((char)20), 20.0f, true, 6); + run_floatQuery(float_filterR, charParameter, Character.valueOf((char)23), 23.0f, false, 4); + run_floatQuery(float_filterL, CharacterParameter, Character.valueOf((char)34), 34.0f, true, 6); + run_floatQuery(float_filterR, CharacterParameter, Character.valueOf((char)100), 100.0f, false, 6); + run_floatQuery(float_filterL, intParameter, Integer.valueOf(55000000), 55000000.0f, true, 2); + run_floatQuery(float_filterR, intParameter, Integer.valueOf(23), 23.0f, false, 4); + run_floatQuery(float_filterL, IntegerParameter, Integer.valueOf(34), 34.0f, true, 6); + run_floatQuery(float_filterR, IntegerParameter, Integer.valueOf(100), 100.0f, false, 6); + run_floatQuery(float_filterL, longParameter, Long.valueOf(55000000), 55000000.0f, true, 2); + run_floatQuery(float_filterR, longParameter, Long.valueOf(23), 23.0f, false, 4); + run_floatQuery(float_filterL, LongParameter, Long.valueOf(34), 34.0f, true, 6); + run_floatQuery(float_filterR, LongParameter, Long.valueOf(100), 100.0f, false, 6); + run_floatQuery(float_filterL, doubleParameter, Double.valueOf(55000000.0), 55000000.0f, true, 2); + run_floatQuery(float_filterR, doubleParameter, Double.valueOf(-20.5), -20.5f, false, 3); + run_floatQuery(float_filterL, DoubleParameter, Double.valueOf(2.0), 2.0f, true, 6); + run_floatQuery(float_filterR, DoubleParameter, Double.valueOf(100.0), 100.0f, false, 6); + run_floatQuery(float_filterL, BigIntegerParameter, new BigInteger("55000000"), 55000000.0f, true, 2); + run_floatQuery(float_filterR, BigIntegerParameter, new BigInteger("23"), 23.0f, false, 4); + run_floatQuery(float_filterL, BigDecimalParameter, new BigDecimal("55000000.0"), 55000000.0f, true, 2); + run_floatQuery(float_filterR, BigDecimalParameter, new BigDecimal("-20.5"), -20.5f, false, 3); + alltypes.setfloat(23.23f); + run_floatQuery(float_filterObj, AllTypesParameter, alltypes, 23.23f, false, 4); + run_floatQuery(float_filterVal, null, null, 100.0f, false, 6); + + run_doubleQuery(double_filterL, doubleParameter, Double.valueOf(AllTypes.DOUBLE_SMALLEST), AllTypes.DOUBLE_SMALLEST, true, 10); + run_doubleQuery(double_filterR, doubleParameter, Double.valueOf(AllTypes.DOUBLE_LARGEST), AllTypes.DOUBLE_LARGEST, false, 10); + run_doubleQuery(double_filterL, DoubleParameter, Double.valueOf(0.0), 0.0, true, 7); + run_doubleQuery(double_filterR, DoubleParameter, Double.valueOf(23.34), 23.34, false, 4); + run_doubleQuery(double_filterL, byteParameter, Byte.valueOf((byte)100), 100.0, true, 6); + run_doubleQuery(double_filterR, byteParameter, Byte.valueOf((byte)0), 0.0, false, 4); + run_doubleQuery(double_filterL, ByteParameter, Byte.valueOf((byte)23), 23.0, true, 6); + run_doubleQuery(double_filterR, ByteParameter, Byte.valueOf((byte)100), 100.0, false, 6); + run_doubleQuery(double_filterL, charParameter, Character.valueOf((char)100), 100.0, true, 6); + run_doubleQuery(double_filterR, charParameter, Character.valueOf((char)0), 0.0, false, 4); + run_doubleQuery(double_filterL, CharacterParameter, Character.valueOf((char)23), 23.0, true, 6); + run_doubleQuery(double_filterR, CharacterParameter, Character.valueOf((char)100), 100.0, false, 6); + run_doubleQuery(double_filterL, shortParameter, Short.valueOf((short)100), 100.0, true, 6); + run_doubleQuery(double_filterR, shortParameter, Short.valueOf((short)0), 0.0, false, 4); + run_doubleQuery(double_filterL, ShortParameter, Short.valueOf((short)23), 23.0, true, 6); + run_doubleQuery(double_filterR, ShortParameter, Short.valueOf((short)100), 100.0, false, 6); + run_doubleQuery(double_filterL, intParameter, Integer.valueOf(100), 100.0, true, 6); + run_doubleQuery(double_filterR, intParameter, Integer.valueOf(0), 0.0, false, 4); + run_doubleQuery(double_filterL, IntegerParameter, Integer.valueOf(5000), 5000.0, true, 3); + run_doubleQuery(double_filterR, IntegerParameter, Integer.valueOf(-20), -20.0, false, 3); + run_doubleQuery(double_filterL, longParameter, Long.valueOf(100), 100.0, true, 6); + run_doubleQuery(double_filterR, longParameter, Long.valueOf(0), 0.0, false, 4); + run_doubleQuery(double_filterL, LongParameter, Long.valueOf(5000), 5000.0, true, 3); + run_doubleQuery(double_filterR, LongParameter, Long.valueOf(-20), -20.0, false, 3); + run_doubleQuery(double_filterL, floatParameter, Float.valueOf(0.0f), 0.0f, true, 7); + run_doubleQuery(double_filterR, floatParameter, Float.valueOf(100.0f), 100.0f, false, 6); + run_doubleQuery(double_filterL, FloatParameter, Float.valueOf(100.0f), 100.0, true, 6); + run_doubleQuery(double_filterR, FloatParameter, Float.valueOf(69.96f), 69.96, false, 4); + run_doubleQuery(double_filterL, BigIntegerParameter, new BigInteger("5000"), 5000.0, true, 3); + run_doubleQuery(double_filterR, BigIntegerParameter, new BigInteger("-20"), -20.0, false, 3); + run_doubleQuery(double_filterL, BigDecimalParameter, new BigDecimal("100.0"), 100.0, true, 6); + run_doubleQuery(double_filterR, BigDecimalParameter, new BigDecimal("69.96"), 69.96, false, 4); + alltypes.setdouble(-25.5); + run_doubleQuery(double_filterObj, AllTypesParameter, alltypes, -25.5, true, 8); + run_doubleQuery(double_filterVal, null, null, 100.0, false, 6); + + run_ByteQuery(Byte_filterL, byteParameter, Byte.valueOf((byte)50), Byte.valueOf((byte)50), true, 5); + run_ByteQuery(Byte_filterR, byteParameter, Byte.valueOf(Byte.MIN_VALUE), Byte.valueOf(Byte.MIN_VALUE), false, 1); + run_ByteQuery(Byte_filterL, ByteParameter, Byte.valueOf((byte)20), Byte.valueOf((byte)20), true, 5); + run_ByteQuery(Byte_filterR, ByteParameter, Byte.valueOf(Byte.MAX_VALUE), Byte.valueOf(Byte.MAX_VALUE), false, 10); + run_ByteQuery(Byte_filterL, shortParameter, Short.valueOf((short)60), Byte.valueOf((byte)60), true, 3); + run_ByteQuery(Byte_filterR, shortParameter, Short.valueOf((short)51), Byte.valueOf((byte)51), false, 7); + run_ByteQuery(Byte_filterL, ShortParameter, Short.valueOf((short)-100), Byte.valueOf((byte)-100), true, 9); + run_ByteQuery(Byte_filterR, ShortParameter, Short.valueOf((short)-100), Byte.valueOf((byte)-100), false, 2); + run_ByteQuery(Byte_filterL, charParameter, Character.valueOf((char)101), Byte.valueOf((byte)101), true, 1); + run_ByteQuery(Byte_filterR, charParameter, Character.valueOf((char)10), Byte.valueOf((byte)10), false, 5); + run_ByteQuery(Byte_filterL, CharacterParameter, Character.valueOf((char)50), Byte.valueOf((byte)50), true, 5); + run_ByteQuery(Byte_filterR, CharacterParameter, Character.valueOf((char)75), Byte.valueOf((byte)75), false, 8); + run_ByteQuery(Byte_filterL, intParameter, Integer.valueOf(77), Byte.valueOf((byte)77), true, 2); + run_ByteQuery(Byte_filterR, intParameter, Integer.valueOf(60), Byte.valueOf((byte)60), false, 7); + run_ByteQuery(Byte_filterL, IntegerParameter, Integer.valueOf(40), Byte.valueOf((byte)40), true, 5); + run_ByteQuery(Byte_filterR, IntegerParameter, Integer.valueOf(75), Byte.valueOf((byte)75), false, 8); + run_ByteQuery(Byte_filterL, longParameter, Long.valueOf(50), Byte.valueOf((byte)50), true, 5); + run_ByteQuery(Byte_filterR, longParameter, Long.valueOf(50), Byte.valueOf((byte)50), false, 7); + run_ByteQuery(Byte_filterL, LongParameter, Long.valueOf(-100), Byte.valueOf((byte)-100), true, 9); + run_ByteQuery(Byte_filterR, LongParameter, Long.valueOf(-100), Byte.valueOf((byte)-100), false, 2); + run_ByteQuery(Byte_filterL, floatParameter, Float.valueOf((float)50), Byte.valueOf((byte)50), true, 5); + run_ByteQuery(Byte_filterR, floatParameter, Float.valueOf((float)50), Byte.valueOf((byte)50), false, 7); + run_ByteQuery(Byte_filterL, FloatParameter, Float.valueOf((float)-100), Byte.valueOf((byte)-100), true, 9); + run_ByteQuery(Byte_filterR, FloatParameter, Float.valueOf((float)-100), Byte.valueOf((byte)-100), false, 2); + run_ByteQuery(Byte_filterL, doubleParameter, Double.valueOf(50), Byte.valueOf((byte)50), true, 5); + run_ByteQuery(Byte_filterR, doubleParameter, Double.valueOf(50), Byte.valueOf((byte)50), false, 7); + run_ByteQuery(Byte_filterL, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte)-100), true, 9); + run_ByteQuery(Byte_filterR, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte)-100), false, 2); + run_ByteQuery(Byte_filterL, BigIntegerParameter, new BigInteger("50"), Byte.valueOf((byte)50), true, 5); + run_ByteQuery(Byte_filterR, BigIntegerParameter, new BigInteger("-100"), Byte.valueOf((byte)-100), false, 2); + run_ByteQuery(Byte_filterL, BigDecimalParameter, new BigDecimal("50.000000"), Byte.valueOf((byte)50), true, 5); + run_ByteQuery(Byte_filterR, BigDecimalParameter, new BigDecimal("10.00000"), Byte.valueOf((byte)10), false, 5); + Byte val = Byte.valueOf((byte)50); + alltypes.setByte(val); + run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, false, 7); + val = Byte.valueOf((byte)51); + alltypes.setByte(val); + run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, false, 7); + run_ByteQuery(Byte_filterVal, null, null, Byte.valueOf((byte)100), true, 2); + + run_ShortQuery(Short_filterL, shortParameter, Short.valueOf((short)100), Short.valueOf((short)100), true, 5); + run_ShortQuery(Short_filterR, shortParameter, Short.valueOf((short)100), Short.valueOf((short)100), false, 7); + run_ShortQuery(Short_filterL, ShortParameter, Short.valueOf(Short.MIN_VALUE), Short.valueOf(Short.MIN_VALUE), true, 10); + run_ShortQuery(Short_filterR, ShortParameter, Short.valueOf((short)253), Short.valueOf((short)253), false, 7); + run_ShortQuery(Short_filterR, shortParameter, Short.valueOf((short)1000), Short.valueOf((short)1000), false, 8); + run_ShortQuery(Short_filterL, byteParameter, Byte.valueOf((byte)75), Short.valueOf((short)75), true, 5); + run_ShortQuery(Short_filterR, byteParameter, Byte.valueOf((byte)75), Short.valueOf((short)75), false, 5); + run_ShortQuery(Short_filterL, ByteParameter, Byte.valueOf((byte)100), Short.valueOf((short)100), true, 5); + run_ShortQuery(Short_filterR, ByteParameter, Byte.valueOf((byte)100), Short.valueOf((short)100), false, 7); + run_ShortQuery(Short_filterL, charParameter, Character.valueOf((char)75), Short.valueOf((short)75), true, 5); + run_ShortQuery(Short_filterR, charParameter, Character.valueOf((char)75), Short.valueOf((short)75), false, 5); + run_ShortQuery(Short_filterL, CharacterParameter, Character.valueOf((char)100), Short.valueOf((short)100), true, 5); + run_ShortQuery(Short_filterR, CharacterParameter, Character.valueOf((char)200), Short.valueOf((short)200), false, 7); + run_ShortQuery(Short_filterL, intParameter, Integer.valueOf(-10000), Short.valueOf((short)-10000), true, 9); + run_ShortQuery(Short_filterR, intParameter, Integer.valueOf(-10000), Short.valueOf((short)-10000), false, 2); + run_ShortQuery(Short_filterL, IntegerParameter, Integer.valueOf(10000), Short.valueOf((short)10000), true, 2); + run_ShortQuery(Short_filterR, IntegerParameter, Integer.valueOf(10000), Short.valueOf((short)10000), false, 9); + run_ShortQuery(Short_filterL, longParameter, Long.valueOf(20000), Short.valueOf((short) 20000), true, 1); + run_ShortQuery(Short_filterR, longParameter, Long.valueOf(5000), Short.valueOf((short) 5000), false, 8); + run_ShortQuery(Short_filterL, LongParameter, Long.valueOf(200), Short.valueOf((short)200), true, 3); + run_ShortQuery(Short_filterR, LongParameter, Long.valueOf(500), Short.valueOf((short)500), false, 7); + run_ShortQuery(Short_filterL, floatParameter, Float.valueOf(23000.0f), Short.valueOf((short)23000), true, 1); + run_ShortQuery(Short_filterR, floatParameter, Float.valueOf(23000.0f), Short.valueOf((short)23000), false, 9); + run_ShortQuery(Short_filterL, FloatParameter, Float.valueOf(10.0f), Short.valueOf((short)10), true, 5); + run_ShortQuery(Short_filterR, FloatParameter, Float.valueOf(101.0f), Short.valueOf((short)101), false, 7); + run_ShortQuery(Short_filterL, doubleParameter, Double.valueOf(-10000.0), Short.valueOf((short)-10000), true, 9); + run_ShortQuery(Short_filterR, doubleParameter, Double.valueOf(-10000.0), Short.valueOf((short)-10000), false, 2); + run_ShortQuery(Short_filterL, DoubleParameter, Double.valueOf(101.0), Short.valueOf((short)101), true, 3); + run_ShortQuery(Short_filterR, DoubleParameter, Double.valueOf(23.0), Short.valueOf((short)23), false, 5); + run_ShortQuery(Short_filterL, BigIntegerParameter, new BigInteger("10000"), Short.valueOf((short)10000), true, 2); + run_ShortQuery(Short_filterR, BigIntegerParameter, new BigInteger("30000"), Short.valueOf((short)30000), false, 9); + run_ShortQuery(Short_filterL, BigDecimalParameter, new BigDecimal("23.0"), Short.valueOf((short)23), true, 5); + run_ShortQuery(Short_filterR, BigDecimalParameter, new BigDecimal("23.0"), Short.valueOf((short)23), false, 5); + Short sval = Short.valueOf((short)100); + alltypes.setShort(sval); + run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, false, 7); + sval = Short.valueOf((short)23); + alltypes.setShort(sval); + run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, false, 5); + run_ShortQuery(Short_filterVal, null, null, Short.valueOf((short)-1000), true, 8); + + run_CharacterQuery(Character_filterL, charParameter, Character.valueOf(Character.MIN_VALUE), Character.valueOf(Character.MIN_VALUE), true, 10); + run_CharacterQuery(Character_filterR, charParameter, Character.valueOf(Character.MAX_VALUE), Character.valueOf(Character.MAX_VALUE), false, 10); + run_CharacterQuery(Character_filterL, charParameter, Character.valueOf('C'), Character.valueOf('C'), true, 6); + run_CharacterQuery(Character_filterR, charParameter, Character.valueOf('z'), Character.valueOf('z'), false, 9); + run_CharacterQuery(Character_filterL, CharacterParameter, Character.valueOf(' '), Character.valueOf(' '), true, 9); + run_CharacterQuery(Character_filterR, CharacterParameter, Character.valueOf('f'), Character.valueOf('f'), false, 7); + run_CharacterQuery(Character_filterL, byteParameter, Byte.valueOf((byte)Character.MIN_VALUE), Character.valueOf((char)Character.MIN_VALUE), true, 10); + run_CharacterQuery(Character_filterR, ByteParameter, Byte.valueOf((byte)'a'), Character.valueOf('a'), false, 7); + run_CharacterQuery(Character_filterL, shortParameter, Short.valueOf((short)'M'), Character.valueOf('M'), true, 5); + run_CharacterQuery(Character_filterR, shortParameter, Short.valueOf((short)'F'), Character.valueOf('F'), false, 5); + run_CharacterQuery(Character_filterL, ShortParameter, Short.valueOf((short)'A'), Character.valueOf('A'), true, 8); + run_CharacterQuery(Character_filterR, ShortParameter, Short.valueOf((short)'A'), Character.valueOf('A'), false, 3); + run_CharacterQuery(Character_filterL, intParameter, Integer.valueOf('z'), Character.valueOf('z'), true, 3); + run_CharacterQuery(Character_filterR, intParameter, Integer.valueOf('z'), Character.valueOf('z'), false, 9); + run_CharacterQuery(Character_filterL, IntegerParameter, Integer.valueOf('B'), Character.valueOf('B'), true, 7); + run_CharacterQuery(Character_filterR, IntegerParameter, Integer.valueOf('B'), Character.valueOf('B'), false, 4); + run_CharacterQuery(Character_filterL, longParameter, Long.valueOf('z'), Character.valueOf('z'), true, 3); + run_CharacterQuery(Character_filterR, longParameter, Long.valueOf('z'), Character.valueOf('z'), false, 9); + run_CharacterQuery(Character_filterL, LongParameter, Long.valueOf('B'), Character.valueOf('B'), true, 7); + run_CharacterQuery(Character_filterR, LongParameter, Long.valueOf('B'), Character.valueOf('B'), false, 4); + run_CharacterQuery(Character_filterL, floatParameter, Float.valueOf((float)'z'), Character.valueOf('z'), true, 3); + run_CharacterQuery(Character_filterR, floatParameter, Float.valueOf((float)'z'), Character.valueOf('z'), false, 9); + run_CharacterQuery(Character_filterL, FloatParameter, Float.valueOf((float)'M'), Character.valueOf('M'), true, 5); + run_CharacterQuery(Character_filterR, FloatParameter, Float.valueOf((float)'X'), Character.valueOf('X'), false, 7); + run_CharacterQuery(Character_filterL, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), true, 7); + run_CharacterQuery(Character_filterR, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), false, 4); + run_CharacterQuery(Character_filterL, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), true, 8); + run_CharacterQuery(Character_filterR, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), false, 3); + run_CharacterQuery(Character_filterL, BigIntegerParameter, new BigInteger("65"), Character.valueOf('A'), true, 8); // 'A' == 65 + run_CharacterQuery(Character_filterR, BigIntegerParameter, new BigInteger("122"), Character.valueOf('z'), false, 9); // 'z' == 122 + run_CharacterQuery(Character_filterL, BigDecimalParameter, new BigDecimal("65.00000"), Character.valueOf('A'), true, 8); + run_CharacterQuery(Character_filterR, BigDecimalParameter, new BigDecimal("77.0000"), Character.valueOf('M'), false, 7); // 'M' == 77 + alltypes.setCharacter(Character.valueOf('A')); + run_CharacterQuery(Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('A'), true, 8); + alltypes.setCharacter(Character.valueOf('b')); + run_CharacterQuery(Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('b'), true, 3); + run_CharacterQuery(Character_filterVal, null, null, Character.valueOf('z'), false, 9); + + run_IntegerQuery(Integer_filterL, intParameter, Integer.valueOf(AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), true, 10); + run_IntegerQuery(Integer_filterR, intParameter, Integer.valueOf(AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), false, 10); + run_IntegerQuery(Integer_filterR, intParameter, Integer.valueOf(23), Integer.valueOf(23), false, 4); + run_IntegerQuery(Integer_filterL, IntegerParameter, Integer.valueOf(1000000), Integer.valueOf(1000000), true, 2); + run_IntegerQuery(Integer_filterR, IntegerParameter, Integer.valueOf(1000), Integer.valueOf(1000), false, 7); + run_IntegerQuery(Integer_filterL, byteParameter, Byte.valueOf((byte)100), Integer.valueOf(100), true, 6); + run_IntegerQuery(Integer_filterR, byteParameter, Byte.valueOf((byte)0), Integer.valueOf(0), false, 4); + run_IntegerQuery(Integer_filterL, ByteParameter, Byte.valueOf((byte)100), Integer.valueOf(100), true, 6); + run_IntegerQuery(Integer_filterR, ByteParameter, Byte.valueOf((byte)0), Integer.valueOf(0), false, 4); + run_IntegerQuery(Integer_filterL, shortParameter, Short.valueOf((short)10000), Integer.valueOf(10000), true, 3); + run_IntegerQuery(Integer_filterR, shortParameter, Short.valueOf((short)-1000), Integer.valueOf(-1000), false, 3); + run_IntegerQuery(Integer_filterL, ShortParameter, Short.valueOf((short)-1000), Integer.valueOf(-1000), true, 8); + run_IntegerQuery(Integer_filterR, ShortParameter, Short.valueOf((short)-999), Integer.valueOf(-999), false, 3); + run_IntegerQuery(Integer_filterL, charParameter, Character.valueOf((char)10000), Integer.valueOf(10000), true, 3); + run_IntegerQuery(Integer_filterR, charParameter, Character.valueOf((char)10000), Integer.valueOf(10000), false, 8); + run_IntegerQuery(Integer_filterL, CharacterParameter, Character.valueOf((char)100), Integer.valueOf(100), true, 6); + run_IntegerQuery(Integer_filterR, CharacterParameter, Character.valueOf((char)10000), Integer.valueOf(10000), false, 8); + run_IntegerQuery(Integer_filterL, longParameter, Long.valueOf(AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), true, 1); + run_IntegerQuery(Integer_filterR, longParameter, Long.valueOf(AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), false, 1); + run_IntegerQuery(Integer_filterL, LongParameter, Long.valueOf(10000), Integer.valueOf(10000), true, 3); + run_IntegerQuery(Integer_filterR, LongParameter, Long.valueOf(43), Integer.valueOf(43), false, 4); + run_IntegerQuery(Integer_filterL, floatParameter, Float.valueOf((float)AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), true, 1); + run_IntegerQuery(Integer_filterR, floatParameter, Float.valueOf((float)AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), false, 1); + run_IntegerQuery(Integer_filterL, FloatParameter, Float.valueOf((float)10000), Integer.valueOf(10000), true, 3); + run_IntegerQuery(Integer_filterR, FloatParameter, Float.valueOf((float)43), Integer.valueOf(43), false, 4); + run_IntegerQuery(Integer_filterL, doubleParameter, Double.valueOf(AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), true, 1); + run_IntegerQuery(Integer_filterR, doubleParameter, Double.valueOf(AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), false, 1); + run_IntegerQuery(Integer_filterL, DoubleParameter, Double.valueOf(10000), Integer.valueOf(10000), true, 3); + run_IntegerQuery(Integer_filterR, DoubleParameter, Double.valueOf(1000001.0), Integer.valueOf(1000001), false, 9); + run_IntegerQuery(Integer_filterL, BigIntegerParameter, new BigInteger("1000000"), Integer.valueOf(1000000), true, 2); + run_IntegerQuery(Integer_filterR, BigIntegerParameter, new BigInteger("1000"), Integer.valueOf(1000), false, 7); + run_IntegerQuery(Integer_filterL, BigDecimalParameter, new BigDecimal("10000.0"), Integer.valueOf(10000), true, 3); + run_IntegerQuery(Integer_filterR, BigDecimalParameter, new BigDecimal("43.0"), Integer.valueOf(43), false, 4); + alltypes.setInteger(Integer.valueOf(100)); + run_IntegerQuery(Integer_filterObj, AllTypesParameter, alltypes, Integer.valueOf(100), false, 6); + run_IntegerQuery(Integer_filterVal, null, null, Integer.valueOf(100), false, 6); + + run_LongQuery(Long_filterL, longParameter, Long.valueOf(Long.MIN_VALUE), Long.valueOf(Long.MIN_VALUE), true, 10); + run_LongQuery(Long_filterR, longParameter, Long.valueOf(Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE), false, 10); + run_LongQuery(Long_filterL, LongParameter, Long.valueOf(100), Long.valueOf(100), true, 5); + run_LongQuery(Long_filterR, LongParameter, Long.valueOf(23), Long.valueOf(23), false, 5); + run_LongQuery(Long_filterL, byteParameter, Byte.valueOf((byte)100), Long.valueOf(100), true, 5); + run_LongQuery(Long_filterR, byteParameter, Byte.valueOf((byte)0), Long.valueOf(0), false, 5); + run_LongQuery(Long_filterL, ByteParameter, Byte.valueOf((byte)100), Long.valueOf(100), true, 5); + run_LongQuery(Long_filterR, ByteParameter, Byte.valueOf((byte)0), Long.valueOf(0), false, 5); + run_LongQuery(Long_filterL, shortParameter, Short.valueOf((short)-1000 ), Long.valueOf(-1000), true, 8); + run_LongQuery(Long_filterR, shortParameter, Short.valueOf((short)1000), Long.valueOf(1000), false, 8); + run_LongQuery(Long_filterL, ShortParameter, Short.valueOf((short)101), Long.valueOf(101), true, 3); + run_LongQuery(Long_filterR, ShortParameter, Short.valueOf((short)32), Long.valueOf(32), false, 5); + run_LongQuery(Long_filterL, charParameter, Character.valueOf((char)0), Long.valueOf(0), true, 6); + run_LongQuery(Long_filterR, charParameter, Character.valueOf((char)100), Long.valueOf(100), false, 7); + run_LongQuery(Long_filterL, CharacterParameter, Character.valueOf((char)23), Long.valueOf(23), true, 5); + run_LongQuery(Long_filterR, CharacterParameter, Character.valueOf((char)1110), Long.valueOf(1110), false, 8); + run_LongQuery(Long_filterL, intParameter, Integer.valueOf(100), Long.valueOf(100), true, 5); + run_LongQuery(Long_filterR, intParameter, Integer.valueOf(0), Long.valueOf(0), false, 5); + run_LongQuery(Long_filterL, IntegerParameter, Integer.valueOf(23), Long.valueOf(23), true, 5); + run_LongQuery(Long_filterR, IntegerParameter, Integer.valueOf(1000000), Long.valueOf(1000000), false, 9); + run_LongQuery(Long_filterL, floatParameter, Float.valueOf((float)-1000000.0), Long.valueOf(-1000000), true, 9); + run_LongQuery(Long_filterR, floatParameter, Float.valueOf((float)Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE), false, 10); + run_LongQuery(Long_filterL, FloatParameter, Float.valueOf(100.0f), Long.valueOf(100), true, 5); + run_LongQuery(Long_filterR, FloatParameter, Float.valueOf(32.0f), Long.valueOf(32), false, 5); + run_LongQuery(Long_filterL, doubleParameter, Double.valueOf(-1000000.0), Long.valueOf(-1000000), true, 9); + run_LongQuery(Long_filterR, doubleParameter, Double.valueOf((double)Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE), false, 10); + run_LongQuery(Long_filterL, DoubleParameter, Double.valueOf(100.0), Long.valueOf(100), true, 5); + run_LongQuery(Long_filterR, DoubleParameter, Double.valueOf(32.0), Long.valueOf(32), false, 5); + run_LongQuery(Long_filterL, BigIntegerParameter, new BigInteger("23"), Long.valueOf(23), true, 5); + run_LongQuery(Long_filterR, BigIntegerParameter, new BigInteger("1000000"), Long.valueOf(1000000), false, 9); + run_LongQuery(Long_filterL, BigDecimalParameter, new BigDecimal("100.0"), Long.valueOf(100), true, 5); + run_LongQuery(Long_filterR, BigDecimalParameter, new BigDecimal("32.0"), Long.valueOf(32), false, 5); + alltypes.setLong(Long.valueOf(100)); + run_LongQuery(Long_filterObj, AllTypesParameter, alltypes, Long.valueOf(100), true, 5); + run_LongQuery(Long_filterVal, null, null, Long.valueOf(-1000), true, 8); + + run_FloatQuery(Float_filterL, floatParameter, Float.valueOf(-1000000000.0f), Float.valueOf(-1000000000.0f), true, 9); + run_FloatQuery(Float_filterR, floatParameter, Float.valueOf(100.0f), Float.valueOf(100.0f), false, 5); + run_FloatQuery(Float_filterL, FloatParameter, Float.valueOf((float)0.0), Float.valueOf(0.0f), true, 8); + run_FloatQuery(Float_filterR, FloatParameter, Float.valueOf((float)4.0), Float.valueOf(4.0f), false, 3); + run_FloatQuery(Float_filterL, byteParameter, Byte.valueOf((byte)0), Float.valueOf(0.0f), true, 8); + run_FloatQuery(Float_filterR, byteParameter, Byte.valueOf((byte)23), Float.valueOf(23.0f), false, 3); + run_FloatQuery(Float_filterL, ByteParameter, Byte.valueOf((byte)34), Float.valueOf(34.0f), true, 7); + run_FloatQuery(Float_filterR, ByteParameter, Byte.valueOf((byte)100), Float.valueOf(100.0f), false, 5); + run_FloatQuery(Float_filterL, shortParameter, Short.valueOf((short)0), Float.valueOf(0.0f), true, 8); + run_FloatQuery(Float_filterR, shortParameter, Short.valueOf((short)23), Float.valueOf(23.0f), false, 3); + run_FloatQuery(Float_filterL, ShortParameter, Short.valueOf((short)34), Float.valueOf(34.0f), true, 7); + run_FloatQuery(Float_filterR, ShortParameter, Short.valueOf((short)100), Float.valueOf(100.0f), false, 5); + run_FloatQuery(Float_filterL, charParameter, Character.valueOf((char)0), Float.valueOf(0.0f), true, 8); + run_FloatQuery(Float_filterR, charParameter, Character.valueOf((char)23), Float.valueOf(23.0f), false, 3); + run_FloatQuery(Float_filterL, CharacterParameter, Character.valueOf((char)34), Float.valueOf(34.0f), true, 7); + run_FloatQuery(Float_filterR, CharacterParameter, Character.valueOf((char)100), Float.valueOf(100.0f), false, 5); + run_FloatQuery(Float_filterL, intParameter, Integer.valueOf(50000000), Float.valueOf(50000000.0f), true, 3); + run_FloatQuery(Float_filterR, intParameter, Integer.valueOf(23), Float.valueOf(23.0f), false, 3); + run_FloatQuery(Float_filterL, IntegerParameter, Integer.valueOf(34), Float.valueOf(34.0f), true, 7); + run_FloatQuery(Float_filterR, IntegerParameter, Integer.valueOf(100), Float.valueOf(100.0f), false, 5); + run_FloatQuery(Float_filterL, longParameter, Long.valueOf(50000000), Float.valueOf(50000000.0f), true, 3); + run_FloatQuery(Float_filterR, longParameter, Long.valueOf(23), Float.valueOf(23.0f), false, 3); + run_FloatQuery(Float_filterL, LongParameter, Long.valueOf(34), Float.valueOf(34.0f), true, 7); + run_FloatQuery(Float_filterR, LongParameter, Long.valueOf(100), Float.valueOf(100.0f), false, 5); + run_FloatQuery(Float_filterL, doubleParameter, Double.valueOf(50000000.0f), Float.valueOf(50000000.0f), true, 3); + run_FloatQuery(Float_filterR, doubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), false, 5); + run_FloatQuery(Float_filterL, DoubleParameter, Double.valueOf(0.0f), Float.valueOf(0.0f), true, 8); + run_FloatQuery(Float_filterR, DoubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), false, 5); + run_FloatQuery(Float_filterL, BigIntegerParameter, new BigInteger("55000000"), Float.valueOf(55000000.0f), true, 2); + run_FloatQuery(Float_filterR, BigIntegerParameter, new BigInteger("23"), Float.valueOf(23.0f), false, 3); + run_FloatQuery(Float_filterL, BigDecimalParameter, new BigDecimal("55000000.0"), Float.valueOf(55000000.0f), true, 2); + run_FloatQuery(Float_filterR, BigDecimalParameter, new BigDecimal("-20.5"), Float.valueOf(-20.5f), false, 2); + alltypes.setFloat(Float.valueOf(23.23f)); + run_FloatQuery(Float_filterObj, AllTypesParameter, alltypes, Float.valueOf(23.23f), false, 3); + run_FloatQuery(Float_filterVal, null, null, Float.valueOf(100.0f), true, 7); + + run_DoubleQuery(Double_filterL, doubleParameter, Double.valueOf(-999999999999.0), Double.valueOf(-999999999999.0), true, 9); + run_DoubleQuery(Double_filterR, doubleParameter, Double.valueOf(9999999999999.0), Double.valueOf(9999999999999.0), false, 9); + run_DoubleQuery(Double_filterL, DoubleParameter, Double.valueOf(0.0), Double.valueOf(0.0), true, 7); + run_DoubleQuery(Double_filterR, DoubleParameter, Double.valueOf(23.34), Double.valueOf(23.34), false, 4); + run_DoubleQuery(Double_filterL, byteParameter, Byte.valueOf((byte)100), Double.valueOf(100.0), true, 6); + run_DoubleQuery(Double_filterR, byteParameter, Byte.valueOf((byte)0), Double.valueOf(0.0), false, 4); + run_DoubleQuery(Double_filterL, ByteParameter, Byte.valueOf((byte)-23), Double.valueOf(-23.0), true, 7); + run_DoubleQuery(Double_filterR, ByteParameter, Byte.valueOf((byte)100), Double.valueOf(100.0), false, 6); + run_DoubleQuery(Double_filterL, shortParameter, Short.valueOf((short)100), Double.valueOf(100.0), true, 6); + run_DoubleQuery(Double_filterR, shortParameter, Short.valueOf((short)0), Double.valueOf(0.0), false, 4); + run_DoubleQuery(Double_filterL, ShortParameter, Short.valueOf((short)23), Double.valueOf(23.0), true, 6); + run_DoubleQuery(Double_filterR, ShortParameter, Short.valueOf((short)400), Double.valueOf(400.0), false, 7); + run_DoubleQuery(Double_filterL, charParameter, Character.valueOf((char)100), Double.valueOf(100.0), true, 6); + run_DoubleQuery(Double_filterR, charParameter, Character.valueOf((char)0), Double.valueOf(0.0), false, 4); + run_DoubleQuery(Double_filterL, CharacterParameter, Character.valueOf((char)23), Double.valueOf(23.0), true, 6); + run_DoubleQuery(Double_filterR, CharacterParameter, Character.valueOf((char)400), Double.valueOf(400.0), false, 7); + run_DoubleQuery(Double_filterL, intParameter, Integer.valueOf(100), Double.valueOf(100.0), true, 6); + run_DoubleQuery(Double_filterR, intParameter, Integer.valueOf(0), Double.valueOf(0.0), false, 4); + run_DoubleQuery(Double_filterL, IntegerParameter, Integer.valueOf(23), Double.valueOf(23.0), true, 6); + run_DoubleQuery(Double_filterR, IntegerParameter, Integer.valueOf(100), Double.valueOf(100.0), false, 6); + run_DoubleQuery(Double_filterL, longParameter, Long.valueOf(100), Double.valueOf(100.0), true, 6); + run_DoubleQuery(Double_filterR, longParameter, Long.valueOf(0), Double.valueOf(0.0), false, 4); + run_DoubleQuery(Double_filterL, LongParameter, Long.valueOf(23), Double.valueOf(23.0), true, 6); + run_DoubleQuery(Double_filterR, LongParameter, Long.valueOf(100), Double.valueOf(100.0), false, 6); + run_DoubleQuery(Double_filterL, floatParameter, Float.valueOf(0.0f), Double.valueOf(0.0f), true, 7); + run_DoubleQuery(Double_filterR, floatParameter, Float.valueOf(100.0f), Double.valueOf(100.0f), false, 6); + run_DoubleQuery(Double_filterL, FloatParameter, Float.valueOf(100.0f), Double.valueOf(100.0f), true, 6); + run_DoubleQuery(Double_filterR, FloatParameter, Float.valueOf(69.96f), Double.valueOf(69.96), false, 4); + run_DoubleQuery(Double_filterL, BigIntegerParameter, new BigInteger("5000"), Double.valueOf(5000.0), true, 3); + run_DoubleQuery(Double_filterR, BigIntegerParameter, new BigInteger("-20"), Double.valueOf(-20.0), false, 3); + run_DoubleQuery(Double_filterL, BigDecimalParameter, new BigDecimal("100.0"), Double.valueOf(100.0), true, 6); + run_DoubleQuery(Double_filterR, BigDecimalParameter, new BigDecimal("69.96"), Double.valueOf(69.96), false, 4); + alltypes.setDouble(Double.valueOf(-999999999999.0)); + run_DoubleQuery(Double_filterObj, AllTypesParameter, alltypes, Double.valueOf(-999999999999.0), true, 9); + run_DoubleQuery(Double_filterVal, null, null, Double.valueOf(100.0), false, 6); - BigDecimal bd = new BigDecimal("100.0"); - run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, true, 6); - bd = new BigDecimal("-234234.23333"); - run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, false, 2); - bd = new BigDecimal("989899.33304953"); - run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, true, 3); - bd = new BigDecimal("-1123123.22"); - run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, false, 1); - alltypes.setBigDecimal(bd); - run_BigDecimalQuery(BigDecimal_filterObj, AllTypesParameter, alltypes, bd, true, 10); + run_StringQuery(String_filterL, StringParameter, new String("JDO"), new String("JDO"), true, 9); + run_StringQuery(String_filterR, StringParameter, new String("JDBC"), new String("JDBC"), false, 1); + alltypes.setString(new String("abcde")); + run_StringQuery(String_filterObj, AllTypesParameter, alltypes, new String("abcde"), true, 3); + run_StringQuery(String_filterVal1, null, null, new String("Java"), false, 6); + run_StringQuery(String_filterVal2, null, null, new String(""), false, 1); - BigInteger bi = new BigInteger("987034534985043985"); - run_BigIntegerQuery(BigInteger_filterL, BigIntegerParameter, bi, bi, true, 1); - bi = new BigInteger("-999999999999999999"); - run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, false, 1); - bi = new BigInteger("-9999999999999999999"); - run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, false, 0); - bi = new BigInteger("1333330"); - alltypes.setBigInteger(bi); - run_BigIntegerQuery(BigInteger_filterObj, AllTypesParameter, alltypes, bi, false, 8); + BigDecimal bd = new BigDecimal("100.0"); + run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, true, 6); + bd = new BigDecimal("-234234.23333"); + run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, false, 2); + bd = new BigDecimal("989899.33304953"); + run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, true, 3); + bd = new BigDecimal("-1123123.22"); + run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, false, 1); + alltypes.setBigDecimal(bd); + run_BigDecimalQuery(BigDecimal_filterObj, AllTypesParameter, alltypes, bd, true, 10); - GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.UK); - gc.clear(); - gc.set(1999, Calendar.DECEMBER, 31, 9, 0, 0); - Date d = gc.getTime(); - run_DateQuery(Date_filterL, DateParameter, d, d, true, 3); - gc.set(1992, Calendar.NOVEMBER, 22, 9, 0, 0); - d = gc.getTime(); - run_DateQuery(Date_filterR, DateParameter, d, d, false, 6); - gc.set(1959, Calendar.OCTOBER, 9, 9, 0, 0); - d = gc.getTime(); - run_DateQuery(Date_filterR, DateParameter, d, d, false, 3); - gc.set(1995, Calendar.JUNE, 14, 9, 0, 0); - d = gc.getTime(); - alltypes.setDate(d); - run_DateQuery(Date_filterObj, AllTypesParameter, alltypes, d, false, 7); - } + BigInteger bi = new BigInteger("987034534985043985"); + run_BigIntegerQuery(BigInteger_filterL, BigIntegerParameter, bi, bi, true, 1); + bi = new BigInteger("-999999999999999999"); + run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, false, 1); + bi = new BigInteger("-9999999999999999999"); + run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, false, 0); + bi = new BigInteger("1333330"); + alltypes.setBigInteger(bi); + run_BigIntegerQuery(BigInteger_filterObj, AllTypesParameter, alltypes, bi, false, 8); + + GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.UK); + gc.clear(); + gc.set(1999, Calendar.DECEMBER, 31, 9, 0, 0); + Date d = gc.getTime(); + run_DateQuery(Date_filterL, DateParameter, d, d, true, 3); + gc.set(1992, Calendar.NOVEMBER, 22, 9, 0, 0); + d = gc.getTime(); + run_DateQuery(Date_filterR, DateParameter, d, d, false, 6); + gc.set(1959, Calendar.OCTOBER, 9, 9, 0, 0); + d = gc.getTime(); + run_DateQuery(Date_filterR, DateParameter, d, d, false, 3); + gc.set(1995, Calendar.JUNE, 14, 9, 0, 0); + d = gc.getTime(); + alltypes.setDate(d); + run_DateQuery(Date_filterObj, AllTypesParameter, alltypes, d, false, 7); - private void run_byteQuery( - String filter, - String parameter, - Object parameterValue, - byte value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - byte val = obj.getbyte(); - boolean correct_value = valueOnLeft ? value <= val : val <= value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_shortQuery( - String filter, - String parameter, - Object parameterValue, - short value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - short val = obj.getshort(); - boolean correct_value = valueOnLeft ? value <= val : val <= value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_byteQuery(String filter, String parameter, Object parameterValue, + byte value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + byte val = obj.getbyte(); + boolean correct_value = valueOnLeft ? value <= val : val <= value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_charQuery( - String filter, - String parameter, - Object parameterValue, - char value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - char val = obj.getchar(); - boolean correct_value = valueOnLeft ? value <= val : val <= value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_shortQuery(String filter, String parameter, Object parameterValue, + short value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + short val = obj.getshort(); + boolean correct_value = valueOnLeft ? value <= val : val <= value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_intQuery( - String filter, - String parameter, - Object parameterValue, - int value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - int val = obj.getint(); - boolean correct_value = valueOnLeft ? value <= val : val <= value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_charQuery(String filter, String parameter, Object parameterValue, + char value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + char val = obj.getchar(); + boolean correct_value = valueOnLeft ? value <= val : val <= value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_longQuery( - String filter, - String parameter, - Object parameterValue, - long value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - long val = obj.getlong(); - boolean correct_value = valueOnLeft ? value <= val : val <= value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_intQuery(String filter, String parameter, Object parameterValue, + int value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + int val = obj.getint(); + boolean correct_value = valueOnLeft ? value <= val : val <= value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_floatQuery( - String filter, - String parameter, - Object parameterValue, - float value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - float val = obj.getfloat(); - boolean correct_value = valueOnLeft ? value <= val : val <= value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_longQuery(String filter, String parameter, Object parameterValue, + long value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + long val = obj.getlong(); + boolean correct_value = valueOnLeft ? value <= val : val <= value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_doubleQuery( - String filter, - String parameter, - Object parameterValue, - double value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - double val = obj.getdouble(); - boolean correct_value = valueOnLeft ? value <= val : val <= value; - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_floatQuery(String filter, String parameter, Object parameterValue, + float value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + float val = obj.getfloat(); + boolean correct_value = valueOnLeft ? value <= val : val <= value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_ByteQuery( - String filter, - String parameter, - Object parameterValue, - Byte value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Byte val = obj.getByte(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_doubleQuery(String filter, String parameter, Object parameterValue, + double value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + double val = obj.getdouble(); + boolean correct_value = valueOnLeft ? value <= val : val <= value; + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_ShortQuery( - String filter, - String parameter, - Object parameterValue, - Short value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Short val = obj.getShort(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_ByteQuery(String filter, String parameter, Object parameterValue, + Byte value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Byte val = obj.getByte(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_CharacterQuery( - String filter, - String parameter, - Object parameterValue, - Character value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Character val = obj.getCharacter(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_ShortQuery(String filter, String parameter, Object parameterValue, + Short value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Short val = obj.getShort(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_IntegerQuery( - String filter, - String parameter, - Object parameterValue, - Integer value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Integer val = obj.getInteger(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_CharacterQuery(String filter, String parameter, Object parameterValue, + Character value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Character val = obj.getCharacter(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_LongQuery( - String filter, - String parameter, - Object parameterValue, - Long value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Long val = obj.getLong(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_IntegerQuery(String filter, String parameter, Object parameterValue, + Integer value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Integer val = obj.getInteger(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_FloatQuery( - String filter, - String parameter, - Object parameterValue, - Float value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Float val = obj.getFloat(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_LongQuery(String filter, String parameter, Object parameterValue, + Long value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Long val = obj.getLong(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_DoubleQuery( - String filter, - String parameter, - Object parameterValue, - Double value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Double val = obj.getDouble(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_FloatQuery(String filter, String parameter, Object parameterValue, + Float value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Float val = obj.getFloat(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_StringQuery( - String filter, - String parameter, - Object parameterValue, - String value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - String val = obj.getString(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_DoubleQuery(String filter, String parameter, Object parameterValue, + Double value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Double val = obj.getDouble(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_BigDecimalQuery( - String filter, - String parameter, - Object parameterValue, - BigDecimal value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - BigDecimal val = obj.getBigDecimal(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_StringQuery(String filter, String parameter, Object parameterValue, + String value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + String val = obj.getString(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_BigIntegerQuery( - String filter, - String parameter, - Object parameterValue, - BigInteger value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - BigInteger val = obj.getBigInteger(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_BigDecimalQuery(String filter, String parameter, Object parameterValue, + BigDecimal value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + BigDecimal val = obj.getBigDecimal(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_DateQuery( - String filter, - String parameter, - Object parameterValue, - Date value, - boolean valueOnLeft, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Date val = obj.getDate(); - boolean correct_value = - valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); - if (!correct_value) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " - + val - + ", with parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_BigIntegerQuery(String filter, String parameter, Object parameterValue, + BigInteger value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + BigInteger val = obj.getBigInteger(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL LessThanOrEqual test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + + private void run_DateQuery(String filter, String parameter, Object parameterValue, + Date value, boolean valueOnLeft, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Date val = obj.getDate(); + boolean correct_value = valueOnLeft ? (value.compareTo(val) <= 0) : (val.compareTo(value) <= 0); + if( !correct_value ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns incorrect value, retrieved value: " + val + ", with parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL LessThanOrEqual test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - /** */ - protected void localSetUp() { - addTearDownClass(AllTypes.class); - AllTypes.load(getPM()); - } + /** */ + protected void localSetUp() { + addTearDownClass(AllTypes.class); + AllTypes.load(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/LogicalComplement.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/LogicalComplement.java index 22680e914..c4fc825d1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/LogicalComplement.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/LogicalComplement.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,208 +19,235 @@ import java.util.Collection; import java.util.HashSet; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: LogicalComplement Query Operator
    - * Keywords: query
    - * Assertion ID: A14.6.2-32.
    - * Assertion Description: The logical complement operator (!) is supported for - * all types as they are defined in the Java language. This includes the following types: - * - *
      - *
    • Boolean, boolean - *
    + *Title: LogicalComplement Query Operator + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-32. + *
    + *Assertion Description: +The logical complement operator (!) is supported for all types as +they are defined in the Java language. This includes the following types: +
      +
    • Boolean, boolean
    • +
    */ + public class LogicalComplement extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-32 (LogicalComplement) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(LogicalComplement.class); - } - - /** Tests logical complement operator ! used with constants or simple boolean fields */ - public void testPositiveSimpleComplement() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Collection allEvenInstances = - (Collection) pm.newQuery(PrimitiveTypes.class, "booleanNull == false").execute(); - Collection allInstances = (Collection) pm.newQuery(PrimitiveTypes.class, "true").execute(); - Collection empty = new HashSet(); - - // case !false - runSimplePrimitiveTypesQuery("! false", pm, allInstances, ASSERTION_FAILED); - - // case !true - runSimplePrimitiveTypesQuery("! true", pm, empty, ASSERTION_FAILED); - - // case !boolean - runSimplePrimitiveTypesQuery("! booleanNotNull", pm, allEvenInstances, ASSERTION_FAILED); - - // case ! Boolean - runSimplePrimitiveTypesQuery("! booleanNull", pm, allEvenInstances, ASSERTION_FAILED); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-32 (LogicalComplement) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(LogicalComplement.class); } - } - - /** Tests logical complement operator ! negating the result of a relational. */ - public void testPositiveComplementOfRelationalOp() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Collection instancesLess3 = - (Collection) pm.newQuery(PrimitiveTypes.class, "id < 3").execute(); - Collection instancesNot3 = - (Collection) pm.newQuery(PrimitiveTypes.class, "id != 3").execute(); - Collection instances3 = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 3").execute(); - - // case !(field >= value) - runSimplePrimitiveTypesQuery("! (id >= 3)", pm, instancesLess3, ASSERTION_FAILED); - - // case !(field == value) - runSimplePrimitiveTypesQuery("! (id == 3)", pm, instancesNot3, ASSERTION_FAILED); - - // case !(field != value) - runSimplePrimitiveTypesQuery("! (id != 3)", pm, instances3, ASSERTION_FAILED); - - // case !!(field == value) - runSimplePrimitiveTypesQuery("!! (id == 3)", pm, instances3, ASSERTION_FAILED); - - // case !!(field != value) - runSimplePrimitiveTypesQuery("!! (id != 3)", pm, instancesNot3, ASSERTION_FAILED); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** + * Tests logical complement operator ! used with constants or simple boolean fields + */ + public void testPositiveSimpleComplement() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection allEvenInstances = (Collection)pm.newQuery( + PrimitiveTypes.class, "booleanNull == false").execute(); + Collection allInstances = (Collection)pm.newQuery( + PrimitiveTypes.class, "true").execute(); + Collection empty = new HashSet(); + + // case !false + runSimplePrimitiveTypesQuery( + "! false", pm, allInstances, ASSERTION_FAILED); + + // case !true + runSimplePrimitiveTypesQuery( + "! true", pm, empty, ASSERTION_FAILED); + + // case !boolean + runSimplePrimitiveTypesQuery( + "! booleanNotNull", pm, allEvenInstances, ASSERTION_FAILED); + + // case ! Boolean + runSimplePrimitiveTypesQuery( + "! booleanNull", pm, allEvenInstances, ASSERTION_FAILED); + + tx.commit(); + tx = null; + } finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** Tests logical complement operator ! negating field comparison with a non null value. */ - public void testPositiveNullFieldComparison() { - PersistenceManager pm = getPM(); - createAndStoreNullInstance(pm); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Collection instances3 = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 3").execute(); - Collection instancesNot0Not3 = - (Collection) pm.newQuery(PrimitiveTypes.class, "id != 3 && id != 0").execute(); - - // case (nullableField == value) - runSimplePrimitiveTypesQuery("intNull == 3", pm, instances3, ASSERTION_FAILED); - - // case (nullableField != value) - runSimplePrimitiveTypesQuery("intNull != 3", pm, instancesNot0Not3, ASSERTION_FAILED); - - // case ! (nullableField == value) - runSimplePrimitiveTypesQuery("!(intNull == 3)", pm, instancesNot0Not3, ASSERTION_FAILED); - - // case ! (nullableField != value) - runSimplePrimitiveTypesQuery("!(intNull != 3)", pm, instances3, ASSERTION_FAILED); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * Tests logical complement operator ! negating the result of a relational. + */ + public void testPositiveComplementOfRelationalOp() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection instancesLess3 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id < 3").execute(); + Collection instancesNot3 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id != 3").execute(); + Collection instances3 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 3").execute(); + + // case !(field >= value) + runSimplePrimitiveTypesQuery("! (id >= 3)", + pm, instancesLess3, ASSERTION_FAILED); + + // case !(field == value) + runSimplePrimitiveTypesQuery( + "! (id == 3)", pm, instancesNot3, ASSERTION_FAILED); + + // case !(field != value) + runSimplePrimitiveTypesQuery( + "! (id != 3)", pm, instances3, ASSERTION_FAILED); + + // case !!(field == value) + runSimplePrimitiveTypesQuery( + "!! (id == 3)", pm, instances3, ASSERTION_FAILED); + + // case !!(field != value) + runSimplePrimitiveTypesQuery( + "!! (id != 3)", pm, instancesNot3, ASSERTION_FAILED); + + tx.commit(); + tx = null; + } finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** Tests logical complement operator ! negating a null check. */ - public void testPositiveNullCheck() { - PersistenceManager pm = getPM(); - createAndStoreNullInstance(pm); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Collection instancesGreater0 = - (Collection) pm.newQuery(PrimitiveTypes.class, "id > 0").execute(); - Collection instances0 = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 0").execute(); - - // case !(field == null) - runSimplePrimitiveTypesQuery("! (intNull == null)", pm, instancesGreater0, ASSERTION_FAILED); - - // case !(field != null) - runSimplePrimitiveTypesQuery("! (intNull != null)", pm, instances0, ASSERTION_FAILED); - - // case !!(field == null) - runSimplePrimitiveTypesQuery("!! (intNull == null)", pm, instances0, ASSERTION_FAILED); + /** + * Tests logical complement operator ! negating field comparison with a non null value. + */ + public void testPositiveNullFieldComparison() { + PersistenceManager pm = getPM(); + createAndStoreNullInstance(pm); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection instances3 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 3").execute(); + Collection instancesNot0Not3 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id != 3 && id != 0").execute(); + + + // case (nullableField == value) + runSimplePrimitiveTypesQuery( + "intNull == 3", pm, instances3, ASSERTION_FAILED); + + // case (nullableField != value) + runSimplePrimitiveTypesQuery( + "intNull != 3", pm, instancesNot0Not3, ASSERTION_FAILED); + + // case ! (nullableField == value) + runSimplePrimitiveTypesQuery( + "!(intNull == 3)", pm, instancesNot0Not3, ASSERTION_FAILED); + + // case ! (nullableField != value) + runSimplePrimitiveTypesQuery( + "!(intNull != 3)", pm, instances3, ASSERTION_FAILED); + + tx.commit(); + tx = null; + } finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } - // case !!(field != null) - runSimplePrimitiveTypesQuery("!! (intNull != null)", pm, instancesGreater0, ASSERTION_FAILED); + /** + * Tests logical complement operator ! negating a null check. + */ + public void testPositiveNullCheck() { + PersistenceManager pm = getPM(); + createAndStoreNullInstance(pm); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Collection instancesGreater0 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id > 0").execute(); + Collection instances0 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 0").execute(); + + // case !(field == null) + runSimplePrimitiveTypesQuery( + "! (intNull == null)", pm, instancesGreater0, ASSERTION_FAILED); + + // case !(field != null) + runSimplePrimitiveTypesQuery( + "! (intNull != null)", pm, instances0, ASSERTION_FAILED); + + // case !!(field == null) + runSimplePrimitiveTypesQuery( + "!! (intNull == null)", pm, instances0, ASSERTION_FAILED); + + // case !!(field != null) + runSimplePrimitiveTypesQuery( + "!! (intNull != null)", pm, instancesGreater0, ASSERTION_FAILED); + + tx.commit(); + tx = null; + } finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PrimitiveTypes.class); + loadAndPersistPrimitiveTypes(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PrimitiveTypes.class); - loadAndPersistPrimitiveTypes(getPM()); - } - - private void createAndStoreNullInstance(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - PrimitiveTypes primitiveObject = - new PrimitiveTypes( - (long) 0, - false, - null, - (byte) 0, - null, - (short) 0, - null, - (int) 0, - null, - (long) 0, - null, - (float) 0, - null, - (double) 0, - null, - '0', - null, - null, - null, - null, - null, - null); - pm.makePersistent(primitiveObject); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + private void createAndStoreNullInstance(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + PrimitiveTypes primitiveObject = new PrimitiveTypes( + (long)0, false, null, (byte)0, null, + (short)0, null, (int) 0, null, + (long)0, null, (float)0, null, + (double)0, null, '0', null, + null, null, + null, + null, + null); + pm.makePersistent(primitiveObject); + tx.commit(); + tx = null; + } finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/Modulo.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/Modulo.java index 528683555..d0532277d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/Modulo.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/Modulo.java @@ -5,22 +5,25 @@ * 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 + * + * 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.jdo.tck.query.jdoql.operators; import java.util.Collection; + import javax.jdo.JDOQLTypedQuery; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.pc.company.QPerson; @@ -30,89 +33,103 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Modulo operator.
    - * Keywords: query
    - * Assertion ID: A14.6.2-40.
    - * Assertion Description: modulo operator + *Title: Modulo operator. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-40. + *
    + *Assertion Description: + * modulo operator */ public class Modulo extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.2-40 (Modulo) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Modulo.class); - } - - public void testPositive() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp2", "emp4"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.personid.mod(2).eq(0L)); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-40 (Modulo) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Modulo.class); + } - // Import Department twice - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "personid % 2 == 0", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + public void testPositive() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp2", "emp4"}); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - // DataNucleus: UnsupportedOperationException: Dont currently support operator % in JDOQL - // conversion - // executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.personid.mod(2).eq(0L)); - /** */ - public void testPostiveUsingPrimitiveTypes() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); + // Import Department twice + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "personid % 2 == 0", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - Collection instance4 = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 10").execute(); + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + // DataNucleus: UnsupportedOperationException: Dont currently support operator % in JDOQL conversion + //executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } - runSimplePrimitiveTypesQuery("id % 10 == 0", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("byteNotNull % 10 == 0", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("shortNotNull % 10 == 0", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("intNotNull % 10 == 0", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("longNotNull % 10 == 0", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("byteNull % 10 == 0", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("shortNull % 10 == 0", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("intNull % 10 == 0", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("longNull % 10 == 0", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("bigInteger % 10 == 0", pm, instance4, ASSERTION_FAILED); + /** */ + public void testPostiveUsingPrimitiveTypes() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + + Collection instance4 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 10").execute(); + + runSimplePrimitiveTypesQuery("id % 10 == 0", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("byteNotNull % 10 == 0", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("shortNotNull % 10 == 0", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("intNotNull % 10 == 0", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("longNotNull % 10 == 0", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("byteNull % 10 == 0", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("shortNull % 10 == 0", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("intNull % 10 == 0", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("longNull % 10 == 0", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("bigInteger % 10 == 0", + pm, instance4, ASSERTION_FAILED); - tx.commit(); - } + tx.commit(); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - addTearDownClass(PrimitiveTypes.class); - PersistenceManager pm = getPM(); - loadAndPersistCompanyModel(pm); - loadAndPersistPrimitiveTypes(pm); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + addTearDownClass(PrimitiveTypes.class); + PersistenceManager pm = getPM(); + loadAndPersistCompanyModel(pm); + loadAndPersistPrimitiveTypes(pm); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/Multiplication.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/Multiplication.java index 728be2cfc..88d2417a2 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/Multiplication.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/Multiplication.java @@ -5,91 +5,115 @@ * 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 + * + * 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.jdo.tck.query.jdoql.operators; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Multiplication Query Operator
    - * Keywords: query
    - * Assertion ID: A14.6.2-30.
    - * Assertion Description: The multiplication operator (*) is supported for all - * types as they are defined in the Java language. This includes the following types: - * - *
      - *
    • byte, short, int, long, char, Byte, Short Integer, Long, Character - *
    • float, double, Float, Double - *
    • BigDecimal, BigInteger - *
    - * - * The operation on object-valued fields of wrapper types (Boolean, Byte, - * Short, Integer, Long, Float, and Double), and numeric types (BigDecimal - * and BigInteger) use the wrapped values as operands. + *Title: Multiplication Query Operator + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-30. + *
    + *Assertion Description: +The multiplication operator (*) is supported for all types as +they are defined in the Java language. This includes the following types: +
      +
    • byte, short, int, long, char, Byte, Short Integer, Long, Character
    • +
    • float, double, Float, Double
    • +
    • BigDecimal, BigInteger
    • +
    +The operation on object-valued fields of wrapper types (Boolean, Byte, +Short, Integer, Long, Float, and Double), and numeric types +(BigDecimal and BigInteger) +use the wrapped values as operands. */ -public class Multiplication extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.2-30 (Multiplication) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Multiplication.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - if (debug) logger.debug("\nExecuting test Multiplication() ..."); - - Transaction tx = pm.currentTransaction(); - tx.begin(); +public class Multiplication extends QueryTest { - Collection instance4 = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 4").execute(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-30 (Multiplication) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Multiplication.class); + } + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + if (debug) logger.debug("\nExecuting test Multiplication() ..."); - runSimplePrimitiveTypesQuery("id * 2 == 8", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("byteNotNull * 2 == 8", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("shortNotNull * 2 == 8", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("intNotNull * 2 == 8", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("longNotNull * 2 == 8", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("floatNotNull * 2 == 8", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("doubleNotNull * 2 == 8", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("byteNull * 2 == 8", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("shortNull * 2 == 8", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("intNull * 2 == 8", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("longNull * 2 == 8", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("floatNull * 2 == 8", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("doubleNull * 2 == 8", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("bigDecimal * 2 == 8", pm, instance4, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("bigInteger * 2 == 8", pm, instance4, ASSERTION_FAILED); + Transaction tx = pm.currentTransaction(); + tx.begin(); + + Collection instance4 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 4").execute(); + + runSimplePrimitiveTypesQuery("id * 2 == 8", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("byteNotNull * 2 == 8", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("shortNotNull * 2 == 8", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("intNotNull * 2 == 8", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("longNotNull * 2 == 8", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("floatNotNull * 2 == 8", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("doubleNotNull * 2 == 8", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("byteNull * 2 == 8", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("shortNull * 2 == 8", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("intNull * 2 == 8", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("longNull * 2 == 8", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("floatNull * 2 == 8", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("doubleNull * 2 == 8", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("bigDecimal * 2 == 8", + pm, instance4, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("bigInteger * 2 == 8", + pm, instance4, ASSERTION_FAILED); - tx.commit(); - } + tx.commit(); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PrimitiveTypes.class); - loadAndPersistPrimitiveTypes(getPM()); - } -} + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PrimitiveTypes.class); + loadAndPersistPrimitiveTypes(getPM()); + } +} \ No newline at end of file diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/NotEquals.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/NotEquals.java index e06b968a5..150d1ff6f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/NotEquals.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/NotEquals.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -25,1939 +25,1259 @@ import java.util.Iterator; import java.util.Locale; import java.util.TimeZone; + import org.apache.jdo.tck.pc.fieldtypes.AllTypes; import org.apache.jdo.tck.util.BatchTestRunner; -/** - * Title: Not Equals Query Operator
    - * Keywords: query
    - * Assertion ID: A14.6.2-15.
    - * Assertion Description: The not equal operator (!=) is supported for the - * following types: - * - *
      - *
    • byte, short, int, long, char, Byte, Short Integer, Long, Character - *
    • float, double, Float, Double - *
    • BigDecimal, BigInteger - *
    • Boolean, boolean - *
    • any class instance or array - *
    • Date, String - *
    - * - * The operation on object-valued fields of wrapper types (Boolean, Byte, - * Short, Integer, Long, Float, and Double), and numeric types (BigDecimal and - * BigInteger) use the wrapped values as operands. Inequality comparison of - * object-valued fields of PersistenceCapable types use the JDO Identity comparison of - * the references. Thus, two objects will compare not equal if they have different JDO Identity. - * Equality comparison of object-valued fields of non-PersistenceCapable types uses the - * equals method of the field type. - */ -public class NotEquals extends ComparisonTests { - private static String boolean_filterL = "value != fld_boolean"; - private static String boolean_filterR = "fld_boolean != value"; - private static String boolean_filterT = "fld_boolean != true"; - private static String boolean_filterF = "false != fld_boolean"; - private static String boolean_filterObj = "value.fld_boolean != fld_boolean"; - - private static String byte_filterL = "value != fld_byte"; - private static String byte_filterR = "fld_byte != value"; - private static String byte_filterObj = "value.fld_byte != fld_byte"; - private static String byte_filterVal = "fld_byte != 100"; - - private static String char_filterL = "value != fld_char"; - private static String char_filterR = "fld_char != value"; - private static String char_filterObj = "value.fld_char != fld_char"; - private static String char_filterVal = "'M' != fld_char"; - - private static String double_filterL = "value != fld_double"; - private static String double_filterR = "fld_double != value"; - private static String double_filterObj = "value.fld_double != fld_double"; - private static String double_filterVal = "fld_double != 100.0"; - - private static String float_filterL = "value != fld_float"; - private static String float_filterR = "fld_float != value"; - private static String float_filterObj = "fld_float != value.fld_float"; - private static String float_filterVal = "fld_float != 100.0"; - - private static String int_filterL = "value != fld_int"; - private static String int_filterR = "fld_int != value"; - private static String int_filterObj = "value.fld_int != fld_int"; - private static String int_filterVal = "fld_int != 1000"; - - private static String long_filterL = "value != fld_long"; - private static String long_filterR = "fld_long != value"; - private static String long_filterObj = "fld_long != value.fld_long"; - private static String long_filterVal = "fld_long != 1000000"; - - private static String short_filterL = "value != fld_short"; - private static String short_filterR = "fld_short != value"; - private static String short_filterObj = "value.fld_short != fld_short"; - private static String short_filterVal = "1000 != fld_short"; - - private static String Boolean_filterL = "value != fld_Boolean"; - private static String Boolean_filterR = "fld_Boolean != value"; - private static String Boolean_filterT = "fld_Boolean != true"; - private static String Boolean_filterF = "false != fld_Boolean"; - private static String Boolean_filterObj = "value.fld_Boolean != fld_Boolean"; - private static String Boolean_filterVal = "fld_Boolean != false"; - - private static String Byte_filterL = "value != fld_Byte"; - private static String Byte_filterR = "fld_Byte != value"; - private static String Byte_filterObj = "fld_Byte != value.fld_Byte"; - private static String Byte_filterVal = "100 != fld_Byte"; - - private static String Character_filterL = "value != fld_Character"; - private static String Character_filterR = "fld_Character != value"; - private static String Character_filterObj = "value.fld_Character != fld_Character"; - private static String Character_filterVal = "fld_Character != 'z'"; - - private static String Double_filterL = "value != fld_Double"; - private static String Double_filterR = "fld_Double != value"; - private static String Double_filterObj = "value.fld_Double != fld_Double"; - private static String Double_filterVal = "fld_Double != 100.0"; - - private static String Float_filterL = "value != fld_Float"; - private static String Float_filterR = "fld_Float != value"; - private static String Float_filterObj = "fld_Float != value.fld_Float"; - private static String Float_filterVal = "100.0f != fld_Float"; - - private static String Integer_filterL = "value != fld_Integer"; - private static String Integer_filterR = "fld_Integer != value"; - private static String Integer_filterObj = "fld_Integer != value.fld_Integer"; - private static String Integer_filterVal = "fld_Integer != 100"; - - private static String Long_filterL = "value != fld_Long"; - private static String Long_filterR = "fld_Long != value"; - private static String Long_filterObj = "value.fld_Long != fld_Long"; - private static String Long_filterVal = "-1000 != fld_Long"; - - private static String Short_filterL = "value != fld_Short"; - private static String Short_filterR = "fld_Short != value"; - private static String Short_filterObj = "fld_Short != value.fld_Short"; - private static String Short_filterVal = "-1000 != fld_Short"; - - private static String String_filterL = "value != fld_String"; - private static String String_filterR = "fld_String != value"; - private static String String_filterObj = "value.fld_String != fld_String"; - private static String String_filterVal1 = "fld_String != \"Java\""; - private static String String_filterVal2 = "fld_String != \"\""; - - private static String Locale_filterL = "value != fld_Locale"; - private static String Locale_filterR = "fld_Locale != value"; - private static String Locale_filterObj = "value.fld_Locale != fld_Locale"; - - private static String Date_filterL = "value != fld_Date"; - private static String Date_filterR = "fld_Date != value"; - private static String Date_filterObj = "fld_Date != value.fld_Date"; - - private static String BigDecimal_filterL = "value != fld_BigDecimal"; - private static String BigDecimal_filterR = "fld_BigDecimal != value"; - private static String BigDecimal_filterObj = "value.fld_BigDecimal != fld_BigDecimal"; - - private static String BigInteger_filterL = "value != fld_BigInteger"; - private static String BigInteger_filterR = "fld_BigInteger != value"; - private static String BigInteger_filterObj = "fld_BigInteger != value.fld_BigInteger"; - - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.2-15 (NotEquals) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NotEquals.class); - } - - /** */ - public void test() { - pm = getPM(); - tx = pm.currentTransaction(); - runQueries(); - } - - /** */ - private void runQueries() { - Boolean trueBoolean = Boolean.TRUE; - Boolean falseBoolean = Boolean.FALSE; - run_booleanQuery(boolean_filterL, booleanParameter, trueBoolean, true, 6); - run_booleanQuery(boolean_filterL, booleanParameter, falseBoolean, false, 4); - run_booleanQuery(boolean_filterR, booleanParameter, trueBoolean, true, 6); - run_booleanQuery(boolean_filterR, booleanParameter, falseBoolean, false, 4); - run_booleanQuery(boolean_filterL, BooleanParameter, trueBoolean, true, 6); - run_booleanQuery(boolean_filterL, BooleanParameter, falseBoolean, false, 4); - run_booleanQuery(boolean_filterR, BooleanParameter, trueBoolean, true, 6); - run_booleanQuery(boolean_filterR, BooleanParameter, falseBoolean, false, 4); - run_booleanQuery(boolean_filterT, null, null, true, 6); - run_booleanQuery(boolean_filterF, null, null, false, 4); - AllTypes alltypes = new AllTypes(); - alltypes.setboolean(true); - run_booleanQuery(boolean_filterObj, AllTypesParameter, alltypes, true, 6); - alltypes.setboolean(false); - run_booleanQuery(boolean_filterObj, AllTypesParameter, alltypes, false, 4); - - run_byteQuery(byte_filterL, byteParameter, Byte.valueOf((byte) 50), (byte) 50, 8); - run_byteQuery(byte_filterR, byteParameter, Byte.valueOf(Byte.MIN_VALUE), Byte.MIN_VALUE, 9); - run_byteQuery(byte_filterL, ByteParameter, Byte.valueOf((byte) 20), (byte) 20, 10); - run_byteQuery(byte_filterR, ByteParameter, Byte.valueOf(Byte.MAX_VALUE), Byte.MAX_VALUE, 9); - run_byteQuery(byte_filterL, shortParameter, Short.valueOf((short) 50), (byte) 50, 8); - run_byteQuery(byte_filterR, shortParameter, Short.valueOf((short) 50), (byte) 50, 8); - run_byteQuery(byte_filterL, ShortParameter, Short.valueOf((short) -100), (byte) -100, 9); - run_byteQuery(byte_filterR, ShortParameter, Short.valueOf((short) -100), (byte) -100, 9); - run_byteQuery(byte_filterL, charParameter, Character.valueOf((char) 50), (byte) 50, 8); - run_byteQuery(byte_filterR, charParameter, Character.valueOf((char) 50), (byte) 50, 8); - run_byteQuery(byte_filterL, CharacterParameter, Character.valueOf((char) 50), (byte) 50, 8); - run_byteQuery(byte_filterR, CharacterParameter, Character.valueOf((char) 100), (byte) 100, 9); - run_byteQuery(byte_filterL, intParameter, Integer.valueOf(50), (byte) 50, 8); - run_byteQuery(byte_filterR, intParameter, Integer.valueOf(50), (byte) 50, 8); - run_byteQuery(byte_filterL, IntegerParameter, Integer.valueOf(-100), (byte) -100, 9); - run_byteQuery(byte_filterR, IntegerParameter, Integer.valueOf(-100), (byte) -100, 9); - run_byteQuery(byte_filterL, longParameter, Long.valueOf(50), (byte) 50, 8); - run_byteQuery(byte_filterR, longParameter, Long.valueOf(50), (byte) 50, 8); - run_byteQuery(byte_filterL, LongParameter, Long.valueOf(-100), (byte) -100, 9); - run_byteQuery(byte_filterR, LongParameter, Long.valueOf(-100), (byte) -100, 9); - run_byteQuery(byte_filterL, floatParameter, Float.valueOf((float) 50), (byte) 50, 8); - run_byteQuery(byte_filterR, floatParameter, Float.valueOf((float) 50), (byte) 50, 8); - run_byteQuery(byte_filterL, FloatParameter, Float.valueOf((float) -100), (byte) -100, 9); - run_byteQuery(byte_filterR, FloatParameter, Float.valueOf((float) -100), (byte) -100, 9); - run_byteQuery(byte_filterL, doubleParameter, Double.valueOf(50), (byte) 50, 8); - run_byteQuery(byte_filterR, doubleParameter, Double.valueOf(50), (byte) 50, 8); - run_byteQuery(byte_filterL, DoubleParameter, Double.valueOf(-100), (byte) -100, 9); - run_byteQuery(byte_filterR, DoubleParameter, Double.valueOf(-100), (byte) -100, 9); - run_byteQuery(byte_filterL, BigIntegerParameter, new BigInteger("50"), (byte) 50, 8); - run_byteQuery(byte_filterR, BigIntegerParameter, new BigInteger("-100"), (byte) -100, 9); - run_byteQuery(byte_filterL, BigDecimalParameter, new BigDecimal("100.0"), (byte) 100, 9); - run_byteQuery(byte_filterR, BigDecimalParameter, new BigDecimal("10.0"), (byte) 10, 9); - alltypes.setbyte((byte) 50); - run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte) 50, 8); - alltypes.setbyte((byte) 45); - run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte) 45, 10); - run_byteQuery(byte_filterVal, null, null, (byte) 100, 9); - - run_shortQuery(short_filterL, shortParameter, Short.valueOf((short) 100), (short) 100, 8); - run_shortQuery(short_filterR, shortParameter, Short.valueOf((short) 100), (short) 100, 8); - run_shortQuery( - short_filterL, ShortParameter, Short.valueOf(Short.MIN_VALUE), Short.MIN_VALUE, 9); - run_shortQuery(short_filterR, ShortParameter, Short.valueOf((short) 253), (short) 253, 10); - run_shortQuery(short_filterR, shortParameter, Short.valueOf((short) 1000), (short) 1000, 9); - run_shortQuery(short_filterL, byteParameter, Byte.valueOf((byte) 75), (short) 75, 10); - run_shortQuery(short_filterR, byteParameter, Byte.valueOf((byte) 75), (short) 75, 10); - run_shortQuery(short_filterL, ByteParameter, Byte.valueOf((byte) 100), (short) 100, 8); - run_shortQuery(short_filterR, ByteParameter, Byte.valueOf((byte) 100), (short) 100, 8); - run_shortQuery(short_filterL, charParameter, Character.valueOf((char) 75), (short) 75, 10); - run_shortQuery(short_filterR, charParameter, Character.valueOf((char) 75), (short) 75, 10); - run_shortQuery( - short_filterL, CharacterParameter, Character.valueOf((char) 100), (short) 100, 8); - run_shortQuery( - short_filterR, CharacterParameter, Character.valueOf((char) 100), (short) 100, 8); - run_shortQuery(short_filterL, intParameter, Integer.valueOf(-10000), (short) -10000, 9); - run_shortQuery(short_filterR, intParameter, Integer.valueOf(-10000), (short) -10000, 9); - run_shortQuery(short_filterL, IntegerParameter, Integer.valueOf(10000), (short) 10000, 9); - run_shortQuery(short_filterR, IntegerParameter, Integer.valueOf(10000), (short) 10000, 9); - run_shortQuery(short_filterL, longParameter, Long.valueOf(10000), (short) 10000, 9); - run_shortQuery(short_filterR, longParameter, Long.valueOf(10000), (short) 10000, 9); - run_shortQuery(short_filterL, LongParameter, Long.valueOf(100), (short) 100, 8); - run_shortQuery(short_filterR, LongParameter, Long.valueOf(100), (short) 100, 8); - run_shortQuery(short_filterL, floatParameter, Float.valueOf((float) 23000), (short) 23000, 10); - run_shortQuery(short_filterR, floatParameter, Float.valueOf((float) 23000), (short) 23000, 10); - run_shortQuery(short_filterL, FloatParameter, Float.valueOf((float) 100), (short) 100, 8); - run_shortQuery(short_filterR, FloatParameter, Float.valueOf((float) 100), (short) 100, 8); - run_shortQuery(short_filterL, doubleParameter, Double.valueOf(-10000), (short) -10000, 9); - run_shortQuery(short_filterR, doubleParameter, Double.valueOf(-10000), (short) -10000, 9); - run_shortQuery(short_filterL, DoubleParameter, Double.valueOf(23), (short) 23, 10); - run_shortQuery(short_filterR, DoubleParameter, Double.valueOf(23), (short) 23, 10); - run_shortQuery(short_filterL, BigIntegerParameter, new BigInteger("999"), (short) 999, 10); - run_shortQuery(short_filterR, BigIntegerParameter, new BigInteger("-1000"), (short) -1000, 9); - run_shortQuery(short_filterL, BigDecimalParameter, new BigDecimal("100.0"), (short) 100, 8); - run_shortQuery(short_filterR, BigDecimalParameter, new BigDecimal("0.0"), (short) 0, 9); - alltypes.setshort((short) 100); - run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short) 100, 8); - alltypes.setshort((short) 23); - run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short) 23, 10); - run_shortQuery(short_filterVal, null, null, (short) 1000, 9); - - run_charQuery( - char_filterL, - charParameter, - Character.valueOf(Character.MIN_VALUE), - Character.MIN_VALUE, - 9); - run_charQuery( - char_filterR, - charParameter, - Character.valueOf(Character.MAX_VALUE), - Character.MAX_VALUE, - 9); - run_charQuery(char_filterL, charParameter, Character.valueOf('C'), 'C', 10); - run_charQuery(char_filterR, charParameter, Character.valueOf('z'), 'z', 8); - run_charQuery(char_filterL, CharacterParameter, Character.valueOf(' '), ' ', 9); - run_charQuery(char_filterR, CharacterParameter, Character.valueOf('f'), 'f', 10); - run_charQuery( - char_filterL, - byteParameter, - Byte.valueOf((byte) Character.MIN_VALUE), - (char) Character.MIN_VALUE, - 9); - run_charQuery(char_filterR, byteParameter, Byte.valueOf((byte) 122), 'z', 8); - run_charQuery(char_filterL, ByteParameter, Byte.valueOf((byte) 'a'), 'a', 10); - run_charQuery(char_filterR, ByteParameter, Byte.valueOf((byte) 'a'), 'a', 10); - run_charQuery(char_filterL, shortParameter, Short.valueOf((short) 'M'), 'M', 8); - run_charQuery(char_filterR, shortParameter, Short.valueOf((short) 'M'), 'M', 8); - run_charQuery(char_filterL, ShortParameter, Short.valueOf((short) 'A'), 'A', 9); - run_charQuery(char_filterR, ShortParameter, Short.valueOf((short) 'A'), 'A', 9); - run_charQuery(char_filterL, intParameter, Integer.valueOf('z'), 'z', 8); - run_charQuery(char_filterR, intParameter, Integer.valueOf('z'), 'z', 8); - run_charQuery(char_filterL, IntegerParameter, Integer.valueOf('B'), 'B', 9); - run_charQuery(char_filterR, IntegerParameter, Integer.valueOf('B'), 'B', 9); - run_charQuery(char_filterL, longParameter, Long.valueOf('z'), 'z', 8); - run_charQuery(char_filterR, longParameter, Long.valueOf('z'), 'z', 8); - run_charQuery(char_filterL, LongParameter, Long.valueOf('B'), 'B', 9); - run_charQuery(char_filterR, LongParameter, Long.valueOf('B'), 'B', 9); - run_charQuery(char_filterL, floatParameter, Float.valueOf((float) 123.222), 'x', 10); - run_charQuery(char_filterR, floatParameter, Float.valueOf((float) 123.222), 'x', 10); - run_charQuery(char_filterL, FloatParameter, Float.valueOf((float) 'z'), 'z', 8); - run_charQuery(char_filterR, FloatParameter, Float.valueOf((float) 'z'), 'z', 8); - run_charQuery(char_filterL, doubleParameter, Double.valueOf('B'), 'B', 9); - run_charQuery(char_filterR, doubleParameter, Double.valueOf('B'), 'B', 9); - run_charQuery(char_filterL, DoubleParameter, Double.valueOf('A'), 'A', 9); - run_charQuery(char_filterR, DoubleParameter, Double.valueOf('A'), 'A', 9); - run_charQuery(char_filterL, BigIntegerParameter, new BigInteger("65"), 'A', 9); // 'A' == 65 - run_charQuery(char_filterR, BigIntegerParameter, new BigInteger("122"), 'z', 8); // 'z' == 122 - run_charQuery(char_filterL, BigDecimalParameter, new BigDecimal("65.0"), 'A', 9); - run_charQuery(char_filterR, BigDecimalParameter, new BigDecimal("77.0"), 'M', 8); // 'M' == 77 - alltypes.setchar('A'); - run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'A', 9); - alltypes.setchar('b'); - run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'b', 10); - run_charQuery(char_filterVal, null, null, 'M', 8); - - run_intQuery( - int_filterL, - intParameter, - Integer.valueOf(AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - 9); - run_intQuery( - int_filterR, - intParameter, - Integer.valueOf(AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - 9); - run_intQuery(int_filterR, intParameter, Integer.valueOf(23), 23, 10); - run_intQuery(int_filterL, IntegerParameter, Integer.valueOf(1000000), 1000000, 9); - run_intQuery(int_filterR, IntegerParameter, Integer.valueOf(1000), 1000, 9); - run_intQuery(int_filterL, byteParameter, Byte.valueOf((byte) 100), 100, 8); - run_intQuery(int_filterR, byteParameter, Byte.valueOf((byte) 0), 0, 9); - run_intQuery(int_filterL, ByteParameter, Byte.valueOf((byte) 100), 100, 8); - run_intQuery(int_filterR, ByteParameter, Byte.valueOf((byte) 0), 0, 9); - run_intQuery(int_filterL, shortParameter, Short.valueOf((short) 10000), 10000, 9); - run_intQuery(int_filterR, shortParameter, Short.valueOf((short) -1000), -1000, 9); - run_intQuery(int_filterL, ShortParameter, Short.valueOf((short) -1000), -1000, 9); - run_intQuery(int_filterR, ShortParameter, Short.valueOf((short) 10000), 10000, 9); - run_intQuery(int_filterL, charParameter, Character.valueOf((char) 10000), 10000, 9); - run_intQuery(int_filterR, charParameter, Character.valueOf((char) 0), 0, 9); - run_intQuery(int_filterL, CharacterParameter, Character.valueOf((char) 100), 100, 8); - run_intQuery(int_filterR, CharacterParameter, Character.valueOf((char) 10000), 10000, 9); - run_intQuery( - int_filterL, - longParameter, - Long.valueOf(AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - 9); - run_intQuery( - int_filterR, - longParameter, - Long.valueOf(AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - 9); - run_intQuery(int_filterL, LongParameter, Long.valueOf(10000), 10000, 9); - run_intQuery(int_filterR, LongParameter, Long.valueOf(43), 43, 10); - run_intQuery( - int_filterL, - floatParameter, - Float.valueOf((float) AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - 9); - run_intQuery( - int_filterR, - floatParameter, - Float.valueOf((float) AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - 9); - run_intQuery(int_filterL, FloatParameter, Float.valueOf((float) 10000), 10000, 9); - run_intQuery(int_filterR, FloatParameter, Float.valueOf((float) 43), 43, 10); - run_intQuery( - int_filterL, - doubleParameter, - Double.valueOf(AllTypes.veryLargePositiveInt), - AllTypes.veryLargePositiveInt, - 9); - run_intQuery( - int_filterR, - doubleParameter, - Double.valueOf(AllTypes.veryLargeNegativeInt), - AllTypes.veryLargeNegativeInt, - 9); - run_intQuery(int_filterL, DoubleParameter, Double.valueOf(10000), 10000, 9); - run_intQuery(int_filterR, DoubleParameter, Double.valueOf(43), 43, 10); - run_intQuery(int_filterL, BigIntegerParameter, new BigInteger("1000000"), 1000000, 9); - run_intQuery(int_filterR, BigIntegerParameter, new BigInteger("-1000000"), -1000000, 9); - run_intQuery(int_filterL, BigDecimalParameter, new BigDecimal("1000000.0"), 1000000, 9); - run_intQuery(int_filterR, BigDecimalParameter, new BigDecimal("-1000000.0"), -1000000, 9); - alltypes.setint(100); - run_intQuery(int_filterObj, AllTypesParameter, alltypes, 100, 8); - run_intQuery(int_filterVal, null, null, 1000, 9); - - run_longQuery(long_filterL, longParameter, Long.valueOf(Long.MIN_VALUE), Long.MIN_VALUE, 9); - run_longQuery(long_filterR, longParameter, Long.valueOf(Long.MAX_VALUE), Long.MAX_VALUE, 9); - run_longQuery(long_filterL, LongParameter, Long.valueOf(100), 100, 8); - run_longQuery(long_filterR, LongParameter, Long.valueOf(23), 23, 10); - run_longQuery(long_filterL, byteParameter, Byte.valueOf((byte) 100), 100, 8); - run_longQuery(long_filterR, byteParameter, Byte.valueOf((byte) 0), 0, 9); - run_longQuery(long_filterL, ByteParameter, Byte.valueOf((byte) 100), 100, 8); - run_longQuery(long_filterR, ByteParameter, Byte.valueOf((byte) 0), 0, 9); - run_longQuery(long_filterL, shortParameter, Short.valueOf((short) -1000), -1000, 8); - run_longQuery(long_filterR, shortParameter, Short.valueOf((short) 1000), 1000, 9); - run_longQuery(long_filterL, ShortParameter, Short.valueOf((short) 100), 100, 8); - run_longQuery(long_filterR, ShortParameter, Short.valueOf((short) 32), 32, 10); - run_longQuery(long_filterL, charParameter, Character.valueOf((char) 0), 0, 9); - run_longQuery(long_filterR, charParameter, Character.valueOf((char) 100), 100, 8); - run_longQuery(long_filterL, CharacterParameter, Character.valueOf((char) 23), 23, 10); - run_longQuery(long_filterR, CharacterParameter, Character.valueOf((char) 0), 0, 9); - run_longQuery(long_filterL, intParameter, Integer.valueOf(100), 100, 8); - run_longQuery(long_filterR, intParameter, Integer.valueOf(0), 0, 9); - run_longQuery(long_filterL, IntegerParameter, Integer.valueOf(23), 23, 10); - run_longQuery(long_filterR, IntegerParameter, Integer.valueOf(1000000), 1000000, 9); - run_longQuery(long_filterL, floatParameter, Float.valueOf((float) -1000000.0), -1000000, 9); - // run_longQuery(long_filterR, floatParameter, Float.valueOf((float)Long.MAX_VALUE), - // Long.MAX_VALUE, 9); - run_longQuery(long_filterL, FloatParameter, Float.valueOf((float) 100), 100, 8); - run_longQuery(long_filterR, FloatParameter, Float.valueOf((float) 32), 32, 10); - run_longQuery(long_filterL, doubleParameter, Double.valueOf(-1000000.0), -1000000, 9); - // run_longQuery(long_filterR, doubleParameter, Double.valueOf((double)Long.MAX_VALUE), - // Long.MAX_VALUE, 9); - run_longQuery(long_filterL, DoubleParameter, Double.valueOf(100), 100, 8); - run_longQuery(long_filterR, DoubleParameter, Double.valueOf(32), 32, 10); - run_longQuery(long_filterL, BigIntegerParameter, new BigInteger("1000000"), 1000000, 9); - run_longQuery(long_filterR, BigIntegerParameter, new BigInteger("-1000000"), -1000000, 9); - run_longQuery(long_filterL, BigDecimalParameter, new BigDecimal("10000.0"), 10000, 10); - run_longQuery(long_filterR, BigDecimalParameter, new BigDecimal("-1000000.0"), -1000000, 9); - alltypes.setlong(100); - run_longQuery(long_filterObj, AllTypesParameter, alltypes, 100, 8); - run_longQuery(long_filterVal, null, null, 1000000, 9); - - run_floatQuery(float_filterL, floatParameter, Float.valueOf(100.0f), 100.0f, 8); - run_floatQuery(float_filterR, floatParameter, Float.valueOf(100.0f), 100.0f, 8); - run_floatQuery(float_filterL, FloatParameter, Float.valueOf((float) 0.0), 0.0f, 9); - run_floatQuery(float_filterR, FloatParameter, Float.valueOf((float) 4.0), 4.0f, 10); - run_floatQuery(float_filterL, byteParameter, Byte.valueOf((byte) 0), 0.0f, 9); - run_floatQuery(float_filterR, byteParameter, Byte.valueOf((byte) 23), 23.0f, 10); - run_floatQuery(float_filterL, ByteParameter, Byte.valueOf((byte) 34), 34.0f, 10); - run_floatQuery(float_filterR, ByteParameter, Byte.valueOf((byte) 100), 100.0f, 8); - run_floatQuery(float_filterL, shortParameter, Short.valueOf((short) 0), 0.0f, 9); - run_floatQuery(float_filterR, shortParameter, Short.valueOf((short) 23), 23.0f, 10); - run_floatQuery(float_filterL, ShortParameter, Short.valueOf((short) 34), 34.0f, 10); - run_floatQuery(float_filterR, ShortParameter, Short.valueOf((short) 100), 100.0f, 8); - run_floatQuery(float_filterL, charParameter, Character.valueOf((char) 0), 0.0f, 9); - run_floatQuery(float_filterR, charParameter, Character.valueOf((char) 23), 23.0f, 10); - run_floatQuery(float_filterL, CharacterParameter, Character.valueOf((char) 34), 34.0f, 10); - run_floatQuery(float_filterR, CharacterParameter, Character.valueOf((char) 100), 100.0f, 8); - run_floatQuery(float_filterL, intParameter, Integer.valueOf(50000000), 50000000.0f, 9); - run_floatQuery(float_filterR, intParameter, Integer.valueOf(23), 23.0f, 10); - run_floatQuery(float_filterL, IntegerParameter, Integer.valueOf(34), 34.0f, 10); - run_floatQuery(float_filterR, IntegerParameter, Integer.valueOf(100), 100.0f, 8); - run_floatQuery(float_filterL, longParameter, Long.valueOf(50000000), 50000000.0f, 9); - run_floatQuery(float_filterR, longParameter, Long.valueOf(23), 23.0f, 10); - run_floatQuery(float_filterL, LongParameter, Long.valueOf(34), 34.0f, 10); - run_floatQuery(float_filterR, LongParameter, Long.valueOf(100), 100.0f, 8); - run_floatQuery(float_filterL, doubleParameter, Double.valueOf(50000000.0f), 50000000.0f, 9); - run_floatQuery(float_filterR, doubleParameter, Double.valueOf(0.0f), 0.0f, 9); - run_floatQuery(float_filterL, DoubleParameter, Double.valueOf(0.0f), 0.0f, 9); - run_floatQuery(float_filterR, DoubleParameter, Double.valueOf(100.0f), 100.0f, 8); - run_floatQuery(float_filterL, BigIntegerParameter, new BigInteger("0"), 0.0f, 9); - run_floatQuery( - float_filterR, BigIntegerParameter, new BigInteger("1000000000"), 1000000000.0f, 9); - run_floatQuery(float_filterL, BigDecimalParameter, new BigDecimal("-234.23"), -234.23f, 9); - run_floatQuery(float_filterR, BigDecimalParameter, new BigDecimal("100.0"), 100.0f, 8); - alltypes.setfloat(23.23f); - run_floatQuery(float_filterObj, AllTypesParameter, alltypes, 23.23f, 10); - run_floatQuery(float_filterVal, null, null, 100.0f, 8); - run_doubleQuery(double_filterL, doubleParameter, Double.valueOf(350.5), 350.5, 9); - run_doubleQuery(double_filterR, doubleParameter, Double.valueOf(350.5), 350.5, 9); - run_doubleQuery(double_filterL, DoubleParameter, Double.valueOf(0.0), 0.0, 9); - run_doubleQuery(double_filterR, DoubleParameter, Double.valueOf(23.34), 23.34, 10); - run_doubleQuery(double_filterL, byteParameter, Byte.valueOf((byte) 100), 100.0, 8); - run_doubleQuery(double_filterR, byteParameter, Byte.valueOf((byte) 0), 0.0, 9); - run_doubleQuery(double_filterL, ByteParameter, Byte.valueOf((byte) 23), 23.0, 10); - run_doubleQuery(double_filterR, ByteParameter, Byte.valueOf((byte) 100), 100.0, 8); - run_doubleQuery(double_filterL, shortParameter, Short.valueOf((short) 100), 100.0, 8); - run_doubleQuery(double_filterR, shortParameter, Short.valueOf((short) 0), 0.0, 9); - run_doubleQuery(double_filterL, ShortParameter, Short.valueOf((short) 23), 23.0, 10); - run_doubleQuery(double_filterR, ShortParameter, Short.valueOf((short) 100), 100.0, 8); - run_doubleQuery(double_filterL, intParameter, Integer.valueOf(100), 100.0, 8); - run_doubleQuery(double_filterR, intParameter, Integer.valueOf(0), 0.0, 9); - run_doubleQuery(double_filterL, IntegerParameter, Integer.valueOf(23), 23.0, 10); - run_doubleQuery(double_filterR, IntegerParameter, Integer.valueOf(100), 100.0, 8); - run_doubleQuery(double_filterL, longParameter, Long.valueOf(100), 100.0, 8); - run_doubleQuery(double_filterR, longParameter, Long.valueOf(0), 0.0, 9); - run_doubleQuery(double_filterL, LongParameter, Long.valueOf(23), 23.0, 10); - run_doubleQuery(double_filterR, LongParameter, Long.valueOf(100), 100.0, 8); - run_doubleQuery(double_filterL, floatParameter, Float.valueOf(0.0f), 0.0, 9); - run_doubleQuery(double_filterR, floatParameter, Float.valueOf(100.0f), 100.0, 8); - run_doubleQuery(double_filterL, FloatParameter, Float.valueOf(100.0f), 100.0, 8); - run_doubleQuery(double_filterR, FloatParameter, Float.valueOf(69.96f), 69.96, 10); - run_doubleQuery(double_filterL, BigIntegerParameter, new BigInteger("50000000"), 50000000.0, 9); - run_doubleQuery( - double_filterR, BigIntegerParameter, new BigInteger("1000000000"), 1000000000.0, 9); - run_doubleQuery(double_filterL, BigDecimalParameter, new BigDecimal("350.5"), 350.5, 9); - run_doubleQuery( - double_filterR, BigDecimalParameter, new BigDecimal("-234234.234"), -234234.234, 9); - alltypes.setdouble(0.0); - run_doubleQuery(double_filterObj, AllTypesParameter, alltypes, 0.0, 9); - run_doubleQuery(double_filterVal, null, null, 100.0, 8); - - run_BooleanQuery(Boolean_filterL, booleanParameter, trueBoolean, trueBoolean, 6); - run_BooleanQuery(Boolean_filterL, booleanParameter, falseBoolean, falseBoolean, 4); - run_BooleanQuery(Boolean_filterR, booleanParameter, trueBoolean, trueBoolean, 6); - run_BooleanQuery(Boolean_filterR, booleanParameter, falseBoolean, falseBoolean, 4); - run_BooleanQuery(Boolean_filterL, BooleanParameter, trueBoolean, trueBoolean, 6); - run_BooleanQuery(Boolean_filterL, BooleanParameter, falseBoolean, falseBoolean, 4); - run_BooleanQuery(Boolean_filterR, BooleanParameter, trueBoolean, trueBoolean, 6); - run_BooleanQuery(Boolean_filterR, BooleanParameter, falseBoolean, falseBoolean, 4); - run_BooleanQuery(Boolean_filterT, null, trueBoolean, trueBoolean, 6); - run_BooleanQuery(Boolean_filterF, null, falseBoolean, falseBoolean, 4); - alltypes.setBoolean(trueBoolean); - run_BooleanQuery(Boolean_filterObj, AllTypesParameter, alltypes, trueBoolean, 6); - alltypes.setBoolean(falseBoolean); - run_BooleanQuery(Boolean_filterObj, AllTypesParameter, alltypes, falseBoolean, 4); - - run_ByteQuery(Byte_filterL, byteParameter, Byte.valueOf((byte) 50), Byte.valueOf((byte) 50), 8); - run_ByteQuery( - Byte_filterR, byteParameter, Byte.valueOf(Byte.MIN_VALUE), Byte.valueOf(Byte.MIN_VALUE), 9); - run_ByteQuery( - Byte_filterL, ByteParameter, Byte.valueOf((byte) 20), Byte.valueOf((byte) 20), 10); - run_ByteQuery( - Byte_filterR, ByteParameter, Byte.valueOf(Byte.MAX_VALUE), Byte.valueOf(Byte.MAX_VALUE), 9); - run_ByteQuery( - Byte_filterL, shortParameter, Short.valueOf((short) 50), Byte.valueOf((byte) 50), 8); - run_ByteQuery( - Byte_filterR, shortParameter, Short.valueOf((short) 50), Byte.valueOf((byte) 50), 8); - run_ByteQuery( - Byte_filterL, ShortParameter, Short.valueOf((short) -100), Byte.valueOf((byte) -100), 9); - run_ByteQuery( - Byte_filterR, ShortParameter, Short.valueOf((short) -100), Byte.valueOf((byte) -100), 9); - run_ByteQuery( - Byte_filterL, charParameter, Character.valueOf((char) 50), Byte.valueOf((byte) 50), 8); - run_ByteQuery( - Byte_filterR, charParameter, Character.valueOf((char) 50), Byte.valueOf((byte) 50), 8); - run_ByteQuery( - Byte_filterL, CharacterParameter, Character.valueOf((char) 50), Byte.valueOf((byte) 50), 8); - run_ByteQuery( - Byte_filterR, CharacterParameter, Character.valueOf((char) 75), Byte.valueOf((byte) 75), 9); - run_ByteQuery(Byte_filterL, intParameter, Integer.valueOf(50), Byte.valueOf((byte) 50), 8); - run_ByteQuery(Byte_filterR, intParameter, Integer.valueOf(50), Byte.valueOf((byte) 50), 8); - run_ByteQuery(Byte_filterL, IntegerParameter, Integer.valueOf(50), Byte.valueOf((byte) 50), 8); - run_ByteQuery(Byte_filterR, IntegerParameter, Integer.valueOf(75), Byte.valueOf((byte) 75), 9); - run_ByteQuery(Byte_filterL, longParameter, Long.valueOf(50), Byte.valueOf((byte) 50), 8); - run_ByteQuery(Byte_filterR, longParameter, Long.valueOf(50), Byte.valueOf((byte) 50), 8); - run_ByteQuery(Byte_filterL, LongParameter, Long.valueOf(-100), Byte.valueOf((byte) -100), 9); - run_ByteQuery(Byte_filterR, LongParameter, Long.valueOf(-100), Byte.valueOf((byte) -100), 9); - run_ByteQuery( - Byte_filterL, floatParameter, Float.valueOf((float) 50), Byte.valueOf((byte) 50), 8); - run_ByteQuery( - Byte_filterR, floatParameter, Float.valueOf((float) 50), Byte.valueOf((byte) 50), 8); - run_ByteQuery( - Byte_filterL, FloatParameter, Float.valueOf((float) -100), Byte.valueOf((byte) -100), 9); - run_ByteQuery( - Byte_filterR, FloatParameter, Float.valueOf((float) -100), Byte.valueOf((byte) -100), 9); - run_ByteQuery(Byte_filterL, doubleParameter, Double.valueOf(50), Byte.valueOf((byte) 50), 8); - run_ByteQuery(Byte_filterR, doubleParameter, Double.valueOf(50), Byte.valueOf((byte) 50), 8); - run_ByteQuery( - Byte_filterL, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte) -100), 9); - run_ByteQuery( - Byte_filterR, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte) -100), 9); - run_ByteQuery( - Byte_filterL, BigIntegerParameter, new BigInteger("50"), Byte.valueOf((byte) 50), 8); - run_ByteQuery( - Byte_filterR, BigIntegerParameter, new BigInteger("-100"), Byte.valueOf((byte) -100), 9); - run_ByteQuery( - Byte_filterL, BigDecimalParameter, new BigDecimal("100.0"), Byte.valueOf((byte) 100), 9); - run_ByteQuery( - Byte_filterR, BigDecimalParameter, new BigDecimal("10.0"), Byte.valueOf((byte) 10), 9); - Byte val = Byte.valueOf((byte) 50); - alltypes.setByte(val); - run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, 8); - val = Byte.valueOf((byte) 45); - alltypes.setByte(val); - run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, 10); - run_ByteQuery(Byte_filterVal, null, null, Byte.valueOf((byte) 100), 9); - - run_ShortQuery( - Short_filterL, shortParameter, Short.valueOf((short) 100), Short.valueOf((short) 100), 8); - run_ShortQuery( - Short_filterR, shortParameter, Short.valueOf((short) 100), Short.valueOf((short) 100), 8); - run_ShortQuery( - Short_filterL, - ShortParameter, - Short.valueOf(Short.MIN_VALUE), - Short.valueOf(Short.MIN_VALUE), - 9); - run_ShortQuery( - Short_filterR, ShortParameter, Short.valueOf((short) 253), Short.valueOf((short) 253), 10); - run_ShortQuery( - Short_filterR, shortParameter, Short.valueOf((short) 1000), Short.valueOf((short) 1000), 9); - run_ShortQuery( - Short_filterL, byteParameter, Byte.valueOf((byte) 75), Short.valueOf((short) 75), 10); - run_ShortQuery( - Short_filterR, byteParameter, Byte.valueOf((byte) 75), Short.valueOf((short) 75), 10); - run_ShortQuery( - Short_filterL, ByteParameter, Byte.valueOf((byte) 100), Short.valueOf((short) 100), 8); - run_ShortQuery( - Short_filterR, ByteParameter, Byte.valueOf((byte) 100), Short.valueOf((short) 100), 8); - run_ShortQuery( - Short_filterL, charParameter, Character.valueOf((char) 75), Short.valueOf((short) 75), 10); - run_ShortQuery( - Short_filterR, charParameter, Character.valueOf((char) 75), Short.valueOf((short) 75), 10); - run_ShortQuery( - Short_filterL, - CharacterParameter, - Character.valueOf((char) 100), - Short.valueOf((short) 100), - 8); - run_ShortQuery( - Short_filterR, - CharacterParameter, - Character.valueOf((char) 100), - Short.valueOf((short) 100), - 8); - run_ShortQuery( - Short_filterL, intParameter, Integer.valueOf(-10000), Short.valueOf((short) -10000), 9); - run_ShortQuery( - Short_filterR, intParameter, Integer.valueOf(-10000), Short.valueOf((short) -10000), 9); - run_ShortQuery( - Short_filterL, IntegerParameter, Integer.valueOf(10000), Short.valueOf((short) 10000), 9); - run_ShortQuery( - Short_filterR, IntegerParameter, Integer.valueOf(10000), Short.valueOf((short) 10000), 9); - run_ShortQuery( - Short_filterL, longParameter, Long.valueOf(10000), Short.valueOf((short) 10000), 9); - run_ShortQuery( - Short_filterR, longParameter, Long.valueOf(10000), Short.valueOf((short) 10000), 9); - run_ShortQuery(Short_filterL, LongParameter, Long.valueOf(100), Short.valueOf((short) 100), 8); - run_ShortQuery(Short_filterR, LongParameter, Long.valueOf(100), Short.valueOf((short) 100), 8); - run_ShortQuery( - Short_filterL, - floatParameter, - Float.valueOf((float) 23000), - Short.valueOf((short) 23000), - 10); - run_ShortQuery( - Short_filterR, - floatParameter, - Float.valueOf((float) 23000), - Short.valueOf((short) 23000), - 10); - run_ShortQuery( - Short_filterL, FloatParameter, Float.valueOf((float) 100), Short.valueOf((short) 100), 8); - run_ShortQuery( - Short_filterR, FloatParameter, Float.valueOf((float) 100), Short.valueOf((short) 100), 8); - run_ShortQuery( - Short_filterL, doubleParameter, Double.valueOf(-10000), Short.valueOf((short) -10000), 9); - run_ShortQuery( - Short_filterR, doubleParameter, Double.valueOf(-10000), Short.valueOf((short) -10000), 9); - run_ShortQuery( - Short_filterL, DoubleParameter, Double.valueOf(23), Short.valueOf((short) 23), 10); - run_ShortQuery( - Short_filterR, DoubleParameter, Double.valueOf(23), Short.valueOf((short) 23), 10); - run_ShortQuery( - Short_filterL, BigIntegerParameter, new BigInteger("999"), Short.valueOf((short) 999), 10); - run_ShortQuery( - Short_filterR, - BigIntegerParameter, - new BigInteger("-1000"), - Short.valueOf((short) -1000), - 9); - run_ShortQuery( - Short_filterL, BigDecimalParameter, new BigDecimal("100.0"), Short.valueOf((short) 100), 8); - run_ShortQuery( - Short_filterR, - BigDecimalParameter, - new BigDecimal("10000.0"), - Short.valueOf((short) 10000), - 9); - Short sval = Short.valueOf((short) 100); - alltypes.setShort(sval); - run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, 8); - sval = Short.valueOf((short) 23); - alltypes.setShort(sval); - run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, 10); - run_ShortQuery(Short_filterVal, null, null, Short.valueOf((short) -1000), 9); - - run_CharacterQuery( - Character_filterL, - charParameter, - Character.valueOf(Character.MIN_VALUE), - Character.valueOf(Character.MIN_VALUE), - 9); - run_CharacterQuery( - Character_filterR, - charParameter, - Character.valueOf(Character.MAX_VALUE), - Character.valueOf(Character.MAX_VALUE), - 9); - run_CharacterQuery( - Character_filterL, charParameter, Character.valueOf('C'), Character.valueOf('C'), 10); - run_CharacterQuery( - Character_filterR, charParameter, Character.valueOf('z'), Character.valueOf('z'), 8); - run_CharacterQuery( - Character_filterL, CharacterParameter, Character.valueOf(' '), Character.valueOf(' '), 9); - run_CharacterQuery( - Character_filterR, CharacterParameter, Character.valueOf('f'), Character.valueOf('f'), 10); - run_CharacterQuery( - Character_filterL, - byteParameter, - Byte.valueOf((byte) Character.MIN_VALUE), - Character.valueOf((char) Character.MIN_VALUE), - 9); - run_CharacterQuery( - Character_filterR, ByteParameter, Byte.valueOf((byte) 'a'), Character.valueOf('a'), 10); - run_CharacterQuery( - Character_filterL, shortParameter, Short.valueOf((short) 'M'), Character.valueOf('M'), 8); - run_CharacterQuery( - Character_filterR, shortParameter, Short.valueOf((short) 'F'), Character.valueOf('F'), 9); - run_CharacterQuery( - Character_filterL, ShortParameter, Short.valueOf((short) 'A'), Character.valueOf('A'), 9); - run_CharacterQuery( - Character_filterR, ShortParameter, Short.valueOf((short) 'A'), Character.valueOf('A'), 9); - run_CharacterQuery( - Character_filterL, intParameter, Integer.valueOf('z'), Character.valueOf('z'), 8); - run_CharacterQuery( - Character_filterR, intParameter, Integer.valueOf('z'), Character.valueOf('z'), 8); - run_CharacterQuery( - Character_filterL, IntegerParameter, Integer.valueOf('B'), Character.valueOf('B'), 9); - run_CharacterQuery( - Character_filterR, IntegerParameter, Integer.valueOf('B'), Character.valueOf('B'), 9); - run_CharacterQuery( - Character_filterL, longParameter, Long.valueOf('z'), Character.valueOf('z'), 8); - run_CharacterQuery( - Character_filterR, longParameter, Long.valueOf('z'), Character.valueOf('z'), 8); - run_CharacterQuery( - Character_filterL, LongParameter, Long.valueOf('B'), Character.valueOf('B'), 9); - run_CharacterQuery( - Character_filterR, LongParameter, Long.valueOf('B'), Character.valueOf('B'), 9); - run_CharacterQuery( - Character_filterL, - floatParameter, - Float.valueOf((float) 123.222), - Character.valueOf('x'), - 10); - run_CharacterQuery( - Character_filterR, - floatParameter, - Float.valueOf((float) 123.222), - Character.valueOf('x'), - 10); - run_CharacterQuery( - Character_filterL, FloatParameter, Float.valueOf((float) 'z'), Character.valueOf('z'), 8); - run_CharacterQuery( - Character_filterR, FloatParameter, Float.valueOf((float) 'z'), Character.valueOf('z'), 8); - run_CharacterQuery( - Character_filterL, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), 9); - run_CharacterQuery( - Character_filterR, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), 9); - run_CharacterQuery( - Character_filterL, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), 9); - run_CharacterQuery( - Character_filterR, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), 9); - run_CharacterQuery( - Character_filterL, - BigIntegerParameter, - new BigInteger("65"), - Character.valueOf('A'), - 9); // 'A' == 65 - run_CharacterQuery( - Character_filterR, - BigIntegerParameter, - new BigInteger("122"), - Character.valueOf('z'), - 8); // 'z' == 122 - run_CharacterQuery( - Character_filterL, - BigDecimalParameter, - new BigDecimal("65.000000"), - Character.valueOf('A'), - 9); - run_CharacterQuery( - Character_filterR, - BigDecimalParameter, - new BigDecimal("77.0"), - Character.valueOf('M'), - 8); // 'M' == 77 - alltypes.setCharacter(Character.valueOf('A')); - run_CharacterQuery(Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('A'), 9); - alltypes.setCharacter(Character.valueOf('b')); - run_CharacterQuery( - Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('b'), 10); - run_CharacterQuery(Character_filterVal, null, null, Character.valueOf('z'), 8); - - run_IntegerQuery( - Integer_filterL, - intParameter, - Integer.valueOf(AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - 9); - run_IntegerQuery( - Integer_filterR, - intParameter, - Integer.valueOf(AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - 9); - run_IntegerQuery(Integer_filterR, intParameter, Integer.valueOf(23), Integer.valueOf(23), 10); - run_IntegerQuery( - Integer_filterL, IntegerParameter, Integer.valueOf(1000000), Integer.valueOf(1000000), 9); - run_IntegerQuery( - Integer_filterR, IntegerParameter, Integer.valueOf(1000), Integer.valueOf(1000), 9); - run_IntegerQuery( - Integer_filterL, byteParameter, Byte.valueOf((byte) 100), Integer.valueOf(100), 8); - run_IntegerQuery(Integer_filterR, byteParameter, Byte.valueOf((byte) 0), Integer.valueOf(0), 9); - run_IntegerQuery( - Integer_filterL, ByteParameter, Byte.valueOf((byte) 100), Integer.valueOf(100), 8); - run_IntegerQuery(Integer_filterR, ByteParameter, Byte.valueOf((byte) 0), Integer.valueOf(0), 9); - run_IntegerQuery( - Integer_filterL, shortParameter, Short.valueOf((short) 10000), Integer.valueOf(10000), 9); - run_IntegerQuery( - Integer_filterR, shortParameter, Short.valueOf((short) -1000), Integer.valueOf(-1000), 9); - run_IntegerQuery( - Integer_filterL, ShortParameter, Short.valueOf((short) -1000), Integer.valueOf(-1000), 9); - run_IntegerQuery( - Integer_filterL, charParameter, Character.valueOf((char) 10000), Integer.valueOf(10000), 9); - run_IntegerQuery( - Integer_filterR, charParameter, Character.valueOf((char) 100), Integer.valueOf(100), 8); - run_IntegerQuery( - Integer_filterL, - CharacterParameter, - Character.valueOf((char) 10000), - Integer.valueOf(10000), - 9); - run_IntegerQuery( - Integer_filterR, - CharacterParameter, - Character.valueOf((char) 10000), - Integer.valueOf(10000), - 9); - run_IntegerQuery( - Integer_filterL, - longParameter, - Long.valueOf(AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - 9); - run_IntegerQuery( - Integer_filterR, - longParameter, - Long.valueOf(AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - 9); - run_IntegerQuery( - Integer_filterL, LongParameter, Long.valueOf(10000), Integer.valueOf(10000), 9); - run_IntegerQuery(Integer_filterR, LongParameter, Long.valueOf(43), Integer.valueOf(43), 10); - run_IntegerQuery( - Integer_filterL, - floatParameter, - Float.valueOf((float) AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - 9); - run_IntegerQuery( - Integer_filterR, - floatParameter, - Float.valueOf((float) AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - 9); - run_IntegerQuery( - Integer_filterL, FloatParameter, Float.valueOf((float) 10000), Integer.valueOf(10000), 9); - run_IntegerQuery( - Integer_filterR, FloatParameter, Float.valueOf((float) 43), Integer.valueOf(43), 10); - run_IntegerQuery( - Integer_filterL, - doubleParameter, - Double.valueOf(AllTypes.veryLargePositiveInt), - Integer.valueOf(AllTypes.veryLargePositiveInt), - 9); - run_IntegerQuery( - Integer_filterR, - doubleParameter, - Double.valueOf(AllTypes.veryLargeNegativeInt), - Integer.valueOf(AllTypes.veryLargeNegativeInt), - 9); - run_IntegerQuery( - Integer_filterL, DoubleParameter, Double.valueOf(10000), Integer.valueOf(10000), 9); - run_IntegerQuery(Integer_filterR, DoubleParameter, Double.valueOf(43), Integer.valueOf(43), 10); - run_IntegerQuery( - Integer_filterL, - BigIntegerParameter, - new BigInteger("1000000"), - Integer.valueOf(1000000), - 9); - run_IntegerQuery( - Integer_filterR, - BigIntegerParameter, - new BigInteger("-1000000"), - Integer.valueOf(-1000000), - 9); - run_IntegerQuery( - Integer_filterL, - BigDecimalParameter, - new BigDecimal("1000000.0"), - Integer.valueOf(1000000), - 9); - run_IntegerQuery( - Integer_filterR, - BigDecimalParameter, - new BigDecimal("-100000.0"), - Integer.valueOf(-100000), - 10); - alltypes.setInteger(Integer.valueOf(100)); - run_IntegerQuery(Integer_filterObj, AllTypesParameter, alltypes, Integer.valueOf(100), 8); - run_IntegerQuery(Integer_filterVal, null, null, Integer.valueOf(100), 8); - - run_LongQuery( - Long_filterL, longParameter, Long.valueOf(Long.MIN_VALUE), Long.valueOf(Long.MIN_VALUE), 9); - run_LongQuery( - Long_filterR, longParameter, Long.valueOf(Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE), 9); - run_LongQuery(Long_filterL, LongParameter, Long.valueOf(100), Long.valueOf(100), 8); - run_LongQuery(Long_filterR, LongParameter, Long.valueOf(23), Long.valueOf(23), 10); - run_LongQuery(Long_filterL, byteParameter, Byte.valueOf((byte) 100), Long.valueOf(100), 8); - run_LongQuery(Long_filterR, byteParameter, Byte.valueOf((byte) 0), Long.valueOf(0), 9); - run_LongQuery(Long_filterL, ByteParameter, Byte.valueOf((byte) 100), Long.valueOf(100), 8); - run_LongQuery(Long_filterR, ByteParameter, Byte.valueOf((byte) 0), Long.valueOf(0), 9); - run_LongQuery( - Long_filterL, shortParameter, Short.valueOf((short) -1000), Long.valueOf(-1000), 8); - run_LongQuery(Long_filterR, shortParameter, Short.valueOf((short) 1000), Long.valueOf(1000), 9); - run_LongQuery(Long_filterL, ShortParameter, Short.valueOf((short) 100), Long.valueOf(100), 8); - run_LongQuery(Long_filterR, ShortParameter, Short.valueOf((short) 32), Long.valueOf(32), 10); - run_LongQuery(Long_filterL, charParameter, Character.valueOf((char) 0), Long.valueOf(0), 9); - run_LongQuery(Long_filterR, charParameter, Character.valueOf((char) 100), Long.valueOf(100), 8); - run_LongQuery( - Long_filterL, CharacterParameter, Character.valueOf((char) 23), Long.valueOf(23), 10); - run_LongQuery( - Long_filterR, CharacterParameter, Character.valueOf((char) 0), Long.valueOf(0), 9); - run_LongQuery(Long_filterL, intParameter, Integer.valueOf(100), Long.valueOf(100), 8); - run_LongQuery(Long_filterR, intParameter, Integer.valueOf(0), Long.valueOf(0), 9); - run_LongQuery(Long_filterL, IntegerParameter, Integer.valueOf(23), Long.valueOf(23), 10); - run_LongQuery( - Long_filterR, IntegerParameter, Integer.valueOf(1000000), Long.valueOf(1000000), 9); - run_LongQuery( - Long_filterL, floatParameter, Float.valueOf((float) -1000000.0), Long.valueOf(-1000000), 9); - // run_LongQuery(Long_filterR, floatParameter, Float.valueOf((float)Long.MAX_VALUE), - // Long.valueOf(Long.MAX_VALUE), 9); - run_LongQuery(Long_filterL, FloatParameter, Float.valueOf((float) 100), Long.valueOf(100), 8); - run_LongQuery(Long_filterR, FloatParameter, Float.valueOf((float) 32), Long.valueOf(32), 10); - run_LongQuery( - Long_filterL, doubleParameter, Double.valueOf(-1000000.0), Long.valueOf(-1000000), 9); - // run_LongQuery(Long_filterR, doubleParameter, Double.valueOf((double)Long.MAX_VALUE), - // Long.valueOf(Long.MAX_VALUE), 9); - run_LongQuery(Long_filterL, DoubleParameter, Double.valueOf(100), Long.valueOf(100), 8); - run_LongQuery(Long_filterR, DoubleParameter, Double.valueOf(32), Long.valueOf(32), 10); - run_LongQuery( - Long_filterL, BigIntegerParameter, new BigInteger("1000000"), Long.valueOf(1000000), 9); - run_LongQuery( - Long_filterR, BigIntegerParameter, new BigInteger("-1000000"), Long.valueOf(-1000000), 9); - run_LongQuery( - Long_filterL, BigDecimalParameter, new BigDecimal("-1000.0"), Long.valueOf(-1000), 8); - run_LongQuery( - Long_filterR, BigDecimalParameter, new BigDecimal("-1000000.0"), Long.valueOf(-1000000), 9); - alltypes.setLong(Long.valueOf(100)); - run_LongQuery(Long_filterObj, AllTypesParameter, alltypes, Long.valueOf(100), 8); - run_LongQuery(Long_filterVal, null, null, Long.valueOf(-1000), 8); - - run_FloatQuery(Float_filterL, floatParameter, Float.valueOf(100.0f), Float.valueOf(100.0f), 8); - run_FloatQuery(Float_filterR, floatParameter, Float.valueOf(100.0f), Float.valueOf(100.0f), 8); - run_FloatQuery( - Float_filterL, FloatParameter, Float.valueOf((float) 0.0), Float.valueOf(0.0f), 9); - run_FloatQuery( - Float_filterR, FloatParameter, Float.valueOf((float) 4.0), Float.valueOf(4.0f), 10); - run_FloatQuery(Float_filterL, byteParameter, Byte.valueOf((byte) 0), Float.valueOf(0.0f), 9); - run_FloatQuery(Float_filterR, byteParameter, Byte.valueOf((byte) 23), Float.valueOf(23.0f), 10); - run_FloatQuery(Float_filterL, ByteParameter, Byte.valueOf((byte) 34), Float.valueOf(34.0f), 10); - run_FloatQuery( - Float_filterR, ByteParameter, Byte.valueOf((byte) 100), Float.valueOf(100.0f), 8); - run_FloatQuery(Float_filterL, shortParameter, Short.valueOf((short) 0), Float.valueOf(0.0f), 9); - run_FloatQuery( - Float_filterR, shortParameter, Short.valueOf((short) 23), Float.valueOf(23.0f), 10); - run_FloatQuery( - Float_filterL, ShortParameter, Short.valueOf((short) 34), Float.valueOf(34.0f), 10); - run_FloatQuery( - Float_filterR, ShortParameter, Short.valueOf((short) 100), Float.valueOf(100.0f), 8); - run_FloatQuery( - Float_filterL, charParameter, Character.valueOf((char) 0), Float.valueOf(0.0f), 9); - run_FloatQuery( - Float_filterR, charParameter, Character.valueOf((char) 23), Float.valueOf(23.0f), 10); - run_FloatQuery( - Float_filterL, CharacterParameter, Character.valueOf((char) 34), Float.valueOf(34.0f), 10); - run_FloatQuery( - Float_filterR, CharacterParameter, Character.valueOf((char) 100), Float.valueOf(100.0f), 8); - run_FloatQuery( - Float_filterL, intParameter, Integer.valueOf(50000000), Float.valueOf(50000000.0f), 9); - run_FloatQuery(Float_filterR, intParameter, Integer.valueOf(23), Float.valueOf(23.0f), 10); - run_FloatQuery(Float_filterL, IntegerParameter, Integer.valueOf(34), Float.valueOf(34.0f), 10); - run_FloatQuery(Float_filterR, IntegerParameter, Integer.valueOf(100), Float.valueOf(100.0f), 8); - run_FloatQuery( - Float_filterL, longParameter, Long.valueOf(50000000), Float.valueOf(50000000.0f), 9); - run_FloatQuery(Float_filterR, longParameter, Long.valueOf(23), Float.valueOf(23.0f), 10); - run_FloatQuery(Float_filterL, LongParameter, Long.valueOf(34), Float.valueOf(34.0f), 10); - run_FloatQuery(Float_filterR, LongParameter, Long.valueOf(100), Float.valueOf(100.0f), 8); - run_FloatQuery( - Float_filterL, doubleParameter, Double.valueOf(50000000.0f), Float.valueOf(50000000.0f), 9); - run_FloatQuery( - Float_filterR, doubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), 8); - run_FloatQuery(Float_filterL, DoubleParameter, Double.valueOf(0.0f), Float.valueOf(0.0f), 9); - run_FloatQuery( - Float_filterR, DoubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), 8); - run_FloatQuery( - Float_filterL, - BigIntegerParameter, - new BigInteger("50000000"), - Float.valueOf(50000000.0f), - 9); - run_FloatQuery( - Float_filterR, - BigIntegerParameter, - new BigInteger("1000000000"), - Float.valueOf(1000000000.0f), - 9); - run_FloatQuery( - Float_filterL, BigDecimalParameter, new BigDecimal("350.5"), Float.valueOf(350.5f), 9); - run_FloatQuery( - Float_filterR, - BigDecimalParameter, - new BigDecimal("50000000.0"), - Float.valueOf(50000000.0f), - 9); - alltypes.setFloat(Float.valueOf(23.23f)); - run_FloatQuery(Float_filterObj, AllTypesParameter, alltypes, Float.valueOf(23.23f), 10); - run_FloatQuery(Float_filterVal, null, null, Float.valueOf(100.0f), 8); - - run_DoubleQuery( - Double_filterL, doubleParameter, Double.valueOf(-25.5), Double.valueOf(-25.5), 9); - run_DoubleQuery( - Double_filterR, doubleParameter, Double.valueOf(-25.5), Double.valueOf(-25.5), 9); - run_DoubleQuery(Double_filterL, DoubleParameter, Double.valueOf(0.0), Double.valueOf(0.0), 9); - run_DoubleQuery( - Double_filterR, DoubleParameter, Double.valueOf(23.34), Double.valueOf(23.34), 10); - run_DoubleQuery( - Double_filterL, byteParameter, Byte.valueOf((byte) 100), Double.valueOf(100.0), 8); - run_DoubleQuery(Double_filterR, byteParameter, Byte.valueOf((byte) 0), Double.valueOf(0.0), 9); - run_DoubleQuery( - Double_filterL, ByteParameter, Byte.valueOf((byte) 23), Double.valueOf(23.0), 10); - run_DoubleQuery( - Double_filterR, ByteParameter, Byte.valueOf((byte) 100), Double.valueOf(100.0), 8); - run_DoubleQuery( - Double_filterL, shortParameter, Short.valueOf((short) 100), Double.valueOf(100.0), 8); - run_DoubleQuery( - Double_filterR, shortParameter, Short.valueOf((short) 0), Double.valueOf(0.0), 9); - run_DoubleQuery( - Double_filterL, ShortParameter, Short.valueOf((short) 23), Double.valueOf(23.0), 10); - run_DoubleQuery( - Double_filterR, ShortParameter, Short.valueOf((short) 100), Double.valueOf(100.0), 8); - run_DoubleQuery( - Double_filterL, charParameter, Character.valueOf((char) 100), Double.valueOf(100.0), 8); - run_DoubleQuery( - Double_filterR, charParameter, Character.valueOf((char) 0), Double.valueOf(0.0), 9); - run_DoubleQuery( - Double_filterL, CharacterParameter, Character.valueOf((char) 23), Double.valueOf(23.0), 10); - run_DoubleQuery( - Double_filterR, - CharacterParameter, - Character.valueOf((char) 100), - Double.valueOf(100.0), - 8); - run_DoubleQuery(Double_filterL, intParameter, Integer.valueOf(100), Double.valueOf(100.0), 8); - run_DoubleQuery(Double_filterR, intParameter, Integer.valueOf(0), Double.valueOf(0.0), 9); - run_DoubleQuery( - Double_filterL, IntegerParameter, Integer.valueOf(23), Double.valueOf(23.0), 10); - run_DoubleQuery( - Double_filterR, IntegerParameter, Integer.valueOf(100), Double.valueOf(100.0), 8); - run_DoubleQuery(Double_filterL, longParameter, Long.valueOf(100), Double.valueOf(100.0), 8); - run_DoubleQuery(Double_filterR, longParameter, Long.valueOf(0), Double.valueOf(0.0), 9); - run_DoubleQuery(Double_filterL, LongParameter, Long.valueOf(23), Double.valueOf(23.0), 10); - run_DoubleQuery(Double_filterR, LongParameter, Long.valueOf(100), Double.valueOf(100.0), 8); - run_DoubleQuery(Double_filterL, floatParameter, Float.valueOf(0.0f), Double.valueOf(0.0), 9); - run_DoubleQuery( - Double_filterR, floatParameter, Float.valueOf(100.0f), Double.valueOf(100.0), 8); - run_DoubleQuery( - Double_filterL, FloatParameter, Float.valueOf(100.0f), Double.valueOf(100.0), 8); - run_DoubleQuery( - Double_filterR, FloatParameter, Float.valueOf(69.96f), Double.valueOf(69.96), 10); - run_DoubleQuery( - Double_filterL, - BigIntegerParameter, - new BigInteger("50000000"), - Double.valueOf(50000000.0f), - 9); - run_DoubleQuery( - Double_filterR, - BigIntegerParameter, - new BigInteger("1000000000"), - Double.valueOf(1000000000.0f), - 9); - run_DoubleQuery( - Double_filterL, BigDecimalParameter, new BigDecimal("350.5"), Double.valueOf(350.5f), 9); - run_DoubleQuery( - Double_filterR, - BigDecimalParameter, - new BigDecimal("50000000.0"), - Double.valueOf(50000000.0f), - 9); - alltypes.setDouble(Double.valueOf(0.0)); - run_DoubleQuery(Double_filterObj, AllTypesParameter, alltypes, Double.valueOf(0.0), 9); - run_DoubleQuery(Double_filterVal, null, null, Double.valueOf(100.0), 8); - - run_StringQuery(String_filterL, StringParameter, new String("JDO"), new String("JDO"), 9); - run_StringQuery(String_filterR, StringParameter, new String("JDBC"), new String("JDBC"), 10); - alltypes.setString(new String("abcde")); - run_StringQuery(String_filterObj, AllTypesParameter, alltypes, new String("abcde"), 9); - run_StringQuery(String_filterVal1, null, null, new String("Java"), 8); - run_StringQuery(String_filterVal2, null, null, new String(""), 9); - - run_LocaleQuery( - Locale_filterL, LocaleParameter, Locale.CANADA_FRENCH, Locale.CANADA_FRENCH, 10); - run_LocaleQuery(Locale_filterR, LocaleParameter, Locale.US, Locale.US, 9); - alltypes.setLocale(Locale.UK); - run_LocaleQuery(Locale_filterObj, AllTypesParameter, alltypes, Locale.UK, 9); - - BigDecimal bd = new BigDecimal("100.0"); - run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, 8); - bd = new BigDecimal("-234234.23333"); - run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, 9); - bd = new BigDecimal("989899.33304953"); - run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, 10); - bd = new BigDecimal("-1123123.22"); - run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, 9); - alltypes.setBigDecimal(bd); - run_BigDecimalQuery(BigDecimal_filterObj, AllTypesParameter, alltypes, bd, 9); - - BigInteger bi = new BigInteger("987034534985043985"); - run_BigIntegerQuery(BigInteger_filterL, BigIntegerParameter, bi, bi, 9); - bi = new BigInteger("-999999999999999999"); - run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, 9); - bi = new BigInteger("-99999999999999999"); - run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, 10); - bi = new BigInteger("1333330"); - alltypes.setBigInteger(bi); - run_BigIntegerQuery(BigInteger_filterObj, AllTypesParameter, alltypes, bi, 9); +/** + *Title: Not Equals Query Operator + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-15. + *
    + *Assertion Description: +The not equal operator (!=) is supported for the following types: +
      +
    • byte, short, int, long, char, Byte, Short Integer, Long, Character
    • +
    • float, double, Float, Double
    • +
    • BigDecimal, BigInteger
    • +
    • Boolean, boolean
    • +
    • any class instance or array
    • +
    • Date, String
    • +
    +The operation on object-valued fields of wrapper types (Boolean, Byte, +Short, Integer, Long, Float, and Double), and numeric types +(BigDecimal and BigInteger) use the wrapped values +as operands. Inequality comparison of object-valued fields of +PersistenceCapable types use the JDO Identity comparison of +the references. Thus, two objects will compare not equal if they have +different JDO Identity. Equality comparison of object-valued fields of +non-PersistenceCapable types uses the equals +method of the field type. - GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.UK); - gc.clear(); - gc.set(1999, Calendar.DECEMBER, 31, 9, 0, 0); - Date d = gc.getTime(); - run_DateQuery(Date_filterL, DateParameter, d, d, 9); - gc.set(1992, Calendar.NOVEMBER, 22, 9, 0, 0); - d = gc.getTime(); - run_DateQuery(Date_filterR, DateParameter, d, d, 9); - gc.set(1959, Calendar.OCTOBER, 9, 9, 0, 0); - d = gc.getTime(); - run_DateQuery(Date_filterR, DateParameter, d, d, 10); - gc.set(1995, Calendar.JUNE, 14, 9, 0, 0); - d = gc.getTime(); - alltypes.setDate(d); - run_DateQuery(Date_filterObj, AllTypesParameter, alltypes, d, 9); - } + */ - private void run_booleanQuery( - String filter, String parameter, Object parameterValue, boolean value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - boolean val = obj.getboolean(); - if (val == value) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns object with incorrect value", - filter, - parameter); - } - cnt++; +public class NotEquals extends ComparisonTests { + private static String boolean_filterL = "value != fld_boolean"; + private static String boolean_filterR = "fld_boolean != value"; + private static String boolean_filterT = "fld_boolean != true"; + private static String boolean_filterF = "false != fld_boolean"; + private static String boolean_filterObj = "value.fld_boolean != fld_boolean"; + + private static String byte_filterL = "value != fld_byte"; + private static String byte_filterR = "fld_byte != value"; + private static String byte_filterObj = "value.fld_byte != fld_byte"; + private static String byte_filterVal = "fld_byte != 100"; + + private static String char_filterL = "value != fld_char"; + private static String char_filterR = "fld_char != value"; + private static String char_filterObj = "value.fld_char != fld_char"; + private static String char_filterVal = "'M' != fld_char"; + + private static String double_filterL = "value != fld_double"; + private static String double_filterR = "fld_double != value"; + private static String double_filterObj = "value.fld_double != fld_double"; + private static String double_filterVal = "fld_double != 100.0"; + + private static String float_filterL = "value != fld_float"; + private static String float_filterR = "fld_float != value"; + private static String float_filterObj = "fld_float != value.fld_float"; + private static String float_filterVal = "fld_float != 100.0"; + + private static String int_filterL = "value != fld_int"; + private static String int_filterR = "fld_int != value"; + private static String int_filterObj = "value.fld_int != fld_int"; + private static String int_filterVal = "fld_int != 1000"; + + private static String long_filterL = "value != fld_long"; + private static String long_filterR = "fld_long != value"; + private static String long_filterObj = "fld_long != value.fld_long"; + private static String long_filterVal = "fld_long != 1000000"; + + private static String short_filterL = "value != fld_short"; + private static String short_filterR = "fld_short != value"; + private static String short_filterObj = "value.fld_short != fld_short"; + private static String short_filterVal = "1000 != fld_short"; + + private static String Boolean_filterL = "value != fld_Boolean"; + private static String Boolean_filterR = "fld_Boolean != value"; + private static String Boolean_filterT = "fld_Boolean != true"; + private static String Boolean_filterF = "false != fld_Boolean"; + private static String Boolean_filterObj = "value.fld_Boolean != fld_Boolean"; + private static String Boolean_filterVal = "fld_Boolean != false"; + + private static String Byte_filterL = "value != fld_Byte"; + private static String Byte_filterR = "fld_Byte != value"; + private static String Byte_filterObj = "fld_Byte != value.fld_Byte"; + private static String Byte_filterVal = "100 != fld_Byte"; + + private static String Character_filterL = "value != fld_Character"; + private static String Character_filterR = "fld_Character != value"; + private static String Character_filterObj = "value.fld_Character != fld_Character"; + private static String Character_filterVal = "fld_Character != 'z'"; + + private static String Double_filterL = "value != fld_Double"; + private static String Double_filterR = "fld_Double != value"; + private static String Double_filterObj = "value.fld_Double != fld_Double"; + private static String Double_filterVal = "fld_Double != 100.0"; + + private static String Float_filterL = "value != fld_Float"; + private static String Float_filterR = "fld_Float != value"; + private static String Float_filterObj = "fld_Float != value.fld_Float"; + private static String Float_filterVal = "100.0f != fld_Float"; + + private static String Integer_filterL = "value != fld_Integer"; + private static String Integer_filterR = "fld_Integer != value"; + private static String Integer_filterObj = "fld_Integer != value.fld_Integer"; + private static String Integer_filterVal = "fld_Integer != 100"; + + private static String Long_filterL = "value != fld_Long"; + private static String Long_filterR = "fld_Long != value"; + private static String Long_filterObj = "value.fld_Long != fld_Long"; + private static String Long_filterVal = "-1000 != fld_Long"; + + private static String Short_filterL = "value != fld_Short"; + private static String Short_filterR = "fld_Short != value"; + private static String Short_filterObj = "fld_Short != value.fld_Short"; + private static String Short_filterVal = "-1000 != fld_Short"; + + private static String String_filterL = "value != fld_String"; + private static String String_filterR = "fld_String != value"; + private static String String_filterObj = "value.fld_String != fld_String"; + private static String String_filterVal1 = "fld_String != \"Java\""; + private static String String_filterVal2 = "fld_String != \"\""; + + private static String Locale_filterL = "value != fld_Locale"; + private static String Locale_filterR = "fld_Locale != value"; + private static String Locale_filterObj = "value.fld_Locale != fld_Locale"; + + private static String Date_filterL = "value != fld_Date"; + private static String Date_filterR = "fld_Date != value"; + private static String Date_filterObj = "fld_Date != value.fld_Date"; + + private static String BigDecimal_filterL = "value != fld_BigDecimal"; + private static String BigDecimal_filterR = "fld_BigDecimal != value"; + private static String BigDecimal_filterObj = "value.fld_BigDecimal != fld_BigDecimal"; + + private static String BigInteger_filterL = "value != fld_BigInteger"; + private static String BigInteger_filterR = "fld_BigInteger != value"; + private static String BigInteger_filterObj = "fld_BigInteger != value.fld_BigInteger"; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-15 (NotEquals) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NotEquals.class); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + + /** */ + public void test() { + pm = getPM(); + tx = pm.currentTransaction(); + runQueries(); } - query.close(query_result); - tx.rollback(); - } - private void run_byteQuery( - String filter, String parameter, Object parameterValue, byte value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - byte val = obj.getbyte(); - if (val == value) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns incorrect value, retrieved value: " - + val - + ", byte parameter value: " - + value - + ", Object parameter value: " - + parameterValue, - filter, - parameter); - } - cnt++; + /** */ + private void runQueries() + { + Boolean trueBoolean = Boolean.TRUE; + Boolean falseBoolean = Boolean.FALSE; + run_booleanQuery(boolean_filterL, booleanParameter, trueBoolean, true, 6); + run_booleanQuery(boolean_filterL, booleanParameter, falseBoolean, false, 4); + run_booleanQuery(boolean_filterR, booleanParameter, trueBoolean, true, 6); + run_booleanQuery(boolean_filterR, booleanParameter, falseBoolean, false, 4); + run_booleanQuery(boolean_filterL, BooleanParameter, trueBoolean, true, 6); + run_booleanQuery(boolean_filterL, BooleanParameter, falseBoolean, false, 4); + run_booleanQuery(boolean_filterR, BooleanParameter, trueBoolean, true, 6); + run_booleanQuery(boolean_filterR, BooleanParameter, falseBoolean, false, 4); + run_booleanQuery(boolean_filterT, null, null, true, 6); + run_booleanQuery(boolean_filterF, null, null, false, 4); + AllTypes alltypes = new AllTypes(); + alltypes.setboolean(true); + run_booleanQuery(boolean_filterObj, AllTypesParameter, alltypes, true, 6); + alltypes.setboolean(false); + run_booleanQuery(boolean_filterObj, AllTypesParameter, alltypes, false, 4); + + run_byteQuery(byte_filterL, byteParameter, Byte.valueOf((byte)50), (byte)50, 8); + run_byteQuery(byte_filterR, byteParameter, Byte.valueOf(Byte.MIN_VALUE), Byte.MIN_VALUE, 9); + run_byteQuery(byte_filterL, ByteParameter, Byte.valueOf((byte)20), (byte)20, 10); + run_byteQuery(byte_filterR, ByteParameter, Byte.valueOf(Byte.MAX_VALUE), Byte.MAX_VALUE, 9); + run_byteQuery(byte_filterL, shortParameter, Short.valueOf((short)50), (byte)50, 8); + run_byteQuery(byte_filterR, shortParameter, Short.valueOf((short)50), (byte)50, 8); + run_byteQuery(byte_filterL, ShortParameter, Short.valueOf((short)-100), (byte)-100, 9); + run_byteQuery(byte_filterR, ShortParameter, Short.valueOf((short)-100), (byte)-100, 9); + run_byteQuery(byte_filterL, charParameter, Character.valueOf((char)50), (byte)50, 8); + run_byteQuery(byte_filterR, charParameter, Character.valueOf((char)50), (byte)50, 8); + run_byteQuery(byte_filterL, CharacterParameter, Character.valueOf((char)50), (byte)50, 8); + run_byteQuery(byte_filterR, CharacterParameter, Character.valueOf((char)100), (byte)100, 9); + run_byteQuery(byte_filterL, intParameter, Integer.valueOf(50), (byte)50, 8); + run_byteQuery(byte_filterR, intParameter, Integer.valueOf(50), (byte)50, 8); + run_byteQuery(byte_filterL, IntegerParameter, Integer.valueOf(-100), (byte)-100, 9); + run_byteQuery(byte_filterR, IntegerParameter, Integer.valueOf(-100), (byte)-100, 9); + run_byteQuery(byte_filterL, longParameter, Long.valueOf(50), (byte)50, 8); + run_byteQuery(byte_filterR, longParameter, Long.valueOf(50), (byte)50, 8); + run_byteQuery(byte_filterL, LongParameter, Long.valueOf(-100), (byte)-100, 9); + run_byteQuery(byte_filterR, LongParameter, Long.valueOf(-100), (byte)-100, 9); + run_byteQuery(byte_filterL, floatParameter, Float.valueOf((float)50), (byte)50, 8); + run_byteQuery(byte_filterR, floatParameter, Float.valueOf((float)50), (byte)50, 8); + run_byteQuery(byte_filterL, FloatParameter, Float.valueOf((float)-100), (byte)-100, 9); + run_byteQuery(byte_filterR, FloatParameter, Float.valueOf((float)-100), (byte)-100, 9); + run_byteQuery(byte_filterL, doubleParameter, Double.valueOf(50), (byte)50, 8); + run_byteQuery(byte_filterR, doubleParameter, Double.valueOf(50), (byte)50, 8); + run_byteQuery(byte_filterL, DoubleParameter, Double.valueOf(-100), (byte)-100, 9); + run_byteQuery(byte_filterR, DoubleParameter, Double.valueOf(-100), (byte)-100, 9); + run_byteQuery(byte_filterL, BigIntegerParameter, new BigInteger("50"), (byte)50, 8); + run_byteQuery(byte_filterR, BigIntegerParameter, new BigInteger("-100"), (byte)-100, 9); + run_byteQuery(byte_filterL, BigDecimalParameter, new BigDecimal("100.0"), (byte)100, 9); + run_byteQuery(byte_filterR, BigDecimalParameter, new BigDecimal("10.0"), (byte)10, 9); + alltypes.setbyte((byte)50); + run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte)50, 8); + alltypes.setbyte((byte)45); + run_byteQuery(byte_filterObj, AllTypesParameter, alltypes, (byte)45, 10); + run_byteQuery(byte_filterVal, null, null, (byte)100, 9); + + run_shortQuery(short_filterL, shortParameter, Short.valueOf((short)100), (short)100, 8); + run_shortQuery(short_filterR, shortParameter, Short.valueOf((short)100), (short)100, 8); + run_shortQuery(short_filterL, ShortParameter, Short.valueOf(Short.MIN_VALUE), Short.MIN_VALUE, 9); + run_shortQuery(short_filterR, ShortParameter, Short.valueOf((short)253), (short)253, 10); + run_shortQuery(short_filterR, shortParameter, Short.valueOf((short)1000), (short)1000, 9); + run_shortQuery(short_filterL, byteParameter, Byte.valueOf((byte)75), (short)75, 10); + run_shortQuery(short_filterR, byteParameter, Byte.valueOf((byte)75), (short)75, 10); + run_shortQuery(short_filterL, ByteParameter, Byte.valueOf((byte)100), (short)100, 8); + run_shortQuery(short_filterR, ByteParameter, Byte.valueOf((byte)100), (short)100, 8); + run_shortQuery(short_filterL, charParameter, Character.valueOf((char)75), (short)75, 10); + run_shortQuery(short_filterR, charParameter, Character.valueOf((char)75), (short)75, 10); + run_shortQuery(short_filterL, CharacterParameter, Character.valueOf((char)100), (short)100, 8); + run_shortQuery(short_filterR, CharacterParameter, Character.valueOf((char)100), (short)100, 8); + run_shortQuery(short_filterL, intParameter, Integer.valueOf(-10000), (short)-10000, 9); + run_shortQuery(short_filterR, intParameter, Integer.valueOf(-10000), (short)-10000, 9); + run_shortQuery(short_filterL, IntegerParameter, Integer.valueOf(10000), (short)10000, 9); + run_shortQuery(short_filterR, IntegerParameter, Integer.valueOf(10000), (short)10000, 9); + run_shortQuery(short_filterL, longParameter, Long.valueOf(10000), (short) 10000, 9); + run_shortQuery(short_filterR, longParameter, Long.valueOf(10000), (short) 10000, 9); + run_shortQuery(short_filterL, LongParameter, Long.valueOf(100), (short)100, 8); + run_shortQuery(short_filterR, LongParameter, Long.valueOf(100), (short)100, 8); + run_shortQuery(short_filterL, floatParameter, Float.valueOf((float)23000), (short)23000, 10); + run_shortQuery(short_filterR, floatParameter, Float.valueOf((float)23000), (short)23000, 10); + run_shortQuery(short_filterL, FloatParameter, Float.valueOf((float)100), (short)100, 8); + run_shortQuery(short_filterR, FloatParameter, Float.valueOf((float)100), (short)100, 8); + run_shortQuery(short_filterL, doubleParameter, Double.valueOf(-10000), (short)-10000, 9); + run_shortQuery(short_filterR, doubleParameter, Double.valueOf(-10000), (short)-10000, 9); + run_shortQuery(short_filterL, DoubleParameter, Double.valueOf(23), (short)23, 10); + run_shortQuery(short_filterR, DoubleParameter, Double.valueOf(23), (short)23, 10); + run_shortQuery(short_filterL, BigIntegerParameter, new BigInteger("999"), (short)999, 10); + run_shortQuery(short_filterR, BigIntegerParameter, new BigInteger("-1000"), (short)-1000, 9); + run_shortQuery(short_filterL, BigDecimalParameter, new BigDecimal("100.0"), (short)100, 8); + run_shortQuery(short_filterR, BigDecimalParameter, new BigDecimal("0.0"), (short)0, 9); + alltypes.setshort((short)100); + run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short)100, 8); + alltypes.setshort((short)23); + run_shortQuery(short_filterObj, AllTypesParameter, alltypes, (short)23, 10); + run_shortQuery(short_filterVal, null, null, (short)1000, 9); + + run_charQuery(char_filterL, charParameter, Character.valueOf(Character.MIN_VALUE), Character.MIN_VALUE, 9); + run_charQuery(char_filterR, charParameter, Character.valueOf(Character.MAX_VALUE), Character.MAX_VALUE, 9); + run_charQuery(char_filterL, charParameter, Character.valueOf('C'), 'C', 10); + run_charQuery(char_filterR, charParameter, Character.valueOf('z'), 'z', 8); + run_charQuery(char_filterL, CharacterParameter, Character.valueOf(' '), ' ', 9); + run_charQuery(char_filterR, CharacterParameter, Character.valueOf('f'), 'f', 10); + run_charQuery(char_filterL, byteParameter, Byte.valueOf((byte)Character.MIN_VALUE), (char)Character.MIN_VALUE, 9); + run_charQuery(char_filterR, byteParameter, Byte.valueOf((byte)122), 'z', 8); + run_charQuery(char_filterL, ByteParameter, Byte.valueOf((byte)'a'), 'a', 10); + run_charQuery(char_filterR, ByteParameter, Byte.valueOf((byte)'a'), 'a', 10); + run_charQuery(char_filterL, shortParameter, Short.valueOf((short)'M'), 'M', 8); + run_charQuery(char_filterR, shortParameter, Short.valueOf((short)'M'), 'M', 8); + run_charQuery(char_filterL, ShortParameter, Short.valueOf((short)'A'), 'A', 9); + run_charQuery(char_filterR, ShortParameter, Short.valueOf((short)'A'), 'A', 9); + run_charQuery(char_filterL, intParameter, Integer.valueOf('z'), 'z', 8); + run_charQuery(char_filterR, intParameter, Integer.valueOf('z'), 'z', 8); + run_charQuery(char_filterL, IntegerParameter, Integer.valueOf('B'), 'B', 9); + run_charQuery(char_filterR, IntegerParameter, Integer.valueOf('B'), 'B', 9); + run_charQuery(char_filterL, longParameter, Long.valueOf('z'), 'z', 8); + run_charQuery(char_filterR, longParameter, Long.valueOf('z'), 'z', 8); + run_charQuery(char_filterL, LongParameter, Long.valueOf('B'), 'B', 9); + run_charQuery(char_filterR, LongParameter, Long.valueOf('B'), 'B', 9); + run_charQuery(char_filterL, floatParameter, Float.valueOf((float)123.222), 'x', 10); + run_charQuery(char_filterR, floatParameter, Float.valueOf((float)123.222), 'x', 10); + run_charQuery(char_filterL, FloatParameter, Float.valueOf((float)'z'), 'z', 8); + run_charQuery(char_filterR, FloatParameter, Float.valueOf((float)'z'), 'z', 8); + run_charQuery(char_filterL, doubleParameter, Double.valueOf('B'), 'B', 9); + run_charQuery(char_filterR, doubleParameter, Double.valueOf('B'), 'B', 9); + run_charQuery(char_filterL, DoubleParameter, Double.valueOf('A'), 'A', 9); + run_charQuery(char_filterR, DoubleParameter, Double.valueOf('A'), 'A', 9); + run_charQuery(char_filterL, BigIntegerParameter, new BigInteger("65"), 'A', 9); // 'A' == 65 + run_charQuery(char_filterR, BigIntegerParameter, new BigInteger("122"), 'z', 8); // 'z' == 122 + run_charQuery(char_filterL, BigDecimalParameter, new BigDecimal("65.0"), 'A', 9); + run_charQuery(char_filterR, BigDecimalParameter, new BigDecimal("77.0"), 'M', 8); // 'M' == 77 + alltypes.setchar('A'); + run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'A', 9); + alltypes.setchar('b'); + run_charQuery(char_filterObj, AllTypesParameter, alltypes, 'b', 10); + run_charQuery(char_filterVal, null, null, 'M', 8); + + run_intQuery(int_filterL, intParameter, Integer.valueOf(AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, 9); + run_intQuery(int_filterR, intParameter, Integer.valueOf(AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, 9); + run_intQuery(int_filterR, intParameter, Integer.valueOf(23), 23, 10); + run_intQuery(int_filterL, IntegerParameter, Integer.valueOf(1000000), 1000000, 9); + run_intQuery(int_filterR, IntegerParameter, Integer.valueOf(1000), 1000, 9); + run_intQuery(int_filterL, byteParameter, Byte.valueOf((byte)100), 100, 8); + run_intQuery(int_filterR, byteParameter, Byte.valueOf((byte)0), 0, 9); + run_intQuery(int_filterL, ByteParameter, Byte.valueOf((byte)100), 100, 8); + run_intQuery(int_filterR, ByteParameter, Byte.valueOf((byte)0), 0, 9); + run_intQuery(int_filterL, shortParameter, Short.valueOf((short)10000), 10000, 9); + run_intQuery(int_filterR, shortParameter, Short.valueOf((short)-1000), -1000, 9); + run_intQuery(int_filterL, ShortParameter, Short.valueOf((short)-1000), -1000, 9); + run_intQuery(int_filterR, ShortParameter, Short.valueOf((short)10000), 10000, 9); + run_intQuery(int_filterL, charParameter, Character.valueOf((char)10000), 10000, 9); + run_intQuery(int_filterR, charParameter, Character.valueOf((char)0), 0, 9); + run_intQuery(int_filterL, CharacterParameter, Character.valueOf((char)100), 100, 8); + run_intQuery(int_filterR, CharacterParameter, Character.valueOf((char)10000), 10000, 9); + run_intQuery(int_filterL, longParameter, Long.valueOf(AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, 9); + run_intQuery(int_filterR, longParameter, Long.valueOf(AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, 9); + run_intQuery(int_filterL, LongParameter, Long.valueOf(10000), 10000, 9); + run_intQuery(int_filterR, LongParameter, Long.valueOf(43), 43, 10); + run_intQuery(int_filterL, floatParameter, Float.valueOf((float)AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, 9); + run_intQuery(int_filterR, floatParameter, Float.valueOf((float)AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, 9); + run_intQuery(int_filterL, FloatParameter, Float.valueOf((float)10000), 10000, 9); + run_intQuery(int_filterR, FloatParameter, Float.valueOf((float)43), 43, 10); + run_intQuery(int_filterL, doubleParameter, Double.valueOf(AllTypes.veryLargePositiveInt), AllTypes.veryLargePositiveInt, 9); + run_intQuery(int_filterR, doubleParameter, Double.valueOf(AllTypes.veryLargeNegativeInt), AllTypes.veryLargeNegativeInt, 9); + run_intQuery(int_filterL, DoubleParameter, Double.valueOf(10000), 10000, 9); + run_intQuery(int_filterR, DoubleParameter, Double.valueOf(43), 43, 10); + run_intQuery(int_filterL, BigIntegerParameter, new BigInteger("1000000"), 1000000, 9); + run_intQuery(int_filterR, BigIntegerParameter, new BigInteger("-1000000"), -1000000, 9); + run_intQuery(int_filterL, BigDecimalParameter, new BigDecimal("1000000.0"), 1000000, 9); + run_intQuery(int_filterR, BigDecimalParameter, new BigDecimal("-1000000.0"), -1000000, 9); + alltypes.setint(100); + run_intQuery(int_filterObj, AllTypesParameter, alltypes, 100, 8); + run_intQuery(int_filterVal, null, null, 1000, 9); + + run_longQuery(long_filterL, longParameter, Long.valueOf(Long.MIN_VALUE), Long.MIN_VALUE, 9); + run_longQuery(long_filterR, longParameter, Long.valueOf(Long.MAX_VALUE), Long.MAX_VALUE, 9); + run_longQuery(long_filterL, LongParameter, Long.valueOf(100), 100, 8); + run_longQuery(long_filterR, LongParameter, Long.valueOf(23), 23, 10); + run_longQuery(long_filterL, byteParameter, Byte.valueOf((byte)100), 100, 8); + run_longQuery(long_filterR, byteParameter, Byte.valueOf((byte)0), 0, 9); + run_longQuery(long_filterL, ByteParameter, Byte.valueOf((byte)100), 100, 8); + run_longQuery(long_filterR, ByteParameter, Byte.valueOf((byte)0), 0, 9); + run_longQuery(long_filterL, shortParameter, Short.valueOf((short)-1000 ), -1000, 8); + run_longQuery(long_filterR, shortParameter, Short.valueOf((short)1000), 1000, 9); + run_longQuery(long_filterL, ShortParameter, Short.valueOf((short)100), 100, 8); + run_longQuery(long_filterR, ShortParameter, Short.valueOf((short)32), 32, 10); + run_longQuery(long_filterL, charParameter, Character.valueOf((char)0), 0, 9); + run_longQuery(long_filterR, charParameter, Character.valueOf((char)100), 100, 8); + run_longQuery(long_filterL, CharacterParameter, Character.valueOf((char)23), 23, 10); + run_longQuery(long_filterR, CharacterParameter, Character.valueOf((char)0), 0, 9); + run_longQuery(long_filterL, intParameter, Integer.valueOf(100), 100, 8); + run_longQuery(long_filterR, intParameter, Integer.valueOf(0), 0, 9); + run_longQuery(long_filterL, IntegerParameter, Integer.valueOf(23), 23, 10); + run_longQuery(long_filterR, IntegerParameter, Integer.valueOf(1000000), 1000000, 9); + run_longQuery(long_filterL, floatParameter, Float.valueOf((float)-1000000.0), -1000000, 9); +// run_longQuery(long_filterR, floatParameter, Float.valueOf((float)Long.MAX_VALUE), Long.MAX_VALUE, 9); + run_longQuery(long_filterL, FloatParameter, Float.valueOf((float)100), 100, 8); + run_longQuery(long_filterR, FloatParameter, Float.valueOf((float)32), 32, 10); + run_longQuery(long_filterL, doubleParameter, Double.valueOf(-1000000.0), -1000000, 9); +// run_longQuery(long_filterR, doubleParameter, Double.valueOf((double)Long.MAX_VALUE), Long.MAX_VALUE, 9); + run_longQuery(long_filterL, DoubleParameter, Double.valueOf(100), 100, 8); + run_longQuery(long_filterR, DoubleParameter, Double.valueOf(32), 32, 10); + run_longQuery(long_filterL, BigIntegerParameter, new BigInteger("1000000"), 1000000, 9); + run_longQuery(long_filterR, BigIntegerParameter, new BigInteger("-1000000"), -1000000, 9); + run_longQuery(long_filterL, BigDecimalParameter, new BigDecimal("10000.0"), 10000, 10); + run_longQuery(long_filterR, BigDecimalParameter, new BigDecimal("-1000000.0"), -1000000, 9); + alltypes.setlong(100); + run_longQuery(long_filterObj, AllTypesParameter, alltypes, 100, 8); + run_longQuery(long_filterVal, null, null, 1000000, 9); + + run_floatQuery(float_filterL, floatParameter, Float.valueOf(100.0f), 100.0f, 8); + run_floatQuery(float_filterR, floatParameter, Float.valueOf(100.0f), 100.0f, 8); + run_floatQuery(float_filterL, FloatParameter, Float.valueOf((float)0.0), 0.0f, 9); + run_floatQuery(float_filterR, FloatParameter, Float.valueOf((float)4.0), 4.0f, 10); + run_floatQuery(float_filterL, byteParameter, Byte.valueOf((byte)0), 0.0f, 9); + run_floatQuery(float_filterR, byteParameter, Byte.valueOf((byte)23), 23.0f, 10); + run_floatQuery(float_filterL, ByteParameter, Byte.valueOf((byte)34), 34.0f, 10); + run_floatQuery(float_filterR, ByteParameter, Byte.valueOf((byte)100), 100.0f, 8); + run_floatQuery(float_filterL, shortParameter, Short.valueOf((short)0), 0.0f, 9); + run_floatQuery(float_filterR, shortParameter, Short.valueOf((short)23), 23.0f, 10); + run_floatQuery(float_filterL, ShortParameter, Short.valueOf((short)34), 34.0f, 10); + run_floatQuery(float_filterR, ShortParameter, Short.valueOf((short)100), 100.0f, 8); + run_floatQuery(float_filterL, charParameter, Character.valueOf((char)0), 0.0f, 9); + run_floatQuery(float_filterR, charParameter, Character.valueOf((char)23), 23.0f, 10); + run_floatQuery(float_filterL, CharacterParameter, Character.valueOf((char)34), 34.0f, 10); + run_floatQuery(float_filterR, CharacterParameter, Character.valueOf((char)100), 100.0f, 8); + run_floatQuery(float_filterL, intParameter, Integer.valueOf(50000000), 50000000.0f, 9); + run_floatQuery(float_filterR, intParameter, Integer.valueOf(23), 23.0f, 10); + run_floatQuery(float_filterL, IntegerParameter, Integer.valueOf(34), 34.0f, 10); + run_floatQuery(float_filterR, IntegerParameter, Integer.valueOf(100), 100.0f, 8); + run_floatQuery(float_filterL, longParameter, Long.valueOf(50000000), 50000000.0f, 9); + run_floatQuery(float_filterR, longParameter, Long.valueOf(23), 23.0f, 10); + run_floatQuery(float_filterL, LongParameter, Long.valueOf(34), 34.0f, 10); + run_floatQuery(float_filterR, LongParameter, Long.valueOf(100), 100.0f, 8); + run_floatQuery(float_filterL, doubleParameter, Double.valueOf(50000000.0f), 50000000.0f, 9); + run_floatQuery(float_filterR, doubleParameter, Double.valueOf(0.0f), 0.0f, 9); + run_floatQuery(float_filterL, DoubleParameter, Double.valueOf(0.0f), 0.0f, 9); + run_floatQuery(float_filterR, DoubleParameter, Double.valueOf(100.0f), 100.0f, 8); + run_floatQuery(float_filterL, BigIntegerParameter, new BigInteger("0"), 0.0f, 9); + run_floatQuery(float_filterR, BigIntegerParameter, new BigInteger("1000000000"), 1000000000.0f, 9); + run_floatQuery(float_filterL, BigDecimalParameter, new BigDecimal("-234.23"), -234.23f, 9); + run_floatQuery(float_filterR, BigDecimalParameter, new BigDecimal("100.0"), 100.0f, 8); + alltypes.setfloat(23.23f); + run_floatQuery(float_filterObj, AllTypesParameter, alltypes, 23.23f, 10); + run_floatQuery(float_filterVal, null, null, 100.0f, 8); + + run_doubleQuery(double_filterL, doubleParameter, Double.valueOf(350.5), 350.5, 9); + run_doubleQuery(double_filterR, doubleParameter, Double.valueOf(350.5), 350.5, 9); + run_doubleQuery(double_filterL, DoubleParameter, Double.valueOf(0.0), 0.0, 9); + run_doubleQuery(double_filterR, DoubleParameter, Double.valueOf(23.34), 23.34, 10); + run_doubleQuery(double_filterL, byteParameter, Byte.valueOf((byte)100), 100.0, 8); + run_doubleQuery(double_filterR, byteParameter, Byte.valueOf((byte)0), 0.0, 9); + run_doubleQuery(double_filterL, ByteParameter, Byte.valueOf((byte)23), 23.0, 10); + run_doubleQuery(double_filterR, ByteParameter, Byte.valueOf((byte)100), 100.0, 8); + run_doubleQuery(double_filterL, shortParameter, Short.valueOf((short)100), 100.0, 8); + run_doubleQuery(double_filterR, shortParameter, Short.valueOf((short)0), 0.0, 9); + run_doubleQuery(double_filterL, ShortParameter, Short.valueOf((short)23), 23.0, 10); + run_doubleQuery(double_filterR, ShortParameter, Short.valueOf((short)100), 100.0, 8); + run_doubleQuery(double_filterL, intParameter, Integer.valueOf(100), 100.0, 8); + run_doubleQuery(double_filterR, intParameter, Integer.valueOf(0), 0.0, 9); + run_doubleQuery(double_filterL, IntegerParameter, Integer.valueOf(23), 23.0, 10); + run_doubleQuery(double_filterR, IntegerParameter, Integer.valueOf(100), 100.0, 8); + run_doubleQuery(double_filterL, longParameter, Long.valueOf(100), 100.0, 8); + run_doubleQuery(double_filterR, longParameter, Long.valueOf(0), 0.0, 9); + run_doubleQuery(double_filterL, LongParameter, Long.valueOf(23), 23.0, 10); + run_doubleQuery(double_filterR, LongParameter, Long.valueOf(100), 100.0, 8); + run_doubleQuery(double_filterL, floatParameter, Float.valueOf(0.0f), 0.0, 9); + run_doubleQuery(double_filterR, floatParameter, Float.valueOf(100.0f), 100.0, 8); + run_doubleQuery(double_filterL, FloatParameter, Float.valueOf(100.0f), 100.0, 8); + run_doubleQuery(double_filterR, FloatParameter, Float.valueOf(69.96f), 69.96, 10); + run_doubleQuery(double_filterL, BigIntegerParameter, new BigInteger("50000000"), 50000000.0, 9); + run_doubleQuery(double_filterR, BigIntegerParameter, new BigInteger("1000000000"), 1000000000.0, 9); + run_doubleQuery(double_filterL, BigDecimalParameter, new BigDecimal("350.5"), 350.5, 9); + run_doubleQuery(double_filterR, BigDecimalParameter, new BigDecimal("-234234.234"), -234234.234, 9); + alltypes.setdouble(0.0); + run_doubleQuery(double_filterObj, AllTypesParameter, alltypes, 0.0, 9); + run_doubleQuery(double_filterVal, null, null, 100.0, 8); + + run_BooleanQuery(Boolean_filterL, booleanParameter, trueBoolean, trueBoolean, 6); + run_BooleanQuery(Boolean_filterL, booleanParameter, falseBoolean, falseBoolean, 4); + run_BooleanQuery(Boolean_filterR, booleanParameter, trueBoolean, trueBoolean, 6); + run_BooleanQuery(Boolean_filterR, booleanParameter, falseBoolean, falseBoolean, 4); + run_BooleanQuery(Boolean_filterL, BooleanParameter, trueBoolean, trueBoolean, 6); + run_BooleanQuery(Boolean_filterL, BooleanParameter, falseBoolean, falseBoolean, 4); + run_BooleanQuery(Boolean_filterR, BooleanParameter, trueBoolean, trueBoolean, 6); + run_BooleanQuery(Boolean_filterR, BooleanParameter, falseBoolean, falseBoolean, 4); + run_BooleanQuery(Boolean_filterT, null, trueBoolean, trueBoolean, 6); + run_BooleanQuery(Boolean_filterF, null, falseBoolean, falseBoolean, 4); + alltypes.setBoolean(trueBoolean); + run_BooleanQuery(Boolean_filterObj, AllTypesParameter, alltypes, trueBoolean, 6); + alltypes.setBoolean(falseBoolean); + run_BooleanQuery(Boolean_filterObj, AllTypesParameter, alltypes, falseBoolean, 4); + + run_ByteQuery(Byte_filterL, byteParameter, Byte.valueOf((byte)50), Byte.valueOf((byte)50), 8); + run_ByteQuery(Byte_filterR, byteParameter, Byte.valueOf(Byte.MIN_VALUE), Byte.valueOf(Byte.MIN_VALUE), 9); + run_ByteQuery(Byte_filterL, ByteParameter, Byte.valueOf((byte)20), Byte.valueOf((byte)20), 10); + run_ByteQuery(Byte_filterR, ByteParameter, Byte.valueOf(Byte.MAX_VALUE), Byte.valueOf(Byte.MAX_VALUE), 9); + run_ByteQuery(Byte_filterL, shortParameter, Short.valueOf((short)50), Byte.valueOf((byte)50), 8); + run_ByteQuery(Byte_filterR, shortParameter, Short.valueOf((short)50), Byte.valueOf((byte)50), 8); + run_ByteQuery(Byte_filterL, ShortParameter, Short.valueOf((short)-100), Byte.valueOf((byte)-100), 9); + run_ByteQuery(Byte_filterR, ShortParameter, Short.valueOf((short)-100), Byte.valueOf((byte)-100), 9); + run_ByteQuery(Byte_filterL, charParameter, Character.valueOf((char)50), Byte.valueOf((byte)50), 8); + run_ByteQuery(Byte_filterR, charParameter, Character.valueOf((char)50), Byte.valueOf((byte)50), 8); + run_ByteQuery(Byte_filterL, CharacterParameter, Character.valueOf((char)50), Byte.valueOf((byte)50), 8); + run_ByteQuery(Byte_filterR, CharacterParameter, Character.valueOf((char)75), Byte.valueOf((byte)75), 9); + run_ByteQuery(Byte_filterL, intParameter, Integer.valueOf(50), Byte.valueOf((byte)50), 8); + run_ByteQuery(Byte_filterR, intParameter, Integer.valueOf(50), Byte.valueOf((byte)50), 8); + run_ByteQuery(Byte_filterL, IntegerParameter, Integer.valueOf(50), Byte.valueOf((byte)50), 8); + run_ByteQuery(Byte_filterR, IntegerParameter, Integer.valueOf(75), Byte.valueOf((byte)75), 9); + run_ByteQuery(Byte_filterL, longParameter, Long.valueOf(50), Byte.valueOf((byte)50), 8); + run_ByteQuery(Byte_filterR, longParameter, Long.valueOf(50), Byte.valueOf((byte)50), 8); + run_ByteQuery(Byte_filterL, LongParameter, Long.valueOf(-100), Byte.valueOf((byte)-100), 9); + run_ByteQuery(Byte_filterR, LongParameter, Long.valueOf(-100), Byte.valueOf((byte)-100), 9); + run_ByteQuery(Byte_filterL, floatParameter, Float.valueOf((float)50), Byte.valueOf((byte)50), 8); + run_ByteQuery(Byte_filterR, floatParameter, Float.valueOf((float)50), Byte.valueOf((byte)50), 8); + run_ByteQuery(Byte_filterL, FloatParameter, Float.valueOf((float)-100), Byte.valueOf((byte)-100), 9); + run_ByteQuery(Byte_filterR, FloatParameter, Float.valueOf((float)-100), Byte.valueOf((byte)-100), 9); + run_ByteQuery(Byte_filterL, doubleParameter, Double.valueOf(50), Byte.valueOf((byte)50), 8); + run_ByteQuery(Byte_filterR, doubleParameter, Double.valueOf(50), Byte.valueOf((byte)50), 8); + run_ByteQuery(Byte_filterL, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte)-100), 9); + run_ByteQuery(Byte_filterR, DoubleParameter, Double.valueOf(-100), Byte.valueOf((byte)-100), 9); + run_ByteQuery(Byte_filterL, BigIntegerParameter, new BigInteger("50"), Byte.valueOf((byte)50), 8); + run_ByteQuery(Byte_filterR, BigIntegerParameter, new BigInteger("-100"), Byte.valueOf((byte)-100), 9); + run_ByteQuery(Byte_filterL, BigDecimalParameter, new BigDecimal("100.0"), Byte.valueOf((byte)100), 9); + run_ByteQuery(Byte_filterR, BigDecimalParameter, new BigDecimal("10.0"), Byte.valueOf((byte)10), 9); + Byte val = Byte.valueOf((byte)50); + alltypes.setByte(val); + run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, 8); + val = Byte.valueOf((byte)45); + alltypes.setByte(val); + run_ByteQuery(Byte_filterObj, AllTypesParameter, alltypes, val, 10); + run_ByteQuery(Byte_filterVal, null, null, Byte.valueOf((byte)100), 9); + + run_ShortQuery(Short_filterL, shortParameter, Short.valueOf((short)100), Short.valueOf((short)100), 8); + run_ShortQuery(Short_filterR, shortParameter, Short.valueOf((short)100), Short.valueOf((short)100), 8); + run_ShortQuery(Short_filterL, ShortParameter, Short.valueOf(Short.MIN_VALUE), Short.valueOf(Short.MIN_VALUE), 9); + run_ShortQuery(Short_filterR, ShortParameter, Short.valueOf((short)253), Short.valueOf((short)253), 10); + run_ShortQuery(Short_filterR, shortParameter, Short.valueOf((short)1000), Short.valueOf((short)1000), 9); + run_ShortQuery(Short_filterL, byteParameter, Byte.valueOf((byte)75), Short.valueOf((short)75), 10); + run_ShortQuery(Short_filterR, byteParameter, Byte.valueOf((byte)75), Short.valueOf((short)75), 10); + run_ShortQuery(Short_filterL, ByteParameter, Byte.valueOf((byte)100), Short.valueOf((short)100), 8); + run_ShortQuery(Short_filterR, ByteParameter, Byte.valueOf((byte)100), Short.valueOf((short)100), 8); + run_ShortQuery(Short_filterL, charParameter, Character.valueOf((char)75), Short.valueOf((short)75), 10); + run_ShortQuery(Short_filterR, charParameter, Character.valueOf((char)75), Short.valueOf((short)75), 10); + run_ShortQuery(Short_filterL, CharacterParameter, Character.valueOf((char)100), Short.valueOf((short)100), 8); + run_ShortQuery(Short_filterR, CharacterParameter, Character.valueOf((char)100), Short.valueOf((short)100), 8); + run_ShortQuery(Short_filterL, intParameter, Integer.valueOf(-10000), Short.valueOf((short)-10000), 9); + run_ShortQuery(Short_filterR, intParameter, Integer.valueOf(-10000), Short.valueOf((short)-10000), 9); + run_ShortQuery(Short_filterL, IntegerParameter, Integer.valueOf(10000), Short.valueOf((short)10000), 9); + run_ShortQuery(Short_filterR, IntegerParameter, Integer.valueOf(10000), Short.valueOf((short)10000), 9); + run_ShortQuery(Short_filterL, longParameter, Long.valueOf(10000), Short.valueOf((short) 10000), 9); + run_ShortQuery(Short_filterR, longParameter, Long.valueOf(10000), Short.valueOf((short) 10000), 9); + run_ShortQuery(Short_filterL, LongParameter, Long.valueOf(100), Short.valueOf((short)100), 8); + run_ShortQuery(Short_filterR, LongParameter, Long.valueOf(100), Short.valueOf((short)100), 8); + run_ShortQuery(Short_filterL, floatParameter, Float.valueOf((float)23000), Short.valueOf((short)23000), 10); + run_ShortQuery(Short_filterR, floatParameter, Float.valueOf((float)23000), Short.valueOf((short)23000), 10); + run_ShortQuery(Short_filterL, FloatParameter, Float.valueOf((float)100), Short.valueOf((short)100), 8); + run_ShortQuery(Short_filterR, FloatParameter, Float.valueOf((float)100), Short.valueOf((short)100), 8); + run_ShortQuery(Short_filterL, doubleParameter, Double.valueOf(-10000), Short.valueOf((short)-10000), 9); + run_ShortQuery(Short_filterR, doubleParameter, Double.valueOf(-10000), Short.valueOf((short)-10000), 9); + run_ShortQuery(Short_filterL, DoubleParameter, Double.valueOf(23), Short.valueOf((short)23), 10); + run_ShortQuery(Short_filterR, DoubleParameter, Double.valueOf(23), Short.valueOf((short)23), 10); + run_ShortQuery(Short_filterL, BigIntegerParameter, new BigInteger("999"), Short.valueOf((short)999), 10); + run_ShortQuery(Short_filterR, BigIntegerParameter, new BigInteger("-1000"), Short.valueOf((short)-1000), 9); + run_ShortQuery(Short_filterL, BigDecimalParameter, new BigDecimal("100.0"), Short.valueOf((short)100), 8); + run_ShortQuery(Short_filterR, BigDecimalParameter, new BigDecimal("10000.0"), Short.valueOf((short)10000), 9); + Short sval = Short.valueOf((short)100); + alltypes.setShort(sval); + run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, 8); + sval = Short.valueOf((short)23); + alltypes.setShort(sval); + run_ShortQuery(Short_filterObj, AllTypesParameter, alltypes, sval, 10); + run_ShortQuery(Short_filterVal, null, null, Short.valueOf((short)-1000), 9); + + run_CharacterQuery(Character_filterL, charParameter, Character.valueOf(Character.MIN_VALUE), Character.valueOf(Character.MIN_VALUE), 9); + run_CharacterQuery(Character_filterR, charParameter, Character.valueOf(Character.MAX_VALUE), Character.valueOf(Character.MAX_VALUE), 9); + run_CharacterQuery(Character_filterL, charParameter, Character.valueOf('C'), Character.valueOf('C'), 10); + run_CharacterQuery(Character_filterR, charParameter, Character.valueOf('z'), Character.valueOf('z'), 8); + run_CharacterQuery(Character_filterL, CharacterParameter, Character.valueOf(' '), Character.valueOf(' '), 9); + run_CharacterQuery(Character_filterR, CharacterParameter, Character.valueOf('f'), Character.valueOf('f'), 10); + run_CharacterQuery(Character_filterL, byteParameter, Byte.valueOf((byte)Character.MIN_VALUE), Character.valueOf((char)Character.MIN_VALUE), 9); + run_CharacterQuery(Character_filterR, ByteParameter, Byte.valueOf((byte)'a'), Character.valueOf('a'), 10); + run_CharacterQuery(Character_filterL, shortParameter, Short.valueOf((short)'M'), Character.valueOf('M'), 8); + run_CharacterQuery(Character_filterR, shortParameter, Short.valueOf((short)'F'), Character.valueOf('F'), 9); + run_CharacterQuery(Character_filterL, ShortParameter, Short.valueOf((short)'A'), Character.valueOf('A'), 9); + run_CharacterQuery(Character_filterR, ShortParameter, Short.valueOf((short)'A'), Character.valueOf('A'), 9); + run_CharacterQuery(Character_filterL, intParameter, Integer.valueOf('z'), Character.valueOf('z'), 8); + run_CharacterQuery(Character_filterR, intParameter, Integer.valueOf('z'), Character.valueOf('z'), 8); + run_CharacterQuery(Character_filterL, IntegerParameter, Integer.valueOf('B'), Character.valueOf('B'), 9); + run_CharacterQuery(Character_filterR, IntegerParameter, Integer.valueOf('B'), Character.valueOf('B'), 9); + run_CharacterQuery(Character_filterL, longParameter, Long.valueOf('z'), Character.valueOf('z'), 8); + run_CharacterQuery(Character_filterR, longParameter, Long.valueOf('z'), Character.valueOf('z'), 8); + run_CharacterQuery(Character_filterL, LongParameter, Long.valueOf('B'), Character.valueOf('B'), 9); + run_CharacterQuery(Character_filterR, LongParameter, Long.valueOf('B'), Character.valueOf('B'), 9); + run_CharacterQuery(Character_filterL, floatParameter, Float.valueOf((float)123.222), Character.valueOf('x'), 10); + run_CharacterQuery(Character_filterR, floatParameter, Float.valueOf((float)123.222), Character.valueOf('x'), 10); + run_CharacterQuery(Character_filterL, FloatParameter, Float.valueOf((float)'z'), Character.valueOf('z'), 8); + run_CharacterQuery(Character_filterR, FloatParameter, Float.valueOf((float)'z'), Character.valueOf('z'), 8); + run_CharacterQuery(Character_filterL, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), 9); + run_CharacterQuery(Character_filterR, doubleParameter, Double.valueOf('B'), Character.valueOf('B'), 9); + run_CharacterQuery(Character_filterL, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), 9); + run_CharacterQuery(Character_filterR, DoubleParameter, Double.valueOf('A'), Character.valueOf('A'), 9); + run_CharacterQuery(Character_filterL, BigIntegerParameter, new BigInteger("65"), Character.valueOf('A'), 9); // 'A' == 65 + run_CharacterQuery(Character_filterR, BigIntegerParameter, new BigInteger("122"), Character.valueOf('z'), 8); // 'z' == 122 + run_CharacterQuery(Character_filterL, BigDecimalParameter, new BigDecimal("65.000000"), Character.valueOf('A'), 9); + run_CharacterQuery(Character_filterR, BigDecimalParameter, new BigDecimal("77.0"), Character.valueOf('M'), 8); // 'M' == 77 + alltypes.setCharacter(Character.valueOf('A')); + run_CharacterQuery(Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('A'), 9); + alltypes.setCharacter(Character.valueOf('b')); + run_CharacterQuery(Character_filterObj, AllTypesParameter, alltypes, Character.valueOf('b'), 10); + run_CharacterQuery(Character_filterVal, null, null, Character.valueOf('z'), 8); + + run_IntegerQuery(Integer_filterL, intParameter, Integer.valueOf(AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), 9); + run_IntegerQuery(Integer_filterR, intParameter, Integer.valueOf(AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), 9); + run_IntegerQuery(Integer_filterR, intParameter, Integer.valueOf(23), Integer.valueOf(23), 10); + run_IntegerQuery(Integer_filterL, IntegerParameter, Integer.valueOf(1000000), Integer.valueOf(1000000), 9); + run_IntegerQuery(Integer_filterR, IntegerParameter, Integer.valueOf(1000), Integer.valueOf(1000), 9); + run_IntegerQuery(Integer_filterL, byteParameter, Byte.valueOf((byte)100), Integer.valueOf(100), 8); + run_IntegerQuery(Integer_filterR, byteParameter, Byte.valueOf((byte)0), Integer.valueOf(0), 9); + run_IntegerQuery(Integer_filterL, ByteParameter, Byte.valueOf((byte)100), Integer.valueOf(100), 8); + run_IntegerQuery(Integer_filterR, ByteParameter, Byte.valueOf((byte)0), Integer.valueOf(0), 9); + run_IntegerQuery(Integer_filterL, shortParameter, Short.valueOf((short)10000), Integer.valueOf(10000), 9); + run_IntegerQuery(Integer_filterR, shortParameter, Short.valueOf((short)-1000), Integer.valueOf(-1000), 9); + run_IntegerQuery(Integer_filterL, ShortParameter, Short.valueOf((short)-1000), Integer.valueOf(-1000), 9); + run_IntegerQuery(Integer_filterL, charParameter, Character.valueOf((char)10000), Integer.valueOf(10000), 9); + run_IntegerQuery(Integer_filterR, charParameter, Character.valueOf((char)100), Integer.valueOf(100), 8); + run_IntegerQuery(Integer_filterL, CharacterParameter, Character.valueOf((char)10000), Integer.valueOf(10000), 9); + run_IntegerQuery(Integer_filterR, CharacterParameter, Character.valueOf((char)10000), Integer.valueOf(10000), 9); + run_IntegerQuery(Integer_filterL, longParameter, Long.valueOf(AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), 9); + run_IntegerQuery(Integer_filterR, longParameter, Long.valueOf(AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), 9); + run_IntegerQuery(Integer_filterL, LongParameter, Long.valueOf(10000), Integer.valueOf(10000), 9); + run_IntegerQuery(Integer_filterR, LongParameter, Long.valueOf(43), Integer.valueOf(43), 10); + run_IntegerQuery(Integer_filterL, floatParameter, Float.valueOf((float)AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), 9); + run_IntegerQuery(Integer_filterR, floatParameter, Float.valueOf((float)AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), 9); + run_IntegerQuery(Integer_filterL, FloatParameter, Float.valueOf((float)10000), Integer.valueOf(10000), 9); + run_IntegerQuery(Integer_filterR, FloatParameter, Float.valueOf((float)43), Integer.valueOf(43), 10); + run_IntegerQuery(Integer_filterL, doubleParameter, Double.valueOf(AllTypes.veryLargePositiveInt), Integer.valueOf(AllTypes.veryLargePositiveInt), 9); + run_IntegerQuery(Integer_filterR, doubleParameter, Double.valueOf(AllTypes.veryLargeNegativeInt), Integer.valueOf(AllTypes.veryLargeNegativeInt), 9); + run_IntegerQuery(Integer_filterL, DoubleParameter, Double.valueOf(10000), Integer.valueOf(10000), 9); + run_IntegerQuery(Integer_filterR, DoubleParameter, Double.valueOf(43), Integer.valueOf(43), 10); + run_IntegerQuery(Integer_filterL, BigIntegerParameter, new BigInteger("1000000"), Integer.valueOf(1000000), 9); + run_IntegerQuery(Integer_filterR, BigIntegerParameter, new BigInteger("-1000000"), Integer.valueOf(-1000000), 9); + run_IntegerQuery(Integer_filterL, BigDecimalParameter, new BigDecimal("1000000.0"), Integer.valueOf(1000000), 9); + run_IntegerQuery(Integer_filterR, BigDecimalParameter, new BigDecimal("-100000.0"), Integer.valueOf(-100000), 10); + alltypes.setInteger(Integer.valueOf(100)); + run_IntegerQuery(Integer_filterObj, AllTypesParameter, alltypes, Integer.valueOf(100), 8); + run_IntegerQuery(Integer_filterVal, null, null, Integer.valueOf(100), 8); + + run_LongQuery(Long_filterL, longParameter, Long.valueOf(Long.MIN_VALUE), Long.valueOf(Long.MIN_VALUE), 9); + run_LongQuery(Long_filterR, longParameter, Long.valueOf(Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE), 9); + run_LongQuery(Long_filterL, LongParameter, Long.valueOf(100), Long.valueOf(100), 8); + run_LongQuery(Long_filterR, LongParameter, Long.valueOf(23), Long.valueOf(23), 10); + run_LongQuery(Long_filterL, byteParameter, Byte.valueOf((byte)100), Long.valueOf(100), 8); + run_LongQuery(Long_filterR, byteParameter, Byte.valueOf((byte)0), Long.valueOf(0), 9); + run_LongQuery(Long_filterL, ByteParameter, Byte.valueOf((byte)100), Long.valueOf(100), 8); + run_LongQuery(Long_filterR, ByteParameter, Byte.valueOf((byte)0), Long.valueOf(0), 9); + run_LongQuery(Long_filterL, shortParameter, Short.valueOf((short)-1000 ), Long.valueOf(-1000), 8); + run_LongQuery(Long_filterR, shortParameter, Short.valueOf((short)1000), Long.valueOf(1000), 9); + run_LongQuery(Long_filterL, ShortParameter, Short.valueOf((short)100), Long.valueOf(100), 8); + run_LongQuery(Long_filterR, ShortParameter, Short.valueOf((short)32), Long.valueOf(32), 10); + run_LongQuery(Long_filterL, charParameter, Character.valueOf((char)0), Long.valueOf(0), 9); + run_LongQuery(Long_filterR, charParameter, Character.valueOf((char)100), Long.valueOf(100), 8); + run_LongQuery(Long_filterL, CharacterParameter, Character.valueOf((char)23), Long.valueOf(23), 10); + run_LongQuery(Long_filterR, CharacterParameter, Character.valueOf((char)0), Long.valueOf(0), 9); + run_LongQuery(Long_filterL, intParameter, Integer.valueOf(100), Long.valueOf(100), 8); + run_LongQuery(Long_filterR, intParameter, Integer.valueOf(0), Long.valueOf(0), 9); + run_LongQuery(Long_filterL, IntegerParameter, Integer.valueOf(23), Long.valueOf(23), 10); + run_LongQuery(Long_filterR, IntegerParameter, Integer.valueOf(1000000), Long.valueOf(1000000), 9); + run_LongQuery(Long_filterL, floatParameter, Float.valueOf((float)-1000000.0), Long.valueOf(-1000000), 9); +// run_LongQuery(Long_filterR, floatParameter, Float.valueOf((float)Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE), 9); + run_LongQuery(Long_filterL, FloatParameter, Float.valueOf((float)100), Long.valueOf(100), 8); + run_LongQuery(Long_filterR, FloatParameter, Float.valueOf((float)32), Long.valueOf(32), 10); + run_LongQuery(Long_filterL, doubleParameter, Double.valueOf(-1000000.0), Long.valueOf(-1000000), 9); +// run_LongQuery(Long_filterR, doubleParameter, Double.valueOf((double)Long.MAX_VALUE), Long.valueOf(Long.MAX_VALUE), 9); + run_LongQuery(Long_filterL, DoubleParameter, Double.valueOf(100), Long.valueOf(100), 8); + run_LongQuery(Long_filterR, DoubleParameter, Double.valueOf(32), Long.valueOf(32), 10); + run_LongQuery(Long_filterL, BigIntegerParameter, new BigInteger("1000000"), Long.valueOf(1000000), 9); + run_LongQuery(Long_filterR, BigIntegerParameter, new BigInteger("-1000000"), Long.valueOf(-1000000), 9); + run_LongQuery(Long_filterL, BigDecimalParameter, new BigDecimal("-1000.0"), Long.valueOf(-1000), 8); + run_LongQuery(Long_filterR, BigDecimalParameter, new BigDecimal("-1000000.0"), Long.valueOf(-1000000), 9); + alltypes.setLong(Long.valueOf(100)); + run_LongQuery(Long_filterObj, AllTypesParameter, alltypes, Long.valueOf(100), 8); + run_LongQuery(Long_filterVal, null, null, Long.valueOf(-1000), 8); + + run_FloatQuery(Float_filterL, floatParameter, Float.valueOf(100.0f), Float.valueOf(100.0f), 8); + run_FloatQuery(Float_filterR, floatParameter, Float.valueOf(100.0f), Float.valueOf(100.0f), 8); + run_FloatQuery(Float_filterL, FloatParameter, Float.valueOf((float)0.0), Float.valueOf(0.0f), 9); + run_FloatQuery(Float_filterR, FloatParameter, Float.valueOf((float)4.0), Float.valueOf(4.0f), 10); + run_FloatQuery(Float_filterL, byteParameter, Byte.valueOf((byte)0), Float.valueOf(0.0f), 9); + run_FloatQuery(Float_filterR, byteParameter, Byte.valueOf((byte)23), Float.valueOf(23.0f), 10); + run_FloatQuery(Float_filterL, ByteParameter, Byte.valueOf((byte)34), Float.valueOf(34.0f), 10); + run_FloatQuery(Float_filterR, ByteParameter, Byte.valueOf((byte)100), Float.valueOf(100.0f), 8); + run_FloatQuery(Float_filterL, shortParameter, Short.valueOf((short)0), Float.valueOf(0.0f), 9); + run_FloatQuery(Float_filterR, shortParameter, Short.valueOf((short)23), Float.valueOf(23.0f), 10); + run_FloatQuery(Float_filterL, ShortParameter, Short.valueOf((short)34), Float.valueOf(34.0f), 10); + run_FloatQuery(Float_filterR, ShortParameter, Short.valueOf((short)100), Float.valueOf(100.0f), 8); + run_FloatQuery(Float_filterL, charParameter, Character.valueOf((char)0), Float.valueOf(0.0f), 9); + run_FloatQuery(Float_filterR, charParameter, Character.valueOf((char)23), Float.valueOf(23.0f), 10); + run_FloatQuery(Float_filterL, CharacterParameter, Character.valueOf((char)34), Float.valueOf(34.0f), 10); + run_FloatQuery(Float_filterR, CharacterParameter, Character.valueOf((char)100), Float.valueOf(100.0f), 8); + run_FloatQuery(Float_filterL, intParameter, Integer.valueOf(50000000), Float.valueOf(50000000.0f), 9); + run_FloatQuery(Float_filterR, intParameter, Integer.valueOf(23), Float.valueOf(23.0f), 10); + run_FloatQuery(Float_filterL, IntegerParameter, Integer.valueOf(34), Float.valueOf(34.0f), 10); + run_FloatQuery(Float_filterR, IntegerParameter, Integer.valueOf(100), Float.valueOf(100.0f), 8); + run_FloatQuery(Float_filterL, longParameter, Long.valueOf(50000000), Float.valueOf(50000000.0f), 9); + run_FloatQuery(Float_filterR, longParameter, Long.valueOf(23), Float.valueOf(23.0f), 10); + run_FloatQuery(Float_filterL, LongParameter, Long.valueOf(34), Float.valueOf(34.0f), 10); + run_FloatQuery(Float_filterR, LongParameter, Long.valueOf(100), Float.valueOf(100.0f), 8); + run_FloatQuery(Float_filterL, doubleParameter, Double.valueOf(50000000.0f), Float.valueOf(50000000.0f), 9); + run_FloatQuery(Float_filterR, doubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), 8); + run_FloatQuery(Float_filterL, DoubleParameter, Double.valueOf(0.0f), Float.valueOf(0.0f), 9); + run_FloatQuery(Float_filterR, DoubleParameter, Double.valueOf(100.0f), Float.valueOf(100.0f), 8); + run_FloatQuery(Float_filterL, BigIntegerParameter, new BigInteger("50000000"), Float.valueOf(50000000.0f), 9); + run_FloatQuery(Float_filterR, BigIntegerParameter, new BigInteger("1000000000"), Float.valueOf(1000000000.0f), 9); + run_FloatQuery(Float_filterL, BigDecimalParameter, new BigDecimal("350.5"), Float.valueOf(350.5f), 9); + run_FloatQuery(Float_filterR, BigDecimalParameter, new BigDecimal("50000000.0"), Float.valueOf(50000000.0f), 9); + alltypes.setFloat(Float.valueOf(23.23f)); + run_FloatQuery(Float_filterObj, AllTypesParameter, alltypes, Float.valueOf(23.23f), 10); + run_FloatQuery(Float_filterVal, null, null, Float.valueOf(100.0f), 8); + + run_DoubleQuery(Double_filterL, doubleParameter, Double.valueOf(-25.5), Double.valueOf(-25.5), 9); + run_DoubleQuery(Double_filterR, doubleParameter, Double.valueOf(-25.5), Double.valueOf(-25.5), 9); + run_DoubleQuery(Double_filterL, DoubleParameter, Double.valueOf(0.0), Double.valueOf(0.0), 9); + run_DoubleQuery(Double_filterR, DoubleParameter, Double.valueOf(23.34), Double.valueOf(23.34), 10); + run_DoubleQuery(Double_filterL, byteParameter, Byte.valueOf((byte)100), Double.valueOf(100.0), 8); + run_DoubleQuery(Double_filterR, byteParameter, Byte.valueOf((byte)0), Double.valueOf(0.0), 9); + run_DoubleQuery(Double_filterL, ByteParameter, Byte.valueOf((byte)23), Double.valueOf(23.0), 10); + run_DoubleQuery(Double_filterR, ByteParameter, Byte.valueOf((byte)100), Double.valueOf(100.0), 8); + run_DoubleQuery(Double_filterL, shortParameter, Short.valueOf((short)100), Double.valueOf(100.0), 8); + run_DoubleQuery(Double_filterR, shortParameter, Short.valueOf((short)0), Double.valueOf(0.0), 9); + run_DoubleQuery(Double_filterL, ShortParameter, Short.valueOf((short)23), Double.valueOf(23.0), 10); + run_DoubleQuery(Double_filterR, ShortParameter, Short.valueOf((short)100), Double.valueOf(100.0), 8); + run_DoubleQuery(Double_filterL, charParameter, Character.valueOf((char)100), Double.valueOf(100.0), 8); + run_DoubleQuery(Double_filterR, charParameter, Character.valueOf((char)0), Double.valueOf(0.0), 9); + run_DoubleQuery(Double_filterL, CharacterParameter, Character.valueOf((char)23), Double.valueOf(23.0), 10); + run_DoubleQuery(Double_filterR, CharacterParameter, Character.valueOf((char)100), Double.valueOf(100.0), 8); + run_DoubleQuery(Double_filterL, intParameter, Integer.valueOf(100), Double.valueOf(100.0), 8); + run_DoubleQuery(Double_filterR, intParameter, Integer.valueOf(0), Double.valueOf(0.0), 9); + run_DoubleQuery(Double_filterL, IntegerParameter, Integer.valueOf(23), Double.valueOf(23.0), 10); + run_DoubleQuery(Double_filterR, IntegerParameter, Integer.valueOf(100), Double.valueOf(100.0), 8); + run_DoubleQuery(Double_filterL, longParameter, Long.valueOf(100), Double.valueOf(100.0), 8); + run_DoubleQuery(Double_filterR, longParameter, Long.valueOf(0), Double.valueOf(0.0), 9); + run_DoubleQuery(Double_filterL, LongParameter, Long.valueOf(23), Double.valueOf(23.0), 10); + run_DoubleQuery(Double_filterR, LongParameter, Long.valueOf(100), Double.valueOf(100.0), 8); + run_DoubleQuery(Double_filterL, floatParameter, Float.valueOf(0.0f), Double.valueOf(0.0), 9); + run_DoubleQuery(Double_filterR, floatParameter, Float.valueOf(100.0f), Double.valueOf(100.0), 8); + run_DoubleQuery(Double_filterL, FloatParameter, Float.valueOf(100.0f), Double.valueOf(100.0), 8); + run_DoubleQuery(Double_filterR, FloatParameter, Float.valueOf(69.96f), Double.valueOf(69.96), 10); + run_DoubleQuery(Double_filterL, BigIntegerParameter, new BigInteger("50000000"), Double.valueOf(50000000.0f), 9); + run_DoubleQuery(Double_filterR, BigIntegerParameter, new BigInteger("1000000000"), Double.valueOf(1000000000.0f), 9); + run_DoubleQuery(Double_filterL, BigDecimalParameter, new BigDecimal("350.5"), Double.valueOf(350.5f), 9); + run_DoubleQuery(Double_filterR, BigDecimalParameter, new BigDecimal("50000000.0"), Double.valueOf(50000000.0f), 9); + alltypes.setDouble(Double.valueOf(0.0)); + run_DoubleQuery(Double_filterObj, AllTypesParameter, alltypes, Double.valueOf(0.0), 9); + run_DoubleQuery(Double_filterVal, null, null, Double.valueOf(100.0), 8); + + run_StringQuery(String_filterL, StringParameter, new String("JDO"), new String("JDO"), 9); + run_StringQuery(String_filterR, StringParameter, new String("JDBC"), new String("JDBC"), 10); + alltypes.setString(new String("abcde")); + run_StringQuery(String_filterObj, AllTypesParameter, alltypes, new String("abcde"), 9); + run_StringQuery(String_filterVal1, null, null, new String("Java"), 8); + run_StringQuery(String_filterVal2, null, null, new String(""), 9); + + run_LocaleQuery(Locale_filterL, LocaleParameter, Locale.CANADA_FRENCH, Locale.CANADA_FRENCH, 10); + run_LocaleQuery(Locale_filterR, LocaleParameter, Locale.US, Locale.US, 9); + alltypes.setLocale(Locale.UK); + run_LocaleQuery(Locale_filterObj, AllTypesParameter, alltypes, Locale.UK, 9); + + BigDecimal bd = new BigDecimal("100.0"); + run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, 8); + bd = new BigDecimal("-234234.23333"); + run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, 9); + bd = new BigDecimal("989899.33304953"); + run_BigDecimalQuery(BigDecimal_filterL, BigDecimalParameter, bd, bd, 10); + bd = new BigDecimal("-1123123.22"); + run_BigDecimalQuery(BigDecimal_filterR, BigDecimalParameter, bd, bd, 9); + alltypes.setBigDecimal(bd); + run_BigDecimalQuery(BigDecimal_filterObj, AllTypesParameter, alltypes, bd, 9); + + BigInteger bi = new BigInteger("987034534985043985"); + run_BigIntegerQuery(BigInteger_filterL, BigIntegerParameter, bi, bi, 9); + bi = new BigInteger("-999999999999999999"); + run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, 9); + bi = new BigInteger("-99999999999999999"); + run_BigIntegerQuery(BigInteger_filterR, BigIntegerParameter, bi, bi, 10); + bi = new BigInteger("1333330"); + alltypes.setBigInteger(bi); + run_BigIntegerQuery(BigInteger_filterObj, AllTypesParameter, alltypes, bi, 9); + + GregorianCalendar gc = new GregorianCalendar(TimeZone.getTimeZone("GMT"), Locale.UK); + gc.clear(); + gc.set(1999, Calendar.DECEMBER, 31, 9, 0, 0); + Date d = gc.getTime(); + run_DateQuery(Date_filterL, DateParameter, d, d, 9); + gc.set(1992, Calendar.NOVEMBER, 22, 9, 0, 0); + d = gc.getTime(); + run_DateQuery(Date_filterR, DateParameter, d, d, 9); + gc.set(1959, Calendar.OCTOBER, 9, 9, 0, 0); + d = gc.getTime(); + run_DateQuery(Date_filterR, DateParameter, d, d, 10); + gc.set(1995, Calendar.JUNE, 14, 9, 0, 0); + d = gc.getTime(); + alltypes.setDate(d); + run_DateQuery(Date_filterObj, AllTypesParameter, alltypes, d, 9); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_shortQuery( - String filter, String parameter, Object parameterValue, short value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - short val = obj.getshort(); - if (val == value) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns incorrect value, retrieved value: " - + val - + ", short parameter value: " - + value - + ", Object parameter value: " - + parameterValue, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_booleanQuery(String filter, String parameter, Object parameterValue, boolean value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while(iter.hasNext()){ + AllTypes obj = (AllTypes) iter.next(); + boolean val = obj.getboolean(); + if( val == value ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns object with incorrect value", filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_charQuery( - String filter, String parameter, Object parameterValue, char value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - char val = obj.getchar(); - if (val == value) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns incorrect value, retrieved value: " - + val - + ", char parameter value: " - + value - + ", char integer value: " - + (int) value - + ", Object parameter value: " - + parameterValue, - filter, - parameter); - } - cnt++; + private void run_byteQuery(String filter, String parameter, Object parameterValue, byte value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + byte val = obj.getbyte(); + if( val == value ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns incorrect value, retrieved value: " + val + ", byte parameter value: " + value + ", Object parameter value: " + parameterValue, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_intQuery( - String filter, String parameter, Object parameterValue, int value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - int val = obj.getint(); - if (val == value) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns incorrect value, retrieved value: " - + val - + ", int parameter value: " - + value - + ", Object parameter value: " - + parameterValue, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_shortQuery(String filter, String parameter, Object parameterValue, short value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + short val = obj.getshort(); + if( val == value ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns incorrect value, retrieved value: " + val + ", short parameter value: " + value + ", Object parameter value: " + parameterValue, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_longQuery( - String filter, String parameter, Object parameterValue, long value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - long val = obj.getlong(); - if (val == value) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns incorrect value, retrieved value: " - + val - + ", long parameter value: " - + value - + ", Object parameter value: " - + parameterValue, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_charQuery(String filter, String parameter, Object parameterValue, char value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + char val = obj.getchar(); + if( val == value ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns incorrect value, retrieved value: " + val + ", char parameter value: " + value + ", char integer value: " + (int)value + ", Object parameter value: " + parameterValue, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_floatQuery( - String filter, String parameter, Object parameterValue, float value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - float val = obj.getfloat(); - if (val == value) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns incorrect value, retrieved value: " - + val - + ", float parameter value: " - + value - + ", Object parameter value: " - + parameterValue, - filter, - parameter); - } - cnt++; + private void run_intQuery(String filter, String parameter, Object parameterValue, int value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + int val = obj.getint(); + if( val == value ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns incorrect value, retrieved value: " + val + ", int parameter value: "+ value + ", Object parameter value: " + parameterValue, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_doubleQuery( - String filter, String parameter, Object parameterValue, double value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - double val = obj.getdouble(); - if (val == value) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns incorrect value, retrieved value: " - + val - + ", double parameter value: " - + value - + ", Object parameter value: " - + parameterValue, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_longQuery(String filter, String parameter, Object parameterValue, long value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + long val = obj.getlong(); + if( val == value ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns incorrect value, retrieved value: " + val + ", long parameter value: " + value + ", Object parameter value: " + parameterValue, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_BooleanQuery( - String filter, String parameter, Object parameterValue, Boolean value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Boolean val = obj.getBoolean(); - if (val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns object with incorrect value, retrieved value: " - + val - + ", Boolean parameter value: " - + value - + ", Object parameter value: " - + parameterValue, - filter, - parameter); - } - cnt++; + private void run_floatQuery(String filter, String parameter, Object parameterValue, float value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + float val = obj.getfloat(); + if( val == value ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns incorrect value, retrieved value: " + val + ", float parameter value: " + value + ", Object parameter value: " + parameterValue, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - query.close(query_result); - tx.rollback(); - } - private void run_ByteQuery( - String filter, String parameter, Object parameterValue, Byte value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Byte val = obj.getByte(); - if (val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns incorrect value, retrieved value: " - + val - + ", Byte parameter value: " - + value - + ", Object parameter value: " - + parameterValue, - filter, - parameter); - } - cnt++; + private void run_doubleQuery(String filter, String parameter, Object parameterValue, double value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + double val = obj.getdouble(); + if( val == value ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns incorrect value, retrieved value: " + val + ", double parameter value: " + value + ", Object parameter value: " + parameterValue, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_ShortQuery( - String filter, String parameter, Object parameterValue, Short value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Short val = obj.getShort(); - if (val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns incorrect value, retrieved value: " - + val - + ", Short parameter value: " - + value - + ", Object parameter value: " - + parameterValue, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_BooleanQuery(String filter, String parameter, Object parameterValue, Boolean value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while(iter.hasNext()){ + AllTypes obj = (AllTypes) iter.next(); + Boolean val = obj.getBoolean(); + if( val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns object with incorrect value, retrieved value: " + val + ", Boolean parameter value: " + value + ", Object parameter value: " + parameterValue, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ) + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_CharacterQuery( - String filter, String parameter, Object parameterValue, Character value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Character val = obj.getCharacter(); - if (val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns incorrect value, retrieved value: " - + val - + ", Character parameter value: " - + value - + ", Object parameter value: " - + parameterValue, - filter, - parameter); - } - cnt++; + private void run_ByteQuery(String filter, String parameter, Object parameterValue, Byte value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Byte val = obj.getByte(); + if( val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns incorrect value, retrieved value: " + val + ", Byte parameter value: " + value + ", Object parameter value: " + parameterValue, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_IntegerQuery( - String filter, String parameter, Object parameterValue, Integer value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Integer val = obj.getInteger(); - if (val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns incorrect value, retrieved value: " - + val - + ", Integer parameter value: " - + value - + ", Object parameter value: " - + parameterValue, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_ShortQuery(String filter, String parameter, Object parameterValue, Short value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Short val = obj.getShort(); + if( val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns incorrect value, retrieved value: " + val + ", Short parameter value: " + value + ", Object parameter value: " + parameterValue, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_LongQuery( - String filter, String parameter, Object parameterValue, Long value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Long val = obj.getLong(); - if (val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns incorrect value, retrieved value: " - + val - + ", Long parameter value: " - + value - + ", Object parameter value: " - + parameterValue, - filter, - parameter); - } - cnt++; + private void run_CharacterQuery(String filter, String parameter, Object parameterValue, Character value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Character val = obj.getCharacter(); + if( val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns incorrect value, retrieved value: " + val + ", Character parameter value: " + value + ", Object parameter value: " + parameterValue, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_FloatQuery( - String filter, String parameter, Object parameterValue, Float value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Float val = obj.getFloat(); - if (val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns incorrect value, retrieved value: " - + val - + ", Float parameter value: " - + value - + ", Object parameter value: " - + parameterValue, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_IntegerQuery(String filter, String parameter, Object parameterValue, Integer value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Integer val = obj.getInteger(); + if( val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns incorrect value, retrieved value: " + val + ", Integer parameter value: " + value + ", Object parameter value: " + parameterValue, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_DoubleQuery( - String filter, String parameter, Object parameterValue, Double value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Double val = obj.getDouble(); - if (val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns incorrect value, retrieved value: " - + val - + ", Double parameter value: " - + value - + ", Object parameter value: " - + parameterValue, - filter, - parameter); - } - cnt++; + private void run_LongQuery(String filter, String parameter, Object parameterValue, Long value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Long val = obj.getLong(); + if( val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns incorrect value, retrieved value: " + val + ", Long parameter value: " + value + ", Object parameter value: " + parameterValue, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_StringQuery( - String filter, String parameter, Object parameterValue, String value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - String val = obj.getString(); - if (val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns incorrect value, retrieved value: " - + val - + ", parameter value: " - + value, - filter, - parameter); - } - cnt++; - } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + private void run_FloatQuery(String filter, String parameter, Object parameterValue, Float value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Float val = obj.getFloat(); + if( val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns incorrect value, retrieved value: " + val + ", Float parameter value: " + value + ", Object parameter value: " + parameterValue, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_LocaleQuery( - String filter, String parameter, Object parameterValue, Locale value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Locale val = obj.getLocale(); - if (val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns incorrect value, retrieved value: " - + val - + ", parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_DoubleQuery(String filter, String parameter, Object parameterValue, Double value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Double val = obj.getDouble(); + if( val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns incorrect value, retrieved value: " + val + ", Double parameter value: " + value + ", Object parameter value: " + parameterValue, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); - } - query.close(query_result); - tx.rollback(); - } - private void run_BigDecimalQuery( - String filter, - String parameter, - Object parameterValue, - BigDecimal value, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - BigDecimal val = obj.getBigDecimal(); - if (val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns incorrect value, retrieved value: " - + val - + ", parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_StringQuery(String filter, String parameter, Object parameterValue, String value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + String val = obj.getString(); + if( val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns incorrect value, retrieved value: " + val + ", parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + + private void run_LocaleQuery(String filter, String parameter, Object parameterValue, Locale value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Locale val = obj.getLocale(); + if( val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns incorrect value, retrieved value: " + val + ", parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_BigIntegerQuery( - String filter, - String parameter, - Object parameterValue, - BigInteger value, - int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - BigInteger val = obj.getBigInteger(); - if (val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns incorrect value, retrieved value: " - + val - + ", parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_BigDecimalQuery(String filter, String parameter, Object parameterValue, BigDecimal value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + BigDecimal val = obj.getBigDecimal(); + if( val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns incorrect value, retrieved value: " + val + ", parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + + private void run_BigIntegerQuery(String filter, String parameter, Object parameterValue, BigInteger value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + BigInteger val = obj.getBigInteger(); + if( val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns incorrect value, retrieved value: " + val + ", parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - query.close(query_result); - tx.rollback(); - } - private void run_DateQuery( - String filter, String parameter, Object parameterValue, Date value, int expected_count) { - tx.begin(); - runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); - if (query_result == null) return; - Iterator iter = query_result.iterator(); - int cnt = 0; - while (iter.hasNext()) { - AllTypes obj = (AllTypes) iter.next(); - Date val = obj.getDate(); - if (val.equals(value)) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns incorrect value, retrieved value: " - + val - + ", parameter value: " - + value, - filter, - parameter); - } - cnt++; + private void run_DateQuery(String filter, String parameter, Object parameterValue, Date value, int expected_count) + { + tx.begin(); + runQuery(pm, filter, parameter, parameterValue, ASSERTION_FAILED); + if( query_result == null ) + return; + Iterator iter = query_result.iterator(); + int cnt = 0; + while( iter.hasNext() ){ + AllTypes obj = (AllTypes) iter.next(); + Date val = obj.getDate(); + if( val.equals(value) ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns incorrect value, retrieved value: " + val + ", parameter value: " + value, filter, parameter); + } + cnt++; + } + if( cnt != expected_count ){ + fail(ASSERTION_FAILED, "JDOQL NotEquals test returns wrong number of instances, expected " + expected_count + ", got " + cnt, filter, parameter); + } + query.close(query_result); + tx.rollback(); } - if (cnt != expected_count) { - fail( - ASSERTION_FAILED, - "JDOQL NotEquals test returns wrong number of instances, expected " - + expected_count - + ", got " - + cnt, - filter, - parameter); + + /** */ + protected void localSetUp() { + addTearDownClass(AllTypes.class); + AllTypes.load(getPM()); } - query.close(query_result); - tx.rollback(); - } - /** */ - protected void localSetUp() { - addTearDownClass(AllTypes.class); - AllTypes.load(getPM()); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/PromotionOfNumericOperands.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/PromotionOfNumericOperands.java index 468400a85..09acf6cf2 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/PromotionOfNumericOperands.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/PromotionOfNumericOperands.java @@ -5,83 +5,99 @@ * 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 + * + * 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.jdo.tck.query.jdoql.operators; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Promotion of Numeric Operands for Comparisons
    - * Keywords: query
    - * Assertion ID: A14.6.2-39.
    - * Assertion Description: Numeric operands can be promoted for comparison and arithmetic - * operations. - */ -public class PromotionOfNumericOperands extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-39 (PromotionOfNumericOperands) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(PromotionOfNumericOperands.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); + *Title: Promotion of Numeric Operands for Comparisons + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-39. + *
    + *Assertion Description: +Numeric operands can be promoted for comparison and arithmetic operations. - Collection instance9 = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 9").execute(); - - // comparison double == int - runSimplePrimitiveTypesQuery("doubleNotNull == 9", pm, instance9, ASSERTION_FAILED); - - // comparison Double == int - runSimplePrimitiveTypesQuery("doubleNull == 9", pm, instance9, ASSERTION_FAILED); - - // comparison BigInteger == int - runSimplePrimitiveTypesQuery("bigInteger == 9", pm, instance9, ASSERTION_FAILED); - - // comparison BigDecimal == int - runSimplePrimitiveTypesQuery("bigDecimal == 9", pm, instance9, ASSERTION_FAILED); + */ - // promotion in arithmetic operation: int + byte == int - runSimplePrimitiveTypesQuery("1 + byteNotNull == 10", pm, instance9, ASSERTION_FAILED); +public class PromotionOfNumericOperands extends QueryTest { - // promotion in arithmetic operation: int - short == long - runSimplePrimitiveTypesQuery("10 - shortNotNull == 1L", pm, instance9, ASSERTION_FAILED); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-39 (PromotionOfNumericOperands) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(PromotionOfNumericOperands.class); + } + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); - // promotion in arithmetic operation: long - Integer == int - runSimplePrimitiveTypesQuery("10L - intNull == 1", pm, instance9, ASSERTION_FAILED); - } + Collection instance9 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 9").execute(); + + // comparison double == int + runSimplePrimitiveTypesQuery("doubleNotNull == 9", + pm, instance9, ASSERTION_FAILED); + + // comparison Double == int + runSimplePrimitiveTypesQuery("doubleNull == 9", + pm, instance9, ASSERTION_FAILED); + + // comparison BigInteger == int + runSimplePrimitiveTypesQuery("bigInteger == 9", + pm, instance9, ASSERTION_FAILED); + + // comparison BigDecimal == int + runSimplePrimitiveTypesQuery("bigDecimal == 9", + pm, instance9, ASSERTION_FAILED); + + // promotion in arithmetic operation: int + byte == int + runSimplePrimitiveTypesQuery("1 + byteNotNull == 10", + pm, instance9, ASSERTION_FAILED); + + // promotion in arithmetic operation: int - short == long + runSimplePrimitiveTypesQuery("10 - shortNotNull == 1L", + pm, instance9, ASSERTION_FAILED); + + // promotion in arithmetic operation: long - Integer == int + runSimplePrimitiveTypesQuery("10L - intNull == 1", + pm, instance9, ASSERTION_FAILED); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PrimitiveTypes.class); - loadAndPersistPrimitiveTypes(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PrimitiveTypes.class); + loadAndPersistPrimitiveTypes(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/SignInversion.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/SignInversion.java index 2738a8b43..29c0c832a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/SignInversion.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/SignInversion.java @@ -5,94 +5,120 @@ * 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 + * + * 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.jdo.tck.query.jdoql.operators; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Sign Inversion Query Operator
    - * Keywords: query
    - * Assertion ID: A14.6.2-29.
    - * Assertion Description: The numeric sign inversion operator (-) is supported - * for all types as they are defined in the Java language. This includes the following types: - * - *
      - *
    • byte, short, int, long, char, Byte, Short Integer, Long, Character - *
    • float, double, Float, Double - *
    • BigDecimal, BigInteger - *
    - * - * The operation on object-valued fields of wrapper types (Boolean, Byte, - * Short, Integer, Long, Float, and Double), and numeric types (BigDecimal - * and BigInteger) use the wrapped values as operands. - */ -public class SignInversion extends QueryTest { + *Title: Sign Inversion Query Operator + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-29. + *
    + *Assertion Description: +The numeric sign inversion operator (-) is supported for all types +as they are defined in the Java language. This includes the following types: +
      +
    • byte, short, int, long, char, Byte, Short Integer, Long, Character
    • +
    • float, double, Float, Double
    • +
    • BigDecimal, BigInteger
    +The operation on object-valued fields of wrapper types (Boolean, Byte, +Short, Integer, Long, Float, and Double), and numeric types +(BigDecimal and BigInteger) +use the wrapped values as operands. - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.2-29 (SignInversion) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SignInversion.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); + */ - Collection instance9 = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 9").execute(); - Collection allOddInstances = - (Collection) pm.newQuery(PrimitiveTypes.class, "booleanNull").execute(); +public class SignInversion extends QueryTest { - runSimplePrimitiveTypesQuery("-id == -9", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("-byteNotNull == -9", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("-shortNotNull == -9", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("-intNotNull == -9", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("-longNotNull == -9", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("-floatNotNull == -9", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("-doubleNotNull == -9", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("-byteNull == -9", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("-shortNull == -9", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("-intNull == -9", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("-longNull == -9", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("-floatNull == -9", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("-doubleNull == -9", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("-bigDecimal == -9", pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("-bigInteger == -9", pm, instance9, ASSERTION_FAILED); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-29 (SignInversion) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SignInversion.class); + } + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + + Collection instance9 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 9").execute(); + Collection allOddInstances = (Collection)pm.newQuery( + PrimitiveTypes.class, "booleanNull").execute(); + + runSimplePrimitiveTypesQuery("-id == -9", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-byteNotNull == -9", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-shortNotNull == -9", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-intNotNull == -9", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-longNotNull == -9", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-floatNotNull == -9", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-doubleNotNull == -9", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-byteNull == -9", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-shortNull == -9", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-intNull == -9", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-longNull == -9", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-floatNull == -9", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-doubleNull == -9", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-bigDecimal == -9", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-bigInteger == -9", + pm, instance9, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("-charNull == -79", pm, allOddInstances, ASSERTION_FAILED); - runSimplePrimitiveTypesQuery("-charNotNull == -79", pm, allOddInstances, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-charNull == -79", + pm, allOddInstances, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-charNotNull == -79", + pm, allOddInstances, ASSERTION_FAILED); - tx.commit(); - } + tx.commit(); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PrimitiveTypes.class); - loadAndPersistPrimitiveTypes(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PrimitiveTypes.class); + loadAndPersistPrimitiveTypes(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/StringConcatenation.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/StringConcatenation.java index 3b1e81b5c..0cfad87be 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/StringConcatenation.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/StringConcatenation.java @@ -5,22 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql.operators; -import java.util.HashMap; -import java.util.Map; -import javax.jdo.JDOQLTypedQuery; -import javax.jdo.query.StringExpression; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.QEmployee; @@ -28,100 +25,111 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; +import javax.jdo.query.StringExpression; +import java.util.HashMap; +import java.util.Map; + /** - * Title: String Concatenation Query Operator
    - * Keywords: query
    - * Assertion ID: A14.6.2-27.
    - * Assertion Description: The String concatenation operator (+) is - * supported for the String type only. + *Title: String Concatenation Query Operator + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-27. + *
    + *Assertion Description: +The String concatenation operator (+) is supported +for the String type only. + */ + public class StringConcatenation extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-27 (StringConcatenation) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(StringConcatenation.class); - } - - /** */ - public void testStringLiteralPlusStringLiteral() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.filter(cand.firstname.eq("emp1" + "First")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname == \"emp1\" + \"First\"", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - public void testStringFieldPlusStringLiteral() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - StringExpression paramExpr = query.stringParameter("param"); - query.filter(cand.firstname.add("Ext").eq(paramExpr)); - - Map paramValues = new HashMap<>(); - paramValues.put("param", "emp1FirstExt"); - - // Import Department twice - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname + \"Ext\" == param", - /*VARIABLES*/ null, - /*PARAMETERS*/ "String param", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-27 (StringConcatenation) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(StringConcatenation.class); + } + + /** + * + */ + public void testStringLiteralPlusStringLiteral() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.filter(cand.firstname.eq("emp1" + "First")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname == \"emp1\" + \"First\"", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + public void testStringFieldPlusStringLiteral() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + StringExpression paramExpr = query.stringParameter("param"); + query.filter(cand.firstname.add("Ext").eq(paramExpr)); + + Map paramValues = new HashMap<>(); + paramValues.put("param", "emp1FirstExt"); + + // Import Department twice + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname + \"Ext\" == param", + /*VARIABLES*/ null, + /*PARAMETERS*/ "String param", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/UnaryPlus.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/UnaryPlus.java index d97186f89..f03c4f3be 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/UnaryPlus.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/operators/UnaryPlus.java @@ -5,76 +5,86 @@ * 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 + * + * 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.jdo.tck.query.jdoql.operators; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Unary Addition Query Operator
    - * Keywords: query
    - * Assertion ID: A14.6.2-25.
    - * Assertion Description: The unary addition operator (+) is supported for all - * types as they are defined in the Java language. This includes the following types: - * - *
      - *
    • byte, short, int, long, char, Byte, Short Integer, Long, Character - *
    • float, double, Float, Double - *
    • BigDecimal, BigInteger - *
    - * - * The operation on object-valued fields of wrapper types (Boolean, Byte, - * Short, Integer, Long, Float, and Double), and numeric types ( - * BigDecimal and BigInteger) use the wrapped values as operands. - */ -public class UnaryPlus extends QueryTest { + *Title: Unary Addition Query Operator + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-25. + *
    + *Assertion Description: +The unary addition operator (+) is supported for all types as they +are defined in the Java language. This includes the following types: +
      +
    • byte, short, int, long, char, Byte, Short Integer, Long, Character
    • +
    • float, double, Float, Double
    • +
    • BigDecimal, BigInteger
    • +
    +The operation on object-valued fields of wrapper types (Boolean, Byte, +Short, Integer, Long, Float, and Double), and numeric types +(BigDecimal and BigInteger) use the wrapped values as operands. - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.2-25 (UnaryPlus) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(UnaryPlus.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - if (debug) logger.debug("\nExecuting test BinaryAddition() ..."); + */ - Transaction tx = pm.currentTransaction(); - tx.begin(); +public class UnaryPlus extends QueryTest { - Collection instance9 = (Collection) pm.newQuery(PrimitiveTypes.class, "id == 9").execute(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-25 (UnaryPlus) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(UnaryPlus.class); + } + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + if (debug) logger.debug("\nExecuting test BinaryAddition() ..."); - runSimplePrimitiveTypesQuery("+id == 9", pm, instance9, ASSERTION_FAILED); - tx.commit(); - } + Transaction tx = pm.currentTransaction(); + tx.begin(); + + Collection instance9 = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 9").execute(); + + runSimplePrimitiveTypesQuery("+id == 9", + pm, instance9, ASSERTION_FAILED); + tx.commit(); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PrimitiveTypes.class); - loadAndPersistPrimitiveTypes(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PrimitiveTypes.class); + loadAndPersistPrimitiveTypes(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/BoundParameterCheck.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/BoundParameterCheck.java index a8360c395..a305213e6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/BoundParameterCheck.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/BoundParameterCheck.java @@ -5,81 +5,91 @@ * 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 + * + * 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.jdo.tck.query.jdoql.parameters; + import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Each parameter named in the parameter declaration must be bound to a value when - * executing the query.
    - * Keywords: query parameter check
    - * Assertion ID: A14.3-3.
    - * Assertion Description: Each parameter named in the parameter declaration must be bound to - * a value when executing the query. + *Title: Each parameter named in the parameter declaration must be bound + *to a value when executing the query. + *
    + *Keywords: query parameter check + *
    + *Assertion ID: A14.3-3. + *
    + *Assertion Description: Each parameter named in the parameter + *declaration must be bound to a value when executing the query. */ -public class BoundParameterCheck extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.3-3 (BoundParameterCheck) failed: "; +public class BoundParameterCheck extends QueryTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(BoundParameterCheck.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.3-3 (BoundParameterCheck) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(BoundParameterCheck.class); + } - /** */ - public void test() { - pm = getPM(); - checkQueryParameters(pm); - pm.close(); - pm = null; - } + /** */ + public void test() { + pm = getPM(); + checkQueryParameters(pm); + pm.close(); + pm = null; + } - /** */ - void checkQueryParameters(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.declareParameters("int a"); - query.setFilter("x == 0"); - try { - Object results = query.execute(); - fail( - ASSERTION_FAILED, - "Query.execute with unbound parameter should throw JDOUserExecption."); - } catch (JDOUserException ex) { - // expected exception - if (debug) { - logger.debug("expected exception: " + ex); + /** */ + void checkQueryParameters(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.declareParameters( "int a" ); + query.setFilter( "x == 0" ); + try { + Object results = query.execute(); + fail(ASSERTION_FAILED, + "Query.execute with unbound parameter should throw JDOUserExecption."); + } + catch (JDOUserException ex) { + // expected exception + if (debug) { + logger.debug("expected exception: " + ex); + } + } + tx.rollback(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - tx.rollback(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/DomainObjectsAsParameters.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/DomainObjectsAsParameters.java index 58515ddc0..fa497588d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/DomainObjectsAsParameters.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/DomainObjectsAsParameters.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,9 +19,12 @@ import java.util.ArrayList; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.Employee; @@ -31,292 +34,317 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Domain Objects as Parameters.
    - * Keywords: query
    - * Assertion ID: A14.6.2-61
    - * Assertion Description: + *Title: Domain Objects as Parameters. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-61 + *
    + *Assertion Description: */ public class DomainObjectsAsParameters extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-61 (DomainObjectsAsParameters) failed: "; - - private Object oidDept1Copy; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DomainObjectsAsParameters.class); - } - - /** - * This methods runs a JDOQL query with an equal operator comparing a field with a parameter of a - * domain object type. - */ - public void testParameterEqual() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - String filter = "this.department == d"; - Collection expectedResult = new ArrayList<>(); - expectedResult.add((Employee) getPersistentCompanyModelInstance("emp1")); - expectedResult.add((Employee) getPersistentCompanyModelInstance("emp2")); - expectedResult.add((Employee) getPersistentCompanyModelInstance("emp3")); - Query q = pm.newQuery(Employee.class); - q.declareParameters("org.apache.jdo.tck.pc.company.Department d"); - q.setFilter(filter); - Collection results = (Collection) q.execute(getPersistentCompanyModelInstance("dept1")); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-61 (DomainObjectsAsParameters) failed: "; + + private Object oidDept1Copy; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DomainObjectsAsParameters.class); } - } - /** - * This methods runs a JDOQL query with an equal operator comparing a field with a parameter of a - * domain object type. The actual parameter is a copy of the domain object referenced by the - * employees, thus the expected result is empty. - */ - public void testParameterEqualCopy() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - String filter = "this.department == d"; - Collection expectedResult = new ArrayList<>(); - Query q = pm.newQuery(Employee.class); - q.declareParameters("org.apache.jdo.tck.pc.company.Department d"); - q.setFilter(filter); - Collection results = (Collection) q.execute(getPM().getObjectById(oidDept1Copy)); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * This methods runs a JDOQL query with an equal operator comparing a field + * with a parameter of a domain object type. + */ + public void testParameterEqual() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + String filter = "this.department == d"; + Collection expectedResult = new ArrayList<>(); + expectedResult.add((Employee)getPersistentCompanyModelInstance("emp1")); + expectedResult.add((Employee)getPersistentCompanyModelInstance("emp2")); + expectedResult.add((Employee)getPersistentCompanyModelInstance("emp3")); + Query q = pm.newQuery(Employee.class); + q.declareParameters("org.apache.jdo.tck.pc.company.Department d"); + q.setFilter(filter); + Collection results = (Collection)q.execute(getPersistentCompanyModelInstance("dept1")); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** - * This methods runs a JDOQL query with a not equal operator comparing a field with a parameter of - * a domain object type. - */ - public void testParameterNotEqual() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - String filter = "this.department != d"; - Collection expectedResult = new ArrayList<>(); - expectedResult.add((Employee) getPersistentCompanyModelInstance("emp4")); - expectedResult.add((Employee) getPersistentCompanyModelInstance("emp5")); - Query q = pm.newQuery(Employee.class); - q.declareParameters("org.apache.jdo.tck.pc.company.Department d"); - q.setFilter(filter); - Collection results = (Collection) q.execute(getPersistentCompanyModelInstance("dept1")); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * This methods runs a JDOQL query with an equal operator comparing a field + * with a parameter of a domain object type. The actual parameter is a copy of the + * domain object referenced by the employees, thus the expected result is empty. + */ + public void testParameterEqualCopy() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + String filter = "this.department == d"; + Collection expectedResult = new ArrayList<>(); + Query q = pm.newQuery(Employee.class); + q.declareParameters("org.apache.jdo.tck.pc.company.Department d"); + q.setFilter(filter); + Collection results = (Collection)q.execute(getPM().getObjectById(oidDept1Copy)); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** - * This methods runs a JDOQL query with an equal operator comparing a field with a domain object - * navigated from a parameter. - */ - public void testParameterNavigationToDomainObject() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - String filter = "this.department == e.department"; - Collection expectedResult = new ArrayList<>(); - expectedResult.add((Employee) getPersistentCompanyModelInstance("emp1")); - expectedResult.add((Employee) getPersistentCompanyModelInstance("emp2")); - expectedResult.add((Employee) getPersistentCompanyModelInstance("emp3")); - Query q = pm.newQuery(Employee.class); - q.declareParameters("org.apache.jdo.tck.pc.company.Employee e"); - q.setFilter(filter); - Collection results = (Collection) q.execute(getPersistentCompanyModelInstance("emp1")); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** + * This methods runs a JDOQL query with a not equal operator comparing a field + * with a parameter of a domain object type. + */ + public void testParameterNotEqual() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + String filter = "this.department != d"; + Collection expectedResult = new ArrayList<>(); + expectedResult.add((Employee)getPersistentCompanyModelInstance("emp4")); + expectedResult.add((Employee)getPersistentCompanyModelInstance("emp5")); + Query q = pm.newQuery(Employee.class); + q.declareParameters("org.apache.jdo.tck.pc.company.Department d"); + q.setFilter(filter); + Collection results = (Collection)q.execute(getPersistentCompanyModelInstance("dept1")); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** - * This methods runs a JDOQL query with an equal operator comparing a field with a domain object - * navigated from a parameter. - */ - public void testParameterNavigationToPrimitiveField() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - String filter = "this.salary > e.salary"; - Collection expectedResult = new ArrayList<>(); - expectedResult.add((Employee) getPersistentCompanyModelInstance("emp5")); - Query q = pm.newQuery(FullTimeEmployee.class); - q.declareParameters("org.apache.jdo.tck.pc.company.FullTimeEmployee e"); - q.setFilter(filter); - Collection results = (Collection) q.execute(getPersistentCompanyModelInstance("emp1")); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** + * This methods runs a JDOQL query with an equal operator comparing a field + * with a domain object navigated from a parameter. + */ + public void testParameterNavigationToDomainObject() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + String filter = "this.department == e.department"; + Collection expectedResult = new ArrayList<>(); + expectedResult.add((Employee)getPersistentCompanyModelInstance("emp1")); + expectedResult.add((Employee)getPersistentCompanyModelInstance("emp2")); + expectedResult.add((Employee)getPersistentCompanyModelInstance("emp3")); + Query q = pm.newQuery(Employee.class); + q.declareParameters("org.apache.jdo.tck.pc.company.Employee e"); + q.setFilter(filter); + Collection results = (Collection)q.execute(getPersistentCompanyModelInstance("emp1")); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** - * This methods runs a JDOQL query with an equal operator comparing a field with a domain object - * navigated from a parameter. - */ - public void testDirtyParameterNavigationToPrimitiveField() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - FullTimeEmployee emp1 = (FullTimeEmployee) getPersistentCompanyModelInstance("emp1"); - emp1.setSalary(5000d); - - String filter = "this.salary > e.salary"; - Collection expectedResult = new ArrayList<>(); - expectedResult.add((Employee) getPersistentCompanyModelInstance("emp2")); - expectedResult.add((Employee) getPersistentCompanyModelInstance("emp5")); - Query q = pm.newQuery(FullTimeEmployee.class); - q.declareParameters("org.apache.jdo.tck.pc.company.FullTimeEmployee e"); - q.setFilter(filter); - Collection results = (Collection) q.execute(emp1); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * This methods runs a JDOQL query with an equal operator comparing a field + * with a domain object navigated from a parameter. + */ + public void testParameterNavigationToPrimitiveField() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + String filter = "this.salary > e.salary"; + Collection expectedResult = new ArrayList<>(); + expectedResult.add((Employee)getPersistentCompanyModelInstance("emp5")); + Query q = pm.newQuery(FullTimeEmployee.class); + q.declareParameters("org.apache.jdo.tck.pc.company.FullTimeEmployee e"); + q.setFilter(filter); + Collection results = (Collection)q.execute(getPersistentCompanyModelInstance("emp1")); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** This methods runs a JDOQL query with a contains clause using a domain object parameter. */ - public void testContainsParameter() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - String filter = "this.employees.contains(e)"; - Collection expectedResult = new ArrayList<>(); - expectedResult.add((Department) getPersistentCompanyModelInstance("dept1")); - Query q = pm.newQuery(Department.class); - q.declareParameters("org.apache.jdo.tck.pc.company.Employee e"); - q.setFilter(filter); - Collection results = (Collection) q.execute(getPersistentCompanyModelInstance("emp1")); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * This methods runs a JDOQL query with an equal operator comparing a field + * with a domain object navigated from a parameter. + */ + public void testDirtyParameterNavigationToPrimitiveField() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + FullTimeEmployee emp1 = (FullTimeEmployee)getPersistentCompanyModelInstance("emp1"); + emp1.setSalary(5000d); + + String filter = "this.salary > e.salary"; + Collection expectedResult = new ArrayList<>(); + expectedResult.add((Employee)getPersistentCompanyModelInstance("emp2")); + expectedResult.add((Employee)getPersistentCompanyModelInstance("emp5")); + Query q = pm.newQuery(FullTimeEmployee.class); + q.declareParameters("org.apache.jdo.tck.pc.company.FullTimeEmployee e"); + q.setFilter(filter); + Collection results = (Collection)q.execute(emp1); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** - * This methods runs a JDOQL query with a contains clause using a navigated domain object - * parameter. - */ - public void testContainsParameterNavigation() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - String filter = "this.employees.contains(ins.employee)"; - Collection expectedResult = new ArrayList<>(); - expectedResult.add((Department) getPersistentCompanyModelInstance("dept1")); - Query q = pm.newQuery(Department.class); - q.declareParameters("org.apache.jdo.tck.pc.company.Insurance ins"); - q.setFilter(filter); - Collection results = (Collection) q.execute(getPersistentCompanyModelInstance("medicalIns1")); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * This methods runs a JDOQL query with a contains clause using a domain object parameter. + */ + public void testContainsParameter() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + String filter = "this.employees.contains(e)"; + Collection expectedResult = new ArrayList<>(); + expectedResult.add((Department)getPersistentCompanyModelInstance("dept1")); + Query q = pm.newQuery(Department.class); + q.declareParameters("org.apache.jdo.tck.pc.company.Employee e"); + q.setFilter(filter); + Collection results = (Collection)q.execute(getPersistentCompanyModelInstance("emp1")); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** This methods runs a JDOQL query with a contains clause using a collection parameter. */ - public void testParameterCollection() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - String filter = "insurances.contains(this.medicalInsurance)"; - Collection expectedResult = new ArrayList<>(); - expectedResult.add((Employee) getPersistentCompanyModelInstance("emp1")); - expectedResult.add((Employee) getPersistentCompanyModelInstance("emp3")); - expectedResult.add((Employee) getPersistentCompanyModelInstance("emp4")); - Query q = pm.newQuery(Employee.class); - q.declareParameters("java.util.Collection insurances"); - q.setFilter(filter); - Collection parameters = new ArrayList<>(); - parameters.add((MedicalInsurance) getPersistentCompanyModelInstance("medicalIns1")); - parameters.add((MedicalInsurance) getPersistentCompanyModelInstance("medicalIns3")); - parameters.add((MedicalInsurance) getPersistentCompanyModelInstance("medicalIns4")); - Collection results = (Collection) q.execute(parameters); - checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * This methods runs a JDOQL query with a contains clause using a navigated domain object parameter. + */ + public void testContainsParameterNavigation() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + String filter = "this.employees.contains(ins.employee)"; + Collection expectedResult = new ArrayList<>(); + expectedResult.add((Department)getPersistentCompanyModelInstance("dept1")); + Query q = pm.newQuery(Department.class); + q.declareParameters("org.apache.jdo.tck.pc.company.Insurance ins"); + q.setFilter(filter); + Collection results = (Collection)q.execute(getPersistentCompanyModelInstance("medicalIns1")); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - PersistenceManager pm = getPM(); - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(pm); + /** + * This methods runs a JDOQL query with a contains clause using a collection parameter. + */ + public void testParameterCollection() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + String filter = "insurances.contains(this.medicalInsurance)"; + Collection expectedResult = new ArrayList<>(); + expectedResult.add((Employee)getPersistentCompanyModelInstance("emp1")); + expectedResult.add((Employee)getPersistentCompanyModelInstance("emp3")); + expectedResult.add((Employee)getPersistentCompanyModelInstance("emp4")); + Query q = pm.newQuery(Employee.class); + q.declareParameters("java.util.Collection insurances"); + q.setFilter(filter); + Collection parameters = new ArrayList<>(); + parameters.add((MedicalInsurance)getPersistentCompanyModelInstance("medicalIns1")); + parameters.add((MedicalInsurance)getPersistentCompanyModelInstance("medicalIns3")); + parameters.add((MedicalInsurance)getPersistentCompanyModelInstance("medicalIns4")); + Collection results = (Collection)q.execute(parameters); + checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - Department dept1 = (Department) getPersistentCompanyModelInstance("dept1"); - Department dept1Copy = - new Department(9999, dept1.getName(), dept1.getCompany(), dept1.getEmployeeOfTheMonth()); - pm.makePersistent(dept1Copy); - oidDept1Copy = pm.getObjectId(dept1Copy); - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + PersistenceManager pm = getPM(); + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(pm); + + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + Department dept1 = (Department) getPersistentCompanyModelInstance("dept1"); + Department dept1Copy = new Department (9999, dept1.getName(), dept1.getCompany(), dept1.getEmployeeOfTheMonth()); + pm.makePersistent(dept1Copy); + oidDept1Copy = pm.getObjectId(dept1Copy); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/ImplicitParameters.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/ImplicitParameters.java index bd1286672..ce3f09cf5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/ImplicitParameters.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/ImplicitParameters.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -21,6 +21,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.Person; @@ -29,172 +31,171 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Implicit parameters.
    - * Keywords: query
    - * Assertion ID: A14.6.3-3.
    - * Assertion Description: Parameters implicitly declared (in the result, filter, grouping, - * ordering, or range) are identified by prepending a ":" to the parameter everywhere it appears. - * All parameter types can be determined by one of the following techniques: + *Title: Implicit parameters. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.3-3. + *
    + *Assertion Description: + * Parameters implicitly declared (in the result, filter, grouping, ordering, + * or range) are identified by prepending a ":" to the parameter + * everywhere it appears. All parameter types can be determined + * by one of the following techniques: */ public class ImplicitParameters extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.3-3 (ImplicitParameters) failed: "; - - private static final String PARAMETER = "parameterInResult"; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ImplicitParameters.class); - } - - /** */ - public void testResult() { - Object expected = - getExpectedResultOfFirstQuery( - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"})); - - Map paramValues = new HashMap<>(); - paramValues.put("param", PARAMETER); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "this, :param", - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ null, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - // TBD executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testFilter() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - - Map paramValues = new HashMap<>(); - paramValues.put("param", "emp1First"); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname == :param", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ null, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - // TBD executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testGrouping() { - Object expected = /* Note: "Development" is not a bean name! */ Arrays.asList("Development"); - - Map paramValues = new HashMap<>(); - paramValues.put("minValue", Long.valueOf(3)); - - // Import Department twice - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "department.name", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ "department.name HAVING COUNT(this) >= :minValue", - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ null, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - // TBD executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testRange() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - Map paramValues = new HashMap<>(); - paramValues.put("zero", Long.valueOf(0)); - paramValues.put("five", Long.valueOf(5)); - - // Import Department twice - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ ":zero", - /*TO*/ ":five", - /*JDOQLTyped*/ null, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - // TBD executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } - - private List getExpectedResultOfFirstQuery(List instances) { - Object[] expectedResult = new Object[instances.size()]; - for (int i = 0; i < expectedResult.length; i++) { - expectedResult[i] = new Object[] {instances.get(i), PARAMETER}; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.3-3 (ImplicitParameters) failed: "; + + private static final String PARAMETER = "parameterInResult"; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ImplicitParameters.class); + } + + /** */ + public void testResult() { + Object expected = getExpectedResultOfFirstQuery( + getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"})); + + Map paramValues = new HashMap<>(); + paramValues.put("param", PARAMETER); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "this, :param", + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ null, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + //TBD executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testFilter() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + + Map paramValues = new HashMap<>(); + paramValues.put("param", "emp1First"); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname == :param", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ null, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + //TBD executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testGrouping() { + Object expected = /* Note: "Development" is not a bean name! */ + Arrays.asList("Development"); + + Map paramValues = new HashMap<>(); + paramValues.put("minValue", Long.valueOf(3)); + + // Import Department twice + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "department.name", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ "department.name HAVING COUNT(this) >= :minValue", + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ null, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + //TBD executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testRange() { + Object expected = getTransientCompanyModelInstancesAsList(new String[] { + "emp1", "emp2", "emp3", "emp4", "emp5"}); + + Map paramValues = new HashMap<>(); + paramValues.put("zero", Long.valueOf(0)); + paramValues.put("five", Long.valueOf(5)); + + // Import Department twice + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ ":zero", + /*TO*/ ":five", + /*JDOQLTyped*/ null, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + //TBD executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } + + private List getExpectedResultOfFirstQuery(List instances) { + Object[] expectedResult = new Object[instances.size()]; + for (int i = 0; i < expectedResult.length; i++) { + expectedResult[i] = new Object[] {instances.get(i), PARAMETER}; + } + return Arrays.asList(expectedResult); } - return Arrays.asList(expectedResult); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/MixedParameters.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/MixedParameters.java index 3cd4cab00..43b6b1cd2 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/MixedParameters.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/MixedParameters.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -23,106 +23,114 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Mixed parameters.
    - * Keywords: query
    - * Assertion ID: A14.6.3-2.
    - * Assertion Description: Parameters must all be declared explicitly via declareParameters + *Title: Mixed parameters. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.3-2. + *
    + *Assertion Description: + * Parameters must all be declared explicitly via declareParameters * or all be declared implicitly in the filter. */ public class MixedParameters extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.3-2 (MixedParameters) failed: "; - - /** - * The array of invalid queries which may be executed as single string queries and as API queries. - */ - private static final QueryElementHolder[] INVALID_QUERIES = { - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname == param", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname == param1 && lastname == :param2", - /*VARIABLES*/ null, - /*PARAMETERS*/ "String param1", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null) - }; - - /** - * The array of valid queries which may be executed as single string queries and as API queries. - */ - private static final QueryElementHolder[] VALID_QUERIES = { - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname == param", - /*VARIABLES*/ null, - /*PARAMETERS*/ "String param", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname == :param", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MixedParameters.class); - } - - /** */ - public void testPositive() { - for (int i = 0; i < VALID_QUERIES.length; i++) { - compileAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], true); - compileSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], true); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.3-2 (MixedParameters) failed: "; + + /** + * The array of invalid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] INVALID_QUERIES = { + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname == param", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname == param1 && lastname == :param2", + /*VARIABLES*/ null, + /*PARAMETERS*/ "String param1", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** + * The array of valid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] VALID_QUERIES = { + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname == param", + /*VARIABLES*/ null, + /*PARAMETERS*/ "String param", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname == :param", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MixedParameters.class); + } + + /** */ + public void testPositive() { + for (int i = 0; i < VALID_QUERIES.length; i++) { + compileAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], true); + compileSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], true); + } } - } - public void testNegative() { - for (int i = 0; i < INVALID_QUERIES.length; i++) { - compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); - compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + public void testNegative() { + for (int i = 0; i < INVALID_QUERIES.length; i++) { + compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], + false); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/OrderOfParameters.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/OrderOfParameters.java index a9ce91be6..b6f1f11e2 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/OrderOfParameters.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/OrderOfParameters.java @@ -5,106 +5,111 @@ * 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 + * + * 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.jdo.tck.query.jdoql.parameters; -import java.util.List; -import javax.jdo.Query; -import javax.jdo.Transaction; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; +import org.apache.jdo.tck.query.QueryElementHolder; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.Query; +import javax.jdo.Transaction; +import java.util.List; + /** - * Title: Order of Parameters.
    - * Keywords: query
    - * Assertion ID: A14.6.13-3.
    - * Assertion Description: If implicit parameters are used, their order of appearance in the - * query determines their order for binding to positional parameters for execution. + *Title: Order of Parameters. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.13-3. + *
    + *Assertion Description: + * If implicit parameters are used, their order of appearance in the query + * determines their order for binding to positional parameters for execution. */ public class OrderOfParameters extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.13-3 (OrderOfParameters) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(OrderOfParameters.class); - } - - /** */ - public void testAPIQuery() { - // Do not use QueryElementHolder, because QueryElementHolder always uses a Map for parameter - // values - Transaction tx = pm.currentTransaction(); - Query query = null; - Object result = null; - try { - tx.begin(); - String singleStringQuery = - "select from org.apache.jdo.tck.pc.company.Person where firstname == :param1 & lastname == :param2"; - query = pm.newQuery(Person.class, "firstname == :param1 & lastname == :param2"); - result = query.execute("emp1First", "emp1Last"); - List expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - checkQueryResultWithoutOrder(ASSERTION_FAILED, singleStringQuery, result, expected); - tx.commit(); - } finally { - if (query != null) { - query.close(result); - } - if (tx.isActive()) { - tx.rollback(); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.13-3 (OrderOfParameters) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(OrderOfParameters.class); + } + + /** */ + public void testAPIQuery() { + // Do not use QueryElementHolder, because QueryElementHolder always uses a Map for parameter values + Transaction tx = pm.currentTransaction(); + Query query = null; + Object result = null; + try { + tx.begin(); + String singleStringQuery = + "select from org.apache.jdo.tck.pc.company.Person where firstname == :param1 & lastname == :param2"; + query = pm.newQuery(Person.class, "firstname == :param1 & lastname == :param2"); + result = query.execute("emp1First", "emp1Last"); + List expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + checkQueryResultWithoutOrder(ASSERTION_FAILED, singleStringQuery, result, expected); + tx.commit(); + } finally { + if (query != null) { + query.close(result); + } + if (tx.isActive()) { + tx.rollback(); + } + } } - } - /** */ - public void testSingleStringAPIQuery() { - // Do not use QueryElementHolder, because QueryElementHolder always uses a Map for parameter - // values - Transaction tx = pm.currentTransaction(); - Query query = null; - Object result = null; - try { - tx.begin(); - String singleStringQuery = - "select from org.apache.jdo.tck.pc.company.Person where firstname == :param1 & lastname == :param2"; - query = pm.newQuery(singleStringQuery); - result = query.execute("emp1First", "emp1Last"); - List expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - checkQueryResultWithoutOrder(ASSERTION_FAILED, singleStringQuery, result, expected); - tx.commit(); - } finally { - if (query != null) { - query.close(result); - } - if (tx.isActive()) { - tx.rollback(); - } + /** */ + public void testSingleStringAPIQuery() { + // Do not use QueryElementHolder, because QueryElementHolder always uses a Map for parameter values + Transaction tx = pm.currentTransaction(); + Query query = null; + Object result = null; + try { + tx.begin(); + String singleStringQuery = + "select from org.apache.jdo.tck.pc.company.Person where firstname == :param1 & lastname == :param2"; + query = pm.newQuery(singleStringQuery); + result = query.execute("emp1First", "emp1Last"); + List expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + checkQueryResultWithoutOrder(ASSERTION_FAILED, singleStringQuery, result, expected); + tx.commit(); + } finally { + if (query != null) { + query.close(result); + } + if (tx.isActive()) { + tx.rollback(); + } + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/ParameterBoundToDifferentPM.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/ParameterBoundToDifferentPM.java index 010ec0e16..a429942c5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/ParameterBoundToDifferentPM.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/ParameterBoundToDifferentPM.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,6 +20,8 @@ import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Query; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.Employee; @@ -27,68 +29,74 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Element Returned in Query Result
    - * Keywords: query
    - * Assertion ID: A14.6.1-8.
    - * Assertion Description: If a persistent instance associated with another - * PersistenceManager is passed as a parameter, JDOUserException is thrown during execute(). + *Title: Element Returned in Query Result + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.1-8. + *
    + *Assertion Description: + * If a persistent instance associated with another PersistenceManager is + * passed as a parameter, JDOUserException is thrown during execute(). */ -public class ParameterBoundToDifferentPM extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.1-8 (ParameterBoundToDifferentPM) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ParameterBoundToDifferentPM.class); - } - - /** */ - public void testNegative() { - // get parameter dept1 - getPM().currentTransaction().begin(); - Department dept1 = (Department) getPersistentCompanyModelInstance("dept1"); - getPM().currentTransaction().commit(); +public class ParameterBoundToDifferentPM extends QueryTest { - // pass parameter dept1 to query of different pm - PersistenceManager pm2 = pmf.getPersistenceManager(); - pm2.currentTransaction().begin(); - try { - Query q = pm2.newQuery(Employee.class, "department == d"); - q.declareParameters("Department d"); - try { - q.execute(dept1); - } finally { - q.closeAll(); - } - fail( - ASSERTION_FAILED, - "Query.execute should throw a JDOUserException if a query " - + "parameter is bound to a different PersistenceManager"); - } catch (JDOUserException ex) { - // expected exception - if (debug) logger.debug("caught expected exception " + ex); - } finally { - if ((pm2 != null) && !pm2.isClosed()) { - if (pm2.currentTransaction().isActive()) { - pm2.currentTransaction().rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.1-8 (ParameterBoundToDifferentPM) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ParameterBoundToDifferentPM.class); + } + + /** */ + public void testNegative() { + // get parameter dept1 + getPM().currentTransaction().begin(); + Department dept1 = (Department) getPersistentCompanyModelInstance("dept1"); + getPM().currentTransaction().commit(); + + // pass parameter dept1 to query of different pm + PersistenceManager pm2 = pmf.getPersistenceManager(); + pm2.currentTransaction().begin(); + try { + Query q = pm2.newQuery(Employee.class, "department == d"); + q.declareParameters("Department d"); + try { + q.execute(dept1); + } finally { + q.closeAll(); + } + fail(ASSERTION_FAILED, + "Query.execute should throw a JDOUserException if a query " + + "parameter is bound to a different PersistenceManager"); + } + catch (JDOUserException ex) { + // expected exception + if (debug) logger.debug("caught expected exception " + ex); + } + finally { + if ((pm2 != null) && !pm2.isClosed()) { + if (pm2.currentTransaction().isActive()) { + pm2.currentTransaction().rollback(); + } + pm2.close(); + } } - pm2.close(); - } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/ParameterDeclaredWithSameNameAsFieldOfCandidateClass.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/ParameterDeclaredWithSameNameAsFieldOfCandidateClass.java index 6893eb563..3d9f49ab0 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/ParameterDeclaredWithSameNameAsFieldOfCandidateClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/ParameterDeclaredWithSameNameAsFieldOfCandidateClass.java @@ -5,139 +5,157 @@ * 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 + * + * 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.jdo.tck.query.jdoql.parameters; + import java.util.ArrayList; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Parameter Declared with Same Name as Field of Candidate Class
    - * Keywords: query
    - * Assertion ID: A14.4-2.
    - * Assertion Description: A field of the candidate class of a Query can be - * hidden if a parameter is declared with the same name. + *Title: Parameter Declared with Same Name as Field of Candidate + Class + *
    + *Keywords: query + *
    + *Assertion ID: A14.4-2. + *
    + *Assertion Description: A field of the candidate class of a + *Query can be hidden if a parameter is declared with the same name. */ + public class ParameterDeclaredWithSameNameAsFieldOfCandidateClass extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.4-2 (ParameterDeclaredWithSameNameAsFieldOfCandidateClass) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ParameterDeclaredWithSameNameAsFieldOfCandidateClass.class); - } - - /** */ - public void testPositve() { - PersistenceManager pm = getPM(); - - runTestParameterDeclaredWithSameNameAsFieldOfCandidateClass01(pm); - runTestParameterDeclaredWithSameNameAsFieldOfCandidateClass02(pm); - } - - /** */ - void runTestParameterDeclaredWithSameNameAsFieldOfCandidateClass01(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.declareParameters("Integer x"); - query.setFilter("x == x"); - Object results = query.execute(new java.lang.Integer(2)); - - // check query result - List expected = new ArrayList(); - Object p1 = new PCPoint(0, 0); - Object p2 = new PCPoint(1, 1); - Object p3 = new PCPoint(2, 2); - Object p4 = new PCPoint(3, 3); - Object p5 = new PCPoint(4, 4); - expected.add(p1); - expected.add(p2); - expected.add(p3); - expected.add(p4); - expected.add(p5); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == x", results, expected); - if (debug) - logger.debug("\nTest ParameterDeclaredWithSameNameAsFieldOfCandidateClass - Passed"); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.4-2 (ParameterDeclaredWithSameNameAsFieldOfCandidateClass) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ParameterDeclaredWithSameNameAsFieldOfCandidateClass.class); + } + + /** */ + public void testPositve() { + PersistenceManager pm = getPM(); + + runTestParameterDeclaredWithSameNameAsFieldOfCandidateClass01(pm); + runTestParameterDeclaredWithSameNameAsFieldOfCandidateClass02(pm); + } + + /** */ + void runTestParameterDeclaredWithSameNameAsFieldOfCandidateClass01( + PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.declareParameters("Integer x"); + query.setFilter("x == x"); + Object results = query.execute(new java.lang.Integer(2)); + + // check query result + List expected = new ArrayList(); + Object p1 = new PCPoint(0, 0); + Object p2 = new PCPoint(1, 1); + Object p3 = new PCPoint(2, 2); + Object p4 = new PCPoint(3, 3); + Object p5 = new PCPoint(4, 4); + expected.add(p1); + expected.add(p2); + expected.add(p3); + expected.add(p4); + expected.add(p5); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "x == x", + results, expected); + if (debug) + logger.debug("\nTest ParameterDeclaredWithSameNameAsFieldOfCandidateClass - Passed"); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } - - /** */ - void runTestParameterDeclaredWithSameNameAsFieldOfCandidateClass02(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - - Query query = pm.newQuery(); - query.setClass(PCPoint.class); - query.setCandidates(pm.getExtent(PCPoint.class, false)); - query.declareParameters("Integer y"); - query.setFilter("y == y"); - Object results = query.execute(new java.lang.Integer(2)); - - // check query result - List expected = new ArrayList(); - Object p1 = new PCPoint(0, 0); - Object p2 = new PCPoint(1, 1); - Object p3 = new PCPoint(2, 2); - Object p4 = new PCPoint(3, 3); - Object p5 = new PCPoint(4, 4); - expected.add(p1); - expected.add(p2); - expected.add(p3); - expected.add(p4); - expected.add(p5); - expected = getFromInserted(expected); - printOutput(results, expected); - checkQueryResultWithoutOrder(ASSERTION_FAILED, "y == y", results, expected); - if (debug) - logger.debug("\nTest ParameterDeclaredWithSameNameAsFieldOfCandidateClass - Passed"); - - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + void runTestParameterDeclaredWithSameNameAsFieldOfCandidateClass02( + PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + + Query query = pm.newQuery(); + query.setClass(PCPoint.class); + query.setCandidates(pm.getExtent(PCPoint.class, false)); + query.declareParameters("Integer y"); + query.setFilter("y == y"); + Object results = query.execute(new java.lang.Integer(2)); + + // check query result + List expected = new ArrayList(); + Object p1 = new PCPoint(0, 0); + Object p2 = new PCPoint(1, 1); + Object p3 = new PCPoint(2, 2); + Object p4 = new PCPoint(3, 3); + Object p5 = new PCPoint(4, 4); + expected.add(p1); + expected.add(p2); + expected.add(p3); + expected.add(p4); + expected.add(p5); + expected = getFromInserted(expected); + printOutput(results, expected); + checkQueryResultWithoutOrder(ASSERTION_FAILED, "y == y", + results, expected); + if (debug) + logger.debug("\nTest ParameterDeclaredWithSameNameAsFieldOfCandidateClass - Passed"); + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + loadAndPersistPCPoints(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - loadAndPersistPCPoints(getPM()); - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/PrimitiveParameterPassedAsNull.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/PrimitiveParameterPassedAsNull.java index 20e33c553..bd550b716 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/PrimitiveParameterPassedAsNull.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/parameters/PrimitiveParameterPassedAsNull.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -21,59 +21,67 @@ import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Primtive type parameter executed null value
    - * Keywords: query
    - * Assertion ID: A14.6.3-1.
    - * Assertion Description: If a parameter type is specified as a primitive, the parameter - * value passed to execute() must not be null or a JDOUserException is thrown. + *Title: Primtive type parameter executed null value + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.3-1. + *
    + *Assertion Description: + * If a parameter type is specified as a primitive, the parameter value + * passed to execute() must not be null or a JDOUserException is thrown. */ -public class PrimitiveParameterPassedAsNull extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.3-1 (PrimitiveParameterPassedAsNull) failed: "; +public class PrimitiveParameterPassedAsNull extends QueryTest { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(PrimitiveParameterPassedAsNull.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.3-1 (PrimitiveParameterPassedAsNull) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(PrimitiveParameterPassedAsNull.class); + } + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); + Query q = pm.newQuery(PrimitiveTypes.class, "intNotNull == param"); + q.declareParameters("int param"); + try { + q.execute(null); + fail(ASSERTION_FAILED, + "query.execute should throw JDOUserException if the actual " + + "value of a primitive type parameter is null"); + } + catch (JDOUserException ex) { + if(debug) logger.debug("caught expected exception " + ex); + } - Query q = pm.newQuery(PrimitiveTypes.class, "intNotNull == param"); - q.declareParameters("int param"); - try { - q.execute(null); - fail( - ASSERTION_FAILED, - "query.execute should throw JDOUserException if the actual " - + "value of a primitive type parameter is null"); - } catch (JDOUserException ex) { - if (debug) logger.debug("caught expected exception " + ex); + tx.commit(); + } - tx.commit(); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PrimitiveTypes.class); - loadAndPersistPrimitiveTypes(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PrimitiveTypes.class); + loadAndPersistPrimitiveTypes(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/AggregateOnSize.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/AggregateOnSize.java index 8f141cadf..65231c8b3 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/AggregateOnSize.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/AggregateOnSize.java @@ -5,87 +5,91 @@ * 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 + * + * 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.jdo.tck.query.jdoql.subqueries; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; + import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test using an aggregate on a size expression
    - * Keywords: query aggregate size
    - * Assertion ID:
    - * Assertion Description: + *Title: Test using an aggregate on a size expression + *
    + *Keywords: query aggregate size + *
    + *Assertion ID: + *
    + *Assertion Description: */ public class AggregateOnSize extends SubqueriesTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion (AggregateOnSize) failed: "; + /** */ + private static final String ASSERTION_FAILED = + "Assertion (AggregateOnSize) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(AggregateOnSize.class); + } - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(AggregateOnSize.class); - } + /** */ + public void testMaxAndSizeInSubquery() { + PersistenceManager pm = getPM(); - /** */ - public void testMaxAndSizeInSubquery() { - PersistenceManager pm = getPM(); + List expectedResult = getTransientCompanyModelInstancesAsList( + new String[]{"dept1"}); - List expectedResult = getTransientCompanyModelInstancesAsList(new String[] {"dept1"}); + // Select departments with the maximum number of employees + String singleStringJDOQL = + "SELECT FROM " + Department.class.getName() + " WHERE this.employees.size() == " + + "(SELECT MAX(d.employees.size()) FROM " + Department.class.getName() + " d)"; - // Select departments with the maximum number of employees - String singleStringJDOQL = - "SELECT FROM " - + Department.class.getName() - + " WHERE this.employees.size() == " - + "(SELECT MAX(d.employees.size()) FROM " - + Department.class.getName() - + " d)"; + // API query + Query sub = pm.newQuery(Department.class); + sub.setResult("MAX(this.employees.size())"); + Query apiQuery = pm.newQuery(Department.class); + apiQuery.setFilter("this.employees.size() == number"); + apiQuery.addSubquery(sub, "long number", null); + executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, + false, null, expectedResult, true); - // API query - Query sub = pm.newQuery(Department.class); - sub.setResult("MAX(this.employees.size())"); - Query apiQuery = pm.newQuery(Department.class); - apiQuery.setFilter("this.employees.size() == number"); - apiQuery.addSubquery(sub, "long number", null); - executeJDOQuery( - ASSERTION_FAILED, apiQuery, singleStringJDOQL, false, null, expectedResult, true); + // API query against memory model + List allDepartments = getAllPersistentInstances(pm, Department.class); + apiQuery.setCandidates(allDepartments); + executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, + false, null, expectedResult, true); - // API query against memory model - List allDepartments = getAllPersistentInstances(pm, Department.class); - apiQuery.setCandidates(allDepartments); - executeJDOQuery( - ASSERTION_FAILED, apiQuery, singleStringJDOQL, false, null, expectedResult, true); + // single String JDOQL + Query singleStringQuery = pm.newQuery(singleStringJDOQL); + executeJDOQuery(ASSERTION_FAILED, singleStringQuery, singleStringJDOQL, + false, null, expectedResult, true); + } - // single String JDOQL - Query singleStringQuery = pm.newQuery(singleStringJDOQL); - executeJDOQuery( - ASSERTION_FAILED, singleStringQuery, singleStringJDOQL, false, null, expectedResult, true); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueries.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueries.java index 06ebcc11b..4a8112889 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueries.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueries.java @@ -5,24 +5,27 @@ * 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 + * + * 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.jdo.tck.query.jdoql.subqueries; import java.util.List; + import javax.jdo.JDOQLTypedQuery; import javax.jdo.JDOQLTypedSubquery; import javax.jdo.Query; import javax.jdo.Transaction; import javax.jdo.query.NumericExpression; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.FullTimeEmployee; @@ -32,219 +35,211 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Correlated Subqueries Without Parameters
    - * Keywords: query
    - * Assertion ID: A14.6.2-56
    - * Assertion Description: A correlated subquery is a subquery which contains references to - * expressions in the outer query. If the correlation can be expressed as a restriction of the - * candidate collection of the subquery, no parameters are needed. + *Title: Correlated Subqueries Without Parameters + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-56 + *
    + *Assertion Description: + * A correlated subquery is a subquery which contains references to expressions + * in the outer query. If the correlation can be expressed as a restriction of + * the candidate collection of the subquery, no parameters are needed. */ public class CorrelatedSubqueries extends SubqueriesTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-56 (CorrelatedSubqueries) failed: "; - - // Select employees who work more than the average of their department employees. - private static final String SINGLE_STRING_QUERY_COLLECTION_SUBQUERY = - "SELECT FROM " - + Employee.class.getName() - + " WHERE this.weeklyhours > (SELECT AVG(e.weeklyhours) FROM this.department.employees e)"; - - // Select employees who work in a department having a meeting room with the maximum roomid. - private static final String SINGLE_STRING_QUERY_LIST_SUBQUERY = - "SELECT FROM " - + Employee.class.getName() - + " WHERE (SELECT max(r.roomid) FROM this.department.meetingRooms r) == 3"; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CorrelatedSubqueries.class); - } - - /** */ - public void testCollectionApiQuery() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp4", "emp6", "emp7", "emp10"}); - - // API query - try (Query apiQuery = pm.newQuery(Employee.class)) { - Query sub = pm.newQuery(Employee.class); - sub.setResult("avg(this.weeklyhours)"); - apiQuery.setFilter("this.weeklyhours> averageWeeklyhours"); - apiQuery.addSubquery(sub, "double averageWeeklyhours", "this.department.employees"); - List emps = apiQuery.executeList(); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, SINGLE_STRING_QUERY_COLLECTION_SUBQUERY, emps, expected); - - // API query against memory model - List allEmployees = (List) pm.newQuery(Employee.class).execute(); - apiQuery.setCandidates(allEmployees); - emps = apiQuery.executeList(); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, SINGLE_STRING_QUERY_COLLECTION_SUBQUERY, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-56 (CorrelatedSubqueries) failed: "; + + // Select employees who work more than the average of their department employees. + private static final String SINGLE_STRING_QUERY_COLLECTION_SUBQUERY = + "SELECT FROM " + Employee.class.getName() + + " WHERE this.weeklyhours > (SELECT AVG(e.weeklyhours) FROM this.department.employees e)"; + + // Select employees who work in a department having a meeting room with the maximum roomid. + private static final String SINGLE_STRING_QUERY_LIST_SUBQUERY = + "SELECT FROM " + Employee.class.getName() + + " WHERE (SELECT max(r.roomid) FROM this.department.meetingRooms r) == 3"; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CorrelatedSubqueries.class); } - } - - /** */ - public void testCollectionSingleStringQuery() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp4", "emp6", "emp7", "emp10"}); - // single String JDOQL - try (Query singleStringQuery = pm.newQuery(SINGLE_STRING_QUERY_COLLECTION_SUBQUERY)) { - List emps = singleStringQuery.executeList(); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, SINGLE_STRING_QUERY_COLLECTION_SUBQUERY, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } + + /** */ + public void testCollectionApiQuery() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList( + new String[]{"emp1", "emp2", "emp4", "emp6", "emp7", "emp10"}); + + // API query + try (Query apiQuery = pm.newQuery(Employee.class)) { + Query sub = pm.newQuery(Employee.class); + sub.setResult("avg(this.weeklyhours)"); + apiQuery.setFilter("this.weeklyhours> averageWeeklyhours"); + apiQuery.addSubquery(sub, "double averageWeeklyhours", + "this.department.employees"); + List emps = apiQuery.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_COLLECTION_SUBQUERY, emps, expected); + + // API query against memory model + List allEmployees = (List)pm.newQuery(Employee.class).execute(); + apiQuery.setCandidates(allEmployees); + emps = apiQuery.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_COLLECTION_SUBQUERY, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } } - } - - /** */ - public void testCollectionJDOQLTypedQuery() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp4", "emp6", "emp7", "emp10"}); - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(Employee.class)) { - QEmployee cand = QEmployee.candidate(); - JDOQLTypedSubquery subquery = - q.subquery(cand.department.employees, Employee.class, "e"); - QEmployee candsub = QEmployee.candidate("e"); - q.filter(cand.weeklyhours.gt(subquery.selectUnique(candsub.weeklyhours.avg()))); - List emps = q.executeList(); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, SINGLE_STRING_QUERY_COLLECTION_SUBQUERY, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } + + /** */ + public void testCollectionSingleStringQuery() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList( + new String[]{"emp1", "emp2", "emp4", "emp6", "emp7", "emp10"}); + // single String JDOQL + try (Query singleStringQuery = pm.newQuery(SINGLE_STRING_QUERY_COLLECTION_SUBQUERY)) { + List emps = singleStringQuery.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_COLLECTION_SUBQUERY, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } } - } - - /** */ - public void testListApiQuery() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp7", "emp8", "emp9", "emp10"}); - - // API query - try (Query apiQuery = pm.newQuery(Employee.class)) { - Query sub = pm.newQuery(MeetingRoom.class); - sub.setResult("max(roomid)"); - apiQuery.setFilter("maxNumber == 3"); - apiQuery.addSubquery(sub, "long maxNumber", "this.department.meetingRooms"); - List emps = apiQuery.executeList(); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, SINGLE_STRING_QUERY_LIST_SUBQUERY, emps, expected); - - // API query against memory model - List allEmployees = (List) pm.newQuery(Employee.class).execute(); - apiQuery.setCandidates(allEmployees); - emps = apiQuery.executeList(); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, SINGLE_STRING_QUERY_LIST_SUBQUERY, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } + + /** */ + public void testCollectionJDOQLTypedQuery() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList( + new String[]{"emp1", "emp2", "emp4", "emp6", "emp7", "emp10"}); + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(Employee.class)) { + QEmployee cand = QEmployee.candidate(); + JDOQLTypedSubquery subquery = q.subquery(cand.department.employees, Employee.class,"e"); + QEmployee candsub = QEmployee.candidate("e"); + q.filter(cand.weeklyhours.gt(subquery.selectUnique(candsub.weeklyhours.avg()))); + List emps = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_COLLECTION_SUBQUERY, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } } - } - - /** */ - public void testListSingleStringQuery() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp7", "emp8", "emp9", "emp10"}); - // single String JDOQL - try (Query singleStringQuery = pm.newQuery(SINGLE_STRING_QUERY_LIST_SUBQUERY)) { - List emps = singleStringQuery.executeList(); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, SINGLE_STRING_QUERY_LIST_SUBQUERY, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } + + /** */ + public void testListApiQuery() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList( + new String[]{"emp7", "emp8", "emp9", "emp10"}); + + // API query + try (Query apiQuery = pm.newQuery(Employee.class)) { + Query sub = pm.newQuery(MeetingRoom.class); + sub.setResult("max(roomid)"); + apiQuery.setFilter("maxNumber == 3"); + apiQuery.addSubquery(sub, "long maxNumber", "this.department.meetingRooms"); + List emps = apiQuery.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_LIST_SUBQUERY, emps, expected); + + // API query against memory model + List allEmployees = (List)pm.newQuery(Employee.class).execute(); + apiQuery.setCandidates(allEmployees); + emps = apiQuery.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_LIST_SUBQUERY, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } } - } - - /** */ - public void testListJDOQLTypedQuery() { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp7", "emp8", "emp9", "emp10"}); - try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(Employee.class)) { - QEmployee cand = QEmployee.candidate(); - JDOQLTypedSubquery subquery = - q.subquery(cand.department.meetingRooms, MeetingRoom.class, "r"); - QMeetingRoom candsub = QMeetingRoom.candidate("r"); - q.filter(subquery.selectUnique((NumericExpression) candsub.roomid.max()).eq(3l)); - List emps = q.executeList(); - checkQueryResultWithoutOrder( - ASSERTION_FAILED, SINGLE_STRING_QUERY_COLLECTION_SUBQUERY, emps, expected); - } catch (Exception ex) { - fail(ASSERTION_FAILED, ex.getLocalizedMessage()); - } - tx.commit(); - } finally { - if (tx.isActive()) { - tx.rollback(); - } + + /** */ + public void testListSingleStringQuery() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList( + new String[]{"emp7", "emp8", "emp9", "emp10"}); + // single String JDOQL + try (Query singleStringQuery = pm.newQuery(SINGLE_STRING_QUERY_LIST_SUBQUERY)) { + List emps = singleStringQuery.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_LIST_SUBQUERY, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } + } + + /** */ + public void testListJDOQLTypedQuery() { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List expected = getTransientCompanyModelInstancesAsList( + new String[]{"emp7", "emp8", "emp9", "emp10"}); + try (JDOQLTypedQuery q = pm.newJDOQLTypedQuery(Employee.class)) { + QEmployee cand = QEmployee.candidate(); + JDOQLTypedSubquery subquery = + q.subquery(cand.department.meetingRooms, MeetingRoom.class,"r"); + QMeetingRoom candsub = QMeetingRoom.candidate("r"); + q.filter(subquery.selectUnique((NumericExpression)candsub.roomid.max()).eq(3l)); + List emps = q.executeList(); + checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_COLLECTION_SUBQUERY, emps, expected); + } catch (Exception ex) { + fail(ASSERTION_FAILED, ex.getLocalizedMessage()); + } + tx.commit(); + } finally { + if (tx.isActive()) { + tx.rollback(); + } + } } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueriesWithParameters.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueriesWithParameters.java index de86cfb14..268085854 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueriesWithParameters.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/CorrelatedSubqueriesWithParameters.java @@ -5,197 +5,185 @@ * 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 + * + * 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.jdo.tck.query.jdoql.subqueries; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Locale; + import javax.jdo.PersistenceManager; import javax.jdo.Query; + import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Support for subqueries in JDOQL
    - * Keywords: query
    - * Assertion ID: A14.6.2-57.
    - * Assertion Description: If the correlation cannot be expressed as a restriction of the - * candidate collection, the correlation is expressed as one or more parameters in the subquery - * which are bound to expressions of the outer query. + *Title: Support for subqueries in JDOQL + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-57. + *
    + *Assertion Description: + * If the correlation cannot be expressed as a restriction of the candidate + * collection, the correlation is expressed as one or more parameters in the + * subquery which are bound to expressions of the outer query. */ public class CorrelatedSubqueriesWithParameters extends SubqueriesTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-57 (CorrelatedSubqueriesWithParameters) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(CorrelatedSubqueriesWithParameters.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - runTestSubqueries01(pm); - runTestSubqueries02(pm); - runTestSubqueries03(pm); - } - - /** Test subquery: */ - void runTestSubqueries01(PersistenceManager pm) { - List expectedResult = - getTransientCompanyModelInstancesAsList(new String[] {"emp2", "emp6", "emp9"}); - - // Select employees who work more than the average of the employees - // in their department having the same manager - String singleStringJDOQL = - "SELECT FROM " - + Employee.class.getName() - + " WHERE this.weeklyhours > " - + "(SELECT AVG(e.weeklyhours) FROM this.department.employees e " - + " WHERE e.manager == this.manager)"; - - // API query - Query sub = pm.newQuery(Employee.class); - sub.setResult("avg(this.weeklyhours)"); - sub.setFilter("this.manager == :manager"); - Query apiQuery = pm.newQuery(Employee.class); - apiQuery.setFilter("this.weeklyhours> averageWeeklyhours"); - apiQuery.addSubquery( - sub, "double averageWeeklyhours", "this.department.employees", "this.manager"); - executeJDOQuery( - ASSERTION_FAILED, apiQuery, singleStringJDOQL, false, null, expectedResult, true); - - // API query against memory model - List allEmployees = getAllEmployees(pm); - apiQuery.setCandidates(allEmployees); - executeJDOQuery( - ASSERTION_FAILED, apiQuery, singleStringJDOQL, false, null, expectedResult, true); - - // single String JDOQL - Query singleStringQuery = pm.newQuery(singleStringJDOQL); - executeJDOQuery( - ASSERTION_FAILED, singleStringQuery, singleStringJDOQL, false, null, expectedResult, true); - } - - /** */ - void runTestSubqueries02(PersistenceManager pm) { - List expectedResult = getTransientCompanyModelInstancesAsList(new String[] {"emp2", "emp10"}); - - // Select employees hired after a particular date who work more - // than the average of all employees of the same manager - String singleStringJDOQL = - "SELECT FROM " - + Employee.class.getName() - + " WHERE this.hiredate > :hired && this.weeklyhours > " - + "(SELECT AVG(e.weeklyhours) FROM " - + Employee.class.getName() - + " e WHERE e.manager == this.manager)"; - - Calendar cal = Calendar.getInstance(Locale.US); - cal.set(2002, Calendar.SEPTEMBER, 1, 0, 0, 0); - Date hired = cal.getTime(); - - // API query - Query sub = pm.newQuery(Employee.class); - sub.setResult("avg(this.weeklyhours)"); - sub.setFilter("this.manager == :manager"); - Query apiQuery = pm.newQuery(Employee.class); - apiQuery.setFilter("this.hiredate > :hired && this.weeklyhours> averageWeeklyhours"); - apiQuery.addSubquery(sub, "double averageWeeklyhours", null, "this.manager"); - executeJDOQuery( - ASSERTION_FAILED, - apiQuery, - singleStringJDOQL, - false, - new Object[] {hired}, - expectedResult, - true); - - // API query against memory model - List allEmployees = getAllEmployees(pm); - apiQuery.setCandidates(allEmployees); - executeJDOQuery( - ASSERTION_FAILED, - apiQuery, - singleStringJDOQL, - false, - new Object[] {hired}, - expectedResult, - true); - - // single String JDOQL - Query singleStringQuery = pm.newQuery(singleStringJDOQL); - executeJDOQuery( - ASSERTION_FAILED, - singleStringQuery, - singleStringJDOQL, - false, - new Object[] {hired}, - expectedResult, - true); - } - - /** */ - void runTestSubqueries03(PersistenceManager pm) { - List expectedResult = - getTransientCompanyModelInstancesAsList(new String[] {"emp2", "emp6", "emp9", "emp10"}); - - // Select employees who work more than the average of all - // employees of the same manager - String singleStringJDOQL = - "SELECT FROM " - + Employee.class.getName() - + " WHERE this.weeklyhours > " - + "(SELECT AVG(e.weeklyhours) FROM " - + Employee.class.getName() - + " e WHERE e.manager == this.manager)"; - - // API query - Query sub = pm.newQuery(Employee.class); - sub.setResult("avg(this.weeklyhours)"); - sub.setFilter("this.manager == :manager"); - Query apiQuery = pm.newQuery(Employee.class); - apiQuery.setFilter("this.weeklyhours > averageWeeklyhours"); - apiQuery.addSubquery(sub, "double averageWeeklyhours", null, "this.manager"); - executeJDOQuery( - ASSERTION_FAILED, apiQuery, singleStringJDOQL, false, null, expectedResult, true); - - // API query against memory model - List allEmployees = getAllEmployees(pm); - apiQuery.setCandidates(allEmployees); - executeJDOQuery( - ASSERTION_FAILED, apiQuery, singleStringJDOQL, false, null, expectedResult, true); - - // single String JDOQL - Query singleStringQuery = pm.newQuery(singleStringJDOQL); - executeJDOQuery( - ASSERTION_FAILED, singleStringQuery, singleStringJDOQL, false, null, expectedResult, true); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-57 (CorrelatedSubqueriesWithParameters) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CorrelatedSubqueriesWithParameters.class); + } + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + runTestSubqueries01(pm); + runTestSubqueries02(pm); + runTestSubqueries03(pm); + } + + /** + * Test subquery: + */ + void runTestSubqueries01(PersistenceManager pm) { + List expectedResult = getTransientCompanyModelInstancesAsList( + new String[]{"emp2", "emp6", "emp9"}); + + // Select employees who work more than the average of the employees + // in their department having the same manager + String singleStringJDOQL = + "SELECT FROM " + Employee.class.getName() + + " WHERE this.weeklyhours > " + + "(SELECT AVG(e.weeklyhours) FROM this.department.employees e " + + " WHERE e.manager == this.manager)"; + + // API query + Query sub = pm.newQuery(Employee.class); + sub.setResult("avg(this.weeklyhours)"); + sub.setFilter("this.manager == :manager"); + Query apiQuery = pm.newQuery(Employee.class); + apiQuery.setFilter("this.weeklyhours> averageWeeklyhours"); + apiQuery.addSubquery(sub, "double averageWeeklyhours", + "this.department.employees", "this.manager"); + executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, + false, null, expectedResult, true); + + // API query against memory model + List allEmployees = getAllEmployees(pm); + apiQuery.setCandidates(allEmployees); + executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, + false, null, expectedResult, true); + + // single String JDOQL + Query singleStringQuery = pm.newQuery(singleStringJDOQL); + executeJDOQuery(ASSERTION_FAILED, singleStringQuery, singleStringJDOQL, + false, null, expectedResult, true); + } + + /** */ + void runTestSubqueries02(PersistenceManager pm) { + List expectedResult = getTransientCompanyModelInstancesAsList( + new String[]{"emp2", "emp10"}); + + // Select employees hired after a particular date who work more + // than the average of all employees of the same manager + String singleStringJDOQL = + "SELECT FROM " + Employee.class.getName() + + " WHERE this.hiredate > :hired && this.weeklyhours > " + + "(SELECT AVG(e.weeklyhours) FROM " + Employee.class.getName() + + " e WHERE e.manager == this.manager)"; + + Calendar cal = Calendar.getInstance(Locale.US); + cal.set(2002, Calendar.SEPTEMBER, 1, 0, 0, 0); + Date hired = cal.getTime(); + + // API query + Query sub = pm.newQuery(Employee.class); + sub.setResult("avg(this.weeklyhours)"); + sub.setFilter("this.manager == :manager"); + Query apiQuery = pm.newQuery(Employee.class); + apiQuery.setFilter("this.hiredate > :hired && this.weeklyhours> averageWeeklyhours"); + apiQuery.addSubquery(sub, "double averageWeeklyhours", null, "this.manager"); + executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, + false, new Object[] {hired}, expectedResult, true); + + // API query against memory model + List allEmployees = getAllEmployees(pm); + apiQuery.setCandidates(allEmployees); + executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, + false, new Object[]{hired} , expectedResult, true); + + // single String JDOQL + Query singleStringQuery = pm.newQuery(singleStringJDOQL); + executeJDOQuery(ASSERTION_FAILED, singleStringQuery, singleStringJDOQL, + false, new Object[]{hired}, expectedResult, true); + } + + /** */ + void runTestSubqueries03(PersistenceManager pm) { + List expectedResult = getTransientCompanyModelInstancesAsList( + new String[]{"emp2", "emp6", "emp9", "emp10"}); + + // Select employees who work more than the average of all + // employees of the same manager + String singleStringJDOQL = + "SELECT FROM " + Employee.class.getName() + " WHERE this.weeklyhours > " + + "(SELECT AVG(e.weeklyhours) FROM " + Employee.class.getName() + + " e WHERE e.manager == this.manager)"; + + // API query + Query sub = pm.newQuery(Employee.class); + sub.setResult("avg(this.weeklyhours)"); + sub.setFilter("this.manager == :manager"); + Query apiQuery = pm.newQuery(Employee.class); + apiQuery.setFilter("this.weeklyhours > averageWeeklyhours"); + apiQuery.addSubquery(sub, "double averageWeeklyhours", null, "this.manager"); + executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, + false, null, expectedResult, true); + + // API query against memory model + List allEmployees = getAllEmployees(pm); + apiQuery.setCandidates(allEmployees); + executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, + false, null, expectedResult, true); + + // single String JDOQL + Query singleStringQuery = pm.newQuery(singleStringJDOQL); + executeJDOQuery(ASSERTION_FAILED, singleStringQuery, singleStringJDOQL, + false, null, expectedResult, true); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } + } + + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/MultipleCallsReplaceSubquery.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/MultipleCallsReplaceSubquery.java index 6d7d6a7b4..00ca8b3a5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/MultipleCallsReplaceSubquery.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/MultipleCallsReplaceSubquery.java @@ -5,88 +5,90 @@ * 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 + * + * 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.jdo.tck.query.jdoql.subqueries; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; + import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Multiple Calls of addSubquery Replaces Previous Instance
    - * Keywords: query
    - * Assertion ID: A14.6.2-51.
    - * Assertion Description: If the same value of variableDeclaration is used to add multiple - * subqueries, the subquery replaces the previous subquery for the same named variable. + *Title: Multiple Calls of addSubquery Replaces Previous Instance + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-51. + *
    + *Assertion Description: + * If the same value of variableDeclaration is used to add multiple subqueries, + * the subquery replaces the previous subquery for the same named variable. */ public class MultipleCallsReplaceSubquery extends SubqueriesTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-51 (MultipleCallsReplaceSubquery) failed: "; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-51 (MultipleCallsReplaceSubquery) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MultipleCallsReplaceSubquery.class); + } - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MultipleCallsReplaceSubquery.class); - } + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + List expectedResult = getTransientCompanyModelInstancesAsList( + new String[]{"emp1","emp2","emp4","emp5","emp6","emp7","emp10"}); - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - List expectedResult = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp4", "emp5", "emp6", "emp7", "emp10"}); + // select employees who work more than the average of all employees + String singleStringJDOQL = + "SELECT FROM " + Employee.class.getName() + " WHERE this.weeklyhours > " + + "(SELECT AVG(e.weeklyhours) FROM " + Employee.class.getName() + " e)"; - // select employees who work more than the average of all employees - String singleStringJDOQL = - "SELECT FROM " - + Employee.class.getName() - + " WHERE this.weeklyhours > " - + "(SELECT AVG(e.weeklyhours) FROM " - + Employee.class.getName() - + " e)"; + // API query + // Query returning the weeklyhours of employee with id 1 + Query tmp = pm.newQuery(Employee.class); + tmp.setResult("this.weeklyhours"); + tmp.setFilter("this.id == 1"); + // Query returning the avg of weeklyhours of all employees + Query sub = pm.newQuery(Employee.class); + sub.setResult("avg(this.weeklyhours)"); + Query apiQuery = pm.newQuery(Employee.class); + apiQuery.setFilter("this.weeklyhours> averageWeeklyhours"); + apiQuery.addSubquery(tmp, "double averageWeeklyhours", null); + // second call of addSubquery using the same variable + // should replace the previous setting, so apiQuery should + // represent the query of singleStringJDOQL + apiQuery.addSubquery(sub, "double averageWeeklyhours", null); + executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, + false, null, expectedResult, true); + } - // API query - // Query returning the weeklyhours of employee with id 1 - Query tmp = pm.newQuery(Employee.class); - tmp.setResult("this.weeklyhours"); - tmp.setFilter("this.id == 1"); - // Query returning the avg of weeklyhours of all employees - Query sub = pm.newQuery(Employee.class); - sub.setResult("avg(this.weeklyhours)"); - Query apiQuery = pm.newQuery(Employee.class); - apiQuery.setFilter("this.weeklyhours> averageWeeklyhours"); - apiQuery.addSubquery(tmp, "double averageWeeklyhours", null); - // second call of addSubquery using the same variable - // should replace the previous setting, so apiQuery should - // represent the query of singleStringJDOQL - apiQuery.addSubquery(sub, "double averageWeeklyhours", null); - executeJDOQuery( - ASSERTION_FAILED, apiQuery, singleStringJDOQL, false, null, expectedResult, true); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/NonCorrelatedSubqueries.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/NonCorrelatedSubqueries.java index ab02c4e26..6fb1119de 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/NonCorrelatedSubqueries.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/NonCorrelatedSubqueries.java @@ -5,157 +5,146 @@ * 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 + * + * 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.jdo.tck.query.jdoql.subqueries; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Locale; +import java.util.TimeZone; + import javax.jdo.PersistenceManager; import javax.jdo.Query; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; +import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Non-correlated Subqueries
    - * Keywords: query
    - * Assertion ID: A14.6.2-55.
    - * Assertion Description: If the subquery has no references to expressions in the outer - * query the subquery is noncorrelated. + *Title: Non-correlated Subqueries + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-55. + *
    + *Assertion Description: + * If the subquery has no references to expressions in the outer query + * the subquery is noncorrelated. */ public class NonCorrelatedSubqueries extends SubqueriesTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-55 (NonCorrelatedSubqueries) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NonCorrelatedSubqueries.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - runTestSubqueries01(pm); - runTestSubqueries02(pm); - } - - /** */ - void runTestSubqueries01(PersistenceManager pm) { - List expectedResult = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp4", "emp5", "emp6", "emp7", "emp10"}); - - // select employees who work more than the average of all employees - String singleStringJDOQL = - "SELECT FROM " - + Employee.class.getName() - + " WHERE this.weeklyhours > " - + "(SELECT AVG(e.weeklyhours) FROM " - + Employee.class.getName() - + " e)"; - - // API query - Query sub = pm.newQuery(Employee.class); - sub.setResult("avg(this.weeklyhours)"); - Query apiQuery = pm.newQuery(Employee.class); - apiQuery.setFilter("this.weeklyhours> averageWeeklyhours"); - apiQuery.addSubquery(sub, "double averageWeeklyhours", null); - executeJDOQuery( - ASSERTION_FAILED, apiQuery, singleStringJDOQL, false, null, expectedResult, true); - - // API query against memory model - List allEmployees = getAllEmployees(pm); - apiQuery.setCandidates(allEmployees); - executeJDOQuery( - ASSERTION_FAILED, apiQuery, singleStringJDOQL, false, null, expectedResult, true); - - // single String JDOQL - Query singleStringQuery = pm.newQuery(singleStringJDOQL); - executeJDOQuery( - ASSERTION_FAILED, singleStringQuery, singleStringJDOQL, false, null, expectedResult, true); - } - - /** */ - void runTestSubqueries02(PersistenceManager pm) { - List expectedResult = - getTransientCompanyModelInstancesAsList(new String[] {"emp2", "emp5", "emp10"}); - - // Select employees hired after a particular date who work more - // than the average of all employees - String singleStringJDOQL = - "SELECT FROM " - + Employee.class.getName() - + " WHERE this.hiredate > :hired && " - + "this.weeklyhours> (SELECT AVG(e.weeklyhours) FROM " - + Employee.class.getName() - + " e)"; - - Calendar cal = Calendar.getInstance(Locale.US); - cal.set(2002, Calendar.SEPTEMBER, 1, 0, 0, 0); - Date hired = cal.getTime(); - - // API query - Query sub = pm.newQuery(Employee.class); - sub.setResult("avg(this.weeklyhours)"); - Query apiQuery = pm.newQuery(Employee.class); - apiQuery.setFilter("this.hiredate > :hired && this.weeklyhours > averageWeeklyhours"); - apiQuery.addSubquery(sub, "double averageWeeklyhours", null); - executeJDOQuery( - ASSERTION_FAILED, - apiQuery, - singleStringJDOQL, - false, - new Object[] {hired}, - expectedResult, - true); - - // API query against memory model - List allEmployees = getAllEmployees(pm); - apiQuery.setCandidates(allEmployees); - executeJDOQuery( - ASSERTION_FAILED, - apiQuery, - singleStringJDOQL, - false, - new Object[] {hired}, - expectedResult, - true); - - // single String JDOQL - Query singleStringQuery = pm.newQuery(singleStringJDOQL); - executeJDOQuery( - ASSERTION_FAILED, - singleStringQuery, - singleStringJDOQL, - false, - new Object[] {hired}, - expectedResult, - true); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-55 (NonCorrelatedSubqueries) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NonCorrelatedSubqueries.class); + } + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + runTestSubqueries01(pm); + runTestSubqueries02(pm); + } + + /** */ + void runTestSubqueries01(PersistenceManager pm) { + List expectedResult = getTransientCompanyModelInstancesAsList( + new String[]{"emp1","emp2","emp4","emp5","emp6","emp7","emp10"}); + + // select employees who work more than the average of all employees + String singleStringJDOQL = + "SELECT FROM " + Employee.class.getName() + + " WHERE this.weeklyhours > " + + "(SELECT AVG(e.weeklyhours) FROM " + Employee.class.getName() + " e)"; + + // API query + Query sub = pm.newQuery(Employee.class); + sub.setResult("avg(this.weeklyhours)"); + Query apiQuery = pm.newQuery(Employee.class); + apiQuery.setFilter("this.weeklyhours> averageWeeklyhours"); + apiQuery.addSubquery(sub, "double averageWeeklyhours", null); + executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, + false, null, expectedResult, true); + + // API query against memory model + List allEmployees = getAllEmployees(pm); + apiQuery.setCandidates(allEmployees); + executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, + false, null, expectedResult, true); + + // single String JDOQL + Query singleStringQuery = pm.newQuery(singleStringJDOQL); + executeJDOQuery(ASSERTION_FAILED, singleStringQuery, singleStringJDOQL, + false, null, expectedResult, true); + } + + /** */ + void runTestSubqueries02(PersistenceManager pm) { + List expectedResult = getTransientCompanyModelInstancesAsList( + new String[]{"emp2", "emp5", "emp10"}); + + // Select employees hired after a particular date who work more + // than the average of all employees + String singleStringJDOQL = + "SELECT FROM " + Employee.class.getName() + + " WHERE this.hiredate > :hired && " + + "this.weeklyhours> (SELECT AVG(e.weeklyhours) FROM " + + Employee.class.getName() + " e)"; + + Calendar cal = Calendar.getInstance(Locale.US); + cal.set(2002, Calendar.SEPTEMBER, 1, 0, 0, 0); + Date hired = cal.getTime(); + + // API query + Query sub = pm.newQuery(Employee.class); + sub.setResult("avg(this.weeklyhours)"); + Query apiQuery = pm.newQuery(Employee.class); + apiQuery.setFilter("this.hiredate > :hired && this.weeklyhours > averageWeeklyhours"); + apiQuery.addSubquery(sub, "double averageWeeklyhours", null); + executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, + false, new Object[]{hired}, expectedResult, true); + + // API query against memory model + List allEmployees = getAllEmployees(pm); + apiQuery.setCandidates(allEmployees); + executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, + false, new Object[]{hired}, expectedResult, true); + + // single String JDOQL + Query singleStringQuery = pm.newQuery(singleStringJDOQL); + executeJDOQuery(ASSERTION_FAILED, singleStringQuery, singleStringJDOQL, + false, new Object[]{hired}, expectedResult, true); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } + } + + diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/NullCandidateCollectionExpression.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/NullCandidateCollectionExpression.java index bfb125f0a..e026925f4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/NullCandidateCollectionExpression.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/NullCandidateCollectionExpression.java @@ -5,90 +5,96 @@ * 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 + * + * 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.jdo.tck.query.jdoql.subqueries; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; +import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Null Candidate Collection Expression in addSubquery
    - * Keywords: query
    - * Assertion ID: A14.6.2-53.
    - * Assertion Description: The candidateCollectionExpression is the expression from the outer - * query that represents the candidates over which the subquery is evaluated. If the trimmed value - * is the empty String, or the parameter is null, then the candidate collection is the extent of the - * candidate class. + *Title: Null Candidate Collection Expression in addSubquery + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-53. + *
    + *Assertion Description: + * The candidateCollectionExpression is the expression from the outer query that + * represents the candidates over which the subquery is evaluated. If the + * trimmed value is the empty String, or the parameter is null, then the + * candidate collection is the extent of the candidate class. */ public class NullCandidateCollectionExpression extends SubqueriesTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-53 (NullCandidateCollectionExpression) failed: "; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-53 (NullCandidateCollectionExpression) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NullCandidateCollectionExpression.class); + } + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NullCandidateCollectionExpression.class); - } + List expectedResult = getTransientCompanyModelInstancesAsList( + new String[]{"emp1","emp2","emp4","emp5","emp6","emp7","emp10"}); - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); + // select employees who work more than the average of all employees + String singleStringJDOQL = + "SELECT FROM " + Employee.class.getName() + " WHERE this.weeklyhours > " + + "(SELECT AVG(e.weeklyhours) FROM " + Employee.class.getName() + " e)"; - List expectedResult = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp4", "emp5", "emp6", "emp7", "emp10"}); + // API query + Query sub = pm.newQuery(Employee.class); + sub.setResult("avg(this.weeklyhours)"); + Query apiQuery = pm.newQuery(Employee.class); + apiQuery.setFilter("this.weeklyhours > averageWeeklyhours"); + // null candidate collection + apiQuery.addSubquery(sub, "double averageWeeklyhours", null); + executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, + false, null, expectedResult, true); - // select employees who work more than the average of all employees - String singleStringJDOQL = - "SELECT FROM " - + Employee.class.getName() - + " WHERE this.weeklyhours > " - + "(SELECT AVG(e.weeklyhours) FROM " - + Employee.class.getName() - + " e)"; + apiQuery = pm.newQuery(Employee.class); + apiQuery.setFilter("this.weeklyhours > averageWeeklyhours"); + // empty candidate collection + apiQuery.addSubquery(sub, "double averageWeeklyhours", " "); + executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, + false, null, expectedResult, true); - // API query - Query sub = pm.newQuery(Employee.class); - sub.setResult("avg(this.weeklyhours)"); - Query apiQuery = pm.newQuery(Employee.class); - apiQuery.setFilter("this.weeklyhours > averageWeeklyhours"); - // null candidate collection - apiQuery.addSubquery(sub, "double averageWeeklyhours", null); - executeJDOQuery( - ASSERTION_FAILED, apiQuery, singleStringJDOQL, false, null, expectedResult, true); + } - apiQuery = pm.newQuery(Employee.class); - apiQuery.setFilter("this.weeklyhours > averageWeeklyhours"); - // empty candidate collection - apiQuery.addSubquery(sub, "double averageWeeklyhours", " "); - executeJDOQuery( - ASSERTION_FAILED, apiQuery, singleStringJDOQL, false, null, expectedResult, true); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/NullSubqueryParameter.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/NullSubqueryParameter.java index 7faafdba9..77cdc4617 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/NullSubqueryParameter.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/NullSubqueryParameter.java @@ -5,81 +5,89 @@ * 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 + * + * 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.jdo.tck.query.jdoql.subqueries; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; +import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Null Subquery Parameter.
    - * Keywords: query
    - * Assertion ID: A14.6.2-52.
    - * Assertion Description: If the subquery parameter is null, the variable is unset, - * effectively making the variable named in the variableDeclaration unbound. + *Title: Null Subquery Parameter. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-52. + *
    + *Assertion Description: + * If the subquery parameter is null, the variable is unset, effectively + * making the variable named in the variableDeclaration unbound. */ public class NullSubqueryParameter extends SubqueriesTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-52 (NullSubqueryParameter) failed: "; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-52 (NullSubqueryParameter) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NullSubqueryParameter.class); + } - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NullSubqueryParameter.class); - } + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); + List expectedResult = getTransientCompanyModelInstancesAsList( + new String[]{"emp1", "emp2", "emp4", "emp6", "emp7", "emp10"}); - List expectedResult = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp4", "emp6", "emp7", "emp10"}); + String singleStringJDOQL = + "SELECT FROM " + Employee.class.getName() + + " WHERE this.weeklyhours == emp.weeklyhours && " + + "emp.firstname == 'emp1First' VARIABLES Employee emp"; - String singleStringJDOQL = - "SELECT FROM " - + Employee.class.getName() - + " WHERE this.weeklyhours == emp.weeklyhours && " - + "emp.firstname == 'emp1First' VARIABLES Employee emp"; + // API query + Query apiQuery = pm.newQuery(Employee.class); + apiQuery.setFilter("this.weeklyhours == emp.weeklyhours && emp.firstname == 'emp1First'"); + // null subquery parameter + apiQuery.addSubquery(null, Employee.class.getName() + " emp", null); + executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, + false, null, expectedResult, true); - // API query - Query apiQuery = pm.newQuery(Employee.class); - apiQuery.setFilter("this.weeklyhours == emp.weeklyhours && emp.firstname == 'emp1First'"); - // null subquery parameter - apiQuery.addSubquery(null, Employee.class.getName() + " emp", null); - executeJDOQuery( - ASSERTION_FAILED, apiQuery, singleStringJDOQL, false, null, expectedResult, true); + // single String JDOQL + Query singleStringQuery = pm.newQuery(singleStringJDOQL); + executeJDOQuery(ASSERTION_FAILED, singleStringQuery, singleStringJDOQL, + false, null, expectedResult, true); + } - // single String JDOQL - Query singleStringQuery = pm.newQuery(singleStringJDOQL); - executeJDOQuery( - ASSERTION_FAILED, singleStringQuery, singleStringJDOQL, false, null, expectedResult, true); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/NullVariableDeclaration.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/NullVariableDeclaration.java index 39a958578..b7de072de 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/NullVariableDeclaration.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/NullVariableDeclaration.java @@ -5,78 +5,88 @@ * 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 + * + * 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.jdo.tck.query.jdoql.subqueries; +import java.util.List; + import javax.jdo.JDOException; import javax.jdo.PersistenceManager; import javax.jdo.Query; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; +import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Null Variable Declaration in addSubquery
    - * Keywords: query
    - * Assertion ID: A14.6.2-53.
    - * Assertion Description: If the trimmed value is the empty String, or the parameter is - * null, then JDOUserException is thrown. + *Title: Null Variable Declaration in addSubquery + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-53. + *
    + *Assertion Description: + * If the trimmed value is the empty String, or the parameter is null, + * then JDOUserException is thrown. */ public class NullVariableDeclaration extends SubqueriesTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-53 (NullVariableDeclaration) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NullVariableDeclaration.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-53 (NullVariableDeclaration) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NullVariableDeclaration.class); + } - /** */ - public void testNegative() { - PersistenceManager pm = getPM(); - runTestNullVariable(pm); - runTestEmptyVariable(pm); - } + /** */ + public void testNegative() { + PersistenceManager pm = getPM(); + runTestNullVariable(pm); + runTestEmptyVariable(pm); + } - /** */ - void runTestNullVariable(PersistenceManager pm) { - Query apiQuery = pm.newQuery(Employee.class); - try { - apiQuery.addSubquery(null, null, null); - apiQuery.compile(); - fail( - ASSERTION_FAILED, - "addSubquery called with a null varible declaration must throw a JDOUserException."); - } catch (JDOException ex) { - // expected JDOException + /** */ + void runTestNullVariable(PersistenceManager pm) { + Query apiQuery = pm.newQuery(Employee.class); + try { + apiQuery.addSubquery(null, null, null); + apiQuery.compile(); + fail(ASSERTION_FAILED, + "addSubquery called with a null varible declaration must throw a JDOUserException."); + } catch (JDOException ex) { + // expected JDOException + } } - } - /** */ - void runTestEmptyVariable(PersistenceManager pm) { - Query apiQuery = pm.newQuery(Employee.class); - try { - apiQuery.addSubquery(null, " ", null); - apiQuery.compile(); - fail( - ASSERTION_FAILED, - "addSubquery called with an empty varible declaration must throw a JDOUserException."); - } catch (JDOException ex) { - // expected JDOException + /** */ + void runTestEmptyVariable(PersistenceManager pm) { + Query apiQuery = pm.newQuery(Employee.class); + try { + apiQuery.addSubquery(null, " ", null); + apiQuery.compile(); + fail(ASSERTION_FAILED, + "addSubquery called with an empty varible declaration must throw a JDOUserException."); + } catch (JDOException ex) { + // expected JDOException + } } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/SubqueriesTest.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/SubqueriesTest.java index 10127df1e..2d5e51a48 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/SubqueriesTest.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/SubqueriesTest.java @@ -5,69 +5,72 @@ * 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 + * + * 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.jdo.tck.query.jdoql.subqueries; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; -import org.apache.jdo.tck.pc.company.Employee; + import org.apache.jdo.tck.query.QueryTest; +import org.apache.jdo.tck.pc.company.Employee; -/** Superclass for all subquery test classes. */ +/** + * Superclass for all subquery test classes. + */ public abstract class SubqueriesTest extends QueryTest { - /** */ - public static final String SUBQUERIES_TEST_COMPANY_TESTDATA = - "org/apache/jdo/tck/pc/company/companyForSubqueriesTests.xml"; + /** */ + public static final String SUBQUERIES_TEST_COMPANY_TESTDATA = + "org/apache/jdo/tck/pc/company/companyForSubqueriesTests.xml"; - /** - * Returns the name of the company test data resource. - * - * @return name of the company test data resource. - */ - protected String getCompanyTestDataResource() { - return SUBQUERIES_TEST_COMPANY_TESTDATA; - } + /** + * Returns the name of the company test data resource. + * @return name of the company test data resource. + */ + protected String getCompanyTestDataResource() { + return SUBQUERIES_TEST_COMPANY_TESTDATA; + } - /** - * Helper method retuning all Employee instances. - * - * @param pm the PersistenceManager - * @return a List including all persistent Employee instances - */ - protected List getAllEmployees(PersistenceManager pm) { - return getAllPersistentInstances(pm, Employee.class); - } + /** + * Helper method retuning all Employee instances. + * @param pm the PersistenceManager + * @return a List including all persistent Employee instances + */ + protected List getAllEmployees(PersistenceManager pm) { + return getAllPersistentInstances(pm, Employee.class); + } - /** - * Helper method retuning all persistent instances of the specified class. Note, this methods - * executes a JDO query in a new transaction. - * - * @param pm the PersistenceManager - * @param pcClass the persistent capable class - * @return a List including all persistent instances of the specified class. - */ - protected List getAllPersistentInstances(PersistenceManager pm, Class pcClass) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - List all = (List) pm.newQuery(pcClass).execute(); - tx.commit(); - return all; - } finally { - if ((tx != null) && tx.isActive()) { - tx.rollback(); - } + /** + * Helper method retuning all persistent instances of the specified class. + * Note, this methods executes a JDO query in a new transaction. + * @param pm the PersistenceManager + * @param pcClass the persistent capable class + * @return a List including all persistent instances of the specified class. + */ + protected List getAllPersistentInstances(PersistenceManager pm, + Class pcClass) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + List all = (List)pm.newQuery(pcClass).execute(); + tx.commit(); + return all; + } finally { + if ((tx != null) && tx.isActive()) { + tx.rollback(); + } + } } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/UnmodifiedSubqueryInstance.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/UnmodifiedSubqueryInstance.java index a6482f883..fa91d9673 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/UnmodifiedSubqueryInstance.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/subqueries/UnmodifiedSubqueryInstance.java @@ -5,127 +5,129 @@ * 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 + * + * 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.jdo.tck.query.jdoql.subqueries; import java.util.List; + import javax.jdo.PersistenceManager; import javax.jdo.Query; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; +import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Unmodified Subquery Instance.
    - * Keywords: query
    - * Assertion ID: A14.6.2-50.
    - * Assertion Description: The Query parameter instance is unmodified as a result of the - * addSubquery or subsequent execution of the outer Query. Only some of the parameter query parts - * are copied for use as the subquery. The parts copied include the candidate class, filter, - * parameter declarations, variable declarations, imports, ordering specification, uniqueness, - * result specification, and grouping specification. The association with a PersistenceManager, the - * candidate collection or extent, result class, and range limits are not used. + *Title: Unmodified Subquery Instance. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.2-50. + *
    + *Assertion Description: + * The Query parameter instance is unmodified as a result of the addSubquery + * or subsequent execution of the outer Query. Only some of the parameter query + * parts are copied for use as the subquery. The parts copied include the + * candidate class, filter, parameter declarations, variable declarations, + * imports, ordering specification, uniqueness, result specification, and + * grouping specification. The association with a PersistenceManager, the + * candidate collection or extent, result class, and range limits are not used. */ public class UnmodifiedSubqueryInstance extends SubqueriesTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.2-50 (UnmodifiedSubqueryInstance) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(UnmodifiedSubqueryInstance.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - runTestUnmodifiedSubquery(pm); - runTestDifferentPM(pm); - } - - /** */ - void runTestUnmodifiedSubquery(PersistenceManager pm) { - List expectedResult = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp4", "emp5", "emp6", "emp7", "emp10"}); - Double averageWeeklyHours = Double.valueOf(33.5); - - // select average weeklyhours of all employees - String singleStringJDOQLSubquery = "SELECT AVG(e.weeklyhours) FROM Employee e"; - // select employees who work more than the average of all employees - String singleStringJDOQL = - "SELECT FROM " - + Employee.class.getName() - + " WHERE this.weeklyhours > " - + "(" - + singleStringJDOQLSubquery - + ")"; - - // execute subquery - Query sub = pm.newQuery(Employee.class); - sub.setResult("avg(this.weeklyhours)"); - executeJDOQuery( - ASSERTION_FAILED, sub, singleStringJDOQLSubquery, false, null, averageWeeklyHours, true); - - // execute API query - Query apiQuery = pm.newQuery(Employee.class); - apiQuery.setFilter("this.weeklyhours> averageWeeklyhours"); - apiQuery.addSubquery(sub, "double averageWeeklyhours", null); - executeJDOQuery( - ASSERTION_FAILED, apiQuery, singleStringJDOQL, false, null, expectedResult, true); - - // execute subquery again - executeJDOQuery( - ASSERTION_FAILED, sub, singleStringJDOQLSubquery, false, null, averageWeeklyHours, true); - } - - /** */ - void runTestDifferentPM(PersistenceManager pm) { - List expectedResult = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp4", "emp5", "emp6", "emp7", "emp10"}); - - // select employees who work more than the average of all employees - String singleStringJDOQL = - "SELECT FROM " - + Employee.class.getName() - + " WHERE this.weeklyhours > " - + "(SELECT AVG(e.weeklyhours) FROM " - + Employee.class.getName() - + " e)"; - - // create subquery instance using different pm - PersistenceManager newPM = pm.getPersistenceManagerFactory().getPersistenceManager(); - Query sub = newPM.newQuery(Employee.class); - sub.setResult("avg(this.weeklyhours)"); - - Query apiQuery = pm.newQuery(Employee.class); - apiQuery.setFilter("this.weeklyhours> averageWeeklyhours"); - apiQuery.addSubquery(sub, "double averageWeeklyhours", null); - executeJDOQuery( - ASSERTION_FAILED, apiQuery, singleStringJDOQL, false, null, expectedResult, true); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-50 (UnmodifiedSubqueryInstance) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(UnmodifiedSubqueryInstance.class); + } + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + runTestUnmodifiedSubquery(pm); + runTestDifferentPM(pm); + } + + /** */ + void runTestUnmodifiedSubquery(PersistenceManager pm) { + List expectedResult = getTransientCompanyModelInstancesAsList( + new String[]{"emp1","emp2","emp4","emp5","emp6","emp7","emp10"}); + Double averageWeeklyHours = Double.valueOf(33.5); + + // select average weeklyhours of all employees + String singleStringJDOQLSubquery = + "SELECT AVG(e.weeklyhours) FROM Employee e"; + // select employees who work more than the average of all employees + String singleStringJDOQL = + "SELECT FROM " + Employee.class.getName() + " WHERE this.weeklyhours > " + + "(" + singleStringJDOQLSubquery + ")"; + + // execute subquery + Query sub = pm.newQuery(Employee.class); + sub.setResult("avg(this.weeklyhours)"); + executeJDOQuery(ASSERTION_FAILED, sub, singleStringJDOQLSubquery, + false, null, averageWeeklyHours, true); + + // execute API query + Query apiQuery = pm.newQuery(Employee.class); + apiQuery.setFilter("this.weeklyhours> averageWeeklyhours"); + apiQuery.addSubquery(sub, "double averageWeeklyhours", null); + executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, + false, null, expectedResult, true); + + // execute subquery again + executeJDOQuery(ASSERTION_FAILED, sub, singleStringJDOQLSubquery, + false, null, averageWeeklyHours, true); + } + + /** */ + void runTestDifferentPM(PersistenceManager pm) { + List expectedResult = getTransientCompanyModelInstancesAsList( + new String[]{"emp1","emp2","emp4","emp5","emp6","emp7","emp10"}); + + // select employees who work more than the average of all employees + String singleStringJDOQL = + "SELECT FROM " + Employee.class.getName() + " WHERE this.weeklyhours > " + + "(SELECT AVG(e.weeklyhours) FROM " + Employee.class.getName() + " e)"; + + // create subquery instance using different pm + PersistenceManager newPM = + pm.getPersistenceManagerFactory().getPersistenceManager(); + Query sub = newPM.newQuery(Employee.class); + sub.setResult("avg(this.weeklyhours)"); + + Query apiQuery = pm.newQuery(Employee.class); + apiQuery.setFilter("this.weeklyhours> averageWeeklyhours"); + apiQuery.addSubquery(sub, "double averageWeeklyhours", null); + executeJDOQuery(ASSERTION_FAILED, apiQuery, singleStringJDOQL, + false, null, expectedResult, true); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/MixedVariables.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/MixedVariables.java index d770a058f..eb829bbd9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/MixedVariables.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/MixedVariables.java @@ -5,18 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql.variables; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.query.QueryElementHolder; @@ -24,110 +25,122 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Mixed Variables.
    - * Keywords: query
    - * Assertion ID: A14.6.5-3.
    - * Assertion Description: All variables must be explicitly declared, or all variables must - * be implicitly declared. + *Title: Mixed Variables. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.5-3. + *
    + *Assertion Description: + * All variables must be explicitly declared, + * or all variables must be implicitly declared. */ public class MixedVariables extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.5-3 (MixedVariables) failed: "; - - /** - * The array of invalid queries which may be executed as single string queries and as API queries. - */ - private static final QueryElementHolder[] INVALID_QUERIES = { - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "(team.contains(e) & e.firstname == 'emp1First') & " - + "(projects.contains(p) & p.name == 'orange')", - /*VARIABLES*/ "Employee e", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null) - }; - - /** - * The array of valid queries which may be executed as single string queries and as API queries. - */ - private static final QueryElementHolder[] VALID_QUERIES = { - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "(team.contains(e) & e.firstname == 'emp1First') & " - + "(projects.contains(p) & p.name == 'orange')", - /*VARIABLES*/ "Employee e; Project p", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "(team.contains(e) & e.firstname == 'emp1First') & " - + "(projects.contains(p) & p.name == 'orange')", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null) - }; - - /** The expected results of valid queries. */ - private Object[] expectedResult = { - getTransientCompanyModelInstancesAsList(new String[] {"emp2"}), - getTransientCompanyModelInstancesAsList(new String[] {"emp2"}) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MixedVariables.class); - } - - /** */ - public void testPositive() { - for (int i = 0; i < VALID_QUERIES.length; i++) { - executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], expectedResult[i]); - executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], expectedResult[i]); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.5-3 (MixedVariables) failed: "; + + /** + * The array of invalid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] INVALID_QUERIES = { + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "(team.contains(e) & e.firstname == 'emp1First') & " + + "(projects.contains(p) & p.name == 'orange')", + /*VARIABLES*/ "Employee e", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** + * The array of valid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] VALID_QUERIES = { + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "(team.contains(e) & e.firstname == 'emp1First') & " + + "(projects.contains(p) & p.name == 'orange')", + /*VARIABLES*/ "Employee e; Project p", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "(team.contains(e) & e.firstname == 'emp1First') & " + + "(projects.contains(p) & p.name == 'orange')", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** + * The expected results of valid queries. + */ + private Object[] expectedResult = { + getTransientCompanyModelInstancesAsList(new String[]{"emp2"}), + getTransientCompanyModelInstancesAsList(new String[]{"emp2"}) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MixedVariables.class); + } + + /** */ + public void testPositive() { + for (int i = 0; i < VALID_QUERIES.length; i++) { + executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], + expectedResult[i]); + executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], + expectedResult[i]); + } } - } - public void testNegative() { - for (int i = 0; i < INVALID_QUERIES.length; i++) { - compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); - compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + public void testNegative() { + for (int i = 0; i < INVALID_QUERIES.length; i++) { + compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], + false); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/UnconstrainedVariable.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/UnconstrainedVariable.java index 7890ff84d..ec9eab1ed 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/UnconstrainedVariable.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/UnconstrainedVariable.java @@ -5,22 +5,19 @@ * 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 + * + * 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.jdo.tck.query.jdoql.variables; -import java.util.HashMap; -import java.util.Map; -import javax.jdo.JDOQLTypedQuery; -import javax.jdo.query.NumericExpression; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.QEmployee; @@ -28,73 +25,81 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; +import javax.jdo.query.NumericExpression; +import java.util.HashMap; +import java.util.Map; + /** - * Title: Unconstrained Variables.
    - * Keywords: query
    - * Assertion ID: A14.6.5-1.
    - * Assertion Description: A variable that is not constrained with an explicit contains - * clause is constrained by the extent of the persistence capable class (including subclasses). + *Title: Unconstrained Variables. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.5-1. + *
    + *Assertion Description: + * A variable that is not constrained with an explicit contains clause + * is constrained by the extent of the persistence capable class + * (including subclasses). */ public class UnconstrainedVariable extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.5-1 (UnconstrainedVariable) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(UnconstrainedVariable.class); - } - - /** */ - public void testPositive() { - if (isUnconstrainedVariablesSupported()) { - Object expected = - getTransientCompanyModelInstancesAsList(new String[] {"emp2", "emp3", "emp4"}); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.5-1 (UnconstrainedVariable) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(UnconstrainedVariable.class); + } + + /** */ + public void testPositive() { + if (isUnconstrainedVariablesSupported()) { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp2", "emp3", "emp4"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - QEmployee e = QEmployee.variable("e"); - NumericExpression param = query.numericParameter("id"); - query.filter(cand.hiredate.gt(e.hiredate).and(e.hiredate.eq(param))); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + QEmployee e = QEmployee.variable("e"); + NumericExpression param = query.numericParameter("id"); + query.filter(cand.hiredate.gt(e.hiredate).and(e.hiredate.eq(param))); - Map paramValues = new HashMap<>(); - paramValues.put("id", Integer.valueOf(1)); + Map paramValues = new HashMap<>(); + paramValues.put("id", Integer.valueOf(1)); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this.hiredate > e.hiredate & e.personid = id", - /*VARIABLES*/ "Employee e", - /*PARAMETERS*/ "int id", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this.hiredate > e.hiredate & e.personid = id", + /*VARIABLES*/ "Employee e", + /*PARAMETERS*/ "int id", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/VariableDeclaredWithSameNameAsFieldOfCandidateClass.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/VariableDeclaredWithSameNameAsFieldOfCandidateClass.java index f91ffdce8..bf722f087 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/VariableDeclaredWithSameNameAsFieldOfCandidateClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/VariableDeclaredWithSameNameAsFieldOfCandidateClass.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -21,75 +21,86 @@ import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Variable Declared with Same Name as Field of Candidate Class
    - * Keywords: query
    - * Assertion ID: A14.4-3.
    - * Assertion Description: A field of the candidate class of a Query can be - * hidden if a variable is declared with the same name. - */ -public class VariableDeclaredWithSameNameAsFieldOfCandidateClass extends QueryTest { + *Title: Variable Declared with Same Name as Field of Candidate Class + *
    + *Keywords: query + *
    + *Assertion ID: A14.4-3. + *
    + *Assertion Description: +A field of the candidate class of a Query can be hidden if a +variable is declared with the same name. - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.4-3 (VariableDeclaredWithSameNameAsFieldOfCandidateClass) failed: "; + */ - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(VariableDeclaredWithSameNameAsFieldOfCandidateClass.class); - } +public class VariableDeclaredWithSameNameAsFieldOfCandidateClass extends QueryTest { - /** */ - public void test() { - pm = getPM(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.4-3 (VariableDeclaredWithSameNameAsFieldOfCandidateClass) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(VariableDeclaredWithSameNameAsFieldOfCandidateClass.class); + } - checkQueryVariables(pm); + /** */ + public void test() { + pm = getPM(); - pm.close(); - pm = null; - } + checkQueryVariables(pm); - /** */ - void checkQueryVariables(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - Class clazz = org.apache.jdo.tck.pc.company.Project.class; - try { - tx.begin(); - Query query = pm.newQuery(); - query.setClass(clazz); - query.setCandidates(pm.getExtent(clazz, false)); - try { - query.declareVariables("org.apache.jdo.tck.pc.company.Person reviewers;"); - query.setFilter("reviewers.contains(reviewers)"); - Object results = query.execute(); - fail( - ASSERTION_FAILED, - "Variable declaration \"Person reviewers\" did not hide field Person.reviewers"); - } catch (JDOUserException e) { - // expected exception - if (debug) logger.debug("Caught expected " + e); - } - } finally { - if (tx.isActive()) tx.rollback(); + pm.close(); + pm = null; } - try { - tx.begin(); - Query query = pm.newQuery(); - query.setClass(clazz); - query.setCandidates(pm.getExtent(clazz, false)); - query.declareVariables("org.apache.jdo.tck.pc.company.Person reviewers;"); - query.setFilter("this.reviewers.contains(reviewers) && reviewers.firstname==\"brazil\""); - Object results = query.execute(); - } finally { - if (tx.isActive()) tx.rollback(); + /** */ + void checkQueryVariables(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + Class clazz = org.apache.jdo.tck.pc.company.Project.class; + try { + tx.begin(); + Query query = pm.newQuery(); + query.setClass(clazz); + query.setCandidates(pm.getExtent(clazz, false)); + try { + query.declareVariables( "org.apache.jdo.tck.pc.company.Person reviewers;" ); + query.setFilter( "reviewers.contains(reviewers)" ); + Object results = query.execute(); + fail(ASSERTION_FAILED, + "Variable declaration \"Person reviewers\" did not hide field Person.reviewers"); + } + catch (JDOUserException e) { + // expected exception + if (debug) logger.debug( "Caught expected " + e); + } + } + finally { + if (tx.isActive()) + tx.rollback(); + } + + try { + tx.begin(); + Query query = pm.newQuery(); + query.setClass(clazz); + query.setCandidates(pm.getExtent(clazz, false)); + query.declareVariables( "org.apache.jdo.tck.pc.company.Person reviewers;" ); + query.setFilter( "this.reviewers.contains(reviewers) && reviewers.firstname==\"brazil\"" ); + Object results = query.execute(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/VariablesAndFields.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/VariablesAndFields.java index 51dfdd643..0fc681d83 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/VariablesAndFields.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/VariablesAndFields.java @@ -5,20 +5,21 @@ * 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 + * + * 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.jdo.tck.query.jdoql.variables; import java.util.LinkedList; -import javax.jdo.JDOQLTypedQuery; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.Person; @@ -28,230 +29,233 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Variables and Fields.
    - * Keywords: query
    - * Assertion ID: A14.6.5-4.
    - * Assertion Description: Names in the filter are treated as parameters if they are - * explicitly declared via declareParameters or if they begin with ":". Names are treated as - * variable names if they are explicitly declared via declareVariables. Names are treated as field - * or property names if they are fields or properties of the candidate class. Names are treated as - * class names if they exist in the package of the candidate class, have been imported, or if they - * are in the java.lang package. e.g. Integer. Otherwise, names are treated as implicitly defined - * variable names. + *Title: Variables and Fields. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.5-4. + *
    + *Assertion Description: + * Names in the filter are treated as parameters if they are explicitly + * declared via declareParameters or if they begin with ":". + * Names are treated as variable names if they are explicitly declared + * via declareVariables. + * Names are treated as field or property names if they are fields or + * properties of the candidate class. + * Names are treated as class names if they exist in the package of the + * candidate class, have been imported, or if they are in the java.lang + * package. e.g. Integer. + * Otherwise, names are treated as implicitly defined variable names. */ public class VariablesAndFields extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.5-4 (VariablesAndFields) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(VariablesAndFields.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.5-4 (VariablesAndFields) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(VariablesAndFields.class); + } - /** */ - public void testPositive0() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp2"}); + /** */ + public void testPositive0() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp2"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - QEmployee e = QEmployee.variable("e"); - query.filter(cand.team.contains(e).and(e.firstname.eq("emp1First"))); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + QEmployee e = QEmployee.variable("e"); + query.filter(cand.team.contains(e).and(e.firstname.eq("emp1First"))); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "team.contains(e) & e.firstname == 'emp1First'", - /*VARIABLES*/ "Employee e", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "team.contains(e) & e.firstname == 'emp1First'", + /*VARIABLES*/ "Employee e", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } - /** */ - public void testPositive1() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp2"}); + /** */ + public void testPositive1() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp2"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - QEmployee e = QEmployee.variable("e"); - query.filter(cand.team.contains(e).and(e.firstname.eq("emp1First"))); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + QEmployee e = QEmployee.variable("e"); + query.filter(cand.team.contains(e).and(e.firstname.eq("emp1First"))); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "team.contains(e) & e.firstname == 'emp1First'", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "team.contains(e) & e.firstname == 'emp1First'", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } - /** */ - public void testPositive2() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); + /** */ + public void testPositive2() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.firstname.eq("emp1First")); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.firstname.eq("emp1First")); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "firstname == 'emp1First'", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname == 'emp1First'", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } - /** */ - public void testPositive3() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp2"}); + /** */ + public void testPositive3() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp2"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - QEmployee manager = QEmployee.variable("manager"); - query.filter(cand.team.contains(manager).and(manager.firstname.eq("emp1First"))); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + QEmployee manager = QEmployee.variable("manager"); + query.filter(cand.team.contains(manager).and(manager.firstname.eq("emp1First"))); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "team.contains(manager) & manager.firstname == 'emp1First'", - /*VARIABLES*/ "Employee manager", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "team.contains(manager) & manager.firstname == 'emp1First'", + /*VARIABLES*/ "Employee manager", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - /** */ - public void testPositive4() { - Object expected = new LinkedList(); + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + /** */ + public void testPositive4() { + Object expected = new LinkedList(); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - QEmployee manager = QEmployee.variable("manager"); - query.filter(cand.team.contains(cand.manager).and(cand.manager.firstname.eq("emp1First"))); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + QEmployee manager = QEmployee.variable("manager"); + query.filter(cand.team.contains(cand.manager).and(cand.manager.firstname.eq("emp1First"))); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "team.contains(manager) & manager.firstname == 'emp1First'", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "team.contains(manager) & manager.firstname == 'emp1First'", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - /** */ - public void testPositive5() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp2"}); + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + /** */ + public void testPositive5() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp2"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - QEmployee employee = QEmployee.variable("employee"); - query.filter(cand.team.contains(employee).and(employee.firstname.eq("emp1First"))); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + QEmployee employee = QEmployee.variable("employee"); + query.filter(cand.team.contains(employee).and(employee.firstname.eq("emp1First"))); - QueryElementHolder holder = - new QueryElementHolder( - /* Note: the variable name is the same as the class - * name except for capitalization. This is legal. */ - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "team.contains(employee) & employee.firstname == 'emp1First'", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /* Note: the variable name is the same as the class + * name except for capitalization. This is legal. */ + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "team.contains(employee) & employee.firstname == 'emp1First'", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/VariablesWithoutExtent.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/VariablesWithoutExtent.java index 327d9bbdc..4620c22f2 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/VariablesWithoutExtent.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/VariablesWithoutExtent.java @@ -5,22 +5,25 @@ * 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 + * + * 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.jdo.tck.query.jdoql.variables; import java.util.LinkedList; + import javax.jdo.JDOHelper; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.pc.query.NoExtent; @@ -29,86 +32,89 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Variables without Extent.
    - * Keywords: query
    - * Assertion ID: A14.6.5-2.
    - * Assertion Description: If the class does not manage an Extent, then no results will - * satisfy the query. + *Title: Variables without Extent. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.5-2. + *
    + *Assertion Description: + * If the class does not manage an Extent, + * then no results will satisfy the query. */ public class VariablesWithoutExtent extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.5-2 (VariablesWithoutExtent) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(VariablesWithoutExtent.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.5-2 (VariablesWithoutExtent) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(VariablesWithoutExtent.class); + } - /** */ - public void testPositive() { - if (isUnconstrainedVariablesSupported()) { + /** */ + public void testPositive() { + if (isUnconstrainedVariablesSupported()) { - Object expected = new LinkedList(); + Object expected = new LinkedList(); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "this.personid = noExtent.id", - /*VARIABLES*/ "NoExtent noExtent", - /*PARAMETERS*/ null, - /*IMPORTS*/ "import org.apache.jdo.tck.pc.query.NoExtent;", - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ null, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "this.personid = noExtent.id", + /*VARIABLES*/ "NoExtent noExtent", + /*PARAMETERS*/ null, + /*IMPORTS*/ "import org.apache.jdo.tck.pc.query.NoExtent;", + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ null, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - NoExtent noExtent = new NoExtent(1); - makePersistent(noExtent); - addTearDownInstance(noExtent); - logger.info("Michael " + noExtent); - logger.info("ID " + JDOHelper.getObjectId(noExtent)); - } - - /** - * Makes the given instance persistent. - * - * @param o the instance to be made persistent. - */ - private void makePersistent(Object o) { - PersistenceManager pm = getPM(); - Transaction transaction = pm.currentTransaction(); - transaction.begin(); - try { - pm.makePersistent(o); - transaction.commit(); - } finally { - if (transaction.isActive()) { - transaction.rollback(); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + NoExtent noExtent = new NoExtent(1); + makePersistent(noExtent); + addTearDownInstance(noExtent); + logger.info("Michael " + noExtent); + logger.info("ID " + JDOHelper.getObjectId(noExtent)); + } + + /** + * Makes the given instance persistent. + * @param o the instance to be made persistent. + */ + private void makePersistent(Object o) { + PersistenceManager pm = getPM(); + Transaction transaction = pm.currentTransaction(); + transaction.begin(); + try { + pm.makePersistent(o); + transaction.commit(); + } finally { + if (transaction.isActive()) { + transaction.rollback(); + } + } } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/AggregateResult.java b/tck/src/main/java/org/apache/jdo/tck/query/result/AggregateResult.java index 4137e3854..80819bbf0 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/AggregateResult.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/AggregateResult.java @@ -5,20 +5,21 @@ * 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 + * + * 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.jdo.tck.query.result; import java.math.BigDecimal; -import javax.jdo.JDOQLTypedQuery; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.DentalInsurance; import org.apache.jdo.tck.pc.company.FullTimeEmployee; @@ -32,954 +33,933 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Aggregate Result.
    - * Keywords: query
    - * Assertion ID: A14.6.9-6.
    - * Assertion Description: Count returns Long. Sum returns Long for integral types and the - * field's type for other Number types (BigDecimal, BigInteger, Float, and Double). Sum is invalid - * if applied to non-Number types. Avg, min, and max return the type of the expression. + *Title: Aggregate Result. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.9-6. + *
    + *Assertion Description: + * Count returns Long. Sum returns Long for integral types and + * the field's type for other Number types + * (BigDecimal, BigInteger, Float, and Double). + * Sum is invalid if applied to non-Number types. + * Avg, min, and max return the type of the expression. */ public class AggregateResult extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.9-6 (AggregateResult) failed: "; - - /** - * The array of invalid queries which may be executed as single string queries and as API queries. - */ - private static final QueryElementHolder[] INVALID_QUERIES = { - // SUM - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "SUM(firstname)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(AggregateResult.class); - } - - /** */ - public void testCount0() { - // COUNT(this) - Object expected = Long.valueOf(3); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - query.result(false, cand.count()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "COUNT(this)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testCount1() { - // COUNT(this) - Object expected = Long.valueOf(0); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - query.result(false, cand.count()); - query.filter(cand.personid.eq(0L)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "COUNT(this)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "personid == 0", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testCount2() { - // COUNT(manager) - Object expected = Long.valueOf(2); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - query.result(false, cand.manager.count()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "COUNT(manager)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testCount3() { - // COUNT(manager.personid) - Object expected = Long.valueOf(2); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - query.result(false, cand.manager.personid.count()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "COUNT(manager.personid)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testCount4() { - // COUNT(DISTINCT manager) - Object expected = Long.valueOf(1); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - query.result(false, cand.manager.countDistinct()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "COUNT(DISTINCT manager)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testSum0() { - // SUM(long) - Object expected = Long.valueOf(1 + 2 + 5); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - query.result(false, cand.personid.sum()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "SUM(personid)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testSum1() { - // SUM(double) - Object expected = Double.valueOf(20000.0 + 10000.0 + 45000.0); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - query.result(false, cand.salary.sum()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "SUM(salary)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testSum2() { - // SUM(BigDecimal) - Object expected = - new BigDecimal("2500000.99").add(new BigDecimal("50000.00")).add(new BigDecimal("2000.99")); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Project.class); - QProject cand = QProject.candidate(); - query.result(false, cand.budget.sum()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "SUM(budget)", - /*INTO*/ null, - /*FROM*/ Project.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testSum3() { - // SUM(budget) - Object expected = null; - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Project.class); - QProject cand = QProject.candidate(); - query.result(false, cand.budget.sum()); - query.filter(cand.projid.eq(0L)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "SUM(budget)", - /*INTO*/ null, - /*FROM*/ Project.class, - /*EXCLUDE*/ null, - /*WHERE*/ "projid == 0", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testSum4() { - // SUM(((FullTimeEmployee)manager).salary) - Object expected = Double.valueOf(20000); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - // DataNucleus: java.lang.ClassCastException: - // org.datanucleus.api.jdo.query.PersistableExpressionImpl - // cannot be cast to org.apache.jdo.tck.pc.company.QFullTimeEmployee - QFullTimeEmployee cast = (QFullTimeEmployee) cand.manager.cast(FullTimeEmployee.class); - query.result(false, cast.salary.sum()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "SUM(((FullTimeEmployee)manager).salary)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testSum5() { - // SUM(DISTINCT ((FullTimeEmployee)manager).salary) - Object expected = Double.valueOf(10000); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - // DataNucleus: )java.lang.ClassCastException: - // org.datanucleus.api.jdo.query.PersistableExpressionImpl - // cannot be cast to org.apache.jdo.tck.pc.company.QFullTimeEmployee - QFullTimeEmployee cast = (QFullTimeEmployee) cand.manager.cast(FullTimeEmployee.class); - query.result(false, cast.salary.sumDistinct()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "SUM(DISTINCT ((FullTimeEmployee)manager).salary)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testMin0() { - // MIN(long) - Object expected = Long.valueOf(1); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - query.result(false, cand.personid.min()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "MIN(personid)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testMin1() { - // MIN(double) - Object expected = Double.valueOf(10000.0); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - query.result(false, cand.salary.min()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "MIN(salary)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testMin2() { - // MIN(BigDecimal) - Object expected = new BigDecimal("2000.99"); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Project.class); - QProject cand = QProject.candidate(); - query.result(false, cand.budget.min()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "MIN(budget)", - /*INTO*/ null, - /*FROM*/ Project.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testMin3() { - // MIN(budget) - Object expected = null; - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Project.class); - QProject cand = QProject.candidate(); - query.result(false, cand.budget.min()); - query.filter(cand.projid.eq(0L)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "MIN(budget)", - /*INTO*/ null, - /*FROM*/ Project.class, - /*EXCLUDE*/ null, - /*WHERE*/ "projid == 0", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testMin4() { - // MIN(((FullTimeEmployee)manager).salary) - Object expected = Double.valueOf(10000); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - // DataNucleus: ClassCastException: org.datanucleus.api.jdo.query.PersistableExpressionImpl - // cannot be cast to org.apache.jdo.tck.pc.company.QFullTimeEmployee - QFullTimeEmployee cast = (QFullTimeEmployee) cand.manager.cast(FullTimeEmployee.class); - query.result(false, cast.salary.min()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "MIN(((FullTimeEmployee)manager).salary)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - /** */ - public void testMax0() { - // MAX(long) - Object expected = Long.valueOf(5); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - query.result(false, cand.personid.max()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "MAX(personid)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testMax1() { - // MAX(double) - Object expected = Double.valueOf(45000.0); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - query.result(false, cand.salary.max()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "MAX(salary)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testMax2() { - // MAX(BigDecimal) - Object expected = new BigDecimal("2500000.99"); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Project.class); - QProject cand = QProject.candidate(); - query.result(false, cand.budget.max()); - - QueryElementHolder holder = + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.9-6 (AggregateResult) failed: "; + + /** + * The array of invalid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] INVALID_QUERIES = { + // SUM new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "MAX(budget)", - /*INTO*/ null, - /*FROM*/ Project.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testMax3() { - // MAX(budget) - Object expected = null; - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Project.class); - QProject cand = QProject.candidate(); - query.result(false, cand.budget.max()); - query.filter(cand.projid.eq(0L)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "MAX(budget)", - /*INTO*/ null, - /*FROM*/ Project.class, - /*EXCLUDE*/ null, - /*WHERE*/ "projid == 0", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testMax4() { - // MAX(((FullTimeEmployee)manager).salary) - Object expected = Double.valueOf(10000); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - // DataNucleus: java.lang.ClassCastException: - // org.datanucleus.api.jdo.query.PersistableExpressionImpl - // cannot be cast to org.apache.jdo.tck.pc.company.QFullTimeEmployee - QFullTimeEmployee cast = (QFullTimeEmployee) cand.manager.cast(FullTimeEmployee.class); - query.result(false, cast.salary.max()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "MAX(((FullTimeEmployee)manager).salary)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testAvg0() { - // AVG(long) - Object expected = Double.valueOf(3); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.result(false, cand.personid.avg()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "AVG(personid)", - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testAvg1() { - // AVG(double) - Object expected = Double.valueOf(25000.0); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - query.result(false, cand.salary.avg()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "AVG(salary)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testAvg2() { - // AVG(BigDecimal) - Object expected = Double.valueOf("99.997"); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(DentalInsurance.class); - QDentalInsurance cand = QDentalInsurance.candidate(); - query.result(false, cand.lifetimeOrthoBenefit.avg()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "AVG(lifetimeOrthoBenefit)", - /*INTO*/ null, - /*FROM*/ DentalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testAvg3() { - // AVG(lifetimeOrthoBenefit) - Object expected = null; - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(DentalInsurance.class); - QDentalInsurance cand = QDentalInsurance.candidate(); - query.result(false, cand.lifetimeOrthoBenefit.avg()); - query.filter(cand.insid.eq(0L)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "AVG(lifetimeOrthoBenefit)", - /*INTO*/ null, - /*FROM*/ DentalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ "insid == 0", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testAvg4() { - // AVG(((FullTimeEmployee)manager).salary) - Object expected = Double.valueOf(10000); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - // DataNucleus: java.lang.ClassCastException: - // org.datanucleus.api.jdo.query.PersistableExpressionImpl - // cannot be cast to org.apache.jdo.tck.pc.company.QFullTimeEmployee - QFullTimeEmployee cast = (QFullTimeEmployee) cand.manager.cast(FullTimeEmployee.class); - query.result(false, cast.salary.avg()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "AVG(((FullTimeEmployee)manager).salary)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testAvg5() { - // AVG(DISTINCT ((FullTimeEmployee)manager).salary) - Object expected = Double.valueOf(10000); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - // DataNucleus: java.lang.ClassCastException: - // org.datanucleus.api.jdo.query.PersistableExpressionImpl - // cannot be cast to org.apache.jdo.tck.pc.company.QFullTimeEmployee - QFullTimeEmployee cast = (QFullTimeEmployee) cand.manager.cast(FullTimeEmployee.class); - query.result(false, cast.salary.avgDistinct()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "AVG(DISTINCT ((FullTimeEmployee)manager).salary)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - public void testNegative() { - for (int i = 0; i < INVALID_QUERIES.length; i++) { - compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); - compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + /*UNIQUE*/ null, + /*RESULT*/ "SUM(firstname)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(AggregateResult.class); + } + + /** */ + public void testCount0() { + // COUNT(this) + Object expected = Long.valueOf(3); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + query.result(false, cand.count()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "COUNT(this)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testCount1() { + // COUNT(this) + Object expected = Long.valueOf(0); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + query.result(false, cand.count()); + query.filter(cand.personid.eq(0L)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "COUNT(this)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "personid == 0", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testCount2() { + // COUNT(manager) + Object expected = Long.valueOf(2); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + query.result(false, cand.manager.count()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "COUNT(manager)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testCount3() { + // COUNT(manager.personid) + Object expected = Long.valueOf(2); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + query.result(false, cand.manager.personid.count()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "COUNT(manager.personid)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testCount4() { + // COUNT(DISTINCT manager) + Object expected = Long.valueOf(1); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + query.result(false, cand.manager.countDistinct()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "COUNT(DISTINCT manager)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testSum0() { + // SUM(long) + Object expected = Long.valueOf(1+2+5); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + query.result(false, cand.personid.sum()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "SUM(personid)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testSum1() { + // SUM(double) + Object expected = Double.valueOf(20000.0+10000.0+45000.0); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + query.result(false, cand.salary.sum()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "SUM(salary)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testSum2() { + // SUM(BigDecimal) + Object expected = new BigDecimal("2500000.99").add + (new BigDecimal("50000.00")).add(new BigDecimal("2000.99")); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Project.class); + QProject cand = QProject.candidate(); + query.result(false, cand.budget.sum()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "SUM(budget)", + /*INTO*/ null, + /*FROM*/ Project.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testSum3() { + // SUM(budget) + Object expected = null; + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Project.class); + QProject cand = QProject.candidate(); + query.result(false, cand.budget.sum()); + query.filter(cand.projid.eq(0L)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "SUM(budget)", + /*INTO*/ null, + /*FROM*/ Project.class, + /*EXCLUDE*/ null, + /*WHERE*/ "projid == 0", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testSum4() { + // SUM(((FullTimeEmployee)manager).salary) + Object expected = Double.valueOf(20000); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + // DataNucleus: java.lang.ClassCastException: org.datanucleus.api.jdo.query.PersistableExpressionImpl + // cannot be cast to org.apache.jdo.tck.pc.company.QFullTimeEmployee + QFullTimeEmployee cast = (QFullTimeEmployee)cand.manager.cast(FullTimeEmployee.class); + query.result(false, cast.salary.sum()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "SUM(((FullTimeEmployee)manager).salary)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testSum5() { + // SUM(DISTINCT ((FullTimeEmployee)manager).salary) + Object expected = Double.valueOf(10000); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + // DataNucleus: )java.lang.ClassCastException: org.datanucleus.api.jdo.query.PersistableExpressionImpl + // cannot be cast to org.apache.jdo.tck.pc.company.QFullTimeEmployee + QFullTimeEmployee cast = (QFullTimeEmployee)cand.manager.cast(FullTimeEmployee.class); + query.result(false, cast.salary.sumDistinct()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "SUM(DISTINCT ((FullTimeEmployee)manager).salary)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testMin0() { + // MIN(long) + Object expected = Long.valueOf(1); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + query.result(false, cand.personid.min()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "MIN(personid)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testMin1() { + // MIN(double) + Object expected = Double.valueOf(10000.0); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + query.result(false, cand.salary.min()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "MIN(salary)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testMin2() { + // MIN(BigDecimal) + Object expected = new BigDecimal("2000.99"); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Project.class); + QProject cand = QProject.candidate(); + query.result(false, cand.budget.min()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "MIN(budget)", + /*INTO*/ null, + /*FROM*/ Project.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testMin3() { + // MIN(budget) + Object expected = null; + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Project.class); + QProject cand = QProject.candidate(); + query.result(false, cand.budget.min()); + query.filter(cand.projid.eq(0L)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "MIN(budget)", + /*INTO*/ null, + /*FROM*/ Project.class, + /*EXCLUDE*/ null, + /*WHERE*/ "projid == 0", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testMin4() { + // MIN(((FullTimeEmployee)manager).salary) + Object expected = Double.valueOf(10000); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + // DataNucleus: ClassCastException: org.datanucleus.api.jdo.query.PersistableExpressionImpl + // cannot be cast to org.apache.jdo.tck.pc.company.QFullTimeEmployee + QFullTimeEmployee cast = (QFullTimeEmployee)cand.manager.cast(FullTimeEmployee.class); + query.result(false, cast.salary.min()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "MIN(((FullTimeEmployee)manager).salary)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + /** */ + public void testMax0() { + // MAX(long) + Object expected = Long.valueOf(5); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + query.result(false, cand.personid.max()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "MAX(personid)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testMax1() { + // MAX(double) + Object expected = Double.valueOf(45000.0); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + query.result(false, cand.salary.max()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "MAX(salary)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testMax2() { + // MAX(BigDecimal) + Object expected = new BigDecimal("2500000.99"); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Project.class); + QProject cand = QProject.candidate(); + query.result(false, cand.budget.max()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "MAX(budget)", + /*INTO*/ null, + /*FROM*/ Project.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testMax3() { + // MAX(budget) + Object expected = null; + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Project.class); + QProject cand = QProject.candidate(); + query.result(false, cand.budget.max()); + query.filter(cand.projid.eq(0L)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "MAX(budget)", + /*INTO*/ null, + /*FROM*/ Project.class, + /*EXCLUDE*/ null, + /*WHERE*/ "projid == 0", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testMax4() { + // MAX(((FullTimeEmployee)manager).salary) + Object expected = Double.valueOf(10000); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + // DataNucleus: java.lang.ClassCastException: org.datanucleus.api.jdo.query.PersistableExpressionImpl + // cannot be cast to org.apache.jdo.tck.pc.company.QFullTimeEmployee + QFullTimeEmployee cast = (QFullTimeEmployee)cand.manager.cast(FullTimeEmployee.class); + query.result(false, cast.salary.max()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "MAX(((FullTimeEmployee)manager).salary)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testAvg0() { + // AVG(long) + Object expected = Double.valueOf(3); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.result(false, cand.personid.avg()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "AVG(personid)", + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testAvg1() { + // AVG(double) + Object expected = Double.valueOf(25000.0); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + query.result(false, cand.salary.avg()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "AVG(salary)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testAvg2() { + // AVG(BigDecimal) + Object expected = Double.valueOf("99.997"); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(DentalInsurance.class); + QDentalInsurance cand = QDentalInsurance.candidate(); + query.result(false, cand.lifetimeOrthoBenefit.avg()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "AVG(lifetimeOrthoBenefit)", + /*INTO*/ null, + /*FROM*/ DentalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testAvg3() { + // AVG(lifetimeOrthoBenefit) + Object expected = null; + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(DentalInsurance.class); + QDentalInsurance cand = QDentalInsurance.candidate(); + query.result(false, cand.lifetimeOrthoBenefit.avg()); + query.filter(cand.insid.eq(0L)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "AVG(lifetimeOrthoBenefit)", + /*INTO*/ null, + /*FROM*/ DentalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ "insid == 0", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testAvg4() { + // AVG(((FullTimeEmployee)manager).salary) + Object expected = Double.valueOf(10000); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + // DataNucleus: java.lang.ClassCastException: org.datanucleus.api.jdo.query.PersistableExpressionImpl + // cannot be cast to org.apache.jdo.tck.pc.company.QFullTimeEmployee + QFullTimeEmployee cast = (QFullTimeEmployee)cand.manager.cast(FullTimeEmployee.class); + query.result(false, cast.salary.avg()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "AVG(((FullTimeEmployee)manager).salary)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testAvg5() { + // AVG(DISTINCT ((FullTimeEmployee)manager).salary) + Object expected = Double.valueOf(10000); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + // DataNucleus: java.lang.ClassCastException: org.datanucleus.api.jdo.query.PersistableExpressionImpl + // cannot be cast to org.apache.jdo.tck.pc.company.QFullTimeEmployee + QFullTimeEmployee cast = (QFullTimeEmployee)cand.manager.cast(FullTimeEmployee.class); + query.result(false, cast.salary.avgDistinct()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "AVG(DISTINCT ((FullTimeEmployee)manager).salary)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + public void testNegative() { + for (int i = 0; i < INVALID_QUERIES.length; i++) { + compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], + false); + } + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/DefaultResult.java b/tck/src/main/java/org/apache/jdo/tck/query/result/DefaultResult.java index 3fe3c35bf..40b25755d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/DefaultResult.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/DefaultResult.java @@ -5,82 +5,88 @@ * 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 + * + * 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.jdo.tck.query.result; -import javax.jdo.JDOQLTypedQuery; +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; +import org.apache.jdo.tck.pc.company.QPerson; import org.apache.jdo.tck.query.QueryElementHolder; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Default Result.
    - * Keywords: query
    - * Assertion ID: A14.6.9-8.
    - * Assertion Description: If not specified, the result defaults to distinct this as C. + *Title: Default Result. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.9-8. + *
    + *Assertion Description: + * If not specified, the result defaults to distinct this as C. */ public class DefaultResult extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.9-8 (DefaultResult) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DefaultResult.class); - } - - /** */ - public void testPositive() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.9-8 (DefaultResult) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DefaultResult.class); + } + + /** */ + public void testPositive() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/DefaultUnique.java b/tck/src/main/java/org/apache/jdo/tck/query/result/DefaultUnique.java index 712a8e9f2..8c73bfe95 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/DefaultUnique.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/DefaultUnique.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,7 +19,8 @@ import java.math.BigDecimal; import java.util.Arrays; -import javax.jdo.JDOQLTypedQuery; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.DentalInsurance; import org.apache.jdo.tck.pc.company.Employee; @@ -30,358 +31,353 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Default Unique.
    - * Keywords: query
    - * Assertion ID: A14.6.11-2.
    - * Assertion Description: The default Unique setting is true for aggregate results without a - * grouping expression, and false otherwise. + *Title: Default Unique. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.11-2. + *
    + *Assertion Description: + * The default Unique setting is true for aggregate results + * without a grouping expression, and false otherwise. */ public class DefaultUnique extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.11-2 (DefaultUnique) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DefaultUnique.class); - } - - /** */ - public void testThis() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testAggregateNoGrouping0() { - Object expected = Long.valueOf(5); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "COUNT(department)", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ null, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testAggregateNoGrouping1() { - Object expected = Double.valueOf("99.997"); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "avg(lifetimeOrthoBenefit)", - /*INTO*/ null, - /*FROM*/ DentalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ null, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testAggregateNoGrouping2() { - Object expected = new BigDecimal("2000.99"); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "MIN(budget)", - /*INTO*/ null, - /*FROM*/ Project.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ null, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testAggregateNoGrouping3() { - Object expected = new BigDecimal("2500000.99"); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "MAX(budget)", - /*INTO*/ null, - /*FROM*/ Project.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ null, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testAggregateNoGrouping4() { - Object expected = new BigDecimal("2552001.98"); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "SUM (budget)", - /*INTO*/ null, - /*FROM*/ Project.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ null, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testAggregateGrouping0() { - Object expected = Arrays.asList(Long.valueOf(3), Long.valueOf(2)); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(false, cand.department.count()); - query.groupBy(cand.department); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "count(department)", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ "department", - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testAggregateGrouping1() { - Object expected = Arrays.asList(Double.valueOf("99.996"), Double.valueOf("99.9985")); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(DentalInsurance.class); - QDentalInsurance cand = QDentalInsurance.candidate(); - query.filter(cand.employee.ne((Employee) null)); - query.result(false, cand.lifetimeOrthoBenefit.avg()); - query.groupBy(cand.employee.department); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "AVG(lifetimeOrthoBenefit)", - /*INTO*/ null, - /*FROM*/ DentalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employee != null", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ "employee.department", - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testAggregateGrouping2() { - Object expected = Arrays.asList(new BigDecimal("99.995"), new BigDecimal("99.998")); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(DentalInsurance.class); - QDentalInsurance cand = QDentalInsurance.candidate(); - query.filter(cand.employee.ne((Employee) null)); - query.result(false, cand.lifetimeOrthoBenefit.min()); - query.groupBy(cand.employee.department); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "min(lifetimeOrthoBenefit)", - /*INTO*/ null, - /*FROM*/ DentalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employee != null", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ "employee.department", - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testAggregateGrouping3() { - Object expected = Arrays.asList(new BigDecimal("99.997"), new BigDecimal("99.999")); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(DentalInsurance.class); - QDentalInsurance cand = QDentalInsurance.candidate(); - query.filter(cand.employee.ne((Employee) null)); - query.result(false, cand.lifetimeOrthoBenefit.max()); - query.groupBy(cand.employee.department); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "MAX(lifetimeOrthoBenefit)", - /*INTO*/ null, - /*FROM*/ DentalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employee != null", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ "employee.department", - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testAggregateGrouping4() { - Object expected = Arrays.asList(new BigDecimal("299.988"), new BigDecimal("199.997")); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(DentalInsurance.class); - QDentalInsurance cand = QDentalInsurance.candidate(); - query.filter(cand.employee.ne((Employee) null)); - query.result(false, cand.lifetimeOrthoBenefit.sum()); - query.groupBy(cand.employee.department); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "sum(lifetimeOrthoBenefit)", - /*INTO*/ null, - /*FROM*/ DentalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employee != null", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ "employee.department", - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.11-2 (DefaultUnique) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DefaultUnique.class); + } + + /** */ + public void testThis() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testAggregateNoGrouping0() { + Object expected = Long.valueOf(5); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "COUNT(department)", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ null, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testAggregateNoGrouping1() { + Object expected = Double.valueOf("99.997"); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "avg(lifetimeOrthoBenefit)", + /*INTO*/ null, + /*FROM*/ DentalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ null, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testAggregateNoGrouping2() { + Object expected = new BigDecimal("2000.99"); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "MIN(budget)", + /*INTO*/ null, + /*FROM*/ Project.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ null, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testAggregateNoGrouping3() { + Object expected = new BigDecimal("2500000.99"); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "MAX(budget)", + /*INTO*/ null, + /*FROM*/ Project.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ null, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testAggregateNoGrouping4() { + Object expected = new BigDecimal("2552001.98"); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "SUM (budget)", + /*INTO*/ null, + /*FROM*/ Project.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ null, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testAggregateGrouping0() { + Object expected = Arrays.asList(Long.valueOf(3), Long.valueOf(2)); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(false, cand.department.count()); + query.groupBy(cand.department); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "count(department)", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ "department", + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testAggregateGrouping1() { + Object expected = Arrays.asList(Double.valueOf("99.996"), Double.valueOf("99.9985")); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(DentalInsurance.class); + QDentalInsurance cand = QDentalInsurance.candidate(); + query.filter(cand.employee.ne((Employee)null)); + query.result(false, cand.lifetimeOrthoBenefit.avg()); + query.groupBy(cand.employee.department); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "AVG(lifetimeOrthoBenefit)", + /*INTO*/ null, + /*FROM*/ DentalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employee != null", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ "employee.department", + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testAggregateGrouping2() { + Object expected = Arrays.asList(new BigDecimal("99.995"), new BigDecimal("99.998")); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(DentalInsurance.class); + QDentalInsurance cand = QDentalInsurance.candidate(); + query.filter(cand.employee.ne((Employee)null)); + query.result(false, cand.lifetimeOrthoBenefit.min()); + query.groupBy(cand.employee.department); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "min(lifetimeOrthoBenefit)", + /*INTO*/ null, + /*FROM*/ DentalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employee != null", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ "employee.department", + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testAggregateGrouping3() { + Object expected = Arrays.asList(new BigDecimal("99.997"), new BigDecimal("99.999")); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(DentalInsurance.class); + QDentalInsurance cand = QDentalInsurance.candidate(); + query.filter(cand.employee.ne((Employee)null)); + query.result(false, cand.lifetimeOrthoBenefit.max()); + query.groupBy(cand.employee.department); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "MAX(lifetimeOrthoBenefit)", + /*INTO*/ null, + /*FROM*/ DentalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employee != null", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ "employee.department", + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testAggregateGrouping4() { + Object expected = Arrays.asList(new BigDecimal("299.988"), new BigDecimal("199.997")); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(DentalInsurance.class); + QDentalInsurance cand = QDentalInsurance.candidate(); + query.filter(cand.employee.ne((Employee)null)); + query.result(false, cand.lifetimeOrthoBenefit.sum()); + query.groupBy(cand.employee.department); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "sum(lifetimeOrthoBenefit)", + /*INTO*/ null, + /*FROM*/ DentalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employee != null", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ "employee.department", + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/DistinctCandidateInstances.java b/tck/src/main/java/org/apache/jdo/tck/query/result/DistinctCandidateInstances.java index aadd6fa13..c772c8b68 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/DistinctCandidateInstances.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/DistinctCandidateInstances.java @@ -5,21 +5,26 @@ * 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 + * + * 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.jdo.tck.query.result; +import java.util.ArrayList; import java.util.List; + import javax.jdo.JDOQLTypedQuery; import javax.jdo.Query; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.Person; @@ -29,131 +34,127 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Distinct Candidate Instances.
    - * Keywords: query
    - * Assertion ID: A14.6.9-2.
    - * Assertion Description: Queries against an extent always consider only distinct candidate - * instances, regardless of whether distinct is specified. Queries against a collection might - * contain duplicate candidate instances; the distinct keyword removes duplicates from the candidate - * collection in this case. + *Title: Distinct Candidate Instances. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.9-2. + *
    + *Assertion Description: + * Queries against an extent always consider only distinct candidate instances, + * regardless of whether distinct is specified. + * Queries against a collection might contain duplicate candidate instances; + * the distinct keyword removes duplicates from the candidate collection + * in this case. */ public class DistinctCandidateInstances extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.9-2 (DistintCandidateInstances) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DistinctCandidateInstances.class); - } - - /** */ - public void testExtentQueries0() { - if (isUnconstrainedVariablesSupported()) { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - query.variable("p", Person.class); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ "Project p", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.9-2 (DistintCandidateInstances) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DistinctCandidateInstances.class); } - } - - /** */ - public void testExtentQueries1() { - if (isUnconstrainedVariablesSupported()) { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(true, cand); - query.variable("p", Person.class); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "DISTINCT", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ "Project p", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + + /** */ + public void testExtentQueries0() { + if (isUnconstrainedVariablesSupported()) { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + query.variable("p", Person.class); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ "Project p", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } } - } - - /** */ - public void testCollectionQueries() { - String singleStringQuery = "SELECT FROM " + Person.class.getName(); - String singleStringDistinctQuery = "SELECT DISTINCT FROM " + Person.class.getName(); - List candidates = getPersistentCompanyModelInstancesAsList(new String[] {"emp1", "emp1"}); - Query query = pm.newQuery(); - query.setClass(Person.class); - query.setCandidates(candidates); - query.setResult("this"); - executeJDOQuery( - ASSERTION_FAILED, - query, - singleStringQuery, - false, - null, - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp1"}), - true); - - query.setResult("DISTINCT this"); - executeJDOQuery( - ASSERTION_FAILED, - query, - singleStringDistinctQuery, - false, - null, - getTransientCompanyModelInstancesAsList(new String[] {"emp1"}), - true); - } + /** */ + public void testExtentQueries1() { + if (isUnconstrainedVariablesSupported()) { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(true, cand); + query.variable("p", Person.class); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "DISTINCT", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ "Project p", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + } + + /** */ + public void testCollectionQueries() { + String singleStringQuery = "SELECT FROM " + Person.class.getName(); + String singleStringDistinctQuery = + "SELECT DISTINCT FROM " + Person.class.getName(); + + List candidates = getPersistentCompanyModelInstancesAsList( + new String[]{"emp1", "emp1"}); + Query query = pm.newQuery(); + query.setClass(Person.class); + query.setCandidates(candidates); + query.setResult("this"); + executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery, + false, null, + getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp1"}), true); + + query.setResult("DISTINCT this"); + executeJDOQuery(ASSERTION_FAILED, query, singleStringDistinctQuery, + false, null, + getTransientCompanyModelInstancesAsList(new String[]{"emp1"}), true); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/DistinctQuery.java b/tck/src/main/java/org/apache/jdo/tck/query/result/DistinctQuery.java index 427911f87..e047c22fd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/DistinctQuery.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/DistinctQuery.java @@ -5,194 +5,193 @@ * 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 + * + * 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.jdo.tck.query.result; import java.util.Arrays; -import javax.jdo.JDOQLTypedQuery; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; +import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.QEmployee; import org.apache.jdo.tck.query.QueryElementHolder; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Disctinct Query.
    - * Keywords: query
    - * Assertion ID: A14.6.9-1.
    - * Assertion Description: If distinct is specified, the query result does not include any - * duplicates. If the result parameter specifies more than one result expression, duplicates are - * those with matching values for each result expression. + *Title: Disctinct Query. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.9-1. + *
    + *Assertion Description: + * If distinct is specified, the query result does not include any duplicates. + * If the result parameter specifies more than one result expression, + * duplicates are those with matching values for each result expression. */ public class DistinctQuery extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.9-1 (DistinctQuery) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(DistinctQuery.class); - } - - /** */ - public void testPositive0() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"dept1", "dept1", "dept1", "dept2", "dept2"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(false, cand.department); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "department", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testPositive1() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"dept1", "dept2"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(true, cand.department); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "DISTINCT department", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testPositive2() { - Object expected = - Arrays.asList( - new Object[] { - new Object[] {Long.valueOf(1), "Development"}, - new Object[] {Long.valueOf(1), "Development"}, - new Object[] {Long.valueOf(1), "Development"}, - new Object[] {Long.valueOf(2), "Human Resources"}, - new Object[] {Long.valueOf(2), "Human Resources"} - }); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(false, cand.department.deptid, cand.department.name); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "department.deptid, department.name", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testPositive3() { - Object expected = - Arrays.asList( - new Object[] { - new Object[] {Long.valueOf(1), "Development"}, - new Object[] {Long.valueOf(2), "Human Resources"} - }); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(true, cand.department.deptid, cand.department.name); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "DISTINCT department.deptid, department.name", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.9-1 (DistinctQuery) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DistinctQuery.class); + } + + /** */ + public void testPositive0() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "dept1", "dept1", "dept1", "dept2", "dept2"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(false, cand.department); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "department", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testPositive1() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{ + "dept1", "dept2"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(true, cand.department); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "DISTINCT department", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testPositive2() { + Object expected = Arrays.asList(new Object[] { + new Object[]{Long.valueOf(1),"Development"}, + new Object[]{Long.valueOf(1),"Development"}, + new Object[]{Long.valueOf(1),"Development"}, + new Object[]{Long.valueOf(2),"Human Resources"}, + new Object[]{Long.valueOf(2),"Human Resources"}}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(false, cand.department.deptid, cand.department.name); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "department.deptid, department.name", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testPositive3() { + Object expected = Arrays.asList(new Object[] { + new Object[]{Long.valueOf(1),"Development"}, + new Object[]{Long.valueOf(2),"Human Resources"}}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(true, cand.department.deptid, cand.department.name); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "DISTINCT department.deptid, department.name", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/Grouping.java b/tck/src/main/java/org/apache/jdo/tck/query/result/Grouping.java index 7d1e4c793..1739931c8 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/Grouping.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/Grouping.java @@ -5,20 +5,21 @@ * 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 + * + * 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.jdo.tck.query.result; import java.util.Arrays; -import javax.jdo.JDOQLTypedQuery; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.FullTimeEmployee; import org.apache.jdo.tck.pc.company.QFullTimeEmployee; @@ -26,100 +27,107 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Grouping.
    - * Keywords: query
    - * Assertion ID: A14.6.10-1.
    - * Assertion Description: When grouping is specified, each result expression must be one of: - * an expression contained in the grouping expression; or, an aggregate expression evaluated once - * per group. The query groups all elements where all expressions specified in setGrouping have the - * same values. The query result consists of one element per group. + *Title: Grouping. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.10-1. + *
    + *Assertion Description: + * When grouping is specified, each result expression must be one of: + * an expression contained in the grouping expression; + * or, an aggregate expression evaluated once per group. + * The query groups all elements where all expressions + * specified in setGrouping have the same values. + * The query result consists of one element per group. */ public class Grouping extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.10-1 (Grouping) failed: "; - - /** - * The array of invalid queries which may be executed as single string queries and as API queries. - */ - private static final QueryElementHolder[] INVALID_QUERIES = { - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "department, salary", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ "department", - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Grouping.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.10-1 (Grouping) failed: "; - /** */ - public void testPositive() { - Object expected = - Arrays.asList( - new Object[] { - new Object[] {getTransientCompanyModelInstance("dept1"), Double.valueOf(30000.0)}, - new Object[] {getTransientCompanyModelInstance("dept2"), Double.valueOf(45000.0)} - }); + /** + * The array of invalid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] INVALID_QUERIES = { + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "department, salary", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ "department", + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Grouping.class); + } + + /** */ + public void testPositive() { + Object expected = Arrays.asList(new Object[] { + new Object[] {getTransientCompanyModelInstance("dept1"), Double.valueOf(30000.0)}, + new Object[] {getTransientCompanyModelInstance("dept2"), Double.valueOf(45000.0)}}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - query.result(false, cand.department, cand.salary.sum()); - query.groupBy(cand.department); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + query.result(false, cand.department, cand.salary.sum()); + query.groupBy(cand.department); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "department, SUM(salary)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ "department", - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "department, SUM(salary)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ "department", + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } - /** */ - public void testNegative() { - for (int i = 0; i < INVALID_QUERIES.length; i++) { - compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); - compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + /** */ + public void testNegative() { + for (int i = 0; i < INVALID_QUERIES.length; i++) { + compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], + false); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/IfElseResult.java b/tck/src/main/java/org/apache/jdo/tck/query/result/IfElseResult.java index 9213b5c6b..17e3458b6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/IfElseResult.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/IfElseResult.java @@ -5,22 +5,22 @@ * 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 + * + * 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.jdo.tck.query.result; -import java.math.BigDecimal; import java.util.Arrays; -import javax.jdo.JDOQLTypedQuery; -import javax.jdo.query.IfThenElseExpression; +import java.math.BigDecimal; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.DentalInsurance; import org.apache.jdo.tck.pc.company.Employee; @@ -31,204 +31,200 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; +import javax.jdo.query.IfThenElseExpression; + /** - * Title: IfElseResult.
    - * Keywords: query
    - * Assertion ID: .
    - * Assertion Description: + *Title: IfElseResult. + *
    + *Keywords: query + *
    + *Assertion ID: . + *
    + *Assertion Description: */ public class IfElseResult extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion (IfElseResult) failed: "; - - /** - * The array of invalid queries which may be executed as single string queries and as API queries. - */ - private static final QueryElementHolder[] INVALID_QUERIES = { - // Invalid type of condition expression - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "IF (this.firstname) 0 ELSE 1", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - // missing ELSE - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "IF (this.employee == null) 0", - /*INTO*/ null, - /*FROM*/ DentalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - // type of THEN expr must be the same as type of ELSE expr - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "IF (this.employee == null) 'Michael' ELSE this.employee", - /*INTO*/ null, - /*FROM*/ DentalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NullResults.class); - } - - /** */ - public void testPositive0() { - Object expected = - Arrays.asList("emp1Last", "emp2Last", "emp3Last", "emp4Last", "emp5Last", "No employee"); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(DentalInsurance.class); - QDentalInsurance cand = QDentalInsurance.candidate(); - query.result( - false, - query.ifThenElse(cand.employee.eq((Employee) null), "No employee", cand.employee.lastname)); - query.orderBy(cand.insid.asc()); - - QueryElementHolder holder = + /** */ + private static final String ASSERTION_FAILED = + "Assertion (IfElseResult) failed: "; + + /** + * The array of invalid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] INVALID_QUERIES = { + // Invalid type of condition expression new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "IF (this.employee == null) 'No employee' ELSE this.employee.lastname", - /*INTO*/ null, - /*FROM*/ DentalInsurance.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "this.insid ascending", - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testPositive1() { - Object expected = - Arrays.asList( - new BigDecimal("3000001.188"), new BigDecimal("55000"), new BigDecimal("2201.089")); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Project.class); - QProject cand = QProject.candidate(); - query.result( - false, - query.ifThenElse( - BigDecimal.class, - cand.members.size().gt(2), - cand.budget.mul(new BigDecimal("1.2")), - cand.budget.mul(new BigDecimal("1.1")))); - query.orderBy(cand.projid.asc()); - - QueryElementHolder holder = + /*UNIQUE*/ null, + /*RESULT*/ "IF (this.firstname) 0 ELSE 1", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + // missing ELSE new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "IF (this.members.size() > 2) this.budget * 1.2 ELSE this.budget * 1.1", - /*INTO*/ null, - /*FROM*/ Project.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "this.projid ascending", - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testPositive2() { - Object expected = Arrays.asList("No reviewer", "Reviewer team", "Single reviewer"); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Project.class); - QProject cand = QProject.candidate(); - IfThenElseExpression ifThenElse = - query - .ifThen(cand.reviewers.isEmpty(), "No reviewer") - .ifThen(cand.reviewers.size().eq(1), "Single reviewer") - .elseEnd("Reviewer team"); - query.result(false, ifThenElse); - query.orderBy(cand.projid.asc()); - - QueryElementHolder holder = + /*UNIQUE*/ null, + /*RESULT*/ "IF (this.employee == null) 0", + /*INTO*/ null, + /*FROM*/ DentalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + // type of THEN expr must be the same as type of ELSE expr new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "IF (this.reviewers.isEmpty()) 'No reviewer' " - + "ELSE IF (this.reviewers.size() == 1) 'Single reviewer' ELSE 'Reviewer team'", - /*INTO*/ null, - /*FROM*/ Project.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "this.projid ascending", - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testNegative() { - for (int i = 0; i < INVALID_QUERIES.length; i++) { - compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); - compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + /*UNIQUE*/ null, + /*RESULT*/ "IF (this.employee == null) 'Michael' ELSE this.employee", + /*INTO*/ null, + /*FROM*/ DentalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NullResults.class); + } + + /** */ + public void testPositive0() { + Object expected = Arrays.asList("emp1Last", "emp2Last", "emp3Last", "emp4Last", "emp5Last", "No employee"); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(DentalInsurance.class); + QDentalInsurance cand = QDentalInsurance.candidate(); + query.result(false, + query.ifThenElse(cand.employee.eq((Employee)null), "No employee", cand.employee.lastname)); + query.orderBy(cand.insid.asc()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "IF (this.employee == null) 'No employee' ELSE this.employee.lastname", + /*INTO*/ null, + /*FROM*/ DentalInsurance.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "this.insid ascending", + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testPositive1() { + Object expected = Arrays.asList( + new BigDecimal("3000001.188"), new BigDecimal("55000"), new BigDecimal("2201.089")); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Project.class); + QProject cand = QProject.candidate(); + query.result(false, + query.ifThenElse(BigDecimal.class, cand.members.size().gt(2), + cand.budget.mul(new BigDecimal("1.2")), cand.budget.mul(new BigDecimal("1.1")))); + query.orderBy(cand.projid.asc()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "IF (this.members.size() > 2) this.budget * 1.2 ELSE this.budget * 1.1", + /*INTO*/ null, + /*FROM*/ Project.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "this.projid ascending", + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testPositive2() { + Object expected = Arrays.asList("No reviewer", "Reviewer team", "Single reviewer"); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Project.class); + QProject cand = QProject.candidate(); + IfThenElseExpression ifThenElse = query.ifThen(cand.reviewers.isEmpty(), "No reviewer"). + ifThen(cand.reviewers.size().eq(1), "Single reviewer").elseEnd("Reviewer team"); + query.result(false, ifThenElse); + query.orderBy(cand.projid.asc()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "IF (this.reviewers.isEmpty()) 'No reviewer' " + + "ELSE IF (this.reviewers.size() == 1) 'Single reviewer' ELSE 'Reviewer team'", + /*INTO*/ null, + /*FROM*/ Project.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "this.projid ascending", + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testNegative() { + for (int i = 0; i < INVALID_QUERIES.length; i++) { + compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], + false); + } + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/ImmutableQueryResult.java b/tck/src/main/java/org/apache/jdo/tck/query/result/ImmutableQueryResult.java index a0ad62ee6..3efc4e457 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/ImmutableQueryResult.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/ImmutableQueryResult.java @@ -5,160 +5,177 @@ * 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 + * + * 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.jdo.tck.query.result; import java.util.Collection; + import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Changing query result fails.
    - * Keywords: query
    - * Assertion ID: A14.6.1-7.
    - * Assertion Description: Executing any operation on the result that might change it throws + *Title: Changing query result fails. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.1-7. + *
    + *Assertion Description: + * Executing any operation on the result that might change it throws * UnsupportedOperationException. */ -public class ImmutableQueryResult extends QueryTest { - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.1-7 (ImmutableQueryResult) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ImmutableQueryResult.class); - } - - /** */ - public void testPositive() { - PersistenceManager pm = getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - - // get PrimitiveTypes instance with id 5 - Collection instance5Collection = - (Collection) pm.newQuery(PrimitiveTypes.class, "id == 5").execute(); - PrimitiveTypes instance5 = (PrimitiveTypes) instance5Collection.iterator().next(); - - // get query result collection - Collection result = (Collection) pm.newQuery(PrimitiveTypes.class, "id > 3").execute(); - - // method add - try { - result.add(Integer.valueOf(1)); - fail( - ASSERTION_FAILED, - "Method add called on a query result show throw " + "UnsupportedOperationException"); - } catch (UnsupportedOperationException ex) { - // expected exception - if (debug) - logger.debug("Method add called on a query result throws " + "expected exception " + ex); - } - - // method addAll - try { - result.addAll(instance5Collection); - fail( - ASSERTION_FAILED, - "Method addAll called on a query result show throw " + "UnsupportedOperationException"); - } catch (UnsupportedOperationException ex) { - // expected exception - if (debug) - logger.debug("Method addAll called on a query result throws " + "expected exception " + ex); - } - - // method clear - try { - result.clear(); - fail( - ASSERTION_FAILED, - "Method clear called on a query result show throw " + "UnsupportedOperationException"); - } catch (UnsupportedOperationException ex) { - // expected exception - if (debug) - logger.debug("Method clear called on a query result throws " + "expected exception " + ex); - } - // method remove - try { - result.remove(instance5); - fail( - ASSERTION_FAILED, - "Method remove called on a query result show throw " + "UnsupportedOperationException"); - } catch (UnsupportedOperationException ex) { - // expected exception - if (debug) - logger.debug("Method remove called on a query result throws " + "expected exception " + ex); - } +public class ImmutableQueryResult extends QueryTest { - // method removeAll - try { - result.removeAll(instance5Collection); - fail( - ASSERTION_FAILED, - "Method removeAll called on a query result show throw " - + "UnsupportedOperationException"); - } catch (UnsupportedOperationException ex) { - // expected exception - if (debug) - logger.debug( - "Method removeAll called on a query result " + "throws expected exception " + ex); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.1-7 (ImmutableQueryResult) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ImmutableQueryResult.class); } - - // method retainAll - try { - result.retainAll(instance5Collection); - fail( - ASSERTION_FAILED, - "Method retainAll called on a query result show throw " - + "UnsupportedOperationException"); - } catch (UnsupportedOperationException ex) { - // expected exception - if (debug) - logger.debug( - "Method retainAll called on a query result " + "throws expected exception " + ex); + + /** */ + public void testPositive() { + PersistenceManager pm = getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + + // get PrimitiveTypes instance with id 5 + Collection instance5Collection = (Collection)pm.newQuery( + PrimitiveTypes.class, "id == 5").execute(); + PrimitiveTypes instance5 = + (PrimitiveTypes)instance5Collection.iterator().next(); + + // get query result collection + Collection result = (Collection)pm.newQuery( + PrimitiveTypes.class, "id > 3").execute(); + + // method add + try { + result.add(Integer.valueOf(1)); + fail(ASSERTION_FAILED, + "Method add called on a query result show throw " + + "UnsupportedOperationException"); + } + catch (UnsupportedOperationException ex) { + // expected exception + if (debug) + logger.debug("Method add called on a query result throws " + + "expected exception " + ex); + } + + // method addAll + try { + result.addAll(instance5Collection); + fail(ASSERTION_FAILED, + "Method addAll called on a query result show throw " + + "UnsupportedOperationException"); + } + catch (UnsupportedOperationException ex) { + // expected exception + if (debug) + logger.debug("Method addAll called on a query result throws " + + "expected exception " + ex); + } + + // method clear + try { + result.clear(); + fail(ASSERTION_FAILED, + "Method clear called on a query result show throw " + + "UnsupportedOperationException"); + } + catch (UnsupportedOperationException ex) { + // expected exception + if (debug) + logger.debug("Method clear called on a query result throws " + + "expected exception " + ex); + } + + // method remove + try { + result.remove(instance5); + fail(ASSERTION_FAILED, + "Method remove called on a query result show throw " + + "UnsupportedOperationException"); + } + catch (UnsupportedOperationException ex) { + // expected exception + if (debug) + logger.debug("Method remove called on a query result throws " + + "expected exception " + ex); + } + + // method removeAll + try { + result.removeAll(instance5Collection); + fail(ASSERTION_FAILED, + "Method removeAll called on a query result show throw " + + "UnsupportedOperationException"); + } + catch (UnsupportedOperationException ex) { + // expected exception + if (debug) + logger.debug("Method removeAll called on a query result " + + "throws expected exception " + ex); + } + + // method retainAll + try { + result.retainAll(instance5Collection); + fail(ASSERTION_FAILED, + "Method retainAll called on a query result show throw " + + "UnsupportedOperationException"); + } + catch (UnsupportedOperationException ex) { + // expected exception + if (debug) + logger.debug("Method retainAll called on a query result " + + "throws expected exception " + ex); + } + + // method iterator.remove + try { + result.iterator().remove(); + fail(ASSERTION_FAILED, + "Method remove called on an iterator obtained from a query " + + "result show throw UnsupportedOperationException"); + } + catch (UnsupportedOperationException ex) { + // expected exception + if (debug) + logger.debug( + "Method remove called on an iterator obtained " + + "from a query result throws expected exception " + ex); + } } - // method iterator.remove - try { - result.iterator().remove(); - fail( - ASSERTION_FAILED, - "Method remove called on an iterator obtained from a query " - + "result show throw UnsupportedOperationException"); - } catch (UnsupportedOperationException ex) { - // expected exception - if (debug) - logger.debug( - "Method remove called on an iterator obtained " - + "from a query result throws expected exception " - + ex); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PrimitiveTypes.class); + loadAndPersistPrimitiveTypes(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PrimitiveTypes.class); - loadAndPersistPrimitiveTypes(getPM()); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/MethodsInResult.java b/tck/src/main/java/org/apache/jdo/tck/query/result/MethodsInResult.java index 00aae5213..96083356a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/MethodsInResult.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/MethodsInResult.java @@ -5,20 +5,23 @@ * 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 + * + * 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.jdo.tck.query.result; import java.util.Arrays; + import javax.jdo.JDOQLTypedQuery; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.Employee; @@ -29,235 +32,226 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test using methods in the result expression
    - * Keywords: query result
    - * Assertion ID: A14.6.9-5.
    - * Assertion Description: The result expressions include: method expression: the value of an - * expression calling any of the methods allowed in queries applied to fields is returned. + *Title: Test using methods in the result expression + *
    + *Keywords: query result + *
    + *Assertion ID: A14.6.9-5. + *
    + *Assertion Description: + * The result expressions include: + * method expression: the value of an expression calling any of the methods allowed in + * queries applied to fields is returned. */ public class MethodsInResult extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.9-5 (MethodsInResult) failed: "; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.9-5 (MethodsInResult) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(MethodsInResult.class); + } - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(MethodsInResult.class); - } + public void testCollectionSizeInResult() { + // collection.size() + Object expected = Arrays.asList(Integer.valueOf(3), Integer.valueOf(2)); - public void testCollectionSizeInResult() { - // collection.size() - Object expected = Arrays.asList(Integer.valueOf(3), Integer.valueOf(2)); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + query.result(false, cand.employees.size()); + query.orderBy(cand.name.asc()); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - query.result(false, cand.employees.size()); - query.orderBy(cand.name.asc()); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "this.employees.size()", + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "this.name ascending", + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "this.employees.size()", - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "this.name ascending", - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } + public void testMapSizeInResult() { + // map.size() + Object expected = Arrays.asList( + Integer.valueOf(2), Integer.valueOf(2), Integer.valueOf(2), Integer.valueOf(2), Integer.valueOf(2)); - public void testMapSizeInResult() { - // map.size() - Object expected = - Arrays.asList( - Integer.valueOf(2), - Integer.valueOf(2), - Integer.valueOf(2), - Integer.valueOf(2), - Integer.valueOf(2)); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(false, cand.phoneNumbers.size()); + query.orderBy(cand.lastname.asc(), cand.firstname.asc()); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(false, cand.phoneNumbers.size()); - query.orderBy(cand.lastname.asc(), cand.firstname.asc()); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "this.phoneNumbers.size()", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "this.lastname ascending, this.firstname ascending", + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "this.phoneNumbers.size()", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "this.lastname ascending, this.firstname ascending", - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } + public void testMaxAndSizeInResult() { + // MAX(collection.size()) + Object expected = Integer.valueOf(3); - public void testMaxAndSizeInResult() { - // MAX(collection.size()) - Object expected = Integer.valueOf(3); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + query.result(false, cand.employees.size().max()); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - query.result(false, cand.employees.size().max()); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "MAX(this.employees.size())", + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "MAX(this.employees.size())", - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } + public void testMapGetInResult() { + // map.get() + Object expected = Arrays.asList("1111", "2222", "3333", "3343", "3363"); - public void testMapGetInResult() { - // map.get() - Object expected = Arrays.asList("1111", "2222", "3333", "3343", "3363"); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(false, cand.phoneNumbers.get("home")); + query.orderBy(cand.lastname.asc(), cand.firstname.asc()); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(false, cand.phoneNumbers.get("home")); - query.orderBy(cand.lastname.asc(), cand.firstname.asc()); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "this.phoneNumbers.get('home')", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "this.lastname ascending, this.firstname ascending", + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "this.phoneNumbers.get('home')", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "this.lastname ascending, this.firstname ascending", - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } + public void testSubstringInResult() { + // String.substring() + Object expected = Arrays.asList("mp1", "mp2", "mp3", "mp4", "mp5"); - public void testSubstringInResult() { - // String.substring() - Object expected = Arrays.asList("mp1", "mp2", "mp3", "mp4", "mp5"); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(false, cand.firstname.substring(1, 4)); + query.orderBy(cand.lastname.asc(), cand.firstname.asc()); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(false, cand.firstname.substring(1, 4)); - query.orderBy(cand.lastname.asc(), cand.firstname.asc()); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "this.firstname.substring(1,4)", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "this.lastname ascending, this.firstname ascending", + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "this.firstname.substring(1,4)", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "this.lastname ascending, this.firstname ascending", - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } + public void testIndexOfInResult() { + // String.indexOf() + Object expected = + Arrays.asList(Integer.valueOf(4), Integer.valueOf(4), Integer.valueOf(4), Integer.valueOf(4), Integer.valueOf(4)); - public void testIndexOfInResult() { - // String.indexOf() - Object expected = - Arrays.asList( - Integer.valueOf(4), - Integer.valueOf(4), - Integer.valueOf(4), - Integer.valueOf(4), - Integer.valueOf(4)); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(false, cand.firstname.indexOf("First")); + query.orderBy(cand.lastname.asc(), cand.firstname.asc()); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(false, cand.firstname.indexOf("First")); - query.orderBy(cand.lastname.asc(), cand.firstname.asc()); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "this.firstname.indexOf('First')", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "this.lastname ascending, this.firstname ascending", + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "this.firstname.indexOf('First')", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "this.lastname ascending, this.firstname ascending", - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/NPEInResultExpr.java b/tck/src/main/java/org/apache/jdo/tck/query/result/NPEInResultExpr.java index 5f3211793..b9a3c4c72 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/NPEInResultExpr.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/NPEInResultExpr.java @@ -5,20 +5,21 @@ * 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 + * + * 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.jdo.tck.query.result; import java.util.Arrays; -import javax.jdo.JDOQLTypedQuery; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.Employee; @@ -28,98 +29,104 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: NullPointerException in Result Expression.
    - * Keywords: query
    - * Assertion ID: A14.6.9-4.
    - * Assertion Description: If any result is a navigational expression, and a non-terminal - * field or variable has a null value for a particular set of conditions (the result calculation - * would throw NullPointerException), then the result is null for that result expression. + *Title: NullPointerException in Result Expression. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.9-4. + *
    + *Assertion Description: + * If any result is a navigational expression, + * and a non-terminal field or variable has a null value for a particular set + * of conditions (the result calculation would throw NullPointerException), + * then the result is null for that result expression. */ public class NPEInResultExpr extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.9-4 (NPEInResultExpr) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NPEInResultExpr.class); - } - - /** */ - public void testPositive0() { - Object expected = Arrays.asList("emp2Last", null, "emp2Last", "emp2Last", "emp2Last"); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.9-4 (NPEInResultExpr) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NPEInResultExpr.class); + } + + /** */ + public void testPositive0() { + Object expected = Arrays.asList("emp2Last", null, "emp2Last", "emp2Last", "emp2Last"); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(false, cand.manager.lastname); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(false, cand.manager.lastname); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "manager.lastname", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "manager.lastname", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } - /** */ - public void testPositive1() { - Object expected = Arrays.asList("emp2Last", null, "emp2Last", "emp2Last", "emp2Last"); + /** */ + public void testPositive1() { + Object expected = Arrays.asList("emp2Last", null, "emp2Last", "emp2Last", "emp2Last"); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - QEmployee e = QEmployee.variable("e"); - query.filter(cand.employees.contains(e)); - query.result(false, e.manager.lastname); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + QEmployee e = QEmployee.variable("e"); + query.filter(cand.employees.contains(e)); + query.result(false, e.manager.lastname); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "e.manager.lastname", - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employees.contains(e)", - /*VARIABLES*/ "Employee e", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "e.manager.lastname", + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.contains(e)", + /*VARIABLES*/ "Employee e", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/NullResults.java b/tck/src/main/java/org/apache/jdo/tck/query/result/NullResults.java index 09d888d47..415b86195 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/NullResults.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/NullResults.java @@ -5,20 +5,21 @@ * 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 + * + * 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.jdo.tck.query.result; import java.util.Arrays; -import javax.jdo.JDOQLTypedQuery; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Employee; import org.apache.jdo.tck.pc.company.QEmployee; @@ -26,128 +27,132 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Null Results.
    - * Keywords: query
    - * Assertion ID: A14.6.9-7.
    - * Assertion Description: If the returned value from a query specifying a result is null, + *Title: Null Results. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.9-7. + *
    + *Assertion Description: + * If the returned value from a query specifying a result is null, * this indicates that the expression specified as the result was null. */ public class NullResults extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.9-7 (NullResults) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NullResults.class); - } - - /** */ - public void testUnique() { - Object expected = null; - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.filter(cand.lastname.eq("emp2Last")); - query.result(false, cand.manager); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "manager", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "lastname == 'emp2Last'", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testNavigation() { - Object expected = Arrays.asList(new Object[] {null}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.filter(cand.lastname.eq("emp2Last")); - query.result(false, cand.manager); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "manager", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "lastname == 'emp2Last'", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testDistinctNavigation() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp2", null}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(true, cand.manager); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "DISTINCT manager", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.9-7 (NullResults) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NullResults.class); + } + + /** */ + public void testUnique() { + Object expected = null; + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.filter(cand.lastname.eq("emp2Last")); + query.result(false, cand.manager); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "manager", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "lastname == 'emp2Last'", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testNavigation() { + Object expected = Arrays.asList(new Object[]{null}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.filter(cand.lastname.eq("emp2Last")); + query.result(false, cand.manager); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "manager", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "lastname == 'emp2Last'", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testDistinctNavigation() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp2", null}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(true, cand.manager); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "DISTINCT manager", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/ProjectedSCODoesNotTrackChanges.java b/tck/src/main/java/org/apache/jdo/tck/query/result/ProjectedSCODoesNotTrackChanges.java index 2f8143000..e434e4e58 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/ProjectedSCODoesNotTrackChanges.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/ProjectedSCODoesNotTrackChanges.java @@ -5,162 +5,162 @@ * 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 + * + * 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.jdo.tck.query.result; import java.util.Calendar; import java.util.Date; + import javax.jdo.JDOHelper; import javax.jdo.Query; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.Address; import org.apache.jdo.tck.pc.company.Company; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Projected Second Class Objects Do Not Track Their Changes
    - * Keywords: embedded query
    - * Assertion ID: A14.6.9-9.
    - * Assertion Description: If an SCO field is in the result, the projected field is not owned - * by any persistent instance, and modifying the SCO value has no effect on any persistent instance. - * If an FCO field is in the result, the projected field is a persistent instance, and modifications - * made to the instance are reflected as changes to the datastore per transaction requirements. + *Title: Projected Second Class Objects Do Not Track Their Changes + *
    + *Keywords: embedded query + *
    + *Assertion ID: A14.6.9-9. + *
    + *Assertion Description: + * If an SCO field is in the result, the projected field is not owned by any persistent + * instance, and modifying the SCO value has no effect on any persistent instance. + * If an FCO field is in the result, the projected field is a persistent instance, and + * modifications made to the instance are reflected as changes to the datastore per + * transaction requirements. */ + public class ProjectedSCODoesNotTrackChanges extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.9-3 (ProjectedSCODoesNotTrackChanges) failed: "; - - private static final Date expectedDate; - - static { - Calendar cal = Calendar.getInstance(); - cal.set(1970, 0, 1, 0, 0, 0); - cal.set(Calendar.MILLISECOND, 0); - expectedDate = cal.getTime(); - } - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ProjectedSCODoesNotTrackChanges.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(Company.class); - } - - private Company getPersistentNewInstance(long companyid) { - Company obj = - new Company(companyid, "MyCompany", expectedDate, new Address(0, "", "", "", "", "")); - pm.makePersistent(obj); // obj should transition to persistent-new - int curr = currentState(obj); - if (curr != PERSISTENT_NEW) { - fail( - ASSERTION_FAILED, - "Unable to create persistent-new instance " - + "from transient instance via makePersistent(), state is " - + states[curr]); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.9-3 (ProjectedSCODoesNotTrackChanges) failed: "; + + private static final Date expectedDate; + + static { + Calendar cal = Calendar.getInstance(); + cal.set(1970, 0, 1, 0, 0, 0); + cal.set(Calendar.MILLISECOND, 0); + expectedDate = cal.getTime(); + } + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ProjectedSCODoesNotTrackChanges.class); } - return obj; - } - - /** - * This tests that when an embedded field is selected and modified, there is no change in the - * owned instance. - */ - public void testEmbeddedField() { - String testZip = "94040"; - pm = getPM(); - pm.currentTransaction().begin(); - Company comp = getPersistentNewInstance(0); - pm.currentTransaction().commit(); - - // Select address, modify, and commit - pm.currentTransaction().begin(); - Query query = pm.newQuery(Company.class, "name.startsWith(\"MyCompany\")"); - query.setResult("address"); - query.setUnique(true); - Address myCompanyAddress = (Address) query.execute(); - myCompanyAddress.setZipcode(testZip); - if (JDOHelper.isDirty((Object) comp)) { - appendMessage( - "Expected Company instance not to be dirty; " - + "actual state is " - + getStateOfInstance((Object) comp)); + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(Company.class); } - pm.currentTransaction().commit(); - - // Check value of address - pm.currentTransaction().begin(); - Address persistedCompanyAddress = (Address) query.execute(); - String actualZip = persistedCompanyAddress.getZipcode(); - if (actualZip.equals(testZip)) { - appendMessage( - "Expected projected field value is " + testZip + "; actual value is " + actualZip); + + private Company getPersistentNewInstance(long companyid) { + Company obj = new Company(companyid, "MyCompany", expectedDate, + new Address(0,"","","","","")); + pm.makePersistent(obj); // obj should transition to persistent-new + int curr = currentState(obj); + if( curr != PERSISTENT_NEW ){ + fail(ASSERTION_FAILED, + "Unable to create persistent-new instance " + + "from transient instance via makePersistent(), state is " + + states[curr]); + } + return obj; } - logger.debug("MyCompany's zipcode is '" + actualZip + "'"); - pm.currentTransaction().commit(); - failOnError(); - } - - /** - * This tests that when a Date field is selected and modified, there is no change in the owned - * instance. - */ - public void testDateField() { - pm = getPM(); - pm.currentTransaction().begin(); - Company comp = getPersistentNewInstance(0); - pm.currentTransaction().commit(); - - // Select date, modify, and commit - pm.currentTransaction().begin(); - Query query = pm.newQuery(Company.class, "name.startsWith(\"MyCompany\")"); - query.setResult("founded"); - query.setUnique(true); - Date retrievedDate = (Date) query.execute(); - retrievedDate.setTime(123789L); - - if (JDOHelper.isDirty((Object) comp)) { - appendMessage( - "Expected Company instance not to be dirty; " - + "actual state is " - + getStateOfInstance((Object) comp)); + + /** This tests that when an embedded field is selected + * and modified, there is no change in the owned instance. + */ + public void testEmbeddedField() { + String testZip = "94040"; + pm = getPM(); + pm.currentTransaction().begin(); + Company comp = getPersistentNewInstance(0); + pm.currentTransaction().commit(); + + // Select address, modify, and commit + pm.currentTransaction().begin(); + Query query = pm.newQuery(Company.class, + "name.startsWith(\"MyCompany\")"); + query.setResult("address"); + query.setUnique(true); + Address myCompanyAddress = (Address) query.execute(); + myCompanyAddress.setZipcode(testZip); + if (JDOHelper.isDirty((Object)comp)) { + appendMessage("Expected Company instance not to be dirty; " + + "actual state is " + getStateOfInstance((Object)comp)); + } + pm.currentTransaction().commit(); + + // Check value of address + pm.currentTransaction().begin(); + Address persistedCompanyAddress = (Address) query.execute(); + String actualZip = persistedCompanyAddress.getZipcode(); + if (actualZip.equals(testZip)) { + appendMessage("Expected projected field value is " + + testZip + "; actual value is " + actualZip); + } + logger.debug("MyCompany's zipcode is '" + actualZip + "'"); + pm.currentTransaction().commit(); + failOnError(); } - pm.currentTransaction().commit(); - - // Check value of date - pm.currentTransaction().begin(); - Date actualDate = (Date) query.execute(); - if (!actualDate.equals(expectedDate)) { - appendMessage( - "Expected projected field value is " - + expectedDate - + "; actual value is " - + actualDate - + "; modified retrieved value is " - + retrievedDate); + + /** This tests that when a Date field is selected + * and modified, there is no change in the owned instance. + */ + public void testDateField() { + pm = getPM(); + pm.currentTransaction().begin(); + Company comp = getPersistentNewInstance(0); + pm.currentTransaction().commit(); + + // Select date, modify, and commit + pm.currentTransaction().begin(); + Query query = pm.newQuery(Company.class, + "name.startsWith(\"MyCompany\")"); + query.setResult("founded"); + query.setUnique(true); + Date retrievedDate = (Date) query.execute(); + retrievedDate.setTime(123789L); + + if (JDOHelper.isDirty((Object)comp)) { + appendMessage("Expected Company instance not to be dirty; " + + "actual state is " + getStateOfInstance((Object)comp)); + } + pm.currentTransaction().commit(); + + // Check value of date + pm.currentTransaction().begin(); + Date actualDate = (Date) query.execute(); + if (!actualDate.equals(expectedDate)) { + appendMessage("Expected projected field value is " + + expectedDate + "; actual value is " + actualDate + + "; modified retrieved value is " + retrievedDate); + } + logger.debug("MyCompany's founded date is '" + actualDate + "'"); + pm.currentTransaction().commit(); + failOnError(); } - logger.debug("MyCompany's founded date is '" + actualDate + "'"); - pm.currentTransaction().commit(); - failOnError(); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/ResultClassRequirements.java b/tck/src/main/java/org/apache/jdo/tck/query/result/ResultClassRequirements.java index 441567a2b..dc98b853e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/ResultClassRequirements.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/ResultClassRequirements.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,7 +20,8 @@ import java.math.BigDecimal; import java.util.Arrays; import java.util.Map; -import javax.jdo.JDOQLTypedQuery; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.FullTimeEmployee; import org.apache.jdo.tck.pc.company.Project; @@ -36,510 +37,496 @@ import org.apache.jdo.tck.util.BatchTestRunner; import org.apache.jdo.tck.util.ConversionHelper; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Result Class Requirements.
    - * Keywords: query
    - * Assertion ID: A14.6.12-1.
    - * Assertion Description: The result class may be one of the java.lang classes ... + *Title: Result Class Requirements. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.12-1. + *
    + *Assertion Description: + * The result class may be one of the java.lang classes ... */ public class ResultClassRequirements extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A14.6.12-1 (ResultClassRequirements) failed: "; - - /** - * The array of invalid queries which may be executed as single string queries and as API queries. - */ - private static final QueryElementHolder[] INVALID_QUERIES = { - // JDK class - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "personid, lastname", - /*INTO*/ Long.class, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - - // JDK class, non assignment compatible - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "this", - /*INTO*/ Long.class, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - - // TCK class, salary field is not assignment compatible - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "personid AS l, salary AS s", - /*INTO*/ LongString.class, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - - // TCK class, non existing constructor - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "new LongString(personid)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ "import org.apache.jdo.tck.query.result.classes.LongString;", - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - - // TCK class, no no-args constructor - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "personid", - /*INTO*/ MissingNoArgsConstructor.class, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - - // TCK class, no no-args constructor - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "personid", - /*INTO*/ NoFieldsNoMethods.class, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - }; - - // Two dimensional arrays to be converted to maps - // in the expected result. - private static Object[][] emp1Map = { - {"id", Long.valueOf(1)}, - {"name", "emp1Last"} - }; - private static Object[][] emp2Map = { - {"id", Long.valueOf(2)}, - {"name", "emp2Last"} - }; - private static Object[][] emp5Map = { - {"id", Long.valueOf(5)}, - {"name", "emp5Last"} - }; - private static Object[][] publicPutMethod1 = { - {"personid", Long.valueOf(1)}, {"lastname", "emp1Last"} - }; - private static Object[][] publicPutMethod2 = { - {"personid", Long.valueOf(2)}, {"lastname", "emp2Last"} - }; - private static Object[][] publicPutMethod5 = { - {"personid", Long.valueOf(5)}, {"lastname", "emp5Last"} - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ResultClassRequirements.class); - } - - /** */ - public void testLong() { - Object expected = Arrays.asList(Long.valueOf(1), Long.valueOf(2), Long.valueOf(5)); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - query.result(false, cand.personid); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "personid", - /*INTO*/ Long.class, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, Long.class, true, expected); - } - - /** */ - public void testDouble() { - Object expected = - Arrays.asList(Double.valueOf(20000.0), Double.valueOf(10000.0), Double.valueOf(45000.0)); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - query.result(false, cand.salary); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "salary", - /*INTO*/ Double.class, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, Double.class, true, expected); - } - - /** */ - public void testBigDecimal() { - Object expected = - Arrays.asList( - new BigDecimal("2500000.99"), new BigDecimal("50000.00"), new BigDecimal("2000.99")); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Project.class); - QProject cand = QProject.candidate(); - query.result(false, cand.budget); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "budget", - /*INTO*/ BigDecimal.class, - /*FROM*/ Project.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, BigDecimal.class, true, expected); - } - - /** */ - public void testDate() { - Object expected = - Arrays.asList( - CompanyModelReader.stringToUtilDate("1/Jan/1999"), - CompanyModelReader.stringToUtilDate("1/Jul/2003"), - CompanyModelReader.stringToUtilDate("15/Aug/1998")); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - query.result(false, cand.hiredate); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "hiredate", - /*INTO*/ java.util.Date.class, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, java.util.Date.class, true, expected); - } - - /** */ - public void testMap() { - Object expected = - Arrays.asList( - ConversionHelper.arrayToMap(emp1Map), - ConversionHelper.arrayToMap(emp2Map), - ConversionHelper.arrayToMap(emp5Map)); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - // JDOQLTypedQuery API: Map Result - query.result(false, cand.personid.as("id"), cand.lastname.as("name")); - - QueryElementHolder holder = + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.12-1 (ResultClassRequirements) failed: "; + + /** + * The array of invalid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] INVALID_QUERIES = { + // JDK class new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "personid AS id, lastname AS name", - /*INTO*/ Map.class, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, Map.class, true, expected); - } - - /** */ - public void testUserDefinedResultClass() { - Object expected = - Arrays.asList( - new LongString(1, "emp1Last"), - new LongString(2, "emp2Last"), - new LongString(5, "emp5Last")); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - // JDOQLTypedQuery API: user defined class - query.result(false, cand.personid.as("l"), cand.lastname.as("s")); - - QueryElementHolder holder = + /*UNIQUE*/ null, + /*RESULT*/ "personid, lastname", + /*INTO*/ Long.class, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + + // JDK class, non assignment compatible new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "personid AS l, lastname AS s", - /*INTO*/ LongString.class, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, LongString.class, true, expected); - } - - /** */ - public void testConstructor() { - Object expected = - Arrays.asList( - new LongString(1, "emp1Last"), - new LongString(2, "emp2Last"), - new LongString(5, "emp5Last")); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - // JDOQLTypedQuery API: constructor - query.result(false, cand.personid, cand.lastname); - - QueryElementHolder holder = + /*UNIQUE*/ null, + /*RESULT*/ "this", + /*INTO*/ Long.class, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + + // TCK class, salary field is not assignment compatible new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "new LongString(personid, lastname)", - /*INTO*/ null, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ "import org.apache.jdo.tck.query.result.classes.LongString;", - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, LongString.class, true, expected); - } - - /** */ - public void testConstructorWithoutConstructorCall() { - Object expected = - Arrays.asList( - new LongString(1, "emp1Last"), - new LongString(2, "emp2Last"), - new LongString(5, "emp5Last")); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - // JDOQLTypedQuery API: constructor - query.result(false, cand.personid, cand.lastname); - - QueryElementHolder holder = + /*UNIQUE*/ null, + /*RESULT*/ "personid AS l, salary AS s", + /*INTO*/ LongString.class, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + + // TCK class, non existing constructor new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "personid, lastname", - /*INTO*/ LongString.class, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, LongString.class, true, expected); - } - - /** */ - public void testFields() { - Object expected = - Arrays.asList(new PublicLongField(1), new PublicLongField(2), new PublicLongField(5)); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - // JDOQLTypedQuery API: - query.result(false, cand.personid.as("l")); - - QueryElementHolder holder = + /*UNIQUE*/ null, + /*RESULT*/ "new LongString(personid)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ "import org.apache.jdo.tck.query.result.classes.LongString;", + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + + // TCK class, no no-args constructor new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "personid AS l", - /*INTO*/ PublicLongField.class, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, PublicLongField.class, true, expected); - } - - /** */ - public void testPut() { - Object expected = - Arrays.asList( - new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod1)), - new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod2)), - new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod5))); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); - QFullTimeEmployee cand = QFullTimeEmployee.candidate(); - // JDOQLTypedQuery API: constructor - query.result(false, cand.personid.as("personid"), cand.lastname.as("lastname")); - - QueryElementHolder holder = + /*UNIQUE*/ null, + /*RESULT*/ "personid", + /*INTO*/ MissingNoArgsConstructor.class, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + + // TCK class, no no-args constructor new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "personid, lastname", - /*INTO*/ PublicPutMethod.class, - /*FROM*/ FullTimeEmployee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, PublicPutMethod.class, true, expected); - } - - /** */ - public void testNegative() { - for (int i = 0; i < INVALID_QUERIES.length; i++) { - compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); - compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + /*UNIQUE*/ null, + /*RESULT*/ "personid", + /*INTO*/ NoFieldsNoMethods.class, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + }; + + // Two dimensional arrays to be converted to maps + // in the expected result. + private static Object[][] emp1Map = + {{"id", Long.valueOf(1)}, + {"name", "emp1Last"}}; + private static Object[][] emp2Map = + {{"id", Long.valueOf(2)}, + {"name", "emp2Last"}}; + private static Object[][] emp5Map = + {{"id", Long.valueOf(5)}, + {"name", "emp5Last"}}; + private static Object[][] publicPutMethod1 = + {{"personid", Long.valueOf(1)}, {"lastname", "emp1Last"}}; + private static Object[][] publicPutMethod2 = + {{"personid", Long.valueOf(2)}, {"lastname", "emp2Last"}}; + private static Object[][] publicPutMethod5 = + {{"personid", Long.valueOf(5)}, {"lastname", "emp5Last"}}; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ResultClassRequirements.class); + } + + /** */ + public void testLong() { + Object expected = Arrays.asList(Long.valueOf(1), Long.valueOf(2), Long.valueOf(5)); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + query.result(false, cand.personid); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "personid", + /*INTO*/ Long.class, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, Long.class, true, expected); + } + + /** */ + public void testDouble() { + Object expected = Arrays.asList(Double.valueOf(20000.0), Double.valueOf(10000.0), Double.valueOf(45000.0)); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + query.result(false, cand.salary); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "salary", + /*INTO*/ Double.class, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, Double.class, true, expected); + } + + /** */ + public void testBigDecimal() { + Object expected = Arrays.asList( + new BigDecimal("2500000.99"), new BigDecimal("50000.00"), new BigDecimal("2000.99")); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Project.class); + QProject cand = QProject.candidate(); + query.result(false, cand.budget); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "budget", + /*INTO*/ BigDecimal.class, + /*FROM*/ Project.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, BigDecimal.class, true, expected); + } + + /** */ + public void testDate() { + Object expected = Arrays.asList( + CompanyModelReader.stringToUtilDate("1/Jan/1999"), + CompanyModelReader.stringToUtilDate("1/Jul/2003"), + CompanyModelReader.stringToUtilDate("15/Aug/1998")); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + query.result(false, cand.hiredate); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "hiredate", + /*INTO*/ java.util.Date.class, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, java.util.Date.class, true, expected); + } + + /** */ + public void testMap() { + Object expected = Arrays.asList( + ConversionHelper.arrayToMap(emp1Map), + ConversionHelper.arrayToMap(emp2Map), + ConversionHelper.arrayToMap(emp5Map)); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + // JDOQLTypedQuery API: Map Result + query.result(false, cand.personid.as("id"), cand.lastname.as("name")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "personid AS id, lastname AS name", + /*INTO*/ Map.class, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, Map.class, true, expected); + } + + /** */ + public void testUserDefinedResultClass() { + Object expected = Arrays.asList( + new LongString(1, "emp1Last"), + new LongString(2, "emp2Last"), + new LongString(5, "emp5Last")); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + // JDOQLTypedQuery API: user defined class + query.result(false, cand.personid.as("l"), cand.lastname.as("s")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "personid AS l, lastname AS s", + /*INTO*/ LongString.class, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, LongString.class, true, expected); + } + + /** */ + public void testConstructor() { + Object expected = Arrays.asList( + new LongString(1, "emp1Last"), + new LongString(2, "emp2Last"), + new LongString(5, "emp5Last")); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + // JDOQLTypedQuery API: constructor + query.result(false, cand.personid, cand.lastname); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "new LongString(personid, lastname)", + /*INTO*/ null, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ "import org.apache.jdo.tck.query.result.classes.LongString;", + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, LongString.class, true, expected); + } + + /** */ + public void testConstructorWithoutConstructorCall() { + Object expected = Arrays.asList( + new LongString(1, "emp1Last"), + new LongString(2, "emp2Last"), + new LongString(5, "emp5Last")); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + // JDOQLTypedQuery API: constructor + query.result(false, cand.personid, cand.lastname); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "personid, lastname", + /*INTO*/ LongString.class, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, LongString.class, true, expected); + } + + /** */ + public void testFields() { + Object expected = Arrays.asList( + new PublicLongField(1), + new PublicLongField(2), + new PublicLongField(5)); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + // JDOQLTypedQuery API: + query.result(false, cand.personid.as("l")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "personid AS l", + /*INTO*/ PublicLongField.class, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, PublicLongField.class, true, expected); + } + + /** */ + public void testPut() { + Object expected = Arrays.asList( + new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod1)), + new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod2)), + new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod5))); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class); + QFullTimeEmployee cand = QFullTimeEmployee.candidate(); + // JDOQLTypedQuery API: constructor + query.result(false, cand.personid.as("personid"), cand.lastname.as("lastname")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "personid, lastname", + /*INTO*/ PublicPutMethod.class, + /*FROM*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, PublicPutMethod.class, true, expected); + } + + /** */ + public void testNegative() { + for (int i = 0; i < INVALID_QUERIES.length; i++) { + compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], + false); + } + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/ResultExpressions.java b/tck/src/main/java/org/apache/jdo/tck/query/result/ResultExpressions.java index 9ab97a9d6..352e4daeb 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/ResultExpressions.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/ResultExpressions.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -20,8 +20,8 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import javax.jdo.JDOQLTypedQuery; -import javax.jdo.query.Expression; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.Employee; @@ -35,678 +35,670 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; +import javax.jdo.query.Expression; + /** - * Title: Result Expressions.
    - * Keywords: query
    - * Assertion ID: A14.6.9-5.
    - * Assertion Description: The result expressions include: ... The result expression can be - * explicitly cast using the (cast) operator. + *Title: Result Expressions. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.9-5. + *
    + *Assertion Description: + * The result expressions include: ... + * The result expression can be explicitly cast using the (cast) operator. */ public class ResultExpressions extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.9-5 (ResultExpressions) failed: "; - - /** - * The array of invalid queries which may be executed as single string queries and as API queries. - */ - private static final QueryElementHolder[] INVALID_QUERIES = { - // unknown field x - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "x", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - // field salary is declared in a subclass of the candidate class - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "salary", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - // project collection field - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "employees", - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null), - // project map field - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "phoneNumbers", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null) - }; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ResultExpressions.class); - } - - /** */ - public void testThis() { - Object expectedResult = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(false, cand); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "this", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expectedResult); - } - - /** */ - public void testField() { - Object expectedResult = - Arrays.asList( - Long.valueOf(1), Long.valueOf(2), Long.valueOf(3), Long.valueOf(4), Long.valueOf(5)); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(false, cand.personid); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "personid", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); - } - - /** */ - public void testVariableField() { - Object expectedResult = Arrays.asList(new Object[] {Long.valueOf(1)}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - QProject p = QProject.variable("p"); - query.result(false, p.projid); - query.filter(cand.projects.contains(p).and(cand.personid.eq(1l))); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "p.projid", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "projects.contains(p) && personid == 1", - /*VARIABLES*/ "Project p", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); - } - - /** */ - public void testVariable() { - Object expectedResult = getTransientCompanyModelInstancesAsList(new String[] {"proj1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - QProject variable = QProject.variable("p"); - query.result(false, variable); - query.filter(cand.projects.contains(variable).and(cand.personid.eq(1l))); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "p", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "projects.contains(p) && personid == 1", - /*VARIABLES*/ "Project p", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); - } - - /** */ - public void testCountThis() { - // COUNT(this) - Object expectedResult = Long.valueOf(5); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(false, cand.count()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "COUNT(this)", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); - } - - /** */ - public void testCountVariable() { - // COUNT(variable) - Object expectedResult = Long.valueOf(1); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - QProject p = QProject.variable("p"); - query.result(false, p.count()); - query.filter(cand.projects.contains(p).and(cand.personid.eq(1l))); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "COUNT(p)", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "projects.contains(p) && personid == 1", - /*VARIABLES*/ "Project p", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); - } - - /** */ - public void testSum() { - // SUM - Object expectedResult = Long.valueOf(1 + 2 + 3 + 4 + 5); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(false, cand.personid.sum()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "SUM(personid)", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); - } - - /** */ - public void testMin() { - // MIN - Object expectedResult = Long.valueOf(1); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(false, cand.personid.min()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "MIN(personid)", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); - } - - /** */ - public void testMax() { - // MAX - Object expectedResult = Long.valueOf(5); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(false, cand.personid.max()); - - QueryElementHolder holder = + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.9-5 (ResultExpressions) failed: "; + + /** + * The array of invalid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] INVALID_QUERIES = { + // unknown field x new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "MAX(personid)", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); - } - - /** */ - public void testAvg() { - // AVG - Object expectedResult = Double.valueOf(3); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(false, cand.personid.avg()); - - QueryElementHolder holder = + /*UNIQUE*/ null, + /*RESULT*/ "x", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + // field salary is declared in a subclass of the candidate class new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "AVG(personid)", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); - } - - /** */ - public void testFieldExpression() { - // field expression - Object expectedResult = - Arrays.asList( - Long.valueOf(2), Long.valueOf(3), Long.valueOf(4), Long.valueOf(5), Long.valueOf(6)); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.result(false, cand.personid.add(1)); - - QueryElementHolder holder = + /*UNIQUE*/ null, + /*RESULT*/ "salary", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + // project collection field new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "personid + 1", - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); - } - - /** */ - public void testNavigationalExpressionThis() { - // navigational expression this - Object expectedResult = - Arrays.asList( - Long.valueOf(1), Long.valueOf(2), Long.valueOf(3), Long.valueOf(4), Long.valueOf(5)); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(false, cand.personid); - - QueryElementHolder holder = + /*UNIQUE*/ null, + /*RESULT*/ "employees", + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + // project map field new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "this.personid", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); - } - - /** */ - public void testNavigationalExpressionVariable() { - // navigational expression variable - Object expectedResult = Arrays.asList(new Object[] {"Development", "Human Resources"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - QEmployee e = QEmployee.variable("e"); - Expression eExpr = query.variable("e", Employee.class); - query.result(true, e.department.name); - query.filter(cand.team.contains(eExpr).and(cand.personid.eq(2l))); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "distinct e.department.name", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "team.contains(e) && personid == 2", - /*VARIABLES*/ "Employee e", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); - } - - /** */ - public void testNavigationalExpressionParameter() { - // navigational expression parameter - Object expectedResult = Arrays.asList(Long.valueOf(1)); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - QProject p = QProject.parameter("p"); - query.parameter("p", Project.class); - query.result(false, p.projid); - query.filter(cand.personid.eq(1l).and(p.projid.eq(cand.personid))); - - Map paramValues = new HashMap<>(); - paramValues.put("p", getPersistentCompanyModelInstance("proj1")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "p.projid", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "personid == 1 && p.projid == this.personid", - /*VARIABLES*/ null, - /*PARAMETERS*/ "Project p", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); - } - - /** */ - public void testNavigationalExpressionField() { - // navigational expression field - Object expectedResult = Arrays.asList(new Object[] {Long.valueOf(1)}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(false, cand.department.deptid); - query.filter(cand.personid.eq(1l)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "department.deptid", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "personid == 1", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); - } - - /** */ - public void testParameter() { - // parameter - Object expectedResult = getTransientCompanyModelInstancesAsList(new String[] {"proj1"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - QProject p = QProject.parameter("p"); - query.parameter("p", Project.class); - query.result(false, p); - query.filter(cand.personid.eq(1l).and(cand.personid.eq(p.projid))); - - Map paramValues = new HashMap<>(); - paramValues.put("p", getPersistentCompanyModelInstance("proj1")); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "p", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "personid == 1 && personid == p.projid", - /*VARIABLES*/ null, - /*PARAMETERS*/ "Project p", - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ paramValues); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); - } - - /** */ - public void testCast() { - // cast - Object expectedResult = getTransientCompanyModelInstancesAsList(new String[] {"emp2"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - query.result(false, cand.manager.cast(FullTimeEmployee.class)); - query.filter(cand.personid.eq(1l)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "(FullTimeEmployee)manager", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "personid == 1", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); - executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); - } - - /** */ - public void testNegative() { - for (int i = 0; i < INVALID_QUERIES.length; i++) { - compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); - compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + /*UNIQUE*/ null, + /*RESULT*/ "phoneNumbers", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ResultExpressions.class); + } + + /** */ + public void testThis() { + Object expectedResult = getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(false, cand); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "this", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expectedResult); + } + + /** */ + public void testField() { + Object expectedResult = Arrays.asList( + Long.valueOf(1), Long.valueOf(2), Long.valueOf(3), Long.valueOf(4), Long.valueOf(5)); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(false, cand.personid); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "personid", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); + } + + /** */ + public void testVariableField() { + Object expectedResult = Arrays.asList(new Object[]{Long.valueOf(1)}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + QProject p = QProject.variable("p"); + query.result(false, p.projid); + query.filter(cand.projects.contains(p).and(cand.personid.eq(1l))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "p.projid", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "projects.contains(p) && personid == 1", + /*VARIABLES*/ "Project p", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); + } + + /** */ + public void testVariable() { + Object expectedResult = getTransientCompanyModelInstancesAsList(new String[]{"proj1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + QProject variable = QProject.variable("p"); + query.result(false, variable); + query.filter(cand.projects.contains(variable).and(cand.personid.eq(1l))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "p", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "projects.contains(p) && personid == 1", + /*VARIABLES*/ "Project p", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); + } + + /** */ + public void testCountThis() { + // COUNT(this) + Object expectedResult = Long.valueOf(5); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(false, cand.count()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "COUNT(this)", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); + } + + /** */ + public void testCountVariable() { + // COUNT(variable) + Object expectedResult = Long.valueOf(1); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + QProject p = QProject.variable("p"); + query.result(false, p.count()); + query.filter(cand.projects.contains(p).and(cand.personid.eq(1l))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "COUNT(p)", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "projects.contains(p) && personid == 1", + /*VARIABLES*/ "Project p", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); + } + + /** */ + public void testSum() { + // SUM + Object expectedResult = Long.valueOf(1+2+3+4+5); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(false, cand.personid.sum()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "SUM(personid)", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); + } + + /** */ + public void testMin() { + // MIN + Object expectedResult = Long.valueOf(1); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(false, cand.personid.min()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "MIN(personid)", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); + } + + /** */ + public void testMax() { + // MAX + Object expectedResult = Long.valueOf(5); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(false, cand.personid.max()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "MAX(personid)", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); + } + + /** */ + public void testAvg() { + // AVG + Object expectedResult = Double.valueOf(3); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(false, cand.personid.avg()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "AVG(personid)", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); + } + + /** */ + public void testFieldExpression() { + // field expression + Object expectedResult = Arrays.asList( + Long.valueOf(2), Long.valueOf(3), Long.valueOf(4), Long.valueOf(5), Long.valueOf(6)); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.result(false, cand.personid.add(1)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "personid + 1", + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); + } + + /** */ + public void testNavigationalExpressionThis() { + // navigational expression this + Object expectedResult = Arrays.asList( + Long.valueOf(1), Long.valueOf(2),Long.valueOf(3), Long.valueOf(4), Long.valueOf(5)); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(false, cand.personid); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "this.personid", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); + } + + /** */ + public void testNavigationalExpressionVariable() { + // navigational expression variable + Object expectedResult = + Arrays.asList(new Object[]{"Development", "Human Resources"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + QEmployee e = QEmployee.variable("e"); + Expression eExpr = query.variable("e", Employee.class); + query.result(true, e.department.name); + query.filter(cand.team.contains(eExpr).and(cand.personid.eq(2l))); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "distinct e.department.name", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "team.contains(e) && personid == 2", + /*VARIABLES*/ "Employee e", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); + } + + /** */ + public void testNavigationalExpressionParameter() { + // navigational expression parameter + Object expectedResult = Arrays.asList(Long.valueOf(1)); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + QProject p = QProject.parameter("p"); + query.parameter("p", Project.class); + query.result(false, p.projid); + query.filter(cand.personid.eq(1l).and(p.projid.eq(cand.personid))); + + Map paramValues = new HashMap<>(); + paramValues.put("p", getPersistentCompanyModelInstance("proj1")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "p.projid", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "personid == 1 && p.projid == this.personid", + /*VARIABLES*/ null, + /*PARAMETERS*/ "Project p", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); + } + + /** */ + public void testNavigationalExpressionField() { + // navigational expression field + Object expectedResult = Arrays.asList(new Object[]{Long.valueOf(1)}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(false, cand.department.deptid); + query.filter(cand.personid.eq(1l)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "department.deptid", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "personid == 1", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); + } + + /** */ + public void testParameter() { + // parameter + Object expectedResult = getTransientCompanyModelInstancesAsList(new String[]{"proj1"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + QProject p = QProject.parameter("p"); + query.parameter("p", Project.class); + query.result(false, p); + query.filter(cand.personid.eq(1l).and(cand.personid.eq(p.projid))); + + Map paramValues = new HashMap<>(); + paramValues.put("p", getPersistentCompanyModelInstance("proj1")); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "p", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "personid == 1 && personid == p.projid", + /*VARIABLES*/ null, + /*PARAMETERS*/ "Project p", + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ paramValues); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); + } + + /** */ + public void testCast() { + // cast + Object expectedResult = getTransientCompanyModelInstancesAsList(new String[]{"emp2"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + query.result(false, cand.manager.cast(FullTimeEmployee.class)); + query.filter(cand.personid.eq(1l)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "(FullTimeEmployee)manager", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "personid == 1", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expectedResult); + } + + /** */ + public void testNegative() { + for (int i = 0; i < INVALID_QUERIES.length; i++) { + compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], + false); + } + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/ShapeOfResult.java b/tck/src/main/java/org/apache/jdo/tck/query/result/ShapeOfResult.java index edccb51ce..dee38e3f1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/ShapeOfResult.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/ShapeOfResult.java @@ -5,20 +5,21 @@ * 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 + * + * 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.jdo.tck.query.result; import java.util.Arrays; -import javax.jdo.JDOQLTypedQuery; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.pc.company.QPerson; @@ -27,373 +28,363 @@ import org.apache.jdo.tck.query.result.classes.FullName; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Shape of Result.
    - * Keywords: query
    - * Assertion ID: A14.6.12-2.
    - * Assertion Description: Table 6: Shape of Result (C is the candidate class) + *Title: Shape of Result. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.12-2. + *
    + *Assertion Description: + * Table 6: Shape of Result (C is the candidate class) */ public class ShapeOfResult extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.12-2 (ShapeOfResult) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ShapeOfResult.class); - } - - /** */ - public void testNoResult() { - // result: null - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testThisAsC() { - // result: this AS C - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.result(false, cand); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "this AS Person", - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testNoResultUnique() { - // result: null, unique: true - Object expected = getTransientCompanyModelInstance("emp1"); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.personid.eq(1l)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "personid == 1", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testThisAsCUnique() { - // result: this AS C, unique: true - Object expected = getTransientCompanyModelInstance("emp1"); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.personid.eq(1l)); - query.result(false, cand); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "this AS Person", - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "personid == 1", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testSingleExpression() { - // result: expression of type T - Object expected = - Arrays.asList("emp1First", "emp2First", "emp3First", "emp4First", "emp5First"); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.result(false, cand.firstname); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "firstname", - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testSingleExpressionUnique() { - // result: expression of type T, unique: true - Object expected = "emp1First"; - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.personid.eq(1l)); - query.result(false, cand.firstname); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "firstname", - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "personid == 1", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testMultipleExpressions() { - // result: multiple expressions of type T - Object expected = - Arrays.asList( - new Object[] {"emp1First", "emp1Last"}, - new Object[] {"emp2First", "emp2Last"}, - new Object[] {"emp3First", "emp3Last"}, - new Object[] {"emp4First", "emp4Last"}, - new Object[] {"emp5First", "emp5Last"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.result(false, cand.firstname, cand.lastname); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "firstname, lastname", - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testMultipleExpressionsUnique() { - // result: multiple expressions of type T, unique: true - Object expected = new Object[] {"emp1First", "emp1Last"}; - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.personid.eq(1l)); - query.result(false, cand.firstname, cand.lastname); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "firstname, lastname", - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "personid == 1", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testMultipleExpressionsResultClass() { - // result: multiple expressions of type T, result class - Object expected = - Arrays.asList( - new FullName("emp1First", "emp1Last"), - new FullName("emp2First", "emp2Last"), - new FullName("emp3First", "emp3Last"), - new FullName("emp4First", "emp4Last"), - new FullName("emp5First", "emp5Last")); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - // JDOQLTypedQuery API - query.result(false, cand.firstname, cand.lastname); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "firstname, lastname", - /*INTO*/ FullName.class, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, FullName.class, true, expected); - } - - /** */ - public void testMultipleExpressionResultClassUnique() { - // result: multiple expressions of type T, result class, unique: true - Object expected = new FullName("emp1First", "emp1Last"); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.personid.eq(1l)); - // JDOQLTypedQuery API - query.result(false, cand.firstname, cand.lastname); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ "firstname, lastname", - /*INTO*/ FullName.class, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "personid == 1", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, FullName.class, true, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.12-2 (ShapeOfResult) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ShapeOfResult.class); + } + + /** */ + public void testNoResult() { + // result: null + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp2", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testThisAsC() { + // result: this AS C + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp2", "emp3", "emp4", "emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.result(false, cand); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "this AS Person", + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testNoResultUnique() { + // result: null, unique: true + Object expected = getTransientCompanyModelInstance("emp1"); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.personid.eq(1l)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "personid == 1", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testThisAsCUnique() { + // result: this AS C, unique: true + Object expected = getTransientCompanyModelInstance("emp1"); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.personid.eq(1l)); + query.result(false, cand); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "this AS Person", + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "personid == 1", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testSingleExpression() { + // result: expression of type T + Object expected = Arrays.asList("emp1First", "emp2First", "emp3First", "emp4First", "emp5First"); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.result(false, cand.firstname); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "firstname", + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testSingleExpressionUnique() { + // result: expression of type T, unique: true + Object expected = "emp1First"; + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.personid.eq(1l)); + query.result(false, cand.firstname); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "firstname", + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "personid == 1", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testMultipleExpressions() { + // result: multiple expressions of type T + Object expected = Arrays.asList( + new Object[]{"emp1First", "emp1Last"}, + new Object[]{"emp2First", "emp2Last"}, + new Object[]{"emp3First", "emp3Last"}, + new Object[]{"emp4First", "emp4Last"}, + new Object[]{"emp5First", "emp5Last"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.result(false, cand.firstname, cand.lastname); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "firstname, lastname", + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testMultipleExpressionsUnique() { + // result: multiple expressions of type T, unique: true + Object expected = new Object[]{"emp1First", "emp1Last"}; + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.personid.eq(1l)); + query.result(false, cand.firstname, cand.lastname); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "firstname, lastname", + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "personid == 1", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testMultipleExpressionsResultClass() { + // result: multiple expressions of type T, result class + Object expected = Arrays.asList( + new FullName("emp1First", "emp1Last"), + new FullName("emp2First", "emp2Last"), + new FullName("emp3First", "emp3Last"), + new FullName("emp4First", "emp4Last"), + new FullName("emp5First", "emp5Last")); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + // JDOQLTypedQuery API + query.result(false, cand.firstname, cand.lastname); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "firstname, lastname", + /*INTO*/ FullName.class, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, FullName.class, true, expected); + } + + /** */ + public void testMultipleExpressionResultClassUnique() { + // result: multiple expressions of type T, result class, unique: true + Object expected = new FullName("emp1First", "emp1Last"); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.personid.eq(1l)); + // JDOQLTypedQuery API + query.result(false, cand.firstname, cand.lastname); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ "firstname, lastname", + /*INTO*/ FullName.class, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "personid == 1", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, FullName.class, true, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/Unique.java b/tck/src/main/java/org/apache/jdo/tck/query/result/Unique.java index 1e90ddcc7..8b14bf886 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/Unique.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/Unique.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,6 +19,8 @@ import javax.jdo.JDOQLTypedQuery; import javax.jdo.Query; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.pc.company.QPerson; @@ -27,138 +29,145 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Unique.
    - * Keywords: query
    - * Assertion ID: A14.6.11-1.
    - * Assertion Description: When the value of the Unique flag is true, then the result of a - * query is a single value, with null used to indicate that none of the instances in the candidates - * satisfied the filter. If more than one instance satisfies the filter, and the range is not - * limited to one result, then execute throws a JDOUserException. + *Title: Unique. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.11-1. + *
    + *Assertion Description: + * When the value of the Unique flag is true, + * then the result of a query is a single value, + * with null used to indicate that none of the instances + * in the candidates satisfied the filter. + * If more than one instance satisfies the filter, + * and the range is not limited to one result, + * then execute throws a JDOUserException. */ public class Unique extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.11-1 (Unique) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Unique.class); - } - - /** */ - public void testPositive0() { - Object expected = getTransientCompanyModelInstance("emp1"); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.personid.eq(1l)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "personid == 1", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testPositive1() { - Object expected = null; - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.filter(cand.personid.eq(0l)); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ "personid == 0", - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - /** */ - public void testPositive2() { - Object expected = getTransientCompanyModelInstance("emp1"); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); - QPerson cand = QPerson.candidate(); - query.orderBy(cand.personid.asc()); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ Boolean.TRUE, - /*RESULT*/ null, - /*INTO*/ null, - /*FROM*/ Person.class, - /*EXCLUDE*/ null, - /*WHERE*/ null, - /*VARIABLES*/ null, - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ "personid ASCENDING", - /*FROM*/ "0", - /*TO*/ "1", - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); - } - - public void testNegative() { - String singleString = "SELECT UNIQUE FROM " + Person.class.getName(); - - Query query = getPM().newQuery(Person.class); - query.setUnique(true); - executeJDOQuery(ASSERTION_FAILED, query, singleString, false, null, null, false); - - query = getPM().newQuery(singleString); - executeJDOQuery(ASSERTION_FAILED, query, singleString, false, null, null, false); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.11-1 (Unique) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Unique.class); + } + + /** */ + public void testPositive0() { + Object expected = getTransientCompanyModelInstance("emp1"); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.personid.eq(1l)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "personid == 1", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testPositive1() { + Object expected = null; + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.filter(cand.personid.eq(0l)); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "personid == 0", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + /** */ + public void testPositive2() { + Object expected = getTransientCompanyModelInstance("emp1"); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Person.class); + QPerson cand = QPerson.candidate(); + query.orderBy(cand.personid.asc()); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ "personid ASCENDING", + /*FROM*/ "0", + /*TO*/ "1", + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected); + } + + public void testNegative() { + String singleString = "SELECT UNIQUE FROM " + Person.class.getName(); + + Query query = getPM().newQuery(Person.class); + query.setUnique(true); + executeJDOQuery(ASSERTION_FAILED, query, singleString, + false, null, null, false); + + query = getPM().newQuery(singleString); + executeJDOQuery(ASSERTION_FAILED, query, singleString, + false, null, null, false); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/VariableInResult.java b/tck/src/main/java/org/apache/jdo/tck/query/result/VariableInResult.java index 2e8eab986..cf58006e2 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/VariableInResult.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/VariableInResult.java @@ -5,20 +5,21 @@ * 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 + * + * 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.jdo.tck.query.result; import java.util.Arrays; -import javax.jdo.JDOQLTypedQuery; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.Employee; @@ -29,215 +30,216 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Variable in Result.
    - * Keywords: query
    - * Assertion ID: A14.6.9-3.
    - * Assertion Description: If a variable or a field of a variable is included in the result, - * either directly or via navigation through the variable, then the semantics of the contains clause - * that include the variable change. In this case, all values of the variable that satisfy the - * filter are included in the result. Result expressions begin with either an instance of the - * candidate class (with an explicit or implicit "this") or an instance of a variable (using the - * variable name). The candidate tuples are the cartesian product of the candidate class and all - * variables used in the result. The result tuples are the tuples of the candidate class and all - * variables used in the result that satisfy the filter. The result is the collection of result - * expressions projected from the result tuples. + *Title: Variable in Result. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.9-3. + *
    + *Assertion Description: + * If a variable or a field of a variable is included in the result, + * either directly or via navigation through the variable, + * then the semantics of the contains clause that include the variable change. + * In this case, all values of the variable + * that satisfy the filter are included in the result. + * Result expressions begin with either an instance of the candidate class + * (with an explicit or implicit "this") or an instance of a variable + * (using the variable name). The candidate tuples are the cartesian product + * of the candidate class and all variables used in the result. The result + * tuples are the tuples of the candidate class and all variables used + * in the result that satisfy the filter. + * The result is the collection of result expressions projected from the + * result tuples. */ public class VariableInResult extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.9-3 (VariableInResult) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(VariableInResult.class); - } - - /** */ - public void testDistinctNoNavigation() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - QEmployee e = QEmployee.variable("e"); - query.filter(cand.employees.contains(e)); - query.result(true, e); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "distinct e", - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employees.contains(e)", - /*VARIABLES*/ "Employee e", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testDistinctNavigation() { - Object elem = new Object[] {Long.valueOf(1), "orange"}; - Object expected = Arrays.asList(elem); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - QProject p = QProject.variable("p"); - query.filter(cand.projects.contains(p).and(p.name.eq("orange"))); - query.result(true, p.projid, p.name); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "distinct p.projid, p.name", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "projects.contains(p) & p.name == 'orange'", - /*VARIABLES*/ "Project p", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testNavigation() { - Object expected = - Arrays.asList( - new Object[] {Long.valueOf(1), "orange"}, - new Object[] {Long.valueOf(1), "orange"}, - new Object[] {Long.valueOf(1), "orange"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); - QEmployee cand = QEmployee.candidate(); - QProject p = QProject.variable("p"); - query.filter(cand.projects.contains(p).and(p.name.eq("orange"))); - query.result(false, p.projid, p.name); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "p.projid, p.name", - /*INTO*/ null, - /*FROM*/ Employee.class, - /*EXCLUDE*/ null, - /*WHERE*/ "projects.contains(p) & p.name == 'orange'", - /*VARIABLES*/ "Project p", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testNoNavigation() { - Object expected = - getTransientCompanyModelInstancesAsList( - new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - QEmployee e = QEmployee.variable("e"); - query.filter(cand.employees.contains(e)); - query.result(false, e); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "e", - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employees.contains(e)", - /*VARIABLES*/ "Employee e", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testMultipleProjectionWithConstraints() { - Object expected = getTransientCompanyModelInstancesAsList(new String[] {"emp4", "emp5"}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - QEmployee e = QEmployee.variable("e"); - query.filter(cand.deptid.eq(2l).and(cand.employees.contains(e))); - query.result(false, e); - - // SELECT e FROM Department WHERE deptid==2 & employees.contains(e) VARIABLES Employee e - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "e", - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "deptid == 2 & employees.contains(e)", - /*VARIABLES*/ "Employee e", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.9-3 (VariableInResult) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(VariableInResult.class); + } + + /** */ + public void testDistinctNoNavigation() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1","emp2","emp3","emp4","emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + QEmployee e = QEmployee.variable("e"); + query.filter(cand.employees.contains(e)); + query.result(true, e); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "distinct e", + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.contains(e)", + /*VARIABLES*/ "Employee e", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testDistinctNavigation() { + Object elem = new Object[]{Long.valueOf(1), "orange"}; + Object expected = Arrays.asList(elem); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + QProject p = QProject.variable("p"); + query.filter(cand.projects.contains(p).and(p.name.eq("orange"))); + query.result(true, p.projid, p.name); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "distinct p.projid, p.name", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "projects.contains(p) & p.name == 'orange'", + /*VARIABLES*/ "Project p", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testNavigation() { + Object expected = Arrays.asList( + new Object[]{Long.valueOf(1), "orange"}, + new Object[]{Long.valueOf(1), "orange"}, + new Object[]{Long.valueOf(1), "orange"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Employee.class); + QEmployee cand = QEmployee.candidate(); + QProject p = QProject.variable("p"); + query.filter(cand.projects.contains(p).and(p.name.eq("orange"))); + query.result(false, p.projid, p.name); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "p.projid, p.name", + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "projects.contains(p) & p.name == 'orange'", + /*VARIABLES*/ "Project p", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testNoNavigation() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1","emp2","emp3","emp4","emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + QEmployee e = QEmployee.variable("e"); + query.filter(cand.employees.contains(e)); + query.result(false, e); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "e", + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.contains(e)", + /*VARIABLES*/ "Employee e", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testMultipleProjectionWithConstraints() { + Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp4","emp5"}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + QEmployee e = QEmployee.variable("e"); + query.filter(cand.deptid.eq(2l).and(cand.employees.contains(e))); + query.result(false, e); + + // SELECT e FROM Department WHERE deptid==2 & employees.contains(e) VARIABLES Employee e + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "e", + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "deptid == 2 & employees.contains(e)", + /*VARIABLES*/ "Employee e", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/VariableInResultMultipleNavigation.java b/tck/src/main/java/org/apache/jdo/tck/query/result/VariableInResultMultipleNavigation.java index 1dfa93294..6cdd4785a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/VariableInResultMultipleNavigation.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/VariableInResultMultipleNavigation.java @@ -5,22 +5,23 @@ * 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 + * + * 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.jdo.tck.query.result; import java.util.Arrays; -import javax.jdo.JDOQLTypedQuery; -import org.apache.jdo.tck.pc.company.Company; + import org.apache.jdo.tck.pc.company.CompanyModelReader; +import org.apache.jdo.tck.pc.company.Company; +import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.QCompany; import org.apache.jdo.tck.pc.company.QDepartment; import org.apache.jdo.tck.pc.company.QEmployee; @@ -29,205 +30,200 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Variable in Result.
    - * Keywords: query
    - * Assertion ID: A14.6.9-3.
    - * Assertion Description: If a variable or a field of a variable is included in the result, - * either directly or via navigation through the variable, then the semantics of the contains clause - * that include the variable change. In this case, all values of the variable that satisfy the - * filter are included in the result. Result expressions begin with either an instance of the - * candidate class (with an explicit or implicit "this") or an instance of a variable (using the - * variable name). The candidate tuples are the cartesian product of the candidate class and all - * variables used in the result. The result tuples are the tuples of the candidate class and all - * variables used in the result that satisfy the filter. The result is the collection of result - * expressions projected from the result tuples. - * - *

    This test differs from VariableInResult by extending the navigation of variables. It navigates - * from the candidate Department class to include fields in the corresponding Company. It navigates - * from the candidate Company class to Department, Employee, and Project. + *Title: Variable in Result. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.9-3. + *
    + *Assertion Description: + * If a variable or a field of a variable is included in the result, + * either directly or via navigation through the variable, + * then the semantics of the contains clause that include the variable change. + * In this case, all values of the variable + * that satisfy the filter are included in the result. + * Result expressions begin with either an instance of the candidate class + * (with an explicit or implicit "this") or an instance of a variable + * (using the variable name). The candidate tuples are the cartesian product + * of the candidate class and all variables used in the result. The result + * tuples are the tuples of the candidate class and all variables used + * in the result that satisfy the filter. + * The result is the collection of result expressions projected from the + * result tuples. + * + * This test differs from VariableInResult by extending the navigation + * of variables. It navigates from the candidate Department class to include + * fields in the corresponding Company. It navigates from the candidate + * Company class to Department, Employee, and Project. */ public class VariableInResultMultipleNavigation extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.9-3 (VariableInResult) failed: "; - - /** The expected results of valid queries. */ - private Object company1 = getTransientCompanyModelInstance("company1"); - - private Object emp1 = getTransientCompanyModelInstance("emp1"); - private Object emp2 = getTransientCompanyModelInstance("emp2"); - private Object emp3 = getTransientCompanyModelInstance("emp3"); - private Object emp4 = getTransientCompanyModelInstance("emp4"); - private Object emp5 = getTransientCompanyModelInstance("emp5"); - private Object proj1 = getTransientCompanyModelInstance("proj1"); - private Object proj2 = getTransientCompanyModelInstance("proj2"); - private Object proj3 = getTransientCompanyModelInstance("proj3"); - private Object dept1 = getTransientCompanyModelInstance("dept1"); - private Object dept2 = getTransientCompanyModelInstance("dept2"); - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(VariableInResult.class); - } - - /** */ - public void testNavigationWithCompanyAndDepartmentAndEmployeeAndProject() { - Object expected = - Arrays.asList( - new Object[] {company1, dept1, emp1, proj1}, - new Object[] {company1, dept1, emp2, proj1}, - new Object[] {company1, dept1, emp3, proj1}, - new Object[] {company1, dept1, emp2, proj2}, - new Object[] {company1, dept1, emp3, proj2}, - new Object[] {company1, dept2, emp4, proj3}, - new Object[] {company1, dept2, emp5, proj3}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Company.class); - QCompany cand = QCompany.candidate(); - QDepartment d = QDepartment.variable("d"); - QEmployee e = QEmployee.variable("e"); - QProject p = QProject.variable("p"); - query.filter( - cand.name - .eq("Sun Microsystems, Inc.") - .and(cand.departments.contains(d)) - .and(d.employees.contains(e)) - .and(e.projects.contains(p))); - query.result(false, cand, d, e, p); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "this, d, e, p", - /*INTO*/ null, - /*FROM*/ Company.class, - /*EXCLUDE*/ null, - /*WHERE*/ "name == \"Sun Microsystems, Inc.\" && " - + "departments.contains(d) && d.employees.contains(e) && e.projects.contains(p)", - /*VARIABLES*/ "Department d; Employee e; Project p", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testNavigationWithCompanyAndEmployeeAndProject() { - Object expected = - Arrays.asList( - new Object[] {company1, emp1, proj1}, - new Object[] {company1, emp2, proj1}, - new Object[] {company1, emp3, proj1}, - new Object[] {company1, emp2, proj2}, - new Object[] {company1, emp3, proj2}, - new Object[] {company1, emp4, proj3}, - new Object[] {company1, emp5, proj3}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Company.class); - QCompany cand = QCompany.candidate(); - QDepartment d = QDepartment.variable("d"); - QEmployee e = QEmployee.variable("e"); - QProject p = QProject.variable("p"); - query.filter( - cand.name - .eq("Sun Microsystems, Inc.") - .and(cand.departments.contains(d)) - .and(d.employees.contains(e)) - .and(e.projects.contains(p))); - query.result(false, cand, e, p); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "this, e, p", - /*INTO*/ null, - /*FROM*/ Company.class, - /*EXCLUDE*/ null, - /*WHERE*/ "name == \"Sun Microsystems, Inc.\" && " - + "departments.contains(d) && d.employees.contains(e) && e.projects.contains(p)", - /*VARIABLES*/ "Department d; Employee e; Project p", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** */ - public void testNavigationWithDepartmentAndEmployeeAndProject() { - Object expected = - Arrays.asList( - new Object[] {dept1, emp1, proj1}, - new Object[] {dept1, emp2, proj1}, - new Object[] {dept1, emp3, proj1}, - new Object[] {dept1, emp2, proj2}, - new Object[] {dept1, emp3, proj2}, - new Object[] {dept2, emp4, proj3}, - new Object[] {dept2, emp5, proj3}); - - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Company.class); - QCompany cand = QCompany.candidate(); - QDepartment d = QDepartment.variable("d"); - QEmployee e = QEmployee.variable("e"); - QProject p = QProject.variable("p"); - query.filter( - cand.name - .eq("Sun Microsystems, Inc.") - .and(cand.departments.contains(d)) - .and(d.employees.contains(e)) - .and(e.projects.contains(p))); - query.result(false, d, e, p); - - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "d, e, p", - /*INTO*/ null, - /*FROM*/ Company.class, - /*EXCLUDE*/ null, - /*WHERE*/ "name == \"Sun Microsystems, Inc.\" && " - + "departments.contains(d) && d.employees.contains(e) && e.projects.contains(p)", - /*VARIABLES*/ "Department d; Employee e; Project p", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); - - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.9-3 (VariableInResult) failed: "; + + /** + * The expected results of valid queries. + */ + private Object company1 = getTransientCompanyModelInstance("company1"); + private Object emp1 = getTransientCompanyModelInstance("emp1"); + private Object emp2 = getTransientCompanyModelInstance("emp2"); + private Object emp3 = getTransientCompanyModelInstance("emp3"); + private Object emp4 = getTransientCompanyModelInstance("emp4"); + private Object emp5 = getTransientCompanyModelInstance("emp5"); + private Object proj1 = getTransientCompanyModelInstance("proj1"); + private Object proj2 = getTransientCompanyModelInstance("proj2"); + private Object proj3 = getTransientCompanyModelInstance("proj3"); + private Object dept1 = getTransientCompanyModelInstance("dept1"); + private Object dept2 = getTransientCompanyModelInstance("dept2"); + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(VariableInResult.class); + } + + /** */ + public void testNavigationWithCompanyAndDepartmentAndEmployeeAndProject() { + Object expected = Arrays.asList( + new Object[] {company1, dept1, emp1, proj1}, + new Object[] {company1, dept1, emp2, proj1}, + new Object[] {company1, dept1, emp3, proj1}, + new Object[] {company1, dept1, emp2, proj2}, + new Object[] {company1, dept1, emp3, proj2}, + new Object[] {company1, dept2, emp4, proj3}, + new Object[] {company1, dept2, emp5, proj3}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Company.class); + QCompany cand = QCompany.candidate(); + QDepartment d = QDepartment.variable("d"); + QEmployee e = QEmployee.variable("e"); + QProject p = QProject.variable("p"); + query.filter(cand.name.eq("Sun Microsystems, Inc.").and( + cand.departments.contains(d)).and(d.employees.contains(e)).and(e.projects.contains(p))); + query.result(false, cand, d, e, p); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "this, d, e, p", + /*INTO*/ null, + /*FROM*/ Company.class, + /*EXCLUDE*/ null, + /*WHERE*/ "name == \"Sun Microsystems, Inc.\" && " + + "departments.contains(d) && d.employees.contains(e) && e.projects.contains(p)", + /*VARIABLES*/ "Department d; Employee e; Project p", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testNavigationWithCompanyAndEmployeeAndProject() { + Object expected = Arrays.asList( + new Object[] {company1, emp1, proj1}, + new Object[] {company1, emp2, proj1}, + new Object[] {company1, emp3, proj1}, + new Object[] {company1, emp2, proj2}, + new Object[] {company1, emp3, proj2}, + new Object[] {company1, emp4, proj3}, + new Object[] {company1, emp5, proj3}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Company.class); + QCompany cand = QCompany.candidate(); + QDepartment d = QDepartment.variable("d"); + QEmployee e = QEmployee.variable("e"); + QProject p = QProject.variable("p"); + query.filter(cand.name.eq("Sun Microsystems, Inc.").and( + cand.departments.contains(d)).and(d.employees.contains(e)).and(e.projects.contains(p))); + query.result(false, cand, e, p); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "this, e, p", + /*INTO*/ null, + /*FROM*/ Company.class, + /*EXCLUDE*/ null, + /*WHERE*/ "name == \"Sun Microsystems, Inc.\" && " + + "departments.contains(d) && d.employees.contains(e) && e.projects.contains(p)", + /*VARIABLES*/ "Department d; Employee e; Project p", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** */ + public void testNavigationWithDepartmentAndEmployeeAndProject() { + Object expected = Arrays.asList( + new Object[] {dept1, emp1, proj1}, + new Object[] {dept1, emp2, proj1}, + new Object[] {dept1, emp3, proj1}, + new Object[] {dept1, emp2, proj2}, + new Object[] {dept1, emp3, proj2}, + new Object[] {dept2, emp4, proj3}, + new Object[] {dept2, emp5, proj3}); + + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Company.class); + QCompany cand = QCompany.candidate(); + QDepartment d = QDepartment.variable("d"); + QEmployee e = QEmployee.variable("e"); + QProject p = QProject.variable("p"); + query.filter(cand.name.eq("Sun Microsystems, Inc.").and( + cand.departments.contains(d)).and(d.employees.contains(e)).and(e.projects.contains(p))); + query.result(false, d, e, p); + + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "d, e, p", + /*INTO*/ null, + /*FROM*/ Company.class, + /*EXCLUDE*/ null, + /*WHERE*/ "name == \"Sun Microsystems, Inc.\" && " + + "departments.contains(d) && d.employees.contains(e) && e.projects.contains(p)", + /*VARIABLES*/ "Department d; Employee e; Project p", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); + + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/VariableInResultNavigation.java b/tck/src/main/java/org/apache/jdo/tck/query/result/VariableInResultNavigation.java index b98955ce8..3fda155ca 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/VariableInResultNavigation.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/VariableInResultNavigation.java @@ -5,21 +5,22 @@ * 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 + * + * 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.jdo.tck.query.result; import java.util.Arrays; -import javax.jdo.JDOQLTypedQuery; + import org.apache.jdo.tck.pc.company.CompanyModelReader; +import org.apache.jdo.tck.pc.company.Company; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.QDepartment; import org.apache.jdo.tck.pc.company.QEmployee; @@ -28,264 +29,264 @@ import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; +import javax.jdo.JDOQLTypedQuery; + /** - * Title: Variable in Result.
    - * Keywords: query
    - * Assertion ID: A14.6.9-3.
    - * Assertion Description: If a variable or a field of a variable is included in the result, - * either directly or via navigation through the variable, then the semantics of the contains clause - * that include the variable change. In this case, all values of the variable that satisfy the - * filter are included in the result. Result expressions begin with either an instance of the - * candidate class (with an explicit or implicit "this") or an instance of a variable (using the - * variable name). The candidate tuples are the cartesian product of the candidate class and all - * variables used in the result. The result tuples are the tuples of the candidate class and all - * variables used in the result that satisfy the filter. The result is the collection of result - * expressions projected from the result tuples. - * - *

    This test differs from VariableInResult by extending the navigation of variables. It navigates - * from the candidate Department class to include fields in the corresponding Company. It navigates - * from the candidate Company class to Department, Employee, and Project. + *Title: Variable in Result. + *
    + *Keywords: query + *
    + *Assertion ID: A14.6.9-3. + *
    + *Assertion Description: + * If a variable or a field of a variable is included in the result, + * either directly or via navigation through the variable, + * then the semantics of the contains clause that include the variable change. + * In this case, all values of the variable + * that satisfy the filter are included in the result. + * Result expressions begin with either an instance of the candidate class + * (with an explicit or implicit "this") or an instance of a variable + * (using the variable name). The candidate tuples are the cartesian product + * of the candidate class and all variables used in the result. The result + * tuples are the tuples of the candidate class and all variables used + * in the result that satisfy the filter. + * The result is the collection of result expressions projected from the + * result tuples. + * + * This test differs from VariableInResult by extending the navigation + * of variables. It navigates from the candidate Department class to include + * fields in the corresponding Company. It navigates from the candidate + * Company class to Department, Employee, and Project. */ public class VariableInResultNavigation extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.6.9-3 (VariableInResult) failed: "; - - /** The expected results of valid queries. */ - private Object emp1 = getTransientCompanyModelInstance("emp1"); - - private Object emp2 = getTransientCompanyModelInstance("emp2"); - private Object emp3 = getTransientCompanyModelInstance("emp3"); - private Object emp4 = getTransientCompanyModelInstance("emp4"); - private Object emp5 = getTransientCompanyModelInstance("emp5"); - private Object proj1 = getTransientCompanyModelInstance("proj1"); - private Object proj2 = getTransientCompanyModelInstance("proj2"); - private Object proj3 = getTransientCompanyModelInstance("proj3"); - private Object dept1 = getTransientCompanyModelInstance("dept1"); - private Object dept2 = getTransientCompanyModelInstance("dept2"); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.9-3 (VariableInResult) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(VariableInResult.class); - } + /** + * The expected results of valid queries. + */ + private Object emp1 = getTransientCompanyModelInstance("emp1"); + private Object emp2 = getTransientCompanyModelInstance("emp2"); + private Object emp3 = getTransientCompanyModelInstance("emp3"); + private Object emp4 = getTransientCompanyModelInstance("emp4"); + private Object emp5 = getTransientCompanyModelInstance("emp5"); + private Object proj1 = getTransientCompanyModelInstance("proj1"); + private Object proj2 = getTransientCompanyModelInstance("proj2"); + private Object proj3 = getTransientCompanyModelInstance("proj3"); + private Object dept1 = getTransientCompanyModelInstance("dept1"); + private Object dept2 = getTransientCompanyModelInstance("dept2"); - /** */ - public void testNavigationWithConstraint() { - Object expected = - Arrays.asList( - new Object[] {emp1, proj1}, new Object[] {emp2, proj1}, new Object[] {emp3, proj1}); + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(VariableInResult.class); + } + + /** */ + public void testNavigationWithConstraint() { + Object expected = Arrays.asList( + new Object[] {emp1, proj1}, + new Object[] {emp2, proj1}, + new Object[] {emp3, proj1}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - QEmployee e = QEmployee.variable("e"); - QProject p = QProject.variable("p"); - query.filter(cand.employees.contains(e).and(e.projects.contains(p)).and(p.name.eq("orange"))); - query.result(false, e, p); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + QEmployee e = QEmployee.variable("e"); + QProject p = QProject.variable("p"); + query.filter(cand.employees.contains(e).and(e.projects.contains(p)).and(p.name.eq("orange"))); + query.result(false, e, p); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "e, p", - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employees.contains(e) && e.projects.contains(p) && p.name == 'orange'", - /*VARIABLES*/ "Employee e; Project p", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "e, p", + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.contains(e) && e.projects.contains(p) && p.name == 'orange'", + /*VARIABLES*/ "Employee e; Project p", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } - /** */ - public void testNavigationWithoutConstraint() { - Object expected = - Arrays.asList( - new Object[] {emp1, proj1}, - new Object[] {emp2, proj1}, - new Object[] {emp3, proj1}, - new Object[] {emp2, proj2}, - new Object[] {emp3, proj2}, - new Object[] {emp4, proj3}, - new Object[] {emp5, proj3}); + /** */ + public void testNavigationWithoutConstraint() { + Object expected = Arrays.asList( + new Object[] {emp1, proj1}, + new Object[] {emp2, proj1}, + new Object[] {emp3, proj1}, + new Object[] {emp2, proj2}, + new Object[] {emp3, proj2}, + new Object[] {emp4, proj3}, + new Object[] {emp5, proj3}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - QEmployee e = QEmployee.variable("e"); - QProject p = QProject.variable("p"); - query.filter(cand.employees.contains(e).and(e.projects.contains(p))); - query.result(false, e, p); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + QEmployee e = QEmployee.variable("e"); + QProject p = QProject.variable("p"); + query.filter(cand.employees.contains(e).and(e.projects.contains(p))); + query.result(false, e, p); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "e, p", - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employees.contains(e) && e.projects.contains(p)", - /*VARIABLES*/ "Employee e; Project p", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "e, p", + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.contains(e) && e.projects.contains(p)", + /*VARIABLES*/ "Employee e; Project p", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } - /** */ - public void testNavigationWithThis() { - Object expected = - Arrays.asList( - new Object[] {dept1, emp1, proj1}, - new Object[] {dept1, emp2, proj1}, - new Object[] {dept1, emp3, proj1}, - new Object[] {dept1, emp2, proj2}, - new Object[] {dept1, emp3, proj2}, - new Object[] {dept2, emp4, proj3}, - new Object[] {dept2, emp5, proj3}); + /** */ + public void testNavigationWithThis() { + Object expected = Arrays.asList( + new Object[] {dept1, emp1, proj1}, + new Object[] {dept1, emp2, proj1}, + new Object[] {dept1, emp3, proj1}, + new Object[] {dept1, emp2, proj2}, + new Object[] {dept1, emp3, proj2}, + new Object[] {dept2, emp4, proj3}, + new Object[] {dept2, emp5, proj3}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - QEmployee e = QEmployee.variable("e"); - QProject p = QProject.variable("p"); - query.filter(cand.employees.contains(e).and(e.projects.contains(p))); - query.result(false, cand, e, p); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + QEmployee e = QEmployee.variable("e"); + QProject p = QProject.variable("p"); + query.filter(cand.employees.contains(e).and(e.projects.contains(p))); + query.result(false, cand, e, p); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "this, e, p", - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "employees.contains(e) && e.projects.contains(p)", - /*VARIABLES*/ "Employee e; Project p", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "this, e, p", + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "employees.contains(e) && e.projects.contains(p)", + /*VARIABLES*/ "Employee e; Project p", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } - /** */ - public void testNavigationWithThisConstraint() { - Object expected = - Arrays.asList( - new Object[] {emp1, proj1}, - new Object[] {emp2, proj1}, - new Object[] {emp3, proj1}, - new Object[] {emp2, proj2}, - new Object[] {emp3, proj2}); + /** */ + public void testNavigationWithThisConstraint() { + Object expected = Arrays.asList( + new Object[] {emp1, proj1}, + new Object[] {emp2, proj1}, + new Object[] {emp3, proj1}, + new Object[] {emp2, proj2}, + new Object[] {emp3, proj2}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - QEmployee e = QEmployee.variable("e"); - QProject p = QProject.variable("p"); - query.filter(cand.deptid.eq(1l).and(cand.employees.contains(e)).and(e.projects.contains(p))); - query.result(false, e, p); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + QEmployee e = QEmployee.variable("e"); + QProject p = QProject.variable("p"); + query.filter(cand.deptid.eq(1l).and(cand.employees.contains(e)).and(e.projects.contains(p))); + query.result(false, e, p); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "e, p", - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "deptid == 1 && employees.contains(e) && e.projects.contains(p)", - /*VARIABLES*/ "Employee e; Project p", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "e, p", + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "deptid == 1 && employees.contains(e) && e.projects.contains(p)", + /*VARIABLES*/ "Employee e; Project p", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } - /** */ - public void testNavigationWithCompanyConstraint() { - Object expected = - Arrays.asList( - new Object[] {emp1, proj1}, - new Object[] {emp2, proj1}, - new Object[] {emp3, proj1}, - new Object[] {emp2, proj2}, - new Object[] {emp3, proj2}, - new Object[] {emp4, proj3}, - new Object[] {emp5, proj3}); + /** */ + public void testNavigationWithCompanyConstraint() { + Object expected = Arrays.asList( + new Object[] {emp1, proj1}, + new Object[] {emp2, proj1}, + new Object[] {emp3, proj1}, + new Object[] {emp2, proj2}, + new Object[] {emp3, proj2}, + new Object[] {emp4, proj3}, + new Object[] {emp5, proj3}); - JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); - QDepartment cand = QDepartment.candidate(); - QEmployee e = QEmployee.variable("e"); - QProject p = QProject.variable("p"); - query.filter( - cand.company - .name - .eq("Sun Microsystems, Inc.") - .and(cand.employees.contains(e)) - .and(e.projects.contains(p))); - query.result(false, e, p); + JDOQLTypedQuery query = getPM().newJDOQLTypedQuery(Department.class); + QDepartment cand = QDepartment.candidate(); + QEmployee e = QEmployee.variable("e"); + QProject p = QProject.variable("p"); + query.filter(cand.company.name.eq("Sun Microsystems, Inc.").and(cand.employees.contains(e)).and(e.projects.contains(p))); + query.result(false, e, p); - QueryElementHolder holder = - new QueryElementHolder( - /*UNIQUE*/ null, - /*RESULT*/ "e, p", - /*INTO*/ null, - /*FROM*/ Department.class, - /*EXCLUDE*/ null, - /*WHERE*/ "company.name == \"Sun Microsystems, Inc.\" && employees.contains(e) && e.projects.contains(p)", - /*VARIABLES*/ "Employee e; Project p", - /*PARAMETERS*/ null, - /*IMPORTS*/ null, - /*GROUP BY*/ null, - /*ORDER BY*/ null, - /*FROM*/ null, - /*TO*/ null, - /*JDOQLTyped*/ query, - /*paramValues*/ null); + QueryElementHolder holder = new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ "e, p", + /*INTO*/ null, + /*FROM*/ Department.class, + /*EXCLUDE*/ null, + /*WHERE*/ "company.name == \"Sun Microsystems, Inc.\" && employees.contains(e) && e.projects.contains(p)", + /*VARIABLES*/ "Employee e; Project p", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null, + /*JDOQLTyped*/ query, + /*paramValues*/ null); - executeAPIQuery(ASSERTION_FAILED, holder, expected); - executeSingleStringQuery(ASSERTION_FAILED, holder, expected); - executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); - } + executeAPIQuery(ASSERTION_FAILED, holder, expected); + executeSingleStringQuery(ASSERTION_FAILED, holder, expected); + executeJDOQLTypedQuery(ASSERTION_FAILED, holder, null, true, expected); + } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/classes/FullName.java b/tck/src/main/java/org/apache/jdo/tck/query/result/classes/FullName.java index 8dc4b9bca..70da60e33 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/classes/FullName.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/classes/FullName.java @@ -5,119 +5,123 @@ * 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 + * + * 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.jdo.tck.query.result.classes; import org.apache.jdo.tck.util.EqualityHelper; /** - * JDOQL result class having bean properties firstname, firstName, - * lastname, and lastName. These properties are used by JDO query tests in - * result clauses. There are two different bean properties on each field, firstname and - * lastname because some result clauses in JDO query tests specify those properties in - * AS clauses. + * JDOQL result class having bean properties firstname, + * firstName, lastname, and lastName. + * These properties are used by JDO query tests in result clauses. + * There are two different bean properties on each field, + * firstname and lastname + * because some result clauses in JDO query tests specify + * those properties in AS clauses. */ public class FullName { - private String firstName; - private String lastName; - - public FullName() {} - - public FullName(String firstName, String lastName) { - this.firstName = firstName; - this.lastName = lastName; - } - - /** - * @see Object#hashCode() - */ - public int hashCode() { - int result = 0; - result += this.firstName != null ? this.firstName.hashCode() : 0; - result += this.lastName != null ? this.lastName.hashCode() : 0; - return result; - } - - /** - * @see Object#equals(java.lang.Object) - */ - public boolean equals(Object o) { - if (!(o instanceof FullName)) return false; - FullName other = (FullName) o; - return EqualityHelper.equals(this.firstName, other.firstName) - && EqualityHelper.equals(this.lastName, other.lastName); - } - - /** - * @see Object#toString() - */ - public String toString() { - return this.firstName + ' ' + this.lastName; - } - - /** - * @return Returns the firstName. - */ - public String getFirstName() { - return firstName; - } - - /** - * @param firstName The firstName to set. - */ - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - /** - * @return Returns the lastName. - */ - public String getLastName() { - return lastName; - } - - /** - * @param lastName The lastName to set. - */ - public void setLastName(String lastName) { - this.lastName = lastName; - } - - /** - * @return Returns the firstName. - */ - public String getFirstname() { - return firstName; - } - - /** - * @param firstname The firstName to set. - */ - public void setFirstname(String firstname) { - this.firstName = firstname; - } - - /** - * @return Returns the lastName. - */ - public String getLastname() { - return lastName; - } + private String firstName; + private String lastName; + + public FullName() {} + + public FullName(String firstName, String lastName) { + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * @see Object#hashCode() + */ + public int hashCode() { + int result = 0; + result += this.firstName != null ? this.firstName.hashCode() : 0; + result += this.lastName != null ? this.lastName.hashCode() : 0; + return result; + } + + /** + * @see Object#equals(java.lang.Object) + */ + public boolean equals(Object o) { + if (!(o instanceof FullName)) + return false; + FullName other = (FullName) o; + return EqualityHelper.equals(this.firstName, other.firstName) && + EqualityHelper.equals(this.lastName, other.lastName); + } + + /** + * @see Object#toString() + */ + public String toString() { + return this.firstName + ' ' + this.lastName; + } + + /** + * @return Returns the firstName. + */ + public String getFirstName() { + return firstName; + } + + /** + * @param firstName The firstName to set. + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * @return Returns the lastName. + */ + public String getLastName() { + return lastName; + } + + /** + * @param lastName The lastName to set. + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * @return Returns the firstName. + */ + public String getFirstname() { + return firstName; + } + + /** + * @param firstname The firstName to set. + */ + public void setFirstname(String firstname) { + this.firstName = firstname; + } + + /** + * @return Returns the lastName. + */ + public String getLastname() { + return lastName; + } + + /** + * @param lastname The lastName to set. + */ + public void setLastname(String lastname) { + this.lastName = lastname; + } - /** - * @param lastname The lastName to set. - */ - public void setLastname(String lastname) { - this.lastName = lastname; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/classes/LongString.java b/tck/src/main/java/org/apache/jdo/tck/query/result/classes/LongString.java index 3708d4ecf..c6f43873a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/classes/LongString.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/classes/LongString.java @@ -5,87 +5,91 @@ * 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 + * + * 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.jdo.tck.query.result.classes; import org.apache.jdo.tck.util.EqualityHelper; /** - * JDOQL result class having bean properties s and l. These properties are - * used by JDO query tests in result clauses. + * JDOQL result class having bean properties s and l. + * These properties are used by JDO query tests in result clauses. */ public class LongString { - private long l; - private String s; - - public LongString() {} - - public LongString(long l, String s) { - this.l = l; - this.s = s; - } - - /** - * @see Object#hashCode() - */ - public int hashCode() { - int result = 0; - result += this.s != null ? this.s.hashCode() : 0; - result += (int) (this.l % Integer.MAX_VALUE); - return result; - } - - /** - * @see Object#equals(java.lang.Object) - */ - public boolean equals(Object o) { - if (!(o instanceof LongString)) return false; - LongString other = (LongString) o; - return this.l == other.l && EqualityHelper.equals(this.s, other.s); - } - - /** - * @see Object#toString() - */ - public String toString() { - return getClass().getName() + '(' + this.l + ", " + this.s + ')'; - } + private long l; + private String s; + + public LongString() {} + + public LongString(long l, String s) { + this.l = l; + this.s = s; + } + + /** + * @see Object#hashCode() + */ + public int hashCode() { + int result = 0; + result += this.s != null ? this.s.hashCode() : 0; + result += (int) (this.l % Integer.MAX_VALUE); + return result; + } + + /** + * @see Object#equals(java.lang.Object) + */ + public boolean equals(Object o) { + if (!(o instanceof LongString)) + return false; + LongString other = (LongString) o; + return this.l == other.l && + EqualityHelper.equals(this.s, other.s); + } + + /** + * @see Object#toString() + */ + public String toString() { + return getClass().getName() + '(' + + this.l + ", " + this.s + ')'; + } - /** - * @return Returns the l. - */ - public long getL() { - return l; - } + /** + * @return Returns the l. + */ + public long getL() { + return l; + } - /** - * @param l The l to set. - */ - public void setL(long l) { - this.l = l; - } + /** + * @param l The l to set. + */ + public void setL(long l) { + this.l = l; + } - /** - * @return Returns the s. - */ - public String getS() { - return s; - } + /** + * @return Returns the s. + */ + public String getS() { + return s; + } - /** - * @param s The s to set. - */ - public void setS(String s) { - this.s = s; - } + /** + * @param s The s to set. + */ + public void setS(String s) { + this.s = s; + } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/classes/MissingNoArgsConstructor.java b/tck/src/main/java/org/apache/jdo/tck/query/result/classes/MissingNoArgsConstructor.java index 780569865..35ed3c816 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/classes/MissingNoArgsConstructor.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/classes/MissingNoArgsConstructor.java @@ -5,63 +5,67 @@ * 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 + * + * 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.jdo.tck.query.result.classes; -/** JDOQL result class not having a no-args constructor. */ -public class MissingNoArgsConstructor { - - private long l; - - public MissingNoArgsConstructor(int l) { - this.l = l; - } - /** - * @see Object#hashCode() - */ - public int hashCode() { - int result = 0; - result += (int) (this.l % Integer.MAX_VALUE); - return result; - } - - /** - * @see Object#equals(java.lang.Object) - */ - public boolean equals(Object o) { - if (!(o instanceof MissingNoArgsConstructor)) return false; - MissingNoArgsConstructor other = (MissingNoArgsConstructor) o; - return this.l == other.l; - } +/** + * JDOQL result class not having a no-args constructor. + */ +public class MissingNoArgsConstructor { - /** - * @see Object#toString() - */ - public String toString() { - return getClass().getName() + '(' + l + ')'; - } + private long l; + + public MissingNoArgsConstructor(int l) { + this.l = l; + } + + /** + * @see Object#hashCode() + */ + public int hashCode() { + int result = 0; + result += (int) (this.l % Integer.MAX_VALUE); + return result; + } + + /** + * @see Object#equals(java.lang.Object) + */ + public boolean equals(Object o) { + if (!(o instanceof MissingNoArgsConstructor)) + return false; + MissingNoArgsConstructor other = (MissingNoArgsConstructor) o; + return this.l == other.l; + } + + /** + * @see Object#toString() + */ + public String toString() { + return getClass().getName() + '(' + l + ')'; + } - /** - * @return Returns the l. - */ - public long getL() { - return l; - } + /** + * @return Returns the l. + */ + public long getL() { + return l; + } - /** - * @param l The l to set. - */ - public void setL(int l) { - this.l = l; - } + /** + * @param l The l to set. + */ + public void setL(int l) { + this.l = l; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/classes/NoFieldsNoMethods.java b/tck/src/main/java/org/apache/jdo/tck/query/result/classes/NoFieldsNoMethods.java index b0a082238..4770474f8 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/classes/NoFieldsNoMethods.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/classes/NoFieldsNoMethods.java @@ -5,17 +5,21 @@ * 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 + * + * 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.jdo.tck.query.result.classes; -/** JDOQL result class not having any fields and methods. */ -public class NoFieldsNoMethods {} + +/** + * JDOQL result class not having any fields and methods. + */ +public class NoFieldsNoMethods { +} diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/classes/PublicLongField.java b/tck/src/main/java/org/apache/jdo/tck/query/result/classes/PublicLongField.java index 4c4065f88..2dda13023 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/classes/PublicLongField.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/classes/PublicLongField.java @@ -5,48 +5,52 @@ * 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 + * + * 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.jdo.tck.query.result.classes; -/** JDOQL result class having a public lonf field. */ +/** + * JDOQL result class having a public lonf field. + */ public class PublicLongField { - public long l; - - public PublicLongField() {} + public long l; - public PublicLongField(long l) { - this.l = l; - } - /** - * @see Object#hashCode() - */ - public int hashCode() { - return (int) (this.l % Integer.MAX_VALUE); - } + public PublicLongField() {} - /** - * @see Object#equals(java.lang.Object) - */ - public boolean equals(Object o) { - if (!(o instanceof PublicLongField)) return false; - PublicLongField other = (PublicLongField) o; - return this.l == other.l; - } + public PublicLongField(long l) { + this.l = l; + } + /** + * @see Object#hashCode() + */ + public int hashCode() { + return (int) (this.l % Integer.MAX_VALUE); + } + + /** + * @see Object#equals(java.lang.Object) + */ + public boolean equals(Object o) { + if (!(o instanceof PublicLongField)) + return false; + PublicLongField other = (PublicLongField) o; + return this.l == other.l; + } + + /** + * @see Object#toString() + */ + public String toString() { + return getClass().getName() + '(' + this.l + ')'; + } - /** - * @see Object#toString() - */ - public String toString() { - return getClass().getName() + '(' + this.l + ')'; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/result/classes/PublicPutMethod.java b/tck/src/main/java/org/apache/jdo/tck/query/result/classes/PublicPutMethod.java index 3b145ffd0..b46eda6cf 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/result/classes/PublicPutMethod.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/result/classes/PublicPutMethod.java @@ -5,56 +5,60 @@ * 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 + * + * 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.jdo.tck.query.result.classes; import java.util.HashMap; import java.util.Map; -/** JDOQL result class having a public lonf field. */ +/** + * JDOQL result class having a public lonf field. + */ public class PublicPutMethod { - private Map map = new HashMap(); - - public PublicPutMethod() {} - - public PublicPutMethod(Map map) { - this.map = map; - } - - public void put(Object key, Object value) { - this.map.put(key, value); - } - - /** - * @see Object#hashCode() - */ - public int hashCode() { - return this.map.hashCode(); - } - - /** - * @see Object#equals(java.lang.Object) - */ - public boolean equals(Object o) { - if (!(o instanceof PublicPutMethod)) return false; - PublicPutMethod other = (PublicPutMethod) o; - return this.map.equals(other.map); - } + private Map map = new HashMap(); + + public PublicPutMethod() {} + + public PublicPutMethod(Map map) { + this.map = map; + } + + public void put(Object key, Object value) { + this.map.put(key, value); + } + + /** + * @see Object#hashCode() + */ + public int hashCode() { + return this.map.hashCode(); + } + + /** + * @see Object#equals(java.lang.Object) + */ + public boolean equals(Object o) { + if (!(o instanceof PublicPutMethod)) + return false; + PublicPutMethod other = (PublicPutMethod) o; + return this.map.equals(other.map); + } + + /** + * @see Object#toString() + */ + public String toString() { + return getClass().getName() + '(' + this.map + ')'; + } - /** - * @see Object#toString() - */ - public String toString() { - return getClass().getName() + '(' + this.map + ')'; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/sql/AllowedAPIMethods.java b/tck/src/main/java/org/apache/jdo/tck/query/sql/AllowedAPIMethods.java index 75a5f38e7..c340de825 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/sql/AllowedAPIMethods.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/sql/AllowedAPIMethods.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,8 +19,11 @@ import java.text.MessageFormat; import java.util.Arrays; + import javax.jdo.JDOUserException; import javax.jdo.Query; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.Person; @@ -31,220 +34,195 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Allowed API Methods.
    - * Keywords: query
    - * Assertion ID: A14.7-2.
    - * Assertion Description: The only methods that can be used are setClass to establish the - * candidate class, setUnique to declare that there is only one result row, and setResultClass to - * establish the result class. + *Title: Allowed API Methods. + *
    + *Keywords: query + *
    + *Assertion ID: A14.7-2. + *
    + *Assertion Description: + * The only methods that can be used are setClass + * to establish the candidate class, + * setUnique to declare that there is only one result row, + * and setResultClass to establish the result class. */ public class AllowedAPIMethods extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.7-2 (AllowedAPIMethods) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(AllowedAPIMethods.class); - } - - /** The array of valid SQL queries. */ - private static final String[] VALID_SQL_QUERIES = { - "SELECT * FROM {0}.PrimitiveTypes", - "SELECT * FROM {0}.departments", - "SELECT * FROM {0}.persons", - "SELECT FIRSTNAME, LASTNAME FROM {0}.persons WHERE PERSONID = 1", - "SELECT FIRSTNAME, LASTNAME FROM {0}.persons" - }; - - /** The expected results of valid SQL queries. */ - private Object[] expectedResult = { - getTransientMylibInstancesAsList( - new String[] { - "primitiveTypesPositive", - "primitiveTypesNegative", - "primitiveTypesCharacterStringLiterals" - }), - getTransientCompanyModelInstancesAsList(new String[] {"dept1", "dept2"}), - getTransientCompanyModelInstancesAsList(new String[] {"emp1", "emp2", "emp3", "emp4", "emp5"}), - new Object[] {"emp1First", "emp1Last"}, - Arrays.asList( - new Object[] { - new FullName("emp1First", "emp1Last"), - new FullName("emp2First", "emp2Last"), - new FullName("emp3First", "emp3Last"), - new FullName("emp4First", "emp4Last"), - new FullName("emp5First", "emp5Last") - }) - }; - - /** */ - public void testSetClass() { - if (isSQLSupported()) { - int index = 0; - executeSQLQuery( - ASSERTION_FAILED, - VALID_SQL_QUERIES[index], - PrimitiveTypes.class, - null, - true, - null, - expectedResult[index], - false); - - index = 1; - executeSQLQuery( - ASSERTION_FAILED, - VALID_SQL_QUERIES[index], - Department.class, - null, - true, - null, - expectedResult[index], - false); - - index = 2; - executeSQLQuery( - ASSERTION_FAILED, - VALID_SQL_QUERIES[index], - Person.class, - null, - true, - null, - expectedResult[index], - false); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.7-2 (AllowedAPIMethods) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(AllowedAPIMethods.class); } - } - - /** */ - public void testSetUnique() { - if (isSQLSupported()) { - int index = 3; - executeSQLQuery( - ASSERTION_FAILED, - VALID_SQL_QUERIES[index], - null, - null, - true, - null, - expectedResult[index], - true); + + /** The array of valid SQL queries. */ + private static final String[] VALID_SQL_QUERIES = { + "SELECT * FROM {0}.PrimitiveTypes", + "SELECT * FROM {0}.departments", + "SELECT * FROM {0}.persons", + "SELECT FIRSTNAME, LASTNAME FROM {0}.persons WHERE PERSONID = 1", + "SELECT FIRSTNAME, LASTNAME FROM {0}.persons" + }; + + /** + * The expected results of valid SQL queries. + */ + private Object[] expectedResult = { + getTransientMylibInstancesAsList(new String[]{ + "primitiveTypesPositive", + "primitiveTypesNegative", + "primitiveTypesCharacterStringLiterals"}), + getTransientCompanyModelInstancesAsList(new String[]{"dept1", "dept2"}), + getTransientCompanyModelInstancesAsList(new String[]{ + "emp1", "emp2", "emp3", "emp4", "emp5"}), + new Object[]{"emp1First", "emp1Last"}, + Arrays.asList(new Object[]{ + new FullName("emp1First", "emp1Last"), + new FullName("emp2First", "emp2Last"), + new FullName("emp3First", "emp3Last"), + new FullName("emp4First", "emp4Last"), + new FullName("emp5First", "emp5Last")}) + }; + + /** */ + public void testSetClass() { + if (isSQLSupported()) { + int index = 0; + executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index], + PrimitiveTypes.class, null, true, null, + expectedResult[index], false); + + index = 1; + executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index], + Department.class, null, true, null, + expectedResult[index], false); + + index = 2; + executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index], + Person.class, null, true, null, + expectedResult[index], false); + } } - } - /** */ - public void testSetResultClass() { - if (isSQLSupported()) { - int index = 4; - executeSQLQuery( - ASSERTION_FAILED, - VALID_SQL_QUERIES[index], - null, - FullName.class, - true, - null, - expectedResult[index], - false); + /** */ + public void testSetUnique() { + if (isSQLSupported()) { + int index = 3; + executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index], + null, null, true, null, expectedResult[index], true); + } } - } - /** */ - public void testNegative() { - if (isSQLSupported()) { - String schema = getPMFProperty("javax.jdo.mapping.Schema"); - // Note that the SQL query below is valid. - // The query is not executed. - // Instead, the method uses a query instance - // to check prohibited setters. - String sql = "SELECT PERSONID FROM {0}.persons"; - sql = MessageFormat.format(sql, new Object[] {schema}); - Query query = getPM().newQuery("javax.jdo.query.SQL", sql); - checkProhibitedSetters(query); + /** */ + public void testSetResultClass() { + if (isSQLSupported()) { + int index = 4; + executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index], + null, FullName.class, true, null, expectedResult[index], + false); + } } - } - private void checkProhibitedSetters(Query query) { - checkSetResult(query); - checkSetFilter(query); - checkDeclareVariables(query); - checkDeclareParameters(query); - checkDeclareImports(query); - checkSetGrouping(query); - checkSetOrdering(query); - } - - private void checkSetResult(Query query) { - try { - query.setResult("firstname, lastname"); - methodFailed("setResult()"); - } catch (JDOUserException e) { + /** */ + public void testNegative() { + if (isSQLSupported()) { + String schema = getPMFProperty("javax.jdo.mapping.Schema"); + // Note that the SQL query below is valid. + // The query is not executed. + // Instead, the method uses a query instance + // to check prohibited setters. + String sql = "SELECT PERSONID FROM {0}.persons"; + sql = MessageFormat.format(sql, new Object[]{schema}); + Query query = getPM().newQuery("javax.jdo.query.SQL", sql); + checkProhibitedSetters(query); + } } - } - - private void checkSetFilter(Query query) { - try { - query.setFilter("WHERE personid = 1"); - methodFailed("setFilter()"); - } catch (JDOUserException e) { + + private void checkProhibitedSetters(Query query) { + checkSetResult(query); + checkSetFilter(query); + checkDeclareVariables(query); + checkDeclareParameters(query); + checkDeclareImports(query); + checkSetGrouping(query); + checkSetOrdering(query); } - } - - private void checkDeclareVariables(Query query) { - try { - query.declareVariables("Employee emp"); - methodFailed("declareVariables()"); - } catch (JDOUserException e) { + + private void checkSetResult(Query query) { + try { + query.setResult("firstname, lastname"); + methodFailed("setResult()"); + } catch (JDOUserException e) { + } } - } - - private void checkDeclareParameters(Query query) { - try { - query.declareParameters("Employee emp"); - methodFailed("declareParameters()"); - } catch (JDOUserException e) { + + private void checkSetFilter(Query query) { + try { + query.setFilter("WHERE personid = 1"); + methodFailed("setFilter()"); + } catch (JDOUserException e) { + } } - } - - private void checkDeclareImports(Query query) { - try { - query.declareImports("import org.apache.jdo.tck.pc.company.Employee"); - methodFailed("declareImports()"); - } catch (JDOUserException e) { + + private void checkDeclareVariables(Query query) { + try { + query.declareVariables("Employee emp"); + methodFailed("declareVariables()"); + } catch (JDOUserException e) { + } } - } - - private void checkSetGrouping(Query query) { - try { - query.setGrouping("firstname"); - methodFailed("setGrouping()"); - } catch (JDOUserException e) { + + private void checkDeclareParameters(Query query) { + try { + query.declareParameters("Employee emp"); + methodFailed("declareParameters()"); + } catch (JDOUserException e) { + } } - } - - private void checkSetOrdering(Query query) { - try { - query.setOrdering("firstname ASCENDING"); - methodFailed("setOrdering()"); - } catch (JDOUserException e) { + + private void checkDeclareImports(Query query) { + try { + query.declareImports("import org.apache.jdo.tck.pc.company.Employee"); + methodFailed("declareImports()"); + } catch (JDOUserException e) { + } + } + + private void checkSetGrouping(Query query) { + try { + query.setGrouping("firstname"); + methodFailed("setGrouping()"); + } catch (JDOUserException e) { + } + } + + private void checkSetOrdering(Query query) { + try { + query.setOrdering("firstname ASCENDING"); + methodFailed("setOrdering()"); + } catch (JDOUserException e) { + } + } + + private void methodFailed(String method) { + fail(ASSERTION_FAILED + method + + " on a SQL query must throw JDOUserException." ); } - } - - private void methodFailed(String method) { - fail(ASSERTION_FAILED + method + " on a SQL query must throw JDOUserException."); - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - addTearDownClass(MylibReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - loadAndPersistMylib(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + addTearDownClass(MylibReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + loadAndPersistMylib(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/sql/ExecuteWithMap.java b/tck/src/main/java/org/apache/jdo/tck/query/sql/ExecuteWithMap.java index 5dab71920..c3656da67 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/sql/ExecuteWithMap.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/sql/ExecuteWithMap.java @@ -5,19 +5,20 @@ * 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 + * + * 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.jdo.tck.query.sql; import java.util.HashMap; + import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.company.Person; import org.apache.jdo.tck.pc.mylib.MylibReader; @@ -26,176 +27,152 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: ExecuteWithMap
    - * Keywords: query
    - * Assertion ID: A14.7-5.
    - * Assertion Description: If the parameter list is a Map, then the keys of the Map must be - * instances of Integer whose intValue is 1..n. The value in the Map corresponding to the key whose - * intValue is 1 is bound to the first ? in the SQL statement, and so forth. + *Title: ExecuteWithMap + *
    + *Keywords: query + *
    + *Assertion ID: A14.7-5. + *
    + *Assertion Description: + * If the parameter list is a Map, then the keys of the Map + * must be instances of Integer whose intValue is 1..n. + * The value in the Map corresponding to the key whose intValue is 1 + * is bound to the first ? in the SQL statement, and so forth. */ public class ExecuteWithMap extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.7-5 (ExecuteWithMap)"; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ExecuteWithMap.class); - } - - /** The array of valid SQL queries. */ - private static final String[] VALID_SQL_QUERIES = { - "SELECT * FROM {0}.PrimitiveTypes WHERE intNotNull = ? " + "OR stringNull = ?", - "SELECT * FROM {0}.persons WHERE FIRSTNAME = ? AND LASTNAME = ?" - + " AND MIDDLENAME = ? AND CITY = ?", - "SELECT * FROM {0}.persons WHERE FIRSTNAME = ? AND LASTNAME = ?" - + " AND MIDDLENAME = ? AND CITY = ?", - "SELECT * FROM {0}.persons WHERE FIRSTNAME = ? AND LASTNAME = ?" - + " AND MIDDLENAME = ? AND CITY = ?" - }; - - /** The expected results of valid SQL queries. */ - private Object[] expectedResult = { - getTransientMylibInstancesAsList( - new String[] {"primitiveTypesPositive", "primitiveTypesCharacterStringLiterals"}), - getTransientCompanyModelInstancesAsList(new String[] {"emp2"}), - getTransientCompanyModelInstancesAsList(new String[] {"emp2"}), - getTransientCompanyModelInstancesAsList(new String[] {"emp2"}) - }; - - /** Maps of parameter values */ - private static HashMap hm1 = new HashMap(); - - private static HashMap hm2 = new HashMap(); - private static HashMap hm3 = new HashMap(); - private static HashMap hm4 = new HashMap(); - private static HashMap illegalMapMissingKeyTwo = new HashMap(); - private static HashMap illegalMapStartsWithZero = new HashMap(); - private static HashMap illegalMapStringKeys = new HashMap(); - - static { - // valid parameter values - hm1.put(Integer.valueOf(1), Integer.valueOf(4)); - hm1.put(Integer.valueOf(2), "Even"); - - hm2.put(Integer.valueOf(1), "emp2First"); - hm2.put(Integer.valueOf(2), "emp2Last"); - hm2.put(Integer.valueOf(3), "emp2Middle"); - hm2.put(Integer.valueOf(4), "New York"); - - hm3 = (HashMap) hm2.clone(); - // extra entry okay, should be ignored by impl - hm3.put(Integer.valueOf(0), "emp2First"); - - hm4 = (HashMap) hm2.clone(); - // extra entry okay, should be ignored by impl - hm4.put(Integer.valueOf(5), "New York"); - - // invalid parameter values - illegalMapMissingKeyTwo.put(Integer.valueOf(1), "emp2First"); - illegalMapMissingKeyTwo.put(Integer.valueOf(3), "emp2Last"); - illegalMapMissingKeyTwo.put(Integer.valueOf(4), "emp2Middle"); - illegalMapMissingKeyTwo.put(Integer.valueOf(5), "New York"); - - illegalMapStartsWithZero.put(Integer.valueOf(0), "emp2First"); - illegalMapStartsWithZero.put(Integer.valueOf(1), "emp2Last"); - illegalMapStartsWithZero.put(Integer.valueOf(2), "emp2Middle"); - illegalMapStartsWithZero.put(Integer.valueOf(3), "New York"); - - illegalMapStringKeys.put(new String("1dog"), "emp2First"); - illegalMapStringKeys.put(new String("2dog"), "emp2Last"); - illegalMapStringKeys.put(new String("3dog"), "emp2Middle"); - illegalMapStringKeys.put(new String("4dog"), "New York"); - } - ; - - private static HashMap[] parameterMap = new HashMap[] {hm1, hm2, hm3, hm4}; - - /** */ - public void testSetClass() { - if (isSQLSupported()) { - int index = 0; - executeSQLQuery( - ASSERTION_FAILED, - VALID_SQL_QUERIES[index], - PrimitiveTypes.class, - null, - true, - parameterMap[index], - expectedResult[index], - false); - - index = 1; - executeSQLQuery( - ASSERTION_FAILED, - VALID_SQL_QUERIES[index], - Person.class, - null, - true, - parameterMap[index], - expectedResult[index], - false); - - index = 2; - executeSQLQuery( - ASSERTION_FAILED, - VALID_SQL_QUERIES[index], - Person.class, - null, - true, - parameterMap[index], - expectedResult[index], - false); - - index = 3; - executeSQLQuery( - ASSERTION_FAILED, - VALID_SQL_QUERIES[index], - Person.class, - null, - true, - parameterMap[index], - expectedResult[index], - false); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.7-5 (ExecuteWithMap)"; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ExecuteWithMap.class); + } + + /** The array of valid SQL queries. */ + private static final String[] VALID_SQL_QUERIES = { + "SELECT * FROM {0}.PrimitiveTypes WHERE intNotNull = ? " + + "OR stringNull = ?", + "SELECT * FROM {0}.persons WHERE FIRSTNAME = ? AND LASTNAME = ?" + + " AND MIDDLENAME = ? AND CITY = ?", + "SELECT * FROM {0}.persons WHERE FIRSTNAME = ? AND LASTNAME = ?" + + " AND MIDDLENAME = ? AND CITY = ?", + "SELECT * FROM {0}.persons WHERE FIRSTNAME = ? AND LASTNAME = ?" + + " AND MIDDLENAME = ? AND CITY = ?" + }; + + /** + * The expected results of valid SQL queries. + */ + private Object[] expectedResult = { + getTransientMylibInstancesAsList(new String[]{ + "primitiveTypesPositive", + "primitiveTypesCharacterStringLiterals"}), + getTransientCompanyModelInstancesAsList(new String[]{"emp2"}), + getTransientCompanyModelInstancesAsList(new String[]{"emp2"}), + getTransientCompanyModelInstancesAsList(new String[]{"emp2"}) + }; + + /** + * Maps of parameter values + */ + private static HashMap hm1 = new HashMap(); + private static HashMap hm2 = new HashMap(); + private static HashMap hm3 = new HashMap(); + private static HashMap hm4 = new HashMap(); + private static HashMap illegalMapMissingKeyTwo = new HashMap(); + private static HashMap illegalMapStartsWithZero = new HashMap(); + private static HashMap illegalMapStringKeys = new HashMap(); + static { + // valid parameter values + hm1.put(Integer.valueOf(1), Integer.valueOf(4)); + hm1.put(Integer.valueOf(2), "Even"); + + hm2.put(Integer.valueOf(1), "emp2First"); + hm2.put(Integer.valueOf(2), "emp2Last"); + hm2.put(Integer.valueOf(3), "emp2Middle"); + hm2.put(Integer.valueOf(4), "New York"); + + hm3 = (HashMap) hm2.clone(); + // extra entry okay, should be ignored by impl + hm3.put(Integer.valueOf(0), "emp2First"); + + hm4 = (HashMap) hm2.clone(); + // extra entry okay, should be ignored by impl + hm4.put(Integer.valueOf(5), "New York"); + + // invalid parameter values + illegalMapMissingKeyTwo.put(Integer.valueOf(1), "emp2First"); + illegalMapMissingKeyTwo.put(Integer.valueOf(3), "emp2Last"); + illegalMapMissingKeyTwo.put(Integer.valueOf(4), "emp2Middle"); + illegalMapMissingKeyTwo.put(Integer.valueOf(5), "New York"); + + illegalMapStartsWithZero.put(Integer.valueOf(0), "emp2First"); + illegalMapStartsWithZero.put(Integer.valueOf(1), "emp2Last"); + illegalMapStartsWithZero.put(Integer.valueOf(2), "emp2Middle"); + illegalMapStartsWithZero.put(Integer.valueOf(3), "New York"); + + illegalMapStringKeys.put(new String("1dog"), "emp2First"); + illegalMapStringKeys.put(new String("2dog"), "emp2Last"); + illegalMapStringKeys.put(new String("3dog"), "emp2Middle"); + illegalMapStringKeys.put(new String("4dog"), "New York"); + }; + private static HashMap[] parameterMap = new HashMap[]{hm1, hm2, hm3, hm4}; + + /** */ + public void testSetClass() { + if (isSQLSupported()) { + int index = 0; + executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index], + PrimitiveTypes.class, null, true, + parameterMap[index], expectedResult[index], false); + + index = 1; + executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index], + Person.class, null, true, + parameterMap[index], expectedResult[index], false); + + index = 2; + executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index], + Person.class, null, true, + parameterMap[index], expectedResult[index], false); + + index = 3; + executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index], + Person.class, null, true, + parameterMap[index], expectedResult[index], false); + } } - } - - /** */ - public void testNegative() { - if (isSQLSupported()) { - String query = - "SELECT * FROM {0}.persons WHERE FIRSTNAME = ? " - + "AND LASTNAME = ? AND MIDDLENAME = ? AND CITY = ? " - + "AND FUNDINGDEPT = ?"; - String singleStringQuery = query; - executeSQLQuery( - ASSERTION_FAILED, query, Person.class, null, false, illegalMapMissingKeyTwo, null, false); - executeSQLQuery( - ASSERTION_FAILED, - query, - Person.class, - null, - false, - illegalMapStartsWithZero, - null, - false); - executeSQLQuery( - ASSERTION_FAILED, query, Person.class, null, false, illegalMapStringKeys, null, false); + + /** */ + public void testNegative() { + if (isSQLSupported()) { + String query = "SELECT * FROM {0}.persons WHERE FIRSTNAME = ? " + + "AND LASTNAME = ? AND MIDDLENAME = ? AND CITY = ? " + + "AND FUNDINGDEPT = ?"; + String singleStringQuery = query; + executeSQLQuery(ASSERTION_FAILED, query, Person.class, null, + false, illegalMapMissingKeyTwo, null, false); + executeSQLQuery(ASSERTION_FAILED, query, Person.class, null, + false, illegalMapStartsWithZero, null, false); + executeSQLQuery(ASSERTION_FAILED, query, Person.class, null, + false, illegalMapStringKeys, null, false); + } + } + + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + addTearDownClass(MylibReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + loadAndPersistMylib(getPM()); } - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - addTearDownClass(MylibReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - loadAndPersistMylib(getPM()); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/sql/NewQuery.java b/tck/src/main/java/org/apache/jdo/tck/query/sql/NewQuery.java index d9ed72c27..bbb3091a4 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/sql/NewQuery.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/sql/NewQuery.java @@ -5,81 +5,88 @@ * 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 + * + * 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.jdo.tck.query.sql; import java.util.Arrays; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: New SQL Query.
    - * Keywords: query
    - * Assertion ID: A14.7-1.
    - * Assertion Description: In this case, the factory method that takes the language string - * and Object is used: newQuery (String language, Object query). The language parameter is - * javax.jdo.query.SQL and the query parameter is the SQL query string. + *Title: New SQL Query. + *
    + *Keywords: query + *
    + *Assertion ID: A14.7-1. + *
    + *Assertion Description: + * In this case, the factory method that takes the language string and + * Object is used: newQuery (String language, Object query). + * The language parameter is javax.jdo.query.SQL and + * the query parameter is the SQL query string. */ public class NewQuery extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.7-1 (NewQuery) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NewQuery.class); - } - - /** The array of valid SQL queries. */ - private static final String[] VALID_SQL_QUERIES = { - "SELECT firstname, lastname FROM {0}.persons WHERE personid = ?" - }; - - /** The expected results of valid SQL queries. */ - private Object[] expectedResult = { - Arrays.asList(new Object[] {new Object[] {"emp1First", "emp1Last"}}) - }; - - /** Parameters of valid SQL queries. */ - private static Object[][] parameters = {{Integer.valueOf(1)}}; - - /** */ - public void testPositive() { - if (isSQLSupported()) { - for (int i = 0; i < VALID_SQL_QUERIES.length; i++) { - executeSQLQuery( - ASSERTION_FAILED, - VALID_SQL_QUERIES[i], - null, - null, - true, - parameters[i], - expectedResult[i], - false); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.7-1 (NewQuery) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NewQuery.class); + } + + /** The array of valid SQL queries. */ + private static final String[] VALID_SQL_QUERIES = { + "SELECT firstname, lastname FROM {0}.persons WHERE personid = ?" + }; + + /** + * The expected results of valid SQL queries. + */ + private Object[] expectedResult = { + Arrays.asList(new Object[]{ + new Object[]{"emp1First", "emp1Last"}}) + }; + + /** Parameters of valid SQL queries. */ + private static Object[][] parameters = { + {Integer.valueOf(1)} + }; + + /** */ + public void testPositive() { + if (isSQLSupported()) { + for (int i = 0; i < VALID_SQL_QUERIES.length; i++) { + executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[i], + null, null, true, parameters[i], expectedResult[i], + false); + } + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/sql/NoCandidateClass.java b/tck/src/main/java/org/apache/jdo/tck/query/sql/NoCandidateClass.java index 1787117e1..1f0bbb328 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/sql/NoCandidateClass.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/sql/NoCandidateClass.java @@ -5,93 +5,97 @@ * 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 + * + * 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.jdo.tck.query.sql; import java.util.Arrays; + import javax.jdo.Query; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.query.QueryTest; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: No Candidate Class.
    - * Keywords: query
    - * Assertion ID: A14.7-3.
    - * Assertion Description: SQL queries can be defined without a candidate class. These - * queries can be found by name using the factory method newNamedQuery, specifying the class as - * null, or can be constructed without a candidate class. + *Title: No Candidate Class. + *
    + *Keywords: query + *
    + *Assertion ID: A14.7-3. + *
    + *Assertion Description: + * SQL queries can be defined without a candidate class. + * These queries can be found by name using the factory method newNamedQuery, + * specifying the class as null, + * or can be constructed without a candidate class. */ public class NoCandidateClass extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.7-3 (CandidateClass) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(NoCandidateClass.class); - } - - /** The array of valid SQL queries. */ - private static final String[] VALID_SQL_QUERIES = {"SELECT firstname, lastname FROM {0}.persons"}; - - /** The expected results of valid SQL queries. */ - private Object[] expectedResult = { - Arrays.asList( - new Object[] { - new Object[] {"emp1First", "emp1Last"}, - new Object[] {"emp2First", "emp2Last"}, - new Object[] {"emp3First", "emp3Last"}, - new Object[] {"emp4First", "emp4Last"}, - new Object[] {"emp5First", "emp5Last"} - }) - }; - - /** */ - public void testNamedQuery() { - if (isSQLSupported()) { - int index = 0; - Query query = getPM().newNamedQuery(null, "SQLQuery"); - executeJDOQuery( - ASSERTION_FAILED, query, "Named SQL query", false, null, expectedResult[index], true); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.7-3 (CandidateClass) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(NoCandidateClass.class); + } + + /** The array of valid SQL queries. */ + private static final String[] VALID_SQL_QUERIES = { + "SELECT firstname, lastname FROM {0}.persons" + }; + + /** + * The expected results of valid SQL queries. + */ + private Object[] expectedResult = { + Arrays.asList(new Object[]{ + new Object[]{"emp1First", "emp1Last"}, + new Object[]{"emp2First", "emp2Last"}, + new Object[]{"emp3First", "emp3Last"}, + new Object[]{"emp4First", "emp4Last"}, + new Object[]{"emp5First", "emp5Last"}}) + }; + + /** */ + public void testNamedQuery() { + if (isSQLSupported()) { + int index = 0; + Query query = getPM().newNamedQuery(null, "SQLQuery"); + executeJDOQuery(ASSERTION_FAILED, query, "Named SQL query", + false, null, expectedResult[index], true); + } } - } - /** */ - public void testNoCandidateClass() { - if (isSQLSupported()) { - int index = 0; - executeSQLQuery( - ASSERTION_FAILED, - VALID_SQL_QUERIES[index], - null, - null, - true, - null, - expectedResult[index], - false); + /** */ + public void testNoCandidateClass() { + if (isSQLSupported()) { + int index = 0; + executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index], + null, null, true, null, expectedResult[index], false); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/query/sql/ShapeOfResult.java b/tck/src/main/java/org/apache/jdo/tck/query/sql/ShapeOfResult.java index bf905d0b8..f6ef6a7a6 100644 --- a/tck/src/main/java/org/apache/jdo/tck/query/sql/ShapeOfResult.java +++ b/tck/src/main/java/org/apache/jdo/tck/query/sql/ShapeOfResult.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -19,7 +19,10 @@ import java.text.MessageFormat; import java.util.Arrays; + import javax.jdo.Query; + +import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.CompanyModelReader; import org.apache.jdo.tck.pc.mylib.MylibReader; import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; @@ -28,208 +31,156 @@ import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Shape of Result.
    - * Keywords: query
    - * Assertion ID: A14.7-4.
    - * Assertion Description: Table 7: Shape of Result of SQL Query + *Title: Shape of Result. + *
    + *Keywords: query + *
    + *Assertion ID: A14.7-4. + *
    + *Assertion Description: + * Table 7: Shape of Result of SQL Query */ public class ShapeOfResult extends QueryTest { - /** */ - private static final String ASSERTION_FAILED = "Assertion A14.7-4 (ShapeOfResult) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(ShapeOfResult.class); - } - - /** The array of valid SQL queries. */ - private static final String[] VALID_SQL_QUERIES = { - // candidate class - "SELECT * FROM {0}.PrimitiveTypes", - // candidate class, unique - "SELECT * FROM {0}.PrimitiveTypes where id = 1", - // single column - "SELECT firstname FROM {0}.persons", - // single column, unique - "SELECT firstname FROM {0}.persons WHERE personid = 1", - // mutiple columns - "SELECT firstname, lastname FROM {0}.persons", - // mutiple columns, unique - "SELECT firstname, lastname FROM {0}.persons WHERE personid = 1", - // result class - "SELECT firstname, lastname FROM {0}.persons", - // result class, unique - "SELECT firstname, lastname FROM {0}.persons WHERE personid = 1" - }; - - /** The expected results of valid SQL queries. */ - private Object[] expectedResult = { - // candidate class - getTransientMylibInstancesAsList( - new String[] { - "primitiveTypesPositive", - "primitiveTypesNegative", - "primitiveTypesCharacterStringLiterals" - }), - // candidate class, unique - getTransientMylibInstance("primitiveTypesPositive"), - // single column - Arrays.asList(new Object[] {"emp1First", "emp2First", "emp3First", "emp4First", "emp5First"}), - // single column, unique - "emp1First", - // mutiple columns - Arrays.asList( - new Object[] { - new Object[] {"emp1First", "emp1Last"}, - new Object[] {"emp2First", "emp2Last"}, - new Object[] {"emp3First", "emp3Last"}, - new Object[] {"emp4First", "emp4Last"}, - new Object[] {"emp5First", "emp5Last"} - }), - // mutiple columns, unique - new Object[] {"emp1First", "emp1Last"}, - // result class - Arrays.asList( - new Object[] { - new FullName("emp1First", "emp1Last"), - new FullName("emp2First", "emp2Last"), - new FullName("emp3First", "emp3Last"), - new FullName("emp4First", "emp4Last"), - new FullName("emp5First", "emp5Last") - }), - // result class, unique - new FullName("emp1First", "emp1Last") - }; - - /** */ - public void testCanidateClass() { - if (isSQLSupported()) { - int index = 0; - executeSQLQuery( - ASSERTION_FAILED, - VALID_SQL_QUERIES[index], - PrimitiveTypes.class, - null, - true, - null, - expectedResult[index], - false); - index++; - executeSQLQuery( - ASSERTION_FAILED, - VALID_SQL_QUERIES[index], - PrimitiveTypes.class, - null, - true, - null, - expectedResult[index], - true); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.7-4 (ShapeOfResult) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(ShapeOfResult.class); } - } - - /** */ - public void testSingleColumn() { - if (isSQLSupported()) { - int index = 2; - executeSQLQuery( - ASSERTION_FAILED, - VALID_SQL_QUERIES[index], - null, - null, - true, - null, - expectedResult[index], - false); - index++; - executeSQLQuery( - ASSERTION_FAILED, - VALID_SQL_QUERIES[index], - null, - null, - true, - null, - expectedResult[index], - true); + + /** The array of valid SQL queries. */ + private static final String[] VALID_SQL_QUERIES = { + // candidate class + "SELECT * FROM {0}.PrimitiveTypes", + // candidate class, unique + "SELECT * FROM {0}.PrimitiveTypes where id = 1", + // single column + "SELECT firstname FROM {0}.persons", + // single column, unique + "SELECT firstname FROM {0}.persons WHERE personid = 1", + // mutiple columns + "SELECT firstname, lastname FROM {0}.persons", + // mutiple columns, unique + "SELECT firstname, lastname FROM {0}.persons WHERE personid = 1", + // result class + "SELECT firstname, lastname FROM {0}.persons", + // result class, unique + "SELECT firstname, lastname FROM {0}.persons WHERE personid = 1" + }; + + /** + * The expected results of valid SQL queries. + */ + private Object[] expectedResult = { + // candidate class + getTransientMylibInstancesAsList(new String[]{ + "primitiveTypesPositive", "primitiveTypesNegative", + "primitiveTypesCharacterStringLiterals"}), + // candidate class, unique + getTransientMylibInstance("primitiveTypesPositive"), + // single column + Arrays.asList(new Object[]{"emp1First", "emp2First", "emp3First", + "emp4First", "emp5First"}), + // single column, unique + "emp1First", + // mutiple columns + Arrays.asList(new Object[]{ + new Object[]{"emp1First", "emp1Last"}, + new Object[]{"emp2First", "emp2Last"}, + new Object[]{"emp3First", "emp3Last"}, + new Object[]{"emp4First", "emp4Last"}, + new Object[]{"emp5First", "emp5Last"}}), + // mutiple columns, unique + new Object[]{"emp1First", "emp1Last"}, + // result class + Arrays.asList(new Object[]{ + new FullName("emp1First", "emp1Last"), + new FullName("emp2First", "emp2Last"), + new FullName("emp3First", "emp3Last"), + new FullName("emp4First", "emp4Last"), + new FullName("emp5First", "emp5Last")}), + // result class, unique + new FullName("emp1First", "emp1Last") + }; + + /** */ + public void testCanidateClass() { + if (isSQLSupported()) { + int index = 0; + executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index], + PrimitiveTypes.class, null, true, null, + expectedResult[index], false); + index++; + executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index], + PrimitiveTypes.class, null, true, null, + expectedResult[index], true); + } } - } - /** */ - public void testMultipleColumn() { - if (isSQLSupported()) { - int index = 4; - executeSQLQuery( - ASSERTION_FAILED, - VALID_SQL_QUERIES[index], - null, - null, - true, - null, - expectedResult[index], - false); - index++; - executeSQLQuery( - ASSERTION_FAILED, - VALID_SQL_QUERIES[index], - null, - null, - true, - null, - expectedResult[index], - true); + /** */ + public void testSingleColumn() { + if (isSQLSupported()) { + int index = 2; + executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index], + null, null, true, null, expectedResult[index], false); + index++; + executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index], + null, null, true, null, expectedResult[index], true); + } } - } - - /** */ - public void testResultClass() { - if (isSQLSupported()) { - int index = 6; - executeSQLQuery( - ASSERTION_FAILED, - VALID_SQL_QUERIES[index], - null, - FullName.class, - true, - null, - expectedResult[index], - false); - index++; - executeSQLQuery( - ASSERTION_FAILED, - VALID_SQL_QUERIES[index], - null, - FullName.class, - true, - null, - expectedResult[index], - true); + + /** */ + public void testMultipleColumn() { + if (isSQLSupported()) { + int index = 4; + executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index], + null, null, true, null, expectedResult[index], false); + index++; + executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index], + null, null, true, null, expectedResult[index], true); + } } - } - - /** */ - public void testNegative() { - if (isSQLSupported()) { - String schema = getPMFProperty("javax.jdo.mapping.Schema"); - String sql = - MessageFormat.format("SELECT stringNull FROM {0}.PrimitiveTypes", new Object[] {schema}); - Query query = getPM().newQuery("javax.jdo.query.SQL", sql); - query.setClass(PrimitiveTypes.class); - compile(ASSERTION_FAILED, query, sql, false); + + /** */ + public void testResultClass() { + if (isSQLSupported()) { + int index = 6; + executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index], + null, FullName.class, true, null, expectedResult[index], false); + index++; + executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index], + null, FullName.class, true, null, expectedResult[index], true); + } + } + + /** */ + public void testNegative() { + if (isSQLSupported()) { + String schema = getPMFProperty("javax.jdo.mapping.Schema"); + String sql = MessageFormat.format( + "SELECT stringNull FROM {0}.PrimitiveTypes", + new Object[]{schema}); + Query query = getPM().newQuery("javax.jdo.query.SQL", sql); + query.setClass(PrimitiveTypes.class); + compile(ASSERTION_FAILED, query, sql, false); + } } - } - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(CompanyModelReader.getTearDownClasses()); - addTearDownClass(MylibReader.getTearDownClasses()); - loadAndPersistCompanyModel(getPM()); - loadAndPersistMylib(getPM()); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(CompanyModelReader.getTearDownClasses()); + addTearDownClass(MylibReader.getTearDownClasses()); + loadAndPersistCompanyModel(getPM()); + loadAndPersistMylib(getPM()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/AfterCompletionMethodCalledWhenCommitted.java b/tck/src/main/java/org/apache/jdo/tck/transactions/AfterCompletionMethodCalledWhenCommitted.java index 5492053c2..bb7c2bf46 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/AfterCompletionMethodCalledWhenCommitted.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/AfterCompletionMethodCalledWhenCommitted.java @@ -5,125 +5,135 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; import javax.transaction.Status; import javax.transaction.Synchronization; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: After Completion Method Called When Committed
    - * Keywords: transactions
    - * Assertion ID: A13.4.3-6.
    - * Assertion Description: The afterCompletionmethod of the Synchronization instance - * registered with a Transaction will be called during the behavior specified for the transaction - * completion method commit with a value of Status.STATUS_COMMITTE + *Title: After Completion Method Called When Committed + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.3-6. + *
    + *Assertion Description: +The afterCompletionmethod of the Synchronization instance registered with a Transaction +will be called during the behavior specified for the transaction completion method commit with a value of +Status.STATUS_COMMITTE */ -/* + + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/11/01 1.0 */ -public class AfterCompletionMethodCalledWhenCommitted extends JDO_Test implements Synchronization { - - private boolean afterCompletionCalled; - private Transaction tx; - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.3-6 (AfterCompletionMethodCalledWhenCommitted) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(AfterCompletionMethodCalledWhenCommitted.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } - - /** */ - public void test() { - pm = getPM(); +public class AfterCompletionMethodCalledWhenCommitted + extends JDO_Test + implements Synchronization { + + private boolean afterCompletionCalled; + private Transaction tx; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.3-6 (AfterCompletionMethodCalledWhenCommitted) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(AfterCompletionMethodCalledWhenCommitted.class); + } - runTestAfterCompletionMethodCalledWhenCommitted(pm); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /** */ + public void test() { + pm = getPM(); - pm.close(); - pm = null; - } + runTestAfterCompletionMethodCalledWhenCommitted(pm); - /** */ - public void beforeCompletion() { - try { - if (debug) logger.debug("before Complition isActive returns" + tx.isActive()); - } catch (Exception ex) { - fail( - ASSERTION_FAILED, - "tx.isActive called in beforeCompletion throws unexpected exception: " + ex); + pm.close(); + pm = null; } - } - /** - * This method is called by the transaction manager after the transaction is committed or rolled - * back. - * - * @param status The status of the transaction completion. - */ - public void afterCompletion(int status) { - if (status == javax.transaction.Status.STATUS_COMMITTED) { - afterCompletionCalled = true; - } else { - fail( - ASSERTION_FAILED, - "afterCompletion: incorrect status, expected " - + Status.STATUS_COMMITTED - + ", got " - + status); + /** */ + public void beforeCompletion() { + try { + if (debug) + logger.debug("before Complition isActive returns" + + tx.isActive()); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.isActive called in beforeCompletion throws unexpected exception: " + ex); + } } - } - /** test transactions.setSynchronization() */ - void runTestAfterCompletionMethodCalledWhenCommitted(PersistenceManager pm) { - tx = pm.currentTransaction(); - try { - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - - tx.setSynchronization(this); - afterCompletionCalled = false; - tx.commit(); - tx = null; - - if (!afterCompletionCalled) { - fail(ASSERTION_FAILED, "commit didn't invoke afterCompletion method"); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * This method is called by the transaction manager after the transaction is committed or rolled back. + * @param status The status of the transaction completion. + */ + public void afterCompletion(int status) { + if (status == javax.transaction.Status.STATUS_COMMITTED) { + afterCompletionCalled = true; + } + else { + fail(ASSERTION_FAILED, + "afterCompletion: incorrect status, expected " + + Status.STATUS_COMMITTED + ", got " + status); + } + } + + /** test transactions.setSynchronization() */ + void runTestAfterCompletionMethodCalledWhenCommitted(PersistenceManager pm) { + tx = pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + + tx.setSynchronization(this); + afterCompletionCalled = false ; + tx.commit(); + tx = null; + + if (!afterCompletionCalled) { + fail(ASSERTION_FAILED, + "commit didn't invoke afterCompletion method"); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/AfterCompletionMethodCalledWhenRolledback.java b/tck/src/main/java/org/apache/jdo/tck/transactions/AfterCompletionMethodCalledWhenRolledback.java index 41977e676..9b3575ad1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/AfterCompletionMethodCalledWhenRolledback.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/AfterCompletionMethodCalledWhenRolledback.java @@ -5,125 +5,136 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import javax.transaction.Status; import javax.transaction.Synchronization; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: After Completion Method Called When Rolledback
    - * Keywords: transactions
    - * Assertion ID: A13.4.3-7.
    - * Assertion Description: The afterCompletion method of the Synchronization instance - * registered with a Transaction will be called after the behavior specified for the method rollback - * with a value of Status.STATUS_ROLLEDBACK. + *Title: After Completion Method Called When Rolledback + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.3-7. + *
    + *Assertion Description: + * The afterCompletion method of the Synchronization instance registered with a + * Transaction will be called after the behavior specified for the method + * rollback with a value of Status.STATUS_ROLLEDBACK. */ -/* + + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/11/01 1.0 */ -public class AfterCompletionMethodCalledWhenRolledback extends JDO_Test implements Synchronization { - - private boolean afterCompletionCalled; - private Transaction tx; - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.3-7 (AfterCompletionMethodCalledWhenRolledback) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(AfterCompletionMethodCalledWhenRolledback.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTestAfterCompletionMethodCalledWhenRolledback(pm); - - pm.close(); - pm = null; - } - - /** */ - public void beforeCompletion() { - try { - if (debug) logger.debug("before Complition isActive returns :" + tx.isActive()); - } catch (Exception ex) { - fail( - ASSERTION_FAILED, - "tx.isActive called in beforeCompletion throws unexpected exception: " + ex); +public class AfterCompletionMethodCalledWhenRolledback + extends JDO_Test + implements Synchronization { + + private boolean afterCompletionCalled; + private Transaction tx; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.3-7 (AfterCompletionMethodCalledWhenRolledback) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(AfterCompletionMethodCalledWhenRolledback.class); } - } - /** - * This method is called by the transaction manager after the transaction is committed or rolled - * back. - * - * @param status The status of the transaction completion. - */ - public void afterCompletion(int status) { - if (status == javax.transaction.Status.STATUS_ROLLEDBACK) { - afterCompletionCalled = true; - } else { - fail( - ASSERTION_FAILED, - "afterCompletion: incorrect status, expected " - + Status.STATUS_ROLLEDBACK - + ", got " - + status); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTestAfterCompletionMethodCalledWhenRolledback(pm); + + pm.close(); + pm = null; } - } - /** test transactions.setSynchronization() */ - void runTestAfterCompletionMethodCalledWhenRolledback(PersistenceManager pm) { - tx = pm.currentTransaction(); - try { - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); + /** */ + public void beforeCompletion() { + try { + if (debug) + logger.debug("before Complition isActive returns :" + + tx.isActive()); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.isActive called in beforeCompletion throws unexpected exception: " + ex); + } + } - tx.setSynchronization(this); - afterCompletionCalled = false; - tx.rollback(); - tx = null; + /** + * This method is called by the transaction manager after the transaction is committed or rolled back. + * @param status The status of the transaction completion. + */ + public void afterCompletion(int status) { + if (status == javax.transaction.Status.STATUS_ROLLEDBACK) { + afterCompletionCalled = true; + } + else { + fail(ASSERTION_FAILED, + "afterCompletion: incorrect status, expected " + + Status.STATUS_ROLLEDBACK + ", got " + status); + } + } - if (!afterCompletionCalled) { - fail(ASSERTION_FAILED, "rollback didn't invoke afterCompletion method"); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** test transactions.setSynchronization() */ + void runTestAfterCompletionMethodCalledWhenRolledback(PersistenceManager pm) { + tx = pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + + tx.setSynchronization(this); + afterCompletionCalled = false ; + tx.rollback(); + tx = null; + + if (!afterCompletionCalled) { + fail(ASSERTION_FAILED, + "rollback didn't invoke afterCompletion method"); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/AfterSetRollbackOnlyCommitFails.java b/tck/src/main/java/org/apache/jdo/tck/transactions/AfterSetRollbackOnlyCommitFails.java index d43ecd170..79bf9a709 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/AfterSetRollbackOnlyCommitFails.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/AfterSetRollbackOnlyCommitFails.java @@ -19,42 +19,51 @@ import javax.jdo.JDOFatalDataStoreException; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; + import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Test AfterSetRollbackOnlyCommitFails
    - * Keywords: rollback commit setRollbackOnly
    - * Assertion IDs: A13.4.5-1
    - * Assertion Description: Once a transaction has been marked for rollback via - * setRollbackOnly, the commit method will always fail with JDOFatalDataStoreException. + *Title: Test AfterSetRollbackOnlyCommitFails + *
    + *Keywords: rollback commit setRollbackOnly + *
    + *Assertion IDs: A13.4.5-1 + + *
    + *Assertion Description: + Once a transaction has been marked for rollback via setRollbackOnly, + the commit method will always fail with JDOFatalDataStoreException. */ + public class AfterSetRollbackOnlyCommitFails extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.5-1 (AfterSetRollbackOnlyCommitFails) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(AfterSetRollbackOnlyCommitFails.class); - } - - /** */ - public void test() { - getPM(); - Transaction tx = pm.currentTransaction(); - tx.begin(); - tx.setRollbackOnly(); - try { - tx.commit(); - fail(ASSERTION_FAILED, "Failed to catch expected JDOFatalDataStoreException."); - } catch (JDOFatalDataStoreException ex) { - // Good catch! + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.5-1 (AfterSetRollbackOnlyCommitFails) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(AfterSetRollbackOnlyCommitFails.class); + } + + /** */ + public void test() { + getPM(); + Transaction tx = pm.currentTransaction(); + tx.begin(); + tx.setRollbackOnly(); + try { + tx.commit(); + fail(ASSERTION_FAILED, + "Failed to catch expected JDOFatalDataStoreException."); + } catch (JDOFatalDataStoreException ex) { + // Good catch! + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/BeforeCompletionMethodCalled.java b/tck/src/main/java/org/apache/jdo/tck/transactions/BeforeCompletionMethodCalled.java index 86517e430..2e23b233f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/BeforeCompletionMethodCalled.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/BeforeCompletionMethodCalled.java @@ -5,117 +5,127 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import javax.transaction.Status; import javax.transaction.Synchronization; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Before Completion Method Called
    - * Keywords: transactions
    - * Assertion ID: A13.4.3-4.
    - * Assertion Description: The beforeCompletion method of the Synchronization instance - * registered with a Transaction will be called during the behavior specified for the transaction - * completion method commit. + *Title: Before Completion Method Called + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.3-4. + *
    + *Assertion Description: +The beforeCompletion method of the +Synchronization instance registered with a Transaction will be +called during the behavior specified for the transaction completion +method commit. + */ -/* + + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/15/01 1.0 */ -public class BeforeCompletionMethodCalled extends JDO_Test implements Synchronization { - - private boolean beforeCompletionCalled; - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.3-4 (BeforeCompletionMethodCalled) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(BeforeCompletionMethodCalled.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTestBeforeCompletionMethodCalled(pm); - - pm.close(); - pm = null; - } - - /** */ - public void beforeCompletion() { - beforeCompletionCalled = true; - if (debug) logger.debug("beforeCompletion called "); - } - - /** - * This method is called by the transaction manager after the transaction is committed or rolled - * back. - * - * @param status The status of the transaction completion. - */ - public void afterCompletion(int status) { - if (status != javax.transaction.Status.STATUS_COMMITTED) { - fail( - ASSERTION_FAILED, - "afterCompletion: incorrect status, expected " - + Status.STATUS_COMMITTED - + ", got " - + status); +public class BeforeCompletionMethodCalled + extends JDO_Test + implements Synchronization { + + private boolean beforeCompletionCalled; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.3-4 (BeforeCompletionMethodCalled) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(BeforeCompletionMethodCalled.class); } - } - /** test transactions.setSynchronization() */ - void runTestBeforeCompletionMethodCalled(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTestBeforeCompletionMethodCalled(pm); + + pm.close(); + pm = null; + } - tx.setSynchronization(this); - beforeCompletionCalled = false; - tx.commit(); - tx = null; + /** */ + public void beforeCompletion(){ + beforeCompletionCalled = true; + if (debug) logger.debug ("beforeCompletion called "); + } - if (!beforeCompletionCalled) { - fail(ASSERTION_FAILED, "commit didn't invoke beforeCompletion method"); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * This method is called by the transaction manager after the transaction is committed or rolled back. + * @param status The status of the transaction completion. + */ + public void afterCompletion(int status) { + if (status != javax.transaction.Status.STATUS_COMMITTED) { + fail(ASSERTION_FAILED, + "afterCompletion: incorrect status, expected " + + Status.STATUS_COMMITTED + ", got " + status); + } + } + + /** test transactions.setSynchronization() */ + void runTestBeforeCompletionMethodCalled(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + + tx.setSynchronization(this); + beforeCompletionCalled = false ; + tx.commit(); + tx = null; + + if (!beforeCompletionCalled) { + fail(ASSERTION_FAILED, + "commit didn't invoke beforeCompletion method"); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/BeforeCompletionMethodNotCalledBeforeRollback.java b/tck/src/main/java/org/apache/jdo/tck/transactions/BeforeCompletionMethodNotCalledBeforeRollback.java index 39882eec8..602d1bbf9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/BeforeCompletionMethodNotCalledBeforeRollback.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/BeforeCompletionMethodNotCalledBeforeRollback.java @@ -5,116 +5,122 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; import javax.transaction.Status; import javax.transaction.Synchronization; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; /** - * Title: Before Completion Method Not Called Before Rolledback
    - * Keywords: transactions
    - * Assertion ID: A13.4.3-5.
    - * Assertion Description: The beforeCompletion method of the Synchronization instance - * registered with a Transaction will not be called before rollback. + *Title: Before Completion Method Not Called Before Rolledback + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.3-5. + *
    + *Assertion Description: + The beforeCompletion method of the Synchronization instance registered with a Transaction will not be +called before rollback. + */ -/* + + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/15/01 1.0 */ -public class BeforeCompletionMethodNotCalledBeforeRollback extends JDO_Test +public class BeforeCompletionMethodNotCalledBeforeRollback + extends JDO_Test implements Synchronization { + + private boolean beforeCompletionCalled; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.3-5 (BeforeCompletionMethodNotCalledBeforeRollback) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(BeforeCompletionMethodNotCalledBeforeRollback.class); + } - private boolean beforeCompletionCalled; - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.3-5 (BeforeCompletionMethodNotCalledBeforeRollback) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(BeforeCompletionMethodNotCalledBeforeRollback.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTestBeforeCompletionMethodNotCalledBeforeRollback(pm); - - pm.close(); - pm = null; - } - - /** */ - public void beforeCompletion() { - beforeCompletionCalled = true; - } - - /** - * This method is called by the transaction manager after the transaction is committed or rolled - * back. - * - * @param status The status of the transaction completion. - */ - public void afterCompletion(int status) { - if (status != javax.transaction.Status.STATUS_ROLLEDBACK) { - fail( - ASSERTION_FAILED, - "afterCompletion: incorrect status, expected " - + Status.STATUS_ROLLEDBACK - + ", got " - + status); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTestBeforeCompletionMethodNotCalledBeforeRollback(pm); + + pm.close(); + pm = null; } - } - /** test transactions.rollback() */ - void runTestBeforeCompletionMethodNotCalledBeforeRollback(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); + /** */ + public void beforeCompletion() { + beforeCompletionCalled = true ; + } - tx.setSynchronization(this); - beforeCompletionCalled = false; - tx.rollback(); - tx = null; + /** + * This method is called by the transaction manager after the transaction is committed or rolled back. + * @param status The status of the transaction completion. + */ + public void afterCompletion(int status) { + if (status != javax.transaction.Status.STATUS_ROLLEDBACK) { + fail(ASSERTION_FAILED, + "afterCompletion: incorrect status, expected " + + Status.STATUS_ROLLEDBACK + ", got " + status); + } + } - if (beforeCompletionCalled) { - fail(ASSERTION_FAILED, "rollback invoked beforeCompletion, but it should not."); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** test transactions.rollback() */ + void runTestBeforeCompletionMethodNotCalledBeforeRollback(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + + tx.setSynchronization(this); + beforeCompletionCalled = false ; + tx.rollback(); + tx = null; + + if (beforeCompletionCalled) { + fail(ASSERTION_FAILED, + "rollback invoked beforeCompletion, but it should not."); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/Commit.java b/tck/src/main/java/org/apache/jdo/tck/transactions/Commit.java index a5becd973..bb66ca66e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/Commit.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/Commit.java @@ -5,16 +5,16 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.JDOHelper; @@ -22,127 +22,134 @@ import javax.jdo.Transaction; import javax.transaction.Status; import javax.transaction.Synchronization; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Commit
    - * Keywords: transactions
    - * Assertion ID: A13.4.4-1.
    - * Assertion Description: The commit method performs the following operations: - * - *

      - *
    • calls the beforeCompletion method of the Synchronization instance - * registered with the Transaction; - *
    • flushes dirty persistent instances; - *
    • notifies the underlying data store to commit the transaction (this cannot be tested) - *
    • transitions persistent instances according to the life cycle specification; - *
    • calls the afterCompletion method of the Synchronization instance - * registered with the Transaction with the results of the data store commit - * operation. - *
    + *Title: Commit + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.4-1. + *
    + *Assertion Description: + The commit method performs the following operations: +
      +
    • calls the beforeCompletion method of the + Synchronization instance registered with the + Transaction;
    • +
    • flushes dirty persistent instances;
    • +
    • notifies the underlying data store to commit the transaction + (this cannot be tested)
    • +
    • transitions persistent instances according to the life cycle specification;
    • +
    • calls the afterCompletion method of the Synchronization + instance registered with the Transaction with the results of the + data store commit operation.
    • +
    */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/15/01 1.0 */ public class Commit extends JDO_Test implements Synchronization { + + private boolean beforeCompletionCalled; + private boolean afterCompletionCalled; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.4-1 (Commit) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Commit.class); + } - private boolean beforeCompletionCalled; - private boolean afterCompletionCalled; - - /** */ - private static final String ASSERTION_FAILED = "Assertion A13.4.4-1 (Commit) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Commit.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTestCommit(pm); - - pm.close(); - pm = null; - } - - /** */ - public void beforeCompletion() { - beforeCompletionCalled = true; - if (debug) logger.debug("beforeCompletion called "); - } - - /** - * This method is called by the transaction manager after the transaction is committed or rolled - * back. - * - * @param status The status of the transaction completion. - */ - public void afterCompletion(int status) { - if (status == Status.STATUS_COMMITTED) { - afterCompletionCalled = true; - if (debug) logger.debug("afterCompletion called\n "); - } else { - fail( - ASSERTION_FAILED, - "afterCompletion: incorrect status, expected " - + Status.STATUS_COMMITTED - + ", got " - + status); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTestCommit(pm); + + pm.close(); + pm = null; } - } - /** test transactions.setSynchronization() */ - void runTestCommit(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - if (!JDOHelper.isDirty(p1)) { - fail( - ASSERTION_FAILED, - "P-NEW instance expected to be dirty, JDOHelper.isDirty returns false."); - } + /** */ + public void beforeCompletion(){ + beforeCompletionCalled = true; + if (debug) logger.debug("beforeCompletion called "); + } - tx.setSynchronization(this); - beforeCompletionCalled = false; - afterCompletionCalled = false; - tx.commit(); - tx = null; + /** + * This method is called by the transaction manager after the transaction is committed or rolled back. + * @param status The status of the transaction completion. + */ + public void afterCompletion(int status) { + if (status == Status.STATUS_COMMITTED) { + afterCompletionCalled = true; + if (debug) logger.debug("afterCompletion called\n "); + } + else { + fail(ASSERTION_FAILED, + "afterCompletion: incorrect status, expected " + + Status.STATUS_COMMITTED + ", got " + status); + } + } - if (JDOHelper.isDirty(p1)) { - fail( - ASSERTION_FAILED, - "P-NEW instance should transition to HOLLOW or P-NONTX and then it should not be dirty, JDOHelper.isDirty returns true."); - } - if (!beforeCompletionCalled) { - fail(ASSERTION_FAILED, "commit didn't invoke beforeCompletion method"); - } - if (!afterCompletionCalled) { - fail(ASSERTION_FAILED, "commit didn't invoke afterCompletion method"); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** test transactions.setSynchronization() */ + void runTestCommit(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + if (!JDOHelper.isDirty(p1)) { + fail(ASSERTION_FAILED, + "P-NEW instance expected to be dirty, JDOHelper.isDirty returns false."); + } + + tx.setSynchronization(this); + beforeCompletionCalled = false; + afterCompletionCalled = false; + tx.commit(); + tx = null; + + if (JDOHelper.isDirty(p1)) { + fail(ASSERTION_FAILED, + "P-NEW instance should transition to HOLLOW or P-NONTX and then it should not be dirty, JDOHelper.isDirty returns true."); + } + if (!beforeCompletionCalled) { + fail(ASSERTION_FAILED, + "commit didn't invoke beforeCompletion method"); + } + if (!afterCompletionCalled) { + fail(ASSERTION_FAILED, + "commit didn't invoke afterCompletion method"); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/GetPersistenceManager.java b/tck/src/main/java/org/apache/jdo/tck/transactions/GetPersistenceManager.java index 2c539c856..8ad46d7ce 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/GetPersistenceManager.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/GetPersistenceManager.java @@ -5,89 +5,97 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Get Persistence Manager
    - * Keywords: transactions
    - * Assertion ID: A13.4.1-1.
    - * Assertion Description: The transactions.getPersistenceManager method returns associated - * persistence manager if the object parameter ia not null and implements persistenceCapable. - * evaluating to true when == is used. + *Title: Get Persistence Manager + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.1-1. + *
    + *Assertion Description: + The transactions.getPersistenceManager method returns associated persistence manager + if the object parameter ia not null and implements persistenceCapable. + evaluating to true when == is used. */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 9/26/01 1.0 */ public class GetPersistenceManager extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.1-1 (GetPersistenceManager) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetPersistenceManager.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTestGetPersistenceManager(pm); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.1-1 (GetPersistenceManager) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetPersistenceManager.class); + } - pm.close(); - pm = null; - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTestGetPersistenceManager(pm); - /** test transactions.getPersistenceManager() */ - void runTestGetPersistenceManager(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - PersistenceManager pm1 = tx.getPersistenceManager(); - tx.commit(); - tx = null; + pm.close(); + pm = null; + } + + /** test transactions.getPersistenceManager() */ + void runTestGetPersistenceManager(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + PersistenceManager pm1 = tx.getPersistenceManager(); + tx.commit(); + tx = null; - if (pm1 != pm) - fail( - ASSERTION_FAILED, - "tx.getPersistenceManager() returned unexpected pm, expected " + pm + ", got " + pm1); - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + if (pm1 != pm) + fail(ASSERTION_FAILED, + "tx.getPersistenceManager() returned unexpected pm, expected " + pm + ", got " + pm1); + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/GetRetainValues.java b/tck/src/main/java/org/apache/jdo/tck/transactions/GetRetainValues.java index ad8fb24c9..7bae115b9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/GetRetainValues.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/GetRetainValues.java @@ -5,90 +5,102 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Get Retain Values
    - * Keywords: transactions
    - * Assertion ID: A13.4.2-17.
    - * Assertion Description: Transaction.getRetainValues returns the currently active setting - * for the RetainValues flag. + *Title: Get Retain Values + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.2-17. + *
    + *Assertion Description: + Transaction.getRetainValues returns the currently active setting for the + RetainValues flag. */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/09/01 1.0 */ public class GetRetainValues extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A13.4.2-17 (GetRetainValues) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetRetainValues.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTestGetRetainValues(pm); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.2-17 (GetRetainValues) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetRetainValues.class); + } - pm.close(); - pm = null; - } + /** */ + public void test() { + pm = getPM(); + + runTestGetRetainValues(pm); - /** - * test transaction.getRetainValues() - * - * @param pm the PersistenceManager - */ - public void runTestGetRetainValues(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.setRetainValues(true); - tx.begin(); - if (!tx.getRetainValues()) { - fail(ASSERTION_FAILED, "tx.getRetainValues returns false after setting the flag to true."); - } - tx.commit(); - if (!tx.getRetainValues()) { - fail(ASSERTION_FAILED, "tx.getRetainValues returns false after setting the flag to true."); - } + pm.close(); + pm = null; + } - tx.setRetainValues(false); - tx.begin(); - if (tx.getRetainValues()) { - fail(ASSERTION_FAILED, "tx.getRetainValues returns true after setting the flag to false."); - } - tx.commit(); - if (tx.getRetainValues()) { - fail(ASSERTION_FAILED, "tx.getRetainValues returns true after setting the flag to false."); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** test transaction.getRetainValues() + * @param pm the PersistenceManager + */ + public void runTestGetRetainValues(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.setRetainValues(true); + tx.begin(); + if (!tx.getRetainValues()) { + fail(ASSERTION_FAILED, + "tx.getRetainValues returns false after setting the flag to true."); + } + tx.commit(); + if (!tx.getRetainValues()) { + fail(ASSERTION_FAILED, + "tx.getRetainValues returns false after setting the flag to true."); + } + + tx.setRetainValues(false); + tx.begin(); + if (tx.getRetainValues()) { + fail(ASSERTION_FAILED, + "tx.getRetainValues returns true after setting the flag to false."); + } + tx.commit(); + if (tx.getRetainValues()) { + fail(ASSERTION_FAILED, + "tx.getRetainValues returns true after setting the flag to false."); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/GetRollbackOnlyReturnsFalseUntilSet.java b/tck/src/main/java/org/apache/jdo/tck/transactions/GetRollbackOnlyReturnsFalseUntilSet.java index 42fd4b85e..1b99aeecb 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/GetRollbackOnlyReturnsFalseUntilSet.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/GetRollbackOnlyReturnsFalseUntilSet.java @@ -5,63 +5,71 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; + import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Test GetRollbackOnlyReturnsFalseUntilSet
    - * Keywords: commit setRollbackOnly getRollbackOnly
    - * Assertion IDs: A13.4.5-2
    - * Assertion Description: When a transaction is not active, and after a transaction is - * begun, getRollbackOnly will return false. Once setRollbackOnly has been called, it will return - * true until commit or rollback is called. + *Title: Test GetRollbackOnlyReturnsFalseUntilSet + *
    + *Keywords: commit setRollbackOnly getRollbackOnly + *
    + *Assertion IDs: A13.4.5-2 + *
    + *Assertion Description: +When a transaction is not active, and after a transaction is begun, +getRollbackOnly will return false. Once setRollbackOnly has been called, +it will return true until commit or rollback is called. */ -public class GetRollbackOnlyReturnsFalseUntilSet extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.5-2 (GetRollbackOnlyReturnsFalseUntilSet) failed: "; +public class GetRollbackOnlyReturnsFalseUntilSet extends JDO_Test { - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetRollbackOnlyReturnsFalseUntilSet.class); - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.5-2 (GetRollbackOnlyReturnsFalseUntilSet) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetRollbackOnlyReturnsFalseUntilSet.class); + } - /** */ - public void test() { - getPM(); - Transaction tx = pm.currentTransaction(); - assertFalse( - ASSERTION_FAILED + "getRollbackOnly returned true before transaction begin.", - tx.getRollbackOnly()); - tx.begin(); - assertFalse( - ASSERTION_FAILED + "getRollbackOnly returned true before setRollbackOnly.", - tx.getRollbackOnly()); - tx.setRollbackOnly(); - assertTrue( - ASSERTION_FAILED + "getRollbackOnly returned false after setRollbackOnly.", - tx.getRollbackOnly()); - tx.rollback(); - assertFalse( - ASSERTION_FAILED + "getRollbackOnly returned true after transaction rollback.", - tx.getRollbackOnly()); - } + /** */ + public void test() { + getPM(); + Transaction tx = pm.currentTransaction(); + assertFalse(ASSERTION_FAILED + + "getRollbackOnly returned true before transaction begin.", + tx.getRollbackOnly()); + tx.begin(); + assertFalse(ASSERTION_FAILED + + "getRollbackOnly returned true before setRollbackOnly.", + tx.getRollbackOnly()); + tx.setRollbackOnly(); + assertTrue(ASSERTION_FAILED + + "getRollbackOnly returned false after setRollbackOnly.", + tx.getRollbackOnly()); + tx.rollback(); + assertFalse(ASSERTION_FAILED + + "getRollbackOnly returned true after transaction rollback.", + tx.getRollbackOnly()); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/GetSynchronization.java b/tck/src/main/java/org/apache/jdo/tck/transactions/GetSynchronization.java index 24fb99d9b..10a228f3a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/GetSynchronization.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/GetSynchronization.java @@ -5,119 +5,134 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; import javax.transaction.Synchronization; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Get Synchronization
    - * Keywords: transactions
    - * Assertion ID: A13.4.3-8.
    - * Assertion Description: A call to Transaction.getSynchronization retrieves the - * Synchronization instance that has been registered via setSynchronization. + *Title: Get Synchronization + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.3-8. + *
    + *Assertion Description: + A call to Transaction.getSynchronization + retrieves the Synchronization instance that has been registered via + setSynchronization. */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/11/01 1.0 */ -public class GetSynchronization extends JDO_Test implements Synchronization { - - private Transaction tx; - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.3-8 (GetSynchronization) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(GetSynchronization.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } - - /** */ - public void beforeCompletion() { - try { - if (debug) logger.debug("before Complition isActive returns :" + tx.isActive()); - } catch (Exception ex) { - fail( - ASSERTION_FAILED, - "tx.isActive called in beforeCompletion throws unexpected exception: " + ex); +public class GetSynchronization + extends JDO_Test + implements Synchronization { + + private Transaction tx; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.3-8 (GetSynchronization) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(GetSynchronization.class); } - } - /** - * This method is called by the transaction manager after the transaction is committed or rolled - * back. - * - * @param status The status of the transaction completion. - */ - public void afterCompletion(int status) { - try { - if (debug) logger.debug("after Complition isActive returns :" + tx.isActive()); - } catch (Exception ex) { - fail( - ASSERTION_FAILED, - "tx.isActive called in afterCompletion throws unexpected exception: " + ex); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /** */ + public void beforeCompletion(){ + try { + if (debug) + logger.debug("before Complition isActive returns :" + + tx.isActive()); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.isActive called in beforeCompletion throws unexpected exception: " + ex); + } } - } - - /** */ - public void test() { - pm = getPM(); - - runTestGetSynchronization(pm); - - pm.close(); - pm = null; - } - - /** test transactions.getSynchronization() */ - void runTestGetSynchronization(PersistenceManager pm) { - tx = pm.currentTransaction(); - try { - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - tx.setSynchronization(this); - Synchronization s = tx.getSynchronization(); - if (s != this) { - fail(ASSERTION_FAILED, "wrong synchronization instance, expected " + this + ", got " + s); - } + /** + * This method is called by the transaction manager after the transaction is committed or rolled back. + * @param status The status of the transaction completion. + */ + public void afterCompletion(int status) { + try { + if (debug) + logger.debug("after Complition isActive returns :" + + tx.isActive()); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.isActive called in afterCompletion throws unexpected exception: " + ex); + } + } + + /** */ + public void test() { + pm = getPM(); + + runTestGetSynchronization(pm); + + pm.close(); + pm = null; + } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** test transactions.getSynchronization() */ + void runTestGetSynchronization(PersistenceManager pm) { + tx = pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + + tx.setSynchronization(this); + Synchronization s = tx.getSynchronization(); + if (s != this) { + fail(ASSERTION_FAILED, + "wrong synchronization instance, expected " + this + ", got " + s); + } + + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/IsActive.java b/tck/src/main/java/org/apache/jdo/tck/transactions/IsActive.java index 050ee2415..1adb60fc2 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/IsActive.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/IsActive.java @@ -5,89 +5,101 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Is Active
    - * Keywords: transactions
    - * Assertion ID: A13.4.1-2.
    - * Assertion Description: The transactions.isActive method tells whether there is an active - * transaction. There will be an active transaction if the begin method has been executed but - * neither commit nor rollback has been executed. + *Title: Is Active + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.1-2. + *
    + *Assertion Description: + The transactions.isActive method tells whether there is an active + transaction. There will be an active transaction if the begin method + has been executed but neither commit nor rollback has been executed. */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/09/01 1.0 */ public class IsActive extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.1-2 (IsActive) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsActive.class); + } - /** */ - private static final String ASSERTION_FAILED = "Assertion A13.4.1-2 (IsActive) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsActive.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTestIsActive(pm); - - pm.close(); - pm = null; - } - - /** - * test transactions.isActive() - * - * @param pm the PersistenceManager - */ - void runTestIsActive(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - if (!tx.isActive()) { - fail(ASSERTION_FAILED, "tx.isActive returns false after tx.begin"); - } - tx.commit(); + /** */ + public void test() { + pm = getPM(); + + runTestIsActive(pm); - if (tx.isActive()) { - fail(ASSERTION_FAILED, "tx.isActive returns true after tx.commit"); - } + pm.close(); + pm = null; + } - tx.begin(); - tx.rollback(); - if (tx.isActive()) { - fail(ASSERTION_FAILED, "tx.isActive returns true after tx.rollback"); - } + /** + * test transactions.isActive() + * @param pm the PersistenceManager + */ + void runTestIsActive(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + if (!tx.isActive()) { + fail(ASSERTION_FAILED, + "tx.isActive returns false after tx.begin"); + } + tx.commit(); + + if (tx.isActive()) { + fail(ASSERTION_FAILED, + "tx.isActive returns true after tx.commit"); + } - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + tx.begin(); + tx.rollback(); + if (tx.isActive()) { + fail(ASSERTION_FAILED, + "tx.isActive returns true after tx.rollback"); + } + + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/IsActiveUntilAfterCompletionMethodCalled.java b/tck/src/main/java/org/apache/jdo/tck/transactions/IsActiveUntilAfterCompletionMethodCalled.java index 32deeaf54..7b3d9c3fb 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/IsActiveUntilAfterCompletionMethodCalled.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/IsActiveUntilAfterCompletionMethodCalled.java @@ -5,125 +5,136 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; import javax.transaction.Synchronization; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Is Active Until After Completion Method Called
    - * Keywords: transactions
    - * Assertion ID: A13.4.1-3.
    - * Assertion Description: Transaction.isActive returns true after the transaction has been - * started, until the afterCompletion synchronization method is called + *Title: Is Active Until After Completion Method Called + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.1-3. + *
    + *Assertion Description: + Transaction.isActive returns true after the transaction has been started, until the afterCompletion + synchronization method is called */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/09/01 1.0 */ -public class IsActiveUntilAfterCompletionMethodCalled extends JDO_Test implements Synchronization { - - private Transaction tx; - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.1-3 (IsActiveUntilAfterCompletionMethodCalled) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(IsActiveUntilAfterCompletionMethodCalled.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } - - /** */ - public void beforeCompletion() { - try { - if (!tx.isActive()) { - fail(ASSERTION_FAILED, "tx.isActive returns false in beforeCompletion."); - } - } catch (Exception ex) { - fail( - ASSERTION_FAILED, - "tx.isActive called in beforeCompletion throws unexpected exception: " + ex); +public class IsActiveUntilAfterCompletionMethodCalled + extends JDO_Test + implements Synchronization { + + private Transaction tx; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.1-3 (IsActiveUntilAfterCompletionMethodCalled) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(IsActiveUntilAfterCompletionMethodCalled.class); } - } - /** - * This method is called by the transaction manager after the transaction is committed or rolled - * back. - * - * @param status The status of the transaction completion. - */ - public void afterCompletion(int status) { - try { - if (tx.isActive()) { - fail(ASSERTION_FAILED, "tx.isActive returns true in afterCompletion."); - } - } catch (Exception ex) { - fail( - ASSERTION_FAILED, - "tx.isActive called in afterCompletion throws unexpected exception: " + ex); + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /** */ + public void beforeCompletion() { + try { + if (!tx.isActive()) { + fail(ASSERTION_FAILED, + "tx.isActive returns false in beforeCompletion."); + } + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.isActive called in beforeCompletion throws unexpected exception: " + ex); + } } - } - - /** */ - public void test() { - pm = getPM(); - - runTestIsActiveUntilAfterCompletionMethodCalled(pm); - - pm.close(); - pm = null; - } - - /** test transactions.isActive() */ - void runTestIsActiveUntilAfterCompletionMethodCalled(PersistenceManager pm) { - tx = pm.currentTransaction(); - try { - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - tx.setSynchronization(this); - if (!tx.isActive()) { - fail( - ASSERTION_FAILED, - "tx.isActive returns false after tx.begin before tx.commit is completed."); - } - tx.commit(); - if (tx.isActive()) { - fail(ASSERTION_FAILED, "tx.isActive returns true after tx.commit."); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * This method is called by the transaction manager after the transaction is committed or rolled back. + * @param status The status of the transaction completion. + */ + public void afterCompletion(int status) { + try { + if (tx.isActive()) { + fail(ASSERTION_FAILED, + "tx.isActive returns true in afterCompletion."); + } + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.isActive called in afterCompletion throws unexpected exception: " + ex); + } + } + + /** */ + public void test() { + pm = getPM(); + + runTestIsActiveUntilAfterCompletionMethodCalled(pm); + + pm.close(); + pm = null; + } + + /** test transactions.isActive() */ + void runTestIsActiveUntilAfterCompletionMethodCalled(PersistenceManager pm) { + tx = pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + tx.setSynchronization(this); + if (!tx.isActive()) { + fail(ASSERTION_FAILED, + "tx.isActive returns false after tx.begin before tx.commit is completed."); + } + + tx.commit(); + if (tx.isActive()) { + fail(ASSERTION_FAILED, + "tx.isActive returns true after tx.commit."); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/Rollback.java b/tck/src/main/java/org/apache/jdo/tck/transactions/Rollback.java index 197bf5292..6d1af2b11 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/Rollback.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/Rollback.java @@ -5,151 +5,163 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.JDOHelper; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import javax.transaction.Status; import javax.transaction.Synchronization; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.mylib.PCPoint; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Rollback
    - * Keywords: transactions
    - * Assertion ID: A13.4.4-2.
    - * Assertion Description: The rollback method performs the following - * operations: - * - *
      - *
    • rolls back changes made in this transaction from the data store; - *
    • transitions persistent instances according to the life cycle specification; - *
    • calls the afterCompletion method of the Synchronization instance - * registered with the Transaction. - *
    + *Title: Rollback + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.4-2. + *
    + *Assertion Description: + The rollback method performs the following operations: +
      +
    • rolls back changes made in this transaction from the data store;
    • +
    • transitions persistent instances + according to the life cycle specification;
    • +
    • calls the afterCompletion method of the + Synchronization instance registered with the + Transaction.
    • +
    */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/17/01 1.0 */ -public class Rollback extends JDO_Test implements Synchronization { - - private boolean beforeCompletionCalled; - private boolean afterCompletionCalled; - - /** */ - private static final String ASSERTION_FAILED = "Assertion A13.4.4-2 (Rollback) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(Rollback.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(PCPoint.class); - } - - /** */ - public void beforeCompletion() { - beforeCompletionCalled = true; - if (debug) logger.debug("beforeCompletion called "); - } - - /** - * This method is called by the transaction manager after the transaction is committed or rolled - * back. - * - * @param status The status of the transaction completion. - */ - public void afterCompletion(int status) { - if (status == javax.transaction.Status.STATUS_ROLLEDBACK) { - afterCompletionCalled = true; - if (debug) logger.debug("afterCompletion called\n "); - } else { - fail( - ASSERTION_FAILED, - "afterCompletion: incorrect status, expected " - + Status.STATUS_ROLLEDBACK - + ", got " - + status); +public class Rollback + extends JDO_Test + implements Synchronization { + + private boolean beforeCompletionCalled; + private boolean afterCompletionCalled; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.4-2 (Rollback) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(Rollback.class); } - } - /** */ - public void test() { - pm = getPM(); - - runTestRollback(pm); - - pm.close(); - pm = null; - } - - /** test transactions.setSynchronization() */ - void runTestRollback(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - PCPoint p1 = new PCPoint(1, 3); - pm.makePersistent(p1); - tx.commit(); - - tx.begin(); - p1.setX(55); - - if (!JDOHelper.isDirty(p1)) { - fail(ASSERTION_FAILED, "JDOHelper.isDirty returns false when called for dirty instance."); - } - - tx.setSynchronization(this); - beforeCompletionCalled = false; - afterCompletionCalled = false; - tx.rollback(); - - if (JDOHelper.isDirty(p1)) { - fail( - ASSERTION_FAILED, - "P-NEW instance should transition to HOLLOW or P-NONTX and then it should not be dirty, JDOHelper.isDirty returns true."); - } - tx.setSynchronization(null); - tx.begin(); - int x = p1.getX(); - tx.commit(); - if (x != 1) { - fail(ASSERTION_FAILED, "tx.rollback should rollback change of ip1.x, expected 1, got " + x); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(PCPoint.class); + } + + /** */ + public void beforeCompletion(){ + beforeCompletionCalled = true; + if (debug) logger.debug ("beforeCompletion called "); + } - if (beforeCompletionCalled) { - fail(ASSERTION_FAILED, "rollback did invoke beforeCompletion method."); - } - if (!afterCompletionCalled) { - fail(ASSERTION_FAILED, "commit didn't invoke afterCompletion method."); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * This method is called by the transaction manager after the transaction is committed or rolled back. + * @param status The status of the transaction completion. + */ + public void afterCompletion(int status) { + if (status == javax.transaction.Status.STATUS_ROLLEDBACK) { + afterCompletionCalled = true; + if (debug) logger.debug("afterCompletion called\n "); + } + else { + fail(ASSERTION_FAILED, + "afterCompletion: incorrect status, expected " + + Status.STATUS_ROLLEDBACK + ", got " + status); + } + } + + /** */ + public void test() { + pm = getPM(); + + runTestRollback(pm); + + pm.close(); + pm = null; + } + + /** test transactions.setSynchronization() */ + void runTestRollback(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 = new PCPoint(1,3); + pm.makePersistent(p1); + tx.commit(); + + tx.begin(); + p1.setX(55); + + if (!JDOHelper.isDirty(p1)) { + fail(ASSERTION_FAILED, + "JDOHelper.isDirty returns false when called for dirty instance."); + } + + tx.setSynchronization(this); + beforeCompletionCalled = false; + afterCompletionCalled = false ; + tx.rollback(); + + if (JDOHelper.isDirty(p1)) { + fail(ASSERTION_FAILED, + "P-NEW instance should transition to HOLLOW or P-NONTX and then it should not be dirty, JDOHelper.isDirty returns true."); + } + tx.setSynchronization(null); + tx.begin(); + int x = p1.getX(); + tx.commit(); + if (x != 1) { + fail(ASSERTION_FAILED, + "tx.rollback should rollback change of ip1.x, expected 1, got " + x); + } + + if (beforeCompletionCalled) { + fail(ASSERTION_FAILED, + "rollback did invoke beforeCompletion method."); + } + if (!afterCompletionCalled) { + fail(ASSERTION_FAILED, + "commit didn't invoke afterCompletion method."); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/SetIsolationLevel.java b/tck/src/main/java/org/apache/jdo/tck/transactions/SetIsolationLevel.java index 43cad2dd6..1cea40116 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/SetIsolationLevel.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/SetIsolationLevel.java @@ -5,16 +5,16 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.Constants; @@ -23,140 +23,145 @@ import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title:Set isolation level of transaction
    - * Keywords: persistencemanagerfactory
    - * Assertion IDs: A11.1-xxxx, A11.1-xxxx.
    - * Assertion Description: Transaction.getIsolationLevel() returns the value of the isolation - * level. Transaction.setIsolationLevel(String) sets the value of the isolation level. + *Title:Set isolation level of transaction + *
    + *Keywords: persistencemanagerfactory + *
    + *Assertion IDs: A11.1-xxxx, A11.1-xxxx. + *
    + *Assertion Description: + * Transaction.getIsolationLevel() returns the value + * of the isolation level. + * Transaction.setIsolationLevel(String) sets the value + * of the isolation level. */ -public class SetIsolationLevel extends JDO_Test implements Constants { - - /** */ - private static final String ASSERTION_29_FAILED = - "Assertion A13.4.2-29 (setIsolationLevel) failed: "; - /** */ - private static final String ASSERTION_25_FAILED = - "Assertion A13.4.2-25 (setIsolationLevel) failed: "; - /** All specified isolation levels */ - private static final String[] isolationLevels = - new String[] { - TX_READ_UNCOMMITTED, TX_READ_COMMITTED, TX_REPEATABLE_READ, TX_SNAPSHOT, TX_SERIALIZABLE - }; +public class SetIsolationLevel extends JDO_Test + implements Constants { + + /** */ + private static final String ASSERTION_29_FAILED = + "Assertion A13.4.2-29 (setIsolationLevel) failed: "; + /** */ + private static final String ASSERTION_25_FAILED = + "Assertion A13.4.2-25 (setIsolationLevel) failed: "; - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetIsolationLevel.class); - } + /** All specified isolation levels */ + private static final String[] isolationLevels = new String[] { + TX_READ_UNCOMMITTED, + TX_READ_COMMITTED, + TX_REPEATABLE_READ, + TX_SNAPSHOT, + TX_SERIALIZABLE + }; - /** */ - protected void localSetUp() { - pm = getPM(); - } + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetIsolationLevel.class); + } - /** Set IsolationLevel to all values. */ - public void testSetIsolationLevelOutsideTransaction() { - // iterate through all possible IsolationLevels - for (int i = 0; i < isolationLevels.length; ++i) { - String isolationLevel = isolationLevels[i]; - setIsolationLevel(isolationLevel); + /** */ + protected void localSetUp() { + pm = getPM(); } - closePMF(pmf); - failOnError(); - } - /** Set IsolationLevel to all values within datastore transaction. */ - public void testSetIsolationLevelWithActiveDataStoreTransaction() { - pm.currentTransaction().setOptimistic(false); - pm.currentTransaction().begin(); - // iterate through all possible IsolationLevels - for (int i = 0; i < isolationLevels.length; ++i) { - String isolationLevel = isolationLevels[i]; - try { - pm.currentTransaction().setIsolationLevel(isolationLevel); - appendMessage( - ASSERTION_25_FAILED - + "active datastore transaction; no exception thrown for " - + "setIsolationLevel(" - + isolationLevel - + ")."); - } catch (JDOUnsupportedOptionException ex) { - // good catch - } catch (Throwable t) { - appendMessage( - ASSERTION_25_FAILED - + "active datastore transaction; " - + "JDOUnsupportedOptionException not thrown for " - + "setIsolationLevel(" - + isolationLevel - + "). Unexpected exception: \n" - + t); - } + /** Set IsolationLevel to all values. */ + public void testSetIsolationLevelOutsideTransaction() { + // iterate through all possible IsolationLevels + for (int i = 0; i < isolationLevels.length; ++i) { + String isolationLevel = isolationLevels[i]; + setIsolationLevel(isolationLevel); + } + closePMF(pmf); + failOnError(); } - pm.currentTransaction().commit(); - closePMF(pmf); - failOnError(); - } - /** Set IsolationLevel to all values within optimistic transaction. */ - public void testSetIsolationLevelWithActiveOptimisticTransaction() { - if (!isOptimisticSupported()) { - printUnsupportedOptionalFeatureNotTested( - "testSetIsolationLevelWithActiveOptimisticTransaction", "Optimistic"); - return; + /** Set IsolationLevel to all values within datastore transaction. */ + public void testSetIsolationLevelWithActiveDataStoreTransaction() { + pm.currentTransaction().setOptimistic(false); + pm.currentTransaction().begin(); + // iterate through all possible IsolationLevels + for (int i = 0; i < isolationLevels.length; ++i) { + String isolationLevel = isolationLevels[i]; + try { + pm.currentTransaction().setIsolationLevel(isolationLevel); + appendMessage(ASSERTION_25_FAILED + + "active datastore transaction; no exception thrown for " + + "setIsolationLevel(" + isolationLevel + ")."); + } catch (JDOUnsupportedOptionException ex) { + // good catch + } catch (Throwable t) { + appendMessage(ASSERTION_25_FAILED + + "active datastore transaction; " + + "JDOUnsupportedOptionException not thrown for " + + "setIsolationLevel(" + isolationLevel + + "). Unexpected exception: \n" + t); + + } + } + pm.currentTransaction().commit(); + closePMF(pmf); + failOnError(); } - pm.currentTransaction().setOptimistic(true); - pm.currentTransaction().begin(); - // iterate through all possible IsolationLevels - for (int i = 0; i < isolationLevels.length; ++i) { - String isolationLevel = isolationLevels[i]; - setIsolationLevel(isolationLevel); + + /** Set IsolationLevel to all values within optimistic transaction. */ + public void testSetIsolationLevelWithActiveOptimisticTransaction() { + if (!isOptimisticSupported()) { + printUnsupportedOptionalFeatureNotTested( + "testSetIsolationLevelWithActiveOptimisticTransaction", + "Optimistic"); + return; + } + pm.currentTransaction().setOptimistic(true); + pm.currentTransaction().begin(); + // iterate through all possible IsolationLevels + for (int i = 0; i < isolationLevels.length; ++i) { + String isolationLevel = isolationLevels[i]; + setIsolationLevel(isolationLevel); + } + pm.currentTransaction().commit(); + closePMF(pmf); + failOnError(); } - pm.currentTransaction().commit(); - closePMF(pmf); - failOnError(); - } - /** */ - private void setIsolationLevel(String level) { - Transaction tx = pm.currentTransaction(); - String property = PROPERTY_TRANSACTION_ISOLATION_LEVEL + "." + level; - if (isSupported(property)) { - tx.setIsolationLevel(level); - String actual = tx.getIsolationLevel(); - if (!validLevelSubstitution(level, actual)) { - appendMessage( - ASSERTION_29_FAILED - + "\nIsolationLevel set to " - + level - + "; value returned by Transaction is " - + actual); - } - } else { - try { - tx.setIsolationLevel(level); - // no exception thrown; bad - appendMessage(ASSERTION_29_FAILED + "\nThe expected JDOUserException was not thrown."); - } catch (JDOUnsupportedOptionException ex) { - // good catch - return; - } catch (Throwable t) { - // wrong exception thrown; bad - appendMessage( - ASSERTION_29_FAILED - + "active datastore transaction; " - + "JDOUnsupportedOptionException not thrown for " - + "setIsolationLevel(" - + level - + "). Unexpected exception: \n" - + t); - return; - } + /** */ + private void setIsolationLevel(String level) { + Transaction tx = pm.currentTransaction(); + String property = PROPERTY_TRANSACTION_ISOLATION_LEVEL + "." + level; + if (isSupported(property)) { + tx.setIsolationLevel(level); + String actual = tx.getIsolationLevel(); + if (!validLevelSubstitution(level, actual)) { + appendMessage(ASSERTION_29_FAILED + + "\nIsolationLevel set to " + + level + + "; value returned by Transaction is " + + actual); + } + } else { + try { + tx.setIsolationLevel(level); + // no exception thrown; bad + appendMessage(ASSERTION_29_FAILED + + "\nThe expected JDOUserException was not thrown."); + } catch (JDOUnsupportedOptionException ex) { + // good catch + return; + } catch (Throwable t) { + // wrong exception thrown; bad + appendMessage(ASSERTION_29_FAILED + + "active datastore transaction; " + + "JDOUnsupportedOptionException not thrown for " + + "setIsolationLevel(" + level + + "). Unexpected exception: \n" + t); + return; + } + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/SetNontransactionalRead.java b/tck/src/main/java/org/apache/jdo/tck/transactions/SetNontransactionalRead.java index 81d348b72..22ef89883 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/SetNontransactionalRead.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/SetNontransactionalRead.java @@ -5,158 +5,164 @@ * 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 + * + * 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.jdo.tck.transactions; import java.util.Collection; import java.util.Date; import java.util.Iterator; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.Company; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Set Nontransactional Read
    - * Keywords: transactions
    - * Assertion ID: A13.4.2-9.
    - * Assertion Description: If an implementation supports nontransactional read, then a call - * to Transaction.setNontransactionalRead with a parameter value of true - * will set the flag to true and allows persistent instances to be read outside of a - * transaction. Queries and navigation will be allowed without an active transaction. + *Title: Set Nontransactional Read + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.2-9. + *
    + *Assertion Description: + If an implementation supports nontransactional read, then a call to + Transaction.setNontransactionalRead with a parameter value of + true will set the flag to true and allows persistent + instances to be read outside of a transaction. + Queries and navigation will be allowed without an active transaction. */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/18/01 1.0 */ public class SetNontransactionalRead extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.2-9 (SetNontransactionalRead) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetNontransactionalRead.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(Department.class); - addTearDownClass(Company.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTestSetNontransactionalRead(pm); - - pm.close(); - pm = null; - } - - /** - * test transactions.setNonteansactionalRead() - * - * @param pm the PersistenceManager - */ - public void runTestSetNontransactionalRead(PersistenceManager pm) { - if (!isNontransactionalReadSupported()) { - if (debug) logger.debug("Implementation does not support non transactional read"); - return; + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.2-9 (SetNontransactionalRead) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetNontransactionalRead.class); } - Transaction tx = pm.currentTransaction(); - try { - tx.setNontransactionalRead(true); - tx.begin(); - Company c = new Company(1L, "MyCompany", new Date(), null); - Department d = new Department(999, "MyDepartment", c); - pm.makePersistent(c); - pm.makePersistent(d); - Object oid = pm.getObjectId(d); - if (!tx.getNontransactionalRead()) { - fail( - ASSERTION_FAILED, - "tx.getNontransactionalRead returns false after setting the flag to true."); - } - tx.commit(); - if (!tx.getNontransactionalRead()) { - fail( - ASSERTION_FAILED, - "tx.getNontransactionalRead returns false after setting the flag to true."); - } - - // make sure transaction is not active - if (tx.isActive()) { - fail(ASSERTION_FAILED, "transaction still active after tx.commit."); - } - tx = null; - - // read department - d = (Department) pm.getObjectById(oid, true); - long deptid = d.getDeptid(); - if (deptid != 999) { - fail( - "Reading department outside of a transaction returns unexpected value of d.deptid, expected 999, got " - + deptid); - } - - // navigate from department to company - c = (Company) d.getCompany(); - if (c == null) { - fail("Navigating from department to company outside of a transaction returns null."); - } - String companyName = c.getName(); - if (!"MyCompany".equals(companyName)) { - fail( - "Navigated company returns unexpected value of c.name, expected MyCompany, got " - + companyName); - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(Department.class); + addTearDownClass(Company.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTestSetNontransactionalRead(pm); + + pm.close(); + pm = null; + } - // run query - Query q = pm.newQuery(Department.class); - q.setFilter("name == \"MyDepartment\""); - Collection result = (Collection) q.execute(); - Iterator i = result.iterator(); - if (!i.hasNext()) { - fail(ASSERTION_FAILED, "Query outside of a transaction returned empty collection."); - } - d = (Department) i.next(); - String deptName = d.getName(); - if (!"MyDepartment".equals(deptName)) { - fail( - "Department in query result returns unexpected value of d.name, expected MyDepartment, got " - + deptName); - } - if (i.hasNext()) { - fail(ASSERTION_FAILED, "Query outside of a transaction returns more than one instance."); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * test transactions.setNonteansactionalRead() + * @param pm the PersistenceManager + */ + public void runTestSetNontransactionalRead(PersistenceManager pm) { + if (!isNontransactionalReadSupported()) { + if (debug) + logger.debug("Implementation does not support non transactional read"); + return; + } + + Transaction tx = pm.currentTransaction(); + try { + tx.setNontransactionalRead(true); + tx.begin(); + Company c = new Company(1L, "MyCompany", new Date(), null); + Department d = new Department(999, "MyDepartment", c); + pm.makePersistent(c); + pm.makePersistent(d); + Object oid = pm.getObjectId(d); + if (!tx.getNontransactionalRead()) { + fail(ASSERTION_FAILED, + "tx.getNontransactionalRead returns false after setting the flag to true."); + } + tx.commit(); + if (!tx.getNontransactionalRead()) { + fail(ASSERTION_FAILED, + "tx.getNontransactionalRead returns false after setting the flag to true."); + } + + // make sure transaction is not active + if (tx.isActive()) { + fail(ASSERTION_FAILED, + "transaction still active after tx.commit."); + } + tx = null; + + // read department + d = (Department)pm.getObjectById(oid, true); + long deptid = d.getDeptid(); + if (deptid != 999) { + fail("Reading department outside of a transaction returns unexpected value of d.deptid, expected 999, got " + deptid); + } + + // navigate from department to company + c = (Company)d.getCompany(); + if (c == null) { + fail("Navigating from department to company outside of a transaction returns null."); + } + String companyName = c.getName(); + if (!"MyCompany".equals(companyName)) { + fail("Navigated company returns unexpected value of c.name, expected MyCompany, got " + companyName); + } + + // run query + Query q = pm.newQuery(Department.class); + q.setFilter("name == \"MyDepartment\""); + Collection result = (Collection)q.execute(); + Iterator i = result.iterator(); + if (!i.hasNext()) { + fail(ASSERTION_FAILED, + "Query outside of a transaction returned empty collection."); + } + d = (Department)i.next(); + String deptName = d.getName(); + if (!"MyDepartment".equals(deptName)) { + fail("Department in query result returns unexpected value of d.name, expected MyDepartment, got " + deptName); + } + if (i.hasNext()) { + fail(ASSERTION_FAILED, + "Query outside of a transaction returns more than one instance."); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/SetNontransactionalReadCalledDuringTxCompletion.java b/tck/src/main/java/org/apache/jdo/tck/transactions/SetNontransactionalReadCalledDuringTxCompletion.java index e725dda26..844350a2c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/SetNontransactionalReadCalledDuringTxCompletion.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/SetNontransactionalReadCalledDuringTxCompletion.java @@ -5,134 +5,141 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; import javax.transaction.Synchronization; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Set Nontransactional Read Called During TX Completion
    - * Keywords: transactions
    - * Assertion ID: A13.4.2-1.
    - * Assertion Description: If the setNontransactionalRead method of the Transaction interface - * is called during commit or rollback processing (within the beforeCompletion and afterCompletion - * synchronization methods), a JDOUserException is thrown. + *Title: Set Nontransactional Read Called During TX Completion + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.2-1. + *
    + *Assertion Description: + If the setNontransactionalRead method of the Transaction interface is + called during commit or rollback processing (within the beforeCompletion and afterCompletion + synchronization methods), a JDOUserException is thrown. + */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/18/01 1.0 */ -public class SetNontransactionalReadCalledDuringTxCompletion extends JDO_Test +public class SetNontransactionalReadCalledDuringTxCompletion + extends JDO_Test implements Synchronization { - private Transaction tx; - - private boolean nonTransactionalReadFlag; - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.2-1 (SetNontransactionalReadCalledDuringTxCompletion) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetNontransactionalReadCalledDuringTxCompletion.class); - } - - /** */ - public void beforeCompletion() { - if (debug) logger.debug("beforeCompletion."); - try { - tx.setNontransactionalRead(nonTransactionalReadFlag); - fail( - ASSERTION_FAILED, - "tx.setNontransactionalRead called in beforeCompletion should throw JDOUserException."); - } catch (JDOUserException ex) { - // expected exception - if (debug) logger.debug("caught expected exception " + ex); - } catch (Exception ex) { - fail( - ASSERTION_FAILED, - "tx.setNontransactionalRead called in beforeCompletion throws unexpected exception: " - + ex); + private Transaction tx; + + private boolean nonTransactionalReadFlag; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.2-1 (SetNontransactionalReadCalledDuringTxCompletion) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetNontransactionalReadCalledDuringTxCompletion.class); } - } - - /** - * This method is called by the transaction manager after the transaction is committed or rolled - * back. - * - * @param status The status of the transaction completion. - */ - public void afterCompletion(int status) { - if (debug) logger.debug("afterCompletion."); - try { - tx.setNontransactionalRead(nonTransactionalReadFlag); - } catch (JDOUserException ex) { - // TBD: need to remove this catch block as soon as the JDORI is - // fixed see 'Issue 61: Transaction.isActive issues' - if (debug) logger.debug("caught exception " + ex); - } catch (Exception ex) { - fail( - ASSERTION_FAILED, - "tx.setNontransactionalRead called in afterCompletion throws unexpected exception: " - + ex); + + /** */ + public void beforeCompletion() { + if (debug) logger.debug("beforeCompletion."); + try { + tx.setNontransactionalRead(nonTransactionalReadFlag); + fail(ASSERTION_FAILED, + "tx.setNontransactionalRead called in beforeCompletion should throw JDOUserException."); + } + catch (JDOUserException ex) { + // expected exception + if (debug) logger.debug("caught expected exception " + ex); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.setNontransactionalRead called in beforeCompletion throws unexpected exception: " + ex); + } } - } - - /** */ - public void test() { - pm = getPM(); - - runTestSetNontransactionalReadCalledDuringTxCompletion(pm); - - pm.close(); - pm = null; - } - - /** - * Test transactions.setNonteansactionalRead() - * - * @param pm the PersistenceManager - */ - public void runTestSetNontransactionalReadCalledDuringTxCompletion(PersistenceManager pm) { - tx = pm.currentTransaction(); - try { - tx.setSynchronization(this); - nonTransactionalReadFlag = false; - tx.begin(); - tx.commit(); - - if (isNontransactionalReadSupported()) { - nonTransactionalReadFlag = true; - tx.begin(); - tx.commit(); - } - - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * This method is called by the transaction manager after the transaction is committed or rolled back. + * @param status The status of the transaction completion. + */ + public void afterCompletion(int status) { + if (debug) logger.debug("afterCompletion."); + try { + tx.setNontransactionalRead(nonTransactionalReadFlag); + } + catch (JDOUserException ex) { + // TBD: need to remove this catch block as soon as the JDORI is + // fixed see 'Issue 61: Transaction.isActive issues' + if (debug) logger.debug("caught exception " + ex); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.setNontransactionalRead called in afterCompletion throws unexpected exception: " + ex); + } + } + + /** */ + public void test() { + pm = getPM(); + + runTestSetNontransactionalReadCalledDuringTxCompletion(pm); + + pm.close(); + pm = null; + } + + /** + * Test transactions.setNonteansactionalRead() + * @param pm the PersistenceManager + */ + public void runTestSetNontransactionalReadCalledDuringTxCompletion(PersistenceManager pm) { + tx = pm.currentTransaction(); + try { + tx.setSynchronization(this); + + nonTransactionalReadFlag = false; + tx.begin(); + tx.commit(); + + if (isNontransactionalReadSupported()) { + nonTransactionalReadFlag = true; + tx.begin(); + tx.commit(); + } + + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/SetNontransactionalReadTrueWhenNotSupported.java b/tck/src/main/java/org/apache/jdo/tck/transactions/SetNontransactionalReadTrueWhenNotSupported.java index c5907f42f..be0d79e85 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/SetNontransactionalReadTrueWhenNotSupported.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/SetNontransactionalReadTrueWhenNotSupported.java @@ -5,84 +5,92 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.JDOUnsupportedOptionException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Set Nontransactional Read True When Not Supported
    - * Keywords: transactions
    - * Assertion ID: A13.4.2-5.
    - * Assertion Description: If an implementation does not support nontransactional read, then - * a call to Transaction.setNontransactionalRead with a parameter value of true will cause a - * JDOUnsupportedOptionException to be thrown. + *Title: Set Nontransactional Read True When Not Supported + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.2-5. + *
    + *Assertion Description: + If an implementation does not support nontransactional read, then a + call to Transaction.setNontransactionalRead with a parameter value of true will + * cause a JDOUnsupportedOptionException to be thrown. */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/18/01 1.0 */ public class SetNontransactionalReadTrueWhenNotSupported extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.2-5 (SetNontransactionalReadTrueWhenNotSupported) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetNontransactionalReadTrueWhenNotSupported.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTestSetNontransactionalReadTrueWhenNotSupported(pm); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.2-5 (SetNontransactionalReadTrueWhenNotSupported) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetNontransactionalReadTrueWhenNotSupported.class); + } - pm.close(); - pm = null; - } + /** */ + public void test() { + pm = getPM(); + + runTestSetNontransactionalReadTrueWhenNotSupported(pm); - /** - * test transactions.setNonteansactionalRead() - * - * @param pm the PersistenceManager - */ - public void runTestSetNontransactionalReadTrueWhenNotSupported(PersistenceManager pm) { - if (isNontransactionalReadSupported()) { - if (debug) logger.debug("Implementation does support non transactional read."); - return; + pm.close(); + pm = null; } + + /** + * test transactions.setNonteansactionalRead() + * @param pm the PersistenceManager + */ + public void runTestSetNontransactionalReadTrueWhenNotSupported( + PersistenceManager pm) { + if (isNontransactionalReadSupported()) { + if (debug) + logger.debug("Implementation does support non transactional read."); + return; + } - Transaction tx = pm.currentTransaction(); - try { - tx.setNontransactionalRead(true); - fail( - ASSERTION_FAILED, - "tx.setNontransactionalRead(true) should throw JDOUnsupportedOptionException, if the implementation does not support non transactional read."); - } catch (JDOUnsupportedOptionException ex) { - // expected excepted - if (debug) logger.debug("caught expected exception " + ex); + Transaction tx = pm.currentTransaction(); + try { + tx.setNontransactionalRead(true); + fail(ASSERTION_FAILED, + "tx.setNontransactionalRead(true) should throw JDOUnsupportedOptionException, if the implementation does not support non transactional read."); + } + catch (JDOUnsupportedOptionException ex) { + // expected excepted + if (debug) logger.debug("caught expected exception " + ex); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/SetNontransactionalWriteCalledDuringTxCompletion.java b/tck/src/main/java/org/apache/jdo/tck/transactions/SetNontransactionalWriteCalledDuringTxCompletion.java index ee86e44d4..48f231d61 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/SetNontransactionalWriteCalledDuringTxCompletion.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/SetNontransactionalWriteCalledDuringTxCompletion.java @@ -5,134 +5,143 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; import javax.transaction.Synchronization; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Set Nontransactional Write Called During TX Completion
    - * Keywords: transactions
    - * Assertion ID: A13.4.2-1.
    - * Assertion Description: If the setNontransactionalWrite method of the Transaction - * interface is called during commit or rollback processing (within the beforeCompletion and - * afterCompletion synchronization methods), a JDOUserException is thrown. + *Title: Set Nontransactional Write Called During TX Completion + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.2-1. + *
    + *Assertion Description: + If the setNontransactionalWrite method of the Transaction interface is + called during commit or rollback processing (within the beforeCompletion + and afterCompletion synchronization methods), a JDOUserException is thrown. + */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/18/01 1.0 */ -public class SetNontransactionalWriteCalledDuringTxCompletion extends JDO_Test +public class SetNontransactionalWriteCalledDuringTxCompletion + extends JDO_Test implements Synchronization { - private Transaction tx; - - private boolean nonTransactionalWriteFlag; - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.2-2 (SetNontransactionalWriteCalledDuringTxCompletion) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetNontransactionalWriteCalledDuringTxCompletion.class); - } - - /** */ - public void beforeCompletion() { - if (debug) logger.debug("beforeCompletion."); - try { - tx.setNontransactionalWrite(nonTransactionalWriteFlag); - fail( - ASSERTION_FAILED, - "tx.setNontransactionalWrite called in beforeCompletion should throw JDOUserException."); - } catch (JDOUserException ex) { - // expected exception - if (debug) logger.debug("Caught expected exception " + ex); - } catch (Exception ex) { - fail( - ASSERTION_FAILED, - "tx.setNontransactionalWrite called in beforeCompletion throws unexpected exception: " - + ex); + private Transaction tx; + + private boolean nonTransactionalWriteFlag; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.2-2 (SetNontransactionalWriteCalledDuringTxCompletion) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetNontransactionalWriteCalledDuringTxCompletion.class); } - } - - /** - * This method is called by the transaction manager after the transaction is committed or rolled - * back. - * - * @param status The status of the transaction completion. - */ - public void afterCompletion(int status) { - if (debug) logger.debug("afterCompletion."); - try { - tx.setNontransactionalWrite(nonTransactionalWriteFlag); - } catch (JDOUserException ex) { - // TBD: need to remove this catch block as soon as the JDORI is - // fixed see 'Issue 61: Transaction.isActive issues' - if (debug) logger.debug("caught exception " + ex); - } catch (Exception ex) { - fail( - ASSERTION_FAILED, - "tx.setNontransactionalWrite called in afterCompletion throws unexpected exception: " - + ex); + + /** */ + public void beforeCompletion() { + if (debug) logger.debug("beforeCompletion."); + try { + tx.setNontransactionalWrite(nonTransactionalWriteFlag); + fail(ASSERTION_FAILED, + "tx.setNontransactionalWrite called in beforeCompletion should throw JDOUserException."); + } + catch (JDOUserException ex) { + // expected exception + if (debug) logger.debug("Caught expected exception " + ex); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.setNontransactionalWrite called in beforeCompletion throws unexpected exception: " + ex); + } } - } - - /** */ - public void test() { - pm = getPM(); - - runTestSetNontransactionalWriteCalledDuringTxCompletion(pm); - - pm.close(); - pm = null; - } - - /** - * test transactions.setNonteansactionalWrite() - * - * @param pm the PersistenceManager - */ - public void runTestSetNontransactionalWriteCalledDuringTxCompletion(PersistenceManager pm) { - tx = pm.currentTransaction(); - try { - tx.setSynchronization(this); - nonTransactionalWriteFlag = false; - tx.begin(); - tx.commit(); - - if (isNontransactionalWriteSupported()) { - nonTransactionalWriteFlag = true; - tx.begin(); - tx.commit(); - } else if (debug) logger.debug("Implementation does not support nontransactional write"); - - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * This method is called by the transaction manager after the transaction is committed or rolled back. + * @param status The status of the transaction completion. + */ + public void afterCompletion(int status) { + if (debug) logger.debug("afterCompletion."); + try { + tx.setNontransactionalWrite(nonTransactionalWriteFlag); + } + catch (JDOUserException ex) { + // TBD: need to remove this catch block as soon as the JDORI is + // fixed see 'Issue 61: Transaction.isActive issues' + if (debug) logger.debug("caught exception " + ex); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.setNontransactionalWrite called in afterCompletion throws unexpected exception: " + ex); + } + } + + /** */ + public void test() { + pm = getPM(); + + runTestSetNontransactionalWriteCalledDuringTxCompletion(pm); + + pm.close(); + pm = null; + } + + /** + * test transactions.setNonteansactionalWrite() + * @param pm the PersistenceManager + */ + public void runTestSetNontransactionalWriteCalledDuringTxCompletion(PersistenceManager pm) { + tx = pm.currentTransaction(); + try { + tx.setSynchronization(this); + + nonTransactionalWriteFlag = false; + tx.begin(); + tx.commit(); + + if (isNontransactionalWriteSupported()) { + nonTransactionalWriteFlag = true; + tx.begin(); + tx.commit(); + } + else if (debug) + logger.debug("Implementation does not support nontransactional write"); + + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/SetOptimistic.java b/tck/src/main/java/org/apache/jdo/tck/transactions/SetOptimistic.java index d5503ef21..bb6b22715 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/SetOptimistic.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/SetOptimistic.java @@ -5,114 +5,126 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Set Optimistic
    - * Keywords: transactions
    - * Assertion ID: A13.4.2-14.
    - * Assertion Description: A call to Transaction.setOptimistic causes the optimistic setting - * passed to replace the optimistic setting currently active, if the Optimistic optional feature is - * supported. + *Title: Set Optimistic + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.2-14. + *
    + *Assertion Description: + A call to Transaction.setOptimistic causes the optimistic setting passed to replace the optimistic setting + currently active, if the Optimistic optional feature is supported. + */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/09/01 1.0 */ public class SetOptimistic extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A13.4.2-14 (SetOptimistic) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetOptimistic.class); - } - - /** */ - public void test() { - pm = getPM(); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.2-14 (SetOptimistic) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetOptimistic.class); + } - runTestSetOptimistic(pm); - runTestSetOptimisticToInverse(pm); + /** */ + public void test() { + pm = getPM(); + + runTestSetOptimistic(pm); + runTestSetOptimisticToInverse(pm); - pm.close(); - pm = null; - } + pm.close(); + pm = null; + } - /** - * @param pm the PersistenceManager - */ - public void runTestSetOptimistic(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - if (isOptimisticSupported()) { - tx.setOptimistic(true); - tx.begin(); - if (!tx.getOptimistic()) { - fail( - ASSERTION_FAILED, "tx.getOptimistic() returns false after setting the flag to true."); + /** + * @param pm the PersistenceManager + */ + public void runTestSetOptimistic(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + if (isOptimisticSupported()) { + tx.setOptimistic(true); + tx.begin(); + if (!tx.getOptimistic()) { + fail(ASSERTION_FAILED, + "tx.getOptimistic() returns false after setting the flag to true."); + } + tx.commit(); + if (!tx.getOptimistic()) { + fail(ASSERTION_FAILED, + "tx.getOptimistic() returns false after setting the flag to true."); + } + } + + tx.setOptimistic(false); + tx.begin(); + if (tx.getOptimistic()) { + fail(ASSERTION_FAILED, + "tx.getOptimistic() returns true after setting the flag to false."); + } + tx.commit(); + if (tx.getOptimistic()) { + fail(ASSERTION_FAILED, + "tx.getOptimistic() returns true after setting the flag to false."); + } } - tx.commit(); - if (!tx.getOptimistic()) { - fail( - ASSERTION_FAILED, "tx.getOptimistic() returns false after setting the flag to true."); + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - - tx.setOptimistic(false); - tx.begin(); - if (tx.getOptimistic()) { - fail(ASSERTION_FAILED, "tx.getOptimistic() returns true after setting the flag to false."); - } - tx.commit(); - if (tx.getOptimistic()) { - fail(ASSERTION_FAILED, "tx.getOptimistic() returns true after setting the flag to false."); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); - } - } - - /** */ - void runTestSetOptimisticToInverse(PersistenceManager pm) { - if (!isOptimisticSupported()) { - if (debug) logger.debug("Optimistic not supported."); - return; } - Transaction tx = pm.currentTransaction(); - boolean orig = tx.getOptimistic(); - tx.setOptimistic(!orig); - if (tx.getOptimistic() == orig) { - fail( - ASSERTION_FAILED, - "changing the optimistic flag by calling tx.setOptimistic does not have a effect."); - } - if ((tx != null) && tx.isActive()) { - tx.rollback(); + /** */ + void runTestSetOptimisticToInverse(PersistenceManager pm) { + if (!isOptimisticSupported()) { + if (debug) logger.debug("Optimistic not supported."); + return; + } + + Transaction tx = pm.currentTransaction(); + boolean orig = tx.getOptimistic(); + tx.setOptimistic(!orig); + if (tx.getOptimistic() == orig) { + fail(ASSERTION_FAILED, + "changing the optimistic flag by calling tx.setOptimistic does not have a effect."); + } + if ((tx != null) && tx.isActive()) { + tx.rollback(); + } } - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/SetOptimisticCalledDuringTxCompletion.java b/tck/src/main/java/org/apache/jdo/tck/transactions/SetOptimisticCalledDuringTxCompletion.java index 4175c9273..6d6ef7d22 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/SetOptimisticCalledDuringTxCompletion.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/SetOptimisticCalledDuringTxCompletion.java @@ -5,128 +5,137 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; import javax.transaction.Synchronization; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Set Optimistic Called During TX Completion
    - * Keywords: transactions
    - * Assertion ID: A13.4.2-3.
    - * Assertion Description: If the setOptimistic method of the Transaction interface is called - * during commit or rollback processing (within the beforeCompletion and afterCompletion - * synchronization methods), a JDOUserException is thrown. + *Title: Set Optimistic Called During TX Completion + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.2-3. + *
    + *Assertion Description: + If the setOptimistic method of the Transaction interface is called during commit or rollback processing (within the + beforeCompletion and afterCompletion synchronization methods), a JDOUserException is thrown. + + */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/20/01 1.0 - * + * */ -public class SetOptimisticCalledDuringTxCompletion extends JDO_Test implements Synchronization { - - private Transaction tx; - - private boolean optimisticFlag; - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.2-3 (SetOptimisticCalledDuringTxCompletion) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetOptimisticCalledDuringTxCompletion.class); - } - - /** */ - public void beforeCompletion() { - if (debug) logger.debug("beforeCompletion"); - try { - tx.setOptimistic(optimisticFlag); - fail( - ASSERTION_FAILED, - "tx.setOptimistic called in beforeCompletion should throw JDOUserException."); - } catch (JDOUserException ex) { - // expected exception - if (debug) logger.debug("caught expected exception " + ex); - } catch (Exception ex) { - fail( - ASSERTION_FAILED, - "tx.setOptimistic called in beforeCompletion throws unexpected exception: " + ex); +public class SetOptimisticCalledDuringTxCompletion + extends JDO_Test + implements Synchronization { + + private Transaction tx; + + private boolean optimisticFlag; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.2-3 (SetOptimisticCalledDuringTxCompletion) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetOptimisticCalledDuringTxCompletion.class); + } + + /** */ + public void beforeCompletion(){ + if (debug) logger.debug ("beforeCompletion"); + try { + tx.setOptimistic(optimisticFlag); + fail(ASSERTION_FAILED, + "tx.setOptimistic called in beforeCompletion should throw JDOUserException."); + } + catch (JDOUserException ex) { + // expected exception + if (debug) logger.debug("caught expected exception " + ex); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.setOptimistic called in beforeCompletion throws unexpected exception: " + ex); + } } - } - - /** - * This method is called by the transaction manager after the transaction is committed or rolled - * back. - * - * @param status The status of the transaction completion. - */ - public void afterCompletion(int status) { - if (debug) logger.debug("afterCompletion"); - try { - tx.setOptimistic(optimisticFlag); - } catch (Exception ex) { - fail( - ASSERTION_FAILED, - "tx.setOptimistic called in afterCompletion throws unexpected exception: " + ex); + + /** + * This method is called by the transaction manager after the transaction is committed or rolled back. + * @param status The status of the transaction completion. + */ + public void afterCompletion(int status) { + if (debug) logger.debug("afterCompletion"); + try { + tx.setOptimistic(optimisticFlag); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.setOptimistic called in afterCompletion throws unexpected exception: " + ex); + } } - } - - /** */ - public void test() { - pm = getPM(); - - runTestSetOptimisticCalledDuringTxCompletion(pm); - - pm.close(); - pm = null; - } - - /** - * test transactions.setOptimistic() - * - * @param pm the PersistenceManager - */ - void runTestSetOptimisticCalledDuringTxCompletion(PersistenceManager pm) { - tx = pm.currentTransaction(); - try { - tx.setSynchronization(this); - - optimisticFlag = false; - tx.begin(); - tx.commit(); - - if (isOptimisticSupported()) { - optimisticFlag = true; - tx.begin(); - tx.commit(); - } - - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + + /** */ + public void test() { + pm = getPM(); + + runTestSetOptimisticCalledDuringTxCompletion(pm); + + pm.close(); + pm = null; + } + + /** + * test transactions.setOptimistic() + * @param pm the PersistenceManager + */ + void runTestSetOptimisticCalledDuringTxCompletion(PersistenceManager pm) { + tx = pm.currentTransaction(); + try { + tx.setSynchronization(this); + + optimisticFlag = false; + tx.begin(); + tx.commit(); + + if (isOptimisticSupported()) { + optimisticFlag = true; + tx.begin(); + tx.commit(); + } + + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/SetOptimisticDuringTransaction.java b/tck/src/main/java/org/apache/jdo/tck/transactions/SetOptimisticDuringTransaction.java index d0a526553..e38d5384f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/SetOptimisticDuringTransaction.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/SetOptimisticDuringTransaction.java @@ -5,96 +5,107 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Set Optimistic During Transaction
    - * Keywords: transactions
    - * Assertion ID: A13.4.2-15.
    - * Assertion Description: If Transaction.setOptimistic is called while there is an active - * transaction, a JDOUserException is thrown. + *Title: Set Optimistic During Transaction + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.2-15. + *
    + *Assertion Description: + If Transaction.setOptimistic is called while there is an active transaction, a JDOUserException is thrown. + + */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/09/01 1.0 */ public class SetOptimisticDuringTransaction extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.2-15 (SetOptimisticDuringTransaction) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetOptimisticDuringTransaction.class); + } - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.2-15 (SetOptimisticDuringTransaction) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetOptimisticDuringTransaction.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTestSetOptimisticDuringTransaction(pm); + /** */ + public void test() { + pm = getPM(); + + runTestSetOptimisticDuringTransaction(pm); - pm.close(); - pm = null; - } + pm.close(); + pm = null; + } - /** - * @param pm the PersistenceManager - */ - void runTestSetOptimisticDuringTransaction(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - // try to call tx.setOptimistic(true) - if (isOptimisticSupported()) { + /** + * + * @param pm the PersistenceManager + */ + void runTestSetOptimisticDuringTransaction(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); try { - tx.setOptimistic(true); - fail( - ASSERTION_FAILED, - "calling tx.setOptimistic in the context of an active transaction should throw a JDOUserException."); - } catch (JDOUserException ex) { - // expected exception - if (debug) logger.debug("caught expected exception " + ex); + tx.begin(); + // try to call tx.setOptimistic(true) + if (isOptimisticSupported()) { + try { + tx.setOptimistic(true); + fail(ASSERTION_FAILED, + "calling tx.setOptimistic in the context of an active transaction should throw a JDOUserException."); + } + catch (JDOUserException ex) { + // expected exception + if (debug) logger.debug("caught expected exception " + ex); + } + } + // try to call tx.setOptimistic(false) + try { + tx.setOptimistic(false); + fail(ASSERTION_FAILED, + "calling tx.setOptimistic in the context of an active transaction should throw a JDOUserException."); + } + catch (JDOUserException ex) { + // expected exception + if (debug) logger.debug("caught expected exception " + ex); + } + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); } - } - // try to call tx.setOptimistic(false) - try { - tx.setOptimistic(false); - fail( - ASSERTION_FAILED, - "calling tx.setOptimistic in the context of an active transaction should throw a JDOUserException."); - } catch (JDOUserException ex) { - // expected exception - if (debug) logger.debug("caught expected exception " + ex); - } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/SetOptimisticTrueWhenNotSupported.java b/tck/src/main/java/org/apache/jdo/tck/transactions/SetOptimisticTrueWhenNotSupported.java index 05697c961..9eea9f3a5 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/SetOptimisticTrueWhenNotSupported.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/SetOptimisticTrueWhenNotSupported.java @@ -5,81 +5,90 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.JDOUnsupportedOptionException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Set Optimistic True When Not Supported
    - * Keywords: transactions
    - * Assertion ID: A13.4.2-7.
    - * Assertion Description: If the optional feature Optimistic is not supported, then a call - * to Transaction.setOptimistic with a value of true will throw a JDOUnsupportedOptionException. + *Title: Set Optimistic True When Not Supported + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.2-7. + *
    + *Assertion Description: + If the optional feature Optimistic is not supported, then a call to Transaction.setOptimistic with a value of true will + throw a JDOUnsupportedOptionException. + */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/18/01 1.0 */ public class SetOptimisticTrueWhenNotSupported extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.2-7 (SetOptimisticTrueWhenNotSupported) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetOptimisticTrueWhenNotSupported.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTestSetOptimisticTrueWhenNotSupported(pm); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.2-7 (SetOptimisticTrueWhenNotSupported) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetOptimisticTrueWhenNotSupported.class); + } - pm.close(); - pm = null; - } + /** */ + public void test() { + pm = getPM(); + + runTestSetOptimisticTrueWhenNotSupported(pm); - /** - * @param pm the PersistenceManager - */ - void runTestSetOptimisticTrueWhenNotSupported(PersistenceManager pm) { - if (isOptimisticSupported()) { - if (debug) logger.debug("Optimistic supported."); - return; + pm.close(); + pm = null; } - Transaction tx = pm.currentTransaction(); - try { - tx.setOptimistic(true); - fail( - ASSERTION_FAILED, - "tx.setOptimistic(true) should throw JDOUnsupportedOptionException, if the implementation does not support optimistic transactions."); - } catch (JDOUnsupportedOptionException ex) { - // expected excepted - if (debug) logger.debug("caught expected exception " + ex); + /** + * + * @param pm the PersistenceManager + */ + void runTestSetOptimisticTrueWhenNotSupported(PersistenceManager pm) { + if (isOptimisticSupported()) { + if (debug) logger.debug("Optimistic supported."); + return; + } + + Transaction tx = pm.currentTransaction(); + try { + tx.setOptimistic(true); + fail(ASSERTION_FAILED, + "tx.setOptimistic(true) should throw JDOUnsupportedOptionException, if the implementation does not support optimistic transactions."); + } + catch (JDOUnsupportedOptionException ex) { + // expected excepted + if (debug) logger.debug("caught expected exception " + ex); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/SetRetainValues.java b/tck/src/main/java/org/apache/jdo/tck/transactions/SetRetainValues.java index 703cfbcf7..64f864d42 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/SetRetainValues.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/SetRetainValues.java @@ -5,80 +5,89 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Set Retain Values
    - * Keywords: transactions
    - * Assertion ID: A13.4.2-18.
    - * Assertion Description: The retainValues setting passed to setRetainValues replaces the - * retainValues setting currently active. + *Title: Set Retain Values + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.2-18. + *
    + *Assertion Description: + The retainValues setting passed to setRetainValues replaces + the retainValues setting currently active. */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/09/01 1.0 */ public class SetRetainValues extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = "Assertion A13.4.2-18 (SetRetainValues) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetRetainValues.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTestSetRetainValues(pm); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.2-18 (SetRetainValues) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetRetainValues.class); + } - pm.close(); - pm = null; - } + /** */ + public void test() { + pm = getPM(); + + runTestSetRetainValues(pm); - /** - * @param pm the PersistenceManager - */ - void runTestSetRetainValues(PersistenceManager pm) { - if (!isRetainValuesSupported()) { - if (debug) logger.debug("RetainValues not supported."); - return; + pm.close(); + pm = null; } - Transaction tx = pm.currentTransaction(); - boolean orig = tx.getRetainValues(); - tx.setRetainValues(!orig); - if (tx.getRetainValues() == orig) { - fail( - ASSERTION_FAILED, - "changing the retainValues flag by calling tx.setRetainValues does not have a effect."); + /** + * + * @param pm the PersistenceManager + */ + void runTestSetRetainValues(PersistenceManager pm) { + if (!isRetainValuesSupported()) { + if (debug) logger.debug("RetainValues not supported."); + return; + } + + Transaction tx = pm.currentTransaction(); + boolean orig = tx.getRetainValues(); + tx.setRetainValues(!orig); + if (tx.getRetainValues() == orig) { + fail(ASSERTION_FAILED, + "changing the retainValues flag by calling tx.setRetainValues does not have a effect."); + } + if ((tx != null) && tx.isActive()) { + tx.rollback(); + } } - if ((tx != null) && tx.isActive()) { - tx.rollback(); - } - } } + diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/SetRetainValuesCalledDuringTxCompletion.java b/tck/src/main/java/org/apache/jdo/tck/transactions/SetRetainValuesCalledDuringTxCompletion.java index ccec3d31d..7f02f865a 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/SetRetainValuesCalledDuringTxCompletion.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/SetRetainValuesCalledDuringTxCompletion.java @@ -5,129 +5,140 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.JDOUserException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; import javax.transaction.Synchronization; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Set Optimistic Called During TX Completion
    - * Keywords: transactions
    - * Assertion ID: A13.4.2-4.
    - * Assertion Description: If the setOptimistic method of the Transaction interface is called - * during commit or rollback processing (within the beforeCompletion and afterCompletion - * synchronization methods), a JDOUserException is thrown. + *Title: Set Optimistic Called During TX Completion + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.2-4. + *
    + *Assertion Description: + If the setOptimistic method of the Transaction interface is called during + * commit or rollback processing (within the beforeCompletion and + * afterCompletion synchronization methods), a JDOUserException is thrown. */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/20/01 1.0 */ -public class SetRetainValuesCalledDuringTxCompletion extends JDO_Test implements Synchronization { - - private Transaction tx; - - private boolean retainValuesFlag; - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.2-4 (SetRetainValuesCalledDuringTxCompletion) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetRetainValuesCalledDuringTxCompletion.class); - } - - /** */ - public void beforeCompletion() { - if (debug) logger.debug("beforeCompletion"); - try { - tx.setRetainValues(retainValuesFlag); - fail( - ASSERTION_FAILED, - "tx.setRetainValues called in beforeCompletion should throw JDOUserException."); - } catch (JDOUserException ex) { - // expected exception - if (debug) logger.debug("caught expected exception " + ex); - } catch (Exception ex) { - fail( - ASSERTION_FAILED, - "tx.setRetainValues called in beforeCompletion throws unexpected exception: " + ex); +public class SetRetainValuesCalledDuringTxCompletion + extends JDO_Test + implements Synchronization { + + private Transaction tx; + + private boolean retainValuesFlag; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.2-4 (SetRetainValuesCalledDuringTxCompletion) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetRetainValuesCalledDuringTxCompletion.class); } - } - /** - * This method is called by the transaction manager after the transaction is committed or rolled - * back. - * - * @param status The status of the transaction completion. - */ - public void afterCompletion(int status) { - if (debug) logger.debug("afterCompletion"); - try { - tx.setRetainValues(retainValuesFlag); - } catch (JDOUserException ex) { - // TBD: need to remove this catch block as soon as the JDORI is - // fixed see 'Issue 61: Transaction.isActive issues' - if (debug) logger.debug("caught exception " + ex); - } catch (Exception ex) { - fail( - ASSERTION_FAILED, - "tx.setRetainValues called in afterCompletion throws unexpected exception: " + ex); + /** */ + public void beforeCompletion(){ + if (debug) logger.debug ("beforeCompletion"); + try { + tx.setRetainValues(retainValuesFlag); + fail(ASSERTION_FAILED, + "tx.setRetainValues called in beforeCompletion should throw JDOUserException."); + } + catch (JDOUserException ex) { + // expected exception + if (debug) logger.debug("caught expected exception " + ex); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.setRetainValues called in beforeCompletion throws unexpected exception: " + ex); + } } - } - - /** */ - public void test() { - pm = getPM(); - - runTestSetRetainValuesCalledDuringTxCompletion(pm); - - pm.close(); - pm = null; - } - /** - * @param pm the PersistenceManager - */ - void runTestSetRetainValuesCalledDuringTxCompletion(PersistenceManager pm) { - tx = pm.currentTransaction(); - try { - tx.setSynchronization(this); - - retainValuesFlag = false; - tx.begin(); - tx.commit(); - - if (isRetainValuesSupported()) { - retainValuesFlag = true; - tx.begin(); - tx.commit(); - } + /** + * This method is called by the transaction manager after the transaction is committed or rolled back. + * @param status The status of the transaction completion. + */ + public void afterCompletion(int status) { + if (debug) logger.debug ("afterCompletion"); + try { + tx.setRetainValues(retainValuesFlag); + } + catch (JDOUserException ex) { + // TBD: need to remove this catch block as soon as the JDORI is + // fixed see 'Issue 61: Transaction.isActive issues' + if (debug) logger.debug("caught exception " + ex); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.setRetainValues called in afterCompletion throws unexpected exception: " + ex); + } + } + + /** */ + public void test() { + pm = getPM(); + + runTestSetRetainValuesCalledDuringTxCompletion(pm); + + pm.close(); + pm = null; + } - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + /** + * + * @param pm the PersistenceManager + */ + void runTestSetRetainValuesCalledDuringTxCompletion(PersistenceManager pm) { + tx = pm.currentTransaction(); + try { + tx.setSynchronization(this); + + retainValuesFlag = false; + tx.begin(); + tx.commit(); + + if (isRetainValuesSupported()) { + retainValuesFlag = true; + tx.begin(); + tx.commit(); + } + + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/SetRetainValuesTrueWhenNotSupported.java b/tck/src/main/java/org/apache/jdo/tck/transactions/SetRetainValuesTrueWhenNotSupported.java index 20404bcb0..339e3419e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/SetRetainValuesTrueWhenNotSupported.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/SetRetainValuesTrueWhenNotSupported.java @@ -5,84 +5,90 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.JDOUnsupportedOptionException; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Set Retain Values True When Not Supported
    - * Keywords: transactions
    - * Assertion ID: A13.4.2-8.
    - * Assertion Description: If the optional feature RetainValues is not supported, then a call - * to Transaction.setRetainValues with a value of true will cause a JDOUnsupportedOptionException to - * be thrown. + *Title: Set Retain Values True When Not Supported + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.2-8. + *
    + *Assertion Description: + If the optional feature RetainValues is not supported, then a call to Transaction.setRetainValues with a + value of true will cause a JDOUnsupportedOptionException to be thrown. + */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/22/01 1.0 */ public class SetRetainValuesTrueWhenNotSupported extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.2-8 (SetRetainValuesTrueWhenNotSupported) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetRetainValuesTrueWhenNotSupported.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTestSetRetainValuesTrueWhenNotSupported(pm); - - pm.close(); - pm = null; - } + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.2-8 (SetRetainValuesTrueWhenNotSupported) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetRetainValuesTrueWhenNotSupported.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTestSetRetainValuesTrueWhenNotSupported(pm); - /** - * test transactions.setRetainValues() - * - * @param pm the PersistenceManager - */ - void runTestSetRetainValuesTrueWhenNotSupported(PersistenceManager pm) { - if (isRetainValuesSupported()) { - if (debug) logger.debug("RetainValues supported."); - return; + pm.close(); + pm = null; } + + /** + * test transactions.setRetainValues() + * @param pm the PersistenceManager + */ + void runTestSetRetainValuesTrueWhenNotSupported(PersistenceManager pm) { + if (isRetainValuesSupported()) { + if (debug) logger.debug("RetainValues supported."); + return; + } - Transaction tx = pm.currentTransaction(); - try { - tx.setRetainValues(true); - fail( - ASSERTION_FAILED, - "tx.setRetainValues(true) should throw JDOUnsupportedOptionException, if the implementation does not support retainValues."); - } catch (JDOUnsupportedOptionException ex) { - // expected excepted - if (debug) logger.debug("caught expected exception " + ex); + Transaction tx = pm.currentTransaction(); + try { + tx.setRetainValues(true); + fail(ASSERTION_FAILED, + "tx.setRetainValues(true) should throw JDOUnsupportedOptionException, if the implementation does not support retainValues."); + } + catch (JDOUnsupportedOptionException ex) { + // expected excepted + if (debug) logger.debug("caught expected exception " + ex); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/SetSynchronization.java b/tck/src/main/java/org/apache/jdo/tck/transactions/SetSynchronization.java index 90a90821f..45b62b31f 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/SetSynchronization.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/SetSynchronization.java @@ -5,118 +5,128 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; import javax.transaction.Synchronization; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Set Synchronization
    - * Keywords: transactions
    - * Assertion ID: A13.4.3-1.
    - * Assertion Description: A call to Transaction.setSynchronization registers a - * Synchronization instance with the Transaction for transaction completion notifications. Any - * Synchronization instance already registered will be replaced. + *Title: Set Synchronization + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.3-1. + *
    + *Assertion Description: + A call to Transaction.setSynchronization registers a Synchronization instance with the + Transaction for transaction completion notifications. Any Synchronization instance already registered will be replaced. */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/11/01 1.0 */ public class SetSynchronization extends JDO_Test implements Synchronization { + + private Transaction tx; - private Transaction tx; - - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.3-1 (SetSynchronization) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetSynchronization.class); - } - - /** */ - public void beforeCompletion() { - try { - if (debug) logger.debug("before Complition isActive returns :" + tx.isActive()); - } catch (Exception ex) { - fail( - ASSERTION_FAILED, - "tx.isActive called in beforeCompletion throws unexpected exception: " + ex); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.3-1 (SetSynchronization) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetSynchronization.class); } - } - - /** - * This method is called by the transaction manager after the transaction is committed or rolled - * back. - * - * @param status The status of the transaction completion. - */ - public void afterCompletion(int status) { - try { - if (debug) logger.debug("after Complition isActive returns :" + tx.isActive()); - } catch (Exception ex) { - fail( - ASSERTION_FAILED, - "tx.isActive called in afterCompletion throws unexpected exception: " + ex); + + /** */ + public void beforeCompletion(){ + try { + if (debug) + logger.debug("before Complition isActive returns :" + + tx.isActive()); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.isActive called in beforeCompletion throws unexpected exception: " + ex); + } + } - } - /** */ - public void test() { - pm = getPM(); + /** + * This method is called by the transaction manager after the transaction is committed or rolled back. + * @param status The status of the transaction completion. + */ + public void afterCompletion(int status) { + try { + if (debug) + logger.debug("after Complition isActive returns :" + + tx.isActive()); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.isActive called in afterCompletion throws unexpected exception: " + ex); + } + } - runTestSetSynchronization(pm); + /** */ + public void test() { + pm = getPM(); + + runTestSetSynchronization(pm); - pm.close(); - pm = null; - } + pm.close(); + pm = null; + } - /** - * @param pm the PersistenceManager - */ - void runTestSetSynchronization(PersistenceManager pm) { - tx = pm.currentTransaction(); - try { - tx.begin(); - Synchronization orig = tx.getSynchronization(); - tx.setSynchronization(this); - Synchronization current = tx.getSynchronization(); - if (current == orig) { - fail( - ASSERTION_FAILED, - "tx.setSynchronization does not replace Synchronization instances registered with the transaction."); - } - if (current != this) { - fail( - ASSERTION_FAILED, - "unexpected sxnchronization isntance, expected " + this + ", got " + current); - } + /** + * + * @param pm the PersistenceManager + */ + void runTestSetSynchronization(PersistenceManager pm) { + tx = pm.currentTransaction(); + try { + tx.begin(); + Synchronization orig = tx.getSynchronization(); + tx.setSynchronization(this); + Synchronization current = tx.getSynchronization(); + if (current == orig) { + fail(ASSERTION_FAILED, + "tx.setSynchronization does not replace Synchronization instances registered with the transaction."); + } + if (current != this) { + fail(ASSERTION_FAILED, + "unexpected sxnchronization isntance, expected " + this + ", got " + current); + } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/SetSynchronizationToNull.java b/tck/src/main/java/org/apache/jdo/tck/transactions/SetSynchronizationToNull.java index be4776f65..5932727f0 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/SetSynchronizationToNull.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/SetSynchronizationToNull.java @@ -5,101 +5,107 @@ * 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 + * + * 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.jdo.tck.transactions; import javax.jdo.PersistenceManager; import javax.jdo.Transaction; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: Set Synchronization To Null
    - * Keywords: transactions
    - * Assertion ID: A13.4.3-2.
    - * Assertion Description: If the parameter to Transaction.setSynchronization is null, then - * no instance will be notified. + *Title: Set Synchronization To Null + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.3-2. + *
    + *Assertion Description: + If the parameter to Transaction.setSynchronization is null, then no instance + will be notified. */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Azita Kamangar 10/11/01 1.0 */ -public class SetSynchronizationToNull extends JDO_Test +public class SetSynchronizationToNull + extends JDO_Test implements javax.transaction.Synchronization { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.3-2 (SetSynchronizationToNull) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(SetSynchronizationToNull.class); + } - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.3-2 (SetSynchronizationToNull) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(SetSynchronizationToNull.class); - } - - /** */ - public void beforeCompletion() { - fail( - ASSERTION_FAILED, - "Instance should not be registered, thus this beforeCompletion methgod should not be called."); - } - - /** - * This method is called by the transaction manager after the transaction is committed or rolled - * back. - * - * @param status The status of the transaction completion. - */ - public void afterCompletion(int status) { - fail( - ASSERTION_FAILED, - "Instance should not be registered, thus this afterCompletion methgod should not be called."); - } - - /** */ - public void test() { - pm = getPM(); + /** */ + public void beforeCompletion(){ + fail(ASSERTION_FAILED, + "Instance should not be registered, thus this beforeCompletion methgod should not be called."); + } - runTestSetSynchronizationToNull(pm); + /** + * This method is called by the transaction manager after the transaction is committed or rolled back. + * @param status The status of the transaction completion. + */ + public void afterCompletion(int status) { + fail(ASSERTION_FAILED, + "Instance should not be registered, thus this afterCompletion methgod should not be called."); + } + + /** */ + public void test() { + pm = getPM(); + + runTestSetSynchronizationToNull(pm); - pm.close(); - pm = null; - } + pm.close(); + pm = null; + } - /** - * @param pm the PersistenceManager - */ - void runTestSetSynchronizationToNull(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.begin(); - tx.setSynchronization(this); - tx.setSynchronization(null); - if (tx.getSynchronization() != null) { - fail( - ASSERTION_FAILED, - "tx.setSynchronization(null) should overwrite previous registered synchronization instance."); - } + /** + * + * @param pm the PersistenceManager + */ + void runTestSetSynchronizationToNull(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.begin(); + tx.setSynchronization(this); + tx.setSynchronization(null); + if (tx.getSynchronization() != null) { + fail(ASSERTION_FAILED, + "tx.setSynchronization(null) should overwrite previous registered synchronization instance."); + } - tx.commit(); - tx = null; - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + tx.commit(); + tx = null; + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/transactions/WhenNontransactionalReadIsFalse.java b/tck/src/main/java/org/apache/jdo/tck/transactions/WhenNontransactionalReadIsFalse.java index c235052d9..fc6585413 100644 --- a/tck/src/main/java/org/apache/jdo/tck/transactions/WhenNontransactionalReadIsFalse.java +++ b/tck/src/main/java/org/apache/jdo/tck/transactions/WhenNontransactionalReadIsFalse.java @@ -5,139 +5,149 @@ * 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 + * + * 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.jdo.tck.transactions; import java.util.Collection; import java.util.Date; -import javax.jdo.JDOUserException; + import javax.jdo.PersistenceManager; import javax.jdo.Query; import javax.jdo.Transaction; +import javax.jdo.JDOUserException; + import org.apache.jdo.tck.JDO_Test; import org.apache.jdo.tck.pc.company.Company; import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.util.BatchTestRunner; + /** - * Title: When Nontransactional Read Is False
    - * Keywords: transactions
    - * Assertion ID: A13.4.2-10.
    - * Assertion Description: If this flag is set to false, then queries and field read access - * (including navigation) outside an active transaction throw a JDOUserException. + *Title: When Nontransactional Read Is False + *
    + *Keywords: transactions + *
    + *Assertion ID: A13.4.2-10. + *
    + *Assertion Description: + If this flag is set to false, then queries and field read access + (including navigation) outside an active transaction + throw a JDOUserException. */ + /* * Revision History * ================ - * Author : Date : Version + * Author : Date : Version * Michelle Caisse 11/11/04 1.0 */ public class WhenNontransactionalReadIsFalse extends JDO_Test { - /** */ - private static final String ASSERTION_FAILED = - "Assertion A13.4.2-10 (WhenNontransactionalReadIsFalse) failed: "; - - /** - * The main is called when the class is directly executed from the command line. - * - * @param args The arguments passed to the program. - */ - public static void main(String[] args) { - BatchTestRunner.run(WhenNontransactionalReadIsFalse.class); - } - - /** - * @see org.apache.jdo.tck.JDO_Test#localSetUp() - */ - @Override - protected void localSetUp() { - addTearDownClass(Department.class); - addTearDownClass(Company.class); - } - - /** */ - public void test() { - pm = getPM(); - - runTestWhenNontransactionalReadIsFalse(pm); + /** */ + private static final String ASSERTION_FAILED = + "Assertion A13.4.2-10 (WhenNontransactionalReadIsFalse) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(WhenNontransactionalReadIsFalse.class); + } - pm.close(); - pm = null; - } + /** + * @see org.apache.jdo.tck.JDO_Test#localSetUp() + */ + @Override + protected void localSetUp() { + addTearDownClass(Department.class); + addTearDownClass(Company.class); + } + + /** */ + public void test() { + pm = getPM(); + + runTestWhenNontransactionalReadIsFalse(pm); - /** - * @param pm the PersistenceManager - */ - public void runTestWhenNontransactionalReadIsFalse(PersistenceManager pm) { - Transaction tx = pm.currentTransaction(); - try { - tx.setNontransactionalRead(false); - tx.begin(); - Company c = new Company(1L, "MyCompany", new Date(), null); - Department d = new Department(999, "MyDepartment", c); + pm.close(); + pm = null; + } - pm.makePersistent(c); - pm.makePersistent(d); - if (tx.getNontransactionalRead()) { - fail( - ASSERTION_FAILED, - "tx.getNontransactionalRead before commit returns true after setting the flag to false."); - } - tx.commit(); - if (tx.getNontransactionalRead()) { - fail( - ASSERTION_FAILED, - "tx.getNontransactionalRead after commit returns true after setting the flag to false."); - } + /** + * @param pm the PersistenceManager + */ + public void runTestWhenNontransactionalReadIsFalse(PersistenceManager pm) { + Transaction tx = pm.currentTransaction(); + try { + tx.setNontransactionalRead(false); + tx.begin(); + Company c = new Company(1L, "MyCompany", new Date(), null); + Department d = new Department(999, "MyDepartment", c); + + pm.makePersistent(c); + pm.makePersistent(d); + if (tx.getNontransactionalRead()) { + fail(ASSERTION_FAILED, + "tx.getNontransactionalRead before commit returns true after setting the flag to false."); + } + tx.commit(); + if (tx.getNontransactionalRead()) { + fail(ASSERTION_FAILED, + "tx.getNontransactionalRead after commit returns true after setting the flag to false."); + } - // make sure transaction is not active - if (tx.isActive()) { - fail(ASSERTION_FAILED, "transaction still active after tx.commit."); - } - tx = null; + // make sure transaction is not active + if (tx.isActive()) { + fail(ASSERTION_FAILED, + "transaction still active after tx.commit."); + } + tx = null; - try { - // read department name - String name = d.getName(); - fail( - ASSERTION_FAILED, - "Field read permitted outside an active transaction when NontransactionalRead is false."); - } catch (JDOUserException juex) { - if (debug) logger.debug(" Caught expected JDOUserException " + juex); - } - try { - // navigate from department to company - c = (Company) d.getCompany(); - fail( - ASSERTION_FAILED, - "Navigation permitted outside an active transaction when NontransactionalRead is false."); - } catch (JDOUserException juex) { - if (debug) logger.debug(" Caught expected JDOUserException " + juex); - } - try { - // run query - Query q = pm.newQuery(Department.class); - q.setFilter("name == \"MyDepartment\""); - Collection result = (Collection) q.execute(); - fail( - ASSERTION_FAILED, - "Query permitted outside an active transaction when NontransactionalRead is false."); - } catch (JDOUserException juex) { - if (debug) logger.debug(" Caught expected JDOUserException " + juex); - } - } finally { - if ((tx != null) && tx.isActive()) tx.rollback(); + try { + // read department name + String name = d.getName(); + fail(ASSERTION_FAILED, + "Field read permitted outside an active transaction when NontransactionalRead is false."); + } catch (JDOUserException juex) { + if (debug) + logger.debug(" Caught expected JDOUserException " + juex); + } + try { + // navigate from department to company + c = (Company)d.getCompany(); + fail(ASSERTION_FAILED, + "Navigation permitted outside an active transaction when NontransactionalRead is false."); + } catch (JDOUserException juex) { + if (debug) + logger.debug(" Caught expected JDOUserException " + juex); + } + try { + // run query + Query q = pm.newQuery(Department.class); + q.setFilter("name == \"MyDepartment\""); + Collection result = (Collection)q.execute(); + fail(ASSERTION_FAILED, + "Query permitted outside an active transaction when NontransactionalRead is false."); + } catch (JDOUserException juex) { + if (debug) + logger.debug(" Caught expected JDOUserException " + juex); + } + } + finally { + if ((tx != null) && tx.isActive()) + tx.rollback(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/util/BatchResultPrinter.java b/tck/src/main/java/org/apache/jdo/tck/util/BatchResultPrinter.java index 3c7c209b4..574e482bf 100644 --- a/tck/src/main/java/org/apache/jdo/tck/util/BatchResultPrinter.java +++ b/tck/src/main/java/org/apache/jdo/tck/util/BatchResultPrinter.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -23,6 +23,7 @@ import java.util.Enumeration; import java.util.HashMap; import java.util.Map; + import junit.framework.AssertionFailedError; import junit.framework.Test; import junit.framework.TestCase; @@ -32,222 +33,224 @@ /** * Default result printer implementation for running tests in batch mode. - * + * * @author Michael Bouschen */ -public class BatchResultPrinter extends ResultPrinter { - private static final DecimalFormat THREE_DIGITS_FORMATTER = new DecimalFormat("000"); - - /** The stream to delegate the output. */ - private ConsoleFileOutput consoleFileOutput; - - /** The time elapsed to run a test suite. */ - private long runtime; - - /** - * @param consoleFileOutput console file output - */ - public BatchResultPrinter(ConsoleFileOutput consoleFileOutput) { - this(new PrintStream(consoleFileOutput)); - this.consoleFileOutput = consoleFileOutput; - } - - /** - * @param writer the writer - */ - public BatchResultPrinter(PrintStream writer) { - super(writer); - } - - /** Called in case of a test error. */ - public void addError(Test test, Throwable t) { - getWriter().print(" ERROR"); - } - - /** Called in case of a test failure. */ - public void addFailure(Test test, AssertionFailedError t) { - getWriter().print(" FAILURE"); - } - - /** Called when a test case is finished. */ - public void endTest(Test test) { - getWriter().println(); - } +public class BatchResultPrinter + extends ResultPrinter +{ + private static final DecimalFormat THREE_DIGITS_FORMATTER = new DecimalFormat("000"); - /** Called when a test case is started. */ - public void startTest(Test test) { - String testName; - if (test instanceof TestCase) { - testName = getClassBaseName(test) + "." + ((TestCase) test).getName(); - } else { - testName = test.toString(); - } - getWriter().print("RUN " + testName + '\t'); - getWriter().flush(); - } - - /** - * @see ResultPrinter#elapsedTimeAsString(long) - */ - protected String elapsedTimeAsString(long runTime) { - return THREE_DIGITS_FORMATTER.format((double) runTime / 1000); - } - - /** */ - protected void printHeader(long runTime) { - this.runtime = runTime; - getWriter().println("Description: " + System.getProperty("jdo.tck.description")); - getWriter().println("Time: " + elapsedTimeAsString(runTime)); - } - - /** */ - protected void printFooter(TestResult result) { - String message = null; - if (this.consoleFileOutput != null) { - message = getResultMessage(result, this.consoleFileOutput); - String directory = this.consoleFileOutput.getDirectory(); - ResultSummary.appendTCKResultMessage(directory, message); - ResultSummary.save(directory, result); - } else { - message = getResultMessage(result); + /** The stream to delegate the output. */ + private ConsoleFileOutput consoleFileOutput; + + /** The time elapsed to run a test suite. */ + private long runtime; + + /** + * + * @param consoleFileOutput console file output + */ + public BatchResultPrinter(ConsoleFileOutput consoleFileOutput) { + this(new PrintStream(consoleFileOutput)); + this.consoleFileOutput = consoleFileOutput; } - if (!result.wasSuccessful()) { - getWriter().println("FAILURES!!!"); - printErrorSummary(result); + /** + * + * @param writer the writer + */ + public BatchResultPrinter(PrintStream writer) { + super(writer); } - - getWriter().println(message); - getWriter().println("Excluded tests: " + System.getProperty("jdo.tck.exclude")); - } - - // helper method - - /** - * Returns the result message for the given result instance and the given console file output - * instance. - * - * @param result the result instance - * @param consoleFileOutput the console file output instance - * @return the result message - */ - private String getResultMessage(TestResult result, ConsoleFileOutput consoleFileOutput) { - String message = this.consoleFileOutput.getFileName() + ':'; - message += System.getProperty("line.separator") + " "; - message += getResultMessage(result); - return message; - } - - /** - * Returns the result message for the given result instance. - * - * @param result the result instance - * @return the result message - */ - private String getResultMessage(TestResult result) { - boolean success = result.wasSuccessful(); - String message = success ? "OK " : "** "; - message += - "Tests run: " - + THREE_DIGITS_FORMATTER.format(result.runCount()) - + ", Time: " - + elapsedTimeAsString(this.runtime) - + " seconds."; - if (!success) { - message += " Failures: " + result.failureCount() + ", Errors: " + result.errorCount(); - } - return message; - } - - /** - * @return Name of the class of the given object without package prefix - */ - private String getClassBaseName(Object obj) { - if (obj == null) return null; - String className = obj.getClass().getName(); - int index = className.lastIndexOf('.'); - if (index != -1) { - className = className.substring(index + 1); - } - return className; - } - - private void printErrorSummary(TestResult result) { - Object[] array = getSortedArrayOfErrorSummaryEntries(result); - if (array.length > 0) { - getWriter().println("Error summary:"); - for (int i = 0; i < array.length; i++) { - getWriter().println(array[i]); - } - } - } - - private static Object[] getSortedArrayOfErrorSummaryEntries(TestResult result) { - Map map = new HashMap(); - for (Enumeration e = result.errors(); e.hasMoreElements(); ) { - TestFailure testFailure = (TestFailure) e.nextElement(); - Throwable t = testFailure.thrownException(); - String message = getRootCause(t).toString(); - ErrorSummaryEntry errorSummaryEntry = (ErrorSummaryEntry) map.get(message); - if (errorSummaryEntry == null) { - errorSummaryEntry = new ErrorSummaryEntry(t); - map.put(message, errorSummaryEntry); - } - errorSummaryEntry.count++; + + /** Called in case of a test error. */ + public void addError(Test test, Throwable t) { + getWriter().print(" ERROR"); } - - Object[] array = map.values().toArray(); - Arrays.sort(array); - return array; - } - - private static Throwable getRootCause(Throwable t) { - while (t.getCause() != null) { - t = t.getCause(); + + /** Called in case of a test failure. */ + public void addFailure(Test test, AssertionFailedError t) { + getWriter().print(" FAILURE"); } - return t; - } - - private static class ErrorSummaryEntry implements Comparable { - private int count = 0; - private Throwable t; - - private ErrorSummaryEntry(Throwable t) { - this.t = t; + + /** Called when a test case is finished. */ + public void endTest(Test test) { + getWriter().println(); } - - public boolean equals(Object o) { - return compareTo(o) == 0; + + /** Called when a test case is started. */ + public void startTest(Test test) { + String testName; + if (test instanceof TestCase) { + testName = getClassBaseName(test) + "." + ((TestCase)test).getName(); + } + else { + testName = test.toString(); + } + getWriter().print("RUN " + testName + '\t'); + getWriter().flush(); } - - public int hashCode() { - return this.count; + + /** + * @see ResultPrinter#elapsedTimeAsString(long) + */ + protected String elapsedTimeAsString(long runTime) { + return THREE_DIGITS_FORMATTER.format((double)runTime/1000); } - public int compareTo(Object o) { - int result = this.count - ((ErrorSummaryEntry) o).count; - if (result == 0) { - String message1 = getRootCause().toString(); - String message2 = ((ErrorSummaryEntry) o).getRootCause().toString(); - result = message1.compareTo(message2); - } - return result; + /** */ + protected void printHeader(long runTime) { + this.runtime = runTime; + getWriter().println("Description: " + System.getProperty("jdo.tck.description")); + getWriter().println("Time: "+elapsedTimeAsString(runTime)); } - - public String toString() { - StringBuffer buffer = new StringBuffer(THREE_DIGITS_FORMATTER.format(count)); - buffer.append(" error"); - if (this.count != 1) { - buffer.append("s: "); - } else { - buffer.append(": "); - } - buffer.append(getRootCause()); - return buffer.toString(); + + /** */ + protected void printFooter(TestResult result) { + String message = null; + if (this.consoleFileOutput != null) { + message = getResultMessage(result, this.consoleFileOutput); + String directory = this.consoleFileOutput.getDirectory(); + ResultSummary.appendTCKResultMessage(directory, message); + ResultSummary.save(directory, result); + } else { + message = getResultMessage(result); + } + + if (!result.wasSuccessful()) { + getWriter().println("FAILURES!!!"); + printErrorSummary(result); + } + + getWriter().println(message); + getWriter().println("Excluded tests: " + System.getProperty("jdo.tck.exclude")); } - - private Throwable getRootCause() { - return BatchResultPrinter.getRootCause(this.t); + + // helper method + + /** + * Returns the result message for the given result instance and + * the given console file output instance. + * @param result the result instance + * @param consoleFileOutput the console file output instance + * @return the result message + */ + private String getResultMessage(TestResult result, ConsoleFileOutput consoleFileOutput) { + String message = this.consoleFileOutput.getFileName() + ':'; + message += System.getProperty("line.separator") + " "; + message += getResultMessage(result); + return message; + } + + /** + * Returns the result message for the given result instance. + * @param result the result instance + * @return the result message + */ + private String getResultMessage(TestResult result) { + boolean success = result.wasSuccessful(); + String message = success ? "OK " : "** "; + message += "Tests run: " + THREE_DIGITS_FORMATTER.format(result.runCount()) + + ", Time: "+elapsedTimeAsString(this.runtime)+" seconds."; + if (!success) { + message += " Failures: "+result.failureCount() + + ", Errors: "+result.errorCount(); + } + return message; + } + + /** + * @return Name of the class of the given object without package prefix + */ + private String getClassBaseName(Object obj) { + if (obj == null) return null; + String className = obj.getClass().getName(); + int index = className.lastIndexOf('.'); + if (index != -1) { + className = className.substring(index + 1); + } + return className; + } + + private void printErrorSummary(TestResult result) { + Object[] array = getSortedArrayOfErrorSummaryEntries(result); + if (array.length>0) { + getWriter().println("Error summary:"); + for (int i=0; i - *
  • 0: success - *
  • 1: failure, the test shows an unexpected behavior - *
  • 2: exception, the test throws an unhandled excption + *
  • 0: success + *
  • 1: failure, the test shows an unexpected behavior + *
  • 2: exception, the test throws an unhandled excption * - * + * * @author Michael Bouschen */ -public class BatchTestRunner extends TestRunner { - /** Name of the system property to specify the result printer class. */ - public static final String RESULTPRINTER_PROPERTY = "ResultPrinterClass"; +public class BatchTestRunner + extends TestRunner +{ + /** Name of the system property to specify the result printer class. */ + public static final String RESULTPRINTER_PROPERTY = "ResultPrinterClass"; + + /** Default of the system property ResultPrinterClass. */ + public static final String RESULTPRINTER_DEFAULT = BatchResultPrinter.class.getName(); - /** Default of the system property ResultPrinterClass. */ - public static final String RESULTPRINTER_DEFAULT = BatchResultPrinter.class.getName(); + /** */ + public static final String LOG_DIRECTORY; - /** */ - public static final String LOG_DIRECTORY; - - static { - String directory = System.getProperty("jdo.tck.log.directory"); - if (directory != null && !directory.endsWith(File.separator)) { - directory += File.separator; + static { + String directory = System.getProperty("jdo.tck.log.directory"); + if (directory!=null && + !directory.endsWith(File.separator)) { + directory += File.separator; + } + LOG_DIRECTORY = directory; } - LOG_DIRECTORY = directory; - } - - /** - * Constructor. It creates a result printer instance based on the system property and delegates to - * the constructor taking a result printer argument. - */ - public BatchTestRunner() { - super(); - setPrinter(getResultPrinter()); - } - - /** - * Constructor. Uses the specified resultPrinter to format the test result. - * - * @param resultPrinter the result printer - */ - public BatchTestRunner(ResultPrinter resultPrinter) { - super(resultPrinter); - } - - /** - * Runs all test methods from the specified class. - * - * @param clazz class object - */ - public static void run(Class clazz) { - run(new TestSuite(clazz)); - } + - /** - * Runs the specified test or test suite - * - * @param test test or test suite - * @return the test result - */ - public static TestResult run(Test test) { - return new BatchTestRunner().doRun(test); - } - - /** - * Runs the specified test and waits until the user types RETURN. - * - * @param suite suite - */ - public static void runAndWait(Test suite) { - new BatchTestRunner().doRun(suite, true); - } + /** + * Constructor. + * It creates a result printer instance based on the system property + * and delegates to the constructor taking a result printer argument. + */ + public BatchTestRunner() { + super(); + setPrinter(getResultPrinter()); + } - /** - * Runs the specified test or test suite and closes the pmf. - * - * @param test test or test suite - * @return the test result - */ - public TestResult doRun(Test test) { - TestResult result = null; - try { - result = doRun(test, false); - JDO_Test.dumpSupportedOptions(LOG_DIRECTORY + "configuration"); - } finally { - JDO_Test.closePMF(); + /** + * Constructor. Uses the specified resultPrinter to format the test result. + * @param resultPrinter the result printer + */ + public BatchTestRunner(ResultPrinter resultPrinter) { + super(resultPrinter); } - return result; - } - /** - * Runs in batch mode and sets an exit code. If the specified String array includes a single fully - * qualified class name, this test class is executed. - * - * @param args command line arguments - */ - public static void main(String args[]) { - try { - TestResult r = new BatchTestRunner().start(args); - if (!r.wasSuccessful()) System.exit(FAILURE_EXIT); - System.exit(SUCCESS_EXIT); - } catch (Exception e) { - System.err.println(e.getMessage()); - System.exit(EXCEPTION_EXIT); + /** + * Runs all test methods from the specified class. + * @param clazz class object + */ + public static void run(Class clazz) { + run(new TestSuite(clazz)); + } + + /** + * Runs the specified test or test suite + * @param test test or test suite + * @return the test result + */ + public static TestResult run(Test test) { + return new BatchTestRunner().doRun(test); } - } - /** - * Starts the test - * - * @param args arguments - * @return the test result - */ - public TestResult start(String[] args) { - Test suite = null; - if ((args == null) || args.length == 0) { - String conf = System.getProperty("jdo.tck.cfg"); - throw new JDOFatalException( - "Missing JDO TCK test classes for configuration '" - + conf - + "'. Please check the property 'jdo.tck.classes'."); - } else if (args.length == 1) { - suite = getTest(args[0]); - } else { - suite = getTestSuite(args); + /** + * Runs the specified test and waits until the user types RETURN. + * @param suite suite + */ + public static void runAndWait(Test suite) { + new BatchTestRunner().doRun(suite, true); } - return doRun(suite); - } - /** - * Returns a JUnit TestSuite instance for the classes of the specified list of class names. - * - * @param classNames class names - * @return the test suite - */ - protected TestSuite getTestSuite(String[] classNames) { - TestSuite testSuite = new TestSuite(); - for (int i = 0; i < classNames.length; i++) { - String className = classNames[i]; - try { - Class clazz = (Class) Class.forName(className); - testSuite.addTestSuite(clazz); - } catch (ClassNotFoundException ex) { - System.out.println("Cannot find test class '" + className + "'."); - } + /** + * Runs the specified test or test suite and closes the pmf. + * @param test test or test suite + * @return the test result + */ + public TestResult doRun(Test test) { + TestResult result = null; + try { + result = doRun(test, false); + JDO_Test.dumpSupportedOptions(LOG_DIRECTORY + "configuration"); + } finally { + JDO_Test.closePMF(); + } + return result; } - return testSuite; - } - /** - * Returns a result printer instance. The system property ResultPrinterClass specifies the class - * of the returned instanec. The class must extend junit.textui.ResultPrinter. - * - * @return the result printer - */ - protected ResultPrinter getResultPrinter() { - String className = System.getProperty(RESULTPRINTER_PROPERTY); - if (className != null) { - className = className.trim(); - if (className.length() != 0) { - String msg = null; + /** + * Runs in batch mode and sets an exit code. If the specified String + * array includes a single fully qualified class name, this test class + * is executed. + * @param args command line arguments + */ + public static void main(String args[]) { try { - // get class instance - Class clazz = Class.forName(className); + TestResult r = new BatchTestRunner().start(args); + if (!r.wasSuccessful()) + System.exit(FAILURE_EXIT); + System.exit(SUCCESS_EXIT); + } catch(Exception e) { + System.err.println(e.getMessage()); + System.exit(EXCEPTION_EXIT); + } + } - Constructor ctor = null; - OutputStream stream = null; + /** + * Starts the test + * @param args arguments + * @return the test result + */ + public TestResult start(String[] args) { + Test suite = null; + if ((args == null) || args.length == 0) { + String conf = System.getProperty("jdo.tck.cfg"); + throw new JDOFatalException( + "Missing JDO TCK test classes for configuration '" + conf + + "'. Please check the property 'jdo.tck.classes'."); + } + else if (args.length == 1) { + suite = getTest(args[0]); + } + else { + suite = getTestSuite(args); + } + return doRun(suite); + } - // choose constructor taking ConsoleFileOutput arg - if (!Boolean.getBoolean("no.log.file")) { + /** + * Returns a JUnit TestSuite instance for the classes of the specified + * list of class names. + * @param classNames class names + * @return the test suite + */ + protected TestSuite getTestSuite(String[] classNames) { + TestSuite testSuite = new TestSuite(); + for (int i = 0; i < classNames.length; i++) { + String className = classNames[i]; try { - ctor = clazz.getConstructor(new Class[] {ConsoleFileOutput.class}); - stream = new ConsoleFileOutput(); - } catch (NoSuchMethodException ex) { - ctor = null; + Class clazz = (Class)Class.forName(className); + testSuite.addTestSuite(clazz); + } + catch (ClassNotFoundException ex) { + System.out.println( + "Cannot find test class '" + className + "'."); } - } - - // choose constructor taking PrintStream arg - if (ctor == null) { - ctor = clazz.getConstructor(new Class[] {PrintStream.class}); - stream = System.out; - } - - return (ResultPrinter) ctor.newInstance(new Object[] {stream}); - } catch (ClassNotFoundException ex) { - // specified ResultPrinter class not - msg = "Cannot find specified result printer class " + className + "."; - } catch (NoSuchMethodException ex) { - msg = "Class " + className + " does not provide constructor taking a PrintStream."; - } catch (InstantiationException ex) { - msg = "Class " + className + " is abstract."; - } catch (IllegalAccessException ex) { - msg = "Constructor taking a PrintStream of class " + className + " is not accessible."; - } catch (InvocationTargetException ex) { - msg = "Constructor call results in exception " + ex + "."; } - - // ResultPrinter class specified, but not avaiable - System.out.println(msg); - ResultPrinter printer = getDefaultResultPrinter(); - System.out.println("Using default result printer of class " + printer.getClass().getName()); - } + return testSuite; } - // ResultPrinter class not specified => use default - return getDefaultResultPrinter(); - } + /** + * Returns a result printer instance. The system property + * ResultPrinterClass specifies the class of the returned instanec. The + * class must extend junit.textui.ResultPrinter. + * @return the result printer + */ + protected ResultPrinter getResultPrinter() { + String className = System.getProperty(RESULTPRINTER_PROPERTY); + if (className != null) { + className = className.trim(); + if (className.length() != 0) { + String msg = null; + try { + // get class instance + Class clazz = Class.forName(className); + + Constructor ctor = null; + OutputStream stream = null; - /** - * Returns an instance of the default result printer class BatchResultPrinter. - * - * @return the default result printer - */ - protected ResultPrinter getDefaultResultPrinter() { - return new BatchResultPrinter(System.out); - } + // choose constructor taking ConsoleFileOutput arg + if (!Boolean.getBoolean("no.log.file")) { + try { + ctor = clazz.getConstructor( + new Class[] { ConsoleFileOutput.class } ); + stream = new ConsoleFileOutput(); + } + catch (NoSuchMethodException ex) { + ctor = null; + } + } + + // choose constructor taking PrintStream arg + if (ctor == null) { + ctor = clazz.getConstructor( + new Class[] { PrintStream.class } ); + stream = System.out; + } + + return (ResultPrinter)ctor.newInstance( + new Object[] { stream }); + } + catch (ClassNotFoundException ex) { + // specified ResultPrinter class not + msg = "Cannot find specified result printer class " + + className + "."; + } + catch (NoSuchMethodException ex) { + msg = "Class " + className + + " does not provide constructor taking a PrintStream."; + } + catch (InstantiationException ex) { + msg = "Class " + className + " is abstract."; + } + catch (IllegalAccessException ex) { + msg = "Constructor taking a PrintStream of class " + + className + " is not accessible."; + } + catch (InvocationTargetException ex) { + msg = "Constructor call results in exception " + ex + "."; + } - /** - * Returns a file name which is determined by method {@link - * BatchTestRunner#changeFileName(String)}. The file name has suffix .txt. - * - * @return the file name - */ - public static String getFileName() { - return changeFileName("junit.txt"); - } - - /** - * Returns a file name which is constructed by values of some system properties appended by the - * given file name. The system properties evaluated are: - * - *
      - *
    • jdo.tck.log.directory: Specifies the directory for the file. - *
    • jdo.tck.database, jdo.tck.cfg: The values of these properties prepend the given file - * name. - *
    • jdo.tck.identitytype: The value of this property is replaced by "app" if it - * equals "applicationidentity", else it is replaced by "dsid". - *
    - * - * The returned file name is constructed as follows:
    - * ${jdo.tck.log.directory}/${jdo.tck.database}-${jdo.tck.identitytype}-${jdo.tck.cfg}${given file - * name} Values of properties which do not exist default to "". - * - * @param fileName the file name - * @return the changed file name - */ - public static String changeFileName(String fileName) { - String directory = LOG_DIRECTORY; - String db = System.getProperty("jdo.tck.database"); - - String identityType = System.getProperty("jdo.tck.identitytype"); - if (identityType != null) { - if (identityType.equals("applicationidentity")) { - identityType = "app"; - } else { - identityType = "dsid"; - } + // ResultPrinter class specified, but not avaiable + System.out.println(msg); + ResultPrinter printer = getDefaultResultPrinter(); + System.out.println("Using default result printer of class " + + printer.getClass().getName()); + } + } + + // ResultPrinter class not specified => use default + return getDefaultResultPrinter(); } - String configuration = System.getProperty("jdo.tck.cfg"); - if (configuration != null) { - int index = configuration.indexOf('.'); - if (index != -1) { - configuration = configuration.substring(0, index); - } + /** + * Returns an instance of the default result printer class + * BatchResultPrinter. + * @return the default result printer + */ + protected ResultPrinter getDefaultResultPrinter() { + return new BatchResultPrinter(System.out); } - - directory = fixPartialFileName(directory); - db = fixPartialFileName(db, '-', new String[] {identityType, configuration, fileName}); - identityType = fixPartialFileName(identityType, '-', new String[] {configuration, fileName}); - configuration = fixPartialFileName(configuration, '-', new String[] {fileName}); - - return directory + db + identityType + configuration + fileName; - } - - private static String fixPartialFileName(String str) { - if (str == null) { - str = ""; + + /** + * Returns a file name which is determined by method + * {@link BatchTestRunner#changeFileName(String)}. + * The file name has suffix .txt. + * @return the file name + */ + public static String getFileName() { + return changeFileName("junit.txt"); } - return str; - } + + /** + * Returns a file name which is constructed by values + * of some system properties appended by the given file name. + * The system properties evaluated are: + *
      + *
    • jdo.tck.log.directory: Specifies the directory for the file.
    • + *
    • jdo.tck.database, jdo.tck.cfg: + * The values of these properties prepend the given file name.
    • + *
    • jdo.tck.identitytype: The value of this property is replaced by + * "app" if it equals "applicationidentity", + * else it is replaced by "dsid".
    • + *
    + * The returned file name is constructed as follows:
    + * ${jdo.tck.log.directory}/${jdo.tck.database}-${jdo.tck.identitytype}-${jdo.tck.cfg}${given file name} + * Values of properties which do not exist default to "". + * @param fileName the file name + * @return the changed file name + */ + public static String changeFileName(String fileName) { + String directory = LOG_DIRECTORY; + String db = System.getProperty("jdo.tck.database"); + + String identityType = System.getProperty("jdo.tck.identitytype"); + if (identityType!=null) { + if (identityType.equals("applicationidentity")) { + identityType = "app"; + } else { + identityType = "dsid"; + } + } + + String configuration = System.getProperty("jdo.tck.cfg"); + if (configuration!=null) { + int index = configuration.indexOf('.'); + if (index!=-1) { + configuration = configuration.substring(0, index); + } + } + + directory = fixPartialFileName(directory); + db = fixPartialFileName(db, '-', + new String[]{identityType, configuration, fileName}); + identityType = fixPartialFileName(identityType, '-', + new String[]{configuration, fileName}); + configuration = fixPartialFileName(configuration, '-', + new String[]{fileName}); - private static String fixPartialFileName(String str, char c, String[] values) { - str = fixPartialFileName(str); - if (!str.equals("")) { - for (int i = 0; i < values.length; i++) { - String value = values[i]; - if (value != null && !value.equals("") && !value.startsWith(".")) { - str += c; - break; + return directory + db + identityType + configuration + fileName; + } + + private static String fixPartialFileName(String str) { + if (str==null) { + str = ""; + } + return str; + } + + private static String fixPartialFileName(String str, char c, + String[] values) { + str = fixPartialFileName(str); + if (!str.equals("")) { + for (int i = 0; i < values.length; i++) { + String value = values[i]; + if (value!=null && + !value.equals("") && + !value.startsWith(".")) { + str += c; + break; + } + } } - } + return str; } - return str; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/util/ClassGenerator.java b/tck/src/main/java/org/apache/jdo/tck/util/ClassGenerator.java index 09e5b723f..4cc908204 100644 --- a/tck/src/main/java/org/apache/jdo/tck/util/ClassGenerator.java +++ b/tck/src/main/java/org/apache/jdo/tck/util/ClassGenerator.java @@ -5,141 +5,78 @@ * 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 + * + * 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.jdo.tck.util; -import java.io.FileOutputStream; -import java.io.PrintWriter; +import java.io.*; public class ClassGenerator { - private final String[] fieldTypes = { - "boolean", - "byte", - "short", - "int", - "long", - "char", - "float", - "double", - "Boolean", - "Character", - "Byte", - "Short", - "Integer", - "Long", - "Float", - "Double", - "String", - "Locale", - "Date", - "BigDecimal", - "BigInteger", - "Object", - "SimpleClass", - "SimpleInterface" - }; - // includes a place holder for default package access - private final String[] accessSpecifiers = {"private ", "public ", "protected ", ""}; - - private final String[] fieldModifiers = { - "", - "static ", - "transient ", - "final ", - "volatile ", - "static transient ", - "static final ", - "static volatile ", - "transient final ", - "transient volatile ", - "static transient final ", - "static transient volatile " - }; - - private final String[] xmlPersistenceModifiers = { - "", - "persistence-modifier=\"none\"", - "persistence-modifier=\"persistent\"", - "persistence-modifier=\"transactional\"" - }; - - private final String[] xmlEmbeddedModifiers = {"", "embedded=\"true\"", "embedded=\"false\""}; - - private final String[] collectionTypes = { - "Collection", - "Map", - "Set", - "List", - "HashSet", - "ArrayList", - "HashMap", - "Hashtable", - "LinkedList", - "TreeMap", - "TreeSet", - "Vector", - "Array" - }; - - // Note: Any updates to elementtypes should include an update to elementsWithPackageInfo - private final String[] elementTypes = { - "Object", - "SimpleClass", - "SimpleInterface", - "String", - "Date", - "Locale", - "BigDecimal", - "BigInteger", - "Byte", - "Double", - "Float", - "Integer", - "Long", - "Short" - }; - - private final String[] elementsWithPackageInfo = { - "java.lang.Object", - "org.apache.jdo.tck.pc.fieldtypes.SimpleClass", - "org.apache.jdo.tck.pc.fieldtypes.SimpleInterface", - "java.lang.String", - "java.util.Date", - "java.util.Locale", - "java.math.BigDecimal", - "java.math.BigInteger", - "java.lang.Byte", - "java.lang.Double", - "java.lang.Float", - "java.lang.Integer", - "java.lang.Long", - "java.lang.Short" - }; + private final String [] fieldTypes = {"boolean", "byte", "short", "int", "long", + "char", "float", "double", + "Boolean", "Character", "Byte", "Short", "Integer", + "Long", "Float", "Double", "String", + "Locale", "Date", "BigDecimal", "BigInteger", + "Object", "SimpleClass", "SimpleInterface" + }; + //includes a place holder for default package access + private final String [] accessSpecifiers = {"private ", "public ", "protected ", "" }; + + private final String [] fieldModifiers = {"", "static ", "transient ", "final ", "volatile ", + "static transient ", "static final ", "static volatile ", + "transient final ", "transient volatile ", + "static transient final ", "static transient volatile " }; + + private final String [] xmlPersistenceModifiers = {"", "persistence-modifier=\"none\"", + "persistence-modifier=\"persistent\"", + "persistence-modifier=\"transactional\""}; + + private final String [] xmlEmbeddedModifiers = {"", "embedded=\"true\"", "embedded=\"false\""}; + + private final String [] collectionTypes = {"Collection", "Map", "Set", "List", + "HashSet", "ArrayList", "HashMap", "Hashtable", + "LinkedList", "TreeMap", "TreeSet", "Vector", "Array"}; + + //Note: Any updates to elementtypes should include an update to elementsWithPackageInfo + private final String [] elementTypes = {"Object", "SimpleClass", "SimpleInterface", "String", + "Date", "Locale", "BigDecimal", "BigInteger", + "Byte", "Double", "Float", "Integer", "Long", + "Short"}; + + private final String [] elementsWithPackageInfo = {"java.lang.Object", + "org.apache.jdo.tck.pc.fieldtypes.SimpleClass", + "org.apache.jdo.tck.pc.fieldtypes.SimpleInterface", + "java.lang.String", "java.util.Date", + "java.util.Locale", "java.math.BigDecimal", + "java.math.BigInteger", "java.lang.Byte", + "java.lang.Double", "java.lang.Float", + "java.lang.Integer","java.lang.Long", + "java.lang.Short"}; private StringBuffer fieldSpecs = new StringBuffer(2000); private StringBuffer isPersistent = new StringBuffer(200); - private StringBuffer isStatic = new StringBuffer(200); + private StringBuffer isStatic = new StringBuffer(200); private StringBuffer isFinalArray = new StringBuffer(2000); - + // can accomodate only 4000 fields, have to increase the capacity if the fields exceed 4000 - private static boolean[] isFinal = new boolean[4000]; + private static boolean [] isFinal = new boolean[4000]; - void generate() throws Exception { + void generate() throws Exception + { final String twoSpaces = " "; final String space = " "; - for (int i = 0; i < fieldTypes.length; i++) { - String classFile = - (isPrimitive(fieldTypes[i]) ? "FieldsOfPrimitive" : "FieldsOf") + fieldTypes[i]; + for (int i=0; i < fieldTypes.length; i++) + { + String classFile = (isPrimitive(fieldTypes[i]) ? "FieldsOfPrimitive" : "FieldsOf") + fieldTypes[i]; FileOutputStream xmlFout = new FileOutputStream(classFile + ".jdo.n"); PrintWriter xmlPw = new PrintWriter(xmlFout); @@ -151,7 +88,7 @@ void generate() throws Exception { startXmlMetaData(xmlPw1); startXmlMetaData(xmlPw2); - startXmlClass(xmlPw, classFile, 0); + startXmlClass(xmlPw, classFile, 0); startXmlClass(xmlPw1, classFile, 1); startXmlClass(xmlPw2, classFile, 2); @@ -159,147 +96,143 @@ void generate() throws Exception { PrintWriter pw = new PrintWriter(fout); startClass(pw, classFile); int fieldCounter = 0; - for (int j = 0; j < accessSpecifiers.length; j++) { - for (int k = 0; k < fieldModifiers.length; k++) { - for (int l = 0; l < xmlPersistenceModifiers.length; l++) { - // do not generate persistence modifiers (persistent or transactional or none) - // for fields that cannot be persisted - - if ((fieldModifiers[k].indexOf("static") >= 0 - || fieldModifiers[k].indexOf("final") >= 0) - && !xmlPersistenceModifiers[l].equals("")) continue; - - /* original code - if(!isPersistenceCapable(fieldModifiers[k]) - && !xmlPersistenceModifiers[l].equals("")) - continue; - */ - for (int m = 0; m < xmlEmbeddedModifiers.length; m++) { - // generate persistence modifiers (persistent or transactional or none) - // only for fields that can be persisted - // generate embedded modifiers only for persistent fields - - boolean fieldIsPersistent = - !(fieldModifiers[k].indexOf("static") >= 0 - || fieldModifiers[k].indexOf("final") >= 0 - || xmlPersistenceModifiers[l].indexOf("none") >= 0 - || xmlPersistenceModifiers[l].indexOf("transactional") >= 0 - || (fieldModifiers[k].indexOf("transient") >= 0 - && xmlPersistenceModifiers[l].indexOf("persistent") == -1)); - - if (!xmlEmbeddedModifiers[m].equals("") && !fieldIsPersistent) continue; - - StringBuffer sb = new StringBuffer(); - sb.append(twoSpaces); - sb.append(accessSpecifiers[j]); - sb.append(fieldModifiers[k]); - sb.append(fieldTypes[i]); - sb.append(space); - String fieldName = (fieldTypes[i] + fieldCounter++); - // temporary fix to get around the bug in the enhancer code - if (!(xmlEmbeddedModifiers[m].equals("") && xmlPersistenceModifiers[l].equals(""))) { - printXmlField( - xmlPw, - "name=\"" - + fieldName - + "\" " - + xmlPersistenceModifiers[l] - + " " - + xmlEmbeddedModifiers[m]); - printXmlField( - xmlPw1, - "name=\"" - + fieldName - + "\" " - + xmlPersistenceModifiers[l] - + " " - + xmlEmbeddedModifiers[m]); - printXmlField( - xmlPw2, - "name=\"" - + fieldName - + "\" " - + xmlPersistenceModifiers[l] - + " " - + xmlEmbeddedModifiers[m]); - } // end temporary fix - sb.append(fieldName); - buildisPersistentArray(fieldIsPersistent); // add to isPersistentArray - buildisStaticArray(isStatic(fieldModifiers[k])); // add to isStaticArray - buildFieldSpecs( - xmlPersistenceModifiers[l].replace('"', ' ') - + " " - + xmlEmbeddedModifiers[m].replace('"', ' ') - + sb.toString()); // add to the field specs array - isFinal[fieldCounter - 1] = fieldModifiers[k].indexOf("final") >= 0; - if (isFinal[fieldCounter - 1]) sb.append(getInitializerForFinalTypes(fieldTypes[i])); - buildisFinalArray(isFinal[fieldCounter - 1]); - sb.append(";"); - pw.println(sb.toString()); - } - } - } - } - writeisPersistentArray(pw); - writeisStaticArray(pw); - writeisFinalArray(pw); - writeFieldSpecs(pw); - writeMethodGetLength(pw); - writeMethodGet(pw, fieldTypes[i], fieldCounter); - writeMethodSet(pw, fieldTypes[i], fieldCounter); - endClass(pw); - pw.close(); - fout.close(); - - endXmlClass(xmlPw); - endXmlClass(xmlPw1); - endXmlClass(xmlPw2); - endXmlMetaDeta(xmlPw); - endXmlMetaDeta(xmlPw1); - endXmlMetaDeta(xmlPw2); - xmlPw.close(); - xmlFout.close(); - xmlPw1.close(); - xmlFout1.close(); - xmlPw2.close(); - xmlFout2.close(); - } - } - - private void startClass(PrintWriter pw, String className) { + for(int j=0; j < accessSpecifiers.length; j++) + { + for (int k=0; k < fieldModifiers.length; k++) + { + for(int l = 0; l < xmlPersistenceModifiers.length; l++) + { + // do not generate persistence modifiers (persistent or transactional or none) + // for fields that cannot be persisted + + + if( (fieldModifiers[k].indexOf("static") >= 0 || fieldModifiers[k].indexOf("final") >= 0 ) && + !xmlPersistenceModifiers[l].equals("")) + continue; + +/* original code + if(!isPersistenceCapable(fieldModifiers[k]) + && !xmlPersistenceModifiers[l].equals("")) + continue; +*/ + for(int m=0; m < xmlEmbeddedModifiers.length; m++) { + // generate persistence modifiers (persistent or transactional or none) + // only for fields that can be persisted + // generate embedded modifiers only for persistent fields + + boolean fieldIsPersistent = !( fieldModifiers[k].indexOf("static") >= 0 || + fieldModifiers[k].indexOf("final") >= 0 || + xmlPersistenceModifiers[l].indexOf("none") >= 0 || + xmlPersistenceModifiers[l].indexOf("transactional") >= 0 || + (fieldModifiers[k].indexOf("transient") >= 0 && xmlPersistenceModifiers[l].indexOf("persistent") == -1) + ); + + if(!xmlEmbeddedModifiers[m].equals("") && !fieldIsPersistent ) + continue; + + StringBuffer sb = new StringBuffer(); + sb.append(twoSpaces); + sb.append(accessSpecifiers[j]); + sb.append(fieldModifiers[k]); + sb.append(fieldTypes[i]); + sb.append(space); + String fieldName = (fieldTypes[i] + fieldCounter++); +//temporary fix to get around the bug in the enhancer code +if(!(xmlEmbeddedModifiers[m].equals("") && xmlPersistenceModifiers[l].equals(""))) +{ + printXmlField(xmlPw, "name=\"" + fieldName + "\" " + + xmlPersistenceModifiers[l]+ " " + + xmlEmbeddedModifiers[m]); + printXmlField(xmlPw1, "name=\"" + fieldName + "\" " + + xmlPersistenceModifiers[l]+ " " + + xmlEmbeddedModifiers[m]); + printXmlField(xmlPw2, "name=\"" + fieldName + "\" " + + xmlPersistenceModifiers[l]+ " " + + xmlEmbeddedModifiers[m]); +}//end temporary fix + sb.append(fieldName); + buildisPersistentArray(fieldIsPersistent); // add to isPersistentArray + buildisStaticArray(isStatic(fieldModifiers[k])); // add to isStaticArray + buildFieldSpecs(xmlPersistenceModifiers[l].replace('"',' ') + " " + + xmlEmbeddedModifiers[m].replace('"',' ') + + sb.toString()); // add to the field specs array + isFinal[fieldCounter-1] = fieldModifiers[k].indexOf("final") >= 0; + if(isFinal[fieldCounter-1]) + sb.append(getInitializerForFinalTypes(fieldTypes[i])); + buildisFinalArray(isFinal[fieldCounter-1]); + sb.append(";"); + pw.println(sb.toString()); + } + } + } + } + writeisPersistentArray(pw); + writeisStaticArray(pw); + writeisFinalArray(pw); + writeFieldSpecs(pw); + writeMethodGetLength(pw); + writeMethodGet(pw, fieldTypes[i], fieldCounter); + writeMethodSet(pw, fieldTypes[i], fieldCounter); + endClass(pw); + pw.close(); + fout.close(); + + endXmlClass(xmlPw); + endXmlClass(xmlPw1); + endXmlClass(xmlPw2); + endXmlMetaDeta(xmlPw); + endXmlMetaDeta(xmlPw1); + endXmlMetaDeta(xmlPw2); + xmlPw.close(); + xmlFout.close(); + xmlPw1.close(); + xmlFout1.close(); + xmlPw2.close(); + xmlFout2.close(); + } + } + + + private void startClass(PrintWriter pw, String className) + { pw.println("package org.apache.jdo.tck.pc.fieldtypes;"); pw.println(""); pw.println(getImportStatements(className)); - pw.println("public class " + className + " { "); + pw.println("public class " + className + " { " ); pw.println(" public int identifier;"); } - private void endClass(PrintWriter pw) { + private void endClass(PrintWriter pw) + { pw.println(""); pw.println("}"); } - private void startXmlMetaData(PrintWriter pw) { + private void startXmlMetaData(PrintWriter pw) + { pw.println(""); pw.println(""); pw.println(""); pw.println(""); } - private void endXmlMetaDeta(PrintWriter pw) { + private void endXmlMetaDeta(PrintWriter pw) + { pw.println(""); pw.println(""); } - private void startXmlClass(PrintWriter pw, String className, int type) { - switch (type) { - case (0): + private void startXmlClass(PrintWriter pw, String className, int type) + { + switch(type) + { + case(0): pw.println(""); break; - case (1): + case(1): pw.println(""); break; - case (2): + case(2): pw.println(""); break; default: @@ -307,374 +240,463 @@ private void startXmlClass(PrintWriter pw, String className, int type) { } } - private void endXmlClass(PrintWriter pw) { + private void endXmlClass(PrintWriter pw) + { pw.println(""); } // need to check if we should support extents // fieldName includes modifiers - private void printXmlField(PrintWriter pw, String fieldName) { - pw.println(""); + private void printXmlField(PrintWriter pw, String fieldName) + { + pw.println(""); pw.println(""); } // fieldname does not include any modifiers. // element type includes package informaiton. - private void printXmlCollectionFieldWithEmbeddedElement( - PrintWriter pw, String fieldName, String elementType, String embeddedValue) { + private void printXmlCollectionFieldWithEmbeddedElement(PrintWriter pw, String fieldName, + String elementType, String embeddedValue) + { pw.println(""); pw.print(""); pw.println(""); pw.println(""); } - private void printXmlArrayFieldWithEmbeddedElement( - PrintWriter pw, String fieldName, String embeddedValue) { + private void printXmlArrayFieldWithEmbeddedElement(PrintWriter pw, String fieldName, + String embeddedValue) + { pw.println(""); - pw.println(""); + pw.println(""); pw.println(""); pw.println(""); } - private void printXmlMapField( - PrintWriter pw, - String fieldName, - String keyType, - String embeddedKey, - String valueType, - String embeddedValue) { + private void printXmlMapField(PrintWriter pw, String fieldName, String keyType, + String embeddedKey, String valueType, String embeddedValue) + { pw.println(""); pw.print(""); pw.println(""); pw.println(""); } - private String getInitializerForFinalTypes(String fieldType) throws Exception { - if (fieldType.equals("char")) return " = 'a'"; // primitive character, return 'a'; - else if (fieldType.equals("boolean")) return " = false"; // primitive boolean, return 'a'; + private String getInitializerForFinalTypes(String fieldType) throws Exception + { + if (fieldType.equals("char")) + return " = 'a'"; //primitive character, return 'a'; + else if (fieldType.equals("boolean")) + return " = false"; //primitive boolean, return 'a'; else if (Character.isLowerCase(fieldType.charAt(0))) return " = 5"; // return 0 for all other primitive types - else if (fieldType.equals("Byte")) return " = Byte.valueOf((byte)5)"; - else if (fieldType.equals("Boolean")) return " = Boolean.FALSE"; - else if (fieldType.equals("Character")) return " = Character.valueOf('a')"; - else if (fieldType.equals("Short")) return " = Short.valueOf((short)5)"; - else if (fieldType.equals("Integer")) return " = Integer.valueOf((int)5)"; - else if (fieldType.equals("Long")) return " = Long.valueOf((long)5)"; - else if (fieldType.equals("Float")) return " = Float.valueOf((float)5)"; - else if (fieldType.equals("Double")) return " = Double.valueOf((double)5)"; - else if (fieldType.equals("String")) return " = new String(\"JDO TCK\")"; - else if (fieldType.equals("Locale")) return " = Locale.US"; - else if (fieldType.equals("BigDecimal")) return " = new BigDecimal(100.15)"; - else if (fieldType.equals("BigInteger")) return " = new BigInteger(\"100\")"; - else if (fieldType.equals("Collection")) return " = new HashSet()"; - else if (fieldType.equals("Set")) return " = new HashSet()"; - else if (fieldType.equals("HashSet")) return " = new HashSet()"; - else if (fieldType.equals("Object")) return " = new Object()"; - else if (fieldType.equals("SimpleClass")) return " = new SimpleClass()"; - else if (fieldType.equals("SimpleInterface")) return " = new SimpleClass()"; - else if (fieldType.equals("Date")) return " = new Date()"; - else throw new Exception("Unsupported FieldType " + fieldType); - } - - private String getImportStatements(String fieldType) { - if (fieldType.equals("FieldsOfLocale")) return "import java.util.*;"; - if (fieldType.equals("FieldsOfDate")) return "import java.util.*;"; - else if (fieldType.equals("FieldsOfBigDecimal")) return "import java.math.*;"; - else if (fieldType.equals("FieldsOfBigInteger")) return "import java.math.*;"; - else if (fieldType.equals("FieldsOfCollection")) return "import java.util.*;"; - else if (fieldType.equals("FieldsOfSet")) return "import java.util.*;"; - else if (fieldType.equals("FieldsOfHashSet")) return "import java.util.*;"; - else if (fieldType.indexOf("Collections") >= 0) + else if (fieldType.equals("Byte")) + return " = Byte.valueOf((byte)5)"; + else if (fieldType.equals("Boolean")) + return " = Boolean.FALSE"; + else if (fieldType.equals("Character")) + return " = Character.valueOf('a')"; + else if (fieldType.equals("Short")) + return " = Short.valueOf((short)5)"; + else if (fieldType.equals("Integer")) + return " = Integer.valueOf((int)5)"; + else if (fieldType.equals("Long")) + return " = Long.valueOf((long)5)"; + else if (fieldType.equals("Float")) + return " = Float.valueOf((float)5)"; + else if (fieldType.equals("Double")) + return " = Double.valueOf((double)5)"; + else if (fieldType.equals("String")) + return " = new String(\"JDO TCK\")"; + else if (fieldType.equals("Locale")) + return " = Locale.US"; + else if (fieldType.equals("BigDecimal")) + return " = new BigDecimal(100.15)"; + else if (fieldType.equals("BigInteger")) + return " = new BigInteger(\"100\")"; + else if (fieldType.equals("Collection")) + return " = new HashSet()"; + else if (fieldType.equals("Set")) + return " = new HashSet()"; + else if (fieldType.equals("HashSet")) + return " = new HashSet()"; + else if (fieldType.equals("Object")) + return " = new Object()"; + else if (fieldType.equals("SimpleClass")) + return " = new SimpleClass()"; + else if (fieldType.equals("SimpleInterface")) + return " = new SimpleClass()"; + else if (fieldType.equals("Date")) + return " = new Date()"; + else + throw new Exception("Unsupported FieldType " + fieldType); + } + + private String getImportStatements(String fieldType) + { + if (fieldType.equals("FieldsOfLocale")) + return "import java.util.*;"; + if (fieldType.equals("FieldsOfDate")) + return "import java.util.*;"; + else if (fieldType.equals("FieldsOfBigDecimal")) + return "import java.math.*;"; + else if (fieldType.equals("FieldsOfBigInteger")) + return "import java.math.*;"; + else if (fieldType.equals("FieldsOfCollection")) + return "import java.util.*;"; + else if (fieldType.equals("FieldsOfSet")) + return "import java.util.*;"; + else if (fieldType.equals("FieldsOfHashSet")) + return "import java.util.*;"; + else if (fieldType.indexOf("Collections") >=0) return "import java.util.*;\r\nimport java.math.*;"; - else return ""; - } - - private boolean isPrimitive(String fieldType) { - if (Character.isUpperCase(fieldType.charAt(0))) return false; - else return true; - } - - private boolean isPersistenceCapable(String fieldModifier) { - if (fieldModifier.indexOf("static") >= 0 - || fieldModifier.indexOf("final") >= 0 - || fieldModifier.indexOf("transient") >= 0) return false; - else return true; - } - - private boolean isStatic(String fieldModifier) { - if (fieldModifier.indexOf("static") >= 0) return true; - else return false; - } - - private boolean isFinal(String fieldModifier) { - return fieldModifier.indexOf("final") >= 0; - } - - private void buildisPersistentArray(boolean value) { - if (isPersistent.length() != 0) isPersistent.append(","); - if (value) isPersistent.append("true"); - else isPersistent.append("false"); - } - - private void buildisStaticArray(boolean value) { - if (isStatic.length() != 0) isStatic.append(","); - if (value) isStatic.append("true"); - else isStatic.append("false"); - } - - private void buildisFinalArray(boolean value) { - if (isFinalArray.length() != 0) isFinalArray.append(","); - if (value) isFinalArray.append("true"); - else isFinalArray.append("false"); - } - - private void writeisPersistentArray(PrintWriter pw) { - // have to go through this hoopla because pw.println(fieldSpecs.toString()); outputs only - // 1024 characters - char[] charArray = new char[isPersistent.length()]; - isPersistent.getChars(0, isPersistent.length(), charArray, 0); - pw.println(""); - pw.println("public static final boolean [] isPersistent = { "); - - int fieldCounter = 0; - for (int i = 0; i < charArray.length; i++) { - pw.print(charArray[i]); - if (charArray[i] == ',') { - fieldCounter++; - if (fieldCounter == 10) { - pw.println(""); - pw.flush(); - fieldCounter = 0; + else + return ""; + } + + private boolean isPrimitive(String fieldType) + { + if (Character.isUpperCase(fieldType.charAt(0))) + return false; + else + return true; + } + + private boolean isPersistenceCapable(String fieldModifier) + { + if (fieldModifier.indexOf("static") >= 0 + || fieldModifier.indexOf("final") >= 0 + || fieldModifier.indexOf("transient") >= 0) + return false; + else + return true; + } + + private boolean isStatic(String fieldModifier) + { + if (fieldModifier.indexOf("static") >= 0) + return true; + else + return false; + } + private boolean isFinal(String fieldModifier) + { + return fieldModifier.indexOf("final") >= 0; + } + private void buildisPersistentArray(boolean value) + { + if(isPersistent.length() != 0) + isPersistent.append(","); + if(value) + isPersistent.append("true"); + else + isPersistent.append("false"); + } + + private void buildisStaticArray(boolean value) + { + if(isStatic.length() != 0) + isStatic.append(","); + if(value) + isStatic.append("true"); + else + isStatic.append("false"); + } + + private void buildisFinalArray(boolean value) + { + if(isFinalArray.length() != 0) + isFinalArray.append(","); + if(value) + isFinalArray.append("true"); + else + isFinalArray.append("false"); + } + + + private void writeisPersistentArray(PrintWriter pw) + { + // have to go through this hoopla because pw.println(fieldSpecs.toString()); outputs only + // 1024 characters + char [] charArray = new char[isPersistent.length()]; + isPersistent.getChars(0,isPersistent.length(),charArray,0); + pw.println(""); + pw.println("public static final boolean [] isPersistent = { "); + + int fieldCounter=0; + for(int i = 0; i < charArray.length; i++) + { + pw.print(charArray[i]); + if(charArray[i] == ',') + { + fieldCounter++; + if(fieldCounter == 10) + { + pw.println(""); + pw.flush(); + fieldCounter = 0; + } } - } - } - pw.println(""); - pw.println(" };"); - isPersistent = new StringBuffer(2000); - } - - private void writeisStaticArray(PrintWriter pw) { - // have to go through this hoopla because pw.println(fieldSpecs.toString()); outputs only - // 1024 characters - char[] charArray = new char[isStatic.length()]; - isStatic.getChars(0, isStatic.length(), charArray, 0); - pw.println(""); - pw.println("public static final boolean [] isStatic = { "); - - int fieldCounter = 0; - for (int i = 0; i < charArray.length; i++) { - pw.print(charArray[i]); - if (charArray[i] == ',') { - fieldCounter++; - if (fieldCounter == 10) { - pw.println(""); - pw.flush(); - fieldCounter = 0; + } + pw.println(""); + pw.println(" };"); + isPersistent = new StringBuffer(2000); + } + + + private void writeisStaticArray(PrintWriter pw) + { + // have to go through this hoopla because pw.println(fieldSpecs.toString()); outputs only + // 1024 characters + char [] charArray = new char[isStatic.length()]; + isStatic.getChars(0,isStatic.length(),charArray,0); + pw.println(""); + pw.println("public static final boolean [] isStatic = { "); + + int fieldCounter=0; + for(int i = 0; i < charArray.length; i++) + { + pw.print(charArray[i]); + if(charArray[i] == ',') + { + fieldCounter++; + if(fieldCounter == 10) + { + pw.println(""); + pw.flush(); + fieldCounter = 0; + } } - } - } - pw.println(""); - pw.println(" };"); - isStatic = new StringBuffer(2000); - } - - private void writeisFinalArray(PrintWriter pw) { - // have to go through this hoopla because pw.println(fieldSpecs.toString()); outputs only - // 1024 characters - char[] charArray = new char[isFinalArray.length()]; - isFinalArray.getChars(0, isFinalArray.length(), charArray, 0); - pw.println(""); - pw.println("public static final boolean [] isFinal = { "); - - int fieldCounter = 0; - for (int i = 0; i < charArray.length; i++) { - pw.print(charArray[i]); - if (charArray[i] == ',') { - fieldCounter++; - if (fieldCounter == 10) { - pw.println(""); - pw.flush(); - fieldCounter = 0; + } + pw.println(""); + pw.println(" };"); + isStatic = new StringBuffer(2000); + } + private void writeisFinalArray(PrintWriter pw) + { + // have to go through this hoopla because pw.println(fieldSpecs.toString()); outputs only + // 1024 characters + char [] charArray = new char[isFinalArray.length()]; + isFinalArray.getChars(0,isFinalArray.length(),charArray,0); + pw.println(""); + pw.println("public static final boolean [] isFinal = { "); + + int fieldCounter=0; + for(int i = 0; i < charArray.length; i++) + { + pw.print(charArray[i]); + if(charArray[i] == ',') + { + fieldCounter++; + if(fieldCounter == 10) + { + pw.println(""); + pw.flush(); + fieldCounter = 0; + } } - } - } - pw.println(""); - pw.println(" };"); - isFinalArray = new StringBuffer(2000); - } + } + pw.println(""); + pw.println(" };"); + isFinalArray = new StringBuffer(2000); + } - private void buildFieldSpecs(String field) { - if (fieldSpecs.length() != 0) fieldSpecs.append(","); + private void buildFieldSpecs(String field) + { + if(fieldSpecs.length() != 0) + fieldSpecs.append(","); fieldSpecs.append("\""); fieldSpecs.append(field.trim()); fieldSpecs.append("\""); } - private void writeFieldSpecs(PrintWriter pw) { + + private void writeFieldSpecs(PrintWriter pw) + { // have to go through this hoopla because pw.println(fieldSpecs.toString()); outputs only // 1024 characters - char[] charArray = new char[fieldSpecs.length()]; - fieldSpecs.getChars(0, fieldSpecs.length(), charArray, 0); + char [] charArray = new char[fieldSpecs.length()]; + fieldSpecs.getChars(0,fieldSpecs.length(),charArray,0); pw.println(""); pw.println(" public static final String [] fieldSpecs = { "); pw.print(" "); - for (int i = 0; i < charArray.length; i++) { - pw.print(charArray[i]); - if (charArray[i] == ',') { - pw.println(""); - pw.print(" "); - pw.flush(); - } + for(int i = 0; i < charArray.length; i++) + { + pw.print(charArray[i]); + if(charArray[i] == ',') + { + pw.println(""); + pw.print(" "); + pw.flush(); + } } pw.println(""); pw.println(" };"); fieldSpecs = new StringBuffer(2000); } - private void writeMethodGetLength(PrintWriter pw) { - pw.println(" public int getLength()"); - pw.println(" {"); - pw.println(" return fieldSpecs.length;"); - pw.println(" }"); - } - - private void writeMethodGet(PrintWriter pw, String fieldType, int numberOfFields) { - pw.println(" public " + fieldType + " get(int index)"); - pw.println(" {"); - - pw.println(" switch (index)"); - pw.println(" {"); - for (int i = 0; i < numberOfFields; i++) { - pw.println(" case(" + i + "):"); - pw.println(" return " + fieldType + i + ";"); - } - pw.println(" default:"); - pw.println(" throw new IndexOutOfBoundsException();"); - pw.println(" }"); - pw.println(" }"); - } - - private void writeMethodGet( - PrintWriter pw, String fieldType, String[] fieldNames, int numFields) { - pw.println(" public " + fieldType + " get(int index)"); - pw.println(" {"); - - pw.println(" switch (index)"); - pw.println(" {"); - for (int i = 0; i < numFields; i++) { - pw.println(" case(" + i + "):"); - pw.println(" return " + fieldNames[i] + ";"); - } - pw.println(" default:"); - pw.println(" throw new IndexOutOfBoundsException();"); - pw.println(" }"); - pw.println(" }"); - } - - private void writeMethodSet(PrintWriter pw, String fieldType, int numberOfFields) { - pw.println(" public boolean set(int index," + fieldType + " value" + ")"); - pw.println(" {"); - pw.println(" if(fieldSpecs[index].indexOf(\"final\") != -1)"); - pw.println(" return false;"); - - pw.println(" switch (index)"); - pw.println(" {"); - for (int i = 0; i < numberOfFields; i++) { - if (!isFinal[i]) { - pw.println(" case(" + i + "):"); - pw.println(" " + fieldType + i + "= value" + ";"); - pw.println(" break;"); - } - } - pw.println(" default:"); - pw.println(" throw new IndexOutOfBoundsException();"); - pw.println(" }"); - pw.println(" return true;"); - pw.println(" }"); - } - - private void writeMethodSet( - PrintWriter pw, String fieldType, String[] fieldNames, int numFields) { - pw.println(" public boolean set(int index," + fieldType + " value" + ")"); - pw.println(" {"); - pw.println(" if(fieldSpecs[index].indexOf(\"final\") != -1)"); - pw.println(" return false;"); - - pw.println(" switch (index)"); - pw.println(" {"); - for (int i = 0; i < numFields; i++) { - // if(!isFinal[i]) { - pw.println(" case(" + i + "):"); - pw.println(" " + fieldNames[i] + "= value" + ";"); - pw.println(" break;"); - // } - } - pw.println(" default:"); - pw.println(" throw new IndexOutOfBoundsException();"); - pw.println(" }"); - pw.println(" return true;"); - pw.println(" }"); - } - - private void writeMethodSetForArray( - PrintWriter pw, String fieldType, String[] fieldNames, int numFields) { - pw.println(" public boolean set(int index," + fieldType + " value" + ")"); - pw.println(" {"); - pw.println(" if(fieldSpecs[index].indexOf(\"final\") != -1)"); - pw.println(" return false;"); - - pw.println(" switch (index)"); - pw.println(" {"); - for (int i = 0; i < numFields; i++) { - // if(!isFinal[i]) { - String fieldName = fieldNames[i]; - String valueType; - pw.println(" case(" + i + "):"); - int indexOfValueType = fieldName.indexOf("Of") + 2; - String valueTypeWithNumber = fieldName.substring(indexOfValueType); - int lastIndexOfValueType = 0; - for (int j = valueTypeWithNumber.length() - 1; j >= 0; j--) { - if (Character.isDigit(valueTypeWithNumber.charAt(j))) { - continue; - } else { - lastIndexOfValueType = j; - break; - } - } - valueType = valueTypeWithNumber.substring(0, lastIndexOfValueType + 1); - pw.println(" " + fieldNames[i] + "= (" + valueType + " []) value ;"); - pw.println(" break;"); - // } - } - pw.println(" default:"); - pw.println(" throw new IndexOutOfBoundsException();"); - pw.println(" }"); - pw.println(" return true;"); - pw.println(" }"); + private void writeMethodGetLength(PrintWriter pw) + { + pw.println(" public int getLength()"); + pw.println(" {"); + pw.println(" return fieldSpecs.length;"); + pw.println(" }"); + } + + private void writeMethodGet(PrintWriter pw, String fieldType, int numberOfFields) + { + pw.println(" public " +fieldType+ " get(int index)"); + pw.println(" {"); + + pw.println(" switch (index)"); + pw.println(" {"); + for(int i = 0; i < numberOfFields; i++) + { + pw.println(" case(" + i + "):"); + pw.println(" return " + fieldType + i +";"); + } + pw.println(" default:"); + pw.println(" throw new IndexOutOfBoundsException();"); + pw.println(" }"); + pw.println(" }"); + } + + private void writeMethodGet(PrintWriter pw, String fieldType, String[] fieldNames, int numFields) + { + pw.println(" public " +fieldType+ " get(int index)"); + pw.println(" {"); + + pw.println(" switch (index)"); + pw.println(" {"); + for(int i = 0; i < numFields; i++) + { + pw.println(" case(" + i + "):"); + pw.println(" return " + fieldNames[i] +";"); + } + pw.println(" default:"); + pw.println(" throw new IndexOutOfBoundsException();"); + pw.println(" }"); + pw.println(" }"); + } + private void writeMethodSet(PrintWriter pw, String fieldType, int numberOfFields) + { + pw.println(" public boolean set(int index," + fieldType + " value"+ ")"); + pw.println(" {"); + pw.println(" if(fieldSpecs[index].indexOf(\"final\") != -1)"); + pw.println(" return false;"); + + pw.println(" switch (index)"); + pw.println(" {"); + for(int i = 0; i < numberOfFields; i++) + { + if(!isFinal[i]) + { + pw.println(" case(" + i + "):"); + pw.println(" " + fieldType + i + "= value" + ";"); + pw.println(" break;" ); + } + } + pw.println(" default:"); + pw.println(" throw new IndexOutOfBoundsException();"); + pw.println(" }"); + pw.println(" return true;"); + pw.println(" }"); + } + + private void writeMethodSet(PrintWriter pw, String fieldType, String [] fieldNames, int numFields) + { + pw.println(" public boolean set(int index," + fieldType + " value"+ ")"); + pw.println(" {"); + pw.println(" if(fieldSpecs[index].indexOf(\"final\") != -1)"); + pw.println(" return false;"); + + pw.println(" switch (index)"); + pw.println(" {"); + for(int i = 0; i < numFields; i++) + { +// if(!isFinal[i]) { + pw.println(" case(" + i + "):"); + pw.println(" " + fieldNames[i] + "= value" + ";"); + pw.println(" break;" ); +// } + } + pw.println(" default:"); + pw.println(" throw new IndexOutOfBoundsException();"); + pw.println(" }"); + pw.println(" return true;"); + pw.println(" }"); + } + + + private void writeMethodSetForArray(PrintWriter pw, String fieldType, String [] fieldNames, int numFields) + { + pw.println(" public boolean set(int index," + fieldType + " value"+ ")"); + pw.println(" {"); + pw.println(" if(fieldSpecs[index].indexOf(\"final\") != -1)"); + pw.println(" return false;"); + + pw.println(" switch (index)"); + pw.println(" {"); + for(int i = 0; i < numFields; i++) + { +// if(!isFinal[i]) { + String fieldName = fieldNames[i]; + String valueType; + pw.println(" case(" + i + "):"); + int indexOfValueType = fieldName.indexOf("Of") + 2; + String valueTypeWithNumber = fieldName.substring(indexOfValueType); + int lastIndexOfValueType = 0; + for (int j=valueTypeWithNumber.length() -1; j>=0; j--) + { + if (Character.isDigit(valueTypeWithNumber.charAt(j))) + { + continue; + }else { + lastIndexOfValueType = j; + break; + } + } + valueType = valueTypeWithNumber.substring(0, lastIndexOfValueType+1); + pw.println(" " + fieldNames[i] + "= (" +valueType + " []) value ;"); + pw.println(" break;" ); +// } + } + pw.println(" default:"); + pw.println(" throw new IndexOutOfBoundsException();"); + pw.println(" }"); + pw.println(" return true;"); + pw.println(" }"); } // generates Collection files for the different collectionTypes // also, updates the corresponding xml files // called by generate, after it is done dealing with the generic field types - void generateCollections() throws Exception { - final String[] embeddedElements = {"", "true", "false"}; - final String[] embeddedElementsForFieldSpec = { - "", "embedded-element=true", "embedded-element=false" - }; - for (int i = 0; i < collectionTypes.length; i++) { - // Map has a lot of combinations, generate it separately - if (collectionTypes[i].indexOf("Map") >= 0 || collectionTypes[i].equals("Hashtable")) { + void generateCollections() throws Exception + { + final String [] embeddedElements = {"", "true", "false"}; + final String [] embeddedElementsForFieldSpec = {"", "embedded-element=true", "embedded-element=false"}; + for(int i=0; i < collectionTypes.length; i++) + { + // Map has a lot of combinations, generate it separately + if(collectionTypes[i].indexOf("Map") >= 0 || collectionTypes[i].equals("Hashtable")) + { generateMapCollection(collectionTypes[i]); - } else // Array and the other collections + } + else // Array and the other collections { String classFile = collectionTypes[i] + "Collections"; FileOutputStream fout = new FileOutputStream(classFile + ".java"); @@ -691,75 +713,58 @@ void generateCollections() throws Exception { startXmlMetaData(xmlPw1); startXmlMetaData(xmlPw2); - startXmlClass(xmlPw, classFile, 0); + startXmlClass(xmlPw, classFile, 0); startXmlClass(xmlPw1, classFile, 1); startXmlClass(xmlPw2, classFile, 2); - int fieldCounter = 0; - String fieldNames[] = new String[elementTypes.length * embeddedElements.length]; - for (int j = 0; j < elementTypes.length; j++) { - if (elementTypes[j].equals("Locale") && collectionTypes[i].equals("TreeSet")) continue; - for (int k = 0; k < embeddedElements.length; k++) { - if (collectionTypes[i].equals("Array")) { - if (!embeddedElements[k].equals("")) { - fieldNames[fieldCounter] = - collectionTypes[i] + "Of" + elementTypes[j] + fieldCounter; - // pw.println(" public " + "Object [] "+ fieldNames[fieldCounter] - // +";"); - pw.println(" public " + elementTypes[j] + " [] " + fieldNames[fieldCounter] + ";"); - printXmlArrayFieldWithEmbeddedElement( - xmlPw, fieldNames[fieldCounter], embeddedElements[k]); - printXmlArrayFieldWithEmbeddedElement( - xmlPw1, fieldNames[fieldCounter], embeddedElements[k]); - printXmlArrayFieldWithEmbeddedElement( - xmlPw2, fieldNames[fieldCounter], embeddedElements[k]); - buildFieldSpecs( - embeddedElementsForFieldSpec[k] - + " " - + "public " - + elementTypes[j] - + " [] " - + fieldNames[fieldCounter]); // add to the field specs array*/ + int fieldCounter=0; + String fieldNames [] = new String [elementTypes.length * embeddedElements.length]; + for(int j=0; j < elementTypes.length; j++) + { + if( elementTypes[j].equals("Locale") && collectionTypes[i].equals("TreeSet") ) + continue; + for(int k=0; k < embeddedElements.length; k++) + { + if(collectionTypes[i].equals("Array")) + { + if(!embeddedElements[k].equals("")) + { + fieldNames[fieldCounter] = collectionTypes[i] + "Of" + elementTypes[j] + fieldCounter; +// pw.println(" public " + "Object [] "+ fieldNames[fieldCounter] +";"); + pw.println(" public " + elementTypes[j] +" [] " + fieldNames[fieldCounter] +";"); + printXmlArrayFieldWithEmbeddedElement(xmlPw, fieldNames[fieldCounter], embeddedElements[k]); + printXmlArrayFieldWithEmbeddedElement(xmlPw1, fieldNames[fieldCounter], embeddedElements[k]); + printXmlArrayFieldWithEmbeddedElement(xmlPw2, fieldNames[fieldCounter], embeddedElements[k]); + buildFieldSpecs(embeddedElementsForFieldSpec[k] + " " + + "public " + elementTypes[j] +" [] " + fieldNames[fieldCounter]); // add to the field specs array*/ fieldCounter++; } - } else // Collection + } + else // Collection { fieldNames[fieldCounter] = collectionTypes[i] + "Of" + elementTypes[j] + fieldCounter; - pw.println(" public " + collectionTypes[i] + " " + fieldNames[fieldCounter] + ";"); - printXmlCollectionFieldWithEmbeddedElement( - xmlPw, fieldNames[fieldCounter], elementsWithPackageInfo[j], embeddedElements[k]); - printXmlCollectionFieldWithEmbeddedElement( - xmlPw1, - fieldNames[fieldCounter], - elementsWithPackageInfo[j], - embeddedElements[k]); - printXmlCollectionFieldWithEmbeddedElement( - xmlPw2, - fieldNames[fieldCounter], - elementsWithPackageInfo[j], - embeddedElements[k]); - buildFieldSpecs( - embeddedElementsForFieldSpec[k] - + " " - + "public " - + collectionTypes[i] - + " " - + fieldNames[fieldCounter]); // add to the field specs array*/ + pw.println(" public " + collectionTypes[i] +" "+ fieldNames[fieldCounter] +";"); + printXmlCollectionFieldWithEmbeddedElement(xmlPw, fieldNames[fieldCounter], elementsWithPackageInfo[j], + embeddedElements[k]); + printXmlCollectionFieldWithEmbeddedElement(xmlPw1, fieldNames[fieldCounter], elementsWithPackageInfo[j], + embeddedElements[k]); + printXmlCollectionFieldWithEmbeddedElement(xmlPw2, fieldNames[fieldCounter], elementsWithPackageInfo[j], + embeddedElements[k]); + buildFieldSpecs(embeddedElementsForFieldSpec[k] + " " + + "public " + collectionTypes[i] +" "+ fieldNames[fieldCounter]); // add to the field specs array*/ fieldCounter++; + } } } writeFieldSpecs(pw); writeMethodGetLength(pw); - writeMethodGet( - pw, - collectionTypes[i].equals("Array") ? "Object [] " : collectionTypes[i], - fieldNames, - fieldCounter); - if (collectionTypes[i].equals("Array")) + writeMethodGet(pw, collectionTypes[i].equals("Array")? "Object [] " : collectionTypes[i], fieldNames, fieldCounter); + if(collectionTypes[i].equals("Array")) writeMethodSetForArray(pw, "Object [] ", fieldNames, fieldCounter); - else writeMethodSet(pw, collectionTypes[i], fieldNames, fieldCounter); + else + writeMethodSet(pw, collectionTypes[i], fieldNames, fieldCounter); endClass(pw); pw.close(); @@ -780,49 +785,27 @@ void generateCollections() throws Exception { } } - private void generateMapCollection(String mapName) throws Exception { - final String[] keyTypes1 = {"String"}; - final String[] valueTypes1 = { - "Object", - "SimpleClass", - "SimpleInterface", - "String", - "Date", - "Locale", - "BigDecimal", - "BigInteger", - "Byte", - "Double", - "Float", - "Integer", - "Long", - "Short" - }; - final String[] keyTypes2 = { - "Object", - "SimpleClass", - "SimpleInterface", - "String", - "Date", - "BigDecimal", - "BigInteger", - "Byte", - "Double", - "Float", - "Integer", - "Long", - "Short" - }; - final String[] valueTypes2 = {"String"}; - - final String[][] keyTypes = {keyTypes1, keyTypes2}; - final String[][] valueTypes = {valueTypes1, valueTypes2}; - - String[] classNameArray = { - mapName + "StringKey" + "Collections", mapName + "StringValue" + "Collections" - }; - - for (int i = 0; i < classNameArray.length; i++) { + private void generateMapCollection(String mapName) throws Exception + { + final String [] keyTypes1 = {"String"}; + final String [] valueTypes1 = {"Object", "SimpleClass", "SimpleInterface", "String", + "Date", "Locale", "BigDecimal", "BigInteger", + "Byte", "Double", "Float", "Integer", "Long", + "Short"}; + final String [] keyTypes2 = {"Object", "SimpleClass", "SimpleInterface", "String", + "Date", "BigDecimal", "BigInteger", + "Byte", "Double", "Float", "Integer", "Long", + "Short"}; + final String [] valueTypes2 = {"String"}; + + final String [][] keyTypes = {keyTypes1, keyTypes2}; + final String [][] valueTypes = {valueTypes1, valueTypes2}; + + String [] classNameArray = {mapName + "StringKey" + "Collections", + mapName + "StringValue" + "Collections"}; + + for(int i=0; i < classNameArray.length; i++) + { String classFile = classNameArray[i]; FileOutputStream fout = new FileOutputStream(classFile + ".java"); PrintWriter pw = new PrintWriter(fout); @@ -838,11 +821,11 @@ private void generateMapCollection(String mapName) throws Exception { startXmlMetaData(xmlPw1); startXmlMetaData(xmlPw2); - startXmlClass(xmlPw, classFile, 0); + startXmlClass(xmlPw, classFile, 0); startXmlClass(xmlPw1, classFile, 1); startXmlClass(xmlPw2, classFile, 2); - fillMapCollection(keyTypes[i], valueTypes[i], mapName, pw, xmlPw, xmlPw1, xmlPw2); + fillMapCollection(keyTypes[i], valueTypes[i],mapName, pw, xmlPw, xmlPw1, xmlPw2); endClass(pw); pw.close(); @@ -862,66 +845,43 @@ private void generateMapCollection(String mapName) throws Exception { } } - private void fillMapCollection( - String[] keyTypes, - String[] valueTypes, - String mapName, - PrintWriter pw, - PrintWriter xmlPw, - PrintWriter xmlPw1, - PrintWriter xmlPw2) { - final String[] embeddedKeys = {"", "true", "false"}; - final String[] embeddedValues = embeddedKeys; - final String[] embeddedKeyForFieldSpec = {"", "embedded-key=true", "embedded-key=false"}; - final String[] embeddedValueForFieldSpec = {"", "embedded-value=true", "embedded-value=false"}; - - int fieldCounter = 0; - String fieldNames[] = - new String - [keyTypes.length * embeddedKeys.length * valueTypes.length * embeddedValues.length]; - for (int i = 0; i < keyTypes.length; i++) { - for (int j = 0; j < embeddedKeys.length; j++) { - for (int k = 0; k < valueTypes.length; k++) { - for (int l = 0; l < embeddedValues.length; l++) { - if (keyTypes[i].equals("") - && embeddedKeys[j].equals("") - && valueTypes[k].equals("") - && embeddedValues[l].equals("")) continue; - fieldNames[fieldCounter] = - mapName + "Of" + keyTypes[i] + "_" + valueTypes[k] + fieldCounter; - pw.println(" public " + mapName + " " + fieldNames[fieldCounter] + ";"); - printXmlMapField( - xmlPw, - fieldNames[fieldCounter], - keyTypes[i], - embeddedKeys[j], - valueTypes[k], - embeddedValues[l]); - printXmlMapField( - xmlPw1, - fieldNames[fieldCounter], - keyTypes[i], - embeddedKeys[j], - valueTypes[k], - embeddedValues[l]); - printXmlMapField( - xmlPw2, - fieldNames[fieldCounter], - keyTypes[i], - embeddedKeys[j], - valueTypes[k], - embeddedValues[l]); - buildFieldSpecs( - embeddedKeyForFieldSpec[j] - + " " - + embeddedValueForFieldSpec[l] - + " " - + "public " - + mapName - + " " - + fieldNames[fieldCounter]); // add to the field specs array*/ + private void fillMapCollection(String [] keyTypes, String [] valueTypes, + String mapName, PrintWriter pw, PrintWriter xmlPw, + PrintWriter xmlPw1, PrintWriter xmlPw2) + { + final String [] embeddedKeys = {"", "true", "false"}; + final String [] embeddedValues = embeddedKeys; + final String [] embeddedKeyForFieldSpec = {"", "embedded-key=true", "embedded-key=false"}; + final String [] embeddedValueForFieldSpec = {"", "embedded-value=true", "embedded-value=false"}; + + int fieldCounter=0; + String fieldNames [] = new String [keyTypes.length * embeddedKeys.length + * valueTypes.length * embeddedValues.length]; + for(int i = 0; i < keyTypes.length; i++) + { + for(int j = 0; j < embeddedKeys.length; j++) + { + for(int k = 0; k < valueTypes.length; k++) + { + for(int l = 0; l < embeddedValues.length; l++) + { + if( keyTypes[i].equals("") && embeddedKeys[j].equals("") + && valueTypes[k].equals("") && embeddedValues[l].equals("")) + continue; + fieldNames[fieldCounter] = mapName+ "Of" + keyTypes[i] +"_"+valueTypes[k] + fieldCounter; + pw.println(" public " + mapName +" " + fieldNames[fieldCounter] +";"); + printXmlMapField(xmlPw, fieldNames[fieldCounter], keyTypes[i], embeddedKeys[j], + valueTypes[k], embeddedValues[l]); + printXmlMapField(xmlPw1, fieldNames[fieldCounter], keyTypes[i], embeddedKeys[j], + valueTypes[k], embeddedValues[l]); + printXmlMapField(xmlPw2, fieldNames[fieldCounter], keyTypes[i], embeddedKeys[j], + valueTypes[k], embeddedValues[l]); + buildFieldSpecs(embeddedKeyForFieldSpec[j] + " " + + embeddedValueForFieldSpec[l] + " " + + "public " + mapName +" "+ fieldNames[fieldCounter]); // add to the field specs array*/ fieldCounter++; - } + + } } } } @@ -931,12 +891,16 @@ private void fillMapCollection( writeMethodSet(pw, mapName, fieldNames, fieldCounter); } - public static void main(String[] args) { + public static void main(String[] args) + { ClassGenerator classGenerator = new ClassGenerator(); - try { - classGenerator.generate(); - classGenerator.generateCollections(); - } catch (Exception e) { + try + { + classGenerator.generate(); + classGenerator.generateCollections(); + } + catch (Exception e) + { System.out.println(e); e.printStackTrace(); } diff --git a/tck/src/main/java/org/apache/jdo/tck/util/ConsoleFileOutput.java b/tck/src/main/java/org/apache/jdo/tck/util/ConsoleFileOutput.java index f8761e6db..e0660853e 100644 --- a/tck/src/main/java/org/apache/jdo/tck/util/ConsoleFileOutput.java +++ b/tck/src/main/java/org/apache/jdo/tck/util/ConsoleFileOutput.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -24,56 +24,58 @@ import java.io.PrintStream; /** - * Creates an output stream that delegates to {@link System#out} and to a file output stream. The - * file name of the file output stream is determined by method {@link - * BatchTestRunner#getFileName()}. + * Creates an output stream that delegates to + * {@link System#out} and to a file output stream. + * The file name of the file output stream is determined + * by method {@link BatchTestRunner#getFileName()}. */ class ConsoleFileOutput extends OutputStream { - private String fileName; - private final PrintStream systemOut = System.out; - private FileOutputStream fileOut; - - ConsoleFileOutput() { - this.fileName = BatchTestRunner.getFileName(); - try { - this.fileOut = new FileOutputStream(this.fileName); - } catch (IOException e) { - System.err.println("Cannot create log file " + this.fileName + ". " + e); + private String fileName; + private final PrintStream systemOut = System.out; + private FileOutputStream fileOut; + + ConsoleFileOutput() { + this.fileName = BatchTestRunner.getFileName(); + try { + this.fileOut = new FileOutputStream(this.fileName); + } catch (IOException e) { + System.err.println("Cannot create log file "+this.fileName+". "+e); + } + } + + /* + * @see java.io.OutputStream#write(int) + */ + public void write(int b) throws IOException { + this.systemOut.write(b); + this.fileOut.write(b); + } + + /** + * @see java.io.OutputStream#close() + */ + public void close() throws IOException { + this.fileOut.close(); + this.systemOut.close(); } - } - - /* - * @see java.io.OutputStream#write(int) - */ - public void write(int b) throws IOException { - this.systemOut.write(b); - this.fileOut.write(b); - } - - /** - * @see java.io.OutputStream#close() - */ - public void close() throws IOException { - this.fileOut.close(); - this.systemOut.close(); - } - - /** - * @see java.io.OutputStream#flush() - */ - public void flush() throws IOException { - this.systemOut.flush(); - this.fileOut.flush(); - } - - String getFileName() { - return new File(this.fileName).getName(); - } - String getDirectory() { - String result = new File(this.fileName).getParent(); - if (!result.endsWith(File.separator)) result += File.separator; - return result; - } + /** + * @see java.io.OutputStream#flush() + */ + public void flush() throws IOException { + this.systemOut.flush(); + this.fileOut.flush(); + } + + String getFileName() { + return new File(this.fileName).getName(); + } + + String getDirectory() { + String result = new File(this.fileName).getParent(); + if (!result.endsWith(File.separator)) + result += File.separator; + return result; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/util/ConversionHelper.java b/tck/src/main/java/org/apache/jdo/tck/util/ConversionHelper.java index 8b97208dd..2cae3198c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/util/ConversionHelper.java +++ b/tck/src/main/java/org/apache/jdo/tck/util/ConversionHelper.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -28,138 +28,143 @@ import java.util.Locale; import java.util.Map; import java.util.TimeZone; + import javax.jdo.JDOFatalException; -/** Provides consersion functionality. */ +/** + * Provides consersion functionality. + */ public class ConversionHelper { - /** - * Converts the given value to a {@link java.util.Date}. - * - * @param pattern the pattern - * @param timezone the timezone - * @param locale the locale - * @param value the value - * @return the date - * @throws JDOFatalException if the conversion fails - */ - public static Date toUtilDate(String pattern, String timezone, Locale locale, String value) { - SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale); - formatter.setTimeZone(TimeZone.getTimeZone(timezone)); - try { - return formatter.parse(value); - } catch (ParseException e) { - throw new JDOFatalException("", e); + /** + * Converts the given value to a {@link java.util.Date}. + * @param pattern the pattern + * @param timezone the timezone + * @param locale the locale + * @param value the value + * @return the date + * @throws JDOFatalException if the conversion fails + */ + public static Date toUtilDate(String pattern, + String timezone, Locale locale, String value) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale); + formatter.setTimeZone(TimeZone.getTimeZone(timezone)); + try { + return formatter.parse(value); + } catch (ParseException e) { + throw new JDOFatalException("", e); + } } - } - public static Date toUtilDate(String pattern, Locale locale, String value) { - SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale); - try { - return formatter.parse(value); - } catch (ParseException e) { - throw new JDOFatalException("", e); + public static Date toUtilDate(String pattern, Locale locale, String value) { + SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale); + try { + return formatter.parse(value); + } catch (ParseException e) { + throw new JDOFatalException("", e); + } } - } - /** - * Converts the given array into a {@link Map}. The first dimension represents the map entries, - * the second dimension holds the keys and values, e.g. { {"key1", "value1"}, {"key2", {"value2"} - * }. - * - * @param array the array - * @return the map - */ - public static Map arrayToMap(Object[][] array) { - Map map = new HashMap(); - for (int i = 0; i < array.length; i++) { - map.put(array[i][0], array[i][1]); + /** + * Converts the given array into a {@link Map}. + * The first dimension represents the map entries, + * the second dimension holds the keys and values, e.g. + * { {"key1", "value1"}, {"key2", {"value2"} }. + * @param array the array + * @return the map + */ + public static Map arrayToMap(Object[][] array) { + Map map = new HashMap(); + for (int i = 0; i < array.length; i++) { + map.put(array[i][0], array[i][1]); + } + return map; } - return map; - } - - /** - * Returns a collection containing all elements in the given collection. Recursively - * converts all elements of type Object[] in the given collection to - * collections in the returned collection. - * - * @param collection the collection - * @return the converted collection - */ - public static Collection convertsElementsOfTypeObjectArray(Collection collection) { - Collection result = new ArrayList(); - for (Iterator i = collection.iterator(); i.hasNext(); ) { - Object current = convertObjectArrayElements(i.next()); - result.add(current); + + /** + * Returns a collection containing all elements + * in the given collection. + * Recursively converts all elements of type Object[] + * in the given collection to collections + * in the returned collection. + * @param collection the collection + * @return the converted collection + */ + public static Collection convertsElementsOfTypeObjectArray(Collection collection) { + Collection result = new ArrayList(); + for (Iterator i = collection.iterator(); i.hasNext(); ) { + Object current = convertObjectArrayElements(i.next()); + result.add(current); + } + return result; } - return result; - } - /** - * Returns a map containing all entries in the given map. Recursively converts all - * entries having keys and/or values of type Object[] in the given map - * to collections in the returned map. - * - * @param map the map - * @return the converted map - */ - public static Map convertsElementsOfTypeObjectArray(Map map) { - Map result = new HashMap(); - for (Iterator i = map.entrySet().iterator(); i.hasNext(); ) { - Map.Entry entry = (Map.Entry) i.next(); - Object key = convertObjectArrayElements(entry.getKey()); - Object value = convertObjectArrayElements(entry.getValue()); - result.put(key, value); + /** + * Returns a map containing all entries + * in the given map. + * Recursively converts all entries having keys and/or values + * of type Object[] in the given map to collections + * in the returned map. + * @param map the map + * @return the converted map + */ + public static Map convertsElementsOfTypeObjectArray(Map map) { + Map result = new HashMap(); + for (Iterator i = map.entrySet().iterator(); i.hasNext(); ) { + Map.Entry entry = (Map.Entry) i.next(); + Object key = convertObjectArrayElements(entry.getKey()); + Object value = convertObjectArrayElements(entry.getValue()); + result.put(key, value); + } + return result; } - return result; - } - /** - * Recursively converts all elements of type Object[] Collection, or Map. - * - * @see #convertObjectArrayElements(Object[]) - * @see #convertsElementsOfTypeObjectArray(Collection) - * @see #convertsElementsOfTypeObjectArray(Map) - * @param object the object to convert - * @return the converted parameter - */ - public static Object convertObjectArrayElements(Object object) { - Object result; - if (object instanceof Object[]) { - result = Arrays.asList(convertObjectArrayElements((Object[]) object)); - } else if (object instanceof Collection) { - result = convertsElementsOfTypeObjectArray((Collection) object); - } else if (object instanceof Map) { - result = convertsElementsOfTypeObjectArray((Map) object); - } else { - result = object; + /** + * Recursively converts all elements of type Object[] + * Collection, or Map. + * @see #convertObjectArrayElements(Object[]) + * @see #convertsElementsOfTypeObjectArray(Collection) + * @see #convertsElementsOfTypeObjectArray(Map) + * @param object the object to convert + * @return the converted parameter + */ + public static Object convertObjectArrayElements(Object object) { + Object result; + if (object instanceof Object[]) { + result = Arrays.asList( + convertObjectArrayElements((Object[])object)); + } else if (object instanceof Collection) { + result = convertsElementsOfTypeObjectArray((Collection)object); + } else if (object instanceof Map) { + result = convertsElementsOfTypeObjectArray((Map)object); + } else { + result = object; + } + return result; + } + + /** + * Recursively converts all elements of type Object[] + * in the given array and retuns that array. + * @param array the array + * @return the converted array + */ + public static Object[] convertObjectArrayElements(Object[] array) { + for (int i = 0; i < array.length; i++ ) { + array[i] = convertObjectArrayElements(array[i]); + } + return array; } - return result; - } - /** - * Recursively converts all elements of type Object[] in the given array - * and retuns that array. - * - * @param array the array - * @return the converted array - */ - public static Object[] convertObjectArrayElements(Object[] array) { - for (int i = 0; i < array.length; i++) { - array[i] = convertObjectArrayElements(array[i]); + /** + * Converts the given array to a string array. + * @param array the object array + * @return the string array + */ + public static String[] toStringArray(Object[] array) { + String[] result = new String[array.length]; + System.arraycopy(array, 0, result, 0, result.length); + return result; } - return array; - } - /** - * Converts the given array to a string array. - * - * @param array the object array - * @return the string array - */ - public static String[] toStringArray(Object[] array) { - String[] result = new String[array.length]; - System.arraycopy(array, 0, result, 0, result.length); - return result; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/util/DeepEquality.java b/tck/src/main/java/org/apache/jdo/tck/util/DeepEquality.java index 0997217d1..bf7782cf3 100644 --- a/tck/src/main/java/org/apache/jdo/tck/util/DeepEquality.java +++ b/tck/src/main/java/org/apache/jdo/tck/util/DeepEquality.java @@ -5,62 +5,71 @@ * 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 + * + * 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.jdo.tck.util; +import java.util.Comparator; + /** - * This DeepEquality interface defines a method indicating whether some other object is - * "deep equal to" this object. - * - *

    Two objects are deep equal, if all the fields are deep equal. The sematics of deep equal on - * the fields depends of the field type: - * + * This DeepEquality interface defines a method indicating + * whether some other object is "deep equal to" this object. + *

    + * Two objects are deep equal, if all the fields are deep equal. The + * sematics of deep equal on the fields depends of the field type: *

      - *
    • fields of type boolean or an integral type are deep equal, if they compare - * true using == - *
    • fields of type float and double are deep equal, if they are close - * enough as defined by methods closeEnough provided by class EqualityHelper - *
    • fields of Java wrapper classes are equal if their wrapped primitive values are deep equal - *
    • fields of type BigDecimal are equal, if compareTo returns 0 - *
    • collection fields are deep equal, if they have the same size and their corresponding - * elements compare deep equal after sorting using the natural ordering. - *
    • map fields compare deep equal, if they have the same size and both keys and values compare - * deep equal after sorting the entries using the natural ordering of the keys. - *
    • fields of type DeepEquality are deep equal, if method deepEquals - * returns true - *
    • fields of other types are deep equal, if method equals returns true - * + *
    • fields of type boolean or an integral type are deep + * equal, if they compare true using ==
    • + *
    • fields of type float and double are deep + * equal, if they are close enough as defined by methods closeEnough + * provided by class EqualityHelper
    • + *
    • fields of Java wrapper classes are equal if their wrapped primitive + * values are deep equal
    • + *
    • fields of type BigDecimal are equal, if compareTo returns 0
    • + *
    • collection fields are deep equal, if they have the same size and + * their corresponding elements compare deep equal after sorting using the + * natural ordering.
    • + *
    • map fields compare deep equal, if they have the same size and both + * keys and values compare deep equal after sorting the entries using the + * natural ordering of the keys.
    • + *
    • fields of type DeepEquality are deep equal, if method + * deepEquals returns true
    • + *
    • fields of other types are deep equal, if method equals + * returns true
    • *
    - * - * The EqualityHelper instance passed to the deepEquals method keeps track - * of instances that have already been processed to avoid endless recursion for cyclic data - * structures. + * The EqualityHelper instance passed to the + * deepEquals method keeps track of instances that have + * already been processed to avoid endless recursion for cyclic data + * structures. * * @author Michael Bouschen * @since 1.1 */ public interface DeepEquality { - /** - * Returns true if all the fields of this instance are deep equal to the - * corresponding fields of the other Object. This means that all non-relationship fields are equal - * to the corresponging fields in the other Object, and all relationship fields are deep equal. - * Recursion is stopped in the equality helper method that compares objects. - * - * @param other the object with which to compare. - * @param helper EqualityHelper to keep track of instances that have already been processed. - * @return true if all the fields are deep equal; false otherwise. - * @throws ClassCastException if the specified instances' type prevents it from being compared to - * this instance. - */ - public boolean deepCompareFields(Object other, EqualityHelper helper); + /** + * Returns true if all the fields of this instance are + * deep equal to the corresponding fields of the other Object. This + * means that all non-relationship fields are equal to the + * corresponging fields in the other Object, and all relationship + * fields are deep equal. Recursion is stopped in the equality helper + * method that compares objects. + * @param other the object with which to compare. + * @param helper EqualityHelper to keep track of instances that have + * already been processed. + * @return true if all the fields are deep equal; + * false otherwise. + * @throws ClassCastException if the specified instances' type prevents + * it from being compared to this instance. + */ + public boolean deepCompareFields(Object other, EqualityHelper helper); + } diff --git a/tck/src/main/java/org/apache/jdo/tck/util/EqualityHelper.java b/tck/src/main/java/org/apache/jdo/tck/util/EqualityHelper.java index de0055a6d..280e20fd9 100644 --- a/tck/src/main/java/org/apache/jdo/tck/util/EqualityHelper.java +++ b/tck/src/main/java/org/apache/jdo/tck/util/EqualityHelper.java @@ -5,19 +5,18 @@ * 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 + * + * 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.jdo.tck.util; -import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -27,843 +26,860 @@ import java.util.List; import java.util.Map; import java.util.Stack; + +import java.math.BigDecimal; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** - * This is a utility class to support equality checking. An EqualityHelper object defines the - * context of a deepEquals call, because it keeps track of objects that have already been processed. - * This avoids endless recursion when comparing cyclic data structures for deep equality. - * - *

    Furthermore, EqualityHelper provides convenience methods for checking deep equality, equality - * and close enough (for floating point values). + * This is a utility class to support equality checking. An EqualityHelper + * object defines the context of a deepEquals call, because it keeps track + * of objects that have already been processed. This avoids endless + * recursion when comparing cyclic data structures for deep equality. + *

    + * Furthermore, EqualityHelper provides convenience methods for checking + * deep equality, equality and close enough (for floating point values). * * @author Michael Bouschen - * @since 1.1 + * @since 1.1 */ public class EqualityHelper { + + /** Logger */ + protected Log logger = + LogFactory.getFactory().getInstance("org.apache.jdo.tck"); + + /** true if debug logging in enabled. */ + protected boolean debug = logger.isDebugEnabled(); + + /** Used when comparing float values close enough. */ + public static float FLOAT_EPSILON = (float)Math.pow(2.0, -20.0); + + /** Used when comparing double values close enough. */ + public static double DOUBLE_EPSILON = Math.pow(2.0, -52.0); + + /** Message for null vs. not null */ + static final String msgMeNull = "\nExpected null, actual not null"; + + /** Message for not null vs. null */ + static final String msgOtherNull = "\nExpected not null, actual null"; + + /** Message for incompatible types */ + static final String msgIncompatibleTypes = "\nIncompatible types for comparison"; + + /** Message for wrong class for counting via iterator */ + static final String msgParameterMustBeCollectionOrMap = + "Parameter must be a Collection or Map."; + + /** Comparator used in method deepEquals comparing maps. This comparator + * is used to order Maps whose keys are Comparable so the entries can be + * compared using deepCompareFields. + */ + private static Comparator entryKeyComparator = new Comparator() { + public int compare(Object o1, Object o2) { + Object key1 = ((Map.Entry)o1).getKey(); + Object key2 = ((Map.Entry)o2).getKey(); + return ((Comparable)key1).compareTo(key2); + } + }; + + /** + * Utility counter for maps and collections + */ + static int countIterator(Object o) { + int result = 0; + Iterator it; + if (o instanceof Collection) { + it = ((Collection)o).iterator(); + } else if (o instanceof Map) { + it = ((Map)o).entrySet().iterator(); + } else { + throw new ClassCastException(msgParameterMustBeCollectionOrMap); + } + while (it.hasNext()) { + it.next(); + result++; + } + return result; + } + /** Comparator used in method deepEquals comparing maps of + * DeepEquality. + */ + private static class DeepEqualityEntryKeyComparator + implements Comparator { + Comparator comparator; + DeepEqualityEntryKeyComparator(Comparator comp) { + this.comparator = comparator; + } + public int compare(Object o1, Object o2) { + Object key1 = ((Map.Entry)o1).getKey(); + Object key2 = ((Map.Entry)o2).getKey(); + return comparator.compare(key1, key2); + } + } - /** Logger */ - protected Log logger = LogFactory.getFactory().getInstance("org.apache.jdo.tck"); - - /** true if debug logging in enabled. */ - protected boolean debug = logger.isDebugEnabled(); - - /** Used when comparing float values close enough. */ - public static float FLOAT_EPSILON = (float) Math.pow(2.0, -20.0); - - /** Used when comparing double values close enough. */ - public static double DOUBLE_EPSILON = Math.pow(2.0, -52.0); + /** Collection of instances that have been processed already in the + * context of this EqualityHelper instance + */ + private Collection processed = new HashSet(); + + /** StringBuffer of logged differences. + */ + StringBuffer unequalBuffer = new StringBuffer(); + + /** + * Context is a stack of navigational paths. + */ + Stack contextStack = new Stack(); + + // Methods to support keeping track of instances that have been + // processed already. + + /** Returns true if the specified instance has been + * processed already in the context of this + * EqualityHelper. + * @param obj the instance to be checked. + * @return true if the instance has been processed + * already; false otherwise. + */ + public boolean isProcessed(Object obj) { + return processed.contains(obj); + } + + /** Marks the specified instance as processed in the context of this + * EqualityHelper. This means the instance is added to the + * collection of processed instances. + * @param obj instance marked as processed + */ + public void markProcessed(Object obj) { + processed.add(obj); + } + + /** Clears the collection of processed instances of this + * EqualityHelper. No instance is marked as processed in + * the context of this EqualityHelper after calling this + * method. + */ + public void clearProcessed() { + processed.clear(); + } + + // Deep equality support methods + + /** Returns true if the specified instances are "deep + * equal". + * @param me one object to be tested for deep equality + * @param other the other object to be tested for deep equality + * @return true if the objects are deep equal. + */ + public boolean deepEquals(DeepEquality me, DeepEquality other) { + if (me == other) + return true; + if ((me == null) || (other == null)) + return false; + if (isProcessed(me)) + return true; + markProcessed(me); + return me.deepCompareFields(other, this); + } + + /** Returns true if the specified instances are "deep + * equal". The method compares the two instances via the deepEquals + * method if they implement DeepEquals; compares the two instances via + * deepEquals if they implement Collection or Map, and otherwise + * compares the instances using equals. + * @param me one object to be tested for deep equality + * @param other the other object to be tested for deep equality + * @return true if the objects are deep equal. + */ + public boolean deepEquals(Object me, Object other) { + if (me == other) + return true; + if ((me == null) || (other == null)) + return false; + if ((me instanceof DeepEquality) && (other instanceof DeepEquality)) + return deepEquals((DeepEquality)me, (DeepEquality)other); + if ((me instanceof Collection) && (other instanceof Collection)) + return deepEquals((Collection)me, (Collection)other); + if ((me instanceof Map) && (other instanceof Map)) + return deepEquals((Map)me, (Map)other); + return me.equals(other); + } + + /** Returns true if the specified collections are "deep + * equal". Two collections are deep equal, if they have the same size + * and their corresponding elements are deep equal after sorting + * using the natural ordering of the elements. The method throws a + * ClassCastException if the elements are not Comparable + * or if they are not mutually comparable. + * @param mine one collection to be tested for deep equality + * @param other the other collection to be tested for deep equality + * @return true if the collections are deep equal. + * @throws ClassCastException if the collections contain elements that + * are not mutually comparable. + */ + public boolean deepEquals(Collection mine, Collection other) { + if (mine == other) + return true; + if ((mine == null) || (other == null)) + return false; + + // Return false, if the size differs + if (mine.size() != other.size()) + return false; + + if (mine.size() == 0) + return true; + + // Now check the elements + List myList = new ArrayList(mine); + Collections.sort(myList); + List otherList = new ArrayList(other); + /* Any collection of elements to be compared must implement Comparator + * to avoid the other side having to implement Comparable. */ + Comparator comparator = + (Comparator)myList.get(0); + Collections.sort(otherList, comparator); + for (int i = 0; i < myList.size(); i++) { + if (!deepEquals(myList.get(i), otherList.get(i))) + return false; + } + return true; + } + + /** Returns true if the specified maps are "deep + * equal". Two maps are deep equal, if they have the same size and the + * values of the corresponding keys compare deep equal. The method + * throws a ClassCastException if keys or values are not + * Comparable or if they are not mutually comparable. + * @param mine one map to be tested for deep equality + * @param other the other map to be tested for deep equality + * @return true if the maps are deep equal. + * @throws ClassCastException if the maps contain keys or values that + * are not mutually comparable. + */ + public boolean deepEquals(Map mine, Map other) { + if (mine == other) + return true; + if ((mine == null) || (other == null)) + return false; + + // Return false, if the size differs + if (mine.size() != other.size()) + return false; + + if (mine.size() == 0) + return true; + + // Now check the elements + List myList = new ArrayList(mine.entrySet()); + Collections.sort(myList, entryKeyComparator); + List otherList = new ArrayList(other.entrySet()); + /* Any collection of elements to be compared must implement Comparator + * to avoid the other side having to implement Comparable. */ + Comparator comparator = + (Comparator)((Map.Entry)myList.get(0)).getKey(); + Collections.sort(otherList, + new DeepEqualityEntryKeyComparator(comparator)); + + for (int i = 0; i < myList.size(); i++) { + Map.Entry entry1 = (Map.Entry)myList.get(i); + Map.Entry entry2 = (Map.Entry)otherList.get(i); + // compare the keys + if (!deepEquals(entry1.getKey(), entry2.getKey())) + return false; + // compare the values + if (!deepEquals(entry1.getValue(), entry2.getValue())) + return false; + } + return true; + } + + // Shallow equality support methods + + /** Returns true if the specified collections are "shallow + * equal". Two collections are shallow equal, if they have the same size + * and their corresponding elements are equal after sorting using the + * natural ordering. + * @param mine one collection to be tested for shallow equality + * @param other the other collection to be tested for shallow equality + * @return true if the collections are deep equal. + */ + public boolean shallowEquals(Collection mine, Collection other) { + if (mine == other) + return true; + if ((mine == null) || (other == null)) + return false; + + // Return false, if the size differs + if (mine.size() != other.size()) + return false; + + if (mine.size() == 0) + return true; + + // Now check the elements + List myList = new ArrayList(mine); + Collections.sort(myList); + List otherList = new ArrayList(other); + /* Any collection of elements to be compared must implement Comparator + * to avoid the other side having to implement Comparable. */ + Comparator comparator = + (Comparator)myList.get(0); + Collections.sort(otherList, comparator); + return myList.equals(otherList); + } + + // Deep equality support methods with logging + + public String getUnequalBuffer() { + return unequalBuffer.toString(); + } + + /** + * Context is nested via navigation through relationships. + */ + void pushContext(String ctx) { + contextStack.push(ctx); + } + + String popContext() { + return (String)contextStack.pop(); + } + + /** Log differences between objects that don't compare equal. + * @param o1 the first object + * @param o2 the second object + * @param where the field where the objects are found + */ + void logUnequal(Object o1, Object o2, String where) { + unequalBuffer.append("Context: "); + Iterator it = contextStack.iterator(); + StringBuffer offset = new StringBuffer("\n"); + while (it.hasNext()) { + unequalBuffer.append(it.next()); + unequalBuffer.append("-> "); + offset.append(" "); + } + unequalBuffer.append(where); + unequalBuffer.append(offset.toString()); + unequalBuffer.append("expected '"); + unequalBuffer.append(o1); + unequalBuffer.append("'"); + unequalBuffer.append(offset.toString()); + unequalBuffer.append(" actual '"); + unequalBuffer.append(o2); + unequalBuffer.append("'\n"); + } + + /** Returns true if the specified instances are "deep + * equal". If unequal, log the location of the inequality. + * @param me one object to be tested for deep equality + * @param other the other object to be tested for deep equality + * @param where the location of the inequality (provided by the caller) + * @return true if the objects are deep equal. + */ + public boolean deepEquals(DeepEquality me, Object other, + String where) { + if (me == other) + return true; + if (me == null) { + logUnequal(me, other, where + msgMeNull); + return false; + } + if (other == null) { + logUnequal(me, other, where + msgOtherNull); + return false; + } + if (isProcessed(me)) + return true; + markProcessed(me); + pushContext(where); + boolean result = true; + if (!me.deepCompareFields(other, this)) { + //logUnequal(me, other, where); + result = false; + } + popContext(); + return result; + } + + /** Returns true if the specified instances are "deep + * equal". The method compares the two instances via the deepEquals + * method if they implement DeepEquals; compares the two instances via + * deepEquals if they implement Collection or Map, and otherwise + * compares the instances using equals. + * @param me one object to be tested for deep equality + * @param other the other object to be tested for deep equality + * @param where the location of the inequality (provided by the caller) + * @return true if the objects are deep equal. + */ + public boolean deepEquals(Object me, Object other, String where) { + if (me == other) + return true; + if (me == null) { + logUnequal(me, other, where + msgMeNull); + return false; + } + if (other == null) { + logUnequal(me, other, where + msgOtherNull); + return false; + } + if (me instanceof DeepEquality) { + return deepEquals((DeepEquality)me, other, where); + } else if ((me instanceof Collection) && (other instanceof Collection)) { + return deepEquals((Collection)me, (Collection)other, where); + } else if ((me instanceof Map) && (other instanceof Map)) { + return deepEquals((Map)me, (Map)other, where); + } else { + return equals(me, other, where); + } + } - /** Message for null vs. not null */ - static final String msgMeNull = "\nExpected null, actual not null"; + /** Returns true if the specified collections are "deep + * equal". Two collections are deep equal, if they have the same size + * and their corresponding elements are deep equal after sorting + * using the natural ordering of the elements. The method throws a + * ClassCastException if the elements are not Comparable + * or if they are not mutually comparable. + * @param me one collection to be tested for deep equality + * @param other the other collection to be tested for deep equality + * @param where the location of the inequality (provided by the caller) + * @return true if the collections are deep equal. + * @throws ClassCastException if the collections contain elements that + * are not mutually comparable. + */ + public boolean deepEquals(Collection me, Collection other, + String where) { + if (me == other) + return true; + if (me == null) { + logUnequal(me, other, where + msgMeNull); + return false; + } + if (other == null) { + logUnequal(me, other, where + msgOtherNull); + return false; + } + int mysize = me.size(); + int othersize = other.size(); + // Return false, if the size differs + if (mysize != othersize) { + int count = countIterator(other); + logUnequal(me, other, + where + "\nSize mismatch: expected size= " + me.size() + + ", original size= " + othersize + + ", current size= " + other.size() + + ", counted size= " + count); + return false; + } + + if (mysize == 0) + return true; + + // Now check each element for equality or deep equality + List myList = new ArrayList(me); + // Use the natural ordering of me; must implement Comparable + Collections.sort(myList); + List otherList = new ArrayList(other); + /* Any collection of elements to be compared must implement Comparator + * to avoid the other side having to implement Comparable. */ + Comparator comparator = + (Comparator)myList.get(0); + Collections.sort(otherList, comparator); + boolean result = true; + for (int i = 0; i < myList.size(); i++) { + DeepEquality o1 = (DeepEquality)myList.get(i); + Object o2 = otherList.get(i); + /* Compare corresponding elements of the ordered list. */ + if (!deepEquals(o1, o2, where + "[" + i + "]")) { + result = false; + } + } + return result; + } + + /** Returns true if the specified maps are "deep + * equal". Two maps are deep equal, if they have the same size and the + * values of the corresponding keys compare deep equal. The method + * throws a ClassCastException if keys or values are not + * Comparable or if they are not mutually comparable. + * @param me one map to be tested for deep equality + * @param other the other map to be tested for deep equality + * @param where the location of the inequality (provided by the caller) + * @return true if the maps are deep equal. + * @throws ClassCastException if the maps contain keys or values that + * are not mutually comparable. + */ + public boolean deepEquals(Map me, Map other, String where) { + if (me == other) + return true; + if (me == null) { + logUnequal(me, other, where + msgMeNull); + return false; + } + if (other == null) { + logUnequal(me, other, where + msgOtherNull); + return false; + } - /** Message for not null vs. null */ - static final String msgOtherNull = "\nExpected not null, actual null"; + // Return false, if the size differs + int mysize = me.size(); + int othersize = other.size(); + if (mysize != othersize) { + int count = countIterator(other); + logUnequal(me, other, + where + "\nSize mismatch: expected size= " + me.size() + + ", original size= " + othersize + + ", current size= " + other.size() + + ", counted size= " + count); + return false; + } - /** Message for incompatible types */ - static final String msgIncompatibleTypes = "\nIncompatible types for comparison"; + if (mysize == 0) + return true; + + // Now check the elements + List myList = new ArrayList(me.entrySet()); + // Use the natural ordering of me; must implement Comparable + Collections.sort(myList, entryKeyComparator); + List otherList = new ArrayList(other.entrySet()); + Comparator comparator = entryKeyComparator; + // Use the Comparator to avoid the other side implementing Comparable + Object key = ((Map.Entry)myList.get(0)).getKey(); + if (key instanceof Comparator) { + comparator = new DeepEqualityEntryKeyComparator((Comparator)key); + } + Collections.sort(otherList, comparator); + + boolean result = true; + for (int i = 0; i < myList.size(); i++) { + Map.Entry entry1 = (Map.Entry)myList.get(i); + Object key1 = entry1.getKey(); + Object value1 = entry1.getValue(); + Map.Entry entry2 = (Map.Entry)otherList.get(i); + Object key2 = entry2.getKey(); + Object value2 = entry2.getValue(); + // compare the keys + if (!deepEquals(key1, key2, where + "[" + i + "].key")) { + result = false; + } + // compare the values + if (!deepEquals(value1, value2, where + "[" + i + "].value")) { + result = false; + } + } + return result; + } + + // Shallow equality support methods + + /** Returns true if the specified collections are "shallow + * equal". Two collections are shallow equal, if they have the same size + * and their corresponding elements are equal after sorting using the + * natural ordering. + * @param me one collection to be tested for shallow equality + * @param other the other collection to be tested for shallow equality + * @param where the location of the inequality (provided by the caller) + * @return true if the collections are deep equal. + */ + public boolean shallowEquals(Collection me, Collection other, + String where) { + if (me == other) + return true; + if (me == null) { + logUnequal(me, other, where + msgMeNull); + return false; + } + if (other == null) { + logUnequal(me, other, where + msgOtherNull); + return false; + } - /** Message for wrong class for counting via iterator */ - static final String msgParameterMustBeCollectionOrMap = "Parameter must be a Collection or Map."; + // Return false, if the size differs + int mysize = me.size(); + int othersize = other.size(); + if (mysize != othersize) { + // debug size... + Iterator it = other.iterator(); + int count = 0; + while (it.hasNext()) { it.next(); ++count; } + logUnequal(me, other, + where + "\nSize mismatch: expected size= " + me.size() + + ", original size= " + othersize + + ", current size= " + other.size() + + ", counted size= " + count); + return false; + } - /** - * Comparator used in method deepEquals comparing maps. This comparator is used to order Maps - * whose keys are Comparable so the entries can be compared using deepCompareFields. - */ - private static Comparator entryKeyComparator = - new Comparator() { - public int compare(Object o1, Object o2) { - Object key1 = ((Map.Entry) o1).getKey(); - Object key2 = ((Map.Entry) o2).getKey(); - return ((Comparable) key1).compareTo(key2); - } - }; - - /** Utility counter for maps and collections */ - static int countIterator(Object o) { - int result = 0; - Iterator it; - if (o instanceof Collection) { - it = ((Collection) o).iterator(); - } else if (o instanceof Map) { - it = ((Map) o).entrySet().iterator(); - } else { - throw new ClassCastException(msgParameterMustBeCollectionOrMap); - } - while (it.hasNext()) { - it.next(); - result++; - } - return result; - } - /** Comparator used in method deepEquals comparing maps of DeepEquality. */ - private static class DeepEqualityEntryKeyComparator implements Comparator { - Comparator comparator; - - DeepEqualityEntryKeyComparator(Comparator comp) { - this.comparator = comparator; - } - - public int compare(Object o1, Object o2) { - Object key1 = ((Map.Entry) o1).getKey(); - Object key2 = ((Map.Entry) o2).getKey(); - return comparator.compare(key1, key2); - } - } - - /** - * Collection of instances that have been processed already in the context of this EqualityHelper - * instance - */ - private Collection processed = new HashSet(); - - /** StringBuffer of logged differences. */ - StringBuffer unequalBuffer = new StringBuffer(); - - /** Context is a stack of navigational paths. */ - Stack contextStack = new Stack(); - - // Methods to support keeping track of instances that have been - // processed already. - - /** - * Returns true if the specified instance has been processed already in the context - * of this EqualityHelper. - * - * @param obj the instance to be checked. - * @return true if the instance has been processed already; false - * otherwise. - */ - public boolean isProcessed(Object obj) { - return processed.contains(obj); - } - - /** - * Marks the specified instance as processed in the context of this EqualityHelper. - * This means the instance is added to the collection of processed instances. - * - * @param obj instance marked as processed - */ - public void markProcessed(Object obj) { - processed.add(obj); - } - - /** - * Clears the collection of processed instances of this EqualityHelper. No instance - * is marked as processed in the context of this EqualityHelper after calling this - * method. - */ - public void clearProcessed() { - processed.clear(); - } - - // Deep equality support methods - - /** - * Returns true if the specified instances are "deep equal". - * - * @param me one object to be tested for deep equality - * @param other the other object to be tested for deep equality - * @return true if the objects are deep equal. - */ - public boolean deepEquals(DeepEquality me, DeepEquality other) { - if (me == other) return true; - if ((me == null) || (other == null)) return false; - if (isProcessed(me)) return true; - markProcessed(me); - return me.deepCompareFields(other, this); - } - - /** - * Returns true if the specified instances are "deep equal". The method compares the - * two instances via the deepEquals method if they implement DeepEquals; compares the two - * instances via deepEquals if they implement Collection or Map, and otherwise compares the - * instances using equals. - * - * @param me one object to be tested for deep equality - * @param other the other object to be tested for deep equality - * @return true if the objects are deep equal. - */ - public boolean deepEquals(Object me, Object other) { - if (me == other) return true; - if ((me == null) || (other == null)) return false; - if ((me instanceof DeepEquality) && (other instanceof DeepEquality)) - return deepEquals((DeepEquality) me, (DeepEquality) other); - if ((me instanceof Collection) && (other instanceof Collection)) - return deepEquals((Collection) me, (Collection) other); - if ((me instanceof Map) && (other instanceof Map)) return deepEquals((Map) me, (Map) other); - return me.equals(other); - } - - /** - * Returns true if the specified collections are "deep equal". Two collections are - * deep equal, if they have the same size and their corresponding elements are deep equal after - * sorting using the natural ordering of the elements. The method throws a - * ClassCastException if the elements are not Comparable or if they are not mutually - * comparable. - * - * @param mine one collection to be tested for deep equality - * @param other the other collection to be tested for deep equality - * @return true if the collections are deep equal. - * @throws ClassCastException if the collections contain elements that are not mutually - * comparable. - */ - public boolean deepEquals(Collection mine, Collection other) { - if (mine == other) return true; - if ((mine == null) || (other == null)) return false; - - // Return false, if the size differs - if (mine.size() != other.size()) return false; - - if (mine.size() == 0) return true; - - // Now check the elements - List myList = new ArrayList(mine); - Collections.sort(myList); - List otherList = new ArrayList(other); - /* Any collection of elements to be compared must implement Comparator - * to avoid the other side having to implement Comparable. */ - Comparator comparator = (Comparator) myList.get(0); - Collections.sort(otherList, comparator); - for (int i = 0; i < myList.size(); i++) { - if (!deepEquals(myList.get(i), otherList.get(i))) return false; - } - return true; - } - - /** - * Returns true if the specified maps are "deep equal". Two maps are deep equal, if - * they have the same size and the values of the corresponding keys compare deep equal. The method - * throws a ClassCastException if keys or values are not Comparable or if they are - * not mutually comparable. - * - * @param mine one map to be tested for deep equality - * @param other the other map to be tested for deep equality - * @return true if the maps are deep equal. - * @throws ClassCastException if the maps contain keys or values that are not mutually comparable. - */ - public boolean deepEquals(Map mine, Map other) { - if (mine == other) return true; - if ((mine == null) || (other == null)) return false; - - // Return false, if the size differs - if (mine.size() != other.size()) return false; - - if (mine.size() == 0) return true; - - // Now check the elements - List myList = new ArrayList(mine.entrySet()); - Collections.sort(myList, entryKeyComparator); - List otherList = new ArrayList(other.entrySet()); - /* Any collection of elements to be compared must implement Comparator - * to avoid the other side having to implement Comparable. */ - Comparator comparator = (Comparator) ((Map.Entry) myList.get(0)).getKey(); - Collections.sort(otherList, new DeepEqualityEntryKeyComparator(comparator)); - - for (int i = 0; i < myList.size(); i++) { - Map.Entry entry1 = (Map.Entry) myList.get(i); - Map.Entry entry2 = (Map.Entry) otherList.get(i); - // compare the keys - if (!deepEquals(entry1.getKey(), entry2.getKey())) return false; - // compare the values - if (!deepEquals(entry1.getValue(), entry2.getValue())) return false; - } - return true; - } - - // Shallow equality support methods - - /** - * Returns true if the specified collections are "shallow equal". Two collections are - * shallow equal, if they have the same size and their corresponding elements are equal after - * sorting using the natural ordering. - * - * @param mine one collection to be tested for shallow equality - * @param other the other collection to be tested for shallow equality - * @return true if the collections are deep equal. - */ - public boolean shallowEquals(Collection mine, Collection other) { - if (mine == other) return true; - if ((mine == null) || (other == null)) return false; - - // Return false, if the size differs - if (mine.size() != other.size()) return false; - - if (mine.size() == 0) return true; - - // Now check the elements - List myList = new ArrayList(mine); - Collections.sort(myList); - List otherList = new ArrayList(other); - /* Any collection of elements to be compared must implement Comparator - * to avoid the other side having to implement Comparable. */ - Comparator comparator = (Comparator) myList.get(0); - Collections.sort(otherList, comparator); - return myList.equals(otherList); - } - - // Deep equality support methods with logging - - public String getUnequalBuffer() { - return unequalBuffer.toString(); - } - - /** Context is nested via navigation through relationships. */ - void pushContext(String ctx) { - contextStack.push(ctx); - } - - String popContext() { - return (String) contextStack.pop(); - } - - /** - * Log differences between objects that don't compare equal. - * - * @param o1 the first object - * @param o2 the second object - * @param where the field where the objects are found - */ - void logUnequal(Object o1, Object o2, String where) { - unequalBuffer.append("Context: "); - Iterator it = contextStack.iterator(); - StringBuffer offset = new StringBuffer("\n"); - while (it.hasNext()) { - unequalBuffer.append(it.next()); - unequalBuffer.append("-> "); - offset.append(" "); - } - unequalBuffer.append(where); - unequalBuffer.append(offset.toString()); - unequalBuffer.append("expected '"); - unequalBuffer.append(o1); - unequalBuffer.append("'"); - unequalBuffer.append(offset.toString()); - unequalBuffer.append(" actual '"); - unequalBuffer.append(o2); - unequalBuffer.append("'\n"); - } - - /** - * Returns true if the specified instances are "deep equal". If unequal, log the - * location of the inequality. - * - * @param me one object to be tested for deep equality - * @param other the other object to be tested for deep equality - * @param where the location of the inequality (provided by the caller) - * @return true if the objects are deep equal. - */ - public boolean deepEquals(DeepEquality me, Object other, String where) { - if (me == other) return true; - if (me == null) { - logUnequal(me, other, where + msgMeNull); - return false; - } - if (other == null) { - logUnequal(me, other, where + msgOtherNull); - return false; - } - if (isProcessed(me)) return true; - markProcessed(me); - pushContext(where); - boolean result = true; - if (!me.deepCompareFields(other, this)) { - // logUnequal(me, other, where); - result = false; - } - popContext(); - return result; - } - - /** - * Returns true if the specified instances are "deep equal". The method compares the - * two instances via the deepEquals method if they implement DeepEquals; compares the two - * instances via deepEquals if they implement Collection or Map, and otherwise compares the - * instances using equals. - * - * @param me one object to be tested for deep equality - * @param other the other object to be tested for deep equality - * @param where the location of the inequality (provided by the caller) - * @return true if the objects are deep equal. - */ - public boolean deepEquals(Object me, Object other, String where) { - if (me == other) return true; - if (me == null) { - logUnequal(me, other, where + msgMeNull); - return false; - } - if (other == null) { - logUnequal(me, other, where + msgOtherNull); - return false; - } - if (me instanceof DeepEquality) { - return deepEquals((DeepEquality) me, other, where); - } else if ((me instanceof Collection) && (other instanceof Collection)) { - return deepEquals((Collection) me, (Collection) other, where); - } else if ((me instanceof Map) && (other instanceof Map)) { - return deepEquals((Map) me, (Map) other, where); - } else { - return equals(me, other, where); - } - } - - /** - * Returns true if the specified collections are "deep equal". Two collections are - * deep equal, if they have the same size and their corresponding elements are deep equal after - * sorting using the natural ordering of the elements. The method throws a - * ClassCastException if the elements are not Comparable or if they are not mutually - * comparable. - * - * @param me one collection to be tested for deep equality - * @param other the other collection to be tested for deep equality - * @param where the location of the inequality (provided by the caller) - * @return true if the collections are deep equal. - * @throws ClassCastException if the collections contain elements that are not mutually - * comparable. - */ - public boolean deepEquals(Collection me, Collection other, String where) { - if (me == other) return true; - if (me == null) { - logUnequal(me, other, where + msgMeNull); - return false; - } - if (other == null) { - logUnequal(me, other, where + msgOtherNull); - return false; - } - int mysize = me.size(); - int othersize = other.size(); - // Return false, if the size differs - if (mysize != othersize) { - int count = countIterator(other); - logUnequal( - me, - other, - where - + "\nSize mismatch: expected size= " - + me.size() - + ", original size= " - + othersize - + ", current size= " - + other.size() - + ", counted size= " - + count); - return false; - } - - if (mysize == 0) return true; - - // Now check each element for equality or deep equality - List myList = new ArrayList(me); - // Use the natural ordering of me; must implement Comparable - Collections.sort(myList); - List otherList = new ArrayList(other); - /* Any collection of elements to be compared must implement Comparator - * to avoid the other side having to implement Comparable. */ - Comparator comparator = (Comparator) myList.get(0); - Collections.sort(otherList, comparator); - boolean result = true; - for (int i = 0; i < myList.size(); i++) { - DeepEquality o1 = (DeepEquality) myList.get(i); - Object o2 = otherList.get(i); - /* Compare corresponding elements of the ordered list. */ - if (!deepEquals(o1, o2, where + "[" + i + "]")) { - result = false; - } - } - return result; - } - - /** - * Returns true if the specified maps are "deep equal". Two maps are deep equal, if - * they have the same size and the values of the corresponding keys compare deep equal. The method - * throws a ClassCastException if keys or values are not Comparable or if they are - * not mutually comparable. - * - * @param me one map to be tested for deep equality - * @param other the other map to be tested for deep equality - * @param where the location of the inequality (provided by the caller) - * @return true if the maps are deep equal. - * @throws ClassCastException if the maps contain keys or values that are not mutually comparable. - */ - public boolean deepEquals(Map me, Map other, String where) { - if (me == other) return true; - if (me == null) { - logUnequal(me, other, where + msgMeNull); - return false; - } - if (other == null) { - logUnequal(me, other, where + msgOtherNull); - return false; - } - - // Return false, if the size differs - int mysize = me.size(); - int othersize = other.size(); - if (mysize != othersize) { - int count = countIterator(other); - logUnequal( - me, - other, - where - + "\nSize mismatch: expected size= " - + me.size() - + ", original size= " - + othersize - + ", current size= " - + other.size() - + ", counted size= " - + count); - return false; - } - - if (mysize == 0) return true; - - // Now check the elements - List myList = new ArrayList(me.entrySet()); - // Use the natural ordering of me; must implement Comparable - Collections.sort(myList, entryKeyComparator); - List otherList = new ArrayList(other.entrySet()); - Comparator comparator = entryKeyComparator; - // Use the Comparator to avoid the other side implementing Comparable - Object key = ((Map.Entry) myList.get(0)).getKey(); - if (key instanceof Comparator) { - comparator = new DeepEqualityEntryKeyComparator((Comparator) key); - } - Collections.sort(otherList, comparator); - - boolean result = true; - for (int i = 0; i < myList.size(); i++) { - Map.Entry entry1 = (Map.Entry) myList.get(i); - Object key1 = entry1.getKey(); - Object value1 = entry1.getValue(); - Map.Entry entry2 = (Map.Entry) otherList.get(i); - Object key2 = entry2.getKey(); - Object value2 = entry2.getValue(); - // compare the keys - if (!deepEquals(key1, key2, where + "[" + i + "].key")) { - result = false; - } - // compare the values - if (!deepEquals(value1, value2, where + "[" + i + "].value")) { - result = false; - } - } - return result; - } - - // Shallow equality support methods - - /** - * Returns true if the specified collections are "shallow equal". Two collections are - * shallow equal, if they have the same size and their corresponding elements are equal after - * sorting using the natural ordering. - * - * @param me one collection to be tested for shallow equality - * @param other the other collection to be tested for shallow equality - * @param where the location of the inequality (provided by the caller) - * @return true if the collections are deep equal. - */ - public boolean shallowEquals(Collection me, Collection other, String where) { - if (me == other) return true; - if (me == null) { - logUnequal(me, other, where + msgMeNull); - return false; - } - if (other == null) { - logUnequal(me, other, where + msgOtherNull); - return false; - } - - // Return false, if the size differs - int mysize = me.size(); - int othersize = other.size(); - if (mysize != othersize) { - // debug size... - Iterator it = other.iterator(); - int count = 0; - while (it.hasNext()) { - it.next(); - ++count; - } - logUnequal( - me, - other, - where - + "\nSize mismatch: expected size= " - + me.size() - + ", original size= " - + othersize - + ", current size= " - + other.size() - + ", counted size= " - + count); - return false; - } - - if (me.size() == 0) return true; - - // Now check the elements - List myList = new ArrayList(me); - Collections.sort(myList); - List otherList = new ArrayList(other); - /* Any collection of elements to be compared must implement Comparator - * to avoid the other side having to implement Comparable. */ - Comparator comparator = (Comparator) myList.get(0); - Collections.sort(otherList, comparator); - boolean result = myList.equals(otherList); - if (!result) logUnequal(me, other, where + "\nCollections do not compare equal"); - return result; - } - - // Equality support methods - - /** - * Returns true if the specified objects are equal. This is a helper method checking - * for identical and null objects before delegating to the regular equals method. - * - * @param o1 one object to be tested for equality - * @param o2 the other object to be tested for equality - * @param where the location of the inequality (provided by the caller) - * @return true if the specified objects are equal. - */ - public boolean equals(Object o1, Object o2, String where) { - if (o1 == o2) return true; - if (o1 == null) { - logUnequal(o1, o2, where + msgMeNull); - return false; - } - if (o2 == null) { - logUnequal(o1, o2, where + msgOtherNull); - return false; - } - if (!o1.equals(o2)) { - logUnequal(o1, o2, where); - return false; - } - return true; - } - - /** - * Returns true, if compare called for the specified BigDecimal objects returns - * 0. Please note, two BigDecimal instances are not equal (using equals) if their - * scale differs, and this method compares the values, ignoring scale. - * - * @param o1 one object to be tested for equality - * @param o2 the other object to be tested for equality - * @param where the location of the inequality (provided by the caller) - * @return true if the specified BigDecimal objects are equal. - */ - public boolean equals(BigDecimal o1, BigDecimal o2, String where) { - if (o1 == o2) return true; - if ((o1 == null) || (o2 == null)) { - logUnequal(o1, o2, where); - return false; - } - boolean result = o1.equals(o2); - if (!result) logUnequal(o1, o2, where); - return result; - } - - /** - * Returns true, if two parameters are equal. - * - * @param p1 one to be tested for equality - * @param p2 the other to be tested for equality - * @param where the location of the inequality (provided by the caller) - * @return true if the parameters are equal. - */ - public boolean equals(boolean p1, boolean p2, String where) { - if (p1 != p2) { - logUnequal(Boolean.toString(p1), Boolean.toString(p2), where); - return false; - } - return true; - } - - /** - * Returns true, if two parameters are equal. - * - * @param p1 one to be tested for equality - * @param p2 the other to be tested for equality - * @param where the location of the inequality (provided by the caller) - * @return true if the parameters are equal. - */ - public boolean equals(char p1, char p2, String where) { - if (p1 != p2) { - logUnequal(Character.toString(p1), Character.toString(p2), where); - return false; - } - return true; - } - - /** - * Returns true, if two parameters are equal. - * - * @param p1 one to be tested for equality - * @param p2 the other to be tested for equality - * @param where the location of the inequality (provided by the caller) - * @return true if the parameters are equal. - */ - public boolean equals(byte p1, byte p2, String where) { - if (p1 != p2) { - logUnequal(Byte.toString(p1), Byte.toString(p2), where); - return false; - } - return true; - } - - /** - * Returns true, if two parameters are equal. - * - * @param p1 one to be tested for equality - * @param p2 the other to be tested for equality - * @param where the location of the inequality (provided by the caller) - * @return true if the parameters are equal. - */ - public boolean equals(short p1, short p2, String where) { - if (p1 != p2) { - logUnequal(Short.toString(p1), Short.toString(p2), where); - return false; - } - return true; - } - - /** - * Returns true, if two parameters are equal. - * - * @param p1 one to be tested for equality - * @param p2 the other to be tested for equality - * @param where the location of the inequality (provided by the caller) - * @return true if the parameters are equal. - */ - public boolean equals(int p1, int p2, String where) { - if (p1 != p2) { - logUnequal(Integer.toString(p1), Integer.toString(p2), where); - return false; - } - return true; - } - - /** - * Returns true, if two parameters are equal. - * - * @param p1 one to be tested for equality - * @param p2 the other to be tested for equality - * @param where the location of the inequality (provided by the caller) - * @return true if the parameters are equal. - */ - public boolean equals(long p1, long p2, String where) { - if (p1 != p2) { - logUnequal(Long.toString(p1), Long.toString(p2), where); - return false; - } - return true; - } - - /** - * Returns true if the specified objects are equal. This is a helper method checking - * for identical and null objects before delegating to the regular equals method. - * - * @param o1 one object to be tested for equality - * @param o2 the other object to be tested for equality - * @return true if the specified objects are equal. - */ - public static boolean equals(Object o1, Object o2) { - if (o1 == o2) { - return true; - } - if (o1 == null || o2 == null) { - return false; - } - return o1.equals(o2); - } - - // Methods to support "close enough" comparison - - /** - * Returns true if the specified objects are close enough to be considered to be - * equal for a deep equals comparison. The method delegates to the method taking double or float - * values if the specified objects are Float or Double wrappers. Otherwise it delegates to equals. - * - * @param o1 one object to be tested for close enough - * @param o2 the other object to be tested for close enough - * @param where the location of the inequality (provided by the caller) - * @return true if the specified values are close enough. - */ - public boolean closeEnough(Object o1, Object o2, String where) { - if (o1 == o2) return true; - if ((o1 == null) || (o2 == null)) { - logUnequal(o1, o2, where); - return false; - } - boolean result = true; - if ((o1 instanceof Double) && (o2 instanceof Double)) { - return closeEnough(((Double) o1).doubleValue(), ((Double) o2).doubleValue(), where); - } else if ((o1 instanceof Float) && (o2 instanceof Float)) { - return closeEnough(((Float) o1).floatValue(), ((Float) o2).floatValue(), where); - } else if ((o1 instanceof BigDecimal) && (o2 instanceof BigDecimal)) { - return ((BigDecimal) o1).compareTo((BigDecimal) o2) == 0; - } else { - result = o1.equals(o2); - } - if (!result) logUnequal(o1, o2, where); - return result; - } - - /** - * Returns true if the specified float values are close enough to be considered to be - * equal for a deep equals comparison. Floating point values are not exact, so comparing them - * using == might not return useful results. This method checks that both double - * values are within some percent of each other. - * - * @param d1 one double to be tested for close enough - * @param d2 the other double to be tested for close enough - * @param where the location of the inequality (provided by the caller) - * @return true if the specified values are close enough. - */ - public boolean closeEnough(double d1, double d2, String where) { - if (d1 == d2) return true; - - double diff = Math.abs(d1 - d2); - boolean result = diff < Math.abs((d1 + d2) * DOUBLE_EPSILON); - if (!result) logUnequal(Double.toString(d1), Double.toString(d2), where); - return result; - } - - /** - * Returns true if the specified float values are close enough to be considered to be - * equal for a deep equals comparison. Floating point values are not exact, so comparing them - * using == might not return useful results. This method checks that both float - * values are within some percent of each other. - * - * @param f1 one float to be tested for close enough - * @param f2 the other float to be tested for close enough - * @param where the location of the inequality (provided by the caller) - * @return true if the specified values are close enough. - */ - public boolean closeEnough(float f1, float f2, String where) { - if (f1 == f2) return true; - - float diff = Math.abs(f1 - f2); - boolean result = diff < Math.abs((f1 + f2) * FLOAT_EPSILON); - if (!result) logUnequal(Float.toString(f1), Float.toString(f2), where); - return result; - } - - // Methods to support compare methods as specified in Comparator - - /** - * Compares its two arguments for order. Returns a negative integer, zero, or a positive integer - * as the first argument is less than, equal to, or greater than the second. - * - * @param l1 the first long to be compared - * @param l2 the second long to be compared - * @return a negative integer, zero, or a positive integer as the first argument is less than, - * equal to, or greater than the second. - */ - public static int compare(long l1, long l2) { - return (l1 < l2 ? -1 : (l1 == l2 ? 0 : 1)); - } + if (me.size() == 0) + return true; + + // Now check the elements + List myList = new ArrayList(me); + Collections.sort(myList); + List otherList = new ArrayList(other); + /* Any collection of elements to be compared must implement Comparator + * to avoid the other side having to implement Comparable. */ + Comparator comparator = + (Comparator)myList.get(0); + Collections.sort(otherList, comparator); + boolean result = myList.equals(otherList); + if (!result) + logUnequal(me, other, + where + "\nCollections do not compare equal"); + return result; + } + + // Equality support methods + + /** Returns true if the specified objects are equal. + * This is a helper method checking for identical and null + * objects before delegating to the regular equals method. + * @param o1 one object to be tested for equality + * @param o2 the other object to be tested for equality + * @param where the location of the inequality (provided by the caller) + * @return true if the specified objects are equal. + */ + public boolean equals(Object o1, Object o2, String where) { + if (o1 == o2) + return true; + if (o1 == null) { + logUnequal(o1, o2, where + msgMeNull); + return false; + } + if (o2 == null) { + logUnequal(o1, o2, where + msgOtherNull); + return false; + } + if (!o1.equals(o2)) { + logUnequal(o1, o2, where); + return false; + } + return true; + } + + /** Returns true, if compare called for the specified + * BigDecimal objects returns 0. Please note, two + * BigDecimal instances are not equal (using equals) if their scale + * differs, and this method compares the values, ignoring scale. + * @param o1 one object to be tested for equality + * @param o2 the other object to be tested for equality + * @param where the location of the inequality (provided by the caller) + * @return true if the specified BigDecimal objects are + * equal. + */ + public boolean equals(BigDecimal o1, BigDecimal o2, String where) { + if (o1 == o2) + return true; + if ((o1 == null) || (o2 == null)) { + logUnequal(o1, o2, where); + return false; + } + boolean result = o1.equals(o2); + if (!result) + logUnequal(o1, o2, where); + return result; + } + + /** Returns true, if two parameters are equal. + * @param p1 one to be tested for equality + * @param p2 the other to be tested for equality + * @param where the location of the inequality (provided by the caller) + * @return true if the parameters are equal. + */ + public boolean equals(boolean p1, boolean p2, String where) { + if (p1 != p2) { + logUnequal(Boolean.toString(p1), Boolean.toString(p2), where); + return false; + } + return true; + } + + /** Returns true, if two parameters are equal. + * @param p1 one to be tested for equality + * @param p2 the other to be tested for equality + * @param where the location of the inequality (provided by the caller) + * @return true if the parameters are equal. + */ + public boolean equals(char p1, char p2, String where) { + if (p1 != p2) { + logUnequal(Character.toString(p1), Character.toString(p2), where); + return false; + } + return true; + } + + /** Returns true, if two parameters are equal. + * @param p1 one to be tested for equality + * @param p2 the other to be tested for equality + * @param where the location of the inequality (provided by the caller) + * @return true if the parameters are equal. + */ + public boolean equals(byte p1, byte p2, String where) { + if (p1 != p2) { + logUnequal(Byte.toString(p1), Byte.toString(p2), where); + return false; + } + return true; + } + + /** Returns true, if two parameters are equal. + * @param p1 one to be tested for equality + * @param p2 the other to be tested for equality + * @param where the location of the inequality (provided by the caller) + * @return true if the parameters are equal. + */ + public boolean equals(short p1, short p2, String where) { + if (p1 != p2) { + logUnequal(Short.toString(p1), Short.toString(p2), where); + return false; + } + return true; + } + + /** Returns true, if two parameters are equal. + * @param p1 one to be tested for equality + * @param p2 the other to be tested for equality + * @param where the location of the inequality (provided by the caller) + * @return true if the parameters are equal. + */ + public boolean equals(int p1, int p2, String where) { + if (p1 != p2) { + logUnequal(Integer.toString(p1), Integer.toString(p2), where); + return false; + } + return true; + } + + /** Returns true, if two parameters are equal. + * @param p1 one to be tested for equality + * @param p2 the other to be tested for equality + * @param where the location of the inequality (provided by the caller) + * @return true if the parameters are equal. + */ + public boolean equals(long p1, long p2, String where) { + if (p1 != p2) { + logUnequal(Long.toString(p1), Long.toString(p2), where); + return false; + } + return true; + } + + /** Returns true if the specified objects are equal. + * This is a helper method checking for identical and null + * objects before delegating to the regular equals method. + * @param o1 one object to be tested for equality + * @param o2 the other object to be tested for equality + * @return true if the specified objects are equal. + */ + public static boolean equals(Object o1, Object o2) { + if (o1 == o2) { + return true; + } + if (o1 == null || o2 == null) { + return false; + } + return o1.equals(o2); + } + + // Methods to support "close enough" comparison + + /** Returns true if the specified objects are close + * enough to be considered to be equal for a deep equals + * comparison. The method delegates to the method taking double + * or float values if the specified objects are Float or Double + * wrappers. Otherwise it delegates to equals. + * @param o1 one object to be tested for close enough + * @param o2 the other object to be tested for close enough + * @param where the location of the inequality (provided by the caller) + * @return true if the specified values are close enough. + */ + public boolean closeEnough(Object o1, Object o2, String where) { + if (o1 == o2) + return true; + if ((o1 == null) || (o2 == null)) { + logUnequal(o1, o2, where); + return false; + } + boolean result = true; + if ((o1 instanceof Double) && (o2 instanceof Double)) { + return closeEnough(((Double)o1).doubleValue(), + ((Double)o2).doubleValue(), where); + } + else if ((o1 instanceof Float) && (o2 instanceof Float)) { + return closeEnough(((Float)o1).floatValue(), + ((Float)o2).floatValue(), where); + } + else if ((o1 instanceof BigDecimal) && (o2 instanceof BigDecimal)) { + return ((BigDecimal)o1).compareTo((BigDecimal)o2) == 0; + } + else { + result = o1.equals(o2); + } + if (!result) + logUnequal(o1, o2, where); + return result; + } + + /** Returns true if the specified float values are close + * enough to be considered to be equal for a deep equals + * comparison. Floating point values are not exact, so comparing them + * using == might not return useful results. This method + * checks that both double values are within some percent of each + * other. + * @param d1 one double to be tested for close enough + * @param d2 the other double to be tested for close enough + * @param where the location of the inequality (provided by the caller) + * @return true if the specified values are close enough. + */ + public boolean closeEnough(double d1, double d2, String where) { + if (d1 == d2) + return true; + + double diff = Math.abs(d1 - d2); + boolean result = diff < Math.abs((d1 + d2) * DOUBLE_EPSILON); + if (!result) + logUnequal(Double.toString(d1), Double.toString(d2), where); + return result; + } + + /** + * Returns true if the specified float values are close + * enough to be considered to be equal for a deep equals + * comparison. Floating point values are not exact, so comparing them + * using == might not return useful results. This method + * checks that both float values are within some percent of each + * other. + * @param f1 one float to be tested for close enough + * @param f2 the other float to be tested for close enough + * @param where the location of the inequality (provided by the caller) + * @return true if the specified values are close enough. + */ + public boolean closeEnough(float f1, float f2, String where) { + if (f1 == f2) + return true; + + float diff = Math.abs(f1 - f2); + boolean result = diff < Math.abs((f1 + f2) * FLOAT_EPSILON); + if (!result) + logUnequal(Float.toString(f1), Float.toString(f2), where); + return result; + } + + // Methods to support compare methods as specified in Comparator + + /** + * Compares its two arguments for order. Returns a negative integer, zero, + * or a positive integer as the first argument is less than, equal to, or + * greater than the second. + * @param l1 the first long to be compared + * @param l2 the second long to be compared + * @return a negative integer, zero, or a positive integer as the first + * argument is less than, equal to, or greater than the second. + */ + public static int compare (long l1, long l2) { + return (l1 < l2 ? -1 : (l1 == l2 ? 0 : 1)); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/util/GetSupportedOptions.java b/tck/src/main/java/org/apache/jdo/tck/util/GetSupportedOptions.java index 2f6b469db..7e2d6d7ab 100644 --- a/tck/src/main/java/org/apache/jdo/tck/util/GetSupportedOptions.java +++ b/tck/src/main/java/org/apache/jdo/tck/util/GetSupportedOptions.java @@ -5,16 +5,16 @@ * 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 + * + * 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.jdo.tck.util; import java.util.Collection; @@ -23,20 +23,22 @@ public class GetSupportedOptions { - public static void main(String[] args) throws Exception { - if (args.length == 0) { - System.err.println("Must pass name of PMF as an argument"); - System.exit(-1); - } - String PMFclassname = args[0]; - Class PMFclass = Class.forName(PMFclassname); - PersistenceManagerFactory pmf = (PersistenceManagerFactory) PMFclass.newInstance(); - Collection options = pmf.supportedOptions(); - System.out.println("Supported options are:"); - Iterator iter = options.iterator(); - while (iter.hasNext()) { - String val = (String) iter.next(); - System.out.println(val); + public static void main(String[] args) throws Exception + { + if( args.length == 0 ){ + System.err.println("Must pass name of PMF as an argument"); + System.exit(-1); + } + String PMFclassname = args[0]; + Class PMFclass = Class.forName(PMFclassname); + PersistenceManagerFactory pmf = (PersistenceManagerFactory) PMFclass.newInstance(); + Collection options = pmf.supportedOptions(); + System.out.println("Supported options are:"); + Iterator iter = options.iterator(); + while( iter.hasNext() ){ + String val = (String) iter.next(); + System.out.println(val); + } } - } + } diff --git a/tck/src/main/java/org/apache/jdo/tck/util/IntegerToStringConverter.java b/tck/src/main/java/org/apache/jdo/tck/util/IntegerToStringConverter.java index 2f9c4d54b..2e769fa39 100644 --- a/tck/src/main/java/org/apache/jdo/tck/util/IntegerToStringConverter.java +++ b/tck/src/main/java/org/apache/jdo/tck/util/IntegerToStringConverter.java @@ -16,76 +16,66 @@ */ package org.apache.jdo.tck.util; -import javax.jdo.AttributeConverter; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -/** AttributeConverter implementation mapping a Integer instance to a string. */ +import javax.jdo.AttributeConverter; + +/** + * AttributeConverter implementation mapping a Integer instance to a string. + */ public class IntegerToStringConverter implements AttributeConverter { - private static int nrOfConvertToDatastoreCalls = 0; - private static int nrOfConvertToAttributeCalls = 0; + private static int nrOfConvertToDatastoreCalls = 0; + private static int nrOfConvertToAttributeCalls = 0; - private final Log logger = LogFactory.getFactory().getInstance("org.apache.jdo.tck"); + private final Log logger = LogFactory.getFactory().getInstance("org.apache.jdo.tck"); - /** - * Converts the given Integer attribute value to its string representation in the datastore. - * - * @param attributeValue the attribute value of type Integer to be converted - * @return the string representation of the Integer instance - */ - @Override - public String convertToDatastore(Integer attributeValue) { - nrOfConvertToDatastoreCalls++; - String datastoreValue = attributeValue != null ? attributeValue.toString() : null; - if (logger.isDebugEnabled()) { - logger.debug( - "IntegerToStringConverter.convertToDatastore " - + "attributeValue=" - + attributeValue - + " datastoreValue=" - + datastoreValue); + /** + * Converts the given Integer attribute value to its string representation in the datastore. + * @param attributeValue the attribute value of type Integer to be converted + * @return the string representation of the Integer instance + */ + @Override + public String convertToDatastore(Integer attributeValue) { + nrOfConvertToDatastoreCalls++; + String datastoreValue = attributeValue != null ? attributeValue.toString() : null; + if (logger.isDebugEnabled()) { + logger.debug("IntegerToStringConverter.convertToDatastore " + + "attributeValue=" + attributeValue + " datastoreValue=" + datastoreValue); + } + return datastoreValue; } - return datastoreValue; - } - /** - * Converts the given string datastore value to its representation as a persistent attribute of - * type Integer. - * - * @param datastoreValue the string value in the datastore - * @return the attribute value as Integer instance - */ - @Override - public Integer convertToAttribute(String datastoreValue) { - nrOfConvertToAttributeCalls++; - Integer attributeValue = datastoreValue != null ? Integer.valueOf(datastoreValue) : null; - if (logger.isDebugEnabled()) { - logger.debug( - "IntegerToStringConverter.convertToAttribute " - + "datastoreValue=" - + datastoreValue - + " attributeValue=" - + attributeValue); + /** + * Converts the given string datastore value to its representation as a persistent attribute of type Integer. + * @param datastoreValue the string value in the datastore + * @return the attribute value as Integer instance + */ + @Override + public Integer convertToAttribute(String datastoreValue) { + nrOfConvertToAttributeCalls++; + Integer attributeValue = datastoreValue != null ? Integer.valueOf(datastoreValue): null; + if (logger.isDebugEnabled()) { + logger.debug("IntegerToStringConverter.convertToAttribute " + + "datastoreValue=" + datastoreValue + " attributeValue=" + attributeValue); + } + return attributeValue; } - return attributeValue; - } - /** - * Method returning the current number of convertToDatastore method calls. - * - * @return number of convertToDatastore method calls - */ - public static int getNrOfConvertToDatastoreCalls() { - return nrOfConvertToDatastoreCalls; - } + /** + * Method returning the current number of convertToDatastore method calls. + * @return number of convertToDatastore method calls + */ + public static int getNrOfConvertToDatastoreCalls() { + return nrOfConvertToDatastoreCalls; + } - /** - * Method returning the current number of convertToAttribute method calls. - * - * @return number of convertToAttribute method calls - */ - public static int getNrOfConvertToAttributeCalls() { - return nrOfConvertToAttributeCalls; - } + /** + * Method returning the current number of convertToAttribute method calls. + * @return number of convertToAttribute method calls + */ + public static int getNrOfConvertToAttributeCalls() { + return nrOfConvertToAttributeCalls; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/util/JDOCustomDateEditor.java b/tck/src/main/java/org/apache/jdo/tck/util/JDOCustomDateEditor.java index 86a64a4f6..754625250 100644 --- a/tck/src/main/java/org/apache/jdo/tck/util/JDOCustomDateEditor.java +++ b/tck/src/main/java/org/apache/jdo/tck/util/JDOCustomDateEditor.java @@ -17,16 +17,17 @@ package org.apache.jdo.tck.util; +import org.springframework.beans.propertyeditors.CustomDateEditor; + import java.text.SimpleDateFormat; import java.util.Locale; -import org.springframework.beans.propertyeditors.CustomDateEditor; public class JDOCustomDateEditor extends CustomDateEditor { - /** The format of date values in the xml representation */ - public static final String DATE_PATTERN = "d/MMM/yyyy"; + /** The format of date values in the xml representation */ + public static final String DATE_PATTERN = "d/MMM/yyyy"; - public JDOCustomDateEditor() { - super(new SimpleDateFormat(DATE_PATTERN, Locale.US), true); - } + public JDOCustomDateEditor() { + super(new SimpleDateFormat(DATE_PATTERN, Locale.US), true); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/util/JDOJdk14Logger.java b/tck/src/main/java/org/apache/jdo/tck/util/JDOJdk14Logger.java index 250da0b12..bb1b1700c 100644 --- a/tck/src/main/java/org/apache/jdo/tck/util/JDOJdk14Logger.java +++ b/tck/src/main/java/org/apache/jdo/tck/util/JDOJdk14Logger.java @@ -5,99 +5,104 @@ * 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 + * + * 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.jdo.tck.util; -import java.io.IOException; import java.io.InputStream; +import java.io.IOException; + +import javax.jdo.JDOFatalInternalException; +import javax.jdo.LegacyJava; import java.lang.reflect.InvocationTargetException; import java.security.PrivilegedAction; + import java.util.logging.LogManager; -import javax.jdo.JDOFatalInternalException; + import javax.jdo.JDOFatalUserException; -import javax.jdo.LegacyJava; + import org.apache.commons.logging.impl.Jdk14Logger; /** - * JDO-specific subclass of the apache commons logging Log implementation that wraps the standard - * JDK 1.4 logging. This class configures the JDK LogManager using a properties file called - * logging.properties found via the CLASSPATH. + * JDO-specific subclass of the apache commons logging Log + * implementation that wraps the standard JDK 1.4 logging. + * This class configures the JDK LogManager using a properties file + * called logging.properties found via the CLASSPATH. * * @author Michael Bouschen * @since 1.1 * @version 1.1 */ -public class JDOJdk14Logger extends Jdk14Logger { - /** Logging properties file name. */ - public static final String PROPERIES_FILE = "logging.properties"; +public class JDOJdk14Logger + extends Jdk14Logger +{ + /** Logging properties file name. */ + public static final String PROPERIES_FILE = "logging.properties"; + + /** Indicates whether JDK 1.4 logging has been configured by this class. */ + private static boolean configured = false; - /** Indicates whether JDK 1.4 logging has been configured by this class. */ - private static boolean configured = false; - - /** - * Constructor checking whether JDK 1.4 logging should be configuared after calling super - * constructor. - * - * @param name logger name - */ - public JDOJdk14Logger(String name) { - super(name); - if (!configured) { - configured = true; - configureJDK14Logger(); + /** + * Constructor checking whether JDK 1.4 logging should be + * configuared after calling super constructor. + * @param name logger name + */ + public JDOJdk14Logger(String name) { + super(name); + if (!configured) { + configured = true; + configureJDK14Logger(); + } } - } - /** Configures JDK 1.4 LogManager. */ - private void configureJDK14Logger() { - final LogManager logManager = LogManager.getLogManager(); - final ClassLoader cl = getClass().getClassLoader(); - doPrivileged( - new PrivilegedAction() { - public Object run() { - try { - InputStream config = cl.getResourceAsStream(PROPERIES_FILE); - logManager.readConfiguration(config); - return null; - } catch (IOException ex) { - throw new JDOFatalUserException( - "A IOException was thrown when trying to read the " - + "logging configuration file " - + PROPERIES_FILE - + ".", - ex); - } catch (SecurityException ex) { - throw new JDOFatalUserException( - "A SecurityException was thrown when trying to read " - + "the logging configuration file " - + PROPERIES_FILE - + ". In order to configure JDK 1.4 logging, you must " - + "grant java.util.logging.LoggingPermission(control) " - + "to the codeBase containing the JDO TCK.", - ex); + /** + * Configures JDK 1.4 LogManager. + */ + private void configureJDK14Logger() { + final LogManager logManager = LogManager.getLogManager(); + final ClassLoader cl = getClass().getClassLoader(); + doPrivileged(new PrivilegedAction() { + public Object run () { + try { + InputStream config = cl.getResourceAsStream(PROPERIES_FILE); + logManager.readConfiguration(config); + return null; + } + catch (IOException ex) { + throw new JDOFatalUserException( + "A IOException was thrown when trying to read the " + + "logging configuration file " + PROPERIES_FILE + ".", + ex); + } + catch (SecurityException ex) { + throw new JDOFatalUserException( + "A SecurityException was thrown when trying to read " + + "the logging configuration file " + PROPERIES_FILE + + ". In order to configure JDK 1.4 logging, you must " + + "grant java.util.logging.LoggingPermission(control) " + + "to the codeBase containing the JDO TCK.", ex); + } } - } - }); - } + }); + } - @SuppressWarnings("unchecked") - private static T doPrivileged(PrivilegedAction privilegedAction) { - try { - return (T) LegacyJava.doPrivilegedAction.invoke(null, privilegedAction); - } catch (IllegalAccessException | InvocationTargetException e) { - if (e.getCause() instanceof RuntimeException) { - throw (RuntimeException) e.getCause(); - } - throw new JDOFatalInternalException(e.getMessage()); + @SuppressWarnings("unchecked") + private static T doPrivileged(PrivilegedAction privilegedAction) { + try { + return (T) LegacyJava.doPrivilegedAction.invoke(null, privilegedAction); + } catch (IllegalAccessException | InvocationTargetException e) { + if (e.getCause() instanceof RuntimeException) { + throw (RuntimeException) e.getCause(); + } + throw new JDOFatalInternalException(e.getMessage()); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/util/PointToStringConverter.java b/tck/src/main/java/org/apache/jdo/tck/util/PointToStringConverter.java index 80524aa2f..300b9377b 100644 --- a/tck/src/main/java/org/apache/jdo/tck/util/PointToStringConverter.java +++ b/tck/src/main/java/org/apache/jdo/tck/util/PointToStringConverter.java @@ -16,94 +16,83 @@ */ package org.apache.jdo.tck.util; -import javax.jdo.AttributeConverter; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.jdo.tck.pc.mylib.Point; -/** AttributeConverter implementation mapping a Point instance to a string of the form x:y. */ +import javax.jdo.AttributeConverter; + +/** + * AttributeConverter implementation mapping a Point instance to a string of the form x:y. + */ public class PointToStringConverter implements AttributeConverter { - private static int nrOfConvertToDatastoreCalls = 0; - private static int nrOfConvertToAttributeCalls = 0; + private static int nrOfConvertToDatastoreCalls = 0; + private static int nrOfConvertToAttributeCalls = 0; - // Character to separate x and y value of the Point instance. - private static final String SEPARATOR = ":"; + // Character to separate x and y value of the Point instance. + private static final String SEPARATOR = ":"; - private final Log logger = LogFactory.getFactory().getInstance("org.apache.jdo.tck"); + private final Log logger = LogFactory.getFactory().getInstance("org.apache.jdo.tck"); - /** - * Converts the given Point attribute value to its string representation in the datastore. - * - * @param attributeValue the attribute value of type Point to be converted - * @return the string representation of the Point instance - */ - @Override - public String convertToDatastore(Point attributeValue) { - nrOfConvertToDatastoreCalls++; - String datastoreValue = null; - if (attributeValue != null) { - datastoreValue = - attributeValue.getX() - + SEPARATOR - + (attributeValue.getY() == null ? Integer.valueOf(0) : attributeValue.getY()); + /** + * Converts the given Point attribute value to its string representation in the datastore. + * @param attributeValue the attribute value of type Point to be converted + * @return the string representation of the Point instance + */ + @Override + public String convertToDatastore(Point attributeValue) { + nrOfConvertToDatastoreCalls++; + String datastoreValue = null; + if (attributeValue != null) { + datastoreValue = attributeValue.getX() + + SEPARATOR + + (attributeValue.getY() == null ? Integer.valueOf(0) : attributeValue.getY()); + } + if (logger.isDebugEnabled()) { + logger.debug("PointToStringConverter.convertToDatastore " + + "attributeValue=" + attributeValue + " datastoreValue=" + datastoreValue); + } + return datastoreValue; } - if (logger.isDebugEnabled()) { - logger.debug( - "PointToStringConverter.convertToDatastore " - + "attributeValue=" - + attributeValue - + " datastoreValue=" - + datastoreValue); - } - return datastoreValue; - } - /** - * Converts the given string datastore value to its representation as a persistent attribute of - * type Point. - * - * @param datastoreValue the string value in the datastore - * @return the attribute value as Point instance - */ - @Override - public Point convertToAttribute(String datastoreValue) { - nrOfConvertToAttributeCalls++; - Point attributeValue = null; - if (datastoreValue != null) { - String[] parts = datastoreValue.split(SEPARATOR); - if (parts.length == 2) { - Integer x = Integer.valueOf(parts[0]); - Integer y = Integer.valueOf(parts[1]); - attributeValue = new Point(x == null ? 0 : x.intValue(), y); - } - } - if (logger.isDebugEnabled()) { - logger.debug( - "PointToStringConverter.convertToAttribute " - + "datastoreValue=" - + datastoreValue - + " attributeValue=" - + attributeValue); + /** + * Converts the given string datastore value to its representation as a persistent attribute of type Point. + * @param datastoreValue the string value in the datastore + * @return the attribute value as Point instance + */ + @Override + public Point convertToAttribute(String datastoreValue) { + nrOfConvertToAttributeCalls++; + Point attributeValue = null; + if (datastoreValue != null) { + String[] parts = datastoreValue.split(SEPARATOR); + if (parts.length == 2) { + Integer x = Integer.valueOf(parts[0]); + Integer y = Integer.valueOf(parts[1]); + attributeValue = new Point(x == null ? 0 : x.intValue(), y); + } + } + if (logger.isDebugEnabled()) { + logger.debug("PointToStringConverter.convertToAttribute " + + "datastoreValue=" + datastoreValue + " attributeValue=" + attributeValue); + } + return attributeValue; } - return attributeValue; - } - /** - * Method returning the current number of convertToDatastore method calls. - * - * @return number of convertToDatastore method calls - */ - public static int getNrOfConvertToDatastoreCalls() { - return nrOfConvertToDatastoreCalls; - } + /** + * Method returning the current number of convertToDatastore method calls. + * @return number of convertToDatastore method calls + */ + public static int getNrOfConvertToDatastoreCalls() { + return nrOfConvertToDatastoreCalls; + } - /** - * Method returning the current number of convertToAttribute method calls. - * - * @return number of convertToAttribute method calls - */ - public static int getNrOfConvertToAttributeCalls() { - return nrOfConvertToAttributeCalls; - } + /** + * Method returning the current number of convertToAttribute method calls. + * @return number of convertToAttribute method calls + */ + public static int getNrOfConvertToAttributeCalls() { + return nrOfConvertToAttributeCalls; + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/util/ResultSummary.java b/tck/src/main/java/org/apache/jdo/tck/util/ResultSummary.java index 494963b4b..8e91b5b11 100644 --- a/tck/src/main/java/org/apache/jdo/tck/util/ResultSummary.java +++ b/tck/src/main/java/org/apache/jdo/tck/util/ResultSummary.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -26,180 +26,192 @@ import java.io.ObjectOutputStream; import java.io.PrintStream; import java.io.Serializable; + import javax.jdo.JDOFatalException; + import junit.framework.TestResult; -/** A serializable class used to store test results in a file. */ +/** + * A serializable class used to store test results in a file. + */ public class ResultSummary implements Serializable { - private static final long serialVersionUID = 1L; - - /** The name of the file to store a serialized instance of this class. */ - private static final String FILE_NAME_OF_RESULT_SUMMARY = "ResultSummary.ser"; - - /** The name of the TCK result file. */ - private static final String RESULT_FILE_NAME = "TCK-results.txt"; - - /* The number of all configurations. */ - private int nrOfTotalConfigurations = 0; - - /* The number of failed configurations. */ - private int nrOfFailedConfigurations = 0; - - /* The total number of tests. */ - private int totalTestCount = 0; - - /* The total number of failures. */ - private int totalFailureCount = 0; - - /* The total number of errors. */ - private int totalErrorCount = 0; - - /** - * Deserializes an instance and prints that instance to {@link System#out} and the TCK result - * file. Finally deletes the file of the serialized instance. - * - * @param args the first element contains the directory where the test result is stored. - */ - public static void main(String[] args) { - // print result summary - - String directory = args[0] + File.separator; - ResultSummary resultSummary = ResultSummary.load(directory); - String newLine = System.getProperty("line.separator"); - String resultMessage = resultSummary != null ? resultSummary.toString() : "No tests were run."; - String message = "-------" + newLine + resultMessage; - appendTCKResultMessage(directory, message); - System.out.println(resultMessage); - System.out.println("See file '" + directory + RESULT_FILE_NAME + "' for details."); - - // delete file - String fileName = args[0] + File.separator + FILE_NAME_OF_RESULT_SUMMARY; - File file = new File(fileName); - file.delete(); - } - - /** - * Appends the given message to the TCK result file in the given directory. - * - * @param directory the directory - * @param message the message - */ - static void appendTCKResultMessage(String directory, String message) { - String fileName = directory + RESULT_FILE_NAME; - PrintStream resultStream = null; - try { - resultStream = new PrintStream(new FileOutputStream(fileName, true)); - resultStream.println(message); - } catch (FileNotFoundException e) { - throw new JDOFatalException("Cannot create file " + fileName, e); - } finally { - if (resultStream != null) resultStream.close(); + private static final long serialVersionUID = 1L; + + /** The name of the file to store a serialized instance of this class. */ + private static final String FILE_NAME_OF_RESULT_SUMMARY = "ResultSummary.ser"; + + /** The name of the TCK result file. */ + private static final String RESULT_FILE_NAME = "TCK-results.txt"; + + /* The number of all configurations. */ + private int nrOfTotalConfigurations = 0; + + /* The number of failed configurations. */ + private int nrOfFailedConfigurations = 0; + + /* The total number of tests. */ + private int totalTestCount = 0; + + /* The total number of failures. */ + private int totalFailureCount = 0; + + /* The total number of errors. */ + private int totalErrorCount = 0; + + /** + * Deserializes an instance and prints that instance to + * {@link System#out} and the TCK result file. + * Finally deletes the file of the serialized instance. + * @param args the first element contains the directory + * where the test result is stored. + */ + public static void main(String[] args) { + // print result summary + + String directory = args[0] + File.separator; + ResultSummary resultSummary = ResultSummary.load(directory); + String newLine = System.getProperty("line.separator"); + String resultMessage = resultSummary != null ? + resultSummary.toString() : + "No tests were run."; + String message = "-------" + newLine + resultMessage; + appendTCKResultMessage(directory, message); + System.out.println(resultMessage); + System.out.println("See file '"+ directory + RESULT_FILE_NAME + + "' for details."); + + // delete file + String fileName = args[0] + File.separator + FILE_NAME_OF_RESULT_SUMMARY; + File file = new File(fileName); + file.delete(); } - } - - /** - * Creates an instance for the given result object and serializes that instance to a file in the - * geven directory. - * - * @param directory the directory - * @param result the result object - */ - static void save(String directory, TestResult result) { - ResultSummary resultSummary = load(directory); - if (resultSummary == null) { - resultSummary = new ResultSummary(); + + /** + * Appends the given message to the TCK result file in the given directory. + * @param directory the directory + * @param message the message + */ + static void appendTCKResultMessage(String directory, String message) { + String fileName = directory + RESULT_FILE_NAME; + PrintStream resultStream = null; + try { + resultStream = new PrintStream( + new FileOutputStream(fileName, true)); + resultStream.println(message); + } catch (FileNotFoundException e) { + throw new JDOFatalException("Cannot create file "+fileName, e); + } finally { + if (resultStream != null) + resultStream.close(); + } } - resultSummary.increment(result); - resultSummary.save(directory); - } - /** - * Returns a deserialized instance stored in the given direcotry. - * - * @param directory the directory - * @return the deserialized instance - */ - private static ResultSummary load(String directory) { - ResultSummary result; - String fileName = directory + FILE_NAME_OF_RESULT_SUMMARY; - ObjectInputStream ois = null; - try { - try { - ois = new ObjectInputStream(new FileInputStream(fileName)); - result = (ResultSummary) ois.readObject(); - } finally { - if (ois != null) { - ois.close(); + /** + * Creates an instance for the given result object and + * serializes that instance to a file in the geven directory. + * @param directory the directory + * @param result the result object + */ + static void save(String directory, TestResult result) { + ResultSummary resultSummary = load(directory); + if (resultSummary == null) { + resultSummary = new ResultSummary(); } - } - } catch (FileNotFoundException e) { - result = null; - } catch (IOException e) { - throw new JDOFatalException("Cannot deserialize result summary in file " + fileName, e); - } catch (ClassNotFoundException e) { - throw new JDOFatalException("Cannot deserialize result summary in file " + fileName, e); + resultSummary.increment(result); + resultSummary.save(directory); } - return result; - } - - /** - * Increments fields of this instance based on the given result object. - * - * @param result the result object - */ - private void increment(TestResult result) { - this.nrOfTotalConfigurations++; - this.totalTestCount += result.runCount(); - if (!result.wasSuccessful()) { - this.nrOfFailedConfigurations++; - this.totalFailureCount += result.failureCount(); - this.totalErrorCount += result.errorCount(); + + /** + * Returns a deserialized instance stored in the given direcotry. + * @param directory the directory + * @return the deserialized instance + */ + private static ResultSummary load(String directory) { + ResultSummary result; + String fileName = directory + FILE_NAME_OF_RESULT_SUMMARY; + ObjectInputStream ois = null; + try { + try { + ois = new ObjectInputStream(new FileInputStream(fileName)); + result = (ResultSummary) ois.readObject(); + } finally { + if (ois != null) { + ois.close(); + } + } + } catch (FileNotFoundException e) { + result = null; + } catch (IOException e) { + throw new JDOFatalException( + "Cannot deserialize result summary in file " + +fileName, e); + } catch (ClassNotFoundException e) { + throw new JDOFatalException( + "Cannot deserialize result summary in file " + +fileName, e); + } + return result; } - } - - /** - * Serializes this instance to a file in the given directory. - * - * @param directory the directory - */ - private void save(String directory) { - String fileName = directory + FILE_NAME_OF_RESULT_SUMMARY; - ObjectOutputStream oos = null; - try { - try { - oos = new ObjectOutputStream(new FileOutputStream(fileName)); - oos.writeObject(this); - } finally { - if (oos != null) { - oos.close(); + + /** + * Increments fields of this instance based on the given result object. + * @param result the result object + */ + private void increment(TestResult result) { + this.nrOfTotalConfigurations++; + this.totalTestCount += result.runCount(); + if (!result.wasSuccessful()) { + this.nrOfFailedConfigurations++; + this.totalFailureCount += result.failureCount(); + this.totalErrorCount += result.errorCount(); } - } - } catch (FileNotFoundException e) { - throw new JDOFatalException("Cannot create file " + fileName, e); - } catch (IOException e) { - throw new JDOFatalException("Cannot serialize result summary to file " + fileName, e); } - } - - /** - * @see Object#toString() - */ - public String toString() { - String newLine = System.getProperty("line.separator"); - StringBuffer result = new StringBuffer(); - result.append("Total tests run: ").append(totalTestCount).append("."); - if (this.nrOfFailedConfigurations == 0) { - result.append(newLine); - result.append("All (").append(this.nrOfTotalConfigurations); - result.append(") configurations passed."); - } else { - result.append(" Failures: ").append(totalFailureCount); - result.append(", Errors: ").append(totalErrorCount).append("."); - result.append(newLine); - result.append(this.nrOfFailedConfigurations).append(" of "); - result.append(this.nrOfTotalConfigurations); - result.append(" configurations failed."); + + /** + * Serializes this instance to a file in the given directory. + * @param directory the directory + */ + private void save(String directory) { + String fileName = directory + FILE_NAME_OF_RESULT_SUMMARY; + ObjectOutputStream oos = null; + try { + try { + oos = new ObjectOutputStream(new FileOutputStream(fileName)); + oos.writeObject(this); + } finally { + if (oos != null) { + oos.close(); + } + } + } catch (FileNotFoundException e) { + throw new JDOFatalException( + "Cannot create file " + fileName, e); + } catch (IOException e) { + throw new JDOFatalException( + "Cannot serialize result summary to file " + + fileName, e); + } + } + + /** + * @see Object#toString() + */ + public String toString() { + String newLine = System.getProperty("line.separator"); + StringBuffer result = new StringBuffer(); + result.append("Total tests run: ").append(totalTestCount).append("."); + if (this.nrOfFailedConfigurations==0) { + result.append(newLine); + result.append("All (").append(this.nrOfTotalConfigurations); + result.append(") configurations passed."); + } else { + result.append(" Failures: ").append(totalFailureCount); + result.append(", Errors: ").append(totalErrorCount).append("."); + result.append(newLine); + result.append(this.nrOfFailedConfigurations).append(" of "); + result.append(this.nrOfTotalConfigurations); + result.append(" configurations failed."); + } + return result.toString(); } - return result.toString(); - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/util/RogueBarrier.java b/tck/src/main/java/org/apache/jdo/tck/util/RogueBarrier.java index 0d8aecb24..8701f9443 100644 --- a/tck/src/main/java/org/apache/jdo/tck/util/RogueBarrier.java +++ b/tck/src/main/java/org/apache/jdo/tck/util/RogueBarrier.java @@ -5,157 +5,162 @@ * 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 + * + * 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.jdo.tck.util; /** - * Allows a set of threads to wait for all to reach a common barrier point. + * Allows a set of threads to wait for all to reach a common barrier + * point. * - *

    The RogueBarrier uses a rigorous breakage model: No thread can leave a barrier point - * prematurely. All attempts to interrupt an awaiting thread via an {@link InterruptedException} are - * being ignored. + *

    The RogueBarrier uses a rigorous breakage model: + * No thread can leave a barrier point prematurely. All attempts to + * interrupt an awaiting thread via an {@link InterruptedException} + * are being ignored. * * @author Martin Zaun */ public class RogueBarrier { - /** The internal synchronization object */ - private final Object lock = new Object(); - - /** The number of parties needed to trip the barrier */ - private final int parties; - - /** The current generation's trip condition (need a boolean holder) */ - private boolean[] tripped = new boolean[1]; - - /** The number of parties still waiting for */ - private int missing; - - /** - * Creates a new RogueBarrier that will trip when the given number of parties (threads) - * are waiting upon it. - * - * @param parties the number of threads that must invoke {@link #await} before the barrier is - * tripped. - * @throws IllegalArgumentException if parties is less than 1. - */ - public RogueBarrier(int parties) { - if (parties <= 0) { - throw new IllegalArgumentException("Argument for parties must be positive."); - } - this.parties = parties; - missing = parties; - } - - /** - * Waits until all parties have invoked await on this barrier. - * - * @return the arrival index of the current thread, where index parties - 1 indicates the - * first to arrive and zero indicates the last to arrive. - */ - public int await() { - synchronized (lock) { - // assert (parties > 0); - // System.out.println("thread = " + Thread.currentThread().getId()); - - // if tripping, reset barrier and notify waiting threads - final int index = --missing; - if (index == 0) { - tripped[0] = true; // notify current generation - lock.notifyAll(); - tripped = new boolean[1]; // start new generation - missing = parties; - return 0; - } - - // wait until tripped - final boolean[] myTripped = tripped; // my generation's condition - do { - try { - lock.wait(); - } catch (InterruptedException ie) { // swallow + /** The internal synchronization object */ + private final Object lock = new Object(); + + /** The number of parties needed to trip the barrier */ + private final int parties; + + /** The current generation's trip condition (need a boolean holder) */ + private boolean[] tripped = new boolean[1]; + + /** The number of parties still waiting for */ + private int missing; + + /** + * Creates a new RogueBarrier that will trip when the + * given number of parties (threads) are waiting upon it. + * + * @param parties the number of threads that must invoke {@link #await} + * before the barrier is tripped. + * + * @throws IllegalArgumentException if parties is less than 1. + */ + public RogueBarrier(int parties) { + if (parties <= 0) { + throw new IllegalArgumentException("Argument for parties must be positive."); } - } while (!myTripped[0]); - return index; + this.parties = parties; + missing = parties; } - } - - public static class Test extends Thread { - private static final int parties = 1000; - private static final RogueBarrier b = new RogueBarrier(parties); - private static int count; - - public void run() { - final int i0 = b.await(); - if (i0 == 0) { - System.out.println(" incrementing count to " + parties + " ..."); - } - synchronized (Test.class) { - count++; - } - - final int i1 = b.await(); - synchronized (Test.class) { - if (i1 == 0) { - System.out.println(" count = " + count); - } - // assert (count == parties+1); - } - - final int i2 = b.await(); - if (i2 == 0) { - System.out.println(" decrementing count to zero ..."); - } - synchronized (Test.class) { - count--; - } - - final int i3 = b.await(); - synchronized (Test.class) { - if (i3 == 0) { - System.out.println(" count = " + count); - } - // assert (count == 0); - } - b.await(); + /** + * Waits until all parties have invoked await on this barrier. + * + * @return the arrival index of the current thread, where index + * parties - 1 indicates the first to arrive and + * zero indicates the last to arrive. + */ + public int await() { + synchronized (lock) { + //assert (parties > 0); + //System.out.println("thread = " + Thread.currentThread().getId()); + + // if tripping, reset barrier and notify waiting threads + final int index = --missing; + if (index == 0) { + tripped[0] = true; // notify current generation + lock.notifyAll(); + tripped = new boolean[1]; // start new generation + missing = parties; + return 0; + } + + // wait until tripped + final boolean[] myTripped = tripped; // my generation's condition + do { + try { + lock.wait(); + } catch (InterruptedException ie) { // swallow + } + } while (!myTripped[0]); + return index; + } } - public static void test() { - System.out.println("--> RogueBarrier$Test.test()"); - - // start threads - final Thread threads[] = new Test[parties]; - for (int i = 0; i < parties; i++) { - threads[i] = new Test(); - threads[i].start(); - } - - // wait for all threads to finish - for (int i = 0; i < parties; i++) { - while (true) { - try { - threads[i].join(); - break; - } catch (InterruptedException e) { - } + static public class Test extends Thread { + static private final int parties = 1000; + static private final RogueBarrier b = new RogueBarrier(parties); + static private int count; + + public void run() { + final int i0 = b.await(); + if (i0 == 0) { + System.out.println(" incrementing count to " + parties + + " ..."); + } + synchronized (Test.class) { + count++; + } + + final int i1 = b.await(); + synchronized (Test.class) { + if (i1 == 0) { + System.out.println(" count = " + count); + } + //assert (count == parties+1); + } + + final int i2 = b.await(); + if (i2 == 0) { + System.out.println(" decrementing count to zero ..."); + } + synchronized (Test.class) { + count--; + } + + final int i3 = b.await(); + synchronized (Test.class) { + if (i3 == 0) { + System.out.println(" count = " + count); + } + //assert (count == 0); + } + + b.await(); } - } - - System.out.println("<-- RogueBarrier$Test.test()"); - } - public static void main(String[] args) { - Test.test(); + static public void test() { + System.out.println("--> RogueBarrier$Test.test()"); + + // start threads + final Thread threads[] = new Test[parties]; + for (int i = 0; i < parties; i++) { + threads[i] = new Test(); + threads[i].start(); + } + + // wait for all threads to finish + for (int i = 0; i < parties; i++) { + while (true) { + try { + threads[i].join(); + break; + } catch (InterruptedException e) { + } + } + } + + System.out.println("<-- RogueBarrier$Test.test()"); + } + + static public void main(String[] args) { + Test.test(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/util/SystemCfgSummary.java b/tck/src/main/java/org/apache/jdo/tck/util/SystemCfgSummary.java index a665743f3..0dd9d31c1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/util/SystemCfgSummary.java +++ b/tck/src/main/java/org/apache/jdo/tck/util/SystemCfgSummary.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -21,72 +21,75 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; + import java.util.Enumeration; import java.util.Properties; + import javax.jdo.JDOFatalException; -/** A class to produce a text summary of system configuration information. */ +/** + * A class to produce a text summary of system configuration information. + */ public class SystemCfgSummary { + + /** The name of the system configuration summary file. */ + private static final String SYSCFG_FILE_NAME = "system_config.txt"; + private static String newLine; - /** The name of the system configuration summary file. */ - private static final String SYSCFG_FILE_NAME = "system_config.txt"; - - private static String newLine; - - /** - * Creates a new file containing system configuration information. - * - * @param args the first element contains the output directory; the second element contains the - * file name - */ - public static void main(String[] args) { - String directory = args[0] + File.separator; - String fileName = null; - if (args[1] != null) { - fileName = args[1]; - } else { - fileName = SYSCFG_FILE_NAME; + /** + * Creates a new file containing system configuration information. + * @param args the first element contains the output directory; + * the second element contains the file name + */ + public static void main(String[] args) { + String directory = args[0] + File.separator; + String fileName = null; + if (args[1] != null) { + fileName = args[1] ; + } else { + fileName = SYSCFG_FILE_NAME; + } + newLine = System.getProperty("line.separator"); + String message = getSystemInfo(); + if (message == null) { + message = "No system information found."; + } + saveSystemInfo(directory + fileName, message); } - newLine = System.getProperty("line.separator"); - String message = getSystemInfo(); - if (message == null) { - message = "No system information found."; - } - saveSystemInfo(directory + fileName, message); - } - - /** - * Gets system information from System properties - * - * @return System property keys and values as a String, one per line - */ - static String getSystemInfo() { - - Properties props = System.getProperties(); - Enumeration propEnum = props.propertyNames(); - StringBuffer sysinfo = new StringBuffer(); - while (propEnum.hasMoreElements()) { - String key = (String) propEnum.nextElement(); - sysinfo.append(key + ": " + props.getProperty(key) + newLine); - } - return sysinfo.toString(); - } - - /** - * Saves the given message to the system configuration summary file in the given directory. - * - * @param path the path - * @param message the message - */ - static void saveSystemInfo(String path, String message) { - PrintStream resultStream = null; - try { - resultStream = new PrintStream(new FileOutputStream(path, true)); - resultStream.println(message); - } catch (FileNotFoundException e) { - throw new JDOFatalException("Cannot create file " + path, e); - } finally { - if (resultStream != null) resultStream.close(); + + /** + * Gets system information from System properties + * @return System property keys and values as a String, one per line + */ + static String getSystemInfo() { + + Properties props = System.getProperties(); + Enumeration propEnum = props.propertyNames(); + StringBuffer sysinfo = new StringBuffer(); + while (propEnum.hasMoreElements()) { + String key = (String)propEnum.nextElement(); + sysinfo.append(key + ": " + props.getProperty(key) + newLine); + } + return sysinfo.toString(); + } + + /** + * Saves the given message to the system configuration summary file + * in the given directory. + * @param path the path + * @param message the message + */ + static void saveSystemInfo(String path, String message) { + PrintStream resultStream = null; + try { + resultStream = new PrintStream( + new FileOutputStream(path, true)); + resultStream.println(message); + } catch (FileNotFoundException e) { + throw new JDOFatalException("Cannot create file " + path, e); + } finally { + if (resultStream != null) + resultStream.close(); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/util/TCKFileHandler.java b/tck/src/main/java/org/apache/jdo/tck/util/TCKFileHandler.java index 37523539f..fb0a32f0d 100644 --- a/tck/src/main/java/org/apache/jdo/tck/util/TCKFileHandler.java +++ b/tck/src/main/java/org/apache/jdo/tck/util/TCKFileHandler.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -32,309 +32,313 @@ import java.util.logging.StreamHandler; /** - * A JDK1.4 logging Handler class which delegates to a file handler. Configuration: By default each - * TCKFileHandler is initialized using the following LogManager configuration properties: - * + * A JDK1.4 logging Handler class which delegates to a file handler. + * Configuration: By default each TCKFileHandler is initialized using + * the following LogManager configuration properties: *

      - *
    • java.util.logging.TCKFileHandler.level specifies the default level for the Handler - * (defaults to Level.ALL). - *
    • java.util.logging.FileHandler.filter specifies the name of a Filter class to use (defaults - * to no Filter). - *
    • java.util.logging.FileHandler.formatter specifies the name of a Formatter class to use - * (defaults to java.util.logging.SimpleFormatter). - *
    • java.util.logging.FileHandler.encoding the name of the character set encoding to use - * (defaults to the default platform encoding). - *
    • java.util.logging.FileHandler.fileName specifies a the output file name. See below for - * details. - *
    • java.util.logging.FileHandler.append specifies whether the FileHandler should append onto - * any existing files (defaults to false). - *
    - * - * For details on the construction of the file name see method {@link - * BatchTestRunner#changeFileName(String)}. + *
  • java.util.logging.TCKFileHandler.level + * specifies the default level for the Handler (defaults to Level.ALL).
  • + *
  • java.util.logging.FileHandler.filter + * specifies the name of a Filter class to use (defaults to no Filter).
  • + *
  • java.util.logging.FileHandler.formatter + * specifies the name of a Formatter class to use + * (defaults to java.util.logging.SimpleFormatter).
  • + *
  • java.util.logging.FileHandler.encoding + * the name of the character set encoding to use + * (defaults to the default platform encoding).
  • + *
  • java.util.logging.FileHandler.fileName + * specifies a the output file name. See below for details.
  • + *
  • java.util.logging.FileHandler.append + * specifies whether the FileHandler should append onto any existing files + * (defaults to false).
  • + * + * For details on the construction of the file name see method + * {@link BatchTestRunner#changeFileName(String)}. */ public class TCKFileHandler extends Handler { - private static final String defaultName = ""; - private static final boolean defaultAppend = false; - private static final Level defaultLevel = Level.ALL; - private static final Filter defaultFilter = null; - private static final Formatter defaultFormatter = new SimpleFormatter(); - private static final String defaultEncoding = null; - - private String fileName; - private boolean append; - - private Level level; - private Filter filter; - private Formatter formatter; - private String encoding; - - private FileHandlerDelegate delegate; - - /** - * @see Handler#Handler() - * @throws IOException IO exception - * @throws SecurityException securiyt exception - */ - public TCKFileHandler() throws IOException, SecurityException { - configure(); - - this.delegate = new FileHandlerDelegate(); - - OutputStream stream = new FileOutputStream(this.fileName, this.append); - this.delegate.setOutputStream(stream); - - this.delegate.setLevel(this.level); - this.delegate.setFilter(this.filter); - this.delegate.setFormatter(this.formatter); - this.delegate.setEncoding(this.encoding); - } - - /** - * @see Handler#publish(java.util.logging.LogRecord) - */ - public synchronized void publish(LogRecord record) { - this.delegate.publish(record); - } - - /** - * @see Handler#close() - */ - public synchronized void close() throws SecurityException { - this.delegate.close(); - } - - /** - * @see Handler#flush() - */ - public void flush() { - this.delegate.flush(); - } - - /** - * @see Handler#getEncoding() - */ - public String getEncoding() { - return this.encoding; - } - - /** - * @see Handler#getErrorManager() - */ - public ErrorManager getErrorManager() { - return this.delegate.getErrorManager(); - } - - /** - * @see Handler#getFilter() - */ - public Filter getFilter() { - return this.filter; - } - - /** - * @see Handler#getFormatter() - */ - public Formatter getFormatter() { - return this.formatter; - } - - /** - * @see Handler#getLevel() - */ - public Level getLevel() { - return this.level; - } - - /** - * @see Handler#reportError(java.lang.String, java.lang.Exception, int) - */ - protected void reportError(String msg, Exception ex, int code) { - this.delegate.reportError(msg, ex, code); - } - - /** - * @see Handler#setErrorManager(java.util.logging.ErrorManager) - */ - public void setErrorManager(ErrorManager em) { - this.delegate.setErrorManager(em); - } - - /** - * @see StreamHandler#isLoggable(java.util.logging.LogRecord) - */ - public boolean isLoggable(LogRecord record) { - return this.delegate.isLoggable(record); - } - - /** - * Sets the file name fileName property. - * - * @param fileName The fileName to set - */ - protected void setPattern(String fileName) { - this.fileName = BatchTestRunner.changeFileName(fileName); - } - - /** - * Sets the append property. - * - * @param append The append to set. - */ - protected void setAppend(boolean append) { - this.append = append; - } + private static final String defaultName = ""; + private static final boolean defaultAppend = false; + private static final Level defaultLevel = Level.ALL; + private static final Filter defaultFilter = null; + private static final Formatter defaultFormatter = new SimpleFormatter(); + private static final String defaultEncoding = null; + + private String fileName; + private boolean append; + + private Level level; + private Filter filter; + private Formatter formatter; + private String encoding; + + private FileHandlerDelegate delegate; + + /** + * @see Handler#Handler() + * @throws IOException IO exception + * @throws SecurityException securiyt exception + */ + public TCKFileHandler() throws IOException, SecurityException { + configure(); + + this.delegate = new FileHandlerDelegate(); + + OutputStream stream = new FileOutputStream(this.fileName, this.append); + this.delegate.setOutputStream(stream); + + this.delegate.setLevel(this.level); + this.delegate.setFilter(this.filter); + this.delegate.setFormatter(this.formatter); + this.delegate.setEncoding(this.encoding); + } - /** - * Sets the level property. - * - * @param level The level to set. - */ - public void setLevel(Level level) { - this.level = level; - if (this.delegate != null) { - this.delegate.setLevel(level); + /** + * @see Handler#publish(java.util.logging.LogRecord) + */ + public synchronized void publish(LogRecord record) { + this.delegate.publish(record); } - } - /** - * Sets the filter property. - * - * @param filter The filter to set. - */ - public void setFilter(Filter filter) { - this.filter = filter; - if (this.delegate != null) { - this.delegate.setFilter(filter); + /** + * @see Handler#close() + */ + public synchronized void close() throws SecurityException { + this.delegate.close(); } - } - /** - * Sets the formatter property. - * - * @param formatter The formatter to set. - */ - public void setFormatter(Formatter formatter) { - this.formatter = formatter; - if (this.delegate != null) { - this.delegate.setFormatter(formatter); + + /** + * @see Handler#flush() + */ + public void flush() { + this.delegate.flush(); + } + + /** + * @see Handler#getEncoding() + */ + public String getEncoding() { + return this.encoding; } - } - /** - * Sets the encoding property. - * - * @param encoding The encoding to set. - * @throws UnsupportedEncodingException encoding not supported - * @throws SecurityException security exception - */ - public void setEncoding(String encoding) throws SecurityException, UnsupportedEncodingException { - this.encoding = encoding; - if (this.delegate != null) { - this.delegate.setEncoding(encoding); + /** + * @see Handler#getErrorManager() + */ + public ErrorManager getErrorManager() { + return this.delegate.getErrorManager(); + } + + /** + * @see Handler#getFilter() + */ + public Filter getFilter() { + return this.filter; + } + + /** + * @see Handler#getFormatter() + */ + public Formatter getFormatter() { + return this.formatter; + } + + /** + * @see Handler#getLevel() + */ + public Level getLevel() { + return this.level; + } + + /** + * @see Handler#reportError(java.lang.String, java.lang.Exception, int) + */ + protected void reportError(String msg, Exception ex, int code) { + this.delegate.reportError(msg, ex, code); + } + + /** + * @see Handler#setErrorManager(java.util.logging.ErrorManager) + */ + public void setErrorManager(ErrorManager em) { + this.delegate.setErrorManager(em); } - } - /** - * Sets the delegate. - * - * @param delegate The delegate to set. - */ - protected void setDelegate(FileHandlerDelegate delegate) { - this.delegate = delegate; - } + /** + * @see StreamHandler#isLoggable(java.util.logging.LogRecord) + */ + public boolean isLoggable(LogRecord record) { + return this.delegate.isLoggable(record); + } - private void configure() { - LogManager manager = LogManager.getLogManager(); - String className = this.getClass().getName(); + /** + * Sets the file name fileName property. + * @param fileName The fileName to set + */ + protected void setPattern(String fileName) { + this.fileName = BatchTestRunner.changeFileName(fileName); + } - setPattern(getStringProperty(manager, className + ".fileName", defaultName)); - setAppend(getBooleanProperty(manager, className + ".append", defaultAppend)); + /** + * Sets the append property. + * @param append The append to set. + */ + protected void setAppend(boolean append) { + this.append = append; + } - setLevel(getLevelProperty(manager, className + ".level", defaultLevel)); - setFilter(getFilterProperty(manager, className + ".filter", defaultFilter)); - setFormatter(getFormatterProperty(manager, className + ".formatter", defaultFormatter)); - try { - setEncoding(getStringProperty(manager, className + ".encoding", defaultEncoding)); - } catch (Exception e) { - try { - setEncoding(defaultEncoding); - } catch (Exception ex) { - } + /** + * Sets the level property. + * @param level The level to set. + */ + public void setLevel(Level level) { + this.level = level; + if (this.delegate != null) { + this.delegate.setLevel(level); + } } - } - private boolean getBooleanProperty(LogManager manager, String property, boolean defaultValue) { - boolean result = defaultValue; - String value = manager.getProperty(property); - if (value != null) { - try { - result = Boolean.valueOf(value.trim()).booleanValue(); - } catch (Exception ex) { - } + /** + * Sets the filter property. + * @param filter The filter to set. + */ + public void setFilter(Filter filter) { + this.filter = filter; + if (this.delegate != null) { + this.delegate.setFilter(filter); + } } - return result; - } - private String getStringProperty(LogManager manager, String property, String defaultValue) { - String result = defaultValue; - String value = manager.getProperty(property); - if (value != null) { - result = value.trim(); + /** + * Sets the formatter property. + * @param formatter The formatter to set. + */ + public void setFormatter(Formatter formatter) { + this.formatter = formatter; + if (this.delegate != null) { + this.delegate.setFormatter(formatter); + } } - return result; - } - private Level getLevelProperty(LogManager manager, String property, Level defaultValue) { - Level result = defaultValue; - String value = manager.getProperty(property); - if (value != null) { - try { - result = Level.parse(value.trim()); - } catch (Exception ex) { - } + /** + * Sets the encoding property. + * @param encoding The encoding to set. + * @throws UnsupportedEncodingException encoding not supported + * @throws SecurityException security exception + */ + public void setEncoding(String encoding) + throws SecurityException, UnsupportedEncodingException { + this.encoding = encoding; + if (this.delegate != null) { + this.delegate.setEncoding(encoding); + } } - return result; - } - private Filter getFilterProperty(LogManager manager, String property, Filter defaultValue) { - return (Filter) newInstanceForProperty(manager, property, defaultValue); - } + /** + * Sets the delegate. + * @param delegate The delegate to set. + */ + protected void setDelegate(FileHandlerDelegate delegate) { + this.delegate = delegate; + } + + private void configure() { + LogManager manager = LogManager.getLogManager(); + String className = this.getClass().getName(); + + setPattern(getStringProperty(manager, className + ".fileName", defaultName)); + setAppend(getBooleanProperty(manager, className + ".append", defaultAppend)); + + setLevel(getLevelProperty(manager, className + ".level", defaultLevel)); + setFilter(getFilterProperty(manager, className + ".filter", defaultFilter)); + setFormatter(getFormatterProperty(manager, className + ".formatter", defaultFormatter)); + try { + setEncoding(getStringProperty(manager, className + ".encoding", defaultEncoding)); + } catch (Exception e) { + try { + setEncoding(defaultEncoding); + } catch (Exception ex) { + } + } + } + + private boolean getBooleanProperty(LogManager manager, String property, + boolean defaultValue) { + boolean result = defaultValue; + String value = manager.getProperty(property); + if ( value != null) { + try { + result = Boolean.valueOf(value.trim()).booleanValue(); + } catch (Exception ex) { + } + } + return result; + } - private Formatter getFormatterProperty( - LogManager manager, String property, Formatter defaultValue) { - return (Formatter) newInstanceForProperty(manager, property, defaultValue); - } + private String getStringProperty(LogManager manager, String property, + String defaultValue) { + String result = defaultValue; + String value = manager.getProperty(property); + if ( value != null) { + result = value.trim(); + } + return result; + } - private Object newInstanceForProperty(LogManager manager, String property, Object defaultValue) { - Object result = defaultValue; - String value = manager.getProperty(property); - if (value != null) { - try { - Class clazz = ClassLoader.getSystemClassLoader().loadClass(value); - result = clazz.newInstance(); - } catch (Exception ex) { - } + private Level getLevelProperty(LogManager manager, String property, + Level defaultValue) { + Level result = defaultValue; + String value = manager.getProperty(property); + if (value != null) { + try { + result = Level.parse(value.trim()); + } catch (Exception ex) { + } + } + return result; } - return result; - } - /** - * This class has been defined to make method {@link Handler#reportError(java.lang.String, - * java.lang.Exception, int)} accessible in the outer class. - */ - private static class FileHandlerDelegate extends StreamHandler { + private Filter getFilterProperty(LogManager manager, String property, + Filter defaultValue) { + return (Filter) newInstanceForProperty(manager, property, defaultValue); + } - protected void setOutputStream(OutputStream out) { - super.setOutputStream(out); + private Formatter getFormatterProperty(LogManager manager, String property, + Formatter defaultValue) { + return (Formatter) newInstanceForProperty(manager, property, defaultValue); } + private Object newInstanceForProperty(LogManager manager, String property, + Object defaultValue) { + Object result = defaultValue; + String value = manager.getProperty(property); + if (value != null) { + try { + Class clazz = + ClassLoader.getSystemClassLoader().loadClass(value); + result = clazz.newInstance(); + } catch (Exception ex) { + } + } + return result; + } + /** - * @see Handler#reportError(java.lang.String, java.lang.Exception, int) + * This class has been defined to make method + * {@link Handler#reportError(java.lang.String, java.lang.Exception, int)} + * accessible in the outer class. */ - protected void reportError(String msg, Exception ex, int code) { - super.reportError(msg, ex, code); + private static class FileHandlerDelegate extends StreamHandler { + + protected void setOutputStream(OutputStream out) { + super.setOutputStream(out); + } + + /** + * @see Handler#reportError(java.lang.String, java.lang.Exception, int) + */ + protected void reportError(String msg, Exception ex, int code) { + super.reportError(msg, ex, code); + } } - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/util/ThreadExceptionHandler.java b/tck/src/main/java/org/apache/jdo/tck/util/ThreadExceptionHandler.java index 09f4a8c1c..457ca41c3 100644 --- a/tck/src/main/java/org/apache/jdo/tck/util/ThreadExceptionHandler.java +++ b/tck/src/main/java/org/apache/jdo/tck/util/ThreadExceptionHandler.java @@ -5,13 +5,13 @@ * 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 + * + * 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. */ @@ -22,54 +22,55 @@ import java.util.Set; /** - * This class extends java.lang.ThreadGroup and stores any uncaught exception of threads from this - * ThreadGroup for later retrieval. + * This class extends java.lang.ThreadGroup and stores any uncaught + * exception of threads from this ThreadGroup for later retrieval. * * @author Michael Bouschen */ -public class ThreadExceptionHandler extends ThreadGroup { - /** - * Map of uncaught exceptions. The thread is the key and the uncaught Throwable is the value in - * the map. - */ - private final Map uncaughtExceptions = new HashMap(); - - /** Constructor. */ - public ThreadExceptionHandler() { - super("ThreadExceptionHandler"); - } - - /** - * Called by the Java Virtual Machine when a thread in this thread group stops because of an - * uncaught exception. This implementation stores the uncaught exception in a map for later - * retrieval. - */ - public void uncaughtException(Thread t, Throwable e) { - uncaughtExceptions.put(t, e); - } +public class ThreadExceptionHandler extends ThreadGroup +{ + /** + * Map of uncaught exceptions. The thread is the key and the uncaught + * Throwable is the value in the map. + */ + private final Map uncaughtExceptions = new HashMap(); + + /** Constructor. */ + public ThreadExceptionHandler() { + super("ThreadExceptionHandler"); + } + + /** Called by the Java Virtual Machine when a thread in this thread + * group stops because of an uncaught exception. This implementation + * stores the uncaught exception in a map for later retrieval. + */ + public void uncaughtException(Thread t, Throwable e) { + uncaughtExceptions.put(t, e); + } - /** - * Returns an uncaught exception for the specified thread. - * - * @param t the thread - * @return uncaught exception for the specified thread - */ - public Throwable getUncaughtException(Thread t) { - return (Throwable) uncaughtExceptions.get(t); - } + /** + * Returns an uncaught exception for the specified thread. + * @param t the thread + * @return uncaught exception for the specified thread + */ + public Throwable getUncaughtException(Thread t) { + return (Throwable)uncaughtExceptions.get(t); + } - /** - * Returns all uncaught exceptions stored in this ThreadGroup. Each element in the returned set is - * a Map.Entry with the thread as the key and the uncaught Throwable is the value. - * - * @return Set of uncaught exceptions - */ - public Set getAllUncaughtExceptions() { - return uncaughtExceptions.entrySet(); - } + /** + * Returns all uncaught exceptions stored in this ThreadGroup. + * Each element in the returned set is a Map.Entry with the + * thread as the key and the uncaught Throwable is the value. + * @return Set of uncaught exceptions + */ + public Set getAllUncaughtExceptions() { + return uncaughtExceptions.entrySet(); + } - /** Clears all exceptions in this ThreadGroup. */ - public void clear() { - uncaughtExceptions.clear(); - } + /** + * Clears all exceptions in this ThreadGroup. + */ + public void clear() { + uncaughtExceptions.clear(); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/util/signature/Formatter.java b/tck/src/main/java/org/apache/jdo/tck/util/signature/Formatter.java index 1ac0b1859..dead8c986 100644 --- a/tck/src/main/java/org/apache/jdo/tck/util/signature/Formatter.java +++ b/tck/src/main/java/org/apache/jdo/tck/util/signature/Formatter.java @@ -5,171 +5,184 @@ * 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 + * + * 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.jdo.tck.util.signature; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; import java.lang.reflect.Member; -import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Constructor; /** - * A helper class for building exhaustive string descriptions of class, field, constructor, or - * method declarations. + * A helper class for building exhaustive string descriptions of + * class, field, constructor, or method declarations. * * @author Martin Zaun */ class Formatter { - /** Returns a string formatting an array of names as comma-separated list. */ - public static String toString(String prefix, String[] names) { - final StringBuffer s = new StringBuffer(); - if (names != null && names.length > 0) { - s.append(prefix == null ? "" : prefix).append(names[0]); - for (int i = 1; i < names.length; i++) { - s.append(", ").append(names[i]); - } + /** + * Returns a string formatting an array of names as + * comma-separated list. + */ + static public String toString(String prefix, String[] names) { + final StringBuffer s = new StringBuffer(); + if (names != null && names.length > 0) { + s.append(prefix == null ? "" : prefix).append(names[0]); + for (int i = 1; i < names.length; i++) { + s.append(", ").append(names[i]); + } + } + return s.toString(); } - return s.toString(); - } - - /** - * Returns a string formatting an array of class objects as comma-separated list of (Java) user - * type names. - */ - public static String toString(String prefix, Class[] cls) { - final StringBuffer s = new StringBuffer(); - if (cls != null && cls.length > 0) { - String n = TypeHelper.userTypeName(cls[0].getName()); - s.append(prefix == null ? "" : prefix).append(n); - for (int i = 1; i < cls.length; i++) { - n = TypeHelper.userTypeName(cls[i].getName()); - s.append(", ").append(n); - } + + /** + * Returns a string formatting an array of class objects as + * comma-separated list of (Java) user type names. + */ + static public String toString(String prefix, Class[] cls) { + final StringBuffer s = new StringBuffer(); + if (cls != null && cls.length > 0) { + String n = TypeHelper.userTypeName(cls[0].getName()); + s.append(prefix == null ? "" : prefix).append(n); + for (int i = 1; i < cls.length; i++) { + n = TypeHelper.userTypeName(cls[i].getName()); + s.append(", ").append(n); + } + } + return s.toString(); + } + + /** + * Returns an exhaustive string description of a Field + * presenting types as (Java) user type names. + */ + static public String toString(Field field, Object value) { + final StringBuffer s = new StringBuffer(); + s.append(Modifier.toString(field.getModifiers())).append(" "); + s.append(TypeHelper.userTypeName(field.getType().getName())); + s.append(" "); + s.append(field.getName()); + s.append(value == null ? "" : " = " + value); + return s.toString(); } - return s.toString(); - } - /** - * Returns an exhaustive string description of a Field presenting types as (Java) - * user type names. - */ - public static String toString(Field field, Object value) { - final StringBuffer s = new StringBuffer(); - s.append(Modifier.toString(field.getModifiers())).append(" "); - s.append(TypeHelper.userTypeName(field.getType().getName())); - s.append(" "); - s.append(field.getName()); - s.append(value == null ? "" : " = " + value); - return s.toString(); - } + /** + * Returns an combined string description of a field declaration. + */ + static public String toString(int mods, String type, String name, + String value) { + final StringBuffer s = new StringBuffer(); + s.append(Modifier.toString(mods)).append(" "); + s.append(type).append(" "); + s.append(name); + s.append(value == null ? "" : " = " + value); + return s.toString(); + } - /** Returns an combined string description of a field declaration. */ - public static String toString(int mods, String type, String name, String value) { - final StringBuffer s = new StringBuffer(); - s.append(Modifier.toString(mods)).append(" "); - s.append(type).append(" "); - s.append(name); - s.append(value == null ? "" : " = " + value); - return s.toString(); - } + /** + * Returns an exhaustive string description of a + * Constructor presenting types as (Java) user type names. - /** - * Returns an exhaustive string description of a Constructor presenting types as - * (Java) user type names. - */ - public static String toString(Constructor ctor) { - final StringBuffer s = new StringBuffer(); - s.append(Modifier.toString(ctor.getModifiers())).append(" "); - s.append(ctor.getName()).append("("); - s.append(toString("", ctor.getParameterTypes())).append(")"); - s.append(toString(" throws ", ctor.getExceptionTypes())); - return s.toString(); - } + */ + static public String toString(Constructor ctor) { + final StringBuffer s = new StringBuffer(); + s.append(Modifier.toString(ctor.getModifiers())).append(" "); + s.append(ctor.getName()).append("("); + s.append(toString("", ctor.getParameterTypes())).append(")"); + s.append(toString(" throws ", ctor.getExceptionTypes())); + return s.toString(); + } - /** - * Returns an exhaustive string description of a Method presenting types as (Java) - * user type names. - */ - public static String toString(Method method) { - final StringBuffer s = new StringBuffer(); - s.append(Modifier.toString(method.getModifiers())).append(" "); - final String r = method.getReturnType().getName(); - s.append(TypeHelper.userTypeName(r)).append(" "); - s.append(method.getName()).append("("); - s.append(toString("", method.getParameterTypes())).append(")"); - s.append(toString(" throws ", method.getExceptionTypes())); - if (method.getDeclaringClass().isAnnotation() && method.getDefaultValue() != null) { - s.append(" default \"" + method.getDefaultValue() + "\""); + /** + * Returns an exhaustive string description of a Method + * presenting types as (Java) user type names. + */ + static public String toString(Method method) { + final StringBuffer s = new StringBuffer(); + s.append(Modifier.toString(method.getModifiers())).append(" "); + final String r = method.getReturnType().getName(); + s.append(TypeHelper.userTypeName(r)).append(" "); + s.append(method.getName()).append("("); + s.append(toString("", method.getParameterTypes())).append(")"); + s.append(toString(" throws ", method.getExceptionTypes())); + if (method.getDeclaringClass().isAnnotation() && method.getDefaultValue() != null) { + s.append(" default \"" + method.getDefaultValue() + "\""); + } + return s.toString(); } - return s.toString(); - } - /** Returns an combined string description of a constructor or method declaration. */ - public static String toString( - int mods, String result, String name, String[] params, String[] excepts) { - final StringBuffer s = new StringBuffer(); - s.append(Modifier.toString(mods)).append(" "); - s.append(result == null ? "" : result).append(" "); - s.append(name).append("(").append(toString("", params)).append(")"); - s.append(toString(" throws ", excepts)); - return s.toString(); - } + /** + * Returns an combined string description of a constructor or + * method declaration. + */ + static public String toString(int mods, String result, String name, + String[] params, String[] excepts) { + final StringBuffer s = new StringBuffer(); + s.append(Modifier.toString(mods)).append(" "); + s.append(result == null ? "" : result).append(" "); + s.append(name).append("(").append(toString("", params)).append(")"); + s.append(toString(" throws ", excepts)); + return s.toString(); + } - /** - * Returns an exhaustive string description of a Class presenting types as (Java) - * user type names. - */ - public static String toString(Class cls) { - final StringBuffer s = new StringBuffer(); - s.append(Modifier.toString(cls.getModifiers())); - s.append(cls.isInterface() ? " " : " class ").append(cls.getName()); - final Class superc = cls.getSuperclass(); - final Class[] interf = cls.getInterfaces(); - if (cls.isInterface()) { - s.append(toString(" extends ", interf)); - } else { - s.append(superc == null ? "" : " extends " + superc.getName()); - s.append(toString(" implements ", interf)); + /** + * Returns an exhaustive string description of a Class + * presenting types as (Java) user type names. + */ + static public String toString(Class cls) { + final StringBuffer s = new StringBuffer(); + s.append(Modifier.toString(cls.getModifiers())); + s.append(cls.isInterface() ? " " : " class ").append(cls.getName()); + final Class superc = cls.getSuperclass(); + final Class[] interf = cls.getInterfaces(); + if (cls.isInterface()) { + s.append(toString(" extends ", interf)); + } else { + s.append(superc == null ? "" : " extends " + superc.getName()); + s.append(toString(" implements ", interf)); + } + return s.toString(); } - return s.toString(); - } - /** Returns an combined string description of a class header declaration. */ - public static String toString(int mods, String name, String[] ext, String[] impl) { - final StringBuffer s = new StringBuffer(); - s.append(Modifier.toString(mods)); - final boolean isInterface = ((mods & Modifier.INTERFACE) != 0); - s.append(isInterface ? " " : " class ").append(name); - s.append(toString(" extends ", ext)); - s.append(toString(" implements ", impl)); - return s.toString(); - } + /** + * Returns an combined string description of a class header declaration. + */ + static public String toString(int mods, String name, + String[] ext, String[] impl) { + final StringBuffer s = new StringBuffer(); + s.append(Modifier.toString(mods)); + final boolean isInterface = ((mods & Modifier.INTERFACE) != 0); + s.append(isInterface ? " " : " class ").append(name); + s.append(toString(" extends ", ext)); + s.append(toString(" implements ", impl)); + return s.toString(); + } - /** - * Returns an exhaustive string description of a Member presenting types as (Java) - * user type names. - */ - public static String toString(Member member) { - final String s; - if (member instanceof Field) { - s = toString((Field) member, null); - } else if (member instanceof Constructor) { - s = toString((Constructor) member); - } else if (member instanceof Method) { - s = toString((Method) member); - } else { - s = null; + /** + * Returns an exhaustive string description of a Member + * presenting types as (Java) user type names. + */ + static public String toString(Member member) { + final String s; + if (member instanceof Field) { + s = toString((Field)member, null); + } else if (member instanceof Constructor) { + s = toString((Constructor)member); + } else if (member instanceof Method) { + s = toString((Method)member); + } else { + s = null; + } + return s; } - return s; - } } diff --git a/tck/src/main/java/org/apache/jdo/tck/util/signature/SignatureVerifier.java b/tck/src/main/java/org/apache/jdo/tck/util/signature/SignatureVerifier.java index 2ac641ade..b8fa9dba1 100644 --- a/tck/src/main/java/org/apache/jdo/tck/util/signature/SignatureVerifier.java +++ b/tck/src/main/java/org/apache/jdo/tck/util/signature/SignatureVerifier.java @@ -5,36 +5,41 @@ * 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 + * + * 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.jdo.tck.util.signature; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.io.LineNumberReader; -import java.io.PrintWriter; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; +import java.lang.reflect.Array; import java.lang.reflect.Member; -import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Constructor; + import java.util.Iterator; -import java.util.List; import java.util.Set; +import java.util.List; +import java.util.Arrays; +import java.util.ArrayList; import java.util.TreeSet; +import java.util.HashSet; + +import java.text.ParseException; + +import java.io.PrintWriter; +import java.io.IOException; +import java.io.File; +import java.io.FileReader; +import java.io.LineNumberReader; + /** * Tests classes for correct signatures. @@ -42,1832 +47,1809 @@ * @author Martin Zaun */ public class SignatureVerifier { - /** The new-line character on this system. */ - protected static final String NL = System.getProperty("line.separator"); - - /** - * All modifiers defined in java.lang.reflect.Modifier. This field is used to filter out - * vm-specific modifiers such as found in Sun's vm to identify Enum and Annotation. - */ - protected static final int ALL_MODIFIERS = - Modifier.ABSTRACT - | Modifier.FINAL - | Modifier.INTERFACE - | Modifier.NATIVE - | Modifier.PRIVATE - | Modifier.PROTECTED - | Modifier.PUBLIC - | Modifier.STATIC - | Modifier.STRICT - | Modifier.SYNCHRONIZED - | Modifier.TRANSIENT - | Modifier.VOLATILE; - - /** Pseudo modifier for annotation */ - protected static final int ANNOTATION = 0x2000; - - /** Pseudo modifier for enum */ - protected static final int ENUM = 0x4000; - - /** A writer for standard output. */ - protected final PrintWriter log; - - /** Flag to print error output only. */ - private boolean quiet; - - /** Flag to also print verbose output. */ - private boolean verbose; - - /** The parse to be used for parsing signature descriptor files. */ - protected final Parser parser = new Parser(); - - /** The classloader to be used for loading types. */ - protected final ClassLoader classLoader; - - /** The currently tested Class. */ - protected Class cls; - - /** All untested, declared members of the current class. */ - protected final Set members = new HashSet(); - - /** Collects names of loadable classes. */ - private final Set loading = new TreeSet(); - - /** Collects names of unloadable classes. */ - private final Set notLoading = new TreeSet(); - - /** Counts tested features (class, constructor, fields, methods). */ - private int tested; - - /** Counts missing members (constructor, fields, methods). */ - private int missing; - - /** Counts non-matching features (class, constructor, fields, methods). */ - private int mismatch; - - /** Counts matching features (class, constructor, fields, methods). */ - private int matching; - - /** Counts public non-standard members (constructor, fields, methods). */ - private int nonStandard; - - /** Counts other reported problems (e.g., accessing field values). */ - private int otherProblems; - - /** - * Constructs a test instance. - * - * @param loader ClassLoader - * @param log writer for logging - * @param quiet quiet option - * @param verbose verbose option - */ - public SignatureVerifier(ClassLoader loader, PrintWriter log, boolean quiet, boolean verbose) { - classLoader = this.getClass().getClassLoader(); - this.log = log; - this.quiet = quiet; - this.verbose = (!quiet && verbose); - } - - /** - * Constructs a test instance. - * - * @param log writer for logging - * @param quiet quiet option - * @param verbose verbose option - */ - public SignatureVerifier(PrintWriter log, boolean quiet, boolean verbose) { - this(SignatureVerifier.class.getClassLoader(), log, quiet, verbose); - } - - // ---------------------------------------------------------------------- - // Local Logging Methods - // ---------------------------------------------------------------------- - - /** - * Prints an error message. - * - * @param msg error message - */ - protected void logError(String msg) { - log.println(msg); - } - - /** - * Prints an info message. - * - * @param msg info message - */ - protected void logInfo(String msg) { - if (!quiet) { - log.println(msg); - } - } - - /** - * Prints a verbose message. - * - * @param msg verbose message - */ - protected void logVerbose(String msg) { - if (verbose) { - log.println(msg); - } - } - - // ---------------------------------------------------------------------- - // Test Methods - // ---------------------------------------------------------------------- - - /** - * Tests the signature of classes (in the specified classloader) against a list of signature - * descriptor files; returns with a status code. - * - * @param descrFileNames list of signature descriptor file names - * @return zero if all tests have passed and no problems were detected - * @throws IOException error reading file - * @throws ParseException error during parsing - */ - public int test(List descrFileNames) throws IOException, ParseException { - // check argument - if (descrFileNames == null || descrFileNames.isEmpty()) { - final String m = ("ERROR: No signature descriptor file to parse."); - logError(m); - return -1; - } + /** The new-line character on this system. */ + static protected final String NL = System.getProperty("line.separator"); - // clear statistics - loading.clear(); - notLoading.clear(); - tested = 0; - missing = 0; - mismatch = 0; - matching = 0; - nonStandard = 0; - otherProblems = 0; - - // process descriptor files - parser.parse(descrFileNames); - report(); - - // return a positive value in case of any problems - return (notLoading.size() + missing + mismatch + nonStandard + otherProblems); - } - - /** Reports the results of the last signature test run. */ - public void report() { - logInfo(""); - logInfo("Signature Test Results"); - logInfo("======================"); - logInfo(""); - logInfo(" tested features: " + tested); - logInfo(""); - logInfo("Successes:"); - logInfo(" matching features: " + matching); - logInfo(" loadable classes: " + loading.size()); - logInfo(""); - logInfo("Failures:"); - logInfo(" missing features: " + missing); - logInfo(" non-matching features: " + mismatch); - logInfo(" non-standard features: " + nonStandard); - logInfo(" unloadable classes: " + notLoading.size()); - logInfo(" other problems: " + otherProblems); - logInfo(""); - } - - // ---------------------------------------------------------------------- - // Test Logic - // ---------------------------------------------------------------------- - - /** - * Handles class loading problems. - * - * @param t Throwable - */ - protected void handleNotLoading(Throwable t) { - notLoading.add(t.getMessage().replace('/', '.')); - final String m = ("--- failed loading class;" + NL + " caught: " + t); - logError(m); - } - - /** - * Handles missing members. - * - * @param msg message - * @param exp expected - */ - protected void handleMissing(String msg, String exp) { - missing++; - final String m = - ("--- " - + msg - + NL - + " expected: " - + exp - + NL - + " class: " - + Formatter.toString(cls)); - logError(m); - } - - /** - * Handles non-matching features. - * - * @param msg message - * @param exp expected - * @param fnd feature - */ - protected void handleMismatch(String msg, String exp, String fnd) { - mismatch++; - final String m = - ("--- " - + msg - + NL - + " expected: " - + exp - + NL - + " found: " - + fnd - + NL - + " class: " - + Formatter.toString(cls)); - logError(m); - } - - /** - * Handles public non-standard features. - * - * @param msg message - * @param fnd feature - */ - protected void handleNonStandard(String msg, String fnd) { - nonStandard++; - final String m = - ("--- " - + msg - + NL - + " found: " - + fnd - + NL - + " class: " - + Formatter.toString(cls)); - logError(m); - } - - /** - * Handles other problems. - * - * @param msg message - * @param exp expected - */ - protected void handleProblem(String msg, String exp) { - otherProblems++; - final String m = - ("--- " - + msg - + NL - + " expected: " - + exp - + NL - + " class: " - + Formatter.toString(cls)); - logError(m); - } - - /** - * Handles a perfect feature match. - * - * @param msg message - * @param fnd feature - */ - protected void handleMatch(String msg, String fnd) { - matching++; - final String m = ("+++ " + msg + fnd); - logVerbose(m); - } - - /** - * Returns the class objects for given (Java) user type names. - * - * @param userTypeName user type names - * @return class objects - */ - protected Class[] getClasses(String[] userTypeName) { - final Class[] cls = new Class[userTypeName.length]; - for (int i = userTypeName.length - 1; i >= 0; i--) { - cls[i] = getClass(userTypeName[i]); - } - return cls; - } - - /** - * Returns the class object for a given (Java) user type name. - * - * @param userTypeName user type name - * @return class object - */ - protected Class getClass(String userTypeName) { - // use helper for retrieving class objects for primitive types - Class cls = TypeHelper.primitiveClass(userTypeName); - if (cls != null) { - return cls; - } - - // load class - try { - final String r = TypeHelper.reflectionTypeName(userTypeName); - cls = Class.forName(r, false, classLoader); - loading.add(userTypeName); - } catch (LinkageError err) { - handleNotLoading(err); - } catch (ClassNotFoundException ex) { - handleNotLoading(ex); - } - return cls; - } - - /** - * Check an expected value expression (the value of a static field or the default value of an - * annotation method), comparing it to the actual value from the Field or Method object. Only - * supports primitive, enum, empty array of enum, empty array of annotation, and String. - * - * @param value the String form of the value from the signature file - * @param type the type as declared in the class - * @param actual the actual value - * @return the description of the expected value, or null if ok - * @throws java.lang.NumberFormatException format exception - */ - protected String checkValue(String value, String type, Object actual) - throws NumberFormatException { - // note array type - boolean isArray = false; - if (type.endsWith("[]")) { - isArray = true; - type = type.substring(0, type.length() - 2); - // remove { from beginning and } from end - value = value.substring(1, value.length() - 1); - } - // first check primitive type - final Object exp; - Class expClass; - final boolean ok; - if (type.equals("byte")) { - if (isArray) { - ok = actual.getClass().getComponentType().equals(byte.class); - } else { - ok = Byte.valueOf(value).equals(actual); - } - } else if (type.equals("boolean")) { - if (isArray) { - ok = actual.getClass().getComponentType().equals(boolean.class); - } else { - ok = Boolean.valueOf(value).equals(actual); - } - } else if (type.equals("short")) { - if (isArray) { - ok = actual.getClass().getComponentType().equals(short.class); - } else { - ok = Short.valueOf(value).equals(actual); - } - } else if (type.equals("int")) { - if (isArray) { - ok = actual.getClass().getComponentType().equals(int.class); - } else { - ok = Integer.valueOf(value).equals(actual); - } - } else if (type.equals("long")) { - if (isArray) { - ok = actual.getClass().getComponentType().equals(long.class); - } else { - ok = Long.valueOf(value).equals(actual); - } - } else if (type.equals("float")) { - if (isArray) { - ok = actual.getClass().getComponentType().equals(float.class); - } else { - ok = Float.valueOf(value).equals(actual); - } - } else if (type.equals("double")) { - if (isArray) { - ok = actual.getClass().getComponentType().equals(double.class); - } else { - ok = Double.valueOf(value).equals(actual); - } - } else if (type.equals("char")) { - if (isArray) { - ok = actual.getClass().getComponentType().equals(char.class); - } else { - ok = Character.valueOf(value.charAt(1)).equals(actual); - } - // next check Class - } else if (type.equals("java.lang.Class")) { - if (isArray) { - ok = actual.getClass().getComponentType().equals(Class.class); - } else { - // strip ".class" from type name - int offset = value.indexOf(".class"); - value = value.substring(0, offset); - ok = getClass(value).equals(actual); - } - // next check String - } else if (type.equals("java.lang.String")) { - if (isArray) { - ok = actual.getClass().getComponentType().equals(String.class); - } else { - // cut off '\"' chars at begin and end - final String s; - if (value.length() > 1) { - s = value.substring(1, value.length() - 1); - } else { - s = ""; - } - ok = (String.valueOf(s)).equals(actual); - } - // now check non-java.lang annotations and enums - } else { - expClass = getClass(type); - if (isArray) { - // check if the actual component type is the right class - // don't check the actual values because only empty arrays - // are supported. - ok = actual.getClass().getComponentType().equals(expClass); - } else if (expClass == null) { - System.out.println( - "WARNING : checkValue value=" + value + " type=" + type + " comes up with null class"); - ok = false; - } else if (expClass.isAnnotation()) { - // check whether the type isAssignableFrom the class of the actual value, - // if type is an annotation. The actual value is a dynamic proxy, - // so an equals comparison does not work. - ok = expClass.isAssignableFrom(actual.getClass()); - } else { - // get the actual value which must be a static class.field - Object expectedValue = null; - try { - // now get actual value - // separate value name into class and field name - int lastDot = value.lastIndexOf("."); - String expectedClassName = value.substring(0, lastDot); - String expectedFieldName = value.substring(lastDot + 1, value.length()); - // get Class object from class name - Class expectedClass = getClass(expectedClassName); - if (expectedClass == null) throw new ClassNotFoundException(); - // get Field object from Class and field name - Field expectedField = expectedClass.getField(expectedFieldName); - expectedValue = expectedField.get(null); - } catch (NoSuchFieldException ex) { - handleNotLoading(ex); - } catch (SecurityException ex) { - handleNotLoading(ex); - } catch (IllegalArgumentException ex) { - handleNotLoading(ex); - } catch (IllegalAccessException ex) { - handleNotLoading(ex); - } catch (ClassNotFoundException ex) { - handleNotLoading(ex); - } - ok = expectedValue.equals(actual); - } - } - // return message if not ok - if (ok) return null; - else return value; - } - - /** - * Validates a field against a prescribed signature. - * - * @param mods modifier - * @param type type - * @param name name - * @param value value - */ - protected void checkField(int mods, String type, String name, String value) { - tested++; - type = TypeHelper.qualifiedUserTypeName(type); - - // get field - final Field field; - try { - field = cls.getDeclaredField(name); - } catch (NoSuchFieldException ex) { - handleMissing("missing field: ", Formatter.toString(mods, type, name, value)); - return; - } catch (LinkageError err) { - handleNotLoading(err); - return; - } - - // check modifiers - if (cls.isInterface()) { - // fields interfaces are implicitly public, static, and final - mods |= Modifier.PUBLIC; - mods |= Modifier.STATIC; - mods |= Modifier.FINAL; - } - if (mods != convertModifiers(field)) { - handleMismatch( - "field declaration: non-matching modifiers;", - Formatter.toString(mods, type, name, null), - Formatter.toString(field, null)); - } - - // check type - if (!TypeHelper.isNameMatch(type, field.getType())) { - handleMismatch( - "field declaration: non-matching type;", - Formatter.toString(mods, type, name, null), - Formatter.toString(field, null)); - } - - // check field value if any - Object actualValue = null; - if (value != null) { - // only support for public, static, and final fields - final int m = (Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL); - if ((mods & m) == 0) { - handleProblem( - "field declaration: ignoring field value " + "definition in descriptor file;", - Formatter.toString(mods, type, name, value)); - } else { - // compare field's expected with found value - try { - actualValue = field.get(null); - } catch (IllegalAccessException ex) { - handleProblem( - "field declaration: cannot access field " + "value, exception: " + ex + ";", - Formatter.toString(mods, type, name, value)); - } - String error = checkValue(value, type, actualValue); - if (error != null) { - handleMismatch( - "field declaration: non-matching values;", - Formatter.toString(mods, type, name, error), - Formatter.toString(field, "\"" + actualValue + "\"")); - } - } - } - - // field OK - members.remove(field); - handleMatch("has field: ", Formatter.toString(field, actualValue)); - } - - /** - * Validates a constructor against a prescribed signature. - * - * @param mods modifier - * @param params parameters - * @param excepts excepts - */ - protected void checkConstructor(int mods, String[] params, String[] excepts) { - tested++; - params = TypeHelper.qualifiedUserTypeNames(params); - excepts = TypeHelper.qualifiedUserTypeNames(excepts); - - // get parameter classes - final Class[] prms = getClasses(params); - if (prms == null) { - return; - } + /** All modifiers defined in java.lang.reflect.Modifier. + * This field is used to filter out vm-specific modifiers + * such as found in Sun's vm to identify Enum and Annotation. + */ + static protected final int ALL_MODIFIERS = + Modifier.ABSTRACT | + Modifier.FINAL | + Modifier.INTERFACE | + Modifier.NATIVE | + Modifier.PRIVATE | + Modifier.PROTECTED | + Modifier.PUBLIC | + Modifier.STATIC | + Modifier.STRICT | + Modifier.SYNCHRONIZED | + Modifier.TRANSIENT | + Modifier.VOLATILE; - // get constructor - final Constructor ctor; - try { - ctor = cls.getDeclaredConstructor(prms); - } catch (NoSuchMethodException ex) { - String name = cls.getName(); - final int i = name.lastIndexOf('.'); - name = (i < 0 ? name : name.substring(i)); - handleMissing("missing constructor: ", Formatter.toString(mods, null, name, params, excepts)); - return; - } catch (LinkageError err) { - handleNotLoading(err); - return; - } + /** Pseudo modifier for annotation */ + static protected final int ANNOTATION = 0x2000; - // check modifiers - if (mods != ctor.getModifiers()) { - handleMismatch( - "constructor declaration: non-matching modifiers;", - Formatter.toString(mods, null, cls.getName(), params, excepts), - Formatter.toString(ctor)); - } + /** Pseudo modifier for enum */ + static protected final int ENUM = 0x4000; - // check exceptions - if (!TypeHelper.isNameMatch(excepts, ctor.getExceptionTypes())) { - handleMismatch( - "method declaration: non-matching exceptions;", - Formatter.toString(mods, null, cls.getName(), params, excepts), - Formatter.toString(ctor)); - } + /** A writer for standard output. */ + protected final PrintWriter log; - // constructor OK - members.remove(ctor); - handleMatch("has constructor: ", Formatter.toString(ctor)); - } - - /** - * Validates a method against a prescribed signature. - * - * @param mods modifier - * @param result result - * @param name name - * @param params parameters - * @param excepts excepts - * @param value value - */ - protected void checkMethod( - int mods, String result, String name, String[] params, String[] excepts, String value) { - tested++; - params = TypeHelper.qualifiedUserTypeNames(params); - excepts = TypeHelper.qualifiedUserTypeNames(excepts); - result = TypeHelper.qualifiedUserTypeName(result); - - // get parameter classes - final Class[] prms = getClasses(params); - if (prms == null) { - return; - } + /** Flag to print error output only. */ + private boolean quiet; - // get method - final Method method; - try { - method = cls.getDeclaredMethod(name, prms); - } catch (NoSuchMethodException ex) { - handleMissing("missing method: ", Formatter.toString(mods, result, name, params, excepts)); - return; - } catch (LinkageError err) { - handleNotLoading(err); - return; - } + /** Flag to also print verbose output. */ + private boolean verbose; - // check modifiers - if (cls.isInterface()) { - // methods in interfaces are implicitly public - mods |= Modifier.PUBLIC; - } - Class resultType = getClass(result); - if (resultType == null) { - System.out.println( - "WARNING : checkMethod " - + name - + " result=" - + result - + " comes up with null resultType!"); - } else if (resultType.isAnnotation()) { - // add ANNOTATION modifier if the result type is an annotation - mods |= ANNOTATION; - } - if (mods != convertModifiers(method)) { - handleMismatch( - "method declaration: non-matching modifiers;", - Formatter.toString(mods, result, name, params, excepts), - Formatter.toString(method)); - } + /** The parse to be used for parsing signature descriptor files. */ + protected final Parser parser = new Parser(); - // check return type - if (!TypeHelper.isNameMatch(result, method.getReturnType())) { - handleMismatch( - "method declaration: non-matching return type", - Formatter.toString(mods, result, name, params, excepts), - Formatter.toString(method)); - } + /** The classloader to be used for loading types. */ + protected final ClassLoader classLoader; - // check exceptions - if (!TypeHelper.isNameMatch(excepts, method.getExceptionTypes())) { - handleMismatch( - "method declaration: non-matching exceptions;", - Formatter.toString(mods, result, name, params, excepts), - Formatter.toString(method)); - } + /** The currently tested Class. */ + protected Class cls; + + /** All untested, declared members of the current class. */ + protected final Set members = new HashSet(); - // check default value of an annotation element (method) - if (value != null) { - Object actualValue = null; - try { - actualValue = method.getDefaultValue(); - } catch (Exception ex) { - handleProblem( - "method declaration: cannot access default " + "value, exception: " + ex + ";", - Formatter.toString(mods, result, name, value)); - } - // check value expected versus actual - String wrong = checkValue(value, result, actualValue); - - if (wrong != null) { - handleMismatch( - "method declaration: non-matching default value;", - Formatter.toString(mods, result, name + "() default ", wrong), - Formatter.toString(method)); - } - } + /** Collects names of loadable classes. */ + private final Set loading = new TreeSet(); - // method OK - members.remove(method); - handleMatch("has method: ", Formatter.toString(method)); - } - - /** - * Validates a class declaration against a prescribed signature. - * - * @param mods modifier - * @param name name - * @param ext ext - * @param impl implementation - */ - protected void checkClass(int mods, String name, String[] ext, String[] impl) { - logVerbose(""); - logVerbose("testing " + Formatter.toString(mods, name, ext, impl)); - tested++; - ext = TypeHelper.qualifiedUserTypeNames(ext); - impl = TypeHelper.qualifiedUserTypeNames(impl); - - // get and assign currently processed class - cls = getClass(name); - if (cls == null) { - return; // can't load class - } + /** Collects names of unloadable classes. */ + private final Set notLoading = new TreeSet(); - // collect all declared members of current class - members.clear(); - try { - members.addAll(Arrays.asList(cls.getDeclaredFields())); - members.addAll(Arrays.asList(cls.getDeclaredConstructors())); - members.addAll(Arrays.asList(cls.getDeclaredMethods())); - } catch (LinkageError err) { - handleNotLoading(err); - } + /** Counts tested features (class, constructor, fields, methods). */ + private int tested; - // check modifiers - final boolean isInterface = ((mods & Modifier.INTERFACE) != 0); - if (isInterface) { - mods |= Modifier.ABSTRACT; - } - if (mods != convertModifiers(cls)) { - handleMismatch( - "class declaration: non-matching modifiers;", - Formatter.toString(mods, name, ext, impl), - Formatter.toString(cls)); - } + /** Counts missing members (constructor, fields, methods). */ + private int missing; - // check superclass and extended/implemented interfaces - final Class superclass = cls.getSuperclass(); - final Class[] interfaces = cls.getInterfaces(); - if (isInterface) { - // assert (impl.length == 0); - if (!TypeHelper.isNameMatch(ext, interfaces)) { - handleMismatch( - "interface declaration: non-matching interfaces;", - Formatter.toString(mods, name, ext, impl), - Formatter.toString(cls)); - } - } else { - // assert (ext.length <= 1); - final String s = (ext.length == 0 ? "java.lang.Object" : ext[0]); - if (!TypeHelper.isNameMatch(s, superclass)) { - handleMismatch( - "class declaration: non-matching superclass;", - Formatter.toString(mods, name, ext, impl), - Formatter.toString(cls)); - } - if (!TypeHelper.isNameMatch(impl, interfaces)) { - handleMismatch( - "class declaration: non-matching interfaces;", - Formatter.toString(mods, name, ext, impl), - Formatter.toString(cls)); - } - } + /** Counts non-matching features (class, constructor, fields, methods). */ + private int mismatch; - handleMatch("has class: ", Formatter.toString(cls)); - } + /** Counts matching features (class, constructor, fields, methods). */ + private int matching; - /** Runs checks on a class after its members have been validated. */ - protected void postCheckClass() { - if (cls == null) { - return; // nothing to do if class couldn't be loaded - } + /** Counts public non-standard members (constructor, fields, methods). */ + private int nonStandard; - // check for public non-standard members - for (Iterator i = members.iterator(); i.hasNext(); ) { - final Member m = (Member) i.next(); - if ((m.getModifiers() & Modifier.PUBLIC) != 0) { - handleNonStandard("non-standard, public member;", Formatter.toString(m)); - } - } - } - - /** - * Return modifiers for the class, but handling enum and annotation as if they had a special - * modifier. - * - * @param cls the class - * @return modifiers of the class with extra flags for enum and annotation - */ - protected int convertModifiers(Class cls) { - int result = cls.getModifiers(); - // first remove extraneous stuff - result &= ALL_MODIFIERS; - // if enum, set pseudo enum flag - if (cls.isEnum()) result |= ENUM; - // if annotation, set pseudo annotation flag - if (cls.isAnnotation()) result |= ANNOTATION; - return result; - } - - /** - * Return modifiers for the method, but handling enum and annotation as if they had a special - * modifier. - * - * @param method the method - * @return modifiers of the class with extra flags for enum and annotation - */ - protected int convertModifiers(Method method) { - int result = method.getModifiers(); - // first remove extraneous stuff - result &= ALL_MODIFIERS; - // if enum return type, set pseudo enum flag - if (method.getReturnType().isEnum()) result |= ENUM; - // if annotation, set pseudo annotation flag - if (method.getReturnType().isAnnotation()) result |= ANNOTATION; - // if return type is an enum class, un-set FINAL modifier in all methods - // because in Java 5, methods are generated as final; in Java 6, not - if (method.getDeclaringClass().isEnum()) result &= ~Modifier.FINAL; - return result; - } - - /** - * Return modifiers for the field, but handling enum as if it had a special modifier. - * - * @param field the field - * @return modifiers of the class with extra flag for enum - */ - protected int convertModifiers(Field field) { - int result = field.getModifiers(); - // first remove extraneous stuff - result &= ALL_MODIFIERS; - // if enum, set pseudo enum flag - if (field.isEnumConstant()) result |= ENUM; - return result; - } - - // ---------------------------------------------------------------------- - // Parser for Signature Descriptor Files - // ---------------------------------------------------------------------- - - /** For parsing of signature descriptor files. */ - protected class Parser { - /** The current descriptor file being parsed. */ - private File descriptorFile; - - /** The line number reader for the current descriptor file. */ - private LineNumberReader ir; - - /** A look-ahead token to be read next. */ - private String nextToken; + /** Counts other reported problems (e.g., accessing field values). */ + private int otherProblems; /** - * Returns an error message reporting an unexpected end of file. - * - * @return message + * Constructs a test instance. + * @param loader ClassLoader + * @param log writer for logging + * @param quiet quiet option + * @param verbose verbose option */ - protected String msgUnexpectedEOF() { - return ("unexpected end of file at line: " - + ir.getLineNumber() - + ", file: " - + descriptorFile.getPath()); - } + public SignatureVerifier(ClassLoader loader, PrintWriter log, + boolean quiet, boolean verbose) { + classLoader = this.getClass().getClassLoader(); + this.log = log; + this.quiet = quiet; + this.verbose = (!quiet && verbose); + } /** - * Returns an error message reporting an unextected token. - * - * @param t token - * @return error message + * Constructs a test instance. + * @param log writer for logging + * @param quiet quiet option + * @param verbose verbose option */ - protected String msgUnexpectedToken(String t) { - return ("unexpected token: '" - + t - + "'" - + " in line: " - + ir.getLineNumber() - + ", file: " - + descriptorFile.getPath()); + public SignatureVerifier(PrintWriter log, + boolean quiet, boolean verbose) { + this(SignatureVerifier.class.getClassLoader(), log, quiet, verbose); } - /** - * Retrieves the look-ahead token to be parsed next. - * - * @return look ahead - */ - protected String getLookAhead() { - final String t = nextToken; - nextToken = null; - return t; - } + // ---------------------------------------------------------------------- + // Local Logging Methods + // ---------------------------------------------------------------------- /** - * Sets the look-ahead token to be parsed next. - * - * @param t token + * Prints an error message. + * @param msg error message */ - protected void setLookAhead(String t) { - // assert (nextToken == null); - nextToken = t; + protected void logError(String msg) { + log.println(msg); } /** - * Skips any "white space" and /* style comments and returns whether there are more characters - * to be parsed. - * - * @return true if there are more characters to be parsed - * @throws IOException IO error + * Prints an info message. + * @param msg info message */ - protected boolean skip() throws IOException { - Character c; - Character cnext; - // Permitted states are white, commentSlashStar, commentSlashSlash - String state = "white"; - final Character SLASH = '/'; - final Character STAR = '*'; - while (true) { - c = peek(); - if (c == null) return false; - if (state.equals("commentSlashStar") && STAR.equals(c)) { - cnext = peek(); - if (cnext == null) return false; - if (SLASH.equals(cnext)) { - state = "white"; - } - continue; - } - if (state.equals("white")) { - if (SLASH.equals(c)) { - cnext = peek(); - if (cnext == null) return false; - if (STAR.equals(cnext)) { - state = "commentSlashStar"; - continue; - } - if (SLASH.equals(cnext)) { - state = "commentSlashSlash"; - continue; - } - } - if (!Character.isWhitespace(c)) { - break; - } - } - if (state.equals("commentSlashSlash") - && (c == Character.LINE_SEPARATOR || c == '\n' || c == '\r')) { - state = "white"; - continue; - } - } - ir.reset(); - return true; + protected void logInfo(String msg) { + if (!quiet) { + log.println(msg); + } } /** - * Returns next char, or null if there is none - * - * @return next char - * @throws IOException IO error + * Prints a verbose message. + * @param msg verbose message */ - protected Character peek() throws IOException { - ir.mark(1); - int i; - if ((i = ir.read()) < 0) { - return null; - } - return Character.valueOf((char) i); + protected void logVerbose(String msg) { + if (verbose) { + log.println(msg); + } } - /** - * Scans for an (unqualified) identifier. - * - * @return null if the next token is not an identifier - * @throws IOException IO error - * @throws ParseException parsing error - */ - protected String scanIdentifier() throws IOException, ParseException { - // parse stored token if any - String t; - if ((t = getLookAhead()) != null) { - if (!Character.isJavaIdentifierStart(t.charAt(0))) { - setLookAhead(t); // not an identifier - return null; - } - return t; - } - - // parse first char - if (!skip()) { - throw new ParseException(msgUnexpectedEOF(), 0); - } - ir.mark(1); - char c = (char) ir.read(); - if (!Character.isJavaIdentifierStart(c)) { - ir.reset(); // not start of an identifier - return null; - } - - // parse remaining chars - final StringBuffer sb = new StringBuffer(); - do { - sb.append(c); - int i; - ir.mark(1); - if ((i = ir.read()) < 0) break; - c = (char) i; - } while (Character.isJavaIdentifierPart(c)); - ir.reset(); // not part of an identifier - return sb.toString(); - } + // ---------------------------------------------------------------------- + // Test Methods + // ---------------------------------------------------------------------- /** - * Scans for a number literal. - * - * @return null if the next token is not a number - * @throws IOException IO error - * @throws ParseException parsing error + * Tests the signature of classes (in the specified classloader) against + * a list of signature descriptor files; returns with a status code. + * @param descrFileNames list of signature descriptor file names + * @return zero if all tests have passed and no problems were detected + * @throws IOException error reading file + * @throws ParseException error during parsing */ - protected String scanNumberLiteral() throws IOException, ParseException { - // parse stored token if any - String t; - if ((t = getLookAhead()) != null) { - if (!(t.charAt(0) == '-' || Character.isDigit(t.charAt(0)))) { - setLookAhead(t); // not a number literal - return null; - } - return t; - } - - // parse first char - if (!skip()) { - throw new ParseException(msgUnexpectedEOF(), 0); - } - ir.mark(1); - char c = (char) ir.read(); - if (Character.isDigit(c)) { - } else if (c == '-') { - skip(); - } else { - ir.reset(); // not start of a number - return null; - } - - // parse remaining chars - final StringBuffer sb = new StringBuffer(); - do { - sb.append(c); - int i; - ir.mark(1); - if ((i = ir.read()) < 0) break; - c = (char) i; - } while (Character.isLetterOrDigit(c) || c == '-' || c == '.'); - ir.reset(); // not part of a number - return sb.toString(); + public int test(List descrFileNames) + throws IOException, ParseException { + // check argument + if (descrFileNames == null || descrFileNames.isEmpty()) { + final String m = ("ERROR: No signature descriptor file to parse."); + logError(m); + return -1; + } + + // clear statistics + loading.clear(); + notLoading.clear(); + tested = 0; + missing = 0; + mismatch = 0; + matching = 0; + nonStandard = 0; + otherProblems = 0; + + // process descriptor files + parser.parse(descrFileNames); + report(); + + // return a positive value in case of any problems + return (notLoading.size() + missing + mismatch + nonStandard + + otherProblems); } /** - * Scans for a character literal. - * - * @return null if the next token is not a character - * @throws IOException IO error - * @throws ParseException parsing error + * Reports the results of the last signature test run. */ - protected String scanCharacterLiteral() throws IOException, ParseException { - // parse stored token if any - String t; - if ((t = getLookAhead()) != null) { - if (t.charAt(0) != '\'') { - setLookAhead(t); // not a char literal - return null; - } - return t; - } - - // parse first char - if (!skip()) { - throw new ParseException(msgUnexpectedEOF(), 0); - } - ir.mark(1); - char c = (char) ir.read(); - if (c != '\'') { - ir.reset(); // not start of a char literal - return null; - } - - // parse remaining two chars - final StringBuffer sb = new StringBuffer(); - for (int j = 0; j < 2; j++) { - sb.append(c); - int i; - if ((i = ir.read()) < 0) { - throw new ParseException(msgUnexpectedEOF(), 0); - } - c = (char) i; - } - if (c != '\'') { - throw new ParseException(msgUnexpectedToken(String.valueOf(c)), 0); - } - sb.append(c); // keep '\'' part of a char literal - return sb.toString(); + public void report() { + logInfo(""); + logInfo("Signature Test Results"); + logInfo("======================"); + logInfo(""); + logInfo(" tested features: " + tested); + logInfo(""); + logInfo("Successes:"); + logInfo(" matching features: " + matching); + logInfo(" loadable classes: " + loading.size()); + logInfo(""); + logInfo("Failures:"); + logInfo(" missing features: " + missing); + logInfo(" non-matching features: " + mismatch); + logInfo(" non-standard features: " + nonStandard); + logInfo(" unloadable classes: " + notLoading.size()); + logInfo(" other problems: " + otherProblems); + logInfo(""); } + + // ---------------------------------------------------------------------- + // Test Logic + // ---------------------------------------------------------------------- /** - * Scans for a string literal. - * - * @return null if the next token is not a string - * @throws IOException IO error - * @throws ParseException parsing error + * Handles class loading problems. + * @param t Throwable */ - protected String scanStringLiteral() throws IOException, ParseException { - // parse stored token if any - String t; - if ((t = getLookAhead()) != null) { - if (t.charAt(0) != '\"') { - setLookAhead(t); // not a string literal - return null; - } - return t; - } - - // parse first char - if (!skip()) { - throw new ParseException(msgUnexpectedEOF(), 0); - } - ir.mark(1); - char c = (char) ir.read(); - if (c != '\"') { - ir.reset(); // not start of a string literal - return null; - } - - // parse remaining chars - final StringBuffer sb = new StringBuffer(); - do { - sb.append(c); - int i; - if ((i = ir.read()) < 0) { - throw new ParseException(msgUnexpectedEOF(), 0); - } - c = (char) i; - } while (c != '\"'); // not supported: nested '\"' char sequences - sb.append(c); // keep '\"' part of a string literal - return sb.toString(); + protected void handleNotLoading(Throwable t) { + notLoading.add(t.getMessage().replace('/', '.')); + final String m = ("--- failed loading class;" + NL + + " caught: " + t); + logError(m); } /** - * Scans for an array literal. Limitation: only the empty array "{}" can be scanned. - * - * @return null if the next token is not an array - * @throws IOException IO error - * @throws ParseException parsing error + * Handles missing members. + * @param msg message + * @param exp expected */ - protected String scanArrayLiteral() throws IOException, ParseException { - // parse stored token if any - String t; - if ((t = getLookAhead()) != null) { - if (t.charAt(0) != '{' || t.charAt(1) != '}') { - setLookAhead(t); // not an array literal - return null; - } - return t; - } - - // parse first char - if (!skip()) { - throw new ParseException(msgUnexpectedEOF(), 0); - } - ir.mark(1); - char c = (char) ir.read(); - if (c != '{') { - ir.reset(); // not start of an array literal - return null; - } - c = (char) ir.read(); - if (c != '}') { - ir.reset(); // not end of an array literal - return null; - } - - return "{}"; + protected void handleMissing(String msg, String exp) { + missing++; + final String m = ("--- " + msg + NL + + " expected: " + exp + NL + + " class: " + Formatter.toString(cls)); + logError(m); } /** - * Scans for an at-sign - * - * @return null if the next token is not an at-sign - * @throws IOException IO error - * @throws ParseException parsing error + * Handles non-matching features. + * @param msg message + * @param exp expected + * @param fnd feature */ - protected String scanAtSign() throws IOException, ParseException { - // parse stored token if any - String t; - if ((t = getLookAhead()) != null) { - if (t.charAt(0) != '@') { - setLookAhead(t); // not an at-sign - return null; - } - return t; - } - - // parse first char - if (!skip()) { - throw new ParseException(msgUnexpectedEOF(), 0); - } - ir.mark(1); - char c = (char) ir.read(); - if (c != '@') { - ir.reset(); // not an at-sign - return null; - } - - return "@"; + protected void handleMismatch(String msg, String exp, String fnd) { + mismatch++; + final String m = ("--- " + msg + NL + + " expected: " + exp + NL + + " found: " + fnd + NL + + " class: " + Formatter.toString(cls)); + logError(m); } /** - * Returns the next token to be parsed. - * - * @return never null - * @throws IOException IO error - * @throws ParseException parsing error + * Handles public non-standard features. + * @param msg message + * @param fnd feature */ - protected String parseToken() throws IOException, ParseException { - String t; - if ((t = getLookAhead()) != null) { - } else if ((t = scanIdentifier()) != null) { - } else if ((t = scanNumberLiteral()) != null) { - } else if ((t = scanStringLiteral()) != null) { - } else if ((t = scanCharacterLiteral()) != null) { - } else if ((t = scanAtSign()) != null) { - } else { - setLookAhead(t); // not an identifier, number, or string - // next non-white char - if (!skip()) { - throw new ParseException(msgUnexpectedEOF(), 0); - } - t = String.valueOf((char) ir.read()); - } - // log.println("parseToken() : '" + t + "'"); - return t; + protected void handleNonStandard(String msg, String fnd) { + nonStandard++; + final String m = ("--- " + msg + NL + + " found: " + fnd + NL + + " class: " + Formatter.toString(cls)); + logError(m); } /** - * Parses the next token and validates it against an expected one. - * - * @param token the token - * @return never null - * @throws IOException IO error - * @throws ParseException parsing error + * Handles other problems. + * @param msg message + * @param exp expected */ - protected String demandToken(String token) throws IOException, ParseException { - final String t = parseToken(); - if (!t.equals(token)) { - throw new ParseException(msgUnexpectedToken(t), 0); - } - return t; + protected void handleProblem(String msg, String exp) { + otherProblems++; + final String m = ("--- " + msg + NL + + " expected: " + exp + NL + + " class: " + Formatter.toString(cls)); + logError(m); } /** - * Parses a literal. - * - * @return null if the next token is not a literal - * @throws IOException IO error - * @throws ParseException parsing error + * Handles a perfect feature match. + * @param msg message + * @param fnd feature */ - protected String parseLiteral() throws IOException, ParseException { - String t; - if ((t = scanNumberLiteral()) != null) { - } else if ((t = scanStringLiteral()) != null) { - } else if ((t = scanCharacterLiteral()) != null) { - } else if ((t = scanArrayLiteral()) != null) { - } - // log.println("parseLiteral() : '" + t + "'"); - return t; + protected void handleMatch(String msg, String fnd) { + matching++; + final String m = ("+++ " + msg + fnd); + logVerbose(m); } /** - * Parses the next token and validates that it is a literal. - * - * @return never null - * @throws IOException IO error - * @throws ParseException parsing error + * Returns the class objects for given (Java) user type names. + * @param userTypeName user type names + * @return class objects */ - protected String demandLiteral() throws IOException, ParseException { - final String l = parseLiteral(); - if (l == null) { - throw new ParseException(msgUnexpectedToken(parseToken()), 0); - } - return l; + protected Class[] getClasses(String[] userTypeName) { + final Class[] cls = new Class[userTypeName.length]; + for (int i = userTypeName.length - 1; i >= 0; i--) { + cls[i] = getClass(userTypeName[i]); + } + return cls; } - + /** - * Parses the next token and validates that it is a constant, which is either a literal or a - * static member. - * - * @return the description of the field - * @throws IOException IO error - * @throws ParseException parsing error + * Returns the class object for a given (Java) user type name. + * @param userTypeName user type name + * @return class object */ - protected String demandConstant() throws IOException, ParseException { - final String literal = parseLiteral(); - if (literal != null) { - return literal; - } - final String field = demandIdentifier(); - if (field == null) { - throw new ParseException(msgUnexpectedToken(parseToken()), 0); - } - return field; - } - - /** - * Parses an annotation which is an at-sign followed by a fully qualified interface name. - * - * @return null if the next token is not an annotation, otherwise return the - * annotation type name without the at-sign. - * @throws IOException IO error - * @throws ParseException parsing error + protected Class getClass(String userTypeName) { + // use helper for retrieving class objects for primitive types + Class cls = TypeHelper.primitiveClass(userTypeName); + if (cls != null) { + return cls; + } + + // load class + try { + final String r = TypeHelper.reflectionTypeName(userTypeName); + cls = Class.forName(r, false, classLoader); + loading.add(userTypeName); + } catch (LinkageError err) { + handleNotLoading(err); + } catch (ClassNotFoundException ex) { + handleNotLoading(ex); + } + return cls; + } + + /** Check an expected value expression (the value of a static field + * or the default value of an annotation method), comparing it to + * the actual value from the Field or Method object. + * Only supports primitive, enum, empty array of enum, empty array of + * annotation, and String. + * @param value the String form of the value from the signature file + * @param type the type as declared in the class + * @param actual the actual value + * @return the description of the expected value, or null if ok + * @throws java.lang.NumberFormatException format exception */ - protected String parseAnnotation() throws IOException, ParseException { - String t; - // parse stored token if any - if ((t = getLookAhead()) != null) { - if (t.charAt(0) != '@') { - setLookAhead(t); // not a annotation - return null; - } - } else if ((t = scanAtSign()) != null) { - } else { - return null; - } - - final String identifier = demandIdentifier(); - if (identifier == null) { - throw new ParseException(msgUnexpectedToken(parseToken()), 0); - } - - return identifier; + protected String checkValue(String value, String type, Object actual) + throws NumberFormatException { + // note array type + boolean isArray = false; + if (type.endsWith("[]")) { + isArray = true; + type = type.substring(0, type.length() - 2); + // remove { from beginning and } from end + value = value.substring(1, value.length() - 1); + } + // first check primitive type + final Object exp; + Class expClass; + final boolean ok; + if (type.equals("byte")) { + if (isArray) { + ok = actual.getClass().getComponentType().equals(byte.class); + } else { + ok = Byte.valueOf(value).equals(actual); + } + } else if (type.equals("boolean")) { + if (isArray) { + ok = actual.getClass().getComponentType().equals(boolean.class); + } else { + ok = Boolean.valueOf(value).equals(actual); + } + } else if (type.equals("short")) { + if (isArray) { + ok = actual.getClass().getComponentType().equals(short.class); + } else { + ok = Short.valueOf(value).equals(actual); + } + } else if (type.equals("int")) { + if (isArray) { + ok = actual.getClass().getComponentType().equals(int.class); + } else { + ok = Integer.valueOf(value).equals(actual); + } + } else if (type.equals("long")) { + if (isArray) { + ok = actual.getClass().getComponentType().equals(long.class); + } else { + ok = Long.valueOf(value).equals(actual); + } + } else if (type.equals("float")) { + if (isArray) { + ok = actual.getClass().getComponentType().equals(float.class); + } else { + ok = Float.valueOf(value).equals(actual); + } + } else if (type.equals("double")) { + if (isArray) { + ok = actual.getClass().getComponentType().equals(double.class); + } else { + ok = Double.valueOf(value).equals(actual); + } + } else if (type.equals("char")) { + if (isArray) { + ok = actual.getClass().getComponentType().equals(char.class); + } else { + ok = Character.valueOf(value.charAt(1)).equals(actual); + } + // next check Class + } else if (type.equals("java.lang.Class")) { + if (isArray) { + ok = actual.getClass().getComponentType().equals(Class.class); + } else { + // strip ".class" from type name + int offset = value.indexOf(".class"); + value = value.substring(0, offset); + ok = getClass(value).equals(actual); + } + // next check String + } else if (type.equals("java.lang.String")) { + if (isArray) { + ok = actual.getClass().getComponentType().equals(String.class); + } else { + // cut off '\"' chars at begin and end + final String s; + if (value.length() > 1) { + s = value.substring(1, value.length() - 1); + } else { + s = ""; + } + ok = (String.valueOf(s)).equals(actual); + } + // now check non-java.lang annotations and enums + } else { + expClass = getClass(type); + if (isArray) { + // check if the actual component type is the right class + // don't check the actual values because only empty arrays + // are supported. + ok = actual.getClass().getComponentType().equals(expClass); + } else if (expClass == null) { + System.out.println("WARNING : checkValue value=" + value + " type=" + type + " comes up with null class"); + ok = false; + } else if (expClass.isAnnotation()) { + // check whether the type isAssignableFrom the class of the actual value, + // if type is an annotation. The actual value is a dynamic proxy, + // so an equals comparison does not work. + ok = expClass.isAssignableFrom(actual.getClass()); + } else { + // get the actual value which must be a static class.field + Object expectedValue = null; + try { + // now get actual value + // separate value name into class and field name + int lastDot = value.lastIndexOf("."); + String expectedClassName = value.substring(0, lastDot); + String expectedFieldName = + value.substring(lastDot + 1, value.length()); + // get Class object from class name + Class expectedClass = getClass(expectedClassName); + if (expectedClass == null) + throw new ClassNotFoundException(); + // get Field object from Class and field name + Field expectedField = + expectedClass.getField(expectedFieldName); + expectedValue = expectedField.get(null); + } catch (NoSuchFieldException ex) { + handleNotLoading(ex); + } catch (SecurityException ex) { + handleNotLoading(ex); + } catch (IllegalArgumentException ex) { + handleNotLoading(ex); + } catch (IllegalAccessException ex) { + handleNotLoading(ex); + } catch (ClassNotFoundException ex) { + handleNotLoading(ex); + } + ok = expectedValue.equals(actual); + } + } + // return message if not ok + if (ok) return null; + else return value; } /** - * Parses the default value specification of an annotation element and validates that it is an - * element value, which is either an annotation or a constant. - * - * @return never null - * @throws IOException IO error - * @throws ParseException parsing error + * Validates a field against a prescribed signature. + * @param mods modifier + * @param type type + * @param name name + * @param value value */ - protected String demandElementValue() throws IOException, ParseException { - final String annotation = parseAnnotation(); - if (annotation != null) { - return annotation; - } - final String constant = demandConstant(); - if (constant == null) { - throw new ParseException(msgUnexpectedToken(parseToken()), 0); - } - return constant; - } + protected void checkField(int mods, String type, String name, + String value) { + tested++; + type = TypeHelper.qualifiedUserTypeName(type); - /** - * Parses any available Java modifiers. - * - * @return an int value with the parsed modifiers' bit set - * @throws IOException IO error - * @throws ParseException parsing error - */ - protected int parseModifiers() throws IOException, ParseException { - int m = 0; - while (true) { - // parse known modifiers - final String t = parseToken(); - if (t.equals("abstract")) m |= Modifier.ABSTRACT; - else if (t.equals("annotation")) m |= (ANNOTATION + Modifier.ABSTRACT + Modifier.INTERFACE); - else if (t.equals("enum")) m |= ENUM; - else if (t.equals("final")) m |= Modifier.FINAL; - else if (t.equals("interface")) m |= Modifier.INTERFACE; - else if (t.equals("native")) m |= Modifier.NATIVE; - else if (t.equals("private")) m |= Modifier.PRIVATE; - else if (t.equals("protected")) m |= Modifier.PROTECTED; - else if (t.equals("public")) m |= Modifier.PUBLIC; - else if (t.equals("static")) m |= Modifier.STATIC; - else if (t.equals("strictfp")) m |= Modifier.STRICT; - else if (t.equals("synchronized")) m |= Modifier.SYNCHRONIZED; - else if (t.equals("transient")) m |= Modifier.TRANSIENT; - else if (t.equals("varargs")) m |= Modifier.TRANSIENT; - else if (t.equals("volatile")) m |= Modifier.VOLATILE; - else { - setLookAhead(t); // not a modifier - break; - } - } - // log.println("parseModifiers() : '" + Modifier.toString(m) + "'"); - return m; - } + // get field + final Field field; + try { + field = cls.getDeclaredField(name); + } catch (NoSuchFieldException ex) { + handleMissing( + "missing field: ", + Formatter.toString(mods, type, name, value)); + return; + } catch (LinkageError err) { + handleNotLoading(err); + return; + } - /** - * Parses a (qualified) identifier. - * - * @return null if the next token is not an identifier - * @throws IOException IO error - * @throws ParseException parsing error - */ - protected String parseIdentifier() throws IOException, ParseException { - String t = scanIdentifier(); - if (t != null) { - // parse dot-connected identifiers - final StringBuffer id = new StringBuffer(t); - String tt = parseToken(); - while (tt.equals(".")) { - id.append("."); - tt = parseIdentifier(); - if (tt == null) { - throw new ParseException(msgUnexpectedToken(tt), 0); - } - id.append(tt); - tt = parseToken(); - } - setLookAhead(tt); // not a dot token - t = id.toString(); - } - // log.println("parseIdentifier() : '" + t + "'"); - return t; + // check modifiers + if (cls.isInterface()) { + // fields interfaces are implicitly public, static, and final + mods |= Modifier.PUBLIC; + mods |= Modifier.STATIC; + mods |= Modifier.FINAL; + } + if (mods != convertModifiers(field)) { + handleMismatch( + "field declaration: non-matching modifiers;", + Formatter.toString(mods, type, name, null), + Formatter.toString(field, null)); + } + + // check type + if (!TypeHelper.isNameMatch(type, field.getType())) { + handleMismatch( + "field declaration: non-matching type;", + Formatter.toString(mods, type, name, null), + Formatter.toString(field, null)); + } + + // check field value if any + Object actualValue = null; + if (value != null) { + // only support for public, static, and final fields + final int m = (Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL); + if ((mods & m) == 0) { + handleProblem("field declaration: ignoring field value " + + "definition in descriptor file;", + Formatter.toString(mods, type, name, value)); + } else { + // compare field's expected with found value + try { + actualValue = field.get(null); + } catch (IllegalAccessException ex) { + handleProblem("field declaration: cannot access field " + + "value, exception: " + ex + ";", + Formatter.toString(mods, type, name, value)); + } + String error = checkValue(value, type, actualValue); + if (error != null) { + handleMismatch( + "field declaration: non-matching values;", + Formatter.toString(mods, type, name, error), + Formatter.toString(field, "\"" + actualValue + "\"")); + } + } + } + + // field OK + members.remove(field); + handleMatch("has field: ", Formatter.toString(field, actualValue)); } /** - * Parses the next token(s) and validates that it is an identifier. - * - * @return never null - * @throws IOException IO error - * @throws ParseException parsing error + * Validates a constructor against a prescribed signature. + * @param mods modifier + * @param params parameters + * @param excepts excepts */ - protected String demandIdentifier() throws IOException, ParseException { - final String id = parseIdentifier(); - if (id == null) { - throw new ParseException(msgUnexpectedToken(parseToken()), 0); - } - return id; - } + protected void checkConstructor(int mods, String[] params, + String[] excepts) { + tested++; + params = TypeHelper.qualifiedUserTypeNames(params); + excepts = TypeHelper.qualifiedUserTypeNames(excepts); + + // get parameter classes + final Class[] prms = getClasses(params); + if (prms == null) { + return; + } + + // get constructor + final Constructor ctor; + try { + ctor = cls.getDeclaredConstructor(prms); + } catch (NoSuchMethodException ex) { + String name = cls.getName(); + final int i = name.lastIndexOf('.'); + name = (i < 0 ? name : name.substring(i)); + handleMissing( + "missing constructor: ", + Formatter.toString(mods, null, name, params, excepts)); + return; + } catch (LinkageError err) { + handleNotLoading(err); + return; + } + + // check modifiers + if (mods != ctor.getModifiers()) { + handleMismatch( + "constructor declaration: non-matching modifiers;", + Formatter.toString(mods, null, cls.getName(), params, excepts), + Formatter.toString(ctor)); + } + // check exceptions + if (!TypeHelper.isNameMatch(excepts, ctor.getExceptionTypes())) { + handleMismatch( + "method declaration: non-matching exceptions;", + Formatter.toString(mods, null, cls.getName(), params, excepts), + Formatter.toString(ctor)); + } + + // constructor OK + members.remove(ctor); + handleMatch("has constructor: ", Formatter.toString(ctor)); + } + /** - * Parses a comma-separated list of identifiers. - * - * @return never null - * @throws IOException IO error - * @throws ParseException parsing error + * Validates a method against a prescribed signature. + * @param mods modifier + * @param result result + * @param name name + * @param params parameters + * @param excepts excepts + * @param value value */ - protected String[] demandIdentifierList() throws IOException, ParseException { - final ArrayList ids = new ArrayList(); - ids.add(demandIdentifier()); - String t; - while ((t = parseToken()).equals(",")) { - ids.add(demandIdentifier()); - } - setLookAhead(t); // not an identifier - return (String[]) ids.toArray(new String[ids.size()]); + protected void checkMethod(int mods, String result, String name, + String[] params, String[] excepts, + String value) { + tested++; + params = TypeHelper.qualifiedUserTypeNames(params); + excepts = TypeHelper.qualifiedUserTypeNames(excepts); + result = TypeHelper.qualifiedUserTypeName(result); + + // get parameter classes + final Class[] prms = getClasses(params); + if (prms == null) { + return; + } + + // get method + final Method method; + try { + method = cls.getDeclaredMethod(name, prms); + } catch (NoSuchMethodException ex) { + handleMissing( + "missing method: ", + Formatter.toString(mods, result, name, params, excepts)); + return; + } catch (LinkageError err) { + handleNotLoading(err); + return; + } + + // check modifiers + if (cls.isInterface()) { + // methods in interfaces are implicitly public + mods |= Modifier.PUBLIC; + } + Class resultType = getClass(result); + if (resultType == null) { + System.out.println("WARNING : checkMethod " + name + " result=" + result + " comes up with null resultType!"); + } else if (resultType.isAnnotation()) { + // add ANNOTATION modifier if the result type is an annotation + mods |= ANNOTATION; + } + if (mods != convertModifiers(method)) { + handleMismatch( + "method declaration: non-matching modifiers;", + Formatter.toString(mods, result, name, params, excepts), + Formatter.toString(method)); + } + + // check return type + if (!TypeHelper.isNameMatch(result, method.getReturnType())) { + handleMismatch( + "method declaration: non-matching return type", + Formatter.toString(mods, result, name, params, excepts), + Formatter.toString(method)); + } + + // check exceptions + if (!TypeHelper.isNameMatch(excepts, method.getExceptionTypes())) { + handleMismatch( + "method declaration: non-matching exceptions;", + Formatter.toString(mods, result, name, params, excepts), + Formatter.toString(method)); + } + + // check default value of an annotation element (method) + if (value != null) { + Object actualValue = null; + try { + actualValue = method.getDefaultValue(); + } catch (Exception ex) { + handleProblem("method declaration: cannot access default " + + "value, exception: " + ex + ";", + Formatter.toString(mods, result, name, value)); + } + // check value expected versus actual + String wrong = checkValue(value, result, actualValue); + + if (wrong != null) { + handleMismatch( + "method declaration: non-matching default value;", + Formatter.toString(mods, result, name + "() default ", wrong), + Formatter.toString(method)); + } + } + + // method OK + members.remove(method); + handleMatch("has method: ", Formatter.toString(method)); } /** - * Parses a type expression. - * - * @return null if the next token is not a type - * @throws IOException IO error - * @throws ParseException parsing error + * Validates a class declaration against a prescribed signature. + * @param mods modifier + * @param name name + * @param ext ext + * @param impl implementation */ - protected String parseType() throws IOException, ParseException { - String t = parseIdentifier(); - if (t != null) { - // parse array dimensions - final StringBuffer type = new StringBuffer(t); - while ((t = parseToken()).equals("[")) { - demandToken("]"); - type.append("[]"); - } - setLookAhead(t); // not an open bracket token - t = type.toString(); - } - // log.println("parseType() : '" + t + "'"); - return t; + protected void checkClass(int mods, String name, + String[] ext, String[] impl) { + logVerbose(""); + logVerbose("testing " + Formatter.toString(mods, name, ext, impl)); + tested++; + ext = TypeHelper.qualifiedUserTypeNames(ext); + impl = TypeHelper.qualifiedUserTypeNames(impl); + + // get and assign currently processed class + cls = getClass(name); + if (cls == null) { + return; // can't load class + } + + // collect all declared members of current class + members.clear(); + try { + members.addAll(Arrays.asList(cls.getDeclaredFields())); + members.addAll(Arrays.asList(cls.getDeclaredConstructors())); + members.addAll(Arrays.asList(cls.getDeclaredMethods())); + } catch (LinkageError err) { + handleNotLoading(err); + } + + // check modifiers + final boolean isInterface = ((mods & Modifier.INTERFACE) != 0); + if (isInterface) { + mods |= Modifier.ABSTRACT; + } + if (mods != convertModifiers(cls)) { + handleMismatch( + "class declaration: non-matching modifiers;", + Formatter.toString(mods, name, ext, impl), + Formatter.toString(cls)); + } + + // check superclass and extended/implemented interfaces + final Class superclass = cls.getSuperclass(); + final Class[] interfaces = cls.getInterfaces(); + if (isInterface) { + //assert (impl.length == 0); + if (!TypeHelper.isNameMatch(ext, interfaces)) { + handleMismatch( + "interface declaration: non-matching interfaces;", + Formatter.toString(mods, name, ext, impl), + Formatter.toString(cls)); + } + } else { + //assert (ext.length <= 1); + final String s = (ext.length == 0 ? "java.lang.Object" : ext[0]); + if (!TypeHelper.isNameMatch(s, superclass)) { + handleMismatch( + "class declaration: non-matching superclass;", + Formatter.toString(mods, name, ext, impl), + Formatter.toString(cls)); + } + if (!TypeHelper.isNameMatch(impl, interfaces)) { + handleMismatch( + "class declaration: non-matching interfaces;", + Formatter.toString(mods, name, ext, impl), + Formatter.toString(cls)); + } + } + + handleMatch("has class: ", Formatter.toString(cls)); } - /** - * Parses the next token and validates that it is a type expression. - * - * @return never null - * @throws IOException IO error - * @throws ParseException parsing error - */ - protected String demandType() throws IOException, ParseException { - final String id = parseType(); - if (id == null) { - throw new ParseException(msgUnexpectedToken(parseToken()), 0); - } - return id; + /** Runs checks on a class after its members have been validated. */ + protected void postCheckClass() { + if (cls == null) { + return; // nothing to do if class couldn't be loaded + } + + // check for public non-standard members + for (Iterator i = members.iterator(); i.hasNext();) { + final Member m = (Member)i.next(); + if ((m.getModifiers() & Modifier.PUBLIC) != 0) { + handleNonStandard("non-standard, public member;", + Formatter.toString(m)); + } + } } - /** - * Parses a comma-separated parameter list. - * - * @return never null - * @throws IOException IO error - * @throws ParseException parsing error + /** Return modifiers for the class, but handling enum and annotation + * as if they had a special modifier. + * @param cls the class + * @return modifiers of the class with extra flags for enum and annotation */ - protected String[] parseParameterList() throws IOException, ParseException { - final ArrayList types = new ArrayList(); - String t = parseType(); - if (t != null) { - types.add(t); - parseIdentifier(); // optional parameter name - while ((t = parseToken()).equals(",")) { - types.add(demandType()); - parseIdentifier(); // optional parameter name - } - setLookAhead(t); // not a comma token - } - return (String[]) types.toArray(new String[types.size()]); + protected int convertModifiers(Class cls) { + int result = cls.getModifiers(); + // first remove extraneous stuff + result &= ALL_MODIFIERS; + // if enum, set pseudo enum flag + if (cls.isEnum()) + result |= ENUM; + // if annotation, set pseudo annotation flag + if (cls.isAnnotation()) + result |= ANNOTATION; + return result; + } + + /** Return modifiers for the method, but handling enum and annotation + * as if they had a special modifier. + * @param method the method + * @return modifiers of the class with extra flags for enum and annotation + */ + protected int convertModifiers(Method method) { + int result = method.getModifiers(); + // first remove extraneous stuff + result &= ALL_MODIFIERS; + // if enum return type, set pseudo enum flag + if (method.getReturnType().isEnum()) + result |= ENUM; + // if annotation, set pseudo annotation flag + if (method.getReturnType().isAnnotation()) + result |= ANNOTATION; + // if return type is an enum class, un-set FINAL modifier in all methods + // because in Java 5, methods are generated as final; in Java 6, not + if (method.getDeclaringClass().isEnum()) + result &= ~Modifier.FINAL; + return result; + } + + /** Return modifiers for the field, but handling enum + * as if it had a special modifier. + * @param field the field + * @return modifiers of the class with extra flag for enum + */ + protected int convertModifiers(Field field) { + int result = field.getModifiers(); + // first remove extraneous stuff + result &= ALL_MODIFIERS; + // if enum, set pseudo enum flag + if (field.isEnumConstant()) + result |= ENUM; + return result; } + // ---------------------------------------------------------------------- + // Parser for Signature Descriptor Files + // ---------------------------------------------------------------------- + /** - * Parses a class member declaration and provides the information to a field, constructor, or - * method handler. - * - * @return null if there's no member declaration - * @throws IOException IO error - * @throws ParseException parsing error + * For parsing of signature descriptor files. */ - protected String parseMember() throws IOException, ParseException { - // parse optional modifiers, type, and member name - final int mods = parseModifiers(); - final String typeOrName = parseType(); - if (typeOrName == null) { - if (mods != 0) { - throw new ParseException(msgUnexpectedEOF(), 0); - } - return null; // no member to parse - } - final String memberName = parseIdentifier(); // null if constructor - - // parse optional field value or parameter+exception list - final String value; - final String[] params; - final String[] excepts; - { - final String tvp = parseToken(); - if (tvp.equals(";")) { - value = null; - params = null; - excepts = null; - } else if (tvp.equals("=")) { - // parse field value - value = demandLiteral(); - demandToken(";"); - params = null; - excepts = null; - } else if (tvp.equals("(")) { - // parse optional parameter and exception list - params = parseParameterList(); - demandToken(")"); - final String tt = parseToken(); - if (tt.equals("throws")) { - excepts = demandIdentifierList(); - demandToken(";"); - value = null; - } else if (tt.equals(";")) { - excepts = new String[] {}; - value = null; - } else if (tt.equals("default")) { - value = demandElementValue(); - demandToken(";"); - excepts = new String[] {}; - } else { - throw new ParseException(msgUnexpectedToken(tt), 0); - } - } else { - throw new ParseException(msgUnexpectedToken(tvp), 0); - } - } - - // verify field, constructor, or method - String name = memberName; - if (params == null) { - checkField(mods, typeOrName, memberName, value); - } else { - if (memberName == null) { - name = typeOrName; - checkConstructor(mods, params, excepts); - } else { - checkMethod(mods, typeOrName, memberName, params, excepts, value); + protected class Parser { + /** The current descriptor file being parsed. */ + private File descriptorFile; + + /** The line number reader for the current descriptor file. */ + private LineNumberReader ir; + + /** A look-ahead token to be read next. */ + private String nextToken; + + /** + * Returns an error message reporting an unexpected end of file. + * @return message + */ + protected String msgUnexpectedEOF() { + return ("unexpected end of file at line: " + ir.getLineNumber() + + ", file: " + descriptorFile.getPath()); } - } - // log.println("parseMember() : " + name); - return name; - } + /** + * Returns an error message reporting an unextected token. + * @param t token + * @return error message + */ + protected String msgUnexpectedToken(String t) { + return ("unexpected token: '" + t + "'" + + " in line: " + ir.getLineNumber() + + ", file: " + descriptorFile.getPath()); + } - /** - * Parses a class definition and provides the information to a handler. - * - * @return null if there's no class definition - * @throws IOException IO error - * @throws ParseException parsing error - */ - @SuppressWarnings("empty-statement") - protected String parseClass() throws IOException, ParseException { - // parse optional modifiers, class token, and class name - if (!skip()) { - return null; // eof, no class to parse - } - final int mods = parseModifiers(); - final String tc = parseToken(); - if (!tc.equals("class")) { // token 'interface' parsed as modifier - setLookAhead(tc); - } - final String name = demandIdentifier(); - - // parse optional extends and implements clauses - final String[] ext; - final String[] impl; - { - String tei = parseToken(); - if (tei.equals("extends")) { - ext = demandIdentifierList(); - tei = parseToken(); - } else { - ext = new String[] {}; + /** + * Retrieves the look-ahead token to be parsed next. + * @return look ahead + */ + protected String getLookAhead() { + final String t = nextToken; + nextToken = null; + return t; } - if (((mods & Modifier.INTERFACE) == 0) && tei.equals("implements")) { - impl = demandIdentifierList(); - tei = parseToken(); - } else { - impl = new String[] {}; + + /** + * Sets the look-ahead token to be parsed next. + * @param t token + */ + protected void setLookAhead(String t) { + //assert (nextToken == null); + nextToken = t; + } + + /** + * Skips any "white space" and /* style comments + * and returns whether there are more + * characters to be parsed. + * @return true if there are more characters to be parsed + * @throws IOException IO error + */ + protected boolean skip() throws IOException { + Character c; + Character cnext; + // Permitted states are white, commentSlashStar, commentSlashSlash + String state = "white"; + final Character SLASH = '/'; + final Character STAR = '*'; + while (true) { + c = peek(); + if (c == null) + return false; + if (state.equals("commentSlashStar") && STAR.equals(c)) { + cnext = peek(); + if (cnext == null) + return false; + if (SLASH.equals(cnext)) { + state = "white"; + } + continue; + } + if (state.equals("white")) { + if (SLASH.equals(c)) { + cnext = peek(); + if (cnext == null) + return false; + if (STAR.equals(cnext)) { + state = "commentSlashStar"; + continue; + } + if (SLASH.equals(cnext)) { + state = "commentSlashSlash"; + continue; + } + } + if (!Character.isWhitespace(c)) { + break; + } + } + if (state.equals("commentSlashSlash") + && (c == Character.LINE_SEPARATOR + || c == '\n' + || c == '\r')) { + state = "white"; + continue; + } + } + ir.reset(); + return true; + } + + /** + * Returns next char, or null if there is none + * @return next char + * @throws IOException IO error + */ + protected Character peek() throws IOException { + ir.mark(1); + int i; + if ((i = ir.read()) < 0) { + return null; + } + return Character.valueOf((char)i); + } + + /** + * Scans for an (unqualified) identifier. + * @return null if the next token is not an identifier + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected String scanIdentifier() + throws IOException, ParseException { + // parse stored token if any + String t; + if ((t = getLookAhead()) != null) { + if (!Character.isJavaIdentifierStart(t.charAt(0))) { + setLookAhead(t); // not an identifier + return null; + } + return t; + } + + // parse first char + if (!skip()) { + throw new ParseException(msgUnexpectedEOF(), 0); + } + ir.mark(1); + char c = (char)ir.read(); + if (!Character.isJavaIdentifierStart(c)) { + ir.reset(); // not start of an identifier + return null; + } + + // parse remaining chars + final StringBuffer sb = new StringBuffer(); + do { + sb.append(c); + int i; + ir.mark(1); + if ((i = ir.read()) < 0) + break; + c = (char)i; + } while (Character.isJavaIdentifierPart(c)); + ir.reset(); // not part of an identifier + return sb.toString(); + } + + /** + * Scans for a number literal. + * @return null if the next token is not a number + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected String scanNumberLiteral() + throws IOException, ParseException { + // parse stored token if any + String t; + if ((t = getLookAhead()) != null) { + if (!(t.charAt(0) == '-' || Character.isDigit(t.charAt(0)))) { + setLookAhead(t); // not a number literal + return null; + } + return t; + } + + // parse first char + if (!skip()) { + throw new ParseException(msgUnexpectedEOF(), 0); + } + ir.mark(1); + char c = (char)ir.read(); + if (Character.isDigit(c)) { + } else if (c == '-') { + skip(); + } else { + ir.reset(); // not start of a number + return null; + } + + // parse remaining chars + final StringBuffer sb = new StringBuffer(); + do { + sb.append(c); + int i; + ir.mark(1); + if ((i = ir.read()) < 0) + break; + c = (char)i; + } while (Character.isLetterOrDigit(c) || c == '-' || c == '.'); + ir.reset(); // not part of a number + return sb.toString(); + } + + /** + * Scans for a character literal. + * @return null if the next token is not a character + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected String scanCharacterLiteral() + throws IOException, ParseException { + // parse stored token if any + String t; + if ((t = getLookAhead()) != null) { + if (t.charAt(0) != '\'') { + setLookAhead(t); // not a char literal + return null; + } + return t; + } + + // parse first char + if (!skip()) { + throw new ParseException(msgUnexpectedEOF(), 0); + } + ir.mark(1); + char c = (char)ir.read(); + if (c != '\'') { + ir.reset(); // not start of a char literal + return null; + } + + // parse remaining two chars + final StringBuffer sb = new StringBuffer(); + for (int j = 0; j < 2; j++) { + sb.append(c); + int i; + if ((i = ir.read()) < 0) { + throw new ParseException(msgUnexpectedEOF(), 0); + } + c = (char)i; + } + if (c != '\'') { + throw new ParseException(msgUnexpectedToken(String.valueOf(c)), + 0); + } + sb.append(c); // keep '\'' part of a char literal + return sb.toString(); + } + + /** + * Scans for a string literal. + * @return null if the next token is not a string + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected String scanStringLiteral() + throws IOException, ParseException { + // parse stored token if any + String t; + if ((t = getLookAhead()) != null) { + if (t.charAt(0) != '\"') { + setLookAhead(t); // not a string literal + return null; + } + return t; + } + + // parse first char + if (!skip()) { + throw new ParseException(msgUnexpectedEOF(), 0); + } + ir.mark(1); + char c = (char)ir.read(); + if (c != '\"') { + ir.reset(); // not start of a string literal + return null; + } + + // parse remaining chars + final StringBuffer sb = new StringBuffer(); + do { + sb.append(c); + int i; + if ((i = ir.read()) < 0) { + throw new ParseException(msgUnexpectedEOF(), 0); + } + c = (char)i; + } while (c != '\"'); // not supported: nested '\"' char sequences + sb.append(c); // keep '\"' part of a string literal + return sb.toString(); + } + + /** + * Scans for an array literal. + * Limitation: only the empty array "{}" can be scanned. + * @return null if the next token is not an array + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected String scanArrayLiteral() + throws IOException, ParseException { + // parse stored token if any + String t; + if ((t = getLookAhead()) != null) { + if (t.charAt(0) != '{' || t.charAt(1) != '}') { + setLookAhead(t); // not an array literal + return null; + } + return t; + } + + // parse first char + if (!skip()) { + throw new ParseException(msgUnexpectedEOF(), 0); + } + ir.mark(1); + char c = (char)ir.read(); + if (c != '{') { + ir.reset(); // not start of an array literal + return null; + } + c = (char)ir.read(); + if (c != '}') { + ir.reset(); // not end of an array literal + return null; + } + + return "{}"; + } + + /** + * Scans for an at-sign + * @return null if the next token is not an at-sign + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected String scanAtSign() + throws IOException, ParseException { + // parse stored token if any + String t; + if ((t = getLookAhead()) != null) { + if (t.charAt(0) != '@') { + setLookAhead(t); // not an at-sign + return null; + } + return t; + } + + // parse first char + if (!skip()) { + throw new ParseException(msgUnexpectedEOF(), 0); + } + ir.mark(1); + char c = (char)ir.read(); + if (c != '@') { + ir.reset(); // not an at-sign + return null; + } + + return "@"; + } + + /** + * Returns the next token to be parsed. + * @return never null + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected String parseToken() + throws IOException, ParseException { + String t; + if ((t = getLookAhead()) != null) { + } else if ((t = scanIdentifier()) != null) { + } else if ((t = scanNumberLiteral()) != null) { + } else if ((t = scanStringLiteral()) != null) { + } else if ((t = scanCharacterLiteral()) != null) { + } else if ((t = scanAtSign()) != null) { + } else { + setLookAhead(t); // not an identifier, number, or string + // next non-white char + if (!skip()) { + throw new ParseException(msgUnexpectedEOF(), 0); + } + t = String.valueOf((char)ir.read()); + } + //log.println("parseToken() : '" + t + "'"); + return t; + } + + /** + * Parses the next token and validates it against an expected one. + * @param token the token + * @return never null + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected String demandToken(String token) + throws IOException, ParseException { + final String t = parseToken(); + if (!t.equals(token)) { + throw new ParseException(msgUnexpectedToken(t), 0); + } + return t; + } + + /** + * Parses a literal. + * @return null if the next token is not a literal + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected String parseLiteral() + throws IOException, ParseException { + String t; + if ((t = scanNumberLiteral()) != null) { + } else if ((t = scanStringLiteral()) != null) { + } else if ((t = scanCharacterLiteral()) != null) { + } else if ((t = scanArrayLiteral()) != null) { + } + //log.println("parseLiteral() : '" + t + "'"); + return t; + } + + /** + * Parses the next token and validates that it is a literal. + * @return never null + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected String demandLiteral() + throws IOException, ParseException { + final String l = parseLiteral(); + if (l == null) { + throw new ParseException(msgUnexpectedToken(parseToken()), 0); + } + return l; + } + + /** + * Parses the next token and validates that it is a constant, + * which is either a literal or a static member. + * @return the description of the field + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected String demandConstant() + throws IOException, ParseException { + final String literal = parseLiteral(); + if (literal != null) { + return literal; + } + final String field = demandIdentifier(); + if (field == null) { + throw new ParseException(msgUnexpectedToken(parseToken()), 0); + } + return field; + } + + /** + * Parses an annotation which is an at-sign followed by a fully qualified interface name. + * @return null if the next token is not an annotation, otherwise return + * the annotation type name without the at-sign. + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected String parseAnnotation() + throws IOException, ParseException { + String t; + // parse stored token if any + if ((t = getLookAhead()) != null) { + if (t.charAt(0) != '@') { + setLookAhead(t); // not a annotation + return null; + } + } else if ((t = scanAtSign()) != null) { + } else { + return null; + } + + final String identifier = demandIdentifier(); + if (identifier == null) { + throw new ParseException(msgUnexpectedToken(parseToken()), 0); + } + + return identifier; + } + + /** + * Parses the default value specification of an annotation element and validates + * that it is an element value, which is either an annotation or a constant. + * @return never null + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected String demandElementValue() + throws IOException, ParseException { + final String annotation = parseAnnotation(); + if (annotation != null) { + return annotation; + } + final String constant = demandConstant(); + if (constant == null) { + throw new ParseException(msgUnexpectedToken(parseToken()), 0); + } + return constant; + } + + /** + * Parses any available Java modifiers. + * @return an int value with the parsed modifiers' bit set + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected int parseModifiers() + throws IOException, ParseException { + int m = 0; + while (true) { + // parse known modifiers + final String t = parseToken(); + if (t.equals("abstract")) m |= Modifier.ABSTRACT; + else if (t.equals("annotation")) m |= + (ANNOTATION + Modifier.ABSTRACT + Modifier.INTERFACE); + else if (t.equals("enum")) m |= ENUM; + else if (t.equals("final")) m |= Modifier.FINAL; + else if (t.equals("interface")) m |= Modifier.INTERFACE; + else if (t.equals("native")) m |= Modifier.NATIVE; + else if (t.equals("private")) m |= Modifier.PRIVATE; + else if (t.equals("protected")) m |= Modifier.PROTECTED; + else if (t.equals("public")) m |= Modifier.PUBLIC; + else if (t.equals("static")) m |= Modifier.STATIC; + else if (t.equals("strictfp")) m |= Modifier.STRICT; + else if (t.equals("synchronized")) m |= Modifier.SYNCHRONIZED; + else if (t.equals("transient")) m |= Modifier.TRANSIENT; + else if (t.equals("varargs")) m |= Modifier.TRANSIENT; + else if (t.equals("volatile")) m |= Modifier.VOLATILE; + else { + setLookAhead(t); // not a modifier + break; + } + } + //log.println("parseModifiers() : '" + Modifier.toString(m) + "'"); + return m; + } + + /** + * Parses a (qualified) identifier. + * @return null if the next token is not an identifier + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected String parseIdentifier() + throws IOException, ParseException { + String t = scanIdentifier(); + if (t != null) { + // parse dot-connected identifiers + final StringBuffer id = new StringBuffer(t); + String tt = parseToken(); + while (tt.equals(".")) { + id.append("."); + tt = parseIdentifier(); + if (tt == null) { + throw new ParseException(msgUnexpectedToken(tt), 0); + } + id.append(tt); + tt = parseToken(); + } + setLookAhead(tt); // not a dot token + t = id.toString(); + } + //log.println("parseIdentifier() : '" + t + "'"); + return t; + } + + /** + * Parses the next token(s) and validates that it is an identifier. + * @return never null + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected String demandIdentifier() + throws IOException, ParseException { + final String id = parseIdentifier(); + if (id == null) { + throw new ParseException(msgUnexpectedToken(parseToken()), 0); + } + return id; + } + + /** + * Parses a comma-separated list of identifiers. + * @return never null + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected String[] demandIdentifierList() + throws IOException, ParseException { + final ArrayList ids = new ArrayList(); + ids.add(demandIdentifier()); + String t; + while ((t = parseToken()).equals(",")) { + ids.add(demandIdentifier()); + } + setLookAhead(t); // not an identifier + return (String[])ids.toArray(new String[ids.size()]); + } + + /** + * Parses a type expression. + * @return null if the next token is not a type + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected String parseType() + throws IOException, ParseException { + String t = parseIdentifier(); + if (t != null) { + // parse array dimensions + final StringBuffer type = new StringBuffer(t); + while ((t = parseToken()).equals("[")) { + demandToken("]"); + type.append("[]"); + } + setLookAhead(t); // not an open bracket token + t = type.toString(); + } + //log.println("parseType() : '" + t + "'"); + return t; + } + + /** + * Parses the next token and validates that it is a type expression. + * @return never null + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected String demandType() + throws IOException, ParseException { + final String id = parseType(); + if (id == null) { + throw new ParseException(msgUnexpectedToken(parseToken()), 0); + } + return id; + } + + /** + * Parses a comma-separated parameter list. + * @return never null + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected String[] parseParameterList() + throws IOException, ParseException { + final ArrayList types = new ArrayList(); + String t = parseType(); + if (t != null) { + types.add(t); + parseIdentifier(); // optional parameter name + while ((t = parseToken()).equals(",")) { + types.add(demandType()); + parseIdentifier(); // optional parameter name + } + setLookAhead(t); // not a comma token + } + return (String[])types.toArray(new String[types.size()]); + } + + /** + * Parses a class member declaration and provides the information + * to a field, constructor, or method handler. + * @return null if there's no member declaration + * @throws IOException IO error + * @throws ParseException parsing error + */ + protected String parseMember() + throws IOException, ParseException { + // parse optional modifiers, type, and member name + final int mods = parseModifiers(); + final String typeOrName = parseType(); + if (typeOrName == null) { + if (mods != 0) { + throw new ParseException(msgUnexpectedEOF(), 0); + } + return null; // no member to parse + } + final String memberName = parseIdentifier(); // null if constructor + + // parse optional field value or parameter+exception list + final String value; + final String[] params; + final String[] excepts; + { + final String tvp = parseToken(); + if (tvp.equals(";")) { + value = null; + params = null; + excepts = null; + } else if (tvp.equals("=")) { + // parse field value + value = demandLiteral(); + demandToken(";"); + params = null; + excepts = null; + } else if (tvp.equals("(")) { + // parse optional parameter and exception list + params = parseParameterList(); + demandToken(")"); + final String tt = parseToken(); + if (tt.equals("throws")) { + excepts = demandIdentifierList(); + demandToken(";"); + value = null; + } else if (tt.equals(";")) { + excepts = new String[]{}; + value = null; + } else if (tt.equals("default")) { + value = demandElementValue(); + demandToken(";"); + excepts = new String[]{}; + } else { + throw new ParseException(msgUnexpectedToken(tt), 0); + } + } else { + throw new ParseException(msgUnexpectedToken(tvp), 0); + } + } + + // verify field, constructor, or method + String name = memberName; + if (params == null) { + checkField(mods, typeOrName, memberName, value); + } else { + if (memberName == null) { + name = typeOrName; + checkConstructor(mods, params, excepts); + } else { + checkMethod(mods, typeOrName, memberName, params, excepts, value); + } + } + + //log.println("parseMember() : " + name); + return name; } - if (!tei.equals("{")) { - throw new ParseException(msgUnexpectedToken(tei), 0); + + /** + * Parses a class definition and provides the information + * to a handler. + * @return null if there's no class definition + * @throws IOException IO error + * @throws ParseException parsing error + */ + @SuppressWarnings("empty-statement") + protected String parseClass() + throws IOException, ParseException { + // parse optional modifiers, class token, and class name + if (!skip()) { + return null; // eof, no class to parse + } + final int mods = parseModifiers(); + final String tc = parseToken(); + if (!tc.equals("class")) { // token 'interface' parsed as modifier + setLookAhead(tc); + } + final String name = demandIdentifier(); + + // parse optional extends and implements clauses + final String[] ext; + final String[] impl; + { + String tei = parseToken(); + if (tei.equals("extends")) { + ext = demandIdentifierList(); + tei = parseToken(); + } else { + ext = new String[]{}; + } + if (((mods & Modifier.INTERFACE) == 0) + && tei.equals("implements")) { + impl = demandIdentifierList(); + tei = parseToken(); + } else { + impl = new String[]{}; + } + if (!tei.equals("{")) { + throw new ParseException(msgUnexpectedToken(tei), 0); + } + } + + // verify class header + checkClass(mods, name, ext, impl); + + // process members; empty-statement intentional + while (parseMember() != null); + demandToken("}"); + + // verify class + postCheckClass(); + + //log.println("parseClass() : " + name); + return name; } - } - // verify class header - checkClass(mods, name, ext, impl); + /** + * Parses a list of signature descriptor files and processes + * the class definitions. + * @param descrFileNames list of signature descriptor file names + * @throws IOException IO error + * @throws ParseException parsing error + */ + @SuppressWarnings("empty-statement") + public void parse(List descrFileNames) + throws IOException, ParseException { + for (Iterator i = descrFileNames.iterator(); i.hasNext();) { + final String fileName = (String)i.next(); + logInfo(""); + logInfo("parsing descriptor file: " + fileName); + try { + descriptorFile = new File(fileName); + ir = new LineNumberReader(new FileReader(descriptorFile)); + ir.setLineNumber(1); + setLookAhead(null); + // empty-statement intentional + while (parseClass() != null); + } finally { + descriptorFile = null; + if (ir != null) { + ir.close(); + } + setLookAhead(null); + } + } + } + } + + // ---------------------------------------------------------------------- + // Stand-Alone Command-Line Interface + // ---------------------------------------------------------------------- + + /** A writer for standard output. */ + static protected PrintWriter out = new PrintWriter(System.out, true); + + /** Command line arguments */ + static public final List descrFileNames = new ArrayList(); - // process members; empty-statement intentional - while (parseMember() != null) - ; - demandToken("}"); + /** Command line option 'quiet'.*/ + static private boolean optionQuiet; - // verify class - postCheckClass(); + /** Command line option 'verbose'.*/ + static private boolean optionVerbose; - // log.println("parseClass() : " + name); - return name; + /** Prints the CLI usage. */ + static public void printUsage() { + out.println(); + out.println("usage: SignatureVerifier [options] arguments"); + out.println("options:"); + out.println(" [-h|--help print usage and exit]"); + out.println(" [-q|--quiet only print error messages]"); + out.println(" [-v|--verbose print verbose messages]"); + out.println("arguments:"); + out.println(" ..."); + out.println(); } /** - * Parses a list of signature descriptor files and processes the class definitions. - * - * @param descrFileNames list of signature descriptor file names - * @throws IOException IO error - * @throws ParseException parsing error + * Parses command line arguments. + * @param args arguments + * @return status code */ - @SuppressWarnings("empty-statement") - public void parse(List descrFileNames) throws IOException, ParseException { - for (Iterator i = descrFileNames.iterator(); i.hasNext(); ) { - final String fileName = (String) i.next(); - logInfo(""); - logInfo("parsing descriptor file: " + fileName); - try { - descriptorFile = new File(fileName); - ir = new LineNumberReader(new FileReader(descriptorFile)); - ir.setLineNumber(1); - setLookAhead(null); - // empty-statement intentional - while (parseClass() != null) - ; - } finally { - descriptorFile = null; - if (ir != null) { - ir.close(); - } - setLookAhead(null); - } - } - } - } - - // ---------------------------------------------------------------------- - // Stand-Alone Command-Line Interface - // ---------------------------------------------------------------------- - - /** A writer for standard output. */ - protected static PrintWriter out = new PrintWriter(System.out, true); - - /** Command line arguments */ - public static final List descrFileNames = new ArrayList(); - - /** Command line option 'quiet'. */ - private static boolean optionQuiet; - - /** Command line option 'verbose'. */ - private static boolean optionVerbose; - - /** Prints the CLI usage. */ - public static void printUsage() { - out.println(); - out.println("usage: SignatureVerifier [options] arguments"); - out.println("options:"); - out.println(" [-h|--help print usage and exit]"); - out.println(" [-q|--quiet only print error messages]"); - out.println(" [-v|--verbose print verbose messages]"); - out.println("arguments:"); - out.println(" ..."); - out.println(); - } - - /** - * Parses command line arguments. - * - * @param args arguments - * @return status code - */ - public static int parseArgs(String args[]) { - out.println("parse main() arguments"); - - // parse this class' options and arguments - for (int i = 0; i < args.length; i++) { - if (args[i] == null) { - continue; - } - if (args[i].equalsIgnoreCase("-h") || args[i].equalsIgnoreCase("--help")) { - return -1; - } - if (args[i].equalsIgnoreCase("-v") || args[i].equalsIgnoreCase("--verbose")) { - optionVerbose = true; - continue; - } - if (args[i].equalsIgnoreCase("-q") || args[i].equalsIgnoreCase("--quiet")) { - optionQuiet = true; - continue; - } - if (args[i].startsWith("-")) { - out.println("Usage Error: unknown option " + args[i]); - return -1; - } - // collect argument - descrFileNames.add(args[i]); - } + static public int parseArgs(String args[]) { + out.println("parse main() arguments"); - // print args - if (false) { - out.println("descrFileNames = {"); - for (Iterator i = descrFileNames.iterator(); i.hasNext(); ) { - out.println(" " + i.next()); - } - out.println(" }"); - out.println("optionQuiet = " + optionQuiet); - out.println("optionVerbose = " + optionVerbose); - } + // parse this class' options and arguments + for (int i = 0; i < args.length; i++) { + if (args[i] == null) { + continue; + } + if (args[i].equalsIgnoreCase("-h") + || args[i].equalsIgnoreCase("--help")) { + return -1; + } + if (args[i].equalsIgnoreCase("-v") + || args[i].equalsIgnoreCase("--verbose")) { + optionVerbose = true; + continue; + } + if (args[i].equalsIgnoreCase("-q") + || args[i].equalsIgnoreCase("--quiet")) { + optionQuiet = true; + continue; + } + if (args[i].startsWith("-")) { + out.println("Usage Error: unknown option " + args[i]); + return -1; + } + // collect argument + descrFileNames.add(args[i]); + } - // check args - if (descrFileNames.isEmpty()) { - out.println("Usage Error: Missing argument " + "..."); - return -1; - } - return 0; - } - - /** - * Runs the signature test and exits with a status code. - * - * @param args command line arguments - */ - public static void main(String[] args) { - out.println("run SignatureVerifier ..."); - if (parseArgs(args) != 0) { - printUsage(); - out.println("abort."); - System.exit(-1); - } + // print args + if (false) { + out.println("descrFileNames = {"); + for (Iterator i = descrFileNames.iterator(); i.hasNext();) { + out.println(" " + i.next()); + } + out.println(" }"); + out.println("optionQuiet = " + optionQuiet); + out.println("optionVerbose = " + optionVerbose); + } - int status = 0; - try { - final SignatureVerifier s = new SignatureVerifier(out, optionQuiet, optionVerbose); - status = s.test(descrFileNames); - } catch (IOException ex) { - out.println("ERROR: exception caught: " + ex); - // ex.printStackTrace(); - out.println("abort."); - System.exit(-2); - } catch (ParseException ex) { - out.println("ERROR: exception caught: " + ex); - // ex.printStackTrace(); - out.println("abort."); - System.exit(-3); + // check args + if (descrFileNames.isEmpty()) { + out.println("Usage Error: Missing argument " + + "..."); + return -1; + } + return 0; } - out.println(); - out.println("done."); - System.exit(status); - } + /** + * Runs the signature test and exits with a status code. + * @param args command line arguments + */ + static public void main(String[] args) { + out.println("run SignatureVerifier ..."); + if (parseArgs(args) != 0) { + printUsage(); + out.println("abort."); + System.exit(-1); + } + + int status = 0; + try { + final SignatureVerifier s + = new SignatureVerifier(out, optionQuiet, optionVerbose); + status = s.test(descrFileNames); + } catch (IOException ex) { + out.println("ERROR: exception caught: " + ex); + //ex.printStackTrace(); + out.println("abort."); + System.exit(-2); + } catch (ParseException ex) { + out.println("ERROR: exception caught: " + ex); + //ex.printStackTrace(); + out.println("abort."); + System.exit(-3); + } + + out.println(); + out.println("done."); + System.exit(status); + } } diff --git a/tck/src/main/java/org/apache/jdo/tck/util/signature/TypeHelper.java b/tck/src/main/java/org/apache/jdo/tck/util/signature/TypeHelper.java index c724c2070..adef553cd 100644 --- a/tck/src/main/java/org/apache/jdo/tck/util/signature/TypeHelper.java +++ b/tck/src/main/java/org/apache/jdo/tck/util/signature/TypeHelper.java @@ -5,266 +5,269 @@ * 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 + * + * 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.jdo.tck.util.signature; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; +import java.lang.reflect.Member; +import java.lang.reflect.Modifier; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Constructor; + import java.util.Iterator; -import java.util.Map; import java.util.Set; +import java.util.Map; +import java.util.Arrays; +import java.util.HashSet; +import java.util.HashMap; -/** A helper class for translating between Java user type names and reflection type names. */ +/** + * A helper class for translating between Java user type names and + * reflection type names. + */ public class TypeHelper { - /** Error message for format errors with a user type name. */ - private static final String MSG_ILLEGAL_USR_TYPE = "illegal user type name: "; - - /** Error message for format errors with a reflection type name. */ - private static final String MSG_ILLEGAL_RFL_TYPE = "illegal reflection type name: "; + /** Error message for format errors with a user type name. */ + static private final String MSG_ILLEGAL_USR_TYPE + = "illegal user type name: "; + + /** Error message for format errors with a reflection type name. */ + static private final String MSG_ILLEGAL_RFL_TYPE + = "illegal reflection type name: "; + + /** Throws an IllegalArgumentException if a given condition is violated. */ + static private void check(boolean cond, String msg) { + if (!cond) throw new IllegalArgumentException(msg); + } - /** Throws an IllegalArgumentException if a given condition is violated. */ - private static void check(boolean cond, String msg) { - if (!cond) throw new IllegalArgumentException(msg); - } + /** Maps primitive reflection type names to (Java) user names. */ + static private final Map userTypeNames = new HashMap(); - /** Maps primitive reflection type names to (Java) user names. */ - private static final Map userTypeNames = new HashMap(); + /** Maps primitive (Java) user type names to reflection names. */ + static private final Map reflectionTypeNames = new HashMap(); - /** Maps primitive (Java) user type names to reflection names. */ - private static final Map reflectionTypeNames = new HashMap(); + /** Maps primitive type names to class objects. */ + static private final Map primitiveClasses = new HashMap(); - /** Maps primitive type names to class objects. */ - private static final Map primitiveClasses = new HashMap(); + // initializes the type maps + static { + userTypeNames.put("B", "byte"); + userTypeNames.put("C", "char"); + userTypeNames.put("D", "double"); + userTypeNames.put("F", "float"); + userTypeNames.put("I", "int"); + userTypeNames.put("J", "long"); + userTypeNames.put("S", "short"); + userTypeNames.put("Z", "boolean"); + userTypeNames.put("V", "void"); - // initializes the type maps - static { - userTypeNames.put("B", "byte"); - userTypeNames.put("C", "char"); - userTypeNames.put("D", "double"); - userTypeNames.put("F", "float"); - userTypeNames.put("I", "int"); - userTypeNames.put("J", "long"); - userTypeNames.put("S", "short"); - userTypeNames.put("Z", "boolean"); - userTypeNames.put("V", "void"); + for (Iterator i = userTypeNames.entrySet().iterator(); + i.hasNext();) { + final Map.Entry e = (Map.Entry)i.next(); + reflectionTypeNames.put(e.getValue(), e.getKey()); + } - for (Iterator i = userTypeNames.entrySet().iterator(); i.hasNext(); ) { - final Map.Entry e = (Map.Entry) i.next(); - reflectionTypeNames.put(e.getValue(), e.getKey()); + primitiveClasses.put("byte", byte.class); + primitiveClasses.put("char", char.class); + primitiveClasses.put("double", double.class); + primitiveClasses.put("float", float.class); + primitiveClasses.put("int", int.class); + primitiveClasses.put("long", long.class); + primitiveClasses.put("short", short.class); + primitiveClasses.put("boolean", boolean.class); + primitiveClasses.put("void", void.class); } - primitiveClasses.put("byte", byte.class); - primitiveClasses.put("char", char.class); - primitiveClasses.put("double", double.class); - primitiveClasses.put("float", float.class); - primitiveClasses.put("int", int.class); - primitiveClasses.put("long", long.class); - primitiveClasses.put("short", short.class); - primitiveClasses.put("boolean", boolean.class); - primitiveClasses.put("void", void.class); - } + /** + * Returns the (Java) user name for a reflection type name. + * @param name typed name + * @return user name for a reflection type name + */ + static public String userTypeName(String name) { + check(name != null, MSG_ILLEGAL_RFL_TYPE + name); - /** - * Returns the (Java) user name for a reflection type name. - * - * @param name typed name - * @return user name for a reflection type name - */ - public static String userTypeName(String name) { - check(name != null, MSG_ILLEGAL_RFL_TYPE + name); + // count array dimensions from start + final int n = name.length(); + check(n > 0, MSG_ILLEGAL_RFL_TYPE + name); + int i = 0; + final StringBuffer sb = new StringBuffer(); + while (name.charAt(i) == '[') { + sb.append("[]"); + i++; + check(i < n, MSG_ILLEGAL_RFL_TYPE + name); + } - // count array dimensions from start - final int n = name.length(); - check(n > 0, MSG_ILLEGAL_RFL_TYPE + name); - int i = 0; - final StringBuffer sb = new StringBuffer(); - while (name.charAt(i) == '[') { - sb.append("[]"); - i++; - check(i < n, MSG_ILLEGAL_RFL_TYPE + name); - } + // no translation of primitive type names if not an array type + if (i == 0) { + return name; + } - // no translation of primitive type names if not an array type - if (i == 0) { - return name; + // translate and recompose name + final String s; + if (name.charAt(i) == 'L') { + check(name.endsWith(";"), MSG_ILLEGAL_RFL_TYPE + name); + s = name.substring(i + 1, n - 1); + } else { + s = (String)userTypeNames.get(name.substring(i)); + check(s != null, MSG_ILLEGAL_RFL_TYPE + name); + } + return (s + sb.toString()); } - - // translate and recompose name - final String s; - if (name.charAt(i) == 'L') { - check(name.endsWith(";"), MSG_ILLEGAL_RFL_TYPE + name); - s = name.substring(i + 1, n - 1); - } else { - s = (String) userTypeNames.get(name.substring(i)); - check(s != null, MSG_ILLEGAL_RFL_TYPE + name); + + /** + * Returns the (Java) user names for reflection type names. + * @param names type names + * @return the (Java) user names for reflection type names. + */ + static public String[] userTypeNames(String[] names) { + final String[] u = new String[names.length]; + for (int i = names.length - 1; i >= 0; i--) { + u[i] = userTypeName(names[i]); + } + return u; } - return (s + sb.toString()); - } + + /** + * Returns the reflection name for a (Java) user type name. + * @param name type name + * @return reflection name for a (Java) user type name + */ + static public String reflectionTypeName(String name) { + check(name != null, MSG_ILLEGAL_USR_TYPE + name); - /** - * Returns the (Java) user names for reflection type names. - * - * @param names type names - * @return the (Java) user names for reflection type names. - */ - public static String[] userTypeNames(String[] names) { - final String[] u = new String[names.length]; - for (int i = names.length - 1; i >= 0; i--) { - u[i] = userTypeName(names[i]); - } - return u; - } + // count array dimensions from end + final int n = name.length(); + check(n > 0, MSG_ILLEGAL_USR_TYPE + name); + int i = n - 1; + final StringBuffer sb = new StringBuffer(); + while (name.charAt(i) == ']') { + i--; + check(name.charAt(i) == '[', MSG_ILLEGAL_USR_TYPE + name); + sb.append("["); + i--; + check(i >= 0, MSG_ILLEGAL_USR_TYPE + name); + } - /** - * Returns the reflection name for a (Java) user type name. - * - * @param name type name - * @return reflection name for a (Java) user type name - */ - public static String reflectionTypeName(String name) { - check(name != null, MSG_ILLEGAL_USR_TYPE + name); + // no translation of primitive type names if not an array type + if (++i == n) { + return name; + } - // count array dimensions from end - final int n = name.length(); - check(n > 0, MSG_ILLEGAL_USR_TYPE + name); - int i = n - 1; - final StringBuffer sb = new StringBuffer(); - while (name.charAt(i) == ']') { - i--; - check(name.charAt(i) == '[', MSG_ILLEGAL_USR_TYPE + name); - sb.append("["); - i--; - check(i >= 0, MSG_ILLEGAL_USR_TYPE + name); + // translate and recompose name + final String s = name.substring(0, i); + final String p = (String)reflectionTypeNames.get(s); + return sb.append(p != null ? p : "L" + s + ";").toString(); } - // no translation of primitive type names if not an array type - if (++i == n) { - return name; + /** + * Returns the (Java) user names for reflection type names. + * @param names type names + * @return the (Java) user names for reflection type names. + */ + static public String[] reflectionTypeNames(String[] names) { + final String[] r = new String[names.length]; + for (int i = names.length - 1; i >= 0; i--) { + r[i] = reflectionTypeName(names[i]); + } + return r; } - // translate and recompose name - final String s = name.substring(0, i); - final String p = (String) reflectionTypeNames.get(s); - return sb.append(p != null ? p : "L" + s + ";").toString(); - } - - /** - * Returns the (Java) user names for reflection type names. - * - * @param names type names - * @return the (Java) user names for reflection type names. - */ - public static String[] reflectionTypeNames(String[] names) { - final String[] r = new String[names.length]; - for (int i = names.length - 1; i >= 0; i--) { - r[i] = reflectionTypeName(names[i]); + /** + * Returns the class object for a primitive type name, or + * null if the name does not denote a primitive type + * (class objects of primitive types cannot be loaded with reflection). + * @param name type name + * @return class object + */ + static public Class primitiveClass(String name) { + return (Class)primitiveClasses.get(name); } - return r; - } - - /** - * Returns the class object for a primitive type name, or null if the name does not - * denote a primitive type (class objects of primitive types cannot be loaded with reflection). - * - * @param name type name - * @return class object - */ - public static Class primitiveClass(String name) { - return (Class) primitiveClasses.get(name); - } - /** - * Tests if a name denotes a primitive type. - * - * @param name type name - * @return true if a name denotes a primitive type. - */ - public static boolean isPrimitive(String name) { - return primitiveClasses.containsKey(name); - } + /** + * Tests if a name denotes a primitive type. + * @param name type name + * @return true if a name denotes a primitive type. + */ + static public boolean isPrimitive(String name) { + return primitiveClasses.containsKey(name); + } - /** - * Returns the component type name of a (Java) user type name. - * - * @param name type name - * @return component type name of a (Java) user type name - */ - public static String componentUserTypeName(String name) { - check(name != null, MSG_ILLEGAL_USR_TYPE + name); - final int n = name.length(); - check(n > 0, MSG_ILLEGAL_USR_TYPE + name); - final int i = name.indexOf('['); - if (i >= 0) { - check(i > 0, MSG_ILLEGAL_USR_TYPE + name); - name = name.substring(0, i); + /** + * Returns the component type name of a (Java) user type name. + * @param name type name + * @return component type name of a (Java) user type name + */ + static public String componentUserTypeName(String name) { + check(name != null, MSG_ILLEGAL_USR_TYPE + name); + final int n = name.length(); + check(n > 0, MSG_ILLEGAL_USR_TYPE + name); + final int i = name.indexOf('['); + if (i >= 0) { + check(i > 0, MSG_ILLEGAL_USR_TYPE + name); + name = name.substring(0, i); + } + return name; } - return name; - } - /** - * Returns the java.lang.-qualified name for a given unqualified (Java) user type - * name. - * - * @param name type name - * @return qualified name - */ - public static String qualifiedUserTypeName(String name) { - final String c = componentUserTypeName(name); - return ((isPrimitive(c) || c.indexOf('.') >= 0) ? name : "java.lang." + name); - } + /** + * Returns the java.lang.-qualified name for a given + * unqualified (Java) user type name. + * @param name type name + * @return qualified name + */ + static public String qualifiedUserTypeName(String name) { + final String c = componentUserTypeName(name); + return ((isPrimitive(c) || c.indexOf('.') >= 0) + ? name : "java.lang." + name); + } - /** - * Returns the java.lang.-qualified names for given unqualified (Java) user type - * names. - * - * @param names type names - * @return qualified name - */ - public static String[] qualifiedUserTypeNames(String[] names) { - final String[] q = new String[names.length]; - for (int i = names.length - 1; i >= 0; i--) { - q[i] = qualifiedUserTypeName(names[i]); + /** + * Returns the java.lang.-qualified names for given + * unqualified (Java) user type names. + * @param names type names + * @return qualified name + */ + static public String[] qualifiedUserTypeNames(String[] names) { + final String[] q = new String[names.length]; + for (int i = names.length - 1; i >= 0; i--) { + q[i] = qualifiedUserTypeName(names[i]); + } + return q; } - return q; - } - /** - * Compares a type name with a class objects for equality in the name. - * - * @param userTypeName type name - * @param cls class object - * @return true if name matches - */ - public static boolean isNameMatch(String userTypeName, Class cls) { - final String c = (cls == null ? null : userTypeName(cls.getName())); - return (userTypeName == null ? (c == null) : userTypeName.equals(c)); - } + /** + * Compares a type name with a class objects for equality in the name. + * @param userTypeName type name + * @param cls class object + * @return true if name matches + */ + static public boolean isNameMatch(String userTypeName, Class cls) { + final String c = (cls == null ? null : userTypeName(cls.getName())); + return (userTypeName == null ? (c == null) : userTypeName.equals(c)); + } - /** - * Compares an array of type names with an array of class objects for set-equality in the names - * (i.e., ignoring order). - * - * @param userTypeName type names - * @param cls class objects - * @return true if names matches - */ - public static boolean isNameMatch(String[] userTypeName, Class[] cls) { - final Set s = new HashSet(Arrays.asList(userTypeName)); - for (int i = cls.length - 1; i >= 0; i--) { - if (!s.remove(userTypeName(cls[i].getName()))) { - return false; - } + /** + * Compares an array of type names with an array of class objects + * for set-equality in the names (i.e., ignoring order). + * @param userTypeName type names + * @param cls class objects + * @return true if names matches + */ + static public boolean isNameMatch(String[] userTypeName, Class[] cls) { + final Set s = new HashSet(Arrays.asList(userTypeName)); + for (int i = cls.length - 1; i >= 0; i--) { + if (!s.remove(userTypeName(cls[i].getName()))) { + return false; + } + } + return s.isEmpty(); } - return s.isEmpty(); - } }